Skip to content
SegmentStream/ Docs

Loading documentation…

↑ ↓ to navigate  ↵ to open  Esc to close
Website Console
Section menu

@segmentstream/ontology · U–Z

101 public exports from @segmentstream/ontology.

Public exports

USER_IDENTITY_ORIGINS

How a sign-in identity came to be, as the `origin` property stores it.

const USER_IDENTITY_ORIGINS: readonly [
    "invite",
    "sign_in",
    "link",
    "pairing",
    "channel",
    "attach",
    "verification"
]
USER_IDENTITY_VERBS

The verbs of the built-in sign-in identities' platform actions: an administrator attaching a member's chat account and revoking one. `user_identity` is in {@link EXPLICIT_GRANT_ENTITIES}, so only `user_identity:<verb>` or `user_identity:*` grants them.

const USER_IDENTITY_VERBS: readonly [
    "attach",
    "attest",
    "revoke"
]
USER_MEMBER_VERBS

The verbs of the built-in user's member management: inviting a member, granting and revoking roles, and deactivating and reactivating a member. Like every other verb on `user` but `read` and `update`, only `user:<verb>` or `user:*` grants them.

const USER_MEMBER_VERBS: readonly [
    "invite",
    "grant_roles",
    "revoke_roles",
    "deactivate",
    "reactivate"
]
UndeclaredWrite

A handler wrote an entity its action's `writes` does not list: a defect in the workspace's code, found by its tests or its first run, never a caller's mistake.

class UndeclaredWrite extends UndeclaredWrite_base {
}
UnknownAction

The entity has no action with this name, authored or generated.

class UnknownAction extends UnknownAction_base {
}
UnknownRole

Roles given to users are roles of the ontology, `member` included.

class UnknownRole extends UnknownRole_base {
}
UpdateManyInput
interface UpdateManyInput extends BatchOptions {
    readonly entity: string;
    readonly records: ReadonlyArray<{
        readonly id: string;
        readonly values: StoredValues;
    }>;
}
UpdateValues

Values for `update`. Handlers may write `managed` properties; the generated `update` may not.

type UpdateValues<P, R> = Simplify<{
    readonly [K in keyof P]?: WriteValueOf<P[K]>;
} & {
    readonly [K in OneKeys<R>]?: R[K] extends OneRelationship<true> ? string | null : string;
} & {
    readonly [K in ManyKeys<R>]?: ReadonlyArray<string>;
}>;
UploadedFile

A completed upload, ready for the action it was made for.

interface UploadedFile {
    readonly ticket: BlobUpload;
    readonly options: {
        readonly idempotencyKey: string;
        readonly createIntent?: string;
    };
}
UpsertManyInput
interface UpsertManyInput extends CreateManyInput {
    readonly on: readonly [
        string,
        ...string[]
    ];
}
UpsertResult
interface UpsertResult<R = StoredRecord> {
    readonly record: R;
    readonly created: boolean;
}
UsedOAuthToken

A consumed code or refresh token. An unused immediate successor can be recovered; consumption of that successor proves reuse of an older generation.

type UsedOAuthToken = {
    readonly status: "valid";
    readonly token: OAuthToken;
    readonly grant: OAuthGrant;
} | {
    readonly status: "reused";
    readonly grant: OAuthGrant;
    readonly successorUsed?: boolean;
} | {
    readonly status: "invalid";
};
User
const User: UserHandle<UserActionsBuilder>
type User = UserRecord;
UserHandle

The built-in user's handle with actions `A`: its entity, and the member writes.

type UserHandle<A extends object> = Entity<"user", typeof UserEntity.properties, NoRelationships, A> & UserMemberWrites;
UserIdentity

The built-in account and verified-contact identities of people and services. Only platform actions write them, with history and explicit user_identity permissions. Account identities authenticate; contact identities record an authority's proof and grant no access. Each live account or contact has one owner. Contacts may have several values per provider; channel accounts retain the one-account-per-user/provider rule.

const UserIdentity: import("./entity.js").DraftEntity<"user_identity", {
    readonly purpose: import("./property.js").Property<"account" | "contact", true, false>;
    readonly provider: import("./property.js").Property<string, false, false>;
    readonly issuer: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
    readonly subject: import("./property.js").Property<string, false, false>;
    readonly username: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
    readonly display: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
    readonly origin: import("./property.js").Property<"link" | "invite" | "attach" | "verification" | "sign_in" | "channel" | "pairing", false, false>;
    readonly revokedAt: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
    readonly verifiedAt: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
    readonly verificationMethod: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
    readonly verificationSource: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
    readonly verificationReference: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
    readonly accountKey: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, true>>;
    readonly memberKey: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, true>>;
}, {
    readonly user: import("./relationship.js").OneRelationship<false, false, "user">;
}, Readonly<Record<never, never>>, "actions">
type UserIdentity = typeof UserIdentity.Type;
UserIdentityOrigin
type UserIdentityOrigin = (typeof USER_IDENTITY_ORIGINS)[number];
UserMemberVerb
type UserMemberVerb = (typeof USER_MEMBER_VERBS)[number];
UserMemberWrites

The member writes of the `User` handle, for action handlers: they require {@link OntologyWrites}, which `prepare` never has. They are the generated `user` actions' own writes, in the action's transaction, with history under the action's name and principal; only members are managed, so a service or an unknown id fails with NotFound. Roles are the ontology's declared roles; one it does not declare, or `member`, is ActionRejected. Each returns the user with its new `roles`.

