@loopstack/core 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/modules/common/common.module.js +10 -15
- package/dist/modules/common/common.module.js.map +1 -1
- package/dist/modules/common/errors/object-expression.error.d.ts +4 -0
- package/dist/modules/common/errors/object-expression.error.js +13 -0
- package/dist/modules/common/errors/object-expression.error.js.map +1 -0
- package/dist/modules/common/errors/template-expression.error.d.ts +4 -0
- package/dist/modules/common/errors/template-expression.error.js +13 -0
- package/dist/modules/common/errors/template-expression.error.js.map +1 -0
- package/dist/modules/common/services/context.service.d.ts +1 -0
- package/dist/modules/common/services/context.service.js +4 -0
- package/dist/modules/common/services/context.service.js.map +1 -1
- package/dist/modules/common/services/expression-handler/object-expression.handler.d.ts +20 -0
- package/dist/modules/common/services/expression-handler/object-expression.handler.js +125 -0
- package/dist/modules/common/services/expression-handler/object-expression.handler.js.map +1 -0
- package/dist/modules/common/services/expression-handler/template-expression.handler.d.ts +12 -0
- package/dist/modules/common/services/expression-handler/template-expression.handler.js +63 -0
- package/dist/modules/common/services/expression-handler/template-expression.handler.js.map +1 -0
- package/dist/modules/common/services/handlebars-helpers/comparison-handlebars-helper.service.d.ts +41 -0
- package/dist/modules/common/services/handlebars-helpers/comparison-handlebars-helper.service.js +416 -0
- package/dist/modules/common/services/handlebars-helpers/comparison-handlebars-helper.service.js.map +1 -0
- package/dist/modules/common/services/handlebars-helpers/date-formatter-handlebars-helper.service.d.ts +9 -0
- package/dist/modules/common/services/handlebars-helpers/date-formatter-handlebars-helper.service.js +124 -0
- package/dist/modules/common/services/handlebars-helpers/date-formatter-handlebars-helper.service.js.map +1 -0
- package/dist/modules/common/services/handlebars-helpers/date-formatter-helper.service.d.ts +9 -0
- package/dist/modules/common/services/handlebars-helpers/date-formatter-helper.service.js +124 -0
- package/dist/modules/common/services/handlebars-helpers/date-formatter-helper.service.js.map +1 -0
- package/dist/modules/common/services/handlebars-helpers/index.d.ts +2 -0
- package/dist/modules/common/services/handlebars-helpers/index.js +19 -0
- package/dist/modules/common/services/handlebars-helpers/index.js.map +1 -0
- package/dist/modules/common/services/handlebars-helpers/operators-helper.service.d.ts +41 -0
- package/dist/modules/common/services/handlebars-helpers/operators-helper.service.js +416 -0
- package/dist/modules/common/services/handlebars-helpers/operators-helper.service.js.map +1 -0
- package/dist/modules/common/services/handlebars-processor.service.d.ts +13 -0
- package/dist/modules/common/services/handlebars-processor.service.js +138 -0
- package/dist/modules/common/services/handlebars-processor.service.js.map +1 -0
- package/dist/modules/common/services/index.d.ts +6 -5
- package/dist/modules/common/services/index.js +6 -5
- package/dist/modules/common/services/index.js.map +1 -1
- package/dist/modules/common/services/template.service.d.ts +16 -0
- package/dist/modules/common/services/template.service.js +64 -0
- package/dist/modules/common/services/template.service.js.map +1 -0
- package/dist/modules/common/services/variable-sanitizer.service.d.ts +9 -0
- package/dist/modules/common/services/variable-sanitizer.service.js +84 -0
- package/dist/modules/common/services/variable-sanitizer.service.js.map +1 -0
- package/dist/modules/configuration/configuration.module.js +2 -1
- package/dist/modules/configuration/configuration.module.js.map +1 -1
- package/dist/modules/configuration/services/configuration.service.d.ts +15 -13
- package/dist/modules/configuration/services/configuration.service.js +97 -96
- package/dist/modules/configuration/services/configuration.service.js.map +1 -1
- package/dist/modules/configuration/services/index.d.ts +1 -0
- package/dist/modules/configuration/services/index.js +1 -0
- package/dist/modules/configuration/services/index.js.map +1 -1
- package/dist/modules/configuration/services/schema-registry.service.d.ts +9 -0
- package/dist/modules/configuration/services/schema-registry.service.js +41 -0
- package/dist/modules/configuration/services/schema-registry.service.js.map +1 -0
- package/dist/modules/persistence/services/document.service.d.ts +5 -1
- package/dist/modules/persistence/services/document.service.js +27 -15
- package/dist/modules/persistence/services/document.service.js.map +1 -1
- package/dist/modules/workflow-processor/services/index.d.ts +2 -1
- package/dist/modules/workflow-processor/services/index.js +2 -1
- package/dist/modules/workflow-processor/services/index.js.map +1 -1
- package/dist/modules/workflow-processor/services/pipeline-processor.service.d.ts +9 -8
- package/dist/modules/workflow-processor/services/pipeline-processor.service.js +92 -52
- package/dist/modules/workflow-processor/services/pipeline-processor.service.js.map +1 -1
- package/dist/modules/workflow-processor/services/root-processor.service.d.ts +2 -2
- package/dist/modules/workflow-processor/services/root-processor.service.js +1 -0
- package/dist/modules/workflow-processor/services/root-processor.service.js.map +1 -1
- package/dist/modules/workflow-processor/services/service-execution.service.d.ts +12 -0
- package/dist/modules/workflow-processor/services/service-execution.service.js +53 -0
- package/dist/modules/workflow-processor/services/service-execution.service.js.map +1 -0
- package/dist/modules/workflow-processor/services/state-machine-config.service.d.ts +2 -17
- package/dist/modules/workflow-processor/services/state-machine-config.service.js +33 -17
- package/dist/modules/workflow-processor/services/state-machine-config.service.js.map +1 -1
- package/dist/modules/workflow-processor/services/state-machine-processor.service.d.ts +11 -7
- package/dist/modules/workflow-processor/services/state-machine-processor.service.js +90 -24
- package/dist/modules/workflow-processor/services/state-machine-processor.service.js.map +1 -1
- package/dist/modules/workflow-processor/services/template-expression-evaluator.service.d.ts +24 -4
- package/dist/modules/workflow-processor/services/template-expression-evaluator.service.js +90 -21
- package/dist/modules/workflow-processor/services/template-expression-evaluator.service.js.map +1 -1
- package/dist/modules/workflow-processor/services/tool-execution.service.d.ts +8 -20
- package/dist/modules/workflow-processor/services/tool-execution.service.js +31 -55
- package/dist/modules/workflow-processor/services/tool-execution.service.js.map +1 -1
- package/dist/modules/workflow-processor/services/workflow-context.service.d.ts +4 -0
- package/dist/modules/{common/services/template-engine.service.js → workflow-processor/services/workflow-context.service.js} +12 -15
- package/dist/modules/workflow-processor/services/workflow-context.service.js.map +1 -0
- package/dist/modules/workflow-processor/services/workflow-processor.service.d.ts +2 -2
- package/dist/modules/workflow-processor/services/workflow-processor.service.js +12 -8
- package/dist/modules/workflow-processor/services/workflow-processor.service.js.map +1 -1
- package/dist/modules/workflow-processor/services/workflow-state.service.d.ts +2 -2
- package/dist/modules/workflow-processor/services/workflow-state.service.js +5 -5
- package/dist/modules/workflow-processor/services/workflow-state.service.js.map +1 -1
- package/dist/modules/workflow-processor/tool-services/add-namespace.service.js +4 -4
- package/dist/modules/workflow-processor/tool-services/add-namespace.service.js.map +1 -1
- package/dist/modules/workflow-processor/tool-services/batch-create-documents.service.d.ts +4 -8
- package/dist/modules/workflow-processor/tool-services/batch-create-documents.service.js +38 -26
- package/dist/modules/workflow-processor/tool-services/batch-create-documents.service.js.map +1 -1
- package/dist/modules/workflow-processor/tool-services/create-document.service.d.ts +17 -138
- package/dist/modules/workflow-processor/tool-services/create-document.service.js +83 -31
- package/dist/modules/workflow-processor/tool-services/create-document.service.js.map +1 -1
- package/dist/modules/workflow-processor/tool-services/load-document.service.d.ts +61 -51
- package/dist/modules/workflow-processor/tool-services/load-document.service.js +57 -79
- package/dist/modules/workflow-processor/tool-services/load-document.service.js.map +1 -1
- package/dist/modules/workflow-processor/tool-services/mock.service.d.ts +11 -8
- package/dist/modules/workflow-processor/tool-services/mock.service.js +41 -9
- package/dist/modules/workflow-processor/tool-services/mock.service.js.map +1 -1
- package/dist/modules/workflow-processor/tool-services/set-context.service.d.ts +3 -0
- package/dist/modules/workflow-processor/tool-services/set-context.service.js +11 -5
- package/dist/modules/workflow-processor/tool-services/set-context.service.js.map +1 -1
- package/dist/modules/workflow-processor/tool-services/set-target-place.service.js +7 -6
- package/dist/modules/workflow-processor/tool-services/set-target-place.service.js.map +1 -1
- package/dist/modules/workflow-processor/tool-services/transition-selector.service.js +2 -2
- package/dist/modules/workflow-processor/tool-services/transition-selector.service.js.map +1 -1
- package/dist/modules/workflow-processor/tool-services/update-document.service.d.ts +32 -55
- package/dist/modules/workflow-processor/tool-services/update-document.service.js +92 -7
- package/dist/modules/workflow-processor/tool-services/update-document.service.js.map +1 -1
- package/dist/modules/workflow-processor/validators/workflow-option.validator.d.ts +1 -1
- package/dist/modules/workflow-processor/validators/workflow-option.validator.js +3 -3
- package/dist/modules/workflow-processor/validators/workflow-option.validator.js.map +1 -1
- package/dist/modules/workflow-processor/workflow-processor.module.js +2 -1
- package/dist/modules/workflow-processor/workflow-processor.module.js.map +1 -1
- package/dist/utils/load-configuration.js +5 -3
- package/dist/utils/load-configuration.js.map +1 -1
- package/package.json +5 -3
- package/dist/modules/common/services/document-helper.service.d.ts +0 -198
- package/dist/modules/common/services/document-helper.service.js +0 -53
- package/dist/modules/common/services/document-helper.service.js.map +0 -1
- package/dist/modules/common/services/expression-evaluator.service.d.ts +0 -5
- package/dist/modules/common/services/expression-evaluator.service.js +0 -44
- package/dist/modules/common/services/expression-evaluator.service.js.map +0 -1
- package/dist/modules/common/services/schema-validator.service.d.ts +0 -7
- package/dist/modules/common/services/schema-validator.service.js +0 -41
- package/dist/modules/common/services/schema-validator.service.js.map +0 -1
- package/dist/modules/common/services/template-engine.service.d.ts +0 -5
- package/dist/modules/common/services/template-engine.service.js.map +0 -1
- package/dist/modules/common/services/value-parser.service.d.ts +0 -19
- package/dist/modules/common/services/value-parser.service.js +0 -68
- package/dist/modules/common/services/value-parser.service.js.map +0 -1
- package/dist/modules/workflow-processor/services/tool-schema-validator.service.d.ts +0 -5
- package/dist/modules/workflow-processor/services/tool-schema-validator.service.js +0 -41
- package/dist/modules/workflow-processor/services/tool-schema-validator.service.js.map +0 -1
|
@@ -5,38 +5,69 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
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
|
+
};
|
|
8
11
|
var MockService_1;
|
|
9
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
13
|
exports.MockService = void 0;
|
|
11
14
|
const common_1 = require("@nestjs/common");
|
|
12
15
|
const zod_1 = require("zod");
|
|
13
16
|
const shared_1 = require("@loopstack/shared");
|
|
17
|
+
const services_1 = require("../services");
|
|
14
18
|
const config = zod_1.z
|
|
15
19
|
.object({
|
|
16
|
-
input: zod_1.z.
|
|
17
|
-
output: zod_1.z.
|
|
20
|
+
input: zod_1.z.any().optional(),
|
|
21
|
+
output: zod_1.z.any().optional(),
|
|
18
22
|
error: zod_1.z.string().optional(),
|
|
19
23
|
})
|
|
20
24
|
.strict();
|
|
21
25
|
const schema = zod_1.z
|
|
22
26
|
.object({
|
|
23
|
-
input: zod_1.z.
|
|
24
|
-
output: zod_1.z.
|
|
27
|
+
input: zod_1.z.any().optional(),
|
|
28
|
+
output: zod_1.z.any().optional(),
|
|
25
29
|
error: zod_1.z.string().optional(),
|
|
26
30
|
})
|
|
27
31
|
.strict();
|
|
28
32
|
let MockService = MockService_1 = class MockService {
|
|
33
|
+
templateExpressionEvaluatorService;
|
|
29
34
|
logger = new common_1.Logger(MockService_1.name);
|
|
30
|
-
|
|
35
|
+
constructor(templateExpressionEvaluatorService) {
|
|
36
|
+
this.templateExpressionEvaluatorService = templateExpressionEvaluatorService;
|
|
37
|
+
}
|
|
38
|
+
async apply(props, workflow, context, transitionData, parentArguments) {
|
|
31
39
|
if (props.input) {
|
|
32
|
-
this.
|
|
40
|
+
const input = this.templateExpressionEvaluatorService.parse(props.input, {
|
|
41
|
+
arguments: parentArguments,
|
|
42
|
+
context,
|
|
43
|
+
workflow,
|
|
44
|
+
transition: transitionData,
|
|
45
|
+
});
|
|
46
|
+
this.logger.debug(`Received mock input:`);
|
|
47
|
+
this.logger.debug(props.input);
|
|
48
|
+
this.logger.debug(parentArguments);
|
|
49
|
+
this.logger.debug(input);
|
|
33
50
|
}
|
|
51
|
+
const output = props.output
|
|
52
|
+
? this.templateExpressionEvaluatorService.parse(props.output, {
|
|
53
|
+
arguments: parentArguments,
|
|
54
|
+
context,
|
|
55
|
+
workflow,
|
|
56
|
+
transition: transitionData,
|
|
57
|
+
})
|
|
58
|
+
: null;
|
|
34
59
|
if (props.error) {
|
|
35
|
-
|
|
60
|
+
const error = this.templateExpressionEvaluatorService.parse(props.error, {
|
|
61
|
+
arguments: parentArguments,
|
|
62
|
+
context,
|
|
63
|
+
workflow,
|
|
64
|
+
transition: transitionData,
|
|
65
|
+
});
|
|
66
|
+
throw new Error(error);
|
|
36
67
|
}
|
|
37
68
|
return {
|
|
38
69
|
success: true,
|
|
39
|
-
data:
|
|
70
|
+
data: output,
|
|
40
71
|
};
|
|
41
72
|
}
|
|
42
73
|
};
|
|
@@ -46,6 +77,7 @@ exports.MockService = MockService = MockService_1 = __decorate([
|
|
|
46
77
|
(0, shared_1.Service)({
|
|
47
78
|
config,
|
|
48
79
|
schema,
|
|
49
|
-
})
|
|
80
|
+
}),
|
|
81
|
+
__metadata("design:paramtypes", [services_1.TemplateExpressionEvaluatorService])
|
|
50
82
|
], MockService);
|
|
51
83
|
//# sourceMappingURL=mock.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/mock.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mock.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/mock.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6BAAwB;AACxB,8CAQ2B;AAC3B,0CAAiE;AAEjE,MAAM,MAAM,GAAG,OAAC;KACb,MAAM,CAAC;IACN,KAAK,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACzB,MAAM,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC1B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAA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,CACF;YACH,CAAC,CAAC,IAAI,CAAC;QAET,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,KAAK,GAAG,IAAI,CAAC,kCAAkC,CAAC,KAAK,CACzD,KAAK,CAAC,KAAK,EACX;gBACE,SAAS,EAAE,eAAe;gBAC1B,OAAO;gBACP,QAAQ;gBACR,UAAU,EAAE,cAAc;aAC3B,CACF,CAAC;YAEF,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,MAAM;SACb,CAAC;IACJ,CAAC;CACF,CAAA;AA9DY,kCAAW;sBAAX,WAAW;IALvB,IAAA,mBAAU,GAAE;IACZ,IAAA,gBAAO,EAAC;QACP,MAAM;QACN,MAAM;KACP,CAAC;qCAK8C,6CAAkC;GAJrE,WAAW,CA8DvB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ServiceInterface, ServiceCallResult } from '@loopstack/shared';
|
|
3
3
|
import { WorkflowEntity } from '@loopstack/shared';
|
|
4
|
+
import { WorkflowContextService } from '../services';
|
|
4
5
|
declare const schema: z.ZodObject<{
|
|
5
6
|
key: z.ZodString;
|
|
6
7
|
value: z.ZodAny;
|
|
@@ -12,7 +13,9 @@ declare const schema: z.ZodObject<{
|
|
|
12
13
|
value?: any;
|
|
13
14
|
}>;
|
|
14
15
|
export declare class SetContextService implements ServiceInterface {
|
|
16
|
+
private readonly workflowContextService;
|
|
15
17
|
private readonly logger;
|
|
18
|
+
constructor(workflowContextService: WorkflowContextService);
|
|
16
19
|
apply(props: z.infer<typeof schema>, workflow: WorkflowEntity | undefined): Promise<ServiceCallResult>;
|
|
17
20
|
}
|
|
18
21
|
export {};
|
|
@@ -5,12 +5,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
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
|
+
};
|
|
8
11
|
var SetContextService_1;
|
|
9
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
13
|
exports.SetContextService = void 0;
|
|
11
14
|
const common_1 = require("@nestjs/common");
|
|
12
15
|
const zod_1 = require("zod");
|
|
13
16
|
const shared_1 = require("@loopstack/shared");
|
|
17
|
+
const services_1 = require("../services");
|
|
14
18
|
const config = zod_1.z
|
|
15
19
|
.object({
|
|
16
20
|
key: zod_1.z.string(),
|
|
@@ -24,15 +28,16 @@ const schema = zod_1.z
|
|
|
24
28
|
})
|
|
25
29
|
.strict();
|
|
26
30
|
let SetContextService = SetContextService_1 = class SetContextService {
|
|
31
|
+
workflowContextService;
|
|
27
32
|
logger = new common_1.Logger(SetContextService_1.name);
|
|
33
|
+
constructor(workflowContextService) {
|
|
34
|
+
this.workflowContextService = workflowContextService;
|
|
35
|
+
}
|
|
28
36
|
async apply(props, workflow) {
|
|
29
37
|
if (!workflow) {
|
|
30
38
|
throw new Error('Workflow is undefined');
|
|
31
39
|
}
|
|
32
|
-
|
|
33
|
-
workflow.contextUpdate = {};
|
|
34
|
-
}
|
|
35
|
-
workflow.contextUpdate[props.key] = props.value;
|
|
40
|
+
workflow = this.workflowContextService.setWorkflowContextUpdate(workflow, props.key, props.value);
|
|
36
41
|
this.logger.debug(`Set context update key "${props.key}".`);
|
|
37
42
|
return {
|
|
38
43
|
success: true,
|
|
@@ -46,6 +51,7 @@ exports.SetContextService = SetContextService = SetContextService_1 = __decorate
|
|
|
46
51
|
(0, shared_1.Service)({
|
|
47
52
|
config,
|
|
48
53
|
schema,
|
|
49
|
-
})
|
|
54
|
+
}),
|
|
55
|
+
__metadata("design:paramtypes", [services_1.WorkflowContextService])
|
|
50
56
|
], SetContextService);
|
|
51
57
|
//# sourceMappingURL=set-context.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-context.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/set-context.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set-context.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/set-context.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6BAAwB;AACxB,8CAI2B;AAE3B,0CAAqD;AAErD,MAAM,MAAM,GAAG,OAAC;KACb,MAAM,CAAC;IACN,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,KAAK,EAAE,OAAC,CAAC,GAAG,EAAE;CACf,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,MAAM,GAAG,OAAC;KACb,MAAM,CAAC;IACN,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,KAAK,EAAE,OAAC,CAAC,GAAG,EAAE;CACf,CAAC;KACD,MAAM,EAAE,CAAC;AAOL,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAIT;IAHF,MAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAE7D,YACmB,sBAA8C;QAA9C,2BAAsB,GAAtB,sBAAsB,CAAwB;IAC9D,CAAC;IAEJ,KAAK,CAAC,KAAK,CACT,KAA6B,EAC7B,QAAoC;QAEpC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,CAC7D,QAAQ,EACR,KAAK,CAAC,GAAG,EACT,KAAK,CAAC,KAAK,CACZ,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QAE5D,OAAO;YACL,OAAO,EAAE,IAAI;YACb,QAAQ;SACT,CAAC;IACJ,CAAC;CACF,CAAA;AA5BY,8CAAiB;4BAAjB,iBAAiB;IAL7B,IAAA,mBAAU,GAAE;IACZ,IAAA,gBAAO,EAAC;QACP,MAAM;QACN,MAAM;KACP,CAAC;qCAK2C,iCAAsB;GAJtD,iBAAiB,CA4B7B"}
|
|
@@ -13,12 +13,12 @@ const zod_1 = require("zod");
|
|
|
13
13
|
const shared_1 = require("@loopstack/shared");
|
|
14
14
|
const config = zod_1.z
|
|
15
15
|
.object({
|
|
16
|
-
target:
|
|
16
|
+
target: zod_1.z.string(),
|
|
17
17
|
})
|
|
18
18
|
.strict();
|
|
19
19
|
const schema = zod_1.z
|
|
20
20
|
.object({
|
|
21
|
-
target:
|
|
21
|
+
target: zod_1.z.string(),
|
|
22
22
|
})
|
|
23
23
|
.strict();
|
|
24
24
|
let SetTargetPlaceService = SetTargetPlaceService_1 = class SetTargetPlaceService {
|
|
@@ -27,14 +27,15 @@ let SetTargetPlaceService = SetTargetPlaceService_1 = class SetTargetPlaceServic
|
|
|
27
27
|
if (!transitionData.transition) {
|
|
28
28
|
throw new Error('No transition available.');
|
|
29
29
|
}
|
|
30
|
+
const target = props.target.trim();
|
|
30
31
|
if ((Array.isArray(transitionData.to) &&
|
|
31
|
-
!transitionData.to.includes(
|
|
32
|
-
(!Array.isArray(transitionData.to) && transitionData.to !==
|
|
33
|
-
throw new Error(`Transition to ${
|
|
32
|
+
!transitionData.to.includes(target)) ||
|
|
33
|
+
(!Array.isArray(transitionData.to) && transitionData.to !== target)) {
|
|
34
|
+
throw new Error(`Transition to ${target} not allowed.`);
|
|
34
35
|
}
|
|
35
36
|
return {
|
|
36
37
|
success: true,
|
|
37
|
-
place:
|
|
38
|
+
place: target,
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-target-place.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/set-target-place.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,6BAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"set-target-place.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/set-target-place.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,6BAAwB;AACxB,8CAQ2B;AAE3B,MAAM,MAAM,GAAG,OAAC;KACb,MAAM,CAAC;IACN,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;CACnB,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,MAAM,GAAG,OAAC;KACb,MAAM,CAAC;IACN,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;CACnB,CAAC;KACD,MAAM,EAAE,CAAC;AAOL,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IACf,MAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAEjE,KAAK,CAAC,KAAK,CACT,KAA6B,EAC7B,QAAwB,EACxB,OAAyB,EACzB,cAA2C;QAE3C,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACnC,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;YAC/B,CAAC,cAAc,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACtC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,KAAK,MAAM,CAAC,EACnE,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,iBAAiB,MAAM,eAAe,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,MAAM;SACd,CAAC;IACJ,CAAC;CACF,CAAA;AA3BY,sDAAqB;gCAArB,qBAAqB;IALjC,IAAA,mBAAU,GAAE;IACZ,IAAA,gBAAO,EAAC;QACP,MAAM;QACN,MAAM;KACP,CAAC;GACW,qBAAqB,CA2BjC"}
|
|
@@ -14,7 +14,7 @@ const shared_1 = require("@loopstack/shared");
|
|
|
14
14
|
const config = zod_1.z
|
|
15
15
|
.object({
|
|
16
16
|
transitions: zod_1.z.array(zod_1.z.object({
|
|
17
|
-
place:
|
|
17
|
+
place: zod_1.z.string(),
|
|
18
18
|
condition: shared_1.ExpressionString.optional(),
|
|
19
19
|
})),
|
|
20
20
|
})
|
|
@@ -22,7 +22,7 @@ const config = zod_1.z
|
|
|
22
22
|
const schema = zod_1.z
|
|
23
23
|
.object({
|
|
24
24
|
transitions: zod_1.z.array(zod_1.z.object({
|
|
25
|
-
place:
|
|
25
|
+
place: zod_1.z.string(),
|
|
26
26
|
condition: zod_1.z.union([zod_1.z.boolean(), zod_1.z.undefined()]),
|
|
27
27
|
})),
|
|
28
28
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition-selector.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/transition-selector.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,6BAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"transition-selector.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/transition-selector.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,6BAAwB;AACxB,8CAK2B;AAE3B,MAAM,MAAM,GAAG,OAAC;KACb,MAAM,CAAC;IACN,WAAW,EAAE,OAAC,CAAC,KAAK,CAClB,OAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;QACjB,SAAS,EAAE,yBAAgB,CAAC,QAAQ,EAAE;KACvC,CAAC,CACH;CACF,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,MAAM,GAAG,OAAC;KACb,MAAM,CAAC;IACN,WAAW,EAAE,OAAC,CAAC,KAAK,CAClB,OAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;QACjB,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,EAAE,EAAE,OAAC,CAAC,SAAS,EAAE,CAAC,CAAC;KACjD,CAAC,CACH;CACF,CAAC;KACD,MAAM,EAAE,CAAC;AAOL,IAAM,yBAAyB,iCAA/B,MAAM,yBAAyB;IACnB,MAAM,GAAG,IAAI,eAAM,CAAC,2BAAyB,CAAC,IAAI,CAAC,CAAC;IAErE,KAAK,CAAC,KAAK,CAAC,KAA6B;QACvC,IAAI,KAAyB,CAAC;QAC9B,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACvC,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;gBACvD,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;gBACrB,MAAM;YACR,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,KAAK;SACN,CAAC;IACJ,CAAC;CACF,CAAA;AAjBY,8DAAyB;oCAAzB,yBAAyB;IALrC,IAAA,mBAAU,GAAE;IACZ,IAAA,gBAAO,EAAC;QACP,MAAM;QACN,MAAM;KACP,CAAC;GACW,yBAAyB,CAiBrC"}
|
|
@@ -1,110 +1,87 @@
|
|
|
1
|
-
import { ServiceInterface, ServiceCallResult } from '@loopstack/shared';
|
|
1
|
+
import { ServiceInterface, ServiceCallResult, ContextInterface, TransitionMetadataInterface } from '@loopstack/shared';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { WorkflowEntity } from '@loopstack/shared';
|
|
4
4
|
import { DocumentService } from '../../persistence';
|
|
5
|
+
import { TemplateExpressionEvaluatorService } from '../services';
|
|
6
|
+
import { SchemaRegistry } from '../../configuration';
|
|
5
7
|
declare const schema: z.ZodObject<{
|
|
6
8
|
id: z.ZodString;
|
|
7
9
|
update: z.ZodOptional<z.ZodObject<{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
meta: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
15
|
-
mimeType: z.ZodOptional<z.ZodEnum<["text/plain", "text/html", "text/css", "text/xml", "text/markdown", "application/javascript", "application/typescript", "application/json", "application/xml", "application/yaml"]>>;
|
|
16
|
-
invalidate: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
-
level: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"debug">, z.ZodLiteral<"info">, z.ZodLiteral<"warning">, z.ZodLiteral<"error">]>>;
|
|
10
|
+
content: z.ZodAny;
|
|
11
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
12
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
13
|
+
mimeType: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["text/plain", "text/html", "text/css", "text/xml", "text/markdown", "application/javascript", "application/typescript", "application/json", "application/xml", "application/yaml"]>, z.ZodString]>>;
|
|
14
|
+
invalidate: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
15
|
+
level: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<"debug">, z.ZodLiteral<"info">, z.ZodLiteral<"warning">, z.ZodLiteral<"error">]>>;
|
|
18
16
|
enableAtPlaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
17
|
hideAtPlaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
-
data: z.ZodOptional<z.ZodAny>;
|
|
21
18
|
}, "strip", z.ZodTypeAny, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
19
|
+
mimeType?: string | undefined;
|
|
20
|
+
invalidate?: string | boolean | undefined;
|
|
21
|
+
level?: string | undefined;
|
|
26
22
|
enableAtPlaces?: string[] | undefined;
|
|
27
23
|
hideAtPlaces?: string[] | undefined;
|
|
28
24
|
}, {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
25
|
+
mimeType?: string | undefined;
|
|
26
|
+
invalidate?: string | boolean | undefined;
|
|
27
|
+
level?: string | undefined;
|
|
33
28
|
enableAtPlaces?: string[] | undefined;
|
|
34
29
|
hideAtPlaces?: string[] | undefined;
|
|
35
|
-
}
|
|
30
|
+
}>>;
|
|
36
31
|
}, "strip", z.ZodTypeAny, {
|
|
37
|
-
name?: string | undefined;
|
|
38
|
-
schema?: any;
|
|
39
32
|
content?: any;
|
|
40
|
-
ui?: any;
|
|
41
33
|
tags?: string[] | undefined;
|
|
42
34
|
meta?: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
35
|
+
mimeType?: string | undefined;
|
|
36
|
+
invalidate?: string | boolean | undefined;
|
|
37
|
+
level?: string | undefined;
|
|
47
38
|
enableAtPlaces?: string[] | undefined;
|
|
48
39
|
hideAtPlaces?: string[] | undefined;
|
|
49
40
|
} | undefined;
|
|
50
|
-
description?: string | undefined;
|
|
51
41
|
}, {
|
|
52
|
-
name?: string | undefined;
|
|
53
|
-
schema?: any;
|
|
54
42
|
content?: any;
|
|
55
|
-
ui?: any;
|
|
56
43
|
tags?: string[] | undefined;
|
|
57
44
|
meta?: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
45
|
+
mimeType?: string | undefined;
|
|
46
|
+
invalidate?: string | boolean | undefined;
|
|
47
|
+
level?: string | undefined;
|
|
62
48
|
enableAtPlaces?: string[] | undefined;
|
|
63
49
|
hideAtPlaces?: string[] | undefined;
|
|
64
50
|
} | undefined;
|
|
65
|
-
description?: string | undefined;
|
|
66
51
|
}>>;
|
|
67
52
|
}, "strict", z.ZodTypeAny, {
|
|
68
53
|
id: string;
|
|
69
54
|
update?: {
|
|
70
|
-
name?: string | undefined;
|
|
71
|
-
schema?: any;
|
|
72
55
|
content?: any;
|
|
73
|
-
ui?: any;
|
|
74
56
|
tags?: string[] | undefined;
|
|
75
57
|
meta?: {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
58
|
+
mimeType?: string | undefined;
|
|
59
|
+
invalidate?: string | boolean | undefined;
|
|
60
|
+
level?: string | undefined;
|
|
80
61
|
enableAtPlaces?: string[] | undefined;
|
|
81
62
|
hideAtPlaces?: string[] | undefined;
|
|
82
63
|
} | undefined;
|
|
83
|
-
description?: string | undefined;
|
|
84
64
|
} | undefined;
|
|
85
65
|
}, {
|
|
86
66
|
id: string;
|
|
87
67
|
update?: {
|
|
88
|
-
name?: string | undefined;
|
|
89
|
-
schema?: any;
|
|
90
68
|
content?: any;
|
|
91
|
-
ui?: any;
|
|
92
69
|
tags?: string[] | undefined;
|
|
93
70
|
meta?: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
71
|
+
mimeType?: string | undefined;
|
|
72
|
+
invalidate?: string | boolean | undefined;
|
|
73
|
+
level?: string | undefined;
|
|
98
74
|
enableAtPlaces?: string[] | undefined;
|
|
99
75
|
hideAtPlaces?: string[] | undefined;
|
|
100
76
|
} | undefined;
|
|
101
|
-
description?: string | undefined;
|
|
102
77
|
} | undefined;
|
|
103
78
|
}>;
|
|
104
79
|
export declare class UpdateDocumentService implements ServiceInterface {
|
|
105
80
|
private documentService;
|
|
81
|
+
private templateExpressionEvaluatorService;
|
|
82
|
+
private schemaRegistry;
|
|
106
83
|
private readonly logger;
|
|
107
|
-
constructor(documentService: DocumentService);
|
|
108
|
-
apply(props: z.infer<typeof schema>, workflow: WorkflowEntity | undefined): Promise<ServiceCallResult>;
|
|
84
|
+
constructor(documentService: DocumentService, templateExpressionEvaluatorService: TemplateExpressionEvaluatorService, schemaRegistry: SchemaRegistry);
|
|
85
|
+
apply(props: z.infer<typeof schema>, workflow: WorkflowEntity | undefined, context: ContextInterface, meta: TransitionMetadataInterface, parentArguments: any): Promise<ServiceCallResult>;
|
|
109
86
|
}
|
|
110
87
|
export {};
|
|
@@ -17,25 +17,74 @@ const zod_1 = require("zod");
|
|
|
17
17
|
const persistence_1 = require("../../persistence");
|
|
18
18
|
const lodash_1 = require("lodash");
|
|
19
19
|
const expression_type_schema_1 = require("@loopstack/shared/dist/schemas/expression-type.schema");
|
|
20
|
+
const services_1 = require("../services");
|
|
21
|
+
const configuration_1 = require("../../configuration");
|
|
20
22
|
const config = zod_1.z
|
|
21
23
|
.object({
|
|
22
24
|
id: expression_type_schema_1.ExpressionString,
|
|
23
|
-
update:
|
|
25
|
+
update: zod_1.z
|
|
26
|
+
.object({
|
|
27
|
+
content: zod_1.z.any(),
|
|
28
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
29
|
+
meta: zod_1.z
|
|
30
|
+
.object({
|
|
31
|
+
mimeType: shared_1.MimeTypeSchema.optional(),
|
|
32
|
+
invalidate: zod_1.z.boolean().optional(),
|
|
33
|
+
level: zod_1.z
|
|
34
|
+
.union([
|
|
35
|
+
zod_1.z.literal('debug'),
|
|
36
|
+
zod_1.z.literal('info'),
|
|
37
|
+
zod_1.z.literal('warning'),
|
|
38
|
+
zod_1.z.literal('error'),
|
|
39
|
+
])
|
|
40
|
+
.optional(),
|
|
41
|
+
enableAtPlaces: zod_1.z.array(zod_1.z.string()).optional(),
|
|
42
|
+
hideAtPlaces: zod_1.z.array(zod_1.z.string()).optional(),
|
|
43
|
+
})
|
|
44
|
+
.optional(),
|
|
45
|
+
})
|
|
46
|
+
.optional(),
|
|
24
47
|
})
|
|
25
48
|
.strict();
|
|
26
49
|
const schema = zod_1.z
|
|
27
50
|
.object({
|
|
28
|
-
id:
|
|
29
|
-
update:
|
|
51
|
+
id: zod_1.z.string(),
|
|
52
|
+
update: zod_1.z
|
|
53
|
+
.object({
|
|
54
|
+
content: zod_1.z.any(),
|
|
55
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
56
|
+
meta: zod_1.z
|
|
57
|
+
.object({
|
|
58
|
+
mimeType: zod_1.z.union([shared_1.MimeTypeSchema, expression_type_schema_1.ExpressionString]).optional(),
|
|
59
|
+
invalidate: zod_1.z.union([zod_1.z.boolean(), expression_type_schema_1.ExpressionString]).optional(),
|
|
60
|
+
level: zod_1.z
|
|
61
|
+
.union([
|
|
62
|
+
expression_type_schema_1.ExpressionString,
|
|
63
|
+
zod_1.z.literal('debug'),
|
|
64
|
+
zod_1.z.literal('info'),
|
|
65
|
+
zod_1.z.literal('warning'),
|
|
66
|
+
zod_1.z.literal('error'),
|
|
67
|
+
])
|
|
68
|
+
.optional(),
|
|
69
|
+
enableAtPlaces: zod_1.z.array(zod_1.z.string()).optional(),
|
|
70
|
+
hideAtPlaces: zod_1.z.array(zod_1.z.string()).optional(),
|
|
71
|
+
})
|
|
72
|
+
.optional(),
|
|
73
|
+
})
|
|
74
|
+
.optional(),
|
|
30
75
|
})
|
|
31
76
|
.strict();
|
|
32
77
|
let UpdateDocumentService = UpdateDocumentService_1 = class UpdateDocumentService {
|
|
33
78
|
documentService;
|
|
79
|
+
templateExpressionEvaluatorService;
|
|
80
|
+
schemaRegistry;
|
|
34
81
|
logger = new common_1.Logger(UpdateDocumentService_1.name);
|
|
35
|
-
constructor(documentService) {
|
|
82
|
+
constructor(documentService, templateExpressionEvaluatorService, schemaRegistry) {
|
|
36
83
|
this.documentService = documentService;
|
|
84
|
+
this.templateExpressionEvaluatorService = templateExpressionEvaluatorService;
|
|
85
|
+
this.schemaRegistry = schemaRegistry;
|
|
37
86
|
}
|
|
38
|
-
async apply(props, workflow) {
|
|
87
|
+
async apply(props, workflow, context, meta, parentArguments) {
|
|
39
88
|
if (!workflow) {
|
|
40
89
|
throw new Error('Workflow is undefined');
|
|
41
90
|
}
|
|
@@ -44,7 +93,41 @@ let UpdateDocumentService = UpdateDocumentService_1 = class UpdateDocumentServic
|
|
|
44
93
|
throw new Error(`Document with ID ${props.id} not found.`);
|
|
45
94
|
}
|
|
46
95
|
this.logger.debug(`Update document "${document.name}".`);
|
|
47
|
-
|
|
96
|
+
let updateSkeleton = (0, lodash_1.omit)(props.update ?? {}, ['content']);
|
|
97
|
+
if (!(0, lodash_1.isEmpty)(updateSkeleton)) {
|
|
98
|
+
updateSkeleton =
|
|
99
|
+
this.templateExpressionEvaluatorService.parse(updateSkeleton, {
|
|
100
|
+
arguments: parentArguments,
|
|
101
|
+
context,
|
|
102
|
+
workflow,
|
|
103
|
+
transition: meta,
|
|
104
|
+
}, {
|
|
105
|
+
schema: shared_1.DocumentSchema,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const content = typeof props.update?.content === 'object'
|
|
109
|
+
? (0, lodash_1.merge)({}, document.content, props.update.content)
|
|
110
|
+
: props.update?.content;
|
|
111
|
+
const zodSchema = this.schemaRegistry.getZodSchema(`${document.name}.content`);
|
|
112
|
+
if (!zodSchema && content) {
|
|
113
|
+
throw Error(`Document updates with content no schema defined.`);
|
|
114
|
+
}
|
|
115
|
+
const parsedDocumentContent = content
|
|
116
|
+
? this.templateExpressionEvaluatorService.parse(content, {
|
|
117
|
+
arguments: parentArguments,
|
|
118
|
+
context,
|
|
119
|
+
workflow,
|
|
120
|
+
transition: meta,
|
|
121
|
+
}, {
|
|
122
|
+
schema: zodSchema,
|
|
123
|
+
})
|
|
124
|
+
: document.content;
|
|
125
|
+
const documentData = {
|
|
126
|
+
...document,
|
|
127
|
+
...updateSkeleton,
|
|
128
|
+
content: parsedDocumentContent,
|
|
129
|
+
};
|
|
130
|
+
document = this.documentService.update(workflow, documentData);
|
|
48
131
|
return {
|
|
49
132
|
success: true,
|
|
50
133
|
persist: true,
|
|
@@ -60,6 +143,8 @@ exports.UpdateDocumentService = UpdateDocumentService = UpdateDocumentService_1
|
|
|
60
143
|
config,
|
|
61
144
|
schema,
|
|
62
145
|
}),
|
|
63
|
-
__metadata("design:paramtypes", [persistence_1.DocumentService
|
|
146
|
+
__metadata("design:paramtypes", [persistence_1.DocumentService,
|
|
147
|
+
services_1.TemplateExpressionEvaluatorService,
|
|
148
|
+
configuration_1.SchemaRegistry])
|
|
64
149
|
], UpdateDocumentService);
|
|
65
150
|
//# sourceMappingURL=update-document.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-document.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/update-document.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"update-document.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/update-document.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAS2B;AAC3B,6BAAwB;AAExB,mDAAoD;AACpD,mCAA8C;AAC9C,kGAAyF;AACzF,0CAAiE;AACjE,uDAAqD;AAErD,MAAM,MAAM,GAAG,OAAC;KACb,MAAM,CAAC;IACN,EAAE,EAAE,yCAAgB;IACpB,MAAM,EAAE,OAAC;SACN,MAAM,CAAC;QACN,OAAO,EAAE,OAAC,CAAC,GAAG,EAAE;QAChB,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;QACpC,IAAI,EAAE,OAAC;aACJ,MAAM,CAAC;YACN,QAAQ,EAAE,uBAAc,CAAC,QAAQ,EAAE;YACnC,UAAU,EAAE,OAAC,C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AAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAE/D,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;YACb,QAAQ;YACR,IAAI,EAAE,QAAQ;SACf,CAAC;IACJ,CAAC;CACF,CAAA;AAzFY,sDAAqB;gCAArB,qBAAqB;IALjC,IAAA,mBAAU,GAAE;IACZ,IAAA,gBAAO,EAAC;QACP,MAAM;QACN,MAAM;KACP,CAAC;qCAK2B,6BAAe;QACI,6CAAkC;QACtD,8BAAc;GAN7B,qBAAqB,CAyFjC"}
|
|
@@ -2,7 +2,7 @@ import { StateMachineValidatorInterface } from '@loopstack/shared';
|
|
|
2
2
|
import { WorkflowEntity } from '@loopstack/shared';
|
|
3
3
|
export declare class WorkflowOptionValidator implements StateMachineValidatorInterface {
|
|
4
4
|
private readonly logger;
|
|
5
|
-
validate(workflow: WorkflowEntity,
|
|
5
|
+
validate(workflow: WorkflowEntity, args: Record<string, any> | undefined): {
|
|
6
6
|
valid: boolean;
|
|
7
7
|
target?: string;
|
|
8
8
|
hash?: string;
|
|
@@ -12,10 +12,10 @@ const common_1 = require("@nestjs/common");
|
|
|
12
12
|
const shared_1 = require("@loopstack/shared");
|
|
13
13
|
let WorkflowOptionValidator = WorkflowOptionValidator_1 = class WorkflowOptionValidator {
|
|
14
14
|
logger = new common_1.Logger(WorkflowOptionValidator_1.name);
|
|
15
|
-
validate(workflow,
|
|
16
|
-
if (
|
|
15
|
+
validate(workflow, args) {
|
|
16
|
+
if (args) {
|
|
17
17
|
const hash = workflow.hashRecord?.['options'];
|
|
18
|
-
const optionsHash = (0, shared_1.generateObjectFingerprint)(
|
|
18
|
+
const optionsHash = (0, shared_1.generateObjectFingerprint)(args);
|
|
19
19
|
this.logger.debug(`Check valid: "${(hash === optionsHash).toString()}".`);
|
|
20
20
|
if (hash !== optionsHash) {
|
|
21
21
|
return { valid: false, target: 'options', hash: optionsHash };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-option.validator.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/validators/workflow-option.validator.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,8CAI2B;AAKpB,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IACjB,MAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;IAEnE,QAAQ,CACN,QAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"workflow-option.validator.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/validators/workflow-option.validator.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,8CAI2B;AAKpB,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IACjB,MAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;IAEnE,QAAQ,CACN,QAAwB,EACxB,IAAqC;QAErC,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,CAAC;YAC9C,MAAM,WAAW,GAAG,IAAA,kCAAyB,EAAC,IAAI,CAAC,CAAC;YAEpD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAE1E,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;gBACzB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;YAChE,CAAC;QACH,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;CACF,CAAA;AApBY,0DAAuB;kCAAvB,uBAAuB;IAFnC,IAAA,mBAAU,GAAE;IACZ,IAAA,8BAAqB,EAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;GAC5B,uBAAuB,CAoBnC"}
|
|
@@ -31,7 +31,6 @@ exports.WorkflowProcessorModule = WorkflowProcessorModule = __decorate([
|
|
|
31
31
|
services_1.WorkflowStateService,
|
|
32
32
|
services_1.WorkflowProcessorService,
|
|
33
33
|
services_1.ToolExecutionService,
|
|
34
|
-
services_1.ToolSchemaValidatorService,
|
|
35
34
|
tool_services_1.CreateDocumentService,
|
|
36
35
|
tool_services_1.BatchCreateDocumentsService,
|
|
37
36
|
tool_services_1.MockService,
|
|
@@ -44,6 +43,8 @@ exports.WorkflowProcessorModule = WorkflowProcessorModule = __decorate([
|
|
|
44
43
|
tool_services_1.UpdateDocumentService,
|
|
45
44
|
services_1.TemplateExpressionEvaluatorService,
|
|
46
45
|
tool_services_1.SetTargetPlaceService,
|
|
46
|
+
services_1.WorkflowContextService,
|
|
47
|
+
services_1.ServiceExecutionService,
|
|
47
48
|
validators_1.InitialRunValidator,
|
|
48
49
|
validators_1.WorkflowDependenciesValidator,
|
|
49
50
|
validators_1.WorkflowOptionValidator,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-processor.module.js","sourceRoot":"","sources":["../../../src/modules/workflow-processor/workflow-processor.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,oDAAuD;AACvD,gDAAmD;AACnD,uCAA+C;AAC/C,sCAAyC;AACzC,6CAIsB;AACtB,
|
|
1
|
+
{"version":3,"file":"workflow-processor.module.js","sourceRoot":"","sources":["../../../src/modules/workflow-processor/workflow-processor.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,oDAAuD;AACvD,gDAAmD;AACnD,uCAA+C;AAC/C,sCAAyC;AACzC,6CAIsB;AACtB,yCAaoB;AACpB,mDAUyB;AA2ClB,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;CAAG,CAAA;AAA1B,0DAAuB;kCAAvB,uBAAuB;IAzCnC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,sBAAe;YACf,qBAAY;YACZ,mCAAmB;YACnB,+BAAiB;SAClB;QACD,SAAS,EAAE;YACT,+BAAoB;YACpB,+BAAoB;YACpB,mCAAwB;YACxB,+BAAoB;YACpB,qCAAqB;YACrB,2CAA2B;YAC3B,2BAAW;YACX,iCAAiB;YACjB,mCAAmB;YACnB,mCAAmB;YACnB,yCAAyB;YACzB,oCAAyB;YACzB,mCAAwB;YACxB,qCAAqB;YACrB,6CAAkC;YAClC,qCAAqB;YACrB,iCAAsB;YACtB,kCAAuB;YAEvB,gCAAmB;YACnB,0CAA6B;YAC7B,oCAAuB;YAEvB,wCAA6B;YAC7B,uCAA4B;YAC5B,oCAAyB;SAC1B;QACD,OAAO,EAAE;YACP,+BAAoB;YACpB,+BAAoB;YACpB,6CAAkC;SACnC;KACF,CAAC;GACW,uBAAuB,CAAG"}
|
|
@@ -43,27 +43,29 @@ const yaml = __importStar(require("js-yaml"));
|
|
|
43
43
|
function loadConfiguration(path) {
|
|
44
44
|
const configs = [];
|
|
45
45
|
try {
|
|
46
|
-
loadConfigsRecursively(path, configs);
|
|
46
|
+
loadConfigsRecursively(path, path, configs);
|
|
47
47
|
}
|
|
48
48
|
catch (error) {
|
|
49
49
|
console.error(`Error loading config files from ${path}:`, error);
|
|
50
50
|
}
|
|
51
51
|
return configs;
|
|
52
52
|
}
|
|
53
|
-
function loadConfigsRecursively(currentPath, configs) {
|
|
53
|
+
function loadConfigsRecursively(rootPath, currentPath, configs) {
|
|
54
54
|
const items = fs_1.default.readdirSync(currentPath);
|
|
55
55
|
items.forEach((item) => {
|
|
56
56
|
const itemPath = path_1.default.join(currentPath, item);
|
|
57
57
|
const stats = fs_1.default.statSync(itemPath);
|
|
58
58
|
if (stats.isFile() && item.endsWith('.yaml')) {
|
|
59
59
|
const config = yaml.load(fs_1.default.readFileSync(itemPath, 'utf8'));
|
|
60
|
+
const relativePath = path_1.default.relative(rootPath, itemPath);
|
|
60
61
|
configs.push({
|
|
61
62
|
path: itemPath,
|
|
63
|
+
relativePath,
|
|
62
64
|
config,
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
else if (stats.isDirectory()) {
|
|
66
|
-
loadConfigsRecursively(itemPath, configs);
|
|
68
|
+
loadConfigsRecursively(rootPath, itemPath, configs);
|
|
67
69
|
}
|
|
68
70
|
});
|
|
69
71
|
}
|