Skip to content
SegmentStream/ Docs

Loading documentation…

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

@segmentstream/app · U–Z

20 public exports from @segmentstream/app.

Public exports

UntypedOntologyClient

A client for any entity, when the app passes no ontology type.

type UntypedOntologyClient = MetricQueryClient & {
    readonly [entity: string]: EntityClient<JsonRecord, {
        readonly [action: string]: ActionCall<JsonRecord, JsonValue>;
    }> & EntityMetricQueryClient;
};
UploadSession
interface UploadSession {
    readonly id: string;
    readonly state: string;
    readonly expiresAt: string;
    readonly ticket?: BlobUploadTicket;
}
UserConnection

Where the signed-in user's own credential of an owned connection stands.

interface UserConnection {
    readonly key: string;
    readonly state: "connected" | "not_connected" | "reconnect_required";
    readonly connectedAt: string | null;
    readonly background: boolean;
}
UserConnectionCall

One call that used the signed-in user's credential: never a body or a header.

interface UserConnectionCall {
    readonly calledAt: string;
    readonly callKind: "interactive" | "background";
    readonly source: string;
    readonly method: string;
    readonly api: string | null;
    readonly path: string;
    readonly outcome: string;
    readonly requestId: string | null;
}
UserConnectionRouteHandlers

Route Handlers, as Next.js calls them.

interface UserConnectionRouteHandlers {
    readonly GET: (request: Request) => Promise<Response>;
    readonly POST: (request: Request) => Promise<Response>;
    readonly PATCH: (request: Request) => Promise<Response>;
    readonly DELETE: (request: Request) => Promise<Response>;
}
UserConnectionStart

The provider's consent the browser goes to, and when it stops working.

interface UserConnectionStart {
    readonly authorizationUrl: string;
    readonly expiresAt: string;
}
UserConnections

The signed-in user's own credentials of the workspace's owned connections (docs/private-connections-spec.md, "In the app"). Each acts on the caller's own credential; none takes a user. Failures throw {@link SegmentStreamApiError } with the platform's code, such as `connection_owner_mismatch` or `connection_authorization_conflict`. Server-only.

interface UserConnections {
    readonly list: () => Promise<ReadonlyArray<UserConnection>>;
    readonly calls: (key: string, options?: {
        readonly after?: string;
    }) => Promise<{
        readonly calls: ReadonlyArray<UserConnectionCall>;
        readonly next: string | null;
    }>;
    readonly start: (key: string, options: {
        readonly background: boolean;
    }) => Promise<UserConnectionStart>;
    readonly connectWithToken: (key: string, options: {
        readonly token: string;
        readonly background: boolean;
        readonly accountId?: string;
    }) => Promise<UserConnection>;
    readonly confirm: (key: string, confirmation: string) => Promise<UserConnection>;
    readonly discard: (key: string, confirmation: string) => Promise<void>;
    readonly setBackground: (key: string, allowed: boolean) => Promise<UserConnection>;
    readonly disconnect: (key: string) => Promise<void>;
    readonly routeHandlers: () => UserConnectionRouteHandlers;
}
UserGeneratedActions

The generated actions of the built-in `user`, which change a member's roles and activation. Role names are spelled as `requireUser().roles` spells them. Each returns the updated record.

interface UserGeneratedActions<Row = JsonRecord> {
    readonly invite: ActionCall<{
        readonly email: string;
        readonly name?: string;
        readonly roles?: ReadonlyArray<string>;
    }, Row>;
    readonly grantRoles: ActionCall<{
        readonly id: string;
        readonly roles: ReadonlyArray<string>;
    }, Row>;
    readonly revokeRoles: ActionCall<{
        readonly id: string;
        readonly roles: ReadonlyArray<string>;
    } | {
        readonly id: string;
        readonly all: true;
    }, Row>;
    readonly deactivate: ActionCall<{
        readonly id: string;
    }, Row>;
    readonly reactivate: ActionCall<{
        readonly id: string;
    }, Row>;
}
UserOptions

How `getUser`, `requireUser` and `can` read the signed-in user.

interface UserOptions {
    readonly fresh?: boolean;
}
ValidationIssue
interface ValidationIssue {
    readonly path: ReadonlyArray<string | number>;
    readonly message: string;
}
WarehouseClient
interface WarehouseClient {
    readonly query: <Row = WarehouseRow>(sql: string, options?: WarehouseQueryOptions) => Promise<WarehouseQueryResult<Row>>;
    readonly result: <Row = WarehouseRow>(queryId: string, options?: WarehouseReadOptions) => Promise<WarehouseQueryResult<Row>>;
    readonly dryRun: (sql: string, options?: Pick<WarehouseQueryOptions, "params" | "maximumBytesBilled" | "signal">) => Promise<WarehouseDryRun>;
}
WarehouseColumn
interface WarehouseColumn {
    readonly name: string;
    readonly type: string;
    readonly mode: string;
    readonly description: string;
}
WarehouseDryRun
interface WarehouseDryRun {
    readonly columns: readonly WarehouseColumn[];
    readonly bytesProcessed: string | null;
    readonly maximumBytesBilled: string;
}
WarehouseQueryOptions
interface WarehouseQueryOptions extends WarehouseReadOptions {
    readonly params?: QueryParameters;
    readonly maximumBytesBilled?: number | bigint | string;
}
WarehouseQueryResult
interface WarehouseQueryResult<Row = WarehouseRow> {
    readonly queryId: string | null;
    readonly columns: readonly WarehouseColumn[];
    readonly rows: Row[];
    readonly totalRows: number | null;
    readonly truncated: boolean;
    readonly bytesProcessed: string | null;
    readonly bytesBilled: string | null;
    readonly cacheHit: boolean | null;
}
WarehouseReadOptions

How much of a query result to wait for and collect.

interface WarehouseReadOptions {
    readonly maxRows?: number;
    readonly pageSize?: number;
    readonly timeoutMs?: number;
    readonly signal?: AbortSignal;
}
WarehouseRow
type WarehouseRow = Record<string, WarehouseValue>;
WarehouseValue
type WarehouseValue = string | number | boolean | null;
Where

Conditions on a record by field or relationship name, with `and`, `or` and `not`.

interface Where {
    readonly and?: ReadonlyArray<Where>;
    readonly or?: ReadonlyArray<Where>;
    readonly not?: Where;
    readonly [field: string]: FieldFilter | ManyFilter | Where | ReadonlyArray<Where> | JsonValue | undefined;
}
withRequestTiming

Time an app Route Handler until it returns response headers. Streaming/rendering after that point is excluded. Logs contain no URL, cookies, body or error text. Server Components need framework instrumentation for complete page timing; a Next.js proxy only times authentication.

function withRequestTiming<R extends Request, A extends unknown[]>(handler: (request: R, ...args: A) => Promise<Response>): (request: R, ...args: A) => Promise<Response>;