interface UserMemberWrites {
    grantRoles(record: RecordRef, roles: ReadonlyArray<string>): Effect.Effect<UserRecord, ActionRejected | NotFound, OntologyWrites>;
    revokeRoles(record: RecordRef, roles: ReadonlyArray<string> | "all"): Effect.Effect<UserRecord, ActionRejected | NotFound, OntologyWrites>;
    invite(input: {
        readonly email: string;
        readonly name?: string;
        readonly roles?: ReadonlyArray<string>;
    }): Effect.Effect<UserRecord, ActionRejected | Conflict, OntologyWrites>;
    setActive(record: RecordRef, active: boolean): Effect.Effect<UserRecord, NotFound, OntologyWrites>;
    sendSignInLink(record: RecordRef, options?: {
        readonly template?: string;
        readonly returnTo?: string;
        readonly values?: Readonly<Record<string, string>>;
    }): Effect.Effect<void, ActionRejected | NotFound, OntologyWrites>;
}
VERIFIED_CONTACT_PROVIDERS

Contacts whose possession a trusted verification authority has already established.

const VERIFIED_CONTACT_PROVIDERS: readonly [
    "email",
    "phone"
]
ValidationIssue

Where a value failed validation, and why. Paths are keys and indexes from the input's root.

const ValidationIssue: Schema.Struct<{
    readonly path: Schema.$Array<Schema.Union<readonly [
        Schema.String,
        Schema.Number
    ]>>;
    readonly message: Schema.String;
}>
type ValidationIssue = typeof ValidationIssue.Type;
VerifiedContactProvider
type VerifiedContactProvider = (typeof VERIFIED_CONTACT_PROVIDERS)[number];
VisitorSignUp

A website visitor's sign-up on `web`, as {@link AgentWebStore.visitor} answers it.

type VisitorSignUp = {
    readonly status: "signed_up";
    readonly userId: string;
    readonly token: string;
    readonly refreshToken: string;
    readonly expiresAt: Date;
} | {
    readonly status: "limited";
    readonly retryAfterSeconds: number;
} | {
    readonly status: "refused";
};
WEBHOOK_BASE_PATH

Where deliveries arrive: `/api/webhooks/<wire name>`, followed by the token when unsigned.

const WEBHOOK_BASE_PATH = "/api/webhooks"
WEBHOOK_ORIGIN_VARIABLE

The origin providers reach the workspace's webhooks at, the workspace's assigned domain. The platform sets it on production deployments that declare webhook triggers, beside `SEGMENTSTREAM_WEBHOOK_SECRET`; previews and local runs have neither.

const WEBHOOK_ORIGIN_VARIABLE = "SEGMENTSTREAM_WEBHOOK_ORIGIN"
WEBHOOK_SIGNATURE_SCHEMES

The signature schemes a webhook trigger can check: `hmac` declares a provider's HMAC format with the trigger; `stripe` and `meta` name two published formats.

const WEBHOOK_SIGNATURE_SCHEMES: readonly [
    "stripe",
    "meta",
    "hmac"
]
WEBHOOK_SIGNING_CONTEXT

What a generated signing secret signs before the webhook's name, apart from its token.

const WEBHOOK_SIGNING_CONTEXT = "segmentstream.webhook-signature.v1:"
WEBHOOK_TOKEN_CONTEXT

What a token signs before the webhook's name, so the key derives nothing else.

const WEBHOOK_TOKEN_CONTEXT = "segmentstream.webhook.v1:"
WEB_PROVIDER

The identity provider the agent names for a member who reached it with an agent token.

const WEB_PROVIDER = "web"
WHERE_COMBINATORS

Combinators of a `where`. They take the place of field names.

const WHERE_COMBINATORS: readonly [
    "and",
    "or",
    "not"
]
WILDCARD

Any entity or any verb, in a role's permissions.

const WILDCARD = "*"
WILDCARD_ENTITY_VERBS

Entities of which a wildcard entity (`*:*`, `*:<verb>`) covers only the listed verbs; any other verb needs a permission that names the entity. A role written for business data must not administer members by accident, and an API key holding `*:*` must not grant itself roles, so `*:*` reaches `user:read` and `user:update` but none of {@link USER_MEMBER_VERBS} or an authored action on `user`.

const WILDCARD_ENTITY_VERBS: ReadonlyMap<string, ReadonlySet<string>>
WORKFLOW_USER_PROVIDER

Who signs workflow users in: no one. A workflow's runs execute in the ontology service's own process, which binds the runtime to the workflow's user; no token names them.

const WORKFLOW_USER_PROVIDER = "segmentstream-ontology-workflow"
WORKSPACE_CHANNEL_KIND

The kind of a channel the workspace defines in its own code. No channel is named after it: each has a name of its own.

const WORKSPACE_CHANNEL_KIND = "custom"
WORKSPACE_SOURCE_CONNECT

Use source access that this member granted to the receiving workspace.

const WORKSPACE_SOURCE_CONNECT = "workspace_source:connect"
WORKSPACE_SOURCE_PATH

Query the workspace's deployed source as the active member.

const WORKSPACE_SOURCE_PATH = "/api/ontology/agent/source/query"
WORKSPACE_SOURCE_PERMISSION

Reading the workspace's deployed code, through the agent's list, search and read tools, and main's commit history, through `workspaceSourceHistory`. Only a role that names it grants it.

const WORKSPACE_SOURCE_PERMISSION = "workspace_source:read"
WarehouseSource

A warehouse asset supplies a warehouse-backed entity's records. Keys name physical columns.

interface WarehouseSource {
    readonly asset: string;
    readonly key: ReadonlyArray<string>;
    readonly currency?: string;
}
WebTurnLimit

The limit a member's turn on the web exceeds, and when the next one may run.

