@lix-js/sdk 0.4.6 → 0.4.8

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.
@@ -2,4 +2,5 @@ export { type Lix, openLix } from "./open-lix.js";
2
2
  export { openLixInMemory } from "./open-lix-in-memory.js";
3
3
  export { newLixFile } from "./new-lix.js";
4
4
  export { toBlob } from "./to-blob.js";
5
+ export { closeLix } from "./close-lix.js";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lix/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lix/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/lix/index.js CHANGED
@@ -2,6 +2,7 @@ export { openLix } from "./open-lix.js";
2
2
  export { openLixInMemory } from "./open-lix-in-memory.js";
3
3
  export { newLixFile } from "./new-lix.js";
4
4
  export { toBlob } from "./to-blob.js";
5
+ export { closeLix } from "./close-lix.js";
5
6
  // not exporting merge for api stability milestone
6
7
  // will need an overhaul to be stable
7
8
  // export { merge } from "./merge.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lix/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,kDAAkD;AAClD,qCAAqC;AACrC,sCAAsC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lix/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,kDAAkD;AAClD,qCAAqC;AACrC,sCAAsC"}
@@ -3,8 +3,6 @@ import { initDb } from "../database/init-db.js";
3
3
  import { initFileQueueProcess } from "../file-queue/file-queue-process.js";
4
4
  import { sql } from "kysely";
5
5
  import { initSyncProcess } from "../sync/sync-process.js";
6
- import { capture } from "../services/telemetry/capture.js";
7
- import { ENV_VARIABLES } from "../services/env-variables/index.js";
8
6
  /**
9
7
  * Common setup between different lix environments.
10
8
  */
@@ -37,49 +35,12 @@ export async function openLix(args) {
37
35
  };
38
36
  await initFileQueueProcess({ lix: { db, plugin, sqlite: args.database } });
39
37
  await initSyncProcess({ lix: { db, plugin, sqlite: args.database } });
40
- captureOpened({ db });
41
38
  return {
42
39
  db,
43
40
  sqlite: args.database,
44
41
  plugin,
45
42
  };
46
43
  }
47
- async function captureOpened(args) {
48
- try {
49
- const telemetry = await args.db
50
- .selectFrom("key_value")
51
- .select("value")
52
- .where("key", "=", "lix_telemetry")
53
- .executeTakeFirst();
54
- if (telemetry?.value === "off") {
55
- return;
56
- }
57
- const activeAccount = await args.db
58
- .selectFrom("active_account")
59
- .select("id")
60
- .executeTakeFirstOrThrow();
61
- const lixId = await args.db
62
- .selectFrom("key_value")
63
- .select("value")
64
- .where("key", "=", "lix_id")
65
- .executeTakeFirstOrThrow();
66
- const fileExtensions = await usedFileExtensions(args.db);
67
- if (Math.random() > 0.1) {
68
- await capture("LIX-SDK lix opened", {
69
- accountId: activeAccount.id,
70
- lixId: lixId.value,
71
- telemetryKeyValue: telemetry?.value ?? "on",
72
- properties: {
73
- lix_sdk_version: ENV_VARIABLES.LIX_SDK_VERSION,
74
- stored_file_extensions: fileExtensions,
75
- },
76
- });
77
- }
78
- }
79
- catch {
80
- // ignore
81
- }
82
- }
83
44
  /**
84
45
  * Get all used file extensions.
85
46
  */
