@intlayer/api 3.5.8

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.
Files changed (63) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +240 -0
  3. package/dist/cjs/ai.cjs +89 -0
  4. package/dist/cjs/ai.cjs.map +1 -0
  5. package/dist/cjs/auth.cjs +166 -0
  6. package/dist/cjs/auth.cjs.map +1 -0
  7. package/dist/cjs/dictionary.cjs +103 -0
  8. package/dist/cjs/dictionary.cjs.map +1 -0
  9. package/dist/cjs/fetcher.cjs +98 -0
  10. package/dist/cjs/fetcher.cjs.map +1 -0
  11. package/dist/cjs/index.cjs +49 -0
  12. package/dist/cjs/index.cjs.map +1 -0
  13. package/dist/cjs/organization.cjs +121 -0
  14. package/dist/cjs/organization.cjs.map +1 -0
  15. package/dist/cjs/project.cjs +135 -0
  16. package/dist/cjs/project.cjs.map +1 -0
  17. package/dist/cjs/stripe.cjs +55 -0
  18. package/dist/cjs/stripe.cjs.map +1 -0
  19. package/dist/cjs/tag.cjs +77 -0
  20. package/dist/cjs/tag.cjs.map +1 -0
  21. package/dist/cjs/user.cjs +95 -0
  22. package/dist/cjs/user.cjs.map +1 -0
  23. package/dist/esm/ai.mjs +64 -0
  24. package/dist/esm/ai.mjs.map +1 -0
  25. package/dist/esm/auth.mjs +141 -0
  26. package/dist/esm/auth.mjs.map +1 -0
  27. package/dist/esm/dictionary.mjs +78 -0
  28. package/dist/esm/dictionary.mjs.map +1 -0
  29. package/dist/esm/fetcher.mjs +73 -0
  30. package/dist/esm/fetcher.mjs.map +1 -0
  31. package/dist/esm/index.mjs +24 -0
  32. package/dist/esm/index.mjs.map +1 -0
  33. package/dist/esm/organization.mjs +96 -0
  34. package/dist/esm/organization.mjs.map +1 -0
  35. package/dist/esm/project.mjs +110 -0
  36. package/dist/esm/project.mjs.map +1 -0
  37. package/dist/esm/stripe.mjs +31 -0
  38. package/dist/esm/stripe.mjs.map +1 -0
  39. package/dist/esm/tag.mjs +52 -0
  40. package/dist/esm/tag.mjs.map +1 -0
  41. package/dist/esm/user.mjs +70 -0
  42. package/dist/esm/user.mjs.map +1 -0
  43. package/dist/types/ai.d.ts +18 -0
  44. package/dist/types/ai.d.ts.map +1 -0
  45. package/dist/types/auth.d.ts +38 -0
  46. package/dist/types/auth.d.ts.map +1 -0
  47. package/dist/types/dictionary.d.ts +22 -0
  48. package/dist/types/dictionary.d.ts.map +1 -0
  49. package/dist/types/fetcher.d.ts +70 -0
  50. package/dist/types/fetcher.d.ts.map +1 -0
  51. package/dist/types/index.d.ts +157 -0
  52. package/dist/types/index.d.ts.map +1 -0
  53. package/dist/types/organization.d.ts +26 -0
  54. package/dist/types/organization.d.ts.map +1 -0
  55. package/dist/types/project.d.ts +28 -0
  56. package/dist/types/project.d.ts.map +1 -0
  57. package/dist/types/stripe.d.ts +8 -0
  58. package/dist/types/stripe.d.ts.map +1 -0
  59. package/dist/types/tag.d.ts +16 -0
  60. package/dist/types/tag.d.ts.map +1 -0
  61. package/dist/types/user.d.ts +22 -0
  62. package/dist/types/user.d.ts.map +1 -0
  63. package/package.json +99 -0
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
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 project_exports = {};
20
+ __export(project_exports, {
21
+ getProjectAPI: () => getProjectAPI,
22
+ projectAPI: () => projectAPI
23
+ });
24
+ module.exports = __toCommonJS(project_exports);
25
+ var import_client = require("@intlayer/config/client");
26
+ var import_fetcher = require('./fetcher.cjs');
27
+ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
28
+ const { backendURL } = (intlayerConfig ?? (0, import_client.getConfiguration)()).editor;
29
+ const PROJECT_API_ROUTE = `${backendURL}/api/project`;
30
+ const getProjects = async (filters, otherOptions = {}) => await (0, import_fetcher.fetcher)(
31
+ PROJECT_API_ROUTE,
32
+ authAPIOptions,
33
+ otherOptions,
34
+ {
35
+ params: filters
36
+ }
37
+ );
38
+ const addProject = async (project, otherOptions = {}) => await (0, import_fetcher.fetcher)(
39
+ `${PROJECT_API_ROUTE}`,
40
+ authAPIOptions,
41
+ otherOptions,
42
+ {
43
+ method: "POST",
44
+ body: project
45
+ }
46
+ );
47
+ const updateProject = async (project, otherOptions = {}) => await (0, import_fetcher.fetcher)(
48
+ `${PROJECT_API_ROUTE}`,
49
+ authAPIOptions,
50
+ otherOptions,
51
+ {
52
+ method: "PUT",
53
+ body: project
54
+ }
55
+ );
56
+ const updateProjectMembers = async (body, otherOptions = {}) => await (0, import_fetcher.fetcher)(
57
+ `${PROJECT_API_ROUTE}/members`,
58
+ authAPIOptions,
59
+ otherOptions,
60
+ {
61
+ method: "PUT",
62
+ body
63
+ }
64
+ );
65
+ const deleteProject = async (otherOptions = {}) => await (0, import_fetcher.fetcher)(
66
+ `${PROJECT_API_ROUTE}`,
67
+ authAPIOptions,
68
+ otherOptions,
69
+ {
70
+ method: "DELETE"
71
+ }
72
+ );
73
+ const selectProject = async (projectId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
74
+ `${PROJECT_API_ROUTE}/${String(projectId)}`,
75
+ authAPIOptions,
76
+ otherOptions,
77
+ {
78
+ method: "PUT"
79
+ }
80
+ );
81
+ const unselectProject = async (otherOptions = {}) => await (0, import_fetcher.fetcher)(
82
+ `${PROJECT_API_ROUTE}/logout`,
83
+ authAPIOptions,
84
+ otherOptions,
85
+ {
86
+ method: "POST"
87
+ }
88
+ );
89
+ const addNewAccessKey = async (accessKey, otherOptions = {}) => await (0, import_fetcher.fetcher)(
90
+ `${PROJECT_API_ROUTE}/access_key`,
91
+ authAPIOptions,
92
+ otherOptions,
93
+ {
94
+ method: "POST",
95
+ body: accessKey
96
+ }
97
+ );
98
+ const deleteAccessKey = async (clientId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
99
+ `${PROJECT_API_ROUTE}/access_key`,
100
+ authAPIOptions,
101
+ otherOptions,
102
+ {
103
+ method: "DELETE",
104
+ body: { clientId }
105
+ }
106
+ );
107
+ const refreshAccessKey = async (clientId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
108
+ `${PROJECT_API_ROUTE}/access_key`,
109
+ authAPIOptions,
110
+ otherOptions,
111
+ {
112
+ method: "PATCH",
113
+ body: { clientId }
114
+ }
115
+ );
116
+ return {
117
+ getProjects,
118
+ addProject,
119
+ updateProject,
120
+ updateProjectMembers,
121
+ deleteProject,
122
+ selectProject,
123
+ unselectProject,
124
+ addNewAccessKey,
125
+ deleteAccessKey,
126
+ refreshAccessKey
127
+ };
128
+ };
129
+ const projectAPI = getProjectAPI();
130
+ // Annotate the CommonJS export names for ESM import in node:
131
+ 0 && (module.exports = {
132
+ getProjectAPI,
133
+ projectAPI
134
+ });
135
+ //# sourceMappingURL=project.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/project.ts"],"sourcesContent":["import type {\n AddProjectBody,\n AddProjectResult,\n DeleteProjectResult,\n GetProjectsParams,\n GetProjectsResult,\n UpdateProjectBody,\n UpdateProjectResult,\n SelectProjectParam,\n SelectProjectResult,\n UnselectProjectResult,\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n // @ts-ignore @intlayer/backend not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from './fetcher';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { backendURL } = (intlayerConfig ?? getConfiguration()).editor;\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n deleteProject,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n };\n};\n\nexport const projectAPI = getProjectAPI();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBA,oBAAsD;AACtD,qBAA6C;AAEtC,MAAM,gBAAgB,CAC3B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,EAAE,WAAW,KAAK,sBAAkB,gCAAiB,GAAG;AAC9D,QAAM,oBAAoB,GAAG,UAAU;AAMvC,QAAM,cAAc,OAClB,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,aAAa,OACjB,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,gBAAgB,OACpB,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,uBAAuB,OAC3B,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAMF,QAAM,gBAAgB,OAAO,eAA+B,CAAC,MAC3D,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,gBAAgB,OACpB,WACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,OAAO,SAAS,CAAC;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,kBAAkB,OAAO,eAA+B,CAAC,MAC7D,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAQF,QAAM,kBAAkB,OACtB,WACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAQF,QAAM,kBAAkB,OACtB,UACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,EAAE,SAAS;AAAA,IACnB;AAAA,EACF;AAQF,QAAM,mBAAmB,OACvB,UACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,EAAE,SAAS;AAAA,IACnB;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,aAAa,cAAc;","names":[]}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
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 stripe_exports = {};
20
+ __export(stripe_exports, {
21
+ getStripeAPI: () => getStripeAPI
22
+ });
23
+ module.exports = __toCommonJS(stripe_exports);
24
+ var import_client = require("@intlayer/config/client");
25
+ var import_fetcher = require('./fetcher.cjs');
26
+ const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
27
+ const backendURL = (intlayerConfig ?? (0, import_client.getConfiguration)()).editor.backendURL;
28
+ const STRIPE_API_ROUTE = `${backendURL}/api/stripe`;
29
+ const getSubscription = async (body, otherOptions = {}) => await (0, import_fetcher.fetcher)(
30
+ `${STRIPE_API_ROUTE}/create-subscription`,
31
+ authAPIOptions,
32
+ otherOptions,
33
+ {
34
+ method: "POST",
35
+ body
36
+ }
37
+ );
38
+ const cancelSubscription = async (otherOptions = {}) => await (0, import_fetcher.fetcher)(
39
+ `${STRIPE_API_ROUTE}/cancel-subscription`,
40
+ authAPIOptions,
41
+ otherOptions,
42
+ {
43
+ method: "POST"
44
+ }
45
+ );
46
+ return {
47
+ getSubscription,
48
+ cancelSubscription
49
+ };
50
+ };
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ getStripeAPI
54
+ });
55
+ //# sourceMappingURL=stripe.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/stripe.ts"],"sourcesContent":["import type {\n GetCheckoutSessionBody,\n GetCheckoutSessionResult,\n // @ts-ignore @intlayer/backend not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from './fetcher';\n\nexport const getStripeAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = (intlayerConfig ?? getConfiguration()).editor.backendURL;\n const STRIPE_API_ROUTE = `${backendURL}/api/stripe`;\n\n /**\n * Retrieves a checkout session.\n * @param body - Checkout session body.\n */\n const getSubscription = async (\n body?: GetCheckoutSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/create-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Cancels a subscription.\n * @param body - Checkout session body.\n */\n const cancelSubscription = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/cancel-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getSubscription,\n cancelSubscription,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAsD;AACtD,qBAA6C;AAEtC,MAAM,eAAe,CAC1B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,cAAc,sBAAkB,gCAAiB,GAAG,OAAO;AACjE,QAAM,mBAAmB,GAAG,UAAU;AAMtC,QAAM,kBAAkB,OACtB,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,gBAAgB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAMF,QAAM,qBAAqB,OAAO,eAA+B,CAAC,MAChE,UAAM;AAAA,IACJ,GAAG,gBAAgB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
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 tag_exports = {};
20
+ __export(tag_exports, {
21
+ getTagAPI: () => getTagAPI,
22
+ tagAPI: () => tagAPI
23
+ });
24
+ module.exports = __toCommonJS(tag_exports);
25
+ var import_client = require("@intlayer/config/client");
26
+ var import_fetcher = require('./fetcher.cjs');
27
+ const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
28
+ const { backendURL } = (intlayerConfig ?? (0, import_client.getConfiguration)()).editor;
29
+ const PROJECT_API_ROUTE = `${backendURL}/api/tag`;
30
+ const getTags = async (filters, otherOptions = {}) => await (0, import_fetcher.fetcher)(
31
+ PROJECT_API_ROUTE,
32
+ authAPIOptions,
33
+ otherOptions,
34
+ {
35
+ params: filters
36
+ }
37
+ );
38
+ const addTag = async (tag, otherOptions = {}) => await (0, import_fetcher.fetcher)(
39
+ `${PROJECT_API_ROUTE}`,
40
+ authAPIOptions,
41
+ otherOptions,
42
+ {
43
+ method: "POST",
44
+ body: tag
45
+ }
46
+ );
47
+ const updateTag = async (tagId, tag, otherOptions = {}) => await (0, import_fetcher.fetcher)(
48
+ `${PROJECT_API_ROUTE}/${tagId}`,
49
+ authAPIOptions,
50
+ otherOptions,
51
+ {
52
+ method: "PUT",
53
+ body: tag
54
+ }
55
+ );
56
+ const deleteTag = async (tagId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
57
+ `${PROJECT_API_ROUTE}/${tagId}`,
58
+ authAPIOptions,
59
+ otherOptions,
60
+ {
61
+ method: "DELETE"
62
+ }
63
+ );
64
+ return {
65
+ getTags,
66
+ addTag,
67
+ updateTag,
68
+ deleteTag
69
+ };
70
+ };
71
+ const tagAPI = getTagAPI();
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ getTagAPI,
75
+ tagAPI
76
+ });
77
+ //# sourceMappingURL=tag.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/tag.ts"],"sourcesContent":["import type {\n AddTagBody,\n AddTagResult,\n DeleteTagParams,\n DeleteTagResult,\n GetTagsParams,\n GetTagsResult,\n UpdateTagBody,\n UpdateTagParams,\n UpdateTagResult,\n // @ts-ignore @intlayer/backend not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from './fetcher';\n\nexport const getTagAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { backendURL } = (intlayerConfig ?? getConfiguration()).editor;\n const PROJECT_API_ROUTE = `${backendURL}/api/tag`;\n\n /**\n * Retrieves a list of tags based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getTags = async (\n filters?: GetTagsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetTagsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Adds a new tag to the database.\n * @param tag - Tag data.\n */\n const addTag = async (tag: AddTagBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<AddTagResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: tag,\n }\n );\n\n /**\n * Updates an existing tag in the database.\n * @param tag - Updated tag data.\n */\n const updateTag = async (\n tagId: UpdateTagParams['tagId'],\n tag: UpdateTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: tag,\n }\n );\n\n /**\n * Deletes a tag from the database by its ID.\n * @param tagId - Tag ID.\n */\n const deleteTag = async (\n tagId: DeleteTagParams['tagId'],\n\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n getTags,\n addTag,\n updateTag,\n deleteTag,\n };\n};\n\nexport const tagAPI = getTagAPI();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,oBAAsD;AACtD,qBAA6C;AAEtC,MAAM,YAAY,CACvB,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,EAAE,WAAW,KAAK,sBAAkB,gCAAiB,GAAG;AAC9D,QAAM,oBAAoB,GAAG,UAAU;AAMvC,QAAM,UAAU,OACd,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,SAAS,OAAO,KAAiB,eAA+B,CAAC,MACrE,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,YAAY,OAChB,OACA,KACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,KAAK;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,YAAY,OAChB,OAEA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,KAAK;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,SAAS,UAAU;","names":[]}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
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 user_exports = {};
20
+ __export(user_exports, {
21
+ getUserAPI: () => getUserAPI,
22
+ userAPI: () => userAPI
23
+ });
24
+ module.exports = __toCommonJS(user_exports);
25
+ var import_client = require("@intlayer/config/client");
26
+ var import_fetcher = require('./fetcher.cjs');
27
+ const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
28
+ const { backendURL } = (intlayerConfig ?? (0, import_client.getConfiguration)()).editor;
29
+ const USER_API_ROUTE = `${backendURL}/api/user`;
30
+ const getUsers = async (filters, otherOptions = {}) => await (0, import_fetcher.fetcher)(
31
+ USER_API_ROUTE,
32
+ authAPIOptions,
33
+ otherOptions,
34
+ {
35
+ params: filters
36
+ }
37
+ );
38
+ const getUserById = async (userId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
39
+ `${USER_API_ROUTE}/${userId}`,
40
+ authAPIOptions,
41
+ otherOptions
42
+ );
43
+ const getUserByEmail = async (email, otherOptions = {}) => await (0, import_fetcher.fetcher)(
44
+ `${USER_API_ROUTE}/email/${email}`,
45
+ authAPIOptions,
46
+ otherOptions
47
+ );
48
+ const getUserByAccount = async (providerAccountId, provider, otherOptions = {}) => await (0, import_fetcher.fetcher)(
49
+ `${USER_API_ROUTE}/account/${provider}/${providerAccountId}`,
50
+ authAPIOptions,
51
+ otherOptions
52
+ );
53
+ const createUser = async (user, otherOptions = {}) => await (0, import_fetcher.fetcher)(
54
+ `${USER_API_ROUTE}/`,
55
+ authAPIOptions,
56
+ otherOptions,
57
+ {
58
+ method: "POST",
59
+ body: user
60
+ }
61
+ );
62
+ const updateUser = async (user, otherOptions = {}) => await (0, import_fetcher.fetcher)(
63
+ `${USER_API_ROUTE}`,
64
+ authAPIOptions,
65
+ otherOptions,
66
+ {
67
+ method: "PUT",
68
+ body: user
69
+ }
70
+ );
71
+ const deleteUser = async (userId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
72
+ `${USER_API_ROUTE}/${userId}`,
73
+ authAPIOptions,
74
+ otherOptions,
75
+ {
76
+ method: "DELETE"
77
+ }
78
+ );
79
+ return {
80
+ createUser,
81
+ getUsers,
82
+ getUserById,
83
+ getUserByAccount,
84
+ getUserByEmail,
85
+ updateUser,
86
+ deleteUser
87
+ };
88
+ };
89
+ const userAPI = getUserAPI();
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ getUserAPI,
93
+ userAPI
94
+ });
95
+ //# sourceMappingURL=user.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/user.ts"],"sourcesContent":["import type {\n CreateUserBody,\n CreateUserResult,\n GetUserByAccountParams,\n GetUserByAccountResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n UpdateUserBody,\n UpdateUserResult,\n // @ts-ignore @intlayer/backend not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from './fetcher';\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { backendURL } = (intlayerConfig ?? getConfiguration()).editor;\n const USER_API_ROUTE = `${backendURL}/api/user`;\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 USER_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\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 `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions\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 `${USER_API_ROUTE}/email/${email}`,\n authAPIOptions,\n otherOptions\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 const getUserByAccount = async (\n providerAccountId: GetUserByAccountParams['providerAccountId'],\n provider: GetUserByAccountParams['provider'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByAccountResult>(\n `${USER_API_ROUTE}/account/${provider}/${providerAccountId}`,\n authAPIOptions,\n otherOptions\n );\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 `${USER_API_ROUTE}/`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\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 `${USER_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\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 `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n createUser,\n getUsers,\n getUserById,\n getUserByAccount,\n getUserByEmail,\n updateUser,\n deleteUser,\n };\n};\n\nexport const userAPI = getUserAPI();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,oBAAsD;AACtD,qBAA6C;AAEtC,MAAM,aAAa,CACxB,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,EAAE,WAAW,KAAK,sBAAkB,gCAAiB,GAAG;AAC9D,QAAM,iBAAiB,GAAG,UAAU;AAOpC,QAAM,WAAW,OACf,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAOF,QAAM,cAAc,OAClB,QACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,cAAc,IAAI,MAAM;AAAA,IAC3B;AAAA,IACA;AAAA,EACF;AAOF,QAAM,iBAAiB,OACrB,OACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,cAAc,UAAU,KAAK;AAAA,IAChC;AAAA,IACA;AAAA,EACF;AAOF,QAAM,mBAAmB,OACvB,mBACA,UACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,cAAc,YAAY,QAAQ,IAAI,iBAAiB;AAAA,IAC1D;AAAA,IACA;AAAA,EACF;AAOF,QAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAOF,QAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAOF,QAAM,aAAa,OACjB,QACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,cAAc,IAAI,MAAM;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,UAAU,WAAW;","names":[]}
@@ -0,0 +1,64 @@
1
+ import { getConfiguration } from "@intlayer/config/client";
2
+ import { fetcher } from './fetcher.mjs';
3
+ const getAiAPI = (authAPIOptions = {}, intlayerConfig) => {
4
+ const { backendURL } = (intlayerConfig ?? getConfiguration()).editor;
5
+ const AI_API_ROUTE = `${backendURL}/api/ai`;
6
+ const auditContentDeclaration = async (body, otherOptions = {}) => await fetcher(
7
+ `${AI_API_ROUTE}/audit/content-declaration`,
8
+ authAPIOptions,
9
+ otherOptions,
10
+ {
11
+ method: "POST",
12
+ body
13
+ }
14
+ );
15
+ const auditContentDeclarationField = async (body, otherOptions = {}) => await fetcher(
16
+ `${AI_API_ROUTE}/audit/content-declaration/field`,
17
+ authAPIOptions,
18
+ otherOptions,
19
+ {
20
+ method: "POST",
21
+ body
22
+ }
23
+ );
24
+ const auditContentDeclarationMetadata = async (body, otherOptions = {}) => await fetcher(
25
+ `${AI_API_ROUTE}/audit/content-declaration/metadata`,
26
+ authAPIOptions,
27
+ otherOptions,
28
+ {
29
+ method: "POST",
30
+ body
31
+ }
32
+ );
33
+ const auditTag = async (body, otherOptions = {}) => await fetcher(
34
+ `${AI_API_ROUTE}/audit/tag`,
35
+ authAPIOptions,
36
+ otherOptions,
37
+ {
38
+ method: "POST",
39
+ body
40
+ }
41
+ );
42
+ const askDocQuestion = async (body, otherOptions = {}) => await fetcher(
43
+ `${AI_API_ROUTE}/ask`,
44
+ authAPIOptions,
45
+ otherOptions,
46
+ {
47
+ method: "POST",
48
+ body
49
+ }
50
+ );
51
+ return {
52
+ auditContentDeclaration,
53
+ auditContentDeclarationField,
54
+ auditContentDeclarationMetadata,
55
+ auditTag,
56
+ askDocQuestion
57
+ };
58
+ };
59
+ const userAPI = getAiAPI();
60
+ export {
61
+ getAiAPI,
62
+ userAPI
63
+ };
64
+ //# sourceMappingURL=ai.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ai.ts"],"sourcesContent":["import type {\n AuditContentDeclarationBody,\n AuditContentDeclarationFieldBody,\n AuditContentDeclarationFieldResult,\n AuditContentDeclarationMetadataBody,\n AuditContentDeclarationMetadataResult,\n AuditContentDeclarationResult,\n AuditTagBody,\n AuditTagResult,\n AskDocQuestionBody,\n AskDocQuestionResult,\n // @ts-ignore @intlayer/backend not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from './fetcher';\n\nexport const getAiAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { backendURL } = (intlayerConfig ?? getConfiguration()).editor;\n const AI_API_ROUTE = `${backendURL}/api/ai`;\n\n /**\n * Audits a content declaration file\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclaration = async (\n body?: AuditContentDeclarationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationResult>(\n `${AI_API_ROUTE}/audit/content-declaration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration field\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationField = async (\n body?: AuditContentDeclarationFieldBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationFieldResult>(\n `${AI_API_ROUTE}/audit/content-declaration/field`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a content declaration file to retrieve title, description and tags\n * @param body - Audit file parameters.\n * @returns Audited file content.\n */\n const auditContentDeclarationMetadata = async (\n body?: AuditContentDeclarationMetadataBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditContentDeclarationMetadataResult>(\n `${AI_API_ROUTE}/audit/content-declaration/metadata`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Audits a tag\n * @param body - Audit tag parameters.\n * @returns Audited tag content.\n */\n const auditTag = async (\n body?: AuditTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AuditTagResult>(\n `${AI_API_ROUTE}/audit/tag`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n /**\n * Asks a question to the AI related to the documentation\n */\n const askDocQuestion = async (\n body?: AskDocQuestionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AskDocQuestionResult>(\n `${AI_API_ROUTE}/ask`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: body,\n }\n );\n\n return {\n auditContentDeclaration,\n auditContentDeclarationField,\n auditContentDeclarationMetadata,\n auditTag,\n askDocQuestion,\n };\n};\n\nexport const userAPI = getAiAPI();\n"],"mappings":"AAaA,SAAS,wBAA6C;AACtD,SAAS,eAAoC;AAEtC,MAAM,WAAW,CACtB,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,EAAE,WAAW,KAAK,kBAAkB,iBAAiB,GAAG;AAC9D,QAAM,eAAe,GAAG,UAAU;AAOlC,QAAM,0BAA0B,OAC9B,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,+BAA+B,OACnC,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,kCAAkC,OACtC,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAOF,QAAM,WAAW,OACf,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAKF,QAAM,iBAAiB,OACrB,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,YAAY;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,UAAU,SAAS;","names":[]}
@@ -0,0 +1,141 @@
1
+ import { getConfiguration } from "@intlayer/config/client";
2
+ import { fetcher } from './fetcher.mjs';
3
+ const getAuthAPI = (authAPIOptions = {}, intlayerConfig) => {
4
+ const { backendURL, clientId, clientSecret } = (intlayerConfig ?? getConfiguration()).editor;
5
+ const AUTH_API_ROUTE = `${backendURL}/api/auth`;
6
+ const login = async (user, otherOptions = {}) => await fetcher(
7
+ `${AUTH_API_ROUTE}/login`,
8
+ authAPIOptions,
9
+ otherOptions,
10
+ {
11
+ method: "POST",
12
+ body: user
13
+ }
14
+ );
15
+ const getLoginWithGitHubURL = (params) => {
16
+ const searchParams = new URLSearchParams(params);
17
+ return `${AUTH_API_ROUTE}/login/github?${searchParams.toString()}`;
18
+ };
19
+ const getLoginWithGoogleURL = (params) => {
20
+ const searchParams = new URLSearchParams(params);
21
+ return `${AUTH_API_ROUTE}/login/google?${searchParams.toString()}`;
22
+ };
23
+ const register = async (user, query = {}, otherOptions = {}) => await fetcher(
24
+ `${AUTH_API_ROUTE}/register`,
25
+ authAPIOptions,
26
+ otherOptions,
27
+ {
28
+ method: "POST",
29
+ body: user,
30
+ params: query
31
+ }
32
+ );
33
+ const logout = async (otherOptions = {}) => await fetcher(
34
+ `${AUTH_API_ROUTE}/logout`,
35
+ authAPIOptions,
36
+ otherOptions,
37
+ {
38
+ method: "POST"
39
+ }
40
+ );
41
+ const askResetPassword = async (email, otherOptions = {}) => await fetcher(
42
+ `${AUTH_API_ROUTE}/password/reset`,
43
+ authAPIOptions,
44
+ otherOptions,
45
+ {
46
+ method: "POST",
47
+ body: { email }
48
+ }
49
+ );
50
+ const resetPassword = async (params, otherOptions = {}) => await fetcher(
51
+ `${AUTH_API_ROUTE}/password/reset`,
52
+ authAPIOptions,
53
+ otherOptions,
54
+ { params, method: "POST" }
55
+ );
56
+ const changePassword = async (data, otherOptions = {}) => await fetcher(
57
+ `${AUTH_API_ROUTE}/password`,
58
+ authAPIOptions,
59
+ otherOptions,
60
+ {
61
+ method: "PUT",
62
+ body: data
63
+ }
64
+ );
65
+ const checkIfUserHasPassword = async (otherOptions = {}) => await fetcher(
66
+ `${AUTH_API_ROUTE}/password/has`,
67
+ authAPIOptions,
68
+ otherOptions,
69
+ {
70
+ method: "GET"
71
+ }
72
+ );
73
+ const verifyEmail = async ({ userId, secret }, otherOptions = {}) => await fetcher(
74
+ `${AUTH_API_ROUTE}/active/${userId}/${secret}`,
75
+ authAPIOptions,
76
+ otherOptions,
77
+ {
78
+ method: "PUT"
79
+ }
80
+ );
81
+ const getVerifyEmailStatusURL = (userId) => `${AUTH_API_ROUTE}/verify-email-status/${String(userId)}`;
82
+ const createSession = async (data, otherOptions = {}) => await fetcher(
83
+ `${AUTH_API_ROUTE}/session`,
84
+ authAPIOptions,
85
+ otherOptions,
86
+ {
87
+ method: "POST",
88
+ body: data
89
+ }
90
+ );
91
+ const getSession = async (sessionToken, otherOptions = {}) => await fetcher(
92
+ `${backendURL}/session`,
93
+ authAPIOptions,
94
+ otherOptions,
95
+ { params: { session_token: sessionToken } }
96
+ );
97
+ const getCSRFToken = async (otherOptions = {}) => await fetcher(
98
+ `${backendURL}/csrf-token`,
99
+ authAPIOptions,
100
+ otherOptions
101
+ );
102
+ const getOAuth2AccessToken = async (otherOptions = {}) => await fetcher(
103
+ `${backendURL}/oauth2/token`,
104
+ authAPIOptions,
105
+ otherOptions,
106
+ {
107
+ method: "POST",
108
+ headers: {
109
+ "Content-Type": "application/x-www-form-urlencoded"
110
+ },
111
+ body: {
112
+ grant_type: "client_credentials",
113
+ client_id: clientId,
114
+ client_secret: clientSecret
115
+ }
116
+ }
117
+ );
118
+ return {
119
+ login,
120
+ getLoginWithGitHubURL,
121
+ getLoginWithGoogleURL,
122
+ register,
123
+ logout,
124
+ resetPassword,
125
+ askResetPassword,
126
+ checkIfUserHasPassword,
127
+ verifyEmail,
128
+ getVerifyEmailStatusURL,
129
+ changePassword,
130
+ createSession,
131
+ getSession,
132
+ getCSRFToken,
133
+ getOAuth2AccessToken
134
+ };
135
+ };
136
+ const authAPI = getAuthAPI();
137
+ export {
138
+ authAPI,
139
+ getAuthAPI
140
+ };
141
+ //# sourceMappingURL=auth.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/auth.ts"],"sourcesContent":["import type {\n AskResetPasswordBody,\n AskResetPasswordResult,\n CreateSessionBody,\n CreateSessionResult,\n GetSessionInformationQuery,\n GithubLoginQueryParams,\n GoogleLoginQueryParams,\n GetSessionInformationResult,\n LoginBody,\n LoginResult,\n RegisterBody,\n RegisterQuery,\n RegisterResult,\n ResetPasswordParams,\n ResetPasswordResult,\n UpdatePasswordBody,\n UpdatePasswordResult,\n ValidEmailParams,\n ValidEmailResult,\n SetCSRFTokenResult,\n GetOAuth2TokenBody,\n GetOAuth2TokenResult,\n UserAPI,\n CheckIfUserHasPasswordResult,\n // @ts-ignore @intlayer/backend not build yet\n} from '@intlayer/backend';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from './fetcher';\n\nexport const getAuthAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const { backendURL, clientId, clientSecret } = (\n intlayerConfig ?? getConfiguration()\n ).editor;\n const AUTH_API_ROUTE = `${backendURL}/api/auth`;\n\n /**\n * Logs in a user with the provided credentials.\n * @param user - User credentials.\n */\n const login = async (user: LoginBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<LoginResult>(\n `${AUTH_API_ROUTE}/login`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Gets the login with GitHub URL.\n * @param params - The parameters for the login with GitHub URL.\n * @returns The login with GitHub URL.\n */\n const getLoginWithGitHubURL = (params: GithubLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/github?${searchParams.toString()}`;\n };\n\n /**\n * Gets the login with Google URL.\n * @param params - The parameters for the login with Google URL.\n * @returns The login with Google URL.\n */\n const getLoginWithGoogleURL = (params: GoogleLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/google?${searchParams.toString()}`;\n };\n\n /**\n * Registers a new user with the provided credentials.\n * @param user - User credentials.\n * @returns User object.\n */\n const register = async (\n user: RegisterBody,\n query: RegisterQuery = {},\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RegisterResult>(\n `${AUTH_API_ROUTE}/register`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n params: query,\n }\n );\n\n /**\n * Signs out the user.\n * @returns User object.\n */\n const logout = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<void>(\n `${AUTH_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Ask to resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const askResetPassword = async (\n email: AskResetPasswordBody['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AskResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { email },\n }\n );\n\n /**\n * Resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const resetPassword = async (\n params: ResetPasswordParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n { params, method: 'POST' }\n );\n\n /**\n * Changes the password of a user with the provided data.\n * @param data - New password and confirmation.\n * @returns User object.\n */\n const changePassword = async (\n data: UpdatePasswordBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdatePasswordResult>(\n `${AUTH_API_ROUTE}/password`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: data,\n }\n );\n\n /**\n * Checks if a user has a password.\n * @param params - User ID.\n * @returns User object.\n */\n const checkIfUserHasPassword = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<CheckIfUserHasPasswordResult>(\n `${AUTH_API_ROUTE}/password/has`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Verifies the email address of a user with the provided token.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const verifyEmail = async (\n { userId, secret }: ValidEmailParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ValidEmailResult>(\n `${AUTH_API_ROUTE}/active/${userId}/${secret}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\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 `${AUTH_API_ROUTE}/verify-email-status/${String(userId)}`;\n\n /**\n * Creates a session for a user.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const createSession = async (\n data: CreateSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateSessionResult>(\n `${AUTH_API_ROUTE}/session`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: data,\n }\n );\n\n /**\n * Gets a session and user.\n * @param sessionToken - Session token.\n * @param otherOptions - Fetcher options.\n * @returns Session and user information.\n */\n const getSession = async (\n sessionToken?: GetSessionInformationQuery['session_token'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetSessionInformationResult>(\n `${backendURL}/session`,\n authAPIOptions,\n otherOptions,\n { params: { session_token: sessionToken } }\n );\n\n /**\n * Gets the CSRF token.\n * @param otherOptions - Fetcher options.\n * @returns The CSRF token.\n */\n const getCSRFToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<SetCSRFTokenResult>(\n `${backendURL}/csrf-token`,\n authAPIOptions,\n otherOptions\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 authAPIOptions,\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 login,\n getLoginWithGitHubURL,\n getLoginWithGoogleURL,\n register,\n logout,\n resetPassword,\n askResetPassword,\n checkIfUserHasPassword,\n verifyEmail,\n getVerifyEmailStatusURL,\n changePassword,\n createSession,\n getSession,\n getCSRFToken,\n getOAuth2AccessToken,\n };\n};\n\nexport const authAPI = getAuthAPI();\n"],"mappings":"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","names":[]}