interface WebTurnLimit {
    readonly scope: AgentLimitScope;
    readonly retryAfterSeconds: number;
}
WebhookDelivery

One webhook delivery, as the workflow's run function receives it.

type WebhookDelivery = typeof webhookDelivery.Type;
WebhookHmacFormat

A provider's HMAC signature format: which bytes it signs, where its signatures travel and how they are written. The ontology service reads them from each delivery; SegmentStream computes the HMAC with the workspace secret, which never leaves it.

interface WebhookHmacFormat {
    readonly algorithm: WebhookHmacAlgorithm;
    readonly encoding: WebhookSignatureEncoding;
    readonly key?: {
        readonly decode: "base64";
        readonly prefix?: string | undefined;
    } | undefined;
    readonly signatures: {
        readonly header: string;
        readonly prefix?: string | undefined;
        readonly entries?: {
            readonly separator: "," | ";" | " ";
            readonly assign: "=" | ",";
            readonly name: string;
        } | undefined;
    };
    readonly timestamp?: {
        readonly header?: string | undefined;
        readonly entry?: string | undefined;
        readonly unit?: "seconds" | "milliseconds" | undefined;
        readonly tolerance?: number | undefined;
    } | undefined;
    readonly message?: ReadonlyArray<WebhookSignedPart> | undefined;
}
WebhookOptions
interface WebhookOptions extends TriggerRuns {
    readonly description: string;
    readonly signature?: WebhookSignature;
    readonly verification?: WebhookVerification;
    readonly headers?: ReadonlyArray<string>;
    readonly connection?: AnyConnectionHandle;
    readonly input?: (delivery: WebhookDelivery) => unknown;
}
WebhookSignature

Where a webhook's deliveries are checked: a provider's signature format and where its signing secret is held. Without one, the webhook's URL ends in a token. `stripe` and `meta` name published formats; `hmac` declares any other HMAC format with the trigger.

type WebhookSignature = ({
    readonly scheme: Exclude<WebhookSignatureScheme, "hmac">;
} & WebhookSignatureSecret) | ({
    readonly scheme: "hmac";
} & WebhookSignatureSecret & WebhookHmacFormat);
WebhookSignatureScheme
type WebhookSignatureScheme = (typeof WEBHOOK_SIGNATURE_SCHEMES)[number];
WebhookSignedPart

One piece of the signed bytes: text, the body, a header's value or the timestamp.

type WebhookSignedPart = string | {
    readonly body: WebhookSignedBody;
} | {
    readonly header: string;
} | {
    readonly timestamp: true;
};
WebhookTrigger

A webhook trigger, `webhook(name, { description, signature, headers })`: the ontology service starts the workflow for each genuine delivery to `/api/webhooks/<name>`, with the delivery as its input. The workflow's `input` is `webhookDelivery`.

interface WebhookTrigger<Name extends string = string> {
    readonly [WorkflowTriggerTypeId]: typeof WorkflowTriggerTypeId;
    readonly kind: "webhook";
    readonly name: Name;
    readonly description: string;
    readonly signature: WebhookSignature | undefined;
    readonly verification?: WebhookVerification | undefined;
    readonly headers: ReadonlyArray<string>;
    readonly connection?: AnyConnectionHandle | undefined;
    readonly runs?: AnyActionHandle | undefined;
    readonly role?: string | undefined;
    readonly input?: ((delivery: WebhookDelivery) => unknown) | undefined;
}
WebhookTriggerManifest

A webhook trigger of a workflow: the ontology service starts the workflow for each genuine delivery to `/api/webhooks/<name>`. With `signature`, deliveries are checked with the provider's scheme against the named workspace secret; without it, the URL ends in a derived token. `verification` opts into a registration handshake; `headers` lists the request headers the delivery carries; `connection` names the connection whose provider sends to it. Optional settings are written only when declared. A signature of scheme `hmac` carries its format: `algorithm`, `encoding`, `key`, `signatures`, `timestamp` and `message`.

const WebhookTriggerManifest: Schema.Struct<{
    readonly kind: Schema.Literal<"webhook">;
    readonly name: Schema.String;
    readonly description: Schema.String;
    readonly signature: Schema.optionalKey<Schema.Struct<{
        readonly scheme: Schema.String;
        readonly secret: Schema.optionalKey<Schema.String>;
        readonly generated: Schema.optionalKey<Schema.Literal<true>>;
        readonly input: Schema.optionalKey<Schema.String>;
        readonly algorithm: Schema.optionalKey<Schema.String>;
        readonly encoding: Schema.optionalKey<Schema.String>;
        readonly key: Schema.optionalKey<Schema.Struct<{
            readonly decode: Schema.String;
            readonly prefix: Schema.optionalKey<Schema.String>;
        }>>;
        readonly signatures: Schema.optionalKey<Schema.Struct<{
            readonly header: Schema.String;
            readonly prefix: Schema.optionalKey<Schema.String>;
            readonly entries: Schema.optionalKey<Schema.Struct<{
                readonly separator: Schema.String;
                readonly assign: Schema.String;
                readonly name: Schema.String;
            }>>;
        }>>;
        readonly timestamp: Schema.optionalKey<Schema.Struct<{
            readonly header: Schema.optionalKey<Schema.String>;
            readonly entry: Schema.optionalKey<Schema.String>;
            readonly unit: Schema.optionalKey<Schema.String>;
            readonly tolerance: Schema.optionalKey<Schema.Number>;
        }>>;
        readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [
            Schema.String,
            Schema.Struct<{
                readonly body: Schema.Literals<readonly [
                    true,
                    "sorted-json"
                ]>;
            }>,
            Schema.Struct<{
                readonly header: Schema.String;
            }>,
            Schema.Struct<{
                readonly timestamp: Schema.Literal<true>;
            }>
        ]>>>;
    }>>;
    readonly verification: Schema.optionalKey<Schema.Struct<{
        readonly scheme: Schema.String;
        readonly verifyToken: Schema.optionalKey<Schema.String>;
        readonly input: Schema.optionalKey<Schema.String>;
    }>>;
    readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
    readonly connection: Schema.optionalKey<Schema.String>;
}>
type WebhookTriggerManifest = typeof WebhookTriggerManifest.Type;
WebhookUrlUnavailable

