@temporal-contract/worker 0.0.1 → 0.0.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporal-contract/worker",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "description": "Worker utilities for implementing temporal-contract workflows and activities",
6
6
  "homepage": "https://github.com/btravers/temporal-contract#readme",
@@ -46,21 +46,25 @@
46
46
  },
47
47
  "./package.json": "./package.json"
48
48
  },
49
+ "files": [
50
+ "dist"
51
+ ],
49
52
  "dependencies": {
50
- "@temporal-contract/contract": "0.0.1"
53
+ "@standard-schema/spec": "1.0.0",
54
+ "@temporal-contract/contract": "0.0.3"
51
55
  },
52
56
  "devDependencies": {
53
57
  "@temporalio/workflow": "1.13.2",
54
58
  "@types/node": "24.10.2",
59
+ "@vitest/coverage-v8": "4.0.15",
55
60
  "tsdown": "0.17.2",
56
61
  "typescript": "5.9.3",
57
62
  "vitest": "4.0.15",
58
63
  "zod": "4.1.13",
59
- "@temporal-contract/tsconfig": "0.0.1"
64
+ "@temporal-contract/tsconfig": "0.0.3"
60
65
  },
61
66
  "peerDependencies": {
62
- "@temporalio/workflow": ">=1.13.0 <2.0.0",
63
- "zod": "^4.0.0"
67
+ "@temporalio/workflow": ">=1.13.0 <2.0.0"
64
68
  },
