@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/workers/index.js
CHANGED
|
@@ -11,6 +11,8 @@ var sdkLogs = require('@opentelemetry/sdk-logs');
|
|
|
11
11
|
var sdkTraceNode = require('@opentelemetry/sdk-trace-node');
|
|
12
12
|
var semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
13
13
|
var zodValidationError = require('zod-validation-error');
|
|
14
|
+
var formDataEncoder = require('form-data-encoder');
|
|
15
|
+
var stream = require('stream');
|
|
14
16
|
var preciseDate = require('@google-cloud/precise-date');
|
|
15
17
|
var util = require('util');
|
|
16
18
|
var promises = require('timers/promises');
|
|
@@ -370,7 +372,7 @@ function getEnvVar(name) {
|
|
|
370
372
|
__name(getEnvVar, "getEnvVar");
|
|
371
373
|
|
|
372
374
|
// package.json
|
|
373
|
-
var version = "0.0.0-v3-prerelease-
|
|
375
|
+
var version = "0.0.0-v3-prerelease-20240620125011";
|
|
374
376
|
|
|
375
377
|
// src/v3/otel/tracingSDK.ts
|
|
376
378
|
var _a;
|
|
@@ -463,16 +465,12 @@ var _TracingSDK = class _TracingSDK {
|
|
|
463
465
|
this.getTracer = traceProvider.getTracer.bind(traceProvider);
|
|
464
466
|
}
|
|
465
467
|
async flush() {
|
|
466
|
-
await
|
|
467
|
-
|
|
468
|
-
this._logProvider.forceFlush()
|
|
469
|
-
]);
|
|
468
|
+
await this._traceProvider.forceFlush();
|
|
469
|
+
await this._logProvider.forceFlush();
|
|
470
470
|
}
|
|
471
471
|
async shutdown() {
|
|
472
|
-
await
|
|
473
|
-
|
|
474
|
-
this._logProvider.shutdown()
|
|
475
|
-
]);
|
|
472
|
+
await this._traceProvider.shutdown();
|
|
473
|
+
await this._logProvider.shutdown();
|
|
476
474
|
}
|
|
477
475
|
};
|
|
478
476
|
__name(_TracingSDK, "TracingSDK");
|
|
@@ -1621,6 +1619,37 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
|
|
|
1621
1619
|
return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
|
|
1622
1620
|
}
|
|
1623
1621
|
__name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
|
|
1622
|
+
function zodupload(schema, url, body, requestInit, options) {
|
|
1623
|
+
const finalRequestInit = createMultipartFormRequestInit(body, requestInit);
|
|
1624
|
+
return new ApiPromise(_doZodFetch(schema, url, finalRequestInit, options));
|
|
1625
|
+
}
|
|
1626
|
+
__name(zodupload, "zodupload");
|
|
1627
|
+
async function createMultipartFormRequestInit(body, requestInit) {
|
|
1628
|
+
const form = await createForm(body);
|
|
1629
|
+
const encoder = new formDataEncoder.FormDataEncoder(form);
|
|
1630
|
+
const finalHeaders = {};
|
|
1631
|
+
for (const [key, value] of Object.entries(requestInit?.headers || {})) {
|
|
1632
|
+
finalHeaders[key] = value;
|
|
1633
|
+
}
|
|
1634
|
+
for (const [key, value] of Object.entries(encoder.headers)) {
|
|
1635
|
+
finalHeaders[key] = value;
|
|
1636
|
+
}
|
|
1637
|
+
finalHeaders["Content-Length"] = String(encoder.contentLength);
|
|
1638
|
+
const finalRequestInit = {
|
|
1639
|
+
...requestInit,
|
|
1640
|
+
headers: finalHeaders,
|
|
1641
|
+
body: stream.Readable.from(encoder),
|
|
1642
|
+
// @ts-expect-error
|
|
1643
|
+
duplex: "half"
|
|
1644
|
+
};
|
|
1645
|
+
return finalRequestInit;
|
|
1646
|
+
}
|
|
1647
|
+
__name(createMultipartFormRequestInit, "createMultipartFormRequestInit");
|
|
1648
|
+
var createForm = /* @__PURE__ */ __name(async (body) => {
|
|
1649
|
+
const form = new FormData();
|
|
1650
|
+
await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
|
|
1651
|
+
return form;
|
|
1652
|
+
}, "createForm");
|
|
1624
1653
|
async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
1625
1654
|
try {
|
|
1626
1655
|
const $requestInit = await requestInit;
|
|
@@ -1746,6 +1775,95 @@ function requestInitWithCache(requestInit) {
|
|
|
1746
1775
|
}
|
|
1747
1776
|
}
|
|
1748
1777
|
__name(requestInitWithCache, "requestInitWithCache");
|
|
1778
|
+
var addFormValue = /* @__PURE__ */ __name(async (form, key, value) => {
|
|
1779
|
+
if (value === void 0)
|
|
1780
|
+
return;
|
|
1781
|
+
if (value == null) {
|
|
1782
|
+
throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
|
|
1783
|
+
}
|
|
1784
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1785
|
+
form.append(key, String(value));
|
|
1786
|
+
} else if (isUploadable(value) || isBlobLike(value) || value instanceof Buffer || value instanceof ArrayBuffer) {
|
|
1787
|
+
const file = await toFile(value);
|
|
1788
|
+
form.append(key, file);
|
|
1789
|
+
} else if (Array.isArray(value)) {
|
|
1790
|
+
await Promise.all(value.map((entry) => addFormValue(form, key + "[]", entry)));
|
|
1791
|
+
} else if (typeof value === "object") {
|
|
1792
|
+
await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
|
|
1793
|
+
} else {
|
|
1794
|
+
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
|
|
1795
|
+
}
|
|
1796
|
+
}, "addFormValue");
|
|
1797
|
+
async function toFile(value, name, options) {
|
|
1798
|
+
value = await value;
|
|
1799
|
+
options ??= isFileLike(value) ? {
|
|
1800
|
+
lastModified: value.lastModified,
|
|
1801
|
+
type: value.type
|
|
1802
|
+
} : {};
|
|
1803
|
+
if (isResponseLike(value)) {
|
|
1804
|
+
const blob = await value.blob();
|
|
1805
|
+
name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? "unknown_file";
|
|
1806
|
+
return new File([
|
|
1807
|
+
blob
|
|
1808
|
+
], name, options);
|
|
1809
|
+
}
|
|
1810
|
+
const bits = await getBytes(value);
|
|
1811
|
+
name ||= getName(value) ?? "unknown_file";
|
|
1812
|
+
if (!options.type) {
|
|
1813
|
+
const type = bits[0]?.type;
|
|
1814
|
+
if (typeof type === "string") {
|
|
1815
|
+
options = {
|
|
1816
|
+
...options,
|
|
1817
|
+
type
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
return new File(bits, name, options);
|
|
1822
|
+
}
|
|
1823
|
+
__name(toFile, "toFile");
|
|
1824
|
+
function getName(value) {
|
|
1825
|
+
return getStringFromMaybeBuffer(value.name) || getStringFromMaybeBuffer(value.filename) || // For fs.ReadStream
|
|
1826
|
+
getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop();
|
|
1827
|
+
}
|
|
1828
|
+
__name(getName, "getName");
|
|
1829
|
+
var getStringFromMaybeBuffer = /* @__PURE__ */ __name((x) => {
|
|
1830
|
+
if (typeof x === "string")
|
|
1831
|
+
return x;
|
|
1832
|
+
if (typeof Buffer !== "undefined" && x instanceof Buffer)
|
|
1833
|
+
return String(x);
|
|
1834
|
+
return void 0;
|
|
1835
|
+
}, "getStringFromMaybeBuffer");
|
|
1836
|
+
async function getBytes(value) {
|
|
1837
|
+
let parts = [];
|
|
1838
|
+
if (typeof value === "string" || ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
|
|
1839
|
+
value instanceof ArrayBuffer) {
|
|
1840
|
+
parts.push(value);
|
|
1841
|
+
} else if (isBlobLike(value)) {
|
|
1842
|
+
parts.push(await value.arrayBuffer());
|
|
1843
|
+
} else if (isAsyncIterableIterator(value)) {
|
|
1844
|
+
for await (const chunk of value) {
|
|
1845
|
+
parts.push(chunk);
|
|
1846
|
+
}
|
|
1847
|
+
} else {
|
|
1848
|
+
throw new Error(`Unexpected data type: ${typeof value}; constructor: ${value?.constructor?.name}; props: ${propsForError(value)}`);
|
|
1849
|
+
}
|
|
1850
|
+
return parts;
|
|
1851
|
+
}
|
|
1852
|
+
__name(getBytes, "getBytes");
|
|
1853
|
+
function propsForError(value) {
|
|
1854
|
+
const props = Object.getOwnPropertyNames(value);
|
|
1855
|
+
return `[${props.map((p) => `"${p}"`).join(", ")}]`;
|
|
1856
|
+
}
|
|
1857
|
+
__name(propsForError, "propsForError");
|
|
1858
|
+
var isAsyncIterableIterator = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function", "isAsyncIterableIterator");
|
|
1859
|
+
var isResponseLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function", "isResponseLike");
|
|
1860
|
+
var isFileLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.name === "string" && typeof value.lastModified === "number" && isBlobLike(value), "isFileLike");
|
|
1861
|
+
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");
|
|
1862
|
+
var isFsReadStream = /* @__PURE__ */ __name((value) => value instanceof stream.Readable, "isFsReadStream");
|
|
1863
|
+
var isUploadable = /* @__PURE__ */ __name((value) => {
|
|
1864
|
+
return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
|
|
1865
|
+
}, "isUploadable");
|
|
1866
|
+
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");
|
|
1749
1867
|
var _ApiPromise = class _ApiPromise extends Promise {
|
|
1750
1868
|
constructor(responsePromise) {
|
|
1751
1869
|
super((resolve) => {
|
|
@@ -2041,11 +2159,18 @@ var _ApiClient = class _ApiClient {
|
|
|
2041
2159
|
});
|
|
2042
2160
|
}
|
|
2043
2161
|
importEnvVars(projectRef, slug, body) {
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2162
|
+
if (isRecordLike(body.variables)) {
|
|
2163
|
+
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
|
|
2164
|
+
method: "POST",
|
|
2165
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2166
|
+
body: JSON.stringify(body)
|
|
2167
|
+
});
|
|
2168
|
+
} else {
|
|
2169
|
+
return zodupload(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, body, {
|
|
2170
|
+
method: "POST",
|
|
2171
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2049
2174
|
}
|
|
2050
2175
|
retrieveEnvVar(projectRef, slug, key) {
|
|
2051
2176
|
return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|