@arkiv-network/sdk 0.6.8 → 0.7.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.
Files changed (83) hide show
  1. package/README.md +52 -16
  2. package/dist/chains/index.d.cts +25 -25
  3. package/dist/consts-AUoL-v42.cjs +18 -0
  4. package/dist/consts-BV4PR-de.js +7 -0
  5. package/dist/consts-BV4PR-de.js.map +1 -0
  6. package/dist/{query-CO6f35AE.d.cts → entity-B6g_EPm1.d.cts} +78 -31
  7. package/dist/entity-B6g_EPm1.d.cts.map +1 -0
  8. package/dist/{query-BhdmAzYg.d.ts → entity-qoLMAuuk.d.ts} +78 -31
  9. package/dist/entity-qoLMAuuk.d.ts.map +1 -0
  10. package/dist/index-DdspxNAA.d.ts +481 -0
  11. package/dist/index-DdspxNAA.d.ts.map +1 -0
  12. package/dist/index-Ds9dwqb5.d.cts +481 -0
  13. package/dist/index-Ds9dwqb5.d.cts.map +1 -0
  14. package/dist/index.cjs +63 -28
  15. package/dist/index.d.cts +90 -5
  16. package/dist/index.d.cts.map +1 -1
  17. package/dist/index.d.ts +91 -6
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +58 -21
  20. package/dist/index.js.map +1 -1
  21. package/dist/{payload-Da9gJMG5.d.ts → payload-B2kFJyah.d.ts} +1 -1
  22. package/dist/{payload-Da9gJMG5.d.ts.map → payload-B2kFJyah.d.ts.map} +1 -1
  23. package/dist/payload-Claf2jUO.js +13 -0
  24. package/dist/payload-Claf2jUO.js.map +1 -0
  25. package/dist/{payload-vwU3Rc6P.cjs → payload-DpA5PA-w.cjs} +0 -17
  26. package/dist/query/index.cjs +10 -28
  27. package/dist/query/index.d.cts +3 -3
  28. package/dist/query/index.d.ts +3 -3
  29. package/dist/query/index.js +7 -28
  30. package/dist/query/index.js.map +1 -1
  31. package/dist/{queryBuilder-DonAg1aq.js → queryBuilder-D2uwP9jI.js} +209 -89
  32. package/dist/queryBuilder-D2uwP9jI.js.map +1 -0
  33. package/dist/{queryBuilder-DM-YO1Y7.cjs → queryBuilder-UW2MCaX4.cjs} +237 -87
  34. package/dist/types/index.d.cts +1 -1
  35. package/dist/types/index.d.ts +1 -1
  36. package/dist/utils/index.cjs +4 -10
  37. package/dist/utils/index.d.cts +0 -1
  38. package/dist/utils/index.d.cts.map +1 -1
  39. package/dist/utils/index.d.ts +1 -2
  40. package/dist/utils/index.d.ts.map +1 -1
  41. package/dist/utils/index.js +2 -3
  42. package/dist/utils/index.js.map +1 -1
  43. package/package.json +11 -15
  44. package/src/actions/public/buildQuery.ts +4 -0
  45. package/src/actions/public/query.ts +10 -0
  46. package/src/actions/wallet/createEntity.ts +12 -2
  47. package/src/actions/wallet/extendEntity.ts +6 -1
  48. package/src/actions/wallet/updateEntity.ts +12 -2
  49. package/src/clients/createPublicClient.test.ts +2 -0
  50. package/src/clients/decorators/arkivPublic.ts +67 -2
  51. package/src/clients/decorators/arkivWallet.ts +18 -0
  52. package/src/errors.ts +18 -0
  53. package/src/index.ts +0 -3
  54. package/src/query/engine.ts +22 -13
  55. package/src/query/index.ts +1 -0
  56. package/src/query/predicate.test.ts +43 -0
  57. package/src/query/predicate.ts +14 -10
  58. package/src/query/queryBuilder.test.ts +22 -0
  59. package/src/query/queryBuilder.ts +221 -106
  60. package/src/query/queryResult.ts +13 -7
  61. package/src/query/selectQueryBuilder.test.ts +210 -0
  62. package/src/query/selection.test.ts +120 -0
  63. package/src/query/selection.ts +116 -0
  64. package/src/types/attributes.ts +12 -0
  65. package/src/utils/arkivTransactions.test.ts +62 -0
  66. package/src/utils/arkivTransactions.ts +36 -27
  67. package/src/utils/index.ts +0 -1
  68. package/src/utils/validation.test.ts +60 -0
  69. package/src/utils/validation.ts +32 -0
  70. package/dist/accounts/index.cjs +0 -9
  71. package/dist/accounts/index.d.cts +0 -1
  72. package/dist/accounts/index.d.ts +0 -1
  73. package/dist/accounts/index.js +0 -1
  74. package/dist/payload-DKBYYjeA.js +0 -18
  75. package/dist/payload-DKBYYjeA.js.map +0 -1
  76. package/dist/query-BhdmAzYg.d.ts.map +0 -1
  77. package/dist/query-CO6f35AE.d.cts.map +0 -1
  78. package/dist/queryBuilder-BvoQXa_u.d.ts +0 -328
  79. package/dist/queryBuilder-BvoQXa_u.d.ts.map +0 -1
  80. package/dist/queryBuilder-DonAg1aq.js.map +0 -1
  81. package/dist/queryBuilder-zTsKXctT.d.cts +0 -328
  82. package/dist/queryBuilder-zTsKXctT.d.cts.map +0 -1
  83. package/src/accounts/index.ts +0 -1
