@concavejs/docstore-cf-d1 0.0.1-alpha.6 → 0.0.1-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/d1-adapter.d.ts +1 -1
- package/dist/index.js +28 -12
- package/package.json +1 -1
package/dist/d1-adapter.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { SqliteAdapter, PreparedStatement, SqlParam, TransactionFn } from "
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class D1SqliteAdapter implements SqliteAdapter {
|
|
10
10
|
private db;
|
|
11
|
-
private
|
|
11
|
+
private statementCollector;
|
|
12
12
|
constructor(db: D1Database);
|
|
13
13
|
exec(sql: string): Promise<void>;
|
|
14
14
|
prepare(sql: string): PreparedStatement;
|
package/dist/index.js
CHANGED
|
@@ -5564,6 +5564,8 @@ function decodeJwtClaimsToken(token) {
|
|
|
5564
5564
|
return null;
|
|
5565
5565
|
}
|
|
5566
5566
|
}
|
|
5567
|
+
var DEFAULT_JWKS_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
5568
|
+
var MAX_JWKS_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
5567
5569
|
var JWKS_CACHE = new Map;
|
|
5568
5570
|
function decodeJwtUnsafe(token) {
|
|
5569
5571
|
if (!token)
|
|
@@ -11497,6 +11499,8 @@ function decodeJwtClaimsToken2(token) {
|
|
|
11497
11499
|
return null;
|
|
11498
11500
|
}
|
|
11499
11501
|
}
|
|
11502
|
+
var DEFAULT_JWKS_CACHE_TTL_MS2 = 5 * 60 * 1000;
|
|
11503
|
+
var MAX_JWKS_CACHE_TTL_MS2 = 24 * 60 * 60 * 1000;
|
|
11500
11504
|
var JWKS_CACHE2 = new Map;
|
|
11501
11505
|
function decodeJwtUnsafe2(token) {
|
|
11502
11506
|
if (!token)
|
|
@@ -12338,11 +12342,11 @@ class BaseSqliteDocStore {
|
|
|
12338
12342
|
class D1StatementWrapper {
|
|
12339
12343
|
db;
|
|
12340
12344
|
sql;
|
|
12341
|
-
|
|
12342
|
-
constructor(db, sql,
|
|
12345
|
+
getCollector;
|
|
12346
|
+
constructor(db, sql, getCollector) {
|
|
12343
12347
|
this.db = db;
|
|
12344
12348
|
this.sql = sql;
|
|
12345
|
-
this.
|
|
12349
|
+
this.getCollector = getCollector;
|
|
12346
12350
|
}
|
|
12347
12351
|
async get(...params) {
|
|
12348
12352
|
const stmt = this.db.prepare(this.sql).bind(...params);
|
|
@@ -12356,13 +12360,18 @@ class D1StatementWrapper {
|
|
|
12356
12360
|
}
|
|
12357
12361
|
async run(...params) {
|
|
12358
12362
|
const stmt = this.db.prepare(this.sql).bind(...params);
|
|
12359
|
-
this.
|
|
12363
|
+
const collector = this.getCollector();
|
|
12364
|
+
if (!collector) {
|
|
12365
|
+
await stmt.run();
|
|
12366
|
+
return;
|
|
12367
|
+
}
|
|
12368
|
+
collector.push(stmt);
|
|
12360
12369
|
}
|
|
12361
12370
|
}
|
|
12362
12371
|
|
|
12363
12372
|
class D1SqliteAdapter {
|
|
12364
12373
|
db;
|
|
12365
|
-
|
|
12374
|
+
statementCollector = null;
|
|
12366
12375
|
constructor(db) {
|
|
12367
12376
|
this.db = db;
|
|
12368
12377
|
}
|
|
@@ -12370,16 +12379,23 @@ class D1SqliteAdapter {
|
|
|
12370
12379
|
await this.db.prepare(sql).run();
|
|
12371
12380
|
}
|
|
12372
12381
|
prepare(sql) {
|
|
12373
|
-
return new D1StatementWrapper(this.db, sql, this.
|
|
12382
|
+
return new D1StatementWrapper(this.db, sql, () => this.statementCollector);
|
|
12374
12383
|
}
|
|
12375
12384
|
async transaction(fn) {
|
|
12376
|
-
this.
|
|
12377
|
-
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
|
|
12385
|
+
if (this.statementCollector) {
|
|
12386
|
+
return await fn();
|
|
12387
|
+
}
|
|
12388
|
+
const collector = [];
|
|
12389
|
+
this.statementCollector = collector;
|
|
12390
|
+
try {
|
|
12391
|
+
const result = await fn();
|
|
12392
|
+
if (collector.length > 0) {
|
|
12393
|
+
await this.db.batch(collector);
|
|
12394
|
+
}
|
|
12395
|
+
return result;
|
|
12396
|
+
} finally {
|
|
12397
|
+
this.statementCollector = null;
|
|
12381
12398
|
}
|
|
12382
|
-
return result;
|
|
12383
12399
|
}
|
|
12384
12400
|
hexToBuffer(hex) {
|
|
12385
12401
|
return hexToArrayBuffer(hex);
|