65
69
  "scripts": {
66
70
  "dev": "tsdown src/activity.ts src/workflow.ts --format cjs,esm --dts --watch",
@@ -1,25 +0,0 @@
1
-
2
- > @temporal-contract/worker@0.0.1 build /home/runner/work/temporal-contract/temporal-contract/packages/worker
3
- > tsdown src/activity.ts src/workflow.ts --format cjs,esm --dts --clean
4
-
5
- ℹ tsdown v0.17.2 powered by rolldown v1.0.0-beta.53
6
- ℹ entry: src/activity.ts, src/workflow.ts
7
- ℹ tsconfig: tsconfig.json
8
- ℹ Build start
9
- ℹ [CJS] dist/workflow.cjs  0.75 kB │ gzip: 0.19 kB
10
- ℹ [CJS] dist/activity.cjs  0.55 kB │ gzip: 0.19 kB
11
- ℹ [CJS] dist/handler-B3KY0uDx.cjs 16.12 kB │ gzip: 2.98 kB
12
- ℹ [CJS] 3 files, total: 17.41 kB
13
- ℹ [CJS] dist/workflow.d.cts  0.92 kB │ gzip: 0.27 kB
14
- ℹ [CJS] dist/activity.d.cts  0.67 kB │ gzip: 0.23 kB
15
- ℹ [CJS] dist/errors-CqX81ysy.d.cts 12.73 kB │ gzip: 2.77 kB
16
- ℹ [CJS] 3 files, total: 14.32 kB
17
- ✔ Build complete in 3501ms
18
- ℹ [ESM] dist/workflow.mjs  0.56 kB │ gzip: 0.20 kB
19
- ℹ [ESM] dist/activity.mjs  0.42 kB │ gzip: 0.18 kB
20
- ℹ [ESM] dist/handler-aA2RFdV7.mjs 14.29 kB │ gzip: 2.90 kB
21
- ℹ [ESM] dist/workflow.d.mts  0.92 kB │ gzip: 0.27 kB
22
- ℹ [ESM] dist/activity.d.mts  0.67 kB │ gzip: 0.23 kB
23
- ℹ [ESM] dist/errors-oc-Iiwmu.d.mts 12.73 kB │ gzip: 2.77 kB
24
- ℹ [ESM] 6 files, total: 29.59 kB
25
- ✔ Build complete in 3504ms
package/src/activity.ts DELETED
@@ -1,15 +0,0 @@
1
- // Entry point for activities
2
- export { declareActivitiesHandler } from "./handler.js";
3
- export type {
4
- RawActivityImplementation,
5
- ActivityImplementations,
6
- DeclareActivitiesHandlerOptions,
7
- ActivitiesHandler,
8
- } from "./handler.js";
9
- export {
10
- WorkerError,
11
- ActivityImplementationNotFoundError,
12
- ActivityDefinitionNotFoundError,
13
- ActivityInputValidationError,
14
- ActivityOutputValidationError,
15
- } from "./errors.js";
package/src/errors.ts DELETED
@@ -1,164 +0,0 @@
1
- import type { z } from "zod";
2
-
3
- /**
4
- * Base error class for worker errors
5
- */
6
- export class WorkerError extends Error {
7
- constructor(message: string) {
8
- super(message);
9
- this.name = "WorkerError";
10
- // Maintains proper stack trace for where our error was thrown (only available on V8)
11
- if (Error.captureStackTrace) {
12
- Error.captureStackTrace(this, this.constructor);
13
- }
14
- }
15
- }
16
-
17
- /**
18
- * Error thrown when an activity implementation is not found
19
- */
20
- export class ActivityImplementationNotFoundError extends WorkerError {
21
- constructor(
22
- public readonly activityName: string,
23
- public readonly availableActivities: readonly string[],
24
- ) {
25
- super(
26
- `Activity implementation not found for: "${activityName}". ` +
27
- `Available activities: ${availableActivities.length > 0 ? availableActivities.join(", ") : "none"}`,
28
- );
29
- this.name = "ActivityImplementationNotFoundError";
30
- }
31
- }
32
-
33
- /**
34
- * Error thrown when an activity definition is not found in the contract
35
- */
36
- export class ActivityDefinitionNotFoundError extends WorkerError {
37
- constructor(
38
- public readonly activityName: string,
39
- public readonly availableDefinitions: readonly string[],
40
- ) {
41
- super(
42
- `Activity definition not found in contract for: "${activityName}". ` +
43
- `Available definitions: ${availableDefinitions.length > 0 ? availableDefinitions.join(", ") : "none"}`,
44
- );
45
- this.name = "ActivityDefinitionNotFoundError";
46
- }
47
- }
48
-
49
- /**
50
- * Error thrown when activity input validation fails
51
- */
52
- export class ActivityInputValidationError extends WorkerError {
53
- constructor(
54
- public readonly activityName: string,
55
- public readonly zodError: z.ZodError,
56
- ) {
57
- super(`Activity "${activityName}" input validation failed: ${zodError.message}`);
58
- this.name = "ActivityInputValidationError";
59
- }
60
- }
61
-
62
- /**
63
- * Error thrown when activity output validation fails
64
- */
65
- export class ActivityOutputValidationError extends WorkerError {
66
- constructor(
67
- public readonly activityName: string,
68
- public readonly zodError: z.ZodError,
69
- ) {
70
- super(`Activity "${activityName}" output validation failed: ${zodError.message}`);
71
- this.name = "ActivityOutputValidationError";
72
- }
73
- }
74
-
75
- /**
76
- * Error thrown when workflow input validation fails
77
- */
78
- export class WorkflowInputValidationError extends WorkerError {
79
- constructor(
80
- public readonly workflowName: string,
81
- public readonly zodError: z.ZodError,
82
- ) {
83
- super(`Workflow "${workflowName}" input validation failed: ${zodError.message}`);
84
- this.name = "WorkflowInputValidationError";
85
- }
86
- }
87
-
88
- /**
89
- * Error thrown when workflow output validation fails
90
- */
91
- export class WorkflowOutputValidationError extends WorkerError {
92
- constructor(
93
- public readonly workflowName: string,
94
- public readonly zodError: z.ZodError,
95
- ) {
96
- super(`Workflow "${workflowName}" output validation failed: ${zodError.message}`);
97
- this.name = "WorkflowOutputValidationError";
98
- }
99
- }
100
-
101
- /**
102
- * Error thrown when signal input validation fails
103
- */
104
- export class SignalInputValidationError extends WorkerError {
105
- constructor(
106
- public readonly signalName: string,
107
- public readonly zodError: z.ZodError,
108
- ) {
109
- super(`Signal "${signalName}" input validation failed: ${zodError.message}`);
110
- this.name = "SignalInputValidationError";
111
- }
112
- }
113
-
114
- /**
115
- * Error thrown when query input validation fails
116
- */
117
- export class QueryInputValidationError extends WorkerError {
118
- constructor(
119
- public readonly queryName: string,
120
- public readonly zodError: z.ZodError,
121
- ) {
122
- super(`Query "${queryName}" input validation failed: ${zodError.message}`);
123
- this.name = "QueryInputValidationError";
124
- }
125
- }
126
-
127
- /**
128
- * Error thrown when query output validation fails
129
- */
130
- export class QueryOutputValidationError extends WorkerError {
131
- constructor(
132
- public readonly queryName: string,
133
- public readonly zodError: z.ZodError,
134
- ) {
135
- super(`Query "${queryName}" output validation failed: ${zodError.message}`);
136
- this.name = "QueryOutputValidationError";
137
- }
138
- }
139
-
140
- /**
141
- * Error thrown when update input validation fails
142
- */
143
- export class UpdateInputValidationError extends WorkerError {
144
- constructor(
145
- public readonly updateName: string,
146
- public readonly zodError: z.ZodError,
147
- ) {
148
- super(`Update "${updateName}" input validation failed: ${zodError.message}`);
149
- this.name = "UpdateInputValidationError";
150
- }
151
- }
152
-
153
- /**
154
- * Error thrown when update output validation fails
155
- */
156
- export class UpdateOutputValidationError extends WorkerError {
157
- constructor(
158
- public readonly updateName: string,
159
- public readonly zodError: z.ZodError,
160
- ) {
161
- super(`Update "${updateName}" output validation failed: ${zodError.message}`);
162
- this.name = "UpdateOutputValidationError";
163
- }
164
- }