@sequenceholdings/managed-functions 0.4.0 → 0.4.2

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 (92) hide show
  1. package/README.md +444 -2
  2. package/dist/abrigo-contract.d.ts +92 -0
  3. package/dist/abrigo-contract.js +55 -0
  4. package/dist/abrigo-response.d.ts +6 -0
  5. package/dist/abrigo-response.js +27 -0
  6. package/dist/abrigo.d.ts +14 -0
  7. package/dist/abrigo.js +150 -0
  8. package/dist/agent-evidence.d.ts +9 -0
  9. package/dist/agent-evidence.js +84 -0
  10. package/dist/agent-source-evidence-contract.d.ts +1197 -0
  11. package/dist/agent-source-evidence-contract.js +96 -0
  12. package/dist/agents-contract.d.ts +99 -0
  13. package/dist/agents-contract.js +69 -0
  14. package/dist/agents.d.ts +15 -0
  15. package/dist/agents.js +121 -0
  16. package/dist/capabilities.d.ts +165 -0
  17. package/dist/capabilities.js +61 -1
  18. package/dist/config.d.ts +18 -2
  19. package/dist/config.js +62 -1
  20. package/dist/deployed-policy.js +102 -0
  21. package/dist/directory-config.d.ts +23 -0
  22. package/dist/directory-config.js +22 -0
  23. package/dist/directory-contract.d.ts +68 -0
  24. package/dist/directory-contract.js +57 -0
  25. package/dist/directory-manifest.d.ts +5 -0
  26. package/dist/directory-manifest.js +10 -0
  27. package/dist/directory.d.ts +15 -0
  28. package/dist/directory.js +65 -0
  29. package/dist/http-tracing.js +3 -0
  30. package/dist/immutable-release-contract.d.ts +3 -0
  31. package/dist/immutable-release-contract.js +12 -0
  32. package/dist/index.d.ts +40 -1
  33. package/dist/index.js +75 -1
  34. package/dist/invocation-client.d.ts +45 -0
  35. package/dist/invocation-client.js +90 -0
  36. package/dist/invocation-contract.d.ts +36 -0
  37. package/dist/invocation-contract.js +48 -0
  38. package/dist/invocation.d.ts +8 -0
  39. package/dist/invocation.js +134 -0
  40. package/dist/lattice-capability.d.ts +5 -0
  41. package/dist/lattice-capability.js +16 -0
  42. package/dist/lattice-provenance-contract.d.ts +519 -0
  43. package/dist/lattice-provenance-contract.js +148 -0
  44. package/dist/lattice-provenance.d.ts +16 -0
  45. package/dist/lattice-provenance.js +167 -0
  46. package/dist/monitoring-annotations.d.ts +53 -0
  47. package/dist/monitoring-annotations.js +54 -0
  48. package/dist/monitoring-contract.d.ts +463 -0
  49. package/dist/monitoring-contract.js +89 -0
  50. package/dist/monitoring-events.d.ts +257 -0
  51. package/dist/monitoring-events.js +136 -0
  52. package/dist/monitoring.d.ts +14 -0
  53. package/dist/monitoring.js +78 -0
  54. package/dist/orm-contract.d.ts +1 -0
  55. package/dist/orm-contract.js +4 -0
  56. package/dist/orm.d.ts +19 -3
  57. package/dist/orm.js +93 -13
  58. package/dist/preflight-abrigo.d.ts +10 -0
  59. package/dist/preflight-abrigo.js +26 -0
  60. package/dist/preflight-agents.d.ts +10 -0
  61. package/dist/preflight-agents.js +51 -0
  62. package/dist/preflight-directory.d.ts +10 -0
  63. package/dist/preflight-directory.js +36 -0
  64. package/dist/preflight-immutable-release.d.ts +10 -0
  65. package/dist/preflight-immutable-release.js +34 -0
  66. package/dist/preflight-invocation.d.ts +10 -0
  67. package/dist/preflight-invocation.js +40 -0
  68. package/dist/preflight-lattice.d.ts +10 -0
  69. package/dist/preflight-lattice.js +40 -0
  70. package/dist/preflight-monitoring.d.ts +10 -0
  71. package/dist/preflight-monitoring.js +46 -0
  72. package/dist/preflight-service-directory.d.ts +10 -0
  73. package/dist/preflight-service-directory.js +26 -0
  74. package/dist/preflight-workflows.d.ts +10 -0
  75. package/dist/preflight-workflows.js +38 -0
  76. package/dist/preflight.js +50 -2
  77. package/dist/processes-contract.d.ts +20 -0
  78. package/dist/processes-contract.js +8 -1
  79. package/dist/processes.d.ts +4 -8
  80. package/dist/processes.js +52 -83
  81. package/dist/runtime.cjs +3387 -259
  82. package/dist/sdk-range.d.ts +1 -0
  83. package/dist/sdk-range.js +25 -0
  84. package/dist/service-directory.d.ts +12 -0
  85. package/dist/service-directory.js +72 -0
  86. package/dist/workflow-scopes-contract.d.ts +8 -0
  87. package/dist/workflow-scopes-contract.js +29 -0
  88. package/dist/workflow-source-contract.d.ts +524 -0
  89. package/dist/workflow-source-contract.js +59 -0
  90. package/dist/workflow-source.d.ts +12 -0
  91. package/dist/workflow-source.js +93 -0
  92. package/package.json +2 -2
