@loopstack/common 0.15.0 → 0.16.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.
@@ -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 --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 }}
@@ -1,2 +1 @@
1
1
  export * from './auth.constants';
2
- export * from './module.constants';
@@ -15,4 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth.constants"), exports);
18
- __exportStar(require("./module.constants"), exports);
@@ -9,6 +9,7 @@ export declare const WORKFLOW_METADATA_KEY: unique symbol;
9
9
  export declare const TEMPLATE_HELPER_METADATA_KEY: unique symbol;
10
10
  export declare function WithArguments<T extends z.ZodType>(schema: T): ClassDecorator;
11
11
  export declare function WithState<T extends z.ZodType>(schema: T): ClassDecorator;
12
+ export declare function WithResult<T extends z.ZodType>(schema: T): ClassDecorator;
12
13
  export declare function BlockConfig(options: BlockOptions): ClassDecorator;
13
14
  export declare function Tool(token?: any): PropertyDecorator & MethodDecorator;
14
15
  export declare function Document(token?: any): PropertyDecorator & MethodDecorator;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
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;
4
4
  exports.WithArguments = WithArguments;
5
5
  exports.WithState = WithState;
6
+ exports.WithResult = WithResult;
6
7
  exports.BlockConfig = BlockConfig;
7
8
  exports.Tool = Tool;
8
9
  exports.Document = Document;
@@ -43,6 +44,12 @@ function WithState(schema) {
43
44
  target.stateSchema = schema;
44
45
  };
45
46
  }
47
+ function WithResult(schema) {
48
+ return (target) => {
49
+ validateStateSchema(schema);
50
+ target.resultSchema = schema;
51
+ };
52
+ }
46
53
  function getTools(target) {
47
54
  const keys = Reflect.getMetadata(exports.TOOL_METADATA_KEY, target.prototype) || [];
48
55
  return keys.map(key => String(key));
@@ -0,0 +1,17 @@
1
+ import { WorkspaceEntity } from "./workspace.entity";
2
+ import { PipelineEntity } from "./pipeline.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 workspace_entity_1 = require("./workspace.entity");
15
+ const pipeline_entity_1 = require("./pipeline.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);
@@ -1,8 +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';
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";
@@ -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);
@@ -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;
@@ -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',
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.0",
5
+ "version": "0.16.0",
6
6
  "license": "BSL",
7
7
  "author": {
8
8
  "name": "Jakob Klippel",
@@ -13,7 +13,6 @@
13
13
  "scripts": {
14
14
  "build": "tsc -p tsconfig.json",
15
15
  "watch": "tsc --watch",
16
- "prepare": "npm run build",
17
16
  "compile": "tsc --noEmit"
18
17
  },
19
18
  "peerDependencies": {
@@ -28,7 +27,7 @@
28
27
  "typescript": "^5.7.3"
29
28
  },
30
29
  "dependencies": {
31
- "@loopstack/contracts": "^0.15.0",
30
+ "@loopstack/contracts": "^0.16.0",
32
31
  "fast-json-stable-stringify": "^2.1.0",
33
32
  "murmurhash": "^2.0.1",
34
33
  "reflect-metadata": "^0.2.2",