@alextheman/utility 5.4.0 → 5.4.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 +20 -0
- package/dist/index.d.cts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +20 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1402,6 +1402,25 @@ function parseFormData(formData, dataParser) {
|
|
|
1402
1402
|
return object;
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
|
+
//#endregion
|
|
1406
|
+
//#region src/root/functions/parsers/parseUUID.ts
|
|
1407
|
+
/**
|
|
1408
|
+
* Parses the input and verifies it is a valid UUID.
|
|
1409
|
+
*
|
|
1410
|
+
* @category Parsers
|
|
1411
|
+
*
|
|
1412
|
+
* @param input - The data to parse.
|
|
1413
|
+
*
|
|
1414
|
+
* @throws {DataError} If the data does not match the general UUID pattern.
|
|
1415
|
+
*
|
|
1416
|
+
* @returns The UUID again if successful.
|
|
1417
|
+
*/
|
|
1418
|
+
function parseUUID(input) {
|
|
1419
|
+
if (!(typeof input === "string")) throw new DataError({ input }, "INVALID_TYPE", "Invalid type - expected string.");
|
|
1420
|
+
if (!UUID_REGEX.test(input)) throw new DataError({ input }, "INVALID_UUID", "The provided input does not match the expected shape for a UUID.");
|
|
1421
|
+
return input;
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1405
1424
|
//#endregion
|
|
1406
1425
|
//#region src/root/functions/parsers/parseVersionType.ts
|
|
1407
1426
|
/**
|
|
@@ -1660,6 +1679,7 @@ exports.parseBoolean = parseBoolean;
|
|
|
1660
1679
|
exports.parseEnv = parseEnv;
|
|
1661
1680
|
exports.parseFormData = parseFormData;
|
|
1662
1681
|
exports.parseIntStrict = parseIntStrict;
|
|
1682
|
+
exports.parseUUID = parseUUID;
|
|
1663
1683
|
exports.parseVersionType = parseVersionType;
|
|
1664
1684
|
exports.parseZodSchema = parseZodSchema;
|
|
1665
1685
|
exports.parseZodSchemaAsync = parseZodSchemaAsync;
|
package/dist/index.d.cts
CHANGED
|
@@ -740,6 +740,20 @@ declare function parseFormData(formData: FormData): Record<string, string | Blob
|
|
|
740
740
|
*/
|
|
741
741
|
declare function parseIntStrict(string: string, radix?: number): number;
|
|
742
742
|
//#endregion
|
|
743
|
+
//#region src/root/functions/parsers/parseUUID.d.ts
|
|
744
|
+
/**
|
|
745
|
+
* Parses the input and verifies it is a valid UUID.
|
|
746
|
+
*
|
|
747
|
+
* @category Parsers
|
|
748
|
+
*
|
|
749
|
+
* @param input - The data to parse.
|
|
750
|
+
*
|
|
751
|
+
* @throws {DataError} If the data does not match the general UUID pattern.
|
|
752
|
+
*
|
|
753
|
+
* @returns The UUID again if successful.
|
|
754
|
+
*/
|
|
755
|
+
declare function parseUUID(input: unknown): string;
|
|
756
|
+
//#endregion
|
|
743
757
|
//#region src/root/functions/parsers/parseVersionType.d.ts
|
|
744
758
|
/**
|
|
745
759
|
* Represents the three common software version types.
|
|
@@ -1086,4 +1100,4 @@ declare function normaliseIndents(strings: TemplateStringsArray, ...interpolatio
|
|
|
1086
1100
|
*/
|
|
1087
1101
|
declare const normalizeIndents: typeof normaliseIndents;
|
|
1088
1102
|
//#endregion
|
|
1089
|
-
export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IsTypeArgumentString, KebabToCamelOptions, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, ONE_DAY_IN_MILLISECONDS, OptionalOnCondition, ParallelTuple, RecordKey, RemoveUndefined, StringListToArrayOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
|
|
1103
|
+
export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IsTypeArgumentString, KebabToCamelOptions, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, ONE_DAY_IN_MILLISECONDS, OptionalOnCondition, ParallelTuple, RecordKey, RemoveUndefined, StringListToArrayOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
|
package/dist/index.d.ts
CHANGED
|
@@ -740,6 +740,20 @@ declare function parseFormData(formData: FormData): Record<string, string | Blob
|
|
|
740
740
|
*/
|
|
741
741
|
declare function parseIntStrict(string: string, radix?: number): number;
|
|
742
742
|
//#endregion
|
|
743
|
+
//#region src/root/functions/parsers/parseUUID.d.ts
|
|
744
|
+
/**
|
|
745
|
+
* Parses the input and verifies it is a valid UUID.
|
|
746
|
+
*
|
|
747
|
+
* @category Parsers
|
|
748
|
+
*
|
|
749
|
+
* @param input - The data to parse.
|
|
750
|
+
*
|
|
751
|
+
* @throws {DataError} If the data does not match the general UUID pattern.
|
|
752
|
+
*
|
|
753
|
+
* @returns The UUID again if successful.
|
|
754
|
+
*/
|
|
755
|
+
declare function parseUUID(input: unknown): string;
|
|
756
|
+
//#endregion
|
|
743
757
|
//#region src/root/functions/parsers/parseVersionType.d.ts
|
|
744
758
|
/**
|
|
745
759
|
* Represents the three common software version types.
|
|
@@ -1086,4 +1100,4 @@ declare function normaliseIndents(strings: TemplateStringsArray, ...interpolatio
|
|
|
1086
1100
|
*/
|
|
1087
1101
|
declare const normalizeIndents: typeof normaliseIndents;
|
|
1088
1102
|
//#endregion
|
|
1089
|
-
export { APIError, type ArrayElement, type CallReturnType, 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, KebabToCamelOptions, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, ParallelTuple, type RecordKey, type RemoveUndefined, type StringListToArrayOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
|
|
1103
|
+
export { APIError, type ArrayElement, type CallReturnType, 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, KebabToCamelOptions, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, ParallelTuple, type RecordKey, type RemoveUndefined, type StringListToArrayOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
|
package/dist/index.js
CHANGED
|
@@ -1372,6 +1372,25 @@ function parseFormData(formData, dataParser) {
|
|
|
1372
1372
|
return object;
|
|
1373
1373
|
}
|
|
1374
1374
|
|
|
1375
|
+
//#endregion
|
|
1376
|
+
//#region src/root/functions/parsers/parseUUID.ts
|
|
1377
|
+
/**
|
|
1378
|
+
* Parses the input and verifies it is a valid UUID.
|
|
1379
|
+
*
|
|
1380
|
+
* @category Parsers
|
|
1381
|
+
*
|
|
1382
|
+
* @param input - The data to parse.
|
|
1383
|
+
*
|
|
1384
|
+
* @throws {DataError} If the data does not match the general UUID pattern.
|
|
1385
|
+
*
|
|
1386
|
+
* @returns The UUID again if successful.
|
|
1387
|
+
*/
|
|
1388
|
+
function parseUUID(input) {
|
|
1389
|
+
if (!(typeof input === "string")) throw new DataError({ input }, "INVALID_TYPE", "Invalid type - expected string.");
|
|
1390
|
+
if (!UUID_REGEX.test(input)) throw new DataError({ input }, "INVALID_UUID", "The provided input does not match the expected shape for a UUID.");
|
|
1391
|
+
return input;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1375
1394
|
//#endregion
|
|
1376
1395
|
//#region src/root/functions/parsers/parseVersionType.ts
|
|
1377
1396
|
/**
|
|
@@ -1586,4 +1605,4 @@ function truncate(stringToTruncate, maxLength = 5) {
|
|
|
1586
1605
|
}
|
|
1587
1606
|
|
|
1588
1607
|
//#endregion
|
|
1589
|
-
export { APIError, DataError, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, ONE_DAY_IN_MILLISECONDS, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
|
|
1608
|
+
export { APIError, DataError, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, ONE_DAY_IN_MILLISECONDS, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
|