@intlayer/api 8.1.2 → 8.1.3-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  2. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +1 -20
  3. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  4. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +1 -22
  5. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  6. package/dist/cjs/distantDictionary/index.cjs +1 -6
  7. package/dist/cjs/fetcher.cjs +1 -122
  8. package/dist/cjs/fetcher.cjs.map +1 -1
  9. package/dist/cjs/getIntlayerAPI/ai.cjs +2 -166
  10. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  11. package/dist/cjs/getIntlayerAPI/audit.cjs +1 -41
  12. package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
  13. package/dist/cjs/getIntlayerAPI/bitbucket.cjs +1 -74
  14. package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
  15. package/dist/cjs/getIntlayerAPI/dictionary.cjs +1 -72
  16. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  17. package/dist/cjs/getIntlayerAPI/editor.cjs +1 -40
  18. package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
  19. package/dist/cjs/getIntlayerAPI/github.cjs +1 -74
  20. package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
  21. package/dist/cjs/getIntlayerAPI/gitlab.cjs +1 -88
  22. package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
  23. package/dist/cjs/getIntlayerAPI/index.cjs +1 -38
  24. package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
  25. package/dist/cjs/getIntlayerAPI/newsletter.cjs +1 -43
  26. package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
  27. package/dist/cjs/getIntlayerAPI/oAuth.cjs +1 -29
  28. package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
  29. package/dist/cjs/getIntlayerAPI/organization.cjs +1 -96
  30. package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
  31. package/dist/cjs/getIntlayerAPI/project.cjs +1 -144
  32. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  33. package/dist/cjs/getIntlayerAPI/search.cjs +1 -25
  34. package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
  35. package/dist/cjs/getIntlayerAPI/stripe.cjs +1 -41
  36. package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
  37. package/dist/cjs/getIntlayerAPI/tag.cjs +1 -50
  38. package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
  39. package/dist/cjs/getIntlayerAPI/user.cjs +1 -82
  40. package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
  41. package/dist/cjs/index.cjs +1 -43
  42. package/dist/cjs/proxy.cjs +1 -101
  43. package/dist/cjs/proxy.cjs.map +1 -1
  44. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +1 -19
  45. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  46. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +1 -21
  47. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  48. package/dist/esm/distantDictionary/index.mjs +1 -4
  49. package/dist/esm/fetcher.mjs +1 -119
  50. package/dist/esm/fetcher.mjs.map +1 -1
  51. package/dist/esm/getIntlayerAPI/ai.mjs +2 -163
  52. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  53. package/dist/esm/getIntlayerAPI/audit.mjs +1 -38
  54. package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
  55. package/dist/esm/getIntlayerAPI/bitbucket.mjs +1 -71
  56. package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
  57. package/dist/esm/getIntlayerAPI/dictionary.mjs +1 -69
  58. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  59. package/dist/esm/getIntlayerAPI/editor.mjs +1 -37
  60. package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
  61. package/dist/esm/getIntlayerAPI/github.mjs +1 -71
  62. package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
  63. package/dist/esm/getIntlayerAPI/gitlab.mjs +1 -85
  64. package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
  65. package/dist/esm/getIntlayerAPI/index.mjs +1 -37
  66. package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
  67. package/dist/esm/getIntlayerAPI/newsletter.mjs +1 -40
  68. package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
  69. package/dist/esm/getIntlayerAPI/oAuth.mjs +1 -26
  70. package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
  71. package/dist/esm/getIntlayerAPI/organization.mjs +1 -93
  72. package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
  73. package/dist/esm/getIntlayerAPI/project.mjs +1 -141
  74. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  75. package/dist/esm/getIntlayerAPI/search.mjs +1 -22
  76. package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
  77. package/dist/esm/getIntlayerAPI/stripe.mjs +1 -38
  78. package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
  79. package/dist/esm/getIntlayerAPI/tag.mjs +1 -47
  80. package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
  81. package/dist/esm/getIntlayerAPI/user.mjs +1 -79
  82. package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
  83. package/dist/esm/index.mjs +1 -22
  84. package/dist/esm/proxy.mjs +1 -100
  85. package/dist/esm/proxy.mjs.map +1 -1
  86. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"project.mjs","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetCIConfigResult,\n GetProjectsParams,\n GetProjectsResult,\n PushCIConfigResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '../types';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCIConfigResult>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<PushCIConfigResult>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n };\n};\n"],"mappings":";;;;AA+BA,MAAa,iBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,eAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,oBAAoB,GAAG,WAAW;;;;;CAMxC,MAAM,cAAc,OAClB,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;CAMH,MAAM,aAAa,OACjB,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,gBAAgB,OACpB,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,uBAAuB,OAC3B,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;CAKH,MAAM,2BAA2B,OAC/B,sBACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,iBACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,gBAAgB,OAAO,eAA+B,EAAE,KAC5D,MAAM,QACJ,GAAG,qBACH,gBACA,cACA,EACE,QAAQ,UACT,CACF;;;;;CAMH,MAAM,gBAAgB,OACpB,WACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,OAAO,UAAU,IACzC,gBACA,cACA,EACE,QAAQ,OACT,CACF;;;;;CAMH,MAAM,kBAAkB,OAAO,eAA+B,EAAE,KAC9D,MAAM,QACJ,GAAG,kBAAkB,UACrB,gBACA,cACA,EACE,QAAQ,QACT,CACF;;;;;;;CAQH,MAAM,kBAAkB,OACtB,WACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;;CAQH,MAAM,kBAAkB,OACtB,UACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,UAAU;EACnB,CACF;;;;;;;CAQH,MAAM,mBAAmB,OACvB,UACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,UAAU;EACnB,CACF;;;;;;CAOH,MAAM,eAAe,OAAO,eAA+B,EAAE,KAC3D,MAAM,QACJ,GAAG,kBAAkB,SACrB,gBACA,cACA,EACE,QAAQ,QACT,CACF;;;;;;;CAQH,MAAM,iBAAiB,OACrB,cACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,cAAc;EACvB,CACF;;;;;;CAOH,MAAM,cAAc,OAAO,eAA+B,EAAE,KAC1D,MAAM,QACJ,GAAG,kBAAkB,MACrB,gBACA,cACA,EACE,QAAQ,OACT,CACF;;;;;;CAOH,MAAM,eAAe,OAAO,eAA+B,EAAE,KAC3D,MAAM,QACJ,GAAG,kBAAkB,MACrB,gBACA,cACA,EACE,QAAQ,QACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"project.mjs","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetCIConfigResult,\n GetProjectsParams,\n GetProjectsResult,\n PushCIConfigResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '../types';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCIConfigResult>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<PushCIConfigResult>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n };\n};\n"],"mappings":"+EA+BA,MAAa,GACX,EAAiC,EAAE,CACnC,IACG,CACH,IAAM,EACJ,GAAgB,QAAQ,YAAc,GAAe,QAAQ,WAE/D,GAAI,CAAC,EACH,MAAU,MACR,4DACD,CAGH,IAAM,EAAoB,GAAG,EAAW,cAsQxC,MAAO,CACL,YAjQkB,MAClB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,EACA,EACA,EACA,CACE,MAAO,WAEP,OAAQ,EACT,CACF,CAqPD,WA/OiB,MACjB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,IACH,EACA,EACA,CACE,OAAQ,OACR,KAAM,EACP,CACF,CAoOD,cA9NoB,MACpB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,IACH,EACA,EACA,CACE,OAAQ,MACR,KAAM,EACP,CACF,CAmND,qBA7M2B,MAC3B,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAkB,UACrB,EACA,EACA,CACE,OAAQ,MACR,OACD,CACF,CAkMD,yBA7L+B,MAC/B,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAkB,gBACrB,EACA,EACA,CACE,OAAQ,MACR,KAAM,EACP,CACF,CAkLD,cA5KoB,MAAO,EAA+B,EAAE,GAC5D,MAAM,EACJ,GAAG,IACH,EACA,EACA,CACE,OAAQ,SACT,CACF,CAqKD,cA/JoB,MACpB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAkB,GAAG,OAAO,EAAU,GACzC,EACA,EACA,CACE,OAAQ,MACT,CACF,CAqJD,gBA/IsB,MAAO,EAA+B,EAAE,GAC9D,MAAM,EACJ,GAAG,EAAkB,SACrB,EACA,EACA,CACE,OAAQ,OACT,CACF,CAwID,gBAhIsB,MACtB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAkB,aACrB,EACA,EACA,CACE,OAAQ,OACR,KAAM,EACP,CACF,CAqHD,gBA7GsB,MACtB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAkB,aACrB,EACA,EACA,CACE,OAAQ,SACR,KAAM,CAAE,WAAU,CACnB,CACF,CAkGD,iBA1FuB,MACvB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAkB,aACrB,EACA,EACA,CACE,OAAQ,QACR,KAAM,CAAE,WAAU,CACnB,CACF,CA+ED,aAxEmB,MAAO,EAA+B,EAAE,GAC3D,MAAM,EACJ,GAAG,EAAkB,QACrB,EACA,EACA,CACE,OAAQ,OACT,CACF,CAiED,eAzDqB,MACrB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAkB,UACrB,EACA,EACA,CACE,OAAQ,OACR,KAAM,CAAE,eAAc,CACvB,CACF,CA8CD,YAvCkB,MAAO,EAA+B,EAAE,GAC1D,MAAM,EACJ,GAAG,EAAkB,KACrB,EACA,EACA,CACE,OAAQ,MACT,CACF,CAgCD,aAzBmB,MAAO,EAA+B,EAAE,GAC3D,MAAM,EACJ,GAAG,EAAkB,KACrB,EACA,EACA,CACE,OAAQ,OACT,CACF,CAkBF"}
