@aurabase/functions 0.7.1 → 0.7.3

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.cjs CHANGED
@@ -36,7 +36,8 @@ function unserializableBodyKind(body) {
36
36
  const g = globalThis;
37
37
  for (const name of ["Blob", "FormData", "URLSearchParams", "ReadableStream"]) {
38
38
  const ctor = g[name];
39
- if (typeof ctor === "function" && body instanceof ctor) return name;
39
+ if (typeof ctor === "function" && body instanceof ctor)
40
+ return name;
40
41
  }
41
42
  if (body instanceof ArrayBuffer) return "ArrayBuffer";
42
43
  if (ArrayBuffer.isView(body)) return body.constructor.name;
@@ -141,9 +142,14 @@ var FunctionsService = class extends core.BaseService {
141
142
  try {
142
143
  if (responseType === "json") {
143
144
  const hasCanceller = options?.timeout !== void 0 || userSignal !== void 0;
144
- const res2 = await this.request("POST", `${this.prefix}/${seg(slug)}/invoke`, envelope, {
145
- ...hasCanceller ? { signal: controller.signal } : {}
146
- });
145
+ const res2 = await this.request(
146
+ "POST",
147
+ `${this.prefix}/${seg(slug)}/invoke`,
148
+ envelope,
149
+ {
150
+ ...hasCanceller ? { signal: controller.signal } : {}
151
+ }
152
+ );
147
153
  if (res2.error && controller.signal.aborted) return timeoutError();
148
154
  if (res2.error) return { data: null, error: toFunctionsError(res2.error) };
149
155
  const rawData = res2.data;
@@ -151,7 +157,9 @@ var FunctionsService = class extends core.BaseService {
151
157
  const invokeStatus = rawData.status;
152
158
  const invokeBody = rawData.body;
153
159
  if (typeof invokeStatus === "number" && invokeStatus >= 400) {
154
- const errPayload = typeof invokeBody === "object" && invokeBody !== null ? invokeBody : invokeBody === null || invokeBody === void 0 || invokeBody === "" ? {} : { message: typeof invokeBody === "string" ? invokeBody : JSON.stringify(invokeBody) };
160
+ const errPayload = typeof invokeBody === "object" && invokeBody !== null ? invokeBody : invokeBody === null || invokeBody === void 0 || invokeBody === "" ? {} : {
161
+ message: typeof invokeBody === "string" ? invokeBody : JSON.stringify(invokeBody)
162
+ };
155
163
  const errorMsg = typeof errPayload.message === "string" ? errPayload.message : typeof errPayload.error === "string" ? errPayload.error : typeof errPayload.error?.message === "string" ? String(errPayload.error.message) : `Function returned HTTP ${invokeStatus}`;
156
164
  const normalizedBody = {
157
165
  ...errPayload,
package/dist/index.js CHANGED
@@ -34,7 +34,8 @@ function unserializableBodyKind(body) {
34
34
  const g = globalThis;
35
35
  for (const name of ["Blob", "FormData", "URLSearchParams", "ReadableStream"]) {
36
36
  const ctor = g[name];
37
- if (typeof ctor === "function" && body instanceof ctor) return name;
37
+ if (typeof ctor === "function" && body instanceof ctor)
38
+ return name;
38
39
  }
39
40
  if (body instanceof ArrayBuffer) return "ArrayBuffer";
40
41
  if (ArrayBuffer.isView(body)) return body.constructor.name;
@@ -139,9 +140,14 @@ var FunctionsService = class extends BaseService {
139
140
  try {
140
141
  if (responseType === "json") {
141
142
  const hasCanceller = options?.timeout !== void 0 || userSignal !== void 0;
142
- const res2 = await this.request("POST", `${this.prefix}/${seg(slug)}/invoke`, envelope, {
143
- ...hasCanceller ? { signal: controller.signal } : {}
144
- });
143
+ const res2 = await this.request(
144
+ "POST",
145
+ `${this.prefix}/${seg(slug)}/invoke`,
146
+ envelope,
147
+ {
148
+ ...hasCanceller ? { signal: controller.signal } : {}
149
+ }
150
+ );
145
151
  if (res2.error && controller.signal.aborted) return timeoutError();
146
152
  if (res2.error) return { data: null, error: toFunctionsError(res2.error) };
147
153
  const rawData = res2.data;
@@ -149,7 +155,9 @@ var FunctionsService = class extends BaseService {
149
155
  const invokeStatus = rawData.status;
150
156
  const invokeBody = rawData.body;
151
157
  if (typeof invokeStatus === "number" && invokeStatus >= 400) {
152
- const errPayload = typeof invokeBody === "object" && invokeBody !== null ? invokeBody : invokeBody === null || invokeBody === void 0 || invokeBody === "" ? {} : { message: typeof invokeBody === "string" ? invokeBody : JSON.stringify(invokeBody) };
158
+ const errPayload = typeof invokeBody === "object" && invokeBody !== null ? invokeBody : invokeBody === null || invokeBody === void 0 || invokeBody === "" ? {} : {
159
+ message: typeof invokeBody === "string" ? invokeBody : JSON.stringify(invokeBody)
160
+ };
153
161
  const errorMsg = typeof errPayload.message === "string" ? errPayload.message : typeof errPayload.error === "string" ? errPayload.error : typeof errPayload.error?.message === "string" ? String(errPayload.error.message) : `Function returned HTTP ${invokeStatus}`;
154
162
  const normalizedBody = {
155
163
  ...errPayload,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurabase/functions",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Service edge functions du SDK Aurabase (invoke, jobs asynchrones, cron)",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -45,7 +45,7 @@
45
45
  "functions"
46
46
  ],
47
47
  "dependencies": {
48
- "@aurabase/core": "0.7.1"
48
+ "@aurabase/core": "0.7.3"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "20.14.15",