Skip to content
SegmentStream/ Docs

Loading documentation…

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

@segmentstream/app · M–P

20 public exports from @segmentstream/app.

Public exports

ManyFilter

A filter on a to-many relationship: some, none or every related record matches.

interface ManyFilter {
    readonly some?: Where;
    readonly none?: Where;
    readonly every?: Where;
}
MetricQuery

A model-level metric query: metrics of one or more entities, as `entity.metric`, and model metrics, declared in `defineOntology({ metrics })`, by their bare names, grouped by `entity.property` dimensions. A dimension may instead be a route from a metric's entity, `entity.relationship.property`, which picks the way that entity reaches the property. Date bounds are `between` or `inPeriod` filters.

interface MetricQuery<Metric extends string = string, Dimension extends string = string> {
    readonly metrics: readonly Metric[];
    readonly dimensions?: readonly Dimension[];
    readonly filters?: ReadonlyArray<MetricQueryFilter<Dimension>>;
    readonly granularity?: MetricQueryGranularity;
    readonly granularityOf?: Dimension;
    readonly timezone?: string;
    readonly orderBy?: ReadonlyArray<{
        readonly metric?: Metric;
        readonly dimension?: Dimension;
        readonly direction: "asc" | "desc";
    }>;
    readonly limit?: number;
}
MetricQueryClient

`segmentstream.ontology.queryMetrics`: `POST /api/ontology/query_metrics`, as the signed-in user, who needs read permission on every entity the request reaches.

interface MetricQueryClient<Metric extends string = string, Dimension extends string = string> extends EarlierQueryMetricsName<Metric, Dimension> {
    readonly queryMetrics: (request: MetricQuery<Metric, Dimension>, options?: RequestOptions) => Promise<MetricQueryResult>;
}
MetricQueryField

A column of a metric query's answer: a dimension or a metric.

interface MetricQueryField {
    readonly name: string;
    readonly label: string;
    readonly type: string;
    readonly unit?: string;
    readonly format?: string;
    readonly filters?: readonly string[];
    readonly additive?: boolean;
    readonly balanceOver?: string;
    readonly inputs?: readonly string[];
}
MetricQueryFilter

A filter of a model-level metric query. Besides the shared operators, `between` takes two inclusive `values`, the lower first, and `inPeriod` a period relative to today as its `value`; the answer's `execution.periods` gives the dates it resolved to. Only these two bound a partitioned entity.

type MetricQueryFilter<Dimension extends string = string> = {
    readonly dimension: Dimension;
    readonly operator: MetricQueryFilterOperator | "between";
    readonly value?: string | number | boolean;
    readonly values?: ReadonlyArray<string | number | boolean>;
} | {
    readonly dimension: Dimension;
    readonly operator: "inPeriod";
    readonly value: RelativePeriod;
    readonly values?: undefined;
};
MetricQueryFilterOperator

The filter operators of both metric queries. `equals` and `notEquals` take one `value`; `in` and `notIn` take 1–100 `values`; `isNull` and `isNotNull` take none. `notEquals` and `notIn` also match nulls and rows whose relationship found no target, so they are the exact complements of `equals` and `in`. `gt`, `gte`, `lt` and `lte` compare a date, timestamp or number dimension with one `value`; a date bound on a timestamp covers whole days. `contains`, `startsWith` and `endsWith` match one non-empty string in a text dimension, case-sensitively, without wildcards.

type MetricQueryFilterOperator = "equals" | "in" | "notEquals" | "notIn" | "isNull" | "isNotNull" | "gt" | "gte" | "lt" | "lte" | "contains" | "startsWith" | "endsWith";
MetricQueryGranularity

How a date or timestamp dimension is bucketed. `hour` needs a timestamp and yields one.

type MetricQueryGranularity = "hour" | "day" | "week" | "month" | "quarter" | "year";
MetricQueryResult

The answer to a metric query, per entity or model-level.

interface MetricQueryResult<Row = Record<string, string | boolean | null>> {
    readonly deploymentId: string | null;
    readonly definitionDigest: string;
    readonly fields: readonly MetricQueryField[];
    readonly rows: Row[];
    readonly truncated: boolean;
    readonly execution: {
        readonly elapsedMs: number;
        readonly bytesProcessed?: string;
        readonly bytesBilled?: string;
        readonly warnings?: readonly string[];
        readonly sources?: ReadonlyArray<{
            readonly entity: string;
            readonly asOf: string;
        }>;
        readonly periods?: ReadonlyArray<{
            readonly dimension: string;
            readonly value: string;
            readonly from: string;
            readonly to: string;
            readonly timezone: string;
        }>;
    };
}
ModelAggregateClient
type ModelAggregateClient<Measure extends string = string, Dimension extends string = string> = MetricQueryClient<Measure, Dimension>;
ModelAggregateFilter
type ModelAggregateFilter<Dimension extends string = string> = MetricQueryFilter<Dimension>;
ModelAggregateRequest
type ModelAggregateRequest<Measure extends string = string, Dimension extends string = string> = WithEarlierNames<MetricQuery<Measure, Dimension>, Measure>;
NOT_INVITED

The person signed in, but the ontology has no member row for them.

const NOT_INVITED = "not_invited"
OntologyClient

`segmentstream.ontology`: one client per entity of `O`, the type of the app's ontology (`typeof ontology`), and `queryMetrics` across them, a name no entity takes. Without `O`, any entity name is accepted and records are untyped.

type OntologyClient<O = unknown> = unknown extends O ? UntypedOntologyClient : TypedOntologyClient<O>;
OntologyPage

A page of records. `nextCursor` is `null` on the last page.

interface OntologyPage<Row> {
    readonly items: ReadonlyArray<Row>;
    readonly nextCursor: string | null;
    readonly projected?: true;
}
OntologyQuery

A query: the same language for `find` (as URL parameters) and `query` (as a JSON body).

interface OntologyQuery<Row = JsonRecord, Selection extends readonly (keyof Row & string)[] | undefined = undefined> {
    readonly select?: Selection;
    readonly where?: Where;
    readonly orderBy?: ReadonlyArray<OrderBy<keyof Row & string>>;
    readonly include?: ReadonlyArray<string> | {
        readonly [relationship: string]: true;
    };
    readonly after?: string;
    readonly limit?: number;
}
OrderBy
interface OrderBy<Field extends string = string> {
    readonly field: Field;
    readonly direction?: "asc" | "desc";
}
ParameterType
type ParameterType = (typeof PARAMETER_TYPES)[number];
Participants
type Participants = Readonly<Record<string, {
    readonly aliases: ReadonlyArray<string>;
}>>;
PermissionHolder

Anything that holds permissions, such as the signed-in user.

interface PermissionHolder {
    readonly permissions: ReadonlyArray<string>;
}
ProxyOptions
interface ProxyOptions {
    readonly publicPaths?: readonly string[];
    readonly sessionOptionalPaths?: readonly string[];
    readonly channelLaunchFailurePath?: string;
}