@postxl/utils 1.0.0 → 1.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.
Files changed (114) hide show
  1. package/dist/index.browser.d.ts +2 -0
  2. package/dist/index.browser.js +3 -0
  3. package/dist/index.d.ts +22 -25
  4. package/dist/index.js +36 -41
  5. package/dist/index.js.map +1 -1
  6. package/dist/zod-excel.decoders-BJliEI1Y.js +1426 -0
  7. package/dist/zod-excel.decoders-BJliEI1Y.js.map +1 -0
  8. package/dist/zod-excel.decoders-CGmBv5CD.d.ts +773 -0
  9. package/package.json +24 -15
  10. package/dist/DefaultMap.d.ts +0 -12
  11. package/dist/DefaultMap.d.ts.map +0 -1
  12. package/dist/DefaultMap.js +0 -26
  13. package/dist/DefaultMap.js.map +0 -1
  14. package/dist/NestedMap.d.ts +0 -17
  15. package/dist/NestedMap.d.ts.map +0 -1
  16. package/dist/NestedMap.js +0 -72
  17. package/dist/NestedMap.js.map +0 -1
  18. package/dist/TypedMapping.d.ts +0 -27
  19. package/dist/TypedMapping.d.ts.map +0 -1
  20. package/dist/TypedMapping.js +0 -33
  21. package/dist/TypedMapping.js.map +0 -1
  22. package/dist/array.d.ts +0 -7
  23. package/dist/array.d.ts.map +0 -1
  24. package/dist/array.js +0 -21
  25. package/dist/array.js.map +0 -1
  26. package/dist/async.d.ts +0 -4
  27. package/dist/async.d.ts.map +0 -1
  28. package/dist/async.js +0 -41
  29. package/dist/async.js.map +0 -1
  30. package/dist/buffer.d.ts +0 -5
  31. package/dist/buffer.d.ts.map +0 -1
  32. package/dist/buffer.js +0 -16
  33. package/dist/buffer.js.map +0 -1
  34. package/dist/check-port.d.ts +0 -10
  35. package/dist/check-port.d.ts.map +0 -1
  36. package/dist/check-port.js +0 -40
  37. package/dist/check-port.js.map +0 -1
  38. package/dist/datetime.d.ts +0 -23
  39. package/dist/datetime.d.ts.map +0 -1
  40. package/dist/datetime.js +0 -37
  41. package/dist/datetime.js.map +0 -1
  42. package/dist/dictionary.d.ts +0 -9
  43. package/dist/dictionary.d.ts.map +0 -1
  44. package/dist/dictionary.js +0 -45
  45. package/dist/dictionary.js.map +0 -1
  46. package/dist/format.d.ts +0 -2
  47. package/dist/format.d.ts.map +0 -1
  48. package/dist/format.js +0 -7
  49. package/dist/format.js.map +0 -1
  50. package/dist/group-by.d.ts +0 -9
  51. package/dist/group-by.d.ts.map +0 -1
  52. package/dist/group-by.js +0 -66
  53. package/dist/group-by.js.map +0 -1
  54. package/dist/index.d.ts.map +0 -1
  55. package/dist/is-object.d.ts +0 -13
  56. package/dist/is-object.d.ts.map +0 -1
  57. package/dist/is-object.js +0 -25
  58. package/dist/is-object.js.map +0 -1
  59. package/dist/map.d.ts +0 -23
  60. package/dist/map.d.ts.map +0 -1
  61. package/dist/map.js +0 -76
  62. package/dist/map.js.map +0 -1
  63. package/dist/omit.d.ts +0 -5
  64. package/dist/omit.d.ts.map +0 -1
  65. package/dist/omit.js +0 -11
  66. package/dist/omit.js.map +0 -1
  67. package/dist/pagination.d.ts +0 -7
  68. package/dist/pagination.d.ts.map +0 -1
  69. package/dist/pagination.js +0 -14
  70. package/dist/pagination.js.map +0 -1
  71. package/dist/random.d.ts +0 -11
  72. package/dist/random.d.ts.map +0 -1
  73. package/dist/random.js +0 -56
  74. package/dist/random.js.map +0 -1
  75. package/dist/remove-secrets.d.ts +0 -12
  76. package/dist/remove-secrets.d.ts.map +0 -1
  77. package/dist/remove-secrets.js +0 -62
  78. package/dist/remove-secrets.js.map +0 -1
  79. package/dist/remove-undefined.d.ts +0 -10
  80. package/dist/remove-undefined.d.ts.map +0 -1
  81. package/dist/remove-undefined.js +0 -22
  82. package/dist/remove-undefined.js.map +0 -1
  83. package/dist/result.d.ts +0 -35
  84. package/dist/result.d.ts.map +0 -1
  85. package/dist/result.js +0 -120
  86. package/dist/result.js.map +0 -1
  87. package/dist/sort.d.ts +0 -18
  88. package/dist/sort.d.ts.map +0 -1
  89. package/dist/sort.js +0 -64
  90. package/dist/sort.js.map +0 -1
  91. package/dist/string-colors.d.ts +0 -45
  92. package/dist/string-colors.d.ts.map +0 -1
  93. package/dist/string-colors.js +0 -73
  94. package/dist/string-colors.js.map +0 -1
  95. package/dist/string.d.ts +0 -162
  96. package/dist/string.d.ts.map +0 -1
  97. package/dist/string.js +0 -434
  98. package/dist/string.js.map +0 -1
  99. package/dist/types.d.ts +0 -98
  100. package/dist/types.d.ts.map +0 -1
  101. package/dist/types.js +0 -57
  102. package/dist/types.js.map +0 -1
  103. package/dist/uniq.d.ts +0 -2
  104. package/dist/uniq.d.ts.map +0 -1
  105. package/dist/uniq.js +0 -16
  106. package/dist/uniq.js.map +0 -1
  107. package/dist/zod-excel.decoders.d.ts +0 -162
  108. package/dist/zod-excel.decoders.d.ts.map +0 -1
  109. package/dist/zod-excel.decoders.js +0 -361
  110. package/dist/zod-excel.decoders.js.map +0 -1
  111. package/dist/zod.d.ts +0 -30
  112. package/dist/zod.d.ts.map +0 -1
  113. package/dist/zod.js +0 -56
  114. package/dist/zod.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-excel.decoders-BJliEI1Y.js","names":["_default: () => Value","key: Key","getKey1: (item: Item) => Key1","getKey2: (item: Item) => Key2","items: Item[]","key1: Key1","key2: Key2","item: Item","values: Item[]","entries: [Key1, Key2, Item][]","mappings: {\n [Model in keyof Identifiers]?: Mapping<Identifiers[Model]>\n }","newId: Identifiers[Model]","arr: T[]","value: T","predicate: (t: T) => number","arr: T[]","iterator: AsyncMapFn<T, R>","result: (R | undefined)[]","array: T[]","id: number | string","gen: ArrayGen<T>","mapFn: AsyncMapFn<T, R>","a: string | Buffer","b: string | Buffer","value: unknown","data: Value[]","keyFn: (item: Value) => Key","result: Dictionary<Value, Key>","data: T[]","result: Dictionary<T>","dict: Dictionary<S>","predicate: (item: S) => T","dict: Dictionary<T>","predicate: (item: T) => boolean","dict: Dictionary<Value>","key: Key","n: number","predicate: (x: T) => U","items: T[]","result: Partial<Record<U, T[]>>","predicate: (x: WithId) => GroupId","items: WithId[]","result: Partial<Record<GroupId, Record<Id, WithId>>>","getGroupId: (x: T) => GroupID","map: Map<Key, ValueFrom>","predicate: (item: ValueFrom, key: Key) => ValueTo","result: ValueTo[]","map: Map<KeyFrom, ValueFrom>","keyPredicate: (key: KeyFrom, value: ValueFrom) => KeyTo","valuePredicate: (item: ValueFrom, key: KeyFrom) => ValueTo","map: Map<KeyFrom, Value>","keyPredicate: (key: KeyFrom, value: Value) => KeyTo","map: Map<Key, Value>","predicate: (item: Value, key: Key) => boolean","key: Key","obj: T","key: string","items: Item[]","skip?: number","take?: number","max: number","value: number","length: number","value: unknown","config: T","newConfig: Record<string, unknown>","key: string","value: unknown","value: string","connection: string","password: string","obj: T","value: A","value: E","f: () => A","handleError: (error: Error) => E","result: SerializedResult<A, E>","promise: () => Promise<A>","#tag","#value","#error","tag: 'ok' | 'err'","value: A | E","f: (a: A) => B","f: (e: E) => X","f: (a: A) => Result<B, E>","fallback: A","items: Item[]","dir: Direction","compareFn: CompareFn<Item>","key: keyof T","getter: Getter<T>","data: T","compareValues: CompareFn<unknown>","compareDates: CompareFn<Date>","compareStrings: CompareFn<string>","compareNumbers: CompareFn<number>","compareBooleans: CompareFn<boolean>","bool: boolean","input: string","s: string","IRREGULAR_PLURALS: [singular: string, plural: string][]","obj: T","str: string","lines: string","input: string","name: string","value: string","existingValues: string[]","val: never","value: unknown","obj: I[]","fn: (i: I) => asserts i is O","items: T[]","predicate: (item: T) => number","result: T[]","seen: Record<string, true>","initialValue: Initial","ctx: z.RefinementCtx","fns: Fns","result: any","param: string | ((data: any) => string)","message: string","x: number","ctx: z.RefinementCtx","transformer: (x: I, ctx: z.RefinementCtx) => O","x: I | undefined | null","excelStringStrictDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>,\n string,\n string | number | boolean // NOSONAR\n>","x: string | number | boolean","excelStringDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodUndefined, z.ZodAny]>,\n string,\n any\n>","excelStringNullableDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodUndefined, z.ZodAny]>,\n string | null,\n any\n>","x: any","excelNumberStrictDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>,\n number,\n string | number | boolean\n>","excelNumberDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodUndefined, z.ZodAny]>,\n number,\n any\n>","excelNumberNullableDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNull, z.ZodNumber, z.ZodUndefined, z.ZodAny]>,\n number | null,\n any\n>","excelIntStrictDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, number, string | number | boolean>,\n number,\n string | number | boolean\n>","excelIntDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodUndefined, z.ZodAny]>, number, any>,\n number,\n any\n>","excelIntNullableDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNull, z.ZodNumber, z.ZodUndefined, z.ZodAny]>, number | null, any>,\n number | null,\n any\n>","excelBigIntStrictDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, number, string | number | boolean>,\n bigint,\n string | number | boolean\n>","excelBigIntDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodUndefined, z.ZodAny]>, number, any>,\n bigint,\n any\n>","excelBigIntNullableDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNull, z.ZodNumber, z.ZodUndefined, z.ZodAny]>, number | null, any>,\n bigint | null,\n any\n>","excelBooleanStrictDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodBoolean, z.ZodNumber, z.ZodString]>,\n boolean,\n string | number | boolean\n>","excelBooleanDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodBoolean, z.ZodNumber, z.ZodNull, z.ZodString, z.ZodUndefined, z.ZodAny]>,\n boolean,\n any\n>","excelBooleanNullableDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodBoolean, z.ZodNumber, z.ZodNull, z.ZodString, z.ZodUndefined, z.ZodAny]>,\n boolean | null,\n any\n>","excelDateDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodDate, z.ZodNumber, z.ZodString]>,\n Date,\n string | number | Date\n>","excelDateNullableDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodDate, z.ZodString, z.ZodNumber, z.ZodNull, z.ZodUndefined, z.ZodAny]>,\n Date | null,\n any\n>"],"sources":["../src/DefaultMap.ts","../src/NestedMap.ts","../src/TypedMapping.ts","../src/array.ts","../src/async.ts","../src/buffer.ts","../src/datetime.ts","../src/dictionary.ts","../src/format.ts","../src/group-by.ts","../src/map.ts","../src/omit.ts","../src/pagination.ts","../src/random.ts","../src/is-object.ts","../src/remove-secrets.ts","../src/remove-undefined.ts","../src/result.ts","../src/sort.ts","../src/string-colors.ts","../src/string.ts","../src/types.ts","../src/uniq.ts","../src/zod.ts","../src/zod-excel.decoders.ts"],"sourcesContent":["/**\n * A map extension that returns a default value if the key is not found.\n */\nexport class DefaultMap<Key, Value> extends Map<Key, Value> {\n /**\n * A function that returns the default value for the map.\n */\n\n constructor(private readonly _default: () => Value) {\n super()\n }\n\n override get(key: Key): Value {\n const value = super.get(key)\n if (value) {\n return value\n }\n\n const defaultValue = this._default()\n this.set(key, defaultValue)\n\n return defaultValue\n }\n}\n","export class NestedMap<Key1, Key2, Item> {\n private readonly _map = new Map<Key1, Map<Key2, Item>>()\n\n constructor(\n private readonly getKey1: (item: Item) => Key1,\n private readonly getKey2: (item: Item) => Key2,\n items: Item[] = [],\n ) {\n for (const item of items) {\n this.set(item)\n }\n }\n get(key1: Key1, key2: Key2): Item | undefined {\n const map = this._map.get(key1)\n if (!map) {\n return undefined\n }\n return map.get(key2)\n }\n\n private getKeys(item: Item): [Key1, Key2] {\n return [this.getKey1(item), this.getKey2(item)]\n }\n set(item: Item): void {\n const [key1, key2] = this.getKeys(item)\n\n let map = this._map.get(key1)\n if (!map) {\n map = new Map<Key2, Item>()\n this._map.set(key1, map)\n }\n map.set(key2, item)\n }\n\n delete(item: Item): void {\n const [key1, key2] = this.getKeys(item)\n const map = this._map.get(key1)\n if (!map) {\n return\n }\n map.delete(key2)\n }\n\n clear(): void {\n this._map.clear()\n }\n\n get size(): number {\n return Array.from(this._map.values()).reduce((sum, map) => sum + map.size, 0)\n }\n\n get keys(): Iterable<Key1> {\n return this._map.keys()\n }\n\n get values(): Iterable<Item> {\n const values: Item[] = []\n for (const map of this._map.values()) {\n for (const value of map.values()) {\n values.push(value)\n }\n }\n return values\n }\n\n get entries(): Iterable<[Key1, Key2, Item]> {\n const entries: [Key1, Key2, Item][] = []\n for (const [key1, map] of this._map.entries()) {\n for (const [key2, value] of map.entries()) {\n entries.push([key1, key2, value])\n }\n }\n return entries\n }\n\n get [Symbol.iterator](): Iterable<[Key1, Key2, Item]> {\n return this.entries\n }\n}\n","type IdentifiersBase = Record<string, string>\n\ntype Mapping<T> = Map<T, T>\n\n/**\n * A map of typed mappings.\n */\nexport class TypedMapping<Identifiers extends IdentifiersBase> {\n private mappings: {\n [Model in keyof Identifiers]?: Mapping<Identifiers[Model]>\n }\n\n constructor(\n mappings: {\n [Model in keyof Identifiers]?: Mapping<Identifiers[Model]>\n } = {},\n ) {\n this.mappings = mappings\n }\n\n /**\n * Creates a new mapping from the original id to the new id.\n */\n public set<Model extends keyof Identifiers>(\n { model, id }: { model: Model; id: Identifiers[Model] },\n newId: Identifiers[Model],\n ): this {\n if (!this.mappings[model]) {\n this.mappings[model] = new Map()\n }\n\n this.mappings[model]!.set(id, newId)\n\n return this\n }\n\n /**\n * Returns the id if there exists a mapping, otherwise returns the original id.\n */\n public get<Model extends keyof Identifiers>({\n model,\n id,\n }: {\n model: Model\n id: Identifiers[Model]\n }): Identifiers[Model] {\n const mapping = this.mappings[model]?.get(id)\n if (!mapping) {\n return id\n }\n return mapping\n }\n}\n","/**\n * Adds a value to a sorted array and keeps the array sorted.\n *\n * O(n)\n */\nexport function addAndSort<T>(arr: T[], value: T, predicate: (t: T) => number): T[] {\n arr.push(value)\n\n let i = arr.length - 1\n const item = arr[i] as T\n const order = predicate(item)\n\n while (i > 0 && order < predicate(arr[i - 1] as T)) {\n arr[i] = arr[i - 1] as T\n i -= 1\n }\n arr[i] = item\n\n return arr\n}\n","//Credit: https://codeburst.io/async-map-with-limited-parallelism-in-node-js-2b91bd47af70\n\nconst defaultConcurrency = 5\ntype AsyncMapFn<T, R> = (item: T, index: number) => Promise<R>\ntype ArrayGen<T> = Generator<[T | undefined, number], void, void>\n\n// async maps over all values of an array but limits the number of concurrent operations\nexport async function mapLimit<T, R>(\n arr: T[],\n iterator: AsyncMapFn<T, R>,\n limit = defaultConcurrency,\n): Promise<(R | undefined)[]> {\n const result: (R | undefined)[] = []\n if (arr.length === 0) {\n return result\n }\n\n const generator = arrayGenerator(arr)\n\n limit = Math.min(limit, arr.length)\n const workers = new Array(limit)\n\n for (let i = 0; i < limit; i++) {\n workers.push(worker(i, generator, iterator, result))\n }\n\n await Promise.all(workers)\n\n return result\n}\n\nfunction* arrayGenerator<T>(array: T[]): ArrayGen<T> {\n for (let index = 0; index < array.length; index++) {\n const currentValue = array[index]\n yield [currentValue, index]\n }\n}\n\nasync function worker<T, R>(\n id: number | string,\n gen: ArrayGen<T>,\n mapFn: AsyncMapFn<T, R>,\n result: (R | undefined)[],\n): Promise<void> {\n for (const [currentValue, index] of gen) {\n result[index] = undefined\n if (currentValue === undefined) {\n return\n }\n try {\n result[index] = await mapFn(currentValue, index)\n } catch (e) {\n console.error(`Worker ${id} --- index ${index} item ${JSON.stringify(currentValue)} failed`, e)\n }\n }\n}\n","/**\n * Compares two string or buffer values for equality.\n */\nexport function equals(a: string | Buffer, b: string | Buffer): boolean {\n if (typeof a === 'string' && typeof b === 'string') {\n return a === b\n }\n\n if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) {\n return a.equals(b)\n }\n\n return false\n}\n","/**\n * returns the default time stamp in format YYMMDD HHMM\n */\nexport function timeStamp(): string {\n const date = new Date()\n const year = date.getFullYear().toString().slice(-2)\n const month = (date.getMonth() + 1).toString().padStart(2, '0')\n const day = date.getDate().toString().padStart(2, '0')\n const hour = date.getHours().toString().padStart(2, '0')\n const minute = date.getMinutes().toString().padStart(2, '0')\n return `${year}${month}${day} ${hour}${minute}`\n}\n\n/**\n * Checks if a value is a valid Date object.\n * Returns true only for Date instances that are not Invalid Date.\n * This function is isomorphic and works in both Node.js and browser environments.\n *\n * @param value - The value to check\n * @returns true if the value is a valid Date object, false otherwise\n *\n * @example\n * isDate(new Date()) // true\n * isDate(new Date('2023-01-01')) // true\n * isDate(new Date('invalid')) // false (Invalid Date)\n * isDate('2023-01-01') // false\n * isDate(1234567890) // false\n * isDate(null) // false\n * isDate(undefined) // false\n */\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date && !Number.isNaN(value.getTime())\n}\n","export type Dictionary<Value, Key extends string = string> = Record<Key, Value>\n\nexport function toDict<Value, Key extends string = string>(\n data: Value[],\n keyFn: (item: Value) => Key,\n): Dictionary<Value, Key> {\n const result: Dictionary<Value, Key> = {} as Dictionary<Value, Key>\n\n for (const item of data) {\n result[keyFn(item)] = item\n }\n return result\n}\n\nexport function idToDict<T extends { id: string | number }>(data: T[]): Dictionary<T> {\n const result: Dictionary<T> = {}\n\n for (const item of data) {\n result[item.id.toString()] = item\n }\n return result\n}\n\nexport function mapDict<S, T>(dict: Dictionary<S>, predicate: (item: S) => T): Dictionary<T> {\n const result: Dictionary<T> = {}\n\n for (const [key, value] of Object.entries(dict)) {\n result[key] = predicate(value)\n }\n return result\n}\n\nexport function filterDict<T>(dict: Dictionary<T>, predicate: (item: T) => boolean): Dictionary<T> {\n const result: Dictionary<T> = {}\n\n for (const [key, value] of Object.entries(dict)) {\n if (predicate(value)) {\n result[key] = value\n }\n }\n return result\n}\n\nexport function dictGetAndAssert<Key extends string, Value>(dict: Dictionary<Value>, key: Key): NonNullable<Value> {\n const value = dict[key]\n if (value === null || value === undefined) {\n throw new Error(`Key ${key} not found`)\n }\n return value as NonNullable<Value>\n}\n","export function format(n: number, locale = 'en-US'): string {\n return new Intl.NumberFormat(locale).format(n)\n}\n","export const groupBy = <T, U extends string | number>(predicate: (x: T) => U, items: T[]): Partial<Record<U, T[]>> => {\n const result: Partial<Record<U, T[]>> = {}\n for (const item of items) {\n const key = predicate(item)\n\n const group = result[key]\n\n if (group === undefined) {\n result[key] = [item]\n } else {\n group.push(item)\n }\n }\n return result\n}\n\nexport const groupByCurried = <T, U extends string | number>(\n predicate: (x: T) => U,\n): ((items: T[]) => Partial<Record<U, T[]>>) => {\n const result: Partial<Record<U, T[]>> = {}\n return (items: T[]) => {\n for (const item of items) {\n const key = predicate(item)\n\n const group = result[key]\n\n if (group === undefined) {\n result[key] = [item]\n } else {\n group.push(item)\n }\n }\n return result\n }\n}\n\nexport const groupByToDict = <Id extends string | number, WithId extends { id: Id }, GroupId extends string | number>(\n predicate: (x: WithId) => GroupId,\n items: WithId[],\n): Partial<Record<GroupId, Record<Id, WithId>>> => {\n const result: Partial<Record<GroupId, Record<Id, WithId>>> = {}\n for (const item of items) {\n const key = predicate(item)\n\n const group = result[key]\n\n if (group === undefined) {\n result[key] = { [item.id]: item } as Record<Id, WithId>\n } else {\n group[item.id] = item\n }\n }\n return result\n}\n\nexport const groupByToMap = <T extends { id: ItemID }, ItemID extends string | number, GroupID extends string | number>(\n getGroupId: (x: T) => GroupID,\n items: T[],\n): Map<GroupID, Map<ItemID, T>> => {\n const result = new Map<GroupID, Map<ItemID, T>>()\n for (const item of items) {\n const groupId = getGroupId(item)\n\n if (!result.has(groupId)) {\n result.set(groupId, new Map())\n }\n\n const group = result.get(groupId)\n if (group !== undefined) {\n group.set(item.id, item)\n }\n }\n return result\n}\n","export function mapMap<Key, ValueFrom, ValueTo>(\n map: Map<Key, ValueFrom>,\n predicate: (item: ValueFrom, key: Key) => ValueTo,\n): Map<Key, ValueTo> {\n const result = new Map<Key, ValueTo>()\n\n for (const [key, value] of map.entries()) {\n result.set(key, predicate(value, key))\n }\n return result\n}\n\nexport function mapMapValues<Key, ValueFrom, ValueTo>(\n map: Map<Key, ValueFrom>,\n predicate: (item: ValueFrom, key: Key) => ValueTo,\n): ValueTo[] {\n const result: ValueTo[] = []\n\n for (const [key, value] of map.entries()) {\n result.push(predicate(value, key))\n }\n return result\n}\n\n/**\n *\n */\nexport function mapMapKeyValues<KeyFrom, KeyTo, ValueFrom, ValueTo>(\n map: Map<KeyFrom, ValueFrom>,\n keyPredicate: (key: KeyFrom, value: ValueFrom) => KeyTo,\n valuePredicate: (item: ValueFrom, key: KeyFrom) => ValueTo,\n): Map<KeyTo, ValueTo> {\n const result = new Map<KeyTo, ValueTo>()\n\n for (const [key, value] of map.entries()) {\n result.set(keyPredicate(key, value), valuePredicate(value, key))\n }\n return result\n}\n\n/**\n * Maps keys of a map.\n */\nexport function mapMapKeys<KeyFrom, KeyTo, Value>(\n map: Map<KeyFrom, Value>,\n keyPredicate: (key: KeyFrom, value: Value) => KeyTo,\n): Map<KeyTo, Value> {\n const result = new Map<KeyTo, Value>()\n\n for (const [key, value] of map.entries()) {\n result.set(keyPredicate(key, value), value)\n }\n return result\n}\n\n/**\n * Filters values from a map.\n */\nexport function filterMap<Key, Value>(\n map: Map<Key, Value>,\n predicate: (item: Value, key: Key) => boolean,\n): Map<Key, Value> {\n const result = new Map<Key, Value>()\n\n for (const [key, value] of map.entries()) {\n if (predicate(value, key)) {\n result.set(key, value)\n }\n }\n\n return result\n}\n\n/**\n * Gets a value from a map and asserts that it exists.\n */\nexport function mapGetAndAssert<Key, Value>(map: Map<Key, Value>, key: Key): Value {\n const value = map.get(key)\n if (!value) {\n throw new Error(`Key ${JSON.stringify(key)} not found`)\n }\n return value\n}\n\n/**\n * Converts a map to a dictionary.\n */\nexport function mapToDict<Key extends string | number, Value>(map: Map<Key, Value>): Record<Key, Value> {\n const result = {} as Record<Key, Value>\n for (const [key, value] of map.entries()) {\n result[key] = value\n }\n return result\n}\n","/**\n * Omits a key from an object\n */\nexport function omit<T extends Record<string, unknown>>(obj: T, key: string): Omit<T, typeof key> {\n const { [key]: _, ...rest } = obj\n return rest\n}\n","export type Page<Item> = { total: number; offset: number; items: Item[] }\n\nexport const slice = <Item>(items: Item[], skip?: number, take?: number): Page<Item> => {\n const start = skip ?? 0\n const end = take ? start + take : undefined\n return {\n total: items.length,\n offset: start,\n items: items.slice(start, end),\n }\n}\n","/**\n * Returns a random integer between 0 (inclusive) and max (exclusive).\n *\n * Isomorphic implementation for Node.js, Deno, Bun, and browser environments.\n * Uses Web Crypto API which is available in all modern JavaScript runtimes.\n */\nexport function randomInt(max: number): number {\n // All modern environments (Node.js 15+, Deno, Bun, browsers) have Web Crypto API\n if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') {\n return browserRandomInt(max)\n }\n\n throw new Error('No suitable random number generator available')\n}\n\nfunction browserRandomInt(max: number): number {\n // Browser - use rejection sampling to avoid modulo bias\n const randomMax = 0x100000000 // 2^32\n const range = randomMax - (randomMax % max)\n\n let value: number\n do {\n const array = new Uint32Array(1)\n crypto.getRandomValues(array)\n value = array[0]!\n } while (value >= range)\n\n return value % max\n}\n\nconst CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'\n\n/**\n * Returns a randomly generated alphanumeric string.\n */\nexport function generateRandomAlphanumericString(length: number): string {\n let result = ''\n for (let i = 0; i < length; i++) {\n result += CHARS[randomInt(CHARS.length)]\n }\n return result\n}\n","/**\n * Returns true if the value is an object, false otherwise.\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null\n}\n\n/**\n * Only returns true for plain objects, not for classes or functions\n */\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && value.constructor === Object\n}\n\n/**\n * Returns true if the value is a function, false otherwise.\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n","import { isPlainObject } from './is-object'\n\n/**\n * Removes secrets from the given configuration object.\n *\n * Recursively checks all properties of the object for keys that end with\n * `key`, `secret`, `password`, `token` and replaces them with '***'.\n *\n * Also checks for keys the end with `connection` or `connectionString` and\n * replaces the connection string with the same string but with the password\n * replaced with '***'.\n */\nexport function removeSecrets<T extends Record<string, unknown>>(config: T): T {\n const newConfig: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(config)) {\n newConfig[key] = processValue(key, value)\n }\n return newConfig as T\n}\n\nfunction processValue(key: string, value: unknown): unknown {\n if (typeof value === 'string') {\n return processString(key, value)\n } else if (Array.isArray(value)) {\n return value.map((item) => removeSecrets(item))\n } else if (typeof value === 'object' && isPlainObject(value)) {\n return removeSecrets(value)\n }\n return value\n}\n\nfunction processString(key: string, value: string): string {\n if (key.endsWith('key') || key.endsWith('secret') || key.endsWith('password') || key.endsWith('token')) {\n return hidePassword(value)\n } else if (key.endsWith('connection') || key.endsWith('connectionString')) {\n return hidePasswordInConnectionString(value)\n } else {\n return value\n }\n}\n\nfunction hidePasswordInConnectionString(connection: string): string {\n return (\n connection\n // e.g. postgresql://user:password@host\n .replace(/^(.*):\\/\\/(.*):(.*)@(.*)$/, '$1://$2:***@$4') //NOSONAR - this is only used to parse environment variables, so no risk of external DOS attacks\n // e.g. user:password@host\n .replace(/^(.*):(.*)@(.*)$/, '$1:***@$3') //NOSONAR - this is only used to parse environment variables, so no risk of external DOS attacks\n )\n}\n\nfunction hidePassword(password: string): string {\n if (password === '') {\n return 'nothing provided!'\n }\n if (password === 'secret') {\n return 'default provided!'\n }\n return '***'\n}\n","/**\n * Removes all undefined properties from an object.\n *\n * NOTE: This is useful when using the `Partial<T>` type modifier in combination with the spread operator to prevent\n * overriding with undefined values.\n */\nexport function removeUndefinedProperties<T extends Record<string, unknown>>(\n obj: T,\n): { [K in keyof T]: T[K] extends undefined ? never : T[K] } {\n const newObj = {} as {\n [K in keyof T]: T[K] extends undefined ? never : T[K]\n }\n\n for (const key in obj) {\n const value = obj[key]\n\n if (value !== undefined) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n newObj[key] = value\n }\n }\n\n return newObj\n}\n","export type SerializedResult<A, E> = { tag: 'ok'; value: A } | { tag: 'err'; err: E }\n\nexport class Result<A, E> {\n static ok<A, E>(value: A): Result<A, E> {\n return new Result<A, E>('ok', value)\n }\n\n static err<A, E>(value: E): Result<A, E> {\n return new Result<A, E>('err', value)\n }\n\n static fromThrowable<A, E>(f: () => A, handleError: (error: Error) => E): Result<A, E> {\n try {\n return Result.ok(f())\n } catch (error) {\n return Result.err(handleError(error as Error))\n }\n }\n\n static fromObject<A, E>(result: SerializedResult<A, E>): Result<A, E> {\n if (result.tag === 'ok') {\n return Result.ok(result.value)\n } else {\n return Result.err(result.err)\n }\n }\n\n static async fromPromise<A, E>(promise: () => Promise<A>, handleError: (error: Error) => E): Promise<Result<A, E>> {\n try {\n return Result.ok(await promise())\n } catch (error) {\n return Result.err(handleError(error as Error))\n }\n }\n\n // We track the tag separately from the value and error to allow for us to use\n // `null` as a valid value.\n\n readonly #tag: 'ok' | 'err'\n readonly #value: A | null\n readonly #error: E | null\n\n private constructor(tag: 'ok', value: A)\n private constructor(tag: 'err', value: E)\n private constructor(tag: 'ok' | 'err', value: A | E) {\n this.#tag = tag\n this.#value = tag === 'ok' ? (value as A) : null\n this.#error = tag === 'err' ? (value as E) : null\n }\n\n isOk(): this is Result<A, never> {\n return this.#tag === 'ok'\n }\n\n isErr(): this is Result<never, E> {\n return this.#tag === 'err'\n }\n\n map<B>(f: (a: A) => B): Result<B, E> {\n if (this.#tag === 'ok') {\n return Result.ok(f(this.#value!))\n } else {\n return this as unknown as Result<B, E>\n }\n }\n\n mapErr<X>(f: (e: E) => X): Result<A, X> {\n if (this.#tag === 'err') {\n return Result.err(f(this.#error!))\n } else {\n return this as unknown as Result<A, X>\n }\n }\n\n andThen<B>(f: (a: A) => Result<B, E>): Result<B, E> {\n if (this.#tag === 'ok') {\n return f(this.#value!)\n } else {\n return this as unknown as Result<B, E>\n }\n }\n\n withDefault(fallback: A): A {\n return this.#tag === 'ok' ? this.#value! : fallback\n }\n\n unwrap(): A {\n if (this.#tag === 'ok') {\n return this.#value!\n } else {\n throw new Error(typeof this.#error === 'string' ? this.#error : JSON.stringify(this.#error))\n }\n }\n\n unwrapErr(): E {\n if (this.#tag === 'err') {\n return this.#error!\n } else {\n throw new Error('tried to unwrap an ok result')\n }\n }\n\n toJSON(): SerializedResult<A, E> {\n if (this.#tag === 'ok') {\n return { tag: 'ok', value: this.#value! }\n } else {\n return { tag: 'err', err: this.#error! }\n }\n }\n}\n\nexport const ok = Result.ok\nexport const err = Result.err\n\nexport type TypedError<T extends string> = {\n type: T\n message: string\n error: Error\n}\n\nexport default Result\n","export type CompareFn<T> = (a: T, b: T) => number\n\nexport type Direction = 'asc' | 'desc'\n\nexport const sort = <Item>(items: Item[], dir: Direction = 'asc', compareFn: CompareFn<Item> = compareValues): Item[] =>\n setDirection(items.toSorted(compareFn), dir)\n\n/**\n * Compare fields of an object.\n */\nexport const compareFields = <T>(key: keyof T): CompareFn<T> => {\n return (a, b) => compareValues(a[key], b[key])\n}\n\nexport type Getter<T> = (data: T) => unknown\n\nexport const compare = <T>(getter: Getter<T>): CompareFn<T> => {\n return (a, b) => compareValues(getter(a), getter(b))\n}\n\nexport const keyGetter = <T>(key: keyof T): Getter<T> => {\n return (data: T) => data[key]\n}\n\nexport const compareValues: CompareFn<unknown> = (a, b) => {\n switch (true) {\n // In case one item is undefined or null and the other is not, we place the non-null item first.\n case (a === undefined || a === null) && b !== undefined && b !== null:\n return 1\n\n case (b === undefined || b === null) && a !== undefined && a !== null:\n return -1\n\n case (a === undefined || a === null) && (b === undefined || b === null):\n return 0\n\n case a instanceof Date && b instanceof Date:\n return compareDates(a, b)\n\n case typeof a === 'string' && typeof b === 'string':\n return compareStrings(a, b)\n\n case typeof a === 'number' && typeof b === 'number':\n return compareNumbers(a, b)\n\n case typeof a === 'boolean' && typeof b === 'boolean':\n return compareBooleans(a, b)\n\n default:\n return 0\n }\n}\n\nexport const compareDates: CompareFn<Date> = (a, b) => compareStrings(a.toISOString(), b.toISOString())\n\nexport const compareStrings: CompareFn<string> = (a, b) => {\n const aLower = a.trim().toLowerCase()\n const bLower = b.trim().toLowerCase()\n if (aLower === bLower) {\n return 0\n }\n return aLower > bLower ? 1 : -1\n}\n\nexport const compareNumbers: CompareFn<number> = (a, b) => a - b\n\nexport const compareBooleans: CompareFn<boolean> = (a, b) => booleanCode(a) - booleanCode(b)\n\nexport const booleanCode = (bool: boolean): number => (bool ? 1 : 0)\n\nexport const setDirection = <Item>(items: Item[], dir: Direction): Item[] => {\n return dir === 'desc' ? items.toReversed() : items\n}\n","/**\n * A function that returns a string with a specific color.\n */\nexport type ColorFn = (input: string) => string\n\n/**\n * Colors a string in red color (using ANSI escape codes).\n */\nexport function red(input: string): string {\n return `\\u001b[31m${input}\\u001b[39m`\n}\n\n/**\n * Colors a string in green color (using ANSI escape codes).\n */\nexport function green(input: string): string {\n return `\\u001b[32m${input}\\u001b[39m`\n}\n\n/**\n * Colors a string in yellow color (using ANSI escape codes).\n */\nexport function yellow(input: string): string {\n return `\\u001b[33m${input}\\u001b[39m`\n}\n\n/**\n * Colors a string in blue color (using ANSI escape codes).\n */\nexport function blue(input: string): string {\n return `\\u001b[34m${input}\\u001b[39m`\n}\n\n/**\n * Colors a string in cyan color (using ANSI escape codes).\n */\nexport function cyan(input: string): string {\n return `\\u001b[36m${input}\\u001b[39m`\n}\n\n/**\n * Colors a string in gray color (using ANSI escape codes).\n */\nexport function gray(input: string): string {\n return `\\u001b[90m${input}\\u001b[39m`\n}\n\n/**\n * Colors a string in bold color (using ANSI escape codes).\n */\nexport function bold(input: string): string {\n return `\\u001b[1m${input}\\u001b[22m`\n}\n\n/**\n * Colors a string in underline color (using ANSI escape codes).\n */\nexport function underline(input: string): string {\n return `\\u001b[4m${input}\\u001b[24m`\n}\n\n/**\n * Colors a string in italic color (using ANSI escape codes).\n */\nexport function italic(input: string): string {\n return `\\u001b[3m${input}\\u001b[23m`\n}\n\n/**\n * Inverts the color of a string (using ANSI escape codes).\n */\nexport function inverse(input: string): string {\n return `\\u001b[7m${input}\\u001b[27m`\n}\n","export function upperFirst(s: string): string {\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nexport function lowerFirst(s: string): string {\n return s.charAt(0).toLowerCase() + s.slice(1)\n}\n\nconst IRREGULAR_PLURALS: [singular: string, plural: string][] = Object.entries({\n abyss: 'abysses',\n aegis: 'aegises',\n alias: 'aliases',\n alumnus: 'alumni',\n amends: 'amends',\n analysis: 'analyses',\n apparatus: 'apparatuses',\n appendix: 'appendices',\n asbestos: 'asbestoses',\n atlas: 'atlases',\n axis: 'axes',\n basis: 'bases',\n biceps: 'bicepses',\n bus: 'buses',\n caress: 'caresses',\n child: 'children',\n children: 'children',\n circus: 'circuses',\n citrus: 'citruses',\n compass: 'compasses',\n crisis: 'crises',\n criterion: 'criteria',\n crocus: 'crocuses',\n data: 'data',\n datum: 'data',\n diabetes: 'diabetes',\n diagnosis: 'diagnoses',\n dross: 'drosses',\n egress: 'egresses',\n elvis: 'elvises',\n emboss: 'embosses',\n fiss: 'fisses',\n focus: 'foci',\n glass: 'glasses',\n hippocampus: 'hippocampi',\n // While `histories` is the plural of `history`, in a model context, `history` makes more sense:\n // If you have a model called `UserHistory`, calling the table `UserHistories` would be confusing.\n history: 'history',\n hypothesis: 'hypotheses',\n ignis: 'ignises',\n index: 'indices',\n iris: 'irises',\n jesus: 'jesuses',\n kudos: 'kudos',\n lens: 'lenses',\n man: 'men',\n matrix: 'matrices',\n medium: 'media',\n news: 'news',\n oasis: 'oases',\n parenthesis: 'parentheses',\n pass: 'passes',\n phenomenon: 'phenomena',\n prognosis: 'prognoses',\n radius: 'radii',\n ras: 'rasses',\n sepsis: 'sepses',\n species: 'species',\n status: 'statuses',\n suffix: 'suffixes',\n syllabus: 'syllabi',\n synopsis: 'synopses',\n thesis: 'theses',\n tress: 'tresses',\n virus: 'viruses',\n vortex: 'vortices',\n woman: 'women',\n})\n\n/**\n * Returns a pluralized version of the given string based on the count.\n */\nexport function pluralize(s: string, count = 2): string {\n // If there's one of something we simply use the singular form.\n if (count === 1) {\n return s\n }\n\n // For plural forms, we first check whether a word is irregular.\n const lower = s.toLowerCase()\n for (const [singular, plural] of IRREGULAR_PLURALS) {\n // We check that items *end with* a given word because we use combined words\n // like `UserHistory` as input values of this function.\n if (lower.endsWith(singular)) {\n return s.slice(0, -singular.length + 1) + plural.slice(1)\n }\n }\n\n if (lower.endsWith('ss')) {\n return s.slice(0, -2) + 'sses'\n }\n if (\n // e.g. index\n lower.endsWith('x') ||\n // e.g. buzz\n lower.endsWith('z') ||\n // e.g. wish\n lower.endsWith('sh') ||\n // e.g. match\n lower.endsWith('ch')\n ) {\n return s + 'es'\n }\n\n if (\n s.endsWith('y') &&\n !s.endsWith('ay') &&\n !s.endsWith('ey') &&\n !s.endsWith('iy') &&\n !s.endsWith('oy') &&\n !s.endsWith('uy')\n ) {\n return s.slice(0, -1) + 'ies'\n }\n\n if (s.endsWith('s')) {\n return s\n }\n\n return s + 's'\n}\n\n/**\n * Returns true if the given string is already pluralized.\n */\nexport function isPlural(s: string): boolean {\n const plural = pluralize(s)\n return plural === s\n}\n\n/**\n * Type modifier that converts all keys of an object to capitalized versions.\n */\nexport type CapitalizedKeys<T extends Record<string, unknown>> = {\n [K in keyof T as CapitalizeFirstLetter<string & K>]: T[K]\n}\n\n/**\n * Type modifier that converts the first letter of a string to a capital letter.\n */\ntype CapitalizeFirstLetter<S extends string> = `${Capitalize<Extract<S, string>>}`\n\n/**\n * Converts all keys of an object to capitalized versions in a type-safe way.\n */\nexport function capitalizeKeys<T extends Record<string, unknown>>(obj: T): CapitalizedKeys<T> {\n const result = {} as CapitalizedKeys<T>\n\n for (const key in obj) {\n const cKey = `${key.charAt(0).toUpperCase()}${key.slice(1)}`\n const cVal = obj[key]\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n result[cKey] = cVal\n }\n\n return result\n}\n\n/**\n * Type modifier that converts all keys of an object to uncapitalized versions.\n */\nexport type UncapitalizedKeys<T extends Record<string, unknown>> = {\n [K in keyof T as UncapitalizeFirstLetter<string & K>]: T[K]\n}\n\n/**\n * Type modifier that converts the first letter of a string to an uncapitalized letter.\n */\ntype UncapitalizeFirstLetter<S extends string> = `${Uncapitalize<Extract<S, string>>}`\n\n/**\n * Converts all keys of an object to uncapitalized versions in a type-safe way.\n */\nexport function uncapitalizeKeys<T extends Record<string, unknown>>(obj: T): UncapitalizedKeys<T> {\n const result = {} as UncapitalizedKeys<T>\n\n for (const key in obj) {\n const unKey = `${key.charAt(0).toLowerCase()}${key.slice(1)}`\n const unVal = obj[key]\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n result[unKey] = unVal\n }\n\n return result\n}\n\n/**\n * Returns the same string with a lowercase first letter.\n */\nexport function uncapitalize(str: string): string {\n return str.charAt(0).toLowerCase() + str.slice(1)\n}\n\n/**\n * Returns the same string with an uppercase first letter.\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1)\n}\n\n/**\n * Returns the camelCase version of the given string.\n *\n * Camel case examples:\n * `toCamelCase('hello world')` -> 'helloWorld',\n * `toCamelCase('hello_world')` -> 'helloWorld',\n * `toCamelCase('helloWorld')` -> 'helloWorld'\n * `toCamelCase('HelloWorld')` -> 'helloWorld'\n * `toCamelCase('hello_world')` -> 'helloWorld'\n */\nexport function toCamelCase(str: string): string {\n if (/^[a-z]+(?:[A-Z][a-z]*)*$/.test(str)) {\n return str\n }\n\n // Split the string into an array of words\n // We split on spaces, underscores, and hyphens.\n // We also split on single uppercase letters, though not on consecutive uppercase letters.\n const words = str.split(/(?<![A-Z])(?=[A-Z])|[\\s_-]+/)\n\n // Convert the first word to lowercase and capitalize the rest\n const camelCasedWords = words\n .map((word) => (word.toUpperCase() === word ? word.toLowerCase() : word))\n .map((word, index) => (index === 0 ? lowerFirst(word) : upperFirst(word)))\n\n // Join the words back together into a single string\n const camelCasedStr = camelCasedWords.join('')\n\n return camelCasedStr\n}\n\n/**\n * Validates if a string is in camelCase format\n */\nexport function isCamelCase(str: string): boolean {\n return str === toCamelCase(str)\n}\n\n/**\n * Returns the PascalCase version of the given string.\n *\n * Examples:\n * `toPascalCase('hello world')` -> 'HelloWorld'\n * `toPascalCase('hello_world')` -> 'HelloWorld'\n * `toPascalCase('helloWorld')` -> 'HelloWorld'\n * `toPascalCase('Hello-World')` -> 'HelloWorld'\n * `toPascalCase('HELLO_WORLD')` -> 'HelloWorld'\n */\nexport function toPascalCase(str: string): string {\n const s = toCamelCase(str)\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\n/**\n * Validates if a string is in PascalCase format\n */\nexport function isPascalCase(str: string): boolean {\n return str === toPascalCase(str)\n}\n\n/**\n * Returns the snake_case version of the given string.\n *\n * Examples:\n * `toSnakeCase('hello world')` -> 'hello_world'\n * `toSnakeCase('helloWorld')` -> 'hello_world'\n * `toSnakeCase('HelloWorld')` -> 'hello_world'\n * `toSnakeCase('HELLO_WORLD')` -> 'hello_world'\n */\nexport function toSnakeCase(str: string): string {\n const camelCase = toCamelCase(str)\n return camelCase.replace(/([A-Z])/g, '_$1').toLowerCase()\n}\n\n/**\n * Validates if a string is in snake_case format\n */\nexport function isSnakeCase(str: string): boolean {\n return str === toSnakeCase(str)\n}\n\n/**\n * Returns the kebab-case version of the given string.\n *\n * Examples:\n * `toKebabCase('hello world')` -> 'hello-world'\n * `toKebabCase('helloWorld')` -> 'hello-world'\n * `toKebabCase('HelloWorld')` -> 'hello-world'\n * `toKebabCase('HELLO_WORLD')` -> 'hello-world'\n */\nexport function toKebabCase(str: string): string {\n const camelCase = toCamelCase(str)\n return camelCase.replaceAll(/([A-Z])/g, '-$1').toLowerCase()\n}\n\n/**\n * Validates if a string is in kebab-case format\n */\nexport function isKebabCase(str: string): boolean {\n return str === toKebabCase(str)\n}\n\n/**\n * Converts each line of a string to a commented line\n */\nexport function commentLines(lines: string): string {\n return lines\n .split('\\n')\n .map((l) => `// ${l}`)\n .join('\\n')\n}\n\nexport function toHumanReadable(input: string): string {\n // Replace underscores and hyphens with spaces\n let result = input.replace(/[_-]/g, ' ')\n\n // Add spaces before capital letters\n result = result.replace(/([a-z])([A-Z])/g, '$1 $2')\n\n //In case the string was already human readable, return it\n if (result === input) {\n return input\n }\n\n //lowercase the first letter of every word\n result = result\n .split(' ')\n .map((s) => s.toLowerCase())\n .join(' ')\n\n // Capitalize the first letter of the resulting string\n result = upperFirst(result)\n\n return result\n}\n\n/**\n * Sanitizes a string to be a valid Excel ListObject (table) column name.\n * - Removes illegal characters: [ ] : ? * / \\\n * - Trims leading/trailing spaces\n * - Replaces multiple spaces with a single space\n * - If the result is empty, returns a default name\n */\nexport function toExcelColumnName(input: string, defaultName = 'Column1'): string {\n // Remove illegal characters: [ ] : ? * / \\\n let result = input.replace(/[[\\]:?*/\\\\]/g, '')\n\n // Replace multiple spaces with a single space\n result = result.replace(/\\s+/g, ' ')\n\n // Trim leading/trailing spaces\n result = result.trim()\n\n // If the result is empty, return the default name\n if (!result) {\n return toExcelColumnName(defaultName, 'Column1')\n }\n\n return result\n}\n\n/**\n * Sanitizes a string to be a valid Excel ListObject (table) name.\n * - Must start with a letter, underscore, or backslash\n * - Only letters, numbers, and underscores allowed (no spaces or punctuation)\n * - Cannot be a cell reference (e.g., \"A1\")\n * - Max 255 characters\n * - If invalid or empty, returns a default name\n */\nexport function toExcelTableName(input: string, defaultName = 'Table1'): string {\n // Remove all characters except letters, numbers, and underscores\n let result = input.replace(/[^A-Za-z0-9_\\\\]/g, '')\n\n // Ensure the name starts with a letter, underscore, or backslash\n if (!/^[A-Za-z_\\\\]/.test(result)) {\n result = '_' + result\n }\n\n // Truncate to 255 characters\n result = result.slice(0, 255)\n\n // Avoid names that look like cell references (e.g., \"A1\", \"AA100\")\n if (/^[A-Za-z]{1,3}[1-9][0-9]{0,6}$/.test(result)) {\n result = '_' + result\n }\n\n // If the result is empty, use the default name\n if (!result || result === '_') {\n return toExcelTableName(defaultName, 'Table1')\n }\n\n return result\n}\n\nexport type Conjugated = {\n camelCase: string\n camelCasePlural: string\n capitalized: string\n capitalizedPlural: string\n kebabCase: string\n kebabCasePlural: string\n PascalCase: string\n PascalCasePlural: string\n pluralized: string\n snake_case_plural: string\n snake_case: string\n uncapitalized: string\n uncapitalizedPlural: string\n}\n\n/**\n * Provide all relevant conjugation of a name\n */\nexport function conjugateNames(name: string): Conjugated {\n const plural = pluralize(name)\n return {\n camelCase: toCamelCase(name),\n camelCasePlural: toCamelCase(plural),\n capitalized: capitalize(name),\n capitalizedPlural: capitalize(plural),\n kebabCase: toKebabCase(name),\n kebabCasePlural: toKebabCase(plural),\n PascalCase: toPascalCase(name),\n PascalCasePlural: toPascalCase(plural),\n pluralized: capitalize(plural),\n snake_case_plural: toSnakeCase(plural),\n snake_case: toSnakeCase(name),\n uncapitalized: uncapitalize(name),\n uncapitalizedPlural: uncapitalize(plural),\n }\n}\n\nexport function slugify(str: string): string {\n return (\n str\n // replace uppercase letters with hyphens and letter (will be lowercased later)\n .replace(/([A-Z])/g, '-$1')\n .toLowerCase()\n // replace letter followed by number with letter-number\n .replace(/([a-z])(\\d)/g, '$1-$2')\n // replace non-alphanumeric characters with hyphens\n .replace(/[^a-z0-9]+/g, '-')\n // remove leading hyphens\n .replace(/^-/g, '')\n // remove trailing hyphens\n .replace(/-$/g, '')\n // replace multiple hyphens with a single hyphen\n .replace(/-+/g, '-')\n )\n}\n\nexport function isSlug(str: string): boolean {\n return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(str)\n}\n\n/**\n * Ensures that a string is unique within a list of existing values by appending a sequential number if necessary.\n *\n * If the base string is not in the list, it is returned as is.\n * If it is, the function looks for existing strings in the format \"base (n)\" where n is a number,\n * and returns the next available sequential string.\n *\n * @param value - The base string to ensure uniqueness for.\n * @param existingValues - An array of existing strings to check against.\n * @param maxChecks - Maximum number of checks to be performed. An error is thrown if this limit is exceeded. Default is 100\n * @returns A unique string based on the base string.\n */\nexport const ensureUnique = (value: string, existingValues: string[], maxChecks = 100): string => {\n // convert existingValues to a Set for faster lookup\n const values = new Set(existingValues)\n\n // if the base itself (without a number) is not in the list, return it\n if (!values.has(value)) {\n return value\n }\n\n let base = value.trim()\n let num = 0\n\n // Regex to match a numeric suffix like \" (n)\" at the end of the string.\n // Using a targeted pattern avoids catastrophic backtracking for inputs without such a suffix.\n const m = /\\((\\d{1,5})\\)$/.exec(value)\n if (m && /\\s$/.test(value.slice(0, m.index))) {\n base = value.slice(0, m.index).trimEnd()\n }\n\n while (num < maxChecks) {\n const newValue = num === 0 ? base : `${base} (${num})`\n if (!values.has(newValue)) {\n return newValue\n }\n num++\n }\n throw new Error(`Could not find a unique name for \"${value}\" after ${maxChecks} checks`)\n}\n","// Source: https://stackoverflow.com/a/53229857/1867581\ntype Without<T, U> = Partial<Record<Exclude<keyof T, keyof U>, never>>\nexport type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U\n\n// Source: see workaround in https://github.com/Microsoft/TypeScript/issues/12936#issuecomment-1061725873\nexport type Exact<T, I> = T extends I ? (Exclude<keyof T, keyof I> extends never ? T : never) : never\n\nexport type UncapitalizeObjectKeys<T> = {\n [key in keyof T as Uncapitalize<key & string>]: T[key]\n}\n// Source: https://twitter.com/mattpocockuk/status/1622730173446557697\nexport type Prettify<T> = {\n [K in keyof T]: T[K]\n}\n\n/**\n * Distributive Pick - does not collapse unions into a \"shared type\" only to\n * run Pick on it. Instead, it \"picks\" from each union item separately.\n *\n * See https://github.com/klimashkin/css-modules-theme/pull/8\n *\n * Example:\n * Pick<{ type: \"pick\" } | { type: \"omit\" }, \"type\">\n * produces { type: \"pick\" | \"omit\" }\n *\n * UnionPick<{ type: \"pick\" } | { type: \"omit\" }, \"type\">\n * produces { type: \"pick\" } | { type: \"omit\" }\n */\nexport type UnionPick<T, K extends keyof T> = T extends unknown ? Pick<T, K> : never\n\n/**\n * Like UnionPick, but for Omit\n */\nexport type UnionOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never\n\n/**\n * Makes a type check that is only valid when all cases of a switch\n * statement have been covered.\n */\nexport class ExhaustiveSwitchCheck extends Error {\n constructor(val: never) {\n super(`Unreachable case: ${JSON.stringify(val)}`)\n }\n}\n\n/**\n * A type that represents an array that is guaranteed to have at least one element.\n */\nexport type NonEmptyArray<T> = [T, ...T[]]\n\n/**\n * Converts a nested object to a nested object where all properties are optional.\n */\nexport type DeepPartial<T> = T extends object\n ? {\n [P in keyof T]?: DeepPartial<T[P]>\n }\n : T\n\n/**\n * Changes properties of an object type to optional.\n *\n * Example:\n * type Foo = { a: string, b: number, c: boolean }\n * type Bar = Optional<Foo, 'a' | 'b'>\n * // Bar is { a?: string, b?: number, c: boolean }\n */\nexport type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\n\n/**\n * Allows inline type assertions.\n *\n * Example:\n * ```\n * type Original = { a: number }\n * type WithExtra = Original & { b: string }\n *\n * function addExtra(obj: Original): asserts obj is WithExtra {\n * assertType(obj)\n * obj.b = 'new value' // ✅ No TypeScript error!\n * }\n * ```\n */\nexport function assertType<T>(value: unknown): asserts value is T {\n return value as any\n}\n\n/**\n * Applies a type assertion to an entire array and hence asserts the array.\n *\n * Type assertions are especially useful when you want to modify and object in place - a function\n * with a type assertion lets TypeScript know that the object was modified.\n *\n * Example:\n * ```\n * type Original = { a: number }\n * type WithExtra = Original & { b: string }\n *\n * function addExtra(obj: Original): asserts obj is WithExtra {\n * obj.b = 'new value'\n * }\n *\n * const myObj: Original[] = [{ a: 1 }]\n * console.log(myObj[0].b) // ❌ TypeScript error!\n * assertArray(myObj, addExtra)\n * console.log(myObj[0].b) // ✅ No TypeScript error!\n * ```\n */\nexport function assertArray<I, O extends I>(obj: I[], fn: (i: I) => asserts i is O): asserts obj is O[] {\n obj.forEach(fn)\n}\n\n/**\n * Converts any branded string type to its underlying string type.\n */\nexport type Debrand<T> = T extends string & infer _U ? string : T extends object ? { [K in keyof T]: Debrand<T[K]> } : T\n","export function uniq<T>(items: T[], predicate: (item: T) => number): T[] {\n const result: T[] = []\n const seen: Record<string, true> = {}\n\n for (const item of items) {\n const key = predicate(item)\n\n if (!seen[key]) {\n seen[key] = true\n result.push(item)\n }\n }\n\n return result\n}\n","import { z } from 'zod'\n\nexport type Transformer<Input, Output> = (value: Input, ctx: z.RefinementCtx) => Output | z.ZodNever\n\ntype ReturnTypeOfLast<T extends any[]> = T extends [...any, infer L]\n ? L extends (...args: any) => any\n ? ReturnType<L>\n : never\n : never\n\n/**\n * Pipes a list of Zod transformers together in a type-safe way. Returns early if any of the transformers returns `z.NEVER`.\n */\nexport function pipeZodTransformers<Initial, Fns extends [Transformer<any, any>, ...Transformer<any, any>[]]>(\n initialValue: Initial,\n ctx: z.RefinementCtx,\n fns: Fns,\n): ReturnTypeOfLast<Fns> {\n let result: any = initialValue\n for (const fn of fns) {\n result = fn(result, ctx)\n if (result === z.NEVER) {\n return z.NEVER\n }\n }\n return result\n}\n\n/**\n * Returns a Zod error map that returns the given message for union errors.\n *\n * This is useful for generating meaningful error messages for unions, e.g.\n * ```\n * z.union(\n * [z.constant('foo'), z.constant('bar')],\n * unionErrorMessage('Value must be either \"foo\" or \"bar\"!')\n * )\n * ```\n *\n * In addition to a static message, you can also pass a function that takes the\n * invalid data as input and returns a string. Example:\n * ```\n * z.union(\n * [z.constant('foo'), z.constant('bar')],\n * unionErrorMessage((data) => `Value must be either \"foo\" or \"bar\" - received ${JSON.stringify(data)} instead!`)\n * )\n * ```\n */\nexport function unionErrorMessage(param: string | ((data: any) => string)): z.RawCreateParams {\n return {\n errorMap: (issue, ctx) => {\n let message: string\n if (typeof param === 'string') {\n message = param\n } else {\n message = param(ctx.data)\n }\n\n if (issue.code === z.ZodIssueCode.invalid_union) {\n return { message }\n }\n return { message: ctx.defaultError }\n },\n }\n}\n","import z from 'zod'\n\nimport { isDate } from './datetime'\n\n/**\n * Transformer that verifies that the number is an integer\n */\nconst intValidator = (x: number, ctx: z.RefinementCtx): number => {\n if (x % 1 !== 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Not an integer: ${x}`,\n })\n return z.NEVER\n }\n return x\n}\n\n/**\n * Converts any transformer to a nullable transformer, i.e. if the input is\n * null or undefined, the output will be nullable. Else the original transformer\n * is applied\n */\nconst nullableTransformer =\n <I, O>(transformer: (x: I, ctx: z.RefinementCtx) => O) =>\n (x: I | undefined | null, ctx: z.RefinementCtx): O | null => {\n if (x === null || x === undefined || (typeof x === 'string' && x === '')) {\n return null\n }\n return transformer(x, ctx)\n }\n\n/**\n * A decoder that transforms Excel strings to JS strings, also handling numbers and boolean. Will not parse any other type!\n *\n * Background: In Excel, entering a number in a cell will automatically convert it to a number -\n * and xlPort will return it as a number. However, often we want to treat it as a string - this decoder\n * hence accepts both strings and numbers, and converts numbers to strings.\n *\n * It'll perform casting based on the following rules:\n * - If the value is a number, it'll be converted to a string\n * - If the value is a string, it'll be returned as-is\n * - If the value is boolean, it'll return 'true' or 'false'\n *\n * Any other type will throw an error!\n */\nexport const excelStringStrictDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>,\n string,\n string | number | boolean // NOSONAR\n> = z.union([z.string(), z.number(), z.boolean()]).transform((x: string | number | boolean): string => {\n if (typeof x === 'number') {\n return x.toString()\n }\n if (typeof x === 'boolean') {\n return x ? 'true' : 'false'\n }\n return x\n})\n\n/**\n * A decoder that transforms Excel strings to JS strings, also handling numbers and any other potential type\n *\n * Background: In Excel, entering a number in a cell will automatically convert it to a number -\n * and xlPort will return it as a number. However, often we want to treat it as a string - this decoder\n * hence accepts both strings and numbers, and converts numbers to strings.\n *\n * It'll perform casting based on the following rules:\n * - If the value is a number, it'll be converted to a string\n * - If the value is a string, it'll be returned as-is\n * - If the value is boolean, it'll return 'true' or 'false'\n * - If the value is null or undefined, it'll return an empty string\n * - If the value is any other type, it'll return an empty string\n *\n * Null handling: Null values/blank cells will be converted to a blank string.\n */\nexport const excelStringDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodUndefined, z.ZodAny]>,\n string,\n any\n> = z.union([z.string(), z.number(), z.boolean(), z.null(), z.undefined(), z.any()]).transform((x): string => {\n if (x === null || x === undefined) {\n return ''\n }\n if (typeof x === 'number') {\n return x.toString()\n }\n if (typeof x === 'boolean') {\n return x ? 'true' : 'false'\n }\n if (typeof x === 'string') {\n return x\n }\n return ''\n})\n\n/**\n * A decoder that transforms Excel strings to JS strings, also handling numbers and null\n *\n * Background: In Excel, entering a number in a cell will automatically convert it to a number -\n * and xlPort will return it as a number. However, often we want to treat it as a string - this decoder\n * hence accepts both strings and numbers, and converts numbers to strings.\n *\n * It'll perform casting based on the following rules:\n * - If the value is a number, it'll be converted to a string\n * - If the value is a string, it'll be returned as-is - except blank strings, which will be converted to null\n * - If the value is boolean, it'll return 'true' or 'false'\n * - If the value is null or undefined, it'll return null\n * - If the value is any other type, it'll return null\n *\n * Null handling: Blank strings will be converted to null. This is to reflect that in Excel a formula\n * cannot return null. As a workaround, one often returns a blank string to represent null.\n */\nexport const excelStringNullableDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodUndefined, z.ZodAny]>,\n string | null,\n any\n> = z.union([z.string(), z.number(), z.boolean(), z.null(), z.undefined(), z.any()]).transform((x) => {\n if (x === null || x === undefined) {\n return null\n }\n if (typeof x === 'number') {\n return x.toString()\n }\n if (typeof x === 'boolean') {\n return x ? 'true' : 'false'\n }\n if (typeof x === 'string') {\n if (x === '') {\n return null\n }\n return x\n }\n return null\n})\n\nconst excelNumberTransformer = (x: any): number | null => {\n if (typeof x === 'string') {\n if (x.trim() === '') {\n return null\n }\n const parsed = parseFloat(x)\n if (Number.isNaN(parsed)) {\n return null\n }\n return parsed\n }\n if (typeof x === 'boolean') {\n return x ? 1 : 0\n }\n if (typeof x === 'number') {\n return x\n }\n\n return null\n}\n/**\n * A decoder that transforms Excel numbers to JS numbers, also handling strings and boolean. Will not parse any other type!\n *\n * It'll perform casting based on the following rules:\n * - If the value is a number, it'll be returned as-is\n * - If the value is a string, it'll try to parse it to a number. Blank strings will be converted to 0. Non-numeric strings will throw an error.\n * - If the value is boolean, it'll return 1 or 0\n * - If the value is any other type, it'll throw an error\n *\n */\nexport const excelNumberStrictDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>,\n number,\n string | number | boolean\n> = z.union([z.string(), z.number(), z.boolean()]).transform((x, ctx): number => {\n const result = excelNumberTransformer(x)\n if (result === null) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Not a number: ${x}`,\n })\n return z.NEVER\n }\n return result\n})\n\n/**\n * A decoder that transforms Excel numbers to JS numbers, also handling strings, boolean and other types.\n *\n * It'll perform casting based on the following rules:\n * - If the value is a number, it'll be returned as-is\n * - If the value is a string, it'll try to parse it to a number. Blank strings and non-numerical strings will be converted to 0.\n * - If the value is boolean, it'll return 1 or 0\n * - If the value is any other type, it'll return 0\n *\n * Null handling: Null values/blank cells will be converted to blank strings.\n */\nexport const excelNumberDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodUndefined, z.ZodAny]>,\n number,\n any\n> = z.union([z.string(), z.number(), z.boolean(), z.null(), z.undefined(), z.any()]).transform((x): number => {\n const result = excelNumberTransformer(x)\n if (result === null) {\n return 0\n }\n return result\n})\n\n/**\n * A decoder that transforms Excel numbers to JS numbers, also handling strings, boolean and other types.\n \n * It'll perform casting based on the following rules:\n * - If the value is a number, it'll be returned as-is\n * - If the value is a string, it'll try to parse it to a number. Non-numerical and blank strings will be converted to null\n * - If the value is boolean, it'll return 1 or 0\n * - If the value is any other type, it'll return null\n * \n * Null handling: Blank strings will be converted to null. This is to reflect that in Excel a formula\n * cannot return null. As a workaround, one often returns a blank string to represent null.\n */\nexport const excelNumberNullableDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodString, z.ZodNull, z.ZodNumber, z.ZodUndefined, z.ZodAny]>,\n number | null,\n any\n> = z.union([z.string(), z.null(), z.number(), z.undefined(), z.any()]).transform(excelNumberTransformer)\n\n/**\n * A decoder that transforms Excel numbers to JS integers, also handling strings and boolean. Other types will throw an error.\n *\n * If the number is not an integer, an error will be thrown.\n */\nexport const excelIntStrictDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, number, string | number | boolean>,\n number,\n string | number | boolean\n> = excelNumberStrictDecoder.transform(intValidator)\n\n/**\n * A decoder that transforms Excel numbers to JS integers, also handling strings and boolean. Other types will be converted to 0.\n *\n * If the number is not an integer, an error will be thrown.\n */\nexport const excelIntDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodUndefined, z.ZodAny]>, number, any>,\n number,\n any\n> = excelNumberDecoder.transform(intValidator)\n\n/**\n * A decoder that transforms Excel numbers to JS integers, also handling strings and boolean. Other types will be converted to null.\n *\n * If the number is not an integer, an error will be thrown.\n */\nexport const excelIntNullableDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNull, z.ZodNumber, z.ZodUndefined, z.ZodAny]>, number | null, any>,\n number | null,\n any\n> = excelNumberNullableDecoder.transform(nullableTransformer(intValidator))\n\n// TODO: Add BigInt tests (to be investigated, how Excel handles BigInts)\nconst bigIntTransformer = (x: number, ctx: z.RefinementCtx): bigint => {\n if (x % 1 !== 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Not an integer: ${x}`,\n })\n return z.NEVER\n }\n return BigInt(x)\n}\n\n/**\n * A decoder that transforms Excel numbers to JS BigInts, also handling strings and boolean. Other types will throw an error.\n *\n * If the number is not a (big) integer, an error will be thrown.\n */\nexport const excelBigIntStrictDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, number, string | number | boolean>,\n bigint,\n string | number | boolean\n> = excelNumberStrictDecoder.transform(bigIntTransformer)\n\n/**\n * A decoder that transforms Excel numbers to JS BigInts, also handling strings and boolean. Other types will be converted to 0.\n *\n * If the number is not a (big) integer, an error will be thrown.\n */\nexport const excelBigIntDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodUndefined, z.ZodAny]>, number, any>,\n bigint,\n any\n> = excelNumberDecoder.transform(bigIntTransformer)\n\n/**\n * A decoder that transforms Excel numbers to JS BigInts, also handling strings and boolean. Other types will be converted to null.\n *\n * If the number is not a (big) integer, an error will be thrown.\n */\nexport const excelBigIntNullableDecoder: z.ZodEffects<\n z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNull, z.ZodNumber, z.ZodUndefined, z.ZodAny]>, number | null, any>,\n bigint | null,\n any\n> = excelNumberNullableDecoder.transform(nullableTransformer(bigIntTransformer))\n\nconst excelBooleanNullableTransformer = (x: any): boolean | null => {\n if (typeof x === 'number') {\n return x !== 0\n }\n\n if (typeof x === 'string') {\n switch (x.toLowerCase()) {\n case 'true':\n case '1':\n return true\n case 'false':\n case '0':\n return false\n default:\n return null\n }\n }\n\n if (typeof x === 'boolean') {\n return x\n }\n\n return null\n}\n\n/**\n * A decoder that transforms Excel booleans to JS booleans, also handling numbers and strings.\n *\n * It'll perform casting based on the following rules:\n * - If the value is a number, it'll return true if it's not 0\n * - If the value is a string, it'll return true if it's 'true' or '1', false if it's 'false' or '0', and throw an error otherwise\n * - If the value is boolean, it'll return it as-is\n * - If the value is any other type, it'll throw an error\n */\nexport const excelBooleanStrictDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodBoolean, z.ZodNumber, z.ZodString]>,\n boolean,\n string | number | boolean\n> = z.union([z.boolean(), z.number(), z.string()]).transform((x, ctx): boolean => {\n const result = excelBooleanNullableTransformer(x)\n if (result === null) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Not a boolean: ${x}`,\n })\n return z.NEVER\n }\n\n return result\n})\n\n/**\n * A decoder that transforms Excel booleans to JS booleans, also handling numbers and strings.\n *\n * It'll perform casting based on the following rules:\n * - If the value is a number, it'll return true if it's not 0\n * - If the value is a string, it'll return true if it's 'true' or '1', false otherwise\n * - If the value is boolean, it'll return it as-is\n * - If the value is any other type, it'll return false\n */\nexport const excelBooleanDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodBoolean, z.ZodNumber, z.ZodNull, z.ZodString, z.ZodUndefined, z.ZodAny]>,\n boolean,\n any\n> = z.union([z.boolean(), z.number(), z.null(), z.string(), z.undefined(), z.any()]).transform((x) => {\n const result = excelBooleanNullableTransformer(x)\n if (result === null) {\n return false\n }\n\n return result\n})\n\n/**\n * A decoder that transforms Excel booleans to JS booleans, also handling numbers and strings.\n *\n * It'll perform casting based on the following rules:\n * - If the value is a number, it'll return true if it's not 0\n * - If the value is a string, it'll return true if it's 'true' or '1', false if it's 'false' or '0', and null otherwise\n * - If the value is boolean, it'll return it as-is\n * - If the value is any other type, it'll return null\n */\nexport const excelBooleanNullableDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodBoolean, z.ZodNumber, z.ZodNull, z.ZodString, z.ZodUndefined, z.ZodAny]>,\n boolean | null,\n any\n> = z\n .union([z.boolean(), z.number(), z.null(), z.string(), z.undefined(), z.any()])\n .transform(excelBooleanNullableTransformer)\n\nconst excelDateNullableTransformer = (x: any, ctx: z.RefinementCtx): Date | null => {\n if (x === null || x === undefined) {\n return null\n }\n\n if (isDate(x)) {\n return x\n }\n\n if (typeof x === 'number') {\n // Excel number is a float with 1 representing Jan 1, 1900. Each increment is a day.\n // As Excel incorrectly ignores the 1900 leap year, we need to correct for that\n const date = new Date(Date.UTC(1900, 0, 1))\n date.setUTCDate(date.getDate() + x - 2)\n\n const fractionalDay = x - Math.floor(x)\n date.setMilliseconds(date.getMilliseconds() + fractionalDay * 24 * 60 * 60 * 1000)\n\n return date\n }\n\n if (typeof x === 'string') {\n if (typeof x === 'string' && x.trim() === '') {\n return null\n }\n const result = new Date(x)\n if (Number.isNaN(result.getTime())) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Not a date: ${x}`,\n })\n return z.NEVER\n }\n return result\n }\n return null\n}\n\n/**\n * A decoder that transforms Excel dates to JS Dates\n */\nexport const excelDateDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodDate, z.ZodNumber, z.ZodString]>,\n Date,\n string | number | Date\n> = z.union([z.date(), z.number(), z.string()]).transform((x, ctx) => {\n const result = excelDateNullableTransformer(x, ctx)\n if (result === null) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Not a date: ${x.toString()}`,\n })\n return z.NEVER\n }\n return result\n})\n\n/**\n * A decoder that transforms nullable Excel dates to JS Dates\n */\nexport const excelDateNullableDecoder: z.ZodEffects<\n z.ZodUnion<[z.ZodDate, z.ZodString, z.ZodNumber, z.ZodNull, z.ZodUndefined, z.ZodAny]>,\n Date | null,\n any\n> = z\n .union([z.date(), z.string(), z.number(), z.null(), z.undefined(), z.any()])\n .transform(excelDateNullableTransformer)\n"],"mappings":";;;;;;AAGA,IAAa,aAAb,cAA4C,IAAgB;;;;CAK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