@lix-js/sdk 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/account/database-schema.d.ts.map +1 -1
  2. package/dist/account/database-schema.js +2 -6
  3. package/dist/account/database-schema.js.map +1 -1
  4. package/dist/account/database-schema.test.js +4 -8
  5. package/dist/account/database-schema.test.js.map +1 -1
  6. package/dist/database/apply-schema.js +2 -2
  7. package/dist/database/init-db.test.js +3 -3
  8. package/dist/database/init-db.test.js.map +1 -1
  9. package/dist/file-queue/file-queue-process.d.ts.map +1 -1
  10. package/dist/file-queue/file-queue-process.js +4 -1
  11. package/dist/file-queue/file-queue-process.js.map +1 -1
  12. package/dist/file-queue/file-queue-process.test.js +4 -5
  13. package/dist/file-queue/file-queue-process.test.js.map +1 -1
  14. package/dist/lix/open-lix.d.ts +16 -1
  15. package/dist/lix/open-lix.d.ts.map +1 -1
  16. package/dist/lix/open-lix.js +76 -0
  17. package/dist/lix/open-lix.js.map +1 -1
  18. package/dist/lix/open-lix.test.js +54 -0
  19. package/dist/lix/open-lix.test.js.map +1 -1
  20. package/dist/query-filter/change-has-label.d.ts +2 -2
  21. package/dist/query-filter/change-has-label.js +2 -2
  22. package/dist/query-filter/change-set-has-label.d.ts +2 -2
  23. package/dist/query-filter/change-set-has-label.js +2 -2
  24. package/dist/services/env-variables/index.d.ts +5 -0
  25. package/dist/services/env-variables/index.d.ts.map +1 -0
  26. package/dist/services/env-variables/index.js +5 -0
  27. package/dist/services/env-variables/index.js.map +1 -0
  28. package/dist/services/telemetry/capture.d.ts +30 -0
  29. package/dist/services/telemetry/capture.d.ts.map +1 -0
  30. package/dist/services/telemetry/capture.js +71 -0
  31. package/dist/services/telemetry/capture.js.map +1 -0
  32. package/dist/services/telemetry/capture.test.d.ts +2 -0
  33. package/dist/services/telemetry/capture.test.d.ts.map +1 -0
  34. package/dist/services/telemetry/capture.test.js +37 -0
  35. package/dist/services/telemetry/capture.test.js.map +1 -0
  36. package/dist/sync/sync-process.d.ts.map +1 -1
  37. package/dist/sync/sync-process.js +11 -5
  38. package/dist/sync/sync-process.js.map +1 -1
  39. package/package.json +4 -6
  40. package/src/account/database-schema.test.ts +6 -9
  41. package/src/account/database-schema.ts +2 -6
  42. package/src/database/apply-schema.ts +2 -2
  43. package/src/database/init-db.test.ts +3 -3
  44. package/src/file-queue/file-queue-process.test.ts +4 -5
  45. package/src/file-queue/file-queue-process.ts +4 -1
  46. package/src/lix/open-lix.test.ts +63 -0
  47. package/src/lix/open-lix.ts +98 -1
  48. package/src/query-filter/change-has-label.ts +2 -2
  49. package/src/query-filter/change-set-has-label.ts +2 -2
  50. package/src/services/env-variables/create-index-file.js +35 -0
  51. package/src/services/env-variables/index.d.ts +15 -0
  52. package/src/services/telemetry/capture.test.ts +44 -0
  53. package/src/services/telemetry/capture.ts +99 -0
  54. package/src/sync/sync-process.ts +11 -6
  55. package/node_modules/@lix-js/server-api-schema/.prettierrc.json +0 -3
  56. package/node_modules/@lix-js/server-api-schema/.vscode/extensions.json +0 -3
  57. package/node_modules/@lix-js/server-api-schema/CHANGELOG.md +0 -9
  58. package/node_modules/@lix-js/server-api-schema/LICENSE +0 -21
  59. package/node_modules/@lix-js/server-api-schema/dist/schema.js +0 -0
  60. package/node_modules/@lix-js/server-api-schema/package.json +0 -21
  61. package/node_modules/@lix-js/server-api-schema/src/schema.yaml +0 -290
  62. package/node_modules/@lix-js/server-api-schema/tsconfig.json +0 -20
  63. package/node_modules/sqlite-wasm-kysely/LICENSE +0 -21
  64. package/node_modules/sqlite-wasm-kysely/README.md +0 -11
  65. package/node_modules/sqlite-wasm-kysely/dist/dialect.d.ts +0 -11
  66. package/node_modules/sqlite-wasm-kysely/dist/dialect.js +0 -13
  67. package/node_modules/sqlite-wasm-kysely/dist/dialect.js.map +0 -1
  68. package/node_modules/sqlite-wasm-kysely/dist/index.d.ts +0 -2
  69. package/node_modules/sqlite-wasm-kysely/dist/index.js +0 -3
  70. package/node_modules/sqlite-wasm-kysely/dist/index.js.map +0 -1
  71. package/node_modules/sqlite-wasm-kysely/dist/kysely/ConnectionMutex.d.ts +0 -5
  72. package/node_modules/sqlite-wasm-kysely/dist/kysely/ConnectionMutex.js +0 -34
  73. package/node_modules/sqlite-wasm-kysely/dist/kysely/ConnectionMutex.js.map +0 -1
  74. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmConnection.d.ts +0 -8
  75. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmConnection.js +0 -57
  76. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmConnection.js.map +0 -1
  77. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDialectConfig.d.ts +0 -18
  78. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDialectConfig.js +0 -2
  79. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDialectConfig.js.map +0 -1
  80. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDriver.d.ts +0 -13
  81. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDriver.js +0 -57
  82. package/node_modules/sqlite-wasm-kysely/dist/kysely/SqliteWasmDriver.js.map +0 -1
  83. package/node_modules/sqlite-wasm-kysely/dist/kysely/index.d.ts +0 -4
  84. package/node_modules/sqlite-wasm-kysely/dist/kysely/index.js +0 -4
  85. package/node_modules/sqlite-wasm-kysely/dist/kysely/index.js.map +0 -1
  86. package/node_modules/sqlite-wasm-kysely/dist/kysely/sqliteModule.d.ts +0 -3
  87. package/node_modules/sqlite-wasm-kysely/dist/kysely/sqliteModule.js +0 -5
  88. package/node_modules/sqlite-wasm-kysely/dist/kysely/sqliteModule.js.map +0 -1
  89. package/node_modules/sqlite-wasm-kysely/dist/util/contentFromDatabase.d.ts +0 -9
  90. package/node_modules/sqlite-wasm-kysely/dist/util/contentFromDatabase.js +0 -12
  91. package/node_modules/sqlite-wasm-kysely/dist/util/contentFromDatabase.js.map +0 -1
  92. package/node_modules/sqlite-wasm-kysely/dist/util/createInMemoryDatabase.d.ts +0 -3
  93. package/node_modules/sqlite-wasm-kysely/dist/util/createInMemoryDatabase.js +0 -22
  94. package/node_modules/sqlite-wasm-kysely/dist/util/createInMemoryDatabase.js.map +0 -1
  95. package/node_modules/sqlite-wasm-kysely/dist/util/importDatabase.d.ts +0 -7
  96. package/node_modules/sqlite-wasm-kysely/dist/util/importDatabase.js +0 -15
  97. package/node_modules/sqlite-wasm-kysely/dist/util/importDatabase.js.map +0 -1
  98. package/node_modules/sqlite-wasm-kysely/dist/util/index.d.ts +0 -5
  99. package/node_modules/sqlite-wasm-kysely/dist/util/index.js +0 -5
  100. package/node_modules/sqlite-wasm-kysely/dist/util/index.js.map +0 -1
  101. package/node_modules/sqlite-wasm-kysely/dist/util/loadDatabaseInMemory.d.ts +0 -1
  102. package/node_modules/sqlite-wasm-kysely/dist/util/loadDatabaseInMemory.js +0 -13
  103. package/node_modules/sqlite-wasm-kysely/dist/util/loadDatabaseInMemory.js.map +0 -1
  104. package/node_modules/sqlite-wasm-kysely/dist/util/sqliteWasmBinary.d.ts +0 -7
  105. package/node_modules/sqlite-wasm-kysely/dist/util/sqliteWasmBinary.js +0 -17
  106. package/node_modules/sqlite-wasm-kysely/dist/util/sqliteWasmBinary.js.map +0 -1
  107. package/node_modules/sqlite-wasm-kysely/package.json +0 -34
  108. package/node_modules/sqlite-wasm-kysely/src/dialect.ts +0 -15
  109. package/node_modules/sqlite-wasm-kysely/src/index.ts +0 -2
  110. package/node_modules/sqlite-wasm-kysely/src/kysely/ConnectionMutex.ts +0 -23
  111. package/node_modules/sqlite-wasm-kysely/src/kysely/SqliteWasmConnection.ts +0 -57
  112. package/node_modules/sqlite-wasm-kysely/src/kysely/SqliteWasmDialectConfig.ts +0 -19
  113. package/node_modules/sqlite-wasm-kysely/src/kysely/SqliteWasmDriver.ts +0 -58
  114. package/node_modules/sqlite-wasm-kysely/src/kysely/index.ts +0 -4
  115. package/node_modules/sqlite-wasm-kysely/src/kysely/sqliteModule.ts +0 -7
  116. package/node_modules/sqlite-wasm-kysely/src/util/contentFromDatabase.ts +0 -13
  117. package/node_modules/sqlite-wasm-kysely/src/util/createInMemoryDatabase.ts +0 -30
  118. package/node_modules/sqlite-wasm-kysely/src/util/importDatabase.ts +0 -34
  119. package/node_modules/sqlite-wasm-kysely/src/util/index.ts +0 -5
  120. package/node_modules/sqlite-wasm-kysely/src/util/loadDatabaseInMemory.ts +0 -13
  121. package/node_modules/sqlite-wasm-kysely/src/util/sqliteWasmBinary.ts +0 -20
