@loopstack/core 0.23.0 → 0.24.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/dist/documents/error-document.d.ts +10 -0
- package/dist/documents/error-document.d.ts.map +1 -0
- package/dist/documents/error-document.js +39 -0
- package/dist/documents/error-document.js.map +1 -0
- package/dist/documents/error-document.yaml +5 -0
- package/dist/documents/index.d.ts +7 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +23 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/link-document.d.ts +16 -0
- package/dist/documents/link-document.d.ts.map +1 -0
- package/dist/documents/link-document.js +45 -0
- package/dist/documents/link-document.js.map +1 -0
- package/dist/documents/link-document.yaml +3 -0
- package/dist/documents/markdown-document.d.ts +10 -0
- package/dist/documents/markdown-document.d.ts.map +1 -0
- package/dist/documents/markdown-document.js +39 -0
- package/dist/documents/markdown-document.js.map +1 -0
- package/dist/documents/markdown-document.yaml +3 -0
- package/dist/documents/message-document.d.ts +11 -0
- package/dist/documents/message-document.d.ts.map +1 -0
- package/dist/documents/message-document.js +40 -0
- package/dist/documents/message-document.js.map +1 -0
- package/dist/documents/message-document.yaml +5 -0
- package/dist/documents/plain-document.d.ts +10 -0
- package/dist/documents/plain-document.d.ts.map +1 -0
- package/dist/documents/plain-document.js +39 -0
- package/dist/documents/plain-document.js.map +1 -0
- package/dist/documents/plain-document.yaml +3 -0
- package/dist/documents/secret-request-document.d.ts +13 -0
- package/dist/documents/secret-request-document.d.ts.map +1 -0
- package/dist/documents/secret-request-document.js +40 -0
- package/dist/documents/secret-request-document.js.map +1 -0
- package/dist/documents/secret-request-document.yaml +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/loop-core.module.d.ts.map +1 -1
- package/dist/loop-core.module.js +33 -2
- package/dist/loop-core.module.js.map +1 -1
- package/dist/persistence/persistence.module.d.ts.map +1 -1
- package/dist/persistence/persistence.module.js +3 -0
- package/dist/persistence/persistence.module.js.map +1 -1
- package/dist/persistence/services/document.service.d.ts.map +1 -1
- package/dist/persistence/services/document.service.js +2 -1
- package/dist/persistence/services/document.service.js.map +1 -1
- package/dist/persistence/services/event-subscriber.service.d.ts +1 -1
- package/dist/persistence/services/event-subscriber.service.d.ts.map +1 -1
- package/dist/persistence/services/event-subscriber.service.js +2 -1
- package/dist/persistence/services/event-subscriber.service.js.map +1 -1
- package/dist/persistence/services/index.d.ts +1 -0
- package/dist/persistence/services/index.d.ts.map +1 -1
- package/dist/persistence/services/index.js +1 -0
- package/dist/persistence/services/index.js.map +1 -1
- package/dist/persistence/services/secret.service.d.ts +20 -0
- package/dist/persistence/services/secret.service.d.ts.map +1 -0
- package/dist/persistence/services/secret.service.js +76 -0
- package/dist/persistence/services/secret.service.js.map +1 -0
- package/dist/scheduler/services/event-processor.service.d.ts.map +1 -1
- package/dist/scheduler/services/event-processor.service.js +4 -1
- package/dist/scheduler/services/event-processor.service.js.map +1 -1
- package/dist/scheduler/services/task-processor/run-pipeline-task-processor.service.d.ts.map +1 -1
- package/dist/scheduler/services/task-processor/run-pipeline-task-processor.service.js +6 -1
- package/dist/scheduler/services/task-processor/run-pipeline-task-processor.service.js.map +1 -1
- package/dist/tools/create-document.tool.d.ts +73 -0
- package/dist/tools/create-document.tool.d.ts.map +1 -0
- package/dist/tools/create-document.tool.js +151 -0
- package/dist/tools/create-document.tool.js.map +1 -0
- package/dist/tools/get-secret-keys.tool.d.ts +6 -0
- package/dist/tools/get-secret-keys.tool.d.ts.map +1 -0
- package/dist/tools/get-secret-keys.tool.js +40 -0
- package/dist/tools/get-secret-keys.tool.js.map +1 -0
- package/dist/tools/index.d.ts +6 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/request-secrets-task.tool.d.ts +19 -0
- package/dist/tools/request-secrets-task.tool.d.ts.map +1 -0
- package/dist/tools/request-secrets-task.tool.js +110 -0
- package/dist/tools/request-secrets-task.tool.js.map +1 -0
- package/dist/tools/request-secrets.tool.d.ts +14 -0
- package/dist/tools/request-secrets.tool.d.ts.map +1 -0
- package/dist/tools/request-secrets.tool.js +45 -0
- package/dist/tools/request-secrets.tool.js.map +1 -0
- package/dist/tools/secrets-request.workflow.d.ts +19 -0
- package/dist/tools/secrets-request.workflow.d.ts.map +1 -0
- package/dist/tools/secrets-request.workflow.js +70 -0
- package/dist/tools/secrets-request.workflow.js.map +1 -0
- package/dist/tools/secrets-request.workflow.yaml +22 -0
- package/dist/tools/{execute-workflow-async.tool.d.ts → task.tool.d.ts} +9 -11
- package/dist/tools/task.tool.d.ts.map +1 -0
- package/dist/tools/{execute-workflow-async.tool.js → task.tool.js} +42 -37
- package/dist/tools/task.tool.js.map +1 -0
- package/dist/workflow-processor/index.d.ts +1 -0
- package/dist/workflow-processor/index.d.ts.map +1 -1
- package/dist/workflow-processor/index.js +1 -0
- package/dist/workflow-processor/index.js.map +1 -1
- package/dist/workflow-processor/services/create-pipeline.service.d.ts +4 -3
- package/dist/workflow-processor/services/create-pipeline.service.d.ts.map +1 -1
- package/dist/workflow-processor/services/create-pipeline.service.js +24 -11
- package/dist/workflow-processor/services/create-pipeline.service.js.map +1 -1
- package/dist/workflow-processor/services/root-processor.service.d.ts +2 -0
- package/dist/workflow-processor/services/root-processor.service.d.ts.map +1 -1
- package/dist/workflow-processor/services/root-processor.service.js +25 -6
- package/dist/workflow-processor/services/root-processor.service.js.map +1 -1
- package/dist/workflow-processor/services/state-machine-processor.service.d.ts.map +1 -1
- package/dist/workflow-processor/services/state-machine-processor.service.js +4 -2
- package/dist/workflow-processor/services/state-machine-processor.service.js.map +1 -1
- package/dist/workflow-processor/services/state-machine-tool-call-processor.service.d.ts +9 -5
- package/dist/workflow-processor/services/state-machine-tool-call-processor.service.d.ts.map +1 -1
- package/dist/workflow-processor/services/state-machine-tool-call-processor.service.js +91 -42
- package/dist/workflow-processor/services/state-machine-tool-call-processor.service.js.map +1 -1
- package/dist/workflow-processor/services/workflow-state.service.d.ts.map +1 -1
- package/dist/workflow-processor/services/workflow-state.service.js +1 -0
- package/dist/workflow-processor/services/workflow-state.service.js.map +1 -1
- package/dist/workflow-processor/utils/index.d.ts +4 -0
- package/dist/workflow-processor/utils/index.d.ts.map +1 -0
- package/dist/workflow-processor/utils/index.js +20 -0
- package/dist/workflow-processor/utils/index.js.map +1 -0
- package/dist/workflow-processor/workflow-processor.module.d.ts.map +1 -1
- package/dist/workflow-processor/workflow-processor.module.js +1 -0
- package/dist/workflow-processor/workflow-processor.module.js.map +1 -1
- package/package.json +2 -2
- package/dist/tools/execute-workflow-async.tool.d.ts.map +0 -1
- package/dist/tools/execute-workflow-async.tool.js.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var RequestSecretsTask_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RequestSecretsTask = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const common_2 = require("@loopstack/common");
|
|
17
|
+
const documents_1 = require("../documents");
|
|
18
|
+
const create_document_tool_1 = require("./create-document.tool");
|
|
19
|
+
const task_tool_1 = require("./task.tool");
|
|
20
|
+
const RequestSecretsTaskInputSchema = zod_1.z
|
|
21
|
+
.object({
|
|
22
|
+
variables: zod_1.z.array(zod_1.z.object({
|
|
23
|
+
key: zod_1.z.string().describe('The environment variable key (e.g. OPENAI_API_KEY)'),
|
|
24
|
+
})),
|
|
25
|
+
})
|
|
26
|
+
.strict();
|
|
27
|
+
let RequestSecretsTask = RequestSecretsTask_1 = class RequestSecretsTask {
|
|
28
|
+
logger = new common_1.Logger(RequestSecretsTask_1.name);
|
|
29
|
+
task;
|
|
30
|
+
createDocument;
|
|
31
|
+
linkDocument;
|
|
32
|
+
args;
|
|
33
|
+
async execute(args, ctx, parent, metadata) {
|
|
34
|
+
const taskResult = await this.task.execute({ workflow: 'secretsRequest', args: { variables: args.variables } }, ctx, parent);
|
|
35
|
+
const effects = [];
|
|
36
|
+
const linkResult = await this.createDocument.execute({
|
|
37
|
+
document: 'linkDocument',
|
|
38
|
+
id: 'secrets_link',
|
|
39
|
+
validate: 'skip',
|
|
40
|
+
update: {
|
|
41
|
+
content: {
|
|
42
|
+
icon: 'Clock',
|
|
43
|
+
label: 'Requesting Secrets',
|
|
44
|
+
href: `/pipelines/${taskResult.data.pipelineId}`,
|
|
45
|
+
embed: true,
|
|
46
|
+
expanded: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
}, ctx, this, metadata);
|
|
50
|
+
if (linkResult.effects) {
|
|
51
|
+
effects.push(...linkResult.effects);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
data: taskResult.data,
|
|
55
|
+
effects,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async complete(result, ctx, parent, metadata) {
|
|
59
|
+
const data = result;
|
|
60
|
+
const effects = [];
|
|
61
|
+
const linkResult = await this.createDocument.execute({
|
|
62
|
+
document: 'linkDocument',
|
|
63
|
+
id: 'secrets_link',
|
|
64
|
+
validate: 'skip',
|
|
65
|
+
update: {
|
|
66
|
+
content: {
|
|
67
|
+
icon: 'CircleCheck',
|
|
68
|
+
label: 'Secrets have been stored',
|
|
69
|
+
href: `/pipelines/${data.pipelineId}`,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}, ctx, this, metadata);
|
|
73
|
+
if (linkResult.effects) {
|
|
74
|
+
effects.push(...linkResult.effects);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
data: 'Secrets have been stored securely by the user.',
|
|
78
|
+
effects,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.RequestSecretsTask = RequestSecretsTask;
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, common_2.InjectTool)(),
|
|
85
|
+
__metadata("design:type", task_tool_1.Task)
|
|
86
|
+
], RequestSecretsTask.prototype, "task", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, common_2.InjectTool)(),
|
|
89
|
+
__metadata("design:type", create_document_tool_1.CreateDocument)
|
|
90
|
+
], RequestSecretsTask.prototype, "createDocument", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, common_2.InjectDocument)(),
|
|
93
|
+
__metadata("design:type", documents_1.LinkDocument)
|
|
94
|
+
], RequestSecretsTask.prototype, "linkDocument", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, common_2.Input)({ schema: RequestSecretsTaskInputSchema }),
|
|
97
|
+
__metadata("design:type", Object)
|
|
98
|
+
], RequestSecretsTask.prototype, "args", void 0);
|
|
99
|
+
exports.RequestSecretsTask = RequestSecretsTask = RequestSecretsTask_1 = __decorate([
|
|
100
|
+
(0, common_1.Injectable)(),
|
|
101
|
+
(0, common_2.Tool)({
|
|
102
|
+
config: {
|
|
103
|
+
description: 'Requests secret values from the user. Shows a secure input form where the user can enter API keys and other secrets. ' +
|
|
104
|
+
'Values are stored securely and never exposed to the workflow or LLM. ' +
|
|
105
|
+
'Returns only the key names after the user has provided the values. ' +
|
|
106
|
+
'IMPORTANT: When using this tool, it must be the ONLY tool call in your response. Do not combine it with other tool calls.',
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
], RequestSecretsTask);
|
|
110
|
+
//# sourceMappingURL=request-secrets-task.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-secrets-task.tool.js","sourceRoot":"","sources":["../../src/tools/request-secrets-task.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6BAAwB;AACxB,8CAW2B;AAC3B,4CAA4C;AAC5C,iEAAwD;AACxD,2CAAmC;AAEnC,MAAM,6BAA6B,GAAG,OAAC;KACpC,MAAM,CAAC;IACN,SAAS,EAAE,OAAC,CAAC,KAAK,CAChB,OAAC,CAAC,MAAM,CAAC;QACP,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;KAC/E,CAAC,CACH;CACF,CAAC;KACD,MAAM,EAAE,CAAC;AAcL,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IACZ,MAAM,GAAG,IAAI,eAAM,CAAC,oBAAkB,CAAC,IAAI,CAAC,CAAC;IAExC,IAAI,CAAO;IACX,cAAc,CAAiB;IAC3B,YAAY,CAAe;IAGrD,IAAI,CAA0B;IAE9B,KAAK,CAAC,OAAO,CACX,IAA6B,EAC7B,GAAe,EACf,MAAyC,EACzC,QAAmC;QAEnC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CACxC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,EACnE,GAAG,EACH,MAAM,CACP,CAAC;QAEF,MAAM,OAAO,GAAsB,EAAE,CAAC;QAEtC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CACl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A;AAzFY,gDAAkB;AAGP;IAArB,IAAA,mBAAU,GAAE;8BAAe,gBAAI;gDAAC;AACX;IAArB,IAAA,mBAAU,GAAE;8BAAyB,qCAAc;0DAAC;AAC3B;IAAzB,IAAA,uBAAc,GAAE;8BAAuB,wBAAY;wDAAC;AAGrD;IADC,IAAA,cAAK,EAAC,EAAE,MAAM,EAAE,6BAA6B,EAAE,CAAC;;gDACnB;6BARnB,kBAAkB;IAV9B,IAAA,mBAAU,GAAE;IACZ,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EACT,uHAAuH;gBACvH,uEAAuE;gBACvE,qEAAqE;gBACrE,2HAA2H;SAC9H;KACF,CAAC;GACW,kBAAkB,CAyF9B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ToolInterface, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const RequestSecretsInputSchema: z.ZodObject<{
|
|
4
|
+
variables: z.ZodArray<z.ZodObject<{
|
|
5
|
+
key: z.ZodString;
|
|
6
|
+
}, z.core.$strip>>;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
type RequestSecretsInput = z.infer<typeof RequestSecretsInputSchema>;
|
|
9
|
+
export declare class RequestSecretsTool implements ToolInterface<RequestSecretsInput> {
|
|
10
|
+
args: RequestSecretsInput;
|
|
11
|
+
execute(args: RequestSecretsInput): Promise<ToolResult>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=request-secrets.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-secrets.tool.d.ts","sourceRoot":"","sources":["../../src/tools/request-secrets.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAe,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3E,QAAA,MAAM,yBAAyB;;;;kBAQpB,CAAC;AAEZ,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAErE,qBASa,kBAAmB,YAAW,aAAa,CAAC,mBAAmB,CAAC;IAE3E,IAAI,EAAE,mBAAmB,CAAC;IAE1B,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;CAKxD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RequestSecretsTool = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const common_1 = require("@loopstack/common");
|
|
15
|
+
const RequestSecretsInputSchema = zod_1.z
|
|
16
|
+
.object({
|
|
17
|
+
variables: zod_1.z.array(zod_1.z.object({
|
|
18
|
+
key: zod_1.z.string().describe('The environment variable key (e.g. OPENAI_API_KEY)'),
|
|
19
|
+
})),
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
22
|
+
let RequestSecretsTool = class RequestSecretsTool {
|
|
23
|
+
args;
|
|
24
|
+
execute(args) {
|
|
25
|
+
return Promise.resolve({
|
|
26
|
+
data: { variables: args.variables },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.RequestSecretsTool = RequestSecretsTool;
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, common_1.Input)({ schema: RequestSecretsInputSchema }),
|
|
33
|
+
__metadata("design:type", Object)
|
|
34
|
+
], RequestSecretsTool.prototype, "args", void 0);
|
|
35
|
+
exports.RequestSecretsTool = RequestSecretsTool = __decorate([
|
|
36
|
+
(0, common_1.Tool)({
|
|
37
|
+
config: {
|
|
38
|
+
description: 'Requests secret values from the user. Shows a secure input form where the user can enter API keys and other secrets. ' +
|
|
39
|
+
'Values are stored securely and never exposed to the workflow or LLM. ' +
|
|
40
|
+
'Returns only the key names after the user has provided the values. ' +
|
|
41
|
+
'IMPORTANT: When using this tool, it must be the ONLY tool call in your response. Do not combine it with other tool calls.',
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
], RequestSecretsTool);
|
|
45
|
+
//# sourceMappingURL=request-secrets.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-secrets.tool.js","sourceRoot":"","sources":["../../src/tools/request-secrets.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAwB;AACxB,8CAA2E;AAE3E,MAAM,yBAAyB,GAAG,OAAC;KAChC,MAAM,CAAC;IACN,SAAS,EAAE,OAAC,CAAC,KAAK,CAChB,OAAC,CAAC,MAAM,CAAC;QACP,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;KAC/E,CAAC,CACH;CACF,CAAC;KACD,MAAM,EAAE,CAAC;AAaL,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAE7B,IAAI,CAAsB;IAE1B,OAAO,CAAC,IAAyB;QAC/B,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AATY,gDAAkB;AAE7B;IADC,IAAA,cAAK,EAAC,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC;;gDACnB;6BAFf,kBAAkB;IAT9B,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EACT,uHAAuH;gBACvH,uEAAuE;gBACvE,qEAAqE;gBACrE,2HAA2H;SAC9H;KACF,CAAC;GACW,kBAAkB,CAS9B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WorkflowInterface } from '@loopstack/common';
|
|
2
|
+
import { SecretRequestDocument } from '../documents';
|
|
3
|
+
import { CreateDocument } from './create-document.tool';
|
|
4
|
+
export declare class SecretsRequestWorkflow implements WorkflowInterface {
|
|
5
|
+
createDocument: CreateDocument;
|
|
6
|
+
secretRequestDocument: SecretRequestDocument;
|
|
7
|
+
args: {
|
|
8
|
+
variables: {
|
|
9
|
+
key: string;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
state: {
|
|
13
|
+
submitted?: boolean;
|
|
14
|
+
};
|
|
15
|
+
getResult(): {
|
|
16
|
+
success: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=secrets-request.workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets-request.workflow.d.ts","sourceRoot":"","sources":["../../src/tools/secrets-request.workflow.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8D,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,qBAIa,sBAAuB,YAAW,iBAAiB;IAChD,cAAc,EAAE,cAAc,CAAC;IAC3B,qBAAqB,EAAE,qBAAqB,CAAC;IAW/D,IAAI,EAAE;QACJ,SAAS,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAC9B,CAAC;IAOF,KAAK,EAAE;QACL,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,CAAC;IAOF,SAAS;;;CAGV"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SecretsRequestWorkflow = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
const common_2 = require("@loopstack/common");
|
|
16
|
+
const documents_1 = require("../documents");
|
|
17
|
+
const create_document_tool_1 = require("./create-document.tool");
|
|
18
|
+
let SecretsRequestWorkflow = class SecretsRequestWorkflow {
|
|
19
|
+
createDocument;
|
|
20
|
+
secretRequestDocument;
|
|
21
|
+
args;
|
|
22
|
+
state;
|
|
23
|
+
getResult() {
|
|
24
|
+
return { success: this.state.submitted ?? false };
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.SecretsRequestWorkflow = SecretsRequestWorkflow;
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, common_2.InjectTool)(),
|
|
30
|
+
__metadata("design:type", create_document_tool_1.CreateDocument)
|
|
31
|
+
], SecretsRequestWorkflow.prototype, "createDocument", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, common_2.InjectDocument)(),
|
|
34
|
+
__metadata("design:type", documents_1.SecretRequestDocument)
|
|
35
|
+
], SecretsRequestWorkflow.prototype, "secretRequestDocument", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, common_2.Input)({
|
|
38
|
+
schema: zod_1.z.object({
|
|
39
|
+
variables: zod_1.z.array(zod_1.z.object({
|
|
40
|
+
key: zod_1.z.string(),
|
|
41
|
+
})),
|
|
42
|
+
}),
|
|
43
|
+
}),
|
|
44
|
+
__metadata("design:type", Object)
|
|
45
|
+
], SecretsRequestWorkflow.prototype, "args", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, common_2.State)({
|
|
48
|
+
schema: zod_1.z.object({
|
|
49
|
+
submitted: zod_1.z.boolean().optional(),
|
|
50
|
+
}),
|
|
51
|
+
}),
|
|
52
|
+
__metadata("design:type", Object)
|
|
53
|
+
], SecretsRequestWorkflow.prototype, "state", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, common_2.Output)({
|
|
56
|
+
schema: zod_1.z.object({
|
|
57
|
+
success: zod_1.z.boolean(),
|
|
58
|
+
}),
|
|
59
|
+
}),
|
|
60
|
+
__metadata("design:type", Function),
|
|
61
|
+
__metadata("design:paramtypes", []),
|
|
62
|
+
__metadata("design:returntype", void 0)
|
|
63
|
+
], SecretsRequestWorkflow.prototype, "getResult", null);
|
|
64
|
+
exports.SecretsRequestWorkflow = SecretsRequestWorkflow = __decorate([
|
|
65
|
+
(0, common_1.Injectable)(),
|
|
66
|
+
(0, common_2.Workflow)({
|
|
67
|
+
configFile: __dirname + '/secrets-request.workflow.yaml',
|
|
68
|
+
})
|
|
69
|
+
], SecretsRequestWorkflow);
|
|
70
|
+
//# sourceMappingURL=secrets-request.workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets-request.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Secrets Request'
|
|
2
|
+
|
|
3
|
+
description: |
|
|
4
|
+
Sub-workflow that presents a secrets request form to the user
|
|
5
|
+
and waits for submission. Completes when the user submits the form.
|
|
6
|
+
|
|
7
|
+
transitions:
|
|
8
|
+
- id: show_form
|
|
9
|
+
from: start
|
|
10
|
+
to: requesting_secrets
|
|
11
|
+
call:
|
|
12
|
+
- tool: createDocument
|
|
13
|
+
args:
|
|
14
|
+
document: secretRequestDocument
|
|
15
|
+
update:
|
|
16
|
+
content:
|
|
17
|
+
variables: ${{ args.variables }}
|
|
18
|
+
|
|
19
|
+
- id: secrets_submitted
|
|
20
|
+
from: requesting_secrets
|
|
21
|
+
to: end
|
|
22
|
+
trigger: manual
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import { Logger } from '@nestjs/common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { RunContext, ToolInterface, ToolResult } from '@loopstack/common';
|
|
3
|
+
import { BlockInterface, RunContext, ToolInterface, ToolResult, WorkflowInterface } from '@loopstack/common';
|
|
4
4
|
import { EventSubscriberService } from '../persistence';
|
|
5
5
|
import { TaskSchedulerService } from '../scheduler';
|
|
6
6
|
import { CreatePipelineService } from '../workflow-processor';
|
|
7
|
-
declare const
|
|
7
|
+
declare const TaskArgsSchema: z.ZodObject<{
|
|
8
8
|
workflow: z.ZodString;
|
|
9
9
|
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
-
callback: z.ZodObject<{
|
|
10
|
+
callback: z.ZodOptional<z.ZodObject<{
|
|
11
11
|
transition: z.ZodString;
|
|
12
|
-
}, z.core.$strip>;
|
|
13
|
-
options: z.ZodOptional<z.ZodObject<{
|
|
14
|
-
runStateless: z.ZodOptional<z.ZodBoolean>;
|
|
15
12
|
}, z.core.$strip>>;
|
|
16
13
|
}, z.core.$strip>;
|
|
17
|
-
type
|
|
18
|
-
export declare class
|
|
14
|
+
type TaskArgs = z.infer<typeof TaskArgsSchema>;
|
|
15
|
+
export declare class Task implements ToolInterface<TaskArgs> {
|
|
19
16
|
private readonly createPipelineService;
|
|
20
17
|
private readonly taskSchedulerService;
|
|
21
18
|
private readonly eventSubscriberService;
|
|
22
19
|
protected readonly logger: Logger;
|
|
23
20
|
constructor(createPipelineService: CreatePipelineService, taskSchedulerService: TaskSchedulerService, eventSubscriberService: EventSubscriberService);
|
|
24
|
-
args:
|
|
25
|
-
execute(args:
|
|
21
|
+
args: TaskArgs;
|
|
22
|
+
execute(args: TaskArgs, context: RunContext, parent?: WorkflowInterface | BlockInterface): Promise<ToolResult>;
|
|
23
|
+
complete(result: unknown): Promise<ToolResult>;
|
|
26
24
|
}
|
|
27
25
|
export {};
|
|
28
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=task.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.tool.d.ts","sourceRoot":"","sources":["../../src/tools/task.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,cAAc,EAEd,UAAU,EAEV,aAAa,EACb,UAAU,EACV,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,QAAA,MAAM,cAAc;;;;;;iBAQlB,CAAC;AAEH,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE/C,qBAMa,IAAK,YAAW,aAAa,CAAC,QAAQ,CAAC;IAIhD,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IALzC,SAAS,CAAC,QAAQ,CAAC,MAAM,SAAyB;gBAG/B,qBAAqB,EAAE,qBAAqB,EAC5C,oBAAoB,EAAE,oBAAoB,EAC1C,sBAAsB,EAAE,sBAAsB;IAMjE,IAAI,EAAE,QAAQ,CAAC;IAET,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IAkE9G,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;CAIrD"}
|
|
@@ -8,9 +8,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var
|
|
11
|
+
var Task_1;
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.Task = void 0;
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
15
|
const node_crypto_1 = require("node:crypto");
|
|
16
16
|
const zod_1 = require("zod");
|
|
@@ -19,57 +19,50 @@ const enums_1 = require("@loopstack/contracts/enums");
|
|
|
19
19
|
const persistence_1 = require("../persistence");
|
|
20
20
|
const scheduler_1 = require("../scheduler");
|
|
21
21
|
const workflow_processor_1 = require("../workflow-processor");
|
|
22
|
-
const
|
|
22
|
+
const TaskArgsSchema = zod_1.z.object({
|
|
23
23
|
workflow: zod_1.z.string(),
|
|
24
24
|
args: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
25
|
-
callback: zod_1.z
|
|
26
|
-
transition: zod_1.z.string(),
|
|
27
|
-
}),
|
|
28
|
-
options: zod_1.z
|
|
25
|
+
callback: zod_1.z
|
|
29
26
|
.object({
|
|
30
|
-
|
|
27
|
+
transition: zod_1.z.string(),
|
|
31
28
|
})
|
|
32
29
|
.optional(),
|
|
33
30
|
});
|
|
34
|
-
let
|
|
31
|
+
let Task = Task_1 = class Task {
|
|
35
32
|
createPipelineService;
|
|
36
33
|
taskSchedulerService;
|
|
37
34
|
eventSubscriberService;
|
|
38
|
-
logger = new common_1.Logger(
|
|
35
|
+
logger = new common_1.Logger(Task_1.name);
|
|
39
36
|
constructor(createPipelineService, taskSchedulerService, eventSubscriberService) {
|
|
40
37
|
this.createPipelineService = createPipelineService;
|
|
41
38
|
this.taskSchedulerService = taskSchedulerService;
|
|
42
39
|
this.eventSubscriberService = eventSubscriberService;
|
|
43
40
|
}
|
|
44
41
|
args;
|
|
45
|
-
async execute(args, context) {
|
|
42
|
+
async execute(args, context, parent) {
|
|
46
43
|
if (context.options.stateless) {
|
|
47
|
-
throw new Error(
|
|
44
|
+
throw new Error('Task tool requires stateful workflow execution.');
|
|
48
45
|
}
|
|
49
46
|
const correlationId = (0, node_crypto_1.randomUUID)();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, context.userId, context.pipelineId);
|
|
62
|
-
}
|
|
63
|
-
await this.eventSubscriberService.registerSubscriber(context.pipelineId, context.workflowId, args.callback.transition, correlationId, `workflow.${enums_1.WorkflowState.Completed}`, context.userId, context.workspaceId);
|
|
64
|
-
const job = await this.taskSchedulerService.addTask({
|
|
47
|
+
const pipeline = await this.createPipelineService.create({
|
|
48
|
+
id: context.workspaceId,
|
|
49
|
+
}, {
|
|
50
|
+
blockName: args.workflow,
|
|
51
|
+
workspaceId: context.workspaceId,
|
|
52
|
+
args: {
|
|
53
|
+
...args.args,
|
|
54
|
+
},
|
|
55
|
+
eventCorrelationId: correlationId,
|
|
56
|
+
}, context.userId, context.pipelineId, parent);
|
|
57
|
+
await this.taskSchedulerService.addTask({
|
|
65
58
|
id: 'sub_pipeline_execution-' + (0, node_crypto_1.randomUUID)(),
|
|
66
59
|
workspaceId: context.workspaceId,
|
|
67
60
|
task: {
|
|
68
|
-
name: '
|
|
61
|
+
name: 'sub_pipeline_execution',
|
|
69
62
|
type: 'run_pipeline',
|
|
70
63
|
user: context.userId,
|
|
71
64
|
workspaceId: context.workspaceId,
|
|
72
|
-
pipelineId: pipeline
|
|
65
|
+
pipelineId: pipeline.id,
|
|
73
66
|
correlationId,
|
|
74
67
|
blockName: args.workflow,
|
|
75
68
|
args: {
|
|
@@ -78,27 +71,39 @@ let ExecuteWorkflowAsync = ExecuteWorkflowAsync_1 = class ExecuteWorkflowAsync {
|
|
|
78
71
|
payload: {},
|
|
79
72
|
},
|
|
80
73
|
});
|
|
74
|
+
if (args.callback?.transition) {
|
|
75
|
+
await this.eventSubscriberService.registerSubscriber(context.pipelineId, context.workflowId, args.callback.transition, correlationId, `workflow.${enums_1.WorkflowState.Completed}`, context.userId, context.workspaceId);
|
|
76
|
+
}
|
|
81
77
|
return {
|
|
82
|
-
data:
|
|
78
|
+
data: {
|
|
79
|
+
mode: 'async',
|
|
80
|
+
correlationId,
|
|
81
|
+
pipelineId: pipeline.id,
|
|
82
|
+
eventName: `workflow.${enums_1.WorkflowState.Completed}`,
|
|
83
|
+
},
|
|
83
84
|
};
|
|
84
85
|
}
|
|
86
|
+
async complete(result) {
|
|
87
|
+
const data = result;
|
|
88
|
+
return await Promise.resolve({ data: data?.result ?? result });
|
|
89
|
+
}
|
|
85
90
|
};
|
|
86
|
-
exports.
|
|
91
|
+
exports.Task = Task;
|
|
87
92
|
__decorate([
|
|
88
93
|
(0, common_2.Input)({
|
|
89
|
-
schema:
|
|
94
|
+
schema: TaskArgsSchema,
|
|
90
95
|
}),
|
|
91
96
|
__metadata("design:type", Object)
|
|
92
|
-
],
|
|
93
|
-
exports.
|
|
97
|
+
], Task.prototype, "args", void 0);
|
|
98
|
+
exports.Task = Task = Task_1 = __decorate([
|
|
94
99
|
(0, common_1.Injectable)(),
|
|
95
100
|
(0, common_2.Tool)({
|
|
96
101
|
config: {
|
|
97
|
-
description: '',
|
|
102
|
+
description: 'Execute a workflow as a sub-task',
|
|
98
103
|
},
|
|
99
104
|
}),
|
|
100
105
|
__metadata("design:paramtypes", [workflow_processor_1.CreatePipelineService,
|
|
101
106
|
scheduler_1.TaskSchedulerService,
|
|
102
107
|
persistence_1.EventSubscriberService])
|
|
103
|
-
],
|
|
104
|
-
//# sourceMappingURL=
|
|
108
|
+
], Task);
|
|
109
|
+
//# sourceMappingURL=task.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.tool.js","sourceRoot":"","sources":["../../src/tools/task.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6CAAyC;AACzC,6BAAwB;AACxB,8CAQ2B;AAC3B,sDAA2D;AAE3D,gDAAwD;AACxD,4CAAoD;AACpD,8DAA8D;AAE9D,MAAM,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,IAAI,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IAClD,QAAQ,EAAE,OAAC;SACR,MAAM,CAAC;QACN,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;KACvB,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC;AAUI,IAAM,IAAI,YAAV,MAAM,IAAI;IAII;IACA;IACA;IALA,MAAM,GAAG,IAAI,eAAM,CAAC,MAAI,CAAC,IAAI,CAAC,CAAC;IAElD,YACmB,qBAA4C,EAC5C,oBAA0C,EAC1C,sBAA8C;QAF9C,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,2BAAsB,GAAtB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AClB,OAAO,CAAC,UAAW,EACnB,IAAI,CAAC,QAAQ,CAAC,UAAU,EACxB,aAAa,EACb,YAAY,qBAAa,CAAC,SAAS,EAAE,EACrC,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,WAAW,CACpB,CAAC;QACJ,CAAC;QAED,OAAO;YACL,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,aAAa;gBACb,UAAU,EAAE,QAAQ,CAAC,EAAE;gBACvB,SAAS,EAAE,YAAY,qBAAa,CAAC,SAAS,EAAE;aACjD;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAe;QAC5B,MAAM,IAAI,GAAG,MAAiC,CAAC;QAC/C,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC,CAAC;IACjE,CAAC;CACF,CAAA;AApFY,oBAAI;AAYf;IAHC,IAAA,cAAK,EAAC;QACL,MAAM,EAAE,cAAc;KACvB,CAAC;;kCACa;eAZJ,IAAI;IANhB,IAAA,mBAAU,GAAE;IACZ,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,kCAAkC;SAChD;KACF,CAAC;qCAK0C,0CAAqB;QACtB,gCAAoB;QAClB,oCAAsB;GANtD,IAAI,CAoFhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflow-processor/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflow-processor/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,SAAS,CAAC"}
|
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./services"), exports);
|
|
18
18
|
__exportStar(require("./workflow-processor.module"), exports);
|
|
19
|
+
__exportStar(require("./utils"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow-processor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8DAA4C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow-processor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8DAA4C;AAC5C,0CAAwB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FindOptionsWhere } from 'typeorm';
|
|
2
|
-
import { PipelineEntity, WorkspaceEntity } from '@loopstack/common';
|
|
2
|
+
import { BlockInterface, PipelineEntity, WorkflowInterface, WorkspaceEntity } from '@loopstack/common';
|
|
3
3
|
import { PipelineService, WorkspaceService } from '../../persistence';
|
|
4
4
|
import { BlockDiscoveryService } from './block-discovery.service';
|
|
5
5
|
export declare class CreatePipelineService {
|
|
@@ -7,7 +7,8 @@ export declare class CreatePipelineService {
|
|
|
7
7
|
private readonly pipelineService;
|
|
8
8
|
private readonly blockDiscoveryService;
|
|
9
9
|
constructor(workspaceService: WorkspaceService, pipelineService: PipelineService, blockDiscoveryService: BlockDiscoveryService);
|
|
10
|
-
private
|
|
11
|
-
|
|
10
|
+
private validateWorkflowArgs;
|
|
11
|
+
private resolveWorkflow;
|
|
12
|
+
create(workspaceWhere: FindOptionsWhere<WorkspaceEntity>, data: Partial<PipelineEntity>, user: string, parentPipelineId?: string, parentWorkflowInstance?: WorkflowInterface | BlockInterface): Promise<PipelineEntity>;
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=create-pipeline.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-pipeline.service.d.ts","sourceRoot":"","sources":["../../../src/workflow-processor/services/create-pipeline.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EACL,cAAc,
|
|
1
|
+
{"version":3,"file":"create-pipeline.service.d.ts","sourceRoot":"","sources":["../../../src/workflow-processor/services/create-pipeline.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,eAAe,EAGhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,qBACa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,qBAAqB;gBAFrB,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,eAAe,EAChC,qBAAqB,EAAE,qBAAqB;IAG/D,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,eAAe;IA2BjB,MAAM,CACV,cAAc,EAAE,gBAAgB,CAAC,eAAe,CAAC,EACjD,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,EAC7B,IAAI,EAAE,MAAM,EACZ,gBAAgB,CAAC,EAAE,MAAM,EACzB,sBAAsB,CAAC,EAAE,iBAAiB,GAAG,cAAc,GAC1D,OAAO,CAAC,cAAc,CAAC;CAwB3B"}
|
|
@@ -23,24 +23,36 @@ let CreatePipelineService = class CreatePipelineService {
|
|
|
23
23
|
this.pipelineService = pipelineService;
|
|
24
24
|
this.blockDiscoveryService = blockDiscoveryService;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
if (!data.blockName) {
|
|
28
|
-
throw new Error(`blockName is required to create a pipeline.`);
|
|
29
|
-
}
|
|
30
|
-
const workflow = (0, common_2.getBlockWorkflow)(workspace, data.blockName);
|
|
31
|
-
if (!workflow) {
|
|
32
|
-
throw new Error(`Workflow ${data.blockName} not available in workspace ${workspace.constructor.name}.`);
|
|
33
|
-
}
|
|
26
|
+
validateWorkflowArgs(workflow, data) {
|
|
34
27
|
if (data.args && Object.keys(data.args).length !== 0) {
|
|
35
28
|
const schema = (0, common_2.getBlockArgsSchema)(workflow);
|
|
36
29
|
data.args = schema?.parse(data.args);
|
|
37
30
|
}
|
|
38
31
|
return data;
|
|
39
32
|
}
|
|
40
|
-
|
|
33
|
+
resolveWorkflow(blockName, workspaceInstance, parentWorkflowInstance) {
|
|
34
|
+
if (parentWorkflowInstance) {
|
|
35
|
+
const workflow = (0, common_2.getBlockWorkflow)(parentWorkflowInstance, blockName);
|
|
36
|
+
if (workflow) {
|
|
37
|
+
return workflow;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const workflow = (0, common_2.getBlockWorkflow)(workspaceInstance, blockName);
|
|
41
|
+
if (workflow) {
|
|
42
|
+
return workflow;
|
|
43
|
+
}
|
|
44
|
+
const parentName = parentWorkflowInstance?.constructor.name;
|
|
45
|
+
throw new Error(`Workflow ${blockName} not found` +
|
|
46
|
+
(parentName ? ` on parent workflow ${parentName} or` : ' on') +
|
|
47
|
+
` workspace ${workspaceInstance.constructor.name}.`);
|
|
48
|
+
}
|
|
49
|
+
async create(workspaceWhere, data, user, parentPipelineId, parentWorkflowInstance) {
|
|
50
|
+
if (!data.blockName) {
|
|
51
|
+
throw new Error('blockName is required to create a pipeline.');
|
|
52
|
+
}
|
|
41
53
|
const workspace = await this.workspaceService.getWorkspace(workspaceWhere, user);
|
|
42
54
|
if (!workspace) {
|
|
43
|
-
throw new Error(
|
|
55
|
+
throw new Error('Workspace not found.');
|
|
44
56
|
}
|
|
45
57
|
const workspaceInstance = this.blockDiscoveryService.getWorkspace(workspace.blockName);
|
|
46
58
|
if (!workspaceInstance) {
|
|
@@ -50,7 +62,8 @@ let CreatePipelineService = class CreatePipelineService {
|
|
|
50
62
|
if (parentPipelineId) {
|
|
51
63
|
parentPipeline = await this.pipelineService.getPipeline(parentPipelineId, user, []);
|
|
52
64
|
}
|
|
53
|
-
const
|
|
65
|
+
const workflow = this.resolveWorkflow(data.blockName, workspaceInstance, parentWorkflowInstance);
|
|
66
|
+
const validData = this.validateWorkflowArgs(workflow, data);
|
|
54
67
|
return this.pipelineService.createPipeline(validData, workspace, user, parentPipeline);
|
|
55
68
|
}
|
|
56
69
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-pipeline.service.js","sourceRoot":"","sources":["../../../src/workflow-processor/services/create-pipeline.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiE;AAEjE,8CAO2B;AAC3B,mDAAsE;AACtE,uEAAkE;AAG3D,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEb;IACA;IACA;IAHnB,YACmB,gBAAkC,EAClC,eAAgC,EAChC,qBAA4C;QAF5C,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,oBAAe,GAAf,eAAe,CAAiB;QAChC,0BAAqB,GAArB,qBAAqB,CAAuB;IAC5D,CAAC;IAEI,
|
|
1
|
+
{"version":3,"file":"create-pipeline.service.js","sourceRoot":"","sources":["../../../src/workflow-processor/services/create-pipeline.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiE;AAEjE,8CAO2B;AAC3B,mDAAsE;AACtE,uEAAkE;AAG3D,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEb;IACA;IACA;IAHnB,YACmB,gBAAkC,EAClC,eAAgC,EAChC,qBAA4C;QAF5C,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,oBAAe,GAAf,eAAe,CAAiB;QAChC,0BAAqB,GAArB,qBAAqB,CAAuB;IAC5D,CAAC;IAEI,oBAAoB,CAAC,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AM,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QACjF,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACvF,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,MAAM,IAAI,4BAAmB,CAAC,kCAAkC,SAAS,CAAC,SAAS,aAAa,CAAC,CAAC;QACpG,CAAC;QAED,IAAI,cAAc,GAA0B,IAAI,CAAC;QACjD,IAAI,gBAAgB,EAAE,CAAC;YACrB,cAAc,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,gBAAgB,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QACtF,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,EAAE,sBAAsB,CAAC,CAAC;QACjG,MAAM,SAAS,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACzF,CAAC;CACF,CAAA;AAxEY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAG0B,8BAAgB;QACjB,6BAAe;QACT,+CAAqB;GAJpD,qBAAqB,CAwEjC"}
|
|
@@ -13,7 +13,9 @@ export declare class RootProcessorService {
|
|
|
13
13
|
private readonly eventEmitter;
|
|
14
14
|
private readonly logger;
|
|
15
15
|
constructor(pipelineService: PipelineService, namespaceProcessorService: NamespaceProcessorService, blockProcessor: BlockProcessor, blockDiscoveryService: BlockDiscoveryService, eventEmitter: EventEmitter2);
|
|
16
|
+
private resolveWorkflowFromWorkspace;
|
|
16
17
|
private resolveWorkflow;
|
|
18
|
+
private resolveWorkflowByNames;
|
|
17
19
|
private emitCompletionEvent;
|
|
18
20
|
runStateless(params: {
|
|
19
21
|
workspaceName: string;
|