@intlayer/api 6.1.6 → 7.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 (117) hide show
  1. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  2. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +18 -55
  3. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  4. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +20 -58
  5. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  6. package/dist/cjs/distantDictionary/index.cjs +5 -25
  7. package/dist/cjs/fetcher.cjs +113 -89
  8. package/dist/cjs/fetcher.cjs.map +1 -1
  9. package/dist/cjs/getIntlayerAPI/ai.cjs +163 -188
  10. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  11. package/dist/cjs/getIntlayerAPI/dictionary.cjs +69 -117
  12. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  13. package/dist/cjs/getIntlayerAPI/editor.cjs +37 -74
  14. package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
  15. package/dist/cjs/getIntlayerAPI/index.cjs +27 -49
  16. package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
  17. package/dist/cjs/getIntlayerAPI/newsletter.cjs +40 -77
  18. package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
  19. package/dist/cjs/getIntlayerAPI/oAuth.cjs +26 -65
  20. package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
  21. package/dist/cjs/getIntlayerAPI/organization.cjs +93 -130
  22. package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
  23. package/dist/cjs/getIntlayerAPI/project.cjs +109 -154
  24. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  25. package/dist/cjs/getIntlayerAPI/search.cjs +22 -58
  26. package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
  27. package/dist/cjs/getIntlayerAPI/stripe.cjs +38 -77
  28. package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
  29. package/dist/cjs/getIntlayerAPI/tag.cjs +47 -86
  30. package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
  31. package/dist/cjs/getIntlayerAPI/user.cjs +79 -106
  32. package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
  33. package/dist/cjs/index.cjs +30 -49
  34. package/dist/cjs/proxy.cjs +90 -115
  35. package/dist/cjs/proxy.cjs.map +1 -1
  36. package/dist/cjs/types.cjs +0 -17
  37. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +17 -20
  38. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  39. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +19 -23
  40. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  41. package/dist/esm/distantDictionary/index.mjs +4 -3
  42. package/dist/esm/fetcher.mjs +111 -64
  43. package/dist/esm/fetcher.mjs.map +1 -1
  44. package/dist/esm/getIntlayerAPI/ai.mjs +160 -153
  45. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  46. package/dist/esm/getIntlayerAPI/dictionary.mjs +66 -82
  47. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  48. package/dist/esm/getIntlayerAPI/editor.mjs +34 -39
  49. package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
  50. package/dist/esm/getIntlayerAPI/index.mjs +16 -14
  51. package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
  52. package/dist/esm/getIntlayerAPI/newsletter.mjs +37 -42
  53. package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
  54. package/dist/esm/getIntlayerAPI/oAuth.mjs +23 -30
  55. package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
  56. package/dist/esm/getIntlayerAPI/organization.mjs +90 -95
  57. package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
  58. package/dist/esm/getIntlayerAPI/project.mjs +106 -119
  59. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  60. package/dist/esm/getIntlayerAPI/search.mjs +19 -23
  61. package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
  62. package/dist/esm/getIntlayerAPI/stripe.mjs +35 -42
  63. package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
  64. package/dist/esm/getIntlayerAPI/tag.mjs +44 -51
  65. package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
  66. package/dist/esm/getIntlayerAPI/user.mjs +76 -71
  67. package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
  68. package/dist/esm/index.mjs +16 -15
  69. package/dist/esm/proxy.mjs +89 -90
  70. package/dist/esm/proxy.mjs.map +1 -1
  71. package/dist/esm/types.mjs +0 -1
  72. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +8 -3
  73. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
  74. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +8 -3
  75. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
  76. package/dist/types/distantDictionary/index.d.ts +3 -3
  77. package/dist/types/fetcher.d.ts +14 -11
  78. package/dist/types/fetcher.d.ts.map +1 -1
  79. package/dist/types/getIntlayerAPI/ai.d.ts +22 -18
  80. package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
  81. package/dist/types/getIntlayerAPI/dictionary.d.ts +16 -12
  82. package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
  83. package/dist/types/getIntlayerAPI/editor.d.ts +11 -7
  84. package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
  85. package/dist/types/getIntlayerAPI/index.d.ts +30 -27
  86. package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
  87. package/dist/types/getIntlayerAPI/newsletter.d.ts +11 -7
  88. package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
  89. package/dist/types/getIntlayerAPI/oAuth.d.ts +8 -5
  90. package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
  91. package/dist/types/getIntlayerAPI/organization.d.ts +18 -13
  92. package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
  93. package/dist/types/getIntlayerAPI/project.d.ts +19 -15
  94. package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
  95. package/dist/types/getIntlayerAPI/search.d.ts +9 -5
  96. package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
  97. package/dist/types/getIntlayerAPI/stripe.d.ts +11 -7
  98. package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
  99. package/dist/types/getIntlayerAPI/tag.d.ts +12 -8
  100. package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
  101. package/dist/types/getIntlayerAPI/user.d.ts +16 -12
  102. package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
  103. package/dist/types/index.d.ts +16 -15
  104. package/dist/types/proxy.d.ts +10 -5
  105. package/dist/types/proxy.d.ts.map +1 -1
  106. package/dist/types/types.d.ts +13 -12
  107. package/dist/types/types.d.ts.map +1 -1
  108. package/package.json +29 -38
  109. package/LICENSE +0 -202
  110. package/dist/cjs/distantDictionary/index.cjs.map +0 -1
  111. package/dist/cjs/index.cjs.map +0 -1
  112. package/dist/cjs/types.cjs.map +0 -1
  113. package/dist/esm/distantDictionary/index.mjs.map +0 -1
  114. package/dist/esm/index.mjs.map +0 -1
  115. package/dist/esm/types.mjs.map +0 -1
  116. package/dist/types/distantDictionary/index.d.ts.map +0 -1
  117. package/dist/types/index.d.ts.map +0 -1
