@arkiv-network/sdk 0.8.0-advanced.2 → 0.8.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -42
- package/dist/attr/index.cjs +33 -34
- package/dist/attr/index.d.cts +1 -1
- package/dist/attr/index.d.ts +1 -2
- package/dist/attr/index.js +1 -2
- package/dist/{attributes-Df9IsCVs.cjs → attr-BXTkpnoc.cjs} +13 -3
- package/dist/{attributes-BhY5DwJp.js → attr-tmyREHtw.js} +14 -4
- package/dist/attr-tmyREHtw.js.map +1 -0
- package/dist/chains/index.cjs +1 -1
- package/dist/chains/index.d.cts +3 -0
- package/dist/chains/index.d.cts.map +1 -1
- package/dist/chains/index.d.ts +3 -0
- package/dist/chains/index.d.ts.map +1 -1
- package/dist/chains/index.js +1 -1
- package/dist/{chains-BYRTTipa.cjs → chains-BfNQliHU.cjs} +3 -0
- package/dist/{chains-BJrZs6sG.js → chains-Du8tql7I.js} +4 -1
- package/dist/chains-Du8tql7I.js.map +1 -0
- package/dist/{arkivTransactions-NtGD6uk5.d.ts → changeOwnership-B0ar96ub.d.ts} +74 -123
- package/dist/changeOwnership-B0ar96ub.d.ts.map +1 -0
- package/dist/{arkivTransactions-D74gERHG.d.cts → changeOwnership-BofkLnXJ.d.cts} +74 -123
- package/dist/changeOwnership-BofkLnXJ.d.cts.map +1 -0
- package/dist/entity/index.cjs +9 -9
- package/dist/entity/index.d.cts +3 -3
- package/dist/entity/index.d.ts +4 -5
- package/dist/entity/index.js +5 -6
- package/dist/{entity-BYQR1uoe.js → entity-BIp_df9u.js} +1 -1
- package/dist/{entity-BYQR1uoe.js.map → entity-BIp_df9u.js.map} +1 -1
- package/dist/{key-D1Bh7MF0.js → entity-CniBgBSd.js} +31 -19
- package/dist/entity-CniBgBSd.js.map +1 -0
- package/dist/{key-WKhXnXuU.cjs → entity-DJ0Gml9c.cjs} +37 -19
- package/dist/{errors-LTe7bOYS.js → errors-D2E1GRjw.js} +2 -2
- package/dist/errors-D2E1GRjw.js.map +1 -0
- package/dist/{errors-BVbjKVMN.cjs → errors-DhV00966.cjs} +1 -1
- package/dist/{expiry-nDbCgZX4.d.ts → expiry-BxOlvVWC.d.ts} +1 -1
- package/dist/{expiry-nDbCgZX4.d.ts.map → expiry-BxOlvVWC.d.ts.map} +1 -1
- package/dist/{expiry-BELY2Kpw.cjs → expiry-CG9GhVXv.cjs} +1 -1
- package/dist/{expiry-BjpxZZQU.js → expiry-Cgdb_dbq.js} +2 -2
- package/dist/expiry-Cgdb_dbq.js.map +1 -0
- package/dist/expiry-DRV29F1r.d.cts.map +1 -1
- package/dist/{flags-CRjPpoh3.d.cts → flags-0Vl5rrHq.d.cts} +1 -1
- package/dist/{flags-CRjPpoh3.d.cts.map → flags-0Vl5rrHq.d.cts.map} +1 -1
- package/dist/{flags-kr276q6i.cjs → flags-DCD26uhe.cjs} +1 -1
- package/dist/{flags-DFBs2J94.js → flags-DUT2gHEU.js} +2 -2
- package/dist/{flags-DFBs2J94.js.map → flags-DUT2gHEU.js.map} +1 -1
- package/dist/{flags-5dTNRnow.d.ts → flags-wmcMoAnN.d.ts} +1 -1
- package/dist/{flags-5dTNRnow.d.ts.map → flags-wmcMoAnN.d.ts.map} +1 -1
- package/dist/{index-fX_XyqLp.d.ts → index-BGp2plHs.d.cts} +15 -13
- package/dist/index-BGp2plHs.d.cts.map +1 -0
- package/dist/{index-DHDud2hC.d.ts → index-BKB875Um.d.ts} +5 -7
- package/dist/{index-DHDud2hC.d.ts.map → index-BKB875Um.d.ts.map} +1 -1
- package/dist/{index-DvYvrkdk.d.ts → index-CIcHPx2j.d.cts} +110 -6
- package/dist/index-CIcHPx2j.d.cts.map +1 -0
- package/dist/{index-CV5zCdpa.d.cts → index-Cd2aaWme.d.ts} +13 -6
- package/dist/index-Cd2aaWme.d.ts.map +1 -0
- package/dist/{index-CA4V7Pdh.d.cts → index-ezMZ2-JH.d.ts} +15 -13
- package/dist/index-ezMZ2-JH.d.ts.map +1 -0
- package/dist/{index-BF7Mq9Is.d.cts → index-rINthNuU.d.cts} +5 -7
- package/dist/{index-BF7Mq9Is.d.cts.map → index-rINthNuU.d.cts.map} +1 -1
- package/dist/index.cjs +433 -139
- package/dist/index.d.cts +58 -164
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +59 -166
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +376 -75
- package/dist/index.js.map +1 -1
- package/dist/{payload-CcUj85ys.d.ts → payload-CGvVPZQX.d.ts} +61 -2
- package/dist/payload-CGvVPZQX.d.ts.map +1 -0
- package/dist/{payload-Bz6651ax.js → payload-DE7wMztL.js} +28 -3
- package/dist/payload-DE7wMztL.js.map +1 -0
- package/dist/{payload-BNoud2KZ.d.cts → payload-Dfu30njp.d.cts} +60 -1
- package/dist/payload-Dfu30njp.d.cts.map +1 -0
- package/dist/{payload-KC14SDlN.cjs → payload-DqFweqiO.cjs} +27 -2
- package/dist/query/index.cjs +5 -7
- package/dist/query/index.d.cts +4 -4
- package/dist/query/index.d.ts +4 -5
- package/dist/query/index.js +5 -7
- package/dist/{queryBuilder-DM6AWCBa.js → queryBuilder-wvA8sn--.js} +169 -23
- package/dist/queryBuilder-wvA8sn--.js.map +1 -0
- package/dist/{queryBuilder-DbUMEZln.cjs → queryBuilder-zHGhDmaG.cjs} +215 -33
- package/dist/{selection-DPg0uyJf.d.cts → selection-Bv8_o-7i.d.cts} +76 -68
- package/dist/selection-Bv8_o-7i.d.cts.map +1 -0
- package/dist/{selection-C4UhsMOO.d.ts → selection-ox7zdtVm.d.ts} +76 -69
- package/dist/selection-ox7zdtVm.d.ts.map +1 -0
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.d.cts +6 -6
- package/dist/types/index.d.ts +7 -8
- package/dist/types/index.js +2 -2
- package/dist/utils/index.cjs +3 -3
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +3 -3
- package/package.json +1 -5
- package/src/actions/public/getEntity.ts +1 -0
- package/src/actions/public/predictEntityKeys.test.ts +17 -1
- package/src/actions/public/predictEntityKeys.ts +28 -14
- package/src/actions/public/query.ts +1 -5
- package/src/actions/wallet/createEntity.ts +7 -6
- package/src/actions/wallet/{mutateEntities.test.ts → executeBatch.test.ts} +7 -7
- package/src/actions/wallet/{mutateEntities.ts → executeBatch.ts} +26 -11
- package/src/actions/wallet/extendEntity.ts +1 -0
- package/src/actions/wallet/patchEntity.ts +3 -3
- package/src/attr/attributes.ts +8 -2
- package/src/attr/errors.ts +2 -2
- package/src/attr/types.ts +3 -3
- package/src/attr/values.ts +5 -1
- package/src/chains/localhost.ts +3 -0
- package/src/clients/createPublicClient.test.ts +1 -1
- package/src/clients/createPublicClient.ts +5 -5
- package/src/clients/createWalletClient.test.ts +2 -2
- package/src/clients/createWalletClient.ts +3 -5
- package/src/clients/decorators/arkivPublic.ts +13 -24
- package/src/clients/decorators/arkivWallet.ts +40 -47
- package/src/entity/create.test.ts +20 -1
- package/src/entity/errors.ts +4 -3
- package/src/entity/expiry.ts +1 -0
- package/src/entity/index.ts +2 -2
- package/src/entity/key.ts +23 -3
- package/src/entity/operations.ts +1 -0
- package/src/index.ts +0 -13
- package/src/query/engine.ts +0 -11
- package/src/query/errors.ts +1 -1
- package/src/query/expression.ts +14 -7
- package/src/query/queryBuilder.test.ts +1 -21
- package/src/query/queryBuilder.ts +3 -10
- package/src/types/index.ts +4 -4
- package/src/types/rpcSchema.ts +1 -0
- package/src/types/txParams.ts +8 -0
- package/src/utils/arkivTransactions.test.ts +7 -1
- package/src/utils/arkivTransactions.ts +114 -254
- package/src/utils/expirationTime.ts +39 -0
- package/src/utils/payload.ts +25 -0
- package/dist/actions/advanced/index.cjs +0 -13
- package/dist/actions/advanced/index.d.cts +0 -8
- package/dist/actions/advanced/index.d.ts +0 -9
- package/dist/actions/advanced/index.js +0 -9
- package/dist/advanced-8ZPTmmaN.js +0 -598
- package/dist/advanced-8ZPTmmaN.js.map +0 -1
- package/dist/advanced-fPImL6lW.cjs +0 -656
- package/dist/arkivTransactions-D74gERHG.d.cts.map +0 -1
- package/dist/arkivTransactions-NtGD6uk5.d.ts.map +0 -1
- package/dist/attributes-BhY5DwJp.js.map +0 -1
- package/dist/chains-BJrZs6sG.js.map +0 -1
- package/dist/codec-Car3KkFF.d.ts +0 -102
- package/dist/codec-Car3KkFF.d.ts.map +0 -1
- package/dist/entity-B7G8q_Eo.cjs +0 -0
- package/dist/entity-CD_qFF2M.js +0 -0
- package/dist/errors-LTe7bOYS.js.map +0 -1
- package/dist/expiry-BjpxZZQU.js.map +0 -1
- package/dist/index-B5j76711.d.ts +0 -184
- package/dist/index-B5j76711.d.ts.map +0 -1
- package/dist/index-CA4V7Pdh.d.cts.map +0 -1
- package/dist/index-CV5zCdpa.d.cts.map +0 -1
- package/dist/index-DvYvrkdk.d.ts.map +0 -1
- package/dist/index-EeUO0nnJ.d.cts +0 -184
- package/dist/index-EeUO0nnJ.d.cts.map +0 -1
- package/dist/index-fX_XyqLp.d.ts.map +0 -1
- package/dist/key-D1Bh7MF0.js.map +0 -1
- package/dist/logger-CVpvU8ik.js +0 -153
- package/dist/logger-CVpvU8ik.js.map +0 -1
- package/dist/logger-Cr15lPAQ.cjs +0 -188
- package/dist/payload-BNoud2KZ.d.cts.map +0 -1
- package/dist/payload-Bz6651ax.js.map +0 -1
- package/dist/payload-CcUj85ys.d.ts.map +0 -1
- package/dist/queryBuilder-DM6AWCBa.js.map +0 -1
- package/dist/selection-C4UhsMOO.d.ts.map +0 -1
- package/dist/selection-DPg0uyJf.d.cts.map +0 -1
- package/dist/types-Bu_ZwMbZ.js +0 -0
- package/dist/types-NRqymi6S.cjs +0 -0
- package/src/actions/advanced/advanced.test.ts +0 -258
- package/src/actions/advanced/buildMutation.ts +0 -104
- package/src/actions/advanced/getMutationResult.ts +0 -112
- package/src/actions/advanced/index.ts +0 -21
- package/src/actions/advanced/pingTransaction.ts +0 -43
- package/src/actions/advanced/sendMutation.ts +0 -59
- package/src/clients/decorators/arkivAdvanced.ts +0 -144
- /package/dist/{entity-B00Li04j.cjs → entity-B0t6sN7F.cjs} +0 -0
- /package/dist/{attr-DlmErkvR.cjs → types-Bx1EKe0v.js} +0 -0
- /package/dist/{attr-GcQKatub.js → types-CKPddlfS.cjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload-DE7wMztL.js","names":[],"sources":["../src/utils/expirationTime.ts","../src/utils/payload.ts"],"sourcesContent":["import { InvalidExpiryError } from \"../entity/errors\"\nimport { type Expiry, type Lifetime, makeExpiry, toBlocks } from \"../entity/expiry\"\nimport { MAX_EXPIRES_AT } from \"../entity/params\"\n\n/**\n * The optional floor a deadline can carry.\n *\n * `atLeast` takes a duration — one of the `from*` helpers — and never another deadline, so\n * `atBlock(x, { atLeast: atBlock(y) })` does not compile. Two deadlines are not a thing the engine\n * can resolve.\n */\nexport type DeadlineOptions = {\n /** Live at least this long from now, even if the deadline is sooner. */\n atLeast?: Lifetime | undefined\n}\n\nfunction lifetimeOf(seconds: number): Lifetime {\n return makeExpiry(toBlocks(seconds), 0n) as Lifetime\n}\n\nfunction deadlineOf(expiresAt: bigint | Date, options?: DeadlineOptions): Expiry {\n return makeExpiry(options?.atLeast?.minLifetime ?? 0n, expiresAt)\n}\n\n/**\n * Builds the `expires` of a create or an extension.\n *\n * Every helper returns the `{ minLifetime, expiresAt }` pair the ABI carries, so what you write is\n * what goes on the wire. The `from*` helpers fill `minLifetime` and leave `expiresAt` at `0n`;\n * {@link ExpirationTime.atBlock} and {@link ExpirationTime.atDate} do the reverse. The engine takes\n * whichever comes later, which is why a deadline can also carry a floor.\n *\n * Values are plain data — no methods, no prototype — so they log, clone and compare like any other\n * object.\n *\n * @example The 90% case: a duration, and nothing else to think about.\n * await client.createEntity({ payload, contentType, expires: ExpirationTime.fromDays(30) })\n *\n * @example An exact block, or a wall-clock date.\n * expires: ExpirationTime.atBlock(1_200_000n)\n * expires: ExpirationTime.atDate(new Date(\"2027-01-01\"))\n *\n * @example A deadline that still guarantees a minimum life.\n * expires: ExpirationTime.atBlock(1_200_000n, { atLeast: ExpirationTime.fromDays(1) })\n */\nexport const ExpirationTime = {\n /**\n * A raw number of seconds. Must be a whole number of blocks' worth — see the other helpers, which\n * all produce one by construction.\n *\n * @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.\n */\n fromSeconds: (seconds: number): Lifetime => lifetimeOf(seconds),\n /**\n * A number of minutes.\n *\n * @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.\n */\n fromMinutes: (minutes: number): Lifetime => lifetimeOf(minutes * 60),\n\n /**\n * A number of hours.\n *\n * @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.\n */\n fromHours: (hours: number): Lifetime => lifetimeOf(hours * 60 * 60),\n\n /**\n * A number of days. The everyday form — `fromDays(30)` is what most creates want.\n *\n * @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.\n */\n fromDays: (days: number): Lifetime => lifetimeOf(days * 24 * 60 * 60),\n\n /**\n * A number of weeks, each of 7 days.\n *\n * @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.\n */\n fromWeeks: (weeks: number): Lifetime => lifetimeOf(weeks * 7 * 24 * 60 * 60),\n\n /**\n * A number of months, each of exactly **30 days** — calendar months are not all the same length,\n * and a lifetime is a duration rather than a date. Use {@link ExpirationTime.atDate} when the\n * expiry has to land on a particular calendar day.\n *\n * @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.\n */\n fromMonths: (months: number): Lifetime => lifetimeOf(months * 30 * 24 * 60 * 60),\n\n /**\n * A number of years, each of exactly **365 days** — leap days are not counted, so `fromYears(4)`\n * is a day short of four calendar years. Use {@link ExpirationTime.atDate} for a calendar\n * deadline.\n *\n * @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.\n */\n fromYears: (years: number): Lifetime => lifetimeOf(years * 365 * 24 * 60 * 60),\n\n /**\n * A number of blocks, for callers who think in the chain's own unit. Always exact — there is no\n * conversion to be approximate about.\n *\n * @throws {InvalidExpiryError} If the count is not a positive whole number.\n */\n fromBlocks: (blocks: number): Lifetime => {\n if (!Number.isInteger(blocks) || blocks <= 0) {\n throw new InvalidExpiryError(\n `a lifetime must be a positive whole number of blocks, got ${blocks}`,\n )\n }\n return makeExpiry(BigInt(blocks), 0n) as Lifetime\n },\n\n /**\n * An absolute block height.\n *\n * @param block - The block the entity expires at.\n * @param options - Optionally, a floor: `{ atLeast: ExpirationTime.fromDays(1) }`.\n * @throws {InvalidExpiryError} If the height is negative.\n */\n atBlock: (block: bigint, options?: DeadlineOptions): Expiry => {\n if (typeof block !== \"bigint\" || block < 0n) {\n throw new InvalidExpiryError(`a deadline must be a non-negative block height, got ${block}`)\n }\n return deadlineOf(block, options)\n },\n\n /**\n * A wall-clock instant, placed against the block the transaction is built on.\n *\n * A date cannot land on a block boundary in general, so it rounds **up** to the next block: the\n * entity lives until at least the instant asked for. This is why a date is never rejected for\n * \"not being a whole number of blocks\" the way a duration is — it becomes a block height, not a\n * duration.\n *\n * @param date - When the entity should expire.\n * @param options - Optionally, a floor: `{ atLeast: ExpirationTime.fromDays(1) }`.\n * @throws {InvalidExpiryError} If the value is not a valid `Date`.\n */\n atDate: (date: Date, options?: DeadlineOptions): Expiry => {\n if (!(date instanceof Date) || Number.isNaN(date.getTime())) {\n throw new InvalidExpiryError(`a deadline must be a valid Date, got ${String(date)}`)\n }\n return deadlineOf(date, options)\n },\n\n /**\n * An entity that should never expire.\n *\n * This is `atBlock(MAX_EXPIRES_AT)` — the largest expiry the `uint64` field holds — and the\n * engine treats it as an ordinary deadline rather than a special case. There is no permanence\n * flag; a block height no chain will reach is what permanence is.\n */\n permanent: (): Expiry => deadlineOf(MAX_EXPIRES_AT),\n}\n","import { stringToBytes, toBytes } from \"viem\"\n\n/**\n * A JSON-serialisable value as an entity payload — `JSON.stringify` then UTF-8.\n *\n * Pair it with `contentType: \"application/json\"`, which is what lets `entity.toJson()` read it back.\n *\n * @example\n * await client.createEntity({\n * payload: jsonToPayload({ hello: \"world\" }),\n * contentType: \"application/json\",\n * expires: ExpirationTime.fromDays(30),\n * })\n */\nexport function jsonToPayload(json: object): Uint8Array {\n return toBytes(JSON.stringify(json))\n}\n\n/**\n * A string as an entity payload, encoded as UTF-8.\n *\n * Hex-looking text is encoded as text: `stringToPayload(\"0xab\")` gives the four bytes of that\n * string, not the single byte `0xab`. Read it back with `entity.toText()`.\n *\n * @example\n * await client.createEntity({\n * payload: stringToPayload(\"hello\"),\n * contentType: \"text/plain\",\n * expires: ExpirationTime.fromDays(30),\n * })\n */\nexport function stringToPayload(data: string): Uint8Array {\n // stringToBytes, not toBytes: toBytes hex-decodes hex-looking strings, which\n // would corrupt payloads like \"0xab\" instead of UTF-8 encoding them\n return stringToBytes(data)\n}\n"],"mappings":";;;;;AAgBA,SAAS,WAAW,SAA2B;AAC7C,QAAO,WAAW,SAAS,QAAQ,EAAE,GAAG;;AAG1C,SAAS,WAAW,WAA0B,SAAmC;AAC/E,QAAO,WAAW,SAAS,SAAS,eAAe,IAAI,UAAU;;;;;;;;;;;;;;;;;;;;;;;AAwBnE,MAAa,iBAAiB;CAO5B,cAAc,YAA8B,WAAW,QAAQ;CAM/D,cAAc,YAA8B,WAAW,UAAU,GAAG;CAOpE,YAAY,UAA4B,WAAW,QAAQ,KAAK,GAAG;CAOnE,WAAW,SAA2B,WAAW,OAAO,KAAK,KAAK,GAAG;CAOrE,YAAY,UAA4B,WAAW,QAAQ,IAAI,KAAK,KAAK,GAAG;CAS5E,aAAa,WAA6B,WAAW,SAAS,KAAK,KAAK,KAAK,GAAG;CAShF,YAAY,UAA4B,WAAW,QAAQ,MAAM,KAAK,KAAK,GAAG;CAQ9E,aAAa,WAA6B;AACxC,MAAI,CAAC,OAAO,UAAU,OAAO,IAAI,UAAU,EACzC,OAAM,IAAI,mBACR,6DAA6D,SAC9D;AAEH,SAAO,WAAW,OAAO,OAAO,EAAE,GAAG;;CAUvC,UAAU,OAAe,YAAsC;AAC7D,MAAI,OAAO,UAAU,YAAY,QAAQ,GACvC,OAAM,IAAI,mBAAmB,uDAAuD,QAAQ;AAE9F,SAAO,WAAW,OAAO,QAAQ;;CAenC,SAAS,MAAY,YAAsC;AACzD,MAAI,EAAE,gBAAgB,SAAS,OAAO,MAAM,KAAK,SAAS,CAAC,CACzD,OAAM,IAAI,mBAAmB,wCAAwC,OAAO,KAAK,GAAG;AAEtF,SAAO,WAAW,MAAM,QAAQ;;CAUlC,iBAAyB,WAAW,eAAe;CACpD;;;;;;;;;;;;;;;;AC7ID,SAAgB,cAAc,MAA0B;AACtD,QAAO,QAAQ,KAAK,UAAU,KAAK,CAAC;;;;;;;;;;;;;;;AAgBtC,SAAgB,gBAAgB,MAA0B;AAGxD,QAAO,cAAc,KAAK"}
|
|
@@ -42,11 +42,45 @@ declare const ExpirationTime: {
|
|
|
42
42
|
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
43
43
|
*/
|
|
44
44
|
fromSeconds: (seconds: number) => Lifetime;
|
|
45
|
+
/**
|
|
46
|
+
* A number of minutes.
|
|
47
|
+
*
|
|
48
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
49
|
+
*/
|
|
45
50
|
fromMinutes: (minutes: number) => Lifetime;
|
|
51
|
+
/**
|
|
52
|
+
* A number of hours.
|
|
53
|
+
*
|
|
54
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
55
|
+
*/
|
|
46
56
|
fromHours: (hours: number) => Lifetime;
|
|
57
|
+
/**
|
|
58
|
+
* A number of days. The everyday form — `fromDays(30)` is what most creates want.
|
|
59
|
+
*
|
|
60
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
61
|
+
*/
|
|
47
62
|
fromDays: (days: number) => Lifetime;
|
|
63
|
+
/**
|
|
64
|
+
* A number of weeks, each of 7 days.
|
|
65
|
+
*
|
|
66
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
67
|
+
*/
|
|
48
68
|
fromWeeks: (weeks: number) => Lifetime;
|
|
69
|
+
/**
|
|
70
|
+
* A number of months, each of exactly **30 days** — calendar months are not all the same length,
|
|
71
|
+
* and a lifetime is a duration rather than a date. Use {@link ExpirationTime.atDate} when the
|
|
72
|
+
* expiry has to land on a particular calendar day.
|
|
73
|
+
*
|
|
74
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
75
|
+
*/
|
|
49
76
|
fromMonths: (months: number) => Lifetime;
|
|
77
|
+
/**
|
|
78
|
+
* A number of years, each of exactly **365 days** — leap days are not counted, so `fromYears(4)`
|
|
79
|
+
* is a day short of four calendar years. Use {@link ExpirationTime.atDate} for a calendar
|
|
80
|
+
* deadline.
|
|
81
|
+
*
|
|
82
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
83
|
+
*/
|
|
50
84
|
fromYears: (years: number) => Lifetime;
|
|
51
85
|
/**
|
|
52
86
|
* A number of blocks, for callers who think in the chain's own unit. Always exact — there is no
|
|
@@ -87,8 +121,33 @@ declare const ExpirationTime: {
|
|
|
87
121
|
};
|
|
88
122
|
//#endregion
|
|
89
123
|
//#region src/utils/payload.d.ts
|
|
124
|
+
/**
|
|
125
|
+
* A JSON-serialisable value as an entity payload — `JSON.stringify` then UTF-8.
|
|
126
|
+
*
|
|
127
|
+
* Pair it with `contentType: "application/json"`, which is what lets `entity.toJson()` read it back.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* await client.createEntity({
|
|
131
|
+
* payload: jsonToPayload({ hello: "world" }),
|
|
132
|
+
* contentType: "application/json",
|
|
133
|
+
* expires: ExpirationTime.fromDays(30),
|
|
134
|
+
* })
|
|
135
|
+
*/
|
|
90
136
|
declare function jsonToPayload(json: object): Uint8Array;
|
|
137
|
+
/**
|
|
138
|
+
* A string as an entity payload, encoded as UTF-8.
|
|
139
|
+
*
|
|
140
|
+
* Hex-looking text is encoded as text: `stringToPayload("0xab")` gives the four bytes of that
|
|
141
|
+
* string, not the single byte `0xab`. Read it back with `entity.toText()`.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* await client.createEntity({
|
|
145
|
+
* payload: stringToPayload("hello"),
|
|
146
|
+
* contentType: "text/plain",
|
|
147
|
+
* expires: ExpirationTime.fromDays(30),
|
|
148
|
+
* })
|
|
149
|
+
*/
|
|
91
150
|
declare function stringToPayload(data: string): Uint8Array;
|
|
92
151
|
//#endregion
|
|
93
152
|
export { ExpirationTime as i, stringToPayload as n, DeadlineOptions as r, jsonToPayload as t };
|
|
94
|
-
//# sourceMappingURL=payload-
|
|
153
|
+
//# sourceMappingURL=payload-Dfu30njp.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload-Dfu30njp.d.cts","names":[],"sources":["../src/utils/expirationTime.ts","../src/utils/payload.ts"],"sourcesContent":[],"mappings":";;;;;;AAWA;AAkCA;;;;AA2B4B,KA7DhB,eAAA,GA6DgB;EAOE;EASE,OAAA,CAAA,EA3EpB,QA2EoB,GAAA,SAAA;CASF;;;;;;;;;;;;ACnF9B;AAiBA;;;;;;;;;cDca;;;;;;;oCAOqB;;;;;;oCAMA;;;;;;gCAOJ;;;;;;8BAOF;;;;;;gCAOE;;;;;;;;kCASE;;;;;;;;gCASF;;;;;;;kCAQE;;;;;;;;qCAgBK,oBAAkB;;;;;;;;;;;;;iBAmBtC,gBAAgB,oBAAkB;;;;;;;;mBAclC;;;;;;;AA/IjB;AAkCA;;;;;;;;AA4DgC,iBC3FhB,aAAA,CD2FgB,IAAA,EAAA,MAAA,CAAA,EC3Fa,UD2Fb;;;;;;;;;;;AC3FhC;AAiBA;;iBAAgB,eAAA,gBAA+B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const require_errors = require('./errors-DhV00966.cjs');
|
|
2
|
+
const require_expiry = require('./expiry-CG9GhVXv.cjs');
|
|
3
3
|
let viem = require("viem");
|
|
4
4
|
|
|
5
5
|
//#region src/utils/expirationTime.ts
|
|
@@ -55,9 +55,34 @@ const ExpirationTime = {
|
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/utils/payload.ts
|
|
58
|
+
/**
|
|
59
|
+
* A JSON-serialisable value as an entity payload — `JSON.stringify` then UTF-8.
|
|
60
|
+
*
|
|
61
|
+
* Pair it with `contentType: "application/json"`, which is what lets `entity.toJson()` read it back.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* await client.createEntity({
|
|
65
|
+
* payload: jsonToPayload({ hello: "world" }),
|
|
66
|
+
* contentType: "application/json",
|
|
67
|
+
* expires: ExpirationTime.fromDays(30),
|
|
68
|
+
* })
|
|
69
|
+
*/
|
|
58
70
|
function jsonToPayload(json) {
|
|
59
71
|
return (0, viem.toBytes)(JSON.stringify(json));
|
|
60
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* A string as an entity payload, encoded as UTF-8.
|
|
75
|
+
*
|
|
76
|
+
* Hex-looking text is encoded as text: `stringToPayload("0xab")` gives the four bytes of that
|
|
77
|
+
* string, not the single byte `0xab`. Read it back with `entity.toText()`.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* await client.createEntity({
|
|
81
|
+
* payload: stringToPayload("hello"),
|
|
82
|
+
* contentType: "text/plain",
|
|
83
|
+
* expires: ExpirationTime.fromDays(30),
|
|
84
|
+
* })
|
|
85
|
+
*/
|
|
61
86
|
function stringToPayload(data) {
|
|
62
87
|
return (0, viem.stringToBytes)(data);
|
|
63
88
|
}
|
package/dist/query/index.cjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
require('../
|
|
2
|
-
require('../
|
|
3
|
-
require('../
|
|
4
|
-
require('../
|
|
5
|
-
require('../
|
|
6
|
-
require('../entity-B00Li04j.cjs');
|
|
7
|
-
const require_queryBuilder = require('../queryBuilder-DbUMEZln.cjs');
|
|
1
|
+
require('../attr-BXTkpnoc.cjs');
|
|
2
|
+
const require_queryBuilder = require('../queryBuilder-zHGhDmaG.cjs');
|
|
3
|
+
require('../errors-DhV00966.cjs');
|
|
4
|
+
require('../flags-DCD26uhe.cjs');
|
|
5
|
+
require('../entity-B0t6sN7F.cjs');
|
|
8
6
|
|
|
9
7
|
exports.InvalidPredicateError = require_queryBuilder.InvalidPredicateError;
|
|
10
8
|
exports.MAX_LIMIT = require_queryBuilder.MAX_LIMIT;
|
package/dist/query/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import { a as QueryErrorKind, c as QueryRequest, i as QueryError, l as QueryResponse, n as QueryResult, o as UnsupportedOperatorError, r as InvalidPredicateError, s as MAX_LIMIT, t as SelectQueryBuilder, u as runQuery } from "../index-
|
|
1
|
+
import "../index-CIcHPx2j.cjs";
|
|
2
|
+
import "../flags-0Vl5rrHq.cjs";
|
|
3
|
+
import { C as lte, D as render, E as or, O as startsWith, S as lt, T as not, _ as eq, a as SelectionFields, b as gte, c as ComparisonNode, d as Expression, f as NotNode, g as and, h as TypeOfNode, i as SelectArg, l as ComparisonOperator, m as StartsWithNode, n as FullEntity, o as toRpcSelect, p as OrNode, r as ProjectedEntity, s as AndNode, t as EntitySelection, u as ExistsNode, v as exists, w as ne, x as hasType, y as gt } from "../selection-Bv8_o-7i.cjs";
|
|
4
|
+
import { a as QueryErrorKind, c as QueryRequest, i as QueryError, l as QueryResponse, n as QueryResult, o as UnsupportedOperatorError, r as InvalidPredicateError, s as MAX_LIMIT, t as SelectQueryBuilder, u as runQuery } from "../index-rINthNuU.cjs";
|
|
5
5
|
export { AndNode, ComparisonNode, ComparisonOperator, EntitySelection, ExistsNode, Expression, FullEntity, InvalidPredicateError, MAX_LIMIT, NotNode, OrNode, ProjectedEntity, QueryError, QueryErrorKind, QueryRequest, QueryResponse, QueryResult, SelectArg, SelectQueryBuilder, SelectionFields, StartsWithNode, TypeOfNode, UnsupportedOperatorError, and, eq, exists, gt, gte, hasType, lt, lte, ne, not, or, render, runQuery, startsWith, toRpcSelect };
|
package/dist/query/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import { a as QueryErrorKind, c as QueryRequest, i as QueryError, l as QueryResponse, n as QueryResult, o as UnsupportedOperatorError, r as InvalidPredicateError, s as MAX_LIMIT, t as SelectQueryBuilder, u as runQuery } from "../index-DHDud2hC.js";
|
|
1
|
+
import "../index-Cd2aaWme.js";
|
|
2
|
+
import "../flags-wmcMoAnN.js";
|
|
3
|
+
import { C as lte, D as render, E as or, O as startsWith, S as lt, T as not, _ as eq, a as SelectionFields, b as gte, c as ComparisonNode, d as Expression, f as NotNode, g as and, h as TypeOfNode, i as SelectArg, l as ComparisonOperator, m as StartsWithNode, n as FullEntity, o as toRpcSelect, p as OrNode, r as ProjectedEntity, s as AndNode, t as EntitySelection, u as ExistsNode, v as exists, w as ne, x as hasType, y as gt } from "../selection-ox7zdtVm.js";
|
|
4
|
+
import { a as QueryErrorKind, c as QueryRequest, i as QueryError, l as QueryResponse, n as QueryResult, o as UnsupportedOperatorError, r as InvalidPredicateError, s as MAX_LIMIT, t as SelectQueryBuilder, u as runQuery } from "../index-BKB875Um.js";
|
|
6
5
|
export { AndNode, ComparisonNode, ComparisonOperator, EntitySelection, ExistsNode, Expression, FullEntity, InvalidPredicateError, MAX_LIMIT, NotNode, OrNode, ProjectedEntity, QueryError, QueryErrorKind, QueryRequest, QueryResponse, QueryResult, SelectArg, SelectQueryBuilder, SelectionFields, StartsWithNode, TypeOfNode, UnsupportedOperatorError, and, eq, exists, gt, gte, hasType, lt, lte, ne, not, or, render, runQuery, startsWith, toRpcSelect };
|
package/dist/query/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import "../
|
|
6
|
-
import "../entity-BYQR1uoe.js";
|
|
7
|
-
import { _ as MAX_LIMIT, a as eq, b as QueryError, c as gte, d as lte, f as ne, g as startsWith, h as render, i as and, l as hasType, m as or, n as QueryResult, o as exists, p as not, r as toRpcSelect, s as gt, t as SelectQueryBuilder, u as lt, v as runQuery, x as UnsupportedOperatorError, y as InvalidPredicateError } from "../queryBuilder-DM6AWCBa.js";
|
|
1
|
+
import "../attr-tmyREHtw.js";
|
|
2
|
+
import { _ as MAX_LIMIT, a as eq, b as QueryError, c as gte, d as lte, f as ne, g as startsWith, h as render, i as and, l as hasType, m as or, n as QueryResult, o as exists, p as not, r as toRpcSelect, s as gt, t as SelectQueryBuilder, u as lt, v as runQuery, x as UnsupportedOperatorError, y as InvalidPredicateError } from "../queryBuilder-wvA8sn--.js";
|
|
3
|
+
import "../errors-D2E1GRjw.js";
|
|
4
|
+
import "../flags-DUT2gHEU.js";
|
|
5
|
+
import "../entity-BIp_df9u.js";
|
|
8
6
|
|
|
9
7
|
export { InvalidPredicateError, MAX_LIMIT, QueryError, QueryResult, SelectQueryBuilder, UnsupportedOperatorError, and, eq, exists, gt, gte, hasType, lt, lte, ne, not, or, render, runQuery, startsWith, toRpcSelect };
|
|
@@ -1,9 +1,159 @@
|
|
|
1
|
-
import { C as str, D as TYPE_IDS, c as asTypeTag, h as addr, l as decodeRpcValue, s as validateAttributeName, w as toValue } from "./
|
|
2
|
-
import { n as encodeCreationFlags, t as decodeCreationFlags } from "./flags-
|
|
3
|
-
import {
|
|
4
|
-
import { t as Entity } from "./entity-BYQR1uoe.js";
|
|
1
|
+
import { C as str, D as TYPE_IDS, c as asTypeTag, h as addr, l as decodeRpcValue, s as validateAttributeName, w as toValue } from "./attr-tmyREHtw.js";
|
|
2
|
+
import { n as encodeCreationFlags, t as decodeCreationFlags } from "./flags-DUT2gHEU.js";
|
|
3
|
+
import { t as Entity } from "./entity-BIp_df9u.js";
|
|
5
4
|
import { checksumAddress, hexToBytes, numberToHex } from "viem";
|
|
6
5
|
|
|
6
|
+
//#region src/utils/logger.ts
|
|
7
|
+
const ROOT_NAMESPACE = "arkiv";
|
|
8
|
+
function getDebugEnv() {
|
|
9
|
+
if (typeof process !== "undefined") {
|
|
10
|
+
const debugEnv = process?.env?.DEBUG;
|
|
11
|
+
if (debugEnv) return debugEnv;
|
|
12
|
+
}
|
|
13
|
+
if (typeof globalThis !== "undefined" && "localStorage" in globalThis) try {
|
|
14
|
+
return globalThis.localStorage?.getItem("DEBUG") || "";
|
|
15
|
+
} catch {}
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
function matchesPattern(namespace, pattern) {
|
|
19
|
+
if (pattern === namespace) return true;
|
|
20
|
+
if (pattern.endsWith("*")) {
|
|
21
|
+
const prefix = pattern.slice(0, -1);
|
|
22
|
+
return namespace.startsWith(prefix);
|
|
23
|
+
}
|
|
24
|
+
if (pattern.startsWith("-")) return !matchesPattern(namespace, pattern.slice(1));
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
function isEnabled(namespace) {
|
|
28
|
+
const debugEnv = getDebugEnv();
|
|
29
|
+
if (!debugEnv) return false;
|
|
30
|
+
const patterns = debugEnv.split(/[\s,]+/).filter((p) => p.length > 0);
|
|
31
|
+
if (patterns.length === 0) return false;
|
|
32
|
+
let enabled = false;
|
|
33
|
+
for (const pattern of patterns) if (pattern.startsWith("-")) {
|
|
34
|
+
if (matchesPattern(namespace, pattern)) return false;
|
|
35
|
+
} else if (matchesPattern(namespace, pattern)) enabled = true;
|
|
36
|
+
return enabled;
|
|
37
|
+
}
|
|
38
|
+
const enabledNamespaces = /* @__PURE__ */ new Set();
|
|
39
|
+
const disabledNamespaces = /* @__PURE__ */ new Set();
|
|
40
|
+
const COLOR_PALETTE = [
|
|
41
|
+
"#0000FF",
|
|
42
|
+
"#008000",
|
|
43
|
+
"#FF0000",
|
|
44
|
+
"#FF00FF",
|
|
45
|
+
"#FFA500",
|
|
46
|
+
"#800080",
|
|
47
|
+
"#00CED1",
|
|
48
|
+
"#FF1493",
|
|
49
|
+
"#32CD32",
|
|
50
|
+
"#1E90FF",
|
|
51
|
+
"#FF4500",
|
|
52
|
+
"#9370DB",
|
|
53
|
+
"#00FA9A",
|
|
54
|
+
"#FFD700",
|
|
55
|
+
"#DC143C",
|
|
56
|
+
"#00BFFF",
|
|
57
|
+
"#FF69B4",
|
|
58
|
+
"#20B2AA",
|
|
59
|
+
"#DA70D6",
|
|
60
|
+
"#4682B4"
|
|
61
|
+
];
|
|
62
|
+
const isNode = typeof process !== "undefined" && process.versions?.node != null;
|
|
63
|
+
const ANSI_COLORS = [
|
|
64
|
+
"\x1B[94m",
|
|
65
|
+
"\x1B[92m",
|
|
66
|
+
"\x1B[91m",
|
|
67
|
+
"\x1B[95m",
|
|
68
|
+
"\x1B[93m",
|
|
69
|
+
"\x1B[96m",
|
|
70
|
+
"\x1B[35m",
|
|
71
|
+
"\x1B[36m",
|
|
72
|
+
"\x1B[32m",
|
|
73
|
+
"\x1B[34m",
|
|
74
|
+
"\x1B[33m",
|
|
75
|
+
"\x1B[31m",
|
|
76
|
+
"\x1B[90m",
|
|
77
|
+
"\x1B[37m",
|
|
78
|
+
"\x1B[1m"
|
|
79
|
+
];
|
|
80
|
+
const ANSI_RESET = "\x1B[0m";
|
|
81
|
+
const ANSI_BOLD = "\x1B[1m";
|
|
82
|
+
const namespaceColors = /* @__PURE__ */ new Map();
|
|
83
|
+
function getColorForNamespace(namespace) {
|
|
84
|
+
const cachedColor = namespaceColors.get(namespace);
|
|
85
|
+
if (cachedColor) return cachedColor;
|
|
86
|
+
let hash = 0;
|
|
87
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
88
|
+
const char = namespace.charCodeAt(i);
|
|
89
|
+
hash = (hash << 5) - hash + char;
|
|
90
|
+
hash = hash & hash;
|
|
91
|
+
}
|
|
92
|
+
const colorIndex = Math.abs(hash) % COLOR_PALETTE.length;
|
|
93
|
+
const color = {
|
|
94
|
+
css: COLOR_PALETTE[colorIndex] ?? "inherit",
|
|
95
|
+
ansi: ANSI_COLORS[colorIndex % ANSI_COLORS.length] ?? ""
|
|
96
|
+
};
|
|
97
|
+
namespaceColors.set(namespace, color);
|
|
98
|
+
return color;
|
|
99
|
+
}
|
|
100
|
+
function createDebugLogger(namespace) {
|
|
101
|
+
const colors = getColorForNamespace(namespace);
|
|
102
|
+
return (...args) => {
|
|
103
|
+
const envEnabled = isEnabled(namespace);
|
|
104
|
+
const progEnabled = enabledNamespaces.has(namespace) && !disabledNamespaces.has(namespace);
|
|
105
|
+
if (envEnabled || progEnabled) if (isNode) {
|
|
106
|
+
const coloredNamespace = `${ANSI_BOLD}${colors.ansi}${namespace}${ANSI_RESET}`;
|
|
107
|
+
console.log(coloredNamespace, ...args);
|
|
108
|
+
} else {
|
|
109
|
+
const style1 = `color: ${colors.css}; font-weight: bold`;
|
|
110
|
+
console.log(`%c${namespace}%c`, style1, "color: inherit; font-weight: normal", ...args);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const getLogger = (scope) => {
|
|
115
|
+
return createDebugLogger(`${ROOT_NAMESPACE}:${scope}`);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/errors.ts
|
|
120
|
+
var EntityMutationError = class extends Error {
|
|
121
|
+
constructor(message, options) {
|
|
122
|
+
super(message, options);
|
|
123
|
+
this.name = "EntityMutationError";
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var NoMoreResultsError = class extends Error {
|
|
127
|
+
constructor() {
|
|
128
|
+
super("No more results — the last page carried no cursor. Check hasNextPage() before next().");
|
|
129
|
+
this.name = "NoMoreResultsError";
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var NoEntityFoundError = class extends Error {
|
|
133
|
+
/** The key that matched nothing, when the lookup was by key. */
|
|
134
|
+
entityKey;
|
|
135
|
+
constructor(entityKey) {
|
|
136
|
+
super(entityKey === void 0 ? "No entity found" : `No live entity with key ${entityKey}. It was never created, or it has been deleted or has expired.`);
|
|
137
|
+
this.name = "NoEntityFoundError";
|
|
138
|
+
this.entityKey = entityKey;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var EmptyPatchError = class extends Error {
|
|
142
|
+
entityKey;
|
|
143
|
+
constructor(entityKey) {
|
|
144
|
+
super(`The patch for entity ${entityKey} has nothing to apply. Pass "set" to write attributes, "unset" to remove them, or "payload"/"contentType" to replace the contents.`);
|
|
145
|
+
this.name = "EmptyPatchError";
|
|
146
|
+
this.entityKey = entityKey;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
var InvalidContentTypeError = class extends Error {
|
|
150
|
+
constructor(contentType) {
|
|
151
|
+
super(`Invalid content type "${contentType}". Must follow RFC 2045 MIME grammar and be lowercase only (e.g. "text/plain").`);
|
|
152
|
+
this.name = "InvalidContentTypeError";
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
7
157
|
//#region src/utils/entities.ts
|
|
8
158
|
const logger$1 = getLogger("utils:entities");
|
|
9
159
|
/**
|
|
@@ -90,7 +240,7 @@ function toFlagsByte(value) {
|
|
|
90
240
|
* | | `=` `!=` | `<` `<=` `>` `>=` | `STARTSWITH` |
|
|
91
241
|
* | --- | --- | --- | --- |
|
|
92
242
|
* | `bool` | yes | no | no |
|
|
93
|
-
* | `i32` `u256` `dec` | yes | yes | no |
|
|
243
|
+
* | `i32` `u64` `u256` `dec` | yes | yes | no |
|
|
94
244
|
* | `str` | yes | no | yes |
|
|
95
245
|
* | `addr` `key` `bytes32` | yes | no | no |
|
|
96
246
|
*/
|
|
@@ -203,7 +353,6 @@ const MAX_LIMIT = 200;
|
|
|
203
353
|
*/
|
|
204
354
|
async function runQuery(client, request) {
|
|
205
355
|
const { query, select, limit, cursor, atBlock } = request;
|
|
206
|
-
if (cursor !== void 0 && atBlock === void 0) throw new Error("a cursor must be resumed with `atBlock` set to the `blockNumber` of the page it came from — persist the two together.");
|
|
207
356
|
if (limit !== void 0) {
|
|
208
357
|
if (!Number.isInteger(limit) || limit < 1) throw new Error(`limit must be a positive integer, got ${limit}.`);
|
|
209
358
|
if (limit > MAX_LIMIT) throw new Error(`limit ${limit} exceeds the node maximum of ${MAX_LIMIT}. Page through the results with the cursor instead.`);
|
|
@@ -341,7 +490,7 @@ function ne(name, value) {
|
|
|
341
490
|
return comparison(name, "!=", value);
|
|
342
491
|
}
|
|
343
492
|
/**
|
|
344
|
-
* Attribute is greater than value. Ordered types only (`i32`, `u256`, `dec`).
|
|
493
|
+
* Attribute is greater than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
345
494
|
*
|
|
346
495
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
347
496
|
*
|
|
@@ -353,7 +502,7 @@ function gt(name, value) {
|
|
|
353
502
|
return comparison(name, ">", value);
|
|
354
503
|
}
|
|
355
504
|
/**
|
|
356
|
-
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u256`, `dec`).
|
|
505
|
+
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
357
506
|
*
|
|
358
507
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
359
508
|
*
|
|
@@ -364,7 +513,7 @@ function gte(name, value) {
|
|
|
364
513
|
return comparison(name, ">=", value);
|
|
365
514
|
}
|
|
366
515
|
/**
|
|
367
|
-
* Attribute is less than value. Ordered types only (`i32`, `u256`, `dec`).
|
|
516
|
+
* Attribute is less than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
368
517
|
*
|
|
369
518
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
370
519
|
*
|
|
@@ -375,7 +524,7 @@ function lt(name, value) {
|
|
|
375
524
|
return comparison(name, "<", value);
|
|
376
525
|
}
|
|
377
526
|
/**
|
|
378
|
-
* Attribute is less than or equal to value. Ordered types only (`i32`, `u256`, `dec`).
|
|
527
|
+
* Attribute is less than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
379
528
|
*
|
|
380
529
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
381
530
|
*
|
|
@@ -392,7 +541,9 @@ function lte(name, value) {
|
|
|
392
541
|
* `startsWith("name", "é")` matches only the same byte sequence, not another normal form of it.
|
|
393
542
|
*
|
|
394
543
|
* @param prefix - The prefix, as a bare string or a `str` value.
|
|
395
|
-
* @throws {
|
|
544
|
+
* @throws {InvalidPredicateError} If the name is not a queryable attribute.
|
|
545
|
+
* @throws {UnsupportedOperatorError} If given a value that is not a `str`, or a system attribute
|
|
546
|
+
* (none of which is a `str`).
|
|
396
547
|
*
|
|
397
548
|
* @example
|
|
398
549
|
* startsWith("desc", "ab") // desc STARTSWITH str('ab')
|
|
@@ -431,7 +582,8 @@ function exists(name) {
|
|
|
431
582
|
* Useful when the same name is written with different types across entities — a comparison already
|
|
432
583
|
* asserts the type, so this is for asking about the type alone.
|
|
433
584
|
*
|
|
434
|
-
* @param tag - The type tag: `bool`, `i32`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
585
|
+
* @param tag - The type tag: `bool`, `i32`, `u64`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
586
|
+
* `key`.
|
|
435
587
|
* @throws {InvalidPredicateError} If the tag is not a settable type, or the name is a system
|
|
436
588
|
* attribute (whose type is fixed).
|
|
437
589
|
*
|
|
@@ -441,7 +593,7 @@ function exists(name) {
|
|
|
441
593
|
function hasType(name, tag) {
|
|
442
594
|
const system = resolveReference(name);
|
|
443
595
|
if (system !== void 0) throw new InvalidPredicateError(`"${name}" is always a ${system} — a system attribute has a fixed type, so TYPEOF(${name}) is a constant.`, name);
|
|
444
|
-
if (!isUserTypeTag(tag)) throw new InvalidPredicateError(`"${tag}" is not a settable attribute type. Use one of bool, i32, u256, dec, bytes32, str, addr, key.`, name);
|
|
596
|
+
if (!isUserTypeTag(tag)) throw new InvalidPredicateError(`"${tag}" is not a settable attribute type. Use one of bool, i32, u64, u256, dec, bytes32, str, addr, key.`, name);
|
|
445
597
|
return node({
|
|
446
598
|
kind: "typeOf",
|
|
447
599
|
name,
|
|
@@ -730,9 +882,7 @@ var SelectQueryBuilder = class {
|
|
|
730
882
|
*
|
|
731
883
|
* Pagination normally goes through {@link QueryResult.next}, which carries the cursor for you;
|
|
732
884
|
* this is for resuming a walk in a later process. A cursor is bound to the query, block and
|
|
733
|
-
* selection it came from, so it must be used with an identically-built query
|
|
734
|
-
* set to the `blockNumber` of the page the cursor came from is required (persist the two
|
|
735
|
-
* together), and a fetch with a cursor but no block rejects locally.
|
|
885
|
+
* selection it came from, so it must be used with an identically-built query.
|
|
736
886
|
*/
|
|
737
887
|
cursor(cursor) {
|
|
738
888
|
this._cursor = cursor;
|
|
@@ -808,13 +958,9 @@ async function fetchPage(client, request, cursor) {
|
|
|
808
958
|
...request,
|
|
809
959
|
cursor
|
|
810
960
|
});
|
|
811
|
-
|
|
812
|
-
...request,
|
|
813
|
-
atBlock: response.blockNumber
|
|
814
|
-
});
|
|
815
|
-
return new QueryResult(response.entities, response.blockNumber, response.cursor, (next) => fetchPage(client, pinned, next));
|
|
961
|
+
return new QueryResult(response.entities, response.blockNumber, response.cursor, (next) => fetchPage(client, request, next));
|
|
816
962
|
}
|
|
817
963
|
|
|
818
964
|
//#endregion
|
|
819
|
-
export { MAX_LIMIT as _, eq as a, QueryError as b, gte as c, lte as d, ne as f, startsWith as g, render as h, and as i, hasType as l, or as m, QueryResult as n, exists as o, not as p, toRpcSelect as r, gt as s, SelectQueryBuilder as t, lt as u, runQuery as v, UnsupportedOperatorError as x, InvalidPredicateError as y };
|
|
820
|
-
//# sourceMappingURL=queryBuilder-
|
|
965
|
+
export { EntityMutationError as C, getLogger as D, NoMoreResultsError as E, EmptyPatchError as S, NoEntityFoundError as T, MAX_LIMIT as _, eq as a, QueryError as b, gte as c, lte as d, ne as f, startsWith as g, render as h, and as i, hasType as l, or as m, QueryResult as n, exists as o, not as p, toRpcSelect as r, gt as s, SelectQueryBuilder as t, lt as u, runQuery as v, InvalidContentTypeError as w, UnsupportedOperatorError as x, InvalidPredicateError as y };
|
|
966
|
+
//# sourceMappingURL=queryBuilder-wvA8sn--.js.map
|