Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add strict Durable Object jurisdiction/locationHint types #471

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/workerd/api/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class DurableObjectNamespace: public jsg::Object {
// Restricts the new unique ID to a set of colos within a jurisdiction.

JSG_STRUCT(jurisdiction);

mrbbot marked this conversation as resolved.
Show resolved Hide resolved
JSG_STRUCT_TS_DEFINE(type DurableObjectJurisdiction = "eu" | "fedramp");
JSG_STRUCT_TS_OVERRIDE({
jurisdiction?: DurableObjectJurisdiction;
});
};

jsg::Ref<DurableObjectId> newUniqueId(jsg::Optional<NewUniqueIdOptions> options);
Expand All @@ -135,6 +140,11 @@ class DurableObjectNamespace: public jsg::Object {
jsg::Optional<kj::String> locationHint;

JSG_STRUCT(locationHint);

mrbbot marked this conversation as resolved.
Show resolved Hide resolved
JSG_STRUCT_TS_DEFINE(type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me");
JSG_STRUCT_TS_OVERRIDE({
locationHint?: DurableObjectLocationHint;
});
};

jsg::Ref<DurableObject> get(
Expand Down Expand Up @@ -162,7 +172,11 @@ class DurableObjectNamespace: public jsg::Object {
JSG_METHOD(getExisting);
}
JSG_METHOD(jurisdiction);

JSG_TS_ROOT();
JSG_TS_OVERRIDE({
jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
});
}

private:
Expand Down