@loopstack/common 0.16.0 → 0.18.0-rc.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.
Files changed (35) hide show
  1. package/dist/decorators/block.decorator.d.ts +14 -4
  2. package/dist/decorators/block.decorator.js +41 -23
  3. package/dist/decorators/capability-decorator.d.ts +1 -1
  4. package/dist/entities/document.entity.d.ts +1 -1
  5. package/dist/entities/document.entity.js +2 -2
  6. package/dist/entities/event-subscriber.entity.d.ts +2 -2
  7. package/dist/entities/event-subscriber.entity.js +19 -19
  8. package/dist/entities/index.d.ts +9 -9
  9. package/dist/entities/namespace.entity.d.ts +1 -1
  10. package/dist/entities/namespace.entity.js +1 -1
  11. package/dist/entities/permission.entity.d.ts +1 -1
  12. package/dist/entities/permission.entity.js +1 -1
  13. package/dist/entities/pipeline.entity.d.ts +6 -3
  14. package/dist/entities/pipeline.entity.js +22 -3
  15. package/dist/entities/role.entity.d.ts +2 -2
  16. package/dist/entities/role.entity.js +4 -4
  17. package/dist/entities/user.entity.d.ts +1 -1
  18. package/dist/entities/user.entity.js +3 -3
  19. package/dist/entities/workflow.entity.d.ts +7 -7
  20. package/dist/entities/workflow.entity.js +3 -3
  21. package/dist/interfaces/current-user.interface.d.ts +2 -1
  22. package/dist/interfaces/sso-response.interface.d.ts +2 -4
  23. package/dist/utils/normalize-deep-serialize.util.d.ts +1 -1
  24. package/dist/utils/normalize-deep-serialize.util.js +4 -3
  25. package/dist/utils/normalize-object.d.ts +1 -1
  26. package/dist/utils/object-fingerprint.util.js +1 -1
  27. package/dist/utils/stable-json-transformer.js +1 -5
  28. package/package.json +13 -19
  29. package/.github/workflows/publish-npm.yml +0 -83
  30. package/LICENSE +0 -43
  31. package/README.md +0 -7
  32. package/dist/constants/module.constants.d.ts +0 -1
  33. package/dist/constants/module.constants.js +0 -4
  34. package/dist/services/block-config-service.d.ts +0 -8
  35. package/dist/services/block-config-service.js +0 -34
@@ -1,5 +1,6 @@
1
- import { BlockOptions } from '../interfaces';
1
+ import { InjectionToken } from '@nestjs/common';
2
2
  import { z } from 'zod';
3
+ import { BlockOptions } from '../interfaces';
3
4
  export declare const BLOCK_METADATA_KEY: unique symbol;
4
5
  export declare const INPUT_METADATA_KEY: unique symbol;
5
6
  export declare const OUTPUT_METADATA_KEY: unique symbol;
@@ -7,13 +8,22 @@ export declare const TOOL_METADATA_KEY: unique symbol;
7
8
  export declare const DOCUMENT_METADATA_KEY: unique symbol;
8
9
  export declare const WORKFLOW_METADATA_KEY: unique symbol;
9
10
  export declare const TEMPLATE_HELPER_METADATA_KEY: unique symbol;
11
+ export interface WorkflowOptions {
12
+ visible?: boolean;
13
+ }
14
+ export interface WorkflowDecoratorOptions {
15
+ token?: InjectionToken;
16
+ options?: WorkflowOptions;
17
+ }
18
+ export declare const WORKFLOW_OPTIONS_KEY = "workflow:options";
10
19
  export declare function WithArguments<T extends z.ZodType>(schema: T): ClassDecorator;
11
20
  export declare function WithState<T extends z.ZodType>(schema: T): ClassDecorator;
12
21
  export declare function WithResult<T extends z.ZodType>(schema: T): ClassDecorator;
22
+ export declare function getWorkflowOptions(target: object, propertyKey: string | symbol): WorkflowOptions;
13
23
  export declare function BlockConfig(options: BlockOptions): ClassDecorator;
14
- export declare function Tool(token?: any): PropertyDecorator & MethodDecorator;
15
- export declare function Document(token?: any): PropertyDecorator & MethodDecorator;
16
- export declare function Workflow(token?: any): PropertyDecorator & MethodDecorator;
24
+ export declare function Tool(token?: InjectionToken): PropertyDecorator & MethodDecorator;
25
+ export declare function Document(token?: InjectionToken): PropertyDecorator & MethodDecorator;
26
+ export declare function Workflow(options?: WorkflowDecoratorOptions): PropertyDecorator & MethodDecorator;
17
27
  export declare function Helper(): MethodDecorator;
18
28
  export declare function Input(): PropertyDecorator;
19
29
  export declare function Output(): PropertyDecorator;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEMPLATE_HELPER_METADATA_KEY = exports.WORKFLOW_METADATA_KEY = exports.DOCUMENT_METADATA_KEY = exports.TOOL_METADATA_KEY = exports.OUTPUT_METADATA_KEY = exports.INPUT_METADATA_KEY = exports.BLOCK_METADATA_KEY = void 0;
3
+ exports.WORKFLOW_OPTIONS_KEY = exports.TEMPLATE_HELPER_METADATA_KEY = exports.WORKFLOW_METADATA_KEY = exports.DOCUMENT_METADATA_KEY = exports.TOOL_METADATA_KEY = exports.OUTPUT_METADATA_KEY = exports.INPUT_METADATA_KEY = exports.BLOCK_METADATA_KEY = void 0;
4
4
  exports.WithArguments = WithArguments;
5
5
  exports.WithState = WithState;
6
6
  exports.WithResult = WithResult;
