miniflare 0.0.0-a67cdbfc4 → 0.0.0-a6cfaa2bd

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.
Files changed (51) hide show
  1. package/README.md +75 -8
  2. package/dist/src/index.d.ts +3186 -631
  3. package/dist/src/index.js +18023 -7793
  4. package/dist/src/index.js.map +3 -3
  5. package/dist/src/workers/analytics-engine/analytics-engine.worker.js +15 -0
  6. package/dist/src/workers/analytics-engine/analytics-engine.worker.js.map +6 -0
  7. package/dist/src/workers/assets/assets-kv.worker.js +1 -1
  8. package/dist/src/workers/assets/assets-kv.worker.js.map +1 -1
  9. package/dist/src/workers/assets/assets.worker.js +5011 -5278
  10. package/dist/src/workers/assets/assets.worker.js.map +3 -3
  11. package/dist/src/workers/assets/router.worker.js +5112 -5885
  12. package/dist/src/workers/assets/router.worker.js.map +3 -3
  13. package/dist/src/workers/assets/rpc-proxy.worker.js +18 -0
  14. package/dist/src/workers/assets/rpc-proxy.worker.js.map +6 -0
  15. package/dist/src/workers/cache/cache-entry.worker.js.map +1 -1
  16. package/dist/src/workers/cache/cache.worker.js +20 -30
  17. package/dist/src/workers/cache/cache.worker.js.map +2 -2
  18. package/dist/src/workers/core/entry.worker.js +3413 -119
  19. package/dist/src/workers/core/entry.worker.js.map +3 -3
  20. package/dist/src/workers/core/strip-cf-connecting-ip.worker.js +11 -0
  21. package/dist/src/workers/core/strip-cf-connecting-ip.worker.js.map +6 -0
  22. package/dist/src/workers/d1/database.worker.js +9 -7
  23. package/dist/src/workers/d1/database.worker.js.map +1 -1
  24. package/dist/src/workers/dispatch-namespace/dispatch-namespace.worker.js +25 -0
  25. package/dist/src/workers/dispatch-namespace/dispatch-namespace.worker.js.map +6 -0
  26. package/dist/src/workers/email/email.worker.js +23 -0
  27. package/dist/src/workers/email/email.worker.js.map +6 -0
  28. package/dist/src/workers/email/send_email.worker.js +3181 -0
  29. package/dist/src/workers/email/send_email.worker.js.map +6 -0
  30. package/dist/src/workers/kv/namespace.worker.js +69 -6
  31. package/dist/src/workers/kv/namespace.worker.js.map +2 -2
  32. package/dist/src/workers/kv/sites.worker.js +5 -7
  33. package/dist/src/workers/kv/sites.worker.js.map +1 -1
  34. package/dist/src/workers/pipelines/pipeline.worker.js +11 -0
  35. package/dist/src/workers/pipelines/pipeline.worker.js.map +6 -0
  36. package/dist/src/workers/queues/broker.worker.js +17 -20
  37. package/dist/src/workers/queues/broker.worker.js.map +1 -1
  38. package/dist/src/workers/r2/bucket.worker.js +23 -46
  39. package/dist/src/workers/r2/bucket.worker.js.map +1 -1
  40. package/dist/src/workers/ratelimit/ratelimit.worker.js.map +1 -1
  41. package/dist/src/workers/secrets-store/secret.worker.js +65 -0
  42. package/dist/src/workers/secrets-store/secret.worker.js.map +6 -0
  43. package/dist/src/workers/shared/index.worker.js +28 -51
  44. package/dist/src/workers/shared/index.worker.js.map +1 -1
  45. package/dist/src/workers/shared/mixed-mode-client.worker.js +18 -0
  46. package/dist/src/workers/shared/mixed-mode-client.worker.js.map +6 -0
  47. package/dist/src/workers/shared/zod.worker.js +80 -84
  48. package/dist/src/workers/shared/zod.worker.js.map +1 -1
  49. package/dist/src/workers/workflows/binding.worker.js +2107 -0
  50. package/dist/src/workers/workflows/binding.worker.js.map +6 -0
  51. package/package.json +33 -26
