@loopstack/common 0.15.1 → 0.17.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 (32) hide show
  1. package/.github/workflows/publish-npm.yml +83 -0
  2. package/.prettierignore +15 -0
  3. package/dist/decorators/block.decorator.d.ts +12 -2
  4. package/dist/decorators/block.decorator.js +25 -7
  5. package/dist/entities/document.entity.d.ts +1 -1
  6. package/dist/entities/document.entity.js +2 -2
  7. package/dist/entities/event-subscriber.entity.d.ts +17 -0
  8. package/dist/entities/event-subscriber.entity.js +93 -0
  9. package/dist/entities/index.d.ts +1 -0
  10. package/dist/entities/index.js +1 -0
  11. package/dist/entities/namespace.entity.d.ts +1 -1
  12. package/dist/entities/namespace.entity.js +1 -1
  13. package/dist/entities/permission.entity.d.ts +1 -1
  14. package/dist/entities/permission.entity.js +1 -1
  15. package/dist/entities/pipeline.entity.d.ts +6 -3
  16. package/dist/entities/pipeline.entity.js +22 -3
  17. package/dist/entities/role.entity.d.ts +2 -2
  18. package/dist/entities/role.entity.js +4 -4
  19. package/dist/entities/user.entity.d.ts +1 -1
  20. package/dist/entities/user.entity.js +3 -3
  21. package/dist/entities/workflow.entity.d.ts +5 -4
  22. package/dist/entities/workflow.entity.js +12 -3
  23. package/dist/interfaces/sso-response.interface.d.ts +2 -4
  24. package/dist/utils/object-fingerprint.util.js +1 -1
  25. package/dist/utils/stable-json-transformer.js +1 -5
  26. package/eslint.config.mjs +21 -0
  27. package/package.json +24 -5
  28. package/prettier.config.mjs +19 -0
  29. package/dist/constants/module.constants.d.ts +0 -1
  30. package/dist/constants/module.constants.js +0 -4
  31. package/dist/services/block-config-service.d.ts +0 -8
  32. package/dist/services/block-config-service.js +0 -34
@@ -0,0 +1,83 @@
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 --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 }}
@@ -0,0 +1,15 @@
1
+ # Build output
2
+ dist
3
+
4
+ # Dependencies
5
+ node_modules
6
+
7
+ # Lock files
8
+ pnpm-lock.yaml
9
+
10
+ # Minified files
11
+ *.min.js
12
+ *.min.css
13
+
14
+ # Auto-generated
15
+ src/components/ui
@@ -1,5 +1,5 @@
1
- import { BlockOptions } from '../interfaces';
2
1
  import { z } from 'zod';
2
+ import { BlockOptions } from '../interfaces';
3
3
  export declare const BLOCK_METADATA_KEY: unique symbol;
4
4
  export declare const INPUT_METADATA_KEY: unique symbol;
5
5
  export declare const OUTPUT_METADATA_KEY: unique symbol;
@@ -7,12 +7,22 @@ export declare const TOOL_METADATA_KEY: unique symbol;
7
7
  export declare const DOCUMENT_METADATA_KEY: unique symbol;
8
8
  export declare const WORKFLOW_METADATA_KEY: unique symbol;
9
9
  export declare const TEMPLATE_HELPER_METADATA_KEY: unique symbol;
10
+ export interface WorkflowOptions {
11
+ visible?: boolean;
12
+ }
13
+ export interface WorkflowDecoratorOptions {
14
+ token?: any;
15
+ options?: WorkflowOptions;
16
+ }
17
+ export declare const WORKFLOW_OPTIONS_KEY = "workflow:options";
10
18
  export declare function WithArguments<T extends z.ZodType>(schema: T): ClassDecorator;
11
19
  export declare function WithState<T extends z.ZodType>(schema: T): ClassDecorator;
20
+ export declare function WithResult<T extends z.ZodType>(schema: T): ClassDecorator;
21
+ export declare function getWorkflowOptions(target: any, propertyKey: string | symbol): WorkflowOptions;
12
22
  export declare function BlockConfig(options: BlockOptions): ClassDecorator;
