convex-effect-workflows 0.1.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 +107 -0
- package/dist/client/ConvexCtx.d.ts +12 -0
- package/dist/client/ConvexCtx.d.ts.map +1 -0
- package/dist/client/ConvexCtx.js +6 -0
- package/dist/client/ConvexCtx.js.map +1 -0
- package/dist/client/ConvexLogger.d.ts +7 -0
- package/dist/client/ConvexLogger.d.ts.map +1 -0
- package/dist/client/ConvexLogger.js +39 -0
- package/dist/client/ConvexLogger.js.map +1 -0
- package/dist/client/ConvexTracer.d.ts +7 -0
- package/dist/client/ConvexTracer.d.ts.map +1 -0
- package/dist/client/ConvexTracer.js +60 -0
- package/dist/client/ConvexTracer.js.map +1 -0
- package/dist/client/ConvexWorkflowEngine.d.ts +308 -0
- package/dist/client/ConvexWorkflowEngine.d.ts.map +1 -0
- package/dist/client/ConvexWorkflowEngine.js +88 -0
- package/dist/client/ConvexWorkflowEngine.js.map +1 -0
- package/dist/client/activityWorker.d.ts +23 -0
- package/dist/client/activityWorker.d.ts.map +1 -0
- package/dist/client/activityWorker.js +41 -0
- package/dist/client/activityWorker.js.map +1 -0
- package/dist/client/boundaries.d.ts +27 -0
- package/dist/client/boundaries.d.ts.map +1 -0
- package/dist/client/boundaries.js +17 -0
- package/dist/client/boundaries.js.map +1 -0
- package/dist/client/encoded.d.ts +22 -0
- package/dist/client/encoded.d.ts.map +1 -0
- package/dist/client/encoded.js +276 -0
- package/dist/client/encoded.js.map +1 -0
- package/dist/client/index.d.ts +13 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +11 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/registry.d.ts +17 -0
- package/dist/client/registry.d.ts.map +1 -0
- package/dist/client/registry.js +21 -0
- package/dist/client/registry.js.map +1 -0
- package/dist/client/runner.d.ts +27 -0
- package/dist/client/runner.d.ts.map +1 -0
- package/dist/client/runner.js +90 -0
- package/dist/client/runner.js.map +1 -0
- package/dist/client/runtime.d.ts +10 -0
- package/dist/client/runtime.d.ts.map +1 -0
- package/dist/client/runtime.js +15 -0
- package/dist/client/runtime.js.map +1 -0
- package/dist/component/_generated/api.d.ts +148 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +921 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/activityCompletions.d.ts +27 -0
- package/dist/component/activityCompletions.d.ts.map +1 -0
- package/dist/component/activityCompletions.js +70 -0
- package/dist/component/activityCompletions.js.map +1 -0
- package/dist/component/boundaries.d.ts +20 -0
- package/dist/component/boundaries.d.ts.map +1 -0
- package/dist/component/boundaries.js +17 -0
- package/dist/component/boundaries.js.map +1 -0
- package/dist/component/cleanup.d.ts +11 -0
- package/dist/component/cleanup.d.ts.map +1 -0
- package/dist/component/cleanup.js +163 -0
- package/dist/component/cleanup.js.map +1 -0
- package/dist/component/clocks.d.ts +12 -0
- package/dist/component/clocks.d.ts.map +1 -0
- package/dist/component/clocks.js +26 -0
- package/dist/component/clocks.js.map +1 -0
- package/dist/component/config.d.ts +25 -0
- package/dist/component/config.d.ts.map +1 -0
- package/dist/component/config.js +110 -0
- package/dist/component/config.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +6 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/dashboard.d.ts +268 -0
- package/dist/component/dashboard.d.ts.map +1 -0
- package/dist/component/dashboard.js +622 -0
- package/dist/component/dashboard.js.map +1 -0
- package/dist/component/deferreds.d.ts +31 -0
- package/dist/component/deferreds.d.ts.map +1 -0
- package/dist/component/deferreds.js +138 -0
- package/dist/component/deferreds.js.map +1 -0
- package/dist/component/executions.d.ts +77 -0
- package/dist/component/executions.d.ts.map +1 -0
- package/dist/component/executions.js +186 -0
- package/dist/component/executions.js.map +1 -0
- package/dist/component/journalSteps.d.ts +261 -0
- package/dist/component/journalSteps.d.ts.map +1 -0
- package/dist/component/journalSteps.js +203 -0
- package/dist/component/journalSteps.js.map +1 -0
- package/dist/component/logs.d.ts +68 -0
- package/dist/component/logs.d.ts.map +1 -0
- package/dist/component/logs.js +123 -0
- package/dist/component/logs.js.map +1 -0
- package/dist/component/onComplete.d.ts +31 -0
- package/dist/component/onComplete.d.ts.map +1 -0
- package/dist/component/onComplete.js +146 -0
- package/dist/component/onComplete.js.map +1 -0
- package/dist/component/payloads.d.ts +26 -0
- package/dist/component/payloads.d.ts.map +1 -0
- package/dist/component/payloads.js +57 -0
- package/dist/component/payloads.js.map +1 -0
- package/dist/component/queries.d.ts +2 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +2 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/runner.d.ts +31 -0
- package/dist/component/runner.d.ts.map +1 -0
- package/dist/component/runner.js +87 -0
- package/dist/component/runner.js.map +1 -0
- package/dist/component/schema.d.ts +282 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +119 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/spans.d.ts +105 -0
- package/dist/component/spans.d.ts.map +1 -0
- package/dist/component/spans.js +190 -0
- package/dist/component/spans.js.map +1 -0
- package/dist/component/utils.d.ts +15 -0
- package/dist/component/utils.d.ts.map +1 -0
- package/dist/component/utils.js +53 -0
- package/dist/component/utils.js.map +1 -0
- package/dist/shared/constants.d.ts +12 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +12 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/validators.d.ts +69 -0
- package/dist/shared/validators.d.ts.map +1 -0
- package/dist/shared/validators.js +30 -0
- package/dist/shared/validators.js.map +1 -0
- package/package.json +74 -0
- package/src/client/ConvexCtx.ts +21 -0
- package/src/client/ConvexLogger.ts +52 -0
- package/src/client/ConvexTracer.ts +75 -0
- package/src/client/ConvexWorkflowEngine.test.ts +124 -0
- package/src/client/ConvexWorkflowEngine.ts +209 -0
- package/src/client/activityWorker.ts +62 -0
- package/src/client/boundaries.test.ts +83 -0
- package/src/client/boundaries.ts +79 -0
- package/src/client/encoded.lifecycle.test.ts +336 -0
- package/src/client/encoded.test.ts +153 -0
- package/src/client/encoded.ts +484 -0
- package/src/client/index.ts +47 -0
- package/src/client/registry.ts +35 -0
- package/src/client/runner.ts +165 -0
- package/src/client/runtime.ts +30 -0
- package/src/component/_generated/api.ts +179 -0
- package/src/component/_generated/component.ts +1216 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/activityCompletions.ts +73 -0
- package/src/component/boundaries.ts +55 -0
- package/src/component/cleanup.test.ts +219 -0
- package/src/component/cleanup.ts +218 -0
- package/src/component/clocks.ts +26 -0
- package/src/component/config.test.ts +159 -0
- package/src/component/config.ts +145 -0
- package/src/component/convex.config.ts +7 -0
- package/src/component/core.test.ts +829 -0
- package/src/component/dashboard.scaling.test.ts +268 -0
- package/src/component/dashboard.ts +743 -0
- package/src/component/deferreds.ts +162 -0
- package/src/component/executions.ts +225 -0
- package/src/component/journalSteps.ts +252 -0
- package/src/component/logs.ts +152 -0
- package/src/component/onComplete.ts +170 -0
- package/src/component/payloads.ts +83 -0
- package/src/component/queries.ts +8 -0
- package/src/component/runner.ts +122 -0
- package/src/component/schema.ts +155 -0
- package/src/component/setup.test.ts +15 -0
- package/src/component/spans.ts +241 -0
- package/src/component/utils.test.ts +32 -0
- package/src/component/utils.ts +73 -0
- package/src/shared/constants.test.ts +14 -0
- package/src/shared/constants.ts +15 -0
- package/src/shared/validators.ts +98 -0
- package/src/test.d.ts +8 -0
- package/src/test.ts +17 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { mutation, query } from "./_generated/server.js";
|
|
3
|
+
import { vSpanKind, vSpanStatus } from "../shared/validators.js";
|
|
4
|
+
import { generateSpanId, nowTs } from "./utils.js";
|
|
5
|
+
import { persistBoundedPayload } from "./payloads.js";
|
|
6
|
+
import { MAX_SPAN_ATTR_BYTES } from "../shared/constants.js";
|
|
7
|
+
async function getSpan(ctx, executionId, spanId) {
|
|
8
|
+
return await ctx.db
|
|
9
|
+
.query("spans")
|
|
10
|
+
.withIndex("by_execution_span", (q) => q.eq("executionId", executionId).eq("spanId", spanId))
|
|
11
|
+
.unique();
|
|
12
|
+
}
|
|
13
|
+
export const createSpan = mutation({
|
|
14
|
+
args: {
|
|
15
|
+
executionId: v.string(),
|
|
16
|
+
traceId: v.string(),
|
|
17
|
+
spanId: v.optional(v.string()),
|
|
18
|
+
parentSpanId: v.optional(v.string()),
|
|
19
|
+
stepNumber: v.optional(v.number()),
|
|
20
|
+
name: v.string(),
|
|
21
|
+
kind: vSpanKind,
|
|
22
|
+
attempt: v.optional(v.number()),
|
|
23
|
+
input: v.optional(v.any()),
|
|
24
|
+
attributes: v.optional(v.any()),
|
|
25
|
+
},
|
|
26
|
+
returns: v.object({ spanId: v.string(), created: v.boolean() }),
|
|
27
|
+
handler: async (ctx, args) => {
|
|
28
|
+
const spanId = args.spanId ?? generateSpanId();
|
|
29
|
+
const existing = await getSpan(ctx, args.executionId, spanId);
|
|
30
|
+
if (existing) {
|
|
31
|
+
return { spanId, created: false };
|
|
32
|
+
}
|
|
33
|
+
const inputPayload = args.input === undefined
|
|
34
|
+
? { size: 0, ref: undefined, preview: undefined }
|
|
35
|
+
: await persistBoundedPayload(ctx, "spanInput", args.input);
|
|
36
|
+
const attrPayload = args.attributes === undefined
|
|
37
|
+
? undefined
|
|
38
|
+
: await persistBoundedPayload(ctx, "logData", args.attributes, MAX_SPAN_ATTR_BYTES);
|
|
39
|
+
await ctx.db.insert("spans", {
|
|
40
|
+
executionId: args.executionId,
|
|
41
|
+
traceId: args.traceId,
|
|
42
|
+
spanId,
|
|
43
|
+
parentSpanId: args.parentSpanId,
|
|
44
|
+
stepNumber: args.stepNumber,
|
|
45
|
+
name: args.name,
|
|
46
|
+
kind: args.kind,
|
|
47
|
+
status: "started",
|
|
48
|
+
startTime: nowTs(),
|
|
49
|
+
attempt: args.attempt,
|
|
50
|
+
attributes: attrPayload?.preview,
|
|
51
|
+
inputRef: inputPayload.ref,
|
|
52
|
+
inputPreview: inputPayload.preview,
|
|
53
|
+
inputSize: inputPayload.size,
|
|
54
|
+
});
|
|
55
|
+
return { spanId, created: true };
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
export const endSpan = mutation({
|
|
59
|
+
args: {
|
|
60
|
+
executionId: v.string(),
|
|
61
|
+
spanId: v.string(),
|
|
62
|
+
output: v.optional(v.any()),
|
|
63
|
+
error: v.optional(v.string()),
|
|
64
|
+
attributes: v.optional(v.any()),
|
|
65
|
+
},
|
|
66
|
+
returns: v.object({ changed: v.boolean() }),
|
|
67
|
+
handler: async (ctx, args) => {
|
|
68
|
+
const span = await getSpan(ctx, args.executionId, args.spanId);
|
|
69
|
+
if (!span) {
|
|
70
|
+
throw new Error(`Span not found: ${args.executionId}/${args.spanId}`);
|
|
71
|
+
}
|
|
72
|
+
if (span.status === "ended") {
|
|
73
|
+
return { changed: false };
|
|
74
|
+
}
|
|
75
|
+
const outputPayload = args.output === undefined
|
|
76
|
+
? { size: undefined, ref: undefined, preview: undefined }
|
|
77
|
+
: await persistBoundedPayload(ctx, "spanOutput", args.output);
|
|
78
|
+
const attrPayload = args.attributes === undefined
|
|
79
|
+
? undefined
|
|
80
|
+
: await persistBoundedPayload(ctx, "logData", args.attributes, MAX_SPAN_ATTR_BYTES);
|
|
81
|
+
await ctx.db.patch(span._id, {
|
|
82
|
+
status: "ended",
|
|
83
|
+
endTime: nowTs(),
|
|
84
|
+
outputRef: outputPayload.ref,
|
|
85
|
+
outputPreview: outputPayload.preview,
|
|
86
|
+
outputSize: outputPayload.size,
|
|
87
|
+
attributes: attrPayload?.preview ?? span.attributes,
|
|
88
|
+
error: args.error,
|
|
89
|
+
});
|
|
90
|
+
return { changed: true };
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
export const getExecutionSpan = query({
|
|
94
|
+
args: {
|
|
95
|
+
executionId: v.string(),
|
|
96
|
+
spanId: v.string(),
|
|
97
|
+
},
|
|
98
|
+
returns: v.any(),
|
|
99
|
+
handler: async (ctx, args) => {
|
|
100
|
+
return await getSpan(ctx, args.executionId, args.spanId);
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
export const listExecutionSpans = query({
|
|
104
|
+
args: {
|
|
105
|
+
executionId: v.string(),
|
|
106
|
+
limit: v.number(),
|
|
107
|
+
afterStartTime: v.optional(v.number()),
|
|
108
|
+
kind: v.optional(vSpanKind),
|
|
109
|
+
status: v.optional(vSpanStatus),
|
|
110
|
+
},
|
|
111
|
+
returns: v.any(),
|
|
112
|
+
handler: async (ctx, args) => {
|
|
113
|
+
const limit = Math.max(1, Math.min(args.limit, 500));
|
|
114
|
+
let rows = await ctx.db
|
|
115
|
+
.query("spans")
|
|
116
|
+
.withIndex("by_execution_start", (q) => q.eq("executionId", args.executionId))
|
|
117
|
+
.take(limit + 200);
|
|
118
|
+
if (args.afterStartTime !== undefined) {
|
|
119
|
+
rows = rows.filter((row) => row.startTime > args.afterStartTime);
|
|
120
|
+
}
|
|
121
|
+
if (args.kind) {
|
|
122
|
+
rows = rows.filter((row) => row.kind === args.kind);
|
|
123
|
+
}
|
|
124
|
+
if (args.status) {
|
|
125
|
+
rows = rows.filter((row) => row.status === args.status);
|
|
126
|
+
}
|
|
127
|
+
rows.sort((a, b) => a.startTime - b.startTime);
|
|
128
|
+
const page = rows.slice(0, limit);
|
|
129
|
+
const nextAfterStartTime = rows.length > limit ? page[page.length - 1]?.startTime : undefined;
|
|
130
|
+
return { page, nextAfterStartTime };
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* Test helper for creating a span with full control over fields including status, startTime, and endTime.
|
|
135
|
+
*/
|
|
136
|
+
export const internalCreateSpan = mutation({
|
|
137
|
+
args: {
|
|
138
|
+
executionId: v.string(),
|
|
139
|
+
traceId: v.string(),
|
|
140
|
+
spanId: v.optional(v.string()),
|
|
141
|
+
parentSpanId: v.optional(v.string()),
|
|
142
|
+
stepNumber: v.optional(v.number()),
|
|
143
|
+
name: v.string(),
|
|
144
|
+
kind: vSpanKind,
|
|
145
|
+
status: vSpanStatus,
|
|
146
|
+
startTime: v.number(),
|
|
147
|
+
endTime: v.optional(v.number()),
|
|
148
|
+
attempt: v.optional(v.number()),
|
|
149
|
+
input: v.optional(v.any()),
|
|
150
|
+
output: v.optional(v.any()),
|
|
151
|
+
error: v.optional(v.string()),
|
|
152
|
+
attributes: v.optional(v.any()),
|
|
153
|
+
},
|
|
154
|
+
returns: v.object({ spanId: v.string() }),
|
|
155
|
+
handler: async (ctx, args) => {
|
|
156
|
+
const spanId = args.spanId ?? generateSpanId();
|
|
157
|
+
const inputPayload = args.input === undefined
|
|
158
|
+
? { size: 0, ref: undefined, preview: undefined }
|
|
159
|
+
: await persistBoundedPayload(ctx, "spanInput", args.input);
|
|
160
|
+
const outputPayload = args.output === undefined
|
|
161
|
+
? { size: undefined, ref: undefined, preview: undefined }
|
|
162
|
+
: await persistBoundedPayload(ctx, "spanOutput", args.output);
|
|
163
|
+
const attrPayload = args.attributes === undefined
|
|
164
|
+
? undefined
|
|
165
|
+
: await persistBoundedPayload(ctx, "logData", args.attributes, MAX_SPAN_ATTR_BYTES);
|
|
166
|
+
await ctx.db.insert("spans", {
|
|
167
|
+
executionId: args.executionId,
|
|
168
|
+
traceId: args.traceId,
|
|
169
|
+
spanId,
|
|
170
|
+
parentSpanId: args.parentSpanId,
|
|
171
|
+
stepNumber: args.stepNumber,
|
|
172
|
+
name: args.name,
|
|
173
|
+
kind: args.kind,
|
|
174
|
+
status: args.status,
|
|
175
|
+
startTime: args.startTime,
|
|
176
|
+
endTime: args.endTime,
|
|
177
|
+
attempt: args.attempt,
|
|
178
|
+
attributes: attrPayload?.preview,
|
|
179
|
+
inputRef: inputPayload.ref,
|
|
180
|
+
inputPreview: inputPayload.preview,
|
|
181
|
+
inputSize: inputPayload.size,
|
|
182
|
+
outputRef: outputPayload.ref,
|
|
183
|
+
outputPreview: outputPayload.preview,
|
|
184
|
+
outputSize: outputPayload.size,
|
|
185
|
+
error: args.error,
|
|
186
|
+
});
|
|
187
|
+
return { spanId };
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
//# sourceMappingURL=spans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spans.js","sourceRoot":"","sources":["../../src/component/spans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAmC,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAI7D,KAAK,UAAU,OAAO,CACpB,GAAgB,EAChB,WAAmB,EACnB,MAAc;IAEd,OAAO,MAAM,GAAG,CAAC,EAAE;SAChB,KAAK,CAAC,OAAO,CAAC;SACd,SAAS,CAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE,EAAE,CACpC,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AE,OAAO;YAChC,QAAQ,EAAE,YAAY,CAAC,GAAG;YAC1B,YAAY,EAAE,YAAY,CAAC,OAAO;YAClC,SAAS,EAAE,YAAY,CAAC,IAAI;YAC5B,SAAS,EAAE,aAAa,CAAC,GAAG;YAC5B,aAAa,EAAE,aAAa,CAAC,OAAO;YACpC,UAAU,EAAE,aAAa,CAAC,IAAI;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Value } from "convex/values";
|
|
2
|
+
export declare function nowTs(): number;
|
|
3
|
+
export declare function randomHex(size?: number): string;
|
|
4
|
+
export declare function generateTraceId(): string;
|
|
5
|
+
export declare function generateSpanId(): string;
|
|
6
|
+
type TruncatedPreview = {
|
|
7
|
+
_truncated: true;
|
|
8
|
+
preview: string;
|
|
9
|
+
originalSize?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function valueSize(value: unknown): number;
|
|
12
|
+
export declare function toPreview(value: unknown, maxBytes?: number): Value | TruncatedPreview | undefined;
|
|
13
|
+
export declare function shouldOffload(value: unknown, inlineLimit?: number): boolean;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/component/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAM1D,wBAAgB,KAAK,WAEpB;AAED,wBAAgB,SAAS,CAAC,IAAI,SAAK,GAAG,MAAM,CAI3C;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQhD;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,OAAO,EACd,QAAQ,SAA2B,GAClC,KAAK,GAAG,gBAAgB,GAAG,SAAS,CAyBtC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,SAA2B,WAEnF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getConvexSize } from "convex/values";
|
|
2
|
+
import { MAX_INLINE_PAYLOAD_BYTES, MAX_PREVIEW_STRING_BYTES, } from "../shared/constants.js";
|
|
3
|
+
export function nowTs() {
|
|
4
|
+
return Date.now();
|
|
5
|
+
}
|
|
6
|
+
export function randomHex(size = 16) {
|
|
7
|
+
const bytes = new Uint8Array(size);
|
|
8
|
+
crypto.getRandomValues(bytes);
|
|
9
|
+
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
10
|
+
}
|
|
11
|
+
export function generateTraceId() {
|
|
12
|
+
return randomHex(16);
|
|
13
|
+
}
|
|
14
|
+
export function generateSpanId() {
|
|
15
|
+
return randomHex(8);
|
|
16
|
+
}
|
|
17
|
+
export function valueSize(value) {
|
|
18
|
+
try {
|
|
19
|
+
// Boundary note: getConvexSize validates Convex Value shape at runtime and
|
|
20
|
+
// throws for unsupported values, which we convert to size=0.
|
|
21
|
+
return getConvexSize((value ?? null));
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function toPreview(value, maxBytes = MAX_PREVIEW_STRING_BYTES) {
|
|
28
|
+
if (value === undefined) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
let json;
|
|
32
|
+
try {
|
|
33
|
+
json = JSON.stringify(value);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return { _truncated: true, preview: "<non-serializable>" };
|
|
37
|
+
}
|
|
38
|
+
if (json === undefined) {
|
|
39
|
+
return { _truncated: true, preview: "<non-serializable>" };
|
|
40
|
+
}
|
|
41
|
+
if (json.length <= maxBytes) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
_truncated: true,
|
|
46
|
+
preview: json.slice(0, maxBytes),
|
|
47
|
+
originalSize: json.length,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function shouldOffload(value, inlineLimit = MAX_INLINE_PAYLOAD_BYTES) {
|
|
51
|
+
return valueSize(value) > inlineLimit;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/component/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAc,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,UAAU,KAAK;IACnB,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAI,GAAG,EAAE;IACjC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,SAAS,CAAC,EAAE,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,SAAS,C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YLOAD_BYTES = 256000;
|
|
3
|
+
export declare const MAX_PREVIEW_STRING_BYTES = 4096;
|
|
4
|
+
export declare const MAX_LOG_DATA_BYTES = 64000;
|
|
5
|
+
export declare const MAX_SPAN_ATTR_BYTES = 64000;
|
|
6
|
+
export declare const DEFAULT_EXECUTIONS_PAGE_SIZE = 50;
|
|
7
|
+
export declare const DEFAULT_STEPS_PAGE_SIZE = 100;
|
|
8
|
+
export declare const DEFAULT_SPANS_PAGE_SIZE = 200;
|
|
9
|
+
export declare const DEFAULT_LOGS_PAGE_SIZE = 200;
|
|
10
|
+
export declare const MAX_PAGE_SIZE = 500;
|
|
11
|
+
export declare const DEFAULT_RETENTION_DAYS = 30;
|
|
12
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/shared/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,wBAAwB,SAAU,CAAC;AAChD,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAC9C,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAE1C,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,eAAO,MAAM,sBAAsB,KAAK,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const COMPONENT_NAME = "effectWorkflows";
|
|
2
|
+
export const MAX_INLINE_PAYLOAD_BYTES = 256_000;
|
|
3
|
+
export const MAX_PREVIEW_STRING_BYTES = 4_096;
|
|
4
|
+
export const MAX_LOG_DATA_BYTES = 64_000;
|
|
5
|
+
export const MAX_SPAN_ATTR_BYTES = 64_000;
|
|
6
|
+
export const DEFAULT_EXECUTIONS_PAGE_SIZE = 50;
|
|
7
|
+
export const DEFAULT_STEPS_PAGE_SIZE = 100;
|
|
8
|
+
export const DEFAULT_SPANS_PAGE_SIZE = 200;
|
|
9
|
+
export const DEFAULT_LOGS_PAGE_SIZE = 200;
|
|
10
|
+
export const MAX_PAGE_SIZE = 500;
|
|
11
|
+
export const DEFAULT_RETENTION_DAYS = 30;
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/shared/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAEhD,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAChD,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAE1C,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAC/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type Infer } from "convex/values";
|
|
2
|
+
export declare const vExecutionStatus: import("convex/values").VUnion<"pending" | "running" | "suspended" | "completed" | "failed" | "interrupted", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"running", "required">, import("convex/values").VLiteral<"suspended", "required">, import("convex/values").VLiteral<"completed", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"interrupted", "required">], "required", never>;
|
|
3
|
+
export type ExecutionStatus = Infer<typeof vExecutionStatus>;
|
|
4
|
+
export declare const vStepKind: import("convex/values").VUnion<"activity" | "system" | "deferred" | "clock" | "nestedWorkflow", [import("convex/values").VLiteral<"activity", "required">, import("convex/values").VLiteral<"deferred", "required">, import("convex/values").VLiteral<"clock", "required">, import("convex/values").VLiteral<"nestedWorkflow", "required">, import("convex/values").VLiteral<"system", "required">], "required", never>;
|
|
5
|
+
export type StepKind = Infer<typeof vStepKind>;
|
|
6
|
+
export declare const vStepState: import("convex/values").VUnion<"suspended" | "completed" | "failed" | "started" | "canceled", [import("convex/values").VLiteral<"started", "required">, import("convex/values").VLiteral<"suspended", "required">, import("convex/values").VLiteral<"completed", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"canceled", "required">], "required", never>;
|
|
7
|
+
export type StepState = Infer<typeof vStepState>;
|
|
8
|
+
export declare const vResultEnvelope: import("convex/values").VUnion<{
|
|
9
|
+
valueRef?: import("convex/values").GenericId<"payloads"> | undefined;
|
|
10
|
+
valuePreview?: any;
|
|
11
|
+
kind: "success";
|
|
12
|
+
} | {
|
|
13
|
+
valueRef?: import("convex/values").GenericId<"payloads"> | undefined;
|
|
14
|
+
valuePreview?: any;
|
|
15
|
+
error: string;
|
|
16
|
+
kind: "failed";
|
|
17
|
+
} | {
|
|
18
|
+
kind: "canceled";
|
|
19
|
+
}, [import("convex/values").VObject<{
|
|
20
|
+
valueRef?: import("convex/values").GenericId<"payloads"> | undefined;
|
|
21
|
+
valuePreview?: any;
|
|
22
|
+
kind: "success";
|
|
23
|
+
}, {
|
|
24
|
+
kind: import("convex/values").VLiteral<"success", "required">;
|
|
25
|
+
valueRef: import("convex/values").VId<import("convex/values").GenericId<"payloads"> | undefined, "optional">;
|
|
26
|
+
valuePreview: import("convex/values").VAny<any, "optional", string>;
|
|
27
|
+
}, "required", "kind" | "valueRef" | "valuePreview" | `valuePreview.${string}`>, import("convex/values").VObject<{
|
|
28
|
+
valueRef?: import("convex/values").GenericId<"payloads"> | undefined;
|
|
29
|
+
valuePreview?: any;
|
|
30
|
+
error: string;
|
|
31
|
+
kind: "failed";
|
|
32
|
+
}, {
|
|
33
|
+
kind: import("convex/values").VLiteral<"failed", "required">;
|
|
34
|
+
error: import("convex/values").VString<string, "required">;
|
|
35
|
+
valueRef: import("convex/values").VId<import("convex/values").GenericId<"payloads"> | undefined, "optional">;
|
|
36
|
+
valuePreview: import("convex/values").VAny<any, "optional", string>;
|
|
37
|
+
}, "required", "error" | "kind" | "valueRef" | "valuePreview" | `valuePreview.${string}`>, import("convex/values").VObject<{
|
|
38
|
+
kind: "canceled";
|
|
39
|
+
}, {
|
|
40
|
+
kind: import("convex/values").VLiteral<"canceled", "required">;
|
|
41
|
+
}, "required", "kind">], "required", "error" | "kind" | "valueRef" | "valuePreview" | `valuePreview.${string}`>;
|
|
42
|
+
export type ResultEnvelope = Infer<typeof vResultEnvelope>;
|
|
43
|
+
export declare const vDeterminismSignature: import("convex/values").VObject<{
|
|
44
|
+
attempt?: number | undefined;
|
|
45
|
+
scheduleMeta?: any;
|
|
46
|
+
schemaVersion?: number | undefined;
|
|
47
|
+
kind: "activity" | "system" | "deferred" | "clock" | "nestedWorkflow";
|
|
48
|
+
opName: string;
|
|
49
|
+
}, {
|
|
50
|
+
kind: import("convex/values").VUnion<"activity" | "system" | "deferred" | "clock" | "nestedWorkflow", [import("convex/values").VLiteral<"activity", "required">, import("convex/values").VLiteral<"deferred", "required">, import("convex/values").VLiteral<"clock", "required">, import("convex/values").VLiteral<"nestedWorkflow", "required">, import("convex/values").VLiteral<"system", "required">], "required", never>;
|
|
51
|
+
opName: import("convex/values").VString<string, "required">;
|
|
52
|
+
attempt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
53
|
+
scheduleMeta: import("convex/values").VAny<any, "optional", string>;
|
|
54
|
+
schemaVersion: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
55
|
+
}, "required", "kind" | "attempt" | "opName" | "scheduleMeta" | "schemaVersion" | `scheduleMeta.${string}`>;
|
|
56
|
+
export type DeterminismSignature = Infer<typeof vDeterminismSignature>;
|
|
57
|
+
export declare const vSpanKind: import("convex/values").VUnion<"workflow" | "activity" | "system" | "deferred" | "clock", [import("convex/values").VLiteral<"workflow", "required">, import("convex/values").VLiteral<"activity", "required">, import("convex/values").VLiteral<"deferred", "required">, import("convex/values").VLiteral<"clock", "required">, import("convex/values").VLiteral<"system", "required">], "required", never>;
|
|
58
|
+
export type SpanKind = Infer<typeof vSpanKind>;
|
|
59
|
+
export declare const vSpanStatus: import("convex/values").VUnion<"started" | "ended", [import("convex/values").VLiteral<"started", "required">, import("convex/values").VLiteral<"ended", "required">], "required", never>;
|
|
60
|
+
export type SpanStatus = Infer<typeof vSpanStatus>;
|
|
61
|
+
export declare const vLogLevel: import("convex/values").VUnion<"debug" | "info" | "warn" | "error", [import("convex/values").VLiteral<"debug", "required">, import("convex/values").VLiteral<"info", "required">, import("convex/values").VLiteral<"warn", "required">, import("convex/values").VLiteral<"error", "required">], "required", never>;
|
|
62
|
+
export type LogLevel = Infer<typeof vLogLevel>;
|
|
63
|
+
export declare const vLogSource: import("convex/values").VUnion<"workflow" | "activity" | "engine" | "system", [import("convex/values").VLiteral<"workflow", "required">, import("convex/values").VLiteral<"activity", "required">, import("convex/values").VLiteral<"engine", "required">, import("convex/values").VLiteral<"system", "required">], "required", never>;
|
|
64
|
+
export type LogSource = Infer<typeof vLogSource>;
|
|
65
|
+
export declare const vSortOrder: import("convex/values").VUnion<"asc" | "desc", [import("convex/values").VLiteral<"asc", "required">, import("convex/values").VLiteral<"desc", "required">], "required", never>;
|
|
66
|
+
export type SortOrder = Infer<typeof vSortOrder>;
|
|
67
|
+
export declare const vPayloadKind: import("convex/values").VUnion<"executionPayload" | "stepInput" | "stepOutput" | "deferredExit" | "spanInput" | "spanOutput" | "logData", [import("convex/values").VLiteral<"executionPayload", "required">, import("convex/values").VLiteral<"stepInput", "required">, import("convex/values").VLiteral<"stepOutput", "required">, import("convex/values").VLiteral<"deferredExit", "required">, import("convex/values").VLiteral<"spanInput", "required">, import("convex/values").VLiteral<"spanOutput", "required">, import("convex/values").VLiteral<"logData", "required">], "required", never>;
|
|
68
|
+
export type PayloadKind = Infer<typeof vPayloadKind>;
|
|
69
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/shared/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAE9C,eAAO,MAAM,gBAAgB,geAO5B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE7D,eAAO,MAAM,SAAS,yZAMrB,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAE/C,eAAO,MAAM,UAAU,qZAMtB,CAAC;AACF,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAIjD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+GAa3B,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE3D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;2GAMhC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEvE,eAAO,MAAM,SAAS,6YAMrB,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAE/C,eAAO,MAAM,WAAW,0LAAoD,CAAC;AAC7E,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnD,eAAO,MAAM,SAAS,oTAKrB,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAE/C,eAAO,MAAM,UAAU,wUAKtB,CAAC;AACF,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEjD,eAAO,MAAM,UAAU,gLAA+C,CAAC;AACvE,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEjD,eAAO,MAAM,YAAY,ukBAQxB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
export const vExecutionStatus = v.union(v.literal("pending"), v.literal("running"), v.literal("suspended"), v.literal("completed"), v.literal("failed"), v.literal("interrupted"));
|
|
3
|
+
export const vStepKind = v.union(v.literal("activity"), v.literal("deferred"), v.literal("clock"), v.literal("nestedWorkflow"), v.literal("system"));
|
|
4
|
+
export const vStepState = v.union(v.literal("started"), v.literal("suspended"), v.literal("completed"), v.literal("failed"), v.literal("canceled"));
|
|
5
|
+
// valuePreview intentionally remains v.any(): previews can be raw inline values
|
|
6
|
+
// or truncated preview envelopes for arbitrary user payloads.
|
|
7
|
+
export const vResultEnvelope = v.union(v.object({
|
|
8
|
+
kind: v.literal("success"),
|
|
9
|
+
valueRef: v.optional(v.id("payloads")),
|
|
10
|
+
valuePreview: v.optional(v.any()),
|
|
11
|
+
}), v.object({
|
|
12
|
+
kind: v.literal("failed"),
|
|
13
|
+
error: v.string(),
|
|
14
|
+
valueRef: v.optional(v.id("payloads")),
|
|
15
|
+
valuePreview: v.optional(v.any()),
|
|
16
|
+
}), v.object({ kind: v.literal("canceled") }));
|
|
17
|
+
export const vDeterminismSignature = v.object({
|
|
18
|
+
kind: vStepKind,
|
|
19
|
+
opName: v.string(),
|
|
20
|
+
attempt: v.optional(v.number()),
|
|
21
|
+
scheduleMeta: v.optional(v.any()),
|
|
22
|
+
schemaVersion: v.optional(v.number()),
|
|
23
|
+
});
|
|
24
|
+
export const vSpanKind = v.union(v.literal("workflow"), v.literal("activity"), v.literal("deferred"), v.literal("clock"), v.literal("system"));
|
|
25
|
+
export const vSpanStatus = v.union(v.literal("started"), v.literal("ended"));
|
|
26
|
+
export const vLogLevel = v.union(v.literal("debug"), v.literal("info"), v.literal("warn"), v.literal("error"));
|
|
27
|
+
export const vLogSource = v.union(v.literal("workflow"), v.literal("activity"), v.literal("engine"), v.literal("system"));
|
|
28
|
+
export const vSortOrder = v.union(v.literal("asc"), v.literal("desc"));
|
|
29
|
+
export const vPayloadKind = v.union(v.literal("executionPayload"), v.literal("stepInput"), v.literal("stepOutput"), v.literal("deferredExit"), v.literal("spanInput"), v.literal("spanOutput"), v.literal("logData"));
|
|
30
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/shared/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAc,MAAM,eAAe,CAAC;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CACrC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EACtB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EACtB,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EACnB,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CACzB,CAAC;AAGF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAC9B,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EACrB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EACrB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAClB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C,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAGvE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CACjC,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAC7B,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EACtB,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EACvB,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,EACzB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EACtB,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EACvB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CACrB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "convex-effect-workflows",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Effect-native Convex workflow engine with durable observability",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"convex",
|
|
7
|
+
"effect",
|
|
8
|
+
"workflow",
|
|
9
|
+
"durable-execution",
|
|
10
|
+
"observability"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/ebg1223/convex-effect-workflows",
|
|
13
|
+
"repository": "github:ebg1223/convex-effect-workflows",
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"packageManager": "bun@1.3.10",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "run-p -r 'dev:*'",
|
|
19
|
+
"dev:backend": "convex dev --typecheck-components",
|
|
20
|
+
"dev:example": "cd example/convex && convex dev --typecheck-components",
|
|
21
|
+
"dev:build": "chokidar 'tsconfig*.json' 'src/**/*.ts' -i '**/*.test.ts' -c 'bun run build:codegen' --initial",
|
|
22
|
+
"predev": "path-exists .env.local dist || (bun run build && convex dev --once)",
|
|
23
|
+
"build": "tsc --project ./tsconfig.build.json",
|
|
24
|
+
"build:codegen": "convex codegen --component-dir ./src/component && bun run build",
|
|
25
|
+
"build:clean": "rm -rf dist *.tsbuildinfo && bun run build:codegen",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest",
|
|
29
|
+
"preversion": "bun install --frozen-lockfile && bun run build:clean && bun run test && bun run typecheck"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
35
|
+
"exports": {
|
|
36
|
+
"./package.json": "./package.json",
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/client/index.d.ts",
|
|
39
|
+
"default": "./dist/client/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./test": "./src/test.ts",
|
|
42
|
+
"./_generated/component.js": {
|
|
43
|
+
"types": "./dist/component/_generated/component.d.ts"
|
|
44
|
+
},
|
|
45
|
+
"./convex.config": {
|
|
46
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
47
|
+
"default": "./dist/component/convex.config.js"
|
|
48
|
+
},
|
|
49
|
+
"./convex.config.js": {
|
|
50
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
51
|
+
"default": "./dist/component/convex.config.js"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@convex-dev/workpool": "^0.4.0",
|
|
56
|
+
"@effect/workflow": "^0.16.0",
|
|
57
|
+
"convex": "^1.32.0",
|
|
58
|
+
"effect": "^3.19.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@convex-dev/workpool": "0.4.0",
|
|
62
|
+
"@types/node": "^24.10.0",
|
|
63
|
+
"chokidar-cli": "3.0.0",
|
|
64
|
+
"convex": "1.32.0",
|
|
65
|
+
"convex-helpers": "0.1.114",
|
|
66
|
+
"convex-test": "0.0.41",
|
|
67
|
+
"npm-run-all2": "8.0.4",
|
|
68
|
+
"path-exists-cli": "2.0.0",
|
|
69
|
+
"typescript": "5.9.3",
|
|
70
|
+
"vitest": "4.0.18"
|
|
71
|
+
},
|
|
72
|
+
"types": "./dist/client/index.d.ts",
|
|
73
|
+
"module": "./dist/client/index.js"
|
|
74
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import type { GenericActionCtx, GenericDataModel, GenericMutationCtx } from "convex/server";
|
|
3
|
+
|
|
4
|
+
export type ConvexWorkflowCtx = Pick<
|
|
5
|
+
GenericMutationCtx<GenericDataModel>,
|
|
6
|
+
"runMutation" | "runQuery" | "scheduler"
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
export type ConvexWorkflowActionCtx = Pick<
|
|
10
|
+
GenericActionCtx<GenericDataModel>,
|
|
11
|
+
"runMutation" | "runQuery" | "runAction"
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
export class ConvexCtx extends Context.Tag("convex-effect-workflows/ConvexCtx")<
|
|
15
|
+
ConvexCtx,
|
|
16
|
+
ConvexWorkflowCtx
|
|
17
|
+
>() {}
|
|
18
|
+
|
|
19
|
+
export class ConvexActionCtx extends Context.Tag(
|
|
20
|
+
"convex-effect-workflows/ConvexActionCtx",
|
|
21
|
+
)<ConvexActionCtx, ConvexWorkflowActionCtx>() {}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as HashMap from "effect/HashMap";
|
|
2
|
+
import * as List from "effect/List";
|
|
3
|
+
import * as Logger from "effect/Logger";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import type { FiberId } from "effect/FiberId";
|
|
6
|
+
import type { GenericMutationCtx, GenericDataModel } from "convex/server";
|
|
7
|
+
import type { ComponentApi } from "../component/_generated/component.js";
|
|
8
|
+
|
|
9
|
+
type MutationRunCtx = Pick<
|
|
10
|
+
GenericMutationCtx<GenericDataModel>,
|
|
11
|
+
"runMutation"
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
function messageToString(message: unknown): string {
|
|
15
|
+
if (typeof message === "string") return message;
|
|
16
|
+
try {
|
|
17
|
+
return JSON.stringify(message);
|
|
18
|
+
} catch {
|
|
19
|
+
return String(message);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function makeConvexLogger(
|
|
24
|
+
component: ComponentApi,
|
|
25
|
+
ctx: MutationRunCtx,
|
|
26
|
+
executionId: string,
|
|
27
|
+
traceId?: string,
|
|
28
|
+
): Logger.Logger<unknown, void> {
|
|
29
|
+
return Logger.make((options) => {
|
|
30
|
+
const span = List.head(options.spans);
|
|
31
|
+
const spanId = Option.match(span, {
|
|
32
|
+
onNone: () => undefined,
|
|
33
|
+
onSome: (currentSpan) => currentSpan.label,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
void ctx
|
|
37
|
+
.runMutation(component.logs.appendLog, {
|
|
38
|
+
executionId,
|
|
39
|
+
traceId,
|
|
40
|
+
spanId,
|
|
41
|
+
level: (options.logLevel.label.toLowerCase() as "debug" | "info" | "warn" | "error"),
|
|
42
|
+
source: "workflow",
|
|
43
|
+
message: messageToString(options.message),
|
|
44
|
+
data: {
|
|
45
|
+
annotations: HashMap.toEntries(options.annotations),
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
.catch(() => {
|
|
49
|
+
// Never fail the workflow because logging persistence fails.
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|