Why a webhook's URL is not known here: outside a production deployment, which alone receives webhooks, or before the platform set the deployment's webhook variables.

class WebhookUrlUnavailable extends Error {
    readonly code = "webhook_url_unavailable";
    constructor(webhook: string);
}
WebhookVerification

Meta's registration handshake. The verify token is a verification value of the webhook's `connection` (`input`), or a workspace secret (`verifyToken`, the older form), separate from the app secret either way.

type WebhookVerification = {
    readonly scheme: "meta";
    readonly input: string;
    readonly verifyToken?: undefined;
} | {
    readonly scheme: "meta";
    readonly verifyToken: string;
    readonly input?: undefined;
};
Where

Conditions on a record, all of which must hold: field filters by field name, relationship filters by relationship name (a `where` on the target for to-one, a {@link ManyFilter} for to-many), and the `and`, `or` and `not` combinators.

interface Where {
    readonly and?: ReadonlyArray<Where>;
    readonly or?: ReadonlyArray<Where>;
    readonly not?: Where;
    readonly [field: string]: FieldFilter | ManyFilter | Where | ReadonlyArray<Where> | Schema.Json | undefined;
}
Workflow

A workflow: a durable process written with the Vercel Workflow SDK, run by the ontology service as its own keyless service user holding `role`. The declaration only records; `check` and the sandbox evaluation of `index.ts` never call `run`.

interface Workflow<Name extends string = string, Input = unknown> {
    readonly [WorkflowTypeId]: typeof WorkflowTypeId;
    readonly name: Name;
    readonly description: string;
    readonly role: string;
    readonly input: Schema.Top | undefined;
    readonly run: WorkflowFunction<Input>;
    readonly triggers: ReadonlyArray<WorkflowTrigger>;
    readonly connections: ReadonlyArray<AnyConnectionHandle>;
    readonly runs?: AnyActionHandle | undefined;
}
WorkflowEngine

How the service starts runs and reads their records. By default it is the Vercel Workflow SDK: `start` from `workflow/api`, and the world's `runs.list`, `runs.get` and `steps.list`.

interface WorkflowEngine {
    readonly allocateRun?: WorkflowSdk["allocateRun"];
    readonly getHookRunId?: (token: string) => Promise<string | undefined>;
    readonly start: (workflow: WorkflowFunction<unknown>, args: ReadonlyArray<unknown>, options?: {
        readonly attributes?: Readonly<Record<string, string>>;
        readonly reservation?: import("../runtime/workflow-admission.js").WorkflowReservation;
    }) => Promise<{
        readonly runId: string;
    }>;
    readonly listRuns: (input: {
        readonly workflowName: string;
        readonly limit: number;
        readonly cursor?: string | undefined;
    }) => Promise<WorkflowPage<WorkflowRunRecord>>;
    readonly getRun: (runId: string) => Promise<WorkflowRunRecord | undefined>;
    readonly getRunArguments?: (runId: string) => Promise<ReadonlyArray<unknown> | undefined>;
    readonly listSteps: (runId: string, page?: {
        readonly limit?: number;
        readonly cursor?: string;
        readonly outputs?: boolean;
    }) => Promise<WorkflowPage<WorkflowStepRecord>>;
    readonly getRunOutput?: (run: WorkflowRunRecord) => Promise<WorkflowOutputRead | undefined>;
    readonly diagnostics?: (run: WorkflowRunRecord, steps?: ReadonlyArray<WorkflowStepRecord>) => Promise<WorkflowDiagnostics>;
    readonly resumeHook?: (token: string, payload: unknown) => Promise<"resumed" | "not_found">;
}
WorkflowFunction

The function a workflow runs: a `"use workflow"` function of the decoded input.

type WorkflowFunction<Input> = (input: Input, context: WorkflowRunContext) => Promise<unknown>;
WorkflowManifest

A workflow, `defineOntology({ workflows })`: a durable process the ontology service runs as the workflow's own service user holding `role`. Names are wire names; `input` is the JSON Schema of the workflow's input and `connections` the keys of the connections its steps call.

