@heyform-inc/utils 1.2.2 → 1.3.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.d.mts +157 -14
- package/dist/index.d.ts +157 -14
- package/dist/index.js +296 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -58
- package/dist/index.mjs.map +1 -1
- package/package.json +48 -30
package/dist/index.js
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
var deepObjectDiff = require('deep-object-diff');
|
|
4
4
|
var qs = require('qs');
|
|
5
|
-
var
|
|
5
|
+
var _isEmail = require('validator/lib/isEmail');
|
|
6
6
|
var _isFQDN = require('validator/lib/isFQDN');
|
|
7
7
|
var _isNumeric = require('validator/lib/isNumeric');
|
|
8
|
-
var _isEmail = require('validator/lib/isEmail');
|
|
9
8
|
var _isURL = require('validator/lib/isURL');
|
|
9
|
+
var _isUUID = require('validator/lib/isUUID');
|
|
10
10
|
var _clone = require('clone');
|
|
11
|
+
var clsx$1 = require('clsx');
|
|
12
|
+
var tailwindMerge = require('tailwind-merge');
|
|
11
13
|
var htmlToText$1 = require('html-to-text');
|
|
12
|
-
var _ms = require('ms');
|
|
13
14
|
var _dayjs = require('dayjs');
|
|
15
|
+
var _ms = require('ms');
|
|
14
16
|
var nanoid$1 = require('nanoid');
|
|
15
17
|
var objectPath = require('object-path');
|
|
16
18
|
var fastEquals = require('fast-equals');
|
|
@@ -38,14 +40,14 @@ function _interopNamespace(e) {
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
var qs__default = /*#__PURE__*/_interopDefault(qs);
|
|
41
|
-
var
|
|
43
|
+
var _isEmail__default = /*#__PURE__*/_interopDefault(_isEmail);
|
|
42
44
|
var _isFQDN__default = /*#__PURE__*/_interopDefault(_isFQDN);
|
|
43
45
|
var _isNumeric__default = /*#__PURE__*/_interopDefault(_isNumeric);
|
|
44
|
-
var _isEmail__default = /*#__PURE__*/_interopDefault(_isEmail);
|
|
45
46
|
var _isURL__default = /*#__PURE__*/_interopDefault(_isURL);
|
|
47
|
+
var _isUUID__default = /*#__PURE__*/_interopDefault(_isUUID);
|
|
46
48
|
var _clone__default = /*#__PURE__*/_interopDefault(_clone);
|
|
47
|
-
var _ms__default = /*#__PURE__*/_interopDefault(_ms);
|
|
48
49
|
var _dayjs__default = /*#__PURE__*/_interopDefault(_dayjs);
|
|
50
|
+
var _ms__default = /*#__PURE__*/_interopDefault(_ms);
|
|
49
51
|
var objectPath__namespace = /*#__PURE__*/_interopNamespace(objectPath);
|
|
50
52
|
var slug__default = /*#__PURE__*/_interopDefault(slug);
|
|
51
53
|
|
|
@@ -303,6 +305,9 @@ function formatBytes(value) {
|
|
|
303
305
|
function clone(obj) {
|
|
304
306
|
return _clone__default.default(obj);
|
|
305
307
|
}
|
|
308
|
+
function clsx(...inputs) {
|
|
309
|
+
return tailwindMerge.twMerge(clsx$1.clsx(inputs));
|
|
310
|
+
}
|
|
306
311
|
|
|
307
312
|
// src/color.ts
|
|
308
313
|
var HEX_REGEX = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
|
|
@@ -382,9 +387,7 @@ function alphaHexToRgb(hex, alpha2, backgroundHex) {
|
|
|
382
387
|
const backgroundRgb = hexToRgb(backgroundHex);
|
|
383
388
|
return hexRgb.map((color, index) => {
|
|
384
389
|
return colorRange(
|
|
385
|
-
Math.floor(
|
|
386
|
-
colorRange(color) * alpha2 + colorRange(backgroundRgb[index]) * (1 - alpha2)
|
|
387
|
-
)
|
|
390
|
+
Math.floor(colorRange(color) * alpha2 + colorRange(backgroundRgb[index]) * (1 - alpha2))
|
|
388
391
|
);
|
|
389
392
|
});
|
|
390
393
|
}
|
|
@@ -548,13 +551,15 @@ function ms(arg) {
|
|
|
548
551
|
}
|
|
549
552
|
var toSecond = hs;
|
|
550
553
|
var toMillisecond = ms;
|
|
554
|
+
|
|
555
|
+
// src/date.ts
|
|
551
556
|
function timestamp() {
|
|
552
557
|
return Math.floor(Date.now() / 1e3);
|
|
553
558
|
}
|
|
554
559
|
var dayjs = _dayjs__default.default;
|
|
555
560
|
var date = dayjs;
|
|
556
561
|
function unixDate(t) {
|
|
557
|
-
return
|
|
562
|
+
return dayjs.unix(t);
|
|
558
563
|
}
|
|
559
564
|
function isDateExpired(start, end, expire) {
|
|
560
565
|
return end - start > hs(expire);
|
|
@@ -569,6 +574,217 @@ function datePeriod(start, value = 1, unit = "month") {
|
|
|
569
574
|
return unixDate(start).add(value, unit).unix();
|
|
570
575
|
}
|
|
571
576
|
|
|
577
|
+
// src/error.ts
|
|
578
|
+
var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
|
|
579
|
+
HttpStatus2[HttpStatus2["CONTINUE"] = 100] = "CONTINUE";
|
|
580
|
+
HttpStatus2[HttpStatus2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
581
|
+
HttpStatus2[HttpStatus2["PROCESSING"] = 102] = "PROCESSING";
|
|
582
|
+
HttpStatus2[HttpStatus2["EARLYHINTS"] = 103] = "EARLYHINTS";
|
|
583
|
+
HttpStatus2[HttpStatus2["OK"] = 200] = "OK";
|
|
584
|
+
HttpStatus2[HttpStatus2["CREATED"] = 201] = "CREATED";
|
|
585
|
+
HttpStatus2[HttpStatus2["ACCEPTED"] = 202] = "ACCEPTED";
|
|
586
|
+
HttpStatus2[HttpStatus2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
587
|
+
HttpStatus2[HttpStatus2["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
588
|
+
HttpStatus2[HttpStatus2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
589
|
+
HttpStatus2[HttpStatus2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
590
|
+
HttpStatus2[HttpStatus2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
591
|
+
HttpStatus2[HttpStatus2["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
|
|
592
|
+
HttpStatus2[HttpStatus2["CONTENT_DIFFERENT"] = 210] = "CONTENT_DIFFERENT";
|
|
593
|
+
HttpStatus2[HttpStatus2["AMBIGUOUS"] = 300] = "AMBIGUOUS";
|
|
594
|
+
HttpStatus2[HttpStatus2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
595
|
+
HttpStatus2[HttpStatus2["FOUND"] = 302] = "FOUND";
|
|
596
|
+
HttpStatus2[HttpStatus2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
597
|
+
HttpStatus2[HttpStatus2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
598
|
+
HttpStatus2[HttpStatus2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
599
|
+
HttpStatus2[HttpStatus2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
600
|
+
HttpStatus2[HttpStatus2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
601
|
+
HttpStatus2[HttpStatus2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
602
|
+
HttpStatus2[HttpStatus2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
603
|
+
HttpStatus2[HttpStatus2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
604
|
+
HttpStatus2[HttpStatus2["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
605
|
+
HttpStatus2[HttpStatus2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
606
|
+
HttpStatus2[HttpStatus2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
607
|
+
HttpStatus2[HttpStatus2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
608
|
+
HttpStatus2[HttpStatus2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
609
|
+
HttpStatus2[HttpStatus2["CONFLICT"] = 409] = "CONFLICT";
|
|
610
|
+
HttpStatus2[HttpStatus2["GONE"] = 410] = "GONE";
|
|
611
|
+
HttpStatus2[HttpStatus2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
612
|
+
HttpStatus2[HttpStatus2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
613
|
+
HttpStatus2[HttpStatus2["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
614
|
+
HttpStatus2[HttpStatus2["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
615
|
+
HttpStatus2[HttpStatus2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
616
|
+
HttpStatus2[HttpStatus2["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
617
|
+
HttpStatus2[HttpStatus2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
618
|
+
HttpStatus2[HttpStatus2["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
619
|
+
HttpStatus2[HttpStatus2["MISDIRECTED"] = 421] = "MISDIRECTED";
|
|
620
|
+
HttpStatus2[HttpStatus2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
621
|
+
HttpStatus2[HttpStatus2["LOCKED"] = 423] = "LOCKED";
|
|
622
|
+
HttpStatus2[HttpStatus2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
623
|
+
HttpStatus2[HttpStatus2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
624
|
+
HttpStatus2[HttpStatus2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
625
|
+
HttpStatus2[HttpStatus2["UNRECOVERABLE_ERROR"] = 456] = "UNRECOVERABLE_ERROR";
|
|
626
|
+
HttpStatus2[HttpStatus2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
627
|
+
HttpStatus2[HttpStatus2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
628
|
+
HttpStatus2[HttpStatus2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
629
|
+
HttpStatus2[HttpStatus2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
630
|
+
HttpStatus2[HttpStatus2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
631
|
+
HttpStatus2[HttpStatus2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
632
|
+
HttpStatus2[HttpStatus2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
633
|
+
HttpStatus2[HttpStatus2["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
634
|
+
return HttpStatus2;
|
|
635
|
+
})(HttpStatus || {});
|
|
636
|
+
var HttpError = class extends Error {
|
|
637
|
+
constructor(message, { status, code, errors }) {
|
|
638
|
+
super(message);
|
|
639
|
+
this.name = "HttpError";
|
|
640
|
+
Object.defineProperty(this, "status", {
|
|
641
|
+
value: status ?? 500 /* INTERNAL_SERVER_ERROR */,
|
|
642
|
+
writable: false,
|
|
643
|
+
enumerable: true,
|
|
644
|
+
configurable: false
|
|
645
|
+
});
|
|
646
|
+
Object.defineProperty(this, "code", {
|
|
647
|
+
value: code || "HTTP_ERROR",
|
|
648
|
+
writable: false,
|
|
649
|
+
enumerable: true,
|
|
650
|
+
configurable: false
|
|
651
|
+
});
|
|
652
|
+
Object.defineProperty(this, "errors", {
|
|
653
|
+
value: errors,
|
|
654
|
+
writable: false,
|
|
655
|
+
enumerable: true,
|
|
656
|
+
configurable: false
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
getStatus() {
|
|
660
|
+
return this.status;
|
|
661
|
+
}
|
|
662
|
+
getCode() {
|
|
663
|
+
return this.code;
|
|
664
|
+
}
|
|
665
|
+
getErrors() {
|
|
666
|
+
return this.errors;
|
|
667
|
+
}
|
|
668
|
+
toJSON() {
|
|
669
|
+
return {
|
|
670
|
+
status: this.status,
|
|
671
|
+
code: this.code,
|
|
672
|
+
message: this.message,
|
|
673
|
+
errors: this.errors
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
var BadGatewayError = class extends HttpError {
|
|
678
|
+
constructor(message = "Bad Gateway", code = "BAD_GATEWAY", errors) {
|
|
679
|
+
super(message, { status: 502 /* BAD_GATEWAY */, code, errors });
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
var BadRequestError = class extends HttpError {
|
|
683
|
+
constructor(message = "Bad Request", code = "BAD_REQUEST", errors) {
|
|
684
|
+
super(message, { status: 400 /* BAD_REQUEST */, code, errors });
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
var ConflictError = class extends HttpError {
|
|
688
|
+
constructor(message = "Conflict", code = "CONFLICT", errors) {
|
|
689
|
+
super(message, { status: 409 /* CONFLICT */, code, errors });
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
var ForbiddenError = class extends HttpError {
|
|
693
|
+
constructor(message = "Forbidden", code = "FORBIDDEN", errors) {
|
|
694
|
+
super(message, { status: 403 /* FORBIDDEN */, code, errors });
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
var TooManyRequestsError = class extends HttpError {
|
|
698
|
+
constructor(message = "Too Many Requests", code = "TOO_MANY_REQUESTS", errors) {
|
|
699
|
+
super(message, { status: 429 /* TOO_MANY_REQUESTS */, code, errors });
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
var GatewayTimeoutError = class extends HttpError {
|
|
703
|
+
constructor(message = "Gateway Timeout", code = "GATEWAY_TIMEOUT", errors) {
|
|
704
|
+
super(message, { status: 504 /* GATEWAY_TIMEOUT */, code, errors });
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
var GoneError = class extends HttpError {
|
|
708
|
+
constructor(message = "Gone", code = "GONE", errors) {
|
|
709
|
+
super(message, { status: 410 /* GONE */, code, errors });
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
var HttpVersionNotSupportedError = class extends HttpError {
|
|
713
|
+
constructor(message = "HTTP Version Not Supported", code = "HTTP_VERSION_NOT_SUPPORTED", errors) {
|
|
714
|
+
super(message, { status: 505 /* HTTP_VERSION_NOT_SUPPORTED */, code, errors });
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
var ImATeapotError = class extends HttpError {
|
|
718
|
+
constructor(message = "I'm a teapot", code = "I_AM_A_TEAPOT", errors) {
|
|
719
|
+
super(message, { status: 418 /* I_AM_A_TEAPOT */, code, errors });
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
var InternalServerError = class extends HttpError {
|
|
723
|
+
constructor(message = "Internal Server Error", code = "INTERNAL_SERVER_ERROR", errors) {
|
|
724
|
+
super(message, { status: 500 /* INTERNAL_SERVER_ERROR */, code, errors });
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
var MethodNotAllowedError = class extends HttpError {
|
|
728
|
+
constructor(message = "Method Not Allowed", code = "METHOD_NOT_ALLOWED", errors) {
|
|
729
|
+
super(message, { status: 405 /* METHOD_NOT_ALLOWED */, code, errors });
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
var MisdirectedError = class extends HttpError {
|
|
733
|
+
constructor(message = "Misdirected Request", code = "MISDIRECTED", errors) {
|
|
734
|
+
super(message, { status: 421 /* MISDIRECTED */, code, errors });
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
var NotAcceptableError = class extends HttpError {
|
|
738
|
+
constructor(message = "Not Acceptable", code = "NOT_ACCEPTABLE", errors) {
|
|
739
|
+
super(message, { status: 406 /* NOT_ACCEPTABLE */, code, errors });
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
var NotFoundError = class extends HttpError {
|
|
743
|
+
constructor(message = "Not Found", code = "NOT_FOUND", errors) {
|
|
744
|
+
super(message, { status: 404 /* NOT_FOUND */, code, errors });
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
var NotImplementedError = class extends HttpError {
|
|
748
|
+
constructor(message = "Not Implemented", code = "NOT_IMPLEMENTED", errors) {
|
|
749
|
+
super(message, { status: 501 /* NOT_IMPLEMENTED */, code, errors });
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
var PayloadTooLargeError = class extends HttpError {
|
|
753
|
+
constructor(message = "Payload Too Large", code = "PAYLOAD_TOO_LARGE", errors) {
|
|
754
|
+
super(message, { status: 413 /* PAYLOAD_TOO_LARGE */, code, errors });
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
var PreconditionFailedError = class extends HttpError {
|
|
758
|
+
constructor(message = "Precondition Failed", code = "PRECONDITION_FAILED", errors) {
|
|
759
|
+
super(message, { status: 412 /* PRECONDITION_FAILED */, code, errors });
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
var RequestTimeoutError = class extends HttpError {
|
|
763
|
+
constructor(message = "Request Timeout", code = "REQUEST_TIMEOUT", errors) {
|
|
764
|
+
super(message, { status: 408 /* REQUEST_TIMEOUT */, code, errors });
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
var ServiceUnavailableError = class extends HttpError {
|
|
768
|
+
constructor(message = "Service Unavailable", code = "SERVICE_UNAVAILABLE", errors) {
|
|
769
|
+
super(message, { status: 503 /* SERVICE_UNAVAILABLE */, code, errors });
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
var UnauthorizedError = class extends HttpError {
|
|
773
|
+
constructor(message = "Unauthorized", code = "UNAUTHORIZED", errors) {
|
|
774
|
+
super(message, { status: 401 /* UNAUTHORIZED */, code, errors });
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
var UnprocessableEntityError = class extends HttpError {
|
|
778
|
+
constructor(message = "Unprocessable Entity", code = "UNPROCESSABLE_ENTITY", errors) {
|
|
779
|
+
super(message, { status: 422 /* UNPROCESSABLE_ENTITY */, code, errors });
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
var UnsupportedMediaTypeError = class extends HttpError {
|
|
783
|
+
constructor(message = "Unsupported Media Type", code = "UNSUPPORTED_MEDIA_TYPE", errors) {
|
|
784
|
+
super(message, { status: 415 /* UNSUPPORTED_MEDIA_TYPE */, code, errors });
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
|
|
572
788
|
// src/mime-db.json
|
|
573
789
|
var mime_db_default = {
|
|
574
790
|
"123": "application/vnd.lotus-1-2-3",
|
|
@@ -1840,15 +2056,23 @@ function excludeObject(target, excludes = []) {
|
|
|
1840
2056
|
return pickObject(target, [], excludes);
|
|
1841
2057
|
}
|
|
1842
2058
|
function pickValidValues(target, fields) {
|
|
2059
|
+
if (!isObject(target) || !isArray(fields)) {
|
|
2060
|
+
return {};
|
|
2061
|
+
}
|
|
1843
2062
|
const dist = {};
|
|
1844
2063
|
fields.forEach((field) => {
|
|
1845
2064
|
let key = String(field);
|
|
1846
2065
|
let alias;
|
|
1847
2066
|
if (isArray(field)) {
|
|
2067
|
+
if (field.length === 0 || isNil(field[0])) {
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
1848
2070
|
key = field[0];
|
|
1849
|
-
if (field.length > 1) {
|
|
1850
|
-
alias = field[1];
|
|
2071
|
+
if (field.length > 1 && !isNil(field[1])) {
|
|
2072
|
+
alias = String(field[1]);
|
|
1851
2073
|
}
|
|
2074
|
+
} else if (isNil(field)) {
|
|
2075
|
+
return;
|
|
1852
2076
|
}
|
|
1853
2077
|
let value = target[key];
|
|
1854
2078
|
if (isValid(value)) {
|
|
@@ -1876,16 +2100,22 @@ function removeObjectNil(target) {
|
|
|
1876
2100
|
return newObj;
|
|
1877
2101
|
}
|
|
1878
2102
|
function copyObjectValues(target, dist, keyMaps) {
|
|
1879
|
-
if (!isObject(target) || !isObject(dist)) {
|
|
2103
|
+
if (!isObject(target) || !isObject(dist) || !isArray(keyMaps)) {
|
|
1880
2104
|
return;
|
|
1881
2105
|
}
|
|
1882
2106
|
for (const keys of keyMaps) {
|
|
1883
2107
|
let targetKey;
|
|
1884
2108
|
let distKey;
|
|
1885
2109
|
if (isArray(keys)) {
|
|
1886
|
-
|
|
1887
|
-
|
|
2110
|
+
if (keys.length === 0 || isNil(keys[0])) {
|
|
2111
|
+
continue;
|
|
2112
|
+
}
|
|
2113
|
+
targetKey = String(keys[0]);
|
|
2114
|
+
distKey = !isNil(keys[1]) ? String(keys[1]) : targetKey;
|
|
1888
2115
|
} else {
|
|
2116
|
+
if (isNil(keys)) {
|
|
2117
|
+
continue;
|
|
2118
|
+
}
|
|
1889
2119
|
targetKey = String(keys);
|
|
1890
2120
|
distKey = targetKey;
|
|
1891
2121
|
}
|
|
@@ -1900,52 +2130,29 @@ function copyObjectValues(target, dist, keyMaps) {
|
|
|
1900
2130
|
}
|
|
1901
2131
|
|
|
1902
2132
|
// src/random.ts
|
|
1903
|
-
var
|
|
1904
|
-
var
|
|
1905
|
-
var
|
|
1906
|
-
var
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
RandomType2[RandomType2["UPPER"] = 1] = "UPPER";
|
|
1911
|
-
RandomType2[RandomType2["NUMERIC"] = 2] = "NUMERIC";
|
|
1912
|
-
RandomType2[RandomType2["HEXIC"] = 3] = "HEXIC";
|
|
1913
|
-
RandomType2[RandomType2["LOWER_NUMERIC"] = 4] = "LOWER_NUMERIC";
|
|
1914
|
-
RandomType2[RandomType2["UPPER_NUMERIC"] = 5] = "UPPER_NUMERIC";
|
|
1915
|
-
RandomType2[RandomType2["ALPHANUMERIC"] = 6] = "ALPHANUMERIC";
|
|
1916
|
-
return RandomType2;
|
|
1917
|
-
})(RandomType || {});
|
|
1918
|
-
function random(len = length * 2, type2 = 6 /* ALPHANUMERIC */) {
|
|
1919
|
-
let alphabet = numeric + lower + upper;
|
|
1920
|
-
switch (type2) {
|
|
1921
|
-
case 0 /* LOWER */:
|
|
1922
|
-
alphabet = lower;
|
|
1923
|
-
break;
|
|
1924
|
-
case 1 /* UPPER */:
|
|
1925
|
-
alphabet = upper;
|
|
1926
|
-
break;
|
|
1927
|
-
case 3 /* HEXIC */:
|
|
1928
|
-
alphabet = hexic;
|
|
1929
|
-
break;
|
|
1930
|
-
case 2 /* NUMERIC */:
|
|
1931
|
-
alphabet = numeric;
|
|
1932
|
-
break;
|
|
1933
|
-
case 4 /* LOWER_NUMERIC */:
|
|
1934
|
-
alphabet = lower + numeric;
|
|
1935
|
-
break;
|
|
1936
|
-
case 5 /* UPPER_NUMERIC */:
|
|
1937
|
-
alphabet = upper + numeric;
|
|
1938
|
-
break;
|
|
1939
|
-
case 6 /* ALPHANUMERIC */:
|
|
1940
|
-
alphabet = lower + upper + numeric;
|
|
1941
|
-
break;
|
|
1942
|
-
}
|
|
1943
|
-
let str = "";
|
|
1944
|
-
const alphabetLength = alphabet.length;
|
|
2133
|
+
var NUMERIC = "0123456789";
|
|
2134
|
+
var HEXIC = "0123456789abcdef";
|
|
2135
|
+
var ALPHA = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
2136
|
+
var ALPHANUMERIC = ALPHA + NUMERIC;
|
|
2137
|
+
function random(len = 6, alphabet = ALPHANUMERIC) {
|
|
2138
|
+
let result = "";
|
|
2139
|
+
const length = alphabet.length;
|
|
1945
2140
|
for (let i = 0; i < len; i++) {
|
|
1946
|
-
|
|
2141
|
+
result += alphabet.charAt(Math.floor(Math.random() * length));
|
|
1947
2142
|
}
|
|
1948
|
-
return
|
|
2143
|
+
return result;
|
|
2144
|
+
}
|
|
2145
|
+
function randomHexic(len) {
|
|
2146
|
+
return random(len, HEXIC);
|
|
2147
|
+
}
|
|
2148
|
+
function randomAlpha(len) {
|
|
2149
|
+
return random(len, ALPHA);
|
|
2150
|
+
}
|
|
2151
|
+
function randomNumeric(len) {
|
|
2152
|
+
return random(len, NUMERIC);
|
|
2153
|
+
}
|
|
2154
|
+
function randomNumber(min, max) {
|
|
2155
|
+
return Math.ceil(Math.random() * (max - min) + min);
|
|
1949
2156
|
}
|
|
1950
2157
|
function slugify(text, options) {
|
|
1951
2158
|
return slug__default.default(text, {
|
|
@@ -1971,13 +2178,37 @@ Object.defineProperty(exports, "uuidv5", {
|
|
|
1971
2178
|
enumerable: true,
|
|
1972
2179
|
get: function () { return uuid.v5; }
|
|
1973
2180
|
});
|
|
2181
|
+
exports.BadGatewayError = BadGatewayError;
|
|
2182
|
+
exports.BadRequestError = BadRequestError;
|
|
2183
|
+
exports.ConflictError = ConflictError;
|
|
1974
2184
|
exports.FILE_MIME_TYPES = FILE_MIME_TYPES;
|
|
2185
|
+
exports.ForbiddenError = ForbiddenError;
|
|
2186
|
+
exports.GatewayTimeoutError = GatewayTimeoutError;
|
|
2187
|
+
exports.GoneError = GoneError;
|
|
2188
|
+
exports.HttpError = HttpError;
|
|
2189
|
+
exports.HttpStatus = HttpStatus;
|
|
2190
|
+
exports.HttpVersionNotSupportedError = HttpVersionNotSupportedError;
|
|
1975
2191
|
exports.IMAGE_MIME_TYPES = IMAGE_MIME_TYPES;
|
|
1976
|
-
exports.
|
|
2192
|
+
exports.ImATeapotError = ImATeapotError;
|
|
2193
|
+
exports.InternalServerError = InternalServerError;
|
|
2194
|
+
exports.MethodNotAllowedError = MethodNotAllowedError;
|
|
2195
|
+
exports.MisdirectedError = MisdirectedError;
|
|
2196
|
+
exports.NotAcceptableError = NotAcceptableError;
|
|
2197
|
+
exports.NotFoundError = NotFoundError;
|
|
2198
|
+
exports.NotImplementedError = NotImplementedError;
|
|
2199
|
+
exports.PayloadTooLargeError = PayloadTooLargeError;
|
|
2200
|
+
exports.PreconditionFailedError = PreconditionFailedError;
|
|
2201
|
+
exports.RequestTimeoutError = RequestTimeoutError;
|
|
2202
|
+
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
2203
|
+
exports.TooManyRequestsError = TooManyRequestsError;
|
|
2204
|
+
exports.UnauthorizedError = UnauthorizedError;
|
|
2205
|
+
exports.UnprocessableEntityError = UnprocessableEntityError;
|
|
2206
|
+
exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
|
|
1977
2207
|
exports.alpha = alpha;
|
|
1978
2208
|
exports.alphaHexToRgb = alphaHexToRgb;
|
|
1979
2209
|
exports.bytes = bytes;
|
|
1980
2210
|
exports.clone = clone;
|
|
2211
|
+
exports.clsx = clsx;
|
|
1981
2212
|
exports.colorBrightness = colorBrightness;
|
|
1982
2213
|
exports.commonFileMimeTypes = commonFileMimeTypes;
|
|
1983
2214
|
exports.commonImageMimeTypes = commonImageMimeTypes;
|
|
@@ -2011,6 +2242,10 @@ exports.parseNumber = parseNumber;
|
|
|
2011
2242
|
exports.pickObject = pickObject;
|
|
2012
2243
|
exports.pickValidValues = pickValidValues;
|
|
2013
2244
|
exports.random = random;
|
|
2245
|
+
exports.randomAlpha = randomAlpha;
|
|
2246
|
+
exports.randomHexic = randomHexic;
|
|
2247
|
+
exports.randomNumber = randomNumber;
|
|
2248
|
+
exports.randomNumeric = randomNumeric;
|
|
2014
2249
|
exports.removeObjectNil = removeObjectNil;
|
|
2015
2250
|
exports.rgbToHex = rgbToHex;
|
|
2016
2251
|
exports.slugify = slugify;
|
|
@@ -2036,5 +2271,5 @@ Object.keys(deepObjectDiff).forEach(function (k) {
|
|
|
2036
2271
|
get: function () { return deepObjectDiff[k]; }
|
|
2037
2272
|
});
|
|
2038
2273
|
});
|
|
2039
|
-
//# sourceMappingURL=
|
|
2274
|
+
//# sourceMappingURL=index.js.map
|
|
2040
2275
|
//# sourceMappingURL=index.js.map
|