@miniflare/shared
Advanced tools
Comparing version 2.9.0-next.1 to 2.9.0
@@ -0,3 +1,7 @@ | ||
/// <reference types="node" /> | ||
import { Awaitable as Awaitable_2 } from '@miniflare/shared'; | ||
import { MockAgent } from 'undici'; | ||
import type { Database as SqliteDB } from 'better-sqlite3'; | ||
import type { Options as SqliteOptions } from 'better-sqlite3'; | ||
@@ -57,2 +61,8 @@ export declare function addAll<T>(set: Set<T>, values: Iterable<T>): void; | ||
export declare function createSQLiteDB(dbPath: string): Promise<SqliteDB>; | ||
export declare interface DBConstructor { | ||
new (filename: string | Buffer, options?: SqliteOptions): SqliteDB; | ||
} | ||
export declare const defaultClock: Clock; | ||
@@ -68,2 +78,4 @@ | ||
export declare function getSQLiteNativeBindingLocation(sqliteResolvePath: string): string; | ||
export declare function globsToMatcher(globs?: string[]): Matcher; | ||
@@ -415,2 +427,6 @@ | ||
export { SqliteDB } | ||
export { SqliteOptions } | ||
/** | ||
@@ -432,2 +448,3 @@ * Common class for key-value storage: | ||
abstract list(options: StorageListOptions, skipMetadata: true): Awaitable<StorageListResult<StoredKey>>; | ||
getSqliteDatabase(): Promise<SqliteDB>; | ||
hasMany(keys: string[]): Promise<number>; | ||
@@ -441,3 +458,3 @@ getMany<Meta = unknown>(keys: string[], skipMetadata?: false): Promise<(StoredValueMeta<Meta> | undefined)[]>; | ||
export declare interface StorageFactory { | ||
storage(namespace: string, persist?: boolean | string): Awaitable<Storage>; | ||
storage(namespace: string, persist?: boolean | string): Storage; | ||
dispose?(): Awaitable<void>; | ||
@@ -582,2 +599,7 @@ } | ||
}[]; | ||
d1_databases?: { | ||
binding: string; | ||
database_name: string; | ||
database_id: string; | ||
}[]; | ||
r2_buckets?: { | ||
@@ -630,2 +652,3 @@ binding: string; | ||
kv_persist?: boolean | string; | ||
d1_persist?: boolean | string; | ||
r2_persist?: boolean | string; | ||
@@ -632,0 +655,0 @@ cache?: boolean; |
@@ -52,4 +52,6 @@ var __create = Object.create; | ||
base64Encode: () => base64Encode, | ||
createSQLiteDB: () => createSQLiteDB, | ||
defaultClock: () => defaultClock, | ||
getRequestContext: () => getRequestContext, | ||
getSQLiteNativeBindingLocation: () => getSQLiteNativeBindingLocation, | ||
globsToMatcher: () => globsToMatcher, | ||
@@ -572,2 +574,5 @@ kGetConsumer: () => kGetConsumer, | ||
var Storage = class { | ||
async getSqliteDatabase() { | ||
throw new Error("D1 not implemented for this Storage class"); | ||
} | ||
async hasMany(keys) { | ||
@@ -606,2 +611,3 @@ const results = keys.map(this.has.bind(this)); | ||
var import_async_hooks2 = __toModule(require("async_hooks")); | ||
var import_timers = __toModule(require("timers")); | ||
var import_promises = __toModule(require("timers/promises")); | ||
@@ -657,3 +663,3 @@ var inputGateStorage = new import_async_hooks2.AsyncLocalStorage(); | ||
} finally { | ||
setImmediate(this.#unlock); | ||
(0, import_timers.setImmediate)(this.#unlock); | ||
} | ||
@@ -740,2 +746,15 @@ } | ||
}; | ||
// packages/shared/src/sqlite.ts | ||
var import_node_path = __toModule(require("node:path")); | ||
async function createSQLiteDB(dbPath) { | ||
const { npxImport, npxResolve } = await import("npx-import"); | ||
const { default: DatabaseConstructor } = await npxImport("better-sqlite3@7.6.2"); | ||
return new DatabaseConstructor(dbPath, { | ||
nativeBinding: getSQLiteNativeBindingLocation(npxResolve("better-sqlite3")) | ||
}); | ||
} | ||
function getSQLiteNativeBindingLocation(sqliteResolvePath) { | ||
return import_node_path.default.resolve(import_node_path.default.dirname(sqliteResolvePath), "../build/Release/better_sqlite3.node"); | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -768,4 +787,6 @@ 0 && (module.exports = { | ||
base64Encode, | ||
createSQLiteDB, | ||
defaultClock, | ||
getRequestContext, | ||
getSQLiteNativeBindingLocation, | ||
globsToMatcher, | ||
@@ -772,0 +793,0 @@ kGetConsumer, |
{ | ||
"name": "@miniflare/shared", | ||
"version": "2.9.0-next.1", | ||
"version": "2.9.0", | ||
"description": "Shared utility module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -38,9 +38,11 @@ "keywords": [ | ||
"dependencies": { | ||
"@types/better-sqlite3": "^7.6.0", | ||
"kleur": "^4.1.4", | ||
"npx-import": "^1.1.3", | ||
"picomatch": "^2.3.1" | ||
}, | ||
"devDependencies": { | ||
"@miniflare/shared-test": "2.9.0-next.1", | ||
"@miniflare/shared-test": "2.9.0", | ||
"@types/picomatch": "^2.3.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
64049
1384
0
4
+ Added@types/better-sqlite3@^7.6.0
+ Addednpx-import@^1.1.3
+ Added@types/better-sqlite3@7.6.11(transitive)
+ Added@types/node@22.9.0(transitive)
+ Addedbuiltins@5.1.0(transitive)
+ Addedcross-spawn@7.0.5(transitive)
+ Addedexeca@6.1.0(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhuman-signals@3.0.1(transitive)
+ Addedis-stream@3.0.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@4.0.0(transitive)
+ Addednpm-run-path@5.3.0(transitive)
+ Addednpx-import@1.1.4(transitive)
+ Addedonetime@6.0.0(transitive)
+ Addedparse-package-name@1.0.0(transitive)
+ Addedpath-key@3.1.14.0.0(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstrip-final-newline@3.0.0(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedvalidate-npm-package-name@4.0.0(transitive)
+ Addedwhich@2.0.2(transitive)