@intlayer/api 9.6.0 → 9.7.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.
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
- package/dist/cjs/fetcher.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/ai.cjs +76 -22
- package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/analytics.cjs +44 -10
- package/dist/cjs/getIntlayerAPI/analytics.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/asset.cjs +38 -8
- package/dist/cjs/getIntlayerAPI/asset.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/audit.cjs +70 -16
- package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/bitbucket.cjs +39 -9
- package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/codeberg.cjs +21 -0
- package/dist/cjs/getIntlayerAPI/codeberg.cjs.map +1 -0
- package/dist/cjs/getIntlayerAPI/dictionary.cjs +59 -13
- package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/environment.cjs +44 -10
- package/dist/cjs/getIntlayerAPI/environment.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/forge.cjs +64 -0
- package/dist/cjs/getIntlayerAPI/forge.cjs.map +1 -0
- package/dist/cjs/getIntlayerAPI/gitee.cjs +21 -0
- package/dist/cjs/getIntlayerAPI/gitee.cjs.map +1 -0
- package/dist/cjs/getIntlayerAPI/github.cjs +44 -10
- package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/gitlab.cjs +39 -9
- package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/index.cjs +4 -0
- package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/newsletter.cjs +28 -6
- package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/oAuth.cjs +31 -5
- package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/organization.cjs +72 -20
- package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/project.cjs +112 -29
- package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/reviewer.cjs +142 -31
- package/dist/cjs/getIntlayerAPI/reviewer.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/search.cjs +15 -3
- package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/showcaseProject.cjs +61 -15
- package/dist/cjs/getIntlayerAPI/showcaseProject.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/status.cjs +16 -3
- package/dist/cjs/getIntlayerAPI/status.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/stripe.cjs +141 -35
- package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/tag.cjs +33 -7
- package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/translate.cjs +46 -8
- package/dist/cjs/getIntlayerAPI/translate.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/user.cjs +58 -14
- package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
- package/dist/cjs/index.cjs +8 -0
- package/dist/cjs/proxy.cjs +4 -0
- package/dist/cjs/proxy.cjs.map +1 -1
- package/dist/cjs/public/createPublicClient.cjs +25 -5
- package/dist/cjs/public/createPublicClient.cjs.map +1 -1
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
- package/dist/esm/fetcher.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/ai.mjs +76 -22
- package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/analytics.mjs +44 -10
- package/dist/esm/getIntlayerAPI/analytics.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/asset.mjs +38 -8
- package/dist/esm/getIntlayerAPI/asset.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/audit.mjs +70 -16
- package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/bitbucket.mjs +39 -9
- package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/codeberg.mjs +19 -0
- package/dist/esm/getIntlayerAPI/codeberg.mjs.map +1 -0
- package/dist/esm/getIntlayerAPI/dictionary.mjs +59 -13
- package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/environment.mjs +44 -10
- package/dist/esm/getIntlayerAPI/environment.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/forge.mjs +63 -0
- package/dist/esm/getIntlayerAPI/forge.mjs.map +1 -0
- package/dist/esm/getIntlayerAPI/gitee.mjs +19 -0
- package/dist/esm/getIntlayerAPI/gitee.mjs.map +1 -0
- package/dist/esm/getIntlayerAPI/github.mjs +44 -10
- package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/gitlab.mjs +39 -9
- package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/index.mjs +4 -0
- package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/newsletter.mjs +28 -6
- package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/oAuth.mjs +31 -5
- package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/organization.mjs +72 -20
- package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/project.mjs +112 -29
- package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/reviewer.mjs +142 -31
- package/dist/esm/getIntlayerAPI/reviewer.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/search.mjs +15 -3
- package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/showcaseProject.mjs +61 -15
- package/dist/esm/getIntlayerAPI/showcaseProject.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/status.mjs +16 -3
- package/dist/esm/getIntlayerAPI/status.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/stripe.mjs +141 -35
- package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/tag.mjs +33 -7
- package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/translate.mjs +46 -8
- package/dist/esm/getIntlayerAPI/translate.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/user.mjs +58 -14
- package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
- package/dist/esm/index.mjs +4 -1
- package/dist/esm/proxy.mjs +4 -0
- package/dist/esm/proxy.mjs.map +1 -1
- package/dist/esm/public/createPublicClient.mjs +25 -5
- package/dist/esm/public/createPublicClient.mjs.map +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +1 -1
- package/dist/types/fetcher.d.ts +1 -1
- package/dist/types/fetcher.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/ai.d.ts +1 -1
- package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/analytics.d.ts +1 -1
- package/dist/types/getIntlayerAPI/analytics.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/asset.d.ts +1 -0
- package/dist/types/getIntlayerAPI/asset.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/audit.d.ts +47 -3
- package/dist/types/getIntlayerAPI/audit.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/bitbucket.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/codeberg.d.ts +23 -0
- package/dist/types/getIntlayerAPI/codeberg.d.ts.map +1 -0
- package/dist/types/getIntlayerAPI/dictionary.d.ts +1 -1
- package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/editor.d.ts +2 -1
- package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/environment.d.ts +1 -1
- package/dist/types/getIntlayerAPI/environment.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/forge.d.ts +17 -0
- package/dist/types/getIntlayerAPI/forge.d.ts.map +1 -0
- package/dist/types/getIntlayerAPI/gitee.d.ts +23 -0
- package/dist/types/getIntlayerAPI/gitee.d.ts.map +1 -0
- package/dist/types/getIntlayerAPI/github.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/gitlab.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/index.d.ts +4 -0
- package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/newsletter.d.ts +1 -1
- package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/oAuth.d.ts +2 -0
- package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/organization.d.ts +1 -3
- package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/project.d.ts +2 -1
- package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/reviewer.d.ts +680 -35
- package/dist/types/getIntlayerAPI/reviewer.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/search.d.ts +1 -1
- package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/showcaseProject.d.ts +1 -1
- package/dist/types/getIntlayerAPI/showcaseProject.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/status.d.ts +3 -4
- package/dist/types/getIntlayerAPI/status.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/stripe.d.ts +1 -1
- package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/tag.d.ts +1 -1
- package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/translate.d.ts +1 -1
- package/dist/types/getIntlayerAPI/translate.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/user.d.ts +4 -4
- package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
- package/dist/types/index.d.ts +7 -4
- package/dist/types/proxy.d.ts.map +1 -1
- package/dist/types/public/createPublicClient.d.ts +1 -7
- package/dist/types/public/createPublicClient.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -2
- package/package.json +20 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oAuth.mjs","names":[],"sources":["../../../src/getIntlayerAPI/oAuth.ts"],"sourcesContent":["import type {\n CreateCliSessionTokenResult,\n GetCliSessionMeResult,\n GetOAuth2TokenBody,\n GetOAuth2TokenResult,\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 getOAuthAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: Pick<IntlayerConfig, 'editor'>\n) => {\n const backendURL
|
|
1
|
+
{"version":3,"file":"oAuth.mjs","names":[],"sources":["../../../src/getIntlayerAPI/oAuth.ts"],"sourcesContent":["import type {\n CliSessionTokenRoutes,\n CreateCliSessionTokenResult,\n cliSessionTokenContract,\n GetCliSessionMeResult,\n} from '@intlayer/backend-contract/cliSessionToken';\nimport type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n GetOAuth2TokenBody,\n GetOAuth2TokenResult,\n OAuth2Routes,\n oAuth2Contract,\n} from '@intlayer/backend-contract/oAuth2';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\n/** OAuth2 routes, checked against the backend contract. */\nconst oAuth2Group = {\n prefix: '/oauth2',\n} as const satisfies Pick<typeof oAuth2Contract, 'prefix'>;\nconst oAuth2Endpoints = {\n getOAuth2AccessToken: { method: 'POST', path: '/token' },\n extendOAuth2Token: { method: 'POST', path: '/token/extend' },\n} as const satisfies RouteEndpoints<OAuth2Routes>;\n\n/** CLI session routes, checked against the backend contract. */\nconst cliSessionGroup = {\n prefix: '/api/cli-session',\n} as const satisfies Pick<typeof cliSessionTokenContract, 'prefix'>;\nconst cliSessionEndpoints = {\n createCliSessionToken: { method: 'POST', path: '/' },\n getCliSessionMe: { method: 'GET', path: '/me' },\n} as const satisfies RouteEndpoints<CliSessionTokenRoutes>;\n\nexport const getOAuthAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: Pick<IntlayerConfig, 'editor'>\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n const { clientId, clientSecret } = intlayerConfig?.editor ?? {};\n\n /**\n * Gets an oAuth2 accessToken via client_credentials grant\n */\n const getOAuth2AccessToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetOAuth2TokenResult>(\n buildRouteURL(\n backendURL,\n oAuth2Group,\n oAuth2Endpoints.getOAuth2AccessToken\n ),\n {},\n otherOptions,\n {\n method: oAuth2Endpoints.getOAuth2AccessToken.method,\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: {\n grant_type: 'client_credentials',\n client_id: clientId!,\n client_secret: clientSecret!,\n } satisfies GetOAuth2TokenBody,\n }\n );\n\n /**\n * Creates a short-lived (2h) CLI session token for the authenticated user.\n * Requires a valid browser session cookie.\n */\n const createCliSessionToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<CreateCliSessionTokenResult>(\n buildRouteURL(\n backendURL,\n cliSessionGroup,\n cliSessionEndpoints.createCliSessionToken\n ),\n authAPIOptions,\n otherOptions,\n { method: cliSessionEndpoints.createCliSessionToken.method }\n );\n\n /**\n * Verifies a CLI session token and returns the associated project context.\n * Useful for checking config consistency in the CLI.\n */\n const getCliSessionMe = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCliSessionMeResult>(\n buildRouteURL(\n backendURL,\n cliSessionGroup,\n cliSessionEndpoints.getCliSessionMe\n ),\n authAPIOptions,\n otherOptions,\n { method: cliSessionEndpoints.getCliSessionMe.method }\n );\n\n return {\n getOAuth2AccessToken,\n createCliSessionToken,\n getCliSessionMe,\n };\n};\n"],"mappings":";;;;;;;AAoBA,MAAM,cAAc,EAClB,QAAQ,UACV;AACA,MAAM,kBAAkB;CACtB,sBAAsB;EAAE,QAAQ;EAAQ,MAAM;CAAS;CACvD,mBAAmB;EAAE,QAAQ;EAAQ,MAAM;CAAgB;AAC7D;;AAGA,MAAM,kBAAkB,EACtB,QAAQ,mBACV;AACA,MAAM,sBAAsB;CAC1B,uBAAuB;EAAE,QAAQ;EAAQ,MAAM;CAAI;CACnD,iBAAiB;EAAE,QAAQ;EAAO,MAAM;CAAM;AAChD;AAEA,MAAa,eACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,OAAO,cAAc;CAC7D,MAAM,EAAE,UAAU,iBAAiB,gBAAgB,UAAU,CAAC;;;;CAK9D,MAAM,uBAAuB,OAAO,eAA+B,CAAC,MAClE,MAAM,QACJ,cACE,YACA,aACA,gBAAgB,oBAClB,GACA,CAAC,GACD,cACA;EACE,QAAQ,gBAAgB,qBAAqB;EAC7C,SAAS,EACP,gBAAgB,oCAClB;EACA,MAAM;GACJ,YAAY;GACZ,WAAW;GACX,eAAe;EACjB;CACF,CACF;;;;;CAMF,MAAM,wBAAwB,OAAO,eAA+B,CAAC,MACnE,MAAM,QACJ,cACE,YACA,iBACA,oBAAoB,qBACtB,GACA,gBACA,cACA,EAAE,QAAQ,oBAAoB,sBAAsB,OAAO,CAC7D;;;;;CAMF,MAAM,kBAAkB,OAAO,eAA+B,CAAC,MAC7D,MAAM,QACJ,cACE,YACA,iBACA,oBAAoB,eACtB,GACA,gBACA,cACA,EAAE,QAAQ,oBAAoB,gBAAgB,OAAO,CACvD;CAEF,OAAO;EACL;EACA;EACA;CACF;AACF"}
|
|
@@ -1,15 +1,69 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
2
|
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
3
3
|
import { editor } from "@intlayer/config/built";
|
|
4
|
+
import { buildRouteURL } from "@intlayer/backend-contract/defineRoute";
|
|
5
|
+
import { BACKEND_URL } from "@intlayer/config/defaultValues";
|
|
4
6
|
|
|
5
7
|
//#region src/getIntlayerAPI/organization.ts
|
|
8
|
+
/** Prefix of the routes, checked against the backend contract. */
|
|
9
|
+
const organizationGroup = { prefix: "/api/organization" };
|
|
10
|
+
/**
|
|
11
|
+
* Method and path of every route, checked against the backend contract at
|
|
12
|
+
* compile time (the contract's zod schemas are never loaded).
|
|
13
|
+
*/
|
|
14
|
+
const organizationEndpoints = {
|
|
15
|
+
getOrganizations: {
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: "/"
|
|
18
|
+
},
|
|
19
|
+
addOrganization: {
|
|
20
|
+
method: "POST",
|
|
21
|
+
path: "/"
|
|
22
|
+
},
|
|
23
|
+
updateOrganization: {
|
|
24
|
+
method: "PUT",
|
|
25
|
+
path: "/"
|
|
26
|
+
},
|
|
27
|
+
updateOrganizationMailerConfig: {
|
|
28
|
+
method: "PUT",
|
|
29
|
+
path: "/mailer-config"
|
|
30
|
+
},
|
|
31
|
+
updateOrganizationMembers: {
|
|
32
|
+
method: "PUT",
|
|
33
|
+
path: "/members"
|
|
34
|
+
},
|
|
35
|
+
updateOrganizationMembersById: {
|
|
36
|
+
method: "PUT",
|
|
37
|
+
path: "/:organizationId/members"
|
|
38
|
+
},
|
|
39
|
+
addOrganizationMember: {
|
|
40
|
+
method: "POST",
|
|
41
|
+
path: "/member"
|
|
42
|
+
},
|
|
43
|
+
deleteOrganization: {
|
|
44
|
+
method: "DELETE",
|
|
45
|
+
path: "/"
|
|
46
|
+
},
|
|
47
|
+
selectOrganization: {
|
|
48
|
+
method: "PUT",
|
|
49
|
+
path: "/:organizationId"
|
|
50
|
+
},
|
|
51
|
+
unselectOrganization: {
|
|
52
|
+
method: "POST",
|
|
53
|
+
path: "/logout"
|
|
54
|
+
},
|
|
55
|
+
deleteOrganizationByIdAdmin: {
|
|
56
|
+
method: "DELETE",
|
|
57
|
+
path: "/:organizationId/admin"
|
|
58
|
+
}
|
|
59
|
+
};
|
|
6
60
|
const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
7
|
-
const
|
|
61
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;
|
|
8
62
|
/**
|
|
9
63
|
* Retrieves a list of organizations based on filters and pagination.
|
|
10
64
|
* @param filters - Filters and pagination options.
|
|
11
65
|
*/
|
|
12
|
-
const getOrganizations = async (filters, otherOptions = {}) => await fetcher(
|
|
66
|
+
const getOrganizations = async (filters, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.getOrganizations), authAPIOptions, otherOptions, {
|
|
13
67
|
cache: "no-store",
|
|
14
68
|
params: filters
|
|
15
69
|
});
|
|
@@ -17,21 +71,20 @@ const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
17
71
|
* Retrieves an organization by its ID.
|
|
18
72
|
* @param organizationId - Organization ID.
|
|
19
73
|
*/
|
|
20
|
-
const getOrganization = async (organizationId, otherOptions = {}) => await fetcher(`${ORGANIZATION_API_ROUTE}/${String(organizationId)}`, authAPIOptions, otherOptions);
|
|
21
74
|
/**
|
|
22
75
|
* Adds a new organization to the database.
|
|
23
76
|
* @param organization - Organization data.
|
|
24
77
|
*/
|
|
25
|
-
const addOrganization = async (organization, otherOptions = {}) => await fetcher(
|
|
26
|
-
method:
|
|
78
|
+
const addOrganization = async (organization, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.addOrganization), authAPIOptions, otherOptions, {
|
|
79
|
+
method: organizationEndpoints.addOrganization.method,
|
|
27
80
|
body: organization
|
|
28
81
|
});
|
|
29
82
|
/**
|
|
30
83
|
* Updates an existing organization in the database.
|
|
31
84
|
* @param organization - Updated organization data.
|
|
32
85
|
*/
|
|
33
|
-
const updateOrganization = async (organization, otherOptions = {}) => fetcher(
|
|
34
|
-
method:
|
|
86
|
+
const updateOrganization = async (organization, otherOptions = {}) => fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.updateOrganization), authAPIOptions, otherOptions, {
|
|
87
|
+
method: organizationEndpoints.updateOrganization.method,
|
|
35
88
|
body: organization
|
|
36
89
|
});
|
|
37
90
|
/**
|
|
@@ -39,16 +92,16 @@ const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
39
92
|
* @param body - Mailer configuration. Secrets are optional; omit to keep the
|
|
40
93
|
* value already stored.
|
|
41
94
|
*/
|
|
42
|
-
const updateOrganizationMailerConfig = async (body, otherOptions = {}) => fetcher(
|
|
43
|
-
method:
|
|
95
|
+
const updateOrganizationMailerConfig = async (body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.updateOrganizationMailerConfig), authAPIOptions, otherOptions, {
|
|
96
|
+
method: organizationEndpoints.updateOrganizationMailerConfig.method,
|
|
44
97
|
body
|
|
45
98
|
});
|
|
46
99
|
/**
|
|
47
100
|
* Update members to the organization in the database.
|
|
48
101
|
* @param body - Updated organization members data.
|
|
49
102
|
*/
|
|
50
|
-
const updateOrganizationMembers = async (body, otherOptions = {}) => fetcher(
|
|
51
|
-
method:
|
|
103
|
+
const updateOrganizationMembers = async (body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.updateOrganizationMembers), authAPIOptions, otherOptions, {
|
|
104
|
+
method: organizationEndpoints.updateOrganizationMembers.method,
|
|
52
105
|
body
|
|
53
106
|
});
|
|
54
107
|
/**
|
|
@@ -56,41 +109,40 @@ const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
56
109
|
* @param organizationId - Organization ID
|
|
57
110
|
* @param body - Updated organization members data.
|
|
58
111
|
*/
|
|
59
|
-
const updateOrganizationMembersById = async (organizationId, body, otherOptions = {}) => fetcher(
|
|
60
|
-
method:
|
|
112
|
+
const updateOrganizationMembersById = async (organizationId, body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.updateOrganizationMembersById, { organizationId: String(organizationId) }), authAPIOptions, otherOptions, {
|
|
113
|
+
method: organizationEndpoints.updateOrganizationMembersById.method,
|
|
61
114
|
body
|
|
62
115
|
});
|
|
63
116
|
/**
|
|
64
117
|
* Add member to the organization in the database.
|
|
65
118
|
* @param body - Updated organization members data.
|
|
66
119
|
*/
|
|
67
|
-
const addOrganizationMember = async (body, otherOptions = {}) => fetcher(
|
|
68
|
-
method:
|
|
120
|
+
const addOrganizationMember = async (body, otherOptions = {}) => fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.addOrganizationMember), authAPIOptions, otherOptions, {
|
|
121
|
+
method: organizationEndpoints.addOrganizationMember.method,
|
|
69
122
|
body
|
|
70
123
|
});
|
|
71
124
|
/**
|
|
72
125
|
* Deletes an organization from the database by its ID.
|
|
73
126
|
* @param organizationId - Organization ID.
|
|
74
127
|
*/
|
|
75
|
-
const deleteOrganization = async (otherOptions = {}) => await fetcher(
|
|
128
|
+
const deleteOrganization = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.deleteOrganization), authAPIOptions, otherOptions, { method: organizationEndpoints.deleteOrganization.method });
|
|
76
129
|
/**
|
|
77
130
|
* Admin-only: Deletes any organization from the database by its ID.
|
|
78
131
|
* @param organizationId - Organization ID.
|
|
79
132
|
*/
|
|
80
|
-
const deleteOrganizationByIdAdmin = async (organizationId, otherOptions = {}) => fetcher(
|
|
133
|
+
const deleteOrganizationByIdAdmin = async (organizationId, otherOptions = {}) => fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.deleteOrganizationByIdAdmin, { organizationId: String(organizationId) }), authAPIOptions, otherOptions, { method: organizationEndpoints.deleteOrganizationByIdAdmin.method });
|
|
81
134
|
/**
|
|
82
135
|
* Select an organization from the database by its ID.
|
|
83
136
|
* @param organizationId - Organization ID.
|
|
84
137
|
*/
|
|
85
|
-
const selectOrganization = async (organizationId, otherOptions = {}) => await fetcher(
|
|
138
|
+
const selectOrganization = async (organizationId, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.selectOrganization, { organizationId: String(organizationId) }), authAPIOptions, otherOptions, { method: organizationEndpoints.selectOrganization.method });
|
|
86
139
|
/**
|
|
87
140
|
* Unselect an organization from the database by its ID.
|
|
88
141
|
* @param organizationId - Organization ID.
|
|
89
142
|
*/
|
|
90
|
-
const unselectOrganization = async (otherOptions = {}) => await fetcher(
|
|
143
|
+
const unselectOrganization = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, organizationGroup, organizationEndpoints.unselectOrganization), authAPIOptions, otherOptions, { method: organizationEndpoints.unselectOrganization.method });
|
|
91
144
|
return {
|
|
92
145
|
getOrganizations,
|
|
93
|
-
getOrganization,
|
|
94
146
|
addOrganization,
|
|
95
147
|
addOrganizationMember,
|
|
96
148
|
updateOrganization,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization.mjs","names":[],"sources":["../../../src/getIntlayerAPI/organization.ts"],"sourcesContent":["import type {\n AddOrganizationBody,\n AddOrganizationMemberBody,\n AddOrganizationMemberResult,\n AddOrganizationResult,\n DeleteOrganizationResult,\n GetOrganizationParam,\n GetOrganizationResult,\n GetOrganizationsParams,\n GetOrganizationsResult,\n SelectOrganizationParam,\n SelectOrganizationResult,\n UnselectOrganizationResult,\n UpdateOrganizationBody,\n UpdateOrganizationMailerConfigBody,\n UpdateOrganizationMailerConfigResult,\n UpdateOrganizationMembersBody,\n UpdateOrganizationMembersResult,\n UpdateOrganizationResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getOrganizationAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const ORGANIZATION_API_ROUTE = `${backendURL}/api/organization`;\n\n /**\n * Retrieves a list of organizations based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getOrganizations = async (\n filters?: GetOrganizationsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationsResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves an organization by its ID.\n * @param organizationId - Organization ID.\n */\n const getOrganization = async (\n organizationId: GetOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Adds a new organization to the database.\n * @param organization - Organization data.\n */\n const addOrganization = async (\n organization: AddOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: organization,\n }\n );\n\n /**\n * Updates an existing organization in the database.\n * @param organization - Updated organization data.\n */\n const updateOrganization = async (\n organization: UpdateOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: organization,\n }\n );\n\n /**\n * Updates the per-organization transactional mailer configuration.\n * @param body - Mailer configuration. Secrets are optional; omit to keep the\n * value already stored.\n */\n const updateOrganizationMailerConfig = async (\n body: UpdateOrganizationMailerConfigBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMailerConfigResult>(\n `${ORGANIZATION_API_ROUTE}/mailer-config`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Update members to the organization in the database.\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembers = async (\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n `${ORGANIZATION_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Admin-only: Update members of any organization by ID\n * @param organizationId - Organization ID\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembersById = async (\n organizationId: string,\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n `${ORGANIZATION_API_ROUTE}/${organizationId}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Add member to the organization in the database.\n * @param body - Updated organization members data.\n */\n const addOrganizationMember = async (\n body: AddOrganizationMemberBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<AddOrganizationMemberResult>(\n `${ORGANIZATION_API_ROUTE}/member`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Deletes an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Admin-only: Deletes any organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganizationByIdAdmin = async (\n organizationId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${organizationId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const selectOrganization = async (\n organizationId: SelectOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const unselectOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getOrganizations,\n getOrganization,\n addOrganization,\n addOrganizationMember,\n updateOrganization,\n updateOrganizationMailerConfig,\n updateOrganizationMembers,\n updateOrganizationMembersById,\n deleteOrganization,\n deleteOrganizationByIdAdmin,\n selectOrganization,\n unselectOrganization,\n };\n};\n\n/**\n * Authenticated `organization` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const organizationEndpoint = createEndpoint(getOrganizationAPI);\n"],"mappings":";;;;;AAyBA,MAAa,sBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,yBAAyB,GAFZ,gBAAgB,QAAQ,cAAc,OAAO,WAEnB;;;;;CAM7C,MAAM,mBAAmB,OACvB,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,wBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;;CAMF,MAAM,kBAAkB,OACtB,gBACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,uBAAuB,GAAG,OAAO,cAAc,KAClD,gBACA,YACF;;;;;CAMF,MAAM,kBAAkB,OACtB,cACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,wBACA,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,qBAAqB,OACzB,cACA,eAA+B,CAAC,MAEhC,QACE,wBACA,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;;CAOF,MAAM,iCAAiC,OACrC,MACA,eAA+B,CAAC,MAEhC,QACE,GAAG,uBAAuB,iBAC1B,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;;CAMF,MAAM,4BAA4B,OAChC,MACA,eAA+B,CAAC,MAEhC,QACE,GAAG,uBAAuB,WAC1B,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;;;CAOF,MAAM,gCAAgC,OACpC,gBACA,MACA,eAA+B,CAAC,MAEhC,QACE,GAAG,uBAAuB,GAAG,eAAe,WAC5C,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;;CAMF,MAAM,wBAAwB,OAC5B,MACA,eAA+B,CAAC,MAEhC,QACE,GAAG,uBAAuB,UAC1B,gBACA,cACA;EACE,QAAQ;EACR;CACF,CACF;;;;;CAMF,MAAM,qBAAqB,OAAO,eAA+B,CAAC,MAChE,MAAM,QACJ,wBACA,gBACA,cACA,EACE,QAAQ,SACV,CACF;;;;;CAMF,MAAM,8BAA8B,OAClC,gBACA,eAA+B,CAAC,MAEhC,QACE,GAAG,uBAAuB,GAAG,eAAe,SAC5C,gBACA,cACA,EAAE,QAAQ,SAAS,CACrB;;;;;CAMF,MAAM,qBAAqB,OACzB,gBACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,GAAG,uBAAuB,GAAG,OAAO,cAAc,KAClD,gBACA,cACA,EACE,QAAQ,MACV,CACF;;;;;CAMF,MAAM,uBAAuB,OAAO,eAA+B,CAAC,MAClE,MAAM,QACJ,GAAG,uBAAuB,UAC1B,gBACA,cACA,EACE,QAAQ,OACV,CACF;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,uBAAuB,eAAe,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"organization.mjs","names":[],"sources":["../../../src/getIntlayerAPI/organization.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n AddOrganizationBody,\n AddOrganizationMemberBody,\n AddOrganizationMemberResult,\n AddOrganizationResult,\n DeleteOrganizationResult,\n GetOrganizationsParams,\n GetOrganizationsResult,\n OrganizationRoutes,\n organizationContract,\n SelectOrganizationParam,\n SelectOrganizationResult,\n UnselectOrganizationResult,\n UpdateOrganizationBody,\n UpdateOrganizationMailerConfigBody,\n UpdateOrganizationMailerConfigResult,\n UpdateOrganizationMembersBody,\n UpdateOrganizationMembersResult,\n UpdateOrganizationResult,\n} from '@intlayer/backend-contract/organization';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\n/** Prefix of the routes, checked against the backend contract. */\nconst organizationGroup = {\n prefix: '/api/organization',\n} as const satisfies Pick<typeof organizationContract, 'prefix'>;\n\n/**\n * Method and path of every route, checked against the backend contract at\n * compile time (the contract's zod schemas are never loaded).\n */\nconst organizationEndpoints = {\n getOrganizations: { method: 'GET', path: '/' },\n addOrganization: { method: 'POST', path: '/' },\n updateOrganization: { method: 'PUT', path: '/' },\n updateOrganizationMailerConfig: { method: 'PUT', path: '/mailer-config' },\n updateOrganizationMembers: { method: 'PUT', path: '/members' },\n updateOrganizationMembersById: {\n method: 'PUT',\n path: '/:organizationId/members',\n },\n addOrganizationMember: { method: 'POST', path: '/member' },\n deleteOrganization: { method: 'DELETE', path: '/' },\n selectOrganization: { method: 'PUT', path: '/:organizationId' },\n unselectOrganization: { method: 'POST', path: '/logout' },\n deleteOrganizationByIdAdmin: {\n method: 'DELETE',\n path: '/:organizationId/admin',\n },\n} as const satisfies RouteEndpoints<OrganizationRoutes>;\n\nexport const getOrganizationAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /**\n * Retrieves a list of organizations based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getOrganizations = async (\n filters?: GetOrganizationsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationsResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.getOrganizations\n ),\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves an organization by its ID.\n * @param organizationId - Organization ID.\n */\n /**\n * Adds a new organization to the database.\n * @param organization - Organization data.\n */\n const addOrganization = async (\n organization: AddOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddOrganizationResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.addOrganization\n ),\n authAPIOptions,\n otherOptions,\n {\n method: organizationEndpoints.addOrganization.method,\n body: organization,\n }\n );\n\n /**\n * Updates an existing organization in the database.\n * @param organization - Updated organization data.\n */\n const updateOrganization = async (\n organization: UpdateOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.updateOrganization\n ),\n authAPIOptions,\n otherOptions,\n {\n method: organizationEndpoints.updateOrganization.method,\n body: organization,\n }\n );\n\n /**\n * Updates the per-organization transactional mailer configuration.\n * @param body - Mailer configuration. Secrets are optional; omit to keep the\n * value already stored.\n */\n const updateOrganizationMailerConfig = async (\n body: UpdateOrganizationMailerConfigBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMailerConfigResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.updateOrganizationMailerConfig\n ),\n authAPIOptions,\n otherOptions,\n {\n method: organizationEndpoints.updateOrganizationMailerConfig.method,\n body,\n }\n );\n\n /**\n * Update members to the organization in the database.\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembers = async (\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.updateOrganizationMembers\n ),\n authAPIOptions,\n otherOptions,\n {\n method: organizationEndpoints.updateOrganizationMembers.method,\n body,\n }\n );\n\n /**\n * Admin-only: Update members of any organization by ID\n * @param organizationId - Organization ID\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembersById = async (\n organizationId: string,\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.updateOrganizationMembersById,\n { organizationId: String(organizationId) }\n ),\n authAPIOptions,\n otherOptions,\n {\n method: organizationEndpoints.updateOrganizationMembersById.method,\n body,\n }\n );\n\n /**\n * Add member to the organization in the database.\n * @param body - Updated organization members data.\n */\n const addOrganizationMember = async (\n body: AddOrganizationMemberBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<AddOrganizationMemberResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.addOrganizationMember\n ),\n authAPIOptions,\n otherOptions,\n {\n method: organizationEndpoints.addOrganizationMember.method,\n body,\n }\n );\n\n /**\n * Deletes an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteOrganizationResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.deleteOrganization\n ),\n authAPIOptions,\n otherOptions,\n {\n method: organizationEndpoints.deleteOrganization.method,\n }\n );\n\n /**\n * Admin-only: Deletes any organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganizationByIdAdmin = async (\n organizationId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteOrganizationResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.deleteOrganizationByIdAdmin,\n { organizationId: String(organizationId) }\n ),\n authAPIOptions,\n otherOptions,\n { method: organizationEndpoints.deleteOrganizationByIdAdmin.method }\n );\n\n /**\n * Select an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const selectOrganization = async (\n organizationId: SelectOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectOrganizationResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.selectOrganization,\n { organizationId: String(organizationId) }\n ),\n authAPIOptions,\n otherOptions,\n {\n method: organizationEndpoints.selectOrganization.method,\n }\n );\n\n /**\n * Unselect an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const unselectOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectOrganizationResult>(\n buildRouteURL(\n backendURL,\n organizationGroup,\n organizationEndpoints.unselectOrganization\n ),\n authAPIOptions,\n otherOptions,\n {\n method: organizationEndpoints.unselectOrganization.method,\n }\n );\n\n return {\n getOrganizations,\n addOrganization,\n addOrganizationMember,\n updateOrganization,\n updateOrganizationMailerConfig,\n updateOrganizationMembers,\n updateOrganizationMembersById,\n deleteOrganization,\n deleteOrganizationByIdAdmin,\n selectOrganization,\n unselectOrganization,\n };\n};\n\n/**\n * Authenticated `organization` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const organizationEndpoint = createEndpoint(getOrganizationAPI);\n"],"mappings":"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"}
|
|
@@ -1,16 +1,99 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
2
|
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
3
3
|
import { editor } from "@intlayer/config/built";
|
|
4
|
+
import { buildRouteURL } from "@intlayer/backend-contract/defineRoute";
|
|
5
|
+
import { BACKEND_URL } from "@intlayer/config/defaultValues";
|
|
4
6
|
|
|
5
7
|
//#region src/getIntlayerAPI/project.ts
|
|
8
|
+
/** Prefix of the project routes, checked against the backend contract. */
|
|
9
|
+
const projectGroup = { prefix: "/api/project" };
|
|
10
|
+
/**
|
|
11
|
+
* Method and path of every project route, checked against the backend
|
|
12
|
+
* contract at compile time (the contract's zod schemas are never loaded).
|
|
13
|
+
*/
|
|
14
|
+
const projectEndpoints = {
|
|
15
|
+
getProjects: {
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: "/"
|
|
18
|
+
},
|
|
19
|
+
getProjectInsights: {
|
|
20
|
+
method: "GET",
|
|
21
|
+
path: "/insights"
|
|
22
|
+
},
|
|
23
|
+
addProject: {
|
|
24
|
+
method: "POST",
|
|
25
|
+
path: "/"
|
|
26
|
+
},
|
|
27
|
+
updateProject: {
|
|
28
|
+
method: "PUT",
|
|
29
|
+
path: "/"
|
|
30
|
+
},
|
|
31
|
+
updateProjectMembers: {
|
|
32
|
+
method: "PUT",
|
|
33
|
+
path: "/members"
|
|
34
|
+
},
|
|
35
|
+
pushProjectConfiguration: {
|
|
36
|
+
method: "PUT",
|
|
37
|
+
path: "/configuration"
|
|
38
|
+
},
|
|
39
|
+
deleteProject: {
|
|
40
|
+
method: "DELETE",
|
|
41
|
+
path: "/"
|
|
42
|
+
},
|
|
43
|
+
selectProject: {
|
|
44
|
+
method: "PUT",
|
|
45
|
+
path: "/:projectId"
|
|
46
|
+
},
|
|
47
|
+
unselectProject: {
|
|
48
|
+
method: "POST",
|
|
49
|
+
path: "/logout"
|
|
50
|
+
},
|
|
51
|
+
addNewAccessKey: {
|
|
52
|
+
method: "POST",
|
|
53
|
+
path: "/access_key"
|
|
54
|
+
},
|
|
55
|
+
refreshAccessKey: {
|
|
56
|
+
method: "PATCH",
|
|
57
|
+
path: "/access_key"
|
|
58
|
+
},
|
|
59
|
+
deleteAccessKey: {
|
|
60
|
+
method: "DELETE",
|
|
61
|
+
path: "/access_key"
|
|
62
|
+
},
|
|
63
|
+
triggerBuild: {
|
|
64
|
+
method: "POST",
|
|
65
|
+
path: "/build"
|
|
66
|
+
},
|
|
67
|
+
triggerWebhook: {
|
|
68
|
+
method: "POST",
|
|
69
|
+
path: "/webhook"
|
|
70
|
+
},
|
|
71
|
+
getCIConfiguration: {
|
|
72
|
+
method: "GET",
|
|
73
|
+
path: "/ci"
|
|
74
|
+
},
|
|
75
|
+
pushCIConfiguration: {
|
|
76
|
+
method: "POST",
|
|
77
|
+
path: "/ci"
|
|
78
|
+
},
|
|
79
|
+
deleteProjectByIdAdmin: {
|
|
80
|
+
method: "DELETE",
|
|
81
|
+
path: "/:projectId/admin"
|
|
82
|
+
},
|
|
83
|
+
updateMemberAccess: {
|
|
84
|
+
method: "PUT",
|
|
85
|
+
path: "/member/:userId/access"
|
|
86
|
+
}
|
|
87
|
+
};
|
|
6
88
|
const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
7
|
-
const
|
|
89
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;
|
|
8
90
|
/**
|
|
9
91
|
* Retrieves a list of projects based on filters and pagination.
|
|
10
92
|
* @param filters - Filters and pagination options.
|
|
11
93
|
*/
|
|
12
|
-
const getProjects = async (filters, otherOptions = {}) => await fetcher(
|
|
94
|
+
const getProjects = async (filters, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.getProjects), authAPIOptions, otherOptions, {
|
|
13
95
|
cache: "no-store",
|
|
96
|
+
method: projectEndpoints.getProjects.method,
|
|
14
97
|
params: filters
|
|
15
98
|
});
|
|
16
99
|
/**
|
|
@@ -18,69 +101,69 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
18
101
|
* project (locale/key counts, per-locale completion, missing translations,
|
|
19
102
|
* recent activity, team/config status).
|
|
20
103
|
*/
|
|
21
|
-
const getProjectInsights = async (otherOptions = {}) => await fetcher(
|
|
104
|
+
const getProjectInsights = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.getProjectInsights), authAPIOptions, otherOptions, {
|
|
22
105
|
cache: "no-store",
|
|
23
|
-
method:
|
|
106
|
+
method: projectEndpoints.getProjectInsights.method
|
|
24
107
|
});
|
|
25
108
|
/**
|
|
26
109
|
* Adds a new project to the database.
|
|
27
110
|
* @param project - Project data.
|
|
28
111
|
*/
|
|
29
|
-
const addProject = async (project, otherOptions = {}) => await fetcher(
|
|
30
|
-
method:
|
|
112
|
+
const addProject = async (project, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.addProject), authAPIOptions, otherOptions, {
|
|
113
|
+
method: projectEndpoints.addProject.method,
|
|
31
114
|
body: project
|
|
32
115
|
});
|
|
33
116
|
/**
|
|
34
117
|
* Updates an existing project in the database.
|
|
35
118
|
* @param project - Updated project data.
|
|
36
119
|
*/
|
|
37
|
-
const updateProject = async (project, otherOptions = {}) => await fetcher(
|
|
38
|
-
method:
|
|
120
|
+
const updateProject = async (project, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.updateProject), authAPIOptions, otherOptions, {
|
|
121
|
+
method: projectEndpoints.updateProject.method,
|
|
39
122
|
body: project
|
|
40
123
|
});
|
|
41
124
|
/**
|
|
42
125
|
* Updates project members in the database.
|
|
43
126
|
* @param project - Updated project data.
|
|
44
127
|
*/
|
|
45
|
-
const updateProjectMembers = async (body, otherOptions = {}) => await fetcher(
|
|
46
|
-
method:
|
|
128
|
+
const updateProjectMembers = async (body, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.updateProjectMembers), authAPIOptions, otherOptions, {
|
|
129
|
+
method: projectEndpoints.updateProjectMembers.method,
|
|
47
130
|
body
|
|
48
131
|
});
|
|
49
132
|
/** Pushes a project configuration to the database.
|
|
50
133
|
* @param projectConfiguration - Project configuration data.
|
|
51
134
|
*/
|
|
52
|
-
const pushProjectConfiguration = async (projectConfiguration, otherOptions = {}) => await fetcher(
|
|
53
|
-
method:
|
|
135
|
+
const pushProjectConfiguration = async (projectConfiguration, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.pushProjectConfiguration), authAPIOptions, otherOptions, {
|
|
136
|
+
method: projectEndpoints.pushProjectConfiguration.method,
|
|
54
137
|
body: projectConfiguration
|
|
55
138
|
});
|
|
56
139
|
/**
|
|
57
140
|
* Deletes a project from the database by its ID.
|
|
58
141
|
* @param id - Project ID.
|
|
59
142
|
*/
|
|
60
|
-
const deleteProject = async (otherOptions = {}) => await fetcher(
|
|
143
|
+
const deleteProject = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.deleteProject), authAPIOptions, otherOptions, { method: projectEndpoints.deleteProject.method });
|
|
61
144
|
/**
|
|
62
145
|
* Admin-only: Deletes any project from the database by its ID.
|
|
63
146
|
* @param projectId - Project ID.
|
|
64
147
|
*/
|
|
65
|
-
const deleteProjectByIdAdmin = async (projectId, otherOptions = {}) => fetcher(
|
|
148
|
+
const deleteProjectByIdAdmin = async (projectId, otherOptions = {}) => fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.deleteProjectByIdAdmin, { projectId }), authAPIOptions, otherOptions, { method: projectEndpoints.deleteProjectByIdAdmin.method });
|
|
66
149
|
/**
|
|
67
150
|
* Select a project from the database by its ID.
|
|
68
151
|
* @param projectId - Organization ID.
|
|
69
152
|
*/
|
|
70
|
-
const selectProject = async (projectId, otherOptions = {}) => await fetcher(
|
|
153
|
+
const selectProject = async (projectId, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.selectProject, { projectId: String(projectId) }), authAPIOptions, otherOptions, { method: projectEndpoints.selectProject.method });
|
|
71
154
|
/**
|
|
72
155
|
* Unselect a project from the database by its ID.
|
|
73
156
|
* @param projectId - Project ID.
|
|
74
157
|
*/
|
|
75
|
-
const unselectProject = async (otherOptions = {}) => await fetcher(
|
|
158
|
+
const unselectProject = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.unselectProject), authAPIOptions, otherOptions, { method: projectEndpoints.unselectProject.method });
|
|
76
159
|
/**
|
|
77
160
|
* Add a new access key to a project.
|
|
78
161
|
* @param accessKey - Access key data.
|
|
79
162
|
* @param otherOptions - Fetcher options.
|
|
80
163
|
* @returns The new access key.
|
|
81
164
|
*/
|
|
82
|
-
const addNewAccessKey = async (accessKey, otherOptions = {}) => await fetcher(
|
|
83
|
-
method:
|
|
165
|
+
const addNewAccessKey = async (accessKey, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.addNewAccessKey), authAPIOptions, otherOptions, {
|
|
166
|
+
method: projectEndpoints.addNewAccessKey.method,
|
|
84
167
|
body: accessKey
|
|
85
168
|
});
|
|
86
169
|
/**
|
|
@@ -89,8 +172,8 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
89
172
|
* @param otherOptions - Fetcher options.
|
|
90
173
|
* @returns The deleted project.
|
|
91
174
|
*/
|
|
92
|
-
const deleteAccessKey = async (clientId, otherOptions = {}) => await fetcher(
|
|
93
|
-
method:
|
|
175
|
+
const deleteAccessKey = async (clientId, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.deleteAccessKey), authAPIOptions, otherOptions, {
|
|
176
|
+
method: projectEndpoints.deleteAccessKey.method,
|
|
94
177
|
body: { clientId }
|
|
95
178
|
});
|
|
96
179
|
/**
|
|
@@ -99,8 +182,8 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
99
182
|
* @param projectId - The ID of the project to refresh the access key from.
|
|
100
183
|
* @returns The new access key.
|
|
101
184
|
*/
|
|
102
|
-
const refreshAccessKey = async (clientId, otherOptions = {}) => await fetcher(
|
|
103
|
-
method:
|
|
185
|
+
const refreshAccessKey = async (clientId, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.refreshAccessKey), authAPIOptions, otherOptions, {
|
|
186
|
+
method: projectEndpoints.refreshAccessKey.method,
|
|
104
187
|
body: { clientId }
|
|
105
188
|
});
|
|
106
189
|
/**
|
|
@@ -108,15 +191,15 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
108
191
|
* @param otherOptions - Fetcher options.
|
|
109
192
|
* @returns The trigger results.
|
|
110
193
|
*/
|
|
111
|
-
const triggerBuild = async (otherOptions = {}) => await fetcher(
|
|
194
|
+
const triggerBuild = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.triggerBuild), authAPIOptions, otherOptions, { method: projectEndpoints.triggerBuild.method });
|
|
112
195
|
/**
|
|
113
196
|
* Triggers a single webhook by index.
|
|
114
197
|
* @param webhookIndex - The index of the webhook to trigger.
|
|
115
198
|
* @param otherOptions - Fetcher options.
|
|
116
199
|
* @returns The trigger result.
|
|
117
200
|
*/
|
|
118
|
-
const triggerWebhook = async (webhookIndex, otherOptions = {}) => await fetcher(
|
|
119
|
-
method:
|
|
201
|
+
const triggerWebhook = async (webhookIndex, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.triggerWebhook), authAPIOptions, otherOptions, {
|
|
202
|
+
method: projectEndpoints.triggerWebhook.method,
|
|
120
203
|
body: { webhookIndex }
|
|
121
204
|
});
|
|
122
205
|
/**
|
|
@@ -124,20 +207,20 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
124
207
|
* @param otherOptions - Fetcher options.
|
|
125
208
|
* @returns The CI configuration status.
|
|
126
209
|
*/
|
|
127
|
-
const getCIConfig = async (otherOptions = {}) => await fetcher(
|
|
210
|
+
const getCIConfig = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.getCIConfiguration), authAPIOptions, otherOptions, { method: projectEndpoints.getCIConfiguration.method });
|
|
128
211
|
/**
|
|
129
212
|
* Push CI configuration file to the repository.
|
|
130
213
|
* @param otherOptions - Fetcher options.
|
|
131
214
|
* @returns Success status.
|
|
132
215
|
*/
|
|
133
|
-
const pushCIConfig = async (otherOptions = {}) => await fetcher(
|
|
216
|
+
const pushCIConfig = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.pushCIConfiguration), authAPIOptions, otherOptions, { method: projectEndpoints.pushCIConfiguration.method });
|
|
134
217
|
/**
|
|
135
218
|
* Updates granular access constraints for a project member.
|
|
136
219
|
* @param userId - The user ID to update access for.
|
|
137
220
|
* @param body - The new access constraints.
|
|
138
221
|
*/
|
|
139
|
-
const updateMemberAccess = async (userId, body, otherOptions = {}) => await fetcher(
|
|
140
|
-
method:
|
|
222
|
+
const updateMemberAccess = async (userId, body, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, projectGroup, projectEndpoints.updateMemberAccess, { userId }), authAPIOptions, otherOptions, {
|
|
223
|
+
method: projectEndpoints.updateMemberAccess.method,
|
|
141
224
|
body
|
|
142
225
|
});
|
|
143
226
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.mjs","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectInsightsResult,\n GetProjectsParams,\n GetProjectsResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n ResponseData,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateMemberAccessBody,\n UpdateMemberAccessResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves aggregated localization insights for the currently selected\n * project (locale/key counts, per-locale completion, missing translations,\n * recent activity, team/config status).\n */\n const getProjectInsights = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetProjectInsightsResult>(\n `${PROJECT_API_ROUTE}/insights`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n method: 'GET',\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Admin-only: Deletes any project from the database by its ID.\n * @param projectId - Project ID.\n */\n const deleteProjectByIdAdmin = async (\n projectId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}/${projectId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Updates granular access constraints for a project member.\n * @param userId - The user ID to update access for.\n * @param body - The new access constraints.\n */\n const updateMemberAccess = async (\n userId: string,\n body: UpdateMemberAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateMemberAccessResult>(\n `${PROJECT_API_ROUTE}/member/${userId}/access`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n return {\n getProjects,\n getProjectInsights,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n deleteProjectByIdAdmin,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n updateMemberAccess,\n };\n};\n\n/**\n * Authenticated `project` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const projectEndpoint = createEndpoint(getProjectAPI);\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"project.mjs","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectInsightsResult,\n GetProjectsParams,\n GetProjectsResult,\n ProjectRoutes,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n projectContract,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateMemberAccessBody,\n UpdateMemberAccessResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '@intlayer/backend-contract/project';\nimport type { ResponseData } from '@intlayer/backend-contract/responseData';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\n/** Prefix of the project routes, checked against the backend contract. */\nconst projectGroup = {\n prefix: '/api/project',\n} as const satisfies Pick<typeof projectContract, 'prefix'>;\n\n/**\n * Method and path of every project route, checked against the backend\n * contract at compile time (the contract's zod schemas are never loaded).\n */\nconst projectEndpoints = {\n getProjects: { method: 'GET', path: '/' },\n getProjectInsights: { method: 'GET', path: '/insights' },\n addProject: { method: 'POST', path: '/' },\n updateProject: { method: 'PUT', path: '/' },\n updateProjectMembers: { method: 'PUT', path: '/members' },\n pushProjectConfiguration: { method: 'PUT', path: '/configuration' },\n deleteProject: { method: 'DELETE', path: '/' },\n selectProject: { method: 'PUT', path: '/:projectId' },\n unselectProject: { method: 'POST', path: '/logout' },\n addNewAccessKey: { method: 'POST', path: '/access_key' },\n refreshAccessKey: { method: 'PATCH', path: '/access_key' },\n deleteAccessKey: { method: 'DELETE', path: '/access_key' },\n triggerBuild: { method: 'POST', path: '/build' },\n triggerWebhook: { method: 'POST', path: '/webhook' },\n getCIConfiguration: { method: 'GET', path: '/ci' },\n pushCIConfiguration: { method: 'POST', path: '/ci' },\n deleteProjectByIdAdmin: { method: 'DELETE', path: '/:projectId/admin' },\n updateMemberAccess: { method: 'PUT', path: '/member/:userId/access' },\n} as const satisfies RouteEndpoints<ProjectRoutes>;\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.getProjects),\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n method: projectEndpoints.getProjects.method,\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves aggregated localization insights for the currently selected\n * project (locale/key counts, per-locale completion, missing translations,\n * recent activity, team/config status).\n */\n const getProjectInsights = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetProjectInsightsResult>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.getProjectInsights\n ),\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n method: projectEndpoints.getProjectInsights.method,\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.addProject),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.addProject.method,\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.updateProject),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.updateProject.method,\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.updateProjectMembers\n ),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.updateProjectMembers.method,\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.pushProjectConfiguration\n ),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.pushProjectConfiguration.method,\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.deleteProject),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.deleteProject.method,\n }\n );\n\n /**\n * Admin-only: Deletes any project from the database by its ID.\n * @param projectId - Project ID.\n */\n const deleteProjectByIdAdmin = async (\n projectId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteProjectResult>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.deleteProjectByIdAdmin,\n { projectId }\n ),\n authAPIOptions,\n otherOptions,\n { method: projectEndpoints.deleteProjectByIdAdmin.method }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.selectProject, {\n projectId: String(projectId),\n }),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.selectProject.method,\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.unselectProject),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.unselectProject.method,\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.addNewAccessKey),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.addNewAccessKey.method,\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.deleteAccessKey),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.deleteAccessKey.method,\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.refreshAccessKey\n ),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.refreshAccessKey.method,\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.triggerBuild),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.triggerBuild.method,\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n buildRouteURL(backendURL, projectGroup, projectEndpoints.triggerWebhook),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.triggerWebhook.method,\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.getCIConfiguration\n ),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.getCIConfiguration.method,\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.pushCIConfiguration\n ),\n authAPIOptions,\n otherOptions,\n {\n method: projectEndpoints.pushCIConfiguration.method,\n }\n );\n\n /**\n * Updates granular access constraints for a project member.\n * @param userId - The user ID to update access for.\n * @param body - The new access constraints.\n */\n const updateMemberAccess = async (\n userId: string,\n body: UpdateMemberAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateMemberAccessResult>(\n buildRouteURL(\n backendURL,\n projectGroup,\n projectEndpoints.updateMemberAccess,\n { userId }\n ),\n authAPIOptions,\n otherOptions,\n { method: projectEndpoints.updateMemberAccess.method, body }\n );\n\n return {\n getProjects,\n getProjectInsights,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n deleteProjectByIdAdmin,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n updateMemberAccess,\n };\n};\n\n/**\n * Authenticated `project` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const projectEndpoint = createEndpoint(getProjectAPI);\n"],"mappings":"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"}
|