@trigger.dev/sdk 3.0.0-beta.46 → 3.0.0-beta.47
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/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/v3/index.d.mts +128 -32
- package/dist/v3/index.d.ts +128 -32
- package/dist/v3/index.js +567 -136
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +567 -138
- package/dist/v3/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/v3/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TriggerTracer, SemanticInternalAttributes, apiClientManager,
|
|
1
|
+
import { TriggerTracer, SemanticInternalAttributes, apiClientManager, isRequestOptions, mergeRequestOptions, accessoryAttributes, flattenAttributes, taskContext, runtime, usage as usage$1, taskCatalog, TimezonesResult, defaultRetryOptions, calculateNextRetryDelay, defaultFetchRetryOptions, calculateResetAt, eventFilterMatches, stringifyIO, logger, conditionallyImportPacket, parsePacket, createErrorTaskError } from '@trigger.dev/core/v3';
|
|
2
2
|
export { ApiError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, logger } from '@trigger.dev/core/v3';
|
|
3
3
|
import { trace, context, SpanStatusCode, SpanKind } from '@opentelemetry/api';
|
|
4
4
|
import { SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH, SEMATTRS_MESSAGING_OPERATION, SEMATTRS_MESSAGING_DESTINATION, SEMATTRS_MESSAGING_SYSTEM } from '@opentelemetry/semantic-conventions';
|
|
@@ -9,8 +9,8 @@ var __defProp = Object.defineProperty;
|
|
|
9
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
10
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
11
|
var __export = (target, all) => {
|
|
12
|
-
for (var
|
|
13
|
-
__defProp(target,
|
|
12
|
+
for (var name2 in all)
|
|
13
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
14
14
|
};
|
|
15
15
|
var __publicField = (obj, key, value) => {
|
|
16
16
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -18,7 +18,7 @@ var __publicField = (obj, key, value) => {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
// package.json
|
|
21
|
-
var version = "3.0.0-beta.
|
|
21
|
+
var version = "3.0.0-beta.47";
|
|
22
22
|
|
|
23
23
|
// src/v3/tracer.ts
|
|
24
24
|
var tracer = new TriggerTracer({
|
|
@@ -123,6 +123,10 @@ function onThrow(fn, options) {
|
|
|
123
123
|
innerSpan.setStatus({
|
|
124
124
|
code: SpanStatusCode.ERROR
|
|
125
125
|
});
|
|
126
|
+
if (e instanceof Error && e.name === "AbortTaskRunError") {
|
|
127
|
+
innerSpan.end();
|
|
128
|
+
throw e;
|
|
129
|
+
}
|
|
126
130
|
const nextRetryDelay = calculateNextRetryDelay(opts, attempt);
|
|
127
131
|
if (!nextRetryDelay) {
|
|
128
132
|
innerSpan.end();
|
|
@@ -509,63 +513,231 @@ var runs = {
|
|
|
509
513
|
reschedule: rescheduleRun,
|
|
510
514
|
poll
|
|
511
515
|
};
|
|
512
|
-
function listRuns(paramsOrProjectRef,
|
|
516
|
+
function listRuns(paramsOrProjectRef, paramsOrOptions, requestOptions) {
|
|
513
517
|
const apiClient = apiClientManager.client;
|
|
514
518
|
if (!apiClient) {
|
|
515
519
|
throw apiClientMissingError();
|
|
516
520
|
}
|
|
521
|
+
const $requestOptions = listRunsRequestOptions(paramsOrProjectRef, paramsOrOptions, requestOptions);
|
|
517
522
|
if (typeof paramsOrProjectRef === "string") {
|
|
518
|
-
|
|
523
|
+
if (isRequestOptions(paramsOrOptions)) {
|
|
524
|
+
return apiClient.listProjectRuns(paramsOrProjectRef, {}, $requestOptions);
|
|
525
|
+
} else {
|
|
526
|
+
return apiClient.listProjectRuns(paramsOrProjectRef, paramsOrOptions, $requestOptions);
|
|
527
|
+
}
|
|
519
528
|
}
|
|
520
|
-
return apiClient.listRuns(
|
|
529
|
+
return apiClient.listRuns(paramsOrProjectRef, $requestOptions);
|
|
521
530
|
}
|
|
522
531
|
__name(listRuns, "listRuns");
|
|
523
|
-
function
|
|
532
|
+
function listRunsRequestOptions(paramsOrProjectRef, paramsOrOptions, requestOptions) {
|
|
533
|
+
if (typeof paramsOrProjectRef === "string") {
|
|
534
|
+
if (isRequestOptions(paramsOrOptions)) {
|
|
535
|
+
return mergeRequestOptions({
|
|
536
|
+
tracer,
|
|
537
|
+
name: "runs.list()",
|
|
538
|
+
icon: "runs",
|
|
539
|
+
attributes: {
|
|
540
|
+
projectRef: paramsOrProjectRef,
|
|
541
|
+
...accessoryAttributes({
|
|
542
|
+
items: [
|
|
543
|
+
{
|
|
544
|
+
text: paramsOrProjectRef,
|
|
545
|
+
variant: "normal"
|
|
546
|
+
}
|
|
547
|
+
],
|
|
548
|
+
style: "codepath"
|
|
549
|
+
})
|
|
550
|
+
}
|
|
551
|
+
}, paramsOrOptions);
|
|
552
|
+
} else {
|
|
553
|
+
return mergeRequestOptions({
|
|
554
|
+
tracer,
|
|
555
|
+
name: "runs.list()",
|
|
556
|
+
icon: "runs",
|
|
557
|
+
attributes: {
|
|
558
|
+
projectRef: paramsOrProjectRef,
|
|
559
|
+
...flattenAttributes(paramsOrOptions, "queryParams"),
|
|
560
|
+
...accessoryAttributes({
|
|
561
|
+
items: [
|
|
562
|
+
{
|
|
563
|
+
text: paramsOrProjectRef,
|
|
564
|
+
variant: "normal"
|
|
565
|
+
}
|
|
566
|
+
],
|
|
567
|
+
style: "codepath"
|
|
568
|
+
})
|
|
569
|
+
}
|
|
570
|
+
}, requestOptions);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return mergeRequestOptions({
|
|
574
|
+
tracer,
|
|
575
|
+
name: "runs.list()",
|
|
576
|
+
icon: "runs",
|
|
577
|
+
attributes: {
|
|
578
|
+
...flattenAttributes(paramsOrProjectRef, "queryParams")
|
|
579
|
+
}
|
|
580
|
+
}, isRequestOptions(paramsOrOptions) ? paramsOrOptions : requestOptions);
|
|
581
|
+
}
|
|
582
|
+
__name(listRunsRequestOptions, "listRunsRequestOptions");
|
|
583
|
+
function retrieveRun(runId, requestOptions) {
|
|
524
584
|
const apiClient = apiClientManager.client;
|
|
525
585
|
if (!apiClient) {
|
|
526
586
|
throw apiClientMissingError();
|
|
527
587
|
}
|
|
588
|
+
const $requestOptions = mergeRequestOptions({
|
|
589
|
+
tracer,
|
|
590
|
+
name: "runs.retrieve()",
|
|
591
|
+
icon: "runs",
|
|
592
|
+
attributes: {
|
|
593
|
+
runId: typeof runId === "string" ? runId : runId.id,
|
|
594
|
+
...accessoryAttributes({
|
|
595
|
+
items: [
|
|
596
|
+
{
|
|
597
|
+
text: typeof runId === "string" ? runId : runId.id,
|
|
598
|
+
variant: "normal"
|
|
599
|
+
}
|
|
600
|
+
],
|
|
601
|
+
style: "codepath"
|
|
602
|
+
})
|
|
603
|
+
}
|
|
604
|
+
}, requestOptions);
|
|
528
605
|
if (typeof runId === "string") {
|
|
529
|
-
return apiClient.retrieveRun(runId);
|
|
606
|
+
return apiClient.retrieveRun(runId, $requestOptions);
|
|
530
607
|
} else {
|
|
531
|
-
return apiClient.retrieveRun(runId.id);
|
|
608
|
+
return apiClient.retrieveRun(runId.id, $requestOptions);
|
|
532
609
|
}
|
|
533
610
|
}
|
|
534
611
|
__name(retrieveRun, "retrieveRun");
|
|
535
|
-
function replayRun(runId) {
|
|
612
|
+
function replayRun(runId, requestOptions) {
|
|
536
613
|
const apiClient = apiClientManager.client;
|
|
537
614
|
if (!apiClient) {
|
|
538
615
|
throw apiClientMissingError();
|
|
539
616
|
}
|
|
540
|
-
|
|
617
|
+
const $requestOptions = mergeRequestOptions({
|
|
618
|
+
tracer,
|
|
619
|
+
name: "runs.replay()",
|
|
620
|
+
icon: "runs",
|
|
621
|
+
attributes: {
|
|
622
|
+
runId,
|
|
623
|
+
...accessoryAttributes({
|
|
624
|
+
items: [
|
|
625
|
+
{
|
|
626
|
+
text: runId,
|
|
627
|
+
variant: "normal"
|
|
628
|
+
}
|
|
629
|
+
],
|
|
630
|
+
style: "codepath"
|
|
631
|
+
})
|
|
632
|
+
}
|
|
633
|
+
}, requestOptions);
|
|
634
|
+
return apiClient.replayRun(runId, $requestOptions);
|
|
541
635
|
}
|
|
542
636
|
__name(replayRun, "replayRun");
|
|
543
|
-
function cancelRun(runId) {
|
|
637
|
+
function cancelRun(runId, requestOptions) {
|
|
544
638
|
const apiClient = apiClientManager.client;
|
|
545
639
|
if (!apiClient) {
|
|
546
640
|
throw apiClientMissingError();
|
|
547
641
|
}
|
|
548
|
-
|
|
642
|
+
const $requestOptions = mergeRequestOptions({
|
|
643
|
+
tracer,
|
|
644
|
+
name: "runs.cancel()",
|
|
645
|
+
icon: "runs",
|
|
646
|
+
attributes: {
|
|
647
|
+
runId,
|
|
648
|
+
...accessoryAttributes({
|
|
649
|
+
items: [
|
|
650
|
+
{
|
|
651
|
+
text: runId,
|
|
652
|
+
variant: "normal"
|
|
653
|
+
}
|
|
654
|
+
],
|
|
655
|
+
style: "codepath"
|
|
656
|
+
})
|
|
657
|
+
}
|
|
658
|
+
}, requestOptions);
|
|
659
|
+
return apiClient.cancelRun(runId, $requestOptions);
|
|
549
660
|
}
|
|
550
661
|
__name(cancelRun, "cancelRun");
|
|
551
|
-
function rescheduleRun(runId, body) {
|
|
662
|
+
function rescheduleRun(runId, body, requestOptions) {
|
|
552
663
|
const apiClient = apiClientManager.client;
|
|
553
664
|
if (!apiClient) {
|
|
554
665
|
throw apiClientMissingError();
|
|
555
666
|
}
|
|
556
|
-
|
|
667
|
+
const $requestOptions = mergeRequestOptions({
|
|
668
|
+
tracer,
|
|
669
|
+
name: "runs.reschedule()",
|
|
670
|
+
icon: "runs",
|
|
671
|
+
attributes: {
|
|
672
|
+
runId,
|
|
673
|
+
...accessoryAttributes({
|
|
674
|
+
items: [
|
|
675
|
+
{
|
|
676
|
+
text: runId,
|
|
677
|
+
variant: "normal"
|
|
678
|
+
}
|
|
679
|
+
],
|
|
680
|
+
style: "codepath"
|
|
681
|
+
})
|
|
682
|
+
}
|
|
683
|
+
}, requestOptions);
|
|
684
|
+
return apiClient.rescheduleRun(runId, body, $requestOptions);
|
|
557
685
|
}
|
|
558
686
|
__name(rescheduleRun, "rescheduleRun");
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
687
|
+
var MAX_POLL_ATTEMPTS = 500;
|
|
688
|
+
async function poll(handle, options, requestOptions) {
|
|
689
|
+
let attempts = 0;
|
|
690
|
+
while (attempts++ < MAX_POLL_ATTEMPTS) {
|
|
691
|
+
const run = await runs.retrieve(handle, requestOptions);
|
|
562
692
|
if (run.isCompleted) {
|
|
563
693
|
return run;
|
|
564
694
|
}
|
|
565
695
|
await new Promise((resolve) => setTimeout(resolve, options?.pollIntervalMs ?? 1e3));
|
|
566
696
|
}
|
|
697
|
+
throw new Error(`Run ${handle} did not complete after ${MAX_POLL_ATTEMPTS} attempts`);
|
|
567
698
|
}
|
|
568
699
|
__name(poll, "poll");
|
|
700
|
+
var idempotencyKeys = {
|
|
701
|
+
create: createIdempotencyKey
|
|
702
|
+
};
|
|
703
|
+
function isIdempotencyKey(value) {
|
|
704
|
+
return typeof value === "string" && value.length === 64;
|
|
705
|
+
}
|
|
706
|
+
__name(isIdempotencyKey, "isIdempotencyKey");
|
|
707
|
+
async function createIdempotencyKey(key, options) {
|
|
708
|
+
const idempotencyKey = await generateIdempotencyKey([
|
|
709
|
+
...Array.isArray(key) ? key : [
|
|
710
|
+
key
|
|
711
|
+
]
|
|
712
|
+
].concat(injectScope(options?.scope ?? "run")));
|
|
713
|
+
return idempotencyKey;
|
|
714
|
+
}
|
|
715
|
+
__name(createIdempotencyKey, "createIdempotencyKey");
|
|
716
|
+
function injectScope(scope) {
|
|
717
|
+
switch (scope) {
|
|
718
|
+
case "run": {
|
|
719
|
+
if (taskContext?.ctx) {
|
|
720
|
+
return [
|
|
721
|
+
taskContext.ctx.run.id
|
|
722
|
+
];
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
case "attempt": {
|
|
726
|
+
if (taskContext?.ctx) {
|
|
727
|
+
return [
|
|
728
|
+
taskContext.ctx.attempt.id
|
|
729
|
+
];
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
return [];
|
|
734
|
+
}
|
|
735
|
+
__name(injectScope, "injectScope");
|
|
736
|
+
async function generateIdempotencyKey(keyMaterial) {
|
|
737
|
+
const hash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(keyMaterial.join("-")));
|
|
738
|
+
return Array.from(new Uint8Array(hash)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
739
|
+
}
|
|
740
|
+
__name(generateIdempotencyKey, "generateIdempotencyKey");
|
|
569
741
|
|
|
570
742
|
// src/v3/shared.ts
|
|
571
743
|
function queue(options) {
|
|
@@ -582,40 +754,41 @@ function createTask(params) {
|
|
|
582
754
|
}
|
|
583
755
|
const taskMetadata = taskCatalog.getTaskMetadata(params.id);
|
|
584
756
|
const payloadPacket = await stringifyIO(payload);
|
|
585
|
-
const handle = await
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}, {
|
|
598
|
-
spanParentAsLink: true
|
|
599
|
-
});
|
|
600
|
-
span.setAttribute("messaging.message.id", response.id);
|
|
601
|
-
return response;
|
|
757
|
+
const handle = await apiClient.triggerTask(params.id, {
|
|
758
|
+
payload: payloadPacket.data,
|
|
759
|
+
options: {
|
|
760
|
+
queue: options?.queue ?? params.queue,
|
|
761
|
+
concurrencyKey: options?.concurrencyKey,
|
|
762
|
+
test: taskContext.ctx?.run.isTest,
|
|
763
|
+
payloadType: payloadPacket.dataType,
|
|
764
|
+
idempotencyKey: await makeKey(options?.idempotencyKey),
|
|
765
|
+
delay: options?.delay,
|
|
766
|
+
ttl: options?.ttl,
|
|
767
|
+
maxAttempts: options?.maxAttempts
|
|
768
|
+
}
|
|
602
769
|
}, {
|
|
603
|
-
|
|
770
|
+
spanParentAsLink: true
|
|
771
|
+
}, {
|
|
772
|
+
name: taskMetadata ? `${taskMetadata.exportName}.trigger()` : `trigger()`,
|
|
773
|
+
tracer,
|
|
774
|
+
icon: "trigger",
|
|
604
775
|
attributes: {
|
|
605
776
|
[SEMATTRS_MESSAGING_OPERATION]: "publish",
|
|
606
|
-
[SemanticInternalAttributes.STYLE_ICON]: "trigger",
|
|
607
777
|
["messaging.client_id"]: taskContext.worker?.id,
|
|
608
778
|
[SEMATTRS_MESSAGING_DESTINATION]: params.queue?.name ?? params.id,
|
|
609
779
|
[SEMATTRS_MESSAGING_SYSTEM]: "trigger.dev",
|
|
610
|
-
...
|
|
780
|
+
...accessoryAttributes({
|
|
611
781
|
items: [
|
|
612
782
|
{
|
|
613
|
-
text:
|
|
783
|
+
text: params.id,
|
|
614
784
|
variant: "normal"
|
|
615
785
|
}
|
|
616
786
|
],
|
|
617
787
|
style: "codepath"
|
|
618
|
-
})
|
|
788
|
+
})
|
|
789
|
+
},
|
|
790
|
+
onResponseBody: (body, span) => {
|
|
791
|
+
body && typeof body === "object" && !Array.isArray(body) && "id" in body && typeof body.id === "string" && span.setAttribute("messaging.message.id", body.id);
|
|
619
792
|
}
|
|
620
793
|
});
|
|
621
794
|
return handle;
|
|
@@ -626,55 +799,53 @@ function createTask(params) {
|
|
|
626
799
|
throw apiClientMissingError();
|
|
627
800
|
}
|
|
628
801
|
const taskMetadata = taskCatalog.getTaskMetadata(params.id);
|
|
629
|
-
const response = await
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
}, {
|
|
647
|
-
spanParentAsLink: true
|
|
648
|
-
});
|
|
649
|
-
span.setAttribute("messaging.message.id", response2.batchId);
|
|
650
|
-
const handle = {
|
|
651
|
-
batchId: response2.batchId,
|
|
652
|
-
runs: response2.runs.map((id) => ({
|
|
653
|
-
id
|
|
654
|
-
}))
|
|
655
|
-
};
|
|
656
|
-
return handle;
|
|
802
|
+
const response = await apiClient.batchTriggerTask(params.id, {
|
|
803
|
+
items: await Promise.all(items.map(async (item) => {
|
|
804
|
+
const payloadPacket = await stringifyIO(item.payload);
|
|
805
|
+
return {
|
|
806
|
+
payload: payloadPacket.data,
|
|
807
|
+
options: {
|
|
808
|
+
queue: item.options?.queue ?? params.queue,
|
|
809
|
+
concurrencyKey: item.options?.concurrencyKey,
|
|
810
|
+
test: taskContext.ctx?.run.isTest,
|
|
811
|
+
payloadType: payloadPacket.dataType,
|
|
812
|
+
idempotencyKey: await makeKey(item.options?.idempotencyKey),
|
|
813
|
+
delay: item.options?.delay,
|
|
814
|
+
ttl: item.options?.ttl,
|
|
815
|
+
maxAttempts: item.options?.maxAttempts
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
}))
|
|
657
819
|
}, {
|
|
658
|
-
|
|
820
|
+
spanParentAsLink: true
|
|
821
|
+
}, {
|
|
822
|
+
name: taskMetadata ? `${taskMetadata.exportName}.batchTrigger()` : `batchTrigger()`,
|
|
823
|
+
icon: "trigger",
|
|
824
|
+
tracer,
|
|
659
825
|
attributes: {
|
|
660
826
|
[SEMATTRS_MESSAGING_OPERATION]: "publish",
|
|
661
827
|
["messaging.batch.message_count"]: items.length,
|
|
662
828
|
["messaging.client_id"]: taskContext.worker?.id,
|
|
663
829
|
[SEMATTRS_MESSAGING_DESTINATION]: params.queue?.name ?? params.id,
|
|
664
830
|
[SEMATTRS_MESSAGING_SYSTEM]: "trigger.dev",
|
|
665
|
-
|
|
666
|
-
...taskMetadata ? accessoryAttributes({
|
|
831
|
+
...accessoryAttributes({
|
|
667
832
|
items: [
|
|
668
833
|
{
|
|
669
|
-
text:
|
|
834
|
+
text: params.id,
|
|
670
835
|
variant: "normal"
|
|
671
836
|
}
|
|
672
837
|
],
|
|
673
838
|
style: "codepath"
|
|
674
|
-
})
|
|
839
|
+
})
|
|
675
840
|
}
|
|
676
841
|
});
|
|
677
|
-
|
|
842
|
+
const handle = {
|
|
843
|
+
batchId: response.batchId,
|
|
844
|
+
runs: response.runs.map((id) => ({
|
|
845
|
+
id
|
|
846
|
+
}))
|
|
847
|
+
};
|
|
848
|
+
return handle;
|
|
678
849
|
},
|
|
679
850
|
triggerAndWait: async (payload, options) => {
|
|
680
851
|
const ctx = taskContext.ctx;
|
|
@@ -687,7 +858,7 @@ function createTask(params) {
|
|
|
687
858
|
}
|
|
688
859
|
const taskMetadata = taskCatalog.getTaskMetadata(params.id);
|
|
689
860
|
const payloadPacket = await stringifyIO(payload);
|
|
690
|
-
return await tracer.startActiveSpan(taskMetadata ?
|
|
861
|
+
return await tracer.startActiveSpan(taskMetadata ? `${taskMetadata.exportName}.triggerAndWait()` : `triggerAndWait()`, async (span) => {
|
|
691
862
|
const response = await apiClient.triggerTask(params.id, {
|
|
692
863
|
payload: payloadPacket.data,
|
|
693
864
|
options: {
|
|
@@ -697,9 +868,10 @@ function createTask(params) {
|
|
|
697
868
|
concurrencyKey: options?.concurrencyKey,
|
|
698
869
|
test: taskContext.ctx?.run.isTest,
|
|
699
870
|
payloadType: payloadPacket.dataType,
|
|
700
|
-
idempotencyKey: options?.idempotencyKey,
|
|
871
|
+
idempotencyKey: await makeKey(options?.idempotencyKey),
|
|
701
872
|
delay: options?.delay,
|
|
702
|
-
ttl: options?.ttl
|
|
873
|
+
ttl: options?.ttl,
|
|
874
|
+
maxAttempts: options?.maxAttempts
|
|
703
875
|
}
|
|
704
876
|
});
|
|
705
877
|
span.setAttribute("messaging.message.id", response.id);
|
|
@@ -726,15 +898,15 @@ function createTask(params) {
|
|
|
726
898
|
["messaging.client_id"]: taskContext.worker?.id,
|
|
727
899
|
[SEMATTRS_MESSAGING_DESTINATION]: params.queue?.name ?? params.id,
|
|
728
900
|
[SEMATTRS_MESSAGING_SYSTEM]: "trigger.dev",
|
|
729
|
-
...
|
|
901
|
+
...accessoryAttributes({
|
|
730
902
|
items: [
|
|
731
903
|
{
|
|
732
|
-
text:
|
|
904
|
+
text: params.id,
|
|
733
905
|
variant: "normal"
|
|
734
906
|
}
|
|
735
907
|
],
|
|
736
908
|
style: "codepath"
|
|
737
|
-
})
|
|
909
|
+
})
|
|
738
910
|
}
|
|
739
911
|
});
|
|
740
912
|
},
|
|
@@ -748,7 +920,7 @@ function createTask(params) {
|
|
|
748
920
|
throw apiClientMissingError();
|
|
749
921
|
}
|
|
750
922
|
const taskMetadata = taskCatalog.getTaskMetadata(params.id);
|
|
751
|
-
return await tracer.startActiveSpan(taskMetadata ?
|
|
923
|
+
return await tracer.startActiveSpan(taskMetadata ? `${taskMetadata.exportName}.batchTriggerAndWait()` : `batchTriggerAndWait()`, async (span) => {
|
|
752
924
|
const response = await apiClient.batchTriggerTask(params.id, {
|
|
753
925
|
items: await Promise.all(items.map(async (item) => {
|
|
754
926
|
const payloadPacket = await stringifyIO(item.payload);
|
|
@@ -760,9 +932,10 @@ function createTask(params) {
|
|
|
760
932
|
concurrencyKey: item.options?.concurrencyKey,
|
|
761
933
|
test: taskContext.ctx?.run.isTest,
|
|
762
934
|
payloadType: payloadPacket.dataType,
|
|
763
|
-
idempotencyKey: item.options?.idempotencyKey,
|
|
935
|
+
idempotencyKey: await makeKey(item.options?.idempotencyKey),
|
|
764
936
|
delay: item.options?.delay,
|
|
765
|
-
ttl: item.options?.ttl
|
|
937
|
+
ttl: item.options?.ttl,
|
|
938
|
+
maxAttempts: item.options?.maxAttempts
|
|
766
939
|
}
|
|
767
940
|
};
|
|
768
941
|
})),
|
|
@@ -823,15 +996,15 @@ function createTask(params) {
|
|
|
823
996
|
[SEMATTRS_MESSAGING_DESTINATION]: params.queue?.name ?? params.id,
|
|
824
997
|
[SEMATTRS_MESSAGING_SYSTEM]: "trigger.dev",
|
|
825
998
|
[SemanticInternalAttributes.STYLE_ICON]: "trigger",
|
|
826
|
-
...
|
|
999
|
+
...accessoryAttributes({
|
|
827
1000
|
items: [
|
|
828
1001
|
{
|
|
829
|
-
text:
|
|
1002
|
+
text: params.id,
|
|
830
1003
|
variant: "normal"
|
|
831
1004
|
}
|
|
832
1005
|
],
|
|
833
1006
|
style: "codepath"
|
|
834
|
-
})
|
|
1007
|
+
})
|
|
835
1008
|
}
|
|
836
1009
|
});
|
|
837
1010
|
}
|
|
@@ -859,7 +1032,7 @@ function createTask(params) {
|
|
|
859
1032
|
return task3;
|
|
860
1033
|
}
|
|
861
1034
|
__name(createTask, "createTask");
|
|
862
|
-
async function trigger(id, payload, options) {
|
|
1035
|
+
async function trigger(id, payload, options, requestOptions) {
|
|
863
1036
|
const apiClient = apiClientManager.client;
|
|
864
1037
|
if (!apiClient) {
|
|
865
1038
|
throw apiClientMissingError();
|
|
@@ -872,20 +1045,108 @@ async function trigger(id, payload, options) {
|
|
|
872
1045
|
concurrencyKey: options?.concurrencyKey,
|
|
873
1046
|
test: taskContext.ctx?.run.isTest,
|
|
874
1047
|
payloadType: payloadPacket.dataType,
|
|
875
|
-
idempotencyKey: options?.idempotencyKey,
|
|
1048
|
+
idempotencyKey: await makeKey(options?.idempotencyKey),
|
|
876
1049
|
delay: options?.delay,
|
|
877
|
-
ttl: options?.ttl
|
|
1050
|
+
ttl: options?.ttl,
|
|
1051
|
+
maxAttempts: options?.maxAttempts
|
|
878
1052
|
}
|
|
1053
|
+
}, {
|
|
1054
|
+
spanParentAsLink: true
|
|
1055
|
+
}, {
|
|
1056
|
+
name: `tasks.trigger()`,
|
|
1057
|
+
tracer,
|
|
1058
|
+
icon: "trigger",
|
|
1059
|
+
attributes: {
|
|
1060
|
+
[SEMATTRS_MESSAGING_OPERATION]: "publish",
|
|
1061
|
+
["messaging.client_id"]: taskContext.worker?.id,
|
|
1062
|
+
[SEMATTRS_MESSAGING_SYSTEM]: "trigger.dev",
|
|
1063
|
+
...accessoryAttributes({
|
|
1064
|
+
items: [
|
|
1065
|
+
{
|
|
1066
|
+
text: id,
|
|
1067
|
+
variant: "normal"
|
|
1068
|
+
}
|
|
1069
|
+
],
|
|
1070
|
+
style: "codepath"
|
|
1071
|
+
})
|
|
1072
|
+
},
|
|
1073
|
+
onResponseBody: (body, span) => {
|
|
1074
|
+
body && typeof body === "object" && !Array.isArray(body) && "id" in body && typeof body.id === "string" && span.setAttribute("messaging.message.id", body.id);
|
|
1075
|
+
},
|
|
1076
|
+
...requestOptions
|
|
879
1077
|
});
|
|
880
1078
|
return handle;
|
|
881
1079
|
}
|
|
882
1080
|
__name(trigger, "trigger");
|
|
883
|
-
async function
|
|
884
|
-
const
|
|
885
|
-
|
|
1081
|
+
async function triggerAndWait(id, payload, options, requestOptions) {
|
|
1082
|
+
const ctx = taskContext.ctx;
|
|
1083
|
+
if (!ctx) {
|
|
1084
|
+
throw new Error("tasks.triggerAndWait can only be used from inside a task.run()");
|
|
1085
|
+
}
|
|
1086
|
+
const apiClient = apiClientManager.client;
|
|
1087
|
+
if (!apiClient) {
|
|
1088
|
+
throw apiClientMissingError();
|
|
1089
|
+
}
|
|
1090
|
+
const payloadPacket = await stringifyIO(payload);
|
|
1091
|
+
return await tracer.startActiveSpan("tasks.triggerAndWait()", async (span) => {
|
|
1092
|
+
const response = await apiClient.triggerTask(id, {
|
|
1093
|
+
payload: payloadPacket.data,
|
|
1094
|
+
options: {
|
|
1095
|
+
dependentAttempt: ctx.attempt.id,
|
|
1096
|
+
lockToVersion: taskContext.worker?.version,
|
|
1097
|
+
queue: options?.queue,
|
|
1098
|
+
concurrencyKey: options?.concurrencyKey,
|
|
1099
|
+
test: taskContext.ctx?.run.isTest,
|
|
1100
|
+
payloadType: payloadPacket.dataType,
|
|
1101
|
+
idempotencyKey: await makeKey(options?.idempotencyKey),
|
|
1102
|
+
delay: options?.delay,
|
|
1103
|
+
ttl: options?.ttl,
|
|
1104
|
+
maxAttempts: options?.maxAttempts
|
|
1105
|
+
}
|
|
1106
|
+
}, {}, requestOptions);
|
|
1107
|
+
span.setAttribute("messaging.message.id", response.id);
|
|
1108
|
+
if (options?.idempotencyKey) {
|
|
1109
|
+
const result2 = await apiClient.getRunResult(response.id);
|
|
1110
|
+
if (result2) {
|
|
1111
|
+
logger.log(`Result reused from previous task run with idempotency key '${options.idempotencyKey}'.`, {
|
|
1112
|
+
runId: response.id,
|
|
1113
|
+
idempotencyKey: options.idempotencyKey
|
|
1114
|
+
});
|
|
1115
|
+
return await handleTaskRunExecutionResult(result2);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
const result = await runtime.waitForTask({
|
|
1119
|
+
id: response.id,
|
|
1120
|
+
ctx
|
|
1121
|
+
});
|
|
1122
|
+
return await handleTaskRunExecutionResult(result);
|
|
1123
|
+
}, {
|
|
1124
|
+
kind: SpanKind.PRODUCER,
|
|
1125
|
+
attributes: {
|
|
1126
|
+
[SemanticInternalAttributes.STYLE_ICON]: "trigger",
|
|
1127
|
+
[SEMATTRS_MESSAGING_OPERATION]: "publish",
|
|
1128
|
+
["messaging.client_id"]: taskContext.worker?.id,
|
|
1129
|
+
[SEMATTRS_MESSAGING_DESTINATION]: id,
|
|
1130
|
+
[SEMATTRS_MESSAGING_SYSTEM]: "trigger.dev",
|
|
1131
|
+
...accessoryAttributes({
|
|
1132
|
+
items: [
|
|
1133
|
+
{
|
|
1134
|
+
text: id,
|
|
1135
|
+
variant: "normal"
|
|
1136
|
+
}
|
|
1137
|
+
],
|
|
1138
|
+
style: "codepath"
|
|
1139
|
+
})
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
__name(triggerAndWait, "triggerAndWait");
|
|
1144
|
+
async function triggerAndPoll(id, payload, options, requestOptions) {
|
|
1145
|
+
const handle = await trigger(id, payload, options, requestOptions);
|
|
1146
|
+
return runs.poll(handle, options, requestOptions);
|
|
886
1147
|
}
|
|
887
1148
|
__name(triggerAndPoll, "triggerAndPoll");
|
|
888
|
-
async function batchTrigger(id, items) {
|
|
1149
|
+
async function batchTrigger(id, items, requestOptions) {
|
|
889
1150
|
const apiClient = apiClientManager.client;
|
|
890
1151
|
if (!apiClient) {
|
|
891
1152
|
throw apiClientMissingError();
|
|
@@ -900,12 +1161,34 @@ async function batchTrigger(id, items) {
|
|
|
900
1161
|
concurrencyKey: item.options?.concurrencyKey,
|
|
901
1162
|
test: taskContext.ctx?.run.isTest,
|
|
902
1163
|
payloadType: payloadPacket.dataType,
|
|
903
|
-
idempotencyKey: item.options?.idempotencyKey,
|
|
1164
|
+
idempotencyKey: await makeKey(item.options?.idempotencyKey),
|
|
904
1165
|
delay: item.options?.delay,
|
|
905
|
-
ttl: item.options?.ttl
|
|
1166
|
+
ttl: item.options?.ttl,
|
|
1167
|
+
maxAttempts: item.options?.maxAttempts
|
|
906
1168
|
}
|
|
907
1169
|
};
|
|
908
1170
|
}))
|
|
1171
|
+
}, {
|
|
1172
|
+
spanParentAsLink: true
|
|
1173
|
+
}, {
|
|
1174
|
+
name: `tasks.batchTrigger()`,
|
|
1175
|
+
tracer,
|
|
1176
|
+
icon: "trigger",
|
|
1177
|
+
attributes: {
|
|
1178
|
+
[SEMATTRS_MESSAGING_OPERATION]: "publish",
|
|
1179
|
+
["messaging.client_id"]: taskContext.worker?.id,
|
|
1180
|
+
[SEMATTRS_MESSAGING_SYSTEM]: "trigger.dev",
|
|
1181
|
+
...accessoryAttributes({
|
|
1182
|
+
items: [
|
|
1183
|
+
{
|
|
1184
|
+
text: id,
|
|
1185
|
+
variant: "normal"
|
|
1186
|
+
}
|
|
1187
|
+
],
|
|
1188
|
+
style: "codepath"
|
|
1189
|
+
})
|
|
1190
|
+
},
|
|
1191
|
+
...requestOptions
|
|
909
1192
|
});
|
|
910
1193
|
const handle = {
|
|
911
1194
|
batchId: response.batchId,
|
|
@@ -969,6 +1252,18 @@ function apiClientMissingError() {
|
|
|
969
1252
|
return `Unknown error`;
|
|
970
1253
|
}
|
|
971
1254
|
__name(apiClientMissingError, "apiClientMissingError");
|
|
1255
|
+
async function makeKey(idempotencyKey) {
|
|
1256
|
+
if (!idempotencyKey) {
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
if (isIdempotencyKey(idempotencyKey)) {
|
|
1260
|
+
return idempotencyKey;
|
|
1261
|
+
}
|
|
1262
|
+
return await idempotencyKeys.create(idempotencyKey, {
|
|
1263
|
+
scope: "global"
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
__name(makeKey, "makeKey");
|
|
972
1267
|
|
|
973
1268
|
// src/v3/tasks.ts
|
|
974
1269
|
function task(options) {
|
|
@@ -978,7 +1273,8 @@ __name(task, "task");
|
|
|
978
1273
|
var tasks = {
|
|
979
1274
|
trigger,
|
|
980
1275
|
triggerAndPoll,
|
|
981
|
-
batchTrigger
|
|
1276
|
+
batchTrigger,
|
|
1277
|
+
triggerAndWait
|
|
982
1278
|
};
|
|
983
1279
|
var wait = {
|
|
984
1280
|
for: async (options) => {
|
|
@@ -1206,60 +1502,166 @@ function task2(params) {
|
|
|
1206
1502
|
return task3;
|
|
1207
1503
|
}
|
|
1208
1504
|
__name(task2, "task");
|
|
1209
|
-
function create(options) {
|
|
1505
|
+
function create(options, requestOptions) {
|
|
1210
1506
|
const apiClient = apiClientManager.client;
|
|
1211
1507
|
if (!apiClient) {
|
|
1212
1508
|
throw apiClientMissingError();
|
|
1213
1509
|
}
|
|
1214
|
-
|
|
1510
|
+
const $requestOptions = mergeRequestOptions({
|
|
1511
|
+
tracer,
|
|
1512
|
+
name: "schedules.create()",
|
|
1513
|
+
icon: "clock",
|
|
1514
|
+
attributes: {
|
|
1515
|
+
...accessoryAttributes({
|
|
1516
|
+
items: [
|
|
1517
|
+
{
|
|
1518
|
+
text: options.cron,
|
|
1519
|
+
variant: "normal"
|
|
1520
|
+
}
|
|
1521
|
+
],
|
|
1522
|
+
style: "codepath"
|
|
1523
|
+
})
|
|
1524
|
+
}
|
|
1525
|
+
}, requestOptions);
|
|
1526
|
+
return apiClient.createSchedule(options, $requestOptions);
|
|
1215
1527
|
}
|
|
1216
1528
|
__name(create, "create");
|
|
1217
|
-
function retrieve(scheduleId) {
|
|
1529
|
+
function retrieve(scheduleId, requestOptions) {
|
|
1218
1530
|
const apiClient = apiClientManager.client;
|
|
1219
1531
|
if (!apiClient) {
|
|
1220
1532
|
throw apiClientMissingError();
|
|
1221
1533
|
}
|
|
1222
|
-
|
|
1534
|
+
const $requestOptions = mergeRequestOptions({
|
|
1535
|
+
tracer,
|
|
1536
|
+
name: "schedules.retrieve()",
|
|
1537
|
+
icon: "clock",
|
|
1538
|
+
attributes: {
|
|
1539
|
+
scheduleId,
|
|
1540
|
+
...accessoryAttributes({
|
|
1541
|
+
items: [
|
|
1542
|
+
{
|
|
1543
|
+
text: scheduleId,
|
|
1544
|
+
variant: "normal"
|
|
1545
|
+
}
|
|
1546
|
+
],
|
|
1547
|
+
style: "codepath"
|
|
1548
|
+
})
|
|
1549
|
+
}
|
|
1550
|
+
}, requestOptions);
|
|
1551
|
+
return apiClient.retrieveSchedule(scheduleId, $requestOptions);
|
|
1223
1552
|
}
|
|
1224
1553
|
__name(retrieve, "retrieve");
|
|
1225
|
-
function update(scheduleId, options) {
|
|
1554
|
+
function update(scheduleId, options, requestOptions) {
|
|
1226
1555
|
const apiClient = apiClientManager.client;
|
|
1227
1556
|
if (!apiClient) {
|
|
1228
1557
|
throw apiClientMissingError();
|
|
1229
1558
|
}
|
|
1230
|
-
|
|
1559
|
+
const $requestOptions = mergeRequestOptions({
|
|
1560
|
+
tracer,
|
|
1561
|
+
name: "schedules.update()",
|
|
1562
|
+
icon: "clock",
|
|
1563
|
+
attributes: {
|
|
1564
|
+
scheduleId,
|
|
1565
|
+
...accessoryAttributes({
|
|
1566
|
+
items: [
|
|
1567
|
+
{
|
|
1568
|
+
text: scheduleId,
|
|
1569
|
+
variant: "normal"
|
|
1570
|
+
}
|
|
1571
|
+
],
|
|
1572
|
+
style: "codepath"
|
|
1573
|
+
})
|
|
1574
|
+
}
|
|
1575
|
+
}, requestOptions);
|
|
1576
|
+
return apiClient.updateSchedule(scheduleId, options, $requestOptions);
|
|
1231
1577
|
}
|
|
1232
1578
|
__name(update, "update");
|
|
1233
|
-
function del(scheduleId) {
|
|
1579
|
+
function del(scheduleId, requestOptions) {
|
|
1234
1580
|
const apiClient = apiClientManager.client;
|
|
1235
1581
|
if (!apiClient) {
|
|
1236
1582
|
throw apiClientMissingError();
|
|
1237
1583
|
}
|
|
1238
|
-
|
|
1584
|
+
const $requestOptions = mergeRequestOptions({
|
|
1585
|
+
tracer,
|
|
1586
|
+
name: "schedules.delete()",
|
|
1587
|
+
icon: "clock",
|
|
1588
|
+
attributes: {
|
|
1589
|
+
scheduleId,
|
|
1590
|
+
...accessoryAttributes({
|
|
1591
|
+
items: [
|
|
1592
|
+
{
|
|
1593
|
+
text: scheduleId,
|
|
1594
|
+
variant: "normal"
|
|
1595
|
+
}
|
|
1596
|
+
],
|
|
1597
|
+
style: "codepath"
|
|
1598
|
+
})
|
|
1599
|
+
}
|
|
1600
|
+
}, requestOptions);
|
|
1601
|
+
return apiClient.deleteSchedule(scheduleId, $requestOptions);
|
|
1239
1602
|
}
|
|
1240
1603
|
__name(del, "del");
|
|
1241
|
-
function deactivate(scheduleId) {
|
|
1604
|
+
function deactivate(scheduleId, requestOptions) {
|
|
1242
1605
|
const apiClient = apiClientManager.client;
|
|
1243
1606
|
if (!apiClient) {
|
|
1244
1607
|
throw apiClientMissingError();
|
|
1245
1608
|
}
|
|
1246
|
-
|
|
1609
|
+
const $requestOptions = mergeRequestOptions({
|
|
1610
|
+
tracer,
|
|
1611
|
+
name: "schedules.deactivate()",
|
|
1612
|
+
icon: "clock",
|
|
1613
|
+
attributes: {
|
|
1614
|
+
scheduleId,
|
|
1615
|
+
...accessoryAttributes({
|
|
1616
|
+
items: [
|
|
1617
|
+
{
|
|
1618
|
+
text: scheduleId,
|
|
1619
|
+
variant: "normal"
|
|
1620
|
+
}
|
|
1621
|
+
],
|
|
1622
|
+
style: "codepath"
|
|
1623
|
+
})
|
|
1624
|
+
}
|
|
1625
|
+
}, requestOptions);
|
|
1626
|
+
return apiClient.deactivateSchedule(scheduleId, $requestOptions);
|
|
1247
1627
|
}
|
|
1248
1628
|
__name(deactivate, "deactivate");
|
|
1249
|
-
function activate(scheduleId) {
|
|
1629
|
+
function activate(scheduleId, requestOptions) {
|
|
1250
1630
|
const apiClient = apiClientManager.client;
|
|
1251
1631
|
if (!apiClient) {
|
|
1252
1632
|
throw apiClientMissingError();
|
|
1253
1633
|
}
|
|
1254
|
-
|
|
1634
|
+
const $requestOptions = mergeRequestOptions({
|
|
1635
|
+
tracer,
|
|
1636
|
+
name: "schedules.activate()",
|
|
1637
|
+
icon: "clock",
|
|
1638
|
+
attributes: {
|
|
1639
|
+
scheduleId,
|
|
1640
|
+
...accessoryAttributes({
|
|
1641
|
+
items: [
|
|
1642
|
+
{
|
|
1643
|
+
text: scheduleId,
|
|
1644
|
+
variant: "normal"
|
|
1645
|
+
}
|
|
1646
|
+
],
|
|
1647
|
+
style: "codepath"
|
|
1648
|
+
})
|
|
1649
|
+
}
|
|
1650
|
+
}, requestOptions);
|
|
1651
|
+
return apiClient.activateSchedule(scheduleId, $requestOptions);
|
|
1255
1652
|
}
|
|
1256
1653
|
__name(activate, "activate");
|
|
1257
|
-
function list(options) {
|
|
1654
|
+
function list(options, requestOptions) {
|
|
1258
1655
|
const apiClient = apiClientManager.client;
|
|
1259
1656
|
if (!apiClient) {
|
|
1260
1657
|
throw apiClientMissingError();
|
|
1261
1658
|
}
|
|
1262
|
-
|
|
1659
|
+
const $requestOptions = mergeRequestOptions({
|
|
1660
|
+
tracer,
|
|
1661
|
+
name: "schedules.list()",
|
|
1662
|
+
icon: "clock"
|
|
1663
|
+
}, requestOptions);
|
|
1664
|
+
return apiClient.listSchedules(options, $requestOptions);
|
|
1263
1665
|
}
|
|
1264
1666
|
__name(list, "list");
|
|
1265
1667
|
function timezones(options) {
|
|
@@ -1286,14 +1688,15 @@ __export(envvars_exports, {
|
|
|
1286
1688
|
update: () => update2,
|
|
1287
1689
|
upload: () => upload
|
|
1288
1690
|
});
|
|
1289
|
-
function upload(projectRefOrParams,
|
|
1691
|
+
function upload(projectRefOrParams, slugOrRequestOptions, params, requestOptions) {
|
|
1290
1692
|
let $projectRef;
|
|
1291
1693
|
let $params;
|
|
1292
1694
|
let $slug;
|
|
1695
|
+
const $requestOptions = overloadRequestOptions("upload", slugOrRequestOptions, requestOptions);
|
|
1293
1696
|
if (taskContext.ctx) {
|
|
1294
1697
|
if (typeof projectRefOrParams === "string") {
|
|
1295
1698
|
$projectRef = projectRefOrParams;
|
|
1296
|
-
$slug =
|
|
1699
|
+
$slug = typeof slugOrRequestOptions === "string" ? slugOrRequestOptions : taskContext.ctx.environment.slug;
|
|
1297
1700
|
if (!params) {
|
|
1298
1701
|
throw new Error("params is required");
|
|
1299
1702
|
}
|
|
@@ -1307,47 +1710,54 @@ function upload(projectRefOrParams, slug, params) {
|
|
|
1307
1710
|
if (typeof projectRefOrParams !== "string") {
|
|
1308
1711
|
throw new Error("projectRef is required");
|
|
1309
1712
|
}
|
|
1310
|
-
if (!
|
|
1713
|
+
if (!slugOrRequestOptions || typeof slugOrRequestOptions !== "string") {
|
|
1311
1714
|
throw new Error("slug is required");
|
|
1312
1715
|
}
|
|
1313
1716
|
if (!params) {
|
|
1314
1717
|
throw new Error("params is required");
|
|
1315
1718
|
}
|
|
1316
1719
|
$projectRef = projectRefOrParams;
|
|
1317
|
-
$slug =
|
|
1720
|
+
$slug = slugOrRequestOptions;
|
|
1318
1721
|
$params = params;
|
|
1319
1722
|
}
|
|
1320
1723
|
const apiClient = apiClientManager.client;
|
|
1321
1724
|
if (!apiClient) {
|
|
1322
1725
|
throw apiClientMissingError();
|
|
1323
1726
|
}
|
|
1324
|
-
return apiClient.importEnvVars($projectRef, $slug, $params);
|
|
1727
|
+
return apiClient.importEnvVars($projectRef, $slug, $params, $requestOptions);
|
|
1325
1728
|
}
|
|
1326
1729
|
__name(upload, "upload");
|
|
1327
|
-
function list2(
|
|
1328
|
-
const $projectRef =
|
|
1730
|
+
function list2(projectRefOrRequestOptions, slug, requestOptions) {
|
|
1731
|
+
const $projectRef = !isRequestOptions(projectRefOrRequestOptions) ? projectRefOrRequestOptions : taskContext.ctx?.project.ref;
|
|
1329
1732
|
const $slug = slug ?? taskContext.ctx?.environment.slug;
|
|
1733
|
+
let $requestOptions = isRequestOptions(projectRefOrRequestOptions) ? projectRefOrRequestOptions : requestOptions;
|
|
1330
1734
|
if (!$projectRef) {
|
|
1331
1735
|
throw new Error("projectRef is required");
|
|
1332
1736
|
}
|
|
1333
1737
|
if (!$slug) {
|
|
1334
1738
|
throw new Error("slug is required");
|
|
1335
1739
|
}
|
|
1740
|
+
$requestOptions = mergeRequestOptions({
|
|
1741
|
+
tracer,
|
|
1742
|
+
name: "envvars.list()",
|
|
1743
|
+
icon: "id-badge"
|
|
1744
|
+
}, $requestOptions);
|
|
1336
1745
|
const apiClient = apiClientManager.client;
|
|
1337
1746
|
if (!apiClient) {
|
|
1338
1747
|
throw apiClientMissingError();
|
|
1339
1748
|
}
|
|
1340
|
-
return apiClient.listEnvVars($projectRef, $slug);
|
|
1749
|
+
return apiClient.listEnvVars($projectRef, $slug, $requestOptions);
|
|
1341
1750
|
}
|
|
1342
1751
|
__name(list2, "list");
|
|
1343
|
-
function create2(projectRefOrParams,
|
|
1752
|
+
function create2(projectRefOrParams, slugOrRequestOptions, params, requestOptions) {
|
|
1344
1753
|
let $projectRef;
|
|
1345
1754
|
let $slug;
|
|
1346
1755
|
let $params;
|
|
1756
|
+
const $requestOptions = overloadRequestOptions("create", slugOrRequestOptions, requestOptions);
|
|
1347
1757
|
if (taskContext.ctx) {
|
|
1348
1758
|
if (typeof projectRefOrParams === "string") {
|
|
1349
1759
|
$projectRef = projectRefOrParams;
|
|
1350
|
-
$slug =
|
|
1760
|
+
$slug = typeof slugOrRequestOptions === "string" ? slugOrRequestOptions : taskContext.ctx.environment.slug;
|
|
1351
1761
|
if (!params) {
|
|
1352
1762
|
throw new Error("params is required");
|
|
1353
1763
|
}
|
|
@@ -1361,31 +1771,32 @@ function create2(projectRefOrParams, slug, params) {
|
|
|
1361
1771
|
if (typeof projectRefOrParams !== "string") {
|
|
1362
1772
|
throw new Error("projectRef is required");
|
|
1363
1773
|
}
|
|
1364
|
-
if (!
|
|
1774
|
+
if (!slugOrRequestOptions || typeof slugOrRequestOptions !== "string") {
|
|
1365
1775
|
throw new Error("slug is required");
|
|
1366
1776
|
}
|
|
1367
1777
|
if (!params) {
|
|
1368
1778
|
throw new Error("params is required");
|
|
1369
1779
|
}
|
|
1370
1780
|
$projectRef = projectRefOrParams;
|
|
1371
|
-
$slug =
|
|
1781
|
+
$slug = slugOrRequestOptions;
|
|
1372
1782
|
$params = params;
|
|
1373
1783
|
}
|
|
1374
1784
|
const apiClient = apiClientManager.client;
|
|
1375
1785
|
if (!apiClient) {
|
|
1376
1786
|
throw apiClientMissingError();
|
|
1377
1787
|
}
|
|
1378
|
-
return apiClient.createEnvVar($projectRef, $slug, $params);
|
|
1788
|
+
return apiClient.createEnvVar($projectRef, $slug, $params, $requestOptions);
|
|
1379
1789
|
}
|
|
1380
1790
|
__name(create2, "create");
|
|
1381
|
-
function retrieve2(projectRefOrName,
|
|
1791
|
+
function retrieve2(projectRefOrName, slugOrRequestOptions, name1, requestOptions) {
|
|
1382
1792
|
let $projectRef;
|
|
1383
1793
|
let $slug;
|
|
1384
1794
|
let $name;
|
|
1385
|
-
|
|
1795
|
+
const $requestOptions = overloadRequestOptions("retrieve", slugOrRequestOptions, requestOptions);
|
|
1796
|
+
if (typeof name1 === "string") {
|
|
1386
1797
|
$projectRef = projectRefOrName;
|
|
1387
|
-
$slug = slug;
|
|
1388
|
-
$name =
|
|
1798
|
+
$slug = typeof slugOrRequestOptions === "string" ? slugOrRequestOptions : taskContext.ctx?.environment.slug;
|
|
1799
|
+
$name = name1;
|
|
1389
1800
|
} else {
|
|
1390
1801
|
$projectRef = taskContext.ctx?.project.ref;
|
|
1391
1802
|
$slug = taskContext.ctx?.environment.slug;
|
|
@@ -1401,17 +1812,18 @@ function retrieve2(projectRefOrName, slug, name) {
|
|
|
1401
1812
|
if (!apiClient) {
|
|
1402
1813
|
throw apiClientMissingError();
|
|
1403
1814
|
}
|
|
1404
|
-
return apiClient.retrieveEnvVar($projectRef, $slug, $name);
|
|
1815
|
+
return apiClient.retrieveEnvVar($projectRef, $slug, $name, $requestOptions);
|
|
1405
1816
|
}
|
|
1406
1817
|
__name(retrieve2, "retrieve");
|
|
1407
|
-
function del2(projectRefOrName,
|
|
1818
|
+
function del2(projectRefOrName, slugOrRequestOptions, name1, requestOptions) {
|
|
1408
1819
|
let $projectRef;
|
|
1409
1820
|
let $slug;
|
|
1410
1821
|
let $name;
|
|
1411
|
-
|
|
1822
|
+
const $requestOptions = overloadRequestOptions("del", slugOrRequestOptions, requestOptions);
|
|
1823
|
+
if (typeof name1 === "string") {
|
|
1412
1824
|
$projectRef = projectRefOrName;
|
|
1413
|
-
$slug = slug;
|
|
1414
|
-
$name =
|
|
1825
|
+
$slug = typeof slugOrRequestOptions === "string" ? slugOrRequestOptions : taskContext.ctx?.environment.slug;
|
|
1826
|
+
$name = name1;
|
|
1415
1827
|
} else {
|
|
1416
1828
|
$projectRef = taskContext.ctx?.project.ref;
|
|
1417
1829
|
$slug = taskContext.ctx?.environment.slug;
|
|
@@ -1427,19 +1839,20 @@ function del2(projectRefOrName, slug, name) {
|
|
|
1427
1839
|
if (!apiClient) {
|
|
1428
1840
|
throw apiClientMissingError();
|
|
1429
1841
|
}
|
|
1430
|
-
return apiClient.deleteEnvVar($projectRef, $slug, $name);
|
|
1842
|
+
return apiClient.deleteEnvVar($projectRef, $slug, $name, $requestOptions);
|
|
1431
1843
|
}
|
|
1432
1844
|
__name(del2, "del");
|
|
1433
|
-
function update2(projectRefOrName, slugOrParams,
|
|
1845
|
+
function update2(projectRefOrName, slugOrParams, nameOrRequestOptions, params, requestOptions) {
|
|
1434
1846
|
let $projectRef;
|
|
1435
1847
|
let $slug;
|
|
1436
1848
|
let $name;
|
|
1437
1849
|
let $params;
|
|
1850
|
+
const $requestOptions = overloadRequestOptions("update", nameOrRequestOptions, requestOptions);
|
|
1438
1851
|
if (taskContext.ctx) {
|
|
1439
1852
|
if (typeof slugOrParams === "string") {
|
|
1440
1853
|
$projectRef = slugOrParams;
|
|
1441
1854
|
$slug = slugOrParams ?? taskContext.ctx.environment.slug;
|
|
1442
|
-
$name =
|
|
1855
|
+
$name = typeof nameOrRequestOptions === "string" ? nameOrRequestOptions : taskContext.ctx.environment.slug;
|
|
1443
1856
|
if (!params) {
|
|
1444
1857
|
throw new Error("params is required");
|
|
1445
1858
|
}
|
|
@@ -1469,9 +1882,25 @@ function update2(projectRefOrName, slugOrParams, name, params) {
|
|
|
1469
1882
|
if (!apiClient) {
|
|
1470
1883
|
throw apiClientMissingError();
|
|
1471
1884
|
}
|
|
1472
|
-
return apiClient.updateEnvVar($projectRef, $slug, $name, $params);
|
|
1885
|
+
return apiClient.updateEnvVar($projectRef, $slug, $name, $params, $requestOptions);
|
|
1473
1886
|
}
|
|
1474
1887
|
__name(update2, "update");
|
|
1888
|
+
function overloadRequestOptions(name1, slugOrRequestOptions, requestOptions) {
|
|
1889
|
+
if (isRequestOptions(slugOrRequestOptions)) {
|
|
1890
|
+
return mergeRequestOptions({
|
|
1891
|
+
tracer,
|
|
1892
|
+
name: `envvars.${name1}()`,
|
|
1893
|
+
icon: "id-badge"
|
|
1894
|
+
}, slugOrRequestOptions);
|
|
1895
|
+
} else {
|
|
1896
|
+
return mergeRequestOptions({
|
|
1897
|
+
tracer,
|
|
1898
|
+
name: `envvars.${name1}()`,
|
|
1899
|
+
icon: "id-badge"
|
|
1900
|
+
}, requestOptions);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
__name(overloadRequestOptions, "overloadRequestOptions");
|
|
1475
1904
|
|
|
1476
1905
|
// src/v3/index.ts
|
|
1477
1906
|
function configure(options) {
|
|
@@ -1479,6 +1908,6 @@ function configure(options) {
|
|
|
1479
1908
|
}
|
|
1480
1909
|
__name(configure, "configure");
|
|
1481
1910
|
|
|
1482
|
-
export { InMemoryCache, configure, createCache, envvars_exports as envvars, queue, retry, runs, schedules_exports as schedules, task, tasks, usage, wait };
|
|
1911
|
+
export { InMemoryCache, configure, createCache, envvars_exports as envvars, idempotencyKeys, isIdempotencyKey, queue, retry, runs, schedules_exports as schedules, task, tasks, usage, wait };
|
|
1483
1912
|
//# sourceMappingURL=out.js.map
|
|
1484
1913
|
//# sourceMappingURL=index.mjs.map
|