@mettlecast/domain-cli 0.2.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/CHANGELOG.md +18 -0
- package/README.md +133 -0
- package/dist/builder/build-registry.d.ts +20 -0
- package/dist/builder/build-registry.js +178 -0
- package/dist/builder/build-types.d.ts +10 -0
- package/dist/builder/build-types.js +32 -0
- package/dist/builder/load-domain-module-config.d.ts +12 -0
- package/dist/builder/load-domain-module-config.js +34 -0
- package/dist/builder/load-module.d.ts +26 -0
- package/dist/builder/load-module.js +114 -0
- package/dist/builder/zod-to-json.d.ts +10 -0
- package/dist/builder/zod-to-json.js +15 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +338 -0
- package/dist/commands/add-api.d.ts +32 -0
- package/dist/commands/add-api.js +106 -0
- package/dist/commands/add-component.d.ts +15 -0
- package/dist/commands/add-component.js +78 -0
- package/dist/commands/add-domain.d.ts +21 -0
- package/dist/commands/add-domain.js +71 -0
- package/dist/commands/add-flow.d.ts +14 -0
- package/dist/commands/add-flow.js +108 -0
- package/dist/commands/add-hook.d.ts +15 -0
- package/dist/commands/add-hook.js +65 -0
- package/dist/commands/add-migration.d.ts +26 -0
- package/dist/commands/add-migration.js +93 -0
- package/dist/commands/add-module.d.ts +7 -0
- package/dist/commands/add-module.js +261 -0
- package/dist/commands/add-page.d.ts +13 -0
- package/dist/commands/add-page.js +170 -0
- package/dist/commands/add-seed-page.d.ts +5 -0
- package/dist/commands/add-seed-page.js +251 -0
- package/dist/commands/add-subscriber.d.ts +30 -0
- package/dist/commands/add-subscriber.js +87 -0
- package/dist/commands/add-test.d.ts +22 -0
- package/dist/commands/add-test.js +285 -0
- package/dist/commands/audit.d.ts +39 -0
- package/dist/commands/audit.js +171 -0
- package/dist/commands/build-catalog.d.ts +68 -0
- package/dist/commands/build-catalog.js +105 -0
- package/dist/commands/build-flows.d.ts +26 -0
- package/dist/commands/build-flows.js +174 -0
- package/dist/commands/build.d.ts +17 -0
- package/dist/commands/build.js +39 -0
- package/dist/commands/check-hashes.d.ts +38 -0
- package/dist/commands/check-hashes.js +97 -0
- package/dist/commands/create-project.d.ts +5 -0
- package/dist/commands/create-project.js +272 -0
- package/dist/commands/dev.d.ts +15 -0
- package/dist/commands/dev.js +27 -0
- package/dist/commands/doctor.d.ts +48 -0
- package/dist/commands/doctor.js +1301 -0
- package/dist/commands/explain.d.ts +34 -0
- package/dist/commands/explain.js +167 -0
- package/dist/commands/power-tune.d.ts +1 -0
- package/dist/commands/power-tune.js +87 -0
- package/dist/commands/reseed-page.d.ts +6 -0
- package/dist/commands/reseed-page.js +297 -0
- package/dist/commands/show-dns.d.ts +15 -0
- package/dist/commands/show-dns.js +101 -0
- package/dist/commands/show.d.ts +46 -0
- package/dist/commands/show.js +135 -0
- package/dist/commands/test.d.ts +18 -0
- package/dist/commands/test.js +56 -0
- package/dist/commands/upgrade-backend.d.ts +9 -0
- package/dist/commands/upgrade-backend.js +46 -0
- package/dist/commands/upgrade-event.d.ts +22 -0
- package/dist/commands/upgrade-event.js +111 -0
- package/dist/commands/upgrade-frontend.d.ts +5 -0
- package/dist/commands/upgrade-frontend.js +99 -0
- package/dist/commands/upgrade.d.ts +7 -0
- package/dist/commands/upgrade.js +495 -0
- package/dist/commands/validate.d.ts +30 -0
- package/dist/commands/validate.js +148 -0
- package/dist/runtime-stubs/hydrate-local-ctx.d.ts +49 -0
- package/dist/runtime-stubs/hydrate-local-ctx.js +45 -0
- package/dist/runtime-stubs/load-secrets.d.ts +11 -0
- package/dist/runtime-stubs/load-secrets.js +37 -0
- package/dist/server/api-server.d.ts +21 -0
- package/dist/server/api-server.js +14 -0
- package/dist/server/mount-routes.d.ts +19 -0
- package/dist/server/mount-routes.js +42 -0
- package/dist/templates/api-skeleton.d.ts +18 -0
- package/dist/templates/api-skeleton.js +69 -0
- package/dist/templates/claude-md.d.ts +4 -0
- package/dist/templates/claude-md.js +7 -0
- package/dist/templates/dashboard-pages/index.d.ts +101 -0
- package/dist/templates/dashboard-pages/index.js +22 -0
- package/dist/templates/domain-config.d.ts +10 -0
- package/dist/templates/domain-config.js +19 -0
- package/dist/templates/events-skeleton.d.ts +9 -0
- package/dist/templates/events-skeleton.js +23 -0
- package/dist/templates/patterns/api/create-with-event.d.ts +5 -0
- package/dist/templates/patterns/api/create-with-event.js +69 -0
- package/dist/templates/patterns/api/idempotent-mutation.d.ts +5 -0
- package/dist/templates/patterns/api/idempotent-mutation.js +99 -0
- package/dist/templates/patterns/api/paginated-list.d.ts +5 -0
- package/dist/templates/patterns/api/paginated-list.js +71 -0
- package/dist/templates/patterns/api/simple-crud.d.ts +6 -0
- package/dist/templates/patterns/api/simple-crud.js +95 -0
- package/dist/templates/patterns/api/system-admin.d.ts +5 -0
- package/dist/templates/patterns/api/system-admin.js +98 -0
- package/dist/templates/patterns/api/webhook-receiver-style.d.ts +5 -0
- package/dist/templates/patterns/api/webhook-receiver-style.js +125 -0
- package/dist/templates/patterns/component/index.d.ts +25 -0
- package/dist/templates/patterns/component/index.js +814 -0
- package/dist/templates/patterns/flow/autonomous-remediation.d.ts +5 -0
- package/dist/templates/patterns/flow/autonomous-remediation.js +98 -0
- package/dist/templates/patterns/flow/fan-out-reaction.d.ts +5 -0
- package/dist/templates/patterns/flow/fan-out-reaction.js +53 -0
- package/dist/templates/patterns/flow/human-in-loop.d.ts +5 -0
- package/dist/templates/patterns/flow/human-in-loop.js +90 -0
- package/dist/templates/patterns/flow/multi-step-orchestration.d.ts +5 -0
- package/dist/templates/patterns/flow/multi-step-orchestration.js +67 -0
- package/dist/templates/patterns/hook/index.d.ts +7 -0
- package/dist/templates/patterns/hook/index.js +378 -0
- package/dist/templates/patterns/migration/column-add.d.ts +5 -0
- package/dist/templates/patterns/migration/column-add.js +52 -0
- package/dist/templates/patterns/migration/event-store.d.ts +6 -0
- package/dist/templates/patterns/migration/event-store.js +97 -0
- package/dist/templates/patterns/migration/index.d.ts +5 -0
- package/dist/templates/patterns/migration/index.js +52 -0
- package/dist/templates/patterns/migration/rls-policy.d.ts +5 -0
- package/dist/templates/patterns/migration/rls-policy.js +78 -0
- package/dist/templates/patterns/migration/tenant-scoped-table.d.ts +6 -0
- package/dist/templates/patterns/migration/tenant-scoped-table.js +81 -0
- package/dist/templates/patterns/page/dashboard.d.ts +4 -0
- package/dist/templates/patterns/page/dashboard.js +164 -0
- package/dist/templates/patterns/page/detail.d.ts +4 -0
- package/dist/templates/patterns/page/detail.js +162 -0
- package/dist/templates/patterns/page/form.d.ts +4 -0
- package/dist/templates/patterns/page/form.js +192 -0
- package/dist/templates/patterns/page/index.d.ts +8 -0
- package/dist/templates/patterns/page/index.js +14 -0
- package/dist/templates/patterns/page/list.d.ts +4 -0
- package/dist/templates/patterns/page/list.js +138 -0
- package/dist/templates/patterns/page/settings.d.ts +4 -0
- package/dist/templates/patterns/page/settings.js +318 -0
- package/dist/templates/patterns/page/wizard.d.ts +4 -0
- package/dist/templates/patterns/page/wizard.js +293 -0
- package/dist/templates/patterns/subscriber/audit-relay.d.ts +5 -0
- package/dist/templates/patterns/subscriber/audit-relay.js +51 -0
- package/dist/templates/patterns/subscriber/cascade-deletion.d.ts +5 -0
- package/dist/templates/patterns/subscriber/cascade-deletion.js +60 -0
- package/dist/templates/patterns/subscriber/single-step-projection.d.ts +5 -0
- package/dist/templates/patterns/subscriber/single-step-projection.js +36 -0
- package/dist/templates/readme.d.ts +4 -0
- package/dist/templates/readme.js +7 -0
- package/dist/templates/subscriber-skeleton.d.ts +11 -0
- package/dist/templates/subscriber-skeleton.js +23 -0
- package/dist/utils/checksum.d.ts +18 -0
- package/dist/utils/checksum.js +39 -0
- package/dist/utils/file-helpers.d.ts +35 -0
- package/dist/utils/file-helpers.js +59 -0
- package/dist/utils/header-inject.d.ts +15 -0
- package/dist/utils/header-inject.js +93 -0
- package/dist/utils/install-file.d.ts +17 -0
- package/dist/utils/install-file.js +78 -0
- package/dist/utils/logger.d.ts +12 -0
- package/dist/utils/logger.js +24 -0
- package/dist/utils/manifest.d.ts +28 -0
- package/dist/utils/manifest.js +93 -0
- package/dist/utils/s3-fetch.d.ts +25 -0
- package/dist/utils/s3-fetch.js +52 -0
- package/dist/utils/scaffold-config.d.ts +95 -0
- package/dist/utils/scaffold-config.js +53 -0
- package/dist/utils/token-substitution.d.ts +35 -0
- package/dist/utils/token-substitution.js +52 -0
- package/dist/utils/zod-extractor.d.ts +10 -0
- package/dist/utils/zod-extractor.js +28 -0
- package/package.json +43 -0
- package/src/__tests__/build-registry.test.ts +115 -0
- package/src/__tests__/build-types.test.ts +100 -0
- package/src/__tests__/builder/walkDomainDir.test.ts +140 -0
- package/src/__tests__/commands/add-domain.test.ts +174 -0
- package/src/__tests__/commands/add-flow.test.ts +69 -0
- package/src/__tests__/commands/add-module.test.ts +207 -0
- package/src/__tests__/commands/build-flows.test.ts +154 -0
- package/src/__tests__/commands/check-hashes.test.ts +142 -0
- package/src/__tests__/commands/create-project.test.ts +712 -0
- package/src/__tests__/commands/upgrade.test.ts +762 -0
- package/src/__tests__/doctor.test.ts +291 -0
- package/src/__tests__/hydrate-local-ctx.test.ts +71 -0
- package/src/__tests__/load-domain-module-config.test.ts +10 -0
- package/src/__tests__/mount-routes.test.ts +100 -0
- package/src/__tests__/scaffold-src/part-a-layout.test.ts +46 -0
- package/src/__tests__/scripts/package-scaffold.test.ts +45 -0
- package/src/__tests__/utils/checksum.test.ts +90 -0
- package/src/__tests__/utils/header-inject.test.ts +89 -0
- package/src/__tests__/utils/install-file.test.ts +207 -0
- package/src/__tests__/utils/manifest.test.ts +229 -0
- package/src/__tests__/utils/token-substitution.test.ts +134 -0
- package/src/__tests__/validate.test.ts +18 -0
- package/src/builder/build-registry.ts +237 -0
- package/src/builder/build-types.ts +36 -0
- package/src/builder/load-domain-module-config.ts +43 -0
- package/src/builder/load-module.ts +133 -0
- package/src/builder/zod-to-json.ts +16 -0
- package/src/cli.ts +387 -0
- package/src/commands/add-api.ts +145 -0
- package/src/commands/add-component.ts +116 -0
- package/src/commands/add-domain.ts +100 -0
- package/src/commands/add-flow.ts +136 -0
- package/src/commands/add-hook.ts +100 -0
- package/src/commands/add-migration.ts +129 -0
- package/src/commands/add-module.ts +347 -0
- package/src/commands/add-page.ts +242 -0
- package/src/commands/add-seed-page.ts +338 -0
- package/src/commands/add-subscriber.ts +123 -0
- package/src/commands/add-test.ts +328 -0
- package/src/commands/audit.ts +217 -0
- package/src/commands/build-catalog.ts +181 -0
- package/src/commands/build-flows.ts +198 -0
- package/src/commands/build.ts +59 -0
- package/src/commands/check-hashes.ts +150 -0
- package/src/commands/create-project.ts +367 -0
- package/src/commands/dev.ts +47 -0
- package/src/commands/doctor.ts +1362 -0
- package/src/commands/explain.ts +209 -0
- package/src/commands/power-tune.ts +112 -0
- package/src/commands/reseed-page.ts +410 -0
- package/src/commands/show-dns.ts +139 -0
- package/src/commands/show.ts +179 -0
- package/src/commands/test.ts +91 -0
- package/src/commands/upgrade-backend.ts +72 -0
- package/src/commands/upgrade-event.ts +175 -0
- package/src/commands/upgrade-frontend.ts +135 -0
- package/src/commands/upgrade.ts +668 -0
- package/src/commands/validate.ts +208 -0
- package/src/runtime-stubs/hydrate-local-ctx.ts +102 -0
- package/src/runtime-stubs/load-secrets.ts +40 -0
- package/src/server/api-server.ts +34 -0
- package/src/server/mount-routes.ts +68 -0
- package/src/templates/api-skeleton.ts +72 -0
- package/src/templates/claude-md.ts +7 -0
- package/src/templates/dashboard-pages/account/api-keys.tsx +107 -0
- package/src/templates/dashboard-pages/account/audit-log.tsx +60 -0
- package/src/templates/dashboard-pages/account/index.ts +5 -0
- package/src/templates/dashboard-pages/account/members.tsx +107 -0
- package/src/templates/dashboard-pages/account/profile.tsx +53 -0
- package/src/templates/dashboard-pages/account/workspace-settings.tsx +64 -0
- package/src/templates/dashboard-pages/auth/accept-invitation.tsx +62 -0
- package/src/templates/dashboard-pages/auth/choose-org.tsx +66 -0
- package/src/templates/dashboard-pages/auth/forgot-password.tsx +69 -0
- package/src/templates/dashboard-pages/auth/index.ts +10 -0
- package/src/templates/dashboard-pages/auth/login.tsx +75 -0
- package/src/templates/dashboard-pages/auth/mfa-setup.tsx +56 -0
- package/src/templates/dashboard-pages/auth/mfa-verify.tsx +49 -0
- package/src/templates/dashboard-pages/auth/reset-password.tsx +64 -0
- package/src/templates/dashboard-pages/auth/sign-out.tsx +20 -0
- package/src/templates/dashboard-pages/auth/signup.tsx +71 -0
- package/src/templates/dashboard-pages/auth/verify-email.tsx +53 -0
- package/src/templates/dashboard-pages/index.ts +22 -0
- package/src/templates/dashboard-pages/shell/dashboard-home.tsx +41 -0
- package/src/templates/dashboard-pages/shell/forbidden.tsx +46 -0
- package/src/templates/dashboard-pages/shell/index.ts +5 -0
- package/src/templates/dashboard-pages/shell/maintenance.tsx +27 -0
- package/src/templates/dashboard-pages/shell/not-found.tsx +34 -0
- package/src/templates/dashboard-pages/shell/server-error.tsx +44 -0
- package/src/templates/domain-config.ts +20 -0
- package/src/templates/events-skeleton.ts +24 -0
- package/src/templates/patterns/api/create-with-event.ts +72 -0
- package/src/templates/patterns/api/idempotent-mutation.ts +102 -0
- package/src/templates/patterns/api/paginated-list.ts +74 -0
- package/src/templates/patterns/api/simple-crud.ts +100 -0
- package/src/templates/patterns/api/system-admin.ts +101 -0
- package/src/templates/patterns/api/webhook-receiver-style.ts +128 -0
- package/src/templates/patterns/component/index.ts +833 -0
- package/src/templates/patterns/flow/autonomous-remediation.ts +101 -0
- package/src/templates/patterns/flow/fan-out-reaction.ts +56 -0
- package/src/templates/patterns/flow/human-in-loop.ts +93 -0
- package/src/templates/patterns/flow/multi-step-orchestration.ts +70 -0
- package/src/templates/patterns/hook/index.ts +382 -0
- package/src/templates/patterns/migration/column-add.ts +54 -0
- package/src/templates/patterns/migration/event-store.ts +99 -0
- package/src/templates/patterns/migration/index.ts +54 -0
- package/src/templates/patterns/migration/rls-policy.ts +80 -0
- package/src/templates/patterns/migration/tenant-scoped-table.ts +83 -0
- package/src/templates/patterns/page/dashboard.ts +164 -0
- package/src/templates/patterns/page/detail.ts +162 -0
- package/src/templates/patterns/page/form.ts +192 -0
- package/src/templates/patterns/page/index.ts +17 -0
- package/src/templates/patterns/page/list.ts +138 -0
- package/src/templates/patterns/page/settings.ts +318 -0
- package/src/templates/patterns/page/wizard.ts +293 -0
- package/src/templates/patterns/subscriber/audit-relay.ts +54 -0
- package/src/templates/patterns/subscriber/cascade-deletion.ts +63 -0
- package/src/templates/patterns/subscriber/single-step-projection.ts +39 -0
- package/src/templates/readme.ts +7 -0
- package/src/templates/subscriber-skeleton.ts +28 -0
- package/src/utils/checksum.ts +43 -0
- package/src/utils/file-helpers.ts +91 -0
- package/src/utils/header-inject.ts +126 -0
- package/src/utils/install-file.ts +99 -0
- package/src/utils/logger.ts +26 -0
- package/src/utils/manifest.ts +137 -0
- package/src/utils/s3-fetch.ts +91 -0
- package/src/utils/scaffold-config.ts +172 -0
- package/src/utils/token-substitution.ts +80 -0
- package/src/utils/zod-extractor.ts +31 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autonomous-remediation flow pattern template.
|
|
3
|
+
* Produces: flow that detects anomalies and self-heals without human intervention.
|
|
4
|
+
*/
|
|
5
|
+
function camelCase(s) {
|
|
6
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
7
|
+
}
|
|
8
|
+
export function autonomousRemediationTemplate(domain, id) {
|
|
9
|
+
const varName = camelCase(id);
|
|
10
|
+
return `import { defineFlow } from '@mettlecast/domain-runtime';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ${id} — Autonomous remediation flow.
|
|
14
|
+
*
|
|
15
|
+
* Detects anomaly events, runs diagnostic checks, applies
|
|
16
|
+
* corrective actions, and verifies resolution — all automated.
|
|
17
|
+
*/
|
|
18
|
+
export const ${varName} = defineFlow({
|
|
19
|
+
id: '${id}',
|
|
20
|
+
owningDomain: '${domain}',
|
|
21
|
+
type: 'standard',
|
|
22
|
+
name: '${id}',
|
|
23
|
+
steps: [
|
|
24
|
+
{
|
|
25
|
+
type: 'domain-action',
|
|
26
|
+
name: 'DetectAnomaly',
|
|
27
|
+
domainId: '${domain}',
|
|
28
|
+
actionId: 'detect-anomaly',
|
|
29
|
+
next: 'RunDiagnostics',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'domain-action',
|
|
33
|
+
name: 'RunDiagnostics',
|
|
34
|
+
domainId: '${domain}',
|
|
35
|
+
actionId: 'run-diagnostics',
|
|
36
|
+
next: 'DecideAction',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'choice',
|
|
40
|
+
name: 'DecideAction',
|
|
41
|
+
choices: [
|
|
42
|
+
{ when: '$.diagnostics.severity == "critical"', next: 'ApplyCriticalFix' },
|
|
43
|
+
{ when: '$.diagnostics.severity == "warning"', next: 'ApplySoftFix' },
|
|
44
|
+
{ default: true, next: 'LogAndSkip' },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'domain-action',
|
|
49
|
+
name: 'ApplyCriticalFix',
|
|
50
|
+
domainId: '${domain}',
|
|
51
|
+
actionId: 'apply-critical-fix',
|
|
52
|
+
next: 'VerifyResolution',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'domain-action',
|
|
56
|
+
name: 'ApplySoftFix',
|
|
57
|
+
domainId: '${domain}',
|
|
58
|
+
actionId: 'apply-soft-fix',
|
|
59
|
+
next: 'VerifyResolution',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: 'domain-action',
|
|
63
|
+
name: 'LogAndSkip',
|
|
64
|
+
domainId: '${domain}',
|
|
65
|
+
actionId: 'log-and-skip',
|
|
66
|
+
next: 'Done',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'domain-action',
|
|
70
|
+
name: 'VerifyResolution',
|
|
71
|
+
domainId: '${domain}',
|
|
72
|
+
actionId: 'verify-resolution',
|
|
73
|
+
next: 'EscalateIfUnresolved',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
type: 'choice',
|
|
77
|
+
name: 'EscalateIfUnresolved',
|
|
78
|
+
choices: [
|
|
79
|
+
{ when: '$.resolution === "unresolved"', next: 'EscalateToHuman' },
|
|
80
|
+
{ default: true, next: 'Done' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: 'domain-action',
|
|
85
|
+
name: 'EscalateToHuman',
|
|
86
|
+
domainId: '${domain}',
|
|
87
|
+
actionId: 'escalate-to-human',
|
|
88
|
+
next: 'Done',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'flow-control',
|
|
92
|
+
control: 'succeed',
|
|
93
|
+
name: 'Done',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fan-out-reaction flow pattern template.
|
|
3
|
+
* Produces: flow that fans out an event to multiple domain actions in parallel.
|
|
4
|
+
*/
|
|
5
|
+
function camelCase(s) {
|
|
6
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
7
|
+
}
|
|
8
|
+
export function fanOutReactionTemplate(domain, id) {
|
|
9
|
+
const varName = camelCase(id);
|
|
10
|
+
return `import { defineFlow } from '@mettlecast/domain-runtime';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ${id} — Fan-out reaction flow.
|
|
14
|
+
*
|
|
15
|
+
* When an upstream event arrives, this flow fans out to multiple
|
|
16
|
+
* domain actions that run in parallel, then joins at a completion step.
|
|
17
|
+
*/
|
|
18
|
+
export const ${varName} = defineFlow({
|
|
19
|
+
id: '${id}',
|
|
20
|
+
owningDomain: '${domain}',
|
|
21
|
+
type: 'express',
|
|
22
|
+
name: '${id}',
|
|
23
|
+
steps: [
|
|
24
|
+
{
|
|
25
|
+
type: 'domain-action',
|
|
26
|
+
name: 'NotifyServiceA',
|
|
27
|
+
domainId: '${domain}',
|
|
28
|
+
actionId: 'notify-service-a',
|
|
29
|
+
next: 'NotifyServiceB',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'domain-action',
|
|
33
|
+
name: 'NotifyServiceB',
|
|
34
|
+
domainId: '${domain}',
|
|
35
|
+
actionId: 'notify-service-b',
|
|
36
|
+
next: 'AuditFanOut',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'domain-action',
|
|
40
|
+
name: 'AuditFanOut',
|
|
41
|
+
domainId: '${domain}',
|
|
42
|
+
actionId: 'audit-fan-out',
|
|
43
|
+
next: 'Done',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: 'flow-control',
|
|
47
|
+
control: 'succeed',
|
|
48
|
+
name: 'Done',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human-in-loop flow pattern template.
|
|
3
|
+
* Produces: flow that pauses for human approval before proceeding.
|
|
4
|
+
*/
|
|
5
|
+
function camelCase(s) {
|
|
6
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
7
|
+
}
|
|
8
|
+
export function humanInLoopTemplate(domain, id) {
|
|
9
|
+
const varName = camelCase(id);
|
|
10
|
+
return `import { defineFlow } from '@mettlecast/domain-runtime';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ${id} — Human-in-the-loop flow.
|
|
14
|
+
*
|
|
15
|
+
* Pauses execution at an approval gate, waits for an authorised
|
|
16
|
+
* human to approve or reject, then proceeds or aborts accordingly.
|
|
17
|
+
*/
|
|
18
|
+
export const ${varName} = defineFlow({
|
|
19
|
+
id: '${id}',
|
|
20
|
+
owningDomain: '${domain}',
|
|
21
|
+
type: 'standard',
|
|
22
|
+
name: '${id}',
|
|
23
|
+
steps: [
|
|
24
|
+
{
|
|
25
|
+
type: 'domain-action',
|
|
26
|
+
name: 'PrepareChangeRequest',
|
|
27
|
+
domainId: '${domain}',
|
|
28
|
+
actionId: 'prepare-change-request',
|
|
29
|
+
next: 'NotifyReviewers',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'domain-action',
|
|
33
|
+
name: 'NotifyReviewers',
|
|
34
|
+
domainId: '${domain}',
|
|
35
|
+
actionId: 'notify-reviewers',
|
|
36
|
+
next: 'WaitForApproval',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'domain-action',
|
|
40
|
+
name: 'WaitForApproval',
|
|
41
|
+
domainId: '${domain}',
|
|
42
|
+
actionId: 'wait-for-approval',
|
|
43
|
+
next: 'EvaluateApproval',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: 'choice',
|
|
47
|
+
name: 'EvaluateApproval',
|
|
48
|
+
choices: [
|
|
49
|
+
{ when: '$.approval.decision === "approved"', next: 'ApplyChange' },
|
|
50
|
+
{ when: '$.approval.decision === "rejected"', next: 'LogRejection' },
|
|
51
|
+
{ default: true, next: 'RetryApproval' },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'domain-action',
|
|
56
|
+
name: 'ApplyChange',
|
|
57
|
+
domainId: '${domain}',
|
|
58
|
+
actionId: 'apply-change',
|
|
59
|
+
next: 'NotifyCompletion',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: 'domain-action',
|
|
63
|
+
name: 'LogRejection',
|
|
64
|
+
domainId: '${domain}',
|
|
65
|
+
actionId: 'log-rejection',
|
|
66
|
+
next: 'Done',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'domain-action',
|
|
70
|
+
name: 'RetryApproval',
|
|
71
|
+
domainId: '${domain}',
|
|
72
|
+
actionId: 'retry-approval',
|
|
73
|
+
next: 'NotifyReviewers',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
type: 'domain-action',
|
|
77
|
+
name: 'NotifyCompletion',
|
|
78
|
+
domainId: '${domain}',
|
|
79
|
+
actionId: 'notify-completion',
|
|
80
|
+
next: 'Done',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'flow-control',
|
|
84
|
+
control: 'succeed',
|
|
85
|
+
name: 'Done',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-step-orchestration flow pattern template.
|
|
3
|
+
* Produces: flow that orchestrates a chain of dependent domain actions.
|
|
4
|
+
*/
|
|
5
|
+
function camelCase(s) {
|
|
6
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
7
|
+
}
|
|
8
|
+
export function multiStepOrchestrationTemplate(domain, id) {
|
|
9
|
+
const varName = camelCase(id);
|
|
10
|
+
return `import { defineFlow } from '@mettlecast/domain-runtime';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ${id} — Multi-step orchestration flow.
|
|
14
|
+
*
|
|
15
|
+
* Executes a sequential pipeline of domain actions where each step
|
|
16
|
+
* depends on the output of the previous step.
|
|
17
|
+
*/
|
|
18
|
+
export const ${varName} = defineFlow({
|
|
19
|
+
id: '${id}',
|
|
20
|
+
owningDomain: '${domain}',
|
|
21
|
+
type: 'standard',
|
|
22
|
+
name: '${id}',
|
|
23
|
+
steps: [
|
|
24
|
+
{
|
|
25
|
+
type: 'domain-action',
|
|
26
|
+
name: 'ValidateInput',
|
|
27
|
+
domainId: '${domain}',
|
|
28
|
+
actionId: 'validate-input',
|
|
29
|
+
next: 'ProvisionResource',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'domain-action',
|
|
33
|
+
name: 'ProvisionResource',
|
|
34
|
+
domainId: '${domain}',
|
|
35
|
+
actionId: 'provision-resource',
|
|
36
|
+
next: 'ConfigureResource',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'domain-action',
|
|
40
|
+
name: 'ConfigureResource',
|
|
41
|
+
domainId: '${domain}',
|
|
42
|
+
actionId: 'configure-resource',
|
|
43
|
+
next: 'ActivateResource',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: 'domain-action',
|
|
47
|
+
name: 'ActivateResource',
|
|
48
|
+
domainId: '${domain}',
|
|
49
|
+
actionId: 'activate-resource',
|
|
50
|
+
next: 'SendNotification',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: 'domain-action',
|
|
54
|
+
name: 'SendNotification',
|
|
55
|
+
domainId: '${domain}',
|
|
56
|
+
actionId: 'send-notification',
|
|
57
|
+
next: 'Done',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: 'flow-control',
|
|
61
|
+
control: 'succeed',
|
|
62
|
+
name: 'Done',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paginated list hook pattern — uses `useInfiniteQuery` from TanStack Query for paginated lists.
|
|
3
|
+
*/
|
|
4
|
+
export declare function paginatedListHookTemplate(name: string): string;
|
|
5
|
+
export declare function mutationHookTemplate(name: string): string;
|
|
6
|
+
export declare function featureFlagHookTemplate(name: string): string;
|
|
7
|
+
export declare function subscriptionHookTemplate(name: string): string;
|