import * as i0 from '@angular/core'; import { InjectionToken } from '@angular/core'; declare const SD_GRAPH_FORMAT = "sdcorejs.graph"; declare const SD_GRAPH_VERSION = 1; type SdPersistenceErrorCode = 'INVALID_DOCUMENT' | 'UNKNOWN_FORMAT' | 'UNKNOWN_VERSION' | 'INVALID_NODE' | 'INVALID_REFERENCE' | 'UNSUPPORTED_VALUE' | 'LIMIT_EXCEEDED'; interface SdGraphSerializerLimits { maxDocumentCharacters: number; maxDepth: number; maxNodes: number; maxEntries: number; maxStringCharacters: number; maxKeyCharacters: number; maxBigIntDigits: number; } interface SdPersistenceSerializer { readonly format: string; stringify(value: T): string; parse(serialized: string): T; clone(value: T): T; } /** Deterministic, versioned canonicalization used only for persistence identity. */ interface SdPersistenceIdentityCanonicalizer { readonly format: string; canonicalize(value: unknown): string; } type SdGraphSpecialNumber = 'NaN' | 'Infinity' | '-Infinity' | '-0'; type SdGraphValue = null | boolean | string | number | { $ref: number; } | { $type: 'undefined'; } | { $type: 'number'; value: SdGraphSpecialNumber; } | { $type: 'bigint'; value: string; }; interface SdGraphArrayNode { type: 'array'; values: SdGraphValue[]; } interface SdGraphObjectNode { type: 'object'; prototype: 'object' | 'null'; entries: [string, SdGraphValue][]; } interface SdGraphDateNode { type: 'date'; value: string; } interface SdGraphMapNode { type: 'map'; entries: [SdGraphValue, SdGraphValue][]; } interface SdGraphSetNode { type: 'set'; values: SdGraphValue[]; } type SdGraphNode = SdGraphArrayNode | SdGraphObjectNode | SdGraphDateNode | SdGraphMapNode | SdGraphSetNode; interface SdGraphEnvelope { format: typeof SD_GRAPH_FORMAT; version: typeof SD_GRAPH_VERSION; root: SdGraphValue; nodes: SdGraphNode[]; } declare const SD_GRAPH_HARD_LIMITS: Readonly; declare class SdPersistenceError extends Error { readonly code: SdPersistenceErrorCode; readonly name = "SdPersistenceError"; constructor(code: SdPersistenceErrorCode, message: string); } declare class SdGraphSerializer implements SdPersistenceSerializer { #private; readonly format = "sdcorejs.graph@1"; readonly limits: Readonly; constructor(limits?: Partial); stringify(value: T): string; parse(serialized: string): T; clone(value: T): T; } type SdPersistenceStorageArea = 'local' | 'session'; type SdPersistenceStorageRead = { status: 'found'; value: string; } | { status: 'absent'; } | { status: 'unavailable'; }; interface SdPersistenceStorageAdapter { /** Optional tri-state read. Legacy adapters may continue to implement only `getItem`. */ readItem?(area: SdPersistenceStorageArea, key: string): SdPersistenceStorageRead; getItem(area: SdPersistenceStorageArea, key: string): string | null; setItem(area: SdPersistenceStorageArea, key: string, value: string): boolean; removeItem(area: SdPersistenceStorageArea, key: string): boolean; } declare class SdBrowserStorageAdapter implements SdPersistenceStorageAdapter { #private; readItem(area: SdPersistenceStorageArea, key: string): SdPersistenceStorageRead; getItem(area: SdPersistenceStorageArea, key: string): string | null; setItem(area: SdPersistenceStorageArea, key: string, value: string): boolean; removeItem(area: SdPersistenceStorageArea, key: string): boolean; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare function readSdPersistenceStorageItem(adapter: SdPersistenceStorageAdapter, area: SdPersistenceStorageArea, key: string): SdPersistenceStorageRead; declare const SD_PERSISTENCE_STORAGE_ADAPTER: InjectionToken; interface SdPersistenceKeyField { tag: string; value: string; } declare class SdPersistenceIdentityError extends Error { readonly name = "SdPersistenceIdentityError"; constructor(message: string); } declare function buildSdPersistenceKey(baseKey: string, fields: readonly SdPersistenceKeyField[]): string; declare class SdGraphIdentityCanonicalizer implements SdPersistenceIdentityCanonicalizer { #private; readonly format = "sdcorejs.graph-identity@1"; canonicalize(value: unknown): string; } declare function canonicalizeSdPersistenceValue(canonicalizer: SdPersistenceIdentityCanonicalizer, value: unknown, label: string): string; declare function digestSdPersistenceKey(value: string): string; declare const SD_PERSISTENCE_ENVELOPE_FORMAT = "sdcorejs.persistence-envelope"; declare const SD_PERSISTENCE_ENVELOPE_VERSION = 1; interface SdPersistenceEnvelopeLimits { maxDocumentCharacters: number; maxPayloadCharacters: number; maxSerializerCharacters: number; maxIdentityCharacters: number; } declare const SD_PERSISTENCE_ENVELOPE_HARD_LIMITS: Readonly; interface SdPersistenceValueEnvelope { format: typeof SD_PERSISTENCE_ENVELOPE_FORMAT; version: typeof SD_PERSISTENCE_ENVELOPE_VERSION; kind: 'value'; identity: string; serializer: string; payload: string; } interface SdPersistenceTombstoneEnvelope { format: typeof SD_PERSISTENCE_ENVELOPE_FORMAT; version: typeof SD_PERSISTENCE_ENVELOPE_VERSION; kind: 'tombstone'; identity: string; serializer: string; } type SdPersistenceEnvelope = SdPersistenceValueEnvelope | SdPersistenceTombstoneEnvelope; declare function stringifySdPersistenceValueEnvelope(identity: string, serializer: string, payload: string, limits?: Partial): string; declare function stringifySdPersistenceTombstoneEnvelope(identity: string, serializer: string, limits?: Partial): string; declare function parseSdPersistenceEnvelope(serialized: string, expectedIdentity: string, expectedSerializer: string, limits?: Partial): SdPersistenceEnvelope | undefined; export { SD_GRAPH_FORMAT, SD_GRAPH_HARD_LIMITS, SD_GRAPH_VERSION, SD_PERSISTENCE_ENVELOPE_FORMAT, SD_PERSISTENCE_ENVELOPE_HARD_LIMITS, SD_PERSISTENCE_ENVELOPE_VERSION, SD_PERSISTENCE_STORAGE_ADAPTER, SdBrowserStorageAdapter, SdGraphIdentityCanonicalizer, SdGraphSerializer, SdPersistenceError, SdPersistenceIdentityError, buildSdPersistenceKey, canonicalizeSdPersistenceValue, digestSdPersistenceKey, parseSdPersistenceEnvelope, readSdPersistenceStorageItem, stringifySdPersistenceTombstoneEnvelope, stringifySdPersistenceValueEnvelope }; export type { SdGraphArrayNode, SdGraphDateNode, SdGraphEnvelope, SdGraphMapNode, SdGraphNode, SdGraphObjectNode, SdGraphSerializerLimits, SdGraphSetNode, SdGraphSpecialNumber, SdGraphValue, SdPersistenceEnvelope, SdPersistenceEnvelopeLimits, SdPersistenceErrorCode, SdPersistenceIdentityCanonicalizer, SdPersistenceKeyField, SdPersistenceSerializer, SdPersistenceStorageAdapter, SdPersistenceStorageArea, SdPersistenceStorageRead, SdPersistenceTombstoneEnvelope, SdPersistenceValueEnvelope };