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
|
@@ -80,6 +80,9 @@ __export(src_exports, {
|
|
|
80
80
|
getTokenKind: () => getTokenKind,
|
|
81
81
|
getTomorrow: () => getTomorrow,
|
|
82
82
|
getTypeSubtype: () => getTypeSubtype,
|
|
83
|
+
getUrlBase: () => getUrlBase,
|
|
84
|
+
getUrlDefaultPort: () => getUrlDefaultPort,
|
|
85
|
+
getUrlDynamics: () => getUrlDynamics,
|
|
83
86
|
getUrlPath: () => getUrlPath,
|
|
84
87
|
getUrlPort: () => getUrlPort,
|
|
85
88
|
getUrlProtocol: () => getUrlProtocol,
|
|
@@ -92,6 +95,9 @@ __export(src_exports, {
|
|
|
92
95
|
hasDefaultValue: () => hasDefaultValue,
|
|
93
96
|
hasIndexOf: () => hasIndexOf,
|
|
94
97
|
hasKeys: () => hasKeys,
|
|
98
|
+
hasOverlappingKeys: () => hasOverlappingKeys,
|
|
99
|
+
hasProtocol: () => hasProtocol,
|
|
100
|
+
hasProtocolPrefix: () => hasProtocolPrefix,
|
|
95
101
|
hasUrlPort: () => hasUrlPort,
|
|
96
102
|
hasUrlQueryParameter: () => hasUrlQueryParameter,
|
|
97
103
|
hasWhiteSpace: () => hasWhiteSpace,
|
|
@@ -157,6 +163,7 @@ __export(src_exports, {
|
|
|
157
163
|
isCountryCode3: () => isCountryCode3,
|
|
158
164
|
isCountryName: () => isCountryName,
|
|
159
165
|
isCssAspectRatio: () => isCssAspectRatio,
|
|
166
|
+
isCsv: () => isCsv,
|
|
160
167
|
isCurrentMetric: () => isCurrentMetric,
|
|
161
168
|
isCurrentUom: () => isCurrentUom,
|
|
162
169
|
isCvsUrl: () => isCvsUrl,
|
|
@@ -233,12 +240,14 @@ __export(src_exports, {
|
|
|
233
240
|
isLuminosityUom: () => isLuminosityUom,
|
|
234
241
|
isLuxonDateTime: () => isLuxonDateTime,
|
|
235
242
|
isMacysUrl: () => isMacysUrl,
|
|
243
|
+
isMap: () => isMap,
|
|
236
244
|
isMapToken: () => isMapToken,
|
|
237
245
|
isMassMetric: () => isMassMetric,
|
|
238
246
|
isMassUom: () => isMassUom,
|
|
239
247
|
isMetric: () => isMetric,
|
|
240
248
|
isMexicanNewsUrl: () => isMexicanNewsUrl,
|
|
241
249
|
isMoment: () => isMoment,
|
|
250
|
+
isNarrowableObject: () => isNarrowableObject,
|
|
242
251
|
isNever: () => isNever,
|
|
243
252
|
isNewsUrl: () => isNewsUrl,
|
|
244
253
|
isNikeUrl: () => isNikeUrl,
|
|
@@ -258,6 +267,8 @@ __export(src_exports, {
|
|
|
258
267
|
isPowerUom: () => isPowerUom,
|
|
259
268
|
isPressureMetric: () => isPressureMetric,
|
|
260
269
|
isPressureUom: () => isPressureUom,
|
|
270
|
+
isProtocol: () => isProtocol,
|
|
271
|
+
isProtocolPrefix: () => isProtocolPrefix,
|
|
261
272
|
isReadonlyArray: () => isReadonlyArray,
|
|
262
273
|
isRecordToken: () => isRecordToken,
|
|
263
274
|
isRef: () => isRef,
|
|
@@ -273,6 +284,7 @@ __export(src_exports, {
|
|
|
273
284
|
isSet: () => isSet,
|
|
274
285
|
isSetBasedKind: () => isSetBasedKind,
|
|
275
286
|
isSetBasedToken: () => isSetBasedToken,
|
|
287
|
+
isSetContainer: () => isSetContainer,
|
|
276
288
|
isSetToken: () => isSetToken,
|
|
277
289
|
isShape: () => isShape,
|
|
278
290
|
isShapeCallback: () => isShapeCallback,
|
|
@@ -335,6 +347,7 @@ __export(src_exports, {
|
|
|
335
347
|
isUsNewsUrl: () => isUsNewsUrl,
|
|
336
348
|
isUsStateAbbreviation: () => isUsStateAbbreviation,
|
|
337
349
|
isUsStateName: () => isUsStateName,
|
|
350
|
+
isVariable: () => isVariable,
|
|
338
351
|
isVoltageMetric: () => isVoltageMetric,
|
|
339
352
|
isVoltageUom: () => isVoltageUom,
|
|
340
353
|
isVolumeMetric: () => isVolumeMetric,
|
|
@@ -382,6 +395,7 @@ __export(src_exports, {
|
|
|
382
395
|
narrowObjectToType: () => narrowObjectToType,
|
|
383
396
|
never: () => never,
|
|
384
397
|
objectToApi: () => objectToApi,
|
|
398
|
+
objectValues: () => objectValues,
|
|
385
399
|
omit: () => omit,
|
|
386
400
|
optional: () => optional,
|
|
387
401
|
optionalOrNull: () => optionalOrNull,
|
|
@@ -458,6 +472,7 @@ __export(src_exports, {
|
|
|
458
472
|
widen: () => widen,
|
|
459
473
|
withDefaults: () => withDefaults,
|
|
460
474
|
withKeys: () => withKeys,
|
|
475
|
+
withValue: () => withValue,
|
|
461
476
|
withoutKeys: () => withoutKeys,
|
|
462
477
|
withoutValue: () => withoutValue,
|
|
463
478
|
wrapFn: () => wrapFn,
|
|
@@ -1153,13 +1168,51 @@ var AREA_METRICS_LOOKUP = [
|
|
|
1153
1168
|
{ abbrev: "acre", name: "acre" },
|
|
1154
1169
|
{ abbrev: "ha", name: "hectare" }
|
|
1155
1170
|
];
|
|
1171
|
+
var NETWORK_PROTOCOL_INSECURE = [
|
|
1172
|
+
"http",
|
|
1173
|
+
"ftp",
|
|
1174
|
+
"ws",
|
|
1175
|
+
"dns",
|
|
1176
|
+
"telnet",
|
|
1177
|
+
"imap",
|
|
1178
|
+
"pop3",
|
|
1179
|
+
"smtp"
|
|
1180
|
+
];
|
|
1181
|
+
var NETWORK_PROTOCOL_SECURE = [
|
|
1182
|
+
"https",
|
|
1183
|
+
"sftp",
|
|
1184
|
+
"wss",
|
|
1185
|
+
"sdns",
|
|
1186
|
+
"ssh"
|
|
1187
|
+
];
|
|
1188
|
+
var NETWORK_PROTOCOL = [
|
|
1189
|
+
...NETWORK_PROTOCOL_INSECURE,
|
|
1190
|
+
...NETWORK_PROTOCOL_SECURE
|
|
1191
|
+
];
|
|
1156
1192
|
var NETWORK_PROTOCOL_LOOKUP = {
|
|
1157
1193
|
http: ["http", "https"],
|
|
1158
1194
|
ftp: ["ftp", "sftp"],
|
|
1159
1195
|
file: ["", "file"],
|
|
1160
1196
|
ws: ["ws", "wss"],
|
|
1161
1197
|
ssh: ["", "ssh"],
|
|
1162
|
-
scp: ["", "scp"]
|
|
1198
|
+
scp: ["", "scp"],
|
|
1199
|
+
telnet: ["telnet", ""],
|
|
1200
|
+
dns: ["dns", "sdns"]
|
|
1201
|
+
};
|
|
1202
|
+
var PROTOCOL_DEFAULT_PORTS = {
|
|
1203
|
+
http: 80,
|
|
1204
|
+
https: 443,
|
|
1205
|
+
ws: 80,
|
|
1206
|
+
wss: 443,
|
|
1207
|
+
ssh: 22,
|
|
1208
|
+
telnet: 23,
|
|
1209
|
+
dns: 53,
|
|
1210
|
+
sdns: 853,
|
|
1211
|
+
smtp: 25,
|
|
1212
|
+
imap: 142,
|
|
1213
|
+
pop3: 110,
|
|
1214
|
+
ftp: 21,
|
|
1215
|
+
sftp: 22
|
|
1163
1216
|
};
|
|
1164
1217
|
var Never = createConstant("never");
|
|
1165
1218
|
var US_NEWS = [
|
|
@@ -2665,6 +2718,18 @@ function narrowObjectToType() {
|
|
|
2665
2718
|
);
|
|
2666
2719
|
}
|
|
2667
2720
|
|
|
2721
|
+
// src/dictionary/objectValues.ts
|
|
2722
|
+
function objectValues(obj) {
|
|
2723
|
+
const tuple3 = Object.keys(obj).reduce(
|
|
2724
|
+
(acc, key) => [
|
|
2725
|
+
...acc,
|
|
2726
|
+
obj[key]
|
|
2727
|
+
],
|
|
2728
|
+
[]
|
|
2729
|
+
);
|
|
2730
|
+
return tuple3;
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2668
2733
|
// src/dictionary/omit.ts
|
|
2669
2734
|
function omit(obj, ...removeKeys) {
|
|
2670
2735
|
const keys = Object.keys(obj);
|
|
@@ -2731,13 +2796,115 @@ function withoutKeys(dict, ...exclude) {
|
|
|
2731
2796
|
return omit(dict, ...exclude);
|
|
2732
2797
|
}
|
|
2733
2798
|
|
|
2799
|
+
// src/runtime-types/doesExtend.ts
|
|
2800
|
+
function doesExtend(type) {
|
|
2801
|
+
return (val) => {
|
|
2802
|
+
let response = false;
|
|
2803
|
+
if (isString(val)) {
|
|
2804
|
+
if (type === "string") {
|
|
2805
|
+
response = true;
|
|
2806
|
+
}
|
|
2807
|
+
if (type.startsWith("string(")) {
|
|
2808
|
+
const literals = stripAfter(
|
|
2809
|
+
stripBefore(type, "string("),
|
|
2810
|
+
")"
|
|
2811
|
+
).split(/,\s*/);
|
|
2812
|
+
if (literals.includes(val)) {
|
|
2813
|
+
response = true;
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
if (isNumber(val)) {
|
|
2818
|
+
if (type === "number") {
|
|
2819
|
+
response = true;
|
|
2820
|
+
}
|
|
2821
|
+
if (type.startsWith("number(")) {
|
|
2822
|
+
const literals = stripAfter(
|
|
2823
|
+
stripBefore(type, "number("),
|
|
2824
|
+
")"
|
|
2825
|
+
).split(/,\s*/).map(Number);
|
|
2826
|
+
if (literals.includes(val)) {
|
|
2827
|
+
response = true;
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
if (isNull(val) && (type === "null" || type === "Opt<null>")) {
|
|
2832
|
+
response = true;
|
|
2833
|
+
}
|
|
2834
|
+
if (isUndefined(val) && (type === "undefined" || type.startsWith("Opt<"))) {
|
|
2835
|
+
response = true;
|
|
2836
|
+
}
|
|
2837
|
+
if (isBoolean(val)) {
|
|
2838
|
+
if (type === "boolean") {
|
|
2839
|
+
response = true;
|
|
2840
|
+
}
|
|
2841
|
+
if (type === "true" && val === true || type === "false" && val === false) {
|
|
2842
|
+
response = true;
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
if (isNarrowableObject(val)) {
|
|
2846
|
+
if (type === "Dict" || type === "Dict<string, unknown>") {
|
|
2847
|
+
response = true;
|
|
2848
|
+
}
|
|
2849
|
+
if (startsWith("Dict<")(type)) {
|
|
2850
|
+
const match = infer("Dict<{{infer key}}, {{infer value}}>")(type);
|
|
2851
|
+
if (match) {
|
|
2852
|
+
const { value } = match;
|
|
2853
|
+
const isOpt = value.includes(`Opt<`);
|
|
2854
|
+
const values = objectValues(val);
|
|
2855
|
+
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>") {
|
|
2856
|
+
response = true;
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
if (isArray(val)) {
|
|
2862
|
+
if (type === "Array" || type === "Array<unknown>") {
|
|
2863
|
+
return true;
|
|
2864
|
+
}
|
|
2865
|
+
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)) {
|
|
2866
|
+
response = true;
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
if (isMap(val)) {
|
|
2870
|
+
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)) {
|
|
2871
|
+
response = true;
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
if (isSetContainer(val)) {
|
|
2875
|
+
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))) {
|
|
2876
|
+
response = true;
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
return response;
|
|
2880
|
+
};
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2734
2883
|
// src/dictionary/withoutValue.ts
|
|
2735
|
-
function withoutValue(
|
|
2884
|
+
function withoutValue(wo) {
|
|
2736
2885
|
return (obj) => {
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2886
|
+
const output = {};
|
|
2887
|
+
for (const key of keysOf(obj)) {
|
|
2888
|
+
const val = obj[key];
|
|
2889
|
+
if (!doesExtend(wo)(val)) {
|
|
2890
|
+
output[key] = val;
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
return output;
|
|
2894
|
+
};
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
// src/dictionary/withValue.ts
|
|
2898
|
+
function withValue(wo) {
|
|
2899
|
+
return (obj) => {
|
|
2900
|
+
const output = {};
|
|
2901
|
+
for (const key of keysOf(obj)) {
|
|
2902
|
+
const val = obj[key];
|
|
2903
|
+
if (doesExtend(wo)(val)) {
|
|
2904
|
+
output[key] = val;
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
return output;
|
|
2741
2908
|
};
|
|
2742
2909
|
}
|
|
2743
2910
|
|
|
@@ -2822,7 +2989,7 @@ var filter = "NOT READY";
|
|
|
2822
2989
|
function find(list2, deref = null) {
|
|
2823
2990
|
return (comparator) => {
|
|
2824
2991
|
return list2.find((i) => {
|
|
2825
|
-
const val = deref ?
|
|
2992
|
+
const val = deref ? isObject(i) || isArray(i) ? deref in i ? i[deref] : void 0 : i : i;
|
|
2826
2993
|
return val === comparator;
|
|
2827
2994
|
});
|
|
2828
2995
|
};
|
|
@@ -3012,6 +3179,9 @@ function isFunction(value) {
|
|
|
3012
3179
|
function isObject(value) {
|
|
3013
3180
|
return typeof value === "object" && value !== null && Array.isArray(value) === false;
|
|
3014
3181
|
}
|
|
3182
|
+
function isNarrowableObject(value) {
|
|
3183
|
+
return isObject(value) && Object.keys(value).every((key) => ["string", "number", "boolean", "symbol", "object", "undefined", "void", "null"].includes(typeof value[key]));
|
|
3184
|
+
}
|
|
3015
3185
|
|
|
3016
3186
|
// src/type-guards/api-tg.ts
|
|
3017
3187
|
function isEscapeFunction(val) {
|
|
@@ -3652,6 +3822,11 @@ function isCssAspectRatio(val) {
|
|
|
3652
3822
|
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
3653
3823
|
}
|
|
3654
3824
|
|
|
3825
|
+
// src/type-guards/isCsv.ts
|
|
3826
|
+
function isCsv(val) {
|
|
3827
|
+
return isString(val) && val.includes(",") && !val.startsWith(",");
|
|
3828
|
+
}
|
|
3829
|
+
|
|
3655
3830
|
// src/type-guards/isDefined.ts
|
|
3656
3831
|
function isDefined(value) {
|
|
3657
3832
|
return typeof value !== "undefined";
|
|
@@ -3709,6 +3884,11 @@ function isInlineSvg(v) {
|
|
|
3709
3884
|
return isString(v) && v.trim().startsWith(`<svg`) && v.trim().endsWith(`</svg>`);
|
|
3710
3885
|
}
|
|
3711
3886
|
|
|
3887
|
+
// src/type-guards/isMap.ts
|
|
3888
|
+
function isMap(val) {
|
|
3889
|
+
return val instanceof Map;
|
|
3890
|
+
}
|
|
3891
|
+
|
|
3712
3892
|
// src/type-guards/isNever.ts
|
|
3713
3893
|
function isNever(val) {
|
|
3714
3894
|
return isConstant(val) && val.kind === "never";
|
|
@@ -3729,7 +3909,7 @@ function isPhoneNumber(val) {
|
|
|
3729
3909
|
const svelte = String(val).trim();
|
|
3730
3910
|
const chars = svelte.split("");
|
|
3731
3911
|
const numeric = retainChars(svelte, ...NUMERIC_CHAR);
|
|
3732
|
-
const
|
|
3912
|
+
const valid2 = ["+", "(", ...NUMERIC_CHAR];
|
|
3733
3913
|
const nothing = stripChars(svelte, ...[
|
|
3734
3914
|
...NUMERIC_CHAR,
|
|
3735
3915
|
...WHITESPACE_CHARS,
|
|
@@ -3739,7 +3919,7 @@ function isPhoneNumber(val) {
|
|
|
3739
3919
|
".",
|
|
3740
3920
|
"-"
|
|
3741
3921
|
]);
|
|
3742
|
-
return chars.every((i) =>
|
|
3922
|
+
return chars.every((i) => valid2.includes(i)) && svelte.startsWith(`+`) ? numeric.length >= 8 : svelte.startsWith(`00`) ? numeric.length >= 10 : numeric.length >= 7 && nothing === "";
|
|
3743
3923
|
}
|
|
3744
3924
|
|
|
3745
3925
|
// src/type-guards/isReadonlyArray.ts
|
|
@@ -3771,6 +3951,16 @@ function isLikeRegExp(val) {
|
|
|
3771
3951
|
return false;
|
|
3772
3952
|
}
|
|
3773
3953
|
|
|
3954
|
+
// src/type-guards/isSet.ts
|
|
3955
|
+
function isSet(val) {
|
|
3956
|
+
return isObject(val) ? val.kind !== "Unset" : true;
|
|
3957
|
+
}
|
|
3958
|
+
|
|
3959
|
+
// src/type-guards/isSetContainer.ts
|
|
3960
|
+
function isSetContainer(val) {
|
|
3961
|
+
return val instanceof Set;
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3774
3964
|
// src/type-guards/isStringArray.ts
|
|
3775
3965
|
function isStringArray(val) {
|
|
3776
3966
|
return Array.isArray(val) && val.every((i) => isString(i));
|
|
@@ -3810,9 +4000,6 @@ function isTypeTuple(value) {
|
|
|
3810
4000
|
function isUnset(val) {
|
|
3811
4001
|
return isObject(val) && val.kind === "Unset";
|
|
3812
4002
|
}
|
|
3813
|
-
function isSet(val) {
|
|
3814
|
-
return isObject(val) ? val.kind !== "Unset" : true;
|
|
3815
|
-
}
|
|
3816
4003
|
|
|
3817
4004
|
// src/type-guards/isUrl.ts
|
|
3818
4005
|
function isUri(val, ...protocols) {
|
|
@@ -3824,6 +4011,21 @@ function isUrl(val, ...protocols) {
|
|
|
3824
4011
|
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
3825
4012
|
}
|
|
3826
4013
|
|
|
4014
|
+
// src/type-guards/isVariable.ts
|
|
4015
|
+
var VALID = [
|
|
4016
|
+
...ALPHA_CHARS,
|
|
4017
|
+
...NUMERIC_CHAR,
|
|
4018
|
+
"_",
|
|
4019
|
+
"."
|
|
4020
|
+
];
|
|
4021
|
+
var alpha = null;
|
|
4022
|
+
function valid(chars) {
|
|
4023
|
+
return chars.every((i) => VALID.includes(i));
|
|
4024
|
+
}
|
|
4025
|
+
function isVariable(val) {
|
|
4026
|
+
return isString(val) && startsWith(alpha)(val) && valid(asChars(val));
|
|
4027
|
+
}
|
|
4028
|
+
|
|
3827
4029
|
// src/type-guards/metrics/isMetric.ts
|
|
3828
4030
|
function separate(s) {
|
|
3829
4031
|
return stripWhile(s.toLowerCase(), ...NUMERIC_CHAR).trim();
|
|
@@ -3970,6 +4172,20 @@ function isNumericArray(val) {
|
|
|
3970
4172
|
return Array.isArray(val) && val.every((i) => isNumber(i));
|
|
3971
4173
|
}
|
|
3972
4174
|
|
|
4175
|
+
// src/type-guards/protocol.ts
|
|
4176
|
+
function hasProtocol(val, ...protocols) {
|
|
4177
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL.some((i) => val.startsWith(i)) : protocols.some((i) => val.startsWith(i));
|
|
4178
|
+
}
|
|
4179
|
+
function isProtocol(val, ...protocols) {
|
|
4180
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL.includes(val) : protocols.includes(val);
|
|
4181
|
+
}
|
|
4182
|
+
function hasProtocolPrefix(val, ...protocols) {
|
|
4183
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL.map((i) => `${i}://`).some((i) => val.startsWith(i)) : protocols.map((i) => `${i}://`).some((i) => val.startsWith(i));
|
|
4184
|
+
}
|
|
4185
|
+
function isProtocolPrefix(val, ...protocols) {
|
|
4186
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL.map((i) => `${i}://`).includes(val) : protocols.map((i) => `${i}://`).includes(val);
|
|
4187
|
+
}
|
|
4188
|
+
|
|
3973
4189
|
// src/type-guards/tokens/general.ts
|
|
3974
4190
|
function isTypeToken(val, kind) {
|
|
3975
4191
|
if (isString(val) && val.startsWith("<<") && val.endsWith(">>")) {
|
|
@@ -4264,28 +4480,28 @@ function isNewsUrl(val) {
|
|
|
4264
4480
|
|
|
4265
4481
|
// src/type-guards/urls/repos/bitbucket.ts
|
|
4266
4482
|
function isBitbucketUrl(val) {
|
|
4267
|
-
const
|
|
4268
|
-
return isString(val) &&
|
|
4483
|
+
const valid2 = REPO_SOURCE_LOOKUP.bitbucket;
|
|
4484
|
+
return isString(val) && valid2.some(
|
|
4269
4485
|
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
4270
4486
|
);
|
|
4271
4487
|
}
|
|
4272
4488
|
|
|
4273
4489
|
// src/type-guards/urls/repos/codeCommit.ts
|
|
4274
4490
|
function isCodeCommitUrl(val) {
|
|
4275
|
-
const
|
|
4276
|
-
return isString(val) &&
|
|
4491
|
+
const valid2 = REPO_SOURCE_LOOKUP.codecommit;
|
|
4492
|
+
return isString(val) && valid2.some(
|
|
4277
4493
|
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
4278
4494
|
);
|
|
4279
4495
|
}
|
|
4280
4496
|
|
|
4281
4497
|
// src/type-guards/urls/repos/github.ts
|
|
4282
4498
|
function isGithubUrl(val) {
|
|
4283
|
-
const
|
|
4499
|
+
const valid2 = [
|
|
4284
4500
|
"https://github.com",
|
|
4285
4501
|
"https://www.github.com",
|
|
4286
4502
|
"https://github.io"
|
|
4287
4503
|
];
|
|
4288
|
-
return isString(val) &&
|
|
4504
|
+
return isString(val) && valid2.some(
|
|
4289
4505
|
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
4290
4506
|
);
|
|
4291
4507
|
}
|
|
@@ -4923,16 +5139,77 @@ function getUrlQueryParams(url, specific = void 0) {
|
|
|
4923
5139
|
}
|
|
4924
5140
|
return qp === "" ? qp : `?${qp}`;
|
|
4925
5141
|
}
|
|
4926
|
-
function
|
|
4927
|
-
const
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
5142
|
+
function getUrlDefaultPort(url) {
|
|
5143
|
+
const proto = getUrlProtocol(url);
|
|
5144
|
+
return proto in PROTOCOL_DEFAULT_PORTS ? PROTOCOL_DEFAULT_PORTS[proto] : null;
|
|
5145
|
+
}
|
|
5146
|
+
function getUrlPort(url, resolve = false) {
|
|
5147
|
+
const re = /.*:(\d{2,3})/;
|
|
5148
|
+
const match = url.match(re);
|
|
5149
|
+
return re.test(url) && match && isNumberLike(Array.from(match)[1]) ? Number(Array.from(match)[1]) : resolve ? getUrlDefaultPort(url) : hasProtocol(url) ? `default` : null;
|
|
4931
5150
|
}
|
|
4932
5151
|
function getUrlSource(url) {
|
|
4933
5152
|
const candidate = stripAfter(stripAfter(stripAfter(removeUrlProtocol(url), "/"), "?"), ":");
|
|
4934
5153
|
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never;
|
|
4935
5154
|
}
|
|
5155
|
+
function getUrlBase(url) {
|
|
5156
|
+
const path = getUrlPath(url);
|
|
5157
|
+
const remaining = stripAfter(url, path);
|
|
5158
|
+
return remaining;
|
|
5159
|
+
}
|
|
5160
|
+
function getUrlDynamics(url) {
|
|
5161
|
+
const path = getUrlPath(url);
|
|
5162
|
+
const qp = getUrlQueryParams(url);
|
|
5163
|
+
const pathParts = path.startsWith("<") ? path.split("<").map((i) => ensureLeading(i, "<")) : path.split("<").map((i) => ensureLeading(i, "<")).slice(1);
|
|
5164
|
+
const segmentTypes = [
|
|
5165
|
+
"string",
|
|
5166
|
+
"number",
|
|
5167
|
+
"boolean",
|
|
5168
|
+
"Opt<string>",
|
|
5169
|
+
"Opt<number>",
|
|
5170
|
+
"Opt<boolean>"
|
|
5171
|
+
];
|
|
5172
|
+
const pathVars = {};
|
|
5173
|
+
const findPathTyped = infer(`<{{infer name}} as {{infer type}}>`);
|
|
5174
|
+
const findPathUnion = infer(`<{{infer name}} as string({{infer union}})>`);
|
|
5175
|
+
const findPathNamed = infer(`<{{infer name}}>`);
|
|
5176
|
+
for (const part of pathParts) {
|
|
5177
|
+
const union4 = findPathUnion(part);
|
|
5178
|
+
const typed = findPathTyped(part);
|
|
5179
|
+
const named = findPathNamed(part);
|
|
5180
|
+
if (union4) {
|
|
5181
|
+
if (isVariable(union4.name) && isCsv(union4.union)) {
|
|
5182
|
+
pathVars[union4.name] = `string(${union4.union})`;
|
|
5183
|
+
}
|
|
5184
|
+
} else if (typed && segmentTypes.includes(typed.type) && isVariable(typed.name)) {
|
|
5185
|
+
pathVars[typed.name] = typed.type;
|
|
5186
|
+
} else if (named && isVariable(named.name)) {
|
|
5187
|
+
pathVars[named.name] = "string";
|
|
5188
|
+
}
|
|
5189
|
+
}
|
|
5190
|
+
const qpVars = {};
|
|
5191
|
+
const qpParts = stripLeading(qp, "?").split("&");
|
|
5192
|
+
for (const p of qpParts) {
|
|
5193
|
+
const union4 = infer(`{{infer var}}=<string({{infer params}})>`)(p);
|
|
5194
|
+
const dynamic = infer(`{{infer var}}=<{{infer val}}>`)(p);
|
|
5195
|
+
const fixed = infer(`{{infer var}}={{infer val}}`)(p);
|
|
5196
|
+
if (union4 && isVariable(union4.var) && isCsv(union4.params)) {
|
|
5197
|
+
qpVars[union4.var] = `string(${union4.params})`;
|
|
5198
|
+
} else if (dynamic && isVariable(dynamic.var) && segmentTypes.includes(dynamic.val)) {
|
|
5199
|
+
qpVars[dynamic.var] = dynamic.val;
|
|
5200
|
+
} else if (fixed && isVariable(fixed.var)) {
|
|
5201
|
+
qpVars[fixed.var] = fixed.val;
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
return {
|
|
5205
|
+
pathVars,
|
|
5206
|
+
qpVars,
|
|
5207
|
+
allVars: hasOverlappingKeys(pathVars, qpVars) ? null : {
|
|
5208
|
+
...pathVars,
|
|
5209
|
+
...qpVars
|
|
5210
|
+
}
|
|
5211
|
+
};
|
|
5212
|
+
}
|
|
4936
5213
|
function urlMeta(url) {
|
|
4937
5214
|
return {
|
|
4938
5215
|
url,
|
|
@@ -4940,6 +5217,7 @@ function urlMeta(url) {
|
|
|
4940
5217
|
protocol: getUrlProtocol(url),
|
|
4941
5218
|
path: getUrlPath(url),
|
|
4942
5219
|
queryParameters: getUrlQueryParams(url),
|
|
5220
|
+
params: getUrlDynamics,
|
|
4943
5221
|
port: getUrlPort(url),
|
|
4944
5222
|
source: getUrlSource(url),
|
|
4945
5223
|
isIpAddress: isIpAddress(getUrlSource(url)),
|
|
@@ -5385,6 +5663,17 @@ function simpleType(token) {
|
|
|
5385
5663
|
return value;
|
|
5386
5664
|
}
|
|
5387
5665
|
|
|
5666
|
+
// src/sets/hasOverlappingKeys.ts
|
|
5667
|
+
function hasOverlappingKeys(a, b) {
|
|
5668
|
+
const keys = Object.keys(a);
|
|
5669
|
+
for (const k of keys) {
|
|
5670
|
+
if (k in b) {
|
|
5671
|
+
return true;
|
|
5672
|
+
}
|
|
5673
|
+
}
|
|
5674
|
+
return false;
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5388
5677
|
// src/sets/uniqueKeys.ts
|
|
5389
5678
|
function uniqueKeys(left, right) {
|
|
5390
5679
|
const isNumeric = !!(isArray(left) && isArray(right));
|
|
@@ -5474,6 +5763,9 @@ function asVueRef(value) {
|
|
|
5474
5763
|
getTokenKind,
|
|
5475
5764
|
getTomorrow,
|
|
5476
5765
|
getTypeSubtype,
|
|
5766
|
+
getUrlBase,
|
|
5767
|
+
getUrlDefaultPort,
|
|
5768
|
+
getUrlDynamics,
|
|
5477
5769
|
getUrlPath,
|
|
5478
5770
|
getUrlPort,
|
|
5479
5771
|
getUrlProtocol,
|
|
@@ -5486,6 +5778,9 @@ function asVueRef(value) {
|
|
|
5486
5778
|
hasDefaultValue,
|
|
5487
5779
|
hasIndexOf,
|
|
5488
5780
|
hasKeys,
|
|
5781
|
+
hasOverlappingKeys,
|
|
5782
|
+
hasProtocol,
|
|
5783
|
+
hasProtocolPrefix,
|
|
5489
5784
|
hasUrlPort,
|
|
5490
5785
|
hasUrlQueryParameter,
|
|
5491
5786
|
hasWhiteSpace,
|
|
@@ -5551,6 +5846,7 @@ function asVueRef(value) {
|
|
|
5551
5846
|
isCountryCode3,
|
|
5552
5847
|
isCountryName,
|
|
5553
5848
|
isCssAspectRatio,
|
|
5849
|
+
isCsv,
|
|
5554
5850
|
isCurrentMetric,
|
|
5555
5851
|
isCurrentUom,
|
|
5556
5852
|
isCvsUrl,
|
|
@@ -5627,12 +5923,14 @@ function asVueRef(value) {
|
|
|
5627
5923
|
isLuminosityUom,
|
|
5628
5924
|
isLuxonDateTime,
|
|
5629
5925
|
isMacysUrl,
|
|
5926
|
+
isMap,
|
|
5630
5927
|
isMapToken,
|
|
5631
5928
|
isMassMetric,
|
|
5632
5929
|
isMassUom,
|
|
5633
5930
|
isMetric,
|
|
5634
5931
|
isMexicanNewsUrl,
|
|
5635
5932
|
isMoment,
|
|
5933
|
+
isNarrowableObject,
|
|
5636
5934
|
isNever,
|
|
5637
5935
|
isNewsUrl,
|
|
5638
5936
|
isNikeUrl,
|
|
@@ -5652,6 +5950,8 @@ function asVueRef(value) {
|
|
|
5652
5950
|
isPowerUom,
|
|
5653
5951
|
isPressureMetric,
|
|
5654
5952
|
isPressureUom,
|
|
5953
|
+
isProtocol,
|
|
5954
|
+
isProtocolPrefix,
|
|
5655
5955
|
isReadonlyArray,
|
|
5656
5956
|
isRecordToken,
|
|
5657
5957
|
isRef,
|
|
@@ -5667,6 +5967,7 @@ function asVueRef(value) {
|
|
|
5667
5967
|
isSet,
|
|
5668
5968
|
isSetBasedKind,
|
|
5669
5969
|
isSetBasedToken,
|
|
5970
|
+
isSetContainer,
|
|
5670
5971
|
isSetToken,
|
|
5671
5972
|
isShape,
|
|
5672
5973
|
isShapeCallback,
|
|
@@ -5729,6 +6030,7 @@ function asVueRef(value) {
|
|
|
5729
6030
|
isUsNewsUrl,
|
|
5730
6031
|
isUsStateAbbreviation,
|
|
5731
6032
|
isUsStateName,
|
|
6033
|
+
isVariable,
|
|
5732
6034
|
isVoltageMetric,
|
|
5733
6035
|
isVoltageUom,
|
|
5734
6036
|
isVolumeMetric,
|
|
@@ -5776,6 +6078,7 @@ function asVueRef(value) {
|
|
|
5776
6078
|
narrowObjectToType,
|
|
5777
6079
|
never,
|
|
5778
6080
|
objectToApi,
|
|
6081
|
+
objectValues,
|
|
5779
6082
|
omit,
|
|
5780
6083
|
optional,
|
|
5781
6084
|
optionalOrNull,
|
|
@@ -5852,6 +6155,7 @@ function asVueRef(value) {
|
|
|
5852
6155
|
widen,
|
|
5853
6156
|
withDefaults,
|
|
5854
6157
|
withKeys,
|
|
6158
|
+
withValue,
|
|
5855
6159
|
withoutKeys,
|
|
5856
6160
|
withoutValue,
|
|
5857
6161
|
wrapFn,
|