@loopstack/common 0.17.0 → 0.18.0-rc.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.
@@ -1,3 +1,4 @@
1
+ import { InjectionToken } from '@nestjs/common';
1
2
  import { z } from 'zod';
2
3
  import { BlockOptions } from '../interfaces';
3
4
  export declare const BLOCK_METADATA_KEY: unique symbol;
@@ -11,17 +12,17 @@ export interface WorkflowOptions {
11
12
  visible?: boolean;
12
13
  }
13
14
  export interface WorkflowDecoratorOptions {
14
- token?: any;
15
+ token?: InjectionToken;
15
16
  options?: WorkflowOptions;
16
17
  }
17
18
  export declare const WORKFLOW_OPTIONS_KEY = "workflow:options";
18
19
  export declare function WithArguments<T extends z.ZodType>(schema: T): ClassDecorator;
19
20
  export declare function WithState<T extends z.ZodType>(schema: T): ClassDecorator;
20
21
  export declare function WithResult<T extends z.ZodType>(schema: T): ClassDecorator;
21
- export declare function getWorkflowOptions(target: any, propertyKey: string | symbol): WorkflowOptions;
22
+ export declare function getWorkflowOptions(target: object, propertyKey: string | symbol): WorkflowOptions;
22
23
  export declare function BlockConfig(options: BlockOptions): ClassDecorator;
23
- export declare function Tool(token?: any): PropertyDecorator & MethodDecorator;
24
- export declare function Document(token?: any): PropertyDecorator & MethodDecorator;
24
+ export declare function Tool(token?: InjectionToken): PropertyDecorator & MethodDecorator;
25
+ export declare function Document(token?: InjectionToken): PropertyDecorator & MethodDecorator;
25
26
  export declare function Workflow(options?: WorkflowDecoratorOptions): PropertyDecorator & MethodDecorator;
26
27
  export declare function Helper(): MethodDecorator;
27
28
  export declare function Input(): PropertyDecorator;
@@ -53,31 +53,38 @@ function WithResult(schema) {
53
53
  };
54
54
  }
55
55
  function getTools(target) {
56
- const keys = Reflect.getMetadata(exports.TOOL_METADATA_KEY, target.prototype) || [];
56
+ const proto = target.prototype;
57
+ const keys = Reflect.getMetadata(exports.TOOL_METADATA_KEY, proto) ?? [];
57
58
  return keys.map((key) => String(key));
58
59
  }
59
60
  function getDocuments(target) {
60
- const keys = Reflect.getMetadata(exports.DOCUMENT_METADATA_KEY, target.prototype) || [];
61
+ const proto = target.prototype;
62
+ const keys = Reflect.getMetadata(exports.DOCUMENT_METADATA_KEY, proto) ?? [];
61
63
  return keys.map((key) => String(key));
62
64
  }
63
65
  function getWorkflows(target) {
64
- const keys = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, target.prototype) || [];
66
+ const proto = target.prototype;
67
+ const keys = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, proto) ?? [];
65
68
  return keys.map((key) => String(key));
66
69
  }
67
70
  function getHelpers(target) {
68
- const keys = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, target.prototype) || [];
71
+ const proto = target.prototype;
72
+ const keys = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, proto) ?? [];
69
73
  return keys.map((key) => String(key));
70
74
  }
71
75
  function getWorkflowOptions(target, propertyKey) {
72
- return Reflect.getMetadata(exports.WORKFLOW_OPTIONS_KEY, target, propertyKey) ?? { visible: true };
76
+ return (Reflect.getMetadata(exports.WORKFLOW_OPTIONS_KEY, target, propertyKey) ?? {
77
+ visible: true,
78
+ });
73
79
  }
74
80
  function BlockConfig(options) {
75
81
  return (target) => {
76
- target.blockConfig = (0, block_config_builder_1.buildConfig)(options);
77
- target.blockTools = getTools(target);
78
- target.blockDocuments = getDocuments(target);
79
- target.blockWorkflows = getWorkflows(target);
80
- 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);
81
88
  Reflect.defineMetadata(exports.BLOCK_METADATA_KEY, options, target);
82
89
  };
83
90
  }