@@ -1,86 +1,70 @@
1
- import configuration from "@intlayer/config/built";
2
1
  import { fetcher } from "../fetcher.mjs";
2
+ import configuration from "@intlayer/config/built";
3
+
4
+ //#region src/getIntlayerAPI/dictionary.ts
3
5
  const getDictionaryAPI = (authAPIOptions = {}, intlayerConfig) => {
4
- const backendURL = intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;
5
- if (!backendURL) {
6
- throw new Error(
7
- "Backend URL is not defined in the Intlayer configuration."
8
- );
9
- }
10
- const PROJECT_API_ROUTE = `${backendURL}/api/dictionary`;
11
- const getDictionaries = async (filters, otherOptions = {}) => await fetcher(
12
- PROJECT_API_ROUTE,
13
- authAPIOptions,
14
- otherOptions,
15
- {
16
- params: filters
17
- }
18
- );
19
- const getDictionariesKeys = async (otherOptions = {}) => await fetcher(
20
- `${PROJECT_API_ROUTE}/keys`,
21
- authAPIOptions,
22
- otherOptions
23
- );
24
- const getDictionariesUpdateTimestamp = async (otherOptions = {}) => await fetcher(
25
- `${PROJECT_API_ROUTE}/update`,
26
- authAPIOptions,
27
- otherOptions
28
- );
29
- const getDictionary = async (dictionaryKey, version, otherOptions = {}) => await fetcher(
30
- `${PROJECT_API_ROUTE}/${dictionaryKey}`,
31
- authAPIOptions,
32
- otherOptions,
33
- {
34
- params: version ? { version: version.toString() } : void 0
35
- }
36
- );
37
- const addDictionary = async (body, otherOptions = {}) => await fetcher(
38
- `${PROJECT_API_ROUTE}`,
39
- authAPIOptions,
40
- otherOptions,
41
- {
42
- method: "POST",
43
- body
44
- }
45
- );
46
- const pushDictionaries = async (dictionaries, otherOptions = {}) => await fetcher(
47
- `${PROJECT_API_ROUTE}`,
48
- authAPIOptions,
49
- otherOptions,
50
- {
51
- method: "PATCH",
52
- body: { dictionaries }
53
- }
54
- );
55
- const updateDictionary = async (dictionary, otherOptions = {}) => await fetcher(
56
- `${PROJECT_API_ROUTE}/${dictionary.id}`,
57
- authAPIOptions,
58
- otherOptions,
59
- {
60
- method: "PUT",
61
- body: dictionary
62
- }
63
- );
64
- const deleteDictionary = async (id, otherOptions = {}) => await fetcher(
65
- `${PROJECT_API_ROUTE}/${id}`,
66
- authAPIOptions,
67
- otherOptions,
68
- {
69
- method: "DELETE"
70
- }
71
- );
72
- return {
73
- getDictionaries,
74
- getDictionariesKeys,
75
- getDictionariesUpdateTimestamp,
76
- getDictionary,
77
- pushDictionaries,
78
- addDictionary,
79
- updateDictionary,
80
- deleteDictionary
81
- };
82
- };
83
- export {
84
- getDictionaryAPI
6
+ const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;
7
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
8
+ const PROJECT_API_ROUTE = `${backendURL}/api/dictionary`;
9
+ /**
10
+ * Retrieves a list of dictionaries based on filters and pagination.
11
+ * @param filters - Filters and pagination options.
12
+ */
13
+ const getDictionaries = async (filters, otherOptions = {}) => await fetcher(PROJECT_API_ROUTE, authAPIOptions, otherOptions, {
14
+ cache: "no-store",
15
+ params: filters
16
+ });
17
+ /**
18
+ * Retrieves a list of dictionary keys related to the project.
19
+ */
20
+ const getDictionariesKeys = async (otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/keys`, authAPIOptions, otherOptions, { cache: "no-store" });
21
+ /**
22
+ * Retrieves a list of dictionary keys related to the project.
23
+ */
24
+ const getDictionariesUpdateTimestamp = async (otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/update`, authAPIOptions, otherOptions, { cache: "no-store" });
25
+ /**
26
+ * Retrieves a dictionary by its key and version.
27
+ * @param dictionaryKey - Dictionary key.
28
+ * @param version - Dictionary version of content.
29
+ */
30
+ const getDictionary = async (dictionaryKey, version, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/${dictionaryKey}`, authAPIOptions, otherOptions, { params: version ? { version: version.toString() } : void 0 });
31
+ /**
32
+ * Adds a new dictionary to the database.
33
+ * @param dictionary - Dictionary data.
34
+ */
35
+ const addDictionary = async (body, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
36
+ method: "POST",
37
+ body
38
+ });
39
+ const pushDictionaries = async (dictionaries, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
40
+ method: "PATCH",
41
+ body: { dictionaries }
42
+ });
43
+ /**
44
+ * Updates an existing dictionary in the database.
45
+ * @param dictionary - Updated dictionary data.
46
+ */
47
+ const updateDictionary = async (dictionary, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/${dictionary.id}`, authAPIOptions, otherOptions, {
48
+ method: "PUT",
49
+ body: dictionary
50
+ });
51
+ /**
52
+ * Deletes a dictionary from the database by its ID.
53
+ * @param id - Dictionary ID.
54
+ */
55
+ const deleteDictionary = async (id, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/${id}`, authAPIOptions, otherOptions, { method: "DELETE" });
56
+ return {
57
+ getDictionaries,
58
+ getDictionariesKeys,
59
+ getDictionariesUpdateTimestamp,
60
+ getDictionary,
61
+ pushDictionaries,
62
+ addDictionary,
63
+ updateDictionary,
64
+ deleteDictionary
65
+ };
85
66
  };
67
+
68
+ //#endregion
69
+ export { getDictionaryAPI };
86
70
  //# sourceMappingURL=dictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/dictionary.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\nimport type {\n AddDictionaryBody,\n AddDictionaryResult,\n DeleteDictionaryParam,\n DeleteDictionaryResult,\n GetDictionariesKeysResult,\n GetDictionariesParams,\n GetDictionariesResult,\n GetDictionariesUpdateTimestampResult,\n GetDictionaryParams,\n GetDictionaryQuery,\n GetDictionaryResult,\n PushDictionariesBody,\n PushDictionariesResult,\n UpdateDictionaryBody,\n UpdateDictionaryResult,\n} from '../types';\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 list of dictionary keys related to the project.\n */\n const getDictionariesUpdateTimestamp = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionariesUpdateTimestampResult>(\n `${PROJECT_API_ROUTE}/update`,\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 dictionary: UpdateDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionary.id}`,\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 getDictionariesUpdateTimestamp,\n getDictionary,\n pushDictionaries,\n addDictionary,\n updateDictionary,\n deleteDictionary,\n };\n};\n"],"mappings":"AAAA,OAAO,mBAAmB;AAE1B,SAAS,eAAoC;AAmBtC,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;AAKF,QAAM,iCAAiC,OACrC,eAA+B,CAAC,MAEhC,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,YACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,WAAW,EAAE;AAAA,IACrC;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,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"dictionary.mjs","names":[],"sources":["../../../src/getIntlayerAPI/dictionary.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddDictionaryBody,\n AddDictionaryResult,\n DeleteDictionaryParam,\n DeleteDictionaryResult,\n GetDictionariesKeysResult,\n GetDictionariesParams,\n GetDictionariesResult,\n GetDictionariesUpdateTimestampResult,\n GetDictionaryParams,\n GetDictionaryQuery,\n GetDictionaryResult,\n PushDictionariesBody,\n PushDictionariesResult,\n UpdateDictionaryBody,\n UpdateDictionaryResult,\n} from '../types';\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 cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\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 cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a list of dictionary keys related to the project.\n */\n const getDictionariesUpdateTimestamp = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionariesUpdateTimestampResult>(\n `${PROJECT_API_ROUTE}/update`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\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 dictionary: UpdateDictionaryBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateDictionaryResult>(\n `${PROJECT_API_ROUTE}/${dictionary.id}`,\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 getDictionariesUpdateTimestamp,\n getDictionary,\n pushDictionaries,\n addDictionary,\n updateDictionary,\n deleteDictionary,\n };\n};\n"],"mappings":";;;;AAqBA,MAAa,oBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,eAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,oBAAoB,GAAG,WAAW;;;;;CAMxC,MAAM,kBAAkB,OACtB,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;CAKH,MAAM,sBAAsB,OAAO,eAA+B,EAAE,KAClE,MAAM,QACJ,GAAG,kBAAkB,QACrB,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;CAKH,MAAM,iCAAiC,OACrC,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,UACrB,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,gBAAgB,OACpB,eACA,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,iBACxB,gBACA,cACA,EACE,QAAQ,UAAU,EAAE,SAAS,QAAQ,UAAU,EAAE,GAAG,QACrD,CACF;;;;;CAMH,MAAM,gBAAgB,OACpB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;CAEH,MAAM,mBAAmB,OACvB,cACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,cAAc;EACvB,CACF;;;;;CAMH,MAAM,mBAAmB,OACvB,YACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,WAAW,MACnC,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,mBAAmB,OACvB,IACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,MACxB,gBACA,cACA,EACE,QAAQ,UACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -1,43 +1,38 @@
