@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,16 +1,99 @@
1
- import { fetcher } from "../fetcher.mjs";
2
1
  import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
2
+ import { fetcher } from "../fetcher.mjs";
3
3
  import { editor } from "@intlayer/config/built";
4
+ import { buildRouteURL } from "@intlayer/backend-contract/defineRoute";
5
+ import { BACKEND_URL } from "@intlayer/config/defaultValues";
4
6
 
5
- //#region src/getIntlayerAPI/project.ts
7
+ // src/getIntlayerAPI/project.ts
8
+ /** Prefix of the project routes, checked against the backend contract. */
9
+ const projectGroup = { prefix: "/api/project" };
10
+ /**
11
+ * Method and path of every project route, checked against the backend
12
+ * contract at compile time (the contract's zod schemas are never loaded).
13
+ */
14
+ const projectEndpoints = {
15
+ getProjects: {
16
+ method: "GET",
17
+ path: "/"
18
+ },
19
+ getProjectInsights: {
20
+ method: "GET",
21
+ path: "/insights"
22
+ },
23
+ addProject: {
24
+ method: "POST",
25
+ path: "/"
26
+ },
27
+ updateProject: {
28
+ method: "PUT",
29
+ path: "/"
30
+ },
31
+ updateProjectMembers: {
32
+ method: "PUT",
33
+ path: "/members"
34
+ },
35
+ pushProjectConfiguration: {
36
+ method: "PUT",
37
+ path: "/configuration"
38
+ },
39
+ deleteProject: {
40
+ method: "DELETE",
41
+ path: "/"
42
+ },
43
+ selectProject: {
44
+ method: "PUT",
45
+ path: "/:projectId"
46
+ },
47
+ unselectProject: {
48
+ method: "POST",
49
+ path: "/logout"
50
+ },
51
+ addNewAccessKey: {
52
+ method: "POST",
53
+ path: "/access_key"
54
+ },
55
+ refreshAccessKey: {
56
+ method: "PATCH",
57
+ path: "/access_key"
58
+ },
59
+ deleteAccessKey: {
60
+ method: "DELETE",
61
+ path: "/access_key"
62
+ },
63
+ triggerBuild: {
64
+ method: "POST",
65
+ path: "/build"
66
+ },
67
+ triggerWebhook: {
68
+ method: "POST",
69
+ path: "/webhook"
70
+ },
71
+ getCIConfiguration: {
72
+ method: "GET",
73
+ path: "/ci"
74
+ },
75
+ pushCIConfiguration: {
76
+ method: "POST",
77
+ path: "/ci"
78
+ },
79
+ deleteProjectByIdAdmin: {
80
+ method: "DELETE",
81
+ path: "/:projectId/admin"
82
+ },
83
+ updateMemberAccess: {
84
+ method: "PUT",
85
+ path: "/member/:userId/access"
86
+ }
87
+ };
6
88
  const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
7
- const PROJECT_API_ROUTE = `${intlayerConfig?.editor?.backendURL ?? editor.backendURL}/api/project`;
89
+ const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;
8
90
  /**
9
91
  * Retrieves a list of projects based on filters and pagination.
10
92
  * @param filters - Filters and pagination options.
11
93
  */
