@arkiv-network/sdk
Version:
TypeScript client library for Arkiv's blockchains interactions
1,231 lines • 58.2 kB
text/typescript
import { c as ResolvedCreationFlags, i as SaltInput, s as CreationFlags } from "./index-DR2PwYJ2.cjs";
import { t as Expiry } from "./expiry-B48I-yTA.cjs";
import { C as IndexedColumnName, E as PatchEntityValues, O as Schema, R as TagOf, S as CreateEntityValues, T as OptionalColumnName, _ as Attributes, at as ArkivValue, dt as IndexableTypeTag, et as AnyColumn, ft as IndexableValue, g as AttributeSchema, ht as TypeTag, mt as StrValue, vt as ValueOf, x as ColumnsOf } from "./index-DfPlTdS7.cjs";
import { Account, Address, Chain, Client, Hash, Hex, RpcSchema, Transport } from "viem";
//#region src/types/rpcSchema.d.ts
/**
* An attribute as the node renders it: the name, the type **tag** (not the wire typeId), and the
* value in the JSON encoding that type prescribes — a JSON number for `i32`, a `0x` QUANTITY for
* `u64` and `u256`, a decimal string for `dec`, `0x` DATA for the byte-shaped types (`bytes`
* included), and a string for `str`.
*
* The encoding follows the *declared type*, never the magnitude, so a decoder dispatches on `type`
* and never has to guess from the shape of the value.
*/
type RpcAttribute = {
name: string;
type: string;
value: unknown;
};
/**
* An entry of the `attributeSchema` projection — a name, its type, and whether the node indexes
* it, with no value.
*/
type RpcAttributeSchemaEntry = {
name: string;
type: string;
indexed?: boolean;
};
/**
* The `creationFlags` projection.
*/
type RpcCreationFlags = {
readonly?: boolean;
permissionlessExtension?: boolean;
raw: number;
};
/**
* An entity as `arkiv_query` returns it. Every field is present only if it was selected, so all of
* them are optional here — {@link RpcSelect} is what decides which arrive.
*/
type RpcEntity = {
key?: Hex;
owner?: Hex;
creator?: Hex;
createdAt?: Hex;
updatedAt?: Hex;
expiresAt?: Hex;
creationFlags?: RpcCreationFlags | number;
attributeSchema?: RpcAttributeSchemaEntry[];
attributes?: RpcAttribute[];
};
/**
* The `select` projection: flat, per-field booleans. Everything except `key` defaults to **off**,
* so a query asks for exactly what it needs and nothing more.
*
* `attributes` is the one field with a third form: `true` for every attribute, or a map of names
* for a subset.
*/
type RpcSelect = {
key?: boolean;
owner?: boolean;
creator?: boolean;
createdAt?: boolean;
updatedAt?: boolean;
expiresAt?: boolean;
creationFlags?: boolean;
attributeSchema?: boolean;
attributes?: boolean | Record<string, boolean>;
/**
* Not a field of each entity but of the page: the number of entities the query matches at the
* block, regardless of `limit` and `offset`, returned as the response's `count`.
*/
count?: boolean;
};
/** The second parameter of `arkiv_query` — what to return, and where in the results to start. */
type RpcQueryOptions = {
/** What to return. Defaults to `{ key: true }`. */
select?: RpcSelect;
/** Page size, as a hex quantity. Node maximum is 100. */
limit?: Hex;
/** How many matches to skip before the page, as a hex quantity. Defaults to none. */
offset?: Hex;
};
type ArkivRpcSchema = [{
Method: "arkiv_query";
Parameters?: [query: string, queryOptions?: RpcQueryOptions];
ReturnType: {
data: RpcEntity[];
blockNumber: Hex;
/** How many entities the query matches, as a hex quantity. Present only when selected. */
count?: Hex;
};
}, {
Method: "arkiv_getEntity";
Parameters: [entityKey: Hex];
/** Every field except `attributeSchema`, or `null` if no live entity has the key. */
ReturnType: RpcEntity | null;
}, {
Method: "arkiv_getBlockTiming";
Parameters?: [];
ReturnType: {
current_block: bigint;
current_block_time: number;
duration: number;
};
}];
//#endregion
//#region src/clients/baseClient.d.ts
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>;
//#endregion
//#region src/actions/public/getBlockTiming.d.ts
type GetBlockTimingReturnType = {
currentBlock: bigint;
currentBlockTime: number;
blockDuration: number;
};
//#endregion
//#region src/actions/public/predictEntityKeys.d.ts
/**
* A key a create will be given, together with the salt that mints it.
*
* The two travel as a pair because neither is any use alone: a create defaults to a *random* salt,
* so the key only comes out as predicted if that same create carries this salt.
*/
type PredictedEntityKey = {
/** The key the create will be given. */
key: Hex;
/**
* The salt the create must carry for its key to come out as {@link PredictedEntityKey.key}.
* Always a plain `uint128` — a requested {@link NO_SALT} comes back as the `0n` it resolves to,
* which a create accepts just the same.
*/
salt: bigint;
};
/** Parameters for `client.predictEntityKeys`. */
type PredictEntityKeysParameters<TCount extends number = number, TSalts extends readonly SaltInput[] | undefined = readonly SaltInput[] | undefined> = {
/** The account that will sign the creates. Its nonce is what the keys are derived from. */
owner: Address;
/**
* How many creates the batch will carry. Ignored when `salts` is given, which already says how
* many there are.
*
* A literal count comes back as a fixed-length tuple, so `count: 2` destructures into two named
* pairs without a cast.
*/
count?: TCount | undefined;
/**
* The salt each create will carry, in batch order. Defaults to `count` fresh random salts —
* either way each key comes back paired with the salt that mints it. Pass {@link NO_SALT} in a
* slot whose create opts out of salting.
*/
salts?: TSalts;
};
/**
* The keys a batch would mint, in batch order, each paired with its salt.
*
* The length follows the request whenever it is known statically: a literal `count`, or a `salts`
* tuple, gives a fixed-length tuple; a count computed at runtime gives a plain array.
*
* `TSalts` is wrapped in a tuple to stop the conditional distributing over it. Left naked, the
* `readonly SaltInput[] | undefined` default would take both branches and union a tuple with an
* array, which widens the length straight back to `number`.
*/
type PredictEntityKeysReturnType<TCount extends number = number, TSalts extends readonly SaltInput[] | undefined = readonly SaltInput[] | undefined> = [TSalts] extends [readonly SaltInput[]] ? { -readonly [Index in keyof TSalts]: PredictedEntityKey } : Repeat<PredictedEntityKey, TCount>;
/**
* A tuple of `TLength` × `T`, or a plain array when the length is only known at runtime.
*
* Written tail-recursively so TypeScript can build the batch sizes anyone would actually send.
*/
type Repeat<T$1, TLength extends number, TAcc extends T$1[] = []> = number extends TLength ? T$1[] : TAcc["length"] extends TLength ? TAcc : Repeat<T$1, TLength, [...TAcc, T$1]>;
/**
* Works out the keys an account's next creates will be given, before sending them.
*
* A key is `keccak256(chainId ++ registry ++ owner ++ nonce ++ salt)`. Everything but the nonce is
* known to the caller, and the nonce is read here — so a batch can reference a key it is about to
* mint, storing it as a `key` attribute on a sibling entity created in the same transaction.
*
* Each key arrives paired with its salt, and the create must be given that salt: a create left to
* pick its own salt picks a random one, which mints a different key.
*
* The prediction is valid only while nothing else from this owner is in flight. Every create that
* lands first takes the nonce with it and moves these keys. For a key you can rely on
* unconditionally, read it back from the create instead — `createEntity` and `executeBatch`
* report the keys the engine actually minted.
*
* @param parameters - Owner, and either a count or the salts. {@link PredictEntityKeysParameters}
* @returns One `{ key, salt }` pair per create, in batch order. {@link PredictEntityKeysReturnType}
*
* @example A batch whose second entity points at its first.
* import { defineSchema, key, str } from "@arkiv-network/sdk/schema"
*
* const Nodes = defineSchema("nodes", { name: str(), parent: key().indexed().optional() })
*
* const [parent, child] = await client.predictEntityKeys({ owner: account.address, count: 2 })
* await wallet.executeBatch({
* creates: [
* { schema: Nodes, values: { name: "root" }, expiration, salt: parent.salt },
* {
* schema: Nodes,
* values: { name: "leaf", parent: key(parent.key) },
* expiration,
* salt: child.salt,
* },
* ],
* })
*/
//#endregion
//#region src/query/expression.d.ts
/**
* The comparison operators the query language defines. Every indexable type accepts all of them;
* `<` `<=` `>` `>=` compare in index order — numerically for `i32`, `u64`, `u256` and `dec`,
* `false < true` for `bool`, and by unsigned bytes for `str`, `addr` and `key`.
*/
type ComparisonOperator = "=" | "<" | "<=" | ">" | ">=";
/**
* A value a predicate can compare against: a value of any indexable type, or a bare boolean,
* number, bigint or string. `bytes` is excluded — it is never indexed, so never filterable.
*/
type PredicateValue = IndexableValue | boolean | number | bigint | string;
/**
* `between`'s check that both bounds have one type — `unknown` when they do, and otherwise an
* object whose one property is named after the problem. No value has that property, so the
* compiler reports the sentence as the property it is missing.
*/
type SameTypeCheck<L, H> = [TagOf<L>, TagOf<H>] extends [TagOf<H>, TagOf<L>] ? unknown : { [K in `BETWEEN bounds must have one type, got ${TagOf<L>} and ${TagOf<H>}`]: never };
/**
* The attribute a predicate names, and the type it asserts — `never` when it asserts none, as
* `EXISTS` does. Carried by an {@link Expression} at the type level only, so a query against a
* schema can be checked at compile time: every name must be an indexed column, and every type the
* column's.
*/
type AttributeRef = {
readonly name: string;
readonly type: IndexableTypeTag;
};
declare const refs: unique symbol;
/** The type-level record of the attributes an expression names. Never present at runtime. */
type Refs<R$1 extends AttributeRef> = {
readonly [refs]?: R$1;
};
/** A comparison between an attribute and a typed literal. */
interface ComparisonNode<R$1 extends AttributeRef = AttributeRef> extends Refs<R$1> {
readonly kind: "comparison";
readonly name: string;
readonly operator: ComparisonOperator;
readonly value: IndexableValue;
}
/** An inclusive range test, `name BETWEEN low AND high`. Both bounds have one type. */
interface BetweenNode<R$1 extends AttributeRef = AttributeRef> extends Refs<R$1> {
readonly kind: "between";
readonly name: string;
readonly low: IndexableValue;
readonly high: IndexableValue;
}
/** A `STARTSWITH` prefix test, the language's only pattern operator. */
interface StartsWithNode<R$1 extends AttributeRef = AttributeRef> extends Refs<R$1> {
readonly kind: "startsWith";
readonly name: string;
readonly value: StrValue;
}
/** An `EXISTS(name)` test — true when the attribute is set with any type. */
interface ExistsNode<R$1 extends AttributeRef = AttributeRef> extends Refs<R$1> {
readonly kind: "exists";
readonly name: string;
}
/** A `TYPEOF(name) = tag` test. */
interface TypeOfNode<R$1 extends AttributeRef = AttributeRef> extends Refs<R$1> {
readonly kind: "typeOf";
readonly name: string;
readonly tag: IndexableTypeTag;
}
/** A conjunction. */
interface AndNode<R$1 extends AttributeRef = AttributeRef> extends Refs<R$1> {
readonly kind: "and";
readonly expressions: readonly Expression[];
}
/** A disjunction. */
interface OrNode<R$1 extends AttributeRef = AttributeRef> extends Refs<R$1> {
readonly kind: "or";
readonly expressions: readonly Expression[];
}
/**
* A query expression: an immutable tree built by the combinators below, whose `toString()` is the
* exact query string sent over the wire.
*
* @typeParam R - The attributes the expression names, as {@link AttributeRef}s — inferred by the
* combinators, and checked against the schema by `select(...).from(schema).where(...)`.
*
* @example
* const q = and(gte("level", i32(10)), or(eq("status", str("open")), exists("reviewedBy")))
* String(q) // level >= i32(10) AND (status = str('open') OR EXISTS(reviewedBy))
*/
type Expression<R$1 extends AttributeRef = AttributeRef> = ComparisonNode<R$1> | BetweenNode<R$1> | StartsWithNode<R$1> | ExistsNode<R$1> | TypeOfNode<R$1> | AndNode<R$1> | OrNode<R$1>;
/** The attributes an expression names — the `R` of an {@link Expression}. */
type RefsOf<E> = E extends Refs<infer R> ? Exclude<R, undefined> : never;
/** The reference a comparison against `V` makes to `N`. */
type ValueRef<N$1 extends string, V> = {
readonly name: N$1;
readonly type: TagOf<V> & IndexableTypeTag;
};
/**
* The system attributes a query may filter on, and the type each one carries.
*
* Every other system attribute (`$createdAt`, `$updatedAt`, `$creationFlags`) is returned in
* query results — selected and read back as `createdAt`, `updatedAt` and `creationFlags` — but is
* not indexed, so it cannot appear in a predicate.
*/
declare const QUERYABLE_SYSTEM_ATTRIBUTES: {
readonly $key: "key";
readonly $owner: "addr";
readonly $creator: "addr";
readonly $expiresAt: "u64";
};
type SystemAttributeName = keyof typeof QUERYABLE_SYSTEM_ATTRIBUTES;
/** The references a filter on a system attribute makes — each with its fixed type. */
type SystemAttributeRef = { [N in SystemAttributeName]: {
readonly name: N;
readonly type: (typeof QUERYABLE_SYSTEM_ATTRIBUTES)[N];
} }[SystemAttributeName];
/**
* The references a filter through schema `S` may make: each indexed column with its declared
* type, and the queryable system attributes with theirs. An {@link Expression} naming anything else
* is a compile error in `select(...).from(S).where(...)`.
*/
type SchemaRef<S extends Schema> = { [K in IndexedColumnName<S>]: {
readonly name: K;
readonly type: ColumnsOf<S>[K]["type"] & IndexableTypeTag;
} }[IndexedColumnName<S>] | SystemAttributeRef;
/**
* Attribute equals value — set with this exact type, and holding this value.
*
* Bare booleans, numbers, bigints and strings take the same default types they take when written
* (`number` is an `i32`, `bigint` a `u256`, `string` a `str`); anything else names its type.
*
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system
* attribute, a system attribute is compared against the wrong type, or the value is `bytes`.
*
* @example
* eq("status", str("open")) // status = str('open')
* eq("flagged", true) // flagged = true
* eq("$owner", addr(account)) // $owner = addr(0xd8dA…)
*/
declare function eq<N$1 extends string, V extends PredicateValue>(name: N$1, value: V): ComparisonNode<ValueRef<N$1, V>>;
/**
* Attribute is greater than value, in index order — see {@link ComparisonOperator}.
*
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system
* attribute, a system attribute is compared against the wrong type, or the value is `bytes`.
*
* @example
* gt("level", i32(10)) // level > i32(10)
* gt("$expiresAt", u64(1_200_000n)) // $expiresAt > u64(1200000)
*/
declare function gt<N$1 extends string, V extends PredicateValue>(name: N$1, value: V): ComparisonNode<ValueRef<N$1, V>>;
/**
* Attribute is greater than or equal to value, in index order — see {@link ComparisonOperator}.
*
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system
* attribute, a system attribute is compared against the wrong type, or the value is `bytes`.
*
* @example
* gte("score", dec("3.5")) // score >= dec(3.5)
*/
declare function gte<N$1 extends string, V extends PredicateValue>(name: N$1, value: V): ComparisonNode<ValueRef<N$1, V>>;
/**
* Attribute is less than value, in index order — see {@link ComparisonOperator}.
*
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system
* attribute, a system attribute is compared against the wrong type, or the value is `bytes`.
*
* @example
* lt("level", i32(10)) // level < i32(10)
*/
declare function lt<N$1 extends string, V extends PredicateValue>(name: N$1, value: V): ComparisonNode<ValueRef<N$1, V>>;
/**
* Attribute is less than or equal to value, in index order — see {@link ComparisonOperator}.
*
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system
* attribute, a system attribute is compared against the wrong type, or the value is `bytes`.
*
* @example
* lte("score", dec("5")) // score <= dec(5)
*/
declare function lte<N$1 extends string, V extends PredicateValue>(name: N$1, value: V): ComparisonNode<ValueRef<N$1, V>>;
/**
* Attribute lies between two values, **inclusive** at both ends: it matches exactly what
* `and(gte(name, low), lte(name, high))` matches, in one predicate. Both bounds must have one type,
* and a `low` above `high` matches nothing.
*
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If the bounds have different types, the name starts with `$` but
* is not a queryable system attribute, a system attribute is compared against the wrong type, or a
* bound is `bytes`.
*
* @example
* between("score", dec("3.5"), dec("5")) // score BETWEEN dec(3.5) AND dec(5)
* between("$expiresAt", u64(100n), u64(200n))
*/
declare function between<N$1 extends string, L extends PredicateValue, H extends PredicateValue>(name: N$1, low: L, high: H & SameTypeCheck<L, H>): BetweenNode<ValueRef<N$1, L>>;
/**
* Attribute is a `str` beginning with this prefix.
*
* The match is on **raw UTF-8 bytes** with no normalization — it is the index encoding, so
* `startsWith("name", "é")` matches only the same byte sequence, not another normal form of it.
*
* @param prefix - The prefix, as a bare string or a `str` value.
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system
* attribute.
* @throws {UnsupportedOperatorError} If given a value that is not a `str`, or a system attribute
* (none of which is a `str`).
*
* @example
* startsWith("desc", "ab") // desc STARTSWITH str('ab')
*/
declare function startsWith<N$1 extends string>(name: N$1, prefix: string | StrValue): StartsWithNode<{
readonly name: N$1;
readonly type: "str";
}>;
/**
* The attribute is set, with any type.
*
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If given a system attribute — every entity has all of them, so
* the test would be a constant — or a `$` name that is not one.
*
* @example
* exists("reviewedBy") // EXISTS(reviewedBy)
*/
declare function exists<N$1 extends string>(name: N$1): ExistsNode<{
readonly name: N$1;
readonly type: never;
}>;
/**
* The attribute is set with exactly this type, whatever its value.
*
* Useful when the same name is written with different types across entities — a comparison already
* asserts the type, so this is for asking about the type alone.
*
* @param tag - The type tag: `bool`, `i32`, `u64`, `u256`, `dec`, `str`, `addr` or `key` — any
* type but `bytes`, which is never indexed.
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If the tag is not an indexable type, the name is a system
* attribute (whose type is fixed), or the name starts with `$` but is not a system attribute.
*
* @example
* hasType("age", "i32") // TYPEOF(age) = i32
*/
declare function hasType<N$1 extends string, T$1 extends IndexableTypeTag>(name: N$1, tag: T$1): TypeOfNode<{
readonly name: N$1;
readonly type: T$1;
}>;
/**
* All of these must hold.
*
* A single expression is returned unwrapped, so building a conjunction from a filtered list does
* not litter the query with redundant nesting.
*
* @param expressions - The expressions, as separate arguments or one array.
* @throws {InvalidPredicateError} If given nothing to combine.
*
* @example
* and(gte("level", i32(10)), eq("status", "open"))
* and(filters) // an array works too
*/
declare function and<const E extends readonly Expression[]>(expressions: E): Expression<RefsOf<E[number]>>;
declare function and<const E extends readonly Expression[]>(...expressions: E): Expression<RefsOf<E[number]>>;
/**
* At least one of these must hold.
*
* A single expression is returned unwrapped.
*
* @param expressions - The expressions, as separate arguments or one array.
* @throws {InvalidPredicateError} If given nothing to combine.
*
* @example
* or(eq("status", "open"), exists("reviewedBy"))
*/
declare function or<const E extends readonly Expression[]>(expressions: E): Expression<RefsOf<E[number]>>;
declare function or<const E extends readonly Expression[]>(...expressions: E): Expression<RefsOf<E[number]>>;
/**
* Checks every attribute an expression names against a schema — the runtime half of the check
* {@link SchemaRef} makes at compile time, for the callers the type system does not reach.
*
* @throws {InvalidPredicateError} If a predicate names something that is not a column of the
* schema, a column that is not indexed, or compares a column against a value of another type.
*/
declare function checkAgainstSchema(expression: Expression, schema: Schema): void;
/**
* Renders an expression as the query string the node parses. Equivalent to `String(expression)`.
*
* Literals are always written tagged, even where the language would infer them: an untagged number
* defaults to `i32`, but spelling it `i32(10)` keeps the exact-type assertion visible in the query
* that actually went over the wire.
*/
declare function render(expression: Expression): string;
//#endregion
//#region src/query/order.d.ts
/** Which way a sort runs. */
type SortDirection = "asc" | "desc";
/**
* A sort: the attribute, the type it is read as, and the direction. Built by {@link asc} and
* {@link desc}, and passed to `select(...).orderBy(...)` or `query(..., { orderBy })`.
*
* The node sorts the attribute as one type, so every key carries a type. A system attribute's is
* fixed, and through a schema it comes from the column; otherwise the caller writes it.
*
* @typeParam R - The attribute the key names, as an {@link AttributeRef} — checked against the
* schema by `select(...).from(schema).orderBy(...)`, as `where` checks filters.
*/
interface OrderTerm<R$1 extends AttributeRef = AttributeRef> extends Refs<R$1> {
readonly kind: "order";
readonly name: string;
/** The type sorted on, or `undefined` until the schema the query reads through supplies it. */
readonly type: IndexableTypeTag | undefined;
readonly direction: SortDirection;
}
/**
* The reference a key on `N` makes — with the type written, or a system attribute's fixed one. One
* per name when `N` is a union, so each name keeps its own type; a name typed as plain `string`
* could be anything, so it has no fixed type to claim.
*/
type OrderRef<N$1 extends string, T$1 extends IndexableTypeTag> = N$1 extends string ? {
readonly name: N$1;
readonly type: [T$1] extends [never] ? string extends N$1 ? never : Extract<SystemAttributeRef, {
readonly name: N$1;
}>["type"] : T$1;
} : never;
/** Whether a value is a key built by {@link asc} or {@link desc}. */
/**
* Sorts by an attribute, smallest first, in the order values compare in — see
* `ComparisonOperator`. Entities where the attribute is unset, or set with another type, come
* first.
*
* @param name - An attribute of any type but bytes, indexed or not, or one of the system
* attributes `$key`, `$owner`, `$creator` and `$expiresAt`.
* @param type - The type to sort the attribute as. A system attribute's is fixed, and through a
* schema it is the column's, so it is needed only for a query without one.
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system
* attribute, the type is bytes or not a type, or a system attribute is given another type.
*
* @example
* asc("title") // through a schema: title:str ASC
* asc("score", "u256") // without one: score:u256 ASC
* asc("$expiresAt") // $expiresAt:u64 ASC
*/
declare function asc<N$1 extends string>(name: N$1): OrderTerm<OrderRef<N$1, never>>;
declare function asc<N$1 extends string, T$1 extends IndexableTypeTag>(name: N$1, type: T$1): OrderTerm<OrderRef<N$1, T$1>>;
/**
* Sorts by an attribute, largest first, in the order values compare in — see
* `ComparisonOperator`. Entities where the attribute is unset, or set with another type, come
* last.
*
* @param name - An attribute of any type but bytes, indexed or not, or one of the system
* attributes `$key`, `$owner`, `$creator` and `$expiresAt`.
* @param type - The type to sort the attribute as. A system attribute's is fixed, and through a
* schema it is the column's, so it is needed only for a query without one.
* @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.
* @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system
* attribute, the type is bytes or not a type, or a system attribute is given another type.
*
* @example
* desc("score") // through a schema: score:dec DESC
* desc("score", "u256") // without one: score:u256 DESC
*/
declare function desc<N$1 extends string>(name: N$1): OrderTerm<OrderRef<N$1, never>>;
declare function desc<N$1 extends string, T$1 extends IndexableTypeTag>(name: N$1, type: T$1): OrderTerm<OrderRef<N$1, T$1>>;
/**
* The references a sort through schema `S` may make: each column but a bytes one, indexed or not,
* with its declared type, and the queryable system attributes with theirs.
*/
type SortRef<S extends Schema> = { [K in keyof ColumnsOf<S> & string]: ColumnsOf<S>[K]["type"] extends IndexableTypeTag ? {
readonly name: K;
readonly type: ColumnsOf<S>[K]["type"];
} : never }[keyof ColumnsOf<S> & string] | SystemAttributeRef;
/**
* Human-readable messages for compile-time errors when a sort key cannot be sent — it names a
* bytes column or something that is not a column, asserts another type than its column's, or,
* without a schema, has no type at all.
*/
type OrderProblem<R$1, TSchema> = R$1 extends {
readonly name: infer N extends string;
readonly type: infer T extends string;
} ? N extends `$${string}` ? R$1 extends SystemAttributeRef ? never : N extends SystemAttributeRef["name"] ? `"${N}" is always a ${Extract<SystemAttributeRef, {
name: N;
}>["type"]}, but the sort asserts ${T}` : `"${N}" cannot be sorted on. The sortable system attributes are $key, $owner, $creator and $expiresAt` : TSchema extends Schema ? R$1 extends SortRef<TSchema> ? never : N extends SortRef<TSchema>["name"] ? `"${N}" has type ${Extract<SortRef<TSchema>, {
name: N;
}>["type"]}, but the sort asserts ${T}` : N extends keyof ColumnsOf<TSchema> ? `"${N}" is a bytes column, and bytes cannot be sorted on` : `"${N}" is not a column of this schema` : [T] extends [never] ? `"${N}" needs its type to be sorted on without a schema. Write it, as in desc("${N}", "u256")` : never : never;
/**
* `orderBy`'s check that the key can be sent — `unknown` when it can, and otherwise an object
* whose one property is named after the problem. No key has that property, so the compiler reports
* the sentence as the property it is missing.
*/
type OrderCheck<K$1 extends OrderTerm, TSchema> = [OrderProblem<RefsOf<K$1>, TSchema>] extends [infer P extends string] ? [P] extends [never] ? unknown : { [Problem in P]: never } : unknown;
//#endregion
//#region src/types/entity.d.ts
/**
* The fields an {@link Entity} can carry. Every one is optional: a query returns exactly the parts
* it selected, and `undefined` means "not asked for" rather than "empty".
*/
type EntityFields = {
key?: Hex | undefined;
owner?: Hex | undefined;
creator?: Hex | undefined;
/** Block the entity was created at. */
createdAt?: bigint | undefined;
/** Block the entity was last patched at. */
updatedAt?: bigint | undefined;
/** Block the entity expires at. */
expiresAt?: bigint | undefined;
/** The immutable properties the entity was created with. */
creationFlags?: ResolvedCreationFlags | undefined;
/** Attribute names, types and indexing, with no values. */
attributeSchema?: AttributeSchema | undefined;
/** Attribute names, types and values. */
attributes?: Attributes | undefined;
};
/**
* An entity as the node returns it, decoded: the fields a query selected, with its attributes as a
* map keyed by name. Which fields are populated is decided by the selection, so each may be
* `undefined`.
*
* Queries do not return these: `select()`, `query()` and `getEntity()` lay each one out as a flat
* row — the selected entity fields and attributes side by side, typed by the selection and, through
* a schema, by its columns.
*/
declare class Entity implements EntityFields {
key: Hex | undefined;
owner: Hex | undefined;
creator: Hex | undefined;
createdAt: bigint | undefined;
updatedAt: bigint | undefined;
expiresAt: bigint | undefined;
creationFlags: ResolvedCreationFlags | undefined;
attributeSchema: AttributeSchema | undefined;
attributes: Attributes | undefined;
constructor(fields?: EntityFields);
}
//#endregion
//#region src/query/selection.d.ts
/**
* The entity fields a row can carry. Each is `$`-prefixed, like the system attributes `where`
* filters on: an attribute name cannot start with `$`, so no attribute can collide with one.
*/
declare const SYSTEM_FIELDS: readonly ["$key", "$owner", "$creator", "$createdAt", "$updatedAt", "$expiresAt", "$creationFlags"];
/** The name of an entity field a row carries alongside its attributes. */
type SystemField = (typeof SYSTEM_FIELDS)[number];
/** The {@link Entity} property a system field reads. */
type EntityField<F extends SystemField> = F extends `$${infer N extends keyof EntityFields}` ? N : never;
/**
* The keys a selection gives a fixed meaning: the entity fields, plus `$attributes` and
* `$attributeSchema`, which read an entity's attributes as a whole. Any key without a `$` names an
* attribute.
*/
type SelectionFields = { [K in SystemField]?: boolean } & {
/**
* Attribute names, types and indexing, without their values — a cheap way to find out what
* entities hold before fetching values that may be large. See {@link AttributeSchema}.
*/
$attributeSchema?: boolean;
/** Every attribute, as a map keyed by name. */
$attributes?: boolean;
};
/** The selection keys with a fixed meaning, in the order they are written into the RPC `select`. */
declare const SELECTION_KEYS: readonly ["$key", "$owner", "$creator", "$createdAt", "$updatedAt", "$expiresAt", "$creationFlags", "$attributeSchema", "$attributes"];
/** A selection key with a fixed meaning. */
type SelectionKey = (typeof SELECTION_KEYS)[number];
/**
* A selection: entity fields, `$attributes` / `$attributeSchema`, and attributes by name, each set
* to `true` to ask for it. The same selection means the same thing with or without a schema —
* naming one with `.from(...)` only types and checks the selected attributes, and the filter. A
* named schema also restricts the query to entities tagged with its name, and leaves the tag out of
* every row.
*/
type Selection = Readonly<Record<string, boolean | undefined>>;
/** Argument accepted by `select()` — a {@link Selection}, or `"*"` for everything. */
type SelectArg = Selection | "*";
/** Whether a selection value asks for the field: `true` does, `false` and `undefined` do not. */
type Selected<V> = V extends false | undefined ? false : true;
/**
* What a column reads back as: a value of its type, or `undefined` too if the column is optional.
*/
type ColumnValue<C> = C extends {
readonly type: infer T extends TypeTag;
readonly isOptional: infer O;
} ? ValueOf<T> | (true extends O ? undefined : never) : never;
/**
* What a selected key reads back as: an entity field as the entity has it, the attributes as a
* whole, or one attribute — typed by its column through a schema, and any value or none without.
*/
type FieldValue<K$1, TSchema extends Schema | undefined> = K$1 extends SystemField ? NonNullable<Entity[EntityField<K$1>]> : K$1 extends "$attributes" ? Attributes : K$1 extends "$attributeSchema" ? AttributeSchema : K$1 extends `$${string}` ? never : TSchema extends Schema ? K$1 extends keyof ColumnsOf<TSchema> ? ColumnValue<ColumnsOf<TSchema>[K$1]> : never : ArkivValue | undefined;
/**
* One result of selection `S`, through schema `TSchema` or without one: the selected entity fields
* and attributes side by side, flat. Through a schema each attribute is typed as its column
* declares; without one it is whatever value the entity holds, or `undefined`. Accessing an
* unselected field is a compile error.
*
* @example
* // select({ $key: true, title: true }) → { $key: Hex; title: ArkivValue | undefined }
* // select({ $key: true, title: true }).from(Posts) → { $key: Hex; title: StrValue }
*/
type Row<S, TSchema extends Schema | undefined = undefined> = { readonly [K in keyof S as Selected<S[K]> extends true ? K : never]: FieldValue<K, TSchema> };
/**
* What `select()` / `select("*")` selects without a schema: every entity field and every
* attribute. Not the `$attributeSchema`: its point is learning an entity's shape without fetching
* its values, so returning it next to every value would only add to the response. It is only
* returned when asked for by name.
*/
type AllSelected = { [K in SystemField | "$attributes"]: true };
/**
* The result when everything is selected without a schema — every entity field, and every
* attribute as the `$attributes` map. Also what `getEntity(key)` returns.
*/
type FullEntity = Row<AllSelected>;
/** The row type when everything is selected through a schema — every entity field and column. */
type FullRow<TSchema extends Schema> = Row<{ [K in SystemField | keyof ColumnsOf<TSchema>]: true }, TSchema>;
declare const dynamic: unique symbol;
/**
* The selection type of a builder whose selection is only known at runtime — `select(sel)` with
* `sel` typed {@link SelectArg} rather than written inline. Nothing about which fields will be
* present can be known statically, so results are typed with every field optional.
*/
type DynamicSelection = {
readonly [dynamic]: true;
};
/**
* A result whose selection is only known at runtime: any entity field and any attribute may be
* absent, because nothing says statically which were selected.
*/
type PartialRow<TSchema extends Schema | undefined = undefined> = { readonly [K in SystemField]?: NonNullable<Entity[EntityField<K>]> } & {
readonly $attributes?: Attributes;
readonly $attributeSchema?: AttributeSchema;
} & (TSchema extends Schema ? { readonly [K in keyof ColumnsOf<TSchema>]?: ValueOf<ColumnsOf<TSchema>[K]["type"]> } : {
readonly [name: string]: ArkivValue | undefined;
});
/**
* Whether which fields `S` selects is only known at runtime: a selection typed {@link SelectArg} or
* {@link Selection}, or one with a field typed `boolean` rather than `true` or `false`.
*/
type IsDynamic<S> = string extends keyof Exclude<S, "*"> ? true : S extends "*" ? false : true extends { [K in keyof S]: [S[K]] extends [boolean] ? (boolean extends S[K] ? true : false) : false }[keyof S] ? true : false;
/**
* The selection type a query carries for the selection `select()` or `query()` was given: `"*"`
* for everything, {@link DynamicSelection} when the fields are only known at runtime, and the
* selection itself otherwise.
*/
type SelectionOf<S> = [S] extends ["*"] ? "*" : IsDynamic<S> extends true ? DynamicSelection : S;
/**
* Rejects a selection that asks for nothing at compile time — `{}`, or every field `false`:
* `unknown` when `S` asks for something, or when that is only known at runtime, and an object no
* selection satisfies otherwise.
*/
type NonEmptySelection<S> = SelectionOf<S> extends "*" | DynamicSelection ? unknown : [keyof { [K in keyof S as Selected<S[K]> extends true ? K : never]: true }] extends [never] ? {
"select() needs at least one field set to true": true;
} : unknown;
/**
* Rejects a `$` key that is not an entity field, `$attributes` or `$attributeSchema` at compile
* time. An attribute name cannot start with `$`, so such a key can only be a typo: `unknown` when
* there is none, and an object naming the offenders, which no selection satisfies, otherwise.
*/
type KnownSystemFields<S> = SelectionOf<S> extends "*" | DynamicSelection ? unknown : [Extract<Exclude<keyof S, SelectionKey>, `$${string}`>] extends [never] ? unknown : {
"selected names that are not entity fields": Extract<Exclude<keyof S, SelectionKey>, `$${string}`>;
};
/** What a query returns per result — a flat row, typed by the schema when there is one. */
type ResultOf<TSelection, TSchema extends Schema | undefined> = TSelection extends DynamicSelection ? PartialRow<TSchema> : TSelection extends "*" ? TSchema extends Schema ? FullRow<TSchema> : FullEntity : Row<TSelection, TSchema>;
/**
* The keys of a selection that mean nothing through `TSchema` — neither an entity field,
* `$attributes` / `$attributeSchema`, nor a column. None for a star or a selection only known at
* runtime, which `from()` checks when it runs instead.
*/
type UnknownSelection<TSelection, TSchema extends Schema> = TSelection extends "*" | DynamicSelection ? never : Exclude<keyof TSelection, SelectionKey | keyof ColumnsOf<TSchema>>;
/**
* Converts a selection into the RPC `select` object — the same request {@link projectSelection}
* makes without a schema.
*
* Every field is opt-in — anything not explicitly selected is sent as `false`, including the key.
* Sending the full object rather than omitting the `false`s keeps what the SDK asked for legible in
* a request log, and pins the answer even if a node's defaults change.
*
* `undefined` or `"*"` selects everything.
*
* @throws If the selection asks for nothing, or names an attribute outside the name grammar.
*
* @example
* toRpcSelect() // everything
* toRpcSelect({ $key: true }) // only the key
* toRpcSelect({ $key: true, projectId: true }) // the key and one attribute
*/
declare function toRpcSelect(selection?: SelectArg): RpcSelect;
/**
* A selection resolved, through a schema or without one: what to ask the node for, and how to lay
* the answer out.
*/
type Projection = {
readonly select: RpcSelect;
/** The entity fields each row carries. */
readonly fields: readonly SystemField[];
/**
* The attributes each row carries as fields of their own, by name — each with its column
* through a schema, which the value is checked against, and `undefined` without one.
*/
readonly columns: readonly (readonly [name: string, column: AnyColumn | undefined])[];
/** Whether each row carries the `$attributes` map. */
readonly attributes: boolean;
/** Whether each row carries the `$attributeSchema`. */
readonly attributeSchema: boolean;
/** The tag each entity must carry, for a named schema. Checked, never part of the row. */
readonly tag: StrValue | undefined;
};
/**
* Resolves a selection, through a schema or without one. A key that does not start with `$` names
* an attribute — through a schema, it must be a column.
*
* `undefined` or `"*"` selects every entity field and, through a schema, every column; without one,
* every attribute as the `$attributes` map. The `$attributeSchema` is only selected by name.
*
* Attributes are fetched by name where possible, so the ones a row does not carry stay on the node.
* A named schema's tag is fetched too, so each entity can be checked against it.
*
* @throws If the selection asks for nothing, names a `$` key that is not an entity field, names an
* attribute outside the name grammar, or — through a schema — names an attribute that is not a
* column.
*/
declare function projectSelection(selection?: SelectArg, schema?: Schema): Projection;
/**
* Lays an entity out as a row of `projection` — checking it against the schema, when there is one.
*
* @throws {SchemaMismatchError} If a named schema's entity is not tagged with its name, or the
* entity lacks a selected required column or holds one with a type other than the schema's — it
* was not written through this schema, or was patched since.
*/
declare function toRow(entity: Entity, projection: Projection): Record<string, unknown>;
//#endregion
//#region src/actions/public/query.d.ts
type QueryOptions<TSelection extends SelectArg = SelectArg, TOrder extends OrderTerm = OrderTerm> = {
/** What to return — the same selection `select()` takes. Defaults to everything. */
select?: TSelection | undefined;
/**
* The sort, an `asc(...)` or a `desc(...)`, sent as an `ORDER BY` clause after the query. There
* is no schema here, so a key on a user attribute names its type, as in `desc("score", "dec")`.
*/
orderBy?: (TOrder & OrderCheck<TOrder, undefined>) | undefined;
/** Page size, up to the node maximum of 100. */
limit?: number | undefined;
/**
* How many matches to skip before the page. Defaults to none. Each request reads the latest
* block, so writes between two requests shift the matches, and a row can repeat or be missed.
* Sort by a key that does not change, such as `asc("$key")`, so that pages line up at least while
* nothing is written.
*/
offset?: number | undefined;
/** Whether to also count every entity the query matches, returned as `count`. */
count?: boolean | undefined;
};
/**
* What one result of a `query()` reads as for selection `S`: the same row `select(S)` returns
* without a schema — every field when everything is selected, and every field optional when the
* selection is only known at runtime.
*/
type QueryRow<S> = ResultOf<SelectionOf<S>, undefined>;
type QueryReturnType<TResult = FullEntity> = {
entities: TResult[];
/** The block the page was read at. */
blockNumber: bigint;
/** How many entities the query matches, if `count` was set. */
count: bigint | undefined;
};
//#endregion
//#region src/types/events.d.ts
/**
* Where an event sits in the chain — carried by every on-chain entity event.
*
* Operations apply in batch order and emit one event each, so `blockNumber` and `logIndex` together
* are the order the operations were applied in. A replica that replays them in that order sees
* exactly what the engine did.
*/
type EntityEventContext = {
/** The block the operation was applied in. */
blockNumber: bigint;
/** The transaction the operation was part of. */
transactionHash: Hex;
/** The event's position within its block. */
logIndex: number;
};
/** An entity was created. */
type EntityCreatedEvent = EntityEventContext & {
type: "EntityCreated";
entityKey: Hex;
owner: Address;
/** The block the entity is set to expire at. */
expiresAt: bigint;
/**
* The immutable properties the entity was created with, decoded from its `creationFlags` byte.
*/
creationFlags: ResolvedCreationFlags;
};
/**
* An entity's attributes changed.
*
* The event says *that* it changed, not what to — read the entity to see the new state.
*/
type EntityPatchedEvent = EntityEventContext & {
type: "EntityPatched";
entityKey: Hex;
owner: Address;
};
/** An entity's expiry moved further out. */
type ExpiryExtendedEvent = EntityEventContext & {
type: "ExpiryExtended";
entityKey: Hex;
/**
* The entity's owner — **not** whoever extended it. An entity created with
* `permissionlessExtension` can be extended by anyone, and the event does not say by whom; read
* the transaction's sender if you need that.
*/
owner: Address;
/** The block the entity is now set to expire at. */
expiresAt: bigint;
};
/** An entity changed hands. */
type OwnershipTransferredEvent = EntityEventContext & {
type: "OwnershipTransferred";
entityKey: Hex;
previousOwner: Address;
newOwner: Address;
};
/** An entity was deleted by its owner, before its expiry. */
type EntityDeletedEvent = EntityEventContext & {
type: "EntityDeleted";
entityKey: Hex;
owner: Address;
};
/**
* Every event the engine emits, discriminated by `type`.
*/
type EntityEvent = EntityCreatedEvent | EntityPatchedEvent | ExpiryExtendedEvent | OwnershipTransferredEvent | EntityDeletedEvent;
//#endregion
//#region src/actions/public/watchEntityEvents.d.ts
/**
* Handlers and options for `client.watchEntityEvents`. Every handler is optional; the watcher does
* the work for the ones you pass.
*/
type WatchEntityEventsParameters = {
onEntityCreated?: ((event: EntityCreatedEvent) => void) | undefined;
onEntityPatched?: ((event: EntityPatchedEvent) => void) | undefined;
onExpiryExtended?: ((event: ExpiryExtendedEvent) => void) | undefined;
onOwnershipTransferred?: ((event: OwnershipTransferredEvent) => void) | undefined;
onEntityDeleted?: ((event: EntityDeletedEvent) => void) | undefined;
/**
* Every event, in application order, whatever its type. Runs *before* the per-event handler for
* the same event.
*
* This is the replay seam: operations apply in batch order and emit one event each, so an
* off-chain replica that consumes this in order sees what the engine did once the watcher is
* running — see {@link watchEntityEvents} for when that is.
*/
onEvent?: ((event: EntityEvent) => void) | undefined;
/**
* Transport failures, logs that will not decode, and anything one of your own handlers throws.
*
* Defaults to `console.error`. A watcher whose filter the node dropped otherwise just goes quiet,
* and a quiet watcher is indistinguishable from a quiet chain.
*/
onError?: ((error: Error) => void) | undefined;
/** How often to poll, in milliseconds. Defaults to half a block. */
pollingInterval?: number | undefined;
};
//#endregion
//#region src/actions/wallet/createEntity.d.ts
/**
* How an created entity lives: its lifetime, plus the flags and salt it is created with.
*
* @example
* { expiration: ExpirationTime.fromDays(30) }
*
* @example Pin an absolute deadline, but never let it leave the entity with less than a day:
* {
* expiration: ExpirationTime.atDate(someDeadline, {
* atLeast: ExpirationTime.fromDays(1), // ...but live at least a day regardless
* }),
* flags: { readonly: true },
* }
*/
type CreateEntityOptions = {
/**
* How long the entity should live, built with {@link ExpirationTime}.
*
* `ExpirationTime.fromDays(30)` is the everyday form. `atBlock` / `atDate` pin an absolute
* deadline instead, and either can carry `{ atLeast }` to guarantee a minimum life on top of it.
*/
expiration: Expiry;
/**
* Properties fixed at creation: `readonly` and `permissionlessExtension`. No operation changes
* them afterwards, so an entity is whatever it was created as for life. Both default to `false`.
*/
flags?: CreationFlags | undefined;
/**
* The salt mixed into the entity key. Defaults to 128 random bits, which makes the key
* unpredictable to everyone but the creator.
*
* Pass {@link NO_SALT} for a key derived from the owner and nonce alone — predictable by anyone,
* which is what you want only when a third party must be able to compute the key in advance.
*/
salt?: SaltInput | undefined;
};
/**
* One entity to create, as a batch carries it: the schema, the values, and the {@link CreateEntityOptions}.
*
* @typeParam S - The schema the values are typed by.
*/
type CreateEntityParameters<S extends Schema = Schema> = CreateEntityOptions & {
/** The schema the entity is written through. */
schema: S;
/**
* The entity's values, keyed by column. Every required column must be given; an optional one may
* be left out, and a defaulted one left out is written with its default.
*/
values: CreateEntityValues<S>;
};
/**
* The result of creating an entity.
*/
type CreateEntityReturnType = {
/** The new entity's key. */
entityKey: Hex;
txHash: Hash;
/**
* The block the entity expires at, as the engine recorded it — read from the `EntityCreated`
* event, so a duration is already resolved against the block the transaction landed in.
*/
expiresAt: bigint;
};
//#endregion
//#region src/actions/wallet/deleteEntity.d.ts
/**
* Parameters for the deleteEntity function.
* - entityKey: The key of the entity to delete.
*/
type DeleteEntityParameters = {
entityKey: Hex;
};
/**
* Return type for the deleteEntity function.
* - entityKey: The key of the entity.
* - txHash: The transaction hash.
*/
type DeleteEntityReturnType = {
entityKey: Hex;
txHash: Hash;
};
//#endregion
//#region src/actions/wallet/extendEntity.d.ts
/**
* Parameters for extending an entity's life.
*
* An extension **sets a new expiry**; it does not add to the existing one. It is resolved exactly
* as a create's is — a duration counts from now, not from the entity's current expiry — so
* `ExpirationTime.fromDays(30)` means "alive for thirty more days from now" whatever the entity's
* remaining life happened to be.
*
* The engine rejects an extension that would move the expiry earlier, so extending an entity by
* less than it already has left is an error rather than a silent shortening. One that resolves to
* the current expiry changes nothing.
*
* @example
* await client.extendEntity({ entityKey, expiration: ExpirationTime.fromDays(30) })
* await client.extendEntity({ entityKey, expiration: ExpirationTime.atBlock(1_200_000n) })
*/
type ExtendEntityParameters = {
entityKey: Hex;
/** The entity's new lifetime, built with {@link ExpirationTime}. */
expiration: Expiry;
};
/**
* The result of extending an entity.
*/
type ExtendEntityReturnType = {
entityKey: Hex;
txHash: Hash;
/**
* The block the entity now expires at, as the engine recorded it — read from the
* `ExpiryExtended` event, so a duration is already resolved against the block the transaction
* landed in.
*/
expiresAt: bigint;
};
//#endregion
//#region src/actions/wallet/patchEntity.d.ts
/**
* What a patch changes.
*
* A patch names only what changes. Columns it does not mention keep whatever value they have — so
* a caller can change one column without first reading the entity to learn what the others are,
* and without racing anyone else who is changing a different one.
*
* @typeParam S - The schema the changes are typed by.
*
* @example
* { set: { title: "Cells, not entities", score: dec("4.2") }, unset: ["thumbnail"] }
*/
type PatchEntityChanges<S extends Schema = Schema> = {
/**
* Columns to write, keyed by name. Each is written with the indexed flag its column declares,
* so writing a column whose indexing the schema has since changed changes it on the entity too.
* Defaults do not apply: a patch writes only what it names.
*
* @throws {SchemaMismatchError} If a name is not a column, or a value is not of its column's type.
*/
set?: PatchEntityValues<S> | undefined;
/**
* Optional columns to remove. Naming one the entity does not carry is not an error — the outcome
* is the same either way, and a caller clearing a column should not have to know whether it was
* ever set.
*
* @throws {ConflictingMutationError} If a name also appears in `set`.
*/
unset?: readonly OptionalColumnName<S>[] | undefined;
};
/**
* One patch, as a batch carries it: the schema, the entity, and the {@link PatchEntityChanges}.
*
* The entity's identity is fixed: a patch never moves the key, the owner, the creation flags or the
* expiry. Use `extendEntity` for the expiry and `changeOwnership` for the owner.
*/
type PatchEntityParameters<S extends Schema = Schema> = PatchEntityChanges<S> & {
/** The schema the changes are typed by. */
schema: S;
/** The entity to patch. */
entityKey: Hex;
};
/** The result of a patch. */
type PatchEntityReturnType = {
/** The patched entity's key — unchanged, since a patch never moves it. */
entityKey: Hex;
txHash: Hash;
};
//#endregion
//#region src/actions/wallet/executeBatch.d.ts
/**
* Parameters for the executeBatch function.
*
* At least one operation is required; a batch with nothing in it throws rather than spending gas on
* an empty transaction.
*
* Each create and patch names its own schema, and is typed by it — a batch can write entities of
* several schemas at once.
*
* @typeParam TCreates - The schema of each create, in order. Inferred.
* @typeParam TPatches - The schema of each patch, in order. Inferred.
*/
type ExecuteBatchParameters<TCreates extends readonly Schema[] = readonly Schema[], TPatches extends readonly Schema[] = readonly Schema[]> = {
/** The entities to create. */
creates?: { readonly [I in keyof TCreates]: CreateEntityParameters<TCreates[I]> } | undefined;
/** The patches to apply. */
patches?: { readonly [I in keyof TPatches]: PatchEntityParameters<TPatches[I]> } | undefined;
/** The entities to delete. */
deletes?: readonly DeleteEntityParameters[] | undefined;
/** The expiries to set. */
extensions?: readonly ExtendEntityParameters[] | undefined;
/** The ownership transfers to perform. */
ownershipChanges?: readonly ChangeOwnershipParameters[] | undefined;
};
/** Return type for the executeBatch function. */
type ExecuteBatchReturnType = {
/** The transaction hash. */
txHash: Hash;
/** The keys of the created entities, in batch order. */
createdEntities: Hex[];
/** The keys of the patched entities. */
patchedEntities: Hex[];
/** The keys of the deleted entities. */
deletedEntities: Hex[];
/** The keys of the extended entities. */
extendedEntities: Hex[];
/** The keys of the entities handed to a new owner. */
ownershipChanges: Hex[];
};
//#endregion
//#region src/types/txParams.d.ts
/**
* Transaction fields a write action passes through to the wallet, for the cases where the defaults
* are not what you want.
*
* Fee style is either/or: give `gasPrice` for a legacy transaction, or `maxFeePerGas` /
* `maxPriorityFeePerGas` for an EIP-1559 one. Mixing the two does not typecheck. Anything left out
* is estimated.
*/
type TxParams = {
gas?: bigint;
nonce?: number;
gasPrice?: bigint;
maxFeePerGas?: never;
maxPriorityFeePerGas?: never;
} | {
gas?: bigint;
nonce?: number;
maxFeePerGas?: bigint;
maxPriorityFeePerGas?: bigint;
gasPrice?: never;
};
//#endregion
//#region src/actions/wallet/changeOwnership.d.ts
/**
* Parameters for the changeOwnership function.
* - entityKey: The key of the entity.
* - newOwner: The address of the new owner.
*/
type ChangeOwnershipParameters = {
entityKey: Hex;
newOwner: Hex;
};
/**
* Return type for the changeOwnership function.
* - entityKey: The key of the entity.
* - txHash: The transaction hash.
*/
type ChangeOwnershipReturnType = {
entityKey: Hex;
txHash: Hash;
};
//#endregion
export { asc as $, FullRow as A, PredictedEntityKey as At, Selection as B, OwnershipTransferredEvent as C, lt as Ct, ColumnValue as D, startsWith as Dt, QueryRow as E, render as Et, ResultOf as F, RpcAttributeSchemaEntry as Ft, projectSelection as G, SelectionOf as H, Row as I, RpcCreationFlags as It, Entity as J, toRow as K, SYSTEM_FIELDS as L, RpcEntity as Lt, NonEmptySelection as M, ArkivClient as Mt, PartialRow as N, ArkivRpcSchema as Nt, DynamicSelection as O, PredictEntityKeysParameters as Ot, Projection as P, RpcAttribute as Pt, SortDirection as Q, SelectArg as R, RpcQueryOptions as Rt, ExpiryExtendedEvent as S, hasType as St, QueryReturnType as T, or as Tt, SystemField as U, SelectionFields as V, UnknownSelection as W, OrderCheck as X, EntityFields as Y, OrderTerm as Z, EntityCreatedEvent as _, checkAgainstSchema as _t, ExecuteBatchReturnType as a, ComparisonOperator as at, EntityEventContext as b, gt as bt, PatchEntityReturnType as c, OrNode as ct, DeleteEntityParameters as d, SchemaRef as dt, desc as et, DeleteEntityReturnType as f, StartsWithNode as ft, WatchEntityEventsParameters as g, between as gt, CreateEntityReturnType as h, and as ht, ExecuteBatchParameters as i, ComparisonNode as it, KnownSystemFields as j, GetBlockTimingReturnType as jt, FullEntity as k, PredictEntityKeysReturnType as kt, ExtendEntityParameters as l, PredicateValue as lt, CreateEntityParameters as m, TypeOfNode as mt, ChangeOwnershipReturnType as n, AttributeRef as nt, PatchEntityChanges as o, ExistsNode as ot, CreateEntityOptions as p, SystemAttributeRef as pt, toRpcSelect as q, TxParams as r, BetweenNode as rt, PatchEntityParameters as s, Expression as st, ChangeOwnershipParameters as t, AndNode as tt, ExtendEntityReturnType as u, RefsOf as ut, EntityDeletedEvent as v, eq as vt, QueryOptions as w, lte as wt, EntityPatchedEvent as x, gte as xt, EntityEvent as y, exists as yt, Selected as z, RpcSelect as zt };
//# sourceMappingURL=changeOwnership-XF68lRdr.d.cts.map