@requence/service 1.0.0-alpha.49 → 1.0.0-alpha.50
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 +6 -0
- package/build/cli.js +113 -22
- package/build/cli.js.map +3 -3
- package/build/index.js +202 -185
- package/build/index.js.map +12 -11
- package/build/types/helpers/src/files/mapOutput.d.ts.map +1 -1
- package/build/types/helpers/src/index.d.ts +3 -2
- package/build/types/helpers/src/index.d.ts.map +1 -1
- package/build/types/helpers/src/jsonschema/zod.d.ts +1 -0
- package/build/types/helpers/src/jsonschema/zod.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/NodeTree.d.ts +31 -14
- package/build/types/helpers/src/protocol/NodeTree.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/command.d.ts +4 -12
- package/build/types/helpers/src/protocol/command.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/nodeType.d.ts +2 -0
- package/build/types/helpers/src/protocol/nodeType.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/taskOptions.d.ts +0 -3
- package/build/types/helpers/src/protocol/taskOptions.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/templateNodeTypes.d.ts +32 -0
- package/build/types/helpers/src/protocol/templateNodeTypes.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/treeNodes.d.ts +10 -6
- package/build/types/helpers/src/protocol/treeNodes.d.ts.map +1 -1
- package/build/types/helpers/src/utils/debounce.d.ts +4 -0
- package/build/types/helpers/src/utils/debounce.d.ts.map +1 -0
- package/build/types/helpers/src/utils/guards.d.ts +3 -0
- package/build/types/helpers/src/utils/guards.d.ts.map +1 -0
- package/build/types/helpers/src/utils/obj.d.ts +4 -0
- package/build/types/helpers/src/utils/obj.d.ts.map +1 -0
- package/build/types/helpers/src/utils/requenceCallback.d.ts.map +1 -1
- package/build/types/helpers/src/utils/types.d.ts +3 -0
- package/build/types/helpers/src/utils/types.d.ts.map +1 -1
- package/build/types/service/src/createAmqpConnection.d.ts +17 -14
- package/build/types/service/src/createAmqpConnection.d.ts.map +1 -1
- package/build/types/service/src/errors.d.ts +3 -0
- package/build/types/service/src/errors.d.ts.map +1 -0
- package/build/types/service/src/helpers.d.ts +0 -5
- package/build/types/service/src/helpers.d.ts.map +1 -1
- package/build/types/service/src/index.d.ts +2 -0
- package/build/types/service/src/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/build/types/helpers/src/utils/createRemotePromise.d.ts +0 -7
- package/build/types/helpers/src/utils/createRemotePromise.d.ts.map +0 -1
- package/build/types/helpers/src/utils/isRecord.d.ts +0 -2
- package/build/types/helpers/src/utils/isRecord.d.ts.map +0 -1
package/build/index.js
CHANGED
|
@@ -6,12 +6,13 @@ import {
|
|
|
6
6
|
// src/index.ts
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
|
|
9
|
-
// ../helpers/src/utils/
|
|
9
|
+
// ../helpers/src/utils/guards.ts
|
|
10
10
|
import { z } from "zod/v4";
|
|
11
11
|
var recordSchema = z.record(z.string(), z.unknown());
|
|
12
12
|
function isRecord(data) {
|
|
13
13
|
return recordSchema.safeParse(data).success;
|
|
14
14
|
}
|
|
15
|
+
var uuidSchema = z.uuid();
|
|
15
16
|
|
|
16
17
|
// ../helpers/src/utils/mapData.ts
|
|
17
18
|
function resolve(value, onResolve) {
|
|
@@ -110,12 +111,9 @@ function isCallbackObject(data) {
|
|
|
110
111
|
return callbackObjectSchema.safeParse(data).success;
|
|
111
112
|
}
|
|
112
113
|
function createCallback(callback) {
|
|
113
|
-
|
|
114
|
-
const promise = new Promise((resolve2) => {
|
|
115
|
-
resolvePromise = resolve2;
|
|
116
|
-
});
|
|
114
|
+
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
117
115
|
const executor = (arg) => {
|
|
118
|
-
|
|
116
|
+
resolve2(arg);
|
|
119
117
|
callback?.(arg);
|
|
120
118
|
};
|
|
121
119
|
return Object.assign(executor, {
|
|
@@ -125,110 +123,22 @@ function createCallback(callback) {
|
|
|
125
123
|
});
|
|
126
124
|
}
|
|
127
125
|
|
|
128
|
-
// ../helpers/src/files/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
return toFileObject(data);
|
|
143
|
-
}
|
|
144
|
-
async function stream(streamUrl, stream2, signal, contentType) {
|
|
145
|
-
const [testStream, dataStream] = stream2.tee();
|
|
146
|
-
const reader = testStream.getReader();
|
|
147
|
-
const dataPromise = reader.read().then(({ done: done2 }) => {
|
|
148
|
-
if (done2) {
|
|
149
|
-
throw new Error("No streaming date received");
|
|
150
|
-
}
|
|
151
|
-
reader.cancel();
|
|
152
|
-
});
|
|
153
|
-
const streamResponse = await fetch(streamUrl, {
|
|
154
|
-
method: "POST",
|
|
155
|
-
signal,
|
|
156
|
-
headers: contentType ? { "Content-Type": contentType } : {}
|
|
157
|
-
});
|
|
158
|
-
const data = await streamResponse.json();
|
|
159
|
-
if (!data || typeof data !== "object") {
|
|
160
|
-
throw new Error("invalid stream response");
|
|
161
|
-
}
|
|
162
|
-
const { mime, url } = data;
|
|
163
|
-
await dataPromise;
|
|
164
|
-
const done = fetch(url, {
|
|
165
|
-
method: "POST",
|
|
166
|
-
signal,
|
|
167
|
-
duplex: "half",
|
|
168
|
-
body: dataStream
|
|
169
|
-
});
|
|
170
|
-
return [toStreamObject({ mime, url }), done];
|
|
126
|
+
// ../helpers/src/files/fileObject.ts
|
|
127
|
+
import { z as z3 } from "zod/v4";
|
|
128
|
+
var fileObjectSchema = z3.object({
|
|
129
|
+
size: z3.int().positive(),
|
|
130
|
+
mime: z3.string(),
|
|
131
|
+
url: z3.url(),
|
|
132
|
+
__REQUENCE_type: z3.literal("RequenceFile")
|
|
133
|
+
});
|
|
134
|
+
function toFileObject(fileInfo) {
|
|
135
|
+
return {
|
|
136
|
+
...fileInfo,
|
|
137
|
+
__REQUENCE_type: "RequenceFile"
|
|
138
|
+
};
|
|
171
139
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const mapped = await mapData(params.value, {
|
|
175
|
-
async Object(obj) {
|
|
176
|
-
if (obj instanceof Blob || obj instanceof RequenceFile) {
|
|
177
|
-
if (obj instanceof RequenceFile && obj.fileObject) {
|
|
178
|
-
return obj.fileObject;
|
|
179
|
-
}
|
|
180
|
-
if (params.options.uploadUrl) {
|
|
181
|
-
try {
|
|
182
|
-
if (obj instanceof Blob) {
|
|
183
|
-
return await upload(params.options.uploadUrl, obj, params.signal, obj.type);
|
|
184
|
-
}
|
|
185
|
-
if (obj instanceof RequenceFile) {
|
|
186
|
-
return await upload(params.options.uploadUrl, await obj.blob(), params.signal, obj.mimeType);
|
|
187
|
-
}
|
|
188
|
-
} catch (error) {
|
|
189
|
-
if (!(error instanceof Error)) {
|
|
190
|
-
throw error;
|
|
191
|
-
}
|
|
192
|
-
params.onFail?.(error);
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
|
-
} else {
|
|
196
|
-
params.onSkip?.();
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if (obj instanceof Response || obj instanceof RequenceStream) {
|
|
201
|
-
if (obj instanceof RequenceStream && obj.streamObject) {
|
|
202
|
-
return obj.streamObject;
|
|
203
|
-
}
|
|
204
|
-
if (params.options.streamUrl) {
|
|
205
|
-
try {
|
|
206
|
-
if (obj instanceof Response && obj.body) {
|
|
207
|
-
const [streamObject, streamPromise] = await stream(params.options.streamUrl, obj.body, params.signal, obj.headers.get("Content-Type"));
|
|
208
|
-
streamPromises.push(streamPromise);
|
|
209
|
-
return streamObject;
|
|
210
|
-
}
|
|
211
|
-
if (obj instanceof RequenceStream) {
|
|
212
|
-
const [streamObject, streamPromise] = await stream(params.options.streamUrl, obj.stream(), params.signal, obj.mimeType);
|
|
213
|
-
streamPromises.push(streamPromise);
|
|
214
|
-
return streamObject;
|
|
215
|
-
}
|
|
216
|
-
} catch (error) {
|
|
217
|
-
if (!(error instanceof Error)) {
|
|
218
|
-
throw error;
|
|
219
|
-
}
|
|
220
|
-
params.onFail?.(error);
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
} else {
|
|
224
|
-
params.onSkip?.();
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
Promise.allSettled(streamPromises).then(() => params.onDone?.());
|
|
231
|
-
return mapped;
|
|
140
|
+
function isFileObject(data) {
|
|
141
|
+
return fileObjectSchema.safeParse(data).success;
|
|
232
142
|
}
|
|
233
143
|
|
|
234
144
|
// ../helpers/src/files/RequenceFile.ts
|
|
@@ -295,15 +205,15 @@ class RequenceStream {
|
|
|
295
205
|
#data;
|
|
296
206
|
#stream = null;
|
|
297
207
|
#options;
|
|
298
|
-
constructor(
|
|
299
|
-
this.#data =
|
|
208
|
+
constructor(stream, options) {
|
|
209
|
+
this.#data = stream;
|
|
300
210
|
this.#options = options;
|
|
301
211
|
}
|
|
302
|
-
static fromStreamObject(
|
|
212
|
+
static fromStreamObject(stream) {
|
|
303
213
|
const instance = new this(null, {
|
|
304
214
|
type: "x/x"
|
|
305
215
|
});
|
|
306
|
-
instance.#stream =
|
|
216
|
+
instance.#stream = stream;
|
|
307
217
|
return instance;
|
|
308
218
|
}
|
|
309
219
|
get streamObject() {
|
|
@@ -352,11 +262,11 @@ class RequenceStream {
|
|
|
352
262
|
}
|
|
353
263
|
|
|
354
264
|
// ../helpers/src/files/streamObject.ts
|
|
355
|
-
import { z as
|
|
356
|
-
var streamObjectSchema =
|
|
357
|
-
mime:
|
|
358
|
-
url:
|
|
359
|
-
__REQUENCE_type:
|
|
265
|
+
import { z as z4 } from "zod/v4";
|
|
266
|
+
var streamObjectSchema = z4.object({
|
|
267
|
+
mime: z4.string(),
|
|
268
|
+
url: z4.string().url(),
|
|
269
|
+
__REQUENCE_type: z4.literal("RequenceStream")
|
|
360
270
|
});
|
|
361
271
|
function isStreamObject(data) {
|
|
362
272
|
return streamObjectSchema.safeParse(data).success;
|
|
@@ -368,22 +278,110 @@ function toStreamObject(streamInfo) {
|
|
|
368
278
|
};
|
|
369
279
|
}
|
|
370
280
|
|
|
371
|
-
// ../helpers/src/files/
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
281
|
+
// ../helpers/src/files/mapOutput.ts
|
|
282
|
+
async function upload(uploadUrl, body, signal, contentType) {
|
|
283
|
+
const uploadResponse = await fetch(uploadUrl, {
|
|
284
|
+
method: "POST",
|
|
285
|
+
signal,
|
|
286
|
+
headers: contentType ? {
|
|
287
|
+
"Content-Type": contentType
|
|
288
|
+
} : {},
|
|
289
|
+
body
|
|
290
|
+
});
|
|
291
|
+
const data = await uploadResponse.json();
|
|
292
|
+
if (!data || typeof data !== "object") {
|
|
293
|
+
throw new Error("invalid upload response");
|
|
294
|
+
}
|
|
295
|
+
return toFileObject(data);
|
|
384
296
|
}
|
|
385
|
-
function
|
|
386
|
-
|
|
297
|
+
async function stream(streamUrl, stream2, signal, contentType) {
|
|
298
|
+
const [testStream, dataStream] = stream2.tee();
|
|
299
|
+
const reader = testStream.getReader();
|
|
300
|
+
const dataPromise = reader.read().then(({ done: done2 }) => {
|
|
301
|
+
if (done2) {
|
|
302
|
+
throw new Error("No streaming date received");
|
|
303
|
+
}
|
|
304
|
+
reader.cancel();
|
|
305
|
+
});
|
|
306
|
+
const streamResponse = await fetch(streamUrl, {
|
|
307
|
+
method: "POST",
|
|
308
|
+
signal,
|
|
309
|
+
headers: contentType ? { "Content-Type": contentType } : {}
|
|
310
|
+
});
|
|
311
|
+
const data = await streamResponse.json();
|
|
312
|
+
if (!data || typeof data !== "object") {
|
|
313
|
+
throw new Error("invalid stream response");
|
|
314
|
+
}
|
|
315
|
+
const { mime, url } = data;
|
|
316
|
+
await dataPromise;
|
|
317
|
+
const done = fetch(url, {
|
|
318
|
+
method: "POST",
|
|
319
|
+
signal,
|
|
320
|
+
duplex: "half",
|
|
321
|
+
body: dataStream
|
|
322
|
+
});
|
|
323
|
+
return [toStreamObject({ mime, url }), done];
|
|
324
|
+
}
|
|
325
|
+
async function mapOutput(params) {
|
|
326
|
+
const streamPromises = [];
|
|
327
|
+
const mapped = await mapData(params.value, {
|
|
328
|
+
async Object(obj) {
|
|
329
|
+
if (obj instanceof Blob || obj instanceof RequenceFile) {
|
|
330
|
+
if (obj instanceof RequenceFile && obj.fileObject) {
|
|
331
|
+
return obj.fileObject;
|
|
332
|
+
}
|
|
333
|
+
if (params.options.uploadUrl) {
|
|
334
|
+
try {
|
|
335
|
+
if (obj instanceof Blob) {
|
|
336
|
+
return await upload(params.options.uploadUrl, obj, params.signal, obj.type);
|
|
337
|
+
}
|
|
338
|
+
if (obj instanceof RequenceFile) {
|
|
339
|
+
return await upload(params.options.uploadUrl, await obj.blob(), params.signal, obj.mimeType);
|
|
340
|
+
}
|
|
341
|
+
} catch (error) {
|
|
342
|
+
if (!(error instanceof Error)) {
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
params.onFail?.(error);
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
params.onSkip?.();
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (obj instanceof Response || obj instanceof RequenceStream) {
|
|
354
|
+
if (obj instanceof RequenceStream && obj.streamObject) {
|
|
355
|
+
return obj.streamObject;
|
|
356
|
+
}
|
|
357
|
+
if (params.options.streamUrl) {
|
|
358
|
+
try {
|
|
359
|
+
if (obj instanceof Response && obj.body) {
|
|
360
|
+
const [streamObject, streamPromise] = await stream(params.options.streamUrl, obj.body, params.signal, obj.headers.get("Content-Type"));
|
|
361
|
+
streamPromises.push(streamPromise);
|
|
362
|
+
return streamObject;
|
|
363
|
+
}
|
|
364
|
+
if (obj instanceof RequenceStream) {
|
|
365
|
+
const [streamObject, streamPromise] = await stream(params.options.streamUrl, obj.stream(), params.signal, obj.mimeType);
|
|
366
|
+
streamPromises.push(streamPromise);
|
|
367
|
+
return streamObject;
|
|
368
|
+
}
|
|
369
|
+
} catch (error) {
|
|
370
|
+
if (!(error instanceof Error)) {
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
params.onFail?.(error);
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
} else {
|
|
377
|
+
params.onSkip?.();
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
Promise.allSettled(streamPromises).then(() => params.onDone?.());
|
|
384
|
+
return mapped;
|
|
387
385
|
}
|
|
388
386
|
|
|
389
387
|
// ../helpers/src/utils/resolveRequenceTypes.ts
|
|
@@ -405,15 +403,14 @@ function resolveRequenceTypes(data, onCallback) {
|
|
|
405
403
|
});
|
|
406
404
|
}
|
|
407
405
|
|
|
408
|
-
// src/index.ts
|
|
409
|
-
import { z as z6 } from "zod/v4";
|
|
410
|
-
|
|
411
406
|
// src/createAmqpConnection.ts
|
|
412
|
-
import {
|
|
413
|
-
connect
|
|
414
|
-
} from "amqp-connection-manager";
|
|
407
|
+
import { connect } from "amqp-connection-manager";
|
|
415
408
|
import { z as z5 } from "zod/v4";
|
|
416
409
|
|
|
410
|
+
// src/errors.ts
|
|
411
|
+
class RequenceConnectionError extends Error {
|
|
412
|
+
}
|
|
413
|
+
|
|
417
414
|
// src/helpers.ts
|
|
418
415
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
419
416
|
class RetryError extends Error {
|
|
@@ -430,22 +427,6 @@ class SkipError extends Error {
|
|
|
430
427
|
class AbortError extends Error {
|
|
431
428
|
}
|
|
432
429
|
var OUTPUT_VALUE = Symbol("output_value");
|
|
433
|
-
|
|
434
|
-
class PromiseChain {
|
|
435
|
-
chain = Promise.resolve();
|
|
436
|
-
add(createPromise) {
|
|
437
|
-
this.chain = this.chain.then(createPromise);
|
|
438
|
-
}
|
|
439
|
-
async done() {
|
|
440
|
-
while (true) {
|
|
441
|
-
const lastChainSegment = this.chain;
|
|
442
|
-
await lastChainSegment;
|
|
443
|
-
if (lastChainSegment === this.chain) {
|
|
444
|
-
break;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
430
|
function isOutputValue(value) {
|
|
450
431
|
return value !== null && typeof value === "object" && OUTPUT_VALUE in value;
|
|
451
432
|
}
|
|
@@ -594,6 +575,18 @@ var backchannelMessageSchema = z5.object({
|
|
|
594
575
|
messageId: message.properties.correlationId
|
|
595
576
|
}));
|
|
596
577
|
var abortSymbol = Symbol();
|
|
578
|
+
var connectionOptionsSchema = z5.object({
|
|
579
|
+
url: z5.union([
|
|
580
|
+
z5.string().regex(/^amqps?:\/\/(.+):(.+)@(.+)$/).transform((str) => new URL(str)),
|
|
581
|
+
z5.instanceof(URL).refine((url) => url.protocol.match(/^amqps?:/), "Wrong protocol")
|
|
582
|
+
]),
|
|
583
|
+
version: z5.string(),
|
|
584
|
+
devOverlay: z5.string().optional(),
|
|
585
|
+
silent: z5.boolean().optional(),
|
|
586
|
+
prefetch: z5.number().int().optional(),
|
|
587
|
+
connectionTimeout: z5.number().positive().default(3000),
|
|
588
|
+
connectionOptions: z5.any()
|
|
589
|
+
});
|
|
597
590
|
function isMessageHandlerGenerator(handler) {
|
|
598
591
|
return handler.constructor.name === "GeneratorFunction" || handler.constructor.name === "AsyncGeneratorFunction";
|
|
599
592
|
}
|
|
@@ -604,9 +597,11 @@ function createConnection({
|
|
|
604
597
|
prefetch = 1,
|
|
605
598
|
silent = false,
|
|
606
599
|
connectionTimeout,
|
|
607
|
-
connectionOptions
|
|
600
|
+
connectionOptions,
|
|
601
|
+
devOverlay = ""
|
|
608
602
|
}, messageHandler) {
|
|
609
|
-
const
|
|
603
|
+
const baseQueue = `${url.username}@${version}`;
|
|
604
|
+
const queue = devOverlay ? `${baseQueue}-dev-overlay-${devOverlay}` : baseQueue;
|
|
610
605
|
const exchange = url.username;
|
|
611
606
|
const connection = connect(url.toString(), { connectionOptions });
|
|
612
607
|
const connectedPromise = new Promise((resolve2, reject) => {
|
|
@@ -616,7 +611,9 @@ function createConnection({
|
|
|
616
611
|
connection.removeListener("connectFailed", handleConnectFailed);
|
|
617
612
|
};
|
|
618
613
|
const timeout = setTimeout(() => {
|
|
619
|
-
handleConnectFailed({
|
|
614
|
+
handleConnectFailed({
|
|
615
|
+
err: new RequenceConnectionError("Requence connection timeout")
|
|
616
|
+
});
|
|
620
617
|
}, connectionTimeout);
|
|
621
618
|
const handleConnect = () => {
|
|
622
619
|
unsubscribe();
|
|
@@ -625,7 +622,7 @@ function createConnection({
|
|
|
625
622
|
const handleConnectFailed = ({ err }) => {
|
|
626
623
|
unsubscribe();
|
|
627
624
|
if (err.message.startsWith("Handshake terminated by server: 403 (ACCESS-REFUSED)")) {
|
|
628
|
-
reject(new
|
|
625
|
+
reject(new RequenceConnectionError("Invalid service credentials"));
|
|
629
626
|
} else {
|
|
630
627
|
reject(err);
|
|
631
628
|
}
|
|
@@ -634,9 +631,13 @@ function createConnection({
|
|
|
634
631
|
connection.addListener("connectFailed", handleConnectFailed);
|
|
635
632
|
});
|
|
636
633
|
const connectionId = crypto.randomUUID();
|
|
637
|
-
const backchannelQueue = `${
|
|
634
|
+
const backchannelQueue = `${baseQueue}-backchannel-${connectionId}`;
|
|
638
635
|
const channelWrapper = connection.createChannel({
|
|
639
636
|
async setup(channel) {
|
|
637
|
+
if (devOverlay) {
|
|
638
|
+
await channel.assertQueue(queue);
|
|
639
|
+
await channel.bindQueue(queue, "service", queue);
|
|
640
|
+
}
|
|
640
641
|
await channel.checkExchange(exchange);
|
|
641
642
|
await channel.checkExchange(`${exchange}-retry`);
|
|
642
643
|
await channel.checkQueue(queue);
|
|
@@ -657,7 +658,7 @@ function createConnection({
|
|
|
657
658
|
headers: {
|
|
658
659
|
outputName: outputName ?? null,
|
|
659
660
|
connectionId,
|
|
660
|
-
libVersion: "javascript@1.0.0-alpha.
|
|
661
|
+
libVersion: "javascript@1.0.0-alpha.50",
|
|
661
662
|
...headers
|
|
662
663
|
}
|
|
663
664
|
});
|
|
@@ -876,7 +877,7 @@ function createConnection({
|
|
|
876
877
|
headers: {
|
|
877
878
|
...message.properties.headers,
|
|
878
879
|
index: publishIndex++,
|
|
879
|
-
libVersion: "javascript@1.0.0-alpha.
|
|
880
|
+
libVersion: "javascript@1.0.0-alpha.50",
|
|
880
881
|
abort: true
|
|
881
882
|
}
|
|
882
883
|
});
|
|
@@ -895,7 +896,7 @@ function createConnection({
|
|
|
895
896
|
version,
|
|
896
897
|
exception: true,
|
|
897
898
|
index: publishIndex++,
|
|
898
|
-
libVersion: "javascript@1.0.0-alpha.
|
|
899
|
+
libVersion: "javascript@1.0.0-alpha.50",
|
|
899
900
|
"error-message": error.message || "error in service handler"
|
|
900
901
|
}
|
|
901
902
|
});
|
|
@@ -993,7 +994,7 @@ function createConnection({
|
|
|
993
994
|
contentType: "text/plain",
|
|
994
995
|
headers: {
|
|
995
996
|
taskId,
|
|
996
|
-
libVersion: "javascript@1.0.0-alpha.
|
|
997
|
+
libVersion: "javascript@1.0.0-alpha.50",
|
|
997
998
|
index: publishIndex++,
|
|
998
999
|
abort: true
|
|
999
1000
|
}
|
|
@@ -1108,17 +1109,13 @@ function asyncEventEmitter(initial = []) {
|
|
|
1108
1109
|
}
|
|
1109
1110
|
|
|
1110
1111
|
// src/index.ts
|
|
1111
|
-
var
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
prefetch: z6.number().int().optional(),
|
|
1119
|
-
connectionTimeout: z6.number().positive().default(3000),
|
|
1120
|
-
connectionOptions: z6.any()
|
|
1121
|
-
});
|
|
1112
|
+
var pkgJson;
|
|
1113
|
+
function loadPkgJson() {
|
|
1114
|
+
if (!pkgJson) {
|
|
1115
|
+
pkgJson = JSON.parse(fs.readFileSync("package.json", "utf-8"));
|
|
1116
|
+
}
|
|
1117
|
+
return pkgJson;
|
|
1118
|
+
}
|
|
1122
1119
|
function createService(optionsOrVersion, optionalMessageHandler) {
|
|
1123
1120
|
let options;
|
|
1124
1121
|
let messageHandler;
|
|
@@ -1134,22 +1131,41 @@ function createService(optionsOrVersion, optionalMessageHandler) {
|
|
|
1134
1131
|
let token = options.accessToken ?? process.env.REQUENCE_SERVICE_ACCESS_TOKEN ?? process.env.REQUENCE_ACCESS_TOKEN;
|
|
1135
1132
|
if (!token) {
|
|
1136
1133
|
try {
|
|
1137
|
-
const
|
|
1138
|
-
token =
|
|
1134
|
+
const pkgJson2 = loadPkgJson();
|
|
1135
|
+
token = pkgJson2.requence?.service?.accessToken ?? pkgJson2.requence?.accessToken;
|
|
1136
|
+
} catch {}
|
|
1137
|
+
}
|
|
1138
|
+
let devToken = options.devToken ?? process.env.REQUENCE_SERVICE_DEV_TOKEN ?? process.env.REQUENCE_DEV_TOKEN;
|
|
1139
|
+
if (!devToken) {
|
|
1140
|
+
try {
|
|
1141
|
+
const pkgJson2 = loadPkgJson();
|
|
1142
|
+
devToken = pkgJson2.requence?.service?.devToken ?? pkgJson2.requence?.devToken;
|
|
1139
1143
|
} catch {}
|
|
1140
1144
|
}
|
|
1141
1145
|
if (!token) {
|
|
1142
|
-
throw new Error("
|
|
1146
|
+
throw new Error("no access token provided");
|
|
1143
1147
|
}
|
|
1144
1148
|
const parts = deobfuscate(token);
|
|
1145
1149
|
if (parts.length < 2 || parts[0] !== "service") {
|
|
1146
|
-
throw new Error("
|
|
1150
|
+
throw new Error("invalid access token");
|
|
1147
1151
|
}
|
|
1148
|
-
const
|
|
1152
|
+
const url = parts[1];
|
|
1153
|
+
let devOverlay;
|
|
1154
|
+
if (devToken) {
|
|
1155
|
+
const devParts = deobfuscate(devToken);
|
|
1156
|
+
if (devParts[0] !== "api") {
|
|
1157
|
+
throw new Error("invalid dev token: please provide a personal access token");
|
|
1158
|
+
}
|
|
1159
|
+
if (devParts[2] !== parts[2]) {
|
|
1160
|
+
throw new Error("invalid dev token: access token and dev token belong to different requence instances");
|
|
1161
|
+
}
|
|
1162
|
+
devOverlay = devParts[1];
|
|
1163
|
+
}
|
|
1164
|
+
return createConnection(connectionOptionsSchema.parse({
|
|
1149
1165
|
...options,
|
|
1150
|
-
url
|
|
1151
|
-
|
|
1152
|
-
|
|
1166
|
+
url,
|
|
1167
|
+
devOverlay
|
|
1168
|
+
}), messageHandler);
|
|
1153
1169
|
}
|
|
1154
1170
|
export {
|
|
1155
1171
|
wrapIterable,
|
|
@@ -1157,8 +1173,9 @@ export {
|
|
|
1157
1173
|
createCallback,
|
|
1158
1174
|
asyncEventEmitter,
|
|
1159
1175
|
RequenceStream,
|
|
1160
|
-
RequenceFile
|
|
1176
|
+
RequenceFile,
|
|
1177
|
+
RequenceConnectionError
|
|
1161
1178
|
};
|
|
1162
1179
|
|
|
1163
|
-
//# debugId=
|
|
1180
|
+
//# debugId=57C0C865BD4C680C64756E2164756E21
|
|
1164
1181
|
//# sourceMappingURL=index.js.map
|