@inlang/sdk 2.1.0 → 2.1.2

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.
@@ -1,7 +1,7 @@
1
1
  import { Kysely } from "kysely";
2
2
  import { type InlangDatabaseSchema } from "./schema.js";
3
- import { type SqliteDatabase } from "sqlite-wasm-kysely";
3
+ import { type SqliteWasmDatabase } from "sqlite-wasm-kysely";
4
4
  export declare function initDb(args: {
5
- sqlite: SqliteDatabase;
5
+ sqlite: SqliteWasmDatabase;
6
6
  }): Kysely<InlangDatabaseSchema>;
7
7
  //# sourceMappingURL=initDb.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initDb.d.ts","sourceRoot":"/","sources":["database/initDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAe,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKxE,wBAAgB,MAAM,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,cAAc,CAAA;CAAE,gCAatD"}
1
+ {"version":3,"file":"initDb.d.ts","sourceRoot":"/","sources":["database/initDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAe,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAK5E,wBAAgB,MAAM,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,kBAAkB,CAAA;CAAE,gCAa1D"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="23c4687f-1029-5845-9124-0f1a162c7e16")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fc2b29fc-faec-5ff5-91e6-5664b8dc4c09")}catch(e){}}();
3
3
  import { CamelCasePlugin, Kysely } from "kysely";
4
4
  import { applySchema } from "./schema.js";
5
5
  import { createDialect } from "sqlite-wasm-kysely";
@@ -33,4 +33,4 @@ function initDefaultValueFunctions(args) {
33
33
  });
34
34
  }
35
35
  //# sourceMappingURL=initDb.js.map