1
- import configuration from "@intlayer/config/built";
2
1
  import { fetcher } from "../fetcher.mjs";
2
+ import configuration from "@intlayer/config/built";
3
+
4
+ //#region src/getIntlayerAPI/editor.ts
3
5
  const getEditorAPI = (authAPIOptions = {}, intlayerConfig) => {
4
- const editorURL = intlayerConfig?.editor?.editorURL ?? configuration.editor?.editorURL;
5
- if (!editorURL) {
6
- throw new Error("Editor URL is not defined in the Intlayer configuration.");
7
- }
8
- const EDITOR_API_ROUTE = `${editorURL}/api`;
9
- const getConfiguration = async (otherOptions = {}) => {
10
- const response = await fetcher(
11
- `${EDITOR_API_ROUTE}/config`,
12
- authAPIOptions,
13
- otherOptions
14
- );
15
- return response.data;
16
- };
17
- const getDictionaries = async (otherOptions = {}) => {
18
- const response = await fetcher(
19
- `${EDITOR_API_ROUTE}/dictionary`,
20
- authAPIOptions,
21
- otherOptions
22
- );
23
- return response.data;
24
- };
25
- const writeDictionary = async (body, otherOptions = {}) => await fetcher(
26
- `${EDITOR_API_ROUTE}/dictionary`,
27
- authAPIOptions,
28
- otherOptions,
29
- {
30
- method: "POST",
31
- body
32
- }
33
- );
34
- return {
35
- getDictionaries,
36
- getConfiguration,
37
- writeDictionary
38
- };
39
- };
40
- export {
41
- getEditorAPI
6
+ const editorURL = intlayerConfig?.editor?.editorURL ?? configuration?.editor?.editorURL;
7
+ if (!editorURL) throw new Error("Editor URL is not defined in the Intlayer configuration.");
8
+ const EDITOR_API_ROUTE = `${editorURL}/api`;
9
+ /**
10
+ * Get the Intlayer configuration
11
+ */
12
+ const getConfiguration = async (otherOptions = {}) => {
13
+ return (await fetcher(`${EDITOR_API_ROUTE}/config`, authAPIOptions, otherOptions)).data;
14
+ };
15
+ /**
16
+ * Get the Intlayer configuration
17
+ */
18
+ const getDictionaries = async (otherOptions = {}) => {
19
+ return (await fetcher(`${EDITOR_API_ROUTE}/dictionary`, authAPIOptions, otherOptions)).data;
20
+ };
21
+ /**
22
+ * Adds a new dictionary to the database.
23
+ * @param dictionary - Dictionary data.
24
+ */
25
+ const writeDictionary = async (body, otherOptions = {}) => await fetcher(`${EDITOR_API_ROUTE}/dictionary`, authAPIOptions, otherOptions, {
26
+ method: "POST",
27
+ body
28
+ });
29
+ return {
30
+ getDictionaries,
31
+ getConfiguration,
32
+ writeDictionary
33
+ };
42
34
  };
