import { t as MongoContractView } from "./mongo-contract-view-zEiw6S3I.mjs"; import { ControlPolicy } from "@prisma-next/contract/types"; import { ContractSerializer, SchemaDiffIssue, SchemaVerifier, SchemaVerifyOptions, SchemaVerifyResult } from "@prisma-next/framework-components/control"; import { AnyEntityKindDescriptor, Namespace } from "@prisma-next/framework-components/ir"; import { MongoCollection, MongoContract, MongoStorage } from "@prisma-next/mongo-contract"; import { Type } from "arktype"; import { JsonObject } from "@prisma-next/utils/json"; //#region src/core/ir/mongo-contract-serializer-base.d.ts /** * Mongo family `ContractSerializer` abstract base. Owns the family-shared * deserialization pipeline: * * 1. Structural validation against the Mongo contract arktype schema * (`MongoContractSchema`). * 2. Framework-shared domain validation (`validateContractDomain`). * 3. Family-shared storage validation (`validateMongoStorage`). * * The validated value is handed to the target via the * `constructTargetContract` hook, which wraps the plain-JSON shape in * the family-layer `MongoStorage` class instance (carrying the * target-supplied `namespaces` map). Targets that need to add * structural checks beyond the family default can override * `parseMongoContractStructure`. * * Default `serializeContract` is identity over the contract — Mongo * target classes carry JSON-clean fields by construction, so the value * can be `JSON.stringify`'d directly. Targets that need on-the-way-out * canonicalization override `serializeContract`. */ declare abstract class MongoContractSerializerBase implements ContractSerializer { private readonly contractSchema; private readonly entryKinds; constructor(validatorFragments?: ReadonlyMap>, packEntityKinds?: readonly AnyEntityKindDescriptor[]); deserializeContract(json: unknown): T; serializeContract(contract: TContract): JsonObject; /** * Preserve empty `collections` maps and per-collection payloads. Mongo * collections legitimately serialize empty (a declared collection with no * schema is valid); SQL tables never do — that asymmetry lives here rather * than in the family-agnostic canonicalizer. */ shouldPreserveEmpty: import("@prisma-next/contract/hashing").PreserveEmptyPredicate; /** * Family-shared structural validation: parse against the Mongo * contract arktype schema, then run framework-shared domain + Mongo * family storage checks, then hydrate the validated tree into Mongo * Contract IR class instances. Targets can override to add * target-specific structural checks; most targets accept the family * default. * * The returned `MongoContract` carries class instances under * `storage.namespaces[namespaceId].entries.collection[collectionName]` (each value is a * `MongoCollection`, with nested `MongoIndex` / `MongoValidator` / * `MongoCollectionOptions` constructed by the `MongoCollection` constructor). * The rest of the contract envelope (models, valueObjects, capabilities, …) * remains in plain-JSON form; those IR layers are handled by sibling * subsystems and don't sit behind this SPI. */ protected parseMongoContractStructure(json: unknown): MongoContract; /** * Walk a structurally-validated Mongo contract and hydrate each namespace's * entries via the registered entity-kind descriptors. Unknown kinds throw (fail-closed), * preserving the existing Mongo serializer semantics. */ protected hydrateMongoContract(contract: MongoContract): MongoContract; /** * Target-specific class construction from the validated structural * data. The target wraps the contract envelope in the family-layer * `MongoStorage` class instance, supplying the `namespaces` map * (target concretions like `MongoTargetUnboundDatabase`). The * leaf collection / index shapes are already family-layer IR-class * instances after the hydration walk above. */ protected abstract constructTargetContract(validated: MongoContract): TContract; } //#endregion //#region src/core/ir/mongo-contract-serializer.d.ts /** * Default Mongo family `ContractSerializer` concretion. Inherits the * Mongo-shared deserialization pipeline (structural validation + * collection-level hydration) and falls through `constructTargetContract` * with the validated `MongoContract` shape. Family-level call sites * (family-instance methods, family-layer tests that don't reach into * a target descriptor) instantiate this directly; targets with their * own storage concretion (`target-mongo`'s `MongoTargetContractSerializer`) * override `constructTargetContract` to wrap the storage shape. */ declare class MongoContractSerializer extends MongoContractSerializerBase { protected constructTargetContract(validated: MongoContract): MongoContract; } //#endregion //#region src/core/ir/mongo-schema-verifier-base.d.ts /** * Mongo family `SchemaVerifier` abstract base. Commits the Mongo family * to namespace-keyed verification: the family-shared walk iterates * `storage.namespaces` in sorted order and dispatches per-namespace * through the protected `verifyNamespace` hook, then aggregates * target-extension issues from `verifyTargetExtensions`. * * Per-element diff work (collection / index / validator comparisons) * lives on the target inside `verifyNamespace`. The family's structural * commitment is "verification is namespaced"; the target's commitment is * "verification of a given namespace's collections is the existing * diff/canonicalize pipeline". The split keeps target-mongo's * introspection-side helpers (`contractToMongoSchemaIR`, * `canonicalizeSchemasForVerification`, `diffMongoSchemas`) in the target * layer where they belong, while the family base owns the iteration * scaffolding that makes namespaces a first-class verifier concept. * * Target-specific issue kinds (Atlas-only, future RLS-equivalents) * surface through `verifyTargetExtensions`; that hook returns the empty * list when no extensions exist over the Mongo family alphabet. */ declare abstract class MongoSchemaVerifierBase implements SchemaVerifier { verifySchema(options: SchemaVerifyOptions): SchemaVerifyResult; protected effectiveCollectionControlPolicy(contract: TContract, collection: MongoCollection | undefined): ControlPolicy; protected collectionControlPolicyForName(contract: TContract, collectionName: string): ControlPolicy; protected verifyCommonMongoSchema(options: SchemaVerifyOptions): readonly SchemaDiffIssue[]; /** * Per-namespace verification hook. Receives the namespace metadata plus * the full contract + schema pair; the target's implementation owns the * per-collection diff using its existing introspection-side helpers. * Slice the schema by namespace at the call site (or compute the full * diff once and dispatch per namespace) — the family base does not * prescribe the per-namespace shape. */ protected abstract verifyNamespace(options: { readonly contract: TContract; readonly schema: TSchema; readonly namespaceId: string; readonly namespace: Namespace; }): readonly SchemaDiffIssue[]; /** * Target-specific extensions — Atlas-only kinds, target-only * namespace-mismatch issues that don't fit the family-shared walk. * Returns the empty list when the target ships no extensions. */ protected abstract verifyTargetExtensions(options: SchemaVerifyOptions): readonly SchemaDiffIssue[]; } //#endregion export { MongoContractSerializer, MongoContractSerializerBase, MongoContractView, MongoSchemaVerifierBase }; //# sourceMappingURL=ir.d.mts.map