@intlayer/api 8.7.6-canary.0 → 8.7.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.
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.cjs","names":["getIntlayerAPIProxy"],"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getIntlayerAPIProxy } from '../proxy';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI[] | null | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary list\n const getDictionaryResult = await api.dictionary.getDictionaries();\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;;AAOA,MAAa,2BAA2B,OACtC,mBACgD;AAChD,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;AAUH,UAJ4B,MAHhBA,kCAAoB,QAAW,eAAe,CAGpB,WAAW,iBAAiB,EAElB;UAGzC,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
1
+ {"version":3,"file":"fetchDistantDictionaries.cjs","names":["getIntlayerAPIProxy"],"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getIntlayerAPIProxy } from '../proxy';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI[] | null | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary list\n const getDictionaryResult = await api.dictionary.getDictionaries();\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;;AAOA,MAAa,2BAA2B,OACtC,mBACgD;AAChD,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;AAUH,UAF4B,MALhBA,kCAAoB,QAAW,eAGN,CAAC,WAAW,iBAAiB,EAElB;UAGzC,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionary.cjs","names":["getIntlayerAPIProxy"],"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getIntlayerAPIProxy } from '../proxy';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary\n const getDictionaryResult =\n await api.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n return distantDictionary;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;;AAOA,MAAa,yBAAyB,OACpC,eACA,mBACuC;AACvC,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;EASH,MAAM,qBAFJ,MAJUA,kCAAoB,QAAW,eAAe,CAI9C,WAAW,cAAc,cAAc,EAEL;AAE9C,MAAI,CAAC,kBACH,OAAM,IAAI,MAAM,cAAc,cAAc,sBAAsB;AAGpE,SAAO;UACA,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
1
+ {"version":3,"file":"fetchDistantDictionary.cjs","names":["getIntlayerAPIProxy"],"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getIntlayerAPIProxy } from '../proxy';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary\n const getDictionaryResult =\n await api.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n return distantDictionary;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;;AAOA,MAAa,yBAAyB,OACpC,eACA,mBACuC;AACvC,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;EASH,MAAM,qBAAoB,MANdA,kCAAoB,QAAW,eAIhC,CAAC,WAAW,cAAc,cAAc,EAEL;AAE9C,MAAI,CAAC,kBACH,OAAM,IAAI,MAAM,cAAc,cAAc,sBAAsB;AAGpE,SAAO;UACA,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.cjs","names":[],"sources":["../../src/fetcher.ts"],"sourcesContent":["/**\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}`;\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();\n\n // You can customize the error message or include more details\n throw new Error(JSON.stringify(result.error) ?? 'An error occurred');\n }\n return await response.json();\n};\n"],"mappings":";;;;;;;;AAwBA,MAAa,iBAAiC;CAC5C,QAAQ;CACR,SAAS,EACP,gBAAgB,oBACjB;CACD,aAAa;CACd;;;;;;;;AASD,MAAM,mBAAmB,QAAgB;AACvC,QAAO,KAAK,IAAI,CAAC,SAAS,QAAQ;AAChC,MAAI,IAAI,SAA6B,OACnC,QAAO,IAAI;GAEb;AACF,QAAO;;;;;;;;;;AAWT,MAAM,aAA+B,YACnC,QAAQ,QAAQ,KAAK,QAAQ;CAC3B,MAAM,OAAW,OAAO,EAAE;CAC1B,MAAM,OAAU,gBAAgB,OAAO,EAAE,CAAC;AAE1C,KAAI,OAAO,SAAS,YAAY,OAAO,SAAS,SAE9C,QAAO;EAAE,GAAG;EAAM,GAAG;EAAM;AAI7B,QAAO,QAAQ;GACd,EAAE,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDb,MAAa,UAAU,OACrB,KACA,GAAG,YACY;CACf,MAAM,EAAE,WAAW,IAAI,iBAAiB;CAGxC,IAAI,eAAe;CACnB,IAAI;CAQJ,MAAM,gBAAgB,UAAU,CAAC,gBAAgB,GAL5B,QAAQ,KAC1B,EAAE,MAAM,QAAQ,SAAS,GAAG,mBAAmB,aACjD,CAGgE,CAAC;CAGlE,MAAM,gBAAgB,UAAU,CAC9B,eAAe,SACf,GAAG,QAAQ,KAAK,WAAW,OAAO,QAAQ,CAC3C,CAAC;CAGF,MAAM,SAAS,UAAU,QAAQ,KAAK,WAAW,OAAO,OAAO,CAAC;CAEhE,MAAM,SAAS,cAAc;AAG7B,KAAI,WAAW,SAAS,WAAW,QAAQ;EAEzC,MAAM,OAAO,UAAU,QAAQ,KAAK,WAAW,OAAO,KAAK,CAAC;AAC5D,MACE,gBAAgB,oBAChB,oCAGA,cAAa,IAAI,gBACf,KACD,CAAC,UAAU;MAGZ,cAAa,KAAK,UAAU,KAAK;;AAKrC,KAAI,OAAO,QAAQ,OAAO,CAAC,SAAS,EAClC,gBAAe,IAAI,IAAI,gBACrB,OACD,CAAC,UAAU;CAId,MAAM,mBAAgC;EACpC,GAAG;EACH,SAAS;EACT,MAAM;EACN;EACD;CAGD,MAAM,YAAY,GAAG,MAAM;CAG3B,MAAM,WAAW,MAAM,MAAM,WAAW,iBAAiB;AAEzD,KAAI,CAAC,SAAS,IAAI;EAChB,MAAM,SAAS,MAAM,SAAS,MAAM;AAGpC,QAAM,IAAI,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,oBAAoB;;AAEtE,QAAO,MAAM,SAAS,MAAM"}
1
+ {"version":3,"file":"fetcher.cjs","names":[],"sources":["../../src/fetcher.ts"],"sourcesContent":["/**\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}`;\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();\n\n // You can customize the error message or include more details\n throw new Error(JSON.stringify(result.error) ?? 'An error occurred');\n }\n return await response.json();\n};\n"],"mappings":";;;;;;;;AAwBA,MAAa,iBAAiC;CAC5C,QAAQ;CACR,SAAS,EACP,gBAAgB,oBACjB;CACD,aAAa;CACd;;;;;;;;AASD,MAAM,mBAAmB,QAAgB;AACvC,QAAO,KAAK,IAAI,CAAC,SAAS,QAAQ;AAChC,MAAI,IAAI,SAA6B,OACnC,QAAO,IAAI;GAEb;AACF,QAAO;;;;;;;;;;AAWT,MAAM,aAA+B,YACnC,QAAQ,QAAQ,KAAK,QAAQ;CAC3B,MAAM,OAAW,OAAO,EAAE;CAC1B,MAAM,OAAU,gBAAgB,OAAO,EAAE,CAAC;AAE1C,KAAI,OAAO,SAAS,YAAY,OAAO,SAAS,SAE9C,QAAO;EAAE,GAAG;EAAM,GAAG;EAAM;AAI7B,QAAO,QAAQ;GACd,EAAE,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDb,MAAa,UAAU,OACrB,KACA,GAAG,YACY;CACf,MAAM,EAAE,WAAW,IAAI,iBAAiB;CAGxC,IAAI,eAAe;CACnB,IAAI;CAQJ,MAAM,gBAAgB,UAAU,CAAC,gBAAgB,GAL5B,QAAQ,KAC1B,EAAE,MAAM,QAAQ,SAAS,GAAG,mBAAmB,aAIc,CAAC,CAAC;CAGlE,MAAM,gBAAgB,UAAU,CAC9B,eAAe,SACf,GAAG,QAAQ,KAAK,WAAW,OAAO,QAAQ,CAC3C,CAAC;CAGF,MAAM,SAAS,UAAU,QAAQ,KAAK,WAAW,OAAO,OAAO,CAAC;CAEhE,MAAM,SAAS,cAAc;AAG7B,KAAI,WAAW,SAAS,WAAW,QAAQ;EAEzC,MAAM,OAAO,UAAU,QAAQ,KAAK,WAAW,OAAO,KAAK,CAAC;AAC5D,MACE,gBAAgB,oBAChB,oCAGA,cAAa,IAAI,gBACf,KACD,CAAC,UAAU;MAGZ,cAAa,KAAK,UAAU,KAAK;;AAKrC,KAAI,OAAO,QAAQ,OAAO,CAAC,SAAS,EAClC,gBAAe,IAAI,IAAI,gBACrB,OACD,CAAC,UAAU;CAId,MAAM,mBAAgC;EACpC,GAAG;EACH,SAAS;EACT,MAAM;EACN;EACD;CAGD,MAAM,YAAY,GAAG,MAAM;CAG3B,MAAM,WAAW,MAAM,MAAM,WAAW,iBAAiB;AAEzD,KAAI,CAAC,SAAS,IAAI;EAChB,MAAM,SAAS,MAAM,SAAS,MAAM;AAGpC,QAAM,IAAI,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,oBAAoB;;AAEtE,QAAO,MAAM,SAAS,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"audit.cjs","names":["fetcher"],"sources":["../../../src/getIntlayerAPI/audit.ts"],"sourcesContent":["import type {\n AuditEvent,\n GetRecursiveAuditStatusResult,\n StartRecursiveAuditResult,\n} from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type {\n AuditEvent,\n GetRecursiveAuditStatusResult,\n StartRecursiveAuditResult,\n};\n\nexport type ScanUrlBody = {\n url: string;\n onMessage?: (event: AuditEvent) => void;\n onDone?: () => void;\n};\n\nexport type DiscoverUrlsParams = {\n url: string;\n};\n\nexport type DiscoverUrlsResult = {\n urls: string[];\n};\n\nexport type StartRecursiveAuditBody = {\n url: string;\n urls?: string[];\n};\n\nexport type GetRecursiveAuditStatusParams = {\n jobId: string;\n};\n\nexport type RecursiveAuditJobParams = {\n jobId: string;\n};\n\nexport const getAuditAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig: IntlayerConfig\n) => {\n const backendURL = intlayerConfig.editor.backendURL;\n\n const AUDIT_API_ROUTE = `${backendURL}/api/scan`;\n\n /**\n * Streams a single-page SEO audit as Server-Sent Events.\n *\n * Usage:\n * ```ts\n * await audit.scanUrl({\n * url: 'https://example.com',\n * onMessage: (event) => console.log(event),\n * onDone: () => console.log('done'),\n * });\n * ```\n */\n const discoverUrls = async (\n params?: DiscoverUrlsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DiscoverUrlsResult>(\n `${AUDIT_API_ROUTE}/recursive/discover`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n params,\n }\n );\n\n const scanUrl = async (\n body?: ScanUrlBody,\n otherOptions: FetcherOptions = {}\n ) => {\n if (!body?.url) return;\n\n const { url, onMessage, onDone } = body;\n\n const params = new URLSearchParams({ url });\n const endpoint = `${AUDIT_API_ROUTE}?${params.toString()}`;\n\n const response = await fetch(endpoint, {\n method: 'GET',\n headers: {\n Accept: 'text/event-stream',\n ...authAPIOptions.headers,\n ...otherOptions.headers,\n },\n credentials: 'include',\n signal: otherOptions.signal,\n });\n\n if (!response.ok) {\n let errorMessage = 'An error occurred';\n try {\n const errorData = await response.json();\n errorMessage = JSON.stringify(errorData.error) ?? errorMessage;\n } catch {\n try {\n const errorText = await response.text();\n if (errorText) errorMessage = errorText;\n } catch {\n // ignore\n }\n }\n throw new Error(errorMessage);\n }\n\n const reader = response.body?.getReader();\n if (!reader) throw new Error('No reader available');\n\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n try {\n const event = JSON.parse(line.slice(6)) as AuditEvent;\n onMessage?.(event);\n } catch {\n // ignore malformed lines\n }\n }\n }\n }\n\n onDone?.();\n };\n\n /**\n * Starts a recursive audit job for the given URL.\n */\n const startRecursiveAudit = async (\n body?: StartRecursiveAuditBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<StartRecursiveAuditResult>(\n `${AUDIT_API_ROUTE}/recursive/start`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n params: body?.url ? { url: body.url } : undefined,\n body: body?.urls !== undefined ? { urls: body.urls as any } : undefined,\n }\n );\n\n /**\n * Gets the status of a recursive audit job.\n */\n const getRecursiveAuditStatus = async (\n params?: GetRecursiveAuditStatusParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetRecursiveAuditStatusResult>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n const cancelRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/cancel`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const pauseRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/pause`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const resumeRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/resume`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n return {\n discoverUrls,\n scanUrl,\n startRecursiveAudit,\n getRecursiveAuditStatus,\n cancelRecursiveAudit,\n pauseRecursiveAudit,\n resumeRecursiveAudit,\n };\n};\n"],"mappings":";;;;AAyCA,MAAa,eACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,kBAAkB,GAFL,eAAe,OAAO,WAEH;;;;;;;;;;;;;CActC,MAAM,eAAe,OACnB,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,sBACnB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;CAEH,MAAM,UAAU,OACd,MACA,eAA+B,EAAE,KAC9B;AACH,MAAI,CAAC,MAAM,IAAK;EAEhB,MAAM,EAAE,KAAK,WAAW,WAAW;EAGnC,MAAM,WAAW,GAAG,gBAAgB,GADrB,IAAI,gBAAgB,EAAE,KAAK,CAAC,CACG,UAAU;EAExD,MAAM,WAAW,MAAM,MAAM,UAAU;GACrC,QAAQ;GACR,SAAS;IACP,QAAQ;IACR,GAAG,eAAe;IAClB,GAAG,aAAa;IACjB;GACD,aAAa;GACb,QAAQ,aAAa;GACtB,CAAC;AAEF,MAAI,CAAC,SAAS,IAAI;GAChB,IAAI,eAAe;AACnB,OAAI;IACF,MAAM,YAAY,MAAM,SAAS,MAAM;AACvC,mBAAe,KAAK,UAAU,UAAU,MAAM,IAAI;WAC5C;AACN,QAAI;KACF,MAAM,YAAY,MAAM,SAAS,MAAM;AACvC,SAAI,UAAW,gBAAe;YACxB;;AAIV,SAAM,IAAI,MAAM,aAAa;;EAG/B,MAAM,SAAS,SAAS,MAAM,WAAW;AACzC,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,sBAAsB;EAEnD,MAAM,UAAU,IAAI,aAAa;EACjC,IAAI,SAAS;AAEb,SAAO,MAAM;GACX,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,MAAM;AAE3C,OAAI,KAAM;AAEV,aAAU,QAAQ,OAAO,OAAO,EAAE,QAAQ,MAAM,CAAC;GACjD,MAAM,QAAQ,OAAO,MAAM,KAAK;AAChC,YAAS,MAAM,KAAK,IAAI;AAExB,QAAK,MAAM,QAAQ,MACjB,KAAI,KAAK,WAAW,SAAS,CAC3B,KAAI;IACF,MAAM,QAAQ,KAAK,MAAM,KAAK,MAAM,EAAE,CAAC;AACvC,gBAAY,MAAM;WACZ;;AAOd,YAAU;;;;;CAMZ,MAAM,sBAAsB,OAC1B,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,mBACnB,gBACA,cACA;EACE,QAAQ;EACR,QAAQ,MAAM,MAAM,EAAE,KAAK,KAAK,KAAK,GAAG;EACxC,MAAM,MAAM,SAAS,SAAY,EAAE,MAAM,KAAK,MAAa,GAAG;EAC/D,CACF;;;;CAKH,MAAM,0BAA0B,OAC9B,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,aAAa,QAAQ,SACxC,gBACA,cACA,EACE,QAAQ,OACT,CACF;CAEH,MAAM,uBAAuB,OAC3B,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,UAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,sBAAsB,OAC1B,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,SAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,uBAAuB,OAC3B,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,UAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"audit.cjs","names":["fetcher"],"sources":["../../../src/getIntlayerAPI/audit.ts"],"sourcesContent":["import type {\n AuditEvent,\n GetRecursiveAuditStatusResult,\n StartRecursiveAuditResult,\n} from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type {\n AuditEvent,\n GetRecursiveAuditStatusResult,\n StartRecursiveAuditResult,\n};\n\nexport type ScanUrlBody = {\n url: string;\n onMessage?: (event: AuditEvent) => void;\n onDone?: () => void;\n};\n\nexport type DiscoverUrlsParams = {\n url: string;\n};\n\nexport type DiscoverUrlsResult = {\n urls: string[];\n};\n\nexport type StartRecursiveAuditBody = {\n url: string;\n urls?: string[];\n};\n\nexport type GetRecursiveAuditStatusParams = {\n jobId: string;\n};\n\nexport type RecursiveAuditJobParams = {\n jobId: string;\n};\n\nexport const getAuditAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig: IntlayerConfig\n) => {\n const backendURL = intlayerConfig.editor.backendURL;\n\n const AUDIT_API_ROUTE = `${backendURL}/api/scan`;\n\n /**\n * Streams a single-page SEO audit as Server-Sent Events.\n *\n * Usage:\n * ```ts\n * await audit.scanUrl({\n * url: 'https://example.com',\n * onMessage: (event) => console.log(event),\n * onDone: () => console.log('done'),\n * });\n * ```\n */\n const discoverUrls = async (\n params?: DiscoverUrlsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DiscoverUrlsResult>(\n `${AUDIT_API_ROUTE}/recursive/discover`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n params,\n }\n );\n\n const scanUrl = async (\n body?: ScanUrlBody,\n otherOptions: FetcherOptions = {}\n ) => {\n if (!body?.url) return;\n\n const { url, onMessage, onDone } = body;\n\n const params = new URLSearchParams({ url });\n const endpoint = `${AUDIT_API_ROUTE}?${params.toString()}`;\n\n const response = await fetch(endpoint, {\n method: 'GET',\n headers: {\n Accept: 'text/event-stream',\n ...authAPIOptions.headers,\n ...otherOptions.headers,\n },\n credentials: 'include',\n signal: otherOptions.signal,\n });\n\n if (!response.ok) {\n let errorMessage = 'An error occurred';\n try {\n const errorData = await response.json();\n errorMessage = JSON.stringify(errorData.error) ?? errorMessage;\n } catch {\n try {\n const errorText = await response.text();\n if (errorText) errorMessage = errorText;\n } catch {\n // ignore\n }\n }\n throw new Error(errorMessage);\n }\n\n const reader = response.body?.getReader();\n if (!reader) throw new Error('No reader available');\n\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n try {\n const event = JSON.parse(line.slice(6)) as AuditEvent;\n onMessage?.(event);\n } catch {\n // ignore malformed lines\n }\n }\n }\n }\n\n onDone?.();\n };\n\n /**\n * Starts a recursive audit job for the given URL.\n */\n const startRecursiveAudit = async (\n body?: StartRecursiveAuditBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<StartRecursiveAuditResult>(\n `${AUDIT_API_ROUTE}/recursive/start`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n params: body?.url ? { url: body.url } : undefined,\n body: body?.urls !== undefined ? { urls: body.urls as any } : undefined,\n }\n );\n\n /**\n * Gets the status of a recursive audit job.\n */\n const getRecursiveAuditStatus = async (\n params?: GetRecursiveAuditStatusParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetRecursiveAuditStatusResult>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n const cancelRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/cancel`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const pauseRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/pause`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const resumeRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/resume`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n return {\n discoverUrls,\n scanUrl,\n startRecursiveAudit,\n getRecursiveAuditStatus,\n cancelRecursiveAudit,\n pauseRecursiveAudit,\n resumeRecursiveAudit,\n };\n};\n"],"mappings":";;;;AAyCA,MAAa,eACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,kBAAkB,GAFL,eAAe,OAAO,WAEH;;;;;;;;;;;;;CActC,MAAM,eAAe,OACnB,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,sBACnB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;CAEH,MAAM,UAAU,OACd,MACA,eAA+B,EAAE,KAC9B;AACH,MAAI,CAAC,MAAM,IAAK;EAEhB,MAAM,EAAE,KAAK,WAAW,WAAW;EAGnC,MAAM,WAAW,GAAG,gBAAgB,GAAG,IADpB,gBAAgB,EAAE,KAAK,CACG,CAAC,UAAU;EAExD,MAAM,WAAW,MAAM,MAAM,UAAU;GACrC,QAAQ;GACR,SAAS;IACP,QAAQ;IACR,GAAG,eAAe;IAClB,GAAG,aAAa;IACjB;GACD,aAAa;GACb,QAAQ,aAAa;GACtB,CAAC;AAEF,MAAI,CAAC,SAAS,IAAI;GAChB,IAAI,eAAe;AACnB,OAAI;IACF,MAAM,YAAY,MAAM,SAAS,MAAM;AACvC,mBAAe,KAAK,UAAU,UAAU,MAAM,IAAI;WAC5C;AACN,QAAI;KACF,MAAM,YAAY,MAAM,SAAS,MAAM;AACvC,SAAI,UAAW,gBAAe;YACxB;;AAIV,SAAM,IAAI,MAAM,aAAa;;EAG/B,MAAM,SAAS,SAAS,MAAM,WAAW;AACzC,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,sBAAsB;EAEnD,MAAM,UAAU,IAAI,aAAa;EACjC,IAAI,SAAS;AAEb,SAAO,MAAM;GACX,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,MAAM;AAE3C,OAAI,KAAM;AAEV,aAAU,QAAQ,OAAO,OAAO,EAAE,QAAQ,MAAM,CAAC;GACjD,MAAM,QAAQ,OAAO,MAAM,KAAK;AAChC,YAAS,MAAM,KAAK,IAAI;AAExB,QAAK,MAAM,QAAQ,MACjB,KAAI,KAAK,WAAW,SAAS,CAC3B,KAAI;IACF,MAAM,QAAQ,KAAK,MAAM,KAAK,MAAM,EAAE,CAAC;AACvC,gBAAY,MAAM;WACZ;;AAOd,YAAU;;;;;CAMZ,MAAM,sBAAsB,OAC1B,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,mBACnB,gBACA,cACA;EACE,QAAQ;EACR,QAAQ,MAAM,MAAM,EAAE,KAAK,KAAK,KAAK,GAAG;EACxC,MAAM,MAAM,SAAS,SAAY,EAAE,MAAM,KAAK,MAAa,GAAG;EAC/D,CACF;;;;CAKH,MAAM,0BAA0B,OAC9B,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,aAAa,QAAQ,SACxC,gBACA,cACA,EACE,QAAQ,OACT,CACF;CAEH,MAAM,uBAAuB,OAC3B,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,UAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,sBAAsB,OAC1B,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,SAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,uBAAuB,OAC3B,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,UAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"editor.cjs","names":["fetcher"],"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from 'intlayer-editor';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig: IntlayerConfig\n) => {\n const editorURL = intlayerConfig.editor.editorURL;\n\n if (!editorURL) {\n throw new Error('Editor URL is not defined in the Intlayer configuration.');\n }\n\n const EDITOR_API_ROUTE = `${editorURL}/api`;\n\n /**\n * Get the Intlayer configuration\n */\n const getConfiguration = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetConfigurationResult> => {\n const response = await fetcher<GetConfigurationResult>(\n `${EDITOR_API_ROUTE}/config`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetConfigurationResult;\n };\n\n /**\n * Get the Intlayer configuration\n */\n const getDictionaries = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetEditorDictionariesResult> => {\n const response = await fetcher<GetEditorDictionariesResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetEditorDictionariesResult;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n body: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n return {\n getDictionaries,\n getConfiguration,\n writeDictionary,\n };\n};\n"],"mappings":";;;;AASA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,YAAY,eAAe,OAAO;AAExC,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,2DAA2D;CAG7E,MAAM,mBAAmB,GAAG,UAAU;;;;CAKtC,MAAM,mBAAmB,OACvB,eAA+B,EAAE,KACG;AAOpC,UANiB,MAAMA,wBACrB,GAAG,iBAAiB,UACpB,gBACA,aACD,EAEe;;;;;CAMlB,MAAM,kBAAkB,OACtB,eAA+B,EAAE,KACQ;AAOzC,UANiB,MAAMA,wBACrB,GAAG,iBAAiB,cACpB,gBACA,aACD,EAEe;;;;;;CAOlB,MAAM,kBAAkB,OACtB,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,cACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD"}
1
+ {"version":3,"file":"editor.cjs","names":["fetcher"],"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from 'intlayer-editor';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig: IntlayerConfig\n) => {\n const editorURL = intlayerConfig.editor.editorURL;\n\n if (!editorURL) {\n throw new Error('Editor URL is not defined in the Intlayer configuration.');\n }\n\n const EDITOR_API_ROUTE = `${editorURL}/api`;\n\n /**\n * Get the Intlayer configuration\n */\n const getConfiguration = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetConfigurationResult> => {\n const response = await fetcher<GetConfigurationResult>(\n `${EDITOR_API_ROUTE}/config`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetConfigurationResult;\n };\n\n /**\n * Get the Intlayer configuration\n */\n const getDictionaries = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetEditorDictionariesResult> => {\n const response = await fetcher<GetEditorDictionariesResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetEditorDictionariesResult;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n body: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n return {\n getDictionaries,\n getConfiguration,\n writeDictionary,\n };\n};\n"],"mappings":";;;;AASA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,YAAY,eAAe,OAAO;AAExC,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,2DAA2D;CAG7E,MAAM,mBAAmB,GAAG,UAAU;;;;CAKtC,MAAM,mBAAmB,OACvB,eAA+B,EAAE,KACG;AAOpC,UAAO,MANgBA,wBACrB,GAAG,iBAAiB,UACpB,gBACA,aACD,EAEe;;;;;CAMlB,MAAM,kBAAkB,OACtB,eAA+B,EAAE,KACQ;AAOzC,UAAO,MANgBA,wBACrB,GAAG,iBAAiB,cACpB,gBACA,aACD,EAEe;;;;;;CAOlB,MAAM,kBAAkB,OACtB,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,cACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD"}
@@ -15,6 +15,7 @@ const require_getIntlayerAPI_search = require('./search.cjs');
15
15
  const require_getIntlayerAPI_showcaseProject = require('./showcaseProject.cjs');
16
16
  const require_getIntlayerAPI_stripe = require('./stripe.cjs');
17
17
  const require_getIntlayerAPI_tag = require('./tag.cjs');
18
+ const require_getIntlayerAPI_translate = require('./translate.cjs');
18
19
  const require_getIntlayerAPI_user = require('./user.cjs');
19
20
  let _intlayer_config_built = require("@intlayer/config/built");
20
21
  _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
@@ -39,7 +40,8 @@ const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => {
39
40
  github: require_getIntlayerAPI_github.getGithubAPI(authAPIOptions, resolvedConfig),
40
41
  gitlab: require_getIntlayerAPI_gitlab.getGitlabAPI(authAPIOptions, resolvedConfig),
41
42
  bitbucket: require_getIntlayerAPI_bitbucket.getBitbucketAPI(authAPIOptions, resolvedConfig),
42
- showcaseProject: require_getIntlayerAPI_showcaseProject.getShowcaseProjectAPI(authAPIOptions, resolvedConfig)
43
+ showcaseProject: require_getIntlayerAPI_showcaseProject.getShowcaseProjectAPI(authAPIOptions, resolvedConfig),
44
+ translate: require_getIntlayerAPI_translate.getTranslateAPI(authAPIOptions, resolvedConfig)
43
45
  };
44
46
  };
45
47
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["defaultConfiguration","getOrganizationAPI","getProjectAPI","getUserAPI","getOAuthAPI","getDictionaryAPI","getStripeAPI","getAiAPI","getAuditAPI","getTagAPI","getSearchAPI","getEditorAPI","getNewsletterAPI","getGithubAPI","getGitlabAPI","getBitbucketAPI","getShowcaseProjectAPI"],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import { default as defaultConfiguration } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getAuditAPI } from './audit';\nimport { getBitbucketAPI } from './bitbucket';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getGithubAPI } from './github';\nimport { getGitlabAPI } from './gitlab';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getSearchAPI } from './search';\nimport { getShowcaseProjectAPI } from './showcaseProject';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n audit: ReturnType<typeof getAuditAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n github: ReturnType<typeof getGithubAPI>;\n gitlab: ReturnType<typeof getGitlabAPI>;\n bitbucket: ReturnType<typeof getBitbucketAPI>;\n showcaseProject: ReturnType<typeof getShowcaseProjectAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPIReturn => {\n const resolvedConfig = defu(\n intlayerConfig ?? {},\n defaultConfiguration\n ) as IntlayerConfig;\n\n return {\n organization: getOrganizationAPI(authAPIOptions, resolvedConfig),\n project: getProjectAPI(authAPIOptions, resolvedConfig),\n user: getUserAPI(authAPIOptions, resolvedConfig),\n oAuth: getOAuthAPI(resolvedConfig),\n dictionary: getDictionaryAPI(authAPIOptions, resolvedConfig),\n stripe: getStripeAPI(authAPIOptions, resolvedConfig),\n ai: getAiAPI(authAPIOptions, resolvedConfig),\n audit: getAuditAPI(authAPIOptions, resolvedConfig),\n tag: getTagAPI(authAPIOptions, resolvedConfig),\n search: getSearchAPI(authAPIOptions, resolvedConfig),\n editor: getEditorAPI(authAPIOptions, resolvedConfig),\n newsletter: getNewsletterAPI(authAPIOptions, resolvedConfig),\n github: getGithubAPI(authAPIOptions, resolvedConfig),\n gitlab: getGitlabAPI(authAPIOptions, resolvedConfig),\n bitbucket: getBitbucketAPI(authAPIOptions, resolvedConfig),\n showcaseProject: getShowcaseProjectAPI(authAPIOptions, resolvedConfig),\n };\n};\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,kBACX,iBAAiC,EAAE,EACnC,mBACsB;CACtB,MAAM,gCACJ,kBAAkB,EAAE,EACpBA,+BACD;AAED,QAAO;EACL,cAAcC,uDAAmB,gBAAgB,eAAe;EAChE,SAASC,6CAAc,gBAAgB,eAAe;EACtD,MAAMC,uCAAW,gBAAgB,eAAe;EAChD,OAAOC,yCAAY,eAAe;EAClC,YAAYC,mDAAiB,gBAAgB,eAAe;EAC5D,QAAQC,2CAAa,gBAAgB,eAAe;EACpD,IAAIC,mCAAS,gBAAgB,eAAe;EAC5C,OAAOC,yCAAY,gBAAgB,eAAe;EAClD,KAAKC,qCAAU,gBAAgB,eAAe;EAC9C,QAAQC,2CAAa,gBAAgB,eAAe;EACpD,QAAQC,2CAAa,gBAAgB,eAAe;EACpD,YAAYC,mDAAiB,gBAAgB,eAAe;EAC5D,QAAQC,2CAAa,gBAAgB,eAAe;EACpD,QAAQC,2CAAa,gBAAgB,eAAe;EACpD,WAAWC,iDAAgB,gBAAgB,eAAe;EAC1D,iBAAiBC,6DAAsB,gBAAgB,eAAe;EACvE"}
1
+ {"version":3,"file":"index.cjs","names":["defaultConfiguration","getOrganizationAPI","getProjectAPI","getUserAPI","getOAuthAPI","getDictionaryAPI","getStripeAPI","getAiAPI","getAuditAPI","getTagAPI","getSearchAPI","getEditorAPI","getNewsletterAPI","getGithubAPI","getGitlabAPI","getBitbucketAPI","getShowcaseProjectAPI","getTranslateAPI"],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import { default as defaultConfiguration } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getAuditAPI } from './audit';\nimport { getBitbucketAPI } from './bitbucket';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getGithubAPI } from './github';\nimport { getGitlabAPI } from './gitlab';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getSearchAPI } from './search';\nimport { getShowcaseProjectAPI } from './showcaseProject';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getTranslateAPI } from './translate';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n audit: ReturnType<typeof getAuditAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n github: ReturnType<typeof getGithubAPI>;\n gitlab: ReturnType<typeof getGitlabAPI>;\n bitbucket: ReturnType<typeof getBitbucketAPI>;\n showcaseProject: ReturnType<typeof getShowcaseProjectAPI>;\n translate: ReturnType<typeof getTranslateAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPIReturn => {\n const resolvedConfig = defu(\n intlayerConfig ?? {},\n defaultConfiguration\n ) as IntlayerConfig;\n\n return {\n organization: getOrganizationAPI(authAPIOptions, resolvedConfig),\n project: getProjectAPI(authAPIOptions, resolvedConfig),\n user: getUserAPI(authAPIOptions, resolvedConfig),\n oAuth: getOAuthAPI(resolvedConfig),\n dictionary: getDictionaryAPI(authAPIOptions, resolvedConfig),\n stripe: getStripeAPI(authAPIOptions, resolvedConfig),\n ai: getAiAPI(authAPIOptions, resolvedConfig),\n audit: getAuditAPI(authAPIOptions, resolvedConfig),\n tag: getTagAPI(authAPIOptions, resolvedConfig),\n search: getSearchAPI(authAPIOptions, resolvedConfig),\n editor: getEditorAPI(authAPIOptions, resolvedConfig),\n newsletter: getNewsletterAPI(authAPIOptions, resolvedConfig),\n github: getGithubAPI(authAPIOptions, resolvedConfig),\n gitlab: getGitlabAPI(authAPIOptions, resolvedConfig),\n bitbucket: getBitbucketAPI(authAPIOptions, resolvedConfig),\n showcaseProject: getShowcaseProjectAPI(authAPIOptions, resolvedConfig),\n translate: getTranslateAPI(authAPIOptions, resolvedConfig),\n };\n};\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,kBACX,iBAAiC,EAAE,EACnC,mBACsB;CACtB,MAAM,gCACJ,kBAAkB,EAAE,EACpBA,+BACD;AAED,QAAO;EACL,cAAcC,uDAAmB,gBAAgB,eAAe;EAChE,SAASC,6CAAc,gBAAgB,eAAe;EACtD,MAAMC,uCAAW,gBAAgB,eAAe;EAChD,OAAOC,yCAAY,eAAe;EAClC,YAAYC,mDAAiB,gBAAgB,eAAe;EAC5D,QAAQC,2CAAa,gBAAgB,eAAe;EACpD,IAAIC,mCAAS,gBAAgB,eAAe;EAC5C,OAAOC,yCAAY,gBAAgB,eAAe;EAClD,KAAKC,qCAAU,gBAAgB,eAAe;EAC9C,QAAQC,2CAAa,gBAAgB,eAAe;EACpD,QAAQC,2CAAa,gBAAgB,eAAe;EACpD,YAAYC,mDAAiB,gBAAgB,eAAe;EAC5D,QAAQC,2CAAa,gBAAgB,eAAe;EACpD,QAAQC,2CAAa,gBAAgB,eAAe;EACpD,WAAWC,iDAAgB,gBAAgB,eAAe;EAC1D,iBAAiBC,6DAAsB,gBAAgB,eAAe;EACtE,WAAWC,iDAAgB,gBAAgB,eAAe;EAC3D"}
@@ -0,0 +1,28 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_fetcher = require('../fetcher.cjs');
3
+
4
+ //#region src/getIntlayerAPI/translate.ts
5
+ const getTranslateAPI = (authAPIOptions = {}, intlayerConfig) => {
6
+ const TRANSLATE_API_ROUTE = `${intlayerConfig.editor.backendURL}/api/translate`;
7
+ const translateDictionaries = async (body, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/dictionaries`, authAPIOptions, otherOptions, {
8
+ method: "POST",
9
+ body
10
+ });
11
+ const pauseTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/pause`, authAPIOptions, otherOptions, { method: "POST" });
12
+ const resumeTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/resume`, authAPIOptions, otherOptions, { method: "POST" });
13
+ const stopTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/stop`, authAPIOptions, otherOptions, { method: "POST" });
14
+ const retryTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/retry`, authAPIOptions, otherOptions, { method: "POST" });
15
+ const restartTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/restart`, authAPIOptions, otherOptions, { method: "POST" });
16
+ return {
17
+ translateDictionaries,
18
+ pauseTranslationJob,
19
+ resumeTranslationJob,
20
+ stopTranslationJob,
21
+ retryTranslationJob,
22
+ restartTranslationJob
23
+ };
24
+ };
25
+
26
+ //#endregion
27
+ exports.getTranslateAPI = getTranslateAPI;
28
+ //# sourceMappingURL=translate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.cjs","names":["fetcher"],"sources":["../../../src/getIntlayerAPI/translate.ts"],"sourcesContent":["import type {\n TranslateDictionariesBody,\n TranslateDictionariesResult,\n} from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type { TranslateDictionariesBody, TranslateDictionariesResult };\n\nexport const getTranslateAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig: IntlayerConfig\n) => {\n const backendURL = intlayerConfig.editor.backendURL;\n\n const TRANSLATE_API_ROUTE = `${backendURL}/api/translate`;\n\n const translateDictionaries = async (\n body: TranslateDictionariesBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<TranslateDictionariesResult>(\n `${TRANSLATE_API_ROUTE}/dictionaries`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const pauseTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/pause`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const resumeTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/resume`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const stopTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/stop`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const retryTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/retry`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const restartTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/restart`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n return {\n translateDictionaries,\n pauseTranslationJob,\n resumeTranslationJob,\n stopTranslationJob,\n retryTranslationJob,\n restartTranslationJob,\n };\n};\n"],"mappings":";;;;AASA,MAAa,mBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,sBAAsB,GAFT,eAAe,OAAO,WAEC;CAE1C,MAAM,wBAAwB,OAC5B,MACA,eAA+B,EAAE,KAEjCA,wBACE,GAAG,oBAAoB,gBACvB,gBACA,cACA;EAAE,QAAQ;EAAQ;EAAM,CACzB;CAEH,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAEjCA,wBACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,uBAAuB,OAC3B,OACA,eAA+B,EAAE,KAEjCA,wBACE,GAAG,oBAAoB,GAAG,MAAM,UAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,qBAAqB,OACzB,OACA,eAA+B,EAAE,KAEjCA,wBACE,GAAG,oBAAoB,GAAG,MAAM,QAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAEjCA,wBACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,wBAAwB,OAC5B,OACA,eAA+B,EAAE,KAEjCA,wBACE,GAAG,oBAAoB,GAAG,MAAM,WAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -14,6 +14,7 @@ const require_getIntlayerAPI_project = require('./getIntlayerAPI/project.cjs');
14
14
  const require_getIntlayerAPI_search = require('./getIntlayerAPI/search.cjs');
