@arkiv-network/sdk 0.8.1-dev.1 → 0.9.0-next.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.
Files changed (184) hide show
  1. package/README.md +180 -61
  2. package/dist/chains/index.d.ts +17 -17
  3. package/dist/changeOwnership-Cy9gfyjN.d.cts +1160 -0
  4. package/dist/changeOwnership-Cy9gfyjN.d.cts.map +1 -0
  5. package/dist/changeOwnership-gXf-lBqI.d.ts +1160 -0
  6. package/dist/changeOwnership-gXf-lBqI.d.ts.map +1 -0
  7. package/dist/entity/index.cjs +4 -10
  8. package/dist/entity/index.d.cts +3 -3
  9. package/dist/entity/index.d.ts +3 -3
  10. package/dist/entity/index.js +3 -4
  11. package/dist/entity-BM1unrQf.cjs +41 -0
  12. package/dist/{entity-DJ0Gml9c.cjs → entity-BgaFJSaV.cjs} +4 -4
  13. package/dist/entity-CFAI1KyG.js +36 -0
  14. package/dist/entity-CFAI1KyG.js.map +1 -0
  15. package/dist/{entity-CniBgBSd.js → entity-CGqx_AU0.js} +4 -4
  16. package/dist/entity-CGqx_AU0.js.map +1 -0
  17. package/dist/{payload-AfUfSctb.d.ts → expirationTime-C7PZK49K.d.ts} +8 -37
  18. package/dist/expirationTime-C7PZK49K.d.ts.map +1 -0
  19. package/dist/expirationTime-CkIGNAg8.cjs +140 -0
  20. package/dist/{payload-D167BlJR.d.cts → expirationTime-DOB8V4B8.d.cts} +8 -37
  21. package/dist/expirationTime-DOB8V4B8.d.cts.map +1 -0
  22. package/dist/{expiry-Cgdb_dbq.js → expirationTime-UKPuA-LM.js} +62 -27
  23. package/dist/expirationTime-UKPuA-LM.js.map +1 -0
  24. package/dist/expiry-B48I-yTA.d.cts +40 -0
  25. package/dist/expiry-B48I-yTA.d.cts.map +1 -0
  26. package/dist/expiry-S2PUL8Hg.d.ts +40 -0
  27. package/dist/expiry-S2PUL8Hg.d.ts.map +1 -0
  28. package/dist/index-C-mMF5WZ.d.cts +735 -0
  29. package/dist/index-C-mMF5WZ.d.cts.map +1 -0
  30. package/dist/{index-BkqSnGJH.d.ts → index-C4zZqJ9S.d.ts} +5 -27
  31. package/dist/index-C4zZqJ9S.d.ts.map +1 -0
  32. package/dist/{index-CLhsFyVH.d.cts → index-CcVWYB6v.d.cts} +5 -27
  33. package/dist/index-CcVWYB6v.d.cts.map +1 -0
  34. package/dist/index-DCx2XC6S.d.ts +489 -0
  35. package/dist/index-DCx2XC6S.d.ts.map +1 -0
  36. package/dist/index-DLb7BfIw.d.ts +735 -0
  37. package/dist/index-DLb7BfIw.d.ts.map +1 -0
  38. package/dist/index-DzriOUm8.d.cts +489 -0
  39. package/dist/index-DzriOUm8.d.cts.map +1 -0
  40. package/dist/index.cjs +162 -146
  41. package/dist/index.d.cts +180 -133
  42. package/dist/index.d.cts.map +1 -1
  43. package/dist/index.d.ts +180 -133
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +93 -83
  46. package/dist/index.js.map +1 -1
  47. package/dist/params-BuIrJA9a.cjs +45 -0
  48. package/dist/params-DDJOnsNi.js +22 -0
  49. package/dist/params-DDJOnsNi.js.map +1 -0
  50. package/dist/query/index.cjs +9 -4
  51. package/dist/query/index.d.cts +6 -6
  52. package/dist/query/index.d.ts +6 -6
  53. package/dist/query/index.js +4 -5
  54. package/dist/query-D0KtuFh2.cjs +1625 -0
  55. package/dist/query-DpRDozmj.js +1417 -0
  56. package/dist/query-DpRDozmj.js.map +1 -0
  57. package/dist/schema/index.cjs +46 -0
  58. package/dist/schema/index.d.cts +2 -0
  59. package/dist/schema/index.d.ts +2 -0
  60. package/dist/schema/index.js +3 -0
  61. package/dist/{attr-BXTkpnoc.cjs → schema-B9AyXcgU.cjs} +513 -246
  62. package/dist/{attr-tmyREHtw.js → schema-DY4sqehl.js} +427 -244
  63. package/dist/schema-DY4sqehl.js.map +1 -0
  64. package/dist/types/index.cjs +1 -1
  65. package/dist/types/index.d.cts +5 -5
  66. package/dist/types/index.d.ts +5 -5
  67. package/dist/types/index.js +1 -1
  68. package/dist/utils/index.cjs +3 -5
  69. package/dist/utils/index.d.cts +3 -3
  70. package/dist/utils/index.d.ts +3 -3
  71. package/dist/utils/index.js +3 -3
  72. package/package.json +9 -12
  73. package/src/actions/public/getEntity.test.ts +69 -0
  74. package/src/actions/public/getEntity.ts +34 -20
  75. package/src/actions/public/predictEntityKeys.ts +8 -7
  76. package/src/actions/public/query.test.ts +58 -0
  77. package/src/actions/public/query.ts +41 -13
  78. package/src/actions/wallet/createEntity.ts +34 -63
  79. package/src/actions/wallet/executeBatch.test.ts +38 -0
  80. package/src/actions/wallet/executeBatch.ts +26 -9
  81. package/src/actions/wallet/extendEntity.ts +9 -8
  82. package/src/actions/wallet/patchEntity.ts +43 -52
  83. package/src/clients/createPublicClient.test.ts +10 -2
  84. package/src/clients/createWalletClient.ts +4 -1
  85. package/src/clients/decorators/arkivPublic.ts +123 -80
  86. package/src/clients/decorators/arkivWallet.ts +113 -65
  87. package/src/entity/create.test.ts +25 -21
  88. package/src/entity/expiry.ts +8 -6
  89. package/src/entity/flags.ts +1 -1
  90. package/src/entity/index.ts +2 -4
  91. package/src/entity/key.ts +3 -3
  92. package/src/entity/operations.ts +1 -1
  93. package/src/errors.ts +2 -11
  94. package/src/index.ts +18 -6
  95. package/src/query/builderBase.ts +166 -0
  96. package/src/query/countBuilder.test.ts +91 -0
  97. package/src/query/countBuilder.ts +67 -0
  98. package/src/query/engine.ts +9 -3
  99. package/src/query/errors.ts +24 -14
  100. package/src/query/expression.test.ts +129 -21
  101. package/src/query/expression.ts +323 -94
  102. package/src/query/index.ts +26 -4
  103. package/src/query/injection.test.ts +5 -11
  104. package/src/query/queryBuilder.test.ts +467 -58
  105. package/src/query/queryBuilder.ts +191 -98
  106. package/src/query/queryResult.ts +35 -9
  107. package/src/query/selection.test.ts +278 -24
  108. package/src/query/selection.ts +427 -86
  109. package/src/schema/attributes.test.ts +266 -0
  110. package/src/schema/attributes.ts +212 -0
  111. package/src/{attr → schema}/codec.test.ts +37 -5
  112. package/src/{attr → schema}/codec.ts +40 -11
  113. package/src/schema/column.ts +193 -0
  114. package/src/{attr → schema}/errors.ts +67 -10
  115. package/src/schema/index.ts +76 -0
  116. package/src/{attr → schema}/names.ts +4 -2
  117. package/src/schema/schema.test.ts +171 -0
  118. package/src/schema/schema.ts +250 -0
  119. package/src/{attr → schema}/types.ts +36 -30
  120. package/src/{attr → schema}/values.test.ts +62 -3
  121. package/src/{attr → schema}/values.ts +246 -65
  122. package/src/types/entity.test.ts +1 -44
  123. package/src/types/entity.ts +9 -55
  124. package/src/types/events.ts +1 -1
  125. package/src/types/index.ts +11 -4
  126. package/src/types/rpcSchema.ts +22 -16
  127. package/src/utils/arkivTransactions.test.ts +356 -116
  128. package/src/utils/arkivTransactions.ts +30 -38
  129. package/src/utils/entities.ts +10 -9
  130. package/src/utils/expirationTime.ts +5 -5
  131. package/src/utils/index.ts +0 -1
  132. package/src/utils/logger.test.ts +45 -0
  133. package/src/utils/logger.ts +5 -39
  134. package/src/utils/revert.test.ts +25 -0
  135. package/src/utils/revert.ts +28 -3
  136. package/dist/attr/index.cjs +0 -34
  137. package/dist/attr/index.d.cts +0 -2
  138. package/dist/attr/index.d.ts +0 -2
  139. package/dist/attr/index.js +0 -3
  140. package/dist/attr-tmyREHtw.js.map +0 -1
  141. package/dist/entity-B0t6sN7F.cjs +0 -71
  142. package/dist/entity-BIp_df9u.js +0 -67
  143. package/dist/entity-BIp_df9u.js.map +0 -1
  144. package/dist/entity-CniBgBSd.js.map +0 -1
  145. package/dist/expiry-BxOlvVWC.d.ts +0 -79
  146. package/dist/expiry-BxOlvVWC.d.ts.map +0 -1
  147. package/dist/expiry-CG9GhVXv.cjs +0 -135
  148. package/dist/expiry-Cgdb_dbq.js.map +0 -1
  149. package/dist/expiry-DRV29F1r.d.cts +0 -79
  150. package/dist/expiry-DRV29F1r.d.cts.map +0 -1
  151. package/dist/flags-DCD26uhe.cjs +0 -43
  152. package/dist/flags-DUT2gHEU.js +0 -33
  153. package/dist/flags-DUT2gHEU.js.map +0 -1
  154. package/dist/index-BkqSnGJH.d.ts.map +0 -1
  155. package/dist/index-C7fbakoI.d.cts +0 -278
  156. package/dist/index-C7fbakoI.d.cts.map +0 -1
  157. package/dist/index-CIcHPx2j.d.cts +0 -424
  158. package/dist/index-CIcHPx2j.d.cts.map +0 -1
  159. package/dist/index-CLhsFyVH.d.cts.map +0 -1
  160. package/dist/index-Cd2aaWme.d.ts +0 -424
  161. package/dist/index-Cd2aaWme.d.ts.map +0 -1
  162. package/dist/index-Cq6fa8AI.d.ts +0 -278
  163. package/dist/index-Cq6fa8AI.d.ts.map +0 -1
  164. package/dist/index-DaNeJUw8.d.ts +0 -955
  165. package/dist/index-DaNeJUw8.d.ts.map +0 -1
  166. package/dist/index-Dv16LO2s.d.cts +0 -955
  167. package/dist/index-Dv16LO2s.d.cts.map +0 -1
  168. package/dist/payload-AfUfSctb.d.ts.map +0 -1
  169. package/dist/payload-D167BlJR.d.cts.map +0 -1
  170. package/dist/payload-DE7wMztL.js +0 -92
  171. package/dist/payload-DE7wMztL.js.map +0 -1
  172. package/dist/payload-DqFweqiO.cjs +0 -108
  173. package/dist/query-9oojUdM7.cjs +0 -1128
  174. package/dist/query-Ber-lOJQ.js +0 -968
  175. package/dist/query-Ber-lOJQ.js.map +0 -1
  176. package/src/actions/public/getEntityCount.ts +0 -10
  177. package/src/attr/attributes.test.ts +0 -120
  178. package/src/attr/attributes.ts +0 -196
  179. package/src/attr/index.ts +0 -50
  180. package/src/types/mimeTypes.ts +0 -27
  181. package/src/utils/compression.test.ts +0 -32
  182. package/src/utils/compression.ts +0 -102
  183. package/src/utils/payload.ts +0 -36
  184. /package/src/{attr → schema}/decimal.ts +0 -0