35
+
36
+ //#endregion
37
+ export { getEditorAPI };
43
38
  //# sourceMappingURL=editor.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from '../types';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const editorURL =\n intlayerConfig?.editor?.editorURL ?? configuration.editor?.editorURL;\n\n if (!editorURL) {\n throw new Error('Editor URL is not defined in the Intlayer configuration.');\n }\n\n const EDITOR_API_ROUTE = `${editorURL}/api`;\n\n /**\n * Get the Intlayer configuration\n */\n const getConfiguration = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetConfigurationResult> => {\n const response = await fetcher<GetConfigurationResult>(\n `${EDITOR_API_ROUTE}/config`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetConfigurationResult;\n };\n\n /**\n * Get the Intlayer configuration\n */\n const getDictionaries = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetEditorDictionariesResult> => {\n const response = await fetcher<GetEditorDictionariesResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetEditorDictionariesResult;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n body: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n return {\n getDictionaries,\n getConfiguration,\n writeDictionary,\n };\n};\n"],"mappings":"AAAA,OAAO,mBAAmB;AAE1B,SAAS,eAAoC;AAQtC,MAAM,eAAe,CAC1B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,YACJ,gBAAgB,QAAQ,aAAa,cAAc,QAAQ;AAE7D,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AAEA,QAAM,mBAAmB,GAAG,SAAS;AAKrC,QAAM,mBAAmB,OACvB,eAA+B,CAAC,MACI;AACpC,UAAM,WAAW,MAAM;AAAA,MACrB,GAAG,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AAKA,QAAM,kBAAkB,OACtB,eAA+B,CAAC,MACS;AACzC,UAAM,WAAW,MAAM;AAAA,MACrB,GAAG,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AAMA,QAAM,kBAAkB,OACtB,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,gBAAgB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"editor.mjs","names":[],"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from '../types';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const editorURL =\n intlayerConfig?.editor?.editorURL ?? configuration?.editor?.editorURL;\n\n if (!editorURL) {\n throw new Error('Editor URL is not defined in the Intlayer configuration.');\n }\n\n const EDITOR_API_ROUTE = `${editorURL}/api`;\n\n /**\n * Get the Intlayer configuration\n */\n const getConfiguration = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetConfigurationResult> => {\n const response = await fetcher<GetConfigurationResult>(\n `${EDITOR_API_ROUTE}/config`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetConfigurationResult;\n };\n\n /**\n * Get the Intlayer configuration\n */\n const getDictionaries = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetEditorDictionariesResult> => {\n const response = await fetcher<GetEditorDictionariesResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetEditorDictionariesResult;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n body: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n return {\n getDictionaries,\n getConfiguration,\n writeDictionary,\n };\n};\n"],"mappings":";;;;AAUA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,YACJ,gBAAgB,QAAQ,aAAa,eAAe,QAAQ;AAE9D,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,2DAA2D;CAG7E,MAAM,mBAAmB,GAAG,UAAU;;;;CAKtC,MAAM,mBAAmB,OACvB,eAA+B,EAAE,KACG;AAOpC,UANiB,MAAM,QACrB,GAAG,iBAAiB,UACpB,gBACA,aACD,EAEe;;;;;CAMlB,MAAM,kBAAkB,OACtB,eAA+B,EAAE,KACQ;AAOzC,UANiB,MAAM,QACrB,GAAG,iBAAiB,cACpB,gBACA,aACD,EAEe;;;;;;CAOlB,MAAM,kBAAkB,OACtB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,cACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD"}
