@arkiv-network/sdk 0.6.8-dev.1 → 0.6.8-dev.3
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 +52 -16
- package/dist/chains/index.d.cts +25 -25
- package/dist/chains/index.d.cts.map +1 -1
- package/dist/chains/index.d.ts +25 -25
- package/dist/consts-AUoL-v42.cjs +18 -0
- package/dist/consts-BV4PR-de.js +7 -0
- package/dist/consts-BV4PR-de.js.map +1 -0
- package/dist/{query-CO6f35AE.d.cts → entity-BSU5-vyY.d.cts} +68 -31
- package/dist/entity-BSU5-vyY.d.cts.map +1 -0
- package/dist/{query-BhdmAzYg.d.ts → entity-CHiZ2Qu1.d.ts} +68 -31
- package/dist/entity-CHiZ2Qu1.d.ts.map +1 -0
- package/dist/{queryBuilder-BvoQXa_u.d.ts → index-CzqHiUAo.d.ts} +202 -74
- package/dist/index-CzqHiUAo.d.ts.map +1 -0
- package/dist/{queryBuilder-zTsKXctT.d.cts → index-gj33r3rd.d.cts} +202 -74
- package/dist/index-gj33r3rd.d.cts.map +1 -0
- package/dist/index.cjs +63 -28
- package/dist/index.d.cts +90 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +91 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -21
- package/dist/index.js.map +1 -1
- package/dist/{payload-Da9gJMG5.d.ts → payload-B2kFJyah.d.ts} +1 -1
- package/dist/{payload-Da9gJMG5.d.ts.map → payload-B2kFJyah.d.ts.map} +1 -1
- package/dist/payload-Claf2jUO.js +13 -0
- package/dist/payload-Claf2jUO.js.map +1 -0
- package/dist/{payload-vwU3Rc6P.cjs → payload-DpA5PA-w.cjs} +0 -17
- package/dist/query/index.cjs +6 -2
- package/dist/query/index.d.cts +3 -3
- package/dist/query/index.d.ts +3 -3
- package/dist/query/index.js +3 -2
- package/dist/query/index.js.map +1 -1
- package/dist/{queryBuilder-DM-YO1Y7.cjs → queryBuilder-CTPwve9u.cjs} +229 -70
- package/dist/{queryBuilder-DonAg1aq.js → queryBuilder-D-ACo-g_.js} +201 -72
- package/dist/queryBuilder-D-ACo-g_.js.map +1 -0
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.cjs +4 -10
- package/dist/utils/index.d.cts +0 -1
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -3
- package/dist/utils/index.js.map +1 -1
- package/package.json +11 -15
- package/src/actions/public/buildQuery.ts +4 -0
- package/src/actions/wallet/createEntity.ts +12 -2
- package/src/actions/wallet/extendEntity.ts +6 -1
- package/src/actions/wallet/updateEntity.ts +12 -2
- package/src/clients/createPublicClient.test.ts +2 -0
- package/src/clients/decorators/arkivPublic.ts +67 -1
- package/src/clients/decorators/arkivWallet.ts +18 -0
- package/src/errors.ts +18 -0
- package/src/index.ts +0 -3
- package/src/query/engine.ts +22 -13
- package/src/query/index.ts +1 -0
- package/src/query/queryBuilder.ts +189 -94
- package/src/query/queryResult.ts +13 -7
- package/src/query/selectQueryBuilder.test.ts +210 -0
- package/src/query/selection.test.ts +120 -0
- package/src/query/selection.ts +116 -0
- package/src/types/attributes.ts +12 -0
- package/src/utils/arkivTransactions.test.ts +62 -0
- package/src/utils/arkivTransactions.ts +36 -27
- package/src/utils/index.ts +0 -1
- package/src/utils/validation.test.ts +60 -0
- package/src/utils/validation.ts +32 -0
- package/dist/accounts/index.cjs +0 -9
- package/dist/accounts/index.d.cts +0 -1
- package/dist/accounts/index.d.ts +0 -1
- package/dist/accounts/index.js +0 -1
- package/dist/payload-DKBYYjeA.js +0 -18
- package/dist/payload-DKBYYjeA.js.map +0 -1
- package/dist/query-BhdmAzYg.d.ts.map +0 -1
- package/dist/query-CO6f35AE.d.cts.map +0 -1
- package/dist/queryBuilder-BvoQXa_u.d.ts.map +0 -1
- package/dist/queryBuilder-DonAg1aq.js.map +0 -1
- package/dist/queryBuilder-zTsKXctT.d.cts.map +0 -1
- package/src/accounts/index.ts +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { A as RpcIncludeData, C as
|
|
2
|
-
import {
|
|
1
|
+
import { A as RpcIncludeData, C as QueryOptionsIncludeData, D as ArkivClient, E as GetBlockTimingReturnType, M as RpcQueryOptions, N as MimeType, O as ArkivRpcSchema, S as QueryOptions, T as QueryReturnType, _ as DeleteEntityReturnType, a as OnEntityExpiredEvent, b as ChangeOwnershipParameters, c as OnEntityUpdatedEvent, d as MutateEntitiesReturnType, f as UpdateEntityParameters, g as DeleteEntityParameters, h as ExtendEntityReturnType, i as OnEntityDeletedEvent, j as RpcOrderByAttribute, k as RpcEntity, l as Attribute, m as ExtendEntityParameters, n as TxParams, o as OnEntityExpiresInExtendedEvent, p as UpdateEntityReturnType, r as OnEntityCreatedEvent, s as OnEntityOwnerChangedEvent, t as Entity, u as MutateEntitiesParameters, v as CreateEntityParameters, w as QueryOptionsOrderBy, x as ChangeOwnershipReturnType, y as CreateEntityReturnType } from "./entity-BSU5-vyY.cjs";
|
|
2
|
+
import { c as FullEntity, i as SelectQueryBuilder, l as ProjectedEntity, r as QueryBuilder, s as EntitySelection, u as SelectArg } from "./index-gj33r3rd.cjs";
|
|
3
3
|
import { n as stringToPayload, t as jsonToPayload } from "./payload-CJN8fTvX.cjs";
|
|
4
4
|
import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
|
|
5
|
-
export * from "viem";
|
|
6
5
|
|
|
7
6
|
//#region src/clients/decorators/arkivPublic.d.ts
|
|
8
7
|
type PublicArkivActions<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = Pick<PublicActions<transport, chain, account>, "getBalance" | "getBlock" | "getBlockNumber" | "getChainId" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "waitForTransactionReceipt" | "watchEvent"> & {
|
|
@@ -29,12 +28,75 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
29
28
|
* // }
|
|
30
29
|
*/
|
|
31
30
|
getEntity: (key: Hex) => Promise<Entity>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a SelectQueryBuilder for building and executing queries — the recommended way to
|
|
33
|
+
* read entities. You declare up front which parts of an entity you want returned, so results
|
|
34
|
+
* always contain exactly the data you asked for.
|
|
35
|
+
*
|
|
36
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
|
|
37
|
+
*
|
|
38
|
+
* @param selection - What to include in the results. Omit it (or pass `"*"`) to select everything,
|
|
39
|
+
* or pass an object to select specific parts (at least one field is required). Every part is
|
|
40
|
+
* opt-in, including the `key`. The selection is flat — each field maps to an entity field.
|
|
41
|
+
* {@link SelectArg}
|
|
42
|
+
* @returns A SelectQueryBuilder instance for building and executing queries. {@link SelectQueryBuilder}
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
46
|
+
* import { braga } from 'arkiv/chains'
|
|
47
|
+
* import { eq } from 'arkiv/query'
|
|
48
|
+
*
|
|
49
|
+
* const client = createPublicClient({
|
|
50
|
+
* chain: braga,
|
|
51
|
+
* transport: http(),
|
|
52
|
+
* })
|
|
53
|
+
* // select everything
|
|
54
|
+
* await client.select().where(eq("category", "docs")).fetch()
|
|
55
|
+
* await client.select("*").where(eq("category", "docs")).fetch()
|
|
56
|
+
* // only the key
|
|
57
|
+
* await client.select({ key: true }).where(eq("category", "docs")).fetch()
|
|
58
|
+
* // select specific fields — result typed { owner: Hex; attributes: Attribute[] }
|
|
59
|
+
* await client.select({ owner: true, attributes: true }).fetch()
|
|
60
|
+
* // a single field — result typed { owner: Hex }
|
|
61
|
+
* await client.select({ owner: true }).fetch()
|
|
62
|
+
*/
|
|
63
|
+
select: {
|
|
64
|
+
/** Select every field. Pass nothing or `"*"`; the returned entities contain all fields. */
|
|
65
|
+
(selection?: "*"): SelectQueryBuilder<FullEntity>;
|
|
66
|
+
/**
|
|
67
|
+
* Pick the entity fields to return. Set the ones you want to `true` (at least one is required);
|
|
68
|
+
* the result is typed to exactly those fields, so reading anything else is a compile error.
|
|
69
|
+
*
|
|
70
|
+
* Available fields: `key`, `owner`, `creator`, `contentType`, `payload`, `attributes`,
|
|
71
|
+
* `expiresAtBlock`, `createdAtBlock`, `lastModifiedAtBlock`, `transactionIndexInBlock`,
|
|
72
|
+
* `operationIndexInTransaction`.
|
|
73
|
+
*
|
|
74
|
+
* Pass the selection inline so its fields stay literal `true`. A selection stored in a `let`/
|
|
75
|
+
* `const` variable widens to `boolean` and the result type can no longer be narrowed — annotate
|
|
76
|
+
* it `as const` (e.g. `const sel = { owner: true } as const`) in that case.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* client.select({ owner: true, attributes: true }) // entities typed { owner, attributes }
|
|
80
|
+
* client.select({ key: true, payload: true }) // includes payload → toText()/toJson() too
|
|
81
|
+
*/
|
|
82
|
+
<const S extends EntitySelection>(selection: S): SelectQueryBuilder<ProjectedEntity<S>>;
|
|
83
|
+
/**
|
|
84
|
+
* Dynamic selection: accepts a value typed {@link SelectArg} (e.g. built at runtime). The
|
|
85
|
+
* result cannot be narrowed in this case, so the entities are typed as the full entity.
|
|
86
|
+
*/
|
|
87
|
+
(selection: SelectArg): SelectQueryBuilder<FullEntity>;
|
|
88
|
+
};
|
|
32
89
|
/**
|
|
33
90
|
* Returns a QueryBuilder instance for building and executing queries.
|
|
34
91
|
* The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.
|
|
35
92
|
*
|
|
36
93
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
|
|
37
94
|
*
|
|
95
|
+
* @deprecated Use {@link select} instead. `buildQuery()` returns only the entity `key` unless
|
|
96
|
+
* you remember to opt in to data with `withAttributes()`/`withMetadata()`/`withPayload()`, which
|
|
97
|
+
* is an easy mistake. `select()` makes the selection explicit. This method remains for backwards
|
|
98
|
+
* compatibility and will be removed in a future release.
|
|
99
|
+
*
|
|
38
100
|
* @returns A QueryBuilder instance for building and executing queries. {@link QueryBuilder}
|
|
39
101
|
*
|
|
40
102
|
* @example
|
|
@@ -192,6 +254,11 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
192
254
|
* @param txParams - Optional transaction parameters
|
|
193
255
|
* @returns The created entity with transaction hash
|
|
194
256
|
*
|
|
257
|
+
* @throws {InvalidExpirationError} If `expiresIn` is not a positive integer
|
|
258
|
+
* that is a multiple of the block time (2 seconds).
|
|
259
|
+
* @throws {InvalidAttributeError} If a numeric attribute value is not an
|
|
260
|
+
* integer.
|
|
261
|
+
*
|
|
195
262
|
* @example
|
|
196
263
|
* import { createPublicClient, http } from 'arkiv'
|
|
197
264
|
* import { braga } from 'arkiv/chains'
|
|
@@ -223,6 +290,11 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
223
290
|
* @param txParams - Optional transaction parameters
|
|
224
291
|
* @returns The updated entity with transaction hash
|
|
225
292
|
*
|
|
293
|
+
* @throws {InvalidExpirationError} If `expiresIn` is not a positive integer
|
|
294
|
+
* that is a multiple of the block time (2 seconds).
|
|
295
|
+
* @throws {InvalidAttributeError} If a numeric attribute value is not an
|
|
296
|
+
* integer.
|
|
297
|
+
*
|
|
226
298
|
* @example
|
|
227
299
|
* import { createWalletClient, http } from 'arkiv'
|
|
228
300
|
* import { braga } from 'arkiv/chains'
|
|
@@ -270,6 +342,9 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
270
342
|
* @param txParams - Optional transaction parameters
|
|
271
343
|
* @returns The updated entity with transaction hash
|
|
272
344
|
*
|
|
345
|
+
* @throws {InvalidExpirationError} If `expiresIn` is not a positive integer
|
|
346
|
+
* that is a multiple of the block time (2 seconds).
|
|
347
|
+
*
|
|
273
348
|
* @example
|
|
274
349
|
* import { createWalletClient, http } from 'arkiv'
|
|
275
350
|
* import { braga } from 'arkiv/chains'
|
|
@@ -310,6 +385,11 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
310
385
|
* @param txParams - Optional transaction parameters
|
|
311
386
|
* @returns The mutation result with transaction hash
|
|
312
387
|
*
|
|
388
|
+
* @throws {InvalidExpirationError} If any create/update/extension `expiresIn`
|
|
389
|
+
* is not a positive integer that is a multiple of the block time (2 seconds).
|
|
390
|
+
* @throws {InvalidAttributeError} If a numeric attribute value is not an
|
|
391
|
+
* integer.
|
|
392
|
+
*
|
|
313
393
|
* @example
|
|
314
394
|
* import { createWalletClient, http } from 'arkiv'
|
|
315
395
|
* import { braga } from 'arkiv/chains'
|
|
@@ -375,6 +455,12 @@ declare function createWalletClient<transport extends Transport, chain extends C
|
|
|
375
455
|
declare class EntityMutationError extends Error {
|
|
376
456
|
constructor(message: string);
|
|
377
457
|
}
|
|
458
|
+
declare class InvalidExpirationError extends Error {
|
|
459
|
+
constructor(expiresIn: unknown);
|
|
460
|
+
}
|
|
461
|
+
declare class InvalidAttributeError extends Error {
|
|
462
|
+
constructor(key: string, value: number);
|
|
463
|
+
}
|
|
378
464
|
declare class NoMoreResultsError extends Error {
|
|
379
465
|
constructor();
|
|
380
466
|
}
|
|
@@ -394,5 +480,5 @@ declare class NoEntityFoundError extends Error {
|
|
|
394
480
|
*/
|
|
395
481
|
declare function chainFromName(name: string): Chain;
|
|
396
482
|
//#endregion
|
|
397
|
-
export { type ArkivClient, ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityMutationError, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, NoCursorOrLimitError, NoEntityFoundError, NoMoreResultsError, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, type PublicArkivActions, type PublicArkivClient, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType, type WalletArkivActions, type WalletArkivClient, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
|
483
|
+
export { type ArkivClient, ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityMutationError, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, InvalidAttributeError, InvalidExpirationError, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, NoCursorOrLimitError, NoEntityFoundError, NoMoreResultsError, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, type PublicArkivActions, type PublicArkivClient, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType, type WalletArkivActions, type WalletArkivClient, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
|
398
484
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/clients/decorators/arkivPublic.ts","../src/clients/createPublicClient.ts","../src/clients/decorators/arkivWallet.ts","../src/clients/createWalletClient.ts","../src/errors.ts","../src/utils/chains.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/clients/decorators/arkivPublic.ts","../src/clients/createPublicClient.ts","../src/clients/decor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SACF,OAAO,WAAW,OAAO,SAAS,WAAW,mBAAmB,WAAW,OAAO;;;AHJpF;;;;;;;;;;;;;;;;;AA4FqB,iBGlEL,kBHkEK,CAAA,kBGjED,SHiEC,EAAA,cGhEL,KHgEK,GAAA,SAAA,GAAA,SAAA,EAAA,yBG/DM,OH+DN,GG/DgB,OH+DhB,GAAA,SAAA,GAAA,SAAA,EAAA,kBG9DD,SH8DC,GAAA,SAAA,GG9DuB,cH8DvB,CAAA,CAAA,UAAA,EG5DP,kBH4DO,CG5DY,SH4DZ,EG5DuB,KH4DvB,EG5D8B,gBH4D9B,EG5DgD,SH4DhD,CAAA,CAAA,EG3DlB,iBH2DkB,CG3DA,SH2DA,EG3DW,KH2DX,EG3DkB,YH2DlB,CG3D+B,gBH2D/B,CAAA,EG3DkD,SH2DlD,CAAA;;;cI3GR,mBAAA,SAA4B,KAAA;;;cAM5B,sBAAA,SAA+B,KAAA;;;AJShC,cIDC,qBAAA,SAA8B,KAAA,CJCb;EACV,WAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA;;AACJ,cIMH,kBAAA,SAA2B,KAAA,CJNxB;EAAoB,WAAA,CAAA;;AACI,cIY3B,oBAAA,SAA6B,KAAA,CJZF;EAExB,WAAA,CAAA;;AAAkB,cIiBrB,kBAAA,SAA2B,KAAA,CJjBN;EAAhC,WAAA,CAAA;;;;;;;;;AALF;AACoB,iBKNJ,aAAA,CLMI,IAAA,EAAA,MAAA,CAAA,EKNyB,KLMzB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { A as RpcIncludeData, C as
|
|
2
|
-
import {
|
|
3
|
-
import { n as stringToPayload, t as jsonToPayload } from "./payload-
|
|
1
|
+
import { A as RpcIncludeData, C as QueryOptionsIncludeData, D as ArkivClient, E as GetBlockTimingReturnType, M as RpcQueryOptions, N as MimeType, O as ArkivRpcSchema, S as QueryOptions, T as QueryReturnType, _ as DeleteEntityReturnType, a as OnEntityExpiredEvent, b as ChangeOwnershipParameters, c as OnEntityUpdatedEvent, d as MutateEntitiesReturnType, f as UpdateEntityParameters, g as DeleteEntityParameters, h as ExtendEntityReturnType, i as OnEntityDeletedEvent, j as RpcOrderByAttribute, k as RpcEntity, l as Attribute, m as ExtendEntityParameters, n as TxParams, o as OnEntityExpiresInExtendedEvent, p as UpdateEntityReturnType, r as OnEntityCreatedEvent, s as OnEntityOwnerChangedEvent, t as Entity, u as MutateEntitiesParameters, v as CreateEntityParameters, w as QueryOptionsOrderBy, x as ChangeOwnershipReturnType, y as CreateEntityReturnType } from "./entity-CHiZ2Qu1.js";
|
|
2
|
+
import { c as FullEntity, i as SelectQueryBuilder, l as ProjectedEntity, r as QueryBuilder, s as EntitySelection, u as SelectArg } from "./index-CzqHiUAo.js";
|
|
3
|
+
import { n as stringToPayload, t as jsonToPayload } from "./payload-B2kFJyah.js";
|
|
4
4
|
import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
|
|
5
|
-
export * from "viem";
|
|
6
5
|
|
|
7
6
|
//#region src/clients/decorators/arkivPublic.d.ts
|
|
8
7
|
type PublicArkivActions<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = Pick<PublicActions<transport, chain, account>, "getBalance" | "getBlock" | "getBlockNumber" | "getChainId" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "waitForTransactionReceipt" | "watchEvent"> & {
|
|
@@ -29,12 +28,75 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
29
28
|
* // }
|
|
30
29
|
*/
|
|
31
30
|
getEntity: (key: Hex) => Promise<Entity>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a SelectQueryBuilder for building and executing queries — the recommended way to
|
|
33
|
+
* read entities. You declare up front which parts of an entity you want returned, so results
|
|
34
|
+
* always contain exactly the data you asked for.
|
|
35
|
+
*
|
|
36
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
|
|
37
|
+
*
|
|
38
|
+
* @param selection - What to include in the results. Omit it (or pass `"*"`) to select everything,
|
|
39
|
+
* or pass an object to select specific parts (at least one field is required). Every part is
|
|
40
|
+
* opt-in, including the `key`. The selection is flat — each field maps to an entity field.
|
|
41
|
+
* {@link SelectArg}
|
|
42
|
+
* @returns A SelectQueryBuilder instance for building and executing queries. {@link SelectQueryBuilder}
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
46
|
+
* import { braga } from 'arkiv/chains'
|
|
47
|
+
* import { eq } from 'arkiv/query'
|
|
48
|
+
*
|
|
49
|
+
* const client = createPublicClient({
|
|
50
|
+
* chain: braga,
|
|
51
|
+
* transport: http(),
|
|
52
|
+
* })
|
|
53
|
+
* // select everything
|
|
54
|
+
* await client.select().where(eq("category", "docs")).fetch()
|
|
55
|
+
* await client.select("*").where(eq("category", "docs")).fetch()
|
|
56
|
+
* // only the key
|
|
57
|
+
* await client.select({ key: true }).where(eq("category", "docs")).fetch()
|
|
58
|
+
* // select specific fields — result typed { owner: Hex; attributes: Attribute[] }
|
|
59
|
+
* await client.select({ owner: true, attributes: true }).fetch()
|
|
60
|
+
* // a single field — result typed { owner: Hex }
|
|
61
|
+
* await client.select({ owner: true }).fetch()
|
|
62
|
+
*/
|
|
63
|
+
select: {
|
|
64
|
+
/** Select every field. Pass nothing or `"*"`; the returned entities contain all fields. */
|
|
65
|
+
(selection?: "*"): SelectQueryBuilder<FullEntity>;
|
|
66
|
+
/**
|
|
67
|
+
* Pick the entity fields to return. Set the ones you want to `true` (at least one is required);
|
|
68
|
+
* the result is typed to exactly those fields, so reading anything else is a compile error.
|
|
69
|
+
*
|
|
70
|
+
* Available fields: `key`, `owner`, `creator`, `contentType`, `payload`, `attributes`,
|
|
71
|
+
* `expiresAtBlock`, `createdAtBlock`, `lastModifiedAtBlock`, `transactionIndexInBlock`,
|
|
72
|
+
* `operationIndexInTransaction`.
|
|
73
|
+
*
|
|
74
|
+
* Pass the selection inline so its fields stay literal `true`. A selection stored in a `let`/
|
|
75
|
+
* `const` variable widens to `boolean` and the result type can no longer be narrowed — annotate
|
|
76
|
+
* it `as const` (e.g. `const sel = { owner: true } as const`) in that case.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* client.select({ owner: true, attributes: true }) // entities typed { owner, attributes }
|
|
80
|
+
* client.select({ key: true, payload: true }) // includes payload → toText()/toJson() too
|
|
81
|
+
*/
|
|
82
|
+
<const S extends EntitySelection>(selection: S): SelectQueryBuilder<ProjectedEntity<S>>;
|
|
83
|
+
/**
|
|
84
|
+
* Dynamic selection: accepts a value typed {@link SelectArg} (e.g. built at runtime). The
|
|
85
|
+
* result cannot be narrowed in this case, so the entities are typed as the full entity.
|
|
86
|
+
*/
|
|
87
|
+
(selection: SelectArg): SelectQueryBuilder<FullEntity>;
|
|
88
|
+
};
|
|
32
89
|
/**
|
|
33
90
|
* Returns a QueryBuilder instance for building and executing queries.
|
|
34
91
|
* The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.
|
|
35
92
|
*
|
|
36
93
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
|
|
37
94
|
*
|
|
95
|
+
* @deprecated Use {@link select} instead. `buildQuery()` returns only the entity `key` unless
|
|
96
|
+
* you remember to opt in to data with `withAttributes()`/`withMetadata()`/`withPayload()`, which
|
|
97
|
+
* is an easy mistake. `select()` makes the selection explicit. This method remains for backwards
|
|
98
|
+
* compatibility and will be removed in a future release.
|
|
99
|
+
*
|
|
38
100
|
* @returns A QueryBuilder instance for building and executing queries. {@link QueryBuilder}
|
|
39
101
|
*
|
|
40
102
|
* @example
|
|
@@ -192,6 +254,11 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
192
254
|
* @param txParams - Optional transaction parameters
|
|
193
255
|
* @returns The created entity with transaction hash
|
|
194
256
|
*
|
|
257
|
+
* @throws {InvalidExpirationError} If `expiresIn` is not a positive integer
|
|
258
|
+
* that is a multiple of the block time (2 seconds).
|
|
259
|
+
* @throws {InvalidAttributeError} If a numeric attribute value is not an
|
|
260
|
+
* integer.
|
|
261
|
+
*
|
|
195
262
|
* @example
|
|
196
263
|
* import { createPublicClient, http } from 'arkiv'
|
|
197
264
|
* import { braga } from 'arkiv/chains'
|
|
@@ -223,6 +290,11 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
223
290
|
* @param txParams - Optional transaction parameters
|
|
224
291
|
* @returns The updated entity with transaction hash
|
|
225
292
|
*
|
|
293
|
+
* @throws {InvalidExpirationError} If `expiresIn` is not a positive integer
|
|
294
|
+
* that is a multiple of the block time (2 seconds).
|
|
295
|
+
* @throws {InvalidAttributeError} If a numeric attribute value is not an
|
|
296
|
+
* integer.
|
|
297
|
+
*
|
|
226
298
|
* @example
|
|
227
299
|
* import { createWalletClient, http } from 'arkiv'
|
|
228
300
|
* import { braga } from 'arkiv/chains'
|
|
@@ -270,6 +342,9 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
270
342
|
* @param txParams - Optional transaction parameters
|
|
271
343
|
* @returns The updated entity with transaction hash
|
|
272
344
|
*
|
|
345
|
+
* @throws {InvalidExpirationError} If `expiresIn` is not a positive integer
|
|
346
|
+
* that is a multiple of the block time (2 seconds).
|
|
347
|
+
*
|
|
273
348
|
* @example
|
|
274
349
|
* import { createWalletClient, http } from 'arkiv'
|
|
275
350
|
* import { braga } from 'arkiv/chains'
|
|
@@ -310,6 +385,11 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
310
385
|
* @param txParams - Optional transaction parameters
|
|
311
386
|
* @returns The mutation result with transaction hash
|
|
312
387
|
*
|
|
388
|
+
* @throws {InvalidExpirationError} If any create/update/extension `expiresIn`
|
|
389
|
+
* is not a positive integer that is a multiple of the block time (2 seconds).
|
|
390
|
+
* @throws {InvalidAttributeError} If a numeric attribute value is not an
|
|
391
|
+
* integer.
|
|
392
|
+
*
|
|
313
393
|
* @example
|
|
314
394
|
* import { createWalletClient, http } from 'arkiv'
|
|
315
395
|
* import { braga } from 'arkiv/chains'
|
|
@@ -375,6 +455,12 @@ declare function createWalletClient<transport extends Transport, chain extends C
|
|
|
375
455
|
declare class EntityMutationError extends Error {
|
|
376
456
|
constructor(message: string);
|
|
377
457
|
}
|
|
458
|
+
declare class InvalidExpirationError extends Error {
|
|
459
|
+
constructor(expiresIn: unknown);
|
|
460
|
+
}
|
|
461
|
+
declare class InvalidAttributeError extends Error {
|
|
462
|
+
constructor(key: string, value: number);
|
|
463
|
+
}
|
|
378
464
|
declare class NoMoreResultsError extends Error {
|
|
379
465
|
constructor();
|
|
380
466
|
}
|
|
@@ -394,5 +480,5 @@ declare class NoEntityFoundError extends Error {
|
|
|
394
480
|
*/
|
|
395
481
|
declare function chainFromName(name: string): Chain;
|
|
396
482
|
//#endregion
|
|
397
|
-
export { type ArkivClient, ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityMutationError, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, NoCursorOrLimitError, NoEntityFoundError, NoMoreResultsError, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, type PublicArkivActions, type PublicArkivClient, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType, type WalletArkivActions, type WalletArkivClient, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
|
483
|
+
export { type ArkivClient, ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityMutationError, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, InvalidAttributeError, InvalidExpirationError, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, NoCursorOrLimitError, NoEntityFoundError, NoMoreResultsError, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, type PublicArkivActions, type PublicArkivClient, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType, type WalletArkivActions, type WalletArkivClient, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
|
398
484
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/clients/decorators/arkivPublic.ts","../src/clients/createPublicClient.ts","../src/clients/decorators/arkivWallet.ts","../src/clients/createWalletClient.ts","../src/errors.ts","../src/utils/chains.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/clients/decorators/arkivPublic.ts","../src/clients/createPublicClient.ts","../src/clients/decorators/arkivWallet.ts","../src/clients/createWalletClient.ts","../src/errors.ts","../src/utils/chains.ts"],"sourcesContent":[],"mappings":";;;;;;AAiBY,KAAA,kBAAkB,CAAA,kBACV,SADU,GACE,SADF,EAAA,cAEd,KAFc,GAAA,SAAA,GAEM,KAFN,GAAA,SAAA,EAAA,gBAGZ,OAHY,GAAA,SAAA,GAGU,OAHV,GAAA,SAAA,CAAA,GAI1B,IAJ0B,CAK5B,aAL4B,CAKd,SALc,EAKH,KALG,EAKI,OALJ,C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H4DO,CG5DY,SH4DZ,EG5DuB,KH4DvB,EG5D8B,gBH4D9B,EG5DgD,SH4DhD,CAAA,CAAA,EG3DlB,iBH2DkB,CG3DA,SH2DA,EG3DW,KH2DX,EG3DkB,YH2DlB,CG3D+B,gBH2D/B,CAAA,EG3DkD,SH2DlD,CAAA;;;cI3GR,mBAAA,SAA4B,KAAA;;;cAM5B,sBAAA,SAA+B,KAAA;;;AJShC,cIDC,qBAAA,SAA8B,KAAA,CJCb;EACV,WAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,MAAA;;AACJ,cIMH,kBAAA,SAA2B,KAAA,CJNxB;EAAoB,WAAA,CAAA;;AACI,cIY3B,oBAAA,SAA6B,KAAA,CJZF;EAExB,WAAA,CAAA;;AAAkB,cIiBrB,kBAAA,SAA2B,KAAA,CJjBN;EAAhC,WAAA,CAAA;;;;;;;;;AALF;AACoB,iBKNJ,aAAA,CLMI,IAAA,EAAA,MAAA,CAAA,EKNyB,KLMzB"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { t as chains_exports } from "./chains-CrtkVbBh.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { c as entityFromRpcResult, d as InvalidExpirationError, f as NoCursorOrLimitError, h as getLogger, l as EntityMutationError, m as NoMoreResultsError, n as QueryBuilder, p as NoEntityFoundError, r as SelectQueryBuilder, u as InvalidAttributeError } from "./queryBuilder-D-ACo-g_.js";
|
|
3
|
+
import { n as BLOCK_TIME, t as ARKIV_ADDRESS } from "./consts-BV4PR-de.js";
|
|
4
4
|
import "./types-H-TSmRpm.js";
|
|
5
|
+
import { n as stringToPayload, t as jsonToPayload } from "./payload-Claf2jUO.js";
|
|
5
6
|
import { TransactionExecutionError, bytesToHex, createClient, decodeEventLog, hexToBytes, hexToString, numberToHex, parseAbi, publicActions, toBytes, toHex, toRlp, walletActions } from "viem";
|
|
6
7
|
|
|
7
|
-
export * from "viem"
|
|
8
|
-
|
|
9
8
|
//#region src/actions/public/getBlockTiming.ts
|
|
10
9
|
const logger$9 = getLogger("actions:public:get-block-timing");
|
|
11
10
|
async function getBlockTiming(client) {
|
|
@@ -189,6 +188,7 @@ function publicArkivActions(client) {
|
|
|
189
188
|
getEntity: (key) => getEntity(client, key),
|
|
190
189
|
query: (rawQuery, queryOptions) => query(client, rawQuery, queryOptions),
|
|
191
190
|
buildQuery: () => new QueryBuilder(client),
|
|
191
|
+
select: (selection) => new SelectQueryBuilder(client, selection),
|
|
192
192
|
getBlockTiming: () => getBlockTiming(client),
|
|
193
193
|
getEntityCount: () => getEntityCount(client),
|
|
194
194
|
subscribeEntityEvents: ({ onError, onEntityCreated, onEntityUpdated, onEntityDeleted, onEntityExpired, onEntityExpiresInExtended }, pollingInterval, fromBlock) => subscribeEntityEvents(client, {
|
|
@@ -283,6 +283,32 @@ async function compress(data) {
|
|
|
283
283
|
return brotliCompressed;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/utils/validation.ts
|
|
288
|
+
/**
|
|
289
|
+
* Expiration on Arkiv is measured in blocks (1 block =
|
|
290
|
+
* 2 seconds), so the value must be a positive integer that is
|
|
291
|
+
* a multiple of the block time.
|
|
292
|
+
*
|
|
293
|
+
* @param expiresIn - The expiration in seconds.
|
|
294
|
+
* @throws {InvalidExpirationError} If the value is not a positive integer that
|
|
295
|
+
* is a multiple of the block time.
|
|
296
|
+
*/
|
|
297
|
+
function validateExpiresIn(expiresIn) {
|
|
298
|
+
if (!Number.isInteger(expiresIn) || expiresIn <= 0 || expiresIn % BLOCK_TIME !== 0) throw new InvalidExpirationError(expiresIn);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Validates a single attribute. Arkiv supports string and number attribute
|
|
302
|
+
* values, but numeric values must be integers.
|
|
303
|
+
*
|
|
304
|
+
* @param attribute - The attribute to validate.
|
|
305
|
+
* @throws {InvalidAttributeError} If the attribute has a non-integer numeric
|
|
306
|
+
* value.
|
|
307
|
+
*/
|
|
308
|
+
function validateAttribute(attribute) {
|
|
309
|
+
if (typeof attribute.value === "number" && !Number.isInteger(attribute.value)) throw new InvalidAttributeError(attribute.key, attribute.value);
|
|
310
|
+
}
|
|
311
|
+
|
|
286
312
|
//#endregion
|
|
287
313
|
//#region src/utils/arkivTransactions.ts
|
|
288
314
|
const logger$6 = getLogger("utils:arkiv-transactions");
|
|
@@ -291,23 +317,34 @@ function opsToTxData({ creates, updates, deletes, extensions, ownershipChanges }
|
|
|
291
317
|
return [toHex(attribute.key), toHex(typeof attribute.value === "number" && attribute.value === 0 ? "" : attribute.value)];
|
|
292
318
|
}
|
|
293
319
|
const payload = [
|
|
294
|
-
(creates ?? []).map((item) =>
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
item.
|
|
307
|
-
item.attributes.
|
|
308
|
-
|
|
320
|
+
(creates ?? []).map((item) => {
|
|
321
|
+
validateExpiresIn(item.expiresIn);
|
|
322
|
+
item.attributes.forEach(validateAttribute);
|
|
323
|
+
return [
|
|
324
|
+
toHex(item.expiresIn / BLOCK_TIME),
|
|
325
|
+
toHex(item.contentType),
|
|
326
|
+
toHex(item.payload),
|
|
327
|
+
item.attributes.filter((attribute) => typeof attribute.value === "string").map(formatAttributes),
|
|
328
|
+
item.attributes.filter((attribute) => typeof attribute.value === "number").map(formatAttributes)
|
|
329
|
+
];
|
|
330
|
+
}),
|
|
331
|
+
(updates ?? []).map((item) => {
|
|
332
|
+
validateExpiresIn(item.expiresIn);
|
|
333
|
+
item.attributes.forEach(validateAttribute);
|
|
334
|
+
return [
|
|
335
|
+
item.entityKey,
|
|
336
|
+
toHex(item.contentType),
|
|
337
|
+
toHex(item.expiresIn / BLOCK_TIME),
|
|
338
|
+
toHex(item.payload),
|
|
339
|
+
item.attributes.filter((attribute) => typeof attribute.value === "string").map(formatAttributes),
|
|
340
|
+
item.attributes.filter((attribute) => typeof attribute.value === "number").map(formatAttributes)
|
|
341
|
+
];
|
|
342
|
+
}),
|
|
309
343
|
(deletes ?? []).map((item) => item.entityKey),
|
|
310
|
-
(extensions ?? []).map((item) =>
|
|
344
|
+
(extensions ?? []).map((item) => {
|
|
345
|
+
validateExpiresIn(item.expiresIn);
|
|
346
|
+
return [item.entityKey, toHex(item.expiresIn / BLOCK_TIME)];
|
|
347
|
+
}),
|
|
311
348
|
(ownershipChanges ?? []).map((item) => [item.entityKey, item.newOwner])
|
|
312
349
|
];
|
|
313
350
|
logger$6("txData to send as RLP %o length %d", payload, payload.length);
|
|
@@ -535,5 +572,5 @@ function chainFromName(name) {
|
|
|
535
572
|
}
|
|
536
573
|
|
|
537
574
|
//#endregion
|
|
538
|
-
export { EntityMutationError, NoCursorOrLimitError, NoEntityFoundError, NoMoreResultsError, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
|
575
|
+
export { EntityMutationError, InvalidAttributeError, InvalidExpirationError, NoCursorOrLimitError, NoEntityFoundError, NoMoreResultsError, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
|
539
576
|
//# sourceMappingURL=index.js.map
|