@intlayer/api 9.0.0-canary.9 → 9.0.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 (190) hide show
  1. package/dist/cjs/cms/createAuthManager.cjs +116 -0
  2. package/dist/cjs/cms/createAuthManager.cjs.map +1 -0
  3. package/dist/cjs/cms/createIntlayerCMS.cjs +64 -0
  4. package/dist/cjs/cms/createIntlayerCMS.cjs.map +1 -0
  5. package/dist/cjs/cms/index.cjs +7 -0
  6. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +3 -2
  7. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  8. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +3 -2
  9. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  10. package/dist/cjs/fetcher.cjs +2 -1
  11. package/dist/cjs/fetcher.cjs.map +1 -1
  12. package/dist/cjs/getIntlayerAPI/ai.cjs +9 -0
  13. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  14. package/dist/cjs/getIntlayerAPI/analytics.cjs +64 -0
  15. package/dist/cjs/getIntlayerAPI/analytics.cjs.map +1 -0
  16. package/dist/cjs/getIntlayerAPI/asset.cjs +9 -0
  17. package/dist/cjs/getIntlayerAPI/asset.cjs.map +1 -1
  18. package/dist/cjs/getIntlayerAPI/audit.cjs +11 -1
  19. package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
  20. package/dist/cjs/getIntlayerAPI/bitbucket.cjs +9 -0
  21. package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
  22. package/dist/cjs/getIntlayerAPI/dictionary.cjs +9 -0
  23. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  24. package/dist/cjs/getIntlayerAPI/editor.cjs +9 -0
  25. package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
  26. package/dist/cjs/getIntlayerAPI/environment.cjs +9 -0
  27. package/dist/cjs/getIntlayerAPI/environment.cjs.map +1 -1
  28. package/dist/cjs/getIntlayerAPI/github.cjs +9 -0
  29. package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
  30. package/dist/cjs/getIntlayerAPI/gitlab.cjs +9 -0
  31. package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
  32. package/dist/cjs/getIntlayerAPI/index.cjs +6 -2
  33. package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
  34. package/dist/cjs/getIntlayerAPI/newsletter.cjs +9 -0
  35. package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
  36. package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
  37. package/dist/cjs/getIntlayerAPI/organization.cjs +19 -0
  38. package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
  39. package/dist/cjs/getIntlayerAPI/project.cjs +9 -0
  40. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  41. package/dist/cjs/getIntlayerAPI/reviewer.cjs +9 -0
  42. package/dist/cjs/getIntlayerAPI/reviewer.cjs.map +1 -1
  43. package/dist/cjs/getIntlayerAPI/search.cjs +9 -0
  44. package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
  45. package/dist/cjs/getIntlayerAPI/showcaseProject.cjs +9 -0
  46. package/dist/cjs/getIntlayerAPI/showcaseProject.cjs.map +1 -1
  47. package/dist/cjs/getIntlayerAPI/status.cjs +48 -0
  48. package/dist/cjs/getIntlayerAPI/status.cjs.map +1 -0
  49. package/dist/cjs/getIntlayerAPI/stripe.cjs +13 -2
  50. package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
  51. package/dist/cjs/getIntlayerAPI/tag.cjs +9 -0
  52. package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
  53. package/dist/cjs/getIntlayerAPI/translate.cjs +9 -0
  54. package/dist/cjs/getIntlayerAPI/translate.cjs.map +1 -1
  55. package/dist/cjs/getIntlayerAPI/user.cjs +9 -0
  56. package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
  57. package/dist/cjs/index.cjs +33 -3
  58. package/dist/cjs/proxy.cjs +82 -97
  59. package/dist/cjs/proxy.cjs.map +1 -1
  60. package/dist/esm/cms/createAuthManager.mjs +115 -0
  61. package/dist/esm/cms/createAuthManager.mjs.map +1 -0
  62. package/dist/esm/cms/createIntlayerCMS.mjs +62 -0
  63. package/dist/esm/cms/createIntlayerCMS.mjs.map +1 -0
  64. package/dist/esm/cms/index.mjs +4 -0
  65. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +3 -2
  66. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  67. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +3 -2
  68. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  69. package/dist/esm/fetcher.mjs +2 -1
  70. package/dist/esm/fetcher.mjs.map +1 -1
  71. package/dist/esm/getIntlayerAPI/ai.mjs +9 -1
  72. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  73. package/dist/esm/getIntlayerAPI/analytics.mjs +62 -0
  74. package/dist/esm/getIntlayerAPI/analytics.mjs.map +1 -0
  75. package/dist/esm/getIntlayerAPI/asset.mjs +9 -1
  76. package/dist/esm/getIntlayerAPI/asset.mjs.map +1 -1
  77. package/dist/esm/getIntlayerAPI/audit.mjs +11 -2
  78. package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
  79. package/dist/esm/getIntlayerAPI/bitbucket.mjs +9 -1
  80. package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
  81. package/dist/esm/getIntlayerAPI/dictionary.mjs +9 -1
  82. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  83. package/dist/esm/getIntlayerAPI/editor.mjs +9 -1
  84. package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
  85. package/dist/esm/getIntlayerAPI/environment.mjs +9 -1
  86. package/dist/esm/getIntlayerAPI/environment.mjs.map +1 -1
  87. package/dist/esm/getIntlayerAPI/github.mjs +9 -1
  88. package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
  89. package/dist/esm/getIntlayerAPI/gitlab.mjs +9 -1
  90. package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
  91. package/dist/esm/getIntlayerAPI/index.mjs +6 -2
  92. package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
  93. package/dist/esm/getIntlayerAPI/newsletter.mjs +9 -1
  94. package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
  95. package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
  96. package/dist/esm/getIntlayerAPI/organization.mjs +19 -1
  97. package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
  98. package/dist/esm/getIntlayerAPI/project.mjs +9 -1
  99. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  100. package/dist/esm/getIntlayerAPI/reviewer.mjs +9 -1
  101. package/dist/esm/getIntlayerAPI/reviewer.mjs.map +1 -1
  102. package/dist/esm/getIntlayerAPI/search.mjs +9 -1
  103. package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
  104. package/dist/esm/getIntlayerAPI/showcaseProject.mjs +9 -1
  105. package/dist/esm/getIntlayerAPI/showcaseProject.mjs.map +1 -1
  106. package/dist/esm/getIntlayerAPI/status.mjs +46 -0
  107. package/dist/esm/getIntlayerAPI/status.mjs.map +1 -0
  108. package/dist/esm/getIntlayerAPI/stripe.mjs +13 -3
  109. package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
  110. package/dist/esm/getIntlayerAPI/tag.mjs +9 -1
  111. package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
  112. package/dist/esm/getIntlayerAPI/translate.mjs +9 -1
  113. package/dist/esm/getIntlayerAPI/translate.mjs.map +1 -1
  114. package/dist/esm/getIntlayerAPI/user.mjs +9 -1
  115. package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
  116. package/dist/esm/index.mjs +25 -21
  117. package/dist/esm/proxy.mjs +82 -97
  118. package/dist/esm/proxy.mjs.map +1 -1
  119. package/dist/types/@intlayer/unmerged-dictionaries-entry/dist/types/index.d.ts +9 -0
  120. package/dist/types/@intlayer/unmerged-dictionaries-entry/dist/types/index.d.ts.map +1 -0
  121. package/dist/types/cms/createAuthManager.d.ts +102 -0
  122. package/dist/types/cms/createAuthManager.d.ts.map +1 -0
  123. package/dist/types/cms/createIntlayerCMS.d.ts +79 -0
  124. package/dist/types/cms/createIntlayerCMS.d.ts.map +1 -0
  125. package/dist/types/cms/index.d.ts +3 -0
  126. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +1 -2
  127. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
  128. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +1 -2
  129. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
  130. package/dist/types/fetcher.d.ts.map +1 -1
  131. package/dist/types/getIntlayerAPI/ai.d.ts +23 -3
  132. package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
  133. package/dist/types/getIntlayerAPI/analytics.d.ts +29 -0
  134. package/dist/types/getIntlayerAPI/analytics.d.ts.map +1 -0
  135. package/dist/types/getIntlayerAPI/asset.d.ts +20 -2
  136. package/dist/types/getIntlayerAPI/asset.d.ts.map +1 -1
  137. package/dist/types/getIntlayerAPI/audit.d.ts +25 -3
  138. package/dist/types/getIntlayerAPI/audit.d.ts.map +1 -1
  139. package/dist/types/getIntlayerAPI/bitbucket.d.ts +16 -2
  140. package/dist/types/getIntlayerAPI/bitbucket.d.ts.map +1 -1
  141. package/dist/types/getIntlayerAPI/dictionary.d.ts +23 -6
  142. package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
  143. package/dist/types/getIntlayerAPI/editor.d.ts +17 -3
  144. package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
  145. package/dist/types/getIntlayerAPI/environment.d.ts +18 -3
  146. package/dist/types/getIntlayerAPI/environment.d.ts.map +1 -1
  147. package/dist/types/getIntlayerAPI/github.d.ts +17 -2
  148. package/dist/types/getIntlayerAPI/github.d.ts.map +1 -1
  149. package/dist/types/getIntlayerAPI/gitlab.d.ts +16 -2
  150. package/dist/types/getIntlayerAPI/gitlab.d.ts.map +1 -1
  151. package/dist/types/getIntlayerAPI/index.d.ts +6 -3
  152. package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
  153. package/dist/types/getIntlayerAPI/newsletter.d.ts +15 -3
  154. package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
  155. package/dist/types/getIntlayerAPI/oAuth.d.ts +1 -2
  156. package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
  157. package/dist/types/getIntlayerAPI/organization.d.ts +27 -5
  158. package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
  159. package/dist/types/getIntlayerAPI/project.d.ts +34 -7
  160. package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
  161. package/dist/types/getIntlayerAPI/reviewer.d.ts +49 -5
  162. package/dist/types/getIntlayerAPI/reviewer.d.ts.map +1 -1
  163. package/dist/types/getIntlayerAPI/search.d.ts +13 -3
  164. package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
  165. package/dist/types/getIntlayerAPI/showcaseProject.d.ts +27 -6
  166. package/dist/types/getIntlayerAPI/showcaseProject.d.ts.map +1 -1
  167. package/dist/types/getIntlayerAPI/status.d.ts +35 -0
  168. package/dist/types/getIntlayerAPI/status.d.ts.map +1 -0
  169. package/dist/types/getIntlayerAPI/stripe.d.ts +61 -25
  170. package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
  171. package/dist/types/getIntlayerAPI/tag.d.ts +18 -5
  172. package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
  173. package/dist/types/getIntlayerAPI/translate.d.ts +38 -3
  174. package/dist/types/getIntlayerAPI/translate.d.ts.map +1 -1
  175. package/dist/types/getIntlayerAPI/user.d.ts +25 -7
  176. package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
  177. package/dist/types/index.d.ts +27 -21
  178. package/dist/types/intlayer-editor/server/dist/controllers/configuration.controller.d.ts +9 -0
  179. package/dist/types/intlayer-editor/server/dist/controllers/configuration.controller.d.ts.map +1 -0
  180. package/dist/types/intlayer-editor/server/dist/controllers/dictionary.controller.d.ts +19 -0
  181. package/dist/types/intlayer-editor/server/dist/controllers/dictionary.controller.d.ts.map +1 -0
  182. package/dist/types/intlayer-editor/server/dist/export.d.ts +3 -0
  183. package/dist/types/intlayer-editor/server/dist/utils/httpStatusCodes.d.ts +408 -0
  184. package/dist/types/intlayer-editor/server/dist/utils/httpStatusCodes.d.ts.map +1 -0
  185. package/dist/types/intlayer-editor/server/dist/utils/responseData.d.ts +19 -0
  186. package/dist/types/intlayer-editor/server/dist/utils/responseData.d.ts.map +1 -0
  187. package/dist/types/proxy.d.ts +12 -11
  188. package/dist/types/proxy.d.ts.map +1 -1
  189. package/dist/types/types.d.ts +1 -1
  190. package/package.json +31 -7