package/README.md CHANGED
@@ -107,11 +107,13 @@ modules.
107
107
 
108
108
  Represents where data should be persisted, if anywhere.
109
109
 
110
- - If this is `undefined` or `false`, data will be stored in-memory and only
110
+ - If this is `undefined`, it defaults to `true` if `defaultPersistRoot` is set
111
+ or otherwise defaults to `false`.
112
+ - If this is`false`, data will be stored in-memory and only
111
113
  persist between `Miniflare#setOptions()` calls, not restarts nor
112
114
  `new Miniflare` instances.
113
- - If this is `true`, data will be stored on the file-system, in the `$PWD/.mf`
114
- directory.
115
+ - If this is `true`, data will be stored in a subdirectory of the `defaultPersistRoot` path if `defaultPersistRoot` is set
116
+ or otherwise will be stored in a subdirectory of `$PWD/.mf`.
115
117
  - If this looks like a URL, then:
116
118
  - If the protocol is `memory:`, data will be stored in-memory as above.
117
119
  - If the protocol is `file:`, data will be stored on the file-system, in the
@@ -214,6 +216,20 @@ Options for an individual Worker/"nanoservice". All bindings are accessible on
214
216
  the global scope in service-worker format Workers, or via the 2nd `env`
215
217
  parameter in module format Workers.
216
218
 
219
+ ### `interface WorkflowOptions`
220
+
221
+ - `name: string`
222
+
223
+ The name of the Workflow.
224
+
225
+ - `className: string`
226
+
227
+ The name of the class exported from the Worker that implements the `WorkflowEntrypoint`.
228
+
229
+ - `scriptName?`: string
230
+
231
+ The name of the script that includes the `WorkflowEntrypoint`. This is optional because it defaults to the current script if not set.
232
+
217
233
  #### Core
218
234
 
219
235
  - `name?: string`
@@ -312,7 +328,7 @@ parameter in module format Workers.
312
328
  Record mapping binding name to paths containing arbitrary binary data to
313
329
  inject as `ArrayBuffer` bindings into this Worker.
314
330
 
315
- - `serviceBindings?: Record<string, string | typeof kCurrentWorker | { name: string | typeof kCurrentWorker, entrypoint?: string } | { network: Network } | { external: ExternalServer } | { disk: DiskDirectory } | (request: Request, instance: Miniflare) => Awaitable<Response>>`
331
+ - `serviceBindings?: Record<string, string | typeof kCurrentWorker | { name: string | typeof kCurrentWorker, entrypoint?: string } | { network: Network } | { external: ExternalServer } | { disk: DiskDirectory } | { node: (req: http.IncomingMessage, res: http.ServerResponse, miniflare: Miniflare) => Awaitable<void> } | (request: Request, miniflare: Miniflare) => Awaitable<Response>>`
316
332
 
317
333
  Record mapping binding name to service designators to inject as
318
334
  `{ fetch: typeof fetch }`
