@jfdevelops/multi-step-form-core 1.0.0-alpha.11

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,74 @@
1
+ export interface StandardSchemaValidator<Input = unknown, Output = Input> {
2
+ readonly '~standard': StandardSchemaV1.Props<Input, Output>;
3
+ }
4
+ export declare namespace StandardSchemaV1 {
5
+ /** The Standard Schema properties interface. */
6
+ interface Props<Input = unknown, Output = Input> {
7
+ /** The version number of the standard. */
8
+ readonly version: 1;
9
+ /** The vendor name of the schema library. */
10
+ readonly vendor: string;
11
+ /** Validates unknown input values. */
12
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
13
+ /** Inferred types associated with the schema. */
14
+ readonly types?: Types<Input, Output> | undefined;
15
+ }
16
+ /** The result interface of the validate function. */
17
+ type Result<Output> = SuccessResult<Output> | FailureResult;
18
+ /** The result interface if validation succeeds. */
19
+ interface SuccessResult<Output> {
20
+ /** The typed output value. */
21
+ readonly value: Output;
22
+ /** The non-existent issues. */
23
+ readonly issues?: undefined;
24
+ }
25
+ /** The result interface if validation fails. */
26
+ interface FailureResult {
27
+ /** The issues of failed validation. */
28
+ readonly issues: ReadonlyArray<Issue>;
29
+ }
30
+ /** The issue interface of the failure output. */
31
+ interface Issue {
32
+ /** The error message of the issue. */
33
+ readonly message: string;
34
+ /** The path of the issue, if any. */
35
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
36
+ }
37
+ /** The path segment interface of the issue. */
38
+ interface PathSegment {
39
+ /** The key representing a path segment. */
40
+ readonly key: PropertyKey;
41
+ }
42
+ /** The Standard Schema types interface. */
43
+ interface Types<Input = unknown, Output = Input> {
44
+ /** The input type of the schema. */
45
+ readonly input: Input;
46
+ /** The output type of the schema. */
47
+ readonly output: Output;
48
+ }
49
+ /** Infers the input type of a Standard Schema. */
50
+ type InferInput<Schema extends StandardSchemaValidator> = NonNullable<Schema['~standard']['types']>['input'];
51
+ /** Infers the output type of a Standard Schema. */
52
+ type InferOutput<Schema extends StandardSchemaValidator> = NonNullable<Schema['~standard']['types']>['output'];
53
+ }
54
+ export interface ValidatorAdapter<TInput, TOutput> {
55
+ types: {
56
+ input: TInput;
57
+ output: TOutput;
58
+ };
59
+ parse: (input: unknown) => TOutput;
60
+ }
61
+ export interface ValidatorObj<TInput, TOutput> {
62
+ parse: ValidatorFn<TInput, TOutput>;
63
+ }
64
+ export type ValidatorFn<Input, Output> = (input: Input) => Output;
65
+ export type Validator<Input, Output> = ValidatorFn<Input, Output> | StandardSchemaValidator<Input, Output>;
66
+ export type AnySchema = {};
67
+ export type DefaultValidator = Validator<Record<string, unknown>, AnySchema>;
68
+ export type AnyStandardSchemaValidator = StandardSchemaValidator<any, any>;
69
+ export type AnyValidator = Validator<any, any>;
70
+ export type AnyValidatorObj = ValidatorObj<any, any>;
71
+ export type AnyValidatorAdapter = ValidatorAdapter<any, any>;
72
+ export type ResolveValidatorOutputFn<TValidator> = TValidator extends (...args: any) => infer TSchema ? TSchema : AnySchema;
73
+ export type ResolveValidatorOutput<TValidator> = unknown extends TValidator ? TValidator : TValidator extends AnyStandardSchemaValidator ? NonNullable<TValidator['~standard']['types']>['output'] : TValidator extends AnyValidatorAdapter ? TValidator['types']['output'] : TValidator extends AnyValidatorObj ? ResolveValidatorOutputFn<TValidator['parse']> : ResolveValidatorOutputFn<TValidator>;
74
+ export declare function runStandardValidation<Schema extends StandardSchemaValidator>(schema: Schema, input: StandardSchemaV1.InferInput<Schema>): StandardSchemaV1.InferOutput<Schema>;
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@jfdevelops/multi-step-form-core",
3
+ "version": "1.0.0-alpha.11",
4
+ "description": "",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./_internal": {
16
+ "types": "./dist/internals/index.d.ts",
17
+ "import": "./dist/_internals.mjs",
18
+ "require": "./dist/_internals.cjs"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "keywords": [],
25
+ "author": "Joey Finkel",
26
+ "license": "MIT",
27
+ "devDependencies": {
28
+ "arktype": "^2.1.22",
29
+ "vite": "^7.1.5",
30
+ "vite-plugin-dts": "^4.5.4",
31
+ "vite-tsconfig-paths": "^5.1.4",
32
+ "vitest": "^3.2.4"
33
+ },
34
+ "scripts": {
35
+ "dev": "vite",
36
+ "build": "vite build",
37
+ "watch": "vite build --watch",
38
+ "test": "vitest"
39
+ }
40
+ }