@eide/uniformgen 0.1.0
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/README.md +356 -0
- package/dist/auth/credentials.d.ts +58 -0
- package/dist/auth/credentials.d.ts.map +1 -0
- package/dist/auth/credentials.js +107 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +563 -0
- package/dist/commands/init.d.ts +11 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +113 -0
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +158 -0
- package/dist/commands/logout.d.ts +5 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +13 -0
- package/dist/commands/push.d.ts +13 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +328 -0
- package/dist/commands/scaffold.d.ts +19 -0
- package/dist/commands/scaffold.d.ts.map +1 -0
- package/dist/commands/scaffold.js +366 -0
- package/dist/commands/seed.d.ts +20 -0
- package/dist/commands/seed.d.ts.map +1 -0
- package/dist/commands/seed.js +380 -0
- package/dist/commands/select-project.d.ts +10 -0
- package/dist/commands/select-project.d.ts.map +1 -0
- package/dist/commands/select-project.js +277 -0
- package/dist/commands/setup.d.ts +5 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +51 -0
- package/dist/commands/sync.d.ts +13 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +318 -0
- package/dist/commands/whoami.d.ts +5 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +31 -0
- package/dist/config/load-config.d.ts +6 -0
- package/dist/config/load-config.d.ts.map +1 -0
- package/dist/config/load-config.js +103 -0
- package/dist/config/settings.d.ts +20 -0
- package/dist/config/settings.d.ts.map +1 -0
- package/dist/config/settings.js +64 -0
- package/dist/config/types.d.ts +152 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +94 -0
- package/dist/fetcher/fetch-schemas.d.ts +140 -0
- package/dist/fetcher/fetch-schemas.d.ts.map +1 -0
- package/dist/fetcher/fetch-schemas.js +223 -0
- package/dist/fetcher/fetch-workflows.d.ts +53 -0
- package/dist/fetcher/fetch-workflows.d.ts.map +1 -0
- package/dist/fetcher/fetch-workflows.js +164 -0
- package/dist/generated/hooks/customer-detail.d.ts +74 -0
- package/dist/generated/hooks/customer-detail.d.ts.map +1 -0
- package/dist/generated/hooks/customer-detail.js +113 -0
- package/dist/generated/hooks/design-system.d.ts +74 -0
- package/dist/generated/hooks/design-system.d.ts.map +1 -0
- package/dist/generated/hooks/design-system.js +109 -0
- package/dist/generated/hooks/index.d.ts +16 -0
- package/dist/generated/hooks/index.d.ts.map +1 -0
- package/dist/generated/hooks/index.js +14 -0
- package/dist/generated/hooks/shopify-collection.d.ts +74 -0
- package/dist/generated/hooks/shopify-collection.d.ts.map +1 -0
- package/dist/generated/hooks/shopify-collection.js +113 -0
- package/dist/generated/hooks/shopify-market.d.ts +74 -0
- package/dist/generated/hooks/shopify-market.d.ts.map +1 -0
- package/dist/generated/hooks/shopify-market.js +109 -0
- package/dist/generated/hooks/shopify-product.d.ts +74 -0
- package/dist/generated/hooks/shopify-product.d.ts.map +1 -0
- package/dist/generated/hooks/shopify-product.js +113 -0
- package/dist/generated/hooks/shopify-variant.d.ts +74 -0
- package/dist/generated/hooks/shopify-variant.d.ts.map +1 -0
- package/dist/generated/hooks/shopify-variant.js +113 -0
- package/dist/generated/hooks/template.d.ts +74 -0
- package/dist/generated/hooks/template.d.ts.map +1 -0
- package/dist/generated/hooks/template.js +107 -0
- package/dist/generated/types/config.d.ts +88 -0
- package/dist/generated/types/config.d.ts.map +1 -0
- package/dist/generated/types/config.js +14 -0
- package/dist/generated/types/data-models/index.d.ts +7 -0
- package/dist/generated/types/data-models/index.d.ts.map +1 -0
- package/dist/generated/types/data-models/index.js +6 -0
- package/dist/generated/types/data-models/test.d.ts +29 -0
- package/dist/generated/types/data-models/test.d.ts.map +1 -0
- package/dist/generated/types/data-models/test.js +1 -0
- package/dist/generated/types/data-models/watch.d.ts +26 -0
- package/dist/generated/types/data-models/watch.d.ts.map +1 -0
- package/dist/generated/types/data-models/watch.js +1 -0
- package/dist/generated/types/field-types.d.ts +255 -0
- package/dist/generated/types/field-types.d.ts.map +1 -0
- package/dist/generated/types/field-types.js +35 -0
- package/dist/generated/types/hooks.d.ts +106 -0
- package/dist/generated/types/hooks.d.ts.map +1 -0
- package/dist/generated/types/hooks.js +9 -0
- package/dist/generated/types/index.d.ts +10 -0
- package/dist/generated/types/index.d.ts.map +1 -0
- package/dist/generated/types/index.js +9 -0
- package/dist/generated/types/models/button-variant.d.ts +16 -0
- package/dist/generated/types/models/button-variant.d.ts.map +1 -0
- package/dist/generated/types/models/button-variant.js +1 -0
- package/dist/generated/types/models/color-palette.d.ts +27 -0
- package/dist/generated/types/models/color-palette.d.ts.map +1 -0
- package/dist/generated/types/models/color-palette.js +1 -0
- package/dist/generated/types/models/color-with-scale.d.ts +15 -0
- package/dist/generated/types/models/color-with-scale.d.ts.map +1 -0
- package/dist/generated/types/models/color-with-scale.js +1 -0
- package/dist/generated/types/models/context.d.ts +53 -0
- package/dist/generated/types/models/context.d.ts.map +1 -0
- package/dist/generated/types/models/context.js +51 -0
- package/dist/generated/types/models/customer-detail.d.ts +32 -0
- package/dist/generated/types/models/customer-detail.d.ts.map +1 -0
- package/dist/generated/types/models/customer-detail.js +26 -0
- package/dist/generated/types/models/design-system-badges.d.ts +16 -0
- package/dist/generated/types/models/design-system-badges.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-badges.js +1 -0
- package/dist/generated/types/models/design-system-buttons.d.ts +17 -0
- package/dist/generated/types/models/design-system-buttons.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-buttons.js +1 -0
- package/dist/generated/types/models/design-system-cards.d.ts +16 -0
- package/dist/generated/types/models/design-system-cards.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-cards.js +1 -0
- package/dist/generated/types/models/design-system-colors.d.ts +12 -0
- package/dist/generated/types/models/design-system-colors.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-colors.js +1 -0
- package/dist/generated/types/models/design-system-dark-mode.d.ts +13 -0
- package/dist/generated/types/models/design-system-dark-mode.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-dark-mode.js +1 -0
- package/dist/generated/types/models/design-system-focus-ring.d.ts +14 -0
- package/dist/generated/types/models/design-system-focus-ring.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-focus-ring.js +1 -0
- package/dist/generated/types/models/design-system-grid.d.ts +18 -0
- package/dist/generated/types/models/design-system-grid.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-grid.js +1 -0
- package/dist/generated/types/models/design-system-inputs.d.ts +26 -0
- package/dist/generated/types/models/design-system-inputs.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-inputs.js +1 -0
- package/dist/generated/types/models/design-system-links.d.ts +16 -0
- package/dist/generated/types/models/design-system-links.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-links.js +1 -0
- package/dist/generated/types/models/design-system-shadows.d.ts +20 -0
- package/dist/generated/types/models/design-system-shadows.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-shadows.js +1 -0
- package/dist/generated/types/models/design-system-spacing.d.ts +13 -0
- package/dist/generated/types/models/design-system-spacing.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-spacing.js +1 -0
- package/dist/generated/types/models/design-system-transitions.d.ts +15 -0
- package/dist/generated/types/models/design-system-transitions.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-transitions.js +1 -0
- package/dist/generated/types/models/design-system-typography.d.ts +21 -0
- package/dist/generated/types/models/design-system-typography.d.ts.map +1 -0
- package/dist/generated/types/models/design-system-typography.js +1 -0
- package/dist/generated/types/models/design-system.d.ts +138 -0
- package/dist/generated/types/models/design-system.d.ts.map +1 -0
- package/dist/generated/types/models/design-system.js +64 -0
- package/dist/generated/types/models/experiment.d.ts +57 -0
- package/dist/generated/types/models/experiment.d.ts.map +1 -0
- package/dist/generated/types/models/experiment.js +55 -0
- package/dist/generated/types/models/font-file.d.ts +16 -0
- package/dist/generated/types/models/font-file.d.ts.map +1 -0
- package/dist/generated/types/models/font-file.js +1 -0
- package/dist/generated/types/models/index.d.ts +38 -0
- package/dist/generated/types/models/index.d.ts.map +1 -0
- package/dist/generated/types/models/index.js +12 -0
- package/dist/generated/types/models/integration.d.ts +32 -0
- package/dist/generated/types/models/integration.d.ts.map +1 -0
- package/dist/generated/types/models/integration.js +26 -0
- package/dist/generated/types/models/route-tree.d.ts +43 -0
- package/dist/generated/types/models/route-tree.d.ts.map +1 -0
- package/dist/generated/types/models/route-tree.js +39 -0
- package/dist/generated/types/models/segment.d.ts +57 -0
- package/dist/generated/types/models/segment.d.ts.map +1 -0
- package/dist/generated/types/models/segment.js +55 -0
- package/dist/generated/types/models/shopify-collection.d.ts +32 -0
- package/dist/generated/types/models/shopify-collection.d.ts.map +1 -0
- package/dist/generated/types/models/shopify-collection.js +26 -0
- package/dist/generated/types/models/shopify-market.d.ts +32 -0
- package/dist/generated/types/models/shopify-market.d.ts.map +1 -0
- package/dist/generated/types/models/shopify-market.js +26 -0
- package/dist/generated/types/models/shopify-product.d.ts +32 -0
- package/dist/generated/types/models/shopify-product.d.ts.map +1 -0
- package/dist/generated/types/models/shopify-product.js +26 -0
- package/dist/generated/types/models/shopify-variant.d.ts +32 -0
- package/dist/generated/types/models/shopify-variant.d.ts.map +1 -0
- package/dist/generated/types/models/shopify-variant.js +26 -0
- package/dist/generated/types/models/template.d.ts +53 -0
- package/dist/generated/types/models/template.d.ts.map +1 -0
- package/dist/generated/types/models/template.js +40 -0
- package/dist/generated/types/models/typography-variant.d.ts +15 -0
- package/dist/generated/types/models/typography-variant.d.ts.map +1 -0
- package/dist/generated/types/models/typography-variant.js +1 -0
- package/dist/generated/types/scalars.d.ts +56 -0
- package/dist/generated/types/scalars.d.ts.map +1 -0
- package/dist/generated/types/scalars.js +6 -0
- package/dist/generators/admin/index.d.ts +32 -0
- package/dist/generators/admin/index.d.ts.map +1 -0
- package/dist/generators/admin/index.js +219 -0
- package/dist/generators/admin/mutations.d.ts +23 -0
- package/dist/generators/admin/mutations.d.ts.map +1 -0
- package/dist/generators/admin/mutations.js +424 -0
- package/dist/generators/admin/queries.d.ts +20 -0
- package/dist/generators/admin/queries.d.ts.map +1 -0
- package/dist/generators/admin/queries.js +476 -0
- package/dist/generators/admin/types.d.ts +28 -0
- package/dist/generators/admin/types.d.ts.map +1 -0
- package/dist/generators/admin/types.js +254 -0
- package/dist/generators/cms/index.d.ts +29 -0
- package/dist/generators/cms/index.d.ts.map +1 -0
- package/dist/generators/cms/index.js +126 -0
- package/dist/generators/cms/route.d.ts +27 -0
- package/dist/generators/cms/route.d.ts.map +1 -0
- package/dist/generators/cms/route.js +409 -0
- package/dist/generators/cms/types.d.ts +15 -0
- package/dist/generators/cms/types.d.ts.map +1 -0
- package/dist/generators/cms/types.js +137 -0
- package/dist/generators/contexts/index.d.ts +25 -0
- package/dist/generators/contexts/index.d.ts.map +1 -0
- package/dist/generators/contexts/index.js +591 -0
- package/dist/generators/documents/data-models.d.ts +6 -0
- package/dist/generators/documents/data-models.d.ts.map +1 -0
- package/dist/generators/documents/data-models.js +61 -0
- package/dist/generators/documents/entity-models.d.ts +7 -0
- package/dist/generators/documents/entity-models.d.ts.map +1 -0
- package/dist/generators/documents/entity-models.js +87 -0
- package/dist/generators/documents/workflows.d.ts +11 -0
- package/dist/generators/documents/workflows.d.ts.map +1 -0
- package/dist/generators/documents/workflows.js +101 -0
- package/dist/generators/filters/index.d.ts +16 -0
- package/dist/generators/filters/index.d.ts.map +1 -0
- package/dist/generators/filters/index.js +384 -0
- package/dist/generators/hooks/agnostic.d.ts +16 -0
- package/dist/generators/hooks/agnostic.d.ts.map +1 -0
- package/dist/generators/hooks/agnostic.js +248 -0
- package/dist/generators/hooks/index.d.ts +9 -0
- package/dist/generators/hooks/index.d.ts.map +1 -0
- package/dist/generators/hooks/index.js +8 -0
- package/dist/generators/hooks/react.d.ts +16 -0
- package/dist/generators/hooks/react.d.ts.map +1 -0
- package/dist/generators/hooks/react.js +394 -0
- package/dist/generators/hooks/remix.d.ts +16 -0
- package/dist/generators/hooks/remix.d.ts.map +1 -0
- package/dist/generators/hooks/remix.js +349 -0
- package/dist/generators/hooks/workflows.d.ts +23 -0
- package/dist/generators/hooks/workflows.d.ts.map +1 -0
- package/dist/generators/hooks/workflows.js +312 -0
- package/dist/generators/resolve/index.d.ts +13 -0
- package/dist/generators/resolve/index.d.ts.map +1 -0
- package/dist/generators/resolve/index.js +13 -0
- package/dist/generators/resolve/platform.d.ts +29 -0
- package/dist/generators/resolve/platform.d.ts.map +1 -0
- package/dist/generators/resolve/platform.js +479 -0
- package/dist/generators/types/config.d.ts +7 -0
- package/dist/generators/types/config.d.ts.map +1 -0
- package/dist/generators/types/config.js +113 -0
- package/dist/generators/types/data-models.d.ts +10 -0
- package/dist/generators/types/data-models.d.ts.map +1 -0
- package/dist/generators/types/data-models.js +100 -0
- package/dist/generators/types/entity-models.d.ts +13 -0
- package/dist/generators/types/entity-models.d.ts.map +1 -0
- package/dist/generators/types/entity-models.js +241 -0
- package/dist/generators/types/field-types.d.ts +9 -0
- package/dist/generators/types/field-types.d.ts.map +1 -0
- package/dist/generators/types/field-types.js +651 -0
- package/dist/generators/types/hooks.d.ts +7 -0
- package/dist/generators/types/hooks.d.ts.map +1 -0
- package/dist/generators/types/hooks.js +132 -0
- package/dist/generators/types/scalars.d.ts +6 -0
- package/dist/generators/types/scalars.d.ts.map +1 -0
- package/dist/generators/types/scalars.js +68 -0
- package/dist/generators/types/user-details.d.ts +6 -0
- package/dist/generators/types/user-details.d.ts.map +1 -0
- package/dist/generators/types/user-details.js +60 -0
- package/dist/generators/types/workflows.d.ts +15 -0
- package/dist/generators/types/workflows.d.ts.map +1 -0
- package/dist/generators/types/workflows.js +163 -0
- package/dist/graphql/generated/gql.d.ts +47 -0
- package/dist/graphql/generated/gql.d.ts.map +1 -0
- package/dist/graphql/generated/gql.js +10 -0
- package/dist/graphql/generated/graphql.d.ts +8455 -0
- package/dist/graphql/generated/graphql.d.ts.map +1 -0
- package/dist/graphql/generated/graphql.js +573 -0
- package/dist/graphql/generated/index.d.ts +2 -0
- package/dist/graphql/generated/index.d.ts.map +1 -0
- package/dist/graphql/generated/index.js +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/schema/define-entity-model.d.ts +122 -0
- package/dist/schema/define-entity-model.d.ts.map +1 -0
- package/dist/schema/define-entity-model.js +59 -0
- package/dist/schema/schema-loader.d.ts +10 -0
- package/dist/schema/schema-loader.d.ts.map +1 -0
- package/dist/schema/schema-loader.js +91 -0
- package/dist/utils/field-mapping.d.ts +83 -0
- package/dist/utils/field-mapping.d.ts.map +1 -0
- package/dist/utils/field-mapping.js +334 -0
- package/dist/writer/write-files.d.ts +12 -0
- package/dist/writer/write-files.d.ts.map +1 -0
- package/dist/writer/write-files.js +35 -0
- package/package.json +70 -0
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Resolution Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates typed hooks/functions for platform-level entity resolution:
|
|
5
|
+
* - useResolve{Model} - Resolve by natural key with variant selection
|
|
6
|
+
* - Returns resolved content WITHOUT CMS features (no templates/zones/layouts)
|
|
7
|
+
*
|
|
8
|
+
* Use CMS generators (cms/route.ts) for template/zone resolution.
|
|
9
|
+
*
|
|
10
|
+
* @generated by UniformGen
|
|
11
|
+
*/
|
|
12
|
+
import { toPascalCase, toCamelCase, sanitizeFieldName } from '../../utils/field-mapping.js';
|
|
13
|
+
/**
|
|
14
|
+
* Check if model is inline-only (no records mode)
|
|
15
|
+
*/
|
|
16
|
+
function isInlineOnlyModel(model) {
|
|
17
|
+
return model.modes.inline && !model.modes.records;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Map metadata field type to TypeScript type
|
|
21
|
+
*/
|
|
22
|
+
function getMetadataValueType(fieldType) {
|
|
23
|
+
switch (fieldType) {
|
|
24
|
+
case 'string':
|
|
25
|
+
return 'string';
|
|
26
|
+
case 'number':
|
|
27
|
+
return 'number';
|
|
28
|
+
case 'boolean':
|
|
29
|
+
return 'boolean';
|
|
30
|
+
case 'date':
|
|
31
|
+
return 'string';
|
|
32
|
+
case 'array':
|
|
33
|
+
return 'unknown[]';
|
|
34
|
+
case 'object':
|
|
35
|
+
return 'Record<string, unknown>';
|
|
36
|
+
default:
|
|
37
|
+
return 'unknown';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Build nested metadata type
|
|
42
|
+
*/
|
|
43
|
+
function buildNestedMetadataType(fields, depth = 0) {
|
|
44
|
+
const groups = new Map();
|
|
45
|
+
const directFields = [];
|
|
46
|
+
for (const field of fields) {
|
|
47
|
+
const parts = field.key.split('.');
|
|
48
|
+
if (parts.length === 1) {
|
|
49
|
+
directFields.push(field);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const firstPart = parts[0];
|
|
53
|
+
const remaining = { ...field, key: parts.slice(1).join('.') };
|
|
54
|
+
if (!groups.has(firstPart)) {
|
|
55
|
+
groups.set(firstPart, []);
|
|
56
|
+
}
|
|
57
|
+
groups.get(firstPart).push(remaining);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const indent = ' '.repeat(depth + 1);
|
|
61
|
+
const lines = [];
|
|
62
|
+
for (const field of directFields) {
|
|
63
|
+
const valueType = getMetadataValueType(field.type);
|
|
64
|
+
const fieldName = sanitizeFieldName(field.key);
|
|
65
|
+
const optional = field.required ? '' : '?';
|
|
66
|
+
lines.push(`${indent}${fieldName}${optional}: ${valueType};`);
|
|
67
|
+
}
|
|
68
|
+
for (const [groupName, groupFields] of groups) {
|
|
69
|
+
const nestedType = buildNestedMetadataType(groupFields, depth + 1);
|
|
70
|
+
if (nestedType !== '{}') {
|
|
71
|
+
const fieldName = sanitizeFieldName(groupName);
|
|
72
|
+
lines.push(`${indent}${fieldName}?: ${nestedType}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (lines.length === 0) {
|
|
76
|
+
return '{}';
|
|
77
|
+
}
|
|
78
|
+
const closeIndent = ' '.repeat(depth);
|
|
79
|
+
return `{\n${lines.join('\n')}\n${closeIndent}}`;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Generate metadata type for a model
|
|
83
|
+
*/
|
|
84
|
+
function generateMetadataType(model) {
|
|
85
|
+
const metadataFields = model.metadataSchema?.fields;
|
|
86
|
+
if (!metadataFields || metadataFields.length === 0) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return buildNestedMetadataType(metadataFields, 0);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Generate React platform resolve hook for a model
|
|
93
|
+
*/
|
|
94
|
+
export function generatePlatformResolveReact(model, _allModels) {
|
|
95
|
+
if (isInlineOnlyModel(model)) {
|
|
96
|
+
return '';
|
|
97
|
+
}
|
|
98
|
+
const typeName = toPascalCase(model.key);
|
|
99
|
+
const dataTypeName = `${typeName}Data`;
|
|
100
|
+
const camelName = toCamelCase(model.key);
|
|
101
|
+
const lines = [];
|
|
102
|
+
// File header
|
|
103
|
+
lines.push(`/**`);
|
|
104
|
+
lines.push(` * ${model.name} - Platform Resolution Hook`);
|
|
105
|
+
lines.push(` *`);
|
|
106
|
+
lines.push(` * Resolves ${model.name} content with variant selection.`);
|
|
107
|
+
lines.push(` * Returns platform-level data (NO templates/zones/layouts).`);
|
|
108
|
+
lines.push(` *`);
|
|
109
|
+
lines.push(` * For CMS rendering with templates, use useResolveRoute from ../cms/`);
|
|
110
|
+
lines.push(` *`);
|
|
111
|
+
lines.push(` * @generated by UniformGen - DO NOT EDIT MANUALLY`);
|
|
112
|
+
lines.push(` */`);
|
|
113
|
+
lines.push('');
|
|
114
|
+
// Imports
|
|
115
|
+
lines.push(`import { useQuery, type QueryHookOptions } from '@apollo/client';`);
|
|
116
|
+
lines.push(`import { gql } from '@apollo/client';`);
|
|
117
|
+
lines.push(`import type { ${dataTypeName} } from '../../types/models/${model.key}.js';`);
|
|
118
|
+
lines.push(`import type { VariantContext } from '../../types/field-types.js';`);
|
|
119
|
+
lines.push('');
|
|
120
|
+
// Re-export types
|
|
121
|
+
lines.push(`// Re-export types for convenience`);
|
|
122
|
+
lines.push(`export type { VariantContext } from '../../types/field-types.js';`);
|
|
123
|
+
lines.push('');
|
|
124
|
+
// Generate metadata type if model has metadataSchema
|
|
125
|
+
const metadataType = generateMetadataType(model);
|
|
126
|
+
const metadataTypeName = `${typeName}Metadata`;
|
|
127
|
+
if (metadataType) {
|
|
128
|
+
lines.push(`/** Typed metadata for ${model.name} */`);
|
|
129
|
+
lines.push(`export interface ${metadataTypeName} ${metadataType}`);
|
|
130
|
+
lines.push('');
|
|
131
|
+
}
|
|
132
|
+
// Resolved types (platform level - no templates/zones)
|
|
133
|
+
lines.push(`/** Resolved ${model.name} record (platform level) */`);
|
|
134
|
+
lines.push(`export interface Resolved${typeName}Record {`);
|
|
135
|
+
lines.push(` id: string;`);
|
|
136
|
+
lines.push(` modelKey: '${model.key}';`);
|
|
137
|
+
lines.push(` naturalKey: string | null;`);
|
|
138
|
+
if (metadataType) {
|
|
139
|
+
lines.push(` metadata?: ${metadataTypeName};`);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
lines.push(` metadata?: Record<string, unknown>;`);
|
|
143
|
+
}
|
|
144
|
+
lines.push(`}`);
|
|
145
|
+
lines.push('');
|
|
146
|
+
lines.push(`/** Resolved ${model.name} variant info */`);
|
|
147
|
+
lines.push(`export interface Resolved${typeName}Variant {`);
|
|
148
|
+
lines.push(` id: string;`);
|
|
149
|
+
lines.push(` variantKey: string;`);
|
|
150
|
+
lines.push(` catalogKey: string | null;`);
|
|
151
|
+
lines.push(` matchedContexts: Array<{ key: string; value: string }>;`);
|
|
152
|
+
lines.push(`}`);
|
|
153
|
+
lines.push('');
|
|
154
|
+
lines.push(`/** Experiment assignment (if applicable) */`);
|
|
155
|
+
lines.push(`export interface ${typeName}Experiment {`);
|
|
156
|
+
lines.push(` experimentId: string;`);
|
|
157
|
+
lines.push(` experimentKey: string;`);
|
|
158
|
+
lines.push(` variantId: string;`);
|
|
159
|
+
lines.push(` variantKey: string;`);
|
|
160
|
+
lines.push(` isControl: boolean;`);
|
|
161
|
+
lines.push(`}`);
|
|
162
|
+
lines.push('');
|
|
163
|
+
lines.push(`/** Resolution context (what was used to resolve) */`);
|
|
164
|
+
lines.push(`export interface ${typeName}ResolutionContext {`);
|
|
165
|
+
lines.push(` locale: string;`);
|
|
166
|
+
lines.push(` contexts: Record<string, string>;`);
|
|
167
|
+
lines.push(`}`);
|
|
168
|
+
lines.push('');
|
|
169
|
+
lines.push(`/**`);
|
|
170
|
+
lines.push(` * Resolved ${model.name} (platform level)`);
|
|
171
|
+
lines.push(` *`);
|
|
172
|
+
lines.push(` * Contains resolved content WITHOUT CMS features.`);
|
|
173
|
+
lines.push(` * Use for mobile apps, APIs, or non-CMS frontends.`);
|
|
174
|
+
lines.push(` */`);
|
|
175
|
+
lines.push(`export interface Resolved${typeName} {`);
|
|
176
|
+
lines.push(` record: Resolved${typeName}Record;`);
|
|
177
|
+
lines.push(` variant: Resolved${typeName}Variant;`);
|
|
178
|
+
lines.push(` content: ${dataTypeName};`);
|
|
179
|
+
lines.push(` experiment: ${typeName}Experiment | null;`);
|
|
180
|
+
lines.push(` resolvedWith: ${typeName}ResolutionContext;`);
|
|
181
|
+
lines.push(`}`);
|
|
182
|
+
lines.push('');
|
|
183
|
+
// GraphQL query (platform level - no templates)
|
|
184
|
+
lines.push(`// GraphQL query for platform resolution (no templates/zones)`);
|
|
185
|
+
lines.push(`const RESOLVE_${typeName.toUpperCase()}_QUERY = gql\``);
|
|
186
|
+
lines.push(` query Resolve${typeName}($naturalKey: String!, $locale: String, $contexts: JSON) {`);
|
|
187
|
+
lines.push(` resolveEntity(modelKey: "${model.key}", naturalKey: $naturalKey, locale: $locale, contexts: $contexts) {`);
|
|
188
|
+
lines.push(` record {`);
|
|
189
|
+
lines.push(` id`);
|
|
190
|
+
lines.push(` modelKey`);
|
|
191
|
+
lines.push(` naturalKey`);
|
|
192
|
+
lines.push(` metadata`);
|
|
193
|
+
lines.push(` }`);
|
|
194
|
+
lines.push(` variant {`);
|
|
195
|
+
lines.push(` id`);
|
|
196
|
+
lines.push(` variantKey`);
|
|
197
|
+
lines.push(` catalogKey`);
|
|
198
|
+
lines.push(` matchedContexts {`);
|
|
199
|
+
lines.push(` key`);
|
|
200
|
+
lines.push(` value`);
|
|
201
|
+
lines.push(` }`);
|
|
202
|
+
lines.push(` }`);
|
|
203
|
+
lines.push(` content`);
|
|
204
|
+
lines.push(` experiment {`);
|
|
205
|
+
lines.push(` experimentId`);
|
|
206
|
+
lines.push(` experimentKey`);
|
|
207
|
+
lines.push(` variantId`);
|
|
208
|
+
lines.push(` variantKey`);
|
|
209
|
+
lines.push(` isControl`);
|
|
210
|
+
lines.push(` }`);
|
|
211
|
+
lines.push(` resolvedWith {`);
|
|
212
|
+
lines.push(` locale`);
|
|
213
|
+
lines.push(` contexts`);
|
|
214
|
+
lines.push(` }`);
|
|
215
|
+
lines.push(` }`);
|
|
216
|
+
lines.push(` }`);
|
|
217
|
+
lines.push(`\`;`);
|
|
218
|
+
lines.push('');
|
|
219
|
+
// Parse helper
|
|
220
|
+
lines.push(`/** Parse raw response to typed result */`);
|
|
221
|
+
lines.push(`function parse${typeName}(data: any): Resolved${typeName} {`);
|
|
222
|
+
lines.push(` return {`);
|
|
223
|
+
lines.push(` record: {`);
|
|
224
|
+
lines.push(` ...data.record,`);
|
|
225
|
+
lines.push(` modelKey: '${model.key}',`);
|
|
226
|
+
if (metadataType) {
|
|
227
|
+
lines.push(` metadata: data.record.metadata as ${metadataTypeName},`);
|
|
228
|
+
}
|
|
229
|
+
lines.push(` },`);
|
|
230
|
+
lines.push(` variant: {`);
|
|
231
|
+
lines.push(` id: data.variant.id,`);
|
|
232
|
+
lines.push(` variantKey: data.variant.variantKey,`);
|
|
233
|
+
lines.push(` catalogKey: data.variant.catalogKey,`);
|
|
234
|
+
lines.push(` matchedContexts: data.variant.matchedContexts ?? [],`);
|
|
235
|
+
lines.push(` },`);
|
|
236
|
+
lines.push(` content: data.content as ${dataTypeName},`);
|
|
237
|
+
lines.push(` experiment: data.experiment,`);
|
|
238
|
+
lines.push(` resolvedWith: data.resolvedWith,`);
|
|
239
|
+
lines.push(` };`);
|
|
240
|
+
lines.push(`}`);
|
|
241
|
+
lines.push('');
|
|
242
|
+
// Hook
|
|
243
|
+
lines.push(`/**`);
|
|
244
|
+
lines.push(` * Resolve ${model.name} by natural key with variant selection`);
|
|
245
|
+
lines.push(` *`);
|
|
246
|
+
lines.push(` * Returns platform-level data WITHOUT CMS features.`);
|
|
247
|
+
lines.push(` * For CMS rendering with templates, use useResolveRoute from ../cms/`);
|
|
248
|
+
lines.push(` *`);
|
|
249
|
+
lines.push(` * @example`);
|
|
250
|
+
lines.push(` * const { ${camelName}, loading, error } = useResolve${typeName}('my-slug', {`);
|
|
251
|
+
lines.push(` * locale: 'en-US',`);
|
|
252
|
+
lines.push(` * contexts: { market: 'us' },`);
|
|
253
|
+
lines.push(` * });`);
|
|
254
|
+
lines.push(` *`);
|
|
255
|
+
lines.push(` * // Access resolved content`);
|
|
256
|
+
lines.push(` * console.log(${camelName}?.content.title);`);
|
|
257
|
+
lines.push(` * console.log(${camelName}?.experiment?.variantKey);`);
|
|
258
|
+
lines.push(` */`);
|
|
259
|
+
lines.push(`export function useResolve${typeName}(`);
|
|
260
|
+
lines.push(` naturalKey: string,`);
|
|
261
|
+
lines.push(` context?: VariantContext,`);
|
|
262
|
+
lines.push(` options?: Omit<QueryHookOptions, 'variables'>`);
|
|
263
|
+
lines.push(`) {`);
|
|
264
|
+
lines.push(` const result = useQuery(RESOLVE_${typeName.toUpperCase()}_QUERY, {`);
|
|
265
|
+
lines.push(` ...options,`);
|
|
266
|
+
lines.push(` variables: {`);
|
|
267
|
+
lines.push(` naturalKey,`);
|
|
268
|
+
lines.push(` locale: context?.locale,`);
|
|
269
|
+
lines.push(` contexts: context?.contexts,`);
|
|
270
|
+
lines.push(` },`);
|
|
271
|
+
lines.push(` skip: !naturalKey,`);
|
|
272
|
+
lines.push(` });`);
|
|
273
|
+
lines.push('');
|
|
274
|
+
lines.push(` return {`);
|
|
275
|
+
lines.push(` ...result,`);
|
|
276
|
+
lines.push(` ${camelName}: result.data?.resolveEntity ? parse${typeName}(result.data.resolveEntity) : undefined,`);
|
|
277
|
+
lines.push(` };`);
|
|
278
|
+
lines.push(`}`);
|
|
279
|
+
return lines.join('\n') + '\n';
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Generate Remix/Hydrogen platform resolve function for a model
|
|
283
|
+
*/
|
|
284
|
+
export function generatePlatformResolveRemix(model, _allModels) {
|
|
285
|
+
if (isInlineOnlyModel(model)) {
|
|
286
|
+
return '';
|
|
287
|
+
}
|
|
288
|
+
const typeName = toPascalCase(model.key);
|
|
289
|
+
const dataTypeName = `${typeName}Data`;
|
|
290
|
+
const lines = [];
|
|
291
|
+
// File header
|
|
292
|
+
lines.push(`/**`);
|
|
293
|
+
lines.push(` * ${model.name} - Platform Resolution Function`);
|
|
294
|
+
lines.push(` *`);
|
|
295
|
+
lines.push(` * Server-side function for resolving ${model.name} content.`);
|
|
296
|
+
lines.push(` * Returns platform-level data (NO templates/zones/layouts).`);
|
|
297
|
+
lines.push(` *`);
|
|
298
|
+
lines.push(` * For CMS rendering with templates, use resolveRoute from ../cms/`);
|
|
299
|
+
lines.push(` *`);
|
|
300
|
+
lines.push(` * @generated by UniformGen - DO NOT EDIT MANUALLY`);
|
|
301
|
+
lines.push(` */`);
|
|
302
|
+
lines.push('');
|
|
303
|
+
// Imports
|
|
304
|
+
lines.push(`import type { ${dataTypeName} } from '../../types/models/${model.key}.js';`);
|
|
305
|
+
lines.push(`import type { VariantContext } from '../../types/field-types.js';`);
|
|
306
|
+
lines.push('');
|
|
307
|
+
// Re-export types
|
|
308
|
+
lines.push(`export type { VariantContext } from '../../types/field-types.js';`);
|
|
309
|
+
lines.push('');
|
|
310
|
+
// GraphQL client interface
|
|
311
|
+
lines.push(`/** GraphQL client interface */`);
|
|
312
|
+
lines.push(`export interface GraphQLClient {`);
|
|
313
|
+
lines.push(` request<T>(query: string, variables?: Record<string, unknown>): Promise<T>;`);
|
|
314
|
+
lines.push(`}`);
|
|
315
|
+
lines.push('');
|
|
316
|
+
// Generate metadata type if model has metadataSchema
|
|
317
|
+
const metadataType = generateMetadataType(model);
|
|
318
|
+
const metadataTypeName = `${typeName}Metadata`;
|
|
319
|
+
if (metadataType) {
|
|
320
|
+
lines.push(`/** Typed metadata for ${model.name} */`);
|
|
321
|
+
lines.push(`export interface ${metadataTypeName} ${metadataType}`);
|
|
322
|
+
lines.push('');
|
|
323
|
+
}
|
|
324
|
+
// Resolved types
|
|
325
|
+
lines.push(`/** Resolved ${model.name} record (platform level) */`);
|
|
326
|
+
lines.push(`export interface Resolved${typeName}Record {`);
|
|
327
|
+
lines.push(` id: string;`);
|
|
328
|
+
lines.push(` modelKey: '${model.key}';`);
|
|
329
|
+
lines.push(` naturalKey: string | null;`);
|
|
330
|
+
if (metadataType) {
|
|
331
|
+
lines.push(` metadata?: ${metadataTypeName};`);
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
lines.push(` metadata?: Record<string, unknown>;`);
|
|
335
|
+
}
|
|
336
|
+
lines.push(`}`);
|
|
337
|
+
lines.push('');
|
|
338
|
+
lines.push(`export interface Resolved${typeName}Variant {`);
|
|
339
|
+
lines.push(` id: string;`);
|
|
340
|
+
lines.push(` variantKey: string;`);
|
|
341
|
+
lines.push(` catalogKey: string | null;`);
|
|
342
|
+
lines.push(` matchedContexts: Array<{ key: string; value: string }>;`);
|
|
343
|
+
lines.push(`}`);
|
|
344
|
+
lines.push('');
|
|
345
|
+
lines.push(`export interface ${typeName}Experiment {`);
|
|
346
|
+
lines.push(` experimentId: string;`);
|
|
347
|
+
lines.push(` experimentKey: string;`);
|
|
348
|
+
lines.push(` variantId: string;`);
|
|
349
|
+
lines.push(` variantKey: string;`);
|
|
350
|
+
lines.push(` isControl: boolean;`);
|
|
351
|
+
lines.push(`}`);
|
|
352
|
+
lines.push('');
|
|
353
|
+
lines.push(`export interface ${typeName}ResolutionContext {`);
|
|
354
|
+
lines.push(` locale: string;`);
|
|
355
|
+
lines.push(` contexts: Record<string, string>;`);
|
|
356
|
+
lines.push(`}`);
|
|
357
|
+
lines.push('');
|
|
358
|
+
lines.push(`export interface Resolved${typeName} {`);
|
|
359
|
+
lines.push(` record: Resolved${typeName}Record;`);
|
|
360
|
+
lines.push(` variant: Resolved${typeName}Variant;`);
|
|
361
|
+
lines.push(` content: ${dataTypeName};`);
|
|
362
|
+
lines.push(` experiment: ${typeName}Experiment | null;`);
|
|
363
|
+
lines.push(` resolvedWith: ${typeName}ResolutionContext;`);
|
|
364
|
+
lines.push(`}`);
|
|
365
|
+
lines.push('');
|
|
366
|
+
// GraphQL query
|
|
367
|
+
lines.push(`const RESOLVE_${typeName.toUpperCase()}_QUERY = \``);
|
|
368
|
+
lines.push(` query Resolve${typeName}($naturalKey: String!, $locale: String, $contexts: JSON) {`);
|
|
369
|
+
lines.push(` resolveEntity(modelKey: "${model.key}", naturalKey: $naturalKey, locale: $locale, contexts: $contexts) {`);
|
|
370
|
+
lines.push(` record { id modelKey naturalKey metadata }`);
|
|
371
|
+
lines.push(` variant { id variantKey catalogKey matchedContexts { key value } }`);
|
|
372
|
+
lines.push(` content`);
|
|
373
|
+
lines.push(` experiment { experimentId experimentKey variantId variantKey isControl }`);
|
|
374
|
+
lines.push(` resolvedWith { locale contexts }`);
|
|
375
|
+
lines.push(` }`);
|
|
376
|
+
lines.push(` }`);
|
|
377
|
+
lines.push(`\`;`);
|
|
378
|
+
lines.push('');
|
|
379
|
+
// Function
|
|
380
|
+
lines.push(`/**`);
|
|
381
|
+
lines.push(` * Resolve ${model.name} by natural key with variant selection`);
|
|
382
|
+
lines.push(` * Use in Remix loaders or Hydrogen server functions.`);
|
|
383
|
+
lines.push(` */`);
|
|
384
|
+
lines.push(`export async function resolve${typeName}(`);
|
|
385
|
+
lines.push(` client: GraphQLClient,`);
|
|
386
|
+
lines.push(` naturalKey: string,`);
|
|
387
|
+
lines.push(` context?: VariantContext`);
|
|
388
|
+
lines.push(`): Promise<Resolved${typeName} | null> {`);
|
|
389
|
+
lines.push(` const result = await client.request<{ resolveEntity: any }>(RESOLVE_${typeName.toUpperCase()}_QUERY, {`);
|
|
390
|
+
lines.push(` naturalKey,`);
|
|
391
|
+
lines.push(` locale: context?.locale,`);
|
|
392
|
+
lines.push(` contexts: context?.contexts,`);
|
|
393
|
+
lines.push(` });`);
|
|
394
|
+
lines.push(` if (!result.resolveEntity) return null;`);
|
|
395
|
+
lines.push(` const data = result.resolveEntity;`);
|
|
396
|
+
lines.push(` return {`);
|
|
397
|
+
lines.push(` record: { ...data.record, modelKey: '${model.key}' },`);
|
|
398
|
+
lines.push(` variant: { ...data.variant, matchedContexts: data.variant.matchedContexts ?? [] },`);
|
|
399
|
+
lines.push(` content: data.content as ${dataTypeName},`);
|
|
400
|
+
lines.push(` experiment: data.experiment,`);
|
|
401
|
+
lines.push(` resolvedWith: data.resolvedWith,`);
|
|
402
|
+
lines.push(` };`);
|
|
403
|
+
lines.push(`}`);
|
|
404
|
+
return lines.join('\n') + '\n';
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Generate index file for platform resolve hooks (React)
|
|
408
|
+
*/
|
|
409
|
+
export function generatePlatformResolveIndexReact(models) {
|
|
410
|
+
const recordModels = models.filter((m) => m.modes.records && m.modes.publicApi);
|
|
411
|
+
let indexCode = `/**
|
|
412
|
+
* Platform Resolution Hooks
|
|
413
|
+
*
|
|
414
|
+
* React hooks for platform-level entity resolution.
|
|
415
|
+
* Returns resolved content WITHOUT CMS features.
|
|
416
|
+
*
|
|
417
|
+
* For CMS rendering with templates, use ../cms/ exports.
|
|
418
|
+
*
|
|
419
|
+
* @generated by UniformGen - DO NOT EDIT MANUALLY
|
|
420
|
+
*/\n\n`;
|
|
421
|
+
// Re-export base types
|
|
422
|
+
indexCode += `// Re-export base types\n`;
|
|
423
|
+
indexCode += `export type { VariantContext } from '../types/field-types.js';\n\n`;
|
|
424
|
+
for (const model of recordModels) {
|
|
425
|
+
const typeName = toPascalCase(model.key);
|
|
426
|
+
const hasMetadata = model.metadataSchema?.fields && model.metadataSchema.fields.length > 0;
|
|
427
|
+
indexCode += `export {\n`;
|
|
428
|
+
indexCode += ` useResolve${typeName},\n`;
|
|
429
|
+
indexCode += ` type Resolved${typeName},\n`;
|
|
430
|
+
indexCode += ` type Resolved${typeName}Record,\n`;
|
|
431
|
+
indexCode += ` type Resolved${typeName}Variant,\n`;
|
|
432
|
+
indexCode += ` type ${typeName}Experiment,\n`;
|
|
433
|
+
indexCode += ` type ${typeName}ResolutionContext,\n`;
|
|
434
|
+
if (hasMetadata) {
|
|
435
|
+
indexCode += ` type ${typeName}Metadata,\n`;
|
|
436
|
+
}
|
|
437
|
+
indexCode += `} from './${model.key}.js';\n`;
|
|
438
|
+
}
|
|
439
|
+
return indexCode;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Generate index file for platform resolve functions (Remix)
|
|
443
|
+
*/
|
|
444
|
+
export function generatePlatformResolveIndexRemix(models) {
|
|
445
|
+
const recordModels = models.filter((m) => m.modes.records && m.modes.publicApi);
|
|
446
|
+
let indexCode = `/**
|
|
447
|
+
* Platform Resolution Functions
|
|
448
|
+
*
|
|
449
|
+
* Server-side functions for platform-level entity resolution.
|
|
450
|
+
* Returns resolved content WITHOUT CMS features.
|
|
451
|
+
*
|
|
452
|
+
* For CMS rendering with templates, use ../cms/ exports.
|
|
453
|
+
*
|
|
454
|
+
* @generated by UniformGen - DO NOT EDIT MANUALLY
|
|
455
|
+
*/\n\n`;
|
|
456
|
+
// Re-export base types
|
|
457
|
+
indexCode += `export type { VariantContext } from '../types/field-types.js';\n\n`;
|
|
458
|
+
// Export GraphQL client type from first model
|
|
459
|
+
const firstModel = recordModels[0];
|
|
460
|
+
if (firstModel) {
|
|
461
|
+
indexCode += `export type { GraphQLClient } from './${firstModel.key}.js';\n\n`;
|
|
462
|
+
}
|
|
463
|
+
for (const model of recordModels) {
|
|
464
|
+
const typeName = toPascalCase(model.key);
|
|
465
|
+
const hasMetadata = model.metadataSchema?.fields && model.metadataSchema.fields.length > 0;
|
|
466
|
+
indexCode += `export {\n`;
|
|
467
|
+
indexCode += ` resolve${typeName},\n`;
|
|
468
|
+
indexCode += ` type Resolved${typeName},\n`;
|
|
469
|
+
indexCode += ` type Resolved${typeName}Record,\n`;
|
|
470
|
+
indexCode += ` type Resolved${typeName}Variant,\n`;
|
|
471
|
+
indexCode += ` type ${typeName}Experiment,\n`;
|
|
472
|
+
indexCode += ` type ${typeName}ResolutionContext,\n`;
|
|
473
|
+
if (hasMetadata) {
|
|
474
|
+
indexCode += ` type ${typeName}Metadata,\n`;
|
|
475
|
+
}
|
|
476
|
+
indexCode += `} from './${model.key}.js';\n`;
|
|
477
|
+
}
|
|
478
|
+
return indexCode;
|
|
479
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/generators/types/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,kBAAkB,IAAI,MAAM,CA2G3C"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the config.ts file with EntityModelConfig type
|
|
3
|
+
*
|
|
4
|
+
* @generated by UniformGen
|
|
5
|
+
*/
|
|
6
|
+
export function generateConfigFile() {
|
|
7
|
+
return `/**
|
|
8
|
+
* Entity Model Configuration Type
|
|
9
|
+
*
|
|
10
|
+
* This is the main type for defining entity model configurations.
|
|
11
|
+
* Use this to create strongly-typed entity model definitions.
|
|
12
|
+
*
|
|
13
|
+
* @generated by UniformGen - DO NOT EDIT MANUALLY
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { FieldDef } from './field-types.js';
|
|
17
|
+
import type { EntityHooks } from './hooks.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Routing configuration for entity models
|
|
21
|
+
*/
|
|
22
|
+
export interface RoutingConfig {
|
|
23
|
+
/** Whether this entity type can be used in routes */
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
/** Sitemap configuration */
|
|
26
|
+
sitemap?: {
|
|
27
|
+
/** Change frequency hint for search engines */
|
|
28
|
+
changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
29
|
+
/** Base priority (0.0 to 1.0) */
|
|
30
|
+
priority?: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Entity model configuration
|
|
36
|
+
*
|
|
37
|
+
* This defines the complete configuration for an entity model including
|
|
38
|
+
* its schema, behavior, and lifecycle hooks.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* export const blogPostConfig = {
|
|
42
|
+
* key: 'blog-post',
|
|
43
|
+
* name: 'Blog Post',
|
|
44
|
+
* versions: true,
|
|
45
|
+
* variants: false,
|
|
46
|
+
* customFields: true,
|
|
47
|
+
* mode: 'records',
|
|
48
|
+
* publicApi: true,
|
|
49
|
+
* editorMode: 'flat',
|
|
50
|
+
* fieldDefs: [
|
|
51
|
+
* { key: 'title', type: 'text', label: 'Title', required: true },
|
|
52
|
+
* { key: 'content', type: 'richtext', label: 'Content' },
|
|
53
|
+
* ],
|
|
54
|
+
* } as const satisfies EntityModelConfig;
|
|
55
|
+
*/
|
|
56
|
+
export interface EntityModelConfig {
|
|
57
|
+
/** Unique identifier (kebab-case) */
|
|
58
|
+
key: string;
|
|
59
|
+
/** Display name */
|
|
60
|
+
name: string;
|
|
61
|
+
/** Description of the entity model */
|
|
62
|
+
description?: string;
|
|
63
|
+
|
|
64
|
+
// Feature flags
|
|
65
|
+
/** Enable version history (tier >= 2) */
|
|
66
|
+
versions: boolean;
|
|
67
|
+
/** Enable market/device/locale variants (tier >= 3) */
|
|
68
|
+
variants: boolean;
|
|
69
|
+
/** Allow users to add custom fields to instances */
|
|
70
|
+
customFields: boolean;
|
|
71
|
+
|
|
72
|
+
// Usage mode
|
|
73
|
+
/**
|
|
74
|
+
* How this model can be used:
|
|
75
|
+
* - 'inline': Only as a field type in other models
|
|
76
|
+
* - 'records': Can create standalone records
|
|
77
|
+
* - 'both': Both inline and records
|
|
78
|
+
*/
|
|
79
|
+
mode: 'inline' | 'records' | 'both';
|
|
80
|
+
/** Whether to expose via public GraphQL API */
|
|
81
|
+
publicApi: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Editor mode:
|
|
84
|
+
* - 'flat': Standard form fields
|
|
85
|
+
* - 'tree': Hierarchical nested editor
|
|
86
|
+
*/
|
|
87
|
+
editorMode: 'flat' | 'tree';
|
|
88
|
+
|
|
89
|
+
// Associations
|
|
90
|
+
/** Default template reference (natural key) */
|
|
91
|
+
defaultTemplate?: string | null;
|
|
92
|
+
|
|
93
|
+
// Routing
|
|
94
|
+
/** Routing configuration */
|
|
95
|
+
routing?: RoutingConfig;
|
|
96
|
+
|
|
97
|
+
// Lifecycle hooks
|
|
98
|
+
/** Lifecycle hooks configuration */
|
|
99
|
+
hooks?: EntityHooks;
|
|
100
|
+
|
|
101
|
+
// Schema
|
|
102
|
+
/** Field definitions */
|
|
103
|
+
fieldDefs: readonly FieldDef[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Helper to create a type-safe entity model config
|
|
108
|
+
*/
|
|
109
|
+
export function defineEntityModel<T extends EntityModelConfig>(config: T): T {
|
|
110
|
+
return config;
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
113
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DataModelSchema } from '../../fetcher/fetch-schemas.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generate TypeScript types for a data model
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateDataModelTypes(model: DataModelSchema, _useUnknownForJSON: boolean): string;
|
|
6
|
+
/**
|
|
7
|
+
* Generate index file for data models
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateDataModelsIndex(models: DataModelSchema[]): string;
|
|
10
|
+
//# sourceMappingURL=data-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-models.d.ts","sourceRoot":"","sources":["../../../src/generators/types/data-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAQtE;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,EACtB,kBAAkB,EAAE,OAAO,GAC1B,MAAM,CA6FR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAqBzE"}
|