@trigger.dev/core 3.0.0-beta.36 → 3.0.0-beta.38
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-dRKTgwQ7.d.ts → catalog-Tdea4K0I.d.mts} +43 -3
- package/dist/{catalog-XTlJQaMn.d.mts → catalog-yeAHwmSe.d.ts} +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-6_-q72KG.d.mts → messages-BD0yXLtn.d.mts} +2390 -188
- package/dist/{messages-6_-q72KG.d.ts → messages-BD0yXLtn.d.ts} +2390 -188
- package/dist/{schemas-r4ZP9S-F.d.mts → schemas-XNxZYXOy.d.mts} +199 -33
- package/dist/{schemas-r4ZP9S-F.d.ts → schemas-XNxZYXOy.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 +125 -52
- package/dist/v3/index.d.ts +125 -52
- package/dist/v3/index.js +214 -87
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +209 -87
- 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 +406 -44
- package/dist/v3/workers/index.js.map +1 -1
- package/dist/v3/workers/index.mjs +404 -45
- 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/zodMessageHandler.d.mts +1 -1
- package/dist/v3/zodMessageHandler.d.ts +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.38";
|
|
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,7 +285,8 @@ var ProdTaskRunExecution = TaskRunExecution.extend({
|
|
|
259
285
|
id: z.string(),
|
|
260
286
|
contentHash: z.string(),
|
|
261
287
|
version: z.string()
|
|
262
|
-
})
|
|
288
|
+
}),
|
|
289
|
+
machine: MachinePreset
|
|
263
290
|
});
|
|
264
291
|
var ProdTaskRunExecutionPayload = z.object({
|
|
265
292
|
execution: ProdTaskRunExecution,
|
|
@@ -363,7 +390,7 @@ var TaskMetadata = z.object({
|
|
|
363
390
|
packageVersion: z.string(),
|
|
364
391
|
queue: QueueOptions.optional(),
|
|
365
392
|
retry: RetryOptions.optional(),
|
|
366
|
-
machine:
|
|
393
|
+
machine: MachineConfig.optional(),
|
|
367
394
|
triggerSource: z.string().optional()
|
|
368
395
|
});
|
|
369
396
|
var TaskFileMetadata = z.object({
|
|
@@ -375,7 +402,7 @@ var TaskMetadataWithFilePath = z.object({
|
|
|
375
402
|
packageVersion: z.string(),
|
|
376
403
|
queue: QueueOptions.optional(),
|
|
377
404
|
retry: RetryOptions.optional(),
|
|
378
|
-
machine:
|
|
405
|
+
machine: MachineConfig.optional(),
|
|
379
406
|
triggerSource: z.string().optional(),
|
|
380
407
|
filePath: z.string(),
|
|
381
408
|
exportName: z.string()
|
|
@@ -435,7 +462,7 @@ var TaskResource = z.object({
|
|
|
435
462
|
exportName: z.string(),
|
|
436
463
|
queue: QueueOptions.optional(),
|
|
437
464
|
retry: RetryOptions.optional(),
|
|
438
|
-
machine:
|
|
465
|
+
machine: MachineConfig.optional(),
|
|
439
466
|
triggerSource: z.string().optional()
|
|
440
467
|
});
|
|
441
468
|
var BackgroundWorkerMetadata = z.object({
|
|
@@ -700,7 +727,8 @@ var InitializeDeploymentRequestBody = z.object({
|
|
|
700
727
|
var DeploymentErrorData = z.object({
|
|
701
728
|
name: z.string(),
|
|
702
729
|
message: z.string(),
|
|
703
|
-
stack: z.string().optional()
|
|
730
|
+
stack: z.string().optional(),
|
|
731
|
+
stderr: z.string().optional()
|
|
704
732
|
});
|
|
705
733
|
var GetDeploymentResponseBody = z.object({
|
|
706
734
|
id: z.string(),
|
|
@@ -743,15 +771,26 @@ var ScheduledTaskPayload = z.object({
|
|
|
743
771
|
You can use this to remove the schedule, update it, etc */
|
|
744
772
|
scheduleId: z.string(),
|
|
745
773
|
/** When the task was scheduled to run.
|
|
746
|
-
* Note this will be slightly different from `new Date()` because it takes a few ms to run the task.
|
|
774
|
+
* Note this will be slightly different from `new Date()` because it takes a few ms to run the task.
|
|
775
|
+
*
|
|
776
|
+
* This date is UTC. To output it as a string with a timezone you would do this:
|
|
777
|
+
* ```ts
|
|
778
|
+
* const formatted = payload.timestamp.toLocaleString("en-US", {
|
|
779
|
+
timeZone: payload.timezone,
|
|
780
|
+
});
|
|
781
|
+
``` */
|
|
747
782
|
timestamp: z.date(),
|
|
748
783
|
/** When the task was last run (it has been).
|
|
749
|
-
This can be undefined if it's never been run */
|
|
784
|
+
This can be undefined if it's never been run. This date is UTC. */
|
|
750
785
|
lastTimestamp: z.date().optional(),
|
|
751
786
|
/** You can optionally provide an external id when creating the schedule.
|
|
752
787
|
Usually you would use a userId or some other unique identifier.
|
|
753
788
|
This defaults to undefined if you didn't provide one. */
|
|
754
789
|
externalId: z.string().optional(),
|
|
790
|
+
/** The IANA timezone the schedule is set to. The default is UTC.
|
|
791
|
+
* You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
|
|
792
|
+
*/
|
|
793
|
+
timezone: z.string(),
|
|
755
794
|
/** The next 5 dates this task is scheduled to run */
|
|
756
795
|
upcoming: z.array(z.date())
|
|
757
796
|
});
|
|
@@ -775,17 +814,30 @@ var CreateScheduleOptions = z.object({
|
|
|
775
814
|
|
|
776
815
|
*/
|
|
777
816
|
cron: z.string(),
|
|
778
|
-
/**
|
|
817
|
+
/** You can only create one schedule with this key. If you use it twice, the second call will update the schedule.
|
|
779
818
|
*
|
|
780
|
-
* This is
|
|
781
|
-
deduplicationKey: z.string()
|
|
819
|
+
* This is required to prevent you from creating duplicate schedules. */
|
|
820
|
+
deduplicationKey: z.string(),
|
|
782
821
|
/** Optionally, you can specify your own IDs (like a user ID) and then use it inside the run function of your task.
|
|
783
822
|
*
|
|
784
823
|
* This allows you to have per-user CRON tasks.
|
|
785
824
|
*/
|
|
786
|
-
externalId: z.string().optional()
|
|
825
|
+
externalId: z.string().optional(),
|
|
826
|
+
/** Optionally, you can specify a timezone in the IANA format. If unset it will use UTC.
|
|
827
|
+
* If specified then the CRON will be evaluated in that timezone and will respect daylight savings.
|
|
828
|
+
*
|
|
829
|
+
* 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.
|
|
830
|
+
*
|
|
831
|
+
* You can see the full list of supported timezones here: https://cloud.trigger.dev/timezones
|
|
832
|
+
*
|
|
833
|
+
* @example "America/New_York", "Europe/London", "Asia/Tokyo", "Africa/Cairo"
|
|
834
|
+
*
|
|
835
|
+
*/
|
|
836
|
+
timezone: z.string().optional()
|
|
837
|
+
});
|
|
838
|
+
var UpdateScheduleOptions = CreateScheduleOptions.omit({
|
|
839
|
+
deduplicationKey: true
|
|
787
840
|
});
|
|
788
|
-
var UpdateScheduleOptions = CreateScheduleOptions;
|
|
789
841
|
var ScheduleGenerator = z.object({
|
|
790
842
|
type: z.literal("CRON"),
|
|
791
843
|
expression: z.string(),
|
|
@@ -798,6 +850,7 @@ var ScheduleObject = z.object({
|
|
|
798
850
|
deduplicationKey: z.string().nullish(),
|
|
799
851
|
externalId: z.string().nullish(),
|
|
800
852
|
generator: ScheduleGenerator,
|
|
853
|
+
timezone: z.string(),
|
|
801
854
|
nextRun: z.coerce.date().nullish(),
|
|
802
855
|
environments: z.array(z.object({
|
|
803
856
|
id: z.string(),
|
|
@@ -820,6 +873,9 @@ var ListScheduleOptions = z.object({
|
|
|
820
873
|
page: z.number().optional(),
|
|
821
874
|
perPage: z.number().optional()
|
|
822
875
|
});
|
|
876
|
+
var TimezonesResult = z.object({
|
|
877
|
+
timezones: z.array(z.string())
|
|
878
|
+
});
|
|
823
879
|
var RunStatus = z.enum([
|
|
824
880
|
/// Task hasn't been deployed yet but is waiting to be executed
|
|
825
881
|
"WAITING_FOR_DEPLOY",
|
|
@@ -943,7 +999,7 @@ var BackgroundWorkerServerMessages = z.discriminatedUnion("type", [
|
|
|
943
999
|
type: z.literal("SCHEDULE_ATTEMPT"),
|
|
944
1000
|
image: z.string(),
|
|
945
1001
|
version: z.string(),
|
|
946
|
-
machine:
|
|
1002
|
+
machine: MachinePreset,
|
|
947
1003
|
// identifiers
|
|
948
1004
|
id: z.string().optional(),
|
|
949
1005
|
envId: z.string(),
|
|
@@ -1242,20 +1298,13 @@ var ProviderToPlatformMessages = {
|
|
|
1242
1298
|
error: z.object({
|
|
1243
1299
|
name: z.string(),
|
|
1244
1300
|
message: z.string(),
|
|
1245
|
-
stack: z.string().optional()
|
|
1301
|
+
stack: z.string().optional(),
|
|
1302
|
+
stderr: z.string().optional()
|
|
1246
1303
|
})
|
|
1247
1304
|
})
|
|
1248
1305
|
}
|
|
1249
1306
|
};
|
|
1250
1307
|
var PlatformToProviderMessages = {
|
|
1251
|
-
HEALTH: {
|
|
1252
|
-
message: z.object({
|
|
1253
|
-
version: z.literal("v1").default("v1")
|
|
1254
|
-
}),
|
|
1255
|
-
callback: z.object({
|
|
1256
|
-
status: z.literal("ok")
|
|
1257
|
-
})
|
|
1258
|
-
},
|
|
1259
1308
|
INDEX: {
|
|
1260
1309
|
message: z.object({
|
|
1261
1310
|
version: z.literal("v1").default("v1"),
|
|
@@ -1276,7 +1325,8 @@ var PlatformToProviderMessages = {
|
|
|
1276
1325
|
error: z.object({
|
|
1277
1326
|
name: z.string(),
|
|
1278
1327
|
message: z.string(),
|
|
1279
|
-
stack: z.string().optional()
|
|
1328
|
+
stack: z.string().optional(),
|
|
1329
|
+
stderr: z.string().optional()
|
|
1280
1330
|
})
|
|
1281
1331
|
}),
|
|
1282
1332
|
z.object({
|
|
@@ -1284,7 +1334,6 @@ var PlatformToProviderMessages = {
|
|
|
1284
1334
|
})
|
|
1285
1335
|
])
|
|
1286
1336
|
},
|
|
1287
|
-
// TODO: this should be a shared queue message instead
|
|
1288
1337
|
RESTORE: {
|
|
1289
1338
|
message: z.object({
|
|
1290
1339
|
version: z.literal("v1").default("v1"),
|
|
@@ -1295,7 +1344,7 @@ var PlatformToProviderMessages = {
|
|
|
1295
1344
|
location: z.string(),
|
|
1296
1345
|
reason: z.string().optional(),
|
|
1297
1346
|
imageRef: z.string(),
|
|
1298
|
-
machine:
|
|
1347
|
+
machine: MachinePreset,
|
|
1299
1348
|
// identifiers
|
|
1300
1349
|
checkpointId: z.string(),
|
|
1301
1350
|
envId: z.string(),
|
|
@@ -1304,21 +1353,6 @@ var PlatformToProviderMessages = {
|
|
|
1304
1353
|
projectId: z.string(),
|
|
1305
1354
|
runId: z.string()
|
|
1306
1355
|
})
|
|
1307
|
-
},
|
|
1308
|
-
DELETE: {
|
|
1309
|
-
message: z.object({
|
|
1310
|
-
version: z.literal("v1").default("v1"),
|
|
1311
|
-
name: z.string()
|
|
1312
|
-
}),
|
|
1313
|
-
callback: z.object({
|
|
1314
|
-
message: z.string()
|
|
1315
|
-
})
|
|
1316
|
-
},
|
|
1317
|
-
GET: {
|
|
1318
|
-
message: z.object({
|
|
1319
|
-
version: z.literal("v1").default("v1"),
|
|
1320
|
-
name: z.string()
|
|
1321
|
-
})
|
|
1322
1356
|
}
|
|
1323
1357
|
};
|
|
1324
1358
|
var CreateWorkerMessage = z.object({
|
|
@@ -1481,7 +1515,8 @@ var CoordinatorToPlatformMessages = {
|
|
|
1481
1515
|
error: z.object({
|
|
1482
1516
|
name: z.string(),
|
|
1483
1517
|
message: z.string(),
|
|
1484
|
-
stack: z.string().optional()
|
|
1518
|
+
stack: z.string().optional(),
|
|
1519
|
+
stderr: z.string().optional()
|
|
1485
1520
|
})
|
|
1486
1521
|
})
|
|
1487
1522
|
},
|
|
@@ -1719,7 +1754,8 @@ var ProdWorkerToCoordinatorMessages = {
|
|
|
1719
1754
|
error: z.object({
|
|
1720
1755
|
name: z.string(),
|
|
1721
1756
|
message: z.string(),
|
|
1722
|
-
stack: z.string().optional()
|
|
1757
|
+
stack: z.string().optional(),
|
|
1758
|
+
stderr: z.string().optional()
|
|
1723
1759
|
})
|
|
1724
1760
|
})
|
|
1725
1761
|
},
|
|
@@ -2058,6 +2094,10 @@ var SemanticInternalAttributes = {
|
|
|
2058
2094
|
TASK_EXPORT_NAME: "ctx.task.exportName",
|
|
2059
2095
|
QUEUE_NAME: "ctx.queue.name",
|
|
2060
2096
|
QUEUE_ID: "ctx.queue.id",
|
|
2097
|
+
MACHINE_PRESET_NAME: "ctx.machine.name",
|
|
2098
|
+
MACHINE_PRESET_CPU: "ctx.machine.cpu",
|
|
2099
|
+
MACHINE_PRESET_MEMORY: "ctx.machine.memory",
|
|
2100
|
+
MACHINE_PRESET_CENTS_PER_MS: "ctx.machine.centsPerMs",
|
|
2061
2101
|
SPAN_PARTIAL: "$span.partial",
|
|
2062
2102
|
SPAN_ID: "$span.span_id",
|
|
2063
2103
|
OUTPUT: "$output",
|
|
@@ -2081,7 +2121,9 @@ var SemanticInternalAttributes = {
|
|
|
2081
2121
|
RETRY_DELAY: "retry.delay",
|
|
2082
2122
|
RETRY_COUNT: "retry.count",
|
|
2083
2123
|
LINK_TITLE: "$link.title",
|
|
2084
|
-
IDEMPOTENCY_KEY: "ctx.run.idempotencyKey"
|
|
2124
|
+
IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
|
|
2125
|
+
USAGE_DURATION_MS: "$usage.durationMs",
|
|
2126
|
+
USAGE_COST_IN_CENTS: "$usage.costInCents"
|
|
2085
2127
|
};
|
|
2086
2128
|
|
|
2087
2129
|
// src/v3/taskContext/index.ts
|
|
@@ -2145,7 +2187,11 @@ var _TaskContextAPI = class _TaskContextAPI {
|
|
|
2145
2187
|
[SemanticInternalAttributes.ORGANIZATION_SLUG]: this.ctx.organization.slug,
|
|
2146
2188
|
[SemanticInternalAttributes.ORGANIZATION_NAME]: this.ctx.organization.name,
|
|
2147
2189
|
[SemanticInternalAttributes.BATCH_ID]: this.ctx.batch?.id,
|
|
2148
|
-
[SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey
|
|
2190
|
+
[SemanticInternalAttributes.IDEMPOTENCY_KEY]: this.ctx.run.idempotencyKey,
|
|
2191
|
+
[SemanticInternalAttributes.MACHINE_PRESET_NAME]: this.ctx.machine?.name,
|
|
2192
|
+
[SemanticInternalAttributes.MACHINE_PRESET_CPU]: this.ctx.machine?.cpu,
|
|
2193
|
+
[SemanticInternalAttributes.MACHINE_PRESET_MEMORY]: this.ctx.machine?.memory,
|
|
2194
|
+
[SemanticInternalAttributes.MACHINE_PRESET_CENTS_PER_MS]: this.ctx.machine?.centsPerMs
|
|
2149
2195
|
};
|
|
2150
2196
|
}
|
|
2151
2197
|
return {};
|
|
@@ -3513,8 +3559,77 @@ var _NoopRuntimeManager = class _NoopRuntimeManager {
|
|
|
3513
3559
|
__name(_NoopRuntimeManager, "NoopRuntimeManager");
|
|
3514
3560
|
var NoopRuntimeManager = _NoopRuntimeManager;
|
|
3515
3561
|
|
|
3562
|
+
// src/v3/usage/noopUsageManager.ts
|
|
3563
|
+
var _NoopUsageManager = class _NoopUsageManager {
|
|
3564
|
+
disable() {
|
|
3565
|
+
}
|
|
3566
|
+
start() {
|
|
3567
|
+
return {
|
|
3568
|
+
sample: () => ({
|
|
3569
|
+
cpuTime: 0,
|
|
3570
|
+
wallTime: 0
|
|
3571
|
+
})
|
|
3572
|
+
};
|
|
3573
|
+
}
|
|
3574
|
+
stop(measurement) {
|
|
3575
|
+
return measurement.sample();
|
|
3576
|
+
}
|
|
3577
|
+
pauseAsync(cb) {
|
|
3578
|
+
return cb();
|
|
3579
|
+
}
|
|
3580
|
+
sample() {
|
|
3581
|
+
return void 0;
|
|
3582
|
+
}
|
|
3583
|
+
};
|
|
3584
|
+
__name(_NoopUsageManager, "NoopUsageManager");
|
|
3585
|
+
var NoopUsageManager = _NoopUsageManager;
|
|
3586
|
+
|
|
3587
|
+
// src/v3/usage/api.ts
|
|
3588
|
+
var API_NAME4 = "usage";
|
|
3589
|
+
var NOOP_USAGE_MANAGER = new NoopUsageManager();
|
|
3590
|
+
var _getUsageManager, getUsageManager_fn;
|
|
3591
|
+
var _UsageAPI = class _UsageAPI {
|
|
3592
|
+
constructor() {
|
|
3593
|
+
__privateAdd(this, _getUsageManager);
|
|
3594
|
+
}
|
|
3595
|
+
static getInstance() {
|
|
3596
|
+
if (!this._instance) {
|
|
3597
|
+
this._instance = new _UsageAPI();
|
|
3598
|
+
}
|
|
3599
|
+
return this._instance;
|
|
3600
|
+
}
|
|
3601
|
+
setGlobalUsageManager(manager) {
|
|
3602
|
+
return registerGlobal(API_NAME4, manager);
|
|
3603
|
+
}
|
|
3604
|
+
disable() {
|
|
3605
|
+
__privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).disable();
|
|
3606
|
+
unregisterGlobal(API_NAME4);
|
|
3607
|
+
}
|
|
3608
|
+
start() {
|
|
3609
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).start();
|
|
3610
|
+
}
|
|
3611
|
+
stop(measurement) {
|
|
3612
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).stop(measurement);
|
|
3613
|
+
}
|
|
3614
|
+
pauseAsync(cb) {
|
|
3615
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).pauseAsync(cb);
|
|
3616
|
+
}
|
|
3617
|
+
sample() {
|
|
3618
|
+
return __privateMethod(this, _getUsageManager, getUsageManager_fn).call(this).sample();
|
|
3619
|
+
}
|
|
3620
|
+
};
|
|
3621
|
+
_getUsageManager = new WeakSet();
|
|
3622
|
+
getUsageManager_fn = /* @__PURE__ */ __name(function() {
|
|
3623
|
+
return getGlobal(API_NAME4) ?? NOOP_USAGE_MANAGER;
|
|
3624
|
+
}, "#getUsageManager");
|
|
3625
|
+
__name(_UsageAPI, "UsageAPI");
|
|
3626
|
+
var UsageAPI = _UsageAPI;
|
|
3627
|
+
|
|
3628
|
+
// src/v3/usage-api.ts
|
|
3629
|
+
var usage = UsageAPI.getInstance();
|
|
3630
|
+
|
|
3516
3631
|
// src/v3/runtime/index.ts
|
|
3517
|
-
var
|
|
3632
|
+
var API_NAME5 = "runtime";
|
|
3518
3633
|
var NOOP_RUNTIME_MANAGER = new NoopRuntimeManager();
|
|
3519
3634
|
var _getRuntimeManager, getRuntimeManager_fn;
|
|
3520
3635
|
var _RuntimeAPI = class _RuntimeAPI {
|
|
@@ -3528,28 +3643,28 @@ var _RuntimeAPI = class _RuntimeAPI {
|
|
|
3528
3643
|
return this._instance;
|
|
3529
3644
|
}
|
|
3530
3645
|
waitForDuration(ms) {
|
|
3531
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms);
|
|
3646
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForDuration(ms));
|
|
3532
3647
|
}
|
|
3533
3648
|
waitUntil(date) {
|
|
3534
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date);
|
|
3649
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitUntil(date));
|
|
3535
3650
|
}
|
|
3536
3651
|
waitForTask(params) {
|
|
3537
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params);
|
|
3652
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForTask(params));
|
|
3538
3653
|
}
|
|
3539
3654
|
waitForBatch(params) {
|
|
3540
|
-
return __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params);
|
|
3655
|
+
return usage.pauseAsync(() => __privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).waitForBatch(params));
|
|
3541
3656
|
}
|
|
3542
3657
|
setGlobalRuntimeManager(runtimeManager) {
|
|
3543
|
-
return registerGlobal(
|
|
3658
|
+
return registerGlobal(API_NAME5, runtimeManager);
|
|
3544
3659
|
}
|
|
3545
3660
|
disable() {
|
|
3546
3661
|
__privateMethod(this, _getRuntimeManager, getRuntimeManager_fn).call(this).disable();
|
|
3547
|
-
unregisterGlobal(
|
|
3662
|
+
unregisterGlobal(API_NAME5);
|
|
3548
3663
|
}
|
|
3549
3664
|
};
|
|
3550
3665
|
_getRuntimeManager = new WeakSet();
|
|
3551
3666
|
getRuntimeManager_fn = /* @__PURE__ */ __name(function() {
|
|
3552
|
-
return getGlobal(
|
|
3667
|
+
return getGlobal(API_NAME5) ?? NOOP_RUNTIME_MANAGER;
|
|
3553
3668
|
}, "#getRuntimeManager");
|
|
3554
3669
|
__name(_RuntimeAPI, "RuntimeAPI");
|
|
3555
3670
|
var RuntimeAPI = _RuntimeAPI;
|
|
@@ -3566,7 +3681,7 @@ function getEnvVar(name) {
|
|
|
3566
3681
|
__name(getEnvVar, "getEnvVar");
|
|
3567
3682
|
|
|
3568
3683
|
// src/v3/apiClientManager/index.ts
|
|
3569
|
-
var
|
|
3684
|
+
var API_NAME6 = "api-client";
|
|
3570
3685
|
var _getConfig, getConfig_fn;
|
|
3571
3686
|
var _APIClientManagerAPI = class _APIClientManagerAPI {
|
|
3572
3687
|
constructor() {
|
|
@@ -3579,10 +3694,10 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
|
|
|
3579
3694
|
return this._instance;
|
|
3580
3695
|
}
|
|
3581
3696
|
disable() {
|
|
3582
|
-
unregisterGlobal(
|
|
3697
|
+
unregisterGlobal(API_NAME6);
|
|
3583
3698
|
}
|
|
3584
3699
|
setGlobalAPIClientConfiguration(config) {
|
|
3585
|
-
return registerGlobal(
|
|
3700
|
+
return registerGlobal(API_NAME6, config);
|
|
3586
3701
|
}
|
|
3587
3702
|
get baseURL() {
|
|
3588
3703
|
const store = __privateMethod(this, _getConfig, getConfig_fn).call(this);
|
|
@@ -3601,7 +3716,7 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
|
|
|
3601
3716
|
};
|
|
3602
3717
|
_getConfig = new WeakSet();
|
|
3603
3718
|
getConfig_fn = /* @__PURE__ */ __name(function() {
|
|
3604
|
-
return getGlobal(
|
|
3719
|
+
return getGlobal(API_NAME6);
|
|
3605
3720
|
}, "#getConfig");
|
|
3606
3721
|
__name(_APIClientManagerAPI, "APIClientManagerAPI");
|
|
3607
3722
|
var APIClientManagerAPI = _APIClientManagerAPI;
|
|
@@ -3636,7 +3751,7 @@ __name(_NoopTaskCatalog, "NoopTaskCatalog");
|
|
|
3636
3751
|
var NoopTaskCatalog = _NoopTaskCatalog;
|
|
3637
3752
|
|
|
3638
3753
|
// src/v3/task-catalog/index.ts
|
|
3639
|
-
var
|
|
3754
|
+
var API_NAME7 = "task-catalog";
|
|
3640
3755
|
var NOOP_TASK_CATALOG = new NoopTaskCatalog();
|
|
3641
3756
|
var _getCatalog, getCatalog_fn;
|
|
3642
3757
|
var _TaskCatalogAPI = class _TaskCatalogAPI {
|
|
@@ -3650,10 +3765,10 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
|
|
|
3650
3765
|
return this._instance;
|
|
3651
3766
|
}
|
|
3652
3767
|
setGlobalTaskCatalog(taskCatalog2) {
|
|
3653
|
-
return registerGlobal(
|
|
3768
|
+
return registerGlobal(API_NAME7, taskCatalog2);
|
|
3654
3769
|
}
|
|
3655
3770
|
disable() {
|
|
3656
|
-
unregisterGlobal(
|
|
3771
|
+
unregisterGlobal(API_NAME7);
|
|
3657
3772
|
}
|
|
3658
3773
|
registerTaskMetadata(task) {
|
|
3659
3774
|
__privateMethod(this, _getCatalog, getCatalog_fn).call(this).registerTaskMetadata(task);
|
|
@@ -3679,7 +3794,7 @@ var _TaskCatalogAPI = class _TaskCatalogAPI {
|
|
|
3679
3794
|
};
|
|
3680
3795
|
_getCatalog = new WeakSet();
|
|
3681
3796
|
getCatalog_fn = /* @__PURE__ */ __name(function() {
|
|
3682
|
-
return getGlobal(
|
|
3797
|
+
return getGlobal(API_NAME7) ?? NOOP_TASK_CATALOG;
|
|
3683
3798
|
}, "#getCatalog");
|
|
3684
3799
|
__name(_TaskCatalogAPI, "TaskCatalogAPI");
|
|
3685
3800
|
var TaskCatalogAPI = _TaskCatalogAPI;
|
|
@@ -3799,6 +3914,7 @@ var _TriggerTracer = class _TriggerTracer {
|
|
|
3799
3914
|
[SemanticInternalAttributes.SPAN_ID]: span.spanContext().spanId
|
|
3800
3915
|
}
|
|
3801
3916
|
}, parentContext).end();
|
|
3917
|
+
const usageMeasurement = usage.start();
|
|
3802
3918
|
try {
|
|
3803
3919
|
return await fn(span);
|
|
3804
3920
|
} catch (e) {
|
|
@@ -3810,6 +3926,12 @@ var _TriggerTracer = class _TriggerTracer {
|
|
|
3810
3926
|
});
|
|
3811
3927
|
throw e;
|
|
3812
3928
|
} finally {
|
|
3929
|
+
const usageSample = usage.stop(usageMeasurement);
|
|
3930
|
+
const machine = taskContext.ctx?.machine;
|
|
3931
|
+
span.setAttributes({
|
|
3932
|
+
[SemanticInternalAttributes.USAGE_DURATION_MS]: usageSample.cpuTime,
|
|
3933
|
+
[SemanticInternalAttributes.USAGE_COST_IN_CENTS]: machine?.centsPerMs ? usageSample.cpuTime * machine.centsPerMs : 0
|
|
3934
|
+
});
|
|
3813
3935
|
span.end(clock.preciseNow());
|
|
3814
3936
|
}
|
|
3815
3937
|
});
|
|
@@ -4282,6 +4404,6 @@ function safeJsonParse2(value) {
|
|
|
4282
4404
|
}
|
|
4283
4405
|
__name(safeJsonParse2, "safeJsonParse");
|
|
4284
4406
|
|
|
4285
|
-
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,
|
|
4407
|
+
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 };
|
|
4286
4408
|
//# sourceMappingURL=out.js.map
|
|
4287
4409
|
//# sourceMappingURL=index.mjs.map
|