@earth-app/collegedb 1.0.8 → 1.1.1
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/README.md +590 -132
- package/dist/durable.d.ts +8 -4
- package/dist/durable.d.ts.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +10 -9
- package/dist/kvmap.d.ts +68 -5
- package/dist/kvmap.d.ts.map +1 -1
- package/dist/migrations.d.ts +22 -19
- package/dist/migrations.d.ts.map +1 -1
- package/dist/providers.d.ts +284 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/router.d.ts +10 -10
- package/dist/router.d.ts.map +1 -1
- package/dist/types.d.ts +143 -14
- package/dist/types.d.ts.map +1 -1
- package/package.json +40 -16
package/dist/kvmap.d.ts
CHANGED
|
@@ -33,8 +33,7 @@
|
|
|
33
33
|
* @author Gregory Mitchell
|
|
34
34
|
* @since 1.0.0
|
|
35
35
|
*/
|
|
36
|
-
import type {
|
|
37
|
-
import type { CollegeDBConfig, ShardMapping } from './types.js';
|
|
36
|
+
import type { CollegeDBConfig, KVStorage, ShardMapping } from './types';
|
|
38
37
|
/**
|
|
39
38
|
* The KVShardMapper class provides a persistent storage layer for mapping
|
|
40
39
|
* primary keys to their assigned D1 database shards. It uses Cloudflare KV
|
|
@@ -67,7 +66,7 @@ import type { CollegeDBConfig, ShardMapping } from './types.js';
|
|
|
67
66
|
*/
|
|
68
67
|
export declare class KVShardMapper {
|
|
69
68
|
/**
|
|
70
|
-
*
|
|
69
|
+
* KV provider for storing mappings
|
|
71
70
|
* @readonly
|
|
72
71
|
*/
|
|
73
72
|
private readonly kv;
|
|
@@ -81,12 +80,57 @@ export declare class KVShardMapper {
|
|
|
81
80
|
* @private
|
|
82
81
|
*/
|
|
83
82
|
private readonly hashCache;
|
|
83
|
+
/**
|
|
84
|
+
* In-memory mapping cache to reduce repeated KV reads.
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private readonly mappingCache;
|
|
88
|
+
/**
|
|
89
|
+
* In-memory known shards cache.
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
private readonly knownShardsCache;
|
|
93
|
+
/**
|
|
94
|
+
* Mapping cache TTL in milliseconds.
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
private readonly mappingCacheTtlMs;
|
|
98
|
+
/**
|
|
99
|
+
* Known shards cache TTL in milliseconds.
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
private readonly knownShardsCacheTtlMs;
|
|
84
103
|
/**
|
|
85
104
|
* Creates a new KVShardMapper instance
|
|
86
|
-
* @param kv -
|
|
105
|
+
* @param kv - KV storage provider
|
|
87
106
|
* @param config - Configuration options including hashing preference
|
|
88
107
|
*/
|
|
89
|
-
constructor(kv:
|
|
108
|
+
constructor(kv: KVStorage, config?: Partial<Pick<CollegeDBConfig, 'hashShardMappings' | 'mappingCacheTtlMs' | 'knownShardsCacheTtlMs'>>);
|
|
109
|
+
/**
|
|
110
|
+
* Reads a mapping from the in-memory cache.
|
|
111
|
+
* @private
|
|
112
|
+
*/
|
|
113
|
+
private getCachedMapping;
|
|
114
|
+
/**
|
|
115
|
+
* Writes a mapping to the in-memory cache.
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
118
|
+
private setCachedMapping;
|
|
119
|
+
/**
|
|
120
|
+
* Updates mapping cache entries for the provided logical keys.
|
|
121
|
+
* @private
|
|
122
|
+
*/
|
|
123
|
+
private cacheMappingForKeys;
|
|
124
|
+
/**
|
|
125
|
+
* Retrieves known shards from cache when available.
|
|
126
|
+
* @private
|
|
127
|
+
*/
|
|
128
|
+
private getCachedKnownShards;
|
|
129
|
+
/**
|
|
130
|
+
* Stores known shards in the cache.
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
private setCachedKnownShards;
|
|
90
134
|
/**
|
|
91
135
|
* Hashes a key using SHA-256 if hashing is enabled
|
|
92
136
|
* @param key - The key to hash
|
|
@@ -294,6 +338,25 @@ export declare class KVShardMapper {
|
|
|
294
338
|
* @since 1.0.3
|
|
295
339
|
*/
|
|
296
340
|
addLookupKeys(primaryKey: string, additionalKeys: string[]): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Sets multiple shard mappings concurrently with a configurable concurrency limit.
|
|
343
|
+
*
|
|
344
|
+
* This helper is used by migration workflows to significantly reduce total
|
|
345
|
+
* mapping time while avoiding unbounded concurrency spikes.
|
|
346
|
+
*
|
|
347
|
+
* @param mappings - The mappings to create
|
|
348
|
+
* @param options - Batch execution options
|
|
349
|
+
* @param options.concurrency - Maximum concurrent set operations (default: 25)
|
|
350
|
+
* @returns Promise that resolves when all mappings are written
|
|
351
|
+
* @since 1.1.0
|
|
352
|
+
*/
|
|
353
|
+
setShardMappingsBatch(mappings: Array<{
|
|
354
|
+
primaryKey: string;
|
|
355
|
+
shard: string;
|
|
356
|
+
additionalKeys?: string[];
|
|
357
|
+
}>, options?: {
|
|
358
|
+
concurrency?: number;
|
|
359
|
+
}): Promise<void>;
|
|
297
360
|
/**
|
|
298
361
|
* Gets all lookup keys associated with a shard mapping. This is useful for
|
|
299
362
|
* understanding what keys resolve to the same shard.
|
package/dist/kvmap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kvmap.d.ts","sourceRoot":"","sources":["../src/kvmap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;
|
|
1
|
+
{"version":3,"file":"kvmap.d.ts","sourceRoot":"","sources":["../src/kvmap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAwB,YAAY,EAAE,MAAM,SAAS,CAAC;AAgD9F;;;;;;;;;;;;;;;;;;;;;;;;;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|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
18
|
-
* import { createSchema, migrateRecord, schemaExists } from './migrations
|
|
18
|
+
* import { createSchema, migrateRecord, schemaExists } from './migrations';
|
|
19
19
|
*
|
|
20
20
|
* // Create schema on a new shard
|
|
21
21
|
* await createSchema(env.DB_EAST);
|
|
@@ -30,9 +30,8 @@
|
|
|
30
30
|
* @author Gregory Mitchell
|
|
31
31
|
* @since 1.0.0
|
|
32
32
|
*/
|
|
33
|
-
import type {
|
|
34
|
-
import type {
|
|
35
|
-
import type { CollegeDBConfig, ShardingStrategy } from './types.js';
|
|
33
|
+
import type { KVShardMapper } from './kvmap';
|
|
34
|
+
import type { CollegeDBConfig, SQLDatabase, ShardingStrategy } from './types';
|
|
36
35
|
/**
|
|
37
36
|
* Executes SQL statements to create the default table structure and indexes
|
|
38
37
|
* in the specified D1 database. Supports custom schemas and handles SQL
|
|
@@ -60,7 +59,7 @@ import type { CollegeDBConfig, ShardingStrategy } from './types.js';
|
|
|
60
59
|
* await createSchema(env.DB_PRODUCTS, sql);
|
|
61
60
|
* ```
|
|
62
61
|
*/
|
|
63
|
-
export declare function createSchema(d1:
|
|
62
|
+
export declare function createSchema(d1: SQLDatabase, schema: string): Promise<void>;
|
|
64
63
|
/**
|
|
65
64
|
* Applies the schema to all provided D1 database instances in parallel.
|
|
66
65
|
* This is useful for initializing a complete sharded database system
|
|
@@ -91,7 +90,7 @@ export declare function createSchema(d1: D1Database, schema: string): Promise<vo
|
|
|
91
90
|
* }
|
|
92
91
|
* ```
|
|
93
92
|
*/
|
|
94
|
-
export declare function createSchemaAcrossShards(shards: Record<string,
|
|
93
|
+
export declare function createSchemaAcrossShards(shards: Record<string, SQLDatabase>, schema: string): Promise<void>;
|
|
95
94
|
/**
|
|
96
95
|
* Performs a lightweight check to determine if the expected schema is present
|
|
97
96
|
* in the database.
|
|
@@ -108,7 +107,7 @@ export declare function createSchemaAcrossShards(shards: Record<string, D1Databa
|
|
|
108
107
|
* }
|
|
109
108
|
* ```
|
|
110
109
|
*/
|
|
111
|
-
export declare function schemaExists(d1:
|
|
110
|
+
export declare function schemaExists(d1: SQLDatabase, table: string): Promise<boolean>;
|
|
112
111
|
/**
|
|
113
112
|
* Removes all tables that are part of the default CollegeDB schema from
|
|
114
113
|
* the specified database. This is a destructive operation that cannot be undone.
|
|
@@ -128,7 +127,7 @@ export declare function schemaExists(d1: D1Database, table: string): Promise<boo
|
|
|
128
127
|
* }
|
|
129
128
|
* ```
|
|
130
129
|
*/
|
|
131
|
-
export declare function dropSchema(d1:
|
|
130
|
+
export declare function dropSchema(d1: SQLDatabase, ...tables: string[]): Promise<void>;
|
|
132
131
|
/**
|
|
133
132
|
* Queries the SQLite system catalog to retrieve all user-created tables
|
|
134
133
|
* in the database. This is useful for schema inspection, validation,
|
|
@@ -149,7 +148,7 @@ export declare function dropSchema(d1: D1Database, ...tables: string[]): Promise
|
|
|
149
148
|
* }
|
|
150
149
|
* ```
|
|
151
150
|
*/
|
|
152
|
-
export declare function listTables(d1:
|
|
151
|
+
export declare function listTables(d1: SQLDatabase): Promise<string[]>;
|
|
153
152
|
/**
|
|
154
153
|
* Moves a single record from a source D1 database to a target D1 database.
|
|
155
154
|
* This is typically used during shard rebalancing operations when data needs
|
|
@@ -186,7 +185,7 @@ export declare function listTables(d1: D1Database): Promise<string[]>;
|
|
|
186
185
|
* await migrateRecord(source, target, 'post-456', 'posts');
|
|
187
186
|
* ```
|
|
188
187
|
*/
|
|
189
|
-
export declare function migrateRecord(source:
|
|
188
|
+
export declare function migrateRecord(source: SQLDatabase, target: SQLDatabase, primaryKey: string, tableName: string): Promise<void>;
|
|
190
189
|
/**
|
|
191
190
|
* Scans an existing table to find all primary keys that need to be mapped to shards.
|
|
192
191
|
* This is useful when integrating CollegeDB with an existing database that already
|
|
@@ -207,7 +206,7 @@ export declare function migrateRecord(source: D1Database, target: D1Database, pr
|
|
|
207
206
|
* const orderIds = await discoverExistingPrimaryKeys(env.DB_ORDERS, 'orders', 'order_id');
|
|
208
207
|
* ```
|
|
209
208
|
*/
|
|
210
|
-
export declare function discoverExistingPrimaryKeys(d1:
|
|
209
|
+
export declare function discoverExistingPrimaryKeys(d1: SQLDatabase, tableName: string, primaryKeyColumn?: string): Promise<string[]>;
|
|
211
210
|
/**
|
|
212
211
|
* Discovers existing records with additional columns for multi-key mapping support.
|
|
213
212
|
* Scans a table to find primary keys along with username, email, and name columns
|
|
@@ -229,7 +228,7 @@ export declare function discoverExistingPrimaryKeys(d1: D1Database, tableName: s
|
|
|
229
228
|
* ```
|
|
230
229
|
* @since 1.0.4
|
|
231
230
|
*/
|
|
232
|
-
export declare function discoverExistingRecordsWithColumns(d1:
|
|
231
|
+
export declare function discoverExistingRecordsWithColumns(d1: SQLDatabase, tableName: string, primaryKeyColumn?: string): Promise<Array<{
|
|
233
232
|
[key: string]: any;
|
|
234
233
|
}>>;
|
|
235
234
|
/**
|
|
@@ -245,7 +244,7 @@ export declare function discoverExistingRecordsWithColumns(d1: D1Database, table
|
|
|
245
244
|
* @throws {Error} If mapping creation fails
|
|
246
245
|
* @example
|
|
247
246
|
* ```typescript
|
|
248
|
-
* import { KVShardMapper } from './kvmap
|
|
247
|
+
* import { KVShardMapper } from './kvmap';
|
|
249
248
|
*
|
|
250
249
|
* const mapper = new KVShardMapper(env.KV);
|
|
251
250
|
* const existingIds = await discoverExistingPrimaryKeys(env.DB_EXISTING, 'users');
|
|
@@ -255,7 +254,9 @@ export declare function discoverExistingRecordsWithColumns(d1: D1Database, table
|
|
|
255
254
|
* console.log('All existing users mapped to shards');
|
|
256
255
|
* ```
|
|
257
256
|
*/
|
|
258
|
-
export declare function createMappingsForExistingKeys(primaryKeys: string[], shardBindings: string[], strategy: 'hash' | 'round-robin' | 'random', mapper:
|
|
257
|
+
export declare function createMappingsForExistingKeys(primaryKeys: string[], shardBindings: string[], strategy: 'hash' | 'round-robin' | 'random', mapper: KVShardMapper, options?: {
|
|
258
|
+
concurrency?: number;
|
|
259
|
+
}): Promise<void>;
|
|
259
260
|
/**
|
|
260
261
|
* Represents the result of validating a table for sharding.
|
|
261
262
|
* Contains information about the table structure, primary key, record count,
|
|
@@ -289,7 +290,7 @@ export type ValidationResult = {
|
|
|
289
290
|
* }
|
|
290
291
|
* ```
|
|
291
292
|
*/
|
|
292
|
-
export declare function validateTableForSharding(d1:
|
|
293
|
+
export declare function validateTableForSharding(d1: SQLDatabase, tableName: string, primaryKeyColumn: string): Promise<ValidationResult>;
|
|
293
294
|
/**
|
|
294
295
|
* Configuration options for integrating an existing database with CollegeDB.
|
|
295
296
|
* Allows customization of which tables to process, primary key column,
|
|
@@ -302,6 +303,7 @@ export type IntegrationOptions = {
|
|
|
302
303
|
addShardMappingsTable?: boolean;
|
|
303
304
|
dryRun?: boolean;
|
|
304
305
|
migrateOtherColumns?: boolean;
|
|
306
|
+
concurrency?: number;
|
|
305
307
|
};
|
|
306
308
|
/**
|
|
307
309
|
* Represents the result of integrating an existing database with CollegeDB.
|
|
@@ -336,7 +338,7 @@ export type IntegrationResult = {
|
|
|
336
338
|
* @throws {Error} If integration fails
|
|
337
339
|
* @example
|
|
338
340
|
* ```typescript
|
|
339
|
-
* import { KVShardMapper } from './kvmap
|
|
341
|
+
* import { KVShardMapper } from './kvmap';
|
|
340
342
|
*
|
|
341
343
|
* const mapper = new KVShardMapper(env.KV);
|
|
342
344
|
* const result = await integrateExistingDatabase(env.DB_EXISTING, 'db-existing', mapper, {
|
|
@@ -350,7 +352,7 @@ export type IntegrationResult = {
|
|
|
350
352
|
* // Now users can be looked up by username:john, email:john@example.com, or name:John Doe
|
|
351
353
|
* ```
|
|
352
354
|
*/
|
|
353
|
-
export declare function integrateExistingDatabase(d1:
|
|
355
|
+
export declare function integrateExistingDatabase(d1: SQLDatabase, shardName: string, mapper: KVShardMapper, options?: IntegrationOptions): Promise<IntegrationResult>;
|
|
354
356
|
/**
|
|
355
357
|
* Automatically detects if a database needs migration and performs it
|
|
356
358
|
*
|
|
@@ -384,12 +386,13 @@ export declare function integrateExistingDatabase(d1: D1Database, shardName: str
|
|
|
384
386
|
* }
|
|
385
387
|
* ```
|
|
386
388
|
*/
|
|
387
|
-
export declare function autoDetectAndMigrate(d1:
|
|
389
|
+
export declare function autoDetectAndMigrate(d1: SQLDatabase, shardName: string, config: CollegeDBConfig, options?: {
|
|
388
390
|
primaryKeyColumn?: string;
|
|
389
391
|
tablesToCheck?: string[];
|
|
390
392
|
skipCache?: boolean;
|
|
391
393
|
maxRecordsToCheck?: number;
|
|
392
394
|
migrateOtherColumns?: boolean;
|
|
395
|
+
concurrency?: number;
|
|
393
396
|
}): Promise<{
|
|
394
397
|
migrationNeeded: boolean;
|
|
395
398
|
migrationPerformed: boolean;
|
|
@@ -414,7 +417,7 @@ export declare function autoDetectAndMigrate(d1: D1Database, shardName: string,
|
|
|
414
417
|
* }
|
|
415
418
|
* ```
|
|
416
419
|
*/
|
|
417
|
-
export declare function checkMigrationNeeded(d1:
|
|
420
|
+
export declare function checkMigrationNeeded(d1: SQLDatabase, shardName: string, config: CollegeDBConfig): Promise<boolean>;
|
|
418
421
|
/**
|
|
419
422
|
* Clears the migration status cache
|
|
420
423
|
*
|
package/dist/migrations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAuE9E;;;;;;;;;;;;;;;;;;;;;;;;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E"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Provider adapters for non-Cloudflare backends.
|
|
3
|
+
*
|
|
4
|
+
* This module defines maintainable adapter factories that allow CollegeDB to run
|
|
5
|
+
* on multiple storage backends while preserving Cloudflare compatibility.
|
|
6
|
+
*
|
|
7
|
+
* Supported KV backends:
|
|
8
|
+
* - Cloudflare KV (native shape)
|
|
9
|
+
* - Redis
|
|
10
|
+
* - Valkey
|
|
11
|
+
* - NuxtHub KV / Unstorage-compatible clients
|
|
12
|
+
*
|
|
13
|
+
* Supported SQL backends:
|
|
14
|
+
* - Cloudflare D1 (native shape)
|
|
15
|
+
* - PostgreSQL compatible clients
|
|
16
|
+
* - MySQL / MariaDB compatible clients
|
|
17
|
+
* - SQLite clients
|
|
18
|
+
* - Drizzle ORM database instances
|
|
19
|
+
* - Hyperdrive-backed PostgreSQL / MySQL clients
|
|
20
|
+
*
|
|
21
|
+
* @author CollegeDB Team
|
|
22
|
+
* @since 1.1.0
|
|
23
|
+
*/
|
|
24
|
+
import type { KVStorage, SQLDatabase } from './types';
|
|
25
|
+
/**
|
|
26
|
+
* Minimal Redis/Valkey client contract used by the KV adapter.
|
|
27
|
+
*/
|
|
28
|
+
export interface RedisLikeClient {
|
|
29
|
+
get(key: string): Promise<string | null>;
|
|
30
|
+
set(key: string, value: string): Promise<unknown>;
|
|
31
|
+
del(key: string): Promise<unknown>;
|
|
32
|
+
scan(cursor: string, ...args: any[]): Promise<RedisScanResult>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Redis/Valkey SCAN response in ioredis tuple form.
|
|
36
|
+
*/
|
|
37
|
+
export type RedisScanTupleResult = [string, string[]];
|
|
38
|
+
/**
|
|
39
|
+
* Redis/Valkey SCAN response in node-redis object form.
|
|
40
|
+
*/
|
|
41
|
+
export interface RedisScanObjectResult {
|
|
42
|
+
cursor: string | number;
|
|
43
|
+
keys: string[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Accepted SCAN response formats.
|
|
47
|
+
*/
|
|
48
|
+
export type RedisScanResult = RedisScanTupleResult | RedisScanObjectResult;
|
|
49
|
+
/**
|
|
50
|
+
* PostgreSQL result shape used by adapters.
|
|
51
|
+
*/
|
|
52
|
+
export interface PostgresQueryResult<T = Record<string, unknown>> {
|
|
53
|
+
rows: T[];
|
|
54
|
+
rowCount?: number | null;
|
|
55
|
+
command?: string;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Minimal PostgreSQL client contract used by the SQL adapter.
|
|
60
|
+
*/
|
|
61
|
+
export interface PostgresClientLike {
|
|
62
|
+
query<T = Record<string, unknown>>(sql: string, bindings?: any[]): Promise<PostgresQueryResult<T>>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Optional lifecycle methods used by Hyperdrive helpers.
|
|
66
|
+
*/
|
|
67
|
+
export interface PostgresLifecycleClientLike extends PostgresClientLike {
|
|
68
|
+
connect?: () => Promise<void>;
|
|
69
|
+
end?: () => Promise<void>;
|
|
70
|
+
release?: () => void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* MySQL/MariaDB OK packet shape.
|
|
74
|
+
*/
|
|
75
|
+
export interface MySQLOkPacket {
|
|
76
|
+
affectedRows?: number;
|
|
77
|
+
insertId?: number;
|
|
78
|
+
warningStatus?: number;
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Minimal MySQL/MariaDB client contract used by adapters.
|
|
83
|
+
*/
|
|
84
|
+
export interface MySQLClientLike {
|
|
85
|
+
execute?: (sql: string, bindings?: any[]) => Promise<[unknown, unknown]>;
|
|
86
|
+
query?: (sql: string, bindings?: any[]) => Promise<[unknown, unknown]>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Optional lifecycle methods used by Hyperdrive helpers.
|
|
90
|
+
*/
|
|
91
|
+
export interface MySQLLifecycleClientLike extends MySQLClientLike {
|
|
92
|
+
end?: () => Promise<void>;
|
|
93
|
+
close?: () => Promise<void>;
|
|
94
|
+
destroy?: () => void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Statement contract for SQLite adapters.
|
|
98
|
+
*/
|
|
99
|
+
export interface SQLiteStatementLike {
|
|
100
|
+
run?: (...bindings: any[]) => unknown | Promise<unknown>;
|
|
101
|
+
all?: (...bindings: any[]) => unknown[] | Promise<unknown[]>;
|
|
102
|
+
get?: (...bindings: any[]) => unknown | Promise<unknown>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Minimal SQLite client contract used by adapters.
|
|
106
|
+
*/
|
|
107
|
+
export interface SQLiteClientLike {
|
|
108
|
+
prepare?: (sql: string) => SQLiteStatementLike;
|
|
109
|
+
execute?: (sql: string, bindings?: any[]) => Promise<unknown>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Hyperdrive binding shape used by helper factories.
|
|
113
|
+
*/
|
|
114
|
+
export interface HyperdriveBindingLike {
|
|
115
|
+
connectionString: string;
|
|
116
|
+
localConnectionString?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Factory for creating PostgreSQL clients from a Hyperdrive connection string.
|
|
120
|
+
*/
|
|
121
|
+
export type HyperdrivePostgresClientFactory = (connectionString: string) => PostgresLifecycleClientLike;
|
|
122
|
+
/**
|
|
123
|
+
* Factory for creating MySQL clients from a Hyperdrive connection string.
|
|
124
|
+
*/
|
|
125
|
+
export type HyperdriveMySQLClientFactory = (connectionString: string) => MySQLLifecycleClientLike;
|
|
126
|
+
/**
|
|
127
|
+
* Minimal SQL chunk contract produced by Drizzle's `sql` helper.
|
|
128
|
+
*/
|
|
129
|
+
export interface DrizzleSqlChunkLike {
|
|
130
|
+
append(chunk: DrizzleSqlChunkLike): void;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Minimal Drizzle `sql` tag contract used to build parameterized raw statements.
|
|
134
|
+
*/
|
|
135
|
+
export interface DrizzleSqlTagLike {
|
|
136
|
+
(strings: TemplateStringsArray, ...params: any[]): DrizzleSqlChunkLike;
|
|
137
|
+
raw(sql: string): DrizzleSqlChunkLike;
|
|
138
|
+
empty?: () => DrizzleSqlChunkLike;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Minimal Drizzle database contract used by the SQL adapter.
|
|
142
|
+
*/
|
|
143
|
+
export interface DrizzleClientLike {
|
|
144
|
+
execute?: (query: unknown) => Promise<unknown>;
|
|
145
|
+
run?: (query: unknown) => Promise<unknown>;
|
|
146
|
+
all?: (query: unknown) => Promise<unknown>;
|
|
147
|
+
get?: (query: unknown) => Promise<unknown>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* NuxtHub/Unstorage-like KV contract used by the adapter.
|
|
151
|
+
*/
|
|
152
|
+
export interface NuxtHubKVLike {
|
|
153
|
+
get?<T = unknown>(key: string): Promise<T | null | undefined>;
|
|
154
|
+
set?(key: string, value: unknown, options?: {
|
|
155
|
+
ttl?: number;
|
|
156
|
+
}): Promise<unknown>;
|
|
157
|
+
del?(key: string): Promise<unknown>;
|
|
158
|
+
keys?(prefix?: string): Promise<string[]>;
|
|
159
|
+
getItem?<T = unknown>(key: string): Promise<T | null | undefined>;
|
|
160
|
+
setItem?(key: string, value: unknown): Promise<unknown>;
|
|
161
|
+
removeItem?(key: string): Promise<unknown>;
|
|
162
|
+
getKeys?(prefix?: string): Promise<string[]>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Creates a Redis-backed KV provider adapter.
|
|
166
|
+
*
|
|
167
|
+
* The adapter supports both node-redis and ioredis scan formats.
|
|
168
|
+
*
|
|
169
|
+
* @param client - Redis/Valkey client
|
|
170
|
+
* @param options - Adapter tuning options
|
|
171
|
+
* @returns KVStorage-compatible adapter
|
|
172
|
+
*/
|
|
173
|
+
export declare function createRedisKVProvider(client: RedisLikeClient, options?: {
|
|
174
|
+
scanCount?: number;
|
|
175
|
+
}): KVStorage;
|
|
176
|
+
/**
|
|
177
|
+
* Creates a Valkey-backed KV provider adapter.
|
|
178
|
+
*
|
|
179
|
+
* Valkey and Redis have compatible command surfaces for this adapter.
|
|
180
|
+
*
|
|
181
|
+
* @param client - Valkey client
|
|
182
|
+
* @param options - Adapter tuning options
|
|
183
|
+
* @returns KVStorage-compatible adapter
|
|
184
|
+
*/
|
|
185
|
+
export declare function createValkeyKVProvider(client: RedisLikeClient, options?: {
|
|
186
|
+
scanCount?: number;
|
|
187
|
+
}): KVStorage;
|
|
188
|
+
/**
|
|
189
|
+
* Creates a PostgreSQL adapter implementing CollegeDB's SQL contract.
|
|
190
|
+
*
|
|
191
|
+
* Supports `pg` Client, Pool, and compatible implementations.
|
|
192
|
+
* SQL using `?` placeholders is automatically rewritten to `$1..$n`.
|
|
193
|
+
*
|
|
194
|
+
* For Drizzle-backed PostgreSQL clients, pass the Drizzle DB instance as
|
|
195
|
+
* `client` and the Drizzle `sql` helper as the second argument.
|
|
196
|
+
*
|
|
197
|
+
* @param client - PostgreSQL client/pool
|
|
198
|
+
* @param sqlTag - Optional Drizzle `sql` helper for Drizzle interop
|
|
199
|
+
* @returns SQLDatabase-compatible adapter
|
|
200
|
+
*/
|
|
201
|
+
export declare function createPostgreSQLProvider(client: PostgresClientLike): SQLDatabase;
|
|
202
|
+
export declare function createPostgreSQLProvider(client: DrizzleClientLike, sqlTag: DrizzleSqlTagLike): SQLDatabase;
|
|
203
|
+
/**
|
|
204
|
+
* Creates a MySQL/MariaDB adapter implementing CollegeDB's SQL contract.
|
|
205
|
+
*
|
|
206
|
+
* Supports mysql2/promise clients, pools, and compatible wrappers.
|
|
207
|
+
*
|
|
208
|
+
* For Drizzle-backed MySQL/MariaDB clients, pass the Drizzle DB instance as
|
|
209
|
+
* `client` and the Drizzle `sql` helper as the second argument.
|
|
210
|
+
*
|
|
211
|
+
* @param client - MySQL/MariaDB client or pool
|
|
212
|
+
* @param sqlTag - Optional Drizzle `sql` helper for Drizzle interop
|
|
213
|
+
* @returns SQLDatabase-compatible adapter
|
|
214
|
+
*/
|
|
215
|
+
export declare function createMySQLProvider(client: MySQLClientLike): SQLDatabase;
|
|
216
|
+
export declare function createMySQLProvider(client: DrizzleClientLike, sqlTag: DrizzleSqlTagLike): SQLDatabase;
|
|
217
|
+
/**
|
|
218
|
+
* Creates a SQLite adapter implementing CollegeDB's SQL contract.
|
|
219
|
+
*
|
|
220
|
+
* Supports both execute-style clients and prepare/run/get/all statement clients.
|
|
221
|
+
*
|
|
222
|
+
* For Drizzle-backed SQLite/D1 clients, pass the Drizzle DB instance as
|
|
223
|
+
* `client` and the Drizzle `sql` helper as the second argument.
|
|
224
|
+
*
|
|
225
|
+
* @param client - SQLite client
|
|
226
|
+
* @param sqlTag - Optional Drizzle `sql` helper for Drizzle interop
|
|
227
|
+
* @returns SQLDatabase-compatible adapter
|
|
228
|
+
*/
|
|
229
|
+
export declare function createSQLiteProvider(client: SQLiteClientLike): SQLDatabase;
|
|
230
|
+
export declare function createSQLiteProvider(client: DrizzleClientLike, sqlTag: DrizzleSqlTagLike): SQLDatabase;
|
|
231
|
+
/**
|
|
232
|
+
* Creates a Drizzle-backed SQL adapter implementing CollegeDB's SQL contract.
|
|
233
|
+
*
|
|
234
|
+
* This adapter enables using Drizzle database instances (including NuxtHub's
|
|
235
|
+
* `db` from `@nuxthub/db` or `hub:db`) as shard providers while CollegeDB keeps
|
|
236
|
+
* query routing and key->shard mapping responsibilities.
|
|
237
|
+
*
|
|
238
|
+
* @param client - Drizzle database instance
|
|
239
|
+
* @param sqlTag - Drizzle `sql` helper from `drizzle-orm`
|
|
240
|
+
* @returns SQLDatabase-compatible adapter
|
|
241
|
+
*/
|
|
242
|
+
export declare function createDrizzleSQLProvider(client: DrizzleClientLike, sqlTag: DrizzleSqlTagLike): SQLDatabase;
|
|
243
|
+
/**
|
|
244
|
+
* Creates a NuxtHub KV adapter implementing CollegeDB's KV contract.
|
|
245
|
+
*
|
|
246
|
+
* Supports both `@nuxthub/kv` (`get/set/del/keys`) and unstorage-like
|
|
247
|
+
* implementations (`getItem/setItem/removeItem/getKeys`).
|
|
248
|
+
*
|
|
249
|
+
* @param client - NuxtHub KV/Unstorage-like client
|
|
250
|
+
* @returns KVStorage-compatible adapter
|
|
251
|
+
*/
|
|
252
|
+
export declare function createNuxtHubKVProvider(client: NuxtHubKVLike): KVStorage;
|
|
253
|
+
/**
|
|
254
|
+
* Creates a PostgreSQL adapter wired to a Hyperdrive binding.
|
|
255
|
+
*
|
|
256
|
+
* The returned provider creates a transient client for each statement execution.
|
|
257
|
+
* Hyperdrive handles connection pooling at the edge, so this pattern remains fast
|
|
258
|
+
* and scalable in Workers.
|
|
259
|
+
*
|
|
260
|
+
* @param hyperdrive - Hyperdrive binding
|
|
261
|
+
* @param clientFactory - Client factory (e.g. `connectionString => new Client({ connectionString })`)
|
|
262
|
+
* @returns SQLDatabase-compatible adapter
|
|
263
|
+
*/
|
|
264
|
+
export declare function createHyperdrivePostgresProvider(hyperdrive: HyperdriveBindingLike, clientFactory: HyperdrivePostgresClientFactory): SQLDatabase;
|
|
265
|
+
/**
|
|
266
|
+
* Creates a MySQL/MariaDB adapter wired to a Hyperdrive binding.
|
|
267
|
+
*
|
|
268
|
+
* The returned provider creates a transient client for each statement execution.
|
|
269
|
+
* Hyperdrive handles connection pooling under the hood.
|
|
270
|
+
*
|
|
271
|
+
* @param hyperdrive - Hyperdrive binding
|
|
272
|
+
* @param clientFactory - Client factory (e.g. `connectionString => mysql.createConnection(connectionString)`)
|
|
273
|
+
* @returns SQLDatabase-compatible adapter
|
|
274
|
+
*/
|
|
275
|
+
export declare function createHyperdriveMySQLProvider(hyperdrive: HyperdriveBindingLike, clientFactory: HyperdriveMySQLClientFactory): SQLDatabase;
|
|
276
|
+
/**
|
|
277
|
+
* Returns `true` when a value looks like an SQL database provider.
|
|
278
|
+
*/
|
|
279
|
+
export declare function isSQLDatabase(value: unknown): value is SQLDatabase;
|
|
280
|
+
/**
|
|
281
|
+
* Returns `true` when a value looks like a KV storage provider.
|
|
282
|
+
*/
|
|
283
|
+
export declare function isKVStorage(value: unknown): value is KVStorage;
|
|
284
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAgB,SAAS,EAAmD,WAAW,EAAE,MAAM,SAAS,CAAC;AAIrH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,EAAE,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,qBAAqB,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAA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