Skip to main content

Crate bynk_std

Crate bynk_std 

Source
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§

FirstPartyNpm
A first-party npm dependency (ADR 0799 C, #3328): an npm package the toolchain itself emits into out/package.json for 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 UNITS plus 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.
OptionKind
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 which bynk-<platform>.ts binding is linked for the bynk surface. v0.17 shipped cloudflare; v0.18 adds node, 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).
UnitKind
What a first-party unit is, and so how a project brings it in: an adapter is injected when a unit consumes it, a commons when a unit uses it. Local to this crate, which has no dependencies; bynk-check maps it onto its own unit kind.

Constants§

AI_BINDING_NAME
The Worker binding of the Ai capability (#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 AiSearch instance (#3480): capability Kb = AiSearch @instance("support-docs") binds as AI_SEARCH_KB, an [[ai_search]] entry.
AI_SEARCH_INSTANCE_OPTION
The option of an AiSearch instance that names the instance, by the name the account gives it. It is used as written in every environment, and bynk deploy links to it and never creates it (#3480 Decisions A and B).
ANALYTICS_BINDING_PREFIX
The Worker binding prefix of an Analytics instance (standard-library P3b, #2582): capability Signups = Analytics binds as ANALYTICS_SIGNUPS, an [[analytics_engine_datasets]] entry. It takes no options: bynk deploy derives the dataset’s name (track A12).
ANALYTICS_SQL_BINDING_NAME
The Worker binding of the AnalyticsSql capability (#3513 B): Cloudflare’s Analytics SQL binding, [analytics] binding = "CF_ANALYTICS_SQL". Cloudflare’s own documentation names it ANALYTICS_SQL; the CF_ prefix keeps it clear of an Analytics instance’s binding (capability Sql = Analytics would bind as ANALYTICS_SQL).
BYNK_ADAPTER_SRC
The reserved bynk conformance-surface adapter (env-free core). It has no binding clause — the toolchain supplies one per platform (see Platform::bynk_binding_source).
BYNK_CRYPTO_SRC
bynk.crypto — digests, HMAC, constant-time comparison, and signing and verification with imported keys, as Effects over Web Crypto.
BYNK_LIST_SRC
bynk.list — combinators over the List kernel (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 with fold + prepend and a final reverse — O(n) builds, never append (which would be O(n²) over the array lowering).
BYNK_LOCALE_SRC
bynk.locale — the bundle-free render/renderArg helpers and the message/withText/withWhole/withNum/withMoment builder API (slice 1: render formats code plus a deterministic sorted-by-key rendering of params; no lookup, no locale-dependent behaviour). uses bynk.locale.types for the types its own signatures name.
BYNK_LOCALE_TYPES_SRC
bynk.locale.types — LocaleTag, MessageArg, Message: a dependency-free leaf (no uses of its own) so any consumer, including the bynk adapter itself, can reach these types without also reaching bynk.locale’s value-level API.
BYNK_MAP_SRC
bynk.map — combinators over the Map kernel (empty, insert, get, keys, length). fromList is deliberately absent: Bynk has no pair type to spell a List[(K, V)] with, so map construction is Map.empty()
BYNK_SET_SRC
bynk.set (standard-library K6a, #2596) — Bynk-written combinators over the built-in Set kernel (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, the List fold, and the Option kernel methods). The kernel itself is compiler built-in (ADR 0046); only derived helpers live here. join folds to Option[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 bynk surface exports (its exports capability { … } line in bynk.bynk). First-party symbols live on synthetic files and are excluded from the binding index, so the unknown-name quick-fix (#852) offering consumes bynk { … } needs this explicit list. Kept in sync with the adapter source by bynk_surface_capabilities_match_the_adapter.
BYNK_TESTING_SRC
bynk.testing, the typed-read test support. Compiled in only with the test-support feature, 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) — a Url record with RFC 3986 parse/format and query-string helpers, written in Bynk over the String kernel. Only percent-encoding is kernel (percentEncode, percentDecode): it needs a string’s UTF-8 bytes. Url is a record here, not a base type, because a base type’s name is a lexer token, and Url as a keyword would break every user type 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 the list drain and putTtl (0050/0051); structured values are v0.22-codec composition, and Queue remains its own future increment. Like the bynk surface it has no binding clause — 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 the bynk surface’s per-platform bynk-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 unit bynk stays the portability marker; bynk.<platform> units are the platform-locked ones.
CONTAINER_BINDING_PREFIX
The Worker binding prefix of a Container instance (#3477): capability Renderer = Container @build("containers/renderer") @port(8080) binds as CONTAINER_RENDERER, a Durable Object namespace whose class (derived from the capability’s name) runs the container.
CONTAINER_BUILD_OPTION
A Container instance’s build context: a project-relative directory that holds a Dockerfile (#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 Container can start with under the durable_object scheduling policy. There is no basic under it.
CONTAINER_INSTANCE_TYPE_OPTION
The instance type the container starts with, one of CONTAINER_INSTANCE_TYPES, passed as instance to start() (#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 setInactivityTimeout on every start (#3477 E).
CRYPTO_KEY_TYPES
The opaque key types bynk.crypto exports. 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 a Stream is 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 D1 instance (standard-library P4a, #2602): capability Orders = D1 binds as D1_ORDERS, a [[d1_databases]] entry whose database_id bynk deploy mints.
EDGE_CACHE_BINDING_PREFIX
The prefix an EdgeCache instance’s binding name would carry (first-party registry L7, #2414). Workers Cache is a Worker-wide [cache] setting with no env binding, so the name is never emitted: the instance is built from the entry’s ctx instead.
EMAIL_ALLOWED_RECIPIENTS_OPTION
The option of an Email instance that lists the recipients it may send to (allowed_destination_addresses).
EMAIL_ALLOWED_SENDERS_OPTION
The option of an Email instance that lists the senders it may send as (allowed_sender_addresses); bynk deploy checks each address’s domain is verified for sending on the account (#3302 Decision D).
EMAIL_BINDING_PREFIX
The Worker binding prefix of an Email instance (#3302): capability Mail = Email @allowedSenders(["[email protected]"]) binds as EMAIL_MAIL, a [[send_email]] entry (keyed by name).
EMAIL_TO_OPTION
The option of an Email instance that pins every message to one recipient (destination_address).
FIRSTPARTY_SOURCES
Every first-party .bynk source, 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, and bynk.locale/bynk.locale.types were 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 postgres here. bynk-emit’s first_party_pins_match_the_runtime test holds each pin to the version @bynk/runtime’s own package.json tests against.
IMAGES_BINDING_NAME
The Worker binding of the Images capability (#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, one env.KV field.
LIST_UNIT
The unit names of the first-party collection commons (v0.20b): the Bynk-written combinator stdlib over the built-in List/Map kernel. Inside the reserved bynk.* prefix; injected when uses-imported.
LOCALE_TYPES_UNIT
Inside the reserved bynk.* prefix; injected when uses-imported. Also uses-imported by the bynk adapter itself, to give capability Locale’s current() -> Effect[LocaleTag] a type to name (an adapter may uses a commons; a commons cannot in turn reference an adapter). Split out of bynk.locale (locale-negotiation-slice-2 follow-up, #886) specifically so a context can reach LocaleTag without also pulling in bynk.locale’s own render — which previously collided with a message-bundle commons’s own synthesised render (ADR 0272) the moment a context needed both.
LOCALE_UNIT
Inside the reserved bynk.* prefix; injected when uses-imported by application code (a message-bundle commons, ADR 0272) — never directly by the bynk adapter itself any more (see LOCALE_TYPES_UNIT).
MAP_UNIT
MTLS_BINDING_PREFIX
The Worker binding prefix of an MtlsCertificate instance (#3513 A): capability Backend = MtlsCertificate @certificate("acme-client") binds as MTLS_BACKEND, an [[mtls_certificates]] entry.
MTLS_CERTIFICATE_OPTION
The option of an MtlsCertificate instance that names the account’s client certificate, by the name it was uploaded under. It is used as written in every environment, and bynk deploy links 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 MySql instance (Hyperdrive H5, #3322, ADR 0799 D): the same as Postgres’s, since both are a [[hyperdrive]] entry and the deploy path is one. capability Legacy = MySql binds as HYPERDRIVE_LEGACY.
MYSQL_TLS_MODES
The TLS modes @tls("…") takes, each with the sslmode Cloudflare’s Hyperdrive API spells it as. required is the default and needs no CA certificate; the two verify modes check the server’s certificate against a CA certificate the account holds.
MYSQL_TLS_OPTION
The one option of a MySql instance: the TLS mode of the connection from Hyperdrive to the database (#3322, DECISION B).
POSTGRES_BINDING_PREFIX
The Worker binding prefix of a Postgres instance (Hyperdrive H1, #3318, ADR 0799 D): capability Main = Postgres binds as HYPERDRIVE_MAIN, a [[hyperdrive]] entry whose id bynk deploy makes or adopts (#3319).
QUEUE_BINDING_PREFIX
The Worker binding prefix of a Queue instance (standard-library P2, #2578): capability OrderEvents = Queue @name("order-events") binds as QUEUE_ORDER_EVENTS, a [[queues.producers]] entry.
QUEUE_NAME_OPTION
The option of a Queue instance that names the queue it sends to. name, not the track’s queue: queue is a keyword, so @queue(…) does not parse (as Service’s @worker, ADR 0023).
R2_BINDING_PREFIX
The Worker binding prefix of an R2 instance (standard-library P5, #2323): capability Archives = R2 binds as R2_ARCHIVES, an [[r2_buckets]] entry.
R2_JURISDICTIONS
The jurisdictions an R2 bucket may be pinned to, as @jurisdiction(…) takes them and wrangler r2 bucket create --jurisdiction accepts them.
R2_JURISDICTION_OPTION
The one creation option of an R2 instance: the bucket’s jurisdiction.
RATELIMIT_BINDING_PREFIX
The Worker binding prefix of a RateLimit instance (standard-library P3, #2342): capability LoginLimit = RateLimit @limit(100) @period(60.seconds) binds as RATELIMIT_LOGIN_LIMIT, a [[ratelimits]] entry.
RATELIMIT_LIMIT_OPTION
A RateLimit instance’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 RateLimit instance’s window.
SERVICE_BINDING_PREFIX
The Worker binding prefix of a Service instance (interop I5, #1972): capability Billing = Service @worker("legacy-billing") binds as SERVICE_BILLING, a [[services]] entry naming legacy-billing.
SERVICE_WORKER_OPTION
The option of a Service instance that names the Worker it reaches. worker, not D4’s service: service is 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 StoredSecret instance (#3301): capability StripeKey = StoredSecret @store("payments") @secret("stripe-live") binds as SECRET_STRIPE_KEY, a [[secrets_store_secrets]] entry.
STORED_SECRET_SECRET_OPTION
The option of a StoredSecret instance that names the secret in its store.
STORED_SECRET_STORE_OPTION
The option of a StoredSecret instance that names its Secrets Store, by the name the account gives it; bynk deploy resolves the id (#3301 Decision C), so an id never appears in source.
STRING_UNIT
Inside the reserved bynk.* prefix; injected when uses-imported.
TESTING_BINDING_FILENAME
The output path of bynk.testing’s binding, beside its emitted bynk/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/consumes lines of each unit’s own source, which the checker follows when it injects. The table’s order is FIRSTPARTY_SOURCES’ order; injection follows Unit::id_block.
URL_UNIT
Inside the reserved bynk.* prefix; injected when uses-imported.
VECTORIZE_BINDING_PREFIX
The Worker binding prefix of a Vectorize instance (#3479): capability Docs = Vectorize @dimensions(768) @metric("cosine") binds as VECTORIZE_DOCS, a [[vectorize]] entry naming the index.
VECTORIZE_DIMENSIONS_OPTION
A Vectorize instance’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 Vectorize instance a query may filter on, each written name: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); @dimensions above 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 Vectorize instance’s distance metric, one of VECTORIZE_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]. @dimensions below it is refused at compile time, so the failure is not left for a deploy.
VERSION_BINDING_NAME
The Worker binding of the Version capability (#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] allow entry, reaches anything in experimental (a list of experimental item paths, such as experimental_items): it names an experimental item, lies under one, or contains one. An entry that reaches nothing is stale.
allows
Whether an [unstable] allow list covers path: an entry covers itself and everything under it.
cloudflare_binding_source
The toolchain-supplied binding for the Cloudflare platform adapter.
covers
Whether path is prefix or 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_items over a given table.
exported_names
The names a first-party unit exports: those on its exports … { … } lines (an adapter) and its own fns and types (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 capability of unit is, if a context may declare named instances of it (S4a, #1966).
is_exact_version
Whether version is an exact MAJOR.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 by unit, is extensible.
is_extensible_in
is_extensible over a given table.
names_first_party_item
Whether path names 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_item over 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, env resource typing, and wrangler.toml stanza 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 env as a constructor argument, keyed by (unit, provider class). SecretsProvider accepts an optional env with a globalThis probe fallback; WorkersKv requires env on use — KV namespaces exist only on the Worker env, never on globalThis.
singleton
The one-per-Worker capability capability of first-party unit unit (#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.Kv is in bynk.cloudflare, not in bynk.
split_item_path_in
split_item_path over 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. None when no first-party unit holds the path.
stability_of_in
stability_of over a given table.
unit
The registry entry for name, if it is a first-party unit.