@lix-js/sdk 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/account/database-schema.d.ts.map +1 -1
- package/dist/account/database-schema.js +2 -6
- package/dist/account/database-schema.js.map +1 -1
- package/dist/account/database-schema.test.js +4 -8
- package/dist/account/database-schema.test.js.map +1 -1
- package/dist/change/apply-changes.js +9 -9
- package/dist/change/apply-changes.js.map +1 -1
- package/dist/change/apply-changes.test.js +5 -5
- package/dist/change/apply-changes.test.js.map +1 -1
- package/dist/database/apply-schema.d.ts.map +1 -1
- package/dist/database/apply-schema.js +20 -72
- package/dist/database/apply-schema.js.map +1 -1
- package/dist/database/execute-sync.test.js +3 -3
- package/dist/database/execute-sync.test.js.map +1 -1
- package/dist/database/init-db.d.ts.map +1 -1
- package/dist/database/init-db.js +18 -3
- package/dist/database/init-db.js.map +1 -1
- package/dist/database/init-db.test.js +128 -17
- package/dist/database/init-db.test.js.map +1 -1
- package/dist/database/kysely-plugin/parse-jsonb-plugin-v1.d.ts.map +1 -1
- package/dist/database/kysely-plugin/parse-jsonb-plugin-v1.js +5 -2
- package/dist/database/kysely-plugin/parse-jsonb-plugin-v1.js.map +1 -1
- package/dist/database/mutation-log/database-schema.d.ts.map +1 -1
- package/dist/database/mutation-log/database-schema.js +1 -3
- package/dist/database/mutation-log/database-schema.js.map +1 -1
- package/dist/database/nano-id.d.ts +21 -0
- package/dist/database/nano-id.d.ts.map +1 -0
- package/dist/database/nano-id.js +58 -0
- package/dist/database/nano-id.js.map +1 -0
- package/dist/database/nano-id.test.d.ts +2 -0
- package/dist/database/nano-id.test.d.ts.map +1 -0
- package/dist/database/nano-id.test.js +13 -0
- package/dist/database/nano-id.test.js.map +1 -0
- package/dist/database/schema.d.ts +15 -23
- package/dist/database/schema.d.ts.map +1 -1
- package/dist/discussion/create-comment.d.ts +0 -2
- package/dist/discussion/create-comment.d.ts.map +1 -1
- package/dist/discussion/create-comment.js +0 -1
- package/dist/discussion/create-comment.js.map +1 -1
- package/dist/discussion/create-discussion.d.ts +3 -5
- package/dist/discussion/create-discussion.d.ts.map +1 -1
- package/dist/discussion/create-discussion.js +4 -5
- package/dist/discussion/create-discussion.js.map +1 -1
- package/dist/discussion/create-discussion.test.js +8 -34
- package/dist/discussion/create-discussion.test.js.map +1 -1
- package/dist/file-queue/file-handlers.d.ts +24 -0
- package/dist/file-queue/file-handlers.d.ts.map +1 -0
- package/dist/file-queue/file-handlers.js +209 -0
- package/dist/file-queue/file-handlers.js.map +1 -0
- package/dist/file-queue/file-queue-process.d.ts +5 -0
- package/dist/file-queue/file-queue-process.d.ts.map +1 -0
- package/dist/file-queue/file-queue-process.js +88 -0
- package/dist/file-queue/file-queue-process.js.map +1 -0
- package/dist/file-queue/file-queue-process.test.d.ts +2 -0
- package/dist/file-queue/file-queue-process.test.d.ts.map +1 -0
- package/dist/file-queue/file-queue-process.test.js +372 -0
- package/dist/file-queue/file-queue-process.test.js.map +1 -0
- package/dist/file-queue/file-queue-settled.d.ts +13 -0
- package/dist/file-queue/file-queue-settled.d.ts.map +1 -0
- package/dist/file-queue/file-queue-settled.js +25 -0
- package/dist/file-queue/file-queue-settled.js.map +1 -0
- package/dist/file-queue/file-queue-settled.test.d.ts +2 -0
- package/dist/file-queue/file-queue-settled.test.d.ts.map +1 -0
- package/dist/file-queue/file-queue-settled.test.js +47 -0
- package/dist/file-queue/file-queue-settled.test.js.map +1 -0
- package/dist/file-queue/index.d.ts +2 -0
- package/dist/file-queue/index.d.ts.map +1 -0
- package/dist/file-queue/index.js +2 -0
- package/dist/file-queue/index.js.map +1 -0
- package/dist/file-queue/with-skip-file-queue.d.ts +3 -0
- package/dist/file-queue/with-skip-file-queue.d.ts.map +1 -0
- package/dist/file-queue/with-skip-file-queue.js +26 -0
- package/dist/file-queue/with-skip-file-queue.js.map +1 -0
- package/dist/file-queue/with-skip-file-queue.test.d.ts +2 -0
- package/dist/file-queue/with-skip-file-queue.test.d.ts.map +1 -0
- package/dist/file-queue/with-skip-file-queue.test.js +138 -0
- package/dist/file-queue/with-skip-file-queue.test.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/key-value/database-schema.d.ts +11 -2
- package/dist/key-value/database-schema.d.ts.map +1 -1
- package/dist/key-value/database-schema.js +7 -4
- package/dist/key-value/database-schema.js.map +1 -1
- package/dist/key-value/database-schema.test.js +21 -5
- package/dist/key-value/database-schema.test.js.map +1 -1
- package/dist/lix/close-lix.d.ts +8 -0
- package/dist/lix/close-lix.d.ts.map +1 -0
- package/dist/lix/close-lix.js +7 -0
- package/dist/lix/close-lix.js.map +1 -0
- package/dist/lix/index.d.ts +1 -0
- package/dist/lix/index.d.ts.map +1 -1
- package/dist/lix/index.js +1 -0
- package/dist/lix/index.js.map +1 -1
- package/dist/lix/merge.js +3 -3
- package/dist/lix/merge.js.map +1 -1
- package/dist/lix/merge.test.js +7 -18
- package/dist/lix/merge.test.js.map +1 -1
- package/dist/lix/new-lix.d.ts.map +1 -1
- package/dist/lix/new-lix.js +2 -3
- package/dist/lix/new-lix.js.map +1 -1
- package/dist/lix/open-lix-in-memory.test.js +2 -1
- package/dist/lix/open-lix-in-memory.test.js.map +1 -1
- package/dist/lix/open-lix.d.ts +19 -6
- package/dist/lix/open-lix.d.ts.map +1 -1
- package/dist/lix/open-lix.js +80 -18
- package/dist/lix/open-lix.js.map +1 -1
- package/dist/lix/open-lix.test.js +70 -7
- package/dist/lix/open-lix.test.js.map +1 -1
- package/dist/lix/to-blob.d.ts +11 -0
- package/dist/lix/to-blob.d.ts.map +1 -0
- package/dist/lix/to-blob.js +11 -0
- package/dist/lix/to-blob.js.map +1 -0
- package/dist/own-change-control/apply-own-change.d.ts +10 -0
- package/dist/own-change-control/apply-own-change.d.ts.map +1 -0
- package/dist/own-change-control/apply-own-change.js +69 -0
- package/dist/own-change-control/apply-own-change.js.map +1 -0
- package/dist/own-change-control/apply-own-change.test.d.ts +2 -0
- package/dist/own-change-control/apply-own-change.test.d.ts.map +1 -0
- package/dist/own-change-control/apply-own-change.test.js +297 -0
- package/dist/own-change-control/apply-own-change.test.js.map +1 -0
- package/dist/own-change-control/change-controlled-tables.d.ts +60 -0
- package/dist/own-change-control/change-controlled-tables.d.ts.map +1 -0
- package/dist/own-change-control/change-controlled-tables.js +70 -0
- package/dist/own-change-control/change-controlled-tables.js.map +1 -0
- package/dist/own-change-control/change-controlled-tables.test.d.ts +2 -0
- package/dist/own-change-control/change-controlled-tables.test.d.ts.map +1 -0
- package/dist/own-change-control/change-controlled-tables.test.js +48 -0
- package/dist/own-change-control/change-controlled-tables.test.js.map +1 -0
- package/dist/own-change-control/database-triggers.d.ts +5 -0
- package/dist/own-change-control/database-triggers.d.ts.map +1 -0
- package/dist/own-change-control/database-triggers.js +135 -0
- package/dist/own-change-control/database-triggers.js.map +1 -0
- package/dist/own-change-control/database-triggers.test.d.ts +2 -0
- package/dist/own-change-control/database-triggers.test.d.ts.map +1 -0
- package/dist/own-change-control/database-triggers.test.js +214 -0
- package/dist/own-change-control/database-triggers.test.js.map +1 -0
- package/dist/own-change-control/index.d.ts +2 -0
- package/dist/own-change-control/index.d.ts.map +1 -0
- package/dist/own-change-control/index.js +2 -0
- package/dist/own-change-control/index.js.map +1 -0
- package/dist/own-change-control/with-skip-own-change-control.d.ts +3 -0
- package/dist/own-change-control/with-skip-own-change-control.d.ts.map +1 -0
- package/dist/own-change-control/with-skip-own-change-control.js +28 -0
- package/dist/own-change-control/with-skip-own-change-control.js.map +1 -0
- package/dist/own-change-control/with-skip-own-change-control.test.d.ts +2 -0
- package/dist/own-change-control/with-skip-own-change-control.test.d.ts.map +1 -0
- package/dist/own-change-control/with-skip-own-change-control.test.js +49 -0
- package/dist/own-change-control/with-skip-own-change-control.test.js.map +1 -0
- package/dist/own-entity-change-control/apply-own-entity-change.js +2 -2
- package/dist/own-entity-change-control/apply-own-entity-change.js.map +1 -1
- package/dist/own-entity-change-control/apply-own-entity-change.test.js +9 -9
- package/dist/own-entity-change-control/apply-own-entity-change.test.js.map +1 -1
- package/dist/own-entity-change-control/database-triggers.js +6 -6
- package/dist/own-entity-change-control/database-triggers.js.map +1 -1
- package/dist/own-entity-change-control/database-triggers.test.js +1 -1
- package/dist/own-entity-change-control/database-triggers.test.js.map +1 -1
- package/dist/query-filter/version-change-in-difference.test.js +37 -29
- package/dist/query-filter/version-change-in-difference.test.js.map +1 -1
- package/dist/query-filter/version-change-in-symmetric-difference.test.js +37 -39
- package/dist/query-filter/version-change-in-symmetric-difference.test.js.map +1 -1
- package/dist/server-api-handler/environment/create-in-memory-environment.d.ts.map +1 -1
- package/dist/server-api-handler/environment/create-in-memory-environment.js +7 -3
- package/dist/server-api-handler/environment/create-in-memory-environment.js.map +1 -1
- package/dist/server-api-handler/environment/create-in-memory-environment.test.js +8 -7
- package/dist/server-api-handler/environment/create-in-memory-environment.test.js.map +1 -1
- package/dist/server-api-handler/routes/get-v1.d.ts.map +1 -1
- package/dist/server-api-handler/routes/get-v1.js +1 -2
- package/dist/server-api-handler/routes/get-v1.js.map +1 -1
- package/dist/server-api-handler/routes/get-v1.test.js +6 -5
- package/dist/server-api-handler/routes/get-v1.test.js.map +1 -1
- package/dist/server-api-handler/routes/new-v1.d.ts.map +1 -1
- package/dist/server-api-handler/routes/new-v1.js +3 -1
- package/dist/server-api-handler/routes/new-v1.js.map +1 -1
- package/dist/server-api-handler/routes/new-v1.test.js +2 -1
- package/dist/server-api-handler/routes/new-v1.test.js.map +1 -1
- package/dist/server-api-handler/routes/pull-v1.test.js +4 -3
- package/dist/server-api-handler/routes/pull-v1.test.js.map +1 -1
- package/dist/server-api-handler/routes/push-v1.test.js +5 -4
- package/dist/server-api-handler/routes/push-v1.test.js.map +1 -1
- package/dist/services/env-variables/index.d.ts +5 -0
- package/dist/services/env-variables/index.d.ts.map +1 -0
- package/dist/services/env-variables/index.js +5 -0
- package/dist/services/env-variables/index.js.map +1 -0
- package/dist/services/telemetry/capture.d.ts +30 -0
- package/dist/services/telemetry/capture.d.ts.map +1 -0
- package/dist/services/telemetry/capture.js +71 -0
- package/dist/services/telemetry/capture.js.map +1 -0
- package/dist/services/telemetry/capture.test.d.ts +2 -0
- package/dist/services/telemetry/capture.test.d.ts.map +1 -0
- package/dist/services/telemetry/capture.test.js +37 -0
- package/dist/services/telemetry/capture.test.js.map +1 -0
- package/dist/sync/pull-from-server.d.ts.map +1 -1
- package/dist/sync/pull-from-server.js +0 -2
- package/dist/sync/pull-from-server.js.map +1 -1
- package/dist/sync/pull-from-server.test.js +29 -14
- package/dist/sync/pull-from-server.test.js.map +1 -1
- package/dist/sync/push-to-server.test.js +17 -13
- package/dist/sync/push-to-server.test.js.map +1 -1
- package/dist/sync/sync-process.d.ts +2 -4
- package/dist/sync/sync-process.d.ts.map +1 -1
- package/dist/sync/sync-process.js +14 -13
- package/dist/sync/sync-process.js.map +1 -1
- package/dist/sync/sync-process.test.js +26 -38
- package/dist/sync/sync-process.test.js.map +1 -1
- package/dist/version/create-version.d.ts +5 -5
- package/dist/version/create-version.d.ts.map +1 -1
- package/dist/version/create-version.js +23 -11
- package/dist/version/create-version.js.map +1 -1
- package/dist/version/create-version.test.js +2 -2
- package/dist/version/create-version.test.js.map +1 -1
- package/dist/version/merge-version.d.ts.map +1 -1
- package/dist/version/merge-version.js +16 -26
- package/dist/version/merge-version.js.map +1 -1
- package/dist/version/switch-version.js +3 -3
- package/dist/version/switch-version.js.map +1 -1
- package/dist/version/switch-version.test.js +12 -15
- package/dist/version/switch-version.test.js.map +1 -1
- package/dist/version/update-changes-in-version.d.ts.map +1 -1
- package/dist/version/update-changes-in-version.js +11 -31
- package/dist/version/update-changes-in-version.js.map +1 -1
- package/package.json +7 -9
- package/src/account/database-schema.test.ts +6 -9
- package/src/account/database-schema.ts +2 -6
- package/src/change/apply-changes.test.ts +7 -7
- package/src/change/apply-changes.ts +9 -9
- package/src/database/apply-schema.ts +20 -73
- package/src/database/execute-sync.test.ts +3 -3
- package/src/database/init-db.test.ts +163 -19
- package/src/database/init-db.ts +20 -3
- package/src/database/kysely-plugin/parse-jsonb-plugin-v1.ts +9 -2
- package/src/database/mutation-log/database-schema.ts +1 -3
- package/src/database/nano-id.test.ts +15 -0
- package/src/database/nano-id.ts +72 -0
- package/src/database/schema.ts +15 -24
- package/src/discussion/create-comment.ts +0 -3
- package/src/discussion/create-discussion.test.ts +8 -39
- package/src/discussion/create-discussion.ts +6 -9
- package/src/{change-queue → file-queue}/file-handlers.ts +27 -27
- package/src/{change-queue/init-change-queue.test.ts → file-queue/file-queue-process.test.ts} +28 -29
- package/src/{change-queue/init-change-queue.ts → file-queue/file-queue-process.ts} +21 -16
- package/src/{change-queue/change-queue-settled.test.ts → file-queue/file-queue-settled.test.ts} +12 -12
- package/src/{change-queue/change-queue-settled.ts → file-queue/file-queue-settled.ts} +4 -4
- package/src/file-queue/index.ts +1 -0
- package/src/{change-queue/with-skip-change-queue.test.ts → file-queue/with-skip-file-queue.test.ts} +9 -9
- package/src/{change-queue/with-skip-change-queue.ts → file-queue/with-skip-file-queue.ts} +3 -3
- package/src/index.ts +2 -2
- package/src/key-value/database-schema.test.ts +26 -5
- package/src/key-value/database-schema.ts +18 -6
- package/src/lix/close-lix.ts +8 -0
- package/src/lix/index.ts +1 -0
- package/src/lix/merge.test.ts +7 -19
- package/src/lix/merge.ts +4 -4
- package/src/lix/new-lix.ts +2 -3
- package/src/lix/open-lix-in-memory.test.ts +5 -1
- package/src/lix/open-lix.test.ts +82 -7
- package/src/lix/open-lix.ts +104 -24
- package/src/lix/to-blob.ts +14 -0
- package/src/{own-entity-change-control/apply-own-entity-change.test.ts → own-change-control/apply-own-change.test.ts} +27 -31
- package/src/{own-entity-change-control/apply-own-entity-change.ts → own-change-control/apply-own-change.ts} +3 -3
- package/src/{own-entity-change-control → own-change-control}/change-controlled-tables.ts +0 -1
- package/src/{own-entity-change-control → own-change-control}/database-triggers.test.ts +7 -7
- package/src/{own-entity-change-control → own-change-control}/database-triggers.ts +11 -11
- package/src/{own-entity-change-control → own-change-control}/with-skip-own-change-control.ts +6 -2
- package/src/query-filter/version-change-in-difference.test.ts +41 -32
- package/src/query-filter/version-change-in-symmetric-difference.test.ts +41 -42
- package/src/server-api-handler/environment/create-in-memory-environment.test.ts +8 -7
- package/src/server-api-handler/environment/create-in-memory-environment.ts +7 -3
- package/src/server-api-handler/routes/get-v1.test.ts +6 -5
- package/src/server-api-handler/routes/get-v1.ts +1 -3
- package/src/server-api-handler/routes/new-v1.test.ts +2 -1
- package/src/server-api-handler/routes/new-v1.ts +3 -1
- package/src/server-api-handler/routes/pull-v1.test.ts +4 -3
- package/src/server-api-handler/routes/push-v1.test.ts +5 -4
- package/src/services/env-variables/create-index-file.js +35 -0
- package/src/services/env-variables/index.d.ts +15 -0
- package/src/services/telemetry/capture.test.ts +44 -0
- package/src/services/telemetry/capture.ts +99 -0
- package/src/sync/pull-from-server.test.ts +29 -14
- package/src/sync/pull-from-server.ts +0 -2
- package/src/sync/push-to-server.test.ts +19 -15
- package/src/sync/sync-process.test.ts +37 -43
- package/src/sync/sync-process.ts +16 -23
- package/src/version/create-version.test.ts +2 -2
- package/src/version/create-version.ts +24 -12
- package/src/version/merge-version.ts +18 -26
- package/src/version/switch-version.test.ts +12 -15
- package/src/version/switch-version.ts +3 -3
- package/src/version/update-changes-in-version.ts +11 -30
- package/node_modules/@lix-js/server-api-schema/.prettierrc.json +0 -3
- package/node_modules/@lix-js/server-api-schema/.vscode/extensions.json +0 -3
- package/node_modules/@lix-js/server-api-schema/dist/schema.d.ts +0 -384
- package/node_modules/@lix-js/server-api-schema/package.json +0 -21
- package/node_modules/@lix-js/server-api-schema/src/schema.yaml +0 -290
- package/node_modules/@lix-js/server-api-schema/tsconfig.json +0 -20
- package/node_modules/sqlite-wasm-kysely/README.md +0 -11
- package/node_modules/sqlite-wasm-kysely/dist/dialect.d.ts +0 -11
- package/node_modules/sqlite-wasm-kysely/dist/dialect.js +0 -13
- package/node_modules/sqlite-wasm-kysely/dist/dialect.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/index.d.ts +0 -2
- package/node_modules/sqlite-wasm-kysely/dist/index.js +0 -3
- package/node_modules/sqlite-wasm-kysely/dist/index.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/kysely/ConnectionMutex.d.ts +0 -5
- package/node_modules/sqlite-wasm-kysely/dist/kysely/ConnectionMutex.js +0 -34
- package/node_modules/sqlite-wasm-kysely/dist/kysely/ConnectionMutex.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmConnection.d.ts +0 -8
- package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmConnection.js +0 -57
- package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmConnection.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDialectConfig.d.ts +0 -18
- package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDialectConfig.js +0 -2
- package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDialectConfig.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDriver.d.ts +0 -13
- package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDriver.js +0 -57
- package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDriver.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/kysely/index.d.ts +0 -4
- package/node_modules/sqlite-wasm-kysely/dist/kysely/index.js +0 -4
- package/node_modules/sqlite-wasm-kysely/dist/kysely/index.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/kysely/sqliteModule.d.ts +0 -3
- package/node_modules/sqlite-wasm-kysely/dist/kysely/sqliteModule.js +0 -5
- package/node_modules/sqlite-wasm-kysely/dist/kysely/sqliteModule.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/util/contentFromDatabase.d.ts +0 -9
- package/node_modules/sqlite-wasm-kysely/dist/util/contentFromDatabase.js +0 -12
- package/node_modules/sqlite-wasm-kysely/dist/util/contentFromDatabase.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/util/createInMemoryDatabase.d.ts +0 -3
- package/node_modules/sqlite-wasm-kysely/dist/util/createInMemoryDatabase.js +0 -22
- package/node_modules/sqlite-wasm-kysely/dist/util/createInMemoryDatabase.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/util/importDatabase.d.ts +0 -7
- package/node_modules/sqlite-wasm-kysely/dist/util/importDatabase.js +0 -15
- package/node_modules/sqlite-wasm-kysely/dist/util/importDatabase.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/util/index.d.ts +0 -5
- package/node_modules/sqlite-wasm-kysely/dist/util/index.js +0 -5
- package/node_modules/sqlite-wasm-kysely/dist/util/index.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/util/loadDatabaseInMemory.d.ts +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/util/loadDatabaseInMemory.js +0 -13
- package/node_modules/sqlite-wasm-kysely/dist/util/loadDatabaseInMemory.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/dist/util/sqliteWasmBinary.d.ts +0 -7
- package/node_modules/sqlite-wasm-kysely/dist/util/sqliteWasmBinary.js +0 -17
- package/node_modules/sqlite-wasm-kysely/dist/util/sqliteWasmBinary.js.map +0 -1
- package/node_modules/sqlite-wasm-kysely/package.json +0 -34
- package/node_modules/sqlite-wasm-kysely/src/dialect.ts +0 -15
- package/node_modules/sqlite-wasm-kysely/src/index.ts +0 -2
- package/node_modules/sqlite-wasm-kysely/src/kysely/ConnectionMutex.ts +0 -23
- package/node_modules/sqlite-wasm-kysely/src/kysely/SqliteWasmConnection.ts +0 -57
- package/node_modules/sqlite-wasm-kysely/src/kysely/SqliteWasmDialectConfig.ts +0 -19
- package/node_modules/sqlite-wasm-kysely/src/kysely/SqliteWasmDriver.ts +0 -58
- package/node_modules/sqlite-wasm-kysely/src/kysely/index.ts +0 -4
- package/node_modules/sqlite-wasm-kysely/src/kysely/sqliteModule.ts +0 -7
- package/node_modules/sqlite-wasm-kysely/src/util/contentFromDatabase.ts +0 -13
- package/node_modules/sqlite-wasm-kysely/src/util/createInMemoryDatabase.ts +0 -30
- package/node_modules/sqlite-wasm-kysely/src/util/importDatabase.ts +0 -34
- package/node_modules/sqlite-wasm-kysely/src/util/index.ts +0 -5
- package/node_modules/sqlite-wasm-kysely/src/util/loadDatabaseInMemory.ts +0 -13
- package/node_modules/sqlite-wasm-kysely/src/util/sqliteWasmBinary.ts +0 -20
- package/src/change-queue/index.ts +0 -1
- /package/src/{own-entity-change-control → own-change-control}/change-controlled-tables.test.ts +0 -0
- /package/src/{own-entity-change-control → own-change-control}/index.ts +0 -0
- /package/src/{own-entity-change-control → own-change-control}/with-skip-own-change-control.test.ts +0 -0
|
@@ -4,6 +4,7 @@ import type { VersionChange } from "../database/schema.js";
|
|
|
4
4
|
import { mockChange } from "../change/mock-change.js";
|
|
5
5
|
import { createVersion } from "../version/create-version.js";
|
|
6
6
|
import { versionChangeInDifference } from "./version-change-in-difference.js";
|
|
7
|
+
import { updateChangesInVersion } from "../version/update-changes-in-version.js";
|
|
7
8
|
|
|
8
9
|
test("should return the difference between two versions", async () => {
|
|
9
10
|
const lix = await openLixInMemory({});
|
|
@@ -11,42 +12,42 @@ test("should return the difference between two versions", async () => {
|
|
|
11
12
|
const versionA = await createVersion({ lix });
|
|
12
13
|
const versionB = await createVersion({ lix });
|
|
13
14
|
|
|
15
|
+
const mockChanges = [
|
|
16
|
+
mockChange({ id: "change0", entity_id: "entity0" }),
|
|
17
|
+
mockChange({ id: "change1", entity_id: "entity1" }),
|
|
18
|
+
mockChange({ id: "change2", entity_id: "entity2" }),
|
|
19
|
+
mockChange({ id: "change3", entity_id: "entity3" }),
|
|
20
|
+
] as const;
|
|
21
|
+
|
|
14
22
|
await lix.db
|
|
15
23
|
.insertInto("change")
|
|
16
|
-
.values(
|
|
17
|
-
mockChange({ id: "change1" }),
|
|
18
|
-
mockChange({ id: "change2" }),
|
|
19
|
-
mockChange({ id: "change3" }),
|
|
20
|
-
mockChange({ id: "change4" }),
|
|
21
|
-
])
|
|
24
|
+
.values(mockChanges)
|
|
22
25
|
.returningAll()
|
|
23
26
|
.execute();
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const changesB: VersionChange[] = [
|
|
31
|
-
{ version_id: versionB.id, change_id: "change2" },
|
|
32
|
-
{ version_id: versionB.id, change_id: "change3" },
|
|
33
|
-
];
|
|
28
|
+
await updateChangesInVersion({
|
|
29
|
+
lix,
|
|
30
|
+
version: versionA,
|
|
31
|
+
changes: [mockChanges[0], mockChanges[1]],
|
|
32
|
+
});
|
|
34
33
|
|
|
35
|
-
await
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
await updateChangesInVersion({
|
|
35
|
+
lix,
|
|
36
|
+
version: versionB,
|
|
37
|
+
changes: [mockChanges[1], mockChanges[2]],
|
|
38
|
+
});
|
|
39
39
|
|
|
40
40
|
const result = await lix.db
|
|
41
41
|
.selectFrom("version_change")
|
|
42
42
|
.where(versionChangeInDifference(versionA, versionB))
|
|
43
|
-
.
|
|
43
|
+
.select("version_id")
|
|
44
|
+
.select("change_id")
|
|
44
45
|
.execute();
|
|
45
46
|
|
|
46
47
|
expect(result).toEqual([
|
|
47
|
-
//
|
|
48
|
-
{ version_id: versionA.id, change_id: "
|
|
49
|
-
] satisfies VersionChange[]);
|
|
48
|
+
// change0 is in A but not in B
|
|
49
|
+
expect.objectContaining({ version_id: versionA.id, change_id: "change0" }),
|
|
50
|
+
] satisfies Partial<VersionChange>[]);
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
test("should return an empty array if there are no differences", async () => {
|
|
@@ -55,20 +56,28 @@ test("should return an empty array if there are no differences", async () => {
|
|
|
55
56
|
const versionA = await createVersion({ lix });
|
|
56
57
|
const versionB = await createVersion({ lix });
|
|
57
58
|
|
|
59
|
+
const mockChanges = [
|
|
60
|
+
mockChange({ id: "change0" }),
|
|
61
|
+
mockChange({ id: "change1" }),
|
|
62
|
+
];
|
|
63
|
+
|
|
58
64
|
await lix.db
|
|
59
65
|
.insertInto("change")
|
|
60
|
-
.values(
|
|
66
|
+
.values(mockChanges)
|
|
61
67
|
.returningAll()
|
|
62
68
|
.execute();
|
|
63
69
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
await updateChangesInVersion({
|
|
71
|
+
lix,
|
|
72
|
+
version: versionA,
|
|
73
|
+
changes: mockChanges,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
await updateChangesInVersion({
|
|
77
|
+
lix,
|
|
78
|
+
version: versionB,
|
|
79
|
+
changes: mockChanges,
|
|
80
|
+
});
|
|
72
81
|
|
|
73
82
|
const result = await lix.db
|
|
74
83
|
.selectFrom("version_change")
|
|
@@ -4,6 +4,7 @@ import type { VersionChange } from "../database/schema.js";
|
|
|
4
4
|
import { mockChange } from "../change/mock-change.js";
|
|
5
5
|
import { createVersion } from "../version/create-version.js";
|
|
6
6
|
import { versionChangeInSymmetricDifference } from "./version-change-in-symmetric-difference.js";
|
|
7
|
+
import { updateChangesInVersion } from "../version/update-changes-in-version.js";
|
|
7
8
|
|
|
8
9
|
test("should return the symmetric difference between two versions", async () => {
|
|
9
10
|
const lix = await openLixInMemory({});
|
|
@@ -11,31 +12,26 @@ test("should return the symmetric difference between two versions", async () =>
|
|
|
11
12
|
const versionA = await createVersion({ lix });
|
|
12
13
|
const versionB = await createVersion({ lix });
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
mockChange({ id: "change4" }),
|
|
21
|
-
])
|
|
22
|
-
.returningAll()
|
|
23
|
-
.execute();
|
|
15
|
+
const mockChanges = [
|
|
16
|
+
mockChange({ id: "change0", entity_id: "entity0" }),
|
|
17
|
+
mockChange({ id: "change1", entity_id: "entity1" }),
|
|
18
|
+
mockChange({ id: "change2", entity_id: "entity2" }),
|
|
19
|
+
mockChange({ id: "change3", entity_id: "entity3" }),
|
|
20
|
+
] as const;
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
{ version_id: versionA.id, change_id: "change1" },
|
|
27
|
-
{ version_id: versionA.id, change_id: "change2" },
|
|
28
|
-
];
|
|
22
|
+
await lix.db.insertInto("change").values(mockChanges).execute();
|
|
29
23
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
await updateChangesInVersion({
|
|
25
|
+
lix,
|
|
26
|
+
version: versionA,
|
|
27
|
+
changes: [mockChanges[0], mockChanges[1]],
|
|
28
|
+
});
|
|
34
29
|
|
|
35
|
-
await
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
await updateChangesInVersion({
|
|
31
|
+
lix,
|
|
32
|
+
version: versionB,
|
|
33
|
+
changes: [mockChanges[1], mockChanges[2]],
|
|
34
|
+
});
|
|
39
35
|
|
|
40
36
|
const result = await lix.db
|
|
41
37
|
.selectFrom("version_change")
|
|
@@ -44,13 +40,13 @@ test("should return the symmetric difference between two versions", async () =>
|
|
|
44
40
|
.execute();
|
|
45
41
|
|
|
46
42
|
expect(result).toEqual([
|
|
47
|
-
// change
|
|
48
|
-
{ version_id: versionA.id, change_id: "
|
|
49
|
-
// change
|
|
50
|
-
{ version_id: versionB.id, change_id: "
|
|
51
|
-
// change
|
|
43
|
+
// change 0 is in A but not in B
|
|
44
|
+
expect.objectContaining({ version_id: versionA.id, change_id: "change0" }),
|
|
45
|
+
// change 2 is in B but not in A
|
|
46
|
+
expect.objectContaining({ version_id: versionB.id, change_id: "change2" }),
|
|
47
|
+
// change 3 is in neither A nor B
|
|
52
48
|
// hence not in the symmetric difference
|
|
53
|
-
] satisfies VersionChange[]);
|
|
49
|
+
] satisfies Partial<VersionChange>[]);
|
|
54
50
|
});
|
|
55
51
|
|
|
56
52
|
test("should return an empty array if there are no differences", async () => {
|
|
@@ -59,25 +55,28 @@ test("should return an empty array if there are no differences", async () => {
|
|
|
59
55
|
const versionA = await createVersion({ lix });
|
|
60
56
|
const versionB = await createVersion({ lix });
|
|
61
57
|
|
|
58
|
+
const mockChanges = [
|
|
59
|
+
mockChange({ id: "change0", entity_id: "entity0" }),
|
|
60
|
+
mockChange({ id: "change1", entity_id: "entity1" }),
|
|
61
|
+
] as const;
|
|
62
|
+
|
|
62
63
|
await lix.db
|
|
63
64
|
.insertInto("change")
|
|
64
|
-
.values(
|
|
65
|
-
mockChange({ id: "change1" }),
|
|
66
|
-
mockChange({ id: "change2" }),
|
|
67
|
-
mockChange({ id: "change3" }),
|
|
68
|
-
mockChange({ id: "change4" }),
|
|
69
|
-
])
|
|
65
|
+
.values(mockChanges)
|
|
70
66
|
.returningAll()
|
|
71
67
|
.execute();
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
await updateChangesInVersion({
|
|
70
|
+
lix,
|
|
71
|
+
version: versionA,
|
|
72
|
+
changes: [mockChanges[0], mockChanges[1]],
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await updateChangesInVersion({
|
|
76
|
+
lix,
|
|
77
|
+
version: versionB,
|
|
78
|
+
changes: [mockChanges[0], mockChanges[1]],
|
|
79
|
+
});
|
|
81
80
|
|
|
82
81
|
const result = await lix.db
|
|
83
82
|
.selectFrom("version_change")
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { test, expect } from "vitest";
|
|
2
2
|
import { createLsaInMemoryEnvironment } from "./create-in-memory-environment.js";
|
|
3
3
|
import { openLixInMemory } from "../../lix/open-lix-in-memory.js";
|
|
4
|
+
import { toBlob } from "../../lix/to-blob.js";
|
|
4
5
|
|
|
5
6
|
test("opening a lix works", async () => {
|
|
6
7
|
const environment = createLsaInMemoryEnvironment();
|
|
@@ -14,7 +15,7 @@ test("opening a lix works", async () => {
|
|
|
14
15
|
.executeTakeFirstOrThrow();
|
|
15
16
|
|
|
16
17
|
// initialize the env with the lix file
|
|
17
|
-
environment.setLix({ id: lixId, blob: await
|
|
18
|
+
environment.setLix({ id: lixId, blob: await toBlob({ lix: mockLix }) });
|
|
18
19
|
|
|
19
20
|
const open0 = await environment.openLix({ id: lixId });
|
|
20
21
|
|
|
@@ -24,7 +25,7 @@ test("opening a lix works", async () => {
|
|
|
24
25
|
.returningAll()
|
|
25
26
|
.executeTakeFirstOrThrow();
|
|
26
27
|
|
|
27
|
-
expect(mockInsert).
|
|
28
|
+
expect(mockInsert).toMatchObject({
|
|
28
29
|
key: "foo",
|
|
29
30
|
value: "bar",
|
|
30
31
|
});
|
|
@@ -44,7 +45,7 @@ test("opening a lix works", async () => {
|
|
|
44
45
|
.selectAll()
|
|
45
46
|
.executeTakeFirstOrThrow();
|
|
46
47
|
|
|
47
|
-
expect(mockSelect).
|
|
48
|
+
expect(mockSelect).toMatchObject({ key: "foo", value: "bar" });
|
|
48
49
|
|
|
49
50
|
await environment.closeLix({ id: lixId, connectionId: open1.connectionId });
|
|
50
51
|
});
|
|
@@ -61,7 +62,7 @@ test("it handles concurrent connections", async () => {
|
|
|
61
62
|
.executeTakeFirstOrThrow();
|
|
62
63
|
|
|
63
64
|
// initialize the env with the lix file
|
|
64
|
-
environment.setLix({ id: lixId, blob: await
|
|
65
|
+
environment.setLix({ id: lixId, blob: await toBlob({ lix: mockLix }) });
|
|
65
66
|
|
|
66
67
|
const open0 = await environment.openLix({ id: lixId });
|
|
67
68
|
const open1 = await environment.openLix({ id: lixId });
|
|
@@ -72,7 +73,7 @@ test("it handles concurrent connections", async () => {
|
|
|
72
73
|
.returningAll()
|
|
73
74
|
.executeTakeFirstOrThrow();
|
|
74
75
|
|
|
75
|
-
expect(mockInsert).
|
|
76
|
+
expect(mockInsert).toMatchObject({
|
|
76
77
|
key: "foo",
|
|
77
78
|
value: "bar",
|
|
78
79
|
});
|
|
@@ -83,7 +84,7 @@ test("it handles concurrent connections", async () => {
|
|
|
83
84
|
.selectAll()
|
|
84
85
|
.executeTakeFirstOrThrow();
|
|
85
86
|
|
|
86
|
-
expect(mockSelect).
|
|
87
|
+
expect(mockSelect).toMatchObject({ key: "foo", value: "bar" });
|
|
87
88
|
|
|
88
89
|
// test both writing at the same time
|
|
89
90
|
|
|
@@ -124,7 +125,7 @@ test("it handles concurrent connections", async () => {
|
|
|
124
125
|
.selectAll()
|
|
125
126
|
.executeTakeFirstOrThrow();
|
|
126
127
|
|
|
127
|
-
expect(mockSelect2).
|
|
128
|
+
expect(mockSelect2).toMatchObject({ key: "foo", value: "bar3" });
|
|
128
129
|
|
|
129
130
|
await environment.closeLix({ id: lixId, connectionId: open2.connectionId });
|
|
130
131
|
});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { fileQueueSettled } from "../../file-queue/file-queue-settled.js";
|
|
2
|
+
import { closeLix } from "../../lix/close-lix.js";
|
|
1
3
|
import { openLixInMemory } from "../../lix/open-lix-in-memory.js";
|
|
2
4
|
import type { Lix } from "../../lix/open-lix.js";
|
|
5
|
+
import { toBlob } from "../../lix/to-blob.js";
|
|
3
6
|
import type { LsaEnvironment } from "./environment.js";
|
|
4
7
|
|
|
5
8
|
/**
|
|
@@ -72,7 +75,7 @@ export const createLsaInMemoryEnvironment = (): LsaEnvironment => {
|
|
|
72
75
|
lix = await openLixInMemory({
|
|
73
76
|
blob,
|
|
74
77
|
// don't sync the server with itself
|
|
75
|
-
keyValues: [{ key: "
|
|
78
|
+
keyValues: [{ key: "lix_sync", value: "false" }],
|
|
76
79
|
});
|
|
77
80
|
|
|
78
81
|
lix.sqlite.exec("PRAGMA foreign_keys = OFF;");
|
|
@@ -100,8 +103,9 @@ export const createLsaInMemoryEnvironment = (): LsaEnvironment => {
|
|
|
100
103
|
if (connections.size === 0) {
|
|
101
104
|
// TODO no concurrency guarantees
|
|
102
105
|
const lix = openLixes.get(args.id);
|
|
103
|
-
|
|
104
|
-
await lix
|
|
106
|
+
await fileQueueSettled({ lix: lix! });
|
|
107
|
+
const blob = await toBlob({ lix: lix! });
|
|
108
|
+
await closeLix({ lix: lix! });
|
|
105
109
|
openConnections.delete(args.id);
|
|
106
110
|
openLixes.delete(args.id);
|
|
107
111
|
store.set(args.id, blob);
|
|
@@ -3,6 +3,7 @@ import { createServerApiHandler } from "../create-server-api-handler.js";
|
|
|
3
3
|
import { newLixFile } from "../../lix/new-lix.js";
|
|
4
4
|
import { openLixInMemory } from "../../lix/open-lix-in-memory.js";
|
|
5
5
|
import { createLsaInMemoryEnvironment } from "../environment/create-in-memory-environment.js";
|
|
6
|
+
import { toBlob } from "../../lix/to-blob.js";
|
|
6
7
|
|
|
7
8
|
test("it should fetch the lix file from the server", async () => {
|
|
8
9
|
const lix = await openLixInMemory({
|
|
@@ -26,7 +27,7 @@ test("it should fetch the lix file from the server", async () => {
|
|
|
26
27
|
await lsaHandler(
|
|
27
28
|
new Request("http://localhost:3000/lsa/new-v1", {
|
|
28
29
|
method: "POST",
|
|
29
|
-
body: await
|
|
30
|
+
body: await toBlob({ lix }),
|
|
30
31
|
})
|
|
31
32
|
);
|
|
32
33
|
|
|
@@ -103,20 +104,20 @@ test("it should return 400 for a request without lix_id", async () => {
|
|
|
103
104
|
expect(responseJson.error).toBe("Missing required field 'lix_id'");
|
|
104
105
|
});
|
|
105
106
|
|
|
106
|
-
test("
|
|
107
|
+
test("lix_sync is set to true", async () => {
|
|
107
108
|
const environment = createLsaInMemoryEnvironment();
|
|
108
109
|
const lsaHandler = await createServerApiHandler({ environment });
|
|
109
110
|
|
|
110
111
|
const lix = await openLixInMemory({
|
|
111
112
|
blob: await newLixFile(),
|
|
112
|
-
keyValues: [{ key: "
|
|
113
|
+
keyValues: [{ key: "lix_sync", value: "false" }],
|
|
113
114
|
});
|
|
114
115
|
|
|
115
116
|
// Store the lix file
|
|
116
117
|
const response0 = await lsaHandler(
|
|
117
118
|
new Request("http://localhost:3000/lsa/new-v1", {
|
|
118
119
|
method: "POST",
|
|
119
|
-
body: await
|
|
120
|
+
body: await toBlob({ lix }),
|
|
120
121
|
})
|
|
121
122
|
);
|
|
122
123
|
|
|
@@ -138,7 +139,7 @@ test("#lix_sync is set to true", async () => {
|
|
|
138
139
|
|
|
139
140
|
const lixSync = await lixFromServer.db
|
|
140
141
|
.selectFrom("key_value")
|
|
141
|
-
.where("key", "=", "
|
|
142
|
+
.where("key", "=", "lix_sync")
|
|
142
143
|
.selectAll()
|
|
143
144
|
.executeTakeFirstOrThrow();
|
|
144
145
|
|
|
@@ -47,12 +47,10 @@ export const route: LixServerApiHandlerRoute = async (context) => {
|
|
|
47
47
|
content: new Uint8Array(await blob!.arrayBuffer()),
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
sqlite.exec("UPDATE key_value SET value = 'true' WHERE key = '
|
|
50
|
+
sqlite.exec("UPDATE key_value SET value = 'true' WHERE key = 'lix_sync'");
|
|
51
51
|
|
|
52
52
|
const blob2 = new Blob([contentFromDatabase(sqlite)]);
|
|
53
53
|
|
|
54
|
-
sqlite.close();
|
|
55
|
-
|
|
56
54
|
return new Response(blob2, {
|
|
57
55
|
status: 200,
|
|
58
56
|
headers: {
|
|
@@ -3,6 +3,7 @@ import { createServerApiHandler } from "../create-server-api-handler.js";
|
|
|
3
3
|
import { newLixFile } from "../../lix/new-lix.js";
|
|
4
4
|
import { openLixInMemory } from "../../lix/open-lix-in-memory.js";
|
|
5
5
|
import { createLsaInMemoryEnvironment } from "../environment/create-in-memory-environment.js";
|
|
6
|
+
import { toBlob } from "../../lix/to-blob.js";
|
|
6
7
|
|
|
7
8
|
test("it should store the lix file", async () => {
|
|
8
9
|
const initLix = await openLixInMemory({
|
|
@@ -22,7 +23,7 @@ test("it should store the lix file", async () => {
|
|
|
22
23
|
const response = await lsaHandler(
|
|
23
24
|
new Request("http://localhost:3000/lsa/new-v1", {
|
|
24
25
|
method: "POST",
|
|
25
|
-
body: await
|
|
26
|
+
body: await toBlob({ lix: initLix }),
|
|
26
27
|
})
|
|
27
28
|
);
|
|
28
29
|
const json = await response.json();
|
|
@@ -11,7 +11,9 @@ export const route: LixServerApiHandlerRoute = async (context) => {
|
|
|
11
11
|
lix = await openLixInMemory({
|
|
12
12
|
blob,
|
|
13
13
|
// turn off sync for server
|
|
14
|
-
keyValues: [
|
|
14
|
+
keyValues: [
|
|
15
|
+
{ key: "lix_sync", value: "false", skip_change_control: true },
|
|
16
|
+
],
|
|
15
17
|
});
|
|
16
18
|
} catch {
|
|
17
19
|
return new Response(null, {
|
|
@@ -5,6 +5,7 @@ import { createServerApiHandler } from "../create-server-api-handler.js";
|
|
|
5
5
|
import { mockJsonSnapshot } from "../../snapshot/mock-json-snapshot.js";
|
|
6
6
|
import { mockChange } from "../../change/mock-change.js";
|
|
7
7
|
import { createLsaInMemoryEnvironment } from "../environment/create-in-memory-environment.js";
|
|
8
|
+
import { toBlob } from "../../lix/to-blob.js";
|
|
8
9
|
|
|
9
10
|
type RequestBody =
|
|
10
11
|
LixServerApi.paths["/lsa/pull-v1"]["post"]["requestBody"]["content"]["application/json"];
|
|
@@ -27,7 +28,7 @@ test("it should pull rows successfully", async () => {
|
|
|
27
28
|
|
|
28
29
|
const environment = createLsaInMemoryEnvironment();
|
|
29
30
|
|
|
30
|
-
await environment.setLix({ id: id.value, blob: await
|
|
31
|
+
await environment.setLix({ id: id.value, blob: await toBlob({ lix }) });
|
|
31
32
|
|
|
32
33
|
const lsaHandler = await createServerApiHandler({ environment });
|
|
33
34
|
|
|
@@ -79,7 +80,7 @@ test("it should specifically be able to handle snapshots which use json binary a
|
|
|
79
80
|
.execute();
|
|
80
81
|
|
|
81
82
|
const environment = createLsaInMemoryEnvironment();
|
|
82
|
-
await environment.setLix({ id, blob: await
|
|
83
|
+
await environment.setLix({ id, blob: await toBlob({ lix }) });
|
|
83
84
|
|
|
84
85
|
const lsa = await createServerApiHandler({ environment });
|
|
85
86
|
|
|
@@ -172,7 +173,7 @@ test("it should handle empty tables gracefully", async () => {
|
|
|
172
173
|
.executeTakeFirstOrThrow();
|
|
173
174
|
|
|
174
175
|
const environment = createLsaInMemoryEnvironment();
|
|
175
|
-
await environment.setLix({ id, blob: await
|
|
176
|
+
await environment.setLix({ id, blob: await toBlob({ lix }) });
|
|
176
177
|
|
|
177
178
|
const lsa = await createServerApiHandler({ environment });
|
|
178
179
|
|
|
@@ -9,6 +9,7 @@ import { createVersion } from "../../version/create-version.js";
|
|
|
9
9
|
import { switchVersion } from "../../version/switch-version.js";
|
|
10
10
|
import { pullFromServer } from "../../sync/pull-from-server.js";
|
|
11
11
|
import { createLsaInMemoryEnvironment } from "../environment/create-in-memory-environment.js";
|
|
12
|
+
import { toBlob } from "../../lix/to-blob.js";
|
|
12
13
|
|
|
13
14
|
test("it should push data successfully", async () => {
|
|
14
15
|
const lix = await openLixInMemory({});
|
|
@@ -19,7 +20,7 @@ test("it should push data successfully", async () => {
|
|
|
19
20
|
.executeTakeFirstOrThrow();
|
|
20
21
|
|
|
21
22
|
const environment = createLsaInMemoryEnvironment();
|
|
22
|
-
await environment.setLix({ id, blob: await
|
|
23
|
+
await environment.setLix({ id, blob: await toBlob({ lix }) });
|
|
23
24
|
|
|
24
25
|
const lsaHandler = await createServerApiHandler({ environment });
|
|
25
26
|
|
|
@@ -130,7 +131,7 @@ test("it should return 400 for a failed insert operation", async () => {
|
|
|
130
131
|
|
|
131
132
|
const environment = createLsaInMemoryEnvironment();
|
|
132
133
|
|
|
133
|
-
environment.setLix({ id, blob: await
|
|
134
|
+
environment.setLix({ id, blob: await toBlob({ lix }) });
|
|
134
135
|
|
|
135
136
|
const lsa = await createServerApiHandler({ environment });
|
|
136
137
|
|
|
@@ -169,7 +170,7 @@ test.skip("it should detect conflicts", async () => {
|
|
|
169
170
|
|
|
170
171
|
// initialize client
|
|
171
172
|
const lixOnClient = await openLixInMemory({
|
|
172
|
-
blob: await
|
|
173
|
+
blob: await toBlob({ lix: lixOnServer }),
|
|
173
174
|
});
|
|
174
175
|
|
|
175
176
|
const lixId = await lixOnServer.db
|
|
@@ -192,7 +193,7 @@ test.skip("it should detect conflicts", async () => {
|
|
|
192
193
|
|
|
193
194
|
await environment.setLix({
|
|
194
195
|
id: lixId.value,
|
|
195
|
-
blob: await
|
|
196
|
+
blob: await toBlob({ lix: lixOnServer }),
|
|
196
197
|
});
|
|
197
198
|
|
|
198
199
|
// client has/creates value1 for mock_key
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
/**
|
|
3
|
+
* This script writes public environment variables
|
|
4
|
+
* to an importable env file.
|
|
5
|
+
*
|
|
6
|
+
* - The SDK must bundle this file with the rest of the SDK
|
|
7
|
+
* - This scripts avoids the need for a bundler
|
|
8
|
+
* - Must be ran before building the SDK
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import fs from "node:fs/promises";
|
|
12
|
+
import url from "node:url";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
|
|
15
|
+
const dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
16
|
+
|
|
17
|
+
const packageJson = JSON.parse(
|
|
18
|
+
await fs.readFile(path.resolve(dirname, "../../../package.json"), "utf-8")
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
await fs.writeFile(
|
|
22
|
+
dirname + "/index.ts",
|
|
23
|
+
`
|
|
24
|
+
export const ENV_VARIABLES = {
|
|
25
|
+
LIX_SDK_POSTHOG_TOKEN: ${ifDefined(process.env.LIX_SDK_POSTHOG_TOKEN)},
|
|
26
|
+
LIX_SDK_VERSION: ${ifDefined(packageJson.version)},
|
|
27
|
+
}
|
|
28
|
+
`
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
// console.log("✅ Created env variable index file.");
|
|
32
|
+
|
|
33
|
+
function ifDefined(value) {
|
|
34
|
+
return value ? `"${value}"` : undefined;
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Avoiding TypeScript errors before the `createIndexFile` script
|
|
3
|
+
* is invoked by defining the type ahead of time.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Env variables that are available at runtime.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ENV_VARIABLES: {
|
|
10
|
+
LIX_SDK_POSTHOG_TOKEN?: string;
|
|
11
|
+
/**
|
|
12
|
+
* As defined in the package.json
|
|
13
|
+
*/
|
|
14
|
+
LIX_SDK_VERSION?: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { expect, test, vi } from "vitest";
|
|
2
|
+
import { capture } from "./capture.js";
|
|
3
|
+
|
|
4
|
+
test("it should not capture if telemetry is off", async () => {
|
|
5
|
+
global.fetch = vi.fn(() => Promise.resolve(new Response()));
|
|
6
|
+
|
|
7
|
+
vi.mock("../env-variables/index.js", async () => {
|
|
8
|
+
return {
|
|
9
|
+
ENV_VARIABLES: {
|
|
10
|
+
LIX_SDK_POSTHOG_TOKEN: "mock-defined",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
await capture("LIX-SDK lix opened", {
|
|
16
|
+
lixId: "test",
|
|
17
|
+
accountId: "test",
|
|
18
|
+
telemetryKeyValue: "off",
|
|
19
|
+
properties: {},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(global.fetch).not.toHaveBeenCalled();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("it should not capture if telemetry is NOT off", async () => {
|
|
26
|
+
global.fetch = vi.fn(() => Promise.resolve(new Response()));
|
|
27
|
+
|
|
28
|
+
vi.mock("../env-variables/index.js", async () => {
|
|
29
|
+
return {
|
|
30
|
+
ENV_VARIABLES: {
|
|
31
|
+
LIX_SDK_POSTHOG_TOKEN: "mock-defined",
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await capture("LIX-SDK lix opened", {
|
|
37
|
+
lixId: "test",
|
|
38
|
+
accountId: "test",
|
|
39
|
+
telemetryKeyValue: "on",
|
|
40
|
+
properties: {},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
44
|
+
});
|