@arkiv-network/sdk 0.6.8-dev.1 → 0.6.8-dev.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/README.md +52 -16
- package/dist/chains/index.d.cts +25 -25
- package/dist/{query-CO6f35AE.d.cts → entity-B3qWIdug.d.cts} +26 -26
- package/dist/entity-B3qWIdug.d.cts.map +1 -0
- package/dist/{query-BhdmAzYg.d.ts → entity-BOra9GVW.d.ts} +26 -26
- package/dist/entity-BOra9GVW.d.ts.map +1 -0
- package/dist/{queryBuilder-zTsKXctT.d.cts → index-Dushe05u.d.cts} +202 -74
- package/dist/index-Dushe05u.d.cts.map +1 -0
- package/dist/{queryBuilder-BvoQXa_u.d.ts → index-t3wvdqvC.d.ts} +202 -74
- package/dist/index-t3wvdqvC.d.ts.map +1 -0
- package/dist/index.cjs +3 -8
- package/dist/index.d.cts +65 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +65 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/query/index.cjs +5 -2
- package/dist/query/index.d.cts +3 -3
- package/dist/query/index.d.ts +3 -3
- package/dist/query/index.js +2 -2
- package/dist/{queryBuilder-DM-YO1Y7.cjs → queryBuilder-BlMPfusd.cjs} +204 -70
- package/dist/{queryBuilder-DonAg1aq.js → queryBuilder-D7iYS0vU.js} +188 -72
- package/dist/queryBuilder-D7iYS0vU.js.map +1 -0
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.cjs +1 -8
- package/dist/utils/index.d.cts +0 -1
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +11 -15
- package/src/actions/public/buildQuery.ts +4 -0
- package/src/clients/createPublicClient.test.ts +2 -0
- package/src/clients/decorators/arkivPublic.ts +67 -1
- package/src/index.ts +0 -3
- package/src/query/engine.ts +22 -13
- package/src/query/index.ts +1 -0
- package/src/query/queryBuilder.ts +189 -94
- package/src/query/queryResult.ts +13 -7
- package/src/query/selectQueryBuilder.test.ts +210 -0
- package/src/query/selection.test.ts +120 -0
- package/src/query/selection.ts +116 -0
- package/src/utils/index.ts +0 -1
- package/dist/accounts/index.cjs +0 -9
- package/dist/accounts/index.d.cts +0 -1
- package/dist/accounts/index.d.ts +0 -1
- package/dist/accounts/index.js +0 -1
- package/dist/query-BhdmAzYg.d.ts.map +0 -1
- package/dist/query-CO6f35AE.d.cts.map +0 -1
- package/dist/queryBuilder-BvoQXa_u.d.ts.map +0 -1
- package/dist/queryBuilder-DonAg1aq.js.map +0 -1
- package/dist/queryBuilder-zTsKXctT.d.cts.map +0 -1
- package/src/accounts/index.ts +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as ArkivClient,
|
|
1
|
+
import { A as RpcIncludeData, D as ArkivClient, j as RpcOrderByAttribute, k as RpcEntity, t as Entity } from "./entity-B3qWIdug.cjs";
|
|
2
2
|
import { Hex } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/query/predicate.d.ts
|
|
@@ -114,20 +114,79 @@ declare function lte(key: string, value: string | number): Predicate;
|
|
|
114
114
|
declare function not(key: string): Predicate;
|
|
115
115
|
//#endregion
|
|
116
116
|
//#region src/query/queryResult.d.ts
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
/**
|
|
118
|
+
* The result of a query. Holds the fetched entities and supports cursor-based pagination.
|
|
119
|
+
*
|
|
120
|
+
* @typeParam TEntity - The shape of each entity, inferred from the query builder
|
|
121
|
+
* (a full {@link Entity}, or a projected object inferred from a `select()` selection).
|
|
122
|
+
*/
|
|
123
|
+
declare class QueryResult<TEntity = Entity> {
|
|
124
|
+
entities: TEntity[];
|
|
119
125
|
private _endOfIteration;
|
|
120
126
|
private _cursor;
|
|
121
127
|
private _limit;
|
|
122
128
|
private _validAtBlock;
|
|
123
129
|
private _queryBuilder;
|
|
124
|
-
get queryBuilder():
|
|
130
|
+
get queryBuilder(): BaseQueryBuilder<TEntity>;
|
|
125
131
|
get cursor(): string | undefined;
|
|
126
|
-
constructor(entities:
|
|
132
|
+
constructor(entities: TEntity[], queryBuilder: BaseQueryBuilder<TEntity>, cursor: string | undefined, limit: number | undefined, validAtBlock: bigint | undefined);
|
|
127
133
|
next(): Promise<void>;
|
|
128
134
|
hasNextPage(): boolean;
|
|
129
135
|
}
|
|
130
136
|
//#endregion
|
|
137
|
+
//#region src/query/selection.d.ts
|
|
138
|
+
/** The entity fields that can be selected. These match the fields of {@link Entity} one-to-one. */
|
|
139
|
+
type DataKey = "key" | "contentType" | "owner" | "creator" | "expiresAtBlock" | "createdAtBlock" | "lastModifiedAtBlock" | "transactionIndexInBlock" | "operationIndexInTransaction" | "attributes" | "payload";
|
|
140
|
+
/**
|
|
141
|
+
* The parts of an entity that can be selected. Every field is opt-in (including the `key`) and maps
|
|
142
|
+
* directly to a field of the returned {@link Entity} — the selection is flat.
|
|
143
|
+
*/
|
|
144
|
+
type SelectionFields = { [K in DataKey]?: boolean };
|
|
145
|
+
/**
|
|
146
|
+
* Requires at least one property of `T` to be present.
|
|
147
|
+
* `{}` is not assignable, which is how `select({})` is rejected at compile time.
|
|
148
|
+
*/
|
|
149
|
+
type AtLeastOne<T, K$1 extends keyof T = keyof T> = { [P in K$1]: Required<Pick<T, P>> & Partial<Omit<T, P>> }[K$1];
|
|
150
|
+
/**
|
|
151
|
+
* A non-empty entity selection — the object form accepted by `select()`. At least one field must be
|
|
152
|
+
* selected.
|
|
153
|
+
*/
|
|
154
|
+
type EntitySelection = AtLeastOne<SelectionFields>;
|
|
155
|
+
/** Argument accepted by `select()` — a non-empty {@link EntitySelection}, or `"*"` for everything. */
|
|
156
|
+
type SelectArg = EntitySelection | "*";
|
|
157
|
+
/**
|
|
158
|
+
* The result of a selection `S`: an {@link Entity} narrowed to exactly the selected fields (each
|
|
159
|
+
* non-`undefined`). The shape is flat and backwards compatible — e.g. `select({ owner: true })`
|
|
160
|
+
* yields `{ owner: Hex }` accessed as `entity.owner`. Accessing an unselected field is a compile
|
|
161
|
+
* error.
|
|
162
|
+
*
|
|
163
|
+
* The `toText()` / `toJson()` helpers operate on the payload, so they are only present when
|
|
164
|
+
* `payload` was selected — calling them otherwise would always throw.
|
|
165
|
+
*/
|
|
166
|
+
type ProjectedEntity<S> = { readonly [K in keyof S as S[K] extends true ? K : never]: K extends keyof Entity ? NonNullable<Entity[K]> : never } & (S extends {
|
|
167
|
+
payload: true;
|
|
168
|
+
} ? Pick<Entity, "toText" | "toJson"> : unknown);
|
|
169
|
+
/** A selection of every field, used to type the result of `select()` / `select("*")`. */
|
|
170
|
+
type AllSelected = { [K in DataKey]: true };
|
|
171
|
+
/** The projected entity type when everything is selected — every field, plus the methods. */
|
|
172
|
+
type FullEntity = ProjectedEntity<AllSelected>;
|
|
173
|
+
/**
|
|
174
|
+
* Converts a {@link SelectArg} into the {@link RpcIncludeData} understood by the query engine.
|
|
175
|
+
* Every field is opt-in — anything not explicitly selected defaults to `false`, including the key.
|
|
176
|
+
* `undefined` or `"*"` selects everything.
|
|
177
|
+
*
|
|
178
|
+
* @param selection - The selection to convert
|
|
179
|
+
* @returns The fully-resolved include-data object for the RPC query
|
|
180
|
+
* @throws If an empty selection object is provided
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* selectionToIncludeData() // everything
|
|
184
|
+
* selectionToIncludeData("*") // everything
|
|
185
|
+
* selectionToIncludeData({ key: true }) // only the key
|
|
186
|
+
* selectionToIncludeData({ owner: true }) // only the owner
|
|
187
|
+
*/
|
|
188
|
+
declare function selectionToIncludeData(selection?: SelectArg): RpcIncludeData;
|
|
189
|
+
//#endregion
|
|
131
190
|
//#region src/query/queryBuilder.d.ts
|
|
132
191
|
type OrderByAttribute = {
|
|
133
192
|
name: string;
|
|
@@ -155,41 +214,52 @@ declare function asc(attributeName: string, attributeType: "string" | "number"):
|
|
|
155
214
|
*/
|
|
156
215
|
declare function desc(attributeName: string, attributeType: "string" | "number"): OrderByAttribute;
|
|
157
216
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* @param client - The Arkiv client
|
|
161
|
-
* @returns The QueryBuilder instance {@link QueryBuilder}
|
|
217
|
+
* Data-selection parameters forwarded to the query engine on each fetch.
|
|
218
|
+
* Subclasses of {@link BaseQueryBuilder} decide which parts of an entity are fetched.
|
|
162
219
|
*/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
220
|
+
type SelectionParams = {
|
|
221
|
+
withAttributes?: boolean | undefined;
|
|
222
|
+
withMetadata?: boolean | undefined;
|
|
223
|
+
withPayload?: boolean | undefined;
|
|
224
|
+
includeData?: RpcIncludeData | undefined;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* BaseQueryBuilder holds the query-building logic shared by every query builder
|
|
228
|
+
* (filtering, ordering, pagination, execution). It follows the Builder pattern,
|
|
229
|
+
* allowing methods to be chained. Subclasses decide how data selection is expressed
|
|
230
|
+
* by implementing the protected `selectionParams` method.
|
|
231
|
+
*
|
|
232
|
+
* Use {@link SelectQueryBuilder} via `client.select()` to build and execute queries.
|
|
233
|
+
*
|
|
234
|
+
* @typeParam TEntity - The shape of each entity produced by {@link BaseQueryBuilder.fetch}.
|
|
235
|
+
*/
|
|
236
|
+
declare abstract class BaseQueryBuilder<TEntity> {
|
|
237
|
+
protected _client: ArkivClient;
|
|
238
|
+
protected _ownedBy: Hex | undefined;
|
|
239
|
+
protected _createdBy: Hex | undefined;
|
|
240
|
+
protected _orderBy: RpcOrderByAttribute[] | undefined;
|
|
241
|
+
protected _validAtBlock: bigint | undefined;
|
|
242
|
+
protected _limit: number | undefined;
|
|
243
|
+
protected _cursor: string | undefined;
|
|
244
|
+
protected _predicates: Predicate[];
|
|
175
245
|
constructor(client: ArkivClient);
|
|
176
246
|
/**
|
|
177
247
|
* Sets the ownedBy filter
|
|
178
248
|
* @param ownedBy - The address of the owner
|
|
179
|
-
* @returns The
|
|
249
|
+
* @returns The query builder instance
|
|
180
250
|
*
|
|
181
251
|
* @example
|
|
182
|
-
* const builder =
|
|
252
|
+
* const builder = client.select()
|
|
183
253
|
* builder.ownedBy("0x1234567890123456789012345678901234567890")
|
|
184
254
|
*/
|
|
185
255
|
ownedBy(ownedBy: Hex): this;
|
|
186
256
|
/**
|
|
187
257
|
* Sets the createdBy filter
|
|
188
258
|
* @param createdBy - The address of the creator
|
|
189
|
-
* @returns The
|
|
259
|
+
* @returns The query builder instance
|
|
190
260
|
*
|
|
191
261
|
* @example
|
|
192
|
-
* const builder =
|
|
262
|
+
* const builder = client.select()
|
|
193
263
|
* builder.createdBy("0x1234567890123456789012345678901234567890")
|
|
194
264
|
*/
|
|
195
265
|
createdBy(createdBy: Hex): this;
|
|
@@ -201,10 +271,10 @@ declare class QueryBuilder {
|
|
|
201
271
|
* @param attributeName - The name of the attribute to order by
|
|
202
272
|
* @param attributeType - The type of the attribute to order by (string or number)
|
|
203
273
|
* @param order - The order to set the order by (asc or desc)
|
|
204
|
-
* @returns The
|
|
274
|
+
* @returns The query builder instance
|
|
205
275
|
*
|
|
206
276
|
* @example
|
|
207
|
-
* const builder = client.
|
|
277
|
+
* const builder = client.select()
|
|
208
278
|
* builder.orderBy("name", "string", "desc")
|
|
209
279
|
* builder.orderBy(asc("name", "string"))
|
|
210
280
|
* builder.orderBy(desc("name", "string"))
|
|
@@ -215,72 +285,42 @@ declare class QueryBuilder {
|
|
|
215
285
|
* This method takes the OrderByAttribute object as an argument and is mainly
|
|
216
286
|
* used to use the helper functions asc() and desc() to create the OrderByAttribute instances.
|
|
217
287
|
* @param orderByAttribute - The OrderByAttribute instance to set
|
|
218
|
-
* @returns The
|
|
288
|
+
* @returns The query builder instance
|
|
219
289
|
*
|
|
220
290
|
* @example
|
|
221
|
-
* const builder =
|
|
291
|
+
* const builder = client.select()
|
|
222
292
|
* builder.orderBy(asc("name", "string"))
|
|
223
293
|
* builder.orderBy(desc("name", "string"))
|
|
224
294
|
*/
|
|
225
295
|
orderBy(orderByAttribute: OrderByAttribute): this;
|
|
226
|
-
/**
|
|
227
|
-
* Sets the withAttributes flag which will return the attributes for the entities if true
|
|
228
|
-
* @param withAttributes - The boolean value to set
|
|
229
|
-
* @returns The QueryBuilder instance
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* const builder = new QueryBuilder(client)
|
|
233
|
-
* builder.withAttributes(true)
|
|
234
|
-
*/
|
|
235
|
-
withAttributes(withAttributes?: boolean): this;
|
|
236
|
-
/**
|
|
237
|
-
* Sets the withMetadata flag which will return the metadata (like owner, expiredAt, etc.) for the entities if true
|
|
238
|
-
* @param withMetadata - The boolean value to set
|
|
239
|
-
* @returns The QueryBuilder instance
|
|
240
|
-
*
|
|
241
|
-
* @example
|
|
242
|
-
* const builder = new QueryBuilder(client)
|
|
243
|
-
* builder.withMetadata(true)
|
|
244
|
-
*/
|
|
245
|
-
withMetadata(withMetadata?: boolean): this;
|
|
246
|
-
/**
|
|
247
|
-
* Sets the withPayload flag which will return the payload for the entities if true
|
|
248
|
-
* @param withPayload - The boolean value to set
|
|
249
|
-
* @returns The QueryBuilder instance
|
|
250
|
-
*
|
|
251
|
-
* @example
|
|
252
|
-
* const builder = new QueryBuilder(client)
|
|
253
|
-
* builder.withPayload(true)
|
|
254
|
-
*/
|
|
255
|
-
withPayload(withPayload?: boolean): this;
|
|
256
296
|
/**
|
|
257
297
|
* Sets the limit for the query
|
|
258
298
|
* @param limit - The number of entities to return
|
|
259
|
-
* @returns The
|
|
299
|
+
* @returns The query builder instance
|
|
260
300
|
*
|
|
261
301
|
* @example
|
|
262
|
-
* const builder =
|
|
302
|
+
* const builder = client.select()
|
|
263
303
|
* builder.limit(10)
|
|
264
304
|
*/
|
|
265
305
|
limit(limit: number): this;
|
|
266
306
|
/**
|
|
267
307
|
* Sets the cursor for the query - it is advances setting which rather shouldn't be used manually but it is provided from query result if limit is used (pagination).
|
|
268
308
|
* @param cursor - The cursor to set which tells to RPC Query server where to start or continue the query.
|
|
269
|
-
* @returns The
|
|
309
|
+
* @returns The query builder instance
|
|
270
310
|
*
|
|
271
311
|
* @example
|
|
272
|
-
* const builder =
|
|
273
|
-
* builder.
|
|
312
|
+
* const builder = client.select()
|
|
313
|
+
* builder.cursor("0xABC123")
|
|
274
314
|
*/
|
|
275
315
|
cursor(cursor: string): this;
|
|
276
316
|
/**
|
|
277
317
|
* Sets the validAtBlock for the query which tells at which block height the state we are intested.
|
|
278
318
|
* If not set, the latest block is used.
|
|
279
319
|
* @param validAtBlock - The block number to set
|
|
280
|
-
* @returns The
|
|
320
|
+
* @returns The query builder instance
|
|
281
321
|
*
|
|
282
322
|
* @example
|
|
283
|
-
* const builder =
|
|
323
|
+
* const builder = client.select()
|
|
284
324
|
* builder.validAtBlock(10000)
|
|
285
325
|
*/
|
|
286
326
|
validAtBlock(validAtBlock: bigint): this;
|
|
@@ -288,10 +328,10 @@ declare class QueryBuilder {
|
|
|
288
328
|
* Sets the predicates for the query limiting the results. It can be a single predicate or an array of predicates combined with 'and'.
|
|
289
329
|
* Predicates can be nested using 'or' and 'and' predicates.
|
|
290
330
|
* @param predicates - The predicates to set
|
|
291
|
-
* @returns The
|
|
331
|
+
* @returns The query builder instance
|
|
292
332
|
*
|
|
293
333
|
* @example
|
|
294
|
-
* const builder =
|
|
334
|
+
* const builder = client.select()
|
|
295
335
|
* builder.where(eq("name", "John"))
|
|
296
336
|
* builder.where([eq("name", "John"), eq("age", 30)])
|
|
297
337
|
* builder.where([eq("name", "John"), or([eq("age", 30), eq("age", 31)])])
|
|
@@ -302,27 +342,115 @@ declare class QueryBuilder {
|
|
|
302
342
|
*/
|
|
303
343
|
where(predicates: Predicate[] | Predicate): this;
|
|
304
344
|
/**
|
|
305
|
-
*
|
|
345
|
+
* Returns the data-selection parameters forwarded to the query engine.
|
|
346
|
+
* Subclasses decide which parts of an entity are fetched.
|
|
347
|
+
*/
|
|
348
|
+
protected abstract selectionParams(): SelectionParams;
|
|
349
|
+
/**
|
|
350
|
+
* Builds a single result entity from a raw RPC entity. Subclasses decide the produced shape
|
|
351
|
+
* (a full {@link Entity}, or a projected object inferred from the selection).
|
|
352
|
+
*/
|
|
353
|
+
protected abstract projectEntity(rpcEntity: RpcEntity): TEntity | Promise<TEntity>;
|
|
354
|
+
/**
|
|
355
|
+
* Fetches the entities from the query.
|
|
306
356
|
* It will return a QueryResult instance which can be used to fetch the next and previous pages.
|
|
307
357
|
* @returns The QueryResult instance {@link QueryResult}
|
|
308
358
|
*
|
|
309
359
|
* @example
|
|
310
|
-
* const builder =
|
|
360
|
+
* const builder = client.select()
|
|
311
361
|
* const result = await builder.where(eq("name", "John")).fetch()
|
|
312
362
|
* // result = { entities: [Entity, Entity, Entity], next: async () => QueryResult, previous: async () => QueryResult }
|
|
313
363
|
*/
|
|
314
|
-
fetch(): Promise<QueryResult
|
|
364
|
+
fetch(): Promise<QueryResult<TEntity>>;
|
|
315
365
|
/**
|
|
316
366
|
* Counts the entities from the query.
|
|
317
367
|
* @returns The number of entities
|
|
318
368
|
*
|
|
319
369
|
* @example
|
|
320
|
-
* const builder =
|
|
370
|
+
* const builder = client.select()
|
|
321
371
|
* const result = await builder.where(eq("name", "John")).count()
|
|
322
372
|
* // result = 10
|
|
323
373
|
*/
|
|
324
374
|
count(): Promise<number>;
|
|
325
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* QueryBuilder is a helper class to build queries to the Arkiv DBChains.
|
|
378
|
+
* It can be used to fetch entities from the Arkiv DBChains. It follows the Builder pattern allowing chaining of methods.
|
|
379
|
+
*
|
|
380
|
+
* By default the result includes only the entity `key`. Additional data is opt-in through
|
|
381
|
+
* `withAttributes()`, `withMetadata()` and `withPayload()`.
|
|
382
|
+
*
|
|
383
|
+
* @deprecated Use {@link SelectQueryBuilder} via `client.select()` instead. Declaring the
|
|
384
|
+
* selection up front avoids the common mistake of forgetting to opt in to data and getting back
|
|
385
|
+
* entities with only their `key` populated. This class remains for backwards compatibility and
|
|
386
|
+
* will be removed in a future release.
|
|
387
|
+
*
|
|
388
|
+
* @param client - The Arkiv client
|
|
389
|
+
* @returns The QueryBuilder instance {@link QueryBuilder}
|
|
390
|
+
*/
|
|
391
|
+
declare class QueryBuilder extends BaseQueryBuilder<Entity> {
|
|
392
|
+
private _withAttributes;
|
|
393
|
+
private _withMetadata;
|
|
394
|
+
private _withPayload;
|
|
395
|
+
/**
|
|
396
|
+
* Sets the withAttributes flag which will return the attributes for the entities if true
|
|
397
|
+
* @param withAttributes - The boolean value to set
|
|
398
|
+
* @returns The QueryBuilder instance
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* const builder = client.buildQuery()
|
|
402
|
+
* builder.withAttributes(true)
|
|
403
|
+
*/
|
|
404
|
+
withAttributes(withAttributes?: boolean): this;
|
|
405
|
+
/**
|
|
406
|
+
* Sets the withMetadata flag which will return the metadata (like owner, expiredAt, etc.) for the entities if true
|
|
407
|
+
* @param withMetadata - The boolean value to set
|
|
408
|
+
* @returns The QueryBuilder instance
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* const builder = client.buildQuery()
|
|
412
|
+
* builder.withMetadata(true)
|
|
413
|
+
*/
|
|
414
|
+
withMetadata(withMetadata?: boolean): this;
|
|
415
|
+
/**
|
|
416
|
+
* Sets the withPayload flag which will return the payload for the entities if true
|
|
417
|
+
* @param withPayload - The boolean value to set
|
|
418
|
+
* @returns The QueryBuilder instance
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* const builder = client.buildQuery()
|
|
422
|
+
* builder.withPayload(true)
|
|
423
|
+
*/
|
|
424
|
+
withPayload(withPayload?: boolean): this;
|
|
425
|
+
protected selectionParams(): SelectionParams;
|
|
426
|
+
protected projectEntity(rpcEntity: RpcEntity): Promise<Entity>;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* SelectQueryBuilder is the recommended query builder. It requires the selection to be declared
|
|
430
|
+
* up front, so results always contain exactly the data you asked for — and the type of each
|
|
431
|
+
* returned entity is narrowed to exactly the selected fields.
|
|
432
|
+
*
|
|
433
|
+
* The selection is fixed at construction time and is flat — each field maps to an entity field.
|
|
434
|
+
* Create one via `client.select(...)` rather than constructing it directly, so the result type is
|
|
435
|
+
* inferred from the selection.
|
|
436
|
+
*
|
|
437
|
+
* @typeParam TEntity - The projected entity shape, inferred from the selection by `client.select()`.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* // everything
|
|
441
|
+
* await client.select().where(eq("name", "John")).fetch()
|
|
442
|
+
* await client.select("*").where(eq("name", "John")).fetch()
|
|
443
|
+
* // specific fields
|
|
444
|
+
* await client.select({ owner: true, attributes: true }).fetch()
|
|
445
|
+
* // a single field — result is typed (flat) { owner: Hex }
|
|
446
|
+
* await client.select({ owner: true }).fetch()
|
|
447
|
+
*/
|
|
448
|
+
declare class SelectQueryBuilder<TEntity> extends BaseQueryBuilder<TEntity> {
|
|
449
|
+
private _includeData;
|
|
450
|
+
constructor(client: ArkivClient, selection?: SelectArg);
|
|
451
|
+
protected selectionParams(): SelectionParams;
|
|
452
|
+
protected projectEntity(rpcEntity: RpcEntity): Promise<TEntity>;
|
|
453
|
+
}
|
|
326
454
|
//#endregion
|
|
327
|
-
export { or as _,
|
|
328
|
-
//# sourceMappingURL=
|
|
455
|
+
export { neq as C, lte as S, or as T, and as _, asc as a, gte as b, FullEntity as c, SelectionFields as d, selectionToIncludeData as f, PredicateType as g, PredicateContainerType as h, SelectQueryBuilder as i, ProjectedEntity as l, Predicate as m, OrderByAttribute as n, desc as o, QueryResult as p, QueryBuilder as r, EntitySelection as s, BaseQueryBuilder as t, SelectArg as u, eq as v, not as w, lt as x, gt as y };
|
|
456
|
+
//# sourceMappingURL=index-Dushe05u.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Dushe05u.d.cts","names":[],"sources":["../src/query/predicate.ts","../src/query/queryResult.ts","../src/query/selection.ts","../src/query/queryBuilder.ts"],"sourcesContent":[],"mappings":";;;;KAAY,aAAA;KACA,sBAAA;KAEA,SAAA;QAEA;EALA,GAAA,EAAA,MAAA;EACA,KAAA,EAAA,MAAA,GAAA,MAAA;AAEZ,CAAA,GAAY;EAEA,IAAA,EAKA,sBALA;EAKA,UAAA,EACM,SADN,EAAA;CACM;;AAclB;AAeA;AAcA;AAcA;AAcA;AAcA;AAcA;AAcA;AAaA;;iBAhHgB,EAAA,aAAe,cAAc;;ACZ7C;;;;;;;;;;iBD2BgB,GAAA,aAAgB,cAAc;;;AEvCU;AAoBxD;AAA0D;;;;;;AAOrC,iBF0BL,EAAA,CE1BK,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,GAAA,MAAA,CAAA,EF0BoC,SE1BpC;;;;;;;;AAOrB;AAGA;AAWA;AACuB,iBFkBP,GAAA,CElBO,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,GAAA,MAAA,CAAA,EFkBmC,SElBnC;;;;;;;;;;;AAGY,iBF6BnB,EAAA,CE7BmB,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,GAAA,MAAA,CAAA,EF6BsB,SE7BtB;;AAA4C;AAM/E;AAiBA;;;;AClEA;AAeA;AAiBA;AAYK,iBH0CW,GAAA,CG1CI,GAAA,EAAA,MAIJ,EAAA,KAAA,EAAA,MAAc,GAAA,MAAA,CAAA,EHsC4B,SGtC5B;AAa9B;;;;;;;;;;AAqKoB,iBH9HJ,EAAA,CG8HI,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,GAAA,MAAA,CAAA,EH9HqC,SG8HrC;;;;;;;;;;;AA4DP,iBH5KG,GAAA,CG4KH,GAAA,EAAA,MAAA,EAAA,KAAA,EA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