@trigger.dev/core 3.0.0-beta.33 → 3.0.0-beta.34
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-ck7x04PV.d.mts → catalog-Y8FyPWvh.d.mts} +15 -1
- package/dist/{catalog-KbyTBoap.d.ts → catalog-tX1P4jZQ.d.ts} +15 -1
- package/dist/index.d.mts +60 -1
- package/dist/index.d.ts +60 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/dist/index.mjs.map +1 -1
- package/dist/v3/index.d.mts +142 -3
- package/dist/v3/index.d.ts +142 -3
- package/dist/v3/index.js +495 -304
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +489 -305
- package/dist/v3/index.mjs.map +1 -1
- package/dist/v3/otel/index.js +5 -1
- package/dist/v3/otel/index.js.map +1 -1
- package/dist/v3/otel/index.mjs +5 -1
- package/dist/v3/otel/index.mjs.map +1 -1
- package/dist/v3/workers/index.d.mts +2 -2
- package/dist/v3/workers/index.d.ts +2 -2
- package/dist/v3/workers/index.js +191 -7
- package/dist/v3/workers/index.js.map +1 -1
- package/dist/v3/workers/index.mjs +191 -7
- package/dist/v3/workers/index.mjs.map +1 -1
- package/dist/v3/zodMessageHandler.d.mts +1 -1
- package/dist/v3/zodMessageHandler.d.ts +1 -1
- package/package.json +5 -4
package/dist/v3/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { propagation, context, trace, SpanStatusCode } from '@opentelemetry/api';
|
|
2
|
-
import { fromZodError } from 'zod-validation-error';
|
|
3
2
|
import { z } from 'zod';
|
|
3
|
+
import { fromZodError } from 'zod-validation-error';
|
|
4
|
+
import { FormDataEncoder } from 'form-data-encoder';
|
|
5
|
+
import { Readable } from 'stream';
|
|
4
6
|
import { PreciseDate } from '@google-cloud/precise-date';
|
|
5
7
|
import { logs } from '@opentelemetry/api-logs';
|
|
6
8
|
import humanizeDuration from 'humanize-duration';
|
|
@@ -26,6 +28,31 @@ var __privateMethod = (obj, member, method) => {
|
|
|
26
28
|
return method;
|
|
27
29
|
};
|
|
28
30
|
|
|
31
|
+
// package.json
|
|
32
|
+
var version = "3.0.0-beta.34";
|
|
33
|
+
var dependencies = {
|
|
34
|
+
"@google-cloud/precise-date": "^4.0.0",
|
|
35
|
+
"@opentelemetry/api": "^1.8.0",
|
|
36
|
+
"@opentelemetry/api-logs": "^0.48.0",
|
|
37
|
+
"@opentelemetry/exporter-logs-otlp-http": "^0.49.1",
|
|
38
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.49.1",
|
|
39
|
+
"@opentelemetry/instrumentation": "^0.49.1",
|
|
40
|
+
"@opentelemetry/resources": "^1.22.0",
|
|
41
|
+
"@opentelemetry/sdk-logs": "^0.49.1",
|
|
42
|
+
"@opentelemetry/sdk-node": "^0.49.1",
|
|
43
|
+
"@opentelemetry/sdk-trace-base": "^1.22.0",
|
|
44
|
+
"@opentelemetry/sdk-trace-node": "^1.22.0",
|
|
45
|
+
"@opentelemetry/semantic-conventions": "^1.22.0",
|
|
46
|
+
"form-data-encoder": "^4.0.2",
|
|
47
|
+
"humanize-duration": "^3.27.3",
|
|
48
|
+
"socket.io-client": "4.7.4",
|
|
49
|
+
superjson: "^2.2.1",
|
|
50
|
+
ulidx: "^2.2.1",
|
|
51
|
+
zod: "3.22.3",
|
|
52
|
+
"zod-error": "1.5.0",
|
|
53
|
+
"zod-validation-error": "^1.5.0"
|
|
54
|
+
};
|
|
55
|
+
|
|
29
56
|
// src/v3/apiErrors.ts
|
|
30
57
|
var _APIError = class _APIError extends Error {
|
|
31
58
|
constructor(status, error, message, headers) {
|
|
@@ -163,286 +190,45 @@ function castToError(err) {
|
|
|
163
190
|
return new Error(err);
|
|
164
191
|
}
|
|
165
192
|
__name(castToError, "castToError");
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
function calculateISO8601ResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
206
|
-
if (!resets)
|
|
207
|
-
return void 0;
|
|
208
|
-
const resetAt = new Date(resets);
|
|
209
|
-
if (isNaN(resetAt.getTime()))
|
|
210
|
-
return void 0;
|
|
211
|
-
return resetAt;
|
|
212
|
-
}
|
|
213
|
-
__name(calculateISO8601ResetAt, "calculateISO8601ResetAt");
|
|
214
|
-
function calculateISO8601DurationOpenAIVariantResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
215
|
-
if (!resets)
|
|
216
|
-
return void 0;
|
|
217
|
-
const pattern = /^(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)ms)?$/;
|
|
218
|
-
const match = resets.match(pattern);
|
|
219
|
-
if (!match)
|
|
220
|
-
return void 0;
|
|
221
|
-
const days = parseInt(match[1], 10) || 0;
|
|
222
|
-
const hours = parseInt(match[2], 10) || 0;
|
|
223
|
-
const minutes = parseInt(match[3], 10) || 0;
|
|
224
|
-
const seconds = parseFloat(match[4]) || 0;
|
|
225
|
-
const milliseconds = parseInt(match[5], 10) || 0;
|
|
226
|
-
const resetAt = new Date(now);
|
|
227
|
-
resetAt.setDate(resetAt.getDate() + days);
|
|
228
|
-
resetAt.setHours(resetAt.getHours() + hours);
|
|
229
|
-
resetAt.setMinutes(resetAt.getMinutes() + minutes);
|
|
230
|
-
resetAt.setSeconds(resetAt.getSeconds() + Math.floor(seconds));
|
|
231
|
-
resetAt.setMilliseconds(resetAt.getMilliseconds() + (seconds - Math.floor(seconds)) * 1e3 + milliseconds);
|
|
232
|
-
return resetAt;
|
|
233
|
-
}
|
|
234
|
-
__name(calculateISO8601DurationOpenAIVariantResetAt, "calculateISO8601DurationOpenAIVariantResetAt");
|
|
235
|
-
|
|
236
|
-
// src/v3/utils/retries.ts
|
|
237
|
-
var defaultRetryOptions = {
|
|
238
|
-
maxAttempts: 3,
|
|
239
|
-
factor: 2,
|
|
240
|
-
minTimeoutInMs: 1e3,
|
|
241
|
-
maxTimeoutInMs: 6e4,
|
|
242
|
-
randomize: true
|
|
243
|
-
};
|
|
244
|
-
var defaultFetchRetryOptions = {
|
|
245
|
-
byStatus: {
|
|
246
|
-
"429,408,409,5xx": {
|
|
247
|
-
strategy: "backoff",
|
|
248
|
-
...defaultRetryOptions
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
connectionError: defaultRetryOptions,
|
|
252
|
-
timeout: defaultRetryOptions
|
|
253
|
-
};
|
|
254
|
-
function calculateNextRetryDelay(options, attempt) {
|
|
255
|
-
const opts = {
|
|
256
|
-
...defaultRetryOptions,
|
|
257
|
-
...options
|
|
258
|
-
};
|
|
259
|
-
if (attempt >= opts.maxAttempts) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
|
|
263
|
-
const random = randomize ? Math.random() + 1 : 1;
|
|
264
|
-
const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
|
|
265
|
-
return Math.round(timeout);
|
|
266
|
-
}
|
|
267
|
-
__name(calculateNextRetryDelay, "calculateNextRetryDelay");
|
|
268
|
-
function calculateResetAt2(resets, format, now = Date.now()) {
|
|
269
|
-
const resetAt = calculateResetAt(resets, format, new Date(now));
|
|
270
|
-
return resetAt?.getTime();
|
|
271
|
-
}
|
|
272
|
-
__name(calculateResetAt2, "calculateResetAt");
|
|
273
|
-
|
|
274
|
-
// src/v3/zodfetch.ts
|
|
275
|
-
var defaultRetryOptions2 = {
|
|
276
|
-
maxAttempts: 3,
|
|
277
|
-
factor: 2,
|
|
278
|
-
minTimeoutInMs: 1e3,
|
|
279
|
-
maxTimeoutInMs: 6e4,
|
|
280
|
-
randomize: false
|
|
281
|
-
};
|
|
282
|
-
async function zodfetch(schema, url, requestInit, options) {
|
|
283
|
-
return await _doZodFetch(schema, url, requestInit, options);
|
|
284
|
-
}
|
|
285
|
-
__name(zodfetch, "zodfetch");
|
|
286
|
-
async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
287
|
-
try {
|
|
288
|
-
const response = await fetch(url, requestInitWithCache(requestInit));
|
|
289
|
-
const responseHeaders = createResponseHeaders(response.headers);
|
|
290
|
-
if (!response.ok) {
|
|
291
|
-
const retryResult = shouldRetry(response, attempt, options?.retry);
|
|
292
|
-
if (retryResult.retry) {
|
|
293
|
-
await new Promise((resolve) => setTimeout(resolve, retryResult.delay));
|
|
294
|
-
return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
|
|
295
|
-
} else {
|
|
296
|
-
const errText = await response.text().catch((e) => castToError2(e).message);
|
|
297
|
-
const errJSON = safeJsonParse(errText);
|
|
298
|
-
const errMessage = errJSON ? void 0 : errText;
|
|
299
|
-
throw APIError.generate(response.status, errJSON, errMessage, responseHeaders);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
const jsonBody = await response.json();
|
|
303
|
-
const parsedResult = schema.safeParse(jsonBody);
|
|
304
|
-
if (parsedResult.success) {
|
|
305
|
-
return parsedResult.data;
|
|
306
|
-
}
|
|
307
|
-
throw fromZodError(parsedResult.error);
|
|
308
|
-
} catch (error) {
|
|
309
|
-
if (error instanceof APIError) {
|
|
310
|
-
throw error;
|
|
311
|
-
}
|
|
312
|
-
if (options?.retry) {
|
|
313
|
-
const retry = {
|
|
314
|
-
...defaultRetryOptions2,
|
|
315
|
-
...options.retry
|
|
316
|
-
};
|
|
317
|
-
const delay = calculateNextRetryDelay(retry, attempt);
|
|
318
|
-
if (delay) {
|
|
319
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
320
|
-
return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
throw new APIConnectionError({
|
|
324
|
-
cause: castToError2(error)
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
__name(_doZodFetch, "_doZodFetch");
|
|
329
|
-
function castToError2(err) {
|
|
330
|
-
if (err instanceof Error)
|
|
331
|
-
return err;
|
|
332
|
-
return new Error(err);
|
|
333
|
-
}
|
|
334
|
-
__name(castToError2, "castToError");
|
|
335
|
-
function shouldRetry(response, attempt, retryOptions) {
|
|
336
|
-
function shouldRetryForOptions() {
|
|
337
|
-
const retry = {
|
|
338
|
-
...defaultRetryOptions2,
|
|
339
|
-
...retryOptions
|
|
340
|
-
};
|
|
341
|
-
const delay = calculateNextRetryDelay(retry, attempt);
|
|
342
|
-
if (delay) {
|
|
343
|
-
return {
|
|
344
|
-
retry: true,
|
|
345
|
-
delay
|
|
346
|
-
};
|
|
347
|
-
} else {
|
|
348
|
-
return {
|
|
349
|
-
retry: false
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
__name(shouldRetryForOptions, "shouldRetryForOptions");
|
|
354
|
-
const shouldRetryHeader = response.headers.get("x-should-retry");
|
|
355
|
-
if (shouldRetryHeader === "true")
|
|
356
|
-
return shouldRetryForOptions();
|
|
357
|
-
if (shouldRetryHeader === "false")
|
|
358
|
-
return {
|
|
359
|
-
retry: false
|
|
360
|
-
};
|
|
361
|
-
if (response.status === 408)
|
|
362
|
-
return shouldRetryForOptions();
|
|
363
|
-
if (response.status === 409)
|
|
364
|
-
return shouldRetryForOptions();
|
|
365
|
-
if (response.status === 429)
|
|
366
|
-
return shouldRetryForOptions();
|
|
367
|
-
if (response.status >= 500)
|
|
368
|
-
return shouldRetryForOptions();
|
|
369
|
-
return {
|
|
370
|
-
retry: false
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
__name(shouldRetry, "shouldRetry");
|
|
374
|
-
function safeJsonParse(text) {
|
|
375
|
-
try {
|
|
376
|
-
return JSON.parse(text);
|
|
377
|
-
} catch (e) {
|
|
378
|
-
return void 0;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
__name(safeJsonParse, "safeJsonParse");
|
|
382
|
-
function createResponseHeaders(headers) {
|
|
383
|
-
return new Proxy(Object.fromEntries(
|
|
384
|
-
// @ts-ignore
|
|
385
|
-
headers.entries()
|
|
386
|
-
), {
|
|
387
|
-
get(target, name) {
|
|
388
|
-
const key = name.toString();
|
|
389
|
-
return target[key.toLowerCase()] || target[key];
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
__name(createResponseHeaders, "createResponseHeaders");
|
|
394
|
-
function requestInitWithCache(requestInit) {
|
|
395
|
-
try {
|
|
396
|
-
const withCache = {
|
|
397
|
-
...requestInit,
|
|
398
|
-
cache: "no-cache"
|
|
399
|
-
};
|
|
400
|
-
const _ = new Request("http://localhost", withCache);
|
|
401
|
-
return withCache;
|
|
402
|
-
} catch (error) {
|
|
403
|
-
return requestInit ?? {};
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
__name(requestInitWithCache, "requestInitWithCache");
|
|
407
|
-
var CreateAuthorizationCodeResponseSchema = z.object({
|
|
408
|
-
url: z.string().url(),
|
|
409
|
-
authorizationCode: z.string()
|
|
410
|
-
});
|
|
411
|
-
var GetPersonalAccessTokenRequestSchema = z.object({
|
|
412
|
-
authorizationCode: z.string()
|
|
413
|
-
});
|
|
414
|
-
var GetPersonalAccessTokenResponseSchema = z.object({
|
|
415
|
-
token: z.object({
|
|
416
|
-
token: z.string(),
|
|
417
|
-
obfuscatedToken: z.string()
|
|
418
|
-
}).nullable()
|
|
419
|
-
});
|
|
420
|
-
var TaskRunBuiltInError = z.object({
|
|
421
|
-
type: z.literal("BUILT_IN_ERROR"),
|
|
422
|
-
name: z.string(),
|
|
423
|
-
message: z.string(),
|
|
424
|
-
stackTrace: z.string()
|
|
425
|
-
});
|
|
426
|
-
var TaskRunCustomErrorObject = z.object({
|
|
427
|
-
type: z.literal("CUSTOM_ERROR"),
|
|
428
|
-
raw: z.string()
|
|
429
|
-
});
|
|
430
|
-
var TaskRunStringError = z.object({
|
|
431
|
-
type: z.literal("STRING_ERROR"),
|
|
432
|
-
raw: z.string()
|
|
433
|
-
});
|
|
434
|
-
var TaskRunErrorCodes = {
|
|
435
|
-
COULD_NOT_FIND_EXECUTOR: "COULD_NOT_FIND_EXECUTOR",
|
|
436
|
-
COULD_NOT_FIND_TASK: "COULD_NOT_FIND_TASK",
|
|
437
|
-
CONFIGURED_INCORRECTLY: "CONFIGURED_INCORRECTLY",
|
|
438
|
-
TASK_ALREADY_RUNNING: "TASK_ALREADY_RUNNING",
|
|
439
|
-
TASK_EXECUTION_FAILED: "TASK_EXECUTION_FAILED",
|
|
440
|
-
TASK_EXECUTION_ABORTED: "TASK_EXECUTION_ABORTED",
|
|
441
|
-
TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE: "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE",
|
|
442
|
-
TASK_RUN_CANCELLED: "TASK_RUN_CANCELLED",
|
|
443
|
-
TASK_OUTPUT_ERROR: "TASK_OUTPUT_ERROR",
|
|
444
|
-
HANDLE_ERROR_ERROR: "HANDLE_ERROR_ERROR",
|
|
445
|
-
GRACEFUL_EXIT_TIMEOUT: "GRACEFUL_EXIT_TIMEOUT"
|
|
193
|
+
var CreateAuthorizationCodeResponseSchema = z.object({
|
|
194
|
+
url: z.string().url(),
|
|
195
|
+
authorizationCode: z.string()
|
|
196
|
+
});
|
|
197
|
+
var GetPersonalAccessTokenRequestSchema = z.object({
|
|
198
|
+
authorizationCode: z.string()
|
|
199
|
+
});
|
|
200
|
+
var GetPersonalAccessTokenResponseSchema = z.object({
|
|
201
|
+
token: z.object({
|
|
202
|
+
token: z.string(),
|
|
203
|
+
obfuscatedToken: z.string()
|
|
204
|
+
}).nullable()
|
|
205
|
+
});
|
|
206
|
+
var TaskRunBuiltInError = z.object({
|
|
207
|
+
type: z.literal("BUILT_IN_ERROR"),
|
|
208
|
+
name: z.string(),
|
|
209
|
+
message: z.string(),
|
|
210
|
+
stackTrace: z.string()
|
|
211
|
+
});
|
|
212
|
+
var TaskRunCustomErrorObject = z.object({
|
|
213
|
+
type: z.literal("CUSTOM_ERROR"),
|
|
214
|
+
raw: z.string()
|
|
215
|
+
});
|
|
216
|
+
var TaskRunStringError = z.object({
|
|
217
|
+
type: z.literal("STRING_ERROR"),
|
|
218
|
+
raw: z.string()
|
|
219
|
+
});
|
|
220
|
+
var TaskRunErrorCodes = {
|
|
221
|
+
COULD_NOT_FIND_EXECUTOR: "COULD_NOT_FIND_EXECUTOR",
|
|
222
|
+
COULD_NOT_FIND_TASK: "COULD_NOT_FIND_TASK",
|
|
223
|
+
CONFIGURED_INCORRECTLY: "CONFIGURED_INCORRECTLY",
|
|
224
|
+
TASK_ALREADY_RUNNING: "TASK_ALREADY_RUNNING",
|
|
225
|
+
TASK_EXECUTION_FAILED: "TASK_EXECUTION_FAILED",
|
|
226
|
+
TASK_EXECUTION_ABORTED: "TASK_EXECUTION_ABORTED",
|
|
227
|
+
TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE: "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE",
|
|
228
|
+
TASK_RUN_CANCELLED: "TASK_RUN_CANCELLED",
|
|
229
|
+
TASK_OUTPUT_ERROR: "TASK_OUTPUT_ERROR",
|
|
230
|
+
HANDLE_ERROR_ERROR: "HANDLE_ERROR_ERROR",
|
|
231
|
+
GRACEFUL_EXIT_TIMEOUT: "GRACEFUL_EXIT_TIMEOUT"
|
|
446
232
|
};
|
|
447
233
|
var TaskRunInternalError = z.object({
|
|
448
234
|
type: z.literal("INTERNAL_ERROR"),
|
|
@@ -1038,6 +824,28 @@ var RetrieveRunResponse = z.object({
|
|
|
1038
824
|
completedAt: z.coerce.date().optional()
|
|
1039
825
|
}).optional())
|
|
1040
826
|
});
|
|
827
|
+
var CreateEnvironmentVariableRequestBody = z.object({
|
|
828
|
+
name: z.string(),
|
|
829
|
+
value: z.string()
|
|
830
|
+
});
|
|
831
|
+
var UpdateEnvironmentVariableRequestBody = z.object({
|
|
832
|
+
value: z.string()
|
|
833
|
+
});
|
|
834
|
+
var ImportEnvironmentVariablesRequestBody = z.object({
|
|
835
|
+
variables: z.record(z.string()),
|
|
836
|
+
override: z.boolean().optional()
|
|
837
|
+
});
|
|
838
|
+
var EnvironmentVariableResponseBody = z.object({
|
|
839
|
+
success: z.boolean()
|
|
840
|
+
});
|
|
841
|
+
var EnvironmentVariableValue = z.object({
|
|
842
|
+
value: z.string()
|
|
843
|
+
});
|
|
844
|
+
var EnvironmentVariable = z.object({
|
|
845
|
+
name: z.string(),
|
|
846
|
+
value: z.string()
|
|
847
|
+
});
|
|
848
|
+
var EnvironmentVariables = z.array(EnvironmentVariable);
|
|
1041
849
|
var BackgroundWorkerServerMessages = z.discriminatedUnion("type", [
|
|
1042
850
|
z.object({
|
|
1043
851
|
type: z.literal("EXECUTE_RUNS"),
|
|
@@ -2100,29 +1908,359 @@ var TaskContextAPI = _TaskContextAPI;
|
|
|
2100
1908
|
// src/v3/task-context-api.ts
|
|
2101
1909
|
var taskContext = TaskContextAPI.getInstance();
|
|
2102
1910
|
|
|
2103
|
-
//
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
1911
|
+
// src/retry.ts
|
|
1912
|
+
function calculateResetAt(resets, format, now = /* @__PURE__ */ new Date()) {
|
|
1913
|
+
if (!resets)
|
|
1914
|
+
return;
|
|
1915
|
+
switch (format) {
|
|
1916
|
+
case "iso_8601_duration_openai_variant": {
|
|
1917
|
+
return calculateISO8601DurationOpenAIVariantResetAt(resets, now);
|
|
1918
|
+
}
|
|
1919
|
+
case "iso_8601": {
|
|
1920
|
+
return calculateISO8601ResetAt(resets, now);
|
|
1921
|
+
}
|
|
1922
|
+
case "unix_timestamp": {
|
|
1923
|
+
return calculateUnixTimestampResetAt(resets, now);
|
|
1924
|
+
}
|
|
1925
|
+
case "unix_timestamp_in_ms": {
|
|
1926
|
+
return calculateUnixTimestampInMsResetAt(resets, now);
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
__name(calculateResetAt, "calculateResetAt");
|
|
1931
|
+
function calculateUnixTimestampResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
1932
|
+
if (!resets)
|
|
1933
|
+
return void 0;
|
|
1934
|
+
const resetAt = parseInt(resets, 10);
|
|
1935
|
+
if (isNaN(resetAt))
|
|
1936
|
+
return void 0;
|
|
1937
|
+
return new Date(resetAt * 1e3);
|
|
1938
|
+
}
|
|
1939
|
+
__name(calculateUnixTimestampResetAt, "calculateUnixTimestampResetAt");
|
|
1940
|
+
function calculateUnixTimestampInMsResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
1941
|
+
if (!resets)
|
|
1942
|
+
return void 0;
|
|
1943
|
+
const resetAt = parseInt(resets, 10);
|
|
1944
|
+
if (isNaN(resetAt))
|
|
1945
|
+
return void 0;
|
|
1946
|
+
return new Date(resetAt);
|
|
1947
|
+
}
|
|
1948
|
+
__name(calculateUnixTimestampInMsResetAt, "calculateUnixTimestampInMsResetAt");
|
|
1949
|
+
function calculateISO8601ResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
1950
|
+
if (!resets)
|
|
1951
|
+
return void 0;
|
|
1952
|
+
const resetAt = new Date(resets);
|
|
1953
|
+
if (isNaN(resetAt.getTime()))
|
|
1954
|
+
return void 0;
|
|
1955
|
+
return resetAt;
|
|
1956
|
+
}
|
|
1957
|
+
__name(calculateISO8601ResetAt, "calculateISO8601ResetAt");
|
|
1958
|
+
function calculateISO8601DurationOpenAIVariantResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
1959
|
+
if (!resets)
|
|
1960
|
+
return void 0;
|
|
1961
|
+
const pattern = /^(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)ms)?$/;
|
|
1962
|
+
const match = resets.match(pattern);
|
|
1963
|
+
if (!match)
|
|
1964
|
+
return void 0;
|
|
1965
|
+
const days = parseInt(match[1], 10) || 0;
|
|
1966
|
+
const hours = parseInt(match[2], 10) || 0;
|
|
1967
|
+
const minutes = parseInt(match[3], 10) || 0;
|
|
1968
|
+
const seconds = parseFloat(match[4]) || 0;
|
|
1969
|
+
const milliseconds = parseInt(match[5], 10) || 0;
|
|
1970
|
+
const resetAt = new Date(now);
|
|
1971
|
+
resetAt.setDate(resetAt.getDate() + days);
|
|
1972
|
+
resetAt.setHours(resetAt.getHours() + hours);
|
|
1973
|
+
resetAt.setMinutes(resetAt.getMinutes() + minutes);
|
|
1974
|
+
resetAt.setSeconds(resetAt.getSeconds() + Math.floor(seconds));
|
|
1975
|
+
resetAt.setMilliseconds(resetAt.getMilliseconds() + (seconds - Math.floor(seconds)) * 1e3 + milliseconds);
|
|
1976
|
+
return resetAt;
|
|
1977
|
+
}
|
|
1978
|
+
__name(calculateISO8601DurationOpenAIVariantResetAt, "calculateISO8601DurationOpenAIVariantResetAt");
|
|
1979
|
+
|
|
1980
|
+
// src/v3/utils/retries.ts
|
|
1981
|
+
var defaultRetryOptions = {
|
|
1982
|
+
maxAttempts: 3,
|
|
1983
|
+
factor: 2,
|
|
1984
|
+
minTimeoutInMs: 1e3,
|
|
1985
|
+
maxTimeoutInMs: 6e4,
|
|
1986
|
+
randomize: true
|
|
1987
|
+
};
|
|
1988
|
+
var defaultFetchRetryOptions = {
|
|
1989
|
+
byStatus: {
|
|
1990
|
+
"429,408,409,5xx": {
|
|
1991
|
+
strategy: "backoff",
|
|
1992
|
+
...defaultRetryOptions
|
|
1993
|
+
}
|
|
1994
|
+
},
|
|
1995
|
+
connectionError: defaultRetryOptions,
|
|
1996
|
+
timeout: defaultRetryOptions
|
|
2125
1997
|
};
|
|
1998
|
+
function calculateNextRetryDelay(options, attempt) {
|
|
1999
|
+
const opts = {
|
|
2000
|
+
...defaultRetryOptions,
|
|
2001
|
+
...options
|
|
2002
|
+
};
|
|
2003
|
+
if (attempt >= opts.maxAttempts) {
|
|
2004
|
+
return;
|
|
2005
|
+
}
|
|
2006
|
+
const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
|
|
2007
|
+
const random = randomize ? Math.random() + 1 : 1;
|
|
2008
|
+
const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
|
|
2009
|
+
return Math.round(timeout);
|
|
2010
|
+
}
|
|
2011
|
+
__name(calculateNextRetryDelay, "calculateNextRetryDelay");
|
|
2012
|
+
function calculateResetAt2(resets, format, now = Date.now()) {
|
|
2013
|
+
const resetAt = calculateResetAt(resets, format, new Date(now));
|
|
2014
|
+
return resetAt?.getTime();
|
|
2015
|
+
}
|
|
2016
|
+
__name(calculateResetAt2, "calculateResetAt");
|
|
2017
|
+
var defaultRetryOptions2 = {
|
|
2018
|
+
maxAttempts: 3,
|
|
2019
|
+
factor: 2,
|
|
2020
|
+
minTimeoutInMs: 1e3,
|
|
2021
|
+
maxTimeoutInMs: 6e4,
|
|
2022
|
+
randomize: false
|
|
2023
|
+
};
|
|
2024
|
+
async function zodfetch(schema, url, requestInit, options) {
|
|
2025
|
+
return await _doZodFetch(schema, url, requestInit, options);
|
|
2026
|
+
}
|
|
2027
|
+
__name(zodfetch, "zodfetch");
|
|
2028
|
+
async function zodupload(schema, url, body, requestInit, options) {
|
|
2029
|
+
const form = await createForm(body);
|
|
2030
|
+
const encoder = new FormDataEncoder(form);
|
|
2031
|
+
const finalHeaders = {};
|
|
2032
|
+
for (const [key, value] of Object.entries(requestInit?.headers || {})) {
|
|
2033
|
+
finalHeaders[key] = value;
|
|
2034
|
+
}
|
|
2035
|
+
for (const [key, value] of Object.entries(encoder.headers)) {
|
|
2036
|
+
finalHeaders[key] = value;
|
|
2037
|
+
}
|
|
2038
|
+
finalHeaders["Content-Length"] = String(encoder.contentLength);
|
|
2039
|
+
const finalRequestInit = {
|
|
2040
|
+
...requestInit,
|
|
2041
|
+
headers: finalHeaders,
|
|
2042
|
+
body: Readable.from(encoder),
|
|
2043
|
+
// @ts-expect-error
|
|
2044
|
+
duplex: "half"
|
|
2045
|
+
};
|
|
2046
|
+
return await _doZodFetch(schema, url, finalRequestInit, options);
|
|
2047
|
+
}
|
|
2048
|
+
__name(zodupload, "zodupload");
|
|
2049
|
+
var createForm = /* @__PURE__ */ __name(async (body) => {
|
|
2050
|
+
const form = new FormData();
|
|
2051
|
+
await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
|
|
2052
|
+
return form;
|
|
2053
|
+
}, "createForm");
|
|
2054
|
+
async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
2055
|
+
try {
|
|
2056
|
+
const response = await fetch(url, requestInitWithCache(requestInit));
|
|
2057
|
+
const responseHeaders = createResponseHeaders(response.headers);
|
|
2058
|
+
if (!response.ok) {
|
|
2059
|
+
const retryResult = shouldRetry(response, attempt, options?.retry);
|
|
2060
|
+
if (retryResult.retry) {
|
|
2061
|
+
await new Promise((resolve) => setTimeout(resolve, retryResult.delay));
|
|
2062
|
+
return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
|
|
2063
|
+
} else {
|
|
2064
|
+
const errText = await response.text().catch((e) => castToError2(e).message);
|
|
2065
|
+
const errJSON = safeJsonParse(errText);
|
|
2066
|
+
const errMessage = errJSON ? void 0 : errText;
|
|
2067
|
+
throw APIError.generate(response.status, errJSON, errMessage, responseHeaders);
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
const jsonBody = await response.json();
|
|
2071
|
+
const parsedResult = schema.safeParse(jsonBody);
|
|
2072
|
+
if (parsedResult.success) {
|
|
2073
|
+
return parsedResult.data;
|
|
2074
|
+
}
|
|
2075
|
+
throw fromZodError(parsedResult.error);
|
|
2076
|
+
} catch (error) {
|
|
2077
|
+
if (error instanceof APIError) {
|
|
2078
|
+
throw error;
|
|
2079
|
+
}
|
|
2080
|
+
if (options?.retry) {
|
|
2081
|
+
const retry = {
|
|
2082
|
+
...defaultRetryOptions2,
|
|
2083
|
+
...options.retry
|
|
2084
|
+
};
|
|
2085
|
+
const delay = calculateNextRetryDelay(retry, attempt);
|
|
2086
|
+
if (delay) {
|
|
2087
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2088
|
+
return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
throw new APIConnectionError({
|
|
2092
|
+
cause: castToError2(error)
|
|
2093
|
+
});
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
__name(_doZodFetch, "_doZodFetch");
|
|
2097
|
+
function castToError2(err) {
|
|
2098
|
+
if (err instanceof Error)
|
|
2099
|
+
return err;
|
|
2100
|
+
return new Error(err);
|
|
2101
|
+
}
|
|
2102
|
+
__name(castToError2, "castToError");
|
|
2103
|
+
function shouldRetry(response, attempt, retryOptions) {
|
|
2104
|
+
function shouldRetryForOptions() {
|
|
2105
|
+
const retry = {
|
|
2106
|
+
...defaultRetryOptions2,
|
|
2107
|
+
...retryOptions
|
|
2108
|
+
};
|
|
2109
|
+
const delay = calculateNextRetryDelay(retry, attempt);
|
|
2110
|
+
if (delay) {
|
|
2111
|
+
return {
|
|
2112
|
+
retry: true,
|
|
2113
|
+
delay
|
|
2114
|
+
};
|
|
2115
|
+
} else {
|
|
2116
|
+
return {
|
|
2117
|
+
retry: false
|
|
2118
|
+
};
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
__name(shouldRetryForOptions, "shouldRetryForOptions");
|
|
2122
|
+
const shouldRetryHeader = response.headers.get("x-should-retry");
|
|
2123
|
+
if (shouldRetryHeader === "true")
|
|
2124
|
+
return shouldRetryForOptions();
|
|
2125
|
+
if (shouldRetryHeader === "false")
|
|
2126
|
+
return {
|
|
2127
|
+
retry: false
|
|
2128
|
+
};
|
|
2129
|
+
if (response.status === 408)
|
|
2130
|
+
return shouldRetryForOptions();
|
|
2131
|
+
if (response.status === 409)
|
|
2132
|
+
return shouldRetryForOptions();
|
|
2133
|
+
if (response.status === 429)
|
|
2134
|
+
return shouldRetryForOptions();
|
|
2135
|
+
if (response.status >= 500)
|
|
2136
|
+
return shouldRetryForOptions();
|
|
2137
|
+
return {
|
|
2138
|
+
retry: false
|
|
2139
|
+
};
|
|
2140
|
+
}
|
|
2141
|
+
__name(shouldRetry, "shouldRetry");
|
|
2142
|
+
function safeJsonParse(text) {
|
|
2143
|
+
try {
|
|
2144
|
+
return JSON.parse(text);
|
|
2145
|
+
} catch (e) {
|
|
2146
|
+
return void 0;
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
__name(safeJsonParse, "safeJsonParse");
|
|
2150
|
+
function createResponseHeaders(headers) {
|
|
2151
|
+
return new Proxy(Object.fromEntries(
|
|
2152
|
+
// @ts-ignore
|
|
2153
|
+
headers.entries()
|
|
2154
|
+
), {
|
|
2155
|
+
get(target, name) {
|
|
2156
|
+
const key = name.toString();
|
|
2157
|
+
return target[key.toLowerCase()] || target[key];
|
|
2158
|
+
}
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
__name(createResponseHeaders, "createResponseHeaders");
|
|
2162
|
+
function requestInitWithCache(requestInit) {
|
|
2163
|
+
try {
|
|
2164
|
+
const withCache = {
|
|
2165
|
+
...requestInit,
|
|
2166
|
+
cache: "no-cache"
|
|
2167
|
+
};
|
|
2168
|
+
const _ = new Request("http://localhost", withCache);
|
|
2169
|
+
return withCache;
|
|
2170
|
+
} catch (error) {
|
|
2171
|
+
return requestInit ?? {};
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
__name(requestInitWithCache, "requestInitWithCache");
|
|
2175
|
+
var addFormValue = /* @__PURE__ */ __name(async (form, key, value) => {
|
|
2176
|
+
if (value === void 0)
|
|
2177
|
+
return;
|
|
2178
|
+
if (value == null) {
|
|
2179
|
+
throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
|
|
2180
|
+
}
|
|
2181
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
2182
|
+
form.append(key, String(value));
|
|
2183
|
+
} else if (isUploadable(value) || isBlobLike(value) || value instanceof Buffer || value instanceof ArrayBuffer) {
|
|
2184
|
+
const file = await toFile(value);
|
|
2185
|
+
form.append(key, file);
|
|
2186
|
+
} else if (Array.isArray(value)) {
|
|
2187
|
+
await Promise.all(value.map((entry) => addFormValue(form, key + "[]", entry)));
|
|
2188
|
+
} else if (typeof value === "object") {
|
|
2189
|
+
await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
|
|
2190
|
+
} else {
|
|
2191
|
+
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
|
|
2192
|
+
}
|
|
2193
|
+
}, "addFormValue");
|
|
2194
|
+
async function toFile(value, name, options) {
|
|
2195
|
+
value = await value;
|
|
2196
|
+
options ??= isFileLike(value) ? {
|
|
2197
|
+
lastModified: value.lastModified,
|
|
2198
|
+
type: value.type
|
|
2199
|
+
} : {};
|
|
2200
|
+
if (isResponseLike(value)) {
|
|
2201
|
+
const blob = await value.blob();
|
|
2202
|
+
name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? "unknown_file";
|
|
2203
|
+
return new File([
|
|
2204
|
+
blob
|
|
2205
|
+
], name, options);
|
|
2206
|
+
}
|
|
2207
|
+
const bits = await getBytes(value);
|
|
2208
|
+
name ||= getName(value) ?? "unknown_file";
|
|
2209
|
+
if (!options.type) {
|
|
2210
|
+
const type = bits[0]?.type;
|
|
2211
|
+
if (typeof type === "string") {
|
|
2212
|
+
options = {
|
|
2213
|
+
...options,
|
|
2214
|
+
type
|
|
2215
|
+
};
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
return new File(bits, name, options);
|
|
2219
|
+
}
|
|
2220
|
+
__name(toFile, "toFile");
|
|
2221
|
+
function getName(value) {
|
|
2222
|
+
return getStringFromMaybeBuffer(value.name) || getStringFromMaybeBuffer(value.filename) || // For fs.ReadStream
|
|
2223
|
+
getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop();
|
|
2224
|
+
}
|
|
2225
|
+
__name(getName, "getName");
|
|
2226
|
+
var getStringFromMaybeBuffer = /* @__PURE__ */ __name((x) => {
|
|
2227
|
+
if (typeof x === "string")
|
|
2228
|
+
return x;
|
|
2229
|
+
if (typeof Buffer !== "undefined" && x instanceof Buffer)
|
|
2230
|
+
return String(x);
|
|
2231
|
+
return void 0;
|
|
2232
|
+
}, "getStringFromMaybeBuffer");
|
|
2233
|
+
async function getBytes(value) {
|
|
2234
|
+
let parts = [];
|
|
2235
|
+
if (typeof value === "string" || ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
|
|
2236
|
+
value instanceof ArrayBuffer) {
|
|
2237
|
+
parts.push(value);
|
|
2238
|
+
} else if (isBlobLike(value)) {
|
|
2239
|
+
parts.push(await value.arrayBuffer());
|
|
2240
|
+
} else if (isAsyncIterableIterator(value)) {
|
|
2241
|
+
for await (const chunk of value) {
|
|
2242
|
+
parts.push(chunk);
|
|
2243
|
+
}
|
|
2244
|
+
} else {
|
|
2245
|
+
throw new Error(`Unexpected data type: ${typeof value}; constructor: ${value?.constructor?.name}; props: ${propsForError(value)}`);
|
|
2246
|
+
}
|
|
2247
|
+
return parts;
|
|
2248
|
+
}
|
|
2249
|
+
__name(getBytes, "getBytes");
|
|
2250
|
+
function propsForError(value) {
|
|
2251
|
+
const props = Object.getOwnPropertyNames(value);
|
|
2252
|
+
return `[${props.map((p) => `"${p}"`).join(", ")}]`;
|
|
2253
|
+
}
|
|
2254
|
+
__name(propsForError, "propsForError");
|
|
2255
|
+
var isAsyncIterableIterator = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function", "isAsyncIterableIterator");
|
|
2256
|
+
var isResponseLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function", "isResponseLike");
|
|
2257
|
+
var isFileLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.name === "string" && typeof value.lastModified === "number" && isBlobLike(value), "isFileLike");
|
|
2258
|
+
var isBlobLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.size === "number" && typeof value.type === "string" && typeof value.text === "function" && typeof value.slice === "function" && typeof value.arrayBuffer === "function", "isBlobLike");
|
|
2259
|
+
var isFsReadStream = /* @__PURE__ */ __name((value) => value instanceof Readable, "isFsReadStream");
|
|
2260
|
+
var isUploadable = /* @__PURE__ */ __name((value) => {
|
|
2261
|
+
return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
|
|
2262
|
+
}, "isUploadable");
|
|
2263
|
+
var isRecordLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0 && Object.keys(value).every((key) => typeof key === "string" && typeof value[key] === "string"), "isRecordLike");
|
|
2126
2264
|
|
|
2127
2265
|
// src/v3/apiClient/index.ts
|
|
2128
2266
|
var zodFetchOptions = {
|
|
@@ -2257,6 +2395,52 @@ var _ApiClient = class _ApiClient {
|
|
|
2257
2395
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2258
2396
|
});
|
|
2259
2397
|
}
|
|
2398
|
+
listEnvVars(projectRef, slug) {
|
|
2399
|
+
return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
2400
|
+
method: "GET",
|
|
2401
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
importEnvVars(projectRef, slug, body) {
|
|
2405
|
+
if (isRecordLike(body.variables)) {
|
|
2406
|
+
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
|
|
2407
|
+
method: "POST",
|
|
2408
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2409
|
+
body: JSON.stringify(body)
|
|
2410
|
+
});
|
|
2411
|
+
} else {
|
|
2412
|
+
return zodupload(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, body, {
|
|
2413
|
+
method: "POST",
|
|
2414
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2415
|
+
});
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
retrieveEnvVar(projectRef, slug, key) {
|
|
2419
|
+
return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2420
|
+
method: "GET",
|
|
2421
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2422
|
+
});
|
|
2423
|
+
}
|
|
2424
|
+
createEnvVar(projectRef, slug, body) {
|
|
2425
|
+
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
2426
|
+
method: "POST",
|
|
2427
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2428
|
+
body: JSON.stringify(body)
|
|
2429
|
+
});
|
|
2430
|
+
}
|
|
2431
|
+
updateEnvVar(projectRef, slug, key, body) {
|
|
2432
|
+
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2433
|
+
method: "PUT",
|
|
2434
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2435
|
+
body: JSON.stringify(body)
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
deleteEnvVar(projectRef, slug, key) {
|
|
2439
|
+
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2440
|
+
method: "DELETE",
|
|
2441
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2442
|
+
});
|
|
2443
|
+
}
|
|
2260
2444
|
};
|
|
2261
2445
|
_getHeaders = new WeakSet();
|
|
2262
2446
|
getHeaders_fn = /* @__PURE__ */ __name(function(spanParentAsLink) {
|
|
@@ -2803,7 +2987,7 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
|
|
|
2803
2987
|
}
|
|
2804
2988
|
get accessToken() {
|
|
2805
2989
|
const store = __privateMethod(this, _getConfig, getConfig_fn).call(this);
|
|
2806
|
-
return store?.secretKey ?? getEnvVar("TRIGGER_SECRET_KEY");
|
|
2990
|
+
return store?.secretKey ?? getEnvVar("TRIGGER_SECRET_KEY") ?? getEnvVar("TRIGGER_ACCESS_TOKEN");
|
|
2807
2991
|
}
|
|
2808
2992
|
get client() {
|
|
2809
2993
|
if (!this.baseURL || !this.accessToken) {
|
|
@@ -3495,6 +3679,6 @@ function safeJsonParse2(value) {
|
|
|
3495
3679
|
}
|
|
3496
3680
|
__name(safeJsonParse2, "safeJsonParse");
|
|
3497
3681
|
|
|
3498
|
-
export { APIConnectionError, APIError, ApiClient, AttemptStatus, AuthenticationError, BackgroundWorkerClientMessages, BackgroundWorkerMetadata, BackgroundWorkerProperties, BackgroundWorkerServerMessages, BadRequestError, BatchTaskRunExecutionResult, BatchTriggerTaskRequestBody, BatchTriggerTaskResponse, CanceledRunResponse, CancellationSpanEvent, ClientToSharedQueueMessages, Config, ConflictError, CoordinatorToPlatformMessages, CoordinatorToProdWorkerMessages, CreateAuthorizationCodeResponseSchema, CreateBackgroundWorkerRequestBody, CreateBackgroundWorkerResponse, CreateScheduleOptions, CreateUploadPayloadUrlResponseBody, DeletedScheduleObject, DeploymentErrorData, EnvironmentType, EventFilter, ExceptionEventProperties, ExceptionSpanEvent, ExternalBuildData, FetchRetryBackoffStrategy, FetchRetryByStatusOptions, FetchRetryHeadersStrategy, FetchRetryOptions, FetchRetryStrategy, FetchTimeoutOptions, FixedWindowRateLimit, GetBatchResponseBody, GetDeploymentResponseBody, GetEnvironmentVariablesResponseBody, GetPersonalAccessTokenRequestSchema, GetPersonalAccessTokenResponseSchema, GetProjectEnvResponse, GetProjectResponseBody, GetProjectsResponseBody, ImageDetailsMetadata, InitializeDeploymentRequestBody, InitializeDeploymentResponseBody, InternalServerError, ListScheduleOptions, ListSchedulesResult, Machine, MachineCpu, MachineMemory, 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, OtherSpanEvent, PRIMARY_VARIANT, PermissionDeniedError, PlatformToCoordinatorMessages, PlatformToProviderMessages, PostStartCauses, PreStopCauses, ProdChildToWorkerMessages, ProdTaskRunExecution, ProdTaskRunExecutionPayload, ProdWorkerSocketData, ProdWorkerToChildMessages, ProdWorkerToCoordinatorMessages, ProviderToPlatformMessages, QueueOptions, RateLimitError, RateLimitOptions, ReplayRunResponse, RetrieveRunResponse, RetryOptions, RunStatus, ScheduleObject, ScheduledTaskPayload, SemanticInternalAttributes, SharedQueueToClientMessages, SlidingWindowRateLimit, SpanEvent, SpanEvents, SpanMessagingEvent, StartDeploymentIndexingRequestBody, StartDeploymentIndexingResponseBody, TaskEventStyle, TaskFileMetadata, TaskMetadata, TaskMetadataFailedToParseData, TaskMetadataWithFilePath, TaskResource, TaskRun, TaskRunBuiltInError, TaskRunContext, TaskRunCustomErrorObject, TaskRunError, TaskRunErrorCodes, TaskRunExecution, TaskRunExecutionAttempt, TaskRunExecutionBatch, TaskRunExecutionEnvironment, TaskRunExecutionOrganization, TaskRunExecutionPayload, TaskRunExecutionProject, TaskRunExecutionQueue, TaskRunExecutionResult, TaskRunExecutionRetry, TaskRunExecutionTask, TaskRunFailedExecutionResult, TaskRunInternalError, TaskRunStringError, TaskRunSuccessfulExecutionResult, TriggerTaskRequestBody, TriggerTaskResponse, TriggerTracer, UncaughtExceptionMessage, UnprocessableEntityError, 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, workerToChildMessages };
|
|
3682
|
+
export { APIConnectionError, APIError, ApiClient, AttemptStatus, AuthenticationError, BackgroundWorkerClientMessages, BackgroundWorkerMetadata, BackgroundWorkerProperties, BackgroundWorkerServerMessages, BadRequestError, BatchTaskRunExecutionResult, BatchTriggerTaskRequestBody, BatchTriggerTaskResponse, CanceledRunResponse, CancellationSpanEvent, ClientToSharedQueueMessages, Config, ConflictError, CoordinatorToPlatformMessages, CoordinatorToProdWorkerMessages, CreateAuthorizationCodeResponseSchema, CreateBackgroundWorkerRequestBody, CreateBackgroundWorkerResponse, CreateEnvironmentVariableRequestBody, CreateScheduleOptions, CreateUploadPayloadUrlResponseBody, 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, ListScheduleOptions, ListSchedulesResult, Machine, MachineCpu, MachineMemory, 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, OtherSpanEvent, PRIMARY_VARIANT, PermissionDeniedError, PlatformToCoordinatorMessages, PlatformToProviderMessages, PostStartCauses, PreStopCauses, ProdChildToWorkerMessages, ProdTaskRunExecution, ProdTaskRunExecutionPayload, ProdWorkerSocketData, ProdWorkerToChildMessages, ProdWorkerToCoordinatorMessages, ProviderToPlatformMessages, QueueOptions, RateLimitError, RateLimitOptions, ReplayRunResponse, RetrieveRunResponse, RetryOptions, RunStatus, ScheduleObject, ScheduledTaskPayload, SemanticInternalAttributes, SharedQueueToClientMessages, SlidingWindowRateLimit, SpanEvent, SpanEvents, SpanMessagingEvent, StartDeploymentIndexingRequestBody, StartDeploymentIndexingResponseBody, TaskEventStyle, TaskFileMetadata, TaskMetadata, TaskMetadataFailedToParseData, TaskMetadataWithFilePath, TaskResource, TaskRun, TaskRunBuiltInError, TaskRunContext, TaskRunCustomErrorObject, TaskRunError, TaskRunErrorCodes, TaskRunExecution, TaskRunExecutionAttempt, TaskRunExecutionBatch, TaskRunExecutionEnvironment, TaskRunExecutionOrganization, TaskRunExecutionPayload, TaskRunExecutionProject, TaskRunExecutionQueue, TaskRunExecutionResult, TaskRunExecutionRetry, TaskRunExecutionTask, TaskRunFailedExecutionResult, TaskRunInternalError, TaskRunStringError, TaskRunSuccessfulExecutionResult, 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, workerToChildMessages };
|
|
3499
3683
|
//# sourceMappingURL=out.js.map
|
|
3500
3684
|
//# sourceMappingURL=index.mjs.map
|