@alextheman/utility 5.22.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.cjs +22 -0
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +25 -9
- package/dist/index.js +36 -15
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -1110,6 +1110,27 @@ function omitProperties(object, keysToOmit) {
|
|
|
1110
1110
|
return outputObject;
|
|
1111
1111
|
}
|
|
1112
1112
|
//#endregion
|
|
1113
|
+
//#region src/root/functions/objectHelpers/pickProperties.ts
|
|
1114
|
+
/**
|
|
1115
|
+
* Picks properties from a given object.
|
|
1116
|
+
*
|
|
1117
|
+
* @category Object Helpers
|
|
1118
|
+
*
|
|
1119
|
+
* @template ObjectType - The type of the input object.
|
|
1120
|
+
* @template KeysToPick - A type representing the keys to pick from the object.
|
|
1121
|
+
*
|
|
1122
|
+
* @param object - The object to pick properties from.
|
|
1123
|
+
* @param keysToPick - The keys to pick from the object. Can either be a single string to pick one, or an array to pick multiple.
|
|
1124
|
+
*
|
|
1125
|
+
* @returns An object with a new reference in memory, with the chosen properties present.
|
|
1126
|
+
*/
|
|
1127
|
+
function pickProperties(object, keysToPick) {
|
|
1128
|
+
const keysArray = Array.isArray(keysToPick) ? keysToPick : [keysToPick];
|
|
1129
|
+
const outputObject = {};
|
|
1130
|
+
for (const key of keysArray) outputObject[key] = object[key];
|
|
1131
|
+
return outputObject;
|
|
1132
|
+
}
|
|
1133
|
+
//#endregion
|
|
1113
1134
|
//#region src/root/functions/objectHelpers/removeUndefinedFromObject.ts
|
|
1114
1135
|
/**
|
|
1115
1136
|
* Removes entries whose values are `undefined` from a given object (not including null etc.).
|
|
@@ -2078,6 +2099,7 @@ exports.parseUUID = parseUUID;
|
|
|
2078
2099
|
exports.parseVersionType = parseVersionType;
|
|
2079
2100
|
exports.parseZodSchema = parseZodSchema;
|
|
2080
2101
|
exports.parseZodSchemaAsync = parseZodSchemaAsync;
|
|
2102
|
+
exports.pickProperties = pickProperties;
|
|
2081
2103
|
exports.randomiseArray = randomiseArray;
|
|
2082
2104
|
exports.range = range;
|
|
2083
2105
|
exports.removeDuplicates = removeDuplicates;
|
package/dist/index.d.cts
CHANGED
|
@@ -732,6 +732,22 @@ declare function getRecordKeys<InputRecordType extends Record<PropertyKey, unkno
|
|
|
732
732
|
*/
|
|
733
733
|
declare function omitProperties<ObjectType extends object, KeysToOmit extends keyof ObjectType>(object: ObjectType, keysToOmit: KeysToOmit | ReadonlyArray<KeysToOmit>): Omit<ObjectType, KeysToOmit>;
|
|
734
734
|
//#endregion
|
|
735
|
+
//#region src/root/functions/objectHelpers/pickProperties.d.ts
|
|
736
|
+
/**
|
|
737
|
+
* Picks properties from a given object.
|
|
738
|
+
*
|
|
739
|
+
* @category Object Helpers
|
|
740
|
+
*
|
|
741
|
+
* @template ObjectType - The type of the input object.
|
|
742
|
+
* @template KeysToPick - A type representing the keys to pick from the object.
|
|
743
|
+
*
|
|
744
|
+
* @param object - The object to pick properties from.
|
|
745
|
+
* @param keysToPick - The keys to pick from the object. Can either be a single string to pick one, or an array to pick multiple.
|
|
746
|
+
*
|
|
747
|
+
* @returns An object with a new reference in memory, with the chosen properties present.
|
|
748
|
+
*/
|
|
749
|
+
declare function pickProperties<ObjectType extends object, KeysToPick extends keyof ObjectType>(object: ObjectType, keysToPick: KeysToPick | ReadonlyArray<KeysToPick>): Pick<ObjectType, KeysToPick>;
|
|
750
|
+
//#endregion
|
|
735
751
|
//#region src/root/functions/objectHelpers/removeUndefinedFromObject.d.ts
|
|
736
752
|
type RemoveUndefined<RecordType extends Record<PropertyKey, unknown>> = { [Key in keyof RecordType]: Exclude<RecordType[Key], undefined> };
|
|
737
753
|
/**
|
|
@@ -1467,4 +1483,4 @@ interface ZodParsingErrorData {
|
|
|
1467
1483
|
issues: Array<z.core.$ZodIssue>;
|
|
1468
1484
|
}
|
|
1469
1485
|
//#endregion
|
|
1470
|
-
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, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
|
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.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
|
/**
|
|
@@ -732,6 +732,22 @@ declare function getRecordKeys<InputRecordType extends Record<PropertyKey, unkno
|
|
|
732
732
|
*/
|
|
733
733
|
declare function omitProperties<ObjectType extends object, KeysToOmit extends keyof ObjectType>(object: ObjectType, keysToOmit: KeysToOmit | ReadonlyArray<KeysToOmit>): Omit<ObjectType, KeysToOmit>;
|
|
734
734
|
//#endregion
|
|
735
|
+
//#region src/root/functions/objectHelpers/pickProperties.d.ts
|
|
736
|
+
/**
|
|
737
|
+
* Picks properties from a given object.
|
|
738
|
+
*
|
|
739
|
+
* @category Object Helpers
|
|
740
|
+
*
|
|
741
|
+
* @template ObjectType - The type of the input object.
|
|
742
|
+
* @template KeysToPick - A type representing the keys to pick from the object.
|
|
743
|
+
*
|
|
744
|
+
* @param object - The object to pick properties from.
|
|
745
|
+
* @param keysToPick - The keys to pick from the object. Can either be a single string to pick one, or an array to pick multiple.
|
|
746
|
+
*
|
|
747
|
+
* @returns An object with a new reference in memory, with the chosen properties present.
|
|
748
|
+
*/
|
|
749
|
+
declare function pickProperties<ObjectType extends object, KeysToPick extends keyof ObjectType>(object: ObjectType, keysToPick: KeysToPick | ReadonlyArray<KeysToPick>): Pick<ObjectType, KeysToPick>;
|
|
750
|
+
//#endregion
|
|
735
751
|
//#region src/root/functions/objectHelpers/removeUndefinedFromObject.d.ts
|
|
736
752
|
type RemoveUndefined<RecordType extends Record<PropertyKey, unknown>> = { [Key in keyof RecordType]: Exclude<RecordType[Key], undefined> };
|
|
737
753
|
/**
|
|
@@ -1423,7 +1439,7 @@ declare class DataError$1<DataType extends object = Record<PropertyKey, unknown>
|
|
|
1423
1439
|
*
|
|
1424
1440
|
* @returns The parsed data from the Zod schema.
|
|
1425
1441
|
*/
|
|
1426
|
-
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>;
|
|
1427
1443
|
//#endregion
|
|
1428
1444
|
//#region src/root/zod/parseZodSchemaAsync.d.ts
|
|
1429
1445
|
/**
|
|
@@ -1444,10 +1460,10 @@ declare function parseZodSchema<SchemaType extends ZodType, ErrorType extends Er
|
|
|
1444
1460
|
*
|
|
1445
1461
|
* @returns The parsed data from the Zod schema.
|
|
1446
1462
|
*/
|
|
1447
|
-
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>>;
|
|
1448
1464
|
//#endregion
|
|
1449
1465
|
//#region src/root/zod/zodFieldWrapper.d.ts
|
|
1450
|
-
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>;
|
|
1451
1467
|
//#endregion
|
|
1452
1468
|
//#region src/root/zod/az.d.ts
|
|
1453
1469
|
declare const az: {
|
|
@@ -1456,15 +1472,15 @@ declare const az: {
|
|
|
1456
1472
|
versionNumber: () => ZodType<VersionNumber, unknown>;
|
|
1457
1473
|
fieldDate: () => ZodCoercedDate<string | null>;
|
|
1458
1474
|
with: <SchemaType extends ZodType>(schema: SchemaType) => {
|
|
1459
|
-
parse: <ErrorType extends Error = DataError$1<Record<PropertyKey, unknown>, string>>(input: unknown, error?: ErrorType | ((zodError: z
|
|
1460
|
-
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>>;
|
|
1461
1477
|
};
|
|
1462
1478
|
};
|
|
1463
1479
|
//#endregion
|
|
1464
1480
|
//#region src/root/zod/_parseZodSchema.d.ts
|
|
1465
1481
|
interface ZodParsingErrorData {
|
|
1466
1482
|
input: unknown;
|
|
1467
|
-
issues: Array<z
|
|
1483
|
+
issues: Array<z.core.$ZodIssue>;
|
|
1468
1484
|
}
|
|
1469
1485
|
//#endregion
|
|
1470
|
-
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, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
|
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}$`);
|
|
@@ -1086,6 +1086,27 @@ function omitProperties(object, keysToOmit) {
|
|
|
1086
1086
|
return outputObject;
|
|
1087
1087
|
}
|
|
1088
1088
|
//#endregion
|
|
1089
|
+
//#region src/root/functions/objectHelpers/pickProperties.ts
|
|
1090
|
+
/**
|
|
1091
|
+
* Picks properties from a given object.
|
|
1092
|
+
*
|
|
1093
|
+
* @category Object Helpers
|
|
1094
|
+
*
|
|
1095
|
+
* @template ObjectType - The type of the input object.
|
|
1096
|
+
* @template KeysToPick - A type representing the keys to pick from the object.
|
|
1097
|
+
*
|
|
1098
|
+
* @param object - The object to pick properties from.
|
|
1099
|
+
* @param keysToPick - The keys to pick from the object. Can either be a single string to pick one, or an array to pick multiple.
|
|
1100
|
+
*
|
|
1101
|
+
* @returns An object with a new reference in memory, with the chosen properties present.
|
|
1102
|
+
*/
|
|
1103
|
+
function pickProperties(object, keysToPick) {
|
|
1104
|
+
const keysArray = Array.isArray(keysToPick) ? keysToPick : [keysToPick];
|
|
1105
|
+
const outputObject = {};
|
|
1106
|
+
for (const key of keysArray) outputObject[key] = object[key];
|
|
1107
|
+
return outputObject;
|
|
1108
|
+
}
|
|
1109
|
+
//#endregion
|
|
1089
1110
|
//#region src/root/functions/objectHelpers/removeUndefinedFromObject.ts
|
|
1090
1111
|
/**
|
|
1091
1112
|
* Removes entries whose values are `undefined` from a given object (not including null etc.).
|
|
@@ -1279,14 +1300,14 @@ var VersionNumber = class VersionNumber {
|
|
|
1279
1300
|
return VersionNumber.formatString(rawString, { omitPrefix: false });
|
|
1280
1301
|
}
|
|
1281
1302
|
};
|
|
1282
|
-
const zodVersionNumber = z
|
|
1283
|
-
z
|
|
1284
|
-
z
|
|
1285
|
-
z
|
|
1286
|
-
z
|
|
1287
|
-
z
|
|
1303
|
+
const zodVersionNumber = z.union([
|
|
1304
|
+
z.string(),
|
|
1305
|
+
z.tuple([
|
|
1306
|
+
z.number(),
|
|
1307
|
+
z.number(),
|
|
1308
|
+
z.number()
|
|
1288
1309
|
]),
|
|
1289
|
-
z
|
|
1310
|
+
z.instanceof(VersionNumber)
|
|
1290
1311
|
]).transform((rawVersionNumber) => {
|
|
1291
1312
|
return new VersionNumber(rawVersionNumber);
|
|
1292
1313
|
});
|
|
@@ -1304,7 +1325,7 @@ function _parseZodSchema(parsedResult, input, onError) {
|
|
|
1304
1325
|
throw new DataError$1({
|
|
1305
1326
|
input,
|
|
1306
1327
|
issues: parsedResult.error.issues
|
|
1307
|
-
}, "ZOD_ERROR", `\n\n${z
|
|
1328
|
+
}, "ZOD_ERROR", `\n\n${z.prettifyError(parsedResult.error)}\n`);
|
|
1308
1329
|
}
|
|
1309
1330
|
return parsedResult.data;
|
|
1310
1331
|
}
|
|
@@ -1359,7 +1380,7 @@ async function parseZodSchemaAsync(schema, input, onError) {
|
|
|
1359
1380
|
//#endregion
|
|
1360
1381
|
//#region src/root/zod/zodFieldWrapper.ts
|
|
1361
1382
|
function zodFieldWrapper(schema) {
|
|
1362
|
-
return z
|
|
1383
|
+
return z.string().trim().transform((value) => {
|
|
1363
1384
|
return value === "" ? null : value;
|
|
1364
1385
|
}).pipe(schema);
|
|
1365
1386
|
}
|
|
@@ -1368,13 +1389,13 @@ function zodFieldWrapper(schema) {
|
|
|
1368
1389
|
const az = {
|
|
1369
1390
|
field: zodFieldWrapper,
|
|
1370
1391
|
fieldNumber: () => {
|
|
1371
|
-
return z
|
|
1392
|
+
return z.coerce.number();
|
|
1372
1393
|
},
|
|
1373
1394
|
versionNumber: () => {
|
|
1374
1395
|
return zodVersionNumber;
|
|
1375
1396
|
},
|
|
1376
1397
|
fieldDate: () => {
|
|
1377
|
-
return z
|
|
1398
|
+
return z.coerce.date();
|
|
1378
1399
|
},
|
|
1379
1400
|
with: (schema) => {
|
|
1380
1401
|
return {
|
|
@@ -1411,7 +1432,7 @@ const Env = {
|
|
|
1411
1432
|
* @returns The specified environment if allowed.
|
|
1412
1433
|
*/
|
|
1413
1434
|
function parseEnv(input) {
|
|
1414
|
-
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`"));
|
|
1415
1436
|
}
|
|
1416
1437
|
//#endregion
|
|
1417
1438
|
//#region src/root/functions/parsers/parseFormData.ts
|
|
@@ -1477,7 +1498,7 @@ const VersionType = {
|
|
|
1477
1498
|
* @returns The given version type if allowed.
|
|
1478
1499
|
*/
|
|
1479
1500
|
function parseVersionType(input) {
|
|
1480
|
-
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`"));
|
|
1481
1502
|
}
|
|
1482
1503
|
//#endregion
|
|
1483
1504
|
//#region src/root/functions/recursive/deepCopy.ts
|
|
@@ -1995,4 +2016,4 @@ var DataError = class DataError extends Error {
|
|
|
1995
2016
|
}
|
|
1996
2017
|
};
|
|
1997
2018
|
//#endregion
|
|
1998
|
-
export { APIError, DataError, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, ONE_DAY_IN_MILLISECONDS, SortDirection, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, VersionType, 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, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
|
2019
|
+
export { APIError, DataError, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, ONE_DAY_IN_MILLISECONDS, SortDirection, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, VersionType, 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "5.
|
|
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": {
|