@alextheman/utility 5.23.0 → 5.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -8
- package/dist/index.js +14 -14
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import z
|
|
1
|
+
import z, { ZodCoercedDate, ZodCoercedNumber, ZodError, ZodType, z as z$1 } from "zod";
|
|
2
2
|
import { DotenvParseOutput } from "dotenv";
|
|
3
3
|
|
|
4
4
|
//#region src/root/constants/FILE_PATH_REGEX.d.ts
|
|
@@ -550,7 +550,7 @@ declare class VersionNumber {
|
|
|
550
550
|
*/
|
|
551
551
|
toString(): string;
|
|
552
552
|
}
|
|
553
|
-
declare const zodVersionNumber: z
|
|
553
|
+
declare const zodVersionNumber: z.ZodType<VersionNumber>;
|
|
554
554
|
//#endregion
|
|
555
555
|
//#region src/root/types/ArrayElement.d.ts
|
|
556
556
|
/**
|
|
@@ -1439,7 +1439,7 @@ declare class DataError$1<DataType extends object = Record<PropertyKey, unknown>
|
|
|
1439
1439
|
*
|
|
1440
1440
|
* @returns The parsed data from the Zod schema.
|
|
1441
1441
|
*/
|
|
1442
|
-
declare function parseZodSchema<SchemaType extends ZodType, ErrorType extends Error = DataError$1>(schema: SchemaType, input: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): z.infer<SchemaType>;
|
|
1442
|
+
declare function parseZodSchema<SchemaType extends ZodType, ErrorType extends Error = DataError$1>(schema: SchemaType, input: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): z$1.infer<SchemaType>;
|
|
1443
1443
|
//#endregion
|
|
1444
1444
|
//#region src/root/zod/parseZodSchemaAsync.d.ts
|
|
1445
1445
|
/**
|
|
@@ -1460,10 +1460,10 @@ declare function parseZodSchema<SchemaType extends ZodType, ErrorType extends Er
|
|
|
1460
1460
|
*
|
|
1461
1461
|
* @returns The parsed data from the Zod schema.
|
|
1462
1462
|
*/
|
|
1463
|
-
declare function parseZodSchemaAsync<SchemaType extends ZodType, ErrorType extends Error = DataError$1>(schema: SchemaType, input: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): Promise<z.infer<SchemaType>>;
|
|
1463
|
+
declare function parseZodSchemaAsync<SchemaType extends ZodType, ErrorType extends Error = DataError$1>(schema: SchemaType, input: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): Promise<z$1.infer<SchemaType>>;
|
|
1464
1464
|
//#endregion
|
|
1465
1465
|
//#region src/root/zod/zodFieldWrapper.d.ts
|
|
1466
|
-
declare function zodFieldWrapper<SchemaType extends ZodType<unknown, string | null>>(schema: SchemaType): ZodType<z
|
|
1466
|
+
declare function zodFieldWrapper<SchemaType extends ZodType<unknown, string | null>>(schema: SchemaType): ZodType<z.infer<SchemaType>, string>;
|
|
1467
1467
|
//#endregion
|
|
1468
1468
|
//#region src/root/zod/az.d.ts
|
|
1469
1469
|
declare const az: {
|
|
@@ -1472,15 +1472,15 @@ declare const az: {
|
|
|
1472
1472
|
versionNumber: () => ZodType<VersionNumber, unknown>;
|
|
1473
1473
|
fieldDate: () => ZodCoercedDate<string | null>;
|
|
1474
1474
|
with: <SchemaType extends ZodType>(schema: SchemaType) => {
|
|
1475
|
-
parse: <ErrorType extends Error = DataError$1<Record<PropertyKey, unknown>, string>>(input: unknown, error?: ErrorType | ((zodError: z
|
|
1476
|
-
parseAsync: <ErrorType extends Error = DataError$1<Record<PropertyKey, unknown>, string>>(input: unknown, error?: ErrorType | ((zodError: z
|
|
1475
|
+
parse: <ErrorType extends Error = DataError$1<Record<PropertyKey, unknown>, string>>(input: unknown, error?: ErrorType | ((zodError: z.ZodError<unknown>) => void | ErrorType)) => ReturnType<typeof parseZodSchema<SchemaType, ErrorType>>;
|
|
1476
|
+
parseAsync: <ErrorType extends Error = DataError$1<Record<PropertyKey, unknown>, string>>(input: unknown, error?: ErrorType | ((zodError: z.ZodError<unknown>) => void | ErrorType)) => ReturnType<typeof parseZodSchemaAsync<SchemaType, ErrorType>>;
|
|
1477
1477
|
};
|
|
1478
1478
|
};
|
|
1479
1479
|
//#endregion
|
|
1480
1480
|
//#region src/root/zod/_parseZodSchema.d.ts
|
|
1481
1481
|
interface ZodParsingErrorData {
|
|
1482
1482
|
input: unknown;
|
|
1483
|
-
issues: Array<z
|
|
1483
|
+
issues: Array<z.core.$ZodIssue>;
|
|
1484
1484
|
}
|
|
1485
1485
|
//#endregion
|
|
1486
1486
|
export { APIError, type ArrayElement, type CallReturnType, type CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, SortDirection, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, pickProperties, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import z
|
|
1
|
+
import z, { z as z$1 } from "zod";
|
|
2
2
|
//#region src/root/constants/FILE_PATH_REGEX.ts
|
|
3
3
|
const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
|
|
4
4
|
const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_PATTERN}$`);
|
|
@@ -1300,14 +1300,14 @@ var VersionNumber = class VersionNumber {
|
|
|
1300
1300
|
return VersionNumber.formatString(rawString, { omitPrefix: false });
|
|
1301
1301
|
}
|
|
1302
1302
|
};
|
|
1303
|
-
const zodVersionNumber = z
|
|
1304
|
-
z
|
|
1305
|
-
z
|
|
1306
|
-
z
|
|
1307
|
-
z
|
|
1308
|
-
z
|
|
1303
|
+
const zodVersionNumber = z.union([
|
|
1304
|
+
z.string(),
|
|
1305
|
+
z.tuple([
|
|
1306
|
+
z.number(),
|
|
1307
|
+
z.number(),
|
|
1308
|
+
z.number()
|
|
1309
1309
|
]),
|
|
1310
|
-
z
|
|
1310
|
+
z.instanceof(VersionNumber)
|
|
1311
1311
|
]).transform((rawVersionNumber) => {
|
|
1312
1312
|
return new VersionNumber(rawVersionNumber);
|
|
1313
1313
|
});
|
|
@@ -1325,7 +1325,7 @@ function _parseZodSchema(parsedResult, input, onError) {
|
|
|
1325
1325
|
throw new DataError$1({
|
|
1326
1326
|
input,
|
|
1327
1327
|
issues: parsedResult.error.issues
|
|
1328
|
-
}, "ZOD_ERROR", `\n\n${z
|
|
1328
|
+
}, "ZOD_ERROR", `\n\n${z.prettifyError(parsedResult.error)}\n`);
|
|
1329
1329
|
}
|
|
1330
1330
|
return parsedResult.data;
|
|
1331
1331
|
}
|
|
@@ -1380,7 +1380,7 @@ async function parseZodSchemaAsync(schema, input, onError) {
|
|
|
1380
1380
|
//#endregion
|
|
1381
1381
|
//#region src/root/zod/zodFieldWrapper.ts
|
|
1382
1382
|
function zodFieldWrapper(schema) {
|
|
1383
|
-
return z
|
|
1383
|
+
return z.string().trim().transform((value) => {
|
|
1384
1384
|
return value === "" ? null : value;
|
|
1385
1385
|
}).pipe(schema);
|
|
1386
1386
|
}
|
|
@@ -1389,13 +1389,13 @@ function zodFieldWrapper(schema) {
|
|
|
1389
1389
|
const az = {
|
|
1390
1390
|
field: zodFieldWrapper,
|
|
1391
1391
|
fieldNumber: () => {
|
|
1392
|
-
return z
|
|
1392
|
+
return z.coerce.number();
|
|
1393
1393
|
},
|
|
1394
1394
|
versionNumber: () => {
|
|
1395
1395
|
return zodVersionNumber;
|
|
1396
1396
|
},
|
|
1397
1397
|
fieldDate: () => {
|
|
1398
|
-
return z
|
|
1398
|
+
return z.coerce.date();
|
|
1399
1399
|
},
|
|
1400
1400
|
with: (schema) => {
|
|
1401
1401
|
return {
|
|
@@ -1432,7 +1432,7 @@ const Env = {
|
|
|
1432
1432
|
* @returns The specified environment if allowed.
|
|
1433
1433
|
*/
|
|
1434
1434
|
function parseEnv(input) {
|
|
1435
|
-
return az.with(z.enum(Env)).parse(input, new DataError$1({ input }, "INVALID_ENV", "The provided environment type must be one of `test | development | production`"));
|
|
1435
|
+
return az.with(z$1.enum(Env)).parse(input, new DataError$1({ input }, "INVALID_ENV", "The provided environment type must be one of `test | development | production`"));
|
|
1436
1436
|
}
|
|
1437
1437
|
//#endregion
|
|
1438
1438
|
//#region src/root/functions/parsers/parseFormData.ts
|
|
@@ -1498,7 +1498,7 @@ const VersionType = {
|
|
|
1498
1498
|
* @returns The given version type if allowed.
|
|
1499
1499
|
*/
|
|
1500
1500
|
function parseVersionType(input) {
|
|
1501
|
-
return az.with(z
|
|
1501
|
+
return az.with(z.enum(VersionType)).parse(input, new DataError$1({ input }, "INVALID_VERSION_TYPE", "The provided version type must be one of `major | minor | patch`"));
|
|
1502
1502
|
}
|
|
1503
1503
|
//#endregion
|
|
1504
1504
|
//#region src/root/functions/recursive/deepCopy.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "5.23.
|
|
3
|
+
"version": "5.23.1",
|
|
4
4
|
"description": "Helpful utility functions.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"execa": "9.6.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@alextheman/eslint-plugin": "5.17.
|
|
43
|
+
"@alextheman/eslint-plugin": "5.17.1",
|
|
44
44
|
"@types/node": "25.9.3",
|
|
45
|
-
"alex-c-line": "2.
|
|
45
|
+
"alex-c-line": "2.10.3",
|
|
46
46
|
"cross-env": "10.1.0",
|
|
47
47
|
"dotenv-cli": "11.0.0",
|
|
48
48
|
"eslint": "10.5.0",
|
|
@@ -52,15 +52,15 @@
|
|
|
52
52
|
"markdownlint-cli2": "0.22.1",
|
|
53
53
|
"prettier": "3.8.4",
|
|
54
54
|
"tempy": "3.2.0",
|
|
55
|
-
"tsdown": "0.22.
|
|
55
|
+
"tsdown": "0.22.3",
|
|
56
56
|
"tsx": "4.22.4",
|
|
57
57
|
"typedoc": "0.28.19",
|
|
58
58
|
"typedoc-plugin-markdown": "4.12.0",
|
|
59
59
|
"typedoc-rhineai-theme": "1.2.0",
|
|
60
60
|
"typescript": "6.0.3",
|
|
61
|
-
"typescript-eslint": "8.61.
|
|
61
|
+
"typescript-eslint": "8.61.1",
|
|
62
62
|
"vite": "8.0.16",
|
|
63
|
-
"vitest": "4.1.
|
|
63
|
+
"vitest": "4.1.9",
|
|
64
64
|
"zod": "4.4.3"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|