@loopstack/core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/modules/common/common.module.js +9 -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/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/index.d.ts +1 -0
- package/dist/modules/common/services/handlebars-helpers/index.js +18 -0
- package/dist/modules/common/services/handlebars-helpers/index.js.map +1 -0
- package/dist/modules/common/services/handlebars-processor.service.d.ts +12 -0
- package/dist/modules/common/services/handlebars-processor.service.js +70 -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 +6 -10
- 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 +25 -50
- 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 +1 -1
- 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
|
@@ -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,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;YAClC,KAAK,E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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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-configuration.js","sourceRoot":"","sources":["../../src/utils/load-configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,8CAUC;AAfD,gDAAwB;AACxB,4CAAoB;AACpB,8CAAgC;AAGhC,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,MAAM,OAAO,GAA4B,EAAE,CAAC;IAE5C,IAAI,CAAC;QACH,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"load-configuration.js","sourceRoot":"","sources":["../../src/utils/load-configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,8CAUC;AAfD,gDAAwB;AACxB,4CAAoB;AACpB,8CAAgC;AAGhC,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,MAAM,OAAO,GAA4B,EAAE,CAAC;IAE5C,IAAI,CAAC;QACH,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,mCAAmC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,sBAAsB,CAC7B,QAAgB,EAChB,WAAmB,EACnB,OAAgC;IAEhC,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAE1C,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAG,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEpC,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CACtB,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAChB,CAAC;YAEpB,MAAM,YAAY,GAAG,cAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACvD,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,QAAQ;gBACd,YAAY;gBACZ,MAAM;aACP,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YAC/B,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@loopstack/core",
|
|
3
3
|
"displayName": "Loopstack Core Module",
|
|
4
4
|
"description": "The core module of the loopstack automation framework",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.3.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Jakob Klippel",
|
|
8
8
|
"url": "https://www.linkedin.com/in/jakob-klippel//"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@loopstack/shared": "^0.
|
|
14
|
+
"@loopstack/shared": "^0.3.0",
|
|
15
15
|
"@nestjs/common": "^11.0.1",
|
|
16
16
|
"@nestjs/config": "^4.0.0",
|
|
17
17
|
"@nestjs/core": "^11.0.1",
|
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
"ajv": "^8.17.1",
|
|
22
22
|
"class-transformer": "^0.5.1",
|
|
23
23
|
"class-validator": "^0.14.1",
|
|
24
|
-
"
|
|
24
|
+
"date-fns": "^4.1.0",
|
|
25
|
+
"handlebars": "^4.7.8",
|
|
25
26
|
"js-yaml": "^4.1.0",
|
|
27
|
+
"json-schema-to-zod": "^2.6.1",
|
|
26
28
|
"lodash": "^4.17.21",
|
|
27
29
|
"nest-commander": "^3.16.1",
|
|
28
30
|
"openai": "^4.86.2",
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { DocumentType } from '@loopstack/shared';
|
|
3
|
-
import { ValueParserService } from './value-parser.service';
|
|
4
|
-
export declare const CreateDocumentWithSchema: z.ZodObject<{
|
|
5
|
-
update: z.ZodOptional<z.ZodObject<{
|
|
6
|
-
name: z.ZodOptional<z.ZodString>;
|
|
7
|
-
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
8
|
-
content: z.ZodOptional<z.ZodAny>;
|
|
9
|
-
schema: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
|
|
10
|
-
ui: z.ZodOptional<z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>>;
|
|
11
|
-
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
12
|
-
meta: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
13
|
-
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"]>>;
|
|
14
|
-
invalidate: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
-
level: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"debug">, z.ZodLiteral<"info">, z.ZodLiteral<"warning">, z.ZodLiteral<"error">]>>;
|
|
16
|
-
enableAtPlaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
17
|
-
hideAtPlaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
18
|
-
data: z.ZodOptional<z.ZodAny>;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
invalidate?: boolean | undefined;
|
|
21
|
-
data?: any;
|
|
22
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
23
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
24
|
-
enableAtPlaces?: string[] | undefined;
|
|
25
|
-
hideAtPlaces?: string[] | undefined;
|
|
26
|
-
}, {
|
|
27
|
-
invalidate?: boolean | undefined;
|
|
28
|
-
data?: any;
|
|
29
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
30
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
31
|
-
enableAtPlaces?: string[] | undefined;
|
|
32
|
-
hideAtPlaces?: string[] | undefined;
|
|
33
|
-
}>>>;
|
|
34
|
-
}, "strip", z.ZodTypeAny, {
|
|
35
|
-
name?: string | undefined;
|
|
36
|
-
schema?: any;
|
|
37
|
-
content?: any;
|
|
38
|
-
ui?: any;
|
|
39
|
-
tags?: string[] | undefined;
|
|
40
|
-
meta?: {
|
|
41
|
-
invalidate?: boolean | undefined;
|
|
42
|
-
data?: any;
|
|
43
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
44
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
45
|
-
enableAtPlaces?: string[] | undefined;
|
|
46
|
-
hideAtPlaces?: string[] | undefined;
|
|
47
|
-
} | undefined;
|
|
48
|
-
description?: string | undefined;
|
|
49
|
-
}, {
|
|
50
|
-
name?: string | undefined;
|
|
51
|
-
schema?: any;
|
|
52
|
-
content?: any;
|
|
53
|
-
ui?: any;
|
|
54
|
-
tags?: string[] | undefined;
|
|
55
|
-
meta?: {
|
|
56
|
-
invalidate?: boolean | undefined;
|
|
57
|
-
data?: any;
|
|
58
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
59
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
60
|
-
enableAtPlaces?: string[] | undefined;
|
|
61
|
-
hideAtPlaces?: string[] | undefined;
|
|
62
|
-
} | undefined;
|
|
63
|
-
description?: string | undefined;
|
|
64
|
-
}>>;
|
|
65
|
-
create: z.ZodOptional<z.ZodObject<{
|
|
66
|
-
name: z.ZodString;
|
|
67
|
-
description: z.ZodOptional<z.ZodString>;
|
|
68
|
-
content: z.ZodAny;
|
|
69
|
-
schema: z.ZodType<any, z.ZodTypeDef, any>;
|
|
70
|
-
ui: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
|
|
71
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
72
|
-
meta: z.ZodOptional<z.ZodObject<{
|
|
73
|
-
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"]>>;
|
|
74
|
-
invalidate: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
-
level: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"debug">, z.ZodLiteral<"info">, z.ZodLiteral<"warning">, z.ZodLiteral<"error">]>>;
|
|
76
|
-
enableAtPlaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
77
|
-
hideAtPlaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
78
|
-
data: z.ZodOptional<z.ZodAny>;
|
|
79
|
-
}, "strip", z.ZodTypeAny, {
|
|
80
|
-
invalidate?: boolean | undefined;
|
|
81
|
-
data?: any;
|
|
82
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
83
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
84
|
-
enableAtPlaces?: string[] | undefined;
|
|
85
|
-
hideAtPlaces?: string[] | undefined;
|
|
86
|
-
}, {
|
|
87
|
-
invalidate?: boolean | undefined;
|
|
88
|
-
data?: any;
|
|
89
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
90
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
91
|
-
enableAtPlaces?: string[] | undefined;
|
|
92
|
-
hideAtPlaces?: string[] | undefined;
|
|
93
|
-
}>>;
|
|
94
|
-
}, "strip", z.ZodTypeAny, {
|
|
95
|
-
name: string;
|
|
96
|
-
schema?: any;
|
|
97
|
-
content?: any;
|
|
98
|
-
ui?: any;
|
|
99
|
-
tags?: string[] | undefined;
|
|
100
|
-
meta?: {
|
|
101
|
-
invalidate?: boolean | undefined;
|
|
102
|
-
data?: any;
|
|
103
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
104
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
105
|
-
enableAtPlaces?: string[] | undefined;
|
|
106
|
-
hideAtPlaces?: string[] | undefined;
|
|
107
|
-
} | undefined;
|
|
108
|
-
description?: string | undefined;
|
|
109
|
-
}, {
|
|
110
|
-
name: string;
|
|
111
|
-
schema?: any;
|
|
112
|
-
content?: any;
|
|
113
|
-
ui?: any;
|
|
114
|
-
tags?: string[] | undefined;
|
|
115
|
-
meta?: {
|
|
116
|
-
invalidate?: boolean | undefined;
|
|
117
|
-
data?: any;
|
|
118
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
119
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
120
|
-
enableAtPlaces?: string[] | undefined;
|
|
121
|
-
hideAtPlaces?: string[] | undefined;
|
|
122
|
-
} | undefined;
|
|
123
|
-
description?: string | undefined;
|
|
124
|
-
}>>;
|
|
125
|
-
}, "strip", z.ZodTypeAny, {
|
|
126
|
-
update?: {
|
|
127
|
-
name?: string | undefined;
|
|
128
|
-
schema?: any;
|
|
129
|
-
content?: any;
|
|
130
|
-
ui?: any;
|
|
131
|
-
tags?: string[] | undefined;
|
|
132
|
-
meta?: {
|
|
133
|
-
invalidate?: boolean | undefined;
|
|
134
|
-
data?: any;
|
|
135
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
136
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
137
|
-
enableAtPlaces?: string[] | undefined;
|
|
138
|
-
hideAtPlaces?: string[] | undefined;
|
|
139
|
-
} | undefined;
|
|
140
|
-
description?: string | undefined;
|
|
141
|
-
} | undefined;
|
|
142
|
-
create?: {
|
|
143
|
-
name: string;
|
|
144
|
-
schema?: any;
|
|
145
|
-
content?: any;
|
|
146
|
-
ui?: any;
|
|
147
|
-
tags?: string[] | undefined;
|
|
148
|
-
meta?: {
|
|
149
|
-
invalidate?: boolean | undefined;
|
|
150
|
-
data?: any;
|
|
151
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
152
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
153
|
-
enableAtPlaces?: string[] | undefined;
|
|
154
|
-
hideAtPlaces?: string[] | undefined;
|
|
155
|
-
} | undefined;
|
|
156
|
-
description?: string | undefined;
|
|
157
|
-
} | undefined;
|
|
158
|
-
}, {
|
|
159
|
-
update?: {
|
|
160
|
-
name?: string | undefined;
|
|
161
|
-
schema?: any;
|
|
162
|
-
content?: any;
|
|
163
|
-
ui?: any;
|
|
164
|
-
tags?: string[] | undefined;
|
|
165
|
-
meta?: {
|
|
166
|
-
invalidate?: boolean | undefined;
|
|
167
|
-
data?: any;
|
|
168
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
169
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
170
|
-
enableAtPlaces?: string[] | undefined;
|
|
171
|
-
hideAtPlaces?: string[] | undefined;
|
|
172
|
-
} | undefined;
|
|
173
|
-
description?: string | undefined;
|
|
174
|
-
} | undefined;
|
|
175
|
-
create?: {
|
|
176
|
-
name: string;
|
|
177
|
-
schema?: any;
|
|
178
|
-
content?: any;
|
|
179
|
-
ui?: any;
|
|
180
|
-
tags?: string[] | undefined;
|
|
181
|
-
meta?: {
|
|
182
|
-
invalidate?: boolean | undefined;
|
|
183
|
-
data?: any;
|
|
184
|
-
mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
|
|
185
|
-
level?: "info" | "error" | "debug" | "warning" | undefined;
|
|
186
|
-
enableAtPlaces?: string[] | undefined;
|
|
187
|
-
hideAtPlaces?: string[] | undefined;
|
|
188
|
-
} | undefined;
|
|
189
|
-
description?: string | undefined;
|
|
190
|
-
} | undefined;
|
|
191
|
-
}>;
|
|
192
|
-
export declare class DocumentHelperService {
|
|
193
|
-
private valueParserService;
|
|
194
|
-
constructor(valueParserService: ValueParserService);
|
|
195
|
-
prepare(options: z.infer<typeof CreateDocumentWithSchema>, template: any): any;
|
|
196
|
-
prepareAliasVariables(aliasReference: Record<string, any>, dataSource: Record<string, any>): Record<string, any>;
|
|
197
|
-
createDocumentWithSchema(options: z.infer<typeof CreateDocumentWithSchema>, template: any, context: any): DocumentType;
|
|
198
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
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.DocumentHelperService = exports.CreateDocumentWithSchema = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const zod_1 = require("zod");
|
|
15
|
-
const shared_1 = require("@loopstack/shared");
|
|
16
|
-
const lodash_1 = require("lodash");
|
|
17
|
-
const value_parser_service_1 = require("./value-parser.service");
|
|
18
|
-
exports.CreateDocumentWithSchema = zod_1.z.object({
|
|
19
|
-
update: shared_1.PartialDocumentSchema?.optional(),
|
|
20
|
-
create: shared_1.DocumentSchema?.optional(),
|
|
21
|
-
});
|
|
22
|
-
let DocumentHelperService = class DocumentHelperService {
|
|
23
|
-
valueParserService;
|
|
24
|
-
constructor(valueParserService) {
|
|
25
|
-
this.valueParserService = valueParserService;
|
|
26
|
-
}
|
|
27
|
-
prepare(options, template) {
|
|
28
|
-
if (options.create) {
|
|
29
|
-
return options.create;
|
|
30
|
-
}
|
|
31
|
-
if (template) {
|
|
32
|
-
if (options.update) {
|
|
33
|
-
return (0, lodash_1.merge)({}, template, options.update);
|
|
34
|
-
}
|
|
35
|
-
return template;
|
|
36
|
-
}
|
|
37
|
-
throw new Error(`Create document requires template or create property to be defined.`);
|
|
38
|
-
}
|
|
39
|
-
prepareAliasVariables(aliasReference, dataSource) {
|
|
40
|
-
return this.valueParserService.prepareAliasVariables(aliasReference, dataSource);
|
|
41
|
-
}
|
|
42
|
-
createDocumentWithSchema(options, template, context) {
|
|
43
|
-
const prototype = this.prepare(options, template);
|
|
44
|
-
const document = this.valueParserService.evalObjectLeafs(prototype, context);
|
|
45
|
-
return document;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
exports.DocumentHelperService = DocumentHelperService;
|
|
49
|
-
exports.DocumentHelperService = DocumentHelperService = __decorate([
|
|
50
|
-
(0, common_1.Injectable)(),
|
|
51
|
-
__metadata("design:paramtypes", [value_parser_service_1.ValueParserService])
|
|
52
|
-
], DocumentHelperService);
|
|
53
|
-
//# sourceMappingURL=document-helper.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document-helper.service.js","sourceRoot":"","sources":["../../../../src/modules/common/services/document-helper.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6BAAwB;AACxB,8CAI2B;AAC3B,mCAA+B;AAC/B,iEAA4D;AAE/C,QAAA,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/C,MAAM,EAAE,8BAAqB,EAAE,QAAQ,EAAE;IACzC,MAAM,EAAE,uBAAc,EAAE,QAAQ,EAAE;CACnC,CAAC,CAAC;AAGI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACZ;IAApB,YAAoB,kBAAsC;QAAtC,uBAAkB,GAAlB,kBAAkB,CAAoB;IAAG,CAAC;IAE9D,OAAO,CAAC,OAAiD,EAAE,QAAa;QACtE,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,OAAO,CAAC,MAAM,CAAC;QACxB,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnB,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAC7C,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IAED,qBAAqB,CACnB,cAAmC,EACnC,UAA+B;QAE/B,OAAO,IAAI,CAAC,kBAAkB,CAAC,qBAAqB,CAClD,cAAc,EACd,UAAU,CACX,CAAC;IACJ,CAAC;IAED,wBAAwB,CACtB,OAAiD,EACjD,QAAa,EACb,OAAY;QAEZ,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,eAAe,CACtD,SAAS,EACT,OAAO,CACR,CAAC;QACF,OAAO,QAAwB,CAAC;IAClC,CAAC;CACF,CAAA;AA1CY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAE6B,yCAAkB;GAD/C,qBAAqB,CA0CjC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ExpressionEvaluatorService = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const ejs_1 = __importDefault(require("ejs"));
|
|
15
|
-
let ExpressionEvaluatorService = class ExpressionEvaluatorService {
|
|
16
|
-
isExpression(input) {
|
|
17
|
-
if (typeof input !== 'string') {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
const trimmed = input.trim();
|
|
21
|
-
return trimmed.startsWith('${') && trimmed.endsWith('}');
|
|
22
|
-
}
|
|
23
|
-
extractGetContents(input) {
|
|
24
|
-
return input.trim().replace(/^\${/, '').replace(/}$/, '').trim();
|
|
25
|
-
}
|
|
26
|
-
evaluate(value, variables) {
|
|
27
|
-
if (!this.isExpression(value)) {
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
const content = this.extractGetContents(value);
|
|
31
|
-
const stringify = (value) => undefined === value ? 'undefined' : JSON.stringify(value);
|
|
32
|
-
const processString = `<%- stringify(${content}) %>`;
|
|
33
|
-
let result = ejs_1.default.render(processString, {
|
|
34
|
-
...variables,
|
|
35
|
-
stringify,
|
|
36
|
-
});
|
|
37
|
-
return 'undefined' === result ? undefined : JSON.parse(result);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
exports.ExpressionEvaluatorService = ExpressionEvaluatorService;
|
|
41
|
-
exports.ExpressionEvaluatorService = ExpressionEvaluatorService = __decorate([
|
|
42
|
-
(0, common_1.Injectable)()
|
|
43
|
-
], ExpressionEvaluatorService);
|
|
44
|
-
//# sourceMappingURL=expression-evaluator.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expression-evaluator.service.js","sourceRoot":"","sources":["../../../../src/modules/common/services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AAA;AAhCY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;GACA,0BAA0B,CAgCtC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { JSONSchemaType } from 'ajv';
|
|
2
|
-
import { DocumentEntity } from '@loopstack/shared';
|
|
3
|
-
export declare class SchemaValidatorService {
|
|
4
|
-
private readonly logger;
|
|
5
|
-
validate(data: any, schema: JSONSchemaType<any>): void;
|
|
6
|
-
validateDocument(data: Partial<DocumentEntity>): void;
|
|
7
|
-
}
|