@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":"environment.mjs","names":[],"sources":["../../../src/getIntlayerAPI/environment.ts"],"sourcesContent":["import type {\n AddEnvironmentBody,\n AddEnvironmentResult,\n DeleteEnvironmentResult,\n MigrateEnvironmentBody,\n MigrateEnvironmentResult,\n ResetToProductionEnvironmentResult,\n SelectEnvironmentResult,\n UpdateEnvironmentBody,\n UpdateEnvironmentResult,\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 getEnvironmentAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL
|
|
1
|
+
{"version":3,"file":"environment.mjs","names":[],"sources":["../../../src/getIntlayerAPI/environment.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n AddEnvironmentBody,\n AddEnvironmentResult,\n DeleteEnvironmentResult,\n EnvironmentRoutes,\n environmentContract,\n MigrateEnvironmentBody,\n MigrateEnvironmentResult,\n ResetToProductionEnvironmentResult,\n SelectEnvironmentResult,\n UpdateEnvironmentBody,\n UpdateEnvironmentResult,\n} from '@intlayer/backend-contract/environment';\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 environmentGroup = {\n prefix: '/api/project/environment',\n} as const satisfies Pick<typeof environmentContract, '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 environmentEndpoints = {\n addEnvironment: { method: 'POST', path: '/' },\n updateEnvironment: { method: 'PUT', path: '/:environmentId' },\n deleteEnvironment: { method: 'DELETE', path: '/:environmentId' },\n resetToProductionEnvironment: { method: 'PUT', path: '/production/select' },\n selectEnvironment: { method: 'PUT', path: '/:environmentId/select' },\n migrateEnvironment: { method: 'POST', path: '/migrate' },\n} as const satisfies RouteEndpoints<EnvironmentRoutes>;\n\nexport const getEnvironmentAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n const addEnvironment = async (\n body: AddEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.addEnvironment\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.addEnvironment.method, body }\n );\n\n const updateEnvironment = async (\n environmentId: string,\n body: UpdateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.updateEnvironment,\n { environmentId }\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.updateEnvironment.method, body }\n );\n\n const deleteEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.deleteEnvironment,\n { environmentId }\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.deleteEnvironment.method }\n );\n\n const selectEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.selectEnvironment,\n { environmentId }\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.selectEnvironment.method }\n );\n\n const resetToProductionEnvironment = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetToProductionEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.resetToProductionEnvironment\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.resetToProductionEnvironment.method }\n );\n\n const migrateEnvironment = async (\n body: MigrateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<MigrateEnvironmentResult>(\n buildRouteURL(\n backendURL,\n environmentGroup,\n environmentEndpoints.migrateEnvironment\n ),\n authAPIOptions,\n otherOptions,\n { method: environmentEndpoints.migrateEnvironment.method, body }\n );\n\n return {\n addEnvironment,\n updateEnvironment,\n deleteEnvironment,\n selectEnvironment,\n resetToProductionEnvironment,\n migrateEnvironment,\n };\n};\n\n/**\n * Authenticated `environment` 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 environmentEndpoint = createEndpoint(getEnvironmentAPI);\n"],"mappings":";;;;;;;;AAsBA,MAAM,mBAAmB,EACvB,QAAQ,2BACV;;;;;AAMA,MAAM,uBAAuB;CAC3B,gBAAgB;EAAE,QAAQ;EAAQ,MAAM;CAAI;CAC5C,mBAAmB;EAAE,QAAQ;EAAO,MAAM;CAAkB;CAC5D,mBAAmB;EAAE,QAAQ;EAAU,MAAM;CAAkB;CAC/D,8BAA8B;EAAE,QAAQ;EAAO,MAAM;CAAqB;CAC1E,mBAAmB;EAAE,QAAQ;EAAO,MAAM;CAAyB;CACnE,oBAAoB;EAAE,QAAQ;EAAQ,MAAM;CAAW;AACzD;AAEA,MAAa,qBACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,OAAO,cAAc;CAE7D,MAAM,iBAAiB,OACrB,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cACE,YACA,kBACA,qBAAqB,cACvB,GACA,gBACA,cACA;EAAE,QAAQ,qBAAqB,eAAe;EAAQ;CAAK,CAC7D;CAEF,MAAM,oBAAoB,OACxB,eACA,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cACE,YACA,kBACA,qBAAqB,mBACrB,EAAE,cAAc,CAClB,GACA,gBACA,cACA;EAAE,QAAQ,qBAAqB,kBAAkB;EAAQ;CAAK,CAChE;CAEF,MAAM,oBAAoB,OACxB,eACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cACE,YACA,kBACA,qBAAqB,mBACrB,EAAE,cAAc,CAClB,GACA,gBACA,cACA,EAAE,QAAQ,qBAAqB,kBAAkB,OAAO,CAC1D;CAEF,MAAM,oBAAoB,OACxB,eACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cACE,YACA,kBACA,qBAAqB,mBACrB,EAAE,cAAc,CAClB,GACA,gBACA,cACA,EAAE,QAAQ,qBAAqB,kBAAkB,OAAO,CAC1D;CAEF,MAAM,+BAA+B,OACnC,eAA+B,CAAC,MAEhC,MAAM,QACJ,cACE,YACA,kBACA,qBAAqB,4BACvB,GACA,gBACA,cACA,EAAE,QAAQ,qBAAqB,6BAA6B,OAAO,CACrE;CAEF,MAAM,qBAAqB,OACzB,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cACE,YACA,kBACA,qBAAqB,kBACvB,GACA,gBACA,cACA;EAAE,QAAQ,qBAAqB,mBAAmB;EAAQ;CAAK,CACjE;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,sBAAsB,eAAe,iBAAiB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { editor } from "@intlayer/config/built";
|
|
3
|
+
import { buildRouteURL } from "@intlayer/backend-contract/defineRoute";
|
|
4
|
+
import { BACKEND_URL } from "@intlayer/config/defaultValues";
|
|
5
|
+
|
|
6
|
+
//#region src/getIntlayerAPI/forge.ts
|
|
7
|
+
/**
|
|
8
|
+
* Method and path of every route of a Gitea-compatible forge, checked
|
|
9
|
+
* against the backend contract at compile time.
|
|
10
|
+
*/
|
|
11
|
+
const forgeEndpoints = {
|
|
12
|
+
listRepos: {
|
|
13
|
+
method: "GET",
|
|
14
|
+
path: "/repos"
|
|
15
|
+
},
|
|
16
|
+
checkConfig: {
|
|
17
|
+
method: "POST",
|
|
18
|
+
path: "/check-config"
|
|
19
|
+
},
|
|
20
|
+
getConfigFile: {
|
|
21
|
+
method: "POST",
|
|
22
|
+
path: "/get-config-file"
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Client of a Gitea-compatible forge (Codeberg, Gitee). Omitting `token` makes
|
|
27
|
+
* the backend use the account linked to the session.
|
|
28
|
+
*/
|
|
29
|
+
const createForgeAPI = (group) => (authAPIOptions = {}, intlayerConfig) => {
|
|
30
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;
|
|
31
|
+
/** Repositories of the linked account. */
|
|
32
|
+
const getRepositories = async (token, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, group, forgeEndpoints.listRepos), authAPIOptions, otherOptions, { params: token ? { token } : void 0 });
|
|
33
|
+
/** Paths of the Intlayer configuration files of a repository branch. */
|
|
34
|
+
const checkIntlayerConfig = async (token, owner, repository, branch = "main", otherOptions = {}) => await fetcher(buildRouteURL(backendURL, group, forgeEndpoints.checkConfig), authAPIOptions, otherOptions, {
|
|
35
|
+
method: forgeEndpoints.checkConfig.method,
|
|
36
|
+
body: {
|
|
37
|
+
token: token ?? void 0,
|
|
38
|
+
owner,
|
|
39
|
+
repository,
|
|
40
|
+
branch
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
/** Content of an Intlayer configuration file of a repository. */
|
|
44
|
+
const getConfigFile = async (token, owner, repository, branch = "main", path = "intlayer.config.ts", otherOptions = {}) => await fetcher(buildRouteURL(backendURL, group, forgeEndpoints.getConfigFile), authAPIOptions, otherOptions, {
|
|
45
|
+
method: forgeEndpoints.getConfigFile.method,
|
|
46
|
+
body: {
|
|
47
|
+
token: token ?? void 0,
|
|
48
|
+
owner,
|
|
49
|
+
repository,
|
|
50
|
+
branch,
|
|
51
|
+
path
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
getRepositories,
|
|
56
|
+
checkIntlayerConfig,
|
|
57
|
+
getConfigFile
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { createForgeAPI };
|
|
63
|
+
//# sourceMappingURL=forge.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forge.mjs","names":[],"sources":["../../../src/getIntlayerAPI/forge.ts"],"sourcesContent":["import type {\n RouteEndpoints,\n RouteGroup,\n} from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n ForgeCheckConfigResult,\n ForgeGetConfigFileResult,\n ForgeListReposResult,\n ForgeRoutes,\n} from '@intlayer/backend-contract/gitProviders';\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\nexport type {\n ForgeCheckConfigResult,\n ForgeGetConfigFileResult,\n ForgeListReposResult,\n ForgeRepository,\n} from '@intlayer/backend-contract/gitProviders';\n\n/**\n * Method and path of every route of a Gitea-compatible forge, checked\n * against the backend contract at compile time.\n */\nconst forgeEndpoints = {\n listRepos: { method: 'GET', path: '/repos' },\n checkConfig: { method: 'POST', path: '/check-config' },\n getConfigFile: { method: 'POST', path: '/get-config-file' },\n} as const satisfies RouteEndpoints<ForgeRoutes>;\n\n/**\n * Client of a Gitea-compatible forge (Codeberg, Gitee). Omitting `token` makes\n * the backend use the account linked to the session.\n */\nexport const createForgeAPI =\n <Prefix extends string>(\n group: Pick<RouteGroup<Prefix, ForgeRoutes>, 'prefix'>\n ) =>\n (authAPIOptions: FetcherOptions = {}, intlayerConfig?: IntlayerConfig) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /** Repositories of the linked account. */\n const getRepositories = async (\n token?: string | null,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ForgeListReposResult>(\n buildRouteURL(backendURL, group, forgeEndpoints.listRepos),\n authAPIOptions,\n otherOptions,\n { params: token ? { token } : undefined }\n );\n\n /** Paths of the Intlayer configuration files of a repository branch. */\n const checkIntlayerConfig = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ForgeCheckConfigResult>(\n buildRouteURL(backendURL, group, forgeEndpoints.checkConfig),\n authAPIOptions,\n otherOptions,\n {\n method: forgeEndpoints.checkConfig.method,\n body: { token: token ?? undefined, owner, repository, branch },\n }\n );\n\n /** Content of an Intlayer configuration file of a repository. */\n const getConfigFile = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n path: string = 'intlayer.config.ts',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ForgeGetConfigFileResult>(\n buildRouteURL(backendURL, group, forgeEndpoints.getConfigFile),\n authAPIOptions,\n otherOptions,\n {\n method: forgeEndpoints.getConfigFile.method,\n body: { token: token ?? undefined, owner, repository, branch, path },\n }\n );\n\n return { getRepositories, checkIntlayerConfig, getConfigFile };\n };\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,iBAAiB;CACrB,WAAW;EAAE,QAAQ;EAAO,MAAM;CAAS;CAC3C,aAAa;EAAE,QAAQ;EAAQ,MAAM;CAAgB;CACrD,eAAe;EAAE,QAAQ;EAAQ,MAAM;CAAmB;AAC5D;;;;;AAMA,MAAa,kBAET,WAED,iBAAiC,CAAC,GAAG,mBAAoC;CACxE,MAAM,aACJ,gBAAgB,QAAQ,cAAc,OAAO,cAAc;;CAG7D,MAAM,kBAAkB,OACtB,OACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,OAAO,eAAe,SAAS,GACzD,gBACA,cACA,EAAE,QAAQ,QAAQ,EAAE,MAAM,IAAI,OAAU,CAC1C;;CAGF,MAAM,sBAAsB,OAC1B,OACA,OACA,YACA,SAAiB,QACjB,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,OAAO,eAAe,WAAW,GAC3D,gBACA,cACA;EACE,QAAQ,eAAe,YAAY;EACnC,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;EAAO;CAC/D,CACF;;CAGF,MAAM,gBAAgB,OACpB,OACA,OACA,YACA,SAAiB,QACjB,OAAe,sBACf,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,OAAO,eAAe,aAAa,GAC7D,gBACA,cACA;EACE,QAAQ,eAAe,cAAc;EACrC,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;GAAQ;EAAK;CACrE,CACF;CAEF,OAAO;EAAE;EAAiB;EAAqB;CAAc;AAC/D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
|
+
import { createForgeAPI } from "./forge.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/getIntlayerAPI/gitee.ts
|
|
5
|
+
/** Prefix of the routes, checked against the backend contract. */
|
|
6
|
+
const giteeGroup = { prefix: "/api/gitee" };
|
|
7
|
+
/** Gitee repositories of the linked account. */
|
|
8
|
+
const getGiteeAPI = createForgeAPI(giteeGroup);
|
|
9
|
+
/**
|
|
10
|
+
* Authenticated `gitee` endpoint bound to an Intlayer CMS authenticator.
|
|
11
|
+
*
|
|
12
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
13
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
14
|
+
*/
|
|
15
|
+
const giteeEndpoint = createEndpoint(getGiteeAPI);
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getGiteeAPI, giteeEndpoint };
|
|
19
|
+
//# sourceMappingURL=gitee.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitee.mjs","names":[],"sources":["../../../src/getIntlayerAPI/gitee.ts"],"sourcesContent":["import type { giteeContract } from '@intlayer/backend-contract/gitProviders';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { createForgeAPI } from './forge';\n\n/** Prefix of the routes, checked against the backend contract. */\nconst giteeGroup = {\n prefix: '/api/gitee',\n} as const satisfies Pick<typeof giteeContract, 'prefix'>;\n\n/** Gitee repositories of the linked account. */\nexport const getGiteeAPI = createForgeAPI(giteeGroup);\n\n/**\n * Authenticated `gitee` 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 giteeEndpoint = createEndpoint(getGiteeAPI);\n"],"mappings":";;;;;AAKA,MAAM,aAAa,EACjB,QAAQ,aACV;;AAGA,MAAa,cAAc,eAAe,UAAU;;;;;;;AAQpD,MAAa,gBAAgB,eAAe,WAAW"}
|
|
@@ -1,28 +1,62 @@
|
|
|
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/github.ts
|
|
8
|
+
/** Prefix of the routes, checked against the backend contract. */
|
|
9
|
+
const githubGroup = { prefix: "/api/github" };
|
|
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 githubEndpoints = {
|
|
15
|
+
getAuthUrl: {
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: "/auth-url"
|
|
18
|
+
},
|
|
19
|
+
authCallback: {
|
|
20
|
+
method: "POST",
|
|
21
|
+
path: "/auth"
|
|
22
|
+
},
|
|
23
|
+
listRepos: {
|
|
24
|
+
method: "GET",
|
|
25
|
+
path: "/repos"
|
|
26
|
+
},
|
|
27
|
+
checkConfig: {
|
|
28
|
+
method: "POST",
|
|
29
|
+
path: "/check-config"
|
|
30
|
+
},
|
|
31
|
+
getConfigFile: {
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/get-config-file"
|
|
34
|
+
},
|
|
35
|
+
getToken: {
|
|
36
|
+
method: "GET",
|
|
37
|
+
path: "/token"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
6
40
|
const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
7
|
-
const
|
|
41
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;
|
|
8
42
|
/**
|
|
9
43
|
* Get GitHub OAuth authorization URL
|
|
10
44
|
* @param redirectUri - Redirect URI after OAuth authorization
|
|
11
45
|
*/
|
|
12
|
-
const getAuthUrl = async (redirectUri, otherOptions = {}) => await fetcher(
|
|
46
|
+
const getAuthUrl = async (redirectUri, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, githubGroup, githubEndpoints.getAuthUrl), authAPIOptions, otherOptions, { params: { redirectUri } });
|
|
13
47
|
/**
|
|
14
48
|
* Exchange GitHub authorization code for access token
|
|
15
49
|
* @param code - GitHub authorization code
|
|
16
50
|
*/
|
|
17
|
-
const authenticate = async (code, otherOptions = {}) => await fetcher(
|
|
18
|
-
method:
|
|
51
|
+
const authenticate = async (code, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, githubGroup, githubEndpoints.authCallback), authAPIOptions, otherOptions, {
|
|
52
|
+
method: githubEndpoints.authCallback.method,
|
|
19
53
|
body: { code }
|
|
20
54
|
});
|
|
21
55
|
/**
|
|
22
56
|
* Get user's GitHub repositories
|
|
23
57
|
* @param token - Optional GitHub access token. If not provided, backend will use session.
|
|
24
58
|
*/
|
|
25
|
-
const getRepositories = async (token, otherOptions = {}) => await fetcher(
|
|
59
|
+
const getRepositories = async (token, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, githubGroup, githubEndpoints.listRepos), authAPIOptions, otherOptions, { params: token ? { token } : void 0 });
|
|
26
60
|
/**
|
|
27
61
|
* Check if intlayer.config.ts exists in a repository
|
|
28
62
|
* @param token - Optional GitHub access token. If not provided, backend will use session.
|
|
@@ -30,8 +64,8 @@ const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
30
64
|
* @param repository - Repository name
|
|
31
65
|
* @param branch - Branch name (default: 'main')
|
|
32
66
|
*/
|
|
33
|
-
const checkIntlayerConfig = async (token, owner, repository, branch = "main", otherOptions = {}) => await fetcher(
|
|
34
|
-
method:
|
|
67
|
+
const checkIntlayerConfig = async (token, owner, repository, branch = "main", otherOptions = {}) => await fetcher(buildRouteURL(backendURL, githubGroup, githubEndpoints.checkConfig), authAPIOptions, otherOptions, {
|
|
68
|
+
method: githubEndpoints.checkConfig.method,
|
|
35
69
|
body: {
|
|
36
70
|
token: token ?? void 0,
|
|
37
71
|
owner,
|
|
@@ -47,8 +81,8 @@ const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
47
81
|
* @param branch - Branch name (default: 'main')
|
|
48
82
|
* @param path - File path (default: 'intlayer.config.ts')
|
|
49
83
|
*/
|
|
50
|
-
const getConfigFile = async (token, owner, repository, branch = "main", path = "intlayer.config.ts", otherOptions = {}) => await fetcher(
|
|
51
|
-
method:
|
|
84
|
+
const getConfigFile = async (token, owner, repository, branch = "main", path = "intlayer.config.ts", otherOptions = {}) => await fetcher(buildRouteURL(backendURL, githubGroup, githubEndpoints.getConfigFile), authAPIOptions, otherOptions, {
|
|
85
|
+
method: githubEndpoints.getConfigFile.method,
|
|
52
86
|
body: {
|
|
53
87
|
token: token ?? void 0,
|
|
54
88
|
owner,
|
|
@@ -60,7 +94,7 @@ const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
60
94
|
/**
|
|
61
95
|
* Get user's GitHub token
|
|
62
96
|
*/
|
|
63
|
-
const getToken = async (otherOptions = {}) => await fetcher(
|
|
97
|
+
const getToken = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, githubGroup, githubEndpoints.getToken), authAPIOptions, otherOptions);
|
|
64
98
|
return {
|
|
65
99
|
getAuthUrl,
|
|
66
100
|
authenticate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.mjs","names":[],"sources":["../../../src/getIntlayerAPI/github.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type GitHubRepository = {\n id: number;\n name: string;\n full_name: string;\n owner: {\n login: string;\n id: number;\n };\n html_url: string;\n default_branch: string;\n private: boolean;\n};\n\nexport type GitHubAuthCallbackBody = {\n code: string;\n};\n\nexport type GitHubAuthCallbackResult = {\n data: {\n token: string;\n };\n};\n\nexport type GitHubListReposResult = {\n data: GitHubRepository[];\n};\n\nexport type GitHubCheckConfigBody = {\n token?: string;\n owner: string;\n repository: string;\n branch?: string;\n};\n\nexport type GitHubCheckConfigResult = {\n data: {\n hasConfig: boolean;\n };\n};\n\nexport type GitHubGetConfigFileBody = {\n token?: string;\n owner: string;\n repository: string;\n branch?: string;\n path?: string;\n};\n\nexport type GitHubGetConfigFileResult = {\n data: {\n content: string;\n };\n};\n\nexport type GitHubGetAuthUrlResult = {\n data: {\n authUrl: string;\n };\n};\n\nexport type GitHubGetTokenResult = {\n data: {\n token: string;\n };\n};\n\nexport const getGithubAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL
|
|
1
|
+
{"version":3,"file":"github.mjs","names":[],"sources":["../../../src/getIntlayerAPI/github.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n GitHubRoutes,\n githubContract,\n} from '@intlayer/backend-contract/gitProviders';\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\nexport type GitHubRepository = {\n id: number;\n name: string;\n full_name: string;\n owner: {\n login: string;\n id: number;\n };\n html_url: string;\n default_branch: string;\n private: boolean;\n};\n\nexport type GitHubAuthCallbackBody = {\n code: string;\n};\n\nexport type GitHubAuthCallbackResult = {\n data: {\n token: string;\n };\n};\n\nexport type GitHubListReposResult = {\n data: GitHubRepository[];\n};\n\nexport type GitHubCheckConfigBody = {\n token?: string;\n owner: string;\n repository: string;\n branch?: string;\n};\n\nexport type GitHubCheckConfigResult = {\n data: {\n hasConfig: boolean;\n };\n};\n\nexport type GitHubGetConfigFileBody = {\n token?: string;\n owner: string;\n repository: string;\n branch?: string;\n path?: string;\n};\n\nexport type GitHubGetConfigFileResult = {\n data: {\n content: string;\n };\n};\n\nexport type GitHubGetAuthUrlResult = {\n data: {\n authUrl: string;\n };\n};\n\nexport type GitHubGetTokenResult = {\n data: {\n token: string;\n };\n};\n\n/** Prefix of the routes, checked against the backend contract. */\nconst githubGroup = {\n prefix: '/api/github',\n} as const satisfies Pick<typeof githubContract, '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 githubEndpoints = {\n getAuthUrl: { method: 'GET', path: '/auth-url' },\n authCallback: { method: 'POST', path: '/auth' },\n listRepos: { method: 'GET', path: '/repos' },\n checkConfig: { method: 'POST', path: '/check-config' },\n getConfigFile: { method: 'POST', path: '/get-config-file' },\n getToken: { method: 'GET', path: '/token' },\n} as const satisfies RouteEndpoints<GitHubRoutes>;\n\nexport const getGithubAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /**\n * Get GitHub OAuth authorization URL\n * @param redirectUri - Redirect URI after OAuth authorization\n */\n const getAuthUrl = async (\n redirectUri: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubGetAuthUrlResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.getAuthUrl),\n authAPIOptions,\n otherOptions,\n {\n params: { redirectUri },\n }\n );\n\n /**\n * Exchange GitHub authorization code for access token\n * @param code - GitHub authorization code\n */\n const authenticate = async (\n code: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubAuthCallbackResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.authCallback),\n authAPIOptions,\n otherOptions,\n {\n method: githubEndpoints.authCallback.method,\n body: { code },\n }\n );\n\n /**\n * Get user's GitHub repositories\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n */\n const getRepositories = async (\n token?: string | null,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubListReposResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.listRepos),\n authAPIOptions,\n otherOptions,\n {\n params: token ? { token } : undefined,\n }\n );\n\n /**\n * Check if intlayer.config.ts exists in a repository\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n * @param owner - Repository owner\n * @param repository - Repository name\n * @param branch - Branch name (default: 'main')\n */\n const checkIntlayerConfig = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubCheckConfigResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.checkConfig),\n authAPIOptions,\n otherOptions,\n {\n method: githubEndpoints.checkConfig.method,\n body: { token: token ?? undefined, owner, repository, branch },\n }\n );\n\n /**\n * Get intlayer.config.ts file contents from a repository\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n * @param owner - Repository owner\n * @param repository - Repository name\n * @param branch - Branch name (default: 'main')\n * @param path - File path (default: 'intlayer.config.ts')\n */\n const getConfigFile = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n path: string = 'intlayer.config.ts',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubGetConfigFileResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.getConfigFile),\n authAPIOptions,\n otherOptions,\n {\n method: githubEndpoints.getConfigFile.method,\n body: { token: token ?? undefined, owner, repository, branch, path },\n }\n );\n\n /**\n * Get user's GitHub token\n */\n const getToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GitHubGetTokenResult>(\n buildRouteURL(backendURL, githubGroup, githubEndpoints.getToken),\n authAPIOptions,\n otherOptions\n );\n\n return {\n getAuthUrl,\n authenticate,\n getRepositories,\n checkIntlayerConfig,\n getConfigFile,\n getToken,\n };\n};\n\n/**\n * Authenticated `github` 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 githubEndpoint = createEndpoint(getGithubAPI);\n"],"mappings":";;;;;;;;AA+EA,MAAM,cAAc,EAClB,QAAQ,cACV;;;;;AAMA,MAAM,kBAAkB;CACtB,YAAY;EAAE,QAAQ;EAAO,MAAM;CAAY;CAC/C,cAAc;EAAE,QAAQ;EAAQ,MAAM;CAAQ;CAC9C,WAAW;EAAE,QAAQ;EAAO,MAAM;CAAS;CAC3C,aAAa;EAAE,QAAQ;EAAQ,MAAM;CAAgB;CACrD,eAAe;EAAE,QAAQ;EAAQ,MAAM;CAAmB;CAC1D,UAAU;EAAE,QAAQ;EAAO,MAAM;CAAS;AAC5C;AAEA,MAAa,gBACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,OAAO,cAAc;;;;;CAM7D,MAAM,aAAa,OACjB,aACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,UAAU,GACjE,gBACA,cACA,EACE,QAAQ,EAAE,YAAY,EACxB,CACF;;;;;CAMF,MAAM,eAAe,OACnB,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,YAAY,GACnE,gBACA,cACA;EACE,QAAQ,gBAAgB,aAAa;EACrC,MAAM,EAAE,KAAK;CACf,CACF;;;;;CAMF,MAAM,kBAAkB,OACtB,OACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,SAAS,GAChE,gBACA,cACA,EACE,QAAQ,QAAQ,EAAE,MAAM,IAAI,OAC9B,CACF;;;;;;;;CASF,MAAM,sBAAsB,OAC1B,OACA,OACA,YACA,SAAiB,QACjB,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,WAAW,GAClE,gBACA,cACA;EACE,QAAQ,gBAAgB,YAAY;EACpC,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;EAAO;CAC/D,CACF;;;;;;;;;CAUF,MAAM,gBAAgB,OACpB,OACA,OACA,YACA,SAAiB,QACjB,OAAe,sBACf,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,aAAa,GACpE,gBACA,cACA;EACE,QAAQ,gBAAgB,cAAc;EACtC,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;GAAQ;EAAK;CACrE,CACF;;;;CAKF,MAAM,WAAW,OAAO,eAA+B,CAAC,MACtD,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,QAAQ,GAC/D,gBACA,YACF;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,iBAAiB,eAAe,YAAY"}
|
|
@@ -1,16 +1,46 @@
|
|
|
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/gitlab.ts
|
|
8
|
+
/** Prefix of the routes, checked against the backend contract. */
|
|
9
|
+
const gitlabGroup = { prefix: "/api/gitlab" };
|
|
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 gitlabEndpoints = {
|
|
15
|
+
getAuthUrl: {
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: "/auth-url"
|
|
18
|
+
},
|
|
19
|
+
authCallback: {
|
|
20
|
+
method: "POST",
|
|
21
|
+
path: "/auth"
|
|
22
|
+
},
|
|
23
|
+
listProjects: {
|
|
24
|
+
method: "GET",
|
|
25
|
+
path: "/projects"
|
|
26
|
+
},
|
|
27
|
+
checkConfig: {
|
|
28
|
+
method: "POST",
|
|
29
|
+
path: "/check-config"
|
|
30
|
+
},
|
|
31
|
+
getConfigFile: {
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/get-config-file"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
6
36
|
const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
7
|
-
const
|
|
37
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;
|
|
8
38
|
/**
|
|
9
39
|
* Get GitLab OAuth authorization URL
|
|
10
40
|
* @param redirectUri - Redirect URI after OAuth authorization
|
|
11
41
|
* @param instanceUrl - Custom GitLab instance URL (optional, for self-hosted)
|
|
12
42
|
*/
|
|
13
|
-
const getAuthUrl = async (redirectUri, instanceUrl, otherOptions = {}) => await fetcher(
|
|
43
|
+
const getAuthUrl = async (redirectUri, instanceUrl, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, gitlabGroup, gitlabEndpoints.getAuthUrl), authAPIOptions, otherOptions, { params: {
|
|
14
44
|
redirectUri,
|
|
15
45
|
...instanceUrl && { instanceUrl }
|
|
16
46
|
} });
|
|
@@ -20,8 +50,8 @@ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
20
50
|
* @param redirectUri - Redirect URI used in the authorization request
|
|
21
51
|
* @param instanceUrl - Custom GitLab instance URL (optional)
|
|
22
52
|
*/
|
|
23
|
-
const authenticate = async (code, redirectUri, instanceUrl, otherOptions = {}) => await fetcher(
|
|
24
|
-
method:
|
|
53
|
+
const authenticate = async (code, redirectUri, instanceUrl, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, gitlabGroup, gitlabEndpoints.authCallback), authAPIOptions, otherOptions, {
|
|
54
|
+
method: gitlabEndpoints.authCallback.method,
|
|
25
55
|
body: {
|
|
26
56
|
code,
|
|
27
57
|
redirectUri,
|
|
@@ -33,7 +63,7 @@ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
33
63
|
* @param token - Optional GitLab access token. If not provided, backend will use session.
|
|
34
64
|
* @param instanceUrl - Custom GitLab instance URL (optional)
|
|
35
65
|
*/
|
|
36
|
-
const getProjects = async (token, instanceUrl, otherOptions = {}) => await fetcher(
|
|
66
|
+
const getProjects = async (token, instanceUrl, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, gitlabGroup, gitlabEndpoints.listProjects), authAPIOptions, otherOptions, { params: {
|
|
37
67
|
...token && { token },
|
|
38
68
|
...instanceUrl && { instanceUrl }
|
|
39
69
|
} });
|
|
@@ -44,8 +74,8 @@ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
44
74
|
* @param branch - Branch name (default: 'main')
|
|
45
75
|
* @param instanceUrl - Custom GitLab instance URL (optional)
|
|
46
76
|
*/
|
|
47
|
-
const checkIntlayerConfig = async (token, projectId, branch = "main", instanceUrl, otherOptions = {}) => await fetcher(
|
|
48
|
-
method:
|
|
77
|
+
const checkIntlayerConfig = async (token, projectId, branch = "main", instanceUrl, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, gitlabGroup, gitlabEndpoints.checkConfig), authAPIOptions, otherOptions, {
|
|
78
|
+
method: gitlabEndpoints.checkConfig.method,
|
|
49
79
|
body: {
|
|
50
80
|
token: token ?? void 0,
|
|
51
81
|
projectId,
|
|
@@ -61,8 +91,8 @@ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
61
91
|
* @param path - File path (default: 'intlayer.config.ts')
|
|
62
92
|
* @param instanceUrl - Custom GitLab instance URL (optional)
|
|
63
93
|
*/
|
|
64
|
-
const getConfigFile = async (token, projectId, branch = "main", path = "intlayer.config.ts", instanceUrl, otherOptions = {}) => await fetcher(
|
|
65
|
-
method:
|
|
94
|
+
const getConfigFile = async (token, projectId, branch = "main", path = "intlayer.config.ts", instanceUrl, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, gitlabGroup, gitlabEndpoints.getConfigFile), authAPIOptions, otherOptions, {
|
|
95
|
+
method: gitlabEndpoints.getConfigFile.method,
|
|
66
96
|
body: {
|
|
67
97
|
token: token ?? void 0,
|
|
68
98
|
projectId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.mjs","names":[],"sources":["../../../src/getIntlayerAPI/gitlab.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type GitLabProject = {\n id: number;\n name: string;\n path_with_namespace: string;\n web_url: string;\n default_branch: string;\n visibility: string;\n last_activity_at: string;\n namespace: {\n id: number;\n name: string;\n path: string;\n };\n};\n\nexport type GitLabAuthCallbackBody = {\n code: string;\n redirectUri: string;\n instanceUrl?: string;\n};\n\nexport type GitLabAuthCallbackResult = {\n data: {\n token: string;\n };\n};\n\nexport type GitLabListProjectsResult = {\n data: GitLabProject[];\n};\n\nexport type GitLabCheckConfigBody = {\n token?: string;\n projectId: number;\n branch?: string;\n instanceUrl?: string;\n};\n\nexport type GitLabCheckConfigResult = {\n data: {\n hasConfig: boolean;\n configPaths: string[];\n };\n};\n\nexport type GitLabGetConfigFileBody = {\n token?: string;\n projectId: number;\n branch?: string;\n path?: string;\n instanceUrl?: string;\n};\n\nexport type GitLabGetConfigFileResult = {\n data: {\n content: string;\n };\n};\n\nexport type GitLabGetAuthUrlResult = {\n data: {\n authUrl: string;\n };\n};\n\nexport const getGitlabAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL
|
|
1
|
+
{"version":3,"file":"gitlab.mjs","names":[],"sources":["../../../src/getIntlayerAPI/gitlab.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n GitLabRoutes,\n gitlabContract,\n} from '@intlayer/backend-contract/gitProviders';\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\nexport type GitLabProject = {\n id: number;\n name: string;\n path_with_namespace: string;\n web_url: string;\n default_branch: string;\n visibility: string;\n last_activity_at: string;\n namespace: {\n id: number;\n name: string;\n path: string;\n };\n};\n\nexport type GitLabAuthCallbackBody = {\n code: string;\n redirectUri: string;\n instanceUrl?: string;\n};\n\nexport type GitLabAuthCallbackResult = {\n data: {\n token: string;\n };\n};\n\nexport type GitLabListProjectsResult = {\n data: GitLabProject[];\n};\n\nexport type GitLabCheckConfigBody = {\n token?: string;\n projectId: number;\n branch?: string;\n instanceUrl?: string;\n};\n\nexport type GitLabCheckConfigResult = {\n data: {\n hasConfig: boolean;\n configPaths: string[];\n };\n};\n\nexport type GitLabGetConfigFileBody = {\n token?: string;\n projectId: number;\n branch?: string;\n path?: string;\n instanceUrl?: string;\n};\n\nexport type GitLabGetConfigFileResult = {\n data: {\n content: string;\n };\n};\n\nexport type GitLabGetAuthUrlResult = {\n data: {\n authUrl: string;\n };\n};\n\n/** Prefix of the routes, checked against the backend contract. */\nconst gitlabGroup = {\n prefix: '/api/gitlab',\n} as const satisfies Pick<typeof gitlabContract, '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 gitlabEndpoints = {\n getAuthUrl: { method: 'GET', path: '/auth-url' },\n authCallback: { method: 'POST', path: '/auth' },\n listProjects: { method: 'GET', path: '/projects' },\n checkConfig: { method: 'POST', path: '/check-config' },\n getConfigFile: { method: 'POST', path: '/get-config-file' },\n} as const satisfies RouteEndpoints<GitLabRoutes>;\n\nexport const getGitlabAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /**\n * Get GitLab OAuth authorization URL\n * @param redirectUri - Redirect URI after OAuth authorization\n * @param instanceUrl - Custom GitLab instance URL (optional, for self-hosted)\n */\n const getAuthUrl = async (\n redirectUri: string,\n instanceUrl?: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitLabGetAuthUrlResult>(\n buildRouteURL(backendURL, gitlabGroup, gitlabEndpoints.getAuthUrl),\n authAPIOptions,\n otherOptions,\n {\n params: { redirectUri, ...(instanceUrl && { instanceUrl }) },\n }\n );\n\n /**\n * Exchange GitLab authorization code for access token\n * @param code - GitLab authorization code\n * @param redirectUri - Redirect URI used in the authorization request\n * @param instanceUrl - Custom GitLab instance URL (optional)\n */\n const authenticate = async (\n code: string,\n redirectUri: string,\n instanceUrl?: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitLabAuthCallbackResult>(\n buildRouteURL(backendURL, gitlabGroup, gitlabEndpoints.authCallback),\n authAPIOptions,\n otherOptions,\n {\n method: gitlabEndpoints.authCallback.method,\n body: { code, redirectUri, instanceUrl },\n }\n );\n\n /**\n * Get user's GitLab projects\n * @param token - Optional GitLab access token. If not provided, backend will use session.\n * @param instanceUrl - Custom GitLab instance URL (optional)\n */\n const getProjects = async (\n token?: string | null,\n instanceUrl?: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitLabListProjectsResult>(\n buildRouteURL(backendURL, gitlabGroup, gitlabEndpoints.listProjects),\n authAPIOptions,\n otherOptions,\n {\n params: {\n ...(token && { token }),\n ...(instanceUrl && { instanceUrl }),\n },\n }\n );\n\n /**\n * Check if intlayer.config.ts exists in a GitLab repository\n * @param token - Optional GitLab access token. If not provided, backend will use session.\n * @param projectId - GitLab project ID\n * @param branch - Branch name (default: 'main')\n * @param instanceUrl - Custom GitLab instance URL (optional)\n */\n const checkIntlayerConfig = async (\n token: string | null | undefined,\n projectId: number,\n branch: string = 'main',\n instanceUrl?: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitLabCheckConfigResult>(\n buildRouteURL(backendURL, gitlabGroup, gitlabEndpoints.checkConfig),\n authAPIOptions,\n otherOptions,\n {\n method: gitlabEndpoints.checkConfig.method,\n body: {\n token: token ?? undefined,\n projectId,\n branch,\n ...(instanceUrl && { instanceUrl }),\n },\n }\n );\n\n /**\n * Get intlayer.config.ts file contents from a GitLab repository\n * @param token - Optional GitLab access token. If not provided, backend will use session.\n * @param projectId - GitLab project ID\n * @param branch - Branch name (default: 'main')\n * @param path - File path (default: 'intlayer.config.ts')\n * @param instanceUrl - Custom GitLab instance URL (optional)\n */\n const getConfigFile = async (\n token: string | null | undefined,\n projectId: number,\n branch: string = 'main',\n path: string = 'intlayer.config.ts',\n instanceUrl?: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitLabGetConfigFileResult>(\n buildRouteURL(backendURL, gitlabGroup, gitlabEndpoints.getConfigFile),\n authAPIOptions,\n otherOptions,\n {\n method: gitlabEndpoints.getConfigFile.method,\n body: {\n token: token ?? undefined,\n projectId,\n branch,\n path,\n ...(instanceUrl && { instanceUrl }),\n },\n }\n );\n\n return {\n getAuthUrl,\n authenticate,\n getProjects,\n checkIntlayerConfig,\n getConfigFile,\n };\n};\n\n/**\n * Authenticated `gitlab` 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 gitlabEndpoint = createEndpoint(getGitlabAPI);\n"],"mappings":";;;;;;;;AA8EA,MAAM,cAAc,EAClB,QAAQ,cACV;;;;;AAMA,MAAM,kBAAkB;CACtB,YAAY;EAAE,QAAQ;EAAO,MAAM;CAAY;CAC/C,cAAc;EAAE,QAAQ;EAAQ,MAAM;CAAQ;CAC9C,cAAc;EAAE,QAAQ;EAAO,MAAM;CAAY;CACjD,aAAa;EAAE,QAAQ;EAAQ,MAAM;CAAgB;CACrD,eAAe;EAAE,QAAQ;EAAQ,MAAM;CAAmB;AAC5D;AAEA,MAAa,gBACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,OAAO,cAAc;;;;;;CAO7D,MAAM,aAAa,OACjB,aACA,aACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,UAAU,GACjE,gBACA,cACA,EACE,QAAQ;EAAE;EAAa,GAAI,eAAe,EAAE,YAAY;CAAG,EAC7D,CACF;;;;;;;CAQF,MAAM,eAAe,OACnB,MACA,aACA,aACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,YAAY,GACnE,gBACA,cACA;EACE,QAAQ,gBAAgB,aAAa;EACrC,MAAM;GAAE;GAAM;GAAa;EAAY;CACzC,CACF;;;;;;CAOF,MAAM,cAAc,OAClB,OACA,aACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,YAAY,GACnE,gBACA,cACA,EACE,QAAQ;EACN,GAAI,SAAS,EAAE,MAAM;EACrB,GAAI,eAAe,EAAE,YAAY;CACnC,EACF,CACF;;;;;;;;CASF,MAAM,sBAAsB,OAC1B,OACA,WACA,SAAiB,QACjB,aACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,WAAW,GAClE,gBACA,cACA;EACE,QAAQ,gBAAgB,YAAY;EACpC,MAAM;GACJ,OAAO,SAAS;GAChB;GACA;GACA,GAAI,eAAe,EAAE,YAAY;EACnC;CACF,CACF;;;;;;;;;CAUF,MAAM,gBAAgB,OACpB,OACA,WACA,SAAiB,QACjB,OAAe,sBACf,aACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,aAAa,gBAAgB,aAAa,GACpE,gBACA,cACA;EACE,QAAQ,gBAAgB,cAAc;EACtC,MAAM;GACJ,OAAO,SAAS;GAChB;GACA;GACA;GACA,GAAI,eAAe,EAAE,YAAY;EACnC;CACF,CACF;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,iBAAiB,eAAe,YAAY"}
|
|
@@ -4,9 +4,11 @@ import { getAnalyticsAPI } from "./analytics.mjs";
|
|
|
4
4
|
import { getAssetAPI } from "./asset.mjs";
|
|
5
5
|
import { getAuditAPI } from "./audit.mjs";
|
|
6
6
|
import { getBitbucketAPI } from "./bitbucket.mjs";
|
|
7
|
+
import { getCodebergAPI } from "./codeberg.mjs";
|
|
7
8
|
import { getDictionaryAPI } from "./dictionary.mjs";
|
|
8
9
|
import { getEditorAPI } from "./editor.mjs";
|
|
9
10
|
import { getEnvironmentAPI } from "./environment.mjs";
|
|
11
|
+
import { getGiteeAPI } from "./gitee.mjs";
|
|
10
12
|
import { getGithubAPI } from "./github.mjs";
|
|
11
13
|
import { getGitlabAPI } from "./gitlab.mjs";
|
|
12
14
|
import { getNewsletterAPI } from "./newsletter.mjs";
|
|
@@ -45,6 +47,8 @@ const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
45
47
|
github: getGithubAPI(authAPIOptions, resolvedConfig),
|
|
46
48
|
gitlab: getGitlabAPI(authAPIOptions, resolvedConfig),
|
|
47
49
|
bitbucket: getBitbucketAPI(authAPIOptions, resolvedConfig),
|
|
50
|
+
codeberg: getCodebergAPI(authAPIOptions, resolvedConfig),
|
|
51
|
+
gitee: getGiteeAPI(authAPIOptions, resolvedConfig),
|
|
48
52
|
showcaseProject: getShowcaseProjectAPI(authAPIOptions, resolvedConfig),
|
|
49
53
|
translate: getTranslateAPI(authAPIOptions, resolvedConfig),
|
|
50
54
|
reviewer: getReviewerAPI(authAPIOptions, resolvedConfig),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getAnalyticsAPI } from './analytics';\nimport { getAssetAPI } from './asset';\nimport { getAuditAPI } from './audit';\nimport { getBitbucketAPI } from './bitbucket';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getEnvironmentAPI } from './environment';\nimport { getGithubAPI } from './github';\nimport { getGitlabAPI } from './gitlab';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getReviewerAPI } from './reviewer';\nimport { getSearchAPI } from './search';\nimport { getShowcaseProjectAPI } from './showcaseProject';\nimport { getStatusAPI } from './status';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getTranslateAPI } from './translate';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n asset: ReturnType<typeof getAssetAPI>;\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n environment: ReturnType<typeof getEnvironmentAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n analytics: ReturnType<typeof getAnalyticsAPI>;\n audit: ReturnType<typeof getAuditAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n github: ReturnType<typeof getGithubAPI>;\n gitlab: ReturnType<typeof getGitlabAPI>;\n bitbucket: ReturnType<typeof getBitbucketAPI>;\n showcaseProject: ReturnType<typeof getShowcaseProjectAPI>;\n translate: ReturnType<typeof getTranslateAPI>;\n reviewer: ReturnType<typeof getReviewerAPI>;\n status: ReturnType<typeof getStatusAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: Pick<IntlayerConfig, 'editor'>\n): IntlayerAPIReturn => {\n const resolvedConfig = defu(intlayerConfig ?? {}, {\n editor,\n }) as IntlayerConfig;\n\n return {\n asset: getAssetAPI(authAPIOptions, resolvedConfig),\n organization: getOrganizationAPI(authAPIOptions, resolvedConfig),\n project: getProjectAPI(authAPIOptions, resolvedConfig),\n environment: getEnvironmentAPI(authAPIOptions, resolvedConfig),\n user: getUserAPI(authAPIOptions, resolvedConfig),\n oAuth: getOAuthAPI(authAPIOptions, resolvedConfig),\n dictionary: getDictionaryAPI(authAPIOptions, resolvedConfig),\n stripe: getStripeAPI(authAPIOptions, resolvedConfig),\n ai: getAiAPI(authAPIOptions, resolvedConfig),\n analytics: getAnalyticsAPI(authAPIOptions, resolvedConfig),\n audit: getAuditAPI(authAPIOptions, resolvedConfig),\n tag: getTagAPI(authAPIOptions, resolvedConfig),\n search: getSearchAPI(authAPIOptions, resolvedConfig),\n editor: getEditorAPI(authAPIOptions, resolvedConfig),\n newsletter: getNewsletterAPI(authAPIOptions, resolvedConfig),\n github: getGithubAPI(authAPIOptions, resolvedConfig),\n gitlab: getGitlabAPI(authAPIOptions, resolvedConfig),\n bitbucket: getBitbucketAPI(authAPIOptions, resolvedConfig),\n showcaseProject: getShowcaseProjectAPI(authAPIOptions, resolvedConfig),\n translate: getTranslateAPI(authAPIOptions, resolvedConfig),\n reviewer: getReviewerAPI(authAPIOptions, resolvedConfig),\n status: getStatusAPI(authAPIOptions, resolvedConfig),\n };\n};\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getAnalyticsAPI } from './analytics';\nimport { getAssetAPI } from './asset';\nimport { getAuditAPI } from './audit';\nimport { getBitbucketAPI } from './bitbucket';\nimport { getCodebergAPI } from './codeberg';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getEnvironmentAPI } from './environment';\nimport { getGiteeAPI } from './gitee';\nimport { getGithubAPI } from './github';\nimport { getGitlabAPI } from './gitlab';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getReviewerAPI } from './reviewer';\nimport { getSearchAPI } from './search';\nimport { getShowcaseProjectAPI } from './showcaseProject';\nimport { getStatusAPI } from './status';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getTranslateAPI } from './translate';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n asset: ReturnType<typeof getAssetAPI>;\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n environment: ReturnType<typeof getEnvironmentAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n analytics: ReturnType<typeof getAnalyticsAPI>;\n audit: ReturnType<typeof getAuditAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n github: ReturnType<typeof getGithubAPI>;\n gitlab: ReturnType<typeof getGitlabAPI>;\n bitbucket: ReturnType<typeof getBitbucketAPI>;\n codeberg: ReturnType<typeof getCodebergAPI>;\n gitee: ReturnType<typeof getGiteeAPI>;\n showcaseProject: ReturnType<typeof getShowcaseProjectAPI>;\n translate: ReturnType<typeof getTranslateAPI>;\n reviewer: ReturnType<typeof getReviewerAPI>;\n status: ReturnType<typeof getStatusAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: Pick<IntlayerConfig, 'editor'>\n): IntlayerAPIReturn => {\n const resolvedConfig = defu(intlayerConfig ?? {}, {\n editor,\n }) as IntlayerConfig;\n\n return {\n asset: getAssetAPI(authAPIOptions, resolvedConfig),\n organization: getOrganizationAPI(authAPIOptions, resolvedConfig),\n project: getProjectAPI(authAPIOptions, resolvedConfig),\n environment: getEnvironmentAPI(authAPIOptions, resolvedConfig),\n user: getUserAPI(authAPIOptions, resolvedConfig),\n oAuth: getOAuthAPI(authAPIOptions, resolvedConfig),\n dictionary: getDictionaryAPI(authAPIOptions, resolvedConfig),\n stripe: getStripeAPI(authAPIOptions, resolvedConfig),\n ai: getAiAPI(authAPIOptions, resolvedConfig),\n analytics: getAnalyticsAPI(authAPIOptions, resolvedConfig),\n audit: getAuditAPI(authAPIOptions, resolvedConfig),\n tag: getTagAPI(authAPIOptions, resolvedConfig),\n search: getSearchAPI(authAPIOptions, resolvedConfig),\n editor: getEditorAPI(authAPIOptions, resolvedConfig),\n newsletter: getNewsletterAPI(authAPIOptions, resolvedConfig),\n github: getGithubAPI(authAPIOptions, resolvedConfig),\n gitlab: getGitlabAPI(authAPIOptions, resolvedConfig),\n bitbucket: getBitbucketAPI(authAPIOptions, resolvedConfig),\n codeberg: getCodebergAPI(authAPIOptions, resolvedConfig),\n gitee: getGiteeAPI(authAPIOptions, resolvedConfig),\n showcaseProject: getShowcaseProjectAPI(authAPIOptions, resolvedConfig),\n translate: getTranslateAPI(authAPIOptions, resolvedConfig),\n reviewer: getReviewerAPI(authAPIOptions, resolvedConfig),\n status: getStatusAPI(authAPIOptions, resolvedConfig),\n };\n};\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAa,kBACX,iBAAiC,CAAC,GAClC,mBACsB;CACtB,MAAM,iBAAiB,KAAK,kBAAkB,CAAC,GAAG,EAChD,OACF,CAAC;CAED,OAAO;EACL,OAAO,YAAY,gBAAgB,cAAc;EACjD,cAAc,mBAAmB,gBAAgB,cAAc;EAC/D,SAAS,cAAc,gBAAgB,cAAc;EACrD,aAAa,kBAAkB,gBAAgB,cAAc;EAC7D,MAAM,WAAW,gBAAgB,cAAc;EAC/C,OAAO,YAAY,gBAAgB,cAAc;EACjD,YAAY,iBAAiB,gBAAgB,cAAc;EAC3D,QAAQ,aAAa,gBAAgB,cAAc;EACnD,IAAI,SAAS,gBAAgB,cAAc;EAC3C,WAAW,gBAAgB,gBAAgB,cAAc;EACzD,OAAO,YAAY,gBAAgB,cAAc;EACjD,KAAK,UAAU,gBAAgB,cAAc;EAC7C,QAAQ,aAAa,gBAAgB,cAAc;EACnD,QAAQ,aAAa,gBAAgB,cAAc;EACnD,YAAY,iBAAiB,gBAAgB,cAAc;EAC3D,QAAQ,aAAa,gBAAgB,cAAc;EACnD,QAAQ,aAAa,gBAAgB,cAAc;EACnD,WAAW,gBAAgB,gBAAgB,cAAc;EACzD,UAAU,eAAe,gBAAgB,cAAc;EACvD,OAAO,YAAY,gBAAgB,cAAc;EACjD,iBAAiB,sBAAsB,gBAAgB,cAAc;EACrE,WAAW,gBAAgB,gBAAgB,cAAc;EACzD,UAAU,eAAe,gBAAgB,cAAc;EACvD,QAAQ,aAAa,gBAAgB,cAAc;CACrD;AACF"}
|
|
@@ -1,17 +1,39 @@
|
|
|
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/newsletter.ts
|
|
8
|
+
/** Prefix of the routes, checked against the backend contract. */
|
|
9
|
+
const newsletterGroup = { prefix: "/api/newsletter" };
|
|
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 newsletterEndpoints = {
|
|
15
|
+
subscribeToNewsletter: {
|
|
16
|
+
method: "POST",
|
|
17
|
+
path: "/subscribe"
|
|
18
|
+
},
|
|
19
|
+
unsubscribeFromNewsletter: {
|
|
20
|
+
method: "POST",
|
|
21
|
+
path: "/unsubscribe"
|
|
22
|
+
},
|
|
23
|
+
getNewsletterStatus: {
|
|
24
|
+
method: "GET",
|
|
25
|
+
path: "/status"
|
|
26
|
+
}
|
|
27
|
+
};
|
|
6
28
|
const getNewsletterAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
7
|
-
const
|
|
29
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;
|
|
8
30
|
/**
|
|
9
31
|
* Subscribe a user to newsletter(s)
|
|
10
32
|
* @param body - Newsletter subscription parameters.
|
|
11
33
|
* @returns Newsletter subscription result.
|
|
12
34
|
*/
|
|
13
|
-
const subscribeToNewsletter = async (body, otherOptions = {}) => await fetcher(
|
|
14
|
-
method:
|
|
35
|
+
const subscribeToNewsletter = async (body, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, newsletterGroup, newsletterEndpoints.subscribeToNewsletter), authAPIOptions, otherOptions, {
|
|
36
|
+
method: newsletterEndpoints.subscribeToNewsletter.method,
|
|
15
37
|
body
|
|
16
38
|
});
|
|
17
39
|
/**
|
|
@@ -19,15 +41,15 @@ const getNewsletterAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
19
41
|
* @param body - Newsletter unsubscription parameters.
|
|
20
42
|
* @returns Newsletter unsubscription result.
|
|
21
43
|
*/
|
|
22
|
-
const unsubscribeFromNewsletter = async (body, otherOptions = {}) => await fetcher(
|
|
23
|
-
method:
|
|
44
|
+
const unsubscribeFromNewsletter = async (body, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, newsletterGroup, newsletterEndpoints.unsubscribeFromNewsletter), authAPIOptions, otherOptions, {
|
|
45
|
+
method: newsletterEndpoints.unsubscribeFromNewsletter.method,
|
|
24
46
|
body
|
|
25
47
|
});
|
|
26
48
|
/**
|
|
27
49
|
* Get newsletter subscription status for the authenticated user
|
|
28
50
|
* @returns Newsletter subscription status.
|
|
29
51
|
*/
|
|
30
|
-
const getNewsletterStatus = async (otherOptions = {}) => await fetcher(
|
|
52
|
+
const getNewsletterStatus = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, newsletterGroup, newsletterEndpoints.getNewsletterStatus), authAPIOptions, otherOptions, { method: newsletterEndpoints.getNewsletterStatus.method });
|
|
31
53
|
return {
|
|
32
54
|
subscribeToNewsletter,
|
|
33
55
|
unsubscribeFromNewsletter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"newsletter.mjs","names":[],"sources":["../../../src/getIntlayerAPI/newsletter.ts"],"sourcesContent":["import type {\n NewsletterSubscriptionBody,\n NewsletterSubscriptionResult,\n NewsletterUnsubscriptionBody,\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 getNewsletterAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL
|
|
1
|
+
{"version":3,"file":"newsletter.mjs","names":[],"sources":["../../../src/getIntlayerAPI/newsletter.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n NewsletterRoutes,\n NewsletterSubscriptionBody,\n NewsletterSubscriptionResult,\n NewsletterUnsubscriptionBody,\n newsletterContract,\n} from '@intlayer/backend-contract/newsletter';\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 newsletterGroup = {\n prefix: '/api/newsletter',\n} as const satisfies Pick<typeof newsletterContract, '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 newsletterEndpoints = {\n subscribeToNewsletter: { method: 'POST', path: '/subscribe' },\n unsubscribeFromNewsletter: { method: 'POST', path: '/unsubscribe' },\n getNewsletterStatus: { method: 'GET', path: '/status' },\n} as const satisfies RouteEndpoints<NewsletterRoutes>;\n\nexport const getNewsletterAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /**\n * Subscribe a user to newsletter(s)\n * @param body - Newsletter subscription parameters.\n * @returns Newsletter subscription result.\n */\n const subscribeToNewsletter = async (\n body: NewsletterSubscriptionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<NewsletterSubscriptionResult>(\n buildRouteURL(\n backendURL,\n newsletterGroup,\n newsletterEndpoints.subscribeToNewsletter\n ),\n authAPIOptions,\n otherOptions,\n {\n method: newsletterEndpoints.subscribeToNewsletter.method,\n body: body,\n }\n );\n\n /**\n * Unsubscribe a user from newsletter(s)\n * @param body - Newsletter unsubscription parameters.\n * @returns Newsletter unsubscription result.\n */\n const unsubscribeFromNewsletter = async (\n body: NewsletterUnsubscriptionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<NewsletterSubscriptionResult>(\n buildRouteURL(\n backendURL,\n newsletterGroup,\n newsletterEndpoints.unsubscribeFromNewsletter\n ),\n authAPIOptions,\n otherOptions,\n {\n method: newsletterEndpoints.unsubscribeFromNewsletter.method,\n body: body,\n }\n );\n\n /**\n * Get newsletter subscription status for the authenticated user\n * @returns Newsletter subscription status.\n */\n const getNewsletterStatus = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<NewsletterSubscriptionResult>(\n buildRouteURL(\n backendURL,\n newsletterGroup,\n newsletterEndpoints.getNewsletterStatus\n ),\n authAPIOptions,\n otherOptions,\n {\n method: newsletterEndpoints.getNewsletterStatus.method,\n }\n );\n\n return {\n subscribeToNewsletter,\n unsubscribeFromNewsletter,\n getNewsletterStatus,\n };\n};\n\n/**\n * Authenticated `newsletter` 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 newsletterEndpoint = createEndpoint(getNewsletterAPI);\n"],"mappings":";;;;;;;;AAgBA,MAAM,kBAAkB,EACtB,QAAQ,kBACV;;;;;AAMA,MAAM,sBAAsB;CAC1B,uBAAuB;EAAE,QAAQ;EAAQ,MAAM;CAAa;CAC5D,2BAA2B;EAAE,QAAQ;EAAQ,MAAM;CAAe;CAClE,qBAAqB;EAAE,QAAQ;EAAO,MAAM;CAAU;AACxD;AAEA,MAAa,oBACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,OAAO,cAAc;;;;;;CAO7D,MAAM,wBAAwB,OAC5B,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cACE,YACA,iBACA,oBAAoB,qBACtB,GACA,gBACA,cACA;EACE,QAAQ,oBAAoB,sBAAsB;EAC5C;CACR,CACF;;;;;;CAOF,MAAM,4BAA4B,OAChC,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cACE,YACA,iBACA,oBAAoB,yBACtB,GACA,gBACA,cACA;EACE,QAAQ,oBAAoB,0BAA0B;EAChD;CACR,CACF;;;;;CAMF,MAAM,sBAAsB,OAAO,eAA+B,CAAC,MACjE,MAAM,QACJ,cACE,YACA,iBACA,oBAAoB,mBACtB,GACA,gBACA,cACA,EACE,QAAQ,oBAAoB,oBAAoB,OAClD,CACF;CAEF,OAAO;EACL;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,qBAAqB,eAAe,gBAAgB"}
|
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
2
|
import { editor } from "@intlayer/config/built";
|
|
3
|
+
import { buildRouteURL } from "@intlayer/backend-contract/defineRoute";
|
|
4
|
+
import { BACKEND_URL } from "@intlayer/config/defaultValues";
|
|
3
5
|
|
|
4
6
|
//#region src/getIntlayerAPI/oAuth.ts
|
|
7
|
+
/** OAuth2 routes, checked against the backend contract. */
|
|
8
|
+
const oAuth2Group = { prefix: "/oauth2" };
|
|
9
|
+
const oAuth2Endpoints = {
|
|
10
|
+
getOAuth2AccessToken: {
|
|
11
|
+
method: "POST",
|
|
12
|
+
path: "/token"
|
|
13
|
+
},
|
|
14
|
+
extendOAuth2Token: {
|
|
15
|
+
method: "POST",
|
|
16
|
+
path: "/token/extend"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/** CLI session routes, checked against the backend contract. */
|
|
20
|
+
const cliSessionGroup = { prefix: "/api/cli-session" };
|
|
21
|
+
const cliSessionEndpoints = {
|
|
22
|
+
createCliSessionToken: {
|
|
23
|
+
method: "POST",
|
|
24
|
+
path: "/"
|
|
25
|
+
},
|
|
26
|
+
getCliSessionMe: {
|
|
27
|
+
method: "GET",
|
|
28
|
+
path: "/me"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
5
31
|
const getOAuthAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
6
|
-
const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;
|
|
32
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;
|
|
7
33
|
const { clientId, clientSecret } = intlayerConfig?.editor ?? {};
|
|
8
34
|
/**
|
|
9
35
|
* Gets an oAuth2 accessToken via client_credentials grant
|
|
10
36
|
*/
|
|
11
|
-
const getOAuth2AccessToken = async (otherOptions = {}) => await fetcher(
|
|
12
|
-
method:
|
|
37
|
+
const getOAuth2AccessToken = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, oAuth2Group, oAuth2Endpoints.getOAuth2AccessToken), {}, otherOptions, {
|
|
38
|
+
method: oAuth2Endpoints.getOAuth2AccessToken.method,
|
|
13
39
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
14
40
|
body: {
|
|
15
41
|
grant_type: "client_credentials",
|
|
@@ -21,12 +47,12 @@ const getOAuthAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
21
47
|
* Creates a short-lived (2h) CLI session token for the authenticated user.
|
|
22
48
|
* Requires a valid browser session cookie.
|
|
23
49
|
*/
|
|
24
|
-
const createCliSessionToken = async (otherOptions = {}) => await fetcher(
|
|
50
|
+
const createCliSessionToken = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, cliSessionGroup, cliSessionEndpoints.createCliSessionToken), authAPIOptions, otherOptions, { method: cliSessionEndpoints.createCliSessionToken.method });
|
|
25
51
|
/**
|
|
26
52
|
* Verifies a CLI session token and returns the associated project context.
|
|
27
53
|
* Useful for checking config consistency in the CLI.
|
|
28
54
|
*/
|
|
29
|
-
const getCliSessionMe = async (otherOptions = {}) => await fetcher(
|
|
55
|
+
const getCliSessionMe = async (otherOptions = {}) => await fetcher(buildRouteURL(backendURL, cliSessionGroup, cliSessionEndpoints.getCliSessionMe), authAPIOptions, otherOptions, { method: cliSessionEndpoints.getCliSessionMe.method });
|
|
30
56
|
return {
|
|
31
57
|
getOAuth2AccessToken,
|
|
32
58
|
createCliSessionToken,
|