@temporal-contract/worker 0.0.2 → 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 +6 -3
- package/.turbo/turbo-build.log +0 -25
- package/CHANGELOG.md +0 -9
- package/src/activity.ts +0 -15
- package/src/errors.ts +0 -173
- package/src/handler.spec.ts +0 -499
- package/src/handler.ts +0 -605
- package/src/workflow.ts +0 -20
- package/tsconfig.json +0 -9
- package/vitest.config.ts +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporal-contract/worker",
|
|
3
|
-
"version": "0.0.
|
|
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,9 +46,12 @@
|
|
|
46
46
|
},
|
|
47
47
|
"./package.json": "./package.json"
|
|
48
48
|
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist"
|
|
51
|
+
],
|
|
49
52
|
"dependencies": {
|
|
50
53
|
"@standard-schema/spec": "1.0.0",
|
|
51
|
-
"@temporal-contract/contract": "0.0.
|
|
54
|
+
"@temporal-contract/contract": "0.0.3"
|
|
52
55
|
},
|
|
53
56
|
"devDependencies": {
|
|
54
57
|
"@temporalio/workflow": "1.13.2",
|
|
@@ -58,7 +61,7 @@
|
|
|
58
61
|
"typescript": "5.9.3",
|
|
59
62
|
"vitest": "4.0.15",
|
|
60
63
|
"zod": "4.1.13",
|
|
61
|
-
"@temporal-contract/tsconfig": "0.0.
|
|
64
|
+
"@temporal-contract/tsconfig": "0.0.3"
|
|
62
65
|
},
|
|
63
66
|
"peerDependencies": {
|
|
64
67
|
"@temporalio/workflow": ">=1.13.0 <2.0.0"
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @temporal-contract/worker@0.0.2 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
|
-
[34mℹ[39m tsdown [2mv0.17.2[22m powered by rolldown [2mv1.0.0-beta.53[22m
|
|
6
|
-
[34mℹ[39m entry: [34msrc/activity.ts, src/workflow.ts[39m
|
|
7
|
-
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
8
|
-
[34mℹ[39m Build start
|
|
9
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mworkflow.cjs[22m [2m 0.75 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
10
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mactivity.cjs[22m [2m 0.55 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
11
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mhandler-Cc951VQp.cjs [2m16.80 kB[22m [2m│ gzip: 3.09 kB[22m
|
|
12
|
-
[34mℹ[39m [33m[CJS][39m 3 files, total: 18.10 kB
|
|
13
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mworkflow.mjs[22m [2m 0.56 kB[22m [2m│ gzip: 0.20 kB[22m
|
|
14
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mactivity.mjs[22m [2m 0.42 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
15
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mhandler-BP9xAycT.mjs [2m15.01 kB[22m [2m│ gzip: 3.00 kB[22m
|
|
16
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mworkflow.d.mts[22m[39m [2m 0.92 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
17
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mactivity.d.mts[22m[39m [2m 0.67 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
18
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32merrors-DgUMRes-.d.mts[39m [2m13.22 kB[22m [2m│ gzip: 2.81 kB[22m
|
|
19
|
-
[34mℹ[39m [34m[ESM][39m 6 files, total: 30.79 kB
|
|
20
|
-
[32m✔[39m Build complete in [32m4048ms[39m
|
|
21
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mworkflow.d.cts[22m[39m [2m 0.92 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
22
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mactivity.d.cts[22m[39m [2m 0.67 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
23
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32merrors-B50uht6a.d.cts[39m [2m13.22 kB[22m [2m│ gzip: 2.81 kB[22m
|
|
24
|
-
[34mℹ[39m [33m[CJS][39m 3 files, total: 14.80 kB
|
|
25
|
-
[32m✔[39m Build complete in [32m4051ms[39m
|
package/CHANGELOG.md
DELETED
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,173 +0,0 @@
|
|
|
1
|
-
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
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 issues: ReadonlyArray<StandardSchemaV1.Issue>,
|
|
56
|
-
) {
|
|
57
|
-
const message = issues.map((issue) => issue.message).join("; ");
|
|
58
|
-
super(`Activity "${activityName}" input validation failed: ${message}`);
|
|
59
|
-
this.name = "ActivityInputValidationError";
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Error thrown when activity output validation fails
|
|
65
|
-
*/
|
|
66
|
-
export class ActivityOutputValidationError extends WorkerError {
|
|
67
|
-
constructor(
|
|
68
|
-
public readonly activityName: string,
|
|
69
|
-
public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,
|
|
70
|
-
) {
|
|
71
|
-
const message = issues.map((issue) => issue.message).join("; ");
|
|
72
|
-
super(`Activity "${activityName}" output validation failed: ${message}`);
|
|
73
|
-
this.name = "ActivityOutputValidationError";
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Error thrown when workflow input validation fails
|
|
79
|
-
*/
|
|
80
|
-
export class WorkflowInputValidationError extends WorkerError {
|
|
81
|
-
constructor(
|
|
82
|
-
public readonly workflowName: string,
|
|
83
|
-
public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,
|
|
84
|
-
) {
|
|
85
|
-
const message = issues.map((issue) => issue.message).join("; ");
|
|
86
|
-
super(`Workflow "${workflowName}" input validation failed: ${message}`);
|
|
87
|
-
this.name = "WorkflowInputValidationError";
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Error thrown when workflow output validation fails
|
|
93
|
-
*/
|
|
94
|
-
export class WorkflowOutputValidationError extends WorkerError {
|
|
95
|
-
constructor(
|
|
96
|
-
public readonly workflowName: string,
|
|
97
|
-
public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,
|
|
98
|
-
) {
|
|
99
|
-
const message = issues.map((issue) => issue.message).join("; ");
|
|
100
|
-
super(`Workflow "${workflowName}" output validation failed: ${message}`);
|
|
101
|
-
this.name = "WorkflowOutputValidationError";
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Error thrown when signal input validation fails
|
|
107
|
-
*/
|
|
108
|
-
export class SignalInputValidationError extends WorkerError {
|
|
109
|
-
constructor(
|
|
110
|
-
public readonly signalName: string,
|
|
111
|
-
public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,
|
|
112
|
-
) {
|
|
113
|
-
const message = issues.map((issue) => issue.message).join("; ");
|
|
114
|
-
super(`Signal "${signalName}" input validation failed: ${message}`);
|
|
115
|
-
this.name = "SignalInputValidationError";
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Error thrown when query input validation fails
|
|
121
|
-
*/
|
|
122
|
-
export class QueryInputValidationError extends WorkerError {
|
|
123
|
-
constructor(
|
|
124
|
-
public readonly queryName: string,
|
|
125
|
-
public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,
|
|
126
|
-
) {
|
|
127
|
-
const message = issues.map((issue) => issue.message).join("; ");
|
|
128
|
-
super(`Query "${queryName}" input validation failed: ${message}`);
|
|
129
|
-
this.name = "QueryInputValidationError";
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Error thrown when query output validation fails
|
|
135
|
-
*/
|
|
136
|
-
export class QueryOutputValidationError extends WorkerError {
|
|
137
|
-
constructor(
|
|
138
|
-
public readonly queryName: string,
|
|
139
|
-
public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,
|
|
140
|
-
) {
|
|
141
|
-
const message = issues.map((issue) => issue.message).join("; ");
|
|
142
|
-
super(`Query "${queryName}" output validation failed: ${message}`);
|
|
143
|
-
this.name = "QueryOutputValidationError";
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Error thrown when update input validation fails
|
|
149
|
-
*/
|
|
150
|
-
export class UpdateInputValidationError extends WorkerError {
|
|
151
|
-
constructor(
|
|
152
|
-
public readonly updateName: string,
|
|
153
|
-
public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,
|
|
154
|
-
) {
|
|
155
|
-
const message = issues.map((issue) => issue.message).join("; ");
|
|
156
|
-
super(`Update "${updateName}" input validation failed: ${message}`);
|
|
157
|
-
this.name = "UpdateInputValidationError";
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Error thrown when update output validation fails
|
|
163
|
-
*/
|
|
164
|
-
export class UpdateOutputValidationError extends WorkerError {
|
|
165
|
-
constructor(
|
|
166
|
-
public readonly updateName: string,
|
|
167
|
-
public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,
|
|
168
|
-
) {
|
|
169
|
-
const message = issues.map((issue) => issue.message).join("; ");
|
|
170
|
-
super(`Update "${updateName}" output validation failed: ${message}`);
|
|
171
|
-
this.name = "UpdateOutputValidationError";
|
|
172
|
-
}
|
|
173
|
-
}
|