@alextheman/utility 1.16.3 → 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 +28 -3
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +26 -3
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -61,10 +61,12 @@ __export(index_exports, {
|
|
|
61
61
|
formatDateAndTime: () => formatDateAndTime_default,
|
|
62
62
|
getRandomNumber: () => getRandomNumber_default,
|
|
63
63
|
httpErrorCodeLookup: () => httpErrorCodeLookup,
|
|
64
|
+
interpolateObjects: () => interpolateObjects_default,
|
|
64
65
|
isLeapYear: () => isLeapYear_default,
|
|
65
66
|
isMonthlyMultiple: () => isMonthlyMultiple_default,
|
|
66
67
|
isSameDate: () => isSameDate_default,
|
|
67
68
|
parseEnv: () => Env_default,
|
|
69
|
+
parseUUID: () => UUID_default,
|
|
68
70
|
randomiseArray: () => randomiseArray_default,
|
|
69
71
|
range: () => range_default,
|
|
70
72
|
truncate: () => truncate_default,
|
|
@@ -255,7 +257,7 @@ function truncate(stringToTruncate, maxLength = 5) {
|
|
|
255
257
|
var truncate_default = truncate;
|
|
256
258
|
|
|
257
259
|
// src/functions/validateUUID.ts
|
|
258
|
-
var
|
|
260
|
+
var import_zod3 = __toESM(require("zod"), 1);
|
|
259
261
|
|
|
260
262
|
// src/types/APIError.ts
|
|
261
263
|
var httpErrorCodeLookup = {
|
|
@@ -293,10 +295,18 @@ function parseEnv(data = "development") {
|
|
|
293
295
|
}
|
|
294
296
|
var Env_default = parseEnv;
|
|
295
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
|
+
|
|
296
306
|
// src/functions/validateUUID.ts
|
|
297
307
|
function validateUUID(UUID, error = new APIError_default(400, "INVALID_UUID")) {
|
|
298
|
-
const
|
|
299
|
-
const parsedUUID =
|
|
308
|
+
const uuidSchema2 = import_zod3.default.uuid();
|
|
309
|
+
const parsedUUID = uuidSchema2.safeParse(UUID);
|
|
300
310
|
if (!parsedUUID.success) {
|
|
301
311
|
throw error;
|
|
302
312
|
}
|
|
@@ -313,6 +323,19 @@ function wait(seconds) {
|
|
|
313
323
|
});
|
|
314
324
|
}
|
|
315
325
|
var wait_default = wait;
|
|
326
|
+
|
|
327
|
+
// src/functions/taggedTemplate/interpolateObjects.ts
|
|
328
|
+
function interpolateObjects(strings, ...values) {
|
|
329
|
+
let result = "";
|
|
330
|
+
for (let i = 0; i < strings.length; i++) {
|
|
331
|
+
result += strings[i];
|
|
332
|
+
if (i !== strings.length - 1) {
|
|
333
|
+
result += values[i] && typeof values[i] === "object" ? JSON.stringify(values[i]) : values[i];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return result;
|
|
337
|
+
}
|
|
338
|
+
var interpolateObjects_default = interpolateObjects;
|
|
316
339
|
// Annotate the CommonJS export names for ESM import in node:
|
|
317
340
|
0 && (module.exports = {
|
|
318
341
|
APIError,
|
|
@@ -324,10 +347,12 @@ var wait_default = wait;
|
|
|
324
347
|
formatDateAndTime,
|
|
325
348
|
getRandomNumber,
|
|
326
349
|
httpErrorCodeLookup,
|
|
350
|
+
interpolateObjects,
|
|
327
351
|
isLeapYear,
|
|
328
352
|
isMonthlyMultiple,
|
|
329
353
|
isSameDate,
|
|
330
354
|
parseEnv,
|
|
355
|
+
parseUUID,
|
|
331
356
|
randomiseArray,
|
|
332
357
|
range,
|
|
333
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,8 +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;
|
|
56
|
+
|
|
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,8 +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;
|
|
56
|
+
|
|
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
|
}
|
|
@@ -262,6 +270,19 @@ function wait(seconds) {
|
|
|
262
270
|
});
|
|
263
271
|
}
|
|
264
272
|
var wait_default = wait;
|
|
273
|
+
|
|
274
|
+
// src/functions/taggedTemplate/interpolateObjects.ts
|
|
275
|
+
function interpolateObjects(strings, ...values) {
|
|
276
|
+
let result = "";
|
|
277
|
+
for (let i = 0; i < strings.length; i++) {
|
|
278
|
+
result += strings[i];
|
|
279
|
+
if (i !== strings.length - 1) {
|
|
280
|
+
result += values[i] && typeof values[i] === "object" ? JSON.stringify(values[i]) : values[i];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
285
|
+
var interpolateObjects_default = interpolateObjects;
|
|
265
286
|
export {
|
|
266
287
|
APIError_default as APIError,
|
|
267
288
|
addDaysToDate_default as addDaysToDate,
|
|
@@ -272,10 +293,12 @@ export {
|
|
|
272
293
|
formatDateAndTime_default as formatDateAndTime,
|
|
273
294
|
getRandomNumber_default as getRandomNumber,
|
|
274
295
|
httpErrorCodeLookup,
|
|
296
|
+
interpolateObjects_default as interpolateObjects,
|
|
275
297
|
isLeapYear_default as isLeapYear,
|
|
276
298
|
isMonthlyMultiple_default as isMonthlyMultiple,
|
|
277
299
|
isSameDate_default as isSameDate,
|
|
278
300
|
Env_default as parseEnv,
|
|
301
|
+
UUID_default as parseUUID,
|
|
279
302
|
randomiseArray_default as randomiseArray,
|
|
280
303
|
range_default as range,
|
|
281
304
|
truncate_default as truncate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"main": "dist/index.cjs",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,22 +26,22 @@
|
|
|
26
26
|
"description": "",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@alextheman/eslint-plugin": "^1.14.1",
|
|
29
|
-
"@eslint/js": "^9.
|
|
30
|
-
"@types/node": "^24.
|
|
31
|
-
"eslint": "^9.
|
|
29
|
+
"@eslint/js": "^9.36.0",
|
|
30
|
+
"@types/node": "^24.5.2",
|
|
31
|
+
"eslint": "^9.36.0",
|
|
32
32
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
33
33
|
"eslint-plugin-import": "^2.32.0",
|
|
34
34
|
"globals": "^16.4.0",
|
|
35
35
|
"husky": "^9.1.7",
|
|
36
|
-
"jsdom": "^
|
|
36
|
+
"jsdom": "^27.0.0",
|
|
37
37
|
"prettier": "^3.6.2",
|
|
38
38
|
"tsup": "^8.5.0",
|
|
39
39
|
"typescript": "^5.9.2",
|
|
40
|
-
"typescript-eslint": "^8.
|
|
40
|
+
"typescript-eslint": "^8.44.0",
|
|
41
41
|
"vite-tsconfig-paths": "^5.1.4",
|
|
42
42
|
"vitest": "^3.2.4"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"zod": "^4.1.
|
|
45
|
+
"zod": "^4.1.9"
|
|
46
46
|
}
|
|
47
47
|
}
|