inferred-types 0.33.1 → 0.33.3
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/.vscode/settings.json +1 -0
- package/dist/index.d.ts +1209 -1152
- package/dist/index.js +73 -182
- package/dist/index.mjs +70 -175
- package/package.json +16 -15
- package/src/{utility/errors → errors}/ReadOnlyViolation.ts +0 -0
- package/src/{utility/errors → errors}/index.ts +0 -0
- package/src/index.ts +1 -3
- package/src/{utility → runtime}/README.md +0 -0
- package/src/{utility → runtime}/api/api.ts +0 -0
- package/src/{utility → runtime}/api/index.ts +0 -0
- package/src/{utility/modelling → runtime/builders}/Model.ts +0 -0
- package/src/runtime/builders/url.ts +15 -0
- package/src/{utility/boolean-logic → runtime/combinators}/and.ts +0 -0
- package/src/{utility/boolean-logic → runtime/combinators}/filter.ts +0 -0
- package/src/{utility/boolean-logic → runtime/combinators}/index.ts +0 -0
- package/src/{utility/boolean-logic → runtime/combinators}/not.ts +0 -0
- package/src/{utility/boolean-logic → runtime/combinators}/or.ts +0 -0
- package/src/{utility → runtime}/createFnWithProps.ts +0 -0
- package/src/{utility → runtime}/dictionary/arrayToKeyLookup.ts +0 -0
- package/src/{utility → runtime}/dictionary/defineProperties.ts +0 -0
- package/src/{utility → runtime}/dictionary/dictArr.ts +0 -0
- package/src/{utility → runtime}/dictionary/dictionaryTransform.ts +0 -0
- package/src/{utility → runtime}/dictionary/entries.ts +0 -0
- package/src/{utility → runtime}/dictionary/index.ts +0 -0
- package/src/{utility → runtime}/dictionary/kv/dictToKv.ts +1 -1
- package/src/{utility → runtime}/dictionary/kv/filterDictArray.ts +1 -1
- package/src/{utility → runtime}/dictionary/kv/index.ts +0 -0
- package/src/{utility → runtime}/dictionary/kv/kv.ts +0 -0
- package/src/{utility → runtime}/dictionary/kv/kvToDict.ts +0 -0
- package/src/{utility → runtime}/dictionary/mapTo.ts +0 -0
- package/src/{utility → runtime}/dictionary/mapValues.ts +0 -0
- package/src/{utility → runtime}/dictionary/merge.ts +0 -0
- package/src/{utility → runtime}/dictionary/strArrayToDict.ts +0 -0
- package/src/{utility → runtime}/index.ts +1 -3
- package/src/{utility → runtime}/keys.ts +0 -0
- package/src/{utility → runtime}/lists/asArray.ts +0 -0
- package/src/{utility → runtime}/lists/groupBy.ts +0 -0
- package/src/{utility → runtime}/lists/index.ts +0 -0
- package/src/{utility → runtime}/literals/ExplicitFunction.ts +0 -0
- package/src/runtime/literals/Suggest.ts +19 -0
- package/src/{utility → runtime}/literals/arrayToObject.ts +0 -0
- package/src/runtime/literals/box.ts +77 -0
- package/src/{utility → runtime}/literals/defineType.ts +0 -0
- package/src/{utility → runtime}/literals/identity.ts +0 -0
- package/src/{utility → runtime}/literals/index.ts +2 -0
- package/src/{utility → runtime}/literals/literal.ts +0 -0
- package/src/{utility → runtime}/ruleset.ts +0 -0
- package/src/{utility → runtime}/runtime/README.md +0 -0
- package/src/{utility → runtime}/runtime/condition.ts +0 -0
- package/src/{utility → runtime}/runtime/index.ts +1 -2
- package/src/{utility → runtime}/runtime/type.ts +1 -1
- package/src/{utility → runtime}/runtime/withValue.ts +0 -0
- package/src/{utility → runtime}/state/Configurator.ts +0 -0
- package/src/{utility → runtime}/state/FluentConfigurator.ts +0 -0
- package/src/{utility → runtime}/state/index.ts +0 -0
- package/src/{utility/runtime → runtime/type-checks}/ifTypeOf.ts +0 -0
- package/src/{utility/runtime/conditions → runtime/type-checks}/index.ts +0 -0
- package/src/{utility/runtime/conditions → runtime/type-checks}/isArray.ts +0 -0
- package/src/{utility/runtime/conditions → runtime/type-checks}/isBoolean.ts +0 -0
- package/src/{utility/runtime/conditions → runtime/type-checks}/isFalse.ts +0 -0
- package/src/{utility/runtime/conditions → runtime/type-checks}/isFunction.ts +11 -2
- package/src/{utility/runtime/conditions → runtime/type-checks}/isNull.ts +0 -0
- package/src/{utility/runtime/conditions → runtime/type-checks}/isNumber.ts +0 -0
- package/src/{utility/runtime/conditions → runtime/type-checks}/isObject.ts +1 -1
- package/src/{utility/runtime/conditions → runtime/type-checks}/isString.ts +13 -5
- package/src/{utility/runtime/conditions → runtime/type-checks}/isSymbol.ts +0 -0
- package/src/{utility/runtime/conditions → runtime/type-checks}/isTrue.ts +1 -1
- package/src/{utility/runtime/conditions → runtime/type-checks}/isUndefined.ts +1 -1
- package/src/runtime/type-checks/startsWith.ts +109 -0
- package/src/{shared → runtime}/valueTypes.ts +0 -0
- package/src/types/FunctionType.ts +12 -2
- package/src/types/Mutable.ts +1 -1
- package/src/types/alphabetic/Url.ts +29 -0
- package/src/types/alphabetic/alpha-characters.ts +8 -0
- package/src/types/alphabetic/index.ts +1 -0
- package/src/types/dictionary/MapTo.ts +2 -2
- package/src/types/index.ts +2 -2
- package/src/types/lists/AfterFirst.ts +10 -0
- package/src/types/lists/First.ts +8 -0
- package/src/types/lists/FirstString.ts +4 -0
- package/src/types/lists/Split.ts +21 -0
- package/src/types/lists/index.ts +4 -0
- package/src/types/ruleset-types.ts +1 -1
- package/src/types/type-checks/EndsWith.ts +22 -0
- package/src/types/{TypeInfo → type-checks}/Extends.ts +0 -0
- package/src/types/{TypeInfo → type-checks}/Includes.ts +0 -0
- package/src/types/{TypeInfo → type-checks}/IsBooleanLiteral.ts +0 -0
- package/src/types/{TypeInfo → type-checks}/IsLiteral.ts +0 -0
- package/src/types/{TypeInfo → type-checks}/IsNumericLiteral.ts +0 -0
- package/src/types/{TypeInfo → type-checks}/IsScalar.ts +0 -0
- package/src/types/{TypeInfo → type-checks}/IsStringLiteral.ts +2 -6
- package/src/types/{TypeInfo → type-checks}/IsUndefined.ts +0 -0
- package/src/types/type-checks/StartsWith.ts +43 -0
- package/src/types/{TypeInfo → type-checks}/TypeDefault.ts +1 -1
- package/src/types/{TypeInfo → type-checks}/index.ts +4 -1
- package/src/types/{TypeInfo/IsObject.ts → type-checks/object.ts} +0 -0
- package/src/types/type-checks/string.ts +21 -0
- package/src/types/type-conversion/TupleToUnion.ts +1 -3
- package/tests/ExplicitFunction-spec.ts +1 -1
- package/tests/arrayToKeyLookup-spec.ts +1 -1
- package/tests/arrayToObject-spec.ts +1 -1
- package/tests/boolean-logic/boolean.spec.ts +1 -1
- package/tests/boolean-logic/filter.spec.ts +1 -1
- package/tests/defineType-spec.ts +1 -1
- package/tests/dictionary/Get.spec.ts +1 -1
- package/tests/dictionary/TypeDefault.test.ts +2 -2
- package/tests/dictionary/mapTo.test.ts +1 -1
- package/tests/dictionary/merge.test.ts +1 -1
- package/tests/dictionaryTransform-spec.ts +1 -1
- package/tests/ifTypeOf-spec.ts +3 -2
- package/tests/kv/dict-to-kv-and-back.spec.ts +2 -2
- package/tests/kv/entries-spec.ts +1 -1
- package/tests/kv/keys.spec.ts +1 -1
- package/tests/kv/kv-spec.ts +1 -1
- package/tests/lists/First.test.ts +43 -0
- package/tests/lists/Split.test.ts +29 -0
- package/tests/lists/asArray.test.ts +1 -1
- package/tests/lists/dictArr.test.ts +1 -1
- package/tests/literal-spec.ts +1 -1
- package/tests/{string-literals → literals}/AllCaps.spec.ts +0 -0
- package/tests/{string-literals → literals}/CamelCase.spec.ts +0 -0
- package/tests/{string-literals → literals}/Dasherize.spec.ts +0 -0
- package/tests/{string-literals → literals}/HasUppercase.spec.ts +0 -0
- package/tests/{string-literals → literals}/PascalCase.spec.ts +0 -0
- package/tests/{string-literals → literals}/SnakeCase.spec.ts +0 -0
- package/tests/literals/box.test.ts +77 -0
- package/tests/{string-literals → literals}/whitespace-capture.spec.ts +0 -0
- package/tests/mapValues-spec.ts +1 -1
- package/tests/runtime/condition.spec.ts +1 -1
- package/tests/runtime/if-is.spec.ts +158 -2
- package/tests/runtime/type.spec.ts +1 -1
- package/tests/strArrayToDict-spec.ts +1 -1
- package/tests/withValue.spec.ts +1 -1
- package/vitest.config.ts +2 -5
- package/src/Mutation/MutationFunction.ts +0 -26
- package/src/Mutation/MutationIdentity.ts +0 -36
- package/src/Mutation/index.ts +0 -14
- package/src/shared/README.md +0 -3
- package/src/shared/index.ts +0 -15
- package/src/shared/randomString.ts +0 -5
- package/src/shared/uuid.ts +0 -5
- package/src/types/First.ts +0 -4
- package/src/utility/modelling/index.ts +0 -12
- package/tests/MutationIdentity-spec.ts +0 -25
package/dist/index.mjs
CHANGED
|
@@ -1,46 +1,3 @@
|
|
|
1
|
-
// src/Mutation/MutationFunction.ts
|
|
2
|
-
function createMutationFunction(state) {
|
|
3
|
-
return (mutationIdentity) => {
|
|
4
|
-
return mutationIdentity(state);
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// src/Mutation/MutationIdentity.ts
|
|
9
|
-
function MutationIdentity() {
|
|
10
|
-
return function(m) {
|
|
11
|
-
return m;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// src/shared/randomString.ts
|
|
16
|
-
function randomString() {
|
|
17
|
-
return Math.trunc((1 + Math.random()) * 65536).toString(16).slice(1);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// src/shared/uuid.ts
|
|
21
|
-
function uuid() {
|
|
22
|
-
return `${randomString()}${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}${randomString()}${randomString()}`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// src/shared/valueTypes.ts
|
|
26
|
-
var valueTypes = {
|
|
27
|
-
string: ["", false],
|
|
28
|
-
boolean: [true, false],
|
|
29
|
-
number: [0, false],
|
|
30
|
-
function: [() => "", false],
|
|
31
|
-
object: [{}, false],
|
|
32
|
-
array: (arr = []) => [arr, false],
|
|
33
|
-
null: [null, false],
|
|
34
|
-
symbol: [Symbol("type"), false],
|
|
35
|
-
undefined: [void 0, false],
|
|
36
|
-
true: [true, true],
|
|
37
|
-
false: [false, true],
|
|
38
|
-
literal: (v) => {
|
|
39
|
-
return [v, true];
|
|
40
|
-
},
|
|
41
|
-
literalArray: (arr) => [arr, true]
|
|
42
|
-
};
|
|
43
|
-
|
|
44
1
|
// src/types/dictionary/MapTo.ts
|
|
45
2
|
var MapCardinality = /* @__PURE__ */ ((MapCardinality2) => {
|
|
46
3
|
MapCardinality2["OneToMany"] = "I -> O[]";
|
|
@@ -49,13 +6,13 @@ var MapCardinality = /* @__PURE__ */ ((MapCardinality2) => {
|
|
|
49
6
|
return MapCardinality2;
|
|
50
7
|
})(MapCardinality || {});
|
|
51
8
|
|
|
52
|
-
// src/
|
|
9
|
+
// src/runtime/keys.ts
|
|
53
10
|
function keys(obj, ...without) {
|
|
54
11
|
const v = without.length > 0 ? Object.keys(obj).filter((k) => !without.includes(k)) : Object.keys(obj);
|
|
55
12
|
return v;
|
|
56
13
|
}
|
|
57
14
|
|
|
58
|
-
// src/
|
|
15
|
+
// src/runtime/createFnWithProps.ts
|
|
59
16
|
function createFnWithProps(fn, props) {
|
|
60
17
|
return (() => {
|
|
61
18
|
let combined = fn;
|
|
@@ -80,19 +37,19 @@ function readonlyFnWithProps(fn, props) {
|
|
|
80
37
|
return combined;
|
|
81
38
|
}
|
|
82
39
|
|
|
83
|
-
// src/
|
|
40
|
+
// src/runtime/ruleset.ts
|
|
84
41
|
function ruleSet(defn) {
|
|
85
42
|
return defn;
|
|
86
43
|
}
|
|
87
44
|
|
|
88
|
-
// src/
|
|
45
|
+
// src/runtime/api/api.ts
|
|
89
46
|
var api = (priv) => (pub) => {
|
|
90
47
|
const surface = () => pub;
|
|
91
48
|
surface.prototype.priv = () => priv;
|
|
92
49
|
return surface;
|
|
93
50
|
};
|
|
94
51
|
|
|
95
|
-
// src/
|
|
52
|
+
// src/runtime/combinators/and.ts
|
|
96
53
|
var and = (...ops) => {
|
|
97
54
|
const fn = (...args) => {
|
|
98
55
|
return [...ops].every((i) => i(...args));
|
|
@@ -100,7 +57,7 @@ var and = (...ops) => {
|
|
|
100
57
|
return fn;
|
|
101
58
|
};
|
|
102
59
|
|
|
103
|
-
// src/
|
|
60
|
+
// src/runtime/combinators/or.ts
|
|
104
61
|
var or = (...ops) => {
|
|
105
62
|
const fn = (...args) => {
|
|
106
63
|
return [...ops].some((i) => i(...args));
|
|
@@ -108,7 +65,7 @@ var or = (...ops) => {
|
|
|
108
65
|
return fn;
|
|
109
66
|
};
|
|
110
67
|
|
|
111
|
-
// src/
|
|
68
|
+
// src/runtime/combinators/not.ts
|
|
112
69
|
var not = (op) => {
|
|
113
70
|
const fn = (...args) => {
|
|
114
71
|
return !op(...args);
|
|
@@ -116,73 +73,17 @@ var not = (op) => {
|
|
|
116
73
|
return fn;
|
|
117
74
|
};
|
|
118
75
|
|
|
119
|
-
// src/
|
|
76
|
+
// src/runtime/runtime/condition.ts
|
|
120
77
|
var condition = (c, input) => {
|
|
121
78
|
return c(input);
|
|
122
79
|
};
|
|
123
80
|
|
|
124
|
-
// src/
|
|
125
|
-
function runtimeExtendsCheck(val, base, narrow = false) {
|
|
126
|
-
if (typeof val !== typeof base) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
switch (typeof val) {
|
|
130
|
-
case "boolean":
|
|
131
|
-
case "string":
|
|
132
|
-
case "number":
|
|
133
|
-
case "symbol":
|
|
134
|
-
case "bigint":
|
|
135
|
-
return narrow ? val === base : true;
|
|
136
|
-
case "undefined":
|
|
137
|
-
return true;
|
|
138
|
-
case "function":
|
|
139
|
-
if (narrow) {
|
|
140
|
-
throw new Error(`Use of narrowlyExtends with a function is not possible!`);
|
|
141
|
-
}
|
|
142
|
-
return true;
|
|
143
|
-
case "object":
|
|
144
|
-
if (val === null && base === null) {
|
|
145
|
-
return true;
|
|
146
|
-
} else {
|
|
147
|
-
return keys(base).every(
|
|
148
|
-
(i) => runtimeExtendsCheck(val[i], base[i], narrow)
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
var ifTypeOf = (val) => ({
|
|
154
|
-
extends: (base) => {
|
|
155
|
-
const valid = runtimeExtendsCheck(val, base, false);
|
|
156
|
-
const trueFalse = valid ? true : false;
|
|
157
|
-
return {
|
|
158
|
-
then: (then) => ({
|
|
159
|
-
else: (elseVal) => {
|
|
160
|
-
return valid ? typeof then === "undefined" ? val : then : elseVal;
|
|
161
|
-
}
|
|
162
|
-
}),
|
|
163
|
-
else: (elseVal) => valid ? val : elseVal
|
|
164
|
-
} && trueFalse;
|
|
165
|
-
},
|
|
166
|
-
narrowlyExtends: (base) => {
|
|
167
|
-
const valid = runtimeExtendsCheck(val, base, true);
|
|
168
|
-
const trueFalse = valid ? true : false;
|
|
169
|
-
return {
|
|
170
|
-
then: (then) => ({
|
|
171
|
-
else: (elseVal) => {
|
|
172
|
-
return valid ? typeof then === "undefined" ? val : then : elseVal;
|
|
173
|
-
}
|
|
174
|
-
}),
|
|
175
|
-
else: (elseVal) => valid ? val : elseVal
|
|
176
|
-
} && trueFalse;
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// src/utility/runtime/conditions/isArray.ts
|
|
81
|
+
// src/runtime/type-checks/isArray.ts
|
|
181
82
|
function isArray(i) {
|
|
182
83
|
return Array.isArray(i) === true;
|
|
183
84
|
}
|
|
184
85
|
|
|
185
|
-
// src/
|
|
86
|
+
// src/runtime/type-checks/isBoolean.ts
|
|
186
87
|
function isBoolean(i) {
|
|
187
88
|
return typeof i === "boolean";
|
|
188
89
|
}
|
|
@@ -190,17 +91,17 @@ function ifBoolean(val, ifVal, elseVal) {
|
|
|
190
91
|
return isBoolean(val) ? ifVal : elseVal;
|
|
191
92
|
}
|
|
192
93
|
|
|
193
|
-
// src/
|
|
94
|
+
// src/runtime/type-checks/isFalse.ts
|
|
194
95
|
function isFalse(i) {
|
|
195
96
|
return typeof i === "boolean" && !i;
|
|
196
97
|
}
|
|
197
98
|
|
|
198
|
-
// src/
|
|
99
|
+
// src/runtime/type-checks/isFunction.ts
|
|
199
100
|
function isFunction(input) {
|
|
200
|
-
return typeof input === "function";
|
|
101
|
+
return typeof input === "function" ? true : false;
|
|
201
102
|
}
|
|
202
103
|
|
|
203
|
-
// src/
|
|
104
|
+
// src/runtime/type-checks/isNull.ts
|
|
204
105
|
function isNull(i) {
|
|
205
106
|
return i === null;
|
|
206
107
|
}
|
|
@@ -208,7 +109,7 @@ function ifNull(val, ifVal, elseVal) {
|
|
|
208
109
|
return isNull(val) ? ifVal : elseVal;
|
|
209
110
|
}
|
|
210
111
|
|
|
211
|
-
// src/
|
|
112
|
+
// src/runtime/type-checks/isNumber.ts
|
|
212
113
|
function isNumber(i) {
|
|
213
114
|
return typeof i === "number";
|
|
214
115
|
}
|
|
@@ -216,12 +117,12 @@ function ifNumber(val, ifVal, elseVal) {
|
|
|
216
117
|
return isNumber(val) ? ifVal : elseVal;
|
|
217
118
|
}
|
|
218
119
|
|
|
219
|
-
// src/
|
|
120
|
+
// src/runtime/type-checks/isObject.ts
|
|
220
121
|
function isObject(i) {
|
|
221
122
|
return typeof i === "object" && i !== null && Array.isArray(i) === false;
|
|
222
123
|
}
|
|
223
124
|
|
|
224
|
-
// src/
|
|
125
|
+
// src/runtime/type-checks/isString.ts
|
|
225
126
|
function isString(i) {
|
|
226
127
|
return typeof i === "string";
|
|
227
128
|
}
|
|
@@ -229,12 +130,12 @@ function ifString(val, ifVal, elseVal) {
|
|
|
229
130
|
return isString(val) ? ifVal : elseVal;
|
|
230
131
|
}
|
|
231
132
|
|
|
232
|
-
// src/
|
|
133
|
+
// src/runtime/type-checks/isSymbol.ts
|
|
233
134
|
function isSymbol(i) {
|
|
234
135
|
return typeof i === "symbol";
|
|
235
136
|
}
|
|
236
137
|
|
|
237
|
-
// src/
|
|
138
|
+
// src/runtime/type-checks/isTrue.ts
|
|
238
139
|
function isTrue(i) {
|
|
239
140
|
return typeof i === "boolean" && i === true;
|
|
240
141
|
}
|
|
@@ -242,7 +143,7 @@ function ifTrue(val, ifVal, elseVal) {
|
|
|
242
143
|
return isTrue(val) ? ifVal : elseVal;
|
|
243
144
|
}
|
|
244
145
|
|
|
245
|
-
// src/
|
|
146
|
+
// src/runtime/type-checks/isUndefined.ts
|
|
246
147
|
function isUndefined(i) {
|
|
247
148
|
return typeof i === "undefined";
|
|
248
149
|
}
|
|
@@ -250,7 +151,7 @@ function ifUndefined(val, ifVal, elseVal) {
|
|
|
250
151
|
return isUndefined(val) ? ifVal : elseVal;
|
|
251
152
|
}
|
|
252
153
|
|
|
253
|
-
// src/
|
|
154
|
+
// src/runtime/runtime/type.ts
|
|
254
155
|
var typeApi = () => ({
|
|
255
156
|
string: {
|
|
256
157
|
name: "string",
|
|
@@ -332,7 +233,7 @@ function type(fn) {
|
|
|
332
233
|
return result;
|
|
333
234
|
}
|
|
334
235
|
|
|
335
|
-
// src/
|
|
236
|
+
// src/runtime/dictionary/entries.ts
|
|
336
237
|
function entries(obj) {
|
|
337
238
|
const iterable = {
|
|
338
239
|
*[Symbol.iterator]() {
|
|
@@ -344,7 +245,7 @@ function entries(obj) {
|
|
|
344
245
|
return iterable;
|
|
345
246
|
}
|
|
346
247
|
|
|
347
|
-
// src/
|
|
248
|
+
// src/runtime/runtime/withValue.ts
|
|
348
249
|
function withValue(td) {
|
|
349
250
|
return (obj) => {
|
|
350
251
|
const t = type(td);
|
|
@@ -356,12 +257,12 @@ function withValue(td) {
|
|
|
356
257
|
};
|
|
357
258
|
}
|
|
358
259
|
|
|
359
|
-
// src/
|
|
260
|
+
// src/runtime/lists/asArray.ts
|
|
360
261
|
var asArray = (thing, _widen) => {
|
|
361
262
|
return isArray(thing) ? thing : typeof thing === "undefined" ? [] : [thing];
|
|
362
263
|
};
|
|
363
264
|
|
|
364
|
-
// src/
|
|
265
|
+
// src/runtime/combinators/filter.ts
|
|
365
266
|
function isNotFilter(f) {
|
|
366
267
|
return typeof f === "object" && "not" in f;
|
|
367
268
|
}
|
|
@@ -397,15 +298,15 @@ var numericOps = (config, boolLogic) => {
|
|
|
397
298
|
var stringOps = (config, boolLogic) => {
|
|
398
299
|
const startsWith = (n) => {
|
|
399
300
|
const f = asArray(n);
|
|
400
|
-
return f.length === 0 ? [] : [(input) => f.some((i) => input
|
|
301
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input?.startsWith(i))];
|
|
401
302
|
};
|
|
402
303
|
const endsWith = (n) => {
|
|
403
304
|
const f = asArray(n);
|
|
404
|
-
return f.length === 0 ? [] : [(input) => f.some((i) => input
|
|
305
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input?.endsWith(i))];
|
|
405
306
|
};
|
|
406
307
|
const contains = (n) => {
|
|
407
308
|
const f = asArray(n);
|
|
408
|
-
return f.length === 0 ? [] : [(input) => f.some((i) => input
|
|
309
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input?.includes(i))];
|
|
409
310
|
};
|
|
410
311
|
const conditions = [
|
|
411
312
|
..."startsWith" in config ? startsWith(config.startsWith) : [],
|
|
@@ -437,7 +338,7 @@ var filter = (config, logicCombinator = "AND", ifUndefined2 = "no-impact") => {
|
|
|
437
338
|
return filterFn(config, logicCombinator, ifUndefined2);
|
|
438
339
|
};
|
|
439
340
|
|
|
440
|
-
// src/
|
|
341
|
+
// src/runtime/dictionary/arrayToKeyLookup.ts
|
|
441
342
|
function arrayToKeyLookup(...keys2) {
|
|
442
343
|
const obj = {};
|
|
443
344
|
for (const key of keys2) {
|
|
@@ -446,7 +347,7 @@ function arrayToKeyLookup(...keys2) {
|
|
|
446
347
|
return obj;
|
|
447
348
|
}
|
|
448
349
|
|
|
449
|
-
// src/
|
|
350
|
+
// src/runtime/dictionary/defineProperties.ts
|
|
450
351
|
function defineProperties(obj) {
|
|
451
352
|
return {
|
|
452
353
|
ro(prop, errorMsg) {
|
|
@@ -466,7 +367,7 @@ function defineProperties(obj) {
|
|
|
466
367
|
};
|
|
467
368
|
}
|
|
468
369
|
|
|
469
|
-
// src/
|
|
370
|
+
// src/runtime/dictionary/dictionaryTransform.ts
|
|
470
371
|
function dictionaryTransform(input, transform) {
|
|
471
372
|
return keys(input).reduce((acc, i) => {
|
|
472
373
|
const key = i;
|
|
@@ -474,7 +375,7 @@ function dictionaryTransform(input, transform) {
|
|
|
474
375
|
}, {});
|
|
475
376
|
}
|
|
476
377
|
|
|
477
|
-
// src/
|
|
378
|
+
// src/runtime/dictionary/dictArr.ts
|
|
478
379
|
var dictArr = (...dicts) => {
|
|
479
380
|
const api2 = {
|
|
480
381
|
length: dicts.length,
|
|
@@ -512,14 +413,14 @@ var dictArr = (...dicts) => {
|
|
|
512
413
|
return api2;
|
|
513
414
|
};
|
|
514
415
|
|
|
515
|
-
// src/
|
|
416
|
+
// src/runtime/dictionary/mapValues.ts
|
|
516
417
|
function mapValues(obj, valueMapper) {
|
|
517
418
|
return Object.fromEntries(
|
|
518
419
|
[...entries(obj)].map(([k, v]) => [k, valueMapper(v)])
|
|
519
420
|
);
|
|
520
421
|
}
|
|
521
422
|
|
|
522
|
-
// src/
|
|
423
|
+
// src/runtime/dictionary/mapTo.ts
|
|
523
424
|
var toFinalizedConfig = (config) => {
|
|
524
425
|
return { ...config, finalized: true };
|
|
525
426
|
};
|
|
@@ -584,10 +485,10 @@ var setMapper = (config = { input: void 0, output: void 0, cardinality: void 0 }
|
|
|
584
485
|
};
|
|
585
486
|
return mapper(c)(source);
|
|
586
487
|
},
|
|
587
|
-
input:
|
|
588
|
-
output:
|
|
589
|
-
cardinality:
|
|
590
|
-
debug:
|
|
488
|
+
input: config?.input || defaultValue.input,
|
|
489
|
+
output: config?.output || defaultValue.output,
|
|
490
|
+
cardinality: config?.cardinality || defaultValue.cardinality,
|
|
491
|
+
debug: config?.debug || false
|
|
591
492
|
});
|
|
592
493
|
var mapToFn = (map) => {
|
|
593
494
|
return mapper(DEFAULT_ONE_TO_MANY_MAPPING)(map);
|
|
@@ -612,7 +513,7 @@ var mapToDict = {
|
|
|
612
513
|
};
|
|
613
514
|
var mapTo = createFnWithProps(mapToFn, mapToDict);
|
|
614
515
|
|
|
615
|
-
// src/
|
|
516
|
+
// src/runtime/dictionary/strArrayToDict.ts
|
|
616
517
|
function strArrayToDict(...strings) {
|
|
617
518
|
return strings.reduce((acc, str) => {
|
|
618
519
|
acc = { ...acc, [str]: true };
|
|
@@ -620,14 +521,14 @@ function strArrayToDict(...strings) {
|
|
|
620
521
|
}, {});
|
|
621
522
|
}
|
|
622
523
|
|
|
623
|
-
// src/
|
|
524
|
+
// src/runtime/dictionary/kv/dictToKv.ts
|
|
624
525
|
function dictToKv(obj, _makeTuple = false) {
|
|
625
526
|
return keys(obj).map((k) => {
|
|
626
527
|
return { key: k, value: obj[k] };
|
|
627
528
|
});
|
|
628
529
|
}
|
|
629
530
|
|
|
630
|
-
// src/
|
|
531
|
+
// src/runtime/state/Configurator.ts
|
|
631
532
|
function omit(obj, ...removals) {
|
|
632
533
|
const untyped = removals;
|
|
633
534
|
return Object.fromEntries(Object.entries(obj).filter(([key]) => !untyped.includes(key)));
|
|
@@ -657,7 +558,7 @@ function Configurator() {
|
|
|
657
558
|
return api2();
|
|
658
559
|
}
|
|
659
560
|
|
|
660
|
-
// src/
|
|
561
|
+
// src/runtime/state/FluentConfigurator.ts
|
|
661
562
|
function FluentConfigurator(initial = {}) {
|
|
662
563
|
const api2 = (current) => {
|
|
663
564
|
return {
|
|
@@ -679,7 +580,7 @@ function FluentConfigurator(initial = {}) {
|
|
|
679
580
|
return initial ? api2(initial) : api2({});
|
|
680
581
|
}
|
|
681
582
|
|
|
682
|
-
// src/
|
|
583
|
+
// src/runtime/dictionary/kv/filterDictArray.ts
|
|
683
584
|
function filterDictArray(dictArr2, cb) {
|
|
684
585
|
const state = Configurator();
|
|
685
586
|
const updated = dictArr2.filter((i) => {
|
|
@@ -693,12 +594,12 @@ function filterDictArray(dictArr2, cb) {
|
|
|
693
594
|
return updated;
|
|
694
595
|
}
|
|
695
596
|
|
|
696
|
-
// src/
|
|
597
|
+
// src/runtime/dictionary/kv/kv.ts
|
|
697
598
|
function kv(key, value) {
|
|
698
599
|
return { [key]: value };
|
|
699
600
|
}
|
|
700
601
|
|
|
701
|
-
// src/
|
|
602
|
+
// src/runtime/dictionary/kv/kvToDict.ts
|
|
702
603
|
function kvToDict(kvArr) {
|
|
703
604
|
const out = {};
|
|
704
605
|
for (const kv2 of kvArr) {
|
|
@@ -707,17 +608,17 @@ function kvToDict(kvArr) {
|
|
|
707
608
|
return out;
|
|
708
609
|
}
|
|
709
610
|
|
|
710
|
-
// src/
|
|
611
|
+
// src/runtime/lists/groupBy.ts
|
|
711
612
|
function groupBy(_data) {
|
|
712
613
|
throw new Error("not implemented");
|
|
713
614
|
}
|
|
714
615
|
|
|
715
|
-
// src/
|
|
616
|
+
// src/runtime/literals/ExplicitFunction.ts
|
|
716
617
|
function ExplicitFunction(fn) {
|
|
717
618
|
return fn;
|
|
718
619
|
}
|
|
719
620
|
|
|
720
|
-
// src/
|
|
621
|
+
// src/runtime/literals/arrayToObject.ts
|
|
721
622
|
function arrayToObject(prop, unique) {
|
|
722
623
|
const transform = (arr) => {
|
|
723
624
|
const result = unique !== false ? arr.reduce((acc, v) => ({ ...acc, [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
|
|
@@ -729,17 +630,33 @@ function arrayToObject(prop, unique) {
|
|
|
729
630
|
return transform;
|
|
730
631
|
}
|
|
731
632
|
|
|
732
|
-
// src/
|
|
633
|
+
// src/runtime/literals/box.ts
|
|
634
|
+
function box(value) {
|
|
635
|
+
const rtn = {
|
|
636
|
+
__kind: "box",
|
|
637
|
+
value,
|
|
638
|
+
unbox: () => value
|
|
639
|
+
};
|
|
640
|
+
return rtn;
|
|
641
|
+
}
|
|
642
|
+
function isBox(thing) {
|
|
643
|
+
return typeof thing === "object" && "__kind" in thing && thing.__kind === "box";
|
|
644
|
+
}
|
|
645
|
+
function unbox(thing) {
|
|
646
|
+
return isBox(thing) ? thing.unbox() : thing;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// src/runtime/literals/defineType.ts
|
|
733
650
|
function defineType(literal2 = {}) {
|
|
734
651
|
return (wide = {}) => {
|
|
735
652
|
return literal2 ? { ...wide, ...literal2 } : wide;
|
|
736
653
|
};
|
|
737
654
|
}
|
|
738
655
|
|
|
739
|
-
// src/
|
|
656
|
+
// src/runtime/literals/identity.ts
|
|
740
657
|
var identity = (v) => v;
|
|
741
658
|
|
|
742
|
-
// src/
|
|
659
|
+
// src/runtime/literals/literal.ts
|
|
743
660
|
function idLiteral(o) {
|
|
744
661
|
return { ...o, id: o.id };
|
|
745
662
|
}
|
|
@@ -755,24 +672,6 @@ function idTypeGuard(_o) {
|
|
|
755
672
|
function literal(obj) {
|
|
756
673
|
return obj;
|
|
757
674
|
}
|
|
758
|
-
|
|
759
|
-
// src/utility/modelling/Model.ts
|
|
760
|
-
function Model(name) {
|
|
761
|
-
return {
|
|
762
|
-
required(_prop) {
|
|
763
|
-
return Model(name);
|
|
764
|
-
},
|
|
765
|
-
optional(_prop) {
|
|
766
|
-
return Model(name);
|
|
767
|
-
},
|
|
768
|
-
done() {
|
|
769
|
-
return {
|
|
770
|
-
__model__: name,
|
|
771
|
-
__kind__: "model"
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
675
|
export {
|
|
777
676
|
Configurator,
|
|
778
677
|
DEFAULT_MANY_TO_ONE_MAPPING,
|
|
@@ -781,16 +680,14 @@ export {
|
|
|
781
680
|
ExplicitFunction,
|
|
782
681
|
FluentConfigurator,
|
|
783
682
|
MapCardinality,
|
|
784
|
-
Model,
|
|
785
|
-
MutationIdentity,
|
|
786
683
|
and,
|
|
787
684
|
api,
|
|
788
685
|
arrayToKeyLookup,
|
|
789
686
|
arrayToObject,
|
|
790
687
|
asArray,
|
|
688
|
+
box,
|
|
791
689
|
condition,
|
|
792
690
|
createFnWithProps,
|
|
793
|
-
createMutationFunction,
|
|
794
691
|
defineProperties,
|
|
795
692
|
defineType,
|
|
796
693
|
dictArr,
|
|
@@ -809,10 +706,10 @@ export {
|
|
|
809
706
|
ifNumber,
|
|
810
707
|
ifString,
|
|
811
708
|
ifTrue,
|
|
812
|
-
ifTypeOf,
|
|
813
709
|
ifUndefined,
|
|
814
710
|
isArray,
|
|
815
711
|
isBoolean,
|
|
712
|
+
isBox,
|
|
816
713
|
isFalse,
|
|
817
714
|
isFunction,
|
|
818
715
|
isNotFilter,
|
|
@@ -837,13 +734,11 @@ export {
|
|
|
837
734
|
nameLiteral,
|
|
838
735
|
not,
|
|
839
736
|
or,
|
|
840
|
-
randomString,
|
|
841
737
|
readonlyFnWithProps,
|
|
842
738
|
ruleSet,
|
|
843
739
|
strArrayToDict,
|
|
844
740
|
type,
|
|
845
741
|
typeApi,
|
|
846
|
-
|
|
847
|
-
valueTypes,
|
|
742
|
+
unbox,
|
|
848
743
|
withValue
|
|
849
744
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inferred-types",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.3",
|
|
4
4
|
"description": "Functions which provide useful type inference on TS projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ken Snyder<ken@ken.net>",
|
|
@@ -32,31 +32,32 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@type-challenges/utils": "~0.1.1",
|
|
35
|
-
"@types/node": "^16.18.
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
37
|
-
"@typescript-eslint/parser": "^5.
|
|
35
|
+
"@types/node": "^16.18.3",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
37
|
+
"@typescript-eslint/parser": "^5.45.0",
|
|
38
|
+
"@vitest/ui": "^0.25.3",
|
|
38
39
|
"bumpp": "^8.2.1",
|
|
39
|
-
"common-types": "^1.
|
|
40
|
+
"common-types": "^1.33.2",
|
|
40
41
|
"cross-env": "^7.0.3",
|
|
41
|
-
"dd": "^0.
|
|
42
|
+
"dd": "^0.25.4",
|
|
42
43
|
"dotenv": "^16.0.3",
|
|
43
|
-
"eslint": "^8.
|
|
44
|
+
"eslint": "^8.28.0",
|
|
44
45
|
"eslint-config-prettier": "^8.5.0",
|
|
45
46
|
"eslint-plugin-import": "^2.26.0",
|
|
46
47
|
"eslint-plugin-prettier": "^4.2.1",
|
|
47
48
|
"eslint-plugin-promise": "^6.1.1",
|
|
48
49
|
"npm-run-all": "~4.1.5",
|
|
49
|
-
"pathe": "^0.
|
|
50
|
-
"prettier": "~2.
|
|
50
|
+
"pathe": "^1.0.0",
|
|
51
|
+
"prettier": "~2.8.0",
|
|
51
52
|
"rimraf": "^3.0.2",
|
|
52
|
-
"sharp": "^0.31.
|
|
53
|
-
"tsup": "^6.
|
|
54
|
-
"typescript": "^4.
|
|
55
|
-
"vite": "^3.
|
|
56
|
-
"vitest": "^0.
|
|
53
|
+
"sharp": "^0.31.2",
|
|
54
|
+
"tsup": "^6.5.0",
|
|
55
|
+
"typescript": "^4.9.3",
|
|
56
|
+
"vite": "^3.2.4",
|
|
57
|
+
"vitest": "^0.25.3"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"brilliant-errors": "^0.6.
|
|
60
|
+
"brilliant-errors": "^0.6.1"
|
|
60
61
|
},
|
|
61
62
|
"pnpm": {
|
|
62
63
|
"overrides": {
|
|
File without changes
|
|
File without changes
|
package/src/index.ts
CHANGED
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
// hash-code: 5ddbbf55
|
|
6
6
|
|
|
7
7
|
// directory exports
|
|
8
|
-
export * from "./Mutation/index";
|
|
9
|
-
export * from "./shared/index";
|
|
10
8
|
export * from "./types/index";
|
|
11
|
-
export * from "./
|
|
9
|
+
export * from "./runtime/index";
|
|
12
10
|
|
|
13
11
|
// #endregion auto-indexed files
|
|
14
12
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DomainName, Ipv4, NetworkProtocol, RelativeUrl } from "src/types";
|
|
2
|
+
|
|
3
|
+
export const url = <
|
|
4
|
+
Proto extends NetworkProtocol,
|
|
5
|
+
Site extends DomainName | Ipv4,
|
|
6
|
+
Path extends RelativeUrl
|
|
7
|
+
>(
|
|
8
|
+
...args: [Proto, Site, Path]
|
|
9
|
+
) => {
|
|
10
|
+
if (args.length === 3) {
|
|
11
|
+
return `${args[0]}://${args[1]}/${args[2]}`;
|
|
12
|
+
} else {
|
|
13
|
+
return args[0];
|
|
14
|
+
}
|
|
15
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|