@@ -1 +1 @@
1
- {"version":3,"file":"showcaseProject.mjs","names":[],"sources":["../../../src/getIntlayerAPI/showcaseProject.ts"],"sourcesContent":["import type {\n GetOtherShowcaseProjectsResult,\n GetShowcaseProjectByIdParams,\n GetShowcaseProjectByIdResult,\n GetShowcaseProjectsResult,\n SubmitShowcaseProjectBody,\n SubmitShowcaseProjectResult,\n ToggleShowcaseDownvoteBody,\n ToggleShowcaseDownvoteResult,\n ToggleShowcaseUpvoteBody,\n ToggleShowcaseUpvoteResult,\n UpdateShowcaseProjectBody,\n UpdateShowcaseProjectResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\n// Client-side query types use proper JS types (numbers/booleans) rather than\n// the backend querystring types which are always strings.\nexport type ShowcaseProjectsQuery = {\n page?: number;\n pageSize?: number;\n search?: string;\n selectedUseCases?: string[];\n isOpenSource?: boolean;\n};\n\nexport type OtherShowcaseProjectsQuery = {\n excludeId: string;\n limit?: number;\n};\n\nexport const getShowcaseProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const SHOWCASE_API_ROUTE = `${backendURL}/api/showcase-project`;\n\n const getShowcaseProjects = async (\n query?: ShowcaseProjectsQuery,\n otherOptions: FetcherOptions = {}\n ) => {\n const params: Record<string, string | string[]> = {};\n if (query?.page !== undefined) params.page = String(query.page);\n if (query?.pageSize !== undefined) params.pageSize = String(query.pageSize);\n if (query?.search !== undefined) params.search = query.search;\n if (query?.isOpenSource !== undefined)\n params.isOpenSource = String(query.isOpenSource);\n if (query?.selectedUseCases?.length)\n params.selectedUseCases = query.selectedUseCases;\n\n return await fetcher<GetShowcaseProjectsResult>(\n SHOWCASE_API_ROUTE,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as any }\n );\n };\n\n const getShowcaseProjectById = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetShowcaseProjectByIdResult>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const getOtherShowcaseProjects = async (\n query: OtherShowcaseProjectsQuery,\n otherOptions: FetcherOptions = {}\n ) => {\n const params: Record<string, string> = { excludeId: query.excludeId };\n if (query.limit !== undefined) params.limit = String(query.limit);\n return await fetcher<GetOtherShowcaseProjectsResult>(\n `${SHOWCASE_API_ROUTE}/others`,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as any }\n );\n };\n\n const submitShowcaseProject = async (\n body: SubmitShowcaseProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SubmitShowcaseProjectResult>(\n `${SHOWCASE_API_ROUTE}/submit`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const toggleShowcaseUpvote = async (\n body: ToggleShowcaseUpvoteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ToggleShowcaseUpvoteResult>(\n `${SHOWCASE_API_ROUTE}/upvote`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const toggleShowcaseDownvote = async (\n body: ToggleShowcaseDownvoteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ToggleShowcaseDownvoteResult>(\n `${SHOWCASE_API_ROUTE}/downvote`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const deleteShowcaseProject = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ data: { success: boolean } }>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n const updateShowcaseProject = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n body: UpdateShowcaseProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateShowcaseProjectResult>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'PATCH', body }\n );\n\n return {\n getShowcaseProjects,\n getShowcaseProjectById,\n getOtherShowcaseProjects,\n submitShowcaseProject,\n toggleShowcaseUpvote,\n toggleShowcaseDownvote,\n deleteShowcaseProject,\n updateShowcaseProject,\n };\n};\n"],"mappings":";;;;AAiCA,MAAa,yBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,qBAAqB,GAFR,gBAAgB,QAAQ,cAAc,OAAO,WAEvB;CAEzC,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAC9B;EACH,MAAM,SAA4C,EAAE;AACpD,MAAI,OAAO,SAAS,OAAW,QAAO,OAAO,OAAO,MAAM,KAAK;AAC/D,MAAI,OAAO,aAAa,OAAW,QAAO,WAAW,OAAO,MAAM,SAAS;AAC3E,MAAI,O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AS;EAAM,CAC1B;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"showcaseProject.mjs","names":[],"sources":["../../../src/getIntlayerAPI/showcaseProject.ts"],"sourcesContent":["import type {\n GetOtherShowcaseProjectsResult,\n GetShowcaseProjectByIdParams,\n GetShowcaseProjectByIdResult,\n GetShowcaseProjectsResult,\n SubmitShowcaseProjectBody,\n SubmitShowcaseProjectResult,\n ToggleShowcaseDownvoteBody,\n ToggleShowcaseDownvoteResult,\n ToggleShowcaseUpvoteBody,\n ToggleShowcaseUpvoteResult,\n UpdateShowcaseProjectBody,\n UpdateShowcaseProjectResult,\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\n// Client-side query types use proper JS types (numbers/booleans) rather than\n// the backend querystring types which are always strings.\nexport type ShowcaseProjectsQuery = {\n page?: number;\n pageSize?: number;\n search?: string;\n selectedUseCases?: string[];\n isOpenSource?: boolean;\n};\n\nexport type OtherShowcaseProjectsQuery = {\n excludeId: string;\n limit?: number;\n};\n\nexport const getShowcaseProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const SHOWCASE_API_ROUTE = `${backendURL}/api/showcase-project`;\n\n const getShowcaseProjects = async (\n query?: ShowcaseProjectsQuery,\n otherOptions: FetcherOptions = {}\n ) => {\n const params: Record<string, string | string[]> = {};\n if (query?.page !== undefined) params.page = String(query.page);\n if (query?.pageSize !== undefined) params.pageSize = String(query.pageSize);\n if (query?.search !== undefined) params.search = query.search;\n if (query?.isOpenSource !== undefined)\n params.isOpenSource = String(query.isOpenSource);\n if (query?.selectedUseCases?.length)\n params.selectedUseCases = query.selectedUseCases;\n\n return await fetcher<GetShowcaseProjectsResult>(\n SHOWCASE_API_ROUTE,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as any }\n );\n };\n\n const getShowcaseProjectById = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetShowcaseProjectByIdResult>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const getOtherShowcaseProjects = async (\n query: OtherShowcaseProjectsQuery,\n otherOptions: FetcherOptions = {}\n ) => {\n const params: Record<string, string> = { excludeId: query.excludeId };\n if (query.limit !== undefined) params.limit = String(query.limit);\n return await fetcher<GetOtherShowcaseProjectsResult>(\n `${SHOWCASE_API_ROUTE}/others`,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as any }\n );\n };\n\n const submitShowcaseProject = async (\n body: SubmitShowcaseProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SubmitShowcaseProjectResult>(\n `${SHOWCASE_API_ROUTE}/submit`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const toggleShowcaseUpvote = async (\n body: ToggleShowcaseUpvoteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ToggleShowcaseUpvoteResult>(\n `${SHOWCASE_API_ROUTE}/upvote`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const toggleShowcaseDownvote = async (\n body: ToggleShowcaseDownvoteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ToggleShowcaseDownvoteResult>(\n `${SHOWCASE_API_ROUTE}/downvote`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const deleteShowcaseProject = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ data: { success: boolean } }>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n const updateShowcaseProject = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n body: UpdateShowcaseProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateShowcaseProjectResult>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'PATCH', body }\n );\n\n return {\n getShowcaseProjects,\n getShowcaseProjectById,\n getOtherShowcaseProjects,\n submitShowcaseProject,\n toggleShowcaseUpvote,\n toggleShowcaseDownvote,\n deleteShowcaseProject,\n updateShowcaseProject,\n };\n};\n\n/**\n * Authenticated `showcaseProject` 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 showcaseProjectEndpoint = createEndpoint(getShowcaseProjectAPI);\n"],"mappings":";;;;;AAkCA,MAAa,yBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,qBAAqB,GAFR,gBAAgB,QAAQ,cAAc,OAAO,WAEvB;CAEzC,MAAM,sBAAsB,OAC1B,OACA,eAA+B,CAAC,MAC7B;EACH,MAAM,SAA4C,CAAC;EACnD,IAAI,OAAO,SAAS,QAAW,OAAO,OAAO,OAAO,MAAM,IAAI;EAC9D,IAAI,OAAO,aAAa,QAAW,OAAO,WAAW,OAAO,MAAM,QAAQ;EAC1E,IAAI,OAAO,WAAW,QAAW,OAAO,SAAS,MAAM;EACvD,IAAI,OAAO,iBAAiB,QAC1B,OAAO,eAAe,OAAO,MAAM,YAAY;EACjD,IAAI,OAAO,kBAAkB,QAC3B,OAAO,mBAAmB,MAAM;EAElC,OAAO,MAAM,QACX,oBACA,gBACA,cACA;GAAE,QAAQ;GAAe;EAAc,CACzC;CACF;CAEA,MAAM,yBAAyB,OAC7B,WACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,mBAAmB,GAAG,aACzB,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;CAEF,MAAM,2BAA2B,OAC/B,OACA,eAA+B,CAAC,MAC7B;EACH,MAAM,SAAiC,EAAE,WAAW,MAAM,UAAU;EACpE,IAAI,MAAM,UAAU,QAAW,OAAO,QAAQ,OAAO,MAAM,KAAK;EAChE,OAAO,MAAM,QACX,GAAG,mBAAmB,UACtB,gBACA,cACA;GAAE,QAAQ;GAAe;EAAc,CACzC;CACF;CAEA,MAAM,wBAAwB,OAC5B,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,mBAAmB,UACtB,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;CAEF,MAAM,uBAAuB,OAC3B,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,mBAAmB,UACtB,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;CAEF,MAAM,yBAAyB,OAC7B,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,mBAAmB,YACtB,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;CAEF,MAAM,wBAAwB,OAC5B,WACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,mBAAmB,GAAG,aACzB,gBACA,cACA,EAAE,QAAQ,SAAS,CACrB;CAEF,MAAM,wBAAwB,OAC5B,WACA,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,mBAAmB,GAAG,aACzB,gBACA,cACA;EAAE,QAAQ;EAAS;CAAK,CAC1B;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,0BAA0B,eAAe,qBAAqB"}
@@ -0,0 +1,46 @@
1
+ import { fetcher } from "../fetcher.mjs";
2
+ import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
3
+ import { editor } from "@intlayer/config/built";
4
+
5
+ //#region src/getIntlayerAPI/status.ts
6
+ /**
7
+ * Instance/entry status endpoints. These back the decisions made when an
8
+ * unauthenticated visitor reaches the app root:
9
+ * - `getSetupStatus` — on a self-hosted instance, whether the first
10
+ * super-admin still needs to be created.
11
+ * - `getDemoSession` — on the hosted cloud, signs the visitor into the shared
12
+ * read-only demo account (the backend sets the session cookie on the
13
+ * response).
14
+ */
15
+ const getStatusAPI = (authAPIOptions = {}, intlayerConfig) => {
16
+ const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;
17
+ /**
18
+ * Reports whether the instance still needs its initial setup (creation of
19
+ * the first super-admin). Only ever `true` on a self-hosted deployment with
20
+ * an empty users collection. Public endpoint — no authentication required.
21
+ * @returns `{ isSetupRequired: boolean }`.
22
+ */
23
+ const getSetupStatus = async (otherOptions = {}) => await fetcher(`${backendURL}/api/user/setup`, authAPIOptions, otherOptions, { cache: "no-store" });
24
+ /**
25
+ * Signs the current browser into the shared demo account. The backend
26
+ * responds with a `Set-Cookie` header establishing the demo session, so this
27
+ * must run with credentials included (the default in the fetcher).
28
+ * @returns `{ ok: boolean }`.
29
+ */
30
+ const getDemoSession = async (otherOptions = {}) => await fetcher(`${backendURL}/api/demo/session`, authAPIOptions, otherOptions, { cache: "no-store" });
31
+ return {
32
+ getSetupStatus,
33
+ getDemoSession
34
+ };
35
+ };
36
+ /**
37
+ * Instance status endpoints bound to an Intlayer CMS authenticator.
38
+ *
39
+ * Pass an authenticator created with `createIntlayerCMS`, or omit it to use
40
+ * the build-time configuration (`@intlayer/config/built`).
41
+ */
42
+ const statusEndpoint = createEndpoint(getStatusAPI);
43
+
44
+ //#endregion
45
+ export { getStatusAPI, statusEndpoint };
46
+ //# sourceMappingURL=status.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.mjs","names":[],"sources":["../../../src/getIntlayerAPI/status.ts"],"sourcesContent":["import type { GetSetupStatusResult } 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\n/** Result of the demo-session bootstrap endpoint. */\nexport type GetDemoSessionResult = { ok: boolean };\n\n/**\n * Instance/entry status endpoints. These back the decisions made when an\n * unauthenticated visitor reaches the app root:\n * - `getSetupStatus` — on a self-hosted instance, whether the first\n * super-admin still needs to be created.\n * - `getDemoSession` — on the hosted cloud, signs the visitor into the shared\n * read-only demo account (the backend sets the session cookie on the\n * response).\n */\nexport const getStatusAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n /**\n * Reports whether the instance still needs its initial setup (creation of\n * the first super-admin). Only ever `true` on a self-hosted deployment with\n * an empty users collection. Public endpoint — no authentication required.\n * @returns `{ isSetupRequired: boolean }`.\n */\n const getSetupStatus = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetSetupStatusResult>(\n `${backendURL}/api/user/setup`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Signs the current browser into the shared demo account. The backend\n * responds with a `Set-Cookie` header establishing the demo session, so this\n * must run with credentials included (the default in the fetcher).\n * @returns `{ ok: boolean }`.\n */\n const getDemoSession = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetDemoSessionResult>(\n `${backendURL}/api/demo/session`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n return {\n getSetupStatus,\n getDemoSession,\n };\n};\n\n/**\n * Instance status endpoints 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 statusEndpoint = createEndpoint(getStatusAPI);\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAa,gBACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aAAa,gBAAgB,QAAQ,cAAc,OAAO;;;;;;;CAQhE,MAAM,iBAAiB,OAAO,eAA+B,CAAC,MAC5D,MAAM,QACJ,GAAG,WAAW,kBACd,gBACA,cACA,EACE,OAAO,WACT,CACF;;;;;;;CAQF,MAAM,iBAAiB,OAAO,eAA+B,CAAC,MAC5D,MAAM,QACJ,GAAG,WAAW,oBACd,gBACA,cACA,EACE,OAAO,WACT,CACF;CAEF,OAAO;EACL;EACA;CACF;AACF;;;;;;;AAQA,MAAa,iBAAiB,eAAe,YAAY"}
@@ -1,4 +1,5 @@
1
1
  import { fetcher } from "../fetcher.mjs";
2
+ import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
2
3
  import { editor } from "@intlayer/config/built";
3
4
 
4
5
  //#region src/getIntlayerAPI/stripe.ts
@@ -83,7 +84,8 @@ const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
83
84
  if (params.page) qs.set("page", String(params.page));
84
85
  if (params.pageSize) qs.set("pageSize", String(params.pageSize));
85
86
  if (params.search) qs.set("search", params.search);
86
- return await fetcher(`${STRIPE_API_ROUTE}/affiliate/invitations${qs.toString() ? `?${qs.toString()}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
87
+ const query = qs.toString() ? `?${qs.toString()}` : "";
88
+ return await fetcher(`${STRIPE_API_ROUTE}/affiliate/invitations${query}`, authAPIOptions, otherOptions, { method: "GET" });
87
89
  };
88
90
  /**
89
91
  * Sends an affiliate invitation email to the given address (admin only).
@@ -118,7 +120,8 @@ const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
118
120
  */
119
121
  const getPromoCodeById = async (id, otherOptions = {}) => await fetcher(`${STRIPE_API_ROUTE}/promo-codes/${id}`, authAPIOptions, otherOptions, { method: "GET" });
120
122
  const getPromoCodes = async (params = {}, otherOptions = {}) => {
121
- return await fetcher(`${STRIPE_API_ROUTE}/promo-codes${params.affiliateId ? `?affiliateId=${encodeURIComponent(params.affiliateId)}` : ""}`, authAPIOptions, otherOptions, { method: "GET" });
123
+ const qs = params.affiliateId ? `?affiliateId=${encodeURIComponent(params.affiliateId)}` : "";
124
+ return await fetcher(`${STRIPE_API_ROUTE}/promo-codes${qs}`, authAPIOptions, otherOptions, { method: "GET" });
122
125
  };
123
126
  /**
124
127
  * Admin-only: creates a new promo code (Stripe coupon + promotion code).
@@ -169,7 +172,14 @@ const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
169
172
  getAffiliatePromoCode
170
173
  };
171
174
  };
175
+ /**
176
+ * Authenticated `stripe` endpoint bound to an Intlayer CMS authenticator.
177
+ *
178
+ * Pass an authenticator created with `createIntlayerCMS`, or omit it to use
179
+ * the build-time configuration (`@intlayer/config/built`).
180
+ */
181
+ const stripeEndpoint = createEndpoint(getStripeAPI);
172
182
 
173
183
  //#endregion
174
- export { getStripeAPI };
184
+ export { getStripeAPI, stripeEndpoint };
175
185
  //# sourceMappingURL=stripe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.mjs","names":[],"sources":["../../../src/getIntlayerAPI/stripe.ts"],"sourcesContent":["import type {\n AcceptAffiliateInvitationResult,\n CreatePortalSessionResult,\n CreatePromoCodeBody,\n CreatePromoCodeResult,\n DeletePromoCodeResult,\n GetAffiliateAccountSessionResult,\n GetAffiliateByIdResult,\n GetAffiliateInvitationResult,\n GetAffiliateInvitationsResult,\n GetAffiliateOnboardingLinkResult,\n GetAffiliateResult,\n GetAffiliateStatsResult,\n GetAffiliatesParams,\n GetAffiliatesResult,\n GetCheckoutSessionBody,\n GetCheckoutSessionResult,\n GetInvoicesResult,\n GetPaymentMethodResult,\n GetPricingBody,\n GetPricingResult,\n GetPromoCodeByIdResult,\n GetPromoCodesResult,\n GrantAffiliateAccessBody,\n GrantAffiliateAccessResult,\n SendAffiliateInvitationBody,\n SendAffiliateInvitationResult,\n UpdateAffiliateStatusBody,\n UpdateAffiliateStatusResult,\n UpdatePromoCodeBody,\n UpdatePromoCodeResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getStripeAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const STRIPE_API_ROUTE = `${backendURL}/api/stripe`;\n\n /**\n * Get a pricing plan calculated for a given promotion code.\n * @param body - Pricing plan body.\n */\n const getPricing = async (\n body?: GetPricingBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetPricingResult>(\n `${STRIPE_API_ROUTE}/pricing`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Retrieves a checkout session.\n * @param body - Checkout session body.\n */\n const getSubscription = async (\n body?: GetCheckoutSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/create-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Cancels a subscription.\n * @param body - Checkout session body.\n */\n const cancelSubscription = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/cancel-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Lists invoices for the authenticated organization's Stripe customer.\n */\n const getInvoices = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetInvoicesResult>(\n `${STRIPE_API_ROUTE}/invoices`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Returns the first card payment method for the authenticated organization's\n * Stripe customer (or null if none).\n */\n const getPaymentMethod = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetPaymentMethodResult>(\n `${STRIPE_API_ROUTE}/payment-method`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Creates a Stripe Billing Portal session for the authenticated organization.\n */\n const createPortalSession = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<CreatePortalSessionResult>(\n `${STRIPE_API_ROUTE}/portal-session`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n /**\n * Admin-only: grants affiliate access to a user by creating their Stripe Connect account.\n */\n const grantAffiliateAccess = async (\n body: GrantAffiliateAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GrantAffiliateAccessResult>(\n `${STRIPE_API_ROUTE}/affiliate/grant`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Admin-only: returns a paginated list of all affiliates.\n */\n const getAffiliates = async (\n params?: GetAffiliatesParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliatesResult>(\n `${STRIPE_API_ROUTE}/affiliates`,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as Record<string, string> }\n );\n\n /**\n * Admin-only: returns a single affiliate by ID.\n */\n const getAffiliateById = async (\n { id }: { id: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateByIdResult>(\n `${STRIPE_API_ROUTE}/affiliates/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Returns the affiliate record for the authenticated user (null if not an affiliate).\n */\n const getAffiliate = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetAffiliateResult>(\n `${STRIPE_API_ROUTE}/affiliate`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Creates a Stripe Connect account session for the authenticated affiliate (embedded onboarding).\n */\n const getAffiliateAccountSession = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateAccountSessionResult>(\n `${STRIPE_API_ROUTE}/affiliate/account-session`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n /**\n * Returns a Stripe-hosted onboarding URL for the authenticated affiliate.\n */\n const getAffiliateOnboardingLink = async (\n params?: { returnUrl?: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateOnboardingLinkResult>(\n `${STRIPE_API_ROUTE}/affiliate/onboarding-link`,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params }\n );\n\n /**\n * Returns referral stats for the authenticated affiliate.\n */\n const getAffiliateStats = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetAffiliateStatsResult>(\n `${STRIPE_API_ROUTE}/affiliate/stats`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Admin-only: returns a paginated list of all affiliate invitations.\n */\n const getAffiliateInvitations = async (\n params: GetAffiliatesParams = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const qs = new URLSearchParams();\n if (params.page) qs.set('page', String(params.page));\n if (params.pageSize) qs.set('pageSize', String(params.pageSize));\n if (params.search) qs.set('search', params.search);\n const query = qs.toString() ? `?${qs.toString()}` : '';\n return await fetcher<GetAffiliateInvitationsResult>(\n `${STRIPE_API_ROUTE}/affiliate/invitations${query}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n /**\n * Sends an affiliate invitation email to the given address (admin only).\n */\n const sendAffiliateInvitation = async (\n body: SendAffiliateInvitationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SendAffiliateInvitationResult>(\n `${STRIPE_API_ROUTE}/affiliate/invite`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Retrieves an affiliate invitation by token (public — no auth required).\n */\n const getAffiliateInvitation = async (\n { token }: { token: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateInvitationResult>(\n `${STRIPE_API_ROUTE}/affiliate/invitation/${token}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Admin-only: updates an affiliate's status and/or category.\n */\n const updateAffiliateStatus = async (\n { id }: { id: string },\n body: UpdateAffiliateStatusBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateAffiliateStatusResult>(\n `${STRIPE_API_ROUTE}/affiliates/${id}/status`,\n authAPIOptions,\n otherOptions,\n { method: 'PATCH', body }\n );\n\n /**\n * Accepts an affiliate invitation and creates the affiliate account.\n */\n const acceptAffiliateInvitation = async (\n {\n token,\n country,\n stripeAccountType,\n }: {\n token: string;\n country?: string;\n stripeAccountType?: 'express' | 'standard';\n },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AcceptAffiliateInvitationResult>(\n `${STRIPE_API_ROUTE}/affiliate/invitation/${token}/accept`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body: { country, stripeAccountType } }\n );\n\n /**\n * Admin-only: returns a paginated list of all promo codes.\n */\n const getPromoCodeById = async (\n id: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetPromoCodeByIdResult>(\n `${STRIPE_API_ROUTE}/promo-codes/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const getPromoCodes = async (\n params: { affiliateId?: string } = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const qs = params.affiliateId\n ? `?affiliateId=${encodeURIComponent(params.affiliateId)}`\n : '';\n return await fetcher<GetPromoCodesResult>(\n `${STRIPE_API_ROUTE}/promo-codes${qs}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n /**\n * Admin-only: creates a new promo code (Stripe coupon + promotion code).\n */\n const createPromoCode = async (\n body: CreatePromoCodeBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreatePromoCodeResult>(\n `${STRIPE_API_ROUTE}/promo-codes`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Admin-only: updates a promo code.\n */\n const updatePromoCode = async (\n { id, ...body }: { id: string } & UpdatePromoCodeBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdatePromoCodeResult>(\n `${STRIPE_API_ROUTE}/promo-codes/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'PATCH', body }\n );\n\n /**\n * Admin-only: deactivates a promo code (sets active=false, disables Stripe promotion code).\n */\n const deletePromoCode = async (\n { id }: { id: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeletePromoCodeResult>(\n `${STRIPE_API_ROUTE}/promo-codes/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Retrieves the active promo code associated with a given affiliate referral code.\n */\n const getAffiliatePromoCode = async (\n referralCode: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<any>(\n `${STRIPE_API_ROUTE}/affiliate-promo-code/${referralCode}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n return {\n getPricing,\n getSubscription,\n cancelSubscription,\n getInvoices,\n getPaymentMethod,\n createPortalSession,\n grantAffiliateAccess,\n getAffiliates,\n getAffiliateById,\n getAffiliate,\n getAffiliateAccountSession,\n getAffiliateOnboardingLink,\n getAffiliateStats,\n getAffiliateInvitations,\n sendAffiliateInvitation,\n getAffiliateInvitation,\n acceptAffiliateInvitation,\n updateAffiliateStatus,\n getPromoCodeById,\n getPromoCodes,\n createPromoCode,\n updatePromoCode,\n deletePromoCode,\n getAffiliatePromoCode,\n };\n};\n"],"mappings":";;;;AAoCA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,mBAAmB,GAFN,gBAAgB,QAAQ,cAAc,OAAO,WAEzB;;;;;CAMvC,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,WACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;;CAMH,MAAM,kBAAkB,OACtB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,uBACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;;CAMH,MAAM,qBAAqB,OAAO,eAA+B,EAAE,KACjE,MAAM,QACJ,GAAG,iBAAiB,uBACpB,gBACA,cACA,EACE,QAAQ,QACT,CACF;;;;CAKH,MAAM,cAAc,OAAO,eAA+B,EAAE,KAC1D,MAAM,QACJ,GAAG,iBAAiB,YACpB,gBACA,cACA,EAAE,QAAQ,OAAO,CAClB;;;;;CAMH,MAAM,mBAAm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,OAAO,CAClB;;;;;CAMH,MAAM,kBAAkB,OACtB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,eACpB,gBACA,cACA;EAAE,QAAQ;EAAQ;EAAM,CACzB;;;;CAKH,MAAM,kBAAkB,OACtB,EAAE,IAAI,GAAG,QACT,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,eAAe,MACnC,gBACA,cACA;EAAE,QAAQ;EAAS;EAAM,CAC1B;;;;CAKH,MAAM,kBAAkB,OACtB,EAAE,MACF,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,eAAe,MACnC,gBACA,cACA,EAAE,QAAQ,UAAU,CACrB;;;;CAKH,MAAM,wBAAwB,OAC5B,cACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,wBAAwB,gBAC5C,gBACA,cACA,EAAE,QAAQ,OAAO,CAClB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"stripe.mjs","names":[],"sources":["../../../src/getIntlayerAPI/stripe.ts"],"sourcesContent":["import type {\n AcceptAffiliateInvitationResult,\n CreatePortalSessionResult,\n CreatePromoCodeBody,\n CreatePromoCodeResult,\n DeletePromoCodeResult,\n GetAffiliateAccountSessionResult,\n GetAffiliateByIdResult,\n GetAffiliateInvitationResult,\n GetAffiliateInvitationsResult,\n GetAffiliateOnboardingLinkResult,\n GetAffiliateResult,\n GetAffiliateStatsResult,\n GetAffiliatesParams,\n GetAffiliatesResult,\n GetCheckoutSessionBody,\n GetCheckoutSessionResult,\n GetInvoicesResult,\n GetPaymentMethodResult,\n GetPricingBody,\n GetPricingResult,\n GetPromoCodeByIdResult,\n GetPromoCodesResult,\n GrantAffiliateAccessBody,\n GrantAffiliateAccessResult,\n SendAffiliateInvitationBody,\n SendAffiliateInvitationResult,\n UpdateAffiliateStatusBody,\n UpdateAffiliateStatusResult,\n UpdatePromoCodeBody,\n UpdatePromoCodeResult,\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 getStripeAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const STRIPE_API_ROUTE = `${backendURL}/api/stripe`;\n\n /**\n * Get a pricing plan calculated for a given promotion code.\n * @param body - Pricing plan body.\n */\n const getPricing = async (\n body?: GetPricingBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetPricingResult>(\n `${STRIPE_API_ROUTE}/pricing`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Retrieves a checkout session.\n * @param body - Checkout session body.\n */\n const getSubscription = async (\n body?: GetCheckoutSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/create-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Cancels a subscription.\n * @param body - Checkout session body.\n */\n const cancelSubscription = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/cancel-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Lists invoices for the authenticated organization's Stripe customer.\n */\n const getInvoices = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetInvoicesResult>(\n `${STRIPE_API_ROUTE}/invoices`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Returns the first card payment method for the authenticated organization's\n * Stripe customer (or null if none).\n */\n const getPaymentMethod = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetPaymentMethodResult>(\n `${STRIPE_API_ROUTE}/payment-method`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Creates a Stripe Billing Portal session for the authenticated organization.\n */\n const createPortalSession = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<CreatePortalSessionResult>(\n `${STRIPE_API_ROUTE}/portal-session`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n /**\n * Admin-only: grants affiliate access to a user by creating their Stripe Connect account.\n */\n const grantAffiliateAccess = async (\n body: GrantAffiliateAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GrantAffiliateAccessResult>(\n `${STRIPE_API_ROUTE}/affiliate/grant`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Admin-only: returns a paginated list of all affiliates.\n */\n const getAffiliates = async (\n params?: GetAffiliatesParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliatesResult>(\n `${STRIPE_API_ROUTE}/affiliates`,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as Record<string, string> }\n );\n\n /**\n * Admin-only: returns a single affiliate by ID.\n */\n const getAffiliateById = async (\n { id }: { id: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateByIdResult>(\n `${STRIPE_API_ROUTE}/affiliates/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Returns the affiliate record for the authenticated user (null if not an affiliate).\n */\n const getAffiliate = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetAffiliateResult>(\n `${STRIPE_API_ROUTE}/affiliate`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Creates a Stripe Connect account session for the authenticated affiliate (embedded onboarding).\n */\n const getAffiliateAccountSession = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateAccountSessionResult>(\n `${STRIPE_API_ROUTE}/affiliate/account-session`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n /**\n * Returns a Stripe-hosted onboarding URL for the authenticated affiliate.\n */\n const getAffiliateOnboardingLink = async (\n params?: { returnUrl?: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateOnboardingLinkResult>(\n `${STRIPE_API_ROUTE}/affiliate/onboarding-link`,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params }\n );\n\n /**\n * Returns referral stats for the authenticated affiliate.\n */\n const getAffiliateStats = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetAffiliateStatsResult>(\n `${STRIPE_API_ROUTE}/affiliate/stats`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Admin-only: returns a paginated list of all affiliate invitations.\n */\n const getAffiliateInvitations = async (\n params: GetAffiliatesParams = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const qs = new URLSearchParams();\n if (params.page) qs.set('page', String(params.page));\n if (params.pageSize) qs.set('pageSize', String(params.pageSize));\n if (params.search) qs.set('search', params.search);\n const query = qs.toString() ? `?${qs.toString()}` : '';\n return await fetcher<GetAffiliateInvitationsResult>(\n `${STRIPE_API_ROUTE}/affiliate/invitations${query}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n /**\n * Sends an affiliate invitation email to the given address (admin only).\n */\n const sendAffiliateInvitation = async (\n body: SendAffiliateInvitationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SendAffiliateInvitationResult>(\n `${STRIPE_API_ROUTE}/affiliate/invite`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Retrieves an affiliate invitation by token (public — no auth required).\n */\n const getAffiliateInvitation = async (\n { token }: { token: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateInvitationResult>(\n `${STRIPE_API_ROUTE}/affiliate/invitation/${token}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Admin-only: updates an affiliate's status and/or category.\n */\n const updateAffiliateStatus = async (\n { id }: { id: string },\n body: UpdateAffiliateStatusBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateAffiliateStatusResult>(\n `${STRIPE_API_ROUTE}/affiliates/${id}/status`,\n authAPIOptions,\n otherOptions,\n { method: 'PATCH', body }\n );\n\n /**\n * Accepts an affiliate invitation and creates the affiliate account.\n */\n const acceptAffiliateInvitation = async (\n {\n token,\n country,\n stripeAccountType,\n }: {\n token: string;\n country?: string;\n stripeAccountType?: 'express' | 'standard';\n },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AcceptAffiliateInvitationResult>(\n `${STRIPE_API_ROUTE}/affiliate/invitation/${token}/accept`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body: { country, stripeAccountType } }\n );\n\n /**\n * Admin-only: returns a paginated list of all promo codes.\n */\n const getPromoCodeById = async (\n id: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetPromoCodeByIdResult>(\n `${STRIPE_API_ROUTE}/promo-codes/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const getPromoCodes = async (\n params: { affiliateId?: string } = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const qs = params.affiliateId\n ? `?affiliateId=${encodeURIComponent(params.affiliateId)}`\n : '';\n return await fetcher<GetPromoCodesResult>(\n `${STRIPE_API_ROUTE}/promo-codes${qs}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n /**\n * Admin-only: creates a new promo code (Stripe coupon + promotion code).\n */\n const createPromoCode = async (\n body: CreatePromoCodeBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreatePromoCodeResult>(\n `${STRIPE_API_ROUTE}/promo-codes`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Admin-only: updates a promo code.\n */\n const updatePromoCode = async (\n { id, ...body }: { id: string } & UpdatePromoCodeBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdatePromoCodeResult>(\n `${STRIPE_API_ROUTE}/promo-codes/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'PATCH', body }\n );\n\n /**\n * Admin-only: deactivates a promo code (sets active=false, disables Stripe promotion code).\n */\n const deletePromoCode = async (\n { id }: { id: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeletePromoCodeResult>(\n `${STRIPE_API_ROUTE}/promo-codes/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Retrieves the active promo code associated with a given affiliate referral code.\n */\n const getAffiliatePromoCode = async (\n referralCode: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<any>(\n `${STRIPE_API_ROUTE}/affiliate-promo-code/${referralCode}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n return {\n getPricing,\n getSubscription,\n cancelSubscription,\n getInvoices,\n getPaymentMethod,\n createPortalSession,\n grantAffiliateAccess,\n getAffiliates,\n getAffiliateById,\n getAffiliate,\n getAffiliateAccountSession,\n getAffiliateOnboardingLink,\n getAffiliateStats,\n getAffiliateInvitations,\n sendAffiliateInvitation,\n getAffiliateInvitation,\n acceptAffiliateInvitation,\n updateAffiliateStatus,\n getPromoCodeById,\n getPromoCodes,\n createPromoCode,\n updatePromoCode,\n deletePromoCode,\n getAffiliatePromoCode,\n };\n};\n\n/**\n * Authenticated `stripe` 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 stripeEndpoint = createEndpoint(getStripeAPI);\n"],"mappings":";;;;;AAqCA,MAAa,gBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,mBAAmB,GAFN,gBAAgB,QAAQ,cAAc,OAAO,WAEzB;;;;;CAMvC,MAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,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AAiB,eAAe,YAAY"}
@@ -1,4 +1,5 @@
1
1
  import { fetcher } from "../fetcher.mjs";
2
+ import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
2
3
  import { editor } from "@intlayer/config/built";
3
4
 
4
5
  //#region src/getIntlayerAPI/tag.ts
@@ -40,7 +41,14 @@ const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
40
41
  deleteTag
41
42
  };
42
43
  };