const WorkflowManifest: Schema.Struct<{
    readonly name: Schema.String;
    readonly description: Schema.String;
    readonly role: Schema.String;
    readonly input: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
    readonly connections: Schema.$Array<Schema.String>;
    readonly triggers: Schema.$Array<Schema.Union<readonly [
        Schema.Struct<{
            readonly kind: Schema.Literal<"cron">;
            readonly name: Schema.String;
            readonly description: Schema.String;
            readonly cron: Schema.String;
            readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
        }>,
        Schema.Struct<{
            readonly kind: Schema.Literal<"action">;
            readonly name: Schema.String;
            readonly description: Schema.String;
            readonly entity: Schema.String;
            readonly action: Schema.optionalKey<Schema.String>;
        }>,
        Schema.Struct<{
            readonly kind: Schema.Literal<"webhook">;
            readonly name: Schema.String;
            readonly description: Schema.String;
            readonly signature: Schema.optionalKey<Schema.Struct<{
                readonly scheme: Schema.String;
                readonly secret: Schema.optionalKey<Schema.String>;
                readonly generated: Schema.optionalKey<Schema.Literal<true>>;
                readonly input: Schema.optionalKey<Schema.String>;
                readonly algorithm: Schema.optionalKey<Schema.String>;
                readonly encoding: Schema.optionalKey<Schema.String>;
                readonly key: Schema.optionalKey<Schema.Struct<{
                    readonly decode: Schema.String;
                    readonly prefix: Schema.optionalKey<Schema.String>;
                }>>;
                readonly signatures: Schema.optionalKey<Schema.Struct<{
                    readonly header: Schema.String;
                    readonly prefix: Schema.optionalKey<Schema.String>;
                    readonly entries: Schema.optionalKey<Schema.Struct<{
                        readonly separator: Schema.String;
                        readonly assign: Schema.String;
                        readonly name: Schema.String;
                    }>>;
                }>>;
                readonly timestamp: Schema.optionalKey<Schema.Struct<{
                    readonly header: Schema.optionalKey<Schema.String>;
                    readonly entry: Schema.optionalKey<Schema.String>;
                    readonly unit: Schema.optionalKey<Schema.String>;
                    readonly tolerance: Schema.optionalKey<Schema.Number>;
                }>>;
                readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [
                    Schema.String,
                    Schema.Struct<{
                        readonly body: Schema.Literals<readonly [
                            true,
                            "sorted-json"
                        ]>;
                    }>,
                    Schema.Struct<{
                        readonly header: Schema.String;
                    }>,
                    Schema.Struct<{
                        readonly timestamp: Schema.Literal<true>;
                    }>
                ]>>>;
            }>>;
            readonly verification: Schema.optionalKey<Schema.Struct<{
                readonly scheme: Schema.String;
                readonly verifyToken: Schema.optionalKey<Schema.String>;
                readonly input: Schema.optionalKey<Schema.String>;
            }>>;
            readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
            readonly connection: Schema.optionalKey<Schema.String>;
        }>,
        Schema.Struct<{
            readonly kind: Schema.Literal<"platform">;
            readonly name: Schema.String;
            readonly description: Schema.String;
            readonly events: Schema.$Array<Schema.String>;
        }>,
        Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>
    ]>>;
    readonly action: Schema.optionalKey<Schema.Struct<{
        readonly entity: Schema.String;
        readonly action: Schema.String;
    }>>;
}>
type WorkflowManifest = typeof WorkflowManifest.Type;
WorkflowOptions
interface WorkflowOptions<S extends AnyInputSchema | undefined = undefined> {
    readonly description: string;
    readonly role: string;
    readonly input?: S;
    readonly run: WorkflowFunction<InputOf<S>>;
    readonly triggers?: ReadonlyArray<WorkflowTrigger>;
    readonly connections?: ReadonlyArray<AnyConnectionHandle>;
}
WorkflowPage
interface WorkflowPage<T> {
    readonly data: ReadonlyArray<T>;
    readonly cursor: string | null;
    readonly hasMore: boolean;
}
WorkflowRunContext

Who started a run, as the ontology service passes it to the workflow function as its second argument and records it in plaintext run attributes: a trigger, a member through `POST /api/ontology/workflows/:workflow/start`, or the platform on behalf of a person.

interface WorkflowRunContext {
    readonly startedBy: {
        readonly kind: "trigger";
        readonly triggerKind?: "cron" | "action" | "webhook" | "platform";
        readonly trigger: string;
        readonly actionId?: string;
        readonly recordId?: string;
        readonly event?: string;
    } | {
        readonly kind: "member";
        readonly userId: string;
    } | {
        readonly kind: "platform";
        readonly userId: string | null;
    };
    readonly owner?: {
        readonly entity: "user";
        readonly id: string;
    };
}
WorkflowRunRecord

A run as the workflow routes answer it, from the Workflow SDK's run record.

interface WorkflowRunRecord {
    readonly runId: string;
    readonly workflowName: string;
    readonly status: string;
    readonly createdAt: Date | string;
    readonly startedAt?: Date | string | undefined;
    readonly completedAt?: Date | string | undefined;
    readonly attributes?: Readonly<Record<string, string>> | undefined;
    readonly deploymentId?: string;
    readonly error?: unknown;
    readonly errorCode?: string | undefined;
}
WorkflowStepFailed

The SDK preserves Error.cause; custom Error properties are otherwise discarded.

class WorkflowStepFailed extends Error {
    readonly fatal: boolean;
    readonly retryAfter?: Date;
    constructor(name: string, message: string, fatal?: boolean, cause?: unknown, retryAfter?: Date);
}
WorkflowStepRecord

A step of a run, from the Workflow SDK's step record.

interface WorkflowStepRecord {
    readonly stepId: string;
    readonly stepName: string;
    readonly status: string;
    readonly attempt?: number | undefined;
    readonly startedAt?: Date | string | undefined;
    readonly completedAt?: Date | string | undefined;
    readonly error?: unknown;
    readonly attempts?: ReadonlyArray<WorkflowAttemptRecord>;
    readonly output?: WorkflowOutputRead | undefined;
}
WorkflowTrigger

What starts a workflow on its own. A discriminated union on `kind`: `cron`, `action`, `webhook` and `platform`; other kinds are additions.

type WorkflowTrigger<Input = unknown> = CronTrigger<string, Input> | ActionTrigger<string, Input> | WebhookTrigger | PlatformTrigger<string, Input>;
WorkflowTriggerManifest