13
23
  export declare function Tool(token?: any): PropertyDecorator & MethodDecorator;
14
24
  export declare function Document(token?: any): PropertyDecorator & MethodDecorator;
15
- export declare function Workflow(token?: any): PropertyDecorator & MethodDecorator;
25
+ export declare function Workflow(options?: WorkflowDecoratorOptions): PropertyDecorator & MethodDecorator;
16
26
  export declare function Helper(): MethodDecorator;
17
27
  export declare function Input(): PropertyDecorator;
18
28
  export declare function Output(): PropertyDecorator;
@@ -1,8 +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
+ exports.WithResult = WithResult;
7
+ exports.getWorkflowOptions = getWorkflowOptions;
6
8
  exports.BlockConfig = BlockConfig;
7
9
  exports.Tool = Tool;
8
10
  exports.Document = Document;
@@ -11,8 +13,8 @@ exports.Helper = Helper;
11
13
  exports.Input = Input;
12
14
  exports.Output = Output;
13
15
  const common_1 = require("@nestjs/common");
14
- const block_config_builder_1 = require("../utils/block-config.builder");
15
16
  const zod_1 = require("zod");
17
+ const block_config_builder_1 = require("../utils/block-config.builder");
16
18
  exports.BLOCK_METADATA_KEY = Symbol('block');
17
19
  exports.INPUT_METADATA_KEY = Symbol('input');
18
20
  exports.OUTPUT_METADATA_KEY = Symbol('output');
@@ -20,6 +22,7 @@ exports.TOOL_METADATA_KEY = Symbol('tool');
20
22
  exports.DOCUMENT_METADATA_KEY = Symbol('document');
21
23
  exports.WORKFLOW_METADATA_KEY = Symbol('workflow');
22
24
  exports.TEMPLATE_HELPER_METADATA_KEY = Symbol('templateHelper');
25
+ exports.WORKFLOW_OPTIONS_KEY = 'workflow:options';
23
26
  function WithArguments(schema) {
24
27
  return (target) => {
25
28
  target.argsSchema = schema;
@@ -43,21 +46,30 @@ function WithState(schema) {
43
46
  target.stateSchema = schema;
44
47
  };
45
48
  }
49
+ function WithResult(schema) {
50
+ return (target) => {
51
+ validateStateSchema(schema);
52
+ target.resultSchema = schema;
53
+ };
54
+ }
46
55
  function getTools(target) {
47
56
  const keys = Reflect.getMetadata(exports.TOOL_METADATA_KEY, target.prototype) || [];
48
- return keys.map(key => String(key));
57
+ return keys.map((key) => String(key));
49
58
  }
50
59
  function getDocuments(target) {
51
60
  const keys = Reflect.getMetadata(exports.DOCUMENT_METADATA_KEY, target.prototype) || [];
52
- return keys.map(key => String(key));
61
+ return keys.map((key) => String(key));
53
62
  }
54
63
  function getWorkflows(target) {
55
64
  const keys = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, target.prototype) || [];
56
- return keys.map(key => String(key));
65
+ return keys.map((key) => String(key));
57
66
  }
58
67
  function getHelpers(target) {
59
68
  const keys = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, target.prototype) || [];
60
- return keys.map(key => String(key));
69
+ return keys.map((key) => String(key));
70
+ }
71
+ function getWorkflowOptions(target, propertyKey) {
72
+ return Reflect.getMetadata(exports.WORKFLOW_OPTIONS_KEY, target, propertyKey) ?? { visible: true };
61
73
  }
