@openfn/ws-worker 0.8.0 → 1.0.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.
- package/CHANGELOG.md +31 -0
- package/dist/index.d.ts +49 -121
- package/dist/index.js +311 -169
- package/dist/start.js +410 -249
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# ws-worker
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 86dd668: The 1.0 release updates the language and input of the Worker to match the nomenclature of Lightning.
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 29bff41: Validate the run token
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- a97eb26: Better error handling for invalid dataclips
|
|
16
|
+
- 823b471: Update handling of logs to accept stringified messages
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @openfn/engine-multi@1.0.0
|
|
19
|
+
- @openfn/logger@1.0.0
|
|
20
|
+
- @openfn/runtime@1.0.0
|
|
21
|
+
- @openfn/lexicon@1.0.0
|
|
22
|
+
|
|
23
|
+
## 0.8.1
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 823b471: Update handling of logs to accept stringified messages
|
|
28
|
+
- Updated dependencies [649ca43]
|
|
29
|
+
- Updated dependencies [823b471]
|
|
30
|
+
- @openfn/logger@0.0.20
|
|
31
|
+
- @openfn/engine-multi@0.4.1
|
|
32
|
+
- @openfn/runtime@0.2.6
|
|
33
|
+
|
|
3
34
|
## 0.8.0
|
|
4
35
|
|
|
5
36
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,72 +1,19 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import Koa from 'koa';
|
|
3
|
-
import {
|
|
3
|
+
import { Logger } from '@openfn/logger';
|
|
4
|
+
import * as l from '@openfn/lexicon/lightning';
|
|
5
|
+
import { ClaimRun } from '@openfn/lexicon/lightning';
|
|
6
|
+
import { ExecuteOptions, RuntimeEngine } from '@openfn/engine-multi';
|
|
7
|
+
import { ExecutionPlan, Lazy, State } from '@openfn/lexicon';
|
|
4
8
|
import { Channel as Channel$1 } from 'phoenix';
|
|
5
|
-
import { ExecutionPlan } from '@openfn/runtime';
|
|
6
|
-
import { RuntimeEngine } from '@openfn/engine-multi';
|
|
7
9
|
import { Server } from 'http';
|
|
8
10
|
|
|
9
|
-
type ExitReasonStrings =
|
|
10
|
-
| 'success'
|
|
11
|
-
| 'fail'
|
|
12
|
-
| 'crash'
|
|
13
|
-
| 'kill'
|
|
14
|
-
| 'cancel'
|
|
15
|
-
| 'exception';
|
|
16
|
-
|
|
17
|
-
type ExitReason = {
|
|
18
|
-
reason: ExitReasonStrings;
|
|
19
|
-
error_message: string | null;
|
|
20
|
-
error_type: string | null;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type Node = {
|
|
24
|
-
id: string;
|
|
25
|
-
body?: string;
|
|
26
|
-
adaptor?: string;
|
|
27
|
-
credential?: object;
|
|
28
|
-
credential_id?: string;
|
|
29
|
-
type?: 'webhook' | 'cron'; // trigger only
|
|
30
|
-
state?: any; // Initial state / defaults
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
interface Edge {
|
|
34
|
-
id: string;
|
|
35
|
-
source_job_id?: string;
|
|
36
|
-
source_trigger_id?: string;
|
|
37
|
-
target_job_id: string;
|
|
38
|
-
name?: string;
|
|
39
|
-
condition?: string;
|
|
40
|
-
error_path?: boolean;
|
|
41
|
-
errors?: any;
|
|
42
|
-
enabled?: boolean;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// An run object returned by Lightning
|
|
46
|
-
type Run = {
|
|
47
|
-
id: string;
|
|
48
|
-
dataclip_id: string;
|
|
49
|
-
starting_node_id: string;
|
|
50
|
-
|
|
51
|
-
triggers: Node[];
|
|
52
|
-
jobs: Node[];
|
|
53
|
-
edges: Edge[];
|
|
54
|
-
|
|
55
|
-
options?: RunOptions;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
type RunOptions = {
|
|
59
|
-
runTimeoutMs?: number;
|
|
60
|
-
|
|
61
|
-
sanitize?: SanitizePolicies;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
11
|
// Internal server state for each run
|
|
65
12
|
type RunState = {
|
|
66
13
|
activeStep?: string;
|
|
67
14
|
activeJob?: string;
|
|
68
15
|
plan: ExecutionPlan;
|
|
69
|
-
|
|
16
|
+
input: Lazy<State>;
|
|
70
17
|
dataclips: Record<string, any>;
|
|
71
18
|
// For each run, map the input ids
|
|
72
19
|
// TODO better name maybe?
|
|
@@ -92,74 +39,16 @@ interface Channel extends Channel$1 {
|
|
|
92
39
|
// join: () => ReceiveHook;
|
|
93
40
|
}
|
|
94
41
|
|
|
95
|
-
declare
|
|
96
|
-
|
|
97
|
-
demand?: number;
|
|
98
|
-
};
|
|
99
|
-
declare type ClaimReply = {
|
|
100
|
-
runs: Array<ClaimRun>;
|
|
101
|
-
};
|
|
102
|
-
declare type ClaimRun = {
|
|
103
|
-
id: string;
|
|
104
|
-
token: string;
|
|
42
|
+
declare type WorkerRunOptions = ExecuteOptions & {
|
|
43
|
+
outputDataclips?: boolean;
|
|
105
44
|
};
|
|
106
|
-
declare const GET_PLAN = "fetch:plan";
|
|
107
|
-
declare type GetPlanPayload = void;
|
|
108
|
-
declare type GetPlanReply = Run;
|
|
109
|
-
declare const GET_CREDENTIAL = "fetch:credential";
|
|
110
|
-
declare type GetCredentialPayload = {
|
|
111
|
-
id: string;
|
|
112
|
-
};
|
|
113
|
-
declare type GetCredentialReply = {};
|
|
114
|
-
declare const GET_DATACLIP = "fetch:dataclip";
|
|
115
|
-
declare type GetDataclipPayload = {
|
|
116
|
-
id: string;
|
|
117
|
-
};
|
|
118
|
-
declare type GetDataClipReply = Uint8Array;
|
|
119
|
-
declare const RUN_START = "run:start";
|
|
120
|
-
declare type RunStartPayload = void;
|
|
121
|
-
declare type RunStartReply = {};
|
|
122
|
-
declare const RUN_COMPLETE = "run:complete";
|
|
123
|
-
declare type RunCompletePayload = ExitReason & {
|
|
124
|
-
final_dataclip_id?: string;
|
|
125
|
-
};
|
|
126
|
-
declare type RunCompleteReply = undefined;
|
|
127
|
-
declare const RUN_LOG = "run:log";
|
|
128
|
-
declare type RunLogPayload = {
|
|
129
|
-
message: Array<string | object>;
|
|
130
|
-
timestamp: string;
|
|
131
|
-
run_id: string;
|
|
132
|
-
level?: string;
|
|
133
|
-
source?: string;
|
|
134
|
-
job_id?: string;
|
|
135
|
-
step_id?: string;
|
|
136
|
-
};
|
|
137
|
-
declare type RunLogReply = void;
|
|
138
|
-
declare const STEP_START = "step:start";
|
|
139
|
-
declare type StepStartPayload = {
|
|
140
|
-
job_id: string;
|
|
141
|
-
step_id: string;
|
|
142
|
-
run_id?: string;
|
|
143
|
-
input_dataclip_id?: string;
|
|
144
|
-
versions: Record<string, string>;
|
|
145
|
-
};
|
|
146
|
-
declare type StepStartReply = void;
|
|
147
|
-
declare const STEP_COMPLETE = "step:complete";
|
|
148
|
-
declare type StepCompletePayload = ExitReason & {
|
|
149
|
-
run_id?: string;
|
|
150
|
-
job_id: string;
|
|
151
|
-
step_id: string;
|
|
152
|
-
output_dataclip?: string;
|
|
153
|
-
output_dataclip_id?: string;
|
|
154
|
-
};
|
|
155
|
-
declare type StepCompleteReply = void;
|
|
156
|
-
declare const INTERNAL_RUN_COMPLETE = "server:run-complete";
|
|
157
45
|
|
|
158
46
|
declare type Context = {
|
|
159
47
|
channel: Channel;
|
|
160
48
|
state: RunState;
|
|
161
49
|
logger: Logger;
|
|
162
50
|
engine: RuntimeEngine;
|
|
51
|
+
options: WorkerRunOptions;
|
|
163
52
|
onFinish: (result: any) => void;
|
|
164
53
|
};
|
|
165
54
|
|
|
@@ -170,6 +59,7 @@ declare type ServerOptions = {
|
|
|
170
59
|
logger?: Logger;
|
|
171
60
|
noLoop?: boolean;
|
|
172
61
|
secret?: string;
|
|
62
|
+
runPublicKey?: string;
|
|
173
63
|
backoff?: {
|
|
174
64
|
min?: number;
|
|
175
65
|
max?: number;
|
|
@@ -184,10 +74,48 @@ interface ServerApp extends Koa {
|
|
|
184
74
|
events: EventEmitter;
|
|
185
75
|
server: Server;
|
|
186
76
|
engine: RuntimeEngine;
|
|
77
|
+
options: ServerOptions;
|
|
187
78
|
execute: ({ id, token }: ClaimRun) => Promise<void>;
|
|
188
79
|
destroy: () => void;
|
|
189
80
|
killWorkloop?: () => void;
|
|
190
81
|
}
|
|
191
82
|
declare function createServer(engine: RuntimeEngine, options?: ServerOptions): ServerApp;
|
|
192
83
|
|
|
193
|
-
|
|
84
|
+
declare const CLAIM = "claim";
|
|
85
|
+
declare const GET_PLAN = "fetch:plan";
|
|
86
|
+
declare const GET_DATACLIP = "fetch:dataclip";
|
|
87
|
+
declare const GET_CREDENTIAL = "fetch:credential";
|
|
88
|
+
declare const RUN_START = "run:start";
|
|
89
|
+
declare const RUN_COMPLETE = "run:complete";
|
|
90
|
+
declare const RUN_LOG = "run:log";
|
|
91
|
+
declare const STEP_START = "step:start";
|
|
92
|
+
declare const STEP_COMPLETE = "step:complete";
|
|
93
|
+
declare const INTERNAL_RUN_COMPLETE = "server:run-complete";
|
|
94
|
+
declare type QueueEvents = {
|
|
95
|
+
[CLAIM]: l.ClaimPayload;
|
|
96
|
+
};
|
|
97
|
+
declare type QueueEventReplies = {
|
|
98
|
+
[CLAIM]: l.ClaimReply;
|
|
99
|
+
};
|
|
100
|
+
declare type RunEvents = {
|
|
101
|
+
[GET_PLAN]: l.GetPlanPayload;
|
|
102
|
+
[GET_CREDENTIAL]: l.GetCredentialPayload;
|
|
103
|
+
[GET_DATACLIP]: l.GetDataclipPayload;
|
|
104
|
+
[RUN_START]: l.RunStartPayload;
|
|
105
|
+
[RUN_COMPLETE]: l.RunCompletePayload;
|
|
106
|
+
[RUN_LOG]: l.RunLogPayload;
|
|
107
|
+
[STEP_START]: l.StepStartPayload;
|
|
108
|
+
[STEP_COMPLETE]: l.StepCompletePayload;
|
|
109
|
+
};
|
|
110
|
+
declare type RunReplies = {
|
|
111
|
+
[GET_PLAN]: l.GetPlanReply;
|
|
112
|
+
[GET_CREDENTIAL]: l.GetCredentialReply;
|
|
113
|
+
[GET_DATACLIP]: l.GetDataClipReply;
|
|
114
|
+
[RUN_START]: l.RunStartReply;
|
|
115
|
+
[RUN_COMPLETE]: l.RunCompleteReply;
|
|
116
|
+
[RUN_LOG]: l.RunLogReply;
|
|
117
|
+
[STEP_START]: l.StepStartReply;
|
|
118
|
+
[STEP_COMPLETE]: l.StepCompleteReply;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export { CLAIM, GET_CREDENTIAL, GET_DATACLIP, GET_PLAN, INTERNAL_RUN_COMPLETE, QueueEventReplies, QueueEvents, RUN_COMPLETE, RUN_LOG, RUN_START, RunEvents, RunReplies, STEP_COMPLETE, STEP_START, createServer as default };
|