@@ -1,23 +1,2 @@
1
- import { fetcher } from "../fetcher.mjs";
2
- import configuration from "@intlayer/config/built";
3
-
4
- //#region src/getIntlayerAPI/search.ts
5
- const getSearchAPI = (authAPIOptions = {}, intlayerConfig) => {
6
- const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;
7
- if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
8
- const AI_API_ROUTE = `${backendURL}/api/search`;
9
- /**
10
- * Search documentation
11
- * @param params - Search parameters containing the input query.
12
- * @returns Search results with GitHub URLs.
13
- */
14
- const searchDoc = async (params, otherOptions = {}) => await fetcher(`${AI_API_ROUTE}/doc`, authAPIOptions, otherOptions, {
15
- method: "GET",
16
- params
17
- });
18
- return { searchDoc };
19
- };
20
-
21
- //#endregion
22
- export { getSearchAPI };
1
+ import{fetcher as e}from"../fetcher.mjs";import t from"@intlayer/config/built";const n=(n={},r)=>{let i=r?.editor?.backendURL??t?.editor?.backendURL;if(!i)throw Error(`Backend URL is not defined in the Intlayer configuration.`);let a=`${i}/api/search`;return{searchDoc:async(t,r={})=>await e(`${a}/doc`,n,r,{method:`GET`,params:t})}};export{n as getSearchAPI};
23
2
  //# sourceMappingURL=search.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.mjs","names":[],"sources":["../../../src/getIntlayerAPI/search.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type { SearchDocUtilParams, SearchDocUtilResult } from '../types';\n\nexport const getSearchAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const AI_API_ROUTE = `${backendURL}/api/search`;\n\n /**\n * Search documentation\n * @param params - Search parameters containing the input query.\n * @returns Search results with GitHub URLs.\n */\n const searchDoc = async (\n params?: SearchDocUtilParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SearchDocUtilResult>(\n `${AI_API_ROUTE}/doc`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n params: params,\n }\n );\n\n return {\n searchDoc,\n };\n};\n"],"mappings":";;;;AAKA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,eAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,eAAe,GAAG,WAAW;;;;;;CAOnC,MAAM,YAAY,OAChB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,aAAa,OAChB,gBACA,cACA;EACE,QAAQ;EACA;EACT,CACF;AAEH,QAAO,EACL,WACD"}