@@ -7,7 +7,7 @@ import type { LixDatabaseSchema } from "../database/schema.js";
7
7
  * @example
8
8
  * ```ts
9
9
  * await lix.db.selectFrom("change")
10
- * .where(changeHasLabel("confirmed"))
10
+ * .where(changeHasLabel("checkpoint"))
11
11
  * .selectAll()
12
12
  * .execute();
13
13
  * ```
@@ -17,7 +17,7 @@ import type { LixDatabaseSchema } from "../database/schema.js";
17
17
  *
18
18
  * ```ts
19
19
  * await lix.db.selectFrom("change")
20
- * .where((eb) => eb.not(changeHasLabel("confirmed")))
20
+ * .where((eb) => eb.not(changeHasLabel("checkpoint")))
21
21
  * .selectAll()
22
22
  * .execute();
23
23
  * ```
@@ -7,7 +7,7 @@ import type { LixDatabaseSchema } from "../database/schema.js";
7
7
  * @example
8
8
  * ```ts
9
9
  * await lix.db.selectFrom("change_set")
10
- * .where(changeSetHasLabel("confirmed"))
10
+ * .where(changeSetHasLabel("checkpoint"))
11
11
  * .selectAll()
12
12
  * .execute();
13
13
  * ```
@@ -17,7 +17,7 @@ import type { LixDatabaseSchema } from "../database/schema.js";
17
17
  *