@@ -9,20 +9,22 @@ import { getSearchAPI } from "./search.mjs";
9
9
  import { getStripeAPI } from "./stripe.mjs";
10
10
  import { getTagAPI } from "./tag.mjs";
11
11
  import { getUserAPI } from "./user.mjs";
12
+
13
+ //#region src/getIntlayerAPI/index.ts
12
14
  const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => ({
13
- organization: getOrganizationAPI(authAPIOptions, intlayerConfig),
14
- project: getProjectAPI(authAPIOptions, intlayerConfig),
15
- user: getUserAPI(authAPIOptions, intlayerConfig),
16
- oAuth: getOAuthAPI(intlayerConfig),
17
- dictionary: getDictionaryAPI(authAPIOptions, intlayerConfig),
18
- stripe: getStripeAPI(authAPIOptions, intlayerConfig),
19
- ai: getAiAPI(authAPIOptions, intlayerConfig),
20
- tag: getTagAPI(authAPIOptions, intlayerConfig),
21
- search: getSearchAPI(authAPIOptions, intlayerConfig),
22
- editor: getEditorAPI(authAPIOptions, intlayerConfig),
23
- newsletter: getNewsletterAPI(authAPIOptions, intlayerConfig)
15
+ organization: getOrganizationAPI(authAPIOptions, intlayerConfig),
16
+ project: getProjectAPI(authAPIOptions, intlayerConfig),
17
+ user: getUserAPI(authAPIOptions, intlayerConfig),
18
+ oAuth: getOAuthAPI(intlayerConfig),
19
+ dictionary: getDictionaryAPI(authAPIOptions, intlayerConfig),
20
+ stripe: getStripeAPI(authAPIOptions, intlayerConfig),
21
+ ai: getAiAPI(authAPIOptions, intlayerConfig),
22
+ tag: getTagAPI(authAPIOptions, intlayerConfig),
23
+ search: getSearchAPI(authAPIOptions, intlayerConfig),
24
+ editor: getEditorAPI(authAPIOptions, intlayerConfig),
25
+ newsletter: getNewsletterAPI(authAPIOptions, intlayerConfig)
24
26
  });