1
+ {"version":3,"file":"search.mjs","names":[],"sources":["../../../src/getIntlayerAPI/search.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type { SearchDocUtilParams, SearchDocUtilResult } from '../types';\n\nexport const getSearchAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const AI_API_ROUTE = `${backendURL}/api/search`;\n\n /**\n * Search documentation\n * @param params - Search parameters containing the input query.\n * @returns Search results with GitHub URLs.\n */\n const searchDoc = async (\n params?: SearchDocUtilParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SearchDocUtilResult>(\n `${AI_API_ROUTE}/doc`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n params: params,\n }\n );\n\n return {\n searchDoc,\n };\n};\n"],"mappings":"+EAKA,MAAa,GACX,EAAiC,EAAE,CACnC,IACG,CACH,IAAM,EACJ,GAAgB,QAAQ,YAAc,GAAe,QAAQ,WAE/D,GAAI,CAAC,EACH,MAAU,MACR,4DACD,CAGH,IAAM,EAAe,GAAG,EAAW,aAqBnC,MAAO,CACL,UAfgB,MAChB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAa,MAChB,EACA,EACA,CACE,OAAQ,MACA,SACT,CACF,CAIF"}
@@ -1,39 +1,2 @@
1
- import { fetcher } from "../fetcher.mjs";
2
- import configuration from "@intlayer/config/built";
3
-
4
- //#region src/getIntlayerAPI/stripe.ts
5
- const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
6
- const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;
7
- if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
8
- const STRIPE_API_ROUTE = `${backendURL}/api/stripe`;
9
- /**
10
- * Get a pricing plan calculated for a given promotion code.
11
- * @param body - Pricing plan body.
12
- */
13
- const getPricing = async (body, otherOptions = {}) => await fetcher(`${STRIPE_API_ROUTE}/pricing`, authAPIOptions, otherOptions, {
14
- method: "POST",
15
- body
16
- });
17
- /**
18
- * Retrieves a checkout session.
19
- * @param body - Checkout session body.
20
- */
21
- const getSubscription = async (body, otherOptions = {}) => await fetcher(`${STRIPE_API_ROUTE}/create-subscription`, authAPIOptions, otherOptions, {
22
- method: "POST",
23
- body
24
- });
25
- /**
26
- * Cancels a subscription.
27
- * @param body - Checkout session body.
28
- */
29
- const cancelSubscription = async (otherOptions = {}) => await fetcher(`${STRIPE_API_ROUTE}/cancel-subscription`, authAPIOptions, otherOptions, { method: "POST" });
30
- return {
31
- getPricing,
32
- getSubscription,
33
- cancelSubscription
34
- };
35
- };
36
-
37
- //#endregion
38
- export { getStripeAPI };
1
+ import{fetcher as e}from"../fetcher.mjs";import t from"@intlayer/config/built";const n=(n={},r)=>{let i=r?.editor?.backendURL??t?.editor?.backendURL;if(!i)throw Error(`Backend URL is not defined in the Intlayer configuration.`);let a=`${i}/api/stripe`;return{getPricing:async(t,r={})=>await e(`${a}/pricing`,n,r,{method:`POST`,body:t}),getSubscription:async(t,r={})=>await e(`${a}/create-subscription`,n,r,{method:`POST`,body:t}),cancelSubscription:async(t={})=>await e(`${a}/cancel-subscription`,n,t,{method:`POST`})}};export{n as getStripeAPI};
39
2
  //# sourceMappingURL=stripe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.mjs","names":[],"sources":["../../../src/getIntlayerAPI/stripe.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n GetCheckoutSessionBody,\n GetCheckoutSessionResult,\n GetPricingBody,\n GetPricingResult,\n} from '../types';\n\nexport const getStripeAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const 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 return {\n getPricing,\n getSubscription,\n cancelSubscription,\n };\n};\n"],"mappings":";;;;AAUA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,eAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,mBAAmB,GAAG,WAAW;;;;;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;AAEH,QAAO;EACL;EACA;EACA;EACD"}
1
+ {"version":3,"file":"stripe.mjs","names":[],"sources":["../../../src/getIntlayerAPI/stripe.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n GetCheckoutSessionBody,\n GetCheckoutSessionResult,\n GetPricingBody,\n GetPricingResult,\n} from '../types';\n\nexport const getStripeAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const 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 return {\n getPricing,\n getSubscription,\n cancelSubscription,\n };\n};\n"],"mappings":"+EAUA,MAAa,GACX,EAAiC,EAAE,CACnC,IACG,CACH,IAAM,EACJ,GAAgB,QAAQ,YAAc,GAAe,QAAQ,WAE/D,GAAI,CAAC,EACH,MAAU,MACR,4DACD,CAGH,IAAM,EAAmB,GAAG,EAAW,aAoDvC,MAAO,CACL,WA/CiB,MACjB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAiB,UACpB,EACA,EACA,CACE,OAAQ,OACR,OACD,CACF,CAoCD,gBA9BsB,MACtB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAiB,sBACpB,EACA,EACA,CACE,OAAQ,OACR,OACD,CACF,CAmBD,mBAbyB,MAAO,EAA+B,EAAE,GACjE,MAAM,EACJ,GAAG,EAAiB,sBACpB,EACA,EACA,CACE,OAAQ,OACT,CACF,CAMF"}
@@ -1,48 +1,2 @@
1
- import { fetcher } from "../fetcher.mjs";
2
- import configuration from "@intlayer/config/built";
3
-
4
- //#region src/getIntlayerAPI/tag.ts
5
- const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
6
- const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;
7
- if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
8
- const PROJECT_API_ROUTE = `${backendURL}/api/tag`;
9
- /**
10
- * Retrieves a list of tags based on filters and pagination.
11
- * @param filters - Filters and pagination options.
12
- */
13
- const getTags = async (filters, otherOptions = {}) => await fetcher(PROJECT_API_ROUTE, authAPIOptions, otherOptions, {
14
- cache: "no-store",
15
- params: filters
16
- });
17
- /**
18
- * Adds a new tag to the database.
19
- * @param tag - Tag data.
20
- */
21
- const addTag = async (tag, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
22
- method: "POST",
23
- body: tag
24
- });
25
- /**
26
- * Updates an existing tag in the database.
27
- * @param tag - Updated tag data.
28
- */
29
- const updateTag = async (tagId, tag, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/${tagId}`, authAPIOptions, otherOptions, {
30
- method: "PUT",
31
- body: tag
32
- });
33
- /**
34
- * Deletes a tag from the database by its ID.
35
- * @param tagId - Tag ID.
36
- */
37
- const deleteTag = async (tagId, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/${tagId}`, authAPIOptions, otherOptions, { method: "DELETE" });
38
- return {
39
- getTags,
40
- addTag,
41
- updateTag,
42
- deleteTag
43
- };
44
- };
45
-
46
- //#endregion
47
- export { getTagAPI };
1
+ import{fetcher as e}from"../fetcher.mjs";import t from"@intlayer/config/built";const n=(n={},r)=>{let i=r?.editor?.backendURL??t?.editor?.backendURL;if(!i)throw Error(`Backend URL is not defined in the Intlayer configuration.`);let a=`${i}/api/tag`;return{getTags:async(t,r={})=>await e(a,n,r,{cache:`no-store`,params:t}),addTag:async(t,r={})=>await e(`${a}`,n,r,{method:`POST`,body:t}),updateTag:async(t,r,i={})=>await e(`${a}/${t}`,n,i,{method:`PUT`,body:r}),deleteTag:async(t,r={})=>await e(`${a}/${t}`,n,r,{method:`DELETE`})}};export{n as getTagAPI};
48
2
  //# sourceMappingURL=tag.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tag.mjs","names":[],"sources":["../../../src/getIntlayerAPI/tag.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddTagBody,\n AddTagResult,\n DeleteTagParams,\n DeleteTagResult,\n GetTagsParams,\n GetTagsResult,\n UpdateTagBody,\n UpdateTagParams,\n UpdateTagResult,\n} from '../types';\n\nexport const getTagAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/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;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,eAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,oBAAoB,GAAG,WAAW;;;;;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 configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddTagBody,\n AddTagResult,\n DeleteTagParams,\n DeleteTagResult,\n GetTagsParams,\n GetTagsResult,\n UpdateTagBody,\n UpdateTagParams,\n UpdateTagResult,\n} from '../types';\n\nexport const getTagAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/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":"+EAeA,MAAa,GACX,EAAiC,EAAE,CACnC,IACG,CACH,IAAM,EACJ,GAAgB,QAAQ,YAAc,GAAe,QAAQ,WAE/D,GAAI,CAAC,EACH,MAAU,MACR,4DACD,CAGH,IAAM,EAAoB,GAAG,EAAW,UAyExC,MAAO,CACL,QApEc,MACd,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,EACA,EACA,EACA,CACE,MAAO,WAEP,OAAQ,EACT,CACF,CAwDD,OAlDa,MAAO,EAAiB,EAA+B,EAAE,GACtE,MAAM,EACJ,GAAG,IACH,EACA,EACA,CACE,OAAQ,OACR,KAAM,EACP,CACF,CA0CD,UApCgB,MAChB,EACA,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAkB,GAAG,IACxB,EACA,EACA,CACE,OAAQ,MACR,KAAM,EACP,CACF,CAwBD,UAlBgB,MAChB,EAEA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAkB,GAAG,IACxB,EACA,EACA,CACE,OAAQ,SACT,CACF,CAOF"}
