@inlang/sdk 2.4.10 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/database/initDbAndSchema.test.js +42 -0
- package/dist/database/initDbAndSchema.test.js.map +1 -1
- package/dist/database/jsonbPlugin.d.ts.map +1 -1
- package/dist/database/jsonbPlugin.js +73 -8
- package/dist/database/jsonbPlugin.js.map +1 -1
- package/dist/database/jsonbPlugin.test.js +48 -1
- package/dist/database/jsonbPlugin.test.js.map +1 -1
- package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts.map +1 -1
- package/dist/migrations/v2/createMessageV1.d.ts.map +1 -1
- package/dist/plugin/importPlugins.test.js +3 -3
- package/dist/plugin/importPlugins.test.js.map +1 -1
- package/dist/project/README_CONTENT.d.ts +8 -0
- package/dist/project/README_CONTENT.d.ts.map +1 -0
- package/dist/project/README_CONTENT.js +111 -0
- package/dist/project/README_CONTENT.js.map +1 -0
- package/dist/project/api.d.ts +4 -0
- package/dist/project/api.d.ts.map +1 -1
- package/dist/project/api.js.map +1 -1
- package/dist/project/loadProjectFromDirectory.d.ts.map +1 -1
- package/dist/project/loadProjectFromDirectory.js +13 -7
- package/dist/project/loadProjectFromDirectory.js.map +1 -1
- package/dist/project/loadProjectFromDirectory.test.js +11 -1
- package/dist/project/loadProjectFromDirectory.test.js.map +1 -1
- package/dist/project/saveProjectToDirectory.d.ts.map +1 -1
- package/dist/project/saveProjectToDirectory.js +6 -8
- package/dist/project/saveProjectToDirectory.js.map +1 -1
- package/dist/project/saveProjectToDirectory.test.js +88 -1
- package/dist/project/saveProjectToDirectory.test.js.map +1 -1
- package/dist/query-utilities/insertBundleNested.d.ts.map +1 -1
- package/dist/query-utilities/selectBundleNested.d.ts.map +1 -1
- package/dist/query-utilities/updateBundleNested.d.ts.map +1 -1
- package/dist/query-utilities/upsertBundleNested.d.ts.map +1 -1
- package/dist/services/env-variables/index.js +1 -1
- package/dist/services/env-variables/index.js.map +1 -1
- package/dist/services/telemetry/capture.d.ts.map +1 -1
- package/dist/utilities/detectJsonFormatting.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/database/initDbAndSchema.test.ts +48 -0
- package/src/database/jsonbPlugin.test.ts +60 -1
- package/src/database/jsonbPlugin.ts +75 -10
- package/src/plugin/importPlugins.test.ts +3 -3
- package/src/project/README_CONTENT.ts +110 -0
- package/src/project/api.ts +4 -0
- package/src/project/loadProjectFromDirectory.test.ts +14 -1
- package/src/project/loadProjectFromDirectory.ts +20 -15
- package/src/project/saveProjectToDirectory.test.ts +125 -1
- package/src/project/saveProjectToDirectory.ts +12 -10
- package/src/services/env-variables/createIndexFile.js +0 -4
- package/dist/database/jsonPlugin.d.ts +0 -11
- package/dist/database/jsonPlugin.d.ts.map +0 -1
- package/dist/database/jsonPlugin.js +0 -197
- package/dist/database/jsonPlugin.js.map +0 -1
- package/dist/project/fs-sync.playground.test.d.ts +0 -2
- package/dist/project/fs-sync.playground.test.d.ts.map +0 -1
- package/dist/project/fs-sync.playground.test.js +0 -535
- package/dist/project/fs-sync.playground.test.js.map +0 -1
- package/dist/schema-definitions/bundle.d.ts +0 -22
- package/dist/schema-definitions/bundle.d.ts.map +0 -1
- package/dist/schema-definitions/bundle.js +0 -18
- package/dist/schema-definitions/bundle.js.map +0 -1
- package/dist/schema-definitions/bundle.test.d.ts +0 -2
- package/dist/schema-definitions/bundle.test.d.ts.map +0 -1
- package/dist/schema-definitions/bundle.test.js +0 -23
- package/dist/schema-definitions/bundle.test.js.map +0 -1
- package/dist/schema-definitions/index.d.ts +0 -4
- package/dist/schema-definitions/index.d.ts.map +0 -1
- package/dist/schema-definitions/index.js +0 -4
- package/dist/schema-definitions/index.js.map +0 -1
- package/dist/schema-definitions/message.d.ts +0 -35
- package/dist/schema-definitions/message.d.ts.map +0 -1
- package/dist/schema-definitions/message.js +0 -26
- package/dist/schema-definitions/message.js.map +0 -1
- package/dist/schema-definitions/message.test.d.ts +0 -2
- package/dist/schema-definitions/message.test.d.ts.map +0 -1
- package/dist/schema-definitions/message.test.js +0 -45
- package/dist/schema-definitions/message.test.js.map +0 -1
- package/dist/schema-definitions/variant.d.ts +0 -35
- package/dist/schema-definitions/variant.d.ts.map +0 -1
- package/dist/schema-definitions/variant.js +0 -26
- package/dist/schema-definitions/variant.js.map +0 -1
- package/dist/schema-definitions/variant.test.d.ts +0 -2
- package/dist/schema-definitions/variant.test.d.ts.map +0 -1
- package/dist/schema-definitions/variant.test.js +0 -67
- package/dist/schema-definitions/variant.test.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sourceRoot":"/","sources":["schema-definitions/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,aAAa,CAAC;AAEvE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,WAAW,EAAE,eAAe;IAC5B,eAAe,EAAE,KAAK;IACtB,mBAAmB,EAAE,CAAC,KAAK,CAAC;IAC5B,wBAAwB,EAAE;QACzB,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,cAAc;KACjC;IACD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACX,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE;QACzD,YAAY,EAAE,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,EAAE,EAAE;KAChD;IACD,QAAQ,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC;IAChC,oBAAoB,EAAE,KAAK;CACY,CAAC","sourcesContent":["import { JSONTypeSchema, type LixSchemaDefinition } from \"@lix-js/sdk\";\n\nexport const InlangBundleSchema = {\n\t\"x-lix-key\": \"inlang_bundle\",\n\t\"x-lix-version\": \"1.0\",\n\t\"x-lix-primary-key\": [\"/id\"],\n\t\"x-lix-override-lixcols\": {\n\t\tlixcol_file_id: '\"inlang\"',\n\t\tlixcol_plugin_key: '\"inlang_sdk\"',\n\t},\n\ttype: \"object\",\n\tproperties: {\n\t\tid: { type: \"string\", \"x-lix-default\": \"lix_human_id()\" },\n\t\tdeclarations: { ...JSONTypeSchema, default: [] },\n\t},\n\trequired: [\"id\", \"declarations\"],\n\tadditionalProperties: false,\n} as const satisfies LixSchemaDefinition;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.test.d.ts","sourceRoot":"/","sources":["schema-definitions/bundle.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "vitest";
|
|
2
|
-
import { newProject } from "../project/newProject.js";
|
|
3
|
-
import { loadProjectInMemory } from "../project/loadProjectInMemory.js";
|
|
4
|
-
test("bundle schema accepts JSON declarations via project.db", async () => {
|
|
5
|
-
const project = await loadProjectInMemory({ blob: await newProject() });
|
|
6
|
-
await expect(project.db
|
|
7
|
-
.insertInto("bundle")
|
|
8
|
-
.values({
|
|
9
|
-
id: "json-enabled-bundle",
|
|
10
|
-
declarations: [{ name: "namespace", type: "input-variable" }],
|
|
11
|
-
})
|
|
12
|
-
.execute()).resolves.not.toThrow();
|
|
13
|
-
const inserted = await project.db
|
|
14
|
-
.selectFrom("bundle")
|
|
15
|
-
.selectAll()
|
|
16
|
-
.where("id", "=", "json-enabled-bundle")
|
|
17
|
-
.executeTakeFirstOrThrow();
|
|
18
|
-
expect(inserted.declarations).toEqual([
|
|
19
|
-
{ name: "namespace", type: "input-variable" },
|
|
20
|
-
]);
|
|
21
|
-
await project.close();
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=bundle.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.test.js","sourceRoot":"/","sources":["schema-definitions/bundle.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,IAAI,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;IACzE,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IAExE,MAAM,MAAM,CACX,OAAO,CAAC,EAAE;SACR,UAAU,CAAC,QAAQ,CAAC;SACpB,MAAM,CAAC;QACP,EAAE,EAAE,qBAAqB;QACzB,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;KAC7D,CAAC;SACD,OAAO,EAAE,CACX,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAEzB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,EAAE;SAC/B,UAAU,CAAC,QAAQ,CAAC;SACpB,SAAS,EAAE;SACX,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,qBAAqB,CAAC;SACvC,uBAAuB,EAAE,CAAC;IAE5B,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;QACrC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,gBAAgB,EAAE;KAC7C,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"vitest\";\nimport { newProject } from \"../project/newProject.js\";\nimport { loadProjectInMemory } from \"../project/loadProjectInMemory.js\";\n\ntest(\"bundle schema accepts JSON declarations via project.db\", async () => {\n\tconst project = await loadProjectInMemory({ blob: await newProject() });\n\n\tawait expect(\n\t\tproject.db\n\t\t\t.insertInto(\"bundle\")\n\t\t\t.values({\n\t\t\t\tid: \"json-enabled-bundle\",\n\t\t\t\tdeclarations: [{ name: \"namespace\", type: \"input-variable\" }],\n\t\t\t})\n\t\t\t.execute()\n\t).resolves.not.toThrow();\n\n\tconst inserted = await project.db\n\t\t.selectFrom(\"bundle\")\n\t\t.selectAll()\n\t\t.where(\"id\", \"=\", \"json-enabled-bundle\")\n\t\t.executeTakeFirstOrThrow();\n\n\texpect(inserted.declarations).toEqual([\n\t\t{ name: \"namespace\", type: \"input-variable\" },\n\t]);\n\n\tawait project.close();\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["schema-definitions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["schema-definitions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { InlangBundleSchema } from \"./bundle.js\";\nexport { InlangMessageSchema } from \"./message.js\";\nexport { InlangVariantSchema } from \"./variant.js\";\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export declare const InlangMessageSchema: {
|
|
2
|
-
readonly "x-lix-key": "inlang_message";
|
|
3
|
-
readonly "x-lix-version": "1.0";
|
|
4
|
-
readonly "x-lix-primary-key": ["/id"];
|
|
5
|
-
readonly "x-lix-foreign-keys": [{
|
|
6
|
-
readonly properties: ["/bundleId"];
|
|
7
|
-
readonly references: {
|
|
8
|
-
readonly schemaKey: "inlang_bundle";
|
|
9
|
-
readonly properties: ["/id"];
|
|
10
|
-
};
|
|
11
|
-
}];
|
|
12
|
-
readonly "x-lix-override-lixcols": {
|
|
13
|
-
readonly lixcol_file_id: "\"inlang\"";
|
|
14
|
-
readonly lixcol_plugin_key: "\"inlang_sdk\"";
|
|
15
|
-
};
|
|
16
|
-
readonly type: "object";
|
|
17
|
-
readonly properties: {
|
|
18
|
-
readonly id: {
|
|
19
|
-
readonly type: "string";
|
|
20
|
-
readonly "x-lix-default": "lix_uuid_v7()";
|
|
21
|
-
};
|
|
22
|
-
readonly bundleId: {
|
|
23
|
-
readonly type: "string";
|
|
24
|
-
};
|
|
25
|
-
readonly locale: {
|
|
26
|
-
readonly type: "string";
|
|
27
|
-
};
|
|
28
|
-
readonly selectors: {
|
|
29
|
-
readonly default: readonly [];
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
readonly required: readonly ["id", "bundleId", "locale", "selectors"];
|
|
33
|
-
readonly additionalProperties: false;
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"/","sources":["schema-definitions/message.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBQ,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { JSONTypeSchema } from "@lix-js/sdk";
|
|
2
|
-
export const InlangMessageSchema = {
|
|
3
|
-
"x-lix-key": "inlang_message",
|
|
4
|
-
"x-lix-version": "1.0",
|
|
5
|
-
"x-lix-primary-key": ["/id"],
|
|
6
|
-
"x-lix-foreign-keys": [
|
|
7
|
-
{
|
|
8
|
-
properties: ["/bundleId"],
|
|
9
|
-
references: { schemaKey: "inlang_bundle", properties: ["/id"] },
|
|
10
|
-
},
|
|
11
|
-
],
|
|
12
|
-
"x-lix-override-lixcols": {
|
|
13
|
-
lixcol_file_id: '"inlang"',
|
|
14
|
-
lixcol_plugin_key: '"inlang_sdk"',
|
|
15
|
-
},
|
|
16
|
-
type: "object",
|
|
17
|
-
properties: {
|
|
18
|
-
id: { type: "string", "x-lix-default": "lix_uuid_v7()" },
|
|
19
|
-
bundleId: { type: "string" },
|
|
20
|
-
locale: { type: "string" },
|
|
21
|
-
selectors: { ...JSONTypeSchema, default: [] },
|
|
22
|
-
},
|
|
23
|
-
required: ["id", "bundleId", "locale", "selectors"],
|
|
24
|
-
additionalProperties: false,
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=message.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"/","sources":["schema-definitions/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,aAAa,CAAC;AAEvE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,WAAW,EAAE,gBAAgB;IAC7B,eAAe,EAAE,KAAK;IACtB,mBAAmB,EAAE,CAAC,KAAK,CAAC;IAC5B,oBAAoB,EAAE;QACrB;YACC,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,UAAU,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE;SAC/D;KACD;IACD,wBAAwB,EAAE;QACzB,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,cAAc;KACjC;IACD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACX,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE;QACxD,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC5B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,SAAS,EAAE,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,EAAE,EAAE;KAC7C;IACD,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC;IACnD,oBAAoB,EAAE,KAAK;CACY,CAAC","sourcesContent":["import { JSONTypeSchema, type LixSchemaDefinition } from \"@lix-js/sdk\";\n\nexport const InlangMessageSchema = {\n\t\"x-lix-key\": \"inlang_message\",\n\t\"x-lix-version\": \"1.0\",\n\t\"x-lix-primary-key\": [\"/id\"],\n\t\"x-lix-foreign-keys\": [\n\t\t{\n\t\t\tproperties: [\"/bundleId\"],\n\t\t\treferences: { schemaKey: \"inlang_bundle\", properties: [\"/id\"] },\n\t\t},\n\t],\n\t\"x-lix-override-lixcols\": {\n\t\tlixcol_file_id: '\"inlang\"',\n\t\tlixcol_plugin_key: '\"inlang_sdk\"',\n\t},\n\ttype: \"object\",\n\tproperties: {\n\t\tid: { type: \"string\", \"x-lix-default\": \"lix_uuid_v7()\" },\n\t\tbundleId: { type: \"string\" },\n\t\tlocale: { type: \"string\" },\n\t\tselectors: { ...JSONTypeSchema, default: [] },\n\t},\n\trequired: [\"id\", \"bundleId\", \"locale\", \"selectors\"],\n\tadditionalProperties: false,\n} as const satisfies LixSchemaDefinition;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message.test.d.ts","sourceRoot":"/","sources":["schema-definitions/message.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "vitest";
|
|
2
|
-
import { newProject } from "../project/newProject.js";
|
|
3
|
-
import { loadProjectInMemory } from "../project/loadProjectInMemory.js";
|
|
4
|
-
import { uuidV7 } from "@lix-js/sdk";
|
|
5
|
-
test("message schema stores selectors and respects bundle foreign key", async () => {
|
|
6
|
-
const project = await loadProjectInMemory({ blob: await newProject() });
|
|
7
|
-
const bundleId = "bundle-for-message";
|
|
8
|
-
await project.db
|
|
9
|
-
.insertInto("bundle")
|
|
10
|
-
.values({ id: bundleId, declarations: [] })
|
|
11
|
-
.execute();
|
|
12
|
-
const messageId = await uuidV7({ lix: project.lix });
|
|
13
|
-
const selectors = [{ type: "variable-reference", name: "platform" }];
|
|
14
|
-
await expect(project.db
|
|
15
|
-
.insertInto("message")
|
|
16
|
-
.values({
|
|
17
|
-
id: messageId,
|
|
18
|
-
bundleId,
|
|
19
|
-
locale: "en",
|
|
20
|
-
selectors,
|
|
21
|
-
})
|
|
22
|
-
.execute()).resolves.not.toThrow();
|
|
23
|
-
const stored = await project.db
|
|
24
|
-
.selectFrom("message")
|
|
25
|
-
.selectAll()
|
|
26
|
-
.where("id", "=", messageId)
|
|
27
|
-
.executeTakeFirstOrThrow();
|
|
28
|
-
expect(stored.bundleId).toBe(bundleId);
|
|
29
|
-
expect(stored.locale).toBe("en");
|
|
30
|
-
expect(stored.selectors).toEqual(selectors);
|
|
31
|
-
await project.close();
|
|
32
|
-
});
|
|
33
|
-
test("message schema enforces bundle foreign key", async () => {
|
|
34
|
-
const project = await loadProjectInMemory({ blob: await newProject() });
|
|
35
|
-
await expect(project.db
|
|
36
|
-
.insertInto("message")
|
|
37
|
-
.values({
|
|
38
|
-
bundleId: "missing-bundle",
|
|
39
|
-
locale: "en",
|
|
40
|
-
selectors: [],
|
|
41
|
-
})
|
|
42
|
-
.execute()).rejects.toThrow(/foreign key constraint/i);
|
|
43
|
-
await project.close();
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=message.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message.test.js","sourceRoot":"/","sources":["schema-definitions/message.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,IAAI,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;IAClF,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IACxE,MAAM,QAAQ,GAAG,oBAAoB,CAAC;IACtC,MAAM,OAAO,CAAC,EAAE;SACd,U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AC,EAAE;SACR,UAAU,CAAC,SAAS,CAAC;SACrB,MAAM,CAAC;QACP,QAAQ,EAAE,gBAAgB;QAC1B,MAAM,EAAE,IAAI;QACZ,SAAS,EAAE,EAAE;KACb,CAAC;SACD,OAAO,EAAE,CACX,CAAC,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAE7C,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"vitest\";\nimport { newProject } from \"../project/newProject.js\";\nimport { loadProjectInMemory } from \"../project/loadProjectInMemory.js\";\nimport { uuidV7 } from \"@lix-js/sdk\";\n\ntest(\"message schema stores selectors and respects bundle foreign key\", async () => {\n\tconst project = await loadProjectInMemory({ blob: await newProject() });\n\tconst bundleId = \"bundle-for-message\";\n\tawait project.db\n\t\t.insertInto(\"bundle\")\n\t\t.values({ id: bundleId, declarations: [] })\n\t\t.execute();\n\n\tconst messageId = await uuidV7({ lix: project.lix });\n\tconst selectors = [{ type: \"variable-reference\" as const, name: \"platform\" }];\n\n\tawait expect(\n\t\tproject.db\n\t\t\t.insertInto(\"message\")\n\t\t\t.values({\n\t\t\t\tid: messageId,\n\t\t\t\tbundleId,\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors,\n\t\t\t})\n\t\t\t.execute()\n\t).resolves.not.toThrow();\n\n\tconst stored = await project.db\n\t\t.selectFrom(\"message\")\n\t\t.selectAll()\n\t\t.where(\"id\", \"=\", messageId)\n\t\t.executeTakeFirstOrThrow();\n\n\texpect(stored.bundleId).toBe(bundleId);\n\texpect(stored.locale).toBe(\"en\");\n\texpect(stored.selectors).toEqual(selectors);\n\n\tawait project.close();\n});\n\ntest(\"message schema enforces bundle foreign key\", async () => {\n\tconst project = await loadProjectInMemory({ blob: await newProject() });\n\n\tawait expect(\n\t\tproject.db\n\t\t\t.insertInto(\"message\")\n\t\t\t.values({\n\t\t\t\tbundleId: \"missing-bundle\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t})\n\t\t\t.execute()\n\t).rejects.toThrow(/foreign key constraint/i);\n\n\tawait project.close();\n});\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export declare const InlangVariantSchema: {
|
|
2
|
-
readonly "x-lix-key": "inlang_variant";
|
|
3
|
-
readonly "x-lix-version": "1.0";
|
|
4
|
-
readonly "x-lix-primary-key": ["/id"];
|
|
5
|
-
readonly "x-lix-foreign-keys": [{
|
|
6
|
-
readonly properties: ["/messageId"];
|
|
7
|
-
readonly references: {
|
|
8
|
-
readonly schemaKey: "inlang_message";
|
|
9
|
-
readonly properties: ["/id"];
|
|
10
|
-
};
|
|
11
|
-
}];
|
|
12
|
-
readonly "x-lix-override-lixcols": {
|
|
13
|
-
readonly lixcol_file_id: "\"inlang\"";
|
|
14
|
-
readonly lixcol_plugin_key: "\"inlang_sdk\"";
|
|
15
|
-
};
|
|
16
|
-
readonly type: "object";
|
|
17
|
-
readonly properties: {
|
|
18
|
-
readonly id: {
|
|
19
|
-
readonly type: "string";
|
|
20
|
-
readonly "x-lix-default": "lix_uuid_v7()";
|
|
21
|
-
};
|
|
22
|
-
readonly messageId: {
|
|
23
|
-
readonly type: "string";
|
|
24
|
-
};
|
|
25
|
-
readonly matches: {
|
|
26
|
-
readonly default: readonly [];
|
|
27
|
-
};
|
|
28
|
-
readonly pattern: {
|
|
29
|
-
readonly default: readonly [];
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
readonly required: readonly ["id", "messageId", "matches", "pattern"];
|
|
33
|
-
readonly additionalProperties: false;
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=variant.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant.d.ts","sourceRoot":"/","sources":["schema-definitions/variant.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBQ,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { JSONTypeSchema } from "@lix-js/sdk";
|
|
2
|
-
export const InlangVariantSchema = {
|
|
3
|
-
"x-lix-key": "inlang_variant",
|
|
4
|
-
"x-lix-version": "1.0",
|
|
5
|
-
"x-lix-primary-key": ["/id"],
|
|
6
|
-
"x-lix-foreign-keys": [
|
|
7
|
-
{
|
|
8
|
-
properties: ["/messageId"],
|
|
9
|
-
references: { schemaKey: "inlang_message", properties: ["/id"] },
|
|
10
|
-
},
|
|
11
|
-
],
|
|
12
|
-
"x-lix-override-lixcols": {
|
|
13
|
-
lixcol_file_id: '"inlang"',
|
|
14
|
-
lixcol_plugin_key: '"inlang_sdk"',
|
|
15
|
-
},
|
|
16
|
-
type: "object",
|
|
17
|
-
properties: {
|
|
18
|
-
id: { type: "string", "x-lix-default": "lix_uuid_v7()" },
|
|
19
|
-
messageId: { type: "string" },
|
|
20
|
-
matches: { ...JSONTypeSchema, default: [] },
|
|
21
|
-
pattern: { ...JSONTypeSchema, default: [] },
|
|
22
|
-
},
|
|
23
|
-
required: ["id", "messageId", "matches", "pattern"],
|
|
24
|
-
additionalProperties: false,
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=variant.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant.js","sourceRoot":"/","sources":["schema-definitions/variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,aAAa,CAAC;AAEvE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,WAAW,EAAE,gBAAgB;IAC7B,eAAe,EAAE,KAAK;IACtB,mBAAmB,EAAE,CAAC,KAAK,CAAC;IAC5B,oBAAoB,EAAE;QACrB;YACC,UAAU,EAAE,CAAC,YAAY,CAAC;YAC1B,UAAU,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE;SAChE;KACD;IACD,wBAAwB,EAAE;QACzB,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,cAAc;KACjC;IACD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACX,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE;QACxD,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,OAAO,EAAE,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,EAAE,EAAE;QAC3C,OAAO,EAAE,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,EAAE,EAAE;KAC3C;IACD,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC;IACnD,oBAAoB,EAAE,KAAK;CACY,CAAC","sourcesContent":["import { JSONTypeSchema, type LixSchemaDefinition } from \"@lix-js/sdk\";\n\nexport const InlangVariantSchema = {\n\t\"x-lix-key\": \"inlang_variant\",\n\t\"x-lix-version\": \"1.0\",\n\t\"x-lix-primary-key\": [\"/id\"],\n\t\"x-lix-foreign-keys\": [\n\t\t{\n\t\t\tproperties: [\"/messageId\"],\n\t\t\treferences: { schemaKey: \"inlang_message\", properties: [\"/id\"] },\n\t\t},\n\t],\n\t\"x-lix-override-lixcols\": {\n\t\tlixcol_file_id: '\"inlang\"',\n\t\tlixcol_plugin_key: '\"inlang_sdk\"',\n\t},\n\ttype: \"object\",\n\tproperties: {\n\t\tid: { type: \"string\", \"x-lix-default\": \"lix_uuid_v7()\" },\n\t\tmessageId: { type: \"string\" },\n\t\tmatches: { ...JSONTypeSchema, default: [] },\n\t\tpattern: { ...JSONTypeSchema, default: [] },\n\t},\n\trequired: [\"id\", \"messageId\", \"matches\", \"pattern\"],\n\tadditionalProperties: false,\n} as const satisfies LixSchemaDefinition;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant.test.d.ts","sourceRoot":"/","sources":["schema-definitions/variant.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "vitest";
|
|
2
|
-
import { uuidV7 } from "@lix-js/sdk";
|
|
3
|
-
import { newProject } from "../project/newProject.js";
|
|
4
|
-
import { loadProjectInMemory } from "../project/loadProjectInMemory.js";
|
|
5
|
-
test("variant schema persists matches and pattern JSON", async () => {
|
|
6
|
-
const project = await loadProjectInMemory({ blob: await newProject() });
|
|
7
|
-
const bundleId = "bundle-for-variant";
|
|
8
|
-
await project.db
|
|
9
|
-
.insertInto("bundle")
|
|
10
|
-
.values({ id: bundleId, declarations: [] })
|
|
11
|
-
.execute();
|
|
12
|
-
const messageId = await uuidV7({ lix: project.lix });
|
|
13
|
-
await project.db
|
|
14
|
-
.insertInto("message")
|
|
15
|
-
.values({
|
|
16
|
-
id: messageId,
|
|
17
|
-
bundleId,
|
|
18
|
-
locale: "en",
|
|
19
|
-
selectors: [],
|
|
20
|
-
})
|
|
21
|
-
.execute();
|
|
22
|
-
const variantId = await uuidV7({ lix: project.lix });
|
|
23
|
-
const matches = [
|
|
24
|
-
{ type: "literal-match", key: "platform", value: "web" },
|
|
25
|
-
];
|
|
26
|
-
const pattern = [{ type: "text", value: "Hello web" }];
|
|
27
|
-
await expect(project.db
|
|
28
|
-
.insertInto("variant")
|
|
29
|
-
.values({
|
|
30
|
-
id: variantId,
|
|
31
|
-
messageId,
|
|
32
|
-
matches,
|
|
33
|
-
pattern,
|
|
34
|
-
})
|
|
35
|
-
.execute()).resolves.not.toThrow();
|
|
36
|
-
const stored = await project.db
|
|
37
|
-
.selectFrom("variant")
|
|
38
|
-
.selectAll()
|
|
39
|
-
.where("id", "=", variantId)
|
|
40
|
-
.executeTakeFirstOrThrow();
|
|
41
|
-
expect(stored.messageId).toBe(messageId);
|
|
42
|
-
expect(stored.matches).toEqual(matches);
|
|
43
|
-
expect(stored.pattern).toEqual(pattern);
|
|
44
|
-
await project.close();
|
|
45
|
-
});
|
|
46
|
-
test("variant schema enforces message foreign key", async () => {
|
|
47
|
-
const project = await loadProjectInMemory({ blob: await newProject() });
|
|
48
|
-
let wasRejected = false;
|
|
49
|
-
try {
|
|
50
|
-
await project.db
|
|
51
|
-
.insertInto("variant")
|
|
52
|
-
.values({
|
|
53
|
-
id: await uuidV7({ lix: project.lix }),
|
|
54
|
-
messageId: "missing-message",
|
|
55
|
-
matches: [],
|
|
56
|
-
pattern: [],
|
|
57
|
-
})
|
|
58
|
-
.execute();
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
wasRejected = true;
|
|
62
|
-
expect(error?.resultCode ?? error.message).toBeDefined();
|
|
63
|
-
}
|
|
64
|
-
expect(wasRejected).toBe(true);
|
|
65
|
-
await project.close();
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=variant.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant.test.js","sourceRoot":"/","sources":["schema-definitions/variant.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;IACnE,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IACxE,MAAM,QAAQ,GAAG,oBAAoB,CAAC;IACtC,MAAM,OAAO,CAAC,EAAE;SACd,UAAU,CAAC,QAAQ,CAAC;SACpB,MAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;SAC1C,OAAO,EAAE,CAAC;IAEZ,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EA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H,IAAI,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;IAC9D,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IAExE,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,CAAC;QACJ,MAAM,OAAO,CAAC,EAAE;aACd,UAAU,CAAC,SAAS,CAAC;aACrB,MAAM,CAAC;YACP,EAAE,EAAE,MAAM,MAAM,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;YACtC,SAAS,EAAE,iBAAiB;YAC5B,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;SACX,CAAC;aACD,OAAO,EAAE,CAAC;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,WAAW,GAAG,IAAI,CAAC;QACnB,MAAM,CACJ,KAAa,EAAE,UAAU,IAAK,KAAe,CAAC,OAAO,CACtD,CAAC,WAAW,EAAE,CAAC;IACjB,CAAC;IACD,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/B,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"vitest\";\nimport { uuidV7 } from \"@lix-js/sdk\";\nimport { newProject } from \"../project/newProject.js\";\nimport { loadProjectInMemory } from \"../project/loadProjectInMemory.js\";\n\ntest(\"variant schema persists matches and pattern JSON\", async () => {\n\tconst project = await loadProjectInMemory({ blob: await newProject() });\n\tconst bundleId = \"bundle-for-variant\";\n\tawait project.db\n\t\t.insertInto(\"bundle\")\n\t\t.values({ id: bundleId, declarations: [] })\n\t\t.execute();\n\n\tconst messageId = await uuidV7({ lix: project.lix });\n\tawait project.db\n\t\t.insertInto(\"message\")\n\t\t.values({\n\t\t\tid: messageId,\n\t\t\tbundleId,\n\t\t\tlocale: \"en\",\n\t\t\tselectors: [],\n\t\t})\n\t\t.execute();\n\n\tconst variantId = await uuidV7({ lix: project.lix });\n\tconst matches = [\n\t\t{ type: \"literal-match\" as const, key: \"platform\", value: \"web\" },\n\t];\n\tconst pattern = [{ type: \"text\" as const, value: \"Hello web\" }];\n\n\tawait expect(\n\t\tproject.db\n\t\t\t.insertInto(\"variant\")\n\t\t\t.values({\n\t\t\t\tid: variantId,\n\t\t\t\tmessageId,\n\t\t\t\tmatches,\n\t\t\t\tpattern,\n\t\t\t})\n\t\t\t.execute()\n\t).resolves.not.toThrow();\n\n\tconst stored = await project.db\n\t\t.selectFrom(\"variant\")\n\t\t.selectAll()\n\t\t.where(\"id\", \"=\", variantId)\n\t\t.executeTakeFirstOrThrow();\n\n\texpect(stored.messageId).toBe(messageId);\n\texpect(stored.matches).toEqual(matches);\n\texpect(stored.pattern).toEqual(pattern);\n\n\tawait project.close();\n});\n\ntest(\"variant schema enforces message foreign key\", async () => {\n\tconst project = await loadProjectInMemory({ blob: await newProject() });\n\n\tlet wasRejected = false;\n\ttry {\n\t\tawait project.db\n\t\t\t.insertInto(\"variant\")\n\t\t\t.values({\n\t\t\t\tid: await uuidV7({ lix: project.lix }),\n\t\t\t\tmessageId: \"missing-message\",\n\t\t\t\tmatches: [],\n\t\t\t\tpattern: [],\n\t\t\t})\n\t\t\t.execute();\n\t} catch (error) {\n\t\twasRejected = true;\n\t\texpect(\n\t\t\t(error as any)?.resultCode ?? (error as Error).message\n\t\t).toBeDefined();\n\t}\n\texpect(wasRejected).toBe(true);\n\n\tawait project.close();\n});\n"]}
|