@miniflare/shared
Advanced tools
Comparing version 2.5.1 to 2.6.0-d1.1
import { Awaitable as Awaitable_2 } from '@miniflare/shared'; | ||
import type { Database } from 'better-sqlite3'; | ||
@@ -33,5 +34,5 @@ export declare function addAll<T>(set: Set<T>, values: Iterable<T>): void; | ||
export declare type CompatibilityDisableFlag = "durable_object_fetch_allows_relative_url" | "fetch_treats_unknown_protocols_as_http" | "formdata_parser_converts_files_to_strings"; | ||
export declare type CompatibilityDisableFlag = "no_global_navigator" | "durable_object_fetch_allows_relative_url" | "fetch_treats_unknown_protocols_as_http" | "formdata_parser_converts_files_to_strings"; | ||
export declare type CompatibilityEnableFlag = "durable_object_fetch_requires_full_url" | "fetch_refuses_unknown_protocols" | "formdata_parser_supports_files" | "html_rewriter_treats_esi_include_as_void_tag"; | ||
export declare type CompatibilityEnableFlag = "global_navigator" | "durable_object_fetch_requires_full_url" | "fetch_refuses_unknown_protocols" | "formdata_parser_supports_files" | "html_rewriter_treats_esi_include_as_void_tag"; | ||
@@ -52,2 +53,6 @@ export declare interface CompatibilityFeature { | ||
export declare const EXTERNAL_SUBREQUEST_LIMIT_BUNDLED = 50; | ||
export declare const EXTERNAL_SUBREQUEST_LIMIT_UNBOUND = 1000; | ||
export declare type ExtractOptions<Instance> = Instance extends Plugin<infer Options> ? Options : never; | ||
@@ -57,2 +62,4 @@ | ||
export declare function getSQLiteNativeBindingLocation(): string; | ||
export declare function globsToMatcher(globs?: string[]): Matcher; | ||
@@ -79,2 +86,4 @@ | ||
export declare const INTERNAL_SUBREQUEST_LIMIT = 1000; | ||
export declare function kebabCase(s: string): string; | ||
@@ -139,2 +148,3 @@ | ||
dispatchFetch?: (request: Request) => Promise<Response>; | ||
usageModel?: UsageModel; | ||
} | ||
@@ -174,3 +184,3 @@ | ||
fromEntries?: Type extends OptionType.OBJECT ? (entries: [key: string, value: string][]) => Value : undefined; | ||
fromWrangler?: (config: WranglerConfig, configDir: string) => Value | undefined; | ||
fromWrangler?: (config: WranglerConfig, configDir: string, log: Log) => Value | undefined; | ||
} | ||
@@ -222,2 +232,3 @@ | ||
rootPath: string; | ||
usageModel?: UsageModel; | ||
globalAsyncIO?: boolean; | ||
@@ -262,6 +273,12 @@ } | ||
readonly durableObject: boolean; | ||
constructor({ requestDepth, pipelineDepth, durableObject, }?: RequestContextOptions); | ||
readonly externalSubrequestLimit: number | false; | ||
readonly internalSubrequestLimit: number | false; | ||
constructor({ requestDepth, pipelineDepth, durableObject, externalSubrequestLimit, internalSubrequestLimit, }?: RequestContextOptions); | ||
runWith<T>(closure: () => T): T; | ||
get subrequests(): number; | ||
incrementSubrequests(count?: number): void; | ||
get externalSubrequests(): number; | ||
get internalSubrequests(): number; | ||
incrementExternalSubrequests(count?: number): void; | ||
incrementInternalSubrequests(count?: number): void; | ||
get currentTime(): number; | ||
advanceCurrentTime(): void; | ||
} | ||
@@ -287,2 +304,6 @@ | ||
durableObject?: boolean; | ||
/** Maximum external subrequests (`fetch`, Cache API) allowed. */ | ||
externalSubrequestLimit?: number | false; | ||
/** Maximum internal subrequests (KV, Durable Objects) allowed. */ | ||
internalSubrequestLimit?: number | false; | ||
} | ||
@@ -339,2 +360,4 @@ | ||
abstract list(options: StorageListOptions, skipMetadata: true): Awaitable<StorageListResult<StoredKey>>; | ||
getSqliteDatabase(): Database; | ||
getRangeMaybeExpired?<Meta = unknown>(key: string, start: number, length: number): Promise<StoredValueMeta<Meta> | undefined>; | ||
hasMany(keys: string[]): Promise<number>; | ||
@@ -416,2 +439,6 @@ getMany<Meta = unknown>(keys: string[], skipMetadata?: false): Promise<(StoredValueMeta<Meta> | undefined)[]>; | ||
export declare type UsageModel = "bundled" | "unbound"; | ||
export declare function usageModelExternalSubrequestLimit(model?: UsageModel): number; | ||
export declare type ValueOf<T> = T[keyof T]; | ||
@@ -479,2 +506,7 @@ | ||
}[]; | ||
d1_databases?: { | ||
binding: string; | ||
database_name: string; | ||
database_id: string; | ||
}[]; | ||
site?: { | ||
@@ -496,11 +528,9 @@ bucket: string; | ||
}; | ||
usage_model?: "bundled" | "unbound"; | ||
usage_model?: UsageModel; | ||
wasm_modules?: Record<string, string>; | ||
text_blobs?: Record<string, string>; | ||
data_blobs?: Record<string, string>; | ||
experimental_services?: { | ||
name: string; | ||
service: string; | ||
environment: string; | ||
}[]; | ||
services?: WranglerServiceConfig[]; | ||
/** @deprecated Use `services` instead */ | ||
experimental_services?: WranglerServiceConfig[]; | ||
miniflare?: { | ||
@@ -512,2 +542,3 @@ globals?: Record<string, any>; | ||
kv_persist?: boolean | string; | ||
d1_persist?: boolean | string; | ||
cache?: boolean; | ||
@@ -537,5 +568,12 @@ cache_persist?: boolean | string; | ||
global_random?: boolean; | ||
actual_time?: boolean; | ||
}; | ||
} | ||
export declare interface WranglerServiceConfig { | ||
name: string; | ||
service: string; | ||
environment: string; | ||
} | ||
export { } |
@@ -28,2 +28,5 @@ var __create = Object.create; | ||
Compatibility: () => Compatibility, | ||
EXTERNAL_SUBREQUEST_LIMIT_BUNDLED: () => EXTERNAL_SUBREQUEST_LIMIT_BUNDLED, | ||
EXTERNAL_SUBREQUEST_LIMIT_UNBOUND: () => EXTERNAL_SUBREQUEST_LIMIT_UNBOUND, | ||
INTERNAL_SUBREQUEST_LIMIT: () => INTERNAL_SUBREQUEST_LIMIT, | ||
InputGate: () => InputGate, | ||
@@ -51,2 +54,3 @@ InputGatedEventTarget: () => InputGatedEventTarget, | ||
getRequestContext: () => getRequestContext, | ||
getSQLiteNativeBindingLocation: () => getSQLiteNativeBindingLocation, | ||
globsToMatcher: () => globsToMatcher, | ||
@@ -67,2 +71,3 @@ kWrapListener: () => kWrapListener, | ||
titleCase: () => titleCase, | ||
usageModelExternalSubrequestLimit: () => usageModelExternalSubrequestLimit, | ||
viewToArray: () => viewToArray, | ||
@@ -155,2 +160,7 @@ viewToBuffer: () => viewToBuffer, | ||
{ | ||
defaultAsOf: "2022-03-21", | ||
enableFlag: "global_navigator", | ||
disableFlag: "no_global_navigator" | ||
}, | ||
{ | ||
defaultAsOf: "2021-11-10", | ||
@@ -215,4 +225,18 @@ enableFlag: "durable_object_fetch_requires_full_url", | ||
var import_async_hooks = __toModule(require("async_hooks")); | ||
var subrequestLimit = parseInt(process.env.MINIFLARE_SUBREQUEST_LIMIT); | ||
var MAX_SUBREQUESTS = isNaN(subrequestLimit) ? 50 : subrequestLimit; | ||
function parseSubrequestOverride(limit) { | ||
const parsed = parseInt(limit); | ||
if (Number.isNaN(parsed)) | ||
return void 0; | ||
if (parsed < 0) | ||
return false; | ||
return parsed; | ||
} | ||
var EXTERNAL_SUBREQUEST_LIMIT_OVERRIDE = parseSubrequestOverride(process.env.MINIFLARE_SUBREQUEST_LIMIT); | ||
var INTERNAL_SUBREQUEST_LIMIT_OVERRIDE = parseSubrequestOverride(process.env.MINIFLARE_INTERNAL_SUBREQUEST_LIMIT); | ||
var EXTERNAL_SUBREQUEST_LIMIT_BUNDLED = 50; | ||
var EXTERNAL_SUBREQUEST_LIMIT_UNBOUND = 1e3; | ||
var INTERNAL_SUBREQUEST_LIMIT = 1e3; | ||
function usageModelExternalSubrequestLimit(model) { | ||
return model === "unbound" ? EXTERNAL_SUBREQUEST_LIMIT_UNBOUND : EXTERNAL_SUBREQUEST_LIMIT_BUNDLED; | ||
} | ||
var MAX_REQUEST_DEPTH = 16; | ||
@@ -234,6 +258,13 @@ var MAX_PIPELINE_DEPTH = 32; | ||
durableObject; | ||
externalSubrequestLimit; | ||
internalSubrequestLimit; | ||
#internalSubrequests = 0; | ||
#externalSubrequests = 0; | ||
#currentTime; | ||
constructor({ | ||
requestDepth = 1, | ||
pipelineDepth = 1, | ||
durableObject = false | ||
durableObject = false, | ||
externalSubrequestLimit = EXTERNAL_SUBREQUEST_LIMIT_BUNDLED, | ||
internalSubrequestLimit = INTERNAL_SUBREQUEST_LIMIT | ||
} = {}) { | ||
@@ -254,2 +285,5 @@ (0, import_assert.default)(requestDepth >= 1); | ||
this.durableObject = durableObject; | ||
this.externalSubrequestLimit = EXTERNAL_SUBREQUEST_LIMIT_OVERRIDE !== void 0 ? EXTERNAL_SUBREQUEST_LIMIT_OVERRIDE : externalSubrequestLimit; | ||
this.internalSubrequestLimit = INTERNAL_SUBREQUEST_LIMIT_OVERRIDE !== void 0 ? INTERNAL_SUBREQUEST_LIMIT_OVERRIDE : internalSubrequestLimit; | ||
this.#currentTime = Date.now(); | ||
} | ||
@@ -259,13 +293,27 @@ runWith(closure) { | ||
} | ||
#subrequests = 0; | ||
get subrequests() { | ||
return this.#subrequests; | ||
get externalSubrequests() { | ||
return this.#externalSubrequests; | ||
} | ||
incrementSubrequests(count = 1) { | ||
this.#subrequests += count; | ||
if (MAX_SUBREQUESTS >= 0 && this.#subrequests > MAX_SUBREQUESTS) { | ||
throw new Error(`Too many subrequests. Workers can make up to ${MAX_SUBREQUESTS} subrequests per request. | ||
get internalSubrequests() { | ||
return this.#internalSubrequests; | ||
} | ||
incrementExternalSubrequests(count = 1) { | ||
this.#externalSubrequests += count; | ||
if (this.externalSubrequestLimit !== false && this.#externalSubrequests > this.externalSubrequestLimit) { | ||
throw new Error(`Too many subrequests. Workers can make up to ${this.externalSubrequestLimit} subrequests per request. | ||
A subrequest is a call to fetch(), a redirect, or a call to any Cache API method.`); | ||
} | ||
} | ||
incrementInternalSubrequests(count = 1) { | ||
this.#internalSubrequests += count; | ||
if (this.internalSubrequestLimit !== false && this.#internalSubrequests > this.internalSubrequestLimit) { | ||
throw new Error(`Too many API requests by single worker invocation. Workers can make up to ${this.internalSubrequestLimit} KV and Durable Object requests per invocation.`); | ||
} | ||
} | ||
get currentTime() { | ||
return this.#currentTime; | ||
} | ||
advanceCurrentTime() { | ||
this.#currentTime = Date.now(); | ||
} | ||
}; | ||
@@ -498,3 +546,7 @@ | ||
// packages/shared/src/storage.ts | ||
var import_node_path = __toModule(require("node:path")); | ||
var Storage = class { | ||
getSqliteDatabase() { | ||
throw new Error("D1 not implemented for this Storage class"); | ||
} | ||
async hasMany(keys) { | ||
@@ -523,2 +575,5 @@ const results = keys.map(this.has.bind(this)); | ||
}; | ||
function getSQLiteNativeBindingLocation() { | ||
return import_node_path.default.resolve(import_node_path.default.dirname(require.resolve("better-sqlite3")), "../build/Release/better_sqlite3.node"); | ||
} | ||
@@ -669,2 +724,5 @@ // packages/shared/src/sync/clock.ts | ||
Compatibility, | ||
EXTERNAL_SUBREQUEST_LIMIT_BUNDLED, | ||
EXTERNAL_SUBREQUEST_LIMIT_UNBOUND, | ||
INTERNAL_SUBREQUEST_LIMIT, | ||
InputGate, | ||
@@ -692,2 +750,3 @@ InputGatedEventTarget, | ||
getRequestContext, | ||
getSQLiteNativeBindingLocation, | ||
globsToMatcher, | ||
@@ -708,2 +767,3 @@ kWrapListener, | ||
titleCase, | ||
usageModelExternalSubrequestLimit, | ||
viewToArray, | ||
@@ -710,0 +770,0 @@ viewToBuffer, |
{ | ||
"name": "@miniflare/shared", | ||
"version": "2.5.1", | ||
"version": "2.6.0-d1.1", | ||
"description": "Shared utility module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -38,2 +38,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@types/better-sqlite3": "^7.5.0", | ||
"better-sqlite3": "^7.5.3", | ||
"ignore": "^5.1.8", | ||
@@ -43,4 +45,4 @@ "kleur": "^4.1.4" | ||
"devDependencies": { | ||
"@miniflare/shared-test": "2.5.1" | ||
"@miniflare/shared-test": "2.6.0-d1.1" | ||
} | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
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
58048
1236
4
1
4
1
+ Added@types/better-sqlite3@^7.5.0
+ Addedbetter-sqlite3@^7.5.3
+ Added@types/better-sqlite3@7.6.11(transitive)
+ Added@types/node@22.9.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbetter-sqlite3@7.6.2(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddetect-libc@2.0.3(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexpand-template@2.0.3(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedgithub-from-package@0.0.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedini@1.3.8(transitive)
+ Addedmimic-response@3.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addednapi-build-utils@1.0.2(transitive)
+ Addednode-abi@3.71.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedprebuild-install@7.1.2(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedsimple-get@4.0.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedtar-fs@2.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwrappy@1.0.2(transitive)