7
+ exports.getWorkflowOptions = getWorkflowOptions;
7
8
  exports.BlockConfig = BlockConfig;
8
9
  exports.Tool = Tool;
9
10
  exports.Document = Document;
@@ -12,8 +13,8 @@ exports.Helper = Helper;
12
13
  exports.Input = Input;
13
14
  exports.Output = Output;
14
15
  const common_1 = require("@nestjs/common");
15
- const block_config_builder_1 = require("../utils/block-config.builder");
16
16
  const zod_1 = require("zod");
17
+ const block_config_builder_1 = require("../utils/block-config.builder");
17
18
  exports.BLOCK_METADATA_KEY = Symbol('block');
18
19
  exports.INPUT_METADATA_KEY = Symbol('input');
19
20
  exports.OUTPUT_METADATA_KEY = Symbol('output');
@@ -21,6 +22,7 @@ exports.TOOL_METADATA_KEY = Symbol('tool');
21
22
  exports.DOCUMENT_METADATA_KEY = Symbol('document');
22
23
  exports.WORKFLOW_METADATA_KEY = Symbol('workflow');
23
24
  exports.TEMPLATE_HELPER_METADATA_KEY = Symbol('templateHelper');
25
+ exports.WORKFLOW_OPTIONS_KEY = 'workflow:options';
24
26
  function WithArguments(schema) {
25
27
  return (target) => {
26
28
  target.argsSchema = schema;
@@ -51,28 +53,38 @@ function WithResult(schema) {
51
53
  };
52
54
  }
53
55
  function getTools(target) {
54
- const keys = Reflect.getMetadata(exports.TOOL_METADATA_KEY, target.prototype) || [];
55
- return keys.map(key => String(key));
56
+ const proto = target.prototype;
57
+ const keys = Reflect.getMetadata(exports.TOOL_METADATA_KEY, proto) ?? [];
58
+ return keys.map((key) => String(key));
56
59
  }
57
60
  function getDocuments(target) {
58
- const keys = Reflect.getMetadata(exports.DOCUMENT_METADATA_KEY, target.prototype) || [];
59
- return keys.map(key => String(key));
61
+ const proto = target.prototype;
62
+ const keys = Reflect.getMetadata(exports.DOCUMENT_METADATA_KEY, proto) ?? [];
63
+ return keys.map((key) => String(key));
60
64
  }
61
65
  function getWorkflows(target) {
62
- const keys = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, target.prototype) || [];
63
- return keys.map(key => String(key));
66
+ const proto = target.prototype;
67
+ const keys = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, proto) ?? [];
68
+ return keys.map((key) => String(key));
64
69
  }
65
70
  function getHelpers(target) {
66
- const keys = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, target.prototype) || [];
67
- return keys.map(key => String(key));
71
+ const proto = target.prototype;
72
+ const keys = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, proto) ?? [];
73
+ return keys.map((key) => String(key));
74
+ }
75
+ function getWorkflowOptions(target, propertyKey) {
76
+ return (Reflect.getMetadata(exports.WORKFLOW_OPTIONS_KEY, target, propertyKey) ?? {
77
+ visible: true,
78
+ });
68
79
  }
69
80
  function BlockConfig(options) {
70
81
  return (target) => {
71
- target.blockConfig = (0, block_config_builder_1.buildConfig)(options);
72
- target.blockTools = getTools(target);
73
- target.blockDocuments = getDocuments(target);
74
- target.blockWorkflows = getWorkflows(target);
75
- target.blockHelpers = getHelpers(target);
82
+ const ctor = target;
83
+ ctor.blockConfig = (0, block_config_builder_1.buildConfig)(options);
84
+ ctor.blockTools = getTools(ctor);
85
+ ctor.blockDocuments = getDocuments(ctor);
86
+ ctor.blockWorkflows = getWorkflows(ctor);
87
+ ctor.blockHelpers = getHelpers(ctor);
76
88
  Reflect.defineMetadata(exports.BLOCK_METADATA_KEY, options, target);
77
89
  };
78
90
  }
@@ -82,7 +94,7 @@ function Tool(token) {
82
94
  if (type) {
83
95
  (0, common_1.Inject)(type)(target, propertyKey);
84
96
  }
85
- const existingTools = Reflect.getMetadata(exports.TOOL_METADATA_KEY, target) || [];
97
+ const existingTools = Reflect.getMetadata(exports.TOOL_METADATA_KEY, target) ?? [];
86
98
  Reflect.defineMetadata(exports.TOOL_METADATA_KEY, [...existingTools, propertyKey], target);
87
99
  };
88
100
  }
@@ -92,35 +104,41 @@ function Document(token) {
92
104
  if (type) {
93
105
  (0, common_1.Inject)(type)(target, propertyKey);
94
106
  }
95
- const existingTools = Reflect.getMetadata(exports.DOCUMENT_METADATA_KEY, target) || [];
96
- Reflect.defineMetadata(exports.DOCUMENT_METADATA_KEY, [...existingTools, propertyKey], target);
107
+ const existingDocuments = Reflect.getMetadata(exports.DOCUMENT_METADATA_KEY, target) ?? [];
108
+ Reflect.defineMetadata(exports.DOCUMENT_METADATA_KEY, [...existingDocuments, propertyKey], target);
97
109
  };
98
110
  }
