@cbnsndwch/zero-sources

nest-zero-synced-queries package

Home > @cbnsndwch/nest-zero-synced-queries

nest-zero-synced-queries package

Classes

Class

Description

SyncedQueriesModule

Dynamic module for Zero Synced Queries infrastructure.

This module provides all the plumbing needed for Zero synced queries: - Automatic discovery of @SyncedQuery methods in controllers and providers - HTTP endpoint for query transformation requests from Zero cache - Query execution and AST conversion service - Error handling per Zero protocol

## Usage

Import this module in your app module using forRoot() to configure:

SyncedQueryRegistry

Service for discovering and managing synced query handlers.

This service implements the discovery pattern similar to NestJS microservices, scanning for decorated methods and building a registry of query handlers.

SyncedQueryTransformService

Service for transforming Zero query requests into AST responses.

This service coordinates: 1. Looking up query handlers in the registry 2. Executing handlers with user context and arguments 3. Converting query builders to AST format 4. Handling errors per Zero protocol

Enumerations

Enumeration

Description

SyncedQueryParamType

Parameter types that can be injected into query handlers.

Functions

Function

Description

getParameterMetadata(target, propertyKey)

Get parameter metadata for a method.

QueryArg(index)

Parameter decorator to inject a query argument by index.

Use this decorator to explicitly map query arguments to method parameters.

SyncedQuery(queryName, inputSchema)

Decorator for Zero synced query handlers.

Use this decorator to mark a method as a synced query handler. Works on both controllers and providers.

Interfaces

Interface

Description

RegisteredQueryHandler

Registered query handler with metadata and execution context.

SyncedQueriesModuleOptions

Configuration options for the SyncedQueriesModule.

SyncedQueryMetadata

Configuration for a synced query handler.

SyncedQueryParamMetadata

Metadata for a parameter decorator.

TransformQueryError

Error response for failed query transformation.

TransformQuerySuccess

Successful query transformation response.

TransformRequestItem

Request item structure from Zero cache server.

Variables

Variable

Description

SYNCED_QUERY_METADATA

Metadata key for synced query handlers.

Used by decorator to mark methods as query handlers and store their configuration.

SYNCED_QUERY_PARAM_METADATA

Metadata key for storing parameter decorator information.

Type Aliases

Type Alias

Description

QueryHandler

Type definition for a query handler function.

TransformQueryResult

Union type for query transformation results.

TransformRequestBody

Request body type from Zero cache (array of query requests).

How was this page?