25
- export {
26
- getIntlayerAPI
27
- };
27
+
28
+ //#endregion
29
+ export { getIntlayerAPI };
28
30
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/config/client';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getSearchAPI } from './search';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPIReturn => ({\n organization: getOrganizationAPI(authAPIOptions, intlayerConfig),\n project: getProjectAPI(authAPIOptions, intlayerConfig),\n user: getUserAPI(authAPIOptions, intlayerConfig),\n oAuth: getOAuthAPI(intlayerConfig),\n dictionary: getDictionaryAPI(authAPIOptions, intlayerConfig),\n stripe: getStripeAPI(authAPIOptions, intlayerConfig),\n ai: getAiAPI(authAPIOptions, intlayerConfig),\n tag: getTagAPI(authAPIOptions, intlayerConfig),\n search: getSearchAPI(authAPIOptions, intlayerConfig),\n editor: getEditorAPI(authAPIOptions, intlayerConfig),\n newsletter: getNewsletterAPI(authAPIOptions, intlayerConfig),\n});\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":"AAEA,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAgBpB,MAAM,iBAAiB,CAC5B,iBAAiC,CAAC,GAClC,oBACuB;AAAA,EACvB,cAAc,mBAAmB,gBAAgB,cAAc;AAAA,EAC/D,SAAS,cAAc,gBAAgB,cAAc;AAAA,EACrD,MAAM,WAAW,gBAAgB,cAAc;AAAA,EAC/C,OAAO,YAAY,cAAc;AAAA,EACjC,YAAY,iBAAiB,gBAAgB,cAAc;AAAA,EAC3D,QAAQ,aAAa,gBAAgB,cAAc;AAAA,EACnD,IAAI,SAAS,gBAAgB,cAAc;AAAA,EAC3C,KAAK,UAAU,gBAAgB,cAAc;AAAA,EAC7C,QAAQ,aAAa,gBAAgB,cAAc;AAAA,EACnD,QAAQ,aAAa,gBAAgB,cAAc;AAAA,EACnD,YAAY,iBAAiB,gBAAgB,cAAc;AAC7D;","names":[]}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getSearchAPI } from './search';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPIReturn => ({\n organization: getOrganizationAPI(authAPIOptions, intlayerConfig),\n project: getProjectAPI(authAPIOptions, intlayerConfig),\n user: getUserAPI(authAPIOptions, intlayerConfig),\n oAuth: getOAuthAPI(intlayerConfig),\n dictionary: getDictionaryAPI(authAPIOptions, intlayerConfig),\n stripe: getStripeAPI(authAPIOptions, intlayerConfig),\n ai: getAiAPI(authAPIOptions, intlayerConfig),\n tag: getTagAPI(authAPIOptions, intlayerConfig),\n search: getSearchAPI(authAPIOptions, intlayerConfig),\n editor: getEditorAPI(authAPIOptions, intlayerConfig),\n newsletter: getNewsletterAPI(authAPIOptions, intlayerConfig),\n});\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAa,kBACX,iBAAiC,EAAE,EACnC,oBACuB;CACvB,cAAc,mBAAmB,gBAAgB,eAAe;CAChE,SAAS,cAAc,gBAAgB,eAAe;CACtD,MAAM,WAAW,gBAAgB,eAAe;CAChD,OAAO,YAAY,eAAe;CAClC,YAAY,iBAAiB,gBAAgB,eAAe;CAC5D,QAAQ,aAAa,gBAAgB,eAAe;CACpD,IAAI,SAAS,gBAAgB,eAAe;CAC5C,KAAK,UAAU,gBAAgB,eAAe;CAC9C,QAAQ,aAAa,gBAAgB,eAAe;CACpD,QAAQ,aAAa,gBAAgB,eAAe;CACpD,YAAY,iBAAiB,gBAAgB,eAAe;CAC7D"}
@@ -1,46 +1,41 @@
1
- import configuration from "@intlayer/config/built";
2
1
  import { fetcher } from "../fetcher.mjs";
2
+ import configuration from "@intlayer/config/built";
3
+
4
+ //#region src/getIntlayerAPI/newsletter.ts
3
5
  const getNewsletterAPI = (authAPIOptions = {}, intlayerConfig) => {
4
- const backendURL = intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;
5
- if (!backendURL) {
6
- throw new Error(
7
- "Backend URL is not defined in the Intlayer configuration."
8
- );
9
- }
10
- const NEWSLETTER_API_ROUTE = `${backendURL}/api/newsletter`;
11
- const subscribeToNewsletter = async (body, otherOptions = {}) => await fetcher(
12
- `${NEWSLETTER_API_ROUTE}/subscribe`,
13
- authAPIOptions,
14
- otherOptions,
15
- {
16
- method: "POST",
17
- body
18
- }
19
- );
20
- const unsubscribeFromNewsletter = async (body, otherOptions = {}) => await fetcher(
21
- `${NEWSLETTER_API_ROUTE}/unsubscribe`,
22
- authAPIOptions,
23
- otherOptions,
24
- {
25
- method: "POST",
26
- body
27
- }
28
- );
29
- const getNewsletterStatus = async (otherOptions = {}) => await fetcher(
30
- `${NEWSLETTER_API_ROUTE}/status`,
31
- authAPIOptions,
32
- otherOptions,
33
- {
34
- method: "GET"
35
- }
36
- );
37
- return {
38
- subscribeToNewsletter,
39
- unsubscribeFromNewsletter,
40
- getNewsletterStatus
41
- };
42
- };
43
- export {
44
- getNewsletterAPI
6
+ const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;
7
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
8
+ const NEWSLETTER_API_ROUTE = `${backendURL}/api/newsletter`;
9
+ /**
10
+ * Subscribe a user to newsletter(s)
11
+ * @param body - Newsletter subscription parameters.
12
+ * @returns Newsletter subscription result.
13
+ */
14
+ const subscribeToNewsletter = async (body, otherOptions = {}) => await fetcher(`${NEWSLETTER_API_ROUTE}/subscribe`, authAPIOptions, otherOptions, {
15
+ method: "POST",
16
+ body
17
+ });
18
+ /**
19
+ * Unsubscribe a user from newsletter(s)
20
+ * @param body - Newsletter unsubscription parameters.
21
+ * @returns Newsletter unsubscription result.
22
+ */
23
+ const unsubscribeFromNewsletter = async (body, otherOptions = {}) => await fetcher(`${NEWSLETTER_API_ROUTE}/unsubscribe`, authAPIOptions, otherOptions, {
24
+ method: "POST",
25
+ body
26
+ });
27
+ /**
28
+ * Get newsletter subscription status for the authenticated user
29
+ * @returns Newsletter subscription status.
30
+ */
31
+ const getNewsletterStatus = async (otherOptions = {}) => await fetcher(`${NEWSLETTER_API_ROUTE}/status`, authAPIOptions, otherOptions, { method: "GET" });
32
+ return {
33
+ subscribeToNewsletter,
34
+ unsubscribeFromNewsletter,
35
+ getNewsletterStatus
36
+ };
45
37
  };