A trigger of a workflow, by `kind`: `cron`, `action`, `webhook`, `platform`, or a kind this reader keeps without knowing.

const WorkflowTriggerManifest: Schema.Union<readonly [
    Schema.Struct<{
        readonly kind: Schema.Literal<"cron">;
        readonly name: Schema.String;
        readonly description: Schema.String;
        readonly cron: Schema.String;
        readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
    }>,
    Schema.Struct<{
        readonly kind: Schema.Literal<"action">;
        readonly name: Schema.String;
        readonly description: Schema.String;
        readonly entity: Schema.String;
        readonly action: Schema.optionalKey<Schema.String>;
    }>,
    Schema.Struct<{
        readonly kind: Schema.Literal<"webhook">;
        readonly name: Schema.String;
        readonly description: Schema.String;
        readonly signature: Schema.optionalKey<Schema.Struct<{
            readonly scheme: Schema.String;
            readonly secret: Schema.optionalKey<Schema.String>;
            readonly generated: Schema.optionalKey<Schema.Literal<true>>;
            readonly input: Schema.optionalKey<Schema.String>;
            readonly algorithm: Schema.optionalKey<Schema.String>;
            readonly encoding: Schema.optionalKey<Schema.String>;
            readonly key: Schema.optionalKey<Schema.Struct<{
                readonly decode: Schema.String;
                readonly prefix: Schema.optionalKey<Schema.String>;
            }>>;
            readonly signatures: Schema.optionalKey<Schema.Struct<{
                readonly header: Schema.String;
                readonly prefix: Schema.optionalKey<Schema.String>;
                readonly entries: Schema.optionalKey<Schema.Struct<{
                    readonly separator: Schema.String;
                    readonly assign: Schema.String;
                    readonly name: Schema.String;
                }>>;
            }>>;
            readonly timestamp: Schema.optionalKey<Schema.Struct<{
                readonly header: Schema.optionalKey<Schema.String>;
                readonly entry: Schema.optionalKey<Schema.String>;
                readonly unit: Schema.optionalKey<Schema.String>;
                readonly tolerance: Schema.optionalKey<Schema.Number>;
            }>>;
            readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [
                Schema.String,
                Schema.Struct<{
                    readonly body: Schema.Literals<readonly [
                        true,
                        "sorted-json"
                    ]>;
                }>,
                Schema.Struct<{
                    readonly header: Schema.String;
                }>,
                Schema.Struct<{
                    readonly timestamp: Schema.Literal<true>;
                }>
            ]>>>;
        }>>;
        readonly verification: Schema.optionalKey<Schema.Struct<{
            readonly scheme: Schema.String;
            readonly verifyToken: Schema.optionalKey<Schema.String>;
            readonly input: Schema.optionalKey<Schema.String>;
        }>>;
        readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
        readonly connection: Schema.optionalKey<Schema.String>;
    }>,
    Schema.Struct<{
        readonly kind: Schema.Literal<"platform">;
        readonly name: Schema.String;
        readonly description: Schema.String;
        readonly events: Schema.$Array<Schema.String>;
    }>,
    Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>
]>
type WorkflowTriggerManifest = typeof WorkflowTriggerManifest.Type;
WorkloadExecution

Verified platform claims retained with each write; never supplied by request headers.

const WorkloadExecution: Schema.Struct<{
    readonly issuer: Schema.String;
    readonly audience: Schema.String;
    readonly organizationId: Schema.String;
    readonly workspaceId: Schema.String;
    readonly subject: Schema.String;
    readonly deploymentId: Schema.String;
    readonly ontologyDeploymentId: Schema.String;
    readonly servingOntologyDeploymentId: Schema.String;
    readonly ontologyOrigin: Schema.String;
    readonly environment: Schema.Literals<readonly [
        "production",
        "preview"
    ]>;
    readonly jobName: Schema.NullOr<Schema.String>;
    readonly runId: Schema.String;
    readonly executionId: Schema.NullOr<Schema.String>;
    readonly attemptId: Schema.String;
    readonly generation: Schema.Number;
    readonly tokenId: Schema.String;
    readonly issuedAt: Schema.Number;
    readonly expiresAt: Schema.Number;
}>
type WorkloadExecution = typeof WorkloadExecution.Type;
WorkspaceSourceHistory

A page of main's commits, newest first; `nextOffset` continues the window, or is null.

type WorkspaceSourceHistory = typeof Result.Type;
WorkspaceSourceHistoryQuery
interface WorkspaceSourceHistoryQuery {
    readonly since: Date | string;
    readonly until: Date | string;
    readonly offset?: number;
}
WriteOutsideAction

Writes run inside an action, which names the change for history.

class WriteOutsideAction extends WriteOutsideAction_base {
}
WriteScope

The action a runtime writes for. Every write records history rows naming it, and sets `created_by`/`updated_by` to its principal.

interface WriteScope extends HistoryScope {
    readonly replicationInitialized?: boolean;
    readonly protectPrincipals?: true;
    readonly onEdit?: (edit: Edit) => void;
    readonly onSnapshot?: (snapshot: RecordSnapshot) => void;
    readonly guard?: WriteGuard;
    readonly onSignInEmail?: (email: QueuedSignInEmail) => void;
    readonly declaredWrites?: ReadonlySet<string>;
}
unsafeEmailHtml

Why an email's HTML is unsafe to send, or undefined: an element that runs code, embeds a page or posts a form; `<svg>`, `<math>` or `<plaintext>`; an event handler; a `<meta http-equiv>`; a value other than {@link EMAIL_MARKUP_VALUES} inside a tag, a comment or a `<style>`, or any value outside a quoted attribute value of a tag or right after `<`; a tag the HTML leaves unclosed; or an address that is not `https:`, `mailto:`, `tel:`, an anchor or the app's own `{{link}}`, `{{app.url}}` or `{{app.mcpUrl}}`. The platform applies the same rules to every deployed email before it sends one.

