@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.
- package/README.md +180 -61
- package/dist/chains/index.d.ts +17 -17
- package/dist/changeOwnership-Cy9gfyjN.d.cts +1160 -0
- package/dist/changeOwnership-Cy9gfyjN.d.cts.map +1 -0
- package/dist/changeOwnership-gXf-lBqI.d.ts +1160 -0
- package/dist/changeOwnership-gXf-lBqI.d.ts.map +1 -0
- package/dist/entity/index.cjs +4 -10
- package/dist/entity/index.d.cts +3 -3
- package/dist/entity/index.d.ts +3 -3
- package/dist/entity/index.js +3 -4
- package/dist/entity-BM1unrQf.cjs +41 -0
- package/dist/{entity-DJ0Gml9c.cjs → entity-BgaFJSaV.cjs} +4 -4
- package/dist/entity-CFAI1KyG.js +36 -0
- package/dist/entity-CFAI1KyG.js.map +1 -0
- package/dist/{entity-CniBgBSd.js → entity-CGqx_AU0.js} +4 -4
- package/dist/entity-CGqx_AU0.js.map +1 -0
- package/dist/{payload-AfUfSctb.d.ts → expirationTime-C7PZK49K.d.ts} +8 -37
- package/dist/expirationTime-C7PZK49K.d.ts.map +1 -0
- package/dist/expirationTime-CkIGNAg8.cjs +140 -0
- package/dist/{payload-D167BlJR.d.cts → expirationTime-DOB8V4B8.d.cts} +8 -37
- package/dist/expirationTime-DOB8V4B8.d.cts.map +1 -0
- package/dist/{expiry-Cgdb_dbq.js → expirationTime-UKPuA-LM.js} +62 -27
- package/dist/expirationTime-UKPuA-LM.js.map +1 -0
- package/dist/expiry-B48I-yTA.d.cts +40 -0
- package/dist/expiry-B48I-yTA.d.cts.map +1 -0
- package/dist/expiry-S2PUL8Hg.d.ts +40 -0
- package/dist/expiry-S2PUL8Hg.d.ts.map +1 -0
- package/dist/index-C-mMF5WZ.d.cts +735 -0
- package/dist/index-C-mMF5WZ.d.cts.map +1 -0
- package/dist/{index-BkqSnGJH.d.ts → index-C4zZqJ9S.d.ts} +5 -27
- package/dist/index-C4zZqJ9S.d.ts.map +1 -0
- package/dist/{index-CLhsFyVH.d.cts → index-CcVWYB6v.d.cts} +5 -27
- package/dist/index-CcVWYB6v.d.cts.map +1 -0
- package/dist/index-DCx2XC6S.d.ts +489 -0
- package/dist/index-DCx2XC6S.d.ts.map +1 -0
- package/dist/index-DLb7BfIw.d.ts +735 -0
- package/dist/index-DLb7BfIw.d.ts.map +1 -0
- package/dist/index-DzriOUm8.d.cts +489 -0
- package/dist/index-DzriOUm8.d.cts.map +1 -0
- package/dist/index.cjs +162 -146
- package/dist/index.d.cts +180 -133
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +180 -133
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +93 -83
- package/dist/index.js.map +1 -1
- package/dist/params-BuIrJA9a.cjs +45 -0
- package/dist/params-DDJOnsNi.js +22 -0
- package/dist/params-DDJOnsNi.js.map +1 -0
- package/dist/query/index.cjs +9 -4
- package/dist/query/index.d.cts +6 -6
- package/dist/query/index.d.ts +6 -6
- package/dist/query/index.js +4 -5
- package/dist/query-D0KtuFh2.cjs +1625 -0
- package/dist/query-DpRDozmj.js +1417 -0
- package/dist/query-DpRDozmj.js.map +1 -0
- package/dist/schema/index.cjs +46 -0
- package/dist/schema/index.d.cts +2 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +3 -0
- package/dist/{attr-BXTkpnoc.cjs → schema-B9AyXcgU.cjs} +513 -246
- package/dist/{attr-tmyREHtw.js → schema-DY4sqehl.js} +427 -244
- package/dist/schema-DY4sqehl.js.map +1 -0
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +5 -5
- package/dist/types/index.d.ts +5 -5
- package/dist/types/index.js +1 -1
- package/dist/utils/index.cjs +3 -5
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +3 -3
- package/package.json +9 -12
- package/src/actions/public/getEntity.test.ts +69 -0
- package/src/actions/public/getEntity.ts +34 -20
- package/src/actions/public/predictEntityKeys.ts +8 -7
- package/src/actions/public/query.test.ts +58 -0
- package/src/actions/public/query.ts +41 -13
- package/src/actions/wallet/createEntity.ts +34 -63
- package/src/actions/wallet/executeBatch.test.ts +38 -0
- package/src/actions/wallet/executeBatch.ts +26 -9
- package/src/actions/wallet/extendEntity.ts +9 -8
- package/src/actions/wallet/patchEntity.ts +43 -52
- package/src/clients/createPublicClient.test.ts +10 -2
- package/src/clients/createWalletClient.ts +4 -1
- package/src/clients/decorators/arkivPublic.ts +123 -80
- package/src/clients/decorators/arkivWallet.ts +113 -65
- package/src/entity/create.test.ts +25 -21
- package/src/entity/expiry.ts +8 -6
- package/src/entity/flags.ts +1 -1
- package/src/entity/index.ts +2 -4
- package/src/entity/key.ts +3 -3
- package/src/entity/operations.ts +1 -1
- package/src/errors.ts +2 -11
- package/src/index.ts +18 -6
- package/src/query/builderBase.ts +166 -0
- package/src/query/countBuilder.test.ts +91 -0
- package/src/query/countBuilder.ts +67 -0
- package/src/query/engine.ts +9 -3
- package/src/query/errors.ts +24 -14
- package/src/query/expression.test.ts +129 -21
- package/src/query/expression.ts +323 -94
- package/src/query/index.ts +26 -4
- package/src/query/injection.test.ts +5 -11
- package/src/query/queryBuilder.test.ts +467 -58
- package/src/query/queryBuilder.ts +191 -98
- package/src/query/queryResult.ts +35 -9
- package/src/query/selection.test.ts +278 -24
- package/src/query/selection.ts +427 -86
- package/src/schema/attributes.test.ts +266 -0
- package/src/schema/attributes.ts +212 -0
- package/src/{attr → schema}/codec.test.ts +37 -5
- package/src/{attr → schema}/codec.ts +40 -11
- package/src/schema/column.ts +193 -0
- package/src/{attr → schema}/errors.ts +67 -10
- package/src/schema/index.ts +76 -0
- package/src/{attr → schema}/names.ts +4 -2
- package/src/schema/schema.test.ts +171 -0
- package/src/schema/schema.ts +250 -0
- package/src/{attr → schema}/types.ts +36 -30
- package/src/{attr → schema}/values.test.ts +62 -3
- package/src/{attr → schema}/values.ts +246 -65
- package/src/types/entity.test.ts +1 -44
- package/src/types/entity.ts +9 -55
- package/src/types/events.ts +1 -1
- package/src/types/index.ts +11 -4
- package/src/types/rpcSchema.ts +22 -16
- package/src/utils/arkivTransactions.test.ts +356 -116
- package/src/utils/arkivTransactions.ts +30 -38
- package/src/utils/entities.ts +10 -9
- package/src/utils/expirationTime.ts +5 -5
- package/src/utils/index.ts +0 -1
- package/src/utils/logger.test.ts +45 -0
- package/src/utils/logger.ts +5 -39
- package/src/utils/revert.test.ts +25 -0
- package/src/utils/revert.ts +28 -3
- package/dist/attr/index.cjs +0 -34
- package/dist/attr/index.d.cts +0 -2
- package/dist/attr/index.d.ts +0 -2
- package/dist/attr/index.js +0 -3
- package/dist/attr-tmyREHtw.js.map +0 -1
- package/dist/entity-B0t6sN7F.cjs +0 -71
- package/dist/entity-BIp_df9u.js +0 -67
- package/dist/entity-BIp_df9u.js.map +0 -1
- package/dist/entity-CniBgBSd.js.map +0 -1
- package/dist/expiry-BxOlvVWC.d.ts +0 -79
- package/dist/expiry-BxOlvVWC.d.ts.map +0 -1
- package/dist/expiry-CG9GhVXv.cjs +0 -135
- package/dist/expiry-Cgdb_dbq.js.map +0 -1
- package/dist/expiry-DRV29F1r.d.cts +0 -79
- package/dist/expiry-DRV29F1r.d.cts.map +0 -1
- package/dist/flags-DCD26uhe.cjs +0 -43
- package/dist/flags-DUT2gHEU.js +0 -33
- package/dist/flags-DUT2gHEU.js.map +0 -1
- package/dist/index-BkqSnGJH.d.ts.map +0 -1
- package/dist/index-C7fbakoI.d.cts +0 -278
- package/dist/index-C7fbakoI.d.cts.map +0 -1
- package/dist/index-CIcHPx2j.d.cts +0 -424
- package/dist/index-CIcHPx2j.d.cts.map +0 -1
- package/dist/index-CLhsFyVH.d.cts.map +0 -1
- package/dist/index-Cd2aaWme.d.ts +0 -424
- package/dist/index-Cd2aaWme.d.ts.map +0 -1
- package/dist/index-Cq6fa8AI.d.ts +0 -278
- package/dist/index-Cq6fa8AI.d.ts.map +0 -1
- package/dist/index-DaNeJUw8.d.ts +0 -955
- package/dist/index-DaNeJUw8.d.ts.map +0 -1
- package/dist/index-Dv16LO2s.d.cts +0 -955
- package/dist/index-Dv16LO2s.d.cts.map +0 -1
- package/dist/payload-AfUfSctb.d.ts.map +0 -1
- package/dist/payload-D167BlJR.d.cts.map +0 -1
- package/dist/payload-DE7wMztL.js +0 -92
- package/dist/payload-DE7wMztL.js.map +0 -1
- package/dist/payload-DqFweqiO.cjs +0 -108
- package/dist/query-9oojUdM7.cjs +0 -1128
- package/dist/query-Ber-lOJQ.js +0 -968
- package/dist/query-Ber-lOJQ.js.map +0 -1
- package/src/actions/public/getEntityCount.ts +0 -10
- package/src/attr/attributes.test.ts +0 -120
- package/src/attr/attributes.ts +0 -196
- package/src/attr/index.ts +0 -50
- package/src/types/mimeTypes.ts +0 -27
- package/src/utils/compression.test.ts +0 -32
- package/src/utils/compression.ts +0 -102
- package/src/utils/payload.ts +0 -36
- /package/src/{attr → schema}/decimal.ts +0 -0
package/src/types/entity.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { AttributeSchema, Attributes } from "../attr"
|
|
1
|
+
import type { Hex } from "viem"
|
|
3
2
|
import type { ResolvedCreationFlags } from "../entity/flags"
|
|
3
|
+
import type { AttributeSchema, Attributes } from "../schema"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The fields an {@link Entity} can carry. Every one is optional: a query returns exactly the parts
|
|
@@ -18,20 +18,20 @@ export type EntityFields = {
|
|
|
18
18
|
expiresAt?: bigint | undefined
|
|
19
19
|
/** The immutable properties the entity was created with. */
|
|
20
20
|
creationFlags?: ResolvedCreationFlags | undefined
|
|
21
|
-
|
|
22
|
-
payload?: Uint8Array | undefined
|
|
23
|
-
/** Attribute names and types, with no values. */
|
|
21
|
+
/** Attribute names, types and indexing, with no values. */
|
|
24
22
|
attributeSchema?: AttributeSchema | undefined
|
|
25
23
|
/** Attribute names, types and values. */
|
|
26
24
|
attributes?: Attributes | undefined
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
|
-
* An entity as it
|
|
28
|
+
* An entity as the node returns it, decoded: the fields a query selected, with its attributes as a
|
|
29
|
+
* map keyed by name. Which fields are populated is decided by the selection, so each may be
|
|
30
|
+
* `undefined`.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* Queries do not return these: `select()`, `query()` and `getEntity()` lay each one out as a flat
|
|
33
|
+
* row — the selected entity fields and attributes side by side, typed by the selection and, through
|
|
34
|
+
* a schema, by its columns.
|
|
35
35
|
*/
|
|
36
36
|
export class Entity implements EntityFields {
|
|
37
37
|
key: Hex | undefined
|
|
@@ -41,8 +41,6 @@ export class Entity implements EntityFields {
|
|
|
41
41
|
updatedAt: bigint | undefined
|
|
42
42
|
expiresAt: bigint | undefined
|
|
43
43
|
creationFlags: ResolvedCreationFlags | undefined
|
|
44
|
-
contentType: string | undefined
|
|
45
|
-
payload: Uint8Array | undefined
|
|
46
44
|
attributeSchema: AttributeSchema | undefined
|
|
47
45
|
attributes: Attributes | undefined
|
|
48
46
|
|
|
@@ -54,51 +52,7 @@ export class Entity implements EntityFields {
|
|
|
54
52
|
this.updatedAt = fields.updatedAt
|
|
55
53
|
this.expiresAt = fields.expiresAt
|
|
56
54
|
this.creationFlags = fields.creationFlags
|
|
57
|
-
this.contentType = fields.contentType
|
|
58
|
-
this.payload = fields.payload
|
|
59
55
|
this.attributeSchema = fields.attributeSchema
|
|
60
56
|
this.attributes = fields.attributes
|
|
61
57
|
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The payload decoded as UTF-8 text.
|
|
65
|
-
*
|
|
66
|
-
* @throws If the payload was not selected, or is not valid UTF-8.
|
|
67
|
-
*/
|
|
68
|
-
toText(): string {
|
|
69
|
-
if (this.payload === undefined) {
|
|
70
|
-
throw new Error(
|
|
71
|
-
"Entity has no payload — the query did not select it. Use select({ payload: true }).",
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
return bytesToString(this.payload)
|
|
76
|
-
} catch (e) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
`Failed to convert entity payload to text: ${e instanceof Error ? e.message : String(e)}`,
|
|
79
|
-
{ cause: e },
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* The payload parsed as JSON.
|
|
86
|
-
*
|
|
87
|
-
* @throws If the payload was not selected, is empty, or is not valid JSON.
|
|
88
|
-
*/
|
|
89
|
-
// biome-ignore lint/suspicious/noExplicitAny: JSON.parse returns whatever the payload holds.
|
|
90
|
-
toJson(): any {
|
|
91
|
-
const text = this.toText()
|
|
92
|
-
if (!text) {
|
|
93
|
-
throw new Error("Entity has empty payload, cannot parse as JSON")
|
|
94
|
-
}
|
|
95
|
-
try {
|
|
96
|
-
return JSON.parse(text)
|
|
97
|
-
} catch (e) {
|
|
98
|
-
throw new Error(
|
|
99
|
-
`Failed to parse entity payload as JSON: ${e instanceof Error ? e.message : String(e)}`,
|
|
100
|
-
{ cause: e },
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
58
|
}
|
package/src/types/events.ts
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -4,20 +4,28 @@ export type {
|
|
|
4
4
|
PredictEntityKeysReturnType,
|
|
5
5
|
PredictedEntityKey,
|
|
6
6
|
} from "../actions/public/predictEntityKeys"
|
|
7
|
-
export type { QueryOptions, QueryReturnType } from "../actions/public/query"
|
|
7
|
+
export type { QueryOptions, QueryReturnType, QueryRow } from "../actions/public/query"
|
|
8
8
|
export type { WatchEntityEventsParameters } from "../actions/public/watchEntityEvents"
|
|
9
9
|
export type {
|
|
10
10
|
ChangeOwnershipParameters,
|
|
11
11
|
ChangeOwnershipReturnType,
|
|
12
12
|
} from "../actions/wallet/changeOwnership"
|
|
13
|
-
export type {
|
|
13
|
+
export type {
|
|
14
|
+
CreateEntityOptions,
|
|
15
|
+
CreateEntityParameters,
|
|
16
|
+
CreateEntityReturnType,
|
|
17
|
+
} from "../actions/wallet/createEntity"
|
|
14
18
|
export type { DeleteEntityParameters, DeleteEntityReturnType } from "../actions/wallet/deleteEntity"
|
|
15
19
|
export type {
|
|
16
20
|
ExecuteBatchParameters,
|
|
17
21
|
ExecuteBatchReturnType,
|
|
18
22
|
} from "../actions/wallet/executeBatch"
|
|
19
23
|
export type { ExtendEntityParameters, ExtendEntityReturnType } from "../actions/wallet/extendEntity"
|
|
20
|
-
export type {
|
|
24
|
+
export type {
|
|
25
|
+
PatchEntityChanges,
|
|
26
|
+
PatchEntityParameters,
|
|
27
|
+
PatchEntityReturnType,
|
|
28
|
+
} from "../actions/wallet/patchEntity"
|
|
21
29
|
export type { EntityFields } from "./entity"
|
|
22
30
|
export { Entity } from "./entity"
|
|
23
31
|
export type {
|
|
@@ -29,7 +37,6 @@ export type {
|
|
|
29
37
|
ExpiryExtendedEvent,
|
|
30
38
|
OwnershipTransferredEvent,
|
|
31
39
|
} from "./events"
|
|
32
|
-
export type { MimeType } from "./mimeTypes"
|
|
33
40
|
export type {
|
|
34
41
|
ArkivRpcSchema,
|
|
35
42
|
RpcAttribute,
|
package/src/types/rpcSchema.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Hex
|
|
1
|
+
import type { Hex } from "viem"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* An attribute as the node renders it: the name, the type **tag** (not the wire typeId), and the
|
|
5
5
|
* value in the JSON encoding that type prescribes — a JSON number for `i32`, a `0x` QUANTITY for
|
|
6
|
-
* `u64` and `u256`, a decimal string for `dec`, `0x` DATA for the byte-shaped types
|
|
7
|
-
* `str`.
|
|
6
|
+
* `u64` and `u256`, a decimal string for `dec`, `0x` DATA for the byte-shaped types (`bytes`
|
|
7
|
+
* included), and a string for `str`.
|
|
8
8
|
*
|
|
9
9
|
* The encoding follows the *declared type*, never the magnitude, so a decoder dispatches on `type`
|
|
10
10
|
* and never has to guess from the shape of the value.
|
|
@@ -15,10 +15,14 @@ export type RpcAttribute = {
|
|
|
15
15
|
value: unknown
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* An entry of the `attributeSchema` projection — a name, its type, and whether the node indexes
|
|
20
|
+
* it, with no value.
|
|
21
|
+
*/
|
|
19
22
|
export type RpcAttributeSchemaEntry = {
|
|
20
23
|
name: string
|
|
21
24
|
type: string
|
|
25
|
+
indexed?: boolean
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
/**
|
|
@@ -42,8 +46,6 @@ export type RpcEntity = {
|
|
|
42
46
|
updatedAt?: Hex
|
|
43
47
|
expiresAt?: Hex
|
|
44
48
|
creationFlags?: RpcCreationFlags | number
|
|
45
|
-
contentType?: string
|
|
46
|
-
payload?: Hex
|
|
47
49
|
attributeSchema?: RpcAttributeSchemaEntry[]
|
|
48
50
|
attributes?: RpcAttribute[]
|
|
49
51
|
}
|
|
@@ -63,10 +65,13 @@ export type RpcSelect = {
|
|
|
63
65
|
updatedAt?: boolean
|
|
64
66
|
expiresAt?: boolean
|
|
65
67
|
creationFlags?: boolean
|
|
66
|
-
contentType?: boolean
|
|
67
|
-
payload?: boolean
|
|
68
68
|
attributeSchema?: boolean
|
|
69
69
|
attributes?: boolean | Record<string, boolean>
|
|
70
|
+
/**
|
|
71
|
+
* Not a field of each entity but of the page: the number of entities the query matches at the
|
|
72
|
+
* block, regardless of `limit` and `cursor`, returned as the response's `count`.
|
|
73
|
+
*/
|
|
74
|
+
count?: boolean
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
/** The second parameter of `arkiv_query` — what to return, and where in the results to start. */
|
|
@@ -75,7 +80,7 @@ export type RpcQueryOptions = {
|
|
|
75
80
|
atBlock?: Hex
|
|
76
81
|
/** What to return. Defaults to `{ key: true }`. */
|
|
77
82
|
select?: RpcSelect
|
|
78
|
-
/** Page size, as a hex quantity. Node maximum is
|
|
83
|
+
/** Page size, as a hex quantity. Node maximum is 100. */
|
|
79
84
|
limit?: Hex
|
|
80
85
|
/** Opaque cursor from a previous response; bound to that query, block and selection. */
|
|
81
86
|
cursor?: string
|
|
@@ -90,8 +95,16 @@ export type ArkivRpcSchema = [
|
|
|
90
95
|
blockNumber: Hex
|
|
91
96
|
/** Omitted when no pages remain. */
|
|
92
97
|
cursor?: string
|
|
98
|
+
/** How many entities the query matches, as a hex quantity. Present only when selected. */
|
|
99
|
+
count?: Hex
|
|
93
100
|
}
|
|
94
101
|
},
|
|
102
|
+
{
|
|
103
|
+
Method: "arkiv_getEntity"
|
|
104
|
+
Parameters: [entityKey: Hex]
|
|
105
|
+
/** Every field except `attributeSchema`, or `null` if no live entity has the key. */
|
|
106
|
+
ReturnType: RpcEntity | null
|
|
107
|
+
},
|
|
95
108
|
{
|
|
96
109
|
Method: "arkiv_getBlockTiming"
|
|
97
110
|
Parameters?: []
|
|
@@ -101,11 +114,4 @@ export type ArkivRpcSchema = [
|
|
|
101
114
|
duration: number
|
|
102
115
|
}
|
|
103
116
|
},
|
|
104
|
-
{
|
|
105
|
-
Method: "arkiv_getEntityCount"
|
|
106
|
-
Parameters?: []
|
|
107
|
-
ReturnType: number
|
|
108
|
-
},
|
|
109
117
|
]
|
|
110
|
-
|
|
111
|
-
export type PublicArkivRpcSchema = [...PublicRpcSchema, ...ArkivRpcSchema]
|