@supabase/functions-js 1.4.0-next.3 → 1.4.0-next.4
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/main/FunctionsClient.d.ts +4 -7
- package/dist/main/FunctionsClient.d.ts.map +1 -1
- package/dist/main/FunctionsClient.js +6 -5
- package/dist/main/FunctionsClient.js.map +1 -1
- package/dist/main/types.d.ts +9 -3
- package/dist/main/types.d.ts.map +1 -1
- package/dist/main/types.js +2 -2
- package/dist/main/types.js.map +1 -1
- package/dist/main/version.d.ts +1 -1
- package/dist/main/version.js +1 -1
- package/dist/module/FunctionsClient.d.ts +4 -7
- package/dist/module/FunctionsClient.d.ts.map +1 -1
- package/dist/module/FunctionsClient.js +6 -5
- package/dist/module/FunctionsClient.js.map +1 -1
- package/dist/module/types.d.ts +9 -3
- package/dist/module/types.d.ts.map +1 -1
- package/dist/module/types.js +2 -2
- package/dist/module/types.js.map +1 -1
- package/dist/module/version.d.ts +1 -1
- package/dist/module/version.js +1 -1
- package/package.json +1 -1
- package/src/FunctionsClient.ts +12 -12
- package/src/types.ts +17 -5
- package/src/version.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fetch, FunctionsResponse } from './types';
|
|
1
|
+
import { Fetch, FunctionsResponse, FunctionInvokeOptions } from './types';
|
|
2
2
|
export declare class FunctionsClient {
|
|
3
3
|
protected url: string;
|
|
4
4
|
protected headers: Record<string, string>;
|
|
@@ -15,12 +15,9 @@ export declare class FunctionsClient {
|
|
|
15
15
|
/**
|
|
16
16
|
* Invokes a function
|
|
17
17
|
* @param functionName - the name of the function to invoke
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
* @param options.headers - headers to send with the request
|
|
18
|
+
* @param invokeOption.headers - object representing the headers to send with the request
|
|
19
|
+
* @param invokeOptions.body - the body of the request
|
|
21
20
|
*/
|
|
22
|
-
invoke(functionName: string,
|
|
23
|
-
headers?: Record<string, string>;
|
|
24
|
-
}): Promise<FunctionsResponse>;
|
|
21
|
+
invoke<T = any>(functionName: string, invokeOptions?: FunctionInvokeOptions): Promise<FunctionsResponse<T>>;
|
|
25
22
|
}
|
|
26
23
|
//# sourceMappingURL=FunctionsClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionsClient.d.ts","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EAIL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"FunctionsClient.d.ts","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EAIL,iBAAiB,EACjB,qBAAqB,EACtB,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,KAAK,EAAE,KAAK,CAAA;gBAGpB,GAAG,EAAE,MAAM,EACX,EACE,OAAY,EACZ,WAAW,GACZ,GAAE;QACD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChC,WAAW,CAAC,EAAE,KAAK,CAAA;KACf;IAOR;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM;IAIrB;;;;;OAKG;IACG,MAAM,CAAC,CAAC,GAAG,GAAG,EAClB,YAAY,EAAE,MAAM,EACpB,aAAa,GAAE,qBAA0B,GACxC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAwEjC"}
|
|
@@ -28,17 +28,18 @@ class FunctionsClient {
|
|
|
28
28
|
/**
|
|
29
29
|
* Invokes a function
|
|
30
30
|
* @param functionName - the name of the function to invoke
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param options.headers - headers to send with the request
|
|
31
|
+
* @param invokeOption.headers - object representing the headers to send with the request
|
|
32
|
+
* @param invokeOptions.body - the body of the request
|
|
34
33
|
*/
|
|
35
|
-
invoke(functionName,
|
|
34
|
+
invoke(functionName, invokeOptions = {}) {
|
|
36
35
|
var _a;
|
|
37
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
37
|
try {
|
|
38
|
+
const { headers, body: functionArgs } = invokeOptions;
|
|
39
39
|
let _headers = {};
|
|
40
40
|
let body;
|
|
41
|
-
if (functionArgs &&
|
|
41
|
+
if (functionArgs &&
|
|
42
|
+
((headers && !Object.prototype.hasOwnProperty.call(headers, 'Content-Type')) || !headers)) {
|
|
42
43
|
if ((typeof Blob !== 'undefined' && functionArgs instanceof Blob) ||
|
|
43
44
|
functionArgs instanceof ArrayBuffer) {
|
|
44
45
|
// will work for File as File inherits Blob
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionsClient.js","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"FunctionsClient.js","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAuC;AACvC,mCAOgB;AAEhB,MAAa,eAAe;IAK1B,YACE,GAAW,EACX,EACE,OAAO,GAAG,EAAE,EACZ,WAAW,MAIT,EAAE;QAEN,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,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;;;;;OAKG;IACG,MAAM,CACV,YAAoB,EACpB,gBAAuC,EAAE;;;YAEzC,IAAI;gBACF,MAAM,EAAE,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CHANGED
|
@@ -3,15 +3,15 @@ export declare type Fetch = typeof fetch;
|
|
|
3
3
|
* Response format
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
|
-
interface FunctionsResponseSuccess {
|
|
7
|
-
data:
|
|
6
|
+
interface FunctionsResponseSuccess<T> {
|
|
7
|
+
data: T;
|
|
8
8
|
error: null;
|
|
9
9
|
}
|
|
10
10
|
interface FunctionsResponseFailure {
|
|
11
11
|
data: null;
|
|
12
12
|
error: any;
|
|
13
13
|
}
|
|
14
|
-
export declare type FunctionsResponse = FunctionsResponseSuccess | FunctionsResponseFailure;
|
|
14
|
+
export declare type FunctionsResponse<T> = FunctionsResponseSuccess<T> | FunctionsResponseFailure;
|
|
15
15
|
export declare class FunctionsError extends Error {
|
|
16
16
|
context: any;
|
|
17
17
|
constructor(message: string, name?: string, context?: any);
|
|
@@ -25,5 +25,11 @@ export declare class FunctionsRelayError extends FunctionsError {
|
|
|
25
25
|
export declare class FunctionsHttpError extends FunctionsError {
|
|
26
26
|
constructor(context: any);
|
|
27
27
|
}
|
|
28
|
+
export declare type FunctionInvokeOptions = {
|
|
29
|
+
headers?: {
|
|
30
|
+
[key: string]: string;
|
|
31
|
+
};
|
|
32
|
+
body?: File | Blob | ArrayBuffer | FormData | ReadableStream<Uint8Array> | Record<string, any> | string;
|
|
33
|
+
};
|
|
28
34
|
export {};
|
|
29
35
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/main/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK,GAAG,OAAO,KAAK,CAAA;AAEhC;;;GAGG;AACH,UAAU,wBAAwB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK,GAAG,OAAO,KAAK,CAAA;AAEhC;;;GAGG;AACH,UAAU,wBAAwB,CAAC,CAAC;IAClC,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,IAAI,CAAA;CACZ;AACD,UAAU,wBAAwB;IAChC,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,GAAG,CAAA;CACX;AACD,oBAAY,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,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACnC,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"}
|
package/dist/main/types.js
CHANGED
|
@@ -11,13 +11,13 @@ class FunctionsError extends Error {
|
|
|
11
11
|
exports.FunctionsError = FunctionsError;
|
|
12
12
|
class FunctionsFetchError extends FunctionsError {
|
|
13
13
|
constructor(context) {
|
|
14
|
-
super('Failed to
|
|
14
|
+
super('Failed to send a request to the Edge Function', 'FunctionsFetchError', context);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.FunctionsFetchError = FunctionsFetchError;
|
|
18
18
|
class FunctionsRelayError extends FunctionsError {
|
|
19
19
|
constructor(context) {
|
|
20
|
-
super('Relay
|
|
20
|
+
super('Relay Error invoking the Edge Function', 'FunctionsRelayError', context);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.FunctionsRelayError = FunctionsRelayError;
|
package/dist/main/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAgBA,MAAa,cAAe,SAAQ,KAAK;IAEvC,YAAY,OAAe,EAAE,IAAI,GAAG,gBAAgB,EAAE,OAAa;QACjE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,KAAK,CAAC,IAAI,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CACF;AAPD,wCAOC;AAED,MAAa,mBAAoB,SAAQ,cAAc;IACrD,YAAY,OAAY;QACtB,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAgBA,MAAa,cAAe,SAAQ,KAAK;IAEvC,YAAY,OAAe,EAAE,IAAI,GAAG,gBAAgB,EAAE,OAAa;QACjE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,KAAK,CAAC,IAAI,GAAG,IAAI,CAAA;QACjB,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"}
|
package/dist/main/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.4.0-next.
|
|
1
|
+
export declare const version = "1.4.0-next.4";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/main/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fetch, FunctionsResponse } from './types';
|
|
1
|
+
import { Fetch, FunctionsResponse, FunctionInvokeOptions } from './types';
|
|
2
2
|
export declare class FunctionsClient {
|
|
3
3
|
protected url: string;
|
|
4
4
|
protected headers: Record<string, string>;
|
|
@@ -15,12 +15,9 @@ export declare class FunctionsClient {
|
|
|
15
15
|
/**
|
|
16
16
|
* Invokes a function
|
|
17
17
|
* @param functionName - the name of the function to invoke
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
* @param options.headers - headers to send with the request
|
|
18
|
+
* @param invokeOption.headers - object representing the headers to send with the request
|
|
19
|
+
* @param invokeOptions.body - the body of the request
|
|
21
20
|
*/
|
|
22
|
-
invoke(functionName: string,
|
|
23
|
-
headers?: Record<string, string>;
|
|
24
|
-
}): Promise<FunctionsResponse>;
|
|
21
|
+
invoke<T = any>(functionName: string, invokeOptions?: FunctionInvokeOptions): Promise<FunctionsResponse<T>>;
|
|
25
22
|
}
|
|
26
23
|
//# sourceMappingURL=FunctionsClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionsClient.d.ts","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EAIL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"FunctionsClient.d.ts","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EAIL,iBAAiB,EACjB,qBAAqB,EACtB,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,KAAK,EAAE,KAAK,CAAA;gBAGpB,GAAG,EAAE,MAAM,EACX,EACE,OAAY,EACZ,WAAW,GACZ,GAAE;QACD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChC,WAAW,CAAC,EAAE,KAAK,CAAA;KACf;IAOR;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM;IAIrB;;;;;OAKG;IACG,MAAM,CAAC,CAAC,GAAG,GAAG,EAClB,YAAY,EAAE,MAAM,EACpB,aAAa,GAAE,qBAA0B,GACxC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAwEjC"}
|
|
@@ -25,17 +25,18 @@ export class FunctionsClient {
|
|
|
25
25
|
/**
|
|
26
26
|
* Invokes a function
|
|
27
27
|
* @param functionName - the name of the function to invoke
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @param options.headers - headers to send with the request
|
|
28
|
+
* @param invokeOption.headers - object representing the headers to send with the request
|
|
29
|
+
* @param invokeOptions.body - the body of the request
|
|
31
30
|
*/
|
|
32
|
-
invoke(functionName,
|
|
31
|
+
invoke(functionName, invokeOptions = {}) {
|
|
33
32
|
var _a;
|
|
34
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
34
|
try {
|
|
35
|
+
const { headers, body: functionArgs } = invokeOptions;
|
|
36
36
|
let _headers = {};
|
|
37
37
|
let body;
|
|
38
|
-
if (functionArgs &&
|
|
38
|
+
if (functionArgs &&
|
|
39
|
+
((headers && !Object.prototype.hasOwnProperty.call(headers, 'Content-Type')) || !headers)) {
|
|
39
40
|
if ((typeof Blob !== 'undefined' && functionArgs instanceof Blob) ||
|
|
40
41
|
functionArgs instanceof ArrayBuffer) {
|
|
41
42
|
// will work for File as File inherits Blob
|
|
@@ -1 +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,
|
|
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,GAGpB,MAAM,SAAS,CAAA;AAEhB,MAAM,OAAO,eAAe;IAK1B,YACE,GAAW,EACX,EACE,OAAO,GAAG,EAAE,EACZ,WAAW,MAIT,EAAE;QAEN,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,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;;;;;OAKG;IACG,MAAM,CACV,YAAoB,EACpB,gBAAuC,EAAE;;;YAEzC,IAAI;gBACF,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,aAAa,CAAA;gBAErD,IAAI,QAAQ,GAA2B,EAAE,CAAA;gBACzC,IAAI,IAAS,CAAA;gBACb,IACE,YAAY;oBACZ,CAAC,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EACzF;oBACA,IACE,CAA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Q,CAAC,CAAA;iBACxC;gBAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;oBAChB,MAAM,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAA;iBACvC;gBAED,IAAI,YAAY,GAAG,CAAC,MAAA,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,mCAAI,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;gBAC9F,IAAI,IAAS,CAAA;gBACb,IAAI,YAAY,KAAK,kBAAkB,EAAE;oBACvC,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;iBAC7B;qBAAM,IAAI,YAAY,KAAK,0BAA0B,EAAE;oBACtD,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;iBAC7B;qBAAM,IAAI,YAAY,KAAK,qBAAqB,EAAE;oBACjD,IAAI,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAA;iBACjC;qBAAM;oBACL,kBAAkB;oBAClB,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;iBAC7B;gBAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;aAC7B;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;aAC7B;;KACF;CACF"}
|
package/dist/module/types.d.ts
CHANGED
|
@@ -3,15 +3,15 @@ export declare type Fetch = typeof fetch;
|
|
|
3
3
|
* Response format
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
|
-
interface FunctionsResponseSuccess {
|
|
7
|
-
data:
|
|
6
|
+
interface FunctionsResponseSuccess<T> {
|
|
7
|
+
data: T;
|
|
8
8
|
error: null;
|
|
9
9
|
}
|
|
10
10
|
interface FunctionsResponseFailure {
|
|
11
11
|
data: null;
|
|
12
12
|
error: any;
|
|
13
13
|
}
|
|
14
|
-
export declare type FunctionsResponse = FunctionsResponseSuccess | FunctionsResponseFailure;
|
|
14
|
+
export declare type FunctionsResponse<T> = FunctionsResponseSuccess<T> | FunctionsResponseFailure;
|
|
15
15
|
export declare class FunctionsError extends Error {
|
|
16
16
|
context: any;
|
|
17
17
|
constructor(message: string, name?: string, context?: any);
|
|
@@ -25,5 +25,11 @@ export declare class FunctionsRelayError extends FunctionsError {
|
|
|
25
25
|
export declare class FunctionsHttpError extends FunctionsError {
|
|
26
26
|
constructor(context: any);
|
|
27
27
|
}
|
|
28
|
+
export declare type FunctionInvokeOptions = {
|
|
29
|
+
headers?: {
|
|
30
|
+
[key: string]: string;
|
|
31
|
+
};
|
|
32
|
+
body?: File | Blob | ArrayBuffer | FormData | ReadableStream<Uint8Array> | Record<string, any> | string;
|
|
33
|
+
};
|
|
28
34
|
export {};
|
|
29
35
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK,GAAG,OAAO,KAAK,CAAA;AAEhC;;;GAGG;AACH,UAAU,wBAAwB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK,GAAG,OAAO,KAAK,CAAA;AAEhC;;;GAGG;AACH,UAAU,wBAAwB,CAAC,CAAC;IAClC,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,IAAI,CAAA;CACZ;AACD,UAAU,wBAAwB;IAChC,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,GAAG,CAAA;CACX;AACD,oBAAY,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,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACnC,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"}
|
package/dist/module/types.js
CHANGED
|
@@ -7,12 +7,12 @@ export class FunctionsError extends Error {
|
|
|
7
7
|
}
|
|
8
8
|
export class FunctionsFetchError extends FunctionsError {
|
|
9
9
|
constructor(context) {
|
|
10
|
-
super('Failed to
|
|
10
|
+
super('Failed to send a request to the Edge Function', 'FunctionsFetchError', context);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
export class FunctionsRelayError extends FunctionsError {
|
|
14
14
|
constructor(context) {
|
|
15
|
-
super('Relay
|
|
15
|
+
super('Relay Error invoking the Edge Function', 'FunctionsRelayError', context);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
export class FunctionsHttpError extends FunctionsError {
|
package/dist/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAEvC,YAAY,OAAe,EAAE,IAAI,GAAG,gBAAgB,EAAE,OAAa;QACjE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,KAAK,CAAC,IAAI,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IACrD,YAAY,OAAY;QACtB,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAEvC,YAAY,OAAe,EAAE,IAAI,GAAG,gBAAgB,EAAE,OAAa;QACjE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,KAAK,CAAC,IAAI,GAAG,IAAI,CAAA;QACjB,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"}
|
package/dist/module/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.4.0-next.
|
|
1
|
+
export declare const version = "1.4.0-next.4";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/module/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '1.4.0-next.
|
|
1
|
+
export const version = '1.4.0-next.4';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
package/src/FunctionsClient.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
FunctionsHttpError,
|
|
6
6
|
FunctionsRelayError,
|
|
7
7
|
FunctionsResponse,
|
|
8
|
+
FunctionInvokeOptions,
|
|
8
9
|
} from './types'
|
|
9
10
|
|
|
10
11
|
export class FunctionsClient {
|
|
@@ -38,23 +39,22 @@ export class FunctionsClient {
|
|
|
38
39
|
/**
|
|
39
40
|
* Invokes a function
|
|
40
41
|
* @param functionName - the name of the function to invoke
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param options.headers - headers to send with the request
|
|
42
|
+
* @param invokeOption.headers - object representing the headers to send with the request
|
|
43
|
+
* @param invokeOptions.body - the body of the request
|
|
44
44
|
*/
|
|
45
|
-
async invoke(
|
|
45
|
+
async invoke<T = any>(
|
|
46
46
|
functionName: string,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
headers = {},
|
|
50
|
-
}: {
|
|
51
|
-
headers?: Record<string, string>
|
|
52
|
-
} = {}
|
|
53
|
-
): Promise<FunctionsResponse> {
|
|
47
|
+
invokeOptions: FunctionInvokeOptions = {}
|
|
48
|
+
): Promise<FunctionsResponse<T>> {
|
|
54
49
|
try {
|
|
50
|
+
const { headers, body: functionArgs } = invokeOptions
|
|
51
|
+
|
|
55
52
|
let _headers: Record<string, string> = {}
|
|
56
53
|
let body: any
|
|
57
|
-
if (
|
|
54
|
+
if (
|
|
55
|
+
functionArgs &&
|
|
56
|
+
((headers && !Object.prototype.hasOwnProperty.call(headers, 'Content-Type')) || !headers)
|
|
57
|
+
) {
|
|
58
58
|
if (
|
|
59
59
|
(typeof Blob !== 'undefined' && functionArgs instanceof Blob) ||
|
|
60
60
|
functionArgs instanceof ArrayBuffer
|
package/src/types.ts
CHANGED
|
@@ -4,15 +4,15 @@ export type Fetch = typeof fetch
|
|
|
4
4
|
* Response format
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
|
-
interface FunctionsResponseSuccess {
|
|
8
|
-
data:
|
|
7
|
+
interface FunctionsResponseSuccess<T> {
|
|
8
|
+
data: T
|
|
9
9
|
error: null
|
|
10
10
|
}
|
|
11
11
|
interface FunctionsResponseFailure {
|
|
12
12
|
data: null
|
|
13
13
|
error: any
|
|
14
14
|
}
|
|
15
|
-
export type FunctionsResponse = FunctionsResponseSuccess | FunctionsResponseFailure
|
|
15
|
+
export type FunctionsResponse<T> = FunctionsResponseSuccess<T> | FunctionsResponseFailure
|
|
16
16
|
|
|
17
17
|
export class FunctionsError extends Error {
|
|
18
18
|
context: any
|
|
@@ -25,13 +25,13 @@ export class FunctionsError extends Error {
|
|
|
25
25
|
|
|
26
26
|
export class FunctionsFetchError extends FunctionsError {
|
|
27
27
|
constructor(context: any) {
|
|
28
|
-
super('Failed to
|
|
28
|
+
super('Failed to send a request to the Edge Function', 'FunctionsFetchError', context)
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export class FunctionsRelayError extends FunctionsError {
|
|
33
33
|
constructor(context: any) {
|
|
34
|
-
super('Relay
|
|
34
|
+
super('Relay Error invoking the Edge Function', 'FunctionsRelayError', context)
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -40,3 +40,15 @@ export class FunctionsHttpError extends FunctionsError {
|
|
|
40
40
|
super('Edge Function returned a non-2xx status code', 'FunctionsHttpError', context)
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
export type FunctionInvokeOptions = {
|
|
45
|
+
headers?: { [key: string]: string }
|
|
46
|
+
body?:
|
|
47
|
+
| File
|
|
48
|
+
| Blob
|
|
49
|
+
| ArrayBuffer
|
|
50
|
+
| FormData
|
|
51
|
+
| ReadableStream<Uint8Array>
|
|
52
|
+
| Record<string, any>
|
|
53
|
+
| string
|
|
54
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.4.0-next.
|
|
1
|
+
export const version = '1.4.0-next.4'
|