function unsafeEmailHtml(html: string): string | undefined;
updateMemberRoles

Adds and removes a member's roles in one transaction. Creates a member only for an unknown email when `grant` is given. Granting a role the member holds, or revoking one they do not, changes nothing. A member created here is linked to their identity by email on first sign-in. The writes are the `user` actions' own, as platform writes: history names `user.invite`, `user.revoke_roles` and `user.grant_roles`, without a principal.

function updateMemberRoles(ontology: Ontology, change: MemberRolesChange): Effect.Effect<MemberSummary, UnknownRole | MemberNotFound, SqlClient.SqlClient>;
uploads

Declares which blob field an authored action's upload input may write.

const uploads: {
    target<const P extends Readonly<Record<string, unknown>>>(entity: {
        readonly name: string;
        readonly properties: P;
    }, property: BlobPropertyKey<P>): FileTarget;
    for<const P extends Readonly<Record<string, unknown>>>(entity: {
        readonly name: string;
        readonly properties: P;
    }, property: BlobPropertyKey<P>): typeof BlobUpload;
}
upsertActionName

`upsert_by_email`.

function upsertActionName(property: string): string;
validateBrowserSignIn

Returns a stable machine code for invalid declarations.

function validateBrowserSignIn(value: unknown): string | undefined;
validateWarehouseSource

Validate mappings against a deployment's pipeline schema, never against live warehouse values.

function validateWarehouseSource(entity: EntityManifest, assets: readonly unknown[]): {
    readonly schema: readonly unknown[];
    readonly partitioning: {
        readonly type: string;
        readonly column?: string;
        readonly timezone?: string;
    };
};
vercelWorkflowEngine

The Vercel Workflow SDK as `installWorkflowRuntime()` registered it. The service imports none of the SDK itself: a process that bundles the service without serving workflows, such as the platform's backend on another SDK major, carries none of it.

const vercelWorkflowEngine: WorkflowEngine
warehouse
function warehouse(asset: string, options: Omit<WarehouseSource, "asset">): WarehouseSource;
warehouseColumnType

Normalize scalar pipeline and warehouse schema spellings without accepting nested values.

function warehouseColumnType(value: unknown): string | undefined;
webhook

Declares a webhook trigger; list it in `workflow(name, { input: webhookDelivery, triggers })`. A workflow with a webhook trigger has only webhook triggers.

function webhook<const Name extends string>(name: Name, options: WebhookOptions): WebhookTrigger<Name>;
webhookDelivery

The input of a workflow that a webhook starts: one delivery exactly as it arrived. The workflow parses the body; header names are data and keep their lowercase spelling on the wire.

const webhookDelivery: Schema.Struct<{
    readonly body: import("./property.js").Property<string, false, false>;
    readonly contentType: import("./property.js").Property<string, false, false>;
    readonly query: import("./property.js").Property<string, false, false>;
    readonly headers: Schema.$Record<Schema.String, Schema.String>;
    readonly receivedAt: import("./property.js").Property<string, false, false>;
}>
webhookDeliveryJsonSchema

The JSON Schema of `webhookDelivery`, the input every webhook-started workflow declares, as the manifest writes it. Publication compares a workflow's input with it.

function webhookDeliveryJsonSchema(): JsonSchemaObject;
webhookHeaderProblem

Why a header may not be passed to a workflow, or `undefined` when it may.

function webhookHeaderProblem(name: unknown): string | undefined;
webhookPath

The path of a webhook, without its token: `/api/webhooks/stripe_eu`.

function webhookPath(name: string): string;
webhookSigningKey

The signing secret the platform derives for a webhook that declares `generated: true`: `base64url(HMAC-SHA256(secret, context + name))`, 43 characters, from the workspace's webhook secret and the webhook's wire name. The provider signs deliveries with it as text.

function webhookSigningKey(secret: string, name: string): string;
webhookSigningSecret

The signing secret of a webhook that declares `signature: { generated: true, … }`, for workspace code to register with the provider through the webhook's connection, as BTCPay Server's or GitHub's webhook APIs take one. The ontology service checks deliveries with the same secret. It starts runs for anyone who has it, as a token URL does: send it only to the provider, never to records, logs or people. Call it in a step or an action's `prepare`. It throws {@link WebhookUrlUnavailable} in previews and local runs, and an error for a webhook whose secret is not generated.

function webhookSigningSecret(trigger: WebhookTrigger, environment?: Readonly<Record<string, string | undefined>>): string;
webhookToken

The token of an unsigned webhook: `base64url(HMAC-SHA256(secret, context + name))` without padding, 43 characters. `secret` is the workspace's webhook secret as the platform stores it and `name` the webhook's wire name. The ontology service and backend-next derive the same value, so no token is ever stored (`tests/fixtures/ontology-webhook-token.json`).

function webhookToken(secret: string, name: string): string;
webhookTokenMatches

Whether a received token is the webhook's, compared in constant time.

function webhookTokenMatches(secret: string, name: string, received: string): boolean;
webhookUrl

The full URL of a webhook trigger of this deployment, as `segmentstream workflow webhooks` shows it: the workspace's domain and `/api/webhooks/<name>`, followed by the token for a webhook without a signature. Workspace code gives it to the provider through the webhook's connection, to register an endpoint or as a payment's callback URL. A token URL starts runs for anyone who has it: send it only to the provider, never to records, logs or people. Call it in a step or an action's `prepare`, not in a workflow function. It throws {@link WebhookUrlUnavailable} in previews and local runs, which receive no webhooks.

