@lix-js/sdk 0.1.0 → 0.3.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.
Files changed (121) hide show
  1. package/dist/account/database-schema.d.ts.map +1 -1
  2. package/dist/account/database-schema.js +2 -6
  3. package/dist/account/database-schema.js.map +1 -1
  4. package/dist/account/database-schema.test.js +4 -8
  5. package/dist/account/database-schema.test.js.map +1 -1
  6. package/dist/database/apply-schema.js +2 -2
  7. package/dist/database/init-db.test.js +3 -3
  8. package/dist/database/init-db.test.js.map +1 -1
  9. package/dist/file-queue/file-queue-process.d.ts.map +1 -1
  10. package/dist/file-queue/file-queue-process.js +4 -1
  11. package/dist/file-queue/file-queue-process.js.map +1 -1
  12. package/dist/file-queue/file-queue-process.test.js +4 -5
  13. package/dist/file-queue/file-queue-process.test.js.map +1 -1
  14. package/dist/lix/open-lix.d.ts +16 -1
  15. package/dist/lix/open-lix.d.ts.map +1 -1
  16. package/dist/lix/open-lix.js +76 -0
  17. package/dist/lix/open-lix.js.map +1 -1
  18. package/dist/lix/open-lix.test.js +54 -0
  19. package/dist/lix/open-lix.test.js.map +1 -1
  20. package/dist/query-filter/change-has-label.d.ts +2 -2
  21. package/dist/query-filter/change-has-label.js +2 -2
  22. package/dist/query-filter/change-set-has-label.d.ts +2 -2
  23. package/dist/query-filter/change-set-has-label.js +2 -2
  24. package/dist/services/env-variables/index.d.ts +5 -0
  25. package/dist/services/env-variables/index.d.ts.map +1 -0
  26. package/dist/services/env-variables/index.js +5 -0
  27. package/dist/services/env-variables/index.js.map +1 -0
  28. package/dist/services/telemetry/capture.d.ts +30 -0
  29. package/dist/services/telemetry/capture.d.ts.map +1 -0
  30. package/dist/services/telemetry/capture.js +71 -0
  31. package/dist/services/telemetry/capture.js.map +1 -0
  32. package/dist/services/telemetry/capture.test.d.ts +2 -0
  33. package/dist/services/telemetry/capture.test.d.ts.map +1 -0
  34. package/dist/services/telemetry/capture.test.js +37 -0
  35. package/dist/services/telemetry/capture.test.js.map +1 -0
  36. package/dist/sync/sync-process.d.ts.map +1 -1
  37. package/dist/sync/sync-process.js +11 -5
  38. package/dist/sync/sync-process.js.map +1 -1
  39. package/package.json +4 -6
  40. package/src/account/database-schema.test.ts +6 -9
  41. package/src/account/database-schema.ts +2 -6
  42. package/src/database/apply-schema.ts +2 -2
  43. package/src/database/init-db.test.ts +3 -3
  44. package/src/file-queue/file-queue-process.test.ts +4 -5
  45. package/src/file-queue/file-queue-process.ts +4 -1
  46. package/src/lix/open-lix.test.ts +63 -0
  47. package/src/lix/open-lix.ts +98 -1
  48. package/src/query-filter/change-has-label.ts +2 -2
  49. package/src/query-filter/change-set-has-label.ts +2 -2
  50. package/src/services/env-variables/create-index-file.js +35 -0
  51. package/src/services/env-variables/index.d.ts +15 -0
  52. package/src/services/telemetry/capture.test.ts +44 -0
  53. package/src/services/telemetry/capture.ts +99 -0
  54. package/src/sync/sync-process.ts +11 -6
  55. package/node_modules/@lix-js/server-api-schema/.prettierrc.json +0 -3
  56. package/node_modules/@lix-js/server-api-schema/.vscode/extensions.json +0 -3
  57. package/node_modules/@lix-js/server-api-schema/CHANGELOG.md +0 -9
  58. package/node_modules/@lix-js/server-api-schema/LICENSE +0 -21
  59. package/node_modules/@lix-js/server-api-schema/dist/schema.js +0 -0
  60. package/node_modules/@lix-js/server-api-schema/package.json +0 -21
  61. package/node_modules/@lix-js/server-api-schema/src/schema.yaml +0 -290
  62. package/node_modules/@lix-js/server-api-schema/tsconfig.json +0 -20
  63. package/node_modules/sqlite-wasm-kysely/LICENSE +0 -21
  64. package/node_modules/sqlite-wasm-kysely/README.md +0 -11
  65. package/node_modules/sqlite-wasm-kysely/dist/dialect.d.ts +0 -11
  66. package/node_modules/sqlite-wasm-kysely/dist/dialect.js +0 -13
  67. package/node_modules/sqlite-wasm-kysely/dist/dialect.js.map +0 -1
  68. package/node_modules/sqlite-wasm-kysely/dist/index.d.ts +0 -2
  69. package/node_modules/sqlite-wasm-kysely/dist/index.js +0 -3
  70. package/node_modules/sqlite-wasm-kysely/dist/index.js.map +0 -1
  71. package/node_modules/sqlite-wasm-kysely/dist/kysely/ConnectionMutex.d.ts +0 -5
  72. package/node_modules/sqlite-wasm-kysely/dist/kysely/ConnectionMutex.js +0 -34
  73. package/node_modules/sqlite-wasm-kysely/dist/kysely/ConnectionMutex.js.map +0 -1
  74. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmConnection.d.ts +0 -8
  75. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmConnection.js +0 -57
  76. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmConnection.js.map +0 -1
  77. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDialectConfig.d.ts +0 -18
  78. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDialectConfig.js +0 -2
  79. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDialectConfig.js.map +0 -1
  80. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDriver.d.ts +0 -13
  81. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDriver.js +0 -57
  82. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDriver.js.map +0 -1
  83. package/node_modules/sqlite-wasm-kysely/dist/kysely/index.d.ts +0 -4
  84. package/node_modules/sqlite-wasm-kysely/dist/kysely/index.js +0 -4
  85. package/node_modules/sqlite-wasm-kysely/dist/kysely/index.js.map +0 -1
  86. package/node_modules/sqlite-wasm-kysely/dist/kysely/sqliteModule.d.ts +0 -3
  87. package/node_modules/sqlite-wasm-kysely/dist/kysely/sqliteModule.js +0 -5
  88. package/node_modules/sqlite-wasm-kysely/dist/kysely/sqliteModule.js.map +0 -1
  89. package/node_modules/sqlite-wasm-kysely/dist/util/contentFromDatabase.d.ts +0 -9
  90. package/node_modules/sqlite-wasm-kysely/dist/util/contentFromDatabase.js +0 -12
  91. package/node_modules/sqlite-wasm-kysely/dist/util/contentFromDatabase.js.map +0 -1
  92. package/node_modules/sqlite-wasm-kysely/dist/util/createInMemoryDatabase.d.ts +0 -3
  93. package/node_modules/sqlite-wasm-kysely/dist/util/createInMemoryDatabase.js +0 -22
  94. package/node_modules/sqlite-wasm-kysely/dist/util/createInMemoryDatabase.js.map +0 -1
  95. package/node_modules/sqlite-wasm-kysely/dist/util/importDatabase.d.ts +0 -7
  96. package/node_modules/sqlite-wasm-kysely/dist/util/importDatabase.js +0 -15
  97. package/node_modules/sqlite-wasm-kysely/dist/util/importDatabase.js.map +0 -1
  98. package/node_modules/sqlite-wasm-kysely/dist/util/index.d.ts +0 -5
  99. package/node_modules/sqlite-wasm-kysely/dist/util/index.js +0 -5
  100. package/node_modules/sqlite-wasm-kysely/dist/util/index.js.map +0 -1
  101. package/node_modules/sqlite-wasm-kysely/dist/util/loadDatabaseInMemory.d.ts +0 -1
  102. package/node_modules/sqlite-wasm-kysely/dist/util/loadDatabaseInMemory.js +0 -13
  103. package/node_modules/sqlite-wasm-kysely/dist/util/loadDatabaseInMemory.js.map +0 -1
  104. package/node_modules/sqlite-wasm-kysely/dist/util/sqliteWasmBinary.d.ts +0 -7
  105. package/node_modules/sqlite-wasm-kysely/dist/util/sqliteWasmBinary.js +0 -17
  106. package/node_modules/sqlite-wasm-kysely/dist/util/sqliteWasmBinary.js.map +0 -1
  107. package/node_modules/sqlite-wasm-kysely/package.json +0 -34
  108. package/node_modules/sqlite-wasm-kysely/src/dialect.ts +0 -15
  109. package/node_modules/sqlite-wasm-kysely/src/index.ts +0 -2
  110. package/node_modules/sqlite-wasm-kysely/src/kysely/ConnectionMutex.ts +0 -23
  111. package/node_modules/sqlite-wasm-kysely/src/kysely/SqliteWasmConnection.ts +0 -57
  112. package/node_modules/sqlite-wasm-kysely/src/kysely/SqliteWasmDialectConfig.ts +0 -19
  113. package/node_modules/sqlite-wasm-kysely/src/kysely/SqliteWasmDriver.ts +0 -58
  114. package/node_modules/sqlite-wasm-kysely/src/kysely/index.ts +0 -4
  115. package/node_modules/sqlite-wasm-kysely/src/kysely/sqliteModule.ts +0 -7
  116. package/node_modules/sqlite-wasm-kysely/src/util/contentFromDatabase.ts +0 -13
  117. package/node_modules/sqlite-wasm-kysely/src/util/createInMemoryDatabase.ts +0 -30
  118. package/node_modules/sqlite-wasm-kysely/src/util/importDatabase.ts +0 -34
  119. package/node_modules/sqlite-wasm-kysely/src/util/index.ts +0 -5
  120. package/node_modules/sqlite-wasm-kysely/src/util/loadDatabaseInMemory.ts +0 -13
  121. package/node_modules/sqlite-wasm-kysely/src/util/sqliteWasmBinary.ts +0 -20
