inferred-types 0.54.8 → 0.55.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/README.md +81 -36
- package/modules/constants/dist/index.cjs +118 -1
- package/modules/constants/dist/index.cjs.map +1 -1
- package/modules/constants/dist/index.d.ts +29 -1
- package/modules/constants/dist/index.js +113 -1
- package/modules/constants/dist/index.js.map +1 -1
- package/modules/inferred-types/dist/index.cjs +423 -24
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +19949 -19238
- package/modules/inferred-types/dist/index.js +403 -24
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +327 -23
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +5485 -5155
- package/modules/runtime/dist/index.js +312 -23
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.d.ts +9680 -9327
- package/package.json +3 -4
|
@@ -508,6 +508,73 @@ var HASH_TABLE_CHAR = {
|
|
|
508
508
|
...HASH_TABLE_SPECIAL
|
|
509
509
|
};
|
|
510
510
|
var HASH_TABLE_OTHER = "999";
|
|
511
|
+
var MIME_TYPES = [
|
|
512
|
+
// Application MIME Types
|
|
513
|
+
"application/json",
|
|
514
|
+
"application/xml",
|
|
515
|
+
"application/javascript",
|
|
516
|
+
"application/pdf",
|
|
517
|
+
"application/ld+json",
|
|
518
|
+
"application/octet-stream",
|
|
519
|
+
"application/x-www-form-urlencoded",
|
|
520
|
+
"application/vnd.api+json",
|
|
521
|
+
"application/msword",
|
|
522
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
523
|
+
"application/vnd.ms-excel",
|
|
524
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
525
|
+
"application/vnd.ms-powerpoint",
|
|
526
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
527
|
+
// Text MIME Types
|
|
528
|
+
"text/plain",
|
|
529
|
+
"text/html",
|
|
530
|
+
"text/css",
|
|
531
|
+
"text/csv",
|
|
532
|
+
"text/javascript",
|
|
533
|
+
"text/markdown",
|
|
534
|
+
// Image MIME Types
|
|
535
|
+
"image/jpeg",
|
|
536
|
+
"image/png",
|
|
537
|
+
"image/gif",
|
|
538
|
+
"image/bmp",
|
|
539
|
+
"image/webp",
|
|
540
|
+
"image/svg+xml",
|
|
541
|
+
"image/tiff",
|
|
542
|
+
// Audio MIME Types
|
|
543
|
+
"audio/mpeg",
|
|
544
|
+
"audio/ogg",
|
|
545
|
+
"audio/wav",
|
|
546
|
+
"audio/webm",
|
|
547
|
+
"audio/flac",
|
|
548
|
+
// Video MIME Types
|
|
549
|
+
"video/mp4",
|
|
550
|
+
"video/mpeg",
|
|
551
|
+
"video/ogg",
|
|
552
|
+
"video/webm",
|
|
553
|
+
"video/quicktime",
|
|
554
|
+
// Multipart MIME Types
|
|
555
|
+
"multipart/form-data",
|
|
556
|
+
"multipart/mixed",
|
|
557
|
+
"multipart/alternative",
|
|
558
|
+
"multipart/related",
|
|
559
|
+
// Font MIME Types
|
|
560
|
+
"font/woff",
|
|
561
|
+
"font/woff2",
|
|
562
|
+
"font/ttf",
|
|
563
|
+
"font/otf",
|
|
564
|
+
// Other Common MIME Types
|
|
565
|
+
"application/rss+xml",
|
|
566
|
+
"application/atom+xml",
|
|
567
|
+
"application/x-pkcs12",
|
|
568
|
+
"application/x-shockwave-flash",
|
|
569
|
+
"application/x-www-form-urlencoded",
|
|
570
|
+
"application/x-font-ttf",
|
|
571
|
+
"application/x-font-opentype",
|
|
572
|
+
"application/x-font-woff",
|
|
573
|
+
"application/x-font-woff2",
|
|
574
|
+
"application/vnd.rar",
|
|
575
|
+
"application/zip",
|
|
576
|
+
"application/x-7z-compressed"
|
|
577
|
+
];
|
|
511
578
|
var IMAGE_FORMAT_LOOKUP = [
|
|
512
579
|
{ ext: "jpg", webFormat: true, other_ext: ["jpeg"] },
|
|
513
580
|
{ ext: "png", webFormat: true, other_ext: [] },
|
|
@@ -848,13 +915,51 @@ var IPv6 = {
|
|
|
848
915
|
var IPv4 = {
|
|
849
916
|
Loopback: "127.0.0.1"
|
|
850
917
|
};
|
|
918
|
+
var NETWORK_PROTOCOL_INSECURE = [
|
|
919
|
+
"http",
|
|
920
|
+
"ftp",
|
|
921
|
+
"ws",
|
|
922
|
+
"dns",
|
|
923
|
+
"telnet",
|
|
924
|
+
"imap",
|
|
925
|
+
"pop3",
|
|
926
|
+
"smtp"
|
|
927
|
+
];
|
|
928
|
+
var NETWORK_PROTOCOL_SECURE = [
|
|
929
|
+
"https",
|
|
930
|
+
"sftp",
|
|
931
|
+
"wss",
|
|
932
|
+
"sdns",
|
|
933
|
+
"ssh"
|
|
934
|
+
];
|
|
935
|
+
var NETWORK_PROTOCOL = [
|
|
936
|
+
...NETWORK_PROTOCOL_INSECURE,
|
|
937
|
+
...NETWORK_PROTOCOL_SECURE
|
|
938
|
+
];
|
|
851
939
|
var NETWORK_PROTOCOL_LOOKUP = {
|
|
852
940
|
http: ["http", "https"],
|
|
853
941
|
ftp: ["ftp", "sftp"],
|
|
854
942
|
file: ["", "file"],
|
|
855
943
|
ws: ["ws", "wss"],
|
|
856
944
|
ssh: ["", "ssh"],
|
|
857
|
-
scp: ["", "scp"]
|
|
945
|
+
scp: ["", "scp"],
|
|
946
|
+
telnet: ["telnet", ""],
|
|
947
|
+
dns: ["dns", "sdns"]
|
|
948
|
+
};
|
|
949
|
+
var PROTOCOL_DEFAULT_PORTS = {
|
|
950
|
+
http: 80,
|
|
951
|
+
https: 443,
|
|
952
|
+
ws: 80,
|
|
953
|
+
wss: 443,
|
|
954
|
+
ssh: 22,
|
|
955
|
+
telnet: 23,
|
|
956
|
+
dns: 53,
|
|
957
|
+
sdns: 853,
|
|
958
|
+
smtp: 25,
|
|
959
|
+
imap: 142,
|
|
960
|
+
pop3: 110,
|
|
961
|
+
ftp: 21,
|
|
962
|
+
sftp: 22
|
|
858
963
|
};
|
|
859
964
|
var TOP_LEVEL_DOMAINS = [
|
|
860
965
|
"com",
|
|
@@ -3156,13 +3261,51 @@ var AREA_METRICS_LOOKUP2 = [
|
|
|
3156
3261
|
{ abbrev: "acre", name: "acre" },
|
|
3157
3262
|
{ abbrev: "ha", name: "hectare" }
|
|
3158
3263
|
];
|
|
3264
|
+
var NETWORK_PROTOCOL_INSECURE2 = [
|
|
3265
|
+
"http",
|
|
3266
|
+
"ftp",
|
|
3267
|
+
"ws",
|
|
3268
|
+
"dns",
|
|
3269
|
+
"telnet",
|
|
3270
|
+
"imap",
|
|
3271
|
+
"pop3",
|
|
3272
|
+
"smtp"
|
|
3273
|
+
];
|
|
3274
|
+
var NETWORK_PROTOCOL_SECURE2 = [
|
|
3275
|
+
"https",
|
|
3276
|
+
"sftp",
|
|
3277
|
+
"wss",
|
|
3278
|
+
"sdns",
|
|
3279
|
+
"ssh"
|
|
3280
|
+
];
|
|
3281
|
+
var NETWORK_PROTOCOL2 = [
|
|
3282
|
+
...NETWORK_PROTOCOL_INSECURE2,
|
|
3283
|
+
...NETWORK_PROTOCOL_SECURE2
|
|
3284
|
+
];
|
|
3159
3285
|
var NETWORK_PROTOCOL_LOOKUP2 = {
|
|
3160
3286
|
http: ["http", "https"],
|
|
3161
3287
|
ftp: ["ftp", "sftp"],
|
|
3162
3288
|
file: ["", "file"],
|
|
3163
3289
|
ws: ["ws", "wss"],
|
|
3164
3290
|
ssh: ["", "ssh"],
|
|
3165
|
-
scp: ["", "scp"]
|
|
3291
|
+
scp: ["", "scp"],
|
|
3292
|
+
telnet: ["telnet", ""],
|
|
3293
|
+
dns: ["dns", "sdns"]
|
|
3294
|
+
};
|
|
3295
|
+
var PROTOCOL_DEFAULT_PORTS2 = {
|
|
3296
|
+
http: 80,
|
|
3297
|
+
https: 443,
|
|
3298
|
+
ws: 80,
|
|
3299
|
+
wss: 443,
|
|
3300
|
+
ssh: 22,
|
|
3301
|
+
telnet: 23,
|
|
3302
|
+
dns: 53,
|
|
3303
|
+
sdns: 853,
|
|
3304
|
+
smtp: 25,
|
|
3305
|
+
imap: 142,
|
|
3306
|
+
pop3: 110,
|
|
3307
|
+
ftp: 21,
|
|
3308
|
+
sftp: 22
|
|
3166
3309
|
};
|
|
3167
3310
|
var Never2 = createConstant2("never");
|
|
3168
3311
|
var US_NEWS2 = [
|
|
@@ -4593,6 +4736,16 @@ function narrowObjectToType() {
|
|
|
4593
4736
|
}
|
|
4594
4737
|
);
|
|
4595
4738
|
}
|
|
4739
|
+
function objectValues(obj) {
|
|
4740
|
+
const tuple3 = Object.keys(obj).reduce(
|
|
4741
|
+
(acc, key) => [
|
|
4742
|
+
...acc,
|
|
4743
|
+
obj[key]
|
|
4744
|
+
],
|
|
4745
|
+
[]
|
|
4746
|
+
);
|
|
4747
|
+
return tuple3;
|
|
4748
|
+
}
|
|
4596
4749
|
function omit(obj, ...removeKeys) {
|
|
4597
4750
|
const keys = Object.keys(obj);
|
|
4598
4751
|
return keys.reduce(
|
|
@@ -4643,12 +4796,110 @@ function withKeys(dict, ...keys) {
|
|
|
4643
4796
|
function withoutKeys(dict, ...exclude) {
|
|
4644
4797
|
return omit(dict, ...exclude);
|
|
4645
4798
|
}
|
|
4646
|
-
function
|
|
4799
|
+
function doesExtend(type) {
|
|
4800
|
+
return (val) => {
|
|
4801
|
+
let response = false;
|
|
4802
|
+
if (isString(val)) {
|
|
4803
|
+
if (type === "string") {
|
|
4804
|
+
response = true;
|
|
4805
|
+
}
|
|
4806
|
+
if (type.startsWith("string(")) {
|
|
4807
|
+
const literals = stripAfter(
|
|
4808
|
+
stripBefore(type, "string("),
|
|
4809
|
+
")"
|
|
4810
|
+
).split(/,\s*/);
|
|
4811
|
+
if (literals.includes(val)) {
|
|
4812
|
+
response = true;
|
|
4813
|
+
}
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
if (isNumber(val)) {
|
|
4817
|
+
if (type === "number") {
|
|
4818
|
+
response = true;
|
|
4819
|
+
}
|
|
4820
|
+
if (type.startsWith("number(")) {
|
|
4821
|
+
const literals = stripAfter(
|
|
4822
|
+
stripBefore(type, "number("),
|
|
4823
|
+
")"
|
|
4824
|
+
).split(/,\s*/).map(Number);
|
|
4825
|
+
if (literals.includes(val)) {
|
|
4826
|
+
response = true;
|
|
4827
|
+
}
|
|
4828
|
+
}
|
|
4829
|
+
}
|
|
4830
|
+
if (isNull(val) && (type === "null" || type === "Opt<null>")) {
|
|
4831
|
+
response = true;
|
|
4832
|
+
}
|
|
4833
|
+
if (isUndefined(val) && (type === "undefined" || type.startsWith("Opt<"))) {
|
|
4834
|
+
response = true;
|
|
4835
|
+
}
|
|
4836
|
+
if (isBoolean(val)) {
|
|
4837
|
+
if (type === "boolean") {
|
|
4838
|
+
response = true;
|
|
4839
|
+
}
|
|
4840
|
+
if (type === "true" && val === true || type === "false" && val === false) {
|
|
4841
|
+
response = true;
|
|
4842
|
+
}
|
|
4843
|
+
}
|
|
4844
|
+
if (isNarrowableObject(val)) {
|
|
4845
|
+
if (type === "Dict" || type === "Dict<string, unknown>") {
|
|
4846
|
+
response = true;
|
|
4847
|
+
}
|
|
4848
|
+
if (startsWith("Dict<")(type)) {
|
|
4849
|
+
const match = infer("Dict<{{infer key}}, {{infer value}}>")(type);
|
|
4850
|
+
if (match) {
|
|
4851
|
+
const { value } = match;
|
|
4852
|
+
const isOpt = value.includes(`Opt<`);
|
|
4853
|
+
const values = objectValues(val);
|
|
4854
|
+
if (values.every((i) => isOpt ? isString(i) || isUndefined(i) : isString(i)) && type === "Dict<string, string>" || values.every((i) => isOpt ? isUndefined(i) || isNumber(i) : isNumber(i)) && type === "Dict<string, number>" || values.every((i) => isOpt ? isUndefined(i) || isBoolean(i) : isBoolean(i)) && type === "Dict<string, boolean>") {
|
|
4855
|
+
response = true;
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
if (isArray(val)) {
|
|
4861
|
+
if (type === "Array" || type === "Array<unknown>") {
|
|
4862
|
+
return true;
|
|
4863
|
+
}
|
|
4864
|
+
if (type === "Array<Dict>" && val.every(isObject) || type === "Array<boolean>" && val.every(isBoolean) || type === "Array<string>" && val.every(isString) || type === "Array<number>" && val.every(isNumber) || type === "Array<Map>" && val.every(isMap) || type === "Array<Set>" && val.every(isSetContainer)) {
|
|
4865
|
+
response = true;
|
|
4866
|
+
}
|
|
4867
|
+
}
|
|
4868
|
+
if (isMap(val)) {
|
|
4869
|
+
if (type === "Map" || type === "Map<Dict, Array>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isArray) || type === "Map<Dict, Dict>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isObject) || type === "Map<Dict, boolean>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isBoolean) || type === "Map<Dict, number>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isNumber) || type === "Map<Dict, string>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isString) || type === "Map<Dict, unknown>" && Array.from(val.keys()).every(isObject) || type === "Map<string, string>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isString) || type === "Map<string, number>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isNumber) || type === "Map<string, boolean>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isBoolean) || type === "Map<string, unknown>" && Array.from(val.keys()).every(isString) || type === "Map<number, string>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isString) || type === "Map<number, number>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isNumber) || type === "Map<number, boolean>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isBoolean) || type === "Map<number, unknown>" && Array.from(val.keys()).every(isNumber)) {
|
|
4870
|
+
response = true;
|
|
4871
|
+
}
|
|
4872
|
+
}
|
|
4873
|
+
if (isSetContainer(val)) {
|
|
4874
|
+
if (type === "Set" || type === "Set<unknown>" || type === "Set<boolean>" && Array.from(val).every(isBoolean) || type === "Set<string>" && Array.from(val).every(isString) || type === "Set<number>" && Array.from(val).every(isNumber) || type === "Set<Opt<boolean>>" && Array.from(val).every((i) => isBoolean(i) || isUndefined(i)) || type === "Set<Opt<string>>" && Array.from(val).every((i) => isString(i) || isUndefined(i)) || type === "Set<Opt<number>>" && Array.from(val).every((i) => isNumber(i) || isUndefined(i))) {
|
|
4875
|
+
response = true;
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4878
|
+
return response;
|
|
4879
|
+
};
|
|
4880
|
+
}
|
|
4881
|
+
function withoutValue(wo) {
|
|
4647
4882
|
return (obj) => {
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4883
|
+
const output = {};
|
|
4884
|
+
for (const key of keysOf(obj)) {
|
|
4885
|
+
const val = obj[key];
|
|
4886
|
+
if (!doesExtend(wo)(val)) {
|
|
4887
|
+
output[key] = val;
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4890
|
+
return output;
|
|
4891
|
+
};
|
|
4892
|
+
}
|
|
4893
|
+
function withValue(wo) {
|
|
4894
|
+
return (obj) => {
|
|
4895
|
+
const output = {};
|
|
4896
|
+
for (const key of keysOf(obj)) {
|
|
4897
|
+
const val = obj[key];
|
|
4898
|
+
if (doesExtend(wo)(val)) {
|
|
4899
|
+
output[key] = val;
|
|
4900
|
+
}
|
|
4901
|
+
}
|
|
4902
|
+
return output;
|
|
4652
4903
|
};
|
|
4653
4904
|
}
|
|
4654
4905
|
function createErrorCondition(kind, msg = "", utility = "") {
|
|
@@ -4715,7 +4966,7 @@ var filter = "NOT READY";
|
|
|
4715
4966
|
function find(list2, deref = null) {
|
|
4716
4967
|
return (comparator) => {
|
|
4717
4968
|
return list2.find((i) => {
|
|
4718
|
-
const val = deref ?
|
|
4969
|
+
const val = deref ? isObject(i) || isArray(i) ? deref in i ? i[deref] : void 0 : i : i;
|
|
4719
4970
|
return val === comparator;
|
|
4720
4971
|
});
|
|
4721
4972
|
};
|
|
@@ -4867,6 +5118,9 @@ function isFunction(value) {
|
|
|
4867
5118
|
function isObject(value) {
|
|
4868
5119
|
return typeof value === "object" && value !== null && Array.isArray(value) === false;
|
|
4869
5120
|
}
|
|
5121
|
+
function isNarrowableObject(value) {
|
|
5122
|
+
return isObject(value) && Object.keys(value).every((key) => ["string", "number", "boolean", "symbol", "object", "undefined", "void", "null"].includes(typeof value[key]));
|
|
5123
|
+
}
|
|
4870
5124
|
function isEscapeFunction(val) {
|
|
4871
5125
|
return isFunction(val) && "escape" in val && val.escape === true;
|
|
4872
5126
|
}
|
|
@@ -5386,6 +5640,9 @@ var isRatio = (val) => /\d{1,4}\s*\/\s*\d{1,4}/.test(val);
|
|
|
5386
5640
|
function isCssAspectRatio(val) {
|
|
5387
5641
|
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
5388
5642
|
}
|
|
5643
|
+
function isCsv(val) {
|
|
5644
|
+
return isString(val) && val.includes(",") && !val.startsWith(",");
|
|
5645
|
+
}
|
|
5389
5646
|
function isDefined(value) {
|
|
5390
5647
|
return typeof value !== "undefined";
|
|
5391
5648
|
}
|
|
@@ -5423,6 +5680,9 @@ function isIndexable(value) {
|
|
|
5423
5680
|
function isInlineSvg(v) {
|
|
5424
5681
|
return isString(v) && v.trim().startsWith(`<svg`) && v.trim().endsWith(`</svg>`);
|
|
5425
5682
|
}
|
|
5683
|
+
function isMap(val) {
|
|
5684
|
+
return val instanceof Map;
|
|
5685
|
+
}
|
|
5426
5686
|
function isNever(val) {
|
|
5427
5687
|
return isConstant(val) && val.kind === "never";
|
|
5428
5688
|
}
|
|
@@ -5436,7 +5696,7 @@ function isPhoneNumber(val) {
|
|
|
5436
5696
|
const svelte = String(val).trim();
|
|
5437
5697
|
const chars = svelte.split("");
|
|
5438
5698
|
const numeric = retainChars(svelte, ...NUMERIC_CHAR2);
|
|
5439
|
-
const
|
|
5699
|
+
const valid2 = ["+", "(", ...NUMERIC_CHAR2];
|
|
5440
5700
|
const nothing = stripChars(svelte, ...[
|
|
5441
5701
|
...NUMERIC_CHAR2,
|
|
5442
5702
|
...WHITESPACE_CHARS2,
|
|
@@ -5446,7 +5706,7 @@ function isPhoneNumber(val) {
|
|
|
5446
5706
|
".",
|
|
5447
5707
|
"-"
|
|
5448
5708
|
]);
|
|
5449
|
-
return chars.every((i) =>
|
|
5709
|
+
return chars.every((i) => valid2.includes(i)) && svelte.startsWith(`+`) ? numeric.length >= 8 : svelte.startsWith(`00`) ? numeric.length >= 10 : numeric.length >= 7 && nothing === "";
|
|
5450
5710
|
}
|
|
5451
5711
|
function isReadonlyArray(value) {
|
|
5452
5712
|
return Array.isArray(value) === true;
|
|
@@ -5471,6 +5731,12 @@ function isLikeRegExp(val) {
|
|
|
5471
5731
|
}
|
|
5472
5732
|
return false;
|
|
5473
5733
|
}
|
|
5734
|
+
function isSet(val) {
|
|
5735
|
+
return isObject(val) ? val.kind !== "Unset" : true;
|
|
5736
|
+
}
|
|
5737
|
+
function isSetContainer(val) {
|
|
5738
|
+
return val instanceof Set;
|
|
5739
|
+
}
|
|
5474
5740
|
function isStringArray(val) {
|
|
5475
5741
|
return Array.isArray(val) && val.every((i) => isString(i));
|
|
5476
5742
|
}
|
|
@@ -5495,9 +5761,6 @@ function isTypeTuple(value) {
|
|
|
5495
5761
|
function isUnset(val) {
|
|
5496
5762
|
return isObject(val) && val.kind === "Unset";
|
|
5497
5763
|
}
|
|
5498
|
-
function isSet(val) {
|
|
5499
|
-
return isObject(val) ? val.kind !== "Unset" : true;
|
|
5500
|
-
}
|
|
5501
5764
|
function isUri(val, ...protocols) {
|
|
5502
5765
|
const p = protocols.length === 0 ? valuesOf(NETWORK_PROTOCOL_LOOKUP2).flat().filter((i) => i) : protocols;
|
|
5503
5766
|
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
@@ -5506,6 +5769,19 @@ function isUrl(val, ...protocols) {
|
|
|
5506
5769
|
const p = protocols.length === 0 ? ["http", "https"] : protocols;
|
|
5507
5770
|
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
5508
5771
|
}
|
|
5772
|
+
var VALID = [
|
|
5773
|
+
...ALPHA_CHARS2,
|
|
5774
|
+
...NUMERIC_CHAR2,
|
|
5775
|
+
"_",
|
|
5776
|
+
"."
|
|
5777
|
+
];
|
|
5778
|
+
var alpha = null;
|
|
5779
|
+
function valid(chars) {
|
|
5780
|
+
return chars.every((i) => VALID.includes(i));
|
|
5781
|
+
}
|
|
5782
|
+
function isVariable(val) {
|
|
5783
|
+
return isString(val) && startsWith(alpha)(val) && valid(asChars(val));
|
|
5784
|
+
}
|
|
5509
5785
|
function separate(s) {
|
|
5510
5786
|
return stripWhile(s.toLowerCase(), ...NUMERIC_CHAR2).trim();
|
|
5511
5787
|
}
|
|
@@ -5644,6 +5920,18 @@ function hasUrlQueryParameter(val, prop) {
|
|
|
5644
5920
|
function isNumericArray(val) {
|
|
5645
5921
|
return Array.isArray(val) && val.every((i) => isNumber(i));
|
|
5646
5922
|
}
|
|
5923
|
+
function hasProtocol(val, ...protocols) {
|
|
5924
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.some((i) => val.startsWith(i)) : protocols.some((i) => val.startsWith(i));
|
|
5925
|
+
}
|
|
5926
|
+
function isProtocol(val, ...protocols) {
|
|
5927
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.includes(val) : protocols.includes(val);
|
|
5928
|
+
}
|
|
5929
|
+
function hasProtocolPrefix(val, ...protocols) {
|
|
5930
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.map((i) => `${i}://`).some((i) => val.startsWith(i)) : protocols.map((i) => `${i}://`).some((i) => val.startsWith(i));
|
|
5931
|
+
}
|
|
5932
|
+
function isProtocolPrefix(val, ...protocols) {
|
|
5933
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.map((i) => `${i}://`).includes(val) : protocols.map((i) => `${i}://`).includes(val);
|
|
5934
|
+
}
|
|
5647
5935
|
function isTypeToken(val, kind) {
|
|
5648
5936
|
if (isString(val) && val.startsWith("<<") && val.endsWith(">>")) {
|
|
5649
5937
|
const stripped = stripSurround("<<", ">>")(val);
|
|
@@ -5875,24 +6163,24 @@ function isNewsUrl(val) {
|
|
|
5875
6163
|
return isAustralianNewsUrl(val) || isBelgiumNewsUrl(val) || isCanadianNewsUrl(val) || isDanishNewsUrl(val) || isDutchNewsUrl(val) || isFrenchNewsUrl(val) || isGermanNewsUrl(val) || isIndianNewsUrl(val) || isItalianNewsUrl(val) || isJapaneseNewsUrl(val) || isMexicanNewsUrl(val) || isNorwegianNewsUrl(val) || isSouthKoreanNewsUrl(val) || isSpanishNewsUrl(val) || isSwissNewsUrl(val) || isTurkishNewsUrl(val) || isUkNewsUrl(val) || isUsNewsUrl(val);
|
|
5876
6164
|
}
|
|
5877
6165
|
function isBitbucketUrl(val) {
|
|
5878
|
-
const
|
|
5879
|
-
return isString(val) &&
|
|
6166
|
+
const valid2 = REPO_SOURCE_LOOKUP2.bitbucket;
|
|
6167
|
+
return isString(val) && valid2.some(
|
|
5880
6168
|
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
5881
6169
|
);
|
|
5882
6170
|
}
|
|
5883
6171
|
function isCodeCommitUrl(val) {
|
|
5884
|
-
const
|
|
5885
|
-
return isString(val) &&
|
|
6172
|
+
const valid2 = REPO_SOURCE_LOOKUP2.codecommit;
|
|
6173
|
+
return isString(val) && valid2.some(
|
|
5886
6174
|
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
5887
6175
|
);
|
|
5888
6176
|
}
|
|
5889
6177
|
function isGithubUrl(val) {
|
|
5890
|
-
const
|
|
6178
|
+
const valid2 = [
|
|
5891
6179
|
"https://github.com",
|
|
5892
6180
|
"https://www.github.com",
|
|
5893
6181
|
"https://github.io"
|
|
5894
6182
|
];
|
|
5895
|
-
return isString(val) &&
|
|
6183
|
+
return isString(val) && valid2.some(
|
|
5896
6184
|
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
5897
6185
|
);
|
|
5898
6186
|
}
|
|
@@ -6436,16 +6724,77 @@ function getUrlQueryParams(url, specific = void 0) {
|
|
|
6436
6724
|
}
|
|
6437
6725
|
return qp === "" ? qp : `?${qp}`;
|
|
6438
6726
|
}
|
|
6439
|
-
function
|
|
6440
|
-
const
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6727
|
+
function getUrlDefaultPort(url) {
|
|
6728
|
+
const proto = getUrlProtocol(url);
|
|
6729
|
+
return proto in PROTOCOL_DEFAULT_PORTS2 ? PROTOCOL_DEFAULT_PORTS2[proto] : null;
|
|
6730
|
+
}
|
|
6731
|
+
function getUrlPort(url, resolve = false) {
|
|
6732
|
+
const re = /.*:(\d{2,3})/;
|
|
6733
|
+
const match = url.match(re);
|
|
6734
|
+
return re.test(url) && match && isNumberLike(Array.from(match)[1]) ? Number(Array.from(match)[1]) : resolve ? getUrlDefaultPort(url) : hasProtocol(url) ? `default` : null;
|
|
6444
6735
|
}
|
|
6445
6736
|
function getUrlSource(url) {
|
|
6446
6737
|
const candidate = stripAfter(stripAfter(stripAfter(removeUrlProtocol(url), "/"), "?"), ":");
|
|
6447
6738
|
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never2;
|
|
6448
6739
|
}
|
|
6740
|
+
function getUrlBase(url) {
|
|
6741
|
+
const path = getUrlPath(url);
|
|
6742
|
+
const remaining = stripAfter(url, path);
|
|
6743
|
+
return remaining;
|
|
6744
|
+
}
|
|
6745
|
+
function getUrlDynamics(url) {
|
|
6746
|
+
const path = getUrlPath(url);
|
|
6747
|
+
const qp = getUrlQueryParams(url);
|
|
6748
|
+
const pathParts = path.startsWith("<") ? path.split("<").map((i) => ensureLeading(i, "<")) : path.split("<").map((i) => ensureLeading(i, "<")).slice(1);
|
|
6749
|
+
const segmentTypes = [
|
|
6750
|
+
"string",
|
|
6751
|
+
"number",
|
|
6752
|
+
"boolean",
|
|
6753
|
+
"Opt<string>",
|
|
6754
|
+
"Opt<number>",
|
|
6755
|
+
"Opt<boolean>"
|
|
6756
|
+
];
|
|
6757
|
+
const pathVars = {};
|
|
6758
|
+
const findPathTyped = infer(`<{{infer name}} as {{infer type}}>`);
|
|
6759
|
+
const findPathUnion = infer(`<{{infer name}} as string({{infer union}})>`);
|
|
6760
|
+
const findPathNamed = infer(`<{{infer name}}>`);
|
|
6761
|
+
for (const part of pathParts) {
|
|
6762
|
+
const union4 = findPathUnion(part);
|
|
6763
|
+
const typed = findPathTyped(part);
|
|
6764
|
+
const named = findPathNamed(part);
|
|
6765
|
+
if (union4) {
|
|
6766
|
+
if (isVariable(union4.name) && isCsv(union4.union)) {
|
|
6767
|
+
pathVars[union4.name] = `string(${union4.union})`;
|
|
6768
|
+
}
|
|
6769
|
+
} else if (typed && segmentTypes.includes(typed.type) && isVariable(typed.name)) {
|
|
6770
|
+
pathVars[typed.name] = typed.type;
|
|
6771
|
+
} else if (named && isVariable(named.name)) {
|
|
6772
|
+
pathVars[named.name] = "string";
|
|
6773
|
+
}
|
|
6774
|
+
}
|
|
6775
|
+
const qpVars = {};
|
|
6776
|
+
const qpParts = stripLeading(qp, "?").split("&");
|
|
6777
|
+
for (const p of qpParts) {
|
|
6778
|
+
const union4 = infer(`{{infer var}}=<string({{infer params}})>`)(p);
|
|
6779
|
+
const dynamic = infer(`{{infer var}}=<{{infer val}}>`)(p);
|
|
6780
|
+
const fixed = infer(`{{infer var}}={{infer val}}`)(p);
|
|
6781
|
+
if (union4 && isVariable(union4.var) && isCsv(union4.params)) {
|
|
6782
|
+
qpVars[union4.var] = `string(${union4.params})`;
|
|
6783
|
+
} else if (dynamic && isVariable(dynamic.var) && segmentTypes.includes(dynamic.val)) {
|
|
6784
|
+
qpVars[dynamic.var] = dynamic.val;
|
|
6785
|
+
} else if (fixed && isVariable(fixed.var)) {
|
|
6786
|
+
qpVars[fixed.var] = fixed.val;
|
|
6787
|
+
}
|
|
6788
|
+
}
|
|
6789
|
+
return {
|
|
6790
|
+
pathVars,
|
|
6791
|
+
qpVars,
|
|
6792
|
+
allVars: hasOverlappingKeys(pathVars, qpVars) ? null : {
|
|
6793
|
+
...pathVars,
|
|
6794
|
+
...qpVars
|
|
6795
|
+
}
|
|
6796
|
+
};
|
|
6797
|
+
}
|
|
6449
6798
|
function urlMeta(url) {
|
|
6450
6799
|
return {
|
|
6451
6800
|
url,
|
|
@@ -6453,6 +6802,7 @@ function urlMeta(url) {
|
|
|
6453
6802
|
protocol: getUrlProtocol(url),
|
|
6454
6803
|
path: getUrlPath(url),
|
|
6455
6804
|
queryParameters: getUrlQueryParams(url),
|
|
6805
|
+
params: getUrlDynamics,
|
|
6456
6806
|
port: getUrlPort(url),
|
|
6457
6807
|
source: getUrlSource(url),
|
|
6458
6808
|
isIpAddress: isIpAddress(getUrlSource(url)),
|
|
@@ -6853,6 +7203,15 @@ function simpleType(token) {
|
|
|
6853
7203
|
const value = isSimpleScalarToken(token) ? simpleScalarType(token) : isSimpleContainerToken(token) ? simpleContainerToken(token) : Never2;
|
|
6854
7204
|
return value;
|
|
6855
7205
|
}
|
|
7206
|
+
function hasOverlappingKeys(a, b) {
|
|
7207
|
+
const keys = Object.keys(a);
|
|
7208
|
+
for (const k of keys) {
|
|
7209
|
+
if (k in b) {
|
|
7210
|
+
return true;
|
|
7211
|
+
}
|
|
7212
|
+
}
|
|
7213
|
+
return false;
|
|
7214
|
+
}
|
|
6856
7215
|
function uniqueKeys(left, right) {
|
|
6857
7216
|
const isNumeric = !!(isArray(left) && isArray(right));
|
|
6858
7217
|
if (isArray(left) && !isArray(right) || isArray(right) && !isArray(left)) {
|
|
@@ -7140,11 +7499,15 @@ export {
|
|
|
7140
7499
|
MARKED,
|
|
7141
7500
|
MASS_METRICS_LOOKUP,
|
|
7142
7501
|
MEXICAN_NEWS,
|
|
7502
|
+
MIME_TYPES,
|
|
7143
7503
|
MONTH_ABBR,
|
|
7144
7504
|
MONTH_NAME,
|
|
7145
7505
|
MapCardinality,
|
|
7146
7506
|
NARROW_CONTAINER_TYPE_KINDS,
|
|
7507
|
+
NETWORK_PROTOCOL,
|
|
7508
|
+
NETWORK_PROTOCOL_INSECURE,
|
|
7147
7509
|
NETWORK_PROTOCOL_LOOKUP,
|
|
7510
|
+
NETWORK_PROTOCOL_SECURE,
|
|
7148
7511
|
NIKE_DNS,
|
|
7149
7512
|
NON_ZERO_NUMERIC_CHAR,
|
|
7150
7513
|
NORWEGIAN_NEWS,
|
|
@@ -7161,6 +7524,7 @@ export {
|
|
|
7161
7524
|
PLURAL_EXCEPTIONS_OLD,
|
|
7162
7525
|
POWER_METRICS_LOOKUP,
|
|
7163
7526
|
PRESSURE_METRICS_LOOKUP,
|
|
7527
|
+
PROTOCOL_DEFAULT_PORTS,
|
|
7164
7528
|
PROXMOX_CT_STATE,
|
|
7165
7529
|
REPO_PAGE_TYPES,
|
|
7166
7530
|
REPO_SOURCES,
|
|
@@ -7324,6 +7688,9 @@ export {
|
|
|
7324
7688
|
getTokenKind,
|
|
7325
7689
|
getTomorrow,
|
|
7326
7690
|
getTypeSubtype,
|
|
7691
|
+
getUrlBase,
|
|
7692
|
+
getUrlDefaultPort,
|
|
7693
|
+
getUrlDynamics,
|
|
7327
7694
|
getUrlPath,
|
|
7328
7695
|
getUrlPort,
|
|
7329
7696
|
getUrlProtocol,
|
|
@@ -7336,6 +7703,9 @@ export {
|
|
|
7336
7703
|
hasDefaultValue,
|
|
7337
7704
|
hasIndexOf,
|
|
7338
7705
|
hasKeys,
|
|
7706
|
+
hasOverlappingKeys,
|
|
7707
|
+
hasProtocol,
|
|
7708
|
+
hasProtocolPrefix,
|
|
7339
7709
|
hasUrlPort,
|
|
7340
7710
|
hasUrlQueryParameter,
|
|
7341
7711
|
hasWhiteSpace,
|
|
@@ -7401,6 +7771,7 @@ export {
|
|
|
7401
7771
|
isCountryCode3,
|
|
7402
7772
|
isCountryName,
|
|
7403
7773
|
isCssAspectRatio,
|
|
7774
|
+
isCsv,
|
|
7404
7775
|
isCurrentMetric,
|
|
7405
7776
|
isCurrentUom,
|
|
7406
7777
|
isCvsUrl,
|
|
@@ -7477,12 +7848,14 @@ export {
|
|
|
7477
7848
|
isLuminosityUom,
|
|
7478
7849
|
isLuxonDateTime,
|
|
7479
7850
|
isMacysUrl,
|
|
7851
|
+
isMap,
|
|
7480
7852
|
isMapToken,
|
|
7481
7853
|
isMassMetric,
|
|
7482
7854
|
isMassUom,
|
|
7483
7855
|
isMetric,
|
|
7484
7856
|
isMexicanNewsUrl,
|
|
7485
7857
|
isMoment,
|
|
7858
|
+
isNarrowableObject,
|
|
7486
7859
|
isNever,
|
|
7487
7860
|
isNewsUrl,
|
|
7488
7861
|
isNikeUrl,
|
|
@@ -7502,6 +7875,8 @@ export {
|
|
|
7502
7875
|
isPowerUom,
|
|
7503
7876
|
isPressureMetric,
|
|
7504
7877
|
isPressureUom,
|
|
7878
|
+
isProtocol,
|
|
7879
|
+
isProtocolPrefix,
|
|
7505
7880
|
isReadonlyArray,
|
|
7506
7881
|
isRecordToken,
|
|
7507
7882
|
isRef,
|
|
@@ -7517,6 +7892,7 @@ export {
|
|
|
7517
7892
|
isSet,
|
|
7518
7893
|
isSetBasedKind,
|
|
7519
7894
|
isSetBasedToken,
|
|
7895
|
+
isSetContainer,
|
|
7520
7896
|
isSetToken,
|
|
7521
7897
|
isShape,
|
|
7522
7898
|
isShapeCallback,
|
|
@@ -7579,6 +7955,7 @@ export {
|
|
|
7579
7955
|
isUsNewsUrl,
|
|
7580
7956
|
isUsStateAbbreviation,
|
|
7581
7957
|
isUsStateName,
|
|
7958
|
+
isVariable,
|
|
7582
7959
|
isVoltageMetric,
|
|
7583
7960
|
isVoltageUom,
|
|
7584
7961
|
isVolumeMetric,
|
|
@@ -7626,6 +8003,7 @@ export {
|
|
|
7626
8003
|
narrowObjectToType,
|
|
7627
8004
|
never,
|
|
7628
8005
|
objectToApi,
|
|
8006
|
+
objectValues,
|
|
7629
8007
|
omit,
|
|
7630
8008
|
optional,
|
|
7631
8009
|
optionalOrNull,
|
|
@@ -7702,6 +8080,7 @@ export {
|
|
|
7702
8080
|
widen,
|
|
7703
8081
|
withDefaults,
|
|
7704
8082
|
withKeys,
|
|
8083
|
+
withValue,
|
|
7705
8084
|
withoutKeys,
|
|
7706
8085
|
withoutValue,
|
|
7707
8086
|
wrapFn,
|