@valbuild/core 0.43.0 → 0.43.1

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.
@@ -1,9 +1,9 @@
1
1
  export { initVal } from "./initVal.js";
2
2
  export type { InitVal, ValConfig, ValConstructor } from "./initVal.js";
3
- export { Schema, type SerializedSchema } from "./schema/index.js";
3
+ export { Schema, type SerializedSchema, type SelectorOfSchema } from "./schema/index.js";
4
4
  export type { ImageMetadata } from "./schema/image.js";
5
5
  export type { LinkSource } from "./source/link.js";
6
- export type { ValModule, SerializedModule } from "./module.js";
6
+ export type { ValModule, SerializedModule, InferValModuleType } from "./module.js";
7
7
  export type { SourceObject, SourcePrimitive, Source } from "./source/index.js";
8
8
  export type { FileSource } from "./source/file.js";
9
9
  export type { RawString } from "./schema/string.js";
@@ -28,10 +28,10 @@ export declare function initSchema(): {
28
28
  minLength?: number | undefined;
29
29
  } | undefined) => import("./schema/string.js").StringSchema<T>;
30
30
  boolean: () => import("./schema/index.js").Schema<boolean>;
31
- array: <S extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S) => import("./schema/index.js").Schema<import("./schema/index.js").SchemaTypeOf<S>[]>;
31
+ array: <S extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S) => import("./schema/index.js").Schema<import("./schema/index.js").SelectorOfSchema<S>[]>;
32
32
  object: <Props extends {
33
33
  [key: string]: import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>;
34
- }>(schema: Props) => import("./schema/index.js").Schema<{ [key in keyof Props]: import("./schema/index.js").SchemaTypeOf<Props[key]>; }>;
34
+ }>(schema: Props) => import("./schema/index.js").Schema<{ [key in keyof Props]: import("./schema/index.js").SelectorOfSchema<Props[key]>; }>;
35
35
  number: (options?: {
36
36
  max?: number | undefined;
37
37
  min?: number | undefined;
@@ -51,5 +51,5 @@ export declare function initSchema(): {
51
51
  image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").FileSource<import("./schema/image.js").ImageMetadata>>;
52
52
  literal: <T_2 extends string>(value: T_2) => import("./schema/index.js").Schema<T_2>;
53
53
  keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject | import("./source/index.js").SourceArray, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/index.js").Schema<Src extends import("./selector/index.js").GenericSelector<infer S_2 extends import("./source/index.js").Source, undefined> ? S_2 extends readonly any[] ? number : S_2 extends import("./source/index.js").SourceObject ? keyof S_2 : S_2 extends Record<string, any> ? string : never : never>;
54
- record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").SchemaTypeOf<S_3>>>;
54
+ record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").SelectorOfSchema<S_3>>>;
55
55
  };
@@ -1,4 +1,4 @@
1
- import { Schema, SchemaTypeOf, SerializedSchema } from "./schema/index.js";
1
+ import { Schema, SelectorOfSchema, SerializedSchema } from "./schema/index.js";
2
2
  import { GenericSelector, SelectorOf, SelectorSource } from "./selector/index.js";
3
3
  import { Source } from "./source/index.js";
4
4
  import { ModuleId, ModulePath, SourcePath } from "./val/index.js";
@@ -9,13 +9,13 @@ export type ValModule<T extends SelectorSource> = SelectorOf<T> & ValModuleBrand
9
9
  export type ValModuleBrand = {
10
10
  [brand]: "ValModule";
11
11
  };
12
- export type TypeOfValModule<T extends ValModule<SelectorSource>> = T extends GenericSelector<infer S> ? S : never;
12
+ export type InferValModuleType<T extends ValModule<SelectorSource>> = T extends GenericSelector<infer S> ? S : never;
13
13
  type ReplaceRawStringWithString<T extends SelectorSource> = SelectorSource extends T ? T : T extends RawString ? string : T extends {
14
14
  [key in string]: SelectorSource;
15
15
  } ? {
16
16
  [key in keyof T]: ReplaceRawStringWithString<T[key]>;
17
17
  } : T extends SelectorSource[] ? ReplaceRawStringWithString<T[number]>[] : T;
18
- export declare function content<T extends Schema<SelectorSource>>(id: string, schema: T, source: ReplaceRawStringWithString<SchemaTypeOf<T>>): ValModule<SchemaTypeOf<T>>;
18
+ export declare function content<T extends Schema<SelectorSource>>(id: string, schema: T, source: ReplaceRawStringWithString<SelectorOfSchema<T>>): ValModule<SelectorOfSchema<T>>;
19
19
  export declare function getSource(valModule: ValModule<SelectorSource>): Source;
20
20
  export declare function splitModuleIdAndModulePath(path: SourcePath): [moduleId: ModuleId, path: ModulePath];
21
21
  export declare function getSourceAtPath(modulePath: ModulePath, valModule: ValModule<SelectorSource> | Source): any;
@@ -1,4 +1,4 @@
1
- import { Schema, SchemaTypeOf, SerializedSchema } from "./index.js";
1
+ import { Schema, SelectorOfSchema, SerializedSchema } from "./index.js";
2
2
  import { SelectorSource } from "../selector/index.js";
3
3
  import { SourcePath } from "../val/index.js";
4
4
  import { ValidationErrors } from "./validation/ValidationError.js";
@@ -7,13 +7,13 @@ export type SerializedArraySchema = {
7
7
  item: SerializedSchema;
8
8
  opt: boolean;
9
9
  };
10
- export declare class ArraySchema<T extends Schema<SelectorSource>> extends Schema<SchemaTypeOf<T>[]> {
10
+ export declare class ArraySchema<T extends Schema<SelectorSource>> extends Schema<SelectorOfSchema<T>[]> {
11
11
  readonly item: T;
12
12
  readonly opt: boolean;
13
13
  constructor(item: T, opt?: boolean);
14
- validate(path: SourcePath, src: SchemaTypeOf<T>[]): ValidationErrors;
15
- assert(src: SchemaTypeOf<T>[]): boolean;
16
- optional(): Schema<SchemaTypeOf<T>[] | null>;
14
+ validate(path: SourcePath, src: SelectorOfSchema<T>[]): ValidationErrors;
15
+ assert(src: SelectorOfSchema<T>[]): boolean;
16
+ optional(): Schema<SelectorOfSchema<T>[] | null>;
17
17
  serialize(): SerializedArraySchema;
18
18
  }
19
- export declare const array: <S extends Schema<SelectorSource>>(schema: S) => Schema<SchemaTypeOf<S>[]>;
19
+ export declare const array: <S extends Schema<SelectorSource>>(schema: S) => Schema<SelectorOfSchema<S>[]>;
@@ -21,4 +21,4 @@ export declare abstract class Schema<Src extends SelectorSource> {
21
21
  /** MUTATES! since internal and perf sensitive */
22
22
  protected appendValidationError(current: ValidationErrors, path: SourcePath, message: string, value?: unknown): ValidationErrors;
23
23
  }
24
- export type SchemaTypeOf<T extends Schema<SelectorSource>> = T extends Schema<infer Src> ? Src : never;
24
+ export type SelectorOfSchema<T extends Schema<SelectorSource>> = T extends Schema<infer Src> ? Src : never;
@@ -1,4 +1,4 @@
1
- import { Schema, SchemaTypeOf, SerializedSchema } from "./index.js";
1
+ import { Schema, SelectorOfSchema, SerializedSchema } from "./index.js";
2
2
  import { SelectorSource } from "../selector/index.js";
3
3
  import { SourcePath } from "../val/index.js";
4
4
  import { ValidationErrors } from "./validation/ValidationError.js";
@@ -11,7 +11,7 @@ type ObjectSchemaProps = {
11
11
  [key: string]: Schema<SelectorSource>;
12
12
  };
13
13
  type ObjectSchemaSrcOf<Props extends ObjectSchemaProps> = {
14
- [key in keyof Props]: SchemaTypeOf<Props[key]>;
14
+ [key in keyof Props]: SelectorOfSchema<Props[key]>;
15
15
  };
16
16
  export declare class ObjectSchema<Props extends ObjectSchemaProps> extends Schema<ObjectSchemaSrcOf<Props>> {
17
17
  readonly items: Props;
@@ -22,5 +22,5 @@ export declare class ObjectSchema<Props extends ObjectSchemaProps> extends Schem
22
22
  optional(): Schema<ObjectSchemaSrcOf<Props> | null>;
23
23
  serialize(): SerializedSchema;
24
24
  }
25
- export declare const object: <Props extends ObjectSchemaProps>(schema: Props) => Schema<{ [key in keyof Props]: SchemaTypeOf<Props[key]>; }>;
25
+ export declare const object: <Props extends ObjectSchemaProps>(schema: Props) => Schema<{ [key in keyof Props]: SelectorOfSchema<Props[key]>; }>;
26
26
  export {};
@@ -1,4 +1,4 @@
1
- import { Schema, SchemaTypeOf, SerializedSchema } from "./index.js";
1
+ import { Schema, SelectorOfSchema, SerializedSchema } from "./index.js";
2
2
  import { SelectorSource } from "../selector/index.js";
3
3
  import { SourcePath } from "../val/index.js";
4
4
  import { ValidationErrors } from "./validation/ValidationError.js";
@@ -7,13 +7,13 @@ export type SerializedRecordSchema = {
7
7
  item: SerializedSchema;
8
8
  opt: boolean;
9
9
  };
10
- export declare class RecordSchema<T extends Schema<SelectorSource>> extends Schema<Record<string, SchemaTypeOf<T>>> {
10
+ export declare class RecordSchema<T extends Schema<SelectorSource>> extends Schema<Record<string, SelectorOfSchema<T>>> {
11
11
  readonly item: T;
12
12
  readonly opt: boolean;
13
13
  constructor(item: T, opt?: boolean);
14
- validate(path: SourcePath, src: Record<string, SchemaTypeOf<T>>): ValidationErrors;
15
- assert(src: Record<string, SchemaTypeOf<T>>): boolean;
16
- optional(): Schema<Record<string, SchemaTypeOf<T>> | null>;
14
+ validate(path: SourcePath, src: Record<string, SelectorOfSchema<T>>): ValidationErrors;
15
+ assert(src: Record<string, SelectorOfSchema<T>>): boolean;
16
+ optional(): Schema<Record<string, SelectorOfSchema<T>> | null>;
17
17
  serialize(): SerializedRecordSchema;
18
18
  }
19
- export declare const record: <S extends Schema<SelectorSource>>(schema: S) => Schema<Record<string, SchemaTypeOf<S>>>;
19
+ export declare const record: <S extends Schema<SelectorSource>>(schema: S) => Schema<Record<string, SelectorOfSchema<S>>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/core",
3
- "version": "0.43.0",
3
+ "version": "0.43.1",
4
4
  "private": false,
5
5
  "description": "Val - supercharged hard-coded content",
6
6
  "scripts": {