18
18
  * ```ts
19
19
  * await lix.db.selectFrom("change_set")
20
- * .where((eb) => eb.not(changeSetHasLabel("confirmed")))
20
+ * .where((eb) => eb.not(changeSetHasLabel("checkpoint")))
21
21
  * .selectAll()
22
22
  * .execute();
23
23
  * ```
@@ -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
+ });
@@ -0,0 +1,99 @@
1
+ import { ENV_VARIABLES } from "../env-variables/index.js";
2
+
3
+ /**
4
+ * List of telemetry events for typesafety.
5
+ *
6
+ * - prefix with `SDK` to avoid collisions with other apps
7
+ * - use past tense to indicate that the event is completed
8
+ */
9
+ type TelemetryEvent = "LIX-SDK lix opened";
10
+
11
+ /**
12
+ * Capture an event.
13
+ *
14
+ * - manually calling the PostHog API because the SDKs were not platform angostic (and generally bloated)
15
+ */
16
+ export const capture = async (
17
+ event: TelemetryEvent,
18
+ args: {
19
+ lixId: string;
20
+ accountId: string;
21
+ /**
22
+ * The value of the telemetry key-value pair.
23
+ *
24
+ * @example
25
+ * const telemetryKeyValue = await lix.db.selectFrom("key_value").select("value").where("key", "=", "lix_telemetry").executeTakeFirstOrThrow();
26
+ * await capture("LIX-SDK opened lix", { lixId: "test", accountId: "test", telemetryKeyValue: telemetryKeyValue.value, properties: {} });
27
+ */
28
+ telemetryKeyValue: string;
29
+ /**
30
+ * Please use snake_case for property names.
31
+ */
32
+ properties: Record<string, any>;
33
+ }
34
+ ): Promise<void> => {
35
+ if (ENV_VARIABLES.LIX_SDK_POSTHOG_TOKEN === undefined) {
36
+ return;
37
+ } else if (args.telemetryKeyValue === "off") {
38
+ return;
39
+ }
40
+ try {
41
+ await fetch("https://eu.posthog.com/capture/", {
42
+ method: "POST",
43
+ body: JSON.stringify({
44
+ api_key: ENV_VARIABLES.LIX_SDK_POSTHOG_TOKEN,
45
+ event,
46
+ distinct_id: args.accountId,
47
+ properties: {
48
+ $groups: { lix_id: args.lixId },
49
+ ...args.properties,
50
+ },
51
+ }),
52
+ });
53
+ await identifyLix({
54
+ lixId: args.lixId,
55
+ accountId: args.accountId,
56
+ // using the id for now as a name but can be changed in the future
57
+ // we need at least one property to make a project visible in the dashboard
58
+ properties: { name: args.lixId },
59
+ });
60
+ } catch {
61
+ //
62
+ }
63
+ };
64
+
65
+ /**
66
+ * Identifying a project is needed.
67
+ *
68
+ * Otherwise, the project will not be visible in the PostHog dashboard.
69
+ */
70
+ const identifyLix = async (args: {
71
+ lixId: string;
72
+ accountId: string;
73
+ properties: Record<string, string>;
74
+ }) => {
75
+ // do not send events if the token is not set
76
+ // (assuming this eases testing)
77
+ if (ENV_VARIABLES.LIX_SDK_POSTHOG_TOKEN === undefined) {
78
+ return;
79
+ }
80
+ try {
81
+ await fetch("https://eu.posthog.com/capture/", {
82
+ method: "POST",
83
+ body: JSON.stringify({
84
+ api_key: ENV_VARIABLES.LIX_SDK_POSTHOG_TOKEN,
85
+ event: "$groupidentify",
86
+ distinct_id: args.accountId,
87
+ properties: {
88
+ $group_type: "lix",
89
+ $group_key: args.lixId,
90
+ $group_set: {
91
+ ...args.properties,
92
+ },
93
+ },
94
+ }),
95
+ });
96
+ } catch {
97
+ //
98
+ }
99
+ };
@@ -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
- pullAndPush().catch((e) => {
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
- }, 1000);
86
+ }, 750);
82
87
  }
83
88
 
84
89
  schedulePullAndPush();
@@ -1,3 +0,0 @@
1
- {
2
- "useTabs": true
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "recommendations": ["42crunch.vscode-openapi"]
3
- }
@@ -1,9 +0,0 @@
1
- # @lix-js/server-api-schema
2
-
3
- ## 0.1.1
4
-
5
- ### Patch Changes
6
-
7
- - 896602f: fix: emit .js file for node js
8
-
9
- Otherwise, node js will throw "UNKNOWN FILE EXTENSION .ts".
@@ -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,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
- ## Usage
2
-
3
- ```ts
4
- const db = createInMemoryDatabase();
5
-
6
- const kysely = new Kysely<DB>({
7
- dialect: createDialect({
8
- database: db,
9
- }),
10
- });
11
- ```