44
+ /**
45
+ * Authenticated `tag` endpoint bound to an Intlayer CMS authenticator.
46
+ *
47
+ * Pass an authenticator created with `createIntlayerCMS`, or omit it to use
48
+ * the build-time configuration (`@intlayer/config/built`).
49
+ */
50
+ const tagEndpoint = createEndpoint(getTagAPI);
43
51
 
44
52
  //#endregion
45
- export { getTagAPI };
53
+ export { getTagAPI, tagEndpoint };
46
54
  //# sourceMappingURL=tag.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tag.mjs","names":[],"sources":["../../../src/getIntlayerAPI/tag.ts"],"sourcesContent":["import type {\n AddTagBody,\n AddTagResult,\n DeleteTagParams,\n DeleteTagResult,\n GetTagsParams,\n GetTagsResult,\n UpdateTagBody,\n UpdateTagParams,\n UpdateTagResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getTagAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/tag`;\n\n /**\n * Retrieves a list of tags based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getTags = async (\n filters?: GetTagsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetTagsResult>(\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 * Adds a new tag to the database.\n * @param tag - Tag data.\n */\n const addTag = async (tag: AddTagBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<AddTagResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: tag,\n }\n );\n\n /**\n * Updates an existing tag in the database.\n * @param tag - Updated tag data.\n */\n const updateTag = async (\n tagId: UpdateTagParams['tagId'],\n tag: UpdateTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: tag,\n }\n );\n\n /**\n * Deletes a tag from the database by its ID.\n * @param tagId - Tag ID.\n */\n const deleteTag = async (\n tagId: DeleteTagParams['tagId'],\n\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n getTags,\n addTag,\n updateTag,\n deleteTag,\n };\n};\n"],"mappings":";;;;AAeA,MAAa,aACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,oBAAoB,GAFP,gBAAgB,QAAQ,cAAc,OAAO,WAExB;;;;;CAMxC,MAAM,UAAU,OACd,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;CAMH,MAAM,SAAS,OAAO,KAAiB,eAA+B,EAAE,KACtE,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,YAAY,OAChB,OACA,KACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,YAAY,OAChB,OAEA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA,EACE,QAAQ,UACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"tag.mjs","names":[],"sources":["../../../src/getIntlayerAPI/tag.ts"],"sourcesContent":["import type {\n AddTagBody,\n AddTagResult,\n DeleteTagParams,\n DeleteTagResult,\n GetTagsParams,\n GetTagsResult,\n UpdateTagBody,\n UpdateTagParams,\n UpdateTagResult,\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 getTagAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/tag`;\n\n /**\n * Retrieves a list of tags based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getTags = async (\n filters?: GetTagsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetTagsResult>(\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 * Adds a new tag to the database.\n * @param tag - Tag data.\n */\n const addTag = async (tag: AddTagBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<AddTagResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: tag,\n }\n );\n\n /**\n * Updates an existing tag in the database.\n * @param tag - Updated tag data.\n */\n const updateTag = async (\n tagId: UpdateTagParams['tagId'],\n tag: UpdateTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: tag,\n }\n );\n\n /**\n * Deletes a tag from the database by its ID.\n * @param tagId - Tag ID.\n */\n const deleteTag = async (\n tagId: DeleteTagParams['tagId'],\n\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n getTags,\n addTag,\n updateTag,\n deleteTag,\n };\n};\n\n/**\n * Authenticated `tag` 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 tagEndpoint = createEndpoint(getTagAPI);\n"],"mappings":";;;;;AAgBA,MAAa,aACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,oBAAoB,GAFP,gBAAgB,QAAQ,cAAc,OAAO,WAExB;;;;;CAMxC,MAAM,UAAU,OACd,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;;CAMF,MAAM,SAAS,OAAO,KAAiB,eAA+B,CAAC,MACrE,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,YAAY,OAChB,OACA,KACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,YAAY,OAChB,OAEA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA,EACE,QAAQ,SACV,CACF;CAEF,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,cAAc,eAAe,SAAS"}
