@siglo/query 0.0.0-stage → 1.2.8
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 +49 -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 +178 -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 +86 -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 +253 -0
- package/dist/graphql/subscriptions.js.map +1 -0
- package/dist/graphql/transport.d.ts +37 -0
- package/dist/graphql/transport.d.ts.map +1 -0
- package/dist/graphql/transport.js +230 -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 +17 -0
- package/dist/integrations/express.d.ts.map +1 -0
- package/dist/integrations/express.js +150 -0
- package/dist/integrations/express.js.map +1 -0
- package/dist/integrations/fastify.d.ts +17 -0
- package/dist/integrations/fastify.d.ts.map +1 -0
- package/dist/integrations/fastify.js +110 -0
- package/dist/integrations/fastify.js.map +1 -0
- package/dist/integrations/hono.d.ts +18 -0
- package/dist/integrations/hono.d.ts.map +1 -0
- package/dist/integrations/hono.js +126 -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 +233 -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 +317 -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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Jerico de guzman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @siglo/query
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Storage-agnostic workflow query engine, GraphQL schema & resolvers, real-time SSE/WebSocket subscriptions, drop-in web framework route handlers (Express, Fastify, Hono), and Model Context Protocol (MCP) server for [Siglo](https://github.com/jsoftgem/siglo) workflows.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @siglo/query @siglo/core graphql
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### 1. Programmatic Query Engine
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { createWorkflowQueryEngine } from '@siglo/query';
|
|
17
|
+
import { defaultStorageManager } from '@siglo/core';
|
|
18
|
+
|
|
19
|
+
const engine = createWorkflowQueryEngine({
|
|
20
|
+
storage: defaultStorageManager.getAdapter(),
|
|
21
|
+
redactFields: ['apiKey', 'password', 'token', 'secret'],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const page = await engine.findMany({
|
|
25
|
+
filter: { namespace: 'tenant-acme', status: 'running' },
|
|
26
|
+
pagination: { limit: 20 },
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. Web Framework Route Mounts
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import express from 'express';
|
|
34
|
+
import { createExpressQueryMiddleware } from '@siglo/query';
|
|
35
|
+
|
|
36
|
+
const app = express();
|
|
37
|
+
app.use(express.json());
|
|
38
|
+
app.use(
|
|
39
|
+
'/graphql',
|
|
40
|
+
createExpressQueryMiddleware({
|
|
41
|
+
engine,
|
|
42
|
+
namespace: req => req.headers['x-tenant-id'],
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 3. Model Context Protocol (MCP) Server (`@siglo/query/mcp`)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { createWorkflowMcpServer } from '@siglo/query/mcp';
|
|
51
|
+
import { defaultStorageManager } from '@siglo/core';
|
|
52
|
+
|
|
53
|
+
const mcpServer = createWorkflowMcpServer({
|
|
54
|
+
storage: defaultStorageManager.getAdapter(),
|
|
55
|
+
namespace: 'tenant-acme',
|
|
56
|
+
redactFields: ['apiKey', 'password', 'token', 'secret'],
|
|
57
|
+
transport: 'stdio',
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
await mcpServer.start();
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT
|
package/dist/cursor.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { QueryCheckpoint, WorkflowSortInput } from './types';
|
|
2
|
+
export declare function sortOrder(sort?: WorkflowSortInput): {
|
|
3
|
+
field: "status" | "revision" | "createdAt" | "updatedAt";
|
|
4
|
+
direction: "asc" | "desc";
|
|
5
|
+
};
|
|
6
|
+
type Order = ReturnType<typeof sortOrder>;
|
|
7
|
+
type Position = {
|
|
8
|
+
value: string | number;
|
|
9
|
+
stackId: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function position(record: QueryCheckpoint, { field }: Order): Position;
|
|
12
|
+
export declare function compare(a: Position, b: Position, order: Order): number;
|
|
13
|
+
export declare function encodeCursor(record: QueryCheckpoint, order: Order): string;
|
|
14
|
+
export declare function decodeCursor(cursor: string, order: Order): Position;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=cursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../src/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAElE,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,iBAAiB;;;EAMjD;AAED,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC1C,KAAK,QAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,GAAG,QAAQ,CAQ5E;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,UAI7D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,UAEjE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,QAAQ,CAgBnE"}
|
package/dist/cursor.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortOrder = sortOrder;
|
|
4
|
+
exports.position = position;
|
|
5
|
+
exports.compare = compare;
|
|
6
|
+
exports.encodeCursor = encodeCursor;
|
|
7
|
+
exports.decodeCursor = decodeCursor;
|
|
8
|
+
function sortOrder(sort) {
|
|
9
|
+
const field = sort?.field ?? 'createdAt';
|
|
10
|
+
const direction = sort?.direction ?? 'desc';
|
|
11
|
+
if (!['createdAt', 'updatedAt', 'status', 'revision'].includes(field) || !['asc', 'desc'].includes(direction))
|
|
12
|
+
throw new Error('Invalid workflow sort');
|
|
13
|
+
return { field, direction };
|
|
14
|
+
}
|
|
15
|
+
function position(record, { field }) {
|
|
16
|
+
const values = {
|
|
17
|
+
createdAt: record.createdAt ?? record.timestamp,
|
|
18
|
+
updatedAt: record.timestamp,
|
|
19
|
+
revision: record.revision,
|
|
20
|
+
status: record.status ?? 'running',
|
|
21
|
+
};
|
|
22
|
+
return { value: values[field], stackId: record.stackId };
|
|
23
|
+
}
|
|
24
|
+
function compare(a, b, order) {
|
|
25
|
+
const diff = a.value < b.value ? -1 : a.value > b.value ? 1 : 0;
|
|
26
|
+
if (diff)
|
|
27
|
+
return order.direction === 'asc' ? diff : -diff;
|
|
28
|
+
return a.stackId < b.stackId ? -1 : Number(a.stackId > b.stackId);
|
|
29
|
+
}
|
|
30
|
+
function encodeCursor(record, order) {
|
|
31
|
+
return Buffer.from(JSON.stringify({ ...order, ...position(record, order) })).toString('base64url');
|
|
32
|
+
}
|
|
33
|
+
function decodeCursor(cursor, order) {
|
|
34
|
+
try {
|
|
35
|
+
const bytes = Buffer.from(cursor, 'base64url');
|
|
36
|
+
const data = JSON.parse(bytes.toString());
|
|
37
|
+
if (bytes.toString('base64url') === cursor &&
|
|
38
|
+
data.field === order.field &&
|
|
39
|
+
data.direction === order.direction &&
|
|
40
|
+
typeof data.stackId === 'string' &&
|
|
41
|
+
(order.field === 'status' ? typeof data.value === 'string' : Number.isFinite(data.value)))
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Treat malformed and incompatible tokens alike.
|
|
46
|
+
}
|
|
47
|
+
throw new Error('Invalid workflow cursor');
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../src/cursor.ts"],"names":[],"mappings":";;AAEA,8BAMC;AAKD,4BAQC;AAED,0BAIC;AAED,oCAEC;AAED,oCAgBC;AA/CD,SAAgB,SAAS,CAAC,IAAwB;IAC9C,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,WAAW,CAAC;IACzC,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,MAAM,CAAC;IAC5C,IAAI,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QACzG,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC7C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC;AAKD,SAAgB,QAAQ,CAAC,MAAuB,EAAE,EAAE,KAAK,EAAS;IAC9D,MAAM,MAAM,GAAG;QACX,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS;QAC/C,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,S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AI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK;YAC1B,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS;YAClC,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;YAChC,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAEzF,OAAO,IAAI,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACL,iDAAiD;IACrD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC/C,CAAC"}
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type WorkflowEventEmitter } from '@siglo/core';
|
|
2
|
+
import { type WorkflowSubscriptionManager } from './graphql/subscriptions';
|
|
3
|
+
import type { WorkflowExecution, WorkflowPage, WorkflowQuery, WorkflowQueryOptions, WorkflowSelection } from './types';
|
|
4
|
+
export declare class WorkflowQueryEngine {
|
|
5
|
+
private readonly fields;
|
|
6
|
+
private readonly storage;
|
|
7
|
+
private readonly subscriptionManager;
|
|
8
|
+
private readonly emitter?;
|
|
9
|
+
private readonly resolveWorkflow;
|
|
10
|
+
constructor(options: WorkflowQueryOptions);
|
|
11
|
+
getRedactFields(): ReadonlySet<string>;
|
|
12
|
+
getSubscriptionManager(): WorkflowSubscriptionManager;
|
|
13
|
+
getEmitter(): WorkflowEventEmitter | undefined;
|
|
14
|
+
private project;
|
|
15
|
+
findById(stackId: string, options: WorkflowSelection & {
|
|
16
|
+
namespace: string;
|
|
17
|
+
redact?: boolean;
|
|
18
|
+
}): Promise<WorkflowExecution | undefined>;
|
|
19
|
+
findMany({ filter, sort, pagination, select }: WorkflowQuery): Promise<WorkflowPage>;
|
|
20
|
+
cancelWorkflow(stackId: string, options: {
|
|
21
|
+
reason?: string;
|
|
22
|
+
namespace: string;
|
|
23
|
+
}): Promise<boolean>;
|
|
24
|
+
resumeWorkflow(correlationKey: string, payload?: unknown, namespace?: string): Promise<boolean>;
|
|
25
|
+
}
|
|
26
|
+
export declare function createWorkflowQueryEngine(options: WorkflowQueryOptions): WorkflowQueryEngine;
|
|
27
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,oBAAoB,EAC5B,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAqC,KAAK,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAC9G,OAAO,KAAK,EAMR,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACpB,MAAM,SAAS,CAAC;AAkBjB,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+C;IACvE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA8B;IAClE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAuB;IAEhD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA0C;gBAE9D,OAAO,EAAE,oBAAoB;IAczC,eAAe,IAAI,WAAW,CAAC,MAAM,CAAC;IAItC,sBAAsB,IAAI,2BAA2B;IAIrD,UAAU,IAAI,oBAAoB,GAAG,SAAS;IAI9C,OAAO,CAAC,OAAO;IA+FT,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE;IAS9F,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAW,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAsCzF,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAqBlG,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAcxG;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,oBAAoB,uBAEtE"}
|
package/dist/engine.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowQueryEngine = void 0;
|
|
4
|
+
exports.createWorkflowQueryEngine = createWorkflowQueryEngine;
|
|
5
|
+
const core_1 = require("@siglo/core");
|
|
6
|
+
const backing_1 = require("./graphql/backing");
|
|
7
|
+
const cursor_1 = require("./cursor");
|
|
8
|
+
const subscriptions_1 = require("./graphql/subscriptions");
|
|
9
|
+
function requireNamespace(namespace) {
|
|
10
|
+
if (typeof namespace !== 'string' || !namespace.trim())
|
|
11
|
+
throw new Error('A workflow namespace is required');
|
|
12
|
+
}
|
|
13
|
+
function redactObject(value, fields) {
|
|
14
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, fields.has(key) ? '[REDACTED]' : redactValue(item, fields)]));
|
|
15
|
+
}
|
|
16
|
+
function redactValue(value, fields) {
|
|
17
|
+
if (Array.isArray(value))
|
|
18
|
+
return value.map(item => redactValue(item, fields));
|
|
19
|
+
if (value && typeof value === 'object')
|
|
20
|
+
return redactObject(value, fields);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
class WorkflowQueryEngine {
|
|
24
|
+
fields;
|
|
25
|
+
storage;
|
|
26
|
+
subscriptionManager;
|
|
27
|
+
emitter;
|
|
28
|
+
resolveWorkflow;
|
|
29
|
+
constructor(options) {
|
|
30
|
+
if (!options.storage)
|
|
31
|
+
throw new Error('A workflow storage adapter is required');
|
|
32
|
+
this.resolveWorkflow = options.resolveWorkflow;
|
|
33
|
+
this.storage = options.storage;
|
|
34
|
+
this.fields = new Set(['apiKey', 'password', 'token', 'secret', ...(options.redactFields ?? [])]);
|
|
35
|
+
this.emitter = options.emitter;
|
|
36
|
+
this.subscriptionManager =
|
|
37
|
+
options.subscriptionManager ??
|
|
38
|
+
(0, subscriptions_1.createWorkflowSubscriptionManager)({
|
|
39
|
+
engine: this,
|
|
40
|
+
emitter: options.emitter ?? core_1.defaultWorkflowEventEmitter,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getRedactFields() {
|
|
44
|
+
return this.fields;
|
|
45
|
+
}
|
|
46
|
+
getSubscriptionManager() {
|
|
47
|
+
return this.subscriptionManager;
|
|
48
|
+
}
|
|
49
|
+
getEmitter() {
|
|
50
|
+
return this.emitter;
|
|
51
|
+
}
|
|
52
|
+
project(record, namespace, select, redact) {
|
|
53
|
+
const fields = redact ? this.fields : new Set();
|
|
54
|
+
const wait = record.metadata?.waitRecord;
|
|
55
|
+
const waitRecord = wait
|
|
56
|
+
? {
|
|
57
|
+
correlationKey: wait.correlationKey,
|
|
58
|
+
eventName: wait.eventName,
|
|
59
|
+
expiresAt: wait.expiresAt ? new Date(wait.expiresAt) : undefined,
|
|
60
|
+
lockedBy: wait.lockedBy,
|
|
61
|
+
status: wait.status,
|
|
62
|
+
}
|
|
63
|
+
: undefined;
|
|
64
|
+
const compensations = Array.isArray(record.metadata?.compensations)
|
|
65
|
+
? record.metadata.compensations.map(c => ({
|
|
66
|
+
stepId: String(c.stepId ?? ''),
|
|
67
|
+
stepName: String(c.stepName ?? c.handlerName ?? c.stepId ?? ''),
|
|
68
|
+
status: String(c.status ?? 'registered'),
|
|
69
|
+
}))
|
|
70
|
+
: [];
|
|
71
|
+
const hasContextRequested = !!(select.includeContext || select.contextPath !== undefined);
|
|
72
|
+
const rawError = record.metadata?.error && typeof record.metadata.error === 'object'
|
|
73
|
+
? record.metadata.error
|
|
74
|
+
: undefined;
|
|
75
|
+
const failedStepId = record.status === 'failed'
|
|
76
|
+
? ((typeof record.metadata?.failedStep === 'string' ? record.metadata.failedStep : undefined) ??
|
|
77
|
+
(typeof rawError?.stepName === 'string' ? rawError.stepName : undefined) ??
|
|
78
|
+
(typeof rawError?.stepId === 'string' ? rawError.stepId : undefined))
|
|
79
|
+
: undefined;
|
|
80
|
+
const chainIds = [...(record.chains ?? [])];
|
|
81
|
+
if (failedStepId && !chainIds.includes(failedStepId)) {
|
|
82
|
+
chainIds.push(failedStepId);
|
|
83
|
+
}
|
|
84
|
+
const steps = chainIds.map(id => {
|
|
85
|
+
const stepOutput = hasContextRequested && record.contexts && Object.hasOwn(record.contexts, id)
|
|
86
|
+
? record.contexts[id]
|
|
87
|
+
: undefined;
|
|
88
|
+
const isFailedStep = Boolean(record.status === 'failed' && failedStepId && failedStepId === id);
|
|
89
|
+
const step = {
|
|
90
|
+
stepId: id,
|
|
91
|
+
name: id,
|
|
92
|
+
status: isFailedStep ? 'FAILED' : 'COMPLETED',
|
|
93
|
+
output: stepOutput ? (redact ? redactObject(stepOutput, fields) : stepOutput) : undefined,
|
|
94
|
+
...(isFailedStep && rawError ? { error: redact ? redactObject(rawError, fields) : rawError } : {}),
|
|
95
|
+
};
|
|
96
|
+
if (stepOutput)
|
|
97
|
+
backing_1.rawOutputs.set(step, stepOutput);
|
|
98
|
+
return step;
|
|
99
|
+
});
|
|
100
|
+
const result = {
|
|
101
|
+
stackId: record.stackId,
|
|
102
|
+
namespace,
|
|
103
|
+
workflowId: record.workflowId,
|
|
104
|
+
status: record.status ?? 'running',
|
|
105
|
+
revision: record.revision,
|
|
106
|
+
createdAt: new Date(record.createdAt ?? record.timestamp),
|
|
107
|
+
updatedAt: new Date(record.timestamp),
|
|
108
|
+
expiresAt: record.expiresAt === undefined ? undefined : new Date(record.expiresAt),
|
|
109
|
+
metadata: record.metadata && redactObject(record.metadata, fields),
|
|
110
|
+
steps,
|
|
111
|
+
waitRecord,
|
|
112
|
+
compensations,
|
|
113
|
+
};
|
|
114
|
+
backing_1.rawCheckpoints.set(result, record);
|
|
115
|
+
if (hasContextRequested) {
|
|
116
|
+
const contexts = record.contexts;
|
|
117
|
+
if (!contexts)
|
|
118
|
+
throw new Error('Storage omitted requested workflow context');
|
|
119
|
+
const merged = Object.fromEntries(record.chains.flatMap(id => Object.entries(Object.hasOwn(contexts, id) ? contexts[id] : {})));
|
|
120
|
+
let context = redactObject(merged, fields);
|
|
121
|
+
for (const key of select.contextPath ? select.contextPath.split('.') : []) {
|
|
122
|
+
if (!context || typeof context !== 'object' || !Object.hasOwn(context, key)) {
|
|
123
|
+
context = undefined;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
context = context[key];
|
|
127
|
+
}
|
|
128
|
+
result.context = context;
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
async findById(stackId, options) {
|
|
133
|
+
const namespace = options?.namespace;
|
|
134
|
+
requireNamespace(namespace);
|
|
135
|
+
if (!this.storage.getCheckpoint)
|
|
136
|
+
throw new Error('Storage does not support checkpoint lookup');
|
|
137
|
+
const record = await this.storage.getCheckpoint(stackId);
|
|
138
|
+
if (record?.namespace !== namespace || record.stackId !== stackId)
|
|
139
|
+
return undefined;
|
|
140
|
+
return this.project(record, namespace, { includeContext: true, ...options }, options.redact ?? true);
|
|
141
|
+
}
|
|
142
|
+
async findMany({ filter, sort, pagination, select = {} }) {
|
|
143
|
+
requireNamespace(filter?.namespace);
|
|
144
|
+
const namespace = filter.namespace;
|
|
145
|
+
const order = (0, cursor_1.sortOrder)(sort);
|
|
146
|
+
const limit = pagination?.limit ?? 20;
|
|
147
|
+
if (!Number.isSafeInteger(limit) || limit < 1)
|
|
148
|
+
throw new Error('Invalid workflow page limit');
|
|
149
|
+
if (pagination?.cursor !== undefined)
|
|
150
|
+
(0, cursor_1.decodeCursor)(pagination.cursor, order);
|
|
151
|
+
if (!this.storage.queryWorkflows)
|
|
152
|
+
throw new Error('Storage does not support workflow listing');
|
|
153
|
+
const page = await this.storage.queryWorkflows({
|
|
154
|
+
filter,
|
|
155
|
+
sort: order,
|
|
156
|
+
pagination: { ...pagination, limit },
|
|
157
|
+
includeContext: !!select.includeContext || select.contextPath !== undefined,
|
|
158
|
+
});
|
|
159
|
+
const items = page.checkpoints.map(record => {
|
|
160
|
+
if (record.namespace !== namespace)
|
|
161
|
+
throw new Error('Storage returned a workflow outside the requested namespace');
|
|
162
|
+
return this.project(record, namespace, select, true);
|
|
163
|
+
});
|
|
164
|
+
const last = page.checkpoints.at(-1);
|
|
165
|
+
const edges = items.map((node, i) => {
|
|
166
|
+
const cursor = (0, cursor_1.encodeCursor)(page.checkpoints[i], order);
|
|
167
|
+
node.cursor = cursor;
|
|
168
|
+
return { cursor, node };
|
|
169
|
+
});
|
|
170
|
+
return {
|
|
171
|
+
items,
|
|
172
|
+
edges,
|
|
173
|
+
totalCount: page.totalCount,
|
|
174
|
+
pageInfo: {
|
|
175
|
+
hasNextPage: page.hasNextPage,
|
|
176
|
+
hasPreviousPage: pagination?.cursor !== undefined,
|
|
177
|
+
startCursor: edges.length ? edges[0].cursor : undefined,
|
|
178
|
+
endCursor: last ? (0, cursor_1.encodeCursor)(last, order) : undefined,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async cancelWorkflow(stackId, options) {
|
|
183
|
+
requireNamespace(options?.namespace);
|
|
184
|
+
const existing = await this.storage.getCheckpoint?.(stackId);
|
|
185
|
+
if (!existing || existing.namespace !== options.namespace)
|
|
186
|
+
return false;
|
|
187
|
+
if (typeof this.storage.cancelWorkflow === 'function') {
|
|
188
|
+
await this.storage.cancelWorkflow(stackId);
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
if (this.storage.getCheckpoint && this.storage.saveCheckpoint) {
|
|
192
|
+
existing.status = 'cancelled';
|
|
193
|
+
existing.revision = (existing.revision ?? 0) + 1;
|
|
194
|
+
existing.timestamp = Date.now();
|
|
195
|
+
if (existing.metadata?.waitRecord) {
|
|
196
|
+
existing.metadata.waitRecord.status = 'CANCELLED';
|
|
197
|
+
}
|
|
198
|
+
await this.storage.saveCheckpoint(existing);
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
async resumeWorkflow(correlationKey, payload, namespace) {
|
|
204
|
+
requireNamespace(namespace);
|
|
205
|
+
if (!this.resolveWorkflow || core_1.defaultStorageManager.getAdapter() !== this.storage) {
|
|
206
|
+
throw new Error('Resume requires a workflow resolver and the active durable storage adapter');
|
|
207
|
+
}
|
|
208
|
+
const wait = await this.storage.getWaitRecord?.(correlationKey);
|
|
209
|
+
if (!wait || wait.correlationKey !== correlationKey || wait.namespace !== namespace)
|
|
210
|
+
return false;
|
|
211
|
+
const checkpoint = await this.storage.getCheckpoint?.(wait.stackId);
|
|
212
|
+
if (!checkpoint || checkpoint.namespace !== namespace || checkpoint.status !== 'waiting')
|
|
213
|
+
return false;
|
|
214
|
+
const workflow = this.resolveWorkflow(checkpoint);
|
|
215
|
+
if (!workflow)
|
|
216
|
+
throw new Error('No runtime workflow definition for this checkpoint');
|
|
217
|
+
await (0, core_1.resumeWorkflow)(workflow, correlationKey, payload, { namespace });
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.WorkflowQueryEngine = WorkflowQueryEngine;
|
|
222
|
+
function createWorkflowQueryEngine(options) {
|
|
223
|
+
return new WorkflowQueryEngine(options);
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":";;;AA2PA,8DAEC;AA7PD,sCAKqB;AACrB,+CAA+D;AAC/D,qCAAiE;AACjE,2D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M,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACrF,MAAM,IAAA,qBAAc,EAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAnND,kDAmNC;AAED,SAAgB,yBAAyB,CAAC,OAA6B;IACnE,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { QueryCheckpoint, StepExecution, WorkflowExecution } from '../types';
|
|
2
|
+
export declare const rawCheckpoints: WeakMap<WorkflowExecution, QueryCheckpoint>;
|
|
3
|
+
export declare const rawOutputs: WeakMap<StepExecution, Record<string, unknown>>;
|
|
4
|
+
//# sourceMappingURL=backing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backing.d.ts","sourceRoot":"","sources":["../../src/graphql/backing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElF,eAAO,MAAM,cAAc,6CAAoD,CAAC;AAChF,eAAO,MAAM,UAAU,iDAAwD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backing.js","sourceRoot":"","sources":["../../src/graphql/backing.ts"],"names":[],"mappings":";;;AAEa,QAAA,cAAc,GAAG,IAAI,OAAO,EAAsC,CAAC;AACnE,QAAA,UAAU,GAAG,IAAI,OAAO,EAA0C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type GraphQLResolveInfo } from 'graphql';
|
|
2
|
+
export interface WorkflowSelectionFlags {
|
|
3
|
+
selectedFields: Set<string>;
|
|
4
|
+
hasContext: boolean;
|
|
5
|
+
hasSteps: boolean;
|
|
6
|
+
hasMetadata: boolean;
|
|
7
|
+
includeContext: boolean;
|
|
8
|
+
contextPath?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function getWorkflowExecutionSelections(info: GraphQLResolveInfo): {
|
|
11
|
+
fields: Set<string>;
|
|
12
|
+
contextPath?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function getWorkflowSelectionFlags(info: GraphQLResolveInfo): WorkflowSelectionFlags;
|
|
15
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/graphql/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA+B,MAAM,SAAS,CAAC;AAE/E,MAAM,WAAW,sBAAsB;IACnC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,kBAAkB,GAAG;IACtE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CA8CA;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,kBAAkB,GAAG,sBAAsB,CAa1F"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWorkflowExecutionSelections = getWorkflowExecutionSelections;
|
|
4
|
+
exports.getWorkflowSelectionFlags = getWorkflowSelectionFlags;
|
|
5
|
+
const graphql_1 = require("graphql");
|
|
6
|
+
function getWorkflowExecutionSelections(info) {
|
|
7
|
+
const fields = new Set();
|
|
8
|
+
const fragments = info.fragments;
|
|
9
|
+
let contextPath;
|
|
10
|
+
function visitSelections(selectionSet, inNode) {
|
|
11
|
+
if (!selectionSet)
|
|
12
|
+
return;
|
|
13
|
+
for (const sel of selectionSet.selections) {
|
|
14
|
+
if (sel.kind === graphql_1.Kind.FIELD) {
|
|
15
|
+
const name = sel.name.value;
|
|
16
|
+
if (inNode) {
|
|
17
|
+
fields.add(name);
|
|
18
|
+
if (name === 'context' && contextPath === undefined) {
|
|
19
|
+
const pathArg = sel.arguments?.find(a => a.name.value === 'path');
|
|
20
|
+
if (pathArg && pathArg.value.kind === graphql_1.Kind.STRING) {
|
|
21
|
+
contextPath = pathArg.value.value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (name === 'node' || info.fieldName === 'workflow') {
|
|
26
|
+
visitSelections(sel.selectionSet, true);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
visitSelections(sel.selectionSet, inNode);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (sel.kind === graphql_1.Kind.INLINE_FRAGMENT) {
|
|
33
|
+
const isWorkflowExecution = sel.typeCondition?.name.value === 'WorkflowExecution';
|
|
34
|
+
visitSelections(sel.selectionSet, inNode || isWorkflowExecution);
|
|
35
|
+
}
|
|
36
|
+
else if (sel.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
|
|
37
|
+
const frag = fragments?.[sel.name.value];
|
|
38
|
+
if (frag) {
|
|
39
|
+
const isWorkflowExecution = frag.typeCondition?.name.value === 'WorkflowExecution';
|
|
40
|
+
visitSelections(frag.selectionSet, inNode || isWorkflowExecution);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
for (const fieldNode of info.fieldNodes) {
|
|
46
|
+
if (info.fieldName === 'workflow') {
|
|
47
|
+
visitSelections(fieldNode.selectionSet, true);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
visitSelections(fieldNode.selectionSet, false);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return { fields, contextPath };
|
|
54
|
+
}
|
|
55
|
+
function getWorkflowSelectionFlags(info) {
|
|
56
|
+
const { fields, contextPath } = getWorkflowExecutionSelections(info);
|
|
57
|
+
const hasContext = fields.has('context');
|
|
58
|
+
const hasSteps = fields.has('steps');
|
|
59
|
+
const hasMetadata = fields.has('metadata');
|
|
60
|
+
return {
|
|
61
|
+
selectedFields: fields,
|
|
62
|
+
hasContext,
|
|
63
|
+
hasSteps,
|
|
64
|
+
hasMetadata,
|
|
65
|
+
includeContext: hasContext || hasSteps,
|
|
66
|
+
contextPath,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../../src/graphql/projection.ts"],"names":[],"mappings":";;AAWA,wEAiDC;AAED,8DAaC;AA3ED,qCAA+E;AAW/E,SAAgB,8BAA8B,CAAC,IAAwB;IAInE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IACjC,IAAI,WAA+B,CAAC;IAEpC,SAAS,eAAe,CAAC,YAA0C,EAAE,MAAe;QAChF,IAAI,CAAC,YAAY;YAAE,OAAO;QAC1B,KAAK,MAAM,GAAG,IAAI,YAAY,CAAC,UAAU,EAAE,CAAC;YACxC,IAAI,GAAG,CAAC,IAAI,KAAK,cAAI,CAAC,KAAK,EAAE,CAAC;gBAC1B,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC5B,IAAI,MAAM,EAAE,CAAC;oBACT,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBACjB,IAAI,IAAI,KAAK,SAAS,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;wBAClD,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,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Ae,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAClD,CAAC;aAAM,CAAC;YACJ,eAAe,CAAC,SAAS,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QACnD,CAAC;IACL,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AACnC,CAAC;AAED,SAAgB,yBAAyB,CAAC,IAAwB;IAC9D,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,8BAA8B,CAAC,IAAI,CAAC,CAAC;IACrE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3C,OAAO;QACH,cAAc,EAAE,MAAM;QACtB,UAAU;QACV,QAAQ;QACR,WAAW;QACX,cAAc,EAAE,UAAU,IAAI,QAAQ;QACtC,WAAW;KACd,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { GraphQLResolveInfo } from 'graphql';
|
|
2
|
+
import type { WorkflowQueryEngine } from '../engine';
|
|
3
|
+
import type { WorkflowSubscriptionManager } from './subscriptions';
|
|
4
|
+
import type { StepExecution, WorkflowExecution } from '../types';
|
|
5
|
+
export interface WorkflowGraphQLContext {
|
|
6
|
+
namespace?: string;
|
|
7
|
+
engine?: WorkflowQueryEngine;
|
|
8
|
+
subscriptionManager?: WorkflowSubscriptionManager;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
export declare function queryNamespace(requested?: string, authenticated?: string): string;
|
|
12
|
+
export declare function createResolvers(engine: WorkflowQueryEngine, options?: {
|
|
13
|
+
subscriptionManager?: WorkflowSubscriptionManager;
|
|
14
|
+
}): {
|
|
15
|
+
Query: {
|
|
16
|
+
workflow(_parent: unknown, args: {
|
|
17
|
+
stackId: string;
|
|
18
|
+
namespace?: string;
|
|
19
|
+
}, context: WorkflowGraphQLContext | undefined, info: GraphQLResolveInfo): Promise<WorkflowExecution | null>;
|
|
20
|
+
workflows(_parent: unknown, args: {
|
|
21
|
+
filter?: {
|
|
22
|
+
workflowId?: string;
|
|
23
|
+
namespace?: string;
|
|
24
|
+
status?: string;
|
|
25
|
+
createdAfter?: Date;
|
|
26
|
+
createdBefore?: Date;
|
|
27
|
+
correlationKey?: string;
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
29
|
+
};
|
|
30
|
+
sort?: {
|
|
31
|
+
field?: string;
|
|
32
|
+
direction?: string;
|
|
33
|
+
};
|
|
34
|
+
pagination?: {
|
|
35
|
+
limit?: number;
|
|
36
|
+
cursor?: string;
|
|
37
|
+
};
|
|
38
|
+
}, context: WorkflowGraphQLContext | undefined, info: GraphQLResolveInfo): Promise<{
|
|
39
|
+
edges: {
|
|
40
|
+
cursor: string;
|
|
41
|
+
node: WorkflowExecution;
|
|
42
|
+
}[];
|
|
43
|
+
pageInfo: import("../types").PageInfo;
|
|
44
|
+
totalCount: number;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
Mutation: {
|
|
48
|
+
resumeWorkflow(_parent: unknown, args: {
|
|
49
|
+
correlationKey: string;
|
|
50
|
+
payload?: unknown;
|
|
51
|
+
namespace?: string;
|
|
52
|
+
}, context: WorkflowGraphQLContext | undefined): Promise<boolean>;
|
|
53
|
+
cancelWorkflow(_parent: unknown, args: {
|
|
54
|
+
stackId: string;
|
|
55
|
+
reason?: string;
|
|
56
|
+
}, context: WorkflowGraphQLContext | undefined): Promise<boolean>;
|
|
57
|
+
};
|
|
58
|
+
Subscription: {
|
|
59
|
+
workflowUpdated: {
|
|
60
|
+
subscribe(_parent: unknown, args: {
|
|
61
|
+
stackId: string;
|
|
62
|
+
namespace?: string;
|
|
63
|
+
}, context: WorkflowGraphQLContext | undefined): AsyncIterable<WorkflowExecution>;
|
|
64
|
+
resolve(payload: any): any;
|
|
65
|
+
};
|
|
66
|
+
workflowCompleted: {
|
|
67
|
+
subscribe(_parent: unknown, args: {
|
|
68
|
+
namespace?: string;
|
|
69
|
+
}, context: WorkflowGraphQLContext | undefined): AsyncIterable<WorkflowExecution>;
|
|
70
|
+
resolve(payload: any): any;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
WorkflowExecution: {
|
|
74
|
+
status(node: WorkflowExecution): string;
|
|
75
|
+
context(node: WorkflowExecution, args: {
|
|
76
|
+
path?: string;
|
|
77
|
+
redact?: boolean;
|
|
78
|
+
}): unknown;
|
|
79
|
+
steps(node: WorkflowExecution): StepExecution[];
|
|
80
|
+
waitRecord(node: WorkflowExecution): import("../types").WaitRecord | null;
|
|
81
|
+
compensations(node: WorkflowExecution): import("../types").CompensationRecord[];
|
|
82
|
+
};
|
|
83
|
+
StepExecution: {
|
|
84
|
+
output(step: StepExecution, args: {
|
|
85
|
+
redact?: boolean;
|
|
86
|
+
}): {} | null | undefined;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=resolvers.d.ts.map
|