@intlayer/api 9.6.0 → 9.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/dist/cjs/cms/createAuthManager.cjs +2 -3
  2. package/dist/cjs/cms/createIntlayerCMS.cjs +2 -3
  3. package/dist/cjs/cms/index.cjs +2 -2
  4. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +3 -4
  5. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  6. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +3 -4
  7. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  8. package/dist/cjs/distantDictionary/index.cjs +2 -2
  9. package/dist/cjs/fetcher.cjs +2 -3
  10. package/dist/cjs/fetcher.cjs.map +1 -1
  11. package/dist/cjs/getIntlayerAPI/ai.cjs +79 -26
  12. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  13. package/dist/cjs/getIntlayerAPI/analytics.cjs +47 -14
  14. package/dist/cjs/getIntlayerAPI/analytics.cjs.map +1 -1
  15. package/dist/cjs/getIntlayerAPI/asset.cjs +41 -12
  16. package/dist/cjs/getIntlayerAPI/asset.cjs.map +1 -1
  17. package/dist/cjs/getIntlayerAPI/audit.cjs +73 -20
  18. package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
  19. package/dist/cjs/getIntlayerAPI/bitbucket.cjs +42 -13
  20. package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
  21. package/dist/cjs/getIntlayerAPI/codeberg.cjs +20 -0
  22. package/dist/cjs/getIntlayerAPI/codeberg.cjs.map +1 -0
  23. package/dist/cjs/getIntlayerAPI/dictionary.cjs +62 -17
  24. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  25. package/dist/cjs/getIntlayerAPI/editor.cjs +3 -4
  26. package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
  27. package/dist/cjs/getIntlayerAPI/environment.cjs +47 -14
  28. package/dist/cjs/getIntlayerAPI/environment.cjs.map +1 -1
  29. package/dist/cjs/getIntlayerAPI/forge.cjs +63 -0
  30. package/dist/cjs/getIntlayerAPI/forge.cjs.map +1 -0
  31. package/dist/cjs/getIntlayerAPI/gitee.cjs +20 -0
  32. package/dist/cjs/getIntlayerAPI/gitee.cjs.map +1 -0
  33. package/dist/cjs/getIntlayerAPI/github.cjs +47 -14
  34. package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
  35. package/dist/cjs/getIntlayerAPI/gitlab.cjs +42 -13
  36. package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
  37. package/dist/cjs/getIntlayerAPI/index.cjs +27 -24
  38. package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
  39. package/dist/cjs/getIntlayerAPI/newsletter.cjs +31 -10
  40. package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
  41. package/dist/cjs/getIntlayerAPI/oAuth.cjs +33 -8
  42. package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
  43. package/dist/cjs/getIntlayerAPI/organization.cjs +75 -24
  44. package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
  45. package/dist/cjs/getIntlayerAPI/project.cjs +115 -33
  46. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  47. package/dist/cjs/getIntlayerAPI/reviewer.cjs +145 -35
  48. package/dist/cjs/getIntlayerAPI/reviewer.cjs.map +1 -1
  49. package/dist/cjs/getIntlayerAPI/search.cjs +18 -7
  50. package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
  51. package/dist/cjs/getIntlayerAPI/showcaseProject.cjs +64 -19
  52. package/dist/cjs/getIntlayerAPI/showcaseProject.cjs.map +1 -1
  53. package/dist/cjs/getIntlayerAPI/status.cjs +19 -7
  54. package/dist/cjs/getIntlayerAPI/status.cjs.map +1 -1
  55. package/dist/cjs/getIntlayerAPI/stripe.cjs +144 -39
  56. package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
  57. package/dist/cjs/getIntlayerAPI/tag.cjs +36 -11
  58. package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
  59. package/dist/cjs/getIntlayerAPI/translate.cjs +49 -12
  60. package/dist/cjs/getIntlayerAPI/translate.cjs.map +1 -1
  61. package/dist/cjs/getIntlayerAPI/user.cjs +61 -18
  62. package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
  63. package/dist/cjs/index.cjs +38 -30
  64. package/dist/cjs/proxy.cjs +28 -25
  65. package/dist/cjs/proxy.cjs.map +1 -1
  66. package/dist/cjs/public/createPublicClient.cjs +26 -7
  67. package/dist/cjs/public/createPublicClient.cjs.map +1 -1
  68. package/dist/cjs/public/index.cjs +1 -1
  69. package/dist/cjs/resolveInternalBackendUrl.cjs +1 -2
  70. package/dist/esm/cms/createAuthManager.mjs +1 -2
  71. package/dist/esm/cms/createIntlayerCMS.mjs +1 -2
  72. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +1 -2
  73. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  74. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +1 -2
  75. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  76. package/dist/esm/fetcher.mjs +1 -2
  77. package/dist/esm/fetcher.mjs.map +1 -1
  78. package/dist/esm/getIntlayerAPI/ai.mjs +78 -25
  79. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  80. package/dist/esm/getIntlayerAPI/analytics.mjs +46 -13
  81. package/dist/esm/getIntlayerAPI/analytics.mjs.map +1 -1
  82. package/dist/esm/getIntlayerAPI/asset.mjs +40 -11
  83. package/dist/esm/getIntlayerAPI/asset.mjs.map +1 -1
  84. package/dist/esm/getIntlayerAPI/audit.mjs +72 -19
  85. package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
  86. package/dist/esm/getIntlayerAPI/bitbucket.mjs +41 -12
  87. package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
  88. package/dist/esm/getIntlayerAPI/codeberg.mjs +18 -0
  89. package/dist/esm/getIntlayerAPI/codeberg.mjs.map +1 -0
  90. package/dist/esm/getIntlayerAPI/dictionary.mjs +61 -16
  91. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  92. package/dist/esm/getIntlayerAPI/editor.mjs +2 -3
  93. package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
  94. package/dist/esm/getIntlayerAPI/environment.mjs +46 -13
  95. package/dist/esm/getIntlayerAPI/environment.mjs.map +1 -1
  96. package/dist/esm/getIntlayerAPI/forge.mjs +62 -0
  97. package/dist/esm/getIntlayerAPI/forge.mjs.map +1 -0
  98. package/dist/esm/getIntlayerAPI/gitee.mjs +18 -0
  99. package/dist/esm/getIntlayerAPI/gitee.mjs.map +1 -0
  100. package/dist/esm/getIntlayerAPI/github.mjs +46 -13
  101. package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
  102. package/dist/esm/getIntlayerAPI/gitlab.mjs +41 -12
  103. package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
  104. package/dist/esm/getIntlayerAPI/index.mjs +6 -3
  105. package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
  106. package/dist/esm/getIntlayerAPI/newsletter.mjs +30 -9
  107. package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
  108. package/dist/esm/getIntlayerAPI/oAuth.mjs +32 -7
  109. package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
  110. package/dist/esm/getIntlayerAPI/organization.mjs +74 -23
  111. package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
  112. package/dist/esm/getIntlayerAPI/project.mjs +114 -32
  113. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  114. package/dist/esm/getIntlayerAPI/reviewer.mjs +144 -34
  115. package/dist/esm/getIntlayerAPI/reviewer.mjs.map +1 -1
  116. package/dist/esm/getIntlayerAPI/search.mjs +17 -6
  117. package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
  118. package/dist/esm/getIntlayerAPI/showcaseProject.mjs +63 -18
  119. package/dist/esm/getIntlayerAPI/showcaseProject.mjs.map +1 -1
  120. package/dist/esm/getIntlayerAPI/status.mjs +18 -6
  121. package/dist/esm/getIntlayerAPI/status.mjs.map +1 -1
  122. package/dist/esm/getIntlayerAPI/stripe.mjs +143 -38
  123. package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
  124. package/dist/esm/getIntlayerAPI/tag.mjs +35 -10
  125. package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
  126. package/dist/esm/getIntlayerAPI/translate.mjs +48 -11
  127. package/dist/esm/getIntlayerAPI/translate.mjs.map +1 -1
  128. package/dist/esm/getIntlayerAPI/user.mjs +60 -17
  129. package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
  130. package/dist/esm/index.mjs +10 -7
  131. package/dist/esm/proxy.mjs +6 -3
  132. package/dist/esm/proxy.mjs.map +1 -1
  133. package/dist/esm/public/createPublicClient.mjs +26 -7
  134. package/dist/esm/public/createPublicClient.mjs.map +1 -1
  135. package/dist/esm/resolveInternalBackendUrl.mjs +1 -2
  136. package/dist/types/cms/createAuthManager.d.ts +1 -2
  137. package/dist/types/cms/createAuthManager.d.ts.map +1 -1
  138. package/dist/types/cms/createIntlayerCMS.d.ts +0 -2
  139. package/dist/types/cms/createIntlayerCMS.d.ts.map +1 -1
  140. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +1 -3
  141. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
  142. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +1 -3
  143. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
  144. package/dist/types/fetcher.d.ts +1 -3
  145. package/dist/types/fetcher.d.ts.map +1 -1
  146. package/dist/types/getIntlayerAPI/ai.d.ts +3 -5
  147. package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
  148. package/dist/types/getIntlayerAPI/analytics.d.ts +3 -5
  149. package/dist/types/getIntlayerAPI/analytics.d.ts.map +1 -1
  150. package/dist/types/getIntlayerAPI/asset.d.ts +3 -4
  151. package/dist/types/getIntlayerAPI/asset.d.ts.map +1 -1
  152. package/dist/types/getIntlayerAPI/audit.d.ts +49 -7
  153. package/dist/types/getIntlayerAPI/audit.d.ts.map +1 -1
  154. package/dist/types/getIntlayerAPI/bitbucket.d.ts +2 -4
  155. package/dist/types/getIntlayerAPI/bitbucket.d.ts.map +1 -1
  156. package/dist/types/getIntlayerAPI/codeberg.d.ts +59 -0
  157. package/dist/types/getIntlayerAPI/codeberg.d.ts.map +1 -0
  158. package/dist/types/getIntlayerAPI/dictionary.d.ts +3 -5
  159. package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
  160. package/dist/types/getIntlayerAPI/editor.d.ts +4 -5
  161. package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
  162. package/dist/types/getIntlayerAPI/environment.d.ts +3 -5
  163. package/dist/types/getIntlayerAPI/environment.d.ts.map +1 -1
  164. package/dist/types/getIntlayerAPI/forge.d.ts +34 -0
  165. package/dist/types/getIntlayerAPI/forge.d.ts.map +1 -0
  166. package/dist/types/getIntlayerAPI/gitee.d.ts +59 -0
  167. package/dist/types/getIntlayerAPI/gitee.d.ts.map +1 -0
  168. package/dist/types/getIntlayerAPI/github.d.ts +2 -4
  169. package/dist/types/getIntlayerAPI/github.d.ts.map +1 -1
  170. package/dist/types/getIntlayerAPI/gitlab.d.ts +2 -4
  171. package/dist/types/getIntlayerAPI/gitlab.d.ts.map +1 -1
  172. package/dist/types/getIntlayerAPI/index.d.ts +6 -3
  173. package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
  174. package/dist/types/getIntlayerAPI/newsletter.d.ts +3 -5
  175. package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
  176. package/dist/types/getIntlayerAPI/oAuth.d.ts +2 -2
  177. package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
  178. package/dist/types/getIntlayerAPI/organization.d.ts +3 -7
  179. package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
  180. package/dist/types/getIntlayerAPI/project.d.ts +4 -5
  181. package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
  182. package/dist/types/getIntlayerAPI/reviewer.d.ts +682 -39
  183. package/dist/types/getIntlayerAPI/reviewer.d.ts.map +1 -1
  184. package/dist/types/getIntlayerAPI/search.d.ts +3 -5
  185. package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
  186. package/dist/types/getIntlayerAPI/showcaseProject.d.ts +3 -5
  187. package/dist/types/getIntlayerAPI/showcaseProject.d.ts.map +1 -1
  188. package/dist/types/getIntlayerAPI/status.d.ts +5 -8
  189. package/dist/types/getIntlayerAPI/status.d.ts.map +1 -1
  190. package/dist/types/getIntlayerAPI/stripe.d.ts +3 -5
  191. package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
  192. package/dist/types/getIntlayerAPI/tag.d.ts +3 -5
  193. package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
  194. package/dist/types/getIntlayerAPI/translate.d.ts +3 -5
  195. package/dist/types/getIntlayerAPI/translate.d.ts.map +1 -1
  196. package/dist/types/getIntlayerAPI/user.d.ts +6 -8
  197. package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
  198. package/dist/types/index.d.ts +12 -9
  199. package/dist/types/proxy.d.ts +0 -2
  200. package/dist/types/proxy.d.ts.map +1 -1
  201. package/dist/types/public/createPublicClient.d.ts +1 -9
  202. package/dist/types/public/createPublicClient.d.ts.map +1 -1
  203. package/dist/types/resolveInternalBackendUrl.d.ts +0 -2
  204. package/dist/types/resolveInternalBackendUrl.d.ts.map +1 -1
  205. package/dist/types/types.d.ts +5 -2
  206. package/package.json +23 -6