@@ -1,4 +1,5 @@
1
1
  import { fetcher } from "../fetcher.mjs";
2
+ import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
2
3
  import { editor } from "@intlayer/config/built";
3
4
 
4
5
  //#region src/getIntlayerAPI/translate.ts
@@ -22,7 +23,14 @@ const getTranslateAPI = (authAPIOptions = {}, intlayerConfig) => {
22
23
  restartTranslationJob
23
24
  };
24
25
  };
26
+ /**
27
+ * Authenticated `translate` endpoint bound to an Intlayer CMS authenticator.
28
+ *
29
+ * Pass an authenticator created with `createIntlayerCMS`, or omit it to use
30
+ * the build-time configuration (`@intlayer/config/built`).
31
+ */
32
+ const translateEndpoint = createEndpoint(getTranslateAPI);
25
33
 
26
34
  //#endregion
27
- export { getTranslateAPI };
35
+ export { getTranslateAPI, translateEndpoint };
28
36
  //# sourceMappingURL=translate.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"translate.mjs","names":[],"sources":["../../../src/getIntlayerAPI/translate.ts"],"sourcesContent":["import type {\n TranslateDictionariesBody,\n TranslateDictionariesResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type { TranslateDictionariesBody, TranslateDictionariesResult };\n\nexport const getTranslateAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const TRANSLATE_API_ROUTE = `${backendURL}/api/translate`;\n\n const translateDictionaries = async (\n body: TranslateDictionariesBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<TranslateDictionariesResult>(\n `${TRANSLATE_API_ROUTE}/dictionaries`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const pauseTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/pause`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const resumeTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/resume`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const stopTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/stop`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const retryTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/retry`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const restartTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/restart`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n return {\n translateDictionaries,\n pauseTranslationJob,\n resumeTranslationJob,\n stopTranslationJob,\n retryTranslationJob,\n restartTranslationJob,\n };\n};\n"],"mappings":";;;;AAUA,MAAa,mBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,sBAAsB,GAFT,gBAAgB,QAAQ,cAAc,OAAO,WAEtB;CAE1C,MAAM,wBAAwB,OAC5B,MACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,gBACvB,gBACA,cACA;EAAE,QAAQ;EAAQ;EAAM,CACzB;CAEH,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,uBAAuB,OAC3B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,UAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,qBAAqB,OACzB,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,QAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,wBAAwB,OAC5B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,WAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"translate.mjs","names":[],"sources":["../../../src/getIntlayerAPI/translate.ts"],"sourcesContent":["import type {\n TranslateDictionariesBody,\n TranslateDictionariesResult,\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 type { TranslateDictionariesBody, TranslateDictionariesResult };\n\nexport const getTranslateAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const TRANSLATE_API_ROUTE = `${backendURL}/api/translate`;\n\n const translateDictionaries = async (\n body: TranslateDictionariesBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<TranslateDictionariesResult>(\n `${TRANSLATE_API_ROUTE}/dictionaries`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const pauseTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/pause`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const resumeTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/resume`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const stopTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/stop`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const retryTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/retry`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const restartTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/restart`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n return {\n translateDictionaries,\n pauseTranslationJob,\n resumeTranslationJob,\n stopTranslationJob,\n retryTranslationJob,\n restartTranslationJob,\n };\n};\n\n/**\n * Authenticated `translate` 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 translateEndpoint = createEndpoint(getTranslateAPI);\n"],"mappings":";;;;;AAWA,MAAa,mBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,sBAAsB,GAFT,gBAAgB,QAAQ,cAAc,OAAO,WAEtB;CAE1C,MAAM,wBAAwB,OAC5B,MACA,eAA+B,CAAC,MAEhC,QACE,GAAG,oBAAoB,gBACvB,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;CAEF,MAAM,sBAAsB,OAC1B,OACA,eAA+B,CAAC,MAEhC,QACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;CAEF,MAAM,uBAAuB,OAC3B,OACA,eAA+B,CAAC,MAEhC,QACE,GAAG,oBAAoB,GAAG,MAAM,UAChC,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;CAEF,MAAM,qBAAqB,OACzB,OACA,eAA+B,CAAC,MAEhC,QACE,GAAG,oBAAoB,GAAG,MAAM,QAChC,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;CAEF,MAAM,sBAAsB,OAC1B,OACA,eAA+B,CAAC,MAEhC,QACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;CAEF,MAAM,wBAAwB,OAC5B,OACA,eAA+B,CAAC,MAEhC,QACE,GAAG,oBAAoB,GAAG,MAAM,WAChC,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,oBAAoB,eAAe,eAAe"}
