@mettlecast/domain-cdk-packer 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.
Files changed (30) hide show
  1. package/dist/DomainStack.d.ts +5 -0
  2. package/dist/DomainStack.js +145 -67
  3. package/dist/__tests__/action-construct.test.d.ts +1 -0
  4. package/dist/__tests__/action-construct.test.js +159 -0
  5. package/dist/__tests__/domain-stack.test.js +315 -15
  6. package/dist/__tests__/grouped-lambda-factory-action-wrapper.test.d.ts +11 -0
  7. package/dist/__tests__/grouped-lambda-factory-action-wrapper.test.js +47 -0
  8. package/dist/__tests__/grouped-lambda-factory.test.d.ts +1 -0
  9. package/dist/__tests__/grouped-lambda-factory.test.js +146 -0
  10. package/dist/__tests__/lambda-factory.test.js +7 -7
  11. package/dist/__tests__/registry.test.js +111 -4
  12. package/dist/__tests__/security-assertion-aspect.test.d.ts +1 -0
  13. package/dist/__tests__/security-assertion-aspect.test.js +222 -0
  14. package/dist/aspects/index.d.ts +4 -0
  15. package/dist/aspects/index.js +2 -0
  16. package/dist/aspects/security-assertion-aspect.d.ts +161 -0
  17. package/dist/aspects/security-assertion-aspect.js +226 -0
  18. package/dist/constructs/action-construct.d.ts +16 -6
  19. package/dist/constructs/action-construct.js +10 -11
  20. package/dist/constructs/api-construct.d.ts +10 -2
  21. package/dist/constructs/api-construct.js +25 -5
  22. package/dist/grouped-lambda-factory.d.ts +69 -1
  23. package/dist/grouped-lambda-factory.js +98 -10
  24. package/dist/iam/iam-policy-builder.js +0 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +1 -1
  27. package/dist/pack-domain.d.ts +2 -0
  28. package/dist/pack-domain.js +9 -3
  29. package/dist/registry.d.ts +98 -47
  30. package/package.json +1 -1
@@ -5,7 +5,7 @@ export type SchemaSnapshot = Record<string, unknown>;
5
5
  /**
6
6
  * Kind discriminant for registry entries.
7
7
  */
8
- export type RegistryEntryKind = 'api' | 'webhook' | 'subscriber' | 'schedule' | 'job' | 'action' | 'integration' | 'event' | 'domain';
8
+ export type RegistryEntryKind = 'webhook' | 'subscriber' | 'schedule' | 'job' | 'action' | 'integration' | 'event' | 'domain';
9
9
  /** Controls whether a VPC-attached handler may use NAT-backed public internet egress. */
10
10
  export type RegistryOutboundAccess = 'internal' | 'internet';
11
11
  /**
@@ -38,47 +38,6 @@ export interface BaseRegistryEntry {
38
38
  /** Optional human-readable description of this primitive. */
39
39
  description?: string;
40
40
  }
41
- /**
42
- * Schema snapshot for a single API version.
43
- */
44
- export interface ApiVersionSnapshot {
45
- /** Semver-style version string, e.g. '1'. */
46
- version: string;
47
- /** JSON Schema for the request body of this version. */
48
- requestSchema?: SchemaSnapshot;
49
- /** JSON Schema for the successful response body of this version. */
50
- responseSchema?: SchemaSnapshot;
51
- }
52
- /**
53
- * API registry entry for HTTP endpoint handlers.
54
- */
55
- export interface ApiRegistryEntry extends BaseRegistryEntry {
56
- /** Discriminant. */
57
- kind: 'api';
58
- /** Handler file path (required for API). */
59
- handlerFile: string;
60
- /** HTTP route path, e.g. '/users/:id'. */
61
- path: string;
62
- /** HTTP method. */
63
- method: string;
64
- /** Authentication type. */
65
- authType: 'jwt' | 'api-key' | 'none';
66
- /** Optional deployment overrides. */
67
- deployment?: SerialDeploymentConfig;
68
- /** Whether this handler may use NAT-backed public internet egress. */
69
- outboundAccess?: RegistryOutboundAccess;
70
- /** JSON Schema snapshot for the HTTP request body. */
71
- requestSchema?: SchemaSnapshot;
72
- /** JSON Schema snapshot for the HTTP response body. */
73
- responseSchema?: SchemaSnapshot;
74
- /** Per-version request/response schema snapshots. */
75
- versions?: ApiVersionSnapshot[];
76
- /** Example request/response payloads for documentation (no runtime impact). */
77
- examples?: {
78
- request?: Record<string, unknown>;
79
- response?: Record<string, unknown>;
80
- };
81
- }
82
41
  /**
83
42
  * Webhook registry entry for webhook handlers.
84
43
  */