@@ -1,33 +1,79 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_fetcher = require('../fetcher.cjs');
3
- const require_cms_createIntlayerCMS = require('../cms/createIntlayerCMS.cjs');
2
+ const require_cms_createIntlayerCMS = require("../cms/createIntlayerCMS.cjs");
3
+ const require_fetcher = require("../fetcher.cjs");
4
4
  let _intlayer_config_built = require("@intlayer/config/built");
5
+ let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
6
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
5
7
 
6
- //#region src/getIntlayerAPI/dictionary.ts
8
+ // src/getIntlayerAPI/dictionary.ts
9
+ /** Prefix of the routes, checked against the backend contract. */
10
+ const dictionaryGroup = { prefix: "/api/dictionary" };
11
+ /**
12
+ * Method and path of every route, checked against the backend contract at
13
+ * compile time (the contract's zod schemas are never loaded).
14
+ */
15
+ const dictionaryEndpoints = {
16
+ getDictionaries: {
17
+ method: "GET",
18
+ path: "/"
19
+ },
20
+ getDictionariesKeys: {
21
+ method: "GET",
22
+ path: "/keys"
23
+ },
24
+ getDictionariesUpdateTimestamp: {
25
+ method: "GET",
26
+ path: "/update"
27
+ },
28
+ getDictionariesByKeys: {
29
+ method: "GET",
30
+ path: "/by-keys"
31
+ },
32
+ getDictionary: {
33
+ method: "GET",
34
+ path: "/:dictionaryKey"
35
+ },
36
+ addDictionary: {
37
+ method: "POST",
38
+ path: "/"
39
+ },
40
+ pushDictionaries: {
41
+ method: "PATCH",
42
+ path: "/"
43
+ },
44
+ updateDictionary: {
45
+ method: "PUT",
46
+ path: "/:dictionaryId"
47
+ },
48
+ deleteDictionary: {
49
+ method: "DELETE",
50
+ path: "/:dictionaryId"
51
+ }
52
+ };
7
53
  const getDictionaryAPI = (authAPIOptions = {}, intlayerConfig) => {
8
- const PROJECT_API_ROUTE = `${intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL}/api/dictionary`;
54
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
9
55
  /**
10
56
  * Retrieves a list of dictionaries based on filters and pagination.
11
57
  * @param filters - Filters and pagination options.
12
58
  */
13
- const getDictionaries = async (filters, otherOptions = {}) => await require_fetcher.fetcher(PROJECT_API_ROUTE, authAPIOptions, otherOptions, {
59
+ const getDictionaries = async (filters, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, dictionaryGroup, dictionaryEndpoints.getDictionaries), authAPIOptions, otherOptions, {
14
60
  cache: "no-store",
15
61
  params: filters
16
62
  });
17
63
  /**
18
64
  * Retrieves a list of dictionary keys related to the project.
19
65
  */
20
- const getDictionariesKeys = async (otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/keys`, authAPIOptions, otherOptions, { cache: "no-store" });
66
+ const getDictionariesKeys = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, dictionaryGroup, dictionaryEndpoints.getDictionariesKeys), authAPIOptions, otherOptions, { cache: "no-store" });
21
67
  /**
22
68
  * Retrieves a list of dictionary keys related to the project.
23
69
  */
24
- const getDictionariesUpdateTimestamp = async (otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/update`, authAPIOptions, otherOptions, { cache: "no-store" });
70
+ const getDictionariesUpdateTimestamp = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, dictionaryGroup, dictionaryEndpoints.getDictionariesUpdateTimestamp), authAPIOptions, otherOptions, { cache: "no-store" });
25
71
  /**
26
72
  * Retrieves a dictionary by its key and version.
27
73
  * @param dictionaryKey - Dictionary key.
28
74
  * @param version - Dictionary version of content.
29
75
  */
