@alextheman/utility 4.14.0 → 4.15.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.
package/dist/index.cjs CHANGED
@@ -110,7 +110,7 @@ const httpErrorCodeLookup = {
110
110
  *
111
111
  * @category Types
112
112
  */
113
- var APIError = class extends Error {
113
+ var APIError = class APIError extends Error {
114
114
  status;
115
115
  /**
116
116
  * @param status - A HTTP status code. Can be any number, but numbers between 400 and 600 are encouraged to fit with HTTP status code conventions.
@@ -133,6 +133,7 @@ var APIError = class extends Error {
133
133
  * @returns `true` if the input is an APIError, and `false` otherwise. The type of the input will also be narrowed down to APIError if `true`.
134
134
  */
135
135
  static check(input) {
136
+ if (input instanceof APIError) return true;
136
137
  const data = input;
137
138
  return typeof data === "object" && data !== null && typeof data?.status === "number" && typeof data?.message === "string";
138
139
  }
@@ -145,7 +146,7 @@ var APIError = class extends Error {
145
146
  *
146
147
  * @category Types
147
148
  */
148
- var DataError = class extends Error {
149
+ var DataError = class DataError extends Error {
149
150
  code;
150
151
  data;
151
152
  /**
@@ -171,6 +172,7 @@ var DataError = class extends Error {
171
172
  * @returns `true` if the input is a DataError, and `false` otherwise. The type of the input will also be narrowed down to DataError if `true`.
172
173
  */
173
174
  static check(input) {
175
+ if (input instanceof DataError) return true;
174
176
  const data = input;
175
177
  return typeof data === "object" && data !== null && typeof data.message === "string" && typeof data.code === "string" && "data" in data;
176
178
  }
@@ -304,6 +306,17 @@ var VersionNumber = class VersionNumber {
304
306
  return VersionNumber.formatString(rawString, options);
305
307
  }
306
308
  };
309
+ const zodVersionNumber = zod.default.union([
310
+ zod.default.string(),
311
+ zod.default.tuple([
312
+ zod.default.number(),
313
+ zod.default.number(),
314
+ zod.default.number()
315
+ ]),
316
+ zod.default.instanceof(VersionNumber)
317
+ ]).transform((rawVersionNumber) => {
318
+ return new VersionNumber(rawVersionNumber);
319
+ });
307
320
 
308
321
  //#endregion
309
322
  //#region src/functions/parsers/parseIntStrict.ts
@@ -1775,4 +1788,5 @@ exports.sayHello = sayHello;
1775
1788
  exports.stringListToArray = stringListToArray;
1776
1789
  exports.stringifyDotenv = stringifyDotenv;
1777
1790
  exports.truncate = truncate;
1778
- exports.wait = wait;
1791
+ exports.wait = wait;
1792
+ exports.zodVersionNumber = zodVersionNumber;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
+ import z, { ZodError, ZodType, z as z$1 } from "zod";
1
2
  import { DotenvParseOutput } from "dotenv";
2
- import { ZodError, ZodType, z } from "zod";
3
3
  import sodium from "libsodium-wrappers";
4
4
 
5
5
  //#region src/constants/FILE_PATH_REGEX.d.ts
@@ -334,6 +334,7 @@ declare class VersionNumber {
334
334
  */
335
335
  toString(options?: VersionNumberToStringOptions): string;
336
336
  }
337
+ declare const zodVersionNumber: z.ZodType<VersionNumber>;
337
338
  //#endregion
338
339
  //#region src/types/ArrayElement.d.ts
339
340
  /**
@@ -747,7 +748,7 @@ declare function parseVersionType(data: unknown): VersionType;
747
748
  *
748
749
  * @returns The parsed data from the Zod schema.
749
750
  */
750
- declare function parseZodSchema<SchemaType extends ZodType, ErrorType extends Error>(schema: SchemaType, data: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): z.infer<SchemaType>;
751
+ declare function parseZodSchema<SchemaType extends ZodType, ErrorType extends Error>(schema: SchemaType, data: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): z$1.infer<SchemaType>;
751
752
  //#endregion
752
753
  //#region src/functions/parsers/zod/parseZodSchemaAsync.d.ts
753
754
  /**
@@ -766,7 +767,7 @@ declare function parseZodSchema<SchemaType extends ZodType, ErrorType extends Er
766
767
  *
767
768
  * @returns The parsed data from the Zod schema.
768
769
  */
769
- declare function parseZodSchemaAsync<SchemaType extends ZodType, ErrorType extends Error>(schema: SchemaType, data: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): Promise<z.infer<SchemaType>>;
770
+ declare function parseZodSchemaAsync<SchemaType extends ZodType, ErrorType extends Error>(schema: SchemaType, data: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): Promise<z$1.infer<SchemaType>>;
770
771
  //#endregion
771
772
  //#region src/functions/recursive/deepCopy.d.ts
772
773
  /**
@@ -1223,4 +1224,4 @@ interface ParseVersionOptions {
1223
1224
  */
1224
1225
  declare function parseVersion(input: string, options?: ParseVersionOptions): string;
1225
1226
  //#endregion
1226
- export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, ParseVersionOptions, PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait };
1227
+ export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, ParseVersionOptions, PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ZodError, ZodType, z as z$1 } from "zod";
1
+ import z, { ZodError, ZodType, z as z$1 } from "zod";
2
2
  import sodium from "libsodium-wrappers";
3
3
  import { DotenvParseOutput } from "dotenv";
4
4
 
@@ -334,6 +334,7 @@ declare class VersionNumber {
334
334
  */
335
335
  toString(options?: VersionNumberToStringOptions): string;
336
336
  }
337
+ declare const zodVersionNumber: z.ZodType<VersionNumber>;
337
338
  //#endregion
338
339
  //#region src/types/ArrayElement.d.ts
339
340
  /**
@@ -1223,4 +1224,4 @@ interface ParseVersionOptions {
1223
1224
  */
1224
1225
  declare function parseVersion(input: string, options?: ParseVersionOptions): string;
1225
1226
  //#endregion
1226
- export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, type ParseVersionOptions, type PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait };
1227
+ export { APIError, type ArrayElement, type CallReturnType, CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type OptionalOnCondition, ParallelTuple, type ParseVersionOptions, type PublicAndPrivateKey, type RecordKey, type RemoveUndefined, type StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, type VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
package/dist/index.js CHANGED
@@ -79,7 +79,7 @@ const httpErrorCodeLookup = {
79
79
  *
80
80
  * @category Types
81
81
  */
82
- var APIError = class extends Error {
82
+ var APIError = class APIError extends Error {
83
83
  status;
84
84
  /**
85
85
  * @param status - A HTTP status code. Can be any number, but numbers between 400 and 600 are encouraged to fit with HTTP status code conventions.
@@ -102,6 +102,7 @@ var APIError = class extends Error {
102
102
  * @returns `true` if the input is an APIError, and `false` otherwise. The type of the input will also be narrowed down to APIError if `true`.
103
103
  */
104
104
  static check(input) {
105
+ if (input instanceof APIError) return true;
105
106
  const data = input;
106
107
  return typeof data === "object" && data !== null && typeof data?.status === "number" && typeof data?.message === "string";
107
108
  }
@@ -114,7 +115,7 @@ var APIError = class extends Error {
114
115
  *
115
116
  * @category Types
116
117
  */
117
- var DataError = class extends Error {
118
+ var DataError = class DataError extends Error {
118
119
  code;
119
120
  data;
120
121
  /**
@@ -140,6 +141,7 @@ var DataError = class extends Error {
140
141
  * @returns `true` if the input is a DataError, and `false` otherwise. The type of the input will also be narrowed down to DataError if `true`.
141
142
  */
142
143
  static check(input) {
144
+ if (input instanceof DataError) return true;
143
145
  const data = input;
144
146
  return typeof data === "object" && data !== null && typeof data.message === "string" && typeof data.code === "string" && "data" in data;
145
147
  }
@@ -273,6 +275,17 @@ var VersionNumber = class VersionNumber {
273
275
  return VersionNumber.formatString(rawString, options);
274
276
  }
275
277
  };
278
+ const zodVersionNumber = z.union([
279
+ z.string(),
280
+ z.tuple([
281
+ z.number(),
282
+ z.number(),
283
+ z.number()
284
+ ]),
285
+ z.instanceof(VersionNumber)
286
+ ]).transform((rawVersionNumber) => {
287
+ return new VersionNumber(rawVersionNumber);
288
+ });
276
289
 
277
290
  //#endregion
278
291
  //#region src/functions/parsers/parseIntStrict.ts
@@ -1684,4 +1697,4 @@ function incrementVersion(version, incrementType, options) {
1684
1697
  }
1685
1698
 
1686
1699
  //#endregion
1687
- export { APIError, DataError, Env, FILE_PATH_REGEX, NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX, VersionNumber, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait };
1700
+ export { APIError, DataError, Env, FILE_PATH_REGEX, NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX, VersionNumber, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "4.14.0",
3
+ "version": "4.15.0",
4
4
  "description": "Helpful utility functions.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,12 +21,11 @@
21
21
  "zod": "^4.3.6"
22
22
  },
23
23
  "devDependencies": {
24
- "@alextheman/eslint-plugin": "^5.5.2",
24
+ "@alextheman/eslint-plugin": "^5.6.1",
25
25
  "@types/node": "^25.2.1",
26
- "@typescript-eslint/types": "^8.54.0",
27
26
  "alex-c-line": "^1.23.1",
28
27
  "dotenv-cli": "^11.0.0",
29
- "eslint": "^9.39.2",
28
+ "eslint": "^10.0.0",
30
29
  "execa": "^9.6.1",
31
30
  "globals": "^17.3.0",
32
31
  "husky": "^9.1.7",