@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.mjs
CHANGED
|
@@ -29,7 +29,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// package.json
|
|
32
|
-
var version = "3.0.0-beta.
|
|
32
|
+
var version = "3.0.0-beta.39";
|
|
33
33
|
var dependencies = {
|
|
34
34
|
"@google-cloud/precise-date": "^4.0.0",
|
|
35
35
|
"@opentelemetry/api": "^1.8.0",
|
|
@@ -65,6 +65,41 @@ var GetPersonalAccessTokenResponseSchema = z.object({
|
|
|
65
65
|
obfuscatedToken: z.string()
|
|
66
66
|
}).nullable()
|
|
67
67
|
});
|
|
68
|
+
var MachineCpu = z.union([
|
|
69
|
+
z.literal(0.25),
|
|
70
|
+
z.literal(0.5),
|
|
71
|
+
z.literal(1),
|
|
72
|
+
z.literal(2),
|
|
73
|
+
z.literal(4)
|
|
74
|
+
]);
|
|
75
|
+
var MachineMemory = z.union([
|
|
76
|
+
z.literal(0.25),
|
|
77
|
+
z.literal(0.5),
|
|
78
|
+
z.literal(1),
|
|
79
|
+
z.literal(2),
|
|
80
|
+
z.literal(4),
|
|
81
|
+
z.literal(8)
|
|
82
|
+
]);
|
|
83
|
+
var MachinePresetName = z.enum([
|
|
84
|
+
"micro",
|
|
85
|
+
"small-1x",
|
|
86
|
+
"small-2x",
|
|
87
|
+
"medium-1x",
|
|
88
|
+
"medium-2x",
|
|
89
|
+
"large-1x",
|
|
90
|
+
"large-2x"
|
|
91
|
+
]);
|
|
92
|
+
var MachineConfig = z.object({
|
|
93
|
+
cpu: MachineCpu.optional(),
|
|
94
|
+
memory: MachineMemory.optional(),
|
|
95
|
+
preset: MachinePresetName.optional()
|
|
96
|
+
});
|
|
97
|
+
var MachinePreset = z.object({
|
|
98
|
+
name: MachinePresetName,
|
|
99
|
+
cpu: z.number(),
|
|
100
|
+
memory: z.number(),
|
|
101
|
+
centsPerMs: z.number()
|
|
102
|
+
});
|
|
68
103
|
var TaskRunBuiltInError = z.object({
|
|
69
104
|
type: z.literal("BUILT_IN_ERROR"),
|
|
70
105
|
name: z.string(),
|
|
@@ -126,7 +161,11 @@ var TaskRun = z.object({
|
|
|
126
161
|
tags: z.array(z.string()),
|
|
127
162
|
isTest: z.boolean().default(false),
|
|
128
163
|
createdAt: z.coerce.date(),
|
|
129
|
-
|
|
164
|
+
startedAt: z.coerce.date().default(() => /* @__PURE__ */ new Date()),
|
|
165
|
+
idempotencyKey: z.string().optional(),
|
|
166
|
+
durationMs: z.number().default(0),
|
|
167
|
+
costInCents: z.number().default(0),
|
|
168
|
+
baseCostInCents: z.number().default(0)
|
|
130
169
|
});
|
|
131
170
|
var TaskRunExecutionTask = z.object({
|
|
132
171
|
id: z.string(),
|
|
@@ -177,7 +216,8 @@ var TaskRunExecution = z.object({
|
|
|
177
216
|
environment: TaskRunExecutionEnvironment,
|
|
178
217
|
organization: TaskRunExecutionOrganization,
|
|
179
218
|
project: TaskRunExecutionProject,
|
|
180
|
-
batch: TaskRunExecutionBatch.optional()
|
|
219
|
+
batch: TaskRunExecutionBatch.optional(),
|
|
220
|
+
machine: MachinePreset.optional()
|
|
181
221
|
});
|
|
182
222
|
var TaskRunContext = z.object({
|
|
183
223
|
task: TaskRunExecutionTask,
|
|
@@ -193,25 +233,31 @@ var TaskRunContext = z.object({
|
|
|
193
233
|
environment: TaskRunExecutionEnvironment,
|
|
194
234
|
organization: TaskRunExecutionOrganization,
|
|
195
235
|
project: TaskRunExecutionProject,
|
|
196
|
-
batch: TaskRunExecutionBatch.optional()
|
|
236
|
+
batch: TaskRunExecutionBatch.optional(),
|
|
237
|
+
machine: MachinePreset.optional()
|
|
197
238
|
});
|
|
198
239
|
var TaskRunExecutionRetry = z.object({
|
|
199
240
|
timestamp: z.number(),
|
|
200
241
|
delay: z.number(),
|
|
201
242
|
error: z.unknown().optional()
|
|
202
243
|
});
|
|
244
|
+
var TaskRunExecutionUsage = z.object({
|
|
245
|
+
durationMs: z.number()
|
|
246
|
+
});
|
|
203
247
|
var TaskRunFailedExecutionResult = z.object({
|
|
204
248
|
ok: z.literal(false),
|
|
205
249
|
id: z.string(),
|
|
206
250
|
error: TaskRunError,
|
|
207
251
|
retry: TaskRunExecutionRetry.optional(),
|
|
208
|
-
skippedRetrying: z.boolean().optional()
|
|
252
|
+
skippedRetrying: z.boolean().optional(),
|
|
253
|
+
usage: TaskRunExecutionUsage.optional()
|
|
209
254
|
});
|
|
210
255
|
var TaskRunSuccessfulExecutionResult = z.object({
|
|
211
256
|
ok: z.literal(true),
|
|
212
257
|
id: z.string(),
|
|
213
258
|
output: z.string().optional(),
|
|
214
|
-
outputType: z.string()
|
|
259
|
+
outputType: z.string(),
|
|
260
|
+
usage: TaskRunExecutionUsage.optional()
|
|
215
261
|
});
|
|
216
262
|
var TaskRunExecutionResult = z.discriminatedUnion("ok", [
|
|
217
263
|
TaskRunSuccessfulExecutionResult,
|
|
@@ -229,26 +275,6 @@ var EnvironmentType = z.enum([
|
|
|
229
275
|
"DEVELOPMENT",
|
|
230
276
|
"PREVIEW"
|
|
231
277
|
]);
|
|
232
|
-
var MachineCpu = z.union([
|
|
233
|
-
z.literal(0.25),
|
|
234
|
-
z.literal(0.5),
|
|
235
|
-
z.literal(1),
|
|
236
|
-
z.literal(2),
|
|
237
|
-
z.literal(4)
|
|
238
|
-
]).default(0.5);
|
|
239
|
-
var MachineMemory = z.union([
|
|
240
|
-
z.literal(0.25),
|
|
241
|
-
z.literal(0.5),
|
|
242
|
-
z.literal(1),
|
|
243
|
-
z.literal(2),
|
|
244
|
-
z.literal(4),
|
|
245
|
-
z.literal(8)
|
|
246
|
-
]).default(1);
|
|
247
|
-
var Machine = z.object({
|
|
248
|
-
version: z.literal("v1").default("v1"),
|
|
249
|
-
cpu: MachineCpu,
|
|
250
|
-
memory: MachineMemory
|
|
251
|
-
});
|
|
252
278
|
var TaskRunExecutionPayload = z.object({
|
|
253
279
|
execution: TaskRunExecution,
|
|
254
280
|
traceContext: z.record(z.unknown()),
|
|
@@ -259,6 +285,12 @@ var ProdTaskRunExecution = TaskRunExecution.extend({
|
|
|
259
285
|
id: z.string(),
|
|
260
286
|
contentHash: z.string(),
|
|
261
287
|
version: z.string()
|
|
288
|
+
}),
|
|
289
|
+
machine: MachinePreset.default({
|
|
290
|
+
name: "small-1x",
|
|
291
|
+
cpu: 1,
|
|
292
|
+
memory: 1,
|
|
293
|
+
centsPerMs: 0
|
|
262
294
|
})
|
|
263
295
|
});
|
|
264
296
|
var ProdTaskRunExecutionPayload = z.object({
|
|
@@ -363,7 +395,7 @@ var TaskMetadata = z.object({
|
|
|
363
395
|
packageVersion: z.string(),
|
|
364
396
|
queue: QueueOptions.optional(),
|
|
365
397
|
retry: RetryOptions.optional(),
|
|
366
|
-
machine:
|
|
398
|
+
machine: MachineConfig.optional(),
|
|
367
399
|
triggerSource: z.string().optional()
|
|
368
400
|
});
|
|
369
401
|
var TaskFileMetadata = z.object({
|
|
@@ -375,7 +407,7 @@ var TaskMetadataWithFilePath = z.object({
|
|
|
375
407
|
packageVersion: z.string(),
|
|
376
408
|
queue: QueueOptions.optional(),
|
|
377
409
|
retry: RetryOptions.optional(),
|
|
378
|
-
machine:
|
|
410
|
+
machine: MachineConfig.optional(),
|
|
379
411
|
triggerSource: z.string().optional(),
|
|
380
412
|
filePath: z.string(),
|
|
381
413
|
exportName: z.string()
|
|
@@ -435,7 +467,7 @@ var TaskResource = z.object({
|
|
|
435
467
|
exportName: z.string(),
|
|
436
468
|
queue: QueueOptions.optional(),
|
|
437
469
|
retry: RetryOptions.optional(),
|
|
438
|
-
machine:
|
|
470
|
+
machine: MachineConfig.optional(),
|
|
439
471
|
triggerSource: z.string().optional()
|
|
440
472
|
});
|
|
441
473
|
var BackgroundWorkerMetadata = z.object({
|
|
@@ -744,15 +776,26 @@ var ScheduledTaskPayload = z.object({
|
|
|
744
776
|
You can use this to remove the schedule, update it, etc */
|
|
745
777
|
scheduleId: z.string(),
|
|
746
778
|
/** When the task was scheduled to run.
|
|
747
|
-
* Note this will be slightly different from `new Date()` because it takes a few ms to run the task.
|
|
779
|
+
* Note this will be slightly different from `new Date()` because it takes a few ms to run the task.
|
|
780
|
+
*
|
|
781
|
+
* This date is UTC. To output it as a string with a timezone you would do this:
|
|
782
|
+
* ```ts
|
|
783
|
+
* const formatted = payload.timestamp.toLocaleString("en-US", {
|
|
784
|
+
timeZone: payload.timezone,
|
|
785
|
+
});
|
|
786
|
+
``` */
|
|
748
787
|
timestamp: z.date(),
|
|
749
788
|
/** When the task was last run (it has been).
|
|
750
|
-
This can be undefined if it's never been run */
|
|
789
|
+
This can be undefined if it's never been run. This date is UTC. */
|
|
751
790
|
lastTimestamp: z.date().optional(),
|
|
752
791
|
/** You can optionally provide an external id when creating the schedule.
|
|
753
792
|
Usually you would use a userId or some other unique identifier.
|
|
754
793
|
This defaults to undefined if you didn't provide one. */
|
|
755
794
|
externalId: z.string().optional(),
|
|
795
|
+
/** The IANA timezone the schedule is set to. The default is UTC.
|
|
796
|
+
* You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
|
|
797
|
+
*/
|
|
798
|
+
timezone: z.string(),
|
|
756
799
|
/** The next 5 dates this task is scheduled to run */
|
|
757
800
|
upcoming: z.array(z.date())
|
|
758
801
|
});
|
|
@@ -776,17 +819,30 @@ var CreateScheduleOptions = z.object({
|
|
|
776
819
|
|
|
777
820
|
*/
|
|
778
821
|
cron: z.string(),
|
|
779
|
-
/**
|
|
822
|
+
/** You can only create one schedule with this key. If you use it twice, the second call will update the schedule.
|
|
780
823
|
*
|
|
781
|
-
* This is
|
|
782
|
-
deduplicationKey: z.string()
|
|
824
|
+
* This is required to prevent you from creating duplicate schedules. */
|
|
825
|
+
deduplicationKey: z.string(),
|
|
783
826
|
/** Optionally, you can specify your own IDs (like a user ID) and then use it inside the run function of your task.
|
|
784
827
|
*
|
|
785
828
|
* This allows you to have per-user CRON tasks.
|
|
786
829
|
*/
|
|
787
|
-
externalId: z.string().optional()
|
|
830
|
+
externalId: z.string().optional(),
|
|
831
|
+
/** Optionally, you can specify a timezone in the IANA format. If unset it will use UTC.
|
|
832
|
+
* If specified then the CRON will be evaluated in that timezone and will respect daylight savings.
|
|
833
|
+
*
|
|
834
|
+
* 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.
|
|
835
|
+
*
|
|
836
|
+
* You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
|
|
837
|
+
*
|
|
838
|
+
* @example "America/New_York", "Europe/London", "Asia/Tokyo", "Africa/Cairo"
|
|
839
|
+
*
|
|
840
|
+
*/
|
|
841
|
+
timezone: z.string().optional()
|
|
842
|
+
});
|
|
843
|
+
var UpdateScheduleOptions = CreateScheduleOptions.omit({
|
|
844
|
+
deduplicationKey: true
|
|
788
845
|
});
|
|
789
|
-
var UpdateScheduleOptions = CreateScheduleOptions;
|
|
790
846
|
var ScheduleGenerator = z.object({
|
|
791
847
|
type: z.literal("CRON"),
|
|
792
848
|
expression: z.string(),
|
|
@@ -799,6 +855,7 @@ var ScheduleObject = z.object({
|
|
|
799
855
|
deduplicationKey: z.string().nullish(),
|
|
800
856
|
externalId: z.string().nullish(),
|
|
801
857
|
generator: ScheduleGenerator,
|
|
858
|
+
timezone: z.string(),
|
|
802
859
|
nextRun: z.coerce.date().nullish(),
|
|
803
860
|
environments: z.array(z.object({
|
|
804
861
|
id: z.string(),
|
|
@@ -821,6 +878,9 @@ var ListScheduleOptions = z.object({
|
|
|
821
878
|
page: z.number().optional(),
|
|
822
879
|
perPage: z.number().optional()
|
|
823
880
|
});
|
|
881
|
+
var TimezonesResult = z.object({
|
|
882
|
+
timezones: z.array(z.string())
|
|
883
|
+
});
|
|
824
884
|
var RunStatus = z.enum([
|
|
825
885
|
/// Task hasn't been deployed yet but is waiting to be executed
|
|
826
886
|
"WAITING_FOR_DEPLOY",
|
|
@@ -944,7 +1004,7 @@ var BackgroundWorkerServerMessages = z.discriminatedUnion("type", [
|
|
|
944
1004
|
type: z.literal("SCHEDULE_ATTEMPT"),
|
|
945
1005
|
image: z.string(),
|
|
946
1006
|
version: z.string(),
|
|
947
|
-
machine:
|
|
1007
|
+
machine: MachinePreset,
|
|
948
1008
|
// identifiers
|
|
949
1009
|
id: z.string().optional(),
|
|
950
1010
|
envId: z.string(),
|
|
@@ -1289,7 +1349,7 @@ var PlatformToProviderMessages = {
|
|
|
1289
1349
|
location: z.string(),
|
|
1290
1350
|
reason: z.string().optional(),
|
|
1291
1351
|
imageRef: z.string(),
|
|
1292
|
-
machine:
|
|
1352
|
+
machine: MachinePreset,
|
|
1293
1353
|
// identifiers
|
|
1294
1354
|
checkpointId: z.string(),
|
|
1295
1355
|
envId: z.string(),
|
|
@@ -2039,6 +2099,10 @@ var SemanticInternalAttributes = {
|
|
|
2039
2099
|
TASK_EXPORT_NAME: "ctx.task.exportName",
|
|
2040
2100
|
QUEUE_NAME: "ctx.queue.name",
|
|
2041
2101
|
QUEUE_ID: "ctx.queue.id",
|
|
2102
|
+
MACHINE_PRESET_NAME: "ctx.machine.name",
|
|
2103
|
+
MACHINE_PRESET_CPU: "ctx.machine.cpu",
|
|
2104
|
+
MACHINE_PRESET_MEMORY: "ctx.machine.memory",
|
|
2105
|
+
MACHINE_PRESET_CENTS_PER_MS: "ctx.machine.centsPerMs",
|
|
2042
2106
|
SPAN_PARTIAL: "$span.partial",
|
|
2043
2107
|
SPAN_ID: "$span.span_id",
|
|
2044
2108
|
OUTPUT: "$output",
|
|
@@ -2062,7 +2126,9 @@ var SemanticInternalAttributes = {
|
|
|
2062
2126
|
RETRY_DELAY: "retry.delay",
|
|
2063
2127
|
RETRY_COUNT: "retry.count",
|
|
2064
2128
|
LINK_TITLE: "$link.title",
|
|
2065
|
-
IDEMPOTENCY_KEY: "ctx.run.idempotencyKey"
|
|
2129
|
+
IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
|
|
2130
|
+
USAGE_DURATION_MS: "$usage.durationMs",
|
|
2131
|
+
USAGE_COST_IN_CENTS: "$usage.costInCents"
|
|
2066
2132
|
};
|
|
2067
2133
|
|
|
2068
2134
|
// src/v3/taskContext/index.ts
|
|
@@ -2126,7 +2192,11 @@ var _TaskContextAPI = class _TaskContextAPI {
|
|
|
2126
2192
|
[SemanticInternalAttributes.ORGANIZATION_SLUG]: this.ctx.organization.slug,
|
|
2127
2193
|
[SemanticInternalAttributes.ORGANIZATION_NAME]: this.ctx.organization.name,
|
|
2128
2194
|
[SemanticInternalAttributes.BATCH_ID]: this.ctx.batch?.id,
|
|
2129
|
-
[SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey
|
|
2195
|
+
[SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey,
|
|
2196
|
+
[SemanticInternalAttributes.MACHINE_PRESET_NAME]: this.ctx.machine?.name,
|
|
2197
|
+
[SemanticInternalAttributes.MACHINE_PRESET_CPU]: this.ctx.machine?.cpu,
|
|
2198
|
+
[SemanticInternalAttributes.MACHINE_PRESET_MEMORY]: this.ctx.machine?.memory,
|
|
2199
|
+
[SemanticInternalAttributes.MACHINE_PRESET_CENTS_PER_MS]: this.ctx.machine?.centsPerMs
|
|
2130
2200
|
};
|
|
2131
2201
|
}
|
|
2132
2202
|
return {};
|
|
@@ -3494,8 +3564,77 @@ var _NoopRuntimeManager = class _NoopRuntimeManager {
|
|
|
3494
3564
|
__name(_NoopRuntimeManager, "NoopRuntimeManager");
|
|
3495
3565
|
var NoopRuntimeManager = _NoopRuntimeManager;
|
|
3496
3566
|
|
|
3567
|
+
// src/v3/usage/noopUsageManager.ts
|
|
3568
|
+
var _NoopUsageManager = class _NoopUsageManager {
|
|
3569
|
+
disable() {
|
|
3570
|
+
}
|
|
3571
|
+
start() {
|
|
3572
|
+
return {
|
|
3573
|
+
sample: () => ({
|
|
3574
|
+
cpuTime: 0,
|
|
3575
|
+
wallTime: 0
|
|
3576
|
+
})
|
|
3577
|
+
};
|
|
3578
|
+
}
|
|
3579
|
+
stop(measurement) {
|
|
3580
|
+
return measurement.sample();
|
|
3581
|
+
}
|
|
3582
|
+
pauseAsync(cb) {
|
|
3583
|
+
return cb();
|
|
3584
|
+
}
|
|
3585
|
+
sample() {
|
|
3586
|
+
return void 0;
|
|
3587
|
+
}
|
|
3588
|
+
};
|
|
3589
|
+
__name(_NoopUsageManager, "NoopUsageManager");
|
|
3590
|
+
var NoopUsageManager = _NoopUsageManager;
|
|
3591
|
+
|
|
3592
|
+
// src/v3/usage/api.ts
|
|
3593
|
+
var API_NAME4 = "usage";
|
|
3594
|
+
var NOOP_USAGE_MANAGER = new NoopUsageManager();
|
|
3595
|
+
var _getUsageManager, getUsageManager_fn;
|
|
3596
|
+
var _UsageAPI = class _UsageAPI {
|
|
3597
|
+
constructor() {
|
|
3598
|
+
__privateAdd(this, _getUsageManager);
|
|
3599
|
+
}
|
|
3600
|
+
static getInstance() {
|
|
3601
|
+
if (!this._instance) {
|
|
3602
|
+
this._instance = new _UsageAPI();
|
|
3603
|
+
}
|
|
3604
|
+
return this._instance;
|
|
3605
|
+
}
|
|
3606
|
+
setGlobalUsageManager(manager) {
|
|
3607
|
+
return registerGlobal(API_NAME4, manager);
|
|
3608
|
+
}
|
|
3609
|
+
disable() {
|
|
3610
|
+
__privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).disable();
|
|
3611
|
+
unregisterGlobal(API_NAME4);
|
|
3612
|
+
}
|
|
3613
|
+
start() {
|
|
3614
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).start();
|
|
3615
|
+
}
|
|
3616
|
+
stop(measurement) {
|
|
3617
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).stop(measurement);
|
|
3618
|
+
}
|
|
3619
|
+
pauseAsync(cb) {
|
|
3620
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).pauseAsync(cb);
|
|
3621
|
+
}
|
|
3622
|
+
sample() {
|
|
3623
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).sample();
|
|
3624
|
+
}
|
|
3625
|
+
};
|
|
3626
|
+
_getUsageManager = new WeakSet();
|
|
3627
|
+
getUsageManager_fn = /* @__PURE__ */ __name(function() {
|
|
3628
|
+
return getGlobal(API_NAME4) ?? NOOP_USAGE_MANAGER;
|
|
3629
|
+
}, "#getUsageManager");
|
|
3630
|
+
__name(_UsageAPI, "UsageAPI");
|
|
3631
|
+
var UsageAPI = _UsageAPI;
|
|
3632
|
+
|
|
3633
|
+
// src/v3/usage-api.ts
|
|
3634
|
+
var usage = UsageAPI.getInstance();
|
|
3635
|
+
|
|
3497
3636
|
// src/v3/runtime/index.ts
|
|
3498
|
-
var
|
|
3637
|
+
var API_NAME5 = "runtime";
|
|
3499
3638
|
var NOOP_RUNTIME_MANAGER = new NoopRuntimeManager();
|
|
3500
3639
|
var _getRuntimeManager, getRuntimeManager_fn;
|
|
3501
3640
|
var _RuntimeAPI = class _RuntimeAPI {
|
|
@@ -3509,28 +3648,28 @@ var _RuntimeAPI = class _RuntimeAPI {
|
|
|
3509
3648
|
return this._instance;
|
|
3510
3649
|
}
|
|
3511
3650
|
waitForDuration(ms) {
|
|
3512
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms);
|
|
3651
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms));
|
|
3513
3652
|
}
|
|
3514
3653
|
waitUntil(date) {
|
|
3515
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date);
|
|
3654
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date));
|
|
3516
3655
|
}
|
|
3517
3656
|
waitForTask(params) {
|
|
3518
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params);
|
|
3657
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params));
|
|
3519
3658
|
}
|
|
3520
3659
|
waitForBatch(params) {
|
|
3521
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params);
|
|
3660
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params));
|
|
3522
3661
|
}
|
|
3523
3662
|
setGlobalRuntimeManager(runtimeManager) {
|
|
3524
|
-
return registerGlobal(
|
|
3663
|
+
return registerGlobal(API_NAME5, runtimeManager);
|
|
3525
3664
|
}
|
|
3526
3665
|
disable() {
|
|
3527
3666
|
__privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).disable();
|
|
3528
|
-
unregisterGlobal(
|
|
3667
|
+
unregisterGlobal(API_NAME5);
|
|
3529
3668
|
}
|
|
3530
3669
|
};
|
|
3531
3670
|
_getRuntimeManager = new WeakSet();
|
|
3532
3671
|
getRuntimeManager_fn = /* @__PURE__ */ __name(function() {
|
|
3533
|
-
return getGlobal(
|
|
3672
|
+
return getGlobal(API_NAME5) ?? NOOP_RUNTIME_MANAGER;
|
|
3534
3673
|
}, "#getRuntimeManager");
|
|
3535
3674
|
__name(_RuntimeAPI, "RuntimeAPI");
|
|
3536
3675
|
var RuntimeAPI = _RuntimeAPI;
|
|
@@ -3547,7 +3686,7 @@ function getEnvVar(name) {
|
|
|
3547
3686
|
__name(getEnvVar, "getEnvVar");
|
|
3548
3687
|
|
|
3549
3688
|
// src/v3/apiClientManager/index.ts
|
|
3550
|
-
var
|
|
3689
|
+
var API_NAME6 = "api-client";
|
|
3551
3690
|
var _getConfig, getConfig_fn;
|
|
3552
3691
|
var _APIClientManagerAPI = class _APIClientManagerAPI {
|
|
3553
3692
|
constructor() {
|
|
@@ -3560,10 +3699,10 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
|
|
|
3560
3699
|
return this._instance;
|
|
3561
3700
|
}
|
|
3562
3701
|
disable() {
|
|
3563
|
-
unregisterGlobal(
|
|
3702
|
+
unregisterGlobal(API_NAME6);
|
|
3564
3703
|
}
|
|
3565
3704
|
setGlobalAPIClientConfiguration(config) {
|
|
3566
|
-
return registerGlobal(
|
|
3705
|
+
return registerGlobal(API_NAME6, config);
|
|
3567
3706
|
}
|
|
3568
3707
|
get baseURL() {
|
|
3569
3708
|
const store = __privateMethod(this, _getConfig, getConfig_fn).call(this);
|
|
@@ -3582,7 +3721,7 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
|
|
|
3582
3721
|
};
|
|
3583
3722
|
_getConfig = new WeakSet();
|
|
3584
3723
|
getConfig_fn = /* @__PURE__ */ __name(function() {
|
|
3585
|
-
return getGlobal(
|
|
3724
|
+
return getGlobal(API_NAME6);
|
|
3586
3725
|
}, "#getConfig");
|
|
3587
3726
|
__name(_APIClientManagerAPI, "APIClientManagerAPI");
|
|
3588
3727
|
var APIClientManagerAPI = _APIClientManagerAPI;
|
|
@@ -3617,7 +3756,7 @@ __name(_NoopTaskCatalog, "NoopTaskCatalog");
|
|
|
3617
3756
|
var NoopTaskCatalog = _NoopTaskCatalog;
|
|
3618
3757
|
|
|
3619
3758
|
// src/v3/task-catalog/index.ts
|
|
3620
|
-
var
|
|
3759
|
+
var API_NAME7 = "task-catalog";
|
|
3621
3760
|
var NOOP_TASK_CATALOG = new NoopTaskCatalog();
|
|
3622
3761
|
var _getCatalog, getCatalog_fn;
|
|
3623
3762
|
var _TaskCatalogAPI = class _TaskCatalogAPI {
|
|
@@ -3631,10 +3770,10 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
|
|
|
3631
3770
|
return this._instance;
|
|
3632
3771
|
}
|
|
3633
3772
|
setGlobalTaskCatalog(taskCatalog2) {
|
|
3634
|
-
return registerGlobal(
|
|
3773
|
+
return registerGlobal(API_NAME7, taskCatalog2);
|
|
3635
3774
|
}
|
|
3636
3775
|
disable() {
|
|
3637
|
-
unregisterGlobal(
|
|
3776
|
+
unregisterGlobal(API_NAME7);
|
|
3638
3777
|
}
|
|
3639
3778
|
registerTaskMetadata(task) {
|
|
3640
3779
|
__privateMethod(this, _getCatalog, getCatalog_fn).call(this).registerTaskMetadata(task);
|
|
@@ -3660,7 +3799,7 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
|
|
|
3660
3799
|
};
|
|
3661
3800
|
_getCatalog = new WeakSet();
|
|
3662
3801
|
getCatalog_fn = /* @__PURE__ */ __name(function() {
|
|
3663
|
-
return getGlobal(
|
|
3802
|
+
return getGlobal(API_NAME7) ?? NOOP_TASK_CATALOG;
|
|
3664
3803
|
}, "#getCatalog");
|
|
3665
3804
|
__name(_TaskCatalogAPI, "TaskCatalogAPI");
|
|
3666
3805
|
var TaskCatalogAPI = _TaskCatalogAPI;
|
|
@@ -3780,6 +3919,7 @@ var _TriggerTracer = class _TriggerTracer {
|
|
|
3780
3919
|
[SemanticInternalAttributes.SPAN_ID]: span.spanContext().spanId
|
|
3781
3920
|
}
|
|
3782
3921
|
}, parentContext).end();
|
|
3922
|
+
const usageMeasurement = usage.start();
|
|
3783
3923
|
try {
|
|
3784
3924
|
return await fn(span);
|
|
3785
3925
|
} catch (e) {
|
|
@@ -3791,6 +3931,12 @@ var _TriggerTracer = class _TriggerTracer {
|
|
|
3791
3931
|
});
|
|
3792
3932
|
throw e;
|
|
3793
3933
|
} finally {
|
|
3934
|
+
const usageSample = usage.stop(usageMeasurement);
|
|
3935
|
+
const machine = taskContext.ctx?.machine;
|
|
3936
|
+
span.setAttributes({
|
|
3937
|
+
[SemanticInternalAttributes.USAGE_DURATION_MS]: usageSample.cpuTime,
|
|
3938
|
+
[SemanticInternalAttributes.USAGE_COST_IN_CENTS]: machine?.centsPerMs ? usageSample.cpuTime * machine.centsPerMs : 0
|
|
3939
|
+
});
|
|
3794
3940
|
span.end(clock.preciseNow());
|
|
3795
3941
|
}
|
|
3796
3942
|
});
|
|
@@ -4263,6 +4409,6 @@ function safeJsonParse2(value) {
|
|
|
4263
4409
|
}
|
|
4264
4410
|
__name(safeJsonParse2, "safeJsonParse");
|
|
4265
4411
|
|
|
4266
|
-
export { ApiClient, ApiConnectionError, ApiError, AttemptStatus, AuthenticationError, BackgroundWorkerClientMessages, BackgroundWorkerMetadata, BackgroundWorkerProperties, BackgroundWorkerServerMessages, BadRequestError, BatchTaskRunExecutionResult, BatchTriggerTaskRequestBody, BatchTriggerTaskResponse, CanceledRunResponse, CancellationSpanEvent, ClientToSharedQueueMessages, Config, ConflictError, CoordinatorToPlatformMessages, CoordinatorToProdWorkerMessages, CreateAuthorizationCodeResponseSchema, CreateBackgroundWorkerRequestBody, CreateBackgroundWorkerResponse, CreateEnvironmentVariableRequestBody, CreateScheduleOptions, CreateUploadPayloadUrlResponseBody, CursorPage, DeletedScheduleObject, DeploymentErrorData, EnvironmentType, EnvironmentVariable, EnvironmentVariableResponseBody, EnvironmentVariableValue, EnvironmentVariables, EventFilter, ExceptionEventProperties, ExceptionSpanEvent, ExternalBuildData, FetchRetryBackoffStrategy, FetchRetryByStatusOptions, FetchRetryHeadersStrategy, FetchRetryOptions, FetchRetryStrategy, FetchTimeoutOptions, FixedWindowRateLimit, GetBatchResponseBody, GetDeploymentResponseBody, GetEnvironmentVariablesResponseBody, GetPersonalAccessTokenRequestSchema, GetPersonalAccessTokenResponseSchema, GetProjectEnvResponse, GetProjectResponseBody, GetProjectsResponseBody, ImageDetailsMetadata, ImportEnvironmentVariablesRequestBody, InitializeDeploymentRequestBody, InitializeDeploymentResponseBody, InternalServerError, ListRunResponse, ListRunResponseItem, ListScheduleOptions, ListSchedulesResult,
|
|
4412
|
+
export { ApiClient, ApiConnectionError, ApiError, AttemptStatus, AuthenticationError, BackgroundWorkerClientMessages, BackgroundWorkerMetadata, BackgroundWorkerProperties, BackgroundWorkerServerMessages, BadRequestError, BatchTaskRunExecutionResult, BatchTriggerTaskRequestBody, BatchTriggerTaskResponse, CanceledRunResponse, CancellationSpanEvent, ClientToSharedQueueMessages, Config, ConflictError, CoordinatorToPlatformMessages, CoordinatorToProdWorkerMessages, CreateAuthorizationCodeResponseSchema, CreateBackgroundWorkerRequestBody, CreateBackgroundWorkerResponse, CreateEnvironmentVariableRequestBody, CreateScheduleOptions, CreateUploadPayloadUrlResponseBody, CursorPage, DeletedScheduleObject, DeploymentErrorData, EnvironmentType, EnvironmentVariable, EnvironmentVariableResponseBody, EnvironmentVariableValue, EnvironmentVariables, EventFilter, ExceptionEventProperties, ExceptionSpanEvent, ExternalBuildData, FetchRetryBackoffStrategy, FetchRetryByStatusOptions, FetchRetryHeadersStrategy, FetchRetryOptions, FetchRetryStrategy, FetchTimeoutOptions, FixedWindowRateLimit, GetBatchResponseBody, GetDeploymentResponseBody, GetEnvironmentVariablesResponseBody, GetPersonalAccessTokenRequestSchema, GetPersonalAccessTokenResponseSchema, GetProjectEnvResponse, GetProjectResponseBody, GetProjectsResponseBody, ImageDetailsMetadata, ImportEnvironmentVariablesRequestBody, InitializeDeploymentRequestBody, InitializeDeploymentResponseBody, InternalServerError, ListRunResponse, ListRunResponseItem, ListScheduleOptions, ListSchedulesResult, MachineConfig, MachineCpu, MachineMemory, MachinePreset, MachinePresetName, NULL_SENTINEL, NotFoundError, OFFLOAD_IO_PACKET_LENGTH_LIMIT, OTEL_ATTRIBUTE_PER_EVENT_COUNT_LIMIT, OTEL_ATTRIBUTE_PER_LINK_COUNT_LIMIT, OTEL_LINK_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_EVENT_COUNT_LIMIT, OffsetLimitPage, OtherSpanEvent, PRIMARY_VARIANT, PermissionDeniedError, PlatformToCoordinatorMessages, PlatformToProviderMessages, PostStartCauses, PreStopCauses, ProdChildToWorkerMessages, ProdTaskRunExecution, ProdTaskRunExecutionPayload, ProdWorkerSocketData, ProdWorkerToChildMessages, ProdWorkerToCoordinatorMessages, ProviderToPlatformMessages, QueueOptions, RateLimitError, RateLimitOptions, ReplayRunResponse, RetrieveRunResponse, RetryOptions, RunEnvironmentDetails, RunScheduleDetails, RunStatus, ScheduleGenerator, ScheduleObject, ScheduledTaskPayload, SemanticInternalAttributes, SerializedError, SharedQueueToClientMessages, SlidingWindowRateLimit, SpanEvent, SpanEvents, SpanMessagingEvent, StartDeploymentIndexingRequestBody, StartDeploymentIndexingResponseBody, TaskEventStyle, TaskFileMetadata, TaskMetadata, TaskMetadataFailedToParseData, TaskMetadataWithFilePath, TaskResource, TaskRun, TaskRunBuiltInError, TaskRunContext, TaskRunCustomErrorObject, TaskRunError, TaskRunErrorCodes, TaskRunExecution, TaskRunExecutionAttempt, TaskRunExecutionBatch, TaskRunExecutionEnvironment, TaskRunExecutionLazyAttemptPayload, TaskRunExecutionOrganization, TaskRunExecutionPayload, TaskRunExecutionProject, TaskRunExecutionQueue, TaskRunExecutionResult, TaskRunExecutionRetry, TaskRunExecutionTask, TaskRunExecutionUsage, TaskRunFailedExecutionResult, TaskRunInternalError, TaskRunStringError, TaskRunSuccessfulExecutionResult, TimezonesResult, TriggerTaskRequestBody, TriggerTaskResponse, TriggerTracer, UncaughtExceptionMessage, UnprocessableEntityError, UpdateEnvironmentVariableRequestBody, UpdateScheduleOptions, WaitReason, WhoAmIResponseSchema, accessoryAttributes, apiClientManager, calculateNextRetryDelay, calculateResetAt2 as calculateResetAt, childToWorkerMessages, clientWebsocketMessages, clock, conditionallyExportPacket, conditionallyImportPacket, correctErrorStackTrace, createErrorTaskError, createJsonErrorObject, createPacketAttributes, createPacketAttributesAsJson, defaultFetchRetryOptions, defaultRetryOptions, detectDependencyVersion, eventFilterMatches, flattenAttributes, formatDuration, formatDurationInDays, formatDurationMilliseconds, formatDurationNanoseconds, groupTaskMetadataIssuesByTask, imposeAttributeLimits, isCancellationSpanEvent, isExceptionSpanEvent, logger, millisecondsToNanoseconds, nanosecondsToMilliseconds, omit, packetRequiresOffloading, parseError, parsePacket, prettyPrintPacket, primitiveValueOrflattenedAttributes, runtime, serverWebsocketMessages, stringPatternMatchers, stringifyIO, taskCatalog, taskContext, unflattenAttributes, usage, workerToChildMessages };
|
|
4267
4413
|
//# sourceMappingURL=out.js.map
|
|
4268
4414
|
//# sourceMappingURL=index.mjs.map
|