38
+
39
+ //#endregion
40
+ export { getNewsletterAPI };
46
41
  //# sourceMappingURL=newsletter.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/newsletter.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\nimport type {\n NewsletterSubscriptionBody,\n NewsletterSubscriptionResult,\n NewsletterUnsubscriptionBody,\n} from '../types';\n\nexport const getNewsletterAPI = (\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 NEWSLETTER_API_ROUTE = `${backendURL}/api/newsletter`;\n\n /**\n * Subscribe a user to newsletter(s)\n * @param body - Newsletter subscription parameters.\n * @returns Newsletter subscription result.\n */\n const subscribeToNewsletter = async (\n body: NewsletterSubscriptionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<NewsletterSubscriptionResult>(\n `${NEWSLETTER_API_ROUTE}/subscribe`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Unsubscribe a user from newsletter(s)\n * @param body - Newsletter unsubscription parameters.\n * @returns Newsletter unsubscription result.\n */\n const unsubscribeFromNewsletter = async (\n body: NewsletterUnsubscriptionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<NewsletterSubscriptionResult>(\n `${NEWSLETTER_API_ROUTE}/unsubscribe`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Get newsletter subscription status for the authenticated user\n * @returns Newsletter subscription status.\n */\n const getNewsletterStatus = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<NewsletterSubscriptionResult>(\n `${NEWSLETTER_API_ROUTE}/status`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n return {\n subscribeToNewsletter,\n unsubscribeFromNewsletter,\n getNewsletterStatus,\n };\n};\n"],"mappings":"AAAA,OAAO,mBAAmB;AAE1B,SAAS,eAAoC;AAOtC,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,uBAAuB,GAAG,UAAU;AAO1C,QAAM,wBAAwB,OAC5B,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,oBAAoB;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,4BAA4B,OAChC,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,oBAAoB;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAMF,QAAM,sBAAsB,OAAO,eAA+B,CAAC,MACjE,MAAM;AAAA,IACJ,GAAG,oBAAoB;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"newsletter.mjs","names":[],"sources":["../../../src/getIntlayerAPI/newsletter.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n NewsletterSubscriptionBody,\n NewsletterSubscriptionResult,\n NewsletterUnsubscriptionBody,\n} from '../types';\n\nexport const getNewsletterAPI = (\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 NEWSLETTER_API_ROUTE = `${backendURL}/api/newsletter`;\n\n /**\n * Subscribe a user to newsletter(s)\n * @param body - Newsletter subscription parameters.\n * @returns Newsletter subscription result.\n */\n const subscribeToNewsletter = async (\n body: NewsletterSubscriptionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<NewsletterSubscriptionResult>(\n `${NEWSLETTER_API_ROUTE}/subscribe`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Unsubscribe a user from newsletter(s)\n * @param body - Newsletter unsubscription parameters.\n * @returns Newsletter unsubscription result.\n */\n const unsubscribeFromNewsletter = async (\n body: NewsletterUnsubscriptionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<NewsletterSubscriptionResult>(\n `${NEWSLETTER_API_ROUTE}/unsubscribe`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Get newsletter subscription status for the authenticated user\n * @returns Newsletter subscription status.\n */\n const getNewsletterStatus = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<NewsletterSubscriptionResult>(\n `${NEWSLETTER_API_ROUTE}/status`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n return {\n subscribeToNewsletter,\n unsubscribeFromNewsletter,\n getNewsletterStatus,\n };\n};\n"],"mappings":";;;;AASA,MAAa,oBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,eAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,uBAAuB,GAAG,WAAW;;;;;;CAO3C,MAAM,wBAAwB,OAC5B,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,qBAAqB,aACxB,gBACA,cACA;EACE,QAAQ;EACF;EACP,CACF;;;;;;CAOH,MAAM,4BAA4B,OAChC,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,qBAAqB,eACxB,gBACA,cACA;EACE,QAAQ;EACF;EACP,CACF;;;;;CAMH,MAAM,sBAAsB,OAAO,eAA+B,EAAE,KAClE,MAAM,QACJ,GAAG,qBAAqB,UACxB,gBACA,cACA,EACE,QAAQ,OACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD"}