62
74
  function BlockConfig(options) {
63
75
  return (target) => {
@@ -89,14 +101,20 @@ function Document(token) {
89
101
  Reflect.defineMetadata(exports.DOCUMENT_METADATA_KEY, [...existingTools, propertyKey], target);
90
102
  };
91
103
  }
92
- function Workflow(token) {
104
+ function Workflow(options) {
93
105
  return (target, propertyKey) => {
106
+ const token = options?.token;
107
+ const config = {
108
+ visible: true,
109
+ ...options?.options,
110
+ };
94
111
  const type = token ?? Reflect.getMetadata('design:type', target, propertyKey);
95
112
  if (type) {
96
113
  (0, common_1.Inject)(type)(target, propertyKey);
97
114
  }
98
115
  const existingWorkflows = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, target) || [];
99
116
  Reflect.defineMetadata(exports.WORKFLOW_METADATA_KEY, [...existingWorkflows, propertyKey], target);
117
+ Reflect.defineMetadata(exports.WORKFLOW_OPTIONS_KEY, config, target, propertyKey);
100
118
  };
101
119
  }
102
120
  function Helper() {
@@ -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([
@@ -0,0 +1,17 @@
1
+ import { PipelineEntity } from './pipeline.entity';
2
+ import { WorkspaceEntity } from './workspace.entity';
3
+ export declare class EventSubscriberEntity {
4
+ id: string;
5
+ subscriberPipeline: PipelineEntity;
6
+ subscriberPipelineId: string;
7
+ subscriberWorkflowId: string;
8
+ subscriberTransition: string;
9
+ eventPipelineId: string;
10
+ eventName: string;
11
+ createdAt: Date;
12
+ updatedAt: Date;
13
+ workspace: WorkspaceEntity;
14
+ workspaceId: string;
15
+ userId: string;
16
+ once: boolean;
17
+ }
@@ -0,0 +1,93 @@
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.EventSubscriberEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const pipeline_entity_1 = require("./pipeline.entity");
15
+ const workspace_entity_1 = require("./workspace.entity");
16
+ let EventSubscriberEntity = class EventSubscriberEntity {
17
+ id;
18
+ subscriberPipeline;
19
+ subscriberPipelineId;
20
+ subscriberWorkflowId;
21
+ subscriberTransition;
22
+ eventPipelineId;
23
+ eventName;
24
+ createdAt;
25
+ updatedAt;
26
+ workspace;
27
+ workspaceId;
28
+ userId;
29
+ once;
30
+ };
31
+ exports.EventSubscriberEntity = EventSubscriberEntity;
32
+ __decorate([
33
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
34
+ __metadata("design:type", String)
35
+ ], EventSubscriberEntity.prototype, "id", void 0);
36
+ __decorate([
37
+ (0, typeorm_1.ManyToOne)(() => pipeline_entity_1.PipelineEntity, { onDelete: 'CASCADE' }),
38
+ (0, typeorm_1.JoinColumn)({ name: 'subscriber_pipeline_id' }),
39
+ __metadata("design:type", pipeline_entity_1.PipelineEntity)
40
+ ], EventSubscriberEntity.prototype, "subscriberPipeline", void 0);
41
+ __decorate([
42
+ (0, typeorm_1.Column)({ type: 'uuid', name: 'subscriber_pipeline_id' }),
43
+ (0, typeorm_1.Index)(),
44
+ __metadata("design:type", String)
45
+ ], EventSubscriberEntity.prototype, "subscriberPipelineId", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.Column)({ type: 'uuid', name: 'subscriber_workflow_id' }),
48
+ __metadata("design:type", String)
49
+ ], EventSubscriberEntity.prototype, "subscriberWorkflowId", void 0);
50
+ __decorate([
51
+ (0, typeorm_1.Column)({ type: 'varchar', name: 'subscriber_transition' }),
52
+ __metadata("design:type", String)
53
+ ], EventSubscriberEntity.prototype, "subscriberTransition", void 0);
54
+ __decorate([
55
+ (0, typeorm_1.Column)({ type: 'uuid', name: 'event_pipeline_id' }),
56
+ (0, typeorm_1.Index)(),
57
+ __metadata("design:type", String)
58
+ ], EventSubscriberEntity.prototype, "eventPipelineId", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.Column)({ type: 'varchar', name: 'event_name' }),
61
+ (0, typeorm_1.Index)(),
62
+ __metadata("design:type", String)
63
+ ], EventSubscriberEntity.prototype, "eventName", void 0);
64
+ __decorate([
65
+ (0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
66
+ __metadata("design:type", Date)
67
+ ], EventSubscriberEntity.prototype, "createdAt", void 0);
68
+ __decorate([
69
+ (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at' }),
70
+ __metadata("design:type", Date)
71
+ ], EventSubscriberEntity.prototype, "updatedAt", void 0);
72
+ __decorate([
73
+ (0, typeorm_1.ManyToOne)(() => workspace_entity_1.WorkspaceEntity, { onDelete: 'CASCADE' }),
74
+ (0, typeorm_1.JoinColumn)({ name: 'workspace_id' }),
75
+ __metadata("design:type", workspace_entity_1.WorkspaceEntity)
76
+ ], EventSubscriberEntity.prototype, "workspace", void 0);
77
+ __decorate([
78
+ (0, typeorm_1.Column)({ name: 'workspace_id', nullable: true }),
79
+ __metadata("design:type", String)
80
+ ], EventSubscriberEntity.prototype, "workspaceId", void 0);
81
+ __decorate([
82
+ (0, typeorm_1.Column)({ name: 'user_id', type: 'uuid' }),
83
+ __metadata("design:type", String)
84
+ ], EventSubscriberEntity.prototype, "userId", void 0);
85
+ __decorate([
86
+ (0, typeorm_1.Column)({ name: 'once', type: 'boolean', default: true }),
87
+ __metadata("design:type", Boolean)
88
+ ], EventSubscriberEntity.prototype, "once", void 0);
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'])
93
+ ], EventSubscriberEntity);
@@ -6,3 +6,4 @@ export * from './namespace.entity.js';
6
6
  export * from './permission.entity.js';
