@mettlecast/domain-cli 0.2.60 → 0.2.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder/build-registry.d.ts +1 -1
- package/dist/builder/build-registry.js +1 -36
- package/dist/builder/build-types.d.ts +1 -1
- package/dist/builder/load-module.d.ts +1 -1
- package/dist/cli.js +21 -3
- package/dist/commands/add-api.js +2 -2
- package/dist/commands/add-domain.js +4 -4
- package/dist/commands/add-fixture-factory.js +5 -6
- package/dist/commands/build-catalog.d.ts +6 -22
- package/dist/commands/build-catalog.js +7 -18
- package/dist/commands/build.js +2 -1
- package/dist/commands/check-hashes.d.ts +2 -0
- package/dist/commands/check-hashes.js +8 -0
- package/dist/commands/dev.js +1 -1
- package/dist/commands/doctor.js +70 -41
- package/dist/commands/explain.js +13 -13
- package/dist/commands/generate-openapi.d.ts +10 -1
- package/dist/commands/generate-openapi.js +19 -33
- package/dist/commands/regenerate-modules-hashes.d.ts +25 -0
- package/dist/commands/regenerate-modules-hashes.js +58 -0
- package/dist/commands/show.d.ts +2 -3
- package/dist/commands/show.js +0 -2
- package/dist/commands/test.js +0 -1
- package/dist/commands/update-all.d.ts +21 -0
- package/dist/commands/update-all.js +62 -0
- package/dist/commands/upgrade-backend.js +3 -3
- package/dist/commands/validate.js +12 -90
- package/dist/server/api-server.d.ts +1 -1
- package/dist/server/mount-routes.d.ts +11 -2
- package/dist/server/mount-routes.js +20 -8
- package/dist/templates/api-skeleton.d.ts +5 -0
- package/dist/templates/api-skeleton.js +28 -27
- package/dist/templates/claude-md.js +1 -1
- package/dist/templates/patterns/api/create-with-event.d.ts +4 -0
- package/dist/templates/patterns/api/create-with-event.js +38 -32
- package/dist/templates/patterns/api/idempotent-mutation.d.ts +4 -0
- package/dist/templates/patterns/api/idempotent-mutation.js +47 -41
- package/dist/templates/patterns/api/paginated-list.d.ts +4 -0
- package/dist/templates/patterns/api/paginated-list.js +30 -24
- package/dist/templates/patterns/api/simple-crud.d.ts +4 -0
- package/dist/templates/patterns/api/simple-crud.js +46 -35
- package/dist/templates/patterns/api/streaming-list.d.ts +4 -0
- package/dist/templates/patterns/api/streaming-list.js +46 -41
- package/dist/templates/patterns/api/system-admin.d.ts +4 -0
- package/dist/templates/patterns/api/system-admin.js +59 -52
- package/dist/templates/patterns/api/webhook-receiver-style.d.ts +4 -0
- package/dist/templates/patterns/api/webhook-receiver-style.js +43 -35
- package/dist/types.d.ts +100 -0
- package/dist/types.js +1 -0
- package/dist/utils/file-helpers.d.ts +0 -2
- package/dist/utils/file-helpers.js +2 -3
- package/dist/utils/manifest.d.ts +1 -0
- package/dist/utils/manifest.js +16 -1
- package/dist/utils/scaffold-config.d.ts +6 -0
- package/dist/utils/scaffold-config.js +2 -0
- package/package.json +1 -1
- package/src/__tests__/build-registry.test.ts +43 -20
- package/src/__tests__/build-types.test.ts +4 -7
- package/src/__tests__/builder/walkDomainDir.test.ts +19 -21
- package/src/__tests__/commands/add-api.test.ts +12 -10
- package/src/__tests__/commands/add-domain.test.ts +8 -5
- package/src/__tests__/commands/build-flows.test.ts +55 -0
- package/src/__tests__/commands/check-hashes.test.ts +31 -0
- package/src/__tests__/commands/create-project.test.ts +5 -5
- package/src/__tests__/commands/dev.test.ts +0 -1
- package/src/__tests__/commands/regenerate-modules-hashes.test.ts +170 -0
- package/src/__tests__/commands/update-all.test.ts +322 -0
- package/src/__tests__/doctor.test.ts +73 -0
- package/src/__tests__/mount-routes.test.ts +64 -23
- package/src/__tests__/package-freshness.test.ts +1 -21
- package/src/__tests__/smoke/scaffold.test.ts +13 -15
- package/src/__tests__/utils/manifest.test.ts +128 -0
- package/src/__tests__/validate.test.ts +21 -103
- package/src/builder/build-registry.ts +7 -44
- package/src/builder/build-types.ts +1 -1
- package/src/cli.ts +23 -3
- package/src/commands/add-api.ts +2 -2
- package/src/commands/add-domain.ts +4 -4
- package/src/commands/add-fixture-factory.ts +5 -6
- package/src/commands/build-catalog.ts +13 -35
- package/src/commands/build.ts +3 -2
- package/src/commands/check-hashes.ts +12 -0
- package/src/commands/dev.ts +1 -1
- package/src/commands/doctor.ts +72 -41
- package/src/commands/explain.ts +13 -13
- package/src/commands/generate-openapi.ts +30 -52
- package/src/commands/regenerate-modules-hashes.ts +89 -0
- package/src/commands/show.ts +2 -5
- package/src/commands/test.ts +0 -1
- package/src/commands/update-all.ts +79 -0
- package/src/commands/upgrade-backend.ts +3 -3
- package/src/commands/validate.ts +11 -96
- package/src/server/api-server.ts +1 -1
- package/src/server/mount-routes.ts +21 -10
- package/src/templates/api-skeleton.ts +29 -28
- package/src/templates/claude-md.ts +1 -1
- package/src/templates/patterns/api/create-with-event.ts +39 -33
- package/src/templates/patterns/api/idempotent-mutation.ts +48 -42
- package/src/templates/patterns/api/paginated-list.ts +31 -25
- package/src/templates/patterns/api/simple-crud.ts +47 -36
- package/src/templates/patterns/api/streaming-list.ts +47 -42
- package/src/templates/patterns/api/system-admin.ts +60 -53
- package/src/templates/patterns/api/webhook-receiver-style.ts +48 -40
- package/src/types.ts +128 -0
- package/src/utils/file-helpers.ts +2 -5
- package/src/utils/manifest.ts +16 -1
- package/src/utils/scaffold-config.ts +9 -0
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* System-admin API pattern template.
|
|
3
3
|
* Produces: GET/POST with tenancy: 'system', no tenant context.
|
|
4
|
+
*
|
|
5
|
+
* Action-first: HTTP endpoints are declared with `defineAction` +
|
|
6
|
+
* `exposure: { type: 'api', ... }`. The legacy `defineApi` factory was
|
|
7
|
+
* removed in #4689.
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
10
|
function camelCase(s: string): string {
|
|
@@ -11,8 +15,7 @@ export function systemAdminTemplate(domain: string, id: string, tenancy: string)
|
|
|
11
15
|
const varName = camelCase(id);
|
|
12
16
|
|
|
13
17
|
return `import { z } from 'zod';
|
|
14
|
-
import {
|
|
15
|
-
import { createKyClient, initOtel } from '@mettlecast/domain-runtime';
|
|
18
|
+
import { defineAction, initOtel } from '@mettlecast/domain-runtime';
|
|
16
19
|
import type { Result, AppError } from '@mettlecast/domain-runtime';
|
|
17
20
|
import { ok, err, notFound } from '@mettlecast/domain-runtime';
|
|
18
21
|
|
|
@@ -30,7 +33,7 @@ const ${varName}Output = z.object({
|
|
|
30
33
|
data: z.record(z.unknown()).optional(),
|
|
31
34
|
}).default({ ok: true });
|
|
32
35
|
|
|
33
|
-
// ── System health
|
|
36
|
+
// ── System health output ─────────────────────────────────────
|
|
34
37
|
|
|
35
38
|
const SystemHealthOutput = z.object({
|
|
36
39
|
status: z.enum(['healthy', 'degraded', 'down']),
|
|
@@ -41,64 +44,68 @@ const SystemHealthOutput = z.object({
|
|
|
41
44
|
})),
|
|
42
45
|
}).default({ status: 'healthy', uptime: 0, domains: [] });
|
|
43
46
|
|
|
44
|
-
// ──
|
|
47
|
+
// ── Action definitions (API exposure) ────────────────────────
|
|
45
48
|
|
|
46
|
-
export const ${varName} =
|
|
49
|
+
export const ${varName} = defineAction({
|
|
47
50
|
id: '${id}',
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
backendAccess: 'platform',
|
|
52
|
+
exposure: {
|
|
53
|
+
type: 'api',
|
|
54
|
+
path: '/system/${domain}/${id}',
|
|
55
|
+
method: 'POST',
|
|
56
|
+
auth: 'service',
|
|
57
|
+
tenancy: '${tenancy}',
|
|
58
|
+
},
|
|
50
59
|
outboundAccess: 'internal',
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
handler: async (input, ctx) => {
|
|
57
|
-
await ctx.audit.log('${id}.system', 'system', { command: input.command });
|
|
60
|
+
idempotent: false,
|
|
61
|
+
input: ${varName}Input,
|
|
62
|
+
output: ${varName}Output,
|
|
63
|
+
handler: async (input, ctx) => {
|
|
64
|
+
await ctx.audit.log('${id}.system', 'system', { command: input.command });
|
|
58
65
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
},
|
|
66
|
+
switch (input.command) {
|
|
67
|
+
case 'status':
|
|
68
|
+
return {
|
|
69
|
+
ok: true,
|
|
70
|
+
data: { status: 'healthy', domains: [] },
|
|
71
|
+
};
|
|
72
|
+
case 'metrics':
|
|
73
|
+
return {
|
|
74
|
+
ok: true,
|
|
75
|
+
data: {
|
|
76
|
+
requestCount: 0,
|
|
77
|
+
errorCount: 0,
|
|
78
|
+
p99LatencyMs: 0,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
case 'health':
|
|
82
|
+
return { ok: true, data: { status: 'healthy' } };
|
|
83
|
+
default:
|
|
84
|
+
return { ok: false };
|
|
85
|
+
}
|
|
81
86
|
},
|
|
82
87
|
});
|
|
83
88
|
|
|
84
|
-
export const ${varName}Health =
|
|
89
|
+
export const ${varName}Health = defineAction({
|
|
85
90
|
id: '${id}-health',
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
backendAccess: 'platform',
|
|
92
|
+
exposure: {
|
|
93
|
+
type: 'api',
|
|
94
|
+
path: '/system/${domain}/${id}-health',
|
|
95
|
+
method: 'GET',
|
|
96
|
+
auth: 'service',
|
|
97
|
+
tenancy: '${tenancy}',
|
|
98
|
+
},
|
|
88
99
|
outboundAccess: 'internal',
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
domains: [],
|
|
99
|
-
};
|
|
100
|
-
},
|
|
101
|
-
},
|
|
100
|
+
idempotent: true,
|
|
101
|
+
input: z.object({}).default({}),
|
|
102
|
+
output: SystemHealthOutput,
|
|
103
|
+
handler: async (_input, _ctx) => {
|
|
104
|
+
return {
|
|
105
|
+
status: 'healthy',
|
|
106
|
+
uptime: process.uptime(),
|
|
107
|
+
domains: [],
|
|
108
|
+
};
|
|
102
109
|
},
|
|
103
110
|
});
|
|
104
111
|
`;
|
|
@@ -108,4 +115,4 @@ export const ${varName}Health = defineApi({
|
|
|
108
115
|
* Example body string used as the event body in the add-api fixture for the
|
|
109
116
|
* system-admin pattern. Mirrors the default shape of the input schema.
|
|
110
117
|
*/
|
|
111
|
-
export const systemAdminExampleBody = JSON.stringify({ command: 'status' });
|
|
118
|
+
export const systemAdminExampleBody = JSON.stringify({ command: 'status' });
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Webhook-receiver-style API pattern template.
|
|
3
3
|
* Produces: POST with signature verification, provider enum.
|
|
4
|
+
*
|
|
5
|
+
* Action-first: HTTP endpoints are declared with `defineAction` +
|
|
6
|
+
* `exposure: { type: 'api', ... }`. The legacy `defineApi` factory was
|
|
7
|
+
* removed in #4689.
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
10
|
function camelCase(s: string): string {
|
|
@@ -9,10 +13,12 @@ function camelCase(s: string): string {
|
|
|
9
13
|
|
|
10
14
|
export function webhookReceiverStyleTemplate(domain: string, id: string, tenancy: string): string {
|
|
11
15
|
const varName = camelCase(id);
|
|
16
|
+
// Webhook receivers are typically public; pair `auth: 'none'` with a
|
|
17
|
+
// securityException.reason so the validator does not flag the route.
|
|
18
|
+
const securityException = `\n securityException: { reason: 'webhook receiver; signature verification handled by authorizer' },`;
|
|
12
19
|
|
|
13
20
|
return `import { z } from 'zod';
|
|
14
|
-
import {
|
|
15
|
-
import { createKyClient, initOtel } from '@mettlecast/domain-runtime';
|
|
21
|
+
import { defineAction, initOtel } from '@mettlecast/domain-runtime';
|
|
16
22
|
import type { Result, AppError } from '@mettlecast/domain-runtime';
|
|
17
23
|
import { ok, err, notFound } from '@mettlecast/domain-runtime';
|
|
18
24
|
|
|
@@ -50,46 +56,48 @@ const ${varName}Output = z.object({
|
|
|
50
56
|
provider: 'stripe',
|
|
51
57
|
});
|
|
52
58
|
|
|
53
|
-
// ──
|
|
59
|
+
// ── Action definition (API exposure) ─────────────────────────
|
|
54
60
|
|
|
55
|
-
export const ${varName} =
|
|
61
|
+
export const ${varName} = defineAction({
|
|
56
62
|
id: '${id}',
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
backendAccess: 'domain',
|
|
64
|
+
exposure: {
|
|
65
|
+
type: 'api',
|
|
66
|
+
path: '/webhooks/${domain}/${id}',
|
|
67
|
+
method: 'POST',
|
|
68
|
+
auth: 'none',${securityException}
|
|
69
|
+
tenancy: '${tenancy}',
|
|
70
|
+
},
|
|
59
71
|
outboundAccess: 'internal',
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
provider: input.provider,
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
},
|
|
72
|
+
idempotent: false,
|
|
73
|
+
input: ${varName}Input,
|
|
74
|
+
output: ${varName}Output,
|
|
75
|
+
handler: async (input, ctx) => {
|
|
76
|
+
// Signature verification belongs in a Lambda authorizer (x-webhook-signature header
|
|
77
|
+
// is not accessible here). Wire an HttpLambdaAuthorizer in DomainStack for production.
|
|
78
|
+
|
|
79
|
+
const eventId = crypto.randomUUID();
|
|
80
|
+
|
|
81
|
+
// ── Publish event for downstream processing ───────────
|
|
82
|
+
await ctx.publish('${domain}.webhook.received', {
|
|
83
|
+
eventId,
|
|
84
|
+
provider: input.provider,
|
|
85
|
+
eventType: input.eventType,
|
|
86
|
+
payload: input.payload,
|
|
87
|
+
tenantId: ctx.tenant.id,
|
|
88
|
+
}, 1);
|
|
89
|
+
|
|
90
|
+
await ctx.audit.log('${id}.webhook.received', ctx.tenant.id, {
|
|
91
|
+
provider: input.provider,
|
|
92
|
+
eventType: input.eventType,
|
|
93
|
+
eventId,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
received: true,
|
|
98
|
+
eventId,
|
|
99
|
+
provider: input.provider,
|
|
100
|
+
};
|
|
93
101
|
},
|
|
94
102
|
});
|
|
95
103
|
`;
|
|
@@ -103,4 +111,4 @@ export const webhookReceiverStyleExampleBody = JSON.stringify({
|
|
|
103
111
|
provider: 'stripe',
|
|
104
112
|
eventType: 'example.event',
|
|
105
113
|
payload: {},
|
|
106
|
-
});
|
|
114
|
+
});
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/domain-cli/src/types.ts
|
|
3
|
+
*
|
|
4
|
+
* Local re-declaration of registry types used by the CLI's
|
|
5
|
+
* build/dev/mount-routes pipeline.
|
|
6
|
+
*
|
|
7
|
+
* Issue #4689 removed the legacy `defineApi` primitive and the
|
|
8
|
+
* `registry.apis` field in favour of the action-first model (#4619).
|
|
9
|
+
* The CLI's own source defines the action-first shape here so the
|
|
10
|
+
* pipeline can compile even when the published
|
|
11
|
+
* `@mettlecast/domain-cdk-packer` on npm still carries the legacy
|
|
12
|
+
* shape (i.e. `DomainRegistry` still requires `apis`, and
|
|
13
|
+
* `ActionRegistryEntry` lacks the `exposure` field).
|
|
14
|
+
*
|
|
15
|
+
* Once the npm-published packer catches up, the two local types below
|
|
16
|
+
* can collapse back to a single re-export from
|
|
17
|
+
* `@mettlecast/domain-cdk-packer`.
|
|
18
|
+
*/
|
|
19
|
+
import type {
|
|
20
|
+
DomainRegistry as PackerDomainRegistry,
|
|
21
|
+
ActionRegistryEntry as PackerActionRegistryEntry,
|
|
22
|
+
SchemaSnapshot,
|
|
23
|
+
WebhookRegistryEntry,
|
|
24
|
+
SubscriberRegistryEntry,
|
|
25
|
+
ScheduleRegistryEntry,
|
|
26
|
+
JobRegistryEntry,
|
|
27
|
+
IntegrationRegistryEntry,
|
|
28
|
+
EventRegistryEntry,
|
|
29
|
+
DomainRegistryEntry,
|
|
30
|
+
SerialDeploymentConfig,
|
|
31
|
+
BaseRegistryEntry,
|
|
32
|
+
} from '@mettlecast/domain-cdk-packer';
|
|
33
|
+
|
|
34
|
+
// Re-export the unchanged registry entry types so callers can import
|
|
35
|
+
// everything from a single local module.
|
|
36
|
+
export type {
|
|
37
|
+
SchemaSnapshot,
|
|
38
|
+
WebhookRegistryEntry,
|
|
39
|
+
SubscriberRegistryEntry,
|
|
40
|
+
ScheduleRegistryEntry,
|
|
41
|
+
JobRegistryEntry,
|
|
42
|
+
IntegrationRegistryEntry,
|
|
43
|
+
EventRegistryEntry,
|
|
44
|
+
DomainRegistryEntry,
|
|
45
|
+
SerialDeploymentConfig,
|
|
46
|
+
BaseRegistryEntry,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Backend invocation permission for an action. Re-declared locally
|
|
51
|
+
* because the legacy published packer does not export this union yet
|
|
52
|
+
* (it was introduced as part of the action-first migration #4619).
|
|
53
|
+
*/
|
|
54
|
+
export type ActionBackendAccess = 'private' | 'domain' | 'platform';
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* API-exposure metadata for an action whose `exposure.type === 'api'`.
|
|
58
|
+
* Carries the route, method, auth, tenancy, and any documented security
|
|
59
|
+
* exception that downstream CDK/contract generation needs to wire the
|
|
60
|
+
* route safely. Mirrors the canonical `ActionApiExposure` shape from
|
|
61
|
+
* `@mettlecast/domain-cdk-packer`.
|
|
62
|
+
*/
|
|
63
|
+
export interface ActionApiExposure {
|
|
64
|
+
/** Discriminant. */
|
|
65
|
+
type: 'api';
|
|
66
|
+
/** HTTP route path, e.g. '/v1/tenants/{tenantId}/billing/invoices'. */
|
|
67
|
+
path: string;
|
|
68
|
+
/** HTTP method. One of: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS. */
|
|
69
|
+
method: string;
|
|
70
|
+
/** Authentication requirement for the route. */
|
|
71
|
+
auth: 'required' | 'none' | 'service';
|
|
72
|
+
/** Tenancy requirement for the route. */
|
|
73
|
+
tenancy: 'required' | 'none' | 'system';
|
|
74
|
+
/** Required role(s) for `auth: 'required'` routes (system tenancy requires this). */
|
|
75
|
+
roles?: string[];
|
|
76
|
+
/** Documented exception when auth or tenancy is intentionally not required. */
|
|
77
|
+
securityException?: { reason: string };
|
|
78
|
+
/**
|
|
79
|
+
* True if the source code explicitly declared `auth`. False if the
|
|
80
|
+
* builder fell back to the safe default (`'required'`). Validation-only.
|
|
81
|
+
*/
|
|
82
|
+
authDeclared?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* True if the source code explicitly declared `tenancy`. False if the
|
|
85
|
+
* builder fell back to the safe default (`'required'`). Validation-only.
|
|
86
|
+
*/
|
|
87
|
+
tenancyDeclared?: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Discriminated union for an action's external exposure shape.
|
|
92
|
+
* `internal` actions are reachable only through `ctx.actions`. `api`
|
|
93
|
+
* actions are exposed via API Gateway and carry the route + auth
|
|
94
|
+
* metadata needed for safe route generation.
|
|
95
|
+
*/
|
|
96
|
+
export type ActionExposure = ActionApiExposure | { type: 'internal' };
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Local `DomainRegistry` for the CLI. Drops the legacy `apis` slot
|
|
100
|
+
* that was removed in issue #4689's action-first migration, and pins
|
|
101
|
+
* the `actions` array to the local `ActionRegistryEntry` shape (which
|
|
102
|
+
* carries the action-first `exposure` field). The CLI builds an object
|
|
103
|
+
* literal that satisfies this type and then serialises it to
|
|
104
|
+
* `.mc/<domain>-registry.json`; downstream consumers (CDK packer,
|
|
105
|
+
* OpenAPI generator, dev server) only ever see the JSON.
|
|
106
|
+
*/
|
|
107
|
+
export type DomainRegistry = Omit<PackerDomainRegistry, 'apis' | 'actions'> & {
|
|
108
|
+
/** All callable actions (local shape with action-first `exposure`). */
|
|
109
|
+
actions: ActionRegistryEntry[];
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Local `ActionRegistryEntry` for the CLI. Augments the packer's shape
|
|
114
|
+
* with the `exposure` field and its `exposureDeclared` flag from the
|
|
115
|
+
* action-first migration (#4619) so the build/dev/mount-routes
|
|
116
|
+
* pipeline can read these properties regardless of which packer
|
|
117
|
+
* version is linked. The `backendAccess` field is also surfaced here
|
|
118
|
+
* (the CLI is the canonical writer of this field) even when the
|
|
119
|
+
* linked packer only exposes the legacy `visibility` alias.
|
|
120
|
+
*/
|
|
121
|
+
export type ActionRegistryEntry = PackerActionRegistryEntry & {
|
|
122
|
+
/** External exposure shape for the action (see ActionExposure). */
|
|
123
|
+
exposure: ActionExposure;
|
|
124
|
+
/** True if the source code explicitly declared `exposure`. */
|
|
125
|
+
exposureDeclared?: boolean;
|
|
126
|
+
/** Backend invocation permission for the action. */
|
|
127
|
+
backendAccess?: ActionBackendAccess;
|
|
128
|
+
};
|
|
@@ -10,8 +10,6 @@ import { join } from 'node:path';
|
|
|
10
10
|
export interface DomainFilePaths {
|
|
11
11
|
/** Path to domain.config.ts if present. */
|
|
12
12
|
domain: string | undefined;
|
|
13
|
-
/** API handler file paths under api/. */
|
|
14
|
-
apis: string[];
|
|
15
13
|
/** Webhook handler file paths under webhooks/. */
|
|
16
14
|
webhooks: string[];
|
|
17
15
|
/** Subscriber handler file paths under subscribers/. */
|
|
@@ -74,10 +72,9 @@ export async function walkDomainDir(domainRoot: string): Promise<DomainFilePaths
|
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
const [domain,
|
|
75
|
+
const [domain, webhooks, subscribers, actions, schedules, jobs, integrations, publishes] =
|
|
78
76
|
await Promise.all([
|
|
79
77
|
singleTs(join(domainRoot, 'domain.config.ts')),
|
|
80
|
-
tsFiles(join(domainRoot, 'api')),
|
|
81
78
|
tsFiles(join(domainRoot, 'webhooks')),
|
|
82
79
|
tsFiles(join(domainRoot, 'subscribers')),
|
|
83
80
|
tsFiles(join(domainRoot, 'actions')),
|
|
@@ -87,5 +84,5 @@ export async function walkDomainDir(domainRoot: string): Promise<DomainFilePaths
|
|
|
87
84
|
singleTs(join(domainRoot, 'publishes', 'events.ts')),
|
|
88
85
|
]);
|
|
89
86
|
|
|
90
|
-
return { domain,
|
|
87
|
+
return { domain, webhooks, subscribers, actions, schedules, jobs, integrations, publishes };
|
|
91
88
|
}
|
package/src/utils/manifest.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFile, writeFile, mkdir } from 'fs/promises';
|
|
1
|
+
import { readFile, writeFile, mkdir, access } from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { cliLogger } from './logger.js';
|
|
4
4
|
|
|
@@ -179,3 +179,18 @@ export function isScaffoldManaged(manifest: TibManifest, filePath: string): bool
|
|
|
179
179
|
// Returns true only when the file is in the manifest with policy 'managed'
|
|
180
180
|
return entry != null && entry.policy === 'managed';
|
|
181
181
|
}
|
|
182
|
+
|
|
183
|
+
export async function pruneManifest(projectRoot: string, manifest: TibManifest): Promise<number> {
|
|
184
|
+
let pruned = 0;
|
|
185
|
+
const survivors: ManifestFileEntry[] = [];
|
|
186
|
+
for (const entry of manifest.files) {
|
|
187
|
+
try {
|
|
188
|
+
await access(path.join(projectRoot, entry.path));
|
|
189
|
+
survivors.push(entry);
|
|
190
|
+
} catch {
|
|
191
|
+
pruned++;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
manifest.files = survivors;
|
|
195
|
+
return pruned;
|
|
196
|
+
}
|
|
@@ -50,10 +50,15 @@ export interface CostOptions {
|
|
|
50
50
|
reservedConcurrencyPerDomain?: Record<string, number>;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/** NAT instance type options for cost control. */
|
|
54
|
+
export type NatInstanceType = 't4g.nano' | 't4g.micro' | 't4g.small';
|
|
55
|
+
|
|
53
56
|
/** Monitoring / observability feature opt-ins. */
|
|
54
57
|
export interface MonitoringOptions {
|
|
55
58
|
/** Replace basic MonitoringStack with full ObservabilityStack (Grafana + Cost Explorer + CloudWatch). ~$9–18/month */
|
|
56
59
|
enhanced: boolean;
|
|
60
|
+
/** Disable auto-generated per-domain CloudWatch dashboards. Removes existing dashboards on next deploy. */
|
|
61
|
+
disableCloudWatchDashboards?: boolean;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
/** Lifecycle tunables — Phase B. Schema only in Phase A. */
|
|
@@ -114,6 +119,8 @@ export interface ScaffoldConfig {
|
|
|
114
119
|
environments?: EnvironmentsConfig;
|
|
115
120
|
/** When true, CORS responses include Allow-Credentials: true (requires non-wildcard origins). */
|
|
116
121
|
allowCredentials?: boolean;
|
|
122
|
+
/** NAT instance type for the shared NAT instance. Defaults to the smallest: t4g.nano. */
|
|
123
|
+
natInstanceType?: NatInstanceType;
|
|
117
124
|
}
|
|
118
125
|
|
|
119
126
|
const DEFAULT_SCAFFOLD_CONFIG: Omit<ScaffoldConfig, 'domainIds' | 'flowIds'> = {
|
|
@@ -134,7 +141,9 @@ const DEFAULT_SCAFFOLD_CONFIG: Omit<ScaffoldConfig, 'domainIds' | 'flowIds'> = {
|
|
|
134
141
|
logRetentionDays: 30,
|
|
135
142
|
monitoringOptions: {
|
|
136
143
|
enhanced: false,
|
|
144
|
+
disableCloudWatchDashboards: false,
|
|
137
145
|
},
|
|
146
|
+
natInstanceType: 't4g.nano',
|
|
138
147
|
};
|
|
139
148
|
|
|
140
149
|
const CONFIG_PATH = '.mc/scaffold-config.json';
|