inferred-types 0.33.0 → 0.33.2
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 +1182 -1125
- 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 -4
- 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 +3 -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.js
CHANGED
|
@@ -27,16 +27,14 @@ __export(src_exports, {
|
|
|
27
27
|
ExplicitFunction: () => ExplicitFunction,
|
|
28
28
|
FluentConfigurator: () => FluentConfigurator,
|
|
29
29
|
MapCardinality: () => MapCardinality,
|
|
30
|
-
Model: () => Model,
|
|
31
|
-
MutationIdentity: () => MutationIdentity,
|
|
32
30
|
and: () => and,
|
|
33
31
|
api: () => api,
|
|
34
32
|
arrayToKeyLookup: () => arrayToKeyLookup,
|
|
35
33
|
arrayToObject: () => arrayToObject,
|
|
36
34
|
asArray: () => asArray,
|
|
35
|
+
box: () => box,
|
|
37
36
|
condition: () => condition,
|
|
38
37
|
createFnWithProps: () => createFnWithProps,
|
|
39
|
-
createMutationFunction: () => createMutationFunction,
|
|
40
38
|
defineProperties: () => defineProperties,
|
|
41
39
|
defineType: () => defineType,
|
|
42
40
|
dictArr: () => dictArr,
|
|
@@ -55,10 +53,10 @@ __export(src_exports, {
|
|
|
55
53
|
ifNumber: () => ifNumber,
|
|
56
54
|
ifString: () => ifString,
|
|
57
55
|
ifTrue: () => ifTrue,
|
|
58
|
-
ifTypeOf: () => ifTypeOf,
|
|
59
56
|
ifUndefined: () => ifUndefined,
|
|
60
57
|
isArray: () => isArray,
|
|
61
58
|
isBoolean: () => isBoolean,
|
|
59
|
+
isBox: () => isBox,
|
|
62
60
|
isFalse: () => isFalse,
|
|
63
61
|
isFunction: () => isFunction,
|
|
64
62
|
isNotFilter: () => isNotFilter,
|
|
@@ -83,61 +81,16 @@ __export(src_exports, {
|
|
|
83
81
|
nameLiteral: () => nameLiteral,
|
|
84
82
|
not: () => not,
|
|
85
83
|
or: () => or,
|
|
86
|
-
randomString: () => randomString,
|
|
87
84
|
readonlyFnWithProps: () => readonlyFnWithProps,
|
|
88
85
|
ruleSet: () => ruleSet,
|
|
89
86
|
strArrayToDict: () => strArrayToDict,
|
|
90
87
|
type: () => type,
|
|
91
88
|
typeApi: () => typeApi,
|
|
92
|
-
|
|
93
|
-
valueTypes: () => valueTypes,
|
|
89
|
+
unbox: () => unbox,
|
|
94
90
|
withValue: () => withValue
|
|
95
91
|
});
|
|
96
92
|
module.exports = __toCommonJS(src_exports);
|
|
97
93
|
|
|
98
|
-
// src/Mutation/MutationFunction.ts
|
|
99
|
-
function createMutationFunction(state) {
|
|
100
|
-
return (mutationIdentity) => {
|
|
101
|
-
return mutationIdentity(state);
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// src/Mutation/MutationIdentity.ts
|
|
106
|
-
function MutationIdentity() {
|
|
107
|
-
return function(m) {
|
|
108
|
-
return m;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// src/shared/randomString.ts
|
|
113
|
-
function randomString() {
|
|
114
|
-
return Math.trunc((1 + Math.random()) * 65536).toString(16).slice(1);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// src/shared/uuid.ts
|
|
118
|
-
function uuid() {
|
|
119
|
-
return `${randomString()}${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}${randomString()}${randomString()}`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// src/shared/valueTypes.ts
|
|
123
|
-
var valueTypes = {
|
|
124
|
-
string: ["", false],
|
|
125
|
-
boolean: [true, false],
|
|
126
|
-
number: [0, false],
|
|
127
|
-
function: [() => "", false],
|
|
128
|
-
object: [{}, false],
|
|
129
|
-
array: (arr = []) => [arr, false],
|
|
130
|
-
null: [null, false],
|
|
131
|
-
symbol: [Symbol("type"), false],
|
|
132
|
-
undefined: [void 0, false],
|
|
133
|
-
true: [true, true],
|
|
134
|
-
false: [false, true],
|
|
135
|
-
literal: (v) => {
|
|
136
|
-
return [v, true];
|
|
137
|
-
},
|
|
138
|
-
literalArray: (arr) => [arr, true]
|
|
139
|
-
};
|
|
140
|
-
|
|
141
94
|
// src/types/dictionary/MapTo.ts
|
|
142
95
|
var MapCardinality = /* @__PURE__ */ ((MapCardinality2) => {
|
|
143
96
|
MapCardinality2["OneToMany"] = "I -> O[]";
|
|
@@ -146,13 +99,13 @@ var MapCardinality = /* @__PURE__ */ ((MapCardinality2) => {
|
|
|
146
99
|
return MapCardinality2;
|
|
147
100
|
})(MapCardinality || {});
|
|
148
101
|
|
|
149
|
-
// src/
|
|
102
|
+
// src/runtime/keys.ts
|
|
150
103
|
function keys(obj, ...without) {
|
|
151
104
|
const v = without.length > 0 ? Object.keys(obj).filter((k) => !without.includes(k)) : Object.keys(obj);
|
|
152
105
|
return v;
|
|
153
106
|
}
|
|
154
107
|
|
|
155
|
-
// src/
|
|
108
|
+
// src/runtime/createFnWithProps.ts
|
|
156
109
|
function createFnWithProps(fn, props) {
|
|
157
110
|
return (() => {
|
|
158
111
|
let combined = fn;
|
|
@@ -177,19 +130,19 @@ function readonlyFnWithProps(fn, props) {
|
|
|
177
130
|
return combined;
|
|
178
131
|
}
|
|
179
132
|
|
|
180
|
-
// src/
|
|
133
|
+
// src/runtime/ruleset.ts
|
|
181
134
|
function ruleSet(defn) {
|
|
182
135
|
return defn;
|
|
183
136
|
}
|
|
184
137
|
|
|
185
|
-
// src/
|
|
138
|
+
// src/runtime/api/api.ts
|
|
186
139
|
var api = (priv) => (pub) => {
|
|
187
140
|
const surface = () => pub;
|
|
188
141
|
surface.prototype.priv = () => priv;
|
|
189
142
|
return surface;
|
|
190
143
|
};
|
|
191
144
|
|
|
192
|
-
// src/
|
|
145
|
+
// src/runtime/combinators/and.ts
|
|
193
146
|
var and = (...ops) => {
|
|
194
147
|
const fn = (...args) => {
|
|
195
148
|
return [...ops].every((i) => i(...args));
|
|
@@ -197,7 +150,7 @@ var and = (...ops) => {
|
|
|
197
150
|
return fn;
|
|
198
151
|
};
|
|
199
152
|
|
|
200
|
-
// src/
|
|
153
|
+
// src/runtime/combinators/or.ts
|
|
201
154
|
var or = (...ops) => {
|
|
202
155
|
const fn = (...args) => {
|
|
203
156
|
return [...ops].some((i) => i(...args));
|
|
@@ -205,7 +158,7 @@ var or = (...ops) => {
|
|
|
205
158
|
return fn;
|
|
206
159
|
};
|
|
207
160
|
|
|
208
|
-
// src/
|
|
161
|
+
// src/runtime/combinators/not.ts
|
|
209
162
|
var not = (op) => {
|
|
210
163
|
const fn = (...args) => {
|
|
211
164
|
return !op(...args);
|
|
@@ -213,73 +166,17 @@ var not = (op) => {
|
|
|
213
166
|
return fn;
|
|
214
167
|
};
|
|
215
168
|
|
|
216
|
-
// src/
|
|
169
|
+
// src/runtime/runtime/condition.ts
|
|
217
170
|
var condition = (c, input) => {
|
|
218
171
|
return c(input);
|
|
219
172
|
};
|
|
220
173
|
|
|
221
|
-
// src/
|
|
222
|
-
function runtimeExtendsCheck(val, base, narrow = false) {
|
|
223
|
-
if (typeof val !== typeof base) {
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
switch (typeof val) {
|
|
227
|
-
case "boolean":
|
|
228
|
-
case "string":
|
|
229
|
-
case "number":
|
|
230
|
-
case "symbol":
|
|
231
|
-
case "bigint":
|
|
232
|
-
return narrow ? val === base : true;
|
|
233
|
-
case "undefined":
|
|
234
|
-
return true;
|
|
235
|
-
case "function":
|
|
236
|
-
if (narrow) {
|
|
237
|
-
throw new Error(`Use of narrowlyExtends with a function is not possible!`);
|
|
238
|
-
}
|
|
239
|
-
return true;
|
|
240
|
-
case "object":
|
|
241
|
-
if (val === null && base === null) {
|
|
242
|
-
return true;
|
|
243
|
-
} else {
|
|
244
|
-
return keys(base).every(
|
|
245
|
-
(i) => runtimeExtendsCheck(val[i], base[i], narrow)
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
var ifTypeOf = (val) => ({
|
|
251
|
-
extends: (base) => {
|
|
252
|
-
const valid = runtimeExtendsCheck(val, base, false);
|
|
253
|
-
const trueFalse = valid ? true : false;
|
|
254
|
-
return {
|
|
255
|
-
then: (then) => ({
|
|
256
|
-
else: (elseVal) => {
|
|
257
|
-
return valid ? typeof then === "undefined" ? val : then : elseVal;
|
|
258
|
-
}
|
|
259
|
-
}),
|
|
260
|
-
else: (elseVal) => valid ? val : elseVal
|
|
261
|
-
} && trueFalse;
|
|
262
|
-
},
|
|
263
|
-
narrowlyExtends: (base) => {
|
|
264
|
-
const valid = runtimeExtendsCheck(val, base, true);
|
|
265
|
-
const trueFalse = valid ? true : false;
|
|
266
|
-
return {
|
|
267
|
-
then: (then) => ({
|
|
268
|
-
else: (elseVal) => {
|
|
269
|
-
return valid ? typeof then === "undefined" ? val : then : elseVal;
|
|
270
|
-
}
|
|
271
|
-
}),
|
|
272
|
-
else: (elseVal) => valid ? val : elseVal
|
|
273
|
-
} && trueFalse;
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
// src/utility/runtime/conditions/isArray.ts
|
|
174
|
+
// src/runtime/type-checks/isArray.ts
|
|
278
175
|
function isArray(i) {
|
|
279
176
|
return Array.isArray(i) === true;
|
|
280
177
|
}
|
|
281
178
|
|
|
282
|
-
// src/
|
|
179
|
+
// src/runtime/type-checks/isBoolean.ts
|
|
283
180
|
function isBoolean(i) {
|
|
284
181
|
return typeof i === "boolean";
|
|
285
182
|
}
|
|
@@ -287,17 +184,17 @@ function ifBoolean(val, ifVal, elseVal) {
|
|
|
287
184
|
return isBoolean(val) ? ifVal : elseVal;
|
|
288
185
|
}
|
|
289
186
|
|
|
290
|
-
// src/
|
|
187
|
+
// src/runtime/type-checks/isFalse.ts
|
|
291
188
|
function isFalse(i) {
|
|
292
189
|
return typeof i === "boolean" && !i;
|
|
293
190
|
}
|
|
294
191
|
|
|
295
|
-
// src/
|
|
192
|
+
// src/runtime/type-checks/isFunction.ts
|
|
296
193
|
function isFunction(input) {
|
|
297
|
-
return typeof input === "function";
|
|
194
|
+
return typeof input === "function" ? true : false;
|
|
298
195
|
}
|
|
299
196
|
|
|
300
|
-
// src/
|
|
197
|
+
// src/runtime/type-checks/isNull.ts
|
|
301
198
|
function isNull(i) {
|
|
302
199
|
return i === null;
|
|
303
200
|
}
|
|
@@ -305,7 +202,7 @@ function ifNull(val, ifVal, elseVal) {
|
|
|
305
202
|
return isNull(val) ? ifVal : elseVal;
|
|
306
203
|
}
|
|
307
204
|
|
|
308
|
-
// src/
|
|
205
|
+
// src/runtime/type-checks/isNumber.ts
|
|
309
206
|
function isNumber(i) {
|
|
310
207
|
return typeof i === "number";
|
|
311
208
|
}
|
|
@@ -313,12 +210,12 @@ function ifNumber(val, ifVal, elseVal) {
|
|
|
313
210
|
return isNumber(val) ? ifVal : elseVal;
|
|
314
211
|
}
|
|
315
212
|
|
|
316
|
-
// src/
|
|
213
|
+
// src/runtime/type-checks/isObject.ts
|
|
317
214
|
function isObject(i) {
|
|
318
215
|
return typeof i === "object" && i !== null && Array.isArray(i) === false;
|
|
319
216
|
}
|
|
320
217
|
|
|
321
|
-
// src/
|
|
218
|
+
// src/runtime/type-checks/isString.ts
|
|
322
219
|
function isString(i) {
|
|
323
220
|
return typeof i === "string";
|
|
324
221
|
}
|
|
@@ -326,12 +223,12 @@ function ifString(val, ifVal, elseVal) {
|
|
|
326
223
|
return isString(val) ? ifVal : elseVal;
|
|
327
224
|
}
|
|
328
225
|
|
|
329
|
-
// src/
|
|
226
|
+
// src/runtime/type-checks/isSymbol.ts
|
|
330
227
|
function isSymbol(i) {
|
|
331
228
|
return typeof i === "symbol";
|
|
332
229
|
}
|
|
333
230
|
|
|
334
|
-
// src/
|
|
231
|
+
// src/runtime/type-checks/isTrue.ts
|
|
335
232
|
function isTrue(i) {
|
|
336
233
|
return typeof i === "boolean" && i === true;
|
|
337
234
|
}
|
|
@@ -339,7 +236,7 @@ function ifTrue(val, ifVal, elseVal) {
|
|
|
339
236
|
return isTrue(val) ? ifVal : elseVal;
|
|
340
237
|
}
|
|
341
238
|
|
|
342
|
-
// src/
|
|
239
|
+
// src/runtime/type-checks/isUndefined.ts
|
|
343
240
|
function isUndefined(i) {
|
|
344
241
|
return typeof i === "undefined";
|
|
345
242
|
}
|
|
@@ -347,7 +244,7 @@ function ifUndefined(val, ifVal, elseVal) {
|
|
|
347
244
|
return isUndefined(val) ? ifVal : elseVal;
|
|
348
245
|
}
|
|
349
246
|
|
|
350
|
-
// src/
|
|
247
|
+
// src/runtime/runtime/type.ts
|
|
351
248
|
var typeApi = () => ({
|
|
352
249
|
string: {
|
|
353
250
|
name: "string",
|
|
@@ -429,7 +326,7 @@ function type(fn) {
|
|
|
429
326
|
return result;
|
|
430
327
|
}
|
|
431
328
|
|
|
432
|
-
// src/
|
|
329
|
+
// src/runtime/dictionary/entries.ts
|
|
433
330
|
function entries(obj) {
|
|
434
331
|
const iterable = {
|
|
435
332
|
*[Symbol.iterator]() {
|
|
@@ -441,7 +338,7 @@ function entries(obj) {
|
|
|
441
338
|
return iterable;
|
|
442
339
|
}
|
|
443
340
|
|
|
444
|
-
// src/
|
|
341
|
+
// src/runtime/runtime/withValue.ts
|
|
445
342
|
function withValue(td) {
|
|
446
343
|
return (obj) => {
|
|
447
344
|
const t = type(td);
|
|
@@ -453,12 +350,12 @@ function withValue(td) {
|
|
|
453
350
|
};
|
|
454
351
|
}
|
|
455
352
|
|
|
456
|
-
// src/
|
|
353
|
+
// src/runtime/lists/asArray.ts
|
|
457
354
|
var asArray = (thing, _widen) => {
|
|
458
355
|
return isArray(thing) ? thing : typeof thing === "undefined" ? [] : [thing];
|
|
459
356
|
};
|
|
460
357
|
|
|
461
|
-
// src/
|
|
358
|
+
// src/runtime/combinators/filter.ts
|
|
462
359
|
function isNotFilter(f) {
|
|
463
360
|
return typeof f === "object" && "not" in f;
|
|
464
361
|
}
|
|
@@ -494,15 +391,15 @@ var numericOps = (config, boolLogic) => {
|
|
|
494
391
|
var stringOps = (config, boolLogic) => {
|
|
495
392
|
const startsWith = (n) => {
|
|
496
393
|
const f = asArray(n);
|
|
497
|
-
return f.length === 0 ? [] : [(input) => f.some((i) => input
|
|
394
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input?.startsWith(i))];
|
|
498
395
|
};
|
|
499
396
|
const endsWith = (n) => {
|
|
500
397
|
const f = asArray(n);
|
|
501
|
-
return f.length === 0 ? [] : [(input) => f.some((i) => input
|
|
398
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input?.endsWith(i))];
|
|
502
399
|
};
|
|
503
400
|
const contains = (n) => {
|
|
504
401
|
const f = asArray(n);
|
|
505
|
-
return f.length === 0 ? [] : [(input) => f.some((i) => input
|
|
402
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input?.includes(i))];
|
|
506
403
|
};
|
|
507
404
|
const conditions = [
|
|
508
405
|
..."startsWith" in config ? startsWith(config.startsWith) : [],
|
|
@@ -534,7 +431,7 @@ var filter = (config, logicCombinator = "AND", ifUndefined2 = "no-impact") => {
|
|
|
534
431
|
return filterFn(config, logicCombinator, ifUndefined2);
|
|
535
432
|
};
|
|
536
433
|
|
|
537
|
-
// src/
|
|
434
|
+
// src/runtime/dictionary/arrayToKeyLookup.ts
|
|
538
435
|
function arrayToKeyLookup(...keys2) {
|
|
539
436
|
const obj = {};
|
|
540
437
|
for (const key of keys2) {
|
|
@@ -543,7 +440,7 @@ function arrayToKeyLookup(...keys2) {
|
|
|
543
440
|
return obj;
|
|
544
441
|
}
|
|
545
442
|
|
|
546
|
-
// src/
|
|
443
|
+
// src/runtime/dictionary/defineProperties.ts
|
|
547
444
|
function defineProperties(obj) {
|
|
548
445
|
return {
|
|
549
446
|
ro(prop, errorMsg) {
|
|
@@ -563,7 +460,7 @@ function defineProperties(obj) {
|
|
|
563
460
|
};
|
|
564
461
|
}
|
|
565
462
|
|
|
566
|
-
// src/
|
|
463
|
+
// src/runtime/dictionary/dictionaryTransform.ts
|
|
567
464
|
function dictionaryTransform(input, transform) {
|
|
568
465
|
return keys(input).reduce((acc, i) => {
|
|
569
466
|
const key = i;
|
|
@@ -571,7 +468,7 @@ function dictionaryTransform(input, transform) {
|
|
|
571
468
|
}, {});
|
|
572
469
|
}
|
|
573
470
|
|
|
574
|
-
// src/
|
|
471
|
+
// src/runtime/dictionary/dictArr.ts
|
|
575
472
|
var dictArr = (...dicts) => {
|
|
576
473
|
const api2 = {
|
|
577
474
|
length: dicts.length,
|
|
@@ -609,14 +506,14 @@ var dictArr = (...dicts) => {
|
|
|
609
506
|
return api2;
|
|
610
507
|
};
|
|
611
508
|
|
|
612
|
-
// src/
|
|
509
|
+
// src/runtime/dictionary/mapValues.ts
|
|
613
510
|
function mapValues(obj, valueMapper) {
|
|
614
511
|
return Object.fromEntries(
|
|
615
512
|
[...entries(obj)].map(([k, v]) => [k, valueMapper(v)])
|
|
616
513
|
);
|
|
617
514
|
}
|
|
618
515
|
|
|
619
|
-
// src/
|
|
516
|
+
// src/runtime/dictionary/mapTo.ts
|
|
620
517
|
var toFinalizedConfig = (config) => {
|
|
621
518
|
return { ...config, finalized: true };
|
|
622
519
|
};
|
|
@@ -681,10 +578,10 @@ var setMapper = (config = { input: void 0, output: void 0, cardinality: void 0 }
|
|
|
681
578
|
};
|
|
682
579
|
return mapper(c)(source);
|
|
683
580
|
},
|
|
684
|
-
input:
|
|
685
|
-
output:
|
|
686
|
-
cardinality:
|
|
687
|
-
debug:
|
|
581
|
+
input: config?.input || defaultValue.input,
|
|
582
|
+
output: config?.output || defaultValue.output,
|
|
583
|
+
cardinality: config?.cardinality || defaultValue.cardinality,
|
|
584
|
+
debug: config?.debug || false
|
|
688
585
|
});
|
|
689
586
|
var mapToFn = (map) => {
|
|
690
587
|
return mapper(DEFAULT_ONE_TO_MANY_MAPPING)(map);
|
|
@@ -709,7 +606,7 @@ var mapToDict = {
|
|
|
709
606
|
};
|
|
710
607
|
var mapTo = createFnWithProps(mapToFn, mapToDict);
|
|
711
608
|
|
|
712
|
-
// src/
|
|
609
|
+
// src/runtime/dictionary/strArrayToDict.ts
|
|
713
610
|
function strArrayToDict(...strings) {
|
|
714
611
|
return strings.reduce((acc, str) => {
|
|
715
612
|
acc = { ...acc, [str]: true };
|
|
@@ -717,14 +614,14 @@ function strArrayToDict(...strings) {
|
|
|
717
614
|
}, {});
|
|
718
615
|
}
|
|
719
616
|
|
|
720
|
-
// src/
|
|
617
|
+
// src/runtime/dictionary/kv/dictToKv.ts
|
|
721
618
|
function dictToKv(obj, _makeTuple = false) {
|
|
722
619
|
return keys(obj).map((k) => {
|
|
723
620
|
return { key: k, value: obj[k] };
|
|
724
621
|
});
|
|
725
622
|
}
|
|
726
623
|
|
|
727
|
-
// src/
|
|
624
|
+
// src/runtime/state/Configurator.ts
|
|
728
625
|
function omit(obj, ...removals) {
|
|
729
626
|
const untyped = removals;
|
|
730
627
|
return Object.fromEntries(Object.entries(obj).filter(([key]) => !untyped.includes(key)));
|
|
@@ -754,7 +651,7 @@ function Configurator() {
|
|
|
754
651
|
return api2();
|
|
755
652
|
}
|
|
756
653
|
|
|
757
|
-
// src/
|
|
654
|
+
// src/runtime/state/FluentConfigurator.ts
|
|
758
655
|
function FluentConfigurator(initial = {}) {
|
|
759
656
|
const api2 = (current) => {
|
|
760
657
|
return {
|
|
@@ -776,7 +673,7 @@ function FluentConfigurator(initial = {}) {
|
|
|
776
673
|
return initial ? api2(initial) : api2({});
|
|
777
674
|
}
|
|
778
675
|
|
|
779
|
-
// src/
|
|
676
|
+
// src/runtime/dictionary/kv/filterDictArray.ts
|
|
780
677
|
function filterDictArray(dictArr2, cb) {
|
|
781
678
|
const state = Configurator();
|
|
782
679
|
const updated = dictArr2.filter((i) => {
|
|
@@ -790,12 +687,12 @@ function filterDictArray(dictArr2, cb) {
|
|
|
790
687
|
return updated;
|
|
791
688
|
}
|
|
792
689
|
|
|
793
|
-
// src/
|
|
690
|
+
// src/runtime/dictionary/kv/kv.ts
|
|
794
691
|
function kv(key, value) {
|
|
795
692
|
return { [key]: value };
|
|
796
693
|
}
|
|
797
694
|
|
|
798
|
-
// src/
|
|
695
|
+
// src/runtime/dictionary/kv/kvToDict.ts
|
|
799
696
|
function kvToDict(kvArr) {
|
|
800
697
|
const out = {};
|
|
801
698
|
for (const kv2 of kvArr) {
|
|
@@ -804,17 +701,17 @@ function kvToDict(kvArr) {
|
|
|
804
701
|
return out;
|
|
805
702
|
}
|
|
806
703
|
|
|
807
|
-
// src/
|
|
704
|
+
// src/runtime/lists/groupBy.ts
|
|
808
705
|
function groupBy(_data) {
|
|
809
706
|
throw new Error("not implemented");
|
|
810
707
|
}
|
|
811
708
|
|
|
812
|
-
// src/
|
|
709
|
+
// src/runtime/literals/ExplicitFunction.ts
|
|
813
710
|
function ExplicitFunction(fn) {
|
|
814
711
|
return fn;
|
|
815
712
|
}
|
|
816
713
|
|
|
817
|
-
// src/
|
|
714
|
+
// src/runtime/literals/arrayToObject.ts
|
|
818
715
|
function arrayToObject(prop, unique) {
|
|
819
716
|
const transform = (arr) => {
|
|
820
717
|
const result = unique !== false ? arr.reduce((acc, v) => ({ ...acc, [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
|
|
@@ -826,17 +723,33 @@ function arrayToObject(prop, unique) {
|
|
|
826
723
|
return transform;
|
|
827
724
|
}
|
|
828
725
|
|
|
829
|
-
// src/
|
|
726
|
+
// src/runtime/literals/box.ts
|
|
727
|
+
function box(value) {
|
|
728
|
+
const rtn = {
|
|
729
|
+
__kind: "box",
|
|
730
|
+
value,
|
|
731
|
+
unbox: () => value
|
|
732
|
+
};
|
|
733
|
+
return rtn;
|
|
734
|
+
}
|
|
735
|
+
function isBox(thing) {
|
|
736
|
+
return typeof thing === "object" && "__kind" in thing && thing.__kind === "box";
|
|
737
|
+
}
|
|
738
|
+
function unbox(thing) {
|
|
739
|
+
return isBox(thing) ? thing.unbox() : thing;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// src/runtime/literals/defineType.ts
|
|
830
743
|
function defineType(literal2 = {}) {
|
|
831
744
|
return (wide = {}) => {
|
|
832
745
|
return literal2 ? { ...wide, ...literal2 } : wide;
|
|
833
746
|
};
|
|
834
747
|
}
|
|
835
748
|
|
|
836
|
-
// src/
|
|
749
|
+
// src/runtime/literals/identity.ts
|
|
837
750
|
var identity = (v) => v;
|
|
838
751
|
|
|
839
|
-
// src/
|
|
752
|
+
// src/runtime/literals/literal.ts
|
|
840
753
|
function idLiteral(o) {
|
|
841
754
|
return { ...o, id: o.id };
|
|
842
755
|
}
|
|
@@ -852,24 +765,6 @@ function idTypeGuard(_o) {
|
|
|
852
765
|
function literal(obj) {
|
|
853
766
|
return obj;
|
|
854
767
|
}
|
|
855
|
-
|
|
856
|
-
// src/utility/modelling/Model.ts
|
|
857
|
-
function Model(name) {
|
|
858
|
-
return {
|
|
859
|
-
required(_prop) {
|
|
860
|
-
return Model(name);
|
|
861
|
-
},
|
|
862
|
-
optional(_prop) {
|
|
863
|
-
return Model(name);
|
|
864
|
-
},
|
|
865
|
-
done() {
|
|
866
|
-
return {
|
|
867
|
-
__model__: name,
|
|
868
|
-
__kind__: "model"
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
768
|
// Annotate the CommonJS export names for ESM import in node:
|
|
874
769
|
0 && (module.exports = {
|
|
875
770
|
Configurator,
|
|
@@ -879,16 +774,14 @@ function Model(name) {
|
|
|
879
774
|
ExplicitFunction,
|
|
880
775
|
FluentConfigurator,
|
|
881
776
|
MapCardinality,
|
|
882
|
-
Model,
|
|
883
|
-
MutationIdentity,
|
|
884
777
|
and,
|
|
885
778
|
api,
|
|
886
779
|
arrayToKeyLookup,
|
|
887
780
|
arrayToObject,
|
|
888
781
|
asArray,
|
|
782
|
+
box,
|
|
889
783
|
condition,
|
|
890
784
|
createFnWithProps,
|
|
891
|
-
createMutationFunction,
|
|
892
785
|
defineProperties,
|
|
893
786
|
defineType,
|
|
894
787
|
dictArr,
|
|
@@ -907,10 +800,10 @@ function Model(name) {
|
|
|
907
800
|
ifNumber,
|
|
908
801
|
ifString,
|
|
909
802
|
ifTrue,
|
|
910
|
-
ifTypeOf,
|
|
911
803
|
ifUndefined,
|
|
912
804
|
isArray,
|
|
913
805
|
isBoolean,
|
|
806
|
+
isBox,
|
|
914
807
|
isFalse,
|
|
915
808
|
isFunction,
|
|
916
809
|
isNotFilter,
|
|
@@ -935,13 +828,11 @@ function Model(name) {
|
|
|
935
828
|
nameLiteral,
|
|
936
829
|
not,
|
|
937
830
|
or,
|
|
938
|
-
randomString,
|
|
939
831
|
readonlyFnWithProps,
|
|
940
832
|
ruleSet,
|
|
941
833
|
strArrayToDict,
|
|
942
834
|
type,
|
|
943
835
|
typeApi,
|
|
944
|
-
|
|
945
|
-
valueTypes,
|
|
836
|
+
unbox,
|
|
946
837
|
withValue
|
|
947
838
|
});
|