7
7
  export * from './role.entity.js';
8
8
  export * from './user.entity.js';
9
+ export * from './event-subscriber.entity.js';
@@ -22,3 +22,4 @@ __exportStar(require("./namespace.entity.js"), exports);
22
22
  __exportStar(require("./permission.entity.js"), exports);
23
23
  __exportStar(require("./role.entity.js"), exports);
24
24
  __exportStar(require("./user.entity.js"), exports);
25
+ __exportStar(require("./event-subscriber.entity.js"), exports);
@@ -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;
@@ -18,6 +18,7 @@ export declare class WorkflowEntity {
18
18
  place: string;
19
19
  transitionResults: TransitionResultLookup | null;
20
20
  inputData: Record<string, any>;
21
+ result: Record<string, any> | null;
21
22
  availableTransitions: WorkflowTransitionType[] | null;
22
23
  history: any[] | null;
23
24
  schema: JSONSchemaConfigType | 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;
@@ -29,6 +29,7 @@ let WorkflowEntity = class WorkflowEntity {
29
29
  place;
30
30
  transitionResults;
31
31
  inputData;
32
+ result;
32
33
  availableTransitions;
33
34
  history; //todo should be WorkflowMementoDto[]
34
35
  schema;
@@ -107,6 +108,14 @@ __decorate([
107
108
  }),
108
109
  __metadata("design:type", Object)
109
110
  ], WorkflowEntity.prototype, "inputData", void 0);
