Expand description
The Bynk standard library’s first-party sources, as data.
The bynk conformance surface, the Bynk-written commons (bynk.list,
bynk.map, bynk.string, bynk.locale, bynk.locale.types) and the
bynk.cloudflare platform adapter ship with the compiler rather than being
authored by the user. This crate holds their .bynk sources, their
per-platform TypeScript bindings and the metadata the toolchain reads about
them, embedded with include_str!. It holds no logic: bynk-check parses and
injects these sources when a project uses or consumes them, and provides
each binding for the selected Platform. The bynk root namespace is
reserved (bynk.namespace.reserved) so user code can never collide with it.
The sources live under lib/: the portable layers in lib/core/ (with the
bynk surface’s bindings in lib/core/bindings/) and the platform adapter in
lib/cloudflare/. Nothing in lib/core/ depends on lib/cloudflare/, so the
platform layer can be split out later without renaming a unit.
Structs§
- First
Party Npm - A first-party npm dependency (ADR 0799 C, #3328): an npm package the
toolchain itself emits into
out/package.jsonfor a built-in binding. - Instantiable
- A capability a context may declare instances of (S4a, #1966, track D3).
- Singleton
- A platform capability with exactly one binding per Worker (#3300): Version
metadata’s
[version_metadata]and Workers AI’s[ai]. - Unit
- One first-party unit, as data (standard-library track, S1 #1945). Adding a
unit to the standard library is an entry in
UNITSplus its files; the checker’s injection reads this table and needs no change.
Enums§
- Binding
- The TypeScript binding the toolchain supplies for a first-party unit.
- Option
Kind - The literal an instance option takes (standard-library P3, #2342).
- Platform
- The deploy platform — a selection axis distinct from the
--target {bundle,workers}emit mode (§6.2). It chooses whichbynk-<platform>.tsbinding is linked for thebynksurface. v0.17 shippedcloudflare; v0.18 addsnode, making the axis observable (and giving v0.19’s platform-lock enforcement a second platform to fire against). - Reach
- What reaches a first-party npm dependency (see
FirstPartyNpm::reached_by), by the construct that needs it, never by text in a source file. - Stability
- Whether a first-party item is under the 1.0 promise (track D2).
- Unit
Kind - What a first-party unit is, and so how a project brings it in: an adapter is
injected when a unit
consumesit, a commons when a unitusesit. Local to this crate, which has no dependencies;bynk-checkmaps it onto its own unit kind.
Constants§
- AI_
BINDING_ NAME - The Worker binding of the
Aicapability (#3478): Workers AI’s binding,[ai] binding = "AI", the name Cloudflare’s own documentation uses. - AI_
SEARCH_ BINDING_ PREFIX - The Worker binding prefix of an
AiSearchinstance (#3480):capability Kb = AiSearch @instance("support-docs")binds asAI_SEARCH_KB, an[[ai_search]]entry. - AI_
SEARCH_ INSTANCE_ OPTION - The option of an
AiSearchinstance that names the instance, by the name the account gives it. It is used as written in every environment, andbynk deploylinks to it and never creates it (#3480 Decisions A and B). - ANALYTICS_
BINDING_ PREFIX - The Worker binding prefix of an
Analyticsinstance (standard-library P3b, #2582):capability Signups = Analyticsbinds asANALYTICS_SIGNUPS, an[[analytics_engine_datasets]]entry. It takes no options:bynk deployderives the dataset’s name (track A12). - ANALYTICS_
SQL_ BINDING_ NAME - The Worker binding of the
AnalyticsSqlcapability (#3513 B): Cloudflare’s Analytics SQL binding,[analytics] binding = "CF_ANALYTICS_SQL". Cloudflare’s own documentation names itANALYTICS_SQL; theCF_prefix keeps it clear of anAnalyticsinstance’s binding (capability Sql = Analyticswould bind asANALYTICS_SQL). - BYNK_
ADAPTER_ SRC - The reserved
bynkconformance-surface adapter (env-free core). It has nobindingclause — the toolchain supplies one per platform (seePlatform::bynk_binding_source). - BYNK_
CRYPTO_ SRC bynk.crypto— digests, HMAC, constant-time comparison, and signing and verification with imported keys, asEffects over Web Crypto.- BYNK_
LIST_ SRC bynk.list— combinators over theListkernel (fold,prepend,length,get,foldEff), written in ordinary Bynk (decision 0034): the first real consumer of v0.20a generics, lambdas, and effectful traversal. Order-preserving combinators build withfold+prependand a finalreverse— O(n) builds, neverappend(which would be O(n²) over the array lowering).- BYNK_
LOCALE_ SRC bynk.locale— the bundle-freerender/renderArghelpers and themessage/withText/withWhole/withNum/withMomentbuilder API (slice 1:renderformatscodeplus a deterministic sorted-by-key rendering ofparams; no lookup, no locale-dependent behaviour).uses bynk.locale.typesfor the types its own signatures name.- BYNK_
LOCALE_ TYPES_ SRC bynk.locale.types—LocaleTag,MessageArg,Message: a dependency-free leaf (nousesof its own) so any consumer, including thebynkadapter itself, can reach these types without also reachingbynk.locale’s value-level API.- BYNK_
MAP_ SRC bynk.map— combinators over theMapkernel (empty,insert,get,keys,length).fromListis deliberately absent: Bynk has no pair type to spell aList[(K, V)]with, so map construction isMap.empty()- BYNK_
SET_ SRC bynk.set(standard-library K6a, #2596) — Bynk-written combinators over the built-inSetkernel (length,contains,insert,remove,toList,Set.of):union,intersect,difference,isSubsetOf,filter,map.- BYNK_
STRING_ SRC bynk.string— Bynk-written helpers over the v0.22a string kernel (concat, theListfold, and theOptionkernel methods). The kernel itself is compiler built-in (ADR 0046); only derived helpers live here.joinfolds toOption[String]so empty-string elements are joined faithfully (a bare""accumulator could not tell “nothing yet” from “first element was empty”).- BYNK_
SURFACE_ CAPABILITIES - The capabilities the env-free
bynksurface exports (itsexports capability { … }line inbynk.bynk). First-party symbols live on synthetic files and are excluded from the binding index, so the unknown-name quick-fix (#852) offeringconsumes bynk { … }needs this explicit list. Kept in sync with the adapter source bybynk_surface_capabilities_match_the_adapter. - BYNK_
TESTING_ SRC bynk.testing, the typed-read test support. Compiled in only with thetest-supportfeature, which the toolchain’s own test corpus enables: a released toolchain does not contain the unit.- BYNK_
UNIT - The unit name of the reserved first-party surface adapter.
- BYNK_
URL_ SRC bynk.url(standard-library K2, #2594) — aUrlrecord with RFC 3986parse/formatand query-string helpers, written in Bynk over theStringkernel. Only percent-encoding is kernel (percentEncode,percentDecode): it needs a string’s UTF-8 bytes.Urlis a record here, not a base type, because a base type’s name is a lexer token, andUrlas a keyword would break every usertype Url.- CLOUDFLARE_
ADAPTER_ SRC - The first-party Cloudflare platform adapter (v0.19): the platform’s real
infrastructure capabilities, as they are — no portable intersection
(decision 0016). The v0.19 surface was the minimal, collection-free
Kv(decision 0023); v0.23 adds thelistdrain andputTtl(0050/0051); structured values are v0.22-codec composition, andQueueremains its own future increment. Like thebynksurface it has nobindingclause — the toolchain supplies the binding. - CLOUDFLARE_
BINDING_ FILENAME - The output path of the Cloudflare platform adapter’s binding module,
beside the adapter’s emitted
bynk/cloudflare.ts(distinct from thebynksurface’s per-platformbynk-cloudflare.ts). - CLOUDFLARE_
UNIT - The unit name of the first-party Cloudflare platform adapter (v0.19,
decision 0026): inside the reserved
bynk.*prefix, so no separate reservation rule is needed. The surface unitbynkstays the portability marker;bynk.<platform>units are the platform-locked ones. - CONTAINER_
BINDING_ PREFIX - The Worker binding prefix of a
Containerinstance (#3477):capability Renderer = Container @build("containers/renderer") @port(8080)binds asCONTAINER_RENDERER, a Durable Object namespace whose class (derived from the capability’s name) runs the container. - CONTAINER_
BUILD_ OPTION - A
Containerinstance’s build context: a project-relative directory that holds aDockerfile(#3477 B). - CONTAINER_
FORWARD_ OPTION - The names of the Worker secrets passed to the container’s process at start (#3477 J).
- CONTAINER_
INSTANCE_ TYPES - The instance types a
Containercan start with under thedurable_objectscheduling policy. There is nobasicunder it. - CONTAINER_
INSTANCE_ TYPE_ OPTION - The instance type the container starts with, one of
CONTAINER_INSTANCE_TYPES, passed asinstancetostart()(#3477 E). - CONTAINER_
MAX_ FORWARD - The most Worker secrets one container forwards.
- CONTAINER_
MAX_ SLEEP_ AFTER_ SECONDS - The longest inactivity timeout the platform accepts, in seconds (6 hours).
- CONTAINER_
PORT_ OPTION - The one TCP port the container’s HTTP server listens on (#3477 D).
- CONTAINER_
SLEEP_ AFTER_ OPTION - How long an idle container runs before the platform stops it, applied with
setInactivityTimeouton every start (#3477 E). - CRYPTO_
KEY_ TYPES - The opaque key types
bynk.cryptoexports. A value of one holds a non-extractable platform key, so it is never stored, persisted, logged or sent (bynk.types.key_at_boundary), as aStreamis not. The checker finds them by the unit’s reserved span file, so a user type of the same name is not mistaken for one. - CRYPTO_
UNIT - The unit name of the first-party cryptography adapter (standard-library K4,
D5/D6): a flat sibling of
bynk, platform-free, with a binding per platform. - D1_
BINDING_ PREFIX - The Worker binding prefix of a
D1instance (standard-library P4a, #2602):capability Orders = D1binds asD1_ORDERS, a[[d1_databases]]entry whosedatabase_idbynk deploymints. - EDGE_
CACHE_ BINDING_ PREFIX - The prefix an
EdgeCacheinstance’s binding name would carry (first-party registry L7, #2414). Workers Cache is a Worker-wide[cache]setting with noenvbinding, so the name is never emitted: the instance is built from the entry’sctxinstead. - EMAIL_
ALLOWED_ RECIPIENTS_ OPTION - The option of an
Emailinstance that lists the recipients it may send to (allowed_destination_addresses). - EMAIL_
ALLOWED_ SENDERS_ OPTION - The option of an
Emailinstance that lists the senders it may send as (allowed_sender_addresses);bynk deploychecks each address’s domain is verified for sending on the account (#3302 Decision D). - EMAIL_
BINDING_ PREFIX - The Worker binding prefix of an
Emailinstance (#3302):capability Mail = Email @allowedSenders(["[email protected]"])binds asEMAIL_MAIL, a[[send_email]]entry (keyed byname). - EMAIL_
TO_ OPTION - The option of an
Emailinstance that pins every message to one recipient (destination_address). - FIRSTPARTY_
SOURCES - Every first-party
.bynksource, paired with its unit name — the single list every consumer iterates: hover (describe_firstparty_symbol), completion (EMBEDDED_UNITS), and the parse guard (every_first_party_source_parses). Before this list each consumer kept its own hand-maintained copy, andbynk.locale/bynk.locale.typeswere added to none of them — so the whole locale surface hovered as nothing and was absent from completion (#901). - FIRST_
PARTY_ NPM - Every first-party npm dependency. Hyperdrive H1 (#3318) adds
postgreshere.bynk-emit’sfirst_party_pins_match_the_runtimetest holds each pin to the version@bynk/runtime’s ownpackage.jsontests against. - IMAGES_
BINDING_ NAME - The Worker binding of the
Imagescapability (#3515): Cloudflare Images’ binding,[images] binding = "IMAGES", the name Cloudflare’s own documentation uses. - KV_
BINDING_ NAME - The fixed Worker binding name for the Kv namespace (decision C1, v0.19):
one namespace, one
[[kv_namespaces]]stanza, oneenv.KVfield. - LIST_
UNIT - The unit names of the first-party collection commons (v0.20b): the
Bynk-written combinator stdlib over the built-in
List/Mapkernel. Inside the reservedbynk.*prefix; injected whenuses-imported. - LOCALE_
TYPES_ UNIT - Inside the reserved
bynk.*prefix; injected whenuses-imported. Alsouses-imported by thebynkadapter itself, to givecapability Locale’scurrent() -> Effect[LocaleTag]a type to name (an adapter mayusesa commons; a commons cannot in turn reference an adapter). Split out ofbynk.locale(locale-negotiation-slice-2 follow-up, #886) specifically so a context can reachLocaleTagwithout also pulling inbynk.locale’s ownrender— which previously collided with a message-bundle commons’s own synthesisedrender(ADR 0272) the moment a context needed both. - LOCALE_
UNIT - Inside the reserved
bynk.*prefix; injected whenuses-imported by application code (a message-bundle commons, ADR 0272) — never directly by thebynkadapter itself any more (seeLOCALE_TYPES_UNIT). - MAP_
UNIT - MTLS_
BINDING_ PREFIX - The Worker binding prefix of an
MtlsCertificateinstance (#3513 A):capability Backend = MtlsCertificate @certificate("acme-client")binds asMTLS_BACKEND, an[[mtls_certificates]]entry. - MTLS_
CERTIFICATE_ OPTION - The option of an
MtlsCertificateinstance that names the account’s client certificate, by the name it was uploaded under. It is used as written in every environment, andbynk deploylinks to it and never uploads it: a certificate’s private key never passes through Bynk (#3513 A Decisions A1 and A2). - MYSQL_
BINDING_ PREFIX - The Worker binding prefix of a
MySqlinstance (Hyperdrive H5, #3322, ADR 0799 D): the same asPostgres’s, since both are a[[hyperdrive]]entry and the deploy path is one.capability Legacy = MySqlbinds asHYPERDRIVE_LEGACY. - MYSQL_
TLS_ MODES - The TLS modes
@tls("…")takes, each with thesslmodeCloudflare’s Hyperdrive API spells it as.requiredis the default and needs no CA certificate; the twoverifymodes check the server’s certificate against a CA certificate the account holds. - MYSQL_
TLS_ OPTION - The one option of a
MySqlinstance: the TLS mode of the connection from Hyperdrive to the database (#3322, DECISION B). - POSTGRES_
BINDING_ PREFIX - The Worker binding prefix of a
Postgresinstance (Hyperdrive H1, #3318, ADR 0799 D):capability Main = Postgresbinds asHYPERDRIVE_MAIN, a[[hyperdrive]]entry whoseidbynk deploymakes or adopts (#3319). - QUEUE_
BINDING_ PREFIX - The Worker binding prefix of a
Queueinstance (standard-library P2, #2578):capability OrderEvents = Queue @name("order-events")binds asQUEUE_ORDER_EVENTS, a[[queues.producers]]entry. - QUEUE_
NAME_ OPTION - The option of a
Queueinstance that names the queue it sends to.name, not the track’squeue:queueis a keyword, so@queue(…)does not parse (asService’s@worker, ADR 0023). - R2_
BINDING_ PREFIX - The Worker binding prefix of an
R2instance (standard-library P5, #2323):capability Archives = R2binds asR2_ARCHIVES, an[[r2_buckets]]entry. - R2_
JURISDICTIONS - The jurisdictions an
R2bucket may be pinned to, as@jurisdiction(…)takes them andwrangler r2 bucket create --jurisdictionaccepts them. - R2_
JURISDICTION_ OPTION - The one creation option of an
R2instance: the bucket’s jurisdiction. - RATELIMIT_
BINDING_ PREFIX - The Worker binding prefix of a
RateLimitinstance (standard-library P3, #2342):capability LoginLimit = RateLimit @limit(100) @period(60.seconds)binds asRATELIMIT_LOGIN_LIMIT, a[[ratelimits]]entry. - RATELIMIT_
LIMIT_ OPTION - A
RateLimitinstance’s count: the calls per key allowed in one period. - RATELIMIT_
PERIODS - The windows the Workers Rate Limiting binding offers, in seconds.
- RATELIMIT_
PERIOD_ OPTION - A
RateLimitinstance’s window. - SERVICE_
BINDING_ PREFIX - The Worker binding prefix of a
Serviceinstance (interop I5, #1972):capability Billing = Service @worker("legacy-billing")binds asSERVICE_BILLING, a[[services]]entry naminglegacy-billing. - SERVICE_
WORKER_ OPTION - The option of a
Serviceinstance that names the Worker it reaches.worker, not D4’sservice:serviceis a keyword, so@service(…)does not parse, and widening the annotation grammar is language work (ADR 0023). - SET_
UNIT - STORED_
SECRET_ BINDING_ PREFIX - The Worker binding prefix of a
StoredSecretinstance (#3301):capability StripeKey = StoredSecret @store("payments") @secret("stripe-live")binds asSECRET_STRIPE_KEY, a[[secrets_store_secrets]]entry. - STORED_
SECRET_ SECRET_ OPTION - The option of a
StoredSecretinstance that names the secret in its store. - STORED_
SECRET_ STORE_ OPTION - The option of a
StoredSecretinstance that names its Secrets Store, by the name the account gives it;bynk deployresolves the id (#3301 Decision C), so an id never appears in source. - STRING_
UNIT - Inside the reserved
bynk.*prefix; injected whenuses-imported. - TESTING_
BINDING_ FILENAME - The output path of
bynk.testing’s binding, beside its emittedbynk/testing.ts. - TESTING_
UNIT - The unit name of the toolchain’s test-support adapter (#3458): an in-memory store whose reads are typed, which exercises the call-site decode of a first-party capability reply. Experimental and not part of the language.
- UNITS
- The standard library’s first-party units. Dependencies between them are not
listed here: they are the
uses/consumeslines of each unit’s own source, which the checker follows when it injects. The table’s order isFIRSTPARTY_SOURCES’ order; injection followsUnit::id_block. - URL_
UNIT - Inside the reserved
bynk.*prefix; injected whenuses-imported. - VECTORIZE_
BINDING_ PREFIX - The Worker binding prefix of a
Vectorizeinstance (#3479):capability Docs = Vectorize @dimensions(768) @metric("cosine")binds asVECTORIZE_DOCS, a[[vectorize]]entry naming the index. - VECTORIZE_
DIMENSIONS_ OPTION - A
Vectorizeinstance’s vector length. Fixed when the index is created and never changeable after, so the declaration states it (#3479 A). - VECTORIZE_
INDEXED_ OPTION - The metadata properties of a
Vectorizeinstance a query may filter on, each writtenname:type(#3479 C). - VECTORIZE_
INDEXED_ TYPES - The types a metadata index holds.
- VECTORIZE_
MAX_ DIMENSIONS - The most dimensions a Cloudflare Vectorize vector can have (its published
limit);
@dimensionsabove it is refused at compile time. - VECTORIZE_
MAX_ INDEXED - The most metadata indexes one index carries.
- VECTORIZE_
METRICS - The distance metrics an index is created with.
- VECTORIZE_
METRIC_ OPTION - A
Vectorizeinstance’s distance metric, one ofVECTORIZE_METRICS. - VECTORIZE_
MIN_ DIMENSIONS - The fewest dimensions a Cloudflare Vectorize index accepts: creating one with
fewer fails with
Dimensions must be in range: [32, 1536].@dimensionsbelow it is refused at compile time, so the failure is not left for a deploy. - VERSION_
BINDING_ NAME - The Worker binding of the
Versioncapability (#3300): Cloudflare’s Version metadata binding,[version_metadata] binding = "CF_VERSION_METADATA", the name Cloudflare’s own documentation uses.
Functions§
- allow_
entry_ is_ live - Whether
entry, an[unstable] allowentry, reaches anything inexperimental(a list of experimental item paths, such asexperimental_items): it names an experimental item, lies under one, or contains one. An entry that reaches nothing is stale. - allows
- Whether an
[unstable] allowlist coverspath: an entry covers itself and everything under it. - cloudflare_
binding_ source - The toolchain-supplied binding for the Cloudflare platform adapter.
- covers
- Whether
pathisprefixor lies under it, by whole dotted segments. - experimental_
items - Every experimental item, as a full path: each experimental unit, and each listed item of a stable one.
- experimental_
items_ in experimental_itemsover a given table.- exported_
names - The names a first-party unit exports: those on its
exports … { … }lines (an adapter) and its ownfns andtypes (a commons). Read from the source, so the list cannot fall behind it. - first_
party_ npm_ for - The first-party npm dependencies a set of emitted runtime modules brings.
- instantiable
- The instance kind
capabilityofunitis, if a context may declare named instances of it (S4a, #1966). - is_
exact_ version - Whether
versionis an exactMAJOR.MINOR.PATCH(with an optional pre-release or build suffix), which is all a first-party pin may be. - is_
extensible - Whether
name, an enum exported byunit, is extensible. - is_
extensible_ in is_extensibleover a given table.- names_
first_ party_ item - Whether
pathnames a first-party unit or an item it exports. Operation paths (bynk.cloudflare.Kv.list) are accepted when their item exists. - names_
first_ party_ item_ in names_first_party_itemover a given table.- platform_
of - v0.19 decision 0024: which first-party units are platform-native —
consuming one locks its deployment unit to the returned platform. This is
the metadata that drives effective-platform computation,
envresource typing, andwrangler.tomlstanza derivation; no user-facing marker syntax exists (additive later, when third-party platform adapters become a goal). - provider_
takes_ env - v0.18 decision 0021 / v0.19 decision 0025: which first-party provider
classes take the Worker
envas a constructor argument, keyed by (unit, provider class).SecretsProvideraccepts an optional env with aglobalThisprobe fallback;WorkersKvrequires env on use — KV namespaces exist only on the Workerenv, never onglobalThis. - singleton
- The one-per-Worker capability
capabilityof first-party unitunit(#3300), if it is one. - split_
item_ path - The unit a dotted item path lies in, and the rest of the path relative to it
(empty for the unit itself). Unit names contain dots, so the longest unit
name that is a whole-segment prefix wins:
bynk.cloudflare.Kvis inbynk.cloudflare, not inbynk. - split_
item_ path_ in split_item_pathover a given table (tests pass a synthetic one).- stability_
of - The stability of a first-party item: a unit (
bynk.cloudflare), an exported item (bynk.cloudflare.Kv) or a capability operation (bynk.cloudflare.Kv.list). An item in an experimental unit, or under an experimental item, is experimental.Nonewhen no first-party unit holds the path. - stability_
of_ in stability_ofover a given table.- unit
- The registry entry for
name, if it is a first-party unit.