@@ -1,34 +1,27 @@
1
- import configuration from "@intlayer/config/built";
2
1
  import { fetcher } from "../fetcher.mjs";
2
+ import configuration from "@intlayer/config/built";
3
+
4
+ //#region src/getIntlayerAPI/oAuth.ts
3
5
  const getOAuthAPI = (intlayerConfig) => {
4
- const backendURL = intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;
5
- const { clientId, clientSecret } = intlayerConfig?.editor ?? {};
6
- if (!backendURL) {
7
- throw new Error(
8
- "Backend URL is not defined in the Intlayer configuration."
9
- );
10
- }
11
- const getOAuth2AccessToken = async (otherOptions = {}) => await fetcher(
12
- `${backendURL}/oauth2/token`,
13
- {},
14
- otherOptions,
15
- {
16
- method: "POST",
17
- headers: {
18
- "Content-Type": "application/x-www-form-urlencoded"
19
- },
20
- body: {
21
- grant_type: "client_credentials",
22
- client_id: clientId,
23
- client_secret: clientSecret
24
- }
25
- }
26
- );
27
- return {
28
- getOAuth2AccessToken
29
- };
30
- };
31
- export {
32
- getOAuthAPI
6
+ const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;
7
+ const { clientId, clientSecret } = intlayerConfig?.editor ?? {};
8
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
9
+ /**
10
+ * Gets an oAuth2 accessToken
11
+ * @return The token information
12
+ */
13
+ const getOAuth2AccessToken = async (otherOptions = {}) => await fetcher(`${backendURL}/oauth2/token`, {}, otherOptions, {
14
+ method: "POST",
15
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
16
+ body: {
17
+ grant_type: "client_credentials",
18
+ client_id: clientId,
19
+ client_secret: clientSecret
20
+ }
21
+ });
22
+ return { getOAuth2AccessToken };
33
23
  };
24
+
25
+ //#endregion
26
+ export { getOAuthAPI };
34
27
  //# sourceMappingURL=oAuth.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/oAuth.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { FetcherOptions, fetcher } from '../fetcher';\nimport { GetOAuth2TokenBody, GetOAuth2TokenResult } from '../types';\n\nexport const getOAuthAPI = (intlayerConfig?: IntlayerConfig) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n const { clientId, clientSecret } = intlayerConfig?.editor ?? {};\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n /**\n * Gets an oAuth2 accessToken\n * @return The token information\n */\n const getOAuth2AccessToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetOAuth2TokenResult>(\n `${backendURL}/oauth2/token`,\n {},\n otherOptions,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: {\n grant_type: 'client_credentials',\n client_id: clientId!,\n client_secret: clientSecret!,\n } satisfies GetOAuth2TokenBody,\n }\n );\n\n return {\n getOAuth2AccessToken,\n };\n};\n"],"mappings":"AAAA,OAAO,mBAAmB;AAE1B,SAAyB,eAAe;AAGjC,MAAM,cAAc,CAAC,mBAAoC;AAC9D,QAAM,aACJ,gBAAgB,QAAQ,cAAc,cAAc,QAAQ;AAC9D,QAAM,EAAE,UAAU,aAAa,IAAI,gBAAgB,UAAU,CAAC;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAMA,QAAM,uBAAuB,OAAO,eAA+B,CAAC,MAClE,MAAM;AAAA,IACJ,GAAG,UAAU;AAAA,IACb,CAAC;AAAA,IACD;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"oAuth.mjs","names":[],"sources":["../../../src/getIntlayerAPI/oAuth.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type { GetOAuth2TokenBody, GetOAuth2TokenResult } from '../types';\n\nexport const getOAuthAPI = (intlayerConfig?: IntlayerConfig) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n const { clientId, clientSecret } = intlayerConfig?.editor ?? {};\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n /**\n * Gets an oAuth2 accessToken\n * @return The token information\n */\n const getOAuth2AccessToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetOAuth2TokenResult>(\n `${backendURL}/oauth2/token`,\n {},\n otherOptions,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: {\n grant_type: 'client_credentials',\n client_id: clientId!,\n client_secret: clientSecret!,\n } satisfies GetOAuth2TokenBody,\n }\n );\n\n return {\n getOAuth2AccessToken,\n };\n};\n"],"mappings":";;;;AAKA,MAAa,eAAe,mBAAoC;CAC9D,MAAM,aACJ,gBAAgB,QAAQ,cAAc,eAAe,QAAQ;CAC/D,MAAM,EAAE,UAAU,iBAAiB,gBAAgB,UAAU,EAAE;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;;;;;CAOH,MAAM,uBAAuB,OAAO,eAA+B,EAAE,KACnE,MAAM,QACJ,GAAG,WAAW,gBACd,EAAE,EACF,cACA;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,qCACjB;EACD,MAAM;GACJ,YAAY;GACZ,WAAW;GACX,eAAe;GAChB;EACF,CACF;AAEH,QAAO,EACL,sBACD"}