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.
- package/README.md +75 -8
- package/dist/src/index.d.ts +3186 -631
- package/dist/src/index.js +18023 -7793
- package/dist/src/index.js.map +3 -3
- package/dist/src/workers/analytics-engine/analytics-engine.worker.js +15 -0
- package/dist/src/workers/analytics-engine/analytics-engine.worker.js.map +6 -0
- package/dist/src/workers/assets/assets-kv.worker.js +1 -1
- package/dist/src/workers/assets/assets-kv.worker.js.map +1 -1
- package/dist/src/workers/assets/assets.worker.js +5011 -5278
- package/dist/src/workers/assets/assets.worker.js.map +3 -3
- package/dist/src/workers/assets/router.worker.js +5112 -5885
- package/dist/src/workers/assets/router.worker.js.map +3 -3
- package/dist/src/workers/assets/rpc-proxy.worker.js +18 -0
- package/dist/src/workers/assets/rpc-proxy.worker.js.map +6 -0
- package/dist/src/workers/cache/cache-entry.worker.js.map +1 -1
- package/dist/src/workers/cache/cache.worker.js +20 -30
- package/dist/src/workers/cache/cache.worker.js.map +2 -2
- package/dist/src/workers/core/entry.worker.js +3413 -119
- package/dist/src/workers/core/entry.worker.js.map +3 -3
- package/dist/src/workers/core/strip-cf-connecting-ip.worker.js +11 -0
- package/dist/src/workers/core/strip-cf-connecting-ip.worker.js.map +6 -0
- package/dist/src/workers/d1/database.worker.js +9 -7
- package/dist/src/workers/d1/database.worker.js.map +1 -1
- package/dist/src/workers/dispatch-namespace/dispatch-namespace.worker.js +25 -0
- package/dist/src/workers/dispatch-namespace/dispatch-namespace.worker.js.map +6 -0
- package/dist/src/workers/email/email.worker.js +23 -0
- package/dist/src/workers/email/email.worker.js.map +6 -0
- package/dist/src/workers/email/send_email.worker.js +3181 -0
- package/dist/src/workers/email/send_email.worker.js.map +6 -0
- package/dist/src/workers/kv/namespace.worker.js +69 -6
- package/dist/src/workers/kv/namespace.worker.js.map +2 -2
- package/dist/src/workers/kv/sites.worker.js +5 -7
- package/dist/src/workers/kv/sites.worker.js.map +1 -1
- package/dist/src/workers/pipelines/pipeline.worker.js +11 -0
- package/dist/src/workers/pipelines/pipeline.worker.js.map +6 -0
- package/dist/src/workers/queues/broker.worker.js +17 -20
- package/dist/src/workers/queues/broker.worker.js.map +1 -1
- package/dist/src/workers/r2/bucket.worker.js +23 -46
- package/dist/src/workers/r2/bucket.worker.js.map +1 -1
- package/dist/src/workers/ratelimit/ratelimit.worker.js.map +1 -1
- package/dist/src/workers/secrets-store/secret.worker.js +65 -0
- package/dist/src/workers/secrets-store/secret.worker.js.map +6 -0
- package/dist/src/workers/shared/index.worker.js +28 -51
- package/dist/src/workers/shared/index.worker.js.map +1 -1
- package/dist/src/workers/shared/mixed-mode-client.worker.js +18 -0
- package/dist/src/workers/shared/mixed-mode-client.worker.js.map +6 -0
- package/dist/src/workers/shared/zod.worker.js +80 -84
- package/dist/src/workers/shared/zod.worker.js.map +1 -1
- package/dist/src/workers/workflows/binding.worker.js +2107 -0
- package/dist/src/workers/workflows/binding.worker.js.map +6 -0
- 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
|
|
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
|
|
114
|
-
|
|
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,
|
|
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
|
|
346
|
-
|
|
347
|
-
|
|
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_
|