@riffdb/client 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DriverApplicationTransport, type DriverApplicationError, type DriverCompactQueryResult, type DriverPackedQueryResult, type DriverOperation } from "./driver.js";
1
+ import { DriverApplicationTransport, type DriverApplicationError, type DriverApplicationTransportOptions, type DriverBatchResult, type DriverConnectFromEnvOptions, type DriverCompactQueryResult, type DriverInvokeOptions, type DriverPackedQueryResult, type DriverOperation, type DriverResult, type DriverValue, type ResolvedDriverApplicationIdentity } from "./driver.js";
2
2
  export type ApplicationValueSchema = {
3
3
  readonly kind: "bool" | "i64" | "u64" | "string" | "uuid" | "bytes" | "date" | "timestamp" | "cursor" | "limit";
4
4
  readonly maximumBytes?: number;
@@ -51,12 +51,52 @@ export interface ExactDecimalValue {
51
51
  readonly coefficientTwosComplement: Uint8Array;
52
52
  readonly scale: number;
53
53
  readonly precision: number;
54
+ toString?(): string;
55
+ toJSON?(): string;
54
56
  }
55
57
  /** One exact currency value accepted by generated `money<CURRENCY>` fields. */
56
58
  export interface ExactMoneyValue<Currency extends string = string> {
57
59
  readonly currency: Currency;
58
60
  readonly amount: ExactDecimalValue;
61
+ toString?(): string;
62
+ toJSON?(): {
63
+ readonly currency: Currency;
64
+ readonly amount: string;
65
+ };
59
66
  }
67
+ /** One exact UTC timestamp returned by generated query and command fields. */
68
+ export interface TimestampValue {
69
+ readonly seconds: bigint;
70
+ readonly nanos: number;
71
+ toISOString(): string;
72
+ toDate(): Date;
73
+ toJSON(): string;
74
+ toString(): string;
75
+ }
76
+ export type TimestampInput = TimestampValue | {
77
+ readonly seconds: bigint | number | string;
78
+ readonly nanos?: number;
79
+ } | Date | string;
80
+ export type IntegerInput = bigint | number | string;
81
+ export declare class RiffTimestamp implements TimestampValue {
82
+ readonly seconds: bigint;
83
+ readonly nanos: number;
84
+ constructor(seconds: bigint, nanos?: number);
85
+ static from(value: TimestampInput): TimestampValue;
86
+ static now(): TimestampValue;
87
+ toISOString(): string;
88
+ toDate(): Date;
89
+ toJSON(): string;
90
+ toString(): string;
91
+ }
92
+ export declare function createTimestampValue(seconds: bigint, nanos: number): TimestampValue;
93
+ export declare function formatTimestampIso(seconds: bigint, nanos: number): string;
94
+ export declare function formatExactDecimal(value: {
95
+ readonly coefficientTwosComplement: Uint8Array;
96
+ readonly scale: number;
97
+ }): string;
98
+ export declare function toJsonValue(value: unknown, key?: string): unknown;
99
+ export declare function attachRecordToJson<T extends Record<string, unknown>>(record: T): T;
60
100
  /**
61
101
  * Constructs an exact fixed-point value from decimal text without using a
62
102
  * JavaScript floating-point number.
@@ -198,8 +238,10 @@ export interface ContextualBatch<E> {
198
238
  readonly status: ReactiveConsumerStatus;
199
239
  }
200
240
  export interface ReactiveConsumerStatus {
241
+ readonly kind?: "exact" | "protected";
201
242
  readonly revision: bigint;
202
243
  readonly checkpoint: string;
244
+ readonly progressCursor?: string;
203
245
  readonly historyIncarnation: bigint;
204
246
  readonly liveLeases: number;
205
247
  readonly retries: number;
@@ -294,8 +336,15 @@ export declare class CliApplicationTransport {
294
336
  export declare class DriverGeneratedApplicationTransport {
295
337
  private readonly driver;
296
338
  constructor(driver: DriverApplicationTransport);
339
+ static connect(options: DriverApplicationTransportOptions): Promise<DriverGeneratedApplicationTransport>;
340
+ static connectFromEnv(options?: DriverConnectFromEnvOptions): Promise<DriverGeneratedApplicationTransport>;
297
341
  /** Returns the bound tenant identifier when this session is tenant-scoped. */
298
342
  get tenant(): string | undefined;
343
+ /** Returns the resolved application identity verified during driver handshake. */
344
+ get identity(): ResolvedDriverApplicationIdentity;
345
+ invoke(operation: DriverOperation, input: Readonly<Record<string, DriverValue>>, options?: DriverInvokeOptions): Promise<DriverResult>;
346
+ batch(operation: DriverOperation, items: ReadonlyArray<Readonly<Record<string, DriverValue>>>, concurrency: number, checkpoint: number, options?: DriverInvokeOptions): Promise<DriverBatchResult>;
347
+ shutdown(): Promise<void>;
299
348
  executeNamedQuery<P, R>(request: NamedQueryRequest<P, R>, options?: QueryOptions): Promise<TypedQueryResult<R>>;
300
349
  executeCommand<I, R>(request: CommandRequest<I, R>, attemptBudget: number): Promise<TypedCommandResult<R>>;
301
350
  executeVectorInspection<P, R>(request: VectorInspectionRequest<P, R>, options?: VectorInspectionOptions): Promise<TypedVectorInspectionResult<R>>;
@@ -328,5 +377,39 @@ export declare class DriverGeneratedApplicationTransport {
328
377
  }): AsyncIterable<LiveQueryUpdate<T>>;