@@ -153,16 +112,110 @@ export interface JobRegistryEntry extends BaseRegistryEntry {
153
112
  /** Whether this handler may use NAT-backed public internet egress. */
154
113
  outboundAccess?: RegistryOutboundAccess;
155
114
  }
115
+ /**
116
+ * Backend invocation permission for an action.
117
+ *
118
+ * Controls who can call the action through `ctx.actions` (cross-domain
119
+ * Lambda invocation or runtime action calls).
120
+ *
121
+ * - `private` = only same-domain/internal generated adapters
122
+ * - `domain` = callable by other domains through ctx.actions, subject to policy
123
+ * - `platform` = callable by system jobs, flows, admin tooling
124
+ */
125
+ export type ActionBackendAccess = 'private' | 'domain' | 'platform';
126
+ /**
127
+ * API-exposure metadata for an action.
128
+ *
129
+ * Present only when `exposure.type === 'api'`. Carries the route, method,
130
+ * auth, tenancy, and any required role or documented security exception
131
+ * that downstream CDK/contract generation needs to wire the route safely.
132
+ *
133
+ * The optional `authDeclared` and `tenancyDeclared` flags are populated by
134
+ * the registry builder to record whether the source code explicitly declared
135
+ * each field, or whether the builder fell back to the safe default. They are
136
+ * consumed by the domain CLI's validate command (Wave 6 Task 6.1) to enforce
137
+ * the action-first security model (#4619).
138
+ */
139
+ export interface ActionApiExposure {
140
+ /** Discriminant. */
141
+ type: 'api';
142
+ /** HTTP route path, e.g. '/v1/tenants/{tenantId}/billing/invoices'. */
143
+ path: string;
144
+ /** HTTP method. One of: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS. */
145
+ method: string;
146
+ /** Authentication requirement for the route. */
147
+ auth: 'required' | 'none' | 'service';
148
+ /** Tenancy requirement for the route. */
149
+ tenancy: 'required' | 'none' | 'system';
150
+ /** Required role(s) for `auth: 'required'` routes (system tenancy requires this). */
151
+ roles?: string[];
152
+ /** Documented exception when auth or tenancy is intentionally not required. */
153
+ securityException?: {
154
+ reason: string;
155
+ };
156
+ /**
157
+ * True if the source code explicitly declared `auth`. False if the
158
+ * builder fell back to the safe default (`'required'`). Validation-only.
159
+ */
160
+ authDeclared?: boolean;
161
+ /**
162
+ * True if the source code explicitly declared `tenancy`. False if the
163
+ * builder fell back to the safe default (`'required'`). Validation-only.
164
+ */
165
+ tenancyDeclared?: boolean;
166
+ }
167
+ /**
168
+ * Discriminated union of all supported action exposure shapes.
169
+ *
170
+ * `internal` actions are not exposed externally; they are reachable only
171
+ * through `ctx.actions`. `api` actions are exposed via API Gateway and
172
+ * carry the route + auth metadata needed for safe route generation.
173
+ */
174
+ export type ActionExposure = ActionApiExposure | {
175
+ type: 'internal';
176
+ };
156
177
  /**
157
178
  * Action registry entry for callable domain actions.
179
+ *
180
+ * `backendAccess` is the canonical permission field for backend invocation
181
+ * and replaces the legacy `visibility` field during the
182
+ * action-first migration (#4619). `visibility` is preserved as an optional
183
+ * deprecated field so existing CDK constructs continue to compile until
184
+ * they are updated to consume `backendAccess` directly.
158
185
  */
