@loopstack/contracts 0.14.1 → 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 --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 }}
@@ -585,9 +585,10 @@ export declare const BlockConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
585
585
  type: z.ZodDefault<z.ZodLiteral<"workflow">>;
586
586
  transitions: z.ZodOptional<z.ZodArray<z.ZodObject<{
587
587
  id: z.ZodString;
588
- from: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
589
- to: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
590
- when: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["manual", "onEntry"]>, z.ZodString]>>;
588
+ from: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
589
+ to: z.ZodString;
590
+ if: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodString, z.ZodLiteral<"true">, z.ZodLiteral<"false">]>>;
591
+ trigger: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["manual", "onEntry"]>, z.ZodString]>>;
591
592
  call: z.ZodOptional<z.ZodArray<z.ZodObject<{
592
593
  id: z.ZodOptional<z.ZodString>;
593
594
  tool: z.ZodString;
@@ -605,11 +606,12 @@ export declare const BlockConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
605
606
  assign?: Record<string, string | number | boolean | Record<string, any> | null> | undefined;
606
607
  }>, "many">>;
607
608
  onError: z.ZodOptional<z.ZodString>;
608
- }, "strip", z.ZodTypeAny, {
609
+ }, "strict", z.ZodTypeAny, {
609
610
  id: string;
610
- from?: string | string[] | undefined;
611
- to?: string | string[] | undefined;
612
- when?: string | undefined;
611
+ from: string | string[];
612
+ to: string;
613
+ if?: string | undefined;
614
+ trigger?: string | undefined;
613
615
  call?: {
614
616
  tool: string;
615
617
  id?: string | undefined;
@@ -619,9 +621,10 @@ export declare const BlockConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
619
621
  onError?: string | undefined;
620
622
  }, {
621
623
  id: string;
622
- from?: string | string[] | undefined;
623
- to?: string | string[] | undefined;
624
- when?: string | undefined;
624
+ from: string | string[];
625
+ to: string;
626
+ if?: string | undefined;
627
+ trigger?: string | undefined;
625
628
  call?: {
626
629
  tool: string;
627
630
  id?: string | undefined;
@@ -659,9 +662,10 @@ export declare const BlockConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
659
662
  } | undefined;
660
663
  transitions?: {
661
664
  id: string;
662
- from?: string | string[] | undefined;
663
- to?: string | string[] | undefined;
664
- when?: string | undefined;
665
+ from: string | string[];
666
+ to: string;
667
+ if?: string | undefined;
668
+ trigger?: string | undefined;
665
669
  call?: {
666
670
  tool: string;
667
671
  id?: string | undefined;
@@ -699,9 +703,10 @@ export declare const BlockConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
699
703
  } | undefined;
700
704
  transitions?: {
701
705
  id: string;
702
- from?: string | string[] | undefined;
703
- to?: string | string[] | undefined;
704
- when?: string | undefined;
706
+ from: string | string[];
707
+ to: string;
708
+ if?: string | undefined;
709
+ trigger?: string | undefined;
705
710
  call?: {
706
711
  tool: string;
707
712
  id?: string | undefined;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- export declare const ToolCallSchema: z.ZodObject<{
2
+ export declare const ToolCallConfigSchema: z.ZodObject<{
3
3
  id: z.ZodOptional<z.ZodString>;
4
4
  tool: z.ZodString;
5
5
  args: z.ZodOptional<z.ZodAny>;
@@ -15,3 +15,19 @@ export declare const ToolCallSchema: z.ZodObject<{
15
15
  args?: any;
16
16
  assign?: Record<string, string | number | boolean | Record<string, any> | null> | undefined;
17
17
  }>;
18
+ export declare const ToolCallSchema: z.ZodObject<{
19
+ id: z.ZodOptional<z.ZodString>;
20
+ tool: z.ZodString;
21
+ args: z.ZodOptional<z.ZodAny>;
22
+ assign: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodNull, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodAny>]>>>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ tool: string;
25
+ id?: string | undefined;
26
+ args?: any;
27
+ assign?: Record<string, string | number | boolean | Record<string, any> | null> | undefined;
28
+ }, {
29
+ tool: string;
30
+ id?: string | undefined;
31
+ args?: any;
32
+ assign?: Record<string, string | number | boolean | Record<string, any> | null> | undefined;
33
+ }>;
@@ -1,11 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToolCallSchema = void 0;
3
+ exports.ToolCallSchema = exports.ToolCallConfigSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const assignment_schema_1 = require("./assignment.schema");
6
- exports.ToolCallSchema = zod_1.z.object({
6
+ exports.ToolCallConfigSchema = zod_1.z.object({
7
7
  id: zod_1.z.string().optional(),
8
8
  tool: zod_1.z.string(),
9
9
  args: zod_1.z.any().optional(),
10
10
  assign: assignment_schema_1.AssignmentConfigSchema.optional(),
11
11
  });
12
+ exports.ToolCallSchema = zod_1.z.object({
13
+ id: zod_1.z.string().optional(),
14
+ tool: zod_1.z.string(),
15
+ args: zod_1.z.any().optional(),
16
+ assign: assignment_schema_1.AssignmentSchema.optional(),
17
+ });
@@ -1,9 +1,10 @@
1
1
  import { z } from 'zod';
2
- export declare const WorkflowTransitionSchema: z.ZodObject<{
2
+ export declare const WorkflowTransitionConfigSchema: z.ZodObject<{
3
3
  id: z.ZodString;
4
- from: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
5
- to: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
6
- when: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["manual", "onEntry"]>, z.ZodString]>>;
4
+ from: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
5
+ to: z.ZodString;
6
+ if: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodString, z.ZodLiteral<"true">, z.ZodLiteral<"false">]>>;
7
+ trigger: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["manual", "onEntry"]>, z.ZodString]>>;
7
8
  call: z.ZodOptional<z.ZodArray<z.ZodObject<{
8
9
  id: z.ZodOptional<z.ZodString>;
9
10
  tool: z.ZodString;
@@ -21,11 +22,62 @@ export declare const WorkflowTransitionSchema: z.ZodObject<{
21
22
  assign?: Record<string, string | number | boolean | Record<string, any> | null> | undefined;
22
23
  }>, "many">>;
23
24
  onError: z.ZodOptional<z.ZodString>;
24
- }, "strip", z.ZodTypeAny, {
25
+ }, "strict", z.ZodTypeAny, {
26
+ id: string;
27
+ from: string | string[];
28
+ to: string;
29
+ if?: string | undefined;
30
+ trigger?: string | undefined;
31
+ call?: {
32
+ tool: string;
33
+ id?: string | undefined;
34
+ args?: any;
35
+ assign?: Record<string, string | number | boolean | Record<string, any> | null> | undefined;
36
+ }[] | undefined;
37
+ onError?: string | undefined;
38
+ }, {
39
+ id: string;
40
+ from: string | string[];
41
+ to: string;
42
+ if?: string | undefined;
43
+ trigger?: string | undefined;
44
+ call?: {
45
+ tool: string;
46
+ id?: string | undefined;
47
+ args?: any;
48
+ assign?: Record<string, string | number | boolean | Record<string, any> | null> | undefined;
49
+ }[] | undefined;
50
+ onError?: string | undefined;
51
+ }>;
52
+ export declare const WorkflowTransitionSchema: z.ZodObject<{
53
+ id: z.ZodString;
54
+ from: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
55
+ to: z.ZodString;
56
+ if: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<"true">, z.ZodLiteral<"false">]>>;
57
+ trigger: z.ZodOptional<z.ZodEnum<["manual", "onEntry"]>>;
58
+ call: z.ZodOptional<z.ZodArray<z.ZodObject<{
59
+ id: z.ZodOptional<z.ZodString>;
60
+ tool: z.ZodString;
61
+ args: z.ZodOptional<z.ZodAny>;
62
+ assign: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodNull, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodAny>]>>>;
63
+ }, "strip", z.ZodTypeAny, {
64
+ tool: string;
65
+ id?: string | undefined;
66
+ args?: any;
67
+ assign?: Record<string, string | number | boolean | Record<string, any> | null> | undefined;
68
+ }, {
69
+ tool: string;
70
+ id?: string | undefined;
71
+ args?: any;
72
+ assign?: Record<string, string | number | boolean | Record<string, any> | null> | undefined;
73
+ }>, "many">>;
74
+ onError: z.ZodOptional<z.ZodString>;
75
+ }, "strict", z.ZodTypeAny, {
25
76
  id: string;
26
- from?: string | string[] | undefined;
27
- to?: string | string[] | undefined;
28
- when?: string | undefined;
77
+ from: string | string[];
78
+ to: string;
79
+ if?: string | undefined;
80
+ trigger?: "manual" | "onEntry" | undefined;
29
81
  call?: {
30
82
  tool: string;
31
83
  id?: string | undefined;
@@ -35,9 +87,10 @@ export declare const WorkflowTransitionSchema: z.ZodObject<{
35
87
  onError?: string | undefined;
36
88
  }, {
37
89
  id: string;
38
- from?: string | string[] | undefined;
39
- to?: string | string[] | undefined;
40
- when?: string | undefined;
90
+ from: string | string[];
91
+ to: string;
92
+ if?: string | undefined;
93
+ trigger?: "manual" | "onEntry" | undefined;
41
94
  call?: {
42
95
  tool: string;
43
96
  id?: string | undefined;
@@ -1,17 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkflowTransitionSchema = void 0;
3
+ exports.WorkflowTransitionSchema = exports.WorkflowTransitionConfigSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const tool_call_schema_1 = require("./tool-call.schema");
6
6
  const template_expression_schema_1 = require("./template-expression.schema");
7
- exports.WorkflowTransitionSchema = zod_1.z.object({
7
+ exports.WorkflowTransitionConfigSchema = zod_1.z.object({
8
8
  id: zod_1.z.string(),
9
- from: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]).optional(),
10
- to: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]).optional(),
11
- when: zod_1.z.union([
9
+ from: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]),
10
+ to: zod_1.z.string(),
11
+ if: zod_1.z.union([template_expression_schema_1.TemplateExpression, zod_1.z.string(), zod_1.z.literal('true'), zod_1.z.literal('false')]).optional(),
12
+ trigger: zod_1.z.union([
12
13
  zod_1.z.enum(["manual", "onEntry"]),
13
14
  template_expression_schema_1.TemplateExpression,
14
15
  ]).optional(),
16
+ call: zod_1.z.array(tool_call_schema_1.ToolCallConfigSchema).optional(),
17
+ onError: zod_1.z.string().optional(),
18
+ }).strict();
19
+ exports.WorkflowTransitionSchema = zod_1.z.object({
20
+ id: zod_1.z.string(),
21
+ from: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]),
22
+ to: zod_1.z.string(),
23
+ if: zod_1.z.union([zod_1.z.string(), zod_1.z.literal('true'), zod_1.z.literal('false')]).optional(),
24
+ trigger: zod_1.z.enum(["manual", "onEntry"]).optional(),
15
25
  call: zod_1.z.array(tool_call_schema_1.ToolCallSchema).optional(),
16
26
  onError: zod_1.z.string().optional(),
17
- });
27
+ }).strict();
@@ -311,9 +311,10 @@ export declare const WorkflowSchema: z.ZodObject<{
311
311
  type: z.ZodDefault<z.ZodLiteral<"workflow">>;
312
312
  transitions: z.ZodOptional<z.ZodArray<z.ZodObject<{
313
313
  id: z.ZodString;
314
- from: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
315
- to: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
316
- when: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["manual", "onEntry"]>, z.ZodString]>>;
314
+ from: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
315
+ to: z.ZodString;
316
+ if: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodString, z.ZodLiteral<"true">, z.ZodLiteral<"false">]>>;
317
+ trigger: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["manual", "onEntry"]>, z.ZodString]>>;
317
318
  call: z.ZodOptional<z.ZodArray<z.ZodObject<{
318
319
  id: z.ZodOptional<z.ZodString>;
319
320
  tool: z.ZodString;
@@ -331,11 +332,12 @@ export declare const WorkflowSchema: z.ZodObject<{
331
332
  assign?: Record<string, string | number | boolean | Record<string, any> | null> | undefined;
332
333
  }>, "many">>;
333
334
  onError: z.ZodOptional<z.ZodString>;
334
- }, "strip", z.ZodTypeAny, {
335
+ }, "strict", z.ZodTypeAny, {
335
336
  id: string;
336
- from?: string | string[] | undefined;
337
- to?: string | string[] | undefined;
338
- when?: string | undefined;
337
+ from: string | string[];
338
+ to: string;
339
+ if?: string | undefined;
340
+ trigger?: string | undefined;
339
341
  call?: {
340
342
  tool: string;
341
343
  id?: string | undefined;
@@ -345,9 +347,10 @@ export declare const WorkflowSchema: z.ZodObject<{
345
347
  onError?: string | undefined;
346
348
  }, {
347
349
  id: string;
348
- from?: string | string[] | undefined;
349
- to?: string | string[] | undefined;
350
- when?: string | undefined;
350
+ from: string | string[];
351
+ to: string;
352
+ if?: string | undefined;
353
+ trigger?: string | undefined;
351
354
  call?: {
352
355
  tool: string;
353
356
  id?: string | undefined;
@@ -385,9 +388,10 @@ export declare const WorkflowSchema: z.ZodObject<{
385
388
  } | undefined;
386
389
  transitions?: {
387
390
  id: string;
388
- from?: string | string[] | undefined;
389
- to?: string | string[] | undefined;
390
- when?: string | undefined;
391
+ from: string | string[];
392
+ to: string;
393
+ if?: string | undefined;
394
+ trigger?: string | undefined;
391
395
  call?: {
392
396
  tool: string;
393
397
  id?: string | undefined;
@@ -425,9 +429,10 @@ export declare const WorkflowSchema: z.ZodObject<{
425
429
  } | undefined;
426
430
  transitions?: {
427
431
  id: string;
428
- from?: string | string[] | undefined;
429
- to?: string | string[] | undefined;
430
- when?: string | undefined;
432
+ from: string | string[];
433
+ to: string;
434
+ if?: string | undefined;
435
+ trigger?: string | undefined;
431
436
  call?: {
432
437
  tool: string;
433
438
  id?: string | undefined;
@@ -15,5 +15,5 @@ exports.WorkflowBaseSchema = block_schema_1.BlockSchema.extend({
15
15
  });
16
16
  exports.WorkflowSchema = exports.WorkflowBaseSchema.extend({
17
17
  type: zod_1.z.literal('workflow').default('workflow'),
18
- transitions: zod_1.z.array(workflow_transition_schema_1.WorkflowTransitionSchema).optional(),
18
+ transitions: zod_1.z.array(workflow_transition_schema_1.WorkflowTransitionConfigSchema).optional(),
19
19
  });
@@ -3,7 +3,7 @@ import { UiFormType } from '../types/ui-form.type';
3
3
  export interface DocumentItemInterface {
4
4
  id: string;
5
5
  name: string;
6
- configKey: string;
6
+ blockName: string;
7
7
  content: any;
8
8
  schema: JSONSchemaConfigType;
9
9
  validationError: any;
@@ -1,6 +1,6 @@
1
1
  import { JSONSchemaConfigType, UiFormType } from '../types';
2
2
  export interface PipelineConfigInterface {
3
- configKey: string;
3
+ blockName: string;
4
4
  title?: string;
5
5
  description?: string;
6
6
  schema?: JSONSchemaConfigType;
@@ -1,6 +1,6 @@
1
1
  export interface TransitionInfoInterface {
2
2
  id: string;
3
3
  from: string;
4
- to: string | string[];
4
+ to: string;
5
5
  onError?: string;
6
6
  }
@@ -5,7 +5,7 @@ import { UiFormType } from '../types/ui-form.type';
5
5
  import { WorkflowTransitionType } from '../types/workflow-transition.type';
6
6
  export interface WorkflowInterface {
7
7
  id: string;
8
- configKey: string;
8
+ blockName: string;
9
9
  title: string;
10
10
  index: number;
11
11
  labels: string[];
@@ -1,3 +1,3 @@
1
1
  import { z } from 'zod';
2
- import { ToolCallSchema } from '../../schemas';
3
- export type ToolCallType = z.infer<typeof ToolCallSchema>;
2
+ import { ToolCallConfigSchema } from '../../schemas';
3
+ export type ToolCallType = z.infer<typeof ToolCallConfigSchema>;
@@ -1,3 +1,3 @@
1
1
  import { z } from 'zod';
2
- import { WorkflowTransitionSchema } from '../../schemas';
3
- export type WorkflowTransitionType = z.infer<typeof WorkflowTransitionSchema>;
2
+ import { WorkflowTransitionConfigSchema } from '../../schemas';
3
+ export type WorkflowTransitionType = z.infer<typeof WorkflowTransitionConfigSchema>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@loopstack/contracts",
3
3
  "displayName": "Loopstack Contracts",
4
4
  "description": "A collection of types and schemas shared between projects",
5
- "version": "0.14.1",
5
+ "version": "0.16.0",
6
6
  "license": "BSL",
7
7
  "author": {
8
8
  "name": "Jakob Klippel",
@@ -26,15 +26,20 @@
26
26
  },
27
27
  "typesVersions": {
28
28
  "*": {
29
- "types": ["./dist/types/index.d.ts"],
30
- "enums": ["./dist/enums/index.d.ts"],
31
- "schemas": ["./dist/schemas/index.d.ts"]
29
+ "types": [
30
+ "./dist/types/index.d.ts"
31
+ ],
32
+ "enums": [
33
+ "./dist/enums/index.d.ts"
34
+ ],
35
+ "schemas": [
36
+ "./dist/schemas/index.d.ts"
37
+ ]
32
38
  }
33
39
  },
34
40
  "scripts": {
35
41
  "build": "tsc -p tsconfig.json",
36
42
  "watch": "tsc --watch",
37
- "prepare": "npm run build",
38
43
  "compile": "tsc --noEmit"
39
44
  },
40
45
  "peerDependencies": {