111
+ __decorate([
112
+ (0, typeorm_1.Column)({
113
+ type: 'jsonb',
114
+ name: 'result',
115
+ nullable: true,
116
+ }),
117
+ __metadata("design:type", Object)
118
+ ], WorkflowEntity.prototype, "result", void 0);
110
119
  __decorate([
111
120
  (0, typeorm_1.Column)('jsonb', {
112
121
  name: 'available_transitions',
@@ -128,7 +137,7 @@ __decorate([
128
137
  __metadata("design:type", Object)
129
138
  ], WorkflowEntity.prototype, "schema", void 0);
130
139
  __decorate([
131
- (0, typeorm_1.Column)('jsonb', { nullable: true, name: "error" }),
140
+ (0, typeorm_1.Column)('jsonb', { nullable: true, name: 'error' }),
132
141
  __metadata("design:type", Object)
133
142
  ], WorkflowEntity.prototype, "error", void 0);
134
143
  __decorate([
@@ -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,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;
@@ -0,0 +1,21 @@
1
+ import js from '@eslint/js';
2
+ import prettier from 'eslint-plugin-prettier/recommended';
3
+ import { defineConfig, globalIgnores } from 'eslint/config';
4
+ import globals from 'globals';
5
+ import tseslint from 'typescript-eslint';
6
+
7
+ export default defineConfig([
8
+ globalIgnores(['dist', 'src/components/ai-elements']),
9
+ {
10
+ files: ['**/*.{ts,tsx}'],
11
+ extends: [js.configs.recommended, tseslint.configs.recommended, prettier],
12
+ languageOptions: {
13
+ ecmaVersion: 2020,
14
+ globals: globals.browser,
15
+ },
16
+ rules: {
17
+ //for now we ignore this, fix later
18
+ '@typescript-eslint/no-explicit-any': 'off',
19
+ },
20
+ },
21
+ ]);
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.15.1",
5
+ "version": "0.17.0",
6
6
  "license": "BSL",
7
7
  "author": {
8
8
  "name": "Jakob Klippel",
@@ -13,22 +13,41 @@
13
13
  "scripts": {
14
14
  "build": "tsc -p tsconfig.json",
15
15
  "watch": "tsc --watch",
16
- "prepare": "npm run build",
17
- "compile": "tsc --noEmit"
16
+ "compile": "tsc --noEmit",
17
+ "lint": "eslint .",
18
+ "format": "prettier --write ."
18
19
  },
19
20
  "peerDependencies": {
20
21
  "@nestjs/typeorm": "^11.0.0",
21
22
  "typeorm": "^0.3.25"
22
23
  },
23
24
  "devDependencies": {
25
+ "@eslint/js": "^9.39.1",
24
26
  "@nestjs/common": "^11.0.1",
25
27
  "@nestjs/typeorm": "^11.0.0",
28
+ "@trivago/prettier-plugin-sort-imports": "^6.0.1",
26
29
  "@types/node": "^22.13.4",
30
+ "eslint": "^9.39.1",
31
+ "eslint-config-prettier": "^10.1.5",
32
+ "eslint-plugin-prettier": "^5.4.1",
33
+ "globals": "^16.5.0",
34
+ "husky": "^9.1.7",
35
+ "lint-staged": "^16.2.7",
36
+ "prettier": "^3.7.4",
27
37
  "typeorm": "^0.3.25",
28
- "typescript": "^5.7.3"
38
+ "typescript": "^5.7.3",
39
+ "typescript-eslint": "^8.46.3"
40
+ },
41
+ "lint-staged": {
42
+ "*.{ts,tsx}": [
43
+ "eslint"
44
+ ],
45
+ "*.{json,md,css,yaml,yml}": [
46
+ "prettier --check"
47
+ ]
29
48
  },
30
49
  "dependencies": {
31
- "@loopstack/contracts": "^0.15.0",
50
+ "@loopstack/contracts": "^0.16.0",
32
51
  "fast-json-stable-stringify": "^2.1.0",
33
52
  "murmurhash": "^2.0.1",
34
53
  "reflect-metadata": "^0.2.2",
@@ -0,0 +1,19 @@
1
+ export default {
2
+ plugins: ['@trivago/prettier-plugin-sort-imports'],
3
+ importOrder: [
4
+ '<THIRD_PARTY_MODULES>', // Imports not matched by other special phrases
5
+ '^@loopstack/(.*)$', // Internal packages
6
+ '^@/(.*)$', // Path aliases
7
+ '^[./]', // Relative imports
8
+ ],
9
+ importOrderSortSpecifiers: true,
10
+ importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'],
11
+ printWidth: 120,
12
+ singleQuote: true,
13
+ trailingComma: 'all',
14
+ semi: true,
15
+ tabWidth: 2,
16
+ bracketSpacing: true,
17
+ arrowParens: 'always',
18
+ endOfLine: 'lf',
19
+ };
@@ -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);