329
378
  private mutateDriverLease;
330
379
  }
331
- export { DRIVER_ERROR_REGISTRY_HASH, DRIVER_PROTOCOL_VERSION, DRIVER_VALUE_REGISTRY_HASH, DriverApplicationError, DriverApplicationTransport, } from "./driver.js";
332
- export type { DriverApplicationIdentity, DriverApplicationTransportOptions, DriverBatchItem, DriverBatchResult, DriverBatchSuccess, DriverDecimal, DriverErrorDetails, DriverInvokeOptions, DriverMoney, DriverOperation, DriverPackedColumn, DriverPackedQueryResult, DriverResult, DriverTimestamp, DriverValue, } from "./driver.js";
380
+ declare module "./driver.js" {
381
+ interface DriverApplicationTransport {
382
+ executeNamedQuery<P, R>(request: NamedQueryRequest<P, R>, options?: QueryOptions): Promise<TypedQueryResult<R>>;
383
+ executeCommand<I, R>(request: CommandRequest<I, R>, attemptBudget: number): Promise<TypedCommandResult<R>>;
384
+ executeVectorInspection<P, R>(request: VectorInspectionRequest<P, R>, options?: VectorInspectionOptions): Promise<TypedVectorInspectionResult<R>>;
385
+ executeCommandBatch<I, R>(request: CommandRequest<I, R>, inputs: ReadonlyArray<I>, concurrency: number, checkpoint: number, attemptBudget: number): Promise<{
386
+ readonly items: ReadonlyArray<{
387
+ readonly index: number;
388
+ readonly result?: TypedCommandResult<R>;
389
+ readonly error?: DriverApplicationError;
390
+ }>;
391
+ readonly checkpoint: number;
392
+ }>;
393
+ consumeEventStream<P, E>(request: ReactiveConsumerRequest<P>, options?: ReactiveConsumerOptions): AsyncIterable<ReactiveConsumerBatch<E>>;
394
+ acknowledgeEvent<P>(request: ReactiveConsumerRequest<P>, delivery: ReactiveEventDelivery<unknown>): Promise<ReactiveEventMutationResult>;
395
+ negativeAcknowledgeEvent<P>(request: ReactiveConsumerRequest<P>, delivery: ReactiveEventDelivery<unknown>, retryDelayMs?: number): Promise<ReactiveEventMutationResult>;
396
+ seekEventConsumer<P>(request: ReactiveConsumerRequest<P>, checkpoint: string): Promise<ReactiveEventMutationResult>;
397
+ eventConsumerStatus<P>(request: ReactiveConsumerRequest<P>): Promise<ReactiveConsumerStatus | undefined>;
398
+ consumeContextualSubscription<P, E>(request: ReactiveConsumerRequest<P>, maximumWaitMs?: number, signal?: AbortSignal): Promise<ContextualBatch<E>>;
399
+ acknowledgeContextualItem<P>(request: ReactiveConsumerRequest<P>, item: ContextualWorkItem<unknown>): Promise<ReactiveEventMutationResult>;
400
+ negativeAcknowledgeContextualItem<P>(request: ReactiveConsumerRequest<P>, item: ContextualWorkItem<unknown>, retryDelayMs?: number): Promise<ReactiveEventMutationResult>;
401
+ contextualSubscriptionStatus<P>(request: ReactiveConsumerRequest<P>): Promise<ReactiveConsumerStatus | undefined>;
402
+ executeContextualReaction<P, I, R>(request: ReactiveConsumerRequest<P>, reaction: ContextualReaction, command: CommandRequest<I, R>): Promise<TypedCommandResult<R>>;
403
+ watchNamedQuery<P, T>(request: {
404
+ readonly driverOperations?: Readonly<Record<string, DriverOperation>>;
405
+ readonly reactiveModuleHash: string;
406
+ readonly operationName: string;
407
+ readonly parameters: P;
408
+ readonly parameterSchema: ApplicationValueSchema;
409
+ readonly cursor?: string;
410
+ readonly signal?: AbortSignal;
411
+ }): AsyncIterable<LiveQueryUpdate<T>>;
412
+ }
413
+ }
414
+ export { DRIVER_ERROR_REGISTRY_HASH, DRIVER_PROTOCOL_VERSION, DRIVER_VALUE_REGISTRY_HASH, DriverApplicationError, DriverApplicationTransport, resolveTransportOptionsFromEnv, } from "./driver.js";
415
+ export type { DriverApplicationIdentity, DriverApplicationTransportOptions, DriverConnectFromEnvOptions, DriverBatchItem, DriverBatchResult, DriverBatchSuccess, DriverDecimal, DriverErrorDetails, DriverInvokeOptions, DriverMoney, DriverOperation, DriverPackedColumn, DriverPackedQueryResult, DriverResult, DriverTimestamp, DriverValue, ResolvedDriverApplicationIdentity, } from "./driver.js";