@lix-js/sdk 0.4.7 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/change/apply-changes.test.js +3 -3
- package/dist/file-queue/file-queue-process.js +2 -2
- package/dist/file-queue/with-skip-file-queue.js +2 -2
- package/dist/lix/open-lix.js +1 -40
- package/package.json +3 -3
- package/src/change/apply-changes.test.ts +2 -2
- package/src/file-queue/file-queue-process.ts +1 -1
- package/src/file-queue/with-skip-file-queue.ts +1 -1
- package/src/lix/open-lix.ts +0 -44
|
@@ -189,7 +189,7 @@ test("applies an insert change for a file if the file does not exist", async ()
|
|
|
189
189
|
await fileQueueSettled({ lix });
|
|
190
190
|
const changes1 = await lix.db
|
|
191
191
|
.selectFrom("change")
|
|
192
|
-
.orderBy("id desc")
|
|
192
|
+
.orderBy("id", "desc")
|
|
193
193
|
.selectAll()
|
|
194
194
|
.execute();
|
|
195
195
|
const snapshots1 = await lix.db.selectFrom("snapshot").selectAll().execute();
|
|
@@ -208,7 +208,7 @@ test("applies an insert change for a file if the file does not exist", async ()
|
|
|
208
208
|
await applyChanges({ lix: lix2, changes: changes1 });
|
|
209
209
|
const changes2 = await lix2.db
|
|
210
210
|
.selectFrom("change")
|
|
211
|
-
.orderBy("id desc")
|
|
211
|
+
.orderBy("id", "desc")
|
|
212
212
|
.selectAll()
|
|
213
213
|
.execute();
|
|
214
214
|
const file2 = await lix2.db
|
|
@@ -219,4 +219,4 @@ test("applies an insert change for a file if the file does not exist", async ()
|
|
|
219
219
|
expect(changes1).toEqual(changes2);
|
|
220
220
|
expect(file1).toEqual(file2);
|
|
221
221
|
});
|
|
222
|
-
//# sourceMappingURL=apply-changes.test.js.map
|
|
222
|
+
//# sourceMappingURL=apply-changes.test.js.map
|
|
@@ -33,7 +33,7 @@ export async function initFileQueueProcess(args) {
|
|
|
33
33
|
const entry = await args.lix.db
|
|
34
34
|
.selectFrom("file_queue")
|
|
35
35
|
.selectAll()
|
|
36
|
-
.orderBy("id asc")
|
|
36
|
+
.orderBy("id", "asc")
|
|
37
37
|
.limit(1)
|
|
38
38
|
.executeTakeFirst();
|
|
39
39
|
if (entry) {
|
|
@@ -88,4 +88,4 @@ export async function initFileQueueProcess(args) {
|
|
|
88
88
|
queueWorker();
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
-
//# sourceMappingURL=file-queue-process.js.map
|
|
91
|
+
//# sourceMappingURL=file-queue-process.js.map
|
|
@@ -3,7 +3,7 @@ export async function withSkipFileQueue(db, operation) {
|
|
|
3
3
|
const queryEntryBefore = await trx
|
|
4
4
|
.selectFrom("file_queue")
|
|
5
5
|
.selectAll()
|
|
6
|
-
.orderBy("id desc")
|
|
6
|
+
.orderBy("id", "desc")
|
|
7
7
|
.executeTakeFirst();
|
|
8
8
|
// Perform the user's operation
|
|
9
9
|
const result = await operation(trx);
|
|
@@ -23,4 +23,4 @@ export async function withSkipFileQueue(db, operation) {
|
|
|
23
23
|
return db.transaction().execute(executeInTransaction);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
//# sourceMappingURL=with-skip-file-queue.js.map
|
|
26
|
+
//# sourceMappingURL=with-skip-file-queue.js.map
|
package/dist/lix/open-lix.js
CHANGED
|
@@ -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
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lix-js/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.9",
|
|
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.
|
|
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
|
+
}
|
|
@@ -228,7 +228,7 @@ test("applies an insert change for a file if the file does not exist", async ()
|
|
|
228
228
|
|
|
229
229
|
const changes1 = await lix.db
|
|
230
230
|
.selectFrom("change")
|
|
231
|
-
.orderBy("id desc")
|
|
231
|
+
.orderBy("id", "desc")
|
|
232
232
|
.selectAll()
|
|
233
233
|
.execute();
|
|
234
234
|
|
|
@@ -253,7 +253,7 @@ test("applies an insert change for a file if the file does not exist", async ()
|
|
|
253
253
|
|
|
254
254
|
const changes2 = await lix2.db
|
|
255
255
|
.selectFrom("change")
|
|
256
|
-
.orderBy("id desc")
|
|
256
|
+
.orderBy("id", "desc")
|
|
257
257
|
.selectAll()
|
|
258
258
|
.execute();
|
|
259
259
|
|
package/src/lix/open-lix.ts
CHANGED
|
@@ -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
|
*/
|