@segmentstream/app · E–H
23 public exports from @segmentstream/app.
Public exports
EarlierEntityQueryMetricsName
An entity's `queryMetrics` under its earlier name.
interface EarlierEntityQueryMetricsName<Property extends string, Metric extends string, Temporal extends Property, Path extends string> {
readonly aggregate: (request: EntityMetricQuery<Property, Metric, Temporal, Path> | AggregateRequest<Property, Metric, Temporal, Path>, options?: RequestOptions) => Promise<MetricQueryResult>;
}EarlierMetricsOf
The metrics an entity of an ontology SDK before manifest version 14 declares under their earlier name: a warehouse-backed entity's `measures`, or those of a stored entity's definition.
type EarlierMetricsOf<E> = E extends {
readonly measures: infer M;
} ? keyof M & string : E extends {
readonly definition: {
readonly measures?: infer M;
};
} ? DeclaredNames<NonNullable<M>> : never;EarlierModelMetricsOf
The model metrics of such an ontology, `defineOntology({ measures })`, by their bare names.
type EarlierModelMetricsOf<O> = O extends {
readonly config: {
readonly measures?: infer M;
};
} ? DeclaredNames<NonNullable<M>> : never;EarlierQueryMetricsName
The model-level `queryMetrics` under its earlier name.
interface EarlierQueryMetricsName<Metric extends string, Dimension extends string> {
readonly aggregate: (request: MetricQuery<Metric, Dimension> | ModelAggregateRequest<Metric, Dimension>, options?: RequestOptions) => Promise<MetricQueryResult>;
}Edit
What one action changed on one record.
interface Edit {
readonly entity: string;
readonly id: string;
readonly kind: EditKind;
readonly changes: {
readonly [field: string]: Change;
};
}EditKind
type EditKind = "create" | "update" | "delete" | "link" | "unlink";
EntityClient
interface EntityClient<Row, Actions, Generated = GeneratedActions> {
readonly find: <const Selection extends readonly (keyof Row & string)[] | undefined = undefined>(query?: OntologyQuery<Row, Selection>, options?: RequestOptions) => Promise<OntologyPage<SelectedRecord<Row, Selection>>>;
readonly query: <const Selection extends readonly (keyof Row & string)[] | undefined = undefined>(query?: OntologyQuery<Row, Selection>, options?: RequestOptions) => Promise<OntologyPage<SelectedRecord<Row, Selection>>>;
readonly get: (id: string, options?: RequestOptions) => Promise<Row>;
readonly history: (id: string, options?: HistoryOptions) => Promise<HistoryPage>;
readonly files: EntityFilesClient<BlobPropertyNames<Row>>;
readonly actions: Actions & Generated;
readonly action: (name: string, input: JsonRecord, options?: ActionOptions) => Promise<ActionResponse<JsonValue>>;
}EntityFilesClient
interface EntityFilesClient<Property extends string = string> {
readonly download: (id: string, property: Property, options?: FileDownloadOptions) => Promise<FileTransfer>;
}EntityMetricQuery
A metric query of one entity: its metrics, grouped by dimensions. Dimensions, filters and ordering name the entity's own properties, or a related entity's property through to-one relationships: `Path`, such as `product.brand`.
interface EntityMetricQuery<Property extends string = string, Metric extends string = string, Temporal extends Property = Property, Path extends string = never> {
readonly dimensions: readonly (Property | Path)[];
readonly metrics: readonly Metric[];
readonly dateRange?: {
readonly from: string;
readonly to: string;
};
readonly granularityOf?: Temporal | Path;
readonly granularity?: MetricQueryGranularity;
readonly timezone?: string;
readonly filters?: ReadonlyArray<{
readonly dimension: Property | Path;
readonly operator: MetricQueryFilterOperator;
readonly value?: string | number | boolean;
readonly values?: ReadonlyArray<string | number | boolean>;
}>;
readonly orderBy?: ReadonlyArray<{
readonly metric?: Metric;
readonly dimension?: Property | Path;
readonly direction: "asc" | "desc";
}>;
readonly limit?: number;
}EntityMetricQueryClient
`segmentstream.ontology.<entity>.queryMetrics`: `POST /api/ontology/<entity>/query_metrics`, the entity's own metrics by the names relative to it, as the signed-in user.
interface EntityMetricQueryClient<Property extends string = string, Metric extends string = string, Temporal extends Property = Property, Path extends string = never> extends EarlierEntityQueryMetricsName<Property, Metric, Temporal, Path> {
readonly queryMetrics: (request: EntityMetricQuery<Property, Metric, Temporal, Path>, options?: RequestOptions) => Promise<MetricQueryResult>;
}FieldFilter
Conditions on one field; all of them must hold. `contains` and `startsWith` ignore case; `between` includes both ends; `has` and `hasAny` match a list, such as `user.roles`, that holds the value or any of the values. In a `where`, a bare value stands for `{ eq: value }`.
interface FieldFilter {
readonly eq?: JsonValue;
readonly ne?: JsonValue;
readonly in?: ReadonlyArray<JsonValue>;
readonly isNull?: boolean;
readonly contains?: string;
readonly startsWith?: string;
readonly gt?: number | string;
readonly gte?: number | string;
readonly lt?: number | string;
readonly lte?: number | string;
readonly between?: readonly [
number | string,
number | string
];
readonly has?: string;
readonly hasAny?: ReadonlyArray<string>;
}FileDownloadOptions
interface FileDownloadOptions {
readonly revisionId?: string;
readonly inline?: boolean;
readonly signal?: AbortSignal;
}FileRevision
interface FileRevision {
readonly id: string;
readonly filename: string;
readonly contentType: string;
readonly size: number;
readonly createdAt: string;
}FileTransfer
interface FileTransfer {
readonly url: string;
readonly method: "GET" | "PUT";
readonly headers: Readonly<Record<string, string>>;
readonly expiresAt: string;
}FileUploadOptions
interface FileUploadOptions {
readonly signal?: AbortSignal;
readonly idempotencyKey?: string;
readonly onProgress?: (transferred: number, total: number) => void;
readonly onSession?: (session: UploadSession) => void;
}FileUploadTarget
interface FileUploadTarget {
readonly entity: string;
readonly property: string;
readonly action: string;
readonly recordId?: string;
readonly createIntent?: string;
}GeneratedActions
The generated actions every entity has; their inputs are not typed by the client.
interface GeneratedActions {
readonly create: ActionCall<JsonRecord, JsonValue>;
readonly update: ActionCall<{
readonly id: string;
} & JsonRecord, JsonValue>;
readonly delete: ActionCall<{
readonly id: string;
}, JsonValue>;
}GroupPolicyInput
interface GroupPolicyInput {
readonly mode?: string;
readonly smart?: SmartPolicyInput;
readonly participants?: Participants;
readonly chats?: Readonly<Record<string, ChatOverrideInput>>;
readonly observability?: {
readonly storeRouterPayload?: boolean;
readonly shadow?: SmartPolicyInput;
};
}HistoryEntry
interface HistoryEntry {
readonly id: string;
readonly recordId: string;
readonly action: string;
readonly actionId: string;
readonly kind: EditKind;
readonly principalId: string | null;
readonly chat?: {
readonly provider: string;
readonly chatId: string;
readonly sessionId?: string;
};
readonly at: string;
readonly changes: {
readonly [field: string]: Change;
};
}HistoryOptions
interface HistoryOptions extends RequestOptions {
readonly after?: string;
readonly limit?: number;
}HistoryPage
interface HistoryPage {
readonly items: ReadonlyArray<HistoryEntry>;
readonly nextCursor: string | null;
}grants
Whether a granted permission, which may hold wildcards, covers the required one.
function grants(granted: string, required: string): boolean;
groupPolicyIssues
Strict validation of the `groups` section that `agent/segmentstream.json` authors.
function groupPolicyIssues(authored: unknown): ReadonlyArray<GroupPolicyIssue>;