@@ -157,7 +157,8 @@ class DurableObjectNamespace: public jsg::Object {
157157 ActorGetMode mode,
158158 bool enableReplicaRouting,
159159 ActorRoutingMode routingMode,
160- SpanParent parentSpan) = 0;
160+ SpanParent parentSpan,
161+ kj::Maybe<ActorVersion> version) = 0;
161162 };
162163
163164 DurableObjectNamespace (uint channel, kj::Own<ActorIdFactory> idFactory)
@@ -202,17 +203,39 @@ class DurableObjectNamespace: public jsg::Object {
202203 // - "primary-only": guarantees we route directly to the primary (skip any replicas).
203204 jsg::Optional<kj::String> routingMode;
204205
205- JSG_STRUCT (locationHint, routingMode);
206+ struct VersionOptions {
207+ jsg::Optional<kj::String> cohort;
208+ JSG_STRUCT (cohort);
209+ JSG_STRUCT_TS_OVERRIDE_DYNAMIC (CompatibilityFlags::Reader flags) {
210+ if (!flags.getWorkerdExperimental ()) {
211+ JSG_TS_OVERRIDE (type VersionOptions = never);
212+ }
213+ }
214+ };
215+ jsg::Optional<VersionOptions> version;
216+
217+ JSG_STRUCT (locationHint, routingMode, version);
206218
207219 // DurableObjectLocationHint values from https://developers.cloudflare.com/workers/runtime-apis/durable-objects/#providing-a-location-hint
208220 JSG_STRUCT_TS_DEFINE (
209221 type DurableObjectLocationHint = " wnam" | " enam" | " sam" | " weur" | " eeur" | " apac" | " oc" | " afr" | " me" ;
210222 type DurableObjectRoutingMode = " primary-only" );
211223
212- JSG_STRUCT_TS_OVERRIDE ({
213- locationHint?: DurableObjectLocationHint;
214- routingMode?: DurableObjectRoutingMode;
215- });
224+ JSG_STRUCT_TS_OVERRIDE_DYNAMIC (CompatibilityFlags::Reader flags) {
225+ if (flags.getWorkerdExperimental ()) {
226+ JSG_TS_OVERRIDE ({
227+ locationHint?: DurableObjectLocationHint;
228+ routingMode?: DurableObjectRoutingMode;
229+ version?: { cohort?: string };
230+ });
231+ } else {
232+ JSG_TS_OVERRIDE ({
233+ locationHint?: DurableObjectLocationHint;
234+ routingMode?: DurableObjectRoutingMode;
235+ version: never;
236+ });
237+ }
238+ }
216239 };
217240
218241 // Gets a durable object by ID or creates it if it doesn't already exist.
@@ -281,13 +304,15 @@ class GlobalActorOutgoingFactory final: public Fetcher::OutgoingFactory {
281304 kj::Maybe<kj::String> locationHint,
282305 ActorGetMode mode,
283306 bool enableReplicaRouting,
284- ActorRoutingMode routingMode)
307+ ActorRoutingMode routingMode,
308+ kj::Maybe<ActorVersion> version)
285309 : channelIdOrFactory(kj::mv(channelIdOrFactory)),
286310 id (kj::mv(id)),
287311 locationHint(kj::mv(locationHint)),
288312 mode(mode),
289313 enableReplicaRouting(enableReplicaRouting),
290- routingMode(routingMode) {}
314+ routingMode(routingMode),
315+ version(kj::mv(version)) {}
291316
292317 kj::Own<WorkerInterface> newSingleUseClient (kj::Maybe<kj::String> cfStr) override ;
293318
@@ -298,6 +323,7 @@ class GlobalActorOutgoingFactory final: public Fetcher::OutgoingFactory {
298323 ActorGetMode mode;
299324 bool enableReplicaRouting;
300325 ActorRoutingMode routingMode;
326+ kj::Maybe<ActorVersion> version;
301327 kj::Maybe<kj::Own<IoChannelFactory::ActorChannel>> actorChannel;
302328};
303329
@@ -367,6 +393,7 @@ class DurableObjectClass: public jsg::Object {
367393#define EW_ACTOR_ISOLATE_TYPES \
368394 api::ColoLocalActorNamespace, api::DurableObject, api::DurableObjectId, \
369395 api::DurableObjectNamespace, api::DurableObjectNamespace::NewUniqueIdOptions, \
370- api::DurableObjectNamespace::GetDurableObjectOptions, api::DurableObjectClass
396+ api::DurableObjectNamespace::GetDurableObjectOptions, api::DurableObjectClass, \
397+ api::DurableObjectNamespace::GetDurableObjectOptions::VersionOptions
371398
372399} // namespace workerd::api
0 commit comments