30
- const getDictionary = async (dictionaryKey, version, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/${dictionaryKey}`, authAPIOptions, otherOptions, { params: version ? { version: version.toString() } : void 0 });
76
+ const getDictionary = async (dictionaryKey, version, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, dictionaryGroup, dictionaryEndpoints.getDictionary, { dictionaryKey }), authAPIOptions, otherOptions, { params: version ? { version: version.toString() } : void 0 });
31
77
  /**
32
78
  * Retrieves several dictionaries at once from their keys, in a single
33
79
  * request. Keys matching no dictionary are absent from the result, so the
@@ -36,7 +82,7 @@ const getDictionaryAPI = (authAPIOptions = {}, intlayerConfig) => {
36
82
  * @param dictionaryKeys - Dictionary keys to retrieve.
37
83
  * @param version - Dictionary version of content.
38
84
  */
39
- const getDictionariesByKeys = async (dictionaryKeys, version, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/by-keys`, authAPIOptions, otherOptions, {
85
+ const getDictionariesByKeys = async (dictionaryKeys, version, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, dictionaryGroup, dictionaryEndpoints.getDictionariesByKeys), authAPIOptions, otherOptions, {
40
86
  cache: "no-store",
41
87
  params: {
42
88
  keys: dictionaryKeys.join(","),
@@ -47,27 +93,27 @@ const getDictionaryAPI = (authAPIOptions = {}, intlayerConfig) => {
47
93
  * Adds a new dictionary to the database.
48
94
  * @param dictionary - Dictionary data.
49
95
  */
50
- const addDictionary = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
51
- method: "POST",
96
+ const addDictionary = async (body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, dictionaryGroup, dictionaryEndpoints.addDictionary), authAPIOptions, otherOptions, {
97
+ method: dictionaryEndpoints.addDictionary.method,
52
98
  body
53
99
  });
54
- const pushDictionaries = async (dictionaries, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
55
- method: "PATCH",
100
+ const pushDictionaries = async (dictionaries, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, dictionaryGroup, dictionaryEndpoints.pushDictionaries), authAPIOptions, otherOptions, {
101
+ method: dictionaryEndpoints.pushDictionaries.method,
56
102
  body: { dictionaries }
57
103
  });
58
104
  /**
59
105
  * Updates an existing dictionary in the database.
60
106
  * @param dictionary - Updated dictionary data.
61
107
  */
62
- const updateDictionary = async (dictionary, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/${dictionary.id}`, authAPIOptions, otherOptions, {
63
- method: "PUT",
108
+ const updateDictionary = async (dictionary, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, dictionaryGroup, dictionaryEndpoints.updateDictionary, { dictionaryId: String(dictionary.id) }), authAPIOptions, otherOptions, {
109
+ method: dictionaryEndpoints.updateDictionary.method,
64
110
  body: dictionary
65
111
  });
66
112
  /**
67
113
  * Deletes a dictionary from the database by its ID.
68
114
  * @param id - Dictionary ID.
69
115
  */
70
- const deleteDictionary = async (id, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/${id}`, authAPIOptions, otherOptions, { method: "DELETE" });
116
+ const deleteDictionary = async (id, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, dictionaryGroup, dictionaryEndpoints.deleteDictionary, { dictionaryId: String(id) }), authAPIOptions, otherOptions, { method: dictionaryEndpoints.deleteDictionary.method });
71
117
  return {
72
118
  getDictionaries,
73
119
  getDictionariesKeys,
@@ -88,7 +134,6 @@ const getDictionaryAPI = (authAPIOptions = {}, intlayerConfig) => {
88
134
  */
89
135
  const dictionaryEndpoint = require_cms_createIntlayerCMS.createEndpoint(getDictionaryAPI);
90
136
 
91
- //#endregion
92
137
  exports.dictionaryEndpoint = dictionaryEndpoint;
93
138
  exports.getDictionaryAPI = getDictionaryAPI;
94
139
  //# sourceMappingURL=dictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"dictionary.cjs","names":["editor","fetcher","createEndpoint"],"sources":["../../../src/getIntlayerAPI/dictionary.ts"],"sourcesContent":["import type {\n AddDictionaryBody,\n AddDictionaryResult,\n DeleteDictionaryParam,\n DeleteDictionaryResult,\n GetDictionariesByKeysResult,\n GetDictionariesKeysResult,\n GetDictionariesParams,\n GetDictionariesResult,\n GetDictionariesUpdateTimestampResult,\n GetDictionaryParams,\n GetDictionaryQuery,\n GetDictionaryResult,\n PushDictionariesBody,\n PushDictionariesResult,\n UpdateDictionaryBody,\n UpdateDictionaryResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getDictionaryAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\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 * Retrieves several dictionaries at once from their keys, in a single\n * request. Keys matching no dictionary are absent from the result, so the\n * caller should reconcile the response against the requested keys.\n *\n * @param dictionaryKeys - Dictionary keys to retrieve.\n * @param version - Dictionary version of content.\n */\n const getDictionariesByKeys = async (\n dictionaryKeys: string[],\n version?: GetDictionaryQuery['version'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionariesByKeysResult>(\n `${PROJECT_API_ROUTE}/by-keys`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n params: {\n keys: dictionaryKeys.join(','),\n version: version?.toString(),\n },\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 getDictionariesByKeys,\n pushDictionaries,\n addDictionary,\n updateDictionary,\n deleteDictionary,\n };\n};\n\n/**\n * Authenticated `dictionary` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const dictionaryEndpoint = createEndpoint(getDictionaryAPI);\n"],"mappings":";;;;;;AAuBA,MAAa,oBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,oBAAoB,GAFP,gBAAgB,QAAQ,cAAcA,8BAAO,WAExB;;;;;CAMxC,MAAM,kBAAkB,OACtB,SACA,eAA+B,CAAC,MAEhC,MAAMC,wBACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;CAKF,MAAM,sBAAsB,OAAO,eAA+B,CAAC,MACjE,MAAMA,wBACJ,GAAG,kBAAkB,QACrB,gBACA,cACA,EACE,OAAO,WACT,CACF;;;;CAKF,MAAM,iCAAiC,OACrC,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,kBAAkB,UACrB,gBACA,cACA,EACE,OAAO,WACT,CACF;;;;;;CAOF,MAAM,gBAAgB,OACpB,eACA,SACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,kBAAkB,GAAG,iBACxB,gBACA,cACA,EACE,QAAQ,UAAU,EAAE,SAAS,QAAQ,SAAS,EAAE,IAAI,OACtD,CACF;;;;;;;;;CAUF,MAAM,wBAAwB,OAC5B,gBACA,SACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,OAAO;EACP,QAAQ;GACN,MAAM,eAAe,KAAK,GAAG;GAC7B,SAAS,SAAS,SAAS;EAC7B;CACF,CACF;;;;;CAMF,MAAM,gBAAgB,OACpB,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;CAEF,MAAM,mBAAmB,OACvB,cACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,aAAa;CACvB,CACF;;;;;CAMF,MAAM,mBAAmB,OACvB,YACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,kBAAkB,GAAG,WAAW,MACnC,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,mBAAmB,OACvB,IACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,kBAAkB,GAAG,MACxB,gBACA,cACA,EACE,QAAQ,SACV,CACF;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,qBAAqBC,6CAAe,gBAAgB"}
1
+ {"version":3,"file":"dictionary.cjs","names":["editor","BACKEND_URL","fetcher","buildRouteURL","createEndpoint"],"sources":["../../../src/getIntlayerAPI/dictionary.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n AddDictionaryBody,\n AddDictionaryResult,\n DeleteDictionaryParam,\n DeleteDictionaryResult,\n DictionaryRoutes,\n dictionaryContract,\n GetDictionariesByKeysResult,\n GetDictionariesKeysResult,\n GetDictionariesParams,\n GetDictionariesResult,\n GetDictionariesUpdateTimestampResult,\n GetDictionaryParams,\n GetDictionaryQuery,\n GetDictionaryResult,\n PushDictionariesBody,\n PushDictionariesResult,\n UpdateDictionaryBody,\n UpdateDictionaryResult,\n} from '@intlayer/backend-contract/dictionary';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\n/** Prefix of the routes, checked against the backend contract. */\nconst dictionaryGroup = {\n prefix: '/api/dictionary',\n} as const satisfies Pick<typeof dictionaryContract, 'prefix'>;\n\n/**\n * Method and path of every route, checked against the backend contract at\n * compile time (the contract's zod schemas are never loaded).\n */\nconst dictionaryEndpoints = {\n getDictionaries: { method: 'GET', path: '/' },\n getDictionariesKeys: { method: 'GET', path: '/keys' },\n getDictionariesUpdateTimestamp: { method: 'GET', path: '/update' },\n getDictionariesByKeys: { method: 'GET', path: '/by-keys' },\n getDictionary: { method: 'GET', path: '/:dictionaryKey' },\n addDictionary: { method: 'POST', path: '/' },\n pushDictionaries: { method: 'PATCH', path: '/' },\n updateDictionary: { method: 'PUT', path: '/:dictionaryId' },\n deleteDictionary: { method: 'DELETE', path: '/:dictionaryId' },\n} as const satisfies RouteEndpoints<DictionaryRoutes>;\n\nexport const getDictionaryAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\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 buildRouteURL(\n backendURL,\n dictionaryGroup,\n dictionaryEndpoints.getDictionaries\n ),\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 buildRouteURL(\n backendURL,\n dictionaryGroup,\n dictionaryEndpoints.getDictionariesKeys\n ),\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 buildRouteURL(\n backendURL,\n dictionaryGroup,\n dictionaryEndpoints.getDictionariesUpdateTimestamp\n ),\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 buildRouteURL(\n backendURL,\n dictionaryGroup,\n dictionaryEndpoints.getDictionary,\n { dictionaryKey }\n ),\n authAPIOptions,\n otherOptions,\n {\n params: version ? { version: version.toString() } : undefined,\n }\n );\n\n /**\n * Retrieves several dictionaries at once from their keys, in a single\n * request. Keys matching no dictionary are absent from the result, so the\n * caller should reconcile the response against the requested keys.\n *\n * @param dictionaryKeys - Dictionary keys to retrieve.\n * @param version - Dictionary version of content.\n */\n const getDictionariesByKeys = async (\n dictionaryKeys: string[],\n version?: GetDictionaryQuery['version'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetDictionariesByKeysResult>(\n buildRouteURL(\n backendURL,\n dictionaryGroup,\n dictionaryEndpoints.getDictionariesByKeys\n ),\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n params: {\n keys: dictionaryKeys.join(','),\n version: version?.toString(),\n },\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 buildRouteURL(\n backendURL,\n dictionaryGroup,\n dictionaryEndpoints.addDictionary\n ),\n authAPIOptions,\n otherOptions,\n {\n method: dictionaryEndpoints.addDictionary.method,\n body,\n }\n );\n\n const pushDictionaries = async (\n dictionaries: PushDictionariesBody['dictionaries'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushDictionariesResult>(\n buildRouteURL(\n backendURL,\n dictionaryGroup,\n dictionaryEndpoints.pushDictionaries\n ),\n authAPIOptions,\n otherOptions,\n {\n method: dictionaryEndpoints.pushDictionaries.method,\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 buildRouteURL(\n backendURL,\n dictionaryGroup,\n dictionaryEndpoints.updateDictionary,\n { dictionaryId: String(dictionary.id) }\n ),\n authAPIOptions,\n otherOptions,\n {\n method: dictionaryEndpoints.updateDictionary.method,\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 buildRouteURL(\n backendURL,\n dictionaryGroup,\n dictionaryEndpoints.deleteDictionary,\n { dictionaryId: String(id) }\n ),\n authAPIOptions,\n otherOptions,\n {\n method: dictionaryEndpoints.deleteDictionary.method,\n }\n );\n\n return {\n getDictionaries,\n getDictionariesKeys,\n getDictionariesUpdateTimestamp,\n getDictionary,\n getDictionariesByKeys,\n pushDictionaries,\n addDictionary,\n updateDictionary,\n deleteDictionary,\n };\n};\n\n/**\n * Authenticated `dictionary` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const dictionaryEndpoint = createEndpoint(getDictionaryAPI);\n"],"mappings":";;;;;;;;;AA6BA,MAAM,kBAAkB,EACtB,QAAQ,kBACV;;;;;AAMA,MAAM,sBAAsB;CAC1B,iBAAiB;EAAE,QAAQ;EAAO,MAAM;CAAI;CAC5C,qBAAqB;EAAE,QAAQ;EAAO,MAAM;CAAQ;CACpD,gCAAgC;EAAE,QAAQ;EAAO,MAAM;CAAU;CACjE,uBAAuB;EAAE,QAAQ;EAAO,MAAM;CAAW;CACzD,eAAe;EAAE,QAAQ;EAAO,MAAM;CAAkB;CACxD,eAAe;EAAE,QAAQ;EAAQ,MAAM;CAAI;CAC3C,kBAAkB;EAAE,QAAQ;EAAS,MAAM;CAAI;CAC/C,kBAAkB;EAAE,QAAQ;EAAO,MAAM;CAAiB;CAC1D,kBAAkB;EAAE,QAAQ;EAAU,MAAM;CAAiB;AAC/D;AAEA,MAAa,oBACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,8BAAO,cAAcC;;;;;CAM7D,MAAM,kBAAkB,OACtB,SACA,eAA+B,CAAC,MAEhC,MAAMC,4BACJC,sDACE,YACA,iBACA,oBAAoB,eACtB,GACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;CAKF,MAAM,sBAAsB,OAAO,eAA+B,CAAC,MACjE,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,mBACtB,GACA,gBACA,cACA,EACE,OAAO,WACT,CACF;;;;CAKF,MAAM,iCAAiC,OACrC,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,8BACtB,GACA,gBACA,cACA,EACE,OAAO,WACT,CACF;;;;;;CAOF,MAAM,gBAAgB,OACpB,eACA,SACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,eACpB,EAAE,cAAc,CAClB,GACA,gBACA,cACA,EACE,QAAQ,UAAU,EAAE,SAAS,QAAQ,SAAS,EAAE,IAAI,OACtD,CACF;;;;;;;;;CAUF,MAAM,wBAAwB,OAC5B,gBACA,SACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,qBACtB,GACA,gBACA,cACA;EACE,OAAO;EACP,QAAQ;GACN,MAAM,eAAe,KAAK,GAAG;GAC7B,SAAS,SAAS,SAAS;EAC7B;CACF,CACF;;;;;CAMF,MAAM,gBAAgB,OACpB,MACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,aACtB,GACA,gBACA,cACA;EACE,QAAQ,oBAAoB,cAAc;EAC1C;CACF,CACF;CAEF,MAAM,mBAAmB,OACvB,cACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,gBACtB,GACA,gBACA,cACA;EACE,QAAQ,oBAAoB,iBAAiB;EAC7C,MAAM,EAAE,aAAa;CACvB,CACF;;;;;CAMF,MAAM,mBAAmB,OACvB,YACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,kBACpB,EAAE,cAAc,OAAO,WAAW,EAAE,EAAE,CACxC,GACA,gBACA,cACA;EACE,QAAQ,oBAAoB,iBAAiB;EAC7C,MAAM;CACR,CACF;;;;;CAMF,MAAM,mBAAmB,OACvB,IACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,kBACpB,EAAE,cAAc,OAAO,EAAE,EAAE,CAC7B,GACA,gBACA,cACA,EACE,QAAQ,oBAAoB,iBAAiB,OAC/C,CACF;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,qBAAqBC,6CAAe,gBAAgB"}
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_fetcher = require('../fetcher.cjs');
3
- const require_cms_createIntlayerCMS = require('../cms/createIntlayerCMS.cjs');
2
+ const require_cms_createIntlayerCMS = require("../cms/createIntlayerCMS.cjs");
3
+ const require_fetcher = require("../fetcher.cjs");
4
4
  let _intlayer_config_built = require("@intlayer/config/built");
5
5
 
6
- //#region src/getIntlayerAPI/editor.ts
6
+ // src/getIntlayerAPI/editor.ts
7
7
  const getEditorAPI = (authAPIOptions = {}, intlayerConfig) => {
8
8
  const EDITOR_API_ROUTE = `${intlayerConfig?.editor?.editorURL ?? _intlayer_config_built.editor.editorURL}/api`;
9
9
  /**
@@ -40,7 +40,6 @@ const getEditorAPI = (authAPIOptions = {}, intlayerConfig) => {
40
40
  */
41
41
  const editorEndpoint = require_cms_createIntlayerCMS.createEndpoint(getEditorAPI);
42
42
 
43
- //#endregion
44
43
  exports.editorEndpoint = editorEndpoint;
45
44
  exports.getEditorAPI = getEditorAPI;
46
45
  //# sourceMappingURL=editor.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor.cjs","names":["editor","fetcher","createEndpoint"],"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from 'intlayer-editor';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const editorURL = intlayerConfig?.editor?.editorURL ?? editor.editorURL;\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\n/**\n * Authenticated `editor` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const editorEndpoint = createEndpoint(getEditorAPI);\n"],"mappings":";;;;;;AAWA,MAAa,gBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,mBAAmB,GAFP,gBAAgB,QAAQ,aAAaA,8BAAO,UAExB;;;;CAKtC,MAAM,mBAAmB,OACvB,eAA+B,CAAC,MACI;EAOpC,QAAO,MANgBC,wBACrB,GAAG,iBAAiB,UACpB,gBACA,YACF,EAEe,CAAC;CAClB;;;;CAKA,MAAM,kBAAkB,OACtB,eAA+B,CAAC,MACS;EAOzC,QAAO,MANgBA,wBACrB,GAAG,iBAAiB,cACpB,gBACA,YACF,EAEe,CAAC;CAClB;;;;;CAMA,MAAM,kBAAkB,OACtB,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,iBAAiB,cACpB,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;CAEF,OAAO;EACL;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,iBAAiBC,6CAAe,YAAY"}
1
+ {"version":3,"file":"editor.cjs","names":["editor","fetcher","createEndpoint"],"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from 'intlayer-editor';\n\nexport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n};\n\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const editorURL = intlayerConfig?.editor?.editorURL ?? editor.editorURL;\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\n/**\n * Authenticated `editor` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const editorEndpoint = createEndpoint(getEditorAPI);\n"],"mappings":";;;;;;AAmBA,MAAa,gBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,mBAAmB,GAFP,gBAAgB,QAAQ,aAAaA,8BAAO,UAExB;;;;CAKtC,MAAM,mBAAmB,OACvB,eAA+B,CAAC,MACI;EAOpC,QAAO,MANgBC,wBACrB,GAAG,iBAAiB,UACpB,gBACA,YACF,EAEe,CAAC;CAClB;;;;CAKA,MAAM,kBAAkB,OACtB,eAA+B,CAAC,MACS;EAOzC,QAAO,MANgBA,wBACrB,GAAG,iBAAiB,cACpB,gBACA,YACF,EAEe,CAAC;CAClB;;;;;CAMA,MAAM,kBAAkB,OACtB,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,iBAAiB,cACpB,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;CAEF,OAAO;EACL;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,iBAAiBC,6CAAe,YAAY"}
@@ -1,24 +1,58 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_fetcher = require('../fetcher.cjs');
3
- const require_cms_createIntlayerCMS = require('../cms/createIntlayerCMS.cjs');
2
+ const require_cms_createIntlayerCMS = require("../cms/createIntlayerCMS.cjs");
3
+ const require_fetcher = require("../fetcher.cjs");
4
4
  let _intlayer_config_built = require("@intlayer/config/built");
5
+ let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
6
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
5
7
 
6
- //#region src/getIntlayerAPI/environment.ts
7
- const getEnvironmentAPI = (authAPIOptions = {}, intlayerConfig) => {
8
- const ENVIRONMENT_API_ROUTE = `${intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL}/api/project/environment`;
9
- const addEnvironment = async (body, otherOptions = {}) => await require_fetcher.fetcher(ENVIRONMENT_API_ROUTE, authAPIOptions, otherOptions, {
8
+ // src/getIntlayerAPI/environment.ts
9
+ /** Prefix of the routes, checked against the backend contract. */
10
+ const environmentGroup = { prefix: "/api/project/environment" };
11
+ /**
12
+ * Method and path of every route, checked against the backend contract at
13
+ * compile time (the contract's zod schemas are never loaded).
14
+ */
15
+ const environmentEndpoints = {
16
+ addEnvironment: {
10
17
  method: "POST",
18
+ path: "/"
19
+ },
20
+ updateEnvironment: {
21
+ method: "PUT",
22
+ path: "/:environmentId"
23
+ },
24
+ deleteEnvironment: {
25
+ method: "DELETE",
26
+ path: "/:environmentId"
27
+ },
28
+ resetToProductionEnvironment: {
29
+ method: "PUT",
30
+ path: "/production/select"
31
+ },
32
+ selectEnvironment: {
33
+ method: "PUT",
34
+ path: "/:environmentId/select"
35
+ },
36
+ migrateEnvironment: {
37
+ method: "POST",
38
+ path: "/migrate"
39
+ }
40
+ };
41
+ const getEnvironmentAPI = (authAPIOptions = {}, intlayerConfig) => {
42
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
43
+ const addEnvironment = async (body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, environmentGroup, environmentEndpoints.addEnvironment), authAPIOptions, otherOptions, {
44
+ method: environmentEndpoints.addEnvironment.method,
11
45
  body
12
46
  });
13
- const updateEnvironment = async (environmentId, body, otherOptions = {}) => await require_fetcher.fetcher(`${ENVIRONMENT_API_ROUTE}/${environmentId}`, authAPIOptions, otherOptions, {
14
- method: "PUT",
47
+ const updateEnvironment = async (environmentId, body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, environmentGroup, environmentEndpoints.updateEnvironment, { environmentId }), authAPIOptions, otherOptions, {
48
+ method: environmentEndpoints.updateEnvironment.method,
15
49
  body
16
50
  });
17
- const deleteEnvironment = async (environmentId, otherOptions = {}) => await require_fetcher.fetcher(`${ENVIRONMENT_API_ROUTE}/${environmentId}`, authAPIOptions, otherOptions, { method: "DELETE" });
18
- const selectEnvironment = async (environmentId, otherOptions = {}) => await require_fetcher.fetcher(`${ENVIRONMENT_API_ROUTE}/${environmentId}/select`, authAPIOptions, otherOptions, { method: "PUT" });
19
- const resetToProductionEnvironment = async (otherOptions = {}) => await require_fetcher.fetcher(`${ENVIRONMENT_API_ROUTE}/production/select`, authAPIOptions, otherOptions, { method: "PUT" });
20
- const migrateEnvironment = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${ENVIRONMENT_API_ROUTE}/migrate`, authAPIOptions, otherOptions, {
21
- method: "POST",
51
+ const deleteEnvironment = async (environmentId, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, environmentGroup, environmentEndpoints.deleteEnvironment, { environmentId }), authAPIOptions, otherOptions, { method: environmentEndpoints.deleteEnvironment.method });
52
+ const selectEnvironment = async (environmentId, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, environmentGroup, environmentEndpoints.selectEnvironment, { environmentId }), authAPIOptions, otherOptions, { method: environmentEndpoints.selectEnvironment.method });
53
+ const resetToProductionEnvironment = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, environmentGroup, environmentEndpoints.resetToProductionEnvironment), authAPIOptions, otherOptions, { method: environmentEndpoints.resetToProductionEnvironment.method });
54
+ const migrateEnvironment = async (body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, environmentGroup, environmentEndpoints.migrateEnvironment), authAPIOptions, otherOptions, {
55
+ method: environmentEndpoints.migrateEnvironment.method,
22
56
  body
23
57
  });
24
58
  return {
@@ -38,7 +72,6 @@ const getEnvironmentAPI = (authAPIOptions = {}, intlayerConfig) => {
38
72
  */
39
73
  const environmentEndpoint = require_cms_createIntlayerCMS.createEndpoint(getEnvironmentAPI);
40
74
 
41
- //#endregion
42
75
  exports.environmentEndpoint = environmentEndpoint;
43
76
  exports.getEnvironmentAPI = getEnvironmentAPI;
44
77
  //# sourceMappingURL=environment.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.cjs","names":["editor","fetcher","createEndpoint"],"sources":["../../../src/getIntlayerAPI/environment.ts"],"sourcesContent":["import type {\n AddEnvironmentBody,\n AddEnvironmentResult,\n DeleteEnvironmentResult,\n MigrateEnvironmentBody,\n MigrateEnvironmentResult,\n ResetToProductionEnvironmentResult,\n SelectEnvironmentResult,\n UpdateEnvironmentBody,\n UpdateEnvironmentResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getEnvironmentAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n const ENVIRONMENT_API_ROUTE = `${backendURL}/api/project/environment`;\n\n const addEnvironment = async (\n body: AddEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddEnvironmentResult>(\n ENVIRONMENT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const updateEnvironment = async (\n environmentId: string,\n body: UpdateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n const deleteEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n const selectEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}/select`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const resetToProductionEnvironment = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetToProductionEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/production/select`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const migrateEnvironment = async (\n body: MigrateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<MigrateEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/migrate`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n return {\n addEnvironment,\n updateEnvironment,\n deleteEnvironment,\n selectEnvironment,\n resetToProductionEnvironment,\n migrateEnvironment,\n };\n};\n\n/**\n * Authenticated `environment` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const environmentEndpoint = createEndpoint(getEnvironmentAPI);\n"],"mappings":";;;;;;AAgBA,MAAa,qBACX,iBAAiC,CAAC,GAClC,mBACG;CAEH,MAAM,wBAAwB,GADX,gBAAgB,QAAQ,cAAcA,8BAAO,WACpB;CAE5C,MAAM,iBAAiB,OACrB,MACA,eAA+B,CAAC,MAEhC,MAAMC,wBACJ,uBACA,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;CAEF,MAAM,oBAAoB,OACxB,eACA,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,sBAAsB,GAAG,iBAC5B,gBACA,cACA;EAAE,QAAQ;EAAO;CAAK,CACxB;CAEF,MAAM,oBAAoB,OACxB,eACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,sBAAsB,GAAG,iBAC5B,gBACA,cACA,EAAE,QAAQ,SAAS,CACrB;CAEF,MAAM,oBAAoB,OACxB,eACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,sBAAsB,GAAG,cAAc,UAC1C,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;CAEF,MAAM,+BAA+B,OACnC,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,sBAAsB,qBACzB,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;CAEF,MAAM,qBAAqB,OACzB,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,sBAAsB,WACzB,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,sBAAsBC,6CAAe,iBAAiB"}
1
+ {"version":3,"file":"environment.cjs","names":["editor","BACKEND_URL","fetcher","buildRouteURL","createEndpoint"],"sources":["../../../src/getIntlayerAPI/environment.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n AddEnvironmentBody,\n AddEnvironmentResult,\n DeleteEnvironmentResult,\n EnvironmentRoutes,\n environmentContract,\n MigrateEnvironmentBody,\n MigrateEnvironmentResult,\n ResetToProductionEnvironmentResult,\n SelectEnvironmentResult,\n UpdateEnvironmentBody,\n UpdateEnvironmentResult,\n} from '@intlayer/backend-contract/environment';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\n/** Prefix of the routes, checked against the backend contract. */\nconst environmentGroup = {\n prefix: '/api/project/environment',\n} as const satisfies Pick<typeof environmentContract, 'prefix'>;\n\n/**\n * Method and path of every route, checked against the backend contract at\n * compile time (the contract's zod schemas are never loaded).\n */\nconst environmentEndpoints = {\n addEnvironment: { method: 'POST', path: '/' },\n updateEnvironment: { method: 'PUT', path: '/:environmentId' },\n deleteEnvironment: { method: 'DELETE', path: '/:environmentId' },\n resetToProductionEnvironment: { method: 'PUT', path: '/production/select' },\n selectEnvironment: { method: 'PUT', path: '/:environmentId/select' },\n migrateEnvironment: { method: 'POST', path: '/migrate' },\n} as const satisfies RouteEndpoints<EnvironmentRoutes>;\n\nexport const getEnvironmentAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n const addEnvironment = async (\n body: AddEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.addEnvironment\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.addEnvironment.method, body }\n );\n\n const updateEnvironment = async (\n environmentId: string,\n body: UpdateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.updateEnvironment,\n { environmentId }\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.updateEnvironment.method, body }\n );\n\n const deleteEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.deleteEnvironment,\n { environmentId }\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.deleteEnvironment.method }\n );\n\n const selectEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.selectEnvironment,\n { environmentId }\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.selectEnvironment.method }\n );\n\n const resetToProductionEnvironment = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetToProductionEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.resetToProductionEnvironment\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.resetToProductionEnvironment.method }\n );\n\n const migrateEnvironment = async (\n body: MigrateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<MigrateEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.migrateEnvironment\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.migrateEnvironment.method, body }\n );\n\n return {\n addEnvironment,\n updateEnvironment,\n deleteEnvironment,\n selectEnvironment,\n resetToProductionEnvironment,\n migrateEnvironment,\n };\n};\n\n/**\n * Authenticated `environment` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const environmentEndpoint = createEndpoint(getEnvironmentAPI);\n"],"mappings":";;;;;;;;;AAsBA,MAAM,mBAAmB,EACvB,QAAQ,2BACV;;;;;AAMA,MAAM,uBAAuB;CAC3B,gBAAgB;EAAE,QAAQ;EAAQ,MAAM;CAAI;CAC5C,mBAAmB;EAAE,QAAQ;EAAO,MAAM;CAAkB;CAC5D,mBAAmB;EAAE,QAAQ;EAAU,MAAM;CAAkB;CAC/D,8BAA8B;EAAE,QAAQ;EAAO,MAAM;CAAqB;CAC1E,mBAAmB;EAAE,QAAQ;EAAO,MAAM;CAAyB;CACnE,oBAAoB;EAAE,QAAQ;EAAQ,MAAM;CAAW;AACzD;AAEA,MAAa,qBACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,8BAAO,cAAcC;CAE7D,MAAM,iBAAiB,OACrB,MACA,eAA+B,CAAC,MAEhC,MAAMC,4BACJC,sDACE,YACA,kBACA,qBAAqB,cACvB,GACA,gBACA,cACA;EAAE,QAAQ,qBAAqB,eAAe;EAAQ;CAAK,CAC7D;CAEF,MAAM,oBAAoB,OACxB,eACA,MACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,kBACA,qBAAqB,mBACrB,EAAE,cAAc,CAClB,GACA,gBACA,cACA;EAAE,QAAQ,qBAAqB,kBAAkB;EAAQ;CAAK,CAChE;CAEF,MAAM,oBAAoB,OACxB,eACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,kBACA,qBAAqB,mBACrB,EAAE,cAAc,CAClB,GACA,gBACA,cACA,EAAE,QAAQ,qBAAqB,kBAAkB,OAAO,CAC1D;CAEF,MAAM,oBAAoB,OACxB,eACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,kBACA,qBAAqB,mBACrB,EAAE,cAAc,CAClB,GACA,gBACA,cACA,EAAE,QAAQ,qBAAqB,kBAAkB,OAAO,CAC1D;CAEF,MAAM,+BAA+B,OACnC,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,kBACA,qBAAqB,4BACvB,GACA,gBACA,cACA,EAAE,QAAQ,qBAAqB,6BAA6B,OAAO,CACrE;CAEF,MAAM,qBAAqB,OACzB,MACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,kBACA,qBAAqB,kBACvB,GACA,gBACA,cACA;EAAE,QAAQ,qBAAqB,mBAAmB;EAAQ;CAAK,CACjE;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,sBAAsBC,6CAAe,iBAAiB"}
@@ -0,0 +1,63 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_fetcher = require("../fetcher.cjs");
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+ let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
5
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
6
+
7
+ // src/getIntlayerAPI/forge.ts
8
+ /**
9
+ * Method and path of every route of a Gitea-compatible forge, checked
10
+ * against the backend contract at compile time.
11
+ */
12
+ const forgeEndpoints = {
13
+ listRepos: {
14
+ method: "GET",
15
+ path: "/repos"
16
+ },
17
+ checkConfig: {
18
+ method: "POST",
19
+ path: "/check-config"
20
+ },
21
+ getConfigFile: {
22
+ method: "POST",
23
+ path: "/get-config-file"
24
+ }
25
+ };
26
+ /**
27
+ * Client of a Gitea-compatible forge (Codeberg, Gitee). Omitting `token` makes
28
+ * the backend use the account linked to the session.
29
+ */
30
+ const createForgeAPI = (group) => (authAPIOptions = {}, intlayerConfig) => {
31
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
32
+ /** Repositories of the linked account. */
33
+ const getRepositories = async (token, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, group, forgeEndpoints.listRepos), authAPIOptions, otherOptions, { params: token ? { token } : void 0 });
34
+ /** Paths of the Intlayer configuration files of a repository branch. */
35
+ const checkIntlayerConfig = async (token, owner, repository, branch = "main", otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, group, forgeEndpoints.checkConfig), authAPIOptions, otherOptions, {
36
+ method: forgeEndpoints.checkConfig.method,
37
+ body: {
38
+ token: token ?? void 0,
39
+ owner,
40
+ repository,
41
+ branch
42
+ }
43
+ });
44
+ /** Content of an Intlayer configuration file of a repository. */
45
+ const getConfigFile = async (token, owner, repository, branch = "main", path = "intlayer.config.ts", otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, group, forgeEndpoints.getConfigFile), authAPIOptions, otherOptions, {
46
+ method: forgeEndpoints.getConfigFile.method,
47
+ body: {
48
+ token: token ?? void 0,
49
+ owner,
50
+ repository,
51
+ branch,
52
+ path
53
+ }
54
+ });
55
+ return {
56
+ getRepositories,
57
+ checkIntlayerConfig,
58
+ getConfigFile
59
+ };
60
+ };
61
+
62
+ exports.createForgeAPI = createForgeAPI;
63
+ //# sourceMappingURL=forge.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forge.cjs","names":["editor","BACKEND_URL","fetcher","buildRouteURL"],"sources":["../../../src/getIntlayerAPI/forge.ts"],"sourcesContent":["import type {\n RouteEndpoints,\n RouteGroup,\n} from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n ForgeCheckConfigResult,\n ForgeGetConfigFileResult,\n ForgeListReposResult,\n ForgeRoutes,\n} from '@intlayer/backend-contract/gitProviders';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type {\n ForgeCheckConfigResult,\n ForgeGetConfigFileResult,\n ForgeListReposResult,\n ForgeRepository,\n} from '@intlayer/backend-contract/gitProviders';\n\n/**\n * Method and path of every route of a Gitea-compatible forge, checked\n * against the backend contract at compile time.\n */\nconst forgeEndpoints = {\n listRepos: { method: 'GET', path: '/repos' },\n checkConfig: { method: 'POST', path: '/check-config' },\n getConfigFile: { method: 'POST', path: '/get-config-file' },\n} as const satisfies RouteEndpoints<ForgeRoutes>;\n\n/**\n * Client of a Gitea-compatible forge (Codeberg, Gitee). Omitting `token` makes\n * the backend use the account linked to the session.\n */\nexport const createForgeAPI =\n <Prefix extends string>(\n group: Pick<RouteGroup<Prefix, ForgeRoutes>, 'prefix'>\n ) =>\n (authAPIOptions: FetcherOptions = {}, intlayerConfig?: IntlayerConfig) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /** Repositories of the linked account. */\n const getRepositories = async (\n token?: string | null,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ForgeListReposResult>(\n buildRouteURL(backendURL, group, forgeEndpoints.listRepos),\n authAPIOptions,\n otherOptions,\n { params: token ? { token } : undefined }\n );\n\n /** Paths of the Intlayer configuration files of a repository branch. */\n const checkIntlayerConfig = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ForgeCheckConfigResult>(\n buildRouteURL(backendURL, group, forgeEndpoints.checkConfig),\n authAPIOptions,\n otherOptions,\n {\n method: forgeEndpoints.checkConfig.method,\n body: { token: token ?? undefined, owner, repository, branch },\n }\n );\n\n /** Content of an Intlayer configuration file of a repository. */\n const getConfigFile = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n path: string = 'intlayer.config.ts',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ForgeGetConfigFileResult>(\n buildRouteURL(backendURL, group, forgeEndpoints.getConfigFile),\n authAPIOptions,\n otherOptions,\n {\n method: forgeEndpoints.getConfigFile.method,\n body: { token: token ?? undefined, owner, repository, branch, path },\n }\n );\n\n return { getRepositories, checkIntlayerConfig, getConfigFile };\n };\n"],"mappings":";;;;;;;;;;;AA2BA,MAAM,iBAAiB;CACrB,WAAW;EAAE,QAAQ;EAAO,MAAM;CAAS;CAC3C,aAAa;EAAE,QAAQ;EAAQ,MAAM;CAAgB;CACrD,eAAe;EAAE,QAAQ;EAAQ,MAAM;CAAmB;AAC5D;;;;;AAMA,MAAa,kBAET,WAED,iBAAiC,CAAC,GAAG,mBAAoC;CACxE,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,8BAAO,cAAcC;;CAG7D,MAAM,kBAAkB,OACtB,OACA,eAA+B,CAAC,MAEhC,MAAMC,4BACJC,sDAAc,YAAY,OAAO,eAAe,SAAS,GACzD,gBACA,cACA,EAAE,QAAQ,QAAQ,EAAE,MAAM,IAAI,OAAU,CAC1C;;CAGF,MAAM,sBAAsB,OAC1B,OACA,OACA,YACA,SAAiB,QACjB,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDAAc,YAAY,OAAO,eAAe,WAAW,GAC3D,gBACA,cACA;EACE,QAAQ,eAAe,YAAY;EACnC,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;EAAO;CAC/D,CACF;;CAGF,MAAM,gBAAgB,OACpB,OACA,OACA,YACA,SAAiB,QACjB,OAAe,sBACf,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDAAc,YAAY,OAAO,eAAe,aAAa,GAC7D,gBACA,cACA;EACE,QAAQ,eAAe,cAAc;EACrC,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;GAAQ;EAAK;CACrE,CACF;CAEF,OAAO;EAAE;EAAiB;EAAqB;CAAc;AAC/D"}
@@ -0,0 +1,20 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_cms_createIntlayerCMS = require("../cms/createIntlayerCMS.cjs");
3
+ const require_getIntlayerAPI_forge = require("./forge.cjs");
4
+
5
+ // src/getIntlayerAPI/gitee.ts
6
+ /** Prefix of the routes, checked against the backend contract. */
7
+ const giteeGroup = { prefix: "/api/gitee" };
8
+ /** Gitee repositories of the linked account. */
9
+ const getGiteeAPI = require_getIntlayerAPI_forge.createForgeAPI(giteeGroup);
10
+ /**
11
+ * Authenticated `gitee` endpoint bound to an Intlayer CMS authenticator.
12
+ *
13
+ * Pass an authenticator created with `createIntlayerCMS`, or omit it to use
14
+ * the build-time configuration (`@intlayer/config/built`).
15
+ */
16
+ const giteeEndpoint = require_cms_createIntlayerCMS.createEndpoint(getGiteeAPI);
17
+
18
+ exports.getGiteeAPI = getGiteeAPI;
19
+ exports.giteeEndpoint = giteeEndpoint;
20
+ //# sourceMappingURL=gitee.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitee.cjs","names":["createForgeAPI","createEndpoint"],"sources":["../../../src/getIntlayerAPI/gitee.ts"],"sourcesContent":["import type { giteeContract } from '@intlayer/backend-contract/gitProviders';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { createForgeAPI } from './forge';\n\n/** Prefix of the routes, checked against the backend contract. */\nconst giteeGroup = {\n prefix: '/api/gitee',\n} as const satisfies Pick<typeof giteeContract, 'prefix'>;\n\n/** Gitee repositories of the linked account. */\nexport const getGiteeAPI = createForgeAPI(giteeGroup);\n\n/**\n * Authenticated `gitee` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const giteeEndpoint = createEndpoint(getGiteeAPI);\n"],"mappings":";;;;;;AAKA,MAAM,aAAa,EACjB,QAAQ,aACV;;AAGA,MAAa,cAAcA,4CAAe,UAAU;;;;;;;AAQpD,MAAa,gBAAgBC,6CAAe,WAAW"}
@@ -1,29 +1,63 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_fetcher = require('../fetcher.cjs');
3
- const require_cms_createIntlayerCMS = require('../cms/createIntlayerCMS.cjs');
2
+ const require_cms_createIntlayerCMS = require("../cms/createIntlayerCMS.cjs");
3
+ const require_fetcher = require("../fetcher.cjs");
4
4
  let _intlayer_config_built = require("@intlayer/config/built");