function webhookUrl(trigger: WebhookTrigger, environment?: Readonly<Record<string, string | undefined>>): string;
websiteOrigin

A website's origin as `guest.origins` and `signUp.origins` accept it, written as an origin alone, without a path, and lowercase: - the exact origin of an `https` address, such as `https://www.example.com`; - the exact origin of an `http` address on `localhost` or `127.0.0.1`, for development; - a pattern whose leftmost label is `*`, under a domain of at least two labels that is not a shared second-level domain such as `co.uk`: `https://*.example.com` or `https://*.vercel.app`. `*` stands for exactly one whole label: the pattern matches `https://www.example.com` and `https://pr-12.example.com`, not `https://example.com` or `https://a.b.example.com`. A pattern under a domain others share, such as `vercel.app`, admits their websites too.

function websiteOrigin(value: unknown): string | undefined;
withCurrentDefinitionNames

An `entity(…)` or `defineOntology(…)` definition with each field it declares under an earlier name only renamed to the current one; without such a field, the definition itself. The earlier names stay known to {@link earlierNamesOf}, for `check`.

function withCurrentDefinitionNames<T extends object>(definition: T): T;
withCurrentFreshMetricQueryNames

A fresh metric query's options with its metrics under `metrics`, whichever name the action used. Naming them under both is a mistake in the action's code, so it throws, as other malformed options fail the action.

function withCurrentFreshMetricQueryNames<R, L extends string, Metric extends string, Group extends string>(options: FreshMetricQueryOptions<R, L, Metric, Group> | EarlierFreshMetricQueryOptions<R, L, Metric, Group>): FreshMetricQueryOptions<R, L, Metric, Group>;
withCurrentManifestNames

A manifest document with the earlier names renamed: an entity's or the top-level `measures` becomes `metrics`, and every `{ op: "measure" }` node of their expressions `{ op: "metric" }`. A pure function on the raw JSON: the input is never changed, and is returned itself when it carries no earlier name, so a document's hash is always computed over what was stored. Every decode of `OntologyManifest` reads documents through it, and readers that serve stored documents use it to answer with the current names.

function withCurrentManifestNames(document: Readonly<Record<string, unknown>>): Readonly<Record<string, unknown>>;
function withCurrentManifestNames(document: unknown): unknown;
withCurrentMetricQueryNames

A metric query's body with the earlier names renamed: `measures` becomes `metrics`, and an order's `measure` its `metric`. A body that names one of them twice is returned as it is, for the schema to refuse; a body without earlier names is returned itself.

function withCurrentMetricQueryNames(body: unknown): unknown;
withCurrentMetricsField

A record, such as a fresh metric query's options, with an earlier `measures` and no `metrics` as one with `metrics`; others as given. Definitions use {@link withCurrentDefinitionNames}.

function withCurrentMetricsField<T extends object>(record: T): T;
withEarlierCatalogNames

An API catalog in current names with deprecated `measures` aliases on the model and its entities. Only the aliases use `measure` expression nodes. Stored documents and their hashes stay untouched.

function withEarlierCatalogNames(document: Readonly<Record<string, unknown>>): Readonly<Record<string, unknown>>;
withEarlierManifestNames

The inverse of {@link withCurrentManifestNames}, for a manifest of a version before 14 that is encoded again: its document keeps the names it was hashed with.

function withEarlierManifestNames(document: Readonly<Record<string, unknown>>): Readonly<Record<string, unknown>>;
withEarlierMetricExpression

A catalog metric's expression in the spelling released clients understand.

function withEarlierMetricExpression(expression: unknown): unknown;
withEarlierMetricsName

The earlier property shares the metrics themselves and their declared names.

function withEarlierMetricsName<M>(metrics: M): EarlierMetricsName<M>;
withEarlierQueryMetricsName

The members an entity handle carries under their earlier names.

function withEarlierQueryMetricsName<QueryMetrics>(queryMetrics: QueryMetrics): {
    readonly [EARLIER_QUERY_METRICS]: QueryMetrics;
};
workflow

Declares a workflow; list it in `defineOntology({ workflows })`.

function workflow<const Name extends string, S extends AnyInputSchema | undefined = undefined>(name: Name, options: WorkflowOptions<S>): Workflow<Name, InputOf<S>>;
workflowRoles

The roles a workflow's runs hold: exactly its declared role. While the ontology declares `member`, they also hold the implicit `member`.

function workflowRoles(ontology: Ontology, role: string): ReadonlyArray<string>;
workflowSubject

The identity subject of a workflow's user: `workflows:<workspace id>:<workflow name>`.

function workflowSubject(workspaceId: string, workflow: string): string;
workspaceMemberships

Read the member's consented, current workspace IDs during action preparation. A production ontology proves its own identity to the platform. No caller-supplied account or target.

const workspaceMemberships: (principal: Principal) => Effect.Effect<{
    readonly consented: boolean;
    readonly workspaceIds: readonly string[];
}, ActionRejected, import("./runtime.js").OntologyReads>
workspaceSourceHistory

Main's commits in the workspace's own repository whose commit time is in `[since, until)`, as the production deployment reads them. The caller (a member, or a workflow's user in a step) must hold `workspace_source:read`. Use it in an action's `prepare` or in a workflow step's `run`.

const workspaceSourceHistory: (query: WorkspaceSourceHistoryQuery) => Effect.Effect<WorkspaceSourceHistory, ActionRejected>