fix price and modular

This commit is contained in:
2026-02-01 17:38:39 +03:30
parent 55f34aa15d
commit 164542d3e2
801 changed files with 16129 additions and 14478 deletions
@@ -1,18 +1,26 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FunctionsClient = void 0;
const tslib_1 = require("tslib");
const helper_1 = require("./helper");
const types_1 = require("./types");
/**
* Client for invoking Supabase Edge Functions.
*/
class FunctionsClient {
/**
* Creates a new Functions client bound to an Edge Functions URL.
*
* @example
* ```ts
* import { FunctionsClient, FunctionRegion } from '@supabase/functions-js'
*
* const functions = new FunctionsClient('https://xyzcompany.supabase.co/functions/v1', {
* headers: { apikey: 'public-anon-key' },
* region: FunctionRegion.UsEast1,
* })
* ```
*/
constructor(url, { headers = {}, customFetch, region = types_1.FunctionRegion.Any, } = {}) {
this.url = url;
this.headers = headers;
@@ -22,6 +30,10 @@ class FunctionsClient {
/**
* Updates the authorization header
* @param token - the new jwt token sent in the authorisation header
* @example
* ```ts
* functions.setAuth(session.access_token)
* ```
*/
setAuth(token) {
this.headers.Authorization = `Bearer ${token}`;
@@ -30,12 +42,20 @@ class FunctionsClient {
* Invokes a function
* @param functionName - The name of the Function to invoke.
* @param options - Options for invoking the Function.
* @example
* ```ts
* const { data, error } = await functions.invoke('hello-world', {
* body: { name: 'Ada' },
* })
* ```
*/
invoke(functionName, options = {}) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
invoke(functionName_1) {
return tslib_1.__awaiter(this, arguments, void 0, function* (functionName, options = {}) {
var _a;
let timeoutId;
let timeoutController;
try {
const { headers, method, body: functionArgs } = options;
const { headers, method, body: functionArgs, signal, timeout } = options;
let _headers = {};
let { region } = options;
if (!region) {
@@ -73,6 +93,33 @@ class FunctionsClient {
body = JSON.stringify(functionArgs);
}
}
else {
if (functionArgs &&
typeof functionArgs !== 'string' &&
!(typeof Blob !== 'undefined' && functionArgs instanceof Blob) &&
!(functionArgs instanceof ArrayBuffer) &&
!(typeof FormData !== 'undefined' && functionArgs instanceof FormData)) {
body = JSON.stringify(functionArgs);
}
else {
body = functionArgs;
}
}
// Handle timeout by creating an AbortController
let effectiveSignal = signal;
if (timeout) {
timeoutController = new AbortController();
timeoutId = setTimeout(() => timeoutController.abort(), timeout);
// If user provided their own signal, we need to respect both
if (signal) {
effectiveSignal = timeoutController.signal;
// If the user's signal is aborted, abort our timeout controller too
signal.addEventListener('abort', () => timeoutController.abort());
}
else {
effectiveSignal = timeoutController.signal;
}
}
const response = yield this.fetch(url.toString(), {
method: method || 'POST',
// headers priority is (high to low):
@@ -81,6 +128,7 @@ class FunctionsClient {
// 3. default Content-Type header
headers: Object.assign(Object.assign(Object.assign({}, _headers), this.headers), headers),
body,
signal: effectiveSignal,
}).catch((fetchError) => {
throw new types_1.FunctionsFetchError(fetchError);
});
@@ -96,7 +144,8 @@ class FunctionsClient {
if (responseType === 'application/json') {
data = yield response.json();
}
else if (responseType === 'application/octet-stream') {
else if (responseType === 'application/octet-stream' ||
responseType === 'application/pdf') {
data = yield response.blob();
}
else if (responseType === 'text/event-stream') {
@@ -120,6 +169,12 @@ class FunctionsClient {
: undefined,
};
}
finally {
// Clear the timeout if it was set
if (timeoutId) {
clearTimeout(timeoutId);
}
}
});
}
}
+2 -32
View File
@@ -1,41 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveFetch = void 0;
const resolveFetch = (customFetch) => {
let _fetch;
if (customFetch) {
_fetch = customFetch;
return (...args) => customFetch(...args);
}
else if (typeof fetch === 'undefined') {
_fetch = (...args) => Promise.resolve().then(() => __importStar(require('@supabase/node-fetch'))).then(({ default: fetch }) => fetch(...args));
}
else {
_fetch = fetch;
}
return (...args) => _fetch(...args);
return (...args) => fetch(...args);
};
exports.resolveFetch = resolveFetch;
//# sourceMappingURL=helper.js.map
+43 -1
View File
@@ -1,6 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FunctionRegion = exports.FunctionsHttpError = exports.FunctionsRelayError = exports.FunctionsFetchError = exports.FunctionsError = void 0;
/**
* Base error for Supabase Edge Function invocations.
*
* @example
* ```ts
* import { FunctionsError } from '@supabase/functions-js'
*
* throw new FunctionsError('Unexpected error invoking function', 'FunctionsError', {
* requestId: 'abc123',
* })
* ```
*/
class FunctionsError extends Error {
constructor(message, name = 'FunctionsError', context) {
super(message);
@@ -9,18 +21,48 @@ class FunctionsError extends Error {
}
}
exports.FunctionsError = FunctionsError;
/**
* Error thrown when the network request to an Edge Function fails.
*
* @example
* ```ts
* import { FunctionsFetchError } from '@supabase/functions-js'
*
* throw new FunctionsFetchError({ requestId: 'abc123' })
* ```
*/
class FunctionsFetchError extends FunctionsError {
constructor(context) {
super('Failed to send a request to the Edge Function', 'FunctionsFetchError', context);
}
}
exports.FunctionsFetchError = FunctionsFetchError;
/**
* Error thrown when the Supabase relay cannot reach the Edge Function.
*
* @example
* ```ts
* import { FunctionsRelayError } from '@supabase/functions-js'
*
* throw new FunctionsRelayError({ region: 'us-east-1' })
* ```
*/
class FunctionsRelayError extends FunctionsError {
constructor(context) {
super('Relay Error invoking the Edge Function', 'FunctionsRelayError', context);
}
}
exports.FunctionsRelayError = FunctionsRelayError;
/**
* Error thrown when the Edge Function returns a non-2xx status code.
*
* @example
* ```ts
* import { FunctionsHttpError } from '@supabase/functions-js'
*
* throw new FunctionsHttpError({ status: 500 })
* ```
*/
class FunctionsHttpError extends FunctionsError {
constructor(context) {
super('Edge Function returned a non-2xx status code', 'FunctionsHttpError', context);
@@ -45,5 +87,5 @@ var FunctionRegion;
FunctionRegion["UsEast1"] = "us-east-1";
FunctionRegion["UsWest1"] = "us-west-1";
FunctionRegion["UsWest2"] = "us-west-2";
})(FunctionRegion = exports.FunctionRegion || (exports.FunctionRegion = {}));
})(FunctionRegion || (exports.FunctionRegion = FunctionRegion = {}));
//# sourceMappingURL=types.js.map