159
186
  export interface ActionRegistryEntry extends BaseRegistryEntry {
160
187
  /** Discriminant. */
161
188
  kind: 'action';
162
189
  /** Handler file path (required for action). */
163
190
  handlerFile: string;
164
- /** Visibility scope: 'private', 'domain', or 'workspace'. */
165
- visibility: 'private' | 'domain' | 'workspace';
191
+ /**
192
+ * Backend invocation permission for the action.
193
+ * Replaces legacy `visibility` for the action-first migration.
194
+ */
195
+ backendAccess: ActionBackendAccess;
196
+ /**
197
+ * External exposure shape for the action. New-style actions must declare
198
+ * an exposure; legacy actions default to `{ type: 'internal' }` during
199
+ * migration to preserve existing behavior.
200
+ */
201
+ exposure: ActionExposure;
202
+ /**
203
+ * True if the source code explicitly declared `exposure`. False (or
204
+ * omitted) if the builder fell back to the default `{ type: 'internal' }`
205
+ * because the source did not opt in. Consumed by the domain CLI's
206
+ * validate command (Wave 6 Task 6.1) to enforce `ACTION_EXPOSURE_REQUIRED`.
207
+ */
208
+ exposureDeclared?: boolean;
209
+ /**
210
+ * Legacy visibility scope. Retained during the action-first migration so
211
+ * CDK constructs that still read this field (e.g. action-construct.ts)
212
+ * keep compiling. New source code should set `backendAccess` instead;
213
+ * the registry builder maps legacy `visibility` -> `backendAccess` with
214
+ * `workspace` collapsing to `domain` per the migration spec.
215
+ *
216
+ * @deprecated Use `backendAccess` instead.
217
+ */
218
+ visibility?: 'private' | 'domain' | 'workspace';
166
219
  /** Whether the action enforces idempotency. */
167
220
  idempotent: boolean;
168
221
  /** Optional deployment overrides. */
@@ -213,7 +266,7 @@ export interface DomainRegistryEntry extends BaseRegistryEntry {
213
266
  /**
214
267
  * Union type of all registry entry kinds.
215
268
  */
216
- export type RegistryEntry = ApiRegistryEntry | WebhookRegistryEntry | SubscriberRegistryEntry | ScheduleRegistryEntry | JobRegistryEntry | ActionRegistryEntry | IntegrationRegistryEntry | EventRegistryEntry | DomainRegistryEntry;
269
+ export type RegistryEntry = WebhookRegistryEntry | SubscriberRegistryEntry | ScheduleRegistryEntry | JobRegistryEntry | ActionRegistryEntry | IntegrationRegistryEntry | EventRegistryEntry | DomainRegistryEntry;
217
270
  /**
218
271
  * Top-level domain registry — the compiled snapshot for CDK packer.
219
272
  */
@@ -224,8 +277,6 @@ export interface DomainRegistry {
224
277
  domainRoot: string;
225
278
  /** The domain itself. */
226
279
  domain: DomainRegistryEntry;
227
- /** All API endpoints. */
228
- apis: ApiRegistryEntry[];
229
280
  /** All webhook receivers. */
230
281
  webhooks: WebhookRegistryEntry[];
231
282
  /** All event subscribers. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mettlecast/domain-cdk-packer",
3
- "version": "0.2.60",
3
+ "version": "0.2.62",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",