@trigger.dev/core 0.0.0-v3-trigger-dirs-20240422172150 → 0.0.0-v3-trigger-dirs-20240422221109
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/consoleInterceptor-6WZo2qUS.d.ts +6677 -0
- package/dist/consoleInterceptor-hjdjADX8.d.mts +6677 -0
- package/dist/manager-psJfQhBB.d.mts +1158 -0
- package/dist/manager-psJfQhBB.d.ts +1158 -0
- package/dist/messages-GvjBDSAA.d.mts +8696 -0
- package/dist/messages-GvjBDSAA.d.ts +8696 -0
- package/dist/tracingSDK-XMTLzw35.d.mts +35 -0
- package/dist/tracingSDK-XMTLzw35.d.ts +35 -0
- package/dist/v3/dev/index.d.mts +28 -0
- package/dist/v3/dev/index.d.ts +28 -0
- package/dist/v3/dev/index.js +93 -0
- package/dist/v3/dev/index.js.map +1 -0
- package/dist/v3/dev/index.mjs +91 -0
- package/dist/v3/dev/index.mjs.map +1 -0
- package/dist/v3/index.d.mts +13 -16849
- package/dist/v3/index.d.ts +13 -16849
- package/dist/v3/index.js +48 -1273
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +50 -1261
- package/dist/v3/index.mjs.map +1 -1
- package/dist/v3/otel/index.d.mts +6 -34
- package/dist/v3/otel/index.d.ts +6 -34
- package/dist/v3/prod/index.d.mts +45 -0
- package/dist/v3/prod/index.d.ts +45 -0
- package/dist/v3/prod/index.js +205 -0
- package/dist/v3/prod/index.js.map +1 -0
- package/dist/v3/prod/index.mjs +203 -0
- package/dist/v3/prod/index.mjs.map +1 -0
- package/dist/v3/utils/structuredLogger.d.mts +31 -0
- package/dist/v3/utils/structuredLogger.d.ts +31 -0
- package/dist/v3/utils/structuredLogger.js +88 -0
- package/dist/v3/utils/structuredLogger.js.map +1 -0
- package/dist/v3/utils/structuredLogger.mjs +86 -0
- package/dist/v3/utils/structuredLogger.mjs.map +1 -0
- package/dist/v3/workers/index.d.mts +49 -0
- package/dist/v3/workers/index.d.ts +49 -0
- package/dist/v3/workers/index.js +2056 -0
- package/dist/v3/workers/index.js.map +1 -0
- package/dist/v3/workers/index.mjs +2051 -0
- package/dist/v3/workers/index.mjs.map +1 -0
- package/dist/v3/zodIpc.d.mts +32 -0
- package/dist/v3/zodIpc.d.ts +32 -0
- package/dist/v3/zodIpc.js +268 -0
- package/dist/v3/zodIpc.js.map +1 -0
- package/dist/v3/zodIpc.mjs +266 -0
- package/dist/v3/zodIpc.mjs.map +1 -0
- package/dist/v3/zodMessageHandler.d.mts +69 -0
- package/dist/v3/zodMessageHandler.d.ts +69 -0
- package/dist/v3/zodMessageHandler.js +168 -0
- package/dist/v3/zodMessageHandler.js.map +1 -0
- package/dist/v3/zodMessageHandler.mjs +163 -0
- package/dist/v3/zodMessageHandler.mjs.map +1 -0
- package/dist/v3/zodNamespace.d.mts +3663 -0
- package/dist/v3/zodNamespace.d.ts +3663 -0
- package/dist/v3/zodNamespace.js +356 -0
- package/dist/v3/zodNamespace.js.map +1 -0
- package/dist/v3/zodNamespace.mjs +354 -0
- package/dist/v3/zodNamespace.mjs.map +1 -0
- package/dist/v3/zodSocket.d.mts +88 -0
- package/dist/v3/zodSocket.d.ts +88 -0
- package/dist/v3/zodSocket.js +309 -0
- package/dist/v3/zodSocket.js.map +1 -0
- package/dist/v3/zodSocket.mjs +305 -0
- package/dist/v3/zodSocket.mjs.map +1 -0
- package/package.json +69 -5
package/dist/v3/index.js
CHANGED
|
@@ -4,13 +4,10 @@ var zod = require('zod');
|
|
|
4
4
|
var api = require('@opentelemetry/api');
|
|
5
5
|
var zodValidationError = require('zod-validation-error');
|
|
6
6
|
var async_hooks = require('async_hooks');
|
|
7
|
-
var socket_ioClient = require('socket.io-client');
|
|
8
|
-
var crypto = require('crypto');
|
|
9
7
|
var nodePath = require('path');
|
|
10
8
|
var apiLogs = require('@opentelemetry/api-logs');
|
|
11
9
|
var preciseDate = require('@google-cloud/precise-date');
|
|
12
10
|
var humanizeDuration = require('humanize-duration');
|
|
13
|
-
var promises = require('timers/promises');
|
|
14
11
|
var util = require('util');
|
|
15
12
|
var exporterLogsOtlpHttp = require('@opentelemetry/exporter-logs-otlp-http');
|
|
16
13
|
var exporterTraceOtlpHttp = require('@opentelemetry/exporter-trace-otlp-http');
|
|
@@ -37,28 +34,11 @@ var __accessCheck = (obj, member, msg) => {
|
|
|
37
34
|
if (!member.has(obj))
|
|
38
35
|
throw TypeError("Cannot " + msg);
|
|
39
36
|
};
|
|
40
|
-
var __privateGet = (obj, member, getter) => {
|
|
41
|
-
__accessCheck(obj, member, "read from private field");
|
|
42
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
43
|
-
};
|
|
44
37
|
var __privateAdd = (obj, member, value) => {
|
|
45
38
|
if (member.has(obj))
|
|
46
39
|
throw TypeError("Cannot add the same private member more than once");
|
|
47
40
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
48
41
|
};
|
|
49
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
50
|
-
__accessCheck(obj, member, "write to private field");
|
|
51
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
52
|
-
return value;
|
|
53
|
-
};
|
|
54
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
55
|
-
set _(value) {
|
|
56
|
-
__privateSet(obj, member, value, setter);
|
|
57
|
-
},
|
|
58
|
-
get _() {
|
|
59
|
-
return __privateGet(obj, member, getter);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
42
|
var __privateMethod = (obj, member, method) => {
|
|
63
43
|
__accessCheck(obj, member, "access private method");
|
|
64
44
|
return method;
|
|
@@ -2380,729 +2360,6 @@ getStore_fn2 = /* @__PURE__ */ __name(function() {
|
|
|
2380
2360
|
__name(_ApiClientManager, "ApiClientManager");
|
|
2381
2361
|
var ApiClientManager = _ApiClientManager;
|
|
2382
2362
|
var apiClientManager = new ApiClientManager();
|
|
2383
|
-
var _ZodSchemaParsedError = class _ZodSchemaParsedError extends Error {
|
|
2384
|
-
constructor(error, payload) {
|
|
2385
|
-
super(error.message);
|
|
2386
|
-
this.error = error;
|
|
2387
|
-
this.payload = payload;
|
|
2388
|
-
}
|
|
2389
|
-
};
|
|
2390
|
-
__name(_ZodSchemaParsedError, "ZodSchemaParsedError");
|
|
2391
|
-
var ZodSchemaParsedError = _ZodSchemaParsedError;
|
|
2392
|
-
var ZodMessageSchema = zod.z.object({
|
|
2393
|
-
version: zod.z.literal("v1").default("v1"),
|
|
2394
|
-
type: zod.z.string(),
|
|
2395
|
-
payload: zod.z.unknown()
|
|
2396
|
-
});
|
|
2397
|
-
var _schema, _handlers;
|
|
2398
|
-
var _ZodMessageHandler = class _ZodMessageHandler {
|
|
2399
|
-
constructor(options) {
|
|
2400
|
-
__privateAdd(this, _schema, void 0);
|
|
2401
|
-
__privateAdd(this, _handlers, void 0);
|
|
2402
|
-
__privateSet(this, _schema, options.schema);
|
|
2403
|
-
__privateSet(this, _handlers, options.messages);
|
|
2404
|
-
}
|
|
2405
|
-
async handleMessage(message) {
|
|
2406
|
-
const parsedMessage = this.parseMessage(message);
|
|
2407
|
-
if (!__privateGet(this, _handlers)) {
|
|
2408
|
-
throw new Error("No handlers provided");
|
|
2409
|
-
}
|
|
2410
|
-
const handler = __privateGet(this, _handlers)[parsedMessage.type];
|
|
2411
|
-
if (!handler) {
|
|
2412
|
-
console.error(`No handler for message type: ${String(parsedMessage.type)}`);
|
|
2413
|
-
return;
|
|
2414
|
-
}
|
|
2415
|
-
const ack = await handler(parsedMessage.payload);
|
|
2416
|
-
return ack;
|
|
2417
|
-
}
|
|
2418
|
-
parseMessage(message) {
|
|
2419
|
-
const parsedMessage = ZodMessageSchema.safeParse(message);
|
|
2420
|
-
if (!parsedMessage.success) {
|
|
2421
|
-
throw new Error(`Failed to parse message: ${JSON.stringify(parsedMessage.error)}`);
|
|
2422
|
-
}
|
|
2423
|
-
const schema = __privateGet(this, _schema)[parsedMessage.data.type];
|
|
2424
|
-
if (!schema) {
|
|
2425
|
-
throw new Error(`Unknown message type: ${parsedMessage.data.type}`);
|
|
2426
|
-
}
|
|
2427
|
-
const parsedPayload = schema.safeParse(parsedMessage.data.payload);
|
|
2428
|
-
if (!parsedPayload.success) {
|
|
2429
|
-
throw new Error(`Failed to parse message payload: ${JSON.stringify(parsedPayload.error)}`);
|
|
2430
|
-
}
|
|
2431
|
-
return {
|
|
2432
|
-
type: parsedMessage.data.type,
|
|
2433
|
-
payload: parsedPayload.data
|
|
2434
|
-
};
|
|
2435
|
-
}
|
|
2436
|
-
registerHandlers(emitter, logger2) {
|
|
2437
|
-
const log = logger2 ?? console;
|
|
2438
|
-
if (!__privateGet(this, _handlers)) {
|
|
2439
|
-
log.info("No handlers provided");
|
|
2440
|
-
return;
|
|
2441
|
-
}
|
|
2442
|
-
for (const eventName of Object.keys(__privateGet(this, _schema))) {
|
|
2443
|
-
emitter.on(eventName, async (message, callback) => {
|
|
2444
|
-
log.info(`handling ${eventName}`, {
|
|
2445
|
-
payload: message,
|
|
2446
|
-
hasCallback: !!callback
|
|
2447
|
-
});
|
|
2448
|
-
let ack;
|
|
2449
|
-
if ("payload" in message) {
|
|
2450
|
-
ack = await this.handleMessage({
|
|
2451
|
-
type: eventName,
|
|
2452
|
-
...message
|
|
2453
|
-
});
|
|
2454
|
-
} else {
|
|
2455
|
-
const { version, ...payload } = message;
|
|
2456
|
-
ack = await this.handleMessage({
|
|
2457
|
-
type: eventName,
|
|
2458
|
-
version,
|
|
2459
|
-
payload
|
|
2460
|
-
});
|
|
2461
|
-
}
|
|
2462
|
-
if (callback && typeof callback === "function") {
|
|
2463
|
-
callback(ack);
|
|
2464
|
-
}
|
|
2465
|
-
});
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2468
|
-
};
|
|
2469
|
-
_schema = new WeakMap();
|
|
2470
|
-
_handlers = new WeakMap();
|
|
2471
|
-
__name(_ZodMessageHandler, "ZodMessageHandler");
|
|
2472
|
-
var ZodMessageHandler = _ZodMessageHandler;
|
|
2473
|
-
var _schema2, _sender;
|
|
2474
|
-
var _ZodMessageSender = class _ZodMessageSender {
|
|
2475
|
-
constructor(options) {
|
|
2476
|
-
__privateAdd(this, _schema2, void 0);
|
|
2477
|
-
__privateAdd(this, _sender, void 0);
|
|
2478
|
-
__privateSet(this, _schema2, options.schema);
|
|
2479
|
-
__privateSet(this, _sender, options.sender);
|
|
2480
|
-
}
|
|
2481
|
-
async send(type, payload) {
|
|
2482
|
-
const schema = __privateGet(this, _schema2)[type];
|
|
2483
|
-
if (!schema) {
|
|
2484
|
-
throw new Error(`Unknown message type: ${type}`);
|
|
2485
|
-
}
|
|
2486
|
-
const parsedPayload = schema.safeParse(payload);
|
|
2487
|
-
if (!parsedPayload.success) {
|
|
2488
|
-
throw new ZodSchemaParsedError(parsedPayload.error, payload);
|
|
2489
|
-
}
|
|
2490
|
-
await __privateGet(this, _sender).call(this, {
|
|
2491
|
-
type,
|
|
2492
|
-
payload,
|
|
2493
|
-
version: "v1"
|
|
2494
|
-
});
|
|
2495
|
-
}
|
|
2496
|
-
async forwardMessage(message) {
|
|
2497
|
-
const parsedMessage = ZodMessageSchema.safeParse(message);
|
|
2498
|
-
if (!parsedMessage.success) {
|
|
2499
|
-
throw new Error(`Failed to parse message: ${JSON.stringify(parsedMessage.error)}`);
|
|
2500
|
-
}
|
|
2501
|
-
const schema = __privateGet(this, _schema2)[parsedMessage.data.type];
|
|
2502
|
-
if (!schema) {
|
|
2503
|
-
throw new Error(`Unknown message type: ${parsedMessage.data.type}`);
|
|
2504
|
-
}
|
|
2505
|
-
const parsedPayload = schema.safeParse(parsedMessage.data.payload);
|
|
2506
|
-
if (!parsedPayload.success) {
|
|
2507
|
-
throw new Error(`Failed to parse message payload: ${JSON.stringify(parsedPayload.error)}`);
|
|
2508
|
-
}
|
|
2509
|
-
await __privateGet(this, _sender).call(this, {
|
|
2510
|
-
type: parsedMessage.data.type,
|
|
2511
|
-
payload: parsedPayload.data,
|
|
2512
|
-
version: "v1"
|
|
2513
|
-
});
|
|
2514
|
-
}
|
|
2515
|
-
};
|
|
2516
|
-
_schema2 = new WeakMap();
|
|
2517
|
-
_sender = new WeakMap();
|
|
2518
|
-
__name(_ZodMessageSender, "ZodMessageSender");
|
|
2519
|
-
var ZodMessageSender = _ZodMessageSender;
|
|
2520
|
-
var messageSchema = zod.z.object({
|
|
2521
|
-
version: zod.z.literal("v1").default("v1"),
|
|
2522
|
-
type: zod.z.string(),
|
|
2523
|
-
payload: zod.z.unknown()
|
|
2524
|
-
});
|
|
2525
|
-
var _schema3, _handlers2;
|
|
2526
|
-
var _ZodSocketMessageHandler = class _ZodSocketMessageHandler {
|
|
2527
|
-
constructor(options) {
|
|
2528
|
-
__privateAdd(this, _schema3, void 0);
|
|
2529
|
-
__privateAdd(this, _handlers2, void 0);
|
|
2530
|
-
__privateSet(this, _schema3, options.schema);
|
|
2531
|
-
__privateSet(this, _handlers2, options.handlers);
|
|
2532
|
-
}
|
|
2533
|
-
async handleMessage(message) {
|
|
2534
|
-
const parsedMessage = this.parseMessage(message);
|
|
2535
|
-
if (!__privateGet(this, _handlers2)) {
|
|
2536
|
-
throw new Error("No handlers provided");
|
|
2537
|
-
}
|
|
2538
|
-
const handler = __privateGet(this, _handlers2)[parsedMessage.type];
|
|
2539
|
-
if (!handler) {
|
|
2540
|
-
console.error(`No handler for message type: ${String(parsedMessage.type)}`);
|
|
2541
|
-
return;
|
|
2542
|
-
}
|
|
2543
|
-
const ack = await handler(parsedMessage.payload);
|
|
2544
|
-
return ack;
|
|
2545
|
-
}
|
|
2546
|
-
parseMessage(message) {
|
|
2547
|
-
const parsedMessage = messageSchema.safeParse(message);
|
|
2548
|
-
if (!parsedMessage.success) {
|
|
2549
|
-
throw new Error(`Failed to parse message: ${JSON.stringify(parsedMessage.error)}`);
|
|
2550
|
-
}
|
|
2551
|
-
const schema = __privateGet(this, _schema3)[parsedMessage.data.type]["message"];
|
|
2552
|
-
if (!schema) {
|
|
2553
|
-
throw new Error(`Unknown message type: ${parsedMessage.data.type}`);
|
|
2554
|
-
}
|
|
2555
|
-
const parsedPayload = schema.safeParse(parsedMessage.data.payload);
|
|
2556
|
-
if (!parsedPayload.success) {
|
|
2557
|
-
throw new Error(`Failed to parse message payload: ${JSON.stringify(parsedPayload.error)}`);
|
|
2558
|
-
}
|
|
2559
|
-
return {
|
|
2560
|
-
type: parsedMessage.data.type,
|
|
2561
|
-
payload: parsedPayload.data
|
|
2562
|
-
};
|
|
2563
|
-
}
|
|
2564
|
-
registerHandlers(emitter, logger2) {
|
|
2565
|
-
const log = logger2 ?? console;
|
|
2566
|
-
if (!__privateGet(this, _handlers2)) {
|
|
2567
|
-
log.info("No handlers provided");
|
|
2568
|
-
return;
|
|
2569
|
-
}
|
|
2570
|
-
for (const eventName of Object.keys(__privateGet(this, _handlers2))) {
|
|
2571
|
-
emitter.on(eventName, async (message, callback) => {
|
|
2572
|
-
log.info(`handling ${eventName}`, {
|
|
2573
|
-
payload: message,
|
|
2574
|
-
hasCallback: !!callback
|
|
2575
|
-
});
|
|
2576
|
-
let ack;
|
|
2577
|
-
try {
|
|
2578
|
-
if ("payload" in message) {
|
|
2579
|
-
ack = await this.handleMessage({
|
|
2580
|
-
type: eventName,
|
|
2581
|
-
...message
|
|
2582
|
-
});
|
|
2583
|
-
} else {
|
|
2584
|
-
const { version, ...payload } = message;
|
|
2585
|
-
ack = await this.handleMessage({
|
|
2586
|
-
type: eventName,
|
|
2587
|
-
version,
|
|
2588
|
-
payload
|
|
2589
|
-
});
|
|
2590
|
-
}
|
|
2591
|
-
} catch (error) {
|
|
2592
|
-
log.error("Error while handling message", {
|
|
2593
|
-
error
|
|
2594
|
-
});
|
|
2595
|
-
return;
|
|
2596
|
-
}
|
|
2597
|
-
if (callback && typeof callback === "function") {
|
|
2598
|
-
callback(ack);
|
|
2599
|
-
}
|
|
2600
|
-
});
|
|
2601
|
-
}
|
|
2602
|
-
}
|
|
2603
|
-
};
|
|
2604
|
-
_schema3 = new WeakMap();
|
|
2605
|
-
_handlers2 = new WeakMap();
|
|
2606
|
-
__name(_ZodSocketMessageHandler, "ZodSocketMessageHandler");
|
|
2607
|
-
var ZodSocketMessageHandler = _ZodSocketMessageHandler;
|
|
2608
|
-
var _schema4, _socket;
|
|
2609
|
-
var _ZodSocketMessageSender = class _ZodSocketMessageSender {
|
|
2610
|
-
constructor(options) {
|
|
2611
|
-
__privateAdd(this, _schema4, void 0);
|
|
2612
|
-
__privateAdd(this, _socket, void 0);
|
|
2613
|
-
__privateSet(this, _schema4, options.schema);
|
|
2614
|
-
__privateSet(this, _socket, options.socket);
|
|
2615
|
-
}
|
|
2616
|
-
send(type, payload) {
|
|
2617
|
-
const schema = __privateGet(this, _schema4)[type]["message"];
|
|
2618
|
-
if (!schema) {
|
|
2619
|
-
throw new Error(`Unknown message type: ${type}`);
|
|
2620
|
-
}
|
|
2621
|
-
const parsedPayload = schema.safeParse(payload);
|
|
2622
|
-
if (!parsedPayload.success) {
|
|
2623
|
-
throw new Error(`Failed to parse message payload: ${JSON.stringify(parsedPayload.error)}`);
|
|
2624
|
-
}
|
|
2625
|
-
__privateGet(this, _socket).emit(type, {
|
|
2626
|
-
payload,
|
|
2627
|
-
version: "v1"
|
|
2628
|
-
});
|
|
2629
|
-
return;
|
|
2630
|
-
}
|
|
2631
|
-
async sendWithAck(type, payload) {
|
|
2632
|
-
const schema = __privateGet(this, _schema4)[type]["message"];
|
|
2633
|
-
if (!schema) {
|
|
2634
|
-
throw new Error(`Unknown message type: ${type}`);
|
|
2635
|
-
}
|
|
2636
|
-
const parsedPayload = schema.safeParse(payload);
|
|
2637
|
-
if (!parsedPayload.success) {
|
|
2638
|
-
throw new Error(`Failed to parse message payload: ${JSON.stringify(parsedPayload.error)}`);
|
|
2639
|
-
}
|
|
2640
|
-
const callbackResult = await __privateGet(this, _socket).emitWithAck(type, {
|
|
2641
|
-
payload,
|
|
2642
|
-
version: "v1"
|
|
2643
|
-
});
|
|
2644
|
-
return callbackResult;
|
|
2645
|
-
}
|
|
2646
|
-
};
|
|
2647
|
-
_schema4 = new WeakMap();
|
|
2648
|
-
_socket = new WeakMap();
|
|
2649
|
-
__name(_ZodSocketMessageSender, "ZodSocketMessageSender");
|
|
2650
|
-
var ZodSocketMessageSender = _ZodSocketMessageSender;
|
|
2651
|
-
var _sender2, _handler, _logger;
|
|
2652
|
-
var _ZodSocketConnection = class _ZodSocketConnection {
|
|
2653
|
-
constructor(opts) {
|
|
2654
|
-
__privateAdd(this, _sender2, void 0);
|
|
2655
|
-
__privateAdd(this, _handler, void 0);
|
|
2656
|
-
__privateAdd(this, _logger, void 0);
|
|
2657
|
-
const uri = `${opts.secure ? "wss" : "ws"}://${opts.host}:${opts.port ?? (opts.secure ? "443" : "80")}/${opts.namespace}`;
|
|
2658
|
-
const logger2 = new SimpleStructuredLogger(opts.namespace, exports.LogLevel.info);
|
|
2659
|
-
logger2.log("new zod socket", {
|
|
2660
|
-
uri
|
|
2661
|
-
});
|
|
2662
|
-
this.socket = socket_ioClient.io(uri, {
|
|
2663
|
-
transports: [
|
|
2664
|
-
"websocket"
|
|
2665
|
-
],
|
|
2666
|
-
auth: {
|
|
2667
|
-
token: opts.authToken
|
|
2668
|
-
},
|
|
2669
|
-
extraHeaders: opts.extraHeaders,
|
|
2670
|
-
reconnectionDelay: 500,
|
|
2671
|
-
reconnectionDelayMax: 1e3
|
|
2672
|
-
});
|
|
2673
|
-
__privateSet(this, _logger, logger2.child({
|
|
2674
|
-
socketId: this.socket.id
|
|
2675
|
-
}));
|
|
2676
|
-
__privateSet(this, _handler, new ZodSocketMessageHandler({
|
|
2677
|
-
schema: opts.serverMessages,
|
|
2678
|
-
handlers: opts.handlers
|
|
2679
|
-
}));
|
|
2680
|
-
__privateGet(this, _handler).registerHandlers(this.socket, __privateGet(this, _logger));
|
|
2681
|
-
__privateSet(this, _sender2, new ZodSocketMessageSender({
|
|
2682
|
-
schema: opts.clientMessages,
|
|
2683
|
-
socket: this.socket
|
|
2684
|
-
}));
|
|
2685
|
-
this.socket.on("connect_error", async (error) => {
|
|
2686
|
-
__privateGet(this, _logger).error(`connect_error: ${error}`);
|
|
2687
|
-
if (opts.onError) {
|
|
2688
|
-
await opts.onError(this.socket, error, __privateGet(this, _logger));
|
|
2689
|
-
}
|
|
2690
|
-
});
|
|
2691
|
-
this.socket.on("connect", async () => {
|
|
2692
|
-
__privateGet(this, _logger).info("connect");
|
|
2693
|
-
if (opts.onConnection) {
|
|
2694
|
-
await opts.onConnection(this.socket, __privateGet(this, _handler), __privateGet(this, _sender2), __privateGet(this, _logger));
|
|
2695
|
-
}
|
|
2696
|
-
});
|
|
2697
|
-
this.socket.on("disconnect", async (reason, description) => {
|
|
2698
|
-
__privateGet(this, _logger).info("disconnect", {
|
|
2699
|
-
reason,
|
|
2700
|
-
description
|
|
2701
|
-
});
|
|
2702
|
-
if (opts.onDisconnect) {
|
|
2703
|
-
await opts.onDisconnect(this.socket, reason, description, __privateGet(this, _logger));
|
|
2704
|
-
}
|
|
2705
|
-
});
|
|
2706
|
-
}
|
|
2707
|
-
close() {
|
|
2708
|
-
this.socket.close();
|
|
2709
|
-
}
|
|
2710
|
-
connect() {
|
|
2711
|
-
this.socket.connect();
|
|
2712
|
-
}
|
|
2713
|
-
get send() {
|
|
2714
|
-
return __privateGet(this, _sender2).send.bind(__privateGet(this, _sender2));
|
|
2715
|
-
}
|
|
2716
|
-
get sendWithAck() {
|
|
2717
|
-
return __privateGet(this, _sender2).sendWithAck.bind(__privateGet(this, _sender2));
|
|
2718
|
-
}
|
|
2719
|
-
};
|
|
2720
|
-
_sender2 = new WeakMap();
|
|
2721
|
-
_handler = new WeakMap();
|
|
2722
|
-
_logger = new WeakMap();
|
|
2723
|
-
__name(_ZodSocketConnection, "ZodSocketConnection");
|
|
2724
|
-
var ZodSocketConnection = _ZodSocketConnection;
|
|
2725
|
-
|
|
2726
|
-
// src/v3/zodNamespace.ts
|
|
2727
|
-
exports.LogLevel = void 0;
|
|
2728
|
-
(function(LogLevel2) {
|
|
2729
|
-
LogLevel2[LogLevel2["log"] = 0] = "log";
|
|
2730
|
-
LogLevel2[LogLevel2["error"] = 1] = "error";
|
|
2731
|
-
LogLevel2[LogLevel2["warn"] = 2] = "warn";
|
|
2732
|
-
LogLevel2[LogLevel2["info"] = 3] = "info";
|
|
2733
|
-
LogLevel2[LogLevel2["debug"] = 4] = "debug";
|
|
2734
|
-
})(exports.LogLevel || (exports.LogLevel = {}));
|
|
2735
|
-
var _structuredLog, structuredLog_fn;
|
|
2736
|
-
var _SimpleStructuredLogger = class _SimpleStructuredLogger {
|
|
2737
|
-
constructor(name, level = [
|
|
2738
|
-
"1",
|
|
2739
|
-
"true"
|
|
2740
|
-
].includes(process.env.DEBUG ?? "") ? exports.LogLevel.debug : exports.LogLevel.info, fields) {
|
|
2741
|
-
__privateAdd(this, _structuredLog);
|
|
2742
|
-
this.name = name;
|
|
2743
|
-
this.level = level;
|
|
2744
|
-
this.fields = fields;
|
|
2745
|
-
}
|
|
2746
|
-
child(fields, level) {
|
|
2747
|
-
return new _SimpleStructuredLogger(this.name, level, {
|
|
2748
|
-
...this.fields,
|
|
2749
|
-
...fields
|
|
2750
|
-
});
|
|
2751
|
-
}
|
|
2752
|
-
log(message, ...args) {
|
|
2753
|
-
if (this.level < exports.LogLevel.log)
|
|
2754
|
-
return;
|
|
2755
|
-
__privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.log, message, "log", ...args);
|
|
2756
|
-
}
|
|
2757
|
-
error(message, ...args) {
|
|
2758
|
-
if (this.level < exports.LogLevel.error)
|
|
2759
|
-
return;
|
|
2760
|
-
__privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.error, message, "error", ...args);
|
|
2761
|
-
}
|
|
2762
|
-
warn(message, ...args) {
|
|
2763
|
-
if (this.level < exports.LogLevel.warn)
|
|
2764
|
-
return;
|
|
2765
|
-
__privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.warn, message, "warn", ...args);
|
|
2766
|
-
}
|
|
2767
|
-
info(message, ...args) {
|
|
2768
|
-
if (this.level < exports.LogLevel.info)
|
|
2769
|
-
return;
|
|
2770
|
-
__privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.info, message, "info", ...args);
|
|
2771
|
-
}
|
|
2772
|
-
debug(message, ...args) {
|
|
2773
|
-
if (this.level < exports.LogLevel.debug)
|
|
2774
|
-
return;
|
|
2775
|
-
__privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.debug, message, "debug", ...args);
|
|
2776
|
-
}
|
|
2777
|
-
};
|
|
2778
|
-
_structuredLog = new WeakSet();
|
|
2779
|
-
structuredLog_fn = /* @__PURE__ */ __name(function(loggerFunction, message, level, ...args) {
|
|
2780
|
-
const structuredLog = {
|
|
2781
|
-
...args.length === 1 ? args[0] : args,
|
|
2782
|
-
...this.fields,
|
|
2783
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
2784
|
-
name: this.name,
|
|
2785
|
-
message,
|
|
2786
|
-
level
|
|
2787
|
-
};
|
|
2788
|
-
loggerFunction(JSON.stringify(structuredLog));
|
|
2789
|
-
}, "#structuredLog");
|
|
2790
|
-
__name(_SimpleStructuredLogger, "SimpleStructuredLogger");
|
|
2791
|
-
var SimpleStructuredLogger = _SimpleStructuredLogger;
|
|
2792
|
-
var _logger2, _handler2;
|
|
2793
|
-
var _ZodNamespace = class _ZodNamespace {
|
|
2794
|
-
constructor(opts) {
|
|
2795
|
-
__privateAdd(this, _logger2, void 0);
|
|
2796
|
-
__privateAdd(this, _handler2, void 0);
|
|
2797
|
-
__privateSet(this, _logger2, opts.logger ?? new SimpleStructuredLogger(opts.name));
|
|
2798
|
-
__privateSet(this, _handler2, new ZodSocketMessageHandler({
|
|
2799
|
-
schema: opts.clientMessages,
|
|
2800
|
-
handlers: opts.handlers
|
|
2801
|
-
}));
|
|
2802
|
-
this.io = opts.io;
|
|
2803
|
-
this.namespace = this.io.of(opts.name);
|
|
2804
|
-
this.sender = new ZodMessageSender({
|
|
2805
|
-
schema: opts.serverMessages,
|
|
2806
|
-
sender: async (message) => {
|
|
2807
|
-
return new Promise((resolve, reject) => {
|
|
2808
|
-
try {
|
|
2809
|
-
this.namespace.emit(message.type, message.payload);
|
|
2810
|
-
resolve();
|
|
2811
|
-
} catch (err) {
|
|
2812
|
-
reject(err);
|
|
2813
|
-
}
|
|
2814
|
-
});
|
|
2815
|
-
}
|
|
2816
|
-
});
|
|
2817
|
-
if (opts.preAuth) {
|
|
2818
|
-
this.namespace.use(async (socket, next) => {
|
|
2819
|
-
const logger2 = __privateGet(this, _logger2).child({
|
|
2820
|
-
socketId: socket.id,
|
|
2821
|
-
socketStage: "preAuth"
|
|
2822
|
-
});
|
|
2823
|
-
if (typeof opts.preAuth === "function") {
|
|
2824
|
-
await opts.preAuth(socket, next, logger2);
|
|
2825
|
-
}
|
|
2826
|
-
});
|
|
2827
|
-
}
|
|
2828
|
-
if (opts.authToken) {
|
|
2829
|
-
this.namespace.use((socket, next) => {
|
|
2830
|
-
const logger2 = __privateGet(this, _logger2).child({
|
|
2831
|
-
socketId: socket.id,
|
|
2832
|
-
socketStage: "auth"
|
|
2833
|
-
});
|
|
2834
|
-
const { auth } = socket.handshake;
|
|
2835
|
-
if (!("token" in auth)) {
|
|
2836
|
-
logger2.error("no token");
|
|
2837
|
-
return socket.disconnect(true);
|
|
2838
|
-
}
|
|
2839
|
-
if (auth.token !== opts.authToken) {
|
|
2840
|
-
logger2.error("invalid token");
|
|
2841
|
-
return socket.disconnect(true);
|
|
2842
|
-
}
|
|
2843
|
-
logger2.info("success");
|
|
2844
|
-
next();
|
|
2845
|
-
});
|
|
2846
|
-
}
|
|
2847
|
-
if (opts.postAuth) {
|
|
2848
|
-
this.namespace.use(async (socket, next) => {
|
|
2849
|
-
const logger2 = __privateGet(this, _logger2).child({
|
|
2850
|
-
socketId: socket.id,
|
|
2851
|
-
socketStage: "auth"
|
|
2852
|
-
});
|
|
2853
|
-
if (typeof opts.postAuth === "function") {
|
|
2854
|
-
await opts.postAuth(socket, next, logger2);
|
|
2855
|
-
}
|
|
2856
|
-
});
|
|
2857
|
-
}
|
|
2858
|
-
this.namespace.on("connection", async (socket) => {
|
|
2859
|
-
const logger2 = __privateGet(this, _logger2).child({
|
|
2860
|
-
socketId: socket.id,
|
|
2861
|
-
socketStage: "connection"
|
|
2862
|
-
});
|
|
2863
|
-
logger2.info("connected");
|
|
2864
|
-
__privateGet(this, _handler2).registerHandlers(socket, logger2);
|
|
2865
|
-
socket.on("disconnect", async (reason, description) => {
|
|
2866
|
-
logger2.info("disconnect", {
|
|
2867
|
-
reason,
|
|
2868
|
-
description
|
|
2869
|
-
});
|
|
2870
|
-
if (opts.onDisconnect) {
|
|
2871
|
-
await opts.onDisconnect(socket, reason, description, logger2);
|
|
2872
|
-
}
|
|
2873
|
-
});
|
|
2874
|
-
socket.on("error", async (error) => {
|
|
2875
|
-
logger2.error("error", {
|
|
2876
|
-
error
|
|
2877
|
-
});
|
|
2878
|
-
if (opts.onError) {
|
|
2879
|
-
await opts.onError(socket, error, logger2);
|
|
2880
|
-
}
|
|
2881
|
-
});
|
|
2882
|
-
if (opts.onConnection) {
|
|
2883
|
-
await opts.onConnection(socket, __privateGet(this, _handler2), this.sender, logger2);
|
|
2884
|
-
}
|
|
2885
|
-
});
|
|
2886
|
-
}
|
|
2887
|
-
fetchSockets() {
|
|
2888
|
-
return this.namespace.fetchSockets();
|
|
2889
|
-
}
|
|
2890
|
-
};
|
|
2891
|
-
_logger2 = new WeakMap();
|
|
2892
|
-
_handler2 = new WeakMap();
|
|
2893
|
-
__name(_ZodNamespace, "ZodNamespace");
|
|
2894
|
-
var ZodNamespace = _ZodNamespace;
|
|
2895
|
-
var messageSchema2 = zod.z.object({
|
|
2896
|
-
version: zod.z.literal("v1").default("v1"),
|
|
2897
|
-
type: zod.z.string(),
|
|
2898
|
-
payload: zod.z.unknown()
|
|
2899
|
-
});
|
|
2900
|
-
var _schema5, _handlers3, _sender3, _a;
|
|
2901
|
-
var ZodIpcMessageHandler = (_a = class {
|
|
2902
|
-
constructor(options) {
|
|
2903
|
-
__privateAdd(this, _schema5, void 0);
|
|
2904
|
-
__privateAdd(this, _handlers3, void 0);
|
|
2905
|
-
__privateAdd(this, _sender3, void 0);
|
|
2906
|
-
__privateSet(this, _schema5, options.schema);
|
|
2907
|
-
__privateSet(this, _handlers3, options.handlers);
|
|
2908
|
-
__privateSet(this, _sender3, options.sender);
|
|
2909
|
-
}
|
|
2910
|
-
async handleMessage(message) {
|
|
2911
|
-
const parsedMessage = this.parseMessage(message);
|
|
2912
|
-
if (!__privateGet(this, _handlers3)) {
|
|
2913
|
-
throw new Error("No handlers provided");
|
|
2914
|
-
}
|
|
2915
|
-
const handler = __privateGet(this, _handlers3)[parsedMessage.type];
|
|
2916
|
-
if (!handler) {
|
|
2917
|
-
return;
|
|
2918
|
-
}
|
|
2919
|
-
const ack = await handler(parsedMessage.payload, __privateGet(this, _sender3));
|
|
2920
|
-
return ack;
|
|
2921
|
-
}
|
|
2922
|
-
parseMessage(message) {
|
|
2923
|
-
const parsedMessage = messageSchema2.safeParse(message);
|
|
2924
|
-
if (!parsedMessage.success) {
|
|
2925
|
-
throw new Error(`Failed to parse message: ${JSON.stringify(parsedMessage.error)}`);
|
|
2926
|
-
}
|
|
2927
|
-
const schema = __privateGet(this, _schema5)[parsedMessage.data.type]["message"];
|
|
2928
|
-
if (!schema) {
|
|
2929
|
-
throw new Error(`Unknown message type: ${parsedMessage.data.type}`);
|
|
2930
|
-
}
|
|
2931
|
-
const parsedPayload = schema.safeParse(parsedMessage.data.payload);
|
|
2932
|
-
if (!parsedPayload.success) {
|
|
2933
|
-
throw new Error(`Failed to parse message payload: ${JSON.stringify(parsedPayload.error)}`);
|
|
2934
|
-
}
|
|
2935
|
-
return {
|
|
2936
|
-
type: parsedMessage.data.type,
|
|
2937
|
-
payload: parsedPayload.data
|
|
2938
|
-
};
|
|
2939
|
-
}
|
|
2940
|
-
}, _schema5 = new WeakMap(), _handlers3 = new WeakMap(), _sender3 = new WeakMap(), __name(_a, "ZodIpcMessageHandler"), _a);
|
|
2941
|
-
var Packet = zod.z.discriminatedUnion("type", [
|
|
2942
|
-
zod.z.object({
|
|
2943
|
-
type: zod.z.literal("CONNECT"),
|
|
2944
|
-
sessionId: zod.z.string().optional()
|
|
2945
|
-
}),
|
|
2946
|
-
zod.z.object({
|
|
2947
|
-
type: zod.z.literal("ACK"),
|
|
2948
|
-
message: zod.z.any(),
|
|
2949
|
-
id: zod.z.number()
|
|
2950
|
-
}),
|
|
2951
|
-
zod.z.object({
|
|
2952
|
-
type: zod.z.literal("EVENT"),
|
|
2953
|
-
message: zod.z.any(),
|
|
2954
|
-
id: zod.z.number().optional()
|
|
2955
|
-
})
|
|
2956
|
-
]);
|
|
2957
|
-
var _sessionId, _messageCounter, _handler3, _acks, _registerHandlers, registerHandlers_fn, _handlePacket, handlePacket_fn, _sendPacket, sendPacket_fn;
|
|
2958
|
-
var _ZodIpcConnection = class _ZodIpcConnection {
|
|
2959
|
-
constructor(opts) {
|
|
2960
|
-
__privateAdd(this, _registerHandlers);
|
|
2961
|
-
__privateAdd(this, _handlePacket);
|
|
2962
|
-
__privateAdd(this, _sendPacket);
|
|
2963
|
-
__privateAdd(this, _sessionId, void 0);
|
|
2964
|
-
__privateAdd(this, _messageCounter, void 0);
|
|
2965
|
-
__privateAdd(this, _handler3, void 0);
|
|
2966
|
-
__privateAdd(this, _acks, void 0);
|
|
2967
|
-
this.opts = opts;
|
|
2968
|
-
__privateSet(this, _messageCounter, 0);
|
|
2969
|
-
__privateSet(this, _acks, /* @__PURE__ */ new Map());
|
|
2970
|
-
__privateSet(this, _handler3, new ZodIpcMessageHandler({
|
|
2971
|
-
schema: opts.listenSchema,
|
|
2972
|
-
handlers: opts.handlers,
|
|
2973
|
-
sender: {
|
|
2974
|
-
send: this.send.bind(this),
|
|
2975
|
-
sendWithAck: this.sendWithAck.bind(this)
|
|
2976
|
-
}
|
|
2977
|
-
}));
|
|
2978
|
-
__privateMethod(this, _registerHandlers, registerHandlers_fn).call(this);
|
|
2979
|
-
}
|
|
2980
|
-
async connect() {
|
|
2981
|
-
__privateMethod(this, _sendPacket, sendPacket_fn).call(this, {
|
|
2982
|
-
type: "CONNECT"
|
|
2983
|
-
});
|
|
2984
|
-
}
|
|
2985
|
-
async send(type, payload) {
|
|
2986
|
-
const schema = this.opts.emitSchema[type]["message"];
|
|
2987
|
-
if (!schema) {
|
|
2988
|
-
throw new Error(`Unknown message type: ${type}`);
|
|
2989
|
-
}
|
|
2990
|
-
const parsedPayload = schema.safeParse(payload);
|
|
2991
|
-
if (!parsedPayload.success) {
|
|
2992
|
-
throw new ZodSchemaParsedError(parsedPayload.error, payload);
|
|
2993
|
-
}
|
|
2994
|
-
await __privateMethod(this, _sendPacket, sendPacket_fn).call(this, {
|
|
2995
|
-
type: "EVENT",
|
|
2996
|
-
message: {
|
|
2997
|
-
type,
|
|
2998
|
-
payload,
|
|
2999
|
-
version: "v1"
|
|
3000
|
-
}
|
|
3001
|
-
});
|
|
3002
|
-
}
|
|
3003
|
-
async sendWithAck(type, payload, timeoutInMs) {
|
|
3004
|
-
const currentId = __privateWrapper(this, _messageCounter)._++;
|
|
3005
|
-
return new Promise(async (resolve, reject) => {
|
|
3006
|
-
const defaultTimeoutInMs = 2e3;
|
|
3007
|
-
const timeout = setTimeout(() => {
|
|
3008
|
-
reject(JSON.stringify({
|
|
3009
|
-
reason: "sendWithAck() timeout",
|
|
3010
|
-
timeoutInMs: timeoutInMs ?? defaultTimeoutInMs,
|
|
3011
|
-
type,
|
|
3012
|
-
payload
|
|
3013
|
-
}));
|
|
3014
|
-
}, timeoutInMs ?? defaultTimeoutInMs);
|
|
3015
|
-
__privateGet(this, _acks).set(currentId, {
|
|
3016
|
-
resolve,
|
|
3017
|
-
reject,
|
|
3018
|
-
timeout
|
|
3019
|
-
});
|
|
3020
|
-
const schema = this.opts.emitSchema[type]["message"];
|
|
3021
|
-
if (!schema) {
|
|
3022
|
-
clearTimeout(timeout);
|
|
3023
|
-
return reject(`Unknown message type: ${type}`);
|
|
3024
|
-
}
|
|
3025
|
-
const parsedPayload = schema.safeParse(payload);
|
|
3026
|
-
if (!parsedPayload.success) {
|
|
3027
|
-
clearTimeout(timeout);
|
|
3028
|
-
return reject(`Failed to parse message payload: ${JSON.stringify(parsedPayload.error)}`);
|
|
3029
|
-
}
|
|
3030
|
-
await __privateMethod(this, _sendPacket, sendPacket_fn).call(this, {
|
|
3031
|
-
type: "EVENT",
|
|
3032
|
-
message: {
|
|
3033
|
-
type,
|
|
3034
|
-
payload,
|
|
3035
|
-
version: "v1"
|
|
3036
|
-
},
|
|
3037
|
-
id: currentId
|
|
3038
|
-
});
|
|
3039
|
-
});
|
|
3040
|
-
}
|
|
3041
|
-
};
|
|
3042
|
-
_sessionId = new WeakMap();
|
|
3043
|
-
_messageCounter = new WeakMap();
|
|
3044
|
-
_handler3 = new WeakMap();
|
|
3045
|
-
_acks = new WeakMap();
|
|
3046
|
-
_registerHandlers = new WeakSet();
|
|
3047
|
-
registerHandlers_fn = /* @__PURE__ */ __name(async function() {
|
|
3048
|
-
if (!this.opts.process.on) {
|
|
3049
|
-
return;
|
|
3050
|
-
}
|
|
3051
|
-
this.opts.process.on("message", async (message) => {
|
|
3052
|
-
__privateMethod(this, _handlePacket, handlePacket_fn).call(this, message);
|
|
3053
|
-
});
|
|
3054
|
-
}, "#registerHandlers");
|
|
3055
|
-
_handlePacket = new WeakSet();
|
|
3056
|
-
handlePacket_fn = /* @__PURE__ */ __name(async function(packet) {
|
|
3057
|
-
const parsedPacket = Packet.safeParse(packet);
|
|
3058
|
-
if (!parsedPacket.success) {
|
|
3059
|
-
return;
|
|
3060
|
-
}
|
|
3061
|
-
switch (parsedPacket.data.type) {
|
|
3062
|
-
case "ACK": {
|
|
3063
|
-
const ack = __privateGet(this, _acks).get(parsedPacket.data.id);
|
|
3064
|
-
if (!ack) {
|
|
3065
|
-
return;
|
|
3066
|
-
}
|
|
3067
|
-
clearTimeout(ack.timeout);
|
|
3068
|
-
ack.resolve(parsedPacket.data.message);
|
|
3069
|
-
break;
|
|
3070
|
-
}
|
|
3071
|
-
case "CONNECT": {
|
|
3072
|
-
if (!parsedPacket.data.sessionId) {
|
|
3073
|
-
const id = crypto.randomUUID();
|
|
3074
|
-
await __privateMethod(this, _sendPacket, sendPacket_fn).call(this, {
|
|
3075
|
-
type: "CONNECT",
|
|
3076
|
-
sessionId: id
|
|
3077
|
-
});
|
|
3078
|
-
return;
|
|
3079
|
-
}
|
|
3080
|
-
if (__privateGet(this, _sessionId)) {
|
|
3081
|
-
return;
|
|
3082
|
-
}
|
|
3083
|
-
__privateSet(this, _sessionId, parsedPacket.data.sessionId);
|
|
3084
|
-
break;
|
|
3085
|
-
}
|
|
3086
|
-
case "EVENT": {
|
|
3087
|
-
const result = await __privateGet(this, _handler3).handleMessage(parsedPacket.data.message);
|
|
3088
|
-
if (typeof parsedPacket.data.id === "undefined") {
|
|
3089
|
-
return;
|
|
3090
|
-
}
|
|
3091
|
-
await __privateMethod(this, _sendPacket, sendPacket_fn).call(this, {
|
|
3092
|
-
type: "ACK",
|
|
3093
|
-
id: parsedPacket.data.id,
|
|
3094
|
-
message: result
|
|
3095
|
-
});
|
|
3096
|
-
break;
|
|
3097
|
-
}
|
|
3098
|
-
}
|
|
3099
|
-
}, "#handlePacket");
|
|
3100
|
-
_sendPacket = new WeakSet();
|
|
3101
|
-
sendPacket_fn = /* @__PURE__ */ __name(async function(packet1) {
|
|
3102
|
-
await this.opts.process.send?.(packet1);
|
|
3103
|
-
}, "#sendPacket");
|
|
3104
|
-
__name(_ZodIpcConnection, "ZodIpcConnection");
|
|
3105
|
-
var ZodIpcConnection = _ZodIpcConnection;
|
|
3106
2363
|
function parseError(error) {
|
|
3107
2364
|
if (error instanceof Error) {
|
|
3108
2365
|
return {
|
|
@@ -3744,223 +3001,6 @@ function formatDurationInDays(milliseconds) {
|
|
|
3744
3001
|
return duration;
|
|
3745
3002
|
}
|
|
3746
3003
|
__name(formatDurationInDays, "formatDurationInDays");
|
|
3747
|
-
async function unboundedTimeout(delay = 0, value, options) {
|
|
3748
|
-
const maxDelay = 2147483647;
|
|
3749
|
-
const fullTimeouts = Math.floor(delay / maxDelay);
|
|
3750
|
-
const remainingDelay = delay % maxDelay;
|
|
3751
|
-
let lastTimeoutResult = await promises.setTimeout(remainingDelay, value, options);
|
|
3752
|
-
for (let i = 0; i < fullTimeouts; i++) {
|
|
3753
|
-
lastTimeoutResult = await promises.setTimeout(maxDelay, value, options);
|
|
3754
|
-
}
|
|
3755
|
-
return lastTimeoutResult;
|
|
3756
|
-
}
|
|
3757
|
-
__name(unboundedTimeout, "unboundedTimeout");
|
|
3758
|
-
|
|
3759
|
-
// src/v3/runtime/devRuntimeManager.ts
|
|
3760
|
-
var _DevRuntimeManager = class _DevRuntimeManager {
|
|
3761
|
-
constructor() {
|
|
3762
|
-
__publicField(this, "_taskWaits", /* @__PURE__ */ new Map());
|
|
3763
|
-
__publicField(this, "_batchWaits", /* @__PURE__ */ new Map());
|
|
3764
|
-
__publicField(this, "_pendingCompletionNotifications", /* @__PURE__ */ new Map());
|
|
3765
|
-
}
|
|
3766
|
-
disable() {
|
|
3767
|
-
}
|
|
3768
|
-
async waitForDuration(ms) {
|
|
3769
|
-
await unboundedTimeout(ms);
|
|
3770
|
-
}
|
|
3771
|
-
async waitUntil(date) {
|
|
3772
|
-
return this.waitForDuration(date.getTime() - Date.now());
|
|
3773
|
-
}
|
|
3774
|
-
async waitForTask(params) {
|
|
3775
|
-
const pendingCompletion = this._pendingCompletionNotifications.get(params.id);
|
|
3776
|
-
if (pendingCompletion) {
|
|
3777
|
-
this._pendingCompletionNotifications.delete(params.id);
|
|
3778
|
-
return pendingCompletion;
|
|
3779
|
-
}
|
|
3780
|
-
const promise = new Promise((resolve) => {
|
|
3781
|
-
this._taskWaits.set(params.id, {
|
|
3782
|
-
resolve
|
|
3783
|
-
});
|
|
3784
|
-
});
|
|
3785
|
-
return await promise;
|
|
3786
|
-
}
|
|
3787
|
-
async waitForBatch(params) {
|
|
3788
|
-
if (!params.runs.length) {
|
|
3789
|
-
return Promise.resolve({
|
|
3790
|
-
id: params.id,
|
|
3791
|
-
items: []
|
|
3792
|
-
});
|
|
3793
|
-
}
|
|
3794
|
-
const promise = Promise.all(params.runs.map((runId) => {
|
|
3795
|
-
return new Promise((resolve, reject) => {
|
|
3796
|
-
const pendingCompletion = this._pendingCompletionNotifications.get(runId);
|
|
3797
|
-
if (pendingCompletion) {
|
|
3798
|
-
this._pendingCompletionNotifications.delete(runId);
|
|
3799
|
-
resolve(pendingCompletion);
|
|
3800
|
-
return;
|
|
3801
|
-
}
|
|
3802
|
-
this._taskWaits.set(runId, {
|
|
3803
|
-
resolve
|
|
3804
|
-
});
|
|
3805
|
-
});
|
|
3806
|
-
}));
|
|
3807
|
-
const results = await promise;
|
|
3808
|
-
return {
|
|
3809
|
-
id: params.id,
|
|
3810
|
-
items: results
|
|
3811
|
-
};
|
|
3812
|
-
}
|
|
3813
|
-
resumeTask(completion, execution) {
|
|
3814
|
-
const wait = this._taskWaits.get(execution.run.id);
|
|
3815
|
-
if (!wait) {
|
|
3816
|
-
this._pendingCompletionNotifications.set(execution.run.id, completion);
|
|
3817
|
-
return;
|
|
3818
|
-
}
|
|
3819
|
-
wait.resolve(completion);
|
|
3820
|
-
this._taskWaits.delete(execution.run.id);
|
|
3821
|
-
}
|
|
3822
|
-
};
|
|
3823
|
-
__name(_DevRuntimeManager, "DevRuntimeManager");
|
|
3824
|
-
var DevRuntimeManager = _DevRuntimeManager;
|
|
3825
|
-
|
|
3826
|
-
// src/v3/runtime/prodRuntimeManager.ts
|
|
3827
|
-
var _ProdRuntimeManager = class _ProdRuntimeManager {
|
|
3828
|
-
constructor(ipc, options = {}) {
|
|
3829
|
-
this.ipc = ipc;
|
|
3830
|
-
this.options = options;
|
|
3831
|
-
this._taskWaits = /* @__PURE__ */ new Map();
|
|
3832
|
-
this._batchWaits = /* @__PURE__ */ new Map();
|
|
3833
|
-
}
|
|
3834
|
-
disable() {
|
|
3835
|
-
}
|
|
3836
|
-
async waitForDuration(ms) {
|
|
3837
|
-
const now = Date.now();
|
|
3838
|
-
const resolveAfterDuration = unboundedTimeout(ms, "duration");
|
|
3839
|
-
if (ms <= this.waitThresholdInMs) {
|
|
3840
|
-
await resolveAfterDuration;
|
|
3841
|
-
return;
|
|
3842
|
-
}
|
|
3843
|
-
const waitForRestore = new Promise((resolve, reject) => {
|
|
3844
|
-
this._waitForRestore = {
|
|
3845
|
-
resolve,
|
|
3846
|
-
reject
|
|
3847
|
-
};
|
|
3848
|
-
});
|
|
3849
|
-
const { willCheckpointAndRestore } = await this.ipc.sendWithAck("WAIT_FOR_DURATION", {
|
|
3850
|
-
ms,
|
|
3851
|
-
now
|
|
3852
|
-
});
|
|
3853
|
-
if (!willCheckpointAndRestore) {
|
|
3854
|
-
await resolveAfterDuration;
|
|
3855
|
-
return;
|
|
3856
|
-
}
|
|
3857
|
-
this.ipc.send("READY_FOR_CHECKPOINT", {});
|
|
3858
|
-
await Promise.race([
|
|
3859
|
-
waitForRestore,
|
|
3860
|
-
resolveAfterDuration
|
|
3861
|
-
]);
|
|
3862
|
-
this.ipc.send("CANCEL_CHECKPOINT", {});
|
|
3863
|
-
}
|
|
3864
|
-
resumeAfterRestore() {
|
|
3865
|
-
if (!this._waitForRestore) {
|
|
3866
|
-
return;
|
|
3867
|
-
}
|
|
3868
|
-
clock.reset();
|
|
3869
|
-
this._waitForRestore.resolve("restore");
|
|
3870
|
-
this._waitForRestore = void 0;
|
|
3871
|
-
}
|
|
3872
|
-
async waitUntil(date) {
|
|
3873
|
-
return this.waitForDuration(date.getTime() - Date.now());
|
|
3874
|
-
}
|
|
3875
|
-
async waitForTask(params) {
|
|
3876
|
-
const promise = new Promise((resolve) => {
|
|
3877
|
-
this._taskWaits.set(params.id, {
|
|
3878
|
-
resolve
|
|
3879
|
-
});
|
|
3880
|
-
});
|
|
3881
|
-
await this.ipc.send("WAIT_FOR_TASK", {
|
|
3882
|
-
friendlyId: params.id
|
|
3883
|
-
});
|
|
3884
|
-
const result = await promise;
|
|
3885
|
-
clock.reset();
|
|
3886
|
-
return result;
|
|
3887
|
-
}
|
|
3888
|
-
async waitForBatch(params) {
|
|
3889
|
-
if (!params.runs.length) {
|
|
3890
|
-
return Promise.resolve({
|
|
3891
|
-
id: params.id,
|
|
3892
|
-
items: []
|
|
3893
|
-
});
|
|
3894
|
-
}
|
|
3895
|
-
const promise = Promise.all(params.runs.map((runId) => {
|
|
3896
|
-
return new Promise((resolve, reject) => {
|
|
3897
|
-
this._taskWaits.set(runId, {
|
|
3898
|
-
resolve
|
|
3899
|
-
});
|
|
3900
|
-
});
|
|
3901
|
-
}));
|
|
3902
|
-
await this.ipc.send("WAIT_FOR_BATCH", {
|
|
3903
|
-
batchFriendlyId: params.id,
|
|
3904
|
-
runFriendlyIds: params.runs
|
|
3905
|
-
});
|
|
3906
|
-
const results = await promise;
|
|
3907
|
-
clock.reset();
|
|
3908
|
-
return {
|
|
3909
|
-
id: params.id,
|
|
3910
|
-
items: results
|
|
3911
|
-
};
|
|
3912
|
-
}
|
|
3913
|
-
resumeTask(completion, execution) {
|
|
3914
|
-
const wait = this._taskWaits.get(execution.run.id);
|
|
3915
|
-
if (!wait) {
|
|
3916
|
-
return;
|
|
3917
|
-
}
|
|
3918
|
-
wait.resolve(completion);
|
|
3919
|
-
this._taskWaits.delete(execution.run.id);
|
|
3920
|
-
}
|
|
3921
|
-
get waitThresholdInMs() {
|
|
3922
|
-
return this.options.waitThresholdInMs ?? 3e4;
|
|
3923
|
-
}
|
|
3924
|
-
};
|
|
3925
|
-
__name(_ProdRuntimeManager, "ProdRuntimeManager");
|
|
3926
|
-
var ProdRuntimeManager = _ProdRuntimeManager;
|
|
3927
|
-
var _originClockTime, originClockTime_get, _originPreciseDate, originPreciseDate_get;
|
|
3928
|
-
var _PreciseWallClock = class _PreciseWallClock {
|
|
3929
|
-
constructor(options = {}) {
|
|
3930
|
-
__privateAdd(this, _originClockTime);
|
|
3931
|
-
__privateAdd(this, _originPreciseDate);
|
|
3932
|
-
this._origin = {
|
|
3933
|
-
clockTime: options.origin ?? process.hrtime(),
|
|
3934
|
-
preciseDate: options.now ?? new preciseDate.PreciseDate()
|
|
3935
|
-
};
|
|
3936
|
-
}
|
|
3937
|
-
preciseNow() {
|
|
3938
|
-
const elapsedHrTime = process.hrtime(__privateGet(this, _originClockTime, originClockTime_get));
|
|
3939
|
-
const elapsedNanoseconds = BigInt(elapsedHrTime[0]) * BigInt(1e9) + BigInt(elapsedHrTime[1]);
|
|
3940
|
-
const preciseDate$1 = new preciseDate.PreciseDate(__privateGet(this, _originPreciseDate, originPreciseDate_get).getFullTime() + elapsedNanoseconds);
|
|
3941
|
-
const dateStruct = preciseDate$1.toStruct();
|
|
3942
|
-
return [
|
|
3943
|
-
dateStruct.seconds,
|
|
3944
|
-
dateStruct.nanos
|
|
3945
|
-
];
|
|
3946
|
-
}
|
|
3947
|
-
reset() {
|
|
3948
|
-
this._origin = {
|
|
3949
|
-
clockTime: process.hrtime(),
|
|
3950
|
-
preciseDate: new preciseDate.PreciseDate()
|
|
3951
|
-
};
|
|
3952
|
-
}
|
|
3953
|
-
};
|
|
3954
|
-
_originClockTime = new WeakSet();
|
|
3955
|
-
originClockTime_get = /* @__PURE__ */ __name(function() {
|
|
3956
|
-
return this._origin.clockTime;
|
|
3957
|
-
}, "#originClockTime");
|
|
3958
|
-
_originPreciseDate = new WeakSet();
|
|
3959
|
-
originPreciseDate_get = /* @__PURE__ */ __name(function() {
|
|
3960
|
-
return this._origin.preciseDate;
|
|
3961
|
-
}, "#originPreciseDate");
|
|
3962
|
-
__name(_PreciseWallClock, "PreciseWallClock");
|
|
3963
|
-
var PreciseWallClock = _PreciseWallClock;
|
|
3964
3004
|
var _TriggerTracer = class _TriggerTracer {
|
|
3965
3005
|
constructor(_config) {
|
|
3966
3006
|
this._config = _config;
|
|
@@ -4043,27 +3083,27 @@ var _ConsoleInterceptor = class _ConsoleInterceptor {
|
|
|
4043
3083
|
}
|
|
4044
3084
|
// Intercept the console and send logs to the OpenTelemetry logger
|
|
4045
3085
|
// during the execution of the callback
|
|
4046
|
-
async intercept(
|
|
3086
|
+
async intercept(console, callback) {
|
|
4047
3087
|
const originalConsole = {
|
|
4048
|
-
log:
|
|
4049
|
-
info:
|
|
4050
|
-
warn:
|
|
4051
|
-
error:
|
|
4052
|
-
debug:
|
|
3088
|
+
log: console.log,
|
|
3089
|
+
info: console.info,
|
|
3090
|
+
warn: console.warn,
|
|
3091
|
+
error: console.error,
|
|
3092
|
+
debug: console.debug
|
|
4053
3093
|
};
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
3094
|
+
console.log = this.log.bind(this);
|
|
3095
|
+
console.info = this.info.bind(this);
|
|
3096
|
+
console.warn = this.warn.bind(this);
|
|
3097
|
+
console.error = this.error.bind(this);
|
|
3098
|
+
console.debug = this.debug.bind(this);
|
|
4059
3099
|
try {
|
|
4060
3100
|
return await callback();
|
|
4061
3101
|
} finally {
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
3102
|
+
console.log = originalConsole.log;
|
|
3103
|
+
console.info = originalConsole.info;
|
|
3104
|
+
console.warn = originalConsole.warn;
|
|
3105
|
+
console.error = originalConsole.error;
|
|
3106
|
+
console.debug = originalConsole.debug;
|
|
4067
3107
|
}
|
|
4068
3108
|
}
|
|
4069
3109
|
debug(...args) {
|
|
@@ -4341,8 +3381,8 @@ function omit(obj, ...keys) {
|
|
|
4341
3381
|
return result;
|
|
4342
3382
|
}
|
|
4343
3383
|
__name(omit, "omit");
|
|
4344
|
-
var
|
|
4345
|
-
var AsyncResourceDetector = (
|
|
3384
|
+
var _a;
|
|
3385
|
+
var AsyncResourceDetector = (_a = class {
|
|
4346
3386
|
constructor() {
|
|
4347
3387
|
__publicField(this, "_resolved", false);
|
|
4348
3388
|
this._promise = new Promise((resolver) => {
|
|
@@ -4362,7 +3402,7 @@ var AsyncResourceDetector = (_a2 = class {
|
|
|
4362
3402
|
this._resolved = true;
|
|
4363
3403
|
this._resolver(attributes);
|
|
4364
3404
|
}
|
|
4365
|
-
}, __name(
|
|
3405
|
+
}, __name(_a, "AsyncResourceDetector"), _a);
|
|
4366
3406
|
var _TracingSDK = class _TracingSDK {
|
|
4367
3407
|
constructor(config) {
|
|
4368
3408
|
this.config = config;
|
|
@@ -4486,6 +3526,35 @@ function recordSpanException(span, error) {
|
|
|
4486
3526
|
}
|
|
4487
3527
|
__name(recordSpanException, "recordSpanException");
|
|
4488
3528
|
|
|
3529
|
+
// package.json
|
|
3530
|
+
var dependencies = {
|
|
3531
|
+
"@google-cloud/precise-date": "^4.0.0",
|
|
3532
|
+
"@opentelemetry/api": "^1.8.0",
|
|
3533
|
+
"@opentelemetry/api-logs": "^0.48.0",
|
|
3534
|
+
"@opentelemetry/exporter-logs-otlp-http": "^0.49.1",
|
|
3535
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.49.1",
|
|
3536
|
+
"@opentelemetry/instrumentation": "^0.49.1",
|
|
3537
|
+
"@opentelemetry/resources": "^1.22.0",
|
|
3538
|
+
"@opentelemetry/sdk-logs": "^0.49.1",
|
|
3539
|
+
"@opentelemetry/sdk-node": "^0.49.1",
|
|
3540
|
+
"@opentelemetry/sdk-trace-base": "^1.22.0",
|
|
3541
|
+
"@opentelemetry/sdk-trace-node": "^1.22.0",
|
|
3542
|
+
"@opentelemetry/semantic-conventions": "^1.22.0",
|
|
3543
|
+
"humanize-duration": "^3.27.3",
|
|
3544
|
+
superjson: "^2.2.1",
|
|
3545
|
+
ulidx: "^2.2.1",
|
|
3546
|
+
zod: "3.22.3",
|
|
3547
|
+
"zod-error": "1.5.0",
|
|
3548
|
+
"zod-validation-error": "^1.5.0",
|
|
3549
|
+
"socket.io-client": "4.7.4"
|
|
3550
|
+
};
|
|
3551
|
+
|
|
3552
|
+
// src/v3/utils/detectDependencyVersion.ts
|
|
3553
|
+
function detectDependencyVersion(dependency) {
|
|
3554
|
+
return dependencies[dependency];
|
|
3555
|
+
}
|
|
3556
|
+
__name(detectDependencyVersion, "detectDependencyVersion");
|
|
3557
|
+
|
|
4489
3558
|
// src/v3/utils/ioSerialization.ts
|
|
4490
3559
|
async function parsePacket(value) {
|
|
4491
3560
|
if (!value.data) {
|
|
@@ -4754,286 +3823,6 @@ function safeJsonParse2(value) {
|
|
|
4754
3823
|
}
|
|
4755
3824
|
__name(safeJsonParse2, "safeJsonParse");
|
|
4756
3825
|
|
|
4757
|
-
// src/v3/workers/taskExecutor.ts
|
|
4758
|
-
var _callRun, callRun_fn, _callTaskInit, callTaskInit_fn, _callTaskCleanup, callTaskCleanup_fn, _handleError, handleError_fn;
|
|
4759
|
-
var _TaskExecutor = class _TaskExecutor {
|
|
4760
|
-
constructor(task, options) {
|
|
4761
|
-
__privateAdd(this, _callRun);
|
|
4762
|
-
__privateAdd(this, _callTaskInit);
|
|
4763
|
-
__privateAdd(this, _callTaskCleanup);
|
|
4764
|
-
__privateAdd(this, _handleError);
|
|
4765
|
-
this.task = task;
|
|
4766
|
-
this._tracingSDK = options.tracingSDK;
|
|
4767
|
-
this._tracer = options.tracer;
|
|
4768
|
-
this._consoleInterceptor = options.consoleInterceptor;
|
|
4769
|
-
this._config = options.projectConfig;
|
|
4770
|
-
this._importedConfig = options.importedConfig;
|
|
4771
|
-
this._handleErrorFn = options.handleErrorFn;
|
|
4772
|
-
}
|
|
4773
|
-
async execute(execution, worker, traceContext) {
|
|
4774
|
-
const ctx = TaskRunContext.parse(execution);
|
|
4775
|
-
const attemptMessage = `Attempt ${execution.attempt.number}`;
|
|
4776
|
-
const originalPacket = {
|
|
4777
|
-
data: execution.run.payload,
|
|
4778
|
-
dataType: execution.run.payloadType
|
|
4779
|
-
};
|
|
4780
|
-
const result = await taskContextManager.runWith({
|
|
4781
|
-
ctx,
|
|
4782
|
-
worker
|
|
4783
|
-
}, async () => {
|
|
4784
|
-
this._tracingSDK.asyncResourceDetector.resolveWithAttributes({
|
|
4785
|
-
...taskContextManager.attributes,
|
|
4786
|
-
[SemanticInternalAttributes.SDK_VERSION]: this.task.packageVersion,
|
|
4787
|
-
[SemanticInternalAttributes.SDK_LANGUAGE]: "typescript"
|
|
4788
|
-
});
|
|
4789
|
-
return await this._tracer.startActiveSpan(attemptMessage, async (span) => {
|
|
4790
|
-
return await this._consoleInterceptor.intercept(console, async () => {
|
|
4791
|
-
let parsedPayload;
|
|
4792
|
-
let initOutput;
|
|
4793
|
-
try {
|
|
4794
|
-
const payloadPacket = await conditionallyImportPacket(originalPacket, this._tracer);
|
|
4795
|
-
parsedPayload = await parsePacket(payloadPacket);
|
|
4796
|
-
initOutput = await __privateMethod(this, _callTaskInit, callTaskInit_fn).call(this, parsedPayload, ctx);
|
|
4797
|
-
const output = await __privateMethod(this, _callRun, callRun_fn).call(this, parsedPayload, ctx, initOutput);
|
|
4798
|
-
try {
|
|
4799
|
-
const stringifiedOutput = await stringifyIO(output);
|
|
4800
|
-
const finalOutput = await conditionallyExportPacket(stringifiedOutput, `${execution.attempt.id}/output`, this._tracer);
|
|
4801
|
-
const attributes = await createPacketAttributes(finalOutput, SemanticInternalAttributes.OUTPUT, SemanticInternalAttributes.OUTPUT_TYPE);
|
|
4802
|
-
if (attributes) {
|
|
4803
|
-
span.setAttributes(attributes);
|
|
4804
|
-
}
|
|
4805
|
-
return {
|
|
4806
|
-
ok: true,
|
|
4807
|
-
id: execution.run.id,
|
|
4808
|
-
output: finalOutput.data,
|
|
4809
|
-
outputType: finalOutput.dataType
|
|
4810
|
-
};
|
|
4811
|
-
} catch (stringifyError) {
|
|
4812
|
-
recordSpanException(span, stringifyError);
|
|
4813
|
-
return {
|
|
4814
|
-
ok: false,
|
|
4815
|
-
id: execution.run.id,
|
|
4816
|
-
error: {
|
|
4817
|
-
type: "INTERNAL_ERROR",
|
|
4818
|
-
code: TaskRunErrorCodes.TASK_OUTPUT_ERROR,
|
|
4819
|
-
message: stringifyError instanceof Error ? stringifyError.message : typeof stringifyError === "string" ? stringifyError : void 0
|
|
4820
|
-
}
|
|
4821
|
-
};
|
|
4822
|
-
}
|
|
4823
|
-
} catch (runError) {
|
|
4824
|
-
try {
|
|
4825
|
-
const handleErrorResult = await __privateMethod(this, _handleError, handleError_fn).call(this, execution, runError, parsedPayload, ctx);
|
|
4826
|
-
recordSpanException(span, handleErrorResult.error ?? runError);
|
|
4827
|
-
return {
|
|
4828
|
-
id: execution.run.id,
|
|
4829
|
-
ok: false,
|
|
4830
|
-
error: handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError),
|
|
4831
|
-
retry: handleErrorResult.status === "retry" ? handleErrorResult.retry : void 0,
|
|
4832
|
-
skippedRetrying: handleErrorResult.status === "skipped"
|
|
4833
|
-
};
|
|
4834
|
-
} catch (handleErrorError) {
|
|
4835
|
-
recordSpanException(span, handleErrorError);
|
|
4836
|
-
return {
|
|
4837
|
-
ok: false,
|
|
4838
|
-
id: execution.run.id,
|
|
4839
|
-
error: {
|
|
4840
|
-
type: "INTERNAL_ERROR",
|
|
4841
|
-
code: TaskRunErrorCodes.HANDLE_ERROR_ERROR,
|
|
4842
|
-
message: handleErrorError instanceof Error ? handleErrorError.message : typeof handleErrorError === "string" ? handleErrorError : void 0
|
|
4843
|
-
}
|
|
4844
|
-
};
|
|
4845
|
-
}
|
|
4846
|
-
} finally {
|
|
4847
|
-
await __privateMethod(this, _callTaskCleanup, callTaskCleanup_fn).call(this, parsedPayload, ctx, initOutput);
|
|
4848
|
-
}
|
|
4849
|
-
});
|
|
4850
|
-
}, {
|
|
4851
|
-
kind: api.SpanKind.CONSUMER,
|
|
4852
|
-
attributes: {
|
|
4853
|
-
[SemanticInternalAttributes.STYLE_ICON]: "attempt",
|
|
4854
|
-
...accessoryAttributes({
|
|
4855
|
-
items: [
|
|
4856
|
-
{
|
|
4857
|
-
text: ctx.task.filePath
|
|
4858
|
-
},
|
|
4859
|
-
{
|
|
4860
|
-
text: `${ctx.task.exportName}.run()`
|
|
4861
|
-
}
|
|
4862
|
-
],
|
|
4863
|
-
style: "codepath"
|
|
4864
|
-
})
|
|
4865
|
-
}
|
|
4866
|
-
}, this._tracer.extractContext(traceContext));
|
|
4867
|
-
});
|
|
4868
|
-
return result;
|
|
4869
|
-
}
|
|
4870
|
-
};
|
|
4871
|
-
_callRun = new WeakSet();
|
|
4872
|
-
callRun_fn = /* @__PURE__ */ __name(async function(payload, ctx, init) {
|
|
4873
|
-
const runFn = this.task.fns.run;
|
|
4874
|
-
const middlewareFn = this.task.fns.middleware;
|
|
4875
|
-
if (!runFn) {
|
|
4876
|
-
throw new Error("Task does not have a run function");
|
|
4877
|
-
}
|
|
4878
|
-
if (!middlewareFn) {
|
|
4879
|
-
return runFn(payload, {
|
|
4880
|
-
ctx
|
|
4881
|
-
});
|
|
4882
|
-
}
|
|
4883
|
-
return middlewareFn(payload, {
|
|
4884
|
-
ctx,
|
|
4885
|
-
next: async () => runFn(payload, {
|
|
4886
|
-
ctx,
|
|
4887
|
-
init
|
|
4888
|
-
})
|
|
4889
|
-
});
|
|
4890
|
-
}, "#callRun");
|
|
4891
|
-
_callTaskInit = new WeakSet();
|
|
4892
|
-
callTaskInit_fn = /* @__PURE__ */ __name(async function(payload1, ctx1) {
|
|
4893
|
-
const initFn = this.task.fns.init;
|
|
4894
|
-
if (!initFn) {
|
|
4895
|
-
return {};
|
|
4896
|
-
}
|
|
4897
|
-
return this._tracer.startActiveSpan("init", async (span) => {
|
|
4898
|
-
return await initFn(payload1, {
|
|
4899
|
-
ctx: ctx1
|
|
4900
|
-
});
|
|
4901
|
-
});
|
|
4902
|
-
}, "#callTaskInit");
|
|
4903
|
-
_callTaskCleanup = new WeakSet();
|
|
4904
|
-
callTaskCleanup_fn = /* @__PURE__ */ __name(async function(payload2, ctx2, init1) {
|
|
4905
|
-
const cleanupFn = this.task.fns.cleanup;
|
|
4906
|
-
if (!cleanupFn) {
|
|
4907
|
-
return;
|
|
4908
|
-
}
|
|
4909
|
-
return this._tracer.startActiveSpan("cleanup", async (span) => {
|
|
4910
|
-
return await cleanupFn(payload2, {
|
|
4911
|
-
ctx: ctx2,
|
|
4912
|
-
init: init1
|
|
4913
|
-
});
|
|
4914
|
-
});
|
|
4915
|
-
}, "#callTaskCleanup");
|
|
4916
|
-
_handleError = new WeakSet();
|
|
4917
|
-
handleError_fn = /* @__PURE__ */ __name(async function(execution, error, payload3, ctx3) {
|
|
4918
|
-
const retriesConfig = this._importedConfig?.retries ?? this._config.retries;
|
|
4919
|
-
const retry = this.task.retry ?? retriesConfig?.default;
|
|
4920
|
-
if (!retry) {
|
|
4921
|
-
return {
|
|
4922
|
-
status: "noop"
|
|
4923
|
-
};
|
|
4924
|
-
}
|
|
4925
|
-
const delay = calculateNextRetryDelay(retry, execution.attempt.number);
|
|
4926
|
-
if (execution.environment.type === "DEVELOPMENT" && typeof retriesConfig?.enabledInDev === "boolean" && !retriesConfig.enabledInDev) {
|
|
4927
|
-
return {
|
|
4928
|
-
status: "skipped"
|
|
4929
|
-
};
|
|
4930
|
-
}
|
|
4931
|
-
return this._tracer.startActiveSpan("handleError()", async (span) => {
|
|
4932
|
-
const handleErrorResult = this.task.fns.handleError ? await this.task.fns.handleError(payload3, error, {
|
|
4933
|
-
ctx: ctx3,
|
|
4934
|
-
retry,
|
|
4935
|
-
retryDelayInMs: delay,
|
|
4936
|
-
retryAt: delay ? new Date(Date.now() + delay) : void 0
|
|
4937
|
-
}) : this._importedConfig ? await this._handleErrorFn?.(payload3, error, {
|
|
4938
|
-
ctx: ctx3,
|
|
4939
|
-
retry,
|
|
4940
|
-
retryDelayInMs: delay,
|
|
4941
|
-
retryAt: delay ? new Date(Date.now() + delay) : void 0
|
|
4942
|
-
}) : void 0;
|
|
4943
|
-
if (!handleErrorResult) {
|
|
4944
|
-
return typeof delay === "undefined" ? {
|
|
4945
|
-
status: "noop"
|
|
4946
|
-
} : {
|
|
4947
|
-
status: "retry",
|
|
4948
|
-
retry: {
|
|
4949
|
-
timestamp: Date.now() + delay,
|
|
4950
|
-
delay
|
|
4951
|
-
}
|
|
4952
|
-
};
|
|
4953
|
-
}
|
|
4954
|
-
if (handleErrorResult.skipRetrying) {
|
|
4955
|
-
return {
|
|
4956
|
-
status: "skipped",
|
|
4957
|
-
error: handleErrorResult.error
|
|
4958
|
-
};
|
|
4959
|
-
}
|
|
4960
|
-
if (typeof handleErrorResult.retryAt !== "undefined") {
|
|
4961
|
-
return {
|
|
4962
|
-
status: "retry",
|
|
4963
|
-
retry: {
|
|
4964
|
-
timestamp: handleErrorResult.retryAt.getTime(),
|
|
4965
|
-
delay: handleErrorResult.retryAt.getTime() - Date.now()
|
|
4966
|
-
},
|
|
4967
|
-
error: handleErrorResult.error
|
|
4968
|
-
};
|
|
4969
|
-
}
|
|
4970
|
-
if (typeof handleErrorResult.retryDelayInMs === "number") {
|
|
4971
|
-
return {
|
|
4972
|
-
status: "retry",
|
|
4973
|
-
retry: {
|
|
4974
|
-
timestamp: Date.now() + handleErrorResult.retryDelayInMs,
|
|
4975
|
-
delay: handleErrorResult.retryDelayInMs
|
|
4976
|
-
},
|
|
4977
|
-
error: handleErrorResult.error
|
|
4978
|
-
};
|
|
4979
|
-
}
|
|
4980
|
-
if (handleErrorResult.retry && typeof handleErrorResult.retry === "object") {
|
|
4981
|
-
const delay2 = calculateNextRetryDelay(handleErrorResult.retry, execution.attempt.number);
|
|
4982
|
-
return typeof delay2 === "undefined" ? {
|
|
4983
|
-
status: "noop",
|
|
4984
|
-
error: handleErrorResult.error
|
|
4985
|
-
} : {
|
|
4986
|
-
status: "retry",
|
|
4987
|
-
retry: {
|
|
4988
|
-
timestamp: Date.now() + delay2,
|
|
4989
|
-
delay: delay2
|
|
4990
|
-
},
|
|
4991
|
-
error: handleErrorResult.error
|
|
4992
|
-
};
|
|
4993
|
-
}
|
|
4994
|
-
return {
|
|
4995
|
-
status: "noop",
|
|
4996
|
-
error: handleErrorResult.error
|
|
4997
|
-
};
|
|
4998
|
-
}, {
|
|
4999
|
-
attributes: {
|
|
5000
|
-
[SemanticInternalAttributes.STYLE_ICON]: "exclamation-circle"
|
|
5001
|
-
}
|
|
5002
|
-
});
|
|
5003
|
-
}, "#handleError");
|
|
5004
|
-
__name(_TaskExecutor, "TaskExecutor");
|
|
5005
|
-
var TaskExecutor = _TaskExecutor;
|
|
5006
|
-
|
|
5007
|
-
// package.json
|
|
5008
|
-
var dependencies = {
|
|
5009
|
-
"@google-cloud/precise-date": "^4.0.0",
|
|
5010
|
-
"@opentelemetry/api": "^1.8.0",
|
|
5011
|
-
"@opentelemetry/api-logs": "^0.48.0",
|
|
5012
|
-
"@opentelemetry/exporter-logs-otlp-http": "^0.49.1",
|
|
5013
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.49.1",
|
|
5014
|
-
"@opentelemetry/instrumentation": "^0.49.1",
|
|
5015
|
-
"@opentelemetry/resources": "^1.22.0",
|
|
5016
|
-
"@opentelemetry/sdk-logs": "^0.49.1",
|
|
5017
|
-
"@opentelemetry/sdk-node": "^0.49.1",
|
|
5018
|
-
"@opentelemetry/sdk-trace-base": "^1.22.0",
|
|
5019
|
-
"@opentelemetry/sdk-trace-node": "^1.22.0",
|
|
5020
|
-
"@opentelemetry/semantic-conventions": "^1.22.0",
|
|
5021
|
-
"humanize-duration": "^3.27.3",
|
|
5022
|
-
"socket.io": "^4.7.4",
|
|
5023
|
-
"socket.io-client": "^4.7.4",
|
|
5024
|
-
superjson: "^2.2.1",
|
|
5025
|
-
ulidx: "^2.2.1",
|
|
5026
|
-
zod: "3.22.3",
|
|
5027
|
-
"zod-error": "1.5.0",
|
|
5028
|
-
"zod-validation-error": "^1.5.0"
|
|
5029
|
-
};
|
|
5030
|
-
|
|
5031
|
-
// src/v3/utils/detectDependencyVersion.ts
|
|
5032
|
-
function detectDependencyVersion(dependency) {
|
|
5033
|
-
return dependencies[dependency];
|
|
5034
|
-
}
|
|
5035
|
-
__name(detectDependencyVersion, "detectDependencyVersion");
|
|
5036
|
-
|
|
5037
3826
|
// src/v3/task-catalog/standardTaskCatalog.ts
|
|
5038
3827
|
var _StandardTaskCatalog = class _StandardTaskCatalog {
|
|
5039
3828
|
constructor() {
|
|
@@ -5150,8 +3939,6 @@ exports.CreateScheduleOptions = CreateScheduleOptions;
|
|
|
5150
3939
|
exports.CreateUploadPayloadUrlResponseBody = CreateUploadPayloadUrlResponseBody;
|
|
5151
3940
|
exports.DeletedScheduleObject = DeletedScheduleObject;
|
|
5152
3941
|
exports.DeploymentErrorData = DeploymentErrorData;
|
|
5153
|
-
exports.DevRuntimeManager = DevRuntimeManager;
|
|
5154
|
-
exports.DurableClock = PreciseWallClock;
|
|
5155
3942
|
exports.EnvironmentType = EnvironmentType;
|
|
5156
3943
|
exports.EventFilter = EventFilter;
|
|
5157
3944
|
exports.ExceptionEventProperties = ExceptionEventProperties;
|
|
@@ -5200,7 +3987,6 @@ exports.PlatformToProviderMessages = PlatformToProviderMessages;
|
|
|
5200
3987
|
exports.PostStartCauses = PostStartCauses;
|
|
5201
3988
|
exports.PreStopCauses = PreStopCauses;
|
|
5202
3989
|
exports.ProdChildToWorkerMessages = ProdChildToWorkerMessages;
|
|
5203
|
-
exports.ProdRuntimeManager = ProdRuntimeManager;
|
|
5204
3990
|
exports.ProdTaskRunExecution = ProdTaskRunExecution;
|
|
5205
3991
|
exports.ProdTaskRunExecutionPayload = ProdTaskRunExecutionPayload;
|
|
5206
3992
|
exports.ProdWorkerSocketData = ProdWorkerSocketData;
|
|
@@ -5216,7 +4002,6 @@ exports.ScheduleObject = ScheduleObject;
|
|
|
5216
4002
|
exports.ScheduledTaskPayload = ScheduledTaskPayload;
|
|
5217
4003
|
exports.SemanticInternalAttributes = SemanticInternalAttributes;
|
|
5218
4004
|
exports.SharedQueueToClientMessages = SharedQueueToClientMessages;
|
|
5219
|
-
exports.SimpleStructuredLogger = SimpleStructuredLogger;
|
|
5220
4005
|
exports.SlidingWindowRateLimit = SlidingWindowRateLimit;
|
|
5221
4006
|
exports.SpanEvent = SpanEvent;
|
|
5222
4007
|
exports.SpanEvents = SpanEvents;
|
|
@@ -5226,7 +4011,6 @@ exports.StartDeploymentIndexingRequestBody = StartDeploymentIndexingRequestBody;
|
|
|
5226
4011
|
exports.StartDeploymentIndexingResponseBody = StartDeploymentIndexingResponseBody;
|
|
5227
4012
|
exports.TaskContextSpanProcessor = TaskContextSpanProcessor;
|
|
5228
4013
|
exports.TaskEventStyle = TaskEventStyle;
|
|
5229
|
-
exports.TaskExecutor = TaskExecutor;
|
|
5230
4014
|
exports.TaskFileMetadata = TaskFileMetadata;
|
|
5231
4015
|
exports.TaskMetadata = TaskMetadata;
|
|
5232
4016
|
exports.TaskMetadataFailedToParseData = TaskMetadataFailedToParseData;
|
|
@@ -5262,15 +4046,6 @@ exports.UnprocessableEntityError = UnprocessableEntityError;
|
|
|
5262
4046
|
exports.UpdateScheduleOptions = UpdateScheduleOptions;
|
|
5263
4047
|
exports.WaitReason = WaitReason;
|
|
5264
4048
|
exports.WhoAmIResponseSchema = WhoAmIResponseSchema;
|
|
5265
|
-
exports.ZodIpcConnection = ZodIpcConnection;
|
|
5266
|
-
exports.ZodMessageHandler = ZodMessageHandler;
|
|
5267
|
-
exports.ZodMessageSchema = ZodMessageSchema;
|
|
5268
|
-
exports.ZodMessageSender = ZodMessageSender;
|
|
5269
|
-
exports.ZodNamespace = ZodNamespace;
|
|
5270
|
-
exports.ZodSchemaParsedError = ZodSchemaParsedError;
|
|
5271
|
-
exports.ZodSocketConnection = ZodSocketConnection;
|
|
5272
|
-
exports.ZodSocketMessageHandler = ZodSocketMessageHandler;
|
|
5273
|
-
exports.ZodSocketMessageSender = ZodSocketMessageSender;
|
|
5274
4049
|
exports.accessoryAttributes = accessoryAttributes;
|
|
5275
4050
|
exports.apiClientManager = apiClientManager;
|
|
5276
4051
|
exports.calculateNextRetryDelay = calculateNextRetryDelay;
|