@@ -1,3 +1,4 @@
1
+ const require_consts = require('./consts-AUoL-v42.cjs');
1
2
  let viem = require("viem");
2
3
 
3
4
  //#region src/utils/logger.ts
@@ -120,6 +121,18 @@ var EntityMutationError = class extends Error {
120
121
  this.name = "EntityMutationError";
121
122
  }
122
123
  };
124
+ var InvalidExpirationError = class extends Error {
125
+ constructor(expiresIn) {
126
+ super(`Invalid expiresIn: ${String(expiresIn)}. expiresIn must be a positive integer and a multiple of the Arkiv block time (${require_consts.BLOCK_TIME} seconds), because expiration is measured in whole blocks (1 block = ${require_consts.BLOCK_TIME} seconds).`);
127
+ this.name = "InvalidExpirationError";
128
+ }
129
+ };
130
+ var InvalidAttributeError = class extends Error {
131
+ constructor(key, value) {
132
+ super(`Invalid numeric value for attribute "${key}": ${String(value)}. Numeric attribute values must be integers. To keep numeric ordering/range queries, scale it to an integer (e.g. Math.round(${String(value)} * 1000), dividing by 1000 on read); otherwise store it as a string (e.g. "${String(value)}").`);
133
+ this.name = "InvalidAttributeError";
134
+ }
135
+ };
123
136
  var NoMoreResultsError = class extends Error {
124
137
  constructor() {
125
138
  super("No more results");
@@ -235,7 +248,7 @@ function processPredicates(predicates) {
235
248
  }).join(" && ");
236
249
  }
