@trigger.dev/core 0.0.0-v3-decorators-20240424152300 → 0.0.0-v3-prerelease-20240425102616
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/{catalog-huF1UvYY.d.ts → catalog-KJXg8k3W.d.ts} +21 -4
- package/dist/{catalog-04wPlpvu.d.mts → catalog-PA64uhhi.d.mts} +21 -4
- package/dist/v3/index.d.mts +2 -2
- package/dist/v3/index.d.ts +2 -2
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs.map +1 -1
- package/dist/v3/workers/index.d.mts +2 -2
- package/dist/v3/workers/index.d.ts +2 -2
- package/dist/v3/workers/index.js +99 -15
- package/dist/v3/workers/index.js.map +1 -1
- package/dist/v3/workers/index.mjs +99 -15
- package/dist/v3/workers/index.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -4,8 +4,8 @@ export { TracingDiagnosticLogLevel, recordSpanException } from '../otel/index.mj
|
|
|
4
4
|
import { p as TaskRunExecution, T as TaskRunExecutionResult } from '../../manager-M9GLDnhJ.mjs';
|
|
5
5
|
export { R as RuntimeManager } from '../../manager-M9GLDnhJ.mjs';
|
|
6
6
|
import { B as BackgroundWorkerProperties, T as TaskFileMetadata, a as TaskMetadataWithFilePath } from '../../messages-AriaDDm0.mjs';
|
|
7
|
-
import { d as TriggerTracer, g as Config,
|
|
8
|
-
export { O as OtelTaskLogger,
|
|
7
|
+
import { d as TriggerTracer, g as Config, z as ProjectConfig, x as HandleErrorFunction, c as TaskMetadataWithFunctions, C as Clock, a as ClockTime, b as TaskCatalog } from '../../catalog-PA64uhhi.mjs';
|
|
8
|
+
export { O as OtelTaskLogger, A as logLevels } from '../../catalog-PA64uhhi.mjs';
|
|
9
9
|
import { PreciseDate } from '@google-cloud/precise-date';
|
|
10
10
|
import { LogRecordProcessor, LogRecord } from '@opentelemetry/sdk-logs';
|
|
11
11
|
import { SpanProcessor, Span } from '@opentelemetry/sdk-trace-base';
|
|
@@ -4,8 +4,8 @@ export { TracingDiagnosticLogLevel, recordSpanException } from '../otel/index.js
|
|
|
4
4
|
import { p as TaskRunExecution, T as TaskRunExecutionResult } from '../../manager-M9GLDnhJ.js';
|
|
5
5
|
export { R as RuntimeManager } from '../../manager-M9GLDnhJ.js';
|
|
6
6
|
import { B as BackgroundWorkerProperties, T as TaskFileMetadata, a as TaskMetadataWithFilePath } from '../../messages-AriaDDm0.js';
|
|
7
|
-
import { d as TriggerTracer, g as Config,
|
|
8
|
-
export { O as OtelTaskLogger,
|
|
7
|
+
import { d as TriggerTracer, g as Config, z as ProjectConfig, x as HandleErrorFunction, c as TaskMetadataWithFunctions, C as Clock, a as ClockTime, b as TaskCatalog } from '../../catalog-KJXg8k3W.js';
|
|
8
|
+
export { O as OtelTaskLogger, A as logLevels } from '../../catalog-KJXg8k3W.js';
|
|
9
9
|
import { PreciseDate } from '@google-cloud/precise-date';
|
|
10
10
|
import { LogRecordProcessor, LogRecord } from '@opentelemetry/sdk-logs';
|
|
11
11
|
import { SpanProcessor, Span } from '@opentelemetry/sdk-trace-base';
|
package/dist/v3/workers/index.js
CHANGED
|
@@ -1975,12 +1975,18 @@ function accessoryAttributes(accessory) {
|
|
|
1975
1975
|
__name(accessoryAttributes, "accessoryAttributes");
|
|
1976
1976
|
|
|
1977
1977
|
// src/v3/workers/taskExecutor.ts
|
|
1978
|
-
var _callRun, callRun_fn,
|
|
1978
|
+
var _callRun, callRun_fn, _callInitFunctions, callInitFunctions_fn, _callConfigInit, callConfigInit_fn, _callOnSuccessFunctions, callOnSuccessFunctions_fn, _callOnSuccessFunction, callOnSuccessFunction_fn, _callOnFailureFunctions, callOnFailureFunctions_fn, _callOnFailureFunction, callOnFailureFunction_fn, _callOnStartFunctions, callOnStartFunctions_fn, _callOnStartFunction, callOnStartFunction_fn, _callTaskCleanup, callTaskCleanup_fn, _handleError, handleError_fn;
|
|
1979
1979
|
var _TaskExecutor = class _TaskExecutor {
|
|
1980
1980
|
constructor(task, options) {
|
|
1981
1981
|
__privateAdd(this, _callRun);
|
|
1982
|
-
__privateAdd(this,
|
|
1982
|
+
__privateAdd(this, _callInitFunctions);
|
|
1983
1983
|
__privateAdd(this, _callConfigInit);
|
|
1984
|
+
__privateAdd(this, _callOnSuccessFunctions);
|
|
1985
|
+
__privateAdd(this, _callOnSuccessFunction);
|
|
1986
|
+
__privateAdd(this, _callOnFailureFunctions);
|
|
1987
|
+
__privateAdd(this, _callOnFailureFunction);
|
|
1988
|
+
__privateAdd(this, _callOnStartFunctions);
|
|
1989
|
+
__privateAdd(this, _callOnStartFunction);
|
|
1984
1990
|
__privateAdd(this, _callTaskCleanup);
|
|
1985
1991
|
__privateAdd(this, _handleError);
|
|
1986
1992
|
this.task = task;
|
|
@@ -2014,9 +2020,12 @@ var _TaskExecutor = class _TaskExecutor {
|
|
|
2014
2020
|
try {
|
|
2015
2021
|
const payloadPacket = await conditionallyImportPacket(originalPacket, this._tracer);
|
|
2016
2022
|
parsedPayload = await parsePacket(payloadPacket);
|
|
2017
|
-
|
|
2018
|
-
|
|
2023
|
+
if (execution.attempt.number === 1) {
|
|
2024
|
+
await __privateMethod(this, _callOnStartFunctions, callOnStartFunctions_fn).call(this, parsedPayload, ctx);
|
|
2025
|
+
}
|
|
2026
|
+
initOutput = await __privateMethod(this, _callInitFunctions, callInitFunctions_fn).call(this, parsedPayload, ctx);
|
|
2019
2027
|
const output = await __privateMethod(this, _callRun, callRun_fn).call(this, parsedPayload, ctx, initOutput);
|
|
2028
|
+
await __privateMethod(this, _callOnSuccessFunctions, callOnSuccessFunctions_fn).call(this, parsedPayload, output, ctx, initOutput);
|
|
2020
2029
|
try {
|
|
2021
2030
|
const stringifiedOutput = await stringifyIO(output);
|
|
2022
2031
|
const finalOutput = await conditionallyExportPacket(stringifiedOutput, `${execution.attempt.id}/output`, this._tracer);
|
|
@@ -2046,6 +2055,9 @@ var _TaskExecutor = class _TaskExecutor {
|
|
|
2046
2055
|
try {
|
|
2047
2056
|
const handleErrorResult = await __privateMethod(this, _handleError, handleError_fn).call(this, execution, runError, parsedPayload, ctx);
|
|
2048
2057
|
recordSpanException(span, handleErrorResult.error ?? runError);
|
|
2058
|
+
if (handleErrorResult.status !== "retry") {
|
|
2059
|
+
await __privateMethod(this, _callOnFailureFunctions, callOnFailureFunctions_fn).call(this, parsedPayload, handleErrorResult.error ?? runError, ctx, initOutput);
|
|
2060
|
+
}
|
|
2049
2061
|
return {
|
|
2050
2062
|
id: execution.run.id,
|
|
2051
2063
|
ok: false,
|
|
@@ -2109,8 +2121,9 @@ callRun_fn = /* @__PURE__ */ __name(async function(payload, ctx, init) {
|
|
|
2109
2121
|
})
|
|
2110
2122
|
});
|
|
2111
2123
|
}, "#callRun");
|
|
2112
|
-
|
|
2113
|
-
|
|
2124
|
+
_callInitFunctions = new WeakSet();
|
|
2125
|
+
callInitFunctions_fn = /* @__PURE__ */ __name(async function(payload1, ctx1) {
|
|
2126
|
+
await __privateMethod(this, _callConfigInit, callConfigInit_fn).call(this, payload1, ctx1);
|
|
2114
2127
|
const initFn = this.task.fns.init;
|
|
2115
2128
|
if (!initFn) {
|
|
2116
2129
|
return {};
|
|
@@ -2124,7 +2137,7 @@ callTaskInit_fn = /* @__PURE__ */ __name(async function(payload1, ctx1) {
|
|
|
2124
2137
|
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2125
2138
|
}
|
|
2126
2139
|
});
|
|
2127
|
-
}, "#
|
|
2140
|
+
}, "#callInitFunctions");
|
|
2128
2141
|
_callConfigInit = new WeakSet();
|
|
2129
2142
|
callConfigInit_fn = /* @__PURE__ */ __name(async function(payload2, ctx2) {
|
|
2130
2143
|
const initFn = this._importedConfig?.init;
|
|
@@ -2141,21 +2154,92 @@ callConfigInit_fn = /* @__PURE__ */ __name(async function(payload2, ctx2) {
|
|
|
2141
2154
|
}
|
|
2142
2155
|
});
|
|
2143
2156
|
}, "#callConfigInit");
|
|
2157
|
+
_callOnSuccessFunctions = new WeakSet();
|
|
2158
|
+
callOnSuccessFunctions_fn = /* @__PURE__ */ __name(async function(payload3, output, ctx3, initOutput) {
|
|
2159
|
+
await __privateMethod(this, _callOnSuccessFunction, callOnSuccessFunction_fn).call(this, this.task.fns.onSuccess, "task.onSuccess", payload3, output, ctx3, initOutput);
|
|
2160
|
+
await __privateMethod(this, _callOnSuccessFunction, callOnSuccessFunction_fn).call(this, this._importedConfig?.onSuccess, "config.onSuccess", payload3, output, ctx3, initOutput);
|
|
2161
|
+
}, "#callOnSuccessFunctions");
|
|
2162
|
+
_callOnSuccessFunction = new WeakSet();
|
|
2163
|
+
callOnSuccessFunction_fn = /* @__PURE__ */ __name(async function(onSuccessFn, name, payload4, output1, ctx4, initOutput1) {
|
|
2164
|
+
if (!onSuccessFn) {
|
|
2165
|
+
return;
|
|
2166
|
+
}
|
|
2167
|
+
try {
|
|
2168
|
+
await this._tracer.startActiveSpan(name, async (span) => {
|
|
2169
|
+
return await onSuccessFn(payload4, output1, {
|
|
2170
|
+
ctx: ctx4,
|
|
2171
|
+
init: initOutput1
|
|
2172
|
+
});
|
|
2173
|
+
}, {
|
|
2174
|
+
attributes: {
|
|
2175
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2176
|
+
}
|
|
2177
|
+
});
|
|
2178
|
+
} catch {
|
|
2179
|
+
}
|
|
2180
|
+
}, "#callOnSuccessFunction");
|
|
2181
|
+
_callOnFailureFunctions = new WeakSet();
|
|
2182
|
+
callOnFailureFunctions_fn = /* @__PURE__ */ __name(async function(payload5, error, ctx5, initOutput2) {
|
|
2183
|
+
await __privateMethod(this, _callOnFailureFunction, callOnFailureFunction_fn).call(this, this.task.fns.onFailure, "task.onFailure", payload5, error, ctx5, initOutput2);
|
|
2184
|
+
await __privateMethod(this, _callOnFailureFunction, callOnFailureFunction_fn).call(this, this._importedConfig?.onFailure, "config.onFailure", payload5, error, ctx5, initOutput2);
|
|
2185
|
+
}, "#callOnFailureFunctions");
|
|
2186
|
+
_callOnFailureFunction = new WeakSet();
|
|
2187
|
+
callOnFailureFunction_fn = /* @__PURE__ */ __name(async function(onFailureFn, name1, payload6, error1, ctx6, initOutput3) {
|
|
2188
|
+
if (!onFailureFn) {
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
try {
|
|
2192
|
+
return await this._tracer.startActiveSpan(name1, async (span) => {
|
|
2193
|
+
return await onFailureFn(payload6, error1, {
|
|
2194
|
+
ctx: ctx6,
|
|
2195
|
+
init: initOutput3
|
|
2196
|
+
});
|
|
2197
|
+
}, {
|
|
2198
|
+
attributes: {
|
|
2199
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2200
|
+
}
|
|
2201
|
+
});
|
|
2202
|
+
} catch (e) {
|
|
2203
|
+
}
|
|
2204
|
+
}, "#callOnFailureFunction");
|
|
2205
|
+
_callOnStartFunctions = new WeakSet();
|
|
2206
|
+
callOnStartFunctions_fn = /* @__PURE__ */ __name(async function(payload7, ctx7) {
|
|
2207
|
+
await __privateMethod(this, _callOnStartFunction, callOnStartFunction_fn).call(this, this._importedConfig?.onStart, "config.onStart", payload7, ctx7, {});
|
|
2208
|
+
await __privateMethod(this, _callOnStartFunction, callOnStartFunction_fn).call(this, this.task.fns.onStart, "task.onStart", payload7, ctx7, {});
|
|
2209
|
+
}, "#callOnStartFunctions");
|
|
2210
|
+
_callOnStartFunction = new WeakSet();
|
|
2211
|
+
callOnStartFunction_fn = /* @__PURE__ */ __name(async function(onStartFn, name2, payload8, ctx8, initOutput4) {
|
|
2212
|
+
if (!onStartFn) {
|
|
2213
|
+
return;
|
|
2214
|
+
}
|
|
2215
|
+
try {
|
|
2216
|
+
await this._tracer.startActiveSpan(name2, async (span) => {
|
|
2217
|
+
return await onStartFn(payload8, {
|
|
2218
|
+
ctx: ctx8
|
|
2219
|
+
});
|
|
2220
|
+
}, {
|
|
2221
|
+
attributes: {
|
|
2222
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2223
|
+
}
|
|
2224
|
+
});
|
|
2225
|
+
} catch {
|
|
2226
|
+
}
|
|
2227
|
+
}, "#callOnStartFunction");
|
|
2144
2228
|
_callTaskCleanup = new WeakSet();
|
|
2145
|
-
callTaskCleanup_fn = /* @__PURE__ */ __name(async function(
|
|
2229
|
+
callTaskCleanup_fn = /* @__PURE__ */ __name(async function(payload9, ctx9, init1) {
|
|
2146
2230
|
const cleanupFn = this.task.fns.cleanup;
|
|
2147
2231
|
if (!cleanupFn) {
|
|
2148
2232
|
return;
|
|
2149
2233
|
}
|
|
2150
2234
|
return this._tracer.startActiveSpan("cleanup", async (span) => {
|
|
2151
|
-
return await cleanupFn(
|
|
2152
|
-
ctx:
|
|
2235
|
+
return await cleanupFn(payload9, {
|
|
2236
|
+
ctx: ctx9,
|
|
2153
2237
|
init: init1
|
|
2154
2238
|
});
|
|
2155
2239
|
});
|
|
2156
2240
|
}, "#callTaskCleanup");
|
|
2157
2241
|
_handleError = new WeakSet();
|
|
2158
|
-
handleError_fn = /* @__PURE__ */ __name(async function(execution,
|
|
2242
|
+
handleError_fn = /* @__PURE__ */ __name(async function(execution, error2, payload10, ctx10) {
|
|
2159
2243
|
const retriesConfig = this._importedConfig?.retries ?? this._config.retries;
|
|
2160
2244
|
const retry = this.task.retry ?? retriesConfig?.default;
|
|
2161
2245
|
if (!retry) {
|
|
@@ -2170,13 +2254,13 @@ handleError_fn = /* @__PURE__ */ __name(async function(execution, error, payload
|
|
|
2170
2254
|
};
|
|
2171
2255
|
}
|
|
2172
2256
|
return this._tracer.startActiveSpan("handleError()", async (span) => {
|
|
2173
|
-
const handleErrorResult = this.task.fns.handleError ? await this.task.fns.handleError(
|
|
2174
|
-
ctx:
|
|
2257
|
+
const handleErrorResult = this.task.fns.handleError ? await this.task.fns.handleError(payload10, error2, {
|
|
2258
|
+
ctx: ctx10,
|
|
2175
2259
|
retry,
|
|
2176
2260
|
retryDelayInMs: delay,
|
|
2177
2261
|
retryAt: delay ? new Date(Date.now() + delay) : void 0
|
|
2178
|
-
}) : this._importedConfig ? await this._handleErrorFn?.(
|
|
2179
|
-
ctx:
|
|
2262
|
+
}) : this._importedConfig ? await this._handleErrorFn?.(payload10, error2, {
|
|
2263
|
+
ctx: ctx10,
|
|
2180
2264
|
retry,
|
|
2181
2265
|
retryDelayInMs: delay,
|
|
2182
2266
|
retryAt: delay ? new Date(Date.now() + delay) : void 0
|