@@ -1,11 +0,0 @@
1
- import { SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from "kysely";
2
- import { SqliteWasmDriver } from "./kysely/SqliteWasmDriver.js";
3
- import { Database } from "@eliaspourquoi/sqlite-node-wasm";
4
- export declare const createDialect: (args: {
5
- database: Database;
6
- }) => {
7
- createAdapter: () => SqliteAdapter;
8
- createDriver: () => SqliteWasmDriver;
9
- createIntrospector: (db: any) => SqliteIntrospector;
10
- createQueryCompiler: () => SqliteQueryCompiler;
11
- };
@@ -1,13 +0,0 @@
1
- import { SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from "kysely";
2
- import { SqliteWasmDriver } from "./kysely/SqliteWasmDriver.js";
3
- export const createDialect = (args) => {
4
- return {
5
- createAdapter: () => new SqliteAdapter(),
6
- createDriver: () => new SqliteWasmDriver({
7
- database: args.database,
8
- }),
9
- createIntrospector: (db) => new SqliteIntrospector(db),
10
- createQueryCompiler: () => new SqliteQueryCompiler(),
11
- };
12
- };
13
- //# sourceMappingURL=dialect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dialect.js","sourceRoot":"","sources":["../src/dialect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAA4B,EAAE,EAAE;IAC5D,OAAO;QACL,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,aAAa,EAAE;QACxC,YAAY,EAAE,GAAG,EAAE,CACjB,IAAI,gBAAgB,CAAC;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;QACJ,kBAAkB,EAAE,CAAC,EAAO,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,EAAE,CAAC;QAC3D,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAI,mBAAmB,EAAE;KACrD,CAAC;AACJ,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from "./util/index.js";
2
- export { createDialect } from "./dialect.js";
@@ -1,3 +0,0 @@
1
- export * from "./util/index.js";
2
- export { createDialect } from "./dialect.js";
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
@@ -1,5 +0,0 @@
1
- export declare class ConnectionMutex {
2
- #private;
3
- lock(): Promise<void>;
4
- unlock(): void;
5
- }
@@ -1,34 +0,0 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _ConnectionMutex_promise, _ConnectionMutex_resolve;
13
- export class ConnectionMutex {
14
- constructor() {
15
- _ConnectionMutex_promise.set(this, void 0);
16
- _ConnectionMutex_resolve.set(this, void 0);
17
- }
18
- async lock() {
19
- while (__classPrivateFieldGet(this, _ConnectionMutex_promise, "f")) {
20
- await __classPrivateFieldGet(this, _ConnectionMutex_promise, "f");
21
- }
22
- __classPrivateFieldSet(this, _ConnectionMutex_promise, new Promise((resolve) => {
23
- __classPrivateFieldSet(this, _ConnectionMutex_resolve, resolve, "f");
24
- }), "f");
25
- }
26
- unlock() {
27
- const resolve = __classPrivateFieldGet(this, _ConnectionMutex_resolve, "f");
28
- __classPrivateFieldSet(this, _ConnectionMutex_promise, undefined, "f");
29
- __classPrivateFieldSet(this, _ConnectionMutex_resolve, undefined, "f");
30
- resolve?.();
31
- }
32
- }
33
- _ConnectionMutex_promise = new WeakMap(), _ConnectionMutex_resolve = new WeakMap();
34
- //# sourceMappingURL=ConnectionMutex.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConnectionMutex.js","sourceRoot":"","sources":["../../src/kysely/ConnectionMutex.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAM,OAAO,eAAe;IAA5B;QACE,2CAAyB;QACzB,2CAAsB;IAoBxB,CAAC;IAlBC,KAAK,CAAC,IAAI;QACR,OAAO,uBAAA,IAAI,gCAAS,EAAE,CAAC;YACrB,MAAM,uBAAA,IAAI,gCAAS,CAAC;QACtB,CAAC;QAED,uBAAA,IAAI,4BAAY,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACtC,uBAAA,IAAI,4BAAY,OAAO,MAAA,CAAC;QAC1B,CAAC,CAAC,MAAA,CAAC;IACL,CAAC;IAED,MAAM;QACJ,MAAM,OAAO,GAAG,uBAAA,IAAI,gCAAS,CAAC;QAE9B,uBAAA,IAAI,4BAAY,SAAS,MAAA,CAAC;QAC1B,uBAAA,IAAI,4BAAY,SAAS,MAAA,CAAC;QAE1B,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;CACF"}
@@ -1,8 +0,0 @@
1
- import { CompiledQuery, DatabaseConnection, QueryResult } from "kysely";
2
- import { Database } from "@eliaspourquoi/sqlite-node-wasm";
3
- export declare class SqliteWasmConnection implements DatabaseConnection {
4
- #private;
5
- constructor(db: Database);
6
- executeQuery<O>(compiledQuery: CompiledQuery): Promise<QueryResult<O>>;
7
- streamQuery(): AsyncGenerator<never, void, unknown>;
8
- }
@@ -1,57 +0,0 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _SqliteWasmConnection_db;
13
- import { sqliteModule } from "./sqliteModule.js";
14
- export class SqliteWasmConnection {
15
- constructor(db) {
16
- _SqliteWasmConnection_db.set(this, void 0);
17
- __classPrivateFieldSet(this, _SqliteWasmConnection_db, db, "f");
18
- }
19
- executeQuery(compiledQuery) {
20
- const { sql, parameters } = compiledQuery;
21
- const statementData = {
22
- rows: [],
23
- columns: [],
24
- };
25
- // we cant know what kind of query we are dealing with at that state - unless we switch to perpared statments
26
- // for now we collect all information required
27
- // save the changes before (total changes seems to be fast and worth the twoe extra round trips inspiration from https://github.com/WiseLibs/better-sqlite3/blob/254b8e93d78b1b03c9a2c777f4d304a0ea1530c6/src/objects/statement.lzz#L159)
28
- const totalChangesBefore = __classPrivateFieldGet(this, _SqliteWasmConnection_db, "f").changes(true);
29
- // execute the statement
30
- const rows = __classPrivateFieldGet(this, _SqliteWasmConnection_db, "f").exec({
31
- sql: sql,
32
- bind: parameters,
33
- returnValue: "resultRows",
34
- rowMode: "object",
35
- columnNames: statementData.columns,
36
- });
37
- const lastInsertId = sqliteModule?.capi.sqlite3_last_insert_rowid(__classPrivateFieldGet(this, _SqliteWasmConnection_db, "f"));
38
- // check if we had changes in the db at all - if so - collect the number of changes
39
- const changes = totalChangesBefore === __classPrivateFieldGet(this, _SqliteWasmConnection_db, "f").changes(true) ? 0 : __classPrivateFieldGet(this, _SqliteWasmConnection_db, "f").changes();
40
- // console.log('sql: ' + sql);
41
- // console.log('result: ', rows);
42
- // We don't have knowledge about rather its update/delete/or select - so we return the results
43
- // @ts-expect-error - TODO for @martin-lysk - typescript complains
44
- return Promise.resolve({
45
- numAffectedRows: changes,
46
- insertId: lastInsertId,
47
- // queries with result
48
- rows: rows,
49
- });
50
- }
51
- // eslint-disable-next-line require-yield
52
- async *streamQuery() {
53
- throw new Error("not supported for wasm driver yet");
54
- }
55
- }
56
- _SqliteWasmConnection_db = new WeakMap();
57
- //# sourceMappingURL=SqliteWasmConnection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SqliteWasmConnection.js","sourceRoot":"","sources":["../../src/kysely/SqliteWasmConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,OAAO,oBAAoB;IAG/B,YAAY,EAAY;QAFf,2CAAc;QAGrB,uBAAA,IAAI,4BAAO,EAAE,MAAA,CAAC;IAChB,CAAC;IAED,YAAY,CAAI,aAA4B;QAC1C,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC;QAE1C,MAAM,aAAa,GAAG;YACpB,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,EAAE;SACZ,CAAC;QAEF,6GAA6G;QAC7G,8CAA8C;QAC9C,yOAAyO;QACzO,MAAM,kBAAkB,GAAG,uBAAA,IAAI,gCAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAElD,wBAAwB;QACxB,MAAM,IAAI,GAAG,uBAAA,IAAI,gCAAI,CAAC,IAAI,CAAC;YACzB,GAAG,EAAE,GAAG;YACR,IAAI,EAAE,UAAiB;YACvB,WAAW,EAAE,YAAY;YACzB,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,aAAa,CAAC,OAAO;SACnC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,YAAY,EAAE,IAAI,CAAC,yBAAyB,CAAC,uBAAA,IAAI,gCAAI,CAAC,CAAC;QAE5E,mFAAmF;QACnF,MAAM,OAAO,GACX,kBAAkB,KAAK,uBAAA,IAAI,gCAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,uBAAA,IAAI,gCAAI,CAAC,OAAO,EAAE,CAAC;QAEzE,8BAA8B;QAC9B,iCAAiC;QACjC,8FAA8F;QAC9F,kEAAkE;QAClE,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,eAAe,EAAE,OAAO;YACxB,QAAQ,EAAE,YAAY;YAEtB,sBAAsB;YACtB,IAAI,EAAE,IAAW;SAClB,CAAC,CAAC;IACL,CAAC;IAED,yCAAyC;IACzC,KAAK,CAAC,CAAC,WAAW;QAChB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;CACF"}
@@ -1,18 +0,0 @@
1
- import { DatabaseConnection } from "kysely";
2
- import { Database } from "@eliaspourquoi/sqlite-node-wasm";
3
- export interface SqliteWasmDialectConfig {
4
- /**
5
- * An sqlite Database instance or a function that returns one.
6
- *
7
- * If a function is provided, it's called once when the first query is executed.
8
- *
9
- * https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md#new-databasepath-options
10
- */
11
- database: Database | (() => Promise<Database>);
12
- /**
13
- * Called once when the first query is executed.
14
- *
15
- * This is a Kysely specific feature and does not come from the `better-sqlite3` module.
16
- */
17
- onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
18
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=SqliteWasmDialectConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SqliteWasmDialectConfig.js","sourceRoot":"","sources":["../../src/kysely/SqliteWasmDialectConfig.ts"],"names":[],"mappings":""}
@@ -1,13 +0,0 @@
1
- import { DatabaseConnection, Driver } from "kysely";
2
- import { SqliteWasmDialectConfig } from "./SqliteWasmDialectConfig.js";
3
- export declare class SqliteWasmDriver implements Driver {
4
- #private;
5
- constructor(config: SqliteWasmDialectConfig);
6
- init(): Promise<void>;
7
- acquireConnection(): Promise<DatabaseConnection>;
8
- beginTransaction(connection: DatabaseConnection): Promise<void>;
9
- commitTransaction(connection: DatabaseConnection): Promise<void>;
10
- rollbackTransaction(connection: DatabaseConnection): Promise<void>;
11
- releaseConnection(): Promise<void>;
12
- destroy(): Promise<void>;
13
- }
@@ -1,57 +0,0 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _SqliteWasmDriver_config, _SqliteWasmDriver_connectionMutex, _SqliteWasmDriver_db, _SqliteWasmDriver_connection;
13
- import { CompiledQuery } from "kysely";
14
- import { ConnectionMutex } from "./ConnectionMutex.js";
15
- import { SqliteWasmConnection } from "./SqliteWasmConnection.js";
16
- export class SqliteWasmDriver {
17
- constructor(config) {
18
- _SqliteWasmDriver_config.set(this, void 0);
19
- _SqliteWasmDriver_connectionMutex.set(this, new ConnectionMutex());
20
- _SqliteWasmDriver_db.set(this, void 0);
21
- _SqliteWasmDriver_connection.set(this, void 0);
22
- // this.#config = freeze({ ...config })
23
- __classPrivateFieldSet(this, _SqliteWasmDriver_config, { ...config }, "f");
24
- }
25
- async init() {
26
- __classPrivateFieldSet(this, _SqliteWasmDriver_db, typeof __classPrivateFieldGet(this, _SqliteWasmDriver_config, "f").database === "function"
27
- ? await __classPrivateFieldGet(this, _SqliteWasmDriver_config, "f").database()
28
- : __classPrivateFieldGet(this, _SqliteWasmDriver_config, "f").database, "f");
29
- __classPrivateFieldSet(this, _SqliteWasmDriver_connection, new SqliteWasmConnection(__classPrivateFieldGet(this, _SqliteWasmDriver_db, "f")), "f");
30
- if (__classPrivateFieldGet(this, _SqliteWasmDriver_config, "f").onCreateConnection) {
31
- await __classPrivateFieldGet(this, _SqliteWasmDriver_config, "f").onCreateConnection(__classPrivateFieldGet(this, _SqliteWasmDriver_connection, "f"));
32
- }
33
- }
34
- async acquireConnection() {
35
- // SQLite only has one single connection. We use a mutex here to wait
36
- // until the single connection has been released.
37
- await __classPrivateFieldGet(this, _SqliteWasmDriver_connectionMutex, "f").lock();
38
- return __classPrivateFieldGet(this, _SqliteWasmDriver_connection, "f");
39
- }
40
- async beginTransaction(connection) {
41
- await connection.executeQuery(CompiledQuery.raw("begin"));
42
- }
43
- async commitTransaction(connection) {
44
- await connection.executeQuery(CompiledQuery.raw("commit"));
45
- }
46
- async rollbackTransaction(connection) {
47
- await connection.executeQuery(CompiledQuery.raw("rollback"));
48
- }
49
- async releaseConnection() {
50
- __classPrivateFieldGet(this, _SqliteWasmDriver_connectionMutex, "f").unlock();
51
- }
52
- async destroy() {
53
- __classPrivateFieldGet(this, _SqliteWasmDriver_db, "f")?.close();
54
- }
55
- }
56
- _SqliteWasmDriver_config = new WeakMap(), _SqliteWasmDriver_connectionMutex = new WeakMap(), _SqliteWasmDriver_db = new WeakMap(), _SqliteWasmDriver_connection = new WeakMap();
57
- //# sourceMappingURL=SqliteWasmDriver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SqliteWasmDriver.js","sourceRoot":"","sources":["../../src/kysely/SqliteWasmDriver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAA8B,MAAM,QAAQ,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,OAAO,gBAAgB;IAO3B,YAAY,MAA+B;QANlC,2CAAiC;QACjC,4CAAmB,IAAI,eAAe,EAAE,EAAC;QAElD,uCAAe;QACf,+CAAiC;QAG/B,uCAAuC;QACvC,uBAAA,IAAI,4BAAW,EAAE,GAAG,MAAM,EAAE,MAAA,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI;QACR,uBAAA,IAAI,wBACF,OAAO,uBAAA,IAAI,gCAAQ,CAAC,QAAQ,KAAK,UAAU;YACzC,CAAC,CAAC,MAAM,uBAAA,IAAI,gCAAQ,CAAC,QAAQ,EAAE;YAC/B,CAAC,CAAC,uBAAA,IAAI,gCAAQ,CAAC,QAAQ,MAAA,CAAC;QAE5B,uBAAA,IAAI,gCAAe,IAAI,oBAAoB,CAAC,uBAAA,IAAI,4BAAI,CAAC,MAAA,CAAC;QAEtD,IAAI,uBAAA,IAAI,gCAAQ,CAAC,kBAAkB,EAAE,CAAC;YACpC,MAAM,uBAAA,IAAI,gCAAQ,CAAC,kBAAkB,CAAC,uBAAA,IAAI,oCAAY,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,qEAAqE;QACrE,iDAAiD;QACjD,MAAM,uBAAA,IAAI,yCAAiB,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,uBAAA,IAAI,oCAAa,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,UAA8B;QACnD,MAAM,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,UAA8B;QACpD,MAAM,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,UAA8B;QACtD,MAAM,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,uBAAA,IAAI,yCAAiB,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,OAAO;QACX,uBAAA,IAAI,4BAAI,EAAE,KAAK,EAAE,CAAC;IACpB,CAAC;CACF"}
@@ -1,4 +0,0 @@
1
- export { SqliteWasmConnection } from "./SqliteWasmConnection.js";
2
- export type { SqliteWasmDialectConfig } from "./SqliteWasmDialectConfig.js";
3
- export { SqliteWasmDriver } from "./SqliteWasmDriver.js";
4
- export { ConnectionMutex } from "./ConnectionMutex.js";
@@ -1,4 +0,0 @@
1
- export { SqliteWasmConnection } from "./SqliteWasmConnection.js";
2
- export { SqliteWasmDriver } from "./SqliteWasmDriver.js";
3
- export { ConnectionMutex } from "./ConnectionMutex.js";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/kysely/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Sqlite3Static } from "@eliaspourquoi/sqlite-node-wasm";
2
- export declare let sqliteModule: Sqlite3Static;
3
- export declare function setSqliteModule(module: Sqlite3Static): void;
@@ -1,5 +0,0 @@
1
- export let sqliteModule;
2
- export function setSqliteModule(module) {
3
- sqliteModule = module;
4
- }
5
- //# sourceMappingURL=sqliteModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sqliteModule.js","sourceRoot":"","sources":["../../src/kysely/sqliteModule.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,IAAI,YAA2B,CAAC;AAEvC,MAAM,UAAU,eAAe,CAAC,MAAqB;IACnD,YAAY,GAAG,MAAM,CAAC;AACxB,CAAC"}
@@ -1,9 +0,0 @@
1
- import { Database } from "@eliaspourquoi/sqlite-node-wasm";
2
- /**
3
- * Exports the content of a database as a Uint8Array.
4
- *
5
- * @example
6
- * const db = createInMemoryDatabase({ readOnly: false });
7
- * const content = contentFromDatabase(db);
8
- */
9
- export declare const contentFromDatabase: (db: Database) => Uint8Array;
@@ -1,12 +0,0 @@
1
- import { sqliteModule } from "../kysely/sqliteModule.js";
2
- /**
3
- * Exports the content of a database as a Uint8Array.
4
- *
5
- * @example
6
- * const db = createInMemoryDatabase({ readOnly: false });
7
- * const content = contentFromDatabase(db);
8
- */
9
- export const contentFromDatabase = (db) => {
10
- return sqliteModule.capi.sqlite3_js_db_export(db);
11
- };
12
- //# sourceMappingURL=contentFromDatabase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contentFromDatabase.js","sourceRoot":"","sources":["../../src/util/contentFromDatabase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAY,EAAc,EAAE;IAC9D,OAAO,YAAY,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare const createInMemoryDatabase: ({ readOnly, }: {
2
- readOnly?: boolean;
3
- }) => Promise<import("@eliaspourquoi/sqlite-node-wasm").Database>;
@@ -1,22 +0,0 @@
1
- import sqlite3InitModule from "@eliaspourquoi/sqlite-node-wasm";
2
- import { setSqliteModule, sqliteModule } from "../kysely/sqliteModule.js";
3
- import { wasmBinary } from "./sqliteWasmBinary.js";
4
- export const createInMemoryDatabase = async ({ readOnly = false, }) => {
5
- if (!sqliteModule) {
6
- await initSqlite();
7
- }
8
- const flags = [
9
- readOnly ? "r" : "cw", // read and write
10
- "", // non verbose
11
- ].join("");
12
- return new sqliteModule.oo1.DB(":memory:", flags);
13
- };
14
- async function initSqlite() {
15
- setSqliteModule(await sqlite3InitModule({
16
- // @ts-expect-error
17
- wasmBinary: wasmBinary,
18
- // https://github.com/opral/inlang-sdk/issues/170#issuecomment-2334768193
19
- locateFile: () => "sqlite3.wasm",
20
- }));
21
- }
22
- //# sourceMappingURL=createInMemoryDatabase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createInMemoryDatabase.js","sourceRoot":"","sources":["../../src/util/createInMemoryDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,EAC3C,QAAQ,GAAG,KAAK,GAGjB,EAAE,EAAE;IACH,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,UAAU,EAAE,CAAC;IACrB,CAAC;IACD,MAAM,KAAK,GAAG;QACZ,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,iBAAiB;QACxC,EAAE,EAAE,cAAc;KACnB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEX,OAAO,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,KAAK,UAAU,UAAU;IACvB,eAAe,CACb,MAAM,iBAAiB,CAAC;QACtB,mBAAmB;QACnB,UAAU,EAAE,UAAU;QACtB,yEAAyE;QACzE,UAAU,EAAE,GAAG,EAAE,CAAC,cAAc;KACjC,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -1,7 +0,0 @@
1
- import { Database } from "@eliaspourquoi/sqlite-node-wasm";
2
- export declare const importDatabase: ({ db, content, schema, readOnly, }: {
3
- db: Database;
4
- content: Uint8Array;
5
- schema?: string;
6
- readOnly?: boolean;
7
- }) => Database;
@@ -1,15 +0,0 @@
1
- import { sqliteModule } from "../kysely/sqliteModule.js";
2
- export const importDatabase = ({ db, content, schema = "main", readOnly = false, }) => {
3
- const deserializeFlag = readOnly
4
- ? sqliteModule.capi.SQLITE_DESERIALIZE_READONLY
5
- : sqliteModule.capi.SQLITE_DESERIALIZE_FREEONCLOSE |
6
- sqliteModule.capi.SQLITE_DESERIALIZE_RESIZEABLE;
7
- const contentPointer = sqliteModule.wasm.allocFromTypedArray(content);
8
- const deserializeReturnCode = sqliteModule.capi.sqlite3_deserialize(db.pointer, schema, contentPointer, content.byteLength, // db size
9
- content.byteLength, // content size
10
- deserializeFlag);
11
- // check if the deserialization was successfull
12
- db.checkRc(deserializeReturnCode);
13
- return db;
14
- };
15
- //# sourceMappingURL=importDatabase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importDatabase.js","sourceRoot":"","sources":["../../src/util/importDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,EAAE,EACF,OAAO,EACP,MAAM,GAAG,MAAM,EACf,QAAQ,GAAG,KAAK,GAMjB,EAAE,EAAE;IACH,MAAM,eAAe,GAAG,QAAQ;QAC9B,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,2BAA2B;QAC/C,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,8BAA8B;YAChD,YAAY,CAAC,IAAI,CAAC,6BAA6B,CAAC;IAEpD,MAAM,cAAc,GAAG,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtE,MAAM,qBAAqB,GAAG,YAAY,CAAC,IAAI,CAAC,mBAAmB,CACjE,EAAE,CAAC,OAAQ,EACX,MAAM,EACN,cAAc,EACd,OAAO,CAAC,UAAU,EAAE,UAAU;IAC9B,OAAO,CAAC,UAAU,EAAE,eAAe;IACnC,eAAe,CAChB,CAAC;IAEF,+CAA+C;IAC/C,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAElC,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- export { contentFromDatabase } from "./contentFromDatabase.js";
2
- export { createInMemoryDatabase } from "./createInMemoryDatabase.js";
3
- export { importDatabase } from "./importDatabase.js";
4
- export type { Database as SqliteDatabase } from "@eliaspourquoi/sqlite-node-wasm";
5
- export { loadDatabaseInMemory } from "./loadDatabaseInMemory.js";
@@ -1,5 +0,0 @@
1
- export { contentFromDatabase } from "./contentFromDatabase.js";
2
- export { createInMemoryDatabase } from "./createInMemoryDatabase.js";
3
- export { importDatabase } from "./importDatabase.js";
4
- export { loadDatabaseInMemory } from "./loadDatabaseInMemory.js";
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -1 +0,0 @@
1
- export declare function loadDatabaseInMemory(data: ArrayBuffer): Promise<import("@eliaspourquoi/sqlite-node-wasm").Database>;
@@ -1,13 +0,0 @@
1
- import { createInMemoryDatabase } from "./createInMemoryDatabase.js";
2
- import { importDatabase } from "./importDatabase.js";
3
- export async function loadDatabaseInMemory(data) {
4
- const database = await createInMemoryDatabase({
5
- readOnly: false,
6
- });
7
- importDatabase({
8
- db: database,
9
- content: new Uint8Array(data),
10
- });
11
- return database;
12
- }
13
- //# sourceMappingURL=loadDatabaseInMemory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadDatabaseInMemory.js","sourceRoot":"","sources":["../../src/util/loadDatabaseInMemory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAiB;IAC1D,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC;QAC5C,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IACH,cAAc,CAAC;QACb,EAAE,EAAE,QAAQ;QACZ,OAAO,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC;KAC9B,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Resolving the sqlite wasm dynamically recurringly breaks
3
- * in different environments (node, browser, vitest).
4
- *
5
- * To ease development, the wasm binary is bundled (for now).
6
- */
7
- export declare const wasmBinary: ArrayBufferLike;