import type { CanonicalPublicAttrs, CanonicalPublicAttrValue, HsonNode, JsonValue, NodeContent, Primitive } from "../core/types.js"; import type { HsonSchema, HsonSchemaMode, HsonSchemaMutationCandidate } from "../api/transform/transform.types.js"; import type { HsonData } from "../api/data/hson-data.js"; import type { DocumentAttrsEvidence, DocumentAttrValueEvidence } from "../api/livemap/livemap.document.schema.js"; import type { LiveMapGraphEnsureQuidOp, LiveMapProjectedGraphEnsureQuidOp } from "../api/livemap/livemap.identity.types.js"; /** * One segment of a projected LiveMap path. * * Strings address object properties. Numbers address array indexes. This is the * canonical internal path representation beneath later ergonomic surfaces such * as Proxy access. */ export type LivePathPart = string | number; /** * Canonical data path into a LiveMap graph. * * A LivePath is not a raw Hson node path. It addresses the JSON-facing value * projection, so `["user", "name"]` means the `name` value under `user`, not * the physical wrapper/content path inside the Hson graph. */ export type LivePath = readonly LivePathPart[]; /** Canonical root shape owned by one LiveMap instance. */ export type LiveMapRootMode = DataLiveMapMode | DocumentLiveMapMode; export type DataLiveMapMode = "data-object" | "data-array"; export type DocumentLiveMapMode = "document"; /** One detached semantic cut of a complete fixed LiveMap Libraries registry. */ export type LiveMapLibrariesSnapshot = Readonly<{ format: "hson-livemap-libraries-snapshot"; revision: number; registry: Readonly<{ format: "hson-hosted-registry"; libraries: readonly Readonly<{ name: string; scope?: "hson-internal"; mode: LiveMapRootMode; schema: HsonSchema; schemaDigest: string; rootCodec: "hson-exact-value"; }>[]; digest: string; }>; registryDigest: string; libraries: readonly Readonly<{ name: string; mode: LiveMapRootMode; schema: HsonSchema; schemaDigest: string; root: Readonly<{ format: "hson-exact-value"; payload: string; }>; }>[]; identity: Readonly<{ epoch: number; issuedQuids: readonly string[]; }>; }>; /** One complete Libraries semantic cut plus its durable hosted authority fence. */ export type HostedLiveMapLibrariesSnapshot = LiveMapLibrariesSnapshot & Readonly<{ authority: Readonly<{ logicalMapId: string; incarnationId: string; }>; }>; /** * Runtime Proxy surface for ergonomic projected-path access. * * Normal property access extends the path. `$_` exits the Proxy surface and * returns the existing path handle for the current data path. * * Schema-aware maps expose known object keys and array indexes as typed child * proxies. Unknown property names remain allowed as `unknown` so loose dynamic * proxy usage is still possible without widening known schema paths. */ export type LiveMapProxy = Readonly<{ readonly $_: LiveMapPathHandle>; }> & LiveMapProxyObjectChildren & LiveMapProxyArrayChildren; export type LiveMapProxyObjectChildren = NonNullable> extends readonly unknown[] ? Readonly> : NonNullable> extends object ? Readonly<{ [TKey in Extract>, string>]: LiveMapProxy; }> : Readonly>; export type LiveMapProxyArrayChildren = NonNullable> extends readonly unknown[] ? Readonly<{ [index: number]: LiveMapProxy; }> : Readonly>; /** * Raw result returned by the editor after a graph mutation. * * The editor reports the local before/after value at one path. Core turns this * into a normalized commit/op record for feeds, links, batching, and later * transport. */ export type LiveMapEditResult = Readonly<{ changed: boolean; prev: JsonValue | undefined; next: JsonValue | undefined; }>; /** Property bag accepted by object-shaped `set(...)` and `setMany(...)` calls. */ export type LiveMapSetManyValues = Readonly>; export type LiveMapSortDirection = "asc" | "desc"; /** Overloaded snapshot reader: root with no args, data value with a path. */ export type LiveMapCoreSnap = { (path: LivePath): JsonValue | undefined; (): TValue; }; export type LiveMapCaptureIdentity = "same-epoch" | "preserve-metadata" | "strip"; export type LiveMapCaptureOptions = Readonly<{ identity: LiveMapCaptureIdentity; }>; export type LiveMapRestoreOptions = Readonly<{ identity?: LiveMapCaptureIdentity | "reject"; }>; export type LiveMapCoreReplay = { (input: LiveMapGraphCommit): LiveMapGraphCommit; (input: LiveMapReplay): LiveMapCommit; }; declare const LIVEMAP_INVALID_STATIC_PATH: unique symbol; type LiveMapInvalidStaticPath = Readonly<{ [LIVEMAP_INVALID_STATIC_PATH]: true; }>; type LiveMapTupleSegment = number extends THead ? TValue[number] | undefined : `${THead}` extends keyof TValue ? TValue[THead & keyof TValue] : LiveMapInvalidStaticPath; type LiveMapArraySegment = number extends TValue["length"] ? TValue[number] | undefined : LiveMapTupleSegment; type LiveMapObjectSegment = THead extends string ? string extends THead ? JsonValue | undefined : THead extends keyof TValue ? TValue[THead] | (string extends keyof TValue ? undefined : never) : LiveMapInvalidStaticPath : LiveMapInvalidStaticPath; type LiveMapPathSegmentBranch = unknown extends TValue ? JsonValue | undefined : TValue extends null | undefined ? LiveMapInvalidStaticPath : TValue extends readonly unknown[] ? THead extends number ? LiveMapArraySegment : LiveMapInvalidStaticPath : TValue extends object ? LiveMapObjectSegment : LiveMapInvalidStaticPath; type LiveMapPathSegmentBranches = TValue extends unknown ? LiveMapPathSegmentBranch : never; type LiveMapReachablePathSegment = Exclude, LiveMapInvalidStaticPath>; type LiveMapPathSegmentValue = [ LiveMapReachablePathSegment ] extends [never] ? LiveMapInvalidStaticPath : LiveMapReachablePathSegment | ([Extract, LiveMapInvalidStaticPath>] extends [never] ? never : undefined); type ResolveLiveMapPathValue = number extends TPath["length"] ? JsonValue | undefined : TPath extends readonly [] ? TValue : TPath extends readonly [infer THead, ...infer TRest] ? ResolveLiveMapPathValue, Extract> : JsonValue | undefined; /** * Static value projection for a LivePath. * * Exact literal paths narrow recursively. Branches that cannot continue below * an optional, nullable, union, or indexed ancestor contribute `undefined`. * A literal path that cannot traverse any branch resolves to `never`, while a * broad runtime `LivePath` retains the validated `JsonValue | undefined` route. */ type PublicLiveMapPathValue = [ TResult ] extends [LiveMapInvalidStaticPath] ? never : TResult; export type LiveMapPathValue = PublicLiveMapPathValue>; /** * The ordinary candidate accepted at a LiveMap write boundary. Generated Schema * proof carriers associate their structurally truthful unproved counterpart; * this association is declaration-only and never widens governed reads. */ type LiveMapMutationCandidateValue = TValue extends HsonSchemaMutationCandidate ? TCandidate : TValue extends readonly [infer THead, ...infer TTail] ? [LiveMapMutationCandidateValue, ...LiveMapMutationCandidateTuple] : TValue extends readonly (infer TItem)[] ? Array> : TValue extends object ? { -readonly [TKey in keyof TValue]: LiveMapMutationCandidateValue; } : TValue; type LiveMapMutationCandidateTuple = TValue extends readonly [infer THead, ...infer TTail] ? [LiveMapMutationCandidateValue, ...LiveMapMutationCandidateTuple] : []; /** Remove `undefined` from write positions while preserving JSON value shape. */ export type LiveMapWriteValue = [Exclude, undefined>] extends [JsonValue] ? Exclude, undefined> : JsonValue; export type LiveMapPathWriteValue = LiveMapWriteValue>; /** * Value accepted by `set` at one path. * * Arrays and primitives are written as endpoint values. Object paths accept a * shallow object patch shape because runtime `set` preserves unspecified object * siblings. Use `replace` for exact object replacement. */ export type LiveMapSetValue = NonNullable> extends readonly unknown[] ? LiveMapWriteValue : NonNullable> extends object ? LiveMapObjectSetManyValues : LiveMapWriteValue; export type LiveMapPathSetValue = LiveMapSetValue>; /** Object patch shape accepted by `setMany` at a data path. */ export type LiveMapPathSetManyValues = LiveMapObjectSetManyValues>; export type LiveMapReplaceFn = { (value: NoInfer>): LiveMapCommit; (path: TPath, value: NoInfer>): LiveMapCommit; }; export type LiveMapBatchReplaceFn = { (value: NoInfer>): LiveMapBatchTx; (path: TPath, value: NoInfer>): LiveMapBatchTx; }; /** * Synchronous transaction handle passed to `map.batch(...)`. * * Batch is an explicit grouping envelope, not automatic notification * coalescing. The transaction mirrors Core semantics: `replace` performs exact * endpoint replacement, while object-valued `set` and `setMany` perform shallow * sibling-preserving object writes. */ export type LiveMapBatchTx = Readonly<{ /** Set a resolved data path; plain objects expand into shallow child sets. */ set: (path: TPath, value: NoInfer>) => LiveMapBatchTx; /** Exact root replacement, or exact endpoint replacement at a data path. */ replace: LiveMapBatchReplaceFn; /** Shallow object set that expands values into child-path sets and preserves unspecified siblings. */ setMany: (path: TPath, values: NoInfer>) => LiveMapBatchTx; splice: (path: LivePath, start: number, deleteCount: number, ...items: readonly JsonValue[]) => LiveMapBatchTx; /** Delete the data path. */ delete: (path: LivePath) => LiveMapBatchTx; }>; /** * Schema attachment surface for a LiveMap. * * `schema.use(schema)` validates the current canonical root and returns the same * runtime map object. HsonSchema is the sole public Schema authority. * * The first successful attachment permanently governs that owner. Reusing the * same schema object is idempotent; any distinct schema object rejects. */ export type LiveMapCoreSchemaApi = Readonly<{ get: () => HsonSchema | undefined; use: (schema: TSchema) => LiveMap>; }>; export type LiveMapCore = Readonly<{ /** Canonical capability selected from the validated graph at construction. */ readonly mode: TMode; /** Return a detached structural clone of the complete canonical root graph. */ root: () => HsonNode; snap: LiveMapCoreSnap; /** Read exact canonical data without ordinary-JavaScript materialization. */ data: (path?: LivePath) => HsonData | undefined; schema: LiveMapCoreSchemaApi; at: (path: TPath & ([LiveMapPathValue] extends [never] ? never : unknown)) => LiveMapPathHandle>; proxy: (path?: TPath) => LiveMapProxy; /** Set a resolved data path; plain objects expand into shallow child sets. */ set: (path: TPath, value: NoInfer>) => LiveMapCommit; /** Shallow object set that expands values into child-path sets and preserves unspecified siblings. */ setMany: (path: TPath, values: NoInfer>) => LiveMapCommit; splice: (path: LivePath, start: number, deleteCount: number, ...items: readonly JsonValue[]) => LiveMapCommit; /** Exact root replacement, or exact endpoint replacement at a data path; `set([])` remains invalid. */ replace: LiveMapReplaceFn; delete: (path: LivePath) => LiveMapCommit; /** Explicit synchronous transaction grouping for one commit. */ batch: (fn: (tx: LiveMapBatchTx) => void) => LiveMapCommit; feed: (path: LivePath, listener: LiveMapFeedListener) => LiveMapDisposer; commits: LiveMapCommitObserverApi; sub: LiveMapSubApi; readonly rev: number; /** Emit the canonical structural-JSON capture with detached graph metadata. */ capture: { (): LiveMapCapture; (options: LiveMapCaptureOptions): LiveMapCapture; }; /** Atomically restore one canonical structural-JSON capture. */ restore: (capture: LiveMapCapture, options?: LiveMapRestoreOptions) => void; /** Apply canonical structural-JSON state at one base revision. */ apply: (input: LiveMapApply) => LiveMapCommit; /** Replay one canonical structural-JSON operation envelope. */ replay: LiveMapCoreReplay; }>; /** * Public LiveMap surface. * * `TValue` is the current data root value type. A map created without a * schema starts as `LiveMap`. HsonSchema governance is * attached with `map.schema.use(schema)`. */ export type LiveMap = Readonly, "mode"> & { readonly mode: DataLiveMapMode; }>; /** Detached exact canonical capture, including admitted QUID metadata. */ export type DocumentLiveMapCapture = Readonly<{ kind: "hson-document"; mode: TMode; rev: number; root: HsonNode; }>; /** Explicit identity treatment for one detached document capture. */ export type DocumentLiveMapCaptureIdentity = "same-epoch" | "preserve-metadata" | "strip"; /** Capture policy. Omission preserves durable exact metadata. */ export type DocumentLiveMapCaptureOptions = Readonly<{ identity: DocumentLiveMapCaptureIdentity; }>; /** Explicit identity treatment at a complete document admission boundary. */ export type DocumentLiveMapInstallIdentity = DocumentLiveMapCaptureIdentity | "reject"; /** Callable capture surface with an additive identity-category selector. */ export type DocumentLiveMapCaptureApi = { (): DocumentLiveMapCapture; (options: DocumentLiveMapCaptureOptions): DocumentLiveMapCapture; }; /** Optimistic revision guard plus explicit complete-root identity admission policy. */ export type DocumentLiveMapInstallOptions = Readonly<{ expectedRev?: number; identity?: DocumentLiveMapInstallIdentity; }>; declare const LIVEMAP_DOCUMENT_PATH_BRAND: unique symbol; /** * Validated, detached numeric traversal through canonical document * `$_content` arrays. Runtime values remain frozen ordinary arrays. */ export type LiveMapDocumentPath = readonly number[] & Readonly<{ [LIVEMAP_DOCUMENT_PATH_BRAND]: true; }>; /** Untrusted caller representation accepted at the live request boundary. */ export type LiveMapDocumentPathInput = readonly number[]; /** Path-authoritative target accepted at a live document request boundary. */ export type LiveMapDocumentRequestTarget = Readonly<{ kind: "path"; path: LiveMapDocumentPathInput; }>; /** Optional same-epoch diagnostic evidence; never a routing address. */ export type LiveMapDocumentTargetWitness = Readonly<{ quid: string; }>; /** Path-authoritative target stored by canonical graph operations. */ export type LiveMapDocumentCommitTarget = Readonly<{ kind: "path"; path: LiveMapDocumentPath; witness?: LiveMapDocumentTargetWitness; }>; /** Existing canonical Hson attribute value model; style remains structured. */ export type LiveMapDocumentAttributeValue = CanonicalPublicAttrValue; /** Detached canonical final-state bag for public ordinary document attributes. */ export type LiveMapDocumentAttrs = CanonicalPublicAttrs; /** One legal candidate value for a canonical Hson `$_content` slot. */ export type LiveMapDocumentContent = NodeContent[number]; export type DocumentLiveMapAttrsMustApi = Readonly<{ get: (target: LiveMapDocumentRequestTarget, name: string) => LiveMapDocumentAttributeValue; }>; export type DocumentLiveMapAttrsReadApi = Readonly<{ get: (target: LiveMapDocumentRequestTarget, name: string) => LiveMapDocumentAttributeValue | undefined; has: (target: LiveMapDocumentRequestTarget, name: string) => boolean; keys: (target: LiveMapDocumentRequestTarget) => readonly string[]; must: DocumentLiveMapAttrsMustApi; }>; export type DocumentLiveMapAttrsMutationApi = Readonly<{ set: (target: LiveMapDocumentRequestTarget, name: string, value: LiveMapDocumentAttributeValue) => LiveMapGraphCommit; drop: (target: LiveMapDocumentRequestTarget, name: string) => LiveMapGraphCommit; setMany: (target: LiveMapDocumentRequestTarget, values: LiveMapDocumentAttrs) => LiveMapGraphCommit; dropMany: (target: LiveMapDocumentRequestTarget, names: readonly string[]) => LiveMapGraphCommit; clear: (target: LiveMapDocumentRequestTarget) => LiveMapGraphCommit; replace: (target: LiveMapDocumentRequestTarget, values: LiveMapDocumentAttrs) => LiveMapGraphCommit; }>; /** Canonical ordinary-attribute read and mutation namespace. */ export type DocumentLiveMapAttrsApi = DocumentLiveMapAttrsReadApi & DocumentLiveMapAttrsMutationApi; /** Presence-oriented reads over same-name canonical flag-form attributes. */ export type DocumentLiveMapFlagsReadApi = Readonly<{ has: (target: LiveMapDocumentRequestTarget, name: string) => boolean; }>; /** Atomic semantic flag transitions over the complete canonical attrs bag. */ export type DocumentLiveMapFlagsMutationApi = Readonly<{ set: (target: LiveMapDocumentRequestTarget, ...names: string[]) => LiveMapGraphCommit; clear: (target: LiveMapDocumentRequestTarget, ...names: string[]) => LiveMapGraphCommit; }>; export type DocumentLiveMapFlagsApi = DocumentLiveMapFlagsReadApi & DocumentLiveMapFlagsMutationApi; /** Detached content reader plus atomic single-slot structural mutations. */ export type DocumentLiveMapContentApi = (() => readonly NodeContent[number][]) & Readonly<{ replace: (target: LiveMapDocumentRequestTarget, index: number, replacement: LiveMapDocumentContent) => LiveMapGraphCommit; insert: (target: LiveMapDocumentRequestTarget, index: number, content: LiveMapDocumentContent) => LiveMapGraphCommit; remove: (target: LiveMapDocumentRequestTarget, index: number) => LiveMapGraphCommit; move: (target: LiveMapDocumentRequestTarget, from: number, to: number) => LiveMapGraphCommit; }>; /** Shared detached canonical reads for document capabilities. */ export type LiveMapDocumentApi = Readonly<{ /** Return a detached clone of the complete canonical root. */ root: () => HsonNode; /** Return detached top-level document content in canonical order. */ content: DocumentLiveMapContentApi; /** Resolve a QUID in the current owned graph to a detached element clone. */ byQuid: (quid: string) => HsonNode | undefined; /** Canonical ordinary-attribute mutation namespace. */ attrs: DocumentLiveMapAttrsApi; /** Semantic same-name flag operations over canonical attrs. */ flags: DocumentLiveMapFlagsApi; }>; type DocumentLiveMapForEvidence = DocumentLiveMap; type DocumentLiveMapGovernanceApi = Readonly<{ get: () => HsonSchema | undefined; use: (schema: HsonSchema) => DocumentLiveMapForEvidence; }>; declare const LIVEMAP_DOCUMENT_INVALID_STATIC_PATH: unique symbol; type InternalDocumentInvalidStaticPath = Readonly<{ [LIVEMAP_DOCUMENT_INVALID_STATIC_PATH]: true; }>; declare const LIVEMAP_DOCUMENT_MISSING_COORDINATE: unique symbol; type InternalDocumentMissingCoordinate = Readonly<{ [LIVEMAP_DOCUMENT_MISSING_COORDINATE]: true; }>; declare const LIVEMAP_DOCUMENT_BROAD_SUBTREE: unique symbol; type InternalDocumentBroadSubtree = Readonly<{ [LIVEMAP_DOCUMENT_BROAD_SUBTREE]: true; }>; declare const LIVEMAP_DOCUMENT_UNSCHEMATIZED: unique symbol; type InternalDocumentUnschematized = Readonly<{ [LIVEMAP_DOCUMENT_UNSCHEMATIZED]: true; }>; declare const LIVEMAP_DOCUMENT_ROOT_DESCRIPTOR: unique symbol; type InternalDocumentRootDescriptor = Readonly<{ [LIVEMAP_DOCUMENT_ROOT_DESCRIPTOR]: TEvidence; }>; type InternalDocumentSchemaEndpoint = string | HsonNode | undefined; type InternalDocumentLegacyEndpoint = HsonNode | Primitive | undefined; type InternalDocumentNormalizeBranches = [ Exclude ] extends [never] ? InternalDocumentInvalidStaticPath : Exclude | ([Extract] extends [never] ? never : InternalDocumentMissingCoordinate); type InternalDocumentSequenceCoordinate = number extends TIndex ? TItems[number] | InternalDocumentMissingCoordinate : `${TIndex}` extends keyof TItems ? TItems[TIndex & keyof TItems] : InternalDocumentInvalidStaticPath; type InternalDocumentIndexWithinCount = TCursor["length"] extends TIndex ? TCursor["length"] extends TCount ? false : true : TCursor["length"] extends TCount ? false : InternalDocumentIndexWithinCount; type InternalDocumentCountedCoordinateBranch = InternalDocumentIndexWithinCount extends true ? TItem : InternalDocumentInvalidStaticPath; type InternalDocumentCountedCoordinateBranches = TCount extends unknown ? InternalDocumentCountedCoordinateBranch : never; type InternalDocumentCountedCoordinate = number extends TCount ? TItem | InternalDocumentMissingCoordinate : number extends TIndex ? TItem | InternalDocumentMissingCoordinate : InternalDocumentNormalizeBranches>; type InternalDocumentContentCoordinateBranch = TContent extends Readonly<{ kind: "sequence"; items: infer TItems extends readonly unknown[]; }> ? InternalDocumentSequenceCoordinate : TContent extends Readonly<{ kind: "repeat"; item: infer TItem; }> ? TItem | InternalDocumentMissingCoordinate : TContent extends Readonly<{ kind: "counted-repeat"; count: infer TCount extends number; item: infer TItem; }> ? InternalDocumentCountedCoordinate : TContent extends Readonly<{ kind: "pick"; choices: infer TChoices extends readonly unknown[]; }> ? InternalDocumentNormalizeBranches> : InternalDocumentInvalidStaticPath; type InternalDocumentContentCoordinateBranches = TContent extends unknown ? InternalDocumentContentCoordinateBranch : never; type InternalDocumentContentCoordinate = InternalDocumentNormalizeBranches>; type InternalDocumentDescendItemBranch = TItem extends InternalDocumentBroadSubtree ? InternalDocumentBroadSubtree : TItem extends InternalDocumentMissingCoordinate ? InternalDocumentInvalidStaticPath : TItem extends Readonly<{ kind: "text"; }> ? InternalDocumentInvalidStaticPath : TItem extends Readonly<{ kind: "element"; content: infer TContent; }> ? TContent extends "broad" ? InternalDocumentBroadSubtree : InternalDocumentResolveContentPath : TItem extends Readonly<{ kind: "pick"; choices: infer TChoices extends readonly unknown[]; }> ? InternalDocumentNormalizeBranches> : InternalDocumentInvalidStaticPath; type InternalDocumentDescendItemBranches = TItem extends unknown ? InternalDocumentDescendItemBranch : never; type InternalDocumentDescendItem = InternalDocumentNormalizeBranches>; type InternalDocumentResolveContentPath = TPath extends readonly [ infer THead extends number, ...infer TRest extends readonly number[] ] ? InternalDocumentContentCoordinate extends infer TCoordinate ? TRest extends readonly [] ? TCoordinate : InternalDocumentDescendItem : never : InternalDocumentInvalidStaticPath; type InternalDocumentResolveRootBranch = TEvidence extends Readonly<{ kind: "document"; content: infer TContent; }> ? InternalDocumentResolveContentPath : InternalDocumentInvalidStaticPath; type InternalDocumentResolveRootBranches = TEvidence extends unknown ? InternalDocumentResolveRootBranch : never; type InternalDocumentLogicalPathDescriptor = unknown extends TEvidence ? InternalDocumentUnschematized : number extends TPath["length"] ? InternalDocumentBroadSubtree : TPath extends readonly [] ? InternalDocumentRootDescriptor : InternalDocumentNormalizeBranches>; type InternalDocumentDescriptorEndpoint = TDescriptor extends InternalDocumentInvalidStaticPath ? never : TDescriptor extends InternalDocumentMissingCoordinate ? undefined : TDescriptor extends InternalDocumentUnschematized ? InternalDocumentLegacyEndpoint : TDescriptor extends InternalDocumentRootDescriptor ? HsonNode : TDescriptor extends InternalDocumentBroadSubtree ? InternalDocumentSchemaEndpoint : TDescriptor extends Readonly<{ kind: "text"; }> ? string : TDescriptor extends Readonly<{ kind: "element"; }> ? HsonNode : TDescriptor extends Readonly<{ kind: "pick"; choices: infer TChoices extends readonly unknown[]; }> ? InternalDocumentDescriptorEndpoint : never; type InternalDocumentLogicalPathEndpoint = unknown extends TEvidence ? InternalDocumentLegacyEndpoint : number extends TPath["length"] ? InternalDocumentSchemaEndpoint : TPath extends readonly [] ? HsonNode : InternalDocumentDescriptorEndpoint>; type InternalDocumentResolveDescriptorPath = unknown extends TDescriptor ? InternalDocumentUnschematized : [TDescriptor] extends [InternalDocumentUnschematized] ? InternalDocumentUnschematized : number extends TPath["length"] ? InternalDocumentBroadSubtree : TPath extends readonly [] ? TDescriptor : [TDescriptor] extends [InternalDocumentRootDescriptor] ? InternalDocumentNormalizeBranches> : InternalDocumentDescendItem; type InternalDocumentWritableItemBranch = TDescriptor extends InternalDocumentMissingCoordinate ? never : TDescriptor extends InternalDocumentInvalidStaticPath ? never : TDescriptor extends InternalDocumentBroadSubtree ? string | HsonNode : TDescriptor extends Readonly<{ kind: "text"; }> ? string : TDescriptor extends Readonly<{ kind: "element"; }> ? HsonNode : TDescriptor extends Readonly<{ kind: "pick"; choices: infer TChoices extends readonly unknown[]; }> ? InternalDocumentWritableItemBranches : never; type InternalDocumentWritableItemBranches = TDescriptor extends unknown ? InternalDocumentWritableItemBranch : never; type InternalDocumentWritableItem = unknown extends TDescriptor ? LiveMapDocumentContent : TDescriptor extends InternalDocumentUnschematized ? LiveMapDocumentContent : TDescriptor extends InternalDocumentRootDescriptor ? LiveMapDocumentContent : InternalDocumentWritableItemBranches; type InternalDocumentContentWritableItems = TContent extends Readonly<{ kind: "sequence"; items: infer TItems extends readonly unknown[]; }> ? InternalDocumentWritableItemBranches : TContent extends Readonly<{ kind: "repeat"; item: infer TItem; }> ? InternalDocumentWritableItemBranches : TContent extends Readonly<{ kind: "counted-repeat"; item: infer TItem; }> ? InternalDocumentWritableItemBranches : TContent extends Readonly<{ kind: "pick"; choices: infer TChoices extends readonly unknown[]; }> ? InternalDocumentContentWritableItems : never; declare const LIVEMAP_DOCUMENT_CONTENT_OWNER: unique symbol; type InternalDocumentContentOwner = Readonly<{ [LIVEMAP_DOCUMENT_CONTENT_OWNER]: TItem; }>; declare const LIVEMAP_DOCUMENT_NOT_CONTENT_OWNER: unique symbol; type InternalDocumentNotContentOwner = Readonly<{ [LIVEMAP_DOCUMENT_NOT_CONTENT_OWNER]: true; }>; type InternalDocumentRootInsertOwner = TEvidence extends Readonly<{ kind: "document"; content: infer TContent; }> ? InternalDocumentContentOwner> : InternalDocumentNotContentOwner; type InternalDocumentInsertOwnerBranch = TDescriptor extends InternalDocumentBroadSubtree ? InternalDocumentContentOwner : TDescriptor extends InternalDocumentRootDescriptor ? InternalDocumentRootInsertOwner : TDescriptor extends Readonly<{ kind: "element"; content: infer TContent; }> ? InternalDocumentContentOwner> : TDescriptor extends Readonly<{ kind: "pick"; choices: infer TChoices extends readonly unknown[]; }> ? InternalDocumentInsertOwnerBranches : InternalDocumentNotContentOwner; type InternalDocumentInsertOwnerBranches = TDescriptor extends unknown ? InternalDocumentInsertOwnerBranch : never; type InternalDocumentInsertOwnerDomain = TOwners extends InternalDocumentContentOwner ? TItem : never; type InternalDocumentInsertItem = unknown extends TDescriptor ? LiveMapDocumentContent : TDescriptor extends InternalDocumentUnschematized ? LiveMapDocumentContent : InternalDocumentInsertOwnerBranches extends infer TOwners ? [Extract>] extends [never] ? LiveMapDocumentContent : InternalDocumentInsertOwnerDomain : LiveMapDocumentContent; type InternalDocumentAttrsEvidenceBranch = TDescriptor extends InternalDocumentUnschematized | InternalDocumentBroadSubtree ? "broad" : TDescriptor extends InternalDocumentRootDescriptor ? InternalDocumentAttrsEvidenceBranch : TDescriptor extends Readonly<{ kind: "element"; attrs: infer TAttrs; }> ? TAttrs : TDescriptor extends Readonly<{ kind: "pick"; choices: infer TChoices extends readonly unknown[]; }> ? InternalDocumentAttrsEvidenceBranches : "broad"; type InternalDocumentAttrsEvidenceBranches = TDescriptor extends unknown ? InternalDocumentAttrsEvidenceBranch : never; type InternalDocumentLocationAttrsEvidence = unknown extends TDescriptor ? "broad" : InternalDocumentAttrsEvidenceBranches; type InternalAttrsDeclaredKeys = TAttrs extends DocumentAttrsEvidence ? keyof TShape & string : never; type InternalAttrsHasOpenBranch = TAttrs extends unknown ? TAttrs extends "broad" ? true : TAttrs extends DocumentAttrsEvidence ? TExact extends false ? true : false : true : never; type InternalAttrsName = true extends InternalAttrsHasOpenBranch ? string : InternalAttrsDeclaredKeys; type InternalAttrRuleAt = TAttrs extends DocumentAttrsEvidence ? TName extends keyof TShape ? TShape[TName] : TExact extends false ? DocumentAttrValueEvidence : DocumentAttrValueEvidence : TAttrs extends "broad" ? DocumentAttrValueEvidence : never; type InternalAttrReadBranch = TRule extends DocumentAttrValueEvidence ? TValue | (TOptional extends true ? undefined : never) : undefined; type InternalAttrRead = TAttrs extends unknown ? InternalAttrReadBranch> : never; type InternalAttrWriteValue = TAttrs extends unknown ? InternalAttrRuleAt extends DocumentAttrValueEvidence ? TValue : never : never; type InternalAttrsRequiredKeys = { [TKey in keyof TShape]: TShape[TKey] extends DocumentAttrValueEvidence ? TKey : never; }[keyof TShape]; type InternalAttrsOptionalKeys = Exclude>; type InternalAttrsCompleteShape = Readonly<{ [TKey in InternalAttrsRequiredKeys]: TShape[TKey] extends DocumentAttrValueEvidence ? TValue : never; } & { [TKey in InternalAttrsOptionalKeys]?: TShape[TKey] extends DocumentAttrValueEvidence ? TValue : never; }>; type InternalAttrsPatchShape = Readonly<{ [TKey in keyof TShape]?: TShape[TKey] extends DocumentAttrValueEvidence ? TValue : never; }>; type InternalAttrsSetManyInput = TAttrs extends "broad" ? LiveMapDocumentAttrs : TAttrs extends DocumentAttrsEvidence ? TExact extends true ? InternalAttrsPatchShape : InternalAttrsPatchShape & Readonly> : LiveMapDocumentAttrs; type InternalAttrsReplaceInput = TAttrs extends "broad" ? LiveMapDocumentAttrs : TAttrs extends DocumentAttrsEvidence ? TExact extends true ? InternalAttrsCompleteShape : InternalAttrsCompleteShape & Readonly> : LiveMapDocumentAttrs; type InternalAttrsKeys = true extends InternalAttrsHasOpenBranch ? string : InternalAttrsDeclaredKeys; type InternalFlagNameAllowedBranch = TAttrs extends "broad" ? TName : TAttrs extends DocumentAttrsEvidence ? TName extends keyof TShape ? TShape[TName] extends DocumentAttrValueEvidence ? TName extends TValue ? TName : never : never : TExact extends false ? TName : never : TName; type InternalFlagNameAllowed = TAttrs extends unknown ? InternalFlagNameAllowedBranch : never; type InternalLocationAttrsApi = InternalDocumentLocationAttrsEvidence extends infer TAttrs ? Readonly<{ get: >(name: TName) => InternalAttrRead; has: >(name: TName) => boolean; keys: () => readonly InternalAttrsKeys[]; must: Readonly<{ get: >(name: TName) => Exclude, undefined>; }>; set: >(name: TName, value: NoInfer>) => LiveMapGraphCommit; drop: >(name: TName) => LiveMapGraphCommit; setMany: (values: InternalAttrsSetManyInput) => LiveMapGraphCommit; dropMany: (names: readonly InternalAttrsName[]) => LiveMapGraphCommit; clear: () => LiveMapGraphCommit; replace: (values: InternalAttrsReplaceInput) => LiveMapGraphCommit; }> : never; type InternalLocationFlagsApi = InternalDocumentLocationAttrsEvidence extends infer TAttrs ? Readonly<{ has: (name: TName & InternalFlagNameAllowed) => boolean; set: (...names: TNames & { [TIndex in keyof TNames]: TNames[TIndex] extends string ? InternalFlagNameAllowed : never; }) => LiveMapGraphCommit; clear: (...names: TNames & { [TIndex in keyof TNames]: TNames[TIndex] extends string ? InternalFlagNameAllowed : never; }) => LiveMapGraphCommit; }> : never; type DocumentLiveMapShared = Readonly<{ readonly mode: TMode; readonly rev: number; root: () => HsonNode; /** Create a passive location at one logical ordered-content coordinate. */ at(path: TPath & ([InternalDocumentLogicalPathEndpoint] extends [never] ? never : unknown)): LiveMapDocumentLocation, InternalDocumentLogicalPathDescriptor>; /** Create a passive numeric proxy over logical ordered document content. */ proxy: (path?: TPath & ([InternalDocumentLogicalPathEndpoint] extends [never] ? never : unknown)) => LiveMapDocumentProxy>; capture: DocumentLiveMapCaptureApi; /** Atomically replace this document with a canonical same-mode capture. */ install: (capture: DocumentLiveMapCapture, options?: DocumentLiveMapInstallOptions) => LiveMapGraphCommit; /** Restore one same-mode canonical snapshot at its exact captured revision. */ restore: (capture: DocumentLiveMapCapture, options?: DocumentLiveMapInstallOptions) => void; /** Atomically replay one validated canonical graph commit. */ replay: (commit: LiveMapGraphCommit) => LiveMapGraphCommit; /** Observe successful canonical graph commits without data path coercion. */ commits: LiveMapCommitObserverApi; /** Permanent owner-level document schema attachment. */ schema: DocumentLiveMapGovernanceApi; }>; /** Structural return type for document `at(...)`; intentionally not exported. */ type LiveMapDocumentLocation = Readonly<{ /** Current revision of the owning document map. */ readonly rev: number; /** Return a detached copy of this logical authoring coordinate. */ path: () => readonly number[]; /** Read the detached current occupant, or `undefined` when absent. */ snap: () => TValue; /** Observe future canonical value changes and explicit snapshot replacement. */ watch: (listener: (next: TValue) => void) => LiveMapDisposer; /** Create a child location relative to this logical coordinate. */ at(path: TPath & ([ InternalDocumentDescriptorEndpoint> ] extends [never] ? never : unknown)): LiveMapDocumentLocation>, InternalDocumentResolveDescriptorPath>; /** Discover the first exact canonical ID match in this logical subtree. */ id: (value: string) => LiveMapDocumentLocation | undefined; /** Replace the current logical content item through canonical document mutation. */ replace(value: InternalDocumentWritableItem): LiveMapGraphCommit; /** Remove the current logical content item through canonical document mutation. */ delete: () => LiveMapGraphCommit; /** Insert authored content into the ordered content owned by this location. */ insert(index: number, value: InternalDocumentInsertItem): LiveMapGraphCommit; /** Move one owned content item to its final index. */ move: (from: number, to: number) => LiveMapGraphCommit; /** Ordinary-attribute operations for the element currently at this location. */ attrs: InternalLocationAttrsApi; /** Semantic same-name flag operations for this element location. */ flags: InternalLocationFlagsApi; }>; type InternalDocumentTupleNumericKey = TKey extends `${infer TIndex extends number}` ? TIndex : never; type InternalDocumentCountedStaticKeys = number extends TCount ? never : TCursor["length"] extends TCount ? TKeys : InternalDocumentCountedStaticKeys; type InternalDocumentCountedStaticKeyBranches = TCount extends unknown ? InternalDocumentCountedStaticKeys : never; type InternalDocumentProxyContentStaticKeys = TContent extends Readonly<{ kind: "sequence"; items: infer TItems extends readonly unknown[]; }> ? InternalDocumentTupleNumericKey : TContent extends Readonly<{ kind: "counted-repeat"; count: infer TCount extends number; }> ? InternalDocumentCountedStaticKeyBranches : TContent extends Readonly<{ kind: "pick"; choices: infer TChoices extends readonly unknown[]; }> ? InternalDocumentProxyContentStaticKeys : never; type InternalDocumentProxyRootStaticKeys = TEvidence extends Readonly<{ kind: "document"; content: infer TContent; }> ? InternalDocumentProxyContentStaticKeys : never; type InternalDocumentProxyStaticKeys = TDescriptor extends InternalDocumentRootDescriptor ? InternalDocumentProxyRootStaticKeys : TDescriptor extends Readonly<{ kind: "element"; content: infer TContent; }> ? TContent extends "broad" ? never : InternalDocumentProxyContentStaticKeys : TDescriptor extends Readonly<{ kind: "pick"; choices: infer TChoices extends readonly unknown[]; }> ? InternalDocumentProxyStaticKeys : never; type InternalDocumentProxyExactChildren = Readonly<{ [TIndex in InternalDocumentProxyStaticKeys]: LiveMapDocumentProxy>; }>; type InternalDocumentProxyDynamicChildren = [ InternalDocumentDescriptorEndpoint> ] extends [never] ? Readonly> : Readonly<{ readonly [index: number]: LiveMapDocumentProxy>; }>; /** Structural document proxy return type; intentionally not exported. */ type LiveMapDocumentProxy = Readonly<{ readonly $_: LiveMapDocumentLocation, TDescriptor>; }> & InternalDocumentProxyExactChildren & InternalDocumentProxyDynamicChildren; /** One rooted document authority whose ordered content may contain zero, one, or many nodes. */ export type DocumentLiveMap = DocumentLiveMapShared<"document", TEvidence> & Readonly<{ readonly document: LiveMapDocumentApi; }>; /** Mode-neutral authority boundary shared by schema-narrowed data and document maps. */ export type LiveMapAuthority = Readonly<{ readonly mode: LiveMapRootMode; readonly rev: number; root: () => HsonNode; /** Mode-specific captures share an atomic authoritative revision. */ capture: () => Readonly<{ rev: number; }>; commits: LiveMapCommitObserverApi; }>; /** Result of Hson/node construction after canonical root classification. */ export type ClassifiedLiveMap = LiveMap | DocumentLiveMap; /** One explicit initial library input for a public multi-library LiveMap. */ export type LiveMapDataLibraryInput = HsonSchema> = Readonly<{ /** Existing `fromJson` input: a JSON value or JSON source text. */ data: JsonValue | string; schema: TSchema; document?: never; }>; /** One explicit initial document library input for a public multi-library LiveMap. */ export type LiveMapDocumentLibraryInput = HsonSchema> = Readonly<{ /** Existing `fromHson`/`fromNode` material: Hson source text or a canonical node. */ document: string | HsonNode; schema: TSchema; data?: never; }>; /** Discriminated initial material for one statically named Library. */ export type LiveMapLibraryInput = LiveMapDataLibraryInput | LiveMapDocumentLibraryInput; /** The complete static registry accepted by `hsonLiveMap.fromLibraries(...)`. */ export type LiveMapLibrariesInput = Readonly>; /** Recover the generated value type mechanically associated with a Schema. */ export type HsonSchemaValue = TSchema extends HsonSchema ? TValue : unknown; /** One publicly named operation in the map-wide ordered commit stream. */ export type LiveMapLibraryOperation = Readonly<{ library: TLibrary; operation: TOperation; }>; /** * A truthful local multi-library commit. `operations` is one ordered stream; * it may contain one or several library names and always advances one map-wide * revision. */ export type LiveMapMultiLibraryCommit = Readonly<{ kind: "multi-library"; changed: boolean; prevRev: number; rev: number; operations: readonly LiveMapLibraryOperation[]; }>; /** One selected data handle relative to its Library, never to a library name path segment. */ export type LiveMapLibraryPathHandle = Readonly<{ readonly rev: number; path: () => LivePath; snap: () => TValue; /** Read this path as exact canonical data. */ data: () => HsonData | undefined; at: (path: TPath & ([LiveMapPathValue] extends [never] ? never : unknown)) => LiveMapLibraryPathHandle, TLibrary>; set: (value: LiveMapSetValue) => LiveMapMultiLibraryCommit; replace: (value: LiveMapWriteValue) => LiveMapMultiLibraryCommit; delete: () => LiveMapMultiLibraryCommit; update: (updater: (value: TValue) => LiveMapSetValue) => LiveMapMultiLibraryCommit; }>; /** Read authority for one selected data Library. */ export type LiveMapDataLibrary = Readonly<{ readonly mode: DataLiveMapMode; readonly rev: number; root: () => HsonNode; snap: { (): TValue; (path: TPath & ([LiveMapPathValue] extends [never] ? never : unknown)): LiveMapPathValue; }; at: (path: TPath & ([LiveMapPathValue] extends [never] ? never : unknown)) => LiveMapLibraryPathHandle, TLibrary>; schema: Readonly<{ get: () => TSchema; }>; }>; type LiveMapLibraryDocumentCommit = LiveMapMultiLibraryCommit; type LiveMapLibraryDocumentAttrsApi = DocumentLiveMapAttrsReadApi & Readonly<{ set: (target: LiveMapDocumentRequestTarget, name: string, value: LiveMapDocumentAttributeValue) => LiveMapLibraryDocumentCommit; drop: (target: LiveMapDocumentRequestTarget, name: string) => LiveMapLibraryDocumentCommit; setMany: (target: LiveMapDocumentRequestTarget, values: LiveMapDocumentAttrs) => LiveMapLibraryDocumentCommit; dropMany: (target: LiveMapDocumentRequestTarget, names: readonly string[]) => LiveMapLibraryDocumentCommit; clear: (target: LiveMapDocumentRequestTarget) => LiveMapLibraryDocumentCommit; replace: (target: LiveMapDocumentRequestTarget, values: LiveMapDocumentAttrs) => LiveMapLibraryDocumentCommit; }>; type LiveMapLibraryDocumentFlagsApi = DocumentLiveMapFlagsReadApi & Readonly<{ set: (target: LiveMapDocumentRequestTarget, ...names: string[]) => LiveMapLibraryDocumentCommit; clear: (target: LiveMapDocumentRequestTarget, ...names: string[]) => LiveMapLibraryDocumentCommit; }>; type LiveMapLibraryDocumentLocation = Readonly<{ readonly rev: number; path: () => readonly number[]; snap: () => TValue; watch: (listener: (next: TValue) => void) => LiveMapDisposer; at(path: TPath & ([ InternalDocumentDescriptorEndpoint> ] extends [never] ? never : unknown)): LiveMapLibraryDocumentLocation>, InternalDocumentResolveDescriptorPath>; id: (value: string) => LiveMapLibraryDocumentLocation | undefined; replace: (value: InternalDocumentWritableItem) => LiveMapLibraryDocumentCommit; delete: () => LiveMapLibraryDocumentCommit; insert: (index: number, value: InternalDocumentInsertItem) => LiveMapLibraryDocumentCommit; move: (from: number, to: number) => LiveMapLibraryDocumentCommit; attrs: InternalDocumentLocationAttrsEvidence extends infer TAttrs ? Readonly<{ get: >(name: TName) => InternalAttrRead; has: >(name: TName) => boolean; keys: () => readonly InternalAttrsKeys[]; must: Readonly<{ get: >(name: TName) => Exclude, undefined>; }>; set: >(name: TName, value: NoInfer>) => LiveMapLibraryDocumentCommit; drop: >(name: TName) => LiveMapLibraryDocumentCommit; setMany: (values: InternalAttrsSetManyInput) => LiveMapLibraryDocumentCommit; dropMany: (names: readonly InternalAttrsName[]) => LiveMapLibraryDocumentCommit; clear: () => LiveMapLibraryDocumentCommit; replace: (values: InternalAttrsReplaceInput) => LiveMapLibraryDocumentCommit; }> : never; flags: InternalDocumentLocationAttrsEvidence extends infer TAttrs ? Readonly<{ has: (name: TName & InternalFlagNameAllowed) => boolean; set: (...names: TNames & { [TIndex in keyof TNames]: TNames[TIndex] extends string ? InternalFlagNameAllowed : never; }) => LiveMapLibraryDocumentCommit; clear: (...names: TNames & { [TIndex in keyof TNames]: TNames[TIndex] extends string ? InternalFlagNameAllowed : never; }) => LiveMapLibraryDocumentCommit; }> : never; }>; /** One selected named document authority. Its writes retain the map-global commit envelope. */ export type LiveMapDocumentLibrary = Readonly<{ readonly mode: DocumentLiveMapMode; readonly rev: number; root: () => HsonNode; at(path: TPath & ([InternalDocumentLogicalPathEndpoint] extends [never] ? never : unknown)): LiveMapLibraryDocumentLocation, InternalDocumentLogicalPathDescriptor>; proxy: (path?: TPath & ([InternalDocumentLogicalPathEndpoint] extends [never] ? never : unknown)) => Readonly<{ readonly $_: LiveMapLibraryDocumentLocation>, InternalDocumentLogicalPathDescriptor>; }>; capture: DocumentLiveMapCaptureApi<"document">; document: Readonly<{ root: () => HsonNode; content: (() => readonly NodeContent[number][]) & Readonly<{ replace: (target: LiveMapDocumentRequestTarget, index: number, replacement: LiveMapDocumentContent) => LiveMapLibraryDocumentCommit; insert: (target: LiveMapDocumentRequestTarget, index: number, content: LiveMapDocumentContent) => LiveMapLibraryDocumentCommit; remove: (target: LiveMapDocumentRequestTarget, index: number) => LiveMapLibraryDocumentCommit; move: (target: LiveMapDocumentRequestTarget, from: number, to: number) => LiveMapLibraryDocumentCommit; }>; byQuid: (quid: string) => HsonNode | undefined; attrs: LiveMapLibraryDocumentAttrsApi; flags: LiveMapLibraryDocumentFlagsApi; }>; /** Global-revision selected-document observations used by one Reflect binding. */ commits: LiveMapCommitObserverApi; schema: Readonly<{ get: () => TSchema; }>; }>; type LiveMapLibraryFacadeForInput = TInput extends LiveMapDataLibraryInput ? LiveMapDataLibrary, TLibrary, TSchema> : TInput extends LiveMapDocumentLibraryInput ? LiveMapDocumentLibrary, TLibrary, TSchema> : never; /** The single global observer surface for a local multi-library LiveMap. */ export type LiveMapMultiLibraryCommitObserverApi = Readonly<{ observe: (listener: (commit: LiveMapMultiLibraryCommit) => void) => LiveMapDisposer; }>; declare const liveMapLibrariesType: unique symbol; /** * A statically established collection of canonical Libraries. It has no * default root and intentionally exposes neither topology mutation nor Locus * authority in this first local release. */ export type LiveMapLibraries = Readonly<{ /** Private type evidence; it has no runtime property or public selector. */ readonly [liveMapLibrariesType]: TLibraries; readonly rev: number; lib: >(name: TLibrary) => LiveMapLibraryFacadeForInput; /** Capture one detached semantic cut of the complete public and hidden registry. */ capture: () => LiveMapLibrariesSnapshot; commits: LiveMapMultiLibraryCommitObserverApi>; }>; /** * Normalized set operation emitted by a LiveMap mutation. * * Ops are intentionally data-shaped and replayable. Primitive/array/null * `set(...)`, shallow child writes from object-valued `set(...)` and * `setMany(...)`, array helper rewrites, and `update(fn)` commits report `set` * ops at the data paths they changed. */ export type LiveMapSetOp = Readonly<{ kind: "set"; path: LivePath; prev: JsonValue | undefined; next: JsonValue | undefined; }>; /** * Normalized delete operation emitted by a LiveMap mutation. * * Delete is distinct from `set(undefined)` because undefined is not a JSON value * and should not become part of the set-value surface. */ export type LiveMapDeleteOp = Readonly<{ kind: "delete"; path: LivePath; prev: JsonValue | undefined; next: undefined; }>; /** * Normalized endpoint replacement operation emitted by a LiveMap mutation. * * Root replacement is intentionally distinct from `set([])`: projected child * path writes still reject empty paths, while `replace(...)` makes exact * root/endpoint overwrite explicit. The runtime overwrites the existing root * node in place for root replacement so existing handles stay attached. */ export type LiveMapReplaceOp = Readonly<{ kind: "replace"; path: LivePath; prev: JsonValue | undefined; next: JsonValue | undefined; }>; /** Identity-preserving movement of one own object entry to a new key. */ export type LiveMapRenameOp = Readonly<{ kind: "rename"; path: LivePath; from: string; to: string; prev: JsonValue; next: JsonValue; }>; /** Identity-preserving movement of one array item to its final index. */ export type LiveMapMoveOp = Readonly<{ kind: "move"; path: LivePath; from: number; to: number; prev: JsonValue; next: JsonValue; }>; /** Normalized operation emitted by a LiveMap mutation. */ export type LiveMapDataOp = LiveMapSetOp | LiveMapDeleteOp | LiveMapReplaceOp | LiveMapSpliceOp | LiveMapRenameOp | LiveMapMoveOp; /** Complete canonical document-root replacement; deliberately not a data op. */ export type LiveMapGraphReplaceRootOp = Readonly<{ domain: "graph"; op: "replace-root"; mode: DocumentLiveMapMode; root: HsonNode; }>; export type LiveMapGraphSetAttrOp = Readonly<{ domain: "graph"; op: "set-attr"; target: LiveMapDocumentCommitTarget; name: string; value: LiveMapDocumentAttributeValue; }>; export type LiveMapGraphRemoveAttrOp = Readonly<{ domain: "graph"; op: "remove-attr"; target: LiveMapDocumentCommitTarget; name: string; }>; /** Atomic final-state replacement of one element's complete ordinary attribute bag. */ export type LiveMapGraphReplaceAttrsOp = Readonly<{ domain: "graph"; op: "replace-attrs"; target: LiveMapDocumentCommitTarget; attrs: LiveMapDocumentAttrs; }>; export type LiveMapGraphReplaceContentOp = Readonly<{ domain: "graph"; op: "replace-content"; target: LiveMapDocumentCommitTarget; index: number; replacement: LiveMapDocumentContent; }>; export type LiveMapGraphInsertContentOp = Readonly<{ domain: "graph"; op: "insert-content"; target: LiveMapDocumentCommitTarget; index: number; content: LiveMapDocumentContent; }>; export type LiveMapGraphRemoveContentOp = Readonly<{ domain: "graph"; op: "remove-content"; target: LiveMapDocumentCommitTarget; index: number; }>; export type LiveMapGraphMoveContentOp = Readonly<{ domain: "graph"; op: "move-content"; target: LiveMapDocumentCommitTarget; from: number; to: number; }>; /** Canonical graph-domain operations; distinct from projected JSON writes. */ export type LiveMapGraphOp = LiveMapGraphReplaceRootOp | LiveMapGraphSetAttrOp | LiveMapGraphRemoveAttrOp | LiveMapGraphReplaceAttrsOp | LiveMapGraphReplaceContentOp | LiveMapGraphInsertContentOp | LiveMapGraphRemoveContentOp | LiveMapGraphMoveContentOp | LiveMapGraphEnsureQuidOp; /** Select a LiveMap operation domain; bare use preserves the existing data domain. */ export type LiveMapOp = TDomain extends "graph" ? LiveMapGraphOp : LiveMapDataOp; /** Full shared operation family used by the generic commit envelope. */ export type LiveMapAnyOp = LiveMapOp<"data" | "graph"> | LiveMapProjectedGraphEnsureQuidOp; type LiveMapObservedOp = LiveMapAnyOp | LiveMapGraphEnsureQuidOp | LiveMapProjectedGraphEnsureQuidOp; type LiveMapObservedGraphOp = LiveMapGraphOp | LiveMapGraphEnsureQuidOp | LiveMapProjectedGraphEnsureQuidOp; /** * Normalized mutation record returned by Core. * * A commit can contain zero, one, or many ops. Empty commits represent unchanged * writes/deletes. Multi-op commits are used by `setMany(...)`, object-valued * `set(...)`, and explicit `batch(...)` calls. Data-mode runtime commits also * carry the structural-JSON envelope used by exact replay. The fields remain * optional on this shared type because document graph commits do not use it. */ export type LiveMapStructuralJsonEnvelope = Readonly<{ format: "structural-json"; payload: string; }>; type LiveMapCommitFields = Readonly<{ changed: boolean; rev: number; prevRev: number; ops: readonly TOp[]; }>; export type LiveMapCommit = LiveMapCommitFields & ([TOp] extends [LiveMapDataOp] ? LiveMapStructuralJsonEnvelope : Partial); /** Existing commit envelope specialized to graph-domain operations. */ export type LiveMapGraphCommit = LiveMapCommitFields & Partial; /** Why a canonical commit became visible on one LiveMap instance. */ export type LiveMapCommitOrigin = "authoritative" | "replay"; /** Shared commit observation event across projected and canonical graph modes. */ export type LiveMapCommitObservation = Readonly<{ kind: "commit"; commit: LiveMapCommit; origin: "authoritative" | "replay"; }> | Readonly<{ kind: "snapshot"; origin: "snapshot"; revision: number; }>; export type LiveMapCommitObserver = (observation: LiveMapCommitObservation) => void; export type LiveMapCommitObserverApi = Readonly<{ observe: (observer: LiveMapCommitObserver) => LiveMapDisposer; }>; /** * Event delivered to a feed listener. * * `op` is the first matching op for compatibility. `ops` contains all matching * ops from the commit. `path` is the subscriber's path. `value` is the current * data value at the subscriber's path after the commit has been applied. */ export type LiveMapFeedEvent = Readonly<{ op: LiveMapDataOp; path: LivePath; value: JsonValue | undefined; ops: readonly LiveMapDataOp[]; commit: LiveMapCommit; }>; /** Listener called when a feed receives an overlapping operation. */ export type LiveMapFeedListener = (event: LiveMapFeedEvent) => void; /** Idempotent cleanup function returned by subscriptions and future bindings. */ export type LiveMapDisposer = () => void; export type LiveMapStoreEqual = (next: TValue, prev: TValue) => boolean; export type LiveMapStoreSubscribeOptions = Readonly<{ equal?: LiveMapStoreEqual; }>; export type LiveMapStoreListener = (next: TValue) => void; export type LiveMapStoreDiffListener = (next: TValue, prev: TValue) => void; export type LiveMapStoreSelectedListener = (next: TSelected, prev: TSelected, state: TValue) => void; export type LiveMapStorePathListener = (next: NoInfer>, prev: NoInfer>, event: LiveMapFeedEvent) => void; export type LiveMapStoreApi = Readonly<{ snapshot: () => TValue; subscribe: (listener: LiveMapStoreListener) => LiveMapDisposer; subscribeDiff: (listener: LiveMapStoreDiffListener) => LiveMapDisposer; subscribeSel: (selector: (state: TValue) => TSelected, listener: LiveMapStoreSelectedListener, options?: LiveMapStoreSubscribeOptions) => LiveMapDisposer; subscribePath: (path: TPath, listener: LiveMapStorePathListener, options?: LiveMapStoreSubscribeOptions>>) => LiveMapDisposer; }>; export type LiveMapSubApi = LiveMapStoreApi["subscribe"] & Readonly<{ diff: LiveMapStoreApi["subscribeDiff"]; sel: LiveMapStoreApi["subscribeSel"]; path: LiveMapStoreApi["subscribePath"]; }>; /** * Options for one-way LiveMap links. * * `{ path }` is the same-path shorthand: source ops overlapping `path` are * replayed at their original op path on the target. * * `{ from, to }` maps a source path prefix to a target path prefix. For example, * an op at `["draft", "name"]` with `{ from: ["draft"], to: ["user"] }` * replays to `["user", "name"]`. */ export type LiveMapLinkOptions = LiveMapSamePathLinkOptions | LiveMapMappedLinkOptions; /** One-way link where source and target use the same data path. */ export type LiveMapSamePathLinkOptions = Readonly<{ path: LivePath; }>; /** One-way link where source ops are translated from one path prefix to another. */ export type LiveMapMappedLinkOptions = Readonly<{ from: LivePath; to: LivePath; }>; export type LiveMapObjectShape = NonNullable extends readonly unknown[] ? Readonly> : NonNullable extends object ? NonNullable : Readonly>; export type LiveMapObjectKey = Extract, string>; export type LiveMapObjectValue = TKey extends keyof LiveMapObjectShape ? LiveMapObjectShape[TKey] : JsonValue | undefined; export type LiveMapObjectWriteValue> = LiveMapWriteValue[TKey]>; export type LiveMapObjectSetValue> = LiveMapSetValue[TKey]>; export type LiveMapObjectSetManyValues = string extends LiveMapObjectKey ? LiveMapSetManyValues : Readonly<{ [TKey in LiveMapObjectKey]?: LiveMapWriteValue[TKey]>; }>; export type LiveMapObjectEntry = { [TKey in LiveMapObjectKey]: readonly [TKey, LiveMapObjectValue]; }[LiveMapObjectKey]; export type LiveMapArrayShape = NonNullable extends readonly unknown[] ? NonNullable : readonly JsonValue[]; export type LiveMapArrayItem = LiveMapArrayShape extends readonly (infer TItem)[] ? TItem : JsonValue; export type LiveMapArrayWriteItem = LiveMapWriteValue>; export type LiveMapPathHandle = Readonly<{ /** Current revision of the owning LiveMap. */ readonly rev: number; path: () => LivePath; snap: () => TValue; /** Read this path as exact canonical data. */ data: () => HsonData | undefined; /** Create a child handle relative to this handle's data path. */ at: (path: TPath & ([LiveMapPathValue] extends [never] ? never : unknown)) => LiveMapPathHandle>; /** Set this resolved handle path; plain objects expand into shallow child sets. */ set: (value: LiveMapSetValue) => LiveMapCommit; /** Exact replacement at this handle path using replace-shaped commit ops. */ replace: (value: LiveMapWriteValue) => LiveMapCommit; /** Shallow object set below this handle path, preserving unspecified siblings. */ setMany: (values: NoInfer>) => LiveMapCommit; /** Delete this handle path. */ delete: () => LiveMapCommit; update: (updater: (value: TValue) => LiveMapSetValue) => LiveMapCommit; array: LiveMapPathArrayApi; object: LiveMapPathObjectApi; feed: (listener: LiveMapFeedListener) => LiveMapDisposer; /** Observe future canonical value changes and explicit snapshot replacement. */ watch: (listener: (next: TValue) => void) => LiveMapDisposer; linkTo: (target: LiveMapPathHandle) => LiveMapDisposer; }>; export type LiveMapPathObjectApi = Readonly<{ is: () => boolean; toObject: () => LiveMapObjectShape; pick: (keys: TKeys) => Pick, Extract>>; omit: (keys: TKeys) => Omit, Extract>>; hasKey: (key: TKey) => boolean; getKey: (key: TKey) => LiveMapObjectValue; keys: () => readonly LiveMapObjectKey[]; isEmpty: () => boolean; size: () => number; values: () => readonly LiveMapObjectShape[LiveMapObjectKey][]; entries: () => readonly LiveMapObjectEntry[]; /** Set one child key under this object path, creating that key if needed. */ setKey: >(key: TKey, value: NoInfer>) => LiveMapCommit; /** Shallow child-key writes under this object path, preserving unspecified siblings. */ setMany: (values: NoInfer>) => LiveMapCommit; clear: () => LiveMapCommit; deleteKey: (key: string) => LiveMapCommit; deleteMany: (keys: readonly string[]) => LiveMapCommit; renameKey: (fromKey: string, toKey: string) => LiveMapCommit; }>; /** * Array-scoped helper API. * * Helpers require the array path itself to resolve. Array move retains semantic * movement intent; other whole-array transformations may use endpoint writes. */ export type LiveMapPathArrayApi = Readonly<{ is: () => boolean; toArray: () => LiveMapArrayShape; slice: (start?: number, end?: number) => LiveMapArrayShape; take: (count: number) => LiveMapArrayShape; drop: (count: number) => LiveMapArrayShape; takeLast: (count: number) => LiveMapArrayShape; dropLast: (count: number) => LiveMapArrayShape; length: () => number; isEmpty: () => boolean; at: (index: number) => LiveMapArrayItem; first: () => LiveMapArrayItem; last: () => LiveMapArrayItem; includes: (value: JsonValue) => boolean; indexOf: (value: JsonValue) => number; push: (value: NoInfer>) => LiveMapCommit; pushMany: (values: readonly NoInfer>[]) => LiveMapCommit; unshift: (value: NoInfer>) => LiveMapCommit; unshiftMany: (values: readonly NoInfer>[]) => LiveMapCommit; pop: () => LiveMapCommit; shift: () => LiveMapCommit; clear: () => LiveMapCommit; reverse: () => LiveMapCommit; sortNumbers: (direction?: LiveMapSortDirection) => LiveMapCommit; sortStrings: (direction?: LiveMapSortDirection) => LiveMapCommit; splice: (...args: [start: number] | [start: number, deleteCount: number, ...items: NoInfer>[]]) => LiveMapCommit; insert: (index: number, value: NoInfer>) => LiveMapCommit; remove: (index: number) => LiveMapCommit; replace: (index: number, value: NoInfer>) => LiveMapCommit; move: (fromIndex: number, toIndex: number) => LiveMapCommit; unique: () => LiveMapCommit; removeValue: (value: JsonValue) => LiveMapCommit; removeAll: (value: JsonValue) => LiveMapCommit; }>; export type HsonSchemaIssueCode = "TYPE_MISMATCH" | "MISSING_REQUIRED" | "UNKNOWN_PATH" | "UNKNOWN_KEY" | "INVALID_LITERAL" | "INVALID_CONSTRAINT" | "INVALID_SCHEMA" | "TUPLE_INDEX_OUT_OF_RANGE"; export type LiveMapSpliceOp = Readonly<{ kind: "splice"; path: LivePath; start: number; removed: readonly JsonValue[]; inserted: readonly JsonValue[]; prev: JsonValue; next: JsonValue; }>; /** Canonical projected-state capture with detached exact graph metadata. */ export type LiveMapCapture = Readonly<{ rev: number; root: HsonNode; }> & LiveMapStructuralJsonEnvelope; export type LiveMapApply = Readonly<{ prevRev: number; }> & LiveMapStructuralJsonEnvelope; export type LiveMapReplay = Readonly<{ prevRev: number; }> & LiveMapStructuralJsonEnvelope; export {}; //# sourceMappingURL=livemap.types.d.ts.map