import 'reflect-metadata'; import { JsonSchema } from './JsonSchema.js'; /** * Generates JSON schemas for class constructors using reflection metadata. */ export interface JsonSchemaGenerationOptions { /** Reject members and array elements without runtime types. Defaults to true for standard-decorated classes. */ readonly requireResolvedTypes?: boolean; } export declare class JsonSchemaGenerator { private static readonly _knownTypeFormats; private static readonly _formatAliases; /** * Creates an empty schema for a type name. * @param title - The title to use for the schema. * @returns An empty object schema. */ static createEmptySchema(title: string): JsonSchema; /** * Generates a JSON schema for a class constructor. * @param target - The class constructor to generate schema for. * @param members - Optional pre-introspected members for reuse. * @param options - Schema resolution options. A boolean remains supported for existing callers. * @returns The generated JSON schema. */ static generate(target: Function, members?: ReadonlyMap, options?: JsonSchemaGenerationOptions | boolean): JsonSchema; private static mapRuntimeTypeToSchema; /** * Maps an array-typed member to a schema, resolving the element type from a * `@childrenFrom` child type or `@field(Array, { genericArguments: [ItemType] })` declaration when present. * @param declaringType - The class constructor that declares the array property. * @param propertyName - The array property name. * @returns The array schema, with the element's own compliance metadata carried onto `items` when the element is a PII concept. */ private static mapArrayTypeToSchema; /** * Resolves the element type from an explicit `@childrenFrom` child type, then from * `@field(Array, { genericArguments: [...] })`. TypeScript erases generic type arguments * at runtime, so an explicit declaration is needed to recover the element type. * @param declaringType - The class constructor that declares the array property. * @param propertyName - The array property name. * @returns The element type constructor, or undefined when it cannot be resolved. */ private static getArrayElementType; /** * Checks whether a member is an array whose element type is a ConceptAs. * @param declaringType - The class constructor that declares the property. * @param propertyName - The property name. * @param runtimeType - The member's reflected runtime type. * @returns True when the member is an array of concept elements; false otherwise. */ private static isConceptArrayMember; private static isConceptAs; private static getKnownTypeFormat; private static normalizeFormat; /** * Collects compliance metadata for a property from every source C# resolves PII from: the * property itself, its declaring class, and its own type (the concept case). * @param target - The class prototype the property is declared on. * @param propertyKey - The property name. * @param propertyType - The property's runtime type, when resolved. * @returns The collected compliance metadata, in property → declaring-class → type order. */ private static collectComplianceMetadata; /** * Adds compliance metadata to a schema node, descending into an object's properties so that * the metadata always lands on the leaves that actually hold a value. * @param schema - The schema node to add to. * @param metadata - The compliance metadata to add. * @remarks * A compliance marker can be declared on something that is not a single value: a `@pii()` on a * composite value-object type, or on a property whose type is such an object. Compliance is * applied per value, so leaving the marker on the container would make Chronicle hand the whole * JSON object to the value handler and store one opaque ciphertext string where the schema still * says "object". Releasing that gives back a string, not an object, and the read model then * fails to materialize. Pushing the metadata down to every leaf keeps encryption symmetric with * the release walk, keeps each value independently encrypted, and preserves the document shape. * * An array-typed node is deliberately left as a container: coarse compliance on a whole * collection is an established, separately handled behavior (the collection is blob-encrypted * and its shape restored on release). */ private static addComplianceMetadataToSchema; /** * Checks whether a compliance array already carries metadata of a given type. * @param compliance - The compliance array to check. * @param metadataType - The metadata type to look for. * @returns True when the metadata type is already present, false if not. * @remarks * A leaf can be reached by more than one marker — for example a `@pii()` concept inside a value * object whose type is itself marked `@pii()`. Recording the same metadata type twice adds * nothing and makes the generated schema noisier to read and to diff. */ private static hasComplianceMetadataOfType; /** * Collects security metadata for a property from every source compliance metadata is resolved * from: the property itself, its declaring class, and its own type (the concept case). This is * the security counterpart to {@link collectComplianceMetadata} - a deliberately separate walk * rather than a shared one, over a completely separate `@encrypted()` decorator vocabulary. * @param target - The class prototype the property is declared on. * @param propertyKey - The property name. * @param propertyType - The property's runtime type, when resolved. * @returns The collected security metadata, in property → declaring-class → type order. */ private static collectSecurityMetadata; /** * Adds security metadata to a schema node, descending into an object's properties so that the * metadata always lands on the leaves that actually hold a value. This is the security * counterpart to {@link addComplianceMetadataToSchema} - see its remarks for why metadata is * pushed to leaves and why an array is left as a container. * @param schema - The schema node to add to. * @param metadata - The security metadata to add. */ private static addSecurityMetadataToSchema; /** * Checks whether a security array already carries metadata of a given type. * @param security - The security array to check. * @param metadataType - The metadata type to look for. * @returns True when the metadata type is already present, false if not. */ private static hasSecurityMetadataOfType; /** * Rejects a property or type that resolved both compliance and security metadata. * @param name - The property or type name, used in the thrown error. * @param complianceMetadata - The compliance metadata collected for the property/type. * @param securityMetadata - The security metadata collected for the property/type. * @remarks * This is not merely redundant - it corrupts the value. The kernel applies every matching * handler for a property in sequence, so a value marked both ways is encrypted first under the * PII key and then again under the Encrypted key; releasing it decrypts with the wrong key * against ciphertext, which fails loudly rather than returning a wrong value. Checked here, at * schema-generation time, the same point C#'s `EncryptedMetadataProvider.ThrowIfAlsoPII` checks * it - this client has no compile-time analyzer, so this runtime check is the only backstop. */ private static throwIfBothCompliantAndSecure; } //# sourceMappingURL=JsonSchemaGenerator.d.ts.map