@intlayer/api 9.6.0 → 9.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cms/createAuthManager.cjs +2 -3
- package/dist/cjs/cms/createIntlayerCMS.cjs +2 -3
- package/dist/cjs/cms/index.cjs +2 -2
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +3 -4
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +3 -4
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
- package/dist/cjs/distantDictionary/index.cjs +2 -2
- package/dist/cjs/fetcher.cjs +2 -3
- package/dist/cjs/fetcher.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/ai.cjs +79 -26
- package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/analytics.cjs +47 -14
- package/dist/cjs/getIntlayerAPI/analytics.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/asset.cjs +41 -12
- package/dist/cjs/getIntlayerAPI/asset.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/audit.cjs +73 -20
- package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/bitbucket.cjs +42 -13
- package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/codeberg.cjs +20 -0
- package/dist/cjs/getIntlayerAPI/codeberg.cjs.map +1 -0
- package/dist/cjs/getIntlayerAPI/dictionary.cjs +62 -17
- package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/editor.cjs +3 -4
- package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/environment.cjs +47 -14
- package/dist/cjs/getIntlayerAPI/environment.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/forge.cjs +63 -0
- package/dist/cjs/getIntlayerAPI/forge.cjs.map +1 -0
- package/dist/cjs/getIntlayerAPI/gitee.cjs +20 -0
- package/dist/cjs/getIntlayerAPI/gitee.cjs.map +1 -0
- package/dist/cjs/getIntlayerAPI/github.cjs +47 -14
- package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/gitlab.cjs +42 -13
- package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/index.cjs +27 -24
- package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/newsletter.cjs +31 -10
- package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/oAuth.cjs +33 -8
- package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/organization.cjs +75 -24
- package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/project.cjs +115 -33
- package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/reviewer.cjs +145 -35
- package/dist/cjs/getIntlayerAPI/reviewer.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/search.cjs +18 -7
- package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/showcaseProject.cjs +64 -19
- package/dist/cjs/getIntlayerAPI/showcaseProject.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/status.cjs +19 -7
- package/dist/cjs/getIntlayerAPI/status.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/stripe.cjs +144 -39
- package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/tag.cjs +36 -11
- package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/translate.cjs +49 -12
- package/dist/cjs/getIntlayerAPI/translate.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/user.cjs +61 -18
- package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
- package/dist/cjs/index.cjs +38 -30
- package/dist/cjs/proxy.cjs +28 -25
- package/dist/cjs/proxy.cjs.map +1 -1
- package/dist/cjs/public/createPublicClient.cjs +26 -7
- package/dist/cjs/public/createPublicClient.cjs.map +1 -1
- package/dist/cjs/public/index.cjs +1 -1
- package/dist/cjs/resolveInternalBackendUrl.cjs +1 -2
- package/dist/esm/cms/createAuthManager.mjs +1 -2
- package/dist/esm/cms/createIntlayerCMS.mjs +1 -2
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +1 -2
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +1 -2
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
- package/dist/esm/fetcher.mjs +1 -2
- package/dist/esm/fetcher.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/ai.mjs +78 -25
- package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/analytics.mjs +46 -13
- package/dist/esm/getIntlayerAPI/analytics.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/asset.mjs +40 -11
- package/dist/esm/getIntlayerAPI/asset.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/audit.mjs +72 -19
- package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/bitbucket.mjs +41 -12
- package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/codeberg.mjs +18 -0
- package/dist/esm/getIntlayerAPI/codeberg.mjs.map +1 -0
- package/dist/esm/getIntlayerAPI/dictionary.mjs +61 -16
- package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/editor.mjs +2 -3
- package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/environment.mjs +46 -13
- package/dist/esm/getIntlayerAPI/environment.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/forge.mjs +62 -0
- package/dist/esm/getIntlayerAPI/forge.mjs.map +1 -0
- package/dist/esm/getIntlayerAPI/gitee.mjs +18 -0
- package/dist/esm/getIntlayerAPI/gitee.mjs.map +1 -0
- package/dist/esm/getIntlayerAPI/github.mjs +46 -13
- package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/gitlab.mjs +41 -12
- package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/index.mjs +6 -3
- package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/newsletter.mjs +30 -9
- package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/oAuth.mjs +32 -7
- package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/organization.mjs +74 -23
- package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/project.mjs +114 -32
- package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/reviewer.mjs +144 -34
- package/dist/esm/getIntlayerAPI/reviewer.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/search.mjs +17 -6
- package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/showcaseProject.mjs +63 -18
- package/dist/esm/getIntlayerAPI/showcaseProject.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/status.mjs +18 -6
- package/dist/esm/getIntlayerAPI/status.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/stripe.mjs +143 -38
- package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/tag.mjs +35 -10
- package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/translate.mjs +48 -11
- package/dist/esm/getIntlayerAPI/translate.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/user.mjs +60 -17
- package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
- package/dist/esm/index.mjs +10 -7
- package/dist/esm/proxy.mjs +6 -3
- package/dist/esm/proxy.mjs.map +1 -1
- package/dist/esm/public/createPublicClient.mjs +26 -7
- package/dist/esm/public/createPublicClient.mjs.map +1 -1
- package/dist/esm/resolveInternalBackendUrl.mjs +1 -2
- package/dist/types/cms/createAuthManager.d.ts +1 -2
- package/dist/types/cms/createAuthManager.d.ts.map +1 -1
- package/dist/types/cms/createIntlayerCMS.d.ts +0 -2
- package/dist/types/cms/createIntlayerCMS.d.ts.map +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +1 -3
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +1 -3
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
- package/dist/types/fetcher.d.ts +1 -3
- package/dist/types/fetcher.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/ai.d.ts +3 -5
- package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/analytics.d.ts +3 -5
- package/dist/types/getIntlayerAPI/analytics.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/asset.d.ts +3 -4
- package/dist/types/getIntlayerAPI/asset.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/audit.d.ts +49 -7
- package/dist/types/getIntlayerAPI/audit.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/bitbucket.d.ts +2 -4
- package/dist/types/getIntlayerAPI/bitbucket.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/codeberg.d.ts +59 -0
- package/dist/types/getIntlayerAPI/codeberg.d.ts.map +1 -0
- package/dist/types/getIntlayerAPI/dictionary.d.ts +3 -5
- package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/editor.d.ts +4 -5
- package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/environment.d.ts +3 -5
- package/dist/types/getIntlayerAPI/environment.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/forge.d.ts +34 -0
- package/dist/types/getIntlayerAPI/forge.d.ts.map +1 -0
- package/dist/types/getIntlayerAPI/gitee.d.ts +59 -0
- package/dist/types/getIntlayerAPI/gitee.d.ts.map +1 -0
- package/dist/types/getIntlayerAPI/github.d.ts +2 -4
- package/dist/types/getIntlayerAPI/github.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/gitlab.d.ts +2 -4
- package/dist/types/getIntlayerAPI/gitlab.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/index.d.ts +6 -3
- package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/newsletter.d.ts +3 -5
- package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/oAuth.d.ts +2 -2
- package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/organization.d.ts +3 -7
- package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/project.d.ts +4 -5
- package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/reviewer.d.ts +682 -39
- package/dist/types/getIntlayerAPI/reviewer.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/search.d.ts +3 -5
- package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/showcaseProject.d.ts +3 -5
- package/dist/types/getIntlayerAPI/showcaseProject.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/status.d.ts +5 -8
- package/dist/types/getIntlayerAPI/status.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/stripe.d.ts +3 -5
- package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/tag.d.ts +3 -5
- package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/translate.d.ts +3 -5
- package/dist/types/getIntlayerAPI/translate.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/user.d.ts +6 -8
- package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
- package/dist/types/index.d.ts +12 -9
- package/dist/types/proxy.d.ts +0 -2
- package/dist/types/proxy.d.ts.map +1 -1
- package/dist/types/public/createPublicClient.d.ts +1 -9
- package/dist/types/public/createPublicClient.d.ts.map +1 -1
- package/dist/types/resolveInternalBackendUrl.d.ts +0 -2
- package/dist/types/resolveInternalBackendUrl.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -2
- package/package.json +23 -6
|
@@ -1,17 +1,47 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const require_cms_createIntlayerCMS = require("../cms/createIntlayerCMS.cjs");
|
|
3
|
+
const require_fetcher = require("../fetcher.cjs");
|
|
4
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
|
+
let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
|
|
6
|
+
let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
// src/getIntlayerAPI/gitlab.ts
|
|
9
|
+
/** Prefix of the routes, checked against the backend contract. */
|
|
10
|
+
const gitlabGroup = { prefix: "/api/gitlab" };
|
|
11
|
+
/**
|
|
12
|
+
* Method and path of every route, checked against the backend contract at
|
|
13
|
+
* compile time (the contract's zod schemas are never loaded).
|
|
14
|
+
*/
|
|
15
|
+
const gitlabEndpoints = {
|
|
16
|
+
getAuthUrl: {
|
|
17
|
+
method: "GET",
|
|
18
|
+
path: "/auth-url"
|
|
19
|
+
},
|
|
20
|
+
authCallback: {
|
|
21
|
+
method: "POST",
|
|
22
|
+
path: "/auth"
|
|
23
|
+
},
|
|
24
|
+
listProjects: {
|
|
25
|
+
method: "GET",
|
|
26
|
+
path: "/projects"
|
|
27
|
+
},
|
|
28
|
+
checkConfig: {
|
|
29
|
+
method: "POST",
|
|
30
|
+
path: "/check-config"
|
|
31
|
+
},
|
|
32
|
+
getConfigFile: {
|
|
33
|
+
method: "POST",
|
|
34
|
+
path: "/get-config-file"
|
|
35
|
+
}
|
|
36
|
+
};
|
|
7
37
|
const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
8
|
-
const
|
|
38
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
|
|
9
39
|
/**
|
|
10
40
|
* Get GitLab OAuth authorization URL
|
|
11
41
|
* @param redirectUri - Redirect URI after OAuth authorization
|
|
12
42
|
* @param instanceUrl - Custom GitLab instance URL (optional, for self-hosted)
|
|
13
43
|
*/
|
|
14
|
-
const getAuthUrl = async (redirectUri, instanceUrl, otherOptions = {}) => await require_fetcher.fetcher(
|
|
44
|
+
const getAuthUrl = async (redirectUri, instanceUrl, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, gitlabGroup, gitlabEndpoints.getAuthUrl), authAPIOptions, otherOptions, { params: {
|
|
15
45
|
redirectUri,
|
|
16
46
|
...instanceUrl && { instanceUrl }
|
|
17
47
|
} });
|
|
@@ -21,8 +51,8 @@ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
21
51
|
* @param redirectUri - Redirect URI used in the authorization request
|
|
22
52
|
* @param instanceUrl - Custom GitLab instance URL (optional)
|
|
23
53
|
*/
|
|
24
|
-
const authenticate = async (code, redirectUri, instanceUrl, otherOptions = {}) => await require_fetcher.fetcher(
|
|
25
|
-
method:
|
|
54
|
+
const authenticate = async (code, redirectUri, instanceUrl, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, gitlabGroup, gitlabEndpoints.authCallback), authAPIOptions, otherOptions, {
|
|
55
|
+
method: gitlabEndpoints.authCallback.method,
|
|
26
56
|
body: {
|
|
27
57
|
code,
|
|
28
58
|
redirectUri,
|
|
@@ -34,7 +64,7 @@ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
34
64
|
* @param token - Optional GitLab access token. If not provided, backend will use session.
|
|
35
65
|
* @param instanceUrl - Custom GitLab instance URL (optional)
|
|
36
66
|
*/
|
|
37
|
-
const getProjects = async (token, instanceUrl, otherOptions = {}) => await require_fetcher.fetcher(
|
|
67
|
+
const getProjects = async (token, instanceUrl, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, gitlabGroup, gitlabEndpoints.listProjects), authAPIOptions, otherOptions, { params: {
|
|
38
68
|
...token && { token },
|
|
39
69
|
...instanceUrl && { instanceUrl }
|
|
40
70
|
} });
|
|
@@ -45,8 +75,8 @@ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
45
75
|
* @param branch - Branch name (default: 'main')
|
|
46
76
|
* @param instanceUrl - Custom GitLab instance URL (optional)
|
|
47
77
|
*/
|
|
48
|
-
const checkIntlayerConfig = async (token, projectId, branch = "main", instanceUrl, otherOptions = {}) => await require_fetcher.fetcher(
|
|
49
|
-
method:
|
|
78
|
+
const checkIntlayerConfig = async (token, projectId, branch = "main", instanceUrl, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, gitlabGroup, gitlabEndpoints.checkConfig), authAPIOptions, otherOptions, {
|
|
79
|
+
method: gitlabEndpoints.checkConfig.method,
|
|
50
80
|
body: {
|
|
51
81
|
token: token ?? void 0,
|
|
52
82
|
projectId,
|
|
@@ -62,8 +92,8 @@ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
62
92
|
* @param path - File path (default: 'intlayer.config.ts')
|
|
63
93
|
* @param instanceUrl - Custom GitLab instance URL (optional)
|
|
64
94
|
*/
|
|
65
|
-
const getConfigFile = async (token, projectId, branch = "main", path = "intlayer.config.ts", instanceUrl, otherOptions = {}) => await require_fetcher.fetcher(
|
|
66
|
-
method:
|
|
95
|
+
const getConfigFile = async (token, projectId, branch = "main", path = "intlayer.config.ts", instanceUrl, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, gitlabGroup, gitlabEndpoints.getConfigFile), authAPIOptions, otherOptions, {
|
|
96
|
+
method: gitlabEndpoints.getConfigFile.method,
|
|
67
97
|
body: {
|
|
68
98
|
token: token ?? void 0,
|
|
69
99
|
projectId,
|
|
@@ -88,7 +118,6 @@ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
88
118
|
*/
|
|
89
119
|
const gitlabEndpoint = require_cms_createIntlayerCMS.createEndpoint(getGitlabAPI);
|
|
90
120
|
|
|
91
|
-
//#endregion
|
|
92
121
|
exports.getGitlabAPI = getGitlabAPI;
|
|
93
122
|
exports.gitlabEndpoint = gitlabEndpoint;
|
|
94
123
|
//# sourceMappingURL=gitlab.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.cjs","names":["editor","fetcher","createEndpoint"],"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.cjs","names":["editor","BACKEND_URL","fetcher","buildRouteURL","createEndpoint"],"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,cAAcA,8BAAO,cAAcC;;;;;;CAO7D,MAAM,aAAa,OACjB,aACA,aACA,eAA+B,CAAC,MAEhC,MAAMC,4BACJC,sDAAc,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,MAAMD,4BACJC,sDAAc,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,MAAMD,4BACJC,sDAAc,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,MAAMD,4BACJC,sDAAc,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,MAAMD,4BACJC,sDAAc,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,iBAAiBC,6CAAe,YAAY"}
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const require_getIntlayerAPI_dictionary = require(
|
|
9
|
-
const require_getIntlayerAPI_editor = require(
|
|
10
|
-
const require_getIntlayerAPI_environment = require(
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
2
|
+
const require_getIntlayerAPI_ai = require("./ai.cjs");
|
|
3
|
+
const require_getIntlayerAPI_analytics = require("./analytics.cjs");
|
|
4
|
+
const require_getIntlayerAPI_asset = require("./asset.cjs");
|
|
5
|
+
const require_getIntlayerAPI_audit = require("./audit.cjs");
|
|
6
|
+
const require_getIntlayerAPI_bitbucket = require("./bitbucket.cjs");
|
|
7
|
+
const require_getIntlayerAPI_codeberg = require("./codeberg.cjs");
|
|
8
|
+
const require_getIntlayerAPI_dictionary = require("./dictionary.cjs");
|
|
9
|
+
const require_getIntlayerAPI_editor = require("./editor.cjs");
|
|
10
|
+
const require_getIntlayerAPI_environment = require("./environment.cjs");
|
|
11
|
+
const require_getIntlayerAPI_gitee = require("./gitee.cjs");
|
|
12
|
+
const require_getIntlayerAPI_github = require("./github.cjs");
|
|
13
|
+
const require_getIntlayerAPI_gitlab = require("./gitlab.cjs");
|
|
14
|
+
const require_getIntlayerAPI_newsletter = require("./newsletter.cjs");
|
|
15
|
+
const require_getIntlayerAPI_oAuth = require("./oAuth.cjs");
|
|
16
|
+
const require_getIntlayerAPI_organization = require("./organization.cjs");
|
|
17
|
+
const require_getIntlayerAPI_project = require("./project.cjs");
|
|
18
|
+
const require_getIntlayerAPI_reviewer = require("./reviewer.cjs");
|
|
19
|
+
const require_getIntlayerAPI_search = require("./search.cjs");
|
|
20
|
+
const require_getIntlayerAPI_showcaseProject = require("./showcaseProject.cjs");
|
|
21
|
+
const require_getIntlayerAPI_status = require("./status.cjs");
|
|
22
|
+
const require_getIntlayerAPI_stripe = require("./stripe.cjs");
|
|
23
|
+
const require_getIntlayerAPI_tag = require("./tag.cjs");
|
|
24
|
+
const require_getIntlayerAPI_translate = require("./translate.cjs");
|
|
25
|
+
const require_getIntlayerAPI_user = require("./user.cjs");
|
|
24
26
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
25
27
|
let defu = require("defu");
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
// src/getIntlayerAPI/index.ts
|
|
28
30
|
const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
29
31
|
const resolvedConfig = (0, defu.defu)(intlayerConfig ?? {}, { editor: _intlayer_config_built.editor });
|
|
30
32
|
return {
|
|
@@ -46,6 +48,8 @@ const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
46
48
|
github: require_getIntlayerAPI_github.getGithubAPI(authAPIOptions, resolvedConfig),
|
|
47
49
|
gitlab: require_getIntlayerAPI_gitlab.getGitlabAPI(authAPIOptions, resolvedConfig),
|
|
48
50
|
bitbucket: require_getIntlayerAPI_bitbucket.getBitbucketAPI(authAPIOptions, resolvedConfig),
|
|
51
|
+
codeberg: require_getIntlayerAPI_codeberg.getCodebergAPI(authAPIOptions, resolvedConfig),
|
|
52
|
+
gitee: require_getIntlayerAPI_gitee.getGiteeAPI(authAPIOptions, resolvedConfig),
|
|
49
53
|
showcaseProject: require_getIntlayerAPI_showcaseProject.getShowcaseProjectAPI(authAPIOptions, resolvedConfig),
|
|
50
54
|
translate: require_getIntlayerAPI_translate.getTranslateAPI(authAPIOptions, resolvedConfig),
|
|
51
55
|
reviewer: require_getIntlayerAPI_reviewer.getReviewerAPI(authAPIOptions, resolvedConfig),
|
|
@@ -53,6 +57,5 @@ const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
53
57
|
};
|
|
54
58
|
};
|
|
55
59
|
|
|
56
|
-
//#endregion
|
|
57
60
|
exports.getIntlayerAPI = getIntlayerAPI;
|
|
58
61
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["getAssetAPI","getOrganizationAPI","getProjectAPI","getEnvironmentAPI","getUserAPI","getOAuthAPI","getDictionaryAPI","getStripeAPI","getAiAPI","getAnalyticsAPI","getAuditAPI","getTagAPI","getSearchAPI","getEditorAPI","getNewsletterAPI","getGithubAPI","getGitlabAPI","getBitbucketAPI","getShowcaseProjectAPI","getTranslateAPI","getReviewerAPI","getStatusAPI"],"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.cjs","names":["getAssetAPI","getOrganizationAPI","getProjectAPI","getEnvironmentAPI","getUserAPI","getOAuthAPI","getDictionaryAPI","getStripeAPI","getAiAPI","getAnalyticsAPI","getAuditAPI","getTagAPI","getSearchAPI","getEditorAPI","getNewsletterAPI","getGithubAPI","getGitlabAPI","getBitbucketAPI","getCodebergAPI","getGiteeAPI","getShowcaseProjectAPI","getTranslateAPI","getReviewerAPI","getStatusAPI"],"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,qBAAiB,WAAK,kBAAkB,CAAC,GAAG,EAChD,sCACF,CAAC;CAED,OAAO;EACL,OAAOA,yCAAY,gBAAgB,cAAc;EACjD,cAAcC,uDAAmB,gBAAgB,cAAc;EAC/D,SAASC,6CAAc,gBAAgB,cAAc;EACrD,aAAaC,qDAAkB,gBAAgB,cAAc;EAC7D,MAAMC,uCAAW,gBAAgB,cAAc;EAC/C,OAAOC,yCAAY,gBAAgB,cAAc;EACjD,YAAYC,mDAAiB,gBAAgB,cAAc;EAC3D,QAAQC,2CAAa,gBAAgB,cAAc;EACnD,IAAIC,mCAAS,gBAAgB,cAAc;EAC3C,WAAWC,iDAAgB,gBAAgB,cAAc;EACzD,OAAOC,yCAAY,gBAAgB,cAAc;EACjD,KAAKC,qCAAU,gBAAgB,cAAc;EAC7C,QAAQC,2CAAa,gBAAgB,cAAc;EACnD,QAAQC,2CAAa,gBAAgB,cAAc;EACnD,YAAYC,mDAAiB,gBAAgB,cAAc;EAC3D,QAAQC,2CAAa,gBAAgB,cAAc;EACnD,QAAQC,2CAAa,gBAAgB,cAAc;EACnD,WAAWC,iDAAgB,gBAAgB,cAAc;EACzD,UAAUC,+CAAe,gBAAgB,cAAc;EACvD,OAAOC,yCAAY,gBAAgB,cAAc;EACjD,iBAAiBC,6DAAsB,gBAAgB,cAAc;EACrE,WAAWC,iDAAgB,gBAAgB,cAAc;EACzD,UAAUC,+CAAe,gBAAgB,cAAc;EACvD,QAAQC,2CAAa,gBAAgB,cAAc;CACrD;AACF"}
|
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const require_cms_createIntlayerCMS = require("../cms/createIntlayerCMS.cjs");
|
|
3
|
+
const require_fetcher = require("../fetcher.cjs");
|
|
4
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
|
+
let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
|
|
6
|
+
let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
// src/getIntlayerAPI/newsletter.ts
|
|
9
|
+
/** Prefix of the routes, checked against the backend contract. */
|
|
10
|
+
const newsletterGroup = { prefix: "/api/newsletter" };
|
|
11
|
+
/**
|
|
12
|
+
* Method and path of every route, checked against the backend contract at
|
|
13
|
+
* compile time (the contract's zod schemas are never loaded).
|
|
14
|
+
*/
|
|
15
|
+
const newsletterEndpoints = {
|
|
16
|
+
subscribeToNewsletter: {
|
|
17
|
+
method: "POST",
|
|
18
|
+
path: "/subscribe"
|
|
19
|
+
},
|
|
20
|
+
unsubscribeFromNewsletter: {
|
|
21
|
+
method: "POST",
|
|
22
|
+
path: "/unsubscribe"
|
|
23
|
+
},
|
|
24
|
+
getNewsletterStatus: {
|
|
25
|
+
method: "GET",
|
|
26
|
+
path: "/status"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
7
29
|
const getNewsletterAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
8
|
-
const
|
|
30
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
|
|
9
31
|
/**
|
|
10
32
|
* Subscribe a user to newsletter(s)
|
|
11
33
|
* @param body - Newsletter subscription parameters.
|
|
12
34
|
* @returns Newsletter subscription result.
|
|
13
35
|
*/
|
|
14
|
-
const subscribeToNewsletter = async (body, otherOptions = {}) => await require_fetcher.fetcher(
|
|
15
|
-
method:
|
|
36
|
+
const subscribeToNewsletter = async (body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, newsletterGroup, newsletterEndpoints.subscribeToNewsletter), authAPIOptions, otherOptions, {
|
|
37
|
+
method: newsletterEndpoints.subscribeToNewsletter.method,
|
|
16
38
|
body
|
|
17
39
|
});
|
|
18
40
|
/**
|
|
@@ -20,15 +42,15 @@ const getNewsletterAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
20
42
|
* @param body - Newsletter unsubscription parameters.
|
|
21
43
|
* @returns Newsletter unsubscription result.
|
|
22
44
|
*/
|
|
23
|
-
const unsubscribeFromNewsletter = async (body, otherOptions = {}) => await require_fetcher.fetcher(
|
|
24
|
-
method:
|
|
45
|
+
const unsubscribeFromNewsletter = async (body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, newsletterGroup, newsletterEndpoints.unsubscribeFromNewsletter), authAPIOptions, otherOptions, {
|
|
46
|
+
method: newsletterEndpoints.unsubscribeFromNewsletter.method,
|
|
25
47
|
body
|
|
26
48
|
});
|
|
27
49
|
/**
|
|
28
50
|
* Get newsletter subscription status for the authenticated user
|
|
29
51
|
* @returns Newsletter subscription status.
|
|
30
52
|
*/
|
|
31
|
-
const getNewsletterStatus = async (otherOptions = {}) => await require_fetcher.fetcher(
|
|
53
|
+
const getNewsletterStatus = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, newsletterGroup, newsletterEndpoints.getNewsletterStatus), authAPIOptions, otherOptions, { method: newsletterEndpoints.getNewsletterStatus.method });
|
|
32
54
|
return {
|
|
33
55
|
subscribeToNewsletter,
|
|
34
56
|
unsubscribeFromNewsletter,
|
|
@@ -43,7 +65,6 @@ const getNewsletterAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
43
65
|
*/
|
|
44
66
|
const newsletterEndpoint = require_cms_createIntlayerCMS.createEndpoint(getNewsletterAPI);
|
|
45
67
|
|
|
46
|
-
//#endregion
|
|
47
68
|
exports.getNewsletterAPI = getNewsletterAPI;
|
|
48
69
|
exports.newsletterEndpoint = newsletterEndpoint;
|
|
49
70
|
//# sourceMappingURL=newsletter.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"newsletter.cjs","names":["editor","fetcher","createEndpoint"],"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.cjs","names":["editor","BACKEND_URL","fetcher","buildRouteURL","createEndpoint"],"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,cAAcA,8BAAO,cAAcC;;;;;;CAO7D,MAAM,wBAAwB,OAC5B,MACA,eAA+B,CAAC,MAEhC,MAAMC,4BACJC,sDACE,YACA,iBACA,oBAAoB,qBACtB,GACA,gBACA,cACA;EACE,QAAQ,oBAAoB,sBAAsB;EAC5C;CACR,CACF;;;;;;CAOF,MAAM,4BAA4B,OAChC,MACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,yBACtB,GACA,gBACA,cACA;EACE,QAAQ,oBAAoB,0BAA0B;EAChD;CACR,CACF;;;;;CAMF,MAAM,sBAAsB,OAAO,eAA+B,CAAC,MACjE,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,mBACtB,GACA,gBACA,cACA,EACE,QAAQ,oBAAoB,oBAAoB,OAClD,CACF;CAEF,OAAO;EACL;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,qBAAqBC,6CAAe,gBAAgB"}
|
|
@@ -1,16 +1,42 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_fetcher = require(
|
|
2
|
+
const require_fetcher = require("../fetcher.cjs");
|
|
3
3
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
4
|
+
let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
|
|
5
|
+
let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
// src/getIntlayerAPI/oAuth.ts
|
|
8
|
+
/** OAuth2 routes, checked against the backend contract. */
|
|
9
|
+
const oAuth2Group = { prefix: "/oauth2" };
|
|
10
|
+
const oAuth2Endpoints = {
|
|
11
|
+
getOAuth2AccessToken: {
|
|
12
|
+
method: "POST",
|
|
13
|
+
path: "/token"
|
|
14
|
+
},
|
|
15
|
+
extendOAuth2Token: {
|
|
16
|
+
method: "POST",
|
|
17
|
+
path: "/token/extend"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/** CLI session routes, checked against the backend contract. */
|
|
21
|
+
const cliSessionGroup = { prefix: "/api/cli-session" };
|
|
22
|
+
const cliSessionEndpoints = {
|
|
23
|
+
createCliSessionToken: {
|
|
24
|
+
method: "POST",
|
|
25
|
+
path: "/"
|
|
26
|
+
},
|
|
27
|
+
getCliSessionMe: {
|
|
28
|
+
method: "GET",
|
|
29
|
+
path: "/me"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
6
32
|
const getOAuthAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
7
|
-
const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL;
|
|
33
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
|
|
8
34
|
const { clientId, clientSecret } = intlayerConfig?.editor ?? {};
|
|
9
35
|
/**
|
|
10
36
|
* Gets an oAuth2 accessToken via client_credentials grant
|
|
11
37
|
*/
|
|
12
|
-
const getOAuth2AccessToken = async (otherOptions = {}) => await require_fetcher.fetcher(
|
|
13
|
-
method:
|
|
38
|
+
const getOAuth2AccessToken = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, oAuth2Group, oAuth2Endpoints.getOAuth2AccessToken), {}, otherOptions, {
|
|
39
|
+
method: oAuth2Endpoints.getOAuth2AccessToken.method,
|
|
14
40
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
15
41
|
body: {
|
|
16
42
|
grant_type: "client_credentials",
|
|
@@ -22,12 +48,12 @@ const getOAuthAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
22
48
|
* Creates a short-lived (2h) CLI session token for the authenticated user.
|
|
23
49
|
* Requires a valid browser session cookie.
|
|
24
50
|
*/
|
|
25
|
-
const createCliSessionToken = async (otherOptions = {}) => await require_fetcher.fetcher(
|
|
51
|
+
const createCliSessionToken = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, cliSessionGroup, cliSessionEndpoints.createCliSessionToken), authAPIOptions, otherOptions, { method: cliSessionEndpoints.createCliSessionToken.method });
|
|
26
52
|
/**
|
|
27
53
|
* Verifies a CLI session token and returns the associated project context.
|
|
28
54
|
* Useful for checking config consistency in the CLI.
|
|
29
55
|
*/
|
|
30
|
-
const getCliSessionMe = async (otherOptions = {}) => await require_fetcher.fetcher(
|
|
56
|
+
const getCliSessionMe = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, cliSessionGroup, cliSessionEndpoints.getCliSessionMe), authAPIOptions, otherOptions, { method: cliSessionEndpoints.getCliSessionMe.method });
|
|
31
57
|
return {
|
|
32
58
|
getOAuth2AccessToken,
|
|
33
59
|
createCliSessionToken,
|
|
@@ -35,6 +61,5 @@ const getOAuthAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
35
61
|
};
|
|
36
62
|
};
|
|
37
63
|
|
|
38
|
-
//#endregion
|
|
39
64
|
exports.getOAuthAPI = getOAuthAPI;
|
|
40
65
|
//# sourceMappingURL=oAuth.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oAuth.cjs","names":["editor","fetcher"],"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.cjs","names":["editor","BACKEND_URL","fetcher","buildRouteURL"],"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,cAAcA,8BAAO,cAAcC;CAC7D,MAAM,EAAE,UAAU,iBAAiB,gBAAgB,UAAU,CAAC;;;;CAK9D,MAAM,uBAAuB,OAAO,eAA+B,CAAC,MAClE,MAAMC,4BACJC,sDACE,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,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,qBACtB,GACA,gBACA,cACA,EAAE,QAAQ,oBAAoB,sBAAsB,OAAO,CAC7D;;;;;CAMF,MAAM,kBAAkB,OAAO,eAA+B,CAAC,MAC7D,MAAMD,4BACJC,sDACE,YACA,iBACA,oBAAoB,eACtB,GACA,gBACA,cACA,EAAE,QAAQ,oBAAoB,gBAAgB,OAAO,CACvD;CAEF,OAAO;EACL;EACA;EACA;CACF;AACF"}
|
|
@@ -1,16 +1,70 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const require_cms_createIntlayerCMS = require("../cms/createIntlayerCMS.cjs");
|
|
3
|
+
const require_fetcher = require("../fetcher.cjs");
|
|
4
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
|
+
let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
|
|
6
|
+
let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
// src/getIntlayerAPI/organization.ts
|
|
9
|
+
/** Prefix of the routes, checked against the backend contract. */
|
|
10
|
+
const organizationGroup = { prefix: "/api/organization" };
|
|
11
|
+
/**
|
|
12
|
+
* Method and path of every route, checked against the backend contract at
|
|
13
|
+
* compile time (the contract's zod schemas are never loaded).
|
|
14
|
+
*/
|
|
15
|
+
const organizationEndpoints = {
|
|
16
|
+
getOrganizations: {
|
|
17
|
+
method: "GET",
|
|
18
|
+
path: "/"
|
|
19
|
+
},
|
|
20
|
+
addOrganization: {
|
|
21
|
+
method: "POST",
|
|
22
|
+
path: "/"
|
|
23
|
+
},
|
|
24
|
+
updateOrganization: {
|
|
25
|
+
method: "PUT",
|
|
26
|
+
path: "/"
|
|
27
|
+
},
|
|
28
|
+
updateOrganizationMailerConfig: {
|
|
29
|
+
method: "PUT",
|
|
30
|
+
path: "/mailer-config"
|
|
31
|
+
},
|
|
32
|
+
updateOrganizationMembers: {
|
|
33
|
+
method: "PUT",
|
|
34
|
+
path: "/members"
|
|
35
|
+
},
|
|
36
|
+
updateOrganizationMembersById: {
|
|
37
|
+
method: "PUT",
|
|
38
|
+
path: "/:organizationId/members"
|
|
39
|
+
},
|
|
40
|
+
addOrganizationMember: {
|
|
41
|
+
method: "POST",
|
|
42
|
+
path: "/member"
|
|
43
|
+
},
|
|
44
|
+
deleteOrganization: {
|
|
45
|
+
method: "DELETE",
|
|
46
|
+
path: "/"
|
|
47
|
+
},
|
|
48
|
+
selectOrganization: {
|
|
49
|
+
method: "PUT",
|
|
50
|
+
path: "/:organizationId"
|
|
51
|
+
},
|
|
52
|
+
unselectOrganization: {
|
|
53
|
+
method: "POST",
|
|
54
|
+
path: "/logout"
|
|
55
|
+
},
|
|
56
|
+
deleteOrganizationByIdAdmin: {
|
|
57
|
+
method: "DELETE",
|
|
58
|
+
path: "/:organizationId/admin"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
7
61
|
const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
8
|
-
const
|
|
62
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
|
|
9
63
|
/**
|
|
10
64
|
* Retrieves a list of organizations based on filters and pagination.
|
|
11
65
|
* @param filters - Filters and pagination options.
|
|
12
66
|
*/
|
|
13
|
-
const getOrganizations = async (filters, otherOptions = {}) => await require_fetcher.fetcher(
|
|
67
|
+
const getOrganizations = async (filters, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.getOrganizations), authAPIOptions, otherOptions, {
|
|
14
68
|
cache: "no-store",
|
|
15
69
|
params: filters
|
|
16
70
|
});
|
|
@@ -18,21 +72,20 @@ const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
18
72
|
* Retrieves an organization by its ID.
|
|
19
73
|
* @param organizationId - Organization ID.
|
|
20
74
|
*/
|
|
21
|
-
const getOrganization = async (organizationId, otherOptions = {}) => await require_fetcher.fetcher(`${ORGANIZATION_API_ROUTE}/${String(organizationId)}`, authAPIOptions, otherOptions);
|
|
22
75
|
/**
|
|
23
76
|
* Adds a new organization to the database.
|
|
24
77
|
* @param organization - Organization data.
|
|
25
78
|
*/
|
|
26
|
-
const addOrganization = async (organization, otherOptions = {}) => await require_fetcher.fetcher(
|
|
27
|
-
method:
|
|
79
|
+
const addOrganization = async (organization, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.addOrganization), authAPIOptions, otherOptions, {
|
|
80
|
+
method: organizationEndpoints.addOrganization.method,
|
|
28
81
|
body: organization
|
|
29
82
|
});
|
|
30
83
|
/**
|
|
31
84
|
* Updates an existing organization in the database.
|
|
32
85
|
* @param organization - Updated organization data.
|
|
33
86
|
*/
|
|
34
|
-
const updateOrganization = async (organization, otherOptions = {}) => require_fetcher.fetcher(
|
|
35
|
-
method:
|
|
87
|
+
const updateOrganization = async (organization, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.updateOrganization), authAPIOptions, otherOptions, {
|
|
88
|
+
method: organizationEndpoints.updateOrganization.method,
|
|
36
89
|
body: organization
|
|
37
90
|
});
|
|
38
91
|
/**
|
|
@@ -40,16 +93,16 @@ const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
40
93
|
* @param body - Mailer configuration. Secrets are optional; omit to keep the
|
|
41
94
|
* value already stored.
|
|
42
95
|
*/
|
|
43
|
-
const updateOrganizationMailerConfig = async (body, otherOptions = {}) => require_fetcher.fetcher(
|
|
44
|
-
method:
|
|
96
|
+
const updateOrganizationMailerConfig = async (body, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.updateOrganizationMailerConfig), authAPIOptions, otherOptions, {
|
|
97
|
+
method: organizationEndpoints.updateOrganizationMailerConfig.method,
|
|
45
98
|
body
|
|
46
99
|
});
|
|
47
100
|
/**
|
|
48
101
|
* Update members to the organization in the database.
|
|
49
102
|
* @param body - Updated organization members data.
|
|
50
103
|
*/
|
|
51
|
-
const updateOrganizationMembers = async (body, otherOptions = {}) => require_fetcher.fetcher(
|
|
52
|
-
method:
|
|
104
|
+
const updateOrganizationMembers = async (body, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.updateOrganizationMembers), authAPIOptions, otherOptions, {
|
|
105
|
+
method: organizationEndpoints.updateOrganizationMembers.method,
|
|
53
106
|
body
|
|
54
107
|
});
|
|
55
108
|
/**
|
|
@@ -57,41 +110,40 @@ const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
57
110
|
* @param organizationId - Organization ID
|
|
58
111
|
* @param body - Updated organization members data.
|
|
59
112
|
*/
|
|
60
|
-
const updateOrganizationMembersById = async (organizationId, body, otherOptions = {}) => require_fetcher.fetcher(
|
|
61
|
-
method:
|
|
113
|
+
const updateOrganizationMembersById = async (organizationId, body, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.updateOrganizationMembersById, { organizationId: String(organizationId) }), authAPIOptions, otherOptions, {
|
|
114
|
+
method: organizationEndpoints.updateOrganizationMembersById.method,
|
|
62
115
|
body
|
|
63
116
|
});
|
|
64
117
|
/**
|
|
65
118
|
* Add member to the organization in the database.
|
|
66
119
|
* @param body - Updated organization members data.
|
|
67
120
|
*/
|
|
68
|
-
const addOrganizationMember = async (body, otherOptions = {}) => require_fetcher.fetcher(
|
|
69
|
-
method:
|
|
121
|
+
const addOrganizationMember = async (body, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.addOrganizationMember), authAPIOptions, otherOptions, {
|
|
122
|
+
method: organizationEndpoints.addOrganizationMember.method,
|
|
70
123
|
body
|
|
71
124
|
});
|
|
72
125
|
/**
|
|
73
126
|
* Deletes an organization from the database by its ID.
|
|
74
127
|
* @param organizationId - Organization ID.
|
|
75
128
|
*/
|
|
76
|
-
const deleteOrganization = async (otherOptions = {}) => await require_fetcher.fetcher(
|
|
129
|
+
const deleteOrganization = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.deleteOrganization), authAPIOptions, otherOptions, { method: organizationEndpoints.deleteOrganization.method });
|
|
77
130
|
/**
|
|
78
131
|
* Admin-only: Deletes any organization from the database by its ID.
|
|
79
132
|
* @param organizationId - Organization ID.
|
|
80
133
|
*/
|
|
81
|
-
const deleteOrganizationByIdAdmin = async (organizationId, otherOptions = {}) => require_fetcher.fetcher(
|
|
134
|
+
const deleteOrganizationByIdAdmin = async (organizationId, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.deleteOrganizationByIdAdmin, { organizationId: String(organizationId) }), authAPIOptions, otherOptions, { method: organizationEndpoints.deleteOrganizationByIdAdmin.method });
|
|
82
135
|
/**
|
|
83
136
|
* Select an organization from the database by its ID.
|
|
84
137
|
* @param organizationId - Organization ID.
|
|
85
138
|
*/
|
|
86
|
-
const selectOrganization = async (organizationId, otherOptions = {}) => await require_fetcher.fetcher(
|
|
139
|
+
const selectOrganization = async (organizationId, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.selectOrganization, { organizationId: String(organizationId) }), authAPIOptions, otherOptions, { method: organizationEndpoints.selectOrganization.method });
|
|
87
140
|
/**
|
|
88
141
|
* Unselect an organization from the database by its ID.
|
|
89
142
|
* @param organizationId - Organization ID.
|
|
90
143
|
*/
|
|
91
|
-
const unselectOrganization = async (otherOptions = {}) => await require_fetcher.fetcher(
|
|
144
|
+
const unselectOrganization = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, organizationGroup, organizationEndpoints.unselectOrganization), authAPIOptions, otherOptions, { method: organizationEndpoints.unselectOrganization.method });
|
|
92
145
|
return {
|
|
93
146
|
getOrganizations,
|
|
94
|
-
getOrganization,
|
|
95
147
|
addOrganization,
|
|
96
148
|
addOrganizationMember,
|
|
97
149
|
updateOrganization,
|
|
@@ -112,7 +164,6 @@ const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
112
164
|
*/
|
|
113
165
|
const organizationEndpoint = require_cms_createIntlayerCMS.createEndpoint(getOrganizationAPI);
|
|
114
166
|
|
|
115
|
-
//#endregion
|
|
116
167
|
exports.getOrganizationAPI = getOrganizationAPI;
|
|
117
168
|
exports.organizationEndpoint = organizationEndpoint;
|
|
118
169
|
//# sourceMappingURL=organization.cjs.map
|