@@ -1,424 +0,0 @@
1
- import { Address, Hex } from "viem";
2
-
3
- //#region src/attr/types.d.ts
4
-
5
- /**
6
- * The protocol's attribute type vocabulary, mapping each short **tag** (the name used by the
7
- * client, the query language and this SDK) to its **typeId** (the byte carried on the wire and in
8
- * the entity record).
9
- *
10
- * The typeIds are consensus-critical: they are written into entity records and mixed into index
11
- * keys, so this table must never drift from the node's `AttributeType`.
12
- *
13
- * | tag | typeId | ABI wire type | indexing |
14
- * | --------- | ------ | ------------------- | ----------------- |
15
- * | `bool` | 1 | `bool` | equality |
16
- * | `i32` | 2 | `int32` | equality + range |
17
- * | `u64` | 3 | `uint64` | equality + range |
18
- * | `u256` | 4 | `uint256` | equality + range |
19
- * | `dec` | 5 | `int256` (18 dp) | equality + range |
20
- * | `bytes32` | 6 | `bytes32` | equality |
21
- * | `bytes` | 7 | `bytes` | none — system-only |
22
- * | `str` | 8 | `string` (<= 128 B) | equality + prefix |
23
- * | `addr` | 9 | `address` | equality |
24
- * | `key` | 10 | `bytes32` | equality |
25
- */
26
- declare const TYPE_IDS: {
27
- readonly bool: 1;
28
- readonly i32: 2;
29
- readonly u64: 3;
30
- readonly u256: 4;
31
- readonly dec: 5;
32
- readonly bytes32: 6;
33
- readonly bytes: 7;
34
- readonly str: 8;
35
- readonly addr: 9;
36
- readonly key: 10;
37
- };
38
- /** Every type tag, including the system-only `bytes`. */
39
- type TypeTag = keyof typeof TYPE_IDS;
40
- /**
41
- * The tags a client may set on an attribute. `bytes` is excluded: it backs the system `$payload`
42
- * cell, which travels in its own operation field and is never carried in an attribute array.
43
- */
44
- type UserTypeTag = Exclude<TypeTag, "bytes">;
45
- /**
46
- * Marks a value as having passed its constructor's validation. The symbol is module-private, so a
47
- * hand-written object literal is not assignable to {@link ArkivValue} — every value crossing the
48
- * wire has been range-, length- and format-checked by `i32`, `u256`, `dec`, and friends.
49
- */
50
- declare const validated: unique symbol;
51
- /**
52
- * A typed attribute value: the tag it was created with, plus the JavaScript representation of that
53
- * type. Constructed only by the tagged constructors in `@arkiv-network/sdk/attr`.
54
- *
55
- * @typeParam tag - The type tag, which also discriminates the {@link ArkivValue} union.
56
- * @typeParam value - The decoded JavaScript representation.
57
- */
58
- type Value<tag extends TypeTag, value> = {
59
- readonly type: tag;
60
- readonly value: value;
61
- readonly [validated]: tag;
62
- };
63
- /** A boolean. */
64
- type BoolValue = Value<"bool", boolean>;
65
- /** A 32-bit signed integer — the default for an untagged number. */
66
- type I32Value = Value<"i32", number>;
67
- /**
68
- * A 64-bit unsigned integer — block heights, the
69
- * entity-nonce and `$expiresAt` are all `u64` */
70
- type U64Value = Value<"u64", bigint>;
71
- /** A 256-bit unsigned integer. */
72
- type U256Value = Value<"u256", bigint>;
73
- /**
74
- * A fixed-point decimal with 18 decimal places, held as its canonical decimal string (`"3.5"`).
75
- * Use {@link decUnits} for the exact scaled integer when you need to do arithmetic.
76
- */
77
- type DecValue = Value<"dec", string>;
78
- /** 32 opaque bytes, as lowercase `0x` hex. */
79
- type Bytes32Value = Value<"bytes32", Hex>;
80
- /** A UTF-8 string of at most 128 bytes, free of C0 control characters and DEL. */
81
- type StrValue = Value<"str", string>;
82
- /** A 20-byte Ethereum address, as EIP-55 checksummed hex. */
83
- type AddrValue = Value<"addr", Address>;
84
- /** A reference to another entity. Weak by spec: dangling references are permitted. */
85
- type KeyValue = Value<"key", Hex>;
86
- /**
87
- * Opaque variable-length bytes, as lowercase `0x` hex. System-only — it backs `$payload` and is
88
- * never settable as an attribute, so it is produced by decoding but has no constructor.
89
- */
90
- type BytesValue = Value<"bytes", Hex>;
91
- /** Any value a client may set on an attribute. */
92
- type ArkivValue = BoolValue | I32Value | U64Value | U256Value | DecValue | Bytes32Value | StrValue | AddrValue | KeyValue;
93
- /** Any value that can come back from the node, including the system-only `bytes`. */
94
- type AnyArkivValue = ArkivValue | BytesValue;
95
- /**
96
- * Whether `input` has the *shape* of an {@link ArkivValue} — a known type tag and a value.
97
- */
98
- declare function isArkivValue(input: unknown): input is AnyArkivValue;
99
- //#endregion
100
- //#region src/attr/values.d.ts
101
- /** The widest `i32`. */
102
- declare const I32_MAX = 2147483647;
103
- /** The narrowest `i32`. */
104
- declare const I32_MIN = -2147483648;
105
- /** The widest `u64`. */
106
- declare const U64_MAX: bigint;
107
- /** The widest `u256`. */
108
- declare const U256_MAX: bigint;
109
- /**
110
- * The longest `str`, in UTF-8 bytes
111
- */
112
- declare const MAX_STRING_BYTES = 128;
113
- /**
114
- * A boolean.
115
- *
116
- * `bool` is the one type that may also be written bare — `{ flagged: true }` and
117
- * `{ flagged: bool(true) }` are the same attribute.
118
- *
119
- * @example
120
- * bool(true) // { type: "bool", value: true }
121
- */
122
- declare function bool(value: boolean): BoolValue;
123
- /**
124
- * A 32-bit signed integer, indexed for equality and range queries. This is the default type for a
125
- * bare number, so `{ level: 10 }` and `{ level: i32(10) }` are the same attribute.
126
- *
127
- * @param value - An integer in [-2147483648, 2147483647].
128
- * @throws {InvalidValueError} If the value is not an integer, or does not fit an `i32`.
129
- *
130
- * @example
131
- * i32(10) // { type: "i32", value: 10 }
132
- * i32(-42) // negative values are fine — i32 is the signed integer
133
- */
134
- declare function i32(value: number | bigint): I32Value;
135
- /**
136
- * A 256-bit unsigned integer, indexed for equality and range queries. The type for token amounts
137
- * and anything else that can outgrow 2⁶⁴ — reach for {@link u64} first for counters, timestamps
138
- * and block heights.
139
- *
140
- * @param value - A non-negative integer, as a `bigint`, a safe `number`, or a decimal or `0x` hex
141
- * string.
142
- * @throws {InvalidValueError} If the value is negative, non-integral, or wider than 256 bits.
143
- *
144
- * @example
145
- * u256(1_000_000n)
146
- * u256(Date.now()) // safe integers are accepted
147
- * u256("0xf4240") // hex, as it comes back over JSON-RPC
148
- */
149
- declare function u256(value: bigint | number | string): U256Value;
150
- /**
151
- * A 64-bit unsigned integer, indexed for equality and range queries.
152
- *
153
- * This is the width the protocol counts in: block heights, `$expiresAt` and the entity-nonce are
154
- * all `u64`, so it is the type to reach for when a value has to line up with one of them. Use
155
- * {@link u256} for token amounts and anything else that can exceed 2⁶⁴.
156
- *
157
- * @param value - A non-negative integer, as a `bigint`, a safe `number`, or a decimal or `0x` hex
158
- * string.
159
- * @throws {InvalidValueError} If the value is negative, non-integral, or wider than 64 bits.
160
- *
161
- * @example
162
- * u64(1_200_000n) // a block height
163
- * u64(Date.now()) // safe integers are accepted
164
- * u64("0x124f80") // hex, as it comes back over JSON-RPC
165
- */
166
- declare function u64(value: bigint | number | string): U64Value;
167
- /**
168
- * A signed fixed-point decimal with exactly 18 decimal places, indexed for equality and range
169
- * queries.
170
- *
171
- * Pass fractional values as **strings**. A JavaScript number cannot represent most decimals
172
- * exactly, so accepting `dec(0.1 + 0.2)` would quietly store `0.30000000000000004`; requiring the
173
- * string keeps what you write and what is stored the same thing. Excess precision is likewise an
174
- * error rather than a rounding.
175
- *
176
- * @param value - A decimal string, or an integral `number` / `bigint`.
177
- * @throws {InvalidValueError} If the value is malformed, has more than 18 fractional digits, or
178
- * falls outside the `int256` range.
179
- *
180
- * @example
181
- * dec("3.5")
182
- * dec("-0.000000000000000001") // the smallest step
183
- * dec(5) // integers may be passed bare
184
- */
185
- declare function dec(value: string | number | bigint): DecValue;
186
- /**
187
- * The exact scaled integer behind a `dec` — the value multiplied by 10 ** 18, which is what the
188
- * protocol stores and compares. Use it when you need exact arithmetic; JavaScript has no native
189
- * decimal type, so the SDK carries the canonical string and leaves the maths to you.
190
- *
191
- * @example
192
- * decUnits(dec("3.5")) // 3500000000000000000n
193
- */
194
- declare function decUnits(value: DecValue): bigint;
195
- /**
196
- * A `dec` built from its scaled integer units — the inverse of {@link decUnits}.
197
- *
198
- * @example
199
- * decFromUnits(3_500_000_000_000_000_000n) // dec("3.5")
200
- */
201
- declare function decFromUnits(units: bigint): DecValue;
202
- /**
203
- * A UTF-8 string of at most 128 bytes, indexed for equality and prefix (`STARTSWITH`) matching.
204
- *
205
- * The limit is on **bytes**, not characters: a string of 128 emoji does not fit.
206
- *
207
- * C0 control characters and DEL are rejected: the query language writes a `str` as `str('...')`,
208
- * whose only escape is a doubled quote, so a control character could be stored but never queried.
209
- *
210
- * @throws {InvalidValueError} If the value is not a string, holds a control character, or exceeds
211
- * 128 UTF-8 bytes.
212
- *
213
- * @example
214
- * str("Bob")
215
- */
216
- declare function str(value: string): StrValue;
217
- /**
218
- * A 20-byte Ethereum address, indexed for equality.
219
- *
220
- * All-lowercase and all-uppercase input carries no checksum and is accepted as-is; mixed-case
221
- * input is checked against its EIP-55 checksum, so a mistyped address is caught here rather than
222
- * being written to a wrong account. The stored value is always EIP-55 checksummed.
223
- *
224
- * @throws {InvalidValueError} If the value is not 20 hex bytes, or fails its EIP-55 checksum.
225
- *
226
- * @example
227
- * addr("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")
228
- */
229
- declare function addr(value: string): AddrValue;
230
- /**
231
- * A reference to another entity, indexed for equality.
232
- *
233
- * References are **weak**: nothing checks that the target exists when you write it, and a
234
- * reference to a deleted or expired entity is allowed to dangle.
235
- *
236
- * @param value - A 32-byte entity key, as `0x` hex or raw bytes.
237
- * @throws {InvalidValueError} If the value is not exactly 32 bytes.
238
- *
239
- * @example
240
- * key(parentEntityKey)
241
- */
242
- declare function key(value: Hex | Uint8Array): KeyValue;
243
- /**
244
- * 32 opaque bytes — a hash, a digest, an identifier from another system — indexed for equality.
245
- *
246
- * Use {@link key} instead when the bytes are an Arkiv entity key: same wire width, but the
247
- * distinct type makes the reference visible to readers and to the query language.
248
- *
249
- * @param value - 32 bytes, as `0x` hex or raw bytes.
250
- * @throws {InvalidValueError} If the value is not exactly 32 bytes.
251
- *
252
- * @example
253
- * bytes32(keccak256(toBytes("hello")))
254
- */
255
- declare function bytes32(value: Hex | Uint8Array): Bytes32Value;
256
- /**
257
- * A JavaScript value accepted wherever a typed value is expected: either a tagged value, or one of
258
- * the four bare forms that map unambiguously onto a single type.
259
- *
260
- * | bare form | type |
261
- * | --------- | ------- |
262
- * | `boolean` | `bool` |
263
- * | `number` | `i32` |
264
- * | `bigint` | `u256` |
265
- * | `string` | `str` |
266
- *
267
- * Anything else — a large number, a decimal, an address, an entity key — must name its type, which
268
- * is what keeps `"0x1234..."` a string rather than silently becoming a key.
269
- *
270
- * These defaults apply identically when writing and when querying, so a value written bare and
271
- * queried bare always agrees with itself. The mismatch to watch for is mixing the two: an attribute
272
- * written as {@link u64} does not match a bare `bigint` predicate, because that predicate asserts
273
- * `u256`. A type mismatch is not an error to the engine — it simply matches nothing.
274
- */
275
- type ValueInput = ArkivValue | boolean | number | bigint | string;
276
- /**
277
- * Resolves a {@link ValueInput} to a typed value, applying the bare-form defaults above. Tagged
278
- * values pass through untouched.
279
- *
280
- * @param input - The value to resolve.
281
- * @param attributeName - The attribute this value belongs to, used to make errors name it.
282
- *
283
- * @throws {MissingValueError} If the input is `undefined` or `null` — an attribute is either set
284
- * with a value and a type, or not set at all.
285
- * @throws {UntypedValueError} If the input is not a tagged value or a bare boolean, number, bigint
286
- * or string.
287
- * @throws {InvalidValueError} If a bare value does not fit the type it defaults to.
288
- *
289
- * @example
290
- * toValue(10) // i32(10)
291
- * toValue(10n) // u256(10n)
292
- * toValue("hello") // str("hello")
293
- * toValue(dec("3.5")) // unchanged
294
- */
295
- declare function toValue(input: ValueInput, attributeName?: string): ArkivValue;
296
- //#endregion
297
- //#region src/attr/attributes.d.ts
298
- /**
299
- * The most attribute cells one operation may carry.
300
- */
301
- declare const MAX_ATTRIBUTES = 32;
302
- /**
303
- * The largest payload an entity may carry, in bytes. The payload travels as the `$payload` system
304
- * cell, so this is a bound on that one attribute rather than on the operation as a whole.
305
- */
306
- declare const MAX_PAYLOAD_BYTES: number;
307
- /**
308
- * The attributes written on an entity, as a plain object keyed by attribute name.
309
- *
310
- * Values may be tagged ({@link ArkivValue}) or bare where the type is unambiguous — see
311
- * {@link toValue} for the bare-form defaults.
312
- *
313
- * @example
314
- * const attributes = {
315
- * level: i32(10),
316
- * balance: u256(1_000_000n),
317
- * score: dec("3.5"),
318
- * parent: key(parentKey),
319
- * name: "Bob", // bare string -> str
320
- * flagged: true, // bare boolean -> bool
321
- * } satisfies AttributeInputs
322
- */
323
- type AttributeInputs = Readonly<Record<string, ValueInput>>;
324
- /**
325
- * The attributes read back from an entity: the same shape, with every value typed.
326
- *
327
- * A value read from here drops straight back into an {@link AttributeInputs} — the vocabulary is the
328
- * same in both directions.
329
- */
330
- type Attributes = Readonly<Record<string, AnyArkivValue>>;
331
- /**
332
- * The names and types of an entity's attributes, with no values — what the `attributeSchema`
333
- * projection returns.
334
- *
335
- * Useful for asking what shape the data has without paying to transfer it, and for telling apart
336
- * two entities that use the same name with different types.
337
- */
338
- type AttributeSchema = Readonly<Record<string, TypeTag>>;
339
- //#endregion
340
- //#region src/attr/decimal.d.ts
341
- /**
342
- * Decimal places a `dec` value is scaled by. Fixed by the protocol, so any two decimals are
343
- * directly comparable — and range-indexable — as plain integers.
344
- */
345
- declare const DECIMAL_SCALE = 18;
346
- /** 10 ** {@link DECIMAL_SCALE} — the scaling factor between a `dec` and its integer units. */
347
- declare const DECIMAL_UNIT: bigint;
348
- //#endregion
349
- //#region src/attr/errors.d.ts
350
- /**
351
- * A value was rejected by its tagged constructor — out of range, wrong length, bad checksum, too
352
- * much precision, and so on.
353
- *
354
- * The message names the offending value and, where there is one, the type that *would* hold it, so
355
- * the fix is in the error rather than in the docs.
356
- */
357
- declare class InvalidValueError extends Error {
358
- /** The type tag whose constructor rejected the value. */
359
- readonly tag: TypeTag;
360
- /** The rejected input, as given. */
361
- readonly input: unknown;
362
- constructor(tag: TypeTag, input: unknown, reason: string, hint?: string);
363
- }
364
- /**
365
- * A bare JavaScript value could not be given a type. Raised when an attribute or predicate is
366
- * handed something that is neither a tagged value nor one of the four bare forms
367
- * (`boolean`, `number`, `bigint`, `string`).
368
- */
369
- declare class UntypedValueError extends Error {
370
- readonly input: unknown;
371
- constructor(input: unknown);
372
- }
373
- /**
374
- * An attribute was given `undefined` or `null` as its value.
375
- *
376
- * There is no such thing as an attribute with no value: an attribute either exists with a type, or
377
- * is not set. The fix is always to leave the name out of the map rather than to write an empty
378
- * value, so this is called out separately from {@link UntypedValueError} — the remedy is different.
379
- */
380
- declare class MissingValueError extends Error {
381
- /** The attribute whose value was missing, when raised from an attribute map. */
382
- readonly attributeName: string | undefined;
383
- constructor(input: null | undefined, attributeName?: string);
384
- }
385
- /** An attribute name violated the on-chain name grammar. */
386
- declare class InvalidAttributeNameError extends Error {
387
- readonly attributeName: string;
388
- constructor(attributeName: string, reason: string);
389
- }
390
- /**
391
- * One patch tried to both write and remove the same attribute.
392
- */
393
- declare class ConflictingMutationError extends Error {
394
- readonly attributeName: string;
395
- constructor(attributeName: string);
396
- }
397
- /** More attributes were supplied than an entity operation can carry. */
398
- declare class TooManyAttributesError extends Error {
399
- constructor(count: number, max: number);
400
- }
401
- /** The node sent back an attribute this SDK cannot decode. */
402
- declare class UnknownAttributeTypeError extends Error {
403
- /** The type as the node named it — a tag over JSON-RPC, a typeId on the wire. */
404
- readonly type: string | number;
405
- constructor(type: string | number);
406
- }
407
- //#endregion
408
- //#region src/attr/names.d.ts
409
- /** The longest attribute name, in bytes — the width of the on-chain `Ident32` name cell. */
410
- declare const MAX_NAME_BYTES = 32;
411
- /**
412
- * Validates an attribute name against the engine's `Ident32` grammar and the query language's
413
- * reserved words.
414
- *
415
- * @param name - The attribute name.
416
- * @throws {InvalidAttributeNameError} If the name is empty, too long, uses characters outside the
417
- * grammar, or collides with a reserved word.
418
- */
419
- declare function validateAttributeName(name: string): void;
420
- /** Whether `name` is a valid attribute name — the non-throwing form of {@link validateAttributeName}. */
421
- declare function isValidAttributeName(name: string): boolean;
422
- //#endregion
423
- export { i32 as A, Bytes32Value as B, ValueInput as C, dec as D, bytes32 as E, u64 as F, StrValue as G, DecValue as H, AddrValue as I, U64Value as J, TypeTag as K, AnyArkivValue as L, str as M, toValue as N, decFromUnits as O, u256 as P, ArkivValue as R, U64_MAX as S, bool as T, I32Value as U, BytesValue as V, KeyValue as W, isArkivValue as X, UserTypeTag as Y, MAX_PAYLOAD_BYTES as _, InvalidAttributeNameError as a, MAX_STRING_BYTES as b, TooManyAttributesError as c, DECIMAL_SCALE as d, DECIMAL_UNIT as f, MAX_ATTRIBUTES as g, Attributes as h, ConflictingMutationError as i, key as j, decUnits as k, UnknownAttributeTypeError as l, AttributeSchema as m, isValidAttributeName as n, InvalidValueError as o, AttributeInputs as p, U256Value as q, validateAttributeName as r, MissingValueError as s, MAX_NAME_BYTES as t, UntypedValueError as u, I32_MAX as v, addr as w, U256_MAX as x, I32_MIN as y, BoolValue as z };
424
- //# sourceMappingURL=index-Cd2aaWme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-Cd2aaWme.d.ts","names":[],"sources":["../src/attr/types.ts","../src/attr/values.ts","../src/attr/attributes.ts","../src/attr/decimal.ts","../src/attr/errors.ts","../src/attr/names.ts"],"sourcesContent":[],"mappings":";;;;;;AAwBA;AAcA;AASA;AAKC;AAgBD;;;;;;;AAOA;AAEA;AAIA;AAEA;AAKA;AAEA;AAEA;AAEA;AAEY,cAxEC,QAwEuB,EAAA;EAKxB,SAAA,IAAU,EAAA,CAAA;EAGV,SAAA,GAAA,EAAU,CAAA;EAClB,SAAA,GAAA,EAAA,CAAA;EACA,SAAA,IAAA,EAAA,CAAA;EACA,SAAA,GAAA,EAAA,CAAA;EACA,SAAA,OAAA,EAAA,CAAA;EACA,SAAA,KAAA,EAAA,CAAA;EACA,SAAA,GAAA,EAAA,CAAA;EACA,SAAA,IAAA,EAAA,CAAA;EACA,SAAA,GAAA,EAAA,EAAA;CACA;;AAGQ,KA9EA,OAAA,GA8Ea,MAAA,OA9EU,QA8EP;;;ACvF5B;AAEA;AAEa,KDcD,WAAA,GAAc,OCdW,CDcH,OCdG,EAAA,OAAA,CAAA;AA4BrC;AAkBA;AA8CA;AAoBA;AAgFA;AA6BA,cDnMc,SCmMU,EAAA,OAAQ,MAAQ;AAUxC;AAkBA;AAwCA;AA8BA;;;;AAAsD,KD5R1C,KC4R0C,CAAA,YD5RxB,OC4RwB,EAAA,KAAA,CAAA,GAAA;EAgBtC,SAAA,IAAO,ED3SN,GC2SM;EAAQ,SAAA,KAAA,ED1Sb,KC0Sa;EAAM,UDzSzB,SAAA,CCySyB,EDzS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