@@ -87,7 +94,7 @@ function Tool(token) {
87
94
  if (type) {
88
95
  (0, common_1.Inject)(type)(target, propertyKey);
89
96
  }
90
- const existingTools = Reflect.getMetadata(exports.TOOL_METADATA_KEY, target) || [];
97
+ const existingTools = Reflect.getMetadata(exports.TOOL_METADATA_KEY, target) ?? [];
91
98
  Reflect.defineMetadata(exports.TOOL_METADATA_KEY, [...existingTools, propertyKey], target);
92
99
  };
93
100
  }
@@ -97,8 +104,8 @@ function Document(token) {
97
104
  if (type) {
98
105
  (0, common_1.Inject)(type)(target, propertyKey);
99
106
  }
100
- const existingTools = Reflect.getMetadata(exports.DOCUMENT_METADATA_KEY, target) || [];
101
- 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);
102
109
  };
103
110
  }
104
111
  function Workflow(options) {
@@ -112,26 +119,26 @@ function Workflow(options) {
112
119
  if (type) {
113
120
  (0, common_1.Inject)(type)(target, propertyKey);
114
121
  }
115
- const existingWorkflows = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, target) || [];
122
+ const existingWorkflows = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, target) ?? [];
116
123
  Reflect.defineMetadata(exports.WORKFLOW_METADATA_KEY, [...existingWorkflows, propertyKey], target);
117
124
  Reflect.defineMetadata(exports.WORKFLOW_OPTIONS_KEY, config, target, propertyKey);
118
125
  };
119
126
  }
120
127
  function Helper() {
121
128
  return (target, propertyKey) => {
122
- const existing = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, target) || [];
129
+ const existing = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, target) ?? [];
123
130
  Reflect.defineMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, [...existing, propertyKey], target);
124
131
  };
125
132
  }
126
133
  function Input() {
127
134
  return (target, propertyKey) => {
128
- const existingInputs = Reflect.getMetadata(exports.INPUT_METADATA_KEY, target) || [];
135
+ const existingInputs = Reflect.getMetadata(exports.INPUT_METADATA_KEY, target) ?? [];
129
136
  Reflect.defineMetadata(exports.INPUT_METADATA_KEY, [...existingInputs, propertyKey], target);
130
137
  };
131
138
  }
132
139
  function Output() {
133
140
  return (target, propertyKey) => {
134
- const existingOutputs = Reflect.getMetadata(exports.OUTPUT_METADATA_KEY, target) || [];
141
+ const existingOutputs = Reflect.getMetadata(exports.OUTPUT_METADATA_KEY, target) ?? [];
135
142
  Reflect.defineMetadata(exports.OUTPUT_METADATA_KEY, [...existingOutputs, propertyKey], target);
136
143
  };
137
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;
@@ -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;
@@ -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
  }
@@ -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;
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.17.0",
5
+ "version": "0.18.0-rc.1",
6
6
  "license": "BSL",
7
7
  "author": {
8
8
  "name": "Jakob Klippel",
@@ -11,47 +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",
14
+ "build": "nest build",
16
15
  "compile": "tsc --noEmit",
16
+ "format": "prettier --write .",
17
17
  "lint": "eslint .",
18
- "format": "prettier --write ."
19
- },
20
- "peerDependencies": {
21
- "@nestjs/typeorm": "^11.0.0",
22
- "typeorm": "^0.3.25"
23
- },
24
- "devDependencies": {
25
- "@eslint/js": "^9.39.1",
26
- "@nestjs/common": "^11.0.1",
27
- "@nestjs/typeorm": "^11.0.0",
28
- "@trivago/prettier-plugin-sort-imports": "^6.0.1",
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",
37
- "typeorm": "^0.3.25",
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
- ]
18
+ "watch": "nest build --watch"
48
19
  },
49
20
  "dependencies": {
50
- "@loopstack/contracts": "^0.16.0",
21
+ "@loopstack/contracts": "^0.18.0-rc.1",
51
22
  "fast-json-stable-stringify": "^2.1.0",
52
23
  "murmurhash": "^2.0.1",
53
24
  "reflect-metadata": "^0.2.2",
54
- "yaml": "^2.8.1",
55
- "zod": "^3.25.76"
56
- }
25
+ "yaml": "^2.8.2",
26
+ "zod": "^4.3.5"
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ]
57
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 --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/.prettierignore DELETED
@@ -1,15 +0,0 @@
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
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)
package/eslint.config.mjs DELETED
@@ -1,21 +0,0 @@
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
- ]);
@@ -1,19 +0,0 @@
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
- };