@intlayer/api 9.6.0 → 9.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cms/createAuthManager.cjs +2 -3
- package/dist/cjs/cms/createIntlayerCMS.cjs +2 -3
- package/dist/cjs/cms/index.cjs +2 -2
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +3 -4
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +3 -4
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
- package/dist/cjs/distantDictionary/index.cjs +2 -2
- package/dist/cjs/fetcher.cjs +2 -3
- package/dist/cjs/fetcher.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/ai.cjs +79 -26
- package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/analytics.cjs +47 -14
- package/dist/cjs/getIntlayerAPI/analytics.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/asset.cjs +41 -12
- package/dist/cjs/getIntlayerAPI/asset.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/audit.cjs +73 -20
- package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/bitbucket.cjs +42 -13
- package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/codeberg.cjs +20 -0
- package/dist/cjs/getIntlayerAPI/codeberg.cjs.map +1 -0
- package/dist/cjs/getIntlayerAPI/dictionary.cjs +62 -17
- package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/editor.cjs +3 -4
- package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/environment.cjs +47 -14
- package/dist/cjs/getIntlayerAPI/environment.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/forge.cjs +63 -0
- package/dist/cjs/getIntlayerAPI/forge.cjs.map +1 -0
- package/dist/cjs/getIntlayerAPI/gitee.cjs +20 -0
- package/dist/cjs/getIntlayerAPI/gitee.cjs.map +1 -0
- package/dist/cjs/getIntlayerAPI/github.cjs +47 -14
- package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/gitlab.cjs +42 -13
- package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/index.cjs +27 -24
- package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/newsletter.cjs +31 -10
- package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/oAuth.cjs +33 -8
- package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/organization.cjs +75 -24
- package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/project.cjs +115 -33
- package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/reviewer.cjs +145 -35
- package/dist/cjs/getIntlayerAPI/reviewer.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/search.cjs +18 -7
- package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/showcaseProject.cjs +64 -19
- package/dist/cjs/getIntlayerAPI/showcaseProject.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/status.cjs +19 -7
- package/dist/cjs/getIntlayerAPI/status.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/stripe.cjs +144 -39
- package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/tag.cjs +36 -11
- package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/translate.cjs +49 -12
- package/dist/cjs/getIntlayerAPI/translate.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/user.cjs +61 -18
- package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
- package/dist/cjs/index.cjs +38 -30
- package/dist/cjs/proxy.cjs +28 -25
- package/dist/cjs/proxy.cjs.map +1 -1
- package/dist/cjs/public/createPublicClient.cjs +26 -7
- package/dist/cjs/public/createPublicClient.cjs.map +1 -1
- package/dist/cjs/public/index.cjs +1 -1
- package/dist/cjs/resolveInternalBackendUrl.cjs +1 -2
- package/dist/esm/cms/createAuthManager.mjs +1 -2
- package/dist/esm/cms/createIntlayerCMS.mjs +1 -2
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +1 -2
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +1 -2
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
- package/dist/esm/fetcher.mjs +1 -2
- package/dist/esm/fetcher.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/ai.mjs +78 -25
- package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/analytics.mjs +46 -13
- package/dist/esm/getIntlayerAPI/analytics.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/asset.mjs +40 -11
- package/dist/esm/getIntlayerAPI/asset.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/audit.mjs +72 -19
- package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/bitbucket.mjs +41 -12
- package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/codeberg.mjs +18 -0
- package/dist/esm/getIntlayerAPI/codeberg.mjs.map +1 -0
- package/dist/esm/getIntlayerAPI/dictionary.mjs +61 -16
- package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/editor.mjs +2 -3
- package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/environment.mjs +46 -13
- package/dist/esm/getIntlayerAPI/environment.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/forge.mjs +62 -0
- package/dist/esm/getIntlayerAPI/forge.mjs.map +1 -0
- package/dist/esm/getIntlayerAPI/gitee.mjs +18 -0
- package/dist/esm/getIntlayerAPI/gitee.mjs.map +1 -0
- package/dist/esm/getIntlayerAPI/github.mjs +46 -13
- package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/gitlab.mjs +41 -12
- package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/index.mjs +6 -3
- package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/newsletter.mjs +30 -9
- package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/oAuth.mjs +32 -7
- package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/organization.mjs +74 -23
- package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/project.mjs +114 -32
- package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/reviewer.mjs +144 -34
- package/dist/esm/getIntlayerAPI/reviewer.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/search.mjs +17 -6
- package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/showcaseProject.mjs +63 -18
- package/dist/esm/getIntlayerAPI/showcaseProject.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/status.mjs +18 -6
- package/dist/esm/getIntlayerAPI/status.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/stripe.mjs +143 -38
- package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/tag.mjs +35 -10
- package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/translate.mjs +48 -11
- package/dist/esm/getIntlayerAPI/translate.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/user.mjs +60 -17
- package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
- package/dist/esm/index.mjs +10 -7
- package/dist/esm/proxy.mjs +6 -3
- package/dist/esm/proxy.mjs.map +1 -1
- package/dist/esm/public/createPublicClient.mjs +26 -7
- package/dist/esm/public/createPublicClient.mjs.map +1 -1
- package/dist/esm/resolveInternalBackendUrl.mjs +1 -2
- package/dist/types/cms/createAuthManager.d.ts +1 -2
- package/dist/types/cms/createAuthManager.d.ts.map +1 -1
- package/dist/types/cms/createIntlayerCMS.d.ts +0 -2
- package/dist/types/cms/createIntlayerCMS.d.ts.map +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +1 -3
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +1 -3
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
- package/dist/types/fetcher.d.ts +1 -3
- package/dist/types/fetcher.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/ai.d.ts +3 -5
- package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/analytics.d.ts +3 -5
- package/dist/types/getIntlayerAPI/analytics.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/asset.d.ts +3 -4
- package/dist/types/getIntlayerAPI/asset.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/audit.d.ts +49 -7
- package/dist/types/getIntlayerAPI/audit.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/bitbucket.d.ts +2 -4
- package/dist/types/getIntlayerAPI/bitbucket.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/codeberg.d.ts +59 -0
- package/dist/types/getIntlayerAPI/codeberg.d.ts.map +1 -0
- package/dist/types/getIntlayerAPI/dictionary.d.ts +3 -5
- package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/editor.d.ts +4 -5
- package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/environment.d.ts +3 -5
- package/dist/types/getIntlayerAPI/environment.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/forge.d.ts +34 -0
- package/dist/types/getIntlayerAPI/forge.d.ts.map +1 -0
- package/dist/types/getIntlayerAPI/gitee.d.ts +59 -0
- package/dist/types/getIntlayerAPI/gitee.d.ts.map +1 -0
- package/dist/types/getIntlayerAPI/github.d.ts +2 -4
- package/dist/types/getIntlayerAPI/github.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/gitlab.d.ts +2 -4
- package/dist/types/getIntlayerAPI/gitlab.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/index.d.ts +6 -3
- package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/newsletter.d.ts +3 -5
- package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/oAuth.d.ts +2 -2
- package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/organization.d.ts +3 -7
- package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/project.d.ts +4 -5
- package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/reviewer.d.ts +682 -39
- package/dist/types/getIntlayerAPI/reviewer.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/search.d.ts +3 -5
- package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/showcaseProject.d.ts +3 -5
- package/dist/types/getIntlayerAPI/showcaseProject.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/status.d.ts +5 -8
- package/dist/types/getIntlayerAPI/status.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/stripe.d.ts +3 -5
- package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/tag.d.ts +3 -5
- package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/translate.d.ts +3 -5
- package/dist/types/getIntlayerAPI/translate.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/user.d.ts +6 -8
- package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
- package/dist/types/index.d.ts +12 -9
- package/dist/types/proxy.d.ts +0 -2
- package/dist/types/proxy.d.ts.map +1 -1
- package/dist/types/public/createPublicClient.d.ts +1 -9
- package/dist/types/public/createPublicClient.d.ts.map +1 -1
- package/dist/types/resolveInternalBackendUrl.d.ts +0 -2
- package/dist/types/resolveInternalBackendUrl.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -2
- package/package.json +23 -6
|
@@ -1,16 +1,62 @@
|
|
|
1
|
-
import { fetcher } from "../fetcher.mjs";
|
|
2
1
|
import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
|
|
2
|
+
import { fetcher } from "../fetcher.mjs";
|
|
3
3
|
import { editor } from "@intlayer/config/built";
|
|
4
|
+
import { buildRouteURL } from "@intlayer/backend-contract/defineRoute";
|
|
5
|
+
import { BACKEND_URL } from "@intlayer/config/defaultValues";
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
// src/getIntlayerAPI/user.ts
|
|
8
|
+
/** Prefix of the routes, checked against the backend contract. */
|
|
9
|
+
const userGroup = { prefix: "/api/user" };
|
|
10
|
+
/**
|
|
11
|
+
* Method and path of every route, checked against the backend contract at
|
|
12
|
+
* compile time (the contract's zod schemas are never loaded).
|
|
13
|
+
*/
|
|
14
|
+
const userEndpoints = {
|
|
15
|
+
getSetupStatus: {
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: "/setup"
|
|
18
|
+
},
|
|
19
|
+
getUsers: {
|
|
20
|
+
method: "GET",
|
|
21
|
+
path: "/"
|
|
22
|
+
},
|
|
23
|
+
updateUser: {
|
|
24
|
+
method: "PUT",
|
|
25
|
+
path: "/"
|
|
26
|
+
},
|
|
27
|
+
createUser: {
|
|
28
|
+
method: "POST",
|
|
29
|
+
path: "/"
|
|
30
|
+
},
|
|
31
|
+
getUserById: {
|
|
32
|
+
method: "GET",
|
|
33
|
+
path: "/:userId"
|
|
34
|
+
},
|
|
35
|
+
getUserByEmail: {
|
|
36
|
+
method: "GET",
|
|
37
|
+
path: "/email/:email"
|
|
38
|
+
},
|
|
39
|
+
deleteUser: {
|
|
40
|
+
method: "DELETE",
|
|
41
|
+
path: "/:userId"
|
|
42
|
+
},
|
|
43
|
+
verifyEmailStatusSSE: {
|
|
44
|
+
method: "GET",
|
|
45
|
+
path: "/verify-email-status/:userId"
|
|
46
|
+
},
|
|
47
|
+
uploadAvatar: {
|
|
48
|
+
method: "POST",
|
|
49
|
+
path: "/avatar"
|
|
50
|
+
}
|
|
51
|
+
};
|
|
6
52
|
const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
7
|
-
const
|
|
53
|
+
const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;
|
|
8
54
|
/**
|
|
9
55
|
* Retrieves a list of users based on filters and pagination.
|
|
10
56
|
* @param filters - Filters and pagination options.
|
|
11
57
|
* @returns List of users.
|
|
12
58
|
*/
|
|
13
|
-
const getUsers = async (filters, otherOptions = {}) => await fetcher(
|
|
59
|
+
const getUsers = async (filters, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, userGroup, userEndpoints.getUsers), authAPIOptions, otherOptions, {
|
|
14
60
|
cache: "no-store",
|
|
15
61
|
params: filters
|
|
16
62
|
});
|
|
@@ -19,26 +65,25 @@ const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
19
65
|
* @param userId - User ID.
|
|
20
66
|
* @returns User object.
|
|
21
67
|
*/
|
|
22
|
-
const getUserById = async (userId, otherOptions = {}) => await fetcher(
|
|
68
|
+
const getUserById = async (userId, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, userGroup, userEndpoints.getUserById, { userId: String(userId) }), authAPIOptions, otherOptions, { cache: "no-store" });
|
|
23
69
|
/**
|
|
24
70
|
* Retrieves a user by email.
|
|
25
71
|
* @param email - User email.
|
|
26
72
|
* @returns User object.
|
|
27
73
|
*/
|
|
28
|
-
const getUserByEmail = async (email, otherOptions = {}) => await fetcher(
|
|
74
|
+
const getUserByEmail = async (email, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, userGroup, userEndpoints.getUserByEmail, { email }), authAPIOptions, otherOptions, { cache: "no-store" });
|
|
29
75
|
/**
|
|
30
76
|
* Retrieves a user by account.
|
|
31
77
|
* @param providerAccountId - The provider account ID.
|
|
32
78
|
* @param provider - The provider of the account.
|
|
33
79
|
*/
|
|
34
|
-
const getUserByAccount = async (providerAccountId, provider, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/account/${provider}/${providerAccountId}`, authAPIOptions, otherOptions, { cache: "no-store" });
|
|
35
80
|
/**
|
|
36
81
|
* Creates a new user.
|
|
37
82
|
* @param user - User credentials.
|
|
38
83
|
* @returns User object.
|
|
39
84
|
*/
|
|
40
|
-
const createUser = async (user, otherOptions = {}) => await fetcher(
|
|
41
|
-
method:
|
|
85
|
+
const createUser = async (user, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, userGroup, userEndpoints.createUser), authAPIOptions, otherOptions, {
|
|
86
|
+
method: userEndpoints.createUser.method,
|
|
42
87
|
body: user
|
|
43
88
|
});
|
|
44
89
|
/**
|
|
@@ -46,8 +91,8 @@ const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
46
91
|
* @param user - Updated user data.
|
|
47
92
|
* @returns User object.
|
|
48
93
|
*/
|
|
49
|
-
const updateUser = async (user, otherOptions = {}) => await fetcher(
|
|
50
|
-
method:
|
|
94
|
+
const updateUser = async (user, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, userGroup, userEndpoints.updateUser), authAPIOptions, otherOptions, {
|
|
95
|
+
method: userEndpoints.updateUser.method,
|
|
51
96
|
body: user
|
|
52
97
|
});
|
|
53
98
|
/**
|
|
@@ -55,7 +100,7 @@ const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
55
100
|
* @param userId - User ID.
|
|
56
101
|
* @returns User object.
|
|
57
102
|
*/
|
|
58
|
-
const deleteUser = async (userId, otherOptions = {}) => await fetcher(
|
|
103
|
+
const deleteUser = async (userId, otherOptions = {}) => await fetcher(buildRouteURL(backendURL, userGroup, userEndpoints.deleteUser, { userId: String(userId) }), authAPIOptions, otherOptions, { method: userEndpoints.deleteUser.method });
|
|
59
104
|
/**
|
|
60
105
|
* Uploads a new avatar for the authenticated user.
|
|
61
106
|
* @param file - The image File object to upload.
|
|
@@ -65,8 +110,8 @@ const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
65
110
|
const buffer = await file.arrayBuffer();
|
|
66
111
|
const baseHeaders = { "Content-Type": file.type || "image/jpeg" };
|
|
67
112
|
const authHeaders = authAPIOptions.headers ?? {};
|
|
68
|
-
const response = await fetch(
|
|
69
|
-
method:
|
|
113
|
+
const response = await fetch(buildRouteURL(backendURL, userGroup, userEndpoints.uploadAvatar), {
|
|
114
|
+
method: userEndpoints.uploadAvatar.method,
|
|
70
115
|
credentials: "include",
|
|
71
116
|
headers: {
|
|
72
117
|
...authHeaders,
|
|
@@ -86,12 +131,11 @@ const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
86
131
|
* @param userId - User ID.
|
|
87
132
|
* @returns The verify email status URL.
|
|
88
133
|
*/
|
|
89
|
-
const getVerifyEmailStatusURL = (userId) =>
|
|
134
|
+
const getVerifyEmailStatusURL = (userId) => buildRouteURL(backendURL, userGroup, userEndpoints.verifyEmailStatusSSE, { userId: String(userId) });
|
|
90
135
|
return {
|
|
91
136
|
createUser,
|
|
92
137
|
getUsers,
|
|
93
138
|
getUserById,
|
|
94
|
-
getUserByAccount,
|
|
95
139
|
getUserByEmail,
|
|
96
140
|
updateUser,
|
|
97
141
|
deleteUser,
|
|
@@ -107,6 +151,5 @@ const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
107
151
|
*/
|
|
108
152
|
const userEndpoint = createEndpoint(getUserAPI);
|
|
109
153
|
|
|
110
|
-
//#endregion
|
|
111
154
|
export { getUserAPI, userEndpoint };
|
|
112
155
|
//# sourceMappingURL=user.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.mjs","names":[],"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import type {\n CreateUserBody,\n CreateUserResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n
|
|
1
|
+
{"version":3,"file":"user.mjs","names":[],"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type { ResponseData } from '@intlayer/backend-contract/responseData';\nimport type {\n CreateUserBody,\n CreateUserResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n UpdateUserBody,\n UpdateUserResult,\n UploadUserAvatarResult,\n UserAPI,\n UserRoutes,\n userContract,\n} from '@intlayer/backend-contract/user';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type GetUserByAccountParams = {\n providerAccountId: string;\n provider: string;\n};\nexport type GetUserByAccountResult = ResponseData<UserAPI>;\n\n/** Prefix of the routes, checked against the backend contract. */\nconst userGroup = {\n prefix: '/api/user',\n} as const satisfies Pick<typeof userContract, 'prefix'>;\n\n/**\n * Method and path of every route, checked against the backend contract at\n * compile time (the contract's zod schemas are never loaded).\n */\nconst userEndpoints = {\n getSetupStatus: { method: 'GET', path: '/setup' },\n getUsers: { method: 'GET', path: '/' },\n updateUser: { method: 'PUT', path: '/' },\n createUser: { method: 'POST', path: '/' },\n getUserById: { method: 'GET', path: '/:userId' },\n getUserByEmail: { method: 'GET', path: '/email/:email' },\n deleteUser: { method: 'DELETE', path: '/:userId' },\n verifyEmailStatusSSE: { method: 'GET', path: '/verify-email-status/:userId' },\n uploadAvatar: { method: 'POST', path: '/avatar' },\n} as const satisfies RouteEndpoints<UserRoutes>;\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /**\n * Retrieves a list of users based on filters and pagination.\n * @param filters - Filters and pagination options.\n * @returns List of users.\n */\n const getUsers = async (\n filters?: GetUsersParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUsersResult>(\n buildRouteURL(backendURL, userGroup, userEndpoints.getUsers),\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 a user by ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const getUserById = async (\n userId: GetUserByIdParams['userId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByIdResult>(\n buildRouteURL(backendURL, userGroup, userEndpoints.getUserById, {\n userId: String(userId),\n }),\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by email.\n * @param email - User email.\n * @returns User object.\n */\n const getUserByEmail = async (\n email: GetUserByEmailParams['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByEmailResult>(\n buildRouteURL(backendURL, userGroup, userEndpoints.getUserByEmail, {\n email,\n }),\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by account.\n * @param providerAccountId - The provider account ID.\n * @param provider - The provider of the account.\n */\n /**\n * Creates a new user.\n * @param user - User credentials.\n * @returns User object.\n */\n const createUser = async (\n user: CreateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateUserResult>(\n buildRouteURL(backendURL, userGroup, userEndpoints.createUser),\n authAPIOptions,\n otherOptions,\n {\n method: userEndpoints.createUser.method,\n body: user,\n }\n );\n\n /**\n * Updates the user with the provided data.\n * @param user - Updated user data.\n * @returns User object.\n */\n const updateUser = async (\n user: UpdateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n buildRouteURL(backendURL, userGroup, userEndpoints.updateUser),\n authAPIOptions,\n otherOptions,\n {\n method: userEndpoints.updateUser.method,\n body: user,\n }\n );\n\n /**\n * Deletes a user with the provided ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const deleteUser = async (\n userId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n buildRouteURL(backendURL, userGroup, userEndpoints.deleteUser, {\n userId: String(userId),\n }),\n authAPIOptions,\n otherOptions,\n {\n method: userEndpoints.deleteUser.method,\n }\n );\n\n /**\n * Uploads a new avatar for the authenticated user.\n * @param file - The image File object to upload.\n * @returns Updated user object.\n */\n const uploadAvatar = async (\n file: File,\n otherOptions: FetcherOptions = {}\n ) => {\n const buffer = await file.arrayBuffer();\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': file.type || 'image/jpeg',\n };\n\n // Forward auth cookies / credentials from authAPIOptions headers\n const authHeaders =\n (authAPIOptions.headers as Record<string, string> | undefined) ?? {};\n\n const response = await fetch(\n buildRouteURL(backendURL, userGroup, userEndpoints.uploadAvatar),\n {\n method: userEndpoints.uploadAvatar.method,\n credentials: 'include',\n headers: { ...authHeaders, ...baseHeaders },\n body: buffer,\n signal: otherOptions.signal as AbortSignal | undefined,\n }\n );\n\n if (!response.ok) {\n const result = await response.json();\n throw new Error(JSON.stringify(result.error) ?? 'Avatar upload failed');\n }\n\n return (await response.json()) as UploadUserAvatarResult;\n };\n\n /**\n * Gets the verify email status URL to use in the SSE.\n * @param userId - User ID.\n * @returns The verify email status URL.\n */\n const getVerifyEmailStatusURL = (userId: string | UserAPI['id']) =>\n buildRouteURL(backendURL, userGroup, userEndpoints.verifyEmailStatusSSE, {\n userId: String(userId),\n });\n\n return {\n createUser,\n getUsers,\n getUserById,\n getUserByEmail,\n updateUser,\n deleteUser,\n uploadAvatar,\n getVerifyEmailStatusURL,\n };\n};\n\n/**\n * Authenticated `user` 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 userEndpoint = createEndpoint(getUserAPI);\n"],"mappings":";;;;;;;;AAgCA,MAAM,YAAY,EAChB,QAAQ,YACV;;;;;AAMA,MAAM,gBAAgB;CACpB,gBAAgB;EAAE,QAAQ;EAAO,MAAM;CAAS;CAChD,UAAU;EAAE,QAAQ;EAAO,MAAM;CAAI;CACrC,YAAY;EAAE,QAAQ;EAAO,MAAM;CAAI;CACvC,YAAY;EAAE,QAAQ;EAAQ,MAAM;CAAI;CACxC,aAAa;EAAE,QAAQ;EAAO,MAAM;CAAW;CAC/C,gBAAgB;EAAE,QAAQ;EAAO,MAAM;CAAgB;CACvD,YAAY;EAAE,QAAQ;EAAU,MAAM;CAAW;CACjD,sBAAsB;EAAE,QAAQ;EAAO,MAAM;CAA+B;CAC5E,cAAc;EAAE,QAAQ;EAAQ,MAAM;CAAU;AAClD;AAEA,MAAa,cACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,OAAO,cAAc;;;;;;CAO7D,MAAM,WAAW,OACf,SACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,WAAW,cAAc,QAAQ,GAC3D,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;;;CAOF,MAAM,cAAc,OAClB,QACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,WAAW,cAAc,aAAa,EAC9D,QAAQ,OAAO,MAAM,EACvB,CAAC,GACD,gBACA,cACA,EACE,OAAO,WACT,CACF;;;;;;CAOF,MAAM,iBAAiB,OACrB,OACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,WAAW,cAAc,gBAAgB,EACjE,MACF,CAAC,GACD,gBACA,cACA,EACE,OAAO,WACT,CACF;;;;;;;;;;;CAYF,MAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,WAAW,cAAc,UAAU,GAC7D,gBACA,cACA;EACE,QAAQ,cAAc,WAAW;EACjC,MAAM;CACR,CACF;;;;;;CAOF,MAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,WAAW,cAAc,UAAU,GAC7D,gBACA,cACA;EACE,QAAQ,cAAc,WAAW;EACjC,MAAM;CACR,CACF;;;;;;CAOF,MAAM,aAAa,OACjB,QACA,eAA+B,CAAC,MAEhC,MAAM,QACJ,cAAc,YAAY,WAAW,cAAc,YAAY,EAC7D,QAAQ,OAAO,MAAM,EACvB,CAAC,GACD,gBACA,cACA,EACE,QAAQ,cAAc,WAAW,OACnC,CACF;;;;;;CAOF,MAAM,eAAe,OACnB,MACA,eAA+B,CAAC,MAC7B;EACH,MAAM,SAAS,MAAM,KAAK,YAAY;EAEtC,MAAM,cAAsC,EAC1C,gBAAgB,KAAK,QAAQ,aAC/B;EAGA,MAAM,cACH,eAAe,WAAkD,CAAC;EAErE,MAAM,WAAW,MAAM,MACrB,cAAc,YAAY,WAAW,cAAc,YAAY,GAC/D;GACE,QAAQ,cAAc,aAAa;GACnC,aAAa;GACb,SAAS;IAAE,GAAG;IAAa,GAAG;GAAY;GAC1C,MAAM;GACN,QAAQ,aAAa;EACvB,CACF;EAEA,IAAI,CAAC,SAAS,IAAI;GAChB,MAAM,SAAS,MAAM,SAAS,KAAK;GACnC,MAAM,IAAI,MAAM,KAAK,UAAU,OAAO,KAAK,KAAK,sBAAsB;EACxE;EAEA,OAAQ,MAAM,SAAS,KAAK;CAC9B;;;;;;CAOA,MAAM,2BAA2B,WAC/B,cAAc,YAAY,WAAW,cAAc,sBAAsB,EACvE,QAAQ,OAAO,MAAM,EACvB,CAAC;CAEH,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,eAAe,eAAe,UAAU"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import { BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE, resolveInternalBackendUrl } from "./resolveInternalBackendUrl.mjs";
|
|
2
1
|
import { FetcherError, fetcher, fetcherOptions } from "./fetcher.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
|
|
3
|
+
import { aiEndpoint, getAiAPI } from "./getIntlayerAPI/ai.mjs";
|
|
4
4
|
import { clearAccessTokenCache, createAuthManager } from "./cms/createAuthManager.mjs";
|
|
5
5
|
import { createEndpoint, createIntlayerCMS } from "./cms/createIntlayerCMS.mjs";
|
|
6
|
-
import { aiEndpoint, getAiAPI } from "./getIntlayerAPI/ai.mjs";
|
|
7
6
|
import { analyticsEndpoint, getAnalyticsAPI } from "./getIntlayerAPI/analytics.mjs";
|
|
7
|
+
import { fetchDistantDictionaries } from "./distantDictionary/fetchDistantDictionaries.mjs";
|
|
8
|
+
import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.mjs";
|
|
8
9
|
import { assetEndpoint, getAssetAPI } from "./getIntlayerAPI/asset.mjs";
|
|
9
10
|
import { auditEndpoint, getAuditAPI } from "./getIntlayerAPI/audit.mjs";
|
|
10
11
|
import { bitbucketEndpoint, getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
|
|
12
|
+
import { codebergEndpoint, getCodebergAPI } from "./getIntlayerAPI/codeberg.mjs";
|
|
11
13
|
import { dictionaryEndpoint, getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
|
|
12
14
|
import { editorEndpoint, getEditorAPI } from "./getIntlayerAPI/editor.mjs";
|
|
13
15
|
import { environmentEndpoint, getEnvironmentAPI } from "./getIntlayerAPI/environment.mjs";
|
|
16
|
+
import { createForgeAPI } from "./getIntlayerAPI/forge.mjs";
|
|
17
|
+
import { getGiteeAPI, giteeEndpoint } from "./getIntlayerAPI/gitee.mjs";
|
|
14
18
|
import { getGithubAPI, githubEndpoint } from "./getIntlayerAPI/github.mjs";
|
|
15
19
|
import { getGitlabAPI, gitlabEndpoint } from "./getIntlayerAPI/gitlab.mjs";
|
|
16
20
|
import { getNewsletterAPI, newsletterEndpoint } from "./getIntlayerAPI/newsletter.mjs";
|
|
21
|
+
import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
|
|
17
22
|
import { getOrganizationAPI, organizationEndpoint } from "./getIntlayerAPI/organization.mjs";
|
|
18
23
|
import { getProjectAPI, projectEndpoint } from "./getIntlayerAPI/project.mjs";
|
|
19
24
|
import { getReviewerAPI, reviewerEndpoint } from "./getIntlayerAPI/reviewer.mjs";
|
|
@@ -25,8 +30,6 @@ import { getTagAPI, tagEndpoint } from "./getIntlayerAPI/tag.mjs";
|
|
|
25
30
|
import { getTranslateAPI, translateEndpoint } from "./getIntlayerAPI/translate.mjs";
|
|
26
31
|
import { getUserAPI, userEndpoint } from "./getIntlayerAPI/user.mjs";
|
|
27
32
|
import { getIntlayerAPIProxy } from "./proxy.mjs";
|
|
28
|
-
import {
|
|
29
|
-
import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.mjs";
|
|
30
|
-
import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
|
|
33
|
+
import { BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE, resolveInternalBackendUrl } from "./resolveInternalBackendUrl.mjs";
|
|
31
34
|
|
|
32
|
-
export { BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE, FetcherError, aiEndpoint, analyticsEndpoint, assetEndpoint, auditEndpoint, bitbucketEndpoint, clearAccessTokenCache, createAuthManager, createEndpoint, createIntlayerCMS, dictionaryEndpoint, editorEndpoint, environmentEndpoint, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAnalyticsAPI, getAssetAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getEnvironmentAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getReviewerAPI, getSearchAPI, getShowcaseProjectAPI, getStatusAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI, githubEndpoint, gitlabEndpoint, newsletterEndpoint, organizationEndpoint, projectEndpoint, resolveInternalBackendUrl, reviewerEndpoint, searchEndpoint, showcaseProjectEndpoint, statusEndpoint, stripeEndpoint, tagEndpoint, translateEndpoint, userEndpoint };
|
|
35
|
+
export { BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE, FetcherError, aiEndpoint, analyticsEndpoint, assetEndpoint, auditEndpoint, bitbucketEndpoint, clearAccessTokenCache, codebergEndpoint, createAuthManager, createEndpoint, createForgeAPI, createIntlayerCMS, dictionaryEndpoint, editorEndpoint, environmentEndpoint, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAnalyticsAPI, getAssetAPI, getAuditAPI, getBitbucketAPI, getCodebergAPI, getDictionaryAPI, getEditorAPI, getEnvironmentAPI, getGiteeAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getReviewerAPI, getSearchAPI, getShowcaseProjectAPI, getStatusAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI, giteeEndpoint, githubEndpoint, gitlabEndpoint, newsletterEndpoint, organizationEndpoint, projectEndpoint, resolveInternalBackendUrl, reviewerEndpoint, searchEndpoint, showcaseProjectEndpoint, statusEndpoint, stripeEndpoint, tagEndpoint, translateEndpoint, userEndpoint };
|
package/dist/esm/proxy.mjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
|
|
2
1
|
import { createIntlayerCMS } from "./cms/createIntlayerCMS.mjs";
|
|
3
2
|
import { getAiAPI } from "./getIntlayerAPI/ai.mjs";
|
|
4
3
|
import { getAnalyticsAPI } from "./getIntlayerAPI/analytics.mjs";
|
|
5
4
|
import { getAssetAPI } from "./getIntlayerAPI/asset.mjs";
|
|
6
5
|
import { getAuditAPI } from "./getIntlayerAPI/audit.mjs";
|
|
7
6
|
import { getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
|
|
7
|
+
import { getCodebergAPI } from "./getIntlayerAPI/codeberg.mjs";
|
|
8
8
|
import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
|
|
9
9
|
import { getEditorAPI } from "./getIntlayerAPI/editor.mjs";
|
|
10
10
|
import { getEnvironmentAPI } from "./getIntlayerAPI/environment.mjs";
|
|
11
|
+
import { getGiteeAPI } from "./getIntlayerAPI/gitee.mjs";
|
|
11
12
|
import { getGithubAPI } from "./getIntlayerAPI/github.mjs";
|
|
12
13
|
import { getGitlabAPI } from "./getIntlayerAPI/gitlab.mjs";
|
|
13
14
|
import { getNewsletterAPI } from "./getIntlayerAPI/newsletter.mjs";
|
|
15
|
+
import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
|
|
14
16
|
import { getOrganizationAPI } from "./getIntlayerAPI/organization.mjs";
|
|
15
17
|
import { getProjectAPI } from "./getIntlayerAPI/project.mjs";
|
|
16
18
|
import { getReviewerAPI } from "./getIntlayerAPI/reviewer.mjs";
|
|
@@ -23,7 +25,7 @@ import { getTranslateAPI } from "./getIntlayerAPI/translate.mjs";
|
|
|
23
25
|
import { getUserAPI } from "./getIntlayerAPI/user.mjs";
|
|
24
26
|
import { editor } from "@intlayer/config/built";
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
// src/proxy.ts
|
|
27
29
|
const sectionFactories = {
|
|
28
30
|
asset: getAssetAPI,
|
|
29
31
|
organization: getOrganizationAPI,
|
|
@@ -43,6 +45,8 @@ const sectionFactories = {
|
|
|
43
45
|
github: getGithubAPI,
|
|
44
46
|
gitlab: getGitlabAPI,
|
|
45
47
|
bitbucket: getBitbucketAPI,
|
|
48
|
+
codeberg: getCodebergAPI,
|
|
49
|
+
gitee: getGiteeAPI,
|
|
46
50
|
showcaseProject: getShowcaseProjectAPI,
|
|
47
51
|
translate: getTranslateAPI,
|
|
48
52
|
reviewer: getReviewerAPI,
|
|
@@ -91,6 +95,5 @@ const getIntlayerAPIProxy = (baseAuthOptions = {}, intlayerConfig = { editor },
|
|
|
91
95
|
});
|
|
92
96
|
};
|
|
93
97
|
|
|
94
|
-
//#endregion
|
|
95
98
|
export { getIntlayerAPIProxy };
|
|
96
99
|
//# sourceMappingURL=proxy.mjs.map
|
package/dist/esm/proxy.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.mjs","names":[],"sources":["../../src/proxy.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createIntlayerCMS, type IntlayerCMS } from './cms/createIntlayerCMS';\nimport type { FetcherOptions } from './fetcher';\nimport { getAiAPI } from './getIntlayerAPI/ai';\nimport { getAnalyticsAPI } from './getIntlayerAPI/analytics';\nimport { getAssetAPI } from './getIntlayerAPI/asset';\nimport { getAuditAPI } from './getIntlayerAPI/audit';\nimport { getBitbucketAPI } from './getIntlayerAPI/bitbucket';\nimport { getDictionaryAPI } from './getIntlayerAPI/dictionary';\nimport { getEditorAPI } from './getIntlayerAPI/editor';\nimport { getEnvironmentAPI } from './getIntlayerAPI/environment';\nimport { getGithubAPI } from './getIntlayerAPI/github';\nimport { getGitlabAPI } from './getIntlayerAPI/gitlab';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getNewsletterAPI } from './getIntlayerAPI/newsletter';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\nimport { getOrganizationAPI } from './getIntlayerAPI/organization';\nimport { getProjectAPI } from './getIntlayerAPI/project';\nimport { getReviewerAPI } from './getIntlayerAPI/reviewer';\nimport { getSearchAPI } from './getIntlayerAPI/search';\nimport { getShowcaseProjectAPI } from './getIntlayerAPI/showcaseProject';\nimport { getStatusAPI } from './getIntlayerAPI/status';\nimport { getStripeAPI } from './getIntlayerAPI/stripe';\nimport { getTagAPI } from './getIntlayerAPI/tag';\nimport { getTranslateAPI } from './getIntlayerAPI/translate';\nimport { getUserAPI } from './getIntlayerAPI/user';\n\ntype SectionKey = keyof IntlayerAPI;\n\n/**\n * Homogeneous factory map: every domain factory normalized to the same\n * `(fetcherOptions, config) => section` signature, keyed by section name.\n * Declaring it as a single mapped type lets a generic lookup stay callable\n * (a union of factory signatures would not be).\n */\ntype SectionFactories = {\n [Key in SectionKey]: (\n fetcherOptions: FetcherOptions,\n intlayerConfig: IntlayerConfig\n ) => IntlayerAPI[Key];\n};\n\nconst sectionFactories: SectionFactories = {\n asset: getAssetAPI,\n organization: getOrganizationAPI,\n project: getProjectAPI,\n environment: getEnvironmentAPI,\n user: getUserAPI,\n oAuth: getOAuthAPI,\n dictionary: getDictionaryAPI,\n stripe: getStripeAPI,\n ai: getAiAPI,\n analytics: getAnalyticsAPI,\n audit: getAuditAPI,\n tag: getTagAPI,\n search: getSearchAPI,\n editor: getEditorAPI,\n newsletter: getNewsletterAPI,\n github: getGithubAPI,\n gitlab: getGitlabAPI,\n bitbucket: getBitbucketAPI,\n showcaseProject: getShowcaseProjectAPI,\n translate: getTranslateAPI,\n reviewer: getReviewerAPI,\n status: getStatusAPI,\n};\n\n// The OAuth2 token endpoint must never receive an injected Bearer token —\n// it is the call that issues one.\nconst AUTH_FREE_SECTIONS: ReadonlySet<SectionKey> = new Set<SectionKey>([\n 'oAuth',\n]);\n\n/**\n * Builds the **complete** auto-authenticated Intlayer API as a single lazy\n * object. Every domain is reachable through it, so it pulls every domain client\n * into the bundle.\n *\n * Prefer {@link createIntlayerCMS} together with the per-domain endpoint binders\n * (e.g. `dictionaryEndpoint`) in bundle-sensitive code — they include only the\n * domains you use. This helper is a convenience for Node tools (such as the CLI)\n * where bundle size is not a concern.\n */\nexport const getIntlayerAPIProxy = (\n baseAuthOptions: FetcherOptions = {},\n intlayerConfig: Pick<IntlayerConfig, 'editor'> = { editor },\n sessionToken?: string\n): IntlayerAPI => {\n const cms: IntlayerCMS = createIntlayerCMS(intlayerConfig, {\n baseFetcherOptions: baseAuthOptions,\n sessionToken,\n });\n\n const sectionCache = new Map<SectionKey, unknown>();\n\n // Generic over `Key` so `sectionFactories[key]` resolves to a single\n // `(opts, config) => IntlayerAPI[Key]` signature rather than the union of all\n // factory signatures (which would not be callable).\n const buildSection = <Key extends SectionKey>(key: Key): IntlayerAPI[Key] => {\n const factory = sectionFactories[key] as (\n fetcherOptions: FetcherOptions,\n intlayerConfig: IntlayerConfig\n ) => Record<string, unknown>;\n\n return cms.bindSection(factory, {\n skipAuth: AUTH_FREE_SECTIONS.has(key) ? true : undefined,\n }) as IntlayerAPI[Key];\n };\n\n return new Proxy({} as IntlayerAPI, {\n get(_target, property) {\n const key = property as SectionKey;\n if (!(key in sectionFactories)) return undefined;\n\n if (!sectionCache.has(key)) {\n sectionCache.set(key, buildSection(key));\n }\n\n return sectionCache.get(key);\n },\n has(_target, property) {\n return (property as SectionKey) in sectionFactories;\n },\n ownKeys() {\n return Reflect.ownKeys(sectionFactories);\n },\n getOwnPropertyDescriptor() {\n return { enumerable: true, configurable: true };\n },\n });\n};\n\n/**\n * The complete auto-authenticated Intlayer API returned by\n * {@link getIntlayerAPIProxy}. Equivalent in shape to `IntlayerAPI`.\n */\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"proxy.mjs","names":[],"sources":["../../src/proxy.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createIntlayerCMS, type IntlayerCMS } from './cms/createIntlayerCMS';\nimport type { FetcherOptions } from './fetcher';\nimport { getAiAPI } from './getIntlayerAPI/ai';\nimport { getAnalyticsAPI } from './getIntlayerAPI/analytics';\nimport { getAssetAPI } from './getIntlayerAPI/asset';\nimport { getAuditAPI } from './getIntlayerAPI/audit';\nimport { getBitbucketAPI } from './getIntlayerAPI/bitbucket';\nimport { getCodebergAPI } from './getIntlayerAPI/codeberg';\nimport { getDictionaryAPI } from './getIntlayerAPI/dictionary';\nimport { getEditorAPI } from './getIntlayerAPI/editor';\nimport { getEnvironmentAPI } from './getIntlayerAPI/environment';\nimport { getGiteeAPI } from './getIntlayerAPI/gitee';\nimport { getGithubAPI } from './getIntlayerAPI/github';\nimport { getGitlabAPI } from './getIntlayerAPI/gitlab';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getNewsletterAPI } from './getIntlayerAPI/newsletter';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\nimport { getOrganizationAPI } from './getIntlayerAPI/organization';\nimport { getProjectAPI } from './getIntlayerAPI/project';\nimport { getReviewerAPI } from './getIntlayerAPI/reviewer';\nimport { getSearchAPI } from './getIntlayerAPI/search';\nimport { getShowcaseProjectAPI } from './getIntlayerAPI/showcaseProject';\nimport { getStatusAPI } from './getIntlayerAPI/status';\nimport { getStripeAPI } from './getIntlayerAPI/stripe';\nimport { getTagAPI } from './getIntlayerAPI/tag';\nimport { getTranslateAPI } from './getIntlayerAPI/translate';\nimport { getUserAPI } from './getIntlayerAPI/user';\n\ntype SectionKey = keyof IntlayerAPI;\n\n/**\n * Homogeneous factory map: every domain factory normalized to the same\n * `(fetcherOptions, config) => section` signature, keyed by section name.\n * Declaring it as a single mapped type lets a generic lookup stay callable\n * (a union of factory signatures would not be).\n */\ntype SectionFactories = {\n [Key in SectionKey]: (\n fetcherOptions: FetcherOptions,\n intlayerConfig: IntlayerConfig\n ) => IntlayerAPI[Key];\n};\n\nconst sectionFactories: SectionFactories = {\n asset: getAssetAPI,\n organization: getOrganizationAPI,\n project: getProjectAPI,\n environment: getEnvironmentAPI,\n user: getUserAPI,\n oAuth: getOAuthAPI,\n dictionary: getDictionaryAPI,\n stripe: getStripeAPI,\n ai: getAiAPI,\n analytics: getAnalyticsAPI,\n audit: getAuditAPI,\n tag: getTagAPI,\n search: getSearchAPI,\n editor: getEditorAPI,\n newsletter: getNewsletterAPI,\n github: getGithubAPI,\n gitlab: getGitlabAPI,\n bitbucket: getBitbucketAPI,\n codeberg: getCodebergAPI,\n gitee: getGiteeAPI,\n showcaseProject: getShowcaseProjectAPI,\n translate: getTranslateAPI,\n reviewer: getReviewerAPI,\n status: getStatusAPI,\n};\n\n// The OAuth2 token endpoint must never receive an injected Bearer token —\n// it is the call that issues one.\nconst AUTH_FREE_SECTIONS: ReadonlySet<SectionKey> = new Set<SectionKey>([\n 'oAuth',\n]);\n\n/**\n * Builds the **complete** auto-authenticated Intlayer API as a single lazy\n * object. Every domain is reachable through it, so it pulls every domain client\n * into the bundle.\n *\n * Prefer {@link createIntlayerCMS} together with the per-domain endpoint binders\n * (e.g. `dictionaryEndpoint`) in bundle-sensitive code — they include only the\n * domains you use. This helper is a convenience for Node tools (such as the CLI)\n * where bundle size is not a concern.\n */\nexport const getIntlayerAPIProxy = (\n baseAuthOptions: FetcherOptions = {},\n intlayerConfig: Pick<IntlayerConfig, 'editor'> = { editor },\n sessionToken?: string\n): IntlayerAPI => {\n const cms: IntlayerCMS = createIntlayerCMS(intlayerConfig, {\n baseFetcherOptions: baseAuthOptions,\n sessionToken,\n });\n\n const sectionCache = new Map<SectionKey, unknown>();\n\n // Generic over `Key` so `sectionFactories[key]` resolves to a single\n // `(opts, config) => IntlayerAPI[Key]` signature rather than the union of all\n // factory signatures (which would not be callable).\n const buildSection = <Key extends SectionKey>(key: Key): IntlayerAPI[Key] => {\n const factory = sectionFactories[key] as (\n fetcherOptions: FetcherOptions,\n intlayerConfig: IntlayerConfig\n ) => Record<string, unknown>;\n\n return cms.bindSection(factory, {\n skipAuth: AUTH_FREE_SECTIONS.has(key) ? true : undefined,\n }) as IntlayerAPI[Key];\n };\n\n return new Proxy({} as IntlayerAPI, {\n get(_target, property) {\n const key = property as SectionKey;\n if (!(key in sectionFactories)) return undefined;\n\n if (!sectionCache.has(key)) {\n sectionCache.set(key, buildSection(key));\n }\n\n return sectionCache.get(key);\n },\n has(_target, property) {\n return (property as SectionKey) in sectionFactories;\n },\n ownKeys() {\n return Reflect.ownKeys(sectionFactories);\n },\n getOwnPropertyDescriptor() {\n return { enumerable: true, configurable: true };\n },\n });\n};\n\n/**\n * The complete auto-authenticated Intlayer API returned by\n * {@link getIntlayerAPIProxy}. Equivalent in shape to `IntlayerAPI`.\n */\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,mBAAqC;CACzC,OAAO;CACP,cAAc;CACd,SAAS;CACT,aAAa;CACb,MAAM;CACN,OAAO;CACP,YAAY;CACZ,QAAQ;CACR,IAAI;CACJ,WAAW;CACX,OAAO;CACP,KAAK;CACL,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,UAAU;CACV,OAAO;CACP,iBAAiB;CACjB,WAAW;CACX,UAAU;CACV,QAAQ;AACV;AAIA,MAAM,qCAA8C,IAAI,IAAgB,CACtE,OACF,CAAC;;;;;;;;;;;AAYD,MAAa,uBACX,kBAAkC,CAAC,GACnC,iBAAiD,EAAE,OAAO,GAC1D,iBACgB;CAChB,MAAM,MAAmB,kBAAkB,gBAAgB;EACzD,oBAAoB;EACpB;CACF,CAAC;CAED,MAAM,+BAAe,IAAI,IAAyB;CAKlD,MAAM,gBAAwC,QAA+B;EAC3E,MAAM,UAAU,iBAAiB;EAKjC,OAAO,IAAI,YAAY,SAAS,EAC9B,UAAU,mBAAmB,IAAI,GAAG,IAAI,OAAO,OACjD,CAAC;CACH;CAEA,OAAO,IAAI,MAAM,CAAC,GAAkB;EAClC,IAAI,SAAS,UAAU;GACrB,MAAM,MAAM;GACZ,IAAI,EAAE,OAAO,mBAAmB,OAAO;GAEvC,IAAI,CAAC,aAAa,IAAI,GAAG,GACvB,aAAa,IAAI,KAAK,aAAa,GAAG,CAAC;GAGzC,OAAO,aAAa,IAAI,GAAG;EAC7B;EACA,IAAI,SAAS,UAAU;GACrB,OAAQ,YAA2B;EACrC;EACA,UAAU;GACR,OAAO,QAAQ,QAAQ,gBAAgB;EACzC;EACA,2BAA2B;GACzB,OAAO;IAAE,YAAY;IAAM,cAAc;GAAK;EAChD;CACF,CAAC;AACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { editor } from "@intlayer/config/built";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/public/createPublicClient.ts
|
|
4
4
|
/**
|
|
5
5
|
* Browser-safe Intlayer client, authenticated without any confidential
|
|
6
6
|
* credential.
|
|
@@ -58,6 +58,25 @@ const writeStoredToken = (cached) => {
|
|
|
58
58
|
* @param options - Optional configuration override.
|
|
59
59
|
* @returns A client that authenticates itself with the public project key.
|
|
60
60
|
*/
|
|
61
|
+
/**
|
|
62
|
+
* Public routes, checked against the backend contract at compile time. Kept
|
|
63
|
+
* as plain strings: this client ships in end-user browser bundles.
|
|
64
|
+
*/
|
|
65
|
+
const publicPrefix = "/api/public";
|
|
66
|
+
const publicEndpoints = {
|
|
67
|
+
createPublicBrowserToken: {
|
|
68
|
+
method: "POST",
|
|
69
|
+
path: "/token"
|
|
70
|
+
},
|
|
71
|
+
getPublicDictionaryKeys: {
|
|
72
|
+
method: "GET",
|
|
73
|
+
path: "/dictionaries/keys"
|
|
74
|
+
},
|
|
75
|
+
getPublicDictionaries: {
|
|
76
|
+
method: "GET",
|
|
77
|
+
path: "/dictionaries"
|
|
78
|
+
}
|
|
79
|
+
};
|
|
61
80
|
const createPublicClient = ({ intlayerConfig } = {}) => {
|
|
62
81
|
const resolvedEditor = intlayerConfig?.editor ?? editor;
|
|
63
82
|
const backendURL = (resolvedEditor?.backendURL ?? "").replace(/\/$/, "");
|
|
@@ -66,8 +85,9 @@ const createPublicClient = ({ intlayerConfig } = {}) => {
|
|
|
66
85
|
let pendingExchange = null;
|
|
67
86
|
const isUsable = (candidate) => candidate !== null && candidate.expiresAt - EXPIRY_MARGIN_MS > Date.now();
|
|
68
87
|
const exchange = async () => {
|
|
69
|
-
const
|
|
70
|
-
|
|
88
|
+
const { method, path } = publicEndpoints.createPublicBrowserToken;
|
|
89
|
+
const response = await fetch(`${backendURL}${publicPrefix}${path}`, {
|
|
90
|
+
method,
|
|
71
91
|
headers: { "Content-Type": "application/json" },
|
|
72
92
|
body: JSON.stringify({ clientId }),
|
|
73
93
|
credentials: "omit",
|
|
@@ -102,7 +122,7 @@ const createPublicClient = ({ intlayerConfig } = {}) => {
|
|
|
102
122
|
const request = async (path, fallback) => {
|
|
103
123
|
const token = await getToken();
|
|
104
124
|
if (!token) return fallback;
|
|
105
|
-
const response = await fetch(`${backendURL}
|
|
125
|
+
const response = await fetch(`${backendURL}${publicPrefix}${path}`, {
|
|
106
126
|
headers: { Authorization: `Bearer ${token}` },
|
|
107
127
|
credentials: "omit",
|
|
108
128
|
mode: "cors"
|
|
@@ -112,11 +132,10 @@ const createPublicClient = ({ intlayerConfig } = {}) => {
|
|
|
112
132
|
};
|
|
113
133
|
return {
|
|
114
134
|
getToken,
|
|
115
|
-
getDictionaryKeys: () => request(
|
|
116
|
-
getDictionaries: (keys) => request(
|
|
135
|
+
getDictionaryKeys: () => request(publicEndpoints.getPublicDictionaryKeys.path, []),
|
|
136
|
+
getDictionaries: (keys) => request(`${publicEndpoints.getPublicDictionaries.path}?keys=${encodeURIComponent(keys.join(","))}`, [])
|
|
117
137
|
};
|
|
118
138
|
};
|
|
119
139
|
|
|
120
|
-
//#endregion
|
|
121
140
|
export { createPublicClient };
|
|
122
141
|
//# sourceMappingURL=createPublicClient.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPublicClient.mjs","names":[],"sources":["../../../src/public/createPublicClient.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Browser-safe Intlayer client, authenticated without any confidential\n * credential.\n *\n * This is the Google-Analytics model applied to the whole SDK: the page ships\n * only the **public** `editor.clientId`, exchanges it for a short-lived scoped\n * token, and calls the API directly. No server route, no server action, and no\n * `clientSecret` in the bundle.\n *\n * What it can do is deliberately narrow, and that is what makes shipping the\n * key safe: read the project's published dictionary content — the content the\n * page already renders — and submit analytics events. Writing content, reading\n * a project, an organization or a user still require a real credential\n * (server-side) or a signed-in user.\n *\n * @example\n * ```ts\n * import { createPublicClient } from '@intlayer/api/public';\n *\n * const client = createPublicClient();\n *\n * const keys = await client.getDictionaryKeys();\n * const [dictionary] = await client.getDictionaries(['navbar']);\n * ```\n */\n\n/** `sessionStorage` key holding the cached token for this tab. */\nconst TOKEN_STORAGE_KEY = '__intlayer_public_token__';\n\n/**\n * Refresh margin: a token within this window of expiry is treated as expired,\n * so a request is never sent with a token that dies in flight.\n */\nconst EXPIRY_MARGIN_MS = 60 * 1000;\n\ntype CachedToken = {\n token: string;\n /** Epoch milliseconds. */\n expiresAt: number;\n};\n\n/** Reads the cached token for this tab, ignoring an unusable cache. */\nconst readStoredToken = (): CachedToken | null => {\n try {\n const raw = globalThis.sessionStorage?.getItem(TOKEN_STORAGE_KEY);\n if (!raw) return null;\n\n const parsed = JSON.parse(raw) as CachedToken;\n\n if (typeof parsed?.token !== 'string') return null;\n if (typeof parsed?.expiresAt !== 'number') return null;\n\n return parsed;\n } catch {\n // Private mode, disabled storage, or a corrupted entry — start fresh.\n return null;\n }\n};\n\n/** Persists the token for this tab. Best-effort: storage may be unavailable. */\nconst writeStoredToken = (cached: CachedToken): void => {\n try {\n globalThis.sessionStorage?.setItem(\n TOKEN_STORAGE_KEY,\n JSON.stringify(cached)\n );\n } catch {\n /* ignore — the in-memory cache still applies for this page */\n }\n};\n\n/** Options accepted by {@link createPublicClient}. */\nexport type PublicClientOptions = {\n /** Overrides the build-time `editor` configuration. */\n intlayerConfig?: Pick<IntlayerConfig, 'editor'>;\n};\n\n/** The credential-free client returned by {@link createPublicClient}. */\nexport type PublicClient = {\n /**\n * Returns the current token, exchanging the public `clientId` for one when\n * needed. `null` when the project is unknown or the origin is not allowed.\n */\n getToken: () => Promise<string | null>;\n /** Every dictionary key published for the project. */\n getDictionaryKeys: () => Promise<string[]>;\n /**\n * Published dictionary content for the given keys.\n *\n * @param keys - Dictionary keys to fetch (at most 100 per call).\n */\n getDictionaries: (keys: string[]) => Promise<DictionaryAPI[]>;\n};\n\n/**\n * Creates a {@link PublicClient} for the configured project.\n *\n * @param options - Optional configuration override.\n * @returns A client that authenticates itself with the public project key.\n */\nexport const createPublicClient = ({\n intlayerConfig,\n}: PublicClientOptions = {}): PublicClient => {\n const resolvedEditor = intlayerConfig?.editor ?? editor;\n const backendURL = (resolvedEditor?.backendURL ?? '').replace(/\\/$/, '');\n const clientId = resolvedEditor?.clientId;\n\n let cached: CachedToken | null = null;\n let pendingExchange: Promise<string | null> | null = null;\n\n const isUsable = (candidate: CachedToken | null): candidate is CachedToken =>\n candidate !== null && candidate.expiresAt - EXPIRY_MARGIN_MS > Date.now();\n\n const exchange = async (): Promise<string | null> => {\n const response = await fetch(`${backendURL}
|
|
1
|
+
{"version":3,"file":"createPublicClient.mjs","names":[],"sources":["../../../src/public/createPublicClient.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport type { DictionaryAPI } from '@intlayer/backend-contract/dictionary';\nimport type {\n PublicRoutes,\n publicContract,\n} from '@intlayer/backend-contract/public';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Browser-safe Intlayer client, authenticated without any confidential\n * credential.\n *\n * This is the Google-Analytics model applied to the whole SDK: the page ships\n * only the **public** `editor.clientId`, exchanges it for a short-lived scoped\n * token, and calls the API directly. No server route, no server action, and no\n * `clientSecret` in the bundle.\n *\n * What it can do is deliberately narrow, and that is what makes shipping the\n * key safe: read the project's published dictionary content — the content the\n * page already renders — and submit analytics events. Writing content, reading\n * a project, an organization or a user still require a real credential\n * (server-side) or a signed-in user.\n *\n * @example\n * ```ts\n * import { createPublicClient } from '@intlayer/api/public';\n *\n * const client = createPublicClient();\n *\n * const keys = await client.getDictionaryKeys();\n * const [dictionary] = await client.getDictionaries(['navbar']);\n * ```\n */\n\n/** `sessionStorage` key holding the cached token for this tab. */\nconst TOKEN_STORAGE_KEY = '__intlayer_public_token__';\n\n/**\n * Refresh margin: a token within this window of expiry is treated as expired,\n * so a request is never sent with a token that dies in flight.\n */\nconst EXPIRY_MARGIN_MS = 60 * 1000;\n\ntype CachedToken = {\n token: string;\n /** Epoch milliseconds. */\n expiresAt: number;\n};\n\n/** Reads the cached token for this tab, ignoring an unusable cache. */\nconst readStoredToken = (): CachedToken | null => {\n try {\n const raw = globalThis.sessionStorage?.getItem(TOKEN_STORAGE_KEY);\n if (!raw) return null;\n\n const parsed = JSON.parse(raw) as CachedToken;\n\n if (typeof parsed?.token !== 'string') return null;\n if (typeof parsed?.expiresAt !== 'number') return null;\n\n return parsed;\n } catch {\n // Private mode, disabled storage, or a corrupted entry — start fresh.\n return null;\n }\n};\n\n/** Persists the token for this tab. Best-effort: storage may be unavailable. */\nconst writeStoredToken = (cached: CachedToken): void => {\n try {\n globalThis.sessionStorage?.setItem(\n TOKEN_STORAGE_KEY,\n JSON.stringify(cached)\n );\n } catch {\n /* ignore — the in-memory cache still applies for this page */\n }\n};\n\n/** Options accepted by {@link createPublicClient}. */\nexport type PublicClientOptions = {\n /** Overrides the build-time `editor` configuration. */\n intlayerConfig?: Pick<IntlayerConfig, 'editor'>;\n};\n\n/** The credential-free client returned by {@link createPublicClient}. */\nexport type PublicClient = {\n /**\n * Returns the current token, exchanging the public `clientId` for one when\n * needed. `null` when the project is unknown or the origin is not allowed.\n */\n getToken: () => Promise<string | null>;\n /** Every dictionary key published for the project. */\n getDictionaryKeys: () => Promise<string[]>;\n /**\n * Published dictionary content for the given keys.\n *\n * @param keys - Dictionary keys to fetch (at most 100 per call).\n */\n getDictionaries: (keys: string[]) => Promise<DictionaryAPI[]>;\n};\n\n/**\n * Creates a {@link PublicClient} for the configured project.\n *\n * @param options - Optional configuration override.\n * @returns A client that authenticates itself with the public project key.\n */\n/**\n * Public routes, checked against the backend contract at compile time. Kept\n * as plain strings: this client ships in end-user browser bundles.\n */\nconst publicPrefix = '/api/public' satisfies (typeof publicContract)['prefix'];\nconst publicEndpoints = {\n createPublicBrowserToken: { method: 'POST', path: '/token' },\n getPublicDictionaryKeys: { method: 'GET', path: '/dictionaries/keys' },\n getPublicDictionaries: { method: 'GET', path: '/dictionaries' },\n} as const satisfies RouteEndpoints<PublicRoutes>;\n\nexport const createPublicClient = ({\n intlayerConfig,\n}: PublicClientOptions = {}): PublicClient => {\n const resolvedEditor = intlayerConfig?.editor ?? editor;\n const backendURL = (resolvedEditor?.backendURL ?? '').replace(/\\/$/, '');\n const clientId = resolvedEditor?.clientId;\n\n let cached: CachedToken | null = null;\n let pendingExchange: Promise<string | null> | null = null;\n\n const isUsable = (candidate: CachedToken | null): candidate is CachedToken =>\n candidate !== null && candidate.expiresAt - EXPIRY_MARGIN_MS > Date.now();\n\n const exchange = async (): Promise<string | null> => {\n const { method, path } = publicEndpoints.createPublicBrowserToken;\n const response = await fetch(`${backendURL}${publicPrefix}${path}`, {\n method,\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ clientId }),\n // Authorised by `Origin`, never by cookies.\n credentials: 'omit',\n mode: 'cors',\n });\n\n if (!response.ok) return null;\n\n const payload = (await response.json()) as {\n data?: { token?: string | null; expiresIn?: number };\n };\n\n const token = payload?.data?.token;\n const expiresIn = payload?.data?.expiresIn ?? 0;\n\n if (!token || expiresIn <= 0) return null;\n\n cached = { token, expiresAt: Date.now() + expiresIn * 1000 };\n writeStoredToken(cached);\n\n return token;\n };\n\n const getToken = async (): Promise<string | null> => {\n if (isUsable(cached)) return cached.token;\n\n const stored = readStoredToken();\n if (isUsable(stored)) {\n cached = stored;\n return stored.token;\n }\n\n if (!clientId) return null;\n\n // De-duplicate concurrent exchanges so a burst of calls triggers one fetch.\n pendingExchange ??= exchange().finally(() => {\n pendingExchange = null;\n });\n\n return await pendingExchange;\n };\n\n /** Issues an authorised GET against the public surface. */\n const request = async <Result>(\n path: string,\n fallback: Result\n ): Promise<Result> => {\n const token = await getToken();\n\n if (!token) return fallback;\n\n const response = await fetch(`${backendURL}${publicPrefix}${path}`, {\n headers: { Authorization: `Bearer ${token}` },\n credentials: 'omit',\n mode: 'cors',\n });\n\n if (!response.ok) return fallback;\n\n const payload = (await response.json()) as { data?: Result };\n\n return payload?.data ?? fallback;\n };\n\n return {\n getToken,\n getDictionaryKeys: () =>\n request<string[]>(publicEndpoints.getPublicDictionaryKeys.path, []),\n getDictionaries: (keys) =>\n request<DictionaryAPI[]>(\n `${publicEndpoints.getPublicDictionaries.path}?keys=${encodeURIComponent(keys.join(','))}`,\n []\n ),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,oBAAoB;;;;;AAM1B,MAAM,mBAAmB;;AASzB,MAAM,wBAA4C;CAChD,IAAI;EACF,MAAM,MAAM,WAAW,gBAAgB,QAAQ,iBAAiB;EAChE,IAAI,CAAC,KAAK,OAAO;EAEjB,MAAM,SAAS,KAAK,MAAM,GAAG;EAE7B,IAAI,OAAO,QAAQ,UAAU,UAAU,OAAO;EAC9C,IAAI,OAAO,QAAQ,cAAc,UAAU,OAAO;EAElD,OAAO;CACT,QAAQ;EAEN,OAAO;CACT;AACF;;AAGA,MAAM,oBAAoB,WAA8B;CACtD,IAAI;EACF,WAAW,gBAAgB,QACzB,mBACA,KAAK,UAAU,MAAM,CACvB;CACF,QAAQ,CAER;AACF;;;;;;;;;;;AAmCA,MAAM,eAAe;AACrB,MAAM,kBAAkB;CACtB,0BAA0B;EAAE,QAAQ;EAAQ,MAAM;CAAS;CAC3D,yBAAyB;EAAE,QAAQ;EAAO,MAAM;CAAqB;CACrE,uBAAuB;EAAE,QAAQ;EAAO,MAAM;CAAgB;AAChE;AAEA,MAAa,sBAAsB,EACjC,mBACuB,CAAC,MAAoB;CAC5C,MAAM,iBAAiB,gBAAgB,UAAU;CACjD,MAAM,cAAc,gBAAgB,cAAc,GAAE,CAAE,QAAQ,OAAO,EAAE;CACvE,MAAM,WAAW,gBAAgB;CAEjC,IAAI,SAA6B;CACjC,IAAI,kBAAiD;CAErD,MAAM,YAAY,cAChB,cAAc,QAAQ,UAAU,YAAY,mBAAmB,KAAK,IAAI;CAE1E,MAAM,WAAW,YAAoC;EACnD,MAAM,EAAE,QAAQ,SAAS,gBAAgB;EACzC,MAAM,WAAW,MAAM,MAAM,GAAG,aAAa,eAAe,QAAQ;GAClE;GACA,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,MAAM,KAAK,UAAU,EAAE,SAAS,CAAC;GAEjC,aAAa;GACb,MAAM;EACR,CAAC;EAED,IAAI,CAAC,SAAS,IAAI,OAAO;EAEzB,MAAM,UAAW,MAAM,SAAS,KAAK;EAIrC,MAAM,QAAQ,SAAS,MAAM;EAC7B,MAAM,YAAY,SAAS,MAAM,aAAa;EAE9C,IAAI,CAAC,SAAS,aAAa,GAAG,OAAO;EAErC,SAAS;GAAE;GAAO,WAAW,KAAK,IAAI,IAAI,YAAY;EAAK;EAC3D,iBAAiB,MAAM;EAEvB,OAAO;CACT;CAEA,MAAM,WAAW,YAAoC;EACnD,IAAI,SAAS,MAAM,GAAG,OAAO,OAAO;EAEpC,MAAM,SAAS,gBAAgB;EAC/B,IAAI,SAAS,MAAM,GAAG;GACpB,SAAS;GACT,OAAO,OAAO;EAChB;EAEA,IAAI,CAAC,UAAU,OAAO;EAGtB,oBAAoB,SAAS,CAAC,CAAC,cAAc;GAC3C,kBAAkB;EACpB,CAAC;EAED,OAAO,MAAM;CACf;;CAGA,MAAM,UAAU,OACd,MACA,aACoB;EACpB,MAAM,QAAQ,MAAM,SAAS;EAE7B,IAAI,CAAC,OAAO,OAAO;EAEnB,MAAM,WAAW,MAAM,MAAM,GAAG,aAAa,eAAe,QAAQ;GAClE,SAAS,EAAE,eAAe,UAAU,QAAQ;GAC5C,aAAa;GACb,MAAM;EACR,CAAC;EAED,IAAI,CAAC,SAAS,IAAI,OAAO;EAIzB,QAAO,MAFgB,SAAS,KAAK,EAEvB,EAAE,QAAQ;CAC1B;CAEA,OAAO;EACL;EACA,yBACE,QAAkB,gBAAgB,wBAAwB,MAAM,CAAC,CAAC;EACpE,kBAAkB,SAChB,QACE,GAAG,gBAAgB,sBAAsB,KAAK,QAAQ,mBAAmB,KAAK,KAAK,GAAG,CAAC,KACvF,CAAC,CACH;CACJ;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { editor } from "@intlayer/config/built";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/resolveInternalBackendUrl.ts
|
|
4
4
|
/**
|
|
5
5
|
* Server-only override for the backend origin.
|
|
6
6
|
*
|
|
@@ -44,6 +44,5 @@ const resolveInternalBackendUrl = (url, publicBackendUrl = editor.backendURL) =>
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
//#endregion
|
|
48
47
|
export { BACKEND_INTERNAL_URL_ENVIRONMENT_VARIABLE, resolveInternalBackendUrl };
|
|
49
48
|
//# sourceMappingURL=resolveInternalBackendUrl.mjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FetcherOptions } from "../fetcher.js";
|
|
2
2
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
3
|
-
//#region src/cms/createAuthManager.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Any asynchronous API method exposed by a domain section
|
|
6
5
|
* (e.g. `getDictionaries`, `pushDictionaries`).
|
|
@@ -99,5 +98,5 @@ export type AuthManager = {
|
|
|
99
98
|
* @param options - Optional session token and base fetcher options.
|
|
100
99
|
*/
|
|
101
100
|
export declare const createAuthManager: (intlayerConfig?: Pick<IntlayerConfig, 'editor'>, options?: AuthManagerOptions) => AuthManager;
|
|
102
|
-
|
|
101
|
+
export {};
|
|
103
102
|
//# sourceMappingURL=createAuthManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAuthManager.d.ts","names":[],"sources":["../../../src/cms/createAuthManager.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createAuthManager.d.ts","names":[],"sources":["../../../src/cms/createAuthManager.ts"],"mappings":";;;;;;KAuBK,YAAY,6BAA6B,cACzC,MAAM,cACN,QAAQ;;;;;KAMR,eAAe,gBAAgB,4BAClC,gBAAgB,gBAChB,gBAAgB,mBACb;;qBAsBQ;;;;YA6ED;;;;EAIV,qBAAqB;;;;;;EAMrB;;;;;YAMU;;;;;EAKV;;;;;;;;;;YAWU;;;;;EAKV,gBAAgB;;;;EAIhB,gBAAgB;;;;;EAKhB;;;;;EAKA,kBAAkB;;;;EAIlB;;;;;EAKA,WAAW,6BAA6B,QACtC,QAAQ,YAAY,WAAW,SAC/B,uBACG,YAAY,WAAW;;;;;;;;;;;EAW5B,cAAc,gBAAgB,yBAC5B,SAAS,eAAe,UACxB,UAAU,uBACP;;;;;;;;;;;;;qBAcM,oBAAiB,iBACZ,KAAK,2BAAyB,UACrC,uBACR"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FetcherOptions } from "../fetcher.js";
|
|
2
2
|
import { AuthManager, AuthManagerOptions, BindSectionOptions } from "./createAuthManager.js";
|
|
3
3
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
4
|
-
//#region src/cms/createIntlayerCMS.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Options accepted when creating the Intlayer CMS authenticator.
|
|
7
6
|
*/
|
|
@@ -74,5 +73,4 @@ export type CMSEndpoint<Section extends Record<string, unknown>> = (cms?: Intlay
|
|
|
74
73
|
* ```
|
|
75
74
|
*/
|
|
76
75
|
export declare const createEndpoint: <Section extends Record<string, unknown>>(factory: (fetcherOptions: FetcherOptions, intlayerConfig: IntlayerConfig) => Section, options?: BindSectionOptions) => CMSEndpoint<Section>;
|
|
77
|
-
//#endregion
|
|
78
76
|
//# sourceMappingURL=createIntlayerCMS.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createIntlayerCMS.d.ts","names":[],"sources":["../../../src/cms/createIntlayerCMS.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createIntlayerCMS.d.ts","names":[],"sources":["../../../src/cms/createIntlayerCMS.ts"],"mappings":";;;;;;YAaY,qBAAqB;;;;;;;;YASrB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqCb,oBAAiB,iBACZ,KAAK,2BAAyB,UACrC,uBACR;;;;;;YAOS,YAAY,gBAAgB,4BACtC,MAAM,gBACH;;;;;;;;;;;;;;;;;;qBAmBQ,iBACV,gBAAgB,yBAAuB,UAEpC,gBAAgB,gBAChB,gBAAgB,mBACb,SAAO,UACF,uBACT,YAAY"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
-
import { DictionaryAPI } from "@intlayer/backend";
|
|
3
|
-
//#region src/distantDictionary/fetchDistantDictionaries.d.ts
|
|
2
|
+
import { DictionaryAPI } from "@intlayer/backend-contract/dictionary";
|
|
4
3
|
/**
|
|
5
4
|
* Fetch distant dictionary
|
|
6
5
|
*/
|
|
7
6
|
export declare const fetchDistantDictionaries: (intlayerConfig: IntlayerConfig) => Promise<DictionaryAPI[] | null | undefined>;
|
|
8
|
-
//#endregion
|
|
9
7
|
//# sourceMappingURL=fetchDistantDictionaries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchDistantDictionaries.d.ts","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchDistantDictionaries.d.ts","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"mappings":";;;;;qBAQa,2BAAwB,gBACnB,mBACf,QAAQ"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
-
import { DictionaryAPI } from "@intlayer/backend";
|
|
3
|
-
//#region src/distantDictionary/fetchDistantDictionary.d.ts
|
|
2
|
+
import { DictionaryAPI } from "@intlayer/backend-contract/dictionary";
|
|
4
3
|
/**
|
|
5
4
|
* Fetch distant dictionary
|
|
6
5
|
*/
|
|
7
6
|
export declare const fetchDistantDictionary: (dictionaryKey: string, intlayerConfig: IntlayerConfig) => Promise<DictionaryAPI | undefined>;
|
|
8
|
-
//#endregion
|
|
9
7
|
//# sourceMappingURL=fetchDistantDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchDistantDictionary.d.ts","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchDistantDictionary.d.ts","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"mappings":";;;;;qBAQa,yBAAsB,uBACZ,gBACL,mBACf,QAAQ"}
|
package/dist/types/fetcher.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/fetcher.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Error thrown when the backend answers with a non-ok response.
|
|
4
3
|
*
|
|
@@ -32,7 +31,7 @@ export type FetcherOptions = Omit<RequestInit, 'body'> & {
|
|
|
32
31
|
/**
|
|
33
32
|
* Query parameters to be appended to the URL.
|
|
34
33
|
*/
|
|
35
|
-
params?: Record<string, string | string[] | undefined> | string[] | URLSearchParams;
|
|
34
|
+
params?: Record<string, string | number | boolean | (string | number)[] | undefined> | string[] | URLSearchParams;
|
|
36
35
|
};
|
|
37
36
|
/**
|
|
38
37
|
* Default options for the fetcher function.
|
|
@@ -88,5 +87,4 @@ export declare const fetcherOptions: FetcherOptions;
|
|
|
88
87
|
* ```
|
|
89
88
|
*/
|
|
90
89
|
export declare const fetcher: <T>(url: string, ...options: FetcherOptions[]) => Promise<T>;
|
|
91
|
-
//#endregion
|
|
92
90
|
//# sourceMappingURL=fetcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetcher.d.ts","names":[],"sources":["../../src/fetcher.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetcher.d.ts","names":[],"sources":["../../src/fetcher.ts"],"mappings":";;;;;;;qBASa,qBAAqB;;WAEhB;;WAEA;;WAEA;EAEhB,YACE,iBACA;IAAW;IAAgB;IAAe;;;;;;;;YAgBlC,iBAAiB,KAAK;;;;EAIhC,OAAO;;;;EAIP,SACI,yFAKA;;;;;;;qBAQO,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA6FhB,UAAiB,GAAC,gBAClB,SACC,qBACX,QAAQ"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { FetcherOptions } from "../fetcher.js";
|
|
2
|
-
import { CMSEndpoint } from "../cms/createIntlayerCMS.js";
|
|
3
1
|
import "../index.js";
|
|
2
|
+
import { CMSEndpoint } from "../cms/createIntlayerCMS.js";
|
|
3
|
+
import { FetcherOptions } from "../fetcher.js";
|
|
4
4
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
5
|
-
import { AIOptions, AskDocQuestionResult, AuditContentDeclarationBody, AuditContentDeclarationFieldBody, AuditContentDeclarationMetadataBody, AuditTagBody, ChatCompletionRequestMessage, ChatResult, CustomQueryBody, GetDiscussionsParams, TranslateJSONBody } from "@intlayer/backend";
|
|
6
|
-
//#region src/getIntlayerAPI/ai.d.ts
|
|
5
|
+
import { AIOptions, AskDocQuestionResult, AuditContentDeclarationBody, AuditContentDeclarationFieldBody, AuditContentDeclarationFieldResult, AuditContentDeclarationMetadataBody, AuditContentDeclarationMetadataResult, AuditContentDeclarationResult, AuditTagBody, AuditTagResult, AutocompleteResponse, ChatCompletionRequestMessage, ChatResult, CustomQueryBody, CustomQueryResult, GetAIStatsResult, GetDiscussionsParams, GetDiscussionsResult, TranslateJSONBody, TranslateJSONResult } from "@intlayer/backend-contract/ai";
|
|
7
6
|
export type AutocompleteBody = {
|
|
8
7
|
text: string;
|
|
9
8
|
aiOptions?: AIOptions;
|
|
@@ -62,6 +61,5 @@ export declare const aiEndpoint: CMSEndpoint<{
|
|
|
62
61
|
getDiscussions: (params?: GetDiscussionsParams, otherOptions?: FetcherOptions) => Promise<GetDiscussionsResult>;
|
|
63
62
|
getAIStats: (otherOptions?: FetcherOptions) => Promise<GetAIStatsResult>;
|
|
64
63
|
}>;
|
|
65
|
-
//#endregion
|
|
66
64
|
export type { AskDocQuestionResult, ChatResult };
|
|
67
65
|
//# sourceMappingURL=ai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","names":[],"sources":["../../../src/getIntlayerAPI/ai.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ai.d.ts","names":["_$__0.CMSEndpoint"],"sources":["../../../src/getIntlayerAPI/ai.ts"],"mappings":";;;;;YAgCY;EACV;EACA,YAAY;EACZ;EACA;EACA;;YAGU;EACV,UAAU;EACV;EACA,aAAa;EACb,UAAU,UAAU;;YAGV;EACN;EAAkB;;EAClB;;YAEM;EACV,UAAU;EACV;EACA,aAAa;EACb,UAAU,UAAU;EACpB,YAAY,QAAQ;;qBAkCT,WAAQ,iBACH,gBAAc,iBACb;EAWR,cAAA,OAAA,iBAAe,eACR,mBAAc,QAAA;EAkBrB,gBAAA,OAAA,mBAAiB,eACV,mBAAc,QAAA;EAkBrB,0BAAA,OAAA,6BAA2B,eACpB,mBAAc,QAAA;EAkBrB,+BAAA,OAAA,kCAAgC,eACzB,mBAAc,QAAA;EAsBrB,kCAAA,OAAA,qCAAmC,eAC5B,mBAAc,QAAA;EAsBrB,WAAA,OAAA,cAAY,eACL,mBAAc,QAAA;EAgCrB,iBAAA,OAAA,oBAAkB,eACX,mBAAc;EA0FH,OAAA,OAAA,UAAQ,eAAgB,mBAAc;EAyFxD,eAAA,OAAA,kBAAgB,eACT,mBAAc,QAAA;EAgBnB,iBAAA,SAAA,sBAAoB,eACf,mBAAc,QAAA;EAiBU,aAAA,eAAA,mBAAc,QAAA;;;;;;;;qBA+B3C,YA/B2CA;EA/V7C,cAAA,OAAA,iBAAe,eACR,mBAAc,QAAA;EAkBrB,gBAAA,OAAA,mBAAiB,eACV,mBAAc,QAAA;EAkBrB,0BAAA,OAAA,6BAA2B,eACpB,mBAAc,QAAA;EAkBrB,+BAAA,OAAA,kCAAgC,eACzB,mBAAc,QAAA;EAsBrB,kCAAA,OAAA,qCAAmC,eAC5B,mBAAc,QAAA;EAsBrB,WAAA,OAAA,cAAY,eACL,mBAAc,QAAA;EAgCrB,iBAAA,OAAA,oBAAkB,eACX,mBAAc;EA0FH,OAAA,OAAA,UAAQ,eAAgB,mBAAc;EAyFxD,eAAA,OAAA,kBAAgB,eACT,mBAAc,QAAA;EAgBnB,iBAAA,SAAA,sBAAoB,eACf,mBAAc,QAAA;EAiBU,aAAA,eAAA,mBAAc,QAAA"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { FetcherOptions } from "../fetcher.js";
|
|
2
|
-
import { CMSEndpoint } from "../cms/createIntlayerCMS.js";
|
|
3
1
|
import "../index.js";
|
|
2
|
+
import { CMSEndpoint } from "../cms/createIntlayerCMS.js";
|
|
3
|
+
import { FetcherOptions } from "../fetcher.js";
|
|
4
4
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
5
|
-
import { AudienceRange, IngestAnalyticsBody } from "@intlayer/backend";
|
|
6
|
-
//#region src/getIntlayerAPI/analytics.d.ts
|
|
5
|
+
import { AudienceRange, GetAnalyticsOverviewResult, GetAudienceResult, GetContentStatsResult, GetExperimentResultsResult, GetPageMetadataResult, IngestAnalyticsBody, IngestAnalyticsResult } from "@intlayer/backend-contract/analytics";
|
|
7
6
|
export declare const getAnalyticsAPI: (authAPIOptions?: FetcherOptions, intlayerConfig?: IntlayerConfig) => {
|
|
8
7
|
sendEvents: (body: IngestAnalyticsBody, otherOptions?: FetcherOptions) => Promise<IngestAnalyticsResult>;
|
|
9
8
|
getOverview: (otherOptions?: FetcherOptions) => Promise<GetAnalyticsOverviewResult>;
|
|
@@ -26,5 +25,4 @@ export declare const analyticsEndpoint: CMSEndpoint<{
|
|
|
26
25
|
getExperimentResults: (experimentKey: string, otherOptions?: FetcherOptions) => Promise<GetExperimentResultsResult>;
|
|
27
26
|
getPageMetadata: (url: string, otherOptions?: FetcherOptions) => Promise<GetPageMetadataResult>;
|
|
28
27
|
}>;
|
|
29
|
-
//#endregion
|
|
30
28
|
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","names":[],"sources":["../../../src/getIntlayerAPI/analytics.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","names":["_$__0.CMSEndpoint"],"sources":["../../../src/getIntlayerAPI/analytics.ts"],"mappings":";;;;;qBAsCa,kBAAe,iBACV,gBAAc,iBACb;EAYT,aAAA,MAAA,qBAAmB,eACX,mBAAc,QAAA;EAoBW,cAAA,eAAA,mBAAc,QAAA;EAoB9C,cAAA,QAAA,wBAAsB,eACf,mBAAc,QAAA;EAoBe,kBAAA,eAAA,mBAAc,QAAA;EAkB1C,uBAAA,uBAAM,eACP,mBAAc,QAAA;EAoBvB,kBAAA,aAAM,eACG,mBAAc,QAAA;;;;;;;;qBAgCnB,mBAhCmBA;EAtGtB,aAAA,MAAA,qBAAmB,eACX,mBAAc,QAAA;EAoBW,cAAA,eAAA,mBAAc,QAAA;EAoB9C,cAAA,QAAA,wBAAsB,eACf,mBAAc,QAAA;EAoBe,kBAAA,eAAA,mBAAc,QAAA;EAkB1C,uBAAA,uBAAM,eACP,mBAAc,QAAA;EAoBvB,kBAAA,aAAM,eACG,mBAAc,QAAA"}
|