@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
|
@@ -9,6 +9,8 @@ import { LoggerProvider, BatchLogRecordProcessor, SimpleLogRecordProcessor } fro
|
|
|
9
9
|
import { NodeTracerProvider, BatchSpanProcessor, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';
|
|
10
10
|
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
|
|
11
11
|
import { fromZodError } from 'zod-validation-error';
|
|
12
|
+
import { FormDataEncoder } from 'form-data-encoder';
|
|
13
|
+
import { Readable } from 'node:stream';
|
|
12
14
|
import { PreciseDate } from '@google-cloud/precise-date';
|
|
13
15
|
import util from 'node:util';
|
|
14
16
|
import { setInterval } from 'node:timers/promises';
|
|
@@ -364,7 +366,7 @@ function getEnvVar(name) {
|
|
|
364
366
|
__name(getEnvVar, "getEnvVar");
|
|
365
367
|
|
|
366
368
|
// package.json
|
|
367
|
-
var version = "0.0.0-v3-prerelease-
|
|
369
|
+
var version = "0.0.0-v3-prerelease-20240620125011";
|
|
368
370
|
|
|
369
371
|
// src/v3/otel/tracingSDK.ts
|
|
370
372
|
var _a;
|
|
@@ -457,16 +459,12 @@ var _TracingSDK = class _TracingSDK {
|
|
|
457
459
|
this.getTracer = traceProvider.getTracer.bind(traceProvider);
|
|
458
460
|
}
|
|
459
461
|
async flush() {
|
|
460
|
-
await
|
|
461
|
-
|
|
462
|
-
this._logProvider.forceFlush()
|
|
463
|
-
]);
|
|
462
|
+
await this._traceProvider.forceFlush();
|
|
463
|
+
await this._logProvider.forceFlush();
|
|
464
464
|
}
|
|
465
465
|
async shutdown() {
|
|
466
|
-
await
|
|
467
|
-
|
|
468
|
-
this._logProvider.shutdown()
|
|
469
|
-
]);
|
|
466
|
+
await this._traceProvider.shutdown();
|
|
467
|
+
await this._logProvider.shutdown();
|
|
470
468
|
}
|
|
471
469
|
};
|
|
472
470
|
__name(_TracingSDK, "TracingSDK");
|
|
@@ -1615,6 +1613,37 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
|
|
|
1615
1613
|
return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
|
|
1616
1614
|
}
|
|
1617
1615
|
__name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
|
|
1616
|
+
function zodupload(schema, url, body, requestInit, options) {
|
|
1617
|
+
const finalRequestInit = createMultipartFormRequestInit(body, requestInit);
|
|
1618
|
+
return new ApiPromise(_doZodFetch(schema, url, finalRequestInit, options));
|
|
1619
|
+
}
|
|
1620
|
+
__name(zodupload, "zodupload");
|
|
1621
|
+
async function createMultipartFormRequestInit(body, requestInit) {
|
|
1622
|
+
const form = await createForm(body);
|
|
1623
|
+
const encoder = new FormDataEncoder(form);
|
|
1624
|
+
const finalHeaders = {};
|
|
1625
|
+
for (const [key, value] of Object.entries(requestInit?.headers || {})) {
|
|
1626
|
+
finalHeaders[key] = value;
|
|
1627
|
+
}
|
|
1628
|
+
for (const [key, value] of Object.entries(encoder.headers)) {
|
|
1629
|
+
finalHeaders[key] = value;
|
|
1630
|
+
}
|
|
1631
|
+
finalHeaders["Content-Length"] = String(encoder.contentLength);
|
|
1632
|
+
const finalRequestInit = {
|
|
1633
|
+
...requestInit,
|
|
1634
|
+
headers: finalHeaders,
|
|
1635
|
+
body: Readable.from(encoder),
|
|
1636
|
+
// @ts-expect-error
|
|
1637
|
+
duplex: "half"
|
|
1638
|
+
};
|
|
1639
|
+
return finalRequestInit;
|
|
1640
|
+
}
|
|
1641
|
+
__name(createMultipartFormRequestInit, "createMultipartFormRequestInit");
|
|
1642
|
+
var createForm = /* @__PURE__ */ __name(async (body) => {
|
|
1643
|
+
const form = new FormData();
|
|
1644
|
+
await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
|
|
1645
|
+
return form;
|
|
1646
|
+
}, "createForm");
|
|
1618
1647
|
async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
1619
1648
|
try {
|
|
1620
1649
|
const $requestInit = await requestInit;
|
|
@@ -1740,6 +1769,95 @@ function requestInitWithCache(requestInit) {
|
|
|
1740
1769
|
}
|
|
1741
1770
|
}
|
|
1742
1771
|
__name(requestInitWithCache, "requestInitWithCache");
|
|
1772
|
+
var addFormValue = /* @__PURE__ */ __name(async (form, key, value) => {
|
|
1773
|
+
if (value === void 0)
|
|
1774
|
+
return;
|
|
1775
|
+
if (value == null) {
|
|
1776
|
+
throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
|
|
1777
|
+
}
|
|
1778
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1779
|
+
form.append(key, String(value));
|
|
1780
|
+
} else if (isUploadable(value) || isBlobLike(value) || value instanceof Buffer || value instanceof ArrayBuffer) {
|
|
1781
|
+
const file = await toFile(value);
|
|
1782
|
+
form.append(key, file);
|
|
1783
|
+
} else if (Array.isArray(value)) {
|
|
1784
|
+
await Promise.all(value.map((entry) => addFormValue(form, key + "[]", entry)));
|
|
1785
|
+
} else if (typeof value === "object") {
|
|
1786
|
+
await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
|
|
1787
|
+
} else {
|
|
1788
|
+
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
|
|
1789
|
+
}
|
|
1790
|
+
}, "addFormValue");
|
|
1791
|
+
async function toFile(value, name, options) {
|
|
1792
|
+
value = await value;
|
|
1793
|
+
options ??= isFileLike(value) ? {
|
|
1794
|
+
lastModified: value.lastModified,
|
|
1795
|
+
type: value.type
|
|
1796
|
+
} : {};
|
|
1797
|
+
if (isResponseLike(value)) {
|
|
1798
|
+
const blob = await value.blob();
|
|
1799
|
+
name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? "unknown_file";
|
|
1800
|
+
return new File([
|
|
1801
|
+
blob
|
|
1802
|
+
], name, options);
|
|
1803
|
+
}
|
|
1804
|
+
const bits = await getBytes(value);
|
|
1805
|
+
name ||= getName(value) ?? "unknown_file";
|
|
1806
|
+
if (!options.type) {
|
|
1807
|
+
const type = bits[0]?.type;
|
|
1808
|
+
if (typeof type === "string") {
|
|
1809
|
+
options = {
|
|
1810
|
+
...options,
|
|
1811
|
+
type
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
return new File(bits, name, options);
|
|
1816
|
+
}
|
|
1817
|
+
__name(toFile, "toFile");
|
|
1818
|
+
function getName(value) {
|
|
1819
|
+
return getStringFromMaybeBuffer(value.name) || getStringFromMaybeBuffer(value.filename) || // For fs.ReadStream
|
|
1820
|
+
getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop();
|
|
1821
|
+
}
|
|
1822
|
+
__name(getName, "getName");
|
|
1823
|
+
var getStringFromMaybeBuffer = /* @__PURE__ */ __name((x) => {
|
|
1824
|
+
if (typeof x === "string")
|
|
1825
|
+
return x;
|
|
1826
|
+
if (typeof Buffer !== "undefined" && x instanceof Buffer)
|
|
1827
|
+
return String(x);
|
|
1828
|
+
return void 0;
|
|
1829
|
+
}, "getStringFromMaybeBuffer");
|
|
1830
|
+
async function getBytes(value) {
|
|
1831
|
+
let parts = [];
|
|
1832
|
+
if (typeof value === "string" || ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
|
|
1833
|
+
value instanceof ArrayBuffer) {
|
|
1834
|
+
parts.push(value);
|
|
1835
|
+
} else if (isBlobLike(value)) {
|
|
1836
|
+
parts.push(await value.arrayBuffer());
|
|
1837
|
+
} else if (isAsyncIterableIterator(value)) {
|
|
1838
|
+
for await (const chunk of value) {
|
|
1839
|
+
parts.push(chunk);
|
|
1840
|
+
}
|
|
1841
|
+
} else {
|
|
1842
|
+
throw new Error(`Unexpected data type: ${typeof value}; constructor: ${value?.constructor?.name}; props: ${propsForError(value)}`);
|
|
1843
|
+
}
|
|
1844
|
+
return parts;
|
|
1845
|
+
}
|
|
1846
|
+
__name(getBytes, "getBytes");
|
|
1847
|
+
function propsForError(value) {
|
|
1848
|
+
const props = Object.getOwnPropertyNames(value);
|
|
1849
|
+
return `[${props.map((p) => `"${p}"`).join(", ")}]`;
|
|
1850
|
+
}
|
|
1851
|
+
__name(propsForError, "propsForError");
|
|
1852
|
+
var isAsyncIterableIterator = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function", "isAsyncIterableIterator");
|
|
1853
|
+
var isResponseLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function", "isResponseLike");
|
|
1854
|
+
var isFileLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.name === "string" && typeof value.lastModified === "number" && isBlobLike(value), "isFileLike");
|
|
1855
|
+
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");
|
|
1856
|
+
var isFsReadStream = /* @__PURE__ */ __name((value) => value instanceof Readable, "isFsReadStream");
|
|
1857
|
+
var isUploadable = /* @__PURE__ */ __name((value) => {
|
|
1858
|
+
return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
|
|
1859
|
+
}, "isUploadable");
|
|
1860
|
+
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");
|
|
1743
1861
|
var _ApiPromise = class _ApiPromise extends Promise {
|
|
1744
1862
|
constructor(responsePromise) {
|
|
1745
1863
|
super((resolve) => {
|
|
@@ -2035,11 +2153,18 @@ var _ApiClient = class _ApiClient {
|
|
|
2035
2153
|
});
|
|
2036
2154
|
}
|
|
2037
2155
|
importEnvVars(projectRef, slug, body) {
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2156
|
+
if (isRecordLike(body.variables)) {
|
|
2157
|
+
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
|
|
2158
|
+
method: "POST",
|
|
2159
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2160
|
+
body: JSON.stringify(body)
|
|
2161
|
+
});
|
|
2162
|
+
} else {
|
|
2163
|
+
return zodupload(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, body, {
|
|
2164
|
+
method: "POST",
|
|
2165
|
+
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2043
2168
|
}
|
|
2044
2169
|
retrieveEnvVar(projectRef, slug, key) {
|
|
2045
2170
|
return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|