@@ -342,9 +358,10 @@ parameter in module format Workers.
342
358
  [`workerd` `DiskDirectory` struct](https://github.com/cloudflare/workerd/blob/bdbd6075c7c53948050c52d22f2dfa37bf376253/src/workerd/server/workerd.capnp#L600-L643),
343
359
  requests will be dispatched to an HTTP service backed by an on-disk
344
360
  directory.
345
- - If the designator is a function, requests will be dispatched to your custom
346
- handler. This allows you to access data and functions defined in Node.js
347
- from your Worker. Note `instance` will be the `Miniflare` instance
361
+ - If the designator is an object of the form `{ node: (req: http.IncomingMessage, res: http.ServerResponse, miniflare: Miniflare) => Awaitable<void> }`, requests will be dispatched to your custom Node handler. This allows you to access data and functions defined in Node.js from your Worker using Node.js `req` and `res` objects. Note, `miniflare` will be the `Miniflare` instance dispatching the request.
362
+ - If the designator is a function with the signature `(request: Request, miniflare: Miniflare) => Response`, requests will be dispatched to your custom
363
+ fetch handler. This allows you to access data and functions defined in Node.js
364
+ from your Worker using fetch `Request` and `Response` objects. Note, `miniflare` will be the `Miniflare` instance
348
365
  dispatching the request.
349
366
 
350
367
  <!--prettier-ignore-start-->
@@ -455,7 +472,7 @@ parameter in module format Workers.
455
472
 
456
473
  <!--prettier-ignore-end-->
457
474
 
458
- - `outboundService?: string | { network: Network } | { external: ExternalServer } | { disk: DiskDirectory } | (request: Request) => Awaitable<Response>`
475
+ - `outboundService?: string | { network: Network } | { external: ExternalServer } | { disk: DiskDirectory } | { node: (req: http.IncomingMessage, res: http.ServerResponse, miniflare: Miniflare) => Awaitable<void> } | (request: Request, miniflare: Miniflare) => Awaitable<Response>`
459
476
 
460
477
  Dispatch this Worker's global `fetch()` and `connect()` requests to the
461
478
  configured service. Service designators follow the same rules above for
@@ -476,6 +493,29 @@ parameter in module format Workers.
476
493
  as deployed Workers. If no routes match, Miniflare will fallback to the Worker
477
494
  defined first.
478
495
 
496
+ - `defaultPersistRoot?: string`
497
+
498
+ Specifies the default directory where Miniflare will write persisted data when persistence is enabled.
499
+
500
+ ```js
501
+ // Without `defaultPersistRoot`
502
+ new Miniflare({
503
+ kvPersist: undefined, // → "/(tmp)/kv"
504
+ d1Persist: true, // → "$PWD/.mf/d1"
505
+ r2Persist: false, // → "/(tmp)/r2"
506
+ cachePersist: "/my-cache", // → "/my-cache"
507
+ });
508
+
509
+ // With `defaultPersistRoot`
510
+ new Miniflare({
511
+ defaultPersistRoot: "/storage",
512
+ kvPersist: undefined, // → "/storage/kv"
513
+ d1Persist: true, // → "/storage/d1"
514
+ r2Persist: false, // → "/(tmp)/r2"
515
+ cachePersist: "/my-cache", // → "/my-cache"
516
+ });
517
+ ```
518
+
479
519
  #### Cache
480
520
 
481
521
  - `cache?: boolean`
@@ -574,6 +614,29 @@ parameter in module format Workers.
574
614
  have at most one consumer. If a `string[]` of queue names is specified,
575
615
  default consumer options will be used.
576
616
 
617
+ #### Assets
618
+
619
+ - `directory?: string`
620
+ Path to serve Workers static asset files from.
621
+
622
+ - `binding?: string`
623
+ Binding name to inject as a `Fetcher` binding to allow access to static assets from within the Worker.
624
+
625
+ - `assetOptions?: { html_handling?: HTMLHandlingOptions, not_found_handling?: NotFoundHandlingOptions}`
626
+ Configuration for file-based asset routing - see [docs](https://developers.cloudflare.com/workers/static-assets/routing/#routing-configuration) for options
627
+
628
+ #### Pipelines
629
+
630
+ - `pipelines?: Record<string, PipelineOptions> | string[]`
631
+
632
+ Record mapping binding name to a Pipeline. Different workers may bind to the same Pipeline with different bindings
633
+ names. If a `string[]` of pipeline names, the binding and Pipeline name are assumed to be the same.
634
+
635
+ #### Workflows
636
+
637
+ - `workflows?: WorkflowOptions[]`
638
+ Configuration for one or more Workflows in your project.
639
+
577
640
  #### Analytics Engine, Sending Email, Vectorize and Workers for Platforms
578
641
 
579
642
  _Not yet supported_
@@ -714,6 +777,10 @@ Options shared between all Workers/"nanoservices".
714
777
 
715
778
  Where to persist data stored in D1 databases. See docs for `Persistence`.
716
779
 
780
+ - `workflowsPersist?: Persistence`
781
+
782
+ Where to persist data stored in Workflows. See docs for `Persistence`.
783
+
717
784
  #### Analytics Engine, Browser Rendering, Sending Email, Vectorize, Workers AI and Workers for Platforms
718
785
 
719
786
  _Not yet supported_