package/dist/orm.js CHANGED
@@ -20,11 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/orm.ts
21
21
  var orm_exports = {};
22
22
  __export(orm_exports, {
23
+ FUNCTION_CALLER_DATA_TOKEN_HEADER: () => FUNCTION_CALLER_DATA_TOKEN_HEADER,
23
24
  FunctionOrmError: () => FunctionOrmError,
24
25
  ORM_JSON_SCALARS_HEADER: () => ORM_JSON_SCALARS_HEADER,
25
26
  ORM_LOSSLESS_JSON_SCALARS: () => ORM_LOSSLESS_JSON_SCALARS,
26
27
  OrmClientError: () => OrmClientError,
27
28
  OrmOperationError: () => OrmOperationError,
29
+ createFunctionCallerOrmExecutor: () => createFunctionCallerOrmExecutor,
28
30
  createFunctionOrmExecutor: () => createFunctionOrmExecutor,
29
31
  createFunctionServiceOrmExecutor: () => createFunctionServiceOrmExecutor
30
32
  });
@@ -82,12 +84,48 @@ function readOperationResponse({
82
84
  }
83
85
  return payload.data;
84
86
  }
87
+ function readOperationResponseWithReceipt({
88
+ ok,
89
+ status,
90
+ body,
91
+ expectedSourceGeneration
92
+ }) {
93
+ const data = readOperationResponse({ ok, status, body });
94
+ const extensions = isRecord(body) && isRecord(body.extensions) ? body.extensions : null;
95
+ const sourceGeneration = extensions?.sourceGeneration;
96
+ if (typeof sourceGeneration !== "string" || !/^[a-f0-9]{64}$/.test(sourceGeneration) || expectedSourceGeneration !== void 0 && expectedSourceGeneration !== sourceGeneration) {
97
+ throw new OrmOperationError("Source generation unavailable", status, "OBJECT_UNAVAILABLE");
98
+ }
99
+ return { data, sourceGeneration };
100
+ }
85
101
  var BUILTIN_SQL_READ_HASH = "sha256:a50c477c952a5e0fe68ed158a4530e4aab573c09bcbb1a8ac454dc88a39a6258";
86
102
  function validateIdempotencyKey(key) {
87
103
  if (key !== void 0 && !/^[A-Za-z0-9._:-]{1,128}$/.test(key)) {
88
104
  throw new OrmClientError("idempotencyKey must be 1\u2013128 letters, digits, dots, underscores, colons or hyphens");
89
105
  }
90
106
  }
107
+ function validateExpectedSourceGeneration(value) {
108
+ if (value !== void 0 && (typeof value !== "string" || !/^[a-f0-9]{64}$/.test(value))) {
109
+ throw new OrmClientError("expectedSourceGeneration must be a lowercase 64-character hexadecimal receipt");
110
+ }
111
+ }
112
+ function createReadReceiptOperationResolver({ operations }) {
113
+ const hashesByName = /* @__PURE__ */ new Map();
114
+ const readHashes = /* @__PURE__ */ new Set([BUILTIN_SQL_READ_HASH]);
115
+ const mutationHashes = /* @__PURE__ */ new Set();
116
+ for (const [name, entry] of operations) {
117
+ hashesByName.set(name, entry.hash);
118
+ if (entry.kind === "query" && /^sha256:[a-f0-9]{64}$/.test(entry.hash)) readHashes.add(entry.hash);
119
+ if (entry.kind === "mutation") mutationHashes.add(entry.hash);
120
+ }
121
+ return ({ selector, hashOnly = false }) => {
122
+ const hash = selector.startsWith("sha256:") ? selector : hashOnly ? void 0 : hashesByName.get(selector);
123
+ if (!hash || !readHashes.has(hash) || mutationHashes.has(hash)) {
124
+ throw new OrmClientError("read receipts require a registered query or the built-in SQL read");
125
+ }
126
+ return hash;
127
+ };
128
+ }
91
129
  var operationHash = /^sha256:[a-f0-9]{64}$/;
