@intlayer/api 5.4.2 → 5.5.0-canary.0

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.
Files changed (36) hide show
  1. package/dist/cjs/IntlayerEventListener.cjs +3 -3
  2. package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
  3. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +8 -9
  4. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  5. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +6 -4
  6. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  7. package/dist/cjs/getIntlayerAPI/ai.cjs +10 -0
  8. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  9. package/dist/cjs/getIntlayerAPI/dictionary.cjs +2 -3
  10. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  11. package/dist/cjs/index.cjs +20 -2
  12. package/dist/cjs/index.cjs.map +1 -1
  13. package/dist/esm/IntlayerEventListener.mjs +3 -3
  14. package/dist/esm/IntlayerEventListener.mjs.map +1 -1
  15. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +8 -9
  16. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  17. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +6 -4
  18. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  19. package/dist/esm/getIntlayerAPI/ai.mjs +10 -0
  20. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  21. package/dist/esm/getIntlayerAPI/dictionary.mjs +2 -3
  22. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  23. package/dist/esm/index.mjs +10 -1
  24. package/dist/esm/index.mjs.map +1 -1
  25. package/dist/types/IntlayerEventListener.d.ts.map +1 -1
  26. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
  27. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
  28. package/dist/types/getIntlayerAPI/ai.d.ts +2 -1
  29. package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
  30. package/dist/types/getIntlayerAPI/dictionary.d.ts +1 -1
  31. package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
  32. package/dist/types/getIntlayerAPI/index.d.ts +1 -0
  33. package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
  34. package/dist/types/index.d.ts +11 -1
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/package.json +6 -6
@@ -32,7 +32,7 @@ __export(IntlayerEventListener_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(IntlayerEventListener_exports);
34
34
  var import_built = __toESM(require("@intlayer/config/built"));
35
- var import_getIntlayerAPI = require('./getIntlayerAPI/index.cjs');
35
+ var import_auth = require('./getIntlayerAPI/auth.cjs');
36
36
  class IntlayerEventListener {
37
37
  constructor(intlayerConfig = import_built.default) {
38
38
  this.intlayerConfig = intlayerConfig;
@@ -56,10 +56,10 @@ class IntlayerEventListener {
56
56
  */
57
57
  async initialize() {
58
58
  const backendURL = this.intlayerConfig.editor.backendURL;
59
- const oAuth2TokenResult = await (0, import_getIntlayerAPI.getIntlayerAPI)(
59
+ const oAuth2TokenResult = await (0, import_auth.getAuthAPI)(
60
60
  {},
61
61
  this.intlayerConfig
62
- ).auth.getOAuth2AccessToken();
62
+ ).getOAuth2AccessToken();
63
63
  const accessToken = oAuth2TokenResult.data?.accessToken;
64
64
  if (!accessToken) {
65
65
  throw new Error("Failed to retrieve access token");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/IntlayerEventListener.ts"],"sourcesContent":["// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI, MessageEventData } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport configuration from '@intlayer/config/built';\n\nimport { getIntlayerAPI } from './getIntlayerAPI';\n\nexport type IntlayerMessageEvent = MessageEvent;\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 = configuration) {}\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 const backendURL = this.intlayerConfig.editor.backendURL;\n\n // Retrieve the access token\n const oAuth2TokenResult = await getIntlayerAPI(\n {},\n this.intlayerConfig\n ).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 throw new Error(\n 'Hot reload is enabled, but is only available for enterprise plans'\n );\n }\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 }\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\n const dataJSON: MessageEventData[] = JSON.parse(data);\n\n for (const dataEl of dataJSON) {\n switch (dataEl.object) {\n case 'DICTIONARY':\n switch (dataEl.status) {\n case 'ADDED':\n await this.onDictionaryAdded?.(dataEl.data);\n break;\n case 'UPDATED':\n await this.onDictionaryChange?.(dataEl.data);\n break;\n case 'DELETED':\n await this.onDictionaryDeleted?.(dataEl.data);\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;AAGA,mBAA0B;AAE1B,4BAA+B;AA4BxB,MAAM,sBAAsB;AAAA,EAkBjC,YAAoB,iBAAiC,aAAAA,SAAe;AAAhD;AAAA,EAAiD;AAAA,EAjB7D,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,UAAM,aAAa,KAAK,eAAe,OAAO;AAG9C,UAAM,oBAAoB,UAAM;AAAA,MAC9B,CAAC;AAAA,MACD,KAAK;AAAA,IACP,EAAE,KAAK,qBAAqB;AAC5B,UAAM,cAAc,kBAAkB,MAAM;AAE5C,QAAI,CAAC,aAAa;AAChB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AAEA,Q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]}
1
+ {"version":3,"sources":["../../src/IntlayerEventListener.ts"],"sourcesContent":["// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI, MessageEventData } from '@intlayer/backend';\nimport configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { getAuthAPI } from './getIntlayerAPI/auth';\n\nexport type IntlayerMessageEvent = MessageEvent;\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 = configuration) {}\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 const backendURL = this.intlayerConfig.editor.backendURL;\n\n // Retrieve the access token\n const oAuth2TokenResult = await getAuthAPI(\n {},\n this.intlayerConfig\n ).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 throw new Error(\n 'Hot reload is enabled, but is only available for enterprise plans'\n );\n }\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 }\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\n const dataJSON: MessageEventData[] = JSON.parse(data);\n\n for (const dataEl of dataJSON) {\n switch (dataEl.object) {\n case 'DICTIONARY':\n switch (dataEl.status) {\n case 'ADDED':\n await this.onDictionaryAdded?.(dataEl.data);\n break;\n case 'UPDATED':\n await this.onDictionaryChange?.(dataEl.data);\n break;\n case 'DELETED':\n await this.onDictionaryDeleted?.(dataEl.data);\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,mBAA0B;AAE1B,kBAA2B;AA4BpB,MAAM,sBAAsB;AAAA,EAkBjC,YAAoB,iBAAiC,aAAAA,SAAe;AAAhD;AAAA,EAAiD;AAAA,EAjB7D,cAAkC;AAAA;AAAA;AAAA;AAAA,EAKnC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP,MAAa,aAA4B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AAM;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":["configuration"]}
@@ -32,7 +32,8 @@ __export(fetchDistantDictionaries_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(fetchDistantDictionaries_exports);
34
34
  var import_built = __toESM(require("@intlayer/config/built"));
35
- var import_getIntlayerAPI = require('../getIntlayerAPI/index.cjs');
35
+ var import_auth = require('../getIntlayerAPI/auth.cjs');
36
+ var import_dictionary = require('../getIntlayerAPI/dictionary.cjs');
36
37
  const fetchDistantDictionaries = async (intlayerConfig = import_built.default) => {
37
38
  try {
38
39
  const { clientId, clientSecret } = intlayerConfig?.editor;
@@ -41,15 +42,13 @@ const fetchDistantDictionaries = async (intlayerConfig = import_built.default) =
41
42
  "Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
42
43
  );
43
44
  }
44
- const intlayerAPI = (0, import_getIntlayerAPI.getIntlayerAPI)(void 0, intlayerConfig);
45
- const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();
45
+ const dictionaryAPI = (0, import_dictionary.getDictionaryAPI)(void 0, intlayerConfig);
46
+ const authAPI = (0, import_auth.getAuthAPI)(void 0, intlayerConfig);
47
+ const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();
46
48
  const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
47
- const getDictionaryResult = await intlayerAPI.dictionary.getDictionaries(
48
- void 0,
49
- {
50
- headers: { Authorization: `Bearer ${oAuth2AccessToken}` }
51
- }
52
- );
49
+ const getDictionaryResult = await dictionaryAPI.getDictionaries(void 0, {
50
+ headers: { Authorization: `Bearer ${oAuth2AccessToken}` }
51
+ });
53
52
  const distantDictionaries = getDictionaryResult.data;
54
53
  return distantDictionaries;
55
54
  } catch (error) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport configuration from '@intlayer/config/built';\n\nimport { getIntlayerAPI } from '../getIntlayerAPI/index';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig = configuration\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://intlayer.org/dashboard/project.'\n );\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, intlayerConfig);\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await intlayerAPI.dictionary.getDictionaries(\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA0B;AAE1B,4BAA+B;AAKxB,MAAM,2BAA2B,OACtC,iBAAiC,aAAAA,YACe;AAChD,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,gBAAgB;AAEnD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,kBAAc,sCAAe,QAAW,cAAc;AAE5D,UAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AAEtE,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,YAAY,WAAW;AAAA,MACvD;AAAA,MACA;AAAA,QACE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,MAC1D;AAAA,IACF;AAEA,UAAM,sBAAsB,oBAAoB;AAEhD,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":["configuration"]}
1
+ {"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport configuration from '@intlayer/config/built';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport { getAuthAPI } from '../getIntlayerAPI/auth';\nimport { getDictionaryAPI } from '../getIntlayerAPI/dictionary';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig = configuration\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://intlayer.org/dashboard/project.'\n );\n }\n\n const dictionaryAPI = getDictionaryAPI(undefined, intlayerConfig);\n const authAPI = getAuthAPI(undefined, intlayerConfig);\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionaries(undefined, {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n });\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0B;AAE1B,kBAA2B;AAC3B,wBAAiC;AAK1B,MAAM,2BAA2B,OACtC,iBAAiC,aAAAA,YACe;AAChD,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,gBAAgB;AAEnD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,oBAAgB,oCAAiB,QAAW,cAAc;AAChE,UAAM,cAAU,wBAAW,QAAW,cAAc;AAEpD,UAAM,oBAAoB,MAAM,QAAQ,qBAAqB;AAE7D,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,cAAc,gBAAgB,QAAW;AAAA,MACzE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,IAC1D,CAAC;AAED,UAAM,sBAAsB,oBAAoB;AAEhD,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":["configuration"]}
@@ -32,7 +32,8 @@ __export(fetchDistantDictionary_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(fetchDistantDictionary_exports);
34
34
  var import_built = __toESM(require("@intlayer/config/built"));
35
- var import_getIntlayerAPI = require('../getIntlayerAPI/index.cjs');
35
+ var import_auth = require('../getIntlayerAPI/auth.cjs');
36
+ var import_dictionary = require('../getIntlayerAPI/dictionary.cjs');
36
37
  const fetchDistantDictionary = async (dictionaryKey, intlayerConfig = import_built.default) => {
37
38
  try {
38
39
  const { clientId, clientSecret } = intlayerConfig?.editor;
@@ -41,10 +42,11 @@ const fetchDistantDictionary = async (dictionaryKey, intlayerConfig = import_bui
41
42
  "Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
42
43
  );
43
44
  }
44
- const intlayerAPI = (0, import_getIntlayerAPI.getIntlayerAPI)(void 0, intlayerConfig);
45
- const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();
45
+ const dictionaryAPI = (0, import_dictionary.getDictionaryAPI)(void 0, intlayerConfig);
46
+ const authAPI = (0, import_auth.getAuthAPI)(void 0, intlayerConfig);
47
+ const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();
46
48
  const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
47
- const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(
49
+ const getDictionaryResult = await dictionaryAPI.getDictionary(
48
50
  dictionaryKey,
49
51
  void 0,
50
52
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport configuration from '@intlayer/config/built';\n\nimport { getIntlayerAPI } from '../getIntlayerAPI/index';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig = configuration\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://intlayer.org/dashboard/project.'\n );\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, intlayerConfig);\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(\n dictionaryKey,\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA0B;AAE1B,4BAA+B;AAKxB,MAAM,yBAAyB,OACpC,eACA,iBAAiC,aAAAA,YACM;AACvC,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,gBAAgB;AAEnD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,kBAAc,sCAAe,QAAW,cAAc;AAE5D,UAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AAEtE,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,YAAY,WAAW;AAAA,MACvD;AAAA,MACA;AAAA,MACA;AAAA,QACE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,MAC1D;AAAA,IACF;AAEA,UAAM,oBAAoB,oBAAoB;AAE9C,QAAI,CAAC,mBAAmB;AACtB,YAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,IACnE;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":["configuration"]}
1
+ {"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { getAuthAPI } from '../getIntlayerAPI/auth';\nimport { getDictionaryAPI } from '../getIntlayerAPI/dictionary';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig = configuration\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://intlayer.org/dashboard/project.'\n );\n }\n\n const dictionaryAPI = getDictionaryAPI(undefined, intlayerConfig);\n const authAPI = getAuthAPI(undefined, intlayerConfig);\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionary(\n dictionaryKey,\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0B;AAE1B,kBAA2B;AAC3B,wBAAiC;AAK1B,MAAM,yBAAyB,OACpC,eACA,iBAAiC,aAAAA,YACM;AACvC,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,gBAAgB;AAEnD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,oBAAgB,oCAAiB,QAAW,cAAc;AAChE,UAAM,cAAU,wBAAW,QAAW,cAAc;AAEpD,UAAM,oBAAoB,MAAM,QAAQ,qBAAqB;AAE7D,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,cAAc;AAAA,MAC9C;AAAA,MACA;AAAA,MACA;AAAA,QACE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,MAC1D;AAAA,IACF;AAEA,UAAM,oBAAoB,oBAAoB;AAE9C,QAAI,CAAC,mBAAmB;AACtB,YAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,IACnE;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":["configuration"]}
@@ -41,6 +41,15 @@ const getAiAPI = (authAPIOptions = {}, intlayerConfig) => {
41
41
  );
42
42
  }
43
43
  const AI_API_ROUTE = `${backendURL}/api/ai`;
44
+ const translateJSON = async (body, otherOptions = {}) => await (0, import_fetcher.fetcher)(
45
+ `${AI_API_ROUTE}/translate/json`,
46
+ authAPIOptions,
47
+ otherOptions,
48
+ {
49
+ method: "POST",
50
+ body
51
+ }
52
+ );
44
53
  const auditContentDeclaration = async (body, otherOptions = {}) => await (0, import_fetcher.fetcher)(
45
54
  `${AI_API_ROUTE}/audit/dictionary`,
46
55
  authAPIOptions,
@@ -139,6 +148,7 @@ const getAiAPI = (authAPIOptions = {}, intlayerConfig) => {
139
148
  }
140
149
  );
141
150
  return {
151
+ translateJSON,
142
152
  auditContentDeclaration,
143
153
  auditContentDeclarationField,
144
154
  auditContentDeclarationMetadata,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/ai.ts"],"sourcesContent":["import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AskDocQuestionResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationFieldBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationFieldResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationMetadataBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationMetadataResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditTagBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditTagResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AutocompleteBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AutocompleteResponse,\n // @ts-ignore: @intlayer/backend is not built yet\n ChatCompletionRequestMessage,\n // @ts-ignore: @intlayer/backend is not built yet\n} from '@intlayer/backend';\n\nimport configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\n\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport type AskDocQuestionBody = {\n messages: ChatCompletionRequestMessage[];\n discutionId: string;\n onMessage?: (chunk: string) => void;\n onDone?: (response: AskDocQuestionResult) => void;\n};\n\nexport type { AskDocQuestionResult };\n\nexport const getAiAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const AI_API_ROUTE = `${backendURL}/api/ai`;\n\n /**\n * Audits a content declaration file\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclaration = async (\n body?: AuditContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationResult>(\n `${AI_API_ROUTE}/audit/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration field\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationField = async (\n body?: AuditContentDeclarationFieldBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationFieldResult>(\n `${AI_API_ROUTE}/audit/dictionary/field`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration file to retrieve title, description and tags\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationMetadata = async (\n body?: AuditContentDeclarationMetadataBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationMetadataResult>(\n `${AI_API_ROUTE}/audit/dictionary/metadata`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a tag\n * @param body - Audit tag parameters.\n * @returns Audited tag content.\n */\n const auditTag = async (\n body?: AuditTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditTagResult>(\n `${AI_API_ROUTE}/audit/tag`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Asks a question to the AI related to the documentation **and streams the\n * answer as Server‑Sent Events (SSE)**.\n *\n * The function **returns immediately** with a handle exposing:\n * - `promise` → resolves when the stream completes (or rejects on error)\n * - `abort()` → allows canceling the request on demand\n *\n * Usage example:\n * ```ts\n * const { promise, abort } = ai.askDocQuestion({\n * ...body,\n * onMessage: console.log,\n * onDone: (full) => console.log(\"✔\", full),\n * });\n * // later → abort();\n * await promise; // waits for completion if desired\n * ```\n */\n const askDocQuestion = async (\n body?: AskDocQuestionBody,\n otherOptions: FetcherOptions = {}\n ) => {\n if (!body) return;\n\n const { onMessage, onDone, ...rest } = body;\n const abortController = new AbortController();\n\n try {\n const response = await fetch(`${AI_API_ROUTE}/ask`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...authAPIOptions.headers,\n ...otherOptions.headers,\n },\n body: JSON.stringify(rest),\n signal: abortController.signal,\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n\n throw new Error(errorData.message || 'Failed to fetch response');\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error('No reader available');\n }\n\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\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 data = JSON.parse(line.slice(6));\n if (data.chunk) {\n onMessage?.(data.chunk);\n }\n if (data.done && data.response) {\n onDone?.(data.response);\n }\n } catch (e) {\n console.error('Failed to parse SSE data:', e);\n }\n }\n }\n }\n } catch (error) {\n console.error('Error in askDocQuestion:', error);\n throw error;\n }\n };\n\n const autocomplete = async (\n body?: AutocompleteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AutocompleteResponse>(\n `${AI_API_ROUTE}/autocomplete`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n return {\n auditContentDeclaration,\n auditContentDeclarationField,\n auditContentDeclarationMetadata,\n auditTag,\n askDocQuestion,\n autocomplete,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BA,mBAA0B;AAG1B,qBAA6C;AAWtC,MAAM,WAAW,CACtB,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,aAAAA,QAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,GAAG,UAAU;AAOlC,QAAM,0BAA0B,OAC9B,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,+BAA+B,OACnC,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,kCAAkC,OACtC,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,WAAW,OACf,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAqBF,QAAM,iBAAiB,OACrB,MACA,eAA+B,CAAC,MAC7B;AACH,QAAI,CAA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ACF;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,4BAA4B,KAAK;AAC/C,YAAM;AAAA,IACR;AAAA,EACF;AAEA,QAAM,eAAe,OACnB,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["configuration"]}
1
+ {"version":3,"sources":["../../../src/getIntlayerAPI/ai.ts"],"sourcesContent":["import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AskDocQuestionResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationFieldBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationFieldResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationMetadataBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationMetadataResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditTagBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditTagResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AutocompleteBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AutocompleteResponse,\n // @ts-ignore: @intlayer/backend is not built yet\n ChatCompletionRequestMessage,\n // @ts-ignore: @intlayer/backend is not built yet\n TranslateJSONResult,\n // @ts-ignore: @intlayer/backend is not built yet\n TranslateJSONResultBody,\n // @ts-ignore: @intlayer/backend is not built yet\n} from '@intlayer/backend';\n\nimport configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\n\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport type AskDocQuestionBody = {\n messages: ChatCompletionRequestMessage[];\n discutionId: string;\n onMessage?: (chunk: string) => void;\n onDone?: (response: AskDocQuestionResult) => void;\n};\n\nexport type { AskDocQuestionResult };\n\nexport const getAiAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const AI_API_ROUTE = `${backendURL}/api/ai`;\n\n /**\n * Translate a JSON\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const translateJSON = async (\n body?: TranslateJSONResultBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TranslateJSONResult>(\n `${AI_API_ROUTE}/translate/json`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration file\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclaration = async (\n body?: AuditContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationResult>(\n `${AI_API_ROUTE}/audit/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration field\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationField = async (\n body?: AuditContentDeclarationFieldBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationFieldResult>(\n `${AI_API_ROUTE}/audit/dictionary/field`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration file to retrieve title, description and tags\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationMetadata = async (\n body?: AuditContentDeclarationMetadataBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationMetadataResult>(\n `${AI_API_ROUTE}/audit/dictionary/metadata`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a tag\n * @param body - Audit tag parameters.\n * @returns Audited tag content.\n */\n const auditTag = async (\n body?: AuditTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditTagResult>(\n `${AI_API_ROUTE}/audit/tag`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Asks a question to the AI related to the documentation **and streams the\n * answer as Server‑Sent Events (SSE)**.\n *\n * The function **returns immediately** with a handle exposing:\n * - `promise` → resolves when the stream completes (or rejects on error)\n * - `abort()` → allows canceling the request on demand\n *\n * Usage example:\n * ```ts\n * const { promise, abort } = ai.askDocQuestion({\n * ...body,\n * onMessage: console.log,\n * onDone: (full) => console.log(\"✔\", full),\n * });\n * // later → abort();\n * await promise; // waits for completion if desired\n * ```\n */\n const askDocQuestion = async (\n body?: AskDocQuestionBody,\n otherOptions: FetcherOptions = {}\n ) => {\n if (!body) return;\n\n const { onMessage, onDone, ...rest } = body;\n const abortController = new AbortController();\n\n try {\n const response = await fetch(`${AI_API_ROUTE}/ask`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...authAPIOptions.headers,\n ...otherOptions.headers,\n },\n body: JSON.stringify(rest),\n signal: abortController.signal,\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n\n throw new Error(errorData.message || 'Failed to fetch response');\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error('No reader available');\n }\n\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\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 data = JSON.parse(line.slice(6));\n if (data.chunk) {\n onMessage?.(data.chunk);\n }\n if (data.done && data.response) {\n onDone?.(data.response);\n }\n } catch (e) {\n console.error('Failed to parse SSE data:', e);\n }\n }\n }\n }\n } catch (error) {\n console.error('Error in askDocQuestion:', error);\n throw error;\n }\n };\n\n const autocomplete = async (\n body?: AutocompleteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AutocompleteResponse>(\n `${AI_API_ROUTE}/autocomplete`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n return {\n translateJSON,\n auditContentDeclaration,\n auditContentDeclarationField,\n auditContentDeclarationMetadata,\n auditTag,\n askDocQuestion,\n autocomplete,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCA,mBAA0B;AAG1B,qBAA6C;AAWtC,MAAM,WAAW,CACtB,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,aAAAA,QAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,GAAG,UAAU;AAOlC,QAAM,gBAAgB,OACpB,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,0BAA0B,OAC9B,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,+BAA+B,OACnC,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,kCAAkC,OACtC,MACA,eAA+B,CAA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BAAW,QAAQ,OAAO;AACxB,cAAI,KAAK,WAAW,QAAQ,GAAG;AAC7B,gBAAI;AACF,oBAAM,OAAO,KAAK,MAAM,KAAK,MAAM,CAAC,CAAC;AACrC,kBAAI,KAAK,OAAO;AACd,4BAAY,KAAK,KAAK;AAAA,cACxB;AACA,kBAAI,KAAK,QAAQ,KAAK,UAAU;AAC9B,yBAAS,KAAK,QAAQ;AAAA,cACxB;AAAA,YACF,SAAS,GAAG;AACV,sBAAQ,MAAM,6BAA6B,CAAC;AAAA,YAC9C;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,4BAA4B,KAAK;AAC/C,YAAM;AAAA,IACR;AAAA,EACF;AAEA,QAAM,eAAe,OACnB,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["configuration"]}
@@ -90,12 +90,11 @@ const getDictionaryAPI = (authAPIOptions = {}, intlayerConfig) => {
90
90
  }
91
91
  );
92
92
  const deleteDictionary = async (id, otherOptions = {}) => await (0, import_fetcher.fetcher)(
93
- `${PROJECT_API_ROUTE}`,
93
+ `${PROJECT_API_ROUTE}/${id}`,
94
94
  authAPIOptions,
95
95
  otherOptions,
96
96
  {
97
- method: "DELETE",
98
- body: { id }
97
+ method: "DELETE"
99
98
  }
100
99
  );
101
100
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/dictionary.ts"],"sourcesContent":["import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AddDictionaryBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AddDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteDictionaryParam,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryParam,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n PushDictionariesBody,\n // @ts-ignore: @intlayer/backend is not built yet\n PushDictionariesResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryQuery,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesKeysResult,\n // @ts-ignore @intlayer/backend is not build yet\n} from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport configuration from '@intlayer/config/built';\n\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getDictionaryAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/dictionary`;\n\n /**\n * Retrieves a list of dictionaries based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getDictionaries = async (\n filters?: GetDictionariesParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionariesResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Retrieves a list of dictionary keys related to the project.\n */\n const getDictionariesKeys = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetDictionariesKeysResult>(\n `${PROJECT_API_ROUTE}/keys`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Retrieves a dictionary by its key and version.\n * @param dictionaryKey - Dictionary key.\n * @param version - Dictionary version of content.\n */\n const getDictionary = async (\n dictionaryKey: GetDictionaryParams['dictionaryKey'],\n version?: GetDictionaryQuery['version'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionaryKey}`,\n authAPIOptions,\n otherOptions,\n {\n params: version ? { version: version.toString() } : undefined,\n }\n );\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const addDictionary = async (\n body: AddDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddDictionaryResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n const pushDictionaries = async (\n dictionaries: PushDictionariesBody['dictionaries'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushDictionariesResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { dictionaries },\n }\n );\n\n /**\n * Updates an existing dictionary in the database.\n * @param dictionary - Updated dictionary data.\n */\n const updateDictionary = async (\n dictionaryId: UpdateDictionaryParam['dictionaryId'],\n dictionary: UpdateDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionaryId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: dictionary,\n }\n );\n\n /**\n * Deletes a dictionary from the database by its ID.\n * @param id - Dictionary ID.\n */\n const deleteDictionary = async (\n id: DeleteDictionaryParam['dictionaryId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteDictionaryResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { id },\n }\n );\n\n return {\n getDictionaries,\n getDictionariesKeys,\n getDictionary,\n pushDictionaries,\n addDictionary,\n updateDictionary,\n deleteDictionary,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkCA,mBAA0B;AAE1B,qBAA6C;AAEtC,MAAM,mBAAmB,CAC9B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,aAAAA,QAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,oBAAoB,GAAG,UAAU;AAMvC,QAAM,kBAAkB,OACtB,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAKF,QAAM,sBAAsB,OAAO,eAA+B,CAAC,MACjE,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,EACF;AAOF,QAAM,gBAAgB,OACpB,eACA,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,aAAa;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ,UAAU,EAAE,SAAS,QAAQ,SAAS,EAAE,IAAI;AAAA,IACtD;AAAA,EACF;AAMF,QAAM,gBAAgB,OACpB,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEF,QAAM,mBAAmB,OACvB,cACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,EAAE,aAAa;AAAA,IACvB;AAAA,EACF;AAMF,QAAM,mBAAmB,OACvB,cACA,YACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,YAAY;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,mBAAmB,OACvB,IACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,EAAE,GAAG;AAAA,IACb;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["configuration"]}
1
+ {"version":3,"sources":["../../../src/getIntlayerAPI/dictionary.ts"],"sourcesContent":["import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AddDictionaryBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AddDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteDictionaryParam,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesKeysResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryQuery,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n PushDictionariesBody,\n // @ts-ignore: @intlayer/backend is not built yet\n PushDictionariesResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryParam,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n} from '@intlayer/backend';\nimport configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\n\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getDictionaryAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/dictionary`;\n\n /**\n * Retrieves a list of dictionaries based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getDictionaries = async (\n filters?: GetDictionariesParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionariesResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Retrieves a list of dictionary keys related to the project.\n */\n const getDictionariesKeys = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetDictionariesKeysResult>(\n `${PROJECT_API_ROUTE}/keys`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Retrieves a dictionary by its key and version.\n * @param dictionaryKey - Dictionary key.\n * @param version - Dictionary version of content.\n */\n const getDictionary = async (\n dictionaryKey: GetDictionaryParams['dictionaryKey'],\n version?: GetDictionaryQuery['version'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionaryKey}`,\n authAPIOptions,\n otherOptions,\n {\n params: version ? { version: version.toString() } : undefined,\n }\n );\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const addDictionary = async (\n body: AddDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddDictionaryResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n const pushDictionaries = async (\n dictionaries: PushDictionariesBody['dictionaries'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushDictionariesResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { dictionaries },\n }\n );\n\n /**\n * Updates an existing dictionary in the database.\n * @param dictionary - Updated dictionary data.\n */\n const updateDictionary = async (\n dictionaryId: UpdateDictionaryParam['dictionaryId'],\n dictionary: UpdateDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionaryId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: dictionary,\n }\n );\n\n /**\n * Deletes a dictionary from the database by its ID.\n * @param id - Dictionary ID.\n */\n const deleteDictionary = async (\n id: DeleteDictionaryParam['dictionaryId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteDictionaryResult>(\n `${PROJECT_API_ROUTE}/${id}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n getDictionaries,\n getDictionariesKeys,\n getDictionary,\n pushDictionaries,\n addDictionary,\n updateDictionary,\n deleteDictionary,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCA,mBAA0B;AAG1B,qBAA6C;AAEtC,MAAM,mBAAmB,CAC9B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,aAAAA,QAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,oBAAoB,GAAG,UAAU;AAMvC,QAAM,kBAAkB,OACtB,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAKF,QAAM,sBAAsB,OAAO,eAA+B,CAAC,MACjE,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,EACF;AAOF,QAAM,gBAAgB,OACpB,eACA,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,aAAa;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ,UAAU,EAAE,SAAS,QAAQ,SAAS,EAAE,IAAI;AAAA,IACtD;AAAA,EACF;AAMF,QAAM,gBAAgB,OACpB,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEF,QAAM,mBAAmB,OACvB,cACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,EAAE,aAAa;AAAA,IACvB;AAAA,EACF;AAMF,QAAM,mBAAmB,OACvB,cACA,YACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,YAAY;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,mBAAmB,OACvB,IACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,EAAE;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["configuration"]}
@@ -15,15 +15,33 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
16
  var index_exports = {};
17
17
  module.exports = __toCommonJS(index_exports);
18
- __reExport(index_exports, require('./getIntlayerAPI/index.cjs'), module.exports);
19
18
  __reExport(index_exports, require('./distantDictionary/index.cjs'), module.exports);
20
19
  __reExport(index_exports, require('./fetcher.cjs'), module.exports);
20
+ __reExport(index_exports, require('./getIntlayerAPI/index.cjs'), module.exports);
21
+ __reExport(index_exports, require('./getIntlayerAPI/ai.cjs'), module.exports);
22
+ __reExport(index_exports, require('./getIntlayerAPI/auth.cjs'), module.exports);
23
+ __reExport(index_exports, require('./getIntlayerAPI/dictionary.cjs'), module.exports);
24
+ __reExport(index_exports, require('./getIntlayerAPI/editor.cjs'), module.exports);
25
+ __reExport(index_exports, require('./getIntlayerAPI/organization.cjs'), module.exports);
26
+ __reExport(index_exports, require('./getIntlayerAPI/project.cjs'), module.exports);
27
+ __reExport(index_exports, require('./getIntlayerAPI/stripe.cjs'), module.exports);
28
+ __reExport(index_exports, require('./getIntlayerAPI/tag.cjs'), module.exports);
29
+ __reExport(index_exports, require('./getIntlayerAPI/user.cjs'), module.exports);
21
30
  __reExport(index_exports, require('./IntlayerEventListener.cjs'), module.exports);
22
31
  // Annotate the CommonJS export names for ESM import in node:
23
32
  0 && (module.exports = {
24
- ...require('./getIntlayerAPI/index.cjs'),
25
33
  ...require('./distantDictionary/index.cjs'),
26
34
  ...require('./fetcher.cjs'),
35
+ ...require('./getIntlayerAPI/index.cjs'),
36
+ ...require('./getIntlayerAPI/ai.cjs'),
37
+ ...require('./getIntlayerAPI/auth.cjs'),
38
+ ...require('./getIntlayerAPI/dictionary.cjs'),
39
+ ...require('./getIntlayerAPI/editor.cjs'),
40
+ ...require('./getIntlayerAPI/organization.cjs'),
41
+ ...require('./getIntlayerAPI/project.cjs'),
42
+ ...require('./getIntlayerAPI/stripe.cjs'),
43
+ ...require('./getIntlayerAPI/tag.cjs'),
44
+ ...require('./getIntlayerAPI/user.cjs'),
27
45
  ...require('./IntlayerEventListener.cjs')
28
46
  });
29
47
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './getIntlayerAPI';\nexport * from './distantDictionary/index';\nexport * from './fetcher';\nexport * from './IntlayerEventListener';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,6BAAd;AACA,0BAAc,sCADd;AAEA,0BAAc,sBAFd;AAGA,0BAAc,oCAHd;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './distantDictionary/index';\nexport * from './fetcher';\nexport * from './getIntlayerAPI';\nexport * from './getIntlayerAPI/ai';\nexport * from './getIntlayerAPI/auth';\nexport * from './getIntlayerAPI/dictionary';\nexport * from './getIntlayerAPI/editor';\nexport * from './getIntlayerAPI/organization';\nexport * from './getIntlayerAPI/project';\nexport * from './getIntlayerAPI/stripe';\nexport * from './getIntlayerAPI/tag';\nexport * from './getIntlayerAPI/user';\nexport * from './IntlayerEventListener';\n\n// @ts-ignore @intlayer/backend is not build yet\nexport type { AIOptions } from '@intlayer/backend';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,sCAAd;AACA,0BAAc,sBADd;AAEA,0BAAc,6BAFd;AAGA,0BAAc,gCAHd;AAIA,0BAAc,kCAJd;AAKA,0BAAc,wCALd;AAMA,0BAAc,oCANd;AAOA,0BAAc,0CAPd;AAQA,0BAAc,qCARd;AASA,0BAAc,oCATd;AAUA,0BAAc,iCAVd;AAWA,0BAAc,kCAXd;AAYA,0BAAc,oCAZd;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import configuration from "@intlayer/config/built";
2
- import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
2
+ import { getAuthAPI } from "./getIntlayerAPI/auth.mjs";
3
3
  class IntlayerEventListener {
4
4
  constructor(intlayerConfig = configuration) {
5
5
  this.intlayerConfig = intlayerConfig;
@@ -23,10 +23,10 @@ class IntlayerEventListener {
23
23
  */
24
24
  async initialize() {
25
25
  const backendURL = this.intlayerConfig.editor.backendURL;
26
- const oAuth2TokenResult = await getIntlayerAPI(
26
+ const oAuth2TokenResult = await getAuthAPI(
27
27
  {},
28
28
  this.intlayerConfig
29
- ).auth.getOAuth2AccessToken();
29
+ ).getOAuth2AccessToken();
30
30
  const accessToken = oAuth2TokenResult.data?.accessToken;
31
31
  if (!accessToken) {
32
32
  throw new Error("Failed to retrieve access token");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/IntlayerEventListener.ts"],"sourcesContent":["// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI, MessageEventData } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport configuration from '@intlayer/config/built';\n\nimport { getIntlayerAPI } from './getIntlayerAPI';\n\nexport type IntlayerMessageEvent = MessageEvent;\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 = configuration) {}\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 const backendURL = this.intlayerConfig.editor.backendURL;\n\n // Retrieve the access token\n const oAuth2TokenResult = await getIntlayerAPI(\n {},\n this.intlayerConfig\n ).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 throw new Error(\n 'Hot reload is enabled, but is only available for enterprise plans'\n );\n }\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 }\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\n const dataJSON: MessageEventData[] = JSON.parse(data);\n\n for (const dataEl of dataJSON) {\n switch (dataEl.object) {\n case 'DICTIONARY':\n switch (dataEl.status) {\n case 'ADDED':\n await this.onDictionaryAdded?.(dataEl.data);\n break;\n case 'UPDATED':\n await this.onDictionaryChange?.(dataEl.data);\n break;\n case 'DELETED':\n await this.onDictionaryDeleted?.(dataEl.data);\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"],"m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AK;AACH,sBAAM,KAAK,oBAAoB,OAAO,IAAI;AAC1C;AAAA,cACF,KAAK;AACH,sBAAM,KAAK,qBAAqB,OAAO,IAAI;AAC3C;AAAA,cACF,KAAK;AACH,sBAAM,KAAK,sBAAsB,OAAO,IAAI;AAC5C;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
+ {"version":3,"sources":["../../src/IntlayerEventListener.ts"],"sourcesContent":["// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI, MessageEventData } from '@intlayer/backend';\nimport configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { getAuthAPI } from './getIntlayerAPI/auth';\n\nexport type IntlayerMessageEvent = MessageEvent;\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 = configuration) {}\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 const backendURL = this.intlayerConfig.editor.backendURL;\n\n // Retrieve the access token\n const oAuth2TokenResult = await getAuthAPI(\n {},\n this.intlayerConfig\n ).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 throw new Error(\n 'Hot reload is enabled, but is only available for enterprise plans'\n );\n }\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 }\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\n const dataJSON: MessageEventData[] = JSON.parse(data);\n\n for (const dataEl of dataJSON) {\n switch (dataEl.object) {\n case 'DICTIONARY':\n switch (dataEl.status) {\n case 'ADDED':\n await this.onDictionaryAdded?.(dataEl.data);\n break;\n case 'UPDATED':\n await this.onDictionaryChange?.(dataEl.data);\n break;\n case 'DELETED':\n await this.onDictionaryDeleted?.(dataEl.data);\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,OAAO,mBAAmB;AAE1B,SAAS,kBAAkB;AA4BpB,MAAM,sBAAsB;AAAA,EAkBjC,YAAoB,iBAAiC,eAAe;AAAhD;AAAA,EAAiD;AAAA,EAjB7D,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,UAAM,aAAa,KAAK,eAAe,OAAO;AAG9C,UAAM,oBAAoB,MAAM;AAAA,MAC9B,CAAC;AAAA,MACD,KAAK;AAAA,IACP,EAAE,qBAAqB;AACvB,UAAM,cAAc,kBAAkB,MAAM;AAE5C,QAAI,CAAC,aAAa;AAChB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AAEA,QAAI,kBAAkB,MAAM,aAAa,MAAM,SAAS,cAAc;AACpE,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,YAAY,GAAG,UAAU;AAC/B,UAAM,MAAM,GAAG,SAAS,IAAI,WAAW;AAEvC,SAAK,cAAc,IAAI,YAAY,GAAG;AACtC,SAAK,YAAY,YAAY,CAAC,UAAU,KAAK,cAAc,KAAK;AAChE,SAAK,YAAY,UAAU,CAAC,UAAU,KAAK,YAAY,KAAK;AAAA,EAC9D;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;AAEjB,YAAM,WAA+B,KAAK,MAAM,IAAI;AAEpD,iBAAW,UAAU,UAAU;AAC7B,gBAAQ,OAAO,QAAQ;AAAA,UACrB,KAAK;AACH,oBAAQ,OAAO,QAAQ;AAAA,cACrB,KAAK;AACH,sBAAM,KAAK,oBAAoB,OAAO,IAAI;AAC1C;AAAA,cACF,KAAK;AACH,sBAAM,KAAK,qBAAqB,OAAO,IAAI;AAC3C;AAAA,cACF,KAAK;AACH,sBAAM,KAAK,sBAAsB,OAAO,IAAI;AAC5C;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,5 +1,6 @@
1
1
  import configuration from "@intlayer/config/built";
2
- import { getIntlayerAPI } from "../getIntlayerAPI/index.mjs";
2
+ import { getAuthAPI } from "../getIntlayerAPI/auth.mjs";
3
+ import { getDictionaryAPI } from "../getIntlayerAPI/dictionary.mjs";
3
4
  const fetchDistantDictionaries = async (intlayerConfig = configuration) => {
4
5
  try {
5
6
  const { clientId, clientSecret } = intlayerConfig?.editor;
@@ -8,15 +9,13 @@ const fetchDistantDictionaries = async (intlayerConfig = configuration) => {
8
9
  "Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
9
10
  );
10
11
  }
11
- const intlayerAPI = getIntlayerAPI(void 0, intlayerConfig);
12
- const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();
12
+ const dictionaryAPI = getDictionaryAPI(void 0, intlayerConfig);
13
+ const authAPI = getAuthAPI(void 0, intlayerConfig);
14
+ const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();
13
15
  const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
14
- const getDictionaryResult = await intlayerAPI.dictionary.getDictionaries(
15
- void 0,
16
- {
17
- headers: { Authorization: `Bearer ${oAuth2AccessToken}` }
18
- }
19
- );
16
+ const getDictionaryResult = await dictionaryAPI.getDictionaries(void 0, {
17
+ headers: { Authorization: `Bearer ${oAuth2AccessToken}` }
18
+ });
20
19
  const distantDictionaries = getDictionaryResult.data;
21
20
  return distantDictionaries;
22
21
  } catch (error) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport configuration from '@intlayer/config/built';\n\nimport { getIntlayerAPI } from '../getIntlayerAPI/index';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig = configuration\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://intlayer.org/dashboard/project.'\n );\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, intlayerConfig);\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await intlayerAPI.dictionary.getDictionaries(\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":"AAGA,OAAO,mBAAmB;AAE1B,SAAS,sBAAsB;AAKxB,MAAM,2BAA2B,OACtC,iBAAiC,kBACe;AAChD,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,gBAAgB;AAEnD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,cAAc,eAAe,QAAW,cAAc;AAE5D,UAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AAEtE,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,YAAY,WAAW;AAAA,MACvD;AAAA,MACA;AAAA,QACE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,MAC1D;AAAA,IACF;AAEA,UAAM,sBAAsB,oBAAoB;AAEhD,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport configuration from '@intlayer/config/built';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport { getAuthAPI } from '../getIntlayerAPI/auth';\nimport { getDictionaryAPI } from '../getIntlayerAPI/dictionary';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig = configuration\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://intlayer.org/dashboard/project.'\n );\n }\n\n const dictionaryAPI = getDictionaryAPI(undefined, intlayerConfig);\n const authAPI = getAuthAPI(undefined, intlayerConfig);\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionaries(undefined, {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n });\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":"AAEA,OAAO,mBAAmB;AAE1B,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AAK1B,MAAM,2BAA2B,OACtC,iBAAiC,kBACe;AAChD,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,gBAAgB;AAEnD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,gBAAgB,iBAAiB,QAAW,cAAc;AAChE,UAAM,UAAU,WAAW,QAAW,cAAc;AAEpD,UAAM,oBAAoB,MAAM,QAAQ,qBAAqB;AAE7D,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,cAAc,gBAAgB,QAAW;AAAA,MACzE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,IAC1D,CAAC;AAED,UAAM,sBAAsB,oBAAoB;AAEhD,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,5 +1,6 @@
1
1
  import configuration from "@intlayer/config/built";
2
- import { getIntlayerAPI } from "../getIntlayerAPI/index.mjs";
2
+ import { getAuthAPI } from "../getIntlayerAPI/auth.mjs";
3
+ import { getDictionaryAPI } from "../getIntlayerAPI/dictionary.mjs";
3
4
  const fetchDistantDictionary = async (dictionaryKey, intlayerConfig = configuration) => {
4
5
  try {
5
6
  const { clientId, clientSecret } = intlayerConfig?.editor;
@@ -8,10 +9,11 @@ const fetchDistantDictionary = async (dictionaryKey, intlayerConfig = configurat
8
9
  "Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
9
10
  );
10
11
  }
11
- const intlayerAPI = getIntlayerAPI(void 0, intlayerConfig);
12
- const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();
12
+ const dictionaryAPI = getDictionaryAPI(void 0, intlayerConfig);
13
+ const authAPI = getAuthAPI(void 0, intlayerConfig);
14
+ const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();
13
15
  const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
14
- const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(
16
+ const getDictionaryResult = await dictionaryAPI.getDictionary(
15
17
  dictionaryKey,
16
18
  void 0,
17
19
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport configuration from '@intlayer/config/built';\n\nimport { getIntlayerAPI } from '../getIntlayerAPI/index';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig = configuration\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://intlayer.org/dashboard/project.'\n );\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, intlayerConfig);\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(\n dictionaryKey,\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\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":"AAGA,OAAO,mBAAmB;AAE1B,SAAS,sBAAsB;AAKxB,MAAM,yBAAyB,OACpC,eACA,iBAAiC,kBACM;AACvC,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,gBAAgB;AAEnD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,cAAc,eAAe,QAAW,cAAc;AAE5D,UAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AAEtE,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,YAAY,WAAW;AAAA,MACvD;AAAA,MACA;AAAA,MACA;AAAA,QACE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,MAC1D;AAAA,IACF;AAEA,UAAM,oBAAoB,oBAAoB;AAE9C,QAAI,CAAC,mBAAmB;AACtB,YAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,IACnE;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { getAuthAPI } from '../getIntlayerAPI/auth';\nimport { getDictionaryAPI } from '../getIntlayerAPI/dictionary';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig = configuration\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://intlayer.org/dashboard/project.'\n );\n }\n\n const dictionaryAPI = getDictionaryAPI(undefined, intlayerConfig);\n const authAPI = getAuthAPI(undefined, intlayerConfig);\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionary(\n dictionaryKey,\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\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":"AAEA,OAAO,mBAAmB;AAE1B,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AAK1B,MAAM,yBAAyB,OACpC,eACA,iBAAiC,kBACM;AACvC,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,gBAAgB;AAEnD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,gBAAgB,iBAAiB,QAAW,cAAc;AAChE,UAAM,UAAU,WAAW,QAAW,cAAc;AAEpD,UAAM,oBAAoB,MAAM,QAAQ,qBAAqB;AAE7D,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,cAAc;AAAA,MAC9C;AAAA,MACA;AAAA,MACA;AAAA,QACE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,MAC1D;AAAA,IACF;AAEA,UAAM,oBAAoB,oBAAoB;AAE9C,QAAI,CAAC,mBAAmB;AACtB,YAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,IACnE;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -8,6 +8,15 @@ const getAiAPI = (authAPIOptions = {}, intlayerConfig) => {
8
8
  );
9
9
  }
10
10
  const AI_API_ROUTE = `${backendURL}/api/ai`;
11
+ const translateJSON = async (body, otherOptions = {}) => await fetcher(
12
+ `${AI_API_ROUTE}/translate/json`,
13
+ authAPIOptions,
14
+ otherOptions,
15
+ {
16
+ method: "POST",
17
+ body
18
+ }
19
+ );
11
20
  const auditContentDeclaration = async (body, otherOptions = {}) => await fetcher(
12
21
  `${AI_API_ROUTE}/audit/dictionary`,
13
22
  authAPIOptions,
@@ -106,6 +115,7 @@ const getAiAPI = (authAPIOptions = {}, intlayerConfig) => {
106
115
  }
107
116
  );
108
117
  return {
118
+ translateJSON,
109
119
  auditContentDeclaration,
110
120
  auditContentDeclarationField,
111
121
  auditContentDeclarationMetadata,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/ai.ts"],"sourcesContent":["import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AskDocQuestionResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationFieldBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationFieldResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationMetadataBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationMetadataResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditTagBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditTagResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AutocompleteBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AutocompleteResponse,\n // @ts-ignore: @intlayer/backend is not built yet\n ChatCompletionRequestMessage,\n // @ts-ignore: @intlayer/backend is not built yet\n} from '@intlayer/backend';\n\nimport configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\n\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport type AskDocQuestionBody = {\n messages: ChatCompletionRequestMessage[];\n discutionId: string;\n onMessage?: (chunk: string) => void;\n onDone?: (response: AskDocQuestionResult) => void;\n};\n\nexport type { AskDocQuestionResult };\n\nexport const getAiAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const AI_API_ROUTE = `${backendURL}/api/ai`;\n\n /**\n * Audits a content declaration file\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclaration = async (\n body?: AuditContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationResult>(\n `${AI_API_ROUTE}/audit/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration field\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationField = async (\n body?: AuditContentDeclarationFieldBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationFieldResult>(\n `${AI_API_ROUTE}/audit/dictionary/field`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration file to retrieve title, description and tags\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationMetadata = async (\n body?: AuditContentDeclarationMetadataBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationMetadataResult>(\n `${AI_API_ROUTE}/audit/dictionary/metadata`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a tag\n * @param body - Audit tag parameters.\n * @returns Audited tag content.\n */\n const auditTag = async (\n body?: AuditTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditTagResult>(\n `${AI_API_ROUTE}/audit/tag`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Asks a question to the AI related to the documentation **and streams the\n * answer as Server‑Sent Events (SSE)**.\n *\n * The function **returns immediately** with a handle exposing:\n * - `promise` → resolves when the stream completes (or rejects on error)\n * - `abort()` → allows canceling the request on demand\n *\n * Usage example:\n * ```ts\n * const { promise, abort } = ai.askDocQuestion({\n * ...body,\n * onMessage: console.log,\n * onDone: (full) => console.log(\"✔\", full),\n * });\n * // later → abort();\n * await promise; // waits for completion if desired\n * ```\n */\n const askDocQuestion = async (\n body?: AskDocQuestionBody,\n otherOptions: FetcherOptions = {}\n ) => {\n if (!body) return;\n\n const { onMessage, onDone, ...rest } = body;\n const abortController = new AbortController();\n\n try {\n const response = await fetch(`${AI_API_ROUTE}/ask`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...authAPIOptions.headers,\n ...otherOptions.headers,\n },\n body: JSON.stringify(rest),\n signal: abortController.signal,\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n\n throw new Error(errorData.message || 'Failed to fetch response');\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error('No reader available');\n }\n\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\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 data = JSON.parse(line.slice(6));\n if (data.chunk) {\n onMessage?.(data.chunk);\n }\n if (data.done && data.response) {\n onDone?.(data.response);\n }\n } catch (e) {\n console.error('Failed to parse SSE data:', e);\n }\n }\n }\n }\n } catch (error) {\n console.error('Error in askDocQuestion:', error);\n throw error;\n }\n };\n\n const autocomplete = async (\n body?: AutocompleteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AutocompleteResponse>(\n `${AI_API_ROUTE}/autocomplete`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n return {\n auditContentDeclaration,\n auditContentDeclarationField,\n auditContentDeclarationMetadata,\n auditTag,\n askDocQuestion,\n autocomplete,\n };\n};\n"],"mappings":"AA4BA,OAAO,mBAAmB;AAG1B,SAAS,eAAoC;AAWtC,MAAM,WAAW,CACtB,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,cAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,GAAG,UAAU;AAOlC,QAAM,0BAA0B,OAC9B,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,+BAA+B,OACnC,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,kCAAkC,OACtC,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,WAAW,OACf,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAqBF,QAAM,iBAAiB,OACrB,MACA,eAA+B,CAAC,MAC7B;AACH,QAAI,CAAC,KAAM;AAEX,UAAM,EAAE,WAAW,QAAQ,GAAG,KAAK,IAAI;AACvC,UAAM,kBAAkB,IAAI,gBAAgB;AAE5C,Q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ACF;AAEA,QAAM,eAAe,OACnB,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/getIntlayerAPI/ai.ts"],"sourcesContent":["import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AskDocQuestionResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationFieldBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationFieldResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationMetadataBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationMetadataResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditContentDeclarationResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditTagBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AuditTagResult,\n // @ts-ignore: @intlayer/backend is not built yet\n AutocompleteBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AutocompleteResponse,\n // @ts-ignore: @intlayer/backend is not built yet\n ChatCompletionRequestMessage,\n // @ts-ignore: @intlayer/backend is not built yet\n TranslateJSONResult,\n // @ts-ignore: @intlayer/backend is not built yet\n TranslateJSONResultBody,\n // @ts-ignore: @intlayer/backend is not built yet\n} from '@intlayer/backend';\n\nimport configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\n\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport type AskDocQuestionBody = {\n messages: ChatCompletionRequestMessage[];\n discutionId: string;\n onMessage?: (chunk: string) => void;\n onDone?: (response: AskDocQuestionResult) => void;\n};\n\nexport type { AskDocQuestionResult };\n\nexport const getAiAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const AI_API_ROUTE = `${backendURL}/api/ai`;\n\n /**\n * Translate a JSON\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const translateJSON = async (\n body?: TranslateJSONResultBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TranslateJSONResult>(\n `${AI_API_ROUTE}/translate/json`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration file\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclaration = async (\n body?: AuditContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationResult>(\n `${AI_API_ROUTE}/audit/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration field\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationField = async (\n body?: AuditContentDeclarationFieldBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationFieldResult>(\n `${AI_API_ROUTE}/audit/dictionary/field`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration file to retrieve title, description and tags\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationMetadata = async (\n body?: AuditContentDeclarationMetadataBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationMetadataResult>(\n `${AI_API_ROUTE}/audit/dictionary/metadata`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a tag\n * @param body - Audit tag parameters.\n * @returns Audited tag content.\n */\n const auditTag = async (\n body?: AuditTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditTagResult>(\n `${AI_API_ROUTE}/audit/tag`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Asks a question to the AI related to the documentation **and streams the\n * answer as Server‑Sent Events (SSE)**.\n *\n * The function **returns immediately** with a handle exposing:\n * - `promise` → resolves when the stream completes (or rejects on error)\n * - `abort()` → allows canceling the request on demand\n *\n * Usage example:\n * ```ts\n * const { promise, abort } = ai.askDocQuestion({\n * ...body,\n * onMessage: console.log,\n * onDone: (full) => console.log(\"✔\", full),\n * });\n * // later → abort();\n * await promise; // waits for completion if desired\n * ```\n */\n const askDocQuestion = async (\n body?: AskDocQuestionBody,\n otherOptions: FetcherOptions = {}\n ) => {\n if (!body) return;\n\n const { onMessage, onDone, ...rest } = body;\n const abortController = new AbortController();\n\n try {\n const response = await fetch(`${AI_API_ROUTE}/ask`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...authAPIOptions.headers,\n ...otherOptions.headers,\n },\n body: JSON.stringify(rest),\n signal: abortController.signal,\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n\n throw new Error(errorData.message || 'Failed to fetch response');\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error('No reader available');\n }\n\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\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 data = JSON.parse(line.slice(6));\n if (data.chunk) {\n onMessage?.(data.chunk);\n }\n if (data.done && data.response) {\n onDone?.(data.response);\n }\n } catch (e) {\n console.error('Failed to parse SSE data:', e);\n }\n }\n }\n }\n } catch (error) {\n console.error('Error in askDocQuestion:', error);\n throw error;\n }\n };\n\n const autocomplete = async (\n body?: AutocompleteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AutocompleteResponse>(\n `${AI_API_ROUTE}/autocomplete`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n return {\n translateJSON,\n auditContentDeclaration,\n auditContentDeclarationField,\n auditContentDeclarationMetadata,\n auditTag,\n askDocQuestion,\n autocomplete,\n };\n};\n"],"mappings":"AAgCA,OAAO,mBAAmB;AAG1B,SAAS,eAAoC;AAWtC,MAAM,WAAW,CACtB,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,cAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,GAAG,UAAU;AAOlC,QAAM,gBAAgB,OACpB,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,0BAA0B,OAC9B,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,+BAA+B,OACnC,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,kCAAkC,OACtC,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,WAAW,OACf,MACA,eAA+B,CAAC,M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AK,KAAK;AAAA,cACxB;AACA,kBAAI,KAAK,QAAQ,KAAK,UAAU;AAC9B,yBAAS,KAAK,QAAQ;AAAA,cACxB;AAAA,YACF,SAAS,GAAG;AACV,sBAAQ,MAAM,6BAA6B,CAAC;AAAA,YAC9C;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,4BAA4B,KAAK;AAC/C,YAAM;AAAA,IACR;AAAA,EACF;AAEA,QAAM,eAAe,OACnB,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -57,12 +57,11 @@ const getDictionaryAPI = (authAPIOptions = {}, intlayerConfig) => {
57
57
  }
58
58
  );
59
59
  const deleteDictionary = async (id, otherOptions = {}) => await fetcher(
60
- `${PROJECT_API_ROUTE}`,
60
+ `${PROJECT_API_ROUTE}/${id}`,
61
61
  authAPIOptions,
62
62
  otherOptions,
63
63
  {
64
- method: "DELETE",
65
- body: { id }
64
+ method: "DELETE"
66
65
  }
67
66
  );
68
67
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/dictionary.ts"],"sourcesContent":["import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AddDictionaryBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AddDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteDictionaryParam,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryParam,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n PushDictionariesBody,\n // @ts-ignore: @intlayer/backend is not built yet\n PushDictionariesResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryQuery,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesKeysResult,\n // @ts-ignore @intlayer/backend is not build yet\n} from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport configuration from '@intlayer/config/built';\n\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getDictionaryAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/dictionary`;\n\n /**\n * Retrieves a list of dictionaries based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getDictionaries = async (\n filters?: GetDictionariesParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionariesResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Retrieves a list of dictionary keys related to the project.\n */\n const getDictionariesKeys = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetDictionariesKeysResult>(\n `${PROJECT_API_ROUTE}/keys`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Retrieves a dictionary by its key and version.\n * @param dictionaryKey - Dictionary key.\n * @param version - Dictionary version of content.\n */\n const getDictionary = async (\n dictionaryKey: GetDictionaryParams['dictionaryKey'],\n version?: GetDictionaryQuery['version'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionaryKey}`,\n authAPIOptions,\n otherOptions,\n {\n params: version ? { version: version.toString() } : undefined,\n }\n );\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const addDictionary = async (\n body: AddDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddDictionaryResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n const pushDictionaries = async (\n dictionaries: PushDictionariesBody['dictionaries'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushDictionariesResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { dictionaries },\n }\n );\n\n /**\n * Updates an existing dictionary in the database.\n * @param dictionary - Updated dictionary data.\n */\n const updateDictionary = async (\n dictionaryId: UpdateDictionaryParam['dictionaryId'],\n dictionary: UpdateDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionaryId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: dictionary,\n }\n );\n\n /**\n * Deletes a dictionary from the database by its ID.\n * @param id - Dictionary ID.\n */\n const deleteDictionary = async (\n id: DeleteDictionaryParam['dictionaryId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteDictionaryResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { id },\n }\n );\n\n return {\n getDictionaries,\n getDictionariesKeys,\n getDictionary,\n pushDictionaries,\n addDictionary,\n updateDictionary,\n deleteDictionary,\n };\n};\n"],"mappings":"AAkCA,OAAO,mBAAmB;AAE1B,SAAS,eAAoC;AAEtC,MAAM,mBAAmB,CAC9B,iBAAiC,CAAC,GA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C,MAEhC,MAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,EAAE,GAAG;AAAA,IACb;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/getIntlayerAPI/dictionary.ts"],"sourcesContent":["import type {\n // @ts-ignore: @intlayer/backend is not built yet\n AddDictionaryBody,\n // @ts-ignore: @intlayer/backend is not built yet\n AddDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteDictionaryParam,\n // @ts-ignore: @intlayer/backend is not built yet\n DeleteDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesKeysResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionariesResult,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryParams,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryQuery,\n // @ts-ignore: @intlayer/backend is not built yet\n GetDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n PushDictionariesBody,\n // @ts-ignore: @intlayer/backend is not built yet\n PushDictionariesResult,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryBody,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryParam,\n // @ts-ignore: @intlayer/backend is not built yet\n UpdateDictionaryResult,\n // @ts-ignore: @intlayer/backend is not built yet\n} from '@intlayer/backend';\nimport configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\n\nimport { fetcher, type FetcherOptions } from '../fetcher';\n\nexport const getDictionaryAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/dictionary`;\n\n /**\n * Retrieves a list of dictionaries based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getDictionaries = async (\n filters?: GetDictionariesParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionariesResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Retrieves a list of dictionary keys related to the project.\n */\n const getDictionariesKeys = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetDictionariesKeysResult>(\n `${PROJECT_API_ROUTE}/keys`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Retrieves a dictionary by its key and version.\n * @param dictionaryKey - Dictionary key.\n * @param version - Dictionary version of content.\n */\n const getDictionary = async (\n dictionaryKey: GetDictionaryParams['dictionaryKey'],\n version?: GetDictionaryQuery['version'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionaryKey}`,\n authAPIOptions,\n otherOptions,\n {\n params: version ? { version: version.toString() } : undefined,\n }\n );\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const addDictionary = async (\n body: AddDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddDictionaryResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n const pushDictionaries = async (\n dictionaries: PushDictionariesBody['dictionaries'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushDictionariesResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { dictionaries },\n }\n );\n\n /**\n * Updates an existing dictionary in the database.\n * @param dictionary - Updated dictionary data.\n */\n const updateDictionary = async (\n dictionaryId: UpdateDictionaryParam['dictionaryId'],\n dictionary: UpdateDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionaryId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: dictionary,\n }\n );\n\n /**\n * Deletes a dictionary from the database by its ID.\n * @param id - Dictionary ID.\n */\n const deleteDictionary = async (\n id: DeleteDictionaryParam['dictionaryId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteDictionaryResult>(\n `${PROJECT_API_ROUTE}/${id}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n getDictionaries,\n getDictionariesKeys,\n getDictionary,\n pushDictionaries,\n addDictionary,\n updateDictionary,\n deleteDictionary,\n };\n};\n"],"mappings":"AAiCA,OAAO,mBAAmB;AAG1B,SAAS,eAAoC;AAEtC,MAAM,mBAAmB,CAC9B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,cAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,oBAAoB,GAAG,UAAU;AAMvC,QAAM,kBAAkB,OACtB,SACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAKF,QAAM,sBAAsB,OAAO,eAA+B,CAAC,MACjE,MAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,EACF;AAOF,QAAM,gBAAgB,OACpB,eACA,SACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,aAAa;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ,UAAU,EAAE,SAAS,QAAQ,SAAS,EAAE,IAAI;AAAA,IACtD;AAAA,EACF;AAMF,QAAM,gBAAgB,OACpB,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEF,QAAM,mBAAmB,OACvB,cACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,EAAE,aAAa;AAAA,IACvB;AAAA,EACF;AAMF,QAAM,mBAAmB,OACvB,cACA,YACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,YAAY;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,mBAAmB,OACvB,IACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,EAAE;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1,5 +1,14 @@
1
- export * from "./getIntlayerAPI/index.mjs";
2
1
  export * from "./distantDictionary/index.mjs";
3
2
  export * from "./fetcher.mjs";
3
+ export * from "./getIntlayerAPI/index.mjs";
4
+ export * from "./getIntlayerAPI/ai.mjs";
5
+ export * from "./getIntlayerAPI/auth.mjs";
6
+ export * from "./getIntlayerAPI/dictionary.mjs";
7
+ export * from "./getIntlayerAPI/editor.mjs";
8
+ export * from "./getIntlayerAPI/organization.mjs";
9
+ export * from "./getIntlayerAPI/project.mjs";
10
+ export * from "./getIntlayerAPI/stripe.mjs";
11
+ export * from "./getIntlayerAPI/tag.mjs";
12
+ export * from "./getIntlayerAPI/user.mjs";
4
13
  export * from "./IntlayerEventListener.mjs";
5
14
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './getIntlayerAPI';\nexport * from './distantDictionary/index';\nexport * from './fetcher';\nexport * from './IntlayerEventListener';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './distantDictionary/index';\nexport * from './fetcher';\nexport * from './getIntlayerAPI';\nexport * from './getIntlayerAPI/ai';\nexport * from './getIntlayerAPI/auth';\nexport * from './getIntlayerAPI/dictionary';\nexport * from './getIntlayerAPI/editor';\nexport * from './getIntlayerAPI/organization';\nexport * from './getIntlayerAPI/project';\nexport * from './getIntlayerAPI/stripe';\nexport * from './getIntlayerAPI/tag';\nexport * from './getIntlayerAPI/user';\nexport * from './IntlayerEventListener';\n\n// @ts-ignore @intlayer/backend is not build yet\nexport type { AIOptions } from '@intlayer/backend';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerEventListener.d.ts","sourceRoot":"","sources":["../../src/IntlayerEventListener.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAK9D,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,qBAAqB;IAkBpB,OAAO,CAAC,cAAc;IAjBlC,OAAO,CAAC,WAAW,CAA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CAAC,WAAW;CAIpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.d.ts","sourceRoot":"","sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAK9D;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,iBAAgB,cAA8B,KAC7C,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,GAAG,SAAS,CA+B5C,CAAC"}
1
+ {"version":3,"file":"fetchDistantDictionaries.d.ts","sourceRoot":"","sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAI9D;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,iBAAgB,cAA8B,KAC7C,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,GAAG,SAAS,CA6B5C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionary.d.ts","sourceRoot":"","sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAK9D;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,eAAe,MAAM,EACrB,iBAAgB,cAA8B,KAC7C,OAAO,CAAC,aAAa,GAAG,SAAS,CAoCnC,CAAC"}
1
+ {"version":3,"file":"fetchDistantDictionary.d.ts","sourceRoot":"","sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAI9D;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,eAAe,MAAM,EACrB,iBAAgB,cAA8B,KAC7C,OAAO,CAAC,aAAa,GAAG,SAAS,CAqCnC,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { AskDocQuestionResult, AuditContentDeclarationBody, AuditContentDeclarationFieldBody, AuditContentDeclarationFieldResult, AuditContentDeclarationMetadataBody, AuditContentDeclarationMetadataResult, AuditContentDeclarationResult, AuditTagBody, AuditTagResult, AutocompleteBody, AutocompleteResponse, ChatCompletionRequestMessage } from '@intlayer/backend';
1
+ import type { AskDocQuestionResult, AuditContentDeclarationBody, AuditContentDeclarationFieldBody, AuditContentDeclarationFieldResult, AuditContentDeclarationMetadataBody, AuditContentDeclarationMetadataResult, AuditContentDeclarationResult, AuditTagBody, AuditTagResult, AutocompleteBody, AutocompleteResponse, ChatCompletionRequestMessage, TranslateJSONResult, TranslateJSONResultBody } from '@intlayer/backend';
2
2
  import type { IntlayerConfig } from '@intlayer/config/client';
3
3
  import { type FetcherOptions } from '../fetcher';
4
4
  export type AskDocQuestionBody = {
@@ -9,6 +9,7 @@ export type AskDocQuestionBody = {
9
9
  };
10
10
  export type { AskDocQuestionResult };
11
11
  export declare const getAiAPI: (authAPIOptions?: FetcherOptions, intlayerConfig?: IntlayerConfig) => {
12
+ translateJSON: (body?: TranslateJSONResultBody, otherOptions?: FetcherOptions) => Promise<TranslateJSONResult>;
12
13
  auditContentDeclaration: (body?: AuditContentDeclarationBody, otherOptions?: FetcherOptions) => Promise<AuditContentDeclarationResult>;
13
14
  auditContentDeclarationField: (body?: AuditContentDeclarationFieldBody, otherOptions?: FetcherOptions) => Promise<AuditContentDeclarationFieldResult>;
14
15
  auditContentDeclarationMetadata: (body?: AuditContentDeclarationMetadataBody, otherOptions?: FetcherOptions) => Promise<AuditContentDeclarationMetadataResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../src/getIntlayerAPI/ai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EAEpB,2BAA2B,EAE3B,gCAAgC,EAEhC,kCAAkC,EAElC,mCAAmC,EAEnC,qCAAqC,EAErC,6BAA6B,EAE7B,YAAY,EAEZ,cAAc,EAEd,gBAAgB,EAEhB,oBAAoB,EAEpB,4BAA4B,EAE7B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,4BAA4B,EAAE,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;CACnD,CAAC;AAEF,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAErC,eAAO,MAAM,QAAQ,GACnB,iBAAgB,cAAmB,EACnC,iBAAiB,cAAc;qCAmBtB,2BAA2B,iBACpB,cAAc;0CAkBrB,gCAAgC,iBACzB,cAAc;6CAkBrB,mCAAmC,iBAC5B,cAAc;sBAkBrB,YAAY,iBACL,cAAc;4BAgCrB,kBAAkB,iBACX,cAAc;0BAgErB,gBAAgB,iBACT,cAAc;CAoB/B,CAAC"}
1
+ {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../src/getIntlayerAPI/ai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EAEpB,2BAA2B,EAE3B,gCAAgC,EAEhC,kCAAkC,EAElC,mCAAmC,EAEnC,qCAAqC,EAErC,6BAA6B,EAE7B,YAAY,EAEZ,cAAc,EAEd,gBAAgB,EAEhB,oBAAoB,EAEpB,4BAA4B,EAE5B,mBAAmB,EAEnB,uBAAuB,EAExB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,4BAA4B,EAAE,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;CACnD,CAAC;AAEF,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAErC,eAAO,MAAM,QAAQ,GACnB,iBAAgB,cAAmB,EACnC,iBAAiB,cAAc;2BAmBtB,uBAAuB,iBAChB,cAAc;qCAkBrB,2BAA2B,iBACpB,cAAc;0CAkBrB,gCAAgC,iBACzB,cAAc;6CAkBrB,mCAAmC,iBAC5B,cAAc;sBAkBrB,YAAY,iBACL,cAAc;4BAgCrB,kBAAkB,iBACX,cAAc;0BAgErB,gBAAgB,iBACT,cAAc;CAqB/B,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { AddDictionaryBody, AddDictionaryResult, DeleteDictionaryParam, DeleteDictionaryResult, GetDictionariesParams, GetDictionariesResult, UpdateDictionaryParam, UpdateDictionaryBody, UpdateDictionaryResult, PushDictionariesBody, PushDictionariesResult, GetDictionaryParams, GetDictionaryQuery, GetDictionaryResult, GetDictionariesKeysResult } from '@intlayer/backend';
1
+ import type { AddDictionaryBody, AddDictionaryResult, DeleteDictionaryParam, DeleteDictionaryResult, GetDictionariesKeysResult, GetDictionariesParams, GetDictionariesResult, GetDictionaryParams, GetDictionaryQuery, GetDictionaryResult, PushDictionariesBody, PushDictionariesResult, UpdateDictionaryBody, UpdateDictionaryParam, UpdateDictionaryResult } from '@intlayer/backend';
2
2
  import type { IntlayerConfig } from '@intlayer/config/client';
3
3
  import { type FetcherOptions } from '../fetcher';
4
4
  export declare const getDictionaryAPI: (authAPIOptions?: FetcherOptions, intlayerConfig?: IntlayerConfig) => {
@@ -1 +1 @@
1
- {"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../src/getIntlayerAPI/dictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,iBAAiB,EAEjB,mBAAmB,EAEnB,qBAAqB,EAErB,sBAAsB,EAEtB,qBAAqB,EAErB,qBAAqB,EAErB,qBAAqB,EAErB,oBAAoB,EAEpB,sBAAsB,EAEtB,oBAAoB,EAEpB,sBAAsB,EAEtB,mBAAmB,EAEnB,kBAAkB,EAElB,mBAAmB,EAEnB,yBAAyB,EAE1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE1D,eAAO,MAAM,gBAAgB,GAC3B,iBAAgB,cAAmB,EACnC,iBAAiB,cAAc;gCAkBnB,qBAAqB,iBACjB,cAAc;yCAcmB,cAAc;mCAa9C,mBAAmB,CAAC,eAAe,CAAC,YACzC,kBAAkB,CAAC,SAAS,CAAC,iBACzB,cAAc;qCA8Bd,oBAAoB,CAAC,cAAc,CAAC,iBACpC,cAAc;0BAftB,iBAAiB,iBACT,cAAc;qCA+Bd,qBAAqB,CAAC,cAAc,CAAC,cACvC,oBAAoB,iBAClB,cAAc;2BAiBxB,qBAAqB,CAAC,cAAc,CAAC,iBAC3B,cAAc;CAqB/B,CAAC"}
1
+ {"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../src/getIntlayerAPI/dictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,iBAAiB,EAEjB,mBAAmB,EAEnB,qBAAqB,EAErB,sBAAsB,EAEtB,yBAAyB,EAEzB,qBAAqB,EAErB,qBAAqB,EAErB,mBAAmB,EAEnB,kBAAkB,EAElB,mBAAmB,EAEnB,oBAAoB,EAEpB,sBAAsB,EAEtB,oBAAoB,EAEpB,qBAAqB,EAErB,sBAAsB,EAEvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE1D,eAAO,MAAM,gBAAgB,GAC3B,iBAAgB,cAAmB,EACnC,iBAAiB,cAAc;gCAkBnB,qBAAqB,iBACjB,cAAc;yCAcmB,cAAc;mCAa9C,mBAAmB,CAAC,eAAe,CAAC,YACzC,kBAAkB,CAAC,SAAS,CAAC,iBACzB,cAAc;qCA8Bd,oBAAoB,CAAC,cAAc,CAAC,iBACpC,cAAc;0BAftB,iBAAiB,iBACT,cAAc;qCA+Bd,qBAAqB,CAAC,cAAc,CAAC,cACvC,oBAAoB,iBAClB,cAAc;2BAiBxB,qBAAqB,CAAC,cAAc,CAAC,iBAC3B,cAAc;CAoB/B,CAAC"}
@@ -67,6 +67,7 @@ export declare const getIntlayerAPI: (authAPIOptions?: FetcherOptions, intlayerC
67
67
  cancelSubscription: (otherOptions?: FetcherOptions) => Promise<import("@intlayer/backend").GetCheckoutSessionResult>;
68
68
  };
69
69
  ai: {
70
+ translateJSON: (body?: TranslateJSONResultBody, otherOptions?: FetcherOptions) => Promise<import("@intlayer/backend").TranslateJSONResult>;
70
71
  auditContentDeclaration: (body?: import("@intlayer/backend").AuditContentDeclarationBody, otherOptions?: FetcherOptions) => Promise<import("@intlayer/backend").AuditContentDeclarationResult>;
71
72
  auditContentDeclarationField: (body?: import("@intlayer/backend").AuditContentDeclarationFieldBody, otherOptions?: FetcherOptions) => Promise<import("@intlayer/backend").AuditContentDeclarationFieldResult>;
72
73
  auditContentDeclarationMetadata: (body?: import("@intlayer/backend").AuditContentDeclarationMetadataBody, otherOptions?: FetcherOptions) => Promise<import("@intlayer/backend").AuditContentDeclarationMetadataResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/getIntlayerAPI/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAWjD,eAAO,MAAM,cAAc,GACzB,iBAAgB,cAAmB,EACnC,iBAAiB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAW/B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/getIntlayerAPI/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAWjD,eAAO,MAAM,cAAc,GACzB,iBAAgB,cAAmB,EACnC,iBAAiB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAW/B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -1,5 +1,15 @@
1
- export * from './getIntlayerAPI';
2
1
  export * from './distantDictionary/index';
3
2
  export * from './fetcher';
3
+ export * from './getIntlayerAPI';
4
+ export * from './getIntlayerAPI/ai';
5
+ export * from './getIntlayerAPI/auth';
6
+ export * from './getIntlayerAPI/dictionary';
7
+ export * from './getIntlayerAPI/editor';
8
+ export * from './getIntlayerAPI/organization';
9
+ export * from './getIntlayerAPI/project';
10
+ export * from './getIntlayerAPI/stripe';
11
+ export * from './getIntlayerAPI/tag';
12
+ export * from './getIntlayerAPI/user';
4
13
  export * from './IntlayerEventListener';
14
+ export type { AIOptions } from '@intlayer/backend';
5
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAGxC,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/api",
3
- "version": "5.4.2",
3
+ "version": "5.5.0-canary.0",
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": [
@@ -58,7 +58,7 @@
58
58
  "./package.json"
59
59
  ],
60
60
  "dependencies": {
61
- "@intlayer/config": "5.4.2"
61
+ "@intlayer/config": "5.5.0-canary.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@changesets/changelog-github": "0.5.1",
@@ -74,13 +74,13 @@
74
74
  "typescript": "^5.8.2",
75
75
  "@utils/eslint-config": "1.0.4",
76
76
  "@utils/ts-config": "1.0.4",
77
- "@intlayer/backend": "5.4.2",
78
- "@utils/tsup-config": "1.0.4",
79
77
  "@utils/ts-config-types": "1.0.4",
80
- "intlayer-editor": "5.4.2"
78
+ "@utils/tsup-config": "1.0.4",
79
+ "@intlayer/backend": "5.5.0-canary.0",
80
+ "intlayer-editor": "5.5.0-canary.0"
81
81
  },
82
82
  "peerDependencies": {
83
- "@intlayer/config": "5.4.2"
83
+ "@intlayer/config": "5.5.0-canary.0"
84
84
  },
85
85
  "engines": {
86
86
  "node": ">=14.18"