@arkiv-network/sdk 0.5.0-dev.1 → 0.5.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/dist/chains/index.d.cts +33 -33
- package/dist/index-B801JxcV.d.ts +1003 -0
- package/dist/index-B801JxcV.d.ts.map +1 -0
- package/dist/index-DQGx5KZ6.d.cts +1003 -0
- package/dist/index-DQGx5KZ6.d.cts.map +1 -0
- package/dist/index.cjs +30 -8
- package/dist/index.d.cts +3 -392
- package/dist/index.d.ts +3 -392
- package/dist/index.js +30 -8
- package/dist/index.js.map +1 -1
- package/dist/{payload-Da9gJMG5.d.ts → payload-BI2NXPDf.d.ts} +1 -1
- package/dist/{payload-Da9gJMG5.d.ts.map → payload-BI2NXPDf.d.ts.map} +1 -1
- package/dist/{payload-CJN8fTvX.d.cts → payload-D3fyOBWn.d.cts} +1 -1
- package/dist/{payload-CJN8fTvX.d.cts.map → payload-D3fyOBWn.d.cts.map} +1 -1
- package/dist/query/index.cjs +1 -2
- package/dist/query/index.d.cts +3 -6
- package/dist/query/index.d.cts.map +1 -1
- package/dist/query/index.d.ts +3 -6
- package/dist/query/index.d.ts.map +1 -1
- package/dist/query/index.js +2 -2
- package/dist/{queryBuilder-Cy7vf54g.js → queryBuilder-DNUwJvf0.js} +4 -9
- package/dist/queryBuilder-DNUwJvf0.js.map +1 -0
- package/dist/{queryBuilder-DS2Q9bgk.cjs → queryBuilder-KrdIUVZv.cjs} +2 -13
- package/dist/types/index.d.cts +3 -2
- package/dist/types/index.d.ts +3 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +8 -5
- package/src/actions/public/query.ts +49 -2
- package/src/actions/public/subscribeEntityEvents.ts +2 -2
- package/src/clients/createPublicClient.ts +1 -1
- package/src/clients/createWalletClient.ts +2 -2
- package/src/clients/decorators/arkivPublic.ts +26 -11
- package/src/clients/decorators/arkivWallet.ts +21 -15
- package/src/index.ts +6 -0
- package/src/query/errors.ts +0 -6
- package/src/query/queryBuilder.ts +7 -4
- package/src/types/index.ts +21 -1
- package/src/types/rpcSchema.ts +10 -10
- package/src/utils/compression.ts +1 -1
- package/dist/entity-BNSCqNpu.d.cts +0 -254
- package/dist/entity-BNSCqNpu.d.cts.map +0 -1
- package/dist/entity-D7fzI0Hc.d.ts +0 -254
- package/dist/entity-D7fzI0Hc.d.ts.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/queryBuilder-BGz98Y1C.d.ts +0 -314
- package/dist/queryBuilder-BGz98Y1C.d.ts.map +0 -1
- package/dist/queryBuilder-CvAx57pq.d.cts +0 -314
- package/dist/queryBuilder-CvAx57pq.d.cts.map +0 -1
- package/dist/queryBuilder-Cy7vf54g.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkiv-network/sdk",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.2",
|
|
4
4
|
"description": "TypeScript client library for Arkiv's blockchains interactions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"target": "esnext",
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
"lint": "biome check src/",
|
|
74
74
|
"lint:fix": "biome check --write src/",
|
|
75
75
|
"test:unit": "bun test src/**/*",
|
|
76
|
+
"docs": "bunx typedoc --plugin typedoc-plugin-markdown",
|
|
76
77
|
"package": "rimraf arkiv-network-sdk-*.tgz && bun run build && bun pm pack --no-cache",
|
|
77
78
|
"package:test": "bun run package && mv arkiv-network-sdk-*.tgz arkiv-network-sdk-latest.tgz",
|
|
78
79
|
"prepublishOnly": "bun run build && bun run package && mv arkiv-network-sdk-*.tgz arkiv-network-sdk-latest.tgz",
|
|
@@ -84,11 +85,12 @@
|
|
|
84
85
|
"publish-dev:dry": "npm publish ./arkiv-network-sdk-latest.tgz --access public --tag dev --dry-run"
|
|
85
86
|
},
|
|
86
87
|
"devDependencies": {
|
|
87
|
-
"@types/debug": "^4.1.12",
|
|
88
88
|
"@biomejs/biome": "2.2.4",
|
|
89
89
|
"@types/bun": "latest",
|
|
90
|
+
"@types/debug": "^4.1.12",
|
|
90
91
|
"rimraf": "^6.0.1",
|
|
91
|
-
"tsdown": "^0.16.0"
|
|
92
|
+
"tsdown": "^0.16.0",
|
|
93
|
+
"typedoc": "^0.28.14"
|
|
92
94
|
},
|
|
93
95
|
"peerDependencies": {
|
|
94
96
|
"typescript": "^5.0.0"
|
|
@@ -117,7 +119,8 @@
|
|
|
117
119
|
"homepage": "https://arkiv.network",
|
|
118
120
|
"dependencies": {
|
|
119
121
|
"brotli-wasm": "^3.0.1",
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
+
"debug": "^4.3.7",
|
|
123
|
+
"typedoc-plugin-markdown": "^4.9.0",
|
|
124
|
+
"viem": "^2.38.2"
|
|
122
125
|
}
|
|
123
126
|
}
|
|
@@ -1,10 +1,57 @@
|
|
|
1
1
|
import type { ArkivClient } from "../../clients/baseClient"
|
|
2
|
+
import type { RpcQueryOptions } from "../../types/rpcSchema"
|
|
2
3
|
import { entityFromRpcResult } from "../../utils/entities"
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export type QueryOptionsIncludeData = {
|
|
6
|
+
attributes?: boolean
|
|
7
|
+
payload?: boolean
|
|
8
|
+
metadata?: boolean
|
|
9
|
+
}
|
|
10
|
+
export type QueryOptionsOrderBy = {
|
|
11
|
+
name: string
|
|
12
|
+
type: "string" | "numeric"
|
|
13
|
+
desc: "asc" | "desc"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type QueryOptions = {
|
|
17
|
+
includeData?: QueryOptionsIncludeData
|
|
18
|
+
atBlock?: bigint
|
|
19
|
+
orderBy?: QueryOptionsOrderBy[]
|
|
20
|
+
resultsPerPage?: number | undefined
|
|
21
|
+
cursor?: string | undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function query(client: ArkivClient, query: string, queryOptions?: QueryOptions) {
|
|
25
|
+
const rpcQueryOptions: RpcQueryOptions = {
|
|
26
|
+
includeData: {
|
|
27
|
+
key: true,
|
|
28
|
+
payload: queryOptions?.includeData?.payload ?? true,
|
|
29
|
+
attributes: queryOptions?.includeData?.attributes ?? false,
|
|
30
|
+
contentType: queryOptions?.includeData?.metadata ?? false,
|
|
31
|
+
expiration: queryOptions?.includeData?.metadata ?? false,
|
|
32
|
+
owner: queryOptions?.includeData?.metadata ?? false,
|
|
33
|
+
createdAtBlock: queryOptions?.includeData?.metadata ?? false,
|
|
34
|
+
lastModifiedAtBlock: queryOptions?.includeData?.metadata ?? false,
|
|
35
|
+
transactionIndexInBlock: queryOptions?.includeData?.metadata ?? false,
|
|
36
|
+
operationIndexInTransaction: queryOptions?.includeData?.metadata ?? false,
|
|
37
|
+
},
|
|
38
|
+
...(queryOptions?.atBlock !== undefined && { atBlock: Number(queryOptions.atBlock) }),
|
|
39
|
+
...(queryOptions?.orderBy && {
|
|
40
|
+
orderBy: queryOptions?.orderBy.map((order) => ({
|
|
41
|
+
name: order.name,
|
|
42
|
+
type: order.type,
|
|
43
|
+
desc: order.desc === "desc",
|
|
44
|
+
})),
|
|
45
|
+
}),
|
|
46
|
+
...(queryOptions?.resultsPerPage !== undefined && {
|
|
47
|
+
resultsPerPage: queryOptions.resultsPerPage,
|
|
48
|
+
}),
|
|
49
|
+
...(queryOptions?.cursor !== undefined && { cursor: queryOptions?.cursor }),
|
|
50
|
+
}
|
|
51
|
+
|
|
5
52
|
const result = await client.request({
|
|
6
53
|
method: "arkiv_query",
|
|
7
|
-
params: [query],
|
|
54
|
+
params: [query, rpcQueryOptions],
|
|
8
55
|
})
|
|
9
56
|
|
|
10
57
|
const entities = await Promise.all(result.data.map((entity) => entityFromRpcResult(entity)))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodeEventLog, parseAbi, toHex } from "viem"
|
|
1
|
+
import { decodeEventLog, type Hex, parseAbi, toHex } from "viem"
|
|
2
2
|
import type { ArkivClient } from "../../clients/baseClient"
|
|
3
3
|
import type { PublicArkivClient } from "../../clients/createPublicClient"
|
|
4
4
|
import type {
|
|
@@ -53,7 +53,7 @@ export async function subscribeEntityEvents(
|
|
|
53
53
|
for (const log of logs) {
|
|
54
54
|
const event = decodeEventLog({
|
|
55
55
|
abi: arkivABI,
|
|
56
|
-
topics: log.topics as [
|
|
56
|
+
topics: log.topics as [Hex, ...Hex[]] | [],
|
|
57
57
|
data: log.data,
|
|
58
58
|
})
|
|
59
59
|
logger("event from subscribeEntityEvents %o", event)
|
|
@@ -29,7 +29,7 @@ export type PublicArkivClient<
|
|
|
29
29
|
*
|
|
30
30
|
* A Public Client is an interface to "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/), [Arkiv JSON-RPC API](https://docs.arkiv.network/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.arkiv.network/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
|
|
31
31
|
*
|
|
32
|
-
* @param
|
|
32
|
+
* @param parameters - Configuration object for the public client (chain, transport, etc.)
|
|
33
33
|
* @returns A Arkiv Public Client. {@link PublicArkivClient}
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
@@ -29,8 +29,8 @@ export type WalletArkivClient<
|
|
|
29
29
|
*
|
|
30
30
|
* A Public Client is an interface to "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/), [Arkiv JSON-RPC API](https://docs.arkiv.network/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.arkiv.network/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
|
|
31
31
|
*
|
|
32
|
-
* @param
|
|
33
|
-
* @returns A Arkiv
|
|
32
|
+
* @param parameters - Configuration object for the wallet client (chain, transport, account, etc.)
|
|
33
|
+
* @returns A Arkiv Wallet Client. {@link WalletArkivClient}
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
36
|
* import { createPublicClient, http } from 'arkiv'
|
|
@@ -2,7 +2,7 @@ import type { Account, Chain, Client, Hex, PublicActions, Transport } from "viem
|
|
|
2
2
|
import { getBlockTiming } from "../../actions/public/getBlockTiming"
|
|
3
3
|
import { getEntity } from "../../actions/public/getEntity"
|
|
4
4
|
import { getEntityCount } from "../../actions/public/getEntityCount"
|
|
5
|
-
import { query } from "../../actions/public/query"
|
|
5
|
+
import { type QueryOptions, query } from "../../actions/public/query"
|
|
6
6
|
import { subscribeEntityEvents } from "../../actions/public/subscribeEntityEvents"
|
|
7
7
|
import { QueryBuilder } from "../../query/queryBuilder"
|
|
8
8
|
import type { Entity } from "../../types/entity"
|
|
@@ -36,7 +36,7 @@ export type PublicArkivActions<
|
|
|
36
36
|
*
|
|
37
37
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
|
|
38
38
|
*
|
|
39
|
-
* @param
|
|
39
|
+
* @param key - The entity key (hex string)
|
|
40
40
|
* @returns The entity with the given key. {@link Entity}
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
@@ -79,7 +79,10 @@ export type PublicArkivActions<
|
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Returns a QueryResult instance for fetching the results of a raw query.
|
|
82
|
-
*
|
|
82
|
+
* If no query options are provided, all payload is included, but no metadata (like owner, expiredAt, etc.) and attributes.
|
|
83
|
+
* @param query - The raw query string
|
|
84
|
+
* @param queryOptions - The optional query options - {@link QueryOptions}
|
|
85
|
+
* @returns An array of entities matching the query. {@link Entity}
|
|
83
86
|
*
|
|
84
87
|
* @example
|
|
85
88
|
* import { createPublicClient, http } from 'arkiv'
|
|
@@ -90,13 +93,25 @@ export type PublicArkivActions<
|
|
|
90
93
|
* transport: http(),
|
|
91
94
|
* })
|
|
92
95
|
* const queryResult = client.query('key = value && $owner = 0x123')
|
|
93
|
-
*
|
|
96
|
+
* // queryResult = [{ key: "0x123", value: "0x123" }]
|
|
97
|
+
* const queryResultWithOptions = client.query('key = value && $owner = 0x123', {
|
|
98
|
+
* includeData: {
|
|
99
|
+
* attributes: false,
|
|
100
|
+
* payload: true,
|
|
101
|
+
* metadata: true,
|
|
102
|
+
* },
|
|
103
|
+
* orderBy: [{ name: "key", type: "string", desc: "asc" }],
|
|
104
|
+
* resultsPerPage: 10,
|
|
105
|
+
* cursor: undefined,
|
|
106
|
+
* atBlock: undefined,
|
|
107
|
+
* })
|
|
108
|
+
* // queryResultWithOptions = [{ key: "0x123", value: "0x123" }]
|
|
94
109
|
*/
|
|
95
|
-
query: (query: string) => Promise<Entity[]>
|
|
110
|
+
query: (query: string, queryOptions?: QueryOptions) => Promise<Entity[]>
|
|
96
111
|
|
|
97
112
|
/**
|
|
98
113
|
* Returns the number of entities in the DBChain.
|
|
99
|
-
* @returns The number of entities in the DBChain
|
|
114
|
+
* @returns The number of entities in the DBChain
|
|
100
115
|
*
|
|
101
116
|
* @example
|
|
102
117
|
* import { createPublicClient, http } from 'arkiv'
|
|
@@ -138,10 +153,10 @@ export type PublicArkivActions<
|
|
|
138
153
|
|
|
139
154
|
/**
|
|
140
155
|
* Subscribes to entity events.
|
|
141
|
-
*
|
|
142
|
-
* @param pollingInterval - The polling interval in milliseconds
|
|
143
|
-
* @param fromBlock - The block number to start from
|
|
144
|
-
* @returns A function to unsubscribe from the events
|
|
156
|
+
* Takes an object with event handlers: {onError, onEntityCreated, onEntityUpdated, onEntityDeleted, onEntityExpiresInExtended}
|
|
157
|
+
* @param pollingInterval - The polling interval in milliseconds
|
|
158
|
+
* @param fromBlock - The block number to start from
|
|
159
|
+
* @returns A function to unsubscribe from the events
|
|
145
160
|
*
|
|
146
161
|
* @example
|
|
147
162
|
* import { createPublicClient, http } from 'arkiv'
|
|
@@ -183,7 +198,7 @@ export function publicArkivActions<
|
|
|
183
198
|
>(client: Client<transport, chain, account>) {
|
|
184
199
|
return {
|
|
185
200
|
getEntity: (key: Hex) => getEntity(client, key),
|
|
186
|
-
query: (rawQuery: string) => query(client, rawQuery),
|
|
201
|
+
query: (rawQuery: string, queryOptions?: QueryOptions) => query(client, rawQuery, queryOptions),
|
|
187
202
|
buildQuery: () => new QueryBuilder(client),
|
|
188
203
|
getBlockTiming: () => getBlockTiming(client),
|
|
189
204
|
getEntityCount: () => getEntityCount(client),
|
|
@@ -29,7 +29,7 @@ import type {
|
|
|
29
29
|
UpdateEntityReturnType,
|
|
30
30
|
} from "../../actions/wallet/updateEntity"
|
|
31
31
|
import { updateEntity } from "../../actions/wallet/updateEntity"
|
|
32
|
-
import type {
|
|
32
|
+
import type { TxParams } from "../../types"
|
|
33
33
|
|
|
34
34
|
export type WalletArkivActions<
|
|
35
35
|
transport extends Transport = Transport,
|
|
@@ -47,13 +47,14 @@ export type WalletArkivActions<
|
|
|
47
47
|
| "signTransaction"
|
|
48
48
|
> & {
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Creates a new entity.
|
|
51
51
|
*
|
|
52
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/
|
|
52
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/createEntity
|
|
53
53
|
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
54
54
|
*
|
|
55
|
-
* @param
|
|
56
|
-
* @
|
|
55
|
+
* @param data - The entity creation parameters
|
|
56
|
+
* @param txParams - Optional transaction parameters
|
|
57
|
+
* @returns The created entity with transaction hash
|
|
57
58
|
*
|
|
58
59
|
* @example
|
|
59
60
|
* import { createPublicClient, http } from 'arkiv'
|
|
@@ -86,8 +87,9 @@ export type WalletArkivActions<
|
|
|
86
87
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/updateEntity
|
|
87
88
|
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
88
89
|
*
|
|
89
|
-
* @param
|
|
90
|
-
* @
|
|
90
|
+
* @param data - The entity update parameters
|
|
91
|
+
* @param txParams - Optional transaction parameters
|
|
92
|
+
* @returns The updated entity with transaction hash
|
|
91
93
|
*
|
|
92
94
|
* @example
|
|
93
95
|
* import { createWalletClient, http } from 'arkiv'
|
|
@@ -109,8 +111,9 @@ export type WalletArkivActions<
|
|
|
109
111
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/deleteEntity
|
|
110
112
|
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
111
113
|
*
|
|
112
|
-
* @param
|
|
113
|
-
* @
|
|
114
|
+
* @param data - The entity deletion parameters
|
|
115
|
+
* @param txParams - Optional transaction parameters
|
|
116
|
+
* @returns The deleted entity with transaction hash
|
|
114
117
|
*
|
|
115
118
|
* @example
|
|
116
119
|
* import { createWalletClient, http } from 'arkiv'
|
|
@@ -139,8 +142,9 @@ export type WalletArkivActions<
|
|
|
139
142
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/extendEntity
|
|
140
143
|
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
141
144
|
*
|
|
142
|
-
* @param
|
|
143
|
-
* @
|
|
145
|
+
* @param data - The entity update parameters
|
|
146
|
+
* @param txParams - Optional transaction parameters
|
|
147
|
+
* @returns The updated entity with transaction hash
|
|
144
148
|
*
|
|
145
149
|
* @example
|
|
146
150
|
* import { createWalletClient, http } from 'arkiv'
|
|
@@ -171,8 +175,9 @@ export type WalletArkivActions<
|
|
|
171
175
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/changeOwnership
|
|
172
176
|
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
173
177
|
*
|
|
174
|
-
* @param
|
|
175
|
-
* @
|
|
178
|
+
* @param data - The ownership change parameters
|
|
179
|
+
* @param txParams - Optional transaction parameters
|
|
180
|
+
* @returns The entity with updated ownership and transaction hash
|
|
176
181
|
*/
|
|
177
182
|
changeOwnership: (
|
|
178
183
|
data: ChangeOwnershipParameters,
|
|
@@ -185,8 +190,9 @@ export type WalletArkivActions<
|
|
|
185
190
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
|
|
186
191
|
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
187
192
|
*
|
|
188
|
-
* @param
|
|
189
|
-
* @
|
|
193
|
+
* @param data - The mutation parameters (creates, updates, deletes, extensions)
|
|
194
|
+
* @param txParams - Optional transaction parameters
|
|
195
|
+
* @returns The mutation result with transaction hash
|
|
190
196
|
*
|
|
191
197
|
* @example
|
|
192
198
|
* import { createWalletClient, http } from 'arkiv'
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module main
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
// Re-export all viem stuff
|
|
2
6
|
export * from "viem"
|
|
3
7
|
|
|
@@ -7,6 +11,8 @@ export type { PublicArkivClient } from "./clients/createPublicClient"
|
|
|
7
11
|
export { createPublicClient } from "./clients/createPublicClient"
|
|
8
12
|
export type { WalletArkivClient } from "./clients/createWalletClient"
|
|
9
13
|
export { createWalletClient } from "./clients/createWalletClient"
|
|
14
|
+
export type { PublicArkivActions } from "./clients/decorators/arkivPublic"
|
|
15
|
+
export type { WalletArkivActions } from "./clients/decorators/arkivWallet"
|
|
10
16
|
|
|
11
17
|
// re-export arkiv types in main index file
|
|
12
18
|
export * from "./types"
|
package/src/query/errors.ts
CHANGED
|
@@ -10,12 +10,6 @@ export class NoCursorOrLimitError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export class OffsetCannotBeLessThanZeroError extends Error {
|
|
14
|
-
constructor() {
|
|
15
|
-
super("Offset cannot be less than 0")
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
13
|
export class NoEntityFoundError extends Error {
|
|
20
14
|
constructor() {
|
|
21
15
|
super("No entity found")
|
|
@@ -6,7 +6,7 @@ import { processQuery } from "./engine"
|
|
|
6
6
|
import type { Predicate } from "./predicate"
|
|
7
7
|
import { QueryResult } from "./queryResult"
|
|
8
8
|
|
|
9
|
-
type OrderByAttribute = {
|
|
9
|
+
export type OrderByAttribute = {
|
|
10
10
|
name: string
|
|
11
11
|
type: "string" | "number"
|
|
12
12
|
order: "asc" | "desc"
|
|
@@ -16,7 +16,7 @@ type OrderByAttribute = {
|
|
|
16
16
|
* Helper function to create an ascending order by attribute
|
|
17
17
|
* @param attributeName - The name of the attribute to order by
|
|
18
18
|
* @param attributeType - The type of the attribute to order by (string or number)
|
|
19
|
-
* @returns
|
|
19
|
+
* @returns Input for orderBy method
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* const ascAttribute = asc("name", "string")
|
|
@@ -33,7 +33,7 @@ export function asc(attributeName: string, attributeType: "string" | "number"):
|
|
|
33
33
|
* Helper function to create a descending order by attribute
|
|
34
34
|
* @param attributeName - The name of the attribute to order by
|
|
35
35
|
* @param attributeType - The type of the attribute to order by (string or number)
|
|
36
|
-
* @returns
|
|
36
|
+
* @returns Input for orderBy method
|
|
37
37
|
*
|
|
38
38
|
* @example
|
|
39
39
|
* const descAttribute = desc("name", "string")
|
|
@@ -86,14 +86,17 @@ export class QueryBuilder {
|
|
|
86
86
|
* Sets the orderBy for the query.
|
|
87
87
|
* It can be called multiple times to order by multiple attributes.
|
|
88
88
|
* The order of the attributes is important. The first attribute is the primary order by attribute.
|
|
89
|
+
* You can use the helper functions asc() and desc() as input for this method.
|
|
89
90
|
* @param attributeName - The name of the attribute to order by
|
|
90
91
|
* @param attributeType - The type of the attribute to order by (string or number)
|
|
91
92
|
* @param order - The order to set the order by (asc or desc)
|
|
92
93
|
* @returns The QueryBuilder instance
|
|
93
94
|
*
|
|
94
95
|
* @example
|
|
95
|
-
* const builder =
|
|
96
|
+
* const builder = client.buildQuery()
|
|
96
97
|
* builder.orderBy("name", "string", "desc")
|
|
98
|
+
* builder.orderBy(asc("name", "string"))
|
|
99
|
+
* builder.orderBy(desc("name", "string"))
|
|
97
100
|
*/
|
|
98
101
|
orderBy(attributeName: string, attributeType: "string" | "number", order?: "asc" | "desc"): this
|
|
99
102
|
/**
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export type { GetBlockTimingReturnType } from "../actions/public/getBlockTiming"
|
|
2
|
+
export type {
|
|
3
|
+
QueryOptions,
|
|
4
|
+
QueryOptionsIncludeData,
|
|
5
|
+
QueryOptionsOrderBy,
|
|
6
|
+
} from "../actions/public/query"
|
|
1
7
|
export type {
|
|
2
8
|
ChangeOwnershipParameters,
|
|
3
9
|
ChangeOwnershipReturnType,
|
|
@@ -12,6 +18,20 @@ export type {
|
|
|
12
18
|
export type { UpdateEntityParameters, UpdateEntityReturnType } from "../actions/wallet/updateEntity"
|
|
13
19
|
export type { Attribute } from "./attributes"
|
|
14
20
|
export type { Entity } from "./entity"
|
|
21
|
+
export type {
|
|
22
|
+
OnEntityCreatedEvent,
|
|
23
|
+
OnEntityDeletedEvent,
|
|
24
|
+
OnEntityExpiredEvent,
|
|
25
|
+
OnEntityExpiresInExtendedEvent,
|
|
26
|
+
OnEntityOwnerChangedEvent,
|
|
27
|
+
OnEntityUpdatedEvent,
|
|
28
|
+
} from "./events"
|
|
15
29
|
export type { MimeType } from "./mimeTypes"
|
|
16
|
-
export type {
|
|
30
|
+
export type {
|
|
31
|
+
ArkivRpcSchema,
|
|
32
|
+
RpcEntity,
|
|
33
|
+
RpcIncludeData,
|
|
34
|
+
RpcOrderByAttribute,
|
|
35
|
+
RpcQueryOptions,
|
|
36
|
+
} from "./rpcSchema"
|
|
17
37
|
export type { TxParams } from "./txParams"
|
package/src/types/rpcSchema.ts
CHANGED
|
@@ -30,16 +30,16 @@ export type RpcQueryOptions = {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export type RpcIncludeData = {
|
|
33
|
-
key
|
|
34
|
-
attributes
|
|
35
|
-
payload
|
|
36
|
-
contentType
|
|
37
|
-
expiration
|
|
38
|
-
owner
|
|
39
|
-
createdAtBlock
|
|
40
|
-
lastModifiedAtBlock
|
|
41
|
-
transactionIndexInBlock
|
|
42
|
-
operationIndexInTransaction
|
|
33
|
+
key?: boolean
|
|
34
|
+
attributes?: boolean
|
|
35
|
+
payload?: boolean
|
|
36
|
+
contentType?: boolean
|
|
37
|
+
expiration?: boolean
|
|
38
|
+
owner?: boolean
|
|
39
|
+
createdAtBlock?: boolean
|
|
40
|
+
lastModifiedAtBlock?: boolean
|
|
41
|
+
transactionIndexInBlock?: boolean
|
|
42
|
+
operationIndexInTransaction?: boolean
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export type ArkivRpcSchema = [
|
package/src/utils/compression.ts
CHANGED
|
@@ -32,7 +32,7 @@ async function getBrotli(): Promise<BrotliWasmType | null> {
|
|
|
32
32
|
|
|
33
33
|
try {
|
|
34
34
|
const brotliModule = await import("brotli-wasm")
|
|
35
|
-
brotli = brotliModule.default
|
|
35
|
+
brotli = (brotliModule.default ? await brotliModule.default : brotliModule) as BrotliWasmType
|
|
36
36
|
} catch (error) {
|
|
37
37
|
console.error("Error importing brotli-wasm", error)
|
|
38
38
|
return null
|