@arkiv-network/sdk 0.8.1-dev.1 → 0.9.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +180 -61
- package/dist/chains/index.d.ts +17 -17
- package/dist/changeOwnership-Cy9gfyjN.d.cts +1160 -0
- package/dist/changeOwnership-Cy9gfyjN.d.cts.map +1 -0
- package/dist/changeOwnership-gXf-lBqI.d.ts +1160 -0
- package/dist/changeOwnership-gXf-lBqI.d.ts.map +1 -0
- package/dist/entity/index.cjs +4 -10
- package/dist/entity/index.d.cts +3 -3
- package/dist/entity/index.d.ts +3 -3
- package/dist/entity/index.js +3 -4
- package/dist/entity-BM1unrQf.cjs +41 -0
- package/dist/{entity-DJ0Gml9c.cjs → entity-BgaFJSaV.cjs} +4 -4
- package/dist/entity-CFAI1KyG.js +36 -0
- package/dist/entity-CFAI1KyG.js.map +1 -0
- package/dist/{entity-CniBgBSd.js → entity-CGqx_AU0.js} +4 -4
- package/dist/entity-CGqx_AU0.js.map +1 -0
- package/dist/{payload-AfUfSctb.d.ts → expirationTime-C7PZK49K.d.ts} +8 -37
- package/dist/expirationTime-C7PZK49K.d.ts.map +1 -0
- package/dist/expirationTime-CkIGNAg8.cjs +140 -0
- package/dist/{payload-D167BlJR.d.cts → expirationTime-DOB8V4B8.d.cts} +8 -37
- package/dist/expirationTime-DOB8V4B8.d.cts.map +1 -0
- package/dist/{expiry-Cgdb_dbq.js → expirationTime-UKPuA-LM.js} +62 -27
- package/dist/expirationTime-UKPuA-LM.js.map +1 -0
- package/dist/expiry-B48I-yTA.d.cts +40 -0
- package/dist/expiry-B48I-yTA.d.cts.map +1 -0
- package/dist/expiry-S2PUL8Hg.d.ts +40 -0
- package/dist/expiry-S2PUL8Hg.d.ts.map +1 -0
- package/dist/index-C-mMF5WZ.d.cts +735 -0
- package/dist/index-C-mMF5WZ.d.cts.map +1 -0
- package/dist/{index-BkqSnGJH.d.ts → index-C4zZqJ9S.d.ts} +5 -27
- package/dist/index-C4zZqJ9S.d.ts.map +1 -0
- package/dist/{index-CLhsFyVH.d.cts → index-CcVWYB6v.d.cts} +5 -27
- package/dist/index-CcVWYB6v.d.cts.map +1 -0
- package/dist/index-DCx2XC6S.d.ts +489 -0
- package/dist/index-DCx2XC6S.d.ts.map +1 -0
- package/dist/index-DLb7BfIw.d.ts +735 -0
- package/dist/index-DLb7BfIw.d.ts.map +1 -0
- package/dist/index-DzriOUm8.d.cts +489 -0
- package/dist/index-DzriOUm8.d.cts.map +1 -0
- package/dist/index.cjs +162 -146
- package/dist/index.d.cts +180 -133
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +180 -133
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +93 -83
- package/dist/index.js.map +1 -1
- package/dist/params-BuIrJA9a.cjs +45 -0
- package/dist/params-DDJOnsNi.js +22 -0
- package/dist/params-DDJOnsNi.js.map +1 -0
- package/dist/query/index.cjs +9 -4
- package/dist/query/index.d.cts +6 -6
- package/dist/query/index.d.ts +6 -6
- package/dist/query/index.js +4 -5
- package/dist/query-D0KtuFh2.cjs +1625 -0
- package/dist/query-DpRDozmj.js +1417 -0
- package/dist/query-DpRDozmj.js.map +1 -0
- package/dist/schema/index.cjs +46 -0
- package/dist/schema/index.d.cts +2 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +3 -0
- package/dist/{attr-BXTkpnoc.cjs → schema-B9AyXcgU.cjs} +513 -246
- package/dist/{attr-tmyREHtw.js → schema-DY4sqehl.js} +427 -244
- package/dist/schema-DY4sqehl.js.map +1 -0
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +5 -5
- package/dist/types/index.d.ts +5 -5
- package/dist/types/index.js +1 -1
- package/dist/utils/index.cjs +3 -5
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +3 -3
- package/package.json +9 -12
- package/src/actions/public/getEntity.test.ts +69 -0
- package/src/actions/public/getEntity.ts +34 -20
- package/src/actions/public/predictEntityKeys.ts +8 -7
- package/src/actions/public/query.test.ts +58 -0
- package/src/actions/public/query.ts +41 -13
- package/src/actions/wallet/createEntity.ts +34 -63
- package/src/actions/wallet/executeBatch.test.ts +38 -0
- package/src/actions/wallet/executeBatch.ts +26 -9
- package/src/actions/wallet/extendEntity.ts +9 -8
- package/src/actions/wallet/patchEntity.ts +43 -52
- package/src/clients/createPublicClient.test.ts +10 -2
- package/src/clients/createWalletClient.ts +4 -1
- package/src/clients/decorators/arkivPublic.ts +123 -80
- package/src/clients/decorators/arkivWallet.ts +113 -65
- package/src/entity/create.test.ts +25 -21
- package/src/entity/expiry.ts +8 -6
- package/src/entity/flags.ts +1 -1
- package/src/entity/index.ts +2 -4
- package/src/entity/key.ts +3 -3
- package/src/entity/operations.ts +1 -1
- package/src/errors.ts +2 -11
- package/src/index.ts +18 -6
- package/src/query/builderBase.ts +166 -0
- package/src/query/countBuilder.test.ts +91 -0
- package/src/query/countBuilder.ts +67 -0
- package/src/query/engine.ts +9 -3
- package/src/query/errors.ts +24 -14
- package/src/query/expression.test.ts +129 -21
- package/src/query/expression.ts +323 -94
- package/src/query/index.ts +26 -4
- package/src/query/injection.test.ts +5 -11
- package/src/query/queryBuilder.test.ts +467 -58
- package/src/query/queryBuilder.ts +191 -98
- package/src/query/queryResult.ts +35 -9
- package/src/query/selection.test.ts +278 -24
- package/src/query/selection.ts +427 -86
- package/src/schema/attributes.test.ts +266 -0
- package/src/schema/attributes.ts +212 -0
- package/src/{attr → schema}/codec.test.ts +37 -5
- package/src/{attr → schema}/codec.ts +40 -11
- package/src/schema/column.ts +193 -0
- package/src/{attr → schema}/errors.ts +67 -10
- package/src/schema/index.ts +76 -0
- package/src/{attr → schema}/names.ts +4 -2
- package/src/schema/schema.test.ts +171 -0
- package/src/schema/schema.ts +250 -0
- package/src/{attr → schema}/types.ts +36 -30
- package/src/{attr → schema}/values.test.ts +62 -3
- package/src/{attr → schema}/values.ts +246 -65
- package/src/types/entity.test.ts +1 -44
- package/src/types/entity.ts +9 -55
- package/src/types/events.ts +1 -1
- package/src/types/index.ts +11 -4
- package/src/types/rpcSchema.ts +22 -16
- package/src/utils/arkivTransactions.test.ts +356 -116
- package/src/utils/arkivTransactions.ts +30 -38
- package/src/utils/entities.ts +10 -9
- package/src/utils/expirationTime.ts +5 -5
- package/src/utils/index.ts +0 -1
- package/src/utils/logger.test.ts +45 -0
- package/src/utils/logger.ts +5 -39
- package/src/utils/revert.test.ts +25 -0
- package/src/utils/revert.ts +28 -3
- package/dist/attr/index.cjs +0 -34
- package/dist/attr/index.d.cts +0 -2
- package/dist/attr/index.d.ts +0 -2
- package/dist/attr/index.js +0 -3
- package/dist/attr-tmyREHtw.js.map +0 -1
- package/dist/entity-B0t6sN7F.cjs +0 -71
- package/dist/entity-BIp_df9u.js +0 -67
- package/dist/entity-BIp_df9u.js.map +0 -1
- package/dist/entity-CniBgBSd.js.map +0 -1
- package/dist/expiry-BxOlvVWC.d.ts +0 -79
- package/dist/expiry-BxOlvVWC.d.ts.map +0 -1
- package/dist/expiry-CG9GhVXv.cjs +0 -135
- package/dist/expiry-Cgdb_dbq.js.map +0 -1
- package/dist/expiry-DRV29F1r.d.cts +0 -79
- package/dist/expiry-DRV29F1r.d.cts.map +0 -1
- package/dist/flags-DCD26uhe.cjs +0 -43
- package/dist/flags-DUT2gHEU.js +0 -33
- package/dist/flags-DUT2gHEU.js.map +0 -1
- package/dist/index-BkqSnGJH.d.ts.map +0 -1
- package/dist/index-C7fbakoI.d.cts +0 -278
- package/dist/index-C7fbakoI.d.cts.map +0 -1
- package/dist/index-CIcHPx2j.d.cts +0 -424
- package/dist/index-CIcHPx2j.d.cts.map +0 -1
- package/dist/index-CLhsFyVH.d.cts.map +0 -1
- package/dist/index-Cd2aaWme.d.ts +0 -424
- package/dist/index-Cd2aaWme.d.ts.map +0 -1
- package/dist/index-Cq6fa8AI.d.ts +0 -278
- package/dist/index-Cq6fa8AI.d.ts.map +0 -1
- package/dist/index-DaNeJUw8.d.ts +0 -955
- package/dist/index-DaNeJUw8.d.ts.map +0 -1
- package/dist/index-Dv16LO2s.d.cts +0 -955
- package/dist/index-Dv16LO2s.d.cts.map +0 -1
- package/dist/payload-AfUfSctb.d.ts.map +0 -1
- package/dist/payload-D167BlJR.d.cts.map +0 -1
- package/dist/payload-DE7wMztL.js +0 -92
- package/dist/payload-DE7wMztL.js.map +0 -1
- package/dist/payload-DqFweqiO.cjs +0 -108
- package/dist/query-9oojUdM7.cjs +0 -1128
- package/dist/query-Ber-lOJQ.js +0 -968
- package/dist/query-Ber-lOJQ.js.map +0 -1
- package/src/actions/public/getEntityCount.ts +0 -10
- package/src/attr/attributes.test.ts +0 -120
- package/src/attr/attributes.ts +0 -196
- package/src/attr/index.ts +0 -50
- package/src/types/mimeTypes.ts +0 -27
- package/src/utils/compression.test.ts +0 -32
- package/src/utils/compression.ts +0 -102
- package/src/utils/payload.ts +0 -36
- /package/src/{attr → schema}/decimal.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-DpRDozmj.js","names":["fields: SystemField[]","columns: [string, AnyColumn | undefined][]","select: RpcSelect","row: Record<string, unknown>","logger","attributes: Record<string, ReturnType<typeof decodeRpcValue>>","schema: Record<string, AttributeSchema[string]>","QUERY_ERROR_KINDS: Readonly<Record<number, QueryErrorKind>>","code: number | undefined","data: unknown","detail: string | undefined","current: unknown","queryOptions: RpcQueryOptions","fetchPage","page: QueryResult<ResultOf<TSelection, TSchema>, TCount> | undefined","SKIPPED: unique symbol","results: TResult[]"],"sources":["../src/utils/logger.ts","../src/errors.ts","../src/query/selection.ts","../src/entity/flags.ts","../src/utils/entities.ts","../src/query/errors.ts","../src/query/engine.ts","../src/query/expression.ts","../src/query/builderBase.ts","../src/query/countBuilder.ts","../src/query/queryResult.ts","../src/query/queryBuilder.ts"],"sourcesContent":["const ROOT_NAMESPACE = \"arkiv\"\n\n// Debug logger type - returns a function that can be called to log messages\ntype DebugLogger = (...args: unknown[]) => void\n\n// Get DEBUG environment variable (works in both Node.js and browser)\nfunction getDebugEnv(): string {\n if (typeof process !== \"undefined\") {\n const debugEnv = process?.env?.DEBUG\n if (debugEnv) {\n return debugEnv\n }\n }\n // Browser: check localStorage\n if (typeof globalThis !== \"undefined\" && \"localStorage\" in globalThis) {\n try {\n const storage = (globalThis as { localStorage?: Storage }).localStorage\n return storage?.getItem(\"DEBUG\") || \"\"\n } catch {\n // localStorage might not be available\n }\n }\n return \"\"\n}\n\n// Check if a namespace matches a single positive pattern. Exclusions (\"-pattern\") are handled by\n// isEnabled, which strips the \"-\" and calls this with the rest.\nfunction matchesPattern(namespace: string, pattern: string): boolean {\n // Exact match\n if (pattern === namespace) return true\n\n // Wildcard match: \"arkiv:*\" matches \"arkiv:query\", \"arkiv:rpc\", etc.\n if (pattern.endsWith(\"*\")) {\n const prefix = pattern.slice(0, -1)\n return namespace.startsWith(prefix)\n }\n\n return false\n}\n\n// Check if a namespace is enabled for debugging\nfunction isEnabled(namespace: string): boolean {\n const debugEnv = getDebugEnv()\n if (!debugEnv) return false\n\n // Split by comma/space and check each pattern\n const patterns = debugEnv.split(/[\\s,]+/).filter((p) => p.length > 0)\n\n // If no patterns, nothing is enabled\n if (patterns.length === 0) return false\n\n // Check if any pattern matches (or if explicitly excluded)\n let enabled = false\n for (const pattern of patterns) {\n if (pattern.startsWith(\"-\")) {\n // Exclude pattern: \"-arkiv:query\" disables \"arkiv:query\" whatever else enables it\n if (matchesPattern(namespace, pattern.slice(1))) {\n return false\n }\n } else if (matchesPattern(namespace, pattern)) {\n enabled = true\n }\n }\n\n return enabled\n}\n\n// Color palette for namespace coloring (distinct, readable colors)\nconst COLOR_PALETTE = [\n \"#0000FF\", // blue\n \"#008000\", // green\n \"#FF0000\", // red\n \"#FF00FF\", // magenta\n \"#FFA500\", // orange\n \"#800080\", // purple\n \"#00CED1\", // dark turquoise\n \"#FF1493\", // deep pink\n \"#32CD32\", // lime green\n \"#1E90FF\", // dodger blue\n \"#FF4500\", // orange red\n \"#9370DB\", // medium purple\n \"#00FA9A\", // medium spring green\n \"#FFD700\", // gold\n \"#DC143C\", // crimson\n \"#00BFFF\", // deep sky blue\n \"#FF69B4\", // hot pink\n \"#20B2AA\", // light sea green\n \"#DA70D6\", // orchid\n \"#4682B4\", // steel blue\n]\n\n// Detect if we're in Node.js (for ANSI colors) or browser (for CSS colors)\nconst isNode = typeof process !== \"undefined\" && process.versions?.node != null\n\n// ANSI color codes for Node.js (bright, distinct colors)\nconst ANSI_COLORS = [\n \"\\x1b[94m\", // bright blue\n \"\\x1b[92m\", // bright green\n \"\\x1b[91m\", // bright red\n \"\\x1b[95m\", // bright magenta\n \"\\x1b[93m\", // bright yellow\n \"\\x1b[96m\", // bright cyan\n \"\\x1b[35m\", // magenta\n \"\\x1b[36m\", // cyan\n \"\\x1b[32m\", // green\n \"\\x1b[34m\", // blue\n \"\\x1b[33m\", // yellow\n \"\\x1b[31m\", // red\n \"\\x1b[90m\", // bright black (gray)\n \"\\x1b[37m\", // white\n \"\\x1b[1m\", // bold (as a color option)\n]\n\nconst ANSI_RESET = \"\\x1b[0m\"\nconst ANSI_BOLD = \"\\x1b[1m\"\n\n// Cache colors for namespaces (same namespace = same color)\nconst namespaceColors = new Map<string, { css: string; ansi: string }>()\n\n// Generate a consistent color for a namespace based on its hash\nfunction getColorForNamespace(namespace: string): { css: string; ansi: string } {\n // Check cache first\n const cachedColor = namespaceColors.get(namespace)\n if (cachedColor) {\n return cachedColor\n }\n\n // Simple hash function to convert string to number\n let hash = 0\n for (let i = 0; i < namespace.length; i++) {\n const char = namespace.charCodeAt(i)\n hash = (hash << 5) - hash + char\n hash = hash & hash // Convert to 32-bit integer\n }\n\n // Use absolute value and modulo to get index\n const colorIndex = Math.abs(hash) % COLOR_PALETTE.length\n const cssColor = COLOR_PALETTE[colorIndex] ?? \"inherit\"\n const ansiColor = ANSI_COLORS[colorIndex % ANSI_COLORS.length] ?? \"\"\n\n const color = { css: cssColor, ansi: ansiColor }\n\n // Cache the color\n namespaceColors.set(namespace, color)\n\n return color\n}\n\n// Create a debug logger function\nfunction createDebugLogger(namespace: string): DebugLogger {\n // Get the color for this namespace (consistent across calls)\n const colors = getColorForNamespace(namespace)\n\n return (...args: unknown[]) => {\n if (isEnabled(namespace)) {\n if (isNode) {\n // Node.js: use ANSI color codes\n const coloredNamespace = `${ANSI_BOLD}${colors.ansi}${namespace}${ANSI_RESET}`\n console.log(coloredNamespace, ...args)\n } else {\n // Browser: use CSS styling with %c\n // The format is: console.log(\"%cstyled%cnormal\", style1, style2, ...args)\n // This colors the namespace, then resets for the rest\n const style1 = `color: ${colors.css}; font-weight: bold`\n const style2 = \"color: inherit; font-weight: normal\"\n // Combine namespace with a space, then log with styles\n console.log(`%c${namespace}%c`, style1, style2, ...args)\n }\n }\n }\n}\n\nexport const getLogger = (scope: string): DebugLogger => {\n const namespace = `${ROOT_NAMESPACE}:${scope}`\n return createDebugLogger(namespace)\n}\n","import type { Hex } from \"viem\"\n\nexport class EntityMutationError extends Error {\n readonly txHash: Hex | undefined\n\n constructor(message: string, options?: { cause?: unknown; txHash?: Hex | undefined }) {\n super(message, { cause: options?.cause })\n this.name = \"EntityMutationError\"\n this.txHash = options?.txHash\n }\n}\nexport class NoMoreResultsError extends Error {\n constructor() {\n super(\"No more results — the last page carried no cursor. Check hasNextPage() before next().\")\n this.name = \"NoMoreResultsError\"\n }\n}\n\nexport class NoEntityFoundError extends Error {\n /** The key that matched nothing, when the lookup was by key. */\n readonly entityKey: string | undefined\n\n constructor(entityKey?: string) {\n super(\n entityKey === undefined\n ? \"No entity found\"\n : `No live entity with key ${entityKey}. It was never created, or it has been deleted or ` +\n \"has expired.\",\n )\n this.name = \"NoEntityFoundError\"\n this.entityKey = entityKey\n }\n}\n\nexport class EmptyPatchError extends Error {\n readonly entityKey: string\n\n constructor(entityKey: string) {\n super(\n `The patch for entity ${entityKey} has nothing to apply. Pass \"set\" to write columns, or ` +\n '\"unset\" to remove optional ones.',\n )\n this.name = \"EmptyPatchError\"\n this.entityKey = entityKey\n }\n}\n","import {\n type AnyColumn,\n type ArkivValue,\n type AttributeSchema,\n type Attributes,\n type ColumnsOf,\n describeColumns,\n lookupColumn,\n SCHEMA_ATTRIBUTE,\n type Schema,\n SchemaMismatchError,\n type StrValue,\n type TypeTag,\n type ValueOf,\n validateAttributeName,\n} from \"../schema\"\nimport type { Entity, EntityFields } from \"../types/entity\"\nimport type { RpcSelect } from \"../types/rpcSchema\"\n\n/**\n * The entity fields a row can carry. Each is `$`-prefixed, like the system attributes `where`\n * filters on: an attribute name cannot start with `$`, so no attribute can collide with one.\n */\nexport const SYSTEM_FIELDS = [\n \"$key\",\n \"$owner\",\n \"$creator\",\n \"$createdAt\",\n \"$updatedAt\",\n \"$expiresAt\",\n \"$creationFlags\",\n] as const\n\n/** The name of an entity field a row carries alongside its attributes. */\nexport type SystemField = (typeof SYSTEM_FIELDS)[number]\n\n/** The {@link Entity} property a system field reads. */\ntype EntityField<F extends SystemField> = F extends `$${infer N extends keyof EntityFields}`\n ? N\n : never\n\n/**\n * The keys a selection gives a fixed meaning: the entity fields, plus `$attributes` and\n * `$attributeSchema`, which read an entity's attributes as a whole. Any key without a `$` names an\n * attribute.\n */\nexport type SelectionFields = { [K in SystemField]?: boolean } & {\n /**\n * Attribute names, types and indexing, without their values — a cheap way to find out what\n * entities hold before fetching values that may be large. See {@link AttributeSchema}.\n */\n $attributeSchema?: boolean\n /** Every attribute, as a map keyed by name. */\n $attributes?: boolean\n}\n\n/** The selection keys with a fixed meaning, in the order they are written into the RPC `select`. */\nconst SELECTION_KEYS = [\n ...SYSTEM_FIELDS,\n \"$attributeSchema\",\n \"$attributes\",\n] as const satisfies readonly (keyof SelectionFields)[]\n\n/** A selection key with a fixed meaning. */\ntype SelectionKey = (typeof SELECTION_KEYS)[number]\n\n/**\n * A selection: entity fields, `$attributes` / `$attributeSchema`, and attributes by name, each set\n * to `true` to ask for it. The same selection means the same thing with or without a schema —\n * naming one with `.from(...)` only types and checks the selected attributes, and the filter. A\n * named schema also restricts the query to entities tagged with its name, and leaves the tag out of\n * every row.\n */\nexport type Selection = Readonly<Record<string, boolean | undefined>>\n\n/** Argument accepted by `select()` — a {@link Selection}, or `\"*\"` for everything. */\nexport type SelectArg = Selection | \"*\"\n\n/** Whether a selection value asks for the field: `true` does, `false` and `undefined` do not. */\nexport type Selected<V> = V extends false | undefined ? false : true\n\n/**\n * What a column reads back as: a value of its type, or `undefined` too if the column is optional.\n */\nexport type ColumnValue<C> = C extends {\n readonly type: infer T extends TypeTag\n readonly isOptional: infer O\n}\n ? ValueOf<T> | (true extends O ? undefined : never)\n : never\n\n/**\n * What a selected key reads back as: an entity field as the entity has it, the attributes as a\n * whole, or one attribute — typed by its column through a schema, and any value or none without.\n */\ntype FieldValue<K, TSchema extends Schema | undefined> = K extends SystemField\n ? NonNullable<Entity[EntityField<K>]>\n : K extends \"$attributes\"\n ? Attributes\n : K extends \"$attributeSchema\"\n ? AttributeSchema\n : K extends `$${string}`\n ? never\n : TSchema extends Schema\n ? K extends keyof ColumnsOf<TSchema>\n ? ColumnValue<ColumnsOf<TSchema>[K]>\n : never\n : ArkivValue | undefined\n\n/**\n * One result of selection `S`, through schema `TSchema` or without one: the selected entity fields\n * and attributes side by side, flat. Through a schema each attribute is typed as its column\n * declares; without one it is whatever value the entity holds, or `undefined`. Accessing an\n * unselected field is a compile error.\n *\n * @example\n * // select({ $key: true, title: true }) → { $key: Hex; title: ArkivValue | undefined }\n * // select({ $key: true, title: true }).from(Posts) → { $key: Hex; title: StrValue }\n */\nexport type Row<S, TSchema extends Schema | undefined = undefined> = {\n readonly [K in keyof S as Selected<S[K]> extends true ? K : never]: FieldValue<K, TSchema>\n}\n\n/**\n * What `select()` / `select(\"*\")` selects without a schema: every entity field and every\n * attribute. Not the `$attributeSchema`: its point is learning an entity's shape without fetching\n * its values, so returning it next to every value would only add to the response. It is only\n * returned when asked for by name.\n */\ntype AllSelected = { [K in SystemField | \"$attributes\"]: true }\n\n/**\n * The result when everything is selected without a schema — every entity field, and every\n * attribute as the `$attributes` map. Also what `getEntity(key)` returns.\n */\nexport type FullEntity = Row<AllSelected>\n\n/** The row type when everything is selected through a schema — every entity field and column. */\nexport type FullRow<TSchema extends Schema> = Row<\n { [K in SystemField | keyof ColumnsOf<TSchema>]: true },\n TSchema\n>\n\ndeclare const dynamic: unique symbol\n\n/**\n * The selection type of a builder whose selection is only known at runtime — `select(sel)` with\n * `sel` typed {@link SelectArg} rather than written inline. Nothing about which fields will be\n * present can be known statically, so results are typed with every field optional.\n */\nexport type DynamicSelection = { readonly [dynamic]: true }\n\n/**\n * A result whose selection is only known at runtime: any entity field and any attribute may be\n * absent, because nothing says statically which were selected.\n */\nexport type PartialRow<TSchema extends Schema | undefined = undefined> = {\n readonly [K in SystemField]?: NonNullable<Entity[EntityField<K>]>\n} & {\n readonly $attributes?: Attributes\n readonly $attributeSchema?: AttributeSchema\n} & (TSchema extends Schema\n ? { readonly [K in keyof ColumnsOf<TSchema>]?: ValueOf<ColumnsOf<TSchema>[K][\"type\"]> }\n : { readonly [name: string]: ArkivValue | undefined })\n\n/**\n * Whether which fields `S` selects is only known at runtime: a selection typed {@link SelectArg} or\n * {@link Selection}, or one with a field typed `boolean` rather than `true` or `false`.\n */\ntype IsDynamic<S> = string extends keyof Exclude<S, \"*\">\n ? true\n : S extends \"*\"\n ? false\n : true extends {\n [K in keyof S]: [S[K]] extends [boolean] ? (boolean extends S[K] ? true : false) : false\n }[keyof S]\n ? true\n : false\n\n/**\n * The selection type a query carries for the selection `select()` or `query()` was given: `\"*\"`\n * for everything, {@link DynamicSelection} when the fields are only known at runtime, and the\n * selection itself otherwise.\n */\nexport type SelectionOf<S> = [S] extends [\"*\"]\n ? \"*\"\n : IsDynamic<S> extends true\n ? DynamicSelection\n : S\n\n/**\n * Rejects a selection that asks for nothing at compile time — `{}`, or every field `false`:\n * `unknown` when `S` asks for something, or when that is only known at runtime, and an object no\n * selection satisfies otherwise.\n */\nexport type NonEmptySelection<S> = SelectionOf<S> extends \"*\" | DynamicSelection\n ? unknown\n : [keyof { [K in keyof S as Selected<S[K]> extends true ? K : never]: true }] extends [never]\n ? { \"select() needs at least one field set to true\": true }\n : unknown\n\n/**\n * Rejects a `$` key that is not an entity field, `$attributes` or `$attributeSchema` at compile\n * time. An attribute name cannot start with `$`, so such a key can only be a typo: `unknown` when\n * there is none, and an object naming the offenders, which no selection satisfies, otherwise.\n */\nexport type KnownSystemFields<S> = SelectionOf<S> extends \"*\" | DynamicSelection\n ? unknown\n : [Extract<Exclude<keyof S, SelectionKey>, `$${string}`>] extends [never]\n ? unknown\n : {\n \"selected names that are not entity fields\": Extract<\n Exclude<keyof S, SelectionKey>,\n `$${string}`\n >\n }\n\n/** What a query returns per result — a flat row, typed by the schema when there is one. */\nexport type ResultOf<\n TSelection,\n TSchema extends Schema | undefined,\n> = TSelection extends DynamicSelection\n ? PartialRow<TSchema>\n : TSelection extends \"*\"\n ? TSchema extends Schema\n ? FullRow<TSchema>\n : FullEntity\n : Row<TSelection, TSchema>\n\n/**\n * The keys of a selection that mean nothing through `TSchema` — neither an entity field,\n * `$attributes` / `$attributeSchema`, nor a column. None for a star or a selection only known at\n * runtime, which `from()` checks when it runs instead.\n */\nexport type UnknownSelection<TSelection, TSchema extends Schema> = TSelection extends\n | \"*\"\n | DynamicSelection\n ? never\n : Exclude<keyof TSelection, SelectionKey | keyof ColumnsOf<TSchema>>\n\n/**\n * Converts a selection into the RPC `select` object — the same request {@link projectSelection}\n * makes without a schema.\n *\n * Every field is opt-in — anything not explicitly selected is sent as `false`, including the key.\n * Sending the full object rather than omitting the `false`s keeps what the SDK asked for legible in\n * a request log, and pins the answer even if a node's defaults change.\n *\n * `undefined` or `\"*\"` selects everything.\n *\n * @throws If the selection asks for nothing, or names an attribute outside the name grammar.\n *\n * @example\n * toRpcSelect() // everything\n * toRpcSelect({ $key: true }) // only the key\n * toRpcSelect({ $key: true, projectId: true }) // the key and one attribute\n */\nexport function toRpcSelect(selection?: SelectArg): RpcSelect {\n return projectSelection(selection).select\n}\n\n/**\n * A frozen copy of a selection, so that editing the object passed to `select()` afterwards cannot\n * change what the builder sends.\n */\nexport function snapshotSelection<S extends SelectArg | undefined>(selection: S): S {\n if (typeof selection !== \"object\" || selection === null) return selection\n return Object.freeze({ ...selection }) as S\n}\n\n/**\n * A selection resolved, through a schema or without one: what to ask the node for, and how to lay\n * the answer out.\n */\nexport type Projection = {\n readonly select: RpcSelect\n /** The entity fields each row carries. */\n readonly fields: readonly SystemField[]\n /**\n * The attributes each row carries as fields of their own, by name — each with its column\n * through a schema, which the value is checked against, and `undefined` without one.\n */\n readonly columns: readonly (readonly [name: string, column: AnyColumn | undefined])[]\n /** Whether each row carries the `$attributes` map. */\n readonly attributes: boolean\n /** Whether each row carries the `$attributeSchema`. */\n readonly attributeSchema: boolean\n /** The tag each entity must carry, for a named schema. Checked, never part of the row. */\n readonly tag: StrValue | undefined\n}\n\n/**\n * Resolves a selection, through a schema or without one. A key that does not start with `$` names\n * an attribute — through a schema, it must be a column.\n *\n * `undefined` or `\"*\"` selects every entity field and, through a schema, every column; without one,\n * every attribute as the `$attributes` map. The `$attributeSchema` is only selected by name.\n *\n * Attributes are fetched by name where possible, so the ones a row does not carry stay on the node.\n * A named schema's tag is fetched too, so each entity can be checked against it.\n *\n * @throws If the selection asks for nothing, names a `$` key that is not an entity field, names an\n * attribute outside the name grammar, or — through a schema — names an attribute that is not a\n * column.\n */\nexport function projectSelection(selection?: SelectArg, schema?: Schema): Projection {\n const fields: SystemField[] = []\n const columns: [string, AnyColumn | undefined][] = []\n let attributes = false\n let attributeSchema = false\n\n if (selection === undefined || selection === \"*\") {\n fields.push(...SYSTEM_FIELDS)\n if (schema === undefined) {\n attributes = true\n } else {\n columns.push(...Object.entries(schema.columns))\n }\n } else {\n if (typeof selection !== \"object\" || selection === null || Array.isArray(selection)) {\n throw new TypeError('select() takes \"*\" or an object of fields set to true')\n }\n for (const [name, wanted] of Object.entries(selection)) {\n if (typeof wanted !== \"boolean\" && wanted !== undefined) {\n throw new Error(\n name === \"$attributes\"\n ? 'select() takes true or false for \"$attributes\", which reads every attribute. To ' +\n \"read some of them, select each by name: select({ title: true, body: true }).\"\n : `select() takes true or false for \"${name}\", got ${typeof wanted}.`,\n )\n }\n const fixed = (SELECTION_KEYS as readonly string[]).includes(name)\n if (!fixed && name.startsWith(\"$\")) {\n throw new Error(\n `select() names \"${name}\", which is not an entity field. The entity fields are ` +\n `${SYSTEM_FIELDS.join(\", \")}, and $attributes and $attributeSchema read the ` +\n \"attributes as a whole.\",\n )\n }\n const column = fixed || schema === undefined ? undefined : lookupColumn(schema, name)\n if (!fixed) {\n if (schema !== undefined && column === undefined) {\n throw new Error(\n `select() names \"${name}\", which is not a column of the schema. Its columns are ` +\n `${describeColumns(schema)}.`,\n )\n }\n validateAttributeName(name)\n }\n if (!wanted) continue\n if (name === \"$attributes\") attributes = true\n else if (name === \"$attributeSchema\") attributeSchema = true\n else if (fixed) fields.push(name as SystemField)\n else columns.push([name, column])\n }\n // Rejects both `{}` and a selection whose fields are all explicitly `false` — the type system\n // permits `select({ $key: false })`, and the node would answer it with a page of empty objects.\n if (fields.length === 0 && columns.length === 0 && !attributes && !attributeSchema) {\n throw nothingSelected()\n }\n }\n\n const select: RpcSelect = {}\n for (const field of SYSTEM_FIELDS) select[entityField(field)] = fields.includes(field)\n select.attributeSchema = attributeSchema\n if (attributes) {\n select.attributes = true\n } else {\n const names = new Set(columns.map(([name]) => name))\n if (schema?.tag !== undefined) names.add(SCHEMA_ATTRIBUTE)\n select.attributes =\n names.size > 0 ? Object.fromEntries([...names].map((n) => [n, true])) : false\n }\n return { select, fields, columns, attributes, attributeSchema, tag: schema?.tag }\n}\n\n/**\n * Lays an entity out as a row of `projection` — checking it against the schema, when there is one.\n *\n * @throws {SchemaMismatchError} If a named schema's entity is not tagged with its name, or the\n * entity lacks a selected required column or holds one with a type other than the schema's — it\n * was not written through this schema, or was patched since.\n */\nexport function toRow(entity: Entity, projection: Projection): Record<string, unknown> {\n const subject = entity.key === undefined ? \"the entity\" : `entity ${entity.key}`\n\n const { tag } = projection\n if (tag !== undefined) {\n const found = attributeOf(entity, SCHEMA_ATTRIBUTE)\n if (found?.type !== \"str\" || found.value !== tag.value) {\n throw new SchemaMismatchError(\n SCHEMA_ATTRIBUTE,\n `${subject} is ${describeTag(found)}, not ${JSON.stringify(tag.value)}, so it was not ` +\n \"written through this schema\",\n )\n }\n }\n\n const row: Record<string, unknown> = {}\n for (const field of projection.fields) row[field] = entity[entityField(field)]\n\n for (const [name, column] of projection.columns) {\n const value = attributeOf(entity, name)\n if (column !== undefined) {\n if (value === undefined) {\n if (!column.isOptional) {\n throw new SchemaMismatchError(\n name,\n `${subject} has no value for this required ${column.type} column, so it does not ` +\n \"match the schema. Declare the column .optional() if entities may leave it unset\",\n )\n }\n } else if (value.type !== column.type) {\n throw new SchemaMismatchError(\n name,\n `${subject} holds a ${value.type}, not the ${column.type} the schema declares`,\n )\n }\n }\n row[name] = value\n }\n\n if (projection.attributes) {\n row.$attributes = withoutTag(entity.attributes ?? {}, tag)\n }\n if (projection.attributeSchema) {\n row.$attributeSchema = withoutTag(entity.attributeSchema ?? {}, tag)\n }\n return row\n}\n\n/** The {@link Entity} property, and RPC `select` key, a system field reads: its name without `$`. */\nfunction entityField<F extends SystemField>(field: F): EntityField<F> {\n return field.slice(1) as EntityField<F>\n}\n\n/**\n * A copy of `record` without a named schema's tag: the tag is how a query finds the schema's\n * entities, not one of their attributes, so a row never carries it — and a map read back from a\n * row drops into a write without sending the reserved name.\n */\nfunction withoutTag<T>(record: Readonly<Record<string, T>>, tag: StrValue | undefined) {\n if (tag === undefined || !Object.hasOwn(record, SCHEMA_ATTRIBUTE)) return record\n const { [SCHEMA_ATTRIBUTE]: _tag, ...rest } = record\n return rest\n}\n\n/**\n * The entity's attribute `name`, or `undefined` if it has none. An own-property read: a column may\n * be named `constructor` or `toString`, and an entity that leaves it unset must not find the\n * inherited one instead.\n */\nfunction attributeOf(entity: Entity, name: string): ArkivValue | undefined {\n const { attributes } = entity\n return attributes !== undefined && Object.hasOwn(attributes, name) ? attributes[name] : undefined\n}\n\n/** How an entity's schema tag reads in a mismatch — whatever type another writer gave it. */\nfunction describeTag(found: ArkivValue | undefined): string {\n if (found === undefined) return \"not tagged with a schema\"\n if (found.type === \"str\") return `tagged ${JSON.stringify(found.value)}`\n return `tagged with a value of type ${found.type}`\n}\n\nfunction nothingSelected(): Error {\n return new Error(\n 'select() requires at least one field to be selected. Pass select() or select(\"*\") to select everything.',\n )\n}\n","import { InvalidCreationFlagsError } from \"./errors\"\n\n/** Bit positions in the `creationFlags` byte. Bits 2-7 are reserved and must be zero. */\nconst READONLY_BIT = 0b0000_0001\nconst PERMISSIONLESS_EXTENSION_BIT = 0b0000_0010\n\n/**\n * The immutable properties an entity is created with. Both default to `false`.\n *\n * Creation flags are fixed at creation: there is no operation that changes them, so an entity is\n * whatever it was created as for its whole life.\n */\nexport type CreationFlags = {\n /**\n * The entity's attributes can never be changed — only its expiry extended, its\n * ownership transferred, and the entity deleted.\n */\n readonly?: boolean\n /**\n * Anyone, not just the owner, may extend the entity's expiry. Lets a third party keep something\n * alive without being able to change it.\n */\n permissionlessExtension?: boolean\n}\n\n/** {@link CreationFlags} as read back, with every flag resolved and the raw byte alongside. */\nexport type ResolvedCreationFlags = {\n readonly: boolean\n permissionlessExtension: boolean\n raw: number\n}\n\n/**\n * Packs creation flags into the `creationFlags` byte.\n *\n * @throws {InvalidCreationFlagsError} If a value is not a boolean.\n */\nexport function encodeCreationFlags(flags: CreationFlags = {}): number {\n for (const [name, value] of Object.entries(flags)) {\n if (value !== undefined && typeof value !== \"boolean\") {\n throw new InvalidCreationFlagsError(`\"${name}\" must be a boolean, got ${typeof value}`)\n }\n }\n return (\n (flags.readonly ? READONLY_BIT : 0) |\n (flags.permissionlessExtension ? PERMISSIONLESS_EXTENSION_BIT : 0)\n )\n}\n\n/**\n * Reads the `creationFlags` byte back.\n *\n * @param raw - The `creationFlags` byte.\n * @throws {InvalidCreationFlagsError} Malformed input\n */\nexport function decodeCreationFlags(raw: number): ResolvedCreationFlags {\n if (!Number.isInteger(raw) || raw < 0 || raw > 0xff) {\n throw new InvalidCreationFlagsError(`${raw} is not a byte`)\n }\n return {\n readonly: (raw & READONLY_BIT) !== 0,\n permissionlessExtension: (raw & PERMISSIONLESS_EXTENSION_BIT) !== 0,\n raw,\n }\n}\n","import { checksumAddress, type Hex } from \"viem\"\nimport {\n decodeCreationFlags,\n encodeCreationFlags,\n type ResolvedCreationFlags,\n} from \"../entity/flags\"\nimport type { AttributeSchema, Attributes } from \"../schema\"\n// Internal seam: the JSON-RPC decoder is not part of the package's public surface.\nimport { asTypeTag, decodeRpcValue } from \"../schema/codec\"\nimport { Entity, type EntityFields } from \"../types/entity\"\nimport type { RpcEntity } from \"../types/rpcSchema\"\nimport { getLogger } from \"./logger\"\n\nconst logger = getLogger(\"utils:entities\")\n\n/**\n * Turns the attribute array a query returns into a name-keyed map of typed values.\n *\n * Attribute names are unique per entity, so the map loses nothing and gives callers\n * `entity.attributes.level.value` instead of a linear search.\n */\nfunction decodeAttributes(rpcAttributes: NonNullable<RpcEntity[\"attributes\"]>): Attributes {\n const attributes: Record<string, ReturnType<typeof decodeRpcValue>> = {}\n for (const { name, type, value } of rpcAttributes) {\n attributes[name] = decodeRpcValue(type, value)\n }\n return attributes\n}\n\n/** The same, for the values-free `attributeSchema` projection. */\nfunction decodeSchema(entries: NonNullable<RpcEntity[\"attributeSchema\"]>): AttributeSchema {\n const schema: Record<string, AttributeSchema[string]> = {}\n for (const { name, type, indexed } of entries) {\n schema[name] = {\n type: asTypeTag(type),\n indexed: typeof indexed === \"boolean\" ? indexed : undefined,\n }\n }\n return schema\n}\n\n/**\n * Builds an {@link Entity} from a query result row.\n *\n * A field the query did not select is absent from the response and stays `undefined` here — the\n * decoder never substitutes an empty value for one that was not asked for.\n */\nexport function entityFromRpcResult(rpcEntity: RpcEntity): Entity {\n logger(\"entityFromRpcResult %o\", rpcEntity)\n\n const fields: EntityFields = {\n key: rpcEntity.key,\n owner: toAddress(rpcEntity.owner),\n creator: toAddress(rpcEntity.creator),\n createdAt: toBlock(rpcEntity.createdAt),\n updatedAt: toBlock(rpcEntity.updatedAt),\n expiresAt: toBlock(rpcEntity.expiresAt),\n creationFlags: decodeFlags(rpcEntity.creationFlags),\n attributeSchema:\n rpcEntity.attributeSchema !== undefined ? decodeSchema(rpcEntity.attributeSchema) : undefined,\n attributes:\n rpcEntity.attributes !== undefined ? decodeAttributes(rpcEntity.attributes) : undefined,\n }\n\n return new Entity(fields)\n}\n\nfunction toBlock(value: string | undefined): bigint | undefined {\n return value === undefined ? undefined : BigInt(value)\n}\n\nfunction toAddress(value: Hex | undefined): Hex | undefined {\n if (value === undefined) return undefined\n if (!/^0x[0-9a-fA-F]{40}$/.test(value)) {\n logger(\"unreadable address %o\", value)\n return value\n }\n return checksumAddress(value)\n}\n\n/**\n * Resolves the `creationFlags` projection, preferring the byte.\n */\nfunction decodeFlags(\n value: NonNullable<RpcEntity[\"creationFlags\"]> | undefined,\n): ResolvedCreationFlags | undefined {\n if (value === undefined) return undefined\n\n const raw = toFlagsByte(typeof value === \"number\" ? value : value.raw)\n if (raw !== undefined) return decodeCreationFlags(raw)\n\n if (\n typeof value === \"object\" &&\n (value.readonly ?? value.permissionlessExtension) !== undefined\n ) {\n return decodeCreationFlags(\n encodeCreationFlags({\n readonly: value.readonly ?? false,\n permissionlessExtension: value.permissionlessExtension ?? false,\n }),\n )\n }\n\n logger(\"unreadable creationFlags %o\", value)\n return undefined\n}\n\n/**\n * A flags byte in whichever spelling arrived: a JSON number, or the `0x` QUANTITY that every other\n * numeric field on {@link RpcEntity} already uses. `undefined` for anything that is not a byte.\n */\nfunction toFlagsByte(value: unknown): number | undefined {\n const parsed =\n typeof value === \"number\"\n ? value\n : typeof value === \"string\" && /^(0x[0-9a-fA-F]+|\\d+)$/.test(value)\n ? Number(value)\n : Number.NaN\n return Number.isInteger(parsed) && parsed >= 0 && parsed <= 0xff ? parsed : undefined\n}\n","import type { TypeTag } from \"../schema\"\n\n/**\n * A predicate asked for an operator the query language does not define for that type.\n *\n * The operator × type matrix is part of the language, not a policy: a prefix test on a type other\n * than `str` is a **type error** at the node (a {@link QueryError} of kind `\"type\"`), not\n * an empty result. Catching it here turns a round trip and an RPC error code into a stack trace\n * pointing at the call site.\n *\n * | | `=` `!=` `<` `<=` `>` `>=` `BETWEEN` | `STARTSWITH` |\n * | --- | --- | --- |\n * | `str` | yes | yes |\n * | every other indexable type | yes | no |\n */\nexport class UnsupportedOperatorError extends Error {\n /** The attribute the predicate names. */\n readonly attributeName: string\n /** The operator, as it would have been written in the query. */\n readonly operator: string\n /** The type of the value it was applied to. */\n readonly tag: TypeTag\n\n constructor(attributeName: string, operator: string, tag: TypeTag, hint?: string) {\n super(\n `The query language does not define ${operator} for a ${tag}, so \"${attributeName} ` +\n `${operator} ...\" cannot be expressed.${hint ? ` ${hint}` : \"\"}`,\n )\n this.name = \"UnsupportedOperatorError\"\n this.attributeName = attributeName\n this.operator = operator\n this.tag = tag\n }\n}\n\n/**\n * A predicate or query could not be expressed in the query language for a reason other than its\n * operator. The main causes:\n *\n * - a `$` name that is not a queryable system attribute — one returned in results but never\n * indexed (`$createdAt`, `$updatedAt`, `$creationFlags`), or none at all;\n * - a system attribute compared against the wrong type, or tested with `exists()` / `hasType()`,\n * which on a system attribute would be constants;\n * - a comparison against a `bytes` value, which is never indexed;\n * - a `BETWEEN` whose bounds have different types;\n * - a `hasType()` tag that is not an indexable type;\n * - a combinator with nothing to combine;\n * - a query with no filter at all — a named schema's tag counts as one;\n * - through `.from(schema)`, a filter that does not fit the schema: a name that is not a column, a\n * column that is not indexed, or a value of another type than the column's.\n */\nexport class InvalidPredicateError extends Error {\n /** The attribute the predicate names, where there is one. */\n readonly attributeName: string | undefined\n\n constructor(message: string, attributeName?: string) {\n super(message)\n this.name = \"InvalidPredicateError\"\n this.attributeName = attributeName\n }\n}\n\n/**\n * What a node rejected a query for. Part of the frozen RPC surface, so it is safe to branch on —\n * a `\"cursor\"` failure means start the query again, a `\"block\"` failure means the node no longer\n * retains that height, and the rest mean the query itself needs fixing.\n */\nexport type QueryErrorKind =\n /** The query string does not parse. `data` locates it: `{ position, expected, got }`. */\n | \"parse\"\n /** A predicate is well-formed but ill-typed — `STARTSWITH` on a type other than `str`, `BETWEEN` bounds of different types, an unknown tag. */\n | \"type\"\n /** A literal failed validation — an `i32` out of range, a bad EIP-55 checksum, more than 18 decimal places. */\n | \"literal\"\n /** A node budget was exceeded — query length, predicate count, nesting depth, bitmap operations. */\n | \"limits\"\n /** The cursor expired, is malformed, or belongs to a different query, block or selection. */\n | \"cursor\"\n /** `atBlock` is outside the range the node retains. */\n | \"block\"\n\n/** The JSON-RPC error codes `arkiv_query` answers with, and what each one means. */\nconst QUERY_ERROR_KINDS: Readonly<Record<number, QueryErrorKind>> = {\n [-32001]: \"parse\",\n [-32002]: \"type\",\n [-32003]: \"literal\",\n [-32004]: \"limits\",\n [-32005]: \"cursor\",\n [-32006]: \"block\",\n}\n\n/**\n * The node rejected a query.\n *\n * These codes are part of the frozen `arkiv_query` surface, so {@link kind} and {@link data} are\n * stable enough to branch on — which the underlying JSON-RPC error is not, because the codes\n * overlap Ethereum's own EIP-1474 numbering and get wrapped accordingly on the way up.\n *\n * @example\n * try {\n * await result.next()\n * } catch (error) {\n * if (error instanceof QueryError && error.kind === \"cursor\") {\n * // The page is gone — start the query over.\n * }\n * }\n */\nexport class QueryError extends Error {\n /** Which failure this is. */\n readonly kind: QueryErrorKind\n /** The JSON-RPC error code. */\n readonly code: number\n /** The machine-readable detail the node sent, if any — e.g. `{ position, expected, got }`. */\n readonly data: unknown\n /** The query string that was rejected. */\n readonly query: string\n\n constructor(kind: QueryErrorKind, code: number, query: string, data: unknown, detail?: string) {\n super(`Query rejected (${kind}, ${code})${detail ? `: ${detail}` : \"\"}. Query: ${query}`, {\n cause: data,\n })\n this.name = \"QueryError\"\n this.kind = kind\n this.code = code\n this.data = data\n this.query = query\n }\n}\n\n/**\n * Recognises an `arkiv_query` failure in whatever the transport threw.\n *\n * The codes are dug out of the error chain rather than read off the top: viem maps this range onto\n * its own EIP-1474 error classes (`-32001` is its \"resource not found\"), so by the time an error\n * surfaces the Arkiv meaning is one or more `cause` links down.\n *\n * @returns The typed error, or `undefined` if this was not a query rejection.\n */\nexport function asQueryError(error: unknown, query: string): QueryError | undefined {\n let code: number | undefined\n let data: unknown\n let detail: string | undefined\n\n let current: unknown = error\n for (let depth = 0; current != null && depth < 8; depth++) {\n const link = current as {\n code?: unknown\n data?: unknown\n shortMessage?: unknown\n cause?: unknown\n }\n if (code === undefined && typeof link.code === \"number\") code = link.code\n if (data === undefined && link.data !== undefined) data = link.data\n if (detail === undefined && typeof link.shortMessage === \"string\") detail = link.shortMessage\n current = link.cause\n }\n\n const kind = code === undefined ? undefined : QUERY_ERROR_KINDS[code]\n if (kind === undefined || code === undefined) return undefined\n return new QueryError(kind, code, query, data, detail)\n}\n","import { numberToHex } from \"viem\"\nimport type { ArkivClient } from \"../clients/baseClient\"\nimport type { Entity } from \"../types/entity\"\nimport type { RpcQueryOptions, RpcSelect } from \"../types/rpcSchema\"\nimport { entityFromRpcResult } from \"../utils/entities\"\nimport { getLogger } from \"../utils/logger\"\nimport { asQueryError } from \"./errors\"\n\nconst logger = getLogger(\"query:engine\")\n\nexport const MAX_LIMIT = 100\n\n/** One `arkiv_query` call. */\nexport type QueryRequest = {\n /** The query expression, already rendered. */\n query: string\n /** What to return. */\n select: RpcSelect\n /** Page size, up to {@link MAX_LIMIT}. Defaults to the node's own page size. */\n limit?: number | undefined\n /** Cursor from a previous page. */\n cursor?: string | undefined\n /** Block height to read at. Defaults to the head. */\n atBlock?: bigint | undefined\n /** Whether to also count every entity the query matches. */\n count?: boolean | undefined\n}\n\n/** One page of results. */\nexport type QueryResponse = {\n entities: Entity[]\n /** The block the page was read at — the same for every page of a paginated query. */\n blockNumber: bigint\n /** The cursor for the next page, or `undefined` when this was the last one. */\n cursor: string | undefined\n /** How many entities the query matches, if the request asked to count them. */\n count: bigint | undefined\n}\n\n/**\n * Runs one query and decodes the page it returns.\n *\n * @throws If `limit` is not an integer from 1 to {@link MAX_LIMIT}.\n * @throws {QueryError} If the node rejects the query.\n */\nexport async function runQuery(client: ArkivClient, request: QueryRequest): Promise<QueryResponse> {\n const { query, select, limit, cursor, atBlock, count } = request\n\n if (limit !== undefined) {\n if (!Number.isInteger(limit) || limit < 1) {\n throw new Error(`limit must be a positive integer, got ${limit}.`)\n }\n if (limit > MAX_LIMIT) {\n throw new Error(\n `limit ${limit} exceeds the node maximum of ${MAX_LIMIT}. Page through the results with ` +\n \"the cursor instead.\",\n )\n }\n }\n\n const queryOptions: RpcQueryOptions = {\n select: count ? { ...select, count: true } : select,\n ...(atBlock !== undefined && { atBlock: numberToHex(atBlock) }),\n ...(limit !== undefined && { limit: numberToHex(limit) }),\n ...(cursor !== undefined && { cursor }),\n }\n\n logger(\"arkiv_query %s %o\", query, queryOptions)\n\n const result = await client\n .request({ method: \"arkiv_query\", params: [query, queryOptions] })\n .catch((error: unknown) => {\n throw asQueryError(error, query) ?? error\n })\n\n logger(\"Raw result from query %o\", result)\n\n return {\n entities: result.data.map((rpcEntity) => entityFromRpcResult(rpcEntity)),\n blockNumber: BigInt(result.blockNumber),\n cursor: result.cursor,\n count: result.count === undefined ? undefined : BigInt(result.count),\n }\n}\n","import {\n type ColumnsOf,\n describeColumns,\n type IndexableTypeTag,\n type IndexableValue,\n type IndexedColumnName,\n lookupColumn,\n type Schema,\n type StrValue,\n str,\n type TagOf,\n type TypeTag,\n toValue,\n validateAttributeName,\n} from \"../schema\"\n// Internal seam: the typeId table is the protocol's, not part of the package's public surface.\nimport { isIndexable, TYPE_IDS } from \"../schema/types\"\nimport { InvalidPredicateError, UnsupportedOperatorError } from \"./errors\"\n\n/**\n * The comparison operators the query language defines. Every indexable type accepts all of them;\n * `<` `<=` `>` `>=` compare in index order — numerically for `i32`, `u64`, `u256` and `dec`,\n * `false < true` for `bool`, and by unsigned bytes for `str`, `bytes32`, `addr` and `key`.\n */\nexport type ComparisonOperator = \"=\" | \"!=\" | \"<\" | \"<=\" | \">\" | \">=\"\n\n/**\n * A value a predicate can compare against: a value of any indexable type, or a bare boolean,\n * number, bigint or string. `bytes` is excluded — it is never indexed, so never filterable.\n */\nexport type PredicateValue = IndexableValue | boolean | number | bigint | string\n\n/**\n * `between`'s check that both bounds have one type — `unknown` when they do, and otherwise an\n * object whose one property is named after the problem. No value has that property, so the\n * compiler reports the sentence as the property it is missing.\n */\ntype SameTypeCheck<L, H> = [TagOf<L>, TagOf<H>] extends [TagOf<H>, TagOf<L>]\n ? unknown\n : { [K in `BETWEEN bounds must have one type, got ${TagOf<L>} and ${TagOf<H>}`]: never }\n\n/**\n * The attribute a predicate names, and the type it asserts — `never` when it asserts none, as\n * `EXISTS` does. Carried by an {@link Expression} at the type level only, so a query against a\n * schema can be checked at compile time: every name must be an indexed column, and every type the\n * column's.\n */\nexport type AttributeRef = { readonly name: string; readonly type: IndexableTypeTag }\n\ndeclare const refs: unique symbol\n\n/** The type-level record of the attributes an expression names. Never present at runtime. */\ntype Refs<R extends AttributeRef> = { readonly [refs]?: R }\n\n/** A comparison between an attribute and a typed literal. */\nexport interface ComparisonNode<R extends AttributeRef = AttributeRef> extends Refs<R> {\n readonly kind: \"comparison\"\n readonly name: string\n readonly operator: ComparisonOperator\n readonly value: IndexableValue\n}\n\n/** An inclusive range test, `name BETWEEN low AND high`. Both bounds have one type. */\nexport interface BetweenNode<R extends AttributeRef = AttributeRef> extends Refs<R> {\n readonly kind: \"between\"\n readonly name: string\n readonly low: IndexableValue\n readonly high: IndexableValue\n}\n\n/** A `STARTSWITH` prefix test, the language's only pattern operator. */\nexport interface StartsWithNode<R extends AttributeRef = AttributeRef> extends Refs<R> {\n readonly kind: \"startsWith\"\n readonly name: string\n readonly value: StrValue\n}\n\n/** An `EXISTS(name)` test — true when the attribute is set with any type. */\nexport interface ExistsNode<R extends AttributeRef = AttributeRef> extends Refs<R> {\n readonly kind: \"exists\"\n readonly name: string\n}\n\n/** A `TYPEOF(name) = tag` test. */\nexport interface TypeOfNode<R extends AttributeRef = AttributeRef> extends Refs<R> {\n readonly kind: \"typeOf\"\n readonly name: string\n readonly tag: IndexableTypeTag\n}\n\n/** The complement of an expression, evaluated against the active-entity set. */\nexport interface NotNode<R extends AttributeRef = AttributeRef> extends Refs<R> {\n readonly kind: \"not\"\n readonly expression: Expression\n}\n\n/** A conjunction. */\nexport interface AndNode<R extends AttributeRef = AttributeRef> extends Refs<R> {\n readonly kind: \"and\"\n readonly expressions: readonly Expression[]\n}\n\n/** A disjunction. */\nexport interface OrNode<R extends AttributeRef = AttributeRef> extends Refs<R> {\n readonly kind: \"or\"\n readonly expressions: readonly Expression[]\n}\n\n/**\n * A query expression: an immutable tree built by the combinators below, whose `toString()` is the\n * exact query string sent over the wire.\n *\n * @typeParam R - The attributes the expression names, as {@link AttributeRef}s — inferred by the\n * combinators, and checked against the schema by `select(...).from(schema).where(...)`.\n *\n * @example\n * const q = and(gte(\"level\", i32(10)), or(eq(\"status\", str(\"open\")), not(exists(\"closedAt\"))))\n * String(q) // level >= i32(10) AND (status = str('open') OR NOT EXISTS(closedAt))\n */\nexport type Expression<R extends AttributeRef = AttributeRef> =\n | ComparisonNode<R>\n | BetweenNode<R>\n | StartsWithNode<R>\n | ExistsNode<R>\n | TypeOfNode<R>\n | NotNode<R>\n | AndNode<R>\n | OrNode<R>\n\n/** The attributes an expression names — the `R` of an {@link Expression}. */\nexport type RefsOf<E> = E extends Refs<infer R> ? Exclude<R, undefined> : never\n\n/** The reference a comparison against `V` makes to `N`. */\ntype ValueRef<N extends string, V> = {\n readonly name: N\n readonly type: TagOf<V> & IndexableTypeTag\n}\n\n/**\n * The system attributes a query may filter on, and the type each one carries.\n *\n * Every other system attribute (`$createdAt`, `$updatedAt`, `$creationFlags`) is returned in\n * query results — selected and read back as `createdAt`, `updatedAt` and `creationFlags` — but is\n * not indexed, so it cannot appear in a predicate.\n */\nconst QUERYABLE_SYSTEM_ATTRIBUTES = {\n $key: \"key\",\n $owner: \"addr\",\n $creator: \"addr\",\n $expiresAt: \"u64\",\n} as const satisfies Record<string, TypeTag>\n\ntype SystemAttributeName = keyof typeof QUERYABLE_SYSTEM_ATTRIBUTES\n\n/** The references a filter on a system attribute makes — each with its fixed type. */\nexport type SystemAttributeRef = {\n [N in SystemAttributeName]: {\n readonly name: N\n readonly type: (typeof QUERYABLE_SYSTEM_ATTRIBUTES)[N]\n }\n}[SystemAttributeName]\n\n/**\n * The references a filter through schema `S` may make: each indexed column with its declared\n * type, and the queryable system attributes with theirs. An {@link Expression} naming anything else\n * is a compile error in `select(...).from(S).where(...)`.\n */\nexport type SchemaRef<S extends Schema> =\n | {\n [K in IndexedColumnName<S>]: {\n readonly name: K\n readonly type: ColumnsOf<S>[K][\"type\"] & IndexableTypeTag\n }\n }[IndexedColumnName<S>]\n | SystemAttributeRef\n\n/** System attributes a query can ask for but not filter on — they carry no index. */\nconst RESULT_ONLY_SYSTEM_ATTRIBUTES = [\"$createdAt\", \"$updatedAt\", \"$creationFlags\"]\n\n/**\n * Checks an attribute reference, returning its fixed type when it names a system attribute.\n *\n * User attribute names go through the same grammar the write path enforces, so a name that could\n * never have been written is rejected here rather than matching nothing.\n */\nfunction resolveReference(name: string): TypeTag | undefined {\n if (typeof name !== \"string\" || !name.startsWith(\"$\")) {\n validateAttributeName(name)\n return undefined\n }\n const system = QUERYABLE_SYSTEM_ATTRIBUTES[name as SystemAttributeName]\n if (system !== undefined) return system\n\n if (RESULT_ONLY_SYSTEM_ATTRIBUTES.includes(name)) {\n // Selected, and read back, as the entity field of the same name without the `$`.\n const field = name.slice(1)\n throw new InvalidPredicateError(\n `\"${name}\" is returned in query results but carries no index, so it cannot be filtered ` +\n `on. Select it as \\`${field}\\` and filter the results in JavaScript instead.`,\n name,\n )\n }\n throw new InvalidPredicateError(\n `\"${name}\" is not a system attribute. The queryable ones are ` +\n `${Object.keys(QUERYABLE_SYSTEM_ATTRIBUTES).join(\", \")}. ` +\n '\"$\" is reserved for these, so a user attribute cannot be named this.',\n name,\n )\n}\n\n/**\n * Whether a string names a type that can be indexed — every type but `bytes`.\n *\n * Takes a `string` rather than an `IndexableTypeTag` on purpose — the callers' static types\n * already say as much, and this is the runtime check for the code that has no types.\n */\nfunction isIndexableTag(tag: string): tag is IndexableTypeTag {\n // `Object.hasOwn` rather than `in`, which would also accept every Object.prototype key.\n return Object.hasOwn(TYPE_IDS, tag) && isIndexable(tag as TypeTag)\n}\n\n/** Freezes a node and gives it a (non-enumerable, so still `toEqual`-able) rendering. */\nfunction node<T extends Expression>(value: T): T {\n Object.defineProperty(value, \"toString\", {\n value: () => render(value),\n enumerable: false,\n })\n return Object.freeze(value)\n}\n\n/**\n * Resolves a value a predicate compares `name` against, and checks it can be: not `bytes`, which is\n * never indexed, and of the fixed type when `name` is a system attribute.\n */\nfunction predicateValue(\n name: string,\n system: TypeTag | undefined,\n input: PredicateValue,\n): IndexableValue {\n const value = toValue(input, name)\n if (value.type === \"bytes\") {\n throw new InvalidPredicateError(\n `\"${name}\" is compared against a bytes value, and bytes are stored but never indexed, so ` +\n \"they cannot be filtered on. Index a str, bytes32 or key derived from them instead.\",\n name,\n )\n }\n if (system !== undefined && value.type !== system) {\n throw new InvalidPredicateError(\n `\"${name}\" is a ${system}, but the value is a ${value.type}. ` +\n `System attributes have a fixed type — write ${system}(...) around the value.`,\n name,\n )\n }\n return value\n}\n\nfunction comparison<R extends AttributeRef>(\n name: string,\n operator: ComparisonOperator,\n input: PredicateValue,\n): ComparisonNode<R> {\n const value = predicateValue(name, resolveReference(name), input)\n return node({ kind: \"comparison\", name, operator, value })\n}\n\n/**\n * Attribute equals value — set with this exact type, and holding this value.\n *\n * Bare booleans, numbers, bigints and strings take the same default types they take when written\n * (`number` is an `i32`, `bigint` a `u256`, `string` a `str`); anything else names its type.\n *\n * @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.\n * @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system\n * attribute, a system attribute is compared against the wrong type, or the value is `bytes`.\n *\n * @example\n * eq(\"status\", str(\"open\")) // status = str('open')\n * eq(\"flagged\", true) // flagged = true\n * eq(\"$owner\", addr(account)) // $owner = addr(0xd8dA…)\n */\nexport function eq<N extends string, V extends PredicateValue>(\n name: N,\n value: V,\n): ComparisonNode<ValueRef<N, V>> {\n return comparison(name, \"=\", value)\n}\n\n/**\n * Attribute is set with this type and holds a **different** value.\n *\n * This is typed value-negation, not the complement: an entity that never set the attribute, or set\n * it with another type, does not match. Use `not(eq(...))` for the full complement.\n *\n * @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.\n * @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system\n * attribute, a system attribute is compared against the wrong type, or the value is `bytes`.\n *\n * @example\n * ne(\"status\", str(\"closed\")) // status != str('closed')\n * not(eq(\"status\", str(\"closed\"))) // NOT status = str('closed') — also matches entities with no status\n */\nexport function ne<N extends string, V extends PredicateValue>(\n name: N,\n value: V,\n): ComparisonNode<ValueRef<N, V>> {\n return comparison(name, \"!=\", value)\n}\n\n/**\n * Attribute is greater than value, in index order — see {@link ComparisonOperator}.\n *\n * @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.\n * @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system\n * attribute, a system attribute is compared against the wrong type, or the value is `bytes`.\n *\n * @example\n * gt(\"level\", i32(10)) // level > i32(10)\n * gt(\"$expiresAt\", u64(1_200_000n)) // $expiresAt > u64(1200000)\n */\nexport function gt<N extends string, V extends PredicateValue>(\n name: N,\n value: V,\n): ComparisonNode<ValueRef<N, V>> {\n return comparison(name, \">\", value)\n}\n\n/**\n * Attribute is greater than or equal to value, in index order — see {@link ComparisonOperator}.\n *\n * @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.\n * @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system\n * attribute, a system attribute is compared against the wrong type, or the value is `bytes`.\n *\n * @example\n * gte(\"score\", dec(\"3.5\")) // score >= dec(3.5)\n */\nexport function gte<N extends string, V extends PredicateValue>(\n name: N,\n value: V,\n): ComparisonNode<ValueRef<N, V>> {\n return comparison(name, \">=\", value)\n}\n\n/**\n * Attribute is less than value, in index order — see {@link ComparisonOperator}.\n *\n * @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.\n * @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system\n * attribute, a system attribute is compared against the wrong type, or the value is `bytes`.\n *\n * @example\n * lt(\"level\", i32(10)) // level < i32(10)\n */\nexport function lt<N extends string, V extends PredicateValue>(\n name: N,\n value: V,\n): ComparisonNode<ValueRef<N, V>> {\n return comparison(name, \"<\", value)\n}\n\n/**\n * Attribute is less than or equal to value, in index order — see {@link ComparisonOperator}.\n *\n * @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.\n * @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system\n * attribute, a system attribute is compared against the wrong type, or the value is `bytes`.\n *\n * @example\n * lte(\"score\", dec(\"5\")) // score <= dec(5)\n */\nexport function lte<N extends string, V extends PredicateValue>(\n name: N,\n value: V,\n): ComparisonNode<ValueRef<N, V>> {\n return comparison(name, \"<=\", value)\n}\n\n/**\n * Attribute lies between two values, **inclusive** at both ends: it matches exactly what\n * `and(gte(name, low), lte(name, high))` matches, in one predicate. Both bounds must have one type,\n * and a `low` above `high` matches nothing.\n *\n * @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.\n * @throws {InvalidPredicateError} If the bounds have different types, the name starts with `$` but\n * is not a queryable system attribute, a system attribute is compared against the wrong type, or a\n * bound is `bytes`.\n *\n * @example\n * between(\"score\", dec(\"3.5\"), dec(\"5\")) // score BETWEEN dec(3.5) AND dec(5)\n * between(\"$expiresAt\", u64(100n), u64(200n))\n */\nexport function between<N extends string, L extends PredicateValue, H extends PredicateValue>(\n name: N,\n low: L,\n high: H & SameTypeCheck<L, H>,\n): BetweenNode<ValueRef<N, L>> {\n const system = resolveReference(name)\n const lowValue = predicateValue(name, system, low)\n const highValue = predicateValue(name, system, high)\n if (lowValue.type !== highValue.type) {\n throw new InvalidPredicateError(\n `BETWEEN on \"${name}\" has a ${lowValue.type} and a ${highValue.type} bound. Both bounds ` +\n \"must have one type, the type the attribute is compared as.\",\n name,\n )\n }\n return node({ kind: \"between\", name, low: lowValue, high: highValue })\n}\n\n/**\n * Attribute is a `str` beginning with this prefix.\n *\n * The match is on **raw UTF-8 bytes** with no normalization — it is the index encoding, so\n * `startsWith(\"name\", \"é\")` matches only the same byte sequence, not another normal form of it.\n *\n * @param prefix - The prefix, as a bare string or a `str` value.\n * @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.\n * @throws {InvalidPredicateError} If the name starts with `$` but is not a queryable system\n * attribute.\n * @throws {UnsupportedOperatorError} If given a value that is not a `str`, or a system attribute\n * (none of which is a `str`).\n *\n * @example\n * startsWith(\"desc\", \"ab\") // desc STARTSWITH str('ab')\n */\nexport function startsWith<N extends string>(\n name: N,\n prefix: string | StrValue,\n): StartsWithNode<{ readonly name: N; readonly type: \"str\" }> {\n const system = resolveReference(name)\n const value = typeof prefix === \"string\" ? str(prefix) : toValue(prefix, name)\n if (value.type !== \"str\") {\n throw new UnsupportedOperatorError(\n name,\n \"STARTSWITH\",\n value.type,\n \"Only str carries a prefix index.\",\n )\n }\n if (system !== undefined) {\n throw new UnsupportedOperatorError(\n name,\n \"STARTSWITH\",\n system,\n \"No queryable system attribute is a str.\",\n )\n }\n return node({ kind: \"startsWith\", name, value })\n}\n\n/**\n * The attribute is set, with any type.\n *\n * @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.\n * @throws {InvalidPredicateError} If given a system attribute — every entity has all of them, so\n * the test would be a constant — or a `$` name that is not one.\n *\n * @example\n * exists(\"reviewedBy\") // EXISTS(reviewedBy)\n * not(exists(\"closedAt\")) // NOT EXISTS(closedAt)\n */\nexport function exists<N extends string>(\n name: N,\n): ExistsNode<{ readonly name: N; readonly type: never }> {\n if (resolveReference(name) !== undefined) {\n throw new InvalidPredicateError(\n `\"${name}\" is a system attribute, so it is set on every entity and EXISTS(${name}) is ` +\n \"always true.\",\n name,\n )\n }\n return node({ kind: \"exists\", name })\n}\n\n/**\n * The attribute is set with exactly this type, whatever its value.\n *\n * Useful when the same name is written with different types across entities — a comparison already\n * asserts the type, so this is for asking about the type alone.\n *\n * @param tag - The type tag: `bool`, `i32`, `u64`, `u256`, `dec`, `bytes32`, `str`, `addr` or\n * `key` — any type but `bytes`, which is never indexed.\n * @throws {InvalidAttributeNameError} If the name is outside the attribute name grammar.\n * @throws {InvalidPredicateError} If the tag is not an indexable type, the name is a system\n * attribute (whose type is fixed), or the name starts with `$` but is not a system attribute.\n *\n * @example\n * hasType(\"age\", \"i32\") // TYPEOF(age) = i32\n */\nexport function hasType<N extends string, T extends IndexableTypeTag>(\n name: N,\n tag: T,\n): TypeOfNode<{ readonly name: N; readonly type: T }> {\n const system = resolveReference(name)\n if (system !== undefined) {\n throw new InvalidPredicateError(\n `\"${name}\" is always a ${system} — a system attribute has a fixed type, so ` +\n `TYPEOF(${name}) is a constant.`,\n name,\n )\n }\n if (!isIndexableTag(tag)) {\n throw new InvalidPredicateError(\n `\"${tag}\" is not an indexable attribute type. Use one of ` +\n \"bool, i32, u64, u256, dec, bytes32, str, addr, key.\",\n name,\n )\n }\n return node({ kind: \"typeOf\", name, tag })\n}\n\n/**\n * The complement of an expression, evaluated against the set of live entities — unlike `!=`, it\n * matches entities that never set the attribute at all.\n *\n * @example\n * not(exists(\"closedAt\")) // NOT EXISTS(closedAt)\n * not(and(eq(\"a\", 1), eq(\"b\", 2))) // NOT (a = i32(1) AND b = i32(2))\n */\nexport function not<R extends AttributeRef>(expression: Expression<R>): NotNode<R> {\n return node({ kind: \"not\", expression })\n}\n\n/**\n * All of these must hold.\n *\n * A single expression is returned unwrapped, so building a conjunction from a filtered list does\n * not litter the query with redundant nesting.\n *\n * @param expressions - The expressions, as separate arguments or one array.\n * @throws {InvalidPredicateError} If given nothing to combine.\n *\n * @example\n * and(gte(\"level\", i32(10)), eq(\"status\", \"open\"))\n * and(filters) // an array works too\n */\nexport function and<const E extends readonly Expression[]>(\n expressions: E,\n): Expression<RefsOf<E[number]>>\nexport function and<const E extends readonly Expression[]>(\n ...expressions: E\n): Expression<RefsOf<E[number]>>\nexport function and(...expressions: (Expression | readonly Expression[])[]): Expression {\n return combine(\"and\", expressions.flat())\n}\n\n/**\n * At least one of these must hold.\n *\n * A single expression is returned unwrapped.\n *\n * @param expressions - The expressions, as separate arguments or one array.\n * @throws {InvalidPredicateError} If given nothing to combine.\n *\n * @example\n * or(eq(\"status\", \"open\"), not(exists(\"closedAt\")))\n */\nexport function or<const E extends readonly Expression[]>(\n expressions: E,\n): Expression<RefsOf<E[number]>>\nexport function or<const E extends readonly Expression[]>(\n ...expressions: E\n): Expression<RefsOf<E[number]>>\nexport function or(...expressions: (Expression | readonly Expression[])[]): Expression {\n return combine(\"or\", expressions.flat())\n}\n\nfunction combine(kind: \"and\" | \"or\", expressions: Expression[]): Expression {\n if (expressions.length === 0) {\n throw new InvalidPredicateError(\n `${kind}() needs at least one expression. An empty ${kind === \"and\" ? \"conjunction\" : \"disjunction\"} ` +\n `has no query-language spelling — leave the ${kind}() out. A query still needs at least one ` +\n \"filter, so to match broadly narrow by owner or creator, or read through a named schema, \" +\n \"whose tag counts as one.\",\n )\n }\n // A one-element conjunction *is* its element; keeping the wrapper would only add parentheses.\n const only = expressions[0]\n if (expressions.length === 1 && only !== undefined) return only\n return node(\n kind === \"and\"\n ? { kind: \"and\", expressions: Object.freeze(expressions) }\n : { kind: \"or\", expressions: Object.freeze(expressions) },\n )\n}\n\n/**\n * Checks every attribute an expression names against a schema — the runtime half of the check\n * {@link SchemaRef} makes at compile time, for the callers the type system does not reach.\n *\n * @throws {InvalidPredicateError} If a predicate names something that is not a column of the\n * schema, a column that is not indexed, or compares a column against a value of another type.\n */\nexport function checkAgainstSchema(expression: Expression, schema: Schema): void {\n switch (expression.kind) {\n case \"not\":\n checkAgainstSchema(expression.expression, schema)\n return\n case \"and\":\n case \"or\":\n for (const sub of expression.expressions) checkAgainstSchema(sub, schema)\n return\n }\n\n const { name } = expression\n // System attributes were checked against their fixed types when the predicate was built.\n if (name.startsWith(\"$\")) return\n\n const column = lookupColumn(schema, name)\n if (column === undefined) {\n throw new InvalidPredicateError(\n `\"${name}\" is not a column of the schema, so a predicate on it can only match entities ` +\n `written some other way. Its columns are ${describeColumns(schema)}.`,\n name,\n )\n }\n if (!column.isIndexed) {\n if (column.type === \"bytes\") {\n throw new InvalidPredicateError(\n `\"${name}\" is a bytes column, and bytes are stored but never indexed, so it cannot be ` +\n \"filtered on. Index a str, bytes32 or key derived from it instead, or select it and \" +\n \"filter the results in JavaScript.\",\n name,\n )\n }\n throw new InvalidPredicateError(\n `\"${name}\" is not indexed, and only indexed attributes can be filtered on. Declare it ` +\n `${column.type}().indexed() — entities written before that are indexed by their next ` +\n \"patch of it — or select it and filter the results in JavaScript.\",\n name,\n )\n }\n const asserted =\n expression.kind === \"comparison\" || expression.kind === \"startsWith\"\n ? expression.value.type\n : expression.kind === \"between\"\n ? expression.low.type\n : expression.kind === \"typeOf\"\n ? expression.tag\n : undefined\n if (asserted !== undefined && asserted !== column.type) {\n throw new InvalidPredicateError(\n `\"${name}\" is a ${column.type} column, but the predicate asserts a ${asserted}, so it could ` +\n `never match. Write ${column.type}(...) around the value.`,\n name,\n )\n }\n}\n\n/**\n * Binding strength, tightest last — `NOT` binds tighter than `AND`, which binds tighter than `OR`.\n * A leaf never needs parentheses, so it sits above them all.\n */\nconst PRECEDENCE = { or: 1, and: 2, not: 3, leaf: 4 } as const\n\nfunction precedenceOf(expression: Expression): number {\n switch (expression.kind) {\n case \"or\":\n return PRECEDENCE.or\n case \"and\":\n return PRECEDENCE.and\n case \"not\":\n return PRECEDENCE.not\n default:\n return PRECEDENCE.leaf\n }\n}\n\n/** Renders a subexpression, parenthesising it only where the precedence would otherwise change it. */\nfunction nested(expression: Expression, minimum: number): string {\n const rendered = render(expression)\n return precedenceOf(expression) < minimum ? `(${rendered})` : rendered\n}\n\n/**\n * Renders an expression as the query string the node parses. Equivalent to `String(expression)`.\n *\n * Literals are always written tagged, even where the language would infer them: an untagged number\n * defaults to `i32`, but spelling it `i32(10)` keeps the exact-type assertion visible in the query\n * that actually went over the wire.\n */\nexport function render(expression: Expression): string {\n switch (expression.kind) {\n case \"comparison\":\n return `${expression.name} ${expression.operator} ${renderLiteral(expression.value)}`\n case \"between\":\n // A leaf, never parenthesised: the AND inside BETWEEN belongs to it, so\n // `a BETWEEN 1 AND 5 AND b = 2` already reads as `(a BETWEEN 1 AND 5) AND b = 2`.\n return `${expression.name} BETWEEN ${renderLiteral(expression.low)} AND ${renderLiteral(expression.high)}`\n case \"startsWith\":\n return `${expression.name} STARTSWITH ${renderLiteral(expression.value)}`\n case \"exists\":\n return `EXISTS(${expression.name})`\n case \"typeOf\":\n return `TYPEOF(${expression.name}) = ${expression.tag}`\n case \"not\":\n return `NOT ${nested(expression.expression, PRECEDENCE.not)}`\n case \"and\":\n return expression.expressions.map((sub) => nested(sub, PRECEDENCE.and)).join(\" AND \")\n case \"or\":\n return expression.expressions.map((sub) => nested(sub, PRECEDENCE.or)).join(\" OR \")\n }\n}\n\n/** Renders a typed value as its query literal. `bool` is the one type written bare. */\nfunction renderLiteral(value: IndexableValue): string {\n switch (value.type) {\n case \"bool\":\n return value.value ? \"true\" : \"false\"\n case \"i32\":\n return `i32(${value.value})`\n case \"u64\":\n return `u64(${value.value})`\n case \"u256\":\n return `u256(${value.value})`\n case \"dec\":\n return `dec(${value.value})`\n case \"bytes32\":\n return `bytes32(${value.value})`\n case \"key\":\n return `key(${value.value})`\n case \"addr\":\n return `addr(${value.value})`\n case \"str\":\n // Single-quoted, with '' as the escape for a quote — the language has no backslash escapes.\n return `str('${value.value.replaceAll(\"'\", \"''\")}')`\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../clients/baseClient\"\nimport { addr, type ColumnsOf, SCHEMA_ATTRIBUTE, type Schema } from \"../schema\"\nimport { InvalidPredicateError } from \"./errors\"\nimport {\n and,\n checkAgainstSchema,\n type Expression,\n eq,\n type RefsOf,\n type SchemaRef,\n} from \"./expression\"\n\n/** The expressions in a `where` call — passed one by one, or as one array. */\ntype WhereExpressions<E extends readonly (Expression | readonly Expression[])[]> =\n E[number] extends infer X ? (X extends readonly Expression[] ? X[number] : X) : never\n\n/**\n * Human-readable messages for compile-time errors when a filter does not fit the schema.\n */\ntype FilterProblem<R, S extends Schema> = R extends {\n readonly name: infer N extends string\n readonly type: infer T extends string\n}\n ? R extends SchemaRef<S>\n ? never\n : N extends SchemaRef<S>[\"name\"]\n ? `\"${N}\" has type ${Extract<SchemaRef<S>, { name: N }>[\"type\"]}, but is compared against a value of type ${T}`\n : N extends keyof ColumnsOf<S>\n ? ColumnsOf<S>[N][\"type\"] extends \"bytes\"\n ? `\"${N}\" is a bytes column, and bytes are never indexed, so it cannot be filtered on. Index a str, bytes32 or key derived from it instead`\n : `\"${N}\" is not indexed, so it cannot be filtered on. Declare it ${ColumnsOf<S>[N][\"type\"]}().indexed() to filter on it`\n : `\"${N}\" is not a column of this schema`\n : never\n\n/**\n * `where`'s check that every filter fits the schema — `unknown` when it does, or when there is no\n * schema, and otherwise an object whose one property is named after the problem. No expression has\n * that property, so the compiler reports the sentence as the property it is missing.\n */\ntype FilterCheck<\n E extends readonly (Expression | readonly Expression[])[],\n TSchema,\n> = TSchema extends Schema\n ? [FilterProblem<RefsOf<WhereExpressions<E>>, TSchema>] extends [infer P extends string]\n ? [P] extends [never]\n ? unknown\n : { [K in P]: never }\n : unknown\n : unknown\n\n/**\n * What every query builder shares: the client, the filters — `where`, `ownedBy`, `createdBy` and a\n * named schema's tag — and the block to read at. `client.select()` and `client.count()` build on it,\n * so the same filters always send the same query string, whichever of them runs it.\n *\n * Not constructed directly: create a builder with `client.select(...)` or `client.count()`.\n *\n * @typeParam TSchema - The schema named with `from()`, if any, which `where` is checked against.\n */\nexport abstract class QueryBuilderBase<TSchema extends Schema | undefined = undefined> {\n protected readonly _client: ArkivClient\n protected _schema: Schema | undefined\n protected readonly _filters: Expression[] = []\n protected _ownedBy: Expression | undefined\n protected _createdBy: Expression | undefined\n protected _atBlock: bigint | undefined\n\n constructor(client: ArkivClient) {\n this._client = client\n }\n\n /**\n * This builder's state in a new builder of the same class, re-typed by the caller. Every field is\n * carried over, so one a subclass adds is not dropped by `from()`; the filter list, which is\n * mutated in place, is copied rather than shared.\n *\n * A copy, not `this` re-typed: a builder typed for one schema must never be the same object as\n * one typed for another, or `base.from(Posts)` and `base.from(Users)` would share their state.\n */\n protected copy<B extends QueryBuilderBase<Schema | undefined>>(): B {\n const copy = Object.create(Object.getPrototypeOf(this)) as B\n return Object.assign(copy, this, { _filters: [...this._filters] })\n }\n\n /**\n * Adds filters. Everything passed here, and across repeated calls, must hold.\n *\n * After `from()`, every attribute a filter names must be an indexed column of the schema,\n * compared against a value of its type — anything else is a compile error.\n *\n * @param expressions - The expressions, as separate arguments or one array.\n *\n * @example\n * builder.where(eq(\"category\", \"docs\"))\n * builder.where(gte(\"level\", i32(10)), lt(\"level\", i32(20)))\n * builder.where(or(eq(\"status\", \"open\"), not(exists(\"closedAt\"))))\n */\n where<const E extends readonly (Expression | readonly Expression[])[]>(\n ...expressions: E & FilterCheck<E, TSchema>\n ): this {\n this._filters.push(...expressions.flat())\n return this\n }\n\n /**\n * Restricts the query to entities this account owns — shorthand for\n * `where(eq(\"$owner\", addr(owner)))`. Calling it again replaces the filter.\n *\n * @example\n * builder.ownedBy(\"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\")\n */\n ownedBy(owner: Hex): this {\n this._ownedBy = eq(\"$owner\", addr(owner))\n return this\n }\n\n /**\n * Restricts the query to entities this account created — shorthand for\n * `where(eq(\"$creator\", addr(creator)))`. Calling it again replaces the filter.\n *\n * The creator never changes; the owner does, so these differ after a transfer.\n */\n createdBy(creator: Hex): this {\n this._createdBy = eq(\"$creator\", addr(creator))\n return this\n }\n\n /**\n * Reads the state as of a given block rather than the head. The block must be within the range\n * the node retains.\n *\n * @example\n * builder.atBlock(1_297_000n)\n */\n atBlock(block: bigint): this {\n this._atBlock = block\n return this\n }\n\n /**\n * The query string this builder will send — the same text the node parses: its filters,\n * `ownedBy` and `createdBy`, and a named schema's tag, ANDed.\n *\n * @throws {InvalidPredicateError} If no filter has been added, or — after `from()` — a filter\n * does not fit the schema. A named schema's own tag filter counts as a filter.\n */\n toString(): string {\n const filters = [...this._filters]\n if (this._ownedBy) filters.push(this._ownedBy)\n if (this._createdBy) filters.push(this._createdBy)\n const schema = this._schema\n if (schema !== undefined) {\n for (const filter of filters) checkAgainstSchema(filter, schema)\n // Added after the check: the tag is not a column, and the caller never wrote this filter.\n if (schema.tag !== undefined) filters.unshift(eq(SCHEMA_ATTRIBUTE, schema.tag))\n }\n if (filters.length === 0) {\n throw new InvalidPredicateError(\n \"A query needs at least one filter — the language has no spelling for 'match every \" +\n \"entity'. Add a where(...) predicate, or narrow by ownedBy(...) / createdBy(...).\",\n )\n }\n return and(filters).toString()\n }\n}\n","import { isSchema, type Schema, SchemaDefinitionError } from \"../schema\"\nimport { QueryBuilderBase } from \"./builderBase\"\nimport { runQuery } from \"./engine\"\n\n/**\n * Builds and runs a count: how many entities a query matches, without fetching any of them.\n *\n * It filters exactly as `client.select()` does — {@link from}, `where`, `ownedBy`, `createdBy` and\n * `atBlock` are the same methods, from the same base — but has nothing to select and no pages, so\n * {@link fetch} resolves to a `bigint`. Create one with `client.count()`.\n *\n * To show the total next to a page of rows, use `select(...).withCount()` instead, which counts in\n * the same request.\n *\n * @typeParam TSchema - The schema named with {@link from}, if any.\n *\n * @example\n * const total = await client.count().from(Posts).ownedBy(account.address).fetch()\n */\nexport class CountQueryBuilder<\n TSchema extends Schema | undefined = undefined,\n> extends QueryBuilderBase<TSchema> {\n /**\n * Counts through a schema: `where` is checked against its indexed columns, and a named schema\n * counts only entities tagged with its name — so it needs no other filter.\n *\n * Returns a new builder, carrying whatever this one already holds; this one is left as it was.\n *\n * @throws {SchemaDefinitionError} If `schema` was not built with `defineSchema`.\n *\n * @example\n * client.count().from(Posts) // every post\n */\n from<S extends Schema>(schema: S): CountQueryBuilder<S> {\n if (!isSchema(schema)) {\n throw new SchemaDefinitionError(\"from() takes a schema built with defineSchema(...)\")\n }\n const typed = this.copy<CountQueryBuilder<S>>()\n typed._schema = schema\n return typed\n }\n\n /**\n * Runs the count.\n *\n * Counts every entity the filters match at the block, whether or not it fits the schema — what\n * `select().from(schema)` leaves out of its pages is still counted.\n *\n * @throws {InvalidPredicateError} If no filter has been added, or a filter does not fit the\n * schema.\n * @throws {QueryError} If the node rejects the query.\n * @throws If the node returns no count — it predates the count projection.\n */\n async fetch(): Promise<bigint> {\n // Nothing but the count is selected, so the node returns no rows and no cursor.\n const response = await runQuery(this._client, {\n query: this.toString(),\n select: {},\n atBlock: this._atBlock,\n count: true,\n })\n if (response.count === undefined) {\n throw new Error(\"The node returned no count. It may predate the count projection.\")\n }\n return response.count\n }\n}\n","import { NoMoreResultsError } from \"../errors\"\n\n/** Fetches the page a cursor points at. */\ntype FetchPage<TEntity, TCount extends bigint | undefined> = (\n cursor: string,\n) => Promise<QueryResult<TEntity, TCount>>\n\n/**\n * One page of query results.\n *\n * A page is immutable: {@link next} returns the following page rather than mutating this one, so a\n * page that has been read stays readable.\n *\n * @typeParam TEntity - The shape of each row, inferred from the selection by `client.select()`.\n * @typeParam TCount - `bigint` when the query was built with `withCount()`, and `undefined` when it\n * was not.\n *\n * @example\n * let page = await client.select({ $key: true }).where(eq(\"category\", \"docs\")).limit(100).fetch()\n * while (page.hasNextPage()) {\n * page = await page.next()\n * }\n */\nexport class QueryResult<\n TEntity = Record<string, unknown>,\n TCount extends bigint | undefined = bigint | undefined,\n> {\n /** The rows on this page — flat, as the selection lays them out. */\n readonly entities: readonly TEntity[]\n /**\n * The block this page was read at.\n *\n * Every page of one walk reads the same block — the cursor is bound to it — so results cannot\n * shift under a paginating reader.\n */\n readonly blockNumber: bigint\n /** The cursor for the next page, or `undefined` when this was the last one. */\n readonly cursor: string | undefined\n /**\n * How many matching entities this page left out because they did not fit the schema — always\n * `0` without a schema, or with `.from(schema, { onMismatch: \"throw\" })`.\n *\n * Counted per page, not per walk: `entities.length + skipped` is what the node returned for this\n * page, so a short or empty page with a cursor is explained here rather than mistaken for the\n * end of the results.\n */\n readonly skipped: number\n /**\n * How many entities the query matches in all, regardless of the page size — a `bigint` when the\n * query was built with `withCount()`, and `undefined` otherwise. Every page of one walk reads the\n * same block, so every page carries the same count. It includes entities left out for not fitting\n * the schema, which {@link skipped} reports per page.\n */\n readonly count: TCount\n\n private readonly fetchPage: FetchPage<TEntity, TCount>\n\n constructor(\n entities: readonly TEntity[],\n blockNumber: bigint,\n cursor: string | undefined,\n skipped: number,\n count: TCount,\n fetchPage: FetchPage<TEntity, TCount>,\n ) {\n this.entities = entities\n this.blockNumber = blockNumber\n this.cursor = cursor\n this.skipped = skipped\n this.count = count\n this.fetchPage = fetchPage\n }\n\n /**\n * Whether another page follows.\n *\n * The node omits the cursor once nothing remains, so this is an answer rather than the guess a\n * short final page would be — a full last page is reported correctly.\n */\n hasNextPage(): boolean {\n return this.cursor !== undefined\n }\n\n /**\n * Fetches the next page.\n *\n * @throws {NoMoreResultsError} If this was the last page — check {@link hasNextPage} first.\n * @throws {QueryError} If the node rejects the request; `kind === \"cursor\"` means the cursor\n * expired and the walk has to start again.\n */\n // Async so that \"no more pages\" arrives as a rejection like every other failure here, rather\n // than as a synchronous throw the caller's `.catch` would miss.\n async next(): Promise<QueryResult<TEntity, TCount>> {\n if (this.cursor === undefined) {\n throw new NoMoreResultsError()\n }\n return this.fetchPage(this.cursor)\n }\n}\n","import type { ArkivClient } from \"../clients/baseClient\"\nimport { isSchema, type Schema, SchemaDefinitionError, SchemaMismatchError } from \"../schema\"\nimport type { Entity } from \"../types/entity\"\nimport { QueryBuilderBase } from \"./builderBase\"\nimport { type QueryRequest, runQuery } from \"./engine\"\nimport type { or } from \"./expression\"\nimport { QueryResult } from \"./queryResult\"\nimport {\n type Projection,\n projectSelection,\n type ResultOf,\n type SelectArg,\n snapshotSelection,\n toRow,\n type UnknownSelection,\n} from \"./selection\"\n\n/**\n * `from(schema)`'s check that every selected key is an entity field or a column — `unknown` when\n * it holds, and an object naming the offenders, which no schema satisfies, when it does not.\n */\ntype SelectionCheck<TSelection, TSchema extends Schema> = [\n UnknownSelection<TSelection, TSchema>,\n] extends [never]\n ? unknown\n : { \"selected names that are not columns of this schema\": UnknownSelection<TSelection, TSchema> }\n\n/**\n * How a query through a schema treats a matching entity that does not fit the schema — one not\n * tagged with a named schema's name, or missing a selected required column or holding one of\n * another type. Columns the selection leaves out are not checked.\n */\nexport type FromOptions = {\n /**\n * `\"skip\"` (the default) leaves the entity out of the page — so a page can hold fewer rows than\n * its limit, and a page whose every entity was skipped is empty while later pages still have rows.\n * Each page reports how many it left out as {@link QueryResult.skipped}. Arkiv is public, so\n * anyone can write an entity that matches a query but not the schema; skipping keeps one such\n * entity from failing every read of the others. `\"throw\"` fails the fetch with a\n * {@link SchemaMismatchError} instead.\n */\n onMismatch?: \"throw\" | \"skip\" | undefined\n}\n\n/**\n * Builds and runs a query.\n *\n * The selection is fixed when the builder is created and the filter is added by chaining, so the\n * result type is known before a single predicate is written. Create one with `client.select(...)`\n * rather than constructing it directly — that is what infers the result shape from the selection.\n *\n * The query returns flat rows: the selected entity fields and attributes side by side. Naming a\n * schema with {@link from} changes what the selection means for nothing but the selected\n * attributes — they come back typed and checked as the schema declares — and has `where` checked\n * against it, so that filtering on a column the schema does not index, or comparing one against the\n * wrong type, is a compile error. A named schema also restricts the query to entities tagged with\n * its name, and leaves that tag out of the rows' `$attributes` and `$attributeSchema`.\n *\n * Every filter added with {@link where}, {@link ownedBy} and {@link createdBy} must hold; use\n * {@link or} for alternatives inside one call.\n *\n * @typeParam TSelection - The selection, inferred by `client.select()`.\n * @typeParam TSchema - The schema named with {@link from}, if any.\n *\n * @example\n * import { createPublicClient } from \"@arkiv-network/sdk\"\n * import { dec } from \"@arkiv-network/sdk/schema\"\n * import { tiramisu } from \"@arkiv-network/sdk/chains\"\n * import { and, eq, gt } from \"@arkiv-network/sdk/query\"\n * import { http } from \"viem\"\n *\n * const client = createPublicClient({ chain: tiramisu, transport: http() })\n *\n * const page = await client\n * .select({ $key: true, author: true, title: true })\n * .from(Posts)\n * .where(and(eq(\"category\", \"docs\"), gt(\"score\", dec(\"4.0\"))))\n * .limit(20)\n * .fetch()\n *\n * for (const row of page.entities) console.log(row.$key, row.title.value)\n */\nexport class SelectQueryBuilder<\n TSelection = \"*\",\n TSchema extends Schema | undefined = undefined,\n TCount extends bigint | undefined = undefined,\n> extends QueryBuilderBase<TSchema> {\n private readonly _selection: SelectArg | undefined\n private _projection: Projection\n private _onMismatch: \"throw\" | \"skip\" = \"skip\"\n private _limit: number | undefined\n private _cursor: string | undefined\n private _withCount = false\n\n /**\n * @throws If the selection is not `\"*\"` or an object, asks for nothing, or names an attribute\n * outside the name grammar.\n */\n constructor(client: ArkivClient, selection?: SelectArg) {\n super(client)\n // A copy: the caller's object may change after this, and the builder is typed for it as it was.\n this._selection = snapshotSelection(selection)\n this._projection = projectSelection(this._selection)\n }\n\n /**\n * Runs the query through a schema. The selection keeps its meaning and the rows their shape;\n * each selected attribute becomes a column — typed as the schema declares, and checked against\n * it — and `where` is checked against the schema's indexed columns.\n *\n * A named schema also filters: only entities tagged with its name match, so a query through it\n * sees only entities written through it, and needs no other filter. The tag is how the query finds\n * them rather than one of their attributes, so rows leave it out of `$attributes` and\n * `$attributeSchema`. An unnamed schema types the query without filtering it — `where` alone\n * decides which entities match.\n *\n * A matching entity that does not fit — a selected required column missing or of another type,\n * or, for a named schema, a tag that does not match — is left out of the page, or fails the fetch\n * with a {@link SchemaMismatchError} with `{ onMismatch: \"throw\" }`. Columns the selection leaves\n * out are not checked.\n *\n * Returns a new builder, carrying whatever this one already holds; this one is left as it was.\n *\n * @param schema - The schema, built with `defineSchema`.\n * @param options - How to treat entities that do not fit. {@link FromOptions}\n * @throws {SchemaDefinitionError} If `schema` was not built with `defineSchema`.\n * @throws If the selection names something that is neither an entity field nor a column.\n *\n * @example\n * client.select({ $key: true, title: true }).from(Posts) // rows typed { $key; title }\n * client.select().from(Posts) // every field and every column\n * client.select().from(Posts, { onMismatch: \"throw\" }) // fail on entities that do not fit\n */\n from<S extends Schema>(\n schema: S & SelectionCheck<TSelection, S>,\n options: FromOptions = {},\n ): SelectQueryBuilder<TSelection, S, TCount> {\n if (!isSchema(schema)) {\n throw new SchemaDefinitionError(\"from() takes a schema built with defineSchema(...)\")\n }\n const { onMismatch = \"skip\" } = options\n if (onMismatch !== \"throw\" && onMismatch !== \"skip\") {\n throw new TypeError(`onMismatch must be \"throw\" or \"skip\", got ${String(onMismatch)}`)\n }\n // Resolved here rather than at fetch time, so a selection naming something that is neither an\n // entity field nor a column fails at the call that made it wrong.\n const projection = projectSelection(this._selection, schema)\n const typed = this.copy<SelectQueryBuilder<TSelection, S, TCount>>()\n typed._schema = schema\n typed._projection = projection\n typed._onMismatch = onMismatch\n return typed\n }\n\n /**\n * Sets the page size, up to the node maximum of 100. Without it the node picks the page size.\n *\n * @example\n * builder.limit(100)\n */\n limit(limit: number): this {\n this._limit = limit\n return this\n }\n\n /**\n * Starts from a cursor returned by an earlier page.\n *\n * Pagination normally goes through {@link QueryResult.next}, which carries the cursor for you;\n * this is for resuming a walk in a later process. A cursor is bound to the query, block and\n * selection it came from, so it must be used with an identically-built query.\n */\n cursor(cursor: string): this {\n this._cursor = cursor\n return this\n }\n\n /**\n * Also counts every entity the query matches, regardless of the page size. Each page then carries\n * the total as {@link QueryResult.count}, typed `bigint`, so a paginated list can show it without\n * a second query. To count without fetching rows, use `client.count()` instead.\n *\n * The node counts what the filters match. Through a schema, that includes entities the pages\n * leave out for not fitting it, so the rows of a whole walk can add up to less than the count:\n * the difference is the sum of every page's {@link QueryResult.skipped}.\n *\n * @throws If, when fetched, the node returns no count — it predates the count projection.\n *\n * Returns a new builder, carrying whatever this one already holds; this one is left as it was.\n *\n * @example\n * const page = await builder.withCount().limit(20).fetch()\n * page.count // every match, not just these 20\n */\n withCount(): SelectQueryBuilder<TSelection, TSchema, bigint> {\n const counted = this.copy<SelectQueryBuilder<TSelection, TSchema, bigint>>()\n counted._withCount = true\n return counted\n }\n\n /**\n * Runs the query and returns the first page.\n *\n * @throws {InvalidPredicateError} If no filter has been added, or a filter does not fit the\n * schema.\n * @throws If the {@link limit} is not an integer from 1 to 100.\n * @throws {SchemaMismatchError} If, through a schema, a matching entity does not fit the selected\n * columns or a named schema's tag, and `from()` was given `{ onMismatch: \"throw\" }`.\n * @throws {QueryError} If the node rejects the query.\n *\n * @example\n * const page = await client.select({ $key: true }).where(eq(\"category\", \"docs\")).fetch()\n * page.entities // this page\n * await page.next() // the next one\n */\n fetch(): Promise<QueryResult<ResultOf<TSelection, TSchema>, TCount>> {\n return this.fetchFirstPage()\n }\n\n // Async so that a builder with no filter rejects like every other failure here, rather than\n // throwing synchronously out of a call the caller is awaiting.\n private async fetchFirstPage(): Promise<QueryResult<ResultOf<TSelection, TSchema>, TCount>> {\n // Snapshot the request here, so the pages of one walk are all pages of the *same* query. The\n // builder stays mutable and reusable; a cursor is bound to the query, block and selection it\n // was issued for, so re-reading a since-edited builder would page with a mismatched cursor.\n const projection = this._projection\n const request = Object.freeze({\n query: this.toString(),\n select: projection.select,\n limit: this._limit,\n atBlock: this._atBlock,\n count: this._withCount,\n })\n // Every entity is laid out as a row of the selection — and, through a schema, checked against it.\n // The static narrowing to the selected fields comes from `client.select()`'s inference and\n // nothing at runtime depends on it.\n const skip = this._onMismatch === \"skip\"\n const decode = ((entity: Entity) => {\n try {\n return toRow(entity, projection)\n } catch (error) {\n if (skip && error instanceof SchemaMismatchError) return SKIPPED\n throw error\n }\n }) as (entity: Entity) => ResultOf<TSelection, TSchema> | typeof SKIPPED\n return fetchPage(this._client, request, this._cursor, decode) as Promise<\n QueryResult<ResultOf<TSelection, TSchema>, TCount>\n >\n }\n\n /**\n * Walks every page, yielding one row at a time.\n *\n * @example\n * for await (const row of client.select({ $key: true }).where(eq(\"category\", \"docs\"))) {\n * console.log(row.$key)\n * }\n */\n async *[Symbol.asyncIterator](): AsyncGenerator<ResultOf<TSelection, TSchema>> {\n let page: QueryResult<ResultOf<TSelection, TSchema>, TCount> | undefined =\n await this.fetchFirstPage()\n while (page) {\n yield* page.entities\n page = page.hasNextPage() ? await page.next() : undefined\n }\n }\n}\n\n/** What `decode` returns for an entity `{ onMismatch: \"skip\" }` leaves out of its page. */\nconst SKIPPED: unique symbol = Symbol(\"skipped\")\n\n/**\n * Fetches one page and wires up the next.\n *\n * Free-standing rather than a method: a page holds this closure for its lifetime, and closing over\n * a frozen request keeps the builder — and everything it references — out of that reference.\n */\nasync function fetchPage<TResult>(\n client: ArkivClient,\n request: Readonly<Omit<QueryRequest, \"cursor\">>,\n cursor: string | undefined,\n decode: (entity: Entity) => TResult | typeof SKIPPED,\n): Promise<QueryResult<TResult>> {\n const response = await runQuery(client, { ...request, cursor })\n // withCount() types the count as present, so a node that leaves it out is an error, not a page\n // whose count is silently undefined.\n if (request.count && response.count === undefined) {\n throw new Error(\"The node returned no count. It may predate the count projection.\")\n }\n\n const results: TResult[] = []\n let skipped = 0\n for (const entity of response.entities) {\n const result = decode(entity)\n if (result === SKIPPED) skipped++\n else results.push(result)\n }\n\n return new QueryResult<TResult>(\n results,\n response.blockNumber,\n response.cursor,\n skipped,\n response.count,\n (next) => fetchPage(client, request, next, decode),\n )\n}\n"],"mappings":";;;;;;AAAA,MAAM,iBAAiB;AAMvB,SAAS,cAAsB;AAC7B,KAAI,OAAO,YAAY,aAAa;EAClC,MAAM,WAAW,SAAS,KAAK;AAC/B,MAAI,SACF,QAAO;;AAIX,KAAI,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OAAO;;;;;;;;;;CAa/D,QAAQ,OAAO,iBAAgE;EAC7E,IAAIC,OACF,MAAM,KAAK,gBAAgB;AAC7B,SAAO,MAAM;AACX,UAAO,KAAK;AACZ,UAAO,KAAK,aAAa,GAAG,MAAM,KAAK,MAAM,GAAG;;;;;AAMtD,MAAMC,UAAyB,OAAO,UAAU;;;;;;;AAQhD,eAAe,UACb,QACA,SACA,QACA,QAC+B;CAC/B,MAAM,WAAW,MAAM,SAAS,QAAQ;EAAE,GAAG;EAAS;EAAQ,CAAC;AAG/D,KAAI,QAAQ,SAAS,SAAS,UAAU,OACtC,OAAM,IAAI,MAAM,mEAAmE;CAGrF,MAAMC,UAAqB,EAAE;CAC7B,IAAI,UAAU;AACd,MAAK,MAAM,UAAU,SAAS,UAAU;EACtC,MAAM,SAAS,OAAO,OAAO;AAC7B,MAAI,WAAW,QAAS;MACnB,SAAQ,KAAK,OAAO;;AAG3B,QAAO,IAAI,YACT,SACA,SAAS,aACT,SAAS,QACT,SACA,SAAS,QACR,SAAS,UAAU,QAAQ,SAAS,MAAM,OAAO,CACnD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const require_schema = require('../schema-B9AyXcgU.cjs');
|
|
2
|
+
|
|
3
|
+
exports.ConflictingMutationError = require_schema.ConflictingMutationError;
|
|
4
|
+
exports.DECIMAL_SCALE = require_schema.DECIMAL_SCALE;
|
|
5
|
+
exports.DECIMAL_UNIT = require_schema.DECIMAL_UNIT;
|
|
6
|
+
exports.EntityTooLargeError = require_schema.EntityTooLargeError;
|
|
7
|
+
exports.I32_MAX = require_schema.I32_MAX;
|
|
8
|
+
exports.I32_MIN = require_schema.I32_MIN;
|
|
9
|
+
exports.INDEXED_FLAG = require_schema.INDEXED_FLAG;
|
|
10
|
+
exports.InvalidAttributeNameError = require_schema.InvalidAttributeNameError;
|
|
11
|
+
exports.InvalidValueError = require_schema.InvalidValueError;
|
|
12
|
+
exports.MAX_ATTRIBUTES = require_schema.MAX_ATTRIBUTES;
|
|
13
|
+
exports.MAX_BYTES_LENGTH = require_schema.MAX_BYTES_LENGTH;
|
|
14
|
+
exports.MAX_ENTITY_BYTES = require_schema.MAX_ENTITY_BYTES;
|
|
15
|
+
exports.MAX_NAME_BYTES = require_schema.MAX_NAME_BYTES;
|
|
16
|
+
exports.MAX_STRING_BYTES = require_schema.MAX_STRING_BYTES;
|
|
17
|
+
exports.MissingValueError = require_schema.MissingValueError;
|
|
18
|
+
exports.SCHEMA_ATTRIBUTE = require_schema.SCHEMA_ATTRIBUTE;
|
|
19
|
+
exports.SchemaDefinitionError = require_schema.SchemaDefinitionError;
|
|
20
|
+
exports.SchemaMismatchError = require_schema.SchemaMismatchError;
|
|
21
|
+
exports.TooManyAttributesError = require_schema.TooManyAttributesError;
|
|
22
|
+
exports.U256_MAX = require_schema.U256_MAX;
|
|
23
|
+
exports.U64_MAX = require_schema.U64_MAX;
|
|
24
|
+
exports.UnknownAttributeTypeError = require_schema.UnknownAttributeTypeError;
|
|
25
|
+
exports.UntypedValueError = require_schema.UntypedValueError;
|
|
26
|
+
exports.addr = require_schema.addr;
|
|
27
|
+
exports.bool = require_schema.bool;
|
|
28
|
+
exports.bytes = require_schema.bytes;
|
|
29
|
+
exports.bytes32 = require_schema.bytes32;
|
|
30
|
+
exports.dec = require_schema.dec;
|
|
31
|
+
exports.decFromUnits = require_schema.decFromUnits;
|
|
32
|
+
exports.decUnits = require_schema.decUnits;
|
|
33
|
+
exports.defineSchema = require_schema.defineSchema;
|
|
34
|
+
exports.describeColumns = require_schema.describeColumns;
|
|
35
|
+
exports.i32 = require_schema.i32;
|
|
36
|
+
exports.isArkivValue = require_schema.isArkivValue;
|
|
37
|
+
exports.isColumn = require_schema.isColumn;
|
|
38
|
+
exports.isSchema = require_schema.isSchema;
|
|
39
|
+
exports.isValidAttributeName = require_schema.isValidAttributeName;
|
|
40
|
+
exports.key = require_schema.key;
|
|
41
|
+
exports.lookupColumn = require_schema.lookupColumn;
|
|
42
|
+
exports.str = require_schema.str;
|
|
43
|
+
exports.toValue = require_schema.toValue;
|
|
44
|
+
exports.u256 = require_schema.u256;
|
|
45
|
+
exports.u64 = require_schema.u64;
|
|
46
|
+
exports.validateAttributeName = require_schema.validateAttributeName;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $ as u256, A as describeColumns, B as U64_MAX, C as IndexedColumnName, D as SCHEMA_ATTRIBUTE, E as PatchEntityValues, F as I32_MIN, G as bytes32, H as addr, I as MAX_BYTES_LENGTH, J as decUnits, K as dec, L as MAX_STRING_BYTES, M as lookupColumn, N as BareOf, O as Schema, P as I32_MAX, Q as toValue, R as TagOf, S as CreateEntityValues, T as OptionalColumnName, U as bool, V as ValueInput, W as bytes, X as key, Y as i32, Z as str, _ as Attributes, _t as TypeTag, a as EntityTooLargeError, at as AddrValue, b as Columns, bt as ValueOf, c as MissingValueError, ct as Bytes32Value, d as TooManyAttributesError, dt as I32Value, et as u64, f as UnknownAttributeTypeError, ft as INDEXED_FLAG, g as AttributeSchema, gt as StrValue, h as DECIMAL_UNIT, ht as KeyValue, i as ConflictingMutationError, it as isColumn, j as isSchema, k as defineSchema, l as SchemaDefinitionError, lt as BytesValue, m as DECIMAL_SCALE, mt as IndexableValue, n as isValidAttributeName, nt as Column, o as InvalidAttributeNameError, ot as ArkivValue, p as UntypedValueError, pt as IndexableTypeTag, q as decFromUnits, r as validateAttributeName, rt as ValueArgument, s as InvalidValueError, st as BoolValue, t as MAX_NAME_BYTES, tt as AnyColumn, u as SchemaMismatchError, ut as DecValue, v as MAX_ENTITY_BYTES, vt as U256Value, w as MAX_ATTRIBUTES, x as ColumnsOf, xt as isArkivValue, y as ColumnInput, yt as U64Value, z as U256_MAX } from "../index-C-mMF5WZ.cjs";
|
|
2
|
+
export { AddrValue, AnyColumn, ArkivValue, AttributeSchema, Attributes, BareOf, BoolValue, Bytes32Value, BytesValue, Column, ColumnInput, Columns, ColumnsOf, ConflictingMutationError, CreateEntityValues, DECIMAL_SCALE, DECIMAL_UNIT, DecValue, EntityTooLargeError, I32Value, I32_MAX, I32_MIN, INDEXED_FLAG, IndexableTypeTag, IndexableValue, IndexedColumnName, InvalidAttributeNameError, InvalidValueError, KeyValue, MAX_ATTRIBUTES, MAX_BYTES_LENGTH, MAX_ENTITY_BYTES, MAX_NAME_BYTES, MAX_STRING_BYTES, MissingValueError, OptionalColumnName, PatchEntityValues, SCHEMA_ATTRIBUTE, Schema, SchemaDefinitionError, SchemaMismatchError, StrValue, TagOf, TooManyAttributesError, TypeTag, U256Value, U256_MAX, U64Value, U64_MAX, UnknownAttributeTypeError, UntypedValueError, ValueArgument, ValueInput, ValueOf, addr, bool, bytes, bytes32, dec, decFromUnits, decUnits, defineSchema, describeColumns, i32, isArkivValue, isColumn, isSchema, isValidAttributeName, key, lookupColumn, str, toValue, u256, u64, validateAttributeName };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $ as u256, A as describeColumns, B as U64_MAX, C as IndexedColumnName, D as SCHEMA_ATTRIBUTE, E as PatchEntityValues, F as I32_MIN, G as bytes32, H as addr, I as MAX_BYTES_LENGTH, J as decUnits, K as dec, L as MAX_STRING_BYTES, M as lookupColumn, N as BareOf, O as Schema, P as I32_MAX, Q as toValue, R as TagOf, S as CreateEntityValues, T as OptionalColumnName, U as bool, V as ValueInput, W as bytes, X as key, Y as i32, Z as str, _ as Attributes, _t as TypeTag, a as EntityTooLargeError, at as AddrValue, b as Columns, bt as ValueOf, c as MissingValueError, ct as Bytes32Value, d as TooManyAttributesError, dt as I32Value, et as u64, f as UnknownAttributeTypeError, ft as INDEXED_FLAG, g as AttributeSchema, gt as StrValue, h as DECIMAL_UNIT, ht as KeyValue, i as ConflictingMutationError, it as isColumn, j as isSchema, k as defineSchema, l as SchemaDefinitionError, lt as BytesValue, m as DECIMAL_SCALE, mt as IndexableValue, n as isValidAttributeName, nt as Column, o as InvalidAttributeNameError, ot as ArkivValue, p as UntypedValueError, pt as IndexableTypeTag, q as decFromUnits, r as validateAttributeName, rt as ValueArgument, s as InvalidValueError, st as BoolValue, t as MAX_NAME_BYTES, tt as AnyColumn, u as SchemaMismatchError, ut as DecValue, v as MAX_ENTITY_BYTES, vt as U256Value, w as MAX_ATTRIBUTES, x as ColumnsOf, xt as isArkivValue, y as ColumnInput, yt as U64Value, z as U256_MAX } from "../index-DLb7BfIw.js";
|
|
2
|
+
export { AddrValue, AnyColumn, ArkivValue, AttributeSchema, Attributes, BareOf, BoolValue, Bytes32Value, BytesValue, Column, ColumnInput, Columns, ColumnsOf, ConflictingMutationError, CreateEntityValues, DECIMAL_SCALE, DECIMAL_UNIT, DecValue, EntityTooLargeError, I32Value, I32_MAX, I32_MIN, INDEXED_FLAG, IndexableTypeTag, IndexableValue, IndexedColumnName, InvalidAttributeNameError, InvalidValueError, KeyValue, MAX_ATTRIBUTES, MAX_BYTES_LENGTH, MAX_ENTITY_BYTES, MAX_NAME_BYTES, MAX_STRING_BYTES, MissingValueError, OptionalColumnName, PatchEntityValues, SCHEMA_ATTRIBUTE, Schema, SchemaDefinitionError, SchemaMismatchError, StrValue, TagOf, TooManyAttributesError, TypeTag, U256Value, U256_MAX, U64Value, U64_MAX, UnknownAttributeTypeError, UntypedValueError, ValueArgument, ValueInput, ValueOf, addr, bool, bytes, bytes32, dec, decFromUnits, decUnits, defineSchema, describeColumns, i32, isArkivValue, isColumn, isSchema, isValidAttributeName, key, lookupColumn, str, toValue, u256, u64, validateAttributeName };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { A as key, B as DECIMAL_SCALE, C as bool, D as decFromUnits, E as dec, F as isColumn, G as InvalidValueError, H as ConflictingMutationError, I as INDEXED_FLAG, J as SchemaMismatchError, K as MissingValueError, M as toValue, N as u256, O as decUnits, P as u64, R as isArkivValue, S as addr, T as bytes32, U as EntityTooLargeError, V as DECIMAL_UNIT, W as InvalidAttributeNameError, X as UnknownAttributeTypeError, Y as TooManyAttributesError, Z as UntypedValueError, _ as I32_MIN, a as SCHEMA_ATTRIBUTE, b as U256_MAX, c as isSchema, d as isValidAttributeName, f as validateAttributeName, g as I32_MAX, i as MAX_ATTRIBUTES, j as str, k as i32, l as lookupColumn, o as defineSchema, q as SchemaDefinitionError, s as describeColumns, t as MAX_ENTITY_BYTES, u as MAX_NAME_BYTES, v as MAX_BYTES_LENGTH, w as bytes, x as U64_MAX, y as MAX_STRING_BYTES } from "../schema-DY4sqehl.js";
|
|
2
|
+
|
|
3
|
+
export { ConflictingMutationError, DECIMAL_SCALE, DECIMAL_UNIT, EntityTooLargeError, I32_MAX, I32_MIN, INDEXED_FLAG, InvalidAttributeNameError, InvalidValueError, MAX_ATTRIBUTES, MAX_BYTES_LENGTH, MAX_ENTITY_BYTES, MAX_NAME_BYTES, MAX_STRING_BYTES, MissingValueError, SCHEMA_ATTRIBUTE, SchemaDefinitionError, SchemaMismatchError, TooManyAttributesError, U256_MAX, U64_MAX, UnknownAttributeTypeError, UntypedValueError, addr, bool, bytes, bytes32, dec, decFromUnits, decUnits, defineSchema, describeColumns, i32, isArkivValue, isColumn, isSchema, isValidAttributeName, key, lookupColumn, str, toValue, u256, u64, validateAttributeName };
|