@siglo/query 0.0.0-stage → 1.3.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/LICENSE +21 -0
- package/README.md +64 -2
- package/dist/cursor.d.ts +16 -0
- package/dist/cursor.d.ts.map +1 -0
- package/dist/cursor.js +52 -0
- package/dist/cursor.js.map +1 -0
- package/dist/engine.d.ts +27 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +225 -0
- package/dist/engine.js.map +1 -0
- package/dist/graphql/backing.d.ts +4 -0
- package/dist/graphql/backing.d.ts.map +1 -0
- package/dist/graphql/backing.js +6 -0
- package/dist/graphql/backing.js.map +1 -0
- package/dist/graphql/projection.d.ts +15 -0
- package/dist/graphql/projection.d.ts.map +1 -0
- package/dist/graphql/projection.js +69 -0
- package/dist/graphql/projection.js.map +1 -0
- package/dist/graphql/resolvers.d.ts +89 -0
- package/dist/graphql/resolvers.d.ts.map +1 -0
- package/dist/graphql/resolvers.js +190 -0
- package/dist/graphql/resolvers.js.map +1 -0
- package/dist/graphql/scalars.d.ts +5 -0
- package/dist/graphql/scalars.d.ts.map +1 -0
- package/dist/graphql/scalars.js +91 -0
- package/dist/graphql/scalars.js.map +1 -0
- package/dist/graphql/schema.d.ts +6 -0
- package/dist/graphql/schema.d.ts.map +1 -0
- package/dist/graphql/schema.js +254 -0
- package/dist/graphql/schema.js.map +1 -0
- package/dist/graphql/subscriptions.d.ts +44 -0
- package/dist/graphql/subscriptions.d.ts.map +1 -0
- package/dist/graphql/subscriptions.js +271 -0
- package/dist/graphql/subscriptions.js.map +1 -0
- package/dist/graphql/transport.d.ts +40 -0
- package/dist/graphql/transport.d.ts.map +1 -0
- package/dist/graphql/transport.js +234 -0
- package/dist/graphql/transport.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/express.d.ts +30 -0
- package/dist/integrations/express.d.ts.map +1 -0
- package/dist/integrations/express.js +157 -0
- package/dist/integrations/express.js.map +1 -0
- package/dist/integrations/fastify.d.ts +33 -0
- package/dist/integrations/fastify.d.ts.map +1 -0
- package/dist/integrations/fastify.js +116 -0
- package/dist/integrations/fastify.js.map +1 -0
- package/dist/integrations/hono.d.ts +27 -0
- package/dist/integrations/hono.d.ts.map +1 -0
- package/dist/integrations/hono.js +131 -0
- package/dist/integrations/hono.js.map +1 -0
- package/dist/integrations/index.d.ts +4 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +20 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +21 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/prompts.d.ts +25 -0
- package/dist/mcp/prompts.d.ts.map +1 -0
- package/dist/mcp/prompts.js +102 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/resources.d.ts +25 -0
- package/dist/mcp/resources.d.ts.map +1 -0
- package/dist/mcp/resources.js +111 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/server.d.ts +108 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +238 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +212 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +318 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/memory.d.ts +33 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +78 -0
- package/dist/memory.js.map +1 -0
- package/dist/types.d.ts +112 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +89 -4
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WORKFLOW_SCHEMA_SDL = void 0;
|
|
4
|
+
exports.createWorkflowGraphQLSchema = createWorkflowGraphQLSchema;
|
|
5
|
+
const graphql_1 = require("graphql");
|
|
6
|
+
const resolvers_1 = require("./resolvers");
|
|
7
|
+
const scalars_1 = require("./scalars");
|
|
8
|
+
exports.WORKFLOW_SCHEMA_SDL = `
|
|
9
|
+
scalar JSON
|
|
10
|
+
scalar DateTime
|
|
11
|
+
|
|
12
|
+
enum WorkflowStatus {
|
|
13
|
+
RUNNING
|
|
14
|
+
WAITING
|
|
15
|
+
COMPLETED
|
|
16
|
+
FAILED
|
|
17
|
+
CANCELLED
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
enum SortDirection {
|
|
21
|
+
ASC
|
|
22
|
+
DESC
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
enum WorkflowSortField {
|
|
26
|
+
CREATED_AT
|
|
27
|
+
UPDATED_AT
|
|
28
|
+
STATUS
|
|
29
|
+
REVISION
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
Represents a single workflow execution instance.
|
|
34
|
+
"""
|
|
35
|
+
type WorkflowExecution {
|
|
36
|
+
stackId: ID!
|
|
37
|
+
workflowId: String
|
|
38
|
+
namespace: String
|
|
39
|
+
status: WorkflowStatus!
|
|
40
|
+
revision: Int!
|
|
41
|
+
createdAt: DateTime!
|
|
42
|
+
updatedAt: DateTime!
|
|
43
|
+
expiresAt: DateTime
|
|
44
|
+
|
|
45
|
+
"""
|
|
46
|
+
Promoted top-level metadata passed during workflow initialization.
|
|
47
|
+
"""
|
|
48
|
+
metadata: JSON
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
Materialized accumulated context across all completed steps.
|
|
52
|
+
Supports optional JSONPath filtering and security redaction.
|
|
53
|
+
"""
|
|
54
|
+
context(path: String, redact: Boolean = true): JSON
|
|
55
|
+
|
|
56
|
+
"""
|
|
57
|
+
Execution breakdown of completed and in-flight steps.
|
|
58
|
+
"""
|
|
59
|
+
steps: [StepExecution!]!
|
|
60
|
+
|
|
61
|
+
"""
|
|
62
|
+
Active suspension state if status is WAITING.
|
|
63
|
+
"""
|
|
64
|
+
waitRecord: WaitRecord
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
|
+
Registered saga compensation records if configured.
|
|
68
|
+
"""
|
|
69
|
+
compensations: [CompensationRecord!]!
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type StepExecution {
|
|
73
|
+
stepId: ID!
|
|
74
|
+
name: String!
|
|
75
|
+
status: String!
|
|
76
|
+
output(redact: Boolean = true): JSON
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type WaitRecord {
|
|
80
|
+
correlationKey: String!
|
|
81
|
+
eventName: String
|
|
82
|
+
expiresAt: DateTime
|
|
83
|
+
lockedBy: String
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type CompensationRecord {
|
|
87
|
+
stepId: String!
|
|
88
|
+
stepName: String!
|
|
89
|
+
status: String!
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
input WorkflowFilterInput {
|
|
93
|
+
workflowId: String
|
|
94
|
+
namespace: String
|
|
95
|
+
status: WorkflowStatus
|
|
96
|
+
createdAfter: DateTime
|
|
97
|
+
createdBefore: DateTime
|
|
98
|
+
correlationKey: String
|
|
99
|
+
"""Filter against promoted metadata fields (e.g. { orderId: "ord_123" })"""
|
|
100
|
+
metadata: JSON
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
input WorkflowSortInput {
|
|
104
|
+
field: WorkflowSortField! = CREATED_AT
|
|
105
|
+
direction: SortDirection! = DESC
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
input PaginationInput {
|
|
109
|
+
limit: Int = 20
|
|
110
|
+
cursor: String
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
type PageInfo {
|
|
114
|
+
hasNextPage: Boolean!
|
|
115
|
+
hasPreviousPage: Boolean!
|
|
116
|
+
startCursor: String
|
|
117
|
+
endCursor: String
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
type WorkflowEdge {
|
|
121
|
+
cursor: String!
|
|
122
|
+
node: WorkflowExecution!
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
type WorkflowConnection {
|
|
126
|
+
edges: [WorkflowEdge!]!
|
|
127
|
+
pageInfo: PageInfo!
|
|
128
|
+
totalCount: Int!
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
type Query {
|
|
132
|
+
"""
|
|
133
|
+
Retrieve a single workflow execution by its unique stackId.
|
|
134
|
+
"""
|
|
135
|
+
workflow(stackId: ID!, namespace: String): WorkflowExecution
|
|
136
|
+
|
|
137
|
+
"""
|
|
138
|
+
Query and filter workflow executions with cursor-based pagination.
|
|
139
|
+
"""
|
|
140
|
+
workflows(
|
|
141
|
+
filter: WorkflowFilterInput
|
|
142
|
+
sort: WorkflowSortInput
|
|
143
|
+
pagination: PaginationInput
|
|
144
|
+
): WorkflowConnection!
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
type Mutation {
|
|
148
|
+
"""
|
|
149
|
+
Resume a suspended durable workflow waiting on an external event.
|
|
150
|
+
"""
|
|
151
|
+
resumeWorkflow(
|
|
152
|
+
correlationKey: String!
|
|
153
|
+
payload: JSON
|
|
154
|
+
namespace: String
|
|
155
|
+
): Boolean!
|
|
156
|
+
|
|
157
|
+
"""
|
|
158
|
+
Cancel an active or waiting workflow execution stack.
|
|
159
|
+
"""
|
|
160
|
+
cancelWorkflow(stackId: ID!, reason: String): Boolean!
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
type Subscription {
|
|
164
|
+
"""
|
|
165
|
+
Subscribe to real-time status transitions and context updates for a workflow.
|
|
166
|
+
"""
|
|
167
|
+
workflowUpdated(stackId: ID!, namespace: String): WorkflowExecution!
|
|
168
|
+
|
|
169
|
+
"""
|
|
170
|
+
Subscribe to workflow completion or failure events within a namespace.
|
|
171
|
+
"""
|
|
172
|
+
workflowCompleted(namespace: String!): WorkflowExecution!
|
|
173
|
+
}
|
|
174
|
+
`;
|
|
175
|
+
function createWorkflowGraphQLSchema(engine, options) {
|
|
176
|
+
const schema = (0, graphql_1.buildSchema)(exports.WORKFLOW_SCHEMA_SDL);
|
|
177
|
+
const jsonType = schema.getType('JSON');
|
|
178
|
+
if (jsonType) {
|
|
179
|
+
const serializeJson = (val) => scalars_1.GraphQLJSON.serialize(val);
|
|
180
|
+
const parseValueJson = (val) => scalars_1.GraphQLJSON.parseValue(val);
|
|
181
|
+
const parseLiteralJson = (ast, vars) => scalars_1.GraphQLJSON.parseLiteral(ast, vars);
|
|
182
|
+
Object.assign(jsonType, {
|
|
183
|
+
serialize: serializeJson,
|
|
184
|
+
coerceOutputValue: serializeJson,
|
|
185
|
+
parseValue: parseValueJson,
|
|
186
|
+
coerceInputValue: parseValueJson,
|
|
187
|
+
parseLiteral: parseLiteralJson,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
const dateTimeType = schema.getType('DateTime');
|
|
191
|
+
if (dateTimeType) {
|
|
192
|
+
const serializeDateTime = (val) => scalars_1.GraphQLDateTime.serialize(val);
|
|
193
|
+
const parseValueDateTime = (val) => scalars_1.GraphQLDateTime.parseValue(val);
|
|
194
|
+
const parseLiteralDateTime = (ast, vars) => scalars_1.GraphQLDateTime.parseLiteral(ast, vars);
|
|
195
|
+
Object.assign(dateTimeType, {
|
|
196
|
+
serialize: serializeDateTime,
|
|
197
|
+
coerceOutputValue: serializeDateTime,
|
|
198
|
+
parseValue: parseValueDateTime,
|
|
199
|
+
coerceInputValue: parseValueDateTime,
|
|
200
|
+
parseLiteral: parseLiteralDateTime,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
const resolvers = (0, resolvers_1.createResolvers)(engine, options);
|
|
204
|
+
const queryType = schema.getType('Query');
|
|
205
|
+
if (queryType instanceof graphql_1.GraphQLObjectType) {
|
|
206
|
+
const queryFields = queryType.getFields();
|
|
207
|
+
if (queryFields.workflow)
|
|
208
|
+
queryFields.workflow.resolve = resolvers.Query.workflow;
|
|
209
|
+
if (queryFields.workflows)
|
|
210
|
+
queryFields.workflows.resolve = resolvers.Query.workflows;
|
|
211
|
+
}
|
|
212
|
+
const mutationType = schema.getType('Mutation');
|
|
213
|
+
if (mutationType instanceof graphql_1.GraphQLObjectType) {
|
|
214
|
+
const mutationFields = mutationType.getFields();
|
|
215
|
+
if (mutationFields.resumeWorkflow)
|
|
216
|
+
mutationFields.resumeWorkflow.resolve = resolvers.Mutation.resumeWorkflow;
|
|
217
|
+
if (mutationFields.cancelWorkflow)
|
|
218
|
+
mutationFields.cancelWorkflow.resolve = resolvers.Mutation.cancelWorkflow;
|
|
219
|
+
}
|
|
220
|
+
const subscriptionType = schema.getType('Subscription');
|
|
221
|
+
if (subscriptionType instanceof graphql_1.GraphQLObjectType) {
|
|
222
|
+
const subFields = subscriptionType.getFields();
|
|
223
|
+
if (subFields.workflowUpdated) {
|
|
224
|
+
subFields.workflowUpdated.subscribe = resolvers.Subscription.workflowUpdated.subscribe;
|
|
225
|
+
subFields.workflowUpdated.resolve = resolvers.Subscription.workflowUpdated.resolve;
|
|
226
|
+
}
|
|
227
|
+
if (subFields.workflowCompleted) {
|
|
228
|
+
subFields.workflowCompleted.subscribe = resolvers.Subscription.workflowCompleted.subscribe;
|
|
229
|
+
subFields.workflowCompleted.resolve = resolvers.Subscription.workflowCompleted.resolve;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const executionType = schema.getType('WorkflowExecution');
|
|
233
|
+
if (executionType instanceof graphql_1.GraphQLObjectType) {
|
|
234
|
+
const execFields = executionType.getFields();
|
|
235
|
+
if (execFields.status)
|
|
236
|
+
execFields.status.resolve = resolvers.WorkflowExecution.status;
|
|
237
|
+
if (execFields.context)
|
|
238
|
+
execFields.context.resolve = resolvers.WorkflowExecution.context;
|
|
239
|
+
if (execFields.steps)
|
|
240
|
+
execFields.steps.resolve = resolvers.WorkflowExecution.steps;
|
|
241
|
+
if (execFields.waitRecord)
|
|
242
|
+
execFields.waitRecord.resolve = resolvers.WorkflowExecution.waitRecord;
|
|
243
|
+
if (execFields.compensations)
|
|
244
|
+
execFields.compensations.resolve = resolvers.WorkflowExecution.compensations;
|
|
245
|
+
}
|
|
246
|
+
const stepType = schema.getType('StepExecution');
|
|
247
|
+
if (stepType instanceof graphql_1.GraphQLObjectType) {
|
|
248
|
+
const stepFields = stepType.getFields();
|
|
249
|
+
if (stepFields.output)
|
|
250
|
+
stepFields.output.resolve = resolvers.StepExecution.output;
|
|
251
|
+
}
|
|
252
|
+
return schema;
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/graphql/schema.ts"],"names":[],"mappings":";;;AA8KA,kEAkFC;AAhQD,qCAA6F;AAG7F,2CAA8C;AAC9C,uCAAyD;AAE5C,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsKlC,CAAC;AAEF,SAAgB,2BAA2B,CACvC,MAA2B,EAC3B,OAAsC;IAEtC,MAAM,MAAM,GAAG,IAAA,qBAAW,EAAC,2BAAmB,CAAC,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,IAAI,QAAQ,EAAE,CAAC;QACX,MAAM,aAAa,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,qBAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACnE,MAAM,cAAc,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,qBAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACrE,MAAM,gBAAgB,GAAG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L,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,IAAI,aAAa,YAAY,2BAAiB,EAAE,CAAC;QAC7C,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,EAAE,CAAC;QAC7C,IAAI,UAAU,CAAC,MAAM;YAAE,UAAU,CAAC,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC;QACtF,IAAI,UAAU,CAAC,OAAO;YAAE,UAAU,CAAC,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC;QACzF,IAAI,UAAU,CAAC,KAAK;YAAE,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC;QACnF,IAAI,UAAU,CAAC,UAAU;YAAE,UAAU,CAAC,UAAU,CAAC,OAAO,GAAG,SAAS,CAAC,iBAAiB,CAAC,UAAU,CAAC;QAClG,IAAI,UAAU,CAAC,aAAa;YAAE,UAAU,CAAC,aAAa,CAAC,OAAO,GAAG,SAAS,CAAC,iBAAiB,CAAC,aAAa,CAAC;IAC/G,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACjD,IAAI,QAAQ,YAAY,2BAAiB,EAAE,CAAC;QACxC,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;QACxC,IAAI,UAAU,CAAC,MAAM;YAAE,UAAU,CAAC,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC;IACtF,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type WorkflowEventEmitter } from '@siglo/core';
|
|
2
|
+
import type { WorkflowQueryEngine } from '../engine';
|
|
3
|
+
import type { WorkflowExecution } from '../types';
|
|
4
|
+
export declare class AsyncPushQueue<T> implements AsyncIterable<T>, AsyncIterator<T> {
|
|
5
|
+
private readonly queue;
|
|
6
|
+
private readonly resolvers;
|
|
7
|
+
private closed;
|
|
8
|
+
private onDispose?;
|
|
9
|
+
constructor(onDispose?: () => void);
|
|
10
|
+
push(item: T): void;
|
|
11
|
+
close(): void;
|
|
12
|
+
next(): Promise<IteratorResult<T>>;
|
|
13
|
+
return(): Promise<IteratorResult<T>>;
|
|
14
|
+
throw(err?: unknown): Promise<IteratorResult<T>>;
|
|
15
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
|
16
|
+
}
|
|
17
|
+
export interface WorkflowSubscriptionManager {
|
|
18
|
+
publishWorkflowUpdated(execution: WorkflowExecution): void;
|
|
19
|
+
publishWorkflowCompleted(execution: WorkflowExecution): void;
|
|
20
|
+
subscribeWorkflowUpdated(stackId: string, namespace: string): AsyncIterable<WorkflowExecution>;
|
|
21
|
+
subscribeWorkflowCompleted(namespace: string): AsyncIterable<WorkflowExecution>;
|
|
22
|
+
subscriberCount?(type?: 'workflowUpdated' | 'workflowCompleted'): number;
|
|
23
|
+
close(): void;
|
|
24
|
+
}
|
|
25
|
+
export interface WorkflowSubscriptionManagerOptions {
|
|
26
|
+
engine?: WorkflowQueryEngine;
|
|
27
|
+
emitter?: WorkflowEventEmitter;
|
|
28
|
+
}
|
|
29
|
+
export declare class DefaultWorkflowSubscriptionManager implements WorkflowSubscriptionManager {
|
|
30
|
+
private readonly subscriptions;
|
|
31
|
+
private readonly engine?;
|
|
32
|
+
private readonly emitter?;
|
|
33
|
+
private readonly eventListener;
|
|
34
|
+
constructor(options?: WorkflowSubscriptionManagerOptions);
|
|
35
|
+
private handleEvent;
|
|
36
|
+
publishWorkflowUpdated(execution: WorkflowExecution): void;
|
|
37
|
+
publishWorkflowCompleted(execution: WorkflowExecution): void;
|
|
38
|
+
subscribeWorkflowUpdated(stackId: string, namespace: string): AsyncIterable<WorkflowExecution>;
|
|
39
|
+
subscribeWorkflowCompleted(namespace: string): AsyncIterable<WorkflowExecution>;
|
|
40
|
+
subscriberCount(type?: 'workflowUpdated' | 'workflowCompleted'): number;
|
|
41
|
+
close(): void;
|
|
42
|
+
}
|
|
43
|
+
export declare function createWorkflowSubscriptionManager(options?: WorkflowSubscriptionManagerOptions): WorkflowSubscriptionManager;
|
|
44
|
+
//# sourceMappingURL=subscriptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../../src/graphql/subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,oBAAoB,EAA+B,MAAM,aAAa,CAAC;AAClH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,UAAU,CAAC;AAElE,qBAAa,cAAc,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkD;IAC5E,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAC,CAAa;gBAEnB,SAAS,CAAC,EAAE,MAAM,IAAI;IAIlC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAUnB,KAAK,IAAI,IAAI;IAWb,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAYlC,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAKpC,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAKhD,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC;CAGrD;AAED,MAAM,WAAW,2BAA2B;IACxC,sBAAsB,CAAC,SAAS,EAA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B"}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultWorkflowSubscriptionManager = exports.AsyncPushQueue = void 0;
|
|
4
|
+
exports.createWorkflowSubscriptionManager = createWorkflowSubscriptionManager;
|
|
5
|
+
const core_1 = require("@siglo/core");
|
|
6
|
+
class AsyncPushQueue {
|
|
7
|
+
queue = [];
|
|
8
|
+
resolvers = [];
|
|
9
|
+
closed = false;
|
|
10
|
+
onDispose;
|
|
11
|
+
constructor(onDispose) {
|
|
12
|
+
this.onDispose = onDispose;
|
|
13
|
+
}
|
|
14
|
+
push(item) {
|
|
15
|
+
if (this.closed)
|
|
16
|
+
return;
|
|
17
|
+
const nextResolve = this.resolvers.shift();
|
|
18
|
+
if (nextResolve) {
|
|
19
|
+
nextResolve({ value: item, done: false });
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.queue.push(item);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
close() {
|
|
26
|
+
if (this.closed)
|
|
27
|
+
return;
|
|
28
|
+
this.closed = true;
|
|
29
|
+
while (this.resolvers.length > 0) {
|
|
30
|
+
const resolve = this.resolvers.shift();
|
|
31
|
+
resolve({ value: undefined, done: true });
|
|
32
|
+
}
|
|
33
|
+
this.onDispose?.();
|
|
34
|
+
this.onDispose = undefined;
|
|
35
|
+
}
|
|
36
|
+
next() {
|
|
37
|
+
if (this.queue.length > 0) {
|
|
38
|
+
return Promise.resolve({ value: this.queue.shift(), done: false });
|
|
39
|
+
}
|
|
40
|
+
if (this.closed) {
|
|
41
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
42
|
+
}
|
|
43
|
+
return new Promise(resolve => {
|
|
44
|
+
this.resolvers.push(resolve);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return() {
|
|
48
|
+
this.close();
|
|
49
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
50
|
+
}
|
|
51
|
+
throw(err) {
|
|
52
|
+
this.close();
|
|
53
|
+
return Promise.reject(err);
|
|
54
|
+
}
|
|
55
|
+
[Symbol.asyncIterator]() {
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.AsyncPushQueue = AsyncPushQueue;
|
|
60
|
+
function mapEventToStatus(event) {
|
|
61
|
+
switch (event.type) {
|
|
62
|
+
case 'flow:complete':
|
|
63
|
+
return event.status === 'FAILED' ? 'failed' : 'completed';
|
|
64
|
+
case 'flow:error':
|
|
65
|
+
return 'failed';
|
|
66
|
+
case 'flow:suspended':
|
|
67
|
+
return 'waiting';
|
|
68
|
+
case 'flow:resumed':
|
|
69
|
+
return 'running';
|
|
70
|
+
case 'checkpoint:save':
|
|
71
|
+
if (event.status) {
|
|
72
|
+
const s = event.status.toLowerCase();
|
|
73
|
+
if (s === 'completed' || s === 'failed' || s === 'cancelled' || s === 'waiting') {
|
|
74
|
+
return s;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return 'running';
|
|
78
|
+
case 'branch:selected':
|
|
79
|
+
case 'step:inspection':
|
|
80
|
+
case 'ai:complete':
|
|
81
|
+
case 'flow:start':
|
|
82
|
+
case 'step:start':
|
|
83
|
+
case 'step:complete':
|
|
84
|
+
case 'step:retry':
|
|
85
|
+
case 'step:error':
|
|
86
|
+
case 'step:skipped':
|
|
87
|
+
case 'context:change':
|
|
88
|
+
case 'cache:hit':
|
|
89
|
+
case 'cache:miss':
|
|
90
|
+
case 'notification:dispatched':
|
|
91
|
+
case 'approval:requested':
|
|
92
|
+
return 'running';
|
|
93
|
+
default: {
|
|
94
|
+
const _exhaustive = event;
|
|
95
|
+
void _exhaustive;
|
|
96
|
+
return 'running';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function createExecutionFromEvent(event, namespace) {
|
|
101
|
+
const status = mapEventToStatus(event);
|
|
102
|
+
return {
|
|
103
|
+
stackId: event.stackId ?? 'unknown',
|
|
104
|
+
namespace: event.namespace ?? namespace,
|
|
105
|
+
workflowId: 'flowName' in event ? event.flowName : undefined,
|
|
106
|
+
status,
|
|
107
|
+
revision: 1,
|
|
108
|
+
createdAt: new Date(event.timestamp),
|
|
109
|
+
updatedAt: new Date(event.timestamp),
|
|
110
|
+
steps: [],
|
|
111
|
+
compensations: [],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
class DefaultWorkflowSubscriptionManager {
|
|
115
|
+
subscriptions = new Set();
|
|
116
|
+
engine;
|
|
117
|
+
emitter;
|
|
118
|
+
eventListener;
|
|
119
|
+
constructor(options) {
|
|
120
|
+
this.engine = options?.engine;
|
|
121
|
+
this.emitter = options?.emitter ?? core_1.defaultWorkflowEventEmitter;
|
|
122
|
+
this.eventListener = (event) => {
|
|
123
|
+
void this.handleEvent(event);
|
|
124
|
+
};
|
|
125
|
+
if (this.emitter) {
|
|
126
|
+
this.emitter.on('*', this.eventListener);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async handleEvent(event) {
|
|
130
|
+
if (!event)
|
|
131
|
+
return;
|
|
132
|
+
const stackId = event.stackId;
|
|
133
|
+
if (!stackId)
|
|
134
|
+
return;
|
|
135
|
+
const isCompletionEvent = event.type === 'flow:complete' ||
|
|
136
|
+
event.type === 'flow:error' ||
|
|
137
|
+
(event.type === 'checkpoint:save' &&
|
|
138
|
+
event.status !== undefined &&
|
|
139
|
+
['completed', 'failed', 'cancelled'].includes(event.status.toLowerCase()));
|
|
140
|
+
// Group matching subscribers to avoid redundant engine queries
|
|
141
|
+
const matchingUpdated = [];
|
|
142
|
+
const matchingCompleted = [];
|
|
143
|
+
for (const sub of this.subscriptions) {
|
|
144
|
+
if (sub.type === 'workflowUpdated' && sub.stackId === stackId) {
|
|
145
|
+
if (!event.namespace || sub.namespace === event.namespace) {
|
|
146
|
+
matchingUpdated.push(sub);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else if (sub.type === 'workflowCompleted' && isCompletionEvent) {
|
|
150
|
+
if (!event.namespace || sub.namespace === event.namespace) {
|
|
151
|
+
matchingCompleted.push(sub);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (matchingUpdated.length === 0 && matchingCompleted.length === 0) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
// Cache loaded executions by namespace
|
|
159
|
+
const executionCache = new Map();
|
|
160
|
+
const getExecution = async (namespace) => {
|
|
161
|
+
let exec = executionCache.get(namespace);
|
|
162
|
+
if (!exec) {
|
|
163
|
+
if (this.engine) {
|
|
164
|
+
try {
|
|
165
|
+
await Promise.resolve();
|
|
166
|
+
const found = await this.engine.findById(stackId, {
|
|
167
|
+
namespace,
|
|
168
|
+
includeContext: true,
|
|
169
|
+
});
|
|
170
|
+
if (found) {
|
|
171
|
+
exec = found;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
// ignore and fall back to event synthesized execution
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (!exec) {
|
|
179
|
+
if (!event.namespace)
|
|
180
|
+
return undefined;
|
|
181
|
+
exec = createExecutionFromEvent(event, namespace);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const transitionStatus = mapEventToStatus(event);
|
|
185
|
+
if (event.type.startsWith('flow:') || event.type === 'checkpoint:save') {
|
|
186
|
+
exec.status = transitionStatus;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
executionCache.set(namespace, exec);
|
|
190
|
+
}
|
|
191
|
+
return exec;
|
|
192
|
+
};
|
|
193
|
+
for (const sub of matchingUpdated) {
|
|
194
|
+
const execution = await getExecution(sub.namespace);
|
|
195
|
+
if (execution)
|
|
196
|
+
sub.queue.push(execution);
|
|
197
|
+
}
|
|
198
|
+
for (const sub of matchingCompleted) {
|
|
199
|
+
const execution = await getExecution(sub.namespace);
|
|
200
|
+
if (execution)
|
|
201
|
+
sub.queue.push(execution);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
publishWorkflowUpdated(execution) {
|
|
205
|
+
for (const sub of this.subscriptions) {
|
|
206
|
+
if (sub.type === 'workflowUpdated' &&
|
|
207
|
+
sub.stackId === execution.stackId &&
|
|
208
|
+
sub.namespace === execution.namespace) {
|
|
209
|
+
sub.queue.push(execution);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
publishWorkflowCompleted(execution) {
|
|
214
|
+
for (const sub of this.subscriptions) {
|
|
215
|
+
if (sub.type === 'workflowCompleted' && sub.namespace === execution.namespace) {
|
|
216
|
+
sub.queue.push(execution);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
subscribeWorkflowUpdated(stackId, namespace) {
|
|
221
|
+
let registration;
|
|
222
|
+
const queue = new AsyncPushQueue(() => {
|
|
223
|
+
this.subscriptions.delete(registration);
|
|
224
|
+
});
|
|
225
|
+
registration = {
|
|
226
|
+
type: 'workflowUpdated',
|
|
227
|
+
stackId,
|
|
228
|
+
namespace,
|
|
229
|
+
queue,
|
|
230
|
+
};
|
|
231
|
+
this.subscriptions.add(registration);
|
|
232
|
+
return queue;
|
|
233
|
+
}
|
|
234
|
+
subscribeWorkflowCompleted(namespace) {
|
|
235
|
+
let registration;
|
|
236
|
+
const queue = new AsyncPushQueue(() => {
|
|
237
|
+
this.subscriptions.delete(registration);
|
|
238
|
+
});
|
|
239
|
+
registration = {
|
|
240
|
+
type: 'workflowCompleted',
|
|
241
|
+
namespace,
|
|
242
|
+
queue,
|
|
243
|
+
};
|
|
244
|
+
this.subscriptions.add(registration);
|
|
245
|
+
return queue;
|
|
246
|
+
}
|
|
247
|
+
subscriberCount(type) {
|
|
248
|
+
if (!type)
|
|
249
|
+
return this.subscriptions.size;
|
|
250
|
+
let count = 0;
|
|
251
|
+
for (const sub of this.subscriptions) {
|
|
252
|
+
if (sub.type === type)
|
|
253
|
+
count++;
|
|
254
|
+
}
|
|
255
|
+
return count;
|
|
256
|
+
}
|
|
257
|
+
close() {
|
|
258
|
+
if (this.emitter) {
|
|
259
|
+
this.emitter.off('*', this.eventListener);
|
|
260
|
+
}
|
|
261
|
+
for (const sub of Array.from(this.subscriptions)) {
|
|
262
|
+
sub.queue.close();
|
|
263
|
+
}
|
|
264
|
+
this.subscriptions.clear();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
exports.DefaultWorkflowSubscriptionManager = DefaultWorkflowSubscriptionManager;
|
|
268
|
+
function createWorkflowSubscriptionManager(options) {
|
|
269
|
+
return new DefaultWorkflowSubscriptionManager(options);
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=subscriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/graphql/subscriptions.ts"],"names":[],"mappings":";;;AAgTA,8EAIC;AApTD,sCAAkH;AAIlH,MAAa,cAAc;IACN,KAAK,GAAQ,EAAE,CAAC;IAChB,SAAS,GAA+C,EAAE,CAAC;IACpE,MAAM,GAAG,KAAK,CAAC;IACf,SAAS,CAAc;IAE/B,YAAY,SAAsB;QAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,IAAO;QACR,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAC3C,IAAI,WAAW,EAAE,CAAC;YACd,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC;IAED,KAAK;QACD,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC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KAAK,GAAG,IAAI,cAAc,CAAoB,GAAG,EAAE;YACrD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QACH,YAAY,GAAG;YACX,IAAI,EAAE,mBAAmB;YACzB,SAAS;YACT,KAAK;SACR,CAAC;QACF,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,eAAe,CAAC,IAA8C;QAC1D,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;QAC1C,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACnC,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI;gBAAE,KAAK,EAAE,CAAC;QACnC,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,KAAK;QACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAC9C,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/C,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CACJ;AAnKD,gFAmKC;AAED,SAAgB,iCAAiC,CAC7C,OAA4C;IAE5C,OAAO,IAAI,kCAAkC,CAAC,OAAO,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type GraphQLSchema, type Source } from 'graphql';
|
|
2
|
+
import { type WorkflowGraphQLContext } from './resolvers';
|
|
3
|
+
export interface SSEEvent {
|
|
4
|
+
event?: string;
|
|
5
|
+
data: unknown;
|
|
6
|
+
id?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function formatSSEEvent(event: SSEEvent): string;
|
|
9
|
+
export interface WorkflowSSEStreamOptions {
|
|
10
|
+
schema: GraphQLSchema;
|
|
11
|
+
query: string | Source;
|
|
12
|
+
variables?: Record<string, unknown>;
|
|
13
|
+
context?: WorkflowGraphQLContext;
|
|
14
|
+
operationName?: string;
|
|
15
|
+
keepAliveIntervalMs?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function createWorkflowSSEStream(options: WorkflowSSEStreamOptions): AsyncIterable<string>;
|
|
18
|
+
export declare function createWorkflowSSEResponse(stream: AsyncIterable<string>, init?: ResponseInit): Response;
|
|
19
|
+
export interface NodeServerResponseLike {
|
|
20
|
+
writeHead?(statusCode: number, headers?: Record<string, string>): void;
|
|
21
|
+
setHeader?(name: string, value: string): void;
|
|
22
|
+
write(chunk: string | Uint8Array): boolean;
|
|
23
|
+
end(): void;
|
|
24
|
+
on(event: 'close' | 'finish', listener: () => void): this;
|
|
25
|
+
flushHeaders?(): void;
|
|
26
|
+
flush?(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare function pipeWorkflowSSEToResponse(res: NodeServerResponseLike, stream: AsyncIterable<string>): () => void;
|
|
29
|
+
export interface GraphQLWSConnectionContextLike {
|
|
30
|
+
connectionParams?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
export interface WorkflowWSHandlerOptions {
|
|
33
|
+
schema: GraphQLSchema;
|
|
34
|
+
context?: (ctx: GraphQLWSConnectionContextLike) => Promise<WorkflowGraphQLContext> | WorkflowGraphQLContext;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a graphql-ws server handler if graphql-ws is available in the environment.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createWorkflowWSHandler(options: WorkflowWSHandlerOptions, wsServer?: unknown): any;
|
|
40
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,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