@intlayer/api 5.8.1 → 6.0.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 (66) hide show
  1. package/dist/cjs/distantDictionary/index.cjs +3 -3
  2. package/dist/cjs/distantDictionary/index.cjs.map +1 -1
  3. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  4. package/dist/cjs/getIntlayerAPI/dictionary.cjs +8 -2
  5. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  6. package/dist/cjs/getIntlayerAPI/editor.cjs +2 -2
  7. package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
  8. package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
  9. package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
  10. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  11. package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
  12. package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
  13. package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
  14. package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
  15. package/dist/cjs/index.cjs +0 -2
  16. package/dist/cjs/index.cjs.map +1 -1
  17. package/dist/cjs/types.cjs.map +1 -1
  18. package/dist/esm/distantDictionary/index.mjs +1 -1
  19. package/dist/esm/distantDictionary/index.mjs.map +1 -1
  20. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  21. package/dist/esm/getIntlayerAPI/dictionary.mjs +8 -2
  22. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  23. package/dist/esm/getIntlayerAPI/editor.mjs +2 -2
  24. package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
  25. package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
  26. package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
  27. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  28. package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
  29. package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
  30. package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
  31. package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
  32. package/dist/esm/index.mjs +0 -1
  33. package/dist/esm/index.mjs.map +1 -1
  34. package/dist/types/distantDictionary/index.d.ts +1 -1
  35. package/dist/types/distantDictionary/index.d.ts.map +1 -1
  36. package/dist/types/getIntlayerAPI/ai.d.ts +1 -1
  37. package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
  38. package/dist/types/getIntlayerAPI/dictionary.d.ts +3 -2
  39. package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
  40. package/dist/types/getIntlayerAPI/editor.d.ts +3 -3
  41. package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
  42. package/dist/types/getIntlayerAPI/newsletter.d.ts +1 -1
  43. package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
  44. package/dist/types/getIntlayerAPI/organization.d.ts +1 -1
  45. package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
  46. package/dist/types/getIntlayerAPI/project.d.ts +1 -1
  47. package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
  48. package/dist/types/getIntlayerAPI/search.d.ts +1 -1
  49. package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
  50. package/dist/types/getIntlayerAPI/stripe.d.ts +1 -1
  51. package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
  52. package/dist/types/getIntlayerAPI/tag.d.ts +1 -1
  53. package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
  54. package/dist/types/getIntlayerAPI/user.d.ts +1 -1
  55. package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
  56. package/dist/types/index.d.ts +0 -1
  57. package/dist/types/index.d.ts.map +1 -1
  58. package/dist/types/types.d.ts +2 -2
  59. package/dist/types/types.d.ts.map +1 -1
  60. package/package.json +9 -12
  61. package/dist/cjs/IntlayerEventListener.cjs +0 -127
  62. package/dist/cjs/IntlayerEventListener.cjs.map +0 -1
  63. package/dist/esm/IntlayerEventListener.mjs +0 -93
  64. package/dist/esm/IntlayerEventListener.mjs.map +0 -1
  65. package/dist/types/IntlayerEventListener.d.ts +0 -63
  66. package/dist/types/IntlayerEventListener.d.ts.map +0 -1
