@supabase/functions-js 2.100.0-canary.5 → 2.100.0-canary.6

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.
@@ -19,6 +19,18 @@ export declare class FunctionsClient {
19
19
  * region: FunctionRegion.UsEast1,
20
20
  * })
21
21
  * ```
22
+ *
23
+ * @category Functions
24
+ *
25
+ * @example Creating a Functions client
26
+ * ```ts
27
+ * import { FunctionsClient, FunctionRegion } from '@supabase/functions-js'
28
+ *
29
+ * const functions = new FunctionsClient('https://xyzcompany.supabase.co/functions/v1', {
30
+ * headers: { apikey: 'public-anon-key' },
31
+ * region: FunctionRegion.UsEast1,
32
+ * })
33
+ * ```
22
34
  */
23
35
  constructor(url: string, { headers, customFetch, region, }?: {
24
36
  headers?: Record<string, string>;
@@ -28,7 +40,10 @@ export declare class FunctionsClient {
28
40
  /**
29
41
  * Updates the authorization header
30
42
  * @param token - the new jwt token sent in the authorisation header
31
- * @example
43
+ *
44
+ * @category Functions
45
+ *
46
+ * @example Setting the authorization header
32
47
  * ```ts
33
48
  * functions.setAuth(session.access_token)
34
49
  * ```
@@ -44,6 +59,120 @@ export declare class FunctionsClient {
44
59
  * body: { name: 'Ada' },
45
60
  * })
46
61
  * ```
