@arkiv-network/sdk 0.8.0 → 0.8.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/dist/entity/index.d.cts +1 -2
- package/dist/entity/index.d.ts +1 -2
- package/dist/expiry-BxOlvVWC.d.ts.map +1 -1
- package/dist/{index-BGp2plHs.d.cts → index-BkqSnGJH.d.ts} +41 -2
- package/dist/index-BkqSnGJH.d.ts.map +1 -0
- package/dist/{index-DsM7EXu6.d.cts → index-C7fbakoI.d.cts} +2 -2
- package/dist/{index-DsM7EXu6.d.cts.map → index-C7fbakoI.d.cts.map} +1 -1
- package/dist/{index-ezMZ2-JH.d.ts → index-CLhsFyVH.d.cts} +41 -2
- package/dist/index-CLhsFyVH.d.cts.map +1 -0
- package/dist/{index-CmEefH8_.d.ts → index-Cq6fa8AI.d.ts} +2 -2
- package/dist/{index-CmEefH8_.d.ts.map → index-Cq6fa8AI.d.ts.map} +1 -1
- package/dist/{changeOwnership-B0ar96ub.d.ts → index-DaNeJUw8.d.ts} +460 -27
- package/dist/index-DaNeJUw8.d.ts.map +1 -0
- package/dist/{changeOwnership-BofkLnXJ.d.cts → index-Dv16LO2s.d.cts} +460 -27
- package/dist/index-Dv16LO2s.d.cts.map +1 -0
- package/dist/index.cjs +35 -34
- package/dist/index.d.cts +6 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/{payload-CGvVPZQX.d.ts → payload-AfUfSctb.d.ts} +1 -1
- package/dist/{payload-CGvVPZQX.d.ts.map → payload-AfUfSctb.d.ts.map} +1 -1
- package/dist/{payload-Dfu30njp.d.cts → payload-D167BlJR.d.cts} +1 -1
- package/dist/{payload-Dfu30njp.d.cts.map → payload-D167BlJR.d.cts.map} +1 -1
- package/dist/query/index.cjs +22 -22
- package/dist/query/index.d.cts +6 -5
- package/dist/query/index.d.ts +6 -5
- package/dist/query/index.js +1 -1
- package/dist/{queryBuilder-MubNEvA4.js → query-Ber-lOJQ.js} +1 -1
- package/dist/query-Ber-lOJQ.js.map +1 -0
- package/dist/types/index.d.cts +2 -4
- package/dist/types/index.d.ts +2 -4
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/package.json +1 -1
- package/src/index.ts +11 -0
- package/src/query/index.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/dist/changeOwnership-B0ar96ub.d.ts.map +0 -1
- package/dist/changeOwnership-BofkLnXJ.d.cts.map +0 -1
- package/dist/flags-0Vl5rrHq.d.cts +0 -41
- package/dist/flags-0Vl5rrHq.d.cts.map +0 -1
- package/dist/flags-wmcMoAnN.d.ts +0 -41
- package/dist/flags-wmcMoAnN.d.ts.map +0 -1
- package/dist/index-BGp2plHs.d.cts.map +0 -1
- package/dist/index-ezMZ2-JH.d.ts.map +0 -1
- package/dist/queryBuilder-MubNEvA4.js.map +0 -1
- package/dist/selection-Bv8_o-7i.d.cts +0 -441
- package/dist/selection-Bv8_o-7i.d.cts.map +0 -1
- package/dist/selection-ox7zdtVm.d.ts +0 -441
- package/dist/selection-ox7zdtVm.d.ts.map +0 -1
- /package/dist/{queryBuilder-BmRTaoJ8.cjs → query-9oojUdM7.cjs} +0 -0
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
import { C as ValueInput, G as StrValue, R as ArkivValue, Y as UserTypeTag, h as Attributes, m as AttributeSchema } from "./index-Cd2aaWme.js";
|
|
2
|
-
import { n as ResolvedCreationFlags } from "./flags-wmcMoAnN.js";
|
|
3
|
-
import { Account, Chain, Client, Hex, RpcSchema, Transport } from "viem";
|
|
4
|
-
|
|
5
|
-
//#region src/types/rpcSchema.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* An attribute as the node renders it: the name, the type **tag** (not the wire typeId), and the
|
|
9
|
-
* value in the JSON encoding that type prescribes — a JSON number for `i32`, a `0x` QUANTITY for
|
|
10
|
-
* `u64` and `u256`, a decimal string for `dec`, `0x` DATA for the byte-shaped types, and a string for
|
|
11
|
-
* `str`.
|
|
12
|
-
*
|
|
13
|
-
* The encoding follows the *declared type*, never the magnitude, so a decoder dispatches on `type`
|
|
14
|
-
* and never has to guess from the shape of the value.
|
|
15
|
-
*/
|
|
16
|
-
type RpcAttribute = {
|
|
17
|
-
name: string;
|
|
18
|
-
type: string;
|
|
19
|
-
value: unknown;
|
|
20
|
-
};
|
|
21
|
-
/** An entry of the `attributeSchema` projection — a name and its type, with no value. */
|
|
22
|
-
type RpcAttributeSchemaEntry = {
|
|
23
|
-
name: string;
|
|
24
|
-
type: string;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* The `creationFlags` projection.
|
|
28
|
-
*/
|
|
29
|
-
type RpcCreationFlags = {
|
|
30
|
-
readonly?: boolean;
|
|
31
|
-
permissionlessExtension?: boolean;
|
|
32
|
-
raw: number;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* An entity as `arkiv_query` returns it. Every field is present only if it was selected, so all of
|
|
36
|
-
* them are optional here — {@link RpcSelect} is what decides which arrive.
|
|
37
|
-
*/
|
|
38
|
-
type RpcEntity = {
|
|
39
|
-
key?: Hex;
|
|
40
|
-
owner?: Hex;
|
|
41
|
-
creator?: Hex;
|
|
42
|
-
createdAt?: Hex;
|
|
43
|
-
updatedAt?: Hex;
|
|
44
|
-
expiresAt?: Hex;
|
|
45
|
-
creationFlags?: RpcCreationFlags | number;
|
|
46
|
-
contentType?: string;
|
|
47
|
-
payload?: Hex;
|
|
48
|
-
attributeSchema?: RpcAttributeSchemaEntry[];
|
|
49
|
-
attributes?: RpcAttribute[];
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* The `select` projection: flat, per-field booleans. Everything except `key` defaults to **off**,
|
|
53
|
-
* so a query asks for exactly what it needs and nothing more.
|
|
54
|
-
*
|
|
55
|
-
* `attributes` is the one field with a third form: `true` for every attribute, or a map of names
|
|
56
|
-
* for a subset.
|
|
57
|
-
*/
|
|
58
|
-
type RpcSelect = {
|
|
59
|
-
key?: boolean;
|
|
60
|
-
owner?: boolean;
|
|
61
|
-
creator?: boolean;
|
|
62
|
-
createdAt?: boolean;
|
|
63
|
-
updatedAt?: boolean;
|
|
64
|
-
expiresAt?: boolean;
|
|
65
|
-
creationFlags?: boolean;
|
|
66
|
-
contentType?: boolean;
|
|
67
|
-
payload?: boolean;
|
|
68
|
-
attributeSchema?: boolean;
|
|
69
|
-
attributes?: boolean | Record<string, boolean>;
|
|
70
|
-
};
|
|
71
|
-
/** The second parameter of `arkiv_query` — what to return, and where in the results to start. */
|
|
72
|
-
type RpcQueryOptions = {
|
|
73
|
-
/** Block height to read at, as a hex quantity. Defaults to the head, and must be within the node's retained range. */
|
|
74
|
-
atBlock?: Hex;
|
|
75
|
-
/** What to return. Defaults to `{ key: true }`. */
|
|
76
|
-
select?: RpcSelect;
|
|
77
|
-
/** Page size, as a hex quantity. Node maximum is 200. */
|
|
78
|
-
limit?: Hex;
|
|
79
|
-
/** Opaque cursor from a previous response; bound to that query, block and selection. */
|
|
80
|
-
cursor?: string;
|
|
81
|
-
};
|
|
82
|
-
type ArkivRpcSchema = [{
|
|
83
|
-
Method: "arkiv_query";
|
|
84
|
-
Parameters?: [query: string, queryOptions?: RpcQueryOptions];
|
|
85
|
-
ReturnType: {
|
|
86
|
-
data: RpcEntity[];
|
|
87
|
-
blockNumber: Hex;
|
|
88
|
-
/** Omitted when no pages remain. */
|
|
89
|
-
cursor?: string;
|
|
90
|
-
};
|
|
91
|
-
}, {
|
|
92
|
-
Method: "arkiv_getBlockTiming";
|
|
93
|
-
Parameters?: [];
|
|
94
|
-
ReturnType: {
|
|
95
|
-
current_block: bigint;
|
|
96
|
-
current_block_time: number;
|
|
97
|
-
duration: number;
|
|
98
|
-
};
|
|
99
|
-
}, {
|
|
100
|
-
Method: "arkiv_getEntityCount";
|
|
101
|
-
Parameters?: [];
|
|
102
|
-
ReturnType: number;
|
|
103
|
-
}];
|
|
104
|
-
//#endregion
|
|
105
|
-
//#region src/clients/baseClient.d.ts
|
|
106
|
-
type ArkivClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, accountOrAddress extends Account | undefined = Account | undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema> = Client<transport, chain, accountOrAddress, rpcSchema>;
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/types/entity.d.ts
|
|
109
|
-
/**
|
|
110
|
-
* The fields an {@link Entity} can carry. Every one is optional: a query returns exactly the parts
|
|
111
|
-
* it selected, and `undefined` means "not asked for" rather than "empty".
|
|
112
|
-
*/
|
|
113
|
-
type EntityFields = {
|
|
114
|
-
key?: Hex | undefined;
|
|
115
|
-
owner?: Hex | undefined;
|
|
116
|
-
creator?: Hex | undefined;
|
|
117
|
-
/** Block the entity was created at. */
|
|
118
|
-
createdAt?: bigint | undefined;
|
|
119
|
-
/** Block the entity was last patched at. */
|
|
120
|
-
updatedAt?: bigint | undefined;
|
|
121
|
-
/** Block the entity expires at. */
|
|
122
|
-
expiresAt?: bigint | undefined;
|
|
123
|
-
/** The immutable properties the entity was created with. */
|
|
124
|
-
creationFlags?: ResolvedCreationFlags | undefined;
|
|
125
|
-
contentType?: string | undefined;
|
|
126
|
-
payload?: Uint8Array | undefined;
|
|
127
|
-
/** Attribute names and types, with no values. */
|
|
128
|
-
attributeSchema?: AttributeSchema | undefined;
|
|
129
|
-
/** Attribute names, types and values. */
|
|
130
|
-
attributes?: Attributes | undefined;
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* An entity as it comes back from a query.
|
|
134
|
-
*
|
|
135
|
-
* Which fields are populated is decided by the query's selection — `select({ key: true })` gives
|
|
136
|
-
* back an entity carrying only its key. The static type of a `select()` result is narrowed to
|
|
137
|
-
* exactly the selected fields, so in typed code the `undefined`s here are not reachable.
|
|
138
|
-
*/
|
|
139
|
-
declare class Entity implements EntityFields {
|
|
140
|
-
key: Hex | undefined;
|
|
141
|
-
owner: Hex | undefined;
|
|
142
|
-
creator: Hex | undefined;
|
|
143
|
-
createdAt: bigint | undefined;
|
|
144
|
-
updatedAt: bigint | undefined;
|
|
145
|
-
expiresAt: bigint | undefined;
|
|
146
|
-
creationFlags: ResolvedCreationFlags | undefined;
|
|
147
|
-
contentType: string | undefined;
|
|
148
|
-
payload: Uint8Array | undefined;
|
|
149
|
-
attributeSchema: AttributeSchema | undefined;
|
|
150
|
-
attributes: Attributes | undefined;
|
|
151
|
-
constructor(fields?: EntityFields);
|
|
152
|
-
/**
|
|
153
|
-
* The payload decoded as UTF-8 text.
|
|
154
|
-
*
|
|
155
|
-
* @throws If the payload was not selected, or is not valid UTF-8.
|
|
156
|
-
*/
|
|
157
|
-
toText(): string;
|
|
158
|
-
/**
|
|
159
|
-
* The payload parsed as JSON.
|
|
160
|
-
*
|
|
161
|
-
* @throws If the payload was not selected, is empty, or is not valid JSON.
|
|
162
|
-
*/
|
|
163
|
-
toJson(): any;
|
|
164
|
-
}
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region src/query/expression.d.ts
|
|
167
|
-
/**
|
|
168
|
-
* The comparison operators the query language defines. `<` `<=` `>` `>=` need an ordered type —
|
|
169
|
-
* `i32`, `u64`, `u256` or `dec`; every type accepts `=` and `!=`.
|
|
170
|
-
*/
|
|
171
|
-
type ComparisonOperator = "=" | "!=" | "<" | "<=" | ">" | ">=";
|
|
172
|
-
/** A comparison between an attribute and a typed literal. */
|
|
173
|
-
type ComparisonNode = {
|
|
174
|
-
readonly kind: "comparison";
|
|
175
|
-
readonly name: string;
|
|
176
|
-
readonly operator: ComparisonOperator;
|
|
177
|
-
readonly value: ArkivValue;
|
|
178
|
-
};
|
|
179
|
-
/** A `STARTSWITH` prefix test, the language's only pattern operator. */
|
|
180
|
-
type StartsWithNode = {
|
|
181
|
-
readonly kind: "startsWith";
|
|
182
|
-
readonly name: string;
|
|
183
|
-
readonly value: StrValue;
|
|
184
|
-
};
|
|
185
|
-
/** An `EXISTS(name)` test — true when the attribute is set with any type. */
|
|
186
|
-
type ExistsNode = {
|
|
187
|
-
readonly kind: "exists";
|
|
188
|
-
readonly name: string;
|
|
189
|
-
};
|
|
190
|
-
/** A `TYPEOF(name) = tag` test. */
|
|
191
|
-
type TypeOfNode = {
|
|
192
|
-
readonly kind: "typeOf";
|
|
193
|
-
readonly name: string;
|
|
194
|
-
readonly tag: UserTypeTag;
|
|
195
|
-
};
|
|
196
|
-
/** The complement of an expression, evaluated against the active-entity set. */
|
|
197
|
-
type NotNode = {
|
|
198
|
-
readonly kind: "not";
|
|
199
|
-
readonly expression: Expression;
|
|
200
|
-
};
|
|
201
|
-
/** A conjunction. */
|
|
202
|
-
type AndNode = {
|
|
203
|
-
readonly kind: "and";
|
|
204
|
-
readonly expressions: readonly Expression[];
|
|
205
|
-
};
|
|
206
|
-
/** A disjunction. */
|
|
207
|
-
type OrNode = {
|
|
208
|
-
readonly kind: "or";
|
|
209
|
-
readonly expressions: readonly Expression[];
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* A query expression: an immutable tree built by the combinators below, whose `toString()` is the
|
|
213
|
-
* exact query string sent over the wire.
|
|
214
|
-
*
|
|
215
|
-
* @example
|
|
216
|
-
* const q = and(gte("level", i32(10)), or(eq("status", str("open")), not(exists("closedAt"))))
|
|
217
|
-
* String(q) // level >= i32(10) AND (status = str('open') OR NOT EXISTS(closedAt))
|
|
218
|
-
*/
|
|
219
|
-
type Expression = ComparisonNode | StartsWithNode | ExistsNode | TypeOfNode | NotNode | AndNode | OrNode;
|
|
220
|
-
/**
|
|
221
|
-
* Attribute equals value — set with this exact type, and holding this value.
|
|
222
|
-
*
|
|
223
|
-
* Bare booleans, numbers, bigints and strings take the same default types they take when written
|
|
224
|
-
* (`number` is an `i32`, `bigint` a `u256`, `string` a `str`); anything else names its type.
|
|
225
|
-
*
|
|
226
|
-
* @throws {InvalidPredicateError} If the name is not a queryable attribute, or a system attribute
|
|
227
|
-
* is compared against the wrong type.
|
|
228
|
-
*
|
|
229
|
-
* @example
|
|
230
|
-
* eq("status", str("open")) // status = str('open')
|
|
231
|
-
* eq("flagged", true) // flagged = true
|
|
232
|
-
* eq("$owner", addr(account)) // $owner = addr(0xd8dA…)
|
|
233
|
-
*/
|
|
234
|
-
declare function eq(name: string, value: ValueInput): ComparisonNode;
|
|
235
|
-
/**
|
|
236
|
-
* Attribute is set with this type and holds a **different** value.
|
|
237
|
-
*
|
|
238
|
-
* This is typed value-negation, not the complement: an entity that never set the attribute, or set
|
|
239
|
-
* it with another type, does not match. Use `not(eq(...))` for the full complement.
|
|
240
|
-
*
|
|
241
|
-
* @example
|
|
242
|
-
* ne("status", str("closed")) // status != str('closed')
|
|
243
|
-
* not(eq("status", str("closed"))) // NOT status = str('closed') — also matches entities with no status
|
|
244
|
-
*/
|
|
245
|
-
declare function ne(name: string, value: ValueInput): ComparisonNode;
|
|
246
|
-
/**
|
|
247
|
-
* Attribute is greater than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
248
|
-
*
|
|
249
|
-
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
250
|
-
*
|
|
251
|
-
* @example
|
|
252
|
-
* gt("level", i32(10)) // level > i32(10)
|
|
253
|
-
* gt("$expiresAt", u64(1_200_000n)) // $expiresAt > u64(1200000)
|
|
254
|
-
*/
|
|
255
|
-
declare function gt(name: string, value: ValueInput): ComparisonNode;
|
|
256
|
-
/**
|
|
257
|
-
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
258
|
-
*
|
|
259
|
-
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
260
|
-
*
|
|
261
|
-
* @example
|
|
262
|
-
* gte("score", dec("3.5")) // score >= dec(3.5)
|
|
263
|
-
*/
|
|
264
|
-
declare function gte(name: string, value: ValueInput): ComparisonNode;
|
|
265
|
-
/**
|
|
266
|
-
* Attribute is less than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
267
|
-
*
|
|
268
|
-
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* lt("level", i32(10)) // level < i32(10)
|
|
272
|
-
*/
|
|
273
|
-
declare function lt(name: string, value: ValueInput): ComparisonNode;
|
|
274
|
-
/**
|
|
275
|
-
* Attribute is less than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
276
|
-
*
|
|
277
|
-
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
278
|
-
*
|
|
279
|
-
* @example
|
|
280
|
-
* lte("score", dec("5")) // score <= dec(5)
|
|
281
|
-
*/
|
|
282
|
-
declare function lte(name: string, value: ValueInput): ComparisonNode;
|
|
283
|
-
/**
|
|
284
|
-
* Attribute is a `str` beginning with this prefix.
|
|
285
|
-
*
|
|
286
|
-
* The match is on **raw UTF-8 bytes** with no normalization — it is the index encoding, so
|
|
287
|
-
* `startsWith("name", "é")` matches only the same byte sequence, not another normal form of it.
|
|
288
|
-
*
|
|
289
|
-
* @param prefix - The prefix, as a bare string or a `str` value.
|
|
290
|
-
* @throws {InvalidPredicateError} If the name is not a queryable attribute.
|
|
291
|
-
* @throws {UnsupportedOperatorError} If given a value that is not a `str`, or a system attribute
|
|
292
|
-
* (none of which is a `str`).
|
|
293
|
-
*
|
|
294
|
-
* @example
|
|
295
|
-
* startsWith("desc", "ab") // desc STARTSWITH str('ab')
|
|
296
|
-
*/
|
|
297
|
-
declare function startsWith(name: string, prefix: string | StrValue): StartsWithNode;
|
|
298
|
-
/**
|
|
299
|
-
* The attribute is set, with any type.
|
|
300
|
-
*
|
|
301
|
-
* @throws {InvalidPredicateError} If given a system attribute — every entity has all of them, so
|
|
302
|
-
* the test would be a constant.
|
|
303
|
-
*
|
|
304
|
-
* @example
|
|
305
|
-
* exists("reviewedBy") // EXISTS(reviewedBy)
|
|
306
|
-
* not(exists("closedAt")) // NOT EXISTS(closedAt)
|
|
307
|
-
*/
|
|
308
|
-
declare function exists(name: string): ExistsNode;
|
|
309
|
-
/**
|
|
310
|
-
* The attribute is set with exactly this type, whatever its value.
|
|
311
|
-
*
|
|
312
|
-
* Useful when the same name is written with different types across entities — a comparison already
|
|
313
|
-
* asserts the type, so this is for asking about the type alone.
|
|
314
|
-
*
|
|
315
|
-
* @param tag - The type tag: `bool`, `i32`, `u64`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
316
|
-
* `key`.
|
|
317
|
-
* @throws {InvalidPredicateError} If the tag is not a settable type, or the name is a system
|
|
318
|
-
* attribute (whose type is fixed).
|
|
319
|
-
*
|
|
320
|
-
* @example
|
|
321
|
-
* hasType("age", "i32") // TYPEOF(age) = i32
|
|
322
|
-
*/
|
|
323
|
-
declare function hasType(name: string, tag: UserTypeTag): TypeOfNode;
|
|
324
|
-
/**
|
|
325
|
-
* The complement of an expression, evaluated against the set of live entities — unlike `!=`, it
|
|
326
|
-
* matches entities that never set the attribute at all.
|
|
327
|
-
*
|
|
328
|
-
* @example
|
|
329
|
-
* not(exists("closedAt")) // NOT EXISTS(closedAt)
|
|
330
|
-
* not(and(eq("a", 1), eq("b", 2))) // NOT (a = i32(1) AND b = i32(2))
|
|
331
|
-
*/
|
|
332
|
-
declare function not(expression: Expression): NotNode;
|
|
333
|
-
/**
|
|
334
|
-
* All of these must hold.
|
|
335
|
-
*
|
|
336
|
-
* A single expression is returned unwrapped, so building a conjunction from a filtered list does
|
|
337
|
-
* not litter the query with redundant nesting.
|
|
338
|
-
*
|
|
339
|
-
* @param expressions - The expressions, as separate arguments or one array.
|
|
340
|
-
* @throws {InvalidPredicateError} If given nothing to combine.
|
|
341
|
-
*
|
|
342
|
-
* @example
|
|
343
|
-
* and(gte("level", i32(10)), eq("status", "open"))
|
|
344
|
-
* and(filters) // an array works too
|
|
345
|
-
*/
|
|
346
|
-
declare function and(expressions: readonly Expression[]): Expression;
|
|
347
|
-
declare function and(...expressions: Expression[]): Expression;
|
|
348
|
-
/**
|
|
349
|
-
* At least one of these must hold.
|
|
350
|
-
*
|
|
351
|
-
* A single expression is returned unwrapped.
|
|
352
|
-
*
|
|
353
|
-
* @param expressions - The expressions, as separate arguments or one array.
|
|
354
|
-
* @throws {InvalidPredicateError} If given nothing to combine.
|
|
355
|
-
*
|
|
356
|
-
* @example
|
|
357
|
-
* or(eq("status", "open"), not(exists("closedAt")))
|
|
358
|
-
*/
|
|
359
|
-
declare function or(expressions: readonly Expression[]): Expression;
|
|
360
|
-
declare function or(...expressions: Expression[]): Expression;
|
|
361
|
-
/**
|
|
362
|
-
* Renders an expression as the query string the node parses. Equivalent to `String(expression)`.
|
|
363
|
-
*
|
|
364
|
-
* Literals are always written tagged, even where the language would infer them: an untagged number
|
|
365
|
-
* defaults to `i32`, but spelling it `i32(10)` keeps the exact-type assertion visible in the query
|
|
366
|
-
* that actually went over the wire.
|
|
367
|
-
*/
|
|
368
|
-
declare function render(expression: Expression): string;
|
|
369
|
-
//#endregion
|
|
370
|
-
//#region src/query/selection.d.ts
|
|
371
|
-
/**
|
|
372
|
-
* The entity fields a query can select. Each maps one-to-one onto a field of {@link Entity}.
|
|
373
|
-
*
|
|
374
|
-
* `attributes` takes a third form beyond `true`/`false`: a map of names, to fetch only those.
|
|
375
|
-
*/
|
|
376
|
-
type SelectionFields = {
|
|
377
|
-
key?: boolean;
|
|
378
|
-
owner?: boolean;
|
|
379
|
-
creator?: boolean;
|
|
380
|
-
createdAt?: boolean;
|
|
381
|
-
updatedAt?: boolean;
|
|
382
|
-
expiresAt?: boolean;
|
|
383
|
-
creationFlags?: boolean;
|
|
384
|
-
contentType?: boolean;
|
|
385
|
-
payload?: boolean;
|
|
386
|
-
/** Attribute names and types, without their values. */
|
|
387
|
-
attributeSchema?: boolean;
|
|
388
|
-
/** `true` for every attribute, or a map of names for a subset. */
|
|
389
|
-
attributes?: boolean | Readonly<Record<string, boolean>>;
|
|
390
|
-
};
|
|
391
|
-
/** The selection keys, in the order they are written into the RPC `select` object. */
|
|
392
|
-
declare const SELECTION_KEYS: readonly ["key", "owner", "creator", "createdAt", "updatedAt", "expiresAt", "creationFlags", "contentType", "payload", "attributeSchema", "attributes"];
|
|
393
|
-
/**
|
|
394
|
-
* Requires at least one property of `T` to be present.
|
|
395
|
-
* `{}` is not assignable, which is how `select({})` is rejected at compile time.
|
|
396
|
-
*/
|
|
397
|
-
type AtLeastOne<T, K$1 extends keyof T = keyof T> = { [P in K$1]: Required<Pick<T, P>> & Partial<Omit<T, P>> }[K$1];
|
|
398
|
-
/**
|
|
399
|
-
* A non-empty entity selection — the object form accepted by `select()`. At least one field must be
|
|
400
|
-
* selected.
|
|
401
|
-
*/
|
|
402
|
-
type EntitySelection = AtLeastOne<SelectionFields>;
|
|
403
|
-
/** Argument accepted by `select()` — a non-empty {@link EntitySelection}, or `"*"` for everything. */
|
|
404
|
-
type SelectArg = EntitySelection | "*";
|
|
405
|
-
/** Whether a selection value asks for the field: `true`, or a non-empty map of attribute names. */
|
|
406
|
-
type Selected<V> = V extends false | undefined ? false : true;
|
|
407
|
-
/**
|
|
408
|
-
* The result of a selection `S`: an {@link Entity} narrowed to exactly the selected fields (each
|
|
409
|
-
* non-`undefined`). The shape is flat — `select({ owner: true })` yields `{ owner: Hex }`, read as
|
|
410
|
-
* `entity.owner`. Accessing an unselected field is a compile error.
|
|
411
|
-
*
|
|
412
|
-
* `toText()` / `toJson()` operate on the payload, so they appear only when `payload` was selected —
|
|
413
|
-
* calling them otherwise would always throw.
|
|
414
|
-
*/
|
|
415
|
-
type ProjectedEntity<S> = { readonly [K in keyof S as Selected<S[K]> extends true ? K : never]: K extends keyof Entity ? NonNullable<Entity[K]> : never } & (S extends {
|
|
416
|
-
payload: true;
|
|
417
|
-
} ? Pick<Entity, "toText" | "toJson"> : unknown);
|
|
418
|
-
/** A selection of every field, used to type the result of `select()` / `select("*")`. */
|
|
419
|
-
type AllSelected = { [K in (typeof SELECTION_KEYS)[number]]: true };
|
|
420
|
-
/** The projected entity type when everything is selected — every field, plus the methods. */
|
|
421
|
-
type FullEntity = ProjectedEntity<AllSelected>;
|
|
422
|
-
/**
|
|
423
|
-
* Converts a {@link SelectArg} into the RPC `select` object.
|
|
424
|
-
*
|
|
425
|
-
* Every field is opt-in — anything not explicitly selected is sent as `false`, including the key.
|
|
426
|
-
* Sending the full object rather than omitting the `false`s keeps what the SDK asked for legible in
|
|
427
|
-
* a request log, and pins the answer even if a node's defaults change.
|
|
428
|
-
*
|
|
429
|
-
* `undefined` or `"*"` selects everything.
|
|
430
|
-
*
|
|
431
|
-
* @throws If the selection asks for nothing.
|
|
432
|
-
*
|
|
433
|
-
* @example
|
|
434
|
-
* toRpcSelect() // everything
|
|
435
|
-
* toRpcSelect({ key: true }) // only the key
|
|
436
|
-
* toRpcSelect({ attributes: { projectId: true } }) // one named attribute
|
|
437
|
-
*/
|
|
438
|
-
declare function toRpcSelect(selection?: SelectArg): RpcSelect;
|
|
439
|
-
//#endregion
|
|
440
|
-
export { EntityFields as A, lte as C, render as D, or as E, RpcCreationFlags as F, RpcEntity as I, RpcQueryOptions as L, ArkivRpcSchema as M, RpcAttribute as N, startsWith as O, RpcAttributeSchemaEntry as P, RpcSelect as R, lt as S, not as T, eq as _, SelectionFields as a, gte as b, ComparisonNode as c, Expression as d, NotNode as f, and as g, TypeOfNode as h, SelectArg as i, ArkivClient as j, Entity as k, ComparisonOperator as l, StartsWithNode as m, FullEntity as n, toRpcSelect as o, OrNode as p, ProjectedEntity as r, AndNode as s, EntitySelection as t, ExistsNode as u, exists as v, ne as w, hasType as x, gt as y };
|
|
441
|
-
//# sourceMappingURL=selection-ox7zdtVm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selection-ox7zdtVm.d.ts","names":[],"sources":["../src/types/rpcSchema.ts","../src/clients/baseClient.ts","../src/types/entity.ts","../src/query/expression.ts","../src/query/selection.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAWA;AAOA;AAQA;AAUA;;AAEU,KA3BE,YAAA,GA2BF;E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