@intlayer/api 9.0.0-canary.1 → 9.0.0-canary.11
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 +116 -0
- package/dist/cjs/cms/createAuthManager.cjs.map +1 -0
- package/dist/cjs/cms/createIntlayerCMS.cjs +64 -0
- package/dist/cjs/cms/createIntlayerCMS.cjs.map +1 -0
- package/dist/cjs/cms/index.cjs +7 -0
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +3 -2
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +3 -2
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/ai.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/asset.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/asset.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/audit.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/bitbucket.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/dictionary.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/editor.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/environment.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/environment.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/github.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/gitlab.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/index.cjs +1 -1
- package/dist/cjs/getIntlayerAPI/newsletter.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/organization.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/project.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/reviewer.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/reviewer.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/search.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/showcaseProject.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/showcaseProject.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/stripe.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/tag.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/translate.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/translate.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/user.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
- package/dist/cjs/index.cjs +27 -3
- package/dist/cjs/proxy.cjs +78 -97
- package/dist/cjs/proxy.cjs.map +1 -1
- package/dist/esm/cms/createAuthManager.mjs +115 -0
- package/dist/esm/cms/createAuthManager.mjs.map +1 -0
- package/dist/esm/cms/createIntlayerCMS.mjs +62 -0
- package/dist/esm/cms/createIntlayerCMS.mjs.map +1 -0
- package/dist/esm/cms/index.mjs +4 -0
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +3 -2
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +3 -2
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/ai.mjs +9 -1
- package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/asset.mjs +9 -1
- package/dist/esm/getIntlayerAPI/asset.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/audit.mjs +9 -1
- package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/bitbucket.mjs +9 -1
- package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/dictionary.mjs +9 -1
- package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/editor.mjs +9 -1
- package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/environment.mjs +9 -1
- package/dist/esm/getIntlayerAPI/environment.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/github.mjs +9 -1
- package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/gitlab.mjs +9 -1
- package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/index.mjs +1 -1
- package/dist/esm/getIntlayerAPI/newsletter.mjs +9 -1
- package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/organization.mjs +9 -1
- package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/project.mjs +9 -1
- package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/reviewer.mjs +9 -1
- package/dist/esm/getIntlayerAPI/reviewer.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/search.mjs +9 -1
- package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/showcaseProject.mjs +9 -1
- package/dist/esm/getIntlayerAPI/showcaseProject.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/stripe.mjs +9 -1
- package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/tag.mjs +9 -1
- package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/translate.mjs +9 -1
- package/dist/esm/getIntlayerAPI/translate.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/user.mjs +9 -1
- package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
- package/dist/esm/index.mjs +23 -21
- package/dist/esm/proxy.mjs +78 -97
- package/dist/esm/proxy.mjs.map +1 -1
- package/dist/types/cms/createAuthManager.d.ts +103 -0
- package/dist/types/cms/createAuthManager.d.ts.map +1 -0
- package/dist/types/cms/createIntlayerCMS.d.ts +80 -0
- package/dist/types/cms/createIntlayerCMS.d.ts.map +1 -0
- package/dist/types/cms/index.d.ts +3 -0
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/ai.d.ts +22 -2
- package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/asset.d.ts +19 -1
- package/dist/types/getIntlayerAPI/asset.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/audit.d.ts +24 -2
- package/dist/types/getIntlayerAPI/audit.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/bitbucket.d.ts +15 -1
- package/dist/types/getIntlayerAPI/bitbucket.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/dictionary.d.ts +19 -2
- package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/editor.d.ts +15 -2
- package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/environment.d.ts +17 -2
- package/dist/types/getIntlayerAPI/environment.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/github.d.ts +16 -1
- package/dist/types/getIntlayerAPI/github.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/gitlab.d.ts +15 -1
- package/dist/types/getIntlayerAPI/gitlab.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/index.d.ts +1 -1
- package/dist/types/getIntlayerAPI/newsletter.d.ts +14 -2
- package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/organization.d.ts +22 -2
- package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/project.d.ts +29 -2
- package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/reviewer.d.ts +46 -2
- package/dist/types/getIntlayerAPI/reviewer.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/search.d.ts +12 -2
- package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/showcaseProject.d.ts +23 -2
- package/dist/types/getIntlayerAPI/showcaseProject.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/stripe.d.ts +68 -2
- package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/tag.d.ts +15 -2
- package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/translate.d.ts +37 -2
- package/dist/types/getIntlayerAPI/translate.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/user.d.ts +20 -2
- package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
- package/dist/types/index.d.ts +23 -21
- package/dist/types/packages/@intlayer/unmerged-dictionaries-entry/dist/types/index.d.ts +10 -0
- package/dist/types/packages/@intlayer/unmerged-dictionaries-entry/dist/types/index.d.ts.map +1 -0
- package/dist/types/packages/intlayer-editor/server/dist/controllers/configuration.controller.d.ts +11 -0
- package/dist/types/packages/intlayer-editor/server/dist/controllers/configuration.controller.d.ts.map +1 -0
- package/dist/types/packages/intlayer-editor/server/dist/controllers/dictionary.controller.d.ts +25 -0
- package/dist/types/packages/intlayer-editor/server/dist/controllers/dictionary.controller.d.ts.map +1 -0
- package/dist/types/packages/intlayer-editor/server/dist/export.d.ts +2 -0
- package/dist/types/packages/intlayer-editor/server/dist/utils/httpStatusCodes.d.ts +408 -0
- package/dist/types/packages/intlayer-editor/server/dist/utils/httpStatusCodes.d.ts.map +1 -0
- package/dist/types/packages/intlayer-editor/server/dist/utils/responseData.d.ts +20 -0
- package/dist/types/packages/intlayer-editor/server/dist/utils/responseData.d.ts.map +1 -0
- package/dist/types/proxy.d.ts +11 -9
- package/dist/types/proxy.d.ts.map +1 -1
- package/package.json +12 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
3
|
import { editor } from "@intlayer/config/built";
|
|
3
4
|
|
|
4
5
|
//#region src/getIntlayerAPI/editor.ts
|
|
@@ -30,7 +31,14 @@ const getEditorAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
30
31
|
writeDictionary
|
|
31
32
|
};
|
|
32
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Authenticated `editor` endpoint bound to an Intlayer CMS authenticator.
|
|
36
|
+
*
|
|
37
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
38
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
39
|
+
*/
|
|
40
|
+
const editorEndpoint = createEndpoint(getEditorAPI);
|
|
33
41
|
|
|
34
42
|
//#endregion
|
|
35
|
-
export { getEditorAPI };
|
|
43
|
+
export { editorEndpoint, getEditorAPI };
|
|
36
44
|
//# sourceMappingURL=editor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.mjs","names":[],"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from 'intlayer-editor';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const editorURL = intlayerConfig?.editor?.editorURL ?? editor.editorURL;\n\n const EDITOR_API_ROUTE = `${editorURL}/api`;\n\n /**\n * Get the Intlayer configuration\n */\n const getConfiguration = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetConfigurationResult> => {\n const response = await fetcher<GetConfigurationResult>(\n `${EDITOR_API_ROUTE}/config`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetConfigurationResult;\n };\n\n /**\n * Get the Intlayer configuration\n */\n const getDictionaries = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetEditorDictionariesResult> => {\n const response = await fetcher<GetEditorDictionariesResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetEditorDictionariesResult;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n body: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n return {\n getDictionaries,\n getConfiguration,\n writeDictionary,\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"editor.mjs","names":[],"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from 'intlayer-editor';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const editorURL = intlayerConfig?.editor?.editorURL ?? editor.editorURL;\n\n const EDITOR_API_ROUTE = `${editorURL}/api`;\n\n /**\n * Get the Intlayer configuration\n */\n const getConfiguration = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetConfigurationResult> => {\n const response = await fetcher<GetConfigurationResult>(\n `${EDITOR_API_ROUTE}/config`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetConfigurationResult;\n };\n\n /**\n * Get the Intlayer configuration\n */\n const getDictionaries = async (\n otherOptions: FetcherOptions = {}\n ): Promise<GetEditorDictionariesResult> => {\n const response = await fetcher<GetEditorDictionariesResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions\n );\n\n return response.data as unknown as GetEditorDictionariesResult;\n };\n\n /**\n * Adds a new dictionary to the database.\n * @param dictionary - Dictionary data.\n */\n const writeDictionary = async (\n body: WriteContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<WriteContentDeclarationResult>(\n `${EDITOR_API_ROUTE}/dictionary`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n return {\n getDictionaries,\n getConfiguration,\n writeDictionary,\n };\n};\n\n/**\n * Authenticated `editor` 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 editorEndpoint = createEndpoint(getEditorAPI);\n"],"mappings":";;;;;AAWA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,mBAAmB,GAFP,gBAAgB,QAAQ,aAAa,OAAO,UAExB;;;;CAKtC,MAAM,mBAAmB,OACvB,eAA+B,EAAE,KACG;AAOpC,UAAO,MANgB,QACrB,GAAG,iBAAiB,UACpB,gBACA,aACD,EAEe;;;;;CAMlB,MAAM,kBAAkB,OACtB,eAA+B,EAAE,KACQ;AAOzC,UAAO,MANgB,QACrB,GAAG,iBAAiB,cACpB,gBACA,aACD,EAEe;;;;;;CAOlB,MAAM,kBAAkB,OACtB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,cACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD;;;;;;;;AASH,MAAa,iBAAiB,eAAe,aAAa"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
3
|
import { editor } from "@intlayer/config/built";
|
|
3
4
|
|
|
4
5
|
//#region src/getIntlayerAPI/environment.ts
|
|
@@ -28,7 +29,14 @@ const getEnvironmentAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
28
29
|
migrateEnvironment
|
|
29
30
|
};
|
|
30
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Authenticated `environment` endpoint bound to an Intlayer CMS authenticator.
|
|
34
|
+
*
|
|
35
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
36
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
37
|
+
*/
|
|
38
|
+
const environmentEndpoint = createEndpoint(getEnvironmentAPI);
|
|
31
39
|
|
|
32
40
|
//#endregion
|
|
33
|
-
export { getEnvironmentAPI };
|
|
41
|
+
export { environmentEndpoint, getEnvironmentAPI };
|
|
34
42
|
//# sourceMappingURL=environment.mjs.map
|
|
@@ -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 { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getEnvironmentAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n const ENVIRONMENT_API_ROUTE = `${backendURL}/api/project/environment`;\n\n const addEnvironment = async (\n body: AddEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddEnvironmentResult>(\n ENVIRONMENT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const updateEnvironment = async (\n environmentId: string,\n body: UpdateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n const deleteEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n const selectEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}/select`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const resetToProductionEnvironment = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetToProductionEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/production/select`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const migrateEnvironment = async (\n body: MigrateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<MigrateEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/migrate`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n return {\n addEnvironment,\n updateEnvironment,\n deleteEnvironment,\n selectEnvironment,\n resetToProductionEnvironment,\n migrateEnvironment,\n };\n};\n"],"mappings":"
|
|
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 = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n const ENVIRONMENT_API_ROUTE = `${backendURL}/api/project/environment`;\n\n const addEnvironment = async (\n body: AddEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddEnvironmentResult>(\n ENVIRONMENT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const updateEnvironment = async (\n environmentId: string,\n body: UpdateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n const deleteEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n const selectEnvironment = async (\n environmentId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/${environmentId}/select`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const resetToProductionEnvironment = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetToProductionEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/production/select`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const migrateEnvironment = async (\n body: MigrateEnvironmentBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<MigrateEnvironmentResult>(\n `${ENVIRONMENT_API_ROUTE}/migrate`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n 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":";;;;;AAgBA,MAAa,qBACX,iBAAiC,EAAE,EACnC,mBACG;CAEH,MAAM,wBAAwB,GADX,gBAAgB,QAAQ,cAAc,OAAO,WACpB;CAE5C,MAAM,iBAAiB,OACrB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,uBACA,gBACA,cACA;EAAE,QAAQ;EAAQ;EAAM,CACzB;CAEH,MAAM,oBAAoB,OACxB,eACA,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,sBAAsB,GAAG,iBAC5B,gBACA,cACA;EAAE,QAAQ;EAAO;EAAM,CACxB;CAEH,MAAM,oBAAoB,OACxB,eACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,sBAAsB,GAAG,iBAC5B,gBACA,cACA,EAAE,QAAQ,UAAU,CACrB;CAEH,MAAM,oBAAoB,OACxB,eACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,sBAAsB,GAAG,cAAc,UAC1C,gBACA,cACA,EAAE,QAAQ,OAAO,CAClB;CAEH,MAAM,+BAA+B,OACnC,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,sBAAsB,qBACzB,gBACA,cACA,EAAE,QAAQ,OAAO,CAClB;CAEH,MAAM,qBAAqB,OACzB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,sBAAsB,WACzB,gBACA,cACA;EAAE,QAAQ;EAAQ;EAAM,CACzB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD;;;;;;;;AASH,MAAa,sBAAsB,eAAe,kBAAkB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
3
|
import { editor } from "@intlayer/config/built";
|
|
3
4
|
|
|
4
5
|
//#region src/getIntlayerAPI/github.ts
|
|
@@ -69,7 +70,14 @@ const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
69
70
|
getToken
|
|
70
71
|
};
|
|
71
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Authenticated `github` endpoint bound to an Intlayer CMS authenticator.
|
|
75
|
+
*
|
|
76
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
77
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
78
|
+
*/
|
|
79
|
+
const githubEndpoint = createEndpoint(getGithubAPI);
|
|
72
80
|
|
|
73
81
|
//#endregion
|
|
74
|
-
export { getGithubAPI };
|
|
82
|
+
export { getGithubAPI, githubEndpoint };
|
|
75
83
|
//# sourceMappingURL=github.mjs.map
|
|
@@ -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 { 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 = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const GITHUB_API_ROUTE = `${backendURL}/api/github`;\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 `${GITHUB_API_ROUTE}/auth-url`,\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 `${GITHUB_API_ROUTE}/auth`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${GITHUB_API_ROUTE}/repos`,\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 `${GITHUB_API_ROUTE}/check-config`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${GITHUB_API_ROUTE}/get-config-file`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${GITHUB_API_ROUTE}/token`,\n authAPIOptions,\n otherOptions\n );\n\n return {\n getAuthUrl,\n authenticate,\n getRepositories,\n checkIntlayerConfig,\n getConfigFile,\n getToken,\n };\n};\n"],"mappings":"
|
|
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 = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const GITHUB_API_ROUTE = `${backendURL}/api/github`;\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 `${GITHUB_API_ROUTE}/auth-url`,\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 `${GITHUB_API_ROUTE}/auth`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${GITHUB_API_ROUTE}/repos`,\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 `${GITHUB_API_ROUTE}/check-config`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${GITHUB_API_ROUTE}/get-config-file`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${GITHUB_API_ROUTE}/token`,\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":";;;;;AAuEA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,mBAAmB,GAFN,gBAAgB,QAAQ,cAAc,OAAO,WAEzB;;;;;CAMvC,MAAM,aAAa,OACjB,aACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,YACpB,gBACA,cACA,EACE,QAAQ,EAAE,aAAa,EACxB,CACF;;;;;CAMH,MAAM,eAAe,OACnB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,QACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,MAAM;EACf,CACF;;;;;CAMH,MAAM,kBAAkB,OACtB,OACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,SACpB,gBACA,cACA,EACE,QAAQ,QAAQ,EAAE,OAAO,GAAG,QAC7B,CACF;;;;;;;;CASH,MAAM,sBAAsB,OAC1B,OACA,OACA,YACA,SAAiB,QACjB,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,gBACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;GAAQ;EAC/D,CACF;;;;;;;;;CAUH,MAAM,gBAAgB,OACpB,OACA,OACA,YACA,SAAiB,QACjB,OAAe,sBACf,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,mBACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;GAAQ;GAAM;EACrE,CACF;;;;CAKH,MAAM,WAAW,OAAO,eAA+B,EAAE,KACvD,MAAM,QACJ,GAAG,iBAAiB,SACpB,gBACA,aACD;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD;;;;;;;;AASH,MAAa,iBAAiB,eAAe,aAAa"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
3
|
import { editor } from "@intlayer/config/built";
|
|
3
4
|
|
|
4
5
|
//#region src/getIntlayerAPI/gitlab.ts
|
|
@@ -78,7 +79,14 @@ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
78
79
|
getConfigFile
|
|
79
80
|
};
|
|
80
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Authenticated `gitlab` endpoint bound to an Intlayer CMS authenticator.
|
|
84
|
+
*
|
|
85
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
86
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
87
|
+
*/
|
|
88
|
+
const gitlabEndpoint = createEndpoint(getGitlabAPI);
|
|
81
89
|
|
|
82
90
|
//#endregion
|
|
83
|
-
export { getGitlabAPI };
|
|
91
|
+
export { getGitlabAPI, gitlabEndpoint };
|
|
84
92
|
//# sourceMappingURL=gitlab.mjs.map
|
|
@@ -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 { 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 = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const GITLAB_API_ROUTE = `${backendURL}/api/gitlab`;\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 `${GITLAB_API_ROUTE}/auth-url`,\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 `${GITLAB_API_ROUTE}/auth`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${GITLAB_API_ROUTE}/projects`,\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 `${GITLAB_API_ROUTE}/check-config`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${GITLAB_API_ROUTE}/get-config-file`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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"],"mappings":"
|
|
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 = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const GITLAB_API_ROUTE = `${backendURL}/api/gitlab`;\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 `${GITLAB_API_ROUTE}/auth-url`,\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 `${GITLAB_API_ROUTE}/auth`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${GITLAB_API_ROUTE}/projects`,\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 `${GITLAB_API_ROUTE}/check-config`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${GITLAB_API_ROUTE}/get-config-file`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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":";;;;;AAsEA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,mBAAmB,GAFN,gBAAgB,QAAQ,cAAc,OAAO,WAEzB;;;;;;CAOvC,MAAM,aAAa,OACjB,aACA,aACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,YACpB,gBACA,cACA,EACE,QAAQ;EAAE;EAAa,GAAI,eAAe,EAAE,aAAa;EAAG,EAC7D,CACF;;;;;;;CAQH,MAAM,eAAe,OACnB,MACA,aACA,aACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,QACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GAAE;GAAM;GAAa;GAAa;EACzC,CACF;;;;;;CAOH,MAAM,cAAc,OAClB,OACA,aACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,YACpB,gBACA,cACA,EACE,QAAQ;EACN,GAAI,SAAS,EAAE,OAAO;EACtB,GAAI,eAAe,EAAE,aAAa;EACnC,EACF,CACF;;;;;;;;CASH,MAAM,sBAAsB,OAC1B,OACA,WACA,SAAiB,QACjB,aACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,gBACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GACJ,OAAO,SAAS;GAChB;GACA;GACA,GAAI,eAAe,EAAE,aAAa;GACnC;EACF,CACF;;;;;;;;;CAUH,MAAM,gBAAgB,OACpB,OACA,WACA,SAAiB,QACjB,OAAe,sBACf,aACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,mBACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GACJ,OAAO,SAAS;GAChB;GACA;GACA;GACA,GAAI,eAAe,EAAE,aAAa;GACnC;EACF,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACD;;;;;;;;AASH,MAAa,iBAAiB,eAAe,aAAa"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getOAuthAPI } from "./oAuth.mjs";
|
|
1
2
|
import { getAiAPI } from "./ai.mjs";
|
|
2
3
|
import { getAssetAPI } from "./asset.mjs";
|
|
3
4
|
import { getAuditAPI } from "./audit.mjs";
|
|
@@ -8,7 +9,6 @@ import { getEnvironmentAPI } from "./environment.mjs";
|
|
|
8
9
|
import { getGithubAPI } from "./github.mjs";
|
|
9
10
|
import { getGitlabAPI } from "./gitlab.mjs";
|
|
10
11
|
import { getNewsletterAPI } from "./newsletter.mjs";
|
|
11
|
-
import { getOAuthAPI } from "./oAuth.mjs";
|
|
12
12
|
import { getOrganizationAPI } from "./organization.mjs";
|
|
13
13
|
import { getProjectAPI } from "./project.mjs";
|
|
14
14
|
import { getReviewerAPI } from "./reviewer.mjs";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
3
|
import { editor } from "@intlayer/config/built";
|
|
3
4
|
|
|
4
5
|
//#region src/getIntlayerAPI/newsletter.ts
|
|
@@ -33,7 +34,14 @@ const getNewsletterAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
33
34
|
getNewsletterStatus
|
|
34
35
|
};
|
|
35
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Authenticated `newsletter` endpoint bound to an Intlayer CMS authenticator.
|
|
39
|
+
*
|
|
40
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
41
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
42
|
+
*/
|
|
43
|
+
const newsletterEndpoint = createEndpoint(getNewsletterAPI);
|
|
36
44
|
|
|
37
45
|
//#endregion
|
|
38
|
-
export { getNewsletterAPI };
|
|
46
|
+
export { getNewsletterAPI, newsletterEndpoint };
|
|
39
47
|
//# sourceMappingURL=newsletter.mjs.map
|
|
@@ -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 { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getNewsletterAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const NEWSLETTER_API_ROUTE = `${backendURL}/api/newsletter`;\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 `${NEWSLETTER_API_ROUTE}/subscribe`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${NEWSLETTER_API_ROUTE}/unsubscribe`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${NEWSLETTER_API_ROUTE}/status`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n return {\n subscribeToNewsletter,\n unsubscribeFromNewsletter,\n getNewsletterStatus,\n };\n};\n"],"mappings":"
|
|
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 = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const NEWSLETTER_API_ROUTE = `${backendURL}/api/newsletter`;\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 `${NEWSLETTER_API_ROUTE}/subscribe`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${NEWSLETTER_API_ROUTE}/unsubscribe`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${NEWSLETTER_API_ROUTE}/status`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\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":";;;;;AAUA,MAAa,oBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,uBAAuB,GAFV,gBAAgB,QAAQ,cAAc,OAAO,WAErB;;;;;;CAO3C,MAAM,wBAAwB,OAC5B,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,qBAAqB,aACxB,gBACA,cACA;EACE,QAAQ;EACF;EACP,CACF;;;;;;CAOH,MAAM,4BAA4B,OAChC,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,qBAAqB,eACxB,gBACA,cACA;EACE,QAAQ;EACF;EACP,CACF;;;;;CAMH,MAAM,sBAAsB,OAAO,eAA+B,EAAE,KAClE,MAAM,QACJ,GAAG,qBAAqB,UACxB,gBACA,cACA,EACE,QAAQ,OACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD;;;;;;;;AASH,MAAa,qBAAqB,eAAe,iBAAiB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
3
|
import { editor } from "@intlayer/config/built";
|
|
3
4
|
|
|
4
5
|
//#region src/getIntlayerAPI/organization.ts
|
|
@@ -92,7 +93,14 @@ const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
92
93
|
unselectOrganization
|
|
93
94
|
};
|
|
94
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Authenticated `organization` endpoint bound to an Intlayer CMS authenticator.
|
|
98
|
+
*
|
|
99
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
100
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
101
|
+
*/
|
|
102
|
+
const organizationEndpoint = createEndpoint(getOrganizationAPI);
|
|
95
103
|
|
|
96
104
|
//#endregion
|
|
97
|
-
export { getOrganizationAPI };
|
|
105
|
+
export { getOrganizationAPI, organizationEndpoint };
|
|
98
106
|
//# sourceMappingURL=organization.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization.mjs","names":[],"sources":["../../../src/getIntlayerAPI/organization.ts"],"sourcesContent":["import type {\n AddOrganizationBody,\n AddOrganizationMemberBody,\n AddOrganizationMemberResult,\n AddOrganizationResult,\n DeleteOrganizationResult,\n GetOrganizationParam,\n GetOrganizationResult,\n GetOrganizationsParams,\n GetOrganizationsResult,\n SelectOrganizationParam,\n SelectOrganizationResult,\n UnselectOrganizationResult,\n UpdateOrganizationBody,\n UpdateOrganizationMembersBody,\n UpdateOrganizationMembersResult,\n UpdateOrganizationResult,\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 getOrganizationAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const ORGANIZATION_API_ROUTE = `${backendURL}/api/organization`;\n\n /**\n * Retrieves a list of organizations based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getOrganizations = async (\n filters?: GetOrganizationsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationsResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves an organization by its ID.\n * @param organizationId - Organization ID.\n */\n const getOrganization = async (\n organizationId: GetOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Adds a new organization to the database.\n * @param organization - Organization data.\n */\n const addOrganization = async (\n organization: AddOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: organization,\n }\n );\n\n /**\n * Updates an existing organization in the database.\n * @param organization - Updated organization data.\n */\n const updateOrganization = async (\n organization: UpdateOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: organization,\n }\n );\n\n /**\n * Update members to the organization in the database.\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembers = async (\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n `${ORGANIZATION_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Admin-only: Update members of any organization by ID\n * @param organizationId - Organization ID\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembersById = async (\n organizationId: string,\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n `${ORGANIZATION_API_ROUTE}/${organizationId}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Add member to the organization in the database.\n * @param body - Updated organization members data.\n */\n const addOrganizationMember = async (\n body: AddOrganizationMemberBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<AddOrganizationMemberResult>(\n `${ORGANIZATION_API_ROUTE}/member`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Deletes an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Admin-only: Deletes any organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganizationByIdAdmin = async (\n organizationId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${organizationId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const selectOrganization = async (\n organizationId: SelectOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const unselectOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getOrganizations,\n getOrganization,\n addOrganization,\n addOrganizationMember,\n updateOrganization,\n updateOrganizationMembers,\n updateOrganizationMembersById,\n deleteOrganization,\n deleteOrganizationByIdAdmin,\n selectOrganization,\n unselectOrganization,\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"organization.mjs","names":[],"sources":["../../../src/getIntlayerAPI/organization.ts"],"sourcesContent":["import type {\n AddOrganizationBody,\n AddOrganizationMemberBody,\n AddOrganizationMemberResult,\n AddOrganizationResult,\n DeleteOrganizationResult,\n GetOrganizationParam,\n GetOrganizationResult,\n GetOrganizationsParams,\n GetOrganizationsResult,\n SelectOrganizationParam,\n SelectOrganizationResult,\n UnselectOrganizationResult,\n UpdateOrganizationBody,\n UpdateOrganizationMembersBody,\n UpdateOrganizationMembersResult,\n UpdateOrganizationResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getOrganizationAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const ORGANIZATION_API_ROUTE = `${backendURL}/api/organization`;\n\n /**\n * Retrieves a list of organizations based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getOrganizations = async (\n filters?: GetOrganizationsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationsResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves an organization by its ID.\n * @param organizationId - Organization ID.\n */\n const getOrganization = async (\n organizationId: GetOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Adds a new organization to the database.\n * @param organization - Organization data.\n */\n const addOrganization = async (\n organization: AddOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: organization,\n }\n );\n\n /**\n * Updates an existing organization in the database.\n * @param organization - Updated organization data.\n */\n const updateOrganization = async (\n organization: UpdateOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: organization,\n }\n );\n\n /**\n * Update members to the organization in the database.\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembers = async (\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n `${ORGANIZATION_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Admin-only: Update members of any organization by ID\n * @param organizationId - Organization ID\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembersById = async (\n organizationId: string,\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n `${ORGANIZATION_API_ROUTE}/${organizationId}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Add member to the organization in the database.\n * @param body - Updated organization members data.\n */\n const addOrganizationMember = async (\n body: AddOrganizationMemberBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<AddOrganizationMemberResult>(\n `${ORGANIZATION_API_ROUTE}/member`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Deletes an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Admin-only: Deletes any organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganizationByIdAdmin = async (\n organizationId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${organizationId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const selectOrganization = async (\n organizationId: SelectOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const unselectOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getOrganizations,\n getOrganization,\n addOrganization,\n addOrganizationMember,\n updateOrganization,\n updateOrganizationMembers,\n updateOrganizationMembersById,\n deleteOrganization,\n deleteOrganizationByIdAdmin,\n selectOrganization,\n unselectOrganization,\n };\n};\n\n/**\n * Authenticated `organization` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const organizationEndpoint = createEndpoint(getOrganizationAPI);\n"],"mappings":";;;;;AAuBA,MAAa,sBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,yBAAyB,GAFZ,gBAAgB,QAAQ,cAAc,OAAO,WAEnB;;;;;CAM7C,MAAM,mBAAmB,OACvB,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,wBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EAC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,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;;;;;;;AASH,MAAa,uBAAuB,eAAe,mBAAmB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
3
|
import { editor } from "@intlayer/config/built";
|
|
3
4
|
|
|
4
5
|
//#region src/getIntlayerAPI/project.ts
|
|
@@ -160,7 +161,14 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
160
161
|
updateMemberAccess
|
|
161
162
|
};
|
|
162
163
|
};
|
|
164
|
+
/**
|
|
165
|
+
* Authenticated `project` endpoint bound to an Intlayer CMS authenticator.
|
|
166
|
+
*
|
|
167
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
168
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
169
|
+
*/
|
|
170
|
+
const projectEndpoint = createEndpoint(getProjectAPI);
|
|
163
171
|
|
|
164
172
|
//#endregion
|
|
165
|
-
export { getProjectAPI };
|
|
173
|
+
export { getProjectAPI, projectEndpoint };
|
|
166
174
|
//# sourceMappingURL=project.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.mjs","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectInsightsResult,\n GetProjectsParams,\n GetProjectsResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n ResponseData,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateMemberAccessBody,\n UpdateMemberAccessResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves aggregated localization insights for the currently selected\n * project (locale/key counts, per-locale completion, missing translations,\n * recent activity, team/config status).\n */\n const getProjectInsights = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetProjectInsightsResult>(\n `${PROJECT_API_ROUTE}/insights`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n method: 'GET',\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Admin-only: Deletes any project from the database by its ID.\n * @param projectId - Project ID.\n */\n const deleteProjectByIdAdmin = async (\n projectId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}/${projectId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Updates granular access constraints for a project member.\n * @param userId - The user ID to update access for.\n * @param body - The new access constraints.\n */\n const updateMemberAccess = async (\n userId: string,\n body: UpdateMemberAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateMemberAccessResult>(\n `${PROJECT_API_ROUTE}/member/${userId}/access`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n return {\n getProjects,\n getProjectInsights,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n deleteProjectByIdAdmin,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n updateMemberAccess,\n };\n};\n"],"mappings":";;;;AAiCA,MAAa,iBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,oBAAoB,GAFP,gBAAgB,QAAQ,cAAc,OAAO,WAExB;;;;;CAMxC,MAAM,cAAc,OAClB,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;;CAOH,MAAM,qBAAqB,OAAO,eAA+B,EAAE,KACjE,MAAM,QACJ,GAAG,kBAAkB,YACrB,gBACA,cACA;EACE,O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J,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,UAAU;EACnB,CACF;;;;;;;CAQH,MAAM,mBAAmB,OACvB,UACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,UAAU;EACnB,CACF;;;;;;CAOH,MAAM,eAAe,OAAO,eAA+B,EAAE,KAC3D,MAAM,QACJ,GAAG,kBAAkB,SACrB,gBACA,cACA,EACE,QAAQ,QACT,CACF;;;;;;;CAQH,MAAM,iBAAiB,OACrB,cACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,cAAc;EACvB,CACF;;;;;;CAOH,MAAM,cAAc,OAAO,eAA+B,EAAE,KAC1D,MAAM,QACJ,GAAG,kBAAkB,MACrB,gBACA,cACA,EACE,QAAQ,OACT,CACF;;;;;;CAOH,MAAM,eAAe,OAAO,eAA+B,EAAE,KAC3D,MAAM,QACJ,GAAG,kBAAkB,MACrB,gBACA,cACA,EACE,QAAQ,QACT,CACF;;;;;;CAOH,MAAM,qBAAqB,OACzB,QACA,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,UAAU,OAAO,UACtC,gBACA,cACA;EAAE,QAAQ;EAAO;EAAM,CACxB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"project.mjs","names":[],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectInsightsResult,\n GetProjectsParams,\n GetProjectsResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n ResponseData,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateMemberAccessBody,\n UpdateMemberAccessResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves aggregated localization insights for the currently selected\n * project (locale/key counts, per-locale completion, missing translations,\n * recent activity, team/config status).\n */\n const getProjectInsights = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetProjectInsightsResult>(\n `${PROJECT_API_ROUTE}/insights`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n method: 'GET',\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Admin-only: Deletes any project from the database by its ID.\n * @param projectId - Project ID.\n */\n const deleteProjectByIdAdmin = async (\n projectId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}/${projectId}/admin`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<ResponseData<any>>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Updates granular access constraints for a project member.\n * @param userId - The user ID to update access for.\n * @param body - The new access constraints.\n */\n const updateMemberAccess = async (\n userId: string,\n body: UpdateMemberAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateMemberAccessResult>(\n `${PROJECT_API_ROUTE}/member/${userId}/access`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n return {\n getProjects,\n getProjectInsights,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n deleteProjectByIdAdmin,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n updateMemberAccess,\n };\n};\n\n/**\n * Authenticated `project` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\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O;EAAM,CACxB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;;;;;;;AASH,MAAa,kBAAkB,eAAe,cAAc"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
3
|
import { editor } from "@intlayer/config/built";
|
|
3
4
|
|
|
4
5
|
//#region src/getIntlayerAPI/reviewer.ts
|
|
@@ -126,7 +127,14 @@ const getReviewerAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
126
127
|
getAdminReviewers
|
|
127
128
|
};
|
|
128
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Authenticated `reviewer` endpoint bound to an Intlayer CMS authenticator.
|
|
132
|
+
*
|
|
133
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
134
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
135
|
+
*/
|
|
136
|
+
const reviewerEndpoint = createEndpoint(getReviewerAPI);
|
|
129
137
|
|
|
130
138
|
//#endregion
|
|
131
|
-
export { getReviewerAPI };
|
|
139
|
+
export { getReviewerAPI, reviewerEndpoint };
|
|
132
140
|
//# sourceMappingURL=reviewer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewer.mjs","names":[],"sources":["../../../src/getIntlayerAPI/reviewer.ts"],"sourcesContent":["import type {\n CreateMissionBody,\n EstimateMissionBody,\n GetMarketplaceQuery,\n MissionEstimate,\n PaginatedResponse,\n PriceDistributionData,\n RegisterReviewerBody,\n ResponseData,\n ReviewerMessageAPI,\n ReviewerProfileAPI,\n ReviewerReviewAPI,\n SendMessageBody,\n SubmitReviewBody,\n TranslationMissionAPI,\n UpdateMissionStatusBody,\n UpdateReviewerBody,\n UploadReviewerPictureResult,\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 getReviewerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n const BASE = `${backendURL}/api/reviewer`;\n\n // ── Marketplace ────────────────────────────────────────────────────────────\n\n const getMarketplace = (\n params: GetMarketplaceQuery = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const searchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n value.forEach((item) => {\n searchParams.append(key, String(item));\n });\n } else {\n searchParams.append(key, String(value));\n }\n }\n const query = searchParams.toString();\n\n return fetcher<PaginatedResponse<ReviewerProfileAPI>>(\n `${BASE}/marketplace${query ? `?${query}` : ''}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n const getPriceDistribution = (\n params: Pick<\n GetMarketplaceQuery,\n 'fromLocale' | 'toLocale' | 'minRating' | 'categories'\n > = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const searchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n value.forEach((item) => {\n searchParams.append(key, String(item));\n });\n } else {\n searchParams.append(key, String(value));\n }\n }\n const query = searchParams.toString();\n return fetcher<ResponseData<PriceDistributionData>>(\n `${BASE}/marketplace/price-distribution${query ? `?${query}` : ''}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n const getReviewerById = (\n reviewerId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerProfileAPI>>(\n `${BASE}/${reviewerId}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const getReviewerReviews = (\n reviewerId: string,\n params: { page?: number; pageSize?: number } = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const query = new URLSearchParams(\n Object.fromEntries(\n Object.entries(params)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => [k, String(v)])\n )\n ).toString();\n return fetcher<PaginatedResponse<ReviewerReviewAPI>>(\n `${BASE}/${reviewerId}/reviews${query ? `?${query}` : ''}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n // ── My profile ─────────────────────────────────────────────────────────────\n\n const getMyReviewerProfile = (otherOptions: FetcherOptions = {}) =>\n fetcher<ResponseData<ReviewerProfileAPI | null>>(\n `${BASE}/me`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const registerAsReviewer = (\n body: RegisterReviewerBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerProfileAPI>>(\n `${BASE}/register`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const updateReviewerProfile = (\n body: UpdateReviewerBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerProfileAPI>>(\n `${BASE}/`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n const deleteReviewerProfile = (otherOptions: FetcherOptions = {}) =>\n fetcher<ResponseData<null>>(BASE, authAPIOptions, otherOptions, {\n method: 'DELETE',\n });\n\n // ── Contact ────────────────────────────────────────────────────────────────\n\n const contactReviewer = (\n reviewerId: string,\n body: { message: string },\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<null>>(\n `${BASE}/${reviewerId}/contact`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n // ── Missions ───────────────────────────────────────────────────────────────\n\n const estimateMission = (\n body: EstimateMissionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<MissionEstimate>>(\n `${BASE}/mission/estimate`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const createMission = (\n body: CreateMissionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<TranslationMissionAPI>>(\n `${BASE}/mission`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const getMyMissions = (\n params: {\n role?: 'client' | 'reviewer';\n page?: number;\n pageSize?: number;\n } = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const query = new URLSearchParams(\n Object.fromEntries(\n Object.entries(params)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => [k, String(v)])\n )\n ).toString();\n return fetcher<PaginatedResponse<TranslationMissionAPI>>(\n `${BASE}/mission${query ? `?${query}` : ''}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n const getMissionById = (\n missionId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<TranslationMissionAPI>>(\n `${BASE}/mission/${missionId}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const updateMissionStatus = (\n missionId: string,\n body: UpdateMissionStatusBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<TranslationMissionAPI>>(\n `${BASE}/mission/${missionId}/status`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n // ── Reviews ────────────────────────────────────────────────────────────────\n\n const submitReview = (\n missionId: string,\n body: SubmitReviewBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerReviewAPI>>(\n `${BASE}/mission/${missionId}/review`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n // ── Chat ───────────────────────────────────────────────────────────────────\n\n const getChatHistory = (\n missionId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerMessageAPI[]>>(\n `${BASE}/mission/${missionId}/chat/history`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const sendMessage = (\n missionId: string,\n body: SendMessageBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerMessageAPI>>(\n `${BASE}/mission/${missionId}/chat`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const getChatStreamUrl = (missionId: string) =>\n `${BASE}/mission/${missionId}/chat/stream`;\n\n // ── Picture uploads ────────────────────────────────────────────────────────\n\n const uploadPicture = async (\n kind: 'main' | 'cover',\n file: File,\n otherOptions: FetcherOptions = {}\n ): Promise<UploadReviewerPictureResult> => {\n const buffer = await file.arrayBuffer();\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': file.type || 'image/jpeg',\n };\n\n const authHeaders =\n (authAPIOptions.headers as Record<string, string> | undefined) ?? {};\n\n const response = await fetch(`${BASE}/me/picture/${kind}`, {\n method: 'POST',\n credentials: 'include',\n headers: { ...authHeaders, ...baseHeaders },\n body: buffer,\n signal: otherOptions.signal as AbortSignal | undefined,\n });\n\n if (!response.ok) {\n const result = await response.json();\n throw new Error(JSON.stringify(result.error) ?? 'Picture upload failed');\n }\n\n return (await response.json()) as UploadReviewerPictureResult;\n };\n\n const uploadMainPicture = (file: File, otherOptions: FetcherOptions = {}) =>\n uploadPicture('main', file, otherOptions);\n\n const uploadCoverPicture = (file: File, otherOptions: FetcherOptions = {}) =>\n uploadPicture('cover', file, otherOptions);\n\n // ── Admin ──────────────────────────────────────────────────────────────────\n\n const validateReviewerProfile = (\n reviewerId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerProfileAPI>>(\n `${BASE}/${reviewerId}/validate`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const getAdminReviewers = (\n params: { page?: number; pageSize?: number; status?: string } = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const query = new URLSearchParams(\n Object.fromEntries(\n Object.entries(params)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => [k, String(v)])\n )\n ).toString();\n return fetcher<PaginatedResponse<ReviewerProfileAPI>>(\n `${BASE}/admin/reviewers${query ? `?${query}` : ''}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n return {\n getMarketplace,\n getPriceDistribution,\n getReviewerById,\n getReviewerReviews,\n getMyReviewerProfile,\n registerAsReviewer,\n updateReviewerProfile,\n deleteReviewerProfile,\n estimateMission,\n createMission,\n getMyMissions,\n getMissionById,\n updateMissionStatus,\n submitReview,\n contactReviewer,\n getChatHistory,\n sendMessage,\n getChatStreamUrl,\n uploadMainPicture,\n uploadCoverPicture,\n validateReviewerProfile,\n getAdminReviewers,\n };\n};\n"],"mappings":";;;;AAuBA,MAAa,kBACX,iBAAiC,EAAE,EACnC,mBACG;CAEH,MAAM,OAAO,GADM,gBAAgB,QAAQ,cAAc,OAAO,WACrC;CAI3B,MAAM,kBACJ,SAA8B,EAAE,EAChC,eAA+B,EAAE,KAC9B;EACH,MAAM,eAAe,IAAI,iBAAiB;AAC1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,EAAE;AACjD,OAAI,UAAU,OAAW;AACzB,OAAI,MAAM,QAAQ,MAAM,CACtB,OAAM,SAAS,SAAS;AACtB,iBAAa,OAAO,KAAK,OAAO,KAAK,CAAC;KACtC;OAEF,cAAa,OAAO,KAAK,OAAO,MAAM,CAAC;;EAG3C,MAAM,QAAQ,aAAa,UAAU;AAErC,SAAO,QACL,GAAG,KAAK,cAAc,QAAQ,IAAI,UAAU,MAC5C,gBACA,cACA,EAAE,QAAQ,OAAO,CAClB;;CAGH,MAAM,wBACJ,SAGI,EAAE,EACN,eAA+B,EAAE,KAC9B;EACH,MAAM,eAAe,IAAI,iBAAiB;AAC1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,EAAE;AACjD,OAAI,UAAU,OAAW;AACzB,OAAI,MAAM,QAAQ,MAAM,CACtB,OAAM,SAAS,SAAS;AACtB,iBAAa,OAAO,KAAK,OAAO,KAAK,CAAC;KACtC;OAEF,cAAa,OAAO,KAAK,OAAO,MAAM,CAAC;;EAG3C,MAAM,QAAQ,aAAa,UAAU;AACrC,SAAO,QACL,GAAG,KAAK,iCAAiC,QAAQ,IAAI,U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EAEtE,MAAM,WAAW,MAAM,MAAM,GAAG,KAAK,cAAc,QAAQ;GACzD,QAAQ;GACR,aAAa;GACb,SAAS;IAAE,GAAG;IAAa,GAAG;IAAa;GAC3C,MAAM;GACN,QAAQ,aAAa;GACtB,CAAC;AAEF,MAAI,CAAC,SAAS,IAAI;GAChB,MAAM,SAAS,MAAM,SAAS,MAAM;AACpC,SAAM,IAAI,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,wBAAwB;;AAG1E,SAAQ,MAAM,SAAS,MAAM;;CAG/B,MAAM,qBAAqB,MAAY,eAA+B,EAAE,KACtE,cAAc,QAAQ,MAAM,aAAa;CAE3C,MAAM,sBAAsB,MAAY,eAA+B,EAAE,KACvE,cAAc,SAAS,MAAM,aAAa;CAI5C,MAAM,2BACJ,YACA,eAA+B,EAAE,KAEjC,QACE,GAAG,KAAK,GAAG,WAAW,YACtB,gBACA,cACA,EAAE,QAAQ,OAAO,CAClB;CAEH,MAAM,qBACJ,SAAgE,EAAE,EAClE,eAA+B,EAAE,KAC9B;EACH,MAAM,QAAQ,IAAI,gBAChB,OAAO,YACL,OAAO,QAAQ,OAAO,CACnB,QAAQ,GAAG,OAAO,MAAM,OAAU,CAClC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC,CACnC,CACF,CAAC,UAAU;AACZ,SAAO,QACL,GAAG,KAAK,kBAAkB,QAAQ,IAAI,UAAU,MAChD,gBACA,cACA,EAAE,QAAQ,OAAO,CAClB;;AAGH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"reviewer.mjs","names":[],"sources":["../../../src/getIntlayerAPI/reviewer.ts"],"sourcesContent":["import type {\n CreateMissionBody,\n EstimateMissionBody,\n GetMarketplaceQuery,\n MissionEstimate,\n PaginatedResponse,\n PriceDistributionData,\n RegisterReviewerBody,\n ResponseData,\n ReviewerMessageAPI,\n ReviewerProfileAPI,\n ReviewerReviewAPI,\n SendMessageBody,\n SubmitReviewBody,\n TranslationMissionAPI,\n UpdateMissionStatusBody,\n UpdateReviewerBody,\n UploadReviewerPictureResult,\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 getReviewerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n const BASE = `${backendURL}/api/reviewer`;\n\n // ── Marketplace ────────────────────────────────────────────────────────────\n\n const getMarketplace = (\n params: GetMarketplaceQuery = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const searchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n value.forEach((item) => {\n searchParams.append(key, String(item));\n });\n } else {\n searchParams.append(key, String(value));\n }\n }\n const query = searchParams.toString();\n\n return fetcher<PaginatedResponse<ReviewerProfileAPI>>(\n `${BASE}/marketplace${query ? `?${query}` : ''}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n const getPriceDistribution = (\n params: Pick<\n GetMarketplaceQuery,\n 'fromLocale' | 'toLocale' | 'minRating' | 'categories'\n > = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const searchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n value.forEach((item) => {\n searchParams.append(key, String(item));\n });\n } else {\n searchParams.append(key, String(value));\n }\n }\n const query = searchParams.toString();\n return fetcher<ResponseData<PriceDistributionData>>(\n `${BASE}/marketplace/price-distribution${query ? `?${query}` : ''}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n const getReviewerById = (\n reviewerId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerProfileAPI>>(\n `${BASE}/${reviewerId}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const getReviewerReviews = (\n reviewerId: string,\n params: { page?: number; pageSize?: number } = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const query = new URLSearchParams(\n Object.fromEntries(\n Object.entries(params)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => [k, String(v)])\n )\n ).toString();\n return fetcher<PaginatedResponse<ReviewerReviewAPI>>(\n `${BASE}/${reviewerId}/reviews${query ? `?${query}` : ''}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n // ── My profile ─────────────────────────────────────────────────────────────\n\n const getMyReviewerProfile = (otherOptions: FetcherOptions = {}) =>\n fetcher<ResponseData<ReviewerProfileAPI | null>>(\n `${BASE}/me`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const registerAsReviewer = (\n body: RegisterReviewerBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerProfileAPI>>(\n `${BASE}/register`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const updateReviewerProfile = (\n body: UpdateReviewerBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerProfileAPI>>(\n `${BASE}/`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n const deleteReviewerProfile = (otherOptions: FetcherOptions = {}) =>\n fetcher<ResponseData<null>>(BASE, authAPIOptions, otherOptions, {\n method: 'DELETE',\n });\n\n // ── Contact ────────────────────────────────────────────────────────────────\n\n const contactReviewer = (\n reviewerId: string,\n body: { message: string },\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<null>>(\n `${BASE}/${reviewerId}/contact`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n // ── Missions ───────────────────────────────────────────────────────────────\n\n const estimateMission = (\n body: EstimateMissionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<MissionEstimate>>(\n `${BASE}/mission/estimate`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const createMission = (\n body: CreateMissionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<TranslationMissionAPI>>(\n `${BASE}/mission`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const getMyMissions = (\n params: {\n role?: 'client' | 'reviewer';\n page?: number;\n pageSize?: number;\n } = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const query = new URLSearchParams(\n Object.fromEntries(\n Object.entries(params)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => [k, String(v)])\n )\n ).toString();\n return fetcher<PaginatedResponse<TranslationMissionAPI>>(\n `${BASE}/mission${query ? `?${query}` : ''}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n const getMissionById = (\n missionId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<TranslationMissionAPI>>(\n `${BASE}/mission/${missionId}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const updateMissionStatus = (\n missionId: string,\n body: UpdateMissionStatusBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<TranslationMissionAPI>>(\n `${BASE}/mission/${missionId}/status`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT', body }\n );\n\n // ── Reviews ────────────────────────────────────────────────────────────────\n\n const submitReview = (\n missionId: string,\n body: SubmitReviewBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerReviewAPI>>(\n `${BASE}/mission/${missionId}/review`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n // ── Chat ───────────────────────────────────────────────────────────────────\n\n const getChatHistory = (\n missionId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerMessageAPI[]>>(\n `${BASE}/mission/${missionId}/chat/history`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const sendMessage = (\n missionId: string,\n body: SendMessageBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerMessageAPI>>(\n `${BASE}/mission/${missionId}/chat`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const getChatStreamUrl = (missionId: string) =>\n `${BASE}/mission/${missionId}/chat/stream`;\n\n // ── Picture uploads ────────────────────────────────────────────────────────\n\n const uploadPicture = async (\n kind: 'main' | 'cover',\n file: File,\n otherOptions: FetcherOptions = {}\n ): Promise<UploadReviewerPictureResult> => {\n const buffer = await file.arrayBuffer();\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': file.type || 'image/jpeg',\n };\n\n const authHeaders =\n (authAPIOptions.headers as Record<string, string> | undefined) ?? {};\n\n const response = await fetch(`${BASE}/me/picture/${kind}`, {\n method: 'POST',\n credentials: 'include',\n headers: { ...authHeaders, ...baseHeaders },\n body: buffer,\n signal: otherOptions.signal as AbortSignal | undefined,\n });\n\n if (!response.ok) {\n const result = await response.json();\n throw new Error(JSON.stringify(result.error) ?? 'Picture upload failed');\n }\n\n return (await response.json()) as UploadReviewerPictureResult;\n };\n\n const uploadMainPicture = (file: File, otherOptions: FetcherOptions = {}) =>\n uploadPicture('main', file, otherOptions);\n\n const uploadCoverPicture = (file: File, otherOptions: FetcherOptions = {}) =>\n uploadPicture('cover', file, otherOptions);\n\n // ── Admin ──────────────────────────────────────────────────────────────────\n\n const validateReviewerProfile = (\n reviewerId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<ResponseData<ReviewerProfileAPI>>(\n `${BASE}/${reviewerId}/validate`,\n authAPIOptions,\n otherOptions,\n { method: 'PUT' }\n );\n\n const getAdminReviewers = (\n params: { page?: number; pageSize?: number; status?: string } = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const query = new URLSearchParams(\n Object.fromEntries(\n Object.entries(params)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => [k, String(v)])\n )\n ).toString();\n return fetcher<PaginatedResponse<ReviewerProfileAPI>>(\n `${BASE}/admin/reviewers${query ? `?${query}` : ''}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n return {\n getMarketplace,\n getPriceDistribution,\n getReviewerById,\n getReviewerReviews,\n getMyReviewerProfile,\n registerAsReviewer,\n updateReviewerProfile,\n deleteReviewerProfile,\n estimateMission,\n createMission,\n getMyMissions,\n getMissionById,\n updateMissionStatus,\n submitReview,\n contactReviewer,\n getChatHistory,\n sendMessage,\n getChatStreamUrl,\n uploadMainPicture,\n uploadCoverPicture,\n validateReviewerProfile,\n getAdminReviewers,\n };\n};\n\n/**\n * Authenticated `reviewer` 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 reviewerEndpoint = createEndpoint(getReviewerAPI);\n"],"mappings":";;;;;AAwBA,MAAa,kBACX,iBAAiC,EAAE,EACnC,mBACG;CAEH,MAAM,OAAO,GADM,gBAAgB,QAAQ,cAAc,OAAO,WACrC;CAI3B,MAAM,kBACJ,SAA8B,EAAE,EAChC,eAA+B,EAAE,KAC9B;EACH,MAAM,eAAe,IAAI,iBAAiB;AAC1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,EAAE;AACjD,OAAI,UAAU,OAAW;AACzB,OAAI,MAAM,QAAQ,MAAM,CACtB,OAAM,SAAS,SAAS;AACtB,iBAAa,OAAO,KAAK,OAAO,KAAK,CAAC;KACtC;OAEF,cAAa,OAAO,KAAK,OAAO,MAAM,CAAC;;EAG3C,MAAM,QAAQ,aAAa,UAAU;AAErC,SAAO,QACL,GAAG,KAAK,cAAc,QAAQ,IAAI,UAAU,MAC5C,gBACA,cACA,EAAE,QAAQ,OAAO,CAClB;;CAGH,MAAM,wB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,SAAO,QACL,GAAG,KAAK,kBAAkB,QAAQ,IAAI,UAAU,MAChD,gBACA,cACA,EAAE,QAAQ,OAAO,CAClB;;AAGH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;;;;;;;AASH,MAAa,mBAAmB,eAAe,eAAe"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
3
|
import { editor } from "@intlayer/config/built";
|
|
3
4
|
|
|
4
5
|
//#region src/getIntlayerAPI/search.ts
|
|
@@ -15,7 +16,14 @@ const getSearchAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
15
16
|
});
|
|
16
17
|
return { searchDoc };
|
|
17
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Authenticated `search` endpoint bound to an Intlayer CMS authenticator.
|
|
21
|
+
*
|
|
22
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
23
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
24
|
+
*/
|
|
25
|
+
const searchEndpoint = createEndpoint(getSearchAPI);
|
|
18
26
|
|
|
19
27
|
//#endregion
|
|
20
|
-
export { getSearchAPI };
|
|
28
|
+
export { getSearchAPI, searchEndpoint };
|
|
21
29
|
//# sourceMappingURL=search.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.mjs","names":[],"sources":["../../../src/getIntlayerAPI/search.ts"],"sourcesContent":["import type {\n SearchDocUtilParams,\n SearchDocUtilResult,\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 getSearchAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const AI_API_ROUTE = `${backendURL}/api/search`;\n\n /**\n * Search documentation\n * @param params - Search parameters containing the input query.\n * @returns Search results with GitHub URLs.\n */\n const searchDoc = async (\n params?: SearchDocUtilParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SearchDocUtilResult>(\n `${AI_API_ROUTE}/doc`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n params: params,\n }\n );\n\n return {\n searchDoc,\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.mjs","names":[],"sources":["../../../src/getIntlayerAPI/search.ts"],"sourcesContent":["import type {\n SearchDocUtilParams,\n SearchDocUtilResult,\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 getSearchAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const AI_API_ROUTE = `${backendURL}/api/search`;\n\n /**\n * Search documentation\n * @param params - Search parameters containing the input query.\n * @returns Search results with GitHub URLs.\n */\n const searchDoc = async (\n params?: SearchDocUtilParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SearchDocUtilResult>(\n `${AI_API_ROUTE}/doc`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n params: params,\n }\n );\n\n return {\n searchDoc,\n };\n};\n\n/**\n * Authenticated `search` 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 searchEndpoint = createEndpoint(getSearchAPI);\n"],"mappings":";;;;;AASA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,eAAe,GAFF,gBAAgB,QAAQ,cAAc,OAAO,WAE7B;;;;;;CAOnC,MAAM,YAAY,OAChB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,aAAa,OAChB,gBACA,cACA;EACE,QAAQ;EACA;EACT,CACF;AAEH,QAAO,EACL,WACD;;;;;;;;AASH,MAAa,iBAAiB,eAAe,aAAa"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetcher } from "../fetcher.mjs";
|
|
2
|
+
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
3
|
import { editor } from "@intlayer/config/built";
|
|
3
4
|
|
|
4
5
|
//#region src/getIntlayerAPI/showcaseProject.ts
|
|
@@ -53,7 +54,14 @@ const getShowcaseProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
53
54
|
updateShowcaseProject
|
|
54
55
|
};
|
|
55
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Authenticated `showcaseProject` endpoint bound to an Intlayer CMS authenticator.
|
|
59
|
+
*
|
|
60
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
61
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
62
|
+
*/
|
|
63
|
+
const showcaseProjectEndpoint = createEndpoint(getShowcaseProjectAPI);
|
|
56
64
|
|
|
57
65
|
//#endregion
|
|
58
|
-
export { getShowcaseProjectAPI };
|
|
66
|
+
export { getShowcaseProjectAPI, showcaseProjectEndpoint };
|
|
59
67
|
//# sourceMappingURL=showcaseProject.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"showcaseProject.mjs","names":[],"sources":["../../../src/getIntlayerAPI/showcaseProject.ts"],"sourcesContent":["import type {\n GetOtherShowcaseProjectsResult,\n GetShowcaseProjectByIdParams,\n GetShowcaseProjectByIdResult,\n GetShowcaseProjectsResult,\n SubmitShowcaseProjectBody,\n SubmitShowcaseProjectResult,\n ToggleShowcaseDownvoteBody,\n ToggleShowcaseDownvoteResult,\n ToggleShowcaseUpvoteBody,\n ToggleShowcaseUpvoteResult,\n UpdateShowcaseProjectBody,\n UpdateShowcaseProjectResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\n// Client-side query types use proper JS types (numbers/booleans) rather than\n// the backend querystring types which are always strings.\nexport type ShowcaseProjectsQuery = {\n page?: number;\n pageSize?: number;\n search?: string;\n selectedUseCases?: string[];\n isOpenSource?: boolean;\n};\n\nexport type OtherShowcaseProjectsQuery = {\n excludeId: string;\n limit?: number;\n};\n\nexport const getShowcaseProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const SHOWCASE_API_ROUTE = `${backendURL}/api/showcase-project`;\n\n const getShowcaseProjects = async (\n query?: ShowcaseProjectsQuery,\n otherOptions: FetcherOptions = {}\n ) => {\n const params: Record<string, string | string[]> = {};\n if (query?.page !== undefined) params.page = String(query.page);\n if (query?.pageSize !== undefined) params.pageSize = String(query.pageSize);\n if (query?.search !== undefined) params.search = query.search;\n if (query?.isOpenSource !== undefined)\n params.isOpenSource = String(query.isOpenSource);\n if (query?.selectedUseCases?.length)\n params.selectedUseCases = query.selectedUseCases;\n\n return await fetcher<GetShowcaseProjectsResult>(\n SHOWCASE_API_ROUTE,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as any }\n );\n };\n\n const getShowcaseProjectById = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetShowcaseProjectByIdResult>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const getOtherShowcaseProjects = async (\n query: OtherShowcaseProjectsQuery,\n otherOptions: FetcherOptions = {}\n ) => {\n const params: Record<string, string> = { excludeId: query.excludeId };\n if (query.limit !== undefined) params.limit = String(query.limit);\n return await fetcher<GetOtherShowcaseProjectsResult>(\n `${SHOWCASE_API_ROUTE}/others`,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as any }\n );\n };\n\n const submitShowcaseProject = async (\n body: SubmitShowcaseProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SubmitShowcaseProjectResult>(\n `${SHOWCASE_API_ROUTE}/submit`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const toggleShowcaseUpvote = async (\n body: ToggleShowcaseUpvoteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ToggleShowcaseUpvoteResult>(\n `${SHOWCASE_API_ROUTE}/upvote`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const toggleShowcaseDownvote = async (\n body: ToggleShowcaseDownvoteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ToggleShowcaseDownvoteResult>(\n `${SHOWCASE_API_ROUTE}/downvote`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const deleteShowcaseProject = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ data: { success: boolean } }>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n const updateShowcaseProject = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n body: UpdateShowcaseProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateShowcaseProjectResult>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'PATCH', body }\n );\n\n return {\n getShowcaseProjects,\n getShowcaseProjectById,\n getOtherShowcaseProjects,\n submitShowcaseProject,\n toggleShowcaseUpvote,\n toggleShowcaseDownvote,\n deleteShowcaseProject,\n updateShowcaseProject,\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"showcaseProject.mjs","names":[],"sources":["../../../src/getIntlayerAPI/showcaseProject.ts"],"sourcesContent":["import type {\n GetOtherShowcaseProjectsResult,\n GetShowcaseProjectByIdParams,\n GetShowcaseProjectByIdResult,\n GetShowcaseProjectsResult,\n SubmitShowcaseProjectBody,\n SubmitShowcaseProjectResult,\n ToggleShowcaseDownvoteBody,\n ToggleShowcaseDownvoteResult,\n ToggleShowcaseUpvoteBody,\n ToggleShowcaseUpvoteResult,\n UpdateShowcaseProjectBody,\n UpdateShowcaseProjectResult,\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\n// Client-side query types use proper JS types (numbers/booleans) rather than\n// the backend querystring types which are always strings.\nexport type ShowcaseProjectsQuery = {\n page?: number;\n pageSize?: number;\n search?: string;\n selectedUseCases?: string[];\n isOpenSource?: boolean;\n};\n\nexport type OtherShowcaseProjectsQuery = {\n excludeId: string;\n limit?: number;\n};\n\nexport const getShowcaseProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const SHOWCASE_API_ROUTE = `${backendURL}/api/showcase-project`;\n\n const getShowcaseProjects = async (\n query?: ShowcaseProjectsQuery,\n otherOptions: FetcherOptions = {}\n ) => {\n const params: Record<string, string | string[]> = {};\n if (query?.page !== undefined) params.page = String(query.page);\n if (query?.pageSize !== undefined) params.pageSize = String(query.pageSize);\n if (query?.search !== undefined) params.search = query.search;\n if (query?.isOpenSource !== undefined)\n params.isOpenSource = String(query.isOpenSource);\n if (query?.selectedUseCases?.length)\n params.selectedUseCases = query.selectedUseCases;\n\n return await fetcher<GetShowcaseProjectsResult>(\n SHOWCASE_API_ROUTE,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as any }\n );\n };\n\n const getShowcaseProjectById = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetShowcaseProjectByIdResult>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const getOtherShowcaseProjects = async (\n query: OtherShowcaseProjectsQuery,\n otherOptions: FetcherOptions = {}\n ) => {\n const params: Record<string, string> = { excludeId: query.excludeId };\n if (query.limit !== undefined) params.limit = String(query.limit);\n return await fetcher<GetOtherShowcaseProjectsResult>(\n `${SHOWCASE_API_ROUTE}/others`,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as any }\n );\n };\n\n const submitShowcaseProject = async (\n body: SubmitShowcaseProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SubmitShowcaseProjectResult>(\n `${SHOWCASE_API_ROUTE}/submit`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const toggleShowcaseUpvote = async (\n body: ToggleShowcaseUpvoteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ToggleShowcaseUpvoteResult>(\n `${SHOWCASE_API_ROUTE}/upvote`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const toggleShowcaseDownvote = async (\n body: ToggleShowcaseDownvoteBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ToggleShowcaseDownvoteResult>(\n `${SHOWCASE_API_ROUTE}/downvote`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const deleteShowcaseProject = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<{ data: { success: boolean } }>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n const updateShowcaseProject = async (\n projectId: GetShowcaseProjectByIdParams['projectId'],\n body: UpdateShowcaseProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateShowcaseProjectResult>(\n `${SHOWCASE_API_ROUTE}/${projectId}`,\n authAPIOptions,\n otherOptions,\n { method: 'PATCH', body }\n );\n\n return {\n getShowcaseProjects,\n getShowcaseProjectById,\n getOtherShowcaseProjects,\n submitShowcaseProject,\n toggleShowcaseUpvote,\n toggleShowcaseDownvote,\n deleteShowcaseProject,\n updateShowcaseProject,\n };\n};\n\n/**\n * Authenticated `showcaseProject` 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 showcaseProjectEndpoint = createEndpoint(getShowcaseProjectAPI);\n"],"mappings":";;;;;AAkCA,MAAa,yBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,qBAAqB,GAFR,gBAAgB,QAAQ,cAAc,OAAO,WAEvB;CAEzC,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAC9B;EACH,MAAM,SAA4C,EAAE;AACpD,MAAI,OAAO,SAAS,OAAW,QAAO,OAAO,OAAO,MAAM,KAAK;AAC/D,MAAI,OAAO,aAAa,OAAW,QAAO,WAAW,OAAO,MAAM,SAAS;AAC3E,MAAI,OAAO,WAAW,OAAW,QAAO,SAAS,MAAM;AACvD,MAAI,OAAO,iBAAiB,OAC1B,QAAO,eAAe,OAAO,MAAM,aAAa;AAClD,MAAI,OAAO,kBAAkB,OAC3B,QAAO,mBAAmB,MAAM;AAElC,SAAO,MAAM,QACX,oBACA,gBACA,cACA;GAAE,QAAQ;GAAe;GAAe,CACzC;;CAGH,MAAM,yBAAyB,OAC7B,WACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,mBAAmB,GAAG,aACzB,gBACA,cACA,EAAE,QAAQ,OAAO,CAClB;CAEH,MAAM,2BAA2B,OAC/B,OACA,eAA+B,EAAE,KAC9B;EACH,MAAM,SAAiC,EAAE,WAAW,MAAM,WAAW;AACrE,MA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