62
+ *
63
+ * @category Functions
64
+ *
65
+ * @remarks
66
+ * - Requires an Authorization header.
67
+ * - Invoke params generally match the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) spec.
68
+ * - When you pass in a body to your function, we automatically attach the Content-Type header for `Blob`, `ArrayBuffer`, `File`, `FormData` and `String`. If it doesn't match any of these types we assume the payload is `json`, serialize it and attach the `Content-Type` header as `application/json`. You can override this behavior by passing in a `Content-Type` header of your own.
69
+ * - Responses are automatically parsed as `json`, `blob` and `form-data` depending on the `Content-Type` header sent by your function. Responses are parsed as `text` by default.
70
+ *
71
+ * @example Basic invocation
72
+ * ```js
73
+ * const { data, error } = await supabase.functions.invoke('hello', {
74
+ * body: { foo: 'bar' }
75
+ * })
76
+ * ```
77
+ *
78
+ * @exampleDescription Error handling
79
+ * A `FunctionsHttpError` error is returned if your function throws an error, `FunctionsRelayError` if the Supabase Relay has an error processing your function and `FunctionsFetchError` if there is a network error in calling your function.
80
+ *
81
+ * @example Error handling
82
+ * ```js
83
+ * import { FunctionsHttpError, FunctionsRelayError, FunctionsFetchError } from "@supabase/supabase-js";
84
+ *
85
+ * const { data, error } = await supabase.functions.invoke('hello', {
86
+ * headers: {
87
+ * "my-custom-header": 'my-custom-header-value'
88
+ * },
89
+ * body: { foo: 'bar' }
90
+ * })
91
+ *
92
+ * if (error instanceof FunctionsHttpError) {
93
+ * const errorMessage = await error.context.json()
94
+ * console.log('Function returned an error', errorMessage)
95
+ * } else if (error instanceof FunctionsRelayError) {
96
+ * console.log('Relay error:', error.message)
97
+ * } else if (error instanceof FunctionsFetchError) {
98
+ * console.log('Fetch error:', error.message)
99
+ * }
100
+ * ```
101
+ *
102
+ * @exampleDescription Passing custom headers
103
+ * You can pass custom headers to your function. Note: supabase-js automatically passes the `Authorization` header with the signed in user's JWT.
104
+ *
105
+ * @example Passing custom headers
106
+ * ```js
107
+ * const { data, error } = await supabase.functions.invoke('hello', {
108
+ * headers: {
109
+ * "my-custom-header": 'my-custom-header-value'
110
+ * },
111
+ * body: { foo: 'bar' }
112
+ * })
113
+ * ```
114
+ *
115
+ * @exampleDescription Calling with DELETE HTTP verb
116
+ * You can also set the HTTP verb to `DELETE` when calling your Edge Function.
117
+ *
118
+ * @example Calling with DELETE HTTP verb
119
+ * ```js
120
+ * const { data, error } = await supabase.functions.invoke('hello', {
121
+ * headers: {
122
+ * "my-custom-header": 'my-custom-header-value'
123
+ * },
124
+ * body: { foo: 'bar' },
125
+ * method: 'DELETE'
126
+ * })
127
+ * ```
128
+ *
129
+ * @exampleDescription Invoking a Function in the UsEast1 region
130
+ * Here are the available regions:
131
+ * - `FunctionRegion.Any`
132
+ * - `FunctionRegion.ApNortheast1`
133
+ * - `FunctionRegion.ApNortheast2`
134
+ * - `FunctionRegion.ApSouth1`
135
+ * - `FunctionRegion.ApSoutheast1`
136
+ * - `FunctionRegion.ApSoutheast2`
137
+ * - `FunctionRegion.CaCentral1`
138
+ * - `FunctionRegion.EuCentral1`
139
+ * - `FunctionRegion.EuWest1`
140
+ * - `FunctionRegion.EuWest2`
141
+ * - `FunctionRegion.EuWest3`
142
+ * - `FunctionRegion.SaEast1`
143
+ * - `FunctionRegion.UsEast1`
144
+ * - `FunctionRegion.UsWest1`
145
+ * - `FunctionRegion.UsWest2`
146
+ *
147
+ * @example Invoking a Function in the UsEast1 region
148
+ * ```js
149
+ * import { createClient, FunctionRegion } from '@supabase/supabase-js'
150
+ *
151
+ * const { data, error } = await supabase.functions.invoke('hello', {
152
+ * body: { foo: 'bar' },
153
+ * region: FunctionRegion.UsEast1
154
+ * })
155
+ * ```
156
+ *
157
+ * @exampleDescription Calling with GET HTTP verb
158
+ * You can also set the HTTP verb to `GET` when calling your Edge Function.
159
+ *
160
+ * @example Calling with GET HTTP verb
161
+ * ```js
162
+ * const { data, error } = await supabase.functions.invoke('hello', {
163
+ * headers: {
164
+ * "my-custom-header": 'my-custom-header-value'
165
+ * },
166
+ * method: 'GET'
167
+ * })
168
+ * ```
169
+ *
170
+ * @example Example 7
171
+ * ```ts
172
+ * const { data, error } = await functions.invoke('hello-world', {
173
+ * body: { name: 'Ada' },
174
+ * })
175
+ * ```
47
176
  */
48
177
  invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<FunctionsResponse<T>>;
49
178
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionsClient.d.ts","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,cAAc,EAId,iBAAiB,EAClB,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,qBAAa,eAAe;IAC1B,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,OAA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AM,CAAC,EAAE,cAAc,CAAA;KACnB;IAQR;;;;;;;;;;OAUG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM;IAIrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4HG;IACG,MAAM,CAAC,CAAC,GAAG,GAAG,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAkIjC"}
@@ -20,6 +20,18 @@ class FunctionsClient {
20
20
  * region: FunctionRegion.UsEast1,
21
21
  * })
22
22
  * ```
23
+ *
24
+ * @category Functions
25
+ *
26
+ * @example Creating a Functions client
27
+ * ```ts
28
+ * import { FunctionsClient, FunctionRegion } from '@supabase/functions-js'
29
+ *
30
+ * const functions = new FunctionsClient('https://xyzcompany.supabase.co/functions/v1', {
31
+ * headers: { apikey: 'public-anon-key' },
32
+ * region: FunctionRegion.UsEast1,
33
+ * })
34
+ * ```
23
35
  */
24
36
  constructor(url, { headers = {}, customFetch, region = types_1.FunctionRegion.Any, } = {}) {
25
37
  this.url = url;
@@ -30,7 +42,10 @@ class FunctionsClient {
30
42
  /**
31
43
  * Updates the authorization header
32
44
  * @param token - the new jwt token sent in the authorisation header
33
- * @example
45
+ *
46
+ * @category Functions
47
+ *
48
+ * @example Setting the authorization header
34
49
  * ```ts