@@ -1,4 +1,5 @@
1
1
  import { fetcher } from "../fetcher.mjs";
2
+ import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
2
3
  import { editor } from "@intlayer/config/built";
3
4
 
4
5
  //#region src/getIntlayerAPI/user.ts
@@ -98,7 +99,14 @@ const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
98
99
  getVerifyEmailStatusURL
99
100
  };
100
101
  };
102
+ /**
103
+ * Authenticated `user` endpoint bound to an Intlayer CMS authenticator.
104
+ *
105
+ * Pass an authenticator created with `createIntlayerCMS`, or omit it to use
106
+ * the build-time configuration (`@intlayer/config/built`).
107
+ */
108
+ const userEndpoint = createEndpoint(getUserAPI);
101
109
 
102
110
  //#endregion
103
- export { getUserAPI };
111
+ export { getUserAPI, userEndpoint };
104
112
  //# sourceMappingURL=user.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.mjs","names":[],"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import type {\n CreateUserBody,\n CreateUserResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n UpdateUserBody,\n UpdateUserResult,\n UploadUserAvatarResult,\n UserAPI,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\ntype GetUserByAccountParams = { providerAccountId: string; provider: string };\ntype GetUserByAccountResult = import('@intlayer/backend').ResponseData<UserAPI>;\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const USER_API_ROUTE = `${backendURL}/api/user`;\n\n /**\n * Retrieves a list of users based on filters and pagination.\n * @param filters - Filters and pagination options.\n * @returns List of users.\n */\n const getUsers = async (\n filters?: GetUsersParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUsersResult>(\n USER_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 user by ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const getUserById = async (\n userId: GetUserByIdParams['userId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByIdResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by email.\n * @param email - User email.\n * @returns User object.\n */\n const getUserByEmail = async (\n email: GetUserByEmailParams['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByEmailResult>(\n `${USER_API_ROUTE}/email/${email}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by account.\n * @param providerAccountId - The provider account ID.\n * @param provider - The provider of the account.\n */\n const getUserByAccount = async (\n providerAccountId: GetUserByAccountParams['providerAccountId'],\n provider: GetUserByAccountParams['provider'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByAccountResult>(\n `${USER_API_ROUTE}/account/${provider}/${providerAccountId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Creates a new user.\n * @param user - User credentials.\n * @returns User object.\n */\n const createUser = async (\n user: CreateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateUserResult>(\n `${USER_API_ROUTE}/`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Updates the user with the provided data.\n * @param user - Updated user data.\n * @returns User object.\n */\n const updateUser = async (\n user: UpdateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: user,\n }\n );\n\n /**\n * Deletes a user with the provided ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const deleteUser = async (\n userId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Uploads a new avatar for the authenticated user.\n * @param file - The image File object to upload.\n * @returns Updated user object.\n */\n const uploadAvatar = async (\n file: File,\n otherOptions: FetcherOptions = {}\n ) => {\n const buffer = await file.arrayBuffer();\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': file.type || 'image/jpeg',\n };\n\n // Forward auth cookies / credentials from authAPIOptions headers\n const authHeaders =\n (authAPIOptions.headers as Record<string, string> | undefined) ?? {};\n\n const response = await fetch(`${USER_API_ROUTE}/avatar`, {\n method: 'POST',\n credentials: 'include',\n headers: { ...authHeaders, ...baseHeaders },\n body: buffer,\n signal: otherOptions.signal as AbortSignal | undefined,\n });\n\n if (!response.ok) {\n const result = await response.json();\n throw new Error(JSON.stringify(result.error) ?? 'Avatar upload failed');\n }\n\n return (await response.json()) as UploadUserAvatarResult;\n };\n\n /**\n * Gets the verify email status URL to use in the SSE.\n * @param userId - User ID.\n * @returns The verify email status URL.\n */\n const getVerifyEmailStatusURL = (userId: string | UserAPI['id']) =>\n `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;\n\n return {\n createUser,\n getUsers,\n getUserById,\n getUserByAccount,\n getUserByEmail,\n updateUser,\n deleteUser,\n uploadAvatar,\n getVerifyEmailStatusURL,\n };\n};\n"],"mappings":";;;;AAqBA,MAAa,cACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,iBAAiB,GAFJ,gBAAgB,QAAQ,cAAc,OAAO,WAE3B;;;;;;CAOrC,MAAM,WAAW,OACf,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,gBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;;CAOH,MAAM,cAAc,OAClB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,iBAAiB,OACrB,OACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,SAAS,SAC3B,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,mBAAmB,OACvB,mBACA,UACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,WAAW,SAAS,GAAG,qBACzC,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,IAClB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,QAAQ,UACT,CACF;;;;;;CAOH,MAAM,eAAe,OACnB,MACA,eAA+B,EAAE,KAC9B;EACH,MAAM,SAAS,MAAM,KAAK,aAAa;EAEvC,MAAM,cAAsC,EAC1C,gBAAgB,KAAK,QAAQ,cAC9B;EAGD,MAAM,cACH,eAAe,WAAkD,EAAE;EAEtE,MAAM,WAAW,MAAM,MAAM,GAAG,eAAe,UAAU;GACvD,QAAQ;GACR,aAAa;GACb,SAAS;IAAE,GAAG;IAAa,GAAG;IAAa;GAC3C,MAAM;GACN,QAAQ,aAAa;GACtB,CAAC;AAEF,MAAI,CAAC,SAAS,IAAI;GAChB,MAAM,SAAS,MAAM,SAAS,MAAM;AACpC,SAAM,IAAI,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,uBAAuB;;AAGzE,SAAQ,MAAM,SAAS,MAAM;;;;;;;CAQ/B,MAAM,2BAA2B,WAC/B,GAAG,eAAe,uBAAuB,OAAO,OAAO;AAEzD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"user.mjs","names":[],"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import type {\n CreateUserBody,\n CreateUserResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n ResponseData,\n UpdateUserBody,\n UpdateUserResult,\n UploadUserAvatarResult,\n UserAPI,\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\ntype GetUserByAccountParams = { providerAccountId: string; provider: string };\ntype GetUserByAccountResult = ResponseData<UserAPI>;\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const USER_API_ROUTE = `${backendURL}/api/user`;\n\n /**\n * Retrieves a list of users based on filters and pagination.\n * @param filters - Filters and pagination options.\n * @returns List of users.\n */\n const getUsers = async (\n filters?: GetUsersParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUsersResult>(\n USER_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 user by ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const getUserById = async (\n userId: GetUserByIdParams['userId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByIdResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by email.\n * @param email - User email.\n * @returns User object.\n */\n const getUserByEmail = async (\n email: GetUserByEmailParams['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByEmailResult>(\n `${USER_API_ROUTE}/email/${email}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by account.\n * @param providerAccountId - The provider account ID.\n * @param provider - The provider of the account.\n */\n const getUserByAccount = async (\n providerAccountId: GetUserByAccountParams['providerAccountId'],\n provider: GetUserByAccountParams['provider'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByAccountResult>(\n `${USER_API_ROUTE}/account/${provider}/${providerAccountId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Creates a new user.\n * @param user - User credentials.\n * @returns User object.\n */\n const createUser = async (\n user: CreateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateUserResult>(\n `${USER_API_ROUTE}/`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Updates the user with the provided data.\n * @param user - Updated user data.\n * @returns User object.\n */\n const updateUser = async (\n user: UpdateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: user,\n }\n );\n\n /**\n * Deletes a user with the provided ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const deleteUser = async (\n userId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Uploads a new avatar for the authenticated user.\n * @param file - The image File object to upload.\n * @returns Updated user object.\n */\n const uploadAvatar = async (\n file: File,\n otherOptions: FetcherOptions = {}\n ) => {\n const buffer = await file.arrayBuffer();\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': file.type || 'image/jpeg',\n };\n\n // Forward auth cookies / credentials from authAPIOptions headers\n const authHeaders =\n (authAPIOptions.headers as Record<string, string> | undefined) ?? {};\n\n const response = await fetch(`${USER_API_ROUTE}/avatar`, {\n method: 'POST',\n credentials: 'include',\n headers: { ...authHeaders, ...baseHeaders },\n body: buffer,\n signal: otherOptions.signal as AbortSignal | undefined,\n });\n\n if (!response.ok) {\n const result = await response.json();\n throw new Error(JSON.stringify(result.error) ?? 'Avatar upload failed');\n }\n\n return (await response.json()) as UploadUserAvatarResult;\n };\n\n /**\n * Gets the verify email status URL to use in the SSE.\n * @param userId - User ID.\n * @returns The verify email status URL.\n */\n const getVerifyEmailStatusURL = (userId: string | UserAPI['id']) =>\n `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;\n\n return {\n createUser,\n getUsers,\n getUserById,\n getUserByAccount,\n getUserByEmail,\n updateUser,\n deleteUser,\n uploadAvatar,\n getVerifyEmailStatusURL,\n };\n};\n\n/**\n * Authenticated `user` 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 userEndpoint = createEndpoint(getUserAPI);\n"],"mappings":";;;;;AAuBA,MAAa,cACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,iBAAiB,GAFJ,gBAAgB,QAAQ,cAAc,OAAO,WAE3B;;;;;;CAOrC,MAAM,WAAW,OACf,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,gBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;;;CAOF,MAAM,cAAc,OAClB,QACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,OAAO,WACT,CACF;;;;;;CAOF,MAAM,iBAAiB,OACrB,OACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,eAAe,SAAS,SAC3B,gBACA,cACA,EACE,OAAO,WACT,CACF;;;;;;CAOF,MAAM,mBAAmB,OACvB,mBACA,UACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,eAAe,WAAW,SAAS,GAAG,qBACzC,gBACA,cACA,EACE,OAAO,WACT,CACF;;;;;;CAOF,MAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,eAAe,IAClB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;;CAOF,MAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;;CAOF,MAAM,aAAa,OACjB,QACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,QAAQ,SACV,CACF;;;;;;CAOF,MAAM,eAAe,OACnB,MACA,eAA+B,CAAC,MAC7B;EACH,MAAM,SAAS,MAAM,KAAK,YAAY;EAEtC,MAAM,cAAsC,EAC1C,gBAAgB,KAAK,QAAQ,aAC/B;EAGA,MAAM,cACH,eAAe,WAAkD,CAAC;EAErE,MAAM,WAAW,MAAM,MAAM,GAAG,eAAe,UAAU;GACvD,QAAQ;GACR,aAAa;GACb,SAAS;IAAE,GAAG;IAAa,GAAG;GAAY;GAC1C,MAAM;GACN,QAAQ,aAAa;EACvB,CAAC;EAED,IAAI,CAAC,SAAS,IAAI;GAChB,MAAM,SAAS,MAAM,SAAS,KAAK;GACnC,MAAM,IAAI,MAAM,KAAK,UAAU,OAAO,KAAK,KAAK,sBAAsB;EACxE;EAEA,OAAQ,MAAM,SAAS,KAAK;CAC9B;;;;;;CAOA,MAAM,2BAA2B,WAC/B,GAAG,eAAe,uBAAuB,OAAO,MAAM;CAExD,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,eAAe,eAAe,UAAU"}