92
130
  function readManifestHashes(manifest) {
93
131
  if (!isRecord(manifest) || typeof manifest.schemaHash !== "string" || !manifest.schemaHash || !isRecord(manifest.operations)) {
@@ -98,35 +136,51 @@ function readManifestHashes(manifest) {
98
136
  if (!/^[_A-Za-z][_0-9A-Za-z]*$/.test(name) || !isRecord(entry) || typeof entry.hash !== "string" || !operationHash.test(entry.hash) || entry.kind !== "query" && entry.kind !== "mutation") {
99
137
  throw new OrmClientError(`invalid operations manifest entry "${name}" \u2014 regenerate the manifest`);
100
138
  }
101
- hashes.set(name, entry.hash);
139
+ hashes.set(name, { hash: entry.hash, kind: entry.kind });
102
140
  }
103
141
  return hashes;
104
142
  }
105
143
  function createOperationExecutorWithTransport({ namespace, manifest, transport }) {
106
144
  if (typeof namespace !== "string" || !NAMESPACE_PATTERN.test(namespace)) throw new OrmClientError("invalid ORM namespace \u2014 expected a lowercase identifier of at most 41 characters");
107
145
  const hashes = manifest === void 0 ? /* @__PURE__ */ new Map() : readManifestHashes(manifest);
108
- const knownHashes = new Set(hashes.values());
109
- async function execute(op, variables = {}, options = {}) {
146
+ const knownHashes = new Set([...hashes.values()].map((entry) => entry.hash));
147
+ const resolveReceiptOperation = createReadReceiptOperationResolver({ operations: hashes });
148
+ async function request({ op, variables, options, requireReadReceipt = false }) {
110
149
  validateIdempotencyKey(options.idempotencyKey);
150
+ validateExpectedSourceGeneration(options.expectedSourceGeneration);
111
151
  if (typeof op !== "string" && op.namespace !== namespace) throw new OrmClientError("operation belongs to a different namespace");
112
152
  const selector = typeof op === "string" ? op : op.hash;
113
- const hash = selector === BUILTIN_SQL_READ_HASH ? selector : hashes.get(selector) ?? (knownHashes.has(selector) ? selector : void 0);
153
+ const hash = requireReadReceipt ? resolveReceiptOperation({ selector, hashOnly: typeof op !== "string" }) : selector === BUILTIN_SQL_READ_HASH ? selector : hashes.get(selector)?.hash ?? (knownHashes.has(selector) ? selector : void 0);
114
154
  if (!hash) throw new OrmClientError(`unknown operation "${op}" \u2014 not in the manifest (${hashes.size} known). Re-run seq-studio orm generate.`);
115
155
  if (!isRecord(variables)) throw new OrmClientError("operation variables must be an object");
116
156
  const response = await transport({
117
157
  namespace,
118
158
  op: hash,
119
159
  variables,
120
- ...options.idempotencyKey === void 0 ? {} : { idempotencyKey: options.idempotencyKey }
160
+ ...options.idempotencyKey === void 0 ? {} : { idempotencyKey: options.idempotencyKey },
161
+ ...options.expectedSourceGeneration === void 0 ? {} : { expectedSourceGeneration: options.expectedSourceGeneration }
121
162
  });
122
163
  if (!response || typeof response.ok !== "boolean" || !Number.isInteger(response.status) || response.status < 100 || response.status > 599 || response.ok !== (response.status >= 200 && response.status < 300)) {
123
164
  throw new OrmOperationError("malformed transport response", null, null);
124
165
  }
125
- return readOperationResponse(response);
166
+ return response;
167
+ }
168
+ async function execute(op, variables = {}, options = {}) {
169
+ const executionOptions = { ...options };
170
+ const response = await request({ op, variables, options: executionOptions });
171
+ return executionOptions.expectedSourceGeneration === void 0 ? readOperationResponse(response) : readOperationResponseWithReceipt({ ...response, expectedSourceGeneration: executionOptions.expectedSourceGeneration }).data;
172
+ }
173
+ async function executeWithReadReceipt(op, variables = {}, options = {}) {
174
+ const executionOptions = { ...options };
175
+ const response = await request({ op, variables, options: executionOptions, requireReadReceipt: true });
176
+ return readOperationResponseWithReceipt({ ...response, expectedSourceGeneration: executionOptions.expectedSourceGeneration });
126
177
  }
127
- return { execute, sql: (variables) => execute(BUILTIN_SQL_READ_HASH, variables) };
178
+ return { execute, executeWithReadReceipt, sql: (variables) => execute(BUILTIN_SQL_READ_HASH, variables) };
128
179
  }
129
180
 
181
+ // src/orm-contract.ts
182
+ var FUNCTION_CALLER_DATA_TOKEN_HEADER = "x-sequence-caller-data-token";
183
+
130
184
  // src/orm.ts
131
185
  var FunctionOrmError = class extends Error {
132
186
  constructor(code, message) {
@@ -168,12 +222,12 @@ function invocationClaims({ token }) {
168
222
  } catch {
169
223
  throw invalidContext();
170
224
  }
171
- if (!record(claims) || typeof claims.sub !== "string" || !claims.sub || typeof claims.functionId !== "string" || !claims.functionId || typeof claims.invocationId !== "string" || !claims.invocationId || typeof claims.exp !== "number" || !Number.isSafeInteger(claims.exp) || claims.origin !== void 0 && claims.origin !== "function") throw invalidContext();
172
- return { sub: claims.sub, exp: claims.exp, assertedBy: claims.assertedBy };
225
+ if (!record(claims) || typeof claims.sub !== "string" || !claims.sub || typeof claims.functionId !== "string" || !claims.functionId || typeof claims.invocationId !== "string" || !claims.invocationId || typeof claims.exp !== "number" || !Number.isSafeInteger(claims.exp) || claims.origin !== void 0 && claims.origin !== "function" || claims.executionMode !== void 0 && claims.executionMode !== "caller" && claims.executionMode !== "attached") throw invalidContext();
226
+ return { sub: claims.sub, exp: claims.exp, assertedBy: claims.assertedBy, executionMode: claims.executionMode };
173
227
  }
174
228
  function callerExpiry({ token }) {
175
229
  const claims = invocationClaims({ token });
176
- if (claims.sub.startsWith("service-account|") || claims.sub.endsWith("@clients") || claims.assertedBy != null) {
230
+ if (claims.sub.startsWith("service-account|") || claims.sub.endsWith("@clients") || claims.assertedBy != null || claims.executionMode === "attached") {
177
231
  throw new FunctionOrmError(
178
232
  "UNSUPPORTED_CALLER",
179
233
  "This ORM helper requires a direct human invocation. For system-runner (Lattice) invocations, use createFunctionServiceOrmExecutor to act as the function's attached service account."
@@ -183,7 +237,7 @@ function callerExpiry({ token }) {
183
237
  }
184
238
  function serviceExpiry({ token }) {
185
239
  const claims = invocationClaims({ token });
186
- if (!claims.sub.startsWith("service-account|") || typeof claims.assertedBy !== "string" || !claims.assertedBy) {
240
+ if (!claims.sub.startsWith("service-account|") || typeof claims.assertedBy !== "string" || !claims.assertedBy || claims.executionMode === "caller") {
187
241
  throw new FunctionOrmError(
188
242
  "UNSUPPORTED_CALLER",
189
243
  "The service data token does not name the function's attached service account."
@@ -191,6 +245,17 @@ function serviceExpiry({ token }) {
191
245
  }
192
246
  return claims.exp;
193
247
  }
248
+ function explicitCallerExpiry({ token }) {
249
+ const claims = invocationClaims({ token });
250
+ const platformAccount = /^service-account\|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(claims.sub);
251
+ if (claims.executionMode !== "caller" || claims.sub.endsWith("@clients") || claims.sub.startsWith("service-account|") && !platformAccount) {
252
+ throw new FunctionOrmError(
253
+ "UNSUPPORTED_CALLER",
254
+ "Caller ORM access requires a platform-delivered caller credential for the actual human or platform service account. It never uses the attached service identity or the run initiator."
255
+ );
256
+ }
257
+ return claims.exp;
258
+ }
194
259
  function requireUnexpired({ expiresAt }) {
195
260
  if (expiresAt <= Math.floor(Date.now() / 1e3)) {
196
261
  throw new FunctionOrmError(
@@ -236,7 +301,7 @@ function createExecutor({
236
301
  return createOperationExecutorWithTransport({
237
302
  namespace,
238
303
  manifest,
239
- transport: async ({ namespace: targetNamespace, op, variables, idempotencyKey }) => {
304
+ transport: async ({ namespace: targetNamespace, op, variables, idempotencyKey, expectedSourceGeneration }) => {
240
305
  requireUnexpired({ expiresAt });
241
306
  const response = await fetchImpl(`${origin}/_data/v2/${targetNamespace}`, {
242
307
  method: "POST",
@@ -245,7 +310,7 @@ function createExecutor({
245
310
  [header]: token,
246
311
  ...jsonScalars ? { [ORM_JSON_SCALARS_HEADER]: jsonScalars } : {}
247
312
  },
248
- body: JSON.stringify({ op, variables, idempotencyKey }),
313
+ body: JSON.stringify({ op, variables, idempotencyKey, expectedSourceGeneration }),
249
314
  redirect: "error"
250
315
  });
251
316
  const body = await response.json().catch(() => null);
@@ -273,6 +338,19 @@ function createFunctionOrmExecutor({
273
338
  });
274
339
  return createExecutor({ ...options, fetchImpl, token, header: ORM_DATA_TOKEN_HEADER, expiresAt: callerExpiry({ token }) });
275
340
  }
341
+ function createFunctionCallerOrmExecutor({
342
+ request,
343
+ fetchImpl = globalThis.fetch,
344
+ ...options
345
+ }) {
346
+ trustedOrigin({ baseUrl: options.baseUrl });
347
+ const token = readToken({
348
+ request,
349
+ header: FUNCTION_CALLER_DATA_TOKEN_HEADER,
350
+ missing: "Caller ORM access is unavailable. Invoke through a platform runtime supporting caller delegation, as a human or an explicit platform service account."
351
+ });
352
+ return createExecutor({ ...options, fetchImpl, token, header: ORM_DATA_TOKEN_HEADER, expiresAt: explicitCallerExpiry({ token }) });
353
+ }
276
354
  function createFunctionServiceOrmExecutor({
277
355
  request,
278
356
  fetchImpl = globalThis.fetch,
@@ -288,11 +366,13 @@ function createFunctionServiceOrmExecutor({
288
366
  }
289
367
  // Annotate the CommonJS export names for ESM import in node:
290
368
  0 && (module.exports = {
369
+ FUNCTION_CALLER_DATA_TOKEN_HEADER,
291
370
  FunctionOrmError,
292
371
  ORM_JSON_SCALARS_HEADER,
293
372
  ORM_LOSSLESS_JSON_SCALARS,
294
373
  OrmClientError,
295
374
  OrmOperationError,
375
+ createFunctionCallerOrmExecutor,
296
376
  createFunctionOrmExecutor,
297
377
  createFunctionServiceOrmExecutor
298
378
  });
@@ -0,0 +1,10 @@
1
+ import { type CapabilityTooling, type ManagedFunctionCapabilities, type PreflightIssue, type PreflightManifest } from './capabilities';
2
+ export declare function checkAbrigo({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues }: {
3
+ manifest: PreflightManifest;
4
+ capabilities: ManagedFunctionCapabilities | null;
5
+ tooling: CapabilityTooling;
6
+ cliVersion: string;
7
+ sdkVersion: string | null;
8
+ checkDeployment: boolean;
9
+ issues: PreflightIssue[];
10
+ }): void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkAbrigo = checkAbrigo;
4
+ const capabilities_1 = require("./capabilities");
5
+ const preflight_issue_1 = require("./preflight-issue");
6
+ const abrigo_contract_1 = require("./abrigo-contract");
7
+ const sdk_range_1 = require("./sdk-range");
8
+ function checkAbrigo({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues }) {
9
+ const abrigo = manifest.capabilities?.abrigo;
10
+ if (abrigo === undefined)
11
+ return;
12
+ const deployed = capabilities?.features.abrigo_read;
13
+ const feature = deployed ?? capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features.abrigo_read;
14
+ const details = { limit: feature.limit, tooling, requiredCli: feature.min_cli, requiredSdk: feature.min_sdk, cliVersion, sdkVersion };
15
+ const parsed = abrigo_contract_1.functionAbrigoReadScopesSchema.safeParse(abrigo);
16
+ if (!parsed.success) {
17
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details, field: 'capabilities.abrigo', problem: (0, capabilities_1.formatValidationDetail)(parsed.error.issues) }));
18
+ return;
19
+ }
20
+ if (checkDeployment && deployed?.supported !== true) {
21
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details, field: feature.field, problem: 'caller-scoped Abrigo reads are not supported by this deployment' }));
22
+ return;
23
+ }
24
+ if ((0, capabilities_1.versionIsOlder)(cliVersion, feature.min_cli) || !sdkVersion || !(0, sdk_range_1.sdkSpecAllowsOnlyAtOrAbove)(sdkVersion, feature.min_sdk))
25
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details, field: feature.field, problem: 'declare compatible tooling for caller-scoped Abrigo reads' }));
26
+ }
@@ -0,0 +1,10 @@
1
+ import { type CapabilityTooling, type ManagedFunctionCapabilities, type PreflightIssue, type PreflightManifest } from './capabilities';
2
+ export declare function checkAgents({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues }: {
3
+ manifest: PreflightManifest;
4
+ capabilities: ManagedFunctionCapabilities | null;
5
+ tooling: CapabilityTooling;
6
+ cliVersion: string;
7
+ sdkVersion: string | null;
8
+ checkDeployment: boolean;
9
+ issues: PreflightIssue[];
10
+ }): void;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkAgents = checkAgents;
4
+ const capabilities_1 = require("./capabilities");
5
+ const preflight_issue_1 = require("./preflight-issue");
6
+ const agents_contract_1 = require("./agents-contract");
7
+ const sdk_range_1 = require("./sdk-range");
8
+ function checkAgents({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues }) {
9
+ const agents = manifest.capabilities?.agents;
10
+ if (agents === undefined)
11
+ return;
12
+ const parsed = agents_contract_1.functionAgentReadScopesSchema.safeParse(agents);
13
+ const keys = parsed.success && parsed.data.read === undefined ? [] : ['agents_read'];
14
+ if (parsed.success && parsed.data.evidence !== undefined)
15
+ keys.push('agents_evidence_verify');
16
+ for (const key of keys) {
17
+ const deployed = capabilities?.features[key];
18
+ const feature = deployed ?? capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features[key];
19
+ const details = {
20
+ limit: feature.limit,
21
+ tooling,
22
+ requiredCli: feature.min_cli,
23
+ requiredSdk: feature.min_sdk,
24
+ cliVersion,
25
+ sdkVersion,
26
+ };
27
+ if (!parsed.success) {
28
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
29
+ ...details,
30
+ field: 'capabilities.agents',
31
+ problem: (0, capabilities_1.formatValidationDetail)(parsed.error.issues),
32
+ }));
33
+ return;
34
+ }
35
+ if (checkDeployment && deployed?.supported !== true) {
36
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
37
+ ...details,
38
+ field: feature.field,
39
+ problem: 'the declared agent capability is not supported by this deployment',
40
+ }));
41
+ continue;
42
+ }
43
+ if ((0, capabilities_1.versionIsOlder)(cliVersion, feature.min_cli) || (sdkVersion && (0, sdk_range_1.sdkConstraintIsOlder)(sdkVersion, feature.min_sdk))) {
44
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
45
+ ...details,
46
+ field: feature.field,
47
+ problem: 'the installed tooling does not support the declared agent capability',
48
+ }));
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,10 @@
1
+ import { type CapabilityTooling, type ManagedFunctionCapabilities, type PreflightIssue, type PreflightManifest } from './capabilities';
2
+ export declare function checkDirectory({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }: {
3
+ manifest: PreflightManifest;
4
+ capabilities: ManagedFunctionCapabilities | null;
5
+ tooling: CapabilityTooling;
6
+ cliVersion: string;
7
+ sdkVersion: string | null;
8
+ checkDeployment: boolean;
9
+ issues: PreflightIssue[];
10
+ }): void;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkDirectory = checkDirectory;
4
+ const capabilities_1 = require("./capabilities");
5
+ const preflight_issue_1 = require("./preflight-issue");
6
+ const directory_config_1 = require("./directory-config");
7
+ const sdk_range_1 = require("./sdk-range");
8
+ function checkDirectory({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }) {
9
+ const directory = manifest.capabilities?.directory;
10
+ if (directory === undefined)
11
+ return;
12
+ const deployed = capabilities?.features.directory_members;
13
+ const feature = deployed ?? capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features.directory_members;
14
+ const details = {
15
+ limit: feature.limit, tooling, requiredCli: feature.min_cli,
16
+ requiredSdk: feature.min_sdk, cliVersion, sdkVersion,
17
+ };
18
+ const parsed = directory_config_1.directoryScopesSchema.safeParse(directory);
19
+ if (!parsed.success) {
20
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
21
+ ...details, field: 'capabilities.directory', problem: (0, capabilities_1.formatValidationDetail)(parsed.error.issues),
22
+ }));
23
+ return;
24
+ }
25
+ if (checkDeployment && deployed?.supported !== true) {
26
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
27
+ ...details, field: feature.field, problem: 'group-member directory reads are not supported by this deployment',
28
+ }));
29
+ return;
30
+ }
31
+ if ((0, capabilities_1.versionIsOlder)(cliVersion, feature.min_cli) || (sdkVersion && (0, sdk_range_1.sdkConstraintIsOlder)(sdkVersion, feature.min_sdk))) {
32
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
33
+ ...details, field: feature.field, problem: 'the installed tooling does not support managed function group-member directory reads',
34
+ }));
35
+ }
36
+ }
@@ -0,0 +1,10 @@
1
+ import { type CapabilityTooling, type ManagedFunctionCapabilities, type PreflightIssue, type PreflightManifest } from './capabilities';
2
+ export declare function checkImmutableRelease({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }: {
3
+ manifest: PreflightManifest;
4
+ capabilities: ManagedFunctionCapabilities | null;
5
+ tooling: CapabilityTooling;
6
+ cliVersion: string;
7
+ sdkVersion: string | null;
8
+ checkDeployment: boolean;
9
+ issues: PreflightIssue[];
10
+ }): void;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkImmutableRelease = checkImmutableRelease;
4
+ const capabilities_1 = require("./capabilities");
5
+ const preflight_issue_1 = require("./preflight-issue");
6
+ const immutable_release_contract_1 = require("./immutable-release-contract");
7
+ const sdk_range_1 = require("./sdk-range");
8
+ function checkImmutableRelease({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }) {
9
+ const declaration = manifest.function?.immutable_release;
10
+ if (declaration === undefined || declaration === false)
11
+ return;
12
+ const deployed = capabilities?.features.immutable_release;
13
+ const feature = deployed ?? capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features.immutable_release;
14
+ const details = {
15
+ field: 'function.immutable_release', limit: feature.limit, tooling,
16
+ requiredCli: feature.min_cli, requiredSdk: feature.min_sdk, cliVersion, sdkVersion,
17
+ };
18
+ if (!immutable_release_contract_1.functionImmutableReleaseSchema.safeParse(declaration).success) {
19
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details, problem: 'must be a boolean' }));
20
+ return;
21
+ }
22
+ if (checkDeployment && deployed?.supported !== true) {
23
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details,
24
+ problem: 'Immutable function releases are not supported by this deployment',
25
+ }));
26
+ return;
27
+ }
28
+ if ((0, capabilities_1.versionIsOlder)(cliVersion, feature.min_cli) ||
29
+ (sdkVersion && (0, sdk_range_1.sdkConstraintIsOlder)(sdkVersion, feature.min_sdk))) {
30
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details,
31
+ problem: 'the installed tooling does not support immutable function releases',
32
+ }));
33
+ }
34
+ }
@@ -0,0 +1,10 @@
1
+ import { type CapabilityTooling, type ManagedFunctionCapabilities, type PreflightIssue, type PreflightManifest } from './capabilities';
2
+ export declare function checkInvocationIdentity({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }: {
3
+ manifest: PreflightManifest;
4
+ capabilities: ManagedFunctionCapabilities | null;
5
+ tooling: CapabilityTooling;
6
+ cliVersion: string;
7
+ sdkVersion: string | null;
8
+ checkDeployment: boolean;
9
+ issues: PreflightIssue[];
10
+ }): void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkInvocationIdentity = checkInvocationIdentity;
4
+ const capabilities_1 = require("./capabilities");
5
+ const invocation_contract_1 = require("./invocation-contract");
6
+ const preflight_issue_1 = require("./preflight-issue");
7
+ const sdk_range_1 = require("./sdk-range");
8
+ function checkInvocationIdentity({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }) {
9
+ const invocation = manifest.capabilities?.invocation;
10
+ if (invocation === undefined)
11
+ return;
12
+ const deployed = capabilities?.features.invocation_identity;
13
+ const feature = deployed ?? capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features.invocation_identity;
14
+ const details = {
15
+ limit: feature.limit, tooling, requiredCli: feature.min_cli,
16
+ requiredSdk: feature.min_sdk, cliVersion, sdkVersion,
17
+ };
18
+ const parsed = invocation_contract_1.functionInvocationIdentityCapabilitySchema.safeParse(invocation);
19
+ if (!parsed.success) {
20
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
21
+ ...details, field: 'capabilities.invocation',
22
+ problem: (0, capabilities_1.formatValidationDetail)(parsed.error.issues),
23
+ }));
24
+ return;
25
+ }
26
+ if (checkDeployment && deployed?.supported !== true) {
27
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
28
+ ...details, field: feature.field,
29
+ problem: 'Invocation identity reads are not supported by this deployment',
30
+ }));
31
+ return;
32
+ }
33
+ if ((0, capabilities_1.versionIsOlder)(cliVersion, feature.min_cli) ||
34
+ (sdkVersion && (0, sdk_range_1.sdkConstraintIsOlder)(sdkVersion, feature.min_sdk))) {
35
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
36
+ ...details, field: feature.field,
37
+ problem: 'the installed tooling does not support managed function invocation identity reads',
38
+ }));
39
+ }
40
+ }
@@ -0,0 +1,10 @@
1
+ import { type CapabilityTooling, type ManagedFunctionCapabilities, type PreflightIssue, type PreflightManifest } from './capabilities';
2
+ export declare function checkLatticeContext({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }: {
3
+ manifest: PreflightManifest;
4
+ capabilities: ManagedFunctionCapabilities | null;
5
+ tooling: CapabilityTooling;
6
+ cliVersion: string;
7
+ sdkVersion: string | null;
8
+ checkDeployment: boolean;
9
+ issues: PreflightIssue[];
10
+ }): void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkLatticeContext = checkLatticeContext;
4
+ const capabilities_1 = require("./capabilities");
5
+ const lattice_capability_1 = require("./lattice-capability");
6
+ const preflight_issue_1 = require("./preflight-issue");
7
+ const sdk_range_1 = require("./sdk-range");
8
+ function checkLatticeContext({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }) {
9
+ const lattice = manifest.capabilities?.lattice;
10
+ if (lattice === undefined)
11
+ return;
12
+ const deployed = capabilities?.features.lattice_context;
13
+ const feature = deployed ?? capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features.lattice_context;
14
+ const details = {
15
+ limit: feature.limit, tooling, requiredCli: feature.min_cli,
16
+ requiredSdk: feature.min_sdk, cliVersion, sdkVersion,
17
+ };
18
+ const parsed = lattice_capability_1.functionLatticeContextCapabilitySchema.safeParse(lattice);
19
+ if (!parsed.success) {
20
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
21
+ ...details, field: 'capabilities.lattice',
22
+ problem: (0, capabilities_1.formatValidationDetail)(parsed.error.issues),
23
+ }));
24
+ return;
25
+ }
26
+ if (checkDeployment && deployed?.supported !== true) {
27
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
28
+ ...details, field: feature.field,
29
+ problem: 'Lattice execution context reads are not supported by this deployment',
30
+ }));
31
+ return;
32
+ }
33
+ if ((0, capabilities_1.versionIsOlder)(cliVersion, feature.min_cli) ||
34
+ (sdkVersion && (0, sdk_range_1.sdkConstraintIsOlder)(sdkVersion, feature.min_sdk))) {
35
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
36
+ ...details, field: feature.field,
37
+ problem: 'the installed tooling does not support managed function Lattice context reads',
38
+ }));
39
+ }
40
+ }
@@ -0,0 +1,10 @@
1
+ import { type CapabilityTooling, type ManagedFunctionCapabilities, type PreflightIssue, type PreflightManifest } from './capabilities';
2
+ export declare function checkMonitoring({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }: {
3
+ manifest: PreflightManifest;
4
+ capabilities: ManagedFunctionCapabilities | null;
5
+ tooling: CapabilityTooling;
6
+ cliVersion: string;
7
+ sdkVersion: string | null;
8
+ checkDeployment: boolean;
9
+ issues: PreflightIssue[];
10
+ }): void;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkMonitoring = checkMonitoring;
4
+ const capabilities_1 = require("./capabilities");
5
+ const preflight_issue_1 = require("./preflight-issue");
6
+ const monitoring_contract_1 = require("./monitoring-contract");
7
+ const sdk_range_1 = require("./sdk-range");
8
+ function checkMonitoring({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }) {
9
+ const monitoring = manifest.capabilities?.monitoring;
10
+ if (monitoring === undefined)
11
+ return;
12
+ const deployedFeature = capabilities?.features.monitoring_deliveries;
13
+ const feature = deployedFeature ?? capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features.monitoring_deliveries;
14
+ const details = {
15
+ limit: feature.limit,
16
+ tooling,
17
+ requiredCli: feature.min_cli,
18
+ requiredSdk: feature.min_sdk,
19
+ cliVersion,
20
+ sdkVersion,
21
+ };
22
+ const parsed = monitoring_contract_1.functionMonitoringScopesSchema.safeParse(monitoring);
23
+ if (!parsed.success) {
24
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
25
+ ...details,
26
+ field: 'capabilities.monitoring',
27
+ problem: (0, capabilities_1.formatValidationDetail)(parsed.error.issues),
28
+ }));
29
+ return;
30
+ }
31
+ if (checkDeployment && deployedFeature?.supported !== true) {
32
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
33
+ ...details,
34
+ field: feature.field,
35
+ problem: 'monitoring deliveries are not supported by this deployment',
36
+ }));
37
+ return;
38
+ }
39
+ if ((0, capabilities_1.versionIsOlder)(cliVersion, feature.min_cli) || (sdkVersion && (0, sdk_range_1.sdkConstraintIsOlder)(sdkVersion, feature.min_sdk))) {
40
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
41
+ ...details,
42
+ field: feature.field,
43
+ problem: 'the installed tooling does not support managed function monitoring deliveries',
44
+ }));
45
+ }
46
+ }
@@ -0,0 +1,10 @@
1
+ import { type CapabilityTooling, type ManagedFunctionCapabilities, type PreflightIssue, type PreflightManifest } from './capabilities';
2
+ export declare function checkDirectory({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues }: {
3
+ manifest: PreflightManifest;
4
+ capabilities: ManagedFunctionCapabilities | null;
5
+ tooling: CapabilityTooling;
6
+ cliVersion: string;
7
+ sdkVersion: string | null;
8
+ checkDeployment: boolean;
9
+ issues: PreflightIssue[];
10
+ }): void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkDirectory = checkDirectory;
4
+ const capabilities_1 = require("./capabilities");
5
+ const preflight_issue_1 = require("./preflight-issue");
6
+ const directory_contract_1 = require("./directory-contract");
7
+ const sdk_range_1 = require("./sdk-range");
8
+ function checkDirectory({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues }) {
9
+ const directory = manifest.capabilities?.directory;
10
+ if (directory === undefined)
11
+ return;
12
+ const deployed = capabilities?.features.directory_resolve;
13
+ const feature = deployed ?? capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features.directory_resolve;
14
+ const details = { limit: feature.limit, tooling, requiredCli: feature.min_cli, requiredSdk: feature.min_sdk, cliVersion, sdkVersion };
15
+ const parsed = directory_contract_1.functionDirectoryScopesSchema.safeParse(directory);
16
+ if (!parsed.success) {
17
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details, field: 'capabilities.directory', problem: (0, capabilities_1.formatValidationDetail)(parsed.error.issues) }));
18
+ return;
19
+ }
20
+ if (checkDeployment && deployed?.supported !== true) {
21
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details, field: feature.field, problem: 'exact directory resolution is not supported by this deployment' }));
22
+ return;
23
+ }
24
+ if ((0, capabilities_1.versionIsOlder)(cliVersion, feature.min_cli) || (sdkVersion && (0, sdk_range_1.sdkConstraintIsOlder)(sdkVersion, feature.min_sdk)))
25
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details, field: feature.field, problem: 'the installed tooling does not support managed function directory resolution' }));
26
+ }
@@ -0,0 +1,10 @@
1
+ import { type CapabilityTooling, type ManagedFunctionCapabilities, type PreflightIssue, type PreflightManifest } from './capabilities';
2
+ export declare function checkWorkflows({ manifest, capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues, }: {
3
+ manifest: PreflightManifest;
4
+ capabilities: ManagedFunctionCapabilities | null;
5
+ tooling: CapabilityTooling;
6
+ cliVersion: string;
7
+ sdkVersion: string | null;
8
+ checkDeployment: boolean;
9
+ issues: PreflightIssue[];
10
+ }): void;