@cascade-flow/backend-interface 0.1.0 → 0.2.1
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 +1 -1
- package/dist/error-serialization.d.ts +55 -0
- package/dist/error-serialization.d.ts.map +1 -0
- package/dist/events.d.ts +6 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -1
- package/dist/index.js.map +8 -7
- package/dist/interface.d.ts +47 -3
- package/dist/interface.d.ts.map +1 -1
- package/dist/schemas.d.ts +31 -0
- package/dist/schemas.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ class MyBackend extends Backend {
|
|
|
38
38
|
- `stepStateSchema` - Step state (computed from events)
|
|
39
39
|
- `runStateSchema` - Run state (computed from events)
|
|
40
40
|
- `workflowMetadataSchema` - Backend-agnostic workflow metadata
|
|
41
|
-
- `stepDefinitionSchema` - Step structure
|
|
41
|
+
- `stepDefinitionSchema` - Step structure (includes `id` field with full path for nested steps)
|
|
42
42
|
|
|
43
43
|
### Projection Functions
|
|
44
44
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error serialization utilities for consistent error handling across the codebase
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Serialized error object that can be safely stored and transmitted
|
|
6
|
+
*/
|
|
7
|
+
export interface SerializedError {
|
|
8
|
+
message: string;
|
|
9
|
+
stack?: string;
|
|
10
|
+
name: string;
|
|
11
|
+
thrownValue?: any;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Serializes any thrown value into a consistent error object format.
|
|
15
|
+
* Handles Error instances, non-Error objects (like Skip class instances), and primitives.
|
|
16
|
+
*
|
|
17
|
+
* @param error - The caught error/thrown value
|
|
18
|
+
* @returns Serialized error object with message, stack, name, and optional thrownValue
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* try {
|
|
23
|
+
* throw new Error("Something went wrong");
|
|
24
|
+
* } catch (error) {
|
|
25
|
+
* const serialized = serializeError(error);
|
|
26
|
+
* console.log(serialized.message); // "Something went wrong"
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* // Handles non-Error objects (e.g., Skip instances)
|
|
30
|
+
* try {
|
|
31
|
+
* throw new Skip("Skipping step");
|
|
32
|
+
* } catch (error) {
|
|
33
|
+
* const serialized = serializeError(error);
|
|
34
|
+
* console.log(serialized.message); // "Skipping step"
|
|
35
|
+
* console.log(serialized.name); // "Skip"
|
|
36
|
+
* console.log(serialized.thrownValue); // Full Skip object
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function serializeError(error: unknown): SerializedError;
|
|
41
|
+
/**
|
|
42
|
+
* Ensures an error message is always a string, handling cases where it might be an object.
|
|
43
|
+
* Useful when displaying errors to users or in logs.
|
|
44
|
+
*
|
|
45
|
+
* @param message - The error message (may be a string or object)
|
|
46
|
+
* @returns A string representation of the message
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const msg = ensureErrorMessage("normal string"); // "normal string"
|
|
51
|
+
* const msg2 = ensureErrorMessage({ foo: "bar" }); // '{"foo":"bar"}'
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function ensureErrorMessage(message: unknown): string;
|
|
55
|
+
//# sourceMappingURL=error-serialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-serialization.d.ts","sourceRoot":"","sources":["../src/error-serialization.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,GAAG,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAwB9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAK3D"}
|
package/dist/events.d.ts
CHANGED
|
@@ -324,6 +324,7 @@ export declare const workflowStartedEventSchema: z.ZodObject<{
|
|
|
324
324
|
runId: z.ZodString;
|
|
325
325
|
category: z.ZodLiteral<"workflow">;
|
|
326
326
|
type: z.ZodLiteral<"WorkflowStarted">;
|
|
327
|
+
versionId: z.ZodString;
|
|
327
328
|
workflowAttemptNumber: z.ZodNumber;
|
|
328
329
|
hasInputSchema: z.ZodBoolean;
|
|
329
330
|
hasInput: z.ZodBoolean;
|
|
@@ -425,6 +426,7 @@ export declare const runSubmittedEventSchema: z.ZodObject<{
|
|
|
425
426
|
runId: z.ZodString;
|
|
426
427
|
category: z.ZodLiteral<"workflow">;
|
|
427
428
|
type: z.ZodLiteral<"RunSubmitted">;
|
|
429
|
+
versionId: z.ZodString;
|
|
428
430
|
availableAtUs: z.ZodNumber;
|
|
429
431
|
priority: z.ZodNumber;
|
|
430
432
|
input: z.ZodOptional<z.ZodString>;
|
|
@@ -441,6 +443,7 @@ export declare const workflowEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
441
443
|
runId: z.ZodString;
|
|
442
444
|
category: z.ZodLiteral<"workflow">;
|
|
443
445
|
type: z.ZodLiteral<"RunSubmitted">;
|
|
446
|
+
versionId: z.ZodString;
|
|
444
447
|
availableAtUs: z.ZodNumber;
|
|
445
448
|
priority: z.ZodNumber;
|
|
446
449
|
input: z.ZodOptional<z.ZodString>;
|
|
@@ -456,6 +459,7 @@ export declare const workflowEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
456
459
|
runId: z.ZodString;
|
|
457
460
|
category: z.ZodLiteral<"workflow">;
|
|
458
461
|
type: z.ZodLiteral<"WorkflowStarted">;
|
|
462
|
+
versionId: z.ZodString;
|
|
459
463
|
workflowAttemptNumber: z.ZodNumber;
|
|
460
464
|
hasInputSchema: z.ZodBoolean;
|
|
461
465
|
hasInput: z.ZodBoolean;
|
|
@@ -692,6 +696,7 @@ export declare const eventSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[
|
|
|
692
696
|
runId: z.ZodString;
|
|
693
697
|
category: z.ZodLiteral<"workflow">;
|
|
694
698
|
type: z.ZodLiteral<"RunSubmitted">;
|
|
699
|
+
versionId: z.ZodString;
|
|
695
700
|
availableAtUs: z.ZodNumber;
|
|
696
701
|
priority: z.ZodNumber;
|
|
697
702
|
input: z.ZodOptional<z.ZodString>;
|
|
@@ -707,6 +712,7 @@ export declare const eventSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[
|
|
|
707
712
|
runId: z.ZodString;
|
|
708
713
|
category: z.ZodLiteral<"workflow">;
|
|
709
714
|
type: z.ZodLiteral<"WorkflowStarted">;
|
|
715
|
+
versionId: z.ZodString;
|
|
710
716
|
workflowAttemptNumber: z.ZodNumber;
|
|
711
717
|
hasInputSchema: z.ZodBoolean;
|
|
712
718
|
hasInput: z.ZodBoolean;
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,aAAa,aAA4B,CAAC;AAGvD,eAAO,MAAM,eAAe;;;;;;;;;iBAM1B,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,aAAa,aAA4B,CAAC;AAGvD,eAAO,MAAM,eAAe;;;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cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AAGnC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,wBAAwB,CAAC;AAIvC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAG7B,cAAc,aAAa,CAAC;AAG5B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AAGnC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,wBAAwB,CAAC;AAIvC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12575,6 +12575,19 @@ var WorkflowRegistrationSchema = exports_external.object({
|
|
|
12575
12575
|
inputSchemaJSON: exports_external.any().optional(),
|
|
12576
12576
|
steps: exports_external.array(StepDefinitionSchema)
|
|
12577
12577
|
});
|
|
12578
|
+
var WorkflowVersionGitInfoSchema = exports_external.object({
|
|
12579
|
+
commit: exports_external.string(),
|
|
12580
|
+
dirty: exports_external.boolean(),
|
|
12581
|
+
branch: exports_external.string()
|
|
12582
|
+
});
|
|
12583
|
+
var WorkflowVersionSchema = exports_external.object({
|
|
12584
|
+
workflowSlug: exports_external.string(),
|
|
12585
|
+
versionId: exports_external.string(),
|
|
12586
|
+
createdAt: exports_external.number(),
|
|
12587
|
+
stepManifest: exports_external.array(exports_external.string()),
|
|
12588
|
+
totalSteps: exports_external.number().int().nonnegative(),
|
|
12589
|
+
git: WorkflowVersionGitInfoSchema.optional()
|
|
12590
|
+
});
|
|
12578
12591
|
// src/events.ts
|
|
12579
12592
|
var eventIdSchema = exports_external.string().regex(/^\d+$/);
|
|
12580
12593
|
var baseEventSchema = exports_external.object({
|
|
@@ -12683,6 +12696,7 @@ var stepEventSchema = exports_external.discriminatedUnion("type", [
|
|
|
12683
12696
|
]);
|
|
12684
12697
|
var workflowStartedEventSchema = baseWorkflowEventSchema.extend({
|
|
12685
12698
|
type: exports_external.literal("WorkflowStarted"),
|
|
12699
|
+
versionId: exports_external.string(),
|
|
12686
12700
|
workflowAttemptNumber: exports_external.number().int().positive(),
|
|
12687
12701
|
hasInputSchema: exports_external.boolean(),
|
|
12688
12702
|
hasInput: exports_external.boolean()
|
|
@@ -12741,6 +12755,7 @@ var workflowRetryStartedEventSchema = baseWorkflowEventSchema.extend({
|
|
|
12741
12755
|
});
|
|
12742
12756
|
var runSubmittedEventSchema = baseWorkflowEventSchema.extend({
|
|
12743
12757
|
type: exports_external.literal("RunSubmitted"),
|
|
12758
|
+
versionId: exports_external.string(),
|
|
12744
12759
|
availableAtUs: exports_external.number(),
|
|
12745
12760
|
priority: exports_external.number().int(),
|
|
12746
12761
|
input: exports_external.string().optional(),
|
|
@@ -13696,6 +13711,34 @@ function parseFingerprint(fingerprint) {
|
|
|
13696
13711
|
stackHash: parts[2]
|
|
13697
13712
|
};
|
|
13698
13713
|
}
|
|
13714
|
+
// src/error-serialization.ts
|
|
13715
|
+
function serializeError(error46) {
|
|
13716
|
+
if (error46 instanceof Error) {
|
|
13717
|
+
return {
|
|
13718
|
+
message: error46.message,
|
|
13719
|
+
stack: error46.stack,
|
|
13720
|
+
name: error46.name
|
|
13721
|
+
};
|
|
13722
|
+
} else if (error46 && typeof error46 === "object") {
|
|
13723
|
+
return {
|
|
13724
|
+
message: error46.message || JSON.stringify(error46),
|
|
13725
|
+
name: error46.constructor?.name || "Error",
|
|
13726
|
+
stack: error46.stack,
|
|
13727
|
+
thrownValue: error46
|
|
13728
|
+
};
|
|
13729
|
+
} else {
|
|
13730
|
+
return {
|
|
13731
|
+
message: String(error46),
|
|
13732
|
+
name: "Error"
|
|
13733
|
+
};
|
|
13734
|
+
}
|
|
13735
|
+
}
|
|
13736
|
+
function ensureErrorMessage(message) {
|
|
13737
|
+
if (typeof message === "string") {
|
|
13738
|
+
return message;
|
|
13739
|
+
}
|
|
13740
|
+
return JSON.stringify(message);
|
|
13741
|
+
}
|
|
13699
13742
|
export {
|
|
13700
13743
|
workflowStartedEventSchema,
|
|
13701
13744
|
workflowRetryStartedEventSchema,
|
|
@@ -13720,6 +13763,7 @@ export {
|
|
|
13720
13763
|
stepEventSchema,
|
|
13721
13764
|
stepDurationSchema,
|
|
13722
13765
|
stepCompletedEventSchema,
|
|
13766
|
+
serializeError,
|
|
13723
13767
|
schedulingLatencySchema,
|
|
13724
13768
|
safeSerialize,
|
|
13725
13769
|
safeDeserialize,
|
|
@@ -13744,6 +13788,7 @@ export {
|
|
|
13744
13788
|
eventIdSchema,
|
|
13745
13789
|
errorBreakdownSchema,
|
|
13746
13790
|
errorAnalysisSchema,
|
|
13791
|
+
ensureErrorMessage,
|
|
13747
13792
|
convertZodToJSONSchema,
|
|
13748
13793
|
computeWorkflowDuration,
|
|
13749
13794
|
computeWorkerStability,
|
|
@@ -13760,6 +13805,8 @@ export {
|
|
|
13760
13805
|
baseStepEventSchema,
|
|
13761
13806
|
baseEventSchema,
|
|
13762
13807
|
analyticsSummarySchema,
|
|
13808
|
+
WorkflowVersionSchema,
|
|
13809
|
+
WorkflowVersionGitInfoSchema,
|
|
13763
13810
|
WorkflowRegistrationSchema,
|
|
13764
13811
|
WorkflowMetadataSchema,
|
|
13765
13812
|
StepStatusSchema,
|
|
@@ -13777,4 +13824,4 @@ export {
|
|
|
13777
13824
|
Backend
|
|
13778
13825
|
};
|
|
13779
13826
|
|
|
13780
|
-
//# debugId=
|
|
13827
|
+
//# debugId=8B4CDB82A5D2121C64756E2164756E21
|