5
+ let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
6
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
5
7
 
6
- //#region src/getIntlayerAPI/github.ts
8
+ // src/getIntlayerAPI/github.ts
9
+ /** Prefix of the routes, checked against the backend contract. */
10
+ const githubGroup = { prefix: "/api/github" };
11
+ /**
12
+ * Method and path of every route, checked against the backend contract at
13
+ * compile time (the contract's zod schemas are never loaded).
14
+ */
15
+ const githubEndpoints = {
16
+ getAuthUrl: {
17
+ method: "GET",
18
+ path: "/auth-url"
19
+ },
20
+ authCallback: {
21
+ method: "POST",
22
+ path: "/auth"
23
+ },
24
+ listRepos: {
25
+ method: "GET",
26
+ path: "/repos"
27
+ },
28
+ checkConfig: {
29
+ method: "POST",
30
+ path: "/check-config"
31
+ },
32
+ getConfigFile: {
33
+ method: "POST",
34
+ path: "/get-config-file"
35
+ },
36
+ getToken: {
37
+ method: "GET",
38
+ path: "/token"
39
+ }
40
+ };
7
41
  const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
8
- const GITHUB_API_ROUTE = `${intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL}/api/github`;
42
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
9
43
  /**
10
44
  * Get GitHub OAuth authorization URL
11
45
  * @param redirectUri - Redirect URI after OAuth authorization
12
46
  */
