@intlayer/api 5.0.6 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/IntlayerEventListener.cjs +2 -3
- package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/editor.cjs +1 -1
- package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
- package/dist/esm/IntlayerEventListener.mjs +1 -2
- package/dist/esm/IntlayerEventListener.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/editor.mjs +1 -1
- package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
- package/dist/types/IntlayerEventListener.d.ts +2 -2
- package/dist/types/IntlayerEventListener.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -21,8 +21,8 @@ __export(IntlayerEventListener_exports, {
|
|
|
21
21
|
IntlayerEventListener: () => IntlayerEventListener
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(IntlayerEventListener_exports);
|
|
24
|
-
var import_api = require("@intlayer/api");
|
|
25
24
|
var import_client = require("@intlayer/config/client");
|
|
25
|
+
var import_getIntlayerAPI = require('./getIntlayerAPI/index.cjs');
|
|
26
26
|
class IntlayerEventListener {
|
|
27
27
|
constructor(intlayerConfig) {
|
|
28
28
|
this.intlayerConfig = intlayerConfig;
|
|
@@ -48,7 +48,7 @@ class IntlayerEventListener {
|
|
|
48
48
|
try {
|
|
49
49
|
const config = this.intlayerConfig ?? (0, import_client.getConfiguration)();
|
|
50
50
|
const { backendURL } = config.editor;
|
|
51
|
-
const oAuth2TokenResult = await
|
|
51
|
+
const oAuth2TokenResult = await import_getIntlayerAPI.intlayerAPI.auth.getOAuth2AccessToken();
|
|
52
52
|
const accessToken = oAuth2TokenResult.data?.accessToken;
|
|
53
53
|
if (!accessToken) {
|
|
54
54
|
throw new Error("Failed to retrieve access token");
|
|
@@ -71,7 +71,6 @@ class IntlayerEventListener {
|
|
|
71
71
|
if (this.eventSource) {
|
|
72
72
|
this.eventSource.close();
|
|
73
73
|
this.eventSource = null;
|
|
74
|
-
console.log("IntlayerEventListener cleaned up.");
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/IntlayerEventListener.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/IntlayerEventListener.ts"],"sourcesContent":["// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { type IntlayerConfig, getConfiguration } from '@intlayer/config/client';\nimport { intlayerAPI } from './getIntlayerAPI';\n\nexport type DictionaryMessageEvent = {\n object: 'DICTIONARY';\n dictionary: DictionaryAPI;\n status: 'ADDED' | 'UPDATED' | 'DELETED' | 'CREATED';\n};\n\nexport type IntlayerMessageEvent = MessageEvent<DictionaryMessageEvent[]>;\n\n/**\n * IntlayerEventListener class to listen for dictionary changes via SSE (Server-Sent Events).\n *\n * Usage example:\n *\n * import { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary';\n * import { IntlayerEventListener } from '@intlayer/api';\n *\n * export const checkDictionaryChanges = async () => {\n * // Instantiate the listener\n * const eventListener = new IntlayerEventListener();\n *\n * // Set up your callbacks\n * eventListener.onDictionaryChange = async (dictionary) => {\n * await buildIntlayerDictionary(dictionary);\n * };\n *\n * // Initialize the listener\n * await eventListener.initialize();\n *\n * // Optionally, clean up later when you’re done\n * // eventListener.cleanup();\n * };\n */\nexport class IntlayerEventListener {\n private eventSource: EventSource | null = null;\n\n /**\n * Callback triggered when a Dictionary is ADDED.\n */\n public onDictionaryAdded?: (dictionary: DictionaryAPI) => any;\n\n /**\n * Callback triggered when a Dictionary is UPDATED.\n */\n public onDictionaryChange?: (dictionary: DictionaryAPI) => any;\n\n /**\n * Callback triggered when a Dictionary is DELETED.\n */\n public onDictionaryDeleted?: (dictionary: DictionaryAPI) => any;\n\n constructor(private intlayerConfig?: IntlayerConfig) {}\n\n /**\n * Initializes the EventSource connection using the given intlayerConfig\n * (or the default config if none was provided).\n */\n public async initialize(): Promise<void> {\n try {\n const config = this.intlayerConfig ?? getConfiguration();\n const { backendURL } = config.editor;\n\n // Retrieve the access token\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n const accessToken = oAuth2TokenResult.data?.accessToken;\n\n if (!accessToken) {\n throw new Error('Failed to retrieve access token');\n }\n\n if (oAuth2TokenResult.data?.organization.plan?.type !== 'ENTERPRISE')\n return;\n\n const API_ROUTE = `${backendURL}/api/event-listener`;\n const url = `${API_ROUTE}/${accessToken}`;\n\n this.eventSource = new EventSource(url);\n this.eventSource.onmessage = (event) => this.handleMessage(event);\n this.eventSource.onerror = (event) => this.handleError(event);\n } catch (error) {\n console.error('Error initializing IntlayerEventListener:', error);\n }\n }\n\n /**\n * Cleans up (closes) the EventSource connection.\n */\n public cleanup(): void {\n if (this.eventSource) {\n this.eventSource.close();\n this.eventSource = null;\n }\n }\n\n /**\n * Handles incoming SSE messages, parses the event data,\n * and invokes the appropriate callback.\n */\n private async handleMessage(event: IntlayerMessageEvent): Promise<void> {\n try {\n const { data } = event;\n for (const dataEl of data) {\n switch (dataEl.object) {\n case 'DICTIONARY':\n switch (dataEl.status) {\n case 'ADDED':\n await this.onDictionaryAdded?.(dataEl.dictionary);\n break;\n case 'UPDATED':\n await this.onDictionaryChange?.(dataEl.dictionary);\n break;\n case 'DELETED':\n await this.onDictionaryDeleted?.(dataEl.dictionary);\n break;\n default:\n console.error('Unhandled dictionary status:', dataEl.status);\n break;\n }\n break;\n default:\n console.error('Unknown object type:', dataEl.object);\n break;\n }\n }\n } catch (error) {\n console.error('Error processing dictionary update:', error);\n }\n }\n\n /**\n * Handles any SSE errors and then performs cleanup.\n */\n private handleError(event: Event): void {\n console.error('EventSource error:', event);\n this.cleanup();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAsD;AACtD,4BAA4B;AAkCrB,MAAM,sBAAsB;AAAA,EAkBjC,YAAoB,gBAAiC;AAAjC;AAAA,EAAkC;AAAA,EAjB9C,cAAkC;AAAA;AAAA;AAAA;AAAA,EAKnC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP,MAAa,aAA4B;AACvC,QAAI;AACF,YAAM,SAAS,KAAK,sBAAkB,gCAAiB;AACvD,YAAM,EAAE,WAAW,IAAI,OAAO;AAG9B,YAAM,oBAAoB,MAAM,kCAAY,KAAK,qBAAqB;AACtE,YAAM,cAAc,kBAAkB,MAAM;AAE5C,UAAI,CAAC,aAAa;AAChB,cAAM,IAAI,MAAM,iCAAiC;AAAA,MACnD;AAEA,UAAI,kBAAkB,MAAM,aAAa,MAAM,SAAS;AACtD;AAEF,YAAM,YAAY,GAAG,UAAU;AAC/B,YAAM,MAAM,GAAG,SAAS,IAAI,WAAW;AAEvC,WAAK,cAAc,IAAI,YAAY,GAAG;AACtC,WAAK,YAAY,YAAY,CAAC,UAAU,KAAK,cAAc,KAAK;AAChE,WAAK,YAAY,UAAU,CAAC,UAAU,KAAK,YAAY,KAAK;AAAA,IAC9D,SAAS,OAAO;AACd,cAAQ,MAAM,6CAA6C,KAAK;AAAA,IAClE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKO,UAAgB;AACrB,QAAI,KAAK,aAAa;AACpB,WAAK,YAAY,MAAM;AACvB,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,cAAc,OAA4C;AACtE,QAAI;AACF,YAAM,EAAE,KAAK,IAAI;AACjB,iBAAW,UAAU,MAAM;AACzB,gBAAQ,OAAO,QAAQ;AAAA,UACrB,KAAK;AACH,oBAAQ,OAAO,QAAQ;AAAA,cACrB,KAAK;AACH,sBAAM,KAAK,oBAAoB,OAAO,UAAU;AAChD;AAAA,cACF,KAAK;AACH,sBAAM,KAAK,qBAAqB,OAAO,UAAU;AACjD;AAAA,cACF,KAAK;AACH,sBAAM,KAAK,sBAAsB,OAAO,UAAU;AAClD;AAAA,cACF;AACE,wBAAQ,MAAM,gCAAgC,OAAO,MAAM;AAC3D;AAAA,YACJ;AACA;AAAA,UACF;AACE,oBAAQ,MAAM,wBAAwB,OAAO,MAAM;AACnD;AAAA,QACJ;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,uCAAuC,KAAK;AAAA,IAC5D;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,YAAY,OAAoB;AACtC,YAAQ,MAAM,sBAAsB,KAAK;AACzC,SAAK,QAAQ;AAAA,EACf;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import {\n getConfiguration as getLocaleConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config/client';\nimport type {\n // @ts-ignore: intlayer-editor is not built yet\n GetConfigurationResult,\n // @ts-ignore: intlayer-editor is not built yet\n WriteContentDeclarationBody,\n // @ts-ignore: intlayer-editor is not built yet\n WriteContentDeclarationResult,\n // @ts-ignore: intlayer-editor is not built yet\n} from 'intlayer-editor';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { editorURL } = (intlayerConfig ?? getLocaleConfiguration()).editor;\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;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n dictionary: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) => {\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: dictionary,\n }\n );\n };\n\n return {\n getConfiguration,\n writeDictionary,\n };\n};\n\nexport const editorAPI = getEditorAPI();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAGO;AAUP,qBAA6C;AAEtC,MAAM,eAAe,CAC1B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,EAAE,UAAU,KAAK,sBAAkB,cAAAA,kBAAuB,GAAG;AACnE,QAAM,mBAAmB,GAAG,SAAS;AAKrC,QAAM,mBAAmB,OACvB,eAA+B,CAAC,MACI;AACpC,UAAM,WAAW,UAAM;AAAA,MACrB,GAAG,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AAMA,QAAM,kBAAkB,OACtB,YACA,eAA+B,CAAC,MAC7B;AACH,cAAM;AAAA,MACJ,GAAG,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,MAAM;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import {\n getConfiguration as getLocaleConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config/client';\nimport type {\n // @ts-ignore: intlayer-editor is not built yet\n GetConfigurationResult,\n // @ts-ignore: intlayer-editor is not built yet\n WriteContentDeclarationBody,\n // @ts-ignore: intlayer-editor is not built yet\n WriteContentDeclarationResult,\n // @ts-ignore: intlayer-editor is not built yet\n} from 'intlayer-editor';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { editorURL } = (intlayerConfig ?? getLocaleConfiguration()).editor;\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;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n dictionary: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) => {\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { dictionary },\n }\n );\n };\n\n return {\n getConfiguration,\n writeDictionary,\n };\n};\n\nexport const editorAPI = getEditorAPI();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAGO;AAUP,qBAA6C;AAEtC,MAAM,eAAe,CAC1B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,EAAE,UAAU,KAAK,sBAAkB,cAAAA,kBAAuB,GAAG;AACnE,QAAM,mBAAmB,GAAG,SAAS;AAKrC,QAAM,mBAAmB,OACvB,eAA+B,CAAC,MACI;AACpC,UAAM,WAAW,UAAM;AAAA,MACrB,GAAG,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AAMA,QAAM,kBAAkB,OACtB,YACA,eAA+B,CAAC,MAC7B;AACH,cAAM;AAAA,MACJ,GAAG,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,MAAM,EAAE,WAAW;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,YAAY,aAAa;","names":["getLocaleConfiguration"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { intlayerAPI } from "@intlayer/api";
|
|
2
1
|
import { getConfiguration } from "@intlayer/config/client";
|
|
2
|
+
import { intlayerAPI } from "./getIntlayerAPI/index.mjs";
|
|
3
3
|
class IntlayerEventListener {
|
|
4
4
|
constructor(intlayerConfig) {
|
|
5
5
|
this.intlayerConfig = intlayerConfig;
|
|
@@ -48,7 +48,6 @@ class IntlayerEventListener {
|
|
|
48
48
|
if (this.eventSource) {
|
|
49
49
|
this.eventSource.close();
|
|
50
50
|
this.eventSource = null;
|
|
51
|
-
console.log("IntlayerEventListener cleaned up.");
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/IntlayerEventListener.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/IntlayerEventListener.ts"],"sourcesContent":["// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { type IntlayerConfig, getConfiguration } from '@intlayer/config/client';\nimport { intlayerAPI } from './getIntlayerAPI';\n\nexport type DictionaryMessageEvent = {\n object: 'DICTIONARY';\n dictionary: DictionaryAPI;\n status: 'ADDED' | 'UPDATED' | 'DELETED' | 'CREATED';\n};\n\nexport type IntlayerMessageEvent = MessageEvent<DictionaryMessageEvent[]>;\n\n/**\n * IntlayerEventListener class to listen for dictionary changes via SSE (Server-Sent Events).\n *\n * Usage example:\n *\n * import { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary';\n * import { IntlayerEventListener } from '@intlayer/api';\n *\n * export const checkDictionaryChanges = async () => {\n * // Instantiate the listener\n * const eventListener = new IntlayerEventListener();\n *\n * // Set up your callbacks\n * eventListener.onDictionaryChange = async (dictionary) => {\n * await buildIntlayerDictionary(dictionary);\n * };\n *\n * // Initialize the listener\n * await eventListener.initialize();\n *\n * // Optionally, clean up later when you’re done\n * // eventListener.cleanup();\n * };\n */\nexport class IntlayerEventListener {\n private eventSource: EventSource | null = null;\n\n /**\n * Callback triggered when a Dictionary is ADDED.\n */\n public onDictionaryAdded?: (dictionary: DictionaryAPI) => any;\n\n /**\n * Callback triggered when a Dictionary is UPDATED.\n */\n public onDictionaryChange?: (dictionary: DictionaryAPI) => any;\n\n /**\n * Callback triggered when a Dictionary is DELETED.\n */\n public onDictionaryDeleted?: (dictionary: DictionaryAPI) => any;\n\n constructor(private intlayerConfig?: IntlayerConfig) {}\n\n /**\n * Initializes the EventSource connection using the given intlayerConfig\n * (or the default config if none was provided).\n */\n public async initialize(): Promise<void> {\n try {\n const config = this.intlayerConfig ?? getConfiguration();\n const { backendURL } = config.editor;\n\n // Retrieve the access token\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n const accessToken = oAuth2TokenResult.data?.accessToken;\n\n if (!accessToken) {\n throw new Error('Failed to retrieve access token');\n }\n\n if (oAuth2TokenResult.data?.organization.plan?.type !== 'ENTERPRISE')\n return;\n\n const API_ROUTE = `${backendURL}/api/event-listener`;\n const url = `${API_ROUTE}/${accessToken}`;\n\n this.eventSource = new EventSource(url);\n this.eventSource.onmessage = (event) => this.handleMessage(event);\n this.eventSource.onerror = (event) => this.handleError(event);\n } catch (error) {\n console.error('Error initializing IntlayerEventListener:', error);\n }\n }\n\n /**\n * Cleans up (closes) the EventSource connection.\n */\n public cleanup(): void {\n if (this.eventSource) {\n this.eventSource.close();\n this.eventSource = null;\n }\n }\n\n /**\n * Handles incoming SSE messages, parses the event data,\n * and invokes the appropriate callback.\n */\n private async handleMessage(event: IntlayerMessageEvent): Promise<void> {\n try {\n const { data } = event;\n for (const dataEl of data) {\n switch (dataEl.object) {\n case 'DICTIONARY':\n switch (dataEl.status) {\n case 'ADDED':\n await this.onDictionaryAdded?.(dataEl.dictionary);\n break;\n case 'UPDATED':\n await this.onDictionaryChange?.(dataEl.dictionary);\n break;\n case 'DELETED':\n await this.onDictionaryDeleted?.(dataEl.dictionary);\n break;\n default:\n console.error('Unhandled dictionary status:', dataEl.status);\n break;\n }\n break;\n default:\n console.error('Unknown object type:', dataEl.object);\n break;\n }\n }\n } catch (error) {\n console.error('Error processing dictionary update:', error);\n }\n }\n\n /**\n * Handles any SSE errors and then performs cleanup.\n */\n private handleError(event: Event): void {\n console.error('EventSource error:', event);\n this.cleanup();\n }\n}\n"],"mappings":"AAEA,SAA8B,wBAAwB;AACtD,SAAS,mBAAmB;AAkCrB,MAAM,sBAAsB;AAAA,EAkBjC,YAAoB,gBAAiC;AAAjC;AAAA,EAAkC;AAAA,EAjB9C,cAAkC;AAAA;AAAA;AAAA;AAAA,EAKnC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP,MAAa,aAA4B;AACvC,QAAI;AACF,YAAM,SAAS,KAAK,kBAAkB,iBAAiB;AACvD,YAAM,EAAE,WAAW,IAAI,OAAO;AAG9B,YAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AACtE,YAAM,cAAc,kBAAkB,MAAM;AAE5C,UAAI,CAAC,aAAa;AAChB,cAAM,IAAI,MAAM,iCAAiC;AAAA,MACnD;AAEA,UAAI,kBAAkB,MAAM,aAAa,MAAM,SAAS;AACtD;AAEF,YAAM,YAAY,GAAG,UAAU;AAC/B,YAAM,MAAM,GAAG,SAAS,IAAI,WAAW;AAEvC,WAAK,cAAc,IAAI,YAAY,GAAG;AACtC,WAAK,YAAY,YAAY,CAAC,UAAU,KAAK,cAAc,KAAK;AAChE,WAAK,YAAY,UAAU,CAAC,UAAU,KAAK,YAAY,KAAK;AAAA,IAC9D,SAAS,OAAO;AACd,cAAQ,MAAM,6CAA6C,KAAK;AAAA,IAClE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKO,UAAgB;AACrB,QAAI,KAAK,aAAa;AACpB,WAAK,YAAY,MAAM;AACvB,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,cAAc,OAA4C;AACtE,QAAI;AACF,YAAM,EAAE,KAAK,IAAI;AACjB,iBAAW,UAAU,MAAM;AACzB,gBAAQ,OAAO,QAAQ;AAAA,UACrB,KAAK;AACH,oBAAQ,OAAO,QAAQ;AAAA,cACrB,KAAK;AACH,sBAAM,KAAK,oBAAoB,OAAO,UAAU;AAChD;AAAA,cACF,KAAK;AACH,sBAAM,KAAK,qBAAqB,OAAO,UAAU;AACjD;AAAA,cACF,KAAK;AACH,sBAAM,KAAK,sBAAsB,OAAO,UAAU;AAClD;AAAA,cACF;AACE,wBAAQ,MAAM,gCAAgC,OAAO,MAAM;AAC3D;AAAA,YACJ;AACA;AAAA,UACF;AACE,oBAAQ,MAAM,wBAAwB,OAAO,MAAM;AACnD;AAAA,QACJ;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,uCAAuC,KAAK;AAAA,IAC5D;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,YAAY,OAAoB;AACtC,YAAQ,MAAM,sBAAsB,KAAK;AACzC,SAAK,QAAQ;AAAA,EACf;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import {\n getConfiguration as getLocaleConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config/client';\nimport type {\n // @ts-ignore: intlayer-editor is not built yet\n GetConfigurationResult,\n // @ts-ignore: intlayer-editor is not built yet\n WriteContentDeclarationBody,\n // @ts-ignore: intlayer-editor is not built yet\n WriteContentDeclarationResult,\n // @ts-ignore: intlayer-editor is not built yet\n} from 'intlayer-editor';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { editorURL } = (intlayerConfig ?? getLocaleConfiguration()).editor;\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;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n dictionary: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) => {\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: dictionary,\n }\n );\n };\n\n return {\n getConfiguration,\n writeDictionary,\n };\n};\n\nexport const editorAPI = getEditorAPI();\n"],"mappings":"AAAA;AAAA,EACE,oBAAoB;AAAA,OAEf;AAUP,SAAS,eAAoC;AAEtC,MAAM,eAAe,CAC1B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,EAAE,UAAU,KAAK,kBAAkB,uBAAuB,GAAG;AACnE,QAAM,mBAAmB,GAAG,SAAS;AAKrC,QAAM,mBAAmB,OACvB,eAA+B,CAAC,MACI;AACpC,UAAM,WAAW,MAAM;AAAA,MACrB,GAAG,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AAMA,QAAM,kBAAkB,OACtB,YACA,eAA+B,CAAC,MAC7B;AACH,UAAM;AAAA,MACJ,GAAG,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,MAAM;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import {\n getConfiguration as getLocaleConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config/client';\nimport type {\n // @ts-ignore: intlayer-editor is not built yet\n GetConfigurationResult,\n // @ts-ignore: intlayer-editor is not built yet\n WriteContentDeclarationBody,\n // @ts-ignore: intlayer-editor is not built yet\n WriteContentDeclarationResult,\n // @ts-ignore: intlayer-editor is not built yet\n} from 'intlayer-editor';\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { editorURL } = (intlayerConfig ?? getLocaleConfiguration()).editor;\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;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n dictionary: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) => {\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { dictionary },\n }\n );\n };\n\n return {\n getConfiguration,\n writeDictionary,\n };\n};\n\nexport const editorAPI = getEditorAPI();\n"],"mappings":"AAAA;AAAA,EACE,oBAAoB;AAAA,OAEf;AAUP,SAAS,eAAoC;AAEtC,MAAM,eAAe,CAC1B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,EAAE,UAAU,KAAK,kBAAkB,uBAAuB,GAAG;AACnE,QAAM,mBAAmB,GAAG,SAAS;AAKrC,QAAM,mBAAmB,OACvB,eAA+B,CAAC,MACI;AACpC,UAAM,WAAW,MAAM;AAAA,MACrB,GAAG,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AAMA,QAAM,kBAAkB,OACtB,YACA,eAA+B,CAAC,MAC7B;AACH,UAAM;AAAA,MACJ,GAAG,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,MAAM,EAAE,WAAW;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,YAAY,aAAa;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DictionaryAPI } from '@intlayer/backend';
|
|
2
|
-
import { IntlayerConfig } from '@intlayer/config/client';
|
|
1
|
+
import type { DictionaryAPI } from '@intlayer/backend';
|
|
2
|
+
import { type IntlayerConfig } from '@intlayer/config/client';
|
|
3
3
|
export type DictionaryMessageEvent = {
|
|
4
4
|
object: 'DICTIONARY';
|
|
5
5
|
dictionary: DictionaryAPI;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerEventListener.d.ts","sourceRoot":"","sources":["../../src/IntlayerEventListener.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerEventListener.d.ts","sourceRoot":"","sources":["../../src/IntlayerEventListener.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,cAAc,EAAoB,MAAM,yBAAyB,CAAC;AAGhF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,aAAa,CAAC;IAC1B,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,sBAAsB,EAAE,CAAC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,qBAAqB;IAkBpB,OAAO,CAAC,cAAc,CAAC;IAjBnC,OAAO,CAAC,WAAW,CAA4B;IAE/C;;OAEG;IACI,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,GAAG,CAAC;IAE9D;;OAEG;IACI,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,GAAG,CAAC;IAE/D;;OAEG;IACI,mBAAmB,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,GAAG,CAAC;gBAE5C,cAAc,CAAC,EAAE,cAAc;IAEnD;;;OAGG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BxC;;OAEG;IACI,OAAO,IAAI,IAAI;IAOtB;;;OAGG;YACW,aAAa;IA+B3B;;OAEG;IACH,OAAO,CAAC,WAAW;CAIpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/api",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
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": [
|
|
@@ -57,29 +57,29 @@
|
|
|
57
57
|
"./package.json"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@intlayer/config": "5.
|
|
60
|
+
"@intlayer/config": "5.1.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@changesets/changelog-github": "0.5.0",
|
|
64
64
|
"@changesets/cli": "2.27.12",
|
|
65
65
|
"@types/node": "^22.10.6",
|
|
66
|
-
"@typescript-eslint/parser": "^8.
|
|
66
|
+
"@typescript-eslint/parser": "^8.24.0",
|
|
67
67
|
"concurrently": "^9.1.2",
|
|
68
|
-
"eslint": "^9.
|
|
69
|
-
"prettier": "^3.
|
|
68
|
+
"eslint": "^9.20.0",
|
|
69
|
+
"prettier": "^3.5.0",
|
|
70
70
|
"rimraf": "^6.0.1",
|
|
71
71
|
"tsc-alias": "^1.8.10",
|
|
72
72
|
"tsup": "^8.3.5",
|
|
73
73
|
"typescript": "^5.7.3",
|
|
74
|
-
"@intlayer/backend": "5.
|
|
75
|
-
"@utils/ts-config-types": "1.0.4",
|
|
76
|
-
"@utils/tsup-config": "1.0.4",
|
|
77
|
-
"intlayer-editor": "5.0.6",
|
|
74
|
+
"@intlayer/backend": "5.1.1",
|
|
78
75
|
"@utils/ts-config": "1.0.4",
|
|
79
|
-
"@utils/
|
|
76
|
+
"@utils/tsup-config": "1.0.4",
|
|
77
|
+
"@utils/eslint-config": "1.0.4",
|
|
78
|
+
"@utils/ts-config-types": "1.0.4",
|
|
79
|
+
"intlayer-editor": "5.1.1"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@intlayer/config": "5.
|
|
82
|
+
"@intlayer/config": "5.1.1"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": ">=14.18"
|