@voyantjs/action-ledger 0.52.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canary.d.ts +17 -0
- package/dist/canary.d.ts.map +1 -0
- package/dist/canary.js +77 -0
- package/dist/capability.d.ts +73 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +206 -0
- package/dist/fingerprint.d.ts +26 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/fingerprint.js +55 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/request-context.d.ts +136 -0
- package/dist/request-context.d.ts.map +1 -0
- package/dist/request-context.js +237 -0
- package/dist/route-schemas.d.ts +739 -0
- package/dist/route-schemas.d.ts.map +1 -0
- package/dist/route-schemas.js +427 -0
- package/dist/routes.d.ts +1596 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +271 -0
- package/dist/schema.d.ts +1759 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +237 -0
- package/dist/service.d.ts +317 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +1025 -0
- package/dist/timeline.d.ts +67 -0
- package/dist/timeline.d.ts.map +1 -0
- package/dist/timeline.js +79 -0
- package/package.json +105 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-schemas.d.ts","sourceRoot":"","sources":["../src/route-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA8EvB,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsExC,CAAA;AAEL,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAEzF,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDhD,CAAA;AAEH,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CACpD,OAAO,sCAAsC,CAC9C,CAAA;AAED,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DvC,CAAA;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AA0CnF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsBvC,CAAA;AAEL,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AAsCvF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUtC,CAAA;AAEL,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AA+CrF,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ/C,CAAA;AAEF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAA;AAEjG,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDzC,CAAA;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA"}
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const actionLedgerActionKindValues = [
|
|
3
|
+
"read",
|
|
4
|
+
"create",
|
|
5
|
+
"update",
|
|
6
|
+
"delete",
|
|
7
|
+
"execute",
|
|
8
|
+
"approve",
|
|
9
|
+
"reject",
|
|
10
|
+
"reverse",
|
|
11
|
+
"compensate",
|
|
12
|
+
"duplicate",
|
|
13
|
+
];
|
|
14
|
+
const actionLedgerPrincipalTypeValues = ["user", "api_key", "agent", "workflow", "system"];
|
|
15
|
+
const actionLedgerRiskValues = ["low", "medium", "high", "critical"];
|
|
16
|
+
const actionLedgerStatusValues = [
|
|
17
|
+
"requested",
|
|
18
|
+
"awaiting_approval",
|
|
19
|
+
"approved",
|
|
20
|
+
"denied",
|
|
21
|
+
"succeeded",
|
|
22
|
+
"failed",
|
|
23
|
+
"reversed",
|
|
24
|
+
"compensated",
|
|
25
|
+
"expired",
|
|
26
|
+
"cancelled",
|
|
27
|
+
"superseded",
|
|
28
|
+
];
|
|
29
|
+
const actionLedgerApprovalStatusValues = [
|
|
30
|
+
"pending",
|
|
31
|
+
"approved",
|
|
32
|
+
"denied",
|
|
33
|
+
"expired",
|
|
34
|
+
"cancelled",
|
|
35
|
+
"superseded",
|
|
36
|
+
];
|
|
37
|
+
const actionLedgerRelayStatusValues = [
|
|
38
|
+
"pending",
|
|
39
|
+
"processing",
|
|
40
|
+
"succeeded",
|
|
41
|
+
"failed",
|
|
42
|
+
"dead_letter",
|
|
43
|
+
];
|
|
44
|
+
const actionLedgerReversalKindValues = ["none", "revert", "compensate", "domain_command"];
|
|
45
|
+
const actionLedgerReversalStateValues = [
|
|
46
|
+
"not_reversible",
|
|
47
|
+
"available",
|
|
48
|
+
"requested",
|
|
49
|
+
"running",
|
|
50
|
+
"completed",
|
|
51
|
+
"failed",
|
|
52
|
+
"expired",
|
|
53
|
+
];
|
|
54
|
+
const actionLedgerReversalOutcomeValues = ["full", "partial", "failed"];
|
|
55
|
+
function commaSeparatedEnumList(values) {
|
|
56
|
+
return z.preprocess((value) => {
|
|
57
|
+
if (typeof value !== "string")
|
|
58
|
+
return value;
|
|
59
|
+
return value
|
|
60
|
+
.split(",")
|
|
61
|
+
.map((part) => part.trim())
|
|
62
|
+
.filter(Boolean);
|
|
63
|
+
}, z.array(z.enum(values)).min(1).optional());
|
|
64
|
+
}
|
|
65
|
+
function commaSeparatedStringList() {
|
|
66
|
+
return z.preprocess((value) => {
|
|
67
|
+
if (typeof value !== "string")
|
|
68
|
+
return value;
|
|
69
|
+
return value
|
|
70
|
+
.split(",")
|
|
71
|
+
.map((part) => part.trim())
|
|
72
|
+
.filter(Boolean);
|
|
73
|
+
}, z.array(z.string().trim().min(1)).min(1).optional());
|
|
74
|
+
}
|
|
75
|
+
export const actionLedgerEntryListQuerySchema = z
|
|
76
|
+
.object({
|
|
77
|
+
actionName: z.string().trim().min(1).optional(),
|
|
78
|
+
actionKind: z.enum(actionLedgerActionKindValues).optional(),
|
|
79
|
+
actorType: z.string().trim().min(1).optional(),
|
|
80
|
+
principalType: z.enum(actionLedgerPrincipalTypeValues).optional(),
|
|
81
|
+
principalId: z.string().trim().min(1).optional(),
|
|
82
|
+
apiTokenId: z.string().trim().min(1).optional(),
|
|
83
|
+
sessionId: z.string().trim().min(1).optional(),
|
|
84
|
+
callerType: z.string().trim().min(1).optional(),
|
|
85
|
+
organizationId: z.string().trim().min(1).optional(),
|
|
86
|
+
targetType: z.string().trim().min(1).optional(),
|
|
87
|
+
targetId: z.string().trim().min(1).optional(),
|
|
88
|
+
targetIds: commaSeparatedStringList(),
|
|
89
|
+
routeOrToolName: z.string().trim().min(1).optional(),
|
|
90
|
+
workflowRunId: z.string().trim().min(1).optional(),
|
|
91
|
+
workflowStepId: z.string().trim().min(1).optional(),
|
|
92
|
+
correlationId: z.string().trim().min(1).optional(),
|
|
93
|
+
causationActionId: z.string().trim().min(1).optional(),
|
|
94
|
+
capabilityId: z.string().trim().min(1).optional(),
|
|
95
|
+
capabilityVersion: z.string().trim().min(1).optional(),
|
|
96
|
+
authorizationSource: z.string().trim().min(1).optional(),
|
|
97
|
+
approvalId: z.string().trim().min(1).optional(),
|
|
98
|
+
amendsActionId: z.string().trim().min(1).optional(),
|
|
99
|
+
idempotencyScope: z.string().trim().min(1).optional(),
|
|
100
|
+
idempotencyKey: z.string().trim().min(1).optional(),
|
|
101
|
+
evaluatedRisk: commaSeparatedEnumList(actionLedgerRiskValues),
|
|
102
|
+
status: commaSeparatedEnumList(actionLedgerStatusValues),
|
|
103
|
+
reversalKind: commaSeparatedEnumList(actionLedgerReversalKindValues),
|
|
104
|
+
reversalState: commaSeparatedEnumList(actionLedgerReversalStateValues),
|
|
105
|
+
reversalOutcome: commaSeparatedEnumList(actionLedgerReversalOutcomeValues),
|
|
106
|
+
reversesActionId: z.string().trim().min(1).optional(),
|
|
107
|
+
reversedByActionId: z.string().trim().min(1).optional(),
|
|
108
|
+
sensitiveReasonCode: z.string().trim().min(1).optional(),
|
|
109
|
+
decisionPolicy: z.string().trim().min(1).optional(),
|
|
110
|
+
occurredAtFrom: z.string().datetime().optional(),
|
|
111
|
+
occurredAtTo: z.string().datetime().optional(),
|
|
112
|
+
cursorOccurredAt: z.string().datetime().optional(),
|
|
113
|
+
cursorId: z.string().trim().min(1).optional(),
|
|
114
|
+
limit: z.coerce.number().int().min(1).max(200).optional(),
|
|
115
|
+
})
|
|
116
|
+
.superRefine((value, ctx) => {
|
|
117
|
+
if (Boolean(value.cursorOccurredAt) === Boolean(value.cursorId))
|
|
118
|
+
return;
|
|
119
|
+
ctx.addIssue({
|
|
120
|
+
code: z.ZodIssueCode.custom,
|
|
121
|
+
path: value.cursorOccurredAt ? ["cursorId"] : ["cursorOccurredAt"],
|
|
122
|
+
message: "cursorOccurredAt and cursorId must be provided together",
|
|
123
|
+
});
|
|
124
|
+
})
|
|
125
|
+
.superRefine((value, ctx) => {
|
|
126
|
+
if (!value.targetId || !value.targetIds)
|
|
127
|
+
return;
|
|
128
|
+
ctx.addIssue({
|
|
129
|
+
code: z.ZodIssueCode.custom,
|
|
130
|
+
path: ["targetIds"],
|
|
131
|
+
message: "targetId and targetIds cannot be provided together",
|
|
132
|
+
});
|
|
133
|
+
})
|
|
134
|
+
.transform(({ cursorOccurredAt, cursorId, occurredAtFrom, occurredAtTo, ...query }) => ({
|
|
135
|
+
...query,
|
|
136
|
+
occurredAtFrom: occurredAtFrom ? new Date(occurredAtFrom) : undefined,
|
|
137
|
+
occurredAtTo: occurredAtTo ? new Date(occurredAtTo) : undefined,
|
|
138
|
+
cursor: cursorOccurredAt && cursorId
|
|
139
|
+
? {
|
|
140
|
+
occurredAt: cursorOccurredAt,
|
|
141
|
+
id: cursorId,
|
|
142
|
+
}
|
|
143
|
+
: undefined,
|
|
144
|
+
}));
|
|
145
|
+
export const actionLedgerRelayOutboxListQuerySchema = z
|
|
146
|
+
.object({
|
|
147
|
+
actionId: z.string().trim().min(1).optional(),
|
|
148
|
+
organizationId: z.string().trim().min(1).optional(),
|
|
149
|
+
relayStatus: commaSeparatedEnumList(actionLedgerRelayStatusValues),
|
|
150
|
+
dueBefore: z.string().datetime().optional(),
|
|
151
|
+
createdAtFrom: z.string().datetime().optional(),
|
|
152
|
+
createdAtTo: z.string().datetime().optional(),
|
|
153
|
+
processedAtFrom: z.string().datetime().optional(),
|
|
154
|
+
processedAtTo: z.string().datetime().optional(),
|
|
155
|
+
cursorCreatedAt: z.string().datetime().optional(),
|
|
156
|
+
cursorId: z.string().trim().min(1).optional(),
|
|
157
|
+
limit: z.coerce.number().int().min(1).max(200).optional(),
|
|
158
|
+
})
|
|
159
|
+
.superRefine((value, ctx) => {
|
|
160
|
+
if (Boolean(value.cursorCreatedAt) === Boolean(value.cursorId))
|
|
161
|
+
return;
|
|
162
|
+
ctx.addIssue({
|
|
163
|
+
code: z.ZodIssueCode.custom,
|
|
164
|
+
path: value.cursorCreatedAt ? ["cursorId"] : ["cursorCreatedAt"],
|
|
165
|
+
message: "cursorCreatedAt and cursorId must be provided together",
|
|
166
|
+
});
|
|
167
|
+
})
|
|
168
|
+
.transform(({ cursorCreatedAt, cursorId, dueBefore, createdAtFrom, createdAtTo, processedAtFrom, processedAtTo, ...query }) => ({
|
|
169
|
+
...query,
|
|
170
|
+
dueBefore: dueBefore ? new Date(dueBefore) : undefined,
|
|
171
|
+
createdAtFrom: createdAtFrom ? new Date(createdAtFrom) : undefined,
|
|
172
|
+
createdAtTo: createdAtTo ? new Date(createdAtTo) : undefined,
|
|
173
|
+
processedAtFrom: processedAtFrom ? new Date(processedAtFrom) : undefined,
|
|
174
|
+
processedAtTo: processedAtTo ? new Date(processedAtTo) : undefined,
|
|
175
|
+
cursor: cursorCreatedAt && cursorId
|
|
176
|
+
? {
|
|
177
|
+
createdAt: cursorCreatedAt,
|
|
178
|
+
id: cursorId,
|
|
179
|
+
}
|
|
180
|
+
: undefined,
|
|
181
|
+
}));
|
|
182
|
+
export const actionApprovalListQuerySchema = z
|
|
183
|
+
.object({
|
|
184
|
+
requestedActionId: z.string().trim().min(1).optional(),
|
|
185
|
+
status: commaSeparatedEnumList(actionLedgerApprovalStatusValues),
|
|
186
|
+
requestedByPrincipalId: z.string().trim().min(1).optional(),
|
|
187
|
+
assignedToPrincipalId: z.string().trim().min(1).optional(),
|
|
188
|
+
decidedByPrincipalId: z.string().trim().min(1).optional(),
|
|
189
|
+
delegatedFromPrincipalId: z.string().trim().min(1).optional(),
|
|
190
|
+
policyName: z.string().trim().min(1).optional(),
|
|
191
|
+
policyVersion: z.string().trim().min(1).optional(),
|
|
192
|
+
riskSnapshot: commaSeparatedEnumList(actionLedgerRiskValues),
|
|
193
|
+
reasonCode: z.string().trim().min(1).optional(),
|
|
194
|
+
expiresAtFrom: z.string().datetime().optional(),
|
|
195
|
+
expiresAtTo: z.string().datetime().optional(),
|
|
196
|
+
decidedAtFrom: z.string().datetime().optional(),
|
|
197
|
+
decidedAtTo: z.string().datetime().optional(),
|
|
198
|
+
createdAtFrom: z.string().datetime().optional(),
|
|
199
|
+
createdAtTo: z.string().datetime().optional(),
|
|
200
|
+
cursorCreatedAt: z.string().datetime().optional(),
|
|
201
|
+
cursorId: z.string().trim().min(1).optional(),
|
|
202
|
+
limit: z.coerce.number().int().min(1).max(200).optional(),
|
|
203
|
+
})
|
|
204
|
+
.superRefine((value, ctx) => {
|
|
205
|
+
if (Boolean(value.cursorCreatedAt) === Boolean(value.cursorId))
|
|
206
|
+
return;
|
|
207
|
+
ctx.addIssue({
|
|
208
|
+
code: z.ZodIssueCode.custom,
|
|
209
|
+
path: value.cursorCreatedAt ? ["cursorId"] : ["cursorCreatedAt"],
|
|
210
|
+
message: "cursorCreatedAt and cursorId must be provided together",
|
|
211
|
+
});
|
|
212
|
+
})
|
|
213
|
+
.transform(({ cursorCreatedAt, cursorId, expiresAtFrom, expiresAtTo, decidedAtFrom, decidedAtTo, createdAtFrom, createdAtTo, ...query }) => ({
|
|
214
|
+
...query,
|
|
215
|
+
expiresAtFrom: expiresAtFrom ? new Date(expiresAtFrom) : undefined,
|
|
216
|
+
expiresAtTo: expiresAtTo ? new Date(expiresAtTo) : undefined,
|
|
217
|
+
decidedAtFrom: decidedAtFrom ? new Date(decidedAtFrom) : undefined,
|
|
218
|
+
decidedAtTo: decidedAtTo ? new Date(decidedAtTo) : undefined,
|
|
219
|
+
createdAtFrom: createdAtFrom ? new Date(createdAtFrom) : undefined,
|
|
220
|
+
createdAtTo: createdAtTo ? new Date(createdAtTo) : undefined,
|
|
221
|
+
cursor: cursorCreatedAt && cursorId
|
|
222
|
+
? {
|
|
223
|
+
createdAt: cursorCreatedAt,
|
|
224
|
+
id: cursorId,
|
|
225
|
+
}
|
|
226
|
+
: undefined,
|
|
227
|
+
}));
|
|
228
|
+
const nullableTrimmedString = z
|
|
229
|
+
.string()
|
|
230
|
+
.trim()
|
|
231
|
+
.min(1)
|
|
232
|
+
.optional()
|
|
233
|
+
.transform((value) => value ?? null);
|
|
234
|
+
const actionLedgerApprovalRequestedActionBodySchema = z.object({
|
|
235
|
+
actionName: z.string().trim().min(1),
|
|
236
|
+
actionVersion: z.string().trim().min(1).default("v1"),
|
|
237
|
+
actionKind: z.enum(actionLedgerActionKindValues),
|
|
238
|
+
evaluatedRisk: z.enum(actionLedgerRiskValues),
|
|
239
|
+
actorType: nullableTrimmedString,
|
|
240
|
+
principalType: z.enum(actionLedgerPrincipalTypeValues),
|
|
241
|
+
principalId: z.string().trim().min(1),
|
|
242
|
+
principalSubtype: nullableTrimmedString,
|
|
243
|
+
sessionId: nullableTrimmedString,
|
|
244
|
+
apiTokenId: nullableTrimmedString,
|
|
245
|
+
internalRequest: z.boolean().default(false),
|
|
246
|
+
delegatedByPrincipalType: z.enum(actionLedgerPrincipalTypeValues).optional(),
|
|
247
|
+
delegatedByPrincipalId: nullableTrimmedString,
|
|
248
|
+
delegationId: nullableTrimmedString,
|
|
249
|
+
callerType: nullableTrimmedString,
|
|
250
|
+
organizationId: nullableTrimmedString,
|
|
251
|
+
routeOrToolName: nullableTrimmedString,
|
|
252
|
+
workflowRunId: nullableTrimmedString,
|
|
253
|
+
workflowStepId: nullableTrimmedString,
|
|
254
|
+
correlationId: nullableTrimmedString,
|
|
255
|
+
causationActionId: nullableTrimmedString,
|
|
256
|
+
idempotencyScope: nullableTrimmedString,
|
|
257
|
+
idempotencyKey: nullableTrimmedString,
|
|
258
|
+
idempotencyFingerprint: nullableTrimmedString,
|
|
259
|
+
targetType: z.string().trim().min(1),
|
|
260
|
+
targetId: z.string().trim().min(1),
|
|
261
|
+
capabilityId: nullableTrimmedString,
|
|
262
|
+
capabilityVersion: nullableTrimmedString,
|
|
263
|
+
authorizationSource: nullableTrimmedString,
|
|
264
|
+
amendsActionId: nullableTrimmedString,
|
|
265
|
+
});
|
|
266
|
+
export const requestActionApprovalBodySchema = z
|
|
267
|
+
.object({
|
|
268
|
+
requestedAction: actionLedgerApprovalRequestedActionBodySchema,
|
|
269
|
+
approval: z.object({
|
|
270
|
+
requestedByPrincipalId: nullableTrimmedString,
|
|
271
|
+
assignedToPrincipalId: nullableTrimmedString,
|
|
272
|
+
delegatedFromPrincipalId: nullableTrimmedString,
|
|
273
|
+
policyName: z.string().trim().min(1),
|
|
274
|
+
policyVersion: z.string().trim().min(1),
|
|
275
|
+
targetSnapshotRef: nullableTrimmedString,
|
|
276
|
+
riskSnapshot: z.enum(actionLedgerRiskValues).optional(),
|
|
277
|
+
reasonCode: nullableTrimmedString,
|
|
278
|
+
expiresAt: z.string().datetime().optional(),
|
|
279
|
+
}),
|
|
280
|
+
})
|
|
281
|
+
.transform(({ approval, ...body }) => ({
|
|
282
|
+
...body,
|
|
283
|
+
approval: {
|
|
284
|
+
...approval,
|
|
285
|
+
riskSnapshot: approval.riskSnapshot ?? null,
|
|
286
|
+
expiresAt: approval.expiresAt ? new Date(approval.expiresAt) : null,
|
|
287
|
+
},
|
|
288
|
+
}));
|
|
289
|
+
const actionLedgerApprovalDecisionStatusValues = [
|
|
290
|
+
"approved",
|
|
291
|
+
"denied",
|
|
292
|
+
"expired",
|
|
293
|
+
"cancelled",
|
|
294
|
+
"superseded",
|
|
295
|
+
];
|
|
296
|
+
const actionLedgerApprovalDecisionActionBodySchema = z.object({
|
|
297
|
+
actionName: z.string().trim().min(1),
|
|
298
|
+
actionVersion: z.string().trim().min(1).default("v1"),
|
|
299
|
+
actorType: nullableTrimmedString,
|
|
300
|
+
principalType: z.enum(actionLedgerPrincipalTypeValues),
|
|
301
|
+
principalId: z.string().trim().min(1),
|
|
302
|
+
principalSubtype: nullableTrimmedString,
|
|
303
|
+
sessionId: nullableTrimmedString,
|
|
304
|
+
apiTokenId: nullableTrimmedString,
|
|
305
|
+
internalRequest: z.boolean().default(false),
|
|
306
|
+
delegatedByPrincipalType: z.enum(actionLedgerPrincipalTypeValues).optional(),
|
|
307
|
+
delegatedByPrincipalId: nullableTrimmedString,
|
|
308
|
+
delegationId: nullableTrimmedString,
|
|
309
|
+
callerType: nullableTrimmedString,
|
|
310
|
+
organizationId: nullableTrimmedString,
|
|
311
|
+
routeOrToolName: nullableTrimmedString,
|
|
312
|
+
workflowRunId: nullableTrimmedString,
|
|
313
|
+
workflowStepId: nullableTrimmedString,
|
|
314
|
+
correlationId: nullableTrimmedString,
|
|
315
|
+
idempotencyScope: nullableTrimmedString,
|
|
316
|
+
idempotencyKey: nullableTrimmedString,
|
|
317
|
+
idempotencyFingerprint: nullableTrimmedString,
|
|
318
|
+
capabilityId: nullableTrimmedString,
|
|
319
|
+
capabilityVersion: nullableTrimmedString,
|
|
320
|
+
authorizationSource: nullableTrimmedString,
|
|
321
|
+
amendsActionId: nullableTrimmedString,
|
|
322
|
+
});
|
|
323
|
+
export const decideActionApprovalBodySchema = z
|
|
324
|
+
.object({
|
|
325
|
+
status: z.enum(actionLedgerApprovalDecisionStatusValues),
|
|
326
|
+
decidedByPrincipalId: z.string().trim().min(1),
|
|
327
|
+
decidedAt: z.string().datetime().optional(),
|
|
328
|
+
decisionAction: actionLedgerApprovalDecisionActionBodySchema,
|
|
329
|
+
})
|
|
330
|
+
.transform(({ decidedAt, ...body }) => ({
|
|
331
|
+
...body,
|
|
332
|
+
decidedAt: decidedAt ? new Date(decidedAt) : undefined,
|
|
333
|
+
}));
|
|
334
|
+
const actionLedgerReversalActionBodySchema = z.object({
|
|
335
|
+
actionName: z.string().trim().min(1),
|
|
336
|
+
actionVersion: z.string().trim().min(1).default("v1"),
|
|
337
|
+
actionKind: z.enum(["reverse", "compensate"]),
|
|
338
|
+
status: z.enum(["reversed", "compensated", "failed"]),
|
|
339
|
+
evaluatedRisk: z.enum(actionLedgerRiskValues).default("high"),
|
|
340
|
+
actorType: nullableTrimmedString,
|
|
341
|
+
principalType: z.enum(actionLedgerPrincipalTypeValues),
|
|
342
|
+
principalId: z.string().trim().min(1),
|
|
343
|
+
principalSubtype: nullableTrimmedString,
|
|
344
|
+
sessionId: nullableTrimmedString,
|
|
345
|
+
apiTokenId: nullableTrimmedString,
|
|
346
|
+
internalRequest: z.boolean().default(false),
|
|
347
|
+
delegatedByPrincipalType: z.enum(actionLedgerPrincipalTypeValues).optional(),
|
|
348
|
+
delegatedByPrincipalId: nullableTrimmedString,
|
|
349
|
+
delegationId: nullableTrimmedString,
|
|
350
|
+
callerType: nullableTrimmedString,
|
|
351
|
+
organizationId: nullableTrimmedString,
|
|
352
|
+
routeOrToolName: nullableTrimmedString,
|
|
353
|
+
workflowRunId: nullableTrimmedString,
|
|
354
|
+
workflowStepId: nullableTrimmedString,
|
|
355
|
+
correlationId: nullableTrimmedString,
|
|
356
|
+
idempotencyScope: nullableTrimmedString,
|
|
357
|
+
idempotencyKey: nullableTrimmedString,
|
|
358
|
+
idempotencyFingerprint: nullableTrimmedString,
|
|
359
|
+
targetType: z.string().trim().min(1),
|
|
360
|
+
targetId: z.string().trim().min(1),
|
|
361
|
+
capabilityId: nullableTrimmedString,
|
|
362
|
+
capabilityVersion: nullableTrimmedString,
|
|
363
|
+
authorizationSource: nullableTrimmedString,
|
|
364
|
+
approvalId: nullableTrimmedString,
|
|
365
|
+
amendsActionId: nullableTrimmedString,
|
|
366
|
+
mutationDetail: z
|
|
367
|
+
.object({
|
|
368
|
+
commandInputRef: nullableTrimmedString,
|
|
369
|
+
commandResultRef: nullableTrimmedString,
|
|
370
|
+
summary: nullableTrimmedString,
|
|
371
|
+
reversalKind: z.enum(actionLedgerReversalKindValues).default("none"),
|
|
372
|
+
reversalCommandId: nullableTrimmedString,
|
|
373
|
+
reversalCommandVersion: nullableTrimmedString,
|
|
374
|
+
reversalArgsRef: nullableTrimmedString,
|
|
375
|
+
})
|
|
376
|
+
.optional(),
|
|
377
|
+
});
|
|
378
|
+
export const recordActionLedgerReversalBodySchema = z.object({
|
|
379
|
+
reversalAction: actionLedgerReversalActionBodySchema,
|
|
380
|
+
projection: z
|
|
381
|
+
.object({
|
|
382
|
+
reversalState: z.enum(actionLedgerReversalStateValues).optional(),
|
|
383
|
+
reversalOutcome: z.enum(actionLedgerReversalOutcomeValues).optional(),
|
|
384
|
+
})
|
|
385
|
+
.optional(),
|
|
386
|
+
});
|
|
387
|
+
export const actionDelegationListQuerySchema = z
|
|
388
|
+
.object({
|
|
389
|
+
rootPrincipalType: z.enum(actionLedgerPrincipalTypeValues).optional(),
|
|
390
|
+
rootPrincipalId: z.string().trim().min(1).optional(),
|
|
391
|
+
parentPrincipalType: z.enum(actionLedgerPrincipalTypeValues).optional(),
|
|
392
|
+
parentPrincipalId: z.string().trim().min(1).optional(),
|
|
393
|
+
childPrincipalType: z.enum(actionLedgerPrincipalTypeValues).optional(),
|
|
394
|
+
childPrincipalId: z.string().trim().min(1).optional(),
|
|
395
|
+
grantSource: z.string().trim().min(1).optional(),
|
|
396
|
+
capabilityScopeRef: z.string().trim().min(1).optional(),
|
|
397
|
+
budgetScopeRef: z.string().trim().min(1).optional(),
|
|
398
|
+
expiresAtFrom: z.string().datetime().optional(),
|
|
399
|
+
expiresAtTo: z.string().datetime().optional(),
|
|
400
|
+
createdAtFrom: z.string().datetime().optional(),
|
|
401
|
+
createdAtTo: z.string().datetime().optional(),
|
|
402
|
+
cursorCreatedAt: z.string().datetime().optional(),
|
|
403
|
+
cursorId: z.string().trim().min(1).optional(),
|
|
404
|
+
limit: z.coerce.number().int().min(1).max(200).optional(),
|
|
405
|
+
})
|
|
406
|
+
.superRefine((value, ctx) => {
|
|
407
|
+
if (Boolean(value.cursorCreatedAt) === Boolean(value.cursorId))
|
|
408
|
+
return;
|
|
409
|
+
ctx.addIssue({
|
|
410
|
+
code: z.ZodIssueCode.custom,
|
|
411
|
+
path: value.cursorCreatedAt ? ["cursorId"] : ["cursorCreatedAt"],
|
|
412
|
+
message: "cursorCreatedAt and cursorId must be provided together",
|
|
413
|
+
});
|
|
414
|
+
})
|
|
415
|
+
.transform(({ cursorCreatedAt, cursorId, expiresAtFrom, expiresAtTo, createdAtFrom, createdAtTo, ...query }) => ({
|
|
416
|
+
...query,
|
|
417
|
+
expiresAtFrom: expiresAtFrom ? new Date(expiresAtFrom) : undefined,
|
|
418
|
+
expiresAtTo: expiresAtTo ? new Date(expiresAtTo) : undefined,
|
|
419
|
+
createdAtFrom: createdAtFrom ? new Date(createdAtFrom) : undefined,
|
|
420
|
+
createdAtTo: createdAtTo ? new Date(createdAtTo) : undefined,
|
|
421
|
+
cursor: cursorCreatedAt && cursorId
|
|
422
|
+
? {
|
|
423
|
+
createdAt: cursorCreatedAt,
|
|
424
|
+
id: cursorId,
|
|
425
|
+
}
|
|
426
|
+
: undefined,
|
|
427
|
+
}));
|