@@ -1,80 +1,2 @@
1
- import { fetcher } from "../fetcher.mjs";
2
- import configuration from "@intlayer/config/built";
3
-
4
- //#region src/getIntlayerAPI/user.ts
5
- const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
6
- const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;
7
- if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
8
- const USER_API_ROUTE = `${backendURL}/api/user`;
9
- /**
10
- * Retrieves a list of users based on filters and pagination.
11
- * @param filters - Filters and pagination options.
12
- * @returns List of users.
13
- */
14
- const getUsers = async (filters, otherOptions = {}) => await fetcher(USER_API_ROUTE, authAPIOptions, otherOptions, {
15
- cache: "no-store",
16
- params: filters
17
- });
18
- /**
19
- * Retrieves a user by ID.
20
- * @param userId - User ID.
21
- * @returns User object.
22
- */
23
- const getUserById = async (userId, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/${userId}`, authAPIOptions, otherOptions, { cache: "no-store" });
24
- /**
25
- * Retrieves a user by email.
26
- * @param email - User email.
27
- * @returns User object.
28
- */
29
- const getUserByEmail = async (email, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/email/${email}`, authAPIOptions, otherOptions, { cache: "no-store" });
30
- /**
31
- * Retrieves a user by account.
32
- * @param providerAccountId - The provider account ID.
33
- * @param provider - The provider of the account.
34
- */
35
- const getUserByAccount = async (providerAccountId, provider, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/account/${provider}/${providerAccountId}`, authAPIOptions, otherOptions, { cache: "no-store" });
36
- /**
37
- * Creates a new user.
38
- * @param user - User credentials.
39
- * @returns User object.
40
- */
41
- const createUser = async (user, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/`, authAPIOptions, otherOptions, {
42
- method: "POST",
43
- body: user
44
- });
45
- /**
46
- * Updates the user with the provided data.
47
- * @param user - Updated user data.
48
- * @returns User object.
49
- */
50
- const updateUser = async (user, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}`, authAPIOptions, otherOptions, {
51
- method: "PUT",
52
- body: user
53
- });
54
- /**
55
- * Deletes a user with the provided ID.
56
- * @param userId - User ID.
57
- * @returns User object.
58
- */
59
- const deleteUser = async (userId, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/${userId}`, authAPIOptions, otherOptions, { method: "DELETE" });
60
- /**
61
- * Gets the verify email status URL to use in the SSE.
62
- * @param userId - User ID.
63
- * @returns The verify email status URL.
64
- */
65
- const getVerifyEmailStatusURL = (userId) => `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;
66
- return {
67
- createUser,
68
- getUsers,
69
- getUserById,
70
- getUserByAccount,
71
- getUserByEmail,
72
- updateUser,
73
- deleteUser,
74
- getVerifyEmailStatusURL
75
- };
76
- };
77
-
78
- //#endregion
79
- export { getUserAPI };
1
+ import{fetcher as e}from"../fetcher.mjs";import t from"@intlayer/config/built";const n=(n={},r)=>{let i=r?.editor?.backendURL??t?.editor?.backendURL;if(!i)throw Error(`Backend URL is not defined in the Intlayer configuration.`);let a=`${i}/api/user`;return{createUser:async(t,r={})=>await e(`${a}/`,n,r,{method:`POST`,body:t}),getUsers:async(t,r={})=>await e(a,n,r,{cache:`no-store`,params:t}),getUserById:async(t,r={})=>await e(`${a}/${t}`,n,r,{cache:`no-store`}),getUserByAccount:async(t,r,i={})=>await e(`${a}/account/${r}/${t}`,n,i,{cache:`no-store`}),getUserByEmail:async(t,r={})=>await e(`${a}/email/${t}`,n,r,{cache:`no-store`}),updateUser:async(t,r={})=>await e(`${a}`,n,r,{method:`PUT`,body:t}),deleteUser:async(t,r={})=>await e(`${a}/${t}`,n,r,{method:`DELETE`}),getVerifyEmailStatusURL:e=>`${a}/verify-email-status/${String(e)}`}};export{n as getUserAPI};
80
2
  //# sourceMappingURL=user.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.mjs","names":[],"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n CreateUserBody,\n CreateUserResult,\n GetUserByAccountParams,\n GetUserByAccountResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n UpdateUserBody,\n UpdateUserResult,\n UserAPI,\n} from '../types';\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const 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 * 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 getVerifyEmailStatusURL,\n };\n};\n"],"mappings":";;;;AAmBA,MAAa,cACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,eAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,iBAAiB,GAAG,WAAW;;;;;;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,2BAA2B,WAC/B,GAAG,eAAe,uBAAuB,OAAO,OAAO;AAEzD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"user.mjs","names":[],"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n CreateUserBody,\n CreateUserResult,\n GetUserByAccountParams,\n GetUserByAccountResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n UpdateUserBody,\n UpdateUserResult,\n UserAPI,\n} from '../types';\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const 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 * 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 getVerifyEmailStatusURL,\n };\n};\n"],"mappings":"+EAmBA,MAAa,GACX,EAAiC,EAAE,CACnC,IACG,CACH,IAAM,EACJ,GAAgB,QAAQ,YAAc,GAAe,QAAQ,WAE/D,GAAI,CAAC,EACH,MAAU,MACR,4DACD,CAGH,IAAM,EAAiB,GAAG,EAAW,WA6IrC,MAAO,CACL,WA5DiB,MACjB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAe,GAClB,EACA,EACA,CACE,OAAQ,OACR,KAAM,EACP,CACF,CAiDD,SAxIe,MACf,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,EACA,EACA,EACA,CACE,MAAO,WAEP,OAAQ,EACT,CACF,CA4HD,YArHkB,MAClB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAe,GAAG,IACrB,EACA,EACA,CACE,MAAO,WACR,CACF,CA2GD,iBAlFuB,MACvB,EACA,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAe,WAAW,EAAS,GAAG,IACzC,EACA,EACA,CACE,MAAO,WACR,CACF,CAuED,eArGqB,MACrB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAe,SAAS,IAC3B,EACA,EACA,CACE,MAAO,WACR,CACF,CA2FD,WA9CiB,MACjB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,IACH,EACA,EACA,CACE,OAAQ,MACR,KAAM,EACP,CACF,CAmCD,WA5BiB,MACjB,EACA,EAA+B,EAAE,GAEjC,MAAM,EACJ,GAAG,EAAe,GAAG,IACrB,EACA,EACA,CACE,OAAQ,SACT,CACF,CAkBD,wBAX+B,GAC/B,GAAG,EAAe,uBAAuB,OAAO,EAAO,GAWxD"}
@@ -1,22 +1 @@
1
- import { fetcher, fetcherOptions } from "./fetcher.mjs";
2
- import { getAiAPI } from "./getIntlayerAPI/ai.mjs";
3
- import { getAuditAPI } from "./getIntlayerAPI/audit.mjs";
4
- import { getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
5
- import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
6
- import { getEditorAPI } from "./getIntlayerAPI/editor.mjs";
7
- import { getGithubAPI } from "./getIntlayerAPI/github.mjs";
8
- import { getGitlabAPI } from "./getIntlayerAPI/gitlab.mjs";
9
- import { getNewsletterAPI } from "./getIntlayerAPI/newsletter.mjs";
10
- import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
11
- import { getOrganizationAPI } from "./getIntlayerAPI/organization.mjs";
12
- import { getProjectAPI } from "./getIntlayerAPI/project.mjs";
13
- import { getSearchAPI } from "./getIntlayerAPI/search.mjs";
14
- import { getStripeAPI } from "./getIntlayerAPI/stripe.mjs";
15
- import { getTagAPI } from "./getIntlayerAPI/tag.mjs";
16
- import { getUserAPI } from "./getIntlayerAPI/user.mjs";
17
- import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
18
- import { getIntlayerAPIProxy } from "./proxy.mjs";
19
- import { fetchDistantDictionaries } from "./distantDictionary/fetchDistantDictionaries.mjs";
20
- import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.mjs";
21
-
22
- export { fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getSearchAPI, getStripeAPI, getTagAPI, getUserAPI };
1
+ import{fetcher as e,fetcherOptions as t}from"./fetcher.mjs";import{getAiAPI as n}from"./getIntlayerAPI/ai.mjs";import{getAuditAPI as r}from"./getIntlayerAPI/audit.mjs";import{getBitbucketAPI as i}from"./getIntlayerAPI/bitbucket.mjs";import{getDictionaryAPI as a}from"./getIntlayerAPI/dictionary.mjs";import{getEditorAPI as o}from"./getIntlayerAPI/editor.mjs";import{getGithubAPI as s}from"./getIntlayerAPI/github.mjs";import{getGitlabAPI as c}from"./getIntlayerAPI/gitlab.mjs";import{getNewsletterAPI as l}from"./getIntlayerAPI/newsletter.mjs";import{getOAuthAPI as u}from"./getIntlayerAPI/oAuth.mjs";import{getOrganizationAPI as d}from"./getIntlayerAPI/organization.mjs";import{getProjectAPI as f}from"./getIntlayerAPI/project.mjs";import{getSearchAPI as p}from"./getIntlayerAPI/search.mjs";import{getStripeAPI as m}from"./getIntlayerAPI/stripe.mjs";import{getTagAPI as h}from"./getIntlayerAPI/tag.mjs";import{getUserAPI as g}from"./getIntlayerAPI/user.mjs";import{getIntlayerAPI as _}from"./getIntlayerAPI/index.mjs";import{getIntlayerAPIProxy as v}from"./proxy.mjs";import{fetchDistantDictionaries as y}from"./distantDictionary/fetchDistantDictionaries.mjs";import{fetchDistantDictionary as b}from"./distantDictionary/fetchDistantDictionary.mjs";export{y as fetchDistantDictionaries,b as fetchDistantDictionary,e as fetcher,t as fetcherOptions,n as getAiAPI,r as getAuditAPI,i as getBitbucketAPI,a as getDictionaryAPI,o as getEditorAPI,s as getGithubAPI,c as getGitlabAPI,_ as getIntlayerAPI,v as getIntlayerAPIProxy,l as getNewsletterAPI,u as getOAuthAPI,d as getOrganizationAPI,f as getProjectAPI,p as getSearchAPI,m as getStripeAPI,h as getTagAPI,g as getUserAPI};
@@ -1,101 +1,2 @@
1
- import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
2
- import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
3
-
4
- //#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;
18
- };
19
- let currentAccessToken;
20
- let currentExpiryTs;
21
- let pendingRefresh;
22
- /**
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
- * The returned API matches the shape of getIntlayerAPI.
29
- */
30
- const getIntlayerAPIProxy = (_baseAuthOptions = {}, intlayerConfig) => {
31
- const authOptionsRef = { ..._baseAuthOptions };
32
- const hasCMSAuth = intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;
33
- const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);
34
- const needsRefresh = () => {
35
- if (!currentAccessToken) return true;
36
- if (!currentExpiryTs) return false;
37
- return Date.now() + ONE_MINUTE_MS >= currentExpiryTs;
38
- };
39
- const refreshToken = async () => {
40
- const doRefresh = async () => {
41
- const tokenData = (await getOAuthAPI(intlayerConfig).getOAuth2AccessToken())?.data;
42
- currentAccessToken = tokenData?.accessToken;
43
- currentExpiryTs = getExpiryTimestamp(tokenData);
44
- };
45
- if (!pendingRefresh) pendingRefresh = doRefresh().finally(() => {
46
- pendingRefresh = void 0;
47
- });
48
- await pendingRefresh;
49
- };
50
- const ensureValidToken = async () => {
51
- if (needsRefresh()) await refreshToken();
52
- };
53
- const applyAuthHeaderToRef = () => {
54
- if (!currentAccessToken) return;
55
- authOptionsRef.headers = {
56
- ...authOptionsRef.headers ?? {},
57
- Authorization: `Bearer ${currentAccessToken}`
58
- };
59
- };
60
- const wrapSection = (section, skipAuth = !hasCMSAuth) => {
61
- return new Proxy(section, { get(target, prop, receiver) {
62
- const value = Reflect.get(target, prop, receiver);
63
- if (typeof value === "function") return async (...args) => {
64
- if (!skipAuth) {
65
- await ensureValidToken();
66
- applyAuthHeaderToRef();
67
- }
68
- try {
69
- return await value.apply(target, args);
70
- } catch (err) {
71
- if (!skipAuth) {
72
- await refreshToken();
73
- applyAuthHeaderToRef();
74
- return await value.apply(target, args);
75
- }
76
- throw err;
77
- }
78
- };
79
- return value;
80
- } });
81
- };
82
- return {
83
- organization: wrapSection(baseApi.organization),
84
- project: wrapSection(baseApi.project),
85
- user: wrapSection(baseApi.user),
86
- oAuth: wrapSection(baseApi.oAuth, true),
87
- dictionary: wrapSection(baseApi.dictionary),
88
- stripe: wrapSection(baseApi.stripe),
89
- ai: wrapSection(baseApi.ai),
90
- tag: wrapSection(baseApi.tag),
91
- search: wrapSection(baseApi.search),
92
- editor: wrapSection(baseApi.editor),
93
- newsletter: wrapSection(baseApi.newsletter),
94
- github: wrapSection(baseApi.github),
95
- audit: wrapSection(baseApi.audit)
96
- };
97
- };
98
-
99
- //#endregion
100
- export { getIntlayerAPIProxy };
1
+ import{getOAuthAPI as e}from"./getIntlayerAPI/oAuth.mjs";import{getIntlayerAPI as t}from"./getIntlayerAPI/index.mjs";const n=e=>{if(!e)return;let t=e.accessTokenExpiresAt??e.expiresAt;if(t){let e=typeof t==`string`?Date.parse(t):t.getTime?.();if(typeof e==`number`&&Number.isFinite(e))return e}let n=e.expires_in??e.expiresIn;if(typeof n==`number`&&Number.isFinite(n))return Date.now()+n*1e3};let r,i,a;const o=(o={},s)=>{let c={...o},l=s?.editor?.clientId&&s?.editor?.clientSecret,u=t(c,s),d=()=>r?i?Date.now()+6e4>=i:!1:!0,f=async()=>{a||=(async()=>{let t=(await e(s).getOAuth2AccessToken())?.data;r=t?.accessToken,i=n(t)})().finally(()=>{a=void 0}),await a},p=async()=>{d()&&await f()},m=()=>{r&&(c.headers={...c.headers??{},Authorization:`Bearer ${r}`})},h=(e,t=!l)=>new Proxy(e,{get(e,n,r){let i=Reflect.get(e,n,r);return typeof i==`function`?async(...n)=>{t||(await p(),m());try{return await i.apply(e,n)}catch(r){if(!t)return await f(),m(),await i.apply(e,n);throw r}}:i}});return{organization:h(u.organization),project:h(u.project),user:h(u.user),oAuth:h(u.oAuth,!0),dictionary:h(u.dictionary),stripe:h(u.stripe),ai:h(u.ai),tag:h(u.tag),search:h(u.search),editor:h(u.editor),newsletter:h(u.newsletter),github:h(u.github),audit:h(u.audit)}};export{o as getIntlayerAPIProxy};
101
2
  //# sourceMappingURL=proxy.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.mjs","names":[],"sources":["../../src/proxy.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport type { FetcherOptions } from './fetcher';\nimport { getIntlayerAPI } from './getIntlayerAPI';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\n\ntype OAuthTokenLike = {\n accessToken?: string;\n accessTokenExpiresAt?: string | Date;\n expires_in?: number;\n expiresIn?: number;\n expiresAt?: string | Date;\n};\n\nconst ONE_MINUTE_MS = 60_000;\n\n/**\n * Returns the expiration timestamp in ms from an OAuth token-like object.\n */\nconst getExpiryTimestamp = (\n token: OAuthTokenLike | undefined\n): number | undefined => {\n if (!token) return undefined;\n const dateLike = (token.accessTokenExpiresAt ?? token.expiresAt) as\n | string\n | Date\n | undefined;\n if (dateLike) {\n const ts =\n typeof dateLike === 'string'\n ? Date.parse(dateLike)\n : dateLike.getTime?.();\n if (typeof ts === 'number' && Number.isFinite(ts)) return ts;\n }\n const seconds = token.expires_in ?? token.expiresIn;\n if (typeof seconds === 'number' && Number.isFinite(seconds)) {\n return Date.now() + seconds * 1000;\n }\n return undefined;\n};\n\nlet currentAccessToken: string | undefined;\nlet currentExpiryTs: number | undefined;\nlet pendingRefresh: Promise<void> | undefined;\n\n/**\n * Build an auto-auth proxy around getIntlayerAPI that:\n * - Fetches an OAuth2 token when needed\n * - Injects Authorization header for each request\n * - Refreshes token proactively when near expiry\n *\n * The returned API matches the shape of getIntlayerAPI.\n */\nexport const getIntlayerAPIProxy = (\n _baseAuthOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPI => {\n // Use a shared mutable auth options object captured by the API closures\n const authOptionsRef: FetcherOptions = { ..._baseAuthOptions };\n const hasCMSAuth =\n intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;\n const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);\n\n const needsRefresh = (): boolean => {\n if (!currentAccessToken) return true;\n if (!currentExpiryTs) return false; // If unknown, assume usable until failure\n\n return Date.now() + ONE_MINUTE_MS >= currentExpiryTs; // refresh 1 min before expiry\n };\n\n const refreshToken = async (): Promise<void> => {\n const doRefresh = async () => {\n const authApi = getOAuthAPI(intlayerConfig);\n const res = await authApi.getOAuth2AccessToken();\n const tokenData = res?.data as OAuthTokenLike | undefined;\n\n currentAccessToken = tokenData?.accessToken;\n currentExpiryTs = getExpiryTimestamp(tokenData);\n };\n\n if (!pendingRefresh) {\n pendingRefresh = doRefresh().finally(() => {\n pendingRefresh = undefined;\n });\n }\n await pendingRefresh;\n };\n\n const ensureValidToken = async () => {\n if (needsRefresh()) {\n await refreshToken();\n }\n };\n\n const applyAuthHeaderToRef = () => {\n if (!currentAccessToken) return;\n authOptionsRef.headers = {\n ...(authOptionsRef.headers ?? {}),\n Authorization: `Bearer ${currentAccessToken}`,\n } as HeadersInit;\n };\n\n const wrapSection = <T extends Record<string, unknown>>(\n section: T,\n skipAuth = !hasCMSAuth\n ): T => {\n return new Proxy(section, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === 'function') {\n // Wrap section method to inject token and headers\n return async (...args: unknown[]) => {\n if (!skipAuth) {\n await ensureValidToken();\n applyAuthHeaderToRef();\n }\n\n try {\n return await value.apply(target, args);\n } catch (err) {\n // Best-effort retry: if token might be stale, refresh once and retry\n if (!skipAuth) {\n await refreshToken();\n applyAuthHeaderToRef();\n return await value.apply(target, args);\n }\n throw err;\n }\n };\n }\n\n return value;\n },\n });\n };\n\n return {\n organization: wrapSection(baseApi.organization),\n project: wrapSection(baseApi.project),\n user: wrapSection(baseApi.user),\n oAuth: wrapSection(baseApi.oAuth, true), // do NOT inject auth for token endpoint\n dictionary: wrapSection(baseApi.dictionary),\n stripe: wrapSection(baseApi.stripe),\n ai: wrapSection(baseApi.ai),\n tag: wrapSection(baseApi.tag),\n search: wrapSection(baseApi.search),\n editor: wrapSection(baseApi.editor),\n newsletter: wrapSection(baseApi.newsletter),\n github: wrapSection(baseApi.github),\n audit: wrapSection(baseApi.audit),\n } as IntlayerAPI;\n};\n\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":";;;;AAcA,MAAM,gBAAgB;;;;AAKtB,MAAM,sBACJ,UACuB;AACvB,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,WAAY,MAAM,wBAAwB,MAAM;AAItD,KAAI,UAAU;EACZ,MAAM,KACJ,OAAO,aAAa,WAChB,KAAK,MAAM,SAAS,GACpB,SAAS,WAAW;AAC1B,MAAI,OAAO,OAAO,YAAY,OAAO,SAAS,GAAG,CAAE,QAAO;;CAE5D,MAAM,UAAU,MAAM,cAAc,MAAM;AAC1C,KAAI,OAAO,YAAY,YAAY,OAAO,SAAS,QAAQ,CACzD,QAAO,KAAK,KAAK,GAAG,UAAU;;AAKlC,IAAI;AACJ,IAAI;AACJ,IAAI;;;;;;;;;AAUJ,MAAa,uBACX,mBAAmC,EAAE,EACrC,mBACgB;CAEhB,MAAM,iBAAiC,EAAE,GAAG,kBAAkB;CAC9D,MAAM,aACJ,gBAAgB,QAAQ,YAAY,gBAAgB,QAAQ;CAC9D,MAAM,UAAU,eAAe,gBAAgB,eAAe;CAE9D,MAAM,qBAA8B;AAClC,MAAI,CAAC,mBAAoB,QAAO;AAChC,MAAI,CAAC,gBAAiB,QAAO;AAE7B,SAAO,KAAK,KAAK,GAAG,iBAAiB;;CAGvC,MAAM,eAAe,YAA2B;EAC9C,MAAM,YAAY,YAAY;GAG5B,MAAM,aADM,MADI,YAAY,eAAe,CACjB,sBAAsB,GACzB;AAEvB,wBAAqB,WAAW;AAChC,qBAAkB,mBAAmB,UAAU;;AAGjD,MAAI,CAAC,eACH,kBAAiB,WAAW,CAAC,cAAc;AACzC,oBAAiB;IACjB;AAEJ,QAAM;;CAGR,MAAM,mBAAmB,YAAY;AACnC,MAAI,cAAc,CAChB,OAAM,cAAc;;CAIxB,MAAM,6BAA6B;AACjC,MAAI,CAAC,mBAAoB;AACzB,iBAAe,UAAU;GACvB,GAAI,eAAe,WAAW,EAAE;GAChC,eAAe,UAAU;GAC1B;;CAGH,MAAM,eACJ,SACA,WAAW,CAAC,eACN;AACN,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;GAC1B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,SAAS;AAEjD,OAAI,OAAO,UAAU,WAEnB,QAAO,OAAO,GAAG,SAAoB;AACnC,QAAI,CAAC,UAAU;AACb,WAAM,kBAAkB;AACxB,2BAAsB;;AAGxB,QAAI;AACF,YAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;aAC/B,KAAK;AAEZ,SAAI,CAAC,UAAU;AACb,YAAM,cAAc;AACpB,4BAAsB;AACtB,aAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;;AAExC,WAAM;;;AAKZ,UAAO;KAEV,CAAC;;AAGJ,QAAO;EACL,cAAc,YAAY,QAAQ,aAAa;EAC/C,SAAS,YAAY,QAAQ,QAAQ;EACrC,MAAM,YAAY,QAAQ,KAAK;EAC/B,OAAO,YAAY,QAAQ,OAAO,KAAK;EACvC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACnC,IAAI,YAAY,QAAQ,GAAG;EAC3B,KAAK,YAAY,QAAQ,IAAI;EAC7B,QAAQ,YAAY,QAAQ,OAAO;EACnC,QAAQ,YAAY,QAAQ,OAAO;EACnC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACnC,OAAO,YAAY,QAAQ,MAAM;EAClC"}
1
+ {"version":3,"file":"proxy.mjs","names":[],"sources":["../../src/proxy.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport type { FetcherOptions } from './fetcher';\nimport { getIntlayerAPI } from './getIntlayerAPI';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\n\ntype OAuthTokenLike = {\n accessToken?: string;\n accessTokenExpiresAt?: string | Date;\n expires_in?: number;\n expiresIn?: number;\n expiresAt?: string | Date;\n};\n\nconst ONE_MINUTE_MS = 60_000;\n\n/**\n * Returns the expiration timestamp in ms from an OAuth token-like object.\n */\nconst getExpiryTimestamp = (\n token: OAuthTokenLike | undefined\n): number | undefined => {\n if (!token) return undefined;\n const dateLike = (token.accessTokenExpiresAt ?? token.expiresAt) as\n | string\n | Date\n | undefined;\n if (dateLike) {\n const ts =\n typeof dateLike === 'string'\n ? Date.parse(dateLike)\n : dateLike.getTime?.();\n if (typeof ts === 'number' && Number.isFinite(ts)) return ts;\n }\n const seconds = token.expires_in ?? token.expiresIn;\n if (typeof seconds === 'number' && Number.isFinite(seconds)) {\n return Date.now() + seconds * 1000;\n }\n return undefined;\n};\n\nlet currentAccessToken: string | undefined;\nlet currentExpiryTs: number | undefined;\nlet pendingRefresh: Promise<void> | undefined;\n\n/**\n * Build an auto-auth proxy around getIntlayerAPI that:\n * - Fetches an OAuth2 token when needed\n * - Injects Authorization header for each request\n * - Refreshes token proactively when near expiry\n *\n * The returned API matches the shape of getIntlayerAPI.\n */\nexport const getIntlayerAPIProxy = (\n _baseAuthOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPI => {\n // Use a shared mutable auth options object captured by the API closures\n const authOptionsRef: FetcherOptions = { ..._baseAuthOptions };\n const hasCMSAuth =\n intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;\n const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);\n\n const needsRefresh = (): boolean => {\n if (!currentAccessToken) return true;\n if (!currentExpiryTs) return false; // If unknown, assume usable until failure\n\n return Date.now() + ONE_MINUTE_MS >= currentExpiryTs; // refresh 1 min before expiry\n };\n\n const refreshToken = async (): Promise<void> => {\n const doRefresh = async () => {\n const authApi = getOAuthAPI(intlayerConfig);\n const res = await authApi.getOAuth2AccessToken();\n const tokenData = res?.data as OAuthTokenLike | undefined;\n\n currentAccessToken = tokenData?.accessToken;\n currentExpiryTs = getExpiryTimestamp(tokenData);\n };\n\n if (!pendingRefresh) {\n pendingRefresh = doRefresh().finally(() => {\n pendingRefresh = undefined;\n });\n }\n await pendingRefresh;\n };\n\n const ensureValidToken = async () => {\n if (needsRefresh()) {\n await refreshToken();\n }\n };\n\n const applyAuthHeaderToRef = () => {\n if (!currentAccessToken) return;\n authOptionsRef.headers = {\n ...(authOptionsRef.headers ?? {}),\n Authorization: `Bearer ${currentAccessToken}`,\n } as HeadersInit;\n };\n\n const wrapSection = <T extends Record<string, unknown>>(\n section: T,\n skipAuth = !hasCMSAuth\n ): T => {\n return new Proxy(section, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === 'function') {\n // Wrap section method to inject token and headers\n return async (...args: unknown[]) => {\n if (!skipAuth) {\n await ensureValidToken();\n applyAuthHeaderToRef();\n }\n\n try {\n return await value.apply(target, args);\n } catch (err) {\n // Best-effort retry: if token might be stale, refresh once and retry\n if (!skipAuth) {\n await refreshToken();\n applyAuthHeaderToRef();\n return await value.apply(target, args);\n }\n throw err;\n }\n };\n }\n\n return value;\n },\n });\n };\n\n return {\n organization: wrapSection(baseApi.organization),\n project: wrapSection(baseApi.project),\n user: wrapSection(baseApi.user),\n oAuth: wrapSection(baseApi.oAuth, true), // do NOT inject auth for token endpoint\n dictionary: wrapSection(baseApi.dictionary),\n stripe: wrapSection(baseApi.stripe),\n ai: wrapSection(baseApi.ai),\n tag: wrapSection(baseApi.tag),\n search: wrapSection(baseApi.search),\n editor: wrapSection(baseApi.editor),\n newsletter: wrapSection(baseApi.newsletter),\n github: wrapSection(baseApi.github),\n audit: wrapSection(baseApi.audit),\n } as IntlayerAPI;\n};\n\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":"qHAcA,MAKM,EACJ,GACuB,CACvB,GAAI,CAAC,EAAO,OACZ,IAAM,EAAY,EAAM,sBAAwB,EAAM,UAItD,GAAI,EAAU,CACZ,IAAM,EACJ,OAAO,GAAa,SAChB,KAAK,MAAM,EAAS,CACpB,EAAS,WAAW,CAC1B,GAAI,OAAO,GAAO,UAAY,OAAO,SAAS,EAAG,CAAE,OAAO,EAE5D,IAAM,EAAU,EAAM,YAAc,EAAM,UAC1C,GAAI,OAAO,GAAY,UAAY,OAAO,SAAS,EAAQ,CACzD,OAAO,KAAK,KAAK,CAAG,EAAU,KAKlC,IAAI,EACA,EACA,EAUJ,MAAa,GACX,EAAmC,EAAE,CACrC,IACgB,CAEhB,IAAM,EAAiC,CAAE,GAAG,EAAkB,CACxD,EACJ,GAAgB,QAAQ,UAAY,GAAgB,QAAQ,aACxD,EAAU,EAAe,EAAgB,EAAe,CAExD,MACC,EACA,EAEE,KAAK,KAAK,CAAG,KAAiB,EAFR,GADG,GAM5B,EAAe,SAA2B,CAU9C,AACE,KAVgB,SAAY,CAG5B,IAAM,GADM,MADI,EAAY,EAAe,CACjB,sBAAsB,GACzB,KAEvB,EAAqB,GAAW,YAChC,EAAkB,EAAmB,EAAU,IAInB,CAAC,YAAc,CACzC,EAAiB,IAAA,IACjB,CAEJ,MAAM,GAGF,EAAmB,SAAY,CAC/B,GAAc,EAChB,MAAM,GAAc,EAIlB,MAA6B,CAC5B,IACL,EAAe,QAAU,CACvB,GAAI,EAAe,SAAW,EAAE,CAChC,cAAe,UAAU,IAC1B,GAGG,GACJ,EACA,EAAW,CAAC,IAEL,IAAI,MAAM,EAAS,CACxB,IAAI,EAAQ,EAAM,EAAU,CAC1B,IAAM,EAAQ,QAAQ,IAAI,EAAQ,EAAM,EAAS,CAwBjD,OAtBI,OAAO,GAAU,WAEZ,MAAO,GAAG,IAAoB,CAC9B,IACH,MAAM,GAAkB,CACxB,GAAsB,EAGxB,GAAI,CACF,OAAO,MAAM,EAAM,MAAM,EAAQ,EAAK,OAC/B,EAAK,CAEZ,GAAI,CAAC,EAGH,OAFA,MAAM,GAAc,CACpB,GAAsB,CACf,MAAM,EAAM,MAAM,EAAQ,EAAK,CAExC,MAAM,IAKL,GAEV,CAAC,CAGJ,MAAO,CACL,aAAc,EAAY,EAAQ,aAAa,CAC/C,QAAS,EAAY,EAAQ,QAAQ,CACrC,KAAM,EAAY,EAAQ,KAAK,CAC/B,MAAO,EAAY,EAAQ,MAAO,GAAK,CACvC,WAAY,EAAY,EAAQ,WAAW,CAC3C,OAAQ,EAAY,EAAQ,OAAO,CACnC,GAAI,EAAY,EAAQ,GAAG,CAC3B,IAAK,EAAY,EAAQ,IAAI,CAC7B,OAAQ,EAAY,EAAQ,OAAO,CACnC,OAAQ,EAAY,EAAQ,OAAO,CACnC,WAAY,EAAY,EAAQ,WAAW,CAC3C,OAAQ,EAAY,EAAQ,OAAO,CACnC,MAAO,EAAY,EAAQ,MAAM,CAClC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/api",
3
- "version": "8.1.2",
3
+ "version": "8.1.3-canary.0",
4
4
  "private": false,
5
5
  "description": "SDK for interacting with the Intlayer API, enabling content auditing, and managing organizations, projects, and users.",
6
6
  "keywords": [
@@ -73,8 +73,8 @@
73
73
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
74
74
  },
75
75
  "dependencies": {
76
- "@intlayer/config": "8.1.2",
77
- "@intlayer/types": "8.1.2"
76
+ "@intlayer/config": "8.1.3-canary.0",
77
+ "@intlayer/types": "8.1.3-canary.0"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/node": "25.2.3",
@@ -87,8 +87,8 @@
87
87
  "vitest": "4.0.18"
88
88
  },
89
89
  "peerDependencies": {
90
- "@intlayer/backend": "8.1.2",
91
- "intlayer-editor": "8.1.2"
90
+ "@intlayer/backend": "8.1.3-canary.0",
91
+ "intlayer-editor": "8.1.3-canary.0"
92
92
  },
93
93
  "peerDependenciesMeta": {
94
94
  "@intlayer/backend": {