@arkiv-network/sdk 0.6.8 → 0.7.0-dev.1

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.
Files changed (101) hide show
  1. package/README.md +52 -16
  2. package/dist/consts-Bz0LZQZY.js +7 -0
  3. package/dist/consts-Bz0LZQZY.js.map +1 -0
  4. package/dist/consts-CxT1-RXU.cjs +18 -0
  5. package/dist/entity-BhSXaB23.cjs +81 -0
  6. package/dist/{query-CO6f35AE.d.cts → entity-CN41IOrq.d.cts} +125 -59
  7. package/dist/entity-CN41IOrq.d.cts.map +1 -0
  8. package/dist/entity-DGfVyB-a.js +71 -0
  9. package/dist/entity-DGfVyB-a.js.map +1 -0
  10. package/dist/{query-BhdmAzYg.d.ts → entity-NnEVlePN.d.ts} +125 -59
  11. package/dist/entity-NnEVlePN.d.ts.map +1 -0
  12. package/dist/index-ClkpS6s_.d.ts +481 -0
  13. package/dist/index-ClkpS6s_.d.ts.map +1 -0
  14. package/dist/index-w4qop0Pe.d.cts +481 -0
  15. package/dist/index-w4qop0Pe.d.cts.map +1 -0
  16. package/dist/index.cjs +285 -233
  17. package/dist/index.d.cts +100 -6
  18. package/dist/index.d.cts.map +1 -1
  19. package/dist/index.d.ts +101 -7
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +280 -230
  22. package/dist/index.js.map +1 -1
  23. package/dist/payload-BpNUPOnY.js +13 -0
  24. package/dist/payload-BpNUPOnY.js.map +1 -0
  25. package/dist/{payload-Da9gJMG5.d.ts → payload-C2KHOUoj.d.ts} +1 -1
  26. package/dist/{payload-Da9gJMG5.d.ts.map → payload-C2KHOUoj.d.ts.map} +1 -1
  27. package/dist/{payload-vwU3Rc6P.cjs → payload-D8YLKcJj.cjs} +1 -18
  28. package/dist/query/index.cjs +11 -28
  29. package/dist/query/index.d.cts +3 -3
  30. package/dist/query/index.d.ts +3 -3
  31. package/dist/query/index.js +8 -28
  32. package/dist/query/index.js.map +1 -1
  33. package/dist/{queryBuilder-DonAg1aq.js → queryBuilder-BE_XhLLa.js} +303 -152
  34. package/dist/queryBuilder-BE_XhLLa.js.map +1 -0
  35. package/dist/{queryBuilder-DM-YO1Y7.cjs → queryBuilder-J37buGCi.cjs} +372 -149
  36. package/dist/types/index.cjs +4 -1
  37. package/dist/types/index.d.cts +2 -2
  38. package/dist/types/index.d.ts +2 -2
  39. package/dist/types/index.js +4 -1
  40. package/dist/utils/index.cjs +4 -10
  41. package/dist/utils/index.d.cts +0 -1
  42. package/dist/utils/index.d.cts.map +1 -1
  43. package/dist/utils/index.d.ts +1 -2
  44. package/dist/utils/index.d.ts.map +1 -1
  45. package/dist/utils/index.js +2 -3
  46. package/dist/utils/index.js.map +1 -1
  47. package/package.json +11 -15
  48. package/src/actions/public/buildQuery.ts +4 -0
  49. package/src/actions/public/query.ts +10 -0
  50. package/src/actions/public/subscribeEntityEvents.ts +25 -51
  51. package/src/actions/wallet/changeOwnership.ts +6 -6
  52. package/src/actions/wallet/createEntity.ts +19 -6
  53. package/src/actions/wallet/deleteEntity.ts +2 -3
  54. package/src/actions/wallet/extendEntity.ts +9 -5
  55. package/src/actions/wallet/mutateEntities.ts +11 -54
  56. package/src/actions/wallet/updateEntity.ts +15 -6
  57. package/src/clients/createPublicClient.test.ts +2 -0
  58. package/src/clients/decorators/arkivPublic.ts +67 -2
  59. package/src/clients/decorators/arkivWallet.ts +23 -1
  60. package/src/consts.ts +2 -1
  61. package/src/errors.ts +46 -0
  62. package/src/index.ts +0 -3
  63. package/src/query/engine.test.ts +45 -0
  64. package/src/query/engine.ts +28 -14
  65. package/src/query/index.ts +1 -0
  66. package/src/query/predicate.test.ts +43 -0
  67. package/src/query/predicate.ts +14 -10
  68. package/src/query/queryBuilder.test.ts +22 -0
  69. package/src/query/queryBuilder.ts +221 -106
  70. package/src/query/queryResult.ts +13 -7
  71. package/src/query/selectQueryBuilder.test.ts +213 -0
  72. package/src/query/selection.test.ts +120 -0
  73. package/src/query/selection.ts +116 -0
  74. package/src/types/attributes.ts +25 -1
  75. package/src/types/entity.ts +12 -2
  76. package/src/types/events.ts +14 -16
  77. package/src/types/index.ts +1 -0
  78. package/src/types/rpcSchema.ts +7 -2
  79. package/src/utils/arkivTransactions.test.ts +260 -0
  80. package/src/utils/arkivTransactions.ts +255 -92
  81. package/src/utils/entities.ts +17 -7
  82. package/src/utils/index.ts +0 -1
  83. package/src/utils/payload.ts +4 -2
  84. package/src/utils/validation.test.ts +106 -0
  85. package/src/utils/validation.ts +80 -0
  86. package/dist/accounts/index.cjs +0 -9
  87. package/dist/accounts/index.d.cts +0 -1
  88. package/dist/accounts/index.d.ts +0 -1
  89. package/dist/accounts/index.js +0 -1
  90. package/dist/payload-DKBYYjeA.js +0 -18
  91. package/dist/payload-DKBYYjeA.js.map +0 -1
  92. package/dist/query-BhdmAzYg.d.ts.map +0 -1
  93. package/dist/query-CO6f35AE.d.cts.map +0 -1
  94. package/dist/queryBuilder-BvoQXa_u.d.ts +0 -328
  95. package/dist/queryBuilder-BvoQXa_u.d.ts.map +0 -1
  96. package/dist/queryBuilder-DonAg1aq.js.map +0 -1
  97. package/dist/queryBuilder-zTsKXctT.d.cts +0 -328
  98. package/dist/queryBuilder-zTsKXctT.d.cts.map +0 -1
  99. package/src/accounts/index.ts +0 -1
  100. /package/dist/{types-H-TSmRpm.js → types-Ci4BRClw.js} +0 -0
  101. /package/dist/{types-o3zWarRp.cjs → types-a8gm_IaQ.cjs} +0 -0