13
- const getAuthUrl = async (redirectUri, otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/auth-url`, authAPIOptions, otherOptions, { params: { redirectUri } });
47
+ const getAuthUrl = async (redirectUri, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, githubGroup, githubEndpoints.getAuthUrl), authAPIOptions, otherOptions, { params: { redirectUri } });
14
48
  /**
15
49
  * Exchange GitHub authorization code for access token
16
50
  * @param code - GitHub authorization code
17
51
  */
18
- const authenticate = async (code, otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/auth`, authAPIOptions, otherOptions, {
19
- method: "POST",
52
+ const authenticate = async (code, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, githubGroup, githubEndpoints.authCallback), authAPIOptions, otherOptions, {
53
+ method: githubEndpoints.authCallback.method,
20
54
  body: { code }
21
55
  });
22
56
  /**
23
57
  * Get user's GitHub repositories
24
58
  * @param token - Optional GitHub access token. If not provided, backend will use session.
25
59
  */
26
- const getRepositories = async (token, otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/repos`, authAPIOptions, otherOptions, { params: token ? { token } : void 0 });
60
+ const getRepositories = async (token, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, githubGroup, githubEndpoints.listRepos), authAPIOptions, otherOptions, { params: token ? { token } : void 0 });
27
61
  /**
28
62
  * Check if intlayer.config.ts exists in a repository
29
63
  * @param token - Optional GitHub access token. If not provided, backend will use session.
@@ -31,8 +65,8 @@ const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
31
65
  * @param repository - Repository name
32
66
  * @param branch - Branch name (default: 'main')
33
67
  */
34
- const checkIntlayerConfig = async (token, owner, repository, branch = "main", otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/check-config`, authAPIOptions, otherOptions, {
35
- method: "POST",
68
+ const checkIntlayerConfig = async (token, owner, repository, branch = "main", otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, githubGroup, githubEndpoints.checkConfig), authAPIOptions, otherOptions, {
69
+ method: githubEndpoints.checkConfig.method,
36
70
  body: {
37
71
  token: token ?? void 0,
38
72
  owner,
@@ -48,8 +82,8 @@ const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
48
82
  * @param branch - Branch name (default: 'main')
49
83
  * @param path - File path (default: 'intlayer.config.ts')
50
84
  */
51
- const getConfigFile = async (token, owner, repository, branch = "main", path = "intlayer.config.ts", otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/get-config-file`, authAPIOptions, otherOptions, {
52
- method: "POST",
85
+ const getConfigFile = async (token, owner, repository, branch = "main", path = "intlayer.config.ts", otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, githubGroup, githubEndpoints.getConfigFile), authAPIOptions, otherOptions, {
86
+ method: githubEndpoints.getConfigFile.method,
53
87
  body: {
54
88
  token: token ?? void 0,
55
89
  owner,
@@ -61,7 +95,7 @@ const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
61
95
  /**
62
96
  * Get user's GitHub token
63
97
  */
64
- const getToken = async (otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/token`, authAPIOptions, otherOptions);
98
+ const getToken = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, githubGroup, githubEndpoints.getToken), authAPIOptions, otherOptions);
65
99
  return {
66
100
  getAuthUrl,
67
101
  authenticate,
@@ -79,7 +113,6 @@ const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
79
113
  */
80
114
  const githubEndpoint = require_cms_createIntlayerCMS.createEndpoint(getGithubAPI);
81
115
 
82
- //#endregion
83
116
  exports.getGithubAPI = getGithubAPI;
84
117
  exports.githubEndpoint = githubEndpoint;
85
118
  //# sourceMappingURL=github.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"github.cjs","names":["editor","fetcher","createEndpoint"],"sources":["../../../src/getIntlayerAPI/github.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type GitHubRepository = {\n id: number;\n name: string;\n full_name: string;\n owner: {\n login: string;\n id: number;\n };\n html_url: string;\n default_branch: string;\n private: boolean;\n};\n\nexport type GitHubAuthCallbackBody = {\n code: string;\n};\n\nexport type GitHubAuthCallbackResult = {\n data: {\n token: string;\n };\n};\n\nexport type GitHubListReposResult = {\n data: GitHubRepository[];\n};\n\nexport type GitHubCheckConfigBody = {\n token?: string;\n owner: string;\n repository: string;\n branch?: string;\n};\n\nexport type GitHubCheckConfigResult = {\n data: {\n hasConfig: boolean;\n };\n};\n\nexport type GitHubGetConfigFileBody = {\n token?: string;\n owner: string;\n repository: string;\n branch?: string;\n path?: string;\n};\n\nexport type GitHubGetConfigFileResult = {\n data: {\n content: string;\n };\n};\n\nexport type GitHubGetAuthUrlResult = {\n data: {\n authUrl: string;\n };\n};\n\nexport type GitHubGetTokenResult = {\n data: {\n token: string;\n };\n};\n\nexport const getGithubAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const GITHUB_API_ROUTE = `${backendURL}/api/github`;\n\n /**\n * Get GitHub OAuth authorization URL\n * @param redirectUri - Redirect URI after OAuth authorization\n */\n const getAuthUrl = async (\n redirectUri: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubGetAuthUrlResult>(\n `${GITHUB_API_ROUTE}/auth-url`,\n authAPIOptions,\n otherOptions,\n {\n params: { redirectUri },\n }\n );\n\n /**\n * Exchange GitHub authorization code for access token\n * @param code - GitHub authorization code\n */\n const authenticate = async (\n code: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubAuthCallbackResult>(\n `${GITHUB_API_ROUTE}/auth`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { code },\n }\n );\n\n /**\n * Get user's GitHub repositories\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n */\n const getRepositories = async (\n token?: string | null,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubListReposResult>(\n `${GITHUB_API_ROUTE}/repos`,\n authAPIOptions,\n otherOptions,\n {\n params: token ? { token } : undefined,\n }\n );\n\n /**\n * Check if intlayer.config.ts exists in a repository\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n * @param owner - Repository owner\n * @param repository - Repository name\n * @param branch - Branch name (default: 'main')\n */\n const checkIntlayerConfig = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubCheckConfigResult>(\n `${GITHUB_API_ROUTE}/check-config`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { token: token ?? undefined, owner, repository, branch },\n }\n );\n\n /**\n * Get intlayer.config.ts file contents from a repository\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n * @param owner - Repository owner\n * @param repository - Repository name\n * @param branch - Branch name (default: 'main')\n * @param path - File path (default: 'intlayer.config.ts')\n */\n const getConfigFile = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n path: string = 'intlayer.config.ts',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubGetConfigFileResult>(\n `${GITHUB_API_ROUTE}/get-config-file`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { token: token ?? undefined, owner, repository, branch, path },\n }\n );\n\n /**\n * Get user's GitHub token\n */\n const getToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GitHubGetTokenResult>(\n `${GITHUB_API_ROUTE}/token`,\n authAPIOptions,\n otherOptions\n );\n\n return {\n getAuthUrl,\n authenticate,\n getRepositories,\n checkIntlayerConfig,\n getConfigFile,\n getToken,\n };\n};\n\n/**\n * Authenticated `github` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const githubEndpoint = createEndpoint(getGithubAPI);\n"],"mappings":";;;;;;AAuEA,MAAa,gBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,mBAAmB,GAFN,gBAAgB,QAAQ,cAAcA,8BAAO,WAEzB;;;;;CAMvC,MAAM,aAAa,OACjB,aACA,eAA+B,CAAC,MAEhC,MAAMC,wBACJ,GAAG,iBAAiB,YACpB,gBACA,cACA,EACE,QAAQ,EAAE,YAAY,EACxB,CACF;;;;;CAMF,MAAM,eAAe,OACnB,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,iBAAiB,QACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,KAAK;CACf,CACF;;;;;CAMF,MAAM,kBAAkB,OACtB,OACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,iBAAiB,SACpB,gBACA,cACA,EACE,QAAQ,QAAQ,EAAE,MAAM,IAAI,OAC9B,CACF;;;;;;;;CASF,MAAM,sBAAsB,OAC1B,OACA,OACA,YACA,SAAiB,QACjB,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,iBAAiB,gBACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;EAAO;CAC/D,CACF;;;;;;;;;CAUF,MAAM,gBAAgB,OACpB,OACA,OACA,YACA,SAAiB,QACjB,OAAe,sBACf,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,iBAAiB,mBACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;GAAQ;EAAK;CACrE,CACF;;;;CAKF,MAAM,WAAW,OAAO,eAA+B,CAAC,MACtD,MAAMA,wBACJ,GAAG,iBAAiB,SACpB,gBACA,YACF;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,iBAAiBC,6CAAe,YAAY"}
1
+ {"version":3,"file":"github.cjs","names":["editor","BACKEND_URL","fetcher","buildRouteURL","createEndpoint"],"sources":["../../../src/getIntlayerAPI/github.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n GitHubRoutes,\n githubContract,\n} from '@intlayer/backend-contract/gitProviders';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type GitHubRepository = {\n id: number;\n name: string;\n full_name: string;\n owner: {\n login: string;\n id: number;\n };\n html_url: string;\n default_branch: string;\n private: boolean;\n};\n\nexport type GitHubAuthCallbackBody = {\n code: string;\n};\n\nexport type GitHubAuthCallbackResult = {\n data: {\n token: string;\n };\n};\n\nexport type GitHubListReposResult = {\n data: GitHubRepository[];\n};\n\nexport type GitHubCheckConfigBody = {\n token?: string;\n owner: string;\n repository: string;\n branch?: string;\n};\n\nexport type GitHubCheckConfigResult = {\n data: {\n hasConfig: boolean;\n };\n};\n\nexport type GitHubGetConfigFileBody = {\n token?: string;\n owner: string;\n repository: string;\n branch?: string;\n path?: string;\n};\n\nexport type GitHubGetConfigFileResult = {\n data: {\n content: string;\n };\n};\n\nexport type GitHubGetAuthUrlResult = {\n data: {\n authUrl: string;\n };\n};\n\nexport type GitHubGetTokenResult = {\n data: {\n token: string;\n };\n};\n\n/** Prefix of the routes, checked against the backend contract. */\nconst githubGroup = {\n prefix: '/api/github',\n} as const satisfies Pick<typeof githubContract, 'prefix'>;\n\n/**\n * Method and path of every route, checked against the backend contract at\n * compile time (the contract's zod schemas are never loaded).\n */\nconst githubEndpoints = {\n getAuthUrl: { method: 'GET', path: '/auth-url' },\n authCallback: { method: 'POST', path: '/auth' },\n listRepos: { method: 'GET', path: '/repos' },\n checkConfig: { method: 'POST', path: '/check-config' },\n getConfigFile: { method: 'POST', path: '/get-config-file' },\n getToken: { method: 'GET', path: '/token' },\n} as const satisfies RouteEndpoints<GitHubRoutes>;\n\nexport const getGithubAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /**\n * Get GitHub OAuth authorization URL\n * @param redirectUri - Redirect URI after OAuth authorization\n */\n const getAuthUrl = async (\n redirectUri: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubGetAuthUrlResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.getAuthUrl),\n authAPIOptions,\n otherOptions,\n {\n params: { redirectUri },\n }\n );\n\n /**\n * Exchange GitHub authorization code for access token\n * @param code - GitHub authorization code\n */\n const authenticate = async (\n code: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubAuthCallbackResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.authCallback),\n authAPIOptions,\n otherOptions,\n {\n method: githubEndpoints.authCallback.method,\n body: { code },\n }\n );\n\n /**\n * Get user's GitHub repositories\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n */\n const getRepositories = async (\n token?: string | null,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubListReposResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.listRepos),\n authAPIOptions,\n otherOptions,\n {\n params: token ? { token } : undefined,\n }\n );\n\n /**\n * Check if intlayer.config.ts exists in a repository\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n * @param owner - Repository owner\n * @param repository - Repository name\n * @param branch - Branch name (default: 'main')\n */\n const checkIntlayerConfig = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubCheckConfigResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.checkConfig),\n authAPIOptions,\n otherOptions,\n {\n method: githubEndpoints.checkConfig.method,\n body: { token: token ?? undefined, owner, repository, branch },\n }\n );\n\n /**\n * Get intlayer.config.ts file contents from a repository\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n * @param owner - Repository owner\n * @param repository - Repository name\n * @param branch - Branch name (default: 'main')\n * @param path - File path (default: 'intlayer.config.ts')\n */\n const getConfigFile = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n path: string = 'intlayer.config.ts',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubGetConfigFileResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.getConfigFile),\n authAPIOptions,\n otherOptions,\n {\n method: githubEndpoints.getConfigFile.method,\n body: { token: token ?? undefined, owner, repository, branch, path },\n }\n );\n\n /**\n * Get user's GitHub token\n */\n const getToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GitHubGetTokenResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.getToken),\n authAPIOptions,\n otherOptions\n );\n\n return {\n getAuthUrl,\n authenticate,\n getRepositories,\n checkIntlayerConfig,\n getConfigFile,\n getToken,\n };\n};\n\n/**\n * Authenticated `github` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const githubEndpoint = createEndpoint(getGithubAPI);\n"],"mappings":";;;;;;;;;AA+EA,MAAM,cAAc,EAClB,QAAQ,cACV;;;;;AAMA,MAAM,kBAAkB;CACtB,YAAY;EAAE,QAAQ;EAAO,MAAM;CAAY;CAC/C,cAAc;EAAE,QAAQ;EAAQ,MAAM;CAAQ;CAC9C,WAAW;EAAE,QAAQ;EAAO,MAAM;CAAS;CAC3C,aAAa;EAAE,QAAQ;EAAQ,MAAM;CAAgB;CACrD,eAAe;EAAE,QAAQ;EAAQ,MAAM;CAAmB;CAC1D,UAAU;EAAE,QAAQ;EAAO,MAAM;CAAS;AAC5C;AAEA,MAAa,gBACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,8BAAO,cAAcC;;;;;CAM7D,MAAM,aAAa,OACjB,aACA,eAA+B,CAAC,MAEhC,MAAMC,4BACJC,sDAAc,YAAY,aAAa,gBAAgB,UAAU,GACjE,gBACA,cACA,EACE,QAAQ,EAAE,YAAY,EACxB,CACF;;;;;CAMF,MAAM,eAAe,OACnB,MACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDAAc,YAAY,aAAa,gBAAgB,YAAY,GACnE,gBACA,cACA;EACE,QAAQ,gBAAgB,aAAa;EACrC,MAAM,EAAE,KAAK;CACf,CACF;;;;;CAMF,MAAM,kBAAkB,OACtB,OACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDAAc,YAAY,aAAa,gBAAgB,SAAS,GAChE,gBACA,cACA,EACE,QAAQ,QAAQ,EAAE,MAAM,IAAI,OAC9B,CACF;;;;;;;;CASF,MAAM,sBAAsB,OAC1B,OACA,OACA,YACA,SAAiB,QACjB,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDAAc,YAAY,aAAa,gBAAgB,WAAW,GAClE,gBACA,cACA;EACE,QAAQ,gBAAgB,YAAY;EACpC,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;EAAO;CAC/D,CACF;;;;;;;;;CAUF,MAAM,gBAAgB,OACpB,OACA,OACA,YACA,SAAiB,QACjB,OAAe,sBACf,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDAAc,YAAY,aAAa,gBAAgB,aAAa,GACpE,gBACA,cACA;EACE,QAAQ,gBAAgB,cAAc;EACtC,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;GAAQ;EAAK;CACrE,CACF;;;;CAKF,MAAM,WAAW,OAAO,eAA+B,CAAC,MACtD,MAAMD,4BACJC,sDAAc,YAAY,aAAa,gBAAgB,QAAQ,GAC/D,gBACA,YACF;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,iBAAiBC,6CAAe,YAAY"}