render

package
v0.0.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

License, machine, license-user/license-entitlement and license-file documents (the reference's LicenseSerializer, MachineSerializer, LicenseUserSerializer, LicenseEntitlementSerializer and LicenseFileSerializer).

The checkout payload: the JSON:API dataset embedded in a license or machine file certificate ({data, included, meta}).

Package render projects domain values onto the generated oas wire types. It is shared by the HTTP handlers and the future webhook publisher: one renderer, one wire truth.

Package render holds the domain→ogen conversions: every resource document the API (and later the webhook publisher) writes on the wire, in exactly the reference's serializer shape.

Webhook rendering: the endpoint and event resources, and the webhook payload documents the publisher embeds in the outbox rows.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedPayload = errors.New("render: webhook payload: unsupported resource")

ErrUnsupportedPayload marks a resource the renderer cannot turn into a webhook payload.

Functions

func Base64Std

func Base64Std(s string) string

Base64Std answers the strict standard base64 of s.

func CheckoutPayload

func CheckoutPayload(
	accountID uuid.UUID, checkout licenses.Checkout, now time.Time,
) ([]byte, error)

CheckoutPayload renders the license-file dataset of a checkout. It encodes through the generated jx encoders (encoding/json would marshal the optional relationship wrappers' zero values).

func Component added in v0.0.5

func Component(accountID uuid.UUID, c domain.MachineComponent) oas.ComponentResource

Component renders a machine component document.

func EntitlementResource

func EntitlementResource(accountID uuid.UUID, e domain.Entitlement) oas.EntitlementResource

EntitlementResource renders an entitlement exactly as the reference's EntitlementSerializer does.

func Group

func Group(group domain.Group) oas.GroupResource

Group renders a group exactly as the reference's GroupSerializer does.

func GroupIdentifier

func GroupIdentifier(group uuid.NullUUID) oas.NilResourceIdentifier

GroupIdentifier renders a group linkage (null when none).

func GroupOwner

func GroupOwner(owner domain.GroupOwner) oas.GroupOwnerResource

GroupOwner renders the group-owners join resource.

func KeyResource

func KeyResource(accountID uuid.UUID, k domain.Key) oas.KeyResource

KeyResource renders a key exactly as the reference's KeySerializer does: the product linkage rides through the key's policy.

func License

func License(accountID uuid.UUID, l domain.License, now time.Time, rawKey *string) oas.LicenseResource

License renders a license exactly as the reference's LicenseSerializer does. RawKey carries the one-time plaintext of a legacy-encrypted key (the create response); later reads omit key.

func LicenseEntitlement

func LicenseEntitlement(accountID uuid.UUID, join domain.LicenseEntitlement) oas.LicenseEntitlementResource

LicenseEntitlement renders a license-entitlement join document.

func LicenseFile

func LicenseFile(accountID uuid.UUID, fileID uuid.UUID, certificate, algorithm string,
	includes []string, ttl *int32, issued time.Time, expiry *time.Time, licenseID uuid.UUID,
) oas.LicenseFileResource

LicenseFile renders the license-file document of a checkout.

func LicenseUser

func LicenseUser(accountID uuid.UUID, join domain.LicenseUser) oas.LicenseUserResource

LicenseUser renders a license-user join document.

func LicenseValidation

func LicenseValidation(accountID uuid.UUID, event domain.LicenseValidationEvent) oas.LicenseValidateDocument

LicenseValidation renders the event's complete JSON:API document.

func LicenseValidationMeta

func LicenseValidationMeta(event domain.LicenseValidationEvent) oas.LicenseValidateMeta

LicenseValidationMeta is shared by API responses and validation webhooks.

func Links(doc *paging.Doc) oas.OptListLinks

Links builds the collection links document (nil Doc answers no links at all).

func Machine

func Machine(accountID uuid.UUID, m domain.Machine) oas.MachineResource

Machine renders a machine document (the machines reached through a license's relationship).

func MachineCheckoutPayload added in v0.0.5

func MachineCheckoutPayload(accountID uuid.UUID, checkout machines.Checkout, now time.Time) ([]byte, error)

MachineCheckoutPayload renders the machine-file dataset: the machine, its requested includes (the license's own included as license.*).

func MachineFile added in v0.0.5

func MachineFile(accountID, fileID uuid.UUID, certificate, algorithm string,
	includes []string, ttl *int32, issued time.Time, expiry *time.Time, licenseID, machineID uuid.UUID,
) oas.MachineFileResource

MachineFile renders a machine-file document (the license file's attributes, plus the machine relationship).

func Metadata

func Metadata(stored map[string]any) oas.Metadata

Metadata renders stored metadata camelCased on the wire ({} when empty).

func NilInt

func NilInt(v *int) oas.NilInt

NilInt renders an optional limit column.

func NilPtrString

func NilPtrString(s *string) oas.NilString

NilPtrString renders an optional string.

func NilString

func NilString(s string) oas.NilString

NilString renders "" as null, like the reference's serializers.

func OptNilString

func OptNilString(s string) oas.OptNilString

OptNilString renders the raw token secret: present on creation, explicitly null otherwise.

func PayloadDocument

func PayloadDocument(accountID uuid.UUID, resource any) (any, error)

PayloadDocument renders the resource document a webhook payload carries: the same JSON:API renderer the API responses use. The types that need extra inputs (the user's status, the second factor's email) are resolved by the caller before this; an unknown type is an error, never a wrong payload.

func PolicyEntitlementResource

func PolicyEntitlementResource(accountID uuid.UUID, join domain.PolicyEntitlement) oas.PolicyEntitlementResource

PolicyEntitlementResource renders one policy_entitlements join row exactly as the attach route's PolicyEntitlementSerializer does: the links object carries related (the policy-side relationship URL), not self.

func PolicyResource

func PolicyResource(accountID uuid.UUID, p domain.Policy) oas.PolicyResource

PolicyResource renders a policy exactly as the reference's PolicySerializer does.

func Process added in v0.0.5

func Process(accountID uuid.UUID, p domain.MachineProcess) oas.ProcessResource

Process renders a machine process document.

func ProductResource

func ProductResource(accountID uuid.UUID, p domain.Product) oas.ProductResource

ProductResource renders a product exactly as the reference's ProductSerializer does.

func ProductStub

func ProductStub(accountID, id uuid.UUID) oas.UserProductResource

ProductStub renders the minimal product document of the user/group relationship indexes (the full serializer belongs to the products group).

func SecondFactor

func SecondFactor(accountID uuid.UUID, factor domain.SecondFactor, email string) oas.SecondFactorResource

SecondFactor renders a second factor; the secret and provisioning uri only while the factor is disabled.

func Timestamp

func Timestamp(t time.Time) oas.Timestamp

Timestamp renders the wire timestamp (RFC3339, millisecond precision, Z).

func Token

func Token(accountID uuid.UUID, token domain.Token, role domain.Role, raw string) oas.TokenResource

Token renders a token as the reference's TokenSerializer does: raw (the secret) only on creation/regeneration, the activation counters only on activation tokens. role is the bearer's live role.

func User

func User(accountID uuid.UUID, user domain.User, status string) oas.UserResource

User renders a user as the reference's UserSerializer does (status precomputed by the scenario).

func WebhookEndpoint

func WebhookEndpoint(accountID uuid.UUID, e domain.WebhookEndpoint) oas.WebhookEndpointResource

WebhookEndpoint renders an endpoint exactly as the reference's WebhookEndpointSerializer does (the product relationship's linkage always present, null when account-scoped).

func WebhookEvent

func WebhookEvent(accountID uuid.UUID, e domain.WebhookEvent) oas.WebhookEventResource

WebhookEvent renders an event exactly as the reference's WebhookEventSerializer does (the payload as the JSON string of the resource document; the idempotency token in resource-level meta).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL