wn-turso 0.1.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 (68) hide show
  1. package/LICENSE +21 -0
  2. package/dist/adapters/adapter.d.ts +53 -0
  3. package/dist/adapters/adapter.d.ts.map +1 -0
  4. package/dist/adapters/adapter.js +4 -0
  5. package/dist/adapters/embedded-adapter.d.ts +24 -0
  6. package/dist/adapters/embedded-adapter.d.ts.map +1 -0
  7. package/dist/adapters/embedded-adapter.js +78 -0
  8. package/dist/adapters/index.d.ts +7 -0
  9. package/dist/adapters/index.d.ts.map +1 -0
  10. package/dist/adapters/index.js +5 -0
  11. package/dist/adapters/remote-adapter.d.ts +21 -0
  12. package/dist/adapters/remote-adapter.d.ts.map +1 -0
  13. package/dist/adapters/remote-adapter.js +49 -0
  14. package/dist/cli/index.d.ts +6 -0
  15. package/dist/cli/index.d.ts.map +1 -0
  16. package/dist/cli/index.js +61 -0
  17. package/dist/config.d.ts +77 -0
  18. package/dist/config.d.ts.map +1 -0
  19. package/dist/config.js +37 -0
  20. package/dist/database/index.d.ts +10 -0
  21. package/dist/database/index.d.ts.map +1 -0
  22. package/dist/database/index.js +8 -0
  23. package/dist/database/kysely-query-service.d.ts +32 -0
  24. package/dist/database/kysely-query-service.d.ts.map +1 -0
  25. package/dist/database/kysely-query-service.js +39 -0
  26. package/dist/database/turso-connection.d.ts +15 -0
  27. package/dist/database/turso-connection.d.ts.map +1 -0
  28. package/dist/database/turso-connection.js +29 -0
  29. package/dist/database/turso-database.d.ts +49 -0
  30. package/dist/database/turso-database.d.ts.map +1 -0
  31. package/dist/database/turso-database.js +124 -0
  32. package/dist/database/turso-dialect.d.ts +16 -0
  33. package/dist/database/turso-dialect.d.ts.map +1 -0
  34. package/dist/database/turso-dialect.js +25 -0
  35. package/dist/database/turso-driver.d.ts +25 -0
  36. package/dist/database/turso-driver.d.ts.map +1 -0
  37. package/dist/database/turso-driver.js +43 -0
  38. package/dist/index.d.ts +11 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +15 -0
  41. package/dist/pipeline/index.d.ts +10 -0
  42. package/dist/pipeline/index.d.ts.map +1 -0
  43. package/dist/pipeline/index.js +13 -0
  44. package/dist/pipeline/operators.d.ts +65 -0
  45. package/dist/pipeline/operators.d.ts.map +1 -0
  46. package/dist/pipeline/operators.js +174 -0
  47. package/dist/pipeline/pipeline-builder.d.ts +107 -0
  48. package/dist/pipeline/pipeline-builder.d.ts.map +1 -0
  49. package/dist/pipeline/pipeline-builder.js +181 -0
  50. package/dist/pipeline/sink.d.ts +22 -0
  51. package/dist/pipeline/sink.d.ts.map +1 -0
  52. package/dist/pipeline/sink.js +63 -0
  53. package/dist/pipeline/source.d.ts +20 -0
  54. package/dist/pipeline/source.d.ts.map +1 -0
  55. package/dist/pipeline/source.js +66 -0
  56. package/dist/pipeline/streams.d.ts +18 -0
  57. package/dist/pipeline/streams.d.ts.map +1 -0
  58. package/dist/pipeline/streams.js +115 -0
  59. package/dist/pipeline/types.d.ts +86 -0
  60. package/dist/pipeline/types.d.ts.map +1 -0
  61. package/dist/pipeline/types.js +4 -0
  62. package/dist/wordnet/index.d.ts +5 -0
  63. package/dist/wordnet/index.d.ts.map +1 -0
  64. package/dist/wordnet/index.js +4 -0
  65. package/dist/wordnet/turso-wordnet.d.ts +85 -0
  66. package/dist/wordnet/turso-wordnet.d.ts.map +1 -0
  67. package/dist/wordnet/turso-wordnet.js +107 -0
  68. package/package.json +80 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Francis Lee
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.
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Turso adapter interface
3
+ */
4
+ import type { Client } from '@libsql/client';
5
+ import type { TursoDatabaseConfig } from '../config.js';
6
+ /**
7
+ * Adapter status information
8
+ */
9
+ export interface TursoAdapterInfo {
10
+ /** Adapter mode */
11
+ mode: 'remote' | 'embedded';
12
+ /** Whether connected to database */
13
+ connected: boolean;
14
+ /** Sync status (for embedded mode) */
15
+ syncStatus?: 'synced' | 'pending' | 'error';
16
+ /** Last sync timestamp */
17
+ lastSync?: Date;
18
+ }
19
+ /**
20
+ * Turso adapter interface
21
+ * Provides abstraction over remote and embedded connection modes
22
+ */
23
+ export interface TursoAdapter {
24
+ /**
25
+ * Initialize the adapter with configuration
26
+ */
27
+ initialize(config: TursoDatabaseConfig): Promise<void>;
28
+ /**
29
+ * Get the underlying libsql client
30
+ */
31
+ getClient(): Client;
32
+ /**
33
+ * Get adapter information
34
+ */
35
+ getInfo(): TursoAdapterInfo;
36
+ /**
37
+ * Check if the adapter is connected
38
+ */
39
+ isConnected(): boolean;
40
+ /**
41
+ * Close the connection
42
+ */
43
+ close(): Promise<void>;
44
+ /**
45
+ * Get adapter name
46
+ */
47
+ getName(): string;
48
+ /**
49
+ * Sync with remote (for embedded mode)
50
+ */
51
+ sync?(): Promise<void>;
52
+ }
53
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mBAAmB;IACnB,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC5B,oCAAoC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;IAC5C,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,IAAI,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvD;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,IAAI,gBAAgB,CAAC;IAE5B;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;OAEG;IACH,OAAO,IAAI,MAAM,CAAC;IAElB;;OAEG;IACH,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Turso adapter interface
3
+ */
4
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Embedded Turso adapter - Local SQLite with sync
3
+ */
4
+ import { type Client } from '@libsql/client';
5
+ import type { TursoDatabaseConfig } from '../config.js';
6
+ import type { TursoAdapter, TursoAdapterInfo } from './adapter.js';
7
+ /**
8
+ * Embedded Turso adapter for local SQLite with optional sync
9
+ */
10
+ export declare class EmbeddedTursoAdapter implements TursoAdapter {
11
+ private client?;
12
+ private config?;
13
+ private connected;
14
+ private lastSync?;
15
+ private syncStatus;
16
+ initialize(config: TursoDatabaseConfig): Promise<void>;
17
+ getClient(): Client;
18
+ getInfo(): TursoAdapterInfo;
19
+ isConnected(): boolean;
20
+ close(): Promise<void>;
21
+ getName(): string;
22
+ sync(): Promise<void>;
23
+ }
24
+ //# sourceMappingURL=embedded-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedded-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/embedded-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEnE;;GAEG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,CAAsB;IACrC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAO;IACxB,OAAO,CAAC,UAAU,CAA6C;IAEzD,UAAU,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB5D,SAAS,IAAI,MAAM;IAOnB,OAAO,IAAI,gBAAgB;IAS3B,WAAW,IAAI,OAAO;IAIhB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAe5B,OAAO,IAAI,MAAM;IAIX,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAc5B"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Embedded Turso adapter - Local SQLite with sync
3
+ */
4
+ import { createClient } from '@libsql/client';
5
+ /**
6
+ * Embedded Turso adapter for local SQLite with optional sync
7
+ */
8
+ export class EmbeddedTursoAdapter {
9
+ client;
10
+ config;
11
+ connected = false;
12
+ lastSync;
13
+ syncStatus = 'pending';
14
+ async initialize(config) {
15
+ this.config = config;
16
+ // Create embedded replica client
17
+ this.client = createClient({
18
+ url: config.url, // Local file path: file:./local.db
19
+ syncUrl: config.syncUrl,
20
+ authToken: config.authToken,
21
+ encryptionKey: config.encryptionKey,
22
+ });
23
+ // Initial sync if sync URL is configured
24
+ if (config.syncUrl && config.authToken) {
25
+ await this.sync();
26
+ }
27
+ this.connected = true;
28
+ }
29
+ getClient() {
30
+ if (!this.client) {
31
+ throw new Error('Adapter not initialized');
32
+ }
33
+ return this.client;
34
+ }
35
+ getInfo() {
36
+ return {
37
+ mode: 'embedded',
38
+ connected: this.connected,
39
+ syncStatus: this.syncStatus,
40
+ lastSync: this.lastSync,
41
+ };
42
+ }
43
+ isConnected() {
44
+ return this.connected;
45
+ }
46
+ async close() {
47
+ if (this.client) {
48
+ // Sync before close if configured
49
+ if (this.config?.syncUrl) {
50
+ try {
51
+ await this.sync();
52
+ }
53
+ catch (error) {
54
+ console.warn('Failed to sync before close:', error);
55
+ }
56
+ }
57
+ this.client.close();
58
+ this.connected = false;
59
+ }
60
+ }
61
+ getName() {
62
+ return 'embedded-turso';
63
+ }
64
+ async sync() {
65
+ if (!this.client) {
66
+ throw new Error('Adapter not initialized');
67
+ }
68
+ try {
69
+ await this.client.sync();
70
+ this.lastSync = new Date();
71
+ this.syncStatus = 'synced';
72
+ }
73
+ catch (error) {
74
+ this.syncStatus = 'error';
75
+ throw error;
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Turso adapters
3
+ */
4
+ export { RemoteTursoAdapter } from './remote-adapter.js';
5
+ export { EmbeddedTursoAdapter } from './embedded-adapter.js';
6
+ export type { TursoAdapter, TursoAdapterInfo } from './adapter.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Turso adapters
3
+ */
4
+ export { RemoteTursoAdapter } from './remote-adapter.js';
5
+ export { EmbeddedTursoAdapter } from './embedded-adapter.js';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Remote Turso adapter - HTTP-only connection
3
+ */
4
+ import { type Client } from '@libsql/client';
5
+ import type { TursoDatabaseConfig } from '../config.js';
6
+ import type { TursoAdapter, TursoAdapterInfo } from './adapter.js';
7
+ /**
8
+ * Remote Turso adapter for HTTP-only connections
9
+ */
10
+ export declare class RemoteTursoAdapter implements TursoAdapter {
11
+ private client?;
12
+ private config?;
13
+ private connected;
14
+ initialize(config: TursoDatabaseConfig): Promise<void>;
15
+ getClient(): Client;
16
+ getInfo(): TursoAdapterInfo;
17
+ isConnected(): boolean;
18
+ close(): Promise<void>;
19
+ getName(): string;
20
+ }
21
+ //# sourceMappingURL=remote-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/remote-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEnE;;GAEG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,CAAsB;IACrC,OAAO,CAAC,SAAS,CAAS;IAEpB,UAAU,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB5D,SAAS,IAAI,MAAM;IAOnB,OAAO,IAAI,gBAAgB;IAO3B,WAAW,IAAI,OAAO;IAIhB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B,OAAO,IAAI,MAAM;CAGlB"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Remote Turso adapter - HTTP-only connection
3
+ */
4
+ import { createClient } from '@libsql/client';
5
+ /**
6
+ * Remote Turso adapter for HTTP-only connections
7
+ */
8
+ export class RemoteTursoAdapter {
9
+ client;
10
+ config;
11
+ connected = false;
12
+ async initialize(config) {
13
+ if (!config.authToken) {
14
+ throw new Error('authToken is required for remote Turso connections');
15
+ }
16
+ this.config = config;
17
+ this.client = createClient({
18
+ url: config.url,
19
+ authToken: config.authToken,
20
+ });
21
+ // Test connection
22
+ await this.client.execute('SELECT 1');
23
+ this.connected = true;
24
+ }
25
+ getClient() {
26
+ if (!this.client) {
27
+ throw new Error('Adapter not initialized');
28
+ }
29
+ return this.client;
30
+ }
31
+ getInfo() {
32
+ return {
33
+ mode: 'remote',
34
+ connected: this.connected,
35
+ };
36
+ }
37
+ isConnected() {
38
+ return this.connected;
39
+ }
40
+ async close() {
41
+ if (this.client) {
42
+ this.client.close();
43
+ this.connected = false;
44
+ }
45
+ }
46
+ getName() {
47
+ return 'remote-turso';
48
+ }
49
+ }
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * wn-turso CLI
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;GAEG"}
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * wn-turso CLI
4
+ */
5
+ import { parseArgs } from 'util';
6
+ async function main() {
7
+ const { values, positionals } = parseArgs({
8
+ allowPositionals: true,
9
+ options: {
10
+ help: { type: 'boolean', short: 'h' },
11
+ url: { type: 'string' },
12
+ token: { type: 'string', short: 't' },
13
+ input: { type: 'string', short: 'i' },
14
+ output: { type: 'string', short: 'o' },
15
+ verbose: { type: 'boolean', short: 'v' },
16
+ },
17
+ });
18
+ const command = positionals[0];
19
+ switch (command) {
20
+ case 'upload':
21
+ console.log('Upload command - not yet implemented');
22
+ console.log('Will upload a local SQLite database to Turso');
23
+ break;
24
+ case 'sync':
25
+ console.log('Sync command - not yet implemented');
26
+ console.log('Will sync an embedded replica with Turso cloud');
27
+ break;
28
+ case 'help':
29
+ default:
30
+ showHelp();
31
+ }
32
+ }
33
+ function showHelp() {
34
+ console.log(`
35
+ wn-turso - Turso database tools for WordNet
36
+
37
+ USAGE:
38
+ wn-turso <command> [options]
39
+
40
+ COMMANDS:
41
+ upload Upload local SQLite database to Turso
42
+ sync Sync embedded replica with Turso cloud
43
+ help Show this help
44
+
45
+ OPTIONS:
46
+ --url Turso database URL
47
+ --token Turso auth token
48
+ --input Input file path
49
+ --output Output file path
50
+ --verbose Enable verbose logging
51
+ --help Show this help
52
+
53
+ EXAMPLES:
54
+ wn-turso upload --url libsql://db.turso.io --token $TURSO_TOKEN --input ./wordnet.db
55
+ wn-turso sync --url file:./local.db --token $TURSO_TOKEN
56
+ `);
57
+ }
58
+ main().catch((error) => {
59
+ console.error('Error:', error.message);
60
+ process.exit(1);
61
+ });
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Turso database configuration
3
+ */
4
+ import type { BaseDatabaseConfig } from 'wn-ts-core/shared';
5
+ /**
6
+ * Connection mode for Turso
7
+ * - 'remote': HTTP-only connection to Turso cloud
8
+ * - 'embedded': Local SQLite replica with Turso sync
9
+ */
10
+ export type TursoConnectionMode = 'remote' | 'embedded';
11
+ /**
12
+ * Turso-specific database configuration
13
+ */
14
+ export interface TursoDatabaseConfig extends BaseDatabaseConfig {
15
+ /**
16
+ * Turso database URL
17
+ * - For remote: libsql://db-org.turso.io
18
+ * - For embedded: file:./local.db
19
+ */
20
+ url: string;
21
+ /**
22
+ * Auth token for Turso connection
23
+ * Required for remote connections and embedded sync
24
+ */
25
+ authToken?: string;
26
+ /**
27
+ * Connection mode
28
+ * - 'remote': HTTP-only connection to Turso cloud
29
+ * - 'embedded': Local SQLite with Turso sync
30
+ */
31
+ mode: TursoConnectionMode;
32
+ /**
33
+ * For embedded replicas: remote Turso URL to sync with
34
+ */
35
+ syncUrl?: string;
36
+ /**
37
+ * Sync interval in milliseconds (for embedded mode)
38
+ * Default: 0 (manual sync only)
39
+ */
40
+ syncInterval?: number;
41
+ /**
42
+ * Encryption key for embedded replicas
43
+ */
44
+ encryptionKey?: string;
45
+ /**
46
+ * Connection timeout in milliseconds
47
+ */
48
+ timeout?: number;
49
+ /**
50
+ * Enable foreign key constraints
51
+ */
52
+ enableForeignKeys?: boolean;
53
+ }
54
+ /**
55
+ * Sync configuration for embedded replicas
56
+ */
57
+ export interface SyncConfig {
58
+ /** Enable automatic sync */
59
+ autoSync: boolean;
60
+ /** Sync interval in ms */
61
+ interval: number;
62
+ /** Sync on startup */
63
+ syncOnStart: boolean;
64
+ /** Sync on close */
65
+ syncOnClose: boolean;
66
+ /** Maximum retry attempts */
67
+ maxRetries: number;
68
+ }
69
+ /**
70
+ * Default sync configuration
71
+ */
72
+ export declare const defaultSyncConfig: SyncConfig;
73
+ /**
74
+ * Validate Turso configuration
75
+ */
76
+ export declare function validateTursoConfig(config: TursoDatabaseConfig): void;
77
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,IAAI,EAAE,mBAAmB,CAAC;IAE1B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,4BAA4B;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,oBAAoB;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAM/B,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAsBrE"}
package/dist/config.js ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Turso database configuration
3
+ */
4
+ /**
5
+ * Default sync configuration
6
+ */
7
+ export const defaultSyncConfig = {
8
+ autoSync: false,
9
+ interval: 0,
10
+ syncOnStart: true,
11
+ syncOnClose: true,
12
+ maxRetries: 3,
13
+ };
14
+ /**
15
+ * Validate Turso configuration
16
+ */
17
+ export function validateTursoConfig(config) {
18
+ if (!config.url) {
19
+ throw new Error('Turso config: url is required');
20
+ }
21
+ if (config.mode === 'remote') {
22
+ if (!config.authToken) {
23
+ throw new Error('Turso config: authToken is required for remote mode');
24
+ }
25
+ if (!config.url.startsWith('libsql://') && !config.url.startsWith('https://')) {
26
+ throw new Error('Turso config: remote URL must start with libsql:// or https://');
27
+ }
28
+ }
29
+ if (config.mode === 'embedded') {
30
+ if (!config.url.startsWith('file:')) {
31
+ throw new Error('Turso config: embedded URL must start with file:');
32
+ }
33
+ if (config.syncUrl && !config.authToken) {
34
+ throw new Error('Turso config: authToken is required when syncUrl is provided');
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Database module exports
3
+ */
4
+ export { TursoDatabase } from './turso-database.js';
5
+ export { TursoQueryService } from './kysely-query-service.js';
6
+ export { createTursoDialect } from './turso-dialect.js';
7
+ export { TursoDriver } from './turso-driver.js';
8
+ export { TursoConnection } from './turso-connection.js';
9
+ export type { Database } from 'wn-ts-core/shared';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Database module exports
3
+ */
4
+ export { TursoDatabase } from './turso-database.js';
5
+ export { TursoQueryService } from './kysely-query-service.js';
6
+ export { createTursoDialect } from './turso-dialect.js';
7
+ export { TursoDriver } from './turso-driver.js';
8
+ export { TursoConnection } from './turso-connection.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Turso query service extending the shared BaseKyselyQueryService
3
+ */
4
+ import type { Kysely } from 'kysely';
5
+ import { BaseKyselyQueryService, type Database, type QueryStrategy } from 'wn-ts-core/shared';
6
+ export interface TursoQueryServiceOptions {
7
+ strategy?: QueryStrategy;
8
+ }
9
+ /**
10
+ * Turso-specific query service
11
+ * Inherits all query methods from BaseKyselyQueryService
12
+ */
13
+ export declare class TursoQueryService extends BaseKyselyQueryService {
14
+ constructor(db: Kysely<Database>, options?: TursoQueryServiceOptions);
15
+ /**
16
+ * Create all tables in the database
17
+ */
18
+ createTables(): Promise<void>;
19
+ /**
20
+ * Delete a lexicon and all its data
21
+ */
22
+ deleteLexicon(lexiconId: string): Promise<void>;
23
+ /**
24
+ * Delete all words for a lexicon
25
+ */
26
+ deleteWordsByLexicon(lexiconId: string): Promise<void>;
27
+ /**
28
+ * Delete all synsets for a lexicon
29
+ */
30
+ deleteSynsetsByLexicon(lexiconId: string): Promise<void>;
31
+ }
32
+ //# sourceMappingURL=kysely-query-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely-query-service.d.ts","sourceRoot":"","sources":["../../src/database/kysely-query-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EACL,sBAAsB,EAGtB,KAAK,QAAQ,EACb,KAAK,aAAa,EACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,sBAAsB;gBAC/C,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAIpE;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnC;;OAEG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD;;OAEG;IACG,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5D;;OAEG;IACG,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/D"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Turso query service extending the shared BaseKyselyQueryService
3
+ */
4
+ import { BaseKyselyQueryService, SchemaBuilder, DatabaseUtils, } from 'wn-ts-core/shared';
5
+ /**
6
+ * Turso-specific query service
7
+ * Inherits all query methods from BaseKyselyQueryService
8
+ */
9
+ export class TursoQueryService extends BaseKyselyQueryService {
10
+ constructor(db, options) {
11
+ super(db, options);
12
+ }
13
+ /**
14
+ * Create all tables in the database
15
+ */
16
+ async createTables() {
17
+ await SchemaBuilder.createTables(this.db);
18
+ await SchemaBuilder.migrateSchema(this.db);
19
+ await SchemaBuilder.createIndexes(this.db);
20
+ }
21
+ /**
22
+ * Delete a lexicon and all its data
23
+ */
24
+ async deleteLexicon(lexiconId) {
25
+ return DatabaseUtils.deleteLexicon(this.db, lexiconId);
26
+ }
27
+ /**
28
+ * Delete all words for a lexicon
29
+ */
30
+ async deleteWordsByLexicon(lexiconId) {
31
+ return DatabaseUtils.deleteWordsByLexicon(this.db, lexiconId);
32
+ }
33
+ /**
34
+ * Delete all synsets for a lexicon
35
+ */
36
+ async deleteSynsetsByLexicon(lexiconId) {
37
+ return DatabaseUtils.deleteSynsetsByLexicon(this.db, lexiconId);
38
+ }
39
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Turso/libsql Kysely connection implementation
3
+ */
4
+ import type { CompiledQuery, DatabaseConnection, QueryResult } from 'kysely';
5
+ import type { Client } from '@libsql/client';
6
+ /**
7
+ * Kysely DatabaseConnection implementation for Turso/libsql
8
+ */
9
+ export declare class TursoConnection implements DatabaseConnection {
10
+ private client;
11
+ constructor(client: Client);
12
+ executeQuery<O>(compiledQuery: CompiledQuery): Promise<QueryResult<O>>;
13
+ streamQuery<O>(): AsyncIterableIterator<QueryResult<O>>;
14
+ }
15
+ //# sourceMappingURL=turso-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turso-connection.d.ts","sourceRoot":"","sources":["../../src/database/turso-connection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAa,MAAM,gBAAgB,CAAC;AAExD;;GAEG;AACH,qBAAa,eAAgB,YAAW,kBAAkB;IACxD,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAIpB,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAkBrE,WAAW,CAAC,CAAC,KAAK,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAG/D"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Turso/libsql Kysely connection implementation
3
+ */
4
+ /**
5
+ * Kysely DatabaseConnection implementation for Turso/libsql
6
+ */
7
+ export class TursoConnection {
8
+ client;
9
+ constructor(client) {
10
+ this.client = client;
11
+ }
12
+ async executeQuery(compiledQuery) {
13
+ const { sql, parameters } = compiledQuery;
14
+ const result = await this.client.execute({
15
+ sql,
16
+ args: parameters,
17
+ });
18
+ return {
19
+ numAffectedRows: BigInt(result.rowsAffected),
20
+ insertId: result.lastInsertRowid !== undefined
21
+ ? BigInt(result.lastInsertRowid)
22
+ : undefined,
23
+ rows: result.rows,
24
+ };
25
+ }
26
+ async *streamQuery() {
27
+ throw new Error('Streaming queries not supported by libsql client');
28
+ }
29
+ }