@intlayer/api 9.5.6 → 9.5.7
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/cjs/fetcher.cjs +3 -1
- package/dist/cjs/fetcher.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/index.cjs +1 -1
- package/dist/cjs/index.cjs +7 -4
- package/dist/cjs/proxy.cjs +1 -1
- package/dist/cjs/resolveInternalBackendUrl.cjs +51 -0
- package/dist/cjs/resolveInternalBackendUrl.cjs.map +1 -0
- package/dist/esm/fetcher.mjs +3 -1
- package/dist/esm/fetcher.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/index.mjs +1 -1
- package/dist/esm/index.mjs +6 -5
- package/dist/esm/proxy.mjs +1 -1
- package/dist/esm/resolveInternalBackendUrl.mjs +49 -0
- package/dist/esm/resolveInternalBackendUrl.mjs.map +1 -0
- package/dist/types/fetcher.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/resolveInternalBackendUrl.d.ts +26 -0
- package/dist/types/resolveInternalBackendUrl.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/cjs/fetcher.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_resolveInternalBackendUrl = require('./resolveInternalBackendUrl.cjs');
|
|
3
|
+
|
|
2
4
|
//#region src/fetcher.ts
|
|
3
5
|
/**
|
|
4
6
|
* Error thrown when the backend answers with a non-ok response.
|
|
@@ -130,7 +132,7 @@ const fetcher = async (url, ...options) => {
|
|
|
130
132
|
body: bodyString,
|
|
131
133
|
signal
|
|
132
134
|
};
|
|
133
|
-
const urlResult = `${url}${paramsString}
|
|
135
|
+
const urlResult = require_resolveInternalBackendUrl.resolveInternalBackendUrl(`${url}${paramsString}`);
|
|
134
136
|
const response = await fetch(urlResult, formattedOptions);
|
|
135
137
|
if (!response.ok) {
|
|
136
138
|
const result = await response.json().catch(() => void 0);
|
package/dist/cjs/fetcher.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetcher.cjs","names":[],"sources":["../../src/fetcher.ts"],"sourcesContent":["/**\n * Error thrown when the backend answers with a non-ok response.\n *\n * Carries the HTTP status and the backend error code alongside the message, so\n * callers can tell a transient failure (5xx, network) from a deterministic one\n * (4xx) instead of blindly retrying.\n */\nexport class FetcherError extends Error {\n /** HTTP status code of the response. */\n public readonly status: number;\n /** Error code returned by the backend, when available (ex: `DICTIONARY_NOT_FOUND`). */\n public readonly code?: string;\n /** Raw error payload returned by the backend. */\n public readonly data?: unknown;\n\n constructor(\n message: string,\n details: { status: number; code?: string; data?: unknown }\n ) {\n super(message);\n\n this.name = 'FetcherError';\n this.status = details.status;\n this.code = details.code;\n this.data = details.data;\n }\n}\n\n/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include',\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n const { signal } = new AbortController();\n\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n signal,\n };\n\n // Construct the full URL with query parameters\n const urlResult = `${url}${paramsString}
|
|
1
|
+
{"version":3,"file":"fetcher.cjs","names":["resolveInternalBackendUrl"],"sources":["../../src/fetcher.ts"],"sourcesContent":["import { resolveInternalBackendUrl } from './resolveInternalBackendUrl';\n\n/**\n * Error thrown when the backend answers with a non-ok response.\n *\n * Carries the HTTP status and the backend error code alongside the message, so\n * callers can tell a transient failure (5xx, network) from a deterministic one\n * (4xx) instead of blindly retrying.\n */\nexport class FetcherError extends Error {\n /** HTTP status code of the response. */\n public readonly status: number;\n /** Error code returned by the backend, when available (ex: `DICTIONARY_NOT_FOUND`). */\n public readonly code?: string;\n /** Raw error payload returned by the backend. */\n public readonly data?: unknown;\n\n constructor(\n message: string,\n details: { status: number; code?: string; data?: unknown }\n ) {\n super(message);\n\n this.name = 'FetcherError';\n this.status = details.status;\n this.code = details.code;\n this.data = details.data;\n }\n}\n\n/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include',\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n const { signal } = new AbortController();\n\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n signal,\n };\n\n // Construct the full URL with query parameters. Server code inside a private\n // network may need to reach the backend under another origin — see\n // `resolveInternalBackendUrl`.\n const urlResult = resolveInternalBackendUrl(`${url}${paramsString}`);\n\n // Make the HTTP request using fetch\n const response = await fetch(urlResult, formattedOptions);\n\n if (!response.ok) {\n const result = await response.json().catch(() => undefined);\n\n // You can customize the error message or include more details\n throw new FetcherError(\n JSON.stringify(result?.error) ?? 'An error occurred',\n {\n status: response.status,\n code: result?.error?.code,\n data: result?.error,\n }\n );\n }\n return await response.json();\n};\n"],"mappings":";;;;;;;;;;;AASA,IAAa,eAAb,cAAkC,MAAM;;CAEtC,AAAgB;;CAEhB,AAAgB;;CAEhB,AAAgB;CAEhB,YACE,SACA,SACA;EACA,MAAM,OAAO;EAEb,KAAK,OAAO;EACZ,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO,QAAQ;CACtB;AACF;;;;;;AA0BA,MAAa,iBAAiC;CAC5C,QAAQ;CACR,SAAS,EACP,gBAAgB,mBAClB;CACA,aAAa;AACf;;;;;;;;AASA,MAAM,mBAAmB,QAAgB;CACvC,OAAO,KAAK,GAAG,CAAC,CAAC,SAAS,QAAQ;EAChC,IAAI,IAAI,SAA6B,QACnC,OAAO,IAAI;CAEf,CAAC;CACD,OAAO;AACT;;;;;;;;;AAUA,MAAM,aAA+B,YACnC,QAAQ,QAAQ,KAAK,QAAQ;CAC3B,MAAM,OAAW,OAAO,CAAC;CACzB,MAAM,OAAU,gBAAgB,OAAO,CAAC,CAAC;CAEzC,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAE9C,OAAO;EAAE,GAAG;EAAM,GAAG;CAAK;CAI5B,OAAO,QAAQ;AACjB,GAAG,CAAC,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDZ,MAAa,UAAU,OACrB,KACA,GAAG,YACY;CACf,MAAM,EAAE,WAAW,IAAI,gBAAgB;CAGvC,IAAI,eAAe;CACnB,IAAI;CAGJ,MAAM,eAAe,QAAQ,KAC1B,EAAE,MAAM,QAAQ,SAAS,GAAG,mBAAmB,YAClD;CAGA,MAAM,gBAAgB,UAAU,CAAC,gBAAgB,GAAG,YAAY,CAAC;CAGjE,MAAM,gBAAgB,UAAU,CAC9B,eAAe,SACf,GAAG,QAAQ,KAAK,WAAW,OAAO,OAAO,CAC3C,CAAC;CAGD,MAAM,SAAS,UAAU,QAAQ,KAAK,WAAW,OAAO,MAAM,CAAC;CAE/D,MAAM,SAAS,cAAc;CAG7B,IAAI,WAAW,SAAS,WAAW,QAAQ;EAEzC,MAAM,OAAO,UAAU,QAAQ,KAAK,WAAW,OAAO,IAAI,CAAC;EAC3D,IACE,gBAAgB,oBAChB,qCAGA,aAAa,IAAI,gBACf,IACF,CAAC,CAAC,SAAS;OAGX,aAAa,KAAK,UAAU,IAAI;CAEpC;CAGA,IAAI,OAAO,QAAQ,MAAM,CAAC,CAAC,SAAS,GAClC,eAAe,IAAI,IAAI,gBACrB,MACF,CAAC,CAAC,SAAS;CAIb,MAAM,mBAAgC;EACpC,GAAG;EACH,SAAS;EACT,MAAM;EACN;CACF;CAKA,MAAM,YAAYA,4DAA0B,GAAG,MAAM,cAAc;CAGnE,MAAM,WAAW,MAAM,MAAM,WAAW,gBAAgB;CAExD,IAAI,CAAC,SAAS,IAAI;EAChB,MAAM,SAAS,MAAM,SAAS,KAAK,CAAC,CAAC,YAAY,MAAS;EAG1D,MAAM,IAAI,aACR,KAAK,UAAU,QAAQ,KAAK,KAAK,qBACjC;GACE,QAAQ,SAAS;GACjB,MAAM,QAAQ,OAAO;GACrB,MAAM,QAAQ;EAChB,CACF;CACF;CACA,OAAO,MAAM,SAAS,KAAK;AAC7B"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_getIntlayerAPI_oAuth = require('./oAuth.cjs');
|
|
3
|
-
const require_getIntlayerAPI_dictionary = require('./dictionary.cjs');
|
|
4
3
|
const require_getIntlayerAPI_ai = require('./ai.cjs');
|
|
5
4
|
const require_getIntlayerAPI_analytics = require('./analytics.cjs');
|
|
6
5
|
const require_getIntlayerAPI_asset = require('./asset.cjs');
|
|
7
6
|
const require_getIntlayerAPI_audit = require('./audit.cjs');
|
|
8
7
|
const require_getIntlayerAPI_bitbucket = require('./bitbucket.cjs');
|
|
8
|
+
const require_getIntlayerAPI_dictionary = require('./dictionary.cjs');
|
|
9
9
|
const require_getIntlayerAPI_editor = require('./editor.cjs');
|
|
10
10
|
const require_getIntlayerAPI_environment = require('./environment.cjs');
|
|
11
11
|
const require_getIntlayerAPI_github = require('./github.cjs');
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_resolveInternalBackendUrl = require('./resolveInternalBackendUrl.cjs');
|
|
2
3
|
const require_fetcher = require('./fetcher.cjs');
|
|
3
4
|
const require_getIntlayerAPI_oAuth = require('./getIntlayerAPI/oAuth.cjs');
|
|
4
5
|
const require_cms_createAuthManager = require('./cms/createAuthManager.cjs');
|
|
5
6
|
const require_cms_createIntlayerCMS = require('./cms/createIntlayerCMS.cjs');
|
|
6
|
-
const require_getIntlayerAPI_dictionary = require('./getIntlayerAPI/dictionary.cjs');
|
|
7
|
-
const require_distantDictionary_fetchDistantDictionaries = require('./distantDictionary/fetchDistantDictionaries.cjs');
|
|
8
|
-
const require_distantDictionary_fetchDistantDictionary = require('./distantDictionary/fetchDistantDictionary.cjs');
|
|
9
7
|
const require_getIntlayerAPI_ai = require('./getIntlayerAPI/ai.cjs');
|
|
10
8
|
const require_getIntlayerAPI_analytics = require('./getIntlayerAPI/analytics.cjs');
|
|
11
9
|
const require_getIntlayerAPI_asset = require('./getIntlayerAPI/asset.cjs');
|
|
12
10
|
const require_getIntlayerAPI_audit = require('./getIntlayerAPI/audit.cjs');
|
|
13
11
|
const require_getIntlayerAPI_bitbucket = require('./getIntlayerAPI/bitbucket.cjs');
|
|
12
|
+
const require_getIntlayerAPI_dictionary = require('./getIntlayerAPI/dictionary.cjs');
|
|
14
13
|
const require_getIntlayerAPI_editor = require('./getIntlayerAPI/editor.cjs');
|
|
15
14
|
const require_getIntlayerAPI_environment = require('./getIntlayerAPI/environment.cjs');
|
|
16
15
|
const require_getIntlayerAPI_github = require('./getIntlayerAPI/github.cjs');
|
|
@@ -26,9 +25,12 @@ const require_getIntlayerAPI_stripe = require('./getIntlayerAPI/stripe.cjs');
|
|
|
26
25
|
const require_getIntlayerAPI_tag = require('./getIntlayerAPI/tag.cjs');
|
|
27
26
|
const require_getIntlayerAPI_translate = require('./getIntlayerAPI/translate.cjs');
|
|
28
27
|
const require_getIntlayerAPI_user = require('./getIntlayerAPI/user.cjs');
|
|
29
|
-
const require_getIntlayerAPI_index = require('./getIntlayerAPI/index.cjs');
|
|
30
28
|
const require_proxy = require('./proxy.cjs');
|
|
29
|
+
const require_distantDictionary_fetchDistantDictionaries = require('./distantDictionary/fetchDistantDictionaries.cjs');
|
|
30
|
+
const require_distantDictionary_fetchDistantDictionary = require('./distantDictionary/fetchDistantDictionary.cjs');
|
|
31
|
+
const require_getIntlayerAPI_index = require('./getIntlayerAPI/index.cjs');
|
|
31
32
|
|
|
33
|
+
exports.BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE = require_resolveInternalBackendUrl.BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE;
|
|
32
34
|
exports.FetcherError = require_fetcher.FetcherError;
|
|
33
35
|
exports.aiEndpoint = require_getIntlayerAPI_ai.aiEndpoint;
|
|
34
36
|
exports.analyticsEndpoint = require_getIntlayerAPI_analytics.analyticsEndpoint;
|
|
@@ -74,6 +76,7 @@ exports.gitlabEndpoint = require_getIntlayerAPI_gitlab.gitlabEndpoint;
|
|
|
74
76
|
exports.newsletterEndpoint = require_getIntlayerAPI_newsletter.newsletterEndpoint;
|
|
75
77
|
exports.organizationEndpoint = require_getIntlayerAPI_organization.organizationEndpoint;
|
|
76
78
|
exports.projectEndpoint = require_getIntlayerAPI_project.projectEndpoint;
|
|
79
|
+
exports.resolveInternalBackendUrl = require_resolveInternalBackendUrl.resolveInternalBackendUrl;
|
|
77
80
|
exports.reviewerEndpoint = require_getIntlayerAPI_reviewer.reviewerEndpoint;
|
|
78
81
|
exports.searchEndpoint = require_getIntlayerAPI_search.searchEndpoint;
|
|
79
82
|
exports.showcaseProjectEndpoint = require_getIntlayerAPI_showcaseProject.showcaseProjectEndpoint;
|
package/dist/cjs/proxy.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_getIntlayerAPI_oAuth = require('./getIntlayerAPI/oAuth.cjs');
|
|
3
3
|
const require_cms_createIntlayerCMS = require('./cms/createIntlayerCMS.cjs');
|
|
4
|
-
const require_getIntlayerAPI_dictionary = require('./getIntlayerAPI/dictionary.cjs');
|
|
5
4
|
const require_getIntlayerAPI_ai = require('./getIntlayerAPI/ai.cjs');
|
|
6
5
|
const require_getIntlayerAPI_analytics = require('./getIntlayerAPI/analytics.cjs');
|
|
7
6
|
const require_getIntlayerAPI_asset = require('./getIntlayerAPI/asset.cjs');
|
|
8
7
|
const require_getIntlayerAPI_audit = require('./getIntlayerAPI/audit.cjs');
|
|
9
8
|
const require_getIntlayerAPI_bitbucket = require('./getIntlayerAPI/bitbucket.cjs');
|
|
9
|
+
const require_getIntlayerAPI_dictionary = require('./getIntlayerAPI/dictionary.cjs');
|
|
10
10
|
const require_getIntlayerAPI_editor = require('./getIntlayerAPI/editor.cjs');
|
|
11
11
|
const require_getIntlayerAPI_environment = require('./getIntlayerAPI/environment.cjs');
|
|
12
12
|
const require_getIntlayerAPI_github = require('./getIntlayerAPI/github.cjs');
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _intlayer_config_built = require("@intlayer/config/built");
|
|
3
|
+
|
|
4
|
+
//#region src/resolveInternalBackendUrl.ts
|
|
5
|
+
/**
|
|
6
|
+
* Server-only override for the backend origin.
|
|
7
|
+
*
|
|
8
|
+
* The backend URL compiled into the bundle is the one the *browser* reaches
|
|
9
|
+
* (`http://localhost:3100`, `https://back.intlayer.org`). When the dashboard is
|
|
10
|
+
* server-rendered inside a private network — a Docker Compose stack, a
|
|
11
|
+
* Kubernetes pod — that origin is often not routable from the rendering
|
|
12
|
+
* process itself, while a service name such as `http://backend:3100` is.
|
|
13
|
+
*/
|
|
14
|
+
const BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE = "INTLAYER_BACKEND_INTERNAL_URL";
|
|
15
|
+
/**
|
|
16
|
+
* Reads the internal backend origin, if the current runtime declares one.
|
|
17
|
+
* Always `undefined` in the browser, where `process` does not exist.
|
|
18
|
+
*/
|
|
19
|
+
const getInternalBackendOrigin = () => typeof process === "undefined" ? void 0 : process.env?.["INTLAYER_BACKEND_INTERNAL_URL"]?.trim() || void 0;
|
|
20
|
+
/**
|
|
21
|
+
* Rewrites a request URL aimed at the public backend origin to the internal
|
|
22
|
+
* one, when `INTLAYER_BACKEND_INTERNAL_URL` is set on the server.
|
|
23
|
+
*
|
|
24
|
+
* Only requests to the configured backend origin are touched; any other host
|
|
25
|
+
* (a third-party API, an absolute asset URL) passes through unchanged.
|
|
26
|
+
*
|
|
27
|
+
* @param url - The absolute request URL.
|
|
28
|
+
* @param publicBackendUrl - The browser-facing backend URL the bundle was built
|
|
29
|
+
* with. Defaults to the compiled `editor.backendURL`.
|
|
30
|
+
* @returns The URL to fetch.
|
|
31
|
+
*/
|
|
32
|
+
const resolveInternalBackendUrl = (url, publicBackendUrl = _intlayer_config_built.editor.backendURL) => {
|
|
33
|
+
const internalOrigin = getInternalBackendOrigin();
|
|
34
|
+
if (!internalOrigin || !publicBackendUrl) return url;
|
|
35
|
+
try {
|
|
36
|
+
const target = new URL(url);
|
|
37
|
+
const publicOrigin = new URL(publicBackendUrl).origin;
|
|
38
|
+
if (target.origin !== publicOrigin) return url;
|
|
39
|
+
const internal = new URL(internalOrigin);
|
|
40
|
+
target.protocol = internal.protocol;
|
|
41
|
+
target.host = internal.host;
|
|
42
|
+
return target.toString();
|
|
43
|
+
} catch {
|
|
44
|
+
return url;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE = BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE;
|
|
50
|
+
exports.resolveInternalBackendUrl = resolveInternalBackendUrl;
|
|
51
|
+
//# sourceMappingURL=resolveInternalBackendUrl.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveInternalBackendUrl.cjs","names":["editor"],"sources":["../../src/resolveInternalBackendUrl.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\n\n/**\n * Server-only override for the backend origin.\n *\n * The backend URL compiled into the bundle is the one the *browser* reaches\n * (`http://localhost:3100`, `https://back.intlayer.org`). When the dashboard is\n * server-rendered inside a private network — a Docker Compose stack, a\n * Kubernetes pod — that origin is often not routable from the rendering\n * process itself, while a service name such as `http://backend:3100` is.\n */\nexport const BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE =\n 'INTLAYER_BACKEND_INTERNAL_URL';\n\n/**\n * Reads the internal backend origin, if the current runtime declares one.\n * Always `undefined` in the browser, where `process` does not exist.\n */\nconst getInternalBackendOrigin = (): string | undefined =>\n typeof process === 'undefined'\n ? undefined\n : process.env?.[BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE]?.trim() ||\n undefined;\n\n/**\n * Rewrites a request URL aimed at the public backend origin to the internal\n * one, when `INTLAYER_BACKEND_INTERNAL_URL` is set on the server.\n *\n * Only requests to the configured backend origin are touched; any other host\n * (a third-party API, an absolute asset URL) passes through unchanged.\n *\n * @param url - The absolute request URL.\n * @param publicBackendUrl - The browser-facing backend URL the bundle was built\n * with. Defaults to the compiled `editor.backendURL`.\n * @returns The URL to fetch.\n */\nexport const resolveInternalBackendUrl = (\n url: string,\n publicBackendUrl: string | undefined = editor.backendURL\n): string => {\n const internalOrigin = getInternalBackendOrigin();\n\n if (!internalOrigin || !publicBackendUrl) return url;\n\n try {\n const target = new URL(url);\n const publicOrigin = new URL(publicBackendUrl).origin;\n\n if (target.origin !== publicOrigin) return url;\n\n const internal = new URL(internalOrigin);\n\n target.protocol = internal.protocol;\n target.host = internal.host;\n\n return target.toString();\n } catch {\n return url;\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,4CACX;;;;;AAMF,MAAM,iCACJ,OAAO,YAAY,cACf,SACA,QAAQ,sCAAgD,EAAE,KAAK,KAC/D;;;;;;;;;;;;;AAcN,MAAa,6BACX,KACA,mBAAuCA,8BAAO,eACnC;CACX,MAAM,iBAAiB,yBAAyB;CAEhD,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,OAAO;CAEjD,IAAI;EACF,MAAM,SAAS,IAAI,IAAI,GAAG;EAC1B,MAAM,eAAe,IAAI,IAAI,gBAAgB,CAAC,CAAC;EAE/C,IAAI,OAAO,WAAW,cAAc,OAAO;EAE3C,MAAM,WAAW,IAAI,IAAI,cAAc;EAEvC,OAAO,WAAW,SAAS;EAC3B,OAAO,OAAO,SAAS;EAEvB,OAAO,OAAO,SAAS;CACzB,QAAQ;EACN,OAAO;CACT;AACF"}
|
package/dist/esm/fetcher.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveInternalBackendUrl } from "./resolveInternalBackendUrl.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/fetcher.ts
|
|
2
4
|
/**
|
|
3
5
|
* Error thrown when the backend answers with a non-ok response.
|
|
@@ -129,7 +131,7 @@ const fetcher = async (url, ...options) => {
|
|
|
129
131
|
body: bodyString,
|
|
130
132
|
signal
|
|
131
133
|
};
|
|
132
|
-
const urlResult = `${url}${paramsString}
|
|
134
|
+
const urlResult = resolveInternalBackendUrl(`${url}${paramsString}`);
|
|
133
135
|
const response = await fetch(urlResult, formattedOptions);
|
|
134
136
|
if (!response.ok) {
|
|
135
137
|
const result = await response.json().catch(() => void 0);
|
package/dist/esm/fetcher.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetcher.mjs","names":[],"sources":["../../src/fetcher.ts"],"sourcesContent":["/**\n * Error thrown when the backend answers with a non-ok response.\n *\n * Carries the HTTP status and the backend error code alongside the message, so\n * callers can tell a transient failure (5xx, network) from a deterministic one\n * (4xx) instead of blindly retrying.\n */\nexport class FetcherError extends Error {\n /** HTTP status code of the response. */\n public readonly status: number;\n /** Error code returned by the backend, when available (ex: `DICTIONARY_NOT_FOUND`). */\n public readonly code?: string;\n /** Raw error payload returned by the backend. */\n public readonly data?: unknown;\n\n constructor(\n message: string,\n details: { status: number; code?: string; data?: unknown }\n ) {\n super(message);\n\n this.name = 'FetcherError';\n this.status = details.status;\n this.code = details.code;\n this.data = details.data;\n }\n}\n\n/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include',\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n const { signal } = new AbortController();\n\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n signal,\n };\n\n // Construct the full URL with query parameters\n const urlResult = `${url}${paramsString}
|
|
1
|
+
{"version":3,"file":"fetcher.mjs","names":[],"sources":["../../src/fetcher.ts"],"sourcesContent":["import { resolveInternalBackendUrl } from './resolveInternalBackendUrl';\n\n/**\n * Error thrown when the backend answers with a non-ok response.\n *\n * Carries the HTTP status and the backend error code alongside the message, so\n * callers can tell a transient failure (5xx, network) from a deterministic one\n * (4xx) instead of blindly retrying.\n */\nexport class FetcherError extends Error {\n /** HTTP status code of the response. */\n public readonly status: number;\n /** Error code returned by the backend, when available (ex: `DICTIONARY_NOT_FOUND`). */\n public readonly code?: string;\n /** Raw error payload returned by the backend. */\n public readonly data?: unknown;\n\n constructor(\n message: string,\n details: { status: number; code?: string; data?: unknown }\n ) {\n super(message);\n\n this.name = 'FetcherError';\n this.status = details.status;\n this.code = details.code;\n this.data = details.data;\n }\n}\n\n/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include',\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n const { signal } = new AbortController();\n\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n signal,\n };\n\n // Construct the full URL with query parameters. Server code inside a private\n // network may need to reach the backend under another origin — see\n // `resolveInternalBackendUrl`.\n const urlResult = resolveInternalBackendUrl(`${url}${paramsString}`);\n\n // Make the HTTP request using fetch\n const response = await fetch(urlResult, formattedOptions);\n\n if (!response.ok) {\n const result = await response.json().catch(() => undefined);\n\n // You can customize the error message or include more details\n throw new FetcherError(\n JSON.stringify(result?.error) ?? 'An error occurred',\n {\n status: response.status,\n code: result?.error?.code,\n data: result?.error,\n }\n );\n }\n return await response.json();\n};\n"],"mappings":";;;;;;;;;;AASA,IAAa,eAAb,cAAkC,MAAM;;CAEtC,AAAgB;;CAEhB,AAAgB;;CAEhB,AAAgB;CAEhB,YACE,SACA,SACA;EACA,MAAM,OAAO;EAEb,KAAK,OAAO;EACZ,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO,QAAQ;CACtB;AACF;;;;;;AA0BA,MAAa,iBAAiC;CAC5C,QAAQ;CACR,SAAS,EACP,gBAAgB,mBAClB;CACA,aAAa;AACf;;;;;;;;AASA,MAAM,mBAAmB,QAAgB;CACvC,OAAO,KAAK,GAAG,CAAC,CAAC,SAAS,QAAQ;EAChC,IAAI,IAAI,SAA6B,QACnC,OAAO,IAAI;CAEf,CAAC;CACD,OAAO;AACT;;;;;;;;;AAUA,MAAM,aAA+B,YACnC,QAAQ,QAAQ,KAAK,QAAQ;CAC3B,MAAM,OAAW,OAAO,CAAC;CACzB,MAAM,OAAU,gBAAgB,OAAO,CAAC,CAAC;CAEzC,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAE9C,OAAO;EAAE,GAAG;EAAM,GAAG;CAAK;CAI5B,OAAO,QAAQ;AACjB,GAAG,CAAC,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDZ,MAAa,UAAU,OACrB,KACA,GAAG,YACY;CACf,MAAM,EAAE,WAAW,IAAI,gBAAgB;CAGvC,IAAI,eAAe;CACnB,IAAI;CAGJ,MAAM,eAAe,QAAQ,KAC1B,EAAE,MAAM,QAAQ,SAAS,GAAG,mBAAmB,YAClD;CAGA,MAAM,gBAAgB,UAAU,CAAC,gBAAgB,GAAG,YAAY,CAAC;CAGjE,MAAM,gBAAgB,UAAU,CAC9B,eAAe,SACf,GAAG,QAAQ,KAAK,WAAW,OAAO,OAAO,CAC3C,CAAC;CAGD,MAAM,SAAS,UAAU,QAAQ,KAAK,WAAW,OAAO,MAAM,CAAC;CAE/D,MAAM,SAAS,cAAc;CAG7B,IAAI,WAAW,SAAS,WAAW,QAAQ;EAEzC,MAAM,OAAO,UAAU,QAAQ,KAAK,WAAW,OAAO,IAAI,CAAC;EAC3D,IACE,gBAAgB,oBAChB,qCAGA,aAAa,IAAI,gBACf,IACF,CAAC,CAAC,SAAS;OAGX,aAAa,KAAK,UAAU,IAAI;CAEpC;CAGA,IAAI,OAAO,QAAQ,MAAM,CAAC,CAAC,SAAS,GAClC,eAAe,IAAI,IAAI,gBACrB,MACF,CAAC,CAAC,SAAS;CAIb,MAAM,mBAAgC;EACpC,GAAG;EACH,SAAS;EACT,MAAM;EACN;CACF;CAKA,MAAM,YAAY,0BAA0B,GAAG,MAAM,cAAc;CAGnE,MAAM,WAAW,MAAM,MAAM,WAAW,gBAAgB;CAExD,IAAI,CAAC,SAAS,IAAI;EAChB,MAAM,SAAS,MAAM,SAAS,KAAK,CAAC,CAAC,YAAY,MAAS;EAG1D,MAAM,IAAI,aACR,KAAK,UAAU,QAAQ,KAAK,KAAK,qBACjC;GACE,QAAQ,SAAS;GACjB,MAAM,QAAQ,OAAO;GACrB,MAAM,QAAQ;EAChB,CACF;CACF;CACA,OAAO,MAAM,SAAS,KAAK;AAC7B"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getOAuthAPI } from "./oAuth.mjs";
|
|
2
|
-
import { getDictionaryAPI } from "./dictionary.mjs";
|
|
3
2
|
import { getAiAPI } from "./ai.mjs";
|
|
4
3
|
import { getAnalyticsAPI } from "./analytics.mjs";
|
|
5
4
|
import { getAssetAPI } from "./asset.mjs";
|
|
6
5
|
import { getAuditAPI } from "./audit.mjs";
|
|
7
6
|
import { getBitbucketAPI } from "./bitbucket.mjs";
|
|
7
|
+
import { getDictionaryAPI } from "./dictionary.mjs";
|
|
8
8
|
import { getEditorAPI } from "./editor.mjs";
|
|
9
9
|
import { getEnvironmentAPI } from "./environment.mjs";
|
|
10
10
|
import { getGithubAPI } from "./github.mjs";
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import { BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE, resolveInternalBackendUrl } from "./resolveInternalBackendUrl.mjs";
|
|
1
2
|
import { FetcherError, fetcher, fetcherOptions } from "./fetcher.mjs";
|
|
2
3
|
import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
|
|
3
4
|
import { createAuthManager } from "./cms/createAuthManager.mjs";
|
|
4
5
|
import { createEndpoint, createIntlayerCMS } from "./cms/createIntlayerCMS.mjs";
|
|
5
|
-
import { dictionaryEndpoint, getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
|
|
6
|
-
import { fetchDistantDictionaries } from "./distantDictionary/fetchDistantDictionaries.mjs";
|
|
7
|
-
import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.mjs";
|
|
8
6
|
import { aiEndpoint, getAiAPI } from "./getIntlayerAPI/ai.mjs";
|
|
9
7
|
import { analyticsEndpoint, getAnalyticsAPI } from "./getIntlayerAPI/analytics.mjs";
|
|
10
8
|
import { assetEndpoint, getAssetAPI } from "./getIntlayerAPI/asset.mjs";
|
|
11
9
|
import { auditEndpoint, getAuditAPI } from "./getIntlayerAPI/audit.mjs";
|
|
12
10
|
import { bitbucketEndpoint, getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
|
|
11
|
+
import { dictionaryEndpoint, getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
|
|
13
12
|
import { editorEndpoint, getEditorAPI } from "./getIntlayerAPI/editor.mjs";
|
|
14
13
|
import { environmentEndpoint, getEnvironmentAPI } from "./getIntlayerAPI/environment.mjs";
|
|
15
14
|
import { getGithubAPI, githubEndpoint } from "./getIntlayerAPI/github.mjs";
|
|
@@ -25,7 +24,9 @@ import { getStripeAPI, stripeEndpoint } from "./getIntlayerAPI/stripe.mjs";
|
|
|
25
24
|
import { getTagAPI, tagEndpoint } from "./getIntlayerAPI/tag.mjs";
|
|
26
25
|
import { getTranslateAPI, translateEndpoint } from "./getIntlayerAPI/translate.mjs";
|
|
27
26
|
import { getUserAPI, userEndpoint } from "./getIntlayerAPI/user.mjs";
|
|
28
|
-
import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
|
|
29
27
|
import { getIntlayerAPIProxy } from "./proxy.mjs";
|
|
28
|
+
import { fetchDistantDictionaries } from "./distantDictionary/fetchDistantDictionaries.mjs";
|
|
29
|
+
import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.mjs";
|
|
30
|
+
import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
|
|
30
31
|
|
|
31
|
-
export { FetcherError, aiEndpoint, analyticsEndpoint, assetEndpoint, auditEndpoint, bitbucketEndpoint, createAuthManager, createEndpoint, createIntlayerCMS, dictionaryEndpoint, editorEndpoint, environmentEndpoint, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAnalyticsAPI, getAssetAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getEnvironmentAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getReviewerAPI, getSearchAPI, getShowcaseProjectAPI, getStatusAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI, githubEndpoint, gitlabEndpoint, newsletterEndpoint, organizationEndpoint, projectEndpoint, reviewerEndpoint, searchEndpoint, showcaseProjectEndpoint, statusEndpoint, stripeEndpoint, tagEndpoint, translateEndpoint, userEndpoint };
|
|
32
|
+
export { BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE, FetcherError, aiEndpoint, analyticsEndpoint, assetEndpoint, auditEndpoint, bitbucketEndpoint, createAuthManager, createEndpoint, createIntlayerCMS, dictionaryEndpoint, editorEndpoint, environmentEndpoint, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAnalyticsAPI, getAssetAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getEnvironmentAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getReviewerAPI, getSearchAPI, getShowcaseProjectAPI, getStatusAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI, githubEndpoint, gitlabEndpoint, newsletterEndpoint, organizationEndpoint, projectEndpoint, resolveInternalBackendUrl, reviewerEndpoint, searchEndpoint, showcaseProjectEndpoint, statusEndpoint, stripeEndpoint, tagEndpoint, translateEndpoint, userEndpoint };
|
package/dist/esm/proxy.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
|
|
2
2
|
import { createIntlayerCMS } from "./cms/createIntlayerCMS.mjs";
|
|
3
|
-
import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
|
|
4
3
|
import { getAiAPI } from "./getIntlayerAPI/ai.mjs";
|
|
5
4
|
import { getAnalyticsAPI } from "./getIntlayerAPI/analytics.mjs";
|
|
6
5
|
import { getAssetAPI } from "./getIntlayerAPI/asset.mjs";
|
|
7
6
|
import { getAuditAPI } from "./getIntlayerAPI/audit.mjs";
|
|
8
7
|
import { getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
|
|
8
|
+
import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
|
|
9
9
|
import { getEditorAPI } from "./getIntlayerAPI/editor.mjs";
|
|
10
10
|
import { getEnvironmentAPI } from "./getIntlayerAPI/environment.mjs";
|
|
11
11
|
import { getGithubAPI } from "./getIntlayerAPI/github.mjs";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { editor } from "@intlayer/config/built";
|
|
2
|
+
|
|
3
|
+
//#region src/resolveInternalBackendUrl.ts
|
|
4
|
+
/**
|
|
5
|
+
* Server-only override for the backend origin.
|
|
6
|
+
*
|
|
7
|
+
* The backend URL compiled into the bundle is the one the *browser* reaches
|
|
8
|
+
* (`http://localhost:3100`, `https://back.intlayer.org`). When the dashboard is
|
|
9
|
+
* server-rendered inside a private network — a Docker Compose stack, a
|
|
10
|
+
* Kubernetes pod — that origin is often not routable from the rendering
|
|
11
|
+
* process itself, while a service name such as `http://backend:3100` is.
|
|
12
|
+
*/
|
|
13
|
+
const BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE = "INTLAYER_BACKEND_INTERNAL_URL";
|
|
14
|
+
/**
|
|
15
|
+
* Reads the internal backend origin, if the current runtime declares one.
|
|
16
|
+
* Always `undefined` in the browser, where `process` does not exist.
|
|
17
|
+
*/
|
|
18
|
+
const getInternalBackendOrigin = () => typeof process === "undefined" ? void 0 : process.env?.["INTLAYER_BACKEND_INTERNAL_URL"]?.trim() || void 0;
|
|
19
|
+
/**
|
|
20
|
+
* Rewrites a request URL aimed at the public backend origin to the internal
|
|
21
|
+
* one, when `INTLAYER_BACKEND_INTERNAL_URL` is set on the server.
|
|
22
|
+
*
|
|
23
|
+
* Only requests to the configured backend origin are touched; any other host
|
|
24
|
+
* (a third-party API, an absolute asset URL) passes through unchanged.
|
|
25
|
+
*
|
|
26
|
+
* @param url - The absolute request URL.
|
|
27
|
+
* @param publicBackendUrl - The browser-facing backend URL the bundle was built
|
|
28
|
+
* with. Defaults to the compiled `editor.backendURL`.
|
|
29
|
+
* @returns The URL to fetch.
|
|
30
|
+
*/
|
|
31
|
+
const resolveInternalBackendUrl = (url, publicBackendUrl = editor.backendURL) => {
|
|
32
|
+
const internalOrigin = getInternalBackendOrigin();
|
|
33
|
+
if (!internalOrigin || !publicBackendUrl) return url;
|
|
34
|
+
try {
|
|
35
|
+
const target = new URL(url);
|
|
36
|
+
const publicOrigin = new URL(publicBackendUrl).origin;
|
|
37
|
+
if (target.origin !== publicOrigin) return url;
|
|
38
|
+
const internal = new URL(internalOrigin);
|
|
39
|
+
target.protocol = internal.protocol;
|
|
40
|
+
target.host = internal.host;
|
|
41
|
+
return target.toString();
|
|
42
|
+
} catch {
|
|
43
|
+
return url;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE, resolveInternalBackendUrl };
|
|
49
|
+
//# sourceMappingURL=resolveInternalBackendUrl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveInternalBackendUrl.mjs","names":[],"sources":["../../src/resolveInternalBackendUrl.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\n\n/**\n * Server-only override for the backend origin.\n *\n * The backend URL compiled into the bundle is the one the *browser* reaches\n * (`http://localhost:3100`, `https://back.intlayer.org`). When the dashboard is\n * server-rendered inside a private network — a Docker Compose stack, a\n * Kubernetes pod — that origin is often not routable from the rendering\n * process itself, while a service name such as `http://backend:3100` is.\n */\nexport const BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE =\n 'INTLAYER_BACKEND_INTERNAL_URL';\n\n/**\n * Reads the internal backend origin, if the current runtime declares one.\n * Always `undefined` in the browser, where `process` does not exist.\n */\nconst getInternalBackendOrigin = (): string | undefined =>\n typeof process === 'undefined'\n ? undefined\n : process.env?.[BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE]?.trim() ||\n undefined;\n\n/**\n * Rewrites a request URL aimed at the public backend origin to the internal\n * one, when `INTLAYER_BACKEND_INTERNAL_URL` is set on the server.\n *\n * Only requests to the configured backend origin are touched; any other host\n * (a third-party API, an absolute asset URL) passes through unchanged.\n *\n * @param url - The absolute request URL.\n * @param publicBackendUrl - The browser-facing backend URL the bundle was built\n * with. Defaults to the compiled `editor.backendURL`.\n * @returns The URL to fetch.\n */\nexport const resolveInternalBackendUrl = (\n url: string,\n publicBackendUrl: string | undefined = editor.backendURL\n): string => {\n const internalOrigin = getInternalBackendOrigin();\n\n if (!internalOrigin || !publicBackendUrl) return url;\n\n try {\n const target = new URL(url);\n const publicOrigin = new URL(publicBackendUrl).origin;\n\n if (target.origin !== publicOrigin) return url;\n\n const internal = new URL(internalOrigin);\n\n target.protocol = internal.protocol;\n target.host = internal.host;\n\n return target.toString();\n } catch {\n return url;\n }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,4CACX;;;;;AAMF,MAAM,iCACJ,OAAO,YAAY,cACf,SACA,QAAQ,sCAAgD,EAAE,KAAK,KAC/D;;;;;;;;;;;;;AAcN,MAAa,6BACX,KACA,mBAAuC,OAAO,eACnC;CACX,MAAM,iBAAiB,yBAAyB;CAEhD,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,OAAO;CAEjD,IAAI;EACF,MAAM,SAAS,IAAI,IAAI,GAAG;EAC1B,MAAM,eAAe,IAAI,IAAI,gBAAgB,CAAC,CAAC;EAE/C,IAAI,OAAO,WAAW,cAAc,OAAO;EAE3C,MAAM,WAAW,IAAI,IAAI,cAAc;EAEvC,OAAO,WAAW,SAAS;EAC3B,OAAO,OAAO,SAAS;EAEvB,OAAO,OAAO,SAAS;CACzB,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetcher.d.ts","names":[],"sources":["../../src/fetcher.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"fetcher.d.ts","names":[],"sources":["../../src/fetcher.ts"],"mappings":";;;;;;;;qBASa,qBAAqB;;WAEhB;;WAEA;;WAEA;EAEhB,YACE,iBACA;IAAW;IAAgB;IAAe;;;;;;;;YAgBlC,iBAAiB,KAAK;;;;EAIhC,OAAO;;;;EAIP,SACI,2DAEA;;;;;;;qBAQO,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA6FhB,UAAiB,GAAC,gBAClB,SACC,qBACX,QAAQ"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { TranslateDictionariesBody, TranslateDictionariesResult, getTranslateAPI
|
|
|
28
28
|
import { getUserAPI, userEndpoint } from "./getIntlayerAPI/user.js";
|
|
29
29
|
import { IntlayerAPI, getIntlayerAPI } from "./getIntlayerAPI/index.js";
|
|
30
30
|
import { IntlayerAPIProxy, getIntlayerAPIProxy } from "./proxy.js";
|
|
31
|
+
import { BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE, resolveInternalBackendUrl } from "./resolveInternalBackendUrl.js";
|
|
31
32
|
import { AIOptions } from "./types.js";
|
|
32
33
|
import { AskDocQuestionBody, AskDocQuestionResult, AutocompleteBody, ChatBody, ChatResult, ClientAction, aiEndpoint, getAiAPI } from "./getIntlayerAPI/ai.js";
|
|
33
|
-
export { type AIOptions, AskDocQuestionBody, type AskDocQuestionResult, type AuditEvent, AuthManager, AuthManagerOptions, AutocompleteBody, BindSectionOptions, BitbucketAuthCallbackBody, BitbucketAuthCallbackResult, BitbucketCheckConfigBody, BitbucketCheckConfigResult, BitbucketGetAuthUrlResult, BitbucketGetConfigFileBody, BitbucketGetConfigFileResult, BitbucketListReposResult, BitbucketRepository, CMSEndpoint, ChatBody, type ChatResult, ClientAction, DiscoverUrlsParams, DiscoverUrlsResult, FetcherError, FetcherOptions, GetDemoSessionResult, GetRecursiveAuditStatusParams, type GetRecursiveAuditStatusResult, GitHubAuthCallbackBody, GitHubAuthCallbackResult, GitHubCheckConfigBody, GitHubCheckConfigResult, GitHubGetAuthUrlResult, GitHubGetConfigFileBody, GitHubGetConfigFileResult, GitHubGetTokenResult, GitHubListReposResult, GitHubRepository, GitLabAuthCallbackBody, GitLabAuthCallbackResult, GitLabCheckConfigBody, GitLabCheckConfigResult, GitLabGetAuthUrlResult, GitLabGetConfigFileBody, GitLabGetConfigFileResult, GitLabListProjectsResult, GitLabProject, IntlayerAPI, IntlayerAPIProxy, IntlayerCMS, IntlayerCMSOptions, OtherShowcaseProjectsQuery, RecursiveAuditJobParams, ScanUrlBody, ShowcaseProjectsQuery, StartRecursiveAuditBody, type StartRecursiveAuditResult, type TranslateDictionariesBody, type TranslateDictionariesResult, aiEndpoint, analyticsEndpoint, assetEndpoint, auditEndpoint, bitbucketEndpoint, createAuthManager, createEndpoint, createIntlayerCMS, dictionaryEndpoint, editorEndpoint, environmentEndpoint, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAnalyticsAPI, getAssetAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getEnvironmentAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getReviewerAPI, getSearchAPI, getShowcaseProjectAPI, getStatusAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI, githubEndpoint, gitlabEndpoint, newsletterEndpoint, organizationEndpoint, projectEndpoint, reviewerEndpoint, searchEndpoint, showcaseProjectEndpoint, statusEndpoint, stripeEndpoint, tagEndpoint, translateEndpoint, userEndpoint };
|
|
34
|
+
export { type AIOptions, AskDocQuestionBody, type AskDocQuestionResult, type AuditEvent, AuthManager, AuthManagerOptions, AutocompleteBody, BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE, BindSectionOptions, BitbucketAuthCallbackBody, BitbucketAuthCallbackResult, BitbucketCheckConfigBody, BitbucketCheckConfigResult, BitbucketGetAuthUrlResult, BitbucketGetConfigFileBody, BitbucketGetConfigFileResult, BitbucketListReposResult, BitbucketRepository, CMSEndpoint, ChatBody, type ChatResult, ClientAction, DiscoverUrlsParams, DiscoverUrlsResult, FetcherError, FetcherOptions, GetDemoSessionResult, GetRecursiveAuditStatusParams, type GetRecursiveAuditStatusResult, GitHubAuthCallbackBody, GitHubAuthCallbackResult, GitHubCheckConfigBody, GitHubCheckConfigResult, GitHubGetAuthUrlResult, GitHubGetConfigFileBody, GitHubGetConfigFileResult, GitHubGetTokenResult, GitHubListReposResult, GitHubRepository, GitLabAuthCallbackBody, GitLabAuthCallbackResult, GitLabCheckConfigBody, GitLabCheckConfigResult, GitLabGetAuthUrlResult, GitLabGetConfigFileBody, GitLabGetConfigFileResult, GitLabListProjectsResult, GitLabProject, IntlayerAPI, IntlayerAPIProxy, IntlayerCMS, IntlayerCMSOptions, OtherShowcaseProjectsQuery, RecursiveAuditJobParams, ScanUrlBody, ShowcaseProjectsQuery, StartRecursiveAuditBody, type StartRecursiveAuditResult, type TranslateDictionariesBody, type TranslateDictionariesResult, aiEndpoint, analyticsEndpoint, assetEndpoint, auditEndpoint, bitbucketEndpoint, createAuthManager, createEndpoint, createIntlayerCMS, dictionaryEndpoint, editorEndpoint, environmentEndpoint, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAnalyticsAPI, getAssetAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getEnvironmentAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getReviewerAPI, getSearchAPI, getShowcaseProjectAPI, getStatusAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI, githubEndpoint, gitlabEndpoint, newsletterEndpoint, organizationEndpoint, projectEndpoint, resolveInternalBackendUrl, reviewerEndpoint, searchEndpoint, showcaseProjectEndpoint, statusEndpoint, stripeEndpoint, tagEndpoint, translateEndpoint, userEndpoint };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/resolveInternalBackendUrl.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Server-only override for the backend origin.
|
|
4
|
+
*
|
|
5
|
+
* The backend URL compiled into the bundle is the one the *browser* reaches
|
|
6
|
+
* (`http://localhost:3100`, `https://back.intlayer.org`). When the dashboard is
|
|
7
|
+
* server-rendered inside a private network — a Docker Compose stack, a
|
|
8
|
+
* Kubernetes pod — that origin is often not routable from the rendering
|
|
9
|
+
* process itself, while a service name such as `http://backend:3100` is.
|
|
10
|
+
*/
|
|
11
|
+
export declare const BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE = "INTLAYER_BACKEND_INTERNAL_URL";
|
|
12
|
+
/**
|
|
13
|
+
* Rewrites a request URL aimed at the public backend origin to the internal
|
|
14
|
+
* one, when `INTLAYER_BACKEND_INTERNAL_URL` is set on the server.
|
|
15
|
+
*
|
|
16
|
+
* Only requests to the configured backend origin are touched; any other host
|
|
17
|
+
* (a third-party API, an absolute asset URL) passes through unchanged.
|
|
18
|
+
*
|
|
19
|
+
* @param url - The absolute request URL.
|
|
20
|
+
* @param publicBackendUrl - The browser-facing backend URL the bundle was built
|
|
21
|
+
* with. Defaults to the compiled `editor.backendURL`.
|
|
22
|
+
* @returns The URL to fetch.
|
|
23
|
+
*/
|
|
24
|
+
export declare const resolveInternalBackendUrl: (url: string, publicBackendUrl?: string | undefined) => string;
|
|
25
|
+
//#endregion
|
|
26
|
+
//# sourceMappingURL=resolveInternalBackendUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveInternalBackendUrl.d.ts","names":[],"sources":["../../src/resolveInternalBackendUrl.ts"],"mappings":";;;;;;;;;;qBAWa;;;;;;;;;;;;;qBAyBA,4BAAyB,aACzB"}
|
package/package.json
CHANGED