@earth-app/collegedb 1.0.2 → 1.0.4
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 +183 -33
- package/dist/index.js +7 -7
- package/dist/index.js.map +5 -5
- package/dist/kvmap.d.ts +80 -26
- package/dist/kvmap.d.ts.map +1 -1
- package/dist/migrations.d.ts +40 -2
- package/dist/migrations.d.ts.map +1 -1
- package/dist/router.d.ts +39 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/kvmap.d.ts
CHANGED
|
@@ -8,19 +8,21 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Key features:
|
|
10
10
|
* - Primary key to shard mapping storage and retrieval
|
|
11
|
+
* - Multiple lookup keys for the same shard mapping (e.g., username, email, id)
|
|
12
|
+
* - SHA-256 hashing of keys for security and privacy (enabled by default)
|
|
11
13
|
* - Shard discovery and management
|
|
12
14
|
* - Key counting and statistics for load balancing
|
|
13
15
|
* - Batch operations for efficient KV usage
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
16
18
|
* ```typescript
|
|
17
|
-
* const mapper = new KVShardMapper(env.KV);
|
|
19
|
+
* const mapper = new KVShardMapper(env.KV, { hashShardMappings: true });
|
|
18
20
|
*
|
|
19
|
-
* // Set a mapping
|
|
20
|
-
* await mapper.setShardMapping('user-123', 'db-east');
|
|
21
|
+
* // Set a mapping with multiple lookup keys
|
|
22
|
+
* await mapper.setShardMapping('user-123', 'db-east', ['username:john', 'email:john@example.com', 'id:123']);
|
|
21
23
|
*
|
|
22
|
-
* // Get a mapping
|
|
23
|
-
* const mapping = await mapper.getShardMapping('
|
|
24
|
+
* // Get a mapping by any of the keys
|
|
25
|
+
* const mapping = await mapper.getShardMapping('email:john@example.com');
|
|
24
26
|
* console.log(mapping?.shard); // 'db-east'
|
|
25
27
|
*
|
|
26
28
|
* // Get statistics
|
|
@@ -32,7 +34,7 @@
|
|
|
32
34
|
* @since 1.0.0
|
|
33
35
|
*/
|
|
34
36
|
import type { KVNamespace } from '@cloudflare/workers-types';
|
|
35
|
-
import type { ShardMapping } from './types.js';
|
|
37
|
+
import type { CollegeDBConfig, ShardMapping } from './types.js';
|
|
36
38
|
/**
|
|
37
39
|
* The KVShardMapper class provides a persistent storage layer for mapping
|
|
38
40
|
* primary keys to their assigned D1 database shards. It uses Cloudflare KV
|
|
@@ -40,49 +42,68 @@ import type { ShardMapping } from './types.js';
|
|
|
40
42
|
*
|
|
41
43
|
* Features:
|
|
42
44
|
* - CRUD operations for shard mappings
|
|
45
|
+
* - Multiple lookup keys for the same shard (username, email, id, etc.)
|
|
46
|
+
* - SHA-256 hashing of keys for security and privacy
|
|
43
47
|
* - Atomic updates with timestamp tracking
|
|
44
48
|
* - Efficient bulk operations and statistics
|
|
45
49
|
* - Prefix-based key organization for performance
|
|
46
50
|
*
|
|
47
51
|
* @example
|
|
48
52
|
* ```typescript
|
|
49
|
-
* const mapper = new KVShardMapper(env.KV);
|
|
53
|
+
* const mapper = new KVShardMapper(env.KV, { hashShardMappings: true });
|
|
50
54
|
*
|
|
51
|
-
* // Create a new mapping
|
|
52
|
-
* await mapper.setShardMapping('
|
|
55
|
+
* // Create a new mapping with multiple lookup keys
|
|
56
|
+
* await mapper.setShardMapping('primary-key-123', 'db-central', ['username:john', 'email:john@example.com']);
|
|
53
57
|
*
|
|
54
58
|
* // Update an existing mapping
|
|
55
|
-
* await mapper.updateShardMapping('
|
|
59
|
+
* await mapper.updateShardMapping('username:john', 'db-west');
|
|
56
60
|
*
|
|
57
|
-
* // Query mapping
|
|
58
|
-
* const mapping = await mapper.getShardMapping('
|
|
61
|
+
* // Query mapping by any key
|
|
62
|
+
* const mapping = await mapper.getShardMapping('email:john@example.com');
|
|
59
63
|
* if (mapping) {
|
|
60
|
-
* console.log(`
|
|
64
|
+
* console.log(`User is on ${mapping.shard}`);
|
|
61
65
|
* }
|
|
62
66
|
* ```
|
|
63
67
|
*/
|
|
64
68
|
export declare class KVShardMapper {
|
|
65
|
-
private kv;
|
|
66
69
|
/**
|
|
67
70
|
* Cloudflare KV namespace for storing mappings
|
|
68
71
|
* @readonly
|
|
69
72
|
*/
|
|
70
|
-
|
|
73
|
+
private readonly kv;
|
|
74
|
+
/**
|
|
75
|
+
* Whether to hash mapping keys with SHA-256
|
|
76
|
+
* @readonly
|
|
77
|
+
*/
|
|
78
|
+
private readonly hashKeys;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a new KVShardMapper instance
|
|
81
|
+
* @param kv - Cloudflare KV namespace
|
|
82
|
+
* @param config - Configuration options including hashing preference
|
|
83
|
+
*/
|
|
84
|
+
constructor(kv: KVNamespace, config?: Partial<Pick<CollegeDBConfig, 'hashShardMappings'>>);
|
|
85
|
+
/**
|
|
86
|
+
* Hashes a key using SHA-256 if hashing is enabled
|
|
87
|
+
* @private
|
|
88
|
+
* @param key - The key to hash
|
|
89
|
+
* @returns The hashed key or original key if hashing is disabled
|
|
90
|
+
*/
|
|
91
|
+
private hashKey;
|
|
71
92
|
/**
|
|
72
93
|
* Retrieves the shard assignment for a given primary key from KV storage.
|
|
73
94
|
* Returns null if no mapping exists, indicating the key has not been
|
|
74
|
-
* assigned to any shard yet.
|
|
75
|
-
* @param primaryKey - The primary key to look up
|
|
95
|
+
* assigned to any shard yet. Supports both single-key and multi-key lookups.
|
|
96
|
+
* @param primaryKey - The primary key to look up (will be hashed if hashing is enabled)
|
|
76
97
|
* @returns Promise resolving to the shard mapping or null if not found
|
|
77
98
|
* @throws {Error} If KV read operation fails
|
|
78
99
|
* @example
|
|
79
100
|
* ```typescript
|
|
80
|
-
* const mapping = await mapper.getShardMapping('user
|
|
101
|
+
* const mapping = await mapper.getShardMapping('email:user@example.com');
|
|
81
102
|
* if (mapping) {
|
|
82
|
-
* console.log(`User
|
|
103
|
+
* console.log(`User is on shard: ${mapping.shard}`);
|
|
83
104
|
* console.log(`Created: ${new Date(mapping.createdAt)}`);
|
|
84
105
|
* } else {
|
|
85
|
-
* console.log('User
|
|
106
|
+
* console.log('User not yet assigned to any shard');
|
|
86
107
|
* }
|
|
87
108
|
* ```
|
|
88
109
|
*/
|
|
@@ -96,21 +117,23 @@ export declare class KVShardMapper {
|
|
|
96
117
|
* Use updateShardMapping() if you want to preserve creation timestamp.
|
|
97
118
|
* @param primaryKey - The primary key to map
|
|
98
119
|
* @param shard - The shard binding name to assign
|
|
120
|
+
* @param additionalKeys - Optional array of additional lookup keys for the same mapping
|
|
99
121
|
* @returns Promise that resolves when the mapping is stored
|
|
100
122
|
* @throws {Error} If KV write operation fails
|
|
101
123
|
* @example
|
|
102
124
|
* ```typescript
|
|
103
|
-
* // Assign a new user to the west coast shard
|
|
104
|
-
* await mapper.setShardMapping('user-
|
|
125
|
+
* // Assign a new user to the west coast shard with multiple lookup keys
|
|
126
|
+
* await mapper.setShardMapping('user-123', 'db-west', ['username:john', 'email:john@example.com']);
|
|
105
127
|
* ```
|
|
106
128
|
*/
|
|
107
|
-
setShardMapping(primaryKey: string, shard: string): Promise<void>;
|
|
129
|
+
setShardMapping(primaryKey: string, shard: string, additionalKeys?: string[]): Promise<void>;
|
|
108
130
|
/**
|
|
109
131
|
* Changes the shard assignment for a primary key that already has a mapping.
|
|
110
132
|
* Preserves the original creation timestamp while updating the modified
|
|
111
133
|
* timestamp. Throws an error if no existing mapping is found.
|
|
112
134
|
*
|
|
113
135
|
* This is typically used during shard rebalancing or data migration operations.
|
|
136
|
+
* Works with both single-key and multi-key mappings.
|
|
114
137
|
* @param primaryKey - The primary key to update
|
|
115
138
|
* @param newShard - The new shard binding name to assign
|
|
116
139
|
* @returns Promise that resolves when the mapping is updated
|
|
@@ -119,7 +142,7 @@ export declare class KVShardMapper {
|
|
|
119
142
|
* ```typescript
|
|
120
143
|
* try {
|
|
121
144
|
* // Move user to a different shard for rebalancing
|
|
122
|
-
* await mapper.updateShardMapping('user
|
|
145
|
+
* await mapper.updateShardMapping('email:user@example.com', 'db-central');
|
|
123
146
|
* console.log('User successfully moved to central shard');
|
|
124
147
|
* } catch (error) {
|
|
125
148
|
* console.error('Failed to update mapping:', error.message);
|
|
@@ -130,7 +153,7 @@ export declare class KVShardMapper {
|
|
|
130
153
|
/**
|
|
131
154
|
* Completely removes the shard assignment for a primary key from KV storage.
|
|
132
155
|
* This is typically used when data is being permanently deleted or when
|
|
133
|
-
* cleaning up orphaned mappings.
|
|
156
|
+
* cleaning up orphaned mappings. Handles both single-key and multi-key mappings.
|
|
134
157
|
*
|
|
135
158
|
* **WARNING**: After deletion, the primary key will be treated as new
|
|
136
159
|
* and may be assigned to a different shard on next access.
|
|
@@ -141,7 +164,7 @@ export declare class KVShardMapper {
|
|
|
141
164
|
* @example
|
|
142
165
|
* ```typescript
|
|
143
166
|
* // Remove mapping for deleted user
|
|
144
|
-
* await mapper.deleteShardMapping('
|
|
167
|
+
* await mapper.deleteShardMapping('email:deleted@example.com');
|
|
145
168
|
* console.log('Mapping removed for deleted user');
|
|
146
169
|
* ```
|
|
147
170
|
*/
|
|
@@ -251,5 +274,36 @@ export declare class KVShardMapper {
|
|
|
251
274
|
* ```
|
|
252
275
|
*/
|
|
253
276
|
clearAllMappings(): Promise<void>;
|
|
277
|
+
/**
|
|
278
|
+
* Adds additional lookup keys to an existing shard mapping. This allows you to
|
|
279
|
+
* query the same shard mapping using multiple identifiers (e.g., username, email, id).
|
|
280
|
+
*
|
|
281
|
+
* @param primaryKey - An existing key in the mapping
|
|
282
|
+
* @param additionalKeys - New keys to add for lookup
|
|
283
|
+
* @returns Promise that resolves when the additional keys are added
|
|
284
|
+
* @throws {Error} If no existing mapping found or KV operations fail
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* // Add email lookup to an existing user mapping
|
|
288
|
+
* await mapper.addLookupKeys('user-123', ['email:user@example.com']);
|
|
289
|
+
* ```
|
|
290
|
+
* @since 1.0.3
|
|
291
|
+
*/
|
|
292
|
+
addLookupKeys(primaryKey: string, additionalKeys: string[]): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* Gets all lookup keys associated with a shard mapping. This is useful for
|
|
295
|
+
* understanding what keys resolve to the same shard.
|
|
296
|
+
*
|
|
297
|
+
* @param primaryKey - Any key in the mapping
|
|
298
|
+
* @returns Promise resolving to array of all keys in the mapping
|
|
299
|
+
* @throws {Error} If no existing mapping found
|
|
300
|
+
* @example
|
|
301
|
+
* ```typescript
|
|
302
|
+
* const allKeys = await mapper.getAllLookupKeys('email:user@example.com');
|
|
303
|
+
* console.log(allKeys); // ['user-123', 'username:john', 'email:user@example.com']
|
|
304
|
+
* ```
|
|
305
|
+
* @since 1.0.3
|
|
306
|
+
*/
|
|
307
|
+
getAllLookupKeys(primaryKey: string): Promise<string[]>;
|
|
254
308
|
}
|
|
255
309
|
//# sourceMappingURL=kvmap.d.ts.map
|
package/dist/kvmap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kvmap.d.ts","sourceRoot":"","sources":["../src/kvmap.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"kvmap.d.ts","sourceRoot":"","sources":["../src/kvmap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAwB,YAAY,EAAE,MAAM,YAAY,CAAC;AAoCtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,aAAa;IACzB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAc;IAEjC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IAEnC;;;;OAIG;gBACS,EAAE,EAAE,WAAW,EAAE,MAAM,GAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAM;IAK7F;;;;;O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gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAkB7D"}
|
package/dist/migrations.d.ts
CHANGED
|
@@ -208,6 +208,29 @@ export declare function migrateRecord(source: D1Database, target: D1Database, pr
|
|
|
208
208
|
* ```
|
|
209
209
|
*/
|
|
210
210
|
export declare function discoverExistingPrimaryKeys(d1: D1Database, tableName: string, primaryKeyColumn?: string): Promise<string[]>;
|
|
211
|
+
/**
|
|
212
|
+
* Discovers existing records with additional columns for multi-key mapping support.
|
|
213
|
+
* Scans a table to find primary keys along with username, email, and name columns
|
|
214
|
+
* when they exist, allowing these additional columns to be used as lookup keys.
|
|
215
|
+
*
|
|
216
|
+
* @param d1 - The D1 database instance to scan
|
|
217
|
+
* @param tableName - Name of the table to discover records from
|
|
218
|
+
* @param primaryKeyColumn - Name of the primary key column (defaults to 'id')
|
|
219
|
+
* @returns Promise resolving to array of record data with available columns
|
|
220
|
+
* @throws {Error} If table doesn't exist or database query fails
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* // Discover all user records with available lookup columns
|
|
224
|
+
* const records = await discoverExistingRecordsWithColumns(env.DB_EXISTING, 'users');
|
|
225
|
+
* console.log(`Found ${records.length} user records`);
|
|
226
|
+
* records.forEach(record => {
|
|
227
|
+
* console.log(`ID: ${record.id}, Email: ${record.email || 'N/A'}`);
|
|
228
|
+
* });
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
export declare function discoverExistingRecordsWithColumns(d1: D1Database, tableName: string, primaryKeyColumn?: string): Promise<Array<{
|
|
232
|
+
[key: string]: any;
|
|
233
|
+
}>>;
|
|
211
234
|
/**
|
|
212
235
|
* Takes a list of existing primary keys and creates shard mappings for them using
|
|
213
236
|
* the specified allocation strategy. This allows existing data to be integrated
|
|
@@ -277,6 +300,7 @@ export type IntegrationOptions = {
|
|
|
277
300
|
strategy?: ShardingStrategy;
|
|
278
301
|
addShardMappingsTable?: boolean;
|
|
279
302
|
dryRun?: boolean;
|
|
303
|
+
migrateOtherColumns?: boolean;
|
|
280
304
|
};
|
|
281
305
|
/**
|
|
282
306
|
* Represents the result of integrating an existing database with CollegeDB.
|
|
@@ -298,10 +322,15 @@ export type IntegrationResult = {
|
|
|
298
322
|
* that already contains data. It discovers tables, validates them, creates shard
|
|
299
323
|
* mappings, and optionally adds the shard_mappings table if needed.
|
|
300
324
|
*
|
|
325
|
+
* When `migrateOtherColumns` is enabled, the function will also create additional
|
|
326
|
+
* lookup keys for username, email, and name columns if they exist in the table.
|
|
327
|
+
* This allows these fields to be used as lookup keys in addition to the primary key.
|
|
328
|
+
*
|
|
301
329
|
* @param d1 - The existing D1 database to integrate
|
|
302
330
|
* @param shardName - The shard binding name for this database
|
|
303
331
|
* @param mapper - KVShardMapper instance for storing mappings
|
|
304
332
|
* @param options - Configuration options for the integration
|
|
333
|
+
* @param options.migrateOtherColumns - When true, creates additional lookup keys for username, email, and name columns
|
|
305
334
|
* @returns Promise resolving to integration summary
|
|
306
335
|
* @throws {Error} If integration fails
|
|
307
336
|
* @example
|
|
@@ -312,10 +341,12 @@ export type IntegrationResult = {
|
|
|
312
341
|
* const result = await integrateExistingDatabase(env.DB_EXISTING, 'db-existing', mapper, {
|
|
313
342
|
* tables: ['users', 'posts'],
|
|
314
343
|
* strategy: 'hash',
|
|
315
|
-
* addShardMappingsTable: true
|
|
344
|
+
* addShardMappingsTable: true,
|
|
345
|
+
* migrateOtherColumns: true // Creates additional lookup keys
|
|
316
346
|
* });
|
|
317
347
|
*
|
|
318
348
|
* console.log(`Integrated ${result.totalRecords} records from ${result.tablesProcessed} tables`);
|
|
349
|
+
* // Now users can be looked up by username:john, email:john@example.com, or name:John Doe
|
|
319
350
|
* ```
|
|
320
351
|
*/
|
|
321
352
|
export declare function integrateExistingDatabase(d1: D1Database, shardName: string, mapper: KVShardMapper, options?: IntegrationOptions): Promise<IntegrationResult>;
|
|
@@ -332,15 +363,21 @@ export declare function integrateExistingDatabase(d1: D1Database, shardName: str
|
|
|
332
363
|
* 3. If unmapped data is found, performs automatic integration
|
|
333
364
|
* 4. Caches results to avoid repeated checks
|
|
334
365
|
*
|
|
366
|
+
* When `migrateOtherColumns` is enabled, additional lookup keys will be created
|
|
367
|
+
* for username, email, and name columns if they exist in the tables.
|
|
368
|
+
*
|
|
335
369
|
* @param d1 - The D1 database instance to check and potentially migrate
|
|
336
370
|
* @param shardName - The shard binding name for this database
|
|
337
371
|
* @param config - CollegeDB configuration containing KV and strategy
|
|
338
372
|
* @param options - Optional migration configuration
|
|
373
|
+
* @param options.migrateOtherColumns - When true, creates additional lookup keys for username, email, and name columns
|
|
339
374
|
* @returns Promise resolving to migration result summary
|
|
340
375
|
* @example
|
|
341
376
|
* ```typescript
|
|
342
377
|
* // Called automatically by CollegeDB operations
|
|
343
|
-
* const result = await autoDetectAndMigrate(env.DB_EXISTING, 'db-existing', config
|
|
378
|
+
* const result = await autoDetectAndMigrate(env.DB_EXISTING, 'db-existing', config, {
|
|
379
|
+
* migrateOtherColumns: true
|
|
380
|
+
* });
|
|
344
381
|
* if (result.migrationPerformed) {
|
|
345
382
|
* console.log(`Auto-migrated ${result.recordsMigrated} records`);
|
|
346
383
|
* }
|
|
@@ -351,6 +388,7 @@ export declare function autoDetectAndMigrate(d1: D1Database, shardName: string,
|
|
|
351
388
|
tablesToCheck?: string[];
|
|
352
389
|
skipCache?: boolean;
|
|
353
390
|
maxRecordsToCheck?: number;
|
|
391
|
+
migrateOtherColumns?: boolean;
|
|
354
392
|
}): Promise<{
|
|
355
393
|
migrationNeeded: boolean;
|
|
356
394
|
migrationPerformed: boolean;
|
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;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B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AC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,yBAAyB,CAC9C,EAAE,EAAE,UAAU,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,kBAAuB,GAC9B,OAAO,CAAC,iBAAiB,CAAC,CAyH5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,oBAAoB,CACzC,EAAE,EAAE,UAAU,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE;IACR,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACzB,GACJ,OAAO,CAAC;IACV,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC,CA+KD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAuDvH;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGhE"}
|
package/dist/router.d.ts
CHANGED
|
@@ -510,6 +510,45 @@ export declare function allShard<T = Record<string, unknown>>(shardBinding: stri
|
|
|
510
510
|
* ```
|
|
511
511
|
*/
|
|
512
512
|
export declare function firstShard<T = Record<string, unknown>>(shardBinding: string, sql: string, bindings?: any[]): Promise<T | null>;
|
|
513
|
+
/**
|
|
514
|
+
* Executes a query on all shards and returns the results from each shard.
|
|
515
|
+
*
|
|
516
|
+
* This function is useful for scenarios where you need to aggregate data
|
|
517
|
+
* from multiple shards, such as running analytics or cross-shard queries.
|
|
518
|
+
* It executes the same SQL statement on each shard and collects the results.
|
|
519
|
+
* @param sql - The SQL statement to execute on each shard
|
|
520
|
+
* @param bindings - Parameter values to bind to the SQL statement
|
|
521
|
+
* @param batchSize - Number of concurrent queries to run at once (default: 50)
|
|
522
|
+
* @returns Promise resolving to an array of results from each shard
|
|
523
|
+
* @since 1.0.4
|
|
524
|
+
*/
|
|
525
|
+
export declare function runAllShards<T = Record<string, unknown>>(sql: string, bindings?: any[], batchSize?: number): Promise<D1Result<T>[]>;
|
|
526
|
+
/**
|
|
527
|
+
* Executes a query on all shards and returns all matching records from each shard.
|
|
528
|
+
*
|
|
529
|
+
* This function is useful for scenarios where you need to retrieve all records
|
|
530
|
+
* matching a query across multiple shards, such as aggregating data or running
|
|
531
|
+
* cross-shard analytics.
|
|
532
|
+
* @param sql - The SQL statement to execute on each shard
|
|
533
|
+
* @param bindings - Parameter values to bind to the SQL statement
|
|
534
|
+
* @param batchSize - Number of concurrent queries to run at once (default: 50)
|
|
535
|
+
* @returns Promise resolving to an array of results from each shard
|
|
536
|
+
* @since 1.0.4
|
|
537
|
+
*/
|
|
538
|
+
export declare function allAllShards<T = Record<string, unknown>>(sql: string, bindings?: any[], batchSize?: number): Promise<D1Result<T>[]>;
|
|
539
|
+
/**
|
|
540
|
+
* Executes a query on all shards and returns the first matching record from each shard.
|
|
541
|
+
*
|
|
542
|
+
* This function is useful for scenarios where you need to retrieve a single record
|
|
543
|
+
* from each shard, such as fetching the latest entry or a specific item that may
|
|
544
|
+
* exist on multiple shards.
|
|
545
|
+
* @param sql - The SQL statement to execute
|
|
546
|
+
* @param bindings - Parameter values to bind to the SQL statement
|
|
547
|
+
* @param batchSize - Number of concurrent queries to run at once (default: 50)
|
|
548
|
+
* @returns Promise resolving to an array of first matching records from each shard
|
|
549
|
+
* @since 1.0.4
|
|
550
|
+
*/
|
|
551
|
+
export declare function firstAllShards<T = Record<string, unknown>>(sql: string, bindings?: any[], batchSize?: number): Promise<(T | null)[]>;
|
|
513
552
|
/**
|
|
514
553
|
* Flushes all shard mappings (development only)
|
|
515
554
|
*
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGpG,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAgC,UAAU,EAAoB,MAAM,YAAY,CAAC;AAaxH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,QAQjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,eAAe,iBAS5D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,CAAC,cAG5E;AA0DD;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAgGD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAkIjE;AAoPD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,YAAY,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,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
|
95
95
|
*/
|
|
96
96
|
disableAutoMigration?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Whether to hash shard mapping keys with SHA-256 for security and privacy.
|
|
99
|
+
* When enabled, primary keys are hashed before storing in KV, protecting
|
|
100
|
+
* sensitive data like emails from being visible in KV keys.
|
|
101
|
+
* @default true
|
|
102
|
+
* @since 1.0.3
|
|
103
|
+
*/
|
|
104
|
+
hashShardMappings?: boolean;
|
|
97
105
|
}
|
|
98
106
|
/**
|
|
99
107
|
* Shard statistics for monitoring and load balancing
|
|
@@ -123,6 +131,22 @@ export interface ShardMapping {
|
|
|
123
131
|
createdAt: number;
|
|
124
132
|
/** Timestamp when mapping was last updated */
|
|
125
133
|
updatedAt: number;
|
|
134
|
+
/** Original unhashed primary key (only stored when hashing is disabled) */
|
|
135
|
+
originalKey?: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Multi-key shard mapping for lookup by various unique identifiers
|
|
139
|
+
* @since 1.0.3
|
|
140
|
+
*/
|
|
141
|
+
export interface MultiKeyShardMapping {
|
|
142
|
+
/** D1 binding name */
|
|
143
|
+
shard: string;
|
|
144
|
+
/** Timestamp when mapping was created */
|
|
145
|
+
createdAt: number;
|
|
146
|
+
/** Timestamp when mapping was last updated */
|
|
147
|
+
updatedAt: number;
|
|
148
|
+
/** All keys that resolve to this shard mapping (for reverse lookups) */
|
|
149
|
+
keys: string[];
|
|
126
150
|
}
|
|
127
151
|
/**
|
|
128
152
|
* Durable Object state for shard coordination
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAEjG;;GAEG;AACH,MAAM,MAAM,QAAQ,GACjB,MAAM,GAC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