@@ -1,127 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var IntlayerEventListener_exports = {};
30
- __export(IntlayerEventListener_exports, {
31
- IntlayerEventListener: () => IntlayerEventListener
32
- });
33
- module.exports = __toCommonJS(IntlayerEventListener_exports);
34
- var import_built = __toESM(require("@intlayer/config/built"));
35
- var import_oAuth = require('./getIntlayerAPI/oAuth.cjs');
36
- class IntlayerEventListener {
37
- constructor(intlayerConfig = import_built.default) {
38
- this.intlayerConfig = intlayerConfig;
39
- }
40
- eventSource = null;
41
- /**
42
- * Callback triggered when a Dictionary is ADDED.
43
- */
44
- onDictionaryAdded;
45
- /**
46
- * Callback triggered when a Dictionary is UPDATED.
47
- */
48
- onDictionaryChange;
49
- /**
50
- * Callback triggered when a Dictionary is DELETED.
51
- */
52
- onDictionaryDeleted;
53
- /**
54
- * Initializes the EventSource connection using the given intlayerConfig
55
- * (or the default config if none was provided).
56
- */
57
- async initialize() {
58
- const backendURL = this.intlayerConfig.editor.backendURL;
59
- const accessToken = await (0, import_oAuth.getOAuthAPI)(
60
- this.intlayerConfig
61
- ).getOAuth2AccessToken();
62
- if (!accessToken) {
63
- throw new Error("Failed to retrieve access token");
64
- }
65
- const API_ROUTE = `${backendURL}/api/event-listener`;
66
- const url = `${API_ROUTE}/${accessToken}`;
67
- this.eventSource = new EventSource(url);
68
- this.eventSource.onmessage = (event) => this.handleMessage(event);
69
- this.eventSource.onerror = (event) => this.handleError(event);
70
- }
71
- /**
72
- * Cleans up (closes) the EventSource connection.
73
- */
74
- cleanup() {
75
- if (this.eventSource) {
76
- this.eventSource.close();
77
- this.eventSource = null;
78
- }
79
- }
80
- /**
81
- * Handles incoming SSE messages, parses the event data,
82
- * and invokes the appropriate callback.
83
- */
84
- async handleMessage(event) {
85
- try {
86
- const { data } = event;
87
- const dataJSON = JSON.parse(data);
88
- for (const dataEl of dataJSON) {
89
- switch (dataEl.object) {
90
- case "DICTIONARY":
91
- switch (dataEl.status) {
92
- case "ADDED":
93
- await this.onDictionaryAdded?.(dataEl.data);
94
- break;
95
- case "UPDATED":
96
- await this.onDictionaryChange?.(dataEl.data);
97
- break;
98
- case "DELETED":
99
- await this.onDictionaryDeleted?.(dataEl.data);
100
- break;
101
- default:
102
- console.error("Unhandled dictionary status:", dataEl.status);
103
- break;
104
- }
105
- break;
106
- default:
107
- console.error("Unknown object type:", dataEl.object);
108
- break;
109
- }
110
- }
111
- } catch (error) {
112
- console.error("Error processing dictionary update:", error);
113
- }
114
- }
115
- /**
116
- * Handles any SSE errors and then performs cleanup.
117
- */
118
- handleError(event) {
119
- console.error("EventSource error:", event);
120
- this.cleanup();
121
- }
122
- }
123
- // Annotate the CommonJS export names for ESM import in node:
124
- 0 && (module.exports = {
125
- IntlayerEventListener
126
- });
127
- //# sourceMappingURL=IntlayerEventListener.cjs.map
@@ -1 +0,0 @@
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 { getOAuthAPI } from './getIntlayerAPI/oAuth';\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 accessToken = await getOAuthAPI(\n this.intlayerConfig\n ).getOAuth2AccessToken();\n\n if (!accessToken) {\n throw new Error('Failed to retrieve access token');\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,mBAA4B;AA4BrB,MAAM,sBAAsB;AAAA,EAkBjC,YAAoB,iBAAiC,aAAAA,SAAe;AAAhD;AAAA,EAAiD;AAAA,EAj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M;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"]}
@@ -1,93 +0,0 @@
1
- import configuration from "@intlayer/config/built";
2
- import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
3
- class IntlayerEventListener {
4
- constructor(intlayerConfig = configuration) {
5
- this.intlayerConfig = intlayerConfig;
6
- }
7
- eventSource = null;
8
- /**
9
- * Callback triggered when a Dictionary is ADDED.
10
- */
11
- onDictionaryAdded;
12
- /**
13
- * Callback triggered when a Dictionary is UPDATED.
14
- */
15
- onDictionaryChange;
16
- /**
17
- * Callback triggered when a Dictionary is DELETED.
18
- */
19
- onDictionaryDeleted;
20
- /**
21
- * Initializes the EventSource connection using the given intlayerConfig
22
- * (or the default config if none was provided).
23
- */
24
- async initialize() {
25
- const backendURL = this.intlayerConfig.editor.backendURL;
26
- const accessToken = await getOAuthAPI(
27
- this.intlayerConfig
28
- ).getOAuth2AccessToken();
29
- if (!accessToken) {
30
- throw new Error("Failed to retrieve access token");
31
- }
32
- const API_ROUTE = `${backendURL}/api/event-listener`;
33
- const url = `${API_ROUTE}/${accessToken}`;
34
- this.eventSource = new EventSource(url);
35
- this.eventSource.onmessage = (event) => this.handleMessage(event);
36
- this.eventSource.onerror = (event) => this.handleError(event);
37
- }
38
- /**
39
- * Cleans up (closes) the EventSource connection.
40
- */
41
- cleanup() {
42
- if (this.eventSource) {
43
- this.eventSource.close();
44
- this.eventSource = null;
45
- }
46
- }
47
- /**
48
- * Handles incoming SSE messages, parses the event data,
49
- * and invokes the appropriate callback.
50
- */
51
- async handleMessage(event) {
52
- try {
53
- const { data } = event;
54
- const dataJSON = JSON.parse(data);
55
- for (const dataEl of dataJSON) {
56
- switch (dataEl.object) {
57
- case "DICTIONARY":
58
- switch (dataEl.status) {
59
- case "ADDED":
60
- await this.onDictionaryAdded?.(dataEl.data);
61
- break;
62
- case "UPDATED":
63
- await this.onDictionaryChange?.(dataEl.data);
64
- break;
65
- case "DELETED":
66
- await this.onDictionaryDeleted?.(dataEl.data);
67
- break;
68
- default:
69
- console.error("Unhandled dictionary status:", dataEl.status);
70
- break;
71
- }
72
- break;
73
- default:
74
- console.error("Unknown object type:", dataEl.object);
75
- break;
76
- }
77
- }
78
- } catch (error) {
79
- console.error("Error processing dictionary update:", error);
80
- }
81
- }
82
- /**
83
- * Handles any SSE errors and then performs cleanup.
84
- */
85
- handleError(event) {
86
- console.error("EventSource error:", event);
87
- this.cleanup();
88
- }
89
- }
90
- export {
91
- IntlayerEventListener
92
- };
93
- //# sourceMappingURL=IntlayerEventListener.mjs.map
@@ -1 +0,0 @@
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 { getOAuthAPI } from './getIntlayerAPI/oAuth';\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 accessToken = await getOAuthAPI(\n this.intlayerConfig\n ).getOAuth2AccessToken();\n\n if (!accessToken) {\n throw new Error('Failed to retrieve access token');\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 clean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AO,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,63 +0,0 @@
1
- import type { DictionaryAPI } from '@intlayer/backend';
2
- import type { IntlayerConfig } from '@intlayer/config/client';
3
- export type IntlayerMessageEvent = MessageEvent;
4
- /**
5
- * IntlayerEventListener class to listen for dictionary changes via SSE (Server-Sent Events).
6
- *
7
- * Usage example:
8
- *
9
- * import { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary';
10
- * import { IntlayerEventListener } from '@intlayer/api';
11
- *
12
- * export const checkDictionaryChanges = async () => {
13
- * // Instantiate the listener
14
- * const eventListener = new IntlayerEventListener();
15
- *
16
- * // Set up your callbacks
17
- * eventListener.onDictionaryChange = async (dictionary) => {
18
- * await buildIntlayerDictionary(dictionary);
19
- * };
20
- *
21
- * // Initialize the listener
22
- * await eventListener.initialize();
23
- *
24
- * // Optionally, clean up later when you’re done
25
- * // eventListener.cleanup();
26
- * };
27
- */
28
- export declare class IntlayerEventListener {
29
- private intlayerConfig;
30
- private eventSource;
31
- /**
32
- * Callback triggered when a Dictionary is ADDED.
33
- */
34
- onDictionaryAdded?: (dictionary: DictionaryAPI) => any;
35
- /**
36
- * Callback triggered when a Dictionary is UPDATED.
37
- */
38
- onDictionaryChange?: (dictionary: DictionaryAPI) => any;
39
- /**
40
- * Callback triggered when a Dictionary is DELETED.
41
- */
42
- onDictionaryDeleted?: (dictionary: DictionaryAPI) => any;
43
- constructor(intlayerConfig?: IntlayerConfig);
44
- /**
45
- * Initializes the EventSource connection using the given intlayerConfig
46
- * (or the default config if none was provided).
47
- */
48
- initialize(): Promise<void>;
49
- /**
50
- * Cleans up (closes) the EventSource connection.
51
- */
52
- cleanup(): void;
53
- /**
54
- * Handles incoming SSE messages, parses the event data,
55
- * and invokes the appropriate callback.
56
- */
57
- private handleMessage;
58
- /**
59
- * Handles any SSE errors and then performs cleanup.
60
- */
61
- private handleError;
62
- }
63
- //# sourceMappingURL=IntlayerEventListener.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlayerEventListener.d.ts","sourceRoot":"","sources":["../../src/IntlayerEventListener.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,qBAAqB;IAkBpB,OAAO,CAAC,cAAc;IAjBlC,OAAO,CAAC,WAAW,CAA4B;IAE/C;;OAEG;IACI,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,GAAG,CAAC;IAE9D;;OAEG;IACI,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,GAAG,CAAC;IAE/D;;OAEG;IACI,mBAAmB,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,GAAG,CAAC;gBAE5C,cAAc,GAAE,cAA8B;IAElE;;;OAGG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBxC;;OAEG;IACI,OAAO,IAAI,IAAI;IAOtB;;;OAGG;YACW,aAAa;IAkC3B;;OAEG;IACH,OAAO,CAAC,WAAW;CAIpB"}