@trigger.dev/core 3.0.0-beta.5 → 3.0.0-beta.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/dist/api-Pl9fxB8v.d.mts +13879 -0
- package/dist/api-sNoooMbT.d.ts +13879 -0
- package/dist/catalog-H7yFiZ60.d.mts +202 -0
- package/dist/catalog-h79CG5Wy.d.ts +202 -0
- package/dist/common-CLW82lkt.d.mts +1423 -0
- package/dist/common-CLW82lkt.d.ts +1423 -0
- package/dist/{eventFilterMatches-2kHImluE.d.mts → eventFilter-66NaBAMi.d.mts} +1 -3
- package/dist/{eventFilterMatches-2kHImluE.d.ts → eventFilter-66NaBAMi.d.ts} +1 -3
- package/dist/eventFilterMatches.d.mts +6 -0
- package/dist/eventFilterMatches.d.ts +6 -0
- package/dist/eventFilterMatches.js +165 -0
- package/dist/eventFilterMatches.js.map +1 -0
- package/dist/eventFilterMatches.mjs +163 -0
- package/dist/eventFilterMatches.mjs.map +1 -0
- package/dist/index.d.mts +14 -16657
- package/dist/index.d.ts +14 -16657
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -2
- package/dist/index.mjs.map +1 -1
- package/dist/json-DBPEJQRe.d.mts +16 -0
- package/dist/json-DBPEJQRe.d.ts +16 -0
- package/dist/manager-KvCabW1a.d.mts +18 -0
- package/dist/manager-OBA35PzR.d.ts +18 -0
- package/dist/messages-JvHJ83wv.d.mts +19428 -0
- package/dist/messages-JvHJ83wv.d.ts +19428 -0
- package/dist/replacements.d.mts +22 -0
- package/dist/replacements.d.ts +22 -0
- package/dist/replacements.js +33 -0
- package/dist/replacements.js.map +1 -0
- package/dist/replacements.mjs +28 -0
- package/dist/replacements.mjs.map +1 -0
- package/dist/requestFilter-HNZQEpQb.d.ts +180 -0
- package/dist/requestFilter-b5W2_1oP.d.mts +180 -0
- package/dist/requestFilterMatches.d.mts +13 -0
- package/dist/requestFilterMatches.d.ts +13 -0
- package/dist/requestFilterMatches.js +238 -0
- package/dist/requestFilterMatches.js.map +1 -0
- package/dist/requestFilterMatches.mjs +235 -0
- package/dist/requestFilterMatches.mjs.map +1 -0
- package/dist/retry.d.mts +10 -0
- package/dist/retry.d.ts +10 -0
- package/dist/retry.js +100 -0
- package/dist/retry.js.map +1 -0
- package/dist/retry.mjs +97 -0
- package/dist/retry.mjs.map +1 -0
- package/dist/schemas/index.d.mts +2611 -0
- package/dist/schemas/index.d.ts +2611 -0
- package/dist/schemas/index.js +1630 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/index.mjs +1463 -0
- package/dist/schemas/index.mjs.map +1 -0
- package/dist/schemas-C9ssfehv.d.mts +2568 -0
- package/dist/schemas-C9ssfehv.d.ts +2568 -0
- package/dist/taskLogger-CzADe4je.d.ts +33 -0
- package/dist/taskLogger-r_AFTX45.d.mts +33 -0
- package/dist/tracer-N0p2Fuuv.d.mts +23 -0
- package/dist/tracer-N0p2Fuuv.d.ts +23 -0
- package/dist/types.d.mts +11 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +3 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils.d.mts +7 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +33 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +30 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/v3/dev/index.d.mts +29 -0
- package/dist/v3/dev/index.d.ts +29 -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/errors.d.mts +39 -0
- package/dist/v3/errors.d.ts +39 -0
- package/dist/v3/errors.js +204 -0
- package/dist/v3/errors.js.map +1 -0
- package/dist/v3/errors.mjs +195 -0
- package/dist/v3/errors.mjs.map +1 -0
- package/dist/v3/index.d.mts +436 -20511
- package/dist/v3/index.d.ts +436 -20511
- package/dist/v3/index.js +2822 -2890
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +2767 -2863
- package/dist/v3/index.mjs.map +1 -1
- package/dist/v3/logger-api.d.mts +24 -0
- package/dist/v3/logger-api.d.ts +24 -0
- package/dist/v3/logger-api.js +118 -0
- package/dist/v3/logger-api.js.map +1 -0
- package/dist/v3/logger-api.mjs +116 -0
- package/dist/v3/logger-api.mjs.map +1 -0
- package/dist/v3/otel/index.js +119 -53
- package/dist/v3/otel/index.js.map +1 -1
- package/dist/v3/otel/index.mjs +119 -53
- package/dist/v3/otel/index.mjs.map +1 -1
- package/dist/v3/prod/index.d.mts +46 -0
- package/dist/v3/prod/index.d.ts +46 -0
- package/dist/v3/prod/index.js +180 -0
- package/dist/v3/prod/index.js.map +1 -0
- package/dist/v3/prod/index.mjs +178 -0
- package/dist/v3/prod/index.mjs.map +1 -0
- package/dist/v3/schemas/index.d.mts +4741 -0
- package/dist/v3/schemas/index.d.ts +4741 -0
- package/dist/v3/schemas/index.js +2039 -0
- package/dist/v3/schemas/index.js.map +1 -0
- package/dist/v3/schemas/index.mjs +1900 -0
- package/dist/v3/schemas/index.mjs.map +1 -0
- package/dist/v3/semanticInternalAttributes.d.mts +56 -0
- package/dist/v3/semanticInternalAttributes.d.ts +56 -0
- package/dist/v3/semanticInternalAttributes.js +61 -0
- package/dist/v3/semanticInternalAttributes.js.map +1 -0
- package/dist/v3/semanticInternalAttributes.mjs +59 -0
- package/dist/v3/semanticInternalAttributes.mjs.map +1 -0
- package/dist/v3/utils/durations.d.mts +15 -0
- package/dist/v3/utils/durations.d.ts +15 -0
- package/dist/v3/utils/durations.js +93 -0
- package/dist/v3/utils/durations.js.map +1 -0
- package/dist/v3/utils/durations.mjs +82 -0
- package/dist/v3/utils/durations.mjs.map +1 -0
- package/dist/v3/utils/flattenAttributes.d.mts +8 -0
- package/dist/v3/utils/flattenAttributes.d.ts +8 -0
- package/dist/v3/utils/flattenAttributes.js +131 -0
- package/dist/v3/utils/flattenAttributes.js.map +1 -0
- package/dist/v3/utils/flattenAttributes.mjs +126 -0
- package/dist/v3/utils/flattenAttributes.mjs.map +1 -0
- package/dist/v3/utils/ioSerialization.d.mts +21 -0
- package/dist/v3/utils/ioSerialization.d.ts +21 -0
- package/dist/v3/utils/ioSerialization.js +2367 -0
- package/dist/v3/utils/ioSerialization.js.map +1 -0
- package/dist/v3/utils/ioSerialization.mjs +2358 -0
- package/dist/v3/utils/ioSerialization.mjs.map +1 -0
- package/dist/v3/utils/omit.d.mts +3 -0
- package/dist/v3/utils/omit.d.ts +3 -0
- package/dist/v3/utils/omit.js +20 -0
- package/dist/v3/utils/omit.js.map +1 -0
- package/dist/v3/utils/omit.mjs +18 -0
- package/dist/v3/utils/omit.mjs.map +1 -0
- package/dist/v3/utils/retries.d.mts +46 -0
- package/dist/v3/utils/retries.d.ts +46 -0
- package/dist/v3/utils/retries.js +118 -0
- package/dist/v3/utils/retries.js.map +1 -0
- package/dist/v3/utils/retries.mjs +113 -0
- package/dist/v3/utils/retries.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/utils/timers.d.mts +6 -0
- package/dist/v3/utils/timers.d.ts +6 -0
- package/dist/v3/utils/timers.js +31 -0
- package/dist/v3/utils/timers.js.map +1 -0
- package/dist/v3/utils/timers.mjs +28 -0
- package/dist/v3/utils/timers.mjs.map +1 -0
- package/dist/v3/workers/index.d.mts +144 -0
- package/dist/v3/workers/index.d.ts +144 -0
- package/dist/v3/workers/index.js +3683 -0
- package/dist/v3/workers/index.js.map +1 -0
- package/dist/v3/workers/index.mjs +3664 -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 +82 -0
- package/dist/v3/zodMessageHandler.d.ts +82 -0
- package/dist/v3/zodMessageHandler.js +222 -0
- package/dist/v3/zodMessageHandler.js.map +1 -0
- package/dist/v3/zodMessageHandler.mjs +217 -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 +397 -0
- package/dist/v3/zodNamespace.js.map +1 -0
- package/dist/v3/zodNamespace.mjs +395 -0
- package/dist/v3/zodNamespace.mjs.map +1 -0
- package/dist/v3/zodSocket.d.mts +93 -0
- package/dist/v3/zodSocket.d.ts +93 -0
- package/dist/v3/zodSocket.js +350 -0
- package/dist/v3/zodSocket.js.map +1 -0
- package/dist/v3/zodSocket.mjs +346 -0
- package/dist/v3/zodSocket.mjs.map +1 -0
- package/dist/v3/zodfetch.d.mts +219 -0
- package/dist/v3/zodfetch.d.ts +219 -0
- package/dist/v3/zodfetch.js +834 -0
- package/dist/v3/zodfetch.js.map +1 -0
- package/dist/v3/zodfetch.mjs +811 -0
- package/dist/v3/zodfetch.mjs.map +1 -0
- package/dist/versions.d.mts +11 -0
- package/dist/versions.d.ts +11 -0
- package/dist/versions.js +31 -0
- package/dist/versions.js.map +1 -0
- package/dist/versions.mjs +27 -0
- package/dist/versions.mjs.map +1 -0
- package/package.json +223 -5
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Span, SpanOptions } from '@opentelemetry/api';
|
|
2
|
+
import { Logger } from '@opentelemetry/api-logs';
|
|
3
|
+
import { T as TriggerTracer } from './tracer-N0p2Fuuv.js';
|
|
4
|
+
|
|
5
|
+
type LogLevel = "none" | "error" | "warn" | "info" | "debug" | "log";
|
|
6
|
+
declare const logLevels: Array<LogLevel>;
|
|
7
|
+
type TaskLoggerConfig = {
|
|
8
|
+
logger: Logger;
|
|
9
|
+
tracer: TriggerTracer;
|
|
10
|
+
level: LogLevel;
|
|
11
|
+
};
|
|
12
|
+
interface TaskLogger {
|
|
13
|
+
debug(message: string, properties?: Record<string, unknown>): void;
|
|
14
|
+
log(message: string, properties?: Record<string, unknown>): void;
|
|
15
|
+
info(message: string, properties?: Record<string, unknown>): void;
|
|
16
|
+
warn(message: string, properties?: Record<string, unknown>): void;
|
|
17
|
+
error(message: string, properties?: Record<string, unknown>): void;
|
|
18
|
+
trace<T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions): Promise<T>;
|
|
19
|
+
}
|
|
20
|
+
declare class OtelTaskLogger implements TaskLogger {
|
|
21
|
+
#private;
|
|
22
|
+
private readonly _config;
|
|
23
|
+
private readonly _level;
|
|
24
|
+
constructor(_config: TaskLoggerConfig);
|
|
25
|
+
debug(message: string, properties?: Record<string, unknown>): void;
|
|
26
|
+
log(message: string, properties?: Record<string, unknown>): void;
|
|
27
|
+
info(message: string, properties?: Record<string, unknown>): void;
|
|
28
|
+
warn(message: string, properties?: Record<string, unknown>): void;
|
|
29
|
+
error(message: string, properties?: Record<string, unknown>): void;
|
|
30
|
+
trace<T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions): Promise<T>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { type LogLevel as L, OtelTaskLogger as O, type TaskLogger as T, logLevels as l };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Span, SpanOptions } from '@opentelemetry/api';
|
|
2
|
+
import { Logger } from '@opentelemetry/api-logs';
|
|
3
|
+
import { T as TriggerTracer } from './tracer-N0p2Fuuv.mjs';
|
|
4
|
+
|
|
5
|
+
type LogLevel = "none" | "error" | "warn" | "info" | "debug" | "log";
|
|
6
|
+
declare const logLevels: Array<LogLevel>;
|
|
7
|
+
type TaskLoggerConfig = {
|
|
8
|
+
logger: Logger;
|
|
9
|
+
tracer: TriggerTracer;
|
|
10
|
+
level: LogLevel;
|
|
11
|
+
};
|
|
12
|
+
interface TaskLogger {
|
|
13
|
+
debug(message: string, properties?: Record<string, unknown>): void;
|
|
14
|
+
log(message: string, properties?: Record<string, unknown>): void;
|
|
15
|
+
info(message: string, properties?: Record<string, unknown>): void;
|
|
16
|
+
warn(message: string, properties?: Record<string, unknown>): void;
|
|
17
|
+
error(message: string, properties?: Record<string, unknown>): void;
|
|
18
|
+
trace<T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions): Promise<T>;
|
|
19
|
+
}
|
|
20
|
+
declare class OtelTaskLogger implements TaskLogger {
|
|
21
|
+
#private;
|
|
22
|
+
private readonly _config;
|
|
23
|
+
private readonly _level;
|
|
24
|
+
constructor(_config: TaskLoggerConfig);
|
|
25
|
+
debug(message: string, properties?: Record<string, unknown>): void;
|
|
26
|
+
log(message: string, properties?: Record<string, unknown>): void;
|
|
27
|
+
info(message: string, properties?: Record<string, unknown>): void;
|
|
28
|
+
warn(message: string, properties?: Record<string, unknown>): void;
|
|
29
|
+
error(message: string, properties?: Record<string, unknown>): void;
|
|
30
|
+
trace<T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions): Promise<T>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { type LogLevel as L, OtelTaskLogger as O, type TaskLogger as T, logLevels as l };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Context, Span, SpanOptions, Tracer } from '@opentelemetry/api';
|
|
2
|
+
import { Logger } from '@opentelemetry/api-logs';
|
|
3
|
+
|
|
4
|
+
type TriggerTracerConfig = {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
} | {
|
|
8
|
+
tracer: Tracer;
|
|
9
|
+
logger: Logger;
|
|
10
|
+
};
|
|
11
|
+
declare class TriggerTracer {
|
|
12
|
+
private readonly _config;
|
|
13
|
+
constructor(_config: TriggerTracerConfig);
|
|
14
|
+
private _tracer;
|
|
15
|
+
private get tracer();
|
|
16
|
+
private _logger;
|
|
17
|
+
private get logger();
|
|
18
|
+
extractContext(traceContext?: Record<string, unknown>): Context;
|
|
19
|
+
startActiveSpan<T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions, ctx?: Context): Promise<T>;
|
|
20
|
+
startSpan(name: string, options?: SpanOptions, ctx?: Context): Span;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { TriggerTracer as T };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Context, Span, SpanOptions, Tracer } from '@opentelemetry/api';
|
|
2
|
+
import { Logger } from '@opentelemetry/api-logs';
|
|
3
|
+
|
|
4
|
+
type TriggerTracerConfig = {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
} | {
|
|
8
|
+
tracer: Tracer;
|
|
9
|
+
logger: Logger;
|
|
10
|
+
};
|
|
11
|
+
declare class TriggerTracer {
|
|
12
|
+
private readonly _config;
|
|
13
|
+
constructor(_config: TriggerTracerConfig);
|
|
14
|
+
private _tracer;
|
|
15
|
+
private get tracer();
|
|
16
|
+
private _logger;
|
|
17
|
+
private get logger();
|
|
18
|
+
extractContext(traceContext?: Record<string, unknown>): Context;
|
|
19
|
+
startActiveSpan<T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions, ctx?: Context): Promise<T>;
|
|
20
|
+
startSpan(name: string, options?: SpanOptions, ctx?: Context): Span;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { TriggerTracer as T };
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Prettify<T> = {
|
|
2
|
+
[K in keyof T]: T[K];
|
|
3
|
+
} & {};
|
|
4
|
+
interface AsyncMap {
|
|
5
|
+
delete: (key: string) => Promise<boolean>;
|
|
6
|
+
get: (key: string) => Promise<any>;
|
|
7
|
+
has: (key: string) => Promise<boolean>;
|
|
8
|
+
set: (key: string, value: any) => Promise<any>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type { AsyncMap, Prettify };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Prettify<T> = {
|
|
2
|
+
[K in keyof T]: T[K];
|
|
3
|
+
} & {};
|
|
4
|
+
interface AsyncMap {
|
|
5
|
+
delete: (key: string) => Promise<boolean>;
|
|
6
|
+
get: (key: string) => Promise<any>;
|
|
7
|
+
has: (key: string) => Promise<boolean>;
|
|
8
|
+
set: (key: string, value: any) => Promise<any>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type { AsyncMap, Prettify };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/utils.d.mts
ADDED
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
|
|
6
|
+
// src/utils.ts
|
|
7
|
+
function deepMergeFilters(...filters) {
|
|
8
|
+
const result = {};
|
|
9
|
+
for (const filter of filters) {
|
|
10
|
+
for (const key in filter) {
|
|
11
|
+
if (filter.hasOwnProperty(key)) {
|
|
12
|
+
const filterValue = filter[key];
|
|
13
|
+
const existingValue = result[key];
|
|
14
|
+
if (existingValue && typeof existingValue === "object" && typeof filterValue === "object" && !Array.isArray(existingValue) && !Array.isArray(filterValue) && existingValue !== null && filterValue !== null) {
|
|
15
|
+
result[key] = deepMergeFilters(existingValue, filterValue);
|
|
16
|
+
} else {
|
|
17
|
+
result[key] = filterValue;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
__name(deepMergeFilters, "deepMergeFilters");
|
|
25
|
+
function assertExhaustive(x) {
|
|
26
|
+
throw new Error("Unexpected object: " + x);
|
|
27
|
+
}
|
|
28
|
+
__name(assertExhaustive, "assertExhaustive");
|
|
29
|
+
|
|
30
|
+
exports.assertExhaustive = assertExhaustive;
|
|
31
|
+
exports.deepMergeFilters = deepMergeFilters;
|
|
32
|
+
//# sourceMappingURL=out.js.map
|
|
33
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"names":["deepMergeFilters","filters","result","filter","key","hasOwnProperty","filterValue","existingValue","Array","isArray","assertExhaustive","x","Error"],"mappings":";;;;AAKO,SAASA,oBAAoBC,SAAqC;AACvE,QAAMC,SAAsB,CAAC;AAE7B,aAAWC,UAAUF,SAAS;AAC5B,eAAWG,OAAOD,QAAQ;AACxB,UAAIA,OAAOE,eAAeD,GAAAA,GAAM;AAC9B,cAAME,cAAcH,OAAOC,GAAAA;AAC3B,cAAMG,gBAAgBL,OAAOE,GAAAA;AAE7B,YACEG,iBACA,OAAOA,kBAAkB,YACzB,OAAOD,gBAAgB,YACvB,CAACE,MAAMC,QAAQF,aAAAA,KACf,CAACC,MAAMC,QAAQH,WAAAA,KACfC,kBAAkB,QAClBD,gBAAgB,MAChB;AACAJ,iBAAOE,GAAAA,IAAOJ,iBAAiBO,eAAeD,WAAAA;QAChD,OAAO;AACLJ,iBAAOE,GAAAA,IAAOE;QAChB;MACF;IACF;EACF;AAEA,SAAOJ;AACT;AA3BgBF;AA6BT,SAASU,iBAAiBC,GAAiB;AAChD,QAAM,IAAIC,MAAM,wBAAwBD,CAAAA;AAC1C;AAFgBD","sourcesContent":["// EventFilter is typed as type EventFilter = { [key: string]: EventFilter | string[] | number[] | boolean[] }\n\nimport { EventFilter } from \"./schemas\";\n\n// This function should take any number of EventFilters and return a new EventFilter that is the result of merging of them.\nexport function deepMergeFilters(...filters: EventFilter[]): EventFilter {\n const result: EventFilter = {};\n\n for (const filter of filters) {\n for (const key in filter) {\n if (filter.hasOwnProperty(key)) {\n const filterValue = filter[key];\n const existingValue = result[key];\n\n if (\n existingValue &&\n typeof existingValue === \"object\" &&\n typeof filterValue === \"object\" &&\n !Array.isArray(existingValue) &&\n !Array.isArray(filterValue) &&\n existingValue !== null &&\n filterValue !== null\n ) {\n result[key] = deepMergeFilters(existingValue, filterValue);\n } else {\n result[key] = filterValue;\n }\n }\n }\n }\n\n return result;\n}\n\nexport function assertExhaustive(x: never): never {\n throw new Error(\"Unexpected object: \" + x);\n}\n"]}
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/utils.ts
|
|
5
|
+
function deepMergeFilters(...filters) {
|
|
6
|
+
const result = {};
|
|
7
|
+
for (const filter of filters) {
|
|
8
|
+
for (const key in filter) {
|
|
9
|
+
if (filter.hasOwnProperty(key)) {
|
|
10
|
+
const filterValue = filter[key];
|
|
11
|
+
const existingValue = result[key];
|
|
12
|
+
if (existingValue && typeof existingValue === "object" && typeof filterValue === "object" && !Array.isArray(existingValue) && !Array.isArray(filterValue) && existingValue !== null && filterValue !== null) {
|
|
13
|
+
result[key] = deepMergeFilters(existingValue, filterValue);
|
|
14
|
+
} else {
|
|
15
|
+
result[key] = filterValue;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
__name(deepMergeFilters, "deepMergeFilters");
|
|
23
|
+
function assertExhaustive(x) {
|
|
24
|
+
throw new Error("Unexpected object: " + x);
|
|
25
|
+
}
|
|
26
|
+
__name(assertExhaustive, "assertExhaustive");
|
|
27
|
+
|
|
28
|
+
export { assertExhaustive, deepMergeFilters };
|
|
29
|
+
//# sourceMappingURL=out.js.map
|
|
30
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"names":["deepMergeFilters","filters","result","filter","key","hasOwnProperty","filterValue","existingValue","Array","isArray","assertExhaustive","x","Error"],"mappings":";;;;AAKO,SAASA,oBAAoBC,SAAqC;AACvE,QAAMC,SAAsB,CAAC;AAE7B,aAAWC,UAAUF,SAAS;AAC5B,eAAWG,OAAOD,QAAQ;AACxB,UAAIA,OAAOE,eAAeD,GAAAA,GAAM;AAC9B,cAAME,cAAcH,OAAOC,GAAAA;AAC3B,cAAMG,gBAAgBL,OAAOE,GAAAA;AAE7B,YACEG,iBACA,OAAOA,kBAAkB,YACzB,OAAOD,gBAAgB,YACvB,CAACE,MAAMC,QAAQF,aAAAA,KACf,CAACC,MAAMC,QAAQH,WAAAA,KACfC,kBAAkB,QAClBD,gBAAgB,MAChB;AACAJ,iBAAOE,GAAAA,IAAOJ,iBAAiBO,eAAeD,WAAAA;QAChD,OAAO;AACLJ,iBAAOE,GAAAA,IAAOE;QAChB;MACF;IACF;EACF;AAEA,SAAOJ;AACT;AA3BgBF;AA6BT,SAASU,iBAAiBC,GAAiB;AAChD,QAAM,IAAIC,MAAM,wBAAwBD,CAAAA;AAC1C;AAFgBD","sourcesContent":["// EventFilter is typed as type EventFilter = { [key: string]: EventFilter | string[] | number[] | boolean[] }\n\nimport { EventFilter } from \"./schemas\";\n\n// This function should take any number of EventFilters and return a new EventFilter that is the result of merging of them.\nexport function deepMergeFilters(...filters: EventFilter[]): EventFilter {\n const result: EventFilter = {};\n\n for (const filter of filters) {\n for (const key in filter) {\n if (filter.hasOwnProperty(key)) {\n const filterValue = filter[key];\n const existingValue = result[key];\n\n if (\n existingValue &&\n typeof existingValue === \"object\" &&\n typeof filterValue === \"object\" &&\n !Array.isArray(existingValue) &&\n !Array.isArray(filterValue) &&\n existingValue !== null &&\n filterValue !== null\n ) {\n result[key] = deepMergeFilters(existingValue, filterValue);\n } else {\n result[key] = filterValue;\n }\n }\n }\n }\n\n return result;\n}\n\nexport function assertExhaustive(x: never): never {\n throw new Error(\"Unexpected object: \" + x);\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { T as TaskRunExecutionResult, B as BatchTaskRunExecutionResult, a as TaskRunContext } from '../../common-CLW82lkt.mjs';
|
|
2
|
+
import { R as RuntimeManager } from '../../manager-KvCabW1a.mjs';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
5
|
+
declare class DevRuntimeManager implements RuntimeManager {
|
|
6
|
+
_taskWaits: Map<string, {
|
|
7
|
+
resolve: (value: TaskRunExecutionResult) => void;
|
|
8
|
+
}>;
|
|
9
|
+
_batchWaits: Map<string, {
|
|
10
|
+
resolve: (value: BatchTaskRunExecutionResult) => void;
|
|
11
|
+
reject: (err?: any) => void;
|
|
12
|
+
}>;
|
|
13
|
+
_pendingCompletionNotifications: Map<string, TaskRunExecutionResult>;
|
|
14
|
+
disable(): void;
|
|
15
|
+
waitForDuration(ms: number): Promise<void>;
|
|
16
|
+
waitUntil(date: Date): Promise<void>;
|
|
17
|
+
waitForTask(params: {
|
|
18
|
+
id: string;
|
|
19
|
+
ctx: TaskRunContext;
|
|
20
|
+
}): Promise<TaskRunExecutionResult>;
|
|
21
|
+
waitForBatch(params: {
|
|
22
|
+
id: string;
|
|
23
|
+
runs: string[];
|
|
24
|
+
ctx: TaskRunContext;
|
|
25
|
+
}): Promise<BatchTaskRunExecutionResult>;
|
|
26
|
+
resumeTask(completion: TaskRunExecutionResult, runId: string): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { DevRuntimeManager };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { T as TaskRunExecutionResult, B as BatchTaskRunExecutionResult, a as TaskRunContext } from '../../common-CLW82lkt.js';
|
|
2
|
+
import { R as RuntimeManager } from '../../manager-OBA35PzR.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
5
|
+
declare class DevRuntimeManager implements RuntimeManager {
|
|
6
|
+
_taskWaits: Map<string, {
|
|
7
|
+
resolve: (value: TaskRunExecutionResult) => void;
|
|
8
|
+
}>;
|
|
9
|
+
_batchWaits: Map<string, {
|
|
10
|
+
resolve: (value: BatchTaskRunExecutionResult) => void;
|
|
11
|
+
reject: (err?: any) => void;
|
|
12
|
+
}>;
|
|
13
|
+
_pendingCompletionNotifications: Map<string, TaskRunExecutionResult>;
|
|
14
|
+
disable(): void;
|
|
15
|
+
waitForDuration(ms: number): Promise<void>;
|
|
16
|
+
waitUntil(date: Date): Promise<void>;
|
|
17
|
+
waitForTask(params: {
|
|
18
|
+
id: string;
|
|
19
|
+
ctx: TaskRunContext;
|
|
20
|
+
}): Promise<TaskRunExecutionResult>;
|
|
21
|
+
waitForBatch(params: {
|
|
22
|
+
id: string;
|
|
23
|
+
runs: string[];
|
|
24
|
+
ctx: TaskRunContext;
|
|
25
|
+
}): Promise<BatchTaskRunExecutionResult>;
|
|
26
|
+
resumeTask(completion: TaskRunExecutionResult, runId: string): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { DevRuntimeManager };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var promises = require('timers/promises');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __publicField = (obj, key, value) => {
|
|
9
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
async function unboundedTimeout(delay = 0, value, options) {
|
|
13
|
+
const maxDelay = 2147483647;
|
|
14
|
+
const fullTimeouts = Math.floor(delay / maxDelay);
|
|
15
|
+
const remainingDelay = delay % maxDelay;
|
|
16
|
+
let lastTimeoutResult = await promises.setTimeout(remainingDelay, value, options);
|
|
17
|
+
for (let i = 0; i < fullTimeouts; i++) {
|
|
18
|
+
lastTimeoutResult = await promises.setTimeout(maxDelay, value, options);
|
|
19
|
+
}
|
|
20
|
+
return lastTimeoutResult;
|
|
21
|
+
}
|
|
22
|
+
__name(unboundedTimeout, "unboundedTimeout");
|
|
23
|
+
|
|
24
|
+
// src/v3/runtime/devRuntimeManager.ts
|
|
25
|
+
var _DevRuntimeManager = class _DevRuntimeManager {
|
|
26
|
+
constructor() {
|
|
27
|
+
__publicField(this, "_taskWaits", /* @__PURE__ */ new Map());
|
|
28
|
+
__publicField(this, "_batchWaits", /* @__PURE__ */ new Map());
|
|
29
|
+
__publicField(this, "_pendingCompletionNotifications", /* @__PURE__ */ new Map());
|
|
30
|
+
}
|
|
31
|
+
disable() {
|
|
32
|
+
}
|
|
33
|
+
async waitForDuration(ms) {
|
|
34
|
+
await unboundedTimeout(ms);
|
|
35
|
+
}
|
|
36
|
+
async waitUntil(date) {
|
|
37
|
+
return this.waitForDuration(date.getTime() - Date.now());
|
|
38
|
+
}
|
|
39
|
+
async waitForTask(params) {
|
|
40
|
+
const pendingCompletion = this._pendingCompletionNotifications.get(params.id);
|
|
41
|
+
if (pendingCompletion) {
|
|
42
|
+
this._pendingCompletionNotifications.delete(params.id);
|
|
43
|
+
return pendingCompletion;
|
|
44
|
+
}
|
|
45
|
+
const promise = new Promise((resolve) => {
|
|
46
|
+
this._taskWaits.set(params.id, {
|
|
47
|
+
resolve
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
return await promise;
|
|
51
|
+
}
|
|
52
|
+
async waitForBatch(params) {
|
|
53
|
+
if (!params.runs.length) {
|
|
54
|
+
return Promise.resolve({
|
|
55
|
+
id: params.id,
|
|
56
|
+
items: []
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const promise = Promise.all(params.runs.map((runId) => {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
const pendingCompletion = this._pendingCompletionNotifications.get(runId);
|
|
62
|
+
if (pendingCompletion) {
|
|
63
|
+
this._pendingCompletionNotifications.delete(runId);
|
|
64
|
+
resolve(pendingCompletion);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this._taskWaits.set(runId, {
|
|
68
|
+
resolve
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}));
|
|
72
|
+
const results = await promise;
|
|
73
|
+
return {
|
|
74
|
+
id: params.id,
|
|
75
|
+
items: results
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
resumeTask(completion, runId) {
|
|
79
|
+
const wait = this._taskWaits.get(runId);
|
|
80
|
+
if (!wait) {
|
|
81
|
+
this._pendingCompletionNotifications.set(runId, completion);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
wait.resolve(completion);
|
|
85
|
+
this._taskWaits.delete(runId);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
__name(_DevRuntimeManager, "DevRuntimeManager");
|
|
89
|
+
var DevRuntimeManager = _DevRuntimeManager;
|
|
90
|
+
|
|
91
|
+
exports.DevRuntimeManager = DevRuntimeManager;
|
|
92
|
+
//# sourceMappingURL=out.js.map
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/v3/utils/timers.ts","../../../src/v3/runtime/devRuntimeManager.ts"],"names":["setInterval","setTimeout","unboundedTimeout","delay","value","options","maxDelay","fullTimeouts","Math","floor","remainingDelay","lastTimeoutResult","i","DevRuntimeManager","_taskWaits","Map","_batchWaits","_pendingCompletionNotifications","disable","waitForDuration","ms","waitUntil","date","getTime","Date","now","waitForTask","params","pendingCompletion","get","id","delete","promise","Promise","resolve","set","waitForBatch","runs","length","items","all","map","runId","reject","results","resumeTask","completion","wait"],"mappings":";;;;;;;;;AAAA,SAASA,aAAaC,kBAAkB;AAExC,eAAsBC,iBACpBC,QAAgB,GAChBC,OACAC,SACY;AACZ,QAAMC,WAAW;AAEjB,QAAMC,eAAeC,KAAKC,MAAMN,QAAQG,QAAAA;AACxC,QAAMI,iBAAiBP,QAAQG;AAE/B,MAAIK,oBAAoB,MAAMV,WAAWS,gBAAgBN,OAAOC,OAAAA;AAEhE,WAASO,IAAI,GAAGA,IAAIL,cAAcK,KAAK;AACrCD,wBAAoB,MAAMV,WAAWK,UAAUF,OAAOC,OAAAA;EACxD;AAEA,SAAOM;AACT;AAjBsBT;;;ACOf,IAAMW,qBAAN,MAAMA,mBAAAA;EAAN;AACLC,sCAAgF,oBAAIC,IAAAA;AAEpFC,uCAGI,oBAAID,IAAAA;AAERE,2DAAuE,oBAAIF,IAAAA;;EAE3EG,UAAgB;EAEhB;EAEA,MAAMC,gBAAgBC,IAA2B;AAC/C,UAAMlB,iBAAiBkB,EAAAA;EACzB;EAEA,MAAMC,UAAUC,MAA2B;AACzC,WAAO,KAAKH,gBAAgBG,KAAKC,QAAO,IAAKC,KAAKC,IAAG,CAAA;EACvD;EAEA,MAAMC,YAAYC,QAA8E;AAC9F,UAAMC,oBAAoB,KAAKX,gCAAgCY,IAAIF,OAAOG,EAAE;AAE5E,QAAIF,mBAAmB;AACrB,WAAKX,gCAAgCc,OAAOJ,OAAOG,EAAE;AAErD,aAAOF;IACT;AAEA,UAAMI,UAAU,IAAIC,QAAgC,CAACC,YAAY;AAC/D,WAAKpB,WAAWqB,IAAIR,OAAOG,IAAI;QAAEI;MAAQ,CAAA;IAC3C,CAAA;AAEA,WAAO,MAAMF;EACf;EAEA,MAAMI,aAAaT,QAIsB;AACvC,QAAI,CAACA,OAAOU,KAAKC,QAAQ;AACvB,aAAOL,QAAQC,QAAQ;QAAEJ,IAAIH,OAAOG;QAAIS,OAAO,CAAA;MAAG,CAAA;IACpD;AAEA,UAAMP,UAAUC,QAAQO,IACtBb,OAAOU,KAAKI,IAAI,CAACC,UAAU;AACzB,aAAO,IAAIT,QAAgC,CAACC,SAASS,WAAW;AAC9D,cAAMf,oBAAoB,KAAKX,gCAAgCY,IAAIa,KAAAA;AAEnE,YAAId,mBAAmB;AACrB,eAAKX,gCAAgCc,OAAOW,KAAAA;AAE5CR,kBAAQN,iBAAAA;AAER;QACF;AAEA,aAAKd,WAAWqB,IAAIO,OAAO;UAAER;QAAQ,CAAA;MACvC,CAAA;IACF,CAAA,CAAA;AAGF,UAAMU,UAAU,MAAMZ;AAEtB,WAAO;MACLF,IAAIH,OAAOG;MACXS,OAAOK;IACT;EACF;EAEAC,WAAWC,YAAoCJ,OAAqB;AAClE,UAAMK,OAAO,KAAKjC,WAAWe,IAAIa,KAAAA;AAEjC,QAAI,CAACK,MAAM;AAET,WAAK9B,gCAAgCkB,IAAIO,OAAOI,UAAAA;AAEhD;IACF;AAEAC,SAAKb,QAAQY,UAAAA;AAEb,SAAKhC,WAAWiB,OAAOW,KAAAA;EACzB;AACF;AAvFa7B;AAAN,IAAMA,oBAAN","sourcesContent":["import { setInterval, setTimeout } from \"node:timers/promises\";\n\nexport async function unboundedTimeout<T = void>(\n delay: number = 0,\n value?: T,\n options?: Parameters<typeof setTimeout>[2]\n): Promise<T> {\n const maxDelay = 2147483647; // Highest value that will fit in a 32-bit signed integer\n\n const fullTimeouts = Math.floor(delay / maxDelay);\n const remainingDelay = delay % maxDelay;\n\n let lastTimeoutResult = await setTimeout(remainingDelay, value, options);\n\n for (let i = 0; i < fullTimeouts; i++) {\n lastTimeoutResult = await setTimeout(maxDelay, value, options);\n }\n\n return lastTimeoutResult;\n}\n\nexport async function checkpointSafeTimeout(delay: number = 0): Promise<void> {\n const scanIntervalMs = 1000;\n\n // Every scanIntervalMs, check if delay has elapsed\n for await (const start of setInterval(scanIntervalMs, Date.now())) {\n if (Date.now() - start > delay) {\n break;\n }\n }\n}\n","import {\n BatchTaskRunExecutionResult,\n TaskRunContext,\n TaskRunExecution,\n TaskRunExecutionResult,\n} from \"../schemas\";\nimport { RuntimeManager } from \"./manager\";\nimport { unboundedTimeout } from \"../utils/timers\";\n\nexport class DevRuntimeManager implements RuntimeManager {\n _taskWaits: Map<string, { resolve: (value: TaskRunExecutionResult) => void }> = new Map();\n\n _batchWaits: Map<\n string,\n { resolve: (value: BatchTaskRunExecutionResult) => void; reject: (err?: any) => void }\n > = new Map();\n\n _pendingCompletionNotifications: Map<string, TaskRunExecutionResult> = new Map();\n\n disable(): void {\n // do nothing\n }\n\n async waitForDuration(ms: number): Promise<void> {\n await unboundedTimeout(ms);\n }\n\n async waitUntil(date: Date): Promise<void> {\n return this.waitForDuration(date.getTime() - Date.now());\n }\n\n async waitForTask(params: { id: string; ctx: TaskRunContext }): Promise<TaskRunExecutionResult> {\n const pendingCompletion = this._pendingCompletionNotifications.get(params.id);\n\n if (pendingCompletion) {\n this._pendingCompletionNotifications.delete(params.id);\n\n return pendingCompletion;\n }\n\n const promise = new Promise<TaskRunExecutionResult>((resolve) => {\n this._taskWaits.set(params.id, { resolve });\n });\n\n return await promise;\n }\n\n async waitForBatch(params: {\n id: string;\n runs: string[];\n ctx: TaskRunContext;\n }): Promise<BatchTaskRunExecutionResult> {\n if (!params.runs.length) {\n return Promise.resolve({ id: params.id, items: [] });\n }\n\n const promise = Promise.all(\n params.runs.map((runId) => {\n return new Promise<TaskRunExecutionResult>((resolve, reject) => {\n const pendingCompletion = this._pendingCompletionNotifications.get(runId);\n\n if (pendingCompletion) {\n this._pendingCompletionNotifications.delete(runId);\n\n resolve(pendingCompletion);\n\n return;\n }\n\n this._taskWaits.set(runId, { resolve });\n });\n })\n );\n\n const results = await promise;\n\n return {\n id: params.id,\n items: results,\n };\n }\n\n resumeTask(completion: TaskRunExecutionResult, runId: string): void {\n const wait = this._taskWaits.get(runId);\n\n if (!wait) {\n // We need to store the completion in case the task is awaited later\n this._pendingCompletionNotifications.set(runId, completion);\n\n return;\n }\n\n wait.resolve(completion);\n\n this._taskWaits.delete(runId);\n }\n}\n"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { setTimeout } from 'node:timers/promises';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __publicField = (obj, key, value) => {
|
|
7
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
10
|
+
async function unboundedTimeout(delay = 0, value, options) {
|
|
11
|
+
const maxDelay = 2147483647;
|
|
12
|
+
const fullTimeouts = Math.floor(delay / maxDelay);
|
|
13
|
+
const remainingDelay = delay % maxDelay;
|
|
14
|
+
let lastTimeoutResult = await setTimeout(remainingDelay, value, options);
|
|
15
|
+
for (let i = 0; i < fullTimeouts; i++) {
|
|
16
|
+
lastTimeoutResult = await setTimeout(maxDelay, value, options);
|
|
17
|
+
}
|
|
18
|
+
return lastTimeoutResult;
|
|
19
|
+
}
|
|
20
|
+
__name(unboundedTimeout, "unboundedTimeout");
|
|
21
|
+
|
|
22
|
+
// src/v3/runtime/devRuntimeManager.ts
|
|
23
|
+
var _DevRuntimeManager = class _DevRuntimeManager {
|
|
24
|
+
constructor() {
|
|
25
|
+
__publicField(this, "_taskWaits", /* @__PURE__ */ new Map());
|
|
26
|
+
__publicField(this, "_batchWaits", /* @__PURE__ */ new Map());
|
|
27
|
+
__publicField(this, "_pendingCompletionNotifications", /* @__PURE__ */ new Map());
|
|
28
|
+
}
|
|
29
|
+
disable() {
|
|
30
|
+
}
|
|
31
|
+
async waitForDuration(ms) {
|
|
32
|
+
await unboundedTimeout(ms);
|
|
33
|
+
}
|
|
34
|
+
async waitUntil(date) {
|
|
35
|
+
return this.waitForDuration(date.getTime() - Date.now());
|
|
36
|
+
}
|
|
37
|
+
async waitForTask(params) {
|
|
38
|
+
const pendingCompletion = this._pendingCompletionNotifications.get(params.id);
|
|
39
|
+
if (pendingCompletion) {
|
|
40
|
+
this._pendingCompletionNotifications.delete(params.id);
|
|
41
|
+
return pendingCompletion;
|
|
42
|
+
}
|
|
43
|
+
const promise = new Promise((resolve) => {
|
|
44
|
+
this._taskWaits.set(params.id, {
|
|
45
|
+
resolve
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return await promise;
|
|
49
|
+
}
|
|
50
|
+
async waitForBatch(params) {
|
|
51
|
+
if (!params.runs.length) {
|
|
52
|
+
return Promise.resolve({
|
|
53
|
+
id: params.id,
|
|
54
|
+
items: []
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const promise = Promise.all(params.runs.map((runId) => {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const pendingCompletion = this._pendingCompletionNotifications.get(runId);
|
|
60
|
+
if (pendingCompletion) {
|
|
61
|
+
this._pendingCompletionNotifications.delete(runId);
|
|
62
|
+
resolve(pendingCompletion);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this._taskWaits.set(runId, {
|
|
66
|
+
resolve
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}));
|
|
70
|
+
const results = await promise;
|
|
71
|
+
return {
|
|
72
|
+
id: params.id,
|
|
73
|
+
items: results
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
resumeTask(completion, runId) {
|
|
77
|
+
const wait = this._taskWaits.get(runId);
|
|
78
|
+
if (!wait) {
|
|
79
|
+
this._pendingCompletionNotifications.set(runId, completion);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
wait.resolve(completion);
|
|
83
|
+
this._taskWaits.delete(runId);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
__name(_DevRuntimeManager, "DevRuntimeManager");
|
|
87
|
+
var DevRuntimeManager = _DevRuntimeManager;
|
|
88
|
+
|
|
89
|
+
export { DevRuntimeManager };
|
|
90
|
+
//# sourceMappingURL=out.js.map
|
|
91
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/v3/utils/timers.ts","../../../src/v3/runtime/devRuntimeManager.ts"],"names":["setInterval","setTimeout","unboundedTimeout","delay","value","options","maxDelay","fullTimeouts","Math","floor","remainingDelay","lastTimeoutResult","i","DevRuntimeManager","_taskWaits","Map","_batchWaits","_pendingCompletionNotifications","disable","waitForDuration","ms","waitUntil","date","getTime","Date","now","waitForTask","params","pendingCompletion","get","id","delete","promise","Promise","resolve","set","waitForBatch","runs","length","items","all","map","runId","reject","results","resumeTask","completion","wait"],"mappings":";;;;;;;;;AAAA,SAASA,aAAaC,kBAAkB;AAExC,eAAsBC,iBACpBC,QAAgB,GAChBC,OACAC,SACY;AACZ,QAAMC,WAAW;AAEjB,QAAMC,eAAeC,KAAKC,MAAMN,QAAQG,QAAAA;AACxC,QAAMI,iBAAiBP,QAAQG;AAE/B,MAAIK,oBAAoB,MAAMV,WAAWS,gBAAgBN,OAAOC,OAAAA;AAEhE,WAASO,IAAI,GAAGA,IAAIL,cAAcK,KAAK;AACrCD,wBAAoB,MAAMV,WAAWK,UAAUF,OAAOC,OAAAA;EACxD;AAEA,SAAOM;AACT;AAjBsBT;;;ACOf,IAAMW,qBAAN,MAAMA,mBAAAA;EAAN;AACLC,sCAAgF,oBAAIC,IAAAA;AAEpFC,uCAGI,oBAAID,IAAAA;AAERE,2DAAuE,oBAAIF,IAAAA;;EAE3EG,UAAgB;EAEhB;EAEA,MAAMC,gBAAgBC,IAA2B;AAC/C,UAAMlB,iBAAiBkB,EAAAA;EACzB;EAEA,MAAMC,UAAUC,MAA2B;AACzC,WAAO,KAAKH,gBAAgBG,KAAKC,QAAO,IAAKC,KAAKC,IAAG,CAAA;EACvD;EAEA,MAAMC,YAAYC,QAA8E;AAC9F,UAAMC,oBAAoB,KAAKX,gCAAgCY,IAAIF,OAAOG,EAAE;AAE5E,QAAIF,mBAAmB;AACrB,WAAKX,gCAAgCc,OAAOJ,OAAOG,EAAE;AAErD,aAAOF;IACT;AAEA,UAAMI,UAAU,IAAIC,QAAgC,CAACC,YAAY;AAC/D,WAAKpB,WAAWqB,IAAIR,OAAOG,IAAI;QAAEI;MAAQ,CAAA;IAC3C,CAAA;AAEA,WAAO,MAAMF;EACf;EAEA,MAAMI,aAAaT,QAIsB;AACvC,QAAI,CAACA,OAAOU,KAAKC,QAAQ;AACvB,aAAOL,QAAQC,QAAQ;QAAEJ,IAAIH,OAAOG;QAAIS,OAAO,CAAA;MAAG,CAAA;IACpD;AAEA,UAAMP,UAAUC,QAAQO,IACtBb,OAAOU,KAAKI,IAAI,CAACC,UAAU;AACzB,aAAO,IAAIT,QAAgC,CAACC,SAASS,WAAW;AAC9D,cAAMf,oBAAoB,KAAKX,gCAAgCY,IAAIa,KAAAA;AAEnE,YAAId,mBAAmB;AACrB,eAAKX,gCAAgCc,OAAOW,KAAAA;AAE5CR,kBAAQN,iBAAAA;AAER;QACF;AAEA,aAAKd,WAAWqB,IAAIO,OAAO;UAAER;QAAQ,CAAA;MACvC,CAAA;IACF,CAAA,CAAA;AAGF,UAAMU,UAAU,MAAMZ;AAEtB,WAAO;MACLF,IAAIH,OAAOG;MACXS,OAAOK;IACT;EACF;EAEAC,WAAWC,YAAoCJ,OAAqB;AAClE,UAAMK,OAAO,KAAKjC,WAAWe,IAAIa,KAAAA;AAEjC,QAAI,CAACK,MAAM;AAET,WAAK9B,gCAAgCkB,IAAIO,OAAOI,UAAAA;AAEhD;IACF;AAEAC,SAAKb,QAAQY,UAAAA;AAEb,SAAKhC,WAAWiB,OAAOW,KAAAA;EACzB;AACF;AAvFa7B;AAAN,IAAMA,oBAAN","sourcesContent":["import { setInterval, setTimeout } from \"node:timers/promises\";\n\nexport async function unboundedTimeout<T = void>(\n delay: number = 0,\n value?: T,\n options?: Parameters<typeof setTimeout>[2]\n): Promise<T> {\n const maxDelay = 2147483647; // Highest value that will fit in a 32-bit signed integer\n\n const fullTimeouts = Math.floor(delay / maxDelay);\n const remainingDelay = delay % maxDelay;\n\n let lastTimeoutResult = await setTimeout(remainingDelay, value, options);\n\n for (let i = 0; i < fullTimeouts; i++) {\n lastTimeoutResult = await setTimeout(maxDelay, value, options);\n }\n\n return lastTimeoutResult;\n}\n\nexport async function checkpointSafeTimeout(delay: number = 0): Promise<void> {\n const scanIntervalMs = 1000;\n\n // Every scanIntervalMs, check if delay has elapsed\n for await (const start of setInterval(scanIntervalMs, Date.now())) {\n if (Date.now() - start > delay) {\n break;\n }\n }\n}\n","import {\n BatchTaskRunExecutionResult,\n TaskRunContext,\n TaskRunExecution,\n TaskRunExecutionResult,\n} from \"../schemas\";\nimport { RuntimeManager } from \"./manager\";\nimport { unboundedTimeout } from \"../utils/timers\";\n\nexport class DevRuntimeManager implements RuntimeManager {\n _taskWaits: Map<string, { resolve: (value: TaskRunExecutionResult) => void }> = new Map();\n\n _batchWaits: Map<\n string,\n { resolve: (value: BatchTaskRunExecutionResult) => void; reject: (err?: any) => void }\n > = new Map();\n\n _pendingCompletionNotifications: Map<string, TaskRunExecutionResult> = new Map();\n\n disable(): void {\n // do nothing\n }\n\n async waitForDuration(ms: number): Promise<void> {\n await unboundedTimeout(ms);\n }\n\n async waitUntil(date: Date): Promise<void> {\n return this.waitForDuration(date.getTime() - Date.now());\n }\n\n async waitForTask(params: { id: string; ctx: TaskRunContext }): Promise<TaskRunExecutionResult> {\n const pendingCompletion = this._pendingCompletionNotifications.get(params.id);\n\n if (pendingCompletion) {\n this._pendingCompletionNotifications.delete(params.id);\n\n return pendingCompletion;\n }\n\n const promise = new Promise<TaskRunExecutionResult>((resolve) => {\n this._taskWaits.set(params.id, { resolve });\n });\n\n return await promise;\n }\n\n async waitForBatch(params: {\n id: string;\n runs: string[];\n ctx: TaskRunContext;\n }): Promise<BatchTaskRunExecutionResult> {\n if (!params.runs.length) {\n return Promise.resolve({ id: params.id, items: [] });\n }\n\n const promise = Promise.all(\n params.runs.map((runId) => {\n return new Promise<TaskRunExecutionResult>((resolve, reject) => {\n const pendingCompletion = this._pendingCompletionNotifications.get(runId);\n\n if (pendingCompletion) {\n this._pendingCompletionNotifications.delete(runId);\n\n resolve(pendingCompletion);\n\n return;\n }\n\n this._taskWaits.set(runId, { resolve });\n });\n })\n );\n\n const results = await promise;\n\n return {\n id: params.id,\n items: results,\n };\n }\n\n resumeTask(completion: TaskRunExecutionResult, runId: string): void {\n const wait = this._taskWaits.get(runId);\n\n if (!wait) {\n // We need to store the completion in case the task is awaited later\n this._pendingCompletionNotifications.set(runId, completion);\n\n return;\n }\n\n wait.resolve(completion);\n\n this._taskWaits.delete(runId);\n }\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { b as TaskRunError } from '../common-CLW82lkt.mjs';
|
|
3
|
+
|
|
4
|
+
declare class AbortTaskRunError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
declare function parseError(error: unknown): TaskRunError;
|
|
8
|
+
declare function createErrorTaskError(error: TaskRunError): any;
|
|
9
|
+
declare const SerializedError: z.ZodObject<{
|
|
10
|
+
message: z.ZodString;
|
|
11
|
+
name: z.ZodOptional<z.ZodString>;
|
|
12
|
+
stackTrace: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
message: string;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
stackTrace?: string | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
message: string;
|
|
19
|
+
name?: string | undefined;
|
|
20
|
+
stackTrace?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
type SerializedError = z.infer<typeof SerializedError>;
|
|
23
|
+
declare function createJsonErrorObject(error: TaskRunError): SerializedError;
|
|
24
|
+
declare function sanitizeError(error: TaskRunError): TaskRunError;
|
|
25
|
+
declare function correctErrorStackTrace(stackTrace: string, projectDir?: string, options?: {
|
|
26
|
+
removeFirstLine?: boolean;
|
|
27
|
+
isDev?: boolean;
|
|
28
|
+
}): string;
|
|
29
|
+
declare function groupTaskMetadataIssuesByTask(tasks: any, issues: z.ZodIssue[]): Record<number, {
|
|
30
|
+
id: any;
|
|
31
|
+
exportName: string;
|
|
32
|
+
filePath: string;
|
|
33
|
+
issues: Array<{
|
|
34
|
+
message: string;
|
|
35
|
+
path?: string;
|
|
36
|
+
}>;
|
|
37
|
+
}>;
|
|
38
|
+
|
|
39
|
+
export { AbortTaskRunError, SerializedError, correctErrorStackTrace, createErrorTaskError, createJsonErrorObject, groupTaskMetadataIssuesByTask, parseError, sanitizeError };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { b as TaskRunError } from '../common-CLW82lkt.js';
|
|
3
|
+
|
|
4
|
+
declare class AbortTaskRunError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
declare function parseError(error: unknown): TaskRunError;
|
|
8
|
+
declare function createErrorTaskError(error: TaskRunError): any;
|
|
9
|
+
declare const SerializedError: z.ZodObject<{
|
|
10
|
+
message: z.ZodString;
|
|
11
|
+
name: z.ZodOptional<z.ZodString>;
|
|
12
|
+
stackTrace: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
message: string;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
stackTrace?: string | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
message: string;
|
|
19
|
+
name?: string | undefined;
|
|
20
|
+
stackTrace?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
type SerializedError = z.infer<typeof SerializedError>;
|
|
23
|
+
declare function createJsonErrorObject(error: TaskRunError): SerializedError;
|
|
24
|
+
declare function sanitizeError(error: TaskRunError): TaskRunError;
|
|
25
|
+
declare function correctErrorStackTrace(stackTrace: string, projectDir?: string, options?: {
|
|
26
|
+
removeFirstLine?: boolean;
|
|
27
|
+
isDev?: boolean;
|
|
28
|
+
}): string;
|
|
29
|
+
declare function groupTaskMetadataIssuesByTask(tasks: any, issues: z.ZodIssue[]): Record<number, {
|
|
30
|
+
id: any;
|
|
31
|
+
exportName: string;
|
|
32
|
+
filePath: string;
|
|
33
|
+
issues: Array<{
|
|
34
|
+
message: string;
|
|
35
|
+
path?: string;
|
|
36
|
+
}>;
|
|
37
|
+
}>;
|
|
38
|
+
|
|
39
|
+
export { AbortTaskRunError, SerializedError, correctErrorStackTrace, createErrorTaskError, createJsonErrorObject, groupTaskMetadataIssuesByTask, parseError, sanitizeError };
|