@inf-monkeys-tech/monkeys 1.1.23 → 1.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/lib/contracts/declarative-control-http.d.ts +148 -0
- package/lib/contracts/declarative-control-http.d.ts.map +1 -1
- package/lib/contracts/declarative-control.d.ts +31 -0
- package/lib/contracts/declarative-control.d.ts.map +1 -1
- package/lib/contracts/declarative-control.js +6 -0
- package/lib/contracts/declarative-control.js.map +1 -1
- package/lib/contracts/declarative-document-import.d.ts +25 -0
- package/lib/contracts/declarative-document-import.d.ts.map +1 -1
- package/lib/contracts/declarative-publication-job.d.ts +16 -0
- package/lib/contracts/declarative-publication-job.d.ts.map +1 -1
- package/lib/esm/chunk-4H5MD2LH.mjs +7280 -0
- package/lib/esm/chunk-4H5MD2LH.mjs.map +1 -0
- package/lib/esm/chunk-4ZSCTEY6.mjs +1009 -0
- package/lib/esm/chunk-4ZSCTEY6.mjs.map +1 -0
- package/lib/esm/chunk-H7J4XGXK.mjs +159 -0
- package/lib/esm/chunk-H7J4XGXK.mjs.map +1 -0
- package/lib/esm/chunk-KRIKORSN.mjs +20328 -0
- package/lib/esm/chunk-KRIKORSN.mjs.map +1 -0
- package/lib/esm/chunk-X4YQITI2.mjs +205 -0
- package/lib/esm/chunk-X4YQITI2.mjs.map +1 -0
- package/lib/esm/chunk-YKM3R2KZ.mjs +78 -0
- package/lib/esm/chunk-YKM3R2KZ.mjs.map +1 -0
- package/lib/esm/contracts/index.mjs +585 -20882
- package/lib/esm/contracts/index.mjs.map +1 -1
- package/lib/esm/index.mjs +765 -27862
- package/lib/esm/index.mjs.map +1 -1
- package/lib/esm/runtime/index.mjs +144 -26550
- package/lib/esm/runtime/index.mjs.map +1 -1
- package/lib/esm/schemas/index.mjs +352 -20670
- package/lib/esm/schemas/index.mjs.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/json-schema/page-runtime-bundle.schema.json +15 -0
- package/lib/json-schema/page.schema.json +15 -0
- package/lib/runtime/declarative-control-compiler.d.ts.map +1 -1
- package/lib/runtime/declarative-control-compiler.js +2 -0
- package/lib/runtime/declarative-control-compiler.js.map +1 -1
- package/lib/runtime/declarative-runtime-contract.d.ts +1 -1
- package/lib/runtime/declarative-runtime-contract.d.ts.map +1 -1
- package/lib/runtime/declarative-runtime-contract.js +50 -3
- package/lib/runtime/declarative-runtime-contract.js.map +1 -1
- package/lib/runtime/index.d.ts +2 -0
- package/lib/runtime/index.d.ts.map +1 -1
- package/lib/runtime/index.js +2 -0
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/page-composition.d.ts +35 -0
- package/lib/runtime/page-composition.d.ts.map +1 -0
- package/lib/runtime/page-composition.js +107 -0
- package/lib/runtime/page-composition.js.map +1 -0
- package/lib/runtime/runtime-definition-wire.d.ts +8275 -0
- package/lib/runtime/runtime-definition-wire.d.ts.map +1 -0
- package/lib/runtime/runtime-definition-wire.js +111 -0
- package/lib/runtime/runtime-definition-wire.js.map +1 -0
- package/lib/schemas/index.d.ts +14 -0
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/theme-tokens/core.d.ts.map +1 -1
- package/lib/theme-tokens/core.js +16 -8
- package/lib/theme-tokens/core.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,1009 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ContractIdentifierSchema,
|
|
3
|
+
ContractVersionSchema,
|
|
4
|
+
DeclarativeDiagnosticSchema,
|
|
5
|
+
EntityRefSchema,
|
|
6
|
+
IsoDateTimeSchema,
|
|
7
|
+
JsonObjectSchema,
|
|
8
|
+
JsonValueSchema,
|
|
9
|
+
LineageRecordSchema,
|
|
10
|
+
NavigationSchema,
|
|
11
|
+
PageSchema,
|
|
12
|
+
ProductSurfaceSchema,
|
|
13
|
+
RevisionRefSchema,
|
|
14
|
+
Sha256Schema,
|
|
15
|
+
TenantScopeSchema
|
|
16
|
+
} from "./chunk-KRIKORSN.mjs";
|
|
17
|
+
|
|
18
|
+
// src/contracts/artifact.ts
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
var StorageLocatorSchema = z.object({
|
|
21
|
+
provider: ContractIdentifierSchema,
|
|
22
|
+
bucket: ContractIdentifierSchema.optional(),
|
|
23
|
+
key: ContractIdentifierSchema,
|
|
24
|
+
region: ContractIdentifierSchema.optional(),
|
|
25
|
+
url: z.string().url().optional(),
|
|
26
|
+
expiresAt: IsoDateTimeSchema.optional()
|
|
27
|
+
}).strict();
|
|
28
|
+
var ArtifactAccessSchema = z.object({
|
|
29
|
+
tenantId: ContractIdentifierSchema.optional(),
|
|
30
|
+
teamId: ContractIdentifierSchema.optional(),
|
|
31
|
+
ownerRef: EntityRefSchema.optional(),
|
|
32
|
+
visibility: z.enum(["private", "team", "tenant", "public"])
|
|
33
|
+
}).strict();
|
|
34
|
+
var ArtifactManifestSchema = z.object({
|
|
35
|
+
contract: z.literal("ArtifactManifest"),
|
|
36
|
+
artifactId: ContractIdentifierSchema,
|
|
37
|
+
kind: ContractIdentifierSchema,
|
|
38
|
+
mimeType: z.string().trim().min(1),
|
|
39
|
+
byteSize: z.number().int().nonnegative().optional(),
|
|
40
|
+
sha256: Sha256Schema,
|
|
41
|
+
storage: StorageLocatorSchema,
|
|
42
|
+
sourceRef: EntityRefSchema.optional(),
|
|
43
|
+
runRef: EntityRefSchema,
|
|
44
|
+
outputRef: EntityRefSchema,
|
|
45
|
+
producer: z.object({
|
|
46
|
+
service: ContractIdentifierSchema,
|
|
47
|
+
version: ContractIdentifierSchema,
|
|
48
|
+
capabilityRef: EntityRefSchema.optional()
|
|
49
|
+
}).strict(),
|
|
50
|
+
access: ArtifactAccessSchema,
|
|
51
|
+
metadata: z.record(z.string(), JsonValueSchema).default({}),
|
|
52
|
+
createdAt: IsoDateTimeSchema
|
|
53
|
+
}).strict();
|
|
54
|
+
var OutputRecordSchema = z.object({
|
|
55
|
+
contract: z.literal("OutputRecord"),
|
|
56
|
+
outputId: ContractIdentifierSchema,
|
|
57
|
+
runRef: EntityRefSchema,
|
|
58
|
+
outputPort: ContractIdentifierSchema,
|
|
59
|
+
value: JsonValueSchema.optional(),
|
|
60
|
+
artifactRefs: z.array(EntityRefSchema).default([]),
|
|
61
|
+
schemaRef: ContractIdentifierSchema.optional(),
|
|
62
|
+
createdAt: IsoDateTimeSchema
|
|
63
|
+
}).strict();
|
|
64
|
+
|
|
65
|
+
// src/contracts/aggregate-commit.ts
|
|
66
|
+
import { z as z2 } from "zod";
|
|
67
|
+
var AggregateIdentifierSchema = z2.string().trim().min(1).max(128);
|
|
68
|
+
var AggregateRequestIdentifierSchema = z2.string().trim().min(1).max(256);
|
|
69
|
+
var AggregateMutationsLimit = 500;
|
|
70
|
+
var AggregateAssetSchema = z2.object({
|
|
71
|
+
id: AggregateIdentifierSchema,
|
|
72
|
+
name: z2.string().trim().min(1).max(500),
|
|
73
|
+
asset_type: AggregateIdentifierSchema,
|
|
74
|
+
primary_content: JsonObjectSchema,
|
|
75
|
+
status: z2.string().trim().min(1).max(64).optional(),
|
|
76
|
+
creator_user_id: AggregateIdentifierSchema.optional(),
|
|
77
|
+
properties: JsonObjectSchema.optional(),
|
|
78
|
+
files: z2.array(JsonObjectSchema).max(100).optional(),
|
|
79
|
+
media: z2.string().max(4096).optional(),
|
|
80
|
+
thumbnail: z2.string().max(4096).optional(),
|
|
81
|
+
media_ref: JsonObjectSchema.optional(),
|
|
82
|
+
keywords: z2.string().max(2e3).optional(),
|
|
83
|
+
extra: JsonObjectSchema.optional(),
|
|
84
|
+
sort: z2.number().int().nonnegative().optional()
|
|
85
|
+
}).strict();
|
|
86
|
+
var AggregateAssetUpsertSchema = z2.object({
|
|
87
|
+
ontology_id: AggregateIdentifierSchema,
|
|
88
|
+
asset: AggregateAssetSchema,
|
|
89
|
+
tag_ids: z2.array(AggregateIdentifierSchema).max(200).optional()
|
|
90
|
+
}).strict();
|
|
91
|
+
var AggregateAssetDeleteSchema = z2.object({
|
|
92
|
+
ontology_id: AggregateIdentifierSchema,
|
|
93
|
+
asset_id: AggregateIdentifierSchema
|
|
94
|
+
}).strict();
|
|
95
|
+
var AggregateFeatureValueWriteSchema = z2.object({
|
|
96
|
+
ontology_id: AggregateIdentifierSchema,
|
|
97
|
+
asset_id: AggregateIdentifierSchema,
|
|
98
|
+
column_id: AggregateIdentifierSchema,
|
|
99
|
+
value_text: z2.string().max(1e6).nullable()
|
|
100
|
+
}).strict();
|
|
101
|
+
var AggregateFeatureRelationTargetSchema = z2.object({
|
|
102
|
+
ontology_id: AggregateIdentifierSchema,
|
|
103
|
+
asset_id: AggregateIdentifierSchema
|
|
104
|
+
}).strict();
|
|
105
|
+
var AggregateFeatureRelationReplaceSchema = z2.object({
|
|
106
|
+
ontology_id: AggregateIdentifierSchema,
|
|
107
|
+
asset_id: AggregateIdentifierSchema,
|
|
108
|
+
column_id: AggregateIdentifierSchema,
|
|
109
|
+
targets: z2.array(AggregateFeatureRelationTargetSchema).max(AggregateMutationsLimit)
|
|
110
|
+
}).strict();
|
|
111
|
+
var AggregateAssetRelationObjectSchema = z2.object({
|
|
112
|
+
object_kind: z2.string().trim().min(1).max(64),
|
|
113
|
+
object_id: z2.string().trim().min(1).max(256),
|
|
114
|
+
properties: JsonObjectSchema.optional()
|
|
115
|
+
}).strict();
|
|
116
|
+
var AggregateAssetRelationReplaceSchema = z2.object({
|
|
117
|
+
ontology_id: AggregateIdentifierSchema,
|
|
118
|
+
asset_id: AggregateIdentifierSchema,
|
|
119
|
+
relation_kind: z2.string().trim().min(1).max(64),
|
|
120
|
+
objects: z2.array(AggregateAssetRelationObjectSchema).max(AggregateMutationsLimit)
|
|
121
|
+
}).strict();
|
|
122
|
+
var AggregateContainerMembershipWriteSchema = z2.object({
|
|
123
|
+
ontology_id: AggregateIdentifierSchema,
|
|
124
|
+
container_view_id: AggregateIdentifierSchema,
|
|
125
|
+
asset_id: AggregateIdentifierSchema,
|
|
126
|
+
present: z2.boolean()
|
|
127
|
+
}).strict();
|
|
128
|
+
var AggregateCommitRequestSchema = z2.object({
|
|
129
|
+
contract: z2.literal("AggregateCommitRequest"),
|
|
130
|
+
aggregate_id: AggregateIdentifierSchema,
|
|
131
|
+
request_id: AggregateRequestIdentifierSchema,
|
|
132
|
+
idempotency_key: AggregateIdentifierSchema,
|
|
133
|
+
expected_head_commit_id: AggregateIdentifierSchema.optional(),
|
|
134
|
+
message: z2.string().trim().max(500).optional(),
|
|
135
|
+
assets: z2.array(AggregateAssetUpsertSchema).max(AggregateMutationsLimit).optional(),
|
|
136
|
+
asset_deletes: z2.array(AggregateAssetDeleteSchema).max(AggregateMutationsLimit).optional(),
|
|
137
|
+
feature_values: z2.array(AggregateFeatureValueWriteSchema).max(AggregateMutationsLimit).optional(),
|
|
138
|
+
feature_relations: z2.array(AggregateFeatureRelationReplaceSchema).max(AggregateMutationsLimit).optional(),
|
|
139
|
+
asset_relations: z2.array(AggregateAssetRelationReplaceSchema).max(AggregateMutationsLimit).optional(),
|
|
140
|
+
container_memberships: z2.array(AggregateContainerMembershipWriteSchema).max(AggregateMutationsLimit).optional()
|
|
141
|
+
}).strict().superRefine((request, context) => {
|
|
142
|
+
const mutationCount = (request.assets?.length ?? 0) + (request.asset_deletes?.length ?? 0) + (request.feature_values?.length ?? 0) + (request.feature_relations?.length ?? 0) + (request.asset_relations?.length ?? 0) + (request.container_memberships?.length ?? 0);
|
|
143
|
+
if (mutationCount === 0) {
|
|
144
|
+
context.addIssue({ code: "custom", message: "at least one aggregate mutation is required" });
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// src/contracts/context.ts
|
|
149
|
+
import { z as z3 } from "zod";
|
|
150
|
+
var ActorRefSchema = z3.object({
|
|
151
|
+
kind: z3.enum(["human", "agent", "service", "tenant", "public"]),
|
|
152
|
+
id: ContractIdentifierSchema.optional(),
|
|
153
|
+
userId: ContractIdentifierSchema.optional(),
|
|
154
|
+
agentId: ContractIdentifierSchema.optional(),
|
|
155
|
+
serviceId: ContractIdentifierSchema.optional()
|
|
156
|
+
}).strict();
|
|
157
|
+
var AuthorityScopeSchema = z3.object({
|
|
158
|
+
resource: ContractIdentifierSchema,
|
|
159
|
+
actions: z3.array(ContractIdentifierSchema).min(1),
|
|
160
|
+
constraints: z3.record(z3.string(), JsonValueSchema).optional()
|
|
161
|
+
}).strict();
|
|
162
|
+
var RequestScopeSchema = z3.object({
|
|
163
|
+
contract: z3.literal("RequestScope"),
|
|
164
|
+
requestId: ContractIdentifierSchema,
|
|
165
|
+
traceId: ContractIdentifierSchema.optional(),
|
|
166
|
+
appId: ContractIdentifierSchema,
|
|
167
|
+
tenantId: ContractIdentifierSchema.optional(),
|
|
168
|
+
teamId: ContractIdentifierSchema.optional(),
|
|
169
|
+
actor: ActorRefSchema,
|
|
170
|
+
session: z3.object({
|
|
171
|
+
authType: ContractIdentifierSchema,
|
|
172
|
+
authenticated: z3.boolean(),
|
|
173
|
+
membershipVerified: z3.boolean()
|
|
174
|
+
}).strict(),
|
|
175
|
+
permissionCodes: z3.array(ContractIdentifierSchema).default([]),
|
|
176
|
+
authority: z3.array(AuthorityScopeSchema).default([]),
|
|
177
|
+
issuedAt: IsoDateTimeSchema
|
|
178
|
+
}).strict();
|
|
179
|
+
var ExecutionLinkSchema = z3.object({
|
|
180
|
+
contract: z3.literal("ExecutionLink"),
|
|
181
|
+
requestId: ContractIdentifierSchema,
|
|
182
|
+
traceId: ContractIdentifierSchema.optional(),
|
|
183
|
+
correlationId: ContractIdentifierSchema.optional(),
|
|
184
|
+
causationId: ContractIdentifierSchema.optional(),
|
|
185
|
+
workflowRef: EntityRefSchema.optional(),
|
|
186
|
+
runRef: EntityRefSchema,
|
|
187
|
+
taskRef: EntityRefSchema.optional(),
|
|
188
|
+
parentRunRef: EntityRefSchema.optional()
|
|
189
|
+
}).strict();
|
|
190
|
+
var CompletionHeaderSchema = z3.object({
|
|
191
|
+
contract: z3.literal("CompletionHeader"),
|
|
192
|
+
eventId: ContractIdentifierSchema,
|
|
193
|
+
runtimeEventId: ContractIdentifierSchema,
|
|
194
|
+
idempotencyKey: ContractIdentifierSchema,
|
|
195
|
+
sequence: z3.number().int().nonnegative(),
|
|
196
|
+
execution: ExecutionLinkSchema,
|
|
197
|
+
producer: z3.object({
|
|
198
|
+
service: ContractIdentifierSchema,
|
|
199
|
+
runtime: ContractIdentifierSchema,
|
|
200
|
+
version: ContractIdentifierSchema
|
|
201
|
+
}).strict(),
|
|
202
|
+
status: z3.enum(["SUCCEEDED", "FAILED", "CANCELLED", "TIMED_OUT"]),
|
|
203
|
+
occurredAt: IsoDateTimeSchema,
|
|
204
|
+
payloadSchemaRef: ContractIdentifierSchema.optional()
|
|
205
|
+
}).strict();
|
|
206
|
+
var CompletionEventSchema = z3.object({
|
|
207
|
+
header: CompletionHeaderSchema,
|
|
208
|
+
payload: JsonValueSchema.optional()
|
|
209
|
+
}).strict();
|
|
210
|
+
var AgentRuntimeEventSchema = z3.object({
|
|
211
|
+
contract: z3.literal("AgentRuntimeEvent"),
|
|
212
|
+
runtimeEventId: ContractIdentifierSchema,
|
|
213
|
+
streamId: ContractIdentifierSchema,
|
|
214
|
+
sequence: z3.number().int().nonnegative(),
|
|
215
|
+
requestId: ContractIdentifierSchema,
|
|
216
|
+
teamId: ContractIdentifierSchema,
|
|
217
|
+
threadId: ContractIdentifierSchema.optional(),
|
|
218
|
+
eventType: z3.enum(["messages:append", "messages:update", "thread:update", "tool-call:upsert", "session:event"]),
|
|
219
|
+
payload: JsonValueSchema,
|
|
220
|
+
occurredAt: IsoDateTimeSchema
|
|
221
|
+
}).strict();
|
|
222
|
+
|
|
223
|
+
// src/contracts/continuity.ts
|
|
224
|
+
import { z as z4 } from "zod";
|
|
225
|
+
var DataContinuityEnvelopeSchema = z4.object({
|
|
226
|
+
contract: z4.literal("DataContinuityEnvelope"),
|
|
227
|
+
tenantId: ContractIdentifierSchema,
|
|
228
|
+
teamId: ContractIdentifierSchema,
|
|
229
|
+
sourceRef: EntityRefSchema.optional(),
|
|
230
|
+
bodyRef: EntityRefSchema.optional(),
|
|
231
|
+
runRef: EntityRefSchema.optional(),
|
|
232
|
+
outputRef: EntityRefSchema.optional(),
|
|
233
|
+
artifactRef: EntityRefSchema.optional(),
|
|
234
|
+
requestId: ContractIdentifierSchema,
|
|
235
|
+
actorRef: EntityRefSchema,
|
|
236
|
+
schemaVersion: ContractVersionSchema
|
|
237
|
+
}).strict().refine(
|
|
238
|
+
(value) => Boolean(value.sourceRef || value.bodyRef || value.runRef || value.outputRef || value.artifactRef),
|
|
239
|
+
"At least one continuity ref is required."
|
|
240
|
+
);
|
|
241
|
+
var BodyRelationRecordSchema = z4.object({
|
|
242
|
+
contract: z4.literal("BodyRelationRecord"),
|
|
243
|
+
relationId: ContractIdentifierSchema,
|
|
244
|
+
relationKind: ContractIdentifierSchema,
|
|
245
|
+
subjectRef: EntityRefSchema,
|
|
246
|
+
objectRef: EntityRefSchema,
|
|
247
|
+
ownerRepo: ContractIdentifierSchema,
|
|
248
|
+
authorityScope: z4.enum(["tenant", "team", "global"]),
|
|
249
|
+
properties: JsonObjectSchema.default({}),
|
|
250
|
+
createdAt: IsoDateTimeSchema,
|
|
251
|
+
updatedAt: IsoDateTimeSchema
|
|
252
|
+
}).strict();
|
|
253
|
+
var ApplicationRunSchema = z4.object({
|
|
254
|
+
contract: z4.literal("ApplicationRun"),
|
|
255
|
+
runId: ContractIdentifierSchema,
|
|
256
|
+
definitionRef: EntityRefSchema,
|
|
257
|
+
runtimeLedgerRef: EntityRefSchema.optional(),
|
|
258
|
+
requestId: ContractIdentifierSchema,
|
|
259
|
+
actorRef: EntityRefSchema,
|
|
260
|
+
status: z4.enum(["PENDING", "RUNNING", "COMPLETED", "FAILED", "CANCELLED", "EXPIRED"]),
|
|
261
|
+
inputRefs: z4.array(EntityRefSchema).default([]),
|
|
262
|
+
outputRefs: z4.array(EntityRefSchema).default([]),
|
|
263
|
+
startedAt: IsoDateTimeSchema.optional(),
|
|
264
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
265
|
+
expiresAt: IsoDateTimeSchema.optional(),
|
|
266
|
+
metadata: JsonObjectSchema.default({})
|
|
267
|
+
}).strict().superRefine((run, context) => {
|
|
268
|
+
if (run.definitionRef.kind !== "workflow-definition") {
|
|
269
|
+
context.addIssue({
|
|
270
|
+
code: "custom",
|
|
271
|
+
path: ["definitionRef", "kind"],
|
|
272
|
+
message: "definitionRef must reference a workflow-definition."
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (run.runtimeLedgerRef && run.runtimeLedgerRef.kind !== "workflow-run") {
|
|
276
|
+
context.addIssue({
|
|
277
|
+
code: "custom",
|
|
278
|
+
path: ["runtimeLedgerRef", "kind"],
|
|
279
|
+
message: "runtimeLedgerRef must reference a workflow-run."
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
if ((run.status === "RUNNING" || run.status === "COMPLETED" || run.status === "CANCELLED") && !run.runtimeLedgerRef) {
|
|
283
|
+
context.addIssue({
|
|
284
|
+
code: "custom",
|
|
285
|
+
path: ["runtimeLedgerRef"],
|
|
286
|
+
message: `${run.status} ApplicationRun requires runtimeLedgerRef.`
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
if (run.status === "RUNNING" && !run.startedAt) {
|
|
290
|
+
context.addIssue({
|
|
291
|
+
code: "custom",
|
|
292
|
+
path: ["startedAt"],
|
|
293
|
+
message: "RUNNING ApplicationRun requires startedAt."
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
if (["COMPLETED", "FAILED", "CANCELLED", "EXPIRED"].includes(run.status) && !run.completedAt) {
|
|
297
|
+
context.addIssue({
|
|
298
|
+
code: "custom",
|
|
299
|
+
path: ["completedAt"],
|
|
300
|
+
message: `Terminal ApplicationRun status ${run.status} requires completedAt.`
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
var ExpiringAccessGrantSchema = z4.object({
|
|
305
|
+
contract: z4.literal("ExpiringAccessGrant"),
|
|
306
|
+
grantId: ContractIdentifierSchema,
|
|
307
|
+
subjectRef: EntityRefSchema,
|
|
308
|
+
resourceRef: EntityRefSchema,
|
|
309
|
+
permissions: z4.array(ContractIdentifierSchema).min(1),
|
|
310
|
+
issuedAt: IsoDateTimeSchema,
|
|
311
|
+
expiresAt: IsoDateTimeSchema,
|
|
312
|
+
revokedAt: IsoDateTimeSchema.optional()
|
|
313
|
+
}).strict().refine((value) => Date.parse(value.expiresAt) > Date.parse(value.issuedAt), "expiresAt must be after issuedAt");
|
|
314
|
+
|
|
315
|
+
// src/contracts/declarative-document-import.ts
|
|
316
|
+
import { z as z5 } from "zod";
|
|
317
|
+
var sameScope = (left, right) => ["tenantRef", "dataSpaceRef", "teamRef"].every(
|
|
318
|
+
(key) => left[key]?.kind === right[key]?.kind && left[key]?.id === right[key]?.id && left[key]?.ownerRepo === right[key]?.ownerRepo
|
|
319
|
+
);
|
|
320
|
+
var DeclarativeImportDocumentSchema = z5.union([
|
|
321
|
+
PageSchema,
|
|
322
|
+
NavigationSchema
|
|
323
|
+
]);
|
|
324
|
+
var requestShape = {
|
|
325
|
+
document: DeclarativeImportDocumentSchema,
|
|
326
|
+
surface: ProductSurfaceSchema,
|
|
327
|
+
environmentId: ContractIdentifierSchema.optional()
|
|
328
|
+
};
|
|
329
|
+
function supportsSurface(value) {
|
|
330
|
+
return value.document.contract === "Page" ? value.document.surface === value.surface : value.document.supportedSurfaces.includes(value.surface);
|
|
331
|
+
}
|
|
332
|
+
var DeclarativeDocumentImportRequestSchema = z5.object(requestShape).strict().refine(supportsSurface, {
|
|
333
|
+
path: ["surface"],
|
|
334
|
+
message: "The document does not support the selected surface."
|
|
335
|
+
});
|
|
336
|
+
var DeclarativeDocumentImportIntentSchema = z5.object({
|
|
337
|
+
...requestShape,
|
|
338
|
+
expectedVersion: z5.number().int().nonnegative(),
|
|
339
|
+
expectedPlanHash: Sha256Schema,
|
|
340
|
+
idempotencyKey: z5.string().trim().min(1).max(256)
|
|
341
|
+
}).strict().refine(supportsSurface, {
|
|
342
|
+
path: ["surface"],
|
|
343
|
+
message: "The document does not support the selected surface."
|
|
344
|
+
});
|
|
345
|
+
var DeclarativeDocumentImportPlanSchema = z5.object({
|
|
346
|
+
contract: z5.literal("DeclarativeDocumentImportPlan"),
|
|
347
|
+
schemaVersion: z5.literal(1),
|
|
348
|
+
resourceKind: z5.enum(["page", "navigation"]),
|
|
349
|
+
resourceId: ContractIdentifierSchema,
|
|
350
|
+
surface: ProductSurfaceSchema,
|
|
351
|
+
sourceContentHash: Sha256Schema,
|
|
352
|
+
environmentRevisionRef: RevisionRefSchema,
|
|
353
|
+
document: DeclarativeImportDocumentSchema,
|
|
354
|
+
tenantScope: TenantScopeSchema.nullable(),
|
|
355
|
+
requiresInitialization: z5.boolean(),
|
|
356
|
+
expectedVersion: z5.number().int().nonnegative(),
|
|
357
|
+
currentContentHash: Sha256Schema.nullable(),
|
|
358
|
+
changed: z5.boolean(),
|
|
359
|
+
diagnostics: z5.array(DeclarativeDiagnosticSchema),
|
|
360
|
+
dependencyContentHash: Sha256Schema,
|
|
361
|
+
planHash: Sha256Schema
|
|
362
|
+
}).strict().superRefine((value, context) => {
|
|
363
|
+
const kind = value.document.contract === "Page" ? "page" : "navigation";
|
|
364
|
+
const id = value.document.contract === "Page" ? value.document.pageId : value.document.navigationId;
|
|
365
|
+
if (kind !== value.resourceKind || id !== value.resourceId || !supportsSurface(value))
|
|
366
|
+
context.addIssue({
|
|
367
|
+
code: "custom",
|
|
368
|
+
path: ["document"],
|
|
369
|
+
message: "The plan must identify its document and supported surface."
|
|
370
|
+
});
|
|
371
|
+
if (value.requiresInitialization !== (value.tenantScope === null))
|
|
372
|
+
context.addIssue({
|
|
373
|
+
code: "custom",
|
|
374
|
+
path: ["requiresInitialization"],
|
|
375
|
+
message: "Only an uninitialized target may omit tenantScope."
|
|
376
|
+
});
|
|
377
|
+
if (value.environmentRevisionRef.kind !== "environment")
|
|
378
|
+
context.addIssue({
|
|
379
|
+
code: "custom",
|
|
380
|
+
path: ["environmentRevisionRef"],
|
|
381
|
+
message: "The import plan must pin an environment revision."
|
|
382
|
+
});
|
|
383
|
+
if (value.tenantScope && !sameScope(value.tenantScope, value.document.tenantScope))
|
|
384
|
+
context.addIssue({
|
|
385
|
+
code: "custom",
|
|
386
|
+
path: ["tenantScope"],
|
|
387
|
+
message: "The plan and bound document must belong to the same scope."
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
var DeclarativeDocumentImportResultSchema = z5.object({
|
|
391
|
+
action: z5.literal("import"),
|
|
392
|
+
changed: z5.boolean(),
|
|
393
|
+
plan: DeclarativeDocumentImportPlanSchema,
|
|
394
|
+
revisionRef: RevisionRefSchema
|
|
395
|
+
}).strict().superRefine((value, context) => {
|
|
396
|
+
if (value.changed !== value.plan.changed || value.revisionRef.kind !== value.plan.resourceKind || value.revisionRef.id !== value.plan.resourceId || value.revisionRef.revision !== value.plan.expectedVersion + Number(value.changed) || !value.revisionRef.tenantScope || !sameScope(value.revisionRef.tenantScope, value.plan.document.tenantScope)) {
|
|
397
|
+
context.addIssue({
|
|
398
|
+
code: "custom",
|
|
399
|
+
path: ["revisionRef"],
|
|
400
|
+
message: "The import result must identify the exact saved or unchanged draft revision."
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// src/contracts/trend.ts
|
|
406
|
+
import { z as z6 } from "zod";
|
|
407
|
+
var RadarDecisionMetricsSchema = z6.object({
|
|
408
|
+
currentSales: z6.number().finite(),
|
|
409
|
+
forecastSales: z6.number().finite(),
|
|
410
|
+
searchHeat: z6.number().finite(),
|
|
411
|
+
socialHeat: z6.number().finite(),
|
|
412
|
+
confidence: z6.number().min(0).max(1)
|
|
413
|
+
}).strict();
|
|
414
|
+
var TrendSourceSchema = z6.object({
|
|
415
|
+
sourceId: ContractIdentifierSchema,
|
|
416
|
+
provider: ContractIdentifierSchema,
|
|
417
|
+
channel: z6.enum(["trend", "ecommerce", "social", "search", "internal"]),
|
|
418
|
+
collectedAt: IsoDateTimeSchema,
|
|
419
|
+
sourceUrl: z6.string().url().optional(),
|
|
420
|
+
evidenceRefs: z6.array(EntityRefSchema).default([])
|
|
421
|
+
}).strict();
|
|
422
|
+
var TrendIngestRunSchema = z6.object({
|
|
423
|
+
contract: z6.literal("TrendIngestRun"),
|
|
424
|
+
ingestRunId: ContractIdentifierSchema,
|
|
425
|
+
sourceId: ContractIdentifierSchema,
|
|
426
|
+
requestId: ContractIdentifierSchema,
|
|
427
|
+
idempotencyKey: ContractIdentifierSchema,
|
|
428
|
+
status: z6.enum(["RUNNING", "SUCCEEDED", "FAILED", "PARTIAL"]),
|
|
429
|
+
recordCount: z6.number().int().nonnegative(),
|
|
430
|
+
errorCount: z6.number().int().nonnegative(),
|
|
431
|
+
startedAt: IsoDateTimeSchema,
|
|
432
|
+
completedAt: IsoDateTimeSchema.optional()
|
|
433
|
+
}).strict();
|
|
434
|
+
var TrendSourceRecordSchema = z6.object({
|
|
435
|
+
contract: z6.literal("TrendSourceRecord"),
|
|
436
|
+
sourceRecordId: ContractIdentifierSchema,
|
|
437
|
+
source: TrendSourceSchema,
|
|
438
|
+
ingestRunRef: EntityRefSchema,
|
|
439
|
+
recordVersion: z6.number().int().positive(),
|
|
440
|
+
contentHash: Sha256Schema,
|
|
441
|
+
payload: JsonValueSchema,
|
|
442
|
+
idempotencyKey: ContractIdentifierSchema,
|
|
443
|
+
collectedAt: IsoDateTimeSchema
|
|
444
|
+
}).strict();
|
|
445
|
+
var HotwordBodySchema = z6.object({
|
|
446
|
+
contract: z6.literal("HotwordBody"),
|
|
447
|
+
hotwordId: ContractIdentifierSchema,
|
|
448
|
+
label: z6.string().trim().min(1),
|
|
449
|
+
normalizedLabel: z6.string().trim().min(1),
|
|
450
|
+
categories: z6.array(ContractIdentifierSchema).default([]),
|
|
451
|
+
sourceRefs: z6.array(TrendSourceSchema).min(1),
|
|
452
|
+
relationRefs: z6.array(EntityRefSchema).default([]),
|
|
453
|
+
createdAt: IsoDateTimeSchema,
|
|
454
|
+
updatedAt: IsoDateTimeSchema
|
|
455
|
+
}).strict();
|
|
456
|
+
var CommerceBodyFieldsSchema = {
|
|
457
|
+
displayName: z6.string().trim().min(1),
|
|
458
|
+
normalizedName: z6.string().trim().min(1),
|
|
459
|
+
categories: z6.array(ContractIdentifierSchema).default([]),
|
|
460
|
+
sourceRefs: z6.array(EntityRefSchema).min(1),
|
|
461
|
+
relationRefs: z6.array(EntityRefSchema).default([]),
|
|
462
|
+
createdAt: IsoDateTimeSchema,
|
|
463
|
+
updatedAt: IsoDateTimeSchema
|
|
464
|
+
};
|
|
465
|
+
var BrandBodySchema = z6.object({
|
|
466
|
+
contract: z6.literal("BrandBody"),
|
|
467
|
+
brandId: ContractIdentifierSchema,
|
|
468
|
+
...CommerceBodyFieldsSchema
|
|
469
|
+
}).strict();
|
|
470
|
+
var ProductBodySchema = z6.object({
|
|
471
|
+
contract: z6.literal("ProductBody"),
|
|
472
|
+
productId: ContractIdentifierSchema,
|
|
473
|
+
brandRef: EntityRefSchema.optional(),
|
|
474
|
+
...CommerceBodyFieldsSchema
|
|
475
|
+
}).strict();
|
|
476
|
+
var TrendMetricSnapshotSchema = z6.object({
|
|
477
|
+
contract: z6.literal("TrendMetricSnapshot"),
|
|
478
|
+
snapshotId: ContractIdentifierSchema,
|
|
479
|
+
subjectRef: EntityRefSchema,
|
|
480
|
+
observedAt: IsoDateTimeSchema,
|
|
481
|
+
metrics: z6.record(z6.string(), z6.number().finite()),
|
|
482
|
+
confidence: z6.number().min(0).max(1),
|
|
483
|
+
evidenceRefs: z6.array(EntityRefSchema).min(1)
|
|
484
|
+
}).strict();
|
|
485
|
+
var RadarScoreModelBodySchema = z6.object({
|
|
486
|
+
contract: z6.literal("RadarScoreModelBody"),
|
|
487
|
+
modelId: ContractIdentifierSchema,
|
|
488
|
+
version: z6.number().int().positive(),
|
|
489
|
+
weights: RadarDecisionMetricsSchema,
|
|
490
|
+
thresholds: z6.record(z6.string(), z6.number().finite()).default({}),
|
|
491
|
+
explanationRules: z6.record(z6.string(), z6.string().trim().min(1)).default({}),
|
|
492
|
+
createdAt: IsoDateTimeSchema
|
|
493
|
+
}).strict();
|
|
494
|
+
var RadarScoreProjectionSchema = z6.object({
|
|
495
|
+
contract: z6.literal("RadarScoreProjection"),
|
|
496
|
+
projectionId: ContractIdentifierSchema,
|
|
497
|
+
subjectRef: EntityRefSchema,
|
|
498
|
+
modelRef: EntityRefSchema,
|
|
499
|
+
totalScore: z6.number().finite(),
|
|
500
|
+
dimensions: RadarDecisionMetricsSchema,
|
|
501
|
+
evidenceRefs: z6.array(EntityRefSchema).min(1),
|
|
502
|
+
freshnessAt: IsoDateTimeSchema
|
|
503
|
+
}).strict();
|
|
504
|
+
var RadarPanoramaNodeSchema = z6.object({
|
|
505
|
+
ref: EntityRefSchema,
|
|
506
|
+
label: z6.string().trim().min(1),
|
|
507
|
+
categories: z6.array(ContractIdentifierSchema).default([]),
|
|
508
|
+
score: z6.number().finite().optional(),
|
|
509
|
+
freshnessAt: IsoDateTimeSchema.optional()
|
|
510
|
+
}).strict();
|
|
511
|
+
var RadarPanoramaEdgeSchema = z6.object({
|
|
512
|
+
sourceRef: EntityRefSchema,
|
|
513
|
+
targetRef: EntityRefSchema,
|
|
514
|
+
relation: ContractIdentifierSchema,
|
|
515
|
+
evidenceRefs: z6.array(EntityRefSchema).default([])
|
|
516
|
+
}).strict();
|
|
517
|
+
var RadarPanoramaSchema = z6.object({
|
|
518
|
+
contract: z6.literal("RadarPanorama"),
|
|
519
|
+
nodes: z6.array(RadarPanoramaNodeSchema),
|
|
520
|
+
edges: z6.array(RadarPanoramaEdgeSchema),
|
|
521
|
+
generatedAt: IsoDateTimeSchema
|
|
522
|
+
}).strict();
|
|
523
|
+
var BrandGeneticsProfileSchema = z6.object({
|
|
524
|
+
contract: z6.literal("BrandGeneticsProfile"),
|
|
525
|
+
brandRef: EntityRefSchema,
|
|
526
|
+
categories: z6.array(ContractIdentifierSchema).default([]),
|
|
527
|
+
signature: z6.record(ContractIdentifierSchema, z6.number().finite()),
|
|
528
|
+
relatedRefs: z6.array(EntityRefSchema).default([]),
|
|
529
|
+
evidenceRefs: z6.array(EntityRefSchema).default([]),
|
|
530
|
+
computedAt: IsoDateTimeSchema
|
|
531
|
+
}).strict();
|
|
532
|
+
var RadarOpportunityMatrixPointSchema = z6.object({
|
|
533
|
+
subjectRef: EntityRefSchema,
|
|
534
|
+
label: z6.string().trim().min(1),
|
|
535
|
+
x: z6.number().finite(),
|
|
536
|
+
y: z6.number().finite(),
|
|
537
|
+
score: z6.number().finite(),
|
|
538
|
+
evidenceRefs: z6.array(EntityRefSchema).default([])
|
|
539
|
+
}).strict();
|
|
540
|
+
var RadarOpportunityMatrixSchema = z6.object({
|
|
541
|
+
contract: z6.literal("RadarOpportunityMatrix"),
|
|
542
|
+
xMetric: z6.enum(["currentSales", "forecastSales", "searchHeat", "socialHeat", "confidence"]),
|
|
543
|
+
yMetric: z6.enum(["currentSales", "forecastSales", "searchHeat", "socialHeat", "confidence"]),
|
|
544
|
+
points: z6.array(RadarOpportunityMatrixPointSchema),
|
|
545
|
+
computedAt: IsoDateTimeSchema
|
|
546
|
+
}).strict();
|
|
547
|
+
var RadarQueryBodySchema = z6.object({
|
|
548
|
+
contract: z6.literal("RadarQueryBody"),
|
|
549
|
+
queryId: ContractIdentifierSchema,
|
|
550
|
+
filters: z6.record(z6.string(), JsonValueSchema).default({}),
|
|
551
|
+
sort: z6.object({
|
|
552
|
+
field: ContractIdentifierSchema,
|
|
553
|
+
direction: z6.enum(["asc", "desc"])
|
|
554
|
+
}).strict(),
|
|
555
|
+
pageSize: z6.number().int().min(1).max(200),
|
|
556
|
+
updatedAt: IsoDateTimeSchema
|
|
557
|
+
}).strict();
|
|
558
|
+
var SavedRadarQuerySchema = z6.object({
|
|
559
|
+
contract: z6.literal("SavedRadarQuery"),
|
|
560
|
+
savedQueryId: ContractIdentifierSchema,
|
|
561
|
+
teamId: ContractIdentifierSchema,
|
|
562
|
+
ownerRef: EntityRefSchema,
|
|
563
|
+
name: z6.string().trim().min(1),
|
|
564
|
+
queryRef: EntityRefSchema,
|
|
565
|
+
expectedVersion: z6.number().int().nonnegative(),
|
|
566
|
+
updatedAt: IsoDateTimeSchema
|
|
567
|
+
}).strict();
|
|
568
|
+
var RadarSelectionSchema = z6.object({
|
|
569
|
+
contract: z6.literal("RadarSelection"),
|
|
570
|
+
selectionId: ContractIdentifierSchema,
|
|
571
|
+
teamId: ContractIdentifierSchema,
|
|
572
|
+
ownerRef: EntityRefSchema,
|
|
573
|
+
subjectRefs: z6.array(EntityRefSchema),
|
|
574
|
+
status: z6.enum(["stashed", "selected", "rejected", "archived"]),
|
|
575
|
+
note: z6.string().optional(),
|
|
576
|
+
expectedVersion: z6.number().int().nonnegative(),
|
|
577
|
+
updatedAt: IsoDateTimeSchema
|
|
578
|
+
}).strict();
|
|
579
|
+
var versionedRefFields = {
|
|
580
|
+
id: ContractIdentifierSchema,
|
|
581
|
+
version: z6.union([z6.number().int().positive(), z6.string().trim().min(1)]).optional(),
|
|
582
|
+
ownerRepo: ContractIdentifierSchema.optional()
|
|
583
|
+
};
|
|
584
|
+
var TrendRadarCollectionAssetRefSchema = z6.object({
|
|
585
|
+
kind: z6.literal("asset"),
|
|
586
|
+
...versionedRefFields
|
|
587
|
+
}).strict();
|
|
588
|
+
var TrendRadarCollectionSelectionRefSchema = z6.object({
|
|
589
|
+
kind: z6.literal("radar-selection"),
|
|
590
|
+
...versionedRefFields
|
|
591
|
+
}).strict();
|
|
592
|
+
var TrendRadarCollectionRunRefSchema = z6.object({
|
|
593
|
+
kind: z6.literal("radar-analysis-run"),
|
|
594
|
+
...versionedRefFields
|
|
595
|
+
}).strict();
|
|
596
|
+
var TrendRadarCollectionSubjectRefSchema = z6.object({
|
|
597
|
+
kind: z6.literal("hotword"),
|
|
598
|
+
...versionedRefFields
|
|
599
|
+
}).strict();
|
|
600
|
+
var TrendRadarCollectionArtifactRefSchema = z6.object({
|
|
601
|
+
kind: z6.literal("artifact"),
|
|
602
|
+
...versionedRefFields
|
|
603
|
+
}).strict();
|
|
604
|
+
var TrendRadarCollectionRecipeEntrySchema = z6.object({
|
|
605
|
+
subjectRef: TrendRadarCollectionSubjectRefSchema,
|
|
606
|
+
label: z6.string().trim().min(1).max(200)
|
|
607
|
+
}).strict();
|
|
608
|
+
var TrendRadarCollectionRecipeSchema = z6.object({
|
|
609
|
+
category: z6.array(TrendRadarCollectionRecipeEntrySchema),
|
|
610
|
+
design: z6.array(TrendRadarCollectionRecipeEntrySchema),
|
|
611
|
+
audience: z6.array(TrendRadarCollectionRecipeEntrySchema)
|
|
612
|
+
}).strict().refine(
|
|
613
|
+
(recipe) => recipe.category.length + recipe.design.length + recipe.audience.length > 0,
|
|
614
|
+
"A Trend Radar collection recipe must contain at least one subject."
|
|
615
|
+
);
|
|
616
|
+
var TrendRadarCollectionDecisionAxisSchema = z6.object({
|
|
617
|
+
key: ContractIdentifierSchema,
|
|
618
|
+
label: z6.string().trim().min(1).max(200).optional(),
|
|
619
|
+
value: z6.number().finite()
|
|
620
|
+
}).strict();
|
|
621
|
+
var TrendRadarCollectionDecisionProjectionSchema = z6.object({
|
|
622
|
+
axes: z6.array(TrendRadarCollectionDecisionAxisSchema).max(32).optional(),
|
|
623
|
+
overallScore: z6.number().finite().optional(),
|
|
624
|
+
itemRank: z6.number().finite().optional(),
|
|
625
|
+
sourceRefs: z6.array(EntityRefSchema).optional(),
|
|
626
|
+
outputRefs: z6.array(EntityRefSchema).optional()
|
|
627
|
+
}).strict().superRefine((projection, context) => {
|
|
628
|
+
const hasProjection = Boolean(
|
|
629
|
+
projection.axes?.length || projection.overallScore !== void 0 || projection.itemRank !== void 0 || projection.sourceRefs?.length || projection.outputRefs?.length
|
|
630
|
+
);
|
|
631
|
+
if (!hasProjection) {
|
|
632
|
+
context.addIssue({
|
|
633
|
+
code: "custom",
|
|
634
|
+
message: "A decision projection must contain canonical decision data or references."
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
const seenAxisKeys = /* @__PURE__ */ new Set();
|
|
638
|
+
projection.axes?.forEach((axis, index) => {
|
|
639
|
+
if (seenAxisKeys.has(axis.key)) {
|
|
640
|
+
context.addIssue({
|
|
641
|
+
code: "custom",
|
|
642
|
+
path: ["axes", index, "key"],
|
|
643
|
+
message: `Duplicate decision axis key: ${axis.key}`
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
seenAxisKeys.add(axis.key);
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
var TrendRadarCollectionArtifactProjectionSchema = z6.object({
|
|
650
|
+
artifactRef: TrendRadarCollectionArtifactRefSchema,
|
|
651
|
+
url: z6.string().url().optional(),
|
|
652
|
+
thumbnailUrl: z6.string().url().optional(),
|
|
653
|
+
mimeType: z6.string().trim().min(1).optional(),
|
|
654
|
+
metadata: JsonObjectSchema.optional()
|
|
655
|
+
}).strict();
|
|
656
|
+
var TrendRadarCollectionProjectionWritebackSchema = z6.object({
|
|
657
|
+
status: z6.enum(["PENDING", "APPLIED", "FAILED"]),
|
|
658
|
+
updatedAt: IsoDateTimeSchema,
|
|
659
|
+
error: z6.object({
|
|
660
|
+
code: ContractIdentifierSchema,
|
|
661
|
+
message: z6.string().trim().min(1),
|
|
662
|
+
retryable: z6.boolean()
|
|
663
|
+
}).strict().optional()
|
|
664
|
+
}).strict().superRefine((writeback, context) => {
|
|
665
|
+
if (writeback.status === "FAILED" && !writeback.error) {
|
|
666
|
+
context.addIssue({
|
|
667
|
+
code: "custom",
|
|
668
|
+
path: ["error"],
|
|
669
|
+
message: "A failed collection projection writeback must include an error."
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
if (writeback.status !== "FAILED" && writeback.error) {
|
|
673
|
+
context.addIssue({
|
|
674
|
+
code: "custom",
|
|
675
|
+
path: ["error"],
|
|
676
|
+
message: "Only a failed collection projection writeback may include an error."
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
var TrendRadarCollectionItemSchema = z6.object({
|
|
681
|
+
contract: z6.literal("TrendRadarCollectionItem"),
|
|
682
|
+
schemaVersion: z6.literal(1),
|
|
683
|
+
selectionRef: TrendRadarCollectionSelectionRefSchema,
|
|
684
|
+
recipe: TrendRadarCollectionRecipeSchema,
|
|
685
|
+
status: z6.enum(["SAVED", "QUEUED", "RUNNING", "SUCCEEDED", "FAILED", "CANCELLED", "PARTIAL"]),
|
|
686
|
+
latestRunRef: TrendRadarCollectionRunRefSchema.optional(),
|
|
687
|
+
decisionProjection: TrendRadarCollectionDecisionProjectionSchema.optional(),
|
|
688
|
+
artifactProjection: TrendRadarCollectionArtifactProjectionSchema.optional(),
|
|
689
|
+
createdAt: IsoDateTimeSchema,
|
|
690
|
+
updatedAt: IsoDateTimeSchema,
|
|
691
|
+
generatedAt: IsoDateTimeSchema.optional()
|
|
692
|
+
}).strict();
|
|
693
|
+
var RadarAnalysisRunSchema = z6.object({
|
|
694
|
+
contract: z6.literal("RadarAnalysisRun"),
|
|
695
|
+
runId: ContractIdentifierSchema,
|
|
696
|
+
teamId: ContractIdentifierSchema,
|
|
697
|
+
selectionRef: EntityRefSchema,
|
|
698
|
+
workflowRef: EntityRefSchema,
|
|
699
|
+
executionRef: EntityRefSchema.optional(),
|
|
700
|
+
designProjectRef: EntityRefSchema.optional(),
|
|
701
|
+
replayedFromRef: EntityRefSchema.optional(),
|
|
702
|
+
collectionAssetRef: TrendRadarCollectionAssetRefSchema.optional(),
|
|
703
|
+
collectionProjectionWriteback: TrendRadarCollectionProjectionWritebackSchema.optional(),
|
|
704
|
+
workflowDefinitionTeamId: ContractIdentifierSchema.optional(),
|
|
705
|
+
workflowInput: z6.record(z6.string(), JsonValueSchema).default({}),
|
|
706
|
+
createDesignProject: z6.boolean().default(true),
|
|
707
|
+
designProjectName: z6.string().trim().min(1).max(200).optional(),
|
|
708
|
+
modelRef: EntityRefSchema,
|
|
709
|
+
requestId: ContractIdentifierSchema,
|
|
710
|
+
idempotencyKey: ContractIdentifierSchema,
|
|
711
|
+
status: z6.enum(["QUEUED", "RUNNING", "SUCCEEDED", "FAILED", "CANCELLED", "PARTIAL"]),
|
|
712
|
+
outputRefs: z6.array(EntityRefSchema).default([]),
|
|
713
|
+
error: z6.object({
|
|
714
|
+
code: ContractIdentifierSchema,
|
|
715
|
+
message: z6.string().trim().min(1),
|
|
716
|
+
retryable: z6.boolean()
|
|
717
|
+
}).strict().optional(),
|
|
718
|
+
startedAt: IsoDateTimeSchema.optional(),
|
|
719
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
720
|
+
createdAt: IsoDateTimeSchema
|
|
721
|
+
}).strict();
|
|
722
|
+
var RadarAnalysisAssetSchema = z6.object({
|
|
723
|
+
artifactRef: EntityRefSchema,
|
|
724
|
+
kind: ContractIdentifierSchema,
|
|
725
|
+
mimeType: z6.string().trim().min(1).optional(),
|
|
726
|
+
url: z6.string().url(),
|
|
727
|
+
metadata: z6.record(z6.string(), JsonValueSchema).default({}),
|
|
728
|
+
createdAt: IsoDateTimeSchema
|
|
729
|
+
}).strict();
|
|
730
|
+
var RadarAnalysisDetailSchema = z6.object({
|
|
731
|
+
contract: z6.literal("RadarAnalysisDetail"),
|
|
732
|
+
run: RadarAnalysisRunSchema,
|
|
733
|
+
runVersion: z6.number().int().positive(),
|
|
734
|
+
selection: RadarSelectionSchema,
|
|
735
|
+
outputs: z6.array(OutputRecordSchema),
|
|
736
|
+
assets: z6.array(RadarAnalysisAssetSchema),
|
|
737
|
+
lineage: z6.array(LineageRecordSchema)
|
|
738
|
+
}).strict();
|
|
739
|
+
var RadarActionRecordSchema = z6.object({
|
|
740
|
+
contract: z6.literal("RadarActionRecord"),
|
|
741
|
+
actionId: ContractIdentifierSchema,
|
|
742
|
+
teamId: ContractIdentifierSchema,
|
|
743
|
+
actorRef: EntityRefSchema,
|
|
744
|
+
action: z6.enum(["stash", "select", "reject", "archive", "launch", "retry", "replay", "rollback"]),
|
|
745
|
+
targetRef: EntityRefSchema,
|
|
746
|
+
requestId: ContractIdentifierSchema,
|
|
747
|
+
idempotencyKey: ContractIdentifierSchema,
|
|
748
|
+
expectedVersion: z6.number().int().nonnegative(),
|
|
749
|
+
occurredAt: IsoDateTimeSchema
|
|
750
|
+
}).strict();
|
|
751
|
+
var RadarWritebackRecordSchema = z6.object({
|
|
752
|
+
contract: z6.literal("RadarWritebackRecord"),
|
|
753
|
+
writebackId: ContractIdentifierSchema,
|
|
754
|
+
actionRef: EntityRefSchema,
|
|
755
|
+
targetRef: EntityRefSchema,
|
|
756
|
+
status: z6.enum(["PENDING", "APPLIED", "FAILED"]),
|
|
757
|
+
resultingVersion: z6.number().int().nonnegative().optional(),
|
|
758
|
+
error: z6.string().trim().min(1).optional(),
|
|
759
|
+
recordedAt: IsoDateTimeSchema
|
|
760
|
+
}).strict();
|
|
761
|
+
|
|
762
|
+
// src/contracts/workflow-runtime.ts
|
|
763
|
+
import { z as z7 } from "zod";
|
|
764
|
+
var WorkflowCatalogEntrySchema = z7.object({
|
|
765
|
+
contract: z7.literal("WorkflowCatalogEntry"),
|
|
766
|
+
workflowId: ContractIdentifierSchema,
|
|
767
|
+
teamId: ContractIdentifierSchema,
|
|
768
|
+
creatorRef: EntityRefSchema,
|
|
769
|
+
currentDefinitionRef: EntityRefSchema,
|
|
770
|
+
lifecycle: z7.enum(["ACTIVE", "DELETED"]),
|
|
771
|
+
asset: z7.object({
|
|
772
|
+
preset: z7.boolean(),
|
|
773
|
+
marketplacePublished: z7.boolean(),
|
|
774
|
+
publishConfig: JsonObjectSchema.optional(),
|
|
775
|
+
sort: z7.number().int(),
|
|
776
|
+
forkFromRef: EntityRefSchema.optional(),
|
|
777
|
+
notAuthorized: z7.boolean()
|
|
778
|
+
}).strict(),
|
|
779
|
+
createdAt: IsoDateTimeSchema,
|
|
780
|
+
updatedAt: IsoDateTimeSchema,
|
|
781
|
+
deletedAt: IsoDateTimeSchema.optional()
|
|
782
|
+
}).strict().superRefine((entry, context) => {
|
|
783
|
+
if (entry.creatorRef.kind !== "user" && entry.creatorRef.kind !== "service") {
|
|
784
|
+
context.addIssue({
|
|
785
|
+
code: "custom",
|
|
786
|
+
path: ["creatorRef", "kind"],
|
|
787
|
+
message: "creatorRef must reference a user or service."
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
if (entry.currentDefinitionRef.kind !== "workflow-definition") {
|
|
791
|
+
context.addIssue({
|
|
792
|
+
code: "custom",
|
|
793
|
+
path: ["currentDefinitionRef", "kind"],
|
|
794
|
+
message: "currentDefinitionRef must reference a workflow-definition."
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
if (entry.lifecycle === "DELETED" && !entry.deletedAt) {
|
|
798
|
+
context.addIssue({
|
|
799
|
+
code: "custom",
|
|
800
|
+
path: ["deletedAt"],
|
|
801
|
+
message: "Deleted workflow catalog entries require deletedAt."
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
if (entry.lifecycle === "ACTIVE" && entry.deletedAt) {
|
|
805
|
+
context.addIssue({
|
|
806
|
+
code: "custom",
|
|
807
|
+
path: ["deletedAt"],
|
|
808
|
+
message: "Active workflow catalog entries cannot declare deletedAt."
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
var WorkflowPublicationSchema = z7.object({
|
|
813
|
+
contract: z7.literal("WorkflowPublication"),
|
|
814
|
+
publicationId: ContractIdentifierSchema,
|
|
815
|
+
definitionRef: EntityRefSchema,
|
|
816
|
+
runtimeDefinitionRef: EntityRefSchema,
|
|
817
|
+
sourceHash: Sha256Schema,
|
|
818
|
+
compiledHash: Sha256Schema,
|
|
819
|
+
status: z7.enum(["PENDING", "PUBLISHED", "FAILED", "RETIRED"]),
|
|
820
|
+
publisherRef: EntityRefSchema,
|
|
821
|
+
publishedAt: IsoDateTimeSchema.optional(),
|
|
822
|
+
failureReason: z7.string().trim().min(1).optional()
|
|
823
|
+
}).strict().superRefine((publication, context) => {
|
|
824
|
+
if (publication.definitionRef.kind !== "workflow-definition") {
|
|
825
|
+
context.addIssue({
|
|
826
|
+
code: "custom",
|
|
827
|
+
path: ["definitionRef", "kind"],
|
|
828
|
+
message: "definitionRef must reference a workflow-definition."
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
if (publication.runtimeDefinitionRef.kind !== "conductor-workflow-definition") {
|
|
832
|
+
context.addIssue({
|
|
833
|
+
code: "custom",
|
|
834
|
+
path: ["runtimeDefinitionRef", "kind"],
|
|
835
|
+
message: "runtimeDefinitionRef must reference a conductor-workflow-definition."
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
if (publication.status === "PUBLISHED" && !publication.publishedAt) {
|
|
839
|
+
context.addIssue({
|
|
840
|
+
code: "custom",
|
|
841
|
+
path: ["publishedAt"],
|
|
842
|
+
message: "Published workflow publications require publishedAt."
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
if (publication.status === "FAILED" && !publication.failureReason) {
|
|
846
|
+
context.addIssue({
|
|
847
|
+
code: "custom",
|
|
848
|
+
path: ["failureReason"],
|
|
849
|
+
message: "Failed workflow publications require failureReason."
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
var WorkflowCompletionCommitSchema = z7.object({
|
|
854
|
+
contract: z7.literal("WorkflowCompletionCommit"),
|
|
855
|
+
commitId: ContractIdentifierSchema,
|
|
856
|
+
run: ApplicationRunSchema,
|
|
857
|
+
outputs: z7.array(OutputRecordSchema),
|
|
858
|
+
artifacts: z7.array(ArtifactManifestSchema),
|
|
859
|
+
lineage: LineageRecordSchema,
|
|
860
|
+
completedAt: IsoDateTimeSchema
|
|
861
|
+
}).strict().superRefine((commit, context) => {
|
|
862
|
+
const expectedRunId = commit.run.runId;
|
|
863
|
+
const referencesRun = (value) => value.runRef.kind === "application-run" && value.runRef.id === expectedRunId;
|
|
864
|
+
commit.outputs.forEach((output, index) => {
|
|
865
|
+
if (!referencesRun(output)) {
|
|
866
|
+
context.addIssue({
|
|
867
|
+
code: "custom",
|
|
868
|
+
path: ["outputs", index, "runRef"],
|
|
869
|
+
message: "Every output must reference the committed ApplicationRun."
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
commit.artifacts.forEach((artifact, index) => {
|
|
874
|
+
if (!referencesRun(artifact)) {
|
|
875
|
+
context.addIssue({
|
|
876
|
+
code: "custom",
|
|
877
|
+
path: ["artifacts", index, "runRef"],
|
|
878
|
+
message: "Every artifact must reference the committed ApplicationRun."
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
if (commit.lineage.subjectRef.kind !== "application-run" || commit.lineage.subjectRef.id !== expectedRunId) {
|
|
883
|
+
context.addIssue({
|
|
884
|
+
code: "custom",
|
|
885
|
+
path: ["lineage", "subjectRef"],
|
|
886
|
+
message: "Completion lineage must use the committed ApplicationRun as its subject."
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
const outputIds = new Set(commit.outputs.map((output) => output.outputId));
|
|
890
|
+
commit.artifacts.forEach((artifact, index) => {
|
|
891
|
+
if (artifact.outputRef.kind !== "workflow-output" || !outputIds.has(artifact.outputRef.id)) {
|
|
892
|
+
context.addIssue({
|
|
893
|
+
code: "custom",
|
|
894
|
+
path: ["artifacts", index, "outputRef"],
|
|
895
|
+
message: "Artifact outputRef must reference an output in the same commit."
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
});
|
|
900
|
+
var WorkflowCompletionReceiptSchema = z7.object({
|
|
901
|
+
contract: z7.literal("WorkflowCompletionReceipt"),
|
|
902
|
+
commitId: ContractIdentifierSchema,
|
|
903
|
+
runRef: EntityRefSchema,
|
|
904
|
+
outputRefs: z7.array(EntityRefSchema),
|
|
905
|
+
artifactRefs: z7.array(EntityRefSchema),
|
|
906
|
+
contentHash: Sha256Schema,
|
|
907
|
+
committedAt: IsoDateTimeSchema,
|
|
908
|
+
idempotentReplay: z7.boolean()
|
|
909
|
+
}).strict().superRefine((receipt, context) => {
|
|
910
|
+
if (receipt.runRef.kind !== "application-run") {
|
|
911
|
+
context.addIssue({
|
|
912
|
+
code: "custom",
|
|
913
|
+
path: ["runRef", "kind"],
|
|
914
|
+
message: "runRef must reference an application-run."
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
receipt.outputRefs.forEach((ref, index) => {
|
|
918
|
+
if (ref.kind !== "workflow-output") {
|
|
919
|
+
context.addIssue({
|
|
920
|
+
code: "custom",
|
|
921
|
+
path: ["outputRefs", index, "kind"],
|
|
922
|
+
message: "outputRefs must reference workflow-output records."
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
receipt.artifactRefs.forEach((ref, index) => {
|
|
927
|
+
if (ref.kind !== "artifact") {
|
|
928
|
+
context.addIssue({
|
|
929
|
+
code: "custom",
|
|
930
|
+
path: ["artifactRefs", index, "kind"],
|
|
931
|
+
message: "artifactRefs must reference artifacts."
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
export {
|
|
938
|
+
StorageLocatorSchema,
|
|
939
|
+
ArtifactAccessSchema,
|
|
940
|
+
ArtifactManifestSchema,
|
|
941
|
+
OutputRecordSchema,
|
|
942
|
+
AggregateAssetSchema,
|
|
943
|
+
AggregateAssetUpsertSchema,
|
|
944
|
+
AggregateAssetDeleteSchema,
|
|
945
|
+
AggregateFeatureValueWriteSchema,
|
|
946
|
+
AggregateFeatureRelationTargetSchema,
|
|
947
|
+
AggregateFeatureRelationReplaceSchema,
|
|
948
|
+
AggregateAssetRelationObjectSchema,
|
|
949
|
+
AggregateAssetRelationReplaceSchema,
|
|
950
|
+
AggregateContainerMembershipWriteSchema,
|
|
951
|
+
AggregateCommitRequestSchema,
|
|
952
|
+
ActorRefSchema,
|
|
953
|
+
AuthorityScopeSchema,
|
|
954
|
+
RequestScopeSchema,
|
|
955
|
+
ExecutionLinkSchema,
|
|
956
|
+
CompletionHeaderSchema,
|
|
957
|
+
CompletionEventSchema,
|
|
958
|
+
AgentRuntimeEventSchema,
|
|
959
|
+
DataContinuityEnvelopeSchema,
|
|
960
|
+
BodyRelationRecordSchema,
|
|
961
|
+
ApplicationRunSchema,
|
|
962
|
+
ExpiringAccessGrantSchema,
|
|
963
|
+
DeclarativeImportDocumentSchema,
|
|
964
|
+
DeclarativeDocumentImportRequestSchema,
|
|
965
|
+
DeclarativeDocumentImportIntentSchema,
|
|
966
|
+
DeclarativeDocumentImportPlanSchema,
|
|
967
|
+
DeclarativeDocumentImportResultSchema,
|
|
968
|
+
RadarDecisionMetricsSchema,
|
|
969
|
+
TrendSourceSchema,
|
|
970
|
+
TrendIngestRunSchema,
|
|
971
|
+
TrendSourceRecordSchema,
|
|
972
|
+
HotwordBodySchema,
|
|
973
|
+
BrandBodySchema,
|
|
974
|
+
ProductBodySchema,
|
|
975
|
+
TrendMetricSnapshotSchema,
|
|
976
|
+
RadarScoreModelBodySchema,
|
|
977
|
+
RadarScoreProjectionSchema,
|
|
978
|
+
RadarPanoramaNodeSchema,
|
|
979
|
+
RadarPanoramaEdgeSchema,
|
|
980
|
+
RadarPanoramaSchema,
|
|
981
|
+
BrandGeneticsProfileSchema,
|
|
982
|
+
RadarOpportunityMatrixPointSchema,
|
|
983
|
+
RadarOpportunityMatrixSchema,
|
|
984
|
+
RadarQueryBodySchema,
|
|
985
|
+
SavedRadarQuerySchema,
|
|
986
|
+
RadarSelectionSchema,
|
|
987
|
+
TrendRadarCollectionAssetRefSchema,
|
|
988
|
+
TrendRadarCollectionSelectionRefSchema,
|
|
989
|
+
TrendRadarCollectionRunRefSchema,
|
|
990
|
+
TrendRadarCollectionSubjectRefSchema,
|
|
991
|
+
TrendRadarCollectionArtifactRefSchema,
|
|
992
|
+
TrendRadarCollectionRecipeEntrySchema,
|
|
993
|
+
TrendRadarCollectionRecipeSchema,
|
|
994
|
+
TrendRadarCollectionDecisionAxisSchema,
|
|
995
|
+
TrendRadarCollectionDecisionProjectionSchema,
|
|
996
|
+
TrendRadarCollectionArtifactProjectionSchema,
|
|
997
|
+
TrendRadarCollectionProjectionWritebackSchema,
|
|
998
|
+
TrendRadarCollectionItemSchema,
|
|
999
|
+
RadarAnalysisRunSchema,
|
|
1000
|
+
RadarAnalysisAssetSchema,
|
|
1001
|
+
RadarAnalysisDetailSchema,
|
|
1002
|
+
RadarActionRecordSchema,
|
|
1003
|
+
RadarWritebackRecordSchema,
|
|
1004
|
+
WorkflowCatalogEntrySchema,
|
|
1005
|
+
WorkflowPublicationSchema,
|
|
1006
|
+
WorkflowCompletionCommitSchema,
|
|
1007
|
+
WorkflowCompletionReceiptSchema
|
|
1008
|
+
};
|
|
1009
|
+
//# sourceMappingURL=chunk-4ZSCTEY6.mjs.map
|