Client configuration and metadata
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 / method | Contract |
|---|---|
| contextAlias, resourceAttribution, aggregateName | Joined in this order to make basePath; absent parts are empty. |
| basePath | Explicit value overrides the composed path, including an explicit empty string. |
| Other ApiMetadata options | Forwarded to decorator execution, including fetcher and request options. |
| createSnapshotQueryClient | SnapshotQueryClient<S,FIELDS> |
| createLoadStateAggregateClient | LoadStateAggregateClient<S> |
| createOwnerLoadStateAggregateClient | LoadOwnerStateAggregateClient<S> (note method spelling) |
| createEventStreamQueryClient | EventStreamQueryClient<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
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
export interface ScopesCapable {
scopes: string[];
}packages/wow/src/configuration/wowMetadata.ts:16
Aggregate
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
export interface BoundedContext extends ScopesCapable, DescriptionCapable {
alias: string | null;
aggregates: Record<string, Aggregate>;
}packages/wow/src/configuration/wowMetadata.ts:43
WowMetadata
export interface WowMetadata extends DescriptionCapable {
contexts: Record<string, BoundedContext>;
}packages/wow/src/configuration/wowMetadata.ts:48
createQueryApiMetadata
export function createQueryApiMetadata(
options: QueryClientOptions,
): ApiMetadata;packages/wow/src/query/queryClients.ts:49
QueryClientOptions
export interface QueryClientOptions
extends
PartialBy<ApiMetadata, 'basePath'>,
Partial<AliasBoundedContext>,
Partial<AggregateNameCapable> {
contextAlias?: string;
resourceAttribution?: ResourceAttributionPathSpec;
}packages/wow/src/query/queryClients.ts:31
QueryClientFactory
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
Related topics
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
