@alextheman/utility 1.17.0 → 1.18.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 +13 -3
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +12 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -66,6 +66,7 @@ __export(index_exports, {
|
|
|
66
66
|
isMonthlyMultiple: () => isMonthlyMultiple_default,
|
|
67
67
|
isSameDate: () => isSameDate_default,
|
|
68
68
|
parseEnv: () => Env_default,
|
|
69
|
+
parseUUID: () => UUID_default,
|
|
69
70
|
randomiseArray: () => randomiseArray_default,
|
|
70
71
|
range: () => range_default,
|
|
71
72
|
truncate: () => truncate_default,
|
|
@@ -256,7 +257,7 @@ function truncate(stringToTruncate, maxLength = 5) {
|
|
|
256
257
|
var truncate_default = truncate;
|
|
257
258
|
|
|
258
259
|
// src/functions/validateUUID.ts
|
|
259
|
-
var
|
|
260
|
+
var import_zod3 = __toESM(require("zod"), 1);
|
|
260
261
|
|
|
261
262
|
// src/types/APIError.ts
|
|
262
263
|
var httpErrorCodeLookup = {
|
|
@@ -294,10 +295,18 @@ function parseEnv(data = "development") {
|
|
|
294
295
|
}
|
|
295
296
|
var Env_default = parseEnv;
|
|
296
297
|
|
|
298
|
+
// src/types/UUID.ts
|
|
299
|
+
var import_zod2 = __toESM(require("zod"), 1);
|
|
300
|
+
var uuidSchema = import_zod2.default.uuid();
|
|
301
|
+
function parseUUID(UUID) {
|
|
302
|
+
return uuidSchema.parse(UUID);
|
|
303
|
+
}
|
|
304
|
+
var UUID_default = parseUUID;
|
|
305
|
+
|
|
297
306
|
// src/functions/validateUUID.ts
|
|
298
307
|
function validateUUID(UUID, error = new APIError_default(400, "INVALID_UUID")) {
|
|
299
|
-
const
|
|
300
|
-
const parsedUUID =
|
|
308
|
+
const uuidSchema2 = import_zod3.default.uuid();
|
|
309
|
+
const parsedUUID = uuidSchema2.safeParse(UUID);
|
|
301
310
|
if (!parsedUUID.success) {
|
|
302
311
|
throw error;
|
|
303
312
|
}
|
|
@@ -343,6 +352,7 @@ var interpolateObjects_default = interpolateObjects;
|
|
|
343
352
|
isMonthlyMultiple,
|
|
344
353
|
isSameDate,
|
|
345
354
|
parseEnv,
|
|
355
|
+
parseUUID,
|
|
346
356
|
randomiseArray,
|
|
347
357
|
range,
|
|
348
358
|
truncate,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import z$1, { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
declare function addDaysToDate(currentDate?: Date, dayIncrement?: number): Date;
|
|
4
4
|
|
|
@@ -41,10 +41,17 @@ declare const envSchema: z.ZodEnum<{
|
|
|
41
41
|
type Env = z.infer<typeof envSchema>;
|
|
42
42
|
declare function parseEnv(data?: unknown): Env;
|
|
43
43
|
|
|
44
|
+
declare const uuidSchema: z$1.ZodUUID;
|
|
45
|
+
type UUID = z$1.infer<typeof uuidSchema>;
|
|
46
|
+
declare function parseUUID(UUID: unknown): UUID;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated validateUUID() is deprecated in favour of parseUUID()
|
|
50
|
+
*/
|
|
44
51
|
declare function validateUUID(UUID: string, error?: Error | APIError): string;
|
|
45
52
|
|
|
46
53
|
declare function wait(seconds: number): Promise<void>;
|
|
47
54
|
|
|
48
55
|
declare function interpolateObjects(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
49
56
|
|
|
50
|
-
export { APIError, type Env, type HTTPErrorCodes, addDaysToDate, appendSemicolon, convertFileToBase64, fillArray, fillArrayAsync, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, parseEnv, randomiseArray, range, truncate, validateUUID, wait };
|
|
57
|
+
export { APIError, type Env, type HTTPErrorCodes, type UUID, addDaysToDate, appendSemicolon, convertFileToBase64, fillArray, fillArrayAsync, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, parseEnv, parseUUID, randomiseArray, range, truncate, validateUUID, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import z$1, { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
declare function addDaysToDate(currentDate?: Date, dayIncrement?: number): Date;
|
|
4
4
|
|
|
@@ -41,10 +41,17 @@ declare const envSchema: z.ZodEnum<{
|
|
|
41
41
|
type Env = z.infer<typeof envSchema>;
|
|
42
42
|
declare function parseEnv(data?: unknown): Env;
|
|
43
43
|
|
|
44
|
+
declare const uuidSchema: z$1.ZodUUID;
|
|
45
|
+
type UUID = z$1.infer<typeof uuidSchema>;
|
|
46
|
+
declare function parseUUID(UUID: unknown): UUID;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated validateUUID() is deprecated in favour of parseUUID()
|
|
50
|
+
*/
|
|
44
51
|
declare function validateUUID(UUID: string, error?: Error | APIError): string;
|
|
45
52
|
|
|
46
53
|
declare function wait(seconds: number): Promise<void>;
|
|
47
54
|
|
|
48
55
|
declare function interpolateObjects(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
49
56
|
|
|
50
|
-
export { APIError, type Env, type HTTPErrorCodes, addDaysToDate, appendSemicolon, convertFileToBase64, fillArray, fillArrayAsync, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, parseEnv, randomiseArray, range, truncate, validateUUID, wait };
|
|
57
|
+
export { APIError, type Env, type HTTPErrorCodes, type UUID, addDaysToDate, appendSemicolon, convertFileToBase64, fillArray, fillArrayAsync, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, parseEnv, parseUUID, randomiseArray, range, truncate, validateUUID, wait };
|
package/dist/index.js
CHANGED
|
@@ -204,7 +204,7 @@ function truncate(stringToTruncate, maxLength = 5) {
|
|
|
204
204
|
var truncate_default = truncate;
|
|
205
205
|
|
|
206
206
|
// src/functions/validateUUID.ts
|
|
207
|
-
import
|
|
207
|
+
import z3 from "zod";
|
|
208
208
|
|
|
209
209
|
// src/types/APIError.ts
|
|
210
210
|
var httpErrorCodeLookup = {
|
|
@@ -242,10 +242,18 @@ function parseEnv(data = "development") {
|
|
|
242
242
|
}
|
|
243
243
|
var Env_default = parseEnv;
|
|
244
244
|
|
|
245
|
+
// src/types/UUID.ts
|
|
246
|
+
import z2 from "zod";
|
|
247
|
+
var uuidSchema = z2.uuid();
|
|
248
|
+
function parseUUID(UUID) {
|
|
249
|
+
return uuidSchema.parse(UUID);
|
|
250
|
+
}
|
|
251
|
+
var UUID_default = parseUUID;
|
|
252
|
+
|
|
245
253
|
// src/functions/validateUUID.ts
|
|
246
254
|
function validateUUID(UUID, error = new APIError_default(400, "INVALID_UUID")) {
|
|
247
|
-
const
|
|
248
|
-
const parsedUUID =
|
|
255
|
+
const uuidSchema2 = z3.uuid();
|
|
256
|
+
const parsedUUID = uuidSchema2.safeParse(UUID);
|
|
249
257
|
if (!parsedUUID.success) {
|
|
250
258
|
throw error;
|
|
251
259
|
}
|
|
@@ -290,6 +298,7 @@ export {
|
|
|
290
298
|
isMonthlyMultiple_default as isMonthlyMultiple,
|
|
291
299
|
isSameDate_default as isSameDate,
|
|
292
300
|
Env_default as parseEnv,
|
|
301
|
+
UUID_default as parseUUID,
|
|
293
302
|
randomiseArray_default as randomiseArray,
|
|
294
303
|
range_default as range,
|
|
295
304
|
truncate_default as truncate,
|