15
15
  const require_getIntlayerAPI_stripe = require('./getIntlayerAPI/stripe.cjs');
16
16
  const require_getIntlayerAPI_tag = require('./getIntlayerAPI/tag.cjs');
17
+ const require_getIntlayerAPI_translate = require('./getIntlayerAPI/translate.cjs');
17
18
  const require_getIntlayerAPI_user = require('./getIntlayerAPI/user.cjs');
18
19
  const require_getIntlayerAPI_index = require('./getIntlayerAPI/index.cjs');
19
20
  const require_proxy = require('./proxy.cjs');
@@ -40,4 +41,5 @@ exports.getProjectAPI = require_getIntlayerAPI_project.getProjectAPI;
40
41
  exports.getSearchAPI = require_getIntlayerAPI_search.getSearchAPI;
41
42
  exports.getStripeAPI = require_getIntlayerAPI_stripe.getStripeAPI;
42
43
  exports.getTagAPI = require_getIntlayerAPI_tag.getTagAPI;
44
+ exports.getTranslateAPI = require_getIntlayerAPI_translate.getTranslateAPI;
43
45
  exports.getUserAPI = require_getIntlayerAPI_user.getUserAPI;
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.cjs","names":["getIntlayerAPI","getOAuthAPI"],"sources":["../../src/proxy.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport type { FetcherOptions } from './fetcher';\nimport { getIntlayerAPI } from './getIntlayerAPI';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\n\ntype OAuthTokenLike = {\n accessToken?: string;\n accessTokenExpiresAt?: string | Date;\n expires_in?: number;\n expiresIn?: number;\n expiresAt?: string | Date;\n};\n\nconst ONE_MINUTE_MS = 60_000;\n\n/**\n * Returns the expiration timestamp in ms from an OAuth token-like object.\n */\nconst getExpiryTimestamp = (\n token: OAuthTokenLike | undefined\n): number | undefined => {\n if (!token) return undefined;\n const dateLike = (token.accessTokenExpiresAt ?? token.expiresAt) as\n | string\n | Date\n | undefined;\n if (dateLike) {\n const ts =\n typeof dateLike === 'string'\n ? Date.parse(dateLike)\n : dateLike.getTime?.();\n if (typeof ts === 'number' && Number.isFinite(ts)) return ts;\n }\n const seconds = token.expires_in ?? token.expiresIn;\n if (typeof seconds === 'number' && Number.isFinite(seconds)) {\n return Date.now() + seconds * 1000;\n }\n return undefined;\n};\n\nlet currentAccessToken: string | undefined;\nlet currentExpiryTs: number | undefined;\nlet pendingRefresh: Promise<void> | undefined;\n\n/**\n * Build an auto-auth proxy around getIntlayerAPI that:\n * - Fetches an OAuth2 token when needed\n * - Injects Authorization header for each request\n * - Refreshes token proactively when near expiry\n *\n * The returned API matches the shape of getIntlayerAPI.\n */\nexport const getIntlayerAPIProxy = (\n baseAuthOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPI => {\n // Use a shared mutable auth options object captured by the API closures\n const authOptionsRef: FetcherOptions = { ...baseAuthOptions };\n const hasCMSAuth =\n intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;\n const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);\n\n const needsRefresh = (): boolean => {\n if (!currentAccessToken) return true;\n if (!currentExpiryTs) return false; // If unknown, assume usable until failure\n\n return Date.now() + ONE_MINUTE_MS >= currentExpiryTs; // refresh 1 min before expiry\n };\n\n const refreshToken = async (): Promise<void> => {\n const doRefresh = async () => {\n const authApi = getOAuthAPI(intlayerConfig);\n const res = await authApi.getOAuth2AccessToken();\n const tokenData = res?.data as OAuthTokenLike | undefined;\n\n currentAccessToken = tokenData?.accessToken;\n currentExpiryTs = getExpiryTimestamp(tokenData);\n };\n\n if (!pendingRefresh) {\n pendingRefresh = doRefresh().finally(() => {\n pendingRefresh = undefined;\n });\n }\n await pendingRefresh;\n };\n\n const ensureValidToken = async () => {\n if (needsRefresh()) {\n await refreshToken();\n }\n };\n\n const applyAuthHeaderToRef = () => {\n if (!currentAccessToken) return;\n authOptionsRef.headers = {\n ...(authOptionsRef.headers ?? {}),\n Authorization: `Bearer ${currentAccessToken}`,\n } as HeadersInit;\n };\n\n const wrapSection = <T extends Record<string, unknown>>(\n section: T,\n skipAuth = !hasCMSAuth\n ): T => {\n return new Proxy(section, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === 'function') {\n // Wrap section method to inject token and headers\n return async (...args: unknown[]) => {\n if (!skipAuth) {\n await ensureValidToken();\n applyAuthHeaderToRef();\n }\n\n try {\n return await value.apply(target, args);\n } catch (err) {\n // Best-effort retry: if token might be stale, refresh once and retry\n if (!skipAuth) {\n await refreshToken();\n applyAuthHeaderToRef();\n return await value.apply(target, args);\n }\n throw err;\n }\n };\n }\n\n return value;\n },\n });\n };\n\n return {\n organization: wrapSection(baseApi.organization),\n project: wrapSection(baseApi.project),\n user: wrapSection(baseApi.user),\n oAuth: wrapSection(baseApi.oAuth, true), // do NOT inject auth for token endpoint\n dictionary: wrapSection(baseApi.dictionary),\n stripe: wrapSection(baseApi.stripe),\n ai: wrapSection(baseApi.ai),\n tag: wrapSection(baseApi.tag),\n search: wrapSection(baseApi.search),\n editor: wrapSection(baseApi.editor),\n newsletter: wrapSection(baseApi.newsletter),\n github: wrapSection(baseApi.github),\n } as IntlayerAPI;\n};\n\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":";;;;;AAcA,MAAM,gBAAgB;;;;AAKtB,MAAM,sBACJ,UACuB;AACvB,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,WAAY,MAAM,wBAAwB,MAAM;AAItD,KAAI,UAAU;EACZ,MAAM,KACJ,OAAO,aAAa,WAChB,KAAK,MAAM,SAAS,GACpB,SAAS,WAAW;AAC1B,MAAI,OAAO,OAAO,YAAY,OAAO,SAAS,GAAG,CAAE,QAAO;;CAE5D,MAAM,UAAU,MAAM,cAAc,MAAM;AAC1C,KAAI,OAAO,YAAY,YAAY,OAAO,SAAS,QAAQ,CACzD,QAAO,KAAK,KAAK,GAAG,UAAU;;AAKlC,IAAI;AACJ,IAAI;AACJ,IAAI;;;;;;;;;AAUJ,MAAa,uBACX,kBAAkC,EAAE,EACpC,mBACgB;CAEhB,MAAM,iBAAiC,EAAE,GAAG,iBAAiB;CAC7D,MAAM,aACJ,gBAAgB,QAAQ,YAAY,gBAAgB,QAAQ;CAC9D,MAAM,UAAUA,4CAAe,gBAAgB,eAAe;CAE9D,MAAM,qBAA8B;AAClC,MAAI,CAAC,mBAAoB,QAAO;AAChC,MAAI,CAAC,gBAAiB,QAAO;AAE7B,SAAO,KAAK,KAAK,GAAG,iBAAiB;;CAGvC,MAAM,eAAe,YAA2B;EAC9C,MAAM,YAAY,YAAY;GAG5B,MAAM,aADM,MADIC,yCAAY,eAAe,CACjB,sBAAsB,GACzB;AAEvB,wBAAqB,WAAW;AAChC,qBAAkB,mBAAmB,UAAU;;AAGjD,MAAI,CAAC,eACH,kBAAiB,WAAW,CAAC,cAAc;AACzC,oBAAiB;IACjB;AAEJ,QAAM;;CAGR,MAAM,mBAAmB,YAAY;AACnC,MAAI,cAAc,CAChB,OAAM,cAAc;;CAIxB,MAAM,6BAA6B;AACjC,MAAI,CAAC,mBAAoB;AACzB,iBAAe,UAAU;GACvB,GAAI,eAAe,WAAW,EAAE;GAChC,eAAe,UAAU;GAC1B;;CAGH,MAAM,eACJ,SACA,WAAW,CAAC,eACN;AACN,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;GAC1B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,SAAS;AAEjD,OAAI,OAAO,UAAU,WAEnB,QAAO,OAAO,GAAG,SAAoB;AACnC,QAAI,CAAC,UAAU;AACb,WAAM,kBAAkB;AACxB,2BAAsB;;AAGxB,QAAI;AACF,YAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;aAC/B,KAAK;AAEZ,SAAI,CAAC,UAAU;AACb,YAAM,cAAc;AACpB,4BAAsB;AACtB,aAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;;AAExC,WAAM;;;AAKZ,UAAO;KAEV,CAAC;;AAGJ,QAAO;EACL,cAAc,YAAY,QAAQ,aAAa;EAC/C,SAAS,YAAY,QAAQ,QAAQ;EACrC,MAAM,YAAY,QAAQ,KAAK;EAC/B,OAAO,YAAY,QAAQ,OAAO,KAAK;EACvC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACnC,IAAI,YAAY,QAAQ,GAAG;EAC3B,KAAK,YAAY,QAAQ,IAAI;EAC7B,QAAQ,YAAY,QAAQ,OAAO;EACnC,QAAQ,YAAY,QAAQ,OAAO;EACnC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACpC"}
1
+ {"version":3,"file":"proxy.cjs","names":["getIntlayerAPI","getOAuthAPI"],"sources":["../../src/proxy.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport type { FetcherOptions } from './fetcher';\nimport { getIntlayerAPI } from './getIntlayerAPI';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\n\ntype OAuthTokenLike = {\n accessToken?: string;\n accessTokenExpiresAt?: string | Date;\n expires_in?: number;\n expiresIn?: number;\n expiresAt?: string | Date;\n};\n\nconst ONE_MINUTE_MS = 60_000;\n\n/**\n * Returns the expiration timestamp in ms from an OAuth token-like object.\n */\nconst getExpiryTimestamp = (\n token: OAuthTokenLike | undefined\n): number | undefined => {\n if (!token) return undefined;\n const dateLike = (token.accessTokenExpiresAt ?? token.expiresAt) as\n | string\n | Date\n | undefined;\n if (dateLike) {\n const ts =\n typeof dateLike === 'string'\n ? Date.parse(dateLike)\n : dateLike.getTime?.();\n if (typeof ts === 'number' && Number.isFinite(ts)) return ts;\n }\n const seconds = token.expires_in ?? token.expiresIn;\n if (typeof seconds === 'number' && Number.isFinite(seconds)) {\n return Date.now() + seconds * 1000;\n }\n return undefined;\n};\n\nlet currentAccessToken: string | undefined;\nlet currentExpiryTs: number | undefined;\nlet pendingRefresh: Promise<void> | undefined;\n\n/**\n * Build an auto-auth proxy around getIntlayerAPI that:\n * - Fetches an OAuth2 token when needed\n * - Injects Authorization header for each request\n * - Refreshes token proactively when near expiry\n *\n * The returned API matches the shape of getIntlayerAPI.\n */\nexport const getIntlayerAPIProxy = (\n baseAuthOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPI => {\n // Use a shared mutable auth options object captured by the API closures\n const authOptionsRef: FetcherOptions = { ...baseAuthOptions };\n const hasCMSAuth =\n intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;\n const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);\n\n const needsRefresh = (): boolean => {\n if (!currentAccessToken) return true;\n if (!currentExpiryTs) return false; // If unknown, assume usable until failure\n\n return Date.now() + ONE_MINUTE_MS >= currentExpiryTs; // refresh 1 min before expiry\n };\n\n const refreshToken = async (): Promise<void> => {\n const doRefresh = async () => {\n const authApi = getOAuthAPI(intlayerConfig);\n const res = await authApi.getOAuth2AccessToken();\n const tokenData = res?.data as OAuthTokenLike | undefined;\n\n currentAccessToken = tokenData?.accessToken;\n currentExpiryTs = getExpiryTimestamp(tokenData);\n };\n\n if (!pendingRefresh) {\n pendingRefresh = doRefresh().finally(() => {\n pendingRefresh = undefined;\n });\n }\n await pendingRefresh;\n };\n\n const ensureValidToken = async () => {\n if (needsRefresh()) {\n await refreshToken();\n }\n };\n\n const applyAuthHeaderToRef = () => {\n if (!currentAccessToken) return;\n authOptionsRef.headers = {\n ...(authOptionsRef.headers ?? {}),\n Authorization: `Bearer ${currentAccessToken}`,\n } as HeadersInit;\n };\n\n const wrapSection = <T extends Record<string, unknown>>(\n section: T,\n skipAuth = !hasCMSAuth\n ): T => {\n return new Proxy(section, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === 'function') {\n // Wrap section method to inject token and headers\n return async (...args: unknown[]) => {\n if (!skipAuth) {\n await ensureValidToken();\n applyAuthHeaderToRef();\n }\n\n try {\n return await value.apply(target, args);\n } catch (err) {\n // Best-effort retry: if token might be stale, refresh once and retry\n if (!skipAuth) {\n await refreshToken();\n applyAuthHeaderToRef();\n return await value.apply(target, args);\n }\n throw err;\n }\n };\n }\n\n return value;\n },\n });\n };\n\n return {\n organization: wrapSection(baseApi.organization),\n project: wrapSection(baseApi.project),\n user: wrapSection(baseApi.user),\n oAuth: wrapSection(baseApi.oAuth, true), // do NOT inject auth for token endpoint\n dictionary: wrapSection(baseApi.dictionary),\n stripe: wrapSection(baseApi.stripe),\n ai: wrapSection(baseApi.ai),\n tag: wrapSection(baseApi.tag),\n search: wrapSection(baseApi.search),\n editor: wrapSection(baseApi.editor),\n newsletter: wrapSection(baseApi.newsletter),\n github: wrapSection(baseApi.github),\n } as IntlayerAPI;\n};\n\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":";;;;;AAcA,MAAM,gBAAgB;;;;AAKtB,MAAM,sBACJ,UACuB;AACvB,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,WAAY,MAAM,wBAAwB,MAAM;AAItD,KAAI,UAAU;EACZ,MAAM,KACJ,OAAO,aAAa,WAChB,KAAK,MAAM,SAAS,GACpB,SAAS,WAAW;AAC1B,MAAI,OAAO,OAAO,YAAY,OAAO,SAAS,GAAG,CAAE,QAAO;;CAE5D,MAAM,UAAU,MAAM,cAAc,MAAM;AAC1C,KAAI,OAAO,YAAY,YAAY,OAAO,SAAS,QAAQ,CACzD,QAAO,KAAK,KAAK,GAAG,UAAU;;AAKlC,IAAI;AACJ,IAAI;AACJ,IAAI;;;;;;;;;AAUJ,MAAa,uBACX,kBAAkC,EAAE,EACpC,mBACgB;CAEhB,MAAM,iBAAiC,EAAE,GAAG,iBAAiB;CAC7D,MAAM,aACJ,gBAAgB,QAAQ,YAAY,gBAAgB,QAAQ;CAC9D,MAAM,UAAUA,4CAAe,gBAAgB,eAAe;CAE9D,MAAM,qBAA8B;AAClC,MAAI,CAAC,mBAAoB,QAAO;AAChC,MAAI,CAAC,gBAAiB,QAAO;AAE7B,SAAO,KAAK,KAAK,GAAG,iBAAiB;;CAGvC,MAAM,eAAe,YAA2B;EAC9C,MAAM,YAAY,YAAY;GAG5B,MAAM,aAAY,MAFFC,yCAAY,eACH,CAAC,sBAAsB,GACzB;AAEvB,wBAAqB,WAAW;AAChC,qBAAkB,mBAAmB,UAAU;;AAGjD,MAAI,CAAC,eACH,kBAAiB,WAAW,CAAC,cAAc;AACzC,oBAAiB;IACjB;AAEJ,QAAM;;CAGR,MAAM,mBAAmB,YAAY;AACnC,MAAI,cAAc,CAChB,OAAM,cAAc;;CAIxB,MAAM,6BAA6B;AACjC,MAAI,CAAC,mBAAoB;AACzB,iBAAe,UAAU;GACvB,GAAI,eAAe,WAAW,EAAE;GAChC,eAAe,UAAU;GAC1B;;CAGH,MAAM,eACJ,SACA,WAAW,CAAC,eACN;AACN,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;GAC1B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,SAAS;AAEjD,OAAI,OAAO,UAAU,WAEnB,QAAO,OAAO,GAAG,SAAoB;AACnC,QAAI,CAAC,UAAU;AACb,WAAM,kBAAkB;AACxB,2BAAsB;;AAGxB,QAAI;AACF,YAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;aAC/B,KAAK;AAEZ,SAAI,CAAC,UAAU;AACb,YAAM,cAAc;AACpB,4BAAsB;AACtB,aAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;;AAExC,WAAM;;;AAKZ,UAAO;KAEV,CAAC;;AAGJ,QAAO;EACL,cAAc,YAAY,QAAQ,aAAa;EAC/C,SAAS,YAAY,QAAQ,QAAQ;EACrC,MAAM,YAAY,QAAQ,KAAK;EAC/B,OAAO,YAAY,QAAQ,OAAO,KAAK;EACvC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACnC,IAAI,YAAY,QAAQ,GAAG;EAC3B,KAAK,YAAY,QAAQ,IAAI;EAC7B,QAAQ,YAAY,QAAQ,OAAO;EACnC,QAAQ,YAAY,QAAQ,OAAO;EACnC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getIntlayerAPIProxy } from '../proxy';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI[] | null | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary list\n const getDictionaryResult = await api.dictionary.getDictionaries();\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;AAOA,MAAa,2BAA2B,OACtC,mBACgD;AAChD,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;AAUH,UAJ4B,MAHhB,oBAAoB,QAAW,eAAe,CAGpB,WAAW,iBAAiB,EAElB;UAGzC,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
1
+ {"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getIntlayerAPIProxy } from '../proxy';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI[] | null | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary list\n const getDictionaryResult = await api.dictionary.getDictionaries();\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;AAOA,MAAa,2BAA2B,OACtC,mBACgD;AAChD,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;AAUH,UAF4B,MALhB,oBAAoB,QAAW,eAGN,CAAC,WAAW,iBAAiB,EAElB;UAGzC,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionary.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getIntlayerAPIProxy } from '../proxy';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary\n const getDictionaryResult =\n await api.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n return distantDictionary;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;AAOA,MAAa,yBAAyB,OACpC,eACA,mBACuC;AACvC,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;EASH,MAAM,qBAFJ,MAJU,oBAAoB,QAAW,eAAe,CAI9C,WAAW,cAAc,cAAc,EAEL;AAE9C,MAAI,CAAC,kBACH,OAAM,IAAI,MAAM,cAAc,cAAc,sBAAsB;AAGpE,SAAO;UACA,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
1
+ {"version":3,"file":"fetchDistantDictionary.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getIntlayerAPIProxy } from '../proxy';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary\n const getDictionaryResult =\n await api.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n return distantDictionary;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;AAOA,MAAa,yBAAyB,OACpC,eACA,mBACuC;AACvC,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;EASH,MAAM,qBAAoB,MANd,oBAAoB,QAAW,eAIhC,CAAC,WAAW,cAAc,cAAc,EAEL;AAE9C,MAAI,CAAC,kBACH,OAAM,IAAI,MAAM,cAAc,cAAc,sBAAsB;AAGpE,SAAO;UACA,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.mjs","names":[],"sources":["../../src/fetcher.ts"],"sourcesContent":["/**\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}`;\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();\n\n // You can customize the error message or include more details\n throw new Error(JSON.stringify(result.error) ?? 'An error occurred');\n }\n return await response.json();\n};\n"],"mappings":";;;;;;AAwBA,MAAa,iBAAiC;CAC5C,QAAQ;CACR,SAAS,EACP,gBAAgB,oBACjB;CACD,aAAa;CACd;;;;;;;;AASD,MAAM,mBAAmB,QAAgB;AACvC,QAAO,KAAK,IAAI,CAAC,SAAS,QAAQ;AAChC,MAAI,IAAI,SAA6B,OACnC,QAAO,IAAI;GAEb;AACF,QAAO;;;;;;;;;;AAWT,MAAM,aAA+B,YACnC,QAAQ,QAAQ,KAAK,QAAQ;CAC3B,MAAM,OAAW,OAAO,EAAE;CAC1B,MAAM,OAAU,gBAAgB,OAAO,EAAE,CAAC;AAE1C,KAAI,OAAO,SAAS,YAAY,OAAO,SAAS,SAE9C,QAAO;EAAE,GAAG;EAAM,GAAG;EAAM;AAI7B,QAAO,QAAQ;GACd,EAAE,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDb,MAAa,UAAU,OACrB,KACA,GAAG,YACY;CACf,MAAM,EAAE,WAAW,IAAI,iBAAiB;CAGxC,IAAI,eAAe;CACnB,IAAI;CAQJ,MAAM,gBAAgB,UAAU,CAAC,gBAAgB,GAL5B,QAAQ,KAC1B,EAAE,MAAM,QAAQ,SAAS,GAAG,mBAAmB,aACjD,CAGgE,CAAC;CAGlE,MAAM,gBAAgB,UAAU,CAC9B,eAAe,SACf,GAAG,QAAQ,KAAK,WAAW,OAAO,QAAQ,CAC3C,CAAC;CAGF,MAAM,SAAS,UAAU,QAAQ,KAAK,WAAW,OAAO,OAAO,CAAC;CAEhE,MAAM,SAAS,cAAc;AAG7B,KAAI,WAAW,SAAS,WAAW,QAAQ;EAEzC,MAAM,OAAO,UAAU,QAAQ,KAAK,WAAW,OAAO,KAAK,CAAC;AAC5D,MACE,gBAAgB,oBAChB,oCAGA,cAAa,IAAI,gBACf,KACD,CAAC,UAAU;MAGZ,cAAa,KAAK,UAAU,KAAK;;AAKrC,KAAI,OAAO,QAAQ,OAAO,CAAC,SAAS,EAClC,gBAAe,IAAI,IAAI,gBACrB,OACD,CAAC,UAAU;CAId,MAAM,mBAAgC;EACpC,GAAG;EACH,SAAS;EACT,MAAM;EACN;EACD;CAGD,MAAM,YAAY,GAAG,MAAM;CAG3B,MAAM,WAAW,MAAM,MAAM,WAAW,iBAAiB;AAEzD,KAAI,CAAC,SAAS,IAAI;EAChB,MAAM,SAAS,MAAM,SAAS,MAAM;AAGpC,QAAM,IAAI,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,oBAAoB;;AAEtE,QAAO,MAAM,SAAS,MAAM"}
1
+ {"version":3,"file":"fetcher.mjs","names":[],"sources":["../../src/fetcher.ts"],"sourcesContent":["/**\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}`;\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();\n\n // You can customize the error message or include more details\n throw new Error(JSON.stringify(result.error) ?? 'An error occurred');\n }\n return await response.json();\n};\n"],"mappings":";;;;;;AAwBA,MAAa,iBAAiC;CAC5C,QAAQ;CACR,SAAS,EACP,gBAAgB,oBACjB;CACD,aAAa;CACd;;;;;;;;AASD,MAAM,mBAAmB,QAAgB;AACvC,QAAO,KAAK,IAAI,CAAC,SAAS,QAAQ;AAChC,MAAI,IAAI,SAA6B,OACnC,QAAO,IAAI;GAEb;AACF,QAAO;;;;;;;;;;AAWT,MAAM,aAA+B,YACnC,QAAQ,QAAQ,KAAK,QAAQ;CAC3B,MAAM,OAAW,OAAO,EAAE;CAC1B,MAAM,OAAU,gBAAgB,OAAO,EAAE,CAAC;AAE1C,KAAI,OAAO,SAAS,YAAY,OAAO,SAAS,SAE9C,QAAO;EAAE,GAAG;EAAM,GAAG;EAAM;AAI7B,QAAO,QAAQ;GACd,EAAE,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDb,MAAa,UAAU,OACrB,KACA,GAAG,YACY;CACf,MAAM,EAAE,WAAW,IAAI,iBAAiB;CAGxC,IAAI,eAAe;CACnB,IAAI;CAQJ,MAAM,gBAAgB,UAAU,CAAC,gBAAgB,GAL5B,QAAQ,KAC1B,EAAE,MAAM,QAAQ,SAAS,GAAG,mBAAmB,aAIc,CAAC,CAAC;CAGlE,MAAM,gBAAgB,UAAU,CAC9B,eAAe,SACf,GAAG,QAAQ,KAAK,WAAW,OAAO,QAAQ,CAC3C,CAAC;CAGF,MAAM,SAAS,UAAU,QAAQ,KAAK,WAAW,OAAO,OAAO,CAAC;CAEhE,MAAM,SAAS,cAAc;AAG7B,KAAI,WAAW,SAAS,WAAW,QAAQ;EAEzC,MAAM,OAAO,UAAU,QAAQ,KAAK,WAAW,OAAO,KAAK,CAAC;AAC5D,MACE,gBAAgB,oBAChB,oCAGA,cAAa,IAAI,gBACf,KACD,CAAC,UAAU;MAGZ,cAAa,KAAK,UAAU,KAAK;;AAKrC,KAAI,OAAO,QAAQ,OAAO,CAAC,SAAS,EAClC,gBAAe,IAAI,IAAI,gBACrB,OACD,CAAC,UAAU;CAId,MAAM,mBAAgC;EACpC,GAAG;EACH,SAAS;EACT,MAAM;EACN;EACD;CAGD,MAAM,YAAY,GAAG,MAAM;CAG3B,MAAM,WAAW,MAAM,MAAM,WAAW,iBAAiB;AAEzD,KAAI,CAAC,SAAS,IAAI;EAChB,MAAM,SAAS,MAAM,SAAS,MAAM;AAGpC,QAAM,IAAI,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,oBAAoB;;AAEtE,QAAO,MAAM,SAAS,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"audit.mjs","names":[],"sources":["../../../src/getIntlayerAPI/audit.ts"],"sourcesContent":["import type {\n AuditEvent,\n GetRecursiveAuditStatusResult,\n StartRecursiveAuditResult,\n} from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type {\n AuditEvent,\n GetRecursiveAuditStatusResult,\n StartRecursiveAuditResult,\n};\n\nexport type ScanUrlBody = {\n url: string;\n onMessage?: (event: AuditEvent) => void;\n onDone?: () => void;\n};\n\nexport type DiscoverUrlsParams = {\n url: string;\n};\n\nexport type DiscoverUrlsResult = {\n urls: string[];\n};\n\nexport type StartRecursiveAuditBody = {\n url: string;\n urls?: string[];\n};\n\nexport type GetRecursiveAuditStatusParams = {\n jobId: string;\n};\n\nexport type RecursiveAuditJobParams = {\n jobId: string;\n};\n\nexport const getAuditAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig: IntlayerConfig\n) => {\n const backendURL = intlayerConfig.editor.backendURL;\n\n const AUDIT_API_ROUTE = `${backendURL}/api/scan`;\n\n /**\n * Streams a single-page SEO audit as Server-Sent Events.\n *\n * Usage:\n * ```ts\n * await audit.scanUrl({\n * url: 'https://example.com',\n * onMessage: (event) => console.log(event),\n * onDone: () => console.log('done'),\n * });\n * ```\n */\n const discoverUrls = async (\n params?: DiscoverUrlsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DiscoverUrlsResult>(\n `${AUDIT_API_ROUTE}/recursive/discover`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n params,\n }\n );\n\n const scanUrl = async (\n body?: ScanUrlBody,\n otherOptions: FetcherOptions = {}\n ) => {\n if (!body?.url) return;\n\n const { url, onMessage, onDone } = body;\n\n const params = new URLSearchParams({ url });\n const endpoint = `${AUDIT_API_ROUTE}?${params.toString()}`;\n\n const response = await fetch(endpoint, {\n method: 'GET',\n headers: {\n Accept: 'text/event-stream',\n ...authAPIOptions.headers,\n ...otherOptions.headers,\n },\n credentials: 'include',\n signal: otherOptions.signal,\n });\n\n if (!response.ok) {\n let errorMessage = 'An error occurred';\n try {\n const errorData = await response.json();\n errorMessage = JSON.stringify(errorData.error) ?? errorMessage;\n } catch {\n try {\n const errorText = await response.text();\n if (errorText) errorMessage = errorText;\n } catch {\n // ignore\n }\n }\n throw new Error(errorMessage);\n }\n\n const reader = response.body?.getReader();\n if (!reader) throw new Error('No reader available');\n\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n try {\n const event = JSON.parse(line.slice(6)) as AuditEvent;\n onMessage?.(event);\n } catch {\n // ignore malformed lines\n }\n }\n }\n }\n\n onDone?.();\n };\n\n /**\n * Starts a recursive audit job for the given URL.\n */\n const startRecursiveAudit = async (\n body?: StartRecursiveAuditBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<StartRecursiveAuditResult>(\n `${AUDIT_API_ROUTE}/recursive/start`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n params: body?.url ? { url: body.url } : undefined,\n body: body?.urls !== undefined ? { urls: body.urls as any } : undefined,\n }\n );\n\n /**\n * Gets the status of a recursive audit job.\n */\n const getRecursiveAuditStatus = async (\n params?: GetRecursiveAuditStatusParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetRecursiveAuditStatusResult>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n const cancelRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/cancel`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const pauseRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/pause`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const resumeRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/resume`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n return {\n discoverUrls,\n scanUrl,\n startRecursiveAudit,\n getRecursiveAuditStatus,\n cancelRecursiveAudit,\n pauseRecursiveAudit,\n resumeRecursiveAudit,\n };\n};\n"],"mappings":";;;AAyCA,MAAa,eACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,kBAAkB,GAFL,eAAe,OAAO,WAEH;;;;;;;;;;;;;CActC,MAAM,eAAe,OACnB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,sBACnB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;CAEH,MAAM,UAAU,OACd,MACA,eAA+B,EAAE,KAC9B;AACH,MAAI,CAAC,MAAM,IAAK;EAEhB,MAAM,EAAE,KAAK,WAAW,WAAW;EAGnC,MAAM,WAAW,GAAG,gBAAgB,GADrB,IAAI,gBAAgB,EAAE,KAAK,CAAC,CACG,UAAU;EAExD,MAAM,WAAW,MAAM,MAAM,UAAU;GACrC,QAAQ;GACR,SAAS;IACP,QAAQ;IACR,GAAG,eAAe;IAClB,GAAG,aAAa;IACjB;GACD,aAAa;GACb,QAAQ,aAAa;GACtB,CAAC;AAEF,MAAI,CAAC,SAAS,IAAI;GAChB,IAAI,eAAe;AACnB,OAAI;IACF,MAAM,YAAY,MAAM,SAAS,MAAM;AACvC,mBAAe,KAAK,UAAU,UAAU,MAAM,IAAI;WAC5C;AACN,QAAI;KACF,MAAM,YAAY,MAAM,SAAS,MAAM;AACvC,SAAI,UAAW,gBAAe;YACxB;;AAIV,SAAM,IAAI,MAAM,aAAa;;EAG/B,MAAM,SAAS,SAAS,MAAM,WAAW;AACzC,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,sBAAsB;EAEnD,MAAM,UAAU,IAAI,aAAa;EACjC,IAAI,SAAS;AAEb,SAAO,MAAM;GACX,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,MAAM;AAE3C,OAAI,KAAM;AAEV,aAAU,QAAQ,OAAO,OAAO,EAAE,QAAQ,MAAM,CAAC;GACjD,MAAM,QAAQ,OAAO,MAAM,KAAK;AAChC,YAAS,MAAM,KAAK,IAAI;AAExB,QAAK,MAAM,QAAQ,MACjB,KAAI,KAAK,WAAW,SAAS,CAC3B,KAAI;IACF,MAAM,QAAQ,KAAK,MAAM,KAAK,MAAM,EAAE,CAAC;AACvC,gBAAY,MAAM;WACZ;;AAOd,YAAU;;;;;CAMZ,MAAM,sBAAsB,OAC1B,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,mBACnB,gBACA,cACA;EACE,QAAQ;EACR,QAAQ,MAAM,MAAM,EAAE,KAAK,KAAK,KAAK,GAAG;EACxC,MAAM,MAAM,SAAS,SAAY,EAAE,MAAM,KAAK,MAAa,GAAG;EAC/D,CACF;;;;CAKH,MAAM,0BAA0B,OAC9B,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,aAAa,QAAQ,SACxC,gBACA,cACA,EACE,QAAQ,OACT,CACF;CAEH,MAAM,uBAAuB,OAC3B,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,UAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,sBAAsB,OAC1B,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,SAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,uBAAuB,OAC3B,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,UAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"audit.mjs","names":[],"sources":["../../../src/getIntlayerAPI/audit.ts"],"sourcesContent":["import type {\n AuditEvent,\n GetRecursiveAuditStatusResult,\n StartRecursiveAuditResult,\n} from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type {\n AuditEvent,\n GetRecursiveAuditStatusResult,\n StartRecursiveAuditResult,\n};\n\nexport type ScanUrlBody = {\n url: string;\n onMessage?: (event: AuditEvent) => void;\n onDone?: () => void;\n};\n\nexport type DiscoverUrlsParams = {\n url: string;\n};\n\nexport type DiscoverUrlsResult = {\n urls: string[];\n};\n\nexport type StartRecursiveAuditBody = {\n url: string;\n urls?: string[];\n};\n\nexport type GetRecursiveAuditStatusParams = {\n jobId: string;\n};\n\nexport type RecursiveAuditJobParams = {\n jobId: string;\n};\n\nexport const getAuditAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig: IntlayerConfig\n) => {\n const backendURL = intlayerConfig.editor.backendURL;\n\n const AUDIT_API_ROUTE = `${backendURL}/api/scan`;\n\n /**\n * Streams a single-page SEO audit as Server-Sent Events.\n *\n * Usage:\n * ```ts\n * await audit.scanUrl({\n * url: 'https://example.com',\n * onMessage: (event) => console.log(event),\n * onDone: () => console.log('done'),\n * });\n * ```\n */\n const discoverUrls = async (\n params?: DiscoverUrlsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DiscoverUrlsResult>(\n `${AUDIT_API_ROUTE}/recursive/discover`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n params,\n }\n );\n\n const scanUrl = async (\n body?: ScanUrlBody,\n otherOptions: FetcherOptions = {}\n ) => {\n if (!body?.url) return;\n\n const { url, onMessage, onDone } = body;\n\n const params = new URLSearchParams({ url });\n const endpoint = `${AUDIT_API_ROUTE}?${params.toString()}`;\n\n const response = await fetch(endpoint, {\n method: 'GET',\n headers: {\n Accept: 'text/event-stream',\n ...authAPIOptions.headers,\n ...otherOptions.headers,\n },\n credentials: 'include',\n signal: otherOptions.signal,\n });\n\n if (!response.ok) {\n let errorMessage = 'An error occurred';\n try {\n const errorData = await response.json();\n errorMessage = JSON.stringify(errorData.error) ?? errorMessage;\n } catch {\n try {\n const errorText = await response.text();\n if (errorText) errorMessage = errorText;\n } catch {\n // ignore\n }\n }\n throw new Error(errorMessage);\n }\n\n const reader = response.body?.getReader();\n if (!reader) throw new Error('No reader available');\n\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n try {\n const event = JSON.parse(line.slice(6)) as AuditEvent;\n onMessage?.(event);\n } catch {\n // ignore malformed lines\n }\n }\n }\n }\n\n onDone?.();\n };\n\n /**\n * Starts a recursive audit job for the given URL.\n */\n const startRecursiveAudit = async (\n body?: StartRecursiveAuditBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<StartRecursiveAuditResult>(\n `${AUDIT_API_ROUTE}/recursive/start`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n params: body?.url ? { url: body.url } : undefined,\n body: body?.urls !== undefined ? { urls: body.urls as any } : undefined,\n }\n );\n\n /**\n * Gets the status of a recursive audit job.\n */\n const getRecursiveAuditStatus = async (\n params?: GetRecursiveAuditStatusParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetRecursiveAuditStatusResult>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n const cancelRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/cancel`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const pauseRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/pause`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const resumeRecursiveAudit = async (\n params?: RecursiveAuditJobParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ success: boolean }>(\n `${AUDIT_API_ROUTE}/recursive/${params?.jobId}/resume`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n return {\n discoverUrls,\n scanUrl,\n startRecursiveAudit,\n getRecursiveAuditStatus,\n cancelRecursiveAudit,\n pauseRecursiveAudit,\n resumeRecursiveAudit,\n };\n};\n"],"mappings":";;;AAyCA,MAAa,eACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,kBAAkB,GAFL,eAAe,OAAO,WAEH;;;;;;;;;;;;;CActC,MAAM,eAAe,OACnB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,sBACnB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;CAEH,MAAM,UAAU,OACd,MACA,eAA+B,EAAE,KAC9B;AACH,MAAI,CAAC,MAAM,IAAK;EAEhB,MAAM,EAAE,KAAK,WAAW,WAAW;EAGnC,MAAM,WAAW,GAAG,gBAAgB,GAAG,IADpB,gBAAgB,EAAE,KAAK,CACG,CAAC,UAAU;EAExD,MAAM,WAAW,MAAM,MAAM,UAAU;GACrC,QAAQ;GACR,SAAS;IACP,QAAQ;IACR,GAAG,eAAe;IAClB,GAAG,aAAa;IACjB;GACD,aAAa;GACb,QAAQ,aAAa;GACtB,CAAC;AAEF,MAAI,CAAC,SAAS,IAAI;GAChB,IAAI,eAAe;AACnB,OAAI;IACF,MAAM,YAAY,MAAM,SAAS,MAAM;AACvC,mBAAe,KAAK,UAAU,UAAU,MAAM,IAAI;WAC5C;AACN,QAAI;KACF,MAAM,YAAY,MAAM,SAAS,MAAM;AACvC,SAAI,UAAW,gBAAe;YACxB;;AAIV,SAAM,IAAI,MAAM,aAAa;;EAG/B,MAAM,SAAS,SAAS,MAAM,WAAW;AACzC,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,sBAAsB;EAEnD,MAAM,UAAU,IAAI,aAAa;EACjC,IAAI,SAAS;AAEb,SAAO,MAAM;GACX,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,MAAM;AAE3C,OAAI,KAAM;AAEV,aAAU,QAAQ,OAAO,OAAO,EAAE,QAAQ,MAAM,CAAC;GACjD,MAAM,QAAQ,OAAO,MAAM,KAAK;AAChC,YAAS,MAAM,KAAK,IAAI;AAExB,QAAK,MAAM,QAAQ,MACjB,KAAI,KAAK,WAAW,SAAS,CAC3B,KAAI;IACF,MAAM,QAAQ,KAAK,MAAM,KAAK,MAAM,EAAE,CAAC;AACvC,gBAAY,MAAM;WACZ;;AAOd,YAAU;;;;;CAMZ,MAAM,sBAAsB,OAC1B,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,mBACnB,gBACA,cACA;EACE,QAAQ;EACR,QAAQ,MAAM,MAAM,EAAE,KAAK,KAAK,KAAK,GAAG;EACxC,MAAM,MAAM,SAAS,SAAY,EAAE,MAAM,KAAK,MAAa,GAAG;EAC/D,CACF;;;;CAKH,MAAM,0BAA0B,OAC9B,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,aAAa,QAAQ,SACxC,gBACA,cACA,EACE,QAAQ,OACT,CACF;CAEH,MAAM,uBAAuB,OAC3B,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,UAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,sBAAsB,OAC1B,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,SAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,uBAAuB,OAC3B,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,gBAAgB,aAAa,QAAQ,MAAM,UAC9C,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"editor.mjs","names":[],"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from 'intlayer-editor';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig: IntlayerConfig\n) => {\n const editorURL = intlayerConfig.editor.editorURL;\n\n if (!editorURL) {\n throw new Error('Editor URL is not defined in the Intlayer configuration.');\n }\n\n const EDITOR_API_ROUTE = `${editorURL}/api`;\n\n /**\n * Get the Intlayer configuration\n */\n const getConfiguration = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetConfigurationResult> => {\n const response = await fetcher<GetConfigurationResult>(\n `${EDITOR_API_ROUTE}/config`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetConfigurationResult;\n };\n\n /**\n * Get the Intlayer configuration\n */\n const getDictionaries = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetEditorDictionariesResult> => {\n const response = await fetcher<GetEditorDictionariesResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetEditorDictionariesResult;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n body: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n return {\n getDictionaries,\n getConfiguration,\n writeDictionary,\n };\n};\n"],"mappings":";;;AASA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,YAAY,eAAe,OAAO;AAExC,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,2DAA2D;CAG7E,MAAM,mBAAmB,GAAG,UAAU;;;;CAKtC,MAAM,mBAAmB,OACvB,eAA+B,EAAE,KACG;AAOpC,UANiB,MAAM,QACrB,GAAG,iBAAiB,UACpB,gBACA,aACD,EAEe;;;;;CAMlB,MAAM,kBAAkB,OACtB,eAA+B,EAAE,KACQ;AAOzC,UANiB,MAAM,QACrB,GAAG,iBAAiB,cACpB,gBACA,aACD,EAEe;;;;;;CAOlB,MAAM,kBAAkB,OACtB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,cACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD"}
1
+ {"version":3,"file":"editor.mjs","names":[],"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from 'intlayer-editor';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig: IntlayerConfig\n) => {\n const editorURL = intlayerConfig.editor.editorURL;\n\n if (!editorURL) {\n throw new Error('Editor URL is not defined in the Intlayer configuration.');\n }\n\n const EDITOR_API_ROUTE = `${editorURL}/api`;\n\n /**\n * Get the Intlayer configuration\n */\n const getConfiguration = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetConfigurationResult> => {\n const response = await fetcher<GetConfigurationResult>(\n `${EDITOR_API_ROUTE}/config`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetConfigurationResult;\n };\n\n /**\n * Get the Intlayer configuration\n */\n const getDictionaries = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetEditorDictionariesResult> => {\n const response = await fetcher<GetEditorDictionariesResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetEditorDictionariesResult;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n body: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n return {\n getDictionaries,\n getConfiguration,\n writeDictionary,\n };\n};\n"],"mappings":";;;AASA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,YAAY,eAAe,OAAO;AAExC,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,2DAA2D;CAG7E,MAAM,mBAAmB,GAAG,UAAU;;;;CAKtC,MAAM,mBAAmB,OACvB,eAA+B,EAAE,KACG;AAOpC,UAAO,MANgB,QACrB,GAAG,iBAAiB,UACpB,gBACA,aACD,EAEe;;;;;CAMlB,MAAM,kBAAkB,OACtB,eAA+B,EAAE,KACQ;AAOzC,UAAO,MANgB,QACrB,GAAG,iBAAiB,cACpB,gBACA,aACD,EAEe;;;;;;CAOlB,MAAM,kBAAkB,OACtB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,cACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD"}
@@ -13,6 +13,7 @@ import { getSearchAPI } from "./search.mjs";
13
13
  import { getShowcaseProjectAPI } from "./showcaseProject.mjs";
14
14
  import { getStripeAPI } from "./stripe.mjs";
15
15
  import { getTagAPI } from "./tag.mjs";
16
+ import { getTranslateAPI } from "./translate.mjs";
16
17
  import { getUserAPI } from "./user.mjs";
17
18
  import defaultConfiguration from "@intlayer/config/built";
18
19
  import { defu } from "defu";
@@ -36,7 +37,8 @@ const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => {
36
37
  github: getGithubAPI(authAPIOptions, resolvedConfig),
37
38
  gitlab: getGitlabAPI(authAPIOptions, resolvedConfig),
38
39
  bitbucket: getBitbucketAPI(authAPIOptions, resolvedConfig),
39
- showcaseProject: getShowcaseProjectAPI(authAPIOptions, resolvedConfig)
40
+ showcaseProject: getShowcaseProjectAPI(authAPIOptions, resolvedConfig),
41
+ translate: getTranslateAPI(authAPIOptions, resolvedConfig)
40
42
  };
41
43
  };
42
44
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import { default as defaultConfiguration } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getAuditAPI } from './audit';\nimport { getBitbucketAPI } from './bitbucket';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getGithubAPI } from './github';\nimport { getGitlabAPI } from './gitlab';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getSearchAPI } from './search';\nimport { getShowcaseProjectAPI } from './showcaseProject';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n audit: ReturnType<typeof getAuditAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n github: ReturnType<typeof getGithubAPI>;\n gitlab: ReturnType<typeof getGitlabAPI>;\n bitbucket: ReturnType<typeof getBitbucketAPI>;\n showcaseProject: ReturnType<typeof getShowcaseProjectAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPIReturn => {\n const resolvedConfig = defu(\n intlayerConfig ?? {},\n defaultConfiguration\n ) as IntlayerConfig;\n\n return {\n organization: getOrganizationAPI(authAPIOptions, resolvedConfig),\n project: getProjectAPI(authAPIOptions, resolvedConfig),\n user: getUserAPI(authAPIOptions, resolvedConfig),\n oAuth: getOAuthAPI(resolvedConfig),\n dictionary: getDictionaryAPI(authAPIOptions, resolvedConfig),\n stripe: getStripeAPI(authAPIOptions, resolvedConfig),\n ai: getAiAPI(authAPIOptions, resolvedConfig),\n audit: getAuditAPI(authAPIOptions, resolvedConfig),\n tag: getTagAPI(authAPIOptions, resolvedConfig),\n search: getSearchAPI(authAPIOptions, resolvedConfig),\n editor: getEditorAPI(authAPIOptions, resolvedConfig),\n newsletter: getNewsletterAPI(authAPIOptions, resolvedConfig),\n github: getGithubAPI(authAPIOptions, resolvedConfig),\n gitlab: getGitlabAPI(authAPIOptions, resolvedConfig),\n bitbucket: getBitbucketAPI(authAPIOptions, resolvedConfig),\n showcaseProject: getShowcaseProjectAPI(authAPIOptions, resolvedConfig),\n };\n};\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,kBACX,iBAAiC,EAAE,EACnC,mBACsB;CACtB,MAAM,iBAAiB,KACrB,kBAAkB,EAAE,EACpB,qBACD;AAED,QAAO;EACL,cAAc,mBAAmB,gBAAgB,eAAe;EAChE,SAAS,cAAc,gBAAgB,eAAe;EACtD,MAAM,WAAW,gBAAgB,eAAe;EAChD,OAAO,YAAY,eAAe;EAClC,YAAY,iBAAiB,gBAAgB,eAAe;EAC5D,QAAQ,aAAa,gBAAgB,eAAe;EACpD,IAAI,SAAS,gBAAgB,eAAe;EAC5C,OAAO,YAAY,gBAAgB,eAAe;EAClD,KAAK,UAAU,gBAAgB,eAAe;EAC9C,QAAQ,aAAa,gBAAgB,eAAe;EACpD,QAAQ,aAAa,gBAAgB,eAAe;EACpD,YAAY,iBAAiB,gBAAgB,eAAe;EAC5D,QAAQ,aAAa,gBAAgB,eAAe;EACpD,QAAQ,aAAa,gBAAgB,eAAe;EACpD,WAAW,gBAAgB,gBAAgB,eAAe;EAC1D,iBAAiB,sBAAsB,gBAAgB,eAAe;EACvE"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import { default as defaultConfiguration } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getAuditAPI } from './audit';\nimport { getBitbucketAPI } from './bitbucket';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getGithubAPI } from './github';\nimport { getGitlabAPI } from './gitlab';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getSearchAPI } from './search';\nimport { getShowcaseProjectAPI } from './showcaseProject';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getTranslateAPI } from './translate';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n audit: ReturnType<typeof getAuditAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n github: ReturnType<typeof getGithubAPI>;\n gitlab: ReturnType<typeof getGitlabAPI>;\n bitbucket: ReturnType<typeof getBitbucketAPI>;\n showcaseProject: ReturnType<typeof getShowcaseProjectAPI>;\n translate: ReturnType<typeof getTranslateAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPIReturn => {\n const resolvedConfig = defu(\n intlayerConfig ?? {},\n defaultConfiguration\n ) as IntlayerConfig;\n\n return {\n organization: getOrganizationAPI(authAPIOptions, resolvedConfig),\n project: getProjectAPI(authAPIOptions, resolvedConfig),\n user: getUserAPI(authAPIOptions, resolvedConfig),\n oAuth: getOAuthAPI(resolvedConfig),\n dictionary: getDictionaryAPI(authAPIOptions, resolvedConfig),\n stripe: getStripeAPI(authAPIOptions, resolvedConfig),\n ai: getAiAPI(authAPIOptions, resolvedConfig),\n audit: getAuditAPI(authAPIOptions, resolvedConfig),\n tag: getTagAPI(authAPIOptions, resolvedConfig),\n search: getSearchAPI(authAPIOptions, resolvedConfig),\n editor: getEditorAPI(authAPIOptions, resolvedConfig),\n newsletter: getNewsletterAPI(authAPIOptions, resolvedConfig),\n github: getGithubAPI(authAPIOptions, resolvedConfig),\n gitlab: getGitlabAPI(authAPIOptions, resolvedConfig),\n bitbucket: getBitbucketAPI(authAPIOptions, resolvedConfig),\n showcaseProject: getShowcaseProjectAPI(authAPIOptions, resolvedConfig),\n translate: getTranslateAPI(authAPIOptions, resolvedConfig),\n };\n};\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,kBACX,iBAAiC,EAAE,EACnC,mBACsB;CACtB,MAAM,iBAAiB,KACrB,kBAAkB,EAAE,EACpB,qBACD;AAED,QAAO;EACL,cAAc,mBAAmB,gBAAgB,eAAe;EAChE,SAAS,cAAc,gBAAgB,eAAe;EACtD,MAAM,WAAW,gBAAgB,eAAe;EAChD,OAAO,YAAY,eAAe;EAClC,YAAY,iBAAiB,gBAAgB,eAAe;EAC5D,QAAQ,aAAa,gBAAgB,eAAe;EACpD,IAAI,SAAS,gBAAgB,eAAe;EAC5C,OAAO,YAAY,gBAAgB,eAAe;EAClD,KAAK,UAAU,gBAAgB,eAAe;EAC9C,QAAQ,aAAa,gBAAgB,eAAe;EACpD,QAAQ,aAAa,gBAAgB,eAAe;EACpD,YAAY,iBAAiB,gBAAgB,eAAe;EAC5D,QAAQ,aAAa,gBAAgB,eAAe;EACpD,QAAQ,aAAa,gBAAgB,eAAe;EACpD,WAAW,gBAAgB,gBAAgB,eAAe;EAC1D,iBAAiB,sBAAsB,gBAAgB,eAAe;EACtE,WAAW,gBAAgB,gBAAgB,eAAe;EAC3D"}
@@ -0,0 +1,27 @@
1
+ import { fetcher } from "../fetcher.mjs";
2
+
3
+ //#region src/getIntlayerAPI/translate.ts
4
+ const getTranslateAPI = (authAPIOptions = {}, intlayerConfig) => {
5
+ const TRANSLATE_API_ROUTE = `${intlayerConfig.editor.backendURL}/api/translate`;
6
+ const translateDictionaries = async (body, otherOptions = {}) => fetcher(`${TRANSLATE_API_ROUTE}/dictionaries`, authAPIOptions, otherOptions, {
7
+ method: "POST",
8
+ body
9
+ });
10
+ const pauseTranslationJob = async (jobId, otherOptions = {}) => fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/pause`, authAPIOptions, otherOptions, { method: "POST" });
11
+ const resumeTranslationJob = async (jobId, otherOptions = {}) => fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/resume`, authAPIOptions, otherOptions, { method: "POST" });
12
+ const stopTranslationJob = async (jobId, otherOptions = {}) => fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/stop`, authAPIOptions, otherOptions, { method: "POST" });
13
+ const retryTranslationJob = async (jobId, otherOptions = {}) => fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/retry`, authAPIOptions, otherOptions, { method: "POST" });
14
+ const restartTranslationJob = async (jobId, otherOptions = {}) => fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/restart`, authAPIOptions, otherOptions, { method: "POST" });
15
+ return {
16
+ translateDictionaries,
17
+ pauseTranslationJob,
18
+ resumeTranslationJob,
19
+ stopTranslationJob,
20
+ retryTranslationJob,
21
+ restartTranslationJob
22
+ };
23
+ };
24
+
25
+ //#endregion
26
+ export { getTranslateAPI };
27
+ //# sourceMappingURL=translate.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.mjs","names":[],"sources":["../../../src/getIntlayerAPI/translate.ts"],"sourcesContent":["import type {\n TranslateDictionariesBody,\n TranslateDictionariesResult,\n} from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type { TranslateDictionariesBody, TranslateDictionariesResult };\n\nexport const getTranslateAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig: IntlayerConfig\n) => {\n const backendURL = intlayerConfig.editor.backendURL;\n\n const TRANSLATE_API_ROUTE = `${backendURL}/api/translate`;\n\n const translateDictionaries = async (\n body: TranslateDictionariesBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<TranslateDictionariesResult>(\n `${TRANSLATE_API_ROUTE}/dictionaries`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const pauseTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/pause`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const resumeTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/resume`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const stopTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/stop`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const retryTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/retry`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const restartTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/restart`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n return {\n translateDictionaries,\n pauseTranslationJob,\n resumeTranslationJob,\n stopTranslationJob,\n retryTranslationJob,\n restartTranslationJob,\n };\n};\n"],"mappings":";;;AASA,MAAa,mBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,sBAAsB,GAFT,eAAe,OAAO,WAEC;CAE1C,MAAM,wBAAwB,OAC5B,MACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,gBACvB,gBACA,cACA;EAAE,QAAQ;EAAQ;EAAM,CACzB;CAEH,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,uBAAuB,OAC3B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,UAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,qBAAqB,OACzB,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,QAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,wBAAwB,OAC5B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,WAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -13,10 +13,11 @@ import { getProjectAPI } from "./getIntlayerAPI/project.mjs";
13
13
  import { getSearchAPI } from "./getIntlayerAPI/search.mjs";
14
14
  import { getStripeAPI } from "./getIntlayerAPI/stripe.mjs";
15
15
  import { getTagAPI } from "./getIntlayerAPI/tag.mjs";
16
+ import { getTranslateAPI } from "./getIntlayerAPI/translate.mjs";
16
17
  import { getUserAPI } from "./getIntlayerAPI/user.mjs";
17
18
  import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
18
19
  import { getIntlayerAPIProxy } from "./proxy.mjs";
19
20
  import { fetchDistantDictionaries } from "./distantDictionary/fetchDistantDictionaries.mjs";
20
21
  import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.mjs";
21
22
 
22
- export { fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getSearchAPI, getStripeAPI, getTagAPI, getUserAPI };
23
+ export { fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getSearchAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI };
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.mjs","names":[],"sources":["../../src/proxy.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport type { FetcherOptions } from './fetcher';\nimport { getIntlayerAPI } from './getIntlayerAPI';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\n\ntype OAuthTokenLike = {\n accessToken?: string;\n accessTokenExpiresAt?: string | Date;\n expires_in?: number;\n expiresIn?: number;\n expiresAt?: string | Date;\n};\n\nconst ONE_MINUTE_MS = 60_000;\n\n/**\n * Returns the expiration timestamp in ms from an OAuth token-like object.\n */\nconst getExpiryTimestamp = (\n token: OAuthTokenLike | undefined\n): number | undefined => {\n if (!token) return undefined;\n const dateLike = (token.accessTokenExpiresAt ?? token.expiresAt) as\n | string\n | Date\n | undefined;\n if (dateLike) {\n const ts =\n typeof dateLike === 'string'\n ? Date.parse(dateLike)\n : dateLike.getTime?.();\n if (typeof ts === 'number' && Number.isFinite(ts)) return ts;\n }\n const seconds = token.expires_in ?? token.expiresIn;\n if (typeof seconds === 'number' && Number.isFinite(seconds)) {\n return Date.now() + seconds * 1000;\n }\n return undefined;\n};\n\nlet currentAccessToken: string | undefined;\nlet currentExpiryTs: number | undefined;\nlet pendingRefresh: Promise<void> | undefined;\n\n/**\n * Build an auto-auth proxy around getIntlayerAPI that:\n * - Fetches an OAuth2 token when needed\n * - Injects Authorization header for each request\n * - Refreshes token proactively when near expiry\n *\n * The returned API matches the shape of getIntlayerAPI.\n */\nexport const getIntlayerAPIProxy = (\n baseAuthOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPI => {\n // Use a shared mutable auth options object captured by the API closures\n const authOptionsRef: FetcherOptions = { ...baseAuthOptions };\n const hasCMSAuth =\n intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;\n const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);\n\n const needsRefresh = (): boolean => {\n if (!currentAccessToken) return true;\n if (!currentExpiryTs) return false; // If unknown, assume usable until failure\n\n return Date.now() + ONE_MINUTE_MS >= currentExpiryTs; // refresh 1 min before expiry\n };\n\n const refreshToken = async (): Promise<void> => {\n const doRefresh = async () => {\n const authApi = getOAuthAPI(intlayerConfig);\n const res = await authApi.getOAuth2AccessToken();\n const tokenData = res?.data as OAuthTokenLike | undefined;\n\n currentAccessToken = tokenData?.accessToken;\n currentExpiryTs = getExpiryTimestamp(tokenData);\n };\n\n if (!pendingRefresh) {\n pendingRefresh = doRefresh().finally(() => {\n pendingRefresh = undefined;\n });\n }\n await pendingRefresh;\n };\n\n const ensureValidToken = async () => {\n if (needsRefresh()) {\n await refreshToken();\n }\n };\n\n const applyAuthHeaderToRef = () => {\n if (!currentAccessToken) return;\n authOptionsRef.headers = {\n ...(authOptionsRef.headers ?? {}),\n Authorization: `Bearer ${currentAccessToken}`,\n } as HeadersInit;\n };\n\n const wrapSection = <T extends Record<string, unknown>>(\n section: T,\n skipAuth = !hasCMSAuth\n ): T => {\n return new Proxy(section, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === 'function') {\n // Wrap section method to inject token and headers\n return async (...args: unknown[]) => {\n if (!skipAuth) {\n await ensureValidToken();\n applyAuthHeaderToRef();\n }\n\n try {\n return await value.apply(target, args);\n } catch (err) {\n // Best-effort retry: if token might be stale, refresh once and retry\n if (!skipAuth) {\n await refreshToken();\n applyAuthHeaderToRef();\n return await value.apply(target, args);\n }\n throw err;\n }\n };\n }\n\n return value;\n },\n });\n };\n\n return {\n organization: wrapSection(baseApi.organization),\n project: wrapSection(baseApi.project),\n user: wrapSection(baseApi.user),\n oAuth: wrapSection(baseApi.oAuth, true), // do NOT inject auth for token endpoint\n dictionary: wrapSection(baseApi.dictionary),\n stripe: wrapSection(baseApi.stripe),\n ai: wrapSection(baseApi.ai),\n tag: wrapSection(baseApi.tag),\n search: wrapSection(baseApi.search),\n editor: wrapSection(baseApi.editor),\n newsletter: wrapSection(baseApi.newsletter),\n github: wrapSection(baseApi.github),\n } as IntlayerAPI;\n};\n\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":";;;;AAcA,MAAM,gBAAgB;;;;AAKtB,MAAM,sBACJ,UACuB;AACvB,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,WAAY,MAAM,wBAAwB,MAAM;AAItD,KAAI,UAAU;EACZ,MAAM,KACJ,OAAO,aAAa,WAChB,KAAK,MAAM,SAAS,GACpB,SAAS,WAAW;AAC1B,MAAI,OAAO,OAAO,YAAY,OAAO,SAAS,GAAG,CAAE,QAAO;;CAE5D,MAAM,UAAU,MAAM,cAAc,MAAM;AAC1C,KAAI,OAAO,YAAY,YAAY,OAAO,SAAS,QAAQ,CACzD,QAAO,KAAK,KAAK,GAAG,UAAU;;AAKlC,IAAI;AACJ,IAAI;AACJ,IAAI;;;;;;;;;AAUJ,MAAa,uBACX,kBAAkC,EAAE,EACpC,mBACgB;CAEhB,MAAM,iBAAiC,EAAE,GAAG,iBAAiB;CAC7D,MAAM,aACJ,gBAAgB,QAAQ,YAAY,gBAAgB,QAAQ;CAC9D,MAAM,UAAU,eAAe,gBAAgB,eAAe;CAE9D,MAAM,qBAA8B;AAClC,MAAI,CAAC,mBAAoB,QAAO;AAChC,MAAI,CAAC,gBAAiB,QAAO;AAE7B,SAAO,KAAK,KAAK,GAAG,iBAAiB;;CAGvC,MAAM,eAAe,YAA2B;EAC9C,MAAM,YAAY,YAAY;GAG5B,MAAM,aADM,MADI,YAAY,eAAe,CACjB,sBAAsB,GACzB;AAEvB,wBAAqB,WAAW;AAChC,qBAAkB,mBAAmB,UAAU;;AAGjD,MAAI,CAAC,eACH,kBAAiB,WAAW,CAAC,cAAc;AACzC,oBAAiB;IACjB;AAEJ,QAAM;;CAGR,MAAM,mBAAmB,YAAY;AACnC,MAAI,cAAc,CAChB,OAAM,cAAc;;CAIxB,MAAM,6BAA6B;AACjC,MAAI,CAAC,mBAAoB;AACzB,iBAAe,UAAU;GACvB,GAAI,eAAe,WAAW,EAAE;GAChC,eAAe,UAAU;GAC1B;;CAGH,MAAM,eACJ,SACA,WAAW,CAAC,eACN;AACN,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;GAC1B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,SAAS;AAEjD,OAAI,OAAO,UAAU,WAEnB,QAAO,OAAO,GAAG,SAAoB;AACnC,QAAI,CAAC,UAAU;AACb,WAAM,kBAAkB;AACxB,2BAAsB;;AAGxB,QAAI;AACF,YAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;aAC/B,KAAK;AAEZ,SAAI,CAAC,UAAU;AACb,YAAM,cAAc;AACpB,4BAAsB;AACtB,aAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;;AAExC,WAAM;;;AAKZ,UAAO;KAEV,CAAC;;AAGJ,QAAO;EACL,cAAc,YAAY,QAAQ,aAAa;EAC/C,SAAS,YAAY,QAAQ,QAAQ;EACrC,MAAM,YAAY,QAAQ,KAAK;EAC/B,OAAO,YAAY,QAAQ,OAAO,KAAK;EACvC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACnC,IAAI,YAAY,QAAQ,GAAG;EAC3B,KAAK,YAAY,QAAQ,IAAI;EAC7B,QAAQ,YAAY,QAAQ,OAAO;EACnC,QAAQ,YAAY,QAAQ,OAAO;EACnC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACpC"}
1
+ {"version":3,"file":"proxy.mjs","names":[],"sources":["../../src/proxy.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport type { FetcherOptions } from './fetcher';\nimport { getIntlayerAPI } from './getIntlayerAPI';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\n\ntype OAuthTokenLike = {\n accessToken?: string;\n accessTokenExpiresAt?: string | Date;\n expires_in?: number;\n expiresIn?: number;\n expiresAt?: string | Date;\n};\n\nconst ONE_MINUTE_MS = 60_000;\n\n/**\n * Returns the expiration timestamp in ms from an OAuth token-like object.\n */\nconst getExpiryTimestamp = (\n token: OAuthTokenLike | undefined\n): number | undefined => {\n if (!token) return undefined;\n const dateLike = (token.accessTokenExpiresAt ?? token.expiresAt) as\n | string\n | Date\n | undefined;\n if (dateLike) {\n const ts =\n typeof dateLike === 'string'\n ? Date.parse(dateLike)\n : dateLike.getTime?.();\n if (typeof ts === 'number' && Number.isFinite(ts)) return ts;\n }\n const seconds = token.expires_in ?? token.expiresIn;\n if (typeof seconds === 'number' && Number.isFinite(seconds)) {\n return Date.now() + seconds * 1000;\n }\n return undefined;\n};\n\nlet currentAccessToken: string | undefined;\nlet currentExpiryTs: number | undefined;\nlet pendingRefresh: Promise<void> | undefined;\n\n/**\n * Build an auto-auth proxy around getIntlayerAPI that:\n * - Fetches an OAuth2 token when needed\n * - Injects Authorization header for each request\n * - Refreshes token proactively when near expiry\n *\n * The returned API matches the shape of getIntlayerAPI.\n */\nexport const getIntlayerAPIProxy = (\n baseAuthOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPI => {\n // Use a shared mutable auth options object captured by the API closures\n const authOptionsRef: FetcherOptions = { ...baseAuthOptions };\n const hasCMSAuth =\n intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;\n const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);\n\n const needsRefresh = (): boolean => {\n if (!currentAccessToken) return true;\n if (!currentExpiryTs) return false; // If unknown, assume usable until failure\n\n return Date.now() + ONE_MINUTE_MS >= currentExpiryTs; // refresh 1 min before expiry\n };\n\n const refreshToken = async (): Promise<void> => {\n const doRefresh = async () => {\n const authApi = getOAuthAPI(intlayerConfig);\n const res = await authApi.getOAuth2AccessToken();\n const tokenData = res?.data as OAuthTokenLike | undefined;\n\n currentAccessToken = tokenData?.accessToken;\n currentExpiryTs = getExpiryTimestamp(tokenData);\n };\n\n if (!pendingRefresh) {\n pendingRefresh = doRefresh().finally(() => {\n pendingRefresh = undefined;\n });\n }\n await pendingRefresh;\n };\n\n const ensureValidToken = async () => {\n if (needsRefresh()) {\n await refreshToken();\n }\n };\n\n const applyAuthHeaderToRef = () => {\n if (!currentAccessToken) return;\n authOptionsRef.headers = {\n ...(authOptionsRef.headers ?? {}),\n Authorization: `Bearer ${currentAccessToken}`,\n } as HeadersInit;\n };\n\n const wrapSection = <T extends Record<string, unknown>>(\n section: T,\n skipAuth = !hasCMSAuth\n ): T => {\n return new Proxy(section, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === 'function') {\n // Wrap section method to inject token and headers\n return async (...args: unknown[]) => {\n if (!skipAuth) {\n await ensureValidToken();\n applyAuthHeaderToRef();\n }\n\n try {\n return await value.apply(target, args);\n } catch (err) {\n // Best-effort retry: if token might be stale, refresh once and retry\n if (!skipAuth) {\n await refreshToken();\n applyAuthHeaderToRef();\n return await value.apply(target, args);\n }\n throw err;\n }\n };\n }\n\n return value;\n },\n });\n };\n\n return {\n organization: wrapSection(baseApi.organization),\n project: wrapSection(baseApi.project),\n user: wrapSection(baseApi.user),\n oAuth: wrapSection(baseApi.oAuth, true), // do NOT inject auth for token endpoint\n dictionary: wrapSection(baseApi.dictionary),\n stripe: wrapSection(baseApi.stripe),\n ai: wrapSection(baseApi.ai),\n tag: wrapSection(baseApi.tag),\n search: wrapSection(baseApi.search),\n editor: wrapSection(baseApi.editor),\n newsletter: wrapSection(baseApi.newsletter),\n github: wrapSection(baseApi.github),\n } as IntlayerAPI;\n};\n\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":";;;;AAcA,MAAM,gBAAgB;;;;AAKtB,MAAM,sBACJ,UACuB;AACvB,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,WAAY,MAAM,wBAAwB,MAAM;AAItD,KAAI,UAAU;EACZ,MAAM,KACJ,OAAO,aAAa,WAChB,KAAK,MAAM,SAAS,GACpB,SAAS,WAAW;AAC1B,MAAI,OAAO,OAAO,YAAY,OAAO,SAAS,GAAG,CAAE,QAAO;;CAE5D,MAAM,UAAU,MAAM,cAAc,MAAM;AAC1C,KAAI,OAAO,YAAY,YAAY,OAAO,SAAS,QAAQ,CACzD,QAAO,KAAK,KAAK,GAAG,UAAU;;AAKlC,IAAI;AACJ,IAAI;AACJ,IAAI;;;;;;;;;AAUJ,MAAa,uBACX,kBAAkC,EAAE,EACpC,mBACgB;CAEhB,MAAM,iBAAiC,EAAE,GAAG,iBAAiB;CAC7D,MAAM,aACJ,gBAAgB,QAAQ,YAAY,gBAAgB,QAAQ;CAC9D,MAAM,UAAU,eAAe,gBAAgB,eAAe;CAE9D,MAAM,qBAA8B;AAClC,MAAI,CAAC,mBAAoB,QAAO;AAChC,MAAI,CAAC,gBAAiB,QAAO;AAE7B,SAAO,KAAK,KAAK,GAAG,iBAAiB;;CAGvC,MAAM,eAAe,YAA2B;EAC9C,MAAM,YAAY,YAAY;GAG5B,MAAM,aAAY,MAFF,YAAY,eACH,CAAC,sBAAsB,GACzB;AAEvB,wBAAqB,WAAW;AAChC,qBAAkB,mBAAmB,UAAU;;AAGjD,MAAI,CAAC,eACH,kBAAiB,WAAW,CAAC,cAAc;AACzC,oBAAiB;IACjB;AAEJ,QAAM;;CAGR,MAAM,mBAAmB,YAAY;AACnC,MAAI,cAAc,CAChB,OAAM,cAAc;;CAIxB,MAAM,6BAA6B;AACjC,MAAI,CAAC,mBAAoB;AACzB,iBAAe,UAAU;GACvB,GAAI,eAAe,WAAW,EAAE;GAChC,eAAe,UAAU;GAC1B;;CAGH,MAAM,eACJ,SACA,WAAW,CAAC,eACN;AACN,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;GAC1B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,SAAS;AAEjD,OAAI,OAAO,UAAU,WAEnB,QAAO,OAAO,GAAG,SAAoB;AACnC,QAAI,CAAC,UAAU;AACb,WAAM,kBAAkB;AACxB,2BAAsB;;AAGxB,QAAI;AACF,YAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;aAC/B,KAAK;AAEZ,SAAI,CAAC,UAAU;AACb,YAAM,cAAc;AACpB,4BAAsB;AACtB,aAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;;AAExC,WAAM;;;AAKZ,UAAO;KAEV,CAAC;;AAGJ,QAAO;EACL,cAAc,YAAY,QAAQ,aAAa;EAC/C,SAAS,YAAY,QAAQ,QAAQ;EACrC,MAAM,YAAY,QAAQ,KAAK;EAC/B,OAAO,YAAY,QAAQ,OAAO,KAAK;EACvC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACnC,IAAI,YAAY,QAAQ,GAAG;EAC3B,KAAK,YAAY,QAAQ,IAAI;EAC7B,QAAQ,YAAY,QAAQ,OAAO;EACnC,QAAQ,YAAY,QAAQ,OAAO;EACnC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACpC"}
@@ -14,6 +14,7 @@ import { getSearchAPI } from "./search.js";
14
14
  import { getShowcaseProjectAPI } from "./showcaseProject.js";
15
15
  import { getStripeAPI } from "./stripe.js";
16
16
  import { getTagAPI } from "./tag.js";
17
+ import { getTranslateAPI } from "./translate.js";
17
18
  import { getUserAPI } from "./user.js";
18
19
  import { IntlayerConfig } from "@intlayer/types/config";
19
20
 
@@ -35,6 +36,7 @@ interface IntlayerAPIReturn {
35
36
  gitlab: ReturnType<typeof getGitlabAPI>;
36
37
  bitbucket: ReturnType<typeof getBitbucketAPI>;
37
38
  showcaseProject: ReturnType<typeof getShowcaseProjectAPI>;
39
+ translate: ReturnType<typeof getTranslateAPI>;
38
40
  }
39
41
  declare const getIntlayerAPI: (authAPIOptions?: FetcherOptions, intlayerConfig?: IntlayerConfig) => IntlayerAPIReturn;
40
42
  type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/getIntlayerAPI/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;UAqBU,iBAAA;EACR,YAAA,EAAc,UAAA,QAAkB,kBAAA;EAChC,OAAA,EAAS,UAAA,QAAkB,aAAA;EAC3B,IAAA,EAAM,UAAA,QAAkB,UAAA;EACxB,KAAA,EAAO,UAAA,QAAkB,WAAA;EACzB,UAAA,EAAY,UAAA,QAAkB,gBAAA;EAC9B,MAAA,EAAQ,UAAA,QAAkB,YAAA;EAC1B,EAAA,EAAI,UAAA,QAAkB,QAAA;EACtB,KAAA,EAAO,UAAA,QAAkB,WAAA;EACzB,GAAA,EAAK,UAAA,QAAkB,SAAA;EACvB,MAAA,EAAQ,UAAA,QAAkB,YAAA;EAC1B,MAAA,EAAQ,UAAA,QAAkB,YAAA;EAC1B,UAAA,EAAY,UAAA,QAAkB,gBAAA;EAC9B,MAAA,EAAQ,UAAA,QAAkB,YAAA;EAC1B,MAAA,EAAQ,UAAA,QAAkB,YAAA;EAC1B,SAAA,EAAW,UAAA,QAAkB,eAAA;EAC7B,eAAA,EAAiB,UAAA,QAAkB,qBAAA;AAAA;AAAA,cAGxB,cAAA,GACX,cAAA,GAAgB,cAAA,EAChB,cAAA,GAAiB,cAAA,KAChB,iBAAA;AAAA,KA0BS,WAAA,GAAc,UAAA,QAAkB,cAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/getIntlayerAPI/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;UAsBU,iBAAA;EACR,YAAA,EAAc,UAAA,QAAkB,kBAAA;EAChC,OAAA,EAAS,UAAA,QAAkB,aAAA;EAC3B,IAAA,EAAM,UAAA,QAAkB,UAAA;EACxB,KAAA,EAAO,UAAA,QAAkB,WAAA;EACzB,UAAA,EAAY,UAAA,QAAkB,gBAAA;EAC9B,MAAA,EAAQ,UAAA,QAAkB,YAAA;EAC1B,EAAA,EAAI,UAAA,QAAkB,QAAA;EACtB,KAAA,EAAO,UAAA,QAAkB,WAAA;EACzB,GAAA,EAAK,UAAA,QAAkB,SAAA;EACvB,MAAA,EAAQ,UAAA,QAAkB,YAAA;EAC1B,MAAA,EAAQ,UAAA,QAAkB,YAAA;EAC1B,UAAA,EAAY,UAAA,QAAkB,gBAAA;EAC9B,MAAA,EAAQ,UAAA,QAAkB,YAAA;EAC1B,MAAA,EAAQ,UAAA,QAAkB,YAAA;EAC1B,SAAA,EAAW,UAAA,QAAkB,eAAA;EAC7B,eAAA,EAAiB,UAAA,QAAkB,qBAAA;EACnC,SAAA,EAAW,UAAA,QAAkB,eAAA;AAAA;AAAA,cAGlB,cAAA,GACX,cAAA,GAAgB,cAAA,EAChB,cAAA,GAAiB,cAAA,KAChB,iBAAA;AAAA,KA2BS,WAAA,GAAc,UAAA,QAAkB,cAAA"}
@@ -0,0 +1,36 @@
1
+ import { FetcherOptions } from "../fetcher.js";
2
+ import { TranslateDictionariesBody, TranslateDictionariesResult } from "@intlayer/backend";
3
+ import { IntlayerConfig } from "@intlayer/types/config";
4
+
5
+ //#region src/getIntlayerAPI/translate.d.ts
6
+ declare const getTranslateAPI: (authAPIOptions: FetcherOptions, intlayerConfig: IntlayerConfig) => {
7
+ translateDictionaries: (body: TranslateDictionariesBody, otherOptions?: FetcherOptions) => Promise<TranslateDictionariesResult>;
8
+ pauseTranslationJob: (jobId: string, otherOptions?: FetcherOptions) => Promise<{
9
+ data: {
10
+ jobId: string;
11
+ };
12
+ }>;
13
+ resumeTranslationJob: (jobId: string, otherOptions?: FetcherOptions) => Promise<{
14
+ data: {
15
+ jobId: string;
16
+ };
17
+ }>;
18
+ stopTranslationJob: (jobId: string, otherOptions?: FetcherOptions) => Promise<{
19
+ data: {
20
+ jobId: string;
21
+ };
22
+ }>;
23
+ retryTranslationJob: (jobId: string, otherOptions?: FetcherOptions) => Promise<{
24
+ data: {
25
+ jobId: string;
26
+ };
27
+ }>;
28
+ restartTranslationJob: (jobId: string, otherOptions?: FetcherOptions) => Promise<{
29
+ data: {
30
+ jobId: string;
31
+ };
32
+ }>;
33
+ };
34
+ //#endregion
35
+ export { type TranslateDictionariesBody, type TranslateDictionariesResult, getTranslateAPI };
36
+ //# sourceMappingURL=translate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.d.ts","names":[],"sources":["../../../src/getIntlayerAPI/translate.ts"],"mappings":";;;;;cASa,eAAA,GACX,cAAA,EAAgB,cAAA,EAChB,cAAA,EAAgB,cAAA;gCAOR,yBAAA,EAAyB,YAAA,GACjB,cAAA,KAAc,OAAA,CAAA,2BAAA;uCAUf,YAAA,GACC,cAAA,KAAc,OAAA;;MAEV,KAAA;IAAA;EAAA;wCAQL,YAAA,GACC,cAAA,KAAc,OAAA;;MAEV,KAAA;IAAA;EAAA;sCAQL,YAAA,GACC,cAAA,KAAc,OAAA;;MAEV,KAAA;IAAA;EAAA;uCAQL,YAAA,GACC,cAAA,KAAc,OAAA;;MAEV,KAAA;IAAA;EAAA;yCAQL,YAAA,GACC,cAAA,KAAc,OAAA;;MAEV,KAAA;IAAA;EAAA;AAAA"}
@@ -15,8 +15,9 @@ import { getProjectAPI } from "./getIntlayerAPI/project.js";
15
15
  import { getSearchAPI } from "./getIntlayerAPI/search.js";
16
16
  import { getStripeAPI } from "./getIntlayerAPI/stripe.js";
17
17
  import { getTagAPI } from "./getIntlayerAPI/tag.js";
18
+ import { TranslateDictionariesBody, TranslateDictionariesResult, getTranslateAPI } from "./getIntlayerAPI/translate.js";
18
19
  import { getUserAPI } from "./getIntlayerAPI/user.js";
19
20
  import { IntlayerAPI, getIntlayerAPI } from "./getIntlayerAPI/index.js";
20
21
  import { IntlayerAPIProxy, getIntlayerAPIProxy } from "./proxy.js";
21
22
  import { AIOptions } from "./types.js";
22
- export { AIOptions, AskDocQuestionBody, AskDocQuestionResult, AuditEvent, AutocompleteBody, BitbucketAuthCallbackBody, BitbucketAuthCallbackResult, BitbucketCheckConfigBody, BitbucketCheckConfigResult, BitbucketGetAuthUrlResult, BitbucketGetConfigFileBody, BitbucketGetConfigFileResult, BitbucketListReposResult, BitbucketRepository, DiscoverUrlsParams, DiscoverUrlsResult, FetcherOptions, GetRecursiveAuditStatusParams, GetRecursiveAuditStatusResult, GitHubAuthCallbackBody, GitHubAuthCallbackResult, GitHubCheckConfigBody, GitHubCheckConfigResult, GitHubGetAuthUrlResult, GitHubGetConfigFileBody, GitHubGetConfigFileResult, GitHubListReposResult, GitHubRepository, GitLabAuthCallbackBody, GitLabAuthCallbackResult, GitLabCheckConfigBody, GitLabCheckConfigResult, GitLabGetAuthUrlResult, GitLabGetConfigFileBody, GitLabGetConfigFileResult, GitLabListProjectsResult, GitLabProject, IntlayerAPI, IntlayerAPIProxy, RecursiveAuditJobParams, ScanUrlBody, StartRecursiveAuditBody, StartRecursiveAuditResult, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getSearchAPI, getStripeAPI, getTagAPI, getUserAPI };
23
+ export { AIOptions, AskDocQuestionBody, AskDocQuestionResult, AuditEvent, AutocompleteBody, BitbucketAuthCallbackBody, BitbucketAuthCallbackResult, BitbucketCheckConfigBody, BitbucketCheckConfigResult, BitbucketGetAuthUrlResult, BitbucketGetConfigFileBody, BitbucketGetConfigFileResult, BitbucketListReposResult, BitbucketRepository, DiscoverUrlsParams, DiscoverUrlsResult, FetcherOptions, GetRecursiveAuditStatusParams, GetRecursiveAuditStatusResult, GitHubAuthCallbackBody, GitHubAuthCallbackResult, GitHubCheckConfigBody, GitHubCheckConfigResult, GitHubGetAuthUrlResult, GitHubGetConfigFileBody, GitHubGetConfigFileResult, GitHubListReposResult, GitHubRepository, GitLabAuthCallbackBody, GitLabAuthCallbackResult, GitLabCheckConfigBody, GitLabCheckConfigResult, GitLabGetAuthUrlResult, GitLabGetConfigFileBody, GitLabGetConfigFileResult, GitLabListProjectsResult, GitLabProject, IntlayerAPI, IntlayerAPIProxy, RecursiveAuditJobParams, ScanUrlBody, StartRecursiveAuditBody, StartRecursiveAuditResult, TranslateDictionariesBody, TranslateDictionariesResult, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getSearchAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/api",
3
- "version": "8.7.6-canary.0",
3
+ "version": "8.7.7",
4
4
  "private": false,
5
5
  "description": "SDK for interacting with the Intlayer API, enabling content auditing, and managing organizations, projects, and users.",
6
6
  "keywords": [
@@ -72,9 +72,9 @@
72
72
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
73
73
  },
74
74
  "dependencies": {
75
- "@intlayer/config": "8.7.6-canary.0",
76
- "@intlayer/types": "8.7.6-canary.0",
77
- "defu": "6.1.4"
75
+ "@intlayer/config": "8.7.7",
76
+ "@intlayer/types": "8.7.7",
77
+ "defu": "6.1.7"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/node": "25.6.0",
@@ -82,9 +82,9 @@
82
82
  "@utils/ts-config-types": "1.0.4",
83
83
  "@utils/tsdown-config": "1.0.4",
84
84
  "rimraf": "6.1.3",
85
- "tsdown": "0.21.9",
85
+ "tsdown": "0.21.10",
86
86
  "typescript": "6.0.3",
87
- "vitest": "4.1.4"
87
+ "vitest": "4.1.5"
88
88
  },
89
89
  "engines": {
90
90
  "node": ">=14.18"