@intlayer/api 8.11.3 → 8.12.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.
@@ -4,7 +4,9 @@ let _intlayer_config_built = require("@intlayer/config/built");
4
4
 
5
5
  //#region src/getIntlayerAPI/project.ts
6
6
  const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
7
- const PROJECT_API_ROUTE = `${intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL}/api/project`;
7
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL;
8
+ const PROJECT_API_ROUTE = `${backendURL}/api/project`;
9
+ const ENVIRONMENT_API_ROUTE = `${backendURL}/api/project/environment`;
8
10
  /**
9
11
  * Retrieves a list of projects based on filters and pagination.
10
12
  * @param filters - Filters and pagination options.
@@ -122,6 +124,30 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
122
124
  * @returns Success status.
123
125
  */
124
126
  const pushCIConfig = async (otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/ci`, authAPIOptions, otherOptions, { method: "POST" });
127
+ const addEnvironment = async (body, otherOptions = {}) => await require_fetcher.fetcher(ENVIRONMENT_API_ROUTE, authAPIOptions, otherOptions, {
128
+ method: "POST",
129
+ body
130
+ });
131
+ const updateEnvironment = async (environmentId, body, otherOptions = {}) => await require_fetcher.fetcher(`${ENVIRONMENT_API_ROUTE}/${environmentId}`, authAPIOptions, otherOptions, {
132
+ method: "PUT",
133
+ body
134
+ });
135
+ const deleteEnvironment = async (environmentId, otherOptions = {}) => await require_fetcher.fetcher(`${ENVIRONMENT_API_ROUTE}/${environmentId}`, authAPIOptions, otherOptions, { method: "DELETE" });
136
+ const selectEnvironment = async (environmentId, otherOptions = {}) => await require_fetcher.fetcher(`${ENVIRONMENT_API_ROUTE}/${environmentId}/select`, authAPIOptions, otherOptions, { method: "PUT" });
137
+ const resetToProductionEnvironment = async (otherOptions = {}) => await require_fetcher.fetcher(`${ENVIRONMENT_API_ROUTE}/production/select`, authAPIOptions, otherOptions, { method: "PUT" });
138
+ const migrateEnvironment = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${ENVIRONMENT_API_ROUTE}/migrate`, authAPIOptions, otherOptions, {
139
+ method: "POST",
140
+ body
141
+ });
142
+ /**
143
+ * Updates granular access constraints for a project member.
144
+ * @param userId - The user ID to update access for.
145
+ * @param body - The new access constraints.
146
+ */
147
+ const updateMemberAccess = async (userId, body, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/member/${userId}/access`, authAPIOptions, otherOptions, {
148
+ method: "PUT",
149
+ body
150
+ });
125
151
  return {
126
152
  getProjects,
127
153
  addProject,
@@ -138,7 +164,14 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
138
164
  triggerBuild,
139
165
  triggerWebhook,
140
166
  getCIConfig,
141
- pushCIConfig
167
+ pushCIConfig,
168
+ addEnvironment,
169
+ updateEnvironment,
170
+ deleteEnvironment,
171
+ selectEnvironment,
172
+ resetToProductionEnvironment,
173
+ migrateEnvironment,
174
+ updateMemberAccess
142
175
  };
143
176
  };
144
177
 
@@ -1 +1 @@
1
- {"version":3,"file":"project.cjs","names":["editor","fetcher"],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectsParams,\n GetProjectsResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n ResponseData,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Admin-only: Deletes any project from the database by its ID.\n * @param projectId - Project ID.\n */\n const deleteProjectByIdAdmin = async (\n projectId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}/${projectId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n deleteProjectByIdAdmin,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n };\n};\n"],"mappings":";;;;;AA8BA,MAAa,iBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,oBAAoB,GAFP,gBAAgB,QAAQ,cAAcA,8BAAO,WAExB;;;;;CAMxC,MAAM,cAAc,OAClB,SACA,eAA+B,CAAC,MAEhC,MAAMC,wBACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;;CAMF,MAAM,aAAa,OACjB,SACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,gBAAgB,OACpB,SACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,uBAAuB,OAC3B,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;CAKF,MAAM,2BAA2B,OAC/B,sBACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,kBAAkB,iBACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,gBAAgB,OAAO,eAA+B,CAAC,MAC3D,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA,EACE,QAAQ,SACV,CACF;;;;;CAMF,MAAM,yBAAyB,OAC7B,WACA,eAA+B,CAAC,MAEhCA,w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AkB,MACrB,gBACA,cACA,EACE,QAAQ,OACV,CACF;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"project.cjs","names":["editor","fetcher"],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import type {\n AddEnvironmentBody,\n AddEnvironmentResult,\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteEnvironmentResult,\n DeleteProjectResult,\n GetProjectsParams,\n GetProjectsResult,\n MigrateEnvironmentBody,\n MigrateEnvironmentResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n ResetToProductionEnvironmentResult,\n ResponseData,\n SelectEnvironmentResult,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateEnvironmentBody,\n UpdateEnvironmentResult,\n UpdateMemberAccessBody,\n UpdateMemberAccessResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n const ENVIRONMENT_API_ROUTE = `${backendURL}/api/project/environment`;\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 * Admin-only: Deletes any project from the database by its ID.\n * @param projectId - Project ID.\n */\n const deleteProjectByIdAdmin = async (\n projectId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}/${projectId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n const addEnvironment = async (\n body: AddEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddEnvironmentResult>(\n ENVIRONMENT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const updateEnvironment = async (\n environmentId: string,\n body: UpdateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n const deleteEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n const selectEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}/select`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const resetToProductionEnvironment = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetToProductionEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/production/select`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const migrateEnvironment = async (\n body: MigrateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<MigrateEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/migrate`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Updates granular access constraints for a project member.\n * @param userId - The user ID to update access for.\n * @param body - The new access constraints.\n */\n const updateMemberAccess = async (\n userId: string,\n body: UpdateMemberAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateMemberAccessResult>(\n `${PROJECT_API_ROUTE}/member/${userId}/access`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n deleteProjectByIdAdmin,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n addEnvironment,\n updateEnvironment,\n deleteEnvironment,\n selectEnvironment,\n resetToProductionEnvironment,\n migrateEnv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BACJ,GAAG,sBAAsB,GAAG,iBAC5B,gBACA,cACA;EAAE,QAAQ;EAAO;CAAK,CACxB;CAEF,MAAM,oBAAoB,OACxB,eACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,sBAAsB,GAAG,iBAC5B,gBACA,cACA,EAAE,QAAQ,SAAS,CACrB;CAEF,MAAM,oBAAoB,OACxB,eACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,sBAAsB,GAAG,cAAc,UAC1C,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;CAEF,MAAM,+BAA+B,OACnC,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,sBAAsB,qBACzB,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;CAEF,MAAM,qBAAqB,OACzB,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,sBAAsB,WACzB,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;;;;;;CAOF,MAAM,qBAAqB,OACzB,QACA,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,kBAAkB,UAAU,OAAO,UACtC,gBACA,cACA;EAAE,QAAQ;EAAO;CAAK,CACxB;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.cjs","names":["editor","fetcher"],"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,CAAC,GAClC,mBACG;CAGH,MAAM,mBAAmB,GAFN,gBAAgB,QAAQ,cAAcA,8BAAO,WAEzB;;;;;CAMvC,MAAM,aAAa,OACjB,MACA,eAA+B,CAAC,M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;AACF"}
1
+ {"version":3,"file":"stripe.cjs","names":["editor","fetcher"],"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,CAAC,GAClC,mBACG;CAGH,MAAM,mBAAmB,GAFN,gBAAgB,QAAQ,cAAcA,8BAAO,WAEzB;;;;;CAMvC,MAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,MAAMC,wBACJ,GAAG,iBAAiB,WACpB,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;;CAMF,MAAM,kBAAkB,OACtB,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,iBAAiB,uBACpB,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;;CAMF,MAAM,qBAAqB,OAAO,eAA+B,CAAC,MAChE,MAAMA,wBACJ,GAAG,iBAAiB,uBACpB,gBACA,cACA,EACE,QAAQ,OACV,CACF;;;;CAKF,MAAM,cAAc,OAAO,eAA+B,CAAC,MACzD,MAAMA,wBACJ,GAAG,iBAAiB,YACpB,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;;;;;CAMF,MAAM,mBAAmB,OAAO,eAA+B,CAAC,MAC9D,MAAMA,wBACJ,GAAG,iBAAiB,kBACpB,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;;;;CAKF,MAAM,sBAAsB,OAAO,eAA+B,CAAC,MACjE,MAAMA,wBACJ,GAAG,iBAAiB,kBACpB,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;;;;CAKF,MAAM,uBAAuB,OAC3B,MACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,iBAAiB,mBACpB,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;;;;CAKF,MAAM,gBAAgB,OACpB,QACA,eAA+B,CAAC,MAEhC,M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C,MAAMA,wBACJ,GAAG,iBAAiB,eAAe,MACnC,gBACA,cACA,EAAE,QAAQ,SAAS,CACrB;;;;CAKF,MAAM,wBAAwB,OAC5B,cACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,iBAAiB,wBAAwB,gBAC5C,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -3,7 +3,9 @@ import { editor } from "@intlayer/config/built";
3
3
 
4
4
  //#region src/getIntlayerAPI/project.ts
5
5
  const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
6
- const PROJECT_API_ROUTE = `${intlayerConfig?.editor?.backendURL ?? editor.backendURL}/api/project`;
6
+ const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;
7
+ const PROJECT_API_ROUTE = `${backendURL}/api/project`;
8
+ const ENVIRONMENT_API_ROUTE = `${backendURL}/api/project/environment`;
7
9
  /**
8
10
  * Retrieves a list of projects based on filters and pagination.
9
11
  * @param filters - Filters and pagination options.
@@ -121,6 +123,30 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
121
123
  * @returns Success status.
122
124
  */
123
125
  const pushCIConfig = async (otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/ci`, authAPIOptions, otherOptions, { method: "POST" });
126
+ const addEnvironment = async (body, otherOptions = {}) => await fetcher(ENVIRONMENT_API_ROUTE, authAPIOptions, otherOptions, {
127
+ method: "POST",
128
+ body
129
+ });
130
+ const updateEnvironment = async (environmentId, body, otherOptions = {}) => await fetcher(`${ENVIRONMENT_API_ROUTE}/${environmentId}`, authAPIOptions, otherOptions, {
131
+ method: "PUT",
132
+ body
133
+ });
134
+ const deleteEnvironment = async (environmentId, otherOptions = {}) => await fetcher(`${ENVIRONMENT_API_ROUTE}/${environmentId}`, authAPIOptions, otherOptions, { method: "DELETE" });
135
+ const selectEnvironment = async (environmentId, otherOptions = {}) => await fetcher(`${ENVIRONMENT_API_ROUTE}/${environmentId}/select`, authAPIOptions, otherOptions, { method: "PUT" });
136
+ const resetToProductionEnvironment = async (otherOptions = {}) => await fetcher(`${ENVIRONMENT_API_ROUTE}/production/select`, authAPIOptions, otherOptions, { method: "PUT" });
137
+ const migrateEnvironment = async (body, otherOptions = {}) => await fetcher(`${ENVIRONMENT_API_ROUTE}/migrate`, authAPIOptions, otherOptions, {
138
+ method: "POST",
139
+ body
140
+ });
141
+ /**
142
+ * Updates granular access constraints for a project member.
143
+ * @param userId - The user ID to update access for.
144
+ * @param body - The new access constraints.
145
+ */
146
+ const updateMemberAccess = async (userId, body, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/member/${userId}/access`, authAPIOptions, otherOptions, {
147
+ method: "PUT",
148
+ body
149
+ });
124
150
  return {
125
151
  getProjects,
126
152
  addProject,
@@ -137,7 +163,14 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
137
163
  triggerBuild,
138
164
  triggerWebhook,
139
165
  getCIConfig,
140
- pushCIConfig
166
+ pushCIConfig,
167
+ addEnvironment,
168
+ updateEnvironment,
169
+ deleteEnvironment,
170
+ selectEnvironment,
171
+ resetToProductionEnvironment,
172
+ migrateEnvironment,
173
+ updateMemberAccess
141
174
  };
142
175
  };
143
176
 
@@ -1 +1 @@
1
- {"version":3,"file":"project.mjs","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectsParams,\n GetProjectsResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n ResponseData,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Admin-only: Deletes any project from the database by its ID.\n * @param projectId - Project ID.\n */\n const deleteProjectByIdAdmin = async (\n projectId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}/${projectId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n deleteProjectByIdAdmin,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n };\n};\n"],"mappings":";;;;AA8BA,MAAa,iBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,oBAAoB,GAFP,gBAAgB,QAAQ,cAAc,OAAO,WAExB;;;;;CAMxC,MAAM,cAAc,OAClB,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;;CAMF,MAAM,aAAa,OACjB,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,gBAAgB,OACpB,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,uBAAuB,OAC3B,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;CAKF,MAAM,2BAA2B,OAC/B,sBACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,iBACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,gBAAgB,OAAO,eAA+B,CAAC,MA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ACA,EACE,QAAQ,MACV,CACF;;;;;;CAOF,MAAM,eAAe,OAAO,eAA+B,CAAC,MAC1D,MAAM,QACJ,GAAG,kBAAkB,MACrB,gBACA,cACA,EACE,QAAQ,OACV,CACF;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"project.mjs","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import type {\n AddEnvironmentBody,\n AddEnvironmentResult,\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteEnvironmentResult,\n DeleteProjectResult,\n GetProjectsParams,\n GetProjectsResult,\n MigrateEnvironmentBody,\n MigrateEnvironmentResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n ResetToProductionEnvironmentResult,\n ResponseData,\n SelectEnvironmentResult,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateEnvironmentBody,\n UpdateEnvironmentResult,\n UpdateMemberAccessBody,\n UpdateMemberAccessResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n const ENVIRONMENT_API_ROUTE = `${backendURL}/api/project/environment`;\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 * Admin-only: Deletes any project from the database by its ID.\n * @param projectId - Project ID.\n */\n const deleteProjectByIdAdmin = async (\n projectId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}/${projectId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n const addEnvironment = async (\n body: AddEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddEnvironmentResult>(\n ENVIRONMENT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const updateEnvironment = async (\n environmentId: string,\n body: UpdateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n const deleteEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n const selectEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}/select`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const resetToProductionEnvironment = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetToProductionEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/production/select`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const migrateEnvironment = async (\n body: MigrateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<MigrateEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/migrate`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Updates granular access constraints for a project member.\n * @param userId - The user ID to update access for.\n * @param body - The new access constraints.\n */\n const updateMemberAccess = async (\n userId: string,\n body: UpdateMemberAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateMemberAccessResult>(\n `${PROJECT_API_ROUTE}/member/${userId}/access`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n deleteProjectByIdAdmin,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n addEnvironment,\n updateEnvironment,\n deleteEnvironment,\n selectEnvironment,\n resetToProductionEnvironment,\n migrateEnvironment,\n updateMemberAccess,\n };\n};\n"],"mappings":";;;;AAyCA,MAAa,iBACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aAAa,gBAAgB,QAAQ,cAAc,OAAO;CAEhE,MAAM,oBAAoB,GAAG,WAAW;CACxC,MAAM,wBAAwB,GAAG,WAAW;;;;;CAM5C,MAAM,cAAc,OAClB,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;;CAMF,MAAM,aAAa,OACjB,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,gBAAgB,OACpB,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,uBAAuB,OAC3B,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;CAKF,MAAM,2BAA2B,OAC/B,sBACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,iBACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,gBAAgB,OAAO,eAA+B,CAAC,MAC3D,MAAM,QACJ,GAAG,qBACH,gBACA,cACA,EACE,QAAQ,SACV,CACF;;;;;CAMF,MAAM,yBAAyB,OAC7B,WACA,eAA+B,CAAC,MAEhC,QACE,GAAG,kBAAkB,GAAG,UAAU,SAClC,gBACA,cACA,EAAE,QAAQ,SAAS,CACrB;;;;;CAMF,MAAM,gBAAgB,OACpB,WACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,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ACxB,eACA,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,sBAAsB,GAAG,iBAC5B,gBACA,cACA;EAAE,QAAQ;EAAO;CAAK,CACxB;CAEF,MAAM,oBAAoB,OACxB,eACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,sBAAsB,GAAG,iBAC5B,gBACA,cACA,EAAE,QAAQ,SAAS,CACrB;CAEF,MAAM,oBAAoB,OACxB,eACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,sBAAsB,GAAG,cAAc,UAC1C,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;CAEF,MAAM,+BAA+B,OACnC,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,sBAAsB,qBACzB,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;CAEF,MAAM,qBAAqB,OACzB,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,sBAAsB,WACzB,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;;;;;;CAOF,MAAM,qBAAqB,OACzB,QACA,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,kBAAkB,UAAU,OAAO,UACtC,gBACA,cACA;EAAE,QAAQ;EAAO;CAAK,CACxB;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -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,CAAC,GAClC,mBACG;CAGH,MAAM,mBAAmB,GAFN,gBAAgB,QAAQ,cAAc,OAAO,WAEzB;;;;;CAMvC,MAAM,aAAa,OACjB,MACA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ources":["../../../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,CAAC,GAClC,mBACG;CAGH,MAAM,mBAAmB,GAFN,gBAAgB,QAAQ,cAAc,OAAO,WAEzB;;;;;CAMvC,MAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,iBAAiB,WACpB,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;;CAMF,MAAM,kBAAkB,OACtB,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,iBAAiB,uBACpB,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;;CAMF,MAAM,qBAAqB,OAAO,eAA+B,CAAC,MAChE,MAAM,QACJ,GAAG,iBAAiB,uBACpB,gBACA,cACA,EACE,QAAQ,OACV,CACF;;;;CAKF,MAAM,cAAc,OAAO,eAA+B,CAAC,MACzD,MAAM,QACJ,GAAG,iBAAiB,YACpB,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;;;;;CAMF,MAAM,mBAAmB,OAAO,eAA+B,CAAC,MAC9D,MAAM,QACJ,GAAG,iBAAiB,kBACpB,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;;;;CAKF,MAAM,sBAAsB,OAAO,eAA+B,CAAC,MACjE,MAAM,QACJ,GAAG,iBAAiB,kBACpB,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;;;;CAKF,MAAM,uBAAuB,OAC3B,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,iBAAiB,mBACpB,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;;;;CAKF,MAAM,gBAAgB,OACpB,QACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,iBAAiB,cACpB,gBACA,cACA;EAAE,QAAQ;EAAe;CAAiC,CAC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cACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,iBAAiB,wBAAwB,gBAC5C,gBACA,cACA,EAAE,QAAQ,MAAM,CAClB;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { FetcherOptions } from "../fetcher.js";
2
- import { AddNewAccessKeyBody, AddProjectBody, DeleteAccessKeyBody, GetProjectsParams, PushProjectConfigurationBody, RefreshAccessKeyBody, SelectProjectParam, TriggerWebhookBody, UpdateProjectBody, UpdateProjectMembersBody } from "@intlayer/backend";
2
+ import { AddEnvironmentBody, AddNewAccessKeyBody, AddProjectBody, DeleteAccessKeyBody, GetProjectsParams, MigrateEnvironmentBody, PushProjectConfigurationBody, RefreshAccessKeyBody, SelectProjectParam, TriggerWebhookBody, UpdateEnvironmentBody, UpdateMemberAccessBody, UpdateProjectBody, UpdateProjectMembersBody } from "@intlayer/backend";
3
3
  import { IntlayerConfig } from "@intlayer/types/config";
4
4
 
5
5
  //#region src/getIntlayerAPI/project.d.ts
@@ -20,6 +20,13 @@ declare const getProjectAPI: (authAPIOptions?: FetcherOptions, intlayerConfig?:
20
20
  triggerWebhook: (webhookIndex: TriggerWebhookBody["webhookIndex"], otherOptions?: FetcherOptions) => Promise<TriggerWebhookResult>;
21
21
  getCIConfig: (otherOptions?: FetcherOptions) => Promise<ResponseData<any>>;
22
22
  pushCIConfig: (otherOptions?: FetcherOptions) => Promise<ResponseData<any>>;
23
+ addEnvironment: (body: AddEnvironmentBody, otherOptions?: FetcherOptions) => Promise<AddEnvironmentResult>;
24
+ updateEnvironment: (environmentId: string, body: UpdateEnvironmentBody, otherOptions?: FetcherOptions) => Promise<UpdateEnvironmentResult>;
25
+ deleteEnvironment: (environmentId: string, otherOptions?: FetcherOptions) => Promise<DeleteEnvironmentResult>;
26
+ selectEnvironment: (environmentId: string, otherOptions?: FetcherOptions) => Promise<SelectEnvironmentResult>;
27
+ resetToProductionEnvironment: (otherOptions?: FetcherOptions) => Promise<ResetToProductionEnvironmentResult>;
28
+ migrateEnvironment: (body: MigrateEnvironmentBody, otherOptions?: FetcherOptions) => Promise<MigrateEnvironmentResult>;
29
+ updateMemberAccess: (userId: string, body: UpdateMemberAccessBody, otherOptions?: FetcherOptions) => Promise<UpdateMemberAccessResult>;
23
30
  };
24
31
  //#endregion
25
32
  export { getProjectAPI };
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"mappings":";;;;;cA8Ba,aAAA,GACX,cAAA,GAAgB,cAAA,EAChB,cAAA,GAAiB,cAAA;0BAWL,iBAAA,EAAiB,YAAA,GACb,cAAA,KAAc,OAAA,CAAA,iBAAA;wBAkBnB,cAAA,EAAc,YAAA,GACT,cAAA,KAAc,OAAA,CAAA,gBAAA;2BAiBnB,iBAAA,EAAiB,YAAA,GACZ,cAAA,KAAc,OAAA,CAAA,mBAAA;+BAiBtB,wBAAA,EAAwB,YAAA,GAChB,cAAA,KAAc,OAAA,CAAA,0BAAA;mDAgBN,4BAAA,EAA4B,YAAA,GACpC,cAAA,KAAc,OAAA,CAAA,8BAAA;iCAgBa,cAAA,KAAc,OAAA,CAAA,mBAAA;8CAetC,YAAA,GACH,cAAA,KAAc,OAAA,CAAA,mBAAA;6BAcjB,kBAAA,eAA+B,YAAA,GAC5B,cAAA,KAAc,OAAA,CAAA,mBAAA;mCAee,cAAA,KAAc,OAAA,CAAA,qBAAA;+BAiB9C,mBAAA,EAAmB,YAAA,GAChB,cAAA,KAAc,OAAA,CAAA,uBAAA;8BAmBlB,mBAAA,cAA+B,YAAA,GAC3B,cAAA,KAAc,OAAA,CAAA,uBAAA;+BAmBlB,oBAAA,cAAgC,YAAA,GAC5B,cAAA,KAAc,OAAA,CAAA,wBAAA;gCAiBY,cAAA,KAAc,OAAA,CAAA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AAA,GACV,cAAA,KAAc,OAAA,CAAA,oBAAA;6CAUP,IAAA,EACf,qBAAA,EAAqB,YAAA,GACb,cAAA,KAAc,OAAA,CAAA,uBAAA;6CAUP,YAAA,GACP,cAAA,KAAc,OAAA,CAAA,uBAAA;6CAUP,YAAA,GACP,cAAA,KAAc,OAAA,CAAA,uBAAA;gDAUd,cAAA,KAAc,OAAA,CAAA,kCAAA;6BAUtB,sBAAA,EAAsB,YAAA,GACd,cAAA,KAAc,OAAA,CAAA,wBAAA;uCAed,IAAA,EACR,sBAAA,EAAsB,YAAA,GACd,cAAA,KAAc,OAAA,CAAA,wBAAA;AAAA"}
@@ -3,7 +3,7 @@ import { CreatePromoCodeBody, GetAffiliatesParams, GetCheckoutSessionBody, GetPr
3
3
  import { IntlayerConfig } from "@intlayer/types/config";
4
4
 
5
5
  //#region src/getIntlayerAPI/stripe.d.ts
6
- declare const getStripeAPI: (authAPIOptions: FetcherOptions, intlayerConfig: IntlayerConfig) => {
6
+ declare const getStripeAPI: (authAPIOptions?: FetcherOptions, intlayerConfig?: IntlayerConfig) => {
7
7
  getPricing: (body?: GetPricingBody, otherOptions?: FetcherOptions) => Promise<GetPricingResult>;
8
8
  getSubscription: (body?: GetCheckoutSessionBody, otherOptions?: FetcherOptions) => Promise<GetCheckoutSessionResult>;
9
9
  cancelSubscription: (otherOptions?: FetcherOptions) => Promise<GetCheckoutSessionResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.d.ts","names":[],"sources":["../../../src/getIntlayerAPI/stripe.ts"],"mappings":";;;;;cAoCa,YAAA,GACX,cAAA,EAAgB,cAAA,EAChB,cAAA,EAAgB,cAAA;sBAWP,cAAA,EAAc,YAAA,GACP,cAAA,KAAc,OAAA,CAAA,gBAAA;2BAiBrB,sBAAA,EAAsB,YAAA,GACf,cAAA,KAAc,OAAA,CAAA,wBAAA;sCAgBkB,cAAA,KAAc,OAAA,CAAA,wBAAA;+BAarB,cAAA,KAAc,OAAA,CAAA,iBAAA;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AmClB,YAAA,GACI,cAAA,KAAc,OAAA,CAAA,sBAAA;;IAUlB,WAAA;EAAA,GAAsB,YAAA,GAClB,cAAA,KAAc,OAAA,CAAA,mBAAA;0BAiBtB,mBAAA,EAAmB,YAAA,GACX,cAAA,KAAc,OAAA,CAAA,qBAAA;;;;;IAaT,EAAA;EAAA,IAAe,mBAAA,EAAmB,YAAA,GACvC,cAAA,KAAc,OAAA,CAAA,qBAAA;;;;IAalB,EAAA;EAAA,GAAY,YAAA,GACR,cAAA,KAAc,OAAA,CAAA,qBAAA;gDAaR,YAAA,GACN,cAAA,KAAc,OAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/api",
3
- "version": "8.11.3",
3
+ "version": "8.12.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": [
@@ -216,8 +216,8 @@
216
216
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
217
217
  },
218
218
  "dependencies": {
219
- "@intlayer/config": "8.11.3",
220
- "@intlayer/types": "8.11.3",
219
+ "@intlayer/config": "8.12.0",
220
+ "@intlayer/types": "8.12.0",
221
221
  "defu": "6.1.7"
222
222
  },
223
223
  "devDependencies": {
@@ -228,7 +228,7 @@
228
228
  "rimraf": "6.1.3",
229
229
  "tsdown": "0.22.1",
230
230
  "typescript": "6.0.3",
231
- "vitest": "4.1.7"
231
+ "vitest": "4.1.8"
232
232
  },
233
233
  "engines": {
234
234
  "node": ">=14.18"