@@ -0,0 +1,481 @@
1
+ import { A as RpcEntity, M as RpcOrderByAttribute, O as ArkivClient, j as RpcIncludeData, t as Entity } from "./entity-NnEVlePN.js";
2
+ import { Hex } from "viem";
3
+
4
+ //#region src/query/predicate.d.ts
5
+ type PredicateType = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "not";
6
+ type PredicateContainerType = "or" | "and";
7
+ type Predicate = {
8
+ type: PredicateType;
9
+ key: string;
10
+ value: string | number;
11
+ } | {
12
+ type: PredicateContainerType;
13
+ predicates: Predicate[];
14
+ };
15
+ /**
16
+ * Creates an OR predicate
17
+ * @param predicates - The predicates to combine, either as a single array or as separate arguments
18
+ * @returns The OR predicate
19
+ *
20
+ * @example
21
+ * const result = or(eq("name", "John"), eq("age", 30))
22
+ * // or equivalently: or([eq("name", "John"), eq("age", 30)])
23
+ * // result = { type: "or", predicates: [eq("name", "John"), eq("age", 30)] }
24
+ *
25
+ */
26
+ declare function or(predicates: Predicate[]): Predicate;
27
+ declare function or(...predicates: Predicate[]): Predicate;
28
+ /**
29
+ * Creates an AND predicate
30
+ * @param predicates - The predicates to combine, either as a single array or as separate arguments
31
+ * @returns The AND predicate
32
+ *
33
+ * @example
34
+ * const result = and(eq("name", "John"), eq("age", 30))
35
+ * // or equivalently: and([eq("name", "John"), eq("age", 30)])
36
+ * // result = { type: "and", predicates: [eq("name", "John"), eq("age", 30)] }
37
+ *
38
+ */
39
+ declare function and(predicates: Predicate[]): Predicate;
40
+ declare function and(...predicates: Predicate[]): Predicate;
41
+ /**
42
+ * Creates an equality predicate
43
+ * @param key - The key to compare
44
+ * @param value - The value to compare
45
+ * @returns The equality predicate
46
+ *
47
+ * @example
48
+ * const predicate = eq("name", "John")
49
+ * // result = { type: "eq", key: "name", value: "John" }
50
+ */
51
+ declare function eq(key: string, value: string | number): Predicate;
52
+ /**
53
+ * Creates a not equal predicate
54
+ * @param key - The key to compare
55
+ * @param value - The value to compare
56
+ * @returns The not equal predicate
57
+ *
58
+ * @example
59
+ * const predicate = neq("name", "John")
60
+ * // result = { type: "neq", key: "name", value: "John" }
61
+ */
62
+ declare function neq(key: string, value: string | number): Predicate;
63
+ /**
64
+ * Creates a greater than predicate
65
+ * @param key - The key to compare
66
+ * @param value - The value to compare
67
+ * @returns The greater than predicate
68
+ *
69
+ * @example
70
+ * const predicate = gt("name", "John")
71
+ * // result = { type: "gt", key: "name", value: "John" }
72
+ */
73
+ declare function gt(key: string, value: string | number): Predicate;
74
+ /**
75
+ * Creates a greater than or equal predicate
76
+ * @param key - The key to compare
77
+ * @param value - The value to compare
78
+ * @returns The greater than or equal predicate
79
+ *
80
+ * @example
81
+ * const predicate = gte("name", "John")
82
+ * // result = { type: "gte", key: "name", value: "John" }
83
+ */
84
+ declare function gte(key: string, value: string | number): Predicate;
85
+ /**
86
+ * Creates a less than predicate
87
+ * @param key - The key to compare
88
+ * @param value - The value to compare
89
+ * @returns The less than predicate
90
+ *
91
+ * @example
92
+ * const predicate = lt("name", "John")
93
+ * // result = { type: "lt", key: "name", value: "John" }
94
+ */
95
+ declare function lt(key: string, value: string | number): Predicate;
96
+ /**
97
+ * Creates a less than or equal predicate
98
+ * @param key - The key to compare
99
+ * @param value - The value to compare
100
+ * @returns The less than or equal predicate
101
+ *
102
+ * @example
103
+ * const predicate = lte("name", "John")
104
+ * // result = { type: "lte", key: "name", value: "John" }
105
+ */
106
+ declare function lte(key: string, value: string | number): Predicate;
107
+ /**
108
+ * Creates a not predicate
109
+ * @param key - The key to compare
110
+ * @returns The not predicate
111
+ *
112
+ * @example
113
+ * const predicate = not("name")
114
+ * // result = { type: "not", key: "name", value: "" }
115
+ */
116
+ declare function not(key: string): Predicate;
117
+ //#endregion
118
+ //#region src/query/queryResult.d.ts
119
+ /**
120
+ * The result of a query. Holds the fetched entities and supports cursor-based pagination.
121
+ *
122
+ * @typeParam TEntity - The shape of each entity, inferred from the query builder
123
+ * (a full {@link Entity}, or a projected object inferred from a `select()` selection).
124
+ */
125
+ declare class QueryResult<TEntity = Entity> {
126
+ entities: TEntity[];
127
+ private _endOfIteration;
128
+ private _cursor;
129
+ private _limit;
130
+ private _validAtBlock;
131
+ private _queryBuilder;
132
+ get queryBuilder(): BaseQueryBuilder<TEntity>;
133
+ get cursor(): string | undefined;
134
+ constructor(entities: TEntity[], queryBuilder: BaseQueryBuilder<TEntity>, cursor: string | undefined, limit: number | undefined, validAtBlock: bigint | undefined);
135
+ next(): Promise<void>;
136
+ hasNextPage(): boolean;
137
+ }
138
+ //#endregion
139
+ //#region src/query/selection.d.ts
140
+ /** The entity fields that can be selected. These match the fields of {@link Entity} one-to-one. */
141
+ type DataKey = "key" | "contentType" | "owner" | "creator" | "expiresAtBlock" | "createdAtBlock" | "lastModifiedAtBlock" | "transactionIndexInBlock" | "operationIndexInTransaction" | "attributes" | "payload";
142
+ /**
143
+ * The parts of an entity that can be selected. Every field is opt-in (including the `key`) and maps
144
+ * directly to a field of the returned {@link Entity} — the selection is flat.
145
+ */
146
+ type SelectionFields = { [K in DataKey]?: boolean };
147
+ /**
148
+ * Requires at least one property of `T` to be present.
149
+ * `{}` is not assignable, which is how `select({})` is rejected at compile time.
150
+ */
151
+ type AtLeastOne<T, K$1 extends keyof T = keyof T> = { [P in K$1]: Required<Pick<T, P>> & Partial<Omit<T, P>> }[K$1];
152
+ /**
153
+ * A non-empty entity selection — the object form accepted by `select()`. At least one field must be
154
+ * selected.
155
+ */
156
+ type EntitySelection = AtLeastOne<SelectionFields>;
157
+ /** Argument accepted by `select()` — a non-empty {@link EntitySelection}, or `"*"` for everything. */
158
+ type SelectArg = EntitySelection | "*";
159
+ /**
160
+ * The result of a selection `S`: an {@link Entity} narrowed to exactly the selected fields (each
161
+ * non-`undefined`). The shape is flat and backwards compatible — e.g. `select({ owner: true })`
162
+ * yields `{ owner: Hex }` accessed as `entity.owner`. Accessing an unselected field is a compile
163
+ * error.
164
+ *
165
+ * The `toText()` / `toJson()` helpers operate on the payload, so they are only present when
166
+ * `payload` was selected — calling them otherwise would always throw.
167
+ */
168
+ 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 {
169
+ payload: true;
170
+ } ? Pick<Entity, "toText" | "toJson"> : unknown);
171
+ /** A selection of every field, used to type the result of `select()` / `select("*")`. */
172
+ type AllSelected = { [K in DataKey]: true };
173
+ /** The projected entity type when everything is selected — every field, plus the methods. */
174
+ type FullEntity = ProjectedEntity<AllSelected>;
175
+ /**
176
+ * Converts a {@link SelectArg} into the {@link RpcIncludeData} understood by the query engine.
177
+ * Every field is opt-in — anything not explicitly selected defaults to `false`, including the key.
178
+ * `undefined` or `"*"` selects everything.
179
+ *
180
+ * @param selection - The selection to convert
181
+ * @returns The fully-resolved include-data object for the RPC query
182
+ * @throws If an empty selection object is provided
183
+ *
184
+ * @example
185
+ * selectionToIncludeData() // everything
186
+ * selectionToIncludeData("*") // everything
187
+ * selectionToIncludeData({ key: true }) // only the key
188
+ * selectionToIncludeData({ owner: true }) // only the owner
189
+ */
190
+ declare function selectionToIncludeData(selection?: SelectArg): RpcIncludeData;
191
+ //#endregion
192
+ //#region src/query/queryBuilder.d.ts
193
+ /**
194
+ * @deprecated Server-side ordering is not supported by the network. Sort the fetched
195
+ * entities in JavaScript instead (e.g. `entities.sort(...)`). This type will be removed
196
+ * in a future release.
197
+ */
198
+ type OrderByAttribute = {
199
+ name: string;
200
+ type: "string" | "number";
201
+ order: "asc" | "desc";
202
+ };
203
+ /**
204
+ * Helper function to create an ascending order by attribute
205
+ * @param attributeName - The name of the attribute to order by
206
+ * @param attributeType - The type of the attribute to order by (string or number)
207
+ * @returns Input for orderBy method
208
+ *
209
+ * @deprecated Server-side ordering is not supported by the network, so `orderBy` (and this
210
+ * helper) have no effect on the returned order. Sort the fetched entities in JavaScript
211
+ * instead (e.g. `entities.sort(...)`). This function will be removed in a future release.
212
+ *
213
+ * @example
214
+ * const ascAttribute = asc("name", "string")
215
+ */
216
+ declare function asc(attributeName: string, attributeType: "string" | "number"): OrderByAttribute;
217
+ /**
218
+ * Helper function to create a descending order by attribute
219
+ * @param attributeName - The name of the attribute to order by
220
+ * @param attributeType - The type of the attribute to order by (string or number)
221
+ * @returns Input for orderBy method
222
+ *
223
+ * @deprecated Server-side ordering is not supported by the network, so `orderBy` (and this
224
+ * helper) have no effect on the returned order. Sort the fetched entities in JavaScript
225
+ * instead (e.g. `entities.sort(...)`). This function will be removed in a future release.
226
+ *
227
+ * @example
228
+ * const descAttribute = desc("name", "string")
229
+ */
230
+ declare function desc(attributeName: string, attributeType: "string" | "number"): OrderByAttribute;
231
+ /**
232
+ * Data-selection parameters forwarded to the query engine on each fetch.
233
+ * Subclasses of {@link BaseQueryBuilder} decide which parts of an entity are fetched.
234
+ */
235
+ type SelectionParams = {
236
+ withAttributes?: boolean | undefined;
237
+ withMetadata?: boolean | undefined;
238
+ withPayload?: boolean | undefined;
239
+ includeData?: RpcIncludeData | undefined;
240
+ };
241
+ /**
242
+ * BaseQueryBuilder holds the query-building logic shared by every query builder
243
+ * (filtering, ordering, pagination, execution). It follows the Builder pattern,
244
+ * allowing methods to be chained. Subclasses decide how data selection is expressed
245
+ * by implementing the protected `selectionParams` method.
246
+ *
247
+ * Use {@link SelectQueryBuilder} via `client.select()` to build and execute queries.
248
+ *
249
+ * @typeParam TEntity - The shape of each entity produced by {@link BaseQueryBuilder.fetch}.
250
+ */
251
+ declare abstract class BaseQueryBuilder<TEntity> {
252
+ protected _client: ArkivClient;
253
+ protected _ownedBy: Hex | undefined;
254
+ protected _createdBy: Hex | undefined;
255
+ protected _orderBy: RpcOrderByAttribute[] | undefined;
256
+ protected _validAtBlock: bigint | undefined;
257
+ protected _limit: number | undefined;
258
+ protected _cursor: string | undefined;
259
+ protected _predicates: Predicate[];
260
+ constructor(client: ArkivClient);
261
+ /**
262
+ * Sets the ownedBy filter
263
+ * @param ownedBy - The address of the owner
264
+ * @returns The query builder instance
265
+ *
266
+ * @example
267
+ * const builder = client.select()
268
+ * builder.ownedBy("0x1234567890123456789012345678901234567890")
269
+ */
270
+ ownedBy(ownedBy: Hex): this;
271
+ /**
272
+ * Sets the createdBy filter
273
+ * @param createdBy - The address of the creator
274
+ * @returns The query builder instance
275
+ *
276
+ * @example
277
+ * const builder = client.select()
278
+ * builder.createdBy("0x1234567890123456789012345678901234567890")
279
+ */
280
+ createdBy(createdBy: Hex): this;
281
+ /**
282
+ * Sets the orderBy for the query.
283
+ * It can be called multiple times to order by multiple attributes.
284
+ * The order of the attributes is important. The first attribute is the primary order by attribute.
285
+ * You can use the helper functions asc() and desc() as input for this method.
286
+ * @param attributeName - The name of the attribute to order by
287
+ * @param attributeType - The type of the attribute to order by (string or number)
288
+ * @param order - The order to set the order by (asc or desc)
289
+ * @returns The query builder instance
290
+ *
291
+ * @deprecated Server-side ordering is not supported by the network, so this method has no
292
+ * effect on the returned order. Sort the fetched entities in JavaScript instead, e.g.
293
+ * `result.entities.sort((a, b) => ...)`. This method will be removed in a future release.
294
+ *
295
+ * @example
296
+ * const builder = client.select()
297
+ * builder.orderBy("name", "string", "desc")
298
+ * builder.orderBy(asc("name", "string"))
299
+ * builder.orderBy(desc("name", "string"))
300
+ */
301
+ orderBy(attributeName: string, attributeType: "string" | "number", order?: "asc" | "desc"): this;
302
+ /**
303
+ * Sets the orderBy for the query.
304
+ * This method takes the OrderByAttribute object as an argument and is mainly
305
+ * used to use the helper functions asc() and desc() to create the OrderByAttribute instances.
306
+ * @param orderByAttribute - The OrderByAttribute instance to set
307
+ * @returns The query builder instance
308
+ *
309
+ * @deprecated Server-side ordering is not supported by the network, so this method has no
310
+ * effect on the returned order. Sort the fetched entities in JavaScript instead, e.g.
311
+ * `result.entities.sort((a, b) => ...)`. This method will be removed in a future release.
312
+ *
313
+ * @example
314
+ * const builder = client.select()
315
+ * builder.orderBy(asc("name", "string"))
316
+ * builder.orderBy(desc("name", "string"))
317
+ */
318
+ orderBy(orderByAttribute: OrderByAttribute): this;
319
+ /**
320
+ * Sets the limit for the query
321
+ * @param limit - The number of entities to return
322
+ * @returns The query builder instance
323
+ *
324
+ * @example
325
+ * const builder = client.select()
326
+ * builder.limit(10)
327
+ */
328
+ limit(limit: number): this;
329
+ /**
330
+ * 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).
331
+ * @param cursor - The cursor to set which tells to RPC Query server where to start or continue the query.
332
+ * @returns The query builder instance
333
+ *
334
+ * @example
335
+ * const builder = client.select()
336
+ * builder.cursor("0xABC123")
337
+ */
338
+ cursor(cursor: string): this;
339
+ /**
340
+ * Sets the validAtBlock for the query which tells at which block height the state we are intested.
341
+ * If not set, the latest block is used.
342
+ * @param validAtBlock - The block number to set
343
+ * @returns The query builder instance
344
+ *
345
+ * @example
346
+ * const builder = client.select()
347
+ * builder.validAtBlock(10000)
348
+ */
349
+ validAtBlock(validAtBlock: bigint): this;
350
+ /**
351
+ * Sets the predicates for the query limiting the results. It can be a single predicate,
352
+ * multiple predicates passed as separate arguments, or an array of predicates - all combined with 'and'.
353
+ * Predicates can be nested using 'or' and 'and' predicates.
354
+ * @param predicates - The predicates to set, either as a single array or as separate arguments
355
+ * @returns The query builder instance
356
+ *
357
+ * @example
358
+ * const builder = client.select()
359
+ * builder.where(eq("name", "John"))
360
+ * builder.where(eq("name", "John"), eq("age", 30))
361
+ * builder.where([eq("name", "John"), eq("age", 30)])
362
+ * builder.where(eq("name", "John"), or(eq("age", 30), eq("age", 31)))
363
+ * builder.where(eq("name", "John"), and(eq("age", 30), eq("age", 31)))
364
+ * builder.where(eq("name", "John"), or(eq("age", 30), and(eq("age", 31), eq("age", 32))))
365
+ * builder.where(eq("name", "John"), and(eq("age", 30), or(eq("age", 31), eq("age", 32))))
366
+ */
367
+ where(predicates: Predicate[]): this;
368
+ where(...predicates: Predicate[]): this;
369
+ /**
370
+ * Returns the data-selection parameters forwarded to the query engine.
371
+ * Subclasses decide which parts of an entity are fetched.
372
+ */
373
+ protected abstract selectionParams(): SelectionParams;
374
+ /**
375
+ * Builds a single result entity from a raw RPC entity. Subclasses decide the produced shape
376
+ * (a full {@link Entity}, or a projected object inferred from the selection).
377
+ */
378
+ protected abstract projectEntity(rpcEntity: RpcEntity): TEntity | Promise<TEntity>;
379
+ /**
380
+ * Fetches the entities from the query.
381
+ * It will return a QueryResult instance which can be used to fetch the next and previous pages.
382
+ * @returns The QueryResult instance {@link QueryResult}
383
+ *
384
+ * @example
385
+ * const builder = client.select()
386
+ * const result = await builder.where(eq("name", "John")).fetch()
387
+ * // result = { entities: [Entity, Entity, Entity], next: async () => QueryResult, previous: async () => QueryResult }
388
+ */
389
+ fetch(): Promise<QueryResult<TEntity>>;
390
+ /**
391
+ * Counts the entities from the query.
392
+ * @returns The number of entities
393
+ *
394
+ * @example
395
+ * const builder = client.select()
396
+ * const result = await builder.where(eq("name", "John")).count()
397
+ * // result = 10
398
+ */
399
+ count(): Promise<number>;
400
+ }
401
+ /**
402
+ * QueryBuilder is a helper class to build queries to the Arkiv DBChains.
403
+ * It can be used to fetch entities from the Arkiv DBChains. It follows the Builder pattern allowing chaining of methods.
404
+ *
405
+ * By default the result includes only the entity `key`. Additional data is opt-in through
406
+ * `withAttributes()`, `withMetadata()` and `withPayload()`.
407
+ *
408
+ * @deprecated Use {@link SelectQueryBuilder} via `client.select()` instead. Declaring the
409
+ * selection up front avoids the common mistake of forgetting to opt in to data and getting back
410
+ * entities with only their `key` populated. This class remains for backwards compatibility and
411
+ * will be removed in a future release.
412
+ *
413
+ * @param client - The Arkiv client
414
+ * @returns The QueryBuilder instance {@link QueryBuilder}
415
+ */
416
+ declare class QueryBuilder extends BaseQueryBuilder<Entity> {
417
+ private _withAttributes;
418
+ private _withMetadata;
419
+ private _withPayload;
420
+ /**
421
+ * Sets the withAttributes flag which will return the attributes for the entities if true
422
+ * @param withAttributes - The boolean value to set
423
+ * @returns The QueryBuilder instance
424
+ *
425
+ * @example
426
+ * const builder = client.buildQuery()
427
+ * builder.withAttributes(true)
428
+ */
429
+ withAttributes(withAttributes?: boolean): this;
430
+ /**
431
+ * Sets the withMetadata flag which will return the metadata (like owner, expiredAt, etc.) for the entities if true
432
+ * @param withMetadata - The boolean value to set
433
+ * @returns The QueryBuilder instance
434
+ *
435
+ * @example
436
+ * const builder = client.buildQuery()
437
+ * builder.withMetadata(true)
438
+ */
439
+ withMetadata(withMetadata?: boolean): this;
440
+ /**
441
+ * Sets the withPayload flag which will return the payload for the entities if true
442
+ * @param withPayload - The boolean value to set
443
+ * @returns The QueryBuilder instance
444
+ *
445
+ * @example
446
+ * const builder = client.buildQuery()
447
+ * builder.withPayload(true)
448
+ */
449
+ withPayload(withPayload?: boolean): this;
450
+ protected selectionParams(): SelectionParams;
451
+ protected projectEntity(rpcEntity: RpcEntity): Promise<Entity>;
452
+ }
453
+ /**
454
+ * SelectQueryBuilder is the recommended query builder. It requires the selection to be declared
455
+ * up front, so results always contain exactly the data you asked for — and the type of each
456
+ * returned entity is narrowed to exactly the selected fields.
457
+ *
458
+ * The selection is fixed at construction time and is flat — each field maps to an entity field.
459
+ * Create one via `client.select(...)` rather than constructing it directly, so the result type is
460
+ * inferred from the selection.
461
+ *
462
+ * @typeParam TEntity - The projected entity shape, inferred from the selection by `client.select()`.
463
+ *
464
+ * @example
465
+ * // everything
466
+ * await client.select().where(eq("name", "John")).fetch()
467
+ * await client.select("*").where(eq("name", "John")).fetch()
468
+ * // specific fields
469
+ * await client.select({ owner: true, attributes: true }).fetch()
470
+ * // a single field — result is typed (flat) { owner: Hex }
471
+ * await client.select({ owner: true }).fetch()
472
+ */
473
+ declare class SelectQueryBuilder<TEntity> extends BaseQueryBuilder<TEntity> {
474
+ private _includeData;
475
+ constructor(client: ArkivClient, selection?: SelectArg);
476
+ protected selectionParams(): SelectionParams;
477
+ protected projectEntity(rpcEntity: RpcEntity): Promise<TEntity>;
478
+ }
479
+ //#endregion
480
+ 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 };
481
+ //# sourceMappingURL=index-ClkpS6s_.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-ClkpS6s_.d.ts","names":[],"sources":["../src/query/predicate.ts","../src/query/queryResult.ts","../src/query/selection.ts","../src/query/queryBuilder.ts"],"sourcesContent":[],"mappings":";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