inferred-types 0.54.9 → 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/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 +288 -16
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +21421 -20785
- package/modules/inferred-types/dist/index.js +273 -16
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +180 -15
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +5406 -5142
- package/modules/runtime/dist/index.js +170 -15
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.d.ts +9680 -9336
- 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,
|
|
@@ -260,6 +267,8 @@ __export(src_exports, {
|
|
|
260
267
|
isPowerUom: () => isPowerUom,
|
|
261
268
|
isPressureMetric: () => isPressureMetric,
|
|
262
269
|
isPressureUom: () => isPressureUom,
|
|
270
|
+
isProtocol: () => isProtocol,
|
|
271
|
+
isProtocolPrefix: () => isProtocolPrefix,
|
|
263
272
|
isReadonlyArray: () => isReadonlyArray,
|
|
264
273
|
isRecordToken: () => isRecordToken,
|
|
265
274
|
isRef: () => isRef,
|
|
@@ -338,6 +347,7 @@ __export(src_exports, {
|
|
|
338
347
|
isUsNewsUrl: () => isUsNewsUrl,
|
|
339
348
|
isUsStateAbbreviation: () => isUsStateAbbreviation,
|
|
340
349
|
isUsStateName: () => isUsStateName,
|
|
350
|
+
isVariable: () => isVariable,
|
|
341
351
|
isVoltageMetric: () => isVoltageMetric,
|
|
342
352
|
isVoltageUom: () => isVoltageUom,
|
|
343
353
|
isVolumeMetric: () => isVolumeMetric,
|
|
@@ -1158,13 +1168,51 @@ var AREA_METRICS_LOOKUP = [
|
|
|
1158
1168
|
{ abbrev: "acre", name: "acre" },
|
|
1159
1169
|
{ abbrev: "ha", name: "hectare" }
|
|
1160
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
|
+
];
|
|
1161
1192
|
var NETWORK_PROTOCOL_LOOKUP = {
|
|
1162
1193
|
http: ["http", "https"],
|
|
1163
1194
|
ftp: ["ftp", "sftp"],
|
|
1164
1195
|
file: ["", "file"],
|
|
1165
1196
|
ws: ["ws", "wss"],
|
|
1166
1197
|
ssh: ["", "ssh"],
|
|
1167
|
-
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
|
|
1168
1216
|
};
|
|
1169
1217
|
var Never = createConstant("never");
|
|
1170
1218
|
var US_NEWS = [
|
|
@@ -2941,7 +2989,7 @@ var filter = "NOT READY";
|
|
|
2941
2989
|
function find(list2, deref = null) {
|
|
2942
2990
|
return (comparator) => {
|
|
2943
2991
|
return list2.find((i) => {
|
|
2944
|
-
const val = deref ?
|
|
2992
|
+
const val = deref ? isObject(i) || isArray(i) ? deref in i ? i[deref] : void 0 : i : i;
|
|
2945
2993
|
return val === comparator;
|
|
2946
2994
|
});
|
|
2947
2995
|
};
|
|
@@ -3774,6 +3822,11 @@ function isCssAspectRatio(val) {
|
|
|
3774
3822
|
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
3775
3823
|
}
|
|
3776
3824
|
|
|
3825
|
+
// src/type-guards/isCsv.ts
|
|
3826
|
+
function isCsv(val) {
|
|
3827
|
+
return isString(val) && val.includes(",") && !val.startsWith(",");
|
|
3828
|
+
}
|
|
3829
|
+
|
|
3777
3830
|
// src/type-guards/isDefined.ts
|
|
3778
3831
|
function isDefined(value) {
|
|
3779
3832
|
return typeof value !== "undefined";
|
|
@@ -3856,7 +3909,7 @@ function isPhoneNumber(val) {
|
|
|
3856
3909
|
const svelte = String(val).trim();
|
|
3857
3910
|
const chars = svelte.split("");
|
|
3858
3911
|
const numeric = retainChars(svelte, ...NUMERIC_CHAR);
|
|
3859
|
-
const
|
|
3912
|
+
const valid2 = ["+", "(", ...NUMERIC_CHAR];
|
|
3860
3913
|
const nothing = stripChars(svelte, ...[
|
|
3861
3914
|
...NUMERIC_CHAR,
|
|
3862
3915
|
...WHITESPACE_CHARS,
|
|
@@ -3866,7 +3919,7 @@ function isPhoneNumber(val) {
|
|
|
3866
3919
|
".",
|
|
3867
3920
|
"-"
|
|
3868
3921
|
]);
|
|
3869
|
-
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 === "";
|
|
3870
3923
|
}
|
|
3871
3924
|
|
|
3872
3925
|
// src/type-guards/isReadonlyArray.ts
|
|
@@ -3958,6 +4011,21 @@ function isUrl(val, ...protocols) {
|
|
|
3958
4011
|
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
3959
4012
|
}
|
|
3960
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
|
+
|
|
3961
4029
|
// src/type-guards/metrics/isMetric.ts
|
|
3962
4030
|
function separate(s) {
|
|
3963
4031
|
return stripWhile(s.toLowerCase(), ...NUMERIC_CHAR).trim();
|
|
@@ -4104,6 +4172,20 @@ function isNumericArray(val) {
|
|
|
4104
4172
|
return Array.isArray(val) && val.every((i) => isNumber(i));
|
|
4105
4173
|
}
|
|
4106
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
|
+
|
|
4107
4189
|
// src/type-guards/tokens/general.ts
|
|
4108
4190
|
function isTypeToken(val, kind) {
|
|
4109
4191
|
if (isString(val) && val.startsWith("<<") && val.endsWith(">>")) {
|
|
@@ -4398,28 +4480,28 @@ function isNewsUrl(val) {
|
|
|
4398
4480
|
|
|
4399
4481
|
// src/type-guards/urls/repos/bitbucket.ts
|
|
4400
4482
|
function isBitbucketUrl(val) {
|
|
4401
|
-
const
|
|
4402
|
-
return isString(val) &&
|
|
4483
|
+
const valid2 = REPO_SOURCE_LOOKUP.bitbucket;
|
|
4484
|
+
return isString(val) && valid2.some(
|
|
4403
4485
|
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
4404
4486
|
);
|
|
4405
4487
|
}
|
|
4406
4488
|
|
|
4407
4489
|
// src/type-guards/urls/repos/codeCommit.ts
|
|
4408
4490
|
function isCodeCommitUrl(val) {
|
|
4409
|
-
const
|
|
4410
|
-
return isString(val) &&
|
|
4491
|
+
const valid2 = REPO_SOURCE_LOOKUP.codecommit;
|
|
4492
|
+
return isString(val) && valid2.some(
|
|
4411
4493
|
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
4412
4494
|
);
|
|
4413
4495
|
}
|
|
4414
4496
|
|
|
4415
4497
|
// src/type-guards/urls/repos/github.ts
|
|
4416
4498
|
function isGithubUrl(val) {
|
|
4417
|
-
const
|
|
4499
|
+
const valid2 = [
|
|
4418
4500
|
"https://github.com",
|
|
4419
4501
|
"https://www.github.com",
|
|
4420
4502
|
"https://github.io"
|
|
4421
4503
|
];
|
|
4422
|
-
return isString(val) &&
|
|
4504
|
+
return isString(val) && valid2.some(
|
|
4423
4505
|
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
4424
4506
|
);
|
|
4425
4507
|
}
|
|
@@ -5057,16 +5139,77 @@ function getUrlQueryParams(url, specific = void 0) {
|
|
|
5057
5139
|
}
|
|
5058
5140
|
return qp === "" ? qp : `?${qp}`;
|
|
5059
5141
|
}
|
|
5060
|
-
function
|
|
5061
|
-
const
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
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;
|
|
5065
5150
|
}
|
|
5066
5151
|
function getUrlSource(url) {
|
|
5067
5152
|
const candidate = stripAfter(stripAfter(stripAfter(removeUrlProtocol(url), "/"), "?"), ":");
|
|
5068
5153
|
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never;
|
|
5069
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
|
+
}
|
|
5070
5213
|
function urlMeta(url) {
|
|
5071
5214
|
return {
|
|
5072
5215
|
url,
|
|
@@ -5074,6 +5217,7 @@ function urlMeta(url) {
|
|
|
5074
5217
|
protocol: getUrlProtocol(url),
|
|
5075
5218
|
path: getUrlPath(url),
|
|
5076
5219
|
queryParameters: getUrlQueryParams(url),
|
|
5220
|
+
params: getUrlDynamics,
|
|
5077
5221
|
port: getUrlPort(url),
|
|
5078
5222
|
source: getUrlSource(url),
|
|
5079
5223
|
isIpAddress: isIpAddress(getUrlSource(url)),
|
|
@@ -5519,6 +5663,17 @@ function simpleType(token) {
|
|
|
5519
5663
|
return value;
|
|
5520
5664
|
}
|
|
5521
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
|
+
|
|
5522
5677
|
// src/sets/uniqueKeys.ts
|
|
5523
5678
|
function uniqueKeys(left, right) {
|
|
5524
5679
|
const isNumeric = !!(isArray(left) && isArray(right));
|
|
@@ -5608,6 +5763,9 @@ function asVueRef(value) {
|
|
|
5608
5763
|
getTokenKind,
|
|
5609
5764
|
getTomorrow,
|
|
5610
5765
|
getTypeSubtype,
|
|
5766
|
+
getUrlBase,
|
|
5767
|
+
getUrlDefaultPort,
|
|
5768
|
+
getUrlDynamics,
|
|
5611
5769
|
getUrlPath,
|
|
5612
5770
|
getUrlPort,
|
|
5613
5771
|
getUrlProtocol,
|
|
@@ -5620,6 +5778,9 @@ function asVueRef(value) {
|
|
|
5620
5778
|
hasDefaultValue,
|
|
5621
5779
|
hasIndexOf,
|
|
5622
5780
|
hasKeys,
|
|
5781
|
+
hasOverlappingKeys,
|
|
5782
|
+
hasProtocol,
|
|
5783
|
+
hasProtocolPrefix,
|
|
5623
5784
|
hasUrlPort,
|
|
5624
5785
|
hasUrlQueryParameter,
|
|
5625
5786
|
hasWhiteSpace,
|
|
@@ -5685,6 +5846,7 @@ function asVueRef(value) {
|
|
|
5685
5846
|
isCountryCode3,
|
|
5686
5847
|
isCountryName,
|
|
5687
5848
|
isCssAspectRatio,
|
|
5849
|
+
isCsv,
|
|
5688
5850
|
isCurrentMetric,
|
|
5689
5851
|
isCurrentUom,
|
|
5690
5852
|
isCvsUrl,
|
|
@@ -5788,6 +5950,8 @@ function asVueRef(value) {
|
|
|
5788
5950
|
isPowerUom,
|
|
5789
5951
|
isPressureMetric,
|
|
5790
5952
|
isPressureUom,
|
|
5953
|
+
isProtocol,
|
|
5954
|
+
isProtocolPrefix,
|
|
5791
5955
|
isReadonlyArray,
|
|
5792
5956
|
isRecordToken,
|
|
5793
5957
|
isRef,
|
|
@@ -5866,6 +6030,7 @@ function asVueRef(value) {
|
|
|
5866
6030
|
isUsNewsUrl,
|
|
5867
6031
|
isUsStateAbbreviation,
|
|
5868
6032
|
isUsStateName,
|
|
6033
|
+
isVariable,
|
|
5869
6034
|
isVoltageMetric,
|
|
5870
6035
|
isVoltageUom,
|
|
5871
6036
|
isVolumeMetric,
|