@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
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright
52
+ owner or by an individual or Legal Entity authorized to submit on
53
+ behalf of the copyright owner. For the purposes of this definition,
54
+ "submitted" means any form of electronic, verbal, or written
55
+ communication sent to the Licensor or its representatives, including
56
+ but not limited to communication on electronic mailing lists, source
57
+ code control systems, and issue tracking systems that are managed by,
58
+ or on behalf of, the Licensor for the purpose of discussing and improving
59
+ the Work, but excluding communication that is conspicuously marked or
60
+ otherwise designated in writing by the copyright owner as "Not a
61
+ Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024 Aymeric PINEAU
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,240 @@
1
+ <div align="center">
2
+ <a href="https://www.npmjs.com/package/intlayer">
3
+ <img src="https://raw.githubusercontent.com/aymericzip/intlayer/572ae9c9acafb74307b81530c1931a8e98990aef/docs/assets/logo.png" width="500" alt="intlayer" />
4
+ </a>
5
+ </div>
6
+
7
+ <div align="center">
8
+ <a href="https://www.npmjs.com/package/intlayer">
9
+ <img alt="npm" src="https://img.shields.io/npm/v/intlayer.svg?labelColor=49516F&color=8994BC" />
10
+ </a>
11
+ <a href="https://npmjs.org/package/intlayer">
12
+ <img alt="downloads" src="https://badgen.net/npm/dm/intlayer?labelColor=49516F&color=8994BC" />
13
+ </a>
14
+ <a href="https://npmjs.org/package/intlayer">
15
+ <img alt="types included" src="https://badgen.net/npm/types/intlayer?labelColor=49516F&color=8994BC"
16
+ />
17
+ </a>
18
+ </div>
19
+
20
+ # Intlayer: Next-Level Content Management in JavaScript
21
+
22
+ **Intlayer** is an internationalization library designed specifically for JavaScript developers. It allow the declaration of your content everywhere in your code. It converts declaration of multilingual content into structured dictionaries to integrate easily in your code. Using TypeScript, **Intlayer** make your development stronger and more efficient.
23
+
24
+ ## Example of usage
25
+
26
+ ```bash
27
+ .
28
+ ├── ClientComponent
29
+ │   ├── index.content.ts
30
+ │   └── index.tsx
31
+ └── ServerComponent
32
+    ├── index.content.ts
33
+    └── index.tsx
34
+ ```
35
+
36
+ ```tsx
37
+ // ./ClientComponent/index.content.ts
38
+
39
+ import { type DeclarationContent, t } from "intlayer";
40
+
41
+ const clientComponentContent = {
42
+ key: "client-component",
43
+ content: {
44
+ myTranslatedContent: t({
45
+ en: "Hello World",
46
+ fr: "Bonjour le monde",
47
+ es: "Hola Mundo",
48
+ }),
49
+ },
50
+ } satisfies DeclarationContent;
51
+
52
+ export default clientComponentContent;
53
+ ```
54
+
55
+ ```tsx
56
+ // ./ClientComponent/index.tsx
57
+ "use client";
58
+
59
+ import { useIntlayer } from "next-intlayer";
60
+
61
+ export const ClientComponent = () => {
62
+ const { myTranslatedContent } = useIntlayer("client-component");
63
+
64
+ return <span>{myTranslatedContent}</span>;
65
+ };
66
+ ```
67
+
68
+ ## Why Choose Intlayer?
69
+
70
+ - **JavaScript-Powered Content Management**: Harness the flexibility of JavaScript to define and manage your content efficiently.
71
+ - **Type-Safe Environment**: Leverage TypeScript to ensure all your content definitions are precise and error-free.
72
+ - **Integrated Content Files**: Keep your translations close to their respective components, enhancing maintainability and clarity.
73
+
74
+ ## intlayer package
75
+
76
+ `intlayer` package intend to declare your content in a structured way, using JavaScript.
77
+
78
+ To build dictionaries from this declaration, you can use [intlayer-cli](https://github.com/aymericzip/intlayer/blob/main/packages/intlayer-cli/readme.md).
79
+ And to interpret intlayer dictionaries you can interpreters, such as [react-intlayer](https://github.com/aymericzip/intlayer/blob/main/packages/react-intlayer/README.md) [next-intlayer](https://github.com/aymericzip/intlayer/blob/main/packages/next-intlayer/README.md)
80
+
81
+ ## Getting Started with Intlayer
82
+
83
+ [See how to use intlayer with NextJS](https://github.com/aymericzip/intlayer/blob/main/README.md)
84
+
85
+ ### Install Package
86
+
87
+ Install the necessary packages using npm:
88
+
89
+ ```bash
90
+ npm install intlayer
91
+ ```
92
+
93
+ ```bash
94
+ yarn add intlayer
95
+ ```
96
+
97
+ ```bash
98
+ pnpm add intlayer
99
+ ```
100
+
101
+ ### Manage Your Content
102
+
103
+ Create and manage your content dictionaries:
104
+
105
+ #### Using typescript
106
+
107
+ ```typescript
108
+ // src/app/[locale]/page.content.ts
109
+ import { t, enu, type DeclarationContent } from "intlayer";
110
+
111
+ const pageContent = {
112
+ key: "page",
113
+ content: {
114
+ getStarted: {
115
+ main: t({
116
+ en: "Get started by editing",
117
+ fr: "Commencez par éditer",
118
+ es: "Comience por editar",
119
+ }),
120
+ pageLink: "src/app/page.tsx",
121
+ },
122
+ nestedContent: {
123
+ id: "enumeration",
124
+ numberOfCar: enu({
125
+ "<-1": "Less than minus one car",
126
+ "-1": "Minus one car",
127
+ "0": "No cars",
128
+ "1": "One car",
129
+ ">5": "Some cars",
130
+ ">19": "Many cars",
131
+ }),
132
+ },
133
+ },
134
+ } satisfies DeclarationContent;
135
+
136
+ // Content should be exported as default
137
+ export default pageContent;
138
+ ```
139
+
140
+ #### Using ECMAScript modules
141
+
142
+ ```javascript
143
+ // src/app/[locale]/page.content.mjs
144
+
145
+ import { t } from "intlayer";
146
+
147
+ /** @type {import('intlayer').DeclarationContent} */
148
+ const pageContent = {
149
+ "key": "page",
150
+ getStarted: {
151
+ main: t({
152
+ en: "Get started by editing",
153
+ fr: "Commencez par éditer",
154
+ es: "Comience por editar",
155
+ }),
156
+ pageLink: "src/app/page.tsx",
157
+ },
158
+ nestedContent: {
159
+ id: "enumeration",
160
+ numberOfCar: enu({
161
+ "<-1": "Less than minus one car",
162
+ "-1": "Minus one car",
163
+ 0: "No cars",
164
+ 1: "One car",
165
+ ">5": "Some cars",
166
+ ">19": "Many cars",
167
+ }),
168
+ },
169
+ };
170
+
171
+ // Content should be exported as default
172
+ export default pageContent;
173
+ ```
174
+
175
+ #### Using CommonJS modules
176
+
177
+ ```javascript
178
+ // src/app/[locale]/page.content.cjs
179
+
180
+ const { t } = require("intlayer");
181
+
182
+ /** @type {import('intlayer').DeclarationContent} */
183
+ const pageContent = {
184
+ "key": "page",
185
+ getStarted: {
186
+ main: t({
187
+ en: "Get started by editing",
188
+ fr: "Commencez par éditer",
189
+ es: "Comience por editar",
190
+ }),
191
+ pageLink: "src/app/page.tsx",
192
+ },
193
+ nestedContent: {
194
+ id: "enumeration",
195
+ numberOfCar: enu({
196
+ "<-1": "Less than minus one car",
197
+ "-1": "Minus one car",
198
+ 0: "No cars",
199
+ 1: "One car",
200
+ ">5": "Some cars",
201
+ ">19": "Many cars",
202
+ }),
203
+ },
204
+ };
205
+
206
+ // Content should be exported as default
207
+ module.exports = pageContent;
208
+ ```
209
+
210
+ #### Using JSON
211
+
212
+ ```json5
213
+ // src/app/[locale]/page.content.json
214
+ {
215
+ "key": "page",
216
+ getStarted: {
217
+ main: {
218
+ nodeType: "translation",
219
+ en: "Get started by editing",
220
+ fr: "Commencez par éditer",
221
+ es: "Comience por editar",
222
+ },
223
+ pageLink: "src/app/page.tsx",
224
+ },
225
+ nestedContent: {
226
+ id: "enumeration",
227
+ nodeType: "enumeration",
228
+ numberOfCar: {
229
+ "<-1": "Less than minus one car",
230
+ "-1": "Minus one car",
231
+ "0": "No cars",
232
+ "1": "One car",
233
+ ">5": "Some cars",
234
+ ">19": "Many cars",
235
+ },
236
+ },
237
+ }
238
+ ```
239
+
240
+ This version emphasizes ease of use, practical steps, and the professional application of Intlayer in a Next.js environment.
@@ -0,0 +1,89 @@
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 ai_exports = {};
20
+ __export(ai_exports, {
21
+ getAiAPI: () => getAiAPI,
22
+ userAPI: () => userAPI
23
+ });
24
+ module.exports = __toCommonJS(ai_exports);
25
+ var import_client = require("@intlayer/config/client");
26
+ var import_fetcher = require('./fetcher.cjs');
27
+ const getAiAPI = (authAPIOptions = {}, intlayerConfig) => {
28
+ const { backendURL } = (intlayerConfig ?? (0, import_client.getConfiguration)()).editor;
29
+ const AI_API_ROUTE = `${backendURL}/api/ai`;
30
+ const auditContentDeclaration = async (body, otherOptions = {}) => await (0, import_fetcher.fetcher)(
31
+ `${AI_API_ROUTE}/audit/content-declaration`,
32
+ authAPIOptions,
33
+ otherOptions,
34
+ {
35
+ method: "POST",
36
+ body
37
+ }
38
+ );
39
+ const auditContentDeclarationField = async (body, otherOptions = {}) => await (0, import_fetcher.fetcher)(
40
+ `${AI_API_ROUTE}/audit/content-declaration/field`,
41
+ authAPIOptions,
42
+ otherOptions,
43
+ {
44
+ method: "POST",
45
+ body
46
+ }
47
+ );
48
+ const auditContentDeclarationMetadata = async (body, otherOptions = {}) => await (0, import_fetcher.fetcher)(
49
+ `${AI_API_ROUTE}/audit/content-declaration/metadata`,
50
+ authAPIOptions,
51
+ otherOptions,
52
+ {
53
+ method: "POST",
54
+ body
55
+ }
56
+ );
57
+ const auditTag = async (body, otherOptions = {}) => await (0, import_fetcher.fetcher)(
58
+ `${AI_API_ROUTE}/audit/tag`,
59
+ authAPIOptions,
60
+ otherOptions,
61
+ {
62
+ method: "POST",
63
+ body
64
+ }
65
+ );
66
+ const askDocQuestion = async (body, otherOptions = {}) => await (0, import_fetcher.fetcher)(
67
+ `${AI_API_ROUTE}/ask`,
68
+ authAPIOptions,
69
+ otherOptions,
70
+ {
71
+ method: "POST",
72
+ body
73
+ }
74
+ );
75
+ return {
76
+ auditContentDeclaration,
77
+ auditContentDeclarationField,
78
+ auditContentDeclarationMetadata,
79
+ auditTag,
80
+ askDocQuestion
81
+ };
82
+ };
83
+ const userAPI = getAiAPI();
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ getAiAPI,
87
+ userAPI
88
+ });
89
+ //# sourceMappingURL=ai.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,oBAAsD;AACtD,qBAA6C;AAEtC,MAAM,WAAW,CACtB,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,EAAE,WAAW,KAAK,sBAAkB,gCAAiB,GAAG;AAC9D,QAAM,eAAe,GAAG,UAAU;AAOlC,QAAM,0BAA0B,OAC9B,MACA,eAA+B,CAAC,MAEhC,UAAM;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,UAAM;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,UAAM;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,UAAM;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,UAAM;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":[]}