@@ -107,4 +68,4 @@ export async function usedFileExtensions(db) {
107
68
  `.execute(db);
108
69
  return result.rows.map((row) => row.extension);
109
70
  }
110
- //# sourceMappingURL=open-lix.js.map
71
+ //# sourceMappingURL=open-lix.js.map
@@ -1,5 +1,5 @@
1
1
  export const ENV_VARIABLES = {
2
2
  LIX_SDK_POSTHOG_TOKEN: "phc_6492KFrhZMsb2HOZiloRb6R9tJQWZWVVAiebkwfWATT",
3
- LIX_SDK_VERSION: "0.4.6",
3
+ LIX_SDK_VERSION: "0.4.7",
4
4
  };
5
5
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lix-js/sdk",
3
3
  "type": "module",
4
- "version": "0.4.6",
4
+ "version": "0.4.8",
5
5
  "license": "Apache-2.0",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {
@@ -21,7 +21,7 @@
21
21
  "dedent": "1.5.1",
22
22
  "human-id": "^4.1.1",
23
23
  "js-sha256": "^0.11.0",
24
- "kysely": "^0.27.4",
24
+ "kysely": "^0.28.12",
25
25
  "uuid": "^10.0.0",
26
26
  "@lix-js/server-protocol-schema": "0.1.1",
27
27
  "sqlite-wasm-kysely": "0.3.0"
@@ -49,4 +49,4 @@
49
49
  "dev": "tsc --watch",
50
50
  "format": "prettier ./src --write"
51
51
  }
52
- }
52
+ }
package/src/lix/index.ts CHANGED
@@ -2,6 +2,7 @@ export { type Lix, openLix } from "./open-lix.js";
2
2
  export { openLixInMemory } from "./open-lix-in-memory.js";
3
3
  export { newLixFile } from "./new-lix.js";
4
4
  export { toBlob } from "./to-blob.js";
5
+ export { closeLix } from "./close-lix.js";
5
6
  // not exporting merge for api stability milestone
6
7
  // will need an overhaul to be stable
7
8
  // export { merge } from "./merge.js";
@@ -6,8 +6,6 @@ import { sql, type Kysely } from "kysely";
6
6
  import type { LixDatabaseSchema } from "../database/schema.js";
7
7
  import { initSyncProcess } from "../sync/sync-process.js";
8
8
  import type { NewKeyValue } from "../key-value/database-schema.js";
9
- import { capture } from "../services/telemetry/capture.js";
10
- import { ENV_VARIABLES } from "../services/env-variables/index.js";
11
9
  import type { Account } from "../account/database-schema.js";
12
10
 
13
11
  export type Lix = {
@@ -102,8 +100,6 @@ export async function openLix(args: {
102
100
 
103
101
  await initSyncProcess({ lix: { db, plugin, sqlite: args.database } });
104
102
 
105
- captureOpened({ db });
106
-
107
103
  return {
108
104
  db,
109
105
  sqlite: args.database,
@@ -111,46 +107,6 @@ export async function openLix(args: {
111
107
  };
112
108
  }
113
109
 
114
- async function captureOpened(args: { db: Kysely<LixDatabaseSchema> }) {
115
- try {
116
- const telemetry = await args.db
117
- .selectFrom("key_value")
118
- .select("value")
119
- .where("key", "=", "lix_telemetry")
120
- .executeTakeFirst();
121
-
122
- if (telemetry?.value === "off") {
123
- return;
124
- }
125
-
126
- const activeAccount = await args.db
127
- .selectFrom("active_account")
128
- .select("id")
129
- .executeTakeFirstOrThrow();
130
-
131
- const lixId = await args.db
132
- .selectFrom("key_value")
133
- .select("value")
134
- .where("key", "=", "lix_id")
135
- .executeTakeFirstOrThrow();
136
-
137
- const fileExtensions = await usedFileExtensions(args.db);
138
- if (Math.random() > 0.1) {
139
- await capture("LIX-SDK lix opened", {
140
- accountId: activeAccount.id,
141
- lixId: lixId.value,
142
- telemetryKeyValue: telemetry?.value ?? "on",
143
- properties: {
144
- lix_sdk_version: ENV_VARIABLES.LIX_SDK_VERSION,
145
- stored_file_extensions: fileExtensions,
146
- },
147
- });
148
- }
149
- } catch {
150
- // ignore
151
- }
152
- }
153
-
154
110
  /**
155
111
  * Get all used file extensions.
156
112
  */