Skip to content

Commit 89b9d7b

Browse files
marcelobarretocodex
andcommitted
Add Customer Account EXAF address types
Expose structured extended address fields and address codes on the Customer Account mailing address API so public extension types and reference docs match the runtime data provided by Customer Account Web. Co-authored-by: GPT-5.5 <noreply@openai.com> Orchestrated-by: ae <noreply@shopify.com>
1 parent a0a4650 commit 89b9d7b

5 files changed

Lines changed: 294 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/ui-extensions': minor
3+
---
4+
5+
Add structured extended address fields to Customer Account order address APIs.

packages/ui-extensions/docs/surfaces/customer-account/build-docs.mjs

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,90 @@ const cleanupTempFiles = async (tempFiles) => {
6868
);
6969
};
7070

71+
const customerAccountMailingAddressFields = [
72+
{
73+
filePath: 'src/surfaces/customer-account/api/shared.ts',
74+
syntaxKind: 'PropertySignature',
75+
name: 'extendedFields',
76+
value: 'AddressExtendedFields',
77+
description:
78+
'Structured address components for countries and regions that collect them. Values are `null` when the address only has flat address lines.',
79+
isOptional: true,
80+
},
81+
{
82+
filePath: 'src/surfaces/customer-account/api/shared.ts',
83+
syntaxKind: 'PropertySignature',
84+
name: 'addressCode',
85+
value: 'string | null',
86+
description:
87+
'A country-specific address code, such as a short code or postal delivery code.',
88+
isOptional: true,
89+
examples: [
90+
{
91+
title: 'Example',
92+
description: '',
93+
tabs: [{code: "'01001-000'", title: 'Example'}],
94+
},
95+
],
96+
},
97+
];
98+
99+
const customerAccountMailingAddressValue = ` /**
100+
* Structured address components for countries and regions that collect them.
101+
* Values are \`null\` when the address only has flat address lines.
102+
*/
103+
extendedFields?: AddressExtendedFields;
104+
105+
/**
106+
* A country-specific address code, such as a short code or postal delivery code.
107+
*
108+
* @example '01001-000'
109+
*/
110+
addressCode?: string | null;
111+
112+
`;
113+
114+
const addCustomerAccountMailingAddressDocs = async (generatedDocsV2Path) => {
115+
const content = await fs.readFile(generatedDocsV2Path, 'utf8');
116+
const generatedDocs = JSON.parse(content);
117+
const mailingAddressDocs = generatedDocs.MailingAddress;
118+
119+
if (!mailingAddressDocs) return;
120+
121+
const [sourcePath] = Object.keys(mailingAddressDocs);
122+
const docs = mailingAddressDocs[sourcePath];
123+
124+
if (!docs?.members || !docs?.value) return;
125+
126+
const existingMemberNames = new Set(
127+
docs.members.map((member) => member.name),
128+
);
129+
130+
const missingFields = customerAccountMailingAddressFields.filter(
131+
(field) => !existingMemberNames.has(field.name),
132+
);
133+
134+
if (missingFields.length > 0) {
135+
const address2Index = docs.members.findIndex(
136+
(member) => member.name === 'address2',
137+
);
138+
const insertIndex = address2Index === -1 ? docs.members.length : address2Index + 1;
139+
docs.members.splice(insertIndex, 0, ...missingFields);
140+
}
141+
142+
if (!docs.value.includes('extendedFields?: AddressExtendedFields;')) {
143+
docs.value = docs.value.replace(
144+
' /**\n * The city, town, or village of the address.',
145+
`${customerAccountMailingAddressValue} /**\n * The city, town, or village of the address.`,
146+
);
147+
}
148+
149+
await fs.writeFile(
150+
generatedDocsV2Path,
151+
`${JSON.stringify(generatedDocs, null, 2)}\n`,
152+
);
153+
};
154+
71155
const generateExtensionsDocs = async () => {
72156
console.log(
73157
`Building Customer Account UI Extensions docs for ${EXTENSIONS_API_VERSION} version`,
@@ -98,12 +182,16 @@ const generateExtensionsDocs = async () => {
98182
replaceValue: '',
99183
});
100184

185+
const generatedDocsV2Path = path.join(outputDir, generatedDocsDataV2File);
186+
101187
// Replace 'unstable' with the exact API version in relative doc links
102188
await replaceFileContent({
103-
filePaths: path.join(outputDir, generatedDocsDataV2File),
189+
filePaths: generatedDocsV2Path,
104190
searchValue: '/docs/api//unstable/',
105191
replaceValue: `/docs/api/customer-account-ui-extensions/${EXTENSIONS_API_VERSION}`,
106192
});
193+
194+
await addCustomerAccountMailingAddressDocs(generatedDocsV2Path);
107195
};
108196

109197
let checkoutTempFiles = [];

0 commit comments

Comments
 (0)