openxiangda-contracts 2.0.0-alpha.12

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.
@@ -0,0 +1,2216 @@
1
+ import { OPENXIANGDA_CONTRACT_VERSION, SCHEMA_VERSIONS } from "./types.js";
2
+ const digest = { type: "string", pattern: "^[0-9a-f]{64}$" };
3
+ const dateTime = { type: "string", format: "date-time" };
4
+ const nonEmptyString = { type: "string", minLength: 1 };
5
+ export const diagnosticSchema = {
6
+ $id: SCHEMA_VERSIONS.diagnostic,
7
+ type: "object",
8
+ additionalProperties: false,
9
+ required: ["schemaVersion", "code", "severity", "message", "retryable"],
10
+ properties: {
11
+ schemaVersion: { const: SCHEMA_VERSIONS.diagnostic },
12
+ code: nonEmptyString,
13
+ severity: { enum: ["info", "warning", "error"] },
14
+ message: nonEmptyString,
15
+ path: { type: "string" },
16
+ source: { type: "string" },
17
+ retryable: { type: "boolean" },
18
+ remediation: { type: "string" },
19
+ details: { type: "object" },
20
+ },
21
+ };
22
+ export const workspaceContextSchema = {
23
+ $id: SCHEMA_VERSIONS.workspaceContext,
24
+ type: "object",
25
+ additionalProperties: false,
26
+ required: [
27
+ "schemaVersion",
28
+ "workspace",
29
+ "roots",
30
+ "toolchain",
31
+ "environments",
32
+ "changedDomains",
33
+ ],
34
+ properties: {
35
+ schemaVersion: { const: SCHEMA_VERSIONS.workspaceContext },
36
+ workspace: {
37
+ type: "object",
38
+ additionalProperties: false,
39
+ required: ["appCode", "root"],
40
+ properties: {
41
+ appCode: nonEmptyString,
42
+ name: { type: "string" },
43
+ root: nonEmptyString,
44
+ repository: { type: "string" },
45
+ revision: { type: "string" },
46
+ dirty: { type: "boolean" },
47
+ },
48
+ },
49
+ roots: {
50
+ type: "object",
51
+ additionalProperties: false,
52
+ required: ["frontend", "backend", "platform"],
53
+ properties: {
54
+ frontend: nonEmptyString,
55
+ backend: nonEmptyString,
56
+ platform: nonEmptyString,
57
+ },
58
+ },
59
+ toolchain: {
60
+ type: "object",
61
+ additionalProperties: false,
62
+ required: ["version", "contractVersion", "nodeVersion", "packageManager"],
63
+ properties: {
64
+ version: nonEmptyString,
65
+ contractVersion: { const: OPENXIANGDA_CONTRACT_VERSION },
66
+ nodeVersion: nonEmptyString,
67
+ packageManager: nonEmptyString,
68
+ },
69
+ },
70
+ environments: {
71
+ type: "array",
72
+ items: {
73
+ type: "object",
74
+ additionalProperties: false,
75
+ required: ["name", "kind"],
76
+ properties: {
77
+ id: { type: "string" },
78
+ name: nonEmptyString,
79
+ kind: {
80
+ enum: ["development", "preproduction", "production"],
81
+ },
82
+ },
83
+ },
84
+ },
85
+ changedDomains: {
86
+ type: "array",
87
+ uniqueItems: true,
88
+ items: {
89
+ enum: [
90
+ "frontend",
91
+ "backend",
92
+ "data",
93
+ "authz",
94
+ "events",
95
+ "workflow",
96
+ "config",
97
+ ],
98
+ },
99
+ },
100
+ },
101
+ };
102
+ export const applicationSchema = {
103
+ $id: SCHEMA_VERSIONS.application,
104
+ type: "object",
105
+ additionalProperties: false,
106
+ required: ["schemaVersion", "created", "application", "bootstrapAdminRole"],
107
+ properties: {
108
+ schemaVersion: { const: SCHEMA_VERSIONS.application },
109
+ created: { type: "boolean" },
110
+ application: {
111
+ type: "object",
112
+ additionalProperties: false,
113
+ required: ["id", "appCode", "name", "runtimeMode"],
114
+ properties: {
115
+ id: nonEmptyString,
116
+ appCode: nonEmptyString,
117
+ name: nonEmptyString,
118
+ description: { type: ["string", "null"] },
119
+ runtimeMode: { const: "react-spa" },
120
+ createdAt: { anyOf: [dateTime, { type: "null" }] },
121
+ updatedAt: { anyOf: [dateTime, { type: "null" }] },
122
+ },
123
+ },
124
+ bootstrapAdminRole: {
125
+ type: "object",
126
+ additionalProperties: false,
127
+ required: ["code"],
128
+ properties: { code: nonEmptyString },
129
+ },
130
+ },
131
+ };
132
+ export const principalSchema = {
133
+ $id: SCHEMA_VERSIONS.principal,
134
+ type: "object",
135
+ additionalProperties: false,
136
+ required: [
137
+ "schemaVersion",
138
+ "tenantId",
139
+ "appCode",
140
+ "environmentId",
141
+ "principalType",
142
+ "subjectId",
143
+ "authzVersion",
144
+ "isAppSuperAdmin",
145
+ ],
146
+ properties: {
147
+ schemaVersion: { const: SCHEMA_VERSIONS.principal },
148
+ tenantId: nonEmptyString,
149
+ appCode: nonEmptyString,
150
+ environmentId: nonEmptyString,
151
+ principalType: { enum: ["user", "service", "public"] },
152
+ subjectId: nonEmptyString,
153
+ userId: { type: "string" },
154
+ loginSessionId: { type: "string" },
155
+ roleSessionId: { type: "string" },
156
+ activeRoleAssignmentId: { type: "string" },
157
+ activeRoleCode: { type: "string" },
158
+ clientRecordId: { type: "string" },
159
+ clientId: { type: "string" },
160
+ credentialVersion: { type: "integer", minimum: 1 },
161
+ environmentKey: { type: "string" },
162
+ scopes: { type: "array", items: nonEmptyString },
163
+ rateLimitPerMinute: { type: "integer", minimum: 1 },
164
+ tokenId: { type: "string" },
165
+ authzVersion: { type: "integer", minimum: 0 },
166
+ isAppSuperAdmin: { type: "boolean" },
167
+ },
168
+ };
169
+ export const roleSessionSchema = {
170
+ $id: SCHEMA_VERSIONS.roleSession,
171
+ type: "object",
172
+ additionalProperties: false,
173
+ required: [
174
+ "schemaVersion",
175
+ "id",
176
+ "loginSessionId",
177
+ "tenantId",
178
+ "appCode",
179
+ "userId",
180
+ "activeRoleAssignmentId",
181
+ "activeRoleCode",
182
+ "authzVersion",
183
+ "issuedAt",
184
+ "expiresAt",
185
+ "lastUsedAt",
186
+ ],
187
+ properties: {
188
+ schemaVersion: { const: SCHEMA_VERSIONS.roleSession },
189
+ id: nonEmptyString,
190
+ loginSessionId: nonEmptyString,
191
+ tenantId: nonEmptyString,
192
+ appCode: nonEmptyString,
193
+ userId: nonEmptyString,
194
+ activeRoleAssignmentId: nonEmptyString,
195
+ activeRoleCode: nonEmptyString,
196
+ authzVersion: { type: "integer", minimum: 0 },
197
+ issuedAt: dateTime,
198
+ expiresAt: dateTime,
199
+ lastUsedAt: dateTime,
200
+ },
201
+ };
202
+ export const roleAssignmentSchema = {
203
+ $id: SCHEMA_VERSIONS.roleAssignment,
204
+ type: "object",
205
+ additionalProperties: false,
206
+ required: [
207
+ "schemaVersion",
208
+ "id",
209
+ "tenantId",
210
+ "appCode",
211
+ "userId",
212
+ "role",
213
+ "status",
214
+ "revision",
215
+ "scopeGrants",
216
+ "createdAt",
217
+ "updatedAt",
218
+ ],
219
+ properties: {
220
+ schemaVersion: { const: SCHEMA_VERSIONS.roleAssignment },
221
+ id: nonEmptyString,
222
+ tenantId: nonEmptyString,
223
+ appCode: nonEmptyString,
224
+ userId: nonEmptyString,
225
+ role: {
226
+ type: "object",
227
+ additionalProperties: false,
228
+ required: ["id", "code", "name", "isAppSuperAdmin"],
229
+ properties: {
230
+ id: nonEmptyString,
231
+ code: nonEmptyString,
232
+ name: nonEmptyString,
233
+ isAppSuperAdmin: { type: "boolean" },
234
+ },
235
+ },
236
+ status: { enum: ["active", "revoked", "expired"] },
237
+ revision: { type: "integer", minimum: 1 },
238
+ scopeGrants: {
239
+ type: "array",
240
+ items: {
241
+ type: "object",
242
+ additionalProperties: false,
243
+ required: ["dimensionCode", "values", "operations"],
244
+ properties: {
245
+ dimensionCode: nonEmptyString,
246
+ values: {
247
+ type: "array",
248
+ uniqueItems: true,
249
+ minItems: 1,
250
+ items: nonEmptyString,
251
+ },
252
+ operations: {
253
+ type: "array",
254
+ uniqueItems: true,
255
+ minItems: 1,
256
+ items: nonEmptyString,
257
+ },
258
+ },
259
+ },
260
+ },
261
+ validFrom: { anyOf: [dateTime, { type: "null" }] },
262
+ validTo: { anyOf: [dateTime, { type: "null" }] },
263
+ createdAt: dateTime,
264
+ updatedAt: dateTime,
265
+ },
266
+ };
267
+ export const relationshipGrantSchema = {
268
+ $id: SCHEMA_VERSIONS.relationshipGrant,
269
+ type: "object",
270
+ additionalProperties: false,
271
+ required: [
272
+ "schemaVersion",
273
+ "id",
274
+ "tenantId",
275
+ "appCode",
276
+ "relationCode",
277
+ "subjectType",
278
+ "subjectKey",
279
+ "resourceCode",
280
+ "resourceId",
281
+ "operations",
282
+ "sourceCode",
283
+ "status",
284
+ "revision",
285
+ "createdAt",
286
+ "updatedAt",
287
+ ],
288
+ properties: {
289
+ schemaVersion: { const: SCHEMA_VERSIONS.relationshipGrant },
290
+ id: nonEmptyString,
291
+ tenantId: nonEmptyString,
292
+ appCode: nonEmptyString,
293
+ relationCode: nonEmptyString,
294
+ subjectType: { enum: ["user", "role_assignment"] },
295
+ subjectKey: nonEmptyString,
296
+ resourceCode: nonEmptyString,
297
+ resourceId: nonEmptyString,
298
+ operations: {
299
+ type: "array",
300
+ minItems: 1,
301
+ uniqueItems: true,
302
+ items: nonEmptyString,
303
+ },
304
+ sourceCode: nonEmptyString,
305
+ status: { enum: ["active", "revoked", "expired"] },
306
+ revision: { type: "integer", minimum: 1 },
307
+ validFrom: { anyOf: [dateTime, { type: "null" }] },
308
+ validTo: { anyOf: [dateTime, { type: "null" }] },
309
+ createdAt: dateTime,
310
+ updatedAt: dateTime,
311
+ },
312
+ };
313
+ export const authorizationDecisionSchema = {
314
+ $id: SCHEMA_VERSIONS.authorizationDecision,
315
+ type: "object",
316
+ additionalProperties: false,
317
+ required: [
318
+ "schemaVersion",
319
+ "explainId",
320
+ "allowed",
321
+ "principal",
322
+ "roleSession",
323
+ "decisions",
324
+ ],
325
+ properties: {
326
+ schemaVersion: { const: SCHEMA_VERSIONS.authorizationDecision },
327
+ explainId: nonEmptyString,
328
+ allowed: { type: "boolean" },
329
+ principal: { $ref: SCHEMA_VERSIONS.principal },
330
+ roleSession: { $ref: SCHEMA_VERSIONS.roleSession },
331
+ decisions: {
332
+ type: "array",
333
+ minItems: 1,
334
+ items: {
335
+ type: "object",
336
+ required: ["layer", "allowed"],
337
+ properties: {
338
+ layer: {
339
+ enum: ["app_super_admin", "rbac", "data_policy", "field_policy"],
340
+ },
341
+ allowed: { type: "boolean" },
342
+ reason: { type: "string" },
343
+ detail: { type: "object" },
344
+ },
345
+ },
346
+ },
347
+ },
348
+ };
349
+ const authorizationExplainRequestSchema = {
350
+ type: "object",
351
+ additionalProperties: false,
352
+ required: ["key", "capability"],
353
+ properties: {
354
+ key: { type: "string", minLength: 1, maxLength: 128 },
355
+ capability: { type: "string", minLength: 1, maxLength: 255 },
356
+ dataPolicyCode: { type: "string", minLength: 1, maxLength: 128 },
357
+ operation: { type: "string", minLength: 1, maxLength: 64 },
358
+ data: { type: "object" },
359
+ },
360
+ };
361
+ export const authorizationBatchRequestSchema = {
362
+ $id: SCHEMA_VERSIONS.authorizationBatchRequest,
363
+ type: "object",
364
+ additionalProperties: false,
365
+ required: ["schemaVersion", "requests"],
366
+ properties: {
367
+ schemaVersion: { const: SCHEMA_VERSIONS.authorizationBatchRequest },
368
+ requests: {
369
+ type: "array",
370
+ minItems: 1,
371
+ maxItems: 200,
372
+ items: authorizationExplainRequestSchema,
373
+ },
374
+ },
375
+ };
376
+ export const authorizationBatchResultSchema = {
377
+ $id: SCHEMA_VERSIONS.authorizationBatchResult,
378
+ type: "object",
379
+ additionalProperties: false,
380
+ required: ["schemaVersion", "principal", "roleSession", "items"],
381
+ properties: {
382
+ schemaVersion: { const: SCHEMA_VERSIONS.authorizationBatchResult },
383
+ principal: { $ref: SCHEMA_VERSIONS.principal },
384
+ roleSession: { $ref: SCHEMA_VERSIONS.roleSession },
385
+ items: {
386
+ type: "array",
387
+ minItems: 1,
388
+ maxItems: 200,
389
+ items: {
390
+ type: "object",
391
+ additionalProperties: false,
392
+ required: ["key", "decision"],
393
+ properties: {
394
+ key: authorizationExplainRequestSchema.properties.key,
395
+ decision: { $ref: SCHEMA_VERSIONS.authorizationDecision },
396
+ },
397
+ },
398
+ },
399
+ },
400
+ };
401
+ const directoryKindSchema = { enum: ["department", "user"] };
402
+ const directoryEntrySchema = {
403
+ type: "object",
404
+ additionalProperties: false,
405
+ required: ["kind", "id", "label"],
406
+ properties: {
407
+ kind: directoryKindSchema,
408
+ id: nonEmptyString,
409
+ label: nonEmptyString,
410
+ description: { type: "string" },
411
+ path: {
412
+ type: "array",
413
+ items: {
414
+ type: "object",
415
+ additionalProperties: false,
416
+ required: ["id", "label"],
417
+ properties: { id: nonEmptyString, label: nonEmptyString },
418
+ },
419
+ },
420
+ },
421
+ };
422
+ export const directoryResolveRequestSchema = {
423
+ $id: SCHEMA_VERSIONS.directoryResolveRequest,
424
+ type: "object",
425
+ additionalProperties: false,
426
+ required: ["schemaVersion", "kind", "ids"],
427
+ properties: {
428
+ schemaVersion: { const: SCHEMA_VERSIONS.directoryResolveRequest },
429
+ kind: directoryKindSchema,
430
+ ids: {
431
+ type: "array",
432
+ minItems: 1,
433
+ maxItems: 50,
434
+ uniqueItems: true,
435
+ items: nonEmptyString,
436
+ },
437
+ },
438
+ };
439
+ export const directorySearchResultSchema = {
440
+ $id: SCHEMA_VERSIONS.directorySearchResult,
441
+ type: "object",
442
+ additionalProperties: false,
443
+ required: ["schemaVersion", "kind", "items", "total"],
444
+ properties: {
445
+ schemaVersion: { const: SCHEMA_VERSIONS.directorySearchResult },
446
+ kind: directoryKindSchema,
447
+ items: {
448
+ type: "array",
449
+ maxItems: 50,
450
+ items: directoryEntrySchema,
451
+ },
452
+ total: { type: "integer", minimum: 0 },
453
+ },
454
+ };
455
+ export const dataRefSchema = {
456
+ $id: SCHEMA_VERSIONS.dataRef,
457
+ type: "object",
458
+ additionalProperties: false,
459
+ required: ["schemaVersion", "appCode", "resource", "recordId", "revision"],
460
+ properties: {
461
+ schemaVersion: { const: SCHEMA_VERSIONS.dataRef },
462
+ appCode: nonEmptyString,
463
+ resource: nonEmptyString,
464
+ recordId: nonEmptyString,
465
+ revision: { type: "integer", minimum: 0 },
466
+ environmentId: { type: "string" },
467
+ },
468
+ };
469
+ const dataFieldCode = {
470
+ type: "string",
471
+ pattern: "^[A-Za-z][A-Za-z0-9_]{0,62}$",
472
+ };
473
+ const dataResourceCode = {
474
+ type: "string",
475
+ pattern: "^[A-Za-z][A-Za-z0-9_]{0,63}$",
476
+ };
477
+ const dataCapabilities = {
478
+ type: "object",
479
+ additionalProperties: false,
480
+ required: ["read", "create", "update", "delete"],
481
+ properties: {
482
+ read: nonEmptyString,
483
+ create: nonEmptyString,
484
+ update: nonEmptyString,
485
+ delete: nonEmptyString,
486
+ },
487
+ };
488
+ export const dataResourceSchema = {
489
+ $id: SCHEMA_VERSIONS.dataResource,
490
+ type: "object",
491
+ additionalProperties: false,
492
+ required: [
493
+ "schemaVersion",
494
+ "appCode",
495
+ "code",
496
+ "name",
497
+ "schema",
498
+ "capabilities",
499
+ "fieldPolicies",
500
+ ],
501
+ properties: {
502
+ schemaVersion: { const: SCHEMA_VERSIONS.dataResource },
503
+ id: { type: "string" },
504
+ tenantId: { type: "string" },
505
+ appCode: nonEmptyString,
506
+ code: dataResourceCode,
507
+ name: nonEmptyString,
508
+ schema: {
509
+ type: "object",
510
+ additionalProperties: false,
511
+ required: ["fields"],
512
+ properties: {
513
+ fields: {
514
+ type: "array",
515
+ minItems: 1,
516
+ maxItems: 100,
517
+ items: {
518
+ type: "object",
519
+ additionalProperties: false,
520
+ required: ["code", "type"],
521
+ properties: {
522
+ code: dataFieldCode,
523
+ type: {
524
+ enum: [
525
+ "string",
526
+ "text",
527
+ "integer",
528
+ "decimal",
529
+ "boolean",
530
+ "date",
531
+ "datetime",
532
+ "uuid",
533
+ "json",
534
+ "file",
535
+ ],
536
+ },
537
+ nullable: { type: "boolean" },
538
+ indexed: { type: "boolean" },
539
+ file: {
540
+ type: "object",
541
+ additionalProperties: false,
542
+ properties: {
543
+ multiple: { type: "boolean" },
544
+ maxCount: { type: "integer", minimum: 1, maximum: 20 },
545
+ maxSizeMb: { type: "integer", minimum: 1, maximum: 1024 },
546
+ accept: {
547
+ type: "array",
548
+ uniqueItems: true,
549
+ maxItems: 50,
550
+ items: nonEmptyString,
551
+ },
552
+ },
553
+ },
554
+ },
555
+ },
556
+ },
557
+ },
558
+ },
559
+ capabilities: dataCapabilities,
560
+ dataPolicyCode: {
561
+ anyOf: [dataResourceCode, { type: "null" }],
562
+ },
563
+ fieldPolicies: {
564
+ type: "object",
565
+ additionalProperties: {
566
+ type: "object",
567
+ additionalProperties: false,
568
+ properties: {
569
+ read: {
570
+ type: "array",
571
+ uniqueItems: true,
572
+ maxItems: 20,
573
+ items: nonEmptyString,
574
+ },
575
+ write: {
576
+ type: "array",
577
+ uniqueItems: true,
578
+ maxItems: 20,
579
+ items: nonEmptyString,
580
+ },
581
+ mask: { enum: ["omit", "null"] },
582
+ },
583
+ },
584
+ },
585
+ status: { enum: ["active", "retired"] },
586
+ revision: { type: "integer", minimum: 1 },
587
+ createdAt: dateTime,
588
+ updatedAt: dateTime,
589
+ },
590
+ };
591
+ const dataQueryFilter = {
592
+ type: "object",
593
+ additionalProperties: false,
594
+ required: ["field", "operator", "value"],
595
+ properties: {
596
+ field: dataFieldCode,
597
+ operator: {
598
+ enum: [
599
+ "eq",
600
+ "neq",
601
+ "gt",
602
+ "gte",
603
+ "lt",
604
+ "lte",
605
+ "like",
606
+ "ilike",
607
+ "in",
608
+ "is",
609
+ "cs",
610
+ "cd",
611
+ "ov",
612
+ ],
613
+ },
614
+ value: {},
615
+ },
616
+ };
617
+ export const dataQuerySchema = {
618
+ $id: SCHEMA_VERSIONS.dataQuery,
619
+ type: "object",
620
+ additionalProperties: false,
621
+ required: ["schemaVersion"],
622
+ properties: {
623
+ schemaVersion: { const: SCHEMA_VERSIONS.dataQuery },
624
+ select: {
625
+ type: "array",
626
+ uniqueItems: true,
627
+ maxItems: 100,
628
+ items: dataFieldCode,
629
+ },
630
+ filters: {
631
+ type: "array",
632
+ maxItems: 50,
633
+ items: dataQueryFilter,
634
+ },
635
+ order: {
636
+ type: "array",
637
+ maxItems: 10,
638
+ items: {
639
+ type: "object",
640
+ additionalProperties: false,
641
+ required: ["field"],
642
+ properties: {
643
+ field: dataFieldCode,
644
+ direction: { enum: ["asc", "desc"] },
645
+ nulls: { enum: ["first", "last"] },
646
+ },
647
+ },
648
+ },
649
+ limit: { type: "integer", minimum: 1, maximum: 1000 },
650
+ offset: { type: "integer", minimum: 0, maximum: 1000000 },
651
+ },
652
+ };
653
+ export const dataPageSchema = {
654
+ $id: SCHEMA_VERSIONS.dataPage,
655
+ type: "object",
656
+ additionalProperties: false,
657
+ required: [
658
+ "schemaVersion",
659
+ "resourceCode",
660
+ "items",
661
+ "total",
662
+ "limit",
663
+ "offset",
664
+ ],
665
+ properties: {
666
+ schemaVersion: { const: SCHEMA_VERSIONS.dataPage },
667
+ resourceCode: dataResourceCode,
668
+ items: { type: "array", items: { type: "object" } },
669
+ total: { type: "integer", minimum: 0 },
670
+ limit: { type: "integer", minimum: 1, maximum: 1000 },
671
+ offset: { type: "integer", minimum: 0 },
672
+ },
673
+ };
674
+ export const dataRecordSchema = {
675
+ $id: SCHEMA_VERSIONS.dataRecord,
676
+ type: "object",
677
+ additionalProperties: false,
678
+ required: ["schemaVersion", "resourceCode", "data"],
679
+ properties: {
680
+ schemaVersion: { const: SCHEMA_VERSIONS.dataRecord },
681
+ resourceCode: dataResourceCode,
682
+ data: { type: "object" },
683
+ },
684
+ };
685
+ const dataAggregateAlias = {
686
+ type: "string",
687
+ pattern: "^[A-Za-z][A-Za-z0-9_]{0,62}$",
688
+ };
689
+ export const dataAggregateQuerySchema = {
690
+ $id: SCHEMA_VERSIONS.dataAggregateQuery,
691
+ type: "object",
692
+ additionalProperties: false,
693
+ required: ["schemaVersion", "measures"],
694
+ properties: {
695
+ schemaVersion: { const: SCHEMA_VERSIONS.dataAggregateQuery },
696
+ dimensions: {
697
+ type: "array",
698
+ maxItems: 3,
699
+ items: {
700
+ type: "object",
701
+ additionalProperties: false,
702
+ required: ["field", "as"],
703
+ properties: {
704
+ field: dataFieldCode,
705
+ as: dataAggregateAlias,
706
+ bucket: { enum: ["day", "week", "month", "quarter", "year"] },
707
+ },
708
+ },
709
+ },
710
+ measures: {
711
+ type: "array",
712
+ minItems: 1,
713
+ maxItems: 8,
714
+ items: {
715
+ type: "object",
716
+ additionalProperties: false,
717
+ required: ["type", "as"],
718
+ properties: {
719
+ type: { enum: ["count", "countDistinct", "sum", "avg", "min", "max"] },
720
+ field: dataFieldCode,
721
+ as: dataAggregateAlias,
722
+ },
723
+ },
724
+ },
725
+ filters: dataQuerySchema.properties.filters,
726
+ order: {
727
+ type: "array",
728
+ maxItems: 10,
729
+ items: {
730
+ type: "object",
731
+ additionalProperties: false,
732
+ required: ["field"],
733
+ properties: {
734
+ field: dataAggregateAlias,
735
+ direction: { enum: ["asc", "desc"] },
736
+ nulls: { enum: ["first", "last"] },
737
+ },
738
+ },
739
+ },
740
+ limit: { type: "integer", minimum: 1, maximum: 100 },
741
+ offset: { type: "integer", minimum: 0, maximum: 1000000 },
742
+ },
743
+ };
744
+ export const dataAggregatePageSchema = {
745
+ $id: SCHEMA_VERSIONS.dataAggregatePage,
746
+ type: "object",
747
+ additionalProperties: false,
748
+ required: ["schemaVersion", "resourceCode", "items", "total", "limit", "offset"],
749
+ properties: {
750
+ schemaVersion: { const: SCHEMA_VERSIONS.dataAggregatePage },
751
+ resourceCode: dataResourceCode,
752
+ items: { type: "array", items: { type: "object" } },
753
+ total: { type: "integer", minimum: 0 },
754
+ limit: { type: "integer", minimum: 1, maximum: 100 },
755
+ offset: { type: "integer", minimum: 0 },
756
+ },
757
+ };
758
+ export const dataAuditPageSchema = {
759
+ $id: SCHEMA_VERSIONS.dataAuditPage,
760
+ type: "object",
761
+ additionalProperties: false,
762
+ required: ["schemaVersion", "resourceCode", "recordId", "items", "total", "limit", "offset"],
763
+ properties: {
764
+ schemaVersion: { const: SCHEMA_VERSIONS.dataAuditPage },
765
+ resourceCode: dataResourceCode,
766
+ recordId: nonEmptyString,
767
+ items: { type: "array", items: { type: "object" } },
768
+ total: { type: "integer", minimum: 0 },
769
+ limit: { type: "integer", minimum: 1, maximum: 100 },
770
+ offset: { type: "integer", minimum: 0 },
771
+ },
772
+ };
773
+ export const dataFileRefSchema = {
774
+ $id: SCHEMA_VERSIONS.dataFileRef,
775
+ type: "object",
776
+ additionalProperties: false,
777
+ required: ["schemaVersion", "id", "name", "size", "contentType"],
778
+ properties: {
779
+ schemaVersion: { const: SCHEMA_VERSIONS.dataFileRef },
780
+ id: nonEmptyString,
781
+ name: nonEmptyString,
782
+ size: { type: "integer", minimum: 0 },
783
+ contentType: { type: "string" },
784
+ },
785
+ };
786
+ export const dataFileUploadPlanSchema = {
787
+ $id: SCHEMA_VERSIONS.dataFileUploadPlan,
788
+ type: "object",
789
+ additionalProperties: false,
790
+ required: ["schemaVersion", "resourceCode", "fieldCode", "file", "uploadMethod", "uploadUrl", "headers", "expiresAt"],
791
+ properties: {
792
+ schemaVersion: { const: SCHEMA_VERSIONS.dataFileUploadPlan },
793
+ resourceCode: dataResourceCode,
794
+ fieldCode: dataFieldCode,
795
+ file: { $ref: SCHEMA_VERSIONS.dataFileRef },
796
+ uploadMethod: { const: "PUT" },
797
+ uploadUrl: nonEmptyString,
798
+ headers: { type: "object", additionalProperties: { type: "string" } },
799
+ expiresAt: dateTime,
800
+ },
801
+ };
802
+ const dataTransactionOperation = {
803
+ oneOf: [
804
+ {
805
+ type: "object",
806
+ additionalProperties: false,
807
+ required: ["operation", "resourceCode", "data"],
808
+ properties: {
809
+ operation: { const: "create" },
810
+ resourceCode: dataResourceCode,
811
+ data: { type: "object" },
812
+ },
813
+ },
814
+ {
815
+ type: "object",
816
+ additionalProperties: false,
817
+ required: ["operation", "resourceCode", "id", "expectedRevision", "data"],
818
+ properties: {
819
+ operation: { const: "update" },
820
+ resourceCode: dataResourceCode,
821
+ id: nonEmptyString,
822
+ expectedRevision: { type: "integer", minimum: 1 },
823
+ data: { type: "object" },
824
+ },
825
+ },
826
+ {
827
+ type: "object",
828
+ additionalProperties: false,
829
+ required: ["operation", "resourceCode", "id", "expectedRevision"],
830
+ properties: {
831
+ operation: { const: "delete" },
832
+ resourceCode: dataResourceCode,
833
+ id: nonEmptyString,
834
+ expectedRevision: { type: "integer", minimum: 1 },
835
+ },
836
+ },
837
+ ],
838
+ };
839
+ export const dataTransactionRequestSchema = {
840
+ $id: SCHEMA_VERSIONS.dataTransactionRequest,
841
+ type: "object",
842
+ additionalProperties: false,
843
+ required: ["schemaVersion", "idempotencyKey", "operations"],
844
+ properties: {
845
+ schemaVersion: { const: SCHEMA_VERSIONS.dataTransactionRequest },
846
+ idempotencyKey: nonEmptyString,
847
+ operations: {
848
+ type: "array",
849
+ minItems: 1,
850
+ maxItems: 100,
851
+ items: dataTransactionOperation,
852
+ },
853
+ },
854
+ };
855
+ export const dataTransactionResultSchema = {
856
+ $id: SCHEMA_VERSIONS.dataTransactionResult,
857
+ type: "object",
858
+ additionalProperties: false,
859
+ required: ["schemaVersion", "idempotencyKey", "replayed", "items"],
860
+ properties: {
861
+ schemaVersion: { const: SCHEMA_VERSIONS.dataTransactionResult },
862
+ idempotencyKey: nonEmptyString,
863
+ replayed: { type: "boolean" },
864
+ items: {
865
+ type: "array",
866
+ maxItems: 100,
867
+ items: {
868
+ type: "object",
869
+ additionalProperties: false,
870
+ required: ["index", "resourceCode", "operation", "id", "revision"],
871
+ properties: {
872
+ index: { type: "integer", minimum: 0 },
873
+ resourceCode: dataResourceCode,
874
+ operation: { enum: ["create", "update", "delete"] },
875
+ id: nonEmptyString,
876
+ revision: { type: "integer", minimum: 1 },
877
+ },
878
+ },
879
+ },
880
+ },
881
+ };
882
+ export const appPackageSchema = {
883
+ $id: SCHEMA_VERSIONS.appPackage,
884
+ type: "object",
885
+ additionalProperties: false,
886
+ required: [
887
+ "schemaVersion",
888
+ "appCode",
889
+ "version",
890
+ "createdAt",
891
+ "source",
892
+ "toolchain",
893
+ "artifacts",
894
+ "manifests",
895
+ "compatibility",
896
+ ],
897
+ properties: {
898
+ schemaVersion: { const: SCHEMA_VERSIONS.appPackage },
899
+ appCode: nonEmptyString,
900
+ version: nonEmptyString,
901
+ createdAt: dateTime,
902
+ source: {
903
+ type: "object",
904
+ additionalProperties: false,
905
+ required: ["repository", "commit", "dirty"],
906
+ properties: {
907
+ repository: nonEmptyString,
908
+ commit: nonEmptyString,
909
+ dirty: { type: "boolean" },
910
+ },
911
+ },
912
+ toolchain: {
913
+ type: "object",
914
+ additionalProperties: false,
915
+ required: ["version", "contractVersion"],
916
+ properties: {
917
+ version: nonEmptyString,
918
+ contractVersion: { const: OPENXIANGDA_CONTRACT_VERSION },
919
+ },
920
+ },
921
+ artifacts: {
922
+ type: "array",
923
+ items: {
924
+ type: "object",
925
+ additionalProperties: false,
926
+ required: ["kind", "digest", "mediaType"],
927
+ properties: {
928
+ kind: {
929
+ enum: ["frontend", "backend", "config", "contracts"],
930
+ },
931
+ digest,
932
+ mediaType: nonEmptyString,
933
+ size: { type: "integer", minimum: 0 },
934
+ entrypoint: { type: "string" },
935
+ metadata: { type: "object" },
936
+ },
937
+ },
938
+ },
939
+ manifests: {
940
+ type: "object",
941
+ additionalProperties: false,
942
+ properties: {
943
+ frontend: digest,
944
+ backend: digest,
945
+ config: digest,
946
+ dataContract: digest,
947
+ },
948
+ },
949
+ compatibility: {
950
+ type: "object",
951
+ additionalProperties: false,
952
+ required: ["minimumPlatformVersion", "requiredCapabilities"],
953
+ properties: {
954
+ minimumPlatformVersion: nonEmptyString,
955
+ requiredCapabilities: {
956
+ type: "array",
957
+ uniqueItems: true,
958
+ items: nonEmptyString,
959
+ },
960
+ },
961
+ },
962
+ metadata: { type: "object" },
963
+ },
964
+ };
965
+ const componentRevisions = {
966
+ type: "object",
967
+ additionalProperties: false,
968
+ required: ["frontend", "backend", "config", "dataContract"],
969
+ properties: {
970
+ frontend: { type: ["string", "null"] },
971
+ backend: { type: ["string", "null"] },
972
+ config: { type: ["string", "null"] },
973
+ dataContract: { type: ["string", "null"] },
974
+ },
975
+ };
976
+ export const appVersionSchema = {
977
+ $id: SCHEMA_VERSIONS.appVersion,
978
+ type: "object",
979
+ additionalProperties: false,
980
+ required: [
981
+ "schemaVersion",
982
+ "id",
983
+ "appCode",
984
+ "version",
985
+ "packageDigest",
986
+ "source",
987
+ "toolchain",
988
+ "revisions",
989
+ "metadata",
990
+ "createdBy",
991
+ "createdAt",
992
+ ],
993
+ properties: {
994
+ schemaVersion: { const: SCHEMA_VERSIONS.appVersion },
995
+ id: nonEmptyString,
996
+ appCode: nonEmptyString,
997
+ version: nonEmptyString,
998
+ packageDigest: digest,
999
+ source: appPackageSchema.properties.source,
1000
+ toolchain: appPackageSchema.properties.toolchain,
1001
+ revisions: componentRevisions,
1002
+ metadata: { type: "object" },
1003
+ createdBy: nonEmptyString,
1004
+ createdAt: dateTime,
1005
+ },
1006
+ };
1007
+ export const environmentHeadSchema = {
1008
+ $id: SCHEMA_VERSIONS.environmentHead,
1009
+ type: "object",
1010
+ additionalProperties: false,
1011
+ required: [
1012
+ "schemaVersion",
1013
+ "id",
1014
+ "appCode",
1015
+ "environmentKey",
1016
+ "environmentId",
1017
+ "environmentKind",
1018
+ "activeAppVersionId",
1019
+ "revisions",
1020
+ "revision",
1021
+ "activatedByDeploymentId",
1022
+ "activatedBy",
1023
+ "activatedAt",
1024
+ "updatedAt",
1025
+ ],
1026
+ properties: {
1027
+ schemaVersion: { const: SCHEMA_VERSIONS.environmentHead },
1028
+ id: nonEmptyString,
1029
+ appCode: nonEmptyString,
1030
+ environmentKey: nonEmptyString,
1031
+ environmentId: { type: ["string", "null"] },
1032
+ environmentKind: {
1033
+ enum: ["development", "preproduction", "production"],
1034
+ },
1035
+ activeAppVersionId: nonEmptyString,
1036
+ revisions: componentRevisions,
1037
+ revision: { type: "integer", minimum: 1 },
1038
+ activatedByDeploymentId: nonEmptyString,
1039
+ activatedBy: nonEmptyString,
1040
+ activatedAt: dateTime,
1041
+ updatedAt: dateTime,
1042
+ activeAppVersion: {
1043
+ anyOf: [appVersionSchema, { type: "null" }],
1044
+ },
1045
+ },
1046
+ };
1047
+ const deploymentStatus = {
1048
+ enum: [
1049
+ "queued",
1050
+ "preparing",
1051
+ "deploying",
1052
+ "activating",
1053
+ "verifying",
1054
+ "succeeded",
1055
+ "failed",
1056
+ "cancelled",
1057
+ ],
1058
+ };
1059
+ export const deploymentRunSchema = {
1060
+ $id: SCHEMA_VERSIONS.deploymentRun,
1061
+ type: "object",
1062
+ additionalProperties: false,
1063
+ required: [
1064
+ "schemaVersion",
1065
+ "id",
1066
+ "appCode",
1067
+ "environment",
1068
+ "kind",
1069
+ "packageDigest",
1070
+ "idempotencyKey",
1071
+ "status",
1072
+ "stage",
1073
+ "attempt",
1074
+ "progress",
1075
+ "checkpoints",
1076
+ "result",
1077
+ "requestedBy",
1078
+ "createdAt",
1079
+ "updatedAt",
1080
+ ],
1081
+ properties: {
1082
+ schemaVersion: { const: SCHEMA_VERSIONS.deploymentRun },
1083
+ id: nonEmptyString,
1084
+ appCode: nonEmptyString,
1085
+ environment: {
1086
+ type: "object",
1087
+ additionalProperties: false,
1088
+ properties: {
1089
+ id: { type: "string" },
1090
+ kind: {
1091
+ enum: ["development", "preproduction", "production"],
1092
+ },
1093
+ },
1094
+ },
1095
+ kind: { enum: ["deploy", "promotion", "rollback"] },
1096
+ packageDigest: digest,
1097
+ idempotencyKey: nonEmptyString,
1098
+ status: deploymentStatus,
1099
+ stage: nonEmptyString,
1100
+ attempt: { type: "integer", minimum: 1 },
1101
+ progress: { type: "object" },
1102
+ checkpoints: {
1103
+ type: "array",
1104
+ items: {
1105
+ type: "object",
1106
+ additionalProperties: false,
1107
+ required: ["stage", "status", "at", "attempt"],
1108
+ properties: {
1109
+ stage: nonEmptyString,
1110
+ status: deploymentStatus,
1111
+ at: dateTime,
1112
+ attempt: { type: "integer", minimum: 1 },
1113
+ component: { type: "string" },
1114
+ result: { type: "object" },
1115
+ },
1116
+ },
1117
+ },
1118
+ failure: {
1119
+ type: "object",
1120
+ additionalProperties: false,
1121
+ required: ["code", "message", "retryable"],
1122
+ properties: {
1123
+ code: nonEmptyString,
1124
+ message: nonEmptyString,
1125
+ retryable: { type: "boolean" },
1126
+ stage: { type: "string" },
1127
+ component: { type: "string" },
1128
+ details: { type: "object" },
1129
+ },
1130
+ },
1131
+ result: { type: "object" },
1132
+ requestedBy: nonEmptyString,
1133
+ startedAt: dateTime,
1134
+ finishedAt: dateTime,
1135
+ createdAt: dateTime,
1136
+ updatedAt: dateTime,
1137
+ },
1138
+ };
1139
+ export const platformCapabilitiesSchema = {
1140
+ $id: SCHEMA_VERSIONS.platformCapabilities,
1141
+ type: "object",
1142
+ additionalProperties: false,
1143
+ required: [
1144
+ "schemaVersion",
1145
+ "apiVersion",
1146
+ "contractVersion",
1147
+ "platformVersion",
1148
+ "features",
1149
+ "deployment",
1150
+ ],
1151
+ properties: {
1152
+ schemaVersion: { const: SCHEMA_VERSIONS.platformCapabilities },
1153
+ apiVersion: { const: "v2" },
1154
+ contractVersion: { const: OPENXIANGDA_CONTRACT_VERSION },
1155
+ platformVersion: nonEmptyString,
1156
+ features: {
1157
+ type: "object",
1158
+ additionalProperties: {
1159
+ type: "object",
1160
+ additionalProperties: false,
1161
+ required: ["version", "status"],
1162
+ properties: {
1163
+ version: nonEmptyString,
1164
+ status: { enum: ["available", "preview", "planned"] },
1165
+ },
1166
+ },
1167
+ },
1168
+ deployment: {
1169
+ type: "object",
1170
+ additionalProperties: false,
1171
+ required: ["executionOwner", "durableRuns", "clientCanCheckpoint"],
1172
+ properties: {
1173
+ executionOwner: { const: "platform" },
1174
+ durableRuns: { const: true },
1175
+ clientCanCheckpoint: { const: false },
1176
+ },
1177
+ },
1178
+ oauth2: {
1179
+ type: "object",
1180
+ additionalProperties: false,
1181
+ required: [
1182
+ "tokenEndpoint",
1183
+ "grantTypes",
1184
+ "clientAuthenticationMethods",
1185
+ "accessTokenTtlSeconds",
1186
+ "supportedScopes",
1187
+ "environmentBoundClients",
1188
+ "dualSecretRotation",
1189
+ "defaultRotationGracePeriodSeconds",
1190
+ "clientRateLimit",
1191
+ "auditEvents",
1192
+ ],
1193
+ properties: {
1194
+ tokenEndpoint: nonEmptyString,
1195
+ grantTypes: {
1196
+ type: "array",
1197
+ items: { const: "client_credentials" },
1198
+ },
1199
+ clientAuthenticationMethods: {
1200
+ type: "array",
1201
+ items: { const: "client_secret_basic" },
1202
+ },
1203
+ accessTokenTtlSeconds: { type: "integer", minimum: 1 },
1204
+ supportedScopes: { type: "array", items: nonEmptyString },
1205
+ environmentBoundClients: { type: "boolean" },
1206
+ dualSecretRotation: { type: "boolean" },
1207
+ defaultRotationGracePeriodSeconds: { type: "integer", minimum: 0 },
1208
+ clientRateLimit: { type: "boolean" },
1209
+ auditEvents: { type: "boolean" },
1210
+ },
1211
+ },
1212
+ },
1213
+ };
1214
+ export const cloudEventSchema = {
1215
+ $id: SCHEMA_VERSIONS.cloudEvent,
1216
+ type: "object",
1217
+ additionalProperties: false,
1218
+ required: [
1219
+ "specversion",
1220
+ "id",
1221
+ "source",
1222
+ "type",
1223
+ "time",
1224
+ "datacontenttype",
1225
+ "data",
1226
+ "tenantid",
1227
+ "appcode",
1228
+ "environment",
1229
+ "schemaversion",
1230
+ ],
1231
+ properties: {
1232
+ specversion: { const: "1.0" },
1233
+ id: nonEmptyString,
1234
+ source: nonEmptyString,
1235
+ type: {
1236
+ type: "string",
1237
+ pattern: "^[A-Za-z0-9]+(?:[._-][A-Za-z0-9]+)+$",
1238
+ },
1239
+ subject: { type: "string" },
1240
+ time: dateTime,
1241
+ datacontenttype: { const: "application/json" },
1242
+ dataschema: { type: "string" },
1243
+ data: { type: "object" },
1244
+ tenantid: nonEmptyString,
1245
+ appcode: nonEmptyString,
1246
+ environment: nonEmptyString,
1247
+ traceid: { type: "string" },
1248
+ schemaversion: nonEmptyString,
1249
+ },
1250
+ };
1251
+ export const eventSubscriptionSchema = {
1252
+ $id: SCHEMA_VERSIONS.eventSubscription,
1253
+ type: "object",
1254
+ additionalProperties: false,
1255
+ required: [
1256
+ "schemaVersion",
1257
+ "id",
1258
+ "appCode",
1259
+ "code",
1260
+ "description",
1261
+ "eventTypes",
1262
+ "subjectFilters",
1263
+ "environmentKey",
1264
+ "endpointPath",
1265
+ "delivery",
1266
+ "status",
1267
+ "revision",
1268
+ "createdAt",
1269
+ "updatedAt",
1270
+ ],
1271
+ properties: {
1272
+ schemaVersion: { const: SCHEMA_VERSIONS.eventSubscription },
1273
+ id: nonEmptyString,
1274
+ appCode: nonEmptyString,
1275
+ code: { type: "string", pattern: "^[a-z][a-z0-9-]*$" },
1276
+ description: { type: ["string", "null"] },
1277
+ eventTypes: {
1278
+ type: "array",
1279
+ minItems: 1,
1280
+ maxItems: 100,
1281
+ uniqueItems: true,
1282
+ items: nonEmptyString,
1283
+ },
1284
+ subjectFilters: {
1285
+ type: "object",
1286
+ additionalProperties: false,
1287
+ properties: {
1288
+ equals: { type: "string" },
1289
+ prefix: { type: "string" },
1290
+ suffix: { type: "string" },
1291
+ contains: {
1292
+ anyOf: [
1293
+ { type: "string" },
1294
+ { type: "array", maxItems: 20, items: { type: "string" } },
1295
+ ],
1296
+ },
1297
+ },
1298
+ },
1299
+ environmentKey: nonEmptyString,
1300
+ endpointPath: { type: "string", pattern: "^/(?!/)(?!.*\\.\\.).+" },
1301
+ delivery: {
1302
+ type: "object",
1303
+ additionalProperties: false,
1304
+ required: [
1305
+ "timeoutMs",
1306
+ "maxAttempts",
1307
+ "initialBackoffMs",
1308
+ "maxBackoffMs",
1309
+ ],
1310
+ properties: {
1311
+ timeoutMs: { type: "integer", minimum: 100, maximum: 60000 },
1312
+ maxAttempts: { type: "integer", minimum: 1, maximum: 32 },
1313
+ initialBackoffMs: {
1314
+ type: "integer",
1315
+ minimum: 100,
1316
+ maximum: 300000,
1317
+ },
1318
+ maxBackoffMs: {
1319
+ type: "integer",
1320
+ minimum: 100,
1321
+ maximum: 3600000,
1322
+ },
1323
+ },
1324
+ },
1325
+ status: { enum: ["active", "paused"] },
1326
+ revision: { type: "integer", minimum: 1 },
1327
+ signingSecret: { type: "string" },
1328
+ signingSecretVersion: { type: "integer", minimum: 1 },
1329
+ signingSecretReturnedOnce: { type: "boolean" },
1330
+ createdAt: dateTime,
1331
+ updatedAt: dateTime,
1332
+ },
1333
+ };
1334
+ export const eventDeliverySchema = {
1335
+ $id: SCHEMA_VERSIONS.eventDelivery,
1336
+ type: "object",
1337
+ additionalProperties: false,
1338
+ required: [
1339
+ "schemaVersion",
1340
+ "id",
1341
+ "eventId",
1342
+ "eventType",
1343
+ "subject",
1344
+ "subscriptionId",
1345
+ "subscriptionCode",
1346
+ "status",
1347
+ "attempt",
1348
+ "nextAttemptAt",
1349
+ "deliveredAt",
1350
+ "responseStatus",
1351
+ "responseBodyPreview",
1352
+ "lastError",
1353
+ "replayOfDeliveryId",
1354
+ "createdAt",
1355
+ "updatedAt",
1356
+ ],
1357
+ properties: {
1358
+ schemaVersion: { const: SCHEMA_VERSIONS.eventDelivery },
1359
+ id: nonEmptyString,
1360
+ eventId: nonEmptyString,
1361
+ eventType: nonEmptyString,
1362
+ subject: { type: ["string", "null"] },
1363
+ subscriptionId: nonEmptyString,
1364
+ subscriptionCode: nonEmptyString,
1365
+ status: {
1366
+ enum: [
1367
+ "pending",
1368
+ "delivering",
1369
+ "retry_wait",
1370
+ "succeeded",
1371
+ "dead_lettered",
1372
+ ],
1373
+ },
1374
+ attempt: { type: "integer", minimum: 0 },
1375
+ nextAttemptAt: { anyOf: [dateTime, { type: "null" }] },
1376
+ deliveredAt: { anyOf: [dateTime, { type: "null" }] },
1377
+ responseStatus: { type: ["integer", "null"] },
1378
+ responseBodyPreview: { type: ["string", "null"] },
1379
+ lastError: { type: ["string", "null"] },
1380
+ replayOfDeliveryId: { type: ["string", "null"] },
1381
+ correlation: {
1382
+ type: "object",
1383
+ additionalProperties: false,
1384
+ required: [
1385
+ "eventId",
1386
+ "requestId",
1387
+ "traceId",
1388
+ "environmentKey",
1389
+ "eventOccurredAt",
1390
+ "outboxStatus",
1391
+ "outboxAttempts",
1392
+ "outboxError",
1393
+ ],
1394
+ properties: {
1395
+ eventId: nonEmptyString,
1396
+ requestId: { type: ["string", "null"] },
1397
+ traceId: { type: ["string", "null"] },
1398
+ environmentKey: nonEmptyString,
1399
+ eventOccurredAt: { anyOf: [dateTime, { type: "null" }] },
1400
+ outboxStatus: { type: ["string", "null"] },
1401
+ outboxAttempts: { type: "integer", minimum: 0 },
1402
+ outboxError: { type: ["string", "null"] },
1403
+ },
1404
+ },
1405
+ createdAt: dateTime,
1406
+ updatedAt: dateTime,
1407
+ },
1408
+ };
1409
+ export const eventReceiptCommandSchema = {
1410
+ $id: SCHEMA_VERSIONS.eventReceiptCommand,
1411
+ type: "object",
1412
+ additionalProperties: false,
1413
+ required: [
1414
+ "schemaVersion",
1415
+ "action",
1416
+ "tenantId",
1417
+ "appCode",
1418
+ "environmentKey",
1419
+ "subscriptionCode",
1420
+ "eventId",
1421
+ "deliveryId",
1422
+ ],
1423
+ properties: {
1424
+ schemaVersion: { const: SCHEMA_VERSIONS.eventReceiptCommand },
1425
+ action: { enum: ["claim", "complete", "release"] },
1426
+ tenantId: nonEmptyString,
1427
+ appCode: nonEmptyString,
1428
+ environmentKey: nonEmptyString,
1429
+ subscriptionCode: {
1430
+ type: "string",
1431
+ pattern: "^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$",
1432
+ },
1433
+ eventId: nonEmptyString,
1434
+ deliveryId: {
1435
+ type: "string",
1436
+ format: "uuid",
1437
+ },
1438
+ claimToken: {
1439
+ type: "string",
1440
+ format: "uuid",
1441
+ },
1442
+ },
1443
+ };
1444
+ export const eventReceiptResultSchema = {
1445
+ $id: SCHEMA_VERSIONS.eventReceiptResult,
1446
+ type: "object",
1447
+ additionalProperties: false,
1448
+ required: [
1449
+ "schemaVersion",
1450
+ "outcome",
1451
+ "eventId",
1452
+ "deliveryId",
1453
+ "status",
1454
+ "claimToken",
1455
+ "attempts",
1456
+ "leaseExpiresAt",
1457
+ "completedAt",
1458
+ ],
1459
+ properties: {
1460
+ schemaVersion: { const: SCHEMA_VERSIONS.eventReceiptResult },
1461
+ outcome: { enum: ["claimed", "duplicate", "completed", "released"] },
1462
+ eventId: nonEmptyString,
1463
+ deliveryId: {
1464
+ type: "string",
1465
+ format: "uuid",
1466
+ },
1467
+ status: { enum: ["processing", "succeeded", "released"] },
1468
+ claimToken: { type: ["string", "null"], format: "uuid" },
1469
+ attempts: { type: "integer", minimum: 1 },
1470
+ leaseExpiresAt: dateTime,
1471
+ completedAt: { anyOf: [dateTime, { type: "null" }] },
1472
+ },
1473
+ };
1474
+ export const applicationSecretSchema = {
1475
+ $id: SCHEMA_VERSIONS.applicationSecret,
1476
+ type: "object",
1477
+ additionalProperties: true,
1478
+ required: [
1479
+ "schemaVersion",
1480
+ "id",
1481
+ "appCode",
1482
+ "environmentKey",
1483
+ "name",
1484
+ "description",
1485
+ "status",
1486
+ "revision",
1487
+ "hasValue",
1488
+ "expiresAt",
1489
+ "createdAt",
1490
+ "updatedAt",
1491
+ ],
1492
+ properties: {
1493
+ schemaVersion: { const: SCHEMA_VERSIONS.applicationSecret },
1494
+ id: nonEmptyString,
1495
+ appCode: nonEmptyString,
1496
+ environmentKey: nonEmptyString,
1497
+ name: { type: "string", pattern: "^[a-z][a-z0-9]*([-_][a-z0-9]+)*$" },
1498
+ description: { type: ["string", "null"] },
1499
+ status: { enum: ["active", "disabled", "deleted"] },
1500
+ revision: { type: "integer", minimum: 1 },
1501
+ hasValue: { type: "boolean" },
1502
+ expiresAt: { anyOf: [dateTime, { type: "null" }] },
1503
+ createdAt: dateTime,
1504
+ updatedAt: dateTime,
1505
+ },
1506
+ };
1507
+ export const timerSubscriptionSchema = {
1508
+ $id: SCHEMA_VERSIONS.timerSubscription,
1509
+ type: "object",
1510
+ additionalProperties: false,
1511
+ required: [
1512
+ "schemaVersion",
1513
+ "id",
1514
+ "appCode",
1515
+ "code",
1516
+ "eventType",
1517
+ "cronExpression",
1518
+ "timezone",
1519
+ "payload",
1520
+ "environmentKey",
1521
+ "status",
1522
+ "revision",
1523
+ "nextDueAt",
1524
+ "lastFiredAt",
1525
+ "createdAt",
1526
+ "updatedAt",
1527
+ ],
1528
+ properties: {
1529
+ schemaVersion: { const: SCHEMA_VERSIONS.timerSubscription },
1530
+ id: nonEmptyString,
1531
+ appCode: nonEmptyString,
1532
+ code: { type: "string", pattern: "^[a-z][a-z0-9-]*$" },
1533
+ eventType: nonEmptyString,
1534
+ cronExpression: nonEmptyString,
1535
+ timezone: nonEmptyString,
1536
+ payload: { type: "object" },
1537
+ environmentKey: nonEmptyString,
1538
+ status: { enum: ["active", "paused"] },
1539
+ revision: { type: "integer", minimum: 1 },
1540
+ nextDueAt: { anyOf: [dateTime, { type: "null" }] },
1541
+ lastFiredAt: { anyOf: [dateTime, { type: "null" }] },
1542
+ createdAt: dateTime,
1543
+ updatedAt: dateTime,
1544
+ },
1545
+ };
1546
+ const workflowExpressionSchema = {
1547
+ type: "object",
1548
+ required: ["op"],
1549
+ properties: {
1550
+ op: {
1551
+ enum: [
1552
+ "literal",
1553
+ "path",
1554
+ "eq",
1555
+ "neq",
1556
+ "gt",
1557
+ "gte",
1558
+ "lt",
1559
+ "lte",
1560
+ "in",
1561
+ "contains",
1562
+ "and",
1563
+ "or",
1564
+ "not",
1565
+ "exists",
1566
+ ],
1567
+ },
1568
+ value: {},
1569
+ path: { type: "string", pattern: "^[A-Za-z][A-Za-z0-9_.]{0,254}$" },
1570
+ left: { type: "object" },
1571
+ right: { type: "object" },
1572
+ values: { type: "array", minItems: 1, items: { type: "object" } },
1573
+ },
1574
+ };
1575
+ const workflowNodeSchema = {
1576
+ oneOf: [
1577
+ {
1578
+ type: "object",
1579
+ additionalProperties: false,
1580
+ required: [
1581
+ "id",
1582
+ "kind",
1583
+ "title",
1584
+ "binding",
1585
+ "mode",
1586
+ "onApprove",
1587
+ "onReject",
1588
+ ],
1589
+ properties: {
1590
+ id: nonEmptyString,
1591
+ kind: { const: "approval" },
1592
+ title: nonEmptyString,
1593
+ binding: nonEmptyString,
1594
+ mode: { enum: ["single", "any", "all", "sequence"] },
1595
+ onApprove: nonEmptyString,
1596
+ onReject: nonEmptyString,
1597
+ allowedOperations: {
1598
+ type: "array",
1599
+ uniqueItems: true,
1600
+ items: {
1601
+ enum: [
1602
+ "approve",
1603
+ "reject",
1604
+ "return",
1605
+ "transfer",
1606
+ "delegate",
1607
+ "add_assignee",
1608
+ "resubmit",
1609
+ "admin_reassign",
1610
+ "admin_override",
1611
+ ],
1612
+ },
1613
+ },
1614
+ returnTargets: {
1615
+ type: "array",
1616
+ uniqueItems: true,
1617
+ items: nonEmptyString,
1618
+ },
1619
+ fieldPolicy: {
1620
+ type: "object",
1621
+ additionalProperties: false,
1622
+ properties: {
1623
+ default: {
1624
+ enum: ["hidden", "readonly", "edit", "edit_required"],
1625
+ },
1626
+ fields: {
1627
+ type: "object",
1628
+ additionalProperties: {
1629
+ enum: ["hidden", "readonly", "edit", "edit_required"],
1630
+ },
1631
+ },
1632
+ },
1633
+ },
1634
+ },
1635
+ },
1636
+ {
1637
+ type: "object",
1638
+ additionalProperties: false,
1639
+ required: ["id", "kind", "branches", "otherwise"],
1640
+ properties: {
1641
+ id: nonEmptyString,
1642
+ kind: { const: "condition" },
1643
+ title: { type: "string" },
1644
+ branches: {
1645
+ type: "array",
1646
+ minItems: 1,
1647
+ items: {
1648
+ type: "object",
1649
+ additionalProperties: false,
1650
+ required: ["when", "target"],
1651
+ properties: {
1652
+ when: workflowExpressionSchema,
1653
+ target: nonEmptyString,
1654
+ label: { type: "string" },
1655
+ },
1656
+ },
1657
+ },
1658
+ otherwise: nonEmptyString,
1659
+ },
1660
+ },
1661
+ {
1662
+ type: "object",
1663
+ additionalProperties: false,
1664
+ required: ["id", "kind", "title", "outcome"],
1665
+ properties: {
1666
+ id: nonEmptyString,
1667
+ kind: { const: "end" },
1668
+ title: nonEmptyString,
1669
+ outcome: nonEmptyString,
1670
+ },
1671
+ },
1672
+ ],
1673
+ };
1674
+ export const workflowDefinitionSchema = {
1675
+ $id: SCHEMA_VERSIONS.workflowDefinition,
1676
+ type: "object",
1677
+ additionalProperties: false,
1678
+ required: [
1679
+ "schemaVersion",
1680
+ "code",
1681
+ "title",
1682
+ "startAt",
1683
+ "inputSchema",
1684
+ "nodes",
1685
+ ],
1686
+ properties: {
1687
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowDefinition },
1688
+ code: { type: "string", pattern: "^[A-Za-z][A-Za-z0-9_-]{0,127}$" },
1689
+ title: nonEmptyString,
1690
+ startAt: nonEmptyString,
1691
+ inputSchema: { type: "object" },
1692
+ organizationContext: {
1693
+ type: "object",
1694
+ additionalProperties: false,
1695
+ properties: {
1696
+ department: {
1697
+ type: "object",
1698
+ additionalProperties: false,
1699
+ required: ["source"],
1700
+ properties: {
1701
+ source: {
1702
+ enum: [
1703
+ "none",
1704
+ "user_primary_department",
1705
+ "choose_if_multiple",
1706
+ "always_choose",
1707
+ "fixed",
1708
+ "from_input",
1709
+ "from_role_scope",
1710
+ ],
1711
+ },
1712
+ required: { type: "boolean" },
1713
+ value: { type: "string" },
1714
+ path: { type: "string" },
1715
+ dimension: { type: "string" },
1716
+ },
1717
+ },
1718
+ },
1719
+ },
1720
+ nodes: {
1721
+ type: "object",
1722
+ minProperties: 1,
1723
+ maxProperties: 200,
1724
+ additionalProperties: workflowNodeSchema,
1725
+ },
1726
+ },
1727
+ };
1728
+ export const workflowBindingSchema = {
1729
+ $id: SCHEMA_VERSIONS.workflowBinding,
1730
+ type: "object",
1731
+ additionalProperties: false,
1732
+ required: ["schemaVersion", "workflowCode", "bindings"],
1733
+ properties: {
1734
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowBinding },
1735
+ workflowCode: nonEmptyString,
1736
+ bindings: {
1737
+ type: "object",
1738
+ maxProperties: 200,
1739
+ additionalProperties: {
1740
+ type: "object",
1741
+ additionalProperties: false,
1742
+ required: ["provider"],
1743
+ properties: {
1744
+ provider: {
1745
+ enum: [
1746
+ "fixed_users",
1747
+ "initiator",
1748
+ "input_users",
1749
+ "form_field_users",
1750
+ "department_supervisor",
1751
+ "app_role",
1752
+ "app_role_in_scope",
1753
+ "business_relation",
1754
+ "previous_node_actor",
1755
+ "initiator_select",
1756
+ "application_provider",
1757
+ ],
1758
+ },
1759
+ users: { type: "array", uniqueItems: true, items: nonEmptyString },
1760
+ inputPath: { type: "string" },
1761
+ departmentIdFrom: { type: "string" },
1762
+ level: { type: "integer", minimum: 1, maximum: 20 },
1763
+ fallbackToAncestorSupervisor: { type: "boolean" },
1764
+ roleCode: { type: "string" },
1765
+ scope: {
1766
+ type: "object",
1767
+ additionalProperties: false,
1768
+ required: ["dimension"],
1769
+ properties: {
1770
+ dimension: nonEmptyString,
1771
+ valueFrom: { type: "string" },
1772
+ value: { type: "string" },
1773
+ },
1774
+ },
1775
+ relationCode: { type: "string" },
1776
+ resourceCode: { type: "string" },
1777
+ resourceIdFrom: { type: "string" },
1778
+ providerCode: { type: "string" },
1779
+ min: { type: "integer", minimum: 1 },
1780
+ max: { type: "integer", minimum: 1 },
1781
+ },
1782
+ },
1783
+ },
1784
+ },
1785
+ };
1786
+ export const workflowPreparationSchema = {
1787
+ $id: SCHEMA_VERSIONS.workflowPreparation,
1788
+ type: "object",
1789
+ additionalProperties: false,
1790
+ required: [
1791
+ "schemaVersion",
1792
+ "preparationId",
1793
+ "status",
1794
+ "requirements",
1795
+ "preparationToken",
1796
+ "preview",
1797
+ "expiresAt",
1798
+ "definitionVersion",
1799
+ "bindingVersion",
1800
+ "inputHash",
1801
+ ],
1802
+ properties: {
1803
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowPreparation },
1804
+ preparationId: nonEmptyString,
1805
+ status: { enum: ["needs_input", "ready"] },
1806
+ requirements: {
1807
+ type: "array",
1808
+ items: {
1809
+ type: "object",
1810
+ required: ["id", "kind", "title"],
1811
+ properties: {
1812
+ id: nonEmptyString,
1813
+ kind: nonEmptyString,
1814
+ title: nonEmptyString,
1815
+ required: { type: "boolean" },
1816
+ min: { type: "integer", minimum: 1 },
1817
+ max: { type: "integer", minimum: 1 },
1818
+ candidates: { type: "array", items: { type: "object" } },
1819
+ inputSchema: { type: "object" },
1820
+ uiSchema: { type: "object" },
1821
+ },
1822
+ },
1823
+ },
1824
+ preparationToken: { type: ["string", "null"] },
1825
+ preview: { type: "object" },
1826
+ expiresAt: dateTime,
1827
+ definitionVersion: { type: "integer", minimum: 1 },
1828
+ bindingVersion: { type: "integer", minimum: 1 },
1829
+ inputHash: digest,
1830
+ },
1831
+ };
1832
+ export const workflowInstanceSchema = {
1833
+ $id: SCHEMA_VERSIONS.workflowInstance,
1834
+ type: "object",
1835
+ required: [
1836
+ "engineVersion",
1837
+ "id",
1838
+ "appCode",
1839
+ "workflowCode",
1840
+ "status",
1841
+ "version",
1842
+ ],
1843
+ properties: {
1844
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowInstance },
1845
+ engineVersion: { const: "2.0" },
1846
+ id: nonEmptyString,
1847
+ appCode: nonEmptyString,
1848
+ environmentKey: nonEmptyString,
1849
+ workflowCode: nonEmptyString,
1850
+ status: {
1851
+ enum: [
1852
+ "running",
1853
+ "returned",
1854
+ "approved",
1855
+ "rejected",
1856
+ "withdrawn",
1857
+ "terminated",
1858
+ "error",
1859
+ ],
1860
+ },
1861
+ version: { type: "integer", minimum: 1 },
1862
+ },
1863
+ };
1864
+ export const workflowTaskSchema = {
1865
+ $id: SCHEMA_VERSIONS.workflowTask,
1866
+ type: "object",
1867
+ required: [
1868
+ "engineVersion",
1869
+ "id",
1870
+ "instanceId",
1871
+ "nodeId",
1872
+ "status",
1873
+ "taskKind",
1874
+ "originTaskId",
1875
+ "returnSessionId",
1876
+ "version",
1877
+ ],
1878
+ properties: {
1879
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowTask },
1880
+ engineVersion: { const: "2.0" },
1881
+ id: nonEmptyString,
1882
+ instanceId: nonEmptyString,
1883
+ nodeId: nonEmptyString,
1884
+ status: {
1885
+ enum: [
1886
+ "assignment_pending",
1887
+ "assigned",
1888
+ "completed",
1889
+ "rejected",
1890
+ "returned",
1891
+ "cancelled",
1892
+ "expired",
1893
+ ],
1894
+ },
1895
+ taskKind: { enum: ["normal", "return_review", "resume"] },
1896
+ originTaskId: { type: ["string", "null"] },
1897
+ returnSessionId: { type: ["string", "null"] },
1898
+ version: { type: "integer", minimum: 1 },
1899
+ },
1900
+ };
1901
+ export const workflowSurfaceSchema = {
1902
+ $id: SCHEMA_VERSIONS.workflowSurface,
1903
+ type: "object",
1904
+ additionalProperties: false,
1905
+ required: [
1906
+ "protocolVersion",
1907
+ "surfaceRevision",
1908
+ "engineVersion",
1909
+ "instance",
1910
+ "task",
1911
+ "presentation",
1912
+ "fieldPolicy",
1913
+ "operations",
1914
+ "extensions",
1915
+ ],
1916
+ properties: {
1917
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowSurface },
1918
+ protocolVersion: { const: "workflow_surface_v2" },
1919
+ surfaceRevision: digest,
1920
+ engineVersion: { const: "2.0" },
1921
+ instance: { type: "object" },
1922
+ task: { anyOf: [{ type: "object" }, { type: "null" }] },
1923
+ presentation: { type: "object" },
1924
+ fieldPolicy: { type: "object" },
1925
+ operations: { type: "array", items: { type: "object" } },
1926
+ extensions: { type: "object" },
1927
+ },
1928
+ };
1929
+ export const workflowDelegationSchema = {
1930
+ $id: SCHEMA_VERSIONS.workflowDelegation,
1931
+ type: "object",
1932
+ additionalProperties: false,
1933
+ required: [
1934
+ "schemaVersion",
1935
+ "id",
1936
+ "appCode",
1937
+ "workflowCode",
1938
+ "delegatorUserId",
1939
+ "delegateUserId",
1940
+ "delegatorRoleAssignmentId",
1941
+ "delegateRoleAssignmentId",
1942
+ "validFrom",
1943
+ "validTo",
1944
+ "status",
1945
+ "reason",
1946
+ "createdBy",
1947
+ "createdAt",
1948
+ "revokedAt",
1949
+ ],
1950
+ properties: {
1951
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowDelegation },
1952
+ id: nonEmptyString,
1953
+ appCode: nonEmptyString,
1954
+ workflowCode: { type: ["string", "null"] },
1955
+ delegatorUserId: nonEmptyString,
1956
+ delegateUserId: nonEmptyString,
1957
+ delegatorRoleAssignmentId: nonEmptyString,
1958
+ delegateRoleAssignmentId: nonEmptyString,
1959
+ validFrom: dateTime,
1960
+ validTo: dateTime,
1961
+ status: { enum: ["active", "revoked", "expired"] },
1962
+ reason: nonEmptyString,
1963
+ createdBy: nonEmptyString,
1964
+ createdAt: dateTime,
1965
+ revokedAt: { anyOf: [dateTime, { type: "null" }] },
1966
+ },
1967
+ };
1968
+ export const workflowAssigneeProviderSchema = {
1969
+ $id: SCHEMA_VERSIONS.workflowAssigneeProvider,
1970
+ type: "object",
1971
+ required: [
1972
+ "schemaVersion",
1973
+ "id",
1974
+ "appCode",
1975
+ "environmentKey",
1976
+ "code",
1977
+ "endpointPath",
1978
+ "timeoutMs",
1979
+ "status",
1980
+ "signingSecretVersion",
1981
+ "pendingSigningSecretVersion",
1982
+ "rotationPending",
1983
+ "revision",
1984
+ "createdAt",
1985
+ "updatedAt",
1986
+ ],
1987
+ properties: {
1988
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowAssigneeProvider },
1989
+ id: nonEmptyString,
1990
+ appCode: nonEmptyString,
1991
+ environmentKey: nonEmptyString,
1992
+ code: nonEmptyString,
1993
+ endpointPath: nonEmptyString,
1994
+ timeoutMs: { type: "integer", minimum: 100, maximum: 10000 },
1995
+ status: { enum: ["active", "paused"] },
1996
+ signingSecretVersion: { type: "integer", minimum: 1 },
1997
+ pendingSigningSecretVersion: {
1998
+ type: ["integer", "null"],
1999
+ minimum: 2,
2000
+ },
2001
+ rotationPending: { type: "boolean" },
2002
+ revision: { type: "integer", minimum: 1 },
2003
+ signingSecret: { type: ["string", "null"] },
2004
+ signingSecretReturnedOnce: { type: "boolean" },
2005
+ createdAt: dateTime,
2006
+ updatedAt: dateTime,
2007
+ },
2008
+ };
2009
+ export const workflowAssigneeRequestSchema = {
2010
+ $id: SCHEMA_VERSIONS.workflowAssigneeRequest,
2011
+ type: "object",
2012
+ additionalProperties: false,
2013
+ required: [
2014
+ "schemaVersion",
2015
+ "requestId",
2016
+ "providerCode",
2017
+ "appCode",
2018
+ "environmentKey",
2019
+ "workflowCode",
2020
+ "nodeId",
2021
+ "facts",
2022
+ "organizationContext",
2023
+ "initiator",
2024
+ "authzVersion",
2025
+ ],
2026
+ properties: {
2027
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowAssigneeRequest },
2028
+ requestId: nonEmptyString,
2029
+ providerCode: nonEmptyString,
2030
+ appCode: nonEmptyString,
2031
+ environmentKey: nonEmptyString,
2032
+ workflowCode: nonEmptyString,
2033
+ nodeId: nonEmptyString,
2034
+ facts: { type: "object" },
2035
+ organizationContext: { type: "object" },
2036
+ initiator: { type: "object" },
2037
+ authzVersion: { type: "integer", minimum: 1 },
2038
+ },
2039
+ };
2040
+ export const workflowAssigneeResponseSchema = {
2041
+ $id: SCHEMA_VERSIONS.workflowAssigneeResponse,
2042
+ type: "object",
2043
+ additionalProperties: false,
2044
+ required: ["schemaVersion", "requestId", "candidates"],
2045
+ properties: {
2046
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowAssigneeResponse },
2047
+ requestId: nonEmptyString,
2048
+ candidates: {
2049
+ type: "array",
2050
+ maxItems: 200,
2051
+ items: {
2052
+ type: "object",
2053
+ required: ["userId", "source"],
2054
+ properties: {
2055
+ userId: nonEmptyString,
2056
+ roleAssignmentId: nonEmptyString,
2057
+ roleCode: nonEmptyString,
2058
+ displayName: nonEmptyString,
2059
+ source: nonEmptyString,
2060
+ },
2061
+ },
2062
+ },
2063
+ },
2064
+ };
2065
+ export const workflowKernelDescriptorSchema = {
2066
+ $id: SCHEMA_VERSIONS.workflowKernelDescriptor,
2067
+ type: "object",
2068
+ additionalProperties: false,
2069
+ required: [
2070
+ "schemaVersion",
2071
+ "engineVersion",
2072
+ "instanceId",
2073
+ "appCode",
2074
+ "status",
2075
+ "businessKey",
2076
+ "routes",
2077
+ "authorizationMode",
2078
+ ],
2079
+ properties: {
2080
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowKernelDescriptor },
2081
+ engineVersion: { const: "2.0" },
2082
+ instanceId: nonEmptyString,
2083
+ appCode: nonEmptyString,
2084
+ status: nonEmptyString,
2085
+ businessKey: { type: ["string", "null"] },
2086
+ routes: {
2087
+ type: "object",
2088
+ minProperties: 1,
2089
+ additionalProperties: nonEmptyString,
2090
+ },
2091
+ authorizationMode: { const: "role_session_v2" },
2092
+ },
2093
+ };
2094
+ export const workflowKernelWorkItemSchema = {
2095
+ $id: SCHEMA_VERSIONS.workflowKernelWorkItem,
2096
+ type: "object",
2097
+ additionalProperties: false,
2098
+ required: [
2099
+ "schemaVersion",
2100
+ "engineVersion",
2101
+ "appCode",
2102
+ "instanceId",
2103
+ "taskId",
2104
+ "workflowCode",
2105
+ "businessKey",
2106
+ "status",
2107
+ "nodeId",
2108
+ "title",
2109
+ "dataRef",
2110
+ "updatedAt",
2111
+ "startedAt",
2112
+ "descriptorHref",
2113
+ "surfaceHref",
2114
+ "authorizationMode",
2115
+ ],
2116
+ properties: {
2117
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowKernelWorkItem },
2118
+ engineVersion: { const: "2.0" },
2119
+ appCode: nonEmptyString,
2120
+ instanceId: nonEmptyString,
2121
+ taskId: { type: ["string", "null"] },
2122
+ workflowCode: { type: ["string", "null"] },
2123
+ businessKey: { type: ["string", "null"] },
2124
+ status: nonEmptyString,
2125
+ nodeId: { type: ["string", "null"] },
2126
+ title: { type: ["string", "null"] },
2127
+ dataRef: { anyOf: [{ type: "object" }, { type: "null" }] },
2128
+ updatedAt: dateTime,
2129
+ startedAt: dateTime,
2130
+ descriptorHref: nonEmptyString,
2131
+ surfaceHref: nonEmptyString,
2132
+ authorizationMode: { const: "role_session_v2" },
2133
+ },
2134
+ };
2135
+ export const workflowKernelWorkCenterSchema = {
2136
+ $id: SCHEMA_VERSIONS.workflowKernelWorkCenter,
2137
+ type: "object",
2138
+ additionalProperties: false,
2139
+ required: [
2140
+ "schemaVersion",
2141
+ "category",
2142
+ "roleSessionId",
2143
+ "activeRoleAssignmentId",
2144
+ "items",
2145
+ "engineCounts",
2146
+ ],
2147
+ properties: {
2148
+ schemaVersion: { const: SCHEMA_VERSIONS.workflowKernelWorkCenter },
2149
+ category: { enum: ["pending", "completed", "created"] },
2150
+ roleSessionId: nonEmptyString,
2151
+ activeRoleAssignmentId: nonEmptyString,
2152
+ items: {
2153
+ type: "array",
2154
+ items: { $ref: SCHEMA_VERSIONS.workflowKernelWorkItem },
2155
+ },
2156
+ engineCounts: {
2157
+ type: "object",
2158
+ additionalProperties: false,
2159
+ properties: {
2160
+ "2.0": { type: "integer", minimum: 0 },
2161
+ },
2162
+ },
2163
+ },
2164
+ };
2165
+ export const contractSchemas = {
2166
+ diagnostic: diagnosticSchema,
2167
+ workspaceContext: workspaceContextSchema,
2168
+ application: applicationSchema,
2169
+ principal: principalSchema,
2170
+ roleAssignment: roleAssignmentSchema,
2171
+ relationshipGrant: relationshipGrantSchema,
2172
+ roleSession: roleSessionSchema,
2173
+ authorizationDecision: authorizationDecisionSchema,
2174
+ authorizationBatchRequest: authorizationBatchRequestSchema,
2175
+ authorizationBatchResult: authorizationBatchResultSchema,
2176
+ directoryResolveRequest: directoryResolveRequestSchema,
2177
+ directorySearchResult: directorySearchResultSchema,
2178
+ dataRef: dataRefSchema,
2179
+ dataResource: dataResourceSchema,
2180
+ dataQuery: dataQuerySchema,
2181
+ dataPage: dataPageSchema,
2182
+ dataRecord: dataRecordSchema,
2183
+ dataAggregateQuery: dataAggregateQuerySchema,
2184
+ dataAggregatePage: dataAggregatePageSchema,
2185
+ dataAuditPage: dataAuditPageSchema,
2186
+ dataFileRef: dataFileRefSchema,
2187
+ dataFileUploadPlan: dataFileUploadPlanSchema,
2188
+ dataTransactionRequest: dataTransactionRequestSchema,
2189
+ dataTransactionResult: dataTransactionResultSchema,
2190
+ cloudEvent: cloudEventSchema,
2191
+ eventSubscription: eventSubscriptionSchema,
2192
+ eventDelivery: eventDeliverySchema,
2193
+ eventReceiptCommand: eventReceiptCommandSchema,
2194
+ eventReceiptResult: eventReceiptResultSchema,
2195
+ applicationSecret: applicationSecretSchema,
2196
+ timerSubscription: timerSubscriptionSchema,
2197
+ workflowDefinition: workflowDefinitionSchema,
2198
+ workflowBinding: workflowBindingSchema,
2199
+ workflowPreparation: workflowPreparationSchema,
2200
+ workflowInstance: workflowInstanceSchema,
2201
+ workflowTask: workflowTaskSchema,
2202
+ workflowSurface: workflowSurfaceSchema,
2203
+ workflowDelegation: workflowDelegationSchema,
2204
+ workflowAssigneeProvider: workflowAssigneeProviderSchema,
2205
+ workflowAssigneeRequest: workflowAssigneeRequestSchema,
2206
+ workflowAssigneeResponse: workflowAssigneeResponseSchema,
2207
+ workflowKernelDescriptor: workflowKernelDescriptorSchema,
2208
+ workflowKernelWorkItem: workflowKernelWorkItemSchema,
2209
+ workflowKernelWorkCenter: workflowKernelWorkCenterSchema,
2210
+ appPackage: appPackageSchema,
2211
+ appVersion: appVersionSchema,
2212
+ environmentHead: environmentHeadSchema,
2213
+ deploymentRun: deploymentRunSchema,
2214
+ platformCapabilities: platformCapabilitiesSchema,
2215
+ };
2216
+ //# sourceMappingURL=schemas.js.map