@outputai/core 0.14.0 → 0.14.1-next.2947341.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/dist/credentials/credentials.d.ts +6 -0
- package/dist/credentials/credentials.js +87 -0
- package/dist/credentials/encrypted_yaml_provider.d.ts +2 -0
- package/dist/credentials/encrypted_yaml_provider.js +77 -0
- package/dist/credentials/encryption.d.ts +3 -0
- package/dist/credentials/encryption.js +6 -0
- package/dist/credentials/errors.d.ts +13 -0
- package/dist/credentials/errors.js +39 -0
- package/dist/credentials/index.d.ts +6 -0
- package/dist/credentials/index.js +5 -0
- package/dist/credentials/init.d.ts +1 -0
- package/dist/credentials/init.js +7 -0
- package/dist/credentials/paths.d.ts +7 -0
- package/dist/credentials/paths.js +14 -0
- package/dist/credentials/provider_registry.d.ts +3 -0
- package/dist/credentials/provider_registry.js +6 -0
- package/dist/credentials/types.d.ts +12 -0
- package/dist/credentials/types.js +1 -0
- package/package.json +25 -14
- package/src/async_storage.d.ts +4 -0
- package/src/consts.js +0 -2
- package/src/helpers/object.d.ts +2 -0
- package/src/hooks/index.d.ts +0 -8
- package/src/hooks/index.js +0 -3
- package/src/logger/index.d.ts +4 -0
- package/src/worker/index.js +3 -1
- package/bin/healthcheck.spec.js +0 -90
- package/src/bus.spec.js +0 -196
- package/src/errors.spec.js +0 -19
- package/src/helpers/activity_options.spec.js +0 -55
- package/src/helpers/component.spec.js +0 -54
- package/src/helpers/error_serializer.spec.js +0 -479
- package/src/helpers/errors.spec.js +0 -189
- package/src/helpers/fetch.spec.js +0 -292
- package/src/helpers/function.spec.js +0 -24
- package/src/helpers/object.spec.js +0 -425
- package/src/helpers/promise.spec.js +0 -62
- package/src/helpers/redact.spec.js +0 -66
- package/src/helpers/string.spec.js +0 -99
- package/src/helpers/temporal_context.spec.ts +0 -83
- package/src/helpers/trace_info.spec.js +0 -45
- package/src/helpers/workflow_context.spec.js +0 -46
- package/src/hooks/index.spec.js +0 -265
- package/src/hooks/pending_hooks.spec.js +0 -62
- package/src/interface/evaluator.spec.js +0 -685
- package/src/interface/logger.spec.js +0 -172
- package/src/interface/step.spec.js +0 -128
- package/src/interface/validations/index.spec.js +0 -197
- package/src/interface/validations/schemas.spec.js +0 -229
- package/src/interface/webhook.spec.js +0 -170
- package/src/interface/workflow.spec.js +0 -710
- package/src/interface/workflow_utils.spec.js +0 -271
- package/src/interface/zod_integration.spec.js +0 -646
- package/src/internal_activities/index.spec.js +0 -186
- package/src/logger/development.spec.js +0 -87
- package/src/logger/index.spec.js +0 -27
- package/src/logger/production.spec.js +0 -71
- package/src/sdk/helpers/component_metadata.spec.js +0 -30
- package/src/sdk/helpers/objects.spec.js +0 -16
- package/src/sdk/helpers/path.spec.js +0 -102
- package/src/sdk/runtime/context.spec.js +0 -37
- package/src/sdk/runtime/events.spec.js +0 -40
- package/src/temporal/client.spec.js +0 -124
- package/src/tracing/processors/local/index.spec.js +0 -204
- package/src/tracing/processors/s3/configs.spec.js +0 -64
- package/src/tracing/processors/s3/index.spec.js +0 -185
- package/src/tracing/processors/s3/redis_client.spec.js +0 -179
- package/src/tracing/processors/s3/s3_client.spec.js +0 -68
- package/src/tracing/tools/build_trace_tree.spec.js +0 -216
- package/src/tracing/trace_engine.spec.js +0 -299
- package/src/worker/bundle.spec.js +0 -53
- package/src/worker/bundler_options.spec.js +0 -62
- package/src/worker/catalog_workflow/catalog_publisher.spec.js +0 -317
- package/src/worker/catalog_workflow/index.spec.js +0 -222
- package/src/worker/configs.spec.js +0 -213
- package/src/worker/configs_tuner_schema.spec.js +0 -127
- package/src/worker/connection_monitor.spec.js +0 -328
- package/src/worker/global_functions.spec.js +0 -55
- package/src/worker/index.spec.js +0 -526
- package/src/worker/interceptors/activity.spec.js +0 -369
- package/src/worker/interceptors/headers.spec.js +0 -73
- package/src/worker/interceptors/workflow.spec.js +0 -357
- package/src/worker/interruption.spec.js +0 -177
- package/src/worker/loader/activities.spec.js +0 -212
- package/src/worker/loader/hooks.spec.js +0 -64
- package/src/worker/loader/matchers.spec.js +0 -140
- package/src/worker/loader/tools.spec.js +0 -595
- package/src/worker/loader/workflows.spec.js +0 -287
- package/src/worker/log_hooks.spec.js +0 -303
- package/src/worker/shutdown.spec.js +0 -197
- package/src/worker/sinks.spec.js +0 -220
- package/src/worker/telemetry.spec.js +0 -80
- package/src/worker/temporal_logger.spec.js +0 -90
- package/src/worker/webpack_loaders/tools.spec.js +0 -314
- package/src/worker/webpack_loaders/workflow_rewriter/collect_target_imports.spec.js +0 -134
- package/src/worker/webpack_loaders/workflow_rewriter/index.spec.js +0 -154
- package/src/worker/webpack_loaders/workflow_rewriter/rewrite_activity_calls.spec.js +0 -165
- package/src/worker/webpack_loaders/workflow_validator/index.spec.js +0 -202
- package/src/worker/webpack_loaders/workflow_validator/npm_workflow_export_resolve.spec.js +0 -374
- package/src/worker/worker_runner.spec.js +0 -220
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
|
|
3
|
-
const storageLoadMock = vi.fn();
|
|
4
|
-
vi.mock( '#async_storage', () => ( {
|
|
5
|
-
Storage: { load: storageLoadMock }
|
|
6
|
-
} ) );
|
|
7
|
-
|
|
8
|
-
const serializeErrorMock = vi.fn( error => ( {
|
|
9
|
-
name: error.name,
|
|
10
|
-
message: error.message
|
|
11
|
-
} ) );
|
|
12
|
-
vi.mock( '#helpers/error_serializer', () => ( { serializeError: serializeErrorMock } ) );
|
|
13
|
-
|
|
14
|
-
const logErrorMock = vi.fn();
|
|
15
|
-
vi.mock( '#logger', () => ( {
|
|
16
|
-
createChildLogger: () => ( { error: logErrorMock } )
|
|
17
|
-
} ) );
|
|
18
|
-
|
|
19
|
-
const localInitMock = vi.fn( async () => {} );
|
|
20
|
-
const localExecMock = vi.fn();
|
|
21
|
-
const localGetDestinationMock = vi.fn( () => '/local/path.json' );
|
|
22
|
-
vi.mock( './processors/local/index.js', () => ( {
|
|
23
|
-
init: localInitMock,
|
|
24
|
-
exec: localExecMock,
|
|
25
|
-
getDestination: localGetDestinationMock
|
|
26
|
-
} ) );
|
|
27
|
-
|
|
28
|
-
const s3InitMock = vi.fn( async () => {} );
|
|
29
|
-
const s3ExecMock = vi.fn();
|
|
30
|
-
const s3GetDestinationMock = vi.fn( () => 'https://bucket.s3.amazonaws.com/key.json' );
|
|
31
|
-
vi.mock( './processors/s3/index.js', () => ( {
|
|
32
|
-
init: s3InitMock,
|
|
33
|
-
exec: s3ExecMock,
|
|
34
|
-
getDestination: s3GetDestinationMock
|
|
35
|
-
} ) );
|
|
36
|
-
|
|
37
|
-
async function loadTraceEngine() {
|
|
38
|
-
vi.resetModules();
|
|
39
|
-
return import( './trace_engine.js' );
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const traceInfo = {
|
|
43
|
-
workflowId: 'w1',
|
|
44
|
-
runId: 'r1',
|
|
45
|
-
workflowType: 'WF',
|
|
46
|
-
startTime: 1
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
describe( 'tracing/trace_engine', () => {
|
|
50
|
-
beforeEach( () => {
|
|
51
|
-
vi.clearAllMocks();
|
|
52
|
-
delete process.env.OUTPUT_TRACE_LOCAL_ON;
|
|
53
|
-
delete process.env.OUTPUT_TRACE_REMOTE_ON;
|
|
54
|
-
storageLoadMock.mockReset();
|
|
55
|
-
} );
|
|
56
|
-
|
|
57
|
-
it( 'init() starts only enabled processors and attaches listeners', async () => {
|
|
58
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = '1';
|
|
59
|
-
process.env.OUTPUT_TRACE_REMOTE_ON = '0';
|
|
60
|
-
const { init, addEventAction } = await loadTraceEngine();
|
|
61
|
-
|
|
62
|
-
await init();
|
|
63
|
-
|
|
64
|
-
expect( localInitMock ).toHaveBeenCalledTimes( 1 );
|
|
65
|
-
expect( s3InitMock ).not.toHaveBeenCalled();
|
|
66
|
-
|
|
67
|
-
addEventAction( 'start', {
|
|
68
|
-
kind: 'step', name: 'N', id: '1', parentId: 'p', details: { ok: true }, traceInfo
|
|
69
|
-
} );
|
|
70
|
-
expect( localExecMock ).toHaveBeenCalledTimes( 1 );
|
|
71
|
-
const payload = localExecMock.mock.calls[0][0];
|
|
72
|
-
expect( payload.entry.name ).toBe( 'N' );
|
|
73
|
-
expect( payload.entry.kind ).toBe( 'step' );
|
|
74
|
-
expect( payload.entry.action ).toBe( 'start' );
|
|
75
|
-
expect( payload.entry.details ).toEqual( { ok: true } );
|
|
76
|
-
expect( payload.traceInfo ).toBe( traceInfo );
|
|
77
|
-
} );
|
|
78
|
-
|
|
79
|
-
it( 'init() logs processor failures with serialized stacks', async () => {
|
|
80
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = '1';
|
|
81
|
-
const processorError = new Error( 'processor failed' );
|
|
82
|
-
localExecMock.mockRejectedValueOnce( processorError );
|
|
83
|
-
const { init, addEventAction } = await loadTraceEngine();
|
|
84
|
-
await init();
|
|
85
|
-
|
|
86
|
-
addEventAction( 'start', {
|
|
87
|
-
kind: 'step', name: 'N', id: '1', parentId: 'p', details: null, traceInfo
|
|
88
|
-
} );
|
|
89
|
-
|
|
90
|
-
await vi.waitFor( () => expect( logErrorMock ).toHaveBeenCalledWith( 'Processor execution error', {
|
|
91
|
-
processor: 'LOCAL',
|
|
92
|
-
error: { name: 'Error', message: 'processor failed' }
|
|
93
|
-
} ) );
|
|
94
|
-
expect( serializeErrorMock ).toHaveBeenCalledWith( processorError );
|
|
95
|
-
} );
|
|
96
|
-
|
|
97
|
-
it( 'addEventAction() emits an entry consumed by processors', async () => {
|
|
98
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = 'on';
|
|
99
|
-
const { init, addEventAction } = await loadTraceEngine();
|
|
100
|
-
await init();
|
|
101
|
-
|
|
102
|
-
addEventAction( 'end', {
|
|
103
|
-
kind: 'workflow', name: 'W', id: '2', parentId: 'p2', details: 'done',
|
|
104
|
-
traceInfo
|
|
105
|
-
} );
|
|
106
|
-
expect( localExecMock ).toHaveBeenCalledTimes( 1 );
|
|
107
|
-
const payload = localExecMock.mock.calls[0][0];
|
|
108
|
-
expect( payload.entry.name ).toBe( 'W' );
|
|
109
|
-
expect( payload.entry.action ).toBe( 'end' );
|
|
110
|
-
expect( payload.entry.details ).toBe( 'done' );
|
|
111
|
-
} );
|
|
112
|
-
|
|
113
|
-
it( 'addEventAction() serializes error details before emitting', async () => {
|
|
114
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = 'on';
|
|
115
|
-
const { init, addEventAction } = await loadTraceEngine();
|
|
116
|
-
await init();
|
|
117
|
-
const error = new TypeError( 'step failed' );
|
|
118
|
-
|
|
119
|
-
addEventAction( 'error', {
|
|
120
|
-
kind: 'step', name: 'S', id: '3', parentId: 'p3', details: error,
|
|
121
|
-
traceInfo
|
|
122
|
-
} );
|
|
123
|
-
|
|
124
|
-
expect( serializeErrorMock ).toHaveBeenCalledWith( error );
|
|
125
|
-
expect( localExecMock.mock.calls[0][0].entry.details ).toEqual( {
|
|
126
|
-
name: 'TypeError',
|
|
127
|
-
message: 'step failed'
|
|
128
|
-
} );
|
|
129
|
-
} );
|
|
130
|
-
|
|
131
|
-
it( 'addEventAction() does not emit when traceInfo is absent', async () => {
|
|
132
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = '1';
|
|
133
|
-
const { init, addEventAction } = await loadTraceEngine();
|
|
134
|
-
await init();
|
|
135
|
-
|
|
136
|
-
addEventAction( 'start', {
|
|
137
|
-
kind: 'step', name: 'X', id: '1', parentId: 'p', details: {},
|
|
138
|
-
traceInfo: undefined
|
|
139
|
-
} );
|
|
140
|
-
expect( localExecMock ).not.toHaveBeenCalled();
|
|
141
|
-
} );
|
|
142
|
-
|
|
143
|
-
it( 'addEventActionWithContext() uses storage when available', async () => {
|
|
144
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = 'true';
|
|
145
|
-
storageLoadMock.mockReturnValue( {
|
|
146
|
-
parentId: 'ctx-p',
|
|
147
|
-
traceInfo
|
|
148
|
-
} );
|
|
149
|
-
const { init, addEventActionWithContext } = await loadTraceEngine();
|
|
150
|
-
await init();
|
|
151
|
-
|
|
152
|
-
addEventActionWithContext( 'tick', { kind: 'step', name: 'S', id: '3', details: 1 } );
|
|
153
|
-
expect( localExecMock ).toHaveBeenCalledTimes( 1 );
|
|
154
|
-
const payload = localExecMock.mock.calls[0][0];
|
|
155
|
-
expect( payload.traceInfo ).toBe( traceInfo );
|
|
156
|
-
expect( payload.entry.parentId ).toBe( 'ctx-p' );
|
|
157
|
-
expect( payload.entry.name ).toBe( 'S' );
|
|
158
|
-
expect( payload.entry.action ).toBe( 'tick' );
|
|
159
|
-
} );
|
|
160
|
-
|
|
161
|
-
it( 'addEventActionWithContext() unwraps transparent errors without mutating options', async () => {
|
|
162
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = 'true';
|
|
163
|
-
storageLoadMock.mockReturnValue( {
|
|
164
|
-
parentId: 'ctx-p',
|
|
165
|
-
traceInfo
|
|
166
|
-
} );
|
|
167
|
-
const { init, addEventActionWithContext } = await loadTraceEngine();
|
|
168
|
-
const { TransparentFatalError } = await import( '#errors' );
|
|
169
|
-
await init();
|
|
170
|
-
|
|
171
|
-
const cause = new TypeError( 'provider rejected request' );
|
|
172
|
-
const error = new TransparentFatalError( cause );
|
|
173
|
-
const options = { kind: 'llm', name: 'generate', id: 'llm-1', details: error };
|
|
174
|
-
addEventActionWithContext( 'error', options );
|
|
175
|
-
|
|
176
|
-
expect( options.details ).toBe( error );
|
|
177
|
-
expect( serializeErrorMock ).toHaveBeenCalledWith( cause );
|
|
178
|
-
expect( localExecMock.mock.calls[0][0].entry.details ).toEqual( {
|
|
179
|
-
name: 'TypeError',
|
|
180
|
-
message: 'provider rejected request'
|
|
181
|
-
} );
|
|
182
|
-
} );
|
|
183
|
-
|
|
184
|
-
it( 'addEventActionWithContext() emits validated ADD_ATTR trace entries', async () => {
|
|
185
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = 'true';
|
|
186
|
-
storageLoadMock.mockReturnValue( {
|
|
187
|
-
parentId: 'ctx-p',
|
|
188
|
-
traceInfo
|
|
189
|
-
} );
|
|
190
|
-
const { init, addEventActionWithContext } = await loadTraceEngine();
|
|
191
|
-
const { EventAction } = await import( './trace_consts.js' );
|
|
192
|
-
const { Attribute } = await import( './trace_attribute.js' );
|
|
193
|
-
await init();
|
|
194
|
-
|
|
195
|
-
const attribute = new Attribute.HTTPRequestCount( 'https://example.test', 'req-1' );
|
|
196
|
-
addEventActionWithContext( EventAction.ADD_ATTR, { kind: 'http', name: 'request', id: 'req-1', details: attribute } );
|
|
197
|
-
|
|
198
|
-
expect( localExecMock ).toHaveBeenCalledTimes( 1 );
|
|
199
|
-
expect( localExecMock.mock.calls[0][0] ).toEqual( {
|
|
200
|
-
traceInfo,
|
|
201
|
-
entry: {
|
|
202
|
-
kind: 'http',
|
|
203
|
-
action: EventAction.ADD_ATTR,
|
|
204
|
-
name: 'request',
|
|
205
|
-
id: 'req-1',
|
|
206
|
-
parentId: 'ctx-p',
|
|
207
|
-
timestamp: expect.any( Number ),
|
|
208
|
-
details: attribute
|
|
209
|
-
}
|
|
210
|
-
} );
|
|
211
|
-
} );
|
|
212
|
-
|
|
213
|
-
it( 'addEventActionWithContext() throws on invalid ADD_ATTR signal payloads', async () => {
|
|
214
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = 'true';
|
|
215
|
-
storageLoadMock.mockReturnValue( {
|
|
216
|
-
parentId: 'ctx-p',
|
|
217
|
-
traceInfo
|
|
218
|
-
} );
|
|
219
|
-
const { init, addEventActionWithContext } = await loadTraceEngine();
|
|
220
|
-
const { EventAction } = await import( './trace_consts.js' );
|
|
221
|
-
await init();
|
|
222
|
-
|
|
223
|
-
const invalidAttribute = { type: 'not-a-base-attribute' };
|
|
224
|
-
expect( () => addEventActionWithContext(
|
|
225
|
-
EventAction.ADD_ATTR,
|
|
226
|
-
{ kind: 'http', name: 'request', id: 'req-1', details: invalidAttribute }
|
|
227
|
-
) ).toThrow( /not a BaseAttribute instance/ );
|
|
228
|
-
|
|
229
|
-
expect( localExecMock ).not.toHaveBeenCalled();
|
|
230
|
-
} );
|
|
231
|
-
|
|
232
|
-
it( 'addEventActionWithContext() does not emit when storage traceInfo is absent', async () => {
|
|
233
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = '1';
|
|
234
|
-
storageLoadMock.mockReturnValue( {
|
|
235
|
-
parentId: 'ctx-p',
|
|
236
|
-
traceInfo: undefined
|
|
237
|
-
} );
|
|
238
|
-
const { init, addEventActionWithContext } = await loadTraceEngine();
|
|
239
|
-
await init();
|
|
240
|
-
|
|
241
|
-
addEventActionWithContext( 'tick', { kind: 'step', name: 'S', id: '3', details: 1 } );
|
|
242
|
-
expect( localExecMock ).not.toHaveBeenCalled();
|
|
243
|
-
} );
|
|
244
|
-
|
|
245
|
-
it( 'addEventActionWithContext() is a no-op when storage is absent', async () => {
|
|
246
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = '1';
|
|
247
|
-
storageLoadMock.mockReturnValue( undefined );
|
|
248
|
-
const { init, addEventActionWithContext } = await loadTraceEngine();
|
|
249
|
-
await init();
|
|
250
|
-
|
|
251
|
-
addEventActionWithContext( 'noop', { kind: 'step', name: 'X', id: '4', details: null } );
|
|
252
|
-
expect( localExecMock ).not.toHaveBeenCalled();
|
|
253
|
-
} );
|
|
254
|
-
|
|
255
|
-
describe( 'getDestinations()', () => {
|
|
256
|
-
it( 'returns an empty object when traces are off (env vars unset)', async () => {
|
|
257
|
-
const { getDestinations } = await loadTraceEngine();
|
|
258
|
-
const result = getDestinations( traceInfo );
|
|
259
|
-
expect( result ).toEqual( {} );
|
|
260
|
-
expect( localGetDestinationMock ).not.toHaveBeenCalled();
|
|
261
|
-
expect( s3GetDestinationMock ).not.toHaveBeenCalled();
|
|
262
|
-
} );
|
|
263
|
-
|
|
264
|
-
it( 'returns both destinations when both traces are on', async () => {
|
|
265
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = '1';
|
|
266
|
-
process.env.OUTPUT_TRACE_REMOTE_ON = 'true';
|
|
267
|
-
const { getDestinations } = await loadTraceEngine();
|
|
268
|
-
const result = getDestinations( traceInfo );
|
|
269
|
-
expect( result ).toEqual( {
|
|
270
|
-
local: '/local/path.json',
|
|
271
|
-
remote: 'https://bucket.s3.amazonaws.com/key.json'
|
|
272
|
-
} );
|
|
273
|
-
expect( localGetDestinationMock ).toHaveBeenCalledTimes( 1 );
|
|
274
|
-
expect( localGetDestinationMock ).toHaveBeenCalledWith( traceInfo );
|
|
275
|
-
expect( s3GetDestinationMock ).toHaveBeenCalledTimes( 1 );
|
|
276
|
-
expect( s3GetDestinationMock ).toHaveBeenCalledWith( traceInfo );
|
|
277
|
-
} );
|
|
278
|
-
|
|
279
|
-
it( 'returns local only when local trace on and remote off', async () => {
|
|
280
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = '1';
|
|
281
|
-
process.env.OUTPUT_TRACE_REMOTE_ON = '0';
|
|
282
|
-
const { getDestinations } = await loadTraceEngine();
|
|
283
|
-
const result = getDestinations( traceInfo );
|
|
284
|
-
expect( result ).toEqual( { local: '/local/path.json' } );
|
|
285
|
-
expect( localGetDestinationMock ).toHaveBeenCalledWith( traceInfo );
|
|
286
|
-
expect( s3GetDestinationMock ).not.toHaveBeenCalled();
|
|
287
|
-
} );
|
|
288
|
-
|
|
289
|
-
it( 'returns remote only when local trace off and remote on', async () => {
|
|
290
|
-
process.env.OUTPUT_TRACE_LOCAL_ON = '0';
|
|
291
|
-
process.env.OUTPUT_TRACE_REMOTE_ON = 'true';
|
|
292
|
-
const { getDestinations } = await loadTraceEngine();
|
|
293
|
-
const result = getDestinations( traceInfo );
|
|
294
|
-
expect( result ).toEqual( { remote: 'https://bucket.s3.amazonaws.com/key.json' } );
|
|
295
|
-
expect( localGetDestinationMock ).not.toHaveBeenCalled();
|
|
296
|
-
expect( s3GetDestinationMock ).toHaveBeenCalledWith( traceInfo );
|
|
297
|
-
} );
|
|
298
|
-
} );
|
|
299
|
-
} );
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
|
|
3
|
-
// Stub the activity interceptor so the real interceptors/index.js imports cleanly.
|
|
4
|
-
vi.mock( './interceptors/activity.js', () => ( { ActivityExecutionInterceptor: class {} } ) );
|
|
5
|
-
|
|
6
|
-
vi.mock( '@temporalio/worker', () => ( {
|
|
7
|
-
bundleWorkflowCode: vi.fn().mockResolvedValue( { code: '', sourceMap: '' } )
|
|
8
|
-
} ) );
|
|
9
|
-
|
|
10
|
-
vi.mock( './loader/workflows.js', () => ( {
|
|
11
|
-
loadWorkflows: vi.fn().mockResolvedValue( { workflows: [], entrypoint: '/fake/workflows/entrypoint.js' } )
|
|
12
|
-
} ) );
|
|
13
|
-
|
|
14
|
-
vi.mock( './loader/activities.js', () => ( {
|
|
15
|
-
loadActivities: vi.fn().mockResolvedValue( { activities: {} } )
|
|
16
|
-
} ) );
|
|
17
|
-
|
|
18
|
-
vi.mock( './bundler_options.js', () => ( { webpackConfigHook: vi.fn() } ) );
|
|
19
|
-
|
|
20
|
-
import { bundleWorkflowCode } from '@temporalio/worker';
|
|
21
|
-
import { loadWorkflows } from './loader/workflows.js';
|
|
22
|
-
import { loadActivities } from './loader/activities.js';
|
|
23
|
-
import { webpackConfigHook } from './bundler_options.js';
|
|
24
|
-
import { initInterceptors } from './interceptors/index.js';
|
|
25
|
-
import { workflowInterceptorModules } from './interceptors/modules.js';
|
|
26
|
-
import { bundleWorkflows } from './bundle.js';
|
|
27
|
-
|
|
28
|
-
describe( 'output-worker --check parity', () => {
|
|
29
|
-
beforeEach( () => {
|
|
30
|
-
vi.clearAllMocks();
|
|
31
|
-
loadWorkflows.mockResolvedValue( { workflows: [], entrypoint: '/fake/workflows/entrypoint.js' } );
|
|
32
|
-
loadActivities.mockResolvedValue( { activities: {} } );
|
|
33
|
-
bundleWorkflowCode.mockResolvedValue( { code: '', sourceMap: '' } );
|
|
34
|
-
} );
|
|
35
|
-
|
|
36
|
-
it( 'worker registers the shared workflow interceptor modules', () => {
|
|
37
|
-
const { workflowModules } = initInterceptors( { activities: {}, workflows: [], connection: {} } );
|
|
38
|
-
// The check (bundleWorkflows) and the worker must register the very same modules.
|
|
39
|
-
expect( workflowModules ).toBe( workflowInterceptorModules );
|
|
40
|
-
} );
|
|
41
|
-
|
|
42
|
-
it( 'check bundles with the same inputs Worker.create derives', async () => {
|
|
43
|
-
await bundleWorkflows( '/project' );
|
|
44
|
-
|
|
45
|
-
expect( loadWorkflows ).toHaveBeenCalledWith( '/project' );
|
|
46
|
-
expect( loadActivities ).toHaveBeenCalledWith( '/project', [] );
|
|
47
|
-
expect( bundleWorkflowCode ).toHaveBeenCalledWith( {
|
|
48
|
-
workflowsPath: '/fake/workflows/entrypoint.js',
|
|
49
|
-
workflowInterceptorModules,
|
|
50
|
-
webpackConfigHook
|
|
51
|
-
} );
|
|
52
|
-
} );
|
|
53
|
-
} );
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { webpackConfigHook } from './bundler_options.js';
|
|
6
|
-
|
|
7
|
-
const __dirname = dirname( fileURLToPath( import.meta.url ) );
|
|
8
|
-
const TEMP_BASE = join( process.cwd(), 'sdk/core/temp_test_bundler_options' );
|
|
9
|
-
|
|
10
|
-
afterEach( () => {
|
|
11
|
-
rmSync( TEMP_BASE, { recursive: true, force: true } );
|
|
12
|
-
} );
|
|
13
|
-
|
|
14
|
-
const buildExcludes = () => {
|
|
15
|
-
const config = webpackConfigHook( {} );
|
|
16
|
-
return config.module.rules.map( rule => rule.exclude );
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const writePackageResource = ( packagePath, pkgJson ) => {
|
|
20
|
-
const resource = join( packagePath, 'lib', 'index.js' );
|
|
21
|
-
mkdirSync( dirname( resource ), { recursive: true } );
|
|
22
|
-
writeFileSync( join( packagePath, 'package.json' ), JSON.stringify( pkgJson ) );
|
|
23
|
-
writeFileSync( resource, 'export const x = 1;\n' );
|
|
24
|
-
return resource;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
describe( 'webpackConfigHook loader excludes', () => {
|
|
28
|
-
it( 'keeps loaders enabled for project files outside node_modules', () => {
|
|
29
|
-
for ( const exclude of buildExcludes() ) {
|
|
30
|
-
expect( exclude( join( TEMP_BASE, 'src', 'workflow.js' ) ) ).toBe( false );
|
|
31
|
-
}
|
|
32
|
-
} );
|
|
33
|
-
|
|
34
|
-
it( 'excludes worker and interface internals', () => {
|
|
35
|
-
for ( const exclude of buildExcludes() ) {
|
|
36
|
-
expect( exclude( join( __dirname, 'loader', 'tools.js' ) ) ).toBe( true );
|
|
37
|
-
expect( exclude( join( __dirname, '..', 'interface', 'index.js' ) ) ).toBe( true );
|
|
38
|
-
}
|
|
39
|
-
} );
|
|
40
|
-
|
|
41
|
-
it( 'keeps loaders enabled for packages that expose workflows', () => {
|
|
42
|
-
const resource = writePackageResource(
|
|
43
|
-
join( TEMP_BASE, 'node_modules', '@acme', 'catalog' ),
|
|
44
|
-
{ name: '@acme/catalog', outputai: { workflows: { expose: true } } }
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
for ( const exclude of buildExcludes() ) {
|
|
48
|
-
expect( exclude( resource ) ).toBe( false );
|
|
49
|
-
}
|
|
50
|
-
} );
|
|
51
|
-
|
|
52
|
-
it( 'excludes packages that do not expose workflows', () => {
|
|
53
|
-
const resource = writePackageResource(
|
|
54
|
-
join( TEMP_BASE, 'node_modules', 'plain_lib' ),
|
|
55
|
-
{ name: 'plain_lib', dependencies: { '@outputai/core': '1.0.0' } }
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
for ( const exclude of buildExcludes() ) {
|
|
59
|
-
expect( exclude( resource ) ).toBe( true );
|
|
60
|
-
}
|
|
61
|
-
} );
|
|
62
|
-
} );
|