@intlayer/api 6.1.6 → 7.0.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +18 -55
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +20 -58
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
- package/dist/cjs/distantDictionary/index.cjs +5 -25
- package/dist/cjs/fetcher.cjs +113 -89
- package/dist/cjs/fetcher.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/ai.cjs +163 -188
- package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/dictionary.cjs +69 -117
- package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/editor.cjs +37 -74
- package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/index.cjs +27 -49
- package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/newsletter.cjs +40 -77
- package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/oAuth.cjs +26 -65
- package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/organization.cjs +93 -130
- package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/project.cjs +109 -154
- package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/search.cjs +22 -58
- package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/stripe.cjs +38 -77
- package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/tag.cjs +47 -86
- package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/user.cjs +79 -106
- package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
- package/dist/cjs/index.cjs +30 -49
- package/dist/cjs/proxy.cjs +90 -115
- package/dist/cjs/proxy.cjs.map +1 -1
- package/dist/cjs/types.cjs +0 -17
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +17 -20
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +19 -23
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
- package/dist/esm/distantDictionary/index.mjs +4 -3
- package/dist/esm/fetcher.mjs +111 -64
- package/dist/esm/fetcher.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/ai.mjs +160 -153
- package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/dictionary.mjs +66 -82
- package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/editor.mjs +34 -39
- package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/index.mjs +16 -14
- package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/newsletter.mjs +37 -42
- package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/oAuth.mjs +23 -30
- package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/organization.mjs +90 -95
- package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/project.mjs +106 -119
- package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/search.mjs +19 -23
- package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/stripe.mjs +35 -42
- package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/tag.mjs +44 -51
- package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/user.mjs +76 -71
- package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
- package/dist/esm/index.mjs +16 -15
- package/dist/esm/proxy.mjs +89 -90
- package/dist/esm/proxy.mjs.map +1 -1
- package/dist/esm/types.mjs +0 -1
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +8 -3
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +8 -3
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
- package/dist/types/distantDictionary/index.d.ts +3 -3
- package/dist/types/fetcher.d.ts +14 -11
- package/dist/types/fetcher.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/ai.d.ts +22 -18
- package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/dictionary.d.ts +16 -12
- package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/editor.d.ts +11 -7
- package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/index.d.ts +30 -27
- package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/newsletter.d.ts +11 -7
- package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/oAuth.d.ts +8 -5
- package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/organization.d.ts +18 -13
- package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/project.d.ts +19 -15
- package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/search.d.ts +9 -5
- package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/stripe.d.ts +11 -7
- package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/tag.d.ts +12 -8
- package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/user.d.ts +16 -12
- package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
- package/dist/types/index.d.ts +16 -15
- package/dist/types/proxy.d.ts +10 -5
- package/dist/types/proxy.d.ts.map +1 -1
- package/dist/types/types.d.ts +13 -12
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +29 -38
- package/LICENSE +0 -202
- package/dist/cjs/distantDictionary/index.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/types.cjs.map +0 -1
- package/dist/esm/distantDictionary/index.mjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/types/distantDictionary/index.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
|
@@ -1,77 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var editor_exports = {};
|
|
30
|
-
__export(editor_exports, {
|
|
31
|
-
getEditorAPI: () => getEditorAPI
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(editor_exports);
|
|
34
|
-
var import_built = __toESM(require("@intlayer/config/built"));
|
|
35
|
-
var import_fetcher = require('../fetcher.cjs');
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_fetcher = require('../fetcher.cjs');
|
|
3
|
+
let __intlayer_config_built = require("@intlayer/config/built");
|
|
4
|
+
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
|
|
5
|
+
|
|
6
|
+
//#region src/getIntlayerAPI/editor.ts
|
|
36
7
|
const getEditorAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
return {
|
|
68
|
-
getDictionaries,
|
|
69
|
-
getConfiguration,
|
|
70
|
-
writeDictionary
|
|
71
|
-
};
|
|
8
|
+
const editorURL = intlayerConfig?.editor?.editorURL ?? __intlayer_config_built.default?.editor?.editorURL;
|
|
9
|
+
if (!editorURL) throw new Error("Editor URL is not defined in the Intlayer configuration.");
|
|
10
|
+
const EDITOR_API_ROUTE = `${editorURL}/api`;
|
|
11
|
+
/**
|
|
12
|
+
* Get the Intlayer configuration
|
|
13
|
+
*/
|
|
14
|
+
const getConfiguration = async (otherOptions = {}) => {
|
|
15
|
+
return (await require_fetcher.fetcher(`${EDITOR_API_ROUTE}/config`, authAPIOptions, otherOptions)).data;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Get the Intlayer configuration
|
|
19
|
+
*/
|
|
20
|
+
const getDictionaries = async (otherOptions = {}) => {
|
|
21
|
+
return (await require_fetcher.fetcher(`${EDITOR_API_ROUTE}/dictionary`, authAPIOptions, otherOptions)).data;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Adds a new dictionary to the database.
|
|
25
|
+
* @param dictionary - Dictionary data.
|
|
26
|
+
*/
|
|
27
|
+
const writeDictionary = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${EDITOR_API_ROUTE}/dictionary`, authAPIOptions, otherOptions, {
|
|
28
|
+
method: "POST",
|
|
29
|
+
body
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
getDictionaries,
|
|
33
|
+
getConfiguration,
|
|
34
|
+
writeDictionary
|
|
35
|
+
};
|
|
72
36
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.getEditorAPI = getEditorAPI;
|
|
77
40
|
//# sourceMappingURL=editor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/
|
|
1
|
+
{"version":3,"file":"editor.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/editor.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n GetConfigurationResult,\n GetEditorDictionariesResult,\n WriteContentDeclarationBody,\n WriteContentDeclarationResult,\n} from '../types';\n\nexport const getEditorAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const editorURL =\n intlayerConfig?.editor?.editorURL ?? configuration?.editor?.editorURL;\n\n if (!editorURL) {\n throw new Error('Editor URL is not defined in the Intlayer configuration.');\n }\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":";;;;;;AAUA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,YACJ,gBAAgB,QAAQ,aAAaA,iCAAe,QAAQ;AAE9D,KAAI,CAAC,UACH,OAAM,IAAI,MAAM,2DAA2D;CAG7E,MAAM,mBAAmB,GAAG,UAAU;;;;CAKtC,MAAM,mBAAmB,OACvB,eAA+B,EAAE,KACG;AAOpC,UANiB,MAAMC,wBACrB,GAAG,iBAAiB,UACpB,gBACA,aACD,EAEe;;;;;CAMlB,MAAM,kBAAkB,OACtB,eAA+B,EAAE,KACQ;AAOzC,UANiB,MAAMA,wBACrB,GAAG,iBAAiB,cACpB,gBACA,aACD,EAEe;;;;;;CAOlB,MAAM,kBAAkB,OACtB,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,cACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD"}
|
|
@@ -1,52 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var getIntlayerAPI_exports = {};
|
|
20
|
-
__export(getIntlayerAPI_exports, {
|
|
21
|
-
getIntlayerAPI: () => getIntlayerAPI
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(getIntlayerAPI_exports);
|
|
24
|
-
var import_ai = require('./ai.cjs');
|
|
25
|
-
var import_dictionary = require('./dictionary.cjs');
|
|
26
|
-
var import_editor = require('./editor.cjs');
|
|
27
|
-
var import_newsletter = require('./newsletter.cjs');
|
|
28
|
-
var import_oAuth = require('./oAuth.cjs');
|
|
29
|
-
var import_organization = require('./organization.cjs');
|
|
30
|
-
var import_project = require('./project.cjs');
|
|
31
|
-
var import_search = require('./search.cjs');
|
|
32
|
-
var import_stripe = require('./stripe.cjs');
|
|
33
|
-
var import_tag = require('./tag.cjs');
|
|
34
|
-
var import_user = require('./user.cjs');
|
|
1
|
+
const require_getIntlayerAPI_ai = require('./ai.cjs');
|
|
2
|
+
const require_getIntlayerAPI_dictionary = require('./dictionary.cjs');
|
|
3
|
+
const require_getIntlayerAPI_editor = require('./editor.cjs');
|
|
4
|
+
const require_getIntlayerAPI_newsletter = require('./newsletter.cjs');
|
|
5
|
+
const require_getIntlayerAPI_oAuth = require('./oAuth.cjs');
|
|
6
|
+
const require_getIntlayerAPI_organization = require('./organization.cjs');
|
|
7
|
+
const require_getIntlayerAPI_project = require('./project.cjs');
|
|
8
|
+
const require_getIntlayerAPI_search = require('./search.cjs');
|
|
9
|
+
const require_getIntlayerAPI_stripe = require('./stripe.cjs');
|
|
10
|
+
const require_getIntlayerAPI_tag = require('./tag.cjs');
|
|
11
|
+
const require_getIntlayerAPI_user = require('./user.cjs');
|
|
12
|
+
|
|
13
|
+
//#region src/getIntlayerAPI/index.ts
|
|
35
14
|
const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => ({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
getIntlayerAPI
|
|
15
|
+
organization: require_getIntlayerAPI_organization.getOrganizationAPI(authAPIOptions, intlayerConfig),
|
|
16
|
+
project: require_getIntlayerAPI_project.getProjectAPI(authAPIOptions, intlayerConfig),
|
|
17
|
+
user: require_getIntlayerAPI_user.getUserAPI(authAPIOptions, intlayerConfig),
|
|
18
|
+
oAuth: require_getIntlayerAPI_oAuth.getOAuthAPI(intlayerConfig),
|
|
19
|
+
dictionary: require_getIntlayerAPI_dictionary.getDictionaryAPI(authAPIOptions, intlayerConfig),
|
|
20
|
+
stripe: require_getIntlayerAPI_stripe.getStripeAPI(authAPIOptions, intlayerConfig),
|
|
21
|
+
ai: require_getIntlayerAPI_ai.getAiAPI(authAPIOptions, intlayerConfig),
|
|
22
|
+
tag: require_getIntlayerAPI_tag.getTagAPI(authAPIOptions, intlayerConfig),
|
|
23
|
+
search: require_getIntlayerAPI_search.getSearchAPI(authAPIOptions, intlayerConfig),
|
|
24
|
+
editor: require_getIntlayerAPI_editor.getEditorAPI(authAPIOptions, intlayerConfig),
|
|
25
|
+
newsletter: require_getIntlayerAPI_newsletter.getNewsletterAPI(authAPIOptions, intlayerConfig)
|
|
51
26
|
});
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.getIntlayerAPI = getIntlayerAPI;
|
|
52
30
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["getOrganizationAPI","getProjectAPI","getUserAPI","getOAuthAPI","getDictionaryAPI","getStripeAPI","getAiAPI","getTagAPI","getSearchAPI","getEditorAPI","getNewsletterAPI"],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getSearchAPI } from './search';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPIReturn => ({\n organization: getOrganizationAPI(authAPIOptions, intlayerConfig),\n project: getProjectAPI(authAPIOptions, intlayerConfig),\n user: getUserAPI(authAPIOptions, intlayerConfig),\n oAuth: getOAuthAPI(intlayerConfig),\n dictionary: getDictionaryAPI(authAPIOptions, intlayerConfig),\n stripe: getStripeAPI(authAPIOptions, intlayerConfig),\n ai: getAiAPI(authAPIOptions, intlayerConfig),\n tag: getTagAPI(authAPIOptions, intlayerConfig),\n search: getSearchAPI(authAPIOptions, intlayerConfig),\n editor: getEditorAPI(authAPIOptions, intlayerConfig),\n newsletter: getNewsletterAPI(authAPIOptions, intlayerConfig),\n});\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAa,kBACX,iBAAiC,EAAE,EACnC,oBACuB;CACvB,cAAcA,uDAAmB,gBAAgB,eAAe;CAChE,SAASC,6CAAc,gBAAgB,eAAe;CACtD,MAAMC,uCAAW,gBAAgB,eAAe;CAChD,OAAOC,yCAAY,eAAe;CAClC,YAAYC,mDAAiB,gBAAgB,eAAe;CAC5D,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,IAAIC,mCAAS,gBAAgB,eAAe;CAC5C,KAAKC,qCAAU,gBAAgB,eAAe;CAC9C,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,YAAYC,mDAAiB,gBAAgB,eAAe;CAC7D"}
|
|
@@ -1,80 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var newsletter_exports = {};
|
|
30
|
-
__export(newsletter_exports, {
|
|
31
|
-
getNewsletterAPI: () => getNewsletterAPI
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(newsletter_exports);
|
|
34
|
-
var import_built = __toESM(require("@intlayer/config/built"));
|
|
35
|
-
var import_fetcher = require('../fetcher.cjs');
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_fetcher = require('../fetcher.cjs');
|
|
3
|
+
let __intlayer_config_built = require("@intlayer/config/built");
|
|
4
|
+
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
|
|
5
|
+
|
|
6
|
+
//#region src/getIntlayerAPI/newsletter.ts
|
|
36
7
|
const getNewsletterAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
return {
|
|
71
|
-
subscribeToNewsletter,
|
|
72
|
-
unsubscribeFromNewsletter,
|
|
73
|
-
getNewsletterStatus
|
|
74
|
-
};
|
|
8
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? __intlayer_config_built.default?.editor?.backendURL;
|
|
9
|
+
if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
|
|
10
|
+
const NEWSLETTER_API_ROUTE = `${backendURL}/api/newsletter`;
|
|
11
|
+
/**
|
|
12
|
+
* Subscribe a user to newsletter(s)
|
|
13
|
+
* @param body - Newsletter subscription parameters.
|
|
14
|
+
* @returns Newsletter subscription result.
|
|
15
|
+
*/
|
|
16
|
+
const subscribeToNewsletter = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${NEWSLETTER_API_ROUTE}/subscribe`, authAPIOptions, otherOptions, {
|
|
17
|
+
method: "POST",
|
|
18
|
+
body
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Unsubscribe a user from newsletter(s)
|
|
22
|
+
* @param body - Newsletter unsubscription parameters.
|
|
23
|
+
* @returns Newsletter unsubscription result.
|
|
24
|
+
*/
|
|
25
|
+
const unsubscribeFromNewsletter = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${NEWSLETTER_API_ROUTE}/unsubscribe`, authAPIOptions, otherOptions, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
body
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Get newsletter subscription status for the authenticated user
|
|
31
|
+
* @returns Newsletter subscription status.
|
|
32
|
+
*/
|
|
33
|
+
const getNewsletterStatus = async (otherOptions = {}) => await require_fetcher.fetcher(`${NEWSLETTER_API_ROUTE}/status`, authAPIOptions, otherOptions, { method: "GET" });
|
|
34
|
+
return {
|
|
35
|
+
subscribeToNewsletter,
|
|
36
|
+
unsubscribeFromNewsletter,
|
|
37
|
+
getNewsletterStatus
|
|
38
|
+
};
|
|
75
39
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.getNewsletterAPI = getNewsletterAPI;
|
|
80
43
|
//# sourceMappingURL=newsletter.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/getIntlayerAPI/newsletter.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/
|
|
1
|
+
{"version":3,"file":"newsletter.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/newsletter.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n NewsletterSubscriptionBody,\n NewsletterSubscriptionResult,\n NewsletterUnsubscriptionBody,\n} from '../types';\n\nexport const getNewsletterAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\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":";;;;;;AASA,MAAa,oBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,iCAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,uBAAuB,GAAG,WAAW;;;;;;CAO3C,MAAM,wBAAwB,OAC5B,MACA,eAA+B,EAAE,KAEjC,MAAMC,wBACJ,GAAG,qBAAqB,aACxB,gBACA,cACA;EACE,QAAQ;EACF;EACP,CACF;;;;;;CAOH,MAAM,4BAA4B,OAChC,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,qBAAqB,eACxB,gBACA,cACA;EACE,QAAQ;EACF;EACP,CACF;;;;;CAMH,MAAM,sBAAsB,OAAO,eAA+B,EAAE,KAClE,MAAMA,wBACJ,GAAG,qBAAqB,UACxB,gBACA,cACA,EACE,QAAQ,OACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD"}
|
|
@@ -1,68 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var oAuth_exports = {};
|
|
30
|
-
__export(oAuth_exports, {
|
|
31
|
-
getOAuthAPI: () => getOAuthAPI
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(oAuth_exports);
|
|
34
|
-
var import_built = __toESM(require("@intlayer/config/built"));
|
|
35
|
-
var import_fetcher = require('../fetcher.cjs');
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_fetcher = require('../fetcher.cjs');
|
|
3
|
+
let __intlayer_config_built = require("@intlayer/config/built");
|
|
4
|
+
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
|
|
5
|
+
|
|
6
|
+
//#region src/getIntlayerAPI/oAuth.ts
|
|
36
7
|
const getOAuthAPI = (intlayerConfig) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
grant_type: "client_credentials",
|
|
55
|
-
client_id: clientId,
|
|
56
|
-
client_secret: clientSecret
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
return {
|
|
61
|
-
getOAuth2AccessToken
|
|
62
|
-
};
|
|
8
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? __intlayer_config_built.default?.editor?.backendURL;
|
|
9
|
+
const { clientId, clientSecret } = intlayerConfig?.editor ?? {};
|
|
10
|
+
if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
|
|
11
|
+
/**
|
|
12
|
+
* Gets an oAuth2 accessToken
|
|
13
|
+
* @return The token information
|
|
14
|
+
*/
|
|
15
|
+
const getOAuth2AccessToken = async (otherOptions = {}) => await require_fetcher.fetcher(`${backendURL}/oauth2/token`, {}, otherOptions, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
18
|
+
body: {
|
|
19
|
+
grant_type: "client_credentials",
|
|
20
|
+
client_id: clientId,
|
|
21
|
+
client_secret: clientSecret
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return { getOAuth2AccessToken };
|
|
63
25
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.getOAuthAPI = getOAuthAPI;
|
|
68
29
|
//# sourceMappingURL=oAuth.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/getIntlayerAPI/oAuth.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/
|
|
1
|
+
{"version":3,"file":"oAuth.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/oAuth.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type { GetOAuth2TokenBody, GetOAuth2TokenResult } from '../types';\n\nexport const getOAuthAPI = (intlayerConfig?: IntlayerConfig) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n const { clientId, clientSecret } = intlayerConfig?.editor ?? {};\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n /**\n * Gets an oAuth2 accessToken\n * @return The token information\n */\n const getOAuth2AccessToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetOAuth2TokenResult>(\n `${backendURL}/oauth2/token`,\n {},\n otherOptions,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: {\n grant_type: 'client_credentials',\n client_id: clientId!,\n client_secret: clientSecret!,\n } satisfies GetOAuth2TokenBody,\n }\n );\n\n return {\n getOAuth2AccessToken,\n };\n};\n"],"mappings":";;;;;;AAKA,MAAa,eAAe,mBAAoC;CAC9D,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,iCAAe,QAAQ;CAC/D,MAAM,EAAE,UAAU,iBAAiB,gBAAgB,UAAU,EAAE;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;;;;;CAOH,MAAM,uBAAuB,OAAO,eAA+B,EAAE,KACnE,MAAMC,wBACJ,GAAG,WAAW,gBACd,EAAE,EACF,cACA;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,qCACjB;EACD,MAAM;GACJ,YAAY;GACZ,WAAW;GACX,eAAe;GAChB;EACF,CACF;AAEH,QAAO,EACL,sBACD"}
|