inferred-types 0.54.3 → 0.54.4
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/inferred-types/dist/index.cjs +349 -332
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +43 -3
- package/modules/inferred-types/dist/index.js +347 -332
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +396 -375
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +33 -2
- package/modules/runtime/dist/index.js +394 -375
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.d.ts +11 -2
- package/package.json +1 -1
|
@@ -4789,201 +4789,6 @@ function ensureTrailing(content, ensure) {
|
|
|
4789
4789
|
content.endsWith(ensure) ? content : `${content}${ensure}`
|
|
4790
4790
|
);
|
|
4791
4791
|
}
|
|
4792
|
-
function identity(...values) {
|
|
4793
|
-
return values.length === 1 ? values[0] : values.length === 0 ? void 0 : values;
|
|
4794
|
-
}
|
|
4795
|
-
function ifLowercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
4796
|
-
if (ch.length !== 1) {
|
|
4797
|
-
throw new Error(`call to ifUppercaseChar received ${ch.length} characters but is only valid when one character is passed in!`);
|
|
4798
|
-
}
|
|
4799
|
-
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
4800
|
-
}
|
|
4801
|
-
function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
4802
|
-
if (ch.length !== 1) {
|
|
4803
|
-
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
4804
|
-
}
|
|
4805
|
-
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
4806
|
-
}
|
|
4807
|
-
function parseTemplate(template) {
|
|
4808
|
-
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:as\s+(string|number|boolean)\s*)?\}\}/g;
|
|
4809
|
-
let lastIndex = 0;
|
|
4810
|
-
let match;
|
|
4811
|
-
const segments = [];
|
|
4812
|
-
do {
|
|
4813
|
-
match = pattern.exec(template);
|
|
4814
|
-
if (match) {
|
|
4815
|
-
const [fullMatch, varName, asType2] = match;
|
|
4816
|
-
const staticPart = template.slice(lastIndex, match.index);
|
|
4817
|
-
if (staticPart) {
|
|
4818
|
-
segments.push({ dynamic: false, text: staticPart });
|
|
4819
|
-
}
|
|
4820
|
-
segments.push({
|
|
4821
|
-
dynamic: true,
|
|
4822
|
-
varName,
|
|
4823
|
-
type: asType2 ? asType2 : "string"
|
|
4824
|
-
});
|
|
4825
|
-
lastIndex = match.index + fullMatch.length;
|
|
4826
|
-
}
|
|
4827
|
-
} while (match);
|
|
4828
|
-
const remainder = template.slice(lastIndex);
|
|
4829
|
-
if (remainder) {
|
|
4830
|
-
segments.push({ dynamic: false, text: remainder });
|
|
4831
|
-
}
|
|
4832
|
-
return segments;
|
|
4833
|
-
}
|
|
4834
|
-
function escapeRegex(str) {
|
|
4835
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4836
|
-
}
|
|
4837
|
-
function buildRegexPattern(segments) {
|
|
4838
|
-
let regexStr = "^";
|
|
4839
|
-
for (const seg of segments) {
|
|
4840
|
-
if (!seg.dynamic) {
|
|
4841
|
-
regexStr += escapeRegex(seg.text);
|
|
4842
|
-
} else {
|
|
4843
|
-
switch (seg.type) {
|
|
4844
|
-
case "string":
|
|
4845
|
-
regexStr += `(?<${seg.varName}>.*?)`;
|
|
4846
|
-
break;
|
|
4847
|
-
case "number":
|
|
4848
|
-
regexStr += `(?<${seg.varName}>\\d+)`;
|
|
4849
|
-
break;
|
|
4850
|
-
case "boolean":
|
|
4851
|
-
regexStr += `(?<${seg.varName}>(?:true|false))`;
|
|
4852
|
-
break;
|
|
4853
|
-
}
|
|
4854
|
-
}
|
|
4855
|
-
}
|
|
4856
|
-
regexStr += "$";
|
|
4857
|
-
return new RegExp(regexStr, "s");
|
|
4858
|
-
}
|
|
4859
|
-
function convertValue(type, value) {
|
|
4860
|
-
switch (type) {
|
|
4861
|
-
case "string":
|
|
4862
|
-
return value;
|
|
4863
|
-
case "number":
|
|
4864
|
-
return Number(value);
|
|
4865
|
-
case "boolean":
|
|
4866
|
-
return value === "true";
|
|
4867
|
-
}
|
|
4868
|
-
}
|
|
4869
|
-
function matchTemplate(inference, test) {
|
|
4870
|
-
const segments = parseTemplate(inference);
|
|
4871
|
-
const regex = buildRegexPattern(segments);
|
|
4872
|
-
const match = test.match(regex);
|
|
4873
|
-
if (!match)
|
|
4874
|
-
return false;
|
|
4875
|
-
const result2 = {};
|
|
4876
|
-
for (const seg of segments) {
|
|
4877
|
-
if (seg.dynamic) {
|
|
4878
|
-
const rawVal = match.groups?.[seg.varName];
|
|
4879
|
-
if (rawVal === void 0)
|
|
4880
|
-
return false;
|
|
4881
|
-
result2[seg.varName.toLowerCase()] = convertValue(seg.type, rawVal);
|
|
4882
|
-
}
|
|
4883
|
-
}
|
|
4884
|
-
return result2;
|
|
4885
|
-
}
|
|
4886
|
-
function infer(inference) {
|
|
4887
|
-
return (test) => {
|
|
4888
|
-
return matchTemplate(inference, test);
|
|
4889
|
-
};
|
|
4890
|
-
}
|
|
4891
|
-
function idLiteral(o) {
|
|
4892
|
-
return { ...o, id: o.id };
|
|
4893
|
-
}
|
|
4894
|
-
function nameLiteral(o) {
|
|
4895
|
-
return o;
|
|
4896
|
-
}
|
|
4897
|
-
function kindLiteral(o) {
|
|
4898
|
-
return o;
|
|
4899
|
-
}
|
|
4900
|
-
function idTypeGuard(_o) {
|
|
4901
|
-
return true;
|
|
4902
|
-
}
|
|
4903
|
-
function literal(obj) {
|
|
4904
|
-
return obj;
|
|
4905
|
-
}
|
|
4906
|
-
function lowercase(str) {
|
|
4907
|
-
return str.toLowerCase();
|
|
4908
|
-
}
|
|
4909
|
-
function narrow(...values) {
|
|
4910
|
-
return values.length === 1 ? values[0] : values;
|
|
4911
|
-
}
|
|
4912
|
-
function pathJoin(...segments) {
|
|
4913
|
-
const clean_path = segments.map((i) => stripTrailing(stripLeading(i, "/"), "/")).join("/");
|
|
4914
|
-
const original_path = segments.join("/");
|
|
4915
|
-
const pre = original_path.startsWith("/") ? "/" : "";
|
|
4916
|
-
const post = original_path.endsWith("/") ? "/" : "";
|
|
4917
|
-
return `${pre}${clean_path}${post}`;
|
|
4918
|
-
}
|
|
4919
|
-
var asPhoneFormat = () => `NOT IMPLEMENTED`;
|
|
4920
|
-
function getPhoneCountryCode(phone) {
|
|
4921
|
-
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
4922
|
-
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
4923
|
-
...NUMERIC_CHAR2
|
|
4924
|
-
) : "";
|
|
4925
|
-
}
|
|
4926
|
-
function removePhoneCountryCode(phone) {
|
|
4927
|
-
const countryCode = getPhoneCountryCode(phone);
|
|
4928
|
-
return countryCode !== "" ? stripLeading(stripLeading(
|
|
4929
|
-
phone.trim(),
|
|
4930
|
-
"+",
|
|
4931
|
-
"00"
|
|
4932
|
-
), countryCode).trim() : phone.trim();
|
|
4933
|
-
}
|
|
4934
|
-
var isException = (word) => Object.keys(PLURAL_EXCEPTIONS2).includes(word);
|
|
4935
|
-
function endingIn(word, postfix) {
|
|
4936
|
-
switch (postfix) {
|
|
4937
|
-
case "is":
|
|
4938
|
-
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
4939
|
-
case "singular-noun":
|
|
4940
|
-
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
4941
|
-
case "f":
|
|
4942
|
-
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
4943
|
-
case "y":
|
|
4944
|
-
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
4945
|
-
default:
|
|
4946
|
-
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
4947
|
-
}
|
|
4948
|
-
}
|
|
4949
|
-
function pluralize(word) {
|
|
4950
|
-
const right = rightWhitespace(word);
|
|
4951
|
-
const w = word.trimEnd();
|
|
4952
|
-
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
4953
|
-
return `${result2}${right}`;
|
|
4954
|
-
}
|
|
4955
|
-
function retainAfter(content, ...find2) {
|
|
4956
|
-
const idx = Math.min(
|
|
4957
|
-
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
4958
|
-
);
|
|
4959
|
-
const min = Math.min(...find2.map((i) => i.length));
|
|
4960
|
-
let len = Math.max(...find2.map((i) => i.length));
|
|
4961
|
-
if (min !== len) {
|
|
4962
|
-
if (!find2.includes(content.slice(idx, len))) {
|
|
4963
|
-
len = min;
|
|
4964
|
-
}
|
|
4965
|
-
}
|
|
4966
|
-
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
4967
|
-
}
|
|
4968
|
-
function retainAfterInclusive(content, ...find2) {
|
|
4969
|
-
const minFound = Math.min(
|
|
4970
|
-
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
4971
|
-
);
|
|
4972
|
-
return minFound > 0 ? content.slice(minFound) : "";
|
|
4973
|
-
}
|
|
4974
|
-
function asChars(str) {
|
|
4975
|
-
return str.split("");
|
|
4976
|
-
}
|
|
4977
|
-
function retainChars(content, ...retain2) {
|
|
4978
|
-
const chars = asChars(content);
|
|
4979
|
-
return chars.filter((c) => retain2.includes(c)).join("");
|
|
4980
|
-
}
|
|
4981
|
-
function asRecord(obj) {
|
|
4982
|
-
return obj;
|
|
4983
|
-
}
|
|
4984
|
-
function asString(value) {
|
|
4985
|
-
return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
|
|
4986
|
-
}
|
|
4987
4792
|
function isFunction(value) {
|
|
4988
4793
|
return typeof value === "function";
|
|
4989
4794
|
}
|
|
@@ -5265,46 +5070,190 @@ function hasKeys(...props) {
|
|
|
5265
5070
|
return !!((isFunction(val) || isObject(val)) && keys.every((k) => k in val));
|
|
5266
5071
|
};
|
|
5267
5072
|
}
|
|
5268
|
-
function
|
|
5269
|
-
return
|
|
5073
|
+
function asChars(str) {
|
|
5074
|
+
return str.split("");
|
|
5270
5075
|
}
|
|
5271
|
-
function
|
|
5272
|
-
return
|
|
5273
|
-
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
5274
|
-
};
|
|
5076
|
+
function asRecord(obj) {
|
|
5077
|
+
return obj;
|
|
5275
5078
|
}
|
|
5276
|
-
function
|
|
5277
|
-
return (value)
|
|
5079
|
+
function asString(value) {
|
|
5080
|
+
return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
|
|
5278
5081
|
}
|
|
5279
|
-
function
|
|
5280
|
-
|
|
5082
|
+
function csv(csv2, format = `string-numeric-tuple`) {
|
|
5083
|
+
const tuple3 = [];
|
|
5084
|
+
csv2.split(/,\s?/).forEach((v) => {
|
|
5085
|
+
tuple3.push(
|
|
5086
|
+
format === "string-numeric-tuple" ? isNumberLike(v) ? Number(v) : v : format === "json-tuple" ? isNumberLike(v) ? Number(v) : v === "true" ? true : v === "false" ? false : `"${v}"` : format === "string-tuple" ? `${v}` : Never2
|
|
5087
|
+
);
|
|
5088
|
+
});
|
|
5089
|
+
return tuple3;
|
|
5281
5090
|
}
|
|
5282
|
-
function
|
|
5283
|
-
return
|
|
5284
|
-
return typeof base === typeof compare;
|
|
5285
|
-
};
|
|
5091
|
+
function intersect(value, _intersectedWith) {
|
|
5092
|
+
return value;
|
|
5286
5093
|
}
|
|
5287
|
-
function
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5094
|
+
function stripTrailing(content, ...strip2) {
|
|
5095
|
+
let output = String(content);
|
|
5096
|
+
for (const s of strip2) {
|
|
5097
|
+
if (output.endsWith(String(s))) {
|
|
5098
|
+
output = output.slice(0, -1 * String(s).length);
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
return isNumber(content) ? Number(output) : output;
|
|
5292
5102
|
}
|
|
5293
|
-
function
|
|
5294
|
-
return (
|
|
5295
|
-
return typeof value === type;
|
|
5296
|
-
};
|
|
5103
|
+
function ip6GroupExpansion(ip) {
|
|
5104
|
+
return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
|
|
5297
5105
|
}
|
|
5298
|
-
function
|
|
5299
|
-
return (val)
|
|
5300
|
-
return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
|
|
5301
|
-
};
|
|
5106
|
+
function jsonValue(val) {
|
|
5107
|
+
return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
|
|
5302
5108
|
}
|
|
5303
|
-
function
|
|
5304
|
-
return
|
|
5109
|
+
function jsonValues(...val) {
|
|
5110
|
+
return val.map((i) => jsonValue(i));
|
|
5305
5111
|
}
|
|
5306
|
-
function
|
|
5307
|
-
|
|
5112
|
+
function lookupAlpha2Code(code, prop) {
|
|
5113
|
+
const found = ISO3166_12.find((i) => i.alpha2 === code);
|
|
5114
|
+
return found ? found[prop] : void 0;
|
|
5115
|
+
}
|
|
5116
|
+
function lookupAlpha3Code(code, prop) {
|
|
5117
|
+
const found = ISO3166_12.find((i) => i.alpha3 === code);
|
|
5118
|
+
return found ? found[prop] : void 0;
|
|
5119
|
+
}
|
|
5120
|
+
function lookupName(name, prop) {
|
|
5121
|
+
const found = ISO3166_12.find((i) => i.name === name);
|
|
5122
|
+
return found ? found[prop] : void 0;
|
|
5123
|
+
}
|
|
5124
|
+
function lookupNumericCode(code, prop) {
|
|
5125
|
+
let num = isNumber(code) ? `${code}` : code;
|
|
5126
|
+
if (num.length === 1) {
|
|
5127
|
+
num = `00${num}`;
|
|
5128
|
+
} else if (num.length === 2) {
|
|
5129
|
+
num = `0${num}`;
|
|
5130
|
+
}
|
|
5131
|
+
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
5132
|
+
return found ? found[prop] : void 0;
|
|
5133
|
+
}
|
|
5134
|
+
function lookupCountryName(code) {
|
|
5135
|
+
const uc = uppercase(code);
|
|
5136
|
+
return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
|
|
5137
|
+
}
|
|
5138
|
+
function lookupCountryAlpha2(code) {
|
|
5139
|
+
const uc = uppercase(code);
|
|
5140
|
+
return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
|
|
5141
|
+
}
|
|
5142
|
+
function lookupCountryAlpha3(token) {
|
|
5143
|
+
const uc = uppercase(token);
|
|
5144
|
+
return isNumberLike(token) ? lookupNumericCode(token, "alpha3") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha3") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha3") : isIso3166CountryName(token) ? lookupName(token, "alpha3") : void 0;
|
|
5145
|
+
}
|
|
5146
|
+
function lookupCountryCode(token) {
|
|
5147
|
+
const uc = uppercase(token);
|
|
5148
|
+
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
5149
|
+
}
|
|
5150
|
+
function mergeObjects(defVal, override) {
|
|
5151
|
+
const intersectingKeys = sharedKeys(defVal, override);
|
|
5152
|
+
const defUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
5153
|
+
const overrideUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
5154
|
+
const merged = {
|
|
5155
|
+
...intersectingKeys.reduce(
|
|
5156
|
+
(acc, key) => typeof override[key] === "undefined" ? { ...acc, [key]: defVal[key] } : { ...acc, [key]: override[key] },
|
|
5157
|
+
{}
|
|
5158
|
+
),
|
|
5159
|
+
...defUnique,
|
|
5160
|
+
...overrideUnique
|
|
5161
|
+
};
|
|
5162
|
+
return merged;
|
|
5163
|
+
}
|
|
5164
|
+
function isUndefined(value) {
|
|
5165
|
+
return typeof value === "undefined";
|
|
5166
|
+
}
|
|
5167
|
+
function mergeScalars(a, b) {
|
|
5168
|
+
return isUndefined(b) ? a : b;
|
|
5169
|
+
}
|
|
5170
|
+
function mergeTuples(a, b) {
|
|
5171
|
+
return b.length > a.length ? b.map((v, idx) => v !== void 0 ? v : a[idx]) : [...b, ...a.slice(b.length)].map((v, idx) => v !== void 0 ? v : a[idx]);
|
|
5172
|
+
}
|
|
5173
|
+
function never(val) {
|
|
5174
|
+
return val;
|
|
5175
|
+
}
|
|
5176
|
+
function optional(value) {
|
|
5177
|
+
return value;
|
|
5178
|
+
}
|
|
5179
|
+
function orNull(value) {
|
|
5180
|
+
return value;
|
|
5181
|
+
}
|
|
5182
|
+
function optionalOrNull(value) {
|
|
5183
|
+
return value;
|
|
5184
|
+
}
|
|
5185
|
+
function stripParenthesis(val) {
|
|
5186
|
+
return stripTrailing(stripLeading(val.trim(), "("), ")").trim();
|
|
5187
|
+
}
|
|
5188
|
+
function convertScalar(val) {
|
|
5189
|
+
switch (typeof val) {
|
|
5190
|
+
case "number":
|
|
5191
|
+
return val;
|
|
5192
|
+
case "string":
|
|
5193
|
+
return Number(val);
|
|
5194
|
+
case "boolean":
|
|
5195
|
+
return val ? 1 : 0;
|
|
5196
|
+
default:
|
|
5197
|
+
throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
|
|
5198
|
+
}
|
|
5199
|
+
}
|
|
5200
|
+
var convertList = (val) => val.map((i) => convertScalar(i));
|
|
5201
|
+
function toNumber(value) {
|
|
5202
|
+
return Array.isArray(value) ? convertList(value) : convertScalar(value);
|
|
5203
|
+
}
|
|
5204
|
+
var MODS = TW_MODIFIERS2.map((i) => `${i}:`);
|
|
5205
|
+
function removeTailwindModifiers(val) {
|
|
5206
|
+
return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
|
|
5207
|
+
}
|
|
5208
|
+
function getTailwindModifiers(val) {
|
|
5209
|
+
return val.split(":").filter((i) => isTailwindModifier(i));
|
|
5210
|
+
}
|
|
5211
|
+
function union(..._options) {
|
|
5212
|
+
return (value) => value;
|
|
5213
|
+
}
|
|
5214
|
+
function unionize(value, _inUnionWith) {
|
|
5215
|
+
return value;
|
|
5216
|
+
}
|
|
5217
|
+
function hasWhiteSpace(val) {
|
|
5218
|
+
return isString(val) && asChars(val).some((c) => WHITESPACE_CHARS2.includes(c));
|
|
5219
|
+
}
|
|
5220
|
+
function endsWith(endingIn2) {
|
|
5221
|
+
return (val) => {
|
|
5222
|
+
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
5223
|
+
};
|
|
5224
|
+
}
|
|
5225
|
+
function isEqual(base) {
|
|
5226
|
+
return (value) => isSameTypeOf(base)(value) ? value === base : false;
|
|
5227
|
+
}
|
|
5228
|
+
function isLength(value, len) {
|
|
5229
|
+
return isArray(value) ? !!isEqual(value.length)(len) : isString(value) ? !!isEqual(value.length)(len) : isObject(value) ? !!isEqual(keysOf(value))(len) : false;
|
|
5230
|
+
}
|
|
5231
|
+
function isSameTypeOf(base) {
|
|
5232
|
+
return (compare) => {
|
|
5233
|
+
return typeof base === typeof compare;
|
|
5234
|
+
};
|
|
5235
|
+
}
|
|
5236
|
+
function isTuple(...tuple3) {
|
|
5237
|
+
const results = tuple3.map((i) => i(ShapeApiImplementation)).map((i) => isDoneFn(i) ? i.done() : i);
|
|
5238
|
+
return (v) => {
|
|
5239
|
+
return isArray(v) && v.length === results.length && results.every(isShape) && v.every((item, idx) => isSameTypeOf(results[idx])(item));
|
|
5240
|
+
};
|
|
5241
|
+
}
|
|
5242
|
+
function isTypeOf(type) {
|
|
5243
|
+
return (value) => {
|
|
5244
|
+
return typeof value === type;
|
|
5245
|
+
};
|
|
5246
|
+
}
|
|
5247
|
+
function startsWith(startingWith) {
|
|
5248
|
+
return (val) => {
|
|
5249
|
+
return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
|
|
5250
|
+
};
|
|
5251
|
+
}
|
|
5252
|
+
function isHtmlElement(val) {
|
|
5253
|
+
return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
|
|
5254
|
+
}
|
|
5255
|
+
function isAlpha(value) {
|
|
5256
|
+
return isString(value) && split(value).every((v) => ALPHA_CHARS2.includes(v));
|
|
5308
5257
|
}
|
|
5309
5258
|
function isArray(value) {
|
|
5310
5259
|
return Array.isArray(value) === true;
|
|
@@ -5434,12 +5383,12 @@ function isTrue(value) {
|
|
|
5434
5383
|
function isTruthy(val) {
|
|
5435
5384
|
return !FALSY_VALUES2.includes(val);
|
|
5436
5385
|
}
|
|
5386
|
+
function isTypeSubtype(val) {
|
|
5387
|
+
return isString(val) && val.split("/").length === 2;
|
|
5388
|
+
}
|
|
5437
5389
|
function isTypeTuple(value) {
|
|
5438
5390
|
return Array.isArray(value) && value.length === 3 && typeof value[1] === "function";
|
|
5439
5391
|
}
|
|
5440
|
-
function isUndefined(value) {
|
|
5441
|
-
return typeof value === "undefined";
|
|
5442
|
-
}
|
|
5443
5392
|
function isUnset(val) {
|
|
5444
5393
|
return isObject(val) && val.kind === "Unset";
|
|
5445
5394
|
}
|
|
@@ -5999,137 +5948,201 @@ function isYouTubeCreatorUrl(url) {
|
|
|
5999
5948
|
function isYouTubeVideosInPlaylist(val) {
|
|
6000
5949
|
return isString(val) && (val.startsWith(`https://www.youtube.com/playlist?`) || val.startsWith(`https://youtube.com/playlist?`)) && hasUrlQueryParameter(val, "list");
|
|
6001
5950
|
}
|
|
6002
|
-
function
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
);
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
}
|
|
6011
|
-
function intersect(value, _intersectedWith) {
|
|
6012
|
-
return value;
|
|
6013
|
-
}
|
|
6014
|
-
function stripTrailing(content, ...strip2) {
|
|
6015
|
-
let output = String(content);
|
|
6016
|
-
for (const s of strip2) {
|
|
6017
|
-
if (output.endsWith(String(s))) {
|
|
6018
|
-
output = output.slice(0, -1 * String(s).length);
|
|
6019
|
-
}
|
|
5951
|
+
function getTypeSubtype(str) {
|
|
5952
|
+
if (isTypeSubtype(str)) {
|
|
5953
|
+
const [t, st] = str.split("/");
|
|
5954
|
+
return [t, st];
|
|
5955
|
+
} else {
|
|
5956
|
+
const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
|
|
5957
|
+
err.name = "InvalidTypeSubtype";
|
|
5958
|
+
throw err;
|
|
6020
5959
|
}
|
|
6021
|
-
return isNumber(content) ? Number(output) : output;
|
|
6022
5960
|
}
|
|
6023
|
-
function
|
|
6024
|
-
return
|
|
5961
|
+
function identity(...values) {
|
|
5962
|
+
return values.length === 1 ? values[0] : values.length === 0 ? void 0 : values;
|
|
6025
5963
|
}
|
|
6026
|
-
function
|
|
6027
|
-
|
|
5964
|
+
function ifLowercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
5965
|
+
if (ch.length !== 1) {
|
|
5966
|
+
throw new Error(`call to ifUppercaseChar received ${ch.length} characters but is only valid when one character is passed in!`);
|
|
5967
|
+
}
|
|
5968
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
6028
5969
|
}
|
|
6029
|
-
function
|
|
6030
|
-
|
|
5970
|
+
function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
5971
|
+
if (ch.length !== 1) {
|
|
5972
|
+
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
5973
|
+
}
|
|
5974
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
6031
5975
|
}
|
|
6032
|
-
function
|
|
6033
|
-
const
|
|
6034
|
-
|
|
5976
|
+
function parseTemplate(template) {
|
|
5977
|
+
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:as\s+(string|number|boolean)\s*)?\}\}/g;
|
|
5978
|
+
let lastIndex = 0;
|
|
5979
|
+
let match;
|
|
5980
|
+
const segments = [];
|
|
5981
|
+
do {
|
|
5982
|
+
match = pattern.exec(template);
|
|
5983
|
+
if (match) {
|
|
5984
|
+
const [fullMatch, varName, asType2] = match;
|
|
5985
|
+
const staticPart = template.slice(lastIndex, match.index);
|
|
5986
|
+
if (staticPart) {
|
|
5987
|
+
segments.push({ dynamic: false, text: staticPart });
|
|
5988
|
+
}
|
|
5989
|
+
segments.push({
|
|
5990
|
+
dynamic: true,
|
|
5991
|
+
varName,
|
|
5992
|
+
type: asType2 ? asType2 : "string"
|
|
5993
|
+
});
|
|
5994
|
+
lastIndex = match.index + fullMatch.length;
|
|
5995
|
+
}
|
|
5996
|
+
} while (match);
|
|
5997
|
+
const remainder = template.slice(lastIndex);
|
|
5998
|
+
if (remainder) {
|
|
5999
|
+
segments.push({ dynamic: false, text: remainder });
|
|
6000
|
+
}
|
|
6001
|
+
return segments;
|
|
6035
6002
|
}
|
|
6036
|
-
function
|
|
6037
|
-
|
|
6038
|
-
return found ? found[prop] : void 0;
|
|
6003
|
+
function escapeRegex(str) {
|
|
6004
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6039
6005
|
}
|
|
6040
|
-
function
|
|
6041
|
-
|
|
6042
|
-
|
|
6006
|
+
function buildRegexPattern(segments) {
|
|
6007
|
+
let regexStr = "^";
|
|
6008
|
+
for (const seg of segments) {
|
|
6009
|
+
if (!seg.dynamic) {
|
|
6010
|
+
regexStr += escapeRegex(seg.text);
|
|
6011
|
+
} else {
|
|
6012
|
+
switch (seg.type) {
|
|
6013
|
+
case "string":
|
|
6014
|
+
regexStr += `(?<${seg.varName}>.*?)`;
|
|
6015
|
+
break;
|
|
6016
|
+
case "number":
|
|
6017
|
+
regexStr += `(?<${seg.varName}>\\d+)`;
|
|
6018
|
+
break;
|
|
6019
|
+
case "boolean":
|
|
6020
|
+
regexStr += `(?<${seg.varName}>(?:true|false))`;
|
|
6021
|
+
break;
|
|
6022
|
+
}
|
|
6023
|
+
}
|
|
6024
|
+
}
|
|
6025
|
+
regexStr += "$";
|
|
6026
|
+
return new RegExp(regexStr, "s");
|
|
6043
6027
|
}
|
|
6044
|
-
function
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6028
|
+
function convertValue(type, value) {
|
|
6029
|
+
switch (type) {
|
|
6030
|
+
case "string":
|
|
6031
|
+
return value;
|
|
6032
|
+
case "number":
|
|
6033
|
+
return Number(value);
|
|
6034
|
+
case "boolean":
|
|
6035
|
+
return value === "true";
|
|
6050
6036
|
}
|
|
6051
|
-
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
6052
|
-
return found ? found[prop] : void 0;
|
|
6053
6037
|
}
|
|
6054
|
-
function
|
|
6055
|
-
const
|
|
6056
|
-
|
|
6038
|
+
function matchTemplate(inference, test) {
|
|
6039
|
+
const segments = parseTemplate(inference);
|
|
6040
|
+
const regex = buildRegexPattern(segments);
|
|
6041
|
+
const match = test.match(regex);
|
|
6042
|
+
if (!match)
|
|
6043
|
+
return false;
|
|
6044
|
+
const result2 = {};
|
|
6045
|
+
for (const seg of segments) {
|
|
6046
|
+
if (seg.dynamic) {
|
|
6047
|
+
const rawVal = match.groups?.[seg.varName];
|
|
6048
|
+
if (rawVal === void 0)
|
|
6049
|
+
return false;
|
|
6050
|
+
result2[seg.varName.toLowerCase()] = convertValue(seg.type, rawVal);
|
|
6051
|
+
}
|
|
6052
|
+
}
|
|
6053
|
+
return result2;
|
|
6057
6054
|
}
|
|
6058
|
-
function
|
|
6059
|
-
|
|
6060
|
-
|
|
6055
|
+
function infer(inference) {
|
|
6056
|
+
return (test) => {
|
|
6057
|
+
return matchTemplate(inference, test);
|
|
6058
|
+
};
|
|
6061
6059
|
}
|
|
6062
|
-
function
|
|
6063
|
-
|
|
6064
|
-
return isNumberLike(token) ? lookupNumericCode(token, "alpha3") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha3") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha3") : isIso3166CountryName(token) ? lookupName(token, "alpha3") : void 0;
|
|
6060
|
+
function idLiteral(o) {
|
|
6061
|
+
return { ...o, id: o.id };
|
|
6065
6062
|
}
|
|
6066
|
-
function
|
|
6067
|
-
|
|
6068
|
-
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
6063
|
+
function nameLiteral(o) {
|
|
6064
|
+
return o;
|
|
6069
6065
|
}
|
|
6070
|
-
function
|
|
6071
|
-
|
|
6072
|
-
const defUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
6073
|
-
const overrideUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
6074
|
-
const merged = {
|
|
6075
|
-
...intersectingKeys.reduce(
|
|
6076
|
-
(acc, key) => typeof override[key] === "undefined" ? { ...acc, [key]: defVal[key] } : { ...acc, [key]: override[key] },
|
|
6077
|
-
{}
|
|
6078
|
-
),
|
|
6079
|
-
...defUnique,
|
|
6080
|
-
...overrideUnique
|
|
6081
|
-
};
|
|
6082
|
-
return merged;
|
|
6066
|
+
function kindLiteral(o) {
|
|
6067
|
+
return o;
|
|
6083
6068
|
}
|
|
6084
|
-
function
|
|
6085
|
-
return
|
|
6069
|
+
function idTypeGuard(_o) {
|
|
6070
|
+
return true;
|
|
6086
6071
|
}
|
|
6087
|
-
function
|
|
6088
|
-
return
|
|
6072
|
+
function literal(obj) {
|
|
6073
|
+
return obj;
|
|
6089
6074
|
}
|
|
6090
|
-
function
|
|
6091
|
-
return
|
|
6075
|
+
function lowercase(str) {
|
|
6076
|
+
return str.toLowerCase();
|
|
6092
6077
|
}
|
|
6093
|
-
function
|
|
6094
|
-
return
|
|
6078
|
+
function narrow(...values) {
|
|
6079
|
+
return values.length === 1 ? values[0] : values;
|
|
6095
6080
|
}
|
|
6096
|
-
function
|
|
6097
|
-
|
|
6081
|
+
function pathJoin(...segments) {
|
|
6082
|
+
const clean_path = segments.map((i) => stripTrailing(stripLeading(i, "/"), "/")).join("/");
|
|
6083
|
+
const original_path = segments.join("/");
|
|
6084
|
+
const pre = original_path.startsWith("/") ? "/" : "";
|
|
6085
|
+
const post = original_path.endsWith("/") ? "/" : "";
|
|
6086
|
+
return `${pre}${clean_path}${post}`;
|
|
6098
6087
|
}
|
|
6099
|
-
|
|
6100
|
-
|
|
6088
|
+
var asPhoneFormat = () => `NOT IMPLEMENTED`;
|
|
6089
|
+
function getPhoneCountryCode(phone) {
|
|
6090
|
+
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
6091
|
+
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
6092
|
+
...NUMERIC_CHAR2
|
|
6093
|
+
) : "";
|
|
6101
6094
|
}
|
|
6102
|
-
function
|
|
6103
|
-
|
|
6095
|
+
function removePhoneCountryCode(phone) {
|
|
6096
|
+
const countryCode = getPhoneCountryCode(phone);
|
|
6097
|
+
return countryCode !== "" ? stripLeading(stripLeading(
|
|
6098
|
+
phone.trim(),
|
|
6099
|
+
"+",
|
|
6100
|
+
"00"
|
|
6101
|
+
), countryCode).trim() : phone.trim();
|
|
6104
6102
|
}
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6103
|
+
var isException = (word) => Object.keys(PLURAL_EXCEPTIONS2).includes(word);
|
|
6104
|
+
function endingIn(word, postfix) {
|
|
6105
|
+
switch (postfix) {
|
|
6106
|
+
case "is":
|
|
6107
|
+
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
6108
|
+
case "singular-noun":
|
|
6109
|
+
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
6110
|
+
case "f":
|
|
6111
|
+
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
6112
|
+
case "y":
|
|
6113
|
+
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
6113
6114
|
default:
|
|
6114
|
-
throw new Error(
|
|
6115
|
+
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
6115
6116
|
}
|
|
6116
6117
|
}
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
}
|
|
6121
|
-
|
|
6122
|
-
function removeTailwindModifiers(val) {
|
|
6123
|
-
return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
|
|
6118
|
+
function pluralize(word) {
|
|
6119
|
+
const right = rightWhitespace(word);
|
|
6120
|
+
const w = word.trimEnd();
|
|
6121
|
+
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
6122
|
+
return `${result2}${right}`;
|
|
6124
6123
|
}
|
|
6125
|
-
function
|
|
6126
|
-
|
|
6124
|
+
function retainAfter(content, ...find2) {
|
|
6125
|
+
const idx = Math.min(
|
|
6126
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
6127
|
+
);
|
|
6128
|
+
const min = Math.min(...find2.map((i) => i.length));
|
|
6129
|
+
let len = Math.max(...find2.map((i) => i.length));
|
|
6130
|
+
if (min !== len) {
|
|
6131
|
+
if (!find2.includes(content.slice(idx, len))) {
|
|
6132
|
+
len = min;
|
|
6133
|
+
}
|
|
6134
|
+
}
|
|
6135
|
+
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
6127
6136
|
}
|
|
6128
|
-
function
|
|
6129
|
-
|
|
6137
|
+
function retainAfterInclusive(content, ...find2) {
|
|
6138
|
+
const minFound = Math.min(
|
|
6139
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
6140
|
+
);
|
|
6141
|
+
return minFound > 0 ? content.slice(minFound) : "";
|
|
6130
6142
|
}
|
|
6131
|
-
function
|
|
6132
|
-
|
|
6143
|
+
function retainChars(content, ...retain2) {
|
|
6144
|
+
const chars = asChars(content);
|
|
6145
|
+
return chars.filter((c) => retain2.includes(c)).join("");
|
|
6133
6146
|
}
|
|
6134
6147
|
function retainUntil(content, ...find2) {
|
|
6135
6148
|
const chars = asChars(content);
|
|
@@ -7206,6 +7219,7 @@ export {
|
|
|
7206
7219
|
getToday,
|
|
7207
7220
|
getTokenKind,
|
|
7208
7221
|
getTomorrow,
|
|
7222
|
+
getTypeSubtype,
|
|
7209
7223
|
getUrlPath,
|
|
7210
7224
|
getUrlPort,
|
|
7211
7225
|
getUrlProtocol,
|
|
@@ -7446,6 +7460,7 @@ export {
|
|
|
7446
7460
|
isTupleToken,
|
|
7447
7461
|
isTurkishNewsUrl,
|
|
7448
7462
|
isTypeOf,
|
|
7463
|
+
isTypeSubtype,
|
|
7449
7464
|
isTypeToken,
|
|
7450
7465
|
isTypeTokenKind,
|
|
7451
7466
|
isTypeTuple,
|