@loopstack/core 0.0.5 → 0.1.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.
Files changed (153) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/config/core.yaml +1 -0
  3. package/dist/modules/common/services/context.service.d.ts +2 -2
  4. package/dist/modules/common/services/context.service.js +7 -7
  5. package/dist/modules/common/services/context.service.js.map +1 -1
  6. package/dist/modules/common/services/document-helper.service.d.ts +56 -32
  7. package/dist/modules/common/services/schema-validator.service.d.ts +2 -0
  8. package/dist/modules/common/services/schema-validator.service.js +14 -11
  9. package/dist/modules/common/services/schema-validator.service.js.map +1 -1
  10. package/dist/modules/common/services/value-parser.service.d.ts +2 -6
  11. package/dist/modules/common/services/value-parser.service.js +0 -3
  12. package/dist/modules/common/services/value-parser.service.js.map +1 -1
  13. package/dist/modules/configuration/commands/generate-schema.command.d.ts +8 -0
  14. package/dist/modules/configuration/commands/generate-schema.command.js +34 -0
  15. package/dist/modules/configuration/commands/generate-schema.command.js.map +1 -0
  16. package/dist/modules/configuration/commands/generate-schemas.command.js +1 -1
  17. package/dist/modules/configuration/commands/generate-schemas.command.js.map +1 -1
  18. package/dist/modules/configuration/configuration.module.js +4 -5
  19. package/dist/modules/configuration/configuration.module.js.map +1 -1
  20. package/dist/modules/configuration/services/configuration.service.d.ts +5 -7
  21. package/dist/modules/configuration/services/configuration.service.js +38 -44
  22. package/dist/modules/configuration/services/configuration.service.js.map +1 -1
  23. package/dist/modules/configuration/services/dynamic-schema-generator.service.d.ts +8 -8
  24. package/dist/modules/configuration/services/dynamic-schema-generator.service.js +15 -18
  25. package/dist/modules/configuration/services/dynamic-schema-generator.service.js.map +1 -1
  26. package/dist/modules/configuration/services/index.d.ts +1 -2
  27. package/dist/modules/configuration/services/index.js +1 -2
  28. package/dist/modules/configuration/services/index.js.map +1 -1
  29. package/dist/modules/configuration/services/service-registry.service.d.ts +20 -0
  30. package/dist/modules/configuration/services/{adapter-registry.service.js → service-registry.service.js} +31 -16
  31. package/dist/modules/configuration/services/service-registry.service.js.map +1 -0
  32. package/dist/modules/persistence/__tests__/database-entities-utils.d.ts +2 -2
  33. package/dist/modules/persistence/__tests__/database-entities-utils.js +5 -5
  34. package/dist/modules/persistence/__tests__/database-entities-utils.js.map +1 -1
  35. package/dist/modules/persistence/persistence.module.js +3 -3
  36. package/dist/modules/persistence/persistence.module.js.map +1 -1
  37. package/dist/modules/persistence/services/document.service.d.ts +3 -3
  38. package/dist/modules/persistence/services/document.service.js +6 -6
  39. package/dist/modules/persistence/services/document.service.js.map +1 -1
  40. package/dist/modules/persistence/services/index.d.ts +1 -1
  41. package/dist/modules/persistence/services/index.js +1 -1
  42. package/dist/modules/persistence/services/index.js.map +1 -1
  43. package/dist/modules/persistence/services/namespace.service.d.ts +2 -2
  44. package/dist/modules/persistence/services/namespace.service.js +9 -9
  45. package/dist/modules/persistence/services/namespace.service.js.map +1 -1
  46. package/dist/modules/persistence/services/pipeline.service.d.ts +8 -0
  47. package/dist/modules/persistence/services/{project.service.js → pipeline.service.js} +13 -13
  48. package/dist/modules/persistence/services/pipeline.service.js.map +1 -0
  49. package/dist/modules/persistence/services/workflow.service.d.ts +1 -0
  50. package/dist/modules/persistence/services/workflow.service.js +8 -1
  51. package/dist/modules/persistence/services/workflow.service.js.map +1 -1
  52. package/dist/modules/persistence/subscriber/workflow.subscriber.js +2 -2
  53. package/dist/modules/persistence/subscriber/workflow.subscriber.js.map +1 -1
  54. package/dist/modules/workflow-processor/services/index.d.ts +2 -1
  55. package/dist/modules/workflow-processor/services/index.js +2 -1
  56. package/dist/modules/workflow-processor/services/index.js.map +1 -1
  57. package/dist/modules/workflow-processor/services/namespace-processor.service.js +1 -1
  58. package/dist/modules/workflow-processor/services/namespace-processor.service.js.map +1 -1
  59. package/dist/modules/workflow-processor/services/pipeline-processor.service.d.ts +15 -0
  60. package/dist/modules/workflow-processor/services/{project-processor.service.js → pipeline-processor.service.js} +24 -24
  61. package/dist/modules/workflow-processor/services/pipeline-processor.service.js.map +1 -0
  62. package/dist/modules/workflow-processor/services/state-machine-config.service.d.ts +8 -7
  63. package/dist/modules/workflow-processor/services/state-machine-config.service.js +0 -4
  64. package/dist/modules/workflow-processor/services/state-machine-config.service.js.map +1 -1
  65. package/dist/modules/workflow-processor/services/state-machine-processor.service.d.ts +3 -1
  66. package/dist/modules/workflow-processor/services/state-machine-processor.service.js +50 -40
  67. package/dist/modules/workflow-processor/services/state-machine-processor.service.js.map +1 -1
  68. package/dist/modules/workflow-processor/services/template-expression-evaluator.service.d.ts +9 -0
  69. package/dist/modules/workflow-processor/services/template-expression-evaluator.service.js +50 -0
  70. package/dist/modules/workflow-processor/services/template-expression-evaluator.service.js.map +1 -0
  71. package/dist/modules/workflow-processor/services/tool-execution.service.d.ts +19 -12
  72. package/dist/modules/workflow-processor/services/tool-execution.service.js +39 -44
  73. package/dist/modules/workflow-processor/services/tool-execution.service.js.map +1 -1
  74. package/dist/modules/workflow-processor/services/tool-schema-validator.service.d.ts +2 -2
  75. package/dist/modules/workflow-processor/services/tool-schema-validator.service.js +3 -3
  76. package/dist/modules/workflow-processor/services/tool-schema-validator.service.js.map +1 -1
  77. package/dist/modules/workflow-processor/services/workflow-processor.service.js +10 -4
  78. package/dist/modules/workflow-processor/services/workflow-processor.service.js.map +1 -1
  79. package/dist/modules/workflow-processor/tool-services/add-namespace.service.d.ts +20 -0
  80. package/dist/modules/workflow-processor/{tools → tool-services}/add-namespace.service.js +16 -13
  81. package/dist/modules/workflow-processor/tool-services/add-namespace.service.js.map +1 -0
  82. package/dist/modules/workflow-processor/tool-services/batch-create-documents.service.d.ts +33 -0
  83. package/dist/modules/workflow-processor/{tools → tool-services}/batch-create-documents.service.js +39 -42
  84. package/dist/modules/workflow-processor/tool-services/batch-create-documents.service.js.map +1 -0
  85. package/dist/modules/workflow-processor/tool-services/create-document.service.d.ts +223 -0
  86. package/dist/modules/workflow-processor/{tools → tool-services}/create-document.service.js +35 -41
  87. package/dist/modules/workflow-processor/tool-services/create-document.service.js.map +1 -0
  88. package/dist/modules/workflow-processor/{tools → tool-services}/index.d.ts +2 -2
  89. package/dist/modules/workflow-processor/{tools → tool-services}/index.js +2 -2
  90. package/dist/modules/workflow-processor/tool-services/index.js.map +1 -0
  91. package/dist/modules/workflow-processor/tool-services/load-document.service.d.ts +68 -0
  92. package/dist/modules/workflow-processor/{tools → tool-services}/load-document.service.js +14 -12
  93. package/dist/modules/workflow-processor/tool-services/load-document.service.js.map +1 -0
  94. package/dist/modules/workflow-processor/tool-services/mock.service.d.ts +20 -0
  95. package/dist/modules/workflow-processor/tool-services/mock.service.js +51 -0
  96. package/dist/modules/workflow-processor/tool-services/mock.service.js.map +1 -0
  97. package/dist/modules/workflow-processor/tool-services/set-context.service.d.ts +18 -0
  98. package/dist/modules/workflow-processor/{tools → tool-services}/set-context.service.js +20 -17
  99. package/dist/modules/workflow-processor/tool-services/set-context.service.js.map +1 -0
  100. package/dist/modules/workflow-processor/tool-services/set-target-place.service.d.ts +14 -0
  101. package/dist/modules/workflow-processor/tool-services/set-target-place.service.js +48 -0
  102. package/dist/modules/workflow-processor/tool-services/set-target-place.service.js.map +1 -0
  103. package/dist/modules/workflow-processor/tool-services/transition-selector.service.d.ts +29 -0
  104. package/dist/modules/workflow-processor/{tools → tool-services}/transition-selector.service.js +22 -19
  105. package/dist/modules/workflow-processor/tool-services/transition-selector.service.js.map +1 -0
  106. package/dist/modules/workflow-processor/tool-services/update-document.service.d.ts +117 -0
  107. package/dist/modules/workflow-processor/{tools → tool-services}/update-document.service.js +22 -19
  108. package/dist/modules/workflow-processor/tool-services/update-document.service.js.map +1 -0
  109. package/dist/modules/workflow-processor/workflow-processor.module.js +13 -12
  110. package/dist/modules/workflow-processor/workflow-processor.module.js.map +1 -1
  111. package/package.json +2 -2
  112. package/dist/config/documents/assistant-message.yaml +0 -13
  113. package/dist/config/documents/info-message.yaml +0 -9
  114. package/dist/config/documents/internal-message.yaml +0 -14
  115. package/dist/config/documents/loading-message.yaml +0 -10
  116. package/dist/config/documents/user-message.yaml +0 -13
  117. package/dist/config/templates/user-input-template.yaml +0 -29
  118. package/dist/config/tools/creat-error-message.yaml +0 -9
  119. package/dist/config/tools/create-assistant-message.yaml +0 -9
  120. package/dist/config/tools/create-chat-message.tool.yaml +0 -7
  121. package/dist/config/tools/create-template-document-user-update.yaml +0 -7
  122. package/dist/config/tools/create-template-document.yaml +0 -5
  123. package/dist/config/tools/create-user-message.tool.yaml +0 -9
  124. package/dist/modules/configuration/services/adapter-registry.service.d.ts +0 -12
  125. package/dist/modules/configuration/services/adapter-registry.service.js.map +0 -1
  126. package/dist/modules/configuration/services/tool.registry.d.ts +0 -13
  127. package/dist/modules/configuration/services/tool.registry.js +0 -59
  128. package/dist/modules/configuration/services/tool.registry.js.map +0 -1
  129. package/dist/modules/persistence/services/project.service.d.ts +0 -8
  130. package/dist/modules/persistence/services/project.service.js.map +0 -1
  131. package/dist/modules/workflow-processor/services/project-processor.service.d.ts +0 -15
  132. package/dist/modules/workflow-processor/services/project-processor.service.js.map +0 -1
  133. package/dist/modules/workflow-processor/tools/add-namespace.service.d.ts +0 -29
  134. package/dist/modules/workflow-processor/tools/add-namespace.service.js.map +0 -1
  135. package/dist/modules/workflow-processor/tools/batch-create-documents.service.d.ts +0 -42
  136. package/dist/modules/workflow-processor/tools/batch-create-documents.service.js.map +0 -1
  137. package/dist/modules/workflow-processor/tools/create-document.service.d.ts +0 -378
  138. package/dist/modules/workflow-processor/tools/create-document.service.js.map +0 -1
  139. package/dist/modules/workflow-processor/tools/debug.service.d.ts +0 -20
  140. package/dist/modules/workflow-processor/tools/debug.service.js +0 -37
  141. package/dist/modules/workflow-processor/tools/debug.service.js.map +0 -1
  142. package/dist/modules/workflow-processor/tools/index.js.map +0 -1
  143. package/dist/modules/workflow-processor/tools/load-document.service.d.ts +0 -242
  144. package/dist/modules/workflow-processor/tools/load-document.service.js.map +0 -1
  145. package/dist/modules/workflow-processor/tools/set-context.service.d.ts +0 -27
  146. package/dist/modules/workflow-processor/tools/set-context.service.js.map +0 -1
  147. package/dist/modules/workflow-processor/tools/tool-call.service.d.ts +0 -29
  148. package/dist/modules/workflow-processor/tools/tool-call.service.js +0 -55
  149. package/dist/modules/workflow-processor/tools/tool-call.service.js.map +0 -1
  150. package/dist/modules/workflow-processor/tools/transition-selector.service.d.ts +0 -50
  151. package/dist/modules/workflow-processor/tools/transition-selector.service.js.map +0 -1
  152. package/dist/modules/workflow-processor/tools/update-document.service.d.ts +0 -198
  153. package/dist/modules/workflow-processor/tools/update-document.service.js.map +0 -1
