@alextheman/utility 2.20.0 → 3.0.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 +447 -566
- package/dist/index.d.cts +114 -68
- package/dist/index.d.ts +114 -68
- package/dist/index.js +389 -504
- package/package.json +8 -5
package/dist/index.cjs
CHANGED
|
@@ -1,705 +1,586 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __export = (target, all) => {
|
|
23
|
-
for (var name in all)
|
|
24
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
-
};
|
|
26
8
|
var __copyProps = (to, from, except, desc) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
33
21
|
};
|
|
34
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var index_exports = {};
|
|
47
|
-
__export(index_exports, {
|
|
48
|
-
APIError: () => APIError_default,
|
|
49
|
-
addDaysToDate: () => addDaysToDate_default,
|
|
50
|
-
appendSemicolon: () => appendSemicolon_default,
|
|
51
|
-
camelToKebab: () => camelToKebab_default,
|
|
52
|
-
convertFileToBase64: () => convertFileToBase64_default,
|
|
53
|
-
createFormData: () => createFormData_default,
|
|
54
|
-
createTemplateStringsArray: () => createTemplateStringsArray_default,
|
|
55
|
-
fillArray: () => fillArray_default,
|
|
56
|
-
formatDateAndTime: () => formatDateAndTime_default,
|
|
57
|
-
getRandomNumber: () => getRandomNumber_default,
|
|
58
|
-
getRecordKeys: () => getRecordKeys_default,
|
|
59
|
-
httpErrorCodeLookup: () => httpErrorCodeLookup,
|
|
60
|
-
interpolate: () => interpolate_default,
|
|
61
|
-
interpolateObjects: () => interpolateObjects_default,
|
|
62
|
-
isLeapYear: () => isLeapYear_default,
|
|
63
|
-
isMonthlyMultiple: () => isMonthlyMultiple_default,
|
|
64
|
-
isOrdered: () => isOrdered_default,
|
|
65
|
-
isSameDate: () => isSameDate_default,
|
|
66
|
-
kebabToCamel: () => kebabToCamel_default,
|
|
67
|
-
normaliseImportPath: () => normaliseImportPath,
|
|
68
|
-
normalizeImportPath: () => normalizeImportPath_default,
|
|
69
|
-
omitProperties: () => omitProperties_default,
|
|
70
|
-
paralleliseArrays: () => paralleliseArrays_default,
|
|
71
|
-
parseEmail: () => Email_default,
|
|
72
|
-
parseEnv: () => Env_default,
|
|
73
|
-
parseIntStrict: () => parseIntStrict_default,
|
|
74
|
-
parseUUID: () => UUID_default,
|
|
75
|
-
randomiseArray: () => randomiseArray_default,
|
|
76
|
-
range: () => range_default,
|
|
77
|
-
removeDuplicates: () => removeDuplicates_default,
|
|
78
|
-
removeIndents: () => removeIndents_default,
|
|
79
|
-
stringListToArray: () => stringListToArray_default,
|
|
80
|
-
stringToBoolean: () => stringToBoolean_default,
|
|
81
|
-
stripIndents: () => stripIndents_default,
|
|
82
|
-
truncate: () => truncate_default,
|
|
83
|
-
wait: () => wait_default
|
|
84
|
-
});
|
|
85
|
-
module.exports = __toCommonJS(index_exports);
|
|
86
|
-
|
|
87
|
-
// src/functions/addDaysToDate.ts
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
let path = require("path");
|
|
29
|
+
path = __toESM(path);
|
|
30
|
+
let zod = require("zod");
|
|
31
|
+
zod = __toESM(zod);
|
|
32
|
+
|
|
33
|
+
//#region src/functions/addDaysToDate.ts
|
|
88
34
|
function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement = 1) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
35
|
+
const newDate = currentDate;
|
|
36
|
+
newDate.setDate(newDate.getDate() + dayIncrement);
|
|
37
|
+
return newDate;
|
|
92
38
|
}
|
|
93
39
|
var addDaysToDate_default = addDaysToDate;
|
|
94
40
|
|
|
95
|
-
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/functions/appendSemicolon.ts
|
|
96
43
|
function appendSemicolon(stringToAppendTo) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (stringWithNoTrailingWhitespace === "") {
|
|
102
|
-
return "";
|
|
103
|
-
}
|
|
104
|
-
return stringWithNoTrailingWhitespace[stringWithNoTrailingWhitespace.length - 1] === ";" ? stringWithNoTrailingWhitespace : `${stringWithNoTrailingWhitespace};`;
|
|
44
|
+
if (stringToAppendTo.includes("\n")) throw new Error("MULTIPLE_LINE_ERROR");
|
|
45
|
+
const stringWithNoTrailingWhitespace = stringToAppendTo.trimEnd();
|
|
46
|
+
if (stringWithNoTrailingWhitespace === "") return "";
|
|
47
|
+
return stringWithNoTrailingWhitespace[stringWithNoTrailingWhitespace.length - 1] === ";" ? stringWithNoTrailingWhitespace : `${stringWithNoTrailingWhitespace};`;
|
|
105
48
|
}
|
|
106
49
|
var appendSemicolon_default = appendSemicolon;
|
|
107
50
|
|
|
108
|
-
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/functions/camelToKebab.ts
|
|
109
53
|
function camelToKebab(string) {
|
|
110
|
-
|
|
54
|
+
return string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
111
55
|
}
|
|
112
56
|
var camelToKebab_default = camelToKebab;
|
|
113
57
|
|
|
114
|
-
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/functions/convertFileToBase64.ts
|
|
115
60
|
function convertFileToBase64(file) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
const reader = new FileReader();
|
|
63
|
+
reader.readAsDataURL(file);
|
|
64
|
+
reader.onload = () => {
|
|
65
|
+
if (reader.result === null) {
|
|
66
|
+
reject(/* @__PURE__ */ new Error("FILE_CONVERSION_ERROR"));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
resolve(reader.result);
|
|
70
|
+
};
|
|
71
|
+
reader.onerror = () => {
|
|
72
|
+
reject(/* @__PURE__ */ new Error("FILE_READER_ERROR"));
|
|
73
|
+
};
|
|
74
|
+
});
|
|
130
75
|
}
|
|
131
76
|
var convertFileToBase64_default = convertFileToBase64;
|
|
132
77
|
|
|
133
|
-
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/functions/createFormData.ts
|
|
134
80
|
function getNullableResolutionStrategy(key, strategy) {
|
|
135
|
-
|
|
136
|
-
return (_a = typeof strategy === "object" ? strategy[key] : strategy) != null ? _a : "empty";
|
|
81
|
+
return (typeof strategy === "object" ? strategy[key] : strategy) ?? "empty";
|
|
137
82
|
}
|
|
138
83
|
function createFormData(data, options = {
|
|
139
|
-
|
|
140
|
-
|
|
84
|
+
arrayResolution: "stringify",
|
|
85
|
+
nullableResolution: "empty"
|
|
141
86
|
}) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
} else if (value === void 0 || value === null) {
|
|
189
|
-
resolveNullables(key, value, options);
|
|
190
|
-
} else if (typeof value === "object") {
|
|
191
|
-
if (Array.isArray(value)) {
|
|
192
|
-
if (value.some((item) => {
|
|
193
|
-
return item instanceof Blob;
|
|
194
|
-
}) && (options.arrayResolution === "stringify" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "stringify")) {
|
|
195
|
-
throw new TypeError("CANNOT_STRINGIFY_BLOB");
|
|
196
|
-
}
|
|
197
|
-
if (options.arrayResolution === "multiple" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "multiple") {
|
|
198
|
-
for (const item of value) {
|
|
199
|
-
if ((typeof item === "object" || !item) && !(item instanceof Blob)) {
|
|
200
|
-
throw new TypeError("NON_PRIMITIVE_ARRAY_ITEMS_FOUND");
|
|
201
|
-
}
|
|
202
|
-
if (item instanceof Blob) {
|
|
203
|
-
formData.append(String(key), item);
|
|
204
|
-
} else {
|
|
205
|
-
formData.append(String(key), String(item));
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
formData.append(String(key), JSON.stringify(value));
|
|
212
|
-
} else {
|
|
213
|
-
formData.append(String(key), String(value));
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return formData;
|
|
87
|
+
const formData = new FormData();
|
|
88
|
+
function resolveNullablesByStrategy(key, value, resolutionStrategy) {
|
|
89
|
+
switch (resolutionStrategy) {
|
|
90
|
+
case "empty":
|
|
91
|
+
formData.append(String(key), "");
|
|
92
|
+
break;
|
|
93
|
+
case "stringify":
|
|
94
|
+
formData.append(String(key), JSON.stringify(value));
|
|
95
|
+
break;
|
|
96
|
+
case "omit": break;
|
|
97
|
+
default: throw new TypeError("SLOPPY_PURE_JAVASCRIPT_USER_ERROR");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function resolveNullables(key, value, options$1) {
|
|
101
|
+
if (options$1.nullableResolution) {
|
|
102
|
+
resolveNullablesByStrategy(key, value, getNullableResolutionStrategy(key, options$1.nullableResolution));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (options$1.undefinedResolution || options$1.nullResolution) {
|
|
106
|
+
if (data[key] === void 0 && options$1.undefinedResolution) {
|
|
107
|
+
resolveNullablesByStrategy(key, value, getNullableResolutionStrategy(key, options$1.undefinedResolution));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (data[key] === null && options$1.nullResolution) resolveNullablesByStrategy(key, value, getNullableResolutionStrategy(key, options$1.nullResolution));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const entries = Object.entries(data);
|
|
114
|
+
for (const [key, value] of entries) if (value instanceof Blob) formData.append(String(key), value);
|
|
115
|
+
else if (value === void 0 || value === null) resolveNullables(key, value, options);
|
|
116
|
+
else if (typeof value === "object") {
|
|
117
|
+
if (Array.isArray(value)) {
|
|
118
|
+
if (value.some((item) => {
|
|
119
|
+
return item instanceof Blob;
|
|
120
|
+
}) && (options.arrayResolution === "stringify" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "stringify")) throw new TypeError("CANNOT_STRINGIFY_BLOB");
|
|
121
|
+
if (options.arrayResolution === "multiple" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "multiple") {
|
|
122
|
+
for (const item of value) {
|
|
123
|
+
if ((typeof item === "object" || !item) && !(item instanceof Blob)) throw new TypeError("NON_PRIMITIVE_ARRAY_ITEMS_FOUND");
|
|
124
|
+
if (item instanceof Blob) formData.append(String(key), item);
|
|
125
|
+
else formData.append(String(key), String(item));
|
|
126
|
+
}
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
formData.append(String(key), JSON.stringify(value));
|
|
131
|
+
} else formData.append(String(key), String(value));
|
|
132
|
+
return formData;
|
|
217
133
|
}
|
|
218
134
|
var createFormData_default = createFormData;
|
|
219
135
|
|
|
220
|
-
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/functions/createTemplateStringsArray.ts
|
|
221
138
|
function createTemplateStringsArray(strings) {
|
|
222
|
-
|
|
139
|
+
return Object.assign([...strings], { raw: [...strings] });
|
|
223
140
|
}
|
|
224
141
|
var createTemplateStringsArray_default = createTemplateStringsArray;
|
|
225
142
|
|
|
226
|
-
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/functions/fillArray.ts
|
|
227
145
|
function fillArray(callback, length = 1) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return Promise.all(outputArray);
|
|
236
|
-
}
|
|
237
|
-
return outputArray;
|
|
146
|
+
const outputArray = new Array(length).fill(null).map((_, index) => {
|
|
147
|
+
return callback(index);
|
|
148
|
+
});
|
|
149
|
+
if (outputArray.some((item) => {
|
|
150
|
+
return item instanceof Promise;
|
|
151
|
+
})) return Promise.all(outputArray);
|
|
152
|
+
return outputArray;
|
|
238
153
|
}
|
|
239
154
|
var fillArray_default = fillArray;
|
|
240
155
|
|
|
241
|
-
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/functions/isSameDate.ts
|
|
242
158
|
function isSameDate(firstDate, secondDate) {
|
|
243
|
-
|
|
159
|
+
return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
|
|
244
160
|
}
|
|
245
161
|
var isSameDate_default = isSameDate;
|
|
246
162
|
|
|
247
|
-
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/functions/formatDateAndTime.ts
|
|
248
165
|
function formatDateAndTime(inputDate) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (isSameDate_default(inputDate, today)) {
|
|
256
|
-
return `Today at ${inputTime}`;
|
|
257
|
-
}
|
|
258
|
-
const formattedInputDay = inputDate.getDate().toString().padStart(2, "0");
|
|
259
|
-
const formattedInputMonth = (inputDate.getMonth() + 1).toString().padStart(2, "0");
|
|
260
|
-
const formattedInputYear = inputDate.getFullYear().toString();
|
|
261
|
-
return `${formattedInputDay}/${formattedInputMonth}/${formattedInputYear}, ${inputTime}`;
|
|
166
|
+
const yesterday = addDaysToDate_default(/* @__PURE__ */ new Date(), -1);
|
|
167
|
+
const today = /* @__PURE__ */ new Date();
|
|
168
|
+
const inputTime = `${inputDate.getHours().toString().padStart(2, "0")}:${inputDate.getMinutes().toString().padStart(2, "0")}`;
|
|
169
|
+
if (isSameDate_default(inputDate, yesterday)) return `Yesterday at ${inputTime}`;
|
|
170
|
+
if (isSameDate_default(inputDate, today)) return `Today at ${inputTime}`;
|
|
171
|
+
return `${inputDate.getDate().toString().padStart(2, "0")}/${(inputDate.getMonth() + 1).toString().padStart(2, "0")}/${inputDate.getFullYear().toString()}, ${inputTime}`;
|
|
262
172
|
}
|
|
263
173
|
var formatDateAndTime_default = formatDateAndTime;
|
|
264
174
|
|
|
265
|
-
|
|
266
|
-
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/functions/parseIntStrict.ts
|
|
177
|
+
const IntegerParsingError = /* @__PURE__ */ new TypeError("INTEGER_PARSING_ERROR");
|
|
267
178
|
function parseIntStrict(...[string, radix]) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (radix && radix < 10 && [...trimmedString].some((character) => {
|
|
277
|
-
return parseInt(character) >= radix;
|
|
278
|
-
})) {
|
|
279
|
-
throw IntegerParsingError;
|
|
280
|
-
}
|
|
281
|
-
const parseIntResult = parseInt(trimmedString, radix);
|
|
282
|
-
if (isNaN(parseIntResult)) {
|
|
283
|
-
throw IntegerParsingError;
|
|
284
|
-
}
|
|
285
|
-
return parseIntResult;
|
|
179
|
+
const trimmedString = string.trim();
|
|
180
|
+
if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${String.fromCharCode(87 + radix - 1)}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw IntegerParsingError;
|
|
181
|
+
if (radix && radix < 10 && [...trimmedString].some((character) => {
|
|
182
|
+
return parseInt(character) >= radix;
|
|
183
|
+
})) throw IntegerParsingError;
|
|
184
|
+
const parseIntResult = parseInt(trimmedString, radix);
|
|
185
|
+
if (isNaN(parseIntResult)) throw IntegerParsingError;
|
|
186
|
+
return parseIntResult;
|
|
286
187
|
}
|
|
287
188
|
var parseIntStrict_default = parseIntStrict;
|
|
288
189
|
|
|
289
|
-
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/functions/getRandomNumber.ts
|
|
290
192
|
function getRandomNumber(lowerBound, upperBound) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
193
|
+
const parsedLowerBound = parseIntStrict_default(`${lowerBound}`);
|
|
194
|
+
const parsedUpperBound = parseIntStrict_default(`${upperBound}`);
|
|
195
|
+
return Math.floor(Math.random() * (parsedUpperBound - parsedLowerBound + 1) + parsedLowerBound);
|
|
294
196
|
}
|
|
295
197
|
var getRandomNumber_default = getRandomNumber;
|
|
296
198
|
|
|
297
|
-
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/functions/getRecordKeys.ts
|
|
298
201
|
function getRecordKeys(record) {
|
|
299
|
-
|
|
202
|
+
return Object.keys(record);
|
|
300
203
|
}
|
|
301
204
|
var getRecordKeys_default = getRecordKeys;
|
|
302
205
|
|
|
303
|
-
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/functions/isLeapYear.ts
|
|
304
208
|
function isLeapYear(year) {
|
|
305
|
-
|
|
306
|
-
|
|
209
|
+
const parsedYear = parseIntStrict_default(`${year}`);
|
|
210
|
+
return parsedYear % 4 === 0 && parsedYear % 100 !== 0 || parsedYear % 400 === 0;
|
|
307
211
|
}
|
|
308
212
|
var isLeapYear_default = isLeapYear;
|
|
309
213
|
|
|
310
|
-
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/functions/isMonthlyMultiple.ts
|
|
311
216
|
function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
217
|
+
if ([
|
|
218
|
+
3,
|
|
219
|
+
5,
|
|
220
|
+
8,
|
|
221
|
+
10
|
|
222
|
+
].includes(firstDate.getMonth())) return firstDate.getDate() === 30 && secondDate.getDate() === 31;
|
|
223
|
+
return false;
|
|
316
224
|
}
|
|
317
225
|
function nonLeapYearFebruaryChecks(firstDate, secondDate) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
226
|
+
if (firstDate.getMonth() === 1) {
|
|
227
|
+
if (!isLeapYear_default(firstDate.getFullYear()) && firstDate.getDate() === 28) return [
|
|
228
|
+
28,
|
|
229
|
+
29,
|
|
230
|
+
30,
|
|
231
|
+
31
|
|
232
|
+
].includes(secondDate.getDate());
|
|
233
|
+
}
|
|
234
|
+
return false;
|
|
324
235
|
}
|
|
325
236
|
function leapYearFebruaryChecks(firstDate, secondDate) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
237
|
+
if (firstDate.getMonth() === 1) {
|
|
238
|
+
if (isLeapYear_default(firstDate.getFullYear()) && firstDate.getDate() === 29) return [
|
|
239
|
+
29,
|
|
240
|
+
30,
|
|
241
|
+
31
|
|
242
|
+
].includes(secondDate.getDate());
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
332
245
|
}
|
|
333
246
|
function isMonthlyMultiple(firstDate, secondDate) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
return true;
|
|
339
|
-
}
|
|
340
|
-
if (leapYearFebruaryChecks(firstDate, secondDate) || leapYearFebruaryChecks(secondDate, firstDate)) {
|
|
341
|
-
return true;
|
|
342
|
-
}
|
|
343
|
-
return firstDate.getDate() === secondDate.getDate();
|
|
247
|
+
if (endOfMonthChecksButNotFebruary(firstDate, secondDate) || endOfMonthChecksButNotFebruary(secondDate, firstDate)) return true;
|
|
248
|
+
if (nonLeapYearFebruaryChecks(firstDate, secondDate) || nonLeapYearFebruaryChecks(secondDate, firstDate)) return true;
|
|
249
|
+
if (leapYearFebruaryChecks(firstDate, secondDate) || leapYearFebruaryChecks(secondDate, firstDate)) return true;
|
|
250
|
+
return firstDate.getDate() === secondDate.getDate();
|
|
344
251
|
}
|
|
345
252
|
var isMonthlyMultiple_default = isMonthlyMultiple;
|
|
346
253
|
|
|
347
|
-
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/functions/isOrdered.ts
|
|
348
256
|
function isOrdered(array) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return true;
|
|
257
|
+
const newArray = [...array];
|
|
258
|
+
newArray.sort();
|
|
259
|
+
for (const index in newArray) if (newArray[index] !== array[index]) return false;
|
|
260
|
+
return true;
|
|
357
261
|
}
|
|
358
262
|
var isOrdered_default = isOrdered;
|
|
359
263
|
|
|
360
|
-
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/functions/kebabToCamel.ts
|
|
361
266
|
function kebabToCamel(string, options) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
skip = true;
|
|
387
|
-
} else {
|
|
388
|
-
outputString += string[index];
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return outputString;
|
|
267
|
+
if (string !== string.toLowerCase()) throw new Error("INVALID_KEBAB_CASE_INPUT");
|
|
268
|
+
if (string.startsWith("-") || string.endsWith("-") || string.includes("--")) throw new Error("INVALID_KEBAB_CASE_INPUT");
|
|
269
|
+
let outputString = "";
|
|
270
|
+
let skip = false;
|
|
271
|
+
for (const stringIndex in [...string]) {
|
|
272
|
+
if (skip) {
|
|
273
|
+
skip = false;
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
const index = parseIntStrict_default(stringIndex);
|
|
277
|
+
if (index === 0 && options?.startWithUpper) {
|
|
278
|
+
outputString += string[index].toUpperCase();
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
if (index === string.length - 1) {
|
|
282
|
+
outputString += string[index];
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
if (string[index] === "-" && /^[a-zA-Z]+$/.test(string[index + 1])) {
|
|
286
|
+
outputString += string[index + 1].toUpperCase();
|
|
287
|
+
skip = true;
|
|
288
|
+
} else outputString += string[index];
|
|
289
|
+
}
|
|
290
|
+
return outputString;
|
|
392
291
|
}
|
|
393
292
|
var kebabToCamel_default = kebabToCamel;
|
|
394
293
|
|
|
395
|
-
|
|
396
|
-
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/functions/normalizeImportPath.ts
|
|
397
296
|
function normalizeImportPath(importPath) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
return normalizedPath;
|
|
297
|
+
const normalizedPath = path.default.posix.normalize(importPath);
|
|
298
|
+
if (importPath.startsWith("./") && !normalizedPath.startsWith("./")) return `./${normalizedPath}`;
|
|
299
|
+
return normalizedPath;
|
|
403
300
|
}
|
|
404
|
-
|
|
301
|
+
const normaliseImportPath = normalizeImportPath;
|
|
405
302
|
var normalizeImportPath_default = normalizeImportPath;
|
|
406
303
|
|
|
407
|
-
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/functions/omitProperties.ts
|
|
408
306
|
function omitProperties(object, keysToOmit) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return outputObject;
|
|
307
|
+
const outputObject = { ...object };
|
|
308
|
+
(Array.isArray(keysToOmit) ? keysToOmit : [keysToOmit]).forEach((key) => {
|
|
309
|
+
delete outputObject[key];
|
|
310
|
+
});
|
|
311
|
+
return outputObject;
|
|
415
312
|
}
|
|
416
313
|
var omitProperties_default = omitProperties;
|
|
417
314
|
|
|
418
|
-
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/functions/paralleliseArrays.ts
|
|
419
317
|
function paralleliseArrays(firstArray, secondArray) {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
return outputArray;
|
|
318
|
+
const outputArray = [];
|
|
319
|
+
for (let i = 0; i < firstArray.length; i++) outputArray.push([firstArray[i], secondArray[i]]);
|
|
320
|
+
return outputArray;
|
|
425
321
|
}
|
|
426
322
|
var paralleliseArrays_default = paralleliseArrays;
|
|
427
323
|
|
|
428
|
-
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region src/types/APIError.ts
|
|
326
|
+
const httpErrorCodeLookup = {
|
|
327
|
+
400: "BAD_REQUEST",
|
|
328
|
+
401: "UNAUTHORISED",
|
|
329
|
+
403: "FORBIDDEN",
|
|
330
|
+
404: "NOT_FOUND",
|
|
331
|
+
418: "I_AM_A_TEAPOT",
|
|
332
|
+
500: "INTERNAL_SERVER_ERROR"
|
|
333
|
+
};
|
|
334
|
+
var APIError = class extends Error {
|
|
335
|
+
status;
|
|
336
|
+
constructor(status = 500, message, options) {
|
|
337
|
+
super(message, options);
|
|
338
|
+
this.status = status;
|
|
339
|
+
if (message) this.message = message;
|
|
340
|
+
else this.message = httpErrorCodeLookup[this.status] ?? "API_ERROR";
|
|
341
|
+
Object.defineProperty(this, "message", { enumerable: true });
|
|
342
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
343
|
+
}
|
|
344
|
+
static check(input) {
|
|
345
|
+
const data = input;
|
|
346
|
+
return typeof data === "object" && data !== null && typeof data?.status === "number" && typeof data?.message === "string";
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
var APIError_default = APIError;
|
|
350
|
+
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/types/DataError.ts
|
|
353
|
+
var DataError = class extends Error {
|
|
354
|
+
data;
|
|
355
|
+
code;
|
|
356
|
+
/** @param data - The data that caused the error. */
|
|
357
|
+
/** @param message - A human-readable error message (e.g. The data provided is invalid). */
|
|
358
|
+
/** @param code - A standardised code (e.g. UNEXPECTED_DATA). */
|
|
359
|
+
/** @param options - Extra options to pass to super Error constructor. */
|
|
360
|
+
constructor(data, message = "The data provided is invalid", code = "INVALID_DATA", options) {
|
|
361
|
+
super(message, options);
|
|
362
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, new.target);
|
|
363
|
+
this.name = new.target.name;
|
|
364
|
+
this.code = code;
|
|
365
|
+
this.data = data;
|
|
366
|
+
Object.defineProperty(this, "message", { enumerable: true });
|
|
367
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
368
|
+
}
|
|
369
|
+
static check(input) {
|
|
370
|
+
const data = input;
|
|
371
|
+
return typeof data === "object" && data !== null && typeof data.message === "string" && typeof data.code === "string" && "data" in data;
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
var DataError_default = DataError;
|
|
375
|
+
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/types/Email.ts
|
|
378
|
+
const emailSchema = zod.default.email().brand();
|
|
379
|
+
function parseEmail(data) {
|
|
380
|
+
return emailSchema.parse(data);
|
|
381
|
+
}
|
|
382
|
+
var Email_default = parseEmail;
|
|
383
|
+
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/types/Env.ts
|
|
386
|
+
const envSchema = zod.z.enum([
|
|
387
|
+
"test",
|
|
388
|
+
"development",
|
|
389
|
+
"production"
|
|
390
|
+
]);
|
|
391
|
+
function parseEnv(data = "development") {
|
|
392
|
+
return envSchema.parse(data);
|
|
393
|
+
}
|
|
394
|
+
var Env_default = parseEnv;
|
|
395
|
+
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/types/UUID.ts
|
|
398
|
+
const uuidSchema = zod.default.uuid().brand();
|
|
399
|
+
function parseUUID(UUID) {
|
|
400
|
+
return uuidSchema.parse(UUID);
|
|
401
|
+
}
|
|
402
|
+
var UUID_default = parseUUID;
|
|
403
|
+
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/functions/parseZodSchema.ts
|
|
406
|
+
function parseZodSchema(schema, data) {
|
|
407
|
+
const parsedResult = schema.safeParse(data);
|
|
408
|
+
if (!parsedResult.success) throw new DataError_default(data);
|
|
409
|
+
return parsedResult.data;
|
|
410
|
+
}
|
|
411
|
+
var parseZodSchema_default = parseZodSchema;
|
|
412
|
+
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/functions/randomiseArray.ts
|
|
429
415
|
function randomiseArray(array) {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
416
|
+
const mutableArray = [...array];
|
|
417
|
+
const outputArray = [];
|
|
418
|
+
do {
|
|
419
|
+
const indexToRemove = getRandomNumber_default(0, mutableArray.length - 1);
|
|
420
|
+
outputArray.push(mutableArray.splice(indexToRemove, 1)[0]);
|
|
421
|
+
} while (mutableArray.length > 0);
|
|
422
|
+
return outputArray;
|
|
437
423
|
}
|
|
438
424
|
var randomiseArray_default = randomiseArray;
|
|
439
425
|
|
|
440
|
-
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/functions/range.ts
|
|
441
428
|
function range(start, stop, step = 1) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
} else if (step < 0) {
|
|
453
|
-
if (start < stop) {
|
|
454
|
-
throw new Error("INVALID_BOUNDARIES");
|
|
455
|
-
}
|
|
456
|
-
for (let i = start; i > stop; i += step) {
|
|
457
|
-
numbers.push(i);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
return numbers;
|
|
429
|
+
const numbers = [];
|
|
430
|
+
if (step === 0) throw new Error("ZERO_STEP_SIZE_NOT_ALLOWED");
|
|
431
|
+
else if (step > 0) {
|
|
432
|
+
if (start > stop) throw new Error("INVALID_BOUNDARIES");
|
|
433
|
+
for (let i = start; i < stop; i += step) numbers.push(i);
|
|
434
|
+
} else if (step < 0) {
|
|
435
|
+
if (start < stop) throw new Error("INVALID_BOUNDARIES");
|
|
436
|
+
for (let i = start; i > stop; i += step) numbers.push(i);
|
|
437
|
+
}
|
|
438
|
+
return numbers;
|
|
461
439
|
}
|
|
462
440
|
var range_default = range;
|
|
463
441
|
|
|
464
|
-
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/functions/removeDuplicates.ts
|
|
465
444
|
function removeDuplicates(array) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
outputArray.push(item);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
return outputArray;
|
|
445
|
+
const outputArray = [];
|
|
446
|
+
for (const item of array) if (!outputArray.includes(item)) outputArray.push(item);
|
|
447
|
+
return outputArray;
|
|
473
448
|
}
|
|
474
449
|
var removeDuplicates_default = removeDuplicates;
|
|
475
450
|
|
|
476
|
-
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/functions/stringListToArray.ts
|
|
477
453
|
function stringListToArray(stringList, { separator = ",", trimWhitespace = true } = {}) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
return item.trim();
|
|
484
|
-
}) : arrayList;
|
|
454
|
+
if (trimWhitespace && stringList.trim() === "") return [];
|
|
455
|
+
const arrayList = stringList.split(separator ?? "");
|
|
456
|
+
return trimWhitespace ? arrayList.map((item) => {
|
|
457
|
+
return item.trim();
|
|
458
|
+
}) : arrayList;
|
|
485
459
|
}
|
|
486
460
|
var stringListToArray_default = stringListToArray;
|
|
487
461
|
|
|
488
|
-
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region src/functions/stringToBoolean.ts
|
|
489
464
|
function stringToBoolean(inputString) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}
|
|
494
|
-
return normalisedString === "true";
|
|
465
|
+
const normalisedString = inputString.toLowerCase();
|
|
466
|
+
if (normalisedString !== "true" && normalisedString !== "false") throw new TypeError("INVALID_BOOLEAN_STRING");
|
|
467
|
+
return normalisedString === "true";
|
|
495
468
|
}
|
|
496
469
|
var stringToBoolean_default = stringToBoolean;
|
|
497
470
|
|
|
498
|
-
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region src/functions/truncate.ts
|
|
499
473
|
function truncate(stringToTruncate, maxLength = 5) {
|
|
500
|
-
|
|
474
|
+
return stringToTruncate.length > maxLength ? `${stringToTruncate.slice(0, maxLength)}...` : stringToTruncate;
|
|
501
475
|
}
|
|
502
476
|
var truncate_default = truncate;
|
|
503
477
|
|
|
504
|
-
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region src/functions/wait.ts
|
|
505
480
|
function wait(seconds) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
481
|
+
return new Promise((resolve, _) => {
|
|
482
|
+
setTimeout(() => {
|
|
483
|
+
resolve();
|
|
484
|
+
}, seconds * 1e3);
|
|
485
|
+
});
|
|
511
486
|
}
|
|
512
487
|
var wait_default = wait;
|
|
513
488
|
|
|
514
|
-
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region src/functions/taggedTemplate/interpolate.ts
|
|
515
491
|
function interpolate(strings, ...interpolations) {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
return result;
|
|
492
|
+
let result = "";
|
|
493
|
+
for (const [string, interpolation = ""] of paralleliseArrays_default(strings, interpolations)) result += string + interpolation;
|
|
494
|
+
return result;
|
|
521
495
|
}
|
|
522
496
|
var interpolate_default = interpolate;
|
|
523
497
|
|
|
524
|
-
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region src/functions/taggedTemplate/interpolateObjects.ts
|
|
525
500
|
function interpolateObjects(strings, ...values) {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
}
|
|
533
|
-
return result;
|
|
501
|
+
let result = "";
|
|
502
|
+
for (let i = 0; i < strings.length; i++) {
|
|
503
|
+
result += strings[i];
|
|
504
|
+
if (i !== strings.length - 1) result += values[i] && typeof values[i] === "object" ? JSON.stringify(values[i]) : values[i];
|
|
505
|
+
}
|
|
506
|
+
return result;
|
|
534
507
|
}
|
|
535
508
|
var interpolateObjects_default = interpolateObjects;
|
|
536
509
|
|
|
537
|
-
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region src/functions/taggedTemplate/removeIndents.ts
|
|
538
512
|
function calculateTabSize(line, whitespaceLength) {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
const tabSize = line.length - (trimmedString.length + whitespaceLength);
|
|
545
|
-
return tabSize < 0 ? 0 : tabSize;
|
|
513
|
+
const potentialWhitespacePart = line.slice(0, whitespaceLength);
|
|
514
|
+
const trimmedString = line.trimStart();
|
|
515
|
+
if (potentialWhitespacePart.trim() !== "") return 0;
|
|
516
|
+
const tabSize = line.length - (trimmedString.length + whitespaceLength);
|
|
517
|
+
return tabSize < 0 ? 0 : tabSize;
|
|
546
518
|
}
|
|
547
519
|
function getWhitespaceLength(lines) {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
520
|
+
const [firstNonEmptyLine] = lines.filter((line) => {
|
|
521
|
+
return line.trim() !== "";
|
|
522
|
+
});
|
|
523
|
+
return firstNonEmptyLine.length - firstNonEmptyLine.trimStart().length;
|
|
552
524
|
}
|
|
553
525
|
function reduceLines(lines, { preserveTabs = true }) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
526
|
+
const slicedLines = lines.slice(1);
|
|
527
|
+
const isFirstLineEmpty = lines[0].trim() === "";
|
|
528
|
+
const whitespaceLength = getWhitespaceLength(isFirstLineEmpty ? lines : slicedLines);
|
|
529
|
+
return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
|
|
530
|
+
const tabSize = calculateTabSize(line, whitespaceLength);
|
|
531
|
+
return (preserveTabs ? fillArray_default(() => {
|
|
532
|
+
return " ";
|
|
533
|
+
}, tabSize).join("") : "") + line.trimStart();
|
|
534
|
+
}).join("\n");
|
|
563
535
|
}
|
|
564
536
|
function removeIndents(first, ...args) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
const fullString = interpolate_default(strings, ...interpolations);
|
|
575
|
-
return reduceLines(fullString.split("\n"), options);
|
|
537
|
+
if (typeof first === "object" && first !== null && !Array.isArray(first)) {
|
|
538
|
+
const options$1 = first;
|
|
539
|
+
return (strings$1, ...interpolations) => {
|
|
540
|
+
return removeIndents(strings$1, ...interpolations, options$1);
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
const strings = first;
|
|
544
|
+
const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
|
|
545
|
+
return reduceLines(interpolate_default(strings, ...[...args]).split("\n"), options);
|
|
576
546
|
}
|
|
577
547
|
var removeIndents_default = removeIndents;
|
|
578
548
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
404: "NOT_FOUND",
|
|
618
|
-
/* Supporting this one too because it's funny. You'll never use it in practice because
|
|
619
|
-
why would an error give a teapot, but it's funny. Do not question me. */
|
|
620
|
-
418: "I_AM_A_TEAPOT",
|
|
621
|
-
500: "INTERNAL_SERVER_ERROR"
|
|
622
|
-
};
|
|
623
|
-
var APIError = class extends Error {
|
|
624
|
-
constructor(status = 500, message, options) {
|
|
625
|
-
var _a;
|
|
626
|
-
super(message, options);
|
|
627
|
-
__publicField(this, "status");
|
|
628
|
-
this.status = status;
|
|
629
|
-
if (message) {
|
|
630
|
-
this.message = message;
|
|
631
|
-
} else {
|
|
632
|
-
this.message = (_a = httpErrorCodeLookup[this.status]) != null ? _a : "API_ERROR";
|
|
633
|
-
}
|
|
634
|
-
Object.defineProperty(this, "message", { enumerable: true });
|
|
635
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
636
|
-
}
|
|
637
|
-
static check(input) {
|
|
638
|
-
const data = input;
|
|
639
|
-
return typeof data === "object" && data !== null && typeof (data == null ? void 0 : data.status) === "number" && typeof (data == null ? void 0 : data.message) === "string";
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
var APIError_default = APIError;
|
|
643
|
-
|
|
644
|
-
// src/types/Email.ts
|
|
645
|
-
var import_zod = __toESM(require("zod"), 1);
|
|
646
|
-
var emailSchema = import_zod.default.email().brand();
|
|
647
|
-
function parseEmail(data) {
|
|
648
|
-
return emailSchema.parse(data);
|
|
649
|
-
}
|
|
650
|
-
var Email_default = parseEmail;
|
|
651
|
-
|
|
652
|
-
// src/types/Env.ts
|
|
653
|
-
var import_zod2 = require("zod");
|
|
654
|
-
var envSchema = import_zod2.z.enum(["test", "development", "production"]);
|
|
655
|
-
function parseEnv(data = "development") {
|
|
656
|
-
return envSchema.parse(data);
|
|
657
|
-
}
|
|
658
|
-
var Env_default = parseEnv;
|
|
659
|
-
|
|
660
|
-
// src/types/UUID.ts
|
|
661
|
-
var import_zod3 = __toESM(require("zod"), 1);
|
|
662
|
-
var uuidSchema = import_zod3.default.uuid().brand();
|
|
663
|
-
function parseUUID(UUID) {
|
|
664
|
-
return uuidSchema.parse(UUID);
|
|
665
|
-
}
|
|
666
|
-
var UUID_default = parseUUID;
|
|
667
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
668
|
-
0 && (module.exports = {
|
|
669
|
-
APIError,
|
|
670
|
-
addDaysToDate,
|
|
671
|
-
appendSemicolon,
|
|
672
|
-
camelToKebab,
|
|
673
|
-
convertFileToBase64,
|
|
674
|
-
createFormData,
|
|
675
|
-
createTemplateStringsArray,
|
|
676
|
-
fillArray,
|
|
677
|
-
formatDateAndTime,
|
|
678
|
-
getRandomNumber,
|
|
679
|
-
getRecordKeys,
|
|
680
|
-
httpErrorCodeLookup,
|
|
681
|
-
interpolate,
|
|
682
|
-
interpolateObjects,
|
|
683
|
-
isLeapYear,
|
|
684
|
-
isMonthlyMultiple,
|
|
685
|
-
isOrdered,
|
|
686
|
-
isSameDate,
|
|
687
|
-
kebabToCamel,
|
|
688
|
-
normaliseImportPath,
|
|
689
|
-
normalizeImportPath,
|
|
690
|
-
omitProperties,
|
|
691
|
-
paralleliseArrays,
|
|
692
|
-
parseEmail,
|
|
693
|
-
parseEnv,
|
|
694
|
-
parseIntStrict,
|
|
695
|
-
parseUUID,
|
|
696
|
-
randomiseArray,
|
|
697
|
-
range,
|
|
698
|
-
removeDuplicates,
|
|
699
|
-
removeIndents,
|
|
700
|
-
stringListToArray,
|
|
701
|
-
stringToBoolean,
|
|
702
|
-
stripIndents,
|
|
703
|
-
truncate,
|
|
704
|
-
wait
|
|
705
|
-
});
|
|
549
|
+
//#endregion
|
|
550
|
+
exports.APIError = APIError_default;
|
|
551
|
+
exports.DataError = DataError_default;
|
|
552
|
+
exports.addDaysToDate = addDaysToDate_default;
|
|
553
|
+
exports.appendSemicolon = appendSemicolon_default;
|
|
554
|
+
exports.camelToKebab = camelToKebab_default;
|
|
555
|
+
exports.convertFileToBase64 = convertFileToBase64_default;
|
|
556
|
+
exports.createFormData = createFormData_default;
|
|
557
|
+
exports.createTemplateStringsArray = createTemplateStringsArray_default;
|
|
558
|
+
exports.fillArray = fillArray_default;
|
|
559
|
+
exports.formatDateAndTime = formatDateAndTime_default;
|
|
560
|
+
exports.getRandomNumber = getRandomNumber_default;
|
|
561
|
+
exports.getRecordKeys = getRecordKeys_default;
|
|
562
|
+
exports.httpErrorCodeLookup = httpErrorCodeLookup;
|
|
563
|
+
exports.interpolate = interpolate_default;
|
|
564
|
+
exports.interpolateObjects = interpolateObjects_default;
|
|
565
|
+
exports.isLeapYear = isLeapYear_default;
|
|
566
|
+
exports.isMonthlyMultiple = isMonthlyMultiple_default;
|
|
567
|
+
exports.isOrdered = isOrdered_default;
|
|
568
|
+
exports.isSameDate = isSameDate_default;
|
|
569
|
+
exports.kebabToCamel = kebabToCamel_default;
|
|
570
|
+
exports.normaliseImportPath = normaliseImportPath;
|
|
571
|
+
exports.normalizeImportPath = normalizeImportPath_default;
|
|
572
|
+
exports.omitProperties = omitProperties_default;
|
|
573
|
+
exports.paralleliseArrays = paralleliseArrays_default;
|
|
574
|
+
exports.parseEmail = Email_default;
|
|
575
|
+
exports.parseEnv = Env_default;
|
|
576
|
+
exports.parseIntStrict = parseIntStrict_default;
|
|
577
|
+
exports.parseUUID = UUID_default;
|
|
578
|
+
exports.parseZodSchema = parseZodSchema_default;
|
|
579
|
+
exports.randomiseArray = randomiseArray_default;
|
|
580
|
+
exports.range = range_default;
|
|
581
|
+
exports.removeDuplicates = removeDuplicates_default;
|
|
582
|
+
exports.removeIndents = removeIndents_default;
|
|
583
|
+
exports.stringListToArray = stringListToArray_default;
|
|
584
|
+
exports.stringToBoolean = stringToBoolean_default;
|
|
585
|
+
exports.truncate = truncate_default;
|
|
586
|
+
exports.wait = wait_default;
|