@supabase/functions-js 2.71.2-canary.2 → 2.71.2-canary.28

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.
Files changed (41) hide show
  1. package/dist/main/FunctionsClient.d.ts +24 -0
  2. package/dist/main/FunctionsClient.d.ts.map +1 -0
  3. package/dist/main/FunctionsClient.js +127 -0
  4. package/dist/main/FunctionsClient.js.map +1 -0
  5. package/dist/main/helper.d.ts +3 -0
  6. package/dist/main/helper.d.ts.map +1 -0
  7. package/dist/main/helper.js +51 -0
  8. package/dist/main/helper.js.map +1 -0
  9. package/dist/main/index.d.ts +3 -0
  10. package/dist/main/index.d.ts.map +1 -0
  11. package/dist/main/index.js +12 -0
  12. package/dist/main/index.js.map +1 -0
  13. package/dist/main/types.d.ts +66 -0
  14. package/dist/main/types.d.ts.map +1 -0
  15. package/dist/main/types.js +49 -0
  16. package/dist/main/types.js.map +1 -0
  17. package/dist/main/version.d.ts +2 -0
  18. package/dist/main/version.d.ts.map +1 -0
  19. package/dist/main/version.js +5 -0
  20. package/dist/main/version.js.map +1 -0
  21. package/dist/module/FunctionsClient.d.ts +24 -0
  22. package/dist/module/FunctionsClient.d.ts.map +1 -0
  23. package/dist/module/FunctionsClient.js +123 -0
  24. package/dist/module/FunctionsClient.js.map +1 -0
  25. package/dist/module/helper.d.ts +3 -0
  26. package/dist/module/helper.d.ts.map +1 -0
  27. package/dist/module/helper.js +14 -0
  28. package/dist/module/helper.js.map +1 -0
  29. package/dist/module/index.d.ts +3 -0
  30. package/dist/module/index.d.ts.map +1 -0
  31. package/dist/module/index.js +3 -0
  32. package/dist/module/index.js.map +1 -0
  33. package/dist/module/types.d.ts +66 -0
  34. package/dist/module/types.d.ts.map +1 -0
  35. package/dist/module/types.js +42 -0
  36. package/dist/module/types.js.map +1 -0
  37. package/dist/module/version.d.ts +2 -0
  38. package/dist/module/version.d.ts.map +1 -0
  39. package/dist/module/version.js +2 -0
  40. package/dist/module/version.js.map +1 -0
  41. package/package.json +1 -1
