@inlang/sdk 2.6.2 → 2.8.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/dist/json-schema/old-v1-message/toMessageV1.js +5 -0
- package/dist/json-schema/old-v1-message/toMessageV1.js.map +1 -1
- package/dist/json-schema/old-v1-message/toMessageV1.test.js +41 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.js.map +1 -1
- package/dist/json-schema/pattern.d.ts +134 -0
- package/dist/json-schema/pattern.d.ts.map +1 -1
- package/dist/json-schema/pattern.js +23 -1
- package/dist/json-schema/pattern.js.map +1 -1
- package/dist/json-schema/settings.d.ts +0 -1
- package/dist/json-schema/settings.d.ts.map +1 -1
- package/dist/json-schema/settings.js +0 -5
- package/dist/json-schema/settings.js.map +1 -1
- package/dist/project/loadProject.d.ts +0 -9
- package/dist/project/loadProject.d.ts.map +1 -1
- package/dist/project/loadProject.js +0 -16
- package/dist/project/loadProject.js.map +1 -1
- package/dist/project/loadProjectFromDirectory.d.ts.map +1 -1
- package/dist/project/loadProjectFromDirectory.js +1 -1
- package/dist/project/loadProjectFromDirectory.js.map +1 -1
- package/dist/project/newProject.d.ts.map +1 -1
- package/dist/project/newProject.js +1 -6
- package/dist/project/newProject.js.map +1 -1
- package/dist/project/newProject.test.js +12 -0
- package/dist/project/newProject.test.js.map +1 -1
- package/dist/query-utilities/selectBundleNested.d.ts +60 -0
- package/dist/query-utilities/selectBundleNested.d.ts.map +1 -1
- package/dist/services/env-variables/index.d.ts +0 -1
- package/dist/services/env-variables/index.d.ts.map +1 -1
- package/dist/services/env-variables/index.js +1 -2
- package/dist/services/env-variables/index.js.map +1 -1
- package/package.json +1 -1
- package/src/json-schema/old-v1-message/toMessageV1.test.ts +45 -0
- package/src/json-schema/old-v1-message/toMessageV1.ts +8 -0
- package/src/json-schema/pattern.ts +33 -1
- package/src/json-schema/settings.ts +0 -10
- package/src/project/loadProject.ts +0 -28
- package/src/project/loadProjectFromDirectory.ts +1 -6
- package/src/project/newProject.test.ts +16 -0
- package/src/project/newProject.ts +1 -6
- package/src/services/env-variables/createIndexFile.js +0 -1
- package/src/services/env-variables/index.d.ts +0 -1
- package/dist/project/maybeCaptureTelemetry.d.ts +0 -16
- package/dist/project/maybeCaptureTelemetry.d.ts.map +0 -1
- package/dist/project/maybeCaptureTelemetry.js +0 -61
- package/dist/project/maybeCaptureTelemetry.js.map +0 -1
- package/dist/project/maybeCaptureTelemetry.test.d.ts +0 -2
- package/dist/project/maybeCaptureTelemetry.test.d.ts.map +0 -1
- package/dist/project/maybeCaptureTelemetry.test.js +0 -69
- package/dist/project/maybeCaptureTelemetry.test.js.map +0 -1
- package/dist/services/telemetry/capture.d.ts +0 -24
- package/dist/services/telemetry/capture.d.ts.map +0 -1
- package/dist/services/telemetry/capture.js +0 -72
- package/dist/services/telemetry/capture.js.map +0 -1
- package/dist/services/telemetry/capture.test.d.ts +0 -2
- package/dist/services/telemetry/capture.test.d.ts.map +0 -1
- package/dist/services/telemetry/capture.test.js +0 -43
- package/dist/services/telemetry/capture.test.js.map +0 -1
- package/src/project/maybeCaptureTelemetry.test.ts +0 -80
- package/src/project/maybeCaptureTelemetry.ts +0 -77
- package/src/services/telemetry/capture.test.ts +0 -50
- package/src/services/telemetry/capture.ts +0 -98
|
@@ -55,6 +55,11 @@ function toV1Pattern(pattern) {
|
|
|
55
55
|
}
|
|
56
56
|
throw new Error(`Unsupported expression argument type`);
|
|
57
57
|
}
|
|
58
|
+
case "markup-start":
|
|
59
|
+
case "markup-end":
|
|
60
|
+
case "markup-standalone": {
|
|
61
|
+
throw new Error("Markup placeholders are not supported in MessageV1 conversion");
|
|
62
|
+
}
|
|
58
63
|
default: {
|
|
59
64
|
throw new Error(`Unsupported pattern element type`);
|
|
60
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toMessageV1.js","sourceRoot":"/","sources":["json-schema/old-v1-message/toMessageV1.ts"],"names":[],"mappings":"AASA;;;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E,MAAM;oBACZ,KAAK,EAAE,OAAO,CAAC,KAAK;iBACpB,CAAC;YACH,CAAC;YAED,KAAK,YAAY,CAAC,CAAC,CAAC;gBACnB,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;oBAC/C,OAAO;wBACN,IAAI,EAAE,mBAAmB;wBACzB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;qBACtB,CAAC;gBACH,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;YACzD,CAAC;YAED,OAAO,CAAC,CAAC,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACrD,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleNested } from \"../../database/schema.js\";\nimport type { Pattern } from \"../pattern.js\";\nimport type {\n\tExpressionV1,\n\tMessageV1,\n\tPatternV1,\n\tVariantV1,\n} from \"./schemaV1.js\";\n\n/**\n * Converts a BundleNested into a legacy format.\n *\n * @throws If the message cannot be represented in the v1 format\n */\nexport function toMessageV1(bundle: BundleNested): MessageV1 {\n\tconst variants: VariantV1[] = [];\n\tconst selectorNames = new Set<string>();\n\n\tfor (const message of bundle.messages) {\n\t\t// collect all selector names\n\t\tfor (const selector of message.selectors.map((s) => ({\n\t\t\ttype: \"variable-reference\",\n\t\t\tname: s.name,\n\t\t}))) {\n\t\t\tselectorNames.add(selector.name);\n\t\t}\n\n\t\t// collect all variants\n\t\tfor (const variant of message.variants) {\n\t\t\tvariants.push({\n\t\t\t\tlanguageTag: message.locale,\n\t\t\t\tmatch: [],\n\t\t\t\tpattern: toV1Pattern(variant.pattern),\n\t\t\t});\n\t\t}\n\t}\n\n\tconst selectors: ExpressionV1[] = [...selectorNames].map((name) => ({\n\t\ttype: \"VariableReference\",\n\t\tname,\n\t}));\n\n\treturn {\n\t\tid: bundle.id,\n\t\talias: {},\n\t\tvariants,\n\t\tselectors,\n\t};\n}\n\n/**\n * @throws If the pattern cannot be represented in the v1 format\n */\nfunction toV1Pattern(pattern: Pattern): PatternV1 {\n\treturn pattern.map((element) => {\n\t\tswitch (element.type) {\n\t\t\tcase \"text\": {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"Text\",\n\t\t\t\t\tvalue: element.value,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tcase \"expression\": {\n\t\t\t\tif (element.arg.type === \"variable-reference\") {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"VariableReference\",\n\t\t\t\t\t\tname: element.arg.name,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tthrow new Error(`Unsupported expression argument type`);\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unsupported pattern element type`);\n\t\t\t}\n\t\t}\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"toMessageV1.js","sourceRoot":"/","sources":["json-schema/old-v1-message/toMessageV1.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,MAAoB;IAC/C,MAAM,QAAQ,GAAgB,EAAE,CAAC;IACjC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IAExC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACvC,6BAA6B;QAC7B,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACpD,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,CAAC,CAAC,IAAI;SACZ,CAAC,CAAC,EAAE,CAAC;YACL,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC;QAED,uBAAuB;QACvB,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACxC,QAAQ,CAAC,IAAI,CAAC;gBACb,WAAW,E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,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleNested } from \"../../database/schema.js\";\nimport type { Pattern } from \"../pattern.js\";\nimport type {\n\tExpressionV1,\n\tMessageV1,\n\tPatternV1,\n\tVariantV1,\n} from \"./schemaV1.js\";\n\n/**\n * Converts a BundleNested into a legacy format.\n *\n * @throws If the message cannot be represented in the v1 format\n */\nexport function toMessageV1(bundle: BundleNested): MessageV1 {\n\tconst variants: VariantV1[] = [];\n\tconst selectorNames = new Set<string>();\n\n\tfor (const message of bundle.messages) {\n\t\t// collect all selector names\n\t\tfor (const selector of message.selectors.map((s) => ({\n\t\t\ttype: \"variable-reference\",\n\t\t\tname: s.name,\n\t\t}))) {\n\t\t\tselectorNames.add(selector.name);\n\t\t}\n\n\t\t// collect all variants\n\t\tfor (const variant of message.variants) {\n\t\t\tvariants.push({\n\t\t\t\tlanguageTag: message.locale,\n\t\t\t\tmatch: [],\n\t\t\t\tpattern: toV1Pattern(variant.pattern),\n\t\t\t});\n\t\t}\n\t}\n\n\tconst selectors: ExpressionV1[] = [...selectorNames].map((name) => ({\n\t\ttype: \"VariableReference\",\n\t\tname,\n\t}));\n\n\treturn {\n\t\tid: bundle.id,\n\t\talias: {},\n\t\tvariants,\n\t\tselectors,\n\t};\n}\n\n/**\n * @throws If the pattern cannot be represented in the v1 format\n */\nfunction toV1Pattern(pattern: Pattern): PatternV1 {\n\treturn pattern.map((element) => {\n\t\tswitch (element.type) {\n\t\t\tcase \"text\": {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"Text\",\n\t\t\t\t\tvalue: element.value,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tcase \"expression\": {\n\t\t\t\tif (element.arg.type === \"variable-reference\") {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"VariableReference\",\n\t\t\t\t\t\tname: element.arg.name,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tthrow new Error(`Unsupported expression argument type`);\n\t\t\t}\n\n\t\t\tcase \"markup-start\":\n\t\t\tcase \"markup-end\":\n\t\t\tcase \"markup-standalone\": {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Markup placeholders are not supported in MessageV1 conversion\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unsupported pattern element type`);\n\t\t\t}\n\t\t}\n\t});\n}\n"]}
|
|
@@ -7,6 +7,47 @@ test("toMessageV1", () => {
|
|
|
7
7
|
expect(Value.Check(MessageV1, message)).toBe(true);
|
|
8
8
|
expect(message).toStrictEqual(messageV1);
|
|
9
9
|
});
|
|
10
|
+
test("throws when message contains markup placeholders", () => {
|
|
11
|
+
const markupBundle = {
|
|
12
|
+
id: "hello_world",
|
|
13
|
+
declarations: [],
|
|
14
|
+
messages: [
|
|
15
|
+
{
|
|
16
|
+
bundleId: "hello_world",
|
|
17
|
+
id: "hello_world_en",
|
|
18
|
+
locale: "en",
|
|
19
|
+
selectors: [],
|
|
20
|
+
variants: [
|
|
21
|
+
{
|
|
22
|
+
id: "hello_world_en_1",
|
|
23
|
+
matches: [],
|
|
24
|
+
messageId: "hello_world_en",
|
|
25
|
+
pattern: [
|
|
26
|
+
{
|
|
27
|
+
type: "markup-start",
|
|
28
|
+
name: "b",
|
|
29
|
+
options: [
|
|
30
|
+
{
|
|
31
|
+
name: "kind",
|
|
32
|
+
value: { type: "literal", value: "strong" },
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
attributes: [{ name: "track", value: true }],
|
|
36
|
+
},
|
|
37
|
+
{ type: "text", value: "Hello World!" },
|
|
38
|
+
{
|
|
39
|
+
type: "markup-end",
|
|
40
|
+
name: "b",
|
|
41
|
+
attributes: [{ name: "track", value: true }],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
expect(() => toMessageV1(markupBundle)).toThrow("Markup placeholders are not supported in MessageV1 conversion");
|
|
50
|
+
});
|
|
10
51
|
test.todo("with variable references", () => { });
|
|
11
52
|
const messageV1 = {
|
|
12
53
|
id: "hello_world",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toMessageV1.test.js","sourceRoot":"/","sources":["json-schema/old-v1-message/toMessageV1.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;IACxB,MAAM,OAAO,GAAY,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEnD,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAEhD,MAAM,SAAS,GAAc;IAC5B,EAAE,EAAE,aAAa;IACjB,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE;QACT;YACC,WAAW,EAAE,IAAI;YACjB,KAAK,EAAE,EAAE;YACT,OAAO,EAAE;gBACR;oBACC,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,cAAc;iBACrB;aACD;SACD;QACD;YACC,WAAW,EAAE,IAAI;YACjB,KAAK,EAAE,EAAE;YACT,OAAO,EAAE;gBACR;oBACC,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,aAAa;iBACpB;aACD;SACD;KACD;IACD,SAAS,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,MAAM,GAAiB;IAC5B,EAAE,EAAE,aAAa;IACjB,YAAY,EAAE,EAAE;IAChB,QAAQ,EAAE;QACT;YACC,QAAQ,EAAE,aAAa;YACvB,EAAE,EAAE,aAAa,GAAG,KAAK;YACzB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE;gBACT;oBACC,EAAE,EAAE,aAAa,GAAG,OAAO;oBAC3B,OAAO,EAAE,EAAE;oBACX,SAAS,EAAE,aAAa,GAAG,KAAK;oBAChC,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,MAAM;4BACZ,KAAK,EAAE,cAAc;yBACrB;qBACD;iBACD;aACD;SACD;QACD;YACC,QAAQ,EAAE,aAAa;YACvB,EAAE,EAAE,aAAa,GAAG,KAAK;YACzB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE;gBACT;oBACC,EAAE,EAAE,aAAa,GAAG,OAAO;oBAC3B,OAAO,EAAE,EAAE;oBACX,SAAS,EAAE,aAAa,GAAG,KAAK;oBAChC,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,MAAM;4BACZ,KAAK,EAAE,aAAa;yBACpB;qBACD;iBACD;aACD;SACD;KACD;CACD,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { toMessageV1 } from \"./toMessageV1.js\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport { MessageV1 } from \"./schemaV1.js\";\nimport type { BundleNested } from \"../../database/schema.js\";\n\ntest(\"toMessageV1\", () => {\n\tconst message: unknown = toMessageV1(bundle);\n\texpect(Value.Check(MessageV1, message)).toBe(true);\n\n\texpect(message).toStrictEqual(messageV1);\n});\n\ntest.todo(\"with variable references\", () => {});\n\nconst messageV1: MessageV1 = {\n\tid: \"hello_world\",\n\talias: {},\n\tvariants: [\n\t\t{\n\t\t\tlanguageTag: \"en\",\n\t\t\tmatch: [],\n\t\t\tpattern: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"Text\",\n\t\t\t\t\tvalue: \"Hello World!\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tlanguageTag: \"de\",\n\t\t\tmatch: [],\n\t\t\tpattern: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"Text\",\n\t\t\t\t\tvalue: \"Hallo Welt!\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n\tselectors: [],\n};\n\nconst bundle: BundleNested = {\n\tid: \"hello_world\",\n\tdeclarations: [],\n\tmessages: [\n\t\t{\n\t\t\tbundleId: \"hello_world\",\n\t\t\tid: \"hello_world\" + \"_en\",\n\t\t\tlocale: \"en\",\n\t\t\tselectors: [],\n\t\t\tvariants: [\n\t\t\t\t{\n\t\t\t\t\tid: \"hello_world\" + \"_en_1\",\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tmessageId: \"hello_world\" + \"_en\",\n\t\t\t\t\tpattern: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\tvalue: \"Hello World!\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tbundleId: \"hello_world\",\n\t\t\tid: \"hello_world\" + \"_de\",\n\t\t\tlocale: \"de\",\n\t\t\tselectors: [],\n\t\t\tvariants: [\n\t\t\t\t{\n\t\t\t\t\tid: \"hello_world\" + \"_de_1\",\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tmessageId: \"hello_world\" + \"_de\",\n\t\t\t\t\tpattern: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\tvalue: \"Hallo Welt!\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n};\n"]}
|
|
1
|
+
{"version":3,"file":"toMessageV1.test.js","sourceRoot":"/","sources":["json-schema/old-v1-message/toMessageV1.test.ts"],"names":[],"mappings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aACD;SACD;QACD;YACC,QAAQ,EAAE,aAAa;YACvB,EAAE,EAAE,aAAa,GAAG,KAAK;YACzB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE;gBACT;oBACC,EAAE,EAAE,aAAa,GAAG,OAAO;oBAC3B,OAAO,EAAE,EAAE;oBACX,SAAS,EAAE,aAAa,GAAG,KAAK;oBAChC,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,MAAM;4BACZ,KAAK,EAAE,aAAa;yBACpB;qBACD;iBACD;aACD;SACD;KACD;CACD,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { toMessageV1 } from \"./toMessageV1.js\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport { MessageV1 } from \"./schemaV1.js\";\nimport type { BundleNested } from \"../../database/schema.js\";\n\ntest(\"toMessageV1\", () => {\n\tconst message: unknown = toMessageV1(bundle);\n\texpect(Value.Check(MessageV1, message)).toBe(true);\n\n\texpect(message).toStrictEqual(messageV1);\n});\n\ntest(\"throws when message contains markup placeholders\", () => {\n\tconst markupBundle: BundleNested = {\n\t\tid: \"hello_world\",\n\t\tdeclarations: [],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tbundleId: \"hello_world\",\n\t\t\t\tid: \"hello_world_en\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"hello_world_en_1\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tmessageId: \"hello_world_en\",\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-start\",\n\t\t\t\t\t\t\t\tname: \"b\",\n\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: \"kind\",\n\t\t\t\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"strong\" },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tattributes: [{ name: \"track\", value: true }],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello World!\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-end\",\n\t\t\t\t\t\t\t\tname: \"b\",\n\t\t\t\t\t\t\t\tattributes: [{ name: \"track\", value: true }],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\texpect(() => toMessageV1(markupBundle)).toThrow(\n\t\t\"Markup placeholders are not supported in MessageV1 conversion\"\n\t);\n});\n\ntest.todo(\"with variable references\", () => {});\n\nconst messageV1: MessageV1 = {\n\tid: \"hello_world\",\n\talias: {},\n\tvariants: [\n\t\t{\n\t\t\tlanguageTag: \"en\",\n\t\t\tmatch: [],\n\t\t\tpattern: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"Text\",\n\t\t\t\t\tvalue: \"Hello World!\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tlanguageTag: \"de\",\n\t\t\tmatch: [],\n\t\t\tpattern: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"Text\",\n\t\t\t\t\tvalue: \"Hallo Welt!\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n\tselectors: [],\n};\n\nconst bundle: BundleNested = {\n\tid: \"hello_world\",\n\tdeclarations: [],\n\tmessages: [\n\t\t{\n\t\t\tbundleId: \"hello_world\",\n\t\t\tid: \"hello_world\" + \"_en\",\n\t\t\tlocale: \"en\",\n\t\t\tselectors: [],\n\t\t\tvariants: [\n\t\t\t\t{\n\t\t\t\t\tid: \"hello_world\" + \"_en_1\",\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tmessageId: \"hello_world\" + \"_en\",\n\t\t\t\t\tpattern: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\tvalue: \"Hello World!\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tbundleId: \"hello_world\",\n\t\t\tid: \"hello_world\" + \"_de\",\n\t\t\tlocale: \"de\",\n\t\t\tselectors: [],\n\t\t\tvariants: [\n\t\t\t\t{\n\t\t\t\t\tid: \"hello_world\" + \"_de_1\",\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tmessageId: \"hello_world\" + \"_de\",\n\t\t\t\t\tpattern: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\tvalue: \"Hallo Welt!\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n};\n"]}
|
|
@@ -20,6 +20,14 @@ export declare const Option: import("@sinclair/typebox").TObject<{
|
|
|
20
20
|
name: import("@sinclair/typebox").TString;
|
|
21
21
|
}>]>;
|
|
22
22
|
}>;
|
|
23
|
+
export type Attribute = Static<typeof Attribute>;
|
|
24
|
+
export declare const Attribute: import("@sinclair/typebox").TObject<{
|
|
25
|
+
name: import("@sinclair/typebox").TString;
|
|
26
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
27
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
28
|
+
value: import("@sinclair/typebox").TString;
|
|
29
|
+
}>, import("@sinclair/typebox").TLiteral<true>]>;
|
|
30
|
+
}>;
|
|
23
31
|
export type FunctionReference = Static<typeof FunctionReference>;
|
|
24
32
|
export declare const FunctionReference: import("@sinclair/typebox").TObject<{
|
|
25
33
|
type: import("@sinclair/typebox").TLiteral<"function-reference">;
|
|
@@ -65,6 +73,72 @@ export declare const Text: import("@sinclair/typebox").TObject<{
|
|
|
65
73
|
type: import("@sinclair/typebox").TLiteral<"text">;
|
|
66
74
|
value: import("@sinclair/typebox").TString;
|
|
67
75
|
}>;
|
|
76
|
+
export type MarkupStart = Static<typeof MarkupStart>;
|
|
77
|
+
export declare const MarkupStart: import("@sinclair/typebox").TObject<{
|
|
78
|
+
type: import("@sinclair/typebox").TLiteral<"markup-start">;
|
|
79
|
+
name: import("@sinclair/typebox").TString;
|
|
80
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
81
|
+
name: import("@sinclair/typebox").TString;
|
|
82
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
83
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
84
|
+
value: import("@sinclair/typebox").TString;
|
|
85
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
86
|
+
type: import("@sinclair/typebox").TLiteral<"variable-reference">;
|
|
87
|
+
name: import("@sinclair/typebox").TString;
|
|
88
|
+
}>]>;
|
|
89
|
+
}>>>;
|
|
90
|
+
attributes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
91
|
+
name: import("@sinclair/typebox").TString;
|
|
92
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
93
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
94
|
+
value: import("@sinclair/typebox").TString;
|
|
95
|
+
}>, import("@sinclair/typebox").TLiteral<true>]>;
|
|
96
|
+
}>>>;
|
|
97
|
+
}>;
|
|
98
|
+
export type MarkupEnd = Static<typeof MarkupEnd>;
|
|
99
|
+
export declare const MarkupEnd: import("@sinclair/typebox").TObject<{
|
|
100
|
+
type: import("@sinclair/typebox").TLiteral<"markup-end">;
|
|
101
|
+
name: import("@sinclair/typebox").TString;
|
|
102
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
103
|
+
name: import("@sinclair/typebox").TString;
|
|
104
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
105
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
106
|
+
value: import("@sinclair/typebox").TString;
|
|
107
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
108
|
+
type: import("@sinclair/typebox").TLiteral<"variable-reference">;
|
|
109
|
+
name: import("@sinclair/typebox").TString;
|
|
110
|
+
}>]>;
|
|
111
|
+
}>>>;
|
|
112
|
+
attributes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
113
|
+
name: import("@sinclair/typebox").TString;
|
|
114
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
115
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
116
|
+
value: import("@sinclair/typebox").TString;
|
|
117
|
+
}>, import("@sinclair/typebox").TLiteral<true>]>;
|
|
118
|
+
}>>>;
|
|
119
|
+
}>;
|
|
120
|
+
export type MarkupStandalone = Static<typeof MarkupStandalone>;
|
|
121
|
+
export declare const MarkupStandalone: import("@sinclair/typebox").TObject<{
|
|
122
|
+
type: import("@sinclair/typebox").TLiteral<"markup-standalone">;
|
|
123
|
+
name: import("@sinclair/typebox").TString;
|
|
124
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
125
|
+
name: import("@sinclair/typebox").TString;
|
|
126
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
127
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
128
|
+
value: import("@sinclair/typebox").TString;
|
|
129
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
130
|
+
type: import("@sinclair/typebox").TLiteral<"variable-reference">;
|
|
131
|
+
name: import("@sinclair/typebox").TString;
|
|
132
|
+
}>]>;
|
|
133
|
+
}>>>;
|
|
134
|
+
attributes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
135
|
+
name: import("@sinclair/typebox").TString;
|
|
136
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
137
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
138
|
+
value: import("@sinclair/typebox").TString;
|
|
139
|
+
}>, import("@sinclair/typebox").TLiteral<true>]>;
|
|
140
|
+
}>>>;
|
|
141
|
+
}>;
|
|
68
142
|
export type LocalVariable = Static<typeof LocalVariable>;
|
|
69
143
|
export declare const LocalVariable: import("@sinclair/typebox").TObject<{
|
|
70
144
|
type: import("@sinclair/typebox").TLiteral<"local-variable">;
|
|
@@ -186,5 +260,65 @@ export declare const Pattern: import("@sinclair/typebox").TArray<import("@sincla
|
|
|
186
260
|
}>]>;
|
|
187
261
|
}>>;
|
|
188
262
|
}>>;
|
|
263
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
264
|
+
type: import("@sinclair/typebox").TLiteral<"markup-start">;
|
|
265
|
+
name: import("@sinclair/typebox").TString;
|
|
266
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
267
|
+
name: import("@sinclair/typebox").TString;
|
|
268
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
269
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
270
|
+
value: import("@sinclair/typebox").TString;
|
|
271
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
272
|
+
type: import("@sinclair/typebox").TLiteral<"variable-reference">;
|
|
273
|
+
name: import("@sinclair/typebox").TString;
|
|
274
|
+
}>]>;
|
|
275
|
+
}>>>;
|
|
276
|
+
attributes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
277
|
+
name: import("@sinclair/typebox").TString;
|
|
278
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
279
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
280
|
+
value: import("@sinclair/typebox").TString;
|
|
281
|
+
}>, import("@sinclair/typebox").TLiteral<true>]>;
|
|
282
|
+
}>>>;
|
|
283
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
284
|
+
type: import("@sinclair/typebox").TLiteral<"markup-end">;
|
|
285
|
+
name: import("@sinclair/typebox").TString;
|
|
286
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
287
|
+
name: import("@sinclair/typebox").TString;
|
|
288
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
289
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
290
|
+
value: import("@sinclair/typebox").TString;
|
|
291
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
292
|
+
type: import("@sinclair/typebox").TLiteral<"variable-reference">;
|
|
293
|
+
name: import("@sinclair/typebox").TString;
|
|
294
|
+
}>]>;
|
|
295
|
+
}>>>;
|
|
296
|
+
attributes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
297
|
+
name: import("@sinclair/typebox").TString;
|
|
298
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
299
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
300
|
+
value: import("@sinclair/typebox").TString;
|
|
301
|
+
}>, import("@sinclair/typebox").TLiteral<true>]>;
|
|
302
|
+
}>>>;
|
|
303
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
304
|
+
type: import("@sinclair/typebox").TLiteral<"markup-standalone">;
|
|
305
|
+
name: import("@sinclair/typebox").TString;
|
|
306
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
307
|
+
name: import("@sinclair/typebox").TString;
|
|
308
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
309
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
310
|
+
value: import("@sinclair/typebox").TString;
|
|
311
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
312
|
+
type: import("@sinclair/typebox").TLiteral<"variable-reference">;
|
|
313
|
+
name: import("@sinclair/typebox").TString;
|
|
314
|
+
}>]>;
|
|
315
|
+
}>>>;
|
|
316
|
+
attributes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
317
|
+
name: import("@sinclair/typebox").TString;
|
|
318
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
319
|
+
type: import("@sinclair/typebox").TLiteral<"literal">;
|
|
320
|
+
value: import("@sinclair/typebox").TString;
|
|
321
|
+
}>, import("@sinclair/typebox").TLiteral<true>]>;
|
|
322
|
+
}>>>;
|
|
189
323
|
}>]>>;
|
|
190
324
|
//# sourceMappingURL=pattern.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pattern.d.ts","sourceRoot":"/","sources":["json-schema/pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACjE,eAAO,MAAM,iBAAiB;;;EAG5B,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,OAAO,CAAC,CAAC;AAC7C,eAAO,MAAM,OAAO;;;EAGlB,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC;AAC3C,eAAO,MAAM,MAAM;;;;;;;;;EAGjB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACjE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;EAI5B,CAAC;AAEH,MAAM,MAAM,U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AAEtE,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,OAAO,CAAC,CAAC;AAC7C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEnB,CAAC"}
|
|
@@ -11,6 +11,10 @@ export const Option = Type.Object({
|
|
|
11
11
|
name: Type.String(),
|
|
12
12
|
value: Type.Union([Literal, VariableReference]),
|
|
13
13
|
});
|
|
14
|
+
export const Attribute = Type.Object({
|
|
15
|
+
name: Type.String(),
|
|
16
|
+
value: Type.Union([Literal, Type.Literal(true)]),
|
|
17
|
+
});
|
|
14
18
|
export const FunctionReference = Type.Object({
|
|
15
19
|
type: Type.Literal("function-reference"),
|
|
16
20
|
name: Type.String(),
|
|
@@ -25,6 +29,24 @@ export const Text = Type.Object({
|
|
|
25
29
|
type: Type.Literal("text"),
|
|
26
30
|
value: Type.String(),
|
|
27
31
|
});
|
|
32
|
+
export const MarkupStart = Type.Object({
|
|
33
|
+
type: Type.Literal("markup-start"),
|
|
34
|
+
name: Type.String(),
|
|
35
|
+
options: Type.Optional(Type.Array(Option)),
|
|
36
|
+
attributes: Type.Optional(Type.Array(Attribute)),
|
|
37
|
+
});
|
|
38
|
+
export const MarkupEnd = Type.Object({
|
|
39
|
+
type: Type.Literal("markup-end"),
|
|
40
|
+
name: Type.String(),
|
|
41
|
+
options: Type.Optional(Type.Array(Option)),
|
|
42
|
+
attributes: Type.Optional(Type.Array(Attribute)),
|
|
43
|
+
});
|
|
44
|
+
export const MarkupStandalone = Type.Object({
|
|
45
|
+
type: Type.Literal("markup-standalone"),
|
|
46
|
+
name: Type.String(),
|
|
47
|
+
options: Type.Optional(Type.Array(Option)),
|
|
48
|
+
attributes: Type.Optional(Type.Array(Attribute)),
|
|
49
|
+
});
|
|
28
50
|
export const LocalVariable = Type.Object({
|
|
29
51
|
type: Type.Literal("local-variable"),
|
|
30
52
|
name: Type.String(),
|
|
@@ -36,5 +58,5 @@ export const InputVariable = Type.Object({
|
|
|
36
58
|
annotation: Type.Optional(FunctionReference),
|
|
37
59
|
});
|
|
38
60
|
export const Declaration = Type.Union([InputVariable, LocalVariable]);
|
|
39
|
-
export const Pattern = Type.Array(Type.Union([Text, Expression]));
|
|
61
|
+
export const Pattern = Type.Array(Type.Union([Text, Expression, MarkupStart, MarkupEnd, MarkupStandalone]));
|
|
40
62
|
//# sourceMappingURL=pattern.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pattern.js","sourceRoot":"/","sources":["json-schema/pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AAGtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;IACxC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;CACnB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAC7B,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;IACnB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;CAC/C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;IACxC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC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AChD,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACpC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;IACnB,KAAK,EAAE,UAAU;CACjB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACpC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;IACnB,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC;CAC5C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;AAGtE,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAChC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CACxE,CAAC","sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport type VariableReference = Static<typeof VariableReference>;\nexport const VariableReference = Type.Object({\n\ttype: Type.Literal(\"variable-reference\"),\n\tname: Type.String(),\n});\n\nexport type Literal = Static<typeof Literal>;\nexport const Literal = Type.Object({\n\ttype: Type.Literal(\"literal\"),\n\tvalue: Type.String(),\n});\n\nexport type Option = Static<typeof Option>;\nexport const Option = Type.Object({\n\tname: Type.String(),\n\tvalue: Type.Union([Literal, VariableReference]),\n});\n\nexport type Attribute = Static<typeof Attribute>;\nexport const Attribute = Type.Object({\n\tname: Type.String(),\n\tvalue: Type.Union([Literal, Type.Literal(true)]),\n});\n\nexport type FunctionReference = Static<typeof FunctionReference>;\nexport const FunctionReference = Type.Object({\n\ttype: Type.Literal(\"function-reference\"),\n\tname: Type.String(),\n\toptions: Type.Array(Option),\n});\n\nexport type Expression = Static<typeof Expression>;\nexport const Expression = Type.Object({\n\ttype: Type.Literal(\"expression\"),\n\targ: Type.Union([VariableReference, Literal]),\n\tannotation: Type.Optional(FunctionReference),\n});\n\nexport type Text = Static<typeof Text>;\nexport const Text = Type.Object({\n\ttype: Type.Literal(\"text\"),\n\tvalue: Type.String(),\n});\n\nexport type MarkupStart = Static<typeof MarkupStart>;\nexport const MarkupStart = Type.Object({\n\ttype: Type.Literal(\"markup-start\"),\n\tname: Type.String(),\n\toptions: Type.Optional(Type.Array(Option)),\n\tattributes: Type.Optional(Type.Array(Attribute)),\n});\n\nexport type MarkupEnd = Static<typeof MarkupEnd>;\nexport const MarkupEnd = Type.Object({\n\ttype: Type.Literal(\"markup-end\"),\n\tname: Type.String(),\n\toptions: Type.Optional(Type.Array(Option)),\n\tattributes: Type.Optional(Type.Array(Attribute)),\n});\n\nexport type MarkupStandalone = Static<typeof MarkupStandalone>;\nexport const MarkupStandalone = Type.Object({\n\ttype: Type.Literal(\"markup-standalone\"),\n\tname: Type.String(),\n\toptions: Type.Optional(Type.Array(Option)),\n\tattributes: Type.Optional(Type.Array(Attribute)),\n});\n\nexport type LocalVariable = Static<typeof LocalVariable>;\nexport const LocalVariable = Type.Object({\n\ttype: Type.Literal(\"local-variable\"),\n\tname: Type.String(),\n\tvalue: Expression,\n});\n\nexport type InputVariable = Static<typeof InputVariable>;\nexport const InputVariable = Type.Object({\n\ttype: Type.Literal(\"input-variable\"),\n\tname: Type.String(),\n\tannotation: Type.Optional(FunctionReference),\n});\n\nexport type Declaration = Static<typeof Declaration>;\nexport const Declaration = Type.Union([InputVariable, LocalVariable]);\n\nexport type Pattern = Static<typeof Pattern>;\nexport const Pattern = Type.Array(\n\tType.Union([Text, Expression, MarkupStart, MarkupEnd, MarkupStandalone])\n);\n"]}
|
|
@@ -23,7 +23,6 @@ export declare const ProjectSettings: import("@sinclair/typebox").TObject<{
|
|
|
23
23
|
* ]
|
|
24
24
|
*/
|
|
25
25
|
modules: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TString]>>>;
|
|
26
|
-
telemetry: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TLiteral<"off">>;
|
|
27
26
|
experimental: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TLiteral<true>>>;
|
|
28
27
|
}>;
|
|
29
28
|
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"/","sources":["json-schema/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"/","sources":["json-schema/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAqFtD,MAAM,MAAM,eAAe,GAAG,IAAI,CACjC,MAAM,CAAC,OAAO,eAAe,CAAC,EAC9B,cAAc,GAAG,mBAAmB,CACpC,GAAG;IACH,mCAAmC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gCAAgC;IAChC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,uEAAuE;IACvE,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC;CAC5D,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACxB,eAAO,MAAM,eAAe;;;;;;IA3D3B;;;;;;;;OAQG;;;EAmDsC,CAAC"}
|
|
@@ -51,11 +51,6 @@ const SDKSettings = Type.Object({
|
|
|
51
51
|
"./local-testing-plugin.js",
|
|
52
52
|
],
|
|
53
53
|
})),
|
|
54
|
-
telemetry: Type.Optional(Type.Union([
|
|
55
|
-
Type.Literal("off", {
|
|
56
|
-
description: "No telemetry events ",
|
|
57
|
-
}),
|
|
58
|
-
], { description: "If not set, defaults to all" })),
|
|
59
54
|
experimental: Type.Optional(Type.Record(Type.String(), Type.Literal(true), {
|
|
60
55
|
title: "Experimental settings",
|
|
61
56
|
description: "Experimental settings that are used for product development.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"/","sources":["json-schema/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/B,oEAAoE;IACpE,OAAO,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI,CAAC,OAAO,CAAC,4CAA4C,CAAC,CAC1D;IACD,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;QACvB,KAAK,EAAE,aAAa;QACpB,WAAW,EACV,oEAAoE;KACrE,CAAC;IACF,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;QAClC,WAAW,EAAE,IAAI;QACjB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EACV,gJAAgJ;KACjJ,CAAC;IACF,oCAAoC;IACpC,mBAAmB;IACnB,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAC/B,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EACV,gIAAgI;QACjI,UAAU,EAAE,IAAI;KAChB,CAAC,CACF;IACD,oCAAoC;IACpC,mBAAmB;IACnB,YAAY,EAAE,IAAI,CAAC,QAAQ,CAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;QACzB,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,IAAI;QAChB,WAAW,EACV,6HAA6H;KAC9H,CAAC,CACF;IACD;;;;;;;;OAQG;IACH,OAAO,EAAE,IAAI,CAAC,QAAQ,CACr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EAAE,IAAI;QACjB,UAAU,EAAE,IAAI;QAChB,WAAW,EACV,6HAA6H;KAC9H,CAAC,CACF;IACD;;;;;;;;OAQG;IACH,OAAO,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI,CAAC,KAAK,CACT,IAAI,CAAC,SAAS,CAAC;QACd,IAAI,CAAC,MAAM,CAAC;YACX,WAAW,EAAE,uDAAuD;YACpE,OAAO,EACN,sZAAsZ;SACvZ,CAAC;QACF,IAAI,CAAC,MAAM,CAAC;YACX,WAAW,EAAE,iCAAiC;YAC9C,OAAO,EAAE,UAAU;SACnB,CAAC;KACF,CAAC,EACF;QACC,WAAW,EAAE,IAAI;QACjB,WAAW,EACV,+DAA+D;QAChE,QAAQ,EAAE;YACT,qEAAqE;YACrE,iEAAiE;YACjE,2BAA2B;SAC3B;KACD,CACD,CACD;IACD,YAAY,EAAE,IAAI,CAAC,QAAQ,CAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC9C,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EACV,8DAA8D;KAC/D,CAAC,CACF;IACD;;;;OAIG;CACH,CAAC,CAAC;AAaH,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC","sourcesContent":["import { type Static, Type } from \"@sinclair/typebox\";\n\nconst SDKSettings = Type.Object({\n\t// TODO SDK-v2 SETTINGS do we need to generate a settings v2 schema?\n\t$schema: Type.Optional(\n\t\tType.Literal(\"https://inlang.com/schema/project-settings\")\n\t),\n\tbaseLocale: Type.String({\n\t\ttitle: \"Base locale\",\n\t\tdescription:\n\t\t\t\"The base locale of the project. We recommend BCP-47 language tags.\",\n\t}),\n\tlocales: Type.Array(Type.String(), {\n\t\tuniqueItems: true,\n\t\ttitle: \"Project Locales\",\n\t\tdescription:\n\t\t\t\"Set the locales that are available in your project. All locales needs to be a valid BCP-47 language tag. Needs to include the base locale tag.\",\n\t}),\n\t// exits for backwards compatibility\n\t// remove in SDK-v3\n\tsourceLanguageTag: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Use baseLocale instead if all your inlang apps that you are using are on the inlang SDK V2. Otherwise, leave this property in.\",\n\t\t\tdeprecated: true,\n\t\t})\n\t),\n\t// exits for backwards compatibility\n\t// remove in SDK-v3\n\tlanguageTags: Type.Optional(\n\t\tType.Array(Type.String(), {\n\t\t\tuniqueItems: true,\n\t\t\tdeprecated: true,\n\t\t\tdescription:\n\t\t\t\t\"Use locales instead if all your inlang apps that you are using are on the inlang SDK V2. Otherwise, leave this property in.\",\n\t\t})\n\t),\n\t/**\n\t * The modules to load.\n\t *\n\t * @example\n\t * modules: [\n\t * \t \"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@3/dist/index.js\",\n\t * \t \"https://cdn.jsdelivr.net/npm/@inlang/plugin-csv@1/dist/index.js\",\n\t * ]\n\t */\n\tmodules: Type.Optional(\n\t\tType.Array(\n\t\t\tType.Intersect([\n\t\t\t\tType.String({\n\t\t\t\t\tdescription: \"The module must be a valid URI according to RFC 3986.\",\n\t\t\t\t\tpattern:\n\t\t\t\t\t\t\"(?:[A-Za-z][A-Za-z0-9+.-]*:/{2})?(?:(?:[A-Za-z0-9-._~]|%[A-Fa-f0-9]{2})+(?::([A-Za-z0-9-._~]?|[%][A-Fa-f0-9]{2})+)?@)?(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\\\\.){1,126}[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?::[0-9]+)?(?:/(?:[A-Za-z0-9-._~]|%[A-Fa-f0-9]{2})*)*(?:\\\\?(?:[A-Za-z0-9-._~]+(?:=(?:[A-Za-z0-9-._~+]|%[A-Fa-f0-9]{2})+)?)(?:&|;[A-Za-z0-9-._~]+(?:=(?:[A-Za-z0-9-._~+]|%[A-Fa-f0-9]{2})+)?)*)?\",\n\t\t\t\t}),\n\t\t\t\tType.String({\n\t\t\t\t\tdescription: \"The module must end with `.js`.\",\n\t\t\t\t\tpattern: \".*\\\\.js$\",\n\t\t\t\t}),\n\t\t\t]),\n\t\t\t{\n\t\t\t\tuniqueItems: true,\n\t\t\t\tdescription:\n\t\t\t\t\t\"The modules to load. Must be a valid URI but can be relative.\",\n\t\t\t\texamples: [\n\t\t\t\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@3/dist/index.js\",\n\t\t\t\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-csv@1/dist/index.js\",\n\t\t\t\t\t\"./local-testing-plugin.js\",\n\t\t\t\t],\n\t\t\t}\n\t\t)\n\t),\n\texperimental: Type.Optional(\n\t\tType.Record(Type.String(), Type.Literal(true), {\n\t\t\ttitle: \"Experimental settings\",\n\t\t\tdescription:\n\t\t\t\t\"Experimental settings that are used for product development.\",\n\t\t})\n\t),\n\t/**\n\t * plugin.*: JSONObject\n\t *\n\t * The plugin settings are validated when importing plugins\n\t */\n});\n\nexport type ProjectSettings = Omit<\n\tStatic<typeof ProjectSettings>,\n\t\"languageTags\" | \"sourceLanguageTag\"\n> & {\n\t/** @deprecated Use `baseLocale` */\n\tsourceLanguageTag?: string;\n\t/** @deprecated Use `locales` */\n\tlanguageTags?: string[];\n\t/** @deprecated This will soon be replaced by `Lix Validation Rules` */\n\tmessageLintRuleLevels?: Record<string, \"error\" | \"warning\">;\n} & Record<string, any>;\nexport const ProjectSettings = SDKSettings;\n"]}
|
|
@@ -40,14 +40,5 @@ export declare function loadProject(args: {
|
|
|
40
40
|
*
|
|
41
41
|
*/
|
|
42
42
|
preprocessPluginBeforeImport?: PreprocessPluginBeforeImportFunction;
|
|
43
|
-
/**
|
|
44
|
-
* The id of the app that is using the SDK.
|
|
45
|
-
*
|
|
46
|
-
* The is used for telemetry purposes. To derive insights like
|
|
47
|
-
* which app is using the SDK, how many projects are loaded, etc.
|
|
48
|
-
*
|
|
49
|
-
* The app id can be removed at any time in the future
|
|
50
|
-
*/
|
|
51
|
-
appId?: string;
|
|
52
43
|
}): Promise<InlangProject>;
|
|
53
44
|
//# sourceMappingURL=loadProject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadProject.d.ts","sourceRoot":"/","sources":["project/loadProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAEN,KAAK,kBAAkB,EACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEN,KAAK,oCAAoC,EACzC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"loadProject.d.ts","sourceRoot":"/","sources":["project/loadProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAEN,KAAK,kBAAkB,EACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEN,KAAK,oCAAoC,EACzC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAM9C;;GAEG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACvC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IAChC;;;;;;;;;;;OAWG;IACH,4BAA4B,CAAC,EAAE,oCAAoC,CAAC;CACpE,GAAG,OAAO,CAAC,aAAa,CAAC,CA+HzB"}
|
|
@@ -4,7 +4,6 @@ import { initDb } from "../database/initDb.js";
|
|
|
4
4
|
import { importPlugins, } from "../plugin/importPlugins.js";
|
|
5
5
|
import { withLanguageTagToLocaleMigration } from "../migrations/v2/withLanguageTagToLocaleMigration.js";
|
|
6
6
|
import { v4 } from "uuid";
|
|
7
|
-
import { maybeCaptureLoadedProject } from "./maybeCaptureTelemetry.js";
|
|
8
7
|
import { importFiles } from "../import-export/importFiles.js";
|
|
9
8
|
import { exportFiles } from "../import-export/exportFiles.js";
|
|
10
9
|
/**
|
|
@@ -25,25 +24,10 @@ export async function loadProject(args) {
|
|
|
25
24
|
preprocessPluginBeforeImport: args.preprocessPluginBeforeImport,
|
|
26
25
|
});
|
|
27
26
|
const plugins = [...(args.providePlugins ?? []), ...importedPlugins.plugins];
|
|
28
|
-
const idFile = await args.lix.db
|
|
29
|
-
.selectFrom("file")
|
|
30
|
-
.where("path", "=", "/project_id")
|
|
31
|
-
.select("data")
|
|
32
|
-
.executeTakeFirstOrThrow();
|
|
33
|
-
const id = new TextDecoder().decode(idFile.data);
|
|
34
27
|
// const state = createProjectState({
|
|
35
28
|
// ...args,
|
|
36
29
|
// settings,
|
|
37
30
|
// });
|
|
38
|
-
// not awaiting to not block the load time of a project
|
|
39
|
-
maybeCaptureLoadedProject({
|
|
40
|
-
db,
|
|
41
|
-
id,
|
|
42
|
-
settings,
|
|
43
|
-
plugins,
|
|
44
|
-
lix: args.lix,
|
|
45
|
-
appId: args.appId,
|
|
46
|
-
});
|
|
47
31
|
return {
|
|
48
32
|
db,
|
|
49
33
|
id: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadProject.js","sourceRoot":"/","sources":["project/loadProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA0B,MAAM,aAAa,CAAC;AAG7D,OAAO,EACN,mBAAmB,GAEnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EACN,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;QACxC,CAAC;QACD,GAAG,EAAE,IAAI,CAAC,GAAG;KACb,CAAC;AACH,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,IAG1B;IACA,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9C,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE;SACf,WAAW,CAAC,MAAM,CAAC;SACnB,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC;SACjB,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,YAAY,CAAC;SAChC,OAAO,EAAE,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,0BAA0B,CAAC,IAAkB;IAC3D,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE;SAC1C,UAAU,CAAC,MAAM,CAAC;SAClB,MAAM,CAAC,MAAM,CAAC;SACd,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,CAAC;SACjC,gBAAgB,EAAE,CAAC;IAErB,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACzB,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE;aACf,UAAU,CAAC,MAAM,CAAC;aAClB,MAAM,CAAC;YACP,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;SACpC,CAAC;aACD,OAAO,EAAE,CAAC;IACb,CAAC;AACF,CAAC","sourcesContent":["import { toBlob, type Account, type Lix } from \"@lix-js/sdk\";\nimport type { InlangPlugin } from \"../plugin/schema.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport {\n\tcontentFromDatabase,\n\ttype SqliteWasmDatabase,\n} from \"sqlite-wasm-kysely\";\nimport { initDb } from \"../database/initDb.js\";\nimport {\n\timportPlugins,\n\ttype PreprocessPluginBeforeImportFunction,\n} from \"../plugin/importPlugins.js\";\nimport type { InlangProject } from \"./api.js\";\nimport { withLanguageTagToLocaleMigration } from \"../migrations/v2/withLanguageTagToLocaleMigration.js\";\nimport { v4 } from \"uuid\";\nimport { maybeCaptureLoadedProject } from \"./maybeCaptureTelemetry.js\";\nimport { importFiles } from \"../import-export/importFiles.js\";\nimport { exportFiles } from \"../import-export/exportFiles.js\";\n\n/**\n * Common load project logic.\n */\nexport async function loadProject(args: {\n\tsqlite: SqliteWasmDatabase;\n\tlix: Lix;\n\t/**\n\t * The account that loaded the project.\n\t *\n\t * Defaults to an anonymous/new account if undefined.\n\t *\n\t * @example\n\t * const account = localStorage.getItem(\"account\")\n\t * const project = await loadProject({ account })\n\t */\n\taccount?: Account;\n\t/**\n\t * Provide plugins to the project.\n\t *\n\t * This is useful for testing or providing plugins that are\n\t * app specific. Keep in mind that provided plugins\n\t * are not shared with other instances.\n\t */\n\tprovidePlugins?: InlangPlugin[];\n\t/**\n\t * Function that preprocesses the plugin before importing it.\n\t *\n\t * The callback can be used to process plugins as needed in the\n\t * environment of the app. For example, Sherlock uses this to convert\n\t * ESM, which all inlang plugins are written in, to CJS which Sherlock\n\t * runs in.\n\t *\n\t * @example\n\t * const project = await loadProject({ preprocessPluginBeforeImport: (moduleText) => convertEsmToCjs(moduleText) })\n\t *\n\t */\n\tpreprocessPluginBeforeImport?: PreprocessPluginBeforeImportFunction;\n\t/**\n\t * The id of the app that is using the SDK.\n\t *\n\t * The is used for telemetry purposes. To derive insights like\n\t * which app is using the SDK, how many projects are loaded, etc.\n\t *\n\t * The app id can be removed at any time in the future\n\t */\n\tappId?: string;\n}): Promise<InlangProject> {\n\tconst db = initDb({ sqlite: args.sqlite });\n\n\tawait maybeMigrateFirstProjectId({ lix: args.lix });\n\n\tconst settingsFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.select(\"data\")\n\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t.executeTakeFirstOrThrow();\n\n\tconst settings = withLanguageTagToLocaleMigration(\n\t\tJSON.parse(new TextDecoder().decode(settingsFile.data)) as ProjectSettings\n\t);\n\n\tconst importedPlugins = await importPlugins({\n\t\tsettings,\n\t\tlix: args.lix,\n\t\tpreprocessPluginBeforeImport: args.preprocessPluginBeforeImport,\n\t});\n\n\tconst plugins = [...(args.providePlugins ?? []), ...importedPlugins.plugins];\n\n\tconst idFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t.select(\"data\")\n\t\t.executeTakeFirstOrThrow();\n\n\tconst id = new TextDecoder().decode(idFile.data);\n\n\t// const state = createProjectState({\n\t// \t...args,\n\t// \tsettings,\n\t// });\n\n\t// not awaiting to not block the load time of a project\n\tmaybeCaptureLoadedProject({\n\t\tdb,\n\t\tid,\n\t\tsettings,\n\t\tplugins,\n\t\tlix: args.lix,\n\t\tappId: args.appId,\n\t});\n\n\treturn {\n\t\tdb,\n\t\tid: {\n\t\t\tget: async () => {\n\t\t\t\tconst file = await args.lix.db\n\t\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t\t\t\t.select(\"file.data\")\n\t\t\t\t\t.executeTakeFirstOrThrow();\n\t\t\t\treturn new TextDecoder().decode(file.data);\n\t\t\t},\n\t\t},\n\t\tsettings: {\n\t\t\tget: async () => {\n\t\t\t\tconst file = await args.lix.db\n\t\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t\t.select(\"file.data\")\n\t\t\t\t\t.executeTakeFirstOrThrow();\n\t\t\t\treturn withLanguageTagToLocaleMigration(\n\t\t\t\t\tJSON.parse(new TextDecoder().decode(file.data))\n\t\t\t\t);\n\t\t\t},\n\t\t\tset: async (newSettings) => {\n\t\t\t\tconst cloned = JSON.parse(JSON.stringify(newSettings));\n\t\t\t\tcloned.languageTags = cloned.locales;\n\t\t\t\tcloned.sourceLanguageTag = cloned.baseLocale;\n\n\t\t\t\tawait args.lix.db\n\t\t\t\t\t.updateTable(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t\t.set({\n\t\t\t\t\t\tdata: new TextEncoder().encode(\n\t\t\t\t\t\t\tJSON.stringify(cloned, undefined, 2)\n\t\t\t\t\t\t),\n\t\t\t\t\t})\n\t\t\t\t\t.execute();\n\t\t\t},\n\t\t},\n\t\tplugins: {\n\t\t\tget: async () => plugins,\n\t\t},\n\t\terrors: {\n\t\t\tget: async () => [...importedPlugins.errors],\n\t\t},\n\t\t// errors: state.errors,\n\t\timportFiles: async ({ files, pluginKey }) => {\n\t\t\tconst settingsFile = await args.lix.db\n\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t.select(\"file.data\")\n\t\t\t\t.executeTakeFirstOrThrow();\n\n\t\t\tconst settings = JSON.parse(\n\t\t\t\tnew TextDecoder().decode(settingsFile.data)\n\t\t\t) as ProjectSettings;\n\n\t\t\treturn await importFiles({\n\t\t\t\tfiles,\n\t\t\t\tpluginKey,\n\t\t\t\tsettings,\n\t\t\t\t// TODO don't use global state, might be stale\n\t\t\t\tplugins,\n\t\t\t\tdb,\n\t\t\t});\n\t\t},\n\t\texportFiles: async ({ pluginKey }) => {\n\t\t\tconst settingsFile = await args.lix.db\n\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t.select(\"file.data\")\n\t\t\t\t.executeTakeFirstOrThrow();\n\n\t\t\tconst settings = JSON.parse(\n\t\t\t\tnew TextDecoder().decode(settingsFile.data)\n\t\t\t) as ProjectSettings;\n\n\t\t\treturn (\n\t\t\t\tawait exportFiles({\n\t\t\t\t\tpluginKey,\n\t\t\t\t\tdb,\n\t\t\t\t\tsettings,\n\t\t\t\t\t// TODO don't use global state, might be stale\n\t\t\t\t\tplugins,\n\t\t\t\t})\n\t\t\t).map((output) => ({ ...output, pluginKey }));\n\t\t},\n\t\tclose: async () => {\n\t\t\tawait saveDbToLix({ sqlite: args.sqlite, lix: args.lix });\n\t\t\tawait db.destroy();\n\t\t\tawait args.lix.db.destroy();\n\t\t},\n\t\t_sqlite: args.sqlite,\n\t\ttoBlob: async () => {\n\t\t\tawait saveDbToLix({ sqlite: args.sqlite, lix: args.lix });\n\t\t\treturn await toBlob({ lix: args.lix });\n\t\t},\n\t\tlix: args.lix,\n\t};\n}\n\nasync function saveDbToLix(args: {\n\tsqlite: SqliteWasmDatabase;\n\tlix: Lix;\n}): Promise<void> {\n\tconst data = contentFromDatabase(args.sqlite);\n\tawait args.lix.db\n\t\t.updateTable(\"file\")\n\t\t.set(\"data\", data)\n\t\t.where(\"path\", \"=\", \"/db.sqlite\")\n\t\t.execute();\n}\n\n/**\n * Old leftover migration from v1. Probably not needed anymore.\n *\n * Kept it in just in case.\n */\nasync function maybeMigrateFirstProjectId(args: { lix: Lix }): Promise<void> {\n\tconst firstProjectIdFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.select(\"data\")\n\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t.executeTakeFirst();\n\n\tif (!firstProjectIdFile) {\n\t\tawait args.lix.db\n\t\t\t.insertInto(\"file\")\n\t\t\t.values({\n\t\t\t\tpath: \"/project_id\",\n\t\t\t\tdata: new TextEncoder().encode(v4()),\n\t\t\t})\n\t\t\t.execute();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"loadProject.js","sourceRoot":"/","sources":["project/loadProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA0B,MAAM,aAAa,CAAC;AAG7D,OAAO,EACN,mBAAmB,GAEnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EACN,aAAa,GAEb,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gCAAgC,EAAE,MAAM,sDAAsD,CAAC;AACxG,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO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AAE,CAAC;QACzB,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE;aACf,UAAU,CAAC,MAAM,CAAC;aAClB,MAAM,CAAC;YACP,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;SACpC,CAAC;aACD,OAAO,EAAE,CAAC;IACb,CAAC;AACF,CAAC","sourcesContent":["import { toBlob, type Account, type Lix } from \"@lix-js/sdk\";\nimport type { InlangPlugin } from \"../plugin/schema.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport {\n\tcontentFromDatabase,\n\ttype SqliteWasmDatabase,\n} from \"sqlite-wasm-kysely\";\nimport { initDb } from \"../database/initDb.js\";\nimport {\n\timportPlugins,\n\ttype PreprocessPluginBeforeImportFunction,\n} from \"../plugin/importPlugins.js\";\nimport type { InlangProject } from \"./api.js\";\nimport { withLanguageTagToLocaleMigration } from \"../migrations/v2/withLanguageTagToLocaleMigration.js\";\nimport { v4 } from \"uuid\";\nimport { importFiles } from \"../import-export/importFiles.js\";\nimport { exportFiles } from \"../import-export/exportFiles.js\";\n\n/**\n * Common load project logic.\n */\nexport async function loadProject(args: {\n\tsqlite: SqliteWasmDatabase;\n\tlix: Lix;\n\t/**\n\t * The account that loaded the project.\n\t *\n\t * Defaults to an anonymous/new account if undefined.\n\t *\n\t * @example\n\t * const account = localStorage.getItem(\"account\")\n\t * const project = await loadProject({ account })\n\t */\n\taccount?: Account;\n\t/**\n\t * Provide plugins to the project.\n\t *\n\t * This is useful for testing or providing plugins that are\n\t * app specific. Keep in mind that provided plugins\n\t * are not shared with other instances.\n\t */\n\tprovidePlugins?: InlangPlugin[];\n\t/**\n\t * Function that preprocesses the plugin before importing it.\n\t *\n\t * The callback can be used to process plugins as needed in the\n\t * environment of the app. For example, Sherlock uses this to convert\n\t * ESM, which all inlang plugins are written in, to CJS which Sherlock\n\t * runs in.\n\t *\n\t * @example\n\t * const project = await loadProject({ preprocessPluginBeforeImport: (moduleText) => convertEsmToCjs(moduleText) })\n\t *\n\t */\n\tpreprocessPluginBeforeImport?: PreprocessPluginBeforeImportFunction;\n}): Promise<InlangProject> {\n\tconst db = initDb({ sqlite: args.sqlite });\n\n\tawait maybeMigrateFirstProjectId({ lix: args.lix });\n\n\tconst settingsFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.select(\"data\")\n\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t.executeTakeFirstOrThrow();\n\n\tconst settings = withLanguageTagToLocaleMigration(\n\t\tJSON.parse(new TextDecoder().decode(settingsFile.data)) as ProjectSettings\n\t);\n\n\tconst importedPlugins = await importPlugins({\n\t\tsettings,\n\t\tlix: args.lix,\n\t\tpreprocessPluginBeforeImport: args.preprocessPluginBeforeImport,\n\t});\n\n\tconst plugins = [...(args.providePlugins ?? []), ...importedPlugins.plugins];\n\n\t// const state = createProjectState({\n\t// \t...args,\n\t// \tsettings,\n\t// });\n\n\treturn {\n\t\tdb,\n\t\tid: {\n\t\t\tget: async () => {\n\t\t\t\tconst file = await args.lix.db\n\t\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t\t\t\t.select(\"file.data\")\n\t\t\t\t\t.executeTakeFirstOrThrow();\n\t\t\t\treturn new TextDecoder().decode(file.data);\n\t\t\t},\n\t\t},\n\t\tsettings: {\n\t\t\tget: async () => {\n\t\t\t\tconst file = await args.lix.db\n\t\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t\t.select(\"file.data\")\n\t\t\t\t\t.executeTakeFirstOrThrow();\n\t\t\t\treturn withLanguageTagToLocaleMigration(\n\t\t\t\t\tJSON.parse(new TextDecoder().decode(file.data))\n\t\t\t\t);\n\t\t\t},\n\t\t\tset: async (newSettings) => {\n\t\t\t\tconst cloned = JSON.parse(JSON.stringify(newSettings));\n\t\t\t\tcloned.languageTags = cloned.locales;\n\t\t\t\tcloned.sourceLanguageTag = cloned.baseLocale;\n\n\t\t\t\tawait args.lix.db\n\t\t\t\t\t.updateTable(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t\t.set({\n\t\t\t\t\t\tdata: new TextEncoder().encode(\n\t\t\t\t\t\t\tJSON.stringify(cloned, undefined, 2)\n\t\t\t\t\t\t),\n\t\t\t\t\t})\n\t\t\t\t\t.execute();\n\t\t\t},\n\t\t},\n\t\tplugins: {\n\t\t\tget: async () => plugins,\n\t\t},\n\t\terrors: {\n\t\t\tget: async () => [...importedPlugins.errors],\n\t\t},\n\t\t// errors: state.errors,\n\t\timportFiles: async ({ files, pluginKey }) => {\n\t\t\tconst settingsFile = await args.lix.db\n\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t.select(\"file.data\")\n\t\t\t\t.executeTakeFirstOrThrow();\n\n\t\t\tconst settings = JSON.parse(\n\t\t\t\tnew TextDecoder().decode(settingsFile.data)\n\t\t\t) as ProjectSettings;\n\n\t\t\treturn await importFiles({\n\t\t\t\tfiles,\n\t\t\t\tpluginKey,\n\t\t\t\tsettings,\n\t\t\t\t// TODO don't use global state, might be stale\n\t\t\t\tplugins,\n\t\t\t\tdb,\n\t\t\t});\n\t\t},\n\t\texportFiles: async ({ pluginKey }) => {\n\t\t\tconst settingsFile = await args.lix.db\n\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t.select(\"file.data\")\n\t\t\t\t.executeTakeFirstOrThrow();\n\n\t\t\tconst settings = JSON.parse(\n\t\t\t\tnew TextDecoder().decode(settingsFile.data)\n\t\t\t) as ProjectSettings;\n\n\t\t\treturn (\n\t\t\t\tawait exportFiles({\n\t\t\t\t\tpluginKey,\n\t\t\t\t\tdb,\n\t\t\t\t\tsettings,\n\t\t\t\t\t// TODO don't use global state, might be stale\n\t\t\t\t\tplugins,\n\t\t\t\t})\n\t\t\t).map((output) => ({ ...output, pluginKey }));\n\t\t},\n\t\tclose: async () => {\n\t\t\tawait saveDbToLix({ sqlite: args.sqlite, lix: args.lix });\n\t\t\tawait db.destroy();\n\t\t\tawait args.lix.db.destroy();\n\t\t},\n\t\t_sqlite: args.sqlite,\n\t\ttoBlob: async () => {\n\t\t\tawait saveDbToLix({ sqlite: args.sqlite, lix: args.lix });\n\t\t\treturn await toBlob({ lix: args.lix });\n\t\t},\n\t\tlix: args.lix,\n\t};\n}\n\nasync function saveDbToLix(args: {\n\tsqlite: SqliteWasmDatabase;\n\tlix: Lix;\n}): Promise<void> {\n\tconst data = contentFromDatabase(args.sqlite);\n\tawait args.lix.db\n\t\t.updateTable(\"file\")\n\t\t.set(\"data\", data)\n\t\t.where(\"path\", \"=\", \"/db.sqlite\")\n\t\t.execute();\n}\n\n/**\n * Old leftover migration from v1. Probably not needed anymore.\n *\n * Kept it in just in case.\n */\nasync function maybeMigrateFirstProjectId(args: { lix: Lix }): Promise<void> {\n\tconst firstProjectIdFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.select(\"data\")\n\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t.executeTakeFirst();\n\n\tif (!firstProjectIdFile) {\n\t\tawait args.lix.db\n\t\t\t.insertInto(\"file\")\n\t\t\t.values({\n\t\t\t\tpath: \"/project_id\",\n\t\t\t\tdata: new TextEncoder().encode(v4()),\n\t\t\t})\n\t\t\t.execute();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadProjectFromDirectory.d.ts","sourceRoot":"/","sources":["project/loadProjectFromDirectory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"loadProjectFromDirectory.d.ts","sourceRoot":"/","sources":["project/loadProjectFromDirectory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAqC,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAIlE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAM3C;;;;;;;;;;;GAWG;AACH,wBAAsB,wBAAwB,CAC7C,IAAI,EAAE;IACL;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,EAAE,EAAE,OAAO,EAAE,CAAC;IACd;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;GAiL3D;AAggBD,qBAAa,yBAA0B,SAAQ,KAAK;gBACvC,MAAM,EAAE,MAAM;CAM1B;AAuCD,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,IAAI,EAAE,MAAM,CAAC;gBAED,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAMhD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { newProject } from "./newProject.js";
|
|
2
2
|
import { loadProjectInMemory } from "./loadProjectInMemory.js";
|
|
3
|
-
import { closeLix, openLixInMemory, toBlob
|
|
3
|
+
import { closeLix, openLixInMemory, toBlob } from "@lix-js/sdk";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import nodePath from "node:path";
|
|
6
6
|
import { fromMessageV1 } from "../json-schema/old-v1-message/fromMessageV1.js";
|