36
- //# debugId=23c4687f-1029-5845-9124-0f1a162c7e16
36
+ //# debugId=fc2b29fc-faec-5ff5-91e6-5664b8dc4c09
@@ -1 +1 @@
1
- {"version":3,"file":"initDb.js","sources":["database/initDb.ts"],"sourceRoot":"/","sourcesContent":["import { CamelCasePlugin, Kysely } from \"kysely\";\nimport { applySchema, type InlangDatabaseSchema } from \"./schema.js\";\nimport { createDialect, type SqliteDatabase } from \"sqlite-wasm-kysely\";\nimport { v7 } from \"uuid\";\nimport { humanId } from \"../human-id/human-id.js\";\nimport { JsonbPlugin } from \"./jsonbPlugin.js\";\n\nexport function initDb(args: { sqlite: SqliteDatabase }) {\n\tinitDefaultValueFunctions({ sqlite: args.sqlite });\n\tapplySchema({ sqlite: args.sqlite });\n\tconst db = new Kysely<InlangDatabaseSchema>({\n\t\tdialect: createDialect({\n\t\t\tdatabase: args.sqlite,\n\t\t}),\n\t\tplugins: [\n\t\t\tnew CamelCasePlugin(),\n\t\t\tnew JsonbPlugin({ database: args.sqlite }),\n\t\t],\n\t});\n\treturn db;\n}\n\nfunction initDefaultValueFunctions(args: { sqlite: SqliteDatabase }) {\n\targs.sqlite.createFunction({\n\t\tname: \"uuid_v7\",\n\t\tarity: 0,\n\t\txFunc: () => v7(),\n\t});\n\targs.sqlite.createFunction({\n\t\tname: \"human_id\",\n\t\tarity: 0,\n\t\txFunc: () => hum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,"file":"initDb.js","sources":["database/initDb.ts"],"sourceRoot":"/","sourcesContent":["import { CamelCasePlugin, Kysely } from \"kysely\";\nimport { applySchema, type InlangDatabaseSchema } from \"./schema.js\";\nimport { createDialect, type SqliteWasmDatabase } from \"sqlite-wasm-kysely\";\nimport { v7 } from \"uuid\";\nimport { humanId } from \"../human-id/human-id.js\";\nimport { JsonbPlugin } from \"./jsonbPlugin.js\";\n\nexport function initDb(args: { sqlite: SqliteWasmDatabase }) {\n\tinitDefaultValueFunctions({ sqlite: args.sqlite });\n\tapplySchema({ sqlite: args.sqlite });\n\tconst db = new Kysely<InlangDatabaseSchema>({\n\t\tdialect: createDialect({\n\t\t\tdatabase: args.sqlite,\n\t\t}),\n\t\tplugins: [\n\t\t\tnew CamelCasePlugin(),\n\t\t\tnew JsonbPlugin({ database: args.sqlite }),\n\t\t],\n\t});\n\treturn db;\n}\n\nfunction initDefaultValueFunctions(args: { sqlite: SqliteWasmDatabase }) {\n\targs.sqlite.createFunction({\n\t\tname: \"uuid_v7\",\n\t\tarity: 0,\n\t\txFunc: () => v7(),\n\t});\n\targs.sqlite.createFunction({\n\t\tname: \"human_id\",\n\t\tarity: 0,\n\t\txFunc: () => humanId(),\n\t});\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,WAAW,EAA6B,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,aAAa,EAA2B,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,UAAU,MAAM,CAAC,IAAoC;IAC1D,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,IAAI,MAAM,CAAuB;QAC3C,OAAO,EAAE,aAAa,CAAC;YACtB,QAAQ,EAAE,IAAI,CAAC,MAAM;SACrB,CAAC;QACF,OAAO,EAAE;YACR,IAAI,eAAe,EAAE;YACrB,IAAI,WAAW,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;SAC1C;KACD,CAAC,CAAC;IACH,OAAO,EAAE,CAAC;AACX,CAAC;AAED,SAAS,yBAAyB,CAAC,IAAoC;IACtE,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QAC1B,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE;KACjB,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QAC1B,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE;KACtB,CAAC,CAAC;AACJ,CAAC","debug_id":"fc2b29fc-faec-5ff5-91e6-5664b8dc4c09"}
@@ -1,9 +1,9 @@
1
1
  import { type KyselyPlugin, type PluginTransformQueryArgs, type PluginTransformResultArgs, type QueryResult, type RootOperationNode, type UnknownRow } from "kysely";
2
- import type { SqliteDatabase } from "sqlite-wasm-kysely";
2
+ import type { SqliteWasmDatabase } from "sqlite-wasm-kysely";
3
3
  export declare class JsonbPlugin implements KyselyPlugin {
4
4
  #private;
5
5
  constructor(args: {
6
- database: SqliteDatabase;
6
+ database: SqliteWasmDatabase;
7
7
  });
8
8
  /**
9
9
  * For an outgoing query like insert or update, the JSON
@@ -1 +1 @@
1
- {"version":3,"file":"jsonbPlugin.d.ts","sourceRoot":"/","sources":["database/jsonbPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAEf,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,qBAAa,WAAY,YAAW,YAAY;;gBAKnC,IAAI,EAAE;QAAE,QAAQ,EAAE,cAAc,CAAA;KAAE;IAI9C;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB;IAWjE;;;OAGG;IACG,eAAe,CACpB,IAAI,EAAE,yBAAyB,GAC7B,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;CAwBnC"}
1
+ {"version":3,"file":"jsonbPlugin.d.ts","sourceRoot":"/","sources":["database/jsonbPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAEf,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,qBAAa,WAAY,YAAW,YAAY;;gBAKnC,IAAI,EAAE;QAAE,QAAQ,EAAE,kBAAkB,CAAA;KAAE;IAIlD;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB;IAWjE;;;OAGG;IACG,eAAe,CACpB,IAAI,EAAE,yBAAyB,GAC7B,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;CAwBnC"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3327df74-20ec-59b9-aa9d-5070dada72f2")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e8e4087c-9464-57fc-b765-367ee0953d9b")}catch(e){}}();
3
3
  import { OperationNodeTransformer, sql, ValueListNode, ValueNode, ValuesNode, ParseJSONResultsPlugin, OnConflictNode, } from "kysely";
4
4
  export class JsonbPlugin {
5
5
  #serializeJsonTransformer = new SerializeJsonbTransformer();
@@ -180,4 +180,4 @@ function maybeSerializeJson(value) {
180
180
  // };
181
181
  // }
182
182
  //# sourceMappingURL=jsonbPlugin.js.map
183
- //# debugId=3327df74-20ec-59b9-aa9d-5070dada72f2
183
+ //# debugId=e8e4087c-9464-57fc-b765-367ee0953d9b
@@ -1 +1 @@
1
- {"version":3,"file":"jsonbPlugin.js","sources":["database/jsonbPlugin.ts"],"sourceRoot":"/","sourcesContent":["import {\n\tOperationNodeTransformer,\n\tsql,\n\tValueListNode,\n\tValueNode,\n\tValuesNode,\n\tParseJSONResultsPlugin,\n\ttype KyselyPlugin,\n\ttype PluginTransformQueryArgs,\n\ttype PluginTransformResultArgs,\n\ttype QueryResult,\n\ttype RootOperationNode,\n\ttype UnknownRow,\n\tOnConflictNode,\n} from \"kysely\";\nimport type { SqliteDatabase } from \"sqlite-wasm-kysely\";\n\nexport class JsonbPlugin implements KyselyPlugin {\n\t#serializeJsonTransformer = new SerializeJsonbTransformer();\n\t#parseJsonPlugin = new ParseJSONResultsPlugin();\n\t#database: SqliteDatabase;\n\n\tconstructor(args: { database: SqliteDatabase }) {\n\t\tthis.#database = args.database;\n\t}\n\n\t/**\n\t * For an outgoing query like insert or update, the JSON\n\t * values are transformed into `jsonb` function calls when\n\t * executed against the database.\n\t */\n\ttransformQuery(args: PluginTransformQueryArgs): RootOperationNode {\n\t\tif (\n\t\t\targs.node.kind === \"InsertQueryNode\" ||\n\t\t\targs.node.kind === \"UpdateQueryNode\"\n\t\t) {\n\t\t\tconst result = this.#serializeJsonTransformer.transformNode(args.node);\n\t\t\treturn result;\n\t\t}\n\t\treturn args.node;\n\t}\n\n\t/**\n\t * For incoming query results, the JSON binaries are parsed\n\t * into JSON objects.\n\t */\n\tasync transformResult(\n\t\targs: PluginTransformResultArgs\n\t): Promise<QueryResult<UnknownRow>> {\n\t\tfor (const row of args.result.rows) {\n\t\t\tfor (const key in row) {\n\t\t\t\tif (\n\t\t\t\t\trow[key] instanceof ArrayBuffer ||\n\t\t\t\t\t// uint8array, etc\n\t\t\t\t\tArrayBuffer.isView(row[key])\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst res = this.#database.exec(`SELECT json(?)`, {\n\t\t\t\t\t\t\treturnValue: \"resultRows\",\n\t\t\t\t\t\t\tbind: [row[key] as any],\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\trow[key] = JSON.parse(res[0] as any);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// it's not a json binary\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// in case it's a regular (text) json, run it through kyseley's json parser\n\t\treturn this.#parseJsonPlugin.transformResult(args);\n\t}\n}\n\nclass SerializeJsonbTransformer extends OperationNodeTransformer {\n\tprotected override transformOnConflict(node: OnConflictNode): OnConflictNode {\n\t\treturn super.transformOnConflict({\n\t\t\t...node,\n\t\t\tupdates: node.updates?.map((updateItem) => {\n\t\t\t\tif (updateItem.kind !== \"ColumnUpdateNode\") {\n\t\t\t\t\treturn updateItem;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"ColumnUpdateNode\",\n\t\t\t\t\tcolumn: updateItem.column,\n\t\t\t\t\t// @ts-expect-error - we know that the value is a ValueNode\n\t\t\t\t\tvalue: this.transformValue(updateItem.value),\n\t\t\t\t};\n\t\t\t}),\n\t\t});\n\t}\n\n\tprotected override transformValue(node: ValueNode): ValueNode {\n\t\tconst { value } = node;\n\t\tconst serializedValue = maybeSerializeJson(value);\n\t\tif (value === serializedValue) {\n\t\t\treturn node;\n\t\t}\n\t\t// @ts-expect-error - we know that the node is a ValueNode\n\t\treturn sql`jsonb(${serializedValue})`.toOperationNode();\n\t}\n\t/**\n\t * Transforms the value list node by replacing all JSON objects with `jsonb` function calls.\n\t */\n\tprotected override transformValueList(node: ValueListNode): ValueListNode {\n\t\treturn super.transformValueList({\n\t\t\t...node,\n\t\t\tvalues: node.values.map((listNodeItem) => {\n\t\t\t\tif (listNodeItem.kind !== \"ValueNode\") {\n\t\t\t\t\treturn listNodeItem;\n\t\t\t\t}\n\t\t\t\t// @ts-expect-error - we know that the node is a ValueNode\n\t\t\t\tconst { value } = listNodeItem;\n\t\t\t\tconst serializedValue = maybeSerializeJson(value);\n\n\t\t\t\tif (value === serializedValue) {\n\t\t\t\t\treturn listNodeItem;\n\t\t\t\t}\n\t\t\t\treturn sql`jsonb(${serializedValue})`.toOperationNode();\n\t\t\t}),\n\t\t});\n\t}\n\n\t/**\n\t * Why this function is needed or why this works remains a mystery.\n\t */\n\toverride transformValues(node: ValuesNode): ValuesNode {\n\t\treturn super.transformValues({\n\t\t\t...node,\n\t\t\tvalues: node.values.map((valueItemNode) => {\n\t\t\t\tif (valueItemNode.kind !== \"PrimitiveValueListNode\") {\n\t\t\t\t\treturn valueItemNode;\n\t\t\t\t}\n\n\t\t\t\t// change valueItem to ValueListNode\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"ValueListNode\",\n\t\t\t\t\tvalues: valueItemNode.values.map(\n\t\t\t\t\t\t(value) =>\n\t\t\t\t\t\t\t({\n\t\t\t\t\t\t\t\tkind: \"ValueNode\",\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t}) as ValueNode\n\t\t\t\t\t),\n\t\t\t\t} as ValueListNode;\n\t\t\t}),\n\t\t});\n\t}\n}\n\nfunction maybeSerializeJson(value: any): any {\n\tif (\n\t\t// binary data\n\t\tvalue instanceof ArrayBuffer ||\n\t\t// uint8array, etc\n\t\tArrayBuffer.isView(value) ||\n\t\tvalue === null ||\n\t\tvalue === undefined\n\t) {\n\t\treturn value;\n\t} else if (typeof value === \"object\" || Array.isArray(value)) {\n\t\treturn JSON.stringify(value);\n\t}\n\treturn value;\n}\n\n// The code here didn't work https://github.com/opral/inlang-sdk/issues/132#issuecomment-2339321910\n// but would be the \"right\" solution to avoid heuristics which column might or might not be a json column\n// // modifies the query in place for readability and performance\n// function mapQuery(\n// \tnode: InsertQueryNode,\n// \tjsonColumns: TableSchema\n// ): InsertQueryNode {\n// \t// if the query is not an insert query, we don't need to do anything\n// \tif (node.into === undefined) {\n// \t\treturn node;\n// \t}\n// \t// if the table is not in the schema that has json columns, we don't need to do anything\n// \tconst columnsWithJson = jsonColumns[node.into.table.identifier.name];\n// \tif (columnsWithJson === undefined) {\n// \t\treturn node;\n// \t}\n// \t// find the indexes of the values that need to be transformed\n// \t// SQL query: INSERT INTO table (col1, col2) VALUES (val1, val2)\n// \tconst indexesThatNeedToBeTransformed: [number, string][] = [];\n// \tfor (const [i, col] of node.columns?.entries() ?? []) {\n// \t\tconst jsonType = columnsWithJson[col.column.name];\n// \t\tif (jsonType !== undefined) {\n// \t\t\tindexesThatNeedToBeTransformed.push([i, jsonType]);\n// \t\t}\n// \t}\n// \tconst values = structuredClone(node.values);\n// \tfor (const [i, jsonType] of indexesThatNeedToBeTransformed) {\n// \t\tif (\n// \t\t\t// top level values node that should contain a list of values\n// \t\t\tnode.values?.kind !== \"ValuesNode\" &&\n// \t\t\t// the node we are interested in must be a value node\n// \t\t\t// @ts-expect-error - we know that the node is a ValuesNode with values\n// \t\t\t(node.values as ValuesNode).values?.[i].kind !== \"ValueNode\"\n// \t\t) {\n// \t\t\tthrow new Error(\"Unexpected node structure\");\n// \t\t}\n// \t\tconst serializedJson = JSON.stringify(node.values.values[0].values[i]);\n// \t\t// @ts-expect-error - we know that the node is a ValuesNode with values\n// \t\tvalues.values[0].values[i] =\n// \t\t\tjsonType === \"jsonb\"\n// \t\t\t\t? sql`jsonb(${serializedJson})`.toOperationNode()\n// \t\t\t\t: sql`json(${serializedJson})`.toOperationNode();\n// \t}\n\n// \treturn {\n// \t\t...node,\n// \t\tvalues,\n// \t};\n// }\n"],"names":[],"mappings":";;AAAA,OAAO,EACN,wBAAwB,EACxB,GAAG,EACH,aAAa,EACb,SAAS,EACT,UAAU,EACV,sBAAsB,EAOtB,cAAc,GACd,MAAM,QAAQ,CAAC;AAGhB,MAAM,OAAO,WAAW;IACvB,yBAAyB,GAAG,IAAI,yBAAyB,EAAE,CAAC;IAC5D,gBAAgB,GAAG,IAAI,sBAAsB,EAAE,CAAC;IAChD,SAAS,CAAiB;IAE1B,YAAY,IAAkC;QAC7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,IAA8B;QAC5C,IACC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB;YACpC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,EACnC,CAAC;YACF,MAAM,MAAM,GAAG,IAAI,CAAC,yBAAyB,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvE,OAAO,MAAM,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,eAAe,CACpB,IAA+B;QAE/B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACpC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;gBACvB,IACC,GAAG,CAAC,GAAG,CAAC,YAAY,WAAW;oBAC/B,kBAAkB;oBAClB,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAC3B,CAAC;oBACF,IAAI,CAAC;wBACJ,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,EAAE;4BACjD,WAAW,EAAE,YAAY;4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,KAAK,SAAS,EAClB,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9D,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,mGAAmG;AACnG,yGAAyG;AACzG,iEAAiE;AACjE,qBAAqB;AACrB,0BAA0B;AAC1B,4BAA4B;AAC5B,uBAAuB;AACvB,wEAAwE;AACxE,kCAAkC;AAClC,iBAAiB;AACjB,KAAK;AACL,4FAA4F;AAC5F,yEAAyE;AACzE,wCAAwC;AACxC,iBAAiB;AACjB,KAAK;AACL,iEAAiE;AACjE,oEAAoE;AACpE,kEAAkE;AAClE,2DAA2D;AAC3D,uDAAuD;AACvD,kCAAkC;AAClC,yDAAyD;AACzD,MAAM;AACN,KAAK;AACL,gDAAgD;AAChD,iEAAiE;AACjE,SAAS;AACT,mEAAmE;AACnE,2CAA2C;AAC3C,2DAA2D;AAC3D,6EAA6E;AAC7E,kEAAkE;AAClE,QAAQ;AACR,mDAAmD;AACnD,MAAM;AACN,4EAA4E;AAC5E,4EAA4E;AAC5E,iCAAiC;AACjC,0BAA0B;AAC1B,wDAAwD;AACxD,wDAAwD;AACxD,KAAK;AAEL,YAAY;AACZ,aAAa;AACb,YAAY;AACZ,MAAM;AACN,IAAI","debug_id":"3327df74-20ec-59b9-aa9d-5070dada72f2"}
1
+ {"version":3,"file":"jsonbPlugin.js","sources":["database/jsonbPlugin.ts"],"sourceRoot":"/","sourcesContent":["import {\n\tOperationNodeTransformer,\n\tsql,\n\tValueListNode,\n\tValueNode,\n\tValuesNode,\n\tParseJSONResultsPlugin,\n\ttype KyselyPlugin,\n\ttype PluginTransformQueryArgs,\n\ttype PluginTransformResultArgs,\n\ttype QueryResult,\n\ttype RootOperationNode,\n\ttype UnknownRow,\n\tOnConflictNode,\n} from \"kysely\";\nimport type { SqliteWasmDatabase } from \"sqlite-wasm-kysely\";\n\nexport class JsonbPlugin implements KyselyPlugin {\n\t#serializeJsonTransformer = new SerializeJsonbTransformer();\n\t#parseJsonPlugin = new ParseJSONResultsPlugin();\n\t#database: SqliteWasmDatabase;\n\n\tconstructor(args: { database: SqliteWasmDatabase }) {\n\t\tthis.#database = args.database;\n\t}\n\n\t/**\n\t * For an outgoing query like insert or update, the JSON\n\t * values are transformed into `jsonb` function calls when\n\t * executed against the database.\n\t */\n\ttransformQuery(args: PluginTransformQueryArgs): RootOperationNode {\n\t\tif (\n\t\t\targs.node.kind === \"InsertQueryNode\" ||\n\t\t\targs.node.kind === \"UpdateQueryNode\"\n\t\t) {\n\t\t\tconst result = this.#serializeJsonTransformer.transformNode(args.node);\n\t\t\treturn result;\n\t\t}\n\t\treturn args.node;\n\t}\n\n\t/**\n\t * For incoming query results, the JSON binaries are parsed\n\t * into JSON objects.\n\t */\n\tasync transformResult(\n\t\targs: PluginTransformResultArgs\n\t): Promise<QueryResult<UnknownRow>> {\n\t\tfor (const row of args.result.rows) {\n\t\t\tfor (const key in row) {\n\t\t\t\tif (\n\t\t\t\t\trow[key] instanceof ArrayBuffer ||\n\t\t\t\t\t// uint8array, etc\n\t\t\t\t\tArrayBuffer.isView(row[key])\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst res = this.#database.exec(`SELECT json(?)`, {\n\t\t\t\t\t\t\treturnValue: \"resultRows\",\n\t\t\t\t\t\t\tbind: [row[key] as any],\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\trow[key] = JSON.parse(res[0] as any);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// it's not a json binary\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// in case it's a regular (text) json, run it through kyseley's json parser\n\t\treturn this.#parseJsonPlugin.transformResult(args);\n\t}\n}\n\nclass SerializeJsonbTransformer extends OperationNodeTransformer {\n\tprotected override transformOnConflict(node: OnConflictNode): OnConflictNode {\n\t\treturn super.transformOnConflict({\n\t\t\t...node,\n\t\t\tupdates: node.updates?.map((updateItem) => {\n\t\t\t\tif (updateItem.kind !== \"ColumnUpdateNode\") {\n\t\t\t\t\treturn updateItem;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"ColumnUpdateNode\",\n\t\t\t\t\tcolumn: updateItem.column,\n\t\t\t\t\t// @ts-expect-error - we know that the value is a ValueNode\n\t\t\t\t\tvalue: this.transformValue(updateItem.value),\n\t\t\t\t};\n\t\t\t}),\n\t\t});\n\t}\n\n\tprotected override transformValue(node: ValueNode): ValueNode {\n\t\tconst { value } = node;\n\t\tconst serializedValue = maybeSerializeJson(value);\n\t\tif (value === serializedValue) {\n\t\t\treturn node;\n\t\t}\n\t\t// @ts-expect-error - we know that the node is a ValueNode\n\t\treturn sql`jsonb(${serializedValue})`.toOperationNode();\n\t}\n\t/**\n\t * Transforms the value list node by replacing all JSON objects with `jsonb` function calls.\n\t */\n\tprotected override transformValueList(node: ValueListNode): ValueListNode {\n\t\treturn super.transformValueList({\n\t\t\t...node,\n\t\t\tvalues: node.values.map((listNodeItem) => {\n\t\t\t\tif (listNodeItem.kind !== \"ValueNode\") {\n\t\t\t\t\treturn listNodeItem;\n\t\t\t\t}\n\t\t\t\t// @ts-expect-error - we know that the node is a ValueNode\n\t\t\t\tconst { value } = listNodeItem;\n\t\t\t\tconst serializedValue = maybeSerializeJson(value);\n\n\t\t\t\tif (value === serializedValue) {\n\t\t\t\t\treturn listNodeItem;\n\t\t\t\t}\n\t\t\t\treturn sql`jsonb(${serializedValue})`.toOperationNode();\n\t\t\t}),\n\t\t});\n\t}\n\n\t/**\n\t * Why this function is needed or why this works remains a mystery.\n\t */\n\toverride transformValues(node: ValuesNode): ValuesNode {\n\t\treturn super.transformValues({\n\t\t\t...node,\n\t\t\tvalues: node.values.map((valueItemNode) => {\n\t\t\t\tif (valueItemNode.kind !== \"PrimitiveValueListNode\") {\n\t\t\t\t\treturn valueItemNode;\n\t\t\t\t}\n\n\t\t\t\t// change valueItem to ValueListNode\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"ValueListNode\",\n\t\t\t\t\tvalues: valueItemNode.values.map(\n\t\t\t\t\t\t(value) =>\n\t\t\t\t\t\t\t({\n\t\t\t\t\t\t\t\tkind: \"ValueNode\",\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t}) as ValueNode\n\t\t\t\t\t),\n\t\t\t\t} as ValueListNode;\n\t\t\t}),\n\t\t});\n\t}\n}\n\nfunction maybeSerializeJson(value: any): any {\n\tif (\n\t\t// binary data\n\t\tvalue instanceof ArrayBuffer ||\n\t\t// uint8array, etc\n\t\tArrayBuffer.isView(value) ||\n\t\tvalue === null ||\n\t\tvalue === undefined\n\t) {\n\t\treturn value;\n\t} else if (typeof value === \"object\" || Array.isArray(value)) {\n\t\treturn JSON.stringify(value);\n\t}\n\treturn value;\n}\n\n// The code here didn't work https://github.com/opral/inlang-sdk/issues/132#issuecomment-2339321910\n// but would be the \"right\" solution to avoid heuristics which column might or might not be a json column\n// // modifies the query in place for readability and performance\n// function mapQuery(\n// \tnode: InsertQueryNode,\n// \tjsonColumns: TableSchema\n// ): InsertQueryNode {\n// \t// if the query is not an insert query, we don't need to do anything\n// \tif (node.into === undefined) {\n// \t\treturn node;\n// \t}\n// \t// if the table is not in the schema that has json columns, we don't need to do anything\n// \tconst columnsWithJson = jsonColumns[node.into.table.identifier.name];\n// \tif (columnsWithJson === undefined) {\n// \t\treturn node;\n// \t}\n// \t// find the indexes of the values that need to be transformed\n// \t// SQL query: INSERT INTO table (col1, col2) VALUES (val1, val2)\n// \tconst indexesThatNeedToBeTransformed: [number, string][] = [];\n// \tfor (const [i, col] of node.columns?.entries() ?? []) {\n// \t\tconst jsonType = columnsWithJson[col.column.name];\n// \t\tif (jsonType !== undefined) {\n// \t\t\tindexesThatNeedToBeTransformed.push([i, jsonType]);\n// \t\t}\n// \t}\n// \tconst values = structuredClone(node.values);\n// \tfor (const [i, jsonType] of indexesThatNeedToBeTransformed) {\n// \t\tif (\n// \t\t\t// top level values node that should contain a list of values\n// \t\t\tnode.values?.kind !== \"ValuesNode\" &&\n// \t\t\t// the node we are interested in must be a value node\n// \t\t\t// @ts-expect-error - we know that the node is a ValuesNode with values\n// \t\t\t(node.values as ValuesNode).values?.[i].kind !== \"ValueNode\"\n// \t\t) {\n// \t\t\tthrow new Error(\"Unexpected node structure\");\n// \t\t}\n// \t\tconst serializedJson = JSON.stringify(node.values.values[0].values[i]);\n// \t\t// @ts-expect-error - we know that the node is a ValuesNode with values\n// \t\tvalues.values[0].values[i] =\n// \t\t\tjsonType === \"jsonb\"\n// \t\t\t\t? sql`jsonb(${serializedJson})`.toOperationNode()\n// \t\t\t\t: sql`json(${serializedJson})`.toOperationNode();\n// \t}\n\n// \treturn {\n// \t\t...node,\n// \t\tvalues,\n// \t};\n// }\n"],"names":[],"mappings":";;AAAA,OAAO,EACN,wBAAwB,EACxB,GAAG,EACH,aAAa,EACb,SAAS,EACT,UAAU,EACV,sBAAsB,EAOtB,cAAc,GACd,MAAM,QAAQ,CAAC;AAGhB,MAAM,OAAO,WAAW;IACvB,yBAAyB,GAAG,IAAI,yBAAyB,EAAE,CAAC;IAC5D,gBAAgB,GAAG,IAAI,sBAAsB,EAAE,CAAC;IAChD,SAAS,CAAqB;IAE9B,YAAY,IAAsC;QACjD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,IAA8B;QAC5C,IACC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB;YACpC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,EACnC,CAAC;YACF,MAAM,MAAM,GAAG,IAAI,CAAC,yBAAyB,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvE,OAAO,MAAM,CAA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mD;AACnD,MAAM;AACN,4EAA4E;AAC5E,4EAA4E;AAC5E,iCAAiC;AACjC,0BAA0B;AAC1B,wDAAwD;AACxD,wDAAwD;AACxD,KAAK;AAEL,YAAY;AACZ,aAAa;AACb,YAAY;AACZ,MAAM;AACN,IAAI","debug_id":"e8e4087c-9464-57fc-b765-367ee0953d9b"}
@@ -1,8 +1,8 @@
1
1
  import type { Generated, Insertable, Selectable, Updateable } from "kysely";
2
- import type { SqliteDatabase } from "sqlite-wasm-kysely";
2
+ import type { SqliteWasmDatabase } from "sqlite-wasm-kysely";
3
3
  import { Declaration, Pattern, VariableReference } from "../json-schema/pattern.js";
4
4
  export declare function applySchema(args: {
5
- sqlite: SqliteDatabase;
5
+ sqlite: SqliteWasmDatabase;
6
6
  }): void;
7
7
  export type InlangDatabaseSchema = {
8
8
  bundle: BundleTable;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"/","sources":["database/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACN,WAAW,EACX,OAAO,EACP,iBAAiB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,cAAc,CAAA;CAAE,QAyC3D;AAED,MAAM,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,KAAK,WAAW,GAAG;IAClB,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACtB,YAAY,EAAE,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;CAC5C,CAAC;AAEF,KAAK,YAAY,GAAG;IACnB,EA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U,CAAC,YAAY,CAAC,CAAC;AAErD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AAClD,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AAErD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG;IACrC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG;IAC3C,QAAQ,EAAE,UAAU,EAAE,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG;IAC5D,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IACnC,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC1B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IACzC,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG;IAC/C,QAAQ,EAAE,mBAAmB,EAAE,CAAC;CAChC,CAAC"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d18172ff-c888-5198-afa4-b43d012b6685")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f2febd26-8b4a-5507-b058-13bb83472533")}catch(e){}}();
3
3
  import { Declaration, Pattern, VariableReference, } from "../json-schema/pattern.js";
4
4
  export function applySchema(args) {
5
5
  const foreignKeyActivated = args.sqlite.exec("PRAGMA foreign_keys", {
@@ -42,4 +42,4 @@ CREATE INDEX IF NOT EXISTS idx_variant_message_id ON variant (message_id);
42
42
  `);
43
43
  }
44
44
  //# sourceMappingURL=schema.js.map
45
- //# debugId=d18172ff-c888-5198-afa4-b43d012b6685
45
+ //# debugId=f2febd26-8b4a-5507-b058-13bb83472533
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sources":["database/schema.ts"],"sourceRoot":"/","sourcesContent":["import type { Generated, Insertable, Selectable, Updateable } from \"kysely\";\nimport type { SqliteDatabase } from \"sqlite-wasm-kysely\";\nimport {\n\tDeclaration,\n\tPattern,\n\tVariableReference,\n} from \"../json-schema/pattern.js\";\n\nexport function applySchema(args: { sqlite: SqliteDatabase }) {\n\tconst foreignKeyActivated: any = args.sqlite.exec(\"PRAGMA foreign_keys\", {\n\t\treturnValue: \"resultRows\",\n\t});\n\tif (\n\t\t// first row that is returned\n\t\t// first column of the first row\n\t\t// is equal to 0, then foreign keys are disabled\n\t\tforeignKeyActivated[0][0] === 0\n\t) {\n\t\targs.sqlite.exec(\"PRAGMA foreign_keys = ON\", {\n\t\t\treturnValue: \"resultRows\",\n\t\t});\n\t}\n\n\targs.sqlite.exec(`\nCREATE TABLE IF NOT EXISTS bundle (\n id TEXT PRIMARY KEY DEFAULT (human_id()),\n\tdeclarations BLOB NOT NULL DEFAULT (jsonb('[]'))\n) strict;\n\nCREATE TABLE IF NOT EXISTS message (\n id TEXT PRIMARY KEY DEFAULT (uuid_v7()), \n bundle_id TEXT NOT NULL,\n locale TEXT NOT NULL,\n selectors BLOB NOT NULL DEFAULT (jsonb('[]')),\n FOREIGN KEY (bundle_id) REFERENCES bundle(id) ON DELETE CASCADE\n) strict;\n\n\nCREATE TABLE IF NOT EXISTS variant (\n id TEXT PRIMARY KEY DEFAULT (uuid_v7()), \n message_id TEXT NOT NULL,\n matches BLOB NOT NULL DEFAULT (jsonb('[]')),\n pattern BLOB NOT NULL DEFAULT (jsonb('[]')),\n FOREIGN KEY (message_id) REFERENCES message(id) ON DELETE CASCADE\n) strict;\n \nCREATE INDEX IF NOT EXISTS idx_message_bundle_id ON message (bundle_id);\nCREATE INDEX IF NOT EXISTS idx_variant_message_id ON variant (message_id);\n\t\t`);\n}\n\nexport type InlangDatabaseSchema = {\n\tbundle: BundleTable;\n\tmessage: MessageTable;\n\tvariant: VariantTable;\n};\n\ntype BundleTable = {\n\tid: Generated<string>;\n\tdeclarations: Generated<Array<Declaration>>;\n};\n\ntype MessageTable = {\n\tid: Generated<string>;\n\tbundleId: string;\n\tlocale: string;\n\tselectors: Generated<Array<VariableReference>>;\n};\n\ntype VariantTable = {\n\tid: Generated<string>;\n\tmessageId: string;\n\tmatches: Generated<Array<Match>>;\n\tpattern: Generated<Pattern>;\n};\n\n/**\n * A match is a variable reference that is either a literal or a catch-all.\n *\n * https://github.com/opral/inlang-sdk/issues/205\n *\n * @example\n * match = { type: \"match\", name: \"gender\", value: { type: \"literal\", value: \"male\" }}\n */\nexport type Match = LiteralMatch | CatchAllMatch;\n\nexport type LiteralMatch = {\n\ttype: \"literal-match\";\n\tkey: VariableReference[\"name\"];\n\tvalue: string;\n};\nexport type CatchAllMatch = {\n\ttype: \"catchall-match\";\n\tkey: VariableReference[\"name\"];\n};\n\nexport type Bundle = Selectable<BundleTable>;\nexport type NewBundle = Insertable<BundleTable>;\nexport type BundleUpdate = Updateable<BundleTable>;\n\nexport type Message = Selectable<MessageTable>;\nexport type NewMessage = Insertable<MessageTable>;\nexport type MessageUpdate = Updateable<MessageTable>;\n\nexport type Variant = Selectable<VariantTable>;\nexport type NewVariant = Insertable<VariantTable>;\nexport type VariantUpdate = Updateable<VariantTable>;\n\nexport type MessageNested = Message & {\n\tvariants: Variant[];\n};\nexport type NewMessageNested = NewMessage & {\n\tvariants: NewVariant[];\n};\nexport type MessageNestedUpdate = Updateable<MessageTable> & {\n\tvariants: VariantUpdate[];\n};\n\nexport type BundleNested = Bundle & {\n\tmessages: MessageNested[];\n};\nexport type NewBundleNested = NewBundle & {\n\tmessages: NewMessageNested[];\n};\nexport type BundleNestedUpdate = BundleUpdate & {\n\tmessages: MessageNestedUpdate[];\n};\n"],"names":[],"mappings":";;AAEA,OAAO,EACN,WAAW,EACX,OAAO,EACP,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,UAAU,WAAW,CAAC,IAAgC;IAC3D,MAAM,mBAAmB,GAAQ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE;QACxE,WAAW,EAAE,YAAY;KACzB,CAAC,CAAC;IACH;IACC,6BAA6B;IAC7B,gCAAgC;IAChC,gDAAgD;IAChD,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAC9B,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE;YAC5C,WAAW,EAAE,YAAY;SACzB,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBf,CAAC,CAAC;AACL,CAAC","debug_id":"d18172ff-c888-5198-afa4-b43d012b6685"}
1
+ {"version":3,"file":"schema.js","sources":["database/schema.ts"],"sourceRoot":"/","sourcesContent":["import type { Generated, Insertable, Selectable, Updateable } from \"kysely\";\nimport type { SqliteWasmDatabase } from \"sqlite-wasm-kysely\";\nimport {\n\tDeclaration,\n\tPattern,\n\tVariableReference,\n} from \"../json-schema/pattern.js\";\n\nexport function applySchema(args: { sqlite: SqliteWasmDatabase }) {\n\tconst foreignKeyActivated: any = args.sqlite.exec(\"PRAGMA foreign_keys\", {\n\t\treturnValue: \"resultRows\",\n\t});\n\tif (\n\t\t// first row that is returned\n\t\t// first column of the first row\n\t\t// is equal to 0, then foreign keys are disabled\n\t\tforeignKeyActivated[0][0] === 0\n\t) {\n\t\targs.sqlite.exec(\"PRAGMA foreign_keys = ON\", {\n\t\t\treturnValue: \"resultRows\",\n\t\t});\n\t}\n\n\targs.sqlite.exec(`\nCREATE TABLE IF NOT EXISTS bundle (\n id TEXT PRIMARY KEY DEFAULT (human_id()),\n\tdeclarations BLOB NOT NULL DEFAULT (jsonb('[]'))\n) strict;\n\nCREATE TABLE IF NOT EXISTS message (\n id TEXT PRIMARY KEY DEFAULT (uuid_v7()), \n bundle_id TEXT NOT NULL,\n locale TEXT NOT NULL,\n selectors BLOB NOT NULL DEFAULT (jsonb('[]')),\n FOREIGN KEY (bundle_id) REFERENCES bundle(id) ON DELETE CASCADE\n) strict;\n\n\nCREATE TABLE IF NOT EXISTS variant (\n id TEXT PRIMARY KEY DEFAULT (uuid_v7()), \n message_id TEXT NOT NULL,\n matches BLOB NOT NULL DEFAULT (jsonb('[]')),\n pattern BLOB NOT NULL DEFAULT (jsonb('[]')),\n FOREIGN KEY (message_id) REFERENCES message(id) ON DELETE CASCADE\n) strict;\n \nCREATE INDEX IF NOT EXISTS idx_message_bundle_id ON message (bundle_id);\nCREATE INDEX IF NOT EXISTS idx_variant_message_id ON variant (message_id);\n\t\t`);\n}\n\nexport type InlangDatabaseSchema = {\n\tbundle: BundleTable;\n\tmessage: MessageTable;\n\tvariant: VariantTable;\n};\n\ntype BundleTable = {\n\tid: Generated<string>;\n\tdeclarations: Generated<Array<Declaration>>;\n};\n\ntype MessageTable = {\n\tid: Generated<string>;\n\tbundleId: string;\n\tlocale: string;\n\tselectors: Generated<Array<VariableReference>>;\n};\n\ntype VariantTable = {\n\tid: Generated<string>;\n\tmessageId: string;\n\tmatches: Generated<Array<Match>>;\n\tpattern: Generated<Pattern>;\n};\n\n/**\n * A match is a variable reference that is either a literal or a catch-all.\n *\n * https://github.com/opral/inlang-sdk/issues/205\n *\n * @example\n * match = { type: \"match\", name: \"gender\", value: { type: \"literal\", value: \"male\" }}\n */\nexport type Match = LiteralMatch | CatchAllMatch;\n\nexport type LiteralMatch = {\n\ttype: \"literal-match\";\n\tkey: VariableReference[\"name\"];\n\tvalue: string;\n};\nexport type CatchAllMatch = {\n\ttype: \"catchall-match\";\n\tkey: VariableReference[\"name\"];\n};\n\nexport type Bundle = Selectable<BundleTable>;\nexport type NewBundle = Insertable<BundleTable>;\nexport type BundleUpdate = Updateable<BundleTable>;\n\nexport type Message = Selectable<MessageTable>;\nexport type NewMessage = Insertable<MessageTable>;\nexport type MessageUpdate = Updateable<MessageTable>;\n\nexport type Variant = Selectable<VariantTable>;\nexport type NewVariant = Insertable<VariantTable>;\nexport type VariantUpdate = Updateable<VariantTable>;\n\nexport type MessageNested = Message & {\n\tvariants: Variant[];\n};\nexport type NewMessageNested = NewMessage & {\n\tvariants: NewVariant[];\n};\nexport type MessageNestedUpdate = Updateable<MessageTable> & {\n\tvariants: VariantUpdate[];\n};\n\nexport type BundleNested = Bundle & {\n\tmessages: MessageNested[];\n};\nexport type NewBundleNested = NewBundle & {\n\tmessages: NewMessageNested[];\n};\nexport type BundleNestedUpdate = BundleUpdate & {\n\tmessages: MessageNestedUpdate[];\n};\n"],"names":[],"mappings":";;AAEA,OAAO,EACN,WAAW,EACX,OAAO,EACP,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,UAAU,WAAW,CAAC,IAAoC;IAC/D,MAAM,mBAAmB,GAAQ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE;QACxE,WAAW,EAAE,YAAY;KACzB,CAAC,CAAC;IACH;IACC,6BAA6B;IAC7B,gCAAgC;IAChC,gDAAgD;IAChD,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAC9B,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE;YAC5C,WAAW,EAAE,YAAY;SACzB,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBf,CAAC,CAAC;AACL,CAAC","debug_id":"f2febd26-8b4a-5507-b058-13bb83472533"}
@@ -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;AA6FtD,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;;;;;;IArE3B;;;;;;;;OAQG;;;;EA6DsC,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;AA+FtD,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;;;;;;IArE3B;;;;;;;;OAQG;;;;EA6DsC,CAAC"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0ab441fa-e6ed-5327-b6ba-da781e2b1e94")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8d3ca569-3c10-501d-8ae0-6d6ba486ecf5")}catch(e){}}();
3
3
  import { Type } from "@sinclair/typebox";
4
4
  const SDKSettings = Type.Object({
5
5
  // TODO SDK-v2 SETTINGS do we need to generate a settings v2 schema?
@@ -16,7 +16,7 @@ const SDKSettings = Type.Object({
16
16
  // exits for backwards compatibility
17
17
  // remove in SDK-v3
18
18
  sourceLanguageTag: Type.Optional(Type.String({
19
- description: "Use baseLocale instead.",
19
+ description: "Use baseLocale instead if all your inlang apps that you are using are on the inlang SDK V2. Otherwise, leave this property in.",
20
20
  deprecated: true,
21
21
  })),
22
22
  // exits for backwards compatibility
@@ -24,7 +24,7 @@ const SDKSettings = Type.Object({
24
24
  languageTags: Type.Optional(Type.Array(Type.String(), {
25
25
  uniqueItems: true,
26
26
  deprecated: true,
27
- description: "Use locales instead.",
27
+ description: "Use baseLocale instead if all your inlang apps that you are using are on the inlang SDK V2. Otherwise, leave this property in.",
28
28
  })),
29
29
  /**
30
30
  * The modules to load.
@@ -70,4 +70,4 @@ const SDKSettings = Type.Object({
70
70
  });
71
71
  export const ProjectSettings = SDKSettings;
72
72
  //# sourceMappingURL=settings.js.map
73
- //# debugId=0ab441fa-e6ed-5327-b6ba-da781e2b1e94
73
+ //# debugId=8d3ca569-3c10-501d-8ae0-6d6ba486ecf5
@@ -1 +1 @@
1
- {"version":3,"file":"settings.js","sources":["json-schema/settings.ts"],"sourceRoot":"/","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: \"Use baseLocale instead.\",\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: \"Use locales instead.\",\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\ttelemetry: Type.Optional(\n\t\tType.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"off\", {\n\t\t\t\t\tdescription: \"No telemetry events \",\n\t\t\t\t}),\n\t\t\t],\n\t\t\t{ description: \"If not set, defaults to all\" }\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"],"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,EAAE,yBAAyB;QACtC,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,EAAE,sBAAsB;KACnC,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,SAAS,EAAE,IAAI,CAAC,QAAQ,CACvB,IAAI,CAAC,KAAK,CACT;QACC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YACnB,WAAW,EAAE,sBAAsB;SACnC,CAAC;KACF,EACD,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAC9C,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","debug_id":"0ab441fa-e6ed-5327-b6ba-da781e2b1e94"}
1
+ {"version":3,"file":"settings.js","sources":["json-schema/settings.ts"],"sourceRoot":"/","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 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})\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\ttelemetry: Type.Optional(\n\t\tType.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"off\", {\n\t\t\t\t\tdescription: \"No telemetry events \",\n\t\t\t\t}),\n\t\t\t],\n\t\t\t{ description: \"If not set, defaults to all\" }\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"],"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,4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AsB;SACnC,CAAC;KACF,EACD,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAC9C,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","debug_id":"8d3ca569-3c10-501d-8ae0-6d6ba486ecf5"}
@@ -3,7 +3,7 @@ import type { InlangDatabaseSchema } from "../database/schema.js";
3
3
  import type { InlangPlugin } from "../plugin/schema.js";
4
4
  import type { ProjectSettings } from "../json-schema/settings.js";
5
5
  import type { Lix } from "@lix-js/sdk";
6
- import type { SqliteDatabase } from "sqlite-wasm-kysely";
6
+ import type { SqliteWasmDatabase } from "sqlite-wasm-kysely";
7
7
  export type InlangProject = {
8
8
  db: Kysely<InlangDatabaseSchema>;
9
9
  /**
@@ -12,7 +12,7 @@ export type InlangProject = {
12
12
  *
13
13
  * TODO remove this
14
14
  */
15
- _sqlite: SqliteDatabase;
15
+ _sqlite: SqliteWasmDatabase;
16
16
  id: {
17
17
  get: () => Promise<string>;
18
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"/","sources":["project/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EA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,CAAC,eAAe,CAAC,CAAC;QACpC,GAAG,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAClD,CAAC;IACF,GAAG,EAAE,GAAG,CAAC;IACT,WAAW,EAAE,CAAC,IAAI,EAAE;QACnB,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC/B,KAAK,EAAE,UAAU,EAAE,CAAC;KACpB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,WAAW,EAAE,CAAC,IAAI,EAAE;QACnB,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;KAC/B,KAAK,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACxB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,OAAO,EAAE,UAAU,CAAC;IACpB;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACxB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,OAAO,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAAK;IAC/D,WAAW,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="253b34fa-714b-56ee-ada6-d5b2a36b2cb6")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8b543d2d-4604-5a02-a455-7740240ab059")}catch(e){}}();
3
3
  export {};
4
4
  //# sourceMappingURL=api.js.map
5
- //# debugId=253b34fa-714b-56ee-ada6-d5b2a36b2cb6
5
+ //# debugId=8b543d2d-4604-5a02-a455-7740240ab059
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sources":["project/api.ts"],"sourceRoot":"/","sourcesContent":["import type { Kysely } from \"kysely\";\nimport type { InlangDatabaseSchema } from \"../database/schema.js\";\nimport type { InlangPlugin } from \"../plugin/schema.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport type { Lix } from \"@lix-js/sdk\";\nimport type { SqliteDatabase } from \"sqlite-wasm-kysely\";\n\nexport type InlangProject = {\n\tdb: Kysely<InlangDatabaseSchema>;\n\t/**\n\t * @deprecated Don't use this. Only an internal hack to unblock\n\t * fink v2.\n\t *\n\t * TODO remove this\n\t */\n\t_sqlite: SqliteDatabase;\n\tid: {\n\t\tget: () => Promise<string>;\n\t};\n\tplugins: {\n\t\tget: () => Promise<readonly InlangPlugin[]>;\n\t};\n\terrors: {\n\t\tget: () => Promise<readonly Error[]>;\n\t};\n\tsettings: {\n\t\tget: () => Promise<ProjectSettings>;\n\t\tset: (settings: ProjectSettings) => Promise<void>;\n\t};\n\tlix: Lix;\n\timportFiles: (args: {\n\t\tpluginKey: InlangPlugin[\"key\"];\n\t\tfiles: ImportFile[];\n\t}) => Promise<void>;\n\texportFiles: (args: {\n\t\tpluginKey: InlangPlugin[\"key\"];\n\t}) => Promise<ExportFile[]>;\n\tclose: () => Promise<void>;\n\ttoBlob: () => Promise<Blob>;\n};\n\nexport type ImportFile = {\n\t/** The locale of the resource file */\n\tlocale: string;\n\t/** The binary content of the resource */\n\tcontent: Uint8Array;\n\t/**\n\t * The metadata of the file to be imported.\n\t *\n\t * Used to store additional information that is accessible in `importFiles` via `toBeImportedFilesMetadata`.\n\t * https://github.com/opral/inlang-sdk/issues/218\n\t */\n\ttoBeImportedFilesMetadata?: Record<string, any>;\n};\n\nexport type ExportFile = {\n\t/** The locale of the resource file */\n\tlocale: string;\n\t/**\n\t * The name of the file.\n\t *\n\t * @example\n\t * \"en.json\"\n\t * \"common-de.json\"\n\t *\n\t */\n\tname: string;\n\t/** The binary content of the resource */\n\tcontent: Uint8Array;\n};\n\n/**\n * Minimal RxJS compatible (generic) subscription type.\n */\nexport type Subscription<T> = (callback: (value: T) => void) => {\n\tunsubscribe: () => void;\n};\n"],"names":[],"mappings":"","debug_id":"253b34fa-714b-56ee-ada6-d5b2a36b2cb6"}
1
+ {"version":3,"file":"api.js","sources":["project/api.ts"],"sourceRoot":"/","sourcesContent":["import type { Kysely } from \"kysely\";\nimport type { InlangDatabaseSchema } from \"../database/schema.js\";\nimport type { InlangPlugin } from \"../plugin/schema.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport type { Lix } from \"@lix-js/sdk\";\nimport type { SqliteWasmDatabase } from \"sqlite-wasm-kysely\";\n\nexport type InlangProject = {\n\tdb: Kysely<InlangDatabaseSchema>;\n\t/**\n\t * @deprecated Don't use this. Only an internal hack to unblock\n\t * fink v2.\n\t *\n\t * TODO remove this\n\t */\n\t_sqlite: SqliteWasmDatabase;\n\tid: {\n\t\tget: () => Promise<string>;\n\t};\n\tplugins: {\n\t\tget: () => Promise<readonly InlangPlugin[]>;\n\t};\n\terrors: {\n\t\tget: () => Promise<readonly Error[]>;\n\t};\n\tsettings: {\n\t\tget: () => Promise<ProjectSettings>;\n\t\tset: (settings: ProjectSettings) => Promise<void>;\n\t};\n\tlix: Lix;\n\timportFiles: (args: {\n\t\tpluginKey: InlangPlugin[\"key\"];\n\t\tfiles: ImportFile[];\n\t}) => Promise<void>;\n\texportFiles: (args: {\n\t\tpluginKey: InlangPlugin[\"key\"];\n\t}) => Promise<ExportFile[]>;\n\tclose: () => Promise<void>;\n\ttoBlob: () => Promise<Blob>;\n};\n\nexport type ImportFile = {\n\t/** The locale of the resource file */\n\tlocale: string;\n\t/** The binary content of the resource */\n\tcontent: Uint8Array;\n\t/**\n\t * The metadata of the file to be imported.\n\t *\n\t * Used to store additional information that is accessible in `importFiles` via `toBeImportedFilesMetadata`.\n\t * https://github.com/opral/inlang-sdk/issues/218\n\t */\n\ttoBeImportedFilesMetadata?: Record<string, any>;\n};\n\nexport type ExportFile = {\n\t/** The locale of the resource file */\n\tlocale: string;\n\t/**\n\t * The name of the file.\n\t *\n\t * @example\n\t * \"en.json\"\n\t * \"common-de.json\"\n\t *\n\t */\n\tname: string;\n\t/** The binary content of the resource */\n\tcontent: Uint8Array;\n};\n\n/**\n * Minimal RxJS compatible (generic) subscription type.\n */\nexport type Subscription<T> = (callback: (value: T) => void) => {\n\tunsubscribe: () => void;\n};\n"],"names":[],"mappings":"","debug_id":"8b543d2d-4604-5a02-a455-7740240ab059"}
@@ -1,13 +1,13 @@
1
1
  import { type Account, type Lix } from "@lix-js/sdk";
2
2
  import type { InlangPlugin } from "../plugin/schema.js";
3
- import { type SqliteDatabase } from "sqlite-wasm-kysely";
3
+ import { type SqliteWasmDatabase } from "sqlite-wasm-kysely";
4
4
  import { type PreprocessPluginBeforeImportFunction } from "../plugin/importPlugins.js";
5
5
  import type { InlangProject } from "./api.js";
6
6
  /**
7
7
  * Common load project logic.
8
8
  */
9
9
  export declare function loadProject(args: {
10
- sqlite: SqliteDatabase;
10
+ sqlite: SqliteWasmDatabase;
11
11
  lix: Lix;
12
12
  /**
13
13
  * The account that loaded the project.
@@ -1 +1 @@
1
- {"version":3,"file":"loadProject.d.ts","sourceRoot":"/","sources":["project/loadProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,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IACH,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IAChC;;;;;;;;;;;OAWG;IACH,4BAA4B,CAAC,EAAE,oCAAoC,CAAC;IACpE;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,aAAa,CAAC,CAmJzB"}
@@ -1,7 +1,7 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="04d161fd-6b88-5635-ba17-bbbf2ce627e1")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="92ebad4d-e869-5c7c-88e4-2a6561f4a358")}catch(e){}}();
3
3
  import { toBlob } from "@lix-js/sdk";
4
- import { contentFromDatabase } from "sqlite-wasm-kysely";
4
+ import { contentFromDatabase, } from "sqlite-wasm-kysely";
5
5
  import { initDb } from "../database/initDb.js";
6
6
  import { importPlugins, } from "../plugin/importPlugins.js";
7
7
  import { withLanguageTagToLocaleMigration } from "../migrations/v2/withLanguageTagToLocaleMigration.js";
@@ -163,4 +163,4 @@ async function maybeMigrateFirstProjectId(args) {
163
163
  }
164
164
  }
165
165
  //# sourceMappingURL=loadProject.js.map
166
- //# debugId=04d161fd-6b88-5635-ba17-bbbf2ce627e1
166
+ //# debugId=92ebad4d-e869-5c7c-88e4-2a6561f4a358
@@ -1 +1 @@
1
- {"version":3,"file":"loadProject.js","sources":["project/loadProject.ts"],"sourceRoot":"/","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 { contentFromDatabase, type SqliteDatabase } 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 { initErrorReporting } from \"../services/error-reporting/index.js\";\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: SqliteDatabase;\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\tinitErrorReporting({ projectId: id });\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: SqliteDatabase;\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"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAA0B,MAAM,aAAa,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAuB,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EACN,aAAa,GAEb,MAAM,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AE,CAAC,CAAC;YAC1D,OAAO,MAAM,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;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","debug_id":"04d161fd-6b88-5635-ba17-bbbf2ce627e1"}
1
+ {"version":3,"file":"loadProject.js","sources":["project/loadProject.ts"],"sourceRoot":"/","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 { initErrorReporting } from \"../services/error-reporting/index.js\";\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\tinitErrorReporting({ projectId: id });\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"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAA0B,MAAM,aAAa,CAAC;AAG7D,OAAO,EACN,mBAAmB,GAEnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE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,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YAC1D,OAAO,MAAM,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;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","debug_id":"92ebad4d-e869-5c7c-88e4-2a6561f4a358"}
@@ -19,7 +19,7 @@ export declare function loadProjectFromDirectory(args: {
19
19
  get: () => Promise<Error[]>;
20
20
  };
21
21
  db: import("kysely").Kysely<import("../index.js").InlangDatabaseSchema>;
22
- _sqlite: import("sqlite-wasm-kysely").SqliteDatabase;
22
+ _sqlite: import("sqlite-wasm-kysely").SqliteWasmDatabase;
23
23
  id: {
24
24
  get: () => Promise<string>;
25
25
  };
@@ -1,9 +1,9 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="59200f1b-8a13-58e1-8239-5a5836d1dfdc")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="653f0f90-c3af-5107-9290-8ba2d71d10af")}catch(e){}}();
3
3
  export const ENV_VARIABLES = {
4
4
  PUBLIC_POSTHOG_TOKEN: "phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz",
5
5
  PUBLIC_INLANG_SDK_SENTRY_DSN: "https://c3d92d5d011122e525e9f9b368e0905d@o4504345873285120.ingest.us.sentry.io/4507903389335553",
6
- SDK_VERSION: "2.1.0",
6
+ SDK_VERSION: "2.1.2",
7
7
  };
8
8
  //# sourceMappingURL=index.js.map
9
- //# debugId=59200f1b-8a13-58e1-8239-5a5836d1dfdc
9
+ //# debugId=653f0f90-c3af-5107-9290-8ba2d71d10af
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["services/env-variables/index.ts"],"sourceRoot":"/","sourcesContent":["\nexport const ENV_VARIABLES = {\n PUBLIC_POSTHOG_TOKEN: \"phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz\",\n\tPUBLIC_INLANG_SDK_SENTRY_DSN: \"https://c3d92d5d011122e525e9f9b368e0905d@o4504345873285120.ingest.us.sentry.io/4507903389335553\",\n\tSDK_VERSION: \"2.1.0\",\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,oBAAoB,EAAE,iDAAiD;IACxE,4BAA4B,EAAE,iGAAiG;IAC/H,WAAW,EAAE,OAAO;CACpB,CAAA","debug_id":"59200f1b-8a13-58e1-8239-5a5836d1dfdc"}
1
+ {"version":3,"file":"index.js","sources":["services/env-variables/index.ts"],"sourceRoot":"/","sourcesContent":["\nexport const ENV_VARIABLES = {\n PUBLIC_POSTHOG_TOKEN: \"phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz\",\n\tPUBLIC_INLANG_SDK_SENTRY_DSN: \"https://c3d92d5d011122e525e9f9b368e0905d@o4504345873285120.ingest.us.sentry.io/4507903389335553\",\n\tSDK_VERSION: \"2.1.2\",\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,oBAAoB,EAAE,iDAAiD;IACxE,4BAA4B,EAAE,iGAAiG;IAC/H,WAAW,EAAE,OAAO;CACpB,CAAA","debug_id":"653f0f90-c3af-5107-9290-8ba2d71d10af"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inlang/sdk",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -30,8 +30,8 @@
30
30
  "@sinclair/typebox": "^0.31.17",
31
31
  "kysely": "^0.27.4",
32
32
  "uuid": "^10.0.0",
33
- "@lix-js/sdk": "0.3.3",
34
- "sqlite-wasm-kysely": "0.1.1"
33
+ "sqlite-wasm-kysely": "0.3.0",
34
+ "@lix-js/sdk": "0.3.5"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@eslint/js": "^9.12.0",
@@ -1,11 +1,11 @@
1
1
  import { CamelCasePlugin, Kysely } from "kysely";
2
2
  import { applySchema, type InlangDatabaseSchema } from "./schema.js";
3
- import { createDialect, type SqliteDatabase } from "sqlite-wasm-kysely";
3
+ import { createDialect, type SqliteWasmDatabase } from "sqlite-wasm-kysely";
4
4
  import { v7 } from "uuid";
5
5
  import { humanId } from "../human-id/human-id.js";
6
6
  import { JsonbPlugin } from "./jsonbPlugin.js";
7
7
 
8
- export function initDb(args: { sqlite: SqliteDatabase }) {
8
+ export function initDb(args: { sqlite: SqliteWasmDatabase }) {
9
9
  initDefaultValueFunctions({ sqlite: args.sqlite });
10
10
  applySchema({ sqlite: args.sqlite });
11
11
  const db = new Kysely<InlangDatabaseSchema>({
@@ -20,7 +20,7 @@ export function initDb(args: { sqlite: SqliteDatabase }) {
20
20
  return db;
21
21
  }
22
22
 
23
- function initDefaultValueFunctions(args: { sqlite: SqliteDatabase }) {
23
+ function initDefaultValueFunctions(args: { sqlite: SqliteWasmDatabase }) {
24
24
  args.sqlite.createFunction({
25
25
  name: "uuid_v7",
26
26
  arity: 0,
@@ -13,14 +13,14 @@ import {
13
13
  type UnknownRow,
14
14
  OnConflictNode,
15
15
  } from "kysely";
16
- import type { SqliteDatabase } from "sqlite-wasm-kysely";
16
+ import type { SqliteWasmDatabase } from "sqlite-wasm-kysely";
17
17
 
18
18
  export class JsonbPlugin implements KyselyPlugin {
19
19
  #serializeJsonTransformer = new SerializeJsonbTransformer();
20
20
  #parseJsonPlugin = new ParseJSONResultsPlugin();
21
- #database: SqliteDatabase;
21
+ #database: SqliteWasmDatabase;
22
22
 
23
- constructor(args: { database: SqliteDatabase }) {
23
+ constructor(args: { database: SqliteWasmDatabase }) {
24
24
  this.#database = args.database;
25
25
  }
26
26
 
@@ -1,12 +1,12 @@
1
1
  import type { Generated, Insertable, Selectable, Updateable } from "kysely";
2
- import type { SqliteDatabase } from "sqlite-wasm-kysely";
2
+ import type { SqliteWasmDatabase } from "sqlite-wasm-kysely";
3
3
  import {
4
4
  Declaration,
5
5
  Pattern,
6
6
  VariableReference,
7
7
  } from "../json-schema/pattern.js";
8
8
 
9
- export function applySchema(args: { sqlite: SqliteDatabase }) {
9
+ export function applySchema(args: { sqlite: SqliteWasmDatabase }) {
10
10
  const foreignKeyActivated: any = args.sqlite.exec("PRAGMA foreign_keys", {
11
11
  returnValue: "resultRows",
12
12
  });
@@ -20,7 +20,8 @@ const SDKSettings = Type.Object({
20
20
  // remove in SDK-v3
21
21
  sourceLanguageTag: Type.Optional(
22
22
  Type.String({
23
- description: "Use baseLocale instead.",
23
+ description:
24
+ "Use baseLocale instead if all your inlang apps that you are using are on the inlang SDK V2. Otherwise, leave this property in.",
24
25
  deprecated: true,
25
26
  })
26
27
  ),
@@ -30,7 +31,8 @@ const SDKSettings = Type.Object({
30
31
  Type.Array(Type.String(), {
31
32
  uniqueItems: true,
32
33
  deprecated: true,
33
- description: "Use locales instead.",
34
+ description:
35
+ "Use baseLocale instead if all your inlang apps that you are using are on the inlang SDK V2. Otherwise, leave this property in.",
34
36
  })
35
37
  ),
36
38
  /**
@@ -3,7 +3,7 @@ import type { InlangDatabaseSchema } from "../database/schema.js";
3
3
  import type { InlangPlugin } from "../plugin/schema.js";
4
4
  import type { ProjectSettings } from "../json-schema/settings.js";
5
5
  import type { Lix } from "@lix-js/sdk";
6
- import type { SqliteDatabase } from "sqlite-wasm-kysely";
6
+ import type { SqliteWasmDatabase } from "sqlite-wasm-kysely";
7
7
 
8
8
  export type InlangProject = {
9
9
  db: Kysely<InlangDatabaseSchema>;
@@ -13,7 +13,7 @@ export type InlangProject = {
13
13
  *
14
14
  * TODO remove this
15
15
  */
16
- _sqlite: SqliteDatabase;
16
+ _sqlite: SqliteWasmDatabase;
17
17
  id: {
18
18
  get: () => Promise<string>;
19
19
  };
@@ -1,7 +1,10 @@
1
1
  import { toBlob, type Account, type Lix } from "@lix-js/sdk";
2
2
  import type { InlangPlugin } from "../plugin/schema.js";
3
3
  import type { ProjectSettings } from "../json-schema/settings.js";
4
- import { contentFromDatabase, type SqliteDatabase } from "sqlite-wasm-kysely";
4
+ import {
5
+ contentFromDatabase,
6
+ type SqliteWasmDatabase,
7
+ } from "sqlite-wasm-kysely";
5
8
  import { initDb } from "../database/initDb.js";
6
9
  import {
7
10
  importPlugins,
@@ -19,7 +22,7 @@ import { exportFiles } from "../import-export/exportFiles.js";
19
22
  * Common load project logic.
20
23
  */
21
24
  export async function loadProject(args: {
22
- sqlite: SqliteDatabase;
25
+ sqlite: SqliteWasmDatabase;
23
26
  lix: Lix;
24
27
  /**
25
28
  * The account that loaded the project.
@@ -211,7 +214,7 @@ export async function loadProject(args: {
211
214
  }
212
215
 
213
216
  async function saveDbToLix(args: {
214
- sqlite: SqliteDatabase;
217
+ sqlite: SqliteWasmDatabase;
215
218
  lix: Lix;
216
219
  }): Promise<void> {
217
220
  const data = contentFromDatabase(args.sqlite);