@riffdb/client 0.0.0-stage → 0.2.0
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/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +27 -0
- package/README.md +44 -2
- package/conformance-manifest-v1.json +15 -0
- package/dist/driver.d.ts +171 -0
- package/dist/driver.js +932 -0
- package/dist/index.d.ts +332 -0
- package/dist/index.js +2054 -0
- package/dist/operator.d.ts +65 -0
- package/dist/operator.js +313 -0
- package/package.json +1 -6
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { DriverApplicationTransport, type DriverApplicationError, type DriverCompactQueryResult, type DriverPackedQueryResult, type DriverOperation } from "./driver.js";
|
|
2
|
+
export type ApplicationValueSchema = {
|
|
3
|
+
readonly kind: "bool" | "i64" | "u64" | "string" | "uuid" | "bytes" | "date" | "timestamp" | "cursor" | "limit";
|
|
4
|
+
readonly maximumBytes?: number;
|
|
5
|
+
} | {
|
|
6
|
+
readonly kind: "vector";
|
|
7
|
+
readonly dimension: number;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: "decimal";
|
|
10
|
+
readonly precision?: number;
|
|
11
|
+
readonly scale?: number;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: "money";
|
|
14
|
+
readonly precision?: number;
|
|
15
|
+
readonly scale?: number;
|
|
16
|
+
readonly currency?: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "enum";
|
|
19
|
+
readonly typeId?: number;
|
|
20
|
+
readonly variants?: Readonly<Record<string, number>>;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: "optional";
|
|
23
|
+
readonly value: ApplicationValueSchema;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: "list";
|
|
26
|
+
readonly value: ApplicationValueSchema;
|
|
27
|
+
readonly minimum?: number;
|
|
28
|
+
readonly maximum?: number;
|
|
29
|
+
readonly aggregateCanonicalElementBytes?: number;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "record";
|
|
32
|
+
readonly fields: ReadonlyArray<{
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly schema: ApplicationValueSchema;
|
|
35
|
+
readonly wireId?: number;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
export type InputBudgetCause = "collection_count" | "individual_value_bytes" | "aggregate_canonical_element_bytes";
|
|
39
|
+
export interface InputBudgetPath {
|
|
40
|
+
readonly collection: string;
|
|
41
|
+
readonly index?: number;
|
|
42
|
+
readonly leaf?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare class InputBudgetError extends Error {
|
|
45
|
+
readonly cause: InputBudgetCause;
|
|
46
|
+
readonly path: InputBudgetPath;
|
|
47
|
+
constructor(cause: InputBudgetCause, path: InputBudgetPath);
|
|
48
|
+
}
|
|
49
|
+
/** One exact fixed-point value accepted by generated decimal fields. */
|
|
50
|
+
export interface ExactDecimalValue {
|
|
51
|
+
readonly coefficientTwosComplement: Uint8Array;
|
|
52
|
+
readonly scale: number;
|
|
53
|
+
readonly precision: number;
|
|
54
|
+
}
|
|
55
|
+
/** One exact currency value accepted by generated `money<CURRENCY>` fields. */
|
|
56
|
+
export interface ExactMoneyValue<Currency extends string = string> {
|
|
57
|
+
readonly currency: Currency;
|
|
58
|
+
readonly amount: ExactDecimalValue;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Constructs an exact fixed-point value from decimal text without using a
|
|
62
|
+
* JavaScript floating-point number.
|
|
63
|
+
*/
|
|
64
|
+
export declare function exactDecimal(value: string, precision: number, scale: number): ExactDecimalValue;
|
|
65
|
+
/** Constructs the exact precision-38, scale-2 value used by `money<CURRENCY>`. */
|
|
66
|
+
export declare function exactMoney<const Currency extends string>(currency: Currency, value: string): ExactMoneyValue<Currency>;
|
|
67
|
+
export type QueryConsistency = "admissionHead";
|
|
68
|
+
export interface QueryOptions {
|
|
69
|
+
readonly cursor?: string;
|
|
70
|
+
readonly readAfterCommit?: bigint;
|
|
71
|
+
readonly consistency?: QueryConsistency;
|
|
72
|
+
}
|
|
73
|
+
interface NamedQueryRequest<P, R> {
|
|
74
|
+
readonly driverOperation?: DriverOperation;
|
|
75
|
+
readonly contractLineage: string;
|
|
76
|
+
readonly contractVersion: number;
|
|
77
|
+
readonly contractBundleHash: string;
|
|
78
|
+
readonly moduleHash: string;
|
|
79
|
+
readonly queryName: string;
|
|
80
|
+
readonly planHash: string;
|
|
81
|
+
readonly parameters: P;
|
|
82
|
+
readonly parameterSchema: ApplicationValueSchema;
|
|
83
|
+
readonly resultSchemas: Readonly<Record<string, ApplicationValueSchema>>;
|
|
84
|
+
readonly compactDecoder?: (value: DriverCompactQueryResult) => R;
|
|
85
|
+
readonly packedDecoder?: (value: DriverPackedQueryResult) => R;
|
|
86
|
+
readonly decodeError: (value: unknown) => Error;
|
|
87
|
+
readonly resultType?: R;
|
|
88
|
+
}
|
|
89
|
+
interface CommandRequest<I, R> {
|
|
90
|
+
readonly driverOperation?: DriverOperation;
|
|
91
|
+
readonly contractLineage: string;
|
|
92
|
+
readonly contractVersion: number;
|
|
93
|
+
readonly commandName: string;
|
|
94
|
+
readonly planHash: string;
|
|
95
|
+
readonly input: I;
|
|
96
|
+
readonly idempotencyKey: string;
|
|
97
|
+
readonly inputSchema: ApplicationValueSchema;
|
|
98
|
+
readonly outcomeSchemas: Readonly<Record<string, ApplicationValueSchema>>;
|
|
99
|
+
readonly decodeError: (value: unknown) => Error;
|
|
100
|
+
readonly outcomeType?: R;
|
|
101
|
+
}
|
|
102
|
+
interface VectorInspectionRequest<P, R> {
|
|
103
|
+
readonly driverOperation?: DriverOperation;
|
|
104
|
+
readonly contractLineage: string;
|
|
105
|
+
readonly contractVersion: number;
|
|
106
|
+
readonly contractBundleHash: string;
|
|
107
|
+
readonly entity: string;
|
|
108
|
+
readonly field: string;
|
|
109
|
+
readonly inspectionKind: "staleness" | "model_versions";
|
|
110
|
+
readonly partition: P;
|
|
111
|
+
readonly partitionSchema: ApplicationValueSchema;
|
|
112
|
+
readonly limit: number;
|
|
113
|
+
readonly resultType?: R;
|
|
114
|
+
}
|
|
115
|
+
interface VectorInspectionOptions {
|
|
116
|
+
readonly cursor?: string;
|
|
117
|
+
}
|
|
118
|
+
interface TypedVectorInspectionResult<T> {
|
|
119
|
+
readonly value: T;
|
|
120
|
+
readonly applicationHead?: bigint;
|
|
121
|
+
readonly nextCursor?: string;
|
|
122
|
+
}
|
|
123
|
+
export interface QueryResponseIdentity {
|
|
124
|
+
readonly contractLineage: string;
|
|
125
|
+
readonly contractVersion: number;
|
|
126
|
+
readonly contractBundleHash: string;
|
|
127
|
+
readonly moduleHash: string;
|
|
128
|
+
readonly queryName: string;
|
|
129
|
+
readonly planHash: string;
|
|
130
|
+
}
|
|
131
|
+
export interface TypedQueryResult<T> {
|
|
132
|
+
readonly identity: QueryResponseIdentity;
|
|
133
|
+
readonly value: T;
|
|
134
|
+
readonly applicationHead: bigint;
|
|
135
|
+
readonly nextCursor?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface TypedCommandResult<T> {
|
|
138
|
+
readonly outcome: T;
|
|
139
|
+
readonly commitSequence?: bigint;
|
|
140
|
+
readonly contractVersion: number;
|
|
141
|
+
readonly planHash: string;
|
|
142
|
+
readonly replayed: boolean;
|
|
143
|
+
readonly outcomeUri?: string;
|
|
144
|
+
}
|
|
145
|
+
export interface CliApplicationTransportOptions {
|
|
146
|
+
readonly riffdbPath: string;
|
|
147
|
+
readonly endpoint: string;
|
|
148
|
+
readonly credentialFile: string;
|
|
149
|
+
}
|
|
150
|
+
export interface ReactiveConsumerRequest<P> {
|
|
151
|
+
readonly driverOperations?: Readonly<Record<string, DriverOperation>>;
|
|
152
|
+
readonly reactiveModuleHash: string;
|
|
153
|
+
readonly operationName: string;
|
|
154
|
+
readonly parameters: P;
|
|
155
|
+
readonly parameterSchema: ApplicationValueSchema;
|
|
156
|
+
readonly consumerName: string;
|
|
157
|
+
}
|
|
158
|
+
export interface ReactiveConsumerOptions {
|
|
159
|
+
readonly batchLimit?: number;
|
|
160
|
+
readonly inFlightLimit?: number;
|
|
161
|
+
readonly leaseSeconds?: number;
|
|
162
|
+
readonly maximumWaitMs?: number;
|
|
163
|
+
readonly signal?: AbortSignal;
|
|
164
|
+
}
|
|
165
|
+
export interface ReactiveEventDelivery<E> {
|
|
166
|
+
readonly eventId: string;
|
|
167
|
+
readonly event: E;
|
|
168
|
+
readonly attempt: number;
|
|
169
|
+
readonly leaseToken: string;
|
|
170
|
+
readonly expiresAt: string;
|
|
171
|
+
readonly historyIncarnation: bigint;
|
|
172
|
+
}
|
|
173
|
+
export interface ReactiveConsumerBatch<E> {
|
|
174
|
+
readonly events: ReadonlyArray<ReactiveEventDelivery<E>>;
|
|
175
|
+
readonly waitTimedOut: boolean;
|
|
176
|
+
readonly status: ReactiveConsumerStatus;
|
|
177
|
+
}
|
|
178
|
+
export interface ContextualHydration {
|
|
179
|
+
readonly name: string;
|
|
180
|
+
readonly outcome: string;
|
|
181
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
182
|
+
}
|
|
183
|
+
export interface ContextualReaction {
|
|
184
|
+
readonly name: string;
|
|
185
|
+
readonly commandName: string;
|
|
186
|
+
readonly commandId: number;
|
|
187
|
+
readonly causationToken: string;
|
|
188
|
+
}
|
|
189
|
+
export interface ContextualWorkItem<E> {
|
|
190
|
+
readonly delivery: ReactiveEventDelivery<E>;
|
|
191
|
+
readonly contextHead: bigint;
|
|
192
|
+
readonly hydrations: ReadonlyArray<ContextualHydration>;
|
|
193
|
+
readonly availableReactions: ReadonlyArray<ContextualReaction>;
|
|
194
|
+
}
|
|
195
|
+
export interface ContextualBatch<E> {
|
|
196
|
+
readonly items: ReadonlyArray<ContextualWorkItem<E>>;
|
|
197
|
+
readonly waitTimedOut: boolean;
|
|
198
|
+
readonly status: ReactiveConsumerStatus;
|
|
199
|
+
}
|
|
200
|
+
export interface ReactiveConsumerStatus {
|
|
201
|
+
readonly revision: bigint;
|
|
202
|
+
readonly checkpoint: string;
|
|
203
|
+
readonly historyIncarnation: bigint;
|
|
204
|
+
readonly liveLeases: number;
|
|
205
|
+
readonly retries: number;
|
|
206
|
+
readonly deadLetters: number;
|
|
207
|
+
}
|
|
208
|
+
export type ReactiveEventMutationResult = "applied" | "state_changed" | "not_found" | "outstanding_lease" | "stale_lease" | "lease_expired";
|
|
209
|
+
export type LiveQueryPatchOperation = {
|
|
210
|
+
readonly type: "insert";
|
|
211
|
+
readonly index: number;
|
|
212
|
+
readonly record: Readonly<Record<string, unknown>>;
|
|
213
|
+
} | {
|
|
214
|
+
readonly type: "remove";
|
|
215
|
+
readonly index: number;
|
|
216
|
+
readonly key: Readonly<Record<string, unknown>>;
|
|
217
|
+
} | {
|
|
218
|
+
readonly type: "replace";
|
|
219
|
+
readonly index: number;
|
|
220
|
+
readonly record: Readonly<Record<string, unknown>>;
|
|
221
|
+
} | {
|
|
222
|
+
readonly type: "move";
|
|
223
|
+
readonly from: number;
|
|
224
|
+
readonly to: number;
|
|
225
|
+
readonly key: Readonly<Record<string, unknown>>;
|
|
226
|
+
};
|
|
227
|
+
export type LiveQueryUpdate<T> = {
|
|
228
|
+
readonly type: "snapshot";
|
|
229
|
+
readonly value: T;
|
|
230
|
+
readonly cursor: string;
|
|
231
|
+
readonly applicationHead: bigint;
|
|
232
|
+
readonly historyIncarnation: bigint;
|
|
233
|
+
} | {
|
|
234
|
+
readonly type: "patch";
|
|
235
|
+
readonly resultField: string;
|
|
236
|
+
readonly operations: ReadonlyArray<LiveQueryPatchOperation>;
|
|
237
|
+
readonly cursor: string;
|
|
238
|
+
readonly applicationHead: bigint;
|
|
239
|
+
readonly historyIncarnation: bigint;
|
|
240
|
+
} | {
|
|
241
|
+
readonly type: "reset";
|
|
242
|
+
readonly reason: string;
|
|
243
|
+
readonly value: T;
|
|
244
|
+
readonly cursor: string;
|
|
245
|
+
readonly applicationHead: bigint;
|
|
246
|
+
readonly historyIncarnation: bigint;
|
|
247
|
+
} | {
|
|
248
|
+
readonly type: "checkpoint";
|
|
249
|
+
readonly cursor: string;
|
|
250
|
+
readonly applicationHead: bigint;
|
|
251
|
+
readonly historyIncarnation: bigint;
|
|
252
|
+
} | {
|
|
253
|
+
readonly type: "terminal";
|
|
254
|
+
readonly reason: string;
|
|
255
|
+
readonly lastApplicationHead?: bigint;
|
|
256
|
+
readonly historyIncarnation?: bigint;
|
|
257
|
+
};
|
|
258
|
+
export declare class CliApplicationTransport {
|
|
259
|
+
private readonly options;
|
|
260
|
+
constructor(options: CliApplicationTransportOptions);
|
|
261
|
+
executeNamedQuery<P, R>(request: NamedQueryRequest<P, R>, options?: QueryOptions): Promise<TypedQueryResult<R>>;
|
|
262
|
+
executeCommand<I, R>(request: CommandRequest<I, R>, attemptBudget: number): Promise<TypedCommandResult<R>>;
|
|
263
|
+
executeVectorInspection<P, R>(request: VectorInspectionRequest<P, R>, options?: VectorInspectionOptions): Promise<TypedVectorInspectionResult<R>>;
|
|
264
|
+
consumeEventStream<P, E>(request: ReactiveConsumerRequest<P>, options?: ReactiveConsumerOptions): AsyncIterable<ReactiveConsumerBatch<E>>;
|
|
265
|
+
acknowledgeEvent<P>(request: ReactiveConsumerRequest<P>, delivery: ReactiveEventDelivery<unknown>): Promise<ReactiveEventMutationResult>;
|
|
266
|
+
negativeAcknowledgeEvent<P>(request: ReactiveConsumerRequest<P>, delivery: ReactiveEventDelivery<unknown>, retryDelayMs?: number): Promise<ReactiveEventMutationResult>;
|
|
267
|
+
seekEventConsumer<P>(request: ReactiveConsumerRequest<P>, checkpoint: string): Promise<ReactiveEventMutationResult>;
|
|
268
|
+
eventConsumerStatus<P>(request: ReactiveConsumerRequest<P>): Promise<ReactiveConsumerStatus | undefined>;
|
|
269
|
+
consumeContextualSubscription<P, E>(request: ReactiveConsumerRequest<P>, maximumWaitMs?: number): Promise<ContextualBatch<E>>;
|
|
270
|
+
acknowledgeContextualItem<P>(request: ReactiveConsumerRequest<P>, item: ContextualWorkItem<unknown>): Promise<ReactiveEventMutationResult>;
|
|
271
|
+
negativeAcknowledgeContextualItem<P>(request: ReactiveConsumerRequest<P>, item: ContextualWorkItem<unknown>, retryDelayMs?: number): Promise<ReactiveEventMutationResult>;
|
|
272
|
+
contextualSubscriptionStatus<P>(request: ReactiveConsumerRequest<P>): Promise<ReactiveConsumerStatus | undefined>;
|
|
273
|
+
executeContextualReaction<P, I, R>(request: ReactiveConsumerRequest<P>, reaction: ContextualReaction, command: CommandRequest<I, R>): Promise<TypedCommandResult<R>>;
|
|
274
|
+
watchNamedQuery<P, T>(request: {
|
|
275
|
+
readonly reactiveModuleHash: string;
|
|
276
|
+
readonly operationName: string;
|
|
277
|
+
readonly parameters: P;
|
|
278
|
+
readonly parameterSchema: ApplicationValueSchema;
|
|
279
|
+
readonly cursor?: string;
|
|
280
|
+
}): AsyncIterable<LiveQueryUpdate<T>>;
|
|
281
|
+
private mutateEventLease;
|
|
282
|
+
private mutateContextualItem;
|
|
283
|
+
private reactiveArguments;
|
|
284
|
+
private baseArguments;
|
|
285
|
+
private invoke;
|
|
286
|
+
private invokeArguments;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Generated-facade adapter for one retained Rust driver-host session.
|
|
290
|
+
*
|
|
291
|
+
* The adapter owns only checked value assembly and result decoding. Remote
|
|
292
|
+
* trust, credentials, retries, pooling, and uncertainty remain in Rust.
|
|
293
|
+
*/
|
|
294
|
+
export declare class DriverGeneratedApplicationTransport {
|
|
295
|
+
private readonly driver;
|
|
296
|
+
constructor(driver: DriverApplicationTransport);
|
|
297
|
+
/** Returns the bound tenant identifier when this session is tenant-scoped. */
|
|
298
|
+
get tenant(): string | undefined;
|
|
299
|
+
executeNamedQuery<P, R>(request: NamedQueryRequest<P, R>, options?: QueryOptions): Promise<TypedQueryResult<R>>;
|
|
300
|
+
executeCommand<I, R>(request: CommandRequest<I, R>, attemptBudget: number): Promise<TypedCommandResult<R>>;
|
|
301
|
+
executeVectorInspection<P, R>(request: VectorInspectionRequest<P, R>, options?: VectorInspectionOptions): Promise<TypedVectorInspectionResult<R>>;
|
|
302
|
+
executeCommandBatch<I, R>(request: CommandRequest<I, R>, inputs: ReadonlyArray<I>, concurrency: number, checkpoint: number, attemptBudget: number): Promise<{
|
|
303
|
+
readonly items: ReadonlyArray<{
|
|
304
|
+
readonly index: number;
|
|
305
|
+
readonly result?: TypedCommandResult<R>;
|
|
306
|
+
readonly error?: DriverApplicationError;
|
|
307
|
+
}>;
|
|
308
|
+
readonly checkpoint: number;
|
|
309
|
+
}>;
|
|
310
|
+
consumeEventStream<P, E>(request: ReactiveConsumerRequest<P>, options?: ReactiveConsumerOptions): AsyncIterable<ReactiveConsumerBatch<E>>;
|
|
311
|
+
acknowledgeEvent<P>(request: ReactiveConsumerRequest<P>, delivery: ReactiveEventDelivery<unknown>): Promise<ReactiveEventMutationResult>;
|
|
312
|
+
negativeAcknowledgeEvent<P>(request: ReactiveConsumerRequest<P>, delivery: ReactiveEventDelivery<unknown>, retryDelayMs?: number): Promise<ReactiveEventMutationResult>;
|
|
313
|
+
seekEventConsumer<P>(request: ReactiveConsumerRequest<P>, checkpoint: string): Promise<ReactiveEventMutationResult>;
|
|
314
|
+
eventConsumerStatus<P>(request: ReactiveConsumerRequest<P>): Promise<ReactiveConsumerStatus | undefined>;
|
|
315
|
+
consumeContextualSubscription<P, E>(request: ReactiveConsumerRequest<P>, maximumWaitMs?: number, signal?: AbortSignal): Promise<ContextualBatch<E>>;
|
|
316
|
+
acknowledgeContextualItem<P>(request: ReactiveConsumerRequest<P>, item: ContextualWorkItem<unknown>): Promise<ReactiveEventMutationResult>;
|
|
317
|
+
negativeAcknowledgeContextualItem<P>(request: ReactiveConsumerRequest<P>, item: ContextualWorkItem<unknown>, retryDelayMs?: number): Promise<ReactiveEventMutationResult>;
|
|
318
|
+
contextualSubscriptionStatus<P>(request: ReactiveConsumerRequest<P>): Promise<ReactiveConsumerStatus | undefined>;
|
|
319
|
+
executeContextualReaction<P, I, R>(request: ReactiveConsumerRequest<P>, reaction: ContextualReaction, command: CommandRequest<I, R>): Promise<TypedCommandResult<R>>;
|
|
320
|
+
watchNamedQuery<P, T>(request: {
|
|
321
|
+
readonly driverOperations?: Readonly<Record<string, DriverOperation>>;
|
|
322
|
+
readonly reactiveModuleHash: string;
|
|
323
|
+
readonly operationName: string;
|
|
324
|
+
readonly parameters: P;
|
|
325
|
+
readonly parameterSchema: ApplicationValueSchema;
|
|
326
|
+
readonly cursor?: string;
|
|
327
|
+
readonly signal?: AbortSignal;
|
|
328
|
+
}): AsyncIterable<LiveQueryUpdate<T>>;
|
|
329
|
+
private mutateDriverLease;
|
|
330
|
+
}
|
|
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";
|