12
- const getProjects = async (filters, otherOptions = {}) => await fetcher(PROJECT_API_ROUTE, authAPIOptions, otherOptions, {
94
+ const getProjects = async (filters, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.getProjects), authAPIOptions, otherOptions, {
13
95
  cache: "no-store",
96
+ method: projectEndpoints.getProjects.method,
14
97
  params: filters
15
98
  });
16
99
  /**
@@ -18,69 +101,69 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
18
101
  * project (locale/key counts, per-locale completion, missing translations,
19
102
  * recent activity, team/config status).
20
103
  */
21
- const getProjectInsights = async (otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/insights`, authAPIOptions, otherOptions, {
104
+ const getProjectInsights = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.getProjectInsights), authAPIOptions, otherOptions, {
22
105
  cache: "no-store",
23
- method: "GET"
106
+ method: projectEndpoints.getProjectInsights.method
24
107
  });
25
108
  /**
26
109
  * Adds a new project to the database.
27
110
  * @param project - Project data.
28
111
  */
29
- const addProject = async (project, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
30
- method: "POST",
112
+ const addProject = async (project, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.addProject), authAPIOptions, otherOptions, {
113
+ method: projectEndpoints.addProject.method,
31
114
  body: project
32
115
  });
33
116
  /**
34
117
  * Updates an existing project in the database.
35
118
  * @param project - Updated project data.
36
119
  */
37
- const updateProject = async (project, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
38
- method: "PUT",
120
+ const updateProject = async (project, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.updateProject), authAPIOptions, otherOptions, {
121
+ method: projectEndpoints.updateProject.method,
39
122
  body: project
40
123
  });
41
124
  /**
42
125
  * Updates project members in the database.
43
126
  * @param project - Updated project data.
44
127
  */
45
- const updateProjectMembers = async (body, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/members`, authAPIOptions, otherOptions, {
46
- method: "PUT",
128
+ const updateProjectMembers = async (body, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.updateProjectMembers), authAPIOptions, otherOptions, {
129
+ method: projectEndpoints.updateProjectMembers.method,
47
130
  body
48
131
  });
49
132
  /** Pushes a project configuration to the database.
50
133
  * @param projectConfiguration - Project configuration data.
51
134
  */
52
- const pushProjectConfiguration = async (projectConfiguration, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/configuration`, authAPIOptions, otherOptions, {
53
- method: "PUT",
135
+ const pushProjectConfiguration = async (projectConfiguration, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.pushProjectConfiguration), authAPIOptions, otherOptions, {
136
+ method: projectEndpoints.pushProjectConfiguration.method,
54
137
  body: projectConfiguration
55
138
  });
56
139
  /**
57
140
  * Deletes a project from the database by its ID.
58
141
  * @param id - Project ID.
59
142
  */
60
- const deleteProject = async (otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, { method: "DELETE" });
143
+ const deleteProject = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.deleteProject), authAPIOptions, otherOptions, { method: projectEndpoints.deleteProject.method });
61
144
  /**
62
145
  * Admin-only: Deletes any project from the database by its ID.
63
146
  * @param projectId - Project ID.
64
147
  */
65
- const deleteProjectByIdAdmin = async (projectId, otherOptions = {}) => fetcher(`${PROJECT_API_ROUTE}/${projectId}/admin`, authAPIOptions, otherOptions, { method: "DELETE" });
148
+ const deleteProjectByIdAdmin = async (projectId, otherOptions = {}) => fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.deleteProjectByIdAdmin, { projectId }), authAPIOptions, otherOptions, { method: projectEndpoints.deleteProjectByIdAdmin.method });
66
149
  /**
67
150
  * Select a project from the database by its ID.
68
151
  * @param projectId - Organization ID.
69
152
  */
70
- const selectProject = async (projectId, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/${String(projectId)}`, authAPIOptions, otherOptions, { method: "PUT" });
153
+ const selectProject = async (projectId, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.selectProject, { projectId: String(projectId) }), authAPIOptions, otherOptions, { method: projectEndpoints.selectProject.method });
71
154
  /**
72
155
  * Unselect a project from the database by its ID.
73
156
  * @param projectId - Project ID.
74
157
  */
75
- const unselectProject = async (otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/logout`, authAPIOptions, otherOptions, { method: "POST" });
158
+ const unselectProject = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.unselectProject), authAPIOptions, otherOptions, { method: projectEndpoints.unselectProject.method });
76
159
  /**
77
160
  * Add a new access key to a project.
78
161
  * @param accessKey - Access key data.
79
162
  * @param otherOptions - Fetcher options.
80
163
  * @returns The new access key.
81
164
  */
82
- const addNewAccessKey = async (accessKey, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/access_key`, authAPIOptions, otherOptions, {
83
- method: "POST",
165
+ const addNewAccessKey = async (accessKey, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.addNewAccessKey), authAPIOptions, otherOptions, {
166
+ method: projectEndpoints.addNewAccessKey.method,
84
167
  body: accessKey
85
168
  });
86
169
  /**
@@ -89,8 +172,8 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
89
172
  * @param otherOptions - Fetcher options.
90
173
  * @returns The deleted project.
91
174
  */
92
- const deleteAccessKey = async (clientId, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/access_key`, authAPIOptions, otherOptions, {
93
- method: "DELETE",
175
+ const deleteAccessKey = async (clientId, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.deleteAccessKey), authAPIOptions, otherOptions, {
176
+ method: projectEndpoints.deleteAccessKey.method,
94
177
  body: { clientId }
95
178
  });
96
179
  /**
@@ -99,8 +182,8 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
99
182
  * @param projectId - The ID of the project to refresh the access key from.
100
183
  * @returns The new access key.
101
184
  */
102
- const refreshAccessKey = async (clientId, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/access_key`, authAPIOptions, otherOptions, {
103
- method: "PATCH",
185
+ const refreshAccessKey = async (clientId, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.refreshAccessKey), authAPIOptions, otherOptions, {
186
+ method: projectEndpoints.refreshAccessKey.method,
104
187
  body: { clientId }
105
188
  });
106
189
  /**
@@ -108,15 +191,15 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
108
191
  * @param otherOptions - Fetcher options.
109
192
  * @returns The trigger results.
110
193
  */
111
- const triggerBuild = async (otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/build`, authAPIOptions, otherOptions, { method: "POST" });
194
+ const triggerBuild = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.triggerBuild), authAPIOptions, otherOptions, { method: projectEndpoints.triggerBuild.method });
112
195
  /**
113
196
  * Triggers a single webhook by index.
114
197
  * @param webhookIndex - The index of the webhook to trigger.
115
198
  * @param otherOptions - Fetcher options.
116
199
  * @returns The trigger result.
117
200
  */
118
- const triggerWebhook = async (webhookIndex, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/webhook`, authAPIOptions, otherOptions, {
119
- method: "POST",
201
+ const triggerWebhook = async (webhookIndex, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.triggerWebhook), authAPIOptions, otherOptions, {
202
+ method: projectEndpoints.triggerWebhook.method,
120
203
  body: { webhookIndex }
121
204
  });
122
205
  /**
@@ -124,20 +207,20 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
124
207
  * @param otherOptions - Fetcher options.
125
208
  * @returns The CI configuration status.
126
209
  */
127
- const getCIConfig = async (otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/ci`, authAPIOptions, otherOptions, { method: "GET" });
210
+ const getCIConfig = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.getCIConfiguration), authAPIOptions, otherOptions, { method: projectEndpoints.getCIConfiguration.method });
128
211
  /**
129
212
  * Push CI configuration file to the repository.
130
213
  * @param otherOptions - Fetcher options.
131
214
  * @returns Success status.
132
215
  */
133
- const pushCIConfig = async (otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/ci`, authAPIOptions, otherOptions, { method: "POST" });
216
+ const pushCIConfig = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.pushCIConfiguration), authAPIOptions, otherOptions, { method: projectEndpoints.pushCIConfiguration.method });
134
217
  /**
135
218
  * Updates granular access constraints for a project member.
136
219
  * @param userId - The user ID to update access for.
137
220
  * @param body - The new access constraints.
138
221
  */
139
- const updateMemberAccess = async (userId, body, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/member/${userId}/access`, authAPIOptions, otherOptions, {
140
- method: "PUT",
222
+ const updateMemberAccess = async (userId, body, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.updateMemberAccess, { userId }), authAPIOptions, otherOptions, {
223
+ method: projectEndpoints.updateMemberAccess.method,
141
224
  body
142
225
  });
143
226
  return {
@@ -169,6 +252,5 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
169
252
  */
170
253
  const projectEndpoint = createEndpoint(getProjectAPI);
171
254
 
172
- //#endregion
173
255
  export { getProjectAPI, projectEndpoint };
174
256
  //# sourceMappingURL=project.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"project.mjs","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectInsightsResult,\n GetProjectsParams,\n GetProjectsResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n ResponseData,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateMemberAccessBody,\n UpdateMemberAccessResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\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 getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\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 aggregated localization insights for the currently selected\n * project (locale/key counts, per-locale completion, missing translations,\n * recent activity, team/config status).\n */\n const getProjectInsights = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetProjectInsightsResult>(\n `${PROJECT_API_ROUTE}/insights`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n method: 'GET',\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Admin-only: Deletes any project from the database by its ID.\n * @param projectId - Project ID.\n */\n const deleteProjectByIdAdmin = async (\n projectId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}/${projectId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Updates granular access constraints for a project member.\n * @param userId - The user ID to update access for.\n * @param body - The new access constraints.\n */\n const updateMemberAccess = async (\n userId: string,\n body: UpdateMemberAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateMemberAccessResult>(\n `${PROJECT_API_ROUTE}/member/${userId}/access`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n return {\n getProjects,\n getProjectInsights,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n deleteProjectByIdAdmin,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n updateMemberAccess,\n };\n};\n\n/**\n * Authenticated `project` 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 projectEndpoint = createEndpoint(getProjectAPI);\n"],"mappings":";;;;;AAkCA,MAAa,iBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,oBAAoB,GAFP,gBAAgB,QAAQ,cAAc,OAAO,WAExB;;;;;CAMxC,MAAM,cAAc,OAClB,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;;;CAOF,MAAM,qBAAqB,OAAO,eAA+B,CAAC,MAChE,MAAM,QACJ,GAAG,kBAAkB,YACrB,gBACA,cACA;EACE,OAAO;EACP,QAAQ;CACV,CACF;;;;;CAMF,MAAM,aAAa,OACjB,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,gBAAgB,OACpB,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,uBAAuB,OAC3B,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR;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CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,aAAa;CACvB,CACF;;;;;;CAOF,MAAM,cAAc,OAAO,eAA+B,CAAC,MACzD,MAAM,QACJ,GAAG,kBAAkB,MACrB,gBACA,cACA,EACE,QAAQ,MACV,CACF;;;;;;CAOF,MAAM,eAAe,OAAO,eAA+B,CAAC,MAC1D,MAAM,QACJ,GAAG,kBAAkB,MACrB,gBACA,cACA,EACE,QAAQ,OACV,CACF;;;;;;CAOF,MAAM,qBAAqB,OACzB,QACA,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,UAAU,OAAO,UACtC,gBACA,cACA;EAAE,QAAQ;EAAO;CAAK,CACxB;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,kBAAkB,eAAe,aAAa"}
1
+ {"version":3,"file":"project.mjs","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectInsightsResult,\n GetProjectsParams,\n GetProjectsResult,\n ProjectRoutes,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n projectContract,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateMemberAccessBody,\n UpdateMemberAccessResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '@intlayer/backend-contract/project';\nimport type { ResponseData } from '@intlayer/backend-contract/responseData';\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 project routes, checked against the backend contract. */\nconst projectGroup = {\n prefix: '/api/project',\n} as const satisfies Pick<typeof projectContract, 'prefix'>;\n\n/**\n * Method and path of every project route, checked against the backend\n * contract at compile time (the contract's zod schemas are never loaded).\n */\nconst projectEndpoints = {\n getProjects: { method: 'GET', path: '/' },\n getProjectInsights: { method: 'GET', path: '/insights' },\n addProject: { method: 'POST', path: '/' },\n updateProject: { method: 'PUT', path: '/' },\n updateProjectMembers: { method: 'PUT', path: '/members' },\n pushProjectConfiguration: { method: 'PUT', path: '/configuration' },\n deleteProject: { method: 'DELETE', path: '/' },\n selectProject: { method: 'PUT', path: '/:projectId' },\n unselectProject: { method: 'POST', path: '/logout' },\n addNewAccessKey: { method: 'POST', path: '/access_key' },\n refreshAccessKey: { method: 'PATCH', path: '/access_key' },\n deleteAccessKey: { method: 'DELETE', path: '/access_key' },\n triggerBuild: { method: 'POST', path: '/build' },\n triggerWebhook: { method: 'POST', path: '/webhook' },\n getCIConfiguration: { method: 'GET', path: '/ci' },\n pushCIConfiguration: { method: 'POST', path: '/ci' },\n deleteProjectByIdAdmin: { method: 'DELETE', path: '/:projectId/admin' },\n updateMemberAccess: { method: 'PUT', path: '/member/:userId/access' },\n} as const satisfies RouteEndpoints<ProjectRoutes>;\n\nexport const getProjectAPI = (\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 projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.getProjects),\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n method: projectEndpoints.getProjects.method,\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves aggregated localization insights for the currently selected\n * project (locale/key counts, per-locale completion, missing translations,\n * recent activity, team/config status).\n */\n const getProjectInsights = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetProjectInsightsResult>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.getProjectInsights\n ),\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n method: projectEndpoints.getProjectInsights.method,\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.addProject),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.addProject.method,\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.updateProject),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.updateProject.method,\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.updateProjectMembers\n ),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.updateProjectMembers.method,\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.pushProjectConfiguration\n ),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.pushProjectConfiguration.method,\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.deleteProject),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.deleteProject.method,\n }\n );\n\n /**\n * Admin-only: Deletes any project from the database by its ID.\n * @param projectId - Project ID.\n */\n const deleteProjectByIdAdmin = async (\n projectId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteProjectResult>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.deleteProjectByIdAdmin,\n { projectId }\n ),\n authAPIOptions,\n otherOptions,\n { method: projectEndpoints.deleteProjectByIdAdmin.method }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.selectProject, {\n projectId: String(projectId),\n }),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.selectProject.method,\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.unselectProject),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.unselectProject.method,\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.addNewAccessKey),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.addNewAccessKey.method,\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.deleteAccessKey),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.deleteAccessKey.method,\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.refreshAccessKey\n ),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.refreshAccessKey.method,\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.triggerBuild),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.triggerBuild.method,\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.triggerWebhook),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.triggerWebhook.method,\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.getCIConfiguration\n ),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.getCIConfiguration.method,\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.pushCIConfiguration\n ),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.pushCIConfiguration.method,\n }\n );\n\n /**\n * Updates granular access constraints for a project member.\n * @param userId - The user ID to update access for.\n * @param body - The new access constraints.\n */\n const updateMemberAccess = async (\n userId: string,\n body: UpdateMemberAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateMemberAccessResult>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.updateMemberAccess,\n { userId }\n ),\n authAPIOptions,\n otherOptions,\n { method: projectEndpoints.updateMemberAccess.method, body }\n );\n\n return {\n getProjects,\n getProjectInsights,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n deleteProjectByIdAdmin,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n updateMemberAccess,\n };\n};\n\n/**\n * Authenticated `project` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createI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AiB,kBACnB,GACA,gBACA,cACA,EACE,QAAQ,iBAAiB,mBAAmB,OAC9C,CACF;;;;;;CAOF,MAAM,eAAe,OAAO,eAA+B,CAAC,MAC1D,MAAM,QACJ,cACE,YACA,cACA,iBAAiB,mBACnB,GACA,gBACA,cACA,EACE,QAAQ,iBAAiB,oBAAoB,OAC/C,CACF;;;;;;CAOF,MAAM,qBAAqB,OACzB,QACA,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cACE,YACA,cACA,iBAAiB,oBACjB,EAAE,OAAO,CACX,GACA,gBACA,cACA;EAAE,QAAQ,iBAAiB,mBAAmB;EAAQ;CAAK,CAC7D;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,kBAAkB,eAAe,aAAa"}
@@ -1,10 +1,120 @@
1
- import { fetcher } from "../fetcher.mjs";
2
1
  import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
2
+ import { fetcher } from "../fetcher.mjs";
3
3
  import { editor } from "@intlayer/config/built";
4
+ import { buildRouteURL } from "@intlayer/backend-contract/defineRoute";
5
+ import { BACKEND_URL } from "@intlayer/config/defaultValues";
4
6
 
5
- //#region src/getIntlayerAPI/reviewer.ts
7
+ // src/getIntlayerAPI/reviewer.ts
8
+ /** Prefix of the routes, checked against the backend contract. */
9
+ const reviewerGroup = { prefix: "/api/reviewer" };
10
+ /**
11
+ * Method and path of every route, checked against the backend contract at
12
+ * compile time (the contract's zod schemas are never loaded).
13
+ */
14
+ const reviewerEndpoints = {
15
+ getMarketplace: {
16
+ method: "GET",
17
+ path: "/marketplace"
18
+ },
19
+ getPriceDistribution: {
20
+ method: "GET",
21
+ path: "/marketplace/price-distribution"
22
+ },
23
+ getMyReviewerProfile: {
24
+ method: "GET",
25
+ path: "/me"
26
+ },
27
+ getReviewerReviews: {
28
+ method: "GET",
29
+ path: "/:reviewerId/reviews"
30
+ },
31
+ getReviewerById: {
32
+ method: "GET",
33
+ path: "/:reviewerId"
34
+ },
35
+ registerAsReviewer: {
36
+ method: "POST",
37
+ path: "/register"
38
+ },
39
+ updateReviewerProfile: {
40
+ method: "PUT",
41
+ path: "/"
42
+ },
43
+ deleteReviewerProfile: {
44
+ method: "DELETE",
45
+ path: "/"
46
+ },
47
+ uploadMainPicture: {
48
+ method: "POST",
49
+ path: "/me/picture/main"
50
+ },
51
+ uploadCoverPicture: {
52
+ method: "POST",
53
+ path: "/me/picture/cover"
54
+ },
55
+ estimateMission: {
56
+ method: "POST",
57
+ path: "/mission/estimate"
58
+ },
59
+ createMission: {
60
+ method: "POST",
61
+ path: "/mission"
62
+ },
63
+ getMyMissions: {
64
+ method: "GET",
65
+ path: "/mission"
66
+ },
67
+ getMissionById: {
68
+ method: "GET",
69
+ path: "/mission/:missionId"
70
+ },
71
+ updateMissionStatus: {
72
+ method: "PUT",
73
+ path: "/mission/:missionId/status"
74
+ },
75
+ submitReview: {
76
+ method: "POST",
77
+ path: "/mission/:missionId/review"
78
+ },
79
+ getChatHistory: {
80
+ method: "GET",
81
+ path: "/mission/:missionId/chat/history"
82
+ },
83
+ sendMessage: {
84
+ method: "POST",
85
+ path: "/mission/:missionId/chat"
86
+ },
87
+ chatSSE: {
88
+ method: "GET",
89
+ path: "/mission/:missionId/chat/stream"
90
+ },
91
+ createPaymentIntent: {
92
+ method: "POST",
93
+ path: "/mission/:missionId/payment/intent"
94
+ },
95
+ confirmPayment: {
96
+ method: "POST",
97
+ path: "/mission/:missionId/payment/confirm"
98
+ },
99
+ requestPayout: {
100
+ method: "POST",
101
+ path: "/payout"
102
+ },
103
+ contactReviewer: {
104
+ method: "POST",
105
+ path: "/:reviewerId/contact"
106
+ },
107
+ getAdminReviewers: {
108
+ method: "GET",
109
+ path: "/admin/reviewers"
110
+ },
111
+ validateReviewerProfile: {
112
+ method: "PUT",
113
+ path: "/:reviewerId/validate"
114
+ }
115
+ };
6
116
  const getReviewerAPI = (authAPIOptions = {}, intlayerConfig) => {
7
- const BASE = `${intlayerConfig?.editor?.backendURL ?? editor.backendURL}/api/reviewer`;
117
+ const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;
8
118
  const getMarketplace = (params = {}, otherOptions = {}) => {
9
119
  const searchParams = new URLSearchParams();
10
120
  for (const [key, value] of Object.entries(params)) {
@@ -15,7 +125,7 @@ const getReviewerAPI = (authAPIOptions = {}, intlayerConfig) => {
15
125
  else searchParams.append(key, String(value));
16
126
  }
17
127
  const query = searchParams.toString();
18
- return fetcher(`${BASE}/marketplace${query ? `?${query}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
128
+ return fetcher(`${buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.getMarketplace)}${query ? `?${query}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
19
129
  };
20
130
  const getPriceDistribution = (params = {}, otherOptions = {}) => {
21
131
  const searchParams = new URLSearchParams();
@@ -27,60 +137,61 @@ const getReviewerAPI = (authAPIOptions = {}, intlayerConfig) => {
27
137
  else searchParams.append(key, String(value));
28
138
  }
29
139
  const query = searchParams.toString();
30
- return fetcher(`${BASE}/marketplace/price-distribution${query ? `?${query}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
140
+ return fetcher(`${buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.getPriceDistribution)}${query ? `?${query}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
31
141
  };
32
- const getReviewerById = (reviewerId, otherOptions = {}) => fetcher(`${BASE}/${reviewerId}`, authAPIOptions, otherOptions, { method: "GET" });
142
+ const getReviewerById = (reviewerId, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.getReviewerById, { reviewerId }), authAPIOptions, otherOptions, { method: reviewerEndpoints.getReviewerById.method });
33
143
  const getReviewerReviews = (reviewerId, params = {}, otherOptions = {}) => {
34
144
  const query = new URLSearchParams(Object.fromEntries(Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)]))).toString();
35
- return fetcher(`${BASE}/${reviewerId}/reviews${query ? `?${query}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
145
+ return fetcher(`${buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.getReviewerReviews, { reviewerId })}${query ? `?${query}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
36
146
  };
37
- const getMyReviewerProfile = (otherOptions = {}) => fetcher(`${BASE}/me`, authAPIOptions, otherOptions, { method: "GET" });
38
- const registerAsReviewer = (body, otherOptions = {}) => fetcher(`${BASE}/register`, authAPIOptions, otherOptions, {
39
- method: "POST",
147
+ const getMyReviewerProfile = (otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.getMyReviewerProfile), authAPIOptions, otherOptions, { method: reviewerEndpoints.getMyReviewerProfile.method });
148
+ const registerAsReviewer = (body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.registerAsReviewer), authAPIOptions, otherOptions, {
149
+ method: reviewerEndpoints.registerAsReviewer.method,
40
150
  body
41
151
  });
42
- const updateReviewerProfile = (body, otherOptions = {}) => fetcher(`${BASE}/`, authAPIOptions, otherOptions, {
43
- method: "PUT",
152
+ const updateReviewerProfile = (body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.updateReviewerProfile), authAPIOptions, otherOptions, {
153
+ method: reviewerEndpoints.updateReviewerProfile.method,
44
154
  body
45
155
  });
46
- const deleteReviewerProfile = (otherOptions = {}) => fetcher(BASE, authAPIOptions, otherOptions, { method: "DELETE" });
47
- const contactReviewer = (reviewerId, body, otherOptions = {}) => fetcher(`${BASE}/${reviewerId}/contact`, authAPIOptions, otherOptions, {
48
- method: "POST",
156
+ const deleteReviewerProfile = (otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.deleteReviewerProfile), authAPIOptions, otherOptions, { method: reviewerEndpoints.deleteReviewerProfile.method });
157
+ const contactReviewer = (reviewerId, body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.contactReviewer, { reviewerId }), authAPIOptions, otherOptions, {
158
+ method: reviewerEndpoints.contactReviewer.method,
49
159
  body
50
160
  });
51
- const estimateMission = (body, otherOptions = {}) => fetcher(`${BASE}/mission/estimate`, authAPIOptions, otherOptions, {
52
- method: "POST",
161
+ const estimateMission = (body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.estimateMission), authAPIOptions, otherOptions, {
162
+ method: reviewerEndpoints.estimateMission.method,
53
163
  body
54
164
  });
55
- const createMission = (body, otherOptions = {}) => fetcher(`${BASE}/mission`, authAPIOptions, otherOptions, {
56
- method: "POST",
165
+ const createMission = (body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.createMission), authAPIOptions, otherOptions, {
166
+ method: reviewerEndpoints.createMission.method,
57
167
  body
58
168
  });
59
169
  const getMyMissions = (params = {}, otherOptions = {}) => {
60
170
  const query = new URLSearchParams(Object.fromEntries(Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)]))).toString();
61
- return fetcher(`${BASE}/mission${query ? `?${query}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
171
+ return fetcher(`${buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.getMyMissions)}${query ? `?${query}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
62
172
  };
63
- const getMissionById = (missionId, otherOptions = {}) => fetcher(`${BASE}/mission/${missionId}`, authAPIOptions, otherOptions, { method: "GET" });
64
- const updateMissionStatus = (missionId, body, otherOptions = {}) => fetcher(`${BASE}/mission/${missionId}/status`, authAPIOptions, otherOptions, {
65
- method: "PUT",
173
+ const getMissionById = (missionId, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.getMissionById, { missionId }), authAPIOptions, otherOptions, { method: reviewerEndpoints.getMissionById.method });
174
+ const updateMissionStatus = (missionId, body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.updateMissionStatus, { missionId }), authAPIOptions, otherOptions, {
175
+ method: reviewerEndpoints.updateMissionStatus.method,
66
176
  body
67
177
  });
68
- const submitReview = (missionId, body, otherOptions = {}) => fetcher(`${BASE}/mission/${missionId}/review`, authAPIOptions, otherOptions, {
69
- method: "POST",
178
+ const submitReview = (missionId, body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.submitReview, { missionId }), authAPIOptions, otherOptions, {
179
+ method: reviewerEndpoints.submitReview.method,
70
180
  body
71
181
  });
72
- const getChatHistory = (missionId, otherOptions = {}) => fetcher(`${BASE}/mission/${missionId}/chat/history`, authAPIOptions, otherOptions, { method: "GET" });
73
- const sendMessage = (missionId, body, otherOptions = {}) => fetcher(`${BASE}/mission/${missionId}/chat`, authAPIOptions, otherOptions, {
74
- method: "POST",
182
+ const getChatHistory = (missionId, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.getChatHistory, { missionId }), authAPIOptions, otherOptions, { method: reviewerEndpoints.getChatHistory.method });
183
+ const sendMessage = (missionId, body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.sendMessage, { missionId }), authAPIOptions, otherOptions, {
184
+ method: reviewerEndpoints.sendMessage.method,
75
185
  body
76
186
  });
77
- const getChatStreamUrl = (missionId) => `${BASE}/mission/${missionId}/chat/stream`;
187
+ const getChatStreamUrl = (missionId) => buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.chatSSE, { missionId });
78
188
  const uploadPicture = async (kind, file, otherOptions = {}) => {
79
189
  const buffer = await file.arrayBuffer();
80
190
  const baseHeaders = { "Content-Type": file.type || "image/jpeg" };
81
191
  const authHeaders = authAPIOptions.headers ?? {};
82
- const response = await fetch(`${BASE}/me/picture/${kind}`, {
83
- method: "POST",
192
+ const endpoint = kind === "main" ? reviewerEndpoints.uploadMainPicture : reviewerEndpoints.uploadCoverPicture;
193
+ const response = await fetch(buildRouteURL(backendURL, reviewerGroup, endpoint), {
194
+ method: endpoint.method,
84
195
  credentials: "include",
85
196
  headers: {
86
197
  ...authHeaders,
@@ -97,10 +208,10 @@ const getReviewerAPI = (authAPIOptions = {}, intlayerConfig) => {
97
208
  };
98
209
  const uploadMainPicture = (file, otherOptions = {}) => uploadPicture("main", file, otherOptions);
99
210
  const uploadCoverPicture = (file, otherOptions = {}) => uploadPicture("cover", file, otherOptions);
100
- const validateReviewerProfile = (reviewerId, otherOptions = {}) => fetcher(`${BASE}/${reviewerId}/validate`, authAPIOptions, otherOptions, { method: "PUT" });
211
+ const validateReviewerProfile = (reviewerId, otherOptions = {}) => fetcher(buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.validateReviewerProfile, { reviewerId }), authAPIOptions, otherOptions, { method: reviewerEndpoints.validateReviewerProfile.method });
101
212
  const getAdminReviewers = (params = {}, otherOptions = {}) => {
102
213
  const query = new URLSearchParams(Object.fromEntries(Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)]))).toString();
103
- return fetcher(`${BASE}/admin/reviewers${query ? `?${query}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
214
+ return fetcher(`${buildRouteURL(backendURL, reviewerGroup, reviewerEndpoints.getAdminReviewers)}${query ? `?${query}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
104
215
  };
105
216
  return {
106
217
  getMarketplace,
@@ -135,6 +246,5 @@ const getReviewerAPI = (authAPIOptions = {}, intlayerConfig) => {
135
246
  */
136
247
  const reviewerEndpoint = createEndpoint(getReviewerAPI);
137
248
 
138
- //#endregion
139
249
  export { getReviewerAPI, reviewerEndpoint };
140
250
  //# sourceMappingURL=reviewer.mjs.map