@@ -15,30 +15,29 @@ const common_1 = require("@nestjs/common");
15
15
  const zod_1 = require("zod");
16
16
  const shared_1 = require("@loopstack/shared");
17
17
  const persistence_1 = require("../../persistence");
18
+ const config = zod_1.z
19
+ .object({
20
+ label: zod_1.z.union([zod_1.z.string(), shared_1.ExpressionString]),
21
+ meta: zod_1.z.any().optional(),
22
+ })
23
+ .strict();
24
+ const schema = shared_1.NamespacePropsSchema.strict();
18
25
  let AddNamespaceService = AddNamespaceService_1 = class AddNamespaceService {
19
26
  namespacesService;
20
27
  logger = new common_1.Logger(AddNamespaceService_1.name);
21
- configSchema = zod_1.z
22
- .object({
23
- label: zod_1.z.union([zod_1.z.string(), shared_1.ExpressionString]),
24
- meta: zod_1.z.any().optional(),
25
- })
26
- .strict();
27
- schema = shared_1.NamespacePropsSchema.strict();
28
28
  constructor(namespacesService) {
29
29
  this.namespacesService = namespacesService;
30
30
  }
31
31
  async apply(props, workflow, context) {
32
32
  if (!workflow) {
33
- return {};
33
+ throw new Error('Workflow is undefined');
34
34
  }
35
- const validOptions = this.schema.parse(props);
36
35
  const namespace = await this.namespacesService.create({
37
- name: validOptions.label,
36
+ name: props.label,
38
37
  model: context.model,
39
- projectId: context.projectId,
38
+ pipelineId: context.pipelineId,
40
39
  workspaceId: context.workspaceId,
41
- metadata: validOptions.meta,
40
+ metadata: props.meta,
42
41
  createdBy: context.userId,
43
42
  parent: context.namespace,
44
43
  });
@@ -54,6 +53,7 @@ let AddNamespaceService = AddNamespaceService_1 = class AddNamespaceService {
54
53
  ];
55
54
  this.logger.debug(`Add namespace label "${namespace.name}".`);
56
55
  return {
56
+ success: true,
57
57
  workflow,
58
58
  };
59
59
  }
@@ -61,7 +61,10 @@ let AddNamespaceService = AddNamespaceService_1 = class AddNamespaceService {
61
61
  exports.AddNamespaceService = AddNamespaceService;
62
62
  exports.AddNamespaceService = AddNamespaceService = AddNamespaceService_1 = __decorate([
63
63
  (0, common_1.Injectable)(),
64
- (0, shared_1.Tool)(),
64
+ (0, shared_1.Service)({
65
+ config,
66
+ schema,
67
+ }),
65
68
  __metadata("design:paramtypes", [persistence_1.NamespacesService])
66
69
  ], AddNamespaceService);
67
70
  //# sourceMappingURL=add-namespace.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-namespace.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/add-namespace.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6BAAwB;AACxB,8CAQ2B;AAC3B,mDAAsD;AAEtD,MAAM,MAAM,GAAG,OAAC;KACb,MAAM,CAAC;IACN,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,yBAAgB,CAAC,CAAC;IAC9C,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CACzB,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,MAAM,GAAG,6BAAoB,CAAC,MAAM,EAAE,CAAC;AAOtC,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAGV;IAFH,MAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;IAE/D,YAAoB,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAE5D,KAAK,CAAC,KAAK,CACT,KAA6B,EAC7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emaValidatorService } from '../../common';
3
+ import { ConfigurationService } from '../../configuration';
4
+ import { z } from 'zod';
5
+ import { WorkflowEntity } from '@loopstack/shared';
6
+ import { DocumentService } from '../../persistence';
7
+ import { TemplateExpressionEvaluatorService } from '../services';
8
+ declare const schema: z.ZodObject<{
9
+ document: z.ZodString;
10
+ name: z.ZodOptional<z.ZodString>;
11
+ addSuffix: z.ZodOptional<z.ZodBoolean>;
12
+ items: z.ZodArray<z.ZodAny, "many">;
13
+ }, "strict", z.ZodTypeAny, {
14
+ document: string;
15
+ items: any[];
16
+ name?: string | undefined;
17
+ addSuffix?: boolean | undefined;
18
+ }, {
19
+ document: string;
20
+ items: any[];
21
+ name?: string | undefined;
22
+ addSuffix?: boolean | undefined;
23
+ }>;
24
+ export declare class BatchCreateDocumentsService implements ServiceInterface {
25
+ private actionHelperService;
26
+ private loopConfigService;
27
+ private documentService;
28
+ private templateExpressionEvaluatorService;
29
+ private readonly logger;
30
+ constructor(actionHelperService: SchemaValidatorService, loopConfigService: ConfigurationService, documentService: DocumentService, templateExpressionEvaluatorService: TemplateExpressionEvaluatorService);
31
+ apply(props: z.infer<typeof schema>, workflow: WorkflowEntity | undefined, context: ContextInterface, meta: TransitionMetadataInterface): Promise<ServiceCallResult>;
32
+ }
33
+ export {};
@@ -18,66 +18,61 @@ const configuration_1 = require("../../configuration");
18
18
  const zod_1 = require("zod");
19
19
  const persistence_1 = require("../../persistence");
20
20
  const lodash_1 = require("lodash");
21
+ const services_1 = require("../services");
22
+ const config = zod_1.z
23
+ .object({
24
+ document: zod_1.z.string(),
25
+ name: zod_1.z.union([shared_1.ExpressionString, shared_1.NonExpressionString]).optional(),
26
+ addSuffix: zod_1.z.union([shared_1.ExpressionString, zod_1.z.boolean()]).optional(),
27
+ items: zod_1.z.union([shared_1.ExpressionString, zod_1.z.array(zod_1.z.any())]),
28
+ })
29
+ .strict();
30
+ const schema = zod_1.z
31
+ .object({
32
+ document: zod_1.z.string(),
33
+ name: shared_1.NonExpressionString.optional(),
34
+ addSuffix: zod_1.z.boolean().optional(),
35
+ items: zod_1.z.array(zod_1.z.any()),
36
+ })
37
+ .strict();
21
38
  let BatchCreateDocumentsService = BatchCreateDocumentsService_1 = class BatchCreateDocumentsService {
22
39
  actionHelperService;
23
40
  loopConfigService;
24
41
  documentService;
25
- documentHelperService;
26
- valueParserService;
42
+ templateExpressionEvaluatorService;
27
43
  logger = new common_1.Logger(BatchCreateDocumentsService_1.name);
28
- configSchema = zod_1.z
29
- .object({
30
- document: zod_1.z.string(),
31
- namePrefix: zod_1.z.union([shared_1.ExpressionString, shared_1.NonExpressionString]).optional(),
32
- items: zod_1.z.union([shared_1.ExpressionString, zod_1.z.array(zod_1.z.any())]),
33
- })
34
- .strict();
35
- schema = zod_1.z
36
- .object({
37
- document: zod_1.z.string(),
38
- namePrefix: shared_1.NonExpressionString.optional(),
39
- items: zod_1.z.array(zod_1.z.any()),
40
- })
41
- .strict();
42
- constructor(actionHelperService, loopConfigService, documentService, documentHelperService, valueParserService) {
44
+ constructor(actionHelperService, loopConfigService, documentService, templateExpressionEvaluatorService) {
43
45
  this.actionHelperService = actionHelperService;
44
46
  this.loopConfigService = loopConfigService;
45
47
  this.documentService = documentService;
46
- this.documentHelperService = documentHelperService;
47
- this.valueParserService = valueParserService;
48
+ this.templateExpressionEvaluatorService = templateExpressionEvaluatorService;
48
49
  }
49
- async apply(props, workflow, context, workflowContext) {
50
+ async apply(props, workflow, context, meta) {
50
51
  if (!workflow) {
51
- return {};
52
+ throw new Error('Workflow is undefined');
52
53
  }
53
- let template = props?.document
54
- ? this.loopConfigService.get('documents', props.document)
55
- : undefined;
56
- const aliasVariables = workflow?.aliasData && workflow.currData
57
- ? this.documentHelperService.prepareAliasVariables(workflow.aliasData, workflow.currData)
58
- : {};
59
- template = this.valueParserService.evalObjectLeafs(template, {
60
- ...aliasVariables,
61
- context,
62
- data: workflow.currData,
63
- workflow: workflowContext,
64
- });
54
+ const template = this.loopConfigService.get('documents', props.document);
55
+ if (!template) {
56
+ throw new Error(`Document template ${props.document} not found.`);
57
+ }
58
+ const evaluatedTemplate = this.templateExpressionEvaluatorService.evaluate(template, {}, context, workflow, meta);
65
59
  const documents = [];
66
60
  for (let index = 0; index < props.items.length; index++) {
67
- const documentData = (0, lodash_1.merge)({}, template, {
68
- name: (props.namePrefix ?? template?.name ?? 'item') + `-${index + 1}`,
69
- content: props.items[index],
70
- });
61
+ const documentData = (0, lodash_1.merge)({}, evaluatedTemplate, props.items[index]);
71
62
  if (!documentData) {
72
63
  throw new Error(`No document data provided.`);
73
64
  }
65
+ if (props.addSuffix) {
66
+ documentData.name += `-${index + 1}`;
67
+ }
74
68
  this.actionHelperService.validateDocument(documentData);
75
69
  this.logger.debug(`Create document "${documentData.name}".`);
76
- documents.push(this.documentService.create(workflow, context, workflowContext, documentData));
70
+ documents.push(this.documentService.create(workflow, context, meta, documentData));
77
71
  }
78
72
  return {
73
+ success: true,
79
74
  workflow,
80
- commitDirect: true,
75
+ persist: true,
81
76
  data: documents,
82
77
  };
83
78
  }
@@ -85,11 +80,13 @@ let BatchCreateDocumentsService = BatchCreateDocumentsService_1 = class BatchCre
85
80
  exports.BatchCreateDocumentsService = BatchCreateDocumentsService;
86
81
  exports.BatchCreateDocumentsService = BatchCreateDocumentsService = BatchCreateDocumentsService_1 = __decorate([
87
82
  (0, common_1.Injectable)(),
88
- (0, shared_1.Tool)(),
83
+ (0, shared_1.Service)({
84
+ config,
85
+ schema,
86
+ }),
89
87
  __metadata("design:paramtypes", [common_2.SchemaValidatorService,
90
88
  configuration_1.ConfigurationService,
91
89
  persistence_1.DocumentService,
92
- common_2.DocumentHelperService,
93
- common_2.ValueParserService])
90
+ services_1.TemplateExpressionEvaluatorService])
94
91
  ], BatchCreateDocumentsService);
95
92
  //# sourceMappingURL=batch-create-documents.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch-create-documents.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/batch-create-documents.service.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YAE7D,SAAS,CAAC,IAAI,CACZ,IAAI,CAAC,eAAe,CAAC,MAAM,CACzB,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,YAAuC,CACxC,CACF,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,QAAQ;YACR,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,SAAS;SAChB,CAAC;IACJ,CAAC;CACF,CAAA;AAnEY,kEAA2B;sCAA3B,2BAA2B;IALvC,IAAA,mBAAU,GAAE;IACZ,IAAA,gBAAO,EAAC;QACP,MAAM;QACN,MAAM;KACP,CAAC;qCAK+B,+BAAsB;QACxB,oCAAoB;QACtB,6BAAe;QACI,6CAAkC;GAPrE,2BAA2B,CAmEvC"}
@@ -0,0 +1,223 @@
1
+ import { ContextInterface, ServiceInterface, ServiceCallResult, TransitionMetadataInterface } from '@loopstack/shared';
2
+ import { SchemaValidatorService } from '../../common';
3
+ import { ConfigurationService } from '../../configuration';
4
+ import { z } from 'zod';
5
+ import { WorkflowEntity } from '@loopstack/shared';
6
+ import { DocumentService } from '../../persistence';
7
+ import { TemplateExpressionEvaluatorService } from '../services';
8
+ declare const schema: z.ZodObject<{
9
+ document: z.ZodOptional<z.ZodString>;
10
+ update: z.ZodOptional<z.ZodObject<{
11
+ name: z.ZodOptional<z.ZodString>;
12
+ description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
13
+ content: z.ZodOptional<z.ZodAny>;
14
+ schema: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
15
+ ui: z.ZodOptional<z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>>;
16
+ tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
17
+ meta: z.ZodOptional<z.ZodOptional<z.ZodObject<{
18
+ 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"]>>;
19
+ invalidate: z.ZodOptional<z.ZodBoolean>;
20
+ level: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"debug">, z.ZodLiteral<"info">, z.ZodLiteral<"warning">, z.ZodLiteral<"error">]>>;
21
+ enableTransitions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
22
+ enableAtPlaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
23
+ hideAtPlaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
24
+ data: z.ZodOptional<z.ZodAny>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
27
+ invalidate?: boolean | undefined;
28
+ level?: "debug" | "info" | "warning" | "error" | undefined;
29
+ enableTransitions?: string[] | undefined;
30
+ enableAtPlaces?: string[] | undefined;
31
+ hideAtPlaces?: string[] | undefined;
32
+ data?: any;
33
+ }, {
34
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
35
+ invalidate?: boolean | undefined;
36
+ level?: "debug" | "info" | "warning" | "error" | undefined;
37
+ enableTransitions?: string[] | undefined;
38
+ enableAtPlaces?: string[] | undefined;
39
+ hideAtPlaces?: string[] | undefined;
40
+ data?: any;
41
+ }>>>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ name?: string | undefined;
44
+ description?: string | undefined;
45
+ content?: any;
46
+ schema?: any;
47
+ ui?: any;
48
+ tags?: string[] | undefined;
49
+ meta?: {
50
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
51
+ invalidate?: boolean | undefined;
52
+ level?: "debug" | "info" | "warning" | "error" | undefined;
53
+ enableTransitions?: string[] | undefined;
54
+ enableAtPlaces?: string[] | undefined;
55
+ hideAtPlaces?: string[] | undefined;
56
+ data?: any;
57
+ } | undefined;
58
+ }, {
59
+ name?: string | undefined;
60
+ description?: string | undefined;
61
+ content?: any;
62
+ schema?: any;
63
+ ui?: any;
64
+ tags?: string[] | undefined;
65
+ meta?: {
66
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
67
+ invalidate?: boolean | undefined;
68
+ level?: "debug" | "info" | "warning" | "error" | undefined;
69
+ enableTransitions?: string[] | undefined;
70
+ enableAtPlaces?: string[] | undefined;
71
+ hideAtPlaces?: string[] | undefined;
72
+ data?: any;
73
+ } | undefined;
74
+ }>>;
75
+ create: z.ZodOptional<z.ZodObject<{
76
+ name: z.ZodString;
77
+ description: z.ZodOptional<z.ZodString>;
78
+ content: z.ZodAny;
79
+ schema: z.ZodType<any, z.ZodTypeDef, any>;
80
+ ui: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
81
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
82
+ meta: z.ZodOptional<z.ZodObject<{
83
+ 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"]>>;
84
+ invalidate: z.ZodOptional<z.ZodBoolean>;
85
+ level: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"debug">, z.ZodLiteral<"info">, z.ZodLiteral<"warning">, z.ZodLiteral<"error">]>>;
86
+ enableTransitions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
87
+ enableAtPlaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
88
+ hideAtPlaces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
89
+ data: z.ZodOptional<z.ZodAny>;
90
+ }, "strip", z.ZodTypeAny, {
91
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
92
+ invalidate?: boolean | undefined;
93
+ level?: "debug" | "info" | "warning" | "error" | undefined;
94
+ enableTransitions?: string[] | undefined;
95
+ enableAtPlaces?: string[] | undefined;
96
+ hideAtPlaces?: string[] | undefined;
97
+ data?: any;
98
+ }, {
99
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
100
+ invalidate?: boolean | undefined;
101
+ level?: "debug" | "info" | "warning" | "error" | undefined;
102
+ enableTransitions?: string[] | undefined;
103
+ enableAtPlaces?: string[] | undefined;
104
+ hideAtPlaces?: string[] | undefined;
105
+ data?: any;
106
+ }>>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ name: string;
109
+ description?: string | undefined;
110
+ content?: any;
111
+ schema?: any;
112
+ ui?: any;
113
+ tags?: string[] | undefined;
114
+ meta?: {
115
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
116
+ invalidate?: boolean | undefined;
117
+ level?: "debug" | "info" | "warning" | "error" | undefined;
118
+ enableTransitions?: string[] | undefined;
119
+ enableAtPlaces?: string[] | undefined;
120
+ hideAtPlaces?: string[] | undefined;
121
+ data?: any;
122
+ } | undefined;
123
+ }, {
124
+ name: string;
125
+ description?: string | undefined;
126
+ content?: any;
127
+ schema?: any;
128
+ ui?: any;
129
+ tags?: string[] | undefined;
130
+ meta?: {
131
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
132
+ invalidate?: boolean | undefined;
133
+ level?: "debug" | "info" | "warning" | "error" | undefined;
134
+ enableTransitions?: string[] | undefined;
135
+ enableAtPlaces?: string[] | undefined;
136
+ hideAtPlaces?: string[] | undefined;
137
+ data?: any;
138
+ } | undefined;
139
+ }>>;
140
+ }, "strict", z.ZodTypeAny, {
141
+ create?: {
142
+ name: string;
143
+ description?: string | undefined;
144
+ content?: any;
145
+ schema?: any;
146
+ ui?: any;
147
+ tags?: string[] | undefined;
148
+ meta?: {
149
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
150
+ invalidate?: boolean | undefined;
151
+ level?: "debug" | "info" | "warning" | "error" | undefined;
152
+ enableTransitions?: string[] | undefined;
153
+ enableAtPlaces?: string[] | undefined;
154
+ hideAtPlaces?: string[] | undefined;
155
+ data?: any;
156
+ } | undefined;
157
+ } | undefined;
158
+ update?: {
159
+ name?: string | undefined;
160
+ description?: string | undefined;
161
+ content?: any;
162
+ schema?: any;
163
+ ui?: any;
164
+ tags?: string[] | undefined;
165
+ meta?: {
166
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
167
+ invalidate?: boolean | undefined;
168
+ level?: "debug" | "info" | "warning" | "error" | undefined;
169
+ enableTransitions?: string[] | undefined;
170
+ enableAtPlaces?: string[] | undefined;
171
+ hideAtPlaces?: string[] | undefined;
172
+ data?: any;
173
+ } | undefined;
174
+ } | undefined;
175
+ document?: string | undefined;
176
+ }, {
177
+ create?: {
178
+ name: string;
179
+ description?: string | undefined;
180
+ content?: any;
181
+ schema?: any;
182
+ ui?: any;
183
+ tags?: string[] | undefined;
184
+ meta?: {
185
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
186
+ invalidate?: boolean | undefined;
187
+ level?: "debug" | "info" | "warning" | "error" | undefined;
188
+ enableTransitions?: string[] | undefined;
189
+ enableAtPlaces?: string[] | undefined;
190
+ hideAtPlaces?: string[] | undefined;
191
+ data?: any;
192
+ } | undefined;
193
+ } | undefined;
194
+ update?: {
195
+ name?: string | undefined;
196
+ description?: string | undefined;
197
+ content?: any;
198
+ schema?: any;
199
+ ui?: any;
200
+ tags?: string[] | undefined;
201
+ meta?: {
202
+ mimeType?: "text/plain" | "text/html" | "text/css" | "text/xml" | "text/markdown" | "application/javascript" | "application/typescript" | "application/json" | "application/xml" | "application/yaml" | undefined;
203
+ invalidate?: boolean | undefined;
204
+ level?: "debug" | "info" | "warning" | "error" | undefined;
205
+ enableTransitions?: string[] | undefined;
206
+ enableAtPlaces?: string[] | undefined;
207
+ hideAtPlaces?: string[] | undefined;
208
+ data?: any;
209
+ } | undefined;
210
+ } | undefined;
211
+ document?: string | undefined;
212
+ }>;
213
+ export declare class CreateDocumentService implements ServiceInterface {
214
+ private actionHelperService;
215
+ private loopConfigService;
216
+ private documentService;
217
+ private templateExpressionEvaluatorService;
218
+ private readonly logger;
219
+ constructor(actionHelperService: SchemaValidatorService, loopConfigService: ConfigurationService, documentService: DocumentService, templateExpressionEvaluatorService: TemplateExpressionEvaluatorService);
220
+ getDocumentTemplate(props: z.infer<typeof schema>, workflow: WorkflowEntity, context: ContextInterface, meta: TransitionMetadataInterface): {};
221
+ apply(props: z.infer<typeof schema>, workflow: WorkflowEntity | undefined, context: ContextInterface, meta: TransitionMetadataInterface): Promise<ServiceCallResult>;
222
+ }
223
+ export {};
@@ -18,63 +18,55 @@ const configuration_1 = require("../../configuration");
18
18
  const zod_1 = require("zod");
19
19
  const persistence_1 = require("../../persistence");
20
20
  const lodash_1 = require("lodash");
21
+ const services_1 = require("../services");
22
+ const schema = zod_1.z.object({
23
+ document: zod_1.z.string().optional(),
24
+ update: shared_1.PartialDocumentSchema.optional(),
25
+ create: shared_1.DocumentSchema.optional(),
26
+ }).strict();
27
+ const config = zod_1.z.object({
28
+ document: zod_1.z.string().optional(),
29
+ update: shared_1.DocumentConfigSchema.partial().optional(),
30
+ create: shared_1.DocumentConfigSchema.optional(),
31
+ }).strict();
21
32
  let CreateDocumentService = CreateDocumentService_1 = class CreateDocumentService {
22
33
  actionHelperService;
23
34
  loopConfigService;
24
35
  documentService;
25
- documentHelperService;
26
- valueParserService;
36
+ templateExpressionEvaluatorService;
27
37
  logger = new common_1.Logger(CreateDocumentService_1.name);
28
- configSchema = zod_1.z
29
- .object({
30
- document: zod_1.z.string().optional(),
31
- update: shared_1.DocumentConfigSchema.partial().optional(),
32
- create: shared_1.DocumentConfigSchema.optional(),
33
- })
34
- .strict();
35
- schema = zod_1.z
36
- .object({
37
- document: zod_1.z.string().optional(),
38
- update: shared_1.PartialDocumentSchema.optional(),
39
- create: shared_1.DocumentSchema.optional(),
40
- })
41
- .strict();
42
- constructor(actionHelperService, loopConfigService, documentService, documentHelperService, valueParserService) {
38
+ constructor(actionHelperService, loopConfigService, documentService, templateExpressionEvaluatorService) {
43
39
  this.actionHelperService = actionHelperService;
44
40
  this.loopConfigService = loopConfigService;
45
41
  this.documentService = documentService;
46
- this.documentHelperService = documentHelperService;
47
- this.valueParserService = valueParserService;
42
+ this.templateExpressionEvaluatorService = templateExpressionEvaluatorService;
48
43
  }
49
- async apply(props, workflow, context, workflowContext) {
50
- if (!workflow) {
44
+ getDocumentTemplate(props, workflow, context, meta) {
45
+ if (!props?.document) {
51
46
  return {};
52
47
  }
53
- const validProps = this.schema.parse(props);
54
- let template = validProps?.document
55
- ? this.loopConfigService.get('documents', validProps.document)
56
- : undefined;
57
- if (template) {
58
- const aliasVariables = workflow?.aliasData && workflow.currData
59
- ? this.documentHelperService.prepareAliasVariables(workflow.aliasData, workflow.currData)
60
- : {};
61
- template = this.valueParserService.evalObjectLeafs(template, {
62
- ...aliasVariables,
63
- context,
64
- data: workflow.currData,
65
- workflow: workflowContext,
66
- });
48
+ const template = this.loopConfigService.get('documents', props.document);
49
+ if (!template) {
50
+ throw new Error(`Document template ${props.document} not found.`);
51
+ }
52
+ return this.templateExpressionEvaluatorService.evaluate(template, {}, context, workflow, meta);
53
+ }
54
+ async apply(props, workflow, context, meta) {
55
+ if (!workflow) {
56
+ throw new Error('Workflow is undefined');
67
57
  }
68
- const documentData = (0, lodash_1.merge)({}, template, validProps?.create ?? validProps?.update ?? {});
58
+ const template = this.getDocumentTemplate(props, workflow, context, meta);
59
+ const documentData = (0, lodash_1.merge)(template, props?.create ?? props?.update ?? {});
69
60
  if (!documentData) {
70
61
  throw new Error(`No document data provided.`);
71
62
  }
72
63
  this.actionHelperService.validateDocument(documentData);
73
64
  this.logger.debug(`Create document "${documentData.name}".`);
74
- const document = this.documentService.create(workflow, context, workflowContext, documentData);
65
+ const document = this.documentService.create(workflow, context, meta, documentData);
75
66
  return {
67
+ success: true,
76
68
  workflow,
77
- commitDirect: true,
69
+ persist: true,
78
70
  data: document,
79
71
  };
80
72
  }
@@ -82,11 +74,13 @@ let CreateDocumentService = CreateDocumentService_1 = class CreateDocumentServic
82
74
  exports.CreateDocumentService = CreateDocumentService;
83
75
  exports.CreateDocumentService = CreateDocumentService = CreateDocumentService_1 = __decorate([
84
76
  (0, common_1.Injectable)(),
85
- (0, shared_1.Tool)(),
77
+ (0, shared_1.Service)({
78
+ config,
79
+ schema,
80
+ }),
86
81
  __metadata("design:paramtypes", [common_2.SchemaValidatorService,
87
82
  configuration_1.ConfigurationService,
88
83
  persistence_1.DocumentService,
89
- common_2.DocumentHelperService,
90
- common_2.ValueParserService])
84
+ services_1.TemplateExpressionEvaluatorService])
91
85
  ], CreateDocumentService);
92
86
  //# sourceMappingURL=create-document.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-document.service.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/create-document.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAS2B;AAC3B,yCAEsB;AACtB,uDAA2D;AAE3D,6BAAwB;AAExB,mDAAoD;AACpD,mCAA+B;AAC/B,0CAAiE;AAEjE,MAAM,MAAM,GAAG,OAAC,CAAC,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CA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,EACR,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAK,CACT,KAA6B,EAC7B,QAAoC,EACpC,OAAyB,EACzB,IAAiC;QAEjC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,QAAQ,GAA4B,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAEnG,MAAM,YAAY,GAAG,IAAA,cAAK,EACxB,QAAQ,EACR,KAAK,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,IAAI,EAAE,CACrC,CAAC;QAEF,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CACvC,YAAuC,CACxC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,YAAY,CAAC,IAAI,IAAI,CAAC,CAAC;QAE7D,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAC1C,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,YAAuC,CACxC,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,IAAI;YACb,QAAQ;YACR,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,QAAQ;SACf,CAAC;IACJ,CAAC;CACF,CAAA;AAtEY,sDAAqB;gCAArB,qBAAqB;IALjC,IAAA,mBAAU,GAAE;IACZ,IAAA,gBAAO,EAAC;QACP,MAAM;QACN,MAAM;KACP,CAAC;qCAK+B,+BAAsB;QACxB,oCAAoB;QACtB,6BAAe;QACI,6CAAkC;GAPrE,qBAAqB,CAsEjC"}
@@ -1,9 +1,9 @@
1
- export * from './tool-call.service';
2
1
  export * from './add-namespace.service';
3
2
  export * from './create-document.service';
4
- export * from './debug.service';
3
+ export * from './mock.service';
5
4
  export * from './load-document.service';
6
5
  export * from './set-context.service';
7
6
  export * from './transition-selector.service';
8
7
  export * from './update-document.service';
9
8
  export * from './batch-create-documents.service';
9
+ export * from './set-target-place.service';
@@ -14,13 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./tool-call.service"), exports);
18
17
  __exportStar(require("./add-namespace.service"), exports);
19
18
  __exportStar(require("./create-document.service"), exports);
20
- __exportStar(require("./debug.service"), exports);
19
+ __exportStar(require("./mock.service"), exports);
21
20
  __exportStar(require("./load-document.service"), exports);
22
21
  __exportStar(require("./set-context.service"), exports);
23
22
  __exportStar(require("./transition-selector.service"), exports);
24
23
  __exportStar(require("./update-document.service"), exports);
25
24
  __exportStar(require("./batch-create-documents.service"), exports);
25
+ __exportStar(require("./set-target-place.service"), exports);
26
26
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/workflow-processor/tool-services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,4DAA0C;AAC1C,iDAA+B;AAC/B,0DAAwC;AACxC,wDAAsC;AACtC,gEAA8C;AAC9C,4DAA0C;AAC1C,mEAAiD;AACjD,6DAA2C"}