@xtrape/capsule-contracts-node 0.3.0 → 0.4.0
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 +24 -0
- package/dist/index.cjs +121 -0
- package/dist/index.d.cts +807 -15
- package/dist/index.d.ts +807 -15
- package/dist/index.js +101 -0
- package/dist/src/index.d.ts +4245 -0
- package/dist/src/index.js +210 -0
- package/dist/tests/bus.spec.d.ts +1 -0
- package/dist/tests/bus.spec.js +52 -0
- package/dist/tests/schema-validation.spec.d.ts +1 -0
- package/dist/tests/schema-validation.spec.js +155 -0
- package/dist/tests/schema.spec.d.ts +1 -0
- package/dist/tests/schema.spec.js +223 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -78,6 +78,87 @@ var ActionPrepareResultSchema = z.object({
|
|
|
78
78
|
currentState: AnyJson.optional()
|
|
79
79
|
});
|
|
80
80
|
var actionPrepareResultSchema = ActionPrepareResultSchema;
|
|
81
|
+
var CapsuleBusExperimentalSchema = z.literal("v0.4-experimental");
|
|
82
|
+
var BusRouteStatus = ["ENABLED", "DISABLED", "DRY_RUN"];
|
|
83
|
+
var BusRouteStatusSchema = z.enum(BusRouteStatus);
|
|
84
|
+
var BusEventEnvelopeSchema = z.object({
|
|
85
|
+
id: z.string().startsWith("bev_").optional(),
|
|
86
|
+
experimental: CapsuleBusExperimentalSchema.default("v0.4-experimental"),
|
|
87
|
+
eventType: z.string().min(1).max(160),
|
|
88
|
+
sourceServiceCode: z.string().min(1).max(80),
|
|
89
|
+
sourceServiceId: z.string().startsWith("svc_").optional(),
|
|
90
|
+
occurredAt: z.string().datetime().optional(),
|
|
91
|
+
correlationId: z.string().min(1).max(160).optional(),
|
|
92
|
+
causationId: z.string().min(1).max(160).optional(),
|
|
93
|
+
payload: AnyJson.default({}).optional(),
|
|
94
|
+
metadata: AnyJson.default({}).optional()
|
|
95
|
+
});
|
|
96
|
+
var PublishBusEventRequestSchema = BusEventEnvelopeSchema.omit({ id: true }).extend({
|
|
97
|
+
routePolicy: z.object({ dryRun: z.boolean().optional() }).optional()
|
|
98
|
+
});
|
|
99
|
+
var BusRouteRuleSchema = z.object({
|
|
100
|
+
id: z.string().startsWith("brt_").optional(),
|
|
101
|
+
name: z.string().min(1).max(160),
|
|
102
|
+
description: z.string().max(1e3).optional(),
|
|
103
|
+
status: BusRouteStatusSchema.optional().default("DISABLED"),
|
|
104
|
+
match: z.object({
|
|
105
|
+
eventType: z.string().min(1).max(160),
|
|
106
|
+
sourceServiceCode: z.string().min(1).max(80).optional()
|
|
107
|
+
}),
|
|
108
|
+
target: z.object({
|
|
109
|
+
serviceCode: z.string().min(1).max(80),
|
|
110
|
+
actionName: z.string().min(1).max(128)
|
|
111
|
+
}),
|
|
112
|
+
inputMapping: AnyJson.default({}).optional(),
|
|
113
|
+
metadata: AnyJson.default({}).optional()
|
|
114
|
+
});
|
|
115
|
+
var CreateBusRouteRuleRequestSchema = BusRouteRuleSchema.omit({ id: true });
|
|
116
|
+
var BusCommandRequestSchema = z.object({
|
|
117
|
+
commandId: z.string().startsWith("cmd_").optional(),
|
|
118
|
+
commandType: z.literal("ACTION_EXECUTE").default("ACTION_EXECUTE"),
|
|
119
|
+
targetService: z.string().min(1).max(80),
|
|
120
|
+
actionName: z.string().min(1).max(128),
|
|
121
|
+
sourceEventId: z.string().startsWith("bev_").optional(),
|
|
122
|
+
payload: AnyJson.default({}).optional(),
|
|
123
|
+
metadata: z.object({
|
|
124
|
+
routingRuleId: z.string().startsWith("brt_").optional(),
|
|
125
|
+
correlationId: z.string().min(1).max(160).optional()
|
|
126
|
+
}).catchall(z.any()).optional()
|
|
127
|
+
});
|
|
128
|
+
var busCommandRequestSchema = BusCommandRequestSchema;
|
|
129
|
+
var BusRoutingRuleSchema = BusRouteRuleSchema;
|
|
130
|
+
var busRoutingRuleSchema = BusRoutingRuleSchema;
|
|
131
|
+
var BusRoutedCommandSchema = z.object({
|
|
132
|
+
routeId: z.string().startsWith("brt_"),
|
|
133
|
+
commandId: z.string().startsWith("cmd_").optional(),
|
|
134
|
+
dryRun: z.boolean(),
|
|
135
|
+
targetServiceCode: z.string(),
|
|
136
|
+
actionName: z.string(),
|
|
137
|
+
status: z.enum(["CREATED", "DRY_RUN", "SKIPPED", "FAILED"]),
|
|
138
|
+
errorCode: z.string().optional(),
|
|
139
|
+
errorMessage: z.string().optional()
|
|
140
|
+
});
|
|
141
|
+
var PublishBusEventResponseSchema = z.object({
|
|
142
|
+
eventId: z.string().startsWith("bev_"),
|
|
143
|
+
experimental: CapsuleBusExperimentalSchema,
|
|
144
|
+
routedCommands: z.array(BusRoutedCommandSchema)
|
|
145
|
+
});
|
|
146
|
+
var BusEventRecordSchema = BusEventEnvelopeSchema.extend({
|
|
147
|
+
id: z.string().startsWith("bev_"),
|
|
148
|
+
agentId: z.string().startsWith("agt_"),
|
|
149
|
+
acceptedAt: z.string(),
|
|
150
|
+
routeCount: z.number().int()
|
|
151
|
+
});
|
|
152
|
+
var BusErrorCode = {
|
|
153
|
+
CAPSULE_BUS_DISABLED: "CAPSULE_BUS_DISABLED",
|
|
154
|
+
BUS_RATE_LIMITED: "BUS_RATE_LIMITED",
|
|
155
|
+
BUS_DEPTH_EXCEEDED: "BUS_DEPTH_EXCEEDED"
|
|
156
|
+
};
|
|
157
|
+
var publishBusEventRequestSchema = PublishBusEventRequestSchema;
|
|
158
|
+
var publishBusEventResponseSchema = PublishBusEventResponseSchema;
|
|
159
|
+
var busEventEnvelopeSchema = BusEventEnvelopeSchema;
|
|
160
|
+
var busRouteRuleSchema = BusRouteRuleSchema;
|
|
161
|
+
var createBusRouteRuleRequestSchema = CreateBusRouteRuleRequestSchema;
|
|
81
162
|
var CreateActionCommandRequestSchema = z.object({ payload: AnyJson.optional(), confirmation: z.boolean().optional() });
|
|
82
163
|
var createActionCommandRequestSchema = CreateActionCommandRequestSchema;
|
|
83
164
|
var CommandTypeSchema = z.enum(["ACTION_PREPARE", "ACTION_EXECUTE"]);
|
|
@@ -148,6 +229,16 @@ export {
|
|
|
148
229
|
AuditActorType,
|
|
149
230
|
AuditEventSchema,
|
|
150
231
|
AuditResult,
|
|
232
|
+
BusCommandRequestSchema,
|
|
233
|
+
BusErrorCode,
|
|
234
|
+
BusEventEnvelopeSchema,
|
|
235
|
+
BusEventRecordSchema,
|
|
236
|
+
BusRouteRuleSchema,
|
|
237
|
+
BusRouteStatus,
|
|
238
|
+
BusRouteStatusSchema,
|
|
239
|
+
BusRoutedCommandSchema,
|
|
240
|
+
BusRoutingRuleSchema,
|
|
241
|
+
CapsuleBusExperimentalSchema,
|
|
151
242
|
CapsuleManifestSchema,
|
|
152
243
|
CapsuleServiceDetailSchema,
|
|
153
244
|
CapsuleServiceSchema,
|
|
@@ -162,6 +253,7 @@ export {
|
|
|
162
253
|
ConfigItemInputSchema,
|
|
163
254
|
ConfigItemSchema,
|
|
164
255
|
CreateActionCommandRequestSchema,
|
|
256
|
+
CreateBusRouteRuleRequestSchema,
|
|
165
257
|
CreateRegistrationTokenRequestSchema,
|
|
166
258
|
CreateRegistrationTokenResponseSchema,
|
|
167
259
|
DangerLevel,
|
|
@@ -175,6 +267,8 @@ export {
|
|
|
175
267
|
HealthStatusSchema,
|
|
176
268
|
HttpError,
|
|
177
269
|
ListQueryBase,
|
|
270
|
+
PublishBusEventRequestSchema,
|
|
271
|
+
PublishBusEventResponseSchema,
|
|
178
272
|
RegisterAgentRequestSchema,
|
|
179
273
|
RegisterAgentResponseSchema,
|
|
180
274
|
RegistrationTokenSchema,
|
|
@@ -194,14 +288,21 @@ export {
|
|
|
194
288
|
actionPrepareResultSchema,
|
|
195
289
|
adminLoginRequestSchema,
|
|
196
290
|
agentHeartbeatRequestSchema,
|
|
291
|
+
busCommandRequestSchema,
|
|
292
|
+
busEventEnvelopeSchema,
|
|
293
|
+
busRouteRuleSchema,
|
|
294
|
+
busRoutingRuleSchema,
|
|
197
295
|
configItemInputSchema,
|
|
198
296
|
createActionCommandRequestSchema,
|
|
297
|
+
createBusRouteRuleRequestSchema,
|
|
199
298
|
createRegistrationTokenRequestSchema,
|
|
200
299
|
createUserRequestSchema,
|
|
201
300
|
eventMetadataSchema,
|
|
202
301
|
healthReportInputSchema,
|
|
203
302
|
paginate,
|
|
204
303
|
parseSort,
|
|
304
|
+
publishBusEventRequestSchema,
|
|
305
|
+
publishBusEventResponseSchema,
|
|
205
306
|
registerAgentRequestSchema,
|
|
206
307
|
reportCommandResultRequestSchema,
|
|
207
308
|
reportedServiceSchema,
|