35
50
  * functions.setAuth(session.access_token)
36
51
  * ```
@@ -48,6 +63,120 @@ class FunctionsClient {
48
63
  * body: { name: 'Ada' },
49
64
  * })
50
65
  * ```
66
+ *
67
+ * @category Functions
68
+ *
69
+ * @remarks
70
+ * - Requires an Authorization header.
71
+ * - Invoke params generally match the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) spec.
72
+ * - When you pass in a body to your function, we automatically attach the Content-Type header for `Blob`, `ArrayBuffer`, `File`, `FormData` and `String`. If it doesn't match any of these types we assume the payload is `json`, serialize it and attach the `Content-Type` header as `application/json`. You can override this behavior by passing in a `Content-Type` header of your own.
73
+ * - Responses are automatically parsed as `json`, `blob` and `form-data` depending on the `Content-Type` header sent by your function. Responses are parsed as `text` by default.
74
+ *
75
+ * @example Basic invocation
76
+ * ```js
77
+ * const { data, error } = await supabase.functions.invoke('hello', {
78
+ * body: { foo: 'bar' }
79
+ * })
80
+ * ```
81
+ *
82
+ * @exampleDescription Error handling
83
+ * A `FunctionsHttpError` error is returned if your function throws an error, `FunctionsRelayError` if the Supabase Relay has an error processing your function and `FunctionsFetchError` if there is a network error in calling your function.
84
+ *
85
+ * @example Error handling
86
+ * ```js
87
+ * import { FunctionsHttpError, FunctionsRelayError, FunctionsFetchError } from "@supabase/supabase-js";
88
+ *
89
+ * const { data, error } = await supabase.functions.invoke('hello', {
90
+ * headers: {
91
+ * "my-custom-header": 'my-custom-header-value'
92
+ * },
93
+ * body: { foo: 'bar' }
94
+ * })
95
+ *
96
+ * if (error instanceof FunctionsHttpError) {
97
+ * const errorMessage = await error.context.json()
98
+ * console.log('Function returned an error', errorMessage)
99
+ * } else if (error instanceof FunctionsRelayError) {
100
+ * console.log('Relay error:', error.message)
101
+ * } else if (error instanceof FunctionsFetchError) {
102
+ * console.log('Fetch error:', error.message)
103
+ * }
104
+ * ```
105
+ *
106
+ * @exampleDescription Passing custom headers
107
+ * You can pass custom headers to your function. Note: supabase-js automatically passes the `Authorization` header with the signed in user's JWT.
108
+ *
109
+ * @example Passing custom headers
110
+ * ```js
111
+ * const { data, error } = await supabase.functions.invoke('hello', {
112
+ * headers: {
113
+ * "my-custom-header": 'my-custom-header-value'
114
+ * },
115
+ * body: { foo: 'bar' }
116
+ * })
117
+ * ```
118
+ *
119
+ * @exampleDescription Calling with DELETE HTTP verb
120
+ * You can also set the HTTP verb to `DELETE` when calling your Edge Function.
121
+ *
122
+ * @example Calling with DELETE HTTP verb
123
+ * ```js
124
+ * const { data, error } = await supabase.functions.invoke('hello', {
125
+ * headers: {
126
+ * "my-custom-header": 'my-custom-header-value'
127
+ * },
128
+ * body: { foo: 'bar' },
129
+ * method: 'DELETE'
130
+ * })
131
+ * ```
132
+ *
133
+ * @exampleDescription Invoking a Function in the UsEast1 region
134
+ * Here are the available regions:
135
+ * - `FunctionRegion.Any`
136
+ * - `FunctionRegion.ApNortheast1`
137
+ * - `FunctionRegion.ApNortheast2`
138
+ * - `FunctionRegion.ApSouth1`
139
+ * - `FunctionRegion.ApSoutheast1`
140
+ * - `FunctionRegion.ApSoutheast2`
141
+ * - `FunctionRegion.CaCentral1`
142
+ * - `FunctionRegion.EuCentral1`
143
+ * - `FunctionRegion.EuWest1`
144
+ * - `FunctionRegion.EuWest2`
145
+ * - `FunctionRegion.EuWest3`
146
+ * - `FunctionRegion.SaEast1`
147
+ * - `FunctionRegion.UsEast1`
148
+ * - `FunctionRegion.UsWest1`
149
+ * - `FunctionRegion.UsWest2`
150
+ *
151
+ * @example Invoking a Function in the UsEast1 region
152
+ * ```js
153
+ * import { createClient, FunctionRegion } from '@supabase/supabase-js'
154
+ *
155
+ * const { data, error } = await supabase.functions.invoke('hello', {
156
+ * body: { foo: 'bar' },
157
+ * region: FunctionRegion.UsEast1
158
+ * })
159
+ * ```
160
+ *
161
+ * @exampleDescription Calling with GET HTTP verb
162
+ * You can also set the HTTP verb to `GET` when calling your Edge Function.
163
+ *
164
+ * @example Calling with GET HTTP verb
165
+ * ```js
166
+ * const { data, error } = await supabase.functions.invoke('hello', {
167
+ * headers: {
168
+ * "my-custom-header": 'my-custom-header-value'
169
+ * },
170
+ * method: 'GET'
171
+ * })
172
+ * ```
173
+ *
174
+ * @example Example 7
175
+ * ```ts
176
+ * const { data, error } = await functions.invoke('hello-world', {
177
+ * body: { name: 'Ada' },
178
+ * })
179
+ * ```
51
180
  */