237
250
  async function processQuery(client, queryParams) {
238
- const { predicates, limit, cursor, ownedBy, createdBy, orderBy, validAtBlock, withAttributes, withMetadata, withPayload } = queryParams;
251
+ const { predicates, limit, cursor, ownedBy, createdBy, orderBy, validAtBlock, withAttributes, withMetadata, withPayload, includeData } = queryParams;
239
252
  logger$1("Processing query with params %o", {
240
253
  predicates,
241
254
  cursor,
@@ -246,14 +259,15 @@ async function processQuery(client, queryParams) {
246
259
  validAtBlock,
247
260
  withAttributes,
248
261
  withMetadata,
249
- withPayload
262
+ withPayload,
263
+ includeData
250
264
  });
251
265
  let query = processPredicates(predicates);
252
266
  if (ownedBy) query += ` && $owner=${ownedBy}`;
253
267
  if (createdBy) query += ` && $creator=${createdBy}`;
254
268
  query = query.trim();
255
269
  if (query.startsWith("&& ")) query = query.slice(3);
256
- const queryOptions = { includeData: {
270
+ const queryOptions = { includeData: includeData ?? {
257
271
  key: true,
258
272
  attributes: withAttributes ?? false,
259
273
  payload: withPayload ?? false,
@@ -288,6 +302,12 @@ async function processQuery(client, queryParams) {
288
302
  //#endregion
289
303
  //#region src/query/queryResult.ts
290
304
  const logger = getLogger("query:result");
305
+ /**
306
+ * The result of a query. Holds the fetched entities and supports cursor-based pagination.
307
+ *
308
+ * @typeParam TEntity - The shape of each entity, inferred from the query builder
309
+ * (a full {@link Entity}, or a projected object inferred from a `select()` selection).
310
+ */
291
311
  var QueryResult = class {
292
312
  entities;
293
313
  _endOfIteration;
@@ -325,6 +345,53 @@ var QueryResult = class {
325
345
  }
326
346
  };
327
347
 
348
+ //#endregion
349
+ //#region src/query/selection.ts
350
+ /**
351
+ * Converts a {@link SelectArg} into the {@link RpcIncludeData} understood by the query engine.
352
+ * Every field is opt-in — anything not explicitly selected defaults to `false`, including the key.
353
+ * `undefined` or `"*"` selects everything.
354
+ *
355
+ * @param selection - The selection to convert
356
+ * @returns The fully-resolved include-data object for the RPC query
357
+ * @throws If an empty selection object is provided
358
+ *
359
+ * @example
360
+ * selectionToIncludeData() // everything
361
+ * selectionToIncludeData("*") // everything
362
+ * selectionToIncludeData({ key: true }) // only the key
363
+ * selectionToIncludeData({ owner: true }) // only the owner
364
+ */
365
+ function selectionToIncludeData(selection) {
366
+ if (selection === void 0 || selection === "*") return {
367
+ key: true,
368
+ attributes: true,
369
+ payload: true,
370
+ contentType: true,
371
+ expiration: true,
372
+ owner: true,
373
+ creator: true,
374
+ createdAtBlock: true,
375
+ lastModifiedAtBlock: true,
376
+ transactionIndexInBlock: true,
377
+ operationIndexInTransaction: true
378
+ };
379
+ if (!Object.values(selection).some((selected) => selected === true)) throw new Error("select() requires at least one field to be selected. Pass select() or select(\"*\") to select everything.");
380
+ return {
381
+ key: selection.key ?? false,
382
+ attributes: selection.attributes ?? false,
383
+ payload: selection.payload ?? false,
384
+ contentType: selection.contentType ?? false,
385
+ expiration: selection.expiresAtBlock ?? false,
386
+ owner: selection.owner ?? false,
387
+ creator: selection.creator ?? false,
388
+ createdAtBlock: selection.createdAtBlock ?? false,
389
+ lastModifiedAtBlock: selection.lastModifiedAtBlock ?? false,
390
+ transactionIndexInBlock: selection.transactionIndexInBlock ?? false,
391
+ operationIndexInTransaction: selection.operationIndexInTransaction ?? false
392
+ };
393
+ }
394
+
328
395
  //#endregion
329
396
  //#region src/query/queryBuilder.ts
330
397
  /**
@@ -333,6 +400,10 @@ var QueryResult = class {
333
400
  * @param attributeType - The type of the attribute to order by (string or number)
334
401
  * @returns Input for orderBy method
335
402
  *
403
+ * @deprecated Server-side ordering is not supported by the network, so `orderBy` (and this
404
+ * helper) have no effect on the returned order. Sort the fetched entities in JavaScript
405
+ * instead (e.g. `entities.sort(...)`). This function will be removed in a future release.
406
+ *
336
407
  * @example
337
408
  * const ascAttribute = asc("name", "string")
338
409
  */
@@ -349,6 +420,10 @@ function asc(attributeName, attributeType) {
349
420
  * @param attributeType - The type of the attribute to order by (string or number)
350
421
  * @returns Input for orderBy method
351
422
  *
423
+ * @deprecated Server-side ordering is not supported by the network, so `orderBy` (and this
424
+ * helper) have no effect on the returned order. Sort the fetched entities in JavaScript
425
+ * instead (e.g. `entities.sort(...)`). This function will be removed in a future release.
426
+ *
352
427
  * @example
353
428
  * const descAttribute = desc("name", "string")
354
429
  */
@@ -360,20 +435,21 @@ function desc(attributeName, attributeType) {
360
435
  };
361
436
  }
362
437
  /**
363
- * QueryBuilder is a helper class to build queries to the Arkiv DBChains.
364
- * It can be used to fetch entities from the Arkiv DBChains. It follows the Builder pattern allowing chaining of methods.
365
- * @param client - The Arkiv client
366
- * @returns The QueryBuilder instance {@link QueryBuilder}
438
+ * BaseQueryBuilder holds the query-building logic shared by every query builder
439
+ * (filtering, ordering, pagination, execution). It follows the Builder pattern,
440
+ * allowing methods to be chained. Subclasses decide how data selection is expressed
441
+ * by implementing the protected `selectionParams` method.
442
+ *
443
+ * Use {@link SelectQueryBuilder} via `client.select()` to build and execute queries.
444
+ *
445
+ * @typeParam TEntity - The shape of each entity produced by {@link BaseQueryBuilder.fetch}.
367
446
  */
368
- var QueryBuilder = class {
447
+ var BaseQueryBuilder = class {
369
448
  _client;
370
449
  _ownedBy;
371
450
  _createdBy;
372
451
  _orderBy;
373
452
  _validAtBlock;
374
- _withAttributes;
375
- _withMetadata;
376
- _withPayload;
377
453
  _limit;
378
454
  _cursor;
379
455
  _predicates;
@@ -384,10 +460,10 @@ var QueryBuilder = class {
384
460
  /**
385
461
  * Sets the ownedBy filter
386
462
  * @param ownedBy - The address of the owner
387
- * @returns The QueryBuilder instance
463
+ * @returns The query builder instance
388
464
  *
389
465
  * @example
390
- * const builder = new QueryBuilder(client)
466
+ * const builder = client.select()
391
467
  * builder.ownedBy("0x1234567890123456789012345678901234567890")
392
468
  */
393
469
  ownedBy(ownedBy) {
@@ -397,10 +473,10 @@ var QueryBuilder = class {
397
473
  /**
398
474
  * Sets the createdBy filter
399
475
  * @param createdBy - The address of the creator
400
- * @returns The QueryBuilder instance
476
+ * @returns The query builder instance
401
477
  *
402
478
  * @example
403
- * const builder = new QueryBuilder(client)
479
+ * const builder = client.select()
404
480
  * builder.createdBy("0x1234567890123456789012345678901234567890")
405
481
  */
406
482
  createdBy(createdBy) {
@@ -427,51 +503,12 @@ var QueryBuilder = class {
427
503
  return this;
428
504
  }
429
505
  /**
430
- * Sets the withAttributes flag which will return the attributes for the entities if true
431
- * @param withAttributes - The boolean value to set
432
- * @returns The QueryBuilder instance
433
- *
434
- * @example
435
- * const builder = new QueryBuilder(client)
436
- * builder.withAttributes(true)
437
- */
438
- withAttributes(withAttributes = true) {
439
- this._withAttributes = withAttributes;
440
- return this;
441
- }
442
- /**
443
- * Sets the withMetadata flag which will return the metadata (like owner, expiredAt, etc.) for the entities if true
444
- * @param withMetadata - The boolean value to set
445
- * @returns The QueryBuilder instance
446
- *
447
- * @example
448
- * const builder = new QueryBuilder(client)
449
- * builder.withMetadata(true)
450
- */
451
- withMetadata(withMetadata = true) {
452
- this._withMetadata = withMetadata;
453
- return this;
454
- }
455
- /**
456
- * Sets the withPayload flag which will return the payload for the entities if true
457
- * @param withPayload - The boolean value to set
458
- * @returns The QueryBuilder instance
459
- *
460
- * @example
461
- * const builder = new QueryBuilder(client)
462
- * builder.withPayload(true)
463
- */
464
- withPayload(withPayload = true) {
465
- this._withPayload = withPayload;
466
- return this;
467
- }
468
- /**
469
506
  * Sets the limit for the query
470
507
  * @param limit - The number of entities to return
471
- * @returns The QueryBuilder instance
508
+ * @returns The query builder instance
472
509
  *
473
510
  * @example
474
- * const builder = new QueryBuilder(client)
511
+ * const builder = client.select()
475
512
  * builder.limit(10)
476
513
  */
477
514
  limit(limit) {
@@ -481,11 +518,11 @@ var QueryBuilder = class {
481
518
  /**
482
519
  * 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).
483
520
  * @param cursor - The cursor to set which tells to RPC Query server where to start or continue the query.
484
- * @returns The QueryBuilder instance
521
+ * @returns The query builder instance
485
522
  *
486
523
  * @example
487
- * const builder = new QueryBuilder(client)
488
- * builder.offset(10)
524
+ * const builder = client.select()
525
+ * builder.cursor("0xABC123")
489
526
  */
490
527
  cursor(cursor) {
491
528
  this._cursor = cursor;
@@ -495,44 +532,27 @@ var QueryBuilder = class {
495
532
  * Sets the validAtBlock for the query which tells at which block height the state we are intested.
496
533
  * If not set, the latest block is used.
497
534
  * @param validAtBlock - The block number to set
498
- * @returns The QueryBuilder instance
535
+ * @returns The query builder instance
499
536
  *
500
537
  * @example
501
- * const builder = new QueryBuilder(client)
538
+ * const builder = client.select()
502
539
  * builder.validAtBlock(10000)
503
540
  */
504
541
  validAtBlock(validAtBlock) {
505
542
  this._validAtBlock = validAtBlock;
506
543
  return this;
507
544
  }
508
- /**
509
- * Sets the predicates for the query limiting the results. It can be a single predicate or an array of predicates combined with 'and'.
510
- * Predicates can be nested using 'or' and 'and' predicates.
511
- * @param predicates - The predicates to set
512
- * @returns The QueryBuilder instance
513
- *
514
- * @example
515
- * const builder = new QueryBuilder(client)
516
- * builder.where(eq("name", "John"))
517
- * builder.where([eq("name", "John"), eq("age", 30)])
518
- * builder.where([eq("name", "John"), or([eq("age", 30), eq("age", 31)])])
519
- * builder.where([eq("name", "John"), and([eq("age", 30), eq("age", 31)])])
520
- * builder.where([eq("name", "John"), or([eq("age", 30), and([eq("age", 31), eq("age", 32)])])])
521
- * builder.where([eq("name", "John"), and([eq("age", 30), or([eq("age", 31), eq("age", 32)])])])
522
- * builder.where([eq("name", "John"), and([eq("age", 30), or([eq("age", 31), and([eq("age", 32), eq("age", 33)])])])])
523
- */
524
- where(predicates) {
525
- if (Array.isArray(predicates)) this._predicates.push(...predicates);
526
- else this._predicates.push(predicates);
545
+ where(...predicates) {
546
+ this._predicates.push(...predicates.flat());
527
547
  return this;
528
548
  }
529
549
  /**
530
- * Fetches the entities from the query. Re
550
+ * Fetches the entities from the query.
531
551
  * It will return a QueryResult instance which can be used to fetch the next and previous pages.
532
552
  * @returns The QueryResult instance {@link QueryResult}
533
553
  *
534
554
  * @example
535
- * const builder = new QueryBuilder(client)
555
+ * const builder = client.select()
536
556
  * const result = await builder.where(eq("name", "John")).fetch()
537
557
  * // result = { entities: [Entity, Entity, Entity], next: async () => QueryResult, previous: async () => QueryResult }
538
558
  */
@@ -545,11 +565,9 @@ var QueryBuilder = class {
545
565
  createdBy: this._createdBy,
546
566
  orderBy: this._orderBy,
547
567
  validAtBlock: this._validAtBlock,
548
- withAttributes: this._withAttributes,
549
- withMetadata: this._withMetadata,
550
- withPayload: this._withPayload
568
+ ...this.selectionParams()
551
569
  });
552
- const entities = await Promise.all(queryResult.data.map((entity) => entityFromRpcResult(entity)));
570
+ const entities = await Promise.all(queryResult.data.map((entity) => this.projectEntity(entity)));
553
571
  this.cursor(queryResult.cursor);
554
572
  this.validAtBlock(BigInt(queryResult.blockNumber ?? 0));
555
573
  return new QueryResult(entities, this, this._cursor, this._limit, this._validAtBlock);
@@ -559,7 +577,7 @@ var QueryBuilder = class {
559
577
  * @returns The number of entities
560
578
  *
561
579
  * @example
562
- * const builder = new QueryBuilder(client)
580
+ * const builder = client.select()
563
581
  * const result = await builder.where(eq("name", "John")).count()
564
582
  * // result = 10
565
583
  */
@@ -578,14 +596,134 @@ var QueryBuilder = class {
578
596
  })).data.length ?? 0;
579
597
  }
580
598
  };
599
+ /**
600
+ * QueryBuilder is a helper class to build queries to the Arkiv DBChains.
601
+ * It can be used to fetch entities from the Arkiv DBChains. It follows the Builder pattern allowing chaining of methods.
602
+ *
603
+ * By default the result includes only the entity `key`. Additional data is opt-in through
604
+ * `withAttributes()`, `withMetadata()` and `withPayload()`.
605
+ *
606
+ * @deprecated Use {@link SelectQueryBuilder} via `client.select()` instead. Declaring the
607
+ * selection up front avoids the common mistake of forgetting to opt in to data and getting back
608
+ * entities with only their `key` populated. This class remains for backwards compatibility and
609
+ * will be removed in a future release.
610
+ *
611
+ * @param client - The Arkiv client
612
+ * @returns The QueryBuilder instance {@link QueryBuilder}
613
+ */
614
+ var QueryBuilder = class extends BaseQueryBuilder {
615
+ _withAttributes;
616
+ _withMetadata;
617
+ _withPayload;
618
+ /**
619
+ * Sets the withAttributes flag which will return the attributes for the entities if true
620
+ * @param withAttributes - The boolean value to set
621
+ * @returns The QueryBuilder instance
622
+ *
623
+ * @example
624
+ * const builder = client.buildQuery()
625
+ * builder.withAttributes(true)
626
+ */
627
+ withAttributes(withAttributes = true) {
628
+ this._withAttributes = withAttributes;
629
+ return this;
630
+ }
631
+ /**
632
+ * Sets the withMetadata flag which will return the metadata (like owner, expiredAt, etc.) for the entities if true
633
+ * @param withMetadata - The boolean value to set
634
+ * @returns The QueryBuilder instance
635
+ *
636
+ * @example
637
+ * const builder = client.buildQuery()
638
+ * builder.withMetadata(true)
639
+ */
640
+ withMetadata(withMetadata = true) {
641
+ this._withMetadata = withMetadata;
642
+ return this;
643
+ }
644
+ /**
645
+ * Sets the withPayload flag which will return the payload for the entities if true
646
+ * @param withPayload - The boolean value to set
647
+ * @returns The QueryBuilder instance
648
+ *
649
+ * @example
650
+ * const builder = client.buildQuery()
651
+ * builder.withPayload(true)
652
+ */
653
+ withPayload(withPayload = true) {
654
+ this._withPayload = withPayload;
655
+ return this;
656
+ }
657
+ selectionParams() {
658
+ return {
659
+ withAttributes: this._withAttributes,
660
+ withMetadata: this._withMetadata,
661
+ withPayload: this._withPayload
662
+ };
663
+ }
664
+ projectEntity(rpcEntity) {
665
+ return entityFromRpcResult(rpcEntity);
666
+ }
667
+ };
668
+ /**
669
+ * SelectQueryBuilder is the recommended query builder. It requires the selection to be declared
670
+ * up front, so results always contain exactly the data you asked for — and the type of each
671
+ * returned entity is narrowed to exactly the selected fields.
672
+ *
673
+ * The selection is fixed at construction time and is flat — each field maps to an entity field.
674
+ * Create one via `client.select(...)` rather than constructing it directly, so the result type is
675
+ * inferred from the selection.
676
+ *
677
+ * @typeParam TEntity - The projected entity shape, inferred from the selection by `client.select()`.
678
+ *
679
+ * @example
680
+ * // everything
681
+ * await client.select().where(eq("name", "John")).fetch()
682
+ * await client.select("*").where(eq("name", "John")).fetch()
683
+ * // specific fields
684
+ * await client.select({ owner: true, attributes: true }).fetch()
685
+ * // a single field — result is typed (flat) { owner: Hex }
686
+ * await client.select({ owner: true }).fetch()
687
+ */
688
+ var SelectQueryBuilder = class extends BaseQueryBuilder {
689
+ _includeData;
690
+ constructor(client, selection) {
691
+ super(client);
692
+ this._includeData = selectionToIncludeData(selection);
693
+ }
694
+ selectionParams() {
695
+ return { includeData: this._includeData };
696
+ }
697
+ async projectEntity(rpcEntity) {
698
+ return await entityFromRpcResult(rpcEntity);
699
+ }
700
+ };
581
701
 
582
702
  //#endregion
703
+ Object.defineProperty(exports, 'BaseQueryBuilder', {
704
+ enumerable: true,
705
+ get: function () {
706
+ return BaseQueryBuilder;
707
+ }
708
+ });
583
709
  Object.defineProperty(exports, 'EntityMutationError', {
584
710
  enumerable: true,
585
711
  get: function () {
586
712
  return EntityMutationError;
587
713
  }
588
714
  });
715
+ Object.defineProperty(exports, 'InvalidAttributeError', {
716
+ enumerable: true,
717
+ get: function () {
718
+ return InvalidAttributeError;
719
+ }
720
+ });
721
+ Object.defineProperty(exports, 'InvalidExpirationError', {
722
+ enumerable: true,
723
+ get: function () {
724
+ return InvalidExpirationError;
725
+ }
726
+ });
589
727
  Object.defineProperty(exports, 'NoCursorOrLimitError', {
590
728
  enumerable: true,
591
729
  get: function () {
@@ -616,6 +754,12 @@ Object.defineProperty(exports, 'QueryResult', {
616
754
  return QueryResult;
617
755
  }
618
756
  });
757
+ Object.defineProperty(exports, 'SelectQueryBuilder', {
758
+ enumerable: true,
759
+ get: function () {
760
+ return SelectQueryBuilder;
761
+ }
762
+ });
619
763
  Object.defineProperty(exports, 'asc', {
620
764
  enumerable: true,
621
765
  get: function () {
@@ -639,4 +783,10 @@ Object.defineProperty(exports, 'getLogger', {
639
783
  get: function () {
640
784
  return getLogger;
641
785
  }
786
+ });
787
+ Object.defineProperty(exports, 'selectionToIncludeData', {
788
+ enumerable: true,
789
+ get: function () {
790
+ return selectionToIncludeData;
791
+ }
642
792
  });
@@ -1,2 +1,2 @@
1
- import { A as RpcIncludeData, C as CreateEntityReturnType, E as GetBlockTimingReturnType, M as RpcQueryOptions, N as MimeType, O as ArkivRpcSchema, S as CreateEntityParameters, T as ChangeOwnershipReturnType, _ as UpdateEntityReturnType, a as Entity, b as DeleteEntityParameters, c as OnEntityDeletedEvent, d as OnEntityOwnerChangedEvent, f as OnEntityUpdatedEvent, g as UpdateEntityParameters, h as MutateEntitiesReturnType, i as QueryReturnType, j as RpcOrderByAttribute, k as RpcEntity, l as OnEntityExpiredEvent, m as MutateEntitiesParameters, n as QueryOptionsIncludeData, o as TxParams, p as Attribute, r as QueryOptionsOrderBy, s as OnEntityCreatedEvent, t as QueryOptions, u as OnEntityExpiresInExtendedEvent, v as ExtendEntityParameters, w as ChangeOwnershipParameters, x as DeleteEntityReturnType, y as ExtendEntityReturnType } from "../query-CO6f35AE.cjs";
1
+ import { A as RpcIncludeData, C as QueryOptionsIncludeData, E as GetBlockTimingReturnType, M as RpcQueryOptions, N as MimeType, O as ArkivRpcSchema, S as QueryOptions, T as QueryReturnType, _ as DeleteEntityReturnType, a as OnEntityExpiredEvent, b as ChangeOwnershipParameters, c as OnEntityUpdatedEvent, d as MutateEntitiesReturnType, f as UpdateEntityParameters, g as DeleteEntityParameters, h as ExtendEntityReturnType, i as OnEntityDeletedEvent, j as RpcOrderByAttribute, k as RpcEntity, l as Attribute, m as ExtendEntityParameters, n as TxParams, o as OnEntityExpiresInExtendedEvent, p as UpdateEntityReturnType, r as OnEntityCreatedEvent, s as OnEntityOwnerChangedEvent, t as Entity, u as MutateEntitiesParameters, v as CreateEntityParameters, w as QueryOptionsOrderBy, x as ChangeOwnershipReturnType, y as CreateEntityReturnType } from "../entity-B6g_EPm1.cjs";
2
2
  export { ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType };
@@ -1,2 +1,2 @@
1
- import { A as RpcIncludeData, C as CreateEntityReturnType, E as GetBlockTimingReturnType, M as RpcQueryOptions, N as MimeType, O as ArkivRpcSchema, S as CreateEntityParameters, T as ChangeOwnershipReturnType, _ as UpdateEntityReturnType, a as Entity, b as DeleteEntityParameters, c as OnEntityDeletedEvent, d as OnEntityOwnerChangedEvent, f as OnEntityUpdatedEvent, g as UpdateEntityParameters, h as MutateEntitiesReturnType, i as QueryReturnType, j as RpcOrderByAttribute, k as RpcEntity, l as OnEntityExpiredEvent, m as MutateEntitiesParameters, n as QueryOptionsIncludeData, o as TxParams, p as Attribute, r as QueryOptionsOrderBy, s as OnEntityCreatedEvent, t as QueryOptions, u as OnEntityExpiresInExtendedEvent, v as ExtendEntityParameters, w as ChangeOwnershipParameters, x as DeleteEntityReturnType, y as ExtendEntityReturnType } from "../query-BhdmAzYg.js";
1
+ import { A as RpcIncludeData, C as QueryOptionsIncludeData, E as GetBlockTimingReturnType, M as RpcQueryOptions, N as MimeType, O as ArkivRpcSchema, S as QueryOptions, T as QueryReturnType, _ as DeleteEntityReturnType, a as OnEntityExpiredEvent, b as ChangeOwnershipParameters, c as OnEntityUpdatedEvent, d as MutateEntitiesReturnType, f as UpdateEntityParameters, g as DeleteEntityParameters, h as ExtendEntityReturnType, i as OnEntityDeletedEvent, j as RpcOrderByAttribute, k as RpcEntity, l as Attribute, m as ExtendEntityParameters, n as TxParams, o as OnEntityExpiresInExtendedEvent, p as UpdateEntityReturnType, r as OnEntityCreatedEvent, s as OnEntityOwnerChangedEvent, t as Entity, u as MutateEntitiesParameters, v as CreateEntityParameters, w as QueryOptionsOrderBy, x as ChangeOwnershipReturnType, y as CreateEntityReturnType } from "../entity-qoLMAuuk.js";
2
2
  export { ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType };
@@ -1,4 +1,5 @@
1
- const require_payload = require('../payload-vwU3Rc6P.cjs');
1
+ const require_consts = require('../consts-AUoL-v42.cjs');
2
+ const require_payload = require('../payload-DpA5PA-w.cjs');
2
3
 
3
4
  //#region src/utils/expirationTime.ts
4
5
  const ExpirationTime = {
@@ -9,18 +10,11 @@ const ExpirationTime = {
9
10
  fromWeeks: (weeks) => weeks * 7 * 24 * 60 * 60,
10
11
  fromMonths: (months) => months * 30 * 24 * 60 * 60,
11
12
  fromYears: (years) => years * 365 * 24 * 60 * 60,
12
- fromBlocks: (blocks) => blocks * require_payload.BLOCK_TIME,
13
+ fromBlocks: (blocks) => blocks * require_consts.BLOCK_TIME,
13
14
  fromDate: (date) => Math.floor(date.getTime() / 1e3) - Math.floor(Date.now() / 1e3)
14
15
  };
15
16
 
16
17
  //#endregion
17
18
  exports.ExpirationTime = ExpirationTime;
18
19
  exports.jsonToPayload = require_payload.jsonToPayload;
19
- exports.stringToPayload = require_payload.stringToPayload;
20
- var viem_utils = require("viem/utils");
21
- Object.keys(viem_utils).forEach(function (k) {
22
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
23
- enumerable: true,
24
- get: function () { return viem_utils[k]; }
25
- });
26
- });
20
+ exports.stringToPayload = require_payload.stringToPayload;
@@ -1,5 +1,4 @@
1
1
  import { n as stringToPayload, t as jsonToPayload } from "../payload-CJN8fTvX.cjs";
2
- export * from "viem/utils";
3
2
 
4
3
  //#region src/utils/expirationTime.d.ts
5
4
  declare const ExpirationTime: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":[],"mappings":";;;;cAEa;;;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;mBAAJ"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;;;mBAAJ"}
@@ -1,5 +1,4 @@
1
- import { n as stringToPayload, t as jsonToPayload } from "../payload-Da9gJMG5.js";
2
- export * from "viem/utils";
1
+ import { n as stringToPayload, t as jsonToPayload } from "../payload-B2kFJyah.js";
3
2
 
4
3
  //#region src/utils/expirationTime.d.ts
5
4
  declare const ExpirationTime: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":[],"mappings":";;;;cAEa;;;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;mBAAJ"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;;;mBAAJ"}
@@ -1,6 +1,5 @@
1
- import { i as BLOCK_TIME, n as stringToPayload, t as jsonToPayload } from "../payload-DKBYYjeA.js";
2
-
3
- export * from "viem/utils"
1
+ import { n as BLOCK_TIME } from "../consts-BV4PR-de.js";
2
+ import { n as stringToPayload, t as jsonToPayload } from "../payload-Claf2jUO.js";
4
3
 
5
4
  //#region src/utils/expirationTime.ts
6
5
  const ExpirationTime = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":["import { BLOCK_TIME } from \"../consts\"\n\nexport const ExpirationTime = {\n fromSeconds: (seconds: number) => seconds,\n fromMinutes: (minutes: number) => minutes * 60,\n fromHours: (hours: number) => hours * 60 * 60,\n fromDays: (days: number) => days * 24 * 60 * 60,\n fromWeeks: (weeks: number) => weeks * 7 * 24 * 60 * 60,\n fromMonths: (months: number) => months * 30 * 24 * 60 * 60,\n fromYears: (years: number) => years * 365 * 24 * 60 * 60,\n fromBlocks: (blocks: number) => blocks * BLOCK_TIME,\n fromDate: (date: Date) => Math.floor(date.getTime() / 1000) - Math.floor(Date.now() / 1000),\n}\n"],"mappings":";;;;;AAEA,MAAa,iBAAiB;CAC5B,cAAc,YAAoB;CAClC,cAAc,YAAoB,UAAU;CAC5C,YAAY,UAAkB,QAAQ,KAAK;CAC3C,WAAW,SAAiB,OAAO,KAAK,KAAK;CAC7C,YAAY,UAAkB,QAAQ,IAAI,KAAK,KAAK;CACpD,aAAa,WAAmB,SAAS,KAAK,KAAK,KAAK;CACxD,YAAY,UAAkB,QAAQ,MAAM,KAAK,KAAK;CACtD,aAAa,WAAmB,SAAS;CACzC,WAAW,SAAe,KAAK,MAAM,KAAK,SAAS,GAAG,IAAK,GAAG,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;CAC5F"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":["import { BLOCK_TIME } from \"../consts\"\n\nexport const ExpirationTime = {\n fromSeconds: (seconds: number) => seconds,\n fromMinutes: (minutes: number) => minutes * 60,\n fromHours: (hours: number) => hours * 60 * 60,\n fromDays: (days: number) => days * 24 * 60 * 60,\n fromWeeks: (weeks: number) => weeks * 7 * 24 * 60 * 60,\n fromMonths: (months: number) => months * 30 * 24 * 60 * 60,\n fromYears: (years: number) => years * 365 * 24 * 60 * 60,\n fromBlocks: (blocks: number) => blocks * BLOCK_TIME,\n fromDate: (date: Date) => Math.floor(date.getTime() / 1000) - Math.floor(Date.now() / 1000),\n}\n"],"mappings":";;;;AAEA,MAAa,iBAAiB;CAC5B,cAAc,YAAoB;CAClC,cAAc,YAAoB,UAAU;CAC5C,YAAY,UAAkB,QAAQ,KAAK;CAC3C,WAAW,SAAiB,OAAO,KAAK,KAAK;CAC7C,YAAY,UAAkB,QAAQ,IAAI,KAAK,KAAK;CACpD,aAAa,WAAmB,SAAS,KAAK,KAAK,KAAK;CACxD,YAAY,UAAkB,QAAQ,MAAM,KAAK,KAAK;CACtD,aAAa,WAAmB,SAAS;CACzC,WAAW,SAAe,KAAK,MAAM,KAAK,SAAS,GAAG,IAAK,GAAG,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;CAC5F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkiv-network/sdk",
3
- "version": "0.6.8",
3
+ "version": "0.7.0",
4
4
  "description": "TypeScript client library for Arkiv's blockchains interactions",
5
5
  "type": "module",
6
6
  "target": "esnext",
@@ -15,12 +15,6 @@
15
15
  "require": "./dist/index.cjs",
16
16
  "default": "./dist/index.js"
17
17
  },
18
- "./accounts": {
19
- "bun": "./src/accounts/index.ts",
20
- "import": "./dist/accounts/index.js",
21
- "require": "./dist/accounts/index.cjs",
22
- "default": "./dist/accounts/index.js"
23
- },
24
18
  "./chains": {
25
19
  "bun": "./src/chains/index.ts",
26
20
  "import": "./dist/chains/index.js",
@@ -52,9 +46,6 @@
52
46
  "chains": [
53
47
  "./dist/_types/chains/index.d.ts"
54
48
  ],
55
- "accounts": [
56
- "./dist/_types/accounts/index.d.ts"
57
- ],
58
49
  "utils": [
59
50
  "./dist/_types/utils/index.d.ts"
60
51
  ],
@@ -90,13 +81,20 @@
90
81
  "@types/bun": "latest",
91
82
  "rimraf": "^6.0.1",
92
83
  "tsdown": "^0.16.0",
93
- "typedoc": "^0.28.14"
84
+ "typedoc": "^0.28.14",
85
+ "typedoc-plugin-markdown": "^4.9.0",
86
+ "typescript": "^5.9.2",
87
+ "viem": "^2.38.2"
94
88
  },
95
89
  "peerDependencies": {
96
- "typescript": "^5.0.0"
90
+ "typescript": ">=5.0.0",
91
+ "viem": "^2.0.0"
97
92
  },
98
93
  "peerDependenciesMeta": {
99
94
  "typescript": {
95
+ "optional": true
96
+ },
97
+ "viem": {
100
98
  "optional": false
101
99
  }
102
100
  },
@@ -118,8 +116,6 @@
118
116
  },
119
117
  "homepage": "https://arkiv.network",
120
118
  "dependencies": {
121
- "brotli-wasm": "^3.0.1",
122
- "typedoc-plugin-markdown": "^4.9.0",
123
- "viem": "^2.38.2"
119
+ "brotli-wasm": "^3.0.1"
124
120
  }
125
121
  }
@@ -1,6 +1,10 @@
1
1
  import type { ArkivClient } from "../../clients/baseClient"
2
2
  import { QueryBuilder } from "../../query/queryBuilder"
3
3
 
4
+ /**
5
+ * @deprecated Use `client.select()` (see SelectQueryBuilder) instead. `buildQuery()` returns
6
+ * only the entity `key` unless data is explicitly opted in to, which is an easy mistake.
7
+ */
4
8
  export async function buildQuery(client: ArkivClient) {
5
9
  return new QueryBuilder(client)
6
10
  }