miniflare 0.0.0-7bbed63fb → 0.0.0-7ca37bcbb

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.
@@ -58,6 +58,13 @@ export declare class __MiniflareFunctionWrapper {
58
58
 
59
59
  export declare type AnyHeaders = http.IncomingHttpHeaders | string[];
60
60
 
61
+ export declare type AssetReverseMap = {
62
+ [pathHash: string]: {
63
+ filePath: string;
64
+ contentType: string;
65
+ };
66
+ };
67
+
61
68
  export declare const ASSETS_PLUGIN: Plugin<typeof AssetsOptionsSchema>;
62
69
 
63
70
  export declare const AssetsOptionsSchema: z.ZodObject<{
@@ -66,23 +73,41 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
66
73
  path: z.ZodEffects<z.ZodString, string, string>;
67
74
  bindingName: z.ZodOptional<z.ZodString>;
68
75
  routingConfig: z.ZodObject<{
69
- hasUserWorker: z.ZodBoolean;
76
+ has_user_worker: z.ZodOptional<z.ZodBoolean>;
70
77
  }, "strip", z.ZodTypeAny, {
71
- hasUserWorker: boolean;
78
+ has_user_worker?: boolean;
72
79
  }, {
73
- hasUserWorker: boolean;
80
+ has_user_worker?: boolean;
81
+ }>;
82
+ assetConfig: z.ZodObject<{
83
+ html_handling: z.ZodOptional<z.ZodEnum<["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]>>;
84
+ not_found_handling: z.ZodOptional<z.ZodEnum<["single-page-application", "404-page", "none"]>>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
87
+ not_found_handling?: "none" | "single-page-application" | "404-page";
88
+ }, {
89
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
90
+ not_found_handling?: "none" | "single-page-application" | "404-page";
74
91
  }>;
75
92
  }, "strip", z.ZodTypeAny, {
76
93
  path: string;
77
94
  routingConfig: {
78
- hasUserWorker: boolean;
95
+ has_user_worker?: boolean;
96
+ };
97
+ assetConfig: {
98
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
99
+ not_found_handling?: "none" | "single-page-application" | "404-page";
79
100
  };
80
101
  workerName?: string | undefined;
81
102
  bindingName?: string | undefined;
82
103
  }, {
83
104
  path: string;
84
105
  routingConfig: {
85
- hasUserWorker: boolean;
106
+ has_user_worker?: boolean;
107
+ };
108
+ assetConfig: {
109
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
110
+ not_found_handling?: "none" | "single-page-application" | "404-page";
86
111
  };
87
112
  workerName?: string | undefined;
88
113
  bindingName?: string | undefined;
@@ -91,7 +116,11 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
91
116
  assets?: {
92
117
  path: string;
93
118
  routingConfig: {
94
- hasUserWorker: boolean;
119
+ has_user_worker?: boolean;
120
+ };
121
+ assetConfig: {
122
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
123
+ not_found_handling?: "none" | "single-page-application" | "404-page";
95
124
  };
96
125
  workerName?: string | undefined;
97
126
  bindingName?: string | undefined;
@@ -100,7 +129,11 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
100
129
  assets?: {
101
130
  path: string;
102
131
  routingConfig: {
103
- hasUserWorker: boolean;
132
+ has_user_worker?: boolean;
133
+ };
134
+ assetConfig: {
135
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
136
+ not_found_handling?: "none" | "single-page-application" | "404-page";
104
137
  };
105
138
  workerName?: string | undefined;
106
139
  bindingName?: string | undefined;
@@ -115,7 +148,19 @@ export declare function base64Encode(value: string): string;
115
148
 
116
149
  export { BodyInit }
117
150
 
118
- export declare const buildAssetsManifest: (dir: string) => Promise<Uint8Array>;
151
+ /**
152
+ * The Asset Manifest and Asset Reverse Map are used to map a request path to an asset.
153
+ * 1. Hash path of request
154
+ * 2. Use this path hash to find the manifest entry
155
+ * 3. Get content hash from manifest entry
156
+ * 4a. In prod, use content hash to get asset from KV
157
+ * 4b. In dev, we fake out the KV store and use the file system instead.
158
+ * Use content hash to get file path from asset reverse map.
159
+ */
160
+ export declare const buildAssetManifest: (dir: string) => Promise<{
161
+ encodedAssetManifest: Uint8Array;
162
+ assetsReverseMap: AssetReverseMap;
163
+ }>;
119
164
 
120
165
  export declare const CACHE_PLUGIN: Plugin<typeof CacheOptionsSchema, typeof CacheSharedOptionsSchema>;
121
166
 
@@ -1321,6 +1366,7 @@ export declare const DURABLE_OBJECTS_PLUGIN_NAME = "do";
1321
1366
  export declare const DURABLE_OBJECTS_STORAGE_SERVICE_NAME = "do:storage";
1322
1367
 
1323
1368
  export declare type DurableObjectClassNames = Map<string, Map<string, {
1369
+ enableSql?: boolean;
1324
1370
  unsafeUniqueKey?: UnsafeUniqueKey;
1325
1371
  unsafePreventEviction?: boolean;
1326
1372
  }>>;
@@ -1329,16 +1375,19 @@ export declare const DurableObjectsOptionsSchema: z.ZodObject<{
1329
1375
  durableObjects: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodObject<{
1330
1376
  className: z.ZodString;
1331
1377
  scriptName: z.ZodOptional<z.ZodString>;
1378
+ useSQLite: z.ZodOptional<z.ZodBoolean>;
1332
1379
  unsafeUniqueKey: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<typeof kUnsafeEphemeralUniqueKey>]>>;
1333
1380
  unsafePreventEviction: z.ZodOptional<z.ZodBoolean>;
1334
1381
  }, "strip", z.ZodTypeAny, {
1335
1382
  className: string;
1336
1383
  scriptName?: string | undefined;
1384
+ useSQLite?: boolean | undefined;
1337
1385
  unsafeUniqueKey?: string | typeof kUnsafeEphemeralUniqueKey | undefined;
1338
1386
  unsafePreventEviction?: boolean | undefined;
1339
1387
  }, {
1340
1388
  className: string;
1341
1389
  scriptName?: string | undefined;
1390
+ useSQLite?: boolean | undefined;
1342
1391
  unsafeUniqueKey?: string | typeof kUnsafeEphemeralUniqueKey | undefined;
1343
1392
  unsafePreventEviction?: boolean | undefined;
1344
1393
  }>]>>>;
@@ -1346,6 +1395,7 @@ export declare const DurableObjectsOptionsSchema: z.ZodObject<{
1346
1395
  durableObjects?: Record<string, string | {
1347
1396
  className: string;
1348
1397
  scriptName?: string | undefined;
1398
+ useSQLite?: boolean | undefined;
1349
1399
  unsafeUniqueKey?: string | typeof kUnsafeEphemeralUniqueKey | undefined;
1350
1400
  unsafePreventEviction?: boolean | undefined;
1351
1401
  }> | undefined;
@@ -1353,6 +1403,7 @@ export declare const DurableObjectsOptionsSchema: z.ZodObject<{
1353
1403
  durableObjects?: Record<string, string | {
1354
1404
  className: string;
1355
1405
  scriptName?: string | undefined;
1406
+ useSQLite?: boolean | undefined;
1356
1407
  unsafeUniqueKey?: string | typeof kUnsafeEphemeralUniqueKey | undefined;
1357
1408
  unsafePreventEviction?: boolean | undefined;
1358
1409
  }> | undefined;
@@ -1443,6 +1494,30 @@ export declare function getGlobalServices({ sharedOptions, allWorkerRoutes, fall
1443
1494
 
1444
1495
  export declare function getMiniflareObjectBindings(unsafeStickyBlobs: boolean): Worker_Binding[];
1445
1496
 
1497
+ /**
1498
+ * Computes the Node.js compatibility mode we are running.
1499
+ *
1500
+ * NOTES:
1501
+ * - The v2 mode is configured via `nodejs_compat_v2` compat flag or via `nodejs_compat` plus a compatibility date of Sept 23rd. 2024 or later.
1502
+ * - See `EnvironmentInheritable` for `nodeCompat` and `noBundle`.
1503
+ *
1504
+ * @param compatibilityDateStr The compatibility date
1505
+ * @param compatibilityFlags The compatibility flags
1506
+ * @param opts.nodeCompat Whether the legacy node_compat arg is being used
1507
+ * @returns the mode and flags to indicate specific configuration for validating.
1508
+ */
1509
+ export declare function getNodeCompat(compatibilityDate: string | undefined, // Default to some arbitrary old date
1510
+ compatibilityFlags: string[], opts?: {
1511
+ nodeCompat?: boolean;
1512
+ }): {
1513
+ mode: NodeJSCompatMode;
1514
+ hasNodejsAlsFlag: boolean;
1515
+ hasNodejsCompatFlag: boolean;
1516
+ hasNodejsCompatV2Flag: boolean;
1517
+ hasNoNodejsCompatV2Flag: boolean;
1518
+ hasExperimentalNodejsCompatV2Flag: boolean;
1519
+ };
1520
+
1446
1521
  export declare function getPersistPath(pluginName: string, tmpPath: string, persist: Persistence): string;
1447
1522
 
1448
1523
  export declare function getRootPath(opts: unknown): string;
@@ -1641,6 +1716,11 @@ export declare interface LogOptions {
1641
1716
  suffix?: string;
1642
1717
  }
1643
1718
 
1719
+ export declare type ManifestEntry = {
1720
+ pathHash: Uint8Array;
1721
+ contentHash: Uint8Array;
1722
+ };
1723
+
1644
1724
  export declare interface MatcherRegExps {
1645
1725
  include: RegExp[];
1646
1726
  exclude: RegExp[];
@@ -1694,7 +1774,7 @@ export declare class Miniflare {
1694
1774
  export declare class MiniflareCoreError extends MiniflareError<MiniflareCoreErrorCode> {
1695
1775
  }
1696
1776
 
1697
- export declare type MiniflareCoreErrorCode = "ERR_RUNTIME_FAILURE" | "ERR_DISPOSED" | "ERR_MODULE_PARSE" | "ERR_MODULE_STRING_SCRIPT" | "ERR_MODULE_DYNAMIC_SPEC" | "ERR_MODULE_RULE" | "ERR_PERSIST_UNSUPPORTED" | "ERR_PERSIST_REMOTE_UNAUTHENTICATED" | "ERR_PERSIST_REMOTE_UNSUPPORTED" | "ERR_FUTURE_COMPATIBILITY_DATE" | "ERR_NO_WORKERS" | "ERR_VALIDATION" | "ERR_DUPLICATE_NAME" | "ERR_DIFFERENT_UNIQUE_KEYS" | "ERR_DIFFERENT_PREVENT_EVICTION" | "ERR_MULTIPLE_OUTBOUNDS" | "ERR_INVALID_WRAPPED" | "ERR_CYCLIC";
1777
+ export declare type MiniflareCoreErrorCode = "ERR_RUNTIME_FAILURE" | "ERR_DISPOSED" | "ERR_MODULE_PARSE" | "ERR_MODULE_STRING_SCRIPT" | "ERR_MODULE_DYNAMIC_SPEC" | "ERR_MODULE_RULE" | "ERR_PERSIST_UNSUPPORTED" | "ERR_PERSIST_REMOTE_UNAUTHENTICATED" | "ERR_PERSIST_REMOTE_UNSUPPORTED" | "ERR_FUTURE_COMPATIBILITY_DATE" | "ERR_NO_WORKERS" | "ERR_VALIDATION" | "ERR_DUPLICATE_NAME" | "ERR_DIFFERENT_STORAGE_BACKEND" | "ERR_DIFFERENT_UNIQUE_KEYS" | "ERR_DIFFERENT_PREVENT_EVICTION" | "ERR_MULTIPLE_OUTBOUNDS" | "ERR_INVALID_WRAPPED" | "ERR_CYCLIC";
1698
1778
 
1699
1779
  export declare class MiniflareError<Code extends string | number = string | number> extends Error {
1700
1780
  readonly code: Code;
@@ -1765,6 +1845,17 @@ export declare interface Network {
1765
1845
 
1766
1846
  export declare const NODE_PLATFORM_IMPL: PlatformImpl<ReadableStream_2>;
1767
1847
 
1848
+ /**
1849
+ * We can provide Node.js compatibility in a number of different modes:
1850
+ * - "legacy" - this mode adds compile-time polyfills that are not well maintained and cannot work with workerd runtime builtins.
1851
+ * - "als": this mode tells the workerd runtime to enable only the Async Local Storage builtin library (accessible via `node:async_hooks`).
1852
+ * - "v1" - this mode tells the workerd runtime to enable some Node.js builtin libraries (accessible only via `node:...` imports) but no globals.
1853
+ * - "v2" - this mode tells the workerd runtime to enable more Node.js builtin libraries (accessible both with and without the `node:` prefix)
1854
+ * and also some Node.js globals such as `Buffer`; it also turns on additional compile-time polyfills for those that are not provided by the runtime.
1855
+ * - null - no Node.js compatibility.
1856
+ */
1857
+ export declare type NodeJSCompatMode = "legacy" | "als" | "v1" | "v2" | null;
1858
+
1768
1859
  export declare class NoOpLog extends Log {
1769
1860
  constructor();
1770
1861
  protected log(): void;
@@ -1774,6 +1865,7 @@ export declare class NoOpLog extends Log {
1774
1865
  export declare function normaliseDurableObject(designator: NonNullable<z.infer<typeof DurableObjectsOptionsSchema>["durableObjects"]>[string]): {
1775
1866
  className: string;
1776
1867
  serviceName?: string;
1868
+ enableSql?: boolean;
1777
1869
  unsafeUniqueKey?: UnsafeUniqueKey;
1778
1870
  unsafePreventEviction?: boolean;
1779
1871
  };
@@ -2948,16 +3040,19 @@ export declare const PLUGINS: {
2948
3040
  durableObjects: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodObject<{
2949
3041
  className: z.ZodString;
2950
3042
  scriptName: z.ZodOptional<z.ZodString>;
3043
+ useSQLite: z.ZodOptional<z.ZodBoolean>;
2951
3044
  unsafeUniqueKey: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<kUnsafeEphemeralUniqueKey>]>>;
2952
3045
  unsafePreventEviction: z.ZodOptional<z.ZodBoolean>;
2953
3046
  }, "strip", z.ZodTypeAny, {
2954
3047
  className: string;
2955
3048
  scriptName?: string | undefined;
3049
+ useSQLite?: boolean | undefined;
2956
3050
  unsafeUniqueKey?: string | kUnsafeEphemeralUniqueKey | undefined;
2957
3051
  unsafePreventEviction?: boolean | undefined;
2958
3052
  }, {
2959
3053
  className: string;
2960
3054
  scriptName?: string | undefined;
3055
+ useSQLite?: boolean | undefined;
2961
3056
  unsafeUniqueKey?: string | kUnsafeEphemeralUniqueKey | undefined;
2962
3057
  unsafePreventEviction?: boolean | undefined;
2963
3058
  }>]>>>;
@@ -2965,6 +3060,7 @@ export declare const PLUGINS: {
2965
3060
  durableObjects?: Record<string, string | {
2966
3061
  className: string;
2967
3062
  scriptName?: string | undefined;
3063
+ useSQLite?: boolean | undefined;
2968
3064
  unsafeUniqueKey?: string | kUnsafeEphemeralUniqueKey | undefined;
2969
3065
  unsafePreventEviction?: boolean | undefined;
2970
3066
  }> | undefined;
@@ -2972,6 +3068,7 @@ export declare const PLUGINS: {
2972
3068
  durableObjects?: Record<string, string | {
2973
3069
  className: string;
2974
3070
  scriptName?: string | undefined;
3071
+ useSQLite?: boolean | undefined;
2975
3072
  unsafeUniqueKey?: string | kUnsafeEphemeralUniqueKey | undefined;
2976
3073
  unsafePreventEviction?: boolean | undefined;
2977
3074
  }> | undefined;
@@ -3123,23 +3220,41 @@ export declare const PLUGINS: {
3123
3220
  path: z.ZodEffects<z.ZodString, string, string>;
3124
3221
  bindingName: z.ZodOptional<z.ZodString>;
3125
3222
  routingConfig: z.ZodObject<{
3126
- hasUserWorker: z.ZodBoolean;
3223
+ has_user_worker: z.ZodOptional<z.ZodBoolean>;
3224
+ }, "strip", z.ZodTypeAny, {
3225
+ has_user_worker?: boolean;
3226
+ }, {
3227
+ has_user_worker?: boolean;
3228
+ }>;
3229
+ assetConfig: z.ZodObject<{
3230
+ html_handling: z.ZodOptional<z.ZodEnum<["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]>>;
3231
+ not_found_handling: z.ZodOptional<z.ZodEnum<["single-page-application", "404-page", "none"]>>;
3127
3232
  }, "strip", z.ZodTypeAny, {
3128
- hasUserWorker: boolean;
3233
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3234
+ not_found_handling?: "none" | "single-page-application" | "404-page";
3129
3235
  }, {
3130
- hasUserWorker: boolean;
3236
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3237
+ not_found_handling?: "none" | "single-page-application" | "404-page";
3131
3238
  }>;
3132
3239
  }, "strip", z.ZodTypeAny, {
3133
3240
  path: string;
3134
3241
  routingConfig: {
3135
- hasUserWorker: boolean;
3242
+ has_user_worker?: boolean;
3243
+ };
3244
+ assetConfig: {
3245
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3246
+ not_found_handling?: "none" | "single-page-application" | "404-page";
3136
3247
  };
3137
3248
  workerName?: string | undefined;
3138
3249
  bindingName?: string | undefined;
3139
3250
  }, {
3140
3251
  path: string;
3141
3252
  routingConfig: {
3142
- hasUserWorker: boolean;
3253
+ has_user_worker?: boolean;
3254
+ };
3255
+ assetConfig: {
3256
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3257
+ not_found_handling?: "none" | "single-page-application" | "404-page";
3143
3258
  };
3144
3259
  workerName?: string | undefined;
3145
3260
  bindingName?: string | undefined;
@@ -3148,7 +3263,11 @@ export declare const PLUGINS: {
3148
3263
  assets?: {
3149
3264
  path: string;
3150
3265
  routingConfig: {
3151
- hasUserWorker: boolean;
3266
+ has_user_worker?: boolean;
3267
+ };
3268
+ assetConfig: {
3269
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3270
+ not_found_handling?: "none" | "single-page-application" | "404-page";
3152
3271
  };
3153
3272
  workerName?: string | undefined;
3154
3273
  bindingName?: string | undefined;
@@ -3157,7 +3276,11 @@ export declare const PLUGINS: {
3157
3276
  assets?: {
3158
3277
  path: string;
3159
3278
  routingConfig: {
3160
- hasUserWorker: boolean;
3279
+ has_user_worker?: boolean;
3280
+ };
3281
+ assetConfig: {
3282
+ html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3283
+ not_found_handling?: "none" | "single-page-application" | "404-page";
3161
3284
  };
3162
3285
  workerName?: string | undefined;
3163
3286
  bindingName?: string | undefined;
@@ -3640,14 +3763,6 @@ export declare class RouterError extends MiniflareError<RouterErrorCode> {
3640
3763
 
3641
3764
  export declare type RouterErrorCode = "ERR_QUERY_STRING" | "ERR_INFIX_WILDCARD";
3642
3765
 
3643
- export declare const RoutingConfigSchema: z.ZodObject<{
3644
- hasUserWorker: z.ZodBoolean;
3645
- }, "strip", z.ZodTypeAny, {
3646
- hasUserWorker: boolean;
3647
- }, {
3648
- hasUserWorker: boolean;
3649
- }>;
3650
-
3651
3766
  export declare class Runtime {
3652
3767
  #private;
3653
3768
  updateConfig(configBuffer: Buffer, options: Abortable & RuntimeOptions): Promise<SocketPorts | undefined>;
@@ -4130,6 +4245,7 @@ export declare interface Worker_Binding_WrappedBinding {
4130
4245
  export declare type Worker_DurableObjectNamespace = {
4131
4246
  className?: string;
4132
4247
  preventEviction?: boolean;
4248
+ enableSql?: boolean;
4133
4249
  } & ({
4134
4250
  uniqueKey?: string;
4135
4251
  } | {