99
- function Workflow(token) {
111
+ function Workflow(options) {
100
112
  return (target, propertyKey) => {
113
+ const token = options?.token;
114
+ const config = {
115
+ visible: true,
116
+ ...options?.options,
117
+ };
101
118
  const type = token ?? Reflect.getMetadata('design:type', target, propertyKey);
102
119
  if (type) {
103
120
  (0, common_1.Inject)(type)(target, propertyKey);
104
121
  }
105
- const existingWorkflows = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, target) || [];
122
+ const existingWorkflows = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, target) ?? [];
106
123
  Reflect.defineMetadata(exports.WORKFLOW_METADATA_KEY, [...existingWorkflows, propertyKey], target);
124
+ Reflect.defineMetadata(exports.WORKFLOW_OPTIONS_KEY, config, target, propertyKey);
107
125
  };
108
126
  }
109
127
  function Helper() {
110
128
  return (target, propertyKey) => {
111
- const existing = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, target) || [];
129
+ const existing = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, target) ?? [];
112
130
  Reflect.defineMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, [...existing, propertyKey], target);
113
131
  };
114
132
  }
115
133
  function Input() {
116
134
  return (target, propertyKey) => {
117
- const existingInputs = Reflect.getMetadata(exports.INPUT_METADATA_KEY, target) || [];
135
+ const existingInputs = Reflect.getMetadata(exports.INPUT_METADATA_KEY, target) ?? [];
118
136
  Reflect.defineMetadata(exports.INPUT_METADATA_KEY, [...existingInputs, propertyKey], target);
119
137
  };
120
138
  }
121
139
  function Output() {
122
140
  return (target, propertyKey) => {
123
- const existingOutputs = Reflect.getMetadata(exports.OUTPUT_METADATA_KEY, target) || [];
141
+ const existingOutputs = Reflect.getMetadata(exports.OUTPUT_METADATA_KEY, target) ?? [];
124
142
  Reflect.defineMetadata(exports.OUTPUT_METADATA_KEY, [...existingOutputs, propertyKey], target);
125
143
  };
126
144
  }
@@ -1,2 +1,2 @@
1
1
  export declare const FACTORY_MODULE = "FACTORY_MODULE";
2
- export declare function CapabilityFactory(moduleClass: string): (target: any) => any;
2
+ export declare function CapabilityFactory(moduleClass: string): <T extends new (...args: unknown[]) => object>(target: T) => T;
@@ -1,6 +1,6 @@
1
- import { WorkflowEntity } from './workflow.entity';
2
1
  import { z } from 'zod';
3
2
  import type { JSONSchemaConfigType } from '@loopstack/contracts/types';
