@trigger.dev/core 3.0.0-beta.39 → 3.0.0-beta.40

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.
@@ -9,8 +9,6 @@ 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';
14
12
  import { PreciseDate } from '@google-cloud/precise-date';
15
13
  import util from 'node:util';
16
14
  import { setInterval } from 'node:timers/promises';
@@ -366,7 +364,7 @@ function getEnvVar(name) {
366
364
  __name(getEnvVar, "getEnvVar");
367
365
 
368
366
  // package.json
369
- var version = "3.0.0-beta.39";
367
+ var version = "3.0.0-beta.40";
370
368
 
371
369
  // src/v3/otel/tracingSDK.ts
372
370
  var _a;
@@ -459,12 +457,16 @@ var _TracingSDK = class _TracingSDK {
459
457
  this.getTracer = traceProvider.getTracer.bind(traceProvider);
460
458
  }
461
459
  async flush() {
462
- await this._traceProvider.forceFlush();
463
- await this._logProvider.forceFlush();
460
+ await Promise.all([
461
+ this._traceProvider.forceFlush(),
462
+ this._logProvider.forceFlush()
463
+ ]);
464
464
  }
465
465
  async shutdown() {
466
- await this._traceProvider.shutdown();
467
- await this._logProvider.shutdown();
466
+ await Promise.all([
467
+ this._traceProvider.shutdown(),
468
+ this._logProvider.shutdown()
469
+ ]);
468
470
  }
469
471
  };
470
472
  __name(_TracingSDK, "TracingSDK");
@@ -1613,37 +1615,6 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
1613
1615
  return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
1614
1616
  }
1615
1617
  __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");
1647
1618
  async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
1648
1619
  try {
1649
1620
  const $requestInit = await requestInit;
@@ -1769,95 +1740,6 @@ function requestInitWithCache(requestInit) {
1769
1740
  }
1770
1741
  }
1771
1742
  __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");
1861
1743
  var _ApiPromise = class _ApiPromise extends Promise {
1862
1744
  constructor(responsePromise) {
1863
1745
  super((resolve) => {
@@ -2153,18 +2035,11 @@ var _ApiClient = class _ApiClient {
2153
2035
  });
2154
2036
  }
2155
2037
  importEnvVars(projectRef, slug, body) {
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
- }
2038
+ return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
2039
+ method: "POST",
2040
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
2041
+ body: JSON.stringify(body)
2042
+ });
2168
2043
  }
2169
2044
  retrieveEnvVar(projectRef, slug, key) {
2170
2045
  return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {