File tree Expand file tree Collapse file tree 11 files changed +101
-13
lines changed
wrangler/src/api/mixedMode Expand file tree Collapse file tree 11 files changed +101
-13
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " wrangler " : patch
3+ ---
4+
5+ remove experimental ` MixedModeConnectionString ` type
6+
7+ remove the experimental ` MixedModeConnectionString ` type which
8+ is now exposed by Miniflare instead
Original file line number Diff line number Diff line change 1+ ---
2+ " miniflare " : patch
3+ ---
4+
5+ add ` mixedModeConnectionString ` to the various binding configs
Original file line number Diff line number Diff line change 11import { z } from "zod" ;
22import { Request , Response } from "../../http" ;
3- import { HOST_CAPNP_CONNECT , Miniflare } from "../../index" ;
3+ import {
4+ HOST_CAPNP_CONNECT ,
5+ Miniflare ,
6+ MixedModeConnectionString ,
7+ } from "../../index" ;
48import {
59 ExternalServer ,
610 HttpOptions_Style ,
@@ -91,6 +95,7 @@ export const ServiceDesignatorSchema = z.union([
9195 name : z . union ( [ z . string ( ) , z . literal ( kCurrentWorker ) ] ) ,
9296 entrypoint : z . ostring ( ) ,
9397 props : z . record ( z . unknown ( ) ) . optional ( ) ,
98+ mixedModeConnectionString : z . custom < MixedModeConnectionString > ( ) . optional ( ) ,
9499 } ) ,
95100 z . object ( { network : NetworkSchema } ) ,
96101 z . object ( { external : ExternalServerSchema } ) ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111 getMiniflareObjectBindings ,
1212 getPersistPath ,
1313 migrateDatabase ,
14+ MixedModeConnectionString ,
1415 namespaceEntries ,
1516 namespaceKeys ,
1617 objectEntryWorker ,
@@ -21,7 +22,20 @@ import {
2122} from "../shared" ;
2223
2324export const D1OptionsSchema = z . object ( {
24- d1Databases : z . union ( [ z . record ( z . string ( ) ) , z . string ( ) . array ( ) ] ) . optional ( ) ,
25+ d1Databases : z
26+ . union ( [
27+ z . record ( z . string ( ) ) ,
28+ z . record (
29+ z . object ( {
30+ id : z . string ( ) ,
31+ mixedModeConnectionString : z
32+ . custom < MixedModeConnectionString > ( )
33+ . optional ( ) ,
34+ } )
35+ ) ,
36+ z . string ( ) . array ( ) ,
37+ ] )
38+ . optional ( ) ,
2539} ) ;
2640export const D1SharedOptionsSchema = z . object ( {
2741 d1Persist : PersistenceSchema ,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { getUserServiceName } from "../core";
55import {
66 getPersistPath ,
77 kUnsafeEphemeralUniqueKey ,
8+ MixedModeConnectionString ,
89 PersistenceSchema ,
910 Plugin ,
1011 ProxyNodeBinding ,
@@ -29,6 +30,9 @@ export const DurableObjectsOptionsSchema = z.object({
2930 . optional ( ) ,
3031 // Prevents the Durable Object being evicted.
3132 unsafePreventEviction : z . boolean ( ) . optional ( ) ,
33+ mixedModeConnectionString : z
34+ . custom < MixedModeConnectionString > ( )
35+ . optional ( ) ,
3236 } ) ,
3337 ] )
3438 )
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212 getMiniflareObjectBindings ,
1313 getPersistPath ,
1414 migrateDatabase ,
15+ MixedModeConnectionString ,
1516 namespaceEntries ,
1617 namespaceKeys ,
1718 objectEntryWorker ,
@@ -29,7 +30,20 @@ import {
2930} from "./sites" ;
3031
3132export const KVOptionsSchema = z . object ( {
32- kvNamespaces : z . union ( [ z . record ( z . string ( ) ) , z . string ( ) . array ( ) ] ) . optional ( ) ,
33+ kvNamespaces : z
34+ . union ( [
35+ z . record ( z . string ( ) ) ,
36+ z . record (
37+ z . object ( {
38+ id : z . string ( ) ,
39+ mixedModeConnectionString : z
40+ . custom < MixedModeConnectionString > ( )
41+ . optional ( ) ,
42+ } )
43+ ) ,
44+ z . string ( ) . array ( ) ,
45+ ] )
46+ . optional ( ) ,
3347
3448 // Workers Sites
3549 sitePath : PathSchema . optional ( ) ,
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
1515import { getUserServiceName } from "../core" ;
1616import {
1717 getMiniflareObjectBindings ,
18+ MixedModeConnectionString ,
1819 objectEntryWorker ,
1920 Plugin ,
2021 ProxyNodeBinding ,
@@ -24,7 +25,15 @@ import {
2425export const QueuesOptionsSchema = z . object ( {
2526 queueProducers : z
2627 . union ( [
27- z . record ( QueueProducerOptionsSchema ) ,
28+ z . record (
29+ QueueProducerOptionsSchema . merge (
30+ z . object ( {
31+ mixedModeConnectionString : z
32+ . custom < MixedModeConnectionString > ( )
33+ . optional ( ) ,
34+ } )
35+ )
36+ ) ,
2837 z . string ( ) . array ( ) ,
2938 z . record ( z . string ( ) ) ,
3039 ] )
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111 getMiniflareObjectBindings ,
1212 getPersistPath ,
1313 migrateDatabase ,
14+ MixedModeConnectionString ,
1415 namespaceEntries ,
1516 namespaceKeys ,
1617 objectEntryWorker ,
@@ -21,7 +22,20 @@ import {
2122} from "../shared" ;
2223
2324export const R2OptionsSchema = z . object ( {
24- r2Buckets : z . union ( [ z . record ( z . string ( ) ) , z . string ( ) . array ( ) ] ) . optional ( ) ,
25+ r2Buckets : z
26+ . union ( [
27+ z . record ( z . string ( ) ) ,
28+ z . record (
29+ z . object ( {
30+ id : z . string ( ) ,
31+ mixedModeConnectionString : z
32+ . custom < MixedModeConnectionString > ( )
33+ . optional ( ) ,
34+ } )
35+ ) ,
36+ z . string ( ) . array ( ) ,
37+ ] )
38+ . optional ( ) ,
2539} ) ;
2640export const R2SharedOptionsSchema = z . object ( {
2741 r2Persist : PersistenceSchema ,
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ export class ProxyNodeBinding {
125125}
126126
127127export function namespaceKeys (
128- namespaces ?: Record < string , string > | string [ ]
128+ namespaces ?: Record < string , string | { id : string } > | string [ ]
129129) : string [ ] {
130130 if ( Array . isArray ( namespaces ) ) {
131131 return namespaces ;
@@ -136,13 +136,28 @@ export function namespaceKeys(
136136 }
137137}
138138
139+ export type MixedModeConnectionString = URL & {
140+ __brand : "MixedModeConnectionString" ;
141+ } ;
142+
139143export function namespaceEntries (
140- namespaces ?: Record < string , string > | string [ ]
144+ namespaces ?:
145+ | Record <
146+ string ,
147+ | string
148+ | { id : string ; mixedModeConnectionString ?: MixedModeConnectionString }
149+ >
150+ | string [ ]
141151) : [ bindingName : string , id : string ] [ ] {
142152 if ( Array . isArray ( namespaces ) ) {
143153 return namespaces . map ( ( bindingName ) => [ bindingName , bindingName ] ) ;
144154 } else if ( namespaces !== undefined ) {
145- return Object . entries ( namespaces ) ;
155+ return Object . entries ( namespaces ) . map ( ( [ key , value ] ) => {
156+ if ( typeof value === "string" ) {
157+ return [ key , value ] ;
158+ }
159+ return [ key , value . id ] ;
160+ } ) ;
146161 } else {
147162 return [ ] ;
148163 }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { Service } from "../../runtime";
55import { getUserServiceName } from "../core" ;
66import {
77 getPersistPath ,
8+ MixedModeConnectionString ,
89 PersistenceSchema ,
910 Plugin ,
1011 ProxyNodeBinding ,
@@ -17,6 +18,9 @@ export const WorkflowsOptionsSchema = z.object({
1718 name : z . string ( ) ,
1819 className : z . string ( ) ,
1920 scriptName : z . string ( ) . optional ( ) ,
21+ mixedModeConnectionString : z
22+ . custom < MixedModeConnectionString > ( )
23+ . optional ( ) ,
2024 } )
2125 )
2226 . optional ( ) ,
You can’t perform that action at this time.
0 commit comments