@eide/foir-cli 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -0
- package/dist/codegen/fetch-customer-profile-schema.d.ts +12 -0
- package/dist/codegen/fetch-customer-profile-schema.d.ts.map +1 -0
- package/dist/codegen/fetch-customer-profile-schema.js +21 -0
- package/dist/codegen/fetch-models.d.ts.map +1 -1
- package/dist/codegen/field-mapping.d.ts.map +1 -1
- package/dist/codegen/field-mapping.js +60 -16
- package/dist/codegen/generators/customer-profile-types.d.ts +6 -0
- package/dist/codegen/generators/customer-profile-types.d.ts.map +1 -0
- package/dist/codegen/generators/customer-profile-types.js +45 -0
- package/dist/codegen/generators/model-types.d.ts.map +1 -1
- package/dist/codegen/generators/model-types.js +4 -2
- package/dist/codegen/generators/swift-customer-profile.d.ts +9 -0
- package/dist/codegen/generators/swift-customer-profile.d.ts.map +1 -0
- package/dist/codegen/generators/swift-customer-profile.js +152 -0
- package/dist/codegen/generators/swift-types.d.ts.map +1 -1
- package/dist/codegen/generators/swift-types.js +4 -2
- package/dist/codegen/write-files.d.ts.map +1 -1
- package/dist/commands/customer-profiles.d.ts +4 -0
- package/dist/commands/customer-profiles.d.ts.map +1 -0
- package/dist/commands/customer-profiles.js +97 -0
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +37 -11
- package/dist/config/pull-config.d.ts.map +1 -1
- package/dist/config/pull-config.js +6 -2
- package/dist/graphql/queries.d.ts +4 -0
- package/dist/graphql/queries.d.ts.map +1 -1
- package/dist/graphql/queries.js +13 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ import { registerRecordsCommands } from './commands/records.js';
|
|
|
19
19
|
import { registerModelsCommands } from './commands/models.js';
|
|
20
20
|
import { registerSearchCommands } from './commands/search.js';
|
|
21
21
|
import { registerCustomersCommands } from './commands/customers.js';
|
|
22
|
+
import { registerCustomerProfilesCommands } from './commands/customer-profiles.js';
|
|
22
23
|
import { registerSegmentsCommands } from './commands/segments.js';
|
|
23
24
|
import { registerExperimentsCommands } from './commands/experiments.js';
|
|
24
25
|
import { registerSettingsCommands } from './commands/settings.js';
|
|
@@ -61,6 +62,7 @@ registerRecordsCommands(program, getGlobalOpts);
|
|
|
61
62
|
registerModelsCommands(program, getGlobalOpts);
|
|
62
63
|
registerSearchCommands(program, getGlobalOpts);
|
|
63
64
|
registerCustomersCommands(program, getGlobalOpts);
|
|
65
|
+
registerCustomerProfilesCommands(program, getGlobalOpts);
|
|
64
66
|
registerSegmentsCommands(program, getGlobalOpts);
|
|
65
67
|
registerExperimentsCommands(program, getGlobalOpts);
|
|
66
68
|
registerSettingsCommands(program, getGlobalOpts);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches the customer profile schema from the platform GraphQL API for codegen.
|
|
3
|
+
*/
|
|
4
|
+
import type { GraphQLClient } from 'graphql-request';
|
|
5
|
+
import type { FieldSchemaForGen } from './field-mapping.js';
|
|
6
|
+
export interface CodegenCustomerProfileSchema {
|
|
7
|
+
id: string;
|
|
8
|
+
fields: FieldSchemaForGen[];
|
|
9
|
+
version: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function fetchCustomerProfileSchema(client: GraphQLClient): Promise<CodegenCustomerProfileSchema | null>;
|
|
12
|
+
//# sourceMappingURL=fetch-customer-profile-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-customer-profile-schema.d.ts","sourceRoot":"","sources":["../../src/codegen/fetch-customer-profile-schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,WAAW,4BAA4B;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAqBD,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CAiB9C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches the customer profile schema from the platform GraphQL API for codegen.
|
|
3
|
+
*/
|
|
4
|
+
import { CUSTOMER_PROFILE_SCHEMA } from '../graphql/queries.js';
|
|
5
|
+
export async function fetchCustomerProfileSchema(client) {
|
|
6
|
+
const data = await client.request(CUSTOMER_PROFILE_SCHEMA);
|
|
7
|
+
if (!data.customerProfileSchema)
|
|
8
|
+
return null;
|
|
9
|
+
return {
|
|
10
|
+
id: data.customerProfileSchema.id,
|
|
11
|
+
version: data.customerProfileSchema.version,
|
|
12
|
+
fields: (data.customerProfileSchema.fields ?? []).map((f) => ({
|
|
13
|
+
key: f.key,
|
|
14
|
+
type: f.type,
|
|
15
|
+
label: f.label,
|
|
16
|
+
required: f.required,
|
|
17
|
+
helpText: f.helpText,
|
|
18
|
+
options: f.config,
|
|
19
|
+
})),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-models.d.ts","sourceRoot":"","sources":["../../src/codegen/fetch-models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IAC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EAAE,OAAO,CAAA;CAAE,GACpD,YAAY,EAAE,CAahB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-mapping.d.ts","sourceRoot":"","sources":["../../src/codegen/field-mapping.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,qBAAqB,aAsBhC,CAAC;AAEH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"field-mapping.d.ts","sourceRoot":"","sources":["../../src/codegen/field-mapping.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,qBAAqB,aAsBhC,CAAC;AAEH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CA0D1D,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,iBAAiB,EACxB,IAAI,GAAE,QAAQ,GAAG,OAAkB,GAClC,MAAM,CAwCR;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAc3E;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,iBAAiB,EAAE,GAC1B,GAAG,CAAC,MAAM,CAAC,CAiBb;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAiFjE"}
|
|
@@ -30,26 +30,62 @@ export function isPrimitiveFieldType(type) {
|
|
|
30
30
|
}
|
|
31
31
|
export const FIELD_TYPE_MAPPING = {
|
|
32
32
|
text: { outputType: 'string', inputType: 'string' },
|
|
33
|
-
richtext: {
|
|
33
|
+
richtext: {
|
|
34
|
+
outputType: 'RichtextValue',
|
|
35
|
+
inputType: 'RichtextValue',
|
|
36
|
+
needsImport: 'field-types',
|
|
37
|
+
},
|
|
34
38
|
number: { outputType: 'number', inputType: 'number' },
|
|
35
39
|
boolean: { outputType: 'boolean', inputType: 'boolean' },
|
|
36
40
|
email: { outputType: 'string', inputType: 'string' },
|
|
37
41
|
phone: { outputType: 'string', inputType: 'string' },
|
|
38
42
|
url: { outputType: 'string', inputType: 'string' },
|
|
39
43
|
date: { outputType: 'Date', inputType: 'string' },
|
|
40
|
-
image: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
image: {
|
|
45
|
+
outputType: 'ImageValue',
|
|
46
|
+
inputType: 'string',
|
|
47
|
+
needsImport: 'field-types',
|
|
48
|
+
},
|
|
49
|
+
video: {
|
|
50
|
+
outputType: 'VideoValue',
|
|
51
|
+
inputType: 'string',
|
|
52
|
+
needsImport: 'field-types',
|
|
53
|
+
},
|
|
54
|
+
file: {
|
|
55
|
+
outputType: 'FileValue',
|
|
56
|
+
inputType: 'string',
|
|
57
|
+
needsImport: 'field-types',
|
|
58
|
+
},
|
|
59
|
+
currency: {
|
|
60
|
+
outputType: 'CurrencyValue',
|
|
61
|
+
inputType: 'CurrencyValue',
|
|
62
|
+
needsImport: 'field-types',
|
|
63
|
+
},
|
|
44
64
|
select: { outputType: 'string', inputType: 'string' },
|
|
45
65
|
multiselect: { outputType: 'string[]', inputType: 'string[]' },
|
|
46
66
|
json: { outputType: 'unknown', inputType: 'unknown' },
|
|
47
67
|
list: { outputType: 'unknown[]', inputType: 'unknown[]' },
|
|
48
68
|
tree: { outputType: 'unknown[]', inputType: 'unknown[]' },
|
|
49
|
-
flexible: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
flexible: {
|
|
70
|
+
outputType: 'FlexibleFieldItem[]',
|
|
71
|
+
inputType: 'FlexibleFieldItem[]',
|
|
72
|
+
needsImport: 'field-types',
|
|
73
|
+
},
|
|
74
|
+
'entity-reference': {
|
|
75
|
+
outputType: 'ReferenceValue',
|
|
76
|
+
inputType: 'ReferenceValue',
|
|
77
|
+
needsImport: 'field-types',
|
|
78
|
+
},
|
|
79
|
+
reference: {
|
|
80
|
+
outputType: 'ReferenceValue',
|
|
81
|
+
inputType: 'ReferenceValue',
|
|
82
|
+
needsImport: 'field-types',
|
|
83
|
+
},
|
|
84
|
+
link: {
|
|
85
|
+
outputType: 'LinkValue',
|
|
86
|
+
inputType: 'LinkValue',
|
|
87
|
+
needsImport: 'field-types',
|
|
88
|
+
},
|
|
53
89
|
};
|
|
54
90
|
export function getFieldType(field, mode = 'output') {
|
|
55
91
|
if (!field?.type)
|
|
@@ -73,7 +109,8 @@ export function getFieldType(field, mode = 'output') {
|
|
|
73
109
|
tsType = `(${options.map((o) => `'${o.value}'`).join(' | ')})[]`;
|
|
74
110
|
}
|
|
75
111
|
}
|
|
76
|
-
if ((field.type === 'list' || field.type === 'tree') &&
|
|
112
|
+
if ((field.type === 'list' || field.type === 'tree') &&
|
|
113
|
+
field.options?.itemType) {
|
|
77
114
|
const itemType = field.options.itemType;
|
|
78
115
|
const itemMapping = FIELD_TYPE_MAPPING[itemType];
|
|
79
116
|
if (itemMapping) {
|
|
@@ -91,7 +128,8 @@ export function getRequiredImports(fields) {
|
|
|
91
128
|
const mapping = FIELD_TYPE_MAPPING[field.type];
|
|
92
129
|
if (mapping?.needsImport)
|
|
93
130
|
imports.add(mapping.needsImport);
|
|
94
|
-
if ((field.type === 'list' || field.type === 'tree') &&
|
|
131
|
+
if ((field.type === 'list' || field.type === 'tree') &&
|
|
132
|
+
field.options?.itemType) {
|
|
95
133
|
const itemMapping = FIELD_TYPE_MAPPING[field.options.itemType];
|
|
96
134
|
if (itemMapping?.needsImport)
|
|
97
135
|
imports.add(itemMapping.needsImport);
|
|
@@ -105,7 +143,8 @@ export function getInlineSchemaReferences(fields) {
|
|
|
105
143
|
if (!isPrimitiveFieldType(field.type) && !FIELD_TYPE_MAPPING[field.type]) {
|
|
106
144
|
refs.add(field.type);
|
|
107
145
|
}
|
|
108
|
-
if ((field.type === 'list' || field.type === 'tree') &&
|
|
146
|
+
if ((field.type === 'list' || field.type === 'tree') &&
|
|
147
|
+
field.options?.itemType) {
|
|
109
148
|
const itemType = field.options.itemType;
|
|
110
149
|
if (!isPrimitiveFieldType(itemType) && !FIELD_TYPE_MAPPING[itemType]) {
|
|
111
150
|
refs.add(itemType);
|
|
@@ -156,7 +195,8 @@ export function generateFieldDef(field) {
|
|
|
156
195
|
if (field.options.step !== undefined)
|
|
157
196
|
parts.push(`step: ${field.options.step}`);
|
|
158
197
|
}
|
|
159
|
-
if ((field.type === 'select' || field.type === 'multiselect') &&
|
|
198
|
+
if ((field.type === 'select' || field.type === 'multiselect') &&
|
|
199
|
+
field.options?.options) {
|
|
160
200
|
const options = field.options.options;
|
|
161
201
|
const optionsStr = options
|
|
162
202
|
.filter((o) => o.value !== undefined)
|
|
@@ -168,20 +208,24 @@ export function generateFieldDef(field) {
|
|
|
168
208
|
.join(', ');
|
|
169
209
|
parts.push(`options: [${optionsStr}]`);
|
|
170
210
|
}
|
|
171
|
-
if ((field.type === 'entity-reference' || field.type === 'reference') &&
|
|
211
|
+
if ((field.type === 'entity-reference' || field.type === 'reference') &&
|
|
212
|
+
field.options?.referenceTypes) {
|
|
172
213
|
const refTypes = field.options.referenceTypes;
|
|
173
214
|
parts.push(`referenceTypes: [${refTypes.map((t) => `'${t}'`).join(', ')}]`);
|
|
174
215
|
if (field.options.multiple)
|
|
175
216
|
parts.push('multiple: true');
|
|
176
217
|
}
|
|
177
|
-
if ((field.type === 'list' || field.type === 'tree') &&
|
|
218
|
+
if ((field.type === 'list' || field.type === 'tree') &&
|
|
219
|
+
field.options?.itemType) {
|
|
178
220
|
parts.push(`itemType: '${field.options.itemType}'`);
|
|
179
221
|
if (field.options.minItems !== undefined)
|
|
180
222
|
parts.push(`minItems: ${field.options.minItems}`);
|
|
181
223
|
if (field.options.maxItems !== undefined)
|
|
182
224
|
parts.push(`maxItems: ${field.options.maxItems}`);
|
|
183
225
|
}
|
|
184
|
-
if ((field.type === 'image' ||
|
|
226
|
+
if ((field.type === 'image' ||
|
|
227
|
+
field.type === 'video' ||
|
|
228
|
+
field.type === 'file') &&
|
|
185
229
|
field.options) {
|
|
186
230
|
if (field.options.allowedTypes) {
|
|
187
231
|
const types = field.options.allowedTypes;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates TypeScript types for the customer profile schema.
|
|
3
|
+
*/
|
|
4
|
+
import type { CodegenCustomerProfileSchema } from '../fetch-customer-profile-schema.js';
|
|
5
|
+
export declare function generateCustomerProfileTypes(schema: CodegenCustomerProfileSchema): string;
|
|
6
|
+
//# sourceMappingURL=customer-profile-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-profile-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/customer-profile-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAQxF,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,4BAA4B,GACnC,MAAM,CAqCR"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates TypeScript types for the customer profile schema.
|
|
3
|
+
*/
|
|
4
|
+
import { getFieldType, sanitizeFieldName, FIELD_TYPE_MAPPING, } from '../field-mapping.js';
|
|
5
|
+
export function generateCustomerProfileTypes(schema) {
|
|
6
|
+
const fields = schema.fields ?? [];
|
|
7
|
+
const fieldTypeImports = getFieldTypeImportsForFields(fields);
|
|
8
|
+
let code = `/**
|
|
9
|
+
* Customer Profile Types
|
|
10
|
+
*
|
|
11
|
+
* @generated by foir from customer profile schema (version ${schema.version}) — DO NOT EDIT MANUALLY
|
|
12
|
+
*/\n\n`;
|
|
13
|
+
if (fieldTypeImports.size > 0) {
|
|
14
|
+
const types = Array.from(fieldTypeImports).sort().join(', ');
|
|
15
|
+
code += `import type { ${types} } from '../field-types.js';\n\n`;
|
|
16
|
+
}
|
|
17
|
+
code += `/**
|
|
18
|
+
* Customer Profile Data
|
|
19
|
+
* Typed field values for customer profiles
|
|
20
|
+
*
|
|
21
|
+
* @generated from customer profile schema (version ${schema.version})
|
|
22
|
+
*/\n`;
|
|
23
|
+
code += `export interface CustomerProfileData {\n`;
|
|
24
|
+
for (const field of fields) {
|
|
25
|
+
const fieldName = sanitizeFieldName(field.key);
|
|
26
|
+
const fieldType = getFieldType(field, 'output');
|
|
27
|
+
const optional = field.required ? '' : '?';
|
|
28
|
+
if (field.helpText) {
|
|
29
|
+
code += ` /** ${field.helpText} */\n`;
|
|
30
|
+
}
|
|
31
|
+
code += ` ${fieldName}${optional}: ${fieldType};\n`;
|
|
32
|
+
}
|
|
33
|
+
code += `}\n`;
|
|
34
|
+
return code;
|
|
35
|
+
}
|
|
36
|
+
function getFieldTypeImportsForFields(fields) {
|
|
37
|
+
const imports = new Set();
|
|
38
|
+
for (const field of fields) {
|
|
39
|
+
const mapping = FIELD_TYPE_MAPPING[field.type];
|
|
40
|
+
if (mapping?.needsImport === 'field-types') {
|
|
41
|
+
imports.add(mapping.outputType);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return imports;
|
|
45
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/model-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAgBvD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,YAAY,EAAE,GACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"model-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/model-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAgBvD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,YAAY,EAAE,GACxB,MAAM,CAyBR"}
|
|
@@ -119,7 +119,8 @@ function generateDataInterface(model, fields, interfaceName, allModels) {
|
|
|
119
119
|
fieldType = toPascalCase(field.type) + 'Data';
|
|
120
120
|
}
|
|
121
121
|
// Handle list/tree itemType refs
|
|
122
|
-
if ((field.type === 'list' || field.type === 'tree') &&
|
|
122
|
+
if ((field.type === 'list' || field.type === 'tree') &&
|
|
123
|
+
field.options?.itemType) {
|
|
123
124
|
const itemRefModel = allModels.find((m) => m.key === field.options.itemType);
|
|
124
125
|
if (itemRefModel && !isInlineOnlyModel(itemRefModel)) {
|
|
125
126
|
fieldType = toPascalCase(field.options.itemType) + 'Data[]';
|
|
@@ -139,7 +140,8 @@ function getFieldTypeImportsForFields(fields) {
|
|
|
139
140
|
if (mapping?.needsImport === 'field-types') {
|
|
140
141
|
imports.add(mapping.outputType);
|
|
141
142
|
}
|
|
142
|
-
if ((field.type === 'list' || field.type === 'tree') &&
|
|
143
|
+
if ((field.type === 'list' || field.type === 'tree') &&
|
|
144
|
+
field.options?.itemType) {
|
|
143
145
|
const itemMapping = FIELD_TYPE_MAPPING[field.options.itemType];
|
|
144
146
|
if (itemMapping?.needsImport === 'field-types') {
|
|
145
147
|
imports.add(itemMapping.outputType);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a Swift file for the customer profile schema with:
|
|
3
|
+
* - Field key enum (compile-time safe field keys)
|
|
4
|
+
* - Data struct (typed representation)
|
|
5
|
+
* - Serialization helpers (toSyncData / fromSyncData)
|
|
6
|
+
*/
|
|
7
|
+
import type { CodegenCustomerProfileSchema } from '../fetch-customer-profile-schema.js';
|
|
8
|
+
export declare function generateSwiftCustomerProfileFile(schema: CodegenCustomerProfileSchema): string;
|
|
9
|
+
//# sourceMappingURL=swift-customer-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swift-customer-profile.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/swift-customer-profile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAOxF,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,4BAA4B,GACnC,MAAM,CAgCR"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a Swift file for the customer profile schema with:
|
|
3
|
+
* - Field key enum (compile-time safe field keys)
|
|
4
|
+
* - Data struct (typed representation)
|
|
5
|
+
* - Serialization helpers (toSyncData / fromSyncData)
|
|
6
|
+
*/
|
|
7
|
+
import { getSwiftFieldType, SWIFT_FIELD_TYPE_MAPPING, } from '../swift-field-mapping.js';
|
|
8
|
+
export function generateSwiftCustomerProfileFile(schema) {
|
|
9
|
+
const typeName = 'CustomerProfile';
|
|
10
|
+
const fields = schema.fields ?? [];
|
|
11
|
+
const lines = [];
|
|
12
|
+
// Header
|
|
13
|
+
lines.push('//');
|
|
14
|
+
lines.push('// CustomerProfile.swift');
|
|
15
|
+
lines.push('//');
|
|
16
|
+
lines.push(`// Generated from customer profile schema (version ${schema.version})`);
|
|
17
|
+
lines.push('//');
|
|
18
|
+
lines.push('// @generated by foir \u2014 DO NOT EDIT MANUALLY');
|
|
19
|
+
lines.push('//');
|
|
20
|
+
lines.push('');
|
|
21
|
+
lines.push('import Foundation');
|
|
22
|
+
lines.push('');
|
|
23
|
+
// 1. Field key enum
|
|
24
|
+
lines.push(generateFieldsEnum(typeName, fields));
|
|
25
|
+
lines.push('');
|
|
26
|
+
// 2. Data struct
|
|
27
|
+
lines.push(generateDataStruct(typeName, fields));
|
|
28
|
+
lines.push('');
|
|
29
|
+
// 3. Serialization extension
|
|
30
|
+
lines.push(generateSerializationExtension(typeName, fields));
|
|
31
|
+
return lines.join('\n');
|
|
32
|
+
}
|
|
33
|
+
function generateFieldsEnum(typeName, fields) {
|
|
34
|
+
const lines = [];
|
|
35
|
+
lines.push(`// MARK: - ${typeName} Field Keys`);
|
|
36
|
+
lines.push('');
|
|
37
|
+
lines.push(`enum ${typeName}Fields {`);
|
|
38
|
+
for (const field of fields) {
|
|
39
|
+
lines.push(` static let ${field.key} = "${field.key}"`);
|
|
40
|
+
}
|
|
41
|
+
lines.push('}');
|
|
42
|
+
return lines.join('\n');
|
|
43
|
+
}
|
|
44
|
+
function generateDataStruct(typeName, fields) {
|
|
45
|
+
const lines = [];
|
|
46
|
+
lines.push(`// MARK: - ${typeName} Data`);
|
|
47
|
+
lines.push('');
|
|
48
|
+
lines.push(`struct ${typeName}Data {`);
|
|
49
|
+
for (const field of fields) {
|
|
50
|
+
const { type, isOptional } = getSwiftFieldType(field);
|
|
51
|
+
const optionalSuffix = isOptional ? '?' : '';
|
|
52
|
+
lines.push(` var ${field.key}: ${type}${optionalSuffix}`);
|
|
53
|
+
}
|
|
54
|
+
lines.push('}');
|
|
55
|
+
return lines.join('\n');
|
|
56
|
+
}
|
|
57
|
+
function generateSerializationExtension(typeName, fields) {
|
|
58
|
+
const lines = [];
|
|
59
|
+
lines.push(`// MARK: - ${typeName} Serialization`);
|
|
60
|
+
lines.push('');
|
|
61
|
+
lines.push(`extension ${typeName}Data {`);
|
|
62
|
+
// toSyncData()
|
|
63
|
+
lines.push(' func toSyncData() -> [String: Any] {');
|
|
64
|
+
const requiredFields = fields.filter((f) => {
|
|
65
|
+
const { isOptional } = getSwiftFieldType(f);
|
|
66
|
+
return !isOptional;
|
|
67
|
+
});
|
|
68
|
+
const optionalFields = fields.filter((f) => {
|
|
69
|
+
const { isOptional } = getSwiftFieldType(f);
|
|
70
|
+
return isOptional;
|
|
71
|
+
});
|
|
72
|
+
if (requiredFields.length > 0) {
|
|
73
|
+
if (optionalFields.length === 0) {
|
|
74
|
+
lines.push(' return [');
|
|
75
|
+
requiredFields.forEach((f, i) => {
|
|
76
|
+
const comma = i < requiredFields.length - 1 ? ',' : '';
|
|
77
|
+
lines.push(` ${typeName}Fields.${f.key}: ${toSyncValueExpr(f)}${comma}`);
|
|
78
|
+
});
|
|
79
|
+
lines.push(' ]');
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
lines.push(' var data: [String: Any] = [');
|
|
83
|
+
requiredFields.forEach((f, i) => {
|
|
84
|
+
const comma = i < requiredFields.length - 1 ? ',' : '';
|
|
85
|
+
lines.push(` ${typeName}Fields.${f.key}: ${toSyncValueExpr(f)}${comma}`);
|
|
86
|
+
});
|
|
87
|
+
lines.push(' ]');
|
|
88
|
+
for (const f of optionalFields) {
|
|
89
|
+
lines.push(` if let ${f.key} { data[${typeName}Fields.${f.key}] = ${toSyncValueExprForOptional(f)} }`);
|
|
90
|
+
}
|
|
91
|
+
lines.push(' return data');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
lines.push(' var data: [String: Any] = [:]');
|
|
96
|
+
for (const f of optionalFields) {
|
|
97
|
+
lines.push(` if let ${f.key} { data[${typeName}Fields.${f.key}] = ${toSyncValueExprForOptional(f)} }`);
|
|
98
|
+
}
|
|
99
|
+
lines.push(' return data');
|
|
100
|
+
}
|
|
101
|
+
lines.push(' }');
|
|
102
|
+
lines.push('');
|
|
103
|
+
// fromSyncData()
|
|
104
|
+
lines.push(' static func fromSyncData(_ data: [String: Any]) -> ' +
|
|
105
|
+
typeName +
|
|
106
|
+
'Data {');
|
|
107
|
+
lines.push(` ${typeName}Data(`);
|
|
108
|
+
fields.forEach((field, i) => {
|
|
109
|
+
const comma = i < fields.length - 1 ? ',' : '';
|
|
110
|
+
const { isOptional, mapping } = getSwiftFieldType(field);
|
|
111
|
+
lines.push(` ${field.key}: ${fromSyncDataExpr(field, typeName, isOptional, mapping)}${comma}`);
|
|
112
|
+
});
|
|
113
|
+
lines.push(' )');
|
|
114
|
+
lines.push(' }');
|
|
115
|
+
lines.push('}');
|
|
116
|
+
lines.push('');
|
|
117
|
+
return lines.join('\n');
|
|
118
|
+
}
|
|
119
|
+
function toSyncValueExpr(field) {
|
|
120
|
+
const mapping = SWIFT_FIELD_TYPE_MAPPING[field.type];
|
|
121
|
+
if (mapping?.needsSharedType) {
|
|
122
|
+
return `${field.key}.toSyncData()`;
|
|
123
|
+
}
|
|
124
|
+
return field.key;
|
|
125
|
+
}
|
|
126
|
+
function toSyncValueExprForOptional(field) {
|
|
127
|
+
const mapping = SWIFT_FIELD_TYPE_MAPPING[field.type];
|
|
128
|
+
if (mapping?.needsSharedType) {
|
|
129
|
+
return `${field.key}.toSyncData()`;
|
|
130
|
+
}
|
|
131
|
+
return field.key;
|
|
132
|
+
}
|
|
133
|
+
function fromSyncDataExpr(field, typeName, isOptional, mapping) {
|
|
134
|
+
const accessor = `data[${typeName}Fields.${field.key}]`;
|
|
135
|
+
if (!mapping) {
|
|
136
|
+
return isOptional ? `${accessor}` : `${accessor} ?? nil`;
|
|
137
|
+
}
|
|
138
|
+
if (mapping.needsSharedType) {
|
|
139
|
+
const dictCast = `${accessor} as? [String: Any]`;
|
|
140
|
+
if (isOptional) {
|
|
141
|
+
return `(${dictCast}).map { ${mapping.type}.fromSyncData($0) }`;
|
|
142
|
+
}
|
|
143
|
+
return `${mapping.type}.fromSyncData(${dictCast} ?? [:])`;
|
|
144
|
+
}
|
|
145
|
+
if (field.type === 'json') {
|
|
146
|
+
return isOptional ? accessor : `${accessor}`;
|
|
147
|
+
}
|
|
148
|
+
if (isOptional) {
|
|
149
|
+
return `${accessor} ${mapping.castExpression}`;
|
|
150
|
+
}
|
|
151
|
+
return `${accessor} ${mapping.castExpression} ?? ${mapping.defaultValue}`;
|
|
152
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swift-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/swift-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"swift-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/swift-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQvD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAkClE"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - Model config constant
|
|
7
7
|
*/
|
|
8
8
|
import { toPascalCase } from '../field-mapping.js';
|
|
9
|
-
import { getSwiftFieldType, SWIFT_FIELD_TYPE_MAPPING } from '../swift-field-mapping.js';
|
|
9
|
+
import { getSwiftFieldType, SWIFT_FIELD_TYPE_MAPPING, } from '../swift-field-mapping.js';
|
|
10
10
|
/**
|
|
11
11
|
* Generate a complete Swift file for a single model.
|
|
12
12
|
*/
|
|
@@ -112,7 +112,9 @@ function generateSerializationExtension(typeName, fields) {
|
|
|
112
112
|
lines.push(' }');
|
|
113
113
|
lines.push('');
|
|
114
114
|
// fromSyncData()
|
|
115
|
-
lines.push(' static func fromSyncData(_ data: [String: Any]) -> ' +
|
|
115
|
+
lines.push(' static func fromSyncData(_ data: [String: Any]) -> ' +
|
|
116
|
+
typeName +
|
|
117
|
+
'Data {');
|
|
116
118
|
lines.push(` ${typeName}Data(`);
|
|
117
119
|
fields.forEach((field, i) => {
|
|
118
120
|
const comma = i < fields.length - 1 ? ',' : '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-files.d.ts","sourceRoot":"","sources":["../../src/codegen/write-files.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,OAAc,GAC1B,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EAC/C,WAAW,GAAE,OAAc,GAC1B,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"write-files.d.ts","sourceRoot":"","sources":["../../src/codegen/write-files.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,OAAc,GAC1B,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EAC/C,WAAW,GAAE,OAAc,GAC1B,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-profiles.d.ts","sourceRoot":"","sources":["../../src/commands/customer-profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYtD,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CAgIN"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { withErrorHandler } from '../lib/errors.js';
|
|
2
|
+
import { createClient } from '../lib/client.js';
|
|
3
|
+
import { formatOutput, success } from '../lib/output.js';
|
|
4
|
+
import { parseInputData } from '../lib/input.js';
|
|
5
|
+
import { CUSTOMER_PROFILE_SCHEMA, UPDATE_CUSTOMER_PROFILE_SCHEMA, CUSTOMER_PROFILE, SET_CUSTOMER_PROFILE, } from '../graphql/queries.js';
|
|
6
|
+
export function registerCustomerProfilesCommands(program, globalOpts) {
|
|
7
|
+
const cp = program
|
|
8
|
+
.command('customer-profiles')
|
|
9
|
+
.alias('cp')
|
|
10
|
+
.description('Manage customer profile schema and profiles');
|
|
11
|
+
// --- Schema subcommands ---
|
|
12
|
+
const schema = cp
|
|
13
|
+
.command('schema')
|
|
14
|
+
.description('Manage the customer profile schema');
|
|
15
|
+
// schema get
|
|
16
|
+
schema
|
|
17
|
+
.command('get')
|
|
18
|
+
.description('Get the customer profile schema for the current project')
|
|
19
|
+
.action(withErrorHandler(globalOpts, async () => {
|
|
20
|
+
const opts = globalOpts();
|
|
21
|
+
const client = await createClient(opts);
|
|
22
|
+
const data = await client.request(CUSTOMER_PROFILE_SCHEMA);
|
|
23
|
+
if (!data.customerProfileSchema) {
|
|
24
|
+
if (opts.json || opts.jsonl) {
|
|
25
|
+
formatOutput(null, opts);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
console.log('No customer profile schema defined. Use "customer-profiles schema update" to create one.');
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
formatOutput(data.customerProfileSchema, opts);
|
|
33
|
+
}));
|
|
34
|
+
// schema update
|
|
35
|
+
schema
|
|
36
|
+
.command('update')
|
|
37
|
+
.description('Update the customer profile schema (fields array)')
|
|
38
|
+
.option('-d, --data <json>', 'Fields array as JSON')
|
|
39
|
+
.option('-f, --file <path>', 'Read fields from file')
|
|
40
|
+
.action(withErrorHandler(globalOpts, async (cmdOpts) => {
|
|
41
|
+
const opts = globalOpts();
|
|
42
|
+
const client = await createClient(opts);
|
|
43
|
+
const inputData = await parseInputData(cmdOpts);
|
|
44
|
+
// Accept either { fields: [...] } or a raw array
|
|
45
|
+
const fields = Array.isArray(inputData)
|
|
46
|
+
? inputData
|
|
47
|
+
: (inputData.fields ?? inputData);
|
|
48
|
+
if (!Array.isArray(fields)) {
|
|
49
|
+
throw new Error('Input must be a fields array or an object with a "fields" key. ' +
|
|
50
|
+
'Example: [{"key":"name","label":"Name","type":"text"}]');
|
|
51
|
+
}
|
|
52
|
+
const data = await client.request(UPDATE_CUSTOMER_PROFILE_SCHEMA, { fields });
|
|
53
|
+
formatOutput(data.updateCustomerProfileSchema, opts);
|
|
54
|
+
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
55
|
+
const version = data.updateCustomerProfileSchema.version;
|
|
56
|
+
success(`Updated customer profile schema (version ${version})`);
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
// --- Profile subcommands ---
|
|
60
|
+
const profile = cp
|
|
61
|
+
.command('profile')
|
|
62
|
+
.description('Manage individual customer profiles');
|
|
63
|
+
// profile get
|
|
64
|
+
profile
|
|
65
|
+
.command('get <customerId>')
|
|
66
|
+
.description("Get a customer's profile data")
|
|
67
|
+
.action(withErrorHandler(globalOpts, async (customerId) => {
|
|
68
|
+
const opts = globalOpts();
|
|
69
|
+
const client = await createClient(opts);
|
|
70
|
+
const data = await client.request(CUSTOMER_PROFILE, { customerId });
|
|
71
|
+
if (!data.customerProfile) {
|
|
72
|
+
throw new Error(`No profile found for customer "${customerId}".`);
|
|
73
|
+
}
|
|
74
|
+
formatOutput(data.customerProfile, opts);
|
|
75
|
+
}));
|
|
76
|
+
// profile set
|
|
77
|
+
profile
|
|
78
|
+
.command('set <customerId>')
|
|
79
|
+
.description("Set a customer's profile data")
|
|
80
|
+
.option('-d, --data <json>', 'Profile data as JSON')
|
|
81
|
+
.option('-f, --file <path>', 'Read data from file')
|
|
82
|
+
.action(withErrorHandler(globalOpts, async (customerId, cmdOpts) => {
|
|
83
|
+
const opts = globalOpts();
|
|
84
|
+
const client = await createClient(opts);
|
|
85
|
+
const inputData = await parseInputData(cmdOpts);
|
|
86
|
+
// Accept either { data: {...} } or the raw data object
|
|
87
|
+
const profileData = inputData.data ?? inputData;
|
|
88
|
+
const data = await client.request(SET_CUSTOMER_PROFILE, {
|
|
89
|
+
customerId,
|
|
90
|
+
data: profileData,
|
|
91
|
+
});
|
|
92
|
+
formatOutput(data.setCustomerProfile, opts);
|
|
93
|
+
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
94
|
+
success(`Set profile for customer ${customerId}`);
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAsBtD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CAsLN"}
|
package/dist/commands/pull.js
CHANGED
|
@@ -3,7 +3,8 @@ import chalk from 'chalk';
|
|
|
3
3
|
import { withErrorHandler } from '../lib/errors.js';
|
|
4
4
|
import { createClient } from '../lib/client.js';
|
|
5
5
|
import { loadPullConfig } from '../config/pull-config.js';
|
|
6
|
-
import { fetchModelsForCodegen, filterModels } from '../codegen/fetch-models.js';
|
|
6
|
+
import { fetchModelsForCodegen, filterModels, } from '../codegen/fetch-models.js';
|
|
7
|
+
import { fetchCustomerProfileSchema } from '../codegen/fetch-customer-profile-schema.js';
|
|
7
8
|
import { toPascalCase } from '../codegen/field-mapping.js';
|
|
8
9
|
import { generateFieldTypesFile } from '../codegen/generators/field-types.js';
|
|
9
10
|
import { generateConfigFile } from '../codegen/generators/config.js';
|
|
@@ -13,6 +14,8 @@ import { generateModelDocuments } from '../codegen/generators/documents.js';
|
|
|
13
14
|
import { generateSwiftModelFile } from '../codegen/generators/swift-types.js';
|
|
14
15
|
import { generateSwiftFieldTypesFile } from '../codegen/generators/swift-field-types.js';
|
|
15
16
|
import { generateSwiftModelKeys } from '../codegen/generators/swift-model-keys.js';
|
|
17
|
+
import { generateCustomerProfileTypes } from '../codegen/generators/customer-profile-types.js';
|
|
18
|
+
import { generateSwiftCustomerProfileFile } from '../codegen/generators/swift-customer-profile.js';
|
|
16
19
|
import { writeFiles } from '../codegen/write-files.js';
|
|
17
20
|
export function registerPullCommand(program, globalOpts) {
|
|
18
21
|
program
|
|
@@ -35,11 +38,14 @@ export function registerPullCommand(program, globalOpts) {
|
|
|
35
38
|
swift: cmdOpts.swift,
|
|
36
39
|
};
|
|
37
40
|
const config = await loadPullConfig(flags);
|
|
38
|
-
// Fetch models
|
|
41
|
+
// Fetch models + customer profile schema
|
|
39
42
|
const client = await createClient(opts);
|
|
40
43
|
console.log(chalk.dim('Fetching models…'));
|
|
41
|
-
const allModels = await
|
|
42
|
-
|
|
44
|
+
const [allModels, cpSchema] = await Promise.all([
|
|
45
|
+
fetchModelsForCodegen(client),
|
|
46
|
+
fetchCustomerProfileSchema(client),
|
|
47
|
+
]);
|
|
48
|
+
if (allModels.length === 0 && !cpSchema) {
|
|
43
49
|
console.log(chalk.yellow('No models found. Nothing to generate.'));
|
|
44
50
|
return;
|
|
45
51
|
}
|
|
@@ -74,7 +80,14 @@ export function registerPullCommand(program, globalOpts) {
|
|
|
74
80
|
path: resolve(typesDir, 'models', 'index.ts'),
|
|
75
81
|
content: generateModelIndex(models),
|
|
76
82
|
});
|
|
77
|
-
// 4.
|
|
83
|
+
// 4. Customer profile types (when schema exists)
|
|
84
|
+
if (cpSchema && cpSchema.fields.length > 0) {
|
|
85
|
+
files.push({
|
|
86
|
+
path: resolve(typesDir, 'customer-profile.ts'),
|
|
87
|
+
content: generateCustomerProfileTypes(cpSchema),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// 5. Per-model GraphQL documents (only for publicApi models with records)
|
|
78
91
|
const publicModels = models.filter((m) => m.config.publicApi && m.config.records);
|
|
79
92
|
for (const model of publicModels) {
|
|
80
93
|
files.push({
|
|
@@ -82,12 +95,13 @@ export function registerPullCommand(program, globalOpts) {
|
|
|
82
95
|
content: generateModelDocuments(model),
|
|
83
96
|
});
|
|
84
97
|
}
|
|
85
|
-
//
|
|
98
|
+
// 6. Main index
|
|
99
|
+
const hasCustomerProfile = !!(cpSchema && cpSchema.fields.length > 0);
|
|
86
100
|
files.push({
|
|
87
101
|
path: resolve(typesDir, 'index.ts'),
|
|
88
|
-
content: generateMainIndex(),
|
|
102
|
+
content: generateMainIndex(hasCustomerProfile),
|
|
89
103
|
});
|
|
90
|
-
//
|
|
104
|
+
// 7. Swift output (when configured)
|
|
91
105
|
if (config.output.swift) {
|
|
92
106
|
const swiftDir = resolve(cwd, config.output.swift);
|
|
93
107
|
// Shared types
|
|
@@ -108,6 +122,13 @@ export function registerPullCommand(program, globalOpts) {
|
|
|
108
122
|
content: generateSwiftModelFile(model),
|
|
109
123
|
});
|
|
110
124
|
}
|
|
125
|
+
// Customer profile Swift file
|
|
126
|
+
if (hasCustomerProfile) {
|
|
127
|
+
files.push({
|
|
128
|
+
path: resolve(swiftDir, 'CustomerProfile.swift'),
|
|
129
|
+
content: generateSwiftCustomerProfileFile(cpSchema),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
111
132
|
}
|
|
112
133
|
// Dry run: list files
|
|
113
134
|
if (config.dryRun) {
|
|
@@ -125,8 +146,9 @@ export function registerPullCommand(program, globalOpts) {
|
|
|
125
146
|
const modelCount = models.length;
|
|
126
147
|
const docCount = publicModels.length;
|
|
127
148
|
const swiftCount = config.output.swift ? models.length + 2 : 0; // +2 for FieldTypes + ModelKeys
|
|
149
|
+
const cpSuffix = hasCustomerProfile ? ', customer profile' : '';
|
|
128
150
|
console.log(chalk.green(`\nGenerated ${files.length} file(s)`) +
|
|
129
|
-
chalk.dim(` (${modelCount} model type(s), ${docCount} document(s)${swiftCount > 0 ? `, ${swiftCount} Swift file(s)` : ''})`));
|
|
151
|
+
chalk.dim(` (${modelCount} model type(s), ${docCount} document(s)${cpSuffix}${swiftCount > 0 ? `, ${swiftCount} Swift file(s)` : ''})`));
|
|
130
152
|
console.log(chalk.dim(` Types: ${typesDir}`));
|
|
131
153
|
if (docCount > 0) {
|
|
132
154
|
console.log(chalk.dim(` Documents: ${docsDir}`));
|
|
@@ -136,8 +158,8 @@ export function registerPullCommand(program, globalOpts) {
|
|
|
136
158
|
}
|
|
137
159
|
}));
|
|
138
160
|
}
|
|
139
|
-
function generateMainIndex() {
|
|
140
|
-
|
|
161
|
+
function generateMainIndex(includeCustomerProfile) {
|
|
162
|
+
let code = `/**
|
|
141
163
|
* Generated types and configs
|
|
142
164
|
*
|
|
143
165
|
* @generated by foir — DO NOT EDIT MANUALLY
|
|
@@ -147,4 +169,8 @@ export * from './field-types.js';
|
|
|
147
169
|
export * from './config.js';
|
|
148
170
|
export * from './models/index.js';
|
|
149
171
|
`;
|
|
172
|
+
if (includeCustomerProfile) {
|
|
173
|
+
code += `export * from './customer-profile.js';\n`;
|
|
174
|
+
}
|
|
175
|
+
return code;
|
|
150
176
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull-config.d.ts","sourceRoot":"","sources":["../../src/config/pull-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AA+CH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"pull-config.d.ts","sourceRoot":"","sources":["../../src/config/pull-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AA+CH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,CAAC,CA4B7B"}
|
|
@@ -55,10 +55,14 @@ export async function loadPullConfig(flags) {
|
|
|
55
55
|
const types = flags.out ?? fileConfig.output?.types ?? DEFAULT_TYPES_DIR;
|
|
56
56
|
const documents = fileConfig.output?.documents ?? DEFAULT_DOCS_DIR;
|
|
57
57
|
const swift = flags.swift ?? fileConfig.output?.swift;
|
|
58
|
-
const output = {
|
|
58
|
+
const output = {
|
|
59
|
+
types,
|
|
60
|
+
documents,
|
|
61
|
+
...(swift ? { swift } : {}),
|
|
62
|
+
};
|
|
59
63
|
const only = flags.only
|
|
60
64
|
? flags.only.split(',').map((s) => s.trim())
|
|
61
|
-
: fileConfig.only ?? [];
|
|
65
|
+
: (fileConfig.only ?? []);
|
|
62
66
|
const includeInline = fileConfig.includeInline ?? true;
|
|
63
67
|
const prettier = flags.noPrettier ? false : (fileConfig.prettier ?? true);
|
|
64
68
|
const dryRun = flags.dryRun ?? false;
|
|
@@ -23,6 +23,10 @@ export declare const UPDATE_MODEL = "\n mutation($input: UpdateModelInput!) { u
|
|
|
23
23
|
export declare const DELETE_MODEL = "\n mutation($id: ID!) { deleteModel(id: $id) }\n";
|
|
24
24
|
export declare const MODEL_VERSIONS = "\n query($modelId: ID!, $limit: Int, $offset: Int) { modelVersions(modelId: $modelId, limit: $limit, offset: $offset) { items { id modelId versionNumber contentHash changeDescription createdAt createdBy } } }\n";
|
|
25
25
|
export declare const GLOBAL_SEARCH = "\n query($query: String!, $limit: Int, $modelKeys: [String!], $includeMedia: Boolean) {\n globalSearch(query: $query, limit: $limit, modelKeys: $modelKeys, includeMedia: $includeMedia) {\n records { id modelKey title naturalKey subtitle modelName updatedAt }\n media { id fileName altText fileUrl }\n }\n }\n";
|
|
26
|
+
export declare const CUSTOMER_PROFILE_SCHEMA = "\n query { customerProfileSchema { id fields { id key label type required helpText placeholder defaultValue config validation { rule value message } isTranslatable } version createdAt updatedAt updatedBy } }\n";
|
|
27
|
+
export declare const UPDATE_CUSTOMER_PROFILE_SCHEMA = "\n mutation($fields: [FieldDefinitionInput!]!) { updateCustomerProfileSchema(fields: $fields) { id fields { id key label type required helpText placeholder defaultValue config validation { rule value message } isTranslatable } version createdAt updatedAt } }\n";
|
|
28
|
+
export declare const CUSTOMER_PROFILE = "\n query($customerId: ID!) { customerProfile(customerId: $customerId) { id customerId data schemaVersionNumber createdAt updatedAt createdBy updatedBy } }\n";
|
|
29
|
+
export declare const SET_CUSTOMER_PROFILE = "\n mutation($customerId: ID!, $data: JSON!) { setCustomerProfile(customerId: $customerId, data: $data) { id customerId data schemaVersionNumber createdAt updatedAt } }\n";
|
|
26
30
|
export declare const CUSTOMERS = "\n query($status: CustomerStatus, $search: String, $filters: [FilterInput!], $limit: Int, $offset: Int) {\n customers(status: $status, search: $search, filters: $filters, limit: $limit, offset: $offset) {\n customers { id email status lastLoginAt createdAt updatedAt }\n total\n }\n }\n";
|
|
27
31
|
export declare const CUSTOMER = "\n query($id: ID!) { customer(id: $id) { id email status lastLoginAt createdAt updatedAt } }\n";
|
|
28
32
|
export declare const CUSTOMER_BY_EMAIL = "\n query($email: String!) { customerByEmail(email: $email) { id email status lastLoginAt createdAt updatedAt } }\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/graphql/queries.ts"],"names":[],"mappings":"AAOA,eAAO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CAAC;AAEF,eAAO,MAAM,aAAa,gJAEzB,CAAC;AAEF,eAAO,MAAM,aAAa,uDAEzB,CAAC;AAIF,eAAO,MAAM,KAAK,+VAOjB,CAAC;AAEF,eAAO,MAAM,IAAI,yKAEhB,CAAC;AAEF,eAAO,MAAM,kBAAkB,uFAE9B,CAAC;AAEF,eAAO,MAAM,WAAW,uRAEvB,CAAC;AAEF,eAAO,MAAM,oBAAoB,qOAEhC,CAAC;AAEF,eAAO,MAAM,WAAW,qDAEvB,CAAC;AAIF,eAAO,MAAM,KAAK,6XAOjB,CAAC;AAEF,eAAO,MAAM,IAAI,qLAEhB,CAAC;AAEF,eAAO,MAAM,WAAW,8HAEvB,CAAC;AAEF,eAAO,MAAM,YAAY,qHAExB,CAAC;AAEF,eAAO,MAAM,WAAW,iEAEvB,CAAC;AAIF,eAAO,MAAM,eAAe,qNAE3B,CAAC;AAEF,eAAO,MAAM,qBAAqB,yIAEjC,CAAC;AAEF,eAAO,MAAM,4BAA4B,qJAExC,CAAC;AAEF,eAAO,MAAM,4BAA4B,iJAExC,CAAC;AAEF,eAAO,MAAM,4BAA4B,oKAExC,CAAC;AAEF,eAAO,MAAM,4BAA4B,oEAExC,CAAC"}
|
package/dist/graphql/queries.js
CHANGED
|
@@ -107,6 +107,19 @@ export const GLOBAL_SEARCH = `
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
`;
|
|
110
|
+
// --- Customer Profile Schema ---
|
|
111
|
+
export const CUSTOMER_PROFILE_SCHEMA = `
|
|
112
|
+
query { customerProfileSchema { id fields { id key label type required helpText placeholder defaultValue config validation { rule value message } isTranslatable } version createdAt updatedAt updatedBy } }
|
|
113
|
+
`;
|
|
114
|
+
export const UPDATE_CUSTOMER_PROFILE_SCHEMA = `
|
|
115
|
+
mutation($fields: [FieldDefinitionInput!]!) { updateCustomerProfileSchema(fields: $fields) { id fields { id key label type required helpText placeholder defaultValue config validation { rule value message } isTranslatable } version createdAt updatedAt } }
|
|
116
|
+
`;
|
|
117
|
+
export const CUSTOMER_PROFILE = `
|
|
118
|
+
query($customerId: ID!) { customerProfile(customerId: $customerId) { id customerId data schemaVersionNumber createdAt updatedAt createdBy updatedBy } }
|
|
119
|
+
`;
|
|
120
|
+
export const SET_CUSTOMER_PROFILE = `
|
|
121
|
+
mutation($customerId: ID!, $data: JSON!) { setCustomerProfile(customerId: $customerId, data: $data) { id customerId data schemaVersionNumber createdAt updatedAt } }
|
|
122
|
+
`;
|
|
110
123
|
// --- Customers ---
|
|
111
124
|
export const CUSTOMERS = `
|
|
112
125
|
query($status: CustomerStatus, $search: String, $filters: [FilterInput!], $limit: Int, $offset: Int) {
|