@@ -1,27 +1,31 @@
1
1
  import { fetcher, fetcherOptions } from "./fetcher.mjs";
2
- import { getAiAPI } from "./getIntlayerAPI/ai.mjs";
3
- import { getAssetAPI } from "./getIntlayerAPI/asset.mjs";
4
- import { getAuditAPI } from "./getIntlayerAPI/audit.mjs";
5
- import { getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
6
- import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
7
- import { getEditorAPI } from "./getIntlayerAPI/editor.mjs";
8
- import { getEnvironmentAPI } from "./getIntlayerAPI/environment.mjs";
9
- import { getGithubAPI } from "./getIntlayerAPI/github.mjs";
10
- import { getGitlabAPI } from "./getIntlayerAPI/gitlab.mjs";
11
- import { getNewsletterAPI } from "./getIntlayerAPI/newsletter.mjs";
12
2
  import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
13
- import { getOrganizationAPI } from "./getIntlayerAPI/organization.mjs";
14
- import { getProjectAPI } from "./getIntlayerAPI/project.mjs";
15
- import { getReviewerAPI } from "./getIntlayerAPI/reviewer.mjs";
16
- import { getSearchAPI } from "./getIntlayerAPI/search.mjs";
17
- import { getShowcaseProjectAPI } from "./getIntlayerAPI/showcaseProject.mjs";
18
- import { getStripeAPI } from "./getIntlayerAPI/stripe.mjs";
19
- import { getTagAPI } from "./getIntlayerAPI/tag.mjs";
20
- import { getTranslateAPI } from "./getIntlayerAPI/translate.mjs";
21
- import { getUserAPI } from "./getIntlayerAPI/user.mjs";
22
- import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
3
+ import { createAuthManager } from "./cms/createAuthManager.mjs";
4
+ import { createEndpoint, createIntlayerCMS } from "./cms/createIntlayerCMS.mjs";
5
+ import { aiEndpoint, getAiAPI } from "./getIntlayerAPI/ai.mjs";
6
+ import { analyticsEndpoint, getAnalyticsAPI } from "./getIntlayerAPI/analytics.mjs";
7
+ import { assetEndpoint, getAssetAPI } from "./getIntlayerAPI/asset.mjs";
8
+ import { auditEndpoint, getAuditAPI } from "./getIntlayerAPI/audit.mjs";
9
+ import { bitbucketEndpoint, getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
10
+ import { dictionaryEndpoint, getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
11
+ import { editorEndpoint, getEditorAPI } from "./getIntlayerAPI/editor.mjs";
12
+ import { environmentEndpoint, getEnvironmentAPI } from "./getIntlayerAPI/environment.mjs";
13
+ import { getGithubAPI, githubEndpoint } from "./getIntlayerAPI/github.mjs";
14
+ import { getGitlabAPI, gitlabEndpoint } from "./getIntlayerAPI/gitlab.mjs";
15
+ import { getNewsletterAPI, newsletterEndpoint } from "./getIntlayerAPI/newsletter.mjs";
16
+ import { getOrganizationAPI, organizationEndpoint } from "./getIntlayerAPI/organization.mjs";
17
+ import { getProjectAPI, projectEndpoint } from "./getIntlayerAPI/project.mjs";
18
+ import { getReviewerAPI, reviewerEndpoint } from "./getIntlayerAPI/reviewer.mjs";
19
+ import { getSearchAPI, searchEndpoint } from "./getIntlayerAPI/search.mjs";
20
+ import { getShowcaseProjectAPI, showcaseProjectEndpoint } from "./getIntlayerAPI/showcaseProject.mjs";
21
+ import { getStatusAPI, statusEndpoint } from "./getIntlayerAPI/status.mjs";
22
+ import { getStripeAPI, stripeEndpoint } from "./getIntlayerAPI/stripe.mjs";
23
+ import { getTagAPI, tagEndpoint } from "./getIntlayerAPI/tag.mjs";
24
+ import { getTranslateAPI, translateEndpoint } from "./getIntlayerAPI/translate.mjs";
25
+ import { getUserAPI, userEndpoint } from "./getIntlayerAPI/user.mjs";
23
26
  import { getIntlayerAPIProxy } from "./proxy.mjs";
24
27
  import { fetchDistantDictionaries } from "./distantDictionary/fetchDistantDictionaries.mjs";
25
28
  import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.mjs";
29
+ import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
26
30
 
27
- export { fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAssetAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getEnvironmentAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getReviewerAPI, getSearchAPI, getShowcaseProjectAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI };
31
+ export { aiEndpoint, analyticsEndpoint, assetEndpoint, auditEndpoint, bitbucketEndpoint, createAuthManager, createEndpoint, createIntlayerCMS, dictionaryEndpoint, editorEndpoint, environmentEndpoint, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAnalyticsAPI, getAssetAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getEnvironmentAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getReviewerAPI, getSearchAPI, getShowcaseProjectAPI, getStatusAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI, githubEndpoint, gitlabEndpoint, newsletterEndpoint, organizationEndpoint, projectEndpoint, reviewerEndpoint, searchEndpoint, showcaseProjectEndpoint, statusEndpoint, stripeEndpoint, tagEndpoint, translateEndpoint, userEndpoint };
@@ -1,109 +1,94 @@
1
1
  import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
2
- import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
2
+ import { createIntlayerCMS } from "./cms/createIntlayerCMS.mjs";
3
+ import { getAiAPI } from "./getIntlayerAPI/ai.mjs";
4
+ import { getAnalyticsAPI } from "./getIntlayerAPI/analytics.mjs";
5
+ import { getAssetAPI } from "./getIntlayerAPI/asset.mjs";
6
+ import { getAuditAPI } from "./getIntlayerAPI/audit.mjs";
7
+ import { getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
8
+ import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
9
+ import { getEditorAPI } from "./getIntlayerAPI/editor.mjs";
10
+ import { getEnvironmentAPI } from "./getIntlayerAPI/environment.mjs";
11
+ import { getGithubAPI } from "./getIntlayerAPI/github.mjs";
12
+ import { getGitlabAPI } from "./getIntlayerAPI/gitlab.mjs";
13
+ import { getNewsletterAPI } from "./getIntlayerAPI/newsletter.mjs";
14
+ import { getOrganizationAPI } from "./getIntlayerAPI/organization.mjs";
15
+ import { getProjectAPI } from "./getIntlayerAPI/project.mjs";
16
+ import { getReviewerAPI } from "./getIntlayerAPI/reviewer.mjs";
17
+ import { getSearchAPI } from "./getIntlayerAPI/search.mjs";
18
+ import { getShowcaseProjectAPI } from "./getIntlayerAPI/showcaseProject.mjs";
19
+ import { getStatusAPI } from "./getIntlayerAPI/status.mjs";
20
+ import { getStripeAPI } from "./getIntlayerAPI/stripe.mjs";
21
+ import { getTagAPI } from "./getIntlayerAPI/tag.mjs";
22
+ import { getTranslateAPI } from "./getIntlayerAPI/translate.mjs";
23
+ import { getUserAPI } from "./getIntlayerAPI/user.mjs";
24
+ import { editor } from "@intlayer/config/built";
3
25
 
4
26
  //#region src/proxy.ts
5
- const ONE_MINUTE_MS = 6e4;
6
- /**
7
- * Returns the expiration timestamp in ms from an OAuth token-like object.
8
- */
9
- const getExpiryTimestamp = (token) => {
10
- if (!token) return void 0;
11
- const dateLike = token.accessTokenExpiresAt ?? token.expiresAt;
12
- if (dateLike) {
13
- const ts = typeof dateLike === "string" ? Date.parse(dateLike) : dateLike.getTime?.();
14
- if (typeof ts === "number" && Number.isFinite(ts)) return ts;
15
- }
16
- const seconds = token.expires_in ?? token.expiresIn;
17
- if (typeof seconds === "number" && Number.isFinite(seconds)) return Date.now() + seconds * 1e3;
27
+ const sectionFactories = {
28
+ asset: getAssetAPI,
29
+ organization: getOrganizationAPI,
30
+ project: getProjectAPI,
31
+ environment: getEnvironmentAPI,
32
+ user: getUserAPI,
33
+ oAuth: getOAuthAPI,
34
+ dictionary: getDictionaryAPI,
35
+ stripe: getStripeAPI,
36
+ ai: getAiAPI,
37
+ analytics: getAnalyticsAPI,
38
+ audit: getAuditAPI,
39
+ tag: getTagAPI,
40
+ search: getSearchAPI,
41
+ editor: getEditorAPI,
42
+ newsletter: getNewsletterAPI,
43
+ github: getGithubAPI,
44
+ gitlab: getGitlabAPI,
45
+ bitbucket: getBitbucketAPI,
46
+ showcaseProject: getShowcaseProjectAPI,
47
+ translate: getTranslateAPI,
48
+ reviewer: getReviewerAPI,
49
+ status: getStatusAPI
18
50
  };
19
- let currentAccessToken;
20
- let currentExpiryTs;
21
- let pendingRefresh;
51
+ const AUTH_FREE_SECTIONS = /* @__PURE__ */ new Set(["oAuth"]);
22
52
  /**
23
- * Build an auto-auth proxy around getIntlayerAPI that:
24
- * - Fetches an OAuth2 token when needed
25
- * - Injects Authorization header for each request
26
- * - Refreshes token proactively when near expiry
27
- *
28
- * When `sessionToken` is provided (a CLI session token starting with
29
- * "clisession_"), it is used directly as the Bearer token without any OAuth2
30
- * exchange — the backend validates it against the CliSessionToken collection.
53
+ * Builds the **complete** auto-authenticated Intlayer API as a single lazy
54
+ * object. Every domain is reachable through it, so it pulls every domain client
55
+ * into the bundle.
31
56
  *
32
- * The returned API matches the shape of getIntlayerAPI.
57
+ * Prefer {@link createIntlayerCMS} together with the per-domain endpoint binders
58
+ * (e.g. `dictionaryEndpoint`) in bundle-sensitive code — they include only the
59
+ * domains you use. This helper is a convenience for Node tools (such as the CLI)
60
+ * where bundle size is not a concern.
33
61
  */
34
- const getIntlayerAPIProxy = (baseAuthOptions = {}, intlayerConfig, sessionToken) => {
35
- const authOptionsRef = {
36
- ...baseAuthOptions,
37
- credentials: "omit"
38
- };
39
- const hasCMSAuth = Boolean(sessionToken) || Boolean(intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret);
40
- if (sessionToken) authOptionsRef.headers = {
41
- ...authOptionsRef.headers ?? {},
42
- Authorization: `Bearer ${sessionToken}`
43
- };
44
- const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);
45
- const needsRefresh = () => {
46
- if (!currentAccessToken) return true;
47
- if (!currentExpiryTs) return false;
48
- return Date.now() + ONE_MINUTE_MS >= currentExpiryTs;
62
+ const getIntlayerAPIProxy = (baseAuthOptions = {}, intlayerConfig = { editor }, sessionToken) => {
63
+ const cms = createIntlayerCMS(intlayerConfig, {
64
+ baseFetcherOptions: baseAuthOptions,
65
+ sessionToken
66
+ });
67
+ const sectionCache = /* @__PURE__ */ new Map();
68
+ const buildSection = (key) => {
69
+ const factory = sectionFactories[key];
70
+ return cms.bindSection(factory, { skipAuth: AUTH_FREE_SECTIONS.has(key) ? true : void 0 });
49
71
  };
50
- const refreshToken = async () => {
51
- const doRefresh = async () => {
52
- const tokenData = (await getOAuthAPI({}, intlayerConfig).getOAuth2AccessToken())?.data;
53
- currentAccessToken = tokenData?.accessToken;
54
- currentExpiryTs = getExpiryTimestamp(tokenData);
55
- };
56
- if (!pendingRefresh) pendingRefresh = doRefresh().finally(() => {
57
- pendingRefresh = void 0;
58
- });
59
- await pendingRefresh;
60
- };
61
- const ensureValidToken = async () => {
62
- if (needsRefresh()) await refreshToken();
63
- };
64
- const applyAuthHeaderToRef = () => {
65
- if (!currentAccessToken) return;
66
- authOptionsRef.headers = {
67
- ...authOptionsRef.headers ?? {},
68
- Authorization: `Bearer ${currentAccessToken}`
69
- };
70
- };
71
- const wrapSection = (section, skipAuth = !hasCMSAuth) => {
72
- return new Proxy(section, { get(target, prop, receiver) {
73
- const value = Reflect.get(target, prop, receiver);
74
- if (typeof value === "function") return async (...args) => {
75
- if (!skipAuth) if (sessionToken) {} else {
76
- await ensureValidToken();
77
- applyAuthHeaderToRef();
78
- }
79
- try {
80
- return await value.apply(target, args);
81
- } catch (err) {
82
- if (!skipAuth && !sessionToken) {
83
- await refreshToken();
84
- applyAuthHeaderToRef();
85
- return await value.apply(target, args);
86
- }
87
- throw err;
88
- }
72
+ return new Proxy({}, {
73
+ get(_target, property) {
74
+ const key = property;
75
+ if (!(key in sectionFactories)) return void 0;
76
+ if (!sectionCache.has(key)) sectionCache.set(key, buildSection(key));
77
+ return sectionCache.get(key);
78
+ },
79
+ has(_target, property) {
80
+ return property in sectionFactories;
81
+ },
82
+ ownKeys() {
83
+ return Reflect.ownKeys(sectionFactories);
84
+ },
85
+ getOwnPropertyDescriptor() {
86
+ return {
87
+ enumerable: true,
88
+ configurable: true
89
89
  };
90
- return value;
91
- } });
92
- };
93
- return {
94
- organization: wrapSection(baseApi.organization),
95
- project: wrapSection(baseApi.project),
96
- user: wrapSection(baseApi.user),
97
- oAuth: wrapSection(baseApi.oAuth, true),
98
- dictionary: wrapSection(baseApi.dictionary),
99
- stripe: wrapSection(baseApi.stripe),
100
- ai: wrapSection(baseApi.ai),
101
- tag: wrapSection(baseApi.tag),
102
- search: wrapSection(baseApi.search),
103
- editor: wrapSection(baseApi.editor),
104
- newsletter: wrapSection(baseApi.newsletter),
105
- github: wrapSection(baseApi.github)
106
- };
90
+ }
91
+ });
107
92
  };
108
93
 
109
94
  //#endregion