{"version":3,"file":"index.mjs","names":[],"sources":["../src/enum.ts","../src/getKeys.ts","../src/apply.ts","../src/codecTools/decodeCodec.ts","../src/codecTools/dictionary.ts","../src/codecTools/FixedLengthString.ts","../src/codecTools/FixedLengthArray.ts","../src/codecTools/partialRecord.ts","../src/codecTools/isCodecError.ts","../src/codecTools/NonEmptyString.ts","../src/codecTools/toJsonSchema.ts","../src/codecTools/createDefaultCodec.ts","../src/enums.ts","../src/getEntries.ts","../src/getValues.ts","../src/groupBy.ts","../src/gql.ts","../src/invert.ts","../src/valuesOf.ts","../src/findAllWithRegex.ts","../src/aggregateObjects.ts","../src/flattenObject.ts","../src/transposeObjectArray.ts","../src/fromEntries.ts","../src/noExcess.ts"],"sourcesContent":["import type { ObjByString } from './types.js';\n\n/**\n * An enumerated value.\n */\nexport type Enumerate<T = string, TKey extends string = string> = {\n  [key in TKey]: T;\n};\n\n/**\n * A TypeScript enum with string values.\n */\nexport type TypescriptEnum = { [key in string]: string } | { [key in number]: string };\n\n/**\n * An input when defining an enum can be an object of string -> string or a list\n * of strings.\n */\nexport type EnumInput<T, TKey extends string = string> = Enumerate<T, TKey> | string[];\n\n/**\n * Convert a list of strings to an enum-like object.\n */\nexport function listToEnum(attributes: string[]): Enumerate<string> {\n  const initialValue: Enumerate<string> = {};\n  return attributes.reduce((accumulator, value) => {\n    accumulator[value] = value;\n    return accumulator;\n  }, initialValue);\n}\n\n/**\n * Merge enum-like inputs into a single enum object.\n */\nexport function createEnum<T = string, TKey extends string = string>(\n  ...attributes: EnumInput<T, TKey>[]\n): Enumerate<T, TKey> {\n  const objectAttributes = attributes.map((attribute) =>\n    Array.isArray(attribute) ? listToEnum(attribute) : attribute,\n  );\n\n  return Object.assign({}, ...objectAttributes);\n}\n\n/**\n * Filter an enum and return the keys that remain.\n */\nexport function filterEnum<T extends ObjByString>(\n  obj: T,\n  filterFunc: (value: T[keyof T], key: keyof T, calculatedEnum: Enumerate<T[keyof T]>) => boolean,\n): (keyof T)[] {\n  return (Object.keys(obj) as (keyof T)[])\n    .filter((key) => filterFunc(obj[key], key, obj))\n    .map((key) => key);\n}\n\n/**\n * Make an enum compatible with type inference without changing its runtime\n * shape.\n */\nexport function makeEnum<T extends { [index: string]: Value | Value[] }, Value extends string>(\n  value: T,\n): T {\n  return value;\n}\n","import type { StringKeys } from './types.js';\n\n/**\n * `Object.keys` for string keys only.\n */\nexport function getStringKeys<T extends {}>(obj: T): StringKeys<T>[] {\n  return Object.keys(obj).filter((key) => typeof key === 'string') as StringKeys<T>[];\n}\n\n/**\n * `Object.keys` that preserves key types.\n */\nexport function getKeys<T extends {}>(obj: T): (keyof T)[] {\n  return Object.keys(obj) as (keyof T)[];\n}\n","import { createEnum } from './enum.js';\nimport { getKeys } from './getKeys.js';\nimport type { ObjByString, StringKeys } from './types.js';\n\n/**\n * Apply a function to each value of an object while preserving the key types.\n */\nexport function apply<TInput extends ObjByString, TOutput>(\n  obj: TInput,\n  applyFunc: (\n    value: TInput[keyof TInput],\n    key: StringKeys<TInput>,\n    fullObj: typeof obj,\n    index: number,\n  ) => TOutput,\n): { [key in keyof TInput]: TOutput } {\n  const result = Object.keys(obj).reduce(\n    (accumulator, key, index) =>\n      Object.assign(accumulator, {\n        [key]: applyFunc(obj[key], key as StringKeys<TInput>, obj, index),\n      }),\n    {},\n  );\n\n  return result as { [key in keyof TInput]: TOutput };\n}\n\n/**\n * Async version of `apply`.\n */\nexport async function asyncApply<TInput extends ObjByString, TOutput>(\n  obj: TInput,\n  applyFunc: (\n    value: TInput[keyof TInput],\n    key: StringKeys<TInput>,\n    fullObj: typeof obj,\n    index: number,\n  ) => Promise<TOutput>,\n): Promise<{ [key in keyof TInput]: TOutput }> {\n  const entries = await Promise.all(\n    getKeys(obj).map(async (key, index) => ({\n      key,\n      value: await applyFunc(obj[key], key as StringKeys<TInput>, obj, index),\n    })),\n  );\n\n  const result = entries.reduce(\n    (accumulator, { key, value }) =>\n      Object.assign(accumulator, {\n        [key]: value,\n      }),\n    {},\n  );\n\n  return result as { [key in keyof TInput]: TOutput };\n}\n\n/**\n * Convert a TypeScript enum to a value-to-value map and then call `apply`.\n */\nexport function applyEnum<TEnum extends string, TOutput>(\n  enm: { [key in string]: TEnum },\n  applyFunc: (value: TEnum, key: TEnum, fullObj: typeof enm, index: number) => TOutput,\n): { [key in TEnum]: TOutput } {\n  const obj = createEnum<TEnum, TEnum>(Object.values(enm));\n  return apply(obj, applyFunc) as any;\n}\n","import * as either from 'fp-ts/lib/Either.js';\nimport { pipe } from 'fp-ts/lib/function.js';\nimport * as t from 'io-ts';\n\n/**\n * Determine the codec paths that are invalid.\n */\nfunction getPaths<A>(validation: t.Validation<A>): string[] {\n  return pipe(\n    validation,\n    either.fold(\n      (errors) =>\n        errors.map((error) => {\n          const lastContext = error.context.at(-1);\n          const fullPath = error.context.map(({ key }) => key).join('.');\n          return `${fullPath} expected type '${lastContext?.type.name}'`;\n        }),\n      () => ['no errors'],\n    ),\n  );\n}\n\n/**\n * Get custom error messages for the errors.\n */\nfunction getCustomErrors<A>(\n  validation: t.Validation<A>,\n  customErrorFromContext: (validationContext: t.Context) => string,\n): string[] {\n  return pipe(\n    validation,\n    either.fold(\n      (errors) => errors.map((error) => customErrorFromContext(error.context)),\n      () => ['no errors'],\n    ),\n  );\n}\n\nexport const CODEC_ERROR_MESSAGE = 'Failed to decode codec:';\n\n/**\n * Decode a codec, returning the decoded value or throwing an error.\n */\nexport function decodeCodec<TCodec extends t.Any>(\n  codec: TCodec,\n  txt: unknown,\n  parse = true,\n  customErrorFromContext: ((validationContext: t.Context) => string) | undefined = undefined,\n): t.TypeOf<TCodec> {\n  const decoded = codec.decode(parse && typeof txt === 'string' ? JSON.parse(txt) : txt);\n\n  if (either.isLeft(decoded)) {\n    const errorPaths = getPaths(decoded);\n    const customError =\n      customErrorFromContext !== undefined\n        ? JSON.stringify(getCustomErrors(decoded, customErrorFromContext), null, 2)\n        : undefined;\n\n    throw new Error(\n      `${CODEC_ERROR_MESSAGE} ${JSON.stringify(errorPaths, null, 2)}${customError ?? ''}`,\n    );\n  }\n\n  return decoded.right;\n}\n","import { unsafeCoerce } from 'fp-ts/lib/function.js';\nimport * as t from 'io-ts';\n\n/**\n * A record with optional keys.\n */\nexport interface DictionaryC<D extends t.Mixed, C extends t.Mixed> extends t.DictionaryType<\n  D,\n  C,\n  {\n    [K in t.TypeOf<D>]?: t.TypeOf<C>;\n  },\n  {\n    [K in t.OutputOf<D>]?: t.OutputOf<C>;\n  },\n  unknown\n> {}\n\n/**\n * Helper to encode/decode a record with partial keys.\n */\nexport const dictionary = <D extends t.Mixed, C extends t.Mixed>(\n  keys: D,\n  values: C,\n  name?: string,\n): DictionaryC<D, C> => unsafeCoerce(t.record(t.union([keys, t.undefined]), values, name));\n","import * as t from 'io-ts';\n\n/**\n * Brand for strings of fixed length.\n */\nexport type FixedLengthStringBrand<N extends number> = {\n  /** The expected length of the string. */\n  readonly length: N;\n  /** Unique symbol to ensure uniqueness of this type across modules/packages. */\n  readonly FixedLengthString: unique symbol;\n};\n\n/**\n * Codec for strings constrained to a fixed length.\n */\nexport const FixedLengthString = <N extends number>(\n  len: N,\n): t.BrandC<t.StringC, FixedLengthStringBrand<N>> =>\n  t.brand(\n    t.string,\n    (value): value is t.Branded<string, FixedLengthStringBrand<N>> => value.length === len,\n    'FixedLengthString',\n  );\n\n/**\n * Branded fixed-length string type.\n */\nexport type FixedLengthString<N extends number> = t.TypeOf<\n  t.BrandC<t.StringC, FixedLengthStringBrand<N>>\n>;\n","import * as t from 'io-ts';\n\n/**\n * Brand for arrays with bounded length.\n */\nexport interface FixedLengthArrayBrand<T> extends Array<T> {\n  /** Unique symbol to ensure uniqueness of this type across modules/packages. */\n  readonly fixedLengthArray: unique symbol;\n  /** The minimum length of the array. */\n  readonly min: number;\n  /** The maximum length of the array. */\n  readonly max: number;\n}\n\n/**\n * Codec for arrays constrained to a fixed length range.\n */\nexport const FixedLengthArray = <C extends t.Mixed>(\n  min: number,\n  max: number,\n  codec: C,\n): t.BrandC<t.ArrayC<C>, FixedLengthArrayBrand<C>> =>\n  t.brand(\n    t.array(codec),\n    (value: Array<C>): value is t.Branded<Array<C>, FixedLengthArrayBrand<C>> =>\n      min <= value.length && value.length <= max,\n    'fixedLengthArray',\n  );\n\n/**\n * Branded fixed-length array type.\n */\nexport type FixedLengthArray<C extends t.Mixed> = t.TypeOf<\n  t.BrandC<t.ArrayC<C>, FixedLengthArrayBrand<C>>\n>;\n","import * as t from 'io-ts';\n\n/**\n * Like `t.record`, but where the keys are all optional to include.\n */\nexport interface PartialRecordC<D extends t.Mixed, C extends t.Mixed> extends t.DictionaryType<\n  D,\n  C,\n  {\n    [K in t.TypeOf<D>]?: t.TypeOf<C>;\n  },\n  {\n    [K in t.OutputOf<D>]?: t.OutputOf<C>;\n  },\n  unknown\n> {}\n\n/**\n * Create an `io-ts` compatible partial record.\n */\nexport const partialRecord = <D extends t.Mixed, C extends t.Mixed>(\n  domain: D,\n  codomain: C,\n  name?: string,\n): PartialRecordC<D, C> =>\n  t.record(t.union([domain, t.undefined]), codomain, name) as unknown as PartialRecordC<D, C>;\n","/**\n * Checks an error message to see if it is an `io-ts` codec error.\n */\nexport function isCodecError(err: Error): boolean {\n  return err.message.startsWith('Failed to decode codec');\n}\n","import * as t from 'io-ts';\n\n/**\n * Brand for non-empty strings.\n */\ntype NonEmptyStringBrand = {\n  /** Unique symbol to ensure uniqueness of this type across modules/packages. */\n  readonly NonEmptyString: symbol;\n};\n\n/**\n * Codec for non-empty trimmed strings.\n */\nexport const NonEmptyString = t.brand(\n  t.string,\n  (value): value is t.Branded<string, NonEmptyStringBrand> => value.trim().length !== 0,\n  'NonEmptyString',\n);\n\n/**\n * Branded non-empty string type.\n */\nexport type NonEmptyString = t.TypeOf<typeof NonEmptyString>;\n","import * as t from 'io-ts';\nimport type { JSONSchema7 } from 'json-schema';\n\n/**\n * `io-ts` types compatible with JSON Schema.\n */\ntype MappableType =\n  | t.NumberType\n  | t.StringType\n  | t.NullType\n  | t.BooleanType\n  | t.LiteralType<any>\n  | t.KeyofType<any>\n  | t.InterfaceType<any>\n  | t.DictionaryType<any, any>\n  | t.PartialType<any>\n  | t.UnionType<any>\n  | t.ArrayType<any>\n  | t.TupleType<any>\n  | t.IntersectionType<any>\n  | t.RefinementType<any>;\n\n/**\n * Convert an `io-ts` codec to a JSON Schema (v7).\n */\nexport const toJsonSchema = (\n  rawType: any,\n  strict = false,\n  alwaysIncludeRequired = false,\n): JSONSchema7 => {\n  const type = rawType as MappableType;\n\n  if (type._tag === 'StringType') {\n    return { type: 'string' };\n  }\n\n  if (type._tag === 'NumberType') {\n    return { type: 'number' };\n  }\n\n  if (type._tag === 'NullType') {\n    return { type: 'null' };\n  }\n\n  if (type._tag === 'BooleanType') {\n    return { type: 'boolean' };\n  }\n\n  if (type._tag === 'LiteralType') {\n    return { const: type.value };\n  }\n\n  if (type._tag === 'KeyofType') {\n    return { type: 'string', enum: Object.keys(type.keys) };\n  }\n\n  if (type._tag === 'UnionType') {\n    return {\n      anyOf: type.types.map((subtype: any) => toJsonSchema(subtype, strict, alwaysIncludeRequired)),\n    };\n  }\n\n  if (type._tag === 'IntersectionType' && !alwaysIncludeRequired) {\n    return {\n      allOf: type.types.map((subtype: any) => toJsonSchema(subtype, strict, alwaysIncludeRequired)),\n    };\n  }\n\n  if (type._tag === 'IntersectionType' && alwaysIncludeRequired) {\n    const results = type.types.map((subtype: any) =>\n      toJsonSchema(subtype, strict, alwaysIncludeRequired),\n    );\n\n    if (!results.every((result: any) => result.type === 'object')) {\n      throw new Error('InterfaceType must have all children as type=object');\n    }\n\n    return {\n      type: 'object',\n      required: results.map((result: any) => result.required).flat(),\n      properties: results.reduce(\n        (accumulator: any, result: any) => ({ ...accumulator, ...result.properties }),\n        {},\n      ),\n      ...(strict ? { additionalProperties: false } : {}),\n    };\n  }\n\n  if (type._tag === 'InterfaceType') {\n    return {\n      type: 'object',\n      required: Object.keys(type.props),\n      properties: Object.fromEntries(\n        Object.entries(type.props).map(([key, subtype]) => [\n          key,\n          toJsonSchema(subtype as t.Type<any>, strict, alwaysIncludeRequired),\n        ]),\n      ),\n      ...(strict ? { additionalProperties: false } : {}),\n    };\n  }\n\n  if (type._tag === 'DictionaryType') {\n    return {\n      type: 'object',\n      additionalProperties: toJsonSchema(type.codomain, strict, alwaysIncludeRequired),\n    };\n  }\n\n  if (type._tag === 'PartialType') {\n    return {\n      type: 'object',\n      ...(alwaysIncludeRequired ? { required: Object.keys(type.props) } : {}),\n      properties: Object.fromEntries(\n        Object.entries(type.props).map(([key, subtype]) => {\n          const result = toJsonSchema(subtype as t.Type<any>, strict, alwaysIncludeRequired);\n          return [\n            key,\n            alwaysIncludeRequired && result.type\n              ? {\n                  ...result,\n                  type: [result.type as any, 'null'],\n                }\n              : result,\n          ];\n        }),\n      ),\n      ...(strict ? { additionalProperties: false } : {}),\n    };\n  }\n\n  if (type._tag === 'ArrayType') {\n    return {\n      type: 'array',\n      items: toJsonSchema(type.type, strict, alwaysIncludeRequired),\n    };\n  }\n\n  if (type._tag === 'TupleType') {\n    return {\n      type: 'array',\n      items: type.types.map((subtype: any) => toJsonSchema(subtype, strict, alwaysIncludeRequired)),\n    };\n  }\n\n  if (type._tag === 'RefinementType') {\n    if (type.name === 'Int') {\n      return { type: 'integer' };\n    }\n\n    return {\n      ...toJsonSchema(type.type, strict, alwaysIncludeRequired),\n      description: `Predicate: ${type.predicate.name || type.name}`,\n    };\n  }\n\n  return unhandledType(type as never);\n};\n\nconst unhandledType = (_shouldBeNever: never) => ({});\n","import * as t from 'io-ts';\n\n/**\n * Creates a default value for an `io-ts` codec.\n */\nexport const createDefaultCodec = <C extends t.Mixed>(codec: C): t.TypeOf<C> => {\n  if (codec instanceof t.UnionType) {\n    const arrayType = codec.types.find((type: any) => type instanceof t.ArrayType);\n    if (arrayType) {\n      return createDefaultCodec(arrayType);\n    }\n\n    const objectType = codec.types.find(\n      (type: any) =>\n        type instanceof t.InterfaceType ||\n        type instanceof t.PartialType ||\n        type instanceof t.IntersectionType ||\n        type instanceof t.ArrayType,\n    );\n    if (objectType) {\n      return createDefaultCodec(objectType);\n    }\n\n    const hasNull = codec.types.some(\n      (type: any) => type instanceof t.NullType || type.name === 'null',\n    );\n    if (hasNull) {\n      return null as t.TypeOf<C>;\n    }\n\n    return createDefaultCodec(codec.types[0]);\n  }\n\n  if (codec instanceof t.InterfaceType || codec instanceof t.PartialType) {\n    const defaults: Record<string, any> = {};\n    Object.entries(codec.props).forEach(([key, type]) => {\n      defaults[key] = createDefaultCodec(type as any);\n    });\n    return defaults as t.TypeOf<C>;\n  }\n\n  if (codec instanceof t.IntersectionType) {\n    return codec.types.reduce(\n      (accumulator: t.TypeOf<C>, type: any) => ({\n        ...accumulator,\n        ...createDefaultCodec(type),\n      }),\n      {},\n    );\n  }\n\n  if (codec instanceof t.ArrayType) {\n    const elementType = codec.type;\n    const isObjectType =\n      elementType instanceof t.InterfaceType ||\n      elementType instanceof t.PartialType ||\n      elementType instanceof t.IntersectionType;\n\n    return (isObjectType ? [createDefaultCodec(elementType)] : []) as t.TypeOf<C>;\n  }\n\n  if (codec instanceof t.LiteralType) {\n    return codec.value as t.TypeOf<C>;\n  }\n\n  if (codec instanceof t.ObjectType) {\n    return {} as t.TypeOf<C>;\n  }\n\n  switch (codec.name) {\n    case 'string':\n      return '' as t.TypeOf<C>;\n    case 'number':\n      return 0 as t.TypeOf<C>;\n    case 'boolean':\n      return false as t.TypeOf<C>;\n    case 'null':\n      return null as t.TypeOf<C>;\n    case 'undefined':\n      return undefined as t.TypeOf<C>;\n    default:\n      return null as t.TypeOf<C>;\n  }\n};\n","import { makeEnum } from './enum.js';\n\n/**\n * The HTTP method types.\n */\nexport const HttpMethod = makeEnum({\n  /** A GET request. */\n  Get: 'GET',\n  /** A POST request. */\n  Post: 'POST',\n  /** A DELETE request. */\n  Delete: 'DELETE',\n  /** A PUT request. */\n  Put: 'PUT',\n  /** A PATCH request. */\n  Patch: 'PATCH',\n});\n\n/**\n * The HTTP method string union.\n */\nexport type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod];\n","import type { ObjByString } from './types.js';\n\n/**\n * `Object.entries` that preserves entry types.\n */\nexport function getEntries<TKey extends keyof TObj, TObj extends ObjByString>(\n  obj: TObj,\n): [TKey, TObj[TKey]][] {\n  return Object.entries(obj) as any;\n}\n","/**\n * `Object.values` that preserves value types.\n */\nexport function getValues<TValue>(obj: {\n  [key in string | number | symbol]: TValue;\n}): TValue[] {\n  return Object.values(obj) as TValue[];\n}\n","/**\n * A typed version of lodash's `groupBy`.\n */\nexport function groupBy<TItem, TKey>(\n  iterable: TItem[],\n  getKey: (item: TItem) => TKey,\n): Map<TKey, TItem[]> {\n  return iterable.reduce((groupedItems, item) => {\n    const groupedKey = getKey(item);\n    return groupedItems.set(groupedKey, [...(groupedItems.get(groupedKey) ?? []), item]);\n  }, new Map<TKey, TItem[]>());\n}\n","/**\n * Identify whether a string looks like a GraphQL interface/type/input\n * declaration.\n */\nexport const INTERFACE_REGEX = /(interface|type|input) [a-zA-Z0-9]* (implements .+?|){([\\s\\S]+?)}/;\n\n/**\n * A `gql` is simply a string branded with the associated GraphQL type.\n */\nexport type Gql<TGraphQLType extends object> = string & {\n  /** The TypeScript type definition that relates to the gql string. */\n  graphQLType: TGraphQLType;\n};\n\n/**\n * Template tag for GraphQL fragments with a small amount of interpolation\n * support for interface bodies.\n */\nexport function gql<TGraphQLType extends object>(\n  strings: TemplateStringsArray,\n  ...expressions: (string | number)[]\n): Gql<TGraphQLType> {\n  if (expressions.length === 0) {\n    return strings[0] as Gql<TGraphQLType>;\n  }\n\n  const count = strings.length - 1;\n  let result = '';\n  for (let index = 0; index < count; index += 1) {\n    const expression = expressions[index]!;\n    const text = typeof expression === 'string' ? expression : expression.toString();\n    const useExpression = INTERFACE_REGEX.test(text)\n      ? (INTERFACE_REGEX.exec(text) || [])[3]\n      : expression;\n    result += (strings[index] ?? '') + (useExpression ?? '');\n  }\n\n  result += strings[count] ?? '';\n  return result as Gql<TGraphQLType>;\n}\n","import { getEntries } from './getEntries.js';\n\n/**\n * Invert an object so the values look up the keys. Arrays are expanded and map\n * back to arrays of keys.\n */\nexport function invert<TKey extends string, TValue extends string | string[]>(\n  obj: { [key in TKey]?: TValue },\n  throwOnDuplicate = true,\n): {\n  [key in TValue extends (infer Item)[] ? Item : TValue]: TValue extends any[] ? TKey[] : TKey;\n} {\n  const result: any = {};\n\n  getEntries(obj).forEach(([key, instance]: [TKey, TValue | undefined]) => {\n    if (instance === undefined) {\n      throw new Error('inverse found undefined value, this is not supported');\n    }\n\n    if (Array.isArray(instance)) {\n      instance.forEach((listKey) => {\n        if (!result[listKey]) {\n          result[listKey] = [key];\n        } else {\n          result[listKey].push(key);\n        }\n      });\n      return;\n    }\n\n    if (result[instance] && throwOnDuplicate) {\n      throw new Error(\n        `Encountered duplicate value inverting object: \"${instance}: ${key} and ${result[instance]}\"`,\n      );\n    }\n\n    result[instance] = key;\n  });\n\n  return result;\n}\n\n/**\n * Safely invert an object into `{ [value]: key[] }`.\n */\nexport function invertSafe<TKey extends string, TValue extends string>(obj: {\n  [key in TKey]: TValue | TValue[];\n}): {\n  [key in TValue]: TKey[];\n} {\n  const result: any = {};\n\n  getEntries(obj).forEach(([key, instance]) => {\n    if (instance === undefined) {\n      throw new Error('inverse found undefined value, this is not supported');\n    }\n\n    if (Array.isArray(instance)) {\n      instance.forEach((listKey) => {\n        if (!result[listKey]) {\n          result[listKey] = [key];\n        } else {\n          result[listKey].push(key);\n        }\n      });\n      return;\n    }\n\n    if (!result[instance]) {\n      result[instance] = [key];\n      return;\n    }\n\n    result[instance].push(key);\n  });\n\n  return result;\n}\n","import * as t from 'io-ts';\n\nimport { invert } from './invert.js';\n\n/**\n * Build an `io-ts` codec over the values of an enum-like object.\n */\nexport function valuesOf<TEnum extends string>(enm: {\n  [key in string]: TEnum;\n}): t.KeyofC<{ [key in TEnum]: unknown }> {\n  return t.keyof(invert(enm) as any);\n}\n","/**\n * The full match returned when `regex.exec` finds a match.\n */\nexport interface RegExpMatch {\n  /** The full regex match. */\n  fullMatch: string;\n  /** The index in the text where the match was found. */\n  matchIndex: number;\n  /** Whether the match satisfies an optional stricter regex. */\n  isStrict?: boolean;\n}\n\n/**\n * Definition for finding all regex matches and mapping capture groups to keys.\n */\nexport interface FindAllRegExp<TMatchKeys extends string> {\n  /** The regex to test. */\n  value: RegExp;\n  /**\n   * A stricter regex used to annotate matches that satisfy a more exact\n   * standard.\n   */\n  strict?: RegExp;\n  /** Capture group names mapped by index. */\n  matches: readonly TMatchKeys[];\n  /** When true, skip validation of matches being the expected length. */\n  skipMatchValidation?: boolean;\n}\n\n/**\n * Use a regex with the global flag to find all matches and return the list with\n * capture groups mapped to named properties.\n */\nexport function findAllWithRegex<TMatchKeys extends string>(\n  regex: FindAllRegExp<TMatchKeys>,\n  text: string,\n): ({ [key in TMatchKeys]: string } & RegExpMatch)[] {\n  if (!regex.value.flags.includes('g')) {\n    throw new Error('Regex.value must have a g flag');\n  }\n\n  const matchParams = ['fullMatch', ...regex.matches];\n  const results: ({ [key in TMatchKeys]: string } & RegExpMatch)[] = [];\n\n  let match = regex.value.exec(text);\n  let index = 0;\n\n  while (match) {\n    if (matchParams.length !== match.length && !regex.skipMatchValidation) {\n      throw new Error(\n        `Mismatch in match length at index [${index}]: \"${match.length}\" vs expected: \"${matchParams.length}\"`,\n      );\n    }\n\n    const result = match.reduce(\n      (accumulator, matchResult, matchIndex) =>\n        Object.assign(accumulator, {\n          [matchParams[matchIndex] as string]: matchResult,\n        }),\n      {},\n    ) as { [key in TMatchKeys]: string } & RegExpMatch;\n\n    result.matchIndex = match.index;\n\n    if (regex.strict) {\n      result.isStrict = regex.strict.test(result.fullMatch);\n    }\n\n    results.push(result);\n\n    match = regex.value.exec(text);\n    index += 1;\n  }\n\n  return results;\n}\n","/**\n * Aggregates multiple objects into a single object by combining values of\n * matching keys into comma-separated strings.\n */\nexport const aggregateObjects = ({\n  objs,\n  wrap = false,\n}: {\n  /** The objects to aggregate in a single one. */\n  objs: any[];\n  /** Whether to wrap the concatenated values in `[]`. */\n  wrap?: boolean;\n}): any => {\n  const allKeys = Array.from(\n    new Set(objs.flatMap((obj) => (obj && typeof obj === 'object' ? Object.keys(obj) : []))),\n  );\n\n  return allKeys.reduce(\n    (accumulator, key) => {\n      const values = objs\n        .map((obj) => (wrap ? `[${obj?.[key] ?? ''}]` : (obj?.[key] ?? '')))\n        .join(',');\n      accumulator[key] = values;\n      return accumulator;\n    },\n    {} as Record<string, any>,\n  );\n};\n","import { aggregateObjects } from './aggregateObjects.js';\n\n/**\n * Flattens a nested object into a single-level object with concatenated key\n * names.\n */\nexport const flattenObject = ({\n  obj,\n  prefix = '',\n}: {\n  /** The object to flatten. */\n  obj: any;\n  /** The prefix to prepend to keys while recursing. */\n  prefix?: string;\n}): any =>\n  !obj\n    ? {}\n    : Object.keys(obj ?? []).reduce(\n        (accumulator, key) => {\n          const newKey = prefix ? `${prefix}_${key}` : key;\n          const entry = obj[key];\n\n          if (\n            Array.isArray(entry) &&\n            entry.length > 0 &&\n            entry.some((item) => typeof item === 'object' && item !== null)\n          ) {\n            const objectEntries = entry.filter((item) => typeof item === 'object' && item !== null);\n            const flattenedObjects = objectEntries.map((item) => flattenObject({ obj: item }));\n            const aggregated = aggregateObjects({ objs: flattenedObjects });\n            Object.entries(aggregated).forEach(([aggregatedKey, value]) => {\n              accumulator[`${newKey}_${aggregatedKey}`] = value;\n            });\n          } else if (typeof entry === 'object' && entry !== null && !Array.isArray(entry)) {\n            Object.assign(accumulator, flattenObject({ obj: entry, prefix: newKey }));\n          } else {\n            accumulator[newKey] = Array.isArray(entry)\n              ? entry\n                  .map((item) => {\n                    if (typeof item === 'string') {\n                      return item.replaceAll(',', '');\n                    }\n\n                    return item ?? '';\n                  })\n                  .join(',')\n              : typeof entry === 'string'\n                ? entry.replaceAll(',', '')\n                : (entry ?? '');\n          }\n\n          return accumulator;\n        },\n        {} as Record<string, any>,\n      );\n","/**\n * Type representing a transposed array of objects.\n */\ntype TransposedObjectArray<T, K extends keyof T> = {\n  [P in K]: Array<T[P]>;\n} & {\n  /** Properties not selected for transposition. */\n  rest: Array<Omit<T, K>>;\n};\n\n/**\n * Transpose an array of objects by converting selected properties into arrays\n * while keeping the remaining properties grouped in `rest`.\n */\nexport const transposeObjectArray = <T extends object, K extends keyof T>({\n  objects,\n  properties,\n  options = { includeOtherProperties: true },\n}: {\n  /** Array of objects to transpose. */\n  objects: T[];\n  /** Property keys to transpose into arrays. */\n  properties: K[];\n  /** Options for how to transpose the array. */\n  options?: {\n    /** Whether to include non-transposed properties in the final result. */\n    includeOtherProperties?: boolean;\n  };\n}): TransposedObjectArray<T, K> =>\n  objects.reduce(\n    (accumulator, item) => {\n      const result = { ...accumulator } as TransposedObjectArray<T, K>;\n\n      properties.forEach((property) => {\n        const currentArray = (accumulator[property] || []) as T[K][];\n        result[property] = [...currentArray, item[property]] as any;\n      });\n\n      const restObject = {} as Omit<T, K>;\n      Object.entries(item).forEach(([key, value]) => {\n        if (!properties.includes(key as K)) {\n          (restObject as any)[key] = value;\n        }\n      });\n\n      if (options.includeOtherProperties) {\n        result.rest = [...(accumulator.rest || []), restObject];\n      }\n\n      return result;\n    },\n    {} as TransposedObjectArray<T, K>,\n  );\n","/**\n * `Object.fromEntries` that preserves entry types.\n */\nexport function fromEntries<const TEntries extends ReadonlyArray<readonly [PropertyKey, unknown]>>(\n  entries: TEntries,\n): { [K in TEntries[number] as K[0]]: K[1] } {\n  return Object.fromEntries(entries) as { [K in TEntries[number] as K[0]]: K[1] };\n}\n","import type { Either, Right } from 'fp-ts/lib/Either.js';\nimport * as either from 'fp-ts/lib/Either.js';\nimport { pipe } from 'fp-ts/lib/function.js';\nimport * as t from 'io-ts';\n\n/**\n * Creates a type guard function that checks if a codec matches a specific tag.\n */\nconst getIsCodec =\n  <T extends t.Any>(tag: string) =>\n  (codec: t.Any): codec is T =>\n    (codec as any)._tag === tag;\n\nconst isInterfaceCodec = getIsCodec<t.InterfaceType<t.Props>>('InterfaceType');\nconst isPartialCodec = getIsCodec<t.PartialType<t.Props>>('PartialType');\n\n/**\n * Extract property definitions from various codec types.\n */\nconst getProps = (codec: t.HasProps): t.Props => {\n  switch (codec._tag) {\n    case 'RefinementType':\n    case 'ReadonlyType':\n      return getProps(codec.type);\n    case 'InterfaceType':\n    case 'StrictType':\n    case 'PartialType':\n      return codec.props;\n    case 'IntersectionType':\n      return codec.types.reduce<t.Props>((props, type) => Object.assign(props, getProps(type)), {});\n    default:\n      return {};\n  }\n};\n\n/**\n * Generate a string representation of props for type naming.\n */\nconst getNameFromProps = (props: t.Props): string =>\n  Object.keys(props)\n    .map((key) => `${key}: ${props[key]!.name}`)\n    .join(', ');\n\n/**\n * Wrap a type name with `Partial<>`.\n */\nconst getPartialTypeName = (inner: string): string => `Partial<${inner}>`;\n\n/**\n * Generate a human-readable type name for the no-excess wrapper.\n */\nconst getNoExcessTypeName = (codec: t.Any): string => {\n  if (isInterfaceCodec(codec)) {\n    return `{| ${getNameFromProps(codec.props)} |}`;\n  }\n\n  if (isPartialCodec(codec)) {\n    return getPartialTypeName(`{| ${getNameFromProps(codec.props)} |}`);\n  }\n\n  return `Excess<${codec.name}>`;\n};\n\n/**\n * Compare an object's keys against expected properties and return either the\n * object or a list of excess keys.\n */\nconst stripKeys = <T = any>(obj: T, props: t.Props): Either<string[], T> => {\n  const keys = Object.getOwnPropertyNames(obj);\n  const propKeys = Object.getOwnPropertyNames(props);\n\n  propKeys.forEach((propKey) => {\n    const index = keys.indexOf(propKey);\n    if (index !== -1) {\n      keys.splice(index, 1);\n    }\n  });\n\n  return keys.length ? either.left(keys) : either.right(obj);\n};\n\n/**\n * Wrap an `io-ts` codec so validation fails when excess properties are present.\n */\nexport const noExcess = <C extends t.HasProps>(\n  codec: C,\n  name: string = getNoExcessTypeName(codec),\n): NoExcessType<C> => {\n  const props: t.Props = getProps(codec);\n\n  return new NoExcessType<C>(\n    name,\n    (value): value is C => either.isRight(stripKeys(value, props)) && codec.is(value),\n    (value, context) => {\n      const unknownRecordValidation = t.UnknownRecord.validate(value, context);\n      if (either.isLeft(unknownRecordValidation)) {\n        return unknownRecordValidation;\n      }\n\n      const codecValidation = codec.validate(value, context);\n      if (either.isLeft(codecValidation)) {\n        return codecValidation;\n      }\n\n      return pipe(\n        stripKeys<C>(codecValidation.right, props),\n        either.mapLeft((keys) =>\n          keys.map((key) => ({\n            value: codecValidation.right[key],\n            context,\n            message: `excess key \"${key}\" found`,\n          })),\n        ),\n      );\n    },\n    (value) => codec.encode((stripKeys(value, props) as Right<any>).right),\n    codec,\n  );\n};\n\n/**\n * A wrapper type used with `io-ts` to ensure there are not any excess keys.\n */\nexport class NoExcessType<C extends t.Any, A = C['_A'], O = A, I = unknown> extends t.Type<\n  A,\n  O,\n  I\n> {\n  public readonly _tag = 'NoExcessType' as const;\n\n  public constructor(\n    name: string,\n    is: NoExcessType<C, A, O, I>['is'],\n    validate: NoExcessType<C, A, O, I>['validate'],\n    encode: NoExcessType<C, A, O, I>['encode'],\n    public readonly type: C,\n  ) {\n    super(name, is, validate, encode);\n  }\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,WAAW,YAAyC;AAElE,QAAO,WAAW,QAAQ,aAAa,UAAU;AAC/C,cAAY,SAAS;AACrB,SAAO;IAH+B,EAAE,CAI1B;;;;;AAMlB,SAAgB,WACd,GAAG,YACiB;CACpB,MAAM,mBAAmB,WAAW,KAAK,cACvC,MAAM,QAAQ,UAAU,GAAG,WAAW,UAAU,GAAG,UACpD;AAED,QAAO,OAAO,OAAO,EAAE,EAAE,GAAG,iBAAiB;;;;;AAM/C,SAAgB,WACd,KACA,YACa;AACb,QAAQ,OAAO,KAAK,IAAI,CACrB,QAAQ,QAAQ,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC,CAC/C,KAAK,QAAQ,IAAI;;;;;;AAOtB,SAAgB,SACd,OACG;AACH,QAAO;;;;;;;AC1DT,SAAgB,cAA4B,KAAyB;AACnE,QAAO,OAAO,KAA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