bookshelf._produce.helpers#
bookshelf._produce.helpers #
Shared helpers for synchronous and asynchronous production.
VisibilityInput = str | models.Visibility | _Inherit module-attribute #
A visibility argument: an explicit tier, or :data:INHERIT for the caller's default.
Under a recording the default is the book's tier as declared in the recipe, so a public book records public resources and narrowing one is a deliberate act. Everywhere else the default is hidden.
activity_envelope(*, activity_id, kind, code_ref, config, runner, used, config_hash=None) #
Build the activity envelope shared by all registrations in a block.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
external_item(*, type, uri, hash, name, visibility, tags, metadata, tracking_id, dedupe) #
Build the single-item registration an external pointer becomes.
visibility is already resolved, because each surface carries its own default.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
paired_successes(successful, items) #
Pair every committed outcome with the request item it registered.
The server reports the index of each result, so a reordered response still resolves to the right item.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
raise_partial_registration(successful, failures) #
Raise the aggregate error only after retaining every response item.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
registered_name(item) #
Return the bundle-local name an item registers under, unwrapped from its model.
registered_resource_type(outcome, requested) #
Return a trusted local type, or defer canonical alias metadata loading.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
registration_results(response, *, index_offset=0) #
Split a server batch response without discarding committed outcomes.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
resource_discovery(tags) #
Wrap a resource's tags in its discovery object, the only place they now travel.
An empty sequence still gets an object rather than a null, because the field is not nullable on the wire. A profile that states nothing and an absent profile mean the same thing to the platform.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
resource_type(value) #
Normalise a public resource-type input.
runner() #
Describe the current execution environment without background work.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
single_success(successful) #
Return the only committed outcome, refusing a response that registered nothing.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
used_ref(value) #
Convert a public lineage input into its wire representation.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
uuid7() #
Mint RFC 9562 UUIDv7 bits from milliseconds and random values.
Values minted within one millisecond have no additional ordering guarantee.
Source code in packages/bookshelf/src/bookshelf/_produce/helpers.py
visibility(value, default=models.Visibility.hidden) #
Normalise a public visibility input, resolving :data:INHERIT to default.