@arkiv-network/sdk 0.6.1 → 0.6.2-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.
package/README.md CHANGED
@@ -83,7 +83,7 @@ npm install @arkiv-network/sdk
83
83
  This command will update your `package.json` with a section like:
84
84
  ```json
85
85
  "dependencies": {
86
- "@arkiv-network/sdk": "^0.4.4"
86
+ "@arkiv-network/sdk": "^0.6.0"
87
87
  }
88
88
  ```
89
89
  It will also create a `node_modules` directory with all dependencies installed.
@@ -1,4 +1,4 @@
1
- import * as viem8 from "viem";
1
+ import * as viem35 from "viem";
2
2
 
3
3
  //#region src/chains/kaolin.d.ts
4
4
  declare const kaolin: {
@@ -11,13 +11,13 @@ declare const kaolin: {
11
11
  };
12
12
  blockTime?: number | undefined | undefined;
13
13
  contracts?: {
14
- [x: string]: viem8.ChainContract | {
15
- [sourceId: number]: viem8.ChainContract | undefined;
14
+ [x: string]: viem35.ChainContract | {
15
+ [sourceId: number]: viem35.ChainContract | undefined;
16
16
  } | undefined;
17
- ensRegistry?: viem8.ChainContract | undefined;
18
- ensUniversalResolver?: viem8.ChainContract | undefined;
19
- multicall3?: viem8.ChainContract | undefined;
20
- erc6492Verifier?: viem8.ChainContract | undefined;
17
+ ensRegistry?: viem35.ChainContract | undefined;
18
+ ensUniversalResolver?: viem35.ChainContract | undefined;
19
+ multicall3?: viem35.ChainContract | undefined;
20
+ erc6492Verifier?: viem35.ChainContract | undefined;
21
21
  } | undefined;
22
22
  ensTlds?: readonly string[] | undefined;
23
23
  id: 60138453025;
@@ -37,9 +37,9 @@ declare const kaolin: {
37
37
  sourceId?: number | undefined | undefined;
38
38
  testnet: true;
39
39
  custom?: Record<string, unknown> | undefined;
40
- fees?: viem8.ChainFees<undefined> | undefined;
40
+ fees?: viem35.ChainFees<undefined> | undefined;
41
41
  formatters?: undefined;
42
- serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
42
+ serializers?: viem35.ChainSerializers<undefined, viem35.TransactionSerializable> | undefined;
43
43
  readonly network: "kaolin";
44
44
  };
45
45
  //#endregion
@@ -59,13 +59,13 @@ declare const localhost: {
59
59
  } | undefined | undefined;
60
60
  blockTime?: number | undefined | undefined;
61
61
  contracts?: {
62
- [x: string]: viem8.ChainContract | {
63
- [sourceId: number]: viem8.ChainContract | undefined;
62
+ [x: string]: viem35.ChainContract | {
63
+ [sourceId: number]: viem35.ChainContract | undefined;
64
64
  } | undefined;
65
- ensRegistry?: viem8.ChainContract | undefined;
66
- ensUniversalResolver?: viem8.ChainContract | undefined;
67
- multicall3?: viem8.ChainContract | undefined;
68
- erc6492Verifier?: viem8.ChainContract | undefined;
65
+ ensRegistry?: viem35.ChainContract | undefined;
66
+ ensUniversalResolver?: viem35.ChainContract | undefined;
67
+ multicall3?: viem35.ChainContract | undefined;
68
+ erc6492Verifier?: viem35.ChainContract | undefined;
69
69
  } | undefined;
70
70
  ensTlds?: readonly string[] | undefined;
71
71
  id: 1337;
@@ -84,9 +84,9 @@ declare const localhost: {
84
84
  sourceId?: number | undefined | undefined;
85
85
  testnet?: boolean | undefined | undefined;
86
86
  custom?: Record<string, unknown> | undefined;
87
- fees?: viem8.ChainFees<undefined> | undefined;
87
+ fees?: viem35.ChainFees<undefined> | undefined;
88
88
  formatters?: undefined;
89
- serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
89
+ serializers?: viem35.ChainSerializers<undefined, viem35.TransactionSerializable> | undefined;
90
90
  };
91
91
  //#endregion
92
92
  //#region src/chains/marketplace.d.ts
@@ -100,13 +100,13 @@ declare const marketplace: {
100
100
  };
101
101
  blockTime?: number | undefined | undefined;
102
102
  contracts?: {
103
- [x: string]: viem8.ChainContract | {
104
- [sourceId: number]: viem8.ChainContract | undefined;
103
+ [x: string]: viem35.ChainContract | {
104
+ [sourceId: number]: viem35.ChainContract | undefined;
105
105
  } | undefined;
106
- ensRegistry?: viem8.ChainContract | undefined;
107
- ensUniversalResolver?: viem8.ChainContract | undefined;
108
- multicall3?: viem8.ChainContract | undefined;
109
- erc6492Verifier?: viem8.ChainContract | undefined;
106
+ ensRegistry?: viem35.ChainContract | undefined;
107
+ ensUniversalResolver?: viem35.ChainContract | undefined;
108
+ multicall3?: viem35.ChainContract | undefined;
109
+ erc6492Verifier?: viem35.ChainContract | undefined;
110
110
  } | undefined;
111
111
  ensTlds?: readonly string[] | undefined;
112
112
  id: 60138453027;
@@ -126,9 +126,9 @@ declare const marketplace: {
126
126
  sourceId?: number | undefined | undefined;
127
127
  testnet: true;
128
128
  custom?: Record<string, unknown> | undefined;
129
- fees?: viem8.ChainFees<undefined> | undefined;
129
+ fees?: viem35.ChainFees<undefined> | undefined;
130
130
  formatters?: undefined;
131
- serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
131
+ serializers?: viem35.ChainSerializers<undefined, viem35.TransactionSerializable> | undefined;
132
132
  readonly network: "marketplace";
133
133
  };
134
134
  //#endregion
@@ -143,13 +143,13 @@ declare const mendoza: {
143
143
  };
144
144
  blockTime?: number | undefined | undefined;
145
145
  contracts?: {
146
- [x: string]: viem8.ChainContract | {
147
- [sourceId: number]: viem8.ChainContract | undefined;
146
+ [x: string]: viem35.ChainContract | {
147
+ [sourceId: number]: viem35.ChainContract | undefined;
148
148
  } | undefined;
149
- ensRegistry?: viem8.ChainContract | undefined;
150
- ensUniversalResolver?: viem8.ChainContract | undefined;
151
- multicall3?: viem8.ChainContract | undefined;
152
- erc6492Verifier?: viem8.ChainContract | undefined;
149
+ ensRegistry?: viem35.ChainContract | undefined;
150
+ ensUniversalResolver?: viem35.ChainContract | undefined;
151
+ multicall3?: viem35.ChainContract | undefined;
152
+ erc6492Verifier?: viem35.ChainContract | undefined;
153
153
  } | undefined;
154
154
  ensTlds?: readonly string[] | undefined;
155
155
  id: 60138453056;
@@ -169,9 +169,9 @@ declare const mendoza: {
169
169
  sourceId?: number | undefined | undefined;
170
170
  testnet: true;
171
171
  custom?: Record<string, unknown> | undefined;
172
- fees?: viem8.ChainFees<undefined> | undefined;
172
+ fees?: viem35.ChainFees<undefined> | undefined;
173
173
  formatters?: undefined;
174
- serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
174
+ serializers?: viem35.ChainSerializers<undefined, viem35.TransactionSerializable> | undefined;
175
175
  readonly network: "mendoza";
176
176
  };
177
177
  //#endregion
@@ -186,13 +186,13 @@ declare const rosario: {
186
186
  };
187
187
  blockTime?: number | undefined | undefined;
188
188
  contracts?: {
189
- [x: string]: viem8.ChainContract | {
190
- [sourceId: number]: viem8.ChainContract | undefined;
189
+ [x: string]: viem35.ChainContract | {
190
+ [sourceId: number]: viem35.ChainContract | undefined;
191
191
  } | undefined;
192
- ensRegistry?: viem8.ChainContract | undefined;
193
- ensUniversalResolver?: viem8.ChainContract | undefined;
194
- multicall3?: viem8.ChainContract | undefined;
195
- erc6492Verifier?: viem8.ChainContract | undefined;
192
+ ensRegistry?: viem35.ChainContract | undefined;
193
+ ensUniversalResolver?: viem35.ChainContract | undefined;
194
+ multicall3?: viem35.ChainContract | undefined;
195
+ erc6492Verifier?: viem35.ChainContract | undefined;
196
196
  } | undefined;
197
197
  ensTlds?: readonly string[] | undefined;
198
198
  id: 60138453057;
@@ -212,9 +212,9 @@ declare const rosario: {
212
212
  sourceId?: number | undefined | undefined;
213
213
  testnet: true;
214
214
  custom?: Record<string, unknown> | undefined;
215
- fees?: viem8.ChainFees<undefined> | undefined;
215
+ fees?: viem35.ChainFees<undefined> | undefined;
216
216
  formatters?: undefined;
217
- serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
217
+ serializers?: viem35.ChainSerializers<undefined, viem35.TransactionSerializable> | undefined;
218
218
  readonly network: "rosario";
219
219
  };
220
220
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/chains/kaolin.ts","../../src/chains/localhost.ts","../../src/chains/marketplace.ts","../../src/chains/mendoza.ts","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BAAA;MAAA,SAAA,GAAA,EAAA,8CAAA;;;;;;iBIAA,KAAA,CAAA,aAAA;;;;;;;;EHvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/chains/kaolin.ts","../../src/chains/localhost.ts","../../src/chains/marketplace.ts","../../src/chains/mendoza.ts","../../src/chains/rosario.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;MAAA,SAuBX,IAAA,EAAA,uBAAA;MAAA,SAAA,GAAA,EAAA,6CAAA;;;;;;iBAAA,MAAA,CAAA,aAAA;;;;;;;;ECvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA;;;;;;;;;cDvBW;;;MDAA,IAuBX,EAAA,MAAA;MAAA,GAAA,EAAA,MAAA;;;;;;;;;;;iBCZA,MAAA,CAAA,aAAA;;;IAXW,WAWX,CAAA,yBAAA,SAAA;IAAA,oBAAA,CAAA,yBAAA,SAAA;;;;;;;;;;;;;;ICXW,SAAA,OAuBX,EAAA;MAAA,SAAA,IAAA,EAAA,SAAA,CAAA,uBAAA,CAAA;;;;;;;;;;;;cAvBW;;;MFAA,SAuBX,IAAA,EAAA,4BAAA;MAAA,SAAA,GAAA,EAAA,kDAAA;;;;;;iBEAA,MAAA,CAAA,aAAA;;;;;;;;EDvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA;;;;;;;;;cCvBW;;;MHAA,SAuBX,IAAA,EAAA,wBAAA;MAAA,SAAA,GAAA,EAAA,8CAAA;;;;;;iBGAA,MAAA,CAAA,aAAA;;;;;;;;EFvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA;;;;;;;;;cEvBW;;;MJAA,SAuBX,IAAA,EAAA,wBAAA;MAAA,SAAA,GAAA,EAAA,8CAAA;;;;;;iBIAA,MAAA,CAAA,aAAA;;;;;;;;EHvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA"}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  const require_chains = require('./chains-K_cHr4a4.cjs');
2
- const require_queryBuilder = require('./queryBuilder-CE7didAc.cjs');
2
+ const require_queryBuilder = require('./queryBuilder-EbutFwI6.cjs');
3
3
  const require_payload = require('./payload-vwU3Rc6P.cjs');
4
4
  require('./types-o3zWarRp.cjs');
5
5
  let viem = require("viem");
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { A as RpcIncludeData, C as CreateEntityReturnType, D as ArkivClient, 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-fCVivD9L.cjs";
2
- import { n as QueryBuilder } from "./queryBuilder-DSWzci3Y.cjs";
2
+ import { n as QueryBuilder } from "./queryBuilder-D5eEPVnU.cjs";
3
3
  import { n as stringToPayload, t as jsonToPayload } from "./payload-CJN8fTvX.cjs";
4
4
  import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
5
5
  export * from "viem";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { A as RpcIncludeData, C as CreateEntityReturnType, D as ArkivClient, 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-BOF-ysxw.js";
2
- import { n as QueryBuilder } from "./queryBuilder-CAZQmp71.js";
2
+ import { n as QueryBuilder } from "./queryBuilder-DFaMq3oN.js";
3
3
  import { n as stringToPayload, t as jsonToPayload } from "./payload-Da9gJMG5.js";
4
4
  import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
5
5
  export * from "viem";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as chains_exports } from "./chains-CU-aTH5I.js";
2
- import { a as entityFromRpcResult, c as NoEntityFoundError, l as NoMoreResultsError, o as EntityMutationError, s as NoCursorOrLimitError, t as QueryBuilder, u as getLogger } from "./queryBuilder-UO2ZKHFN.js";
2
+ import { a as entityFromRpcResult, c as NoEntityFoundError, l as NoMoreResultsError, o as EntityMutationError, s as NoCursorOrLimitError, t as QueryBuilder, u as getLogger } from "./queryBuilder-C0qPebqD.js";
3
3
  import { i as BLOCK_TIME, n as stringToPayload, r as ARKIV_ADDRESS, t as jsonToPayload } from "./payload-DKBYYjeA.js";
4
4
  import "./types-H-TSmRpm.js";
5
5
  import { TransactionExecutionError, bytesToHex, createClient, decodeEventLog, hexToBytes, hexToString, numberToHex, parseAbi, publicActions, toBytes, toHex, toRlp, walletActions } from "viem";
@@ -1,4 +1,4 @@
1
- const require_queryBuilder = require('../queryBuilder-CE7didAc.cjs');
1
+ const require_queryBuilder = require('../queryBuilder-EbutFwI6.cjs');
2
2
 
3
3
  //#region src/query/predicate.ts
4
4
  /**
@@ -1,3 +1,3 @@
1
1
  import "../query-fCVivD9L.cjs";
2
- import { _ as or, a as QueryResult, c as PredicateType, d as gt, f as gte, g as not, h as neq, i as desc, l as and, m as lte, n as QueryBuilder, o as Predicate, p as lt, r as asc, s as PredicateContainerType, t as OrderByAttribute, u as eq } from "../queryBuilder-DSWzci3Y.cjs";
2
+ import { _ as or, a as QueryResult, c as PredicateType, d as gt, f as gte, g as not, h as neq, i as desc, l as and, m as lte, n as QueryBuilder, o as Predicate, p as lt, r as asc, s as PredicateContainerType, t as OrderByAttribute, u as eq } from "../queryBuilder-D5eEPVnU.cjs";
3
3
  export { OrderByAttribute, Predicate, PredicateContainerType, PredicateType, QueryBuilder, QueryResult, and, asc, desc, eq, gt, gte, lt, lte, neq, not, or };
@@ -1,3 +1,3 @@
1
1
  import "../query-BOF-ysxw.js";
2
- import { _ as or, a as QueryResult, c as PredicateType, d as gt, f as gte, g as not, h as neq, i as desc, l as and, m as lte, n as QueryBuilder, o as Predicate, p as lt, r as asc, s as PredicateContainerType, t as OrderByAttribute, u as eq } from "../queryBuilder-CAZQmp71.js";
2
+ import { _ as or, a as QueryResult, c as PredicateType, d as gt, f as gte, g as not, h as neq, i as desc, l as and, m as lte, n as QueryBuilder, o as Predicate, p as lt, r as asc, s as PredicateContainerType, t as OrderByAttribute, u as eq } from "../queryBuilder-DFaMq3oN.js";
3
3
  export { OrderByAttribute, Predicate, PredicateContainerType, PredicateType, QueryBuilder, QueryResult, and, asc, desc, eq, gt, gte, lt, lte, neq, not, or };
@@ -1,4 +1,4 @@
1
- import { i as QueryResult, n as asc, r as desc, t as QueryBuilder } from "../queryBuilder-UO2ZKHFN.js";
1
+ import { i as QueryResult, n as asc, r as desc, t as QueryBuilder } from "../queryBuilder-C0qPebqD.js";
2
2
 
3
3
  //#region src/query/predicate.ts
4
4
  /**
@@ -210,12 +210,13 @@ function processPredicates(predicates) {
210
210
  }).join(" && ");
211
211
  }
212
212
  async function processQuery(client, queryParams) {
213
- const { predicates, limit, cursor, ownedBy, orderBy, validAtBlock, withAttributes, withMetadata, withPayload } = queryParams;
213
+ const { predicates, limit, cursor, ownedBy, createdBy, orderBy, validAtBlock, withAttributes, withMetadata, withPayload } = queryParams;
214
214
  logger$1("Processing query with params %o", {
215
215
  predicates,
216
216
  cursor,
217
217
  limit,
218
218
  ownedBy,
219
+ createdBy,
219
220
  orderBy,
220
221
  validAtBlock,
221
222
  withAttributes,
@@ -224,6 +225,7 @@ async function processQuery(client, queryParams) {
224
225
  });
225
226
  let query = processPredicates(predicates);
226
227
  if (ownedBy) query += ` && $owner=${ownedBy}`;
228
+ if (createdBy) query += ` && $creator=${createdBy}`;
227
229
  query = query.trim();
228
230
  if (query.startsWith("&& ")) query = query.slice(3);
229
231
  const queryOptions = { includeData: {
@@ -340,6 +342,7 @@ function desc(attributeName, attributeType) {
340
342
  var QueryBuilder = class {
341
343
  _client;
342
344
  _ownedBy;
345
+ _createdBy;
343
346
  _orderBy;
344
347
  _validAtBlock;
345
348
  _withAttributes;
@@ -365,6 +368,19 @@ var QueryBuilder = class {
365
368
  this._ownedBy = ownedBy;
366
369
  return this;
367
370
  }
371
+ /**
372
+ * Sets the createdBy filter
373
+ * @param createdBy - The address of the creator
374
+ * @returns The QueryBuilder instance
375
+ *
376
+ * @example
377
+ * const builder = new QueryBuilder(client)
378
+ * builder.createdBy("0x1234567890123456789012345678901234567890")
379
+ */
380
+ createdBy(createdBy) {
381
+ this._createdBy = createdBy;
382
+ return this;
383
+ }
368
384
  orderBy(attributeNameOrOrderByAttribute, attributeType, order = "asc") {
369
385
  if (!this._orderBy) this._orderBy = [];
370
386
  const pushOrderByAttribute = ({ name, type, order: order$1 }) => {
@@ -500,6 +516,7 @@ var QueryBuilder = class {
500
516
  limit: this._limit,
501
517
  cursor: this._cursor,
502
518
  ownedBy: this._ownedBy,
519
+ createdBy: this._createdBy,
503
520
  orderBy: this._orderBy,
504
521
  validAtBlock: this._validAtBlock,
505
522
  withAttributes: this._withAttributes,
@@ -526,6 +543,7 @@ var QueryBuilder = class {
526
543
  limit: this._limit,
527
544
  cursor: this._cursor,
528
545
  ownedBy: this._ownedBy,
546
+ createdBy: this._createdBy,
529
547
  orderBy: void 0,
530
548
  validAtBlock: this._validAtBlock,
531
549
  withAttributes: false,
@@ -537,4 +555,4 @@ var QueryBuilder = class {
537
555
 
538
556
  //#endregion
539
557
  export { entityFromRpcResult as a, NoEntityFoundError as c, QueryResult as i, NoMoreResultsError as l, asc as n, EntityMutationError as o, desc as r, NoCursorOrLimitError as s, QueryBuilder as t, getLogger as u };
540
- //# sourceMappingURL=queryBuilder-UO2ZKHFN.js.map
558
+ //# sourceMappingURL=queryBuilder-C0qPebqD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryBuilder-C0qPebqD.js","names":["enabledNamespaces: Set<string>","disabledNamespaces: Set<string>","logger","logger","predicate","queryOptions: RpcQueryOptions","order"],"sources":["../src/utils/logger.ts","../src/errors.ts","../src/types/entity.ts","../src/utils/entities.ts","../src/query/engine.ts","../src/query/queryResult.ts","../src/query/queryBuilder.ts"],"sourcesContent":["const ROOT_NAMESPACE = \"arkiv\"\n\n// Debug logger type - returns a function that can be called to log messages\ntype DebugLogger = (...args: unknown[]) => void\n\n// Get DEBUG environment variable (works in both Node.js and browser)\nfunction getDebugEnv(): string {\n if (typeof process !== \"undefined\") {\n const debugEnv = process?.env?.DEBUG\n if (debugEnv) {\n return debugEnv\n }\n }\n // Browser: check localStorage\n if (typeof globalThis !== \"undefined\" && \"localStorage\" in globalThis) {\n try {\n const storage = (globalThis as { localStorage?: Storage }).localStorage\n return storage?.getItem(\"DEBUG\") || \"\"\n } catch {\n // localStorage might not be available\n }\n }\n return \"\"\n}\n\n// Parse debug patterns and check if a namespace matches\nfunction matchesPattern(namespace: string, pattern: string): boolean {\n // Exact match\n if (pattern === namespace) return true\n\n // Wildcard match: \"arkiv:*\" matches \"arkiv:query\", \"arkiv:rpc\", etc.\n if (pattern.endsWith(\"*\")) {\n const prefix = pattern.slice(0, -1)\n return namespace.startsWith(prefix)\n }\n\n // Negative match: \"-arkiv:query\" excludes \"arkiv:query\"\n if (pattern.startsWith(\"-\")) {\n const excludePattern = pattern.slice(1)\n return !matchesPattern(namespace, excludePattern)\n }\n\n return false\n}\n\n// Check if a namespace is enabled for debugging\nfunction isEnabled(namespace: string): boolean {\n const debugEnv = getDebugEnv()\n if (!debugEnv) return false\n\n // Split by comma/space and check each pattern\n const patterns = debugEnv.split(/[\\s,]+/).filter((p) => p.length > 0)\n\n // If no patterns, nothing is enabled\n if (patterns.length === 0) return false\n\n // Check if any pattern matches (or if explicitly excluded)\n let enabled = false\n for (const pattern of patterns) {\n if (pattern.startsWith(\"-\")) {\n // Exclude pattern - if it matches, disable\n if (matchesPattern(namespace, pattern)) {\n return false\n }\n } else if (matchesPattern(namespace, pattern)) {\n enabled = true\n }\n }\n\n return enabled\n}\n\n// Store enabled namespaces (for programmatic enable/disable)\nconst enabledNamespaces: Set<string> = new Set()\nconst disabledNamespaces: Set<string> = new Set()\n\n// Color palette for namespace coloring (distinct, readable colors)\nconst COLOR_PALETTE = [\n \"#0000FF\", // blue\n \"#008000\", // green\n \"#FF0000\", // red\n \"#FF00FF\", // magenta\n \"#FFA500\", // orange\n \"#800080\", // purple\n \"#00CED1\", // dark turquoise\n \"#FF1493\", // deep pink\n \"#32CD32\", // lime green\n \"#1E90FF\", // dodger blue\n \"#FF4500\", // orange red\n \"#9370DB\", // medium purple\n \"#00FA9A\", // medium spring green\n \"#FFD700\", // gold\n \"#DC143C\", // crimson\n \"#00BFFF\", // deep sky blue\n \"#FF69B4\", // hot pink\n \"#20B2AA\", // light sea green\n \"#DA70D6\", // orchid\n \"#4682B4\", // steel blue\n]\n\n// Detect if we're in Node.js (for ANSI colors) or browser (for CSS colors)\nconst isNode = typeof process !== \"undefined\" && process.versions?.node != null\n\n// ANSI color codes for Node.js (bright, distinct colors)\nconst ANSI_COLORS = [\n \"\\x1b[94m\", // bright blue\n \"\\x1b[92m\", // bright green\n \"\\x1b[91m\", // bright red\n \"\\x1b[95m\", // bright magenta\n \"\\x1b[93m\", // bright yellow\n \"\\x1b[96m\", // bright cyan\n \"\\x1b[35m\", // magenta\n \"\\x1b[36m\", // cyan\n \"\\x1b[32m\", // green\n \"\\x1b[34m\", // blue\n \"\\x1b[33m\", // yellow\n \"\\x1b[31m\", // red\n \"\\x1b[90m\", // bright black (gray)\n \"\\x1b[37m\", // white\n \"\\x1b[1m\", // bold (as a color option)\n]\n\nconst ANSI_RESET = \"\\x1b[0m\"\nconst ANSI_BOLD = \"\\x1b[1m\"\n\n// Cache colors for namespaces (same namespace = same color)\nconst namespaceColors = new Map<string, { css: string; ansi: string }>()\n\n// Generate a consistent color for a namespace based on its hash\nfunction getColorForNamespace(namespace: string): { css: string; ansi: string } {\n // Check cache first\n const cachedColor = namespaceColors.get(namespace)\n if (cachedColor) {\n return cachedColor\n }\n\n // Simple hash function to convert string to number\n let hash = 0\n for (let i = 0; i < namespace.length; i++) {\n const char = namespace.charCodeAt(i)\n hash = (hash << 5) - hash + char\n hash = hash & hash // Convert to 32-bit integer\n }\n\n // Use absolute value and modulo to get index\n const colorIndex = Math.abs(hash) % COLOR_PALETTE.length\n const cssColor = COLOR_PALETTE[colorIndex]\n const ansiColor = ANSI_COLORS[colorIndex % ANSI_COLORS.length]\n\n const color = { css: cssColor, ansi: ansiColor }\n\n // Cache the color\n namespaceColors.set(namespace, color)\n\n return color\n}\n\n// Create a debug logger function\nfunction createDebugLogger(namespace: string): DebugLogger {\n // Get the color for this namespace (consistent across calls)\n const colors = getColorForNamespace(namespace)\n\n return (...args: unknown[]) => {\n // Check if enabled via environment variable or programmatically\n const envEnabled = isEnabled(namespace)\n const progEnabled = enabledNamespaces.has(namespace) && !disabledNamespaces.has(namespace)\n\n if (envEnabled || progEnabled) {\n if (isNode) {\n // Node.js: use ANSI color codes\n const coloredNamespace = `${ANSI_BOLD}${colors.ansi}${namespace}${ANSI_RESET}`\n console.log(coloredNamespace, ...args)\n } else {\n // Browser: use CSS styling with %c\n // The format is: console.log(\"%cstyled%cnormal\", style1, style2, ...args)\n // This colors the namespace, then resets for the rest\n const style1 = `color: ${colors.css}; font-weight: bold`\n const style2 = \"color: inherit; font-weight: normal\"\n // Combine namespace with a space, then log with styles\n console.log(`%c${namespace}%c`, style1, style2, ...args)\n }\n }\n }\n}\n\nexport const getLogger = (scope: string): DebugLogger => {\n const namespace = `${ROOT_NAMESPACE}:${scope}`\n return createDebugLogger(namespace)\n}\n\nexport const enableDebug = (namespaces: string): void => {\n // Parse and add namespaces to enabled set\n const patterns = namespaces.split(/[\\s,]+/).filter((p) => p.length > 0)\n for (const pattern of patterns) {\n if (pattern.startsWith(\"-\")) {\n // Remove from enabled, add to disabled\n const namespace = pattern.slice(1)\n enabledNamespaces.delete(namespace)\n disabledNamespaces.add(namespace)\n } else {\n enabledNamespaces.add(pattern)\n disabledNamespaces.delete(pattern)\n }\n }\n}\n\nexport const disableDebug = (): void => {\n enabledNamespaces.clear()\n disabledNamespaces.clear()\n}\n","export class EntityMutationError extends Error {\n constructor(message: string) {\n super(message)\n this.name = \"EntityMutationError\"\n }\n}\n\nexport class NoMoreResultsError extends Error {\n constructor() {\n super(\"No more results\")\n this.name = \"NoMoreResultsError\"\n }\n}\n\nexport class NoCursorOrLimitError extends Error {\n constructor() {\n super(\"Cursor and limit must be defined to fetch next\")\n this.name = \"NoCursorOrLimitError\"\n }\n}\n\nexport class NoEntityFoundError extends Error {\n constructor() {\n super(\"No entity found\")\n this.name = \"NoEntityFoundError\"\n }\n}\n","import { bytesToString, type Hex } from \"viem\"\nimport type { MimeType } from \"../types\"\nimport type { Attribute } from \"./attributes\"\n\nexport class Entity {\n key: Hex\n contentType: MimeType | undefined\n owner: Hex | undefined\n expiresAtBlock: bigint | undefined\n createdAtBlock: bigint | undefined\n lastModifiedAtBlock: bigint | undefined\n transactionIndexInBlock: bigint | undefined\n operationIndexInTransaction: bigint | undefined\n payload: Uint8Array | undefined\n attributes: Attribute[]\n\n constructor(\n key: Hex,\n contentType: MimeType | undefined = undefined,\n owner: Hex | undefined = undefined,\n expiresAtBlock: bigint | undefined = undefined,\n createdAtBlock: bigint | undefined = undefined,\n lastModifiedAtBlock: bigint | undefined = undefined,\n transactionIndexInBlock: bigint | undefined = undefined,\n operationIndexInTransaction: bigint | undefined = undefined,\n payload: Uint8Array | undefined = undefined,\n attributes: Attribute[],\n ) {\n this.key = key\n this.owner = owner\n this.expiresAtBlock = expiresAtBlock\n this.createdAtBlock = createdAtBlock\n this.lastModifiedAtBlock = lastModifiedAtBlock\n this.transactionIndexInBlock = transactionIndexInBlock\n this.operationIndexInTransaction = operationIndexInTransaction\n this.payload = payload\n this.attributes = attributes\n this.contentType = contentType\n }\n\n toText(): string {\n return this.payload ? bytesToString(this.payload) : \"\"\n }\n\n toJson(): any {\n return this.payload ? JSON.parse(bytesToString(this.payload)) : {}\n }\n}\n","import { toBytes } from \"viem\"\nimport { Entity } from \"../types/entity\"\nimport type { RpcEntity } from \"../types/rpcSchema\"\nimport { getLogger } from \"./logger\"\n\nconst logger = getLogger(\"utils:entities\")\n\nexport async function entityFromRpcResult(rpcEntity: RpcEntity) {\n logger(\"entityFromRpcResult %o\", rpcEntity)\n\n return new Entity(\n rpcEntity.key,\n rpcEntity.contentType,\n rpcEntity.owner,\n rpcEntity.expiresAt !== undefined ? BigInt(rpcEntity.expiresAt) : undefined,\n rpcEntity.createdAtBlock !== undefined ? BigInt(rpcEntity.createdAtBlock) : undefined,\n rpcEntity.lastModifiedAtBlock !== undefined ? BigInt(rpcEntity.lastModifiedAtBlock) : undefined,\n rpcEntity.transactionIndexInBlock !== undefined\n ? BigInt(rpcEntity.transactionIndexInBlock)\n : undefined,\n rpcEntity.operationIndexInTransaction !== undefined\n ? BigInt(rpcEntity.operationIndexInTransaction)\n : undefined,\n rpcEntity.value !== undefined ? toBytes(rpcEntity.value) : undefined,\n [\n ...(rpcEntity.stringAttributes ?? []).map(({ key, value }) => ({\n key,\n value,\n })),\n ...(rpcEntity.numericAttributes ?? []).map(({ key, value }) => ({\n key,\n value: Number(value),\n })),\n ],\n )\n}\n","import type { Hex } from \"viem\"\nimport { hexToNumber, numberToHex } from \"viem\"\nimport type { ArkivClient } from \"../clients/baseClient\"\nimport type { RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions } from \"../types/rpcSchema\"\nimport { getLogger } from \"../utils/logger\"\nimport type { Predicate } from \"./predicate\"\n\nconst logger = getLogger(\"query:engine\")\n\nfunction processPredicates(predicates: Predicate[]): string {\n const processValue = (value: string | number) => {\n if (typeof value === \"string\") {\n return `\"${value}\"`\n }\n return value\n }\n return predicates\n .map((predicate) => {\n switch (predicate.type) {\n case \"eq\":\n return `${predicate.key} = ${processValue(predicate.value)}`\n case \"neq\":\n return `${predicate.key} != ${processValue(predicate.value)}`\n case \"gt\":\n return `${predicate.key} > ${processValue(predicate.value)}`\n case \"gte\":\n return `${predicate.key} >= ${processValue(predicate.value)}`\n case \"lt\":\n return `${predicate.key} < ${processValue(predicate.value)}`\n case \"lte\":\n return `${predicate.key} <= ${processValue(predicate.value)}`\n case \"not\":\n return `!${predicate.key}`\n case \"or\":\n return `(${predicate.predicates.map((predicate) => processPredicates([predicate])).join(\" || \")})`\n case \"and\":\n return `(${predicate.predicates.map((predicate) => processPredicates([predicate])).join(\" && \")})`\n default:\n return \"\"\n }\n })\n .join(\" && \")\n}\n\nexport async function processQuery(\n client: ArkivClient,\n queryParams: {\n predicates: Predicate[]\n limit: number | undefined\n cursor: string | undefined\n ownedBy: Hex | undefined\n createdBy: Hex | undefined\n orderBy: RpcOrderByAttribute[] | undefined\n validAtBlock?: bigint | undefined\n withAttributes?: boolean | undefined\n withMetadata?: boolean | undefined\n withPayload?: boolean | undefined\n },\n) {\n const {\n predicates,\n limit,\n cursor,\n ownedBy,\n createdBy,\n orderBy,\n validAtBlock,\n withAttributes,\n withMetadata,\n withPayload,\n } = queryParams\n\n logger(\"Processing query with params %o\", {\n predicates,\n cursor,\n limit,\n ownedBy,\n createdBy,\n orderBy,\n validAtBlock,\n withAttributes,\n withMetadata,\n withPayload,\n })\n\n let query = processPredicates(predicates)\n if (ownedBy) {\n query += ` && $owner=${ownedBy}`\n }\n if (createdBy) {\n query += ` && $creator=${createdBy}`\n }\n\n // remove leading and trailing spaces and leading &&\n query = query.trim()\n if (query.startsWith(\"&& \")) {\n query = query.slice(3)\n }\n\n const queryOptions: RpcQueryOptions = {\n includeData: {\n key: true,\n attributes: withAttributes ?? false,\n payload: withPayload ?? false,\n contentType: withMetadata ?? false,\n expiration: withMetadata ?? false,\n owner: withMetadata ?? false,\n createdAtBlock: withMetadata ?? false,\n lastModifiedAtBlock: withMetadata ?? false,\n transactionIndexInBlock: withMetadata ?? false,\n operationIndexInTransaction: withMetadata ?? false,\n } as RpcIncludeData,\n }\n\n if (validAtBlock !== undefined) {\n queryOptions.atBlock = numberToHex(validAtBlock)\n }\n if (limit !== undefined) {\n queryOptions.resultsPerPage = numberToHex(limit)\n }\n if (cursor !== undefined) {\n queryOptions.cursor = cursor\n }\n if (orderBy !== undefined) {\n queryOptions.orderBy = orderBy\n }\n\n logger(\"Built query to send %s %o\", query, {\n includeData: queryOptions.includeData,\n atBlock: queryOptions.atBlock ? hexToNumber(queryOptions.atBlock) : undefined,\n orderBy: queryOptions.orderBy,\n resultsPerPage: queryOptions.resultsPerPage,\n cursor: queryOptions.cursor,\n })\n\n const result = await client.request({\n method: \"arkiv_query\",\n params: [query, queryOptions],\n })\n logger(\"Raw result from query %o\", result)\n\n return result\n}\n","import { NoCursorOrLimitError, NoMoreResultsError } from \"../errors\"\nimport type { Entity } from \"../types/entity\"\nimport { getLogger } from \"../utils/logger\"\nimport type { QueryBuilder } from \"./queryBuilder\"\n\nconst logger = getLogger(\"query:result\")\n\nexport class QueryResult {\n entities: Entity[]\n private _endOfIteration: boolean\n private _cursor: string | undefined\n private _limit: number | undefined\n private _validAtBlock: bigint | undefined\n private _queryBuilder: QueryBuilder\n\n // Public getters for internal state\n get queryBuilder(): QueryBuilder {\n return this._queryBuilder\n }\n\n get cursor(): string | undefined {\n return this._cursor\n }\n\n constructor(\n entities: Entity[],\n queryBuilder: QueryBuilder,\n cursor: string | undefined,\n limit: number | undefined,\n validAtBlock: bigint | undefined,\n ) {\n this.entities = entities\n this._queryBuilder = queryBuilder\n this._endOfIteration = !limit || entities.length < limit\n this._cursor = cursor\n this._limit = limit\n this._validAtBlock = validAtBlock\n }\n\n async next() {\n if (this._cursor === undefined || this._limit === undefined) {\n throw new NoCursorOrLimitError()\n }\n if (this._endOfIteration) {\n throw new NoMoreResultsError()\n }\n this._queryBuilder.cursor(this._cursor)\n const result = await this._queryBuilder.fetch()\n this.entities = result.entities\n // Update the query builder reference\n this._queryBuilder = result.queryBuilder\n // Check if we've reached the end (no more cursor or we got fewer entities than limit)\n this._endOfIteration = !result.cursor || result.entities.length < this._limit\n // Update the cursor\n this._cursor = result.cursor\n\n // TODO check current block height and if it is not too old\n logger(\"Current block height for next page %s\", this._validAtBlock?.toString() ?? \"unknown\")\n }\n\n hasNextPage() {\n return !this._endOfIteration\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../clients/baseClient\"\nimport type { RpcOrderByAttribute } from \"../types/rpcSchema\"\nimport { entityFromRpcResult } from \"../utils/entities\"\nimport { processQuery } from \"./engine\"\nimport type { Predicate } from \"./predicate\"\nimport { QueryResult } from \"./queryResult\"\n\nexport type OrderByAttribute = {\n name: string\n type: \"string\" | \"number\"\n order: \"asc\" | \"desc\"\n}\n\n/**\n * Helper function to create an ascending order by attribute\n * @param attributeName - The name of the attribute to order by\n * @param attributeType - The type of the attribute to order by (string or number)\n * @returns Input for orderBy method\n *\n * @example\n * const ascAttribute = asc(\"name\", \"string\")\n */\nexport function asc(attributeName: string, attributeType: \"string\" | \"number\"): OrderByAttribute {\n return {\n name: attributeName,\n type: attributeType,\n order: \"asc\",\n }\n}\n\n/**\n * Helper function to create a descending order by attribute\n * @param attributeName - The name of the attribute to order by\n * @param attributeType - The type of the attribute to order by (string or number)\n * @returns Input for orderBy method\n *\n * @example\n * const descAttribute = desc(\"name\", \"string\")\n */\nexport function desc(attributeName: string, attributeType: \"string\" | \"number\"): OrderByAttribute {\n return {\n name: attributeName,\n type: attributeType,\n order: \"desc\",\n }\n}\n/**\n * QueryBuilder is a helper class to build queries to the Arkiv DBChains.\n * It can be used to fetch entities from the Arkiv DBChains. It follows the Builder pattern allowing chaining of methods.\n * @param client - The Arkiv client\n * @returns The QueryBuilder instance {@link QueryBuilder}\n */\nexport class QueryBuilder {\n private _client: ArkivClient\n private _ownedBy: Hex | undefined\n private _createdBy: Hex | undefined\n private _orderBy: RpcOrderByAttribute[] | undefined\n private _validAtBlock: bigint | undefined\n private _withAttributes: boolean | undefined\n private _withMetadata: boolean | undefined\n private _withPayload: boolean | undefined\n private _limit: number | undefined\n private _cursor: string | undefined\n private _predicates: Predicate[]\n\n constructor(client: ArkivClient) {\n this._client = client\n this._predicates = []\n }\n\n /**\n * Sets the ownedBy filter\n * @param ownedBy - The address of the owner\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.ownedBy(\"0x1234567890123456789012345678901234567890\")\n */\n ownedBy(ownedBy: Hex) {\n this._ownedBy = ownedBy\n return this\n }\n\n /**\n * Sets the createdBy filter\n * @param createdBy - The address of the creator\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.createdBy(\"0x1234567890123456789012345678901234567890\")\n */\n createdBy(createdBy: Hex) {\n this._createdBy = createdBy\n return this\n }\n\n /**\n * Sets the orderBy for the query.\n * It can be called multiple times to order by multiple attributes.\n * The order of the attributes is important. The first attribute is the primary order by attribute.\n * You can use the helper functions asc() and desc() as input for this method.\n * @param attributeName - The name of the attribute to order by\n * @param attributeType - The type of the attribute to order by (string or number)\n * @param order - The order to set the order by (asc or desc)\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = client.buildQuery()\n * builder.orderBy(\"name\", \"string\", \"desc\")\n * builder.orderBy(asc(\"name\", \"string\"))\n * builder.orderBy(desc(\"name\", \"string\"))\n */\n orderBy(attributeName: string, attributeType: \"string\" | \"number\", order?: \"asc\" | \"desc\"): this\n /**\n * Sets the orderBy for the query.\n * This method takes the OrderByAttribute object as an argument and is mainly\n * used to use the helper functions asc() and desc() to create the OrderByAttribute instances.\n * @param orderByAttribute - The OrderByAttribute instance to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.orderBy(asc(\"name\", \"string\"))\n * builder.orderBy(desc(\"name\", \"string\"))\n */\n orderBy(orderByAttribute: OrderByAttribute): this\n orderBy(\n attributeNameOrOrderByAttribute: string | OrderByAttribute,\n attributeType?: \"string\" | \"number\",\n order: \"asc\" | \"desc\" = \"asc\",\n ) {\n if (!this._orderBy) {\n this._orderBy = []\n }\n\n const pushOrderByAttribute = ({ name, type, order }: OrderByAttribute) => {\n this._orderBy?.push({\n name,\n type: type === \"number\" ? \"numeric\" : type,\n desc: order === \"desc\",\n })\n }\n\n if (typeof attributeNameOrOrderByAttribute === \"string\") {\n if (!attributeType) {\n throw new Error(\"attributeType is required when using positional orderBy arguments\")\n }\n pushOrderByAttribute({\n name: attributeNameOrOrderByAttribute,\n type: attributeType,\n order,\n })\n } else {\n pushOrderByAttribute(attributeNameOrOrderByAttribute)\n }\n\n return this\n }\n\n /**\n * Sets the withAttributes flag which will return the attributes for the entities if true\n * @param withAttributes - The boolean value to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.withAttributes(true)\n */\n withAttributes(withAttributes: boolean = true) {\n this._withAttributes = withAttributes\n return this\n }\n\n /**\n * Sets the withMetadata flag which will return the metadata (like owner, expiredAt, etc.) for the entities if true\n * @param withMetadata - The boolean value to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.withMetadata(true)\n */\n withMetadata(withMetadata: boolean = true) {\n this._withMetadata = withMetadata\n return this\n }\n\n /**\n * Sets the withPayload flag which will return the payload for the entities if true\n * @param withPayload - The boolean value to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.withPayload(true)\n */\n withPayload(withPayload: boolean = true) {\n this._withPayload = withPayload\n return this\n }\n\n /**\n * Sets the limit for the query\n * @param limit - The number of entities to return\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.limit(10)\n */\n limit(limit: number) {\n this._limit = limit\n return this\n }\n\n /**\n * 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).\n * @param cursor - The cursor to set which tells to RPC Query server where to start or continue the query.\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.offset(10)\n */\n cursor(cursor: string) {\n this._cursor = cursor\n return this\n }\n\n /**\n * Sets the validAtBlock for the query which tells at which block height the state we are intested.\n * If not set, the latest block is used.\n * @param validAtBlock - The block number to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.validAtBlock(10000)\n */\n validAtBlock(validAtBlock: bigint) {\n this._validAtBlock = validAtBlock\n return this\n }\n\n /**\n * Sets the predicates for the query limiting the results. It can be a single predicate or an array of predicates combined with 'and'.\n * Predicates can be nested using 'or' and 'and' predicates.\n * @param predicates - The predicates to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.where(eq(\"name\", \"John\"))\n * builder.where([eq(\"name\", \"John\"), eq(\"age\", 30)])\n * builder.where([eq(\"name\", \"John\"), or([eq(\"age\", 30), eq(\"age\", 31)])])\n * builder.where([eq(\"name\", \"John\"), and([eq(\"age\", 30), eq(\"age\", 31)])])\n * builder.where([eq(\"name\", \"John\"), or([eq(\"age\", 30), and([eq(\"age\", 31), eq(\"age\", 32)])])])\n * builder.where([eq(\"name\", \"John\"), and([eq(\"age\", 30), or([eq(\"age\", 31), eq(\"age\", 32)])])])\n * builder.where([eq(\"name\", \"John\"), and([eq(\"age\", 30), or([eq(\"age\", 31), and([eq(\"age\", 32), eq(\"age\", 33)])])])])\n */\n where(predicates: Predicate[] | Predicate) {\n if (Array.isArray(predicates)) {\n this._predicates.push(...predicates)\n } else {\n this._predicates.push(predicates)\n }\n return this\n }\n\n /**\n * Fetches the entities from the query. Re\n * It will return a QueryResult instance which can be used to fetch the next and previous pages.\n * @returns The QueryResult instance {@link QueryResult}\n *\n * @example\n * const builder = new QueryBuilder(client)\n * const result = await builder.where(eq(\"name\", \"John\")).fetch()\n * // result = { entities: [Entity, Entity, Entity], next: async () => QueryResult, previous: async () => QueryResult }\n */\n async fetch() {\n const queryResult = await processQuery(this._client, {\n predicates: this._predicates,\n limit: this._limit,\n cursor: this._cursor,\n ownedBy: this._ownedBy,\n createdBy: this._createdBy,\n orderBy: this._orderBy,\n validAtBlock: this._validAtBlock,\n withAttributes: this._withAttributes,\n withMetadata: this._withMetadata,\n withPayload: this._withPayload,\n })\n\n const entities = await Promise.all(\n queryResult.data.map((entity) => entityFromRpcResult(entity)),\n )\n\n this.cursor(queryResult.cursor)\n this.validAtBlock(BigInt(queryResult.blockNumber ?? 0))\n\n return new QueryResult(entities, this, this._cursor, this._limit, this._validAtBlock)\n }\n\n /**\n * Counts the entities from the query.\n * @returns The number of entities\n *\n * @example\n * const builder = new QueryBuilder(client)\n * const result = await builder.where(eq(\"name\", \"John\")).count()\n * // result = 10\n */\n async count() {\n const queryResult = await processQuery(this._client, {\n predicates: this._predicates,\n limit: this._limit,\n cursor: this._cursor,\n ownedBy: this._ownedBy,\n createdBy: this._createdBy,\n orderBy: undefined,\n validAtBlock: this._validAtBlock,\n withAttributes: false,\n withMetadata: false,\n withPayload: false,\n })\n\n return queryResult.data.length ?? 0\n }\n}\n"],"mappings":";;;AAAA,MAAM,iBAAiB;AAMvB,SAAS,cAAsB;AAC7B,KAAI,OAAO,YAAY,aAAa;EAClC,MAAM,WAAW,SAAS,KAAK;AAC/B,MAAI,SACF,QAAO;;AAIX,KAAI,OAAO,eAAe,eAAe,kBAAkB,WACzD,KAAI;AAEF,SADiB,WAA0C,cAC3C,QAAQ,QAAQ,IAAI;SAC9B;AAIV,QAAO;;AAIT,SAAS,eAAe,WAAmB,SAA0B;AAEnE,KAAI,YAAY,UAAW,QAAO;AAGlC,KAAI,QAAQ,SAAS,IAAI,EAAE;EACzB,MAAM,SAAS,QAAQ,MAAM,GAAG,GAAG;AACnC,SAAO,UAAU,WAAW,OAAO;;AAIrC,KAAI,QAAQ,WAAW,IAAI,CAEzB,QAAO,CAAC,eAAe,WADA,QAAQ,MAAM,EAAE,CACU;AAGnD,QAAO;;AAIT,SAAS,UAAU,WAA4B;CAC7C,MAAM,WAAW,aAAa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;;;;;;;;;;;;;;;;;CAmBT,MAAM,YAAqC;AACzC,MAAI,MAAM,QAAQ,WAAW,CAC3B,MAAK,YAAY,KAAK,GAAG,WAAW;MAEpC,MAAK,YAAY,KAAK,WAAW;AAEnC,SAAO;;;;;;;;;;;;CAaT,MAAM,QAAQ;EACZ,MAAM,cAAc,MAAM,aAAa,KAAK,SAAS;GACnD,YAAY,KAAK;GACjB,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,SAAS,KAAK;GACd,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,cAAc,KAAK;GACnB,gBAAgB,KAAK;GACrB,cAAc,KAAK;GACnB,aAAa,KAAK;GACnB,CAAC;EAEF,MAAM,WAAW,MAAM,QAAQ,IAC7B,YAAY,KAAK,KAAK,WAAW,oBAAoB,OAAO,CAAC,CAC9D;AAED,OAAK,OAAO,YAAY,OAAO;AAC/B,OAAK,aAAa,OAAO,YAAY,eAAe,EAAE,CAAC;AAEvD,SAAO,IAAI,YAAY,UAAU,MAAM,KAAK,SAAS,KAAK,QAAQ,KAAK,cAAc;;;;;;;;;;;CAYvF,MAAM,QAAQ;AAcZ,UAboB,MAAM,aAAa,KAAK,SAAS;GACnD,YAAY,KAAK;GACjB,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,SAAS,KAAK;GACd,WAAW,KAAK;GAChB,SAAS;GACT,cAAc,KAAK;GACnB,gBAAgB;GAChB,cAAc;GACd,aAAa;GACd,CAAC,EAEiB,KAAK,UAAU"}
@@ -163,6 +163,7 @@ declare function desc(attributeName: string, attributeType: "string" | "number")
163
163
  declare class QueryBuilder {
164
164
  private _client;
165
165
  private _ownedBy;
166
+ private _createdBy;
166
167
  private _orderBy;
167
168
  private _validAtBlock;
168
169
  private _withAttributes;
@@ -182,6 +183,16 @@ declare class QueryBuilder {
182
183
  * builder.ownedBy("0x1234567890123456789012345678901234567890")
183
184
  */
184
185
  ownedBy(ownedBy: Hex): this;
186
+ /**
187
+ * Sets the createdBy filter
188
+ * @param createdBy - The address of the creator
189
+ * @returns The QueryBuilder instance
190
+ *
191
+ * @example
192
+ * const builder = new QueryBuilder(client)
193
+ * builder.createdBy("0x1234567890123456789012345678901234567890")
194
+ */
195
+ createdBy(createdBy: Hex): this;
185
196
  /**
186
197
  * Sets the orderBy for the query.
187
198
  * It can be called multiple times to order by multiple attributes.
@@ -314,4 +325,4 @@ declare class QueryBuilder {
314
325
  }
315
326
  //#endregion
316
327
  export { or as _, QueryResult as a, PredicateType as c, gt as d, gte as f, not as g, neq as h, desc as i, and as l, lte as m, QueryBuilder as n, Predicate as o, lt as p, asc as r, PredicateContainerType as s, OrderByAttribute as t, eq as u };
317
- //# sourceMappingURL=queryBuilder-DSWzci3Y.d.cts.map
328
+ //# sourceMappingURL=queryBuilder-D5eEPVnU.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queryBuilder-DSWzci3Y.d.cts","names":[],"sources":["../src/query/predicate.ts","../src/query/queryResult.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;;AClB7C;;;;;;;;;;ACCY,iBFgCI,GAAA,CEhCY,UAAA,EFgCI,SEhCJ,EAAA,CAAA,EFgCkB,SEhClB;AAe5B;AAiBA;AAaA;;;;;;;;AAsPa,iBFrPG,EAAA,CEqPH,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,GAAA,MAAA,CAAA,EFrP4C,SEqP5C;;;;;;;;;;;iBFvOG,GAAA,uCAA0C;;;;;;;;;;;iBAc1C,EAAA,uCAAyC;;;;;;;;;;;iBAczC,GAAA,uCAA0C;;;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mBAcH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAkCS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAuIR,cAAc;;;;;;;;;;;WAmBrB,QAAA;;;;;;;;;;WAgCA"}
1
+ {"version":3,"file":"queryBuilder-D5eEPVnU.d.cts","names":[],"sources":["../src/query/predicate.ts","../src/query/queryResult.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;;AClB7C;;;;;;;;;;ACCY,iBFgCI,GAAA,CEhCY,UAAA,EFgCI,SEhCJ,EAAA,CAAA,EFgCkB,SEhClB;AAe5B;AAiBA;AAaA;;;;;;;;AAqOa,iBFpOG,EAAA,CEoOH,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,GAAA,MAAA,CAAA,EFpO4C,SEoO5C;;;;;;;;;;;iBFtNG,GAAA,uCAA0C;;;;;;;;;;;iBAc1C,EAAA,uCAAyC;;;;;;;;;;;iBAczC,GAAA,uCAA0C;;;;;;;;;;;iBAc1C,EAAA,uCAAyC;;;;;;;;;;;iBAczC,GAAA,uCAA0C;;;;;;;;;;iBAa1C,GAAA,eAAkB;;;cClIrB,WAAA;YACD;EDRA,QAAA,eAAa;EACb,QAAA,OAAA;EAEA,QAAA,MAAS;EAET,QAAA,aAAA;EAKA,QAAA,aAAA;EACM,IAAA,YAAA,CAAA,CAAA,ECKI,YDLJ;EAAS,IAAA,MAAA,CAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EA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uilder {
164
164
  private _client;
165
165
  private _ownedBy;
166
+ private _createdBy;
166
167
  private _orderBy;
167
168
  private _validAtBlock;
168
169
  private _withAttributes;
@@ -182,6 +183,16 @@ declare class QueryBuilder {
182
183
  * builder.ownedBy("0x1234567890123456789012345678901234567890")
183
184
  */
184
185
  ownedBy(ownedBy: Hex): this;
186
+ /**
187
+ * Sets the createdBy filter
188
+ * @param createdBy - The address of the creator
189
+ * @returns The QueryBuilder instance
190
+ *
191
+ * @example
192
+ * const builder = new QueryBuilder(client)
193
+ * builder.createdBy("0x1234567890123456789012345678901234567890")
194
+ */
195
+ createdBy(createdBy: Hex): this;
185
196
  /**
186
197
  * Sets the orderBy for the query.
187
198
  * It can be called multiple times to order by multiple attributes.
@@ -314,4 +325,4 @@ declare class QueryBuilder {
314
325
  }
315
326
  //#endregion
316
327
  export { or as _, QueryResult as a, PredicateType as c, gt as d, gte as f, not as g, neq as h, desc as i, and as l, lte as m, QueryBuilder as n, Predicate as o, lt as p, asc as r, PredicateContainerType as s, OrderByAttribute as t, eq as u };
317
- //# sourceMappingURL=queryBuilder-CAZQmp71.d.ts.map
328
+ //# sourceMappingURL=queryBuilder-DFaMq3oN.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queryBuilder-CAZQmp71.d.ts","names":[],"sources":["../src/query/predicate.ts","../src/query/queryResult.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;;AClB7C;;;;;;;;;;ACCY,iBFgCI,GAAA,CEhCY,UAAA,EFgCI,SEhCJ,EAAA,CAAA,EFgCkB,SEhCl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BZ;AAeA;AAiBgB,cAaH,YAAA,CAboE;EAapE,QAAA,OAAY;EAYH,QAAA,QAAA;EAcH,QAAA,QAAA;EAkCS,QAAA,aAAA;EAuIR,QAAA,eAAA;EAAc,QAAA,aAAA;EAmBrB,QAAA,YAAA;EAAA,QAAA,MAAA;EAgCA,QAAA,OAAA;EAAA,QAAA,WAAA;sBA1OS;;;;;;;;;;mBAcH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAkCS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAuIR,cAAc;;;;;;;;;;;WAmBrB,QAAA;;;;;;;;;;WAgCA"}
1
+ {"version":3,"file":"queryBuilder-DFaMq3oN.d.ts","names":[],"sources":["../src/query/predicate.ts","../src/query/queryResult.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;;AClB7C;;;;;;;;;;ACCY,iBFgCI,GAAA,CEhCY,UAAA,EFgCI,SEhCJ,EAAA,CAAA,EFgCkB,SEhClB;AAe5B;AAiBA;AAaA;;;;;;;;AAqOa,iBFpOG,EAAA,CEoOH,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA,GAAA,MAAA,CAAA,EFpO4C,SEoO5C;;;;;;;;;;;iBFtNG,GAAA,uCAA0C;;;;;;;;;;;iBAc1C,EAAA,uCAAyC;;;;;;;;;;;iBAczC,GAAA,uCAA0C;;;;;;;;;;;iBAc1C,EAAA,uCAAyC;;;;;;;;;;;iBAczC,GAAA,uCAA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;;;;;;;;;;;;;4BAkCK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAuIR,cAAc;;;;;;;;;;;WAmBrB,QAAA;;;;;;;;;;WAiCA"}
@@ -210,12 +210,13 @@ function processPredicates(predicates) {
210
210
  }).join(" && ");
211
211
  }
212
212
  async function processQuery(client, queryParams) {
213
- const { predicates, limit, cursor, ownedBy, orderBy, validAtBlock, withAttributes, withMetadata, withPayload } = queryParams;
213
+ const { predicates, limit, cursor, ownedBy, createdBy, orderBy, validAtBlock, withAttributes, withMetadata, withPayload } = queryParams;
214
214
  logger$1("Processing query with params %o", {
215
215
  predicates,
216
216
  cursor,
217
217
  limit,
218
218
  ownedBy,
219
+ createdBy,
219
220
  orderBy,
220
221
  validAtBlock,
221
222
  withAttributes,
@@ -224,6 +225,7 @@ async function processQuery(client, queryParams) {
224
225
  });
225
226
  let query = processPredicates(predicates);
226
227
  if (ownedBy) query += ` && $owner=${ownedBy}`;
228
+ if (createdBy) query += ` && $creator=${createdBy}`;
227
229
  query = query.trim();
228
230
  if (query.startsWith("&& ")) query = query.slice(3);
229
231
  const queryOptions = { includeData: {
@@ -340,6 +342,7 @@ function desc(attributeName, attributeType) {
340
342
  var QueryBuilder = class {
341
343
  _client;
342
344
  _ownedBy;
345
+ _createdBy;
343
346
  _orderBy;
344
347
  _validAtBlock;
345
348
  _withAttributes;
@@ -365,6 +368,19 @@ var QueryBuilder = class {
365
368
  this._ownedBy = ownedBy;
366
369
  return this;
367
370
  }
371
+ /**
372
+ * Sets the createdBy filter
373
+ * @param createdBy - The address of the creator
374
+ * @returns The QueryBuilder instance
375
+ *
376
+ * @example
377
+ * const builder = new QueryBuilder(client)
378
+ * builder.createdBy("0x1234567890123456789012345678901234567890")
379
+ */
380
+ createdBy(createdBy) {
381
+ this._createdBy = createdBy;
382
+ return this;
383
+ }
368
384
  orderBy(attributeNameOrOrderByAttribute, attributeType, order = "asc") {
369
385
  if (!this._orderBy) this._orderBy = [];
370
386
  const pushOrderByAttribute = ({ name, type, order: order$1 }) => {
@@ -500,6 +516,7 @@ var QueryBuilder = class {
500
516
  limit: this._limit,
501
517
  cursor: this._cursor,
502
518
  ownedBy: this._ownedBy,
519
+ createdBy: this._createdBy,
503
520
  orderBy: this._orderBy,
504
521
  validAtBlock: this._validAtBlock,
505
522
  withAttributes: this._withAttributes,
@@ -526,6 +543,7 @@ var QueryBuilder = class {
526
543
  limit: this._limit,
527
544
  cursor: this._cursor,
528
545
  ownedBy: this._ownedBy,
546
+ createdBy: this._createdBy,
529
547
  orderBy: void 0,
530
548
  validAtBlock: this._validAtBlock,
531
549
  withAttributes: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkiv-network/sdk",
3
- "version": "0.6.1",
3
+ "version": "0.6.2-dev.1",
4
4
  "description": "TypeScript client library for Arkiv's blockchains interactions",
5
5
  "type": "module",
6
6
  "target": "esnext",
@@ -16,6 +16,7 @@ describe("processQuery tests", () => {
16
16
  limit: undefined,
17
17
  cursor: undefined,
18
18
  ownedBy: undefined,
19
+ createdBy: undefined,
19
20
  orderBy: undefined,
20
21
  validAtBlock: undefined,
21
22
  withAttributes: undefined,
@@ -59,6 +60,7 @@ describe("processQuery tests", () => {
59
60
  limit: undefined,
60
61
  cursor: undefined,
61
62
  ownedBy: undefined,
63
+ createdBy: undefined,
62
64
  orderBy: undefined,
63
65
  validAtBlock: undefined,
64
66
  withAttributes: undefined,
@@ -103,6 +105,7 @@ describe("processQuery tests", () => {
103
105
  limit: undefined,
104
106
  cursor: undefined,
105
107
  ownedBy: undefined,
108
+ createdBy: undefined,
106
109
  orderBy: undefined,
107
110
  validAtBlock: undefined,
108
111
  withAttributes: undefined,
@@ -147,6 +150,7 @@ describe("processQuery tests", () => {
147
150
  limit: undefined,
148
151
  cursor: undefined,
149
152
  ownedBy: undefined,
153
+ createdBy: undefined,
150
154
  orderBy: undefined,
151
155
  validAtBlock: undefined,
152
156
  withAttributes: undefined,
@@ -197,6 +201,7 @@ describe("processQuery tests", () => {
197
201
  limit: undefined,
198
202
  cursor: undefined,
199
203
  ownedBy: undefined,
204
+ createdBy: undefined,
200
205
  orderBy: undefined,
201
206
  validAtBlock: undefined,
202
207
  withAttributes: undefined,
@@ -233,6 +238,7 @@ describe("processQuery tests", () => {
233
238
  limit: undefined,
234
239
  cursor: undefined,
235
240
  ownedBy: "0x123",
241
+ createdBy: undefined,
236
242
  })
237
243
 
238
244
  expect(client.request).lastCalledWith({
@@ -268,6 +274,7 @@ describe("processQuery tests", () => {
268
274
  withAttributes: undefined,
269
275
  withMetadata: undefined,
270
276
  ownedBy: "0x123",
277
+ createdBy: undefined,
271
278
  })
272
279
 
273
280
  expect(client.request).lastCalledWith({
@@ -292,6 +299,75 @@ describe("processQuery tests", () => {
292
299
  })
293
300
  })
294
301
 
302
+ it("should process simple predicates with createdBy", async () => {
303
+ const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
304
+ await processQuery(client, {
305
+ predicates,
306
+ orderBy: undefined,
307
+ limit: undefined,
308
+ cursor: undefined,
309
+ ownedBy: undefined,
310
+ createdBy: "0x123",
311
+ })
312
+
313
+ expect(client.request).lastCalledWith({
314
+ method: "arkiv_query",
315
+ params: [
316
+ `key = "value" && $creator=0x123`,
317
+ {
318
+ includeData: {
319
+ key: true,
320
+ attributes: false,
321
+ contentType: false,
322
+ payload: false,
323
+ expiration: false,
324
+ owner: false,
325
+ createdAtBlock: false,
326
+ lastModifiedAtBlock: false,
327
+ transactionIndexInBlock: false,
328
+ operationIndexInTransaction: false,
329
+ },
330
+ },
331
+ ],
332
+ })
333
+ })
334
+
335
+ it("should process only createdBy", async () => {
336
+ const predicates = [] as Predicate[]
337
+ await processQuery(client, {
338
+ predicates,
339
+ limit: undefined,
340
+ cursor: undefined,
341
+ orderBy: undefined,
342
+ validAtBlock: undefined,
343
+ withAttributes: undefined,
344
+ withMetadata: undefined,
345
+ ownedBy: undefined,
346
+ createdBy: "0x123",
347
+ })
348
+
349
+ expect(client.request).lastCalledWith({
350
+ method: "arkiv_query",
351
+ params: [
352
+ `$creator=0x123`,
353
+ {
354
+ includeData: {
355
+ key: true,
356
+ attributes: false,
357
+ contentType: false,
358
+ payload: false,
359
+ expiration: false,
360
+ owner: false,
361
+ createdAtBlock: false,
362
+ lastModifiedAtBlock: false,
363
+ transactionIndexInBlock: false,
364
+ operationIndexInTransaction: false,
365
+ },
366
+ },
367
+ ],
368
+ })
369
+ })
370
+
295
371
  it("should process simple predicates with orderBy", async () => {
296
372
  const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
297
373
  await processQuery(client, {
@@ -300,6 +376,7 @@ describe("processQuery tests", () => {
300
376
  limit: undefined,
301
377
  cursor: undefined,
302
378
  ownedBy: undefined,
379
+ createdBy: undefined,
303
380
  })
304
381
 
305
382
  expect(client.request).lastCalledWith({
@@ -332,6 +409,7 @@ describe("processQuery tests", () => {
332
409
  limit: undefined,
333
410
  cursor: undefined,
334
411
  ownedBy: undefined,
412
+ createdBy: undefined,
335
413
  orderBy: [{ name: "key", type: "string", desc: true }],
336
414
  validAtBlock: undefined,
337
415
  withAttributes: undefined,
@@ -370,6 +448,7 @@ describe("processQuery tests", () => {
370
448
  orderBy: undefined,
371
449
  validAtBlock: 123n,
372
450
  ownedBy: "0x123",
451
+ createdBy: undefined,
373
452
  })
374
453
 
375
454
  expect(client.request).lastCalledWith({
@@ -405,6 +484,7 @@ describe("processQuery tests", () => {
405
484
  orderBy: undefined,
406
485
  validAtBlock: undefined,
407
486
  ownedBy: "0x123",
487
+ createdBy: undefined,
408
488
  withMetadata: true,
409
489
  })
410
490
 
@@ -49,6 +49,7 @@ export async function processQuery(
49
49
  limit: number | undefined
50
50
  cursor: string | undefined
51
51
  ownedBy: Hex | undefined
52
+ createdBy: Hex | undefined
52
53
  orderBy: RpcOrderByAttribute[] | undefined
53
54
  validAtBlock?: bigint | undefined
54
55
  withAttributes?: boolean | undefined
@@ -61,6 +62,7 @@ export async function processQuery(
61
62
  limit,
62
63
  cursor,
63
64
  ownedBy,
65
+ createdBy,
64
66
  orderBy,
65
67
  validAtBlock,
66
68
  withAttributes,
@@ -73,6 +75,7 @@ export async function processQuery(
73
75
  cursor,
74
76
  limit,
75
77
  ownedBy,
78
+ createdBy,
76
79
  orderBy,
77
80
  validAtBlock,
78
81
  withAttributes,
@@ -84,6 +87,9 @@ export async function processQuery(
84
87
  if (ownedBy) {
85
88
  query += ` && $owner=${ownedBy}`
86
89
  }
90
+ if (createdBy) {
91
+ query += ` && $creator=${createdBy}`
92
+ }
87
93
 
88
94
  // remove leading and trailing spaces and leading &&
89
95
  query = query.trim()
@@ -46,6 +46,7 @@ describe("QueryBuilder", () => {
46
46
  limit: undefined,
47
47
  offset: undefined,
48
48
  ownedBy: undefined,
49
+ createdBy: undefined,
49
50
  orderBy: undefined,
50
51
  validBeforeBlock: undefined,
51
52
  withAttributes: undefined,
@@ -68,6 +69,7 @@ describe("QueryBuilder", () => {
68
69
  limit: undefined,
69
70
  offset: undefined,
70
71
  ownedBy: undefined,
72
+ createdBy: undefined,
71
73
  orderBy: undefined,
72
74
  validBeforeBlock: undefined,
73
75
  withAttributes: undefined,
@@ -98,6 +100,7 @@ describe("QueryBuilder", () => {
98
100
  limit: undefined,
99
101
  offset: undefined,
100
102
  ownedBy: undefined,
103
+ createdBy: undefined,
101
104
  orderBy: undefined,
102
105
  validBeforeBlock: undefined,
103
106
  withAttributes: undefined,
@@ -120,6 +123,7 @@ describe("QueryBuilder", () => {
120
123
  limit: undefined,
121
124
  offset: undefined,
122
125
  ownedBy: undefined,
126
+ createdBy: undefined,
123
127
  orderBy: undefined,
124
128
  validBeforeBlock: undefined,
125
129
  withAttributes: undefined,
@@ -145,6 +149,7 @@ describe("QueryBuilder", () => {
145
149
  limit: undefined,
146
150
  offset: undefined,
147
151
  ownedBy: undefined,
152
+ createdBy: undefined,
148
153
  orderBy: undefined,
149
154
  validBeforeBlock: undefined,
150
155
  withAttributes: undefined,
@@ -169,6 +174,30 @@ describe("QueryBuilder", () => {
169
174
  limit: undefined,
170
175
  offset: undefined,
171
176
  ownedBy: owner,
177
+ createdBy: undefined,
178
+ orderBy: undefined,
179
+ validBeforeBlock: undefined,
180
+ withAttributes: undefined,
181
+ withMetadata: undefined,
182
+ withPayload: undefined,
183
+ })
184
+ })
185
+
186
+ test("createdBy() sets creator", async () => {
187
+ mockProcessQuery.mockResolvedValue({
188
+ data: [],
189
+ })
190
+
191
+ const builder = new QueryBuilder(mockClient)
192
+ const creator = "0x1234567890123456789012345678901234567890" as const
193
+ await builder.createdBy(creator).fetch()
194
+
195
+ expect(mockProcessQuery).toHaveBeenCalledWith(mockClient, {
196
+ predicates: [],
197
+ limit: undefined,
198
+ offset: undefined,
199
+ ownedBy: undefined,
200
+ createdBy: creator,
172
201
  orderBy: undefined,
173
202
  validBeforeBlock: undefined,
174
203
  withAttributes: undefined,
@@ -190,6 +219,7 @@ describe("QueryBuilder", () => {
190
219
  limit: undefined,
191
220
  offset: undefined,
192
221
  ownedBy: undefined,
222
+ createdBy: undefined,
193
223
  orderBy: [{ name: "name", type: "string", desc: false }],
194
224
  validAtBlock: undefined,
195
225
  withAttributes: undefined,
@@ -211,6 +241,7 @@ describe("QueryBuilder", () => {
211
241
  limit: undefined,
212
242
  offset: undefined,
213
243
  ownedBy: undefined,
244
+ createdBy: undefined,
214
245
  orderBy: [{ name: "name", type: "string", desc: true }],
215
246
  validAtBlock: undefined,
216
247
  withAttributes: undefined,
@@ -232,6 +263,7 @@ describe("QueryBuilder", () => {
232
263
  limit: undefined,
233
264
  offset: undefined,
234
265
  ownedBy: undefined,
266
+ createdBy: undefined,
235
267
  orderBy: [{ name: "name", type: "string", desc: false }],
236
268
  validAtBlock: undefined,
237
269
  withAttributes: undefined,
@@ -252,6 +284,7 @@ describe("QueryBuilder", () => {
252
284
  limit: 10,
253
285
  offset: undefined,
254
286
  ownedBy: undefined,
287
+ createdBy: undefined,
255
288
  orderBy: undefined,
256
289
  validBeforeBlock: undefined,
257
290
  withAttributes: undefined,
@@ -273,6 +306,7 @@ describe("QueryBuilder", () => {
273
306
  limit: undefined,
274
307
  cursor: "0xABC123",
275
308
  ownedBy: undefined,
309
+ createdBy: undefined,
276
310
  orderBy: undefined,
277
311
  validAtBlock: undefined,
278
312
  withAttributes: undefined,
@@ -294,6 +328,7 @@ describe("QueryBuilder", () => {
294
328
  limit: undefined,
295
329
  offset: undefined,
296
330
  ownedBy: undefined,
331
+ createdBy: undefined,
297
332
  orderBy: undefined,
298
333
  validBeforeBlock: undefined,
299
334
  withAttributes: true,
@@ -315,6 +350,7 @@ describe("QueryBuilder", () => {
315
350
  limit: undefined,
316
351
  cursor: undefined,
317
352
  ownedBy: undefined,
353
+ createdBy: undefined,
318
354
  orderBy: undefined,
319
355
  validBeforeBlock: undefined,
320
356
  withAttributes: false,
@@ -336,6 +372,7 @@ describe("QueryBuilder", () => {
336
372
  limit: undefined,
337
373
  cursor: undefined,
338
374
  ownedBy: undefined,
375
+ createdBy: undefined,
339
376
  orderBy: undefined,
340
377
  validAtBlock: undefined,
341
378
  withAttributes: undefined,
@@ -357,6 +394,7 @@ describe("QueryBuilder", () => {
357
394
  limit: undefined,
358
395
  cursor: undefined,
359
396
  ownedBy: undefined,
397
+ createdBy: undefined,
360
398
  orderBy: undefined,
361
399
  validAtBlock: undefined,
362
400
  withAttributes: undefined,
@@ -378,6 +416,7 @@ describe("QueryBuilder", () => {
378
416
  limit: undefined,
379
417
  cursor: undefined,
380
418
  ownedBy: undefined,
419
+ createdBy: undefined,
381
420
  orderBy: undefined,
382
421
  validAtBlock: undefined,
383
422
  withAttributes: undefined,
@@ -399,6 +438,7 @@ describe("QueryBuilder", () => {
399
438
  limit: undefined,
400
439
  cursor: undefined,
401
440
  ownedBy: undefined,
441
+ createdBy: undefined,
402
442
  validAtBlock: undefined,
403
443
  withAttributes: undefined,
404
444
  withMetadata: undefined,
@@ -429,6 +469,7 @@ describe("QueryBuilder", () => {
429
469
  limit: 10,
430
470
  cursor: "0xABC123",
431
471
  ownedBy: owner,
472
+ createdBy: undefined,
432
473
  validAtBlock: undefined,
433
474
  withAttributes: true,
434
475
  withMetadata: true,
@@ -518,6 +559,7 @@ describe("QueryBuilder", () => {
518
559
  limit: undefined,
519
560
  cursor: undefined,
520
561
  ownedBy: undefined,
562
+ createdBy: undefined,
521
563
  validAtBlock: undefined,
522
564
  withAttributes: false,
523
565
  withMetadata: false,
@@ -559,6 +601,7 @@ describe("QueryBuilder", () => {
559
601
  limit: 50,
560
602
  cursor: "0xABC123",
561
603
  ownedBy: owner,
604
+ createdBy: undefined,
562
605
  validAtBlock: 123n,
563
606
  withAttributes: false,
564
607
  withMetadata: false,
@@ -54,6 +54,7 @@ export function desc(attributeName: string, attributeType: "string" | "number"):
54
54
  export class QueryBuilder {
55
55
  private _client: ArkivClient
56
56
  private _ownedBy: Hex | undefined
57
+ private _createdBy: Hex | undefined
57
58
  private _orderBy: RpcOrderByAttribute[] | undefined
58
59
  private _validAtBlock: bigint | undefined
59
60
  private _withAttributes: boolean | undefined
@@ -82,6 +83,20 @@ export class QueryBuilder {
82
83
  return this
83
84
  }
84
85
 
86
+ /**
87
+ * Sets the createdBy filter
88
+ * @param createdBy - The address of the creator
89
+ * @returns The QueryBuilder instance
90
+ *
91
+ * @example
92
+ * const builder = new QueryBuilder(client)
93
+ * builder.createdBy("0x1234567890123456789012345678901234567890")
94
+ */
95
+ createdBy(createdBy: Hex) {
96
+ this._createdBy = createdBy
97
+ return this
98
+ }
99
+
85
100
  /**
86
101
  * Sets the orderBy for the query.
87
102
  * It can be called multiple times to order by multiple attributes.
@@ -271,6 +286,7 @@ export class QueryBuilder {
271
286
  limit: this._limit,
272
287
  cursor: this._cursor,
273
288
  ownedBy: this._ownedBy,
289
+ createdBy: this._createdBy,
274
290
  orderBy: this._orderBy,
275
291
  validAtBlock: this._validAtBlock,
276
292
  withAttributes: this._withAttributes,
@@ -303,6 +319,7 @@ export class QueryBuilder {
303
319
  limit: this._limit,
304
320
  cursor: this._cursor,
305
321
  ownedBy: this._ownedBy,
322
+ createdBy: this._createdBy,
306
323
  orderBy: undefined,
307
324
  validAtBlock: this._validAtBlock,
308
325
  withAttributes: false,
@@ -1 +0,0 @@
1
- {"version":3,"file":"queryBuilder-UO2ZKHFN.js","names":["enabledNamespaces: Set<string>","disabledNamespaces: Set<string>","logger","logger","predicate","queryOptions: RpcQueryOptions","order"],"sources":["../src/utils/logger.ts","../src/errors.ts","../src/types/entity.ts","../src/utils/entities.ts","../src/query/engine.ts","../src/query/queryResult.ts","../src/query/queryBuilder.ts"],"sourcesContent":["const ROOT_NAMESPACE = \"arkiv\"\n\n// Debug logger type - returns a function that can be called to log messages\ntype DebugLogger = (...args: unknown[]) => void\n\n// Get DEBUG environment variable (works in both Node.js and browser)\nfunction getDebugEnv(): string {\n if (typeof process !== \"undefined\") {\n const debugEnv = process?.env?.DEBUG\n if (debugEnv) {\n return debugEnv\n }\n }\n // Browser: check localStorage\n if (typeof globalThis !== \"undefined\" && \"localStorage\" in globalThis) {\n try {\n const storage = (globalThis as { localStorage?: Storage }).localStorage\n return storage?.getItem(\"DEBUG\") || \"\"\n } catch {\n // localStorage might not be available\n }\n }\n return \"\"\n}\n\n// Parse debug patterns and check if a namespace matches\nfunction matchesPattern(namespace: string, pattern: string): boolean {\n // Exact match\n if (pattern === namespace) return true\n\n // Wildcard match: \"arkiv:*\" matches \"arkiv:query\", \"arkiv:rpc\", etc.\n if (pattern.endsWith(\"*\")) {\n const prefix = pattern.slice(0, -1)\n return namespace.startsWith(prefix)\n }\n\n // Negative match: \"-arkiv:query\" excludes \"arkiv:query\"\n if (pattern.startsWith(\"-\")) {\n const excludePattern = pattern.slice(1)\n return !matchesPattern(namespace, excludePattern)\n }\n\n return false\n}\n\n// Check if a namespace is enabled for debugging\nfunction isEnabled(namespace: string): boolean {\n const debugEnv = getDebugEnv()\n if (!debugEnv) return false\n\n // Split by comma/space and check each pattern\n const patterns = debugEnv.split(/[\\s,]+/).filter((p) => p.length > 0)\n\n // If no patterns, nothing is enabled\n if (patterns.length === 0) return false\n\n // Check if any pattern matches (or if explicitly excluded)\n let enabled = false\n for (const pattern of patterns) {\n if (pattern.startsWith(\"-\")) {\n // Exclude pattern - if it matches, disable\n if (matchesPattern(namespace, pattern)) {\n return false\n }\n } else if (matchesPattern(namespace, pattern)) {\n enabled = true\n }\n }\n\n return enabled\n}\n\n// Store enabled namespaces (for programmatic enable/disable)\nconst enabledNamespaces: Set<string> = new Set()\nconst disabledNamespaces: Set<string> = new Set()\n\n// Color palette for namespace coloring (distinct, readable colors)\nconst COLOR_PALETTE = [\n \"#0000FF\", // blue\n \"#008000\", // green\n \"#FF0000\", // red\n \"#FF00FF\", // magenta\n \"#FFA500\", // orange\n \"#800080\", // purple\n \"#00CED1\", // dark turquoise\n \"#FF1493\", // deep pink\n \"#32CD32\", // lime green\n \"#1E90FF\", // dodger blue\n \"#FF4500\", // orange red\n \"#9370DB\", // medium purple\n \"#00FA9A\", // medium spring green\n \"#FFD700\", // gold\n \"#DC143C\", // crimson\n \"#00BFFF\", // deep sky blue\n \"#FF69B4\", // hot pink\n \"#20B2AA\", // light sea green\n \"#DA70D6\", // orchid\n \"#4682B4\", // steel blue\n]\n\n// Detect if we're in Node.js (for ANSI colors) or browser (for CSS colors)\nconst isNode = typeof process !== \"undefined\" && process.versions?.node != null\n\n// ANSI color codes for Node.js (bright, distinct colors)\nconst ANSI_COLORS = [\n \"\\x1b[94m\", // bright blue\n \"\\x1b[92m\", // bright green\n \"\\x1b[91m\", // bright red\n \"\\x1b[95m\", // bright magenta\n \"\\x1b[93m\", // bright yellow\n \"\\x1b[96m\", // bright cyan\n \"\\x1b[35m\", // magenta\n \"\\x1b[36m\", // cyan\n \"\\x1b[32m\", // green\n \"\\x1b[34m\", // blue\n \"\\x1b[33m\", // yellow\n \"\\x1b[31m\", // red\n \"\\x1b[90m\", // bright black (gray)\n \"\\x1b[37m\", // white\n \"\\x1b[1m\", // bold (as a color option)\n]\n\nconst ANSI_RESET = \"\\x1b[0m\"\nconst ANSI_BOLD = \"\\x1b[1m\"\n\n// Cache colors for namespaces (same namespace = same color)\nconst namespaceColors = new Map<string, { css: string; ansi: string }>()\n\n// Generate a consistent color for a namespace based on its hash\nfunction getColorForNamespace(namespace: string): { css: string; ansi: string } {\n // Check cache first\n const cachedColor = namespaceColors.get(namespace)\n if (cachedColor) {\n return cachedColor\n }\n\n // Simple hash function to convert string to number\n let hash = 0\n for (let i = 0; i < namespace.length; i++) {\n const char = namespace.charCodeAt(i)\n hash = (hash << 5) - hash + char\n hash = hash & hash // Convert to 32-bit integer\n }\n\n // Use absolute value and modulo to get index\n const colorIndex = Math.abs(hash) % COLOR_PALETTE.length\n const cssColor = COLOR_PALETTE[colorIndex]\n const ansiColor = ANSI_COLORS[colorIndex % ANSI_COLORS.length]\n\n const color = { css: cssColor, ansi: ansiColor }\n\n // Cache the color\n namespaceColors.set(namespace, color)\n\n return color\n}\n\n// Create a debug logger function\nfunction createDebugLogger(namespace: string): DebugLogger {\n // Get the color for this namespace (consistent across calls)\n const colors = getColorForNamespace(namespace)\n\n return (...args: unknown[]) => {\n // Check if enabled via environment variable or programmatically\n const envEnabled = isEnabled(namespace)\n const progEnabled = enabledNamespaces.has(namespace) && !disabledNamespaces.has(namespace)\n\n if (envEnabled || progEnabled) {\n if (isNode) {\n // Node.js: use ANSI color codes\n const coloredNamespace = `${ANSI_BOLD}${colors.ansi}${namespace}${ANSI_RESET}`\n console.log(coloredNamespace, ...args)\n } else {\n // Browser: use CSS styling with %c\n // The format is: console.log(\"%cstyled%cnormal\", style1, style2, ...args)\n // This colors the namespace, then resets for the rest\n const style1 = `color: ${colors.css}; font-weight: bold`\n const style2 = \"color: inherit; font-weight: normal\"\n // Combine namespace with a space, then log with styles\n console.log(`%c${namespace}%c`, style1, style2, ...args)\n }\n }\n }\n}\n\nexport const getLogger = (scope: string): DebugLogger => {\n const namespace = `${ROOT_NAMESPACE}:${scope}`\n return createDebugLogger(namespace)\n}\n\nexport const enableDebug = (namespaces: string): void => {\n // Parse and add namespaces to enabled set\n const patterns = namespaces.split(/[\\s,]+/).filter((p) => p.length > 0)\n for (const pattern of patterns) {\n if (pattern.startsWith(\"-\")) {\n // Remove from enabled, add to disabled\n const namespace = pattern.slice(1)\n enabledNamespaces.delete(namespace)\n disabledNamespaces.add(namespace)\n } else {\n enabledNamespaces.add(pattern)\n disabledNamespaces.delete(pattern)\n }\n }\n}\n\nexport const disableDebug = (): void => {\n enabledNamespaces.clear()\n disabledNamespaces.clear()\n}\n","export class EntityMutationError extends Error {\n constructor(message: string) {\n super(message)\n this.name = \"EntityMutationError\"\n }\n}\n\nexport class NoMoreResultsError extends Error {\n constructor() {\n super(\"No more results\")\n this.name = \"NoMoreResultsError\"\n }\n}\n\nexport class NoCursorOrLimitError extends Error {\n constructor() {\n super(\"Cursor and limit must be defined to fetch next\")\n this.name = \"NoCursorOrLimitError\"\n }\n}\n\nexport class NoEntityFoundError extends Error {\n constructor() {\n super(\"No entity found\")\n this.name = \"NoEntityFoundError\"\n }\n}\n","import { bytesToString, type Hex } from \"viem\"\nimport type { MimeType } from \"../types\"\nimport type { Attribute } from \"./attributes\"\n\nexport class Entity {\n key: Hex\n contentType: MimeType | undefined\n owner: Hex | undefined\n expiresAtBlock: bigint | undefined\n createdAtBlock: bigint | undefined\n lastModifiedAtBlock: bigint | undefined\n transactionIndexInBlock: bigint | undefined\n operationIndexInTransaction: bigint | undefined\n payload: Uint8Array | undefined\n attributes: Attribute[]\n\n constructor(\n key: Hex,\n contentType: MimeType | undefined = undefined,\n owner: Hex | undefined = undefined,\n expiresAtBlock: bigint | undefined = undefined,\n createdAtBlock: bigint | undefined = undefined,\n lastModifiedAtBlock: bigint | undefined = undefined,\n transactionIndexInBlock: bigint | undefined = undefined,\n operationIndexInTransaction: bigint | undefined = undefined,\n payload: Uint8Array | undefined = undefined,\n attributes: Attribute[],\n ) {\n this.key = key\n this.owner = owner\n this.expiresAtBlock = expiresAtBlock\n this.createdAtBlock = createdAtBlock\n this.lastModifiedAtBlock = lastModifiedAtBlock\n this.transactionIndexInBlock = transactionIndexInBlock\n this.operationIndexInTransaction = operationIndexInTransaction\n this.payload = payload\n this.attributes = attributes\n this.contentType = contentType\n }\n\n toText(): string {\n return this.payload ? bytesToString(this.payload) : \"\"\n }\n\n toJson(): any {\n return this.payload ? JSON.parse(bytesToString(this.payload)) : {}\n }\n}\n","import { toBytes } from \"viem\"\nimport { Entity } from \"../types/entity\"\nimport type { RpcEntity } from \"../types/rpcSchema\"\nimport { getLogger } from \"./logger\"\n\nconst logger = getLogger(\"utils:entities\")\n\nexport async function entityFromRpcResult(rpcEntity: RpcEntity) {\n logger(\"entityFromRpcResult %o\", rpcEntity)\n\n return new Entity(\n rpcEntity.key,\n rpcEntity.contentType,\n rpcEntity.owner,\n rpcEntity.expiresAt !== undefined ? BigInt(rpcEntity.expiresAt) : undefined,\n rpcEntity.createdAtBlock !== undefined ? BigInt(rpcEntity.createdAtBlock) : undefined,\n rpcEntity.lastModifiedAtBlock !== undefined ? BigInt(rpcEntity.lastModifiedAtBlock) : undefined,\n rpcEntity.transactionIndexInBlock !== undefined\n ? BigInt(rpcEntity.transactionIndexInBlock)\n : undefined,\n rpcEntity.operationIndexInTransaction !== undefined\n ? BigInt(rpcEntity.operationIndexInTransaction)\n : undefined,\n rpcEntity.value !== undefined ? toBytes(rpcEntity.value) : undefined,\n [\n ...(rpcEntity.stringAttributes ?? []).map(({ key, value }) => ({\n key,\n value,\n })),\n ...(rpcEntity.numericAttributes ?? []).map(({ key, value }) => ({\n key,\n value: Number(value),\n })),\n ],\n )\n}\n","import type { Hex } from \"viem\"\nimport { hexToNumber, numberToHex } from \"viem\"\nimport type { ArkivClient } from \"../clients/baseClient\"\nimport type { RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions } from \"../types/rpcSchema\"\nimport { getLogger } from \"../utils/logger\"\nimport type { Predicate } from \"./predicate\"\n\nconst logger = getLogger(\"query:engine\")\n\nfunction processPredicates(predicates: Predicate[]): string {\n const processValue = (value: string | number) => {\n if (typeof value === \"string\") {\n return `\"${value}\"`\n }\n return value\n }\n return predicates\n .map((predicate) => {\n switch (predicate.type) {\n case \"eq\":\n return `${predicate.key} = ${processValue(predicate.value)}`\n case \"neq\":\n return `${predicate.key} != ${processValue(predicate.value)}`\n case \"gt\":\n return `${predicate.key} > ${processValue(predicate.value)}`\n case \"gte\":\n return `${predicate.key} >= ${processValue(predicate.value)}`\n case \"lt\":\n return `${predicate.key} < ${processValue(predicate.value)}`\n case \"lte\":\n return `${predicate.key} <= ${processValue(predicate.value)}`\n case \"not\":\n return `!${predicate.key}`\n case \"or\":\n return `(${predicate.predicates.map((predicate) => processPredicates([predicate])).join(\" || \")})`\n case \"and\":\n return `(${predicate.predicates.map((predicate) => processPredicates([predicate])).join(\" && \")})`\n default:\n return \"\"\n }\n })\n .join(\" && \")\n}\n\nexport async function processQuery(\n client: ArkivClient,\n queryParams: {\n predicates: Predicate[]\n limit: number | undefined\n cursor: string | undefined\n ownedBy: Hex | undefined\n orderBy: RpcOrderByAttribute[] | undefined\n validAtBlock?: bigint | undefined\n withAttributes?: boolean | undefined\n withMetadata?: boolean | undefined\n withPayload?: boolean | undefined\n },\n) {\n const {\n predicates,\n limit,\n cursor,\n ownedBy,\n orderBy,\n validAtBlock,\n withAttributes,\n withMetadata,\n withPayload,\n } = queryParams\n\n logger(\"Processing query with params %o\", {\n predicates,\n cursor,\n limit,\n ownedBy,\n orderBy,\n validAtBlock,\n withAttributes,\n withMetadata,\n withPayload,\n })\n\n let query = processPredicates(predicates)\n if (ownedBy) {\n query += ` && $owner=${ownedBy}`\n }\n\n // remove leading and trailing spaces and leading &&\n query = query.trim()\n if (query.startsWith(\"&& \")) {\n query = query.slice(3)\n }\n\n const queryOptions: RpcQueryOptions = {\n includeData: {\n key: true,\n attributes: withAttributes ?? false,\n payload: withPayload ?? false,\n contentType: withMetadata ?? false,\n expiration: withMetadata ?? false,\n owner: withMetadata ?? false,\n createdAtBlock: withMetadata ?? false,\n lastModifiedAtBlock: withMetadata ?? false,\n transactionIndexInBlock: withMetadata ?? false,\n operationIndexInTransaction: withMetadata ?? false,\n } as RpcIncludeData,\n }\n\n if (validAtBlock !== undefined) {\n queryOptions.atBlock = numberToHex(validAtBlock)\n }\n if (limit !== undefined) {\n queryOptions.resultsPerPage = numberToHex(limit)\n }\n if (cursor !== undefined) {\n queryOptions.cursor = cursor\n }\n if (orderBy !== undefined) {\n queryOptions.orderBy = orderBy\n }\n\n logger(\"Built query to send %s %o\", query, {\n includeData: queryOptions.includeData,\n atBlock: queryOptions.atBlock ? hexToNumber(queryOptions.atBlock) : undefined,\n orderBy: queryOptions.orderBy,\n resultsPerPage: queryOptions.resultsPerPage,\n cursor: queryOptions.cursor,\n })\n\n const result = await client.request({\n method: \"arkiv_query\",\n params: [query, queryOptions],\n })\n logger(\"Raw result from query %o\", result)\n\n return result\n}\n","import { NoCursorOrLimitError, NoMoreResultsError } from \"../errors\"\nimport type { Entity } from \"../types/entity\"\nimport { getLogger } from \"../utils/logger\"\nimport type { QueryBuilder } from \"./queryBuilder\"\n\nconst logger = getLogger(\"query:result\")\n\nexport class QueryResult {\n entities: Entity[]\n private _endOfIteration: boolean\n private _cursor: string | undefined\n private _limit: number | undefined\n private _validAtBlock: bigint | undefined\n private _queryBuilder: QueryBuilder\n\n // Public getters for internal state\n get queryBuilder(): QueryBuilder {\n return this._queryBuilder\n }\n\n get cursor(): string | undefined {\n return this._cursor\n }\n\n constructor(\n entities: Entity[],\n queryBuilder: QueryBuilder,\n cursor: string | undefined,\n limit: number | undefined,\n validAtBlock: bigint | undefined,\n ) {\n this.entities = entities\n this._queryBuilder = queryBuilder\n this._endOfIteration = !limit || entities.length < limit\n this._cursor = cursor\n this._limit = limit\n this._validAtBlock = validAtBlock\n }\n\n async next() {\n if (this._cursor === undefined || this._limit === undefined) {\n throw new NoCursorOrLimitError()\n }\n if (this._endOfIteration) {\n throw new NoMoreResultsError()\n }\n this._queryBuilder.cursor(this._cursor)\n const result = await this._queryBuilder.fetch()\n this.entities = result.entities\n // Update the query builder reference\n this._queryBuilder = result.queryBuilder\n // Check if we've reached the end (no more cursor or we got fewer entities than limit)\n this._endOfIteration = !result.cursor || result.entities.length < this._limit\n // Update the cursor\n this._cursor = result.cursor\n\n // TODO check current block height and if it is not too old\n logger(\"Current block height for next page %s\", this._validAtBlock?.toString() ?? \"unknown\")\n }\n\n hasNextPage() {\n return !this._endOfIteration\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../clients/baseClient\"\nimport type { RpcOrderByAttribute } from \"../types/rpcSchema\"\nimport { entityFromRpcResult } from \"../utils/entities\"\nimport { processQuery } from \"./engine\"\nimport type { Predicate } from \"./predicate\"\nimport { QueryResult } from \"./queryResult\"\n\nexport type OrderByAttribute = {\n name: string\n type: \"string\" | \"number\"\n order: \"asc\" | \"desc\"\n}\n\n/**\n * Helper function to create an ascending order by attribute\n * @param attributeName - The name of the attribute to order by\n * @param attributeType - The type of the attribute to order by (string or number)\n * @returns Input for orderBy method\n *\n * @example\n * const ascAttribute = asc(\"name\", \"string\")\n */\nexport function asc(attributeName: string, attributeType: \"string\" | \"number\"): OrderByAttribute {\n return {\n name: attributeName,\n type: attributeType,\n order: \"asc\",\n }\n}\n\n/**\n * Helper function to create a descending order by attribute\n * @param attributeName - The name of the attribute to order by\n * @param attributeType - The type of the attribute to order by (string or number)\n * @returns Input for orderBy method\n *\n * @example\n * const descAttribute = desc(\"name\", \"string\")\n */\nexport function desc(attributeName: string, attributeType: \"string\" | \"number\"): OrderByAttribute {\n return {\n name: attributeName,\n type: attributeType,\n order: \"desc\",\n }\n}\n/**\n * QueryBuilder is a helper class to build queries to the Arkiv DBChains.\n * It can be used to fetch entities from the Arkiv DBChains. It follows the Builder pattern allowing chaining of methods.\n * @param client - The Arkiv client\n * @returns The QueryBuilder instance {@link QueryBuilder}\n */\nexport class QueryBuilder {\n private _client: ArkivClient\n private _ownedBy: Hex | undefined\n private _orderBy: RpcOrderByAttribute[] | undefined\n private _validAtBlock: bigint | undefined\n private _withAttributes: boolean | undefined\n private _withMetadata: boolean | undefined\n private _withPayload: boolean | undefined\n private _limit: number | undefined\n private _cursor: string | undefined\n private _predicates: Predicate[]\n\n constructor(client: ArkivClient) {\n this._client = client\n this._predicates = []\n }\n\n /**\n * Sets the ownedBy filter\n * @param ownedBy - The address of the owner\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.ownedBy(\"0x1234567890123456789012345678901234567890\")\n */\n ownedBy(ownedBy: Hex) {\n this._ownedBy = ownedBy\n return this\n }\n\n /**\n * Sets the orderBy for the query.\n * It can be called multiple times to order by multiple attributes.\n * The order of the attributes is important. The first attribute is the primary order by attribute.\n * You can use the helper functions asc() and desc() as input for this method.\n * @param attributeName - The name of the attribute to order by\n * @param attributeType - The type of the attribute to order by (string or number)\n * @param order - The order to set the order by (asc or desc)\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = client.buildQuery()\n * builder.orderBy(\"name\", \"string\", \"desc\")\n * builder.orderBy(asc(\"name\", \"string\"))\n * builder.orderBy(desc(\"name\", \"string\"))\n */\n orderBy(attributeName: string, attributeType: \"string\" | \"number\", order?: \"asc\" | \"desc\"): this\n /**\n * Sets the orderBy for the query.\n * This method takes the OrderByAttribute object as an argument and is mainly\n * used to use the helper functions asc() and desc() to create the OrderByAttribute instances.\n * @param orderByAttribute - The OrderByAttribute instance to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.orderBy(asc(\"name\", \"string\"))\n * builder.orderBy(desc(\"name\", \"string\"))\n */\n orderBy(orderByAttribute: OrderByAttribute): this\n orderBy(\n attributeNameOrOrderByAttribute: string | OrderByAttribute,\n attributeType?: \"string\" | \"number\",\n order: \"asc\" | \"desc\" = \"asc\",\n ) {\n if (!this._orderBy) {\n this._orderBy = []\n }\n\n const pushOrderByAttribute = ({ name, type, order }: OrderByAttribute) => {\n this._orderBy?.push({\n name,\n type: type === \"number\" ? \"numeric\" : type,\n desc: order === \"desc\",\n })\n }\n\n if (typeof attributeNameOrOrderByAttribute === \"string\") {\n if (!attributeType) {\n throw new Error(\"attributeType is required when using positional orderBy arguments\")\n }\n pushOrderByAttribute({\n name: attributeNameOrOrderByAttribute,\n type: attributeType,\n order,\n })\n } else {\n pushOrderByAttribute(attributeNameOrOrderByAttribute)\n }\n\n return this\n }\n\n /**\n * Sets the withAttributes flag which will return the attributes for the entities if true\n * @param withAttributes - The boolean value to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.withAttributes(true)\n */\n withAttributes(withAttributes: boolean = true) {\n this._withAttributes = withAttributes\n return this\n }\n\n /**\n * Sets the withMetadata flag which will return the metadata (like owner, expiredAt, etc.) for the entities if true\n * @param withMetadata - The boolean value to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.withMetadata(true)\n */\n withMetadata(withMetadata: boolean = true) {\n this._withMetadata = withMetadata\n return this\n }\n\n /**\n * Sets the withPayload flag which will return the payload for the entities if true\n * @param withPayload - The boolean value to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.withPayload(true)\n */\n withPayload(withPayload: boolean = true) {\n this._withPayload = withPayload\n return this\n }\n\n /**\n * Sets the limit for the query\n * @param limit - The number of entities to return\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.limit(10)\n */\n limit(limit: number) {\n this._limit = limit\n return this\n }\n\n /**\n * 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).\n * @param cursor - The cursor to set which tells to RPC Query server where to start or continue the query.\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.offset(10)\n */\n cursor(cursor: string) {\n this._cursor = cursor\n return this\n }\n\n /**\n * Sets the validAtBlock for the query which tells at which block height the state we are intested.\n * If not set, the latest block is used.\n * @param validAtBlock - The block number to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.validAtBlock(10000)\n */\n validAtBlock(validAtBlock: bigint) {\n this._validAtBlock = validAtBlock\n return this\n }\n\n /**\n * Sets the predicates for the query limiting the results. It can be a single predicate or an array of predicates combined with 'and'.\n * Predicates can be nested using 'or' and 'and' predicates.\n * @param predicates - The predicates to set\n * @returns The QueryBuilder instance\n *\n * @example\n * const builder = new QueryBuilder(client)\n * builder.where(eq(\"name\", \"John\"))\n * builder.where([eq(\"name\", \"John\"), eq(\"age\", 30)])\n * builder.where([eq(\"name\", \"John\"), or([eq(\"age\", 30), eq(\"age\", 31)])])\n * builder.where([eq(\"name\", \"John\"), and([eq(\"age\", 30), eq(\"age\", 31)])])\n * builder.where([eq(\"name\", \"John\"), or([eq(\"age\", 30), and([eq(\"age\", 31), eq(\"age\", 32)])])])\n * builder.where([eq(\"name\", \"John\"), and([eq(\"age\", 30), or([eq(\"age\", 31), eq(\"age\", 32)])])])\n * builder.where([eq(\"name\", \"John\"), and([eq(\"age\", 30), or([eq(\"age\", 31), and([eq(\"age\", 32), eq(\"age\", 33)])])])])\n */\n where(predicates: Predicate[] | Predicate) {\n if (Array.isArray(predicates)) {\n this._predicates.push(...predicates)\n } else {\n this._predicates.push(predicates)\n }\n return this\n }\n\n /**\n * Fetches the entities from the query. Re\n * It will return a QueryResult instance which can be used to fetch the next and previous pages.\n * @returns The QueryResult instance {@link QueryResult}\n *\n * @example\n * const builder = new QueryBuilder(client)\n * const result = await builder.where(eq(\"name\", \"John\")).fetch()\n * // result = { entities: [Entity, Entity, Entity], next: async () => QueryResult, previous: async () => QueryResult }\n */\n async fetch() {\n const queryResult = await processQuery(this._client, {\n predicates: this._predicates,\n limit: this._limit,\n cursor: this._cursor,\n ownedBy: this._ownedBy,\n orderBy: this._orderBy,\n validAtBlock: this._validAtBlock,\n withAttributes: this._withAttributes,\n withMetadata: this._withMetadata,\n withPayload: this._withPayload,\n })\n\n const entities = await Promise.all(\n queryResult.data.map((entity) => entityFromRpcResult(entity)),\n )\n\n this.cursor(queryResult.cursor)\n this.validAtBlock(BigInt(queryResult.blockNumber ?? 0))\n\n return new QueryResult(entities, this, this._cursor, this._limit, this._validAtBlock)\n }\n\n /**\n * Counts the entities from the query.\n * @returns The number of entities\n *\n * @example\n * const builder = new QueryBuilder(client)\n * const result = await builder.where(eq(\"name\", \"John\")).count()\n * // result = 10\n */\n async count() {\n const queryResult = await processQuery(this._client, {\n predicates: this._predicates,\n limit: this._limit,\n cursor: this._cursor,\n ownedBy: this._ownedBy,\n orderBy: undefined,\n validAtBlock: this._validAtBlock,\n withAttributes: false,\n withMetadata: false,\n withPayload: false,\n })\n\n return queryResult.data.length ?? 0\n }\n}\n"],"mappings":";;;AAAA,MAAM,iBAAiB;AAMvB,SAAS,cAAsB;AAC7B,KAAI,OAAO,YAAY,aAAa;EAClC,MAAM,WAAW,SAAS,KAAK;AAC/B,MAAI,SACF,QAAO;;AAIX,KAAI,OAAO,eAAe,eAAe,kBAAkB,WACzD,KAAI;AAEF,SADiB,WAA0C,cAC3C,QAAQ,QAAQ,IAAI;SAC9B;AAIV,QAAO;;AAIT,SAAS,eAAe,WAAmB,SAA0B;AAEnE,KAAI,YAAY,UAAW,QAAO;AAGlC,KAAI,QAAQ,SAAS,IAAI,EAAE;EACzB,MAAM,SAAS,QAAQ,MAAM,GAAG,GAAG;AACnC,SAAO,UAAU,WAAW,OAAO;;AAIrC,KAAI,QAAQ,WAAW,IAAI,CAEzB,QAAO,CAAC,eAAe,WADA,QAAQ,MAAM,EAAE,CACU;AAGnD,QAAO;;AAIT,SAAS,UAAU,WAA4B;CAC7C,MAAM,WAAW,aAAa;AAC9B,KAAI,CAAC,SAAU,QAAO;CAGtB,MAAM,WAAW,SAAS,MAAM,SAAS,CAAC,QAAQ,MAAM,EAAE,SAAS,EAAE;AAGrE,KA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