@trigger.dev/core 0.0.0-v3-prerelease-20240620110206 → 0.0.0-v3-prerelease-20240620125011
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/{messages-xJbR1Vai.d.mts → messages--WkQvA2l.d.mts} +0 -10
- package/dist/{messages-xJbR1Vai.d.ts → messages--WkQvA2l.d.ts} +0 -10
- package/dist/v3/index.d.mts +5 -4
- package/dist/v3/index.d.ts +5 -4
- package/dist/v3/index.js +136 -10
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +136 -10
- package/dist/v3/index.mjs.map +1 -1
- package/dist/v3/otel/index.js +5 -9
- package/dist/v3/otel/index.js.map +1 -1
- package/dist/v3/otel/index.mjs +5 -9
- package/dist/v3/otel/index.mjs.map +1 -1
- package/dist/v3/prod/index.d.mts +1 -1
- package/dist/v3/prod/index.d.ts +1 -1
- package/dist/v3/workers/index.d.mts +1 -1
- package/dist/v3/workers/index.d.ts +1 -1
- package/dist/v3/workers/index.js +139 -14
- package/dist/v3/workers/index.js.map +1 -1
- package/dist/v3/workers/index.mjs +139 -14
- package/dist/v3/workers/index.mjs.map +1 -1
- package/dist/v3/zodfetch.d.mts +57 -1
- package/dist/v3/zodfetch.d.ts +57 -1
- package/dist/v3/zodfetch.js +130 -0
- package/dist/v3/zodfetch.js.map +1 -1
- package/dist/v3/zodfetch.mjs +123 -1
- package/dist/v3/zodfetch.mjs.map +1 -1
- package/package.json +2 -2
package/dist/v3/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { propagation, context, trace, SpanStatusCode } from '@opentelemetry/api';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { fromZodError } from 'zod-validation-error';
|
|
4
|
+
import { FormDataEncoder } from 'form-data-encoder';
|
|
5
|
+
import { Readable } from 'node: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';
|
|
@@ -27,7 +29,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
// package.json
|
|
30
|
-
var version = "0.0.0-v3-prerelease-
|
|
32
|
+
var version = "0.0.0-v3-prerelease-20240620125011";
|
|
31
33
|
var dependencies = {
|
|
32
34
|
"@google-cloud/precise-date": "^4.0.0",
|
|
33
35
|
"@opentelemetry/api": "^1.8.0",
|
|
@@ -41,6 +43,7 @@ var dependencies = {
|
|
|
41
43
|
"@opentelemetry/sdk-trace-base": "^1.22.0",
|
|
42
44
|
"@opentelemetry/sdk-trace-node": "^1.22.0",
|
|
43
45
|
"@opentelemetry/semantic-conventions": "^1.22.0",
|
|
46
|
+
"form-data-encoder": "^4.0.2",
|
|
44
47
|
"humanize-duration": "^3.27.3",
|
|
45
48
|
"socket.io-client": "4.7.4",
|
|
46
49
|
superjson: "^2.2.1",
|
|
@@ -1508,10 +1511,6 @@ var CoordinatorToPlatformMessages = {
|
|
|
1508
1511
|
attemptNumber: z.number()
|
|
1509
1512
|
})
|
|
1510
1513
|
])
|
|
1511
|
-
}),
|
|
1512
|
-
callback: z.object({
|
|
1513
|
-
version: z.literal("v1").default("v1"),
|
|
1514
|
-
keepRunAlive: z.boolean()
|
|
1515
1514
|
})
|
|
1516
1515
|
},
|
|
1517
1516
|
INDEXING_FAILED: {
|
|
@@ -2622,6 +2621,37 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
|
|
|
2622
2621
|
return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
|
|
2623
2622
|
}
|
|
2624
2623
|
__name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
|
|
2624
|
+
function zodupload(schema, url, body, requestInit, options) {
|
|
2625
|
+
const finalRequestInit = createMultipartFormRequestInit(body, requestInit);
|
|
2626
|
+
return new ApiPromise(_doZodFetch(schema, url, finalRequestInit, options));
|
|
2627
|
+
}
|
|
2628
|
+
__name(zodupload, "zodupload");
|
|
2629
|
+
async function createMultipartFormRequestInit(body, requestInit) {
|
|
2630
|
+
const form = await createForm(body);
|
|
2631
|
+
const encoder = new FormDataEncoder(form);
|
|
2632
|
+
const finalHeaders = {};
|
|
2633
|
+
for (const [key, value] of Object.entries(requestInit?.headers || {})) {
|
|
2634
|
+
finalHeaders[key] = value;
|
|
2635
|
+
}
|
|
2636
|
+
for (const [key, value] of Object.entries(encoder.headers)) {
|
|
2637
|
+
finalHeaders[key] = value;
|
|
2638
|
+
}
|
|
2639
|
+
finalHeaders["Content-Length"] = String(encoder.contentLength);
|
|
2640
|
+
const finalRequestInit = {
|
|
2641
|
+
...requestInit,
|
|
2642
|
+
headers: finalHeaders,
|
|
2643
|
+
body: Readable.from(encoder),
|
|
2644
|
+
// @ts-expect-error
|
|
2645
|
+
duplex: "half"
|
|
2646
|
+
};
|
|
2647
|
+
return finalRequestInit;
|
|
2648
|
+
}
|
|
2649
|
+
__name(createMultipartFormRequestInit, "createMultipartFormRequestInit");
|
|
2650
|
+
var createForm = /* @__PURE__ */ __name(async (body) => {
|
|
2651
|
+
const form = new FormData();
|
|
2652
|
+
await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
|
|
2653
|
+
return form;
|
|
2654
|
+
}, "createForm");
|
|
2625
2655
|
async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
2626
2656
|
try {
|
|
2627
2657
|
const $requestInit = await requestInit;
|
|
@@ -2747,6 +2777,95 @@ function requestInitWithCache(requestInit) {
|
|
|
2747
2777
|
}
|
|
2748
2778
|
}
|
|
2749
2779
|
__name(requestInitWithCache, "requestInitWithCache");
|
|
2780
|
+
var addFormValue = /* @__PURE__ */ __name(async (form, key, value) => {
|
|
2781
|
+
if (value === void 0)
|
|
2782
|
+
return;
|
|
2783
|
+
if (value == null) {
|
|
2784
|
+
throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
|
|
2785
|
+
}
|
|
2786
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
2787
|
+
form.append(key, String(value));
|
|
2788
|
+
} else if (isUploadable(value) || isBlobLike(value) || value instanceof Buffer || value instanceof ArrayBuffer) {
|
|
2789
|
+
const file = await toFile(value);
|
|
2790
|
+
form.append(key, file);
|
|
2791
|
+
} else if (Array.isArray(value)) {
|
|
2792
|
+
await Promise.all(value.map((entry) => addFormValue(form, key + "[]", entry)));
|
|
2793
|
+
} else if (typeof value === "object") {
|
|
2794
|
+
await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
|
|
2795
|
+
} else {
|
|
2796
|
+
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
|
|
2797
|
+
}
|
|
2798
|
+
}, "addFormValue");
|
|
2799
|
+
async function toFile(value, name, options) {
|
|
2800
|
+
value = await value;
|
|
2801
|
+
options ??= isFileLike(value) ? {
|
|
2802
|
+
lastModified: value.lastModified,
|
|
2803
|
+
type: value.type
|
|
2804
|
+
} : {};
|
|
2805
|
+
if (isResponseLike(value)) {
|
|
2806
|
+
const blob = await value.blob();
|
|
2807
|
+
name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? "unknown_file";
|
|
2808
|
+
return new File([
|
|
2809
|
+
blob
|
|
2810
|
+
], name, options);
|
|
2811
|
+
}
|
|
2812
|
+
const bits = await getBytes(value);
|
|
2813
|
+
name ||= getName(value) ?? "unknown_file";
|
|
2814
|
+
if (!options.type) {
|
|
2815
|
+
const type = bits[0]?.type;
|
|
2816
|
+
if (typeof type === "string") {
|
|
2817
|
+
options = {
|
|
2818
|
+
...options,
|
|
2819
|
+
type
|
|
2820
|
+
};
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
return new File(bits, name, options);
|
|
2824
|
+
}
|
|
2825
|
+
__name(toFile, "toFile");
|
|
2826
|
+
function getName(value) {
|
|
2827
|
+
return getStringFromMaybeBuffer(value.name) || getStringFromMaybeBuffer(value.filename) || // For fs.ReadStream
|
|
2828
|
+
getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop();
|
|
2829
|
+
}
|
|
2830
|
+
__name(getName, "getName");
|
|
2831
|
+
var getStringFromMaybeBuffer = /* @__PURE__ */ __name((x) => {
|
|
2832
|
+
if (typeof x === "string")
|
|
2833
|
+
return x;
|
|
2834
|
+
if (typeof Buffer !== "undefined" && x instanceof Buffer)
|
|
2835
|
+
return String(x);
|
|
2836
|
+
return void 0;
|
|
2837
|
+
}, "getStringFromMaybeBuffer");
|
|
2838
|
+
async function getBytes(value) {
|
|
2839
|
+
let parts = [];
|
|
2840
|
+
if (typeof value === "string" || ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
|
|
2841
|
+
value instanceof ArrayBuffer) {
|
|
2842
|
+
parts.push(value);
|
|
2843
|
+
} else if (isBlobLike(value)) {
|
|
2844
|
+
parts.push(await value.arrayBuffer());
|
|
2845
|
+
} else if (isAsyncIterableIterator(value)) {
|
|
2846
|
+
for await (const chunk of value) {
|
|
2847
|
+
parts.push(chunk);
|
|
2848
|
+
}
|
|
2849
|
+
} else {
|
|
2850
|
+
throw new Error(`Unexpected data type: ${typeof value}; constructor: ${value?.constructor?.name}; props: ${propsForError(value)}`);
|
|
2851
|
+
}
|
|
2852
|
+
return parts;
|
|
2853
|
+
}
|
|
2854
|
+
__name(getBytes, "getBytes");
|
|
2855
|
+
function propsForError(value) {
|
|
2856
|
+
const props = Object.getOwnPropertyNames(value);
|
|
2857
|
+
return `[${props.map((p) => `"${p}"`).join(", ")}]`;
|
|
2858
|
+
}
|
|
2859
|
+
__name(propsForError, "propsForError");
|
|
2860
|
+
var isAsyncIterableIterator = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function", "isAsyncIterableIterator");
|
|
2861
|
+
var isResponseLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function", "isResponseLike");
|
|
2862
|
+
var isFileLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.name === "string" && typeof value.lastModified === "number" && isBlobLike(value), "isFileLike");
|
|
2863
|
+
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");
|
|
2864
|
+
var isFsReadStream = /* @__PURE__ */ __name((value) => value instanceof Readable, "isFsReadStream");
|
|
2865
|
+
var isUploadable = /* @__PURE__ */ __name((value) => {
|
|
2866
|
+
return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
|
|
2867
|
+
}, "isUploadable");
|
|
2868
|
+
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");
|
|
2750
2869
|
var _ApiPromise = class _ApiPromise extends Promise {
|
|
2751
2870
|
constructor(responsePromise) {
|
|
2752
2871
|
super((resolve) => {
|
|
@@ -3042,11 +3161,18 @@ var _ApiClient = class _ApiClient {
|
|
|
3042
3161
|
});
|
|
3043
3162
|
}
|
|
3044
3163
|
importEnvVars(projectRef, slug, body) {
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3164
|
+
if (isRecordLike(body.variables)) {
|
|
3165
|
+
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
|
|
3166
|
+
method: "POST",
|
|
3167
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
3168
|
+
body: JSON.stringify(body)
|
|
3169
|
+
});
|
|
3170
|
+
} else {
|
|
3171
|
+
return zodupload(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, body, {
|
|
3172
|
+
method: "POST",
|
|
3173
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
3174
|
+
});
|
|
3175
|
+
}
|
|
3050
3176
|
}
|
|
3051
3177
|
retrieveEnvVar(projectRef, slug, key) {
|
|
3052
3178
|
return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|