@lix-js/sdk 0.1.0 → 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/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/file-queue/file-queue-process.d.ts.map +1 -1
- package/dist/file-queue/file-queue-process.js +4 -1
- package/dist/file-queue/file-queue-process.js.map +1 -1
- package/dist/file-queue/file-queue-process.test.js +4 -5
- package/dist/file-queue/file-queue-process.test.js.map +1 -1
- package/dist/lix/open-lix.d.ts +16 -1
- package/dist/lix/open-lix.d.ts.map +1 -1
- package/dist/lix/open-lix.js +76 -0
- package/dist/lix/open-lix.js.map +1 -1
- package/dist/lix/open-lix.test.js +54 -0
- package/dist/lix/open-lix.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/sync-process.d.ts.map +1 -1
- package/dist/sync/sync-process.js +11 -5
- package/dist/sync/sync-process.js.map +1 -1
- package/package.json +4 -6
- package/src/account/database-schema.test.ts +6 -9
- package/src/account/database-schema.ts +2 -6
- package/src/file-queue/file-queue-process.test.ts +4 -5
- package/src/file-queue/file-queue-process.ts +4 -1
- package/src/lix/open-lix.test.ts +63 -0
- package/src/lix/open-lix.ts +98 -1
- 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/sync-process.ts +11 -6
- 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/CHANGELOG.md +0 -9
- package/node_modules/@lix-js/server-api-schema/LICENSE +0 -21
- package/node_modules/@lix-js/server-api-schema/dist/schema.js +0 -0
- 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/LICENSE +0 -21
- 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/sync/sync-process.ts
CHANGED
|
@@ -34,7 +34,6 @@ export async function initSyncProcess(args: {
|
|
|
34
34
|
if (!url) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
37
|
try {
|
|
39
38
|
// console.log("----------- PULL FROM SERVER -------------");
|
|
40
39
|
const serverState = await pullFromServer({
|
|
@@ -71,14 +70,20 @@ export async function initSyncProcess(args: {
|
|
|
71
70
|
// naive implementation that syncs every second
|
|
72
71
|
|
|
73
72
|
function schedulePullAndPush() {
|
|
74
|
-
if (args.lix.sqlite.isOpen()) {
|
|
75
|
-
|
|
76
|
-
console.error("Error in sync process", e);
|
|
77
|
-
});
|
|
73
|
+
if (args.lix.sqlite.isOpen() === false) {
|
|
74
|
+
return;
|
|
78
75
|
}
|
|
76
|
+
pullAndPush().catch((e) => {
|
|
77
|
+
if (e instanceof Error && e.message.includes("DB has been closed.")) {
|
|
78
|
+
// stop the syncing process, the database has been closed.
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
console.error("Error in sync process", e);
|
|
82
|
+
});
|
|
83
|
+
// schedule next sync
|
|
79
84
|
setTimeout(() => {
|
|
80
85
|
schedulePullAndPush();
|
|
81
|
-
},
|
|
86
|
+
}, 750);
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
schedulePullAndPush();
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Opral US Inc.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
File without changes
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"private": true,
|
|
3
|
-
"name": "@lix-js/server-api-schema",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"version": "0.1.1",
|
|
6
|
-
"license": "Apache-2.0",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": "./dist/schema.js"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "npx openapi-typescript ./src/schema.yaml -o ./dist/schema.d.ts",
|
|
12
|
-
"format": "prettier ./src --write"
|
|
13
|
-
},
|
|
14
|
-
"_comment": "Required for tree-shaking https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free",
|
|
15
|
-
"sideEffects": false,
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"openapi-typescript": "^7.4.3",
|
|
18
|
-
"prettier": "^3.3.3",
|
|
19
|
-
"typescript": "^5.5.4"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
openapi: 3.0.3
|
|
2
|
-
info:
|
|
3
|
-
title: Lix Server Api
|
|
4
|
-
version: 1.0.0
|
|
5
|
-
paths:
|
|
6
|
-
/lsa/new-v1:
|
|
7
|
-
post:
|
|
8
|
-
summary: Stores the lix on the server.
|
|
9
|
-
description: >
|
|
10
|
-
Use sync if you want to push or pull data from the server.
|
|
11
|
-
requestBody:
|
|
12
|
-
description: The lix binary.
|
|
13
|
-
required: true
|
|
14
|
-
content:
|
|
15
|
-
application/octet-stream:
|
|
16
|
-
schema:
|
|
17
|
-
format: binary
|
|
18
|
-
|
|
19
|
-
responses:
|
|
20
|
-
"201":
|
|
21
|
-
description: Lix file created successfully.
|
|
22
|
-
content:
|
|
23
|
-
application/json:
|
|
24
|
-
schema:
|
|
25
|
-
type: object
|
|
26
|
-
properties:
|
|
27
|
-
id:
|
|
28
|
-
type: string
|
|
29
|
-
description: The ID of the created lix.
|
|
30
|
-
example: "123e4567-e89b-12d3-a456-426614174000"
|
|
31
|
-
|
|
32
|
-
"400":
|
|
33
|
-
description: Invalid Lix file.
|
|
34
|
-
content:
|
|
35
|
-
application/json:
|
|
36
|
-
schema:
|
|
37
|
-
type: object
|
|
38
|
-
properties:
|
|
39
|
-
error:
|
|
40
|
-
type: string
|
|
41
|
-
description: Error message.
|
|
42
|
-
example: "Invalid Lix file."
|
|
43
|
-
|
|
44
|
-
"409":
|
|
45
|
-
description: Lix file already exists.
|
|
46
|
-
content:
|
|
47
|
-
application/json:
|
|
48
|
-
schema:
|
|
49
|
-
type: object
|
|
50
|
-
properties:
|
|
51
|
-
error:
|
|
52
|
-
type: string
|
|
53
|
-
description: Error message.
|
|
54
|
-
example: "Lix file already exists."
|
|
55
|
-
|
|
56
|
-
/lsa/get-v1:
|
|
57
|
-
post:
|
|
58
|
-
summary: Get the lix from the server.
|
|
59
|
-
requestBody:
|
|
60
|
-
required: true
|
|
61
|
-
content:
|
|
62
|
-
application/json:
|
|
63
|
-
schema:
|
|
64
|
-
type: object
|
|
65
|
-
required:
|
|
66
|
-
- lix_id
|
|
67
|
-
properties:
|
|
68
|
-
lix_id:
|
|
69
|
-
type: string
|
|
70
|
-
description: The ID of the lix to get.
|
|
71
|
-
example: "123e4567-e89b-12d3-a456-426614174000"
|
|
72
|
-
responses:
|
|
73
|
-
"200":
|
|
74
|
-
description: Lix file fetched successfully.
|
|
75
|
-
content:
|
|
76
|
-
application/octet-stream:
|
|
77
|
-
schema:
|
|
78
|
-
format: binary
|
|
79
|
-
"404":
|
|
80
|
-
description: Lix file not found.
|
|
81
|
-
content:
|
|
82
|
-
application/json:
|
|
83
|
-
schema:
|
|
84
|
-
type: object
|
|
85
|
-
properties:
|
|
86
|
-
error:
|
|
87
|
-
type: string
|
|
88
|
-
description: Error message.
|
|
89
|
-
example: "Lix file not found."
|
|
90
|
-
|
|
91
|
-
/lsa/push-v1:
|
|
92
|
-
post:
|
|
93
|
-
summary: Push data to the server.
|
|
94
|
-
requestBody:
|
|
95
|
-
required: true
|
|
96
|
-
content:
|
|
97
|
-
application/json:
|
|
98
|
-
schema:
|
|
99
|
-
type: object
|
|
100
|
-
required:
|
|
101
|
-
- lix_id
|
|
102
|
-
- vector_clock
|
|
103
|
-
- data
|
|
104
|
-
properties:
|
|
105
|
-
lix_id:
|
|
106
|
-
type: string
|
|
107
|
-
description: The ID of the lix to push to.
|
|
108
|
-
example: "123e4567-e89b-12d3-a456-426614174000"
|
|
109
|
-
vector_clock:
|
|
110
|
-
type: array
|
|
111
|
-
items:
|
|
112
|
-
type: object
|
|
113
|
-
description: The vector clock of the client.
|
|
114
|
-
required:
|
|
115
|
-
- session
|
|
116
|
-
- time
|
|
117
|
-
properties:
|
|
118
|
-
session:
|
|
119
|
-
type: string
|
|
120
|
-
description: The session ID of the client.
|
|
121
|
-
example: "123e4567-e"
|
|
122
|
-
time:
|
|
123
|
-
type: integer
|
|
124
|
-
description: The time of the client.
|
|
125
|
-
example: 123456789
|
|
126
|
-
example:
|
|
127
|
-
123e4567-e89b-12d3-a456-426614174000: 1
|
|
128
|
-
data:
|
|
129
|
-
type: object
|
|
130
|
-
description: The data to push.
|
|
131
|
-
additionalProperties:
|
|
132
|
-
type: array
|
|
133
|
-
items:
|
|
134
|
-
type: object
|
|
135
|
-
additionalProperties: true
|
|
136
|
-
example: >
|
|
137
|
-
{
|
|
138
|
-
"id": 1,
|
|
139
|
-
"name": "Alice"
|
|
140
|
-
}
|
|
141
|
-
example: >
|
|
142
|
-
{
|
|
143
|
-
"table_name": [
|
|
144
|
-
{
|
|
145
|
-
"id": 1,
|
|
146
|
-
"name": "Alice"
|
|
147
|
-
}
|
|
148
|
-
]
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
responses:
|
|
152
|
-
"201":
|
|
153
|
-
description: Rows pushed successfully.
|
|
154
|
-
|
|
155
|
-
"400":
|
|
156
|
-
description: Invalid row data.
|
|
157
|
-
content:
|
|
158
|
-
application/json:
|
|
159
|
-
schema:
|
|
160
|
-
type: object
|
|
161
|
-
properties:
|
|
162
|
-
code:
|
|
163
|
-
type: string
|
|
164
|
-
description: A machine-readable error code.
|
|
165
|
-
example: "INVALID_ROW_DATA"
|
|
166
|
-
message:
|
|
167
|
-
type: string
|
|
168
|
-
description: A human-readable error message.
|
|
169
|
-
example: "The provided row data is invalid."
|
|
170
|
-
|
|
171
|
-
"404":
|
|
172
|
-
description: Lix not found.
|
|
173
|
-
|
|
174
|
-
"500":
|
|
175
|
-
description: Server error.
|
|
176
|
-
content:
|
|
177
|
-
application/json:
|
|
178
|
-
schema:
|
|
179
|
-
type: object
|
|
180
|
-
properties:
|
|
181
|
-
code:
|
|
182
|
-
type: string
|
|
183
|
-
description: Error message.
|
|
184
|
-
example: "INTERNAL_SERVER_ERROR"
|
|
185
|
-
message:
|
|
186
|
-
type: string
|
|
187
|
-
description: A human-readable error message.
|
|
188
|
-
example: "An internal server error occurred."
|
|
189
|
-
|
|
190
|
-
/lsa/pull-v1:
|
|
191
|
-
post:
|
|
192
|
-
summary: Pull all data for all tables from the server.
|
|
193
|
-
requestBody:
|
|
194
|
-
required: true
|
|
195
|
-
content:
|
|
196
|
-
application/json:
|
|
197
|
-
schema:
|
|
198
|
-
type: object
|
|
199
|
-
required:
|
|
200
|
-
- lix_id
|
|
201
|
-
- vector_clock
|
|
202
|
-
properties:
|
|
203
|
-
lix_id:
|
|
204
|
-
type: string
|
|
205
|
-
description: The ID of the lix to pull from.
|
|
206
|
-
example: "123e4567-e89b-12d3-a456-426614174000"
|
|
207
|
-
vector_clock:
|
|
208
|
-
type: array
|
|
209
|
-
items:
|
|
210
|
-
type: object
|
|
211
|
-
description: The vector clock of the client.
|
|
212
|
-
required:
|
|
213
|
-
- session
|
|
214
|
-
- time
|
|
215
|
-
properties:
|
|
216
|
-
session:
|
|
217
|
-
type: string
|
|
218
|
-
description: The session ID of the client.
|
|
219
|
-
example: "123e4567-e"
|
|
220
|
-
time:
|
|
221
|
-
type: integer
|
|
222
|
-
description: The time of the client.
|
|
223
|
-
example: 123456789
|
|
224
|
-
responses:
|
|
225
|
-
"200":
|
|
226
|
-
description: Data fetched successfully.
|
|
227
|
-
content:
|
|
228
|
-
application/json:
|
|
229
|
-
schema:
|
|
230
|
-
type: object
|
|
231
|
-
required:
|
|
232
|
-
- vector_clock
|
|
233
|
-
- data
|
|
234
|
-
properties:
|
|
235
|
-
vector_clock:
|
|
236
|
-
type: array
|
|
237
|
-
items:
|
|
238
|
-
type: object
|
|
239
|
-
description: The vector clock of the server.
|
|
240
|
-
required:
|
|
241
|
-
- session
|
|
242
|
-
- time
|
|
243
|
-
properties:
|
|
244
|
-
session:
|
|
245
|
-
type: string
|
|
246
|
-
description: The session ID of the server.
|
|
247
|
-
example: "123e4567-e"
|
|
248
|
-
time:
|
|
249
|
-
type: integer
|
|
250
|
-
description: The time of the server.
|
|
251
|
-
example:
|
|
252
|
-
session: 123e4567-e89b-12d3-a456-426614174000
|
|
253
|
-
time: 1
|
|
254
|
-
data:
|
|
255
|
-
type: object
|
|
256
|
-
description: The data to push.
|
|
257
|
-
additionalProperties:
|
|
258
|
-
type: array
|
|
259
|
-
items:
|
|
260
|
-
type: object
|
|
261
|
-
additionalProperties: true
|
|
262
|
-
example: >
|
|
263
|
-
{
|
|
264
|
-
"id": 1,
|
|
265
|
-
"name": "Alice"
|
|
266
|
-
}
|
|
267
|
-
required:
|
|
268
|
-
- vector_clock
|
|
269
|
-
example: >
|
|
270
|
-
{
|
|
271
|
-
"table_name": [
|
|
272
|
-
{
|
|
273
|
-
"id": 1,
|
|
274
|
-
"name": "Alice"
|
|
275
|
-
}
|
|
276
|
-
]
|
|
277
|
-
}
|
|
278
|
-
"404":
|
|
279
|
-
description: Lix file not found.
|
|
280
|
-
"500":
|
|
281
|
-
description: Failed to open the Lix file.
|
|
282
|
-
content:
|
|
283
|
-
application/json:
|
|
284
|
-
schema:
|
|
285
|
-
type: object
|
|
286
|
-
properties:
|
|
287
|
-
code:
|
|
288
|
-
type: string
|
|
289
|
-
message:
|
|
290
|
-
type: string
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../tsconfig.base.json",
|
|
3
|
-
"include": ["src/**/*"],
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"allowJs": false,
|
|
6
|
-
"checkJs": false,
|
|
7
|
-
// isolated declarations lead to substantially faster build times
|
|
8
|
-
// which is overproportionally useful in a monorepo
|
|
9
|
-
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#isolated-declarations
|
|
10
|
-
"isolatedDeclarations": true,
|
|
11
|
-
"allowImportingTsExtensions": false,
|
|
12
|
-
"emitDeclarationOnly": false,
|
|
13
|
-
// recommended by openapi-typescript https://openapi-ts.dev/introduction#setup
|
|
14
|
-
"noUncheckedIndexedAccess": true,
|
|
15
|
-
"module": "Node16",
|
|
16
|
-
"lib": ["ESNext"],
|
|
17
|
-
"outDir": "./dist",
|
|
18
|
-
"rootDir": "./src"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Opral US Inc.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -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 +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,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 +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
|
-
}
|