@arkiv-network/sdk 0.7.0 → 0.8.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -16
- package/dist/attr/index.cjs +34 -0
- package/dist/attr/index.d.cts +2 -0
- package/dist/attr/index.d.ts +2 -0
- package/dist/attr/index.js +3 -0
- package/dist/attr-BDZ-APg5.js +809 -0
- package/dist/attr-BDZ-APg5.js.map +1 -0
- package/dist/attr-BvxHN99W.cjs +1029 -0
- package/dist/chains/index.cjs +2 -3
- package/dist/chains/index.d.cts +39 -77
- package/dist/chains/index.d.cts.map +1 -1
- package/dist/chains/index.d.ts +22 -60
- package/dist/chains/index.d.ts.map +1 -1
- package/dist/chains/index.js +2 -2
- package/dist/chains-BJrZs6sG.js +57 -0
- package/dist/chains-BJrZs6sG.js.map +1 -0
- package/dist/chains-BYRTTipa.cjs +73 -0
- package/dist/changeOwnership-B7bEgla4.d.cts +509 -0
- package/dist/changeOwnership-B7bEgla4.d.cts.map +1 -0
- package/dist/changeOwnership-DwgtdSFc.d.ts +509 -0
- package/dist/changeOwnership-DwgtdSFc.d.ts.map +1 -0
- package/dist/entity/index.cjs +19 -0
- package/dist/entity/index.d.cts +4 -0
- package/dist/entity/index.d.ts +4 -0
- package/dist/entity/index.js +6 -0
- package/dist/entity-B0t6sN7F.cjs +71 -0
- package/dist/entity-BIp_df9u.js +67 -0
- package/dist/entity-BIp_df9u.js.map +1 -0
- package/dist/entity-CFhbAv0R.js +70 -0
- package/dist/entity-CFhbAv0R.js.map +1 -0
- package/dist/entity-wfBnZd91.cjs +98 -0
- package/dist/errors-D-eJkGVc.cjs +56 -0
- package/dist/errors-DGB8AgT2.js +33 -0
- package/dist/errors-DGB8AgT2.js.map +1 -0
- package/dist/expiry-BUYIXTGb.cjs +135 -0
- package/dist/expiry-BxOlvVWC.d.ts +79 -0
- package/dist/expiry-BxOlvVWC.d.ts.map +1 -0
- package/dist/expiry-DGRzrSan.js +95 -0
- package/dist/expiry-DGRzrSan.js.map +1 -0
- package/dist/expiry-DRV29F1r.d.cts +79 -0
- package/dist/expiry-DRV29F1r.d.cts.map +1 -0
- package/dist/flags-0Vl5rrHq.d.cts +41 -0
- package/dist/flags-0Vl5rrHq.d.cts.map +1 -0
- package/dist/flags-Ct8k0gpB.cjs +43 -0
- package/dist/flags-ZtlvOIIk.js +33 -0
- package/dist/flags-ZtlvOIIk.js.map +1 -0
- package/dist/flags-wmcMoAnN.d.ts +41 -0
- package/dist/flags-wmcMoAnN.d.ts.map +1 -0
- package/dist/index-Cgw1u5aY.d.cts +278 -0
- package/dist/index-Cgw1u5aY.d.cts.map +1 -0
- package/dist/index-ClgIuxJ8.d.ts +159 -0
- package/dist/index-ClgIuxJ8.d.ts.map +1 -0
- package/dist/index-D0CmtiWT.d.cts +159 -0
- package/dist/index-D0CmtiWT.d.cts.map +1 -0
- package/dist/index-D8LZt-3J.d.cts +417 -0
- package/dist/index-D8LZt-3J.d.cts.map +1 -0
- package/dist/index-DVYFaXNV.d.ts +417 -0
- package/dist/index-DVYFaXNV.d.ts.map +1 -0
- package/dist/index-VCqgn29D.d.ts +278 -0
- package/dist/index-VCqgn29D.d.ts.map +1 -0
- package/dist/index.cjs +675 -357
- package/dist/index.d.cts +251 -203
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +251 -203
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +626 -355
- package/dist/index.js.map +1 -1
- package/dist/payload-Bnw1hrvb.cjs +83 -0
- package/dist/payload-CIxSn_DW.js +67 -0
- package/dist/payload-CIxSn_DW.js.map +1 -0
- package/dist/payload-Dgx3PQeK.d.ts +94 -0
- package/dist/payload-Dgx3PQeK.d.ts.map +1 -0
- package/dist/payload-P0nWyjLg.d.cts +94 -0
- package/dist/payload-P0nWyjLg.d.cts.map +1 -0
- package/dist/query/index.cjs +24 -149
- package/dist/query/index.d.cts +5 -3
- package/dist/query/index.d.ts +5 -3
- package/dist/query/index.js +6 -137
- package/dist/queryBuilder-BXDvX1K_.cjs +1123 -0
- package/dist/queryBuilder-CbLL4pG5.js +963 -0
- package/dist/queryBuilder-CbLL4pG5.js.map +1 -0
- package/dist/selection-BvK6yX0g.d.cts +433 -0
- package/dist/selection-BvK6yX0g.d.cts.map +1 -0
- package/dist/selection-fpmI3ADQ.d.ts +433 -0
- package/dist/selection-fpmI3ADQ.d.ts.map +1 -0
- package/dist/types/index.cjs +4 -1
- package/dist/types/index.d.cts +7 -2
- package/dist/types/index.d.ts +7 -2
- package/dist/types/index.js +4 -1
- package/dist/utils/index.cjs +4 -17
- package/dist/utils/index.d.cts +3 -17
- package/dist/utils/index.d.ts +3 -17
- package/dist/utils/index.js +4 -18
- package/package.json +26 -5
- package/src/actions/public/getEntity.ts +27 -43
- package/src/actions/public/getEntityNonce.ts +30 -0
- package/src/actions/public/predictEntityKeys.test.ts +143 -0
- package/src/actions/public/predictEntityKeys.ts +138 -0
- package/src/actions/public/query.ts +33 -69
- package/src/actions/public/watchEntityEvents.test.ts +414 -0
- package/src/actions/public/watchEntityEvents.ts +225 -0
- package/src/actions/wallet/changeOwnership.ts +8 -8
- package/src/actions/wallet/createEntity.ts +104 -26
- package/src/actions/wallet/deleteEntity.ts +2 -3
- package/src/actions/wallet/extendEntity.ts +39 -16
- package/src/actions/wallet/mutateEntities.test.ts +76 -0
- package/src/actions/wallet/mutateEntities.ts +29 -74
- package/src/actions/wallet/patchEntity.ts +90 -0
- package/src/attr/attributes.test.ts +120 -0
- package/src/attr/attributes.ts +190 -0
- package/src/attr/codec.test.ts +162 -0
- package/src/attr/codec.ts +220 -0
- package/src/attr/decimal.ts +86 -0
- package/src/attr/errors.ts +145 -0
- package/src/attr/index.ts +50 -0
- package/src/attr/names.ts +106 -0
- package/src/attr/types.ts +150 -0
- package/src/attr/values.test.ts +271 -0
- package/src/attr/values.ts +502 -0
- package/src/chains/cheesecake.ts +22 -0
- package/src/chains/index.ts +1 -2
- package/src/clients/createPublicClient.test.ts +3 -5
- package/src/clients/createPublicClient.ts +5 -4
- package/src/clients/createWalletClient.test.ts +2 -2
- package/src/clients/createWalletClient.ts +13 -7
- package/src/clients/decorators/arkivPublic.ts +160 -139
- package/src/clients/decorators/arkivWallet.ts +91 -95
- package/src/consts.ts +2 -1
- package/src/entity/create.test.ts +184 -0
- package/src/entity/errors.ts +38 -0
- package/src/entity/events.ts +16 -0
- package/src/entity/expiry.test.ts +195 -0
- package/src/entity/expiry.ts +181 -0
- package/src/entity/flags.ts +65 -0
- package/src/entity/index.ts +14 -0
- package/src/entity/key.ts +68 -0
- package/src/entity/operations.ts +134 -0
- package/src/entity/params.ts +15 -0
- package/src/errors.ts +33 -28
- package/src/index.ts +6 -0
- package/src/query/engine.ts +59 -134
- package/src/query/errors.ts +151 -0
- package/src/query/expression.test.ts +286 -0
- package/src/query/expression.ts +493 -0
- package/src/query/index.ts +40 -4
- package/src/query/injection.test.ts +151 -0
- package/src/query/queryBuilder.test.ts +322 -637
- package/src/query/queryBuilder.ts +126 -359
- package/src/query/queryResult.ts +54 -51
- package/src/query/selection.test.ts +48 -98
- package/src/query/selection.ts +77 -65
- package/src/types/entity.test.ts +44 -155
- package/src/types/entity.ts +62 -44
- package/src/types/events.ts +64 -23
- package/src/types/index.ts +20 -16
- package/src/types/rpcSchema.ts +70 -33
- package/src/utils/arkivTransactions.test.ts +681 -38
- package/src/utils/arkivTransactions.ts +249 -104
- package/src/utils/chains.test.ts +21 -24
- package/src/utils/compression.ts +1 -1
- package/src/utils/entities.test.ts +62 -0
- package/src/utils/entities.ts +111 -29
- package/src/utils/expirationTime.ts +114 -10
- package/src/utils/logger.ts +2 -2
- package/src/utils/payload.ts +4 -2
- package/src/utils/revert.test.ts +99 -0
- package/src/utils/revert.ts +145 -0
- package/dist/chains-BifaY04V.cjs +0 -108
- package/dist/chains-CrtkVbBh.js +0 -86
- package/dist/chains-CrtkVbBh.js.map +0 -1
- package/dist/consts-AUoL-v42.cjs +0 -18
- package/dist/consts-BV4PR-de.js +0 -7
- package/dist/consts-BV4PR-de.js.map +0 -1
- package/dist/entity-B6g_EPm1.d.cts +0 -382
- package/dist/entity-B6g_EPm1.d.cts.map +0 -1
- package/dist/entity-qoLMAuuk.d.ts +0 -382
- package/dist/entity-qoLMAuuk.d.ts.map +0 -1
- package/dist/index-DdspxNAA.d.ts +0 -481
- package/dist/index-DdspxNAA.d.ts.map +0 -1
- package/dist/index-Ds9dwqb5.d.cts +0 -481
- package/dist/index-Ds9dwqb5.d.cts.map +0 -1
- package/dist/payload-B2kFJyah.d.ts +0 -6
- package/dist/payload-B2kFJyah.d.ts.map +0 -1
- package/dist/payload-CJN8fTvX.d.cts +0 -6
- package/dist/payload-CJN8fTvX.d.cts.map +0 -1
- package/dist/payload-Claf2jUO.js +0 -13
- package/dist/payload-Claf2jUO.js.map +0 -1
- package/dist/payload-DpA5PA-w.cjs +0 -23
- package/dist/query/index.js.map +0 -1
- package/dist/queryBuilder-D2uwP9jI.js +0 -704
- package/dist/queryBuilder-D2uwP9jI.js.map +0 -1
- package/dist/queryBuilder-UW2MCaX4.cjs +0 -792
- package/dist/utils/index.d.cts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/src/actions/public/buildQuery.ts +0 -10
- package/src/actions/public/subscribeEntityEvents.ts +0 -119
- package/src/actions/wallet/updateEntity.ts +0 -60
- package/src/chains/braga.ts +0 -26
- package/src/chains/kaolin.ts +0 -29
- package/src/query/engine.test.ts +0 -526
- package/src/query/predicate.test.ts +0 -461
- package/src/query/predicate.ts +0 -144
- package/src/query/queryResult.test.ts +0 -270
- package/src/query/selectQueryBuilder.test.ts +0 -210
- package/src/types/attributes.ts +0 -16
- package/src/utils/validation.test.ts +0 -60
- package/src/utils/validation.ts +0 -32
- /package/dist/{types-H-TSmRpm.js → types-Bx1EKe0v.js} +0 -0
- /package/dist/{types-o3zWarRp.cjs → types-CKPddlfS.cjs} +0 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { K as TypeTag } from "./index-DVYFaXNV.js";
|
|
2
|
+
import { R as RpcSelect, d as Expression, i as SelectArg, j as ArkivClient, k as Entity } from "./selection-fpmI3ADQ.js";
|
|
3
|
+
import { Hex } from "viem";
|
|
4
|
+
|
|
5
|
+
//#region src/query/engine.d.ts
|
|
6
|
+
declare const MAX_LIMIT = 200;
|
|
7
|
+
/** One `arkiv_query` call. */
|
|
8
|
+
type QueryRequest = {
|
|
9
|
+
/** The query expression, already rendered. */
|
|
10
|
+
query: string;
|
|
11
|
+
/** What to return. */
|
|
12
|
+
select: RpcSelect;
|
|
13
|
+
/** Page size, up to {@link MAX_LIMIT}. Defaults to the node's own page size. */
|
|
14
|
+
limit?: number | undefined;
|
|
15
|
+
/** Cursor from a previous page. */
|
|
16
|
+
cursor?: string | undefined;
|
|
17
|
+
/** Block height to read at. Defaults to the head. */
|
|
18
|
+
atBlock?: bigint | undefined;
|
|
19
|
+
};
|
|
20
|
+
/** One page of results. */
|
|
21
|
+
type QueryResponse = {
|
|
22
|
+
entities: Entity[];
|
|
23
|
+
/** The block the page was read at — the same for every page of a paginated query. */
|
|
24
|
+
blockNumber: bigint;
|
|
25
|
+
/** The cursor for the next page, or `undefined` when this was the last one. */
|
|
26
|
+
cursor: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Runs one query and decodes the page it returns.
|
|
30
|
+
*
|
|
31
|
+
* @throws {QueryError} If the node rejects the query.
|
|
32
|
+
*/
|
|
33
|
+
declare function runQuery(client: ArkivClient, request: QueryRequest): Promise<QueryResponse>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/query/errors.d.ts
|
|
36
|
+
/**
|
|
37
|
+
* A predicate asked for an operator the query language does not define for that type.
|
|
38
|
+
*
|
|
39
|
+
* The operator × type matrix is part of the language, not a policy: a range comparison on an
|
|
40
|
+
* equality-only type is a **parse error** at the node, not an empty result. Catching it here turns
|
|
41
|
+
* a round trip and an RPC error code into a stack trace pointing at the call site.
|
|
42
|
+
*
|
|
43
|
+
* | | `=` `!=` | `<` `<=` `>` `>=` | `STARTSWITH` |
|
|
44
|
+
* | --- | --- | --- | --- |
|
|
45
|
+
* | `bool` | yes | no | no |
|
|
46
|
+
* | `i32` `u256` `dec` | yes | yes | no |
|
|
47
|
+
* | `str` | yes | no | yes |
|
|
48
|
+
* | `addr` `key` `bytes32` | yes | no | no |
|
|
49
|
+
*/
|
|
50
|
+
declare class UnsupportedOperatorError extends Error {
|
|
51
|
+
/** The attribute the predicate names. */
|
|
52
|
+
readonly attributeName: string;
|
|
53
|
+
/** The operator, as it would have been written in the query. */
|
|
54
|
+
readonly operator: string;
|
|
55
|
+
/** The type of the value it was applied to. */
|
|
56
|
+
readonly tag: TypeTag;
|
|
57
|
+
constructor(attributeName: string, operator: string, tag: TypeTag, hint?: string);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A predicate could not be expressed in the query language for a reason other than its operator —
|
|
61
|
+
* a system attribute that is returned in results but cannot be filtered on, a system attribute
|
|
62
|
+
* compared against the wrong type, or a combinator with nothing to combine.
|
|
63
|
+
*/
|
|
64
|
+
declare class InvalidPredicateError extends Error {
|
|
65
|
+
/** The attribute the predicate names, where there is one. */
|
|
66
|
+
readonly attributeName: string | undefined;
|
|
67
|
+
constructor(message: string, attributeName?: string);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* What a node rejected a query for. Part of the frozen RPC surface, so it is safe to branch on —
|
|
71
|
+
* a `"cursor"` failure means start the query again, a `"block"` failure means the node no longer
|
|
72
|
+
* retains that height, and the rest mean the query itself needs fixing.
|
|
73
|
+
*/
|
|
74
|
+
type QueryErrorKind = /** The query string does not parse. `data` locates it: `{ position, expected, got }`. */
|
|
75
|
+
"parse"
|
|
76
|
+
/** A predicate is well-formed but ill-typed — a range operator on an equality-only type, an unknown tag. */ | "type"
|
|
77
|
+
/** A literal failed validation — an `i32` out of range, a bad EIP-55 checksum, more than 18 decimal places. */ | "literal"
|
|
78
|
+
/** A node budget was exceeded — query length, predicate count, nesting depth, bitmap operations. */ | "limits"
|
|
79
|
+
/** The cursor expired, is malformed, or belongs to a different query, block or selection. */ | "cursor"
|
|
80
|
+
/** `atBlock` is outside the range the node retains. */ | "block";
|
|
81
|
+
/**
|
|
82
|
+
* The node rejected a query.
|
|
83
|
+
*
|
|
84
|
+
* These codes are part of the frozen `arkiv_query` surface, so {@link kind} and {@link data} are
|
|
85
|
+
* stable enough to branch on — which the underlying JSON-RPC error is not, because the codes
|
|
86
|
+
* overlap Ethereum's own EIP-1474 numbering and get wrapped accordingly on the way up.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* try {
|
|
90
|
+
* await result.next()
|
|
91
|
+
* } catch (error) {
|
|
92
|
+
* if (error instanceof QueryError && error.kind === "cursor") {
|
|
93
|
+
* // The page is gone — start the query over.
|
|
94
|
+
* }
|
|
95
|
+
* }
|
|
96
|
+
*/
|
|
97
|
+
declare class QueryError extends Error {
|
|
98
|
+
/** Which failure this is. */
|
|
99
|
+
readonly kind: QueryErrorKind;
|
|
100
|
+
/** The JSON-RPC error code. */
|
|
101
|
+
readonly code: number;
|
|
102
|
+
/** The machine-readable detail the node sent, if any — e.g. `{ position, expected, got }`. */
|
|
103
|
+
readonly data: unknown;
|
|
104
|
+
/** The query string that was rejected. */
|
|
105
|
+
readonly query: string;
|
|
106
|
+
constructor(kind: QueryErrorKind, code: number, query: string, data: unknown, detail?: string);
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/query/queryResult.d.ts
|
|
110
|
+
/** Fetches the page a cursor points at. */
|
|
111
|
+
type FetchPage<TEntity> = (cursor: string) => Promise<QueryResult<TEntity>>;
|
|
112
|
+
/**
|
|
113
|
+
* One page of query results.
|
|
114
|
+
*
|
|
115
|
+
* A page is immutable: {@link next} returns the following page rather than mutating this one, so a
|
|
116
|
+
* page that has been read stays readable.
|
|
117
|
+
*
|
|
118
|
+
* @typeParam TEntity - The shape of each entity, inferred from the selection by `client.select()`.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* let page = await client.select({ key: true }).where(eq("category", "docs")).limit(100).fetch()
|
|
122
|
+
* while (page.hasNextPage()) {
|
|
123
|
+
* page = await page.next()
|
|
124
|
+
* }
|
|
125
|
+
*/
|
|
126
|
+
declare class QueryResult<TEntity = Entity> {
|
|
127
|
+
/** The entities on this page. */
|
|
128
|
+
readonly entities: readonly TEntity[];
|
|
129
|
+
/**
|
|
130
|
+
* The block this page was read at.
|
|
131
|
+
*
|
|
132
|
+
* Every page of one walk reads the same block — the cursor is bound to it — so results cannot
|
|
133
|
+
* shift under a paginating reader.
|
|
134
|
+
*/
|
|
135
|
+
readonly blockNumber: bigint;
|
|
136
|
+
/** The cursor for the next page, or `undefined` when this was the last one. */
|
|
137
|
+
readonly cursor: string | undefined;
|
|
138
|
+
private readonly fetchPage;
|
|
139
|
+
constructor(entities: readonly TEntity[], blockNumber: bigint, cursor: string | undefined, fetchPage: FetchPage<TEntity>);
|
|
140
|
+
/**
|
|
141
|
+
* Whether another page follows.
|
|
142
|
+
*
|
|
143
|
+
* The node omits the cursor once nothing remains, so this is an answer rather than the guess a
|
|
144
|
+
* short final page would be — a full last page is reported correctly.
|
|
145
|
+
*/
|
|
146
|
+
hasNextPage(): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Fetches the next page.
|
|
149
|
+
*
|
|
150
|
+
* @throws {NoMoreResultsError} If this was the last page — check {@link hasNextPage} first.
|
|
151
|
+
* @throws {QueryError} If the node rejects the request; `kind === "cursor"` means the cursor
|
|
152
|
+
* expired and the walk has to start again.
|
|
153
|
+
*/
|
|
154
|
+
next(): Promise<QueryResult<TEntity>>;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/query/queryBuilder.d.ts
|
|
158
|
+
/**
|
|
159
|
+
* Builds and runs a query.
|
|
160
|
+
*
|
|
161
|
+
* The selection is fixed when the builder is created and the filter is added by chaining, so the
|
|
162
|
+
* result type is known before a single predicate is written. Create one with `client.select(...)`
|
|
163
|
+
* rather than constructing it directly — that is what infers the entity shape from the selection.
|
|
164
|
+
*
|
|
165
|
+
* Every filter added with {@link where}, {@link ownedBy} and {@link createdBy} must hold; use
|
|
166
|
+
* {@link or} for alternatives inside one call.
|
|
167
|
+
*
|
|
168
|
+
* @typeParam TEntity - The projected entity shape, inferred from the selection by `client.select()`.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* import { createPublicClient } from "@arkiv-network/sdk"
|
|
172
|
+
* import { i32 } from "@arkiv-network/sdk/attr"
|
|
173
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
174
|
+
* import { eq, gte, or } from "@arkiv-network/sdk/query"
|
|
175
|
+
* import { http } from "viem"
|
|
176
|
+
*
|
|
177
|
+
* const client = createPublicClient({ chain: cheesecake, transport: http() })
|
|
178
|
+
*
|
|
179
|
+
* const page = await client
|
|
180
|
+
* .select({ key: true, attributes: true })
|
|
181
|
+
* .where(gte("level", i32(10)), or(eq("status", "open"), eq("status", "review")))
|
|
182
|
+
* .ownedBy(owner)
|
|
183
|
+
* .limit(100)
|
|
184
|
+
* .fetch()
|
|
185
|
+
*
|
|
186
|
+
* for (const entity of page.entities) console.log(entity.key, entity.attributes)
|
|
187
|
+
*/
|
|
188
|
+
declare class SelectQueryBuilder<TEntity = Entity> {
|
|
189
|
+
private readonly _client;
|
|
190
|
+
private readonly _select;
|
|
191
|
+
private readonly _filters;
|
|
192
|
+
private _ownedBy;
|
|
193
|
+
private _createdBy;
|
|
194
|
+
private _limit;
|
|
195
|
+
private _cursor;
|
|
196
|
+
private _atBlock;
|
|
197
|
+
constructor(client: ArkivClient, selection?: SelectArg);
|
|
198
|
+
/**
|
|
199
|
+
* Adds filters. Everything passed here, and across repeated calls, must hold.
|
|
200
|
+
*
|
|
201
|
+
* @param expressions - The expressions, as separate arguments or one array.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* builder.where(eq("category", "docs"))
|
|
205
|
+
* builder.where(gte("level", i32(10)), lt("level", i32(20)))
|
|
206
|
+
* builder.where(or(eq("status", "open"), not(exists("closedAt"))))
|
|
207
|
+
*/
|
|
208
|
+
where(expressions: readonly Expression[]): this;
|
|
209
|
+
where(...expressions: Expression[]): this;
|
|
210
|
+
/**
|
|
211
|
+
* Restricts the results to entities this account owns — shorthand for
|
|
212
|
+
* `where(eq("$owner", addr(owner)))`. Calling it again replaces the filter.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* builder.ownedBy("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")
|
|
216
|
+
*/
|
|
217
|
+
ownedBy(owner: Hex): this;
|
|
218
|
+
/**
|
|
219
|
+
* Restricts the results to entities this account created — shorthand for
|
|
220
|
+
* `where(eq("$creator", addr(creator)))`. Calling it again replaces the filter.
|
|
221
|
+
*
|
|
222
|
+
* The creator never changes; the owner does, so these differ after a transfer.
|
|
223
|
+
*/
|
|
224
|
+
createdBy(creator: Hex): this;
|
|
225
|
+
/**
|
|
226
|
+
* Sets the page size, up to the node maximum of 200. Without it the node picks the page size.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* builder.limit(100)
|
|
230
|
+
*/
|
|
231
|
+
limit(limit: number): this;
|
|
232
|
+
/**
|
|
233
|
+
* Starts from a cursor returned by an earlier page.
|
|
234
|
+
*
|
|
235
|
+
* Pagination normally goes through {@link QueryResult.next}, which carries the cursor for you;
|
|
236
|
+
* this is for resuming a walk in a later process. A cursor is bound to the query, block and
|
|
237
|
+
* selection it came from, so it must be used with an identically-built query.
|
|
238
|
+
*/
|
|
239
|
+
cursor(cursor: string): this;
|
|
240
|
+
/**
|
|
241
|
+
* Reads the state as of a given block rather than the head. The block must be within the range
|
|
242
|
+
* the node retains.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* builder.atBlock(1_297_000n)
|
|
246
|
+
*/
|
|
247
|
+
atBlock(block: bigint): this;
|
|
248
|
+
/**
|
|
249
|
+
* The query string this builder will send — the same text the node parses.
|
|
250
|
+
*
|
|
251
|
+
* @throws {InvalidPredicateError} If no filter has been added.
|
|
252
|
+
*/
|
|
253
|
+
toString(): string;
|
|
254
|
+
/**
|
|
255
|
+
* Runs the query and returns the first page.
|
|
256
|
+
*
|
|
257
|
+
* @throws {InvalidPredicateError} If no filter has been added.
|
|
258
|
+
* @throws {QueryError} If the node rejects the query.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* const page = await client.select({ key: true }).where(eq("category", "docs")).fetch()
|
|
262
|
+
* page.entities // this page
|
|
263
|
+
* await page.next() // the next one
|
|
264
|
+
*/
|
|
265
|
+
fetch(): Promise<QueryResult<TEntity>>;
|
|
266
|
+
/**
|
|
267
|
+
* Walks every page, yielding one entity at a time.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* for await (const entity of client.select({ key: true }).where(eq("category", "docs"))) {
|
|
271
|
+
* console.log(entity.key)
|
|
272
|
+
* }
|
|
273
|
+
*/
|
|
274
|
+
[Symbol.asyncIterator](): AsyncGenerator<TEntity>;
|
|
275
|
+
}
|
|
276
|
+
//#endregion
|
|
277
|
+
export { QueryErrorKind as a, QueryRequest as c, QueryError as i, QueryResponse as l, QueryResult as n, UnsupportedOperatorError as o, InvalidPredicateError as r, MAX_LIMIT as s, SelectQueryBuilder as t, runQuery as u };
|
|
278
|
+
//# sourceMappingURL=index-VCqgn29D.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-VCqgn29D.d.ts","names":[],"sources":["../src/query/engine.ts","../src/query/errors.ts","../src/query/queryResult.ts","../src/query/queryBuilder.ts"],"sourcesContent":[],"mappings":";;;;;cAUa,SAAA;;AAAA,KAGD,YAAA,GAHU;EAGV;EAcA,KAAA,EAAA,MAAA;EAaU;EAAiB,MAAA,EAvB7B,SAuB6B;EAAsB;EAAuB,KAAA,CAAA,EAAA,MAA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