52
181
  invoke(functionName_1) {
53
182
  return tslib_1.__awaiter(this, arguments, void 0, function* (functionName, options = {}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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;oBAAS,CAAC;gBACT,kCAAkC;gBAClC,IAAI,SAAS,EAAE,CAAC;oBACd,YAAY,CAAC,SAAS,CAAC,CAAA;gBACzB,CAAC;YACH,CAAC;QACH,CAAC;KAAA;CACF;AAlUD,0CAkUC"}
@@ -1,2 +1,2 @@
1
- export declare const version = "2.100.0-canary.5";
1
+ export declare const version = "2.100.0-canary.6";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -7,5 +7,5 @@ exports.version = void 0;
7
7
  // - Debugging and support (identifying which version is running)
8
8
  // - Telemetry and logging (version reporting in errors/analytics)
9
9
  // - Ensuring build artifacts match the published package version
10
- exports.version = '2.100.0-canary.5';
10
+ exports.version = '2.100.0-canary.6';
11
11
  //# sourceMappingURL=version.js.map
@@ -19,6 +19,18 @@ export declare class FunctionsClient {
19
19
  * region: FunctionRegion.UsEast1,
20
20
  * })
21
21
  * ```
22
+ *
23
+ * @category Functions
24
+ *
25
+ * @example Creating a Functions client
26
+ * ```ts
27
+ * import { FunctionsClient, FunctionRegion } from '@supabase/functions-js'
28
+ *
29
+ * const functions = new FunctionsClient('https://xyzcompany.supabase.co/functions/v1', {
30
+ * headers: { apikey: 'public-anon-key' },
31
+ * region: FunctionRegion.UsEast1,
32
+ * })
33
+ * ```
22
34
  */
23
35
  constructor(url: string, { headers, customFetch, region, }?: {
24
36
  headers?: Record<string, string>;
@@ -28,7 +40,10 @@ export declare class FunctionsClient {
28
40
  /**
29
41
  * Updates the authorization header
30
42
  * @param token - the new jwt token sent in the authorisation header
31
- * @example
43
+ *
44
+ * @category Functions
45
+ *
46
+ * @example Setting the authorization header
32
47
  * ```ts
33
48
  * functions.setAuth(session.access_token)
34
49
  * ```
@@ -44,6 +59,120 @@ export declare class FunctionsClient {
44
59
  * body: { name: 'Ada' },
45
60
  * })
46
61
  * ```
62
+ *
63
+ * @category Functions
64
+ *
65
+ * @remarks
66
+ * - Requires an Authorization header.
67
+ * - Invoke params generally match the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) spec.
68
+ * - When you pass in a body to your function, we automatically attach the Content-Type header for `Blob`, `ArrayBuffer`, `File`, `FormData` and `String`. If it doesn't match any of these types we assume the payload is `json`, serialize it and attach the `Content-Type` header as `application/json`. You can override this behavior by passing in a `Content-Type` header of your own.
69
+ * - Responses are automatically parsed as `json`, `blob` and `form-data` depending on the `Content-Type` header sent by your function. Responses are parsed as `text` by default.
70
+ *
71
+ * @example Basic invocation
72
+ * ```js
73
+ * const { data, error } = await supabase.functions.invoke('hello', {
74
+ * body: { foo: 'bar' }
75
+ * })
76
+ * ```
77
+ *
78
+ * @exampleDescription Error handling
79
+ * A `FunctionsHttpError` error is returned if your function throws an error, `FunctionsRelayError` if the Supabase Relay has an error processing your function and `FunctionsFetchError` if there is a network error in calling your function.
80
+ *
81
+ * @example Error handling
82
+ * ```js
83
+ * import { FunctionsHttpError, FunctionsRelayError, FunctionsFetchError } from "@supabase/supabase-js";
84
+ *
85
+ * const { data, error } = await supabase.functions.invoke('hello', {
86
+ * headers: {
87
+ * "my-custom-header": 'my-custom-header-value'
88
+ * },
89
+ * body: { foo: 'bar' }
90
+ * })
91
+ *
92
+ * if (error instanceof FunctionsHttpError) {
93
+ * const errorMessage = await error.context.json()
94
+ * console.log('Function returned an error', errorMessage)
95
+ * } else if (error instanceof FunctionsRelayError) {
96
+ * console.log('Relay error:', error.message)
97
+ * } else if (error instanceof FunctionsFetchError) {
98
+ * console.log('Fetch error:', error.message)
99
+ * }
100
+ * ```
101
+ *
102
+ * @exampleDescription Passing custom headers
103
+ * You can pass custom headers to your function. Note: supabase-js automatically passes the `Authorization` header with the signed in user's JWT.
104
+ *
105
+ * @example Passing custom headers
106
+ * ```js
107
+ * const { data, error } = await supabase.functions.invoke('hello', {
108
+ * headers: {
109
+ * "my-custom-header": 'my-custom-header-value'
110
+ * },
111
+ * body: { foo: 'bar' }
112
+ * })
113
+ * ```
114
+ *
115
+ * @exampleDescription Calling with DELETE HTTP verb
116
+ * You can also set the HTTP verb to `DELETE` when calling your Edge Function.
117
+ *
118
+ * @example Calling with DELETE HTTP verb
119
+ * ```js
120
+ * const { data, error } = await supabase.functions.invoke('hello', {
121
+ * headers: {
122
+ * "my-custom-header": 'my-custom-header-value'
123
+ * },
124
+ * body: { foo: 'bar' },
125
+ * method: 'DELETE'
126
+ * })
127
+ * ```
128
+ *
129
+ * @exampleDescription Invoking a Function in the UsEast1 region
130
+ * Here are the available regions:
131
+ * - `FunctionRegion.Any`
132
+ * - `FunctionRegion.ApNortheast1`
133
+ * - `FunctionRegion.ApNortheast2`
134
+ * - `FunctionRegion.ApSouth1`
135
+ * - `FunctionRegion.ApSoutheast1`
136
+ * - `FunctionRegion.ApSoutheast2`
137
+ * - `FunctionRegion.CaCentral1`
138
+ * - `FunctionRegion.EuCentral1`
139
+ * - `FunctionRegion.EuWest1`
140
+ * - `FunctionRegion.EuWest2`
141
+ * - `FunctionRegion.EuWest3`
142
+ * - `FunctionRegion.SaEast1`
143
+ * - `FunctionRegion.UsEast1`
144
+ * - `FunctionRegion.UsWest1`
145
+ * - `FunctionRegion.UsWest2`
146
+ *
147
+ * @example Invoking a Function in the UsEast1 region
148
+ * ```js
149
+ * import { createClient, FunctionRegion } from '@supabase/supabase-js'
150
+ *
151
+ * const { data, error } = await supabase.functions.invoke('hello', {
152
+ * body: { foo: 'bar' },
153
+ * region: FunctionRegion.UsEast1
154
+ * })
155
+ * ```
156
+ *
157
+ * @exampleDescription Calling with GET HTTP verb
158
+ * You can also set the HTTP verb to `GET` when calling your Edge Function.
159
+ *
160
+ * @example Calling with GET HTTP verb
161
+ * ```js
162
+ * const { data, error } = await supabase.functions.invoke('hello', {
163
+ * headers: {
164
+ * "my-custom-header": 'my-custom-header-value'
165
+ * },
166
+ * method: 'GET'
167
+ * })
168
+ * ```
169
+ *
170
+ * @example Example 7
171
+ * ```ts
172
+ * const { data, error } = await functions.invoke('hello-world', {
173
+ * body: { name: 'Ada' },
174
+ * })
175
+ * ```
47
176
  */
48
177
  invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<FunctionsResponse<T>>;
49
178
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionsClient.d.ts","sourceRoot":"","sources":["../../src/FunctionsClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,cAAc,EAId,iBAAiB,EAClB,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,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;IAEtB;;;;;;;;;;;;OAYG;gBAED,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,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CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAkIjC"}
@@ -17,6 +17,18 @@ export class FunctionsClient {
17
17
  * region: FunctionRegion.UsEast1,
18
18
  * })
