import type { CollectionConfig } from "./collections"; /** * Serializing collections so they survive a network hop. * * A collection definition is not plain data. Relations point at their target * with a *function* (`target: () => usersCollection`) so two collections can * reference each other without an import cycle, and collections also carry * callbacks, custom views and component references. `JSON.stringify` silently * drops every one of those, which matters because the SDK generator *calls* * `relation.target()` to decide whether a foreign key is a string or a number. * Serialize naively and remote SDK generation produces subtly wrong types * instead of failing — the worst possible outcome. * * So relation targets are resolved to a slug reference on the way out and * rebuilt into functions on the way in. Everything else that cannot cross a wire * is dropped deliberately: an SDK is generated from the *shape* of the data, and * server-side behaviour is neither useful to a client nor safe to publish. */ /** Marker replacing a relation's `target` function in serialized form. */ export interface SerializedCollectionRef { __collectionRef: string; } export declare function isSerializedCollectionRef(value: unknown): value is SerializedCollectionRef; /** * Serialize collections for transport over the contract endpoint. * * Sorted by slug so the output — and therefore the schema hash computed from it * — does not depend on filesystem ordering. */ export declare function serializeCollections(collections: CollectionConfig[]): unknown[]; /** * Rebuild collections received from a contract endpoint. * * Relation refs become real thunks resolving through the returned set, so * downstream consumers — the SDK generator above all — see exactly the shape * they would have seen had the collections been imported from source. * * A ref naming a collection that is not in the payload resolves to `undefined` * rather than throwing: the generator already tolerates an unresolvable target * by falling back to a permissive key type, and a partial contract should still * produce a usable SDK. */ export declare function deserializeCollections(payload: unknown[]): CollectionConfig[];