@@ -0,0 +1,24 @@
1
+ import { Fetch, FunctionsResponse, FunctionInvokeOptions, FunctionRegion } from './types';
2
+ export declare class FunctionsClient {
3
+ protected url: string;
4
+ protected headers: Record<string, string>;
5
+ protected region: FunctionRegion;
6
+ protected fetch: Fetch;
7
+ constructor(url: string, { headers, customFetch, region, }?: {
8
+ headers?: Record<string, string>;
9
+ customFetch?: Fetch;
10
+ region?: FunctionRegion;
11
+ });
12
+ /**
13
+ * Updates the authorization header
14
+ * @param token - the new jwt token sent in the authorisation header
15
+ */
16
+ setAuth(token: string): void;
17
+ /**
18
+ * Invokes a function
19
+ * @param functionName - The name of the Function to invoke.
20
+ * @param options - Options for invoking the Function.
21
+ */
22
+ invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<FunctionsResponse<T>>;
23
+ }
24
+ //# sourceMappingURL=FunctionsClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionsClient.d.ts","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EAIL,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB,qBAAa,eAAe;IAC1B,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAA;IAChC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAA;gBAGpB,GAAG,EAAE,MAAM,EACX,EACE,OAAY,EACZ,WAAW,EACX,MAA2B,GAC5B,GAAE;QACD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChC,WAAW,CAAC,EAAE,KAAK,CAAA;QACnB,MAAM,CAAC,EAAE,cAAc,CAAA;KACnB;IAQR;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM;IAIrB;;;;OAIG;IACG,MAAM,CAAC,CAAC,GAAG,GAAG,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;CA0FjC"}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FunctionsClient = void 0;
13
+ const helper_1 = require("./helper");
14
+ const types_1 = require("./types");
15
+ class FunctionsClient {
16
+ constructor(url, { headers = {}, customFetch, region = types_1.FunctionRegion.Any, } = {}) {
17
+ this.url = url;
18
+ this.headers = headers;
19
+ this.region = region;
20
+ this.fetch = (0, helper_1.resolveFetch)(customFetch);
21
+ }
22
+ /**
23
+ * Updates the authorization header
24
+ * @param token - the new jwt token sent in the authorisation header
25
+ */
26
+ setAuth(token) {
27
+ this.headers.Authorization = `Bearer ${token}`;
28
+ }
29
+ /**
30
+ * Invokes a function
31
+ * @param functionName - The name of the Function to invoke.
32
+ * @param options - Options for invoking the Function.
33
+ */
34
+ invoke(functionName_1) {
35
+ return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
36
+ var _a;
37
+ try {
38
+ const { headers, method, body: functionArgs } = options;
39
+ let _headers = {};
40
+ let { region } = options;
41
+ if (!region) {
42
+ region = this.region;
43
+ }
44
+ // Add region as query parameter using URL API
45
+ const url = new URL(`${this.url}/${functionName}`);
46
+ if (region && region !== 'any') {
47
+ _headers['x-region'] = region;
48
+ url.searchParams.set('forceFunctionRegion', region);
49
+ }
50
+ let body;
51
+ if (functionArgs &&
52
+ ((headers && !Object.prototype.hasOwnProperty.call(headers, 'Content-Type')) || !headers)) {
53
+ if ((typeof Blob !== 'undefined' && functionArgs instanceof Blob) ||
54
+ functionArgs instanceof ArrayBuffer) {
55
+ // will work for File as File inherits Blob
56
+ // also works for ArrayBuffer as it is the same underlying structure as a Blob
57
+ _headers['Content-Type'] = 'application/octet-stream';
58
+ body = functionArgs;
59
+ }
60
+ else if (typeof functionArgs === 'string') {
61
+ // plain string
62
+ _headers['Content-Type'] = 'text/plain';
63
+ body = functionArgs;
64
+ }
65
+ else if (typeof FormData !== 'undefined' && functionArgs instanceof FormData) {
66
+ // don't set content-type headers
67
+ // Request will automatically add the right boundary value
68
+ body = functionArgs;
69
+ }
70
+ else {
71
+ // default, assume this is JSON
72
+ _headers['Content-Type'] = 'application/json';
73
+ body = JSON.stringify(functionArgs);
74
+ }
75
+ }
76
+ const response = yield this.fetch(url.toString(), {
77
+ method: method || 'POST',
78
+ // headers priority is (high to low):
79
+ // 1. invoke-level headers
80
+ // 2. client-level headers
81
+ // 3. default Content-Type header
82
+ headers: Object.assign(Object.assign(Object.assign({}, _headers), this.headers), headers),
83
+ body,
84
+ }).catch((fetchError) => {
85
+ throw new types_1.FunctionsFetchError(fetchError);
86
+ });
87
+ const isRelayError = response.headers.get('x-relay-error');
88
+ if (isRelayError && isRelayError === 'true') {
89
+ throw new types_1.FunctionsRelayError(response);
90
+ }
91
+ if (!response.ok) {
92
+ throw new types_1.FunctionsHttpError(response);
93
+ }
94
+ let responseType = ((_a = response.headers.get('Content-Type')) !== null && _a !== void 0 ? _a : 'text/plain').split(';')[0].trim();
95
+ let data;
96
+ if (responseType === 'application/json') {
97
+ data = yield response.json();
98
+ }
99
+ else if (responseType === 'application/octet-stream') {
100
+ data = yield response.blob();
101
+ }
102
+ else if (responseType === 'text/event-stream') {
103
+ data = response;
104
+ }
105
+ else if (responseType === 'multipart/form-data') {
106
+ data = yield response.formData();
107
+ }
108
+ else {
109
+ // default to text
110
+ data = yield response.text();
111
+ }
112
+ return { data, error: null, response };
113
+ }
114
+ catch (error) {
115
+ return {
116
+ data: null,
117
+ error,
118
+ response: error instanceof types_1.FunctionsHttpError || error instanceof types_1.FunctionsRelayError
119
+ ? error.context
120
+ : undefined,
121
+ };
122
+ }
123
+ });
124
+ }
125
+ }
126
+ exports.FunctionsClient = FunctionsClient;
127
+ //# sourceMappingURL=FunctionsClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionsClient.js","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAuC;AACvC,mCAQgB;AAEhB,MAAa,eAAe;IAM1B,YACE,GAAW,EACX,EACE,OAAO,GAAG,EAAE,EACZ,WAAW,EACX,MAAM,GAAG,sBAAc,CAAC,GAAG,MAKzB,EAAE;QAEN,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,IAAA,qBAAY,EAAC,WAAW,CAAC,CAAA;IACxC,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,KAAa;QACnB,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACG,MAAM;6DACV,YAAoB,EACpB,UAAiC,EAAE;;YAEnC,IAAI,CAAC;gBACH,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;gBACvD,IAAI,QAAQ,GAA2B,EAAE,CAAA;gBACzC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;gBACxB,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,G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E,CAAC;oBAChD,IAAI,GAAG,QAAQ,CAAA;gBACjB,CAAC;qBAAM,IAAI,YAAY,KAAK,qBAAqB,EAAE,CAAC;oBAClD,IAAI,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAA;gBAClC,CAAC;qBAAM,CAAC;oBACN,kBAAkB;oBAClB,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;gBAC9B,CAAC;gBAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;YACxC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,IAAI,EAAE,IAAI;oBACV,KAAK;oBACL,QAAQ,EACN,KAAK,YAAY,0BAAkB,IAAI,KAAK,YAAY,2BAAmB;wBACzE,CAAC,CAAC,KAAK,CAAC,OAAO;wBACf,CAAC,CAAC,SAAS;iBAChB,CAAA;YACH,CAAC;QACH,CAAC;KAAA;CACF;AAlID,0CAkIC"}
@@ -0,0 +1,3 @@
1
+ import { Fetch } from './types';
2
+ export declare const resolveFetch: (customFetch?: Fetch) => Fetch;
3
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,eAAO,MAAM,YAAY,GAAI,cAAc,KAAK,KAAG,KAWlD,CAAA"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.resolveFetch = void 0;
37
+ const resolveFetch = (customFetch) => {
38
+ let _fetch;
39
+ if (customFetch) {
40
+ _fetch = customFetch;
41
+ }
42
+ else if (typeof fetch === 'undefined') {
43
+ _fetch = (...args) => Promise.resolve(`${'@supabase/node-fetch'}`).then(s => __importStar(require(s))).then(({ default: fetch }) => fetch(...args));
44
+ }
45
+ else {
46
+ _fetch = fetch;
47
+ }
48
+ return (...args) => _fetch(...args);
49
+ };
50
+ exports.resolveFetch = resolveFetch;
51
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAS,EAAE;IACzD,IAAI,MAAa,CAAA;IACjB,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,GAAG,WAAW,CAAA;IACtB,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE,CAAC;QACxC,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CACnB,mBAAO,sBAA6B,wCAAE,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACtF,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,KAAK,CAAA;IAChB,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;AACrC,CAAC,CAAA;AAXY,QAAA,YAAY,gBAWxB"}
@@ -0,0 +1,3 @@
1
+ export { FunctionsClient } from './FunctionsClient';
2
+ export { type FunctionInvokeOptions, FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError, FunctionRegion, type FunctionsResponse, } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EACL,KAAK,qBAAqB,EAC1B,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,KAAK,iBAAiB,GACvB,MAAM,SAAS,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FunctionRegion = exports.FunctionsRelayError = exports.FunctionsHttpError = exports.FunctionsFetchError = exports.FunctionsError = exports.FunctionsClient = void 0;
4
+ var FunctionsClient_1 = require("./FunctionsClient");
5
+ Object.defineProperty(exports, "FunctionsClient", { enumerable: true, get: function () { return FunctionsClient_1.FunctionsClient; } });
6
+ var types_1 = require("./types");
7
+ Object.defineProperty(exports, "FunctionsError", { enumerable: true, get: function () { return types_1.FunctionsError; } });
8
+ Object.defineProperty(exports, "FunctionsFetchError", { enumerable: true, get: function () { return types_1.FunctionsFetchError; } });
9
+ Object.defineProperty(exports, "FunctionsHttpError", { enumerable: true, get: function () { return types_1.FunctionsHttpError; } });
10
+ Object.defineProperty(exports, "FunctionsRelayError", { enumerable: true, get: function () { return types_1.FunctionsRelayError; } });
11
+ Object.defineProperty(exports, "FunctionRegion", { enumerable: true, get: function () { return types_1.FunctionRegion; } });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,kHAAA,eAAe,OAAA;AACxB,iCAQgB;AANd,uGAAA,cAAc,OAAA;AACd,4GAAA,mBAAmB,OAAA;AACnB,2GAAA,kBAAkB,OAAA;AAClB,4GAAA,mBAAmB,OAAA;AACnB,uGAAA,cAAc,OAAA"}
@@ -0,0 +1,66 @@
1
+ export type Fetch = typeof fetch;
2
+ /**
3
+ * Response format
4
+ */
5
+ export interface FunctionsResponseSuccess<T> {
6
+ data: T;
7
+ error: null;
8
+ response?: Response;
9
+ }
10
+ export interface FunctionsResponseFailure {
11
+ data: null;
12
+ error: any;
13
+ response?: Response;
14
+ }
15
+ export type FunctionsResponse<T> = FunctionsResponseSuccess<T> | FunctionsResponseFailure;
16
+ export declare class FunctionsError extends Error {
17
+ context: any;
18
+ constructor(message: string, name?: string, context?: any);
19
+ }
20
+ export declare class FunctionsFetchError extends FunctionsError {
21
+ constructor(context: any);
22
+ }
23
+ export declare class FunctionsRelayError extends FunctionsError {
24
+ constructor(context: any);
25
+ }
26
+ export declare class FunctionsHttpError extends FunctionsError {
27
+ constructor(context: any);
28
+ }
29
+ export declare enum FunctionRegion {
30
+ Any = "any",
31
+ ApNortheast1 = "ap-northeast-1",
32
+ ApNortheast2 = "ap-northeast-2",
33
+ ApSouth1 = "ap-south-1",
34
+ ApSoutheast1 = "ap-southeast-1",
35
+ ApSoutheast2 = "ap-southeast-2",
36
+ CaCentral1 = "ca-central-1",
37
+ EuCentral1 = "eu-central-1",
38
+ EuWest1 = "eu-west-1",
39
+ EuWest2 = "eu-west-2",
40
+ EuWest3 = "eu-west-3",
41
+ SaEast1 = "sa-east-1",
42
+ UsEast1 = "us-east-1",
43
+ UsWest1 = "us-west-1",
44
+ UsWest2 = "us-west-2"
45
+ }
46
+ export type FunctionInvokeOptions = {
47
+ /**
48
+ * Object representing the headers to send with the request.
49
+ */
50
+ headers?: {
51
+ [key: string]: string;
52
+ };
53
+ /**
54
+ * The HTTP verb of the request
55
+ */
56
+ method?: 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE';
57
+ /**
58
+ * The Region to invoke the function in.
59
+ */
60
+ region?: FunctionRegion;
61
+ /**
62
+ * The body of the request.
63
+ */
64
+ body?: File | Blob | ArrayBuffer | FormData | ReadableStream<Uint8Array> | Record<string, any> | string;
65
+ };
66
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAA;AAEhC;;GAEG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,IAAI,CAAA;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB;AACD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,GAAG,CAAA;IACV,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB;AACD,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,wBAAwB,CAAC,CAAC,CAAC,GAAG,wBAAwB,CAAA;AAEzF,qBAAa,cAAe,SAAQ,KAAK;IACvC,OAAO,EAAE,GAAG,CAAA;gBACA,OAAO,EAAE,MAAM,EAAE,IAAI,SAAmB,EAAE,OAAO,CAAC,EAAE,GAAG;CAKpE;AAED,qBAAa,mBAAoB,SAAQ,cAAc;gBACzC,OAAO,EAAE,GAAG;CAGzB;AAED,qBAAa,mBAAoB,SAAQ,cAAc;gBACzC,OAAO,EAAE,GAAG;CAGzB;AAED,qBAAa,kBAAmB,SAAQ,cAAc;gBACxC,OAAO,EAAE,GAAG;CAGzB;AAED,oBAAY,cAAc;IACxB,GAAG,QAAQ;IACX,YAAY,mBAAmB;IAC/B,YAAY,mBAAmB;IAC/B,QAAQ,eAAe;IACvB,YAAY,mBAAmB;IAC/B,YAAY,mBAAmB;IAC/B,UAAU,iBAAiB;IAC3B,UAAU,iBAAiB;IAC3B,OAAO,cAAc;IACrB,OAAO,cAAc;IACrB,OAAO,cAAc;IACrB,OAAO,cAAc;IACrB,OAAO,cAAc;IACrB,OAAO,cAAc;IACrB,OAAO,cAAc;CACtB;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACnC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;IACpD;;OAEG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,IAAI,CAAC,EACD,IAAI,GACJ,IAAI,GACJ,WAAW,GACX,QAAQ,GACR,cAAc,CAAC,UAAU,CAAC,GAC1B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnB,MAAM,CAAA;CACX,CAAA"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FunctionRegion = exports.FunctionsHttpError = exports.FunctionsRelayError = exports.FunctionsFetchError = exports.FunctionsError = void 0;
4
+ class FunctionsError extends Error {
5
+ constructor(message, name = 'FunctionsError', context) {
6
+ super(message);
7
+ this.name = name;
8
+ this.context = context;
9
+ }
10
+ }
11
+ exports.FunctionsError = FunctionsError;
12
+ class FunctionsFetchError extends FunctionsError {
13
+ constructor(context) {
14
+ super('Failed to send a request to the Edge Function', 'FunctionsFetchError', context);
15
+ }
16
+ }
17
+ exports.FunctionsFetchError = FunctionsFetchError;
18
+ class FunctionsRelayError extends FunctionsError {
19
+ constructor(context) {
20
+ super('Relay Error invoking the Edge Function', 'FunctionsRelayError', context);
21
+ }
22
+ }
23
+ exports.FunctionsRelayError = FunctionsRelayError;
24
+ class FunctionsHttpError extends FunctionsError {
25
+ constructor(context) {
26
+ super('Edge Function returned a non-2xx status code', 'FunctionsHttpError', context);
27
+ }
28
+ }
29
+ exports.FunctionsHttpError = FunctionsHttpError;
30
+ // Define the enum for the 'region' property
31
+ var FunctionRegion;
32
+ (function (FunctionRegion) {
33
+ FunctionRegion["Any"] = "any";
34
+ FunctionRegion["ApNortheast1"] = "ap-northeast-1";
35
+ FunctionRegion["ApNortheast2"] = "ap-northeast-2";
36
+ FunctionRegion["ApSouth1"] = "ap-south-1";
37
+ FunctionRegion["ApSoutheast1"] = "ap-southeast-1";
38
+ FunctionRegion["ApSoutheast2"] = "ap-southeast-2";
39
+ FunctionRegion["CaCentral1"] = "ca-central-1";
40
+ FunctionRegion["EuCentral1"] = "eu-central-1";
41
+ FunctionRegion["EuWest1"] = "eu-west-1";
42
+ FunctionRegion["EuWest2"] = "eu-west-2";
43
+ FunctionRegion["EuWest3"] = "eu-west-3";
44
+ FunctionRegion["SaEast1"] = "sa-east-1";
45
+ FunctionRegion["UsEast1"] = "us-east-1";
46
+ FunctionRegion["UsWest1"] = "us-west-1";
47
+ FunctionRegion["UsWest2"] = "us-west-2";
48
+ })(FunctionRegion || (exports.FunctionRegion = FunctionRegion = {}));
49
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAiBA,MAAa,cAAe,SAAQ,KAAK;IAEvC,YAAY,OAAe,EAAE,IAAI,GAAG,gBAAgB,EAAE,OAAa;QACjE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CACF;AAPD,wCAOC;AAED,MAAa,mBAAoB,SAAQ,cAAc;IACrD,YAAY,OAAY;QACtB,KAAK,CAAC,+CAA+C,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAA;IACxF,CAAC;CACF;AAJD,kDAIC;AAED,MAAa,mBAAoB,SAAQ,cAAc;IACrD,YAAY,OAAY;QACtB,KAAK,CAAC,wCAAwC,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAA;IACjF,CAAC;CACF;AAJD,kDAIC;AAED,MAAa,kBAAmB,SAAQ,cAAc;IACpD,YAAY,OAAY;QACtB,KAAK,CAAC,8CAA8C,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAA;IACtF,CAAC;CACF;AAJD,gDAIC;AACD,4CAA4C;AAC5C,IAAY,cAgBX;AAhBD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,iDAA+B,CAAA;IAC/B,iDAA+B,CAAA;IAC/B,yCAAuB,CAAA;IACvB,iDAA+B,CAAA;IAC/B,iDAA+B,CAAA;IAC/B,6CAA2B,CAAA;IAC3B,6CAA2B,CAAA;IAC3B,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;AACvB,CAAC,EAhBW,cAAc,8BAAd,cAAc,QAgBzB"}
@@ -0,0 +1,2 @@
1
+ export declare const version = "0.0.0-automated";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,oBAAoB,CAAA"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = void 0;
4
+ exports.version = '0.0.0-automated';
5
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,iBAAiB,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { Fetch, FunctionsResponse, FunctionInvokeOptions, FunctionRegion } from './types';
2
+ export declare class FunctionsClient {
3
+ protected url: string;
4
+ protected headers: Record<string, string>;
5
+ protected region: FunctionRegion;
6
+ protected fetch: Fetch;
7
+ constructor(url: string, { headers, customFetch, region, }?: {
8
+ headers?: Record<string, string>;
9
+ customFetch?: Fetch;
10
+ region?: FunctionRegion;
11
+ });
12
+ /**
13
+ * Updates the authorization header
14
+ * @param token - the new jwt token sent in the authorisation header
15
+ */
16
+ setAuth(token: string): void;
17
+ /**
18
+ * Invokes a function
19
+ * @param functionName - The name of the Function to invoke.
20
+ * @param options - Options for invoking the Function.
21
+ */
22
+ invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<FunctionsResponse<T>>;
23
+ }
24
+ //# sourceMappingURL=FunctionsClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionsClient.d.ts","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EAIL,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB,qBAAa,eAAe;IAC1B,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAA;IAChC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAA;gBAGpB,GAAG,EAAE,MAAM,EACX,EACE,OAAY,EACZ,WAAW,EACX,MAA2B,GAC5B,GAAE;QACD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChC,WAAW,CAAC,EAAE,KAAK,CAAA;QACnB,MAAM,CAAC,EAAE,cAAc,CAAA;KACnB;IAQR;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM;IAIrB;;;;OAIG;IACG,MAAM,CAAC,CAAC,GAAG,GAAG,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;CA0FjC"}
@@ -0,0 +1,123 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { resolveFetch } from './helper';
11
+ import { FunctionsFetchError, FunctionsHttpError, FunctionsRelayError, FunctionRegion, } from './types';
12
+ export class FunctionsClient {
13
+ constructor(url, { headers = {}, customFetch, region = FunctionRegion.Any, } = {}) {
14
+ this.url = url;
15
+ this.headers = headers;
16
+ this.region = region;
17
+ this.fetch = resolveFetch(customFetch);
18
+ }
19
+ /**
20
+ * Updates the authorization header
21
+ * @param token - the new jwt token sent in the authorisation header
22
+ */
23
+ setAuth(token) {
24
+ this.headers.Authorization = `Bearer ${token}`;
25
+ }
26
+ /**
27
+ * Invokes a function
28
+ * @param functionName - The name of the Function to invoke.
29
+ * @param options - Options for invoking the Function.
30
+ */
31
+ invoke(functionName_1) {
32
+ return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
33
+ var _a;
34
+ try {
35
+ const { headers, method, body: functionArgs } = options;
36
+ let _headers = {};
37
+ let { region } = options;
38
+ if (!region) {
39
+ region = this.region;
40
+ }
41
+ // Add region as query parameter using URL API
42
+ const url = new URL(`${this.url}/${functionName}`);
43
+ if (region && region !== 'any') {
44
+ _headers['x-region'] = region;
45
+ url.searchParams.set('forceFunctionRegion', region);
46
+ }
47
+ let body;
48
+ if (functionArgs &&
49
+ ((headers && !Object.prototype.hasOwnProperty.call(headers, 'Content-Type')) || !headers)) {
50
+ if ((typeof Blob !== 'undefined' && functionArgs instanceof Blob) ||
51
+ functionArgs instanceof ArrayBuffer) {
52
+ // will work for File as File inherits Blob
53
+ // also works for ArrayBuffer as it is the same underlying structure as a Blob
54
+ _headers['Content-Type'] = 'application/octet-stream';
55
+ body = functionArgs;
56
+ }
57
+ else if (typeof functionArgs === 'string') {
58
+ // plain string
59
+ _headers['Content-Type'] = 'text/plain';
60
+ body = functionArgs;
61
+ }
62
+ else if (typeof FormData !== 'undefined' && functionArgs instanceof FormData) {
63
+ // don't set content-type headers
64
+ // Request will automatically add the right boundary value
65
+ body = functionArgs;
66
+ }
67
+ else {
68
+ // default, assume this is JSON
69
+ _headers['Content-Type'] = 'application/json';
70
+ body = JSON.stringify(functionArgs);
71
+ }
72
+ }
73
+ const response = yield this.fetch(url.toString(), {
74
+ method: method || 'POST',
75
+ // headers priority is (high to low):
76
+ // 1. invoke-level headers
77
+ // 2. client-level headers
78
+ // 3. default Content-Type header
79
+ headers: Object.assign(Object.assign(Object.assign({}, _headers), this.headers), headers),
80
+ body,
81
+ }).catch((fetchError) => {
82
+ throw new FunctionsFetchError(fetchError);
83
+ });
84
+ const isRelayError = response.headers.get('x-relay-error');
85
+ if (isRelayError && isRelayError === 'true') {
86
+ throw new FunctionsRelayError(response);
87
+ }
88
+ if (!response.ok) {
89
+ throw new FunctionsHttpError(response);
90
+ }
91
+ let responseType = ((_a = response.headers.get('Content-Type')) !== null && _a !== void 0 ? _a : 'text/plain').split(';')[0].trim();
92
+ let data;
93
+ if (responseType === 'application/json') {
94
+ data = yield response.json();
95
+ }
96
+ else if (responseType === 'application/octet-stream') {
97
+ data = yield response.blob();
98
+ }
99
+ else if (responseType === 'text/event-stream') {
100
+ data = response;
101
+ }
102
+ else if (responseType === 'multipart/form-data') {
103
+ data = yield response.formData();
104
+ }
105
+ else {
106
+ // default to text
107
+ data = yield response.text();
108
+ }
109
+ return { data, error: null, response };
110
+ }
111
+ catch (error) {
112
+ return {
113
+ data: null,
114
+ error,
115
+ response: error instanceof FunctionsHttpError || error instanceof FunctionsRelayError
116
+ ? error.context
117
+ : undefined,
118
+ };
119
+ }
120
+ });
121
+ }
122
+ }
123
+ //# sourceMappingURL=FunctionsClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionsClient.js","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAEL,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EAGnB,cAAc,GACf,MAAM,SAAS,CAAA;AAEhB,MAAM,OAAO,eAAe;IAM1B,YACE,GAAW,EACX,EACE,OAAO,GAAG,EAAE,EACZ,WAAW,EACX,MAAM,GAAG,cAAc,CAAC,GAAG,MAKzB,EAAE;QAEN,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,WAAW,CAAC,CAAA;IACxC,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,KAAa;QACnB,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACG,MAAM;6DACV,YAAoB,EACpB,UAAiC,EAAE;;YAEnC,IAAI,CAAC;gBACH,MAAM,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,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;gBAC9B,CAAC;qBAAM,IAAI,YAAY,KAAK,0BAA0B,EAAE,CAAC;oBACvD,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;gBAC9B,CAAC;qBAAM,IAAI,YAAY,KAAK,mBAAmB,EAAE,CAAC;oBAChD,IAAI,GAAG,QAAQ,CAAA;gBACjB,CAAC;qBAAM,IAAI,YAAY,KAAK,qBAAqB,EAAE,CAAC;oBAClD,IAAI,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAA;gBAClC,CAAC;qBAAM,CAAC;oBACN,kBAAkB;oBAClB,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;gBAC9B,CAAC;gBAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;YACxC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,IAAI,EAAE,IAAI;oBACV,KAAK;oBACL,QAAQ,EACN,KAAK,YAAY,kBAAkB,IAAI,KAAK,YAAY,mBAAmB;wBACzE,CAAC,CAAC,KAAK,CAAC,OAAO;wBACf,CAAC,CAAC,SAAS;iBAChB,CAAA;YACH,CAAC;QACH,CAAC;KAAA;CACF"}
@@ -0,0 +1,3 @@
1
+ import { Fetch } from './types';
2
+ export declare const resolveFetch: (customFetch?: Fetch) => Fetch;
3
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,eAAO,MAAM,YAAY,GAAI,cAAc,KAAK,KAAG,KAWlD,CAAA"}
@@ -0,0 +1,14 @@
1
+ export const resolveFetch = (customFetch) => {
2
+ let _fetch;
3
+ if (customFetch) {
4
+ _fetch = customFetch;
5
+ }
6
+ else if (typeof fetch === 'undefined') {
7
+ _fetch = (...args) => import('@supabase/node-fetch').then(({ default: fetch }) => fetch(...args));
8
+ }
9
+ else {
10
+ _fetch = fetch;
11
+ }
12
+ return (...args) => _fetch(...args);
13
+ };
14
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/helper.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAS,EAAE;IACzD,IAAI,MAAa,CAAA;IACjB,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,GAAG,WAAW,CAAA;IACtB,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE,CAAC;QACxC,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CACnB,MAAM,CAAC,sBAA6B,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACtF,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,KAAK,CAAA;IAChB,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;AACrC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { FunctionsClient } from './FunctionsClient';
2
+ export { type FunctionInvokeOptions, FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError, FunctionRegion, type FunctionsResponse, } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EACL,KAAK,qBAAqB,EAC1B,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,KAAK,iBAAiB,GACvB,MAAM,SAAS,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { FunctionsClient } from './FunctionsClient';
2
+ export { FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError, FunctionRegion, } from './types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAEL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GAEf,MAAM,SAAS,CAAA"}
@@ -0,0 +1,66 @@
1
+ export type Fetch = typeof fetch;
2
+ /**
3
+ * Response format
4
+ */
5
+ export interface FunctionsResponseSuccess<T> {
6
+ data: T;
7
+ error: null;
8
+ response?: Response;
9
+ }
10
+ export interface FunctionsResponseFailure {
11
+ data: null;
12
+ error: any;
13
+ response?: Response;
14
+ }
15
+ export type FunctionsResponse<T> = FunctionsResponseSuccess<T> | FunctionsResponseFailure;
16
+ export declare class FunctionsError extends Error {
17
+ context: any;
18
+ constructor(message: string, name?: string, context?: any);
19
+ }
20
+ export declare class FunctionsFetchError extends FunctionsError {
21
+ constructor(context: any);
22
+ }
23
+ export declare class FunctionsRelayError extends FunctionsError {
24
+ constructor(context: any);
25
+ }
26
+ export declare class FunctionsHttpError extends FunctionsError {
27
+ constructor(context: any);
28
+ }
29
+ export declare enum FunctionRegion {
30
+ Any = "any",
31
+ ApNortheast1 = "ap-northeast-1",
32
+ ApNortheast2 = "ap-northeast-2",
33
+ ApSouth1 = "ap-south-1",
34
+ ApSoutheast1 = "ap-southeast-1",
35
+ ApSoutheast2 = "ap-southeast-2",
36
+ CaCentral1 = "ca-central-1",
37
+ EuCentral1 = "eu-central-1",
38
+ EuWest1 = "eu-west-1",
39
+ EuWest2 = "eu-west-2",
40
+ EuWest3 = "eu-west-3",
41
+ SaEast1 = "sa-east-1",
42
+ UsEast1 = "us-east-1",
43
+ UsWest1 = "us-west-1",
44
+ UsWest2 = "us-west-2"
45
+ }
46
+ export type FunctionInvokeOptions = {
47
+ /**
48
+ * Object representing the headers to send with the request.
49
+ */
50
+ headers?: {
51
+ [key: string]: string;
52
+ };
53
+ /**
54
+ * The HTTP verb of the request
55
+ */
56
+ method?: 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE';
57
+ /**
58
+ * The Region to invoke the function in.
59
+ */
60
+ region?: FunctionRegion;
61
+ /**
62
+ * The body of the request.
63
+ */
64
+ body?: File | Blob | ArrayBuffer | FormData | ReadableStream<Uint8Array> | Record<string, any> | string;
65
+ };
66
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAA;AAEhC;;GAEG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,IAAI,CAAA;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB;AACD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,GAAG,CAAA;IACV,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB;AACD,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,wBAAwB,CAAC,CAAC,CAAC,GAAG,wBAAwB,CAAA;AAEzF,qBAAa,cAAe,SAAQ,KAAK;IACvC,OAAO,EAAE,GAAG,CAAA;gBACA,OAAO,EAAE,MAAM,EAAE,IAAI,SAAmB,EAAE,OAAO,CAAC,EAAE,GAAG;CAKpE;AAED,qBAAa,mBAAoB,SAAQ,cAAc;gBACzC,OAAO,EAAE,GAAG;CAGzB;AAED,qBAAa,mBAAoB,SAAQ,cAAc;gBACzC,OAAO,EAAE,GAAG;CAGzB;AAED,qBAAa,kBAAmB,SAAQ,cAAc;gBACxC,OAAO,EAAE,GAAG;CAGzB;AAED,oBAAY,cAAc;IACxB,GAAG,QAAQ;IACX,YAAY,mBAAmB;IAC/B,YAAY,mBAAmB;IAC/B,QAAQ,eAAe;IACvB,YAAY,mBAAmB;IAC/B,YAAY,mBAAmB;IAC/B,UAAU,iBAAiB;IAC3B,UAAU,iBAAiB;IAC3B,OAAO,cAAc;IACrB,OAAO,cAAc;IACrB,OAAO,cAAc;IACrB,OAAO,cAAc;IACrB,OAAO,cAAc;IACrB,OAAO,cAAc;IACrB,OAAO,cAAc;CACtB;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACnC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;IACpD;;OAEG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,IAAI,CAAC,EACD,IAAI,GACJ,IAAI,GACJ,WAAW,GACX,QAAQ,GACR,cAAc,CAAC,UAAU,CAAC,GAC1B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnB,MAAM,CAAA;CACX,CAAA"}
@@ -0,0 +1,42 @@
1
+ export class FunctionsError extends Error {
2
+ constructor(message, name = 'FunctionsError', context) {
3
+ super(message);
4
+ this.name = name;
5
+ this.context = context;
6
+ }
7
+ }
8
+ export class FunctionsFetchError extends FunctionsError {
9
+ constructor(context) {
10
+ super('Failed to send a request to the Edge Function', 'FunctionsFetchError', context);
11
+ }
12
+ }
13
+ export class FunctionsRelayError extends FunctionsError {
14
+ constructor(context) {
15
+ super('Relay Error invoking the Edge Function', 'FunctionsRelayError', context);
16
+ }
17
+ }
18
+ export class FunctionsHttpError extends FunctionsError {
19
+ constructor(context) {
20
+ super('Edge Function returned a non-2xx status code', 'FunctionsHttpError', context);
21
+ }
22
+ }
23
+ // Define the enum for the 'region' property
24
+ export var FunctionRegion;
25
+ (function (FunctionRegion) {
26
+ FunctionRegion["Any"] = "any";
27
+ FunctionRegion["ApNortheast1"] = "ap-northeast-1";
28
+ FunctionRegion["ApNortheast2"] = "ap-northeast-2";
29
+ FunctionRegion["ApSouth1"] = "ap-south-1";
30
+ FunctionRegion["ApSoutheast1"] = "ap-southeast-1";
31
+ FunctionRegion["ApSoutheast2"] = "ap-southeast-2";
32
+ FunctionRegion["CaCentral1"] = "ca-central-1";
33
+ FunctionRegion["EuCentral1"] = "eu-central-1";
34
+ FunctionRegion["EuWest1"] = "eu-west-1";
35
+ FunctionRegion["EuWest2"] = "eu-west-2";
36
+ FunctionRegion["EuWest3"] = "eu-west-3";
37
+ FunctionRegion["SaEast1"] = "sa-east-1";
38
+ FunctionRegion["UsEast1"] = "us-east-1";
39
+ FunctionRegion["UsWest1"] = "us-west-1";
40
+ FunctionRegion["UsWest2"] = "us-west-2";
41
+ })(FunctionRegion || (FunctionRegion = {}));
42
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAiBA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAEvC,YAAY,OAAe,EAAE,IAAI,GAAG,gBAAgB,EAAE,OAAa;QACjE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IACrD,YAAY,OAAY;QACtB,KAAK,CAAC,+CAA+C,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAA;IACxF,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IACrD,YAAY,OAAY;QACtB,KAAK,CAAC,wCAAwC,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAA;IACjF,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IACpD,YAAY,OAAY;QACtB,KAAK,CAAC,8CAA8C,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAA;IACtF,CAAC;CACF;AACD,4CAA4C;AAC5C,MAAM,CAAN,IAAY,cAgBX;AAhBD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,iDAA+B,CAAA;IAC/B,iDAA+B,CAAA;IAC/B,yCAAuB,CAAA;IACvB,iDAA+B,CAAA;IAC/B,iDAA+B,CAAA;IAC/B,6CAA2B,CAAA;IAC3B,6CAA2B,CAAA;IAC3B,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;AACvB,CAAC,EAhBW,cAAc,KAAd,cAAc,QAgBzB"}
@@ -0,0 +1,2 @@
1
+ export declare const version = "0.0.0-automated";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,oBAAoB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export const version = '0.0.0-automated';
2
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/functions-js",
3
- "version": "2.71.2-canary.2",
3
+ "version": "2.71.2-canary.28",
4
4
  "description": "JS Client library to interact with Supabase Functions.",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",