@intlayer/ai 7.5.2 → 7.5.4
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/auditDictionaryMetadata/index.cjs +7 -7
- package/dist/cjs/auditDictionaryMetadata/index.cjs.map +1 -1
- package/dist/cjs/translateJSON/index.cjs +10 -10
- package/dist/cjs/translateJSON/index.cjs.map +1 -1
- package/dist/esm/auditDictionaryMetadata/index.mjs +7 -7
- package/dist/esm/auditDictionaryMetadata/index.mjs.map +1 -1
- package/dist/esm/translateJSON/index.mjs +10 -10
- package/dist/esm/translateJSON/index.mjs.map +1 -1
- package/package.json +7 -6
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/errors.cjs +0 -30
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/errors.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/iso.cjs +0 -41
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/iso.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/parse.cjs +0 -31
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/parse.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/schemas.cjs +0 -577
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/schemas.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/api.cjs +0 -535
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/api.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/checks.cjs +0 -376
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/checks.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/core.cjs +0 -67
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/core.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/doc.cjs +0 -35
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/doc.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/errors.cjs +0 -66
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/errors.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/json-schema-processors.cjs +0 -239
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/json-schema-processors.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/parse.cjs +0 -123
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/parse.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/regexes.cjs +0 -88
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/regexes.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/registries.cjs +0 -54
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/registries.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/schemas.cjs +0 -1048
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/schemas.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/to-json-schema.cjs +0 -263
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/to-json-schema.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/util.cjs +0 -350
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/util.cjs.map +0 -1
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/versions.cjs +0 -11
- package/dist/cjs/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/versions.cjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/errors.mjs +0 -30
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/errors.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/iso.mjs +0 -38
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/iso.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/parse.mjs +0 -20
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/parse.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/schemas.mjs +0 -571
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/schemas.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/api.mjs +0 -478
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/api.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/checks.mjs +0 -361
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/checks.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/core.mjs +0 -62
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/core.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/doc.mjs +0 -34
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/doc.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/errors.mjs +0 -63
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/errors.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/json-schema-processors.mjs +0 -219
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/json-schema-processors.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/parse.mjs +0 -110
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/parse.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/regexes.mjs +0 -61
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/regexes.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/registries.mjs +0 -53
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/registries.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/schemas.mjs +0 -1002
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/schemas.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/to-json-schema.mjs +0 -261
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/to-json-schema.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/util.mjs +0 -317
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/util.mjs.map +0 -1
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/versions.mjs +0 -10
- package/dist/esm/node_modules/.bun/zod@4.2.1/node_modules/zod/v4/core/versions.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require__utils_asset = require('../_virtual/_utils_asset.cjs');
|
|
2
|
-
const require_schemas = require('../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/schemas.cjs');
|
|
3
2
|
let ai = require("ai");
|
|
3
|
+
let zod = require("zod");
|
|
4
4
|
|
|
5
5
|
//#region src/auditDictionaryMetadata/index.ts
|
|
6
6
|
const aiDefaultOptions = {};
|
|
@@ -14,12 +14,12 @@ const auditDictionaryMetadata = async ({ fileContent, tags, aiConfig, applicatio
|
|
|
14
14
|
const EXAMPLE_REQUEST = require__utils_asset.readAsset("./EXAMPLE_REQUEST.md");
|
|
15
15
|
const EXAMPLE_RESPONSE = require__utils_asset.readAsset("./EXAMPLE_RESPONSE.md");
|
|
16
16
|
const prompt = CHAT_GPT_PROMPT.replace("{{applicationContext}}", applicationContext ?? "").replace("{{tags}}", tags ? JSON.stringify(tags.map(({ key, description }) => `- ${key}: ${description}`).join("\n\n"), null, 2) : "");
|
|
17
|
-
const { object
|
|
17
|
+
const { object, usage } = await (0, ai.generateObject)({
|
|
18
18
|
...aiConfig,
|
|
19
|
-
schema:
|
|
20
|
-
title:
|
|
21
|
-
description:
|
|
22
|
-
tags:
|
|
19
|
+
schema: zod.z.object({
|
|
20
|
+
title: zod.z.string(),
|
|
21
|
+
description: zod.z.string(),
|
|
22
|
+
tags: zod.z.array(zod.z.string())
|
|
23
23
|
}),
|
|
24
24
|
messages: [
|
|
25
25
|
{
|
|
@@ -41,7 +41,7 @@ const auditDictionaryMetadata = async ({ fileContent, tags, aiConfig, applicatio
|
|
|
41
41
|
]
|
|
42
42
|
});
|
|
43
43
|
return {
|
|
44
|
-
fileContent: object
|
|
44
|
+
fileContent: object,
|
|
45
45
|
tokenUsed: usage?.totalTokens ?? 0
|
|
46
46
|
};
|
|
47
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["aiDefaultOptions: AIOptions","readAsset","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["aiDefaultOptions: AIOptions","readAsset","z"],"sources":["../../../src/auditDictionaryMetadata/index.ts"],"sourcesContent":["import { readAsset } from 'utils:asset';\nimport { generateObject } from 'ai';\nimport { z } from 'zod';\nimport type { AIConfig, AIOptions } from '../aiSdk';\n\ntype Tag = {\n key: string;\n description?: string;\n};\n\nexport type AuditDictionaryMetadataOptions = {\n fileContent: string;\n tags?: Tag[];\n aiConfig: AIConfig;\n applicationContext?: string;\n};\n\nexport type AuditFileResultData = {\n fileContent: {\n title: string;\n description: string;\n tags: string[];\n };\n tokenUsed: number;\n};\n\nexport const aiDefaultOptions: AIOptions = {\n // Keep default options\n};\n\n/**\n * Audits a content declaration file by constructing a prompt for AI models.\n * The prompt includes details about the project's locales, file paths of content declarations,\n * and requests for identifying issues or inconsistencies.\n */\nexport const auditDictionaryMetadata = async ({\n fileContent,\n tags,\n aiConfig,\n applicationContext,\n}: AuditDictionaryMetadataOptions): Promise<\n AuditFileResultData | undefined\n> => {\n const CHAT_GPT_PROMPT = readAsset('./PROMPT.md');\n const EXAMPLE_REQUEST = readAsset('./EXAMPLE_REQUEST.md');\n const EXAMPLE_RESPONSE = readAsset('./EXAMPLE_RESPONSE.md');\n\n // Prepare the prompt for AI by replacing placeholders with actual values.\n const prompt = CHAT_GPT_PROMPT.replace(\n '{{applicationContext}}',\n applicationContext ?? ''\n ).replace(\n '{{tags}}',\n tags\n ? JSON.stringify(\n tags\n .map(({ key, description }) => `- ${key}: ${description}`)\n .join('\\n\\n'),\n null,\n 2\n )\n : ''\n );\n\n // Use the AI SDK to generate the completion\n const { object, usage } = await generateObject({\n ...aiConfig,\n schema: z.object({\n title: z.string(),\n description: z.string(),\n tags: z.array(z.string()),\n }),\n messages: [\n { role: 'system', content: prompt },\n { role: 'user', content: EXAMPLE_REQUEST },\n { role: 'assistant', content: EXAMPLE_RESPONSE },\n {\n role: 'user',\n content: fileContent,\n },\n ],\n });\n\n return {\n fileContent: object,\n tokenUsed: usage?.totalTokens ?? 0,\n };\n};\n"],"mappings":";;;;;AA0BA,MAAaA,mBAA8B,EAE1C;;;;;;AAOD,MAAa,0BAA0B,OAAO,EAC5C,aACA,MACA,UACA,yBAGG;CACH,MAAM,kBAAkBC,+BAAU,cAAc;CAChD,MAAM,kBAAkBA,+BAAU,uBAAuB;CACzD,MAAM,mBAAmBA,+BAAU,wBAAwB;CAG3D,MAAM,SAAS,gBAAgB,QAC7B,0BACA,sBAAsB,GACvB,CAAC,QACA,YACA,OACI,KAAK,UACH,KACG,KAAK,EAAE,KAAK,kBAAkB,KAAK,IAAI,IAAI,cAAc,CACzD,KAAK,OAAO,EACf,MACA,EACD,GACD,GACL;CAGD,MAAM,EAAE,QAAQ,UAAU,6BAAqB;EAC7C,GAAG;EACH,QAAQC,MAAE,OAAO;GACf,OAAOA,MAAE,QAAQ;GACjB,aAAaA,MAAE,QAAQ;GACvB,MAAMA,MAAE,MAAMA,MAAE,QAAQ,CAAC;GAC1B,CAAC;EACF,UAAU;GACR;IAAE,MAAM;IAAU,SAAS;IAAQ;GACnC;IAAE,MAAM;IAAQ,SAAS;IAAiB;GAC1C;IAAE,MAAM;IAAa,SAAS;IAAkB;GAChD;IACE,MAAM;IACN,SAAS;IACV;GACF;EACF,CAAC;AAEF,QAAO;EACL,aAAa;EACb,WAAW,OAAO,eAAe;EAClC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_aiSdk = require('../aiSdk.cjs');
|
|
2
2
|
const require__utils_asset = require('../_virtual/_utils_asset.cjs');
|
|
3
|
-
const require_schemas = require('../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/schemas.cjs');
|
|
4
3
|
let ai = require("ai");
|
|
4
|
+
let zod = require("zod");
|
|
5
5
|
let _intlayer_core = require("@intlayer/core");
|
|
6
6
|
let _intlayer_types = require("@intlayer/types");
|
|
7
7
|
|
|
@@ -35,19 +35,19 @@ const getModeInstructions = (mode) => {
|
|
|
35
35
|
return "Mode: \"Review\" - Fill missing content and review existing keys from the preset content. If a key from the entry is missing in the output, it must be translated to the target language and added. If you detect misspelled content, or content that should be reformulated, correct it. If a translation is not coherent with the desired language, translate it.";
|
|
36
36
|
};
|
|
37
37
|
const jsonToZod = (content) => {
|
|
38
|
-
if (typeof content === "string") return
|
|
39
|
-
if (typeof content === "number") return
|
|
40
|
-
if (typeof content === "boolean") return
|
|
38
|
+
if (typeof content === "string") return zod.z.string();
|
|
39
|
+
if (typeof content === "number") return zod.z.number();
|
|
40
|
+
if (typeof content === "boolean") return zod.z.boolean();
|
|
41
41
|
if (Array.isArray(content)) {
|
|
42
|
-
if (content.length === 0) return
|
|
43
|
-
return
|
|
42
|
+
if (content.length === 0) return zod.z.array(zod.z.string());
|
|
43
|
+
return zod.z.array(jsonToZod(content[0]));
|
|
44
44
|
}
|
|
45
45
|
if (typeof content === "object" && content !== null) {
|
|
46
46
|
const shape = {};
|
|
47
47
|
for (const key in content) shape[key] = jsonToZod(content[key]);
|
|
48
|
-
return
|
|
48
|
+
return zod.z.object(shape);
|
|
49
49
|
}
|
|
50
|
-
return
|
|
50
|
+
return zod.z.any();
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
53
|
* TranslateJSONs a content declaration file by constructing a prompt for AI models.
|
|
@@ -59,7 +59,7 @@ const translateJSON = async ({ entryFileContent, presetOutputContent, dictionary
|
|
|
59
59
|
const formattedEntryLocale = formatLocaleWithName(entryLocale);
|
|
60
60
|
const formattedOutputLocale = formatLocaleWithName(outputLocale);
|
|
61
61
|
const prompt = promptFile.replace("{{entryLocale}}", formattedEntryLocale).replace("{{outputLocale}}", formattedOutputLocale).replace("{{presetOutputContent}}", JSON.stringify(presetOutputContent)).replace("{{dictionaryDescription}}", dictionaryDescription ?? "").replace("{{applicationContext}}", applicationContext ?? "").replace("{{tagsInstructions}}", formatTagInstructions(tags ?? [])).replace("{{modeInstructions}}", getModeInstructions(mode));
|
|
62
|
-
const { object
|
|
62
|
+
const { object, usage } = await (0, ai.generateObject)({
|
|
63
63
|
...aiConfig,
|
|
64
64
|
schema: jsonToZod(entryFileContent),
|
|
65
65
|
messages: [{
|
|
@@ -79,7 +79,7 @@ const translateJSON = async ({ entryFileContent, presetOutputContent, dictionary
|
|
|
79
79
|
}]
|
|
80
80
|
});
|
|
81
81
|
return {
|
|
82
|
-
fileContent: object
|
|
82
|
+
fileContent: object,
|
|
83
83
|
tokenUsed: usage?.totalTokens ?? 0
|
|
84
84
|
};
|
|
85
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["aiDefaultOptions: AIOptions","AIProvider","Locales","shape: Record<string, z.ZodTypeAny>","readAsset"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["aiDefaultOptions: AIOptions","AIProvider","Locales","z","shape: Record<string, z.ZodTypeAny>","readAsset"],"sources":["../../../src/translateJSON/index.ts"],"sourcesContent":["import { readAsset } from 'utils:asset';\nimport { getLocaleName } from '@intlayer/core';\nimport { type Locale, Locales } from '@intlayer/types';\nimport { generateObject } from 'ai';\nimport { z } from 'zod';\nimport { type AIConfig, type AIOptions, AIProvider } from '../aiSdk';\n\ntype Tag = {\n key: string;\n description?: string;\n};\n\nexport type TranslateJSONOptions<T = JSON> = {\n entryFileContent: T;\n presetOutputContent: Partial<T>;\n dictionaryDescription?: string;\n entryLocale: Locale;\n outputLocale: Locale;\n tags?: Tag[];\n aiConfig: AIConfig;\n mode: 'complete' | 'review';\n applicationContext?: string;\n};\n\nexport type TranslateJSONResultData<T = JSON> = {\n fileContent: T;\n tokenUsed: number;\n};\n\nexport const aiDefaultOptions: AIOptions = {\n provider: AIProvider.OPENAI,\n model: 'gpt-5-mini',\n};\n\n/**\n * Format a locale with its name.\n *\n * @param locale - The locale to format.\n * @returns A string in the format \"locale: name\", e.g. \"en: English\".\n */\nconst formatLocaleWithName = (locale: Locale): string =>\n `${locale}: ${getLocaleName(locale, Locales.ENGLISH)}`;\n\n/**\n * Formats tag instructions for the AI prompt.\n * Creates a string with all available tags and their descriptions.\n *\n * @param tags - The list of tags to format.\n * @returns A formatted string with tag instructions.\n */\nconst formatTagInstructions = (tags: Tag[]): string => {\n if (!tags || tags.length === 0) {\n return '';\n }\n\n // Prepare the tag instructions.\n return `Based on the dictionary content, identify specific tags from the list below that would be relevant:\n \n${tags.map(({ key, description }) => `- ${key}: ${description}`).join('\\n\\n')}`;\n};\n\nconst getModeInstructions = (mode: 'complete' | 'review'): string => {\n if (mode === 'complete') {\n return 'Mode: \"Complete\" - Enrich the preset content with the missing keys and values in the output locale. Do not update existing keys. Everything should be returned in the output.';\n }\n\n return 'Mode: \"Review\" - Fill missing content and review existing keys from the preset content. If a key from the entry is missing in the output, it must be translated to the target language and added. If you detect misspelled content, or content that should be reformulated, correct it. If a translation is not coherent with the desired language, translate it.';\n};\n\nconst jsonToZod = (content: any): z.ZodTypeAny => {\n // Base case: content is a string (the translation target)\n if (typeof content === 'string') {\n return z.string();\n }\n\n // Base cases: primitives often preserved in i18n files (e.g. strict numbers/booleans)\n if (typeof content === 'number') {\n return z.number();\n }\n if (typeof content === 'boolean') {\n return z.boolean();\n }\n\n // Recursive case: Array\n if (Array.isArray(content)) {\n // If array is empty, we assume array of strings as default for i18n\n if (content.length === 0) {\n return z.array(z.string());\n }\n // We assume all items in the array share the structure of the first item\n return z.array(jsonToZod(content[0]));\n }\n\n // Recursive case: Object\n if (typeof content === 'object' && content !== null) {\n const shape: Record<string, z.ZodTypeAny> = {};\n for (const key in content) {\n shape[key] = jsonToZod(content[key]);\n }\n return z.object(shape);\n }\n\n // Fallback\n return z.any();\n};\n\n/**\n * TranslateJSONs a content declaration file by constructing a prompt for AI models.\n * The prompt includes details about the project's locales, file paths of content declarations,\n * and requests for identifying issues or inconsistencies.\n */\nexport const translateJSON = async <T>({\n entryFileContent,\n presetOutputContent,\n dictionaryDescription,\n aiConfig,\n entryLocale,\n outputLocale,\n tags,\n mode,\n applicationContext,\n}: TranslateJSONOptions<T>): Promise<\n TranslateJSONResultData<T> | undefined\n> => {\n const promptFile = readAsset('./PROMPT.md');\n\n const formattedEntryLocale = formatLocaleWithName(entryLocale);\n const formattedOutputLocale = formatLocaleWithName(outputLocale);\n\n // Prepare the prompt for AI by replacing placeholders with actual values.\n const prompt = promptFile\n .replace('{{entryLocale}}', formattedEntryLocale)\n .replace('{{outputLocale}}', formattedOutputLocale)\n .replace('{{presetOutputContent}}', JSON.stringify(presetOutputContent))\n .replace('{{dictionaryDescription}}', dictionaryDescription ?? '')\n .replace('{{applicationContext}}', applicationContext ?? '')\n .replace('{{tagsInstructions}}', formatTagInstructions(tags ?? []))\n .replace('{{modeInstructions}}', getModeInstructions(mode));\n\n // Use the AI SDK to generate the completion\n const { object, usage } = await generateObject({\n ...aiConfig,\n schema: jsonToZod(entryFileContent),\n messages: [\n { role: 'system', content: prompt },\n {\n role: 'user',\n // KEY CHANGE: Explicitly repeating instructions in the user message\n content: [\n `# Translation Request`,\n `Please translate the following JSON content.`,\n `- **From:** ${formattedEntryLocale}`,\n `- **To:** ${formattedOutputLocale}`,\n ``,\n `## Entry Content:`,\n JSON.stringify(entryFileContent),\n ].join('\\n'),\n },\n ],\n });\n\n return {\n fileContent: object as T,\n tokenUsed: usage?.totalTokens ?? 0,\n };\n};\n"],"mappings":";;;;;;;;AA6BA,MAAaA,mBAA8B;CACzC,UAAUC,yBAAW;CACrB,OAAO;CACR;;;;;;;AAQD,MAAM,wBAAwB,WAC5B,GAAG,OAAO,sCAAkB,QAAQC,wBAAQ,QAAQ;;;;;;;;AAStD,MAAM,yBAAyB,SAAwB;AACrD,KAAI,CAAC,QAAQ,KAAK,WAAW,EAC3B,QAAO;AAIT,QAAO;;EAEP,KAAK,KAAK,EAAE,KAAK,kBAAkB,KAAK,IAAI,IAAI,cAAc,CAAC,KAAK,OAAO;;AAG7E,MAAM,uBAAuB,SAAwC;AACnE,KAAI,SAAS,WACX,QAAO;AAGT,QAAO;;AAGT,MAAM,aAAa,YAA+B;AAEhD,KAAI,OAAO,YAAY,SACrB,QAAOC,MAAE,QAAQ;AAInB,KAAI,OAAO,YAAY,SACrB,QAAOA,MAAE,QAAQ;AAEnB,KAAI,OAAO,YAAY,UACrB,QAAOA,MAAE,SAAS;AAIpB,KAAI,MAAM,QAAQ,QAAQ,EAAE;AAE1B,MAAI,QAAQ,WAAW,EACrB,QAAOA,MAAE,MAAMA,MAAE,QAAQ,CAAC;AAG5B,SAAOA,MAAE,MAAM,UAAU,QAAQ,GAAG,CAAC;;AAIvC,KAAI,OAAO,YAAY,YAAY,YAAY,MAAM;EACnD,MAAMC,QAAsC,EAAE;AAC9C,OAAK,MAAM,OAAO,QAChB,OAAM,OAAO,UAAU,QAAQ,KAAK;AAEtC,SAAOD,MAAE,OAAO,MAAM;;AAIxB,QAAOA,MAAE,KAAK;;;;;;;AAQhB,MAAa,gBAAgB,OAAU,EACrC,kBACA,qBACA,uBACA,UACA,aACA,cACA,MACA,MACA,yBAGG;CACH,MAAM,aAAaE,+BAAU,cAAc;CAE3C,MAAM,uBAAuB,qBAAqB,YAAY;CAC9D,MAAM,wBAAwB,qBAAqB,aAAa;CAGhE,MAAM,SAAS,WACZ,QAAQ,mBAAmB,qBAAqB,CAChD,QAAQ,oBAAoB,sBAAsB,CAClD,QAAQ,2BAA2B,KAAK,UAAU,oBAAoB,CAAC,CACvE,QAAQ,6BAA6B,yBAAyB,GAAG,CACjE,QAAQ,0BAA0B,sBAAsB,GAAG,CAC3D,QAAQ,wBAAwB,sBAAsB,QAAQ,EAAE,CAAC,CAAC,CAClE,QAAQ,wBAAwB,oBAAoB,KAAK,CAAC;CAG7D,MAAM,EAAE,QAAQ,UAAU,6BAAqB;EAC7C,GAAG;EACH,QAAQ,UAAU,iBAAiB;EACnC,UAAU,CACR;GAAE,MAAM;GAAU,SAAS;GAAQ,EACnC;GACE,MAAM;GAEN,SAAS;IACP;IACA;IACA,eAAe;IACf,aAAa;IACb;IACA;IACA,KAAK,UAAU,iBAAiB;IACjC,CAAC,KAAK,KAAK;GACb,CACF;EACF,CAAC;AAEF,QAAO;EACL,aAAa;EACb,WAAW,OAAO,eAAe;EAClC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readAsset } from "../_virtual/_utils_asset.mjs";
|
|
2
|
-
import { array, object, string } from "../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/schemas.mjs";
|
|
3
2
|
import { generateObject } from "ai";
|
|
3
|
+
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/auditDictionaryMetadata/index.ts
|
|
6
6
|
const aiDefaultOptions = {};
|
|
@@ -14,12 +14,12 @@ const auditDictionaryMetadata = async ({ fileContent, tags, aiConfig, applicatio
|
|
|
14
14
|
const EXAMPLE_REQUEST = readAsset("./EXAMPLE_REQUEST.md");
|
|
15
15
|
const EXAMPLE_RESPONSE = readAsset("./EXAMPLE_RESPONSE.md");
|
|
16
16
|
const prompt = CHAT_GPT_PROMPT.replace("{{applicationContext}}", applicationContext ?? "").replace("{{tags}}", tags ? JSON.stringify(tags.map(({ key, description }) => `- ${key}: ${description}`).join("\n\n"), null, 2) : "");
|
|
17
|
-
const { object
|
|
17
|
+
const { object, usage } = await generateObject({
|
|
18
18
|
...aiConfig,
|
|
19
|
-
schema: object({
|
|
20
|
-
title: string(),
|
|
21
|
-
description: string(),
|
|
22
|
-
tags: array(string())
|
|
19
|
+
schema: z.object({
|
|
20
|
+
title: z.string(),
|
|
21
|
+
description: z.string(),
|
|
22
|
+
tags: z.array(z.string())
|
|
23
23
|
}),
|
|
24
24
|
messages: [
|
|
25
25
|
{
|
|
@@ -41,7 +41,7 @@ const auditDictionaryMetadata = async ({ fileContent, tags, aiConfig, applicatio
|
|
|
41
41
|
]
|
|
42
42
|
});
|
|
43
43
|
return {
|
|
44
|
-
fileContent: object
|
|
44
|
+
fileContent: object,
|
|
45
45
|
tokenUsed: usage?.totalTokens ?? 0
|
|
46
46
|
};
|
|
47
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["aiDefaultOptions: AIOptions"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["aiDefaultOptions: AIOptions"],"sources":["../../../src/auditDictionaryMetadata/index.ts"],"sourcesContent":["import { readAsset } from 'utils:asset';\nimport { generateObject } from 'ai';\nimport { z } from 'zod';\nimport type { AIConfig, AIOptions } from '../aiSdk';\n\ntype Tag = {\n key: string;\n description?: string;\n};\n\nexport type AuditDictionaryMetadataOptions = {\n fileContent: string;\n tags?: Tag[];\n aiConfig: AIConfig;\n applicationContext?: string;\n};\n\nexport type AuditFileResultData = {\n fileContent: {\n title: string;\n description: string;\n tags: string[];\n };\n tokenUsed: number;\n};\n\nexport const aiDefaultOptions: AIOptions = {\n // Keep default options\n};\n\n/**\n * Audits a content declaration file by constructing a prompt for AI models.\n * The prompt includes details about the project's locales, file paths of content declarations,\n * and requests for identifying issues or inconsistencies.\n */\nexport const auditDictionaryMetadata = async ({\n fileContent,\n tags,\n aiConfig,\n applicationContext,\n}: AuditDictionaryMetadataOptions): Promise<\n AuditFileResultData | undefined\n> => {\n const CHAT_GPT_PROMPT = readAsset('./PROMPT.md');\n const EXAMPLE_REQUEST = readAsset('./EXAMPLE_REQUEST.md');\n const EXAMPLE_RESPONSE = readAsset('./EXAMPLE_RESPONSE.md');\n\n // Prepare the prompt for AI by replacing placeholders with actual values.\n const prompt = CHAT_GPT_PROMPT.replace(\n '{{applicationContext}}',\n applicationContext ?? ''\n ).replace(\n '{{tags}}',\n tags\n ? JSON.stringify(\n tags\n .map(({ key, description }) => `- ${key}: ${description}`)\n .join('\\n\\n'),\n null,\n 2\n )\n : ''\n );\n\n // Use the AI SDK to generate the completion\n const { object, usage } = await generateObject({\n ...aiConfig,\n schema: z.object({\n title: z.string(),\n description: z.string(),\n tags: z.array(z.string()),\n }),\n messages: [\n { role: 'system', content: prompt },\n { role: 'user', content: EXAMPLE_REQUEST },\n { role: 'assistant', content: EXAMPLE_RESPONSE },\n {\n role: 'user',\n content: fileContent,\n },\n ],\n });\n\n return {\n fileContent: object,\n tokenUsed: usage?.totalTokens ?? 0,\n };\n};\n"],"mappings":";;;;;AA0BA,MAAaA,mBAA8B,EAE1C;;;;;;AAOD,MAAa,0BAA0B,OAAO,EAC5C,aACA,MACA,UACA,yBAGG;CACH,MAAM,kBAAkB,UAAU,cAAc;CAChD,MAAM,kBAAkB,UAAU,uBAAuB;CACzD,MAAM,mBAAmB,UAAU,wBAAwB;CAG3D,MAAM,SAAS,gBAAgB,QAC7B,0BACA,sBAAsB,GACvB,CAAC,QACA,YACA,OACI,KAAK,UACH,KACG,KAAK,EAAE,KAAK,kBAAkB,KAAK,IAAI,IAAI,cAAc,CACzD,KAAK,OAAO,EACf,MACA,EACD,GACD,GACL;CAGD,MAAM,EAAE,QAAQ,UAAU,MAAM,eAAe;EAC7C,GAAG;EACH,QAAQ,EAAE,OAAO;GACf,OAAO,EAAE,QAAQ;GACjB,aAAa,EAAE,QAAQ;GACvB,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;GAC1B,CAAC;EACF,UAAU;GACR;IAAE,MAAM;IAAU,SAAS;IAAQ;GACnC;IAAE,MAAM;IAAQ,SAAS;IAAiB;GAC1C;IAAE,MAAM;IAAa,SAAS;IAAkB;GAChD;IACE,MAAM;IACN,SAAS;IACV;GACF;EACF,CAAC;AAEF,QAAO;EACL,aAAa;EACb,WAAW,OAAO,eAAe;EAClC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AIProvider } from "../aiSdk.mjs";
|
|
2
2
|
import { readAsset } from "../_virtual/_utils_asset.mjs";
|
|
3
|
-
import { any, array, boolean, number, object, string } from "../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/schemas.mjs";
|
|
4
3
|
import { generateObject } from "ai";
|
|
4
|
+
import { z } from "zod";
|
|
5
5
|
import { getLocaleName } from "@intlayer/core";
|
|
6
6
|
import { Locales } from "@intlayer/types";
|
|
7
7
|
|
|
@@ -35,19 +35,19 @@ const getModeInstructions = (mode) => {
|
|
|
35
35
|
return "Mode: \"Review\" - Fill missing content and review existing keys from the preset content. If a key from the entry is missing in the output, it must be translated to the target language and added. If you detect misspelled content, or content that should be reformulated, correct it. If a translation is not coherent with the desired language, translate it.";
|
|
36
36
|
};
|
|
37
37
|
const jsonToZod = (content) => {
|
|
38
|
-
if (typeof content === "string") return string();
|
|
39
|
-
if (typeof content === "number") return number();
|
|
40
|
-
if (typeof content === "boolean") return boolean();
|
|
38
|
+
if (typeof content === "string") return z.string();
|
|
39
|
+
if (typeof content === "number") return z.number();
|
|
40
|
+
if (typeof content === "boolean") return z.boolean();
|
|
41
41
|
if (Array.isArray(content)) {
|
|
42
|
-
if (content.length === 0) return array(string());
|
|
43
|
-
return array(jsonToZod(content[0]));
|
|
42
|
+
if (content.length === 0) return z.array(z.string());
|
|
43
|
+
return z.array(jsonToZod(content[0]));
|
|
44
44
|
}
|
|
45
45
|
if (typeof content === "object" && content !== null) {
|
|
46
46
|
const shape = {};
|
|
47
47
|
for (const key in content) shape[key] = jsonToZod(content[key]);
|
|
48
|
-
return object(shape);
|
|
48
|
+
return z.object(shape);
|
|
49
49
|
}
|
|
50
|
-
return any();
|
|
50
|
+
return z.any();
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
53
|
* TranslateJSONs a content declaration file by constructing a prompt for AI models.
|
|
@@ -59,7 +59,7 @@ const translateJSON = async ({ entryFileContent, presetOutputContent, dictionary
|
|
|
59
59
|
const formattedEntryLocale = formatLocaleWithName(entryLocale);
|
|
60
60
|
const formattedOutputLocale = formatLocaleWithName(outputLocale);
|
|
61
61
|
const prompt = promptFile.replace("{{entryLocale}}", formattedEntryLocale).replace("{{outputLocale}}", formattedOutputLocale).replace("{{presetOutputContent}}", JSON.stringify(presetOutputContent)).replace("{{dictionaryDescription}}", dictionaryDescription ?? "").replace("{{applicationContext}}", applicationContext ?? "").replace("{{tagsInstructions}}", formatTagInstructions(tags ?? [])).replace("{{modeInstructions}}", getModeInstructions(mode));
|
|
62
|
-
const { object
|
|
62
|
+
const { object, usage } = await generateObject({
|
|
63
63
|
...aiConfig,
|
|
64
64
|
schema: jsonToZod(entryFileContent),
|
|
65
65
|
messages: [{
|
|
@@ -79,7 +79,7 @@ const translateJSON = async ({ entryFileContent, presetOutputContent, dictionary
|
|
|
79
79
|
}]
|
|
80
80
|
});
|
|
81
81
|
return {
|
|
82
|
-
fileContent: object
|
|
82
|
+
fileContent: object,
|
|
83
83
|
tokenUsed: usage?.totalTokens ?? 0
|
|
84
84
|
};
|
|
85
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["aiDefaultOptions: AIOptions","
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["aiDefaultOptions: AIOptions","shape: Record<string, z.ZodTypeAny>"],"sources":["../../../src/translateJSON/index.ts"],"sourcesContent":["import { readAsset } from 'utils:asset';\nimport { getLocaleName } from '@intlayer/core';\nimport { type Locale, Locales } from '@intlayer/types';\nimport { generateObject } from 'ai';\nimport { z } from 'zod';\nimport { type AIConfig, type AIOptions, AIProvider } from '../aiSdk';\n\ntype Tag = {\n key: string;\n description?: string;\n};\n\nexport type TranslateJSONOptions<T = JSON> = {\n entryFileContent: T;\n presetOutputContent: Partial<T>;\n dictionaryDescription?: string;\n entryLocale: Locale;\n outputLocale: Locale;\n tags?: Tag[];\n aiConfig: AIConfig;\n mode: 'complete' | 'review';\n applicationContext?: string;\n};\n\nexport type TranslateJSONResultData<T = JSON> = {\n fileContent: T;\n tokenUsed: number;\n};\n\nexport const aiDefaultOptions: AIOptions = {\n provider: AIProvider.OPENAI,\n model: 'gpt-5-mini',\n};\n\n/**\n * Format a locale with its name.\n *\n * @param locale - The locale to format.\n * @returns A string in the format \"locale: name\", e.g. \"en: English\".\n */\nconst formatLocaleWithName = (locale: Locale): string =>\n `${locale}: ${getLocaleName(locale, Locales.ENGLISH)}`;\n\n/**\n * Formats tag instructions for the AI prompt.\n * Creates a string with all available tags and their descriptions.\n *\n * @param tags - The list of tags to format.\n * @returns A formatted string with tag instructions.\n */\nconst formatTagInstructions = (tags: Tag[]): string => {\n if (!tags || tags.length === 0) {\n return '';\n }\n\n // Prepare the tag instructions.\n return `Based on the dictionary content, identify specific tags from the list below that would be relevant:\n \n${tags.map(({ key, description }) => `- ${key}: ${description}`).join('\\n\\n')}`;\n};\n\nconst getModeInstructions = (mode: 'complete' | 'review'): string => {\n if (mode === 'complete') {\n return 'Mode: \"Complete\" - Enrich the preset content with the missing keys and values in the output locale. Do not update existing keys. Everything should be returned in the output.';\n }\n\n return 'Mode: \"Review\" - Fill missing content and review existing keys from the preset content. If a key from the entry is missing in the output, it must be translated to the target language and added. If you detect misspelled content, or content that should be reformulated, correct it. If a translation is not coherent with the desired language, translate it.';\n};\n\nconst jsonToZod = (content: any): z.ZodTypeAny => {\n // Base case: content is a string (the translation target)\n if (typeof content === 'string') {\n return z.string();\n }\n\n // Base cases: primitives often preserved in i18n files (e.g. strict numbers/booleans)\n if (typeof content === 'number') {\n return z.number();\n }\n if (typeof content === 'boolean') {\n return z.boolean();\n }\n\n // Recursive case: Array\n if (Array.isArray(content)) {\n // If array is empty, we assume array of strings as default for i18n\n if (content.length === 0) {\n return z.array(z.string());\n }\n // We assume all items in the array share the structure of the first item\n return z.array(jsonToZod(content[0]));\n }\n\n // Recursive case: Object\n if (typeof content === 'object' && content !== null) {\n const shape: Record<string, z.ZodTypeAny> = {};\n for (const key in content) {\n shape[key] = jsonToZod(content[key]);\n }\n return z.object(shape);\n }\n\n // Fallback\n return z.any();\n};\n\n/**\n * TranslateJSONs a content declaration file by constructing a prompt for AI models.\n * The prompt includes details about the project's locales, file paths of content declarations,\n * and requests for identifying issues or inconsistencies.\n */\nexport const translateJSON = async <T>({\n entryFileContent,\n presetOutputContent,\n dictionaryDescription,\n aiConfig,\n entryLocale,\n outputLocale,\n tags,\n mode,\n applicationContext,\n}: TranslateJSONOptions<T>): Promise<\n TranslateJSONResultData<T> | undefined\n> => {\n const promptFile = readAsset('./PROMPT.md');\n\n const formattedEntryLocale = formatLocaleWithName(entryLocale);\n const formattedOutputLocale = formatLocaleWithName(outputLocale);\n\n // Prepare the prompt for AI by replacing placeholders with actual values.\n const prompt = promptFile\n .replace('{{entryLocale}}', formattedEntryLocale)\n .replace('{{outputLocale}}', formattedOutputLocale)\n .replace('{{presetOutputContent}}', JSON.stringify(presetOutputContent))\n .replace('{{dictionaryDescription}}', dictionaryDescription ?? '')\n .replace('{{applicationContext}}', applicationContext ?? '')\n .replace('{{tagsInstructions}}', formatTagInstructions(tags ?? []))\n .replace('{{modeInstructions}}', getModeInstructions(mode));\n\n // Use the AI SDK to generate the completion\n const { object, usage } = await generateObject({\n ...aiConfig,\n schema: jsonToZod(entryFileContent),\n messages: [\n { role: 'system', content: prompt },\n {\n role: 'user',\n // KEY CHANGE: Explicitly repeating instructions in the user message\n content: [\n `# Translation Request`,\n `Please translate the following JSON content.`,\n `- **From:** ${formattedEntryLocale}`,\n `- **To:** ${formattedOutputLocale}`,\n ``,\n `## Entry Content:`,\n JSON.stringify(entryFileContent),\n ].join('\\n'),\n },\n ],\n });\n\n return {\n fileContent: object as T,\n tokenUsed: usage?.totalTokens ?? 0,\n };\n};\n"],"mappings":";;;;;;;;AA6BA,MAAaA,mBAA8B;CACzC,UAAU,WAAW;CACrB,OAAO;CACR;;;;;;;AAQD,MAAM,wBAAwB,WAC5B,GAAG,OAAO,IAAI,cAAc,QAAQ,QAAQ,QAAQ;;;;;;;;AAStD,MAAM,yBAAyB,SAAwB;AACrD,KAAI,CAAC,QAAQ,KAAK,WAAW,EAC3B,QAAO;AAIT,QAAO;;EAEP,KAAK,KAAK,EAAE,KAAK,kBAAkB,KAAK,IAAI,IAAI,cAAc,CAAC,KAAK,OAAO;;AAG7E,MAAM,uBAAuB,SAAwC;AACnE,KAAI,SAAS,WACX,QAAO;AAGT,QAAO;;AAGT,MAAM,aAAa,YAA+B;AAEhD,KAAI,OAAO,YAAY,SACrB,QAAO,EAAE,QAAQ;AAInB,KAAI,OAAO,YAAY,SACrB,QAAO,EAAE,QAAQ;AAEnB,KAAI,OAAO,YAAY,UACrB,QAAO,EAAE,SAAS;AAIpB,KAAI,MAAM,QAAQ,QAAQ,EAAE;AAE1B,MAAI,QAAQ,WAAW,EACrB,QAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;AAG5B,SAAO,EAAE,MAAM,UAAU,QAAQ,GAAG,CAAC;;AAIvC,KAAI,OAAO,YAAY,YAAY,YAAY,MAAM;EACnD,MAAMC,QAAsC,EAAE;AAC9C,OAAK,MAAM,OAAO,QAChB,OAAM,OAAO,UAAU,QAAQ,KAAK;AAEtC,SAAO,EAAE,OAAO,MAAM;;AAIxB,QAAO,EAAE,KAAK;;;;;;;AAQhB,MAAa,gBAAgB,OAAU,EACrC,kBACA,qBACA,uBACA,UACA,aACA,cACA,MACA,MACA,yBAGG;CACH,MAAM,aAAa,UAAU,cAAc;CAE3C,MAAM,uBAAuB,qBAAqB,YAAY;CAC9D,MAAM,wBAAwB,qBAAqB,aAAa;CAGhE,MAAM,SAAS,WACZ,QAAQ,mBAAmB,qBAAqB,CAChD,QAAQ,oBAAoB,sBAAsB,CAClD,QAAQ,2BAA2B,KAAK,UAAU,oBAAoB,CAAC,CACvE,QAAQ,6BAA6B,yBAAyB,GAAG,CACjE,QAAQ,0BAA0B,sBAAsB,GAAG,CAC3D,QAAQ,wBAAwB,sBAAsB,QAAQ,EAAE,CAAC,CAAC,CAClE,QAAQ,wBAAwB,oBAAoB,KAAK,CAAC;CAG7D,MAAM,EAAE,QAAQ,UAAU,MAAM,eAAe;EAC7C,GAAG;EACH,QAAQ,UAAU,iBAAiB;EACnC,UAAU,CACR;GAAE,MAAM;GAAU,SAAS;GAAQ,EACnC;GACE,MAAM;GAEN,SAAS;IACP;IACA;IACA,eAAe;IACf,aAAa;IACb;IACA;IACA,KAAK,UAAU,iBAAiB;IACjC,CAAC,KAAK,KAAK;GACb,CACF;EACF,CAAC;AAEF,QAAO;EACL,aAAa;EACb,WAAW,OAAO,eAAe;EAClC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/ai",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "SDK that provides AI capabilities for Intlayer applications",
|
|
6
6
|
"keywords": [
|
|
@@ -78,11 +78,12 @@
|
|
|
78
78
|
"@ai-sdk/google": "2.0.51",
|
|
79
79
|
"@ai-sdk/mistral": "2.0.26",
|
|
80
80
|
"@ai-sdk/openai": "2.0.88",
|
|
81
|
-
"@intlayer/api": "7.5.
|
|
82
|
-
"@intlayer/config": "7.5.
|
|
83
|
-
"@intlayer/core": "7.5.
|
|
84
|
-
"@intlayer/types": "7.5.
|
|
85
|
-
"ai": "5.0.116"
|
|
81
|
+
"@intlayer/api": "7.5.4",
|
|
82
|
+
"@intlayer/config": "7.5.4",
|
|
83
|
+
"@intlayer/core": "7.5.4",
|
|
84
|
+
"@intlayer/types": "7.5.4",
|
|
85
|
+
"ai": "5.0.116",
|
|
86
|
+
"zod": "4.2.1"
|
|
86
87
|
},
|
|
87
88
|
"devDependencies": {
|
|
88
89
|
"@types/node": "25.0.3",
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const require_core = require('../core/core.cjs');
|
|
2
|
-
const require_util = require('../core/util.cjs');
|
|
3
|
-
const require_errors = require('../core/errors.cjs');
|
|
4
|
-
|
|
5
|
-
//#region ../../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/errors.js
|
|
6
|
-
const initializer = (inst, issues) => {
|
|
7
|
-
require_errors.$ZodError.init(inst, issues);
|
|
8
|
-
inst.name = "ZodError";
|
|
9
|
-
Object.defineProperties(inst, {
|
|
10
|
-
format: { value: (mapper) => require_errors.formatError(inst, mapper) },
|
|
11
|
-
flatten: { value: (mapper) => require_errors.flattenError(inst, mapper) },
|
|
12
|
-
addIssue: { value: (issue) => {
|
|
13
|
-
inst.issues.push(issue);
|
|
14
|
-
inst.message = JSON.stringify(inst.issues, require_util.jsonStringifyReplacer, 2);
|
|
15
|
-
} },
|
|
16
|
-
addIssues: { value: (issues$1) => {
|
|
17
|
-
inst.issues.push(...issues$1);
|
|
18
|
-
inst.message = JSON.stringify(inst.issues, require_util.jsonStringifyReplacer, 2);
|
|
19
|
-
} },
|
|
20
|
-
isEmpty: { get() {
|
|
21
|
-
return inst.issues.length === 0;
|
|
22
|
-
} }
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
const ZodError = require_core.$constructor("ZodError", initializer);
|
|
26
|
-
const ZodRealError = require_core.$constructor("ZodError", initializer, { Parent: Error });
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
exports.ZodRealError = ZodRealError;
|
|
30
|
-
//# sourceMappingURL=errors.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":["issues"],"sources":["../../../../../../../../../../../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/errors.js"],"sourcesContent":["import * as core from \"../core/index.js\";\nimport { $ZodError } from \"../core/index.js\";\nimport * as util from \"../core/util.js\";\nconst initializer = (inst, issues) => {\n $ZodError.init(inst, issues);\n inst.name = \"ZodError\";\n Object.defineProperties(inst, {\n format: {\n value: (mapper) => core.formatError(inst, mapper),\n // enumerable: false,\n },\n flatten: {\n value: (mapper) => core.flattenError(inst, mapper),\n // enumerable: false,\n },\n addIssue: {\n value: (issue) => {\n inst.issues.push(issue);\n inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);\n },\n // enumerable: false,\n },\n addIssues: {\n value: (issues) => {\n inst.issues.push(...issues);\n inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);\n },\n // enumerable: false,\n },\n isEmpty: {\n get() {\n return inst.issues.length === 0;\n },\n // enumerable: false,\n },\n });\n // Object.defineProperty(inst, \"isEmpty\", {\n // get() {\n // return inst.issues.length === 0;\n // },\n // });\n};\nexport const ZodError = core.$constructor(\"ZodError\", initializer);\nexport const ZodRealError = core.$constructor(\"ZodError\", initializer, {\n Parent: Error,\n});\n// /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */\n// export type ErrorMapCtx = core.$ZodErrorMapCtx;\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAGA,MAAM,eAAe,MAAM,WAAW;AAClC,0BAAU,KAAK,MAAM,OAAO;AAC5B,MAAK,OAAO;AACZ,QAAO,iBAAiB,MAAM;EAC1B,QAAQ,EACJ,QAAQ,sCAA4B,MAAM,OAAO,EAEpD;EACD,SAAS,EACL,QAAQ,uCAA6B,MAAM,OAAO,EAErD;EACD,UAAU,EACN,QAAQ,UAAU;AACd,QAAK,OAAO,KAAK,MAAM;AACvB,QAAK,UAAU,KAAK,UAAU,KAAK,4CAAoC,EAAE;KAGhF;EACD,WAAW,EACP,QAAQ,aAAW;AACf,QAAK,OAAO,KAAK,GAAGA,SAAO;AAC3B,QAAK,UAAU,KAAK,UAAU,KAAK,4CAAoC,EAAE;KAGhF;EACD,SAAS,EACL,MAAM;AACF,UAAO,KAAK,OAAO,WAAW;KAGrC;EACJ,CAAC;;AAON,MAAa,qCAA6B,YAAY,YAAY;AAClE,MAAa,yCAAiC,YAAY,aAAa,EACnE,QAAQ,OACX,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const require_core = require('../core/core.cjs');
|
|
2
|
-
const require_schemas = require('../core/schemas.cjs');
|
|
3
|
-
const require_api = require('../core/api.cjs');
|
|
4
|
-
const require_schemas$1 = require('./schemas.cjs');
|
|
5
|
-
|
|
6
|
-
//#region ../../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/iso.js
|
|
7
|
-
const ZodISODateTime = /* @__PURE__ */ require_core.$constructor("ZodISODateTime", (inst, def) => {
|
|
8
|
-
require_schemas.$ZodISODateTime.init(inst, def);
|
|
9
|
-
require_schemas$1.ZodStringFormat.init(inst, def);
|
|
10
|
-
});
|
|
11
|
-
function datetime(params) {
|
|
12
|
-
return require_api._isoDateTime(ZodISODateTime, params);
|
|
13
|
-
}
|
|
14
|
-
const ZodISODate = /* @__PURE__ */ require_core.$constructor("ZodISODate", (inst, def) => {
|
|
15
|
-
require_schemas.$ZodISODate.init(inst, def);
|
|
16
|
-
require_schemas$1.ZodStringFormat.init(inst, def);
|
|
17
|
-
});
|
|
18
|
-
function date(params) {
|
|
19
|
-
return require_api._isoDate(ZodISODate, params);
|
|
20
|
-
}
|
|
21
|
-
const ZodISOTime = /* @__PURE__ */ require_core.$constructor("ZodISOTime", (inst, def) => {
|
|
22
|
-
require_schemas.$ZodISOTime.init(inst, def);
|
|
23
|
-
require_schemas$1.ZodStringFormat.init(inst, def);
|
|
24
|
-
});
|
|
25
|
-
function time(params) {
|
|
26
|
-
return require_api._isoTime(ZodISOTime, params);
|
|
27
|
-
}
|
|
28
|
-
const ZodISODuration = /* @__PURE__ */ require_core.$constructor("ZodISODuration", (inst, def) => {
|
|
29
|
-
require_schemas.$ZodISODuration.init(inst, def);
|
|
30
|
-
require_schemas$1.ZodStringFormat.init(inst, def);
|
|
31
|
-
});
|
|
32
|
-
function duration(params) {
|
|
33
|
-
return require_api._isoDuration(ZodISODuration, params);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
exports.date = date;
|
|
38
|
-
exports.datetime = datetime;
|
|
39
|
-
exports.duration = duration;
|
|
40
|
-
exports.time = time;
|
|
41
|
-
//# sourceMappingURL=iso.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iso.cjs","names":[],"sources":["../../../../../../../../../../../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/iso.js"],"sourcesContent":["import * as core from \"../core/index.js\";\nimport * as schemas from \"./schemas.js\";\nexport const ZodISODateTime = /*@__PURE__*/ core.$constructor(\"ZodISODateTime\", (inst, def) => {\n core.$ZodISODateTime.init(inst, def);\n schemas.ZodStringFormat.init(inst, def);\n});\nexport function datetime(params) {\n return core._isoDateTime(ZodISODateTime, params);\n}\nexport const ZodISODate = /*@__PURE__*/ core.$constructor(\"ZodISODate\", (inst, def) => {\n core.$ZodISODate.init(inst, def);\n schemas.ZodStringFormat.init(inst, def);\n});\nexport function date(params) {\n return core._isoDate(ZodISODate, params);\n}\nexport const ZodISOTime = /*@__PURE__*/ core.$constructor(\"ZodISOTime\", (inst, def) => {\n core.$ZodISOTime.init(inst, def);\n schemas.ZodStringFormat.init(inst, def);\n});\nexport function time(params) {\n return core._isoTime(ZodISOTime, params);\n}\nexport const ZodISODuration = /*@__PURE__*/ core.$constructor(\"ZodISODuration\", (inst, def) => {\n core.$ZodISODuration.init(inst, def);\n schemas.ZodStringFormat.init(inst, def);\n});\nexport function duration(params) {\n return core._isoDuration(ZodISODuration, params);\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;AAEA,MAAa,iBAA+B,0CAAkB,mBAAmB,MAAM,QAAQ;AAC3F,iCAAqB,KAAK,MAAM,IAAI;AACpC,mCAAwB,KAAK,MAAM,IAAI;EACzC;AACF,SAAgB,SAAS,QAAQ;AAC7B,iCAAyB,gBAAgB,OAAO;;AAEpD,MAAa,aAA2B,0CAAkB,eAAe,MAAM,QAAQ;AACnF,6BAAiB,KAAK,MAAM,IAAI;AAChC,mCAAwB,KAAK,MAAM,IAAI;EACzC;AACF,SAAgB,KAAK,QAAQ;AACzB,6BAAqB,YAAY,OAAO;;AAE5C,MAAa,aAA2B,0CAAkB,eAAe,MAAM,QAAQ;AACnF,6BAAiB,KAAK,MAAM,IAAI;AAChC,mCAAwB,KAAK,MAAM,IAAI;EACzC;AACF,SAAgB,KAAK,QAAQ;AACzB,6BAAqB,YAAY,OAAO;;AAE5C,MAAa,iBAA+B,0CAAkB,mBAAmB,MAAM,QAAQ;AAC3F,iCAAqB,KAAK,MAAM,IAAI;AACpC,mCAAwB,KAAK,MAAM,IAAI;EACzC;AACF,SAAgB,SAAS,QAAQ;AAC7B,iCAAyB,gBAAgB,OAAO"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const require_parse = require('../core/parse.cjs');
|
|
2
|
-
const require_errors = require('./errors.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/parse.js
|
|
5
|
-
const parse = /* @__PURE__ */ require_parse._parse(require_errors.ZodRealError);
|
|
6
|
-
const parseAsync = /* @__PURE__ */ require_parse._parseAsync(require_errors.ZodRealError);
|
|
7
|
-
const safeParse = /* @__PURE__ */ require_parse._safeParse(require_errors.ZodRealError);
|
|
8
|
-
const safeParseAsync = /* @__PURE__ */ require_parse._safeParseAsync(require_errors.ZodRealError);
|
|
9
|
-
const encode = /* @__PURE__ */ require_parse._encode(require_errors.ZodRealError);
|
|
10
|
-
const decode = /* @__PURE__ */ require_parse._decode(require_errors.ZodRealError);
|
|
11
|
-
const encodeAsync = /* @__PURE__ */ require_parse._encodeAsync(require_errors.ZodRealError);
|
|
12
|
-
const decodeAsync = /* @__PURE__ */ require_parse._decodeAsync(require_errors.ZodRealError);
|
|
13
|
-
const safeEncode = /* @__PURE__ */ require_parse._safeEncode(require_errors.ZodRealError);
|
|
14
|
-
const safeDecode = /* @__PURE__ */ require_parse._safeDecode(require_errors.ZodRealError);
|
|
15
|
-
const safeEncodeAsync = /* @__PURE__ */ require_parse._safeEncodeAsync(require_errors.ZodRealError);
|
|
16
|
-
const safeDecodeAsync = /* @__PURE__ */ require_parse._safeDecodeAsync(require_errors.ZodRealError);
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.decode = decode;
|
|
20
|
-
exports.decodeAsync = decodeAsync;
|
|
21
|
-
exports.encode = encode;
|
|
22
|
-
exports.encodeAsync = encodeAsync;
|
|
23
|
-
exports.parse = parse;
|
|
24
|
-
exports.parseAsync = parseAsync;
|
|
25
|
-
exports.safeDecode = safeDecode;
|
|
26
|
-
exports.safeDecodeAsync = safeDecodeAsync;
|
|
27
|
-
exports.safeEncode = safeEncode;
|
|
28
|
-
exports.safeEncodeAsync = safeEncodeAsync;
|
|
29
|
-
exports.safeParse = safeParse;
|
|
30
|
-
exports.safeParseAsync = safeParseAsync;
|
|
31
|
-
//# sourceMappingURL=parse.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.cjs","names":["ZodRealError"],"sources":["../../../../../../../../../../../../node_modules/.bun/zod@4.2.1/node_modules/zod/v4/classic/parse.js"],"sourcesContent":["import * as core from \"../core/index.js\";\nimport { ZodRealError } from \"./errors.js\";\nexport const parse = /* @__PURE__ */ core._parse(ZodRealError);\nexport const parseAsync = /* @__PURE__ */ core._parseAsync(ZodRealError);\nexport const safeParse = /* @__PURE__ */ core._safeParse(ZodRealError);\nexport const safeParseAsync = /* @__PURE__ */ core._safeParseAsync(ZodRealError);\n// Codec functions\nexport const encode = /* @__PURE__ */ core._encode(ZodRealError);\nexport const decode = /* @__PURE__ */ core._decode(ZodRealError);\nexport const encodeAsync = /* @__PURE__ */ core._encodeAsync(ZodRealError);\nexport const decodeAsync = /* @__PURE__ */ core._decodeAsync(ZodRealError);\nexport const safeEncode = /* @__PURE__ */ core._safeEncode(ZodRealError);\nexport const safeDecode = /* @__PURE__ */ core._safeDecode(ZodRealError);\nexport const safeEncodeAsync = /* @__PURE__ */ core._safeEncodeAsync(ZodRealError);\nexport const safeDecodeAsync = /* @__PURE__ */ core._safeDecodeAsync(ZodRealError);\n"],"x_google_ignoreList":[0],"mappings":";;;;AAEA,MAAa,QAAwB,qCAAYA,4BAAa;AAC9D,MAAa,aAA6B,0CAAiBA,4BAAa;AACxE,MAAa,YAA4B,yCAAgBA,4BAAa;AACtE,MAAa,iBAAiC,8CAAqBA,4BAAa;AAEhF,MAAa,SAAyB,sCAAaA,4BAAa;AAChE,MAAa,SAAyB,sCAAaA,4BAAa;AAChE,MAAa,cAA8B,2CAAkBA,4BAAa;AAC1E,MAAa,cAA8B,2CAAkBA,4BAAa;AAC1E,MAAa,aAA6B,0CAAiBA,4BAAa;AACxE,MAAa,aAA6B,0CAAiBA,4BAAa;AACxE,MAAa,kBAAkC,+CAAsBA,4BAAa;AAClF,MAAa,kBAAkC,+CAAsBA,4BAAa"}
|