{"version":3,"file":"base.cjs","names":[],"sources":["../../src/core/base.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { CombinedStandardProps, Result, Schema } from \"./types\";\n\nfunction isPromiseLike<T>(value: T | Promise<T>): value is Promise<T> {\n  return typeof value === \"object\" && value !== null && \"then\" in value;\n}\n\nexport abstract class BaseSchema<I, O> implements Schema<I, O> {\n  abstract get [\"~standard\"](): CombinedStandardProps<I, O>;\n  jsonSchema: any = {};\n  get inferred(): O {\n    return null as unknown as O;\n  }\n  schema: Schema<I, O> = this;\n  protected _coerce = false;\n\n  /**\n   * Enable coercion for the schema.\n   * @returns {this} The schema with coercion enabled.\n   */\n  coerce(): this {\n    this._coerce = true;\n    return this;\n  }\n\n  /**\n   * Mark schema as optional (allows undefined / null on input).\n   * @returns {OptionalSchema<I, O | undefined>} Optional schema wrapper.\n   */\n  optional(): OptionalSchema<I, O | undefined> {\n    return new OptionalSchema<I, O>(this);\n  }\n\n  /**\n   * Allow `null` in addition to the existing schema output.\n   * @returns {UnionSchema<I, O | null>} Union with null.\n   */\n  null(): UnionSchema<I, O | null> {\n    return new UnionSchema<I, O | null>(this, new NullSchemaType() as any);\n  }\n\n  /**\n   * Alias for {@link BaseSchema.null}.\n   * @returns {UnionSchema<I, O | null>} Union with null.\n   */\n  nullable(): UnionSchema<I, O | null> {\n    return this.null();\n  }\n\n  /**\n   * Build an enum schema from this schema's literal type.\n   * @param {Values} values List of allowed literal values.\n   * @returns {UnionSchema<I, Values[number]>} Union of literals.\n   */\n  enum<V extends O & (string | number | boolean), Values extends readonly [V, ...V[]]>(\n    values: Values,\n  ): UnionSchema<I, Values[number]> {\n    const literalSchemas = values.map((value) => new LiteralSchema<I, V>(value));\n    return new UnionSchema<I, Values[number]>(...literalSchemas);\n  }\n\n  /**\n   * Wrap the schema in an array schema.\n   * @returns {ArraySchema<I, O[]>} Array schema.\n   */\n  array(): ArraySchema<I, O[]> {\n    return new ArraySchema<I, O[]>(this);\n  }\n\n  /**\n   * Restrict to instances of the given constructor.\n   * @param {C} constructor Class constructor.\n   * @returns {InstanceOfSchema<I, InstanceType<C>>} Instance-of schema.\n   */\n  instanceOf<C extends new (...args: any[]) => any>(\n    constructor: C,\n  ): InstanceOfSchema<I, InstanceType<C>> {\n    return new InstanceOfSchema<I, InstanceType<C>>(this, constructor);\n  }\n\n  /**\n   * Validate value and throw if invalid.\n   * @param {unknown} value Value to validate.\n   * @returns {O | Promise<O>} Validated value.\n   */\n  parse(value: unknown): O | Promise<O> {\n    const result = this[\"~standard\"].validate(value);\n    if (result instanceof Promise) {\n      return result.then((r) => {\n        if (r.issues) {\n          throw new Error(r.issues[0]!.message);\n        }\n        return r.value as O;\n      });\n    }\n    if (result.issues) {\n      throw new Error(result.issues[0]!.message);\n    }\n    return result.value as O;\n  }\n\n  /**\n   * Validate value and return a result object.\n   * @param {unknown} value Value to validate.\n   * @returns {Result<O> | Promise<Result<O>>} Validation result.\n   */\n  safeParse(value: unknown): Result<O> | Promise<Result<O>> {\n    return this[\"~standard\"].validate(value);\n  }\n}\n\nexport class OptionalSchema<I, O> extends BaseSchema<I, O | undefined> {\n  private readonly innerSchema: Schema<I, O>;\n\n  constructor(schema: Schema<I, O>) {\n    super();\n    this.innerSchema = schema;\n    this.jsonSchema = { ...schema.jsonSchema };\n  }\n\n  get [\"~standard\"](): CombinedStandardProps<I, O | undefined> {\n    return {\n      version: 1,\n      vendor: \"h-schema\",\n      jsonSchema: {\n        input: () => this.jsonSchema,\n        output: () => this.jsonSchema,\n      },\n      validate: (value: unknown) => {\n        if (value === undefined || value === null) {\n          return { value: undefined };\n        }\n        return this.innerSchema[\"~standard\"].validate(value);\n      },\n      types: {\n        input: {} as I,\n        output: {} as O | undefined,\n      },\n    };\n  }\n}\n\nexport class NullSchemaType extends BaseSchema<unknown, null> {\n  readonly type = \"null\";\n  constructor() {\n    super();\n    this.jsonSchema = { type: \"null\" };\n  }\n\n  get [\"~standard\"](): CombinedStandardProps<unknown, null> {\n    return {\n      version: 1,\n      vendor: \"h-schema\",\n      jsonSchema: {\n        input: () => this.jsonSchema,\n        output: () => this.jsonSchema,\n      },\n      validate: (value: unknown) => {\n        if (value !== null) {\n          return {\n            issues: [\n              {\n                message: `Expected null, received ${value === undefined ? \"undefined\" : typeof value}`,\n              },\n            ],\n          };\n        }\n        return { value: null };\n      },\n      types: {\n        input: {} as unknown,\n        output: {} as unknown as null,\n      },\n    };\n  }\n}\n\nexport class LiteralSchema<I, T extends string | number | boolean> extends BaseSchema<I, T> {\n  private readonly value: T;\n\n  constructor(value: T) {\n    super();\n    this.value = value;\n    this.jsonSchema = {\n      const: value,\n      type: typeof value as \"string\" | \"number\" | \"boolean\",\n    };\n  }\n\n  get [\"~standard\"](): CombinedStandardProps<I, T> {\n    return {\n      version: 1,\n      vendor: \"h-schema\",\n      jsonSchema: {\n        input: () => this.jsonSchema,\n        output: () => this.jsonSchema,\n      },\n      validate: (value: unknown) => {\n        if (value !== this.value) {\n          return {\n            issues: [{ message: `Expected literal value ${this.value}, received ${value}` }],\n          };\n        }\n        return { value: value as T };\n      },\n      types: {\n        input: {} as I,\n        output: {} as T,\n      },\n    };\n  }\n}\n\nexport class UnionSchema<I, O> extends BaseSchema<I, O> {\n  readonly schemas: Schema<I, any>[];\n  constructor(...schemas: Schema<I, any>[]) {\n    super();\n    this.schemas = schemas;\n    this.jsonSchema = { anyOf: schemas.map((s) => s.jsonSchema) };\n  }\n\n  get [\"~standard\"](): CombinedStandardProps<I, O> {\n    return {\n      version: 1,\n      vendor: \"h-schema\",\n      jsonSchema: {\n        input: () => this.jsonSchema,\n        output: () => this.jsonSchema,\n      },\n      validate: (value: unknown) => {\n        const validateFrom = (\n          index: number,\n          issues: StandardSchemaV1.Issue[],\n        ): StandardSchemaV1.Result<O> | Promise<StandardSchemaV1.Result<O>> => {\n          for (let i = index; i < this.schemas.length; i++) {\n            const result = this.schemas[i]![\"~standard\"].validate(value) as\n              | StandardSchemaV1.Result<O>\n              | Promise<StandardSchemaV1.Result<O>>;\n            if (isPromiseLike(result)) {\n              return result.then((resolved) => {\n                if (!(\"issues\" in resolved)) {\n                  return { value: resolved.value };\n                }\n                if (resolved.issues) {\n                  issues.push(...resolved.issues);\n                }\n                return validateFrom(i + 1, issues);\n              });\n            }\n            if (!(\"issues\" in result)) {\n              return { value: result.value };\n            }\n            if (result.issues) {\n              issues.push(...result.issues);\n            }\n          }\n          return { issues };\n        };\n\n        return validateFrom(0, []);\n      },\n      types: {\n        input: {} as I,\n        output: {} as O,\n      },\n    };\n  }\n}\n\nexport class ArraySchema<I, O extends any[]> extends BaseSchema<I, O> {\n  private readonly innerSchema: Schema<I, O[number]>;\n  private _minLength?: number;\n  private _maxLength?: number;\n  private _nonEmpty = false;\n\n  constructor(schema: Schema<I, O[number]>) {\n    super();\n    this.innerSchema = schema;\n    this.jsonSchema = { type: \"array\", items: schema.jsonSchema };\n  }\n\n  /**\n   * Require minimum number of items.\n   * @param {number} n Minimum length.\n   * @returns {ArraySchema<I, O>} New constrained schema.\n   */\n  min(n: number): ArraySchema<I, O> {\n    const schema = new ArraySchema<I, O>(this.innerSchema);\n    Object.assign(schema, this);\n    schema._minLength = n;\n    schema.jsonSchema = { ...this.jsonSchema, minItems: n };\n    return schema;\n  }\n\n  /**\n   * Require maximum number of items.\n   * @param {number} n Maximum length.\n   * @returns {ArraySchema<I, O>} New constrained schema.\n   */\n  max(n: number): ArraySchema<I, O> {\n    const schema = new ArraySchema<I, O>(this.innerSchema);\n    Object.assign(schema, this);\n    schema._maxLength = n;\n    schema.jsonSchema = { ...this.jsonSchema, maxItems: n };\n    return schema;\n  }\n\n  /**\n   * Require array to contain at least one item.\n   * @returns {ArraySchema<I, O>} New constrained schema.\n   */\n  nonEmpty(): ArraySchema<I, O> {\n    const schema = new ArraySchema<I, O>(this.innerSchema);\n    Object.assign(schema, this);\n    schema._nonEmpty = true;\n    schema._minLength = Math.max(this._minLength ?? 1, 1);\n    schema.jsonSchema = { ...this.jsonSchema, minItems: schema._minLength };\n    return schema;\n  }\n\n  get [\"~standard\"](): CombinedStandardProps<I, O> {\n    return {\n      version: 1,\n      vendor: \"h-schema\",\n      jsonSchema: {\n        input: () => this.jsonSchema,\n        output: () => this.jsonSchema,\n      },\n      validate: (value: unknown) => {\n        if (!Array.isArray(value)) {\n          return {\n            issues: [{ message: `Expected array, received ${typeof value}` }],\n          };\n        }\n\n        if (this._nonEmpty && value.length === 0) {\n          return { issues: [{ message: \"Array must be non-empty\" }] };\n        }\n        if (this._minLength !== undefined && value.length < this._minLength) {\n          return { issues: [{ message: `Array shorter than ${this._minLength}` }] };\n        }\n        if (this._maxLength !== undefined && value.length > this._maxLength) {\n          return { issues: [{ message: `Array longer than ${this._maxLength}` }] };\n        }\n\n        const results = value.map((item, index) => {\n          const mapResult = (result: StandardSchemaV1.Result<O[number]>) => {\n            if (\"issues\" in result) {\n              return {\n                issues: result.issues?.map((issue) => ({\n                  ...issue,\n                  path: issue.path ? [index, ...issue.path] : [index],\n                })),\n              };\n            }\n            return { value: result.value };\n          };\n          const result = this.innerSchema[\"~standard\"].validate(item) as\n            | StandardSchemaV1.Result<O[number]>\n            | Promise<StandardSchemaV1.Result<O[number]>>;\n          return isPromiseLike(result) ? result.then(mapResult) : mapResult(result);\n        });\n\n        const finish = (\n          resolved: Array<{ value?: O[number]; issues?: StandardSchemaV1.Issue[] }>,\n        ) => {\n          const issues = resolved.flatMap((result) => result.issues ?? []);\n          if (issues.length > 0) {\n            return { issues };\n          }\n          return { value: resolved.map((result) => result.value) as O };\n        };\n\n        return results.some(isPromiseLike)\n          ? Promise.all(results).then(finish)\n          : finish(results as Array<{ value?: O[number]; issues?: StandardSchemaV1.Issue[] }>);\n      },\n      types: {\n        input: {} as I,\n        output: {} as O,\n      },\n    };\n  }\n}\n\nexport class InstanceOfSchema<I, O> extends BaseSchema<I, O> {\n  private readonly innerSchema: Schema<I, any>;\n  private readonly classConstructor: new (\n    ...args: any[]\n  ) => any;\n\n  constructor(schema: Schema<I, any>, classConstructor: new (...args: any[]) => any) {\n    super();\n    this.innerSchema = schema;\n    this.classConstructor = classConstructor;\n    this.jsonSchema = { ...schema.jsonSchema, instanceOf: classConstructor.name };\n  }\n\n  get [\"~standard\"](): CombinedStandardProps<I, O> {\n    return {\n      version: 1,\n      vendor: \"h-schema\",\n      jsonSchema: {\n        input: () => this.jsonSchema,\n        output: () => this.jsonSchema,\n      },\n      validate: (value: unknown) => {\n        if (!(value instanceof this.classConstructor)) {\n          return {\n            issues: [{ message: `Expected instance of ${this.classConstructor.name}` }],\n          };\n        }\n        const result = this.innerSchema[\"~standard\"].validate(value);\n        return isPromiseLike(result)\n          ? result.then((resolved) => resolved as StandardSchemaV1.Result<O>)\n          : (result as StandardSchemaV1.Result<O>);\n      },\n      types: {\n        input: {} as I,\n        output: {} as O,\n      },\n    };\n  }\n}\n\nexport function validatePrimitive(\n  schema: \"string\" | \"number\" | \"boolean\" | \"any\",\n  value: unknown,\n): boolean {\n  if (typeof value === \"string\" && schema === \"string\") {\n    return true;\n  }\n  if (typeof value === \"number\" && schema === \"number\" && !Number.isNaN(value)) {\n    return true;\n  }\n  if (typeof value === \"boolean\" && schema === \"boolean\") {\n    return true;\n  }\n  if (schema === \"any\") {\n    return true;\n  }\n  return false;\n}\n"],"mappings":";AAGA,SAAS,cAAiB,OAA4C;CACpE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AAClE;AAEA,IAAsB,aAAtB,MAA+D;CAE7D,aAAkB,CAAC;CACnB,IAAI,WAAc;EAChB,OAAO;CACT;CACA,SAAuB;CACvB,UAAoB;;;;;CAMpB,SAAe;EACb,KAAK,UAAU;EACf,OAAO;CACT;;;;;CAMA,WAA6C;EAC3C,OAAO,IAAI,eAAqB,IAAI;CACtC;;;;;CAMA,OAAiC;EAC/B,OAAO,IAAI,YAAyB,MAAM,IAAI,eAAe,CAAQ;CACvE;;;;;CAMA,WAAqC;EACnC,OAAO,KAAK,KAAK;CACnB;;;;;;CAOA,KAC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