19
19
  * ```
20
+ *
21
+ * @category Functions
22
+ *
23
+ * @example Creating a Functions client
24
+ * ```ts
25
+ * import { FunctionsClient, FunctionRegion } from '@supabase/functions-js'
26
+ *
27
+ * const functions = new FunctionsClient('https://xyzcompany.supabase.co/functions/v1', {
28
+ * headers: { apikey: 'public-anon-key' },
29
+ * region: FunctionRegion.UsEast1,
30
+ * })
31
+ * ```
20
32
  */
21
33
  constructor(url, { headers = {}, customFetch, region = FunctionRegion.Any, } = {}) {
22
34
  this.url = url;
@@ -27,7 +39,10 @@ export class FunctionsClient {
27
39
  /**
28
40
  * Updates the authorization header
29
41
  * @param token - the new jwt token sent in the authorisation header
30
- * @example
42
+ *
43
+ * @category Functions
44
+ *
45
+ * @example Setting the authorization header
31
46
  * ```ts
32
47
  * functions.setAuth(session.access_token)
33
48
  * ```
@@ -45,6 +60,120 @@ export class FunctionsClient {
45
60
  * body: { name: 'Ada' },
46
61
  * })
47
62
  * ```
63
+ *
64
+ * @category Functions
65
+ *
66
+ * @remarks
67
+ * - Requires an Authorization header.
68
+ * - Invoke params generally match the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) spec.
69
+ * - When you pass in a body to your function, we automatically attach the Content-Type header for `Blob`, `ArrayBuffer`, `File`, `FormData` and `String`. If it doesn't match any of these types we assume the payload is `json`, serialize it and attach the `Content-Type` header as `application/json`. You can override this behavior by passing in a `Content-Type` header of your own.
70
+ * - Responses are automatically parsed as `json`, `blob` and `form-data` depending on the `Content-Type` header sent by your function. Responses are parsed as `text` by default.
71
+ *
72
+ * @example Basic invocation
73
+ * ```js
74
+ * const { data, error } = await supabase.functions.invoke('hello', {
75
+ * body: { foo: 'bar' }
76
+ * })
77
+ * ```
78
+ *
79
+ * @exampleDescription Error handling
80
+ * A `FunctionsHttpError` error is returned if your function throws an error, `FunctionsRelayError` if the Supabase Relay has an error processing your function and `FunctionsFetchError` if there is a network error in calling your function.
81
+ *
82
+ * @example Error handling
83
+ * ```js
84
+ * import { FunctionsHttpError, FunctionsRelayError, FunctionsFetchError } from "@supabase/supabase-js";
85
+ *
86
+ * const { data, error } = await supabase.functions.invoke('hello', {
87
+ * headers: {
88
+ * "my-custom-header": 'my-custom-header-value'
89
+ * },
90
+ * body: { foo: 'bar' }
91
+ * })
92
+ *
93
+ * if (error instanceof FunctionsHttpError) {
94
+ * const errorMessage = await error.context.json()
95
+ * console.log('Function returned an error', errorMessage)
96
+ * } else if (error instanceof FunctionsRelayError) {
97
+ * console.log('Relay error:', error.message)
98
+ * } else if (error instanceof FunctionsFetchError) {
99
+ * console.log('Fetch error:', error.message)
100
+ * }
101
+ * ```
102
+ *
103
+ * @exampleDescription Passing custom headers
104
+ * You can pass custom headers to your function. Note: supabase-js automatically passes the `Authorization` header with the signed in user's JWT.
105
+ *
106
+ * @example Passing custom headers
107
+ * ```js
108
+ * const { data, error } = await supabase.functions.invoke('hello', {
109
+ * headers: {
110
+ * "my-custom-header": 'my-custom-header-value'
111
+ * },
112
+ * body: { foo: 'bar' }
113
+ * })
114
+ * ```
115
+ *
116
+ * @exampleDescription Calling with DELETE HTTP verb
117
+ * You can also set the HTTP verb to `DELETE` when calling your Edge Function.
118
+ *
119
+ * @example Calling with DELETE HTTP verb
120
+ * ```js
121
+ * const { data, error } = await supabase.functions.invoke('hello', {
122
+ * headers: {
123
+ * "my-custom-header": 'my-custom-header-value'
124
+ * },
125
+ * body: { foo: 'bar' },
126
+ * method: 'DELETE'
127
+ * })
128
+ * ```
129
+ *
130
+ * @exampleDescription Invoking a Function in the UsEast1 region
131
+ * Here are the available regions:
132
+ * - `FunctionRegion.Any`
133
+ * - `FunctionRegion.ApNortheast1`
134
+ * - `FunctionRegion.ApNortheast2`
135
+ * - `FunctionRegion.ApSouth1`
136
+ * - `FunctionRegion.ApSoutheast1`
137
+ * - `FunctionRegion.ApSoutheast2`
138
+ * - `FunctionRegion.CaCentral1`
139
+ * - `FunctionRegion.EuCentral1`
140
+ * - `FunctionRegion.EuWest1`
141
+ * - `FunctionRegion.EuWest2`
142
+ * - `FunctionRegion.EuWest3`
143
+ * - `FunctionRegion.SaEast1`
144
+ * - `FunctionRegion.UsEast1`
145
+ * - `FunctionRegion.UsWest1`
146
+ * - `FunctionRegion.UsWest2`
147
+ *
148
+ * @example Invoking a Function in the UsEast1 region
149
+ * ```js
150
+ * import { createClient, FunctionRegion } from '@supabase/supabase-js'
151
+ *
152
+ * const { data, error } = await supabase.functions.invoke('hello', {
153
+ * body: { foo: 'bar' },
154
+ * region: FunctionRegion.UsEast1
155
+ * })
156
+ * ```
157
+ *
158
+ * @exampleDescription Calling with GET HTTP verb
159
+ * You can also set the HTTP verb to `GET` when calling your Edge Function.
160
+ *
161
+ * @example Calling with GET HTTP verb
162
+ * ```js
163
+ * const { data, error } = await supabase.functions.invoke('hello', {
164
+ * headers: {
165
+ * "my-custom-header": 'my-custom-header-value'
166
+ * },
167
+ * method: 'GET'
168
+ * })
169
+ * ```
170
+ *
171
+ * @example Example 7
172
+ * ```ts
173
+ * const { data, error } = await functions.invoke('hello-world', {
174
+ * body: { name: 'Ada' },
175
+ * })
176
+ * ```
48
177
  */
49
178
  invoke(functionName_1) {
50
179
  return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {