Skip to content

Client configuration and metadata ​

5.x only

This page applies to the 5.x line only (npm 5.1.x, branch 5.x). From 6.0, @ahoo-wang/fetcher-wow lives in the Wow repository (typescript/) and is documented at wow.ahoo.me; its successor @ahoo-wang/wow-client is on npm from Wow 9.2.0 (9.2.1 or later accepts fetcher 6).

Use QueryClientFactory<S,FIELDS,DomainEventBody> when snapshot, event and historical-state clients share an aggregate route. Pass QueryClientOptions once and override options per create method. Construction only composes metadata; it does not discover a server, request schema, or validate a deployment.

Input / methodContract
contextAlias, resourceAttribution, aggregateNameJoined in this order to make basePath; absent parts are empty.
basePathExplicit value overrides the composed path, including an explicit empty string.
Other ApiMetadata optionsForwarded to decorator execution, including fetcher and request options.
createSnapshotQueryClientSnapshotQueryClient<S,FIELDS>
createLoadStateAggregateClientLoadStateAggregateClient<S>
createOwnerLoadStateAggregateClientLoadOwnerStateAggregateClient<S> (note method spelling)
createEventStreamQueryClientEventStreamQueryClient<DomainEventBody,FIELDS>

Per-call options shallowly override constructor defaults. createQueryApiMetadata(options) exposes the same route construction directly. Supply actual URL path values through the request configuration when a ResourceAttributionPathSpec contains {tenantId} or {ownerId}. Missing Fetcher registration and request failures belong to decorator/Fetcher execution; no I/O or cleanup occurs when creating these wrappers.

WowMetadata is a data model with description and contexts keyed by name. Each BoundedContext has alias, scopes and aggregates; an Aggregate has type, tenantId, id, scopes, command names and event names. Nullable metadata values are explicit nulls. This module exports no wow() decorator or automatic metadata fetcher. Read commands and snapshot queries for execution.

Complete example ​

ts
import {
  QueryClientFactory,
  createQueryApiMetadata,
} from '@ahoo-wang/fetcher-wow';
interface User {
  id: string;
  name: string;
}
const options = { contextAlias: 'accounts', aggregateName: 'user' };
const factory = new QueryClientFactory<User>(options);
const snapshots = factory.createSnapshotQueryClient();
const history = factory.createLoadStateAggregateClient();
console.log(createQueryApiMetadata(options).basePath); // accounts/user
export { snapshots, history };

Service URLs in examples require application endpoints; type checking does not imply an external service was contacted.

Public signatures and types ​

These signatures follow declarations reachable from the current root entry. ? marks optional input; generics/interfaces only constrain compile-time types. Locate inherited and related types through the symbol index. Runtime defaults and failure behavior are described above.

ScopesCapable ​

ts
export interface ScopesCapable {
  scopes: string[];
}

packages/wow/src/configuration/wowMetadata.ts:16

Aggregate ​

ts
export interface Aggregate extends ScopesCapable {
  type: string | null;
  tenantId: string | null;
  id: string | null;
  commands: string[];
  events: string[];
}

packages/wow/src/configuration/wowMetadata.ts:20

BoundedContext ​

ts
export interface BoundedContext extends ScopesCapable, DescriptionCapable {
  alias: string | null;
  aggregates: Record<string, Aggregate>;
}

packages/wow/src/configuration/wowMetadata.ts:43

WowMetadata ​

ts
export interface WowMetadata extends DescriptionCapable {
  contexts: Record<string, BoundedContext>;
}

packages/wow/src/configuration/wowMetadata.ts:48

createQueryApiMetadata ​

ts
export function createQueryApiMetadata(
  options: QueryClientOptions,
): ApiMetadata;

packages/wow/src/query/queryClients.ts:49

QueryClientOptions ​

ts
export interface QueryClientOptions
  extends
    PartialBy<ApiMetadata, 'basePath'>,
    Partial<AliasBoundedContext>,
    Partial<AggregateNameCapable> {
  contextAlias?: string;
  resourceAttribution?: ResourceAttributionPathSpec;
}

packages/wow/src/query/queryClients.ts:31

QueryClientFactory ​

ts
export class QueryClientFactory<S, FIELDS extends string = string, DomainEventBody = any> {
    constructor(private readonly defaultOptions: QueryClientOptions);
    createSnapshotQueryClient(options?: QueryClientOptions): SnapshotQueryClient<S, FIELDS>;
    createLoadStateAggregateClient(options?: QueryClientOptions): LoadStateAggregateClient<S>;
    createOwnerLoadStateAggregateClient(options?: QueryClientOptions): LoadOwnerStateAggregateClient<S>;
    createEventStreamQueryClient<FIELDS extends string = string>(options?: QueryClientOptions): EventStreamQueryClient<DomainEventBody, FIELDS>;
}

packages/wow/src/query/queryClients.ts:62

Commands and wait results · Snapshot queries · Filter expressions and legacy conditions · Projection, sorting and pagination · Cursor queries · Aggregation builders · Events and historical state · Identity and resource attribution

Released under the Apache License 2.0.