@trigger.dev/core 3.0.0-beta.37 → 3.0.0-beta.39
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-XTlJQaMn.d.mts → catalog-EP9DGAGm.d.ts} +43 -3
- package/dist/{catalog-dRKTgwQ7.d.ts → catalog-Gjy5NtAB.d.mts} +43 -3
- package/dist/{manager-JkbddlcO.d.mts → manager-S98VaLUy.d.mts} +244 -1
- package/dist/{manager-JkbddlcO.d.ts → manager-S98VaLUy.d.ts} +244 -1
- package/dist/{messages-9lty-Du5.d.mts → messages--WkQvA2l.d.mts} +2370 -141
- package/dist/{messages-9lty-Du5.d.ts → messages--WkQvA2l.d.ts} +2370 -141
- package/dist/{schemas-r4ZP9S-F.d.mts → schemas-Sb0sJcEt.d.mts} +199 -33
- package/dist/{schemas-r4ZP9S-F.d.ts → schemas-Sb0sJcEt.d.ts} +199 -33
- package/dist/v3/dev/index.d.mts +1 -1
- package/dist/v3/dev/index.d.ts +1 -1
- package/dist/v3/index.d.mts +129 -55
- package/dist/v3/index.d.ts +129 -55
- package/dist/v3/index.js +208 -57
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +203 -57
- package/dist/v3/index.mjs.map +1 -1
- package/dist/v3/otel/index.js +15 -5
- package/dist/v3/otel/index.js.map +1 -1
- package/dist/v3/otel/index.mjs +15 -5
- package/dist/v3/otel/index.mjs.map +1 -1
- package/dist/v3/prod/index.d.mts +2 -2
- package/dist/v3/prod/index.d.ts +2 -2
- package/dist/v3/prod/index.js.map +1 -1
- package/dist/v3/prod/index.mjs.map +1 -1
- package/dist/v3/workers/index.d.mts +54 -8
- package/dist/v3/workers/index.d.ts +54 -8
- package/dist/v3/workers/index.js +408 -42
- package/dist/v3/workers/index.js.map +1 -1
- package/dist/v3/workers/index.mjs +406 -43
- package/dist/v3/workers/index.mjs.map +1 -1
- package/dist/v3/zodIpc.js.map +1 -1
- package/dist/v3/zodIpc.mjs.map +1 -1
- package/dist/v3/zodfetch.d.mts +1 -1
- package/dist/v3/zodfetch.d.ts +1 -1
- package/package.json +1 -1
package/dist/v3/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
// package.json
|
|
38
|
-
var version = "3.0.0-beta.
|
|
38
|
+
var version = "3.0.0-beta.39";
|
|
39
39
|
var dependencies = {
|
|
40
40
|
"@google-cloud/precise-date": "^4.0.0",
|
|
41
41
|
"@opentelemetry/api": "^1.8.0",
|
|
@@ -71,6 +71,41 @@ var GetPersonalAccessTokenResponseSchema = zod.z.object({
|
|
|
71
71
|
obfuscatedToken: zod.z.string()
|
|
72
72
|
}).nullable()
|
|
73
73
|
});
|
|
74
|
+
var MachineCpu = zod.z.union([
|
|
75
|
+
zod.z.literal(0.25),
|
|
76
|
+
zod.z.literal(0.5),
|
|
77
|
+
zod.z.literal(1),
|
|
78
|
+
zod.z.literal(2),
|
|
79
|
+
zod.z.literal(4)
|
|
80
|
+
]);
|
|
81
|
+
var MachineMemory = zod.z.union([
|
|
82
|
+
zod.z.literal(0.25),
|
|
83
|
+
zod.z.literal(0.5),
|
|
84
|
+
zod.z.literal(1),
|
|
85
|
+
zod.z.literal(2),
|
|
86
|
+
zod.z.literal(4),
|
|
87
|
+
zod.z.literal(8)
|
|
88
|
+
]);
|
|
89
|
+
var MachinePresetName = zod.z.enum([
|
|
90
|
+
"micro",
|
|
91
|
+
"small-1x",
|
|
92
|
+
"small-2x",
|
|
93
|
+
"medium-1x",
|
|
94
|
+
"medium-2x",
|
|
95
|
+
"large-1x",
|
|
96
|
+
"large-2x"
|
|
97
|
+
]);
|
|
98
|
+
var MachineConfig = zod.z.object({
|
|
99
|
+
cpu: MachineCpu.optional(),
|
|
100
|
+
memory: MachineMemory.optional(),
|
|
101
|
+
preset: MachinePresetName.optional()
|
|
102
|
+
});
|
|
103
|
+
var MachinePreset = zod.z.object({
|
|
104
|
+
name: MachinePresetName,
|
|
105
|
+
cpu: zod.z.number(),
|
|
106
|
+
memory: zod.z.number(),
|
|
107
|
+
centsPerMs: zod.z.number()
|
|
108
|
+
});
|
|
74
109
|
var TaskRunBuiltInError = zod.z.object({
|
|
75
110
|
type: zod.z.literal("BUILT_IN_ERROR"),
|
|
76
111
|
name: zod.z.string(),
|
|
@@ -132,7 +167,11 @@ var TaskRun = zod.z.object({
|
|
|
132
167
|
tags: zod.z.array(zod.z.string()),
|
|
133
168
|
isTest: zod.z.boolean().default(false),
|
|
134
169
|
createdAt: zod.z.coerce.date(),
|
|
135
|
-
|
|
170
|
+
startedAt: zod.z.coerce.date().default(() => /* @__PURE__ */ new Date()),
|
|
171
|
+
idempotencyKey: zod.z.string().optional(),
|
|
172
|
+
durationMs: zod.z.number().default(0),
|
|
173
|
+
costInCents: zod.z.number().default(0),
|
|
174
|
+
baseCostInCents: zod.z.number().default(0)
|
|
136
175
|
});
|
|
137
176
|
var TaskRunExecutionTask = zod.z.object({
|
|
138
177
|
id: zod.z.string(),
|
|
@@ -183,7 +222,8 @@ var TaskRunExecution = zod.z.object({
|
|
|
183
222
|
environment: TaskRunExecutionEnvironment,
|
|
184
223
|
organization: TaskRunExecutionOrganization,
|
|
185
224
|
project: TaskRunExecutionProject,
|
|
186
|
-
batch: TaskRunExecutionBatch.optional()
|
|
225
|
+
batch: TaskRunExecutionBatch.optional(),
|
|
226
|
+
machine: MachinePreset.optional()
|
|
187
227
|
});
|
|
188
228
|
var TaskRunContext = zod.z.object({
|
|
189
229
|
task: TaskRunExecutionTask,
|
|
@@ -199,25 +239,31 @@ var TaskRunContext = zod.z.object({
|
|
|
199
239
|
environment: TaskRunExecutionEnvironment,
|
|
200
240
|
organization: TaskRunExecutionOrganization,
|
|
201
241
|
project: TaskRunExecutionProject,
|
|
202
|
-
batch: TaskRunExecutionBatch.optional()
|
|
242
|
+
batch: TaskRunExecutionBatch.optional(),
|
|
243
|
+
machine: MachinePreset.optional()
|
|
203
244
|
});
|
|
204
245
|
var TaskRunExecutionRetry = zod.z.object({
|
|
205
246
|
timestamp: zod.z.number(),
|
|
206
247
|
delay: zod.z.number(),
|
|
207
248
|
error: zod.z.unknown().optional()
|
|
208
249
|
});
|
|
250
|
+
var TaskRunExecutionUsage = zod.z.object({
|
|
251
|
+
durationMs: zod.z.number()
|
|
252
|
+
});
|
|
209
253
|
var TaskRunFailedExecutionResult = zod.z.object({
|
|
210
254
|
ok: zod.z.literal(false),
|
|
211
255
|
id: zod.z.string(),
|
|
212
256
|
error: TaskRunError,
|
|
213
257
|
retry: TaskRunExecutionRetry.optional(),
|
|
214
|
-
skippedRetrying: zod.z.boolean().optional()
|
|
258
|
+
skippedRetrying: zod.z.boolean().optional(),
|
|
259
|
+
usage: TaskRunExecutionUsage.optional()
|
|
215
260
|
});
|
|
216
261
|
var TaskRunSuccessfulExecutionResult = zod.z.object({
|
|
217
262
|
ok: zod.z.literal(true),
|
|
218
263
|
id: zod.z.string(),
|
|
219
264
|
output: zod.z.string().optional(),
|
|
220
|
-
outputType: zod.z.string()
|
|
265
|
+
outputType: zod.z.string(),
|
|
266
|
+
usage: TaskRunExecutionUsage.optional()
|
|
221
267
|
});
|
|
222
268
|
var TaskRunExecutionResult = zod.z.discriminatedUnion("ok", [
|
|
223
269
|
TaskRunSuccessfulExecutionResult,
|
|
@@ -235,26 +281,6 @@ var EnvironmentType = zod.z.enum([
|
|
|
235
281
|
"DEVELOPMENT",
|
|
236
282
|
"PREVIEW"
|
|
237
283
|
]);
|
|
238
|
-
var MachineCpu = zod.z.union([
|
|
239
|
-
zod.z.literal(0.25),
|
|
240
|
-
zod.z.literal(0.5),
|
|
241
|
-
zod.z.literal(1),
|
|
242
|
-
zod.z.literal(2),
|
|
243
|
-
zod.z.literal(4)
|
|
244
|
-
]).default(0.5);
|
|
245
|
-
var MachineMemory = zod.z.union([
|
|
246
|
-
zod.z.literal(0.25),
|
|
247
|
-
zod.z.literal(0.5),
|
|
248
|
-
zod.z.literal(1),
|
|
249
|
-
zod.z.literal(2),
|
|
250
|
-
zod.z.literal(4),
|
|
251
|
-
zod.z.literal(8)
|
|
252
|
-
]).default(1);
|
|
253
|
-
var Machine = zod.z.object({
|
|
254
|
-
version: zod.z.literal("v1").default("v1"),
|
|
255
|
-
cpu: MachineCpu,
|
|
256
|
-
memory: MachineMemory
|
|
257
|
-
});
|
|
258
284
|
var TaskRunExecutionPayload = zod.z.object({
|
|
259
285
|
execution: TaskRunExecution,
|
|
260
286
|
traceContext: zod.z.record(zod.z.unknown()),
|
|
@@ -265,6 +291,12 @@ var ProdTaskRunExecution = TaskRunExecution.extend({
|
|
|
265
291
|
id: zod.z.string(),
|
|
266
292
|
contentHash: zod.z.string(),
|
|
267
293
|
version: zod.z.string()
|
|
294
|
+
}),
|
|
295
|
+
machine: MachinePreset.default({
|
|
296
|
+
name: "small-1x",
|
|
297
|
+
cpu: 1,
|
|
298
|
+
memory: 1,
|
|
299
|
+
centsPerMs: 0
|
|
268
300
|
})
|
|
269
301
|
});
|
|
270
302
|
var ProdTaskRunExecutionPayload = zod.z.object({
|
|
@@ -369,7 +401,7 @@ var TaskMetadata = zod.z.object({
|
|
|
369
401
|
packageVersion: zod.z.string(),
|
|
370
402
|
queue: QueueOptions.optional(),
|
|
371
403
|
retry: RetryOptions.optional(),
|
|
372
|
-
machine:
|
|
404
|
+
machine: MachineConfig.optional(),
|
|
373
405
|
triggerSource: zod.z.string().optional()
|
|
374
406
|
});
|
|
375
407
|
var TaskFileMetadata = zod.z.object({
|
|
@@ -381,7 +413,7 @@ var TaskMetadataWithFilePath = zod.z.object({
|
|
|
381
413
|
packageVersion: zod.z.string(),
|
|
382
414
|
queue: QueueOptions.optional(),
|
|
383
415
|
retry: RetryOptions.optional(),
|
|
384
|
-
machine:
|
|
416
|
+
machine: MachineConfig.optional(),
|
|
385
417
|
triggerSource: zod.z.string().optional(),
|
|
386
418
|
filePath: zod.z.string(),
|
|
387
419
|
exportName: zod.z.string()
|
|
@@ -441,7 +473,7 @@ var TaskResource = zod.z.object({
|
|
|
441
473
|
exportName: zod.z.string(),
|
|
442
474
|
queue: QueueOptions.optional(),
|
|
443
475
|
retry: RetryOptions.optional(),
|
|
444
|
-
machine:
|
|
476
|
+
machine: MachineConfig.optional(),
|
|
445
477
|
triggerSource: zod.z.string().optional()
|
|
446
478
|
});
|
|
447
479
|
var BackgroundWorkerMetadata = zod.z.object({
|
|
@@ -750,15 +782,26 @@ var ScheduledTaskPayload = zod.z.object({
|
|
|
750
782
|
You can use this to remove the schedule, update it, etc */
|
|
751
783
|
scheduleId: zod.z.string(),
|
|
752
784
|
/** When the task was scheduled to run.
|
|
753
|
-
* Note this will be slightly different from `new Date()` because it takes a few ms to run the task.
|
|
785
|
+
* Note this will be slightly different from `new Date()` because it takes a few ms to run the task.
|
|
786
|
+
*
|
|
787
|
+
* This date is UTC. To output it as a string with a timezone you would do this:
|
|
788
|
+
* ```ts
|
|
789
|
+
* const formatted = payload.timestamp.toLocaleString("en-US", {
|
|
790
|
+
timeZone: payload.timezone,
|
|
791
|
+
});
|
|
792
|
+
``` */
|
|
754
793
|
timestamp: zod.z.date(),
|
|
755
794
|
/** When the task was last run (it has been).
|
|
756
|
-
This can be undefined if it's never been run */
|
|
795
|
+
This can be undefined if it's never been run. This date is UTC. */
|
|
757
796
|
lastTimestamp: zod.z.date().optional(),
|
|
758
797
|
/** You can optionally provide an external id when creating the schedule.
|
|
759
798
|
Usually you would use a userId or some other unique identifier.
|
|
760
799
|
This defaults to undefined if you didn't provide one. */
|
|
761
800
|
externalId: zod.z.string().optional(),
|
|
801
|
+
/** The IANA timezone the schedule is set to. The default is UTC.
|
|
802
|
+
* You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
|
|
803
|
+
*/
|
|
804
|
+
timezone: zod.z.string(),
|
|
762
805
|
/** The next 5 dates this task is scheduled to run */
|
|
763
806
|
upcoming: zod.z.array(zod.z.date())
|
|
764
807
|
});
|
|
@@ -782,17 +825,30 @@ var CreateScheduleOptions = zod.z.object({
|
|
|
782
825
|
|
|
783
826
|
*/
|
|
784
827
|
cron: zod.z.string(),
|
|
785
|
-
/**
|
|
828
|
+
/** You can only create one schedule with this key. If you use it twice, the second call will update the schedule.
|
|
786
829
|
*
|
|
787
|
-
* This is
|
|
788
|
-
deduplicationKey: zod.z.string()
|
|
830
|
+
* This is required to prevent you from creating duplicate schedules. */
|
|
831
|
+
deduplicationKey: zod.z.string(),
|
|
789
832
|
/** Optionally, you can specify your own IDs (like a user ID) and then use it inside the run function of your task.
|
|
790
833
|
*
|
|
791
834
|
* This allows you to have per-user CRON tasks.
|
|
792
835
|
*/
|
|
793
|
-
externalId: zod.z.string().optional()
|
|
836
|
+
externalId: zod.z.string().optional(),
|
|
837
|
+
/** Optionally, you can specify a timezone in the IANA format. If unset it will use UTC.
|
|
838
|
+
* If specified then the CRON will be evaluated in that timezone and will respect daylight savings.
|
|
839
|
+
*
|
|
840
|
+
* If you set the CRON to `0 0 * * *` and the timezone to `America/New_York` then the task will run at midnight in New York time, no matter whether it's daylight savings or not.
|
|
841
|
+
*
|
|
842
|
+
* You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
|
|
843
|
+
*
|
|
844
|
+
* @example "America/New_York", "Europe/London", "Asia/Tokyo", "Africa/Cairo"
|
|
845
|
+
*
|
|
846
|
+
*/
|
|
847
|
+
timezone: zod.z.string().optional()
|
|
848
|
+
});
|
|
849
|
+
var UpdateScheduleOptions = CreateScheduleOptions.omit({
|
|
850
|
+
deduplicationKey: true
|
|
794
851
|
});
|
|
795
|
-
var UpdateScheduleOptions = CreateScheduleOptions;
|
|
796
852
|
var ScheduleGenerator = zod.z.object({
|
|
797
853
|
type: zod.z.literal("CRON"),
|
|
798
854
|
expression: zod.z.string(),
|
|
@@ -805,6 +861,7 @@ var ScheduleObject = zod.z.object({
|
|
|
805
861
|
deduplicationKey: zod.z.string().nullish(),
|
|
806
862
|
externalId: zod.z.string().nullish(),
|
|
807
863
|
generator: ScheduleGenerator,
|
|
864
|
+
timezone: zod.z.string(),
|
|
808
865
|
nextRun: zod.z.coerce.date().nullish(),
|
|
809
866
|
environments: zod.z.array(zod.z.object({
|
|
810
867
|
id: zod.z.string(),
|
|
@@ -827,6 +884,9 @@ var ListScheduleOptions = zod.z.object({
|
|
|
827
884
|
page: zod.z.number().optional(),
|
|
828
885
|
perPage: zod.z.number().optional()
|
|
829
886
|
});
|
|
887
|
+
var TimezonesResult = zod.z.object({
|
|
888
|
+
timezones: zod.z.array(zod.z.string())
|
|
889
|
+
});
|
|
830
890
|
var RunStatus = zod.z.enum([
|
|
831
891
|
/// Task hasn't been deployed yet but is waiting to be executed
|
|
832
892
|
"WAITING_FOR_DEPLOY",
|
|
@@ -950,7 +1010,7 @@ var BackgroundWorkerServerMessages = zod.z.discriminatedUnion("type", [
|
|
|
950
1010
|
type: zod.z.literal("SCHEDULE_ATTEMPT"),
|
|
951
1011
|
image: zod.z.string(),
|
|
952
1012
|
version: zod.z.string(),
|
|
953
|
-
machine:
|
|
1013
|
+
machine: MachinePreset,
|
|
954
1014
|
// identifiers
|
|
955
1015
|
id: zod.z.string().optional(),
|
|
956
1016
|
envId: zod.z.string(),
|
|
@@ -1295,7 +1355,7 @@ var PlatformToProviderMessages = {
|
|
|
1295
1355
|
location: zod.z.string(),
|
|
1296
1356
|
reason: zod.z.string().optional(),
|
|
1297
1357
|
imageRef: zod.z.string(),
|
|
1298
|
-
machine:
|
|
1358
|
+
machine: MachinePreset,
|
|
1299
1359
|
// identifiers
|
|
1300
1360
|
checkpointId: zod.z.string(),
|
|
1301
1361
|
envId: zod.z.string(),
|
|
@@ -2045,6 +2105,10 @@ var SemanticInternalAttributes = {
|
|
|
2045
2105
|
TASK_EXPORT_NAME: "ctx.task.exportName",
|
|
2046
2106
|
QUEUE_NAME: "ctx.queue.name",
|
|
2047
2107
|
QUEUE_ID: "ctx.queue.id",
|
|
2108
|
+
MACHINE_PRESET_NAME: "ctx.machine.name",
|
|
2109
|
+
MACHINE_PRESET_CPU: "ctx.machine.cpu",
|
|
2110
|
+
MACHINE_PRESET_MEMORY: "ctx.machine.memory",
|
|
2111
|
+
MACHINE_PRESET_CENTS_PER_MS: "ctx.machine.centsPerMs",
|
|
2048
2112
|
SPAN_PARTIAL: "$span.partial",
|
|
2049
2113
|
SPAN_ID: "$span.span_id",
|
|
2050
2114
|
OUTPUT: "$output",
|
|
@@ -2068,7 +2132,9 @@ var SemanticInternalAttributes = {
|
|
|
2068
2132
|
RETRY_DELAY: "retry.delay",
|
|
2069
2133
|
RETRY_COUNT: "retry.count",
|
|
2070
2134
|
LINK_TITLE: "$link.title",
|
|
2071
|
-
IDEMPOTENCY_KEY: "ctx.run.idempotencyKey"
|
|
2135
|
+
IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
|
|
2136
|
+
USAGE_DURATION_MS: "$usage.durationMs",
|
|
2137
|
+
USAGE_COST_IN_CENTS: "$usage.costInCents"
|
|
2072
2138
|
};
|
|
2073
2139
|
|
|
2074
2140
|
// src/v3/taskContext/index.ts
|
|
@@ -2132,7 +2198,11 @@ var _TaskContextAPI = class _TaskContextAPI {
|
|
|
2132
2198
|
[SemanticInternalAttributes.ORGANIZATION_SLUG]: this.ctx.organization.slug,
|
|
2133
2199
|
[SemanticInternalAttributes.ORGANIZATION_NAME]: this.ctx.organization.name,
|
|
2134
2200
|
[SemanticInternalAttributes.BATCH_ID]: this.ctx.batch?.id,
|
|
2135
|
-
[SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey
|
|
2201
|
+
[SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey,
|
|
2202
|
+
[SemanticInternalAttributes.MACHINE_PRESET_NAME]: this.ctx.machine?.name,
|
|
2203
|
+
[SemanticInternalAttributes.MACHINE_PRESET_CPU]: this.ctx.machine?.cpu,
|
|
2204
|
+
[SemanticInternalAttributes.MACHINE_PRESET_MEMORY]: this.ctx.machine?.memory,
|
|
2205
|
+
[SemanticInternalAttributes.MACHINE_PRESET_CENTS_PER_MS]: this.ctx.machine?.centsPerMs
|
|
2136
2206
|
};
|
|
2137
2207
|
}
|
|
2138
2208
|
return {};
|
|
@@ -3500,8 +3570,77 @@ var _NoopRuntimeManager = class _NoopRuntimeManager {
|
|
|
3500
3570
|
__name(_NoopRuntimeManager, "NoopRuntimeManager");
|
|
3501
3571
|
var NoopRuntimeManager = _NoopRuntimeManager;
|
|
3502
3572
|
|
|
3573
|
+
// src/v3/usage/noopUsageManager.ts
|
|
3574
|
+
var _NoopUsageManager = class _NoopUsageManager {
|
|
3575
|
+
disable() {
|
|
3576
|
+
}
|
|
3577
|
+
start() {
|
|
3578
|
+
return {
|
|
3579
|
+
sample: () => ({
|
|
3580
|
+
cpuTime: 0,
|
|
3581
|
+
wallTime: 0
|
|
3582
|
+
})
|
|
3583
|
+
};
|
|
3584
|
+
}
|
|
3585
|
+
stop(measurement) {
|
|
3586
|
+
return measurement.sample();
|
|
3587
|
+
}
|
|
3588
|
+
pauseAsync(cb) {
|
|
3589
|
+
return cb();
|
|
3590
|
+
}
|
|
3591
|
+
sample() {
|
|
3592
|
+
return void 0;
|
|
3593
|
+
}
|
|
3594
|
+
};
|
|
3595
|
+
__name(_NoopUsageManager, "NoopUsageManager");
|
|
3596
|
+
var NoopUsageManager = _NoopUsageManager;
|
|
3597
|
+
|
|
3598
|
+
// src/v3/usage/api.ts
|
|
3599
|
+
var API_NAME4 = "usage";
|
|
3600
|
+
var NOOP_USAGE_MANAGER = new NoopUsageManager();
|
|
3601
|
+
var _getUsageManager, getUsageManager_fn;
|
|
3602
|
+
var _UsageAPI = class _UsageAPI {
|
|
3603
|
+
constructor() {
|
|
3604
|
+
__privateAdd(this, _getUsageManager);
|
|
3605
|
+
}
|
|
3606
|
+
static getInstance() {
|
|
3607
|
+
if (!this._instance) {
|
|
3608
|
+
this._instance = new _UsageAPI();
|
|
3609
|
+
}
|
|
3610
|
+
return this._instance;
|
|
3611
|
+
}
|
|
3612
|
+
setGlobalUsageManager(manager) {
|
|
3613
|
+
return registerGlobal(API_NAME4, manager);
|
|
3614
|
+
}
|
|
3615
|
+
disable() {
|
|
3616
|
+
__privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).disable();
|
|
3617
|
+
unregisterGlobal(API_NAME4);
|
|
3618
|
+
}
|
|
3619
|
+
start() {
|
|
3620
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).start();
|
|
3621
|
+
}
|
|
3622
|
+
stop(measurement) {
|
|
3623
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).stop(measurement);
|
|
3624
|
+
}
|
|
3625
|
+
pauseAsync(cb) {
|
|
3626
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).pauseAsync(cb);
|
|
3627
|
+
}
|
|
3628
|
+
sample() {
|
|
3629
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).sample();
|
|
3630
|
+
}
|
|
3631
|
+
};
|
|
3632
|
+
_getUsageManager = new WeakSet();
|
|
3633
|
+
getUsageManager_fn = /* @__PURE__ */ __name(function() {
|
|
3634
|
+
return getGlobal(API_NAME4) ?? NOOP_USAGE_MANAGER;
|
|
3635
|
+
}, "#getUsageManager");
|
|
3636
|
+
__name(_UsageAPI, "UsageAPI");
|
|
3637
|
+
var UsageAPI = _UsageAPI;
|
|
3638
|
+
|
|
3639
|
+
// src/v3/usage-api.ts
|
|
3640
|
+
var usage = UsageAPI.getInstance();
|
|
3641
|
+
|
|
3503
3642
|
// src/v3/runtime/index.ts
|
|
3504
|
-
var
|
|
3643
|
+
var API_NAME5 = "runtime";
|
|
3505
3644
|
var NOOP_RUNTIME_MANAGER = new NoopRuntimeManager();
|
|
3506
3645
|
var _getRuntimeManager, getRuntimeManager_fn;
|
|
3507
3646
|
var _RuntimeAPI = class _RuntimeAPI {
|
|
@@ -3515,28 +3654,28 @@ var _RuntimeAPI = class _RuntimeAPI {
|
|
|
3515
3654
|
return this._instance;
|
|
3516
3655
|
}
|
|
3517
3656
|
waitForDuration(ms) {
|
|
3518
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms);
|
|
3657
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms));
|
|
3519
3658
|
}
|
|
3520
3659
|
waitUntil(date) {
|
|
3521
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date);
|
|
3660
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date));
|
|
3522
3661
|
}
|
|
3523
3662
|
waitForTask(params) {
|
|
3524
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params);
|
|
3663
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params));
|
|
3525
3664
|
}
|
|
3526
3665
|
waitForBatch(params) {
|
|
3527
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params);
|
|
3666
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params));
|
|
3528
3667
|
}
|
|
3529
3668
|
setGlobalRuntimeManager(runtimeManager) {
|
|
3530
|
-
return registerGlobal(
|
|
3669
|
+
return registerGlobal(API_NAME5, runtimeManager);
|
|
3531
3670
|
}
|
|
3532
3671
|
disable() {
|
|
3533
3672
|
__privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).disable();
|
|
3534
|
-
unregisterGlobal(
|
|
3673
|
+
unregisterGlobal(API_NAME5);
|
|
3535
3674
|
}
|
|
3536
3675
|
};
|
|
3537
3676
|
_getRuntimeManager = new WeakSet();
|
|
3538
3677
|
getRuntimeManager_fn = /* @__PURE__ */ __name(function() {
|
|
3539
|
-
return getGlobal(
|
|
3678
|
+
return getGlobal(API_NAME5) ?? NOOP_RUNTIME_MANAGER;
|
|
3540
3679
|
}, "#getRuntimeManager");
|
|
3541
3680
|
__name(_RuntimeAPI, "RuntimeAPI");
|
|
3542
3681
|
var RuntimeAPI = _RuntimeAPI;
|
|
@@ -3553,7 +3692,7 @@ function getEnvVar(name) {
|
|
|
3553
3692
|
__name(getEnvVar, "getEnvVar");
|
|
3554
3693
|
|
|
3555
3694
|
// src/v3/apiClientManager/index.ts
|
|
3556
|
-
var
|
|
3695
|
+
var API_NAME6 = "api-client";
|
|
3557
3696
|
var _getConfig, getConfig_fn;
|
|
3558
3697
|
var _APIClientManagerAPI = class _APIClientManagerAPI {
|
|
3559
3698
|
constructor() {
|
|
@@ -3566,10 +3705,10 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
|
|
|
3566
3705
|
return this._instance;
|
|
3567
3706
|
}
|
|
3568
3707
|
disable() {
|
|
3569
|
-
unregisterGlobal(
|
|
3708
|
+
unregisterGlobal(API_NAME6);
|
|
3570
3709
|
}
|
|
3571
3710
|
setGlobalAPIClientConfiguration(config) {
|
|
3572
|
-
return registerGlobal(
|
|
3711
|
+
return registerGlobal(API_NAME6, config);
|
|
3573
3712
|
}
|
|
3574
3713
|
get baseURL() {
|
|
3575
3714
|
const store = __privateMethod(this, _getConfig, getConfig_fn).call(this);
|
|
@@ -3588,7 +3727,7 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
|
|
|
3588
3727
|
};
|
|
3589
3728
|
_getConfig = new WeakSet();
|
|
3590
3729
|
getConfig_fn = /* @__PURE__ */ __name(function() {
|
|
3591
|
-
return getGlobal(
|
|
3730
|
+
return getGlobal(API_NAME6);
|
|
3592
3731
|
}, "#getConfig");
|
|
3593
3732
|
__name(_APIClientManagerAPI, "APIClientManagerAPI");
|
|
3594
3733
|
var APIClientManagerAPI = _APIClientManagerAPI;
|
|
@@ -3623,7 +3762,7 @@ __name(_NoopTaskCatalog, "NoopTaskCatalog");
|
|
|
3623
3762
|
var NoopTaskCatalog = _NoopTaskCatalog;
|
|
3624
3763
|
|
|
3625
3764
|
// src/v3/task-catalog/index.ts
|
|
3626
|
-
var
|
|
3765
|
+
var API_NAME7 = "task-catalog";
|
|
3627
3766
|
var NOOP_TASK_CATALOG = new NoopTaskCatalog();
|
|
3628
3767
|
var _getCatalog, getCatalog_fn;
|
|
3629
3768
|
var _TaskCatalogAPI = class _TaskCatalogAPI {
|
|
@@ -3637,10 +3776,10 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
|
|
|
3637
3776
|
return this._instance;
|
|
3638
3777
|
}
|
|
3639
3778
|
setGlobalTaskCatalog(taskCatalog2) {
|
|
3640
|
-
return registerGlobal(
|
|
3779
|
+
return registerGlobal(API_NAME7, taskCatalog2);
|
|
3641
3780
|
}
|
|
3642
3781
|
disable() {
|
|
3643
|
-
unregisterGlobal(
|
|
3782
|
+
unregisterGlobal(API_NAME7);
|
|
3644
3783
|
}
|
|
3645
3784
|
registerTaskMetadata(task) {
|
|
3646
3785
|
__privateMethod(this, _getCatalog, getCatalog_fn).call(this).registerTaskMetadata(task);
|
|
@@ -3666,7 +3805,7 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
|
|
|
3666
3805
|
};
|
|
3667
3806
|
_getCatalog = new WeakSet();
|
|
3668
3807
|
getCatalog_fn = /* @__PURE__ */ __name(function() {
|
|
3669
|
-
return getGlobal(
|
|
3808
|
+
return getGlobal(API_NAME7) ?? NOOP_TASK_CATALOG;
|
|
3670
3809
|
}, "#getCatalog");
|
|
3671
3810
|
__name(_TaskCatalogAPI, "TaskCatalogAPI");
|
|
3672
3811
|
var TaskCatalogAPI = _TaskCatalogAPI;
|
|
@@ -3786,6 +3925,7 @@ var _TriggerTracer = class _TriggerTracer {
|
|
|
3786
3925
|
[SemanticInternalAttributes.SPAN_ID]: span.spanContext().spanId
|
|
3787
3926
|
}
|
|
3788
3927
|
}, parentContext).end();
|
|
3928
|
+
const usageMeasurement = usage.start();
|
|
3789
3929
|
try {
|
|
3790
3930
|
return await fn(span);
|
|
3791
3931
|
} catch (e) {
|
|
@@ -3797,6 +3937,12 @@ var _TriggerTracer = class _TriggerTracer {
|
|
|
3797
3937
|
});
|
|
3798
3938
|
throw e;
|
|
3799
3939
|
} finally {
|
|
3940
|
+
const usageSample = usage.stop(usageMeasurement);
|
|
3941
|
+
const machine = taskContext.ctx?.machine;
|
|
3942
|
+
span.setAttributes({
|
|
3943
|
+
[SemanticInternalAttributes.USAGE_DURATION_MS]: usageSample.cpuTime,
|
|
3944
|
+
[SemanticInternalAttributes.USAGE_COST_IN_CENTS]: machine?.centsPerMs ? usageSample.cpuTime * machine.centsPerMs : 0
|
|
3945
|
+
});
|
|
3800
3946
|
span.end(clock.preciseNow());
|
|
3801
3947
|
}
|
|
3802
3948
|
});
|
|
@@ -4331,9 +4477,11 @@ exports.ListRunResponse = ListRunResponse;
|
|
|
4331
4477
|
exports.ListRunResponseItem = ListRunResponseItem;
|
|
4332
4478
|
exports.ListScheduleOptions = ListScheduleOptions;
|
|
4333
4479
|
exports.ListSchedulesResult = ListSchedulesResult;
|
|
4334
|
-
exports.
|
|
4480
|
+
exports.MachineConfig = MachineConfig;
|
|
4335
4481
|
exports.MachineCpu = MachineCpu;
|
|
4336
4482
|
exports.MachineMemory = MachineMemory;
|
|
4483
|
+
exports.MachinePreset = MachinePreset;
|
|
4484
|
+
exports.MachinePresetName = MachinePresetName;
|
|
4337
4485
|
exports.NULL_SENTINEL = NULL_SENTINEL;
|
|
4338
4486
|
exports.NotFoundError = NotFoundError;
|
|
4339
4487
|
exports.OFFLOAD_IO_PACKET_LENGTH_LIMIT = OFFLOAD_IO_PACKET_LENGTH_LIMIT;
|
|
@@ -4405,10 +4553,12 @@ exports.TaskRunExecutionQueue = TaskRunExecutionQueue;
|
|
|
4405
4553
|
exports.TaskRunExecutionResult = TaskRunExecutionResult;
|
|
4406
4554
|
exports.TaskRunExecutionRetry = TaskRunExecutionRetry;
|
|
4407
4555
|
exports.TaskRunExecutionTask = TaskRunExecutionTask;
|
|
4556
|
+
exports.TaskRunExecutionUsage = TaskRunExecutionUsage;
|
|
4408
4557
|
exports.TaskRunFailedExecutionResult = TaskRunFailedExecutionResult;
|
|
4409
4558
|
exports.TaskRunInternalError = TaskRunInternalError;
|
|
4410
4559
|
exports.TaskRunStringError = TaskRunStringError;
|
|
4411
4560
|
exports.TaskRunSuccessfulExecutionResult = TaskRunSuccessfulExecutionResult;
|
|
4561
|
+
exports.TimezonesResult = TimezonesResult;
|
|
4412
4562
|
exports.TriggerTaskRequestBody = TriggerTaskRequestBody;
|
|
4413
4563
|
exports.TriggerTaskResponse = TriggerTaskResponse;
|
|
4414
4564
|
exports.TriggerTracer = TriggerTracer;
|
|
@@ -4461,6 +4611,7 @@ exports.stringifyIO = stringifyIO;
|
|
|
4461
4611
|
exports.taskCatalog = taskCatalog;
|
|
4462
4612
|
exports.taskContext = taskContext;
|
|
4463
4613
|
exports.unflattenAttributes = unflattenAttributes;
|
|
4614
|
+
exports.usage = usage;
|
|
4464
4615
|
exports.workerToChildMessages = workerToChildMessages;
|
|
4465
4616
|
//# sourceMappingURL=out.js.map
|
|
4466
4617
|
//# sourceMappingURL=index.js.map
|