@hasna/contracts 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ import type { z } from "zod";
2
+ import { ContractSchemaRegistry, type ContractBySchemaId, type KnownSchemaId } from "./schemas";
3
+ export type EmbeddedContractValidationResult = {
4
+ success: true;
5
+ schemaId: KnownSchemaId;
6
+ data: ContractBySchemaId[KnownSchemaId];
7
+ } | {
8
+ success: false;
9
+ schemaId: string | null;
10
+ issues: z.ZodIssue[];
11
+ };
12
+ export declare class ContractValidationError extends Error {
13
+ readonly schemaId: string;
14
+ readonly issues: z.ZodIssue[];
15
+ constructor(schemaId: string, issues: z.ZodIssue[]);
16
+ }
17
+ export declare function getContractSchema<TSchemaId extends KnownSchemaId>(schemaId: TSchemaId): (typeof ContractSchemaRegistry)[TSchemaId];
18
+ export declare function getEmbeddedSchemaId(value: unknown): KnownSchemaId | null;
19
+ export declare function parseContract<TSchemaId extends KnownSchemaId>(schemaId: TSchemaId, value: unknown): ContractBySchemaId[TSchemaId];
20
+ export declare function validateContract<TSchemaId extends KnownSchemaId>(schemaId: TSchemaId, value: unknown): z.SafeParseReturnType<unknown, ContractBySchemaId[TSchemaId]>;
21
+ export declare function validateEmbeddedContract(value: unknown): EmbeddedContractValidationResult;
22
+ export declare function parseEmbeddedContract(value: unknown): ContractBySchemaId[KnownSchemaId];