3
+ import { WorkflowEntity } from './workflow.entity';
4
4
  export declare class DocumentEntity<T = any> {
5
5
  id: string;
6
6
  messageId: string;
@@ -11,8 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.DocumentEntity = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
- const workflow_entity_1 = require("./workflow.entity");
15
14
  const utils_1 = require("../utils");
15
+ const workflow_entity_1 = require("./workflow.entity");
16
16
  let DocumentEntity = class DocumentEntity {
17
17
  id;
18
18
  messageId;
@@ -79,7 +79,7 @@ __decorate([
79
79
  __metadata("design:type", Object)
80
80
  ], DocumentEntity.prototype, "schema", void 0);
81
81
  __decorate([
82
- (0, typeorm_1.Column)('jsonb', { nullable: true, name: "validation_error" }),
82
+ (0, typeorm_1.Column)('jsonb', { nullable: true, name: 'validation_error' }),
83
83
  __metadata("design:type", Object)
84
84
  ], DocumentEntity.prototype, "error", void 0);
85
85
  __decorate([
@@ -1,5 +1,5 @@
1
- import { WorkspaceEntity } from "./workspace.entity";
2
- import { PipelineEntity } from "./pipeline.entity";
1
+ import { PipelineEntity } from './pipeline.entity';
2
+ import { WorkspaceEntity } from './workspace.entity';
3
3
  export declare class EventSubscriberEntity {
4
4
  id: string;
5
5
  subscriberPipeline: PipelineEntity;
@@ -11,8 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.EventSubscriberEntity = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
- const workspace_entity_1 = require("./workspace.entity");
15
14
  const pipeline_entity_1 = require("./pipeline.entity");
15
+ const workspace_entity_1 = require("./workspace.entity");
16
16
  let EventSubscriberEntity = class EventSubscriberEntity {
17
17
  id;
18
18
  subscriberPipeline;
@@ -30,64 +30,64 @@ let EventSubscriberEntity = class EventSubscriberEntity {
30
30
  };
31
31
  exports.EventSubscriberEntity = EventSubscriberEntity;
32
32
  __decorate([
33
- (0, typeorm_1.PrimaryGeneratedColumn)("uuid"),
33
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
34
34
  __metadata("design:type", String)
35
35
  ], EventSubscriberEntity.prototype, "id", void 0);
36
36
  __decorate([
37
- (0, typeorm_1.ManyToOne)(() => pipeline_entity_1.PipelineEntity, { onDelete: "CASCADE" }),
38
- (0, typeorm_1.JoinColumn)({ name: "subscriber_pipeline_id" }),
37
+ (0, typeorm_1.ManyToOne)(() => pipeline_entity_1.PipelineEntity, { onDelete: 'CASCADE' }),
38
+ (0, typeorm_1.JoinColumn)({ name: 'subscriber_pipeline_id' }),
39
39
  __metadata("design:type", pipeline_entity_1.PipelineEntity)
40
40
  ], EventSubscriberEntity.prototype, "subscriberPipeline", void 0);
41
41
  __decorate([
42
- (0, typeorm_1.Column)({ type: "uuid", name: "subscriber_pipeline_id" }),
42
+ (0, typeorm_1.Column)({ type: 'uuid', name: 'subscriber_pipeline_id' }),
43
43
  (0, typeorm_1.Index)(),
44
44
  __metadata("design:type", String)
45
45
  ], EventSubscriberEntity.prototype, "subscriberPipelineId", void 0);
46
46
  __decorate([
47
- (0, typeorm_1.Column)({ type: "uuid", name: "subscriber_workflow_id" }),
47
+ (0, typeorm_1.Column)({ type: 'uuid', name: 'subscriber_workflow_id' }),
48
48
  __metadata("design:type", String)
49
49
  ], EventSubscriberEntity.prototype, "subscriberWorkflowId", void 0);
50
50
  __decorate([
51
- (0, typeorm_1.Column)({ type: "varchar", name: "subscriber_transition" }),
51
+ (0, typeorm_1.Column)({ type: 'varchar', name: 'subscriber_transition' }),
52
52
  __metadata("design:type", String)
53
53
  ], EventSubscriberEntity.prototype, "subscriberTransition", void 0);
54
54
  __decorate([
55
- (0, typeorm_1.Column)({ type: "uuid", name: "event_pipeline_id" }),
55
+ (0, typeorm_1.Column)({ type: 'uuid', name: 'event_pipeline_id' }),
56
56
  (0, typeorm_1.Index)(),
57
57
  __metadata("design:type", String)
58
58
  ], EventSubscriberEntity.prototype, "eventPipelineId", void 0);
59
59
  __decorate([
60
- (0, typeorm_1.Column)({ type: "varchar", name: "event_name" }),
60
+ (0, typeorm_1.Column)({ type: 'varchar', name: 'event_name' }),
61
61
  (0, typeorm_1.Index)(),
62
62
  __metadata("design:type", String)
63
63
  ], EventSubscriberEntity.prototype, "eventName", void 0);
64
64
  __decorate([
65
- (0, typeorm_1.CreateDateColumn)({ name: "created_at" }),
65
+ (0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
66
66
  __metadata("design:type", Date)
67
67
  ], EventSubscriberEntity.prototype, "createdAt", void 0);
68
68
  __decorate([
69
- (0, typeorm_1.UpdateDateColumn)({ name: "updated_at" }),
69
+ (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at' }),
70
70
  __metadata("design:type", Date)
71
71
  ], EventSubscriberEntity.prototype, "updatedAt", void 0);
72
72
  __decorate([
73
- (0, typeorm_1.ManyToOne)(() => workspace_entity_1.WorkspaceEntity, { onDelete: "CASCADE" }),
74
- (0, typeorm_1.JoinColumn)({ name: "workspace_id" }),
73
+ (0, typeorm_1.ManyToOne)(() => workspace_entity_1.WorkspaceEntity, { onDelete: 'CASCADE' }),
74
+ (0, typeorm_1.JoinColumn)({ name: 'workspace_id' }),
75
75
  __metadata("design:type", workspace_entity_1.WorkspaceEntity)
76
76
  ], EventSubscriberEntity.prototype, "workspace", void 0);
77
77
  __decorate([
78
- (0, typeorm_1.Column)({ name: "workspace_id", nullable: true }),
78
+ (0, typeorm_1.Column)({ name: 'workspace_id', nullable: true }),
79
79
  __metadata("design:type", String)
80
80
  ], EventSubscriberEntity.prototype, "workspaceId", void 0);
81
81
  __decorate([
82
- (0, typeorm_1.Column)({ name: "user_id", type: "uuid" }),
82
+ (0, typeorm_1.Column)({ name: 'user_id', type: 'uuid' }),
83
83
  __metadata("design:type", String)
84
84
  ], EventSubscriberEntity.prototype, "userId", void 0);
85
85
  __decorate([
86
- (0, typeorm_1.Column)({ name: "once", type: "boolean", default: true }),
86
+ (0, typeorm_1.Column)({ name: 'once', type: 'boolean', default: true }),
87
87
  __metadata("design:type", Boolean)
88
88
  ], EventSubscriberEntity.prototype, "once", void 0);
89
89
  exports.EventSubscriberEntity = EventSubscriberEntity = __decorate([
90
- (0, typeorm_1.Entity)({ name: "core_event_subscriber" }),
91
- (0, typeorm_1.Index)(["eventPipelineId", "eventName"]),
92
- (0, typeorm_1.Index)(["subscriberPipelineId", "subscriberWorkflowId", "subscriberTransition"])
90
+ (0, typeorm_1.Entity)({ name: 'core_event_subscriber' }),
91
+ (0, typeorm_1.Index)(['eventPipelineId', 'eventName']),
92
+ (0, typeorm_1.Index)(['subscriberPipelineId', 'subscriberWorkflowId', 'subscriberTransition'])
93
93
  ], EventSubscriberEntity);
@@ -1,9 +1,9 @@
1
- export * from "./pipeline.entity.js";
2
- export * from "./document.entity.js";
3
- export * from "./workflow.entity.js";
4
- export * from "./workspace.entity.js";
5
- export * from "./namespace.entity.js";
6
- export * from "./permission.entity.js";
7
- export * from "./role.entity.js";
8
- export * from "./user.entity.js";
9
- export * from "./event-subscriber.entity.js";
1
+ export * from './pipeline.entity.js';
2
+ export * from './document.entity.js';
3
+ export * from './workflow.entity.js';
4
+ export * from './workspace.entity.js';
5
+ export * from './namespace.entity.js';
6
+ export * from './permission.entity.js';
7
+ export * from './role.entity.js';
8
+ export * from './user.entity.js';
9
+ export * from './event-subscriber.entity.js';
@@ -1,5 +1,5 @@
1
- import { WorkflowEntity } from './workflow.entity';
2
1
  import { PipelineEntity } from './pipeline.entity';
2
+ import { WorkflowEntity } from './workflow.entity';
3
3
  export declare class NamespaceEntity {
4
4
  id: string;
5
5
  name: string;
@@ -11,8 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.NamespaceEntity = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
- const workflow_entity_1 = require("./workflow.entity");
15
14
  const pipeline_entity_1 = require("./pipeline.entity");
15
+ const workflow_entity_1 = require("./workflow.entity");
16
16
  let NamespaceEntity = class NamespaceEntity {
17
17
  id;
18
18
  name;
@@ -1,5 +1,5 @@
1
- import { Role } from './role.entity';
2
1
  import { PermissionInterface } from '../interfaces';
2
+ import { Role } from './role.entity';
3
3
  export declare class Permission implements PermissionInterface {
4
4
  id: string;
5
5
  name: string;
@@ -42,7 +42,7 @@ __decorate([
42
42
  __metadata("design:type", String)
43
43
  ], Permission.prototype, "description", void 0);
44
44
  __decorate([
45
- (0, typeorm_1.ManyToMany)(() => role_entity_1.Role, role => role.permissions),
45
+ (0, typeorm_1.ManyToMany)(() => role_entity_1.Role, (role) => role.permissions),
46
46
  __metadata("design:type", Array)
47
47
  ], Permission.prototype, "roles", void 0);
48
48
  exports.Permission = Permission = __decorate([
@@ -1,8 +1,8 @@
1
- import { WorkspaceEntity } from './workspace.entity';
2
- import { NamespaceEntity } from './namespace.entity';
3
- import { PipelineState } from '../enums';
4
1
  import { z } from 'zod';
5
2
  import type { JSONSchemaConfigType } from '@loopstack/contracts/types';
3
+ import { PipelineState } from '../enums';
4
+ import { NamespaceEntity } from './namespace.entity';
5
+ import { WorkspaceEntity } from './workspace.entity';
6
6
  export declare class PipelineEntity {
7
7
  id: string;
8
8
  blockName: string;
@@ -22,4 +22,7 @@ export declare class PipelineEntity {
22
22
  workspaceId: string;
23
23
  createdBy: string;
24
24
  namespaces: NamespaceEntity[];
25
+ parent: PipelineEntity | null;
26
+ parentId: string | null;
27
+ children: PipelineEntity[];
25
28
  }
@@ -11,10 +11,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PipelineEntity = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
- const workspace_entity_1 = require("./workspace.entity");
15
- const namespace_entity_1 = require("./namespace.entity");
16
14
  const enums_1 = require("../enums");
17
15
  const utils_1 = require("../utils");
16
+ const namespace_entity_1 = require("./namespace.entity");
17
+ const workspace_entity_1 = require("./workspace.entity");
18
18
  let PipelineEntity = class PipelineEntity {
19
19
  id;
20
20
  blockName;
@@ -34,6 +34,9 @@ let PipelineEntity = class PipelineEntity {
34
34
  workspaceId;
35
35
  createdBy;
36
36
  namespaces;
37
+ parent;
38
+ parentId;
39
+ children;
37
40
  };
38
41
  exports.PipelineEntity = PipelineEntity;
39
42
  __decorate([
@@ -87,7 +90,7 @@ __decorate([
87
90
  __metadata("design:type", Object)
88
91
  ], PipelineEntity.prototype, "schema", void 0);
89
92
  __decorate([
90
- (0, typeorm_1.Column)('jsonb', { nullable: true, name: "error" }),
93
+ (0, typeorm_1.Column)('jsonb', { nullable: true, name: 'error' }),
91
94
  __metadata("design:type", Object)
92
95
  ], PipelineEntity.prototype, "error", void 0);
93
96
  __decorate([
@@ -126,6 +129,22 @@ __decorate([
126
129
  (0, typeorm_1.OneToMany)(() => namespace_entity_1.NamespaceEntity, (namespace) => namespace.pipeline),
127
130
  __metadata("design:type", Array)
128
131
  ], PipelineEntity.prototype, "namespaces", void 0);
132
+ __decorate([
133
+ (0, typeorm_1.ManyToOne)(() => PipelineEntity, (pipeline) => pipeline.children, {
134
+ onDelete: 'CASCADE',
135
+ nullable: true,
136
+ }),
137
+ (0, typeorm_1.JoinColumn)({ name: 'parent_id' }),
138
+ __metadata("design:type", Object)
139
+ ], PipelineEntity.prototype, "parent", void 0);
140
+ __decorate([
141
+ (0, typeorm_1.Column)({ name: 'parent_id', type: 'uuid', nullable: true }),
142
+ __metadata("design:type", Object)
143
+ ], PipelineEntity.prototype, "parentId", void 0);
144
+ __decorate([
145
+ (0, typeorm_1.OneToMany)(() => PipelineEntity, (pipeline) => pipeline.parent),
146
+ __metadata("design:type", Array)
147
+ ], PipelineEntity.prototype, "children", void 0);
129
148
  exports.PipelineEntity = PipelineEntity = __decorate([
130
149
  (0, typeorm_1.Entity)({ name: 'core_pipeline' })
131
150
  ], PipelineEntity);
@@ -1,6 +1,6 @@
1
- import { User } from './user.entity';
2
- import { Permission } from './permission.entity';
3
1
  import { RoleInterface } from '../interfaces';
2
+ import { Permission } from './permission.entity';
3
+ import { User } from './user.entity';
4
4
  export declare class Role implements RoleInterface {
5
5
  id: string;
6
6
  name: string;
@@ -11,8 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Role = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
- const user_entity_1 = require("./user.entity");
15
14
  const permission_entity_1 = require("./permission.entity");
15
+ const user_entity_1 = require("./user.entity");
16
16
  let Role = class Role {
17
17
  id;
18
18
  name;
@@ -34,15 +34,15 @@ __decorate([
34
34
  __metadata("design:type", String)
35
35
  ], Role.prototype, "description", void 0);
36
36
  __decorate([
37
- (0, typeorm_1.ManyToMany)(() => user_entity_1.User, user => user.roles),
37
+ (0, typeorm_1.ManyToMany)(() => user_entity_1.User, (user) => user.roles),
38
38
  __metadata("design:type", Array)
39
39
  ], Role.prototype, "users", void 0);
40
40
  __decorate([
41
- (0, typeorm_1.ManyToMany)(() => permission_entity_1.Permission, permission => permission.roles),
41
+ (0, typeorm_1.ManyToMany)(() => permission_entity_1.Permission, (permission) => permission.roles),
42
42
  (0, typeorm_1.JoinTable)({
43
43
  name: 'auth_role_permissions',
44
44
  joinColumn: { name: 'role_id', referencedColumnName: 'id' },
45
- inverseJoinColumn: { name: 'permission_id', referencedColumnName: 'id' }
45
+ inverseJoinColumn: { name: 'permission_id', referencedColumnName: 'id' },
46
46
  }),
47
47
  __metadata("design:type", Array)
48
48
  ], Role.prototype, "permissions", void 0);
@@ -1,5 +1,5 @@
1
- import { Role } from './role.entity';
2
1
  import { UserTypeEnum } from '../enums/user-type.enum';
2
+ import { Role } from './role.entity';
3
3
  export declare class User {
4
4
  id: string;
5
5
  type: UserTypeEnum;
@@ -11,8 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.User = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
- const role_entity_1 = require("./role.entity");
15
14
  const user_type_enum_1 = require("../enums/user-type.enum");
15
+ const role_entity_1 = require("./role.entity");
16
16
  let User = class User {
17
17
  id;
18
18
  type;
@@ -38,11 +38,11 @@ __decorate([
38
38
  __metadata("design:type", Boolean)
39
39
  ], User.prototype, "isActive", void 0);
40
40
  __decorate([
41
- (0, typeorm_1.ManyToMany)(() => role_entity_1.Role, role => role.users),
41
+ (0, typeorm_1.ManyToMany)(() => role_entity_1.Role, (role) => role.users),
42
42
  (0, typeorm_1.JoinTable)({
43
43
  name: 'auth_user_roles',
44
44
  joinColumn: { name: 'user_id', referencedColumnName: 'id' },
45
- inverseJoinColumn: { name: 'role_id', referencedColumnName: 'id' }
45
+ inverseJoinColumn: { name: 'role_id', referencedColumnName: 'id' },
46
46
  }),
47
47
  __metadata("design:type", Array)
48
48
  ], User.prototype, "roles", void 0);
@@ -1,9 +1,9 @@
1
- import { DocumentEntity } from './document.entity';
2
- import { NamespaceEntity } from './namespace.entity';
3
- import { WorkflowState } from '../enums';
4
- import { TransitionResultLookup } from '../interfaces';
5
1
  import { z } from 'zod';
6
2
  import type { JSONSchemaConfigType, UiFormType, WorkflowTransitionType } from '@loopstack/contracts/types';
3
+ import { WorkflowState } from '../enums';
4
+ import { TransitionResultLookup } from '../interfaces';
5
+ import { DocumentEntity } from './document.entity';
6
+ import { NamespaceEntity } from './namespace.entity';
7
7
  export declare class WorkflowEntity {
8
8
  id: string;
9
9
  blockName: string;
@@ -17,10 +17,10 @@ export declare class WorkflowEntity {
17
17
  updatedAt: Date;
18
18
  place: string;
19
19
  transitionResults: TransitionResultLookup | null;
20
- inputData: Record<string, any>;
21
- result: Record<string, any> | null;
20
+ inputData: Record<string, unknown>;
21
+ result: Record<string, unknown> | null;
22
22
  availableTransitions: WorkflowTransitionType[] | null;
23
- history: any[] | null;
23
+ history: unknown[] | null;
24
24
  schema: JSONSchemaConfigType | null;
25
25
  error: z.ZodError | null;
26
26
  ui: UiFormType | null;
@@ -11,10 +11,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.WorkflowEntity = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
- const document_entity_1 = require("./document.entity");
15
- const namespace_entity_1 = require("./namespace.entity");
16
14
  const enums_1 = require("../enums");
17
15
  const utils_1 = require("../utils");
16
+ const document_entity_1 = require("./document.entity");
17
+ const namespace_entity_1 = require("./namespace.entity");
18
18
  let WorkflowEntity = class WorkflowEntity {
19
19
  id;
20
20
  blockName;
@@ -137,7 +137,7 @@ __decorate([
137
137
  __metadata("design:type", Object)
138
138
  ], WorkflowEntity.prototype, "schema", void 0);
139
139
  __decorate([
140
- (0, typeorm_1.Column)('jsonb', { nullable: true, name: "error" }),
140
+ (0, typeorm_1.Column)('jsonb', { nullable: true, name: 'error' }),
141
141
  __metadata("design:type", Object)
142
142
  ], WorkflowEntity.prototype, "error", void 0);
143
143
  __decorate([
@@ -1,6 +1,7 @@
1
+ import { UserTypeEnum } from '../enums';
1
2
  export interface CurrentUserInterface {
2
3
  userId: string;
3
- type: string;
4
+ type: UserTypeEnum;
4
5
  workerId: string;
5
6
  roles: string[];
6
7
  }
@@ -11,10 +11,8 @@ export interface IApiResponse<T = any> {
11
11
  timestamp: Date;
12
12
  correlationId?: string;
13
13
  }
14
- export interface IGenerateCodeResponse extends IApiResponse<IAuthorizationCodeResponse> {
15
- }
16
- export interface IValidateCodeResponse extends IApiResponse<UserInterface> {
17
- }
14
+ export type IGenerateCodeResponse = IApiResponse<IAuthorizationCodeResponse>;
15
+ export type IValidateCodeResponse = IApiResponse<UserInterface>;
18
16
  export interface IErrorResponse {
19
17
  statusCode: number;
20
18
  message: string;
@@ -1 +1 @@
1
- export declare function normalizeDeepSerializeUtil(obj: any): string;
1
+ export declare function normalizeDeepSerializeUtil(obj: unknown): string;
@@ -9,12 +9,13 @@ function normalizeDeepSerializeUtil(obj) {
9
9
  return JSON.stringify(obj.map(normalizeDeepSerializeUtil).sort());
10
10
  }
11
11
  else if (typeof obj === 'object' && obj !== null) {
12
- return JSON.stringify(Object.keys(obj)
12
+ const record = obj;
13
+ return JSON.stringify(Object.keys(record)
13
14
  .sort()
14
15
  .reduce((result, key) => {
15
- result[key] = normalizeDeepSerializeUtil(obj[key]); // Recursively sort nested objects
16
+ result[key] = normalizeDeepSerializeUtil(record[key]); // Recursively sort nested objects
16
17
  return result;
17
18
  }, {}));
18
19
  }
19
- return obj?.toString();
20
+ return String(obj);
20
21
  }
@@ -1 +1 @@
1
- export declare function normalizeObject(object: Record<string, any>): Record<string, any>;
1
+ export declare function normalizeObject<T extends Record<string, unknown>>(object: T): T;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateObjectFingerprint = void 0;
4
- const normalize_deep_serialize_util_1 = require("./normalize-deep-serialize.util");
5
4
  const create_hash_util_1 = require("./create-hash.util");
5
+ const normalize_deep_serialize_util_1 = require("./normalize-deep-serialize.util");
6
6
  const generateObjectFingerprint = (obj) => {
7
7
  return (0, create_hash_util_1.createHash)((0, normalize_deep_serialize_util_1.normalizeDeepSerializeUtil)(obj));
8
8
  };
@@ -7,11 +7,7 @@ exports.StableJsonTransformer = void 0;
7
7
  const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
8
8
  class StableJsonTransformer {
9
9
  from(value) {
10
- return value
11
- ? typeof value === 'string'
12
- ? JSON.parse(value)
13
- : value
14
- : value;
10
+ return value ? (typeof value === 'string' ? JSON.parse(value) : value) : value;
15
11
  }
16
12
  to(value) {
17
13
  return value !== undefined ? (0, fast_json_stable_stringify_1.default)(value) : value;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@loopstack/common",
3
3
  "displayName": "Loopstack Common Module",
4
4
  "description": "A collection of utils and dtos shared between nestjs modules",
5
- "version": "0.16.0",
5
+ "version": "0.18.0-rc.0",
6
6
  "license": "BSL",
7
7
  "author": {
8
8
  "name": "Jakob Klippel",
@@ -11,27 +11,21 @@
11
11
  "main": "dist/index.js",
12
12
  "types": "dist/index.d.ts",
13
13
  "scripts": {
14
- "build": "tsc -p tsconfig.json",
15
- "watch": "tsc --watch",
16
- "compile": "tsc --noEmit"
17
- },
18
- "peerDependencies": {
19
- "@nestjs/typeorm": "^11.0.0",
20
- "typeorm": "^0.3.25"
21
- },
22
- "devDependencies": {
23
- "@nestjs/common": "^11.0.1",
24
- "@nestjs/typeorm": "^11.0.0",
25
- "@types/node": "^22.13.4",
26
- "typeorm": "^0.3.25",
27
- "typescript": "^5.7.3"
14
+ "build": "nest build",
15
+ "compile": "tsc --noEmit",
16
+ "format": "prettier --write .",
17
+ "lint": "eslint .",
18
+ "watch": "nest build --watch"
28
19
  },
29
20
  "dependencies": {
30
- "@loopstack/contracts": "^0.16.0",
21
+ "@loopstack/contracts": "^0.18.0-rc.0",
31
22
  "fast-json-stable-stringify": "^2.1.0",
32
23
  "murmurhash": "^2.0.1",
33
24
  "reflect-metadata": "^0.2.2",
34
- "yaml": "^2.8.1",
35
- "zod": "^3.25.76"
36
- }
25
+ "yaml": "^2.8.2",
26
+ "zod": "^4.3.5"
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ]
37
31
  }
@@ -1,83 +0,0 @@
1
- name: 'Publish to NPM Workflow'
2
-
3
- on:
4
- push:
5
- tags:
6
- - 'v*.*.*'
7
-
8
- jobs:
9
- publish:
10
- name: 'Build & Publish to NPM'
11
- runs-on: ubuntu-latest
12
- timeout-minutes: 15
13
- permissions:
14
- contents: write
15
- id-token: write
16
- steps:
17
- - name: Checkout Code
18
- uses: actions/checkout@v4
19
- with:
20
- fetch-depth: 0
21
-
22
- - name: Check if tag is on main branch
23
- run: |
24
- git fetch origin main
25
- if ! git branch -r --contains ${{ github.ref }} | grep -q 'origin/main'; then
26
- echo "❌ Tag is not on main branch"
27
- exit 1
28
- fi
29
- echo "✅ Tag is on main branch"
30
-
31
- - name: Setup Node.js
32
- uses: actions/setup-node@v4
33
- with:
34
- node-version: '20'
35
- cache: 'npm'
36
- registry-url: 'https://registry.npmjs.org'
37
-
38
- - name: Extract Package Version
39
- id: package
40
- run: |
41
- echo "name=$(node -p "require('./package.json').name")" >> $GITHUB_OUTPUT
42
- echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
43
-
44
- - name: Validate Version Matches Tag
45
- run: |
46
- TAG_VERSION=${GITHUB_REF#refs/tags/v}
47
- PKG_VERSION=${{ steps.package.outputs.version }}
48
- if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
49
- echo "❌ Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
50
- exit 1
51
- fi
52
- echo "✅ Versions match"
53
-
54
- - name: Install Dependencies
55
- run: npm ci
56
-
57
- - name: Build Package
58
- run: npm run build --if-present
59
-
60
- - name: Publish to NPM
61
- run: npm publish --provenance --access public
62
- env:
63
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
64
-
65
- - name: Create GitHub Release
66
- uses: softprops/action-gh-release@v2
67
- if: success()
68
- with:
69
- tag_name: ${{ github.ref_name }}
70
- body: |
71
- ## 📦 NPM Package
72
-
73
- **Package:** [${{ steps.package.outputs.name }}](https://www.npmjs.com/package/${{ steps.package.outputs.name }}/v/${{ steps.package.outputs.version }})
74
- **Version:** ${{ steps.package.outputs.version }}
75
-
76
- Install with:
77
- ```bash
78
- npm install ${{ steps.package.outputs.name }}@${{ steps.package.outputs.version }}
79
- ```
80
- draft: false
81
- prerelease: false
82
- env:
83
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package/LICENSE DELETED
@@ -1,43 +0,0 @@
1
- Business Source License 1.1
2
-
3
- Parameters
4
- ----------
5
- Licensor: Loopstack GmbH
6
- Licensed Work: Loopstack Shared Module (the "Licensed Work")
7
- Additional Use Grant: You may freely use, copy, modify, and distribute the Licensed Work
8
- for both personal and commercial purposes, subject to the conditions below.
9
- Change Date: Four years after the release date of each version.
10
- Change License: Apache License, Version 2.0
11
-
12
- Terms
13
- -----
14
- 1. License Grant
15
- The Licensed Work is made available under the terms of this Business Source License (the "License").
16
- You are granted the right to use, copy, modify, and distribute the Licensed Work for any
17
- personal or commercial purpose, provided that:
18
-
19
- - You do not provide the Licensed Work to third parties as a managed or hosted service
20
- where the primary value of the service is the Licensed Work itself, or a substantial
21
- substitute for it.
22
- - You comply with attribution requirements by including this License file with any distribution.
23
-
24
- 2. Change License
25
- On the Change Date, each version of the Licensed Work will automatically be
26
- made available under the Change License (Apache License 2.0).
27
-
28
- 3. Contributions
29
- Any contributions to the Licensed Work will be licensed under the terms of this License
30
- until the Change Date, and under the Change License thereafter.
31
-
32
- 4. Disclaimer
33
- The Licensed Work is provided "as is," without warranty of any kind, express or implied.
34
-
35
- Additional Terms
36
- ----------------
37
- - This License does not grant you any rights to use the Licensor's trademarks or brand.
38
- - This License explicitly permits both personal and commercial use of the Licensed Work,
39
- including incorporation into commercial products and services, subject to the restrictions
40
- outlined in Section 1.
41
-
42
- For details on the Apache License 2.0 (effective after the Change Date), see:
43
- https://www.apache.org/licenses/LICENSE-2.0
package/README.md DELETED
@@ -1,7 +0,0 @@
1
- # Loopstack Common Module
2
-
3
- This is a submodule of the **Loopstack** framework.
4
-
5
- For full documentation, contribution guidelines, and to get started with Loopstack, please visit the main repository:
6
-
7
- 👉 [github.com/loopstack-ai/loopstack](https://github.com/loopstack-ai/loopstack)
@@ -1 +0,0 @@
1
- export declare const MODULE_NAME_TOKEN = "MODULE_NAME_TOKEN";
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MODULE_NAME_TOKEN = void 0;
4
- exports.MODULE_NAME_TOKEN = 'MODULE_NAME_TOKEN';
@@ -1,8 +0,0 @@
1
- import { Reflector } from '@nestjs/core';
2
- import { BlockOptions } from '../interfaces';
3
- export declare class BlockConfigService {
4
- private reflector;
5
- constructor(reflector: Reflector);
6
- getMetadata(): BlockOptions;
7
- getConfig(target: object | Function): void;
8
- }
@@ -1,34 +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
- var _a;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.BlockConfigService = void 0;
14
- const common_1 = require("@nestjs/common");
15
- const core_1 = require("@nestjs/core");
16
- const decorators_1 = require("../decorators");
17
- let BlockConfigService = class BlockConfigService {
18
- reflector;
19
- constructor(reflector) {
20
- this.reflector = reflector;
21
- }
22
- getMetadata() {
23
- return this.reflector.get(decorators_1.BLOCK_METADATA_KEY, this.constructor);
24
- }
25
- getConfig(target) {
26
- const constructor = typeof target === 'function' ? target : target.constructor;
27
- const metadata = this.getMetadata();
28
- }
29
- };
30
- exports.BlockConfigService = BlockConfigService;
31
- exports.BlockConfigService = BlockConfigService = __decorate([
32
- (0, common_1.Injectable)(),
33
- __metadata("design:paramtypes", [typeof (_a = typeof core_1.Reflector !== "undefined" && core_1.Reflector) === "function" ? _a : Object])
34
- ], BlockConfigService);