@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,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Hooks Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates typed React hooks for workflow execution using Apollo Client.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Convert string to PascalCase
|
|
8
|
+
*/
|
|
9
|
+
function toPascalCase(str) {
|
|
10
|
+
return str
|
|
11
|
+
.split(/[-_]/)
|
|
12
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
13
|
+
.join('');
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Convert string to camelCase
|
|
17
|
+
*/
|
|
18
|
+
function toCamelCase(str) {
|
|
19
|
+
const pascal = toPascalCase(str);
|
|
20
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate React hooks for a single workflow
|
|
24
|
+
*/
|
|
25
|
+
export function generateWorkflowReactHooks(workflow) {
|
|
26
|
+
const typeName = toPascalCase(workflow.key);
|
|
27
|
+
const camelName = toCamelCase(workflow.key);
|
|
28
|
+
const lines = [];
|
|
29
|
+
// File header
|
|
30
|
+
lines.push('/**');
|
|
31
|
+
lines.push(` * ${workflow.name} - React Hooks`);
|
|
32
|
+
if (workflow.description) {
|
|
33
|
+
lines.push(` * ${workflow.description}`);
|
|
34
|
+
}
|
|
35
|
+
lines.push(' *');
|
|
36
|
+
lines.push(' * @generated by UniformGen - DO NOT EDIT MANUALLY');
|
|
37
|
+
lines.push(' */');
|
|
38
|
+
lines.push('');
|
|
39
|
+
// Imports
|
|
40
|
+
lines.push("import { useMutation, useQuery, type MutationHookOptions, type QueryHookOptions } from '@apollo/client';");
|
|
41
|
+
lines.push("import {");
|
|
42
|
+
lines.push(" PublicExecuteWorkflowDocument,");
|
|
43
|
+
lines.push(" PublicWorkflowExecutionDocument,");
|
|
44
|
+
lines.push("} from '../documents/workflows.js';");
|
|
45
|
+
lines.push(`import type { ${typeName}Input, ${typeName}Output } from '../types/workflows/${workflow.key}.js';`);
|
|
46
|
+
lines.push('');
|
|
47
|
+
// Execution result type
|
|
48
|
+
lines.push('/** Execution result type */');
|
|
49
|
+
lines.push(`export interface ${typeName}ExecutionResult {`);
|
|
50
|
+
lines.push(' success: boolean;');
|
|
51
|
+
lines.push(' executionId?: string;');
|
|
52
|
+
lines.push(' queued?: boolean;');
|
|
53
|
+
lines.push(` result?: ${typeName}Output;`);
|
|
54
|
+
lines.push(' error?: { code: string; message: string };');
|
|
55
|
+
lines.push('}');
|
|
56
|
+
lines.push('');
|
|
57
|
+
// Execution status type
|
|
58
|
+
lines.push('/** Execution status type */');
|
|
59
|
+
lines.push(`export interface ${typeName}ExecutionStatus {`);
|
|
60
|
+
lines.push(' id: string;');
|
|
61
|
+
lines.push(' workflowKey: string;');
|
|
62
|
+
lines.push(" status: 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';");
|
|
63
|
+
lines.push(` result?: ${typeName}Output;`);
|
|
64
|
+
lines.push(' error?: { code: string; message: string };');
|
|
65
|
+
lines.push(' createdAt: string;');
|
|
66
|
+
lines.push(' completedAt?: string;');
|
|
67
|
+
lines.push('}');
|
|
68
|
+
lines.push('');
|
|
69
|
+
// useExecute hook
|
|
70
|
+
lines.push('/**');
|
|
71
|
+
lines.push(` * Execute the ${workflow.name} workflow`);
|
|
72
|
+
lines.push(' *');
|
|
73
|
+
lines.push(' * @example');
|
|
74
|
+
lines.push(` * const [execute, { loading, error }] = use${typeName}();`);
|
|
75
|
+
lines.push(' * ');
|
|
76
|
+
lines.push(' * const handleExecute = async () => {');
|
|
77
|
+
lines.push(` * const result = await execute({ /* input */ });`);
|
|
78
|
+
lines.push(' * if (result.queued) {');
|
|
79
|
+
lines.push(' * // Track execution via executionId');
|
|
80
|
+
lines.push(' * } else {');
|
|
81
|
+
lines.push(' * // Use result.result directly');
|
|
82
|
+
lines.push(' * }');
|
|
83
|
+
lines.push(' * };');
|
|
84
|
+
lines.push(' */');
|
|
85
|
+
lines.push(`export function use${typeName}(options?: MutationHookOptions) {`);
|
|
86
|
+
lines.push(' const [mutate, result] = useMutation(PublicExecuteWorkflowDocument, options);');
|
|
87
|
+
lines.push('');
|
|
88
|
+
lines.push(` const ${camelName} = async (input: ${typeName}Input): Promise<${typeName}ExecutionResult> => {`);
|
|
89
|
+
lines.push(' const response = await mutate({');
|
|
90
|
+
lines.push(' variables: {');
|
|
91
|
+
lines.push(' input: {');
|
|
92
|
+
lines.push(` workflowKey: '${workflow.key}',`);
|
|
93
|
+
lines.push(' input,');
|
|
94
|
+
lines.push(' },');
|
|
95
|
+
lines.push(' },');
|
|
96
|
+
lines.push(' });');
|
|
97
|
+
lines.push('');
|
|
98
|
+
lines.push(' const data = response.data?.publicExecuteWorkflow;');
|
|
99
|
+
lines.push(' return {');
|
|
100
|
+
lines.push(' success: data?.success ?? false,');
|
|
101
|
+
lines.push(' executionId: data?.executionId ?? undefined,');
|
|
102
|
+
lines.push(' queued: data?.queued ?? undefined,');
|
|
103
|
+
lines.push(` result: data?.result as ${typeName}Output | undefined,`);
|
|
104
|
+
lines.push(' error: data?.error ?? undefined,');
|
|
105
|
+
lines.push(' };');
|
|
106
|
+
lines.push(' };');
|
|
107
|
+
lines.push('');
|
|
108
|
+
lines.push(` return [${camelName}, result] as const;`);
|
|
109
|
+
lines.push('}');
|
|
110
|
+
lines.push('');
|
|
111
|
+
// useExecution hook
|
|
112
|
+
lines.push('/**');
|
|
113
|
+
lines.push(` * Get ${workflow.name} execution status`);
|
|
114
|
+
lines.push(' *');
|
|
115
|
+
lines.push(' * Use this to poll for async workflow completion.');
|
|
116
|
+
lines.push(' *');
|
|
117
|
+
lines.push(' * @example');
|
|
118
|
+
lines.push(` * const { execution, loading } = use${typeName}Execution(executionId, {`);
|
|
119
|
+
lines.push(' * pollInterval: 1000, // Poll every second');
|
|
120
|
+
lines.push(' * skip: !executionId,');
|
|
121
|
+
lines.push(' * });');
|
|
122
|
+
lines.push(' * ');
|
|
123
|
+
lines.push(" * if (execution?.status === 'COMPLETED') {");
|
|
124
|
+
lines.push(' * // Use execution.result');
|
|
125
|
+
lines.push(' * }');
|
|
126
|
+
lines.push(' */');
|
|
127
|
+
lines.push(`export function use${typeName}Execution(`);
|
|
128
|
+
lines.push(' executionId: string | undefined,');
|
|
129
|
+
lines.push(' options?: Omit<QueryHookOptions, "variables">');
|
|
130
|
+
lines.push(') {');
|
|
131
|
+
lines.push(' const result = useQuery(PublicWorkflowExecutionDocument, {');
|
|
132
|
+
lines.push(' ...options,');
|
|
133
|
+
lines.push(' variables: { id: executionId! },');
|
|
134
|
+
lines.push(' skip: !executionId || options?.skip,');
|
|
135
|
+
lines.push(' });');
|
|
136
|
+
lines.push('');
|
|
137
|
+
lines.push(` const execution: ${typeName}ExecutionStatus | undefined = result.data?.publicWorkflowExecution`);
|
|
138
|
+
lines.push(' ? {');
|
|
139
|
+
lines.push(' ...result.data.publicWorkflowExecution,');
|
|
140
|
+
lines.push(` result: result.data.publicWorkflowExecution.result as ${typeName}Output | undefined,`);
|
|
141
|
+
lines.push(' }');
|
|
142
|
+
lines.push(' : undefined;');
|
|
143
|
+
lines.push('');
|
|
144
|
+
lines.push(' return {');
|
|
145
|
+
lines.push(' ...result,');
|
|
146
|
+
lines.push(' execution,');
|
|
147
|
+
lines.push(' };');
|
|
148
|
+
lines.push('}');
|
|
149
|
+
return lines.join('\n') + '\n';
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Generate Remix server functions for a single workflow
|
|
153
|
+
*/
|
|
154
|
+
export function generateWorkflowRemixHooks(workflow) {
|
|
155
|
+
// For Remix, we generate server-side functions that can be used in loaders/actions
|
|
156
|
+
// The generated code is similar but uses graphql-request instead of Apollo
|
|
157
|
+
const typeName = toPascalCase(workflow.key);
|
|
158
|
+
const camelName = toCamelCase(workflow.key);
|
|
159
|
+
const lines = [];
|
|
160
|
+
// File header
|
|
161
|
+
lines.push('/**');
|
|
162
|
+
lines.push(` * ${workflow.name} - Remix Server Functions`);
|
|
163
|
+
if (workflow.description) {
|
|
164
|
+
lines.push(` * ${workflow.description}`);
|
|
165
|
+
}
|
|
166
|
+
lines.push(' *');
|
|
167
|
+
lines.push(' * @generated by UniformGen - DO NOT EDIT MANUALLY');
|
|
168
|
+
lines.push(' */');
|
|
169
|
+
lines.push('');
|
|
170
|
+
// Imports
|
|
171
|
+
lines.push("import type { GraphQLClient } from 'graphql-request';");
|
|
172
|
+
lines.push("import {");
|
|
173
|
+
lines.push(" PublicExecuteWorkflowDocument,");
|
|
174
|
+
lines.push(" PublicWorkflowExecutionDocument,");
|
|
175
|
+
lines.push("} from '../documents/workflows.js';");
|
|
176
|
+
lines.push(`import type { ${typeName}Input, ${typeName}Output } from '../types/workflows/${workflow.key}.js';`);
|
|
177
|
+
lines.push('');
|
|
178
|
+
// Execution result type
|
|
179
|
+
lines.push('/** Execution result type */');
|
|
180
|
+
lines.push(`export interface ${typeName}ExecutionResult {`);
|
|
181
|
+
lines.push(' success: boolean;');
|
|
182
|
+
lines.push(' executionId?: string;');
|
|
183
|
+
lines.push(' queued?: boolean;');
|
|
184
|
+
lines.push(` result?: ${typeName}Output;`);
|
|
185
|
+
lines.push(' error?: { code: string; message: string };');
|
|
186
|
+
lines.push('}');
|
|
187
|
+
lines.push('');
|
|
188
|
+
// Execution status type
|
|
189
|
+
lines.push('/** Execution status type */');
|
|
190
|
+
lines.push(`export interface ${typeName}ExecutionStatus {`);
|
|
191
|
+
lines.push(' id: string;');
|
|
192
|
+
lines.push(' workflowKey: string;');
|
|
193
|
+
lines.push(" status: 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';");
|
|
194
|
+
lines.push(` result?: ${typeName}Output;`);
|
|
195
|
+
lines.push(' error?: { code: string; message: string };');
|
|
196
|
+
lines.push(' createdAt: string;');
|
|
197
|
+
lines.push(' completedAt?: string;');
|
|
198
|
+
lines.push('}');
|
|
199
|
+
lines.push('');
|
|
200
|
+
// Execute function
|
|
201
|
+
lines.push('/**');
|
|
202
|
+
lines.push(` * Execute the ${workflow.name} workflow`);
|
|
203
|
+
lines.push(' *');
|
|
204
|
+
lines.push(' * @example');
|
|
205
|
+
lines.push(' * // In a Remix action');
|
|
206
|
+
lines.push(' * export async function action({ request }) {');
|
|
207
|
+
lines.push(' * const client = new GraphQLClient(API_URL, {');
|
|
208
|
+
lines.push(" * headers: { 'x-api-key': API_KEY }");
|
|
209
|
+
lines.push(' * });');
|
|
210
|
+
lines.push(' *');
|
|
211
|
+
lines.push(' * const formData = await request.formData();');
|
|
212
|
+
lines.push(` * const result = await ${camelName}({ /* input */ }, client);`);
|
|
213
|
+
lines.push(' * return json(result);');
|
|
214
|
+
lines.push(' * }');
|
|
215
|
+
lines.push(' */');
|
|
216
|
+
lines.push(`export async function ${camelName}(`);
|
|
217
|
+
lines.push(` input: ${typeName}Input,`);
|
|
218
|
+
lines.push(' client: GraphQLClient');
|
|
219
|
+
lines.push(`): Promise<${typeName}ExecutionResult> {`);
|
|
220
|
+
lines.push(' const response = await client.request(PublicExecuteWorkflowDocument, {');
|
|
221
|
+
lines.push(' input: {');
|
|
222
|
+
lines.push(` workflowKey: '${workflow.key}',`);
|
|
223
|
+
lines.push(' input,');
|
|
224
|
+
lines.push(' },');
|
|
225
|
+
lines.push(' });');
|
|
226
|
+
lines.push('');
|
|
227
|
+
lines.push(' const data = (response as any).publicExecuteWorkflow;');
|
|
228
|
+
lines.push(' return {');
|
|
229
|
+
lines.push(' success: data?.success ?? false,');
|
|
230
|
+
lines.push(' executionId: data?.executionId ?? undefined,');
|
|
231
|
+
lines.push(' queued: data?.queued ?? undefined,');
|
|
232
|
+
lines.push(` result: data?.result as ${typeName}Output | undefined,`);
|
|
233
|
+
lines.push(' error: data?.error ?? undefined,');
|
|
234
|
+
lines.push(' };');
|
|
235
|
+
lines.push('}');
|
|
236
|
+
lines.push('');
|
|
237
|
+
// Get execution function
|
|
238
|
+
lines.push('/**');
|
|
239
|
+
lines.push(` * Get ${workflow.name} execution status`);
|
|
240
|
+
lines.push(' *');
|
|
241
|
+
lines.push(' * @example');
|
|
242
|
+
lines.push(' * // In a Remix loader');
|
|
243
|
+
lines.push(' * export async function loader({ params }) {');
|
|
244
|
+
lines.push(' * const client = new GraphQLClient(API_URL, {');
|
|
245
|
+
lines.push(" * headers: { 'x-api-key': API_KEY }");
|
|
246
|
+
lines.push(' * });');
|
|
247
|
+
lines.push(' *');
|
|
248
|
+
lines.push(` * const status = await get${typeName}Execution(params.executionId, client);`);
|
|
249
|
+
lines.push(' * return json(status);');
|
|
250
|
+
lines.push(' * }');
|
|
251
|
+
lines.push(' */');
|
|
252
|
+
lines.push(`export async function get${typeName}Execution(`);
|
|
253
|
+
lines.push(' executionId: string,');
|
|
254
|
+
lines.push(' client: GraphQLClient');
|
|
255
|
+
lines.push(`): Promise<${typeName}ExecutionStatus | null> {`);
|
|
256
|
+
lines.push(' const response = await client.request(PublicWorkflowExecutionDocument, {');
|
|
257
|
+
lines.push(' id: executionId,');
|
|
258
|
+
lines.push(' });');
|
|
259
|
+
lines.push('');
|
|
260
|
+
lines.push(' const data = (response as any).publicWorkflowExecution;');
|
|
261
|
+
lines.push(' if (!data) return null;');
|
|
262
|
+
lines.push('');
|
|
263
|
+
lines.push(' return {');
|
|
264
|
+
lines.push(' ...data,');
|
|
265
|
+
lines.push(` result: data.result as ${typeName}Output | undefined,`);
|
|
266
|
+
lines.push(' };');
|
|
267
|
+
lines.push('}');
|
|
268
|
+
return lines.join('\n') + '\n';
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Generate index file for workflow React hooks
|
|
272
|
+
*/
|
|
273
|
+
export function generateWorkflowReactHooksIndex(workflows) {
|
|
274
|
+
const lines = [];
|
|
275
|
+
lines.push('/**');
|
|
276
|
+
lines.push(' * Workflow React Hooks');
|
|
277
|
+
lines.push(' * @generated by UniformGen - DO NOT EDIT MANUALLY');
|
|
278
|
+
lines.push(' */');
|
|
279
|
+
lines.push('');
|
|
280
|
+
for (const workflow of workflows) {
|
|
281
|
+
const typeName = toPascalCase(workflow.key);
|
|
282
|
+
lines.push(`export {`);
|
|
283
|
+
lines.push(` use${typeName},`);
|
|
284
|
+
lines.push(` use${typeName}Execution,`);
|
|
285
|
+
lines.push(` type ${typeName}ExecutionResult,`);
|
|
286
|
+
lines.push(` type ${typeName}ExecutionStatus,`);
|
|
287
|
+
lines.push(`} from './${workflow.key}.js';`);
|
|
288
|
+
}
|
|
289
|
+
return lines.join('\n') + '\n';
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Generate index file for workflow Remix functions
|
|
293
|
+
*/
|
|
294
|
+
export function generateWorkflowRemixHooksIndex(workflows) {
|
|
295
|
+
const lines = [];
|
|
296
|
+
lines.push('/**');
|
|
297
|
+
lines.push(' * Workflow Remix Server Functions');
|
|
298
|
+
lines.push(' * @generated by UniformGen - DO NOT EDIT MANUALLY');
|
|
299
|
+
lines.push(' */');
|
|
300
|
+
lines.push('');
|
|
301
|
+
for (const workflow of workflows) {
|
|
302
|
+
const typeName = toPascalCase(workflow.key);
|
|
303
|
+
const camelName = toCamelCase(workflow.key);
|
|
304
|
+
lines.push(`export {`);
|
|
305
|
+
lines.push(` ${camelName},`);
|
|
306
|
+
lines.push(` get${typeName}Execution,`);
|
|
307
|
+
lines.push(` type ${typeName}ExecutionResult,`);
|
|
308
|
+
lines.push(` type ${typeName}ExecutionStatus,`);
|
|
309
|
+
lines.push(`} from './${workflow.key}.js';`);
|
|
310
|
+
}
|
|
311
|
+
return lines.join('\n') + '\n';
|
|
312
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve Query Generators
|
|
3
|
+
*
|
|
4
|
+
* Generates typed hooks/functions for frontend entity resolution.
|
|
5
|
+
*
|
|
6
|
+
* Phase 13 structure:
|
|
7
|
+
* - Platform resolution: useResolve{Model} - Returns content WITHOUT CMS features
|
|
8
|
+
* - CMS resolution: useResolveRoute - Returns full template/zone/layout data (see cms/route.ts)
|
|
9
|
+
*
|
|
10
|
+
* @generated by UniformGen
|
|
11
|
+
*/
|
|
12
|
+
export { generatePlatformResolveReact, generatePlatformResolveRemix, generatePlatformResolveIndexReact, generatePlatformResolveIndexRemix, } from './platform.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/resolve/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,iCAAiC,EACjC,iCAAiC,GAClC,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve Query Generators
|
|
3
|
+
*
|
|
4
|
+
* Generates typed hooks/functions for frontend entity resolution.
|
|
5
|
+
*
|
|
6
|
+
* Phase 13 structure:
|
|
7
|
+
* - Platform resolution: useResolve{Model} - Returns content WITHOUT CMS features
|
|
8
|
+
* - CMS resolution: useResolveRoute - Returns full template/zone/layout data (see cms/route.ts)
|
|
9
|
+
*
|
|
10
|
+
* @generated by UniformGen
|
|
11
|
+
*/
|
|
12
|
+
// Export platform generators
|
|
13
|
+
export { generatePlatformResolveReact, generatePlatformResolveRemix, generatePlatformResolveIndexReact, generatePlatformResolveIndexRemix, } from './platform.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
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 type { EntityModel } from '../../fetcher/fetch-schemas.js';
|
|
13
|
+
/**
|
|
14
|
+
* Generate React platform resolve hook for a model
|
|
15
|
+
*/
|
|
16
|
+
export declare function generatePlatformResolveReact(model: EntityModel, _allModels: EntityModel[]): string;
|
|
17
|
+
/**
|
|
18
|
+
* Generate Remix/Hydrogen platform resolve function for a model
|
|
19
|
+
*/
|
|
20
|
+
export declare function generatePlatformResolveRemix(model: EntityModel, _allModels: EntityModel[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* Generate index file for platform resolve hooks (React)
|
|
23
|
+
*/
|
|
24
|
+
export declare function generatePlatformResolveIndexReact(models: EntityModel[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Generate index file for platform resolve functions (Remix)
|
|
27
|
+
*/
|
|
28
|
+
export declare function generatePlatformResolveIndexRemix(models: EntityModel[]): string;
|
|
29
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../src/generators/resolve/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gCAAgC,CAAC;AA6FvF;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,WAAW,EAAE,GACxB,MAAM,CAyMR;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,WAAW,EAAE,GACxB,MAAM,CAwIR;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAoC/E;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAyC/E"}
|