inferred-types 0.20.0 → 0.22.5
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/.eslintrc +36 -20
- package/.github/workflows/main.yml +34 -0
- package/.github/workflows/other.yml +15 -0
- package/.vscode/settings.json +10 -2
- package/dist/index.d.ts +426 -8547
- package/dist/index.js +57 -76
- package/dist/index.mjs +47 -63
- package/package.json +38 -26
- package/src/Mutation/index.ts +6 -29
- package/src/index.ts +6 -29
- package/src/shared/index.ts +6 -29
- package/src/shared/valueTypes.ts +1 -1
- package/src/types/ExpandRecursively.ts +10 -1
- package/src/types/Keys.ts +10 -6
- package/src/types/SimplifyObject.ts +12 -0
- package/src/types/Transformer.ts +1 -1
- package/src/types/alphabetic/CamelCase.ts +2 -2
- package/src/types/alphabetic/CapFirstAlpha.ts +7 -3
- package/src/types/alphabetic/Dasherize.ts +8 -5
- package/src/types/alphabetic/KebabCase.ts +1 -1
- package/src/types/alphabetic/PascalCase.ts +3 -1
- package/src/types/alphabetic/SnakeCase.ts +8 -3
- package/src/types/alphabetic/alpha-characters.ts +33 -9
- package/src/types/alphabetic/index.ts +6 -29
- package/src/types/dictionary/DictChangeValue.ts +26 -0
- package/src/types/dictionary/DictPartialApplication.ts +30 -0
- package/src/types/dictionary/DictPrependWithFn.ts +23 -0
- package/src/types/dictionary/DictReturnValues.ts +27 -0
- package/src/types/dictionary/MutableProps.ts +19 -0
- package/src/types/dictionary/RequireProps.ts +15 -0
- package/src/types/{type-conversion → dictionary}/SameKeys.ts +0 -0
- package/src/types/dictionary/index.ts +13 -30
- package/src/types/{props.ts → dictionary/props.ts} +2 -2
- package/src/types/fluent/index.ts +6 -29
- package/src/types/functions/FinalReturn.ts +12 -0
- package/src/types/functions/index.ts +12 -0
- package/src/types/index.ts +8 -30
- package/src/types/kv/index.ts +6 -29
- package/src/types/lists/index.ts +6 -29
- package/src/types/ruleset-types.ts +3 -3
- package/src/types/runtime.ts +18 -18
- package/src/types/string-literals/LeftWhitespace.ts +5 -2
- package/src/types/string-literals/RightWhitespace.ts +5 -2
- package/src/types/string-literals/index.ts +6 -29
- package/src/types/tuples/FirstKey.ts +3 -3
- package/src/types/tuples/FromDictArray.ts +5 -4
- package/src/types/tuples/index.ts +6 -29
- package/src/types/type-conversion/index.ts +6 -32
- package/src/utility/api/api.ts +8 -7
- package/src/utility/api/index.ts +6 -29
- package/src/utility/dictionary/defineProperties.ts +35 -0
- package/src/utility/dictionary/dictionaryTransform.ts +5 -4
- package/src/utility/dictionary/entries.ts +9 -5
- package/src/utility/dictionary/index.ts +7 -30
- package/src/utility/dictionary/kv/dictToKv.ts +5 -3
- package/src/utility/dictionary/kv/filterDictArray.ts +5 -7
- package/src/utility/dictionary/kv/index.ts +6 -29
- package/src/utility/dictionary/kv/kv.ts +8 -3
- package/src/utility/dictionary/kv/kvToDict.ts +3 -2
- package/src/utility/dictionary/mapValues.ts +8 -5
- package/src/utility/dictionary/strArrayToDict.ts +1 -2
- package/src/utility/errors/ReadOnlyViolation.ts +3 -0
- package/src/utility/errors/index.ts +12 -0
- package/src/utility/index.ts +7 -29
- package/src/utility/keys.ts +8 -4
- package/src/utility/lists/groupBy.ts +2 -9
- package/src/utility/lists/index.ts +6 -29
- package/src/utility/literals/arrayToObject.ts +29 -29
- package/src/utility/literals/defineType.ts +6 -6
- package/src/utility/literals/identity.ts +5 -2
- package/src/utility/literals/index.ts +6 -29
- package/src/utility/literals/literal.ts +3 -3
- package/src/utility/map-reduce/index.ts +6 -29
- package/src/utility/modelling/index.ts +6 -29
- package/src/utility/ruleset.ts +11 -9
- package/src/utility/runtime/condition.ts +1 -1
- package/src/utility/runtime/conditions/index.ts +6 -30
- package/src/utility/runtime/conditions/isFalse.ts +2 -2
- package/src/utility/runtime/conditions/isFunction.ts +2 -2
- package/src/utility/runtime/conditions/isObject.ts +4 -1
- package/src/utility/runtime/conditions/isTrue.ts +1 -1
- package/src/utility/runtime/ifTypeOf.ts +5 -4
- package/src/utility/runtime/index.ts +6 -29
- package/src/utility/runtime/type.ts +3 -1
- package/src/utility/runtime/withValue.ts +5 -3
- package/src/utility/state/Configurator.ts +2 -2
- package/src/utility/state/FluentConfigurator.ts +2 -2
- package/src/utility/state/index.ts +6 -30
- package/tests/CamelCase-spec.ts +2 -0
- package/tests/ExplicitFunction-spec.ts +3 -2
- package/tests/IncludeAndRetain-spec.ts +7 -12
- package/tests/Includes-spec.ts +2 -0
- package/tests/KebabCase-spec.ts +2 -0
- package/tests/MutationIdentity-spec.ts +2 -1
- package/tests/PascalCase-spec.ts +2 -0
- package/tests/Pluralize-spec.ts +2 -0
- package/tests/SnakeCase-spec.ts +2 -0
- package/tests/Where.spec.ts +9 -10
- package/tests/arrayToKeyLookup-spec.ts +5 -5
- package/tests/arrayToObject-spec.ts +12 -8
- package/tests/constructor.spec.ts +2 -0
- package/tests/createFnWithProps.spec.ts +2 -2
- package/tests/data/index.ts +6 -29
- package/tests/defineType-spec.ts +17 -11
- package/tests/dictionary/DictChangeValue.test.ts +30 -0
- package/tests/dictionary/DictPartialApplication.test.ts +43 -0
- package/tests/dictionary/DictReturnValues.test.ts +36 -0
- package/tests/dictionary/Get.spec.ts +5 -3
- package/tests/dictionary/MutableProps.test.ts +30 -0
- package/tests/dictionary/PrependValuesWithFunction.ts +34 -0
- package/tests/dictionary/RequireProps.test.ts +21 -0
- package/tests/dictionaryTransform-spec.ts +3 -3
- package/tests/ifTypeOf-spec.ts +31 -20
- package/tests/kv/KeyValue-spec.ts +4 -4
- package/tests/kv/SameKeys-spec.ts +6 -9
- package/tests/kv/dict-to-kv-and-back.spec.ts +5 -4
- package/tests/kv/entries-spec.ts +8 -9
- package/tests/kv/keys.spec.ts +9 -19
- package/tests/kv/kv-spec.ts +4 -4
- package/tests/lists/UniqueForProp.spec.ts +3 -1
- package/tests/literal-spec.ts +5 -3
- package/tests/mapValues-spec.ts +5 -3
- package/tests/props-spec.ts +3 -2
- package/tests/runtime/condition.spec.ts +2 -1
- package/tests/runtime/type.spec.ts +4 -3
- package/tests/strArrayToDict-spec.ts +6 -6
- package/tests/string-literals/AllCaps.spec.ts +6 -15
- package/tests/string-literals/CamelCase.spec.ts +13 -32
- package/tests/string-literals/Dasherize.spec.ts +13 -31
- package/tests/string-literals/HasUppercase.spec.ts +6 -15
- package/tests/string-literals/PascalCase.spec.ts +13 -32
- package/tests/string-literals/SnakeCase.spec.ts +13 -32
- package/tests/string-literals/whitespace-capture.spec.ts +10 -28
- package/tests/tuples/TupleToUnion.spec.ts +3 -1
- package/tests/withValue.spec.ts +4 -3
- package/tsconfig.json +8 -19
- package/vitest.config.ts +13 -0
- package/jest.config.ts +0 -20
- package/on-hold/Builder/Builder.ts +0 -66
- package/on-hold/Builder/BuilderApi.ts +0 -21
- package/on-hold/Builder/IdentityToMutationApi.ts +0 -44
- package/on-hold/Builder/MutationToFluentApi.ts +0 -60
- package/on-hold/Builder/index.ts +0 -35
- package/on-hold/tests/Builder-spec.ts +0 -310
- package/on-hold/tests/RuleSet-spec.ts +0 -59
- package/on-hold/tests/ToFluent-spec.ts +0 -60
- package/on-hold/tests/api-spec.ts +0 -73
- package/on-hold/tests/data/builder-data.ts +0 -53
- package/on-hold/tests/filterDictArray-spec.ts +0 -50
- package/on-hold/tests/run-time-spec.ts +0 -44
- package/on-hold/type.ts +0 -20
- package/on-hold/types/index.ts +0 -34
- package/on-hold/types/object.ts +0 -19
- package/on-hold/types/prop.ts +0 -28
- package/on-hold/types/scalar.ts +0 -37
- package/src/types/dictionary/NotEmptyObject.ts +0 -9
- package/src/types/type-conversion/UnwrapValue.ts +0 -13
- package/src/types/type-conversion/WrapValue.ts +0 -15
- package/src/utility/dictionary/valuesOfProp.ts +0 -13
- package/src/utility/runtime/conditions/isLiteral.ts +0 -7
- package/src/utility/state/KeyStorage.ts +0 -23
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// #autoindex
|
|
2
|
+
// #region auto-indexed files
|
|
3
|
+
// index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
|
|
4
|
+
// hash-code: 57dfa865
|
|
5
|
+
|
|
6
|
+
// file exports
|
|
7
|
+
export * from "./FinalReturn";
|
|
8
|
+
|
|
9
|
+
// #endregion auto-indexed files
|
|
10
|
+
|
|
11
|
+
// see https://github.com/inocan-group/do-devops/docs/autoindex.md
|
|
12
|
+
// for more info
|
package/src/types/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
|
-
// #region
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
2
|
+
// #region auto-indexed files
|
|
3
|
+
// index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
|
|
4
|
+
// hash-code: fbd4603a
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./Api";
|
|
@@ -22,12 +22,12 @@ export * from "./Not";
|
|
|
22
22
|
export * from "./Numeric";
|
|
23
23
|
export * from "./Opaque";
|
|
24
24
|
export * from "./Retain";
|
|
25
|
+
export * from "./SimplifyObject";
|
|
25
26
|
export * from "./Transformer";
|
|
26
27
|
export * from "./TypeGuard";
|
|
27
28
|
export * from "./Where";
|
|
28
29
|
export * from "./append-types";
|
|
29
30
|
export * from "./maybe";
|
|
30
|
-
export * from "./props";
|
|
31
31
|
export * from "./ruleset-types";
|
|
32
32
|
export * from "./runtime";
|
|
33
33
|
export * from "./type-testing";
|
|
@@ -35,36 +35,14 @@ export * from "./type-testing";
|
|
|
35
35
|
export * from "./alphabetic/index";
|
|
36
36
|
export * from "./dictionary/index";
|
|
37
37
|
export * from "./fluent/index";
|
|
38
|
+
export * from "./functions/index";
|
|
38
39
|
export * from "./kv/index";
|
|
39
40
|
export * from "./lists/index";
|
|
40
41
|
export * from "./string-literals/index";
|
|
41
42
|
export * from "./tuples/index";
|
|
42
43
|
export * from "./type-conversion/index";
|
|
43
44
|
|
|
44
|
-
// #endregion
|
|
45
|
+
// #endregion auto-indexed files
|
|
45
46
|
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
// By default it assumes that exports are named exports but this can be changed by
|
|
50
|
-
// adding a modifier to the '// #autoindex' syntax:
|
|
51
|
-
//
|
|
52
|
-
// - autoindex:named same as default, exports "named symbols"
|
|
53
|
-
// - autoindex:default assumes each file is exporting a default export and
|
|
54
|
-
// converts the default export to the name of the file
|
|
55
|
-
// - autoindex:offset assumes files export "named symbols" but that each
|
|
56
|
-
// file's symbols should be offset by the file's name
|
|
57
|
-
//
|
|
58
|
-
// You may also exclude certain files or directories by adding it to the
|
|
59
|
-
// autoindex command. As an example:
|
|
60
|
-
//
|
|
61
|
-
// - autoindex:named, exclude: foo,bar,baz
|
|
62
|
-
//
|
|
63
|
-
// Inversely, if you state a file to be an "orphan" then autoindex files
|
|
64
|
-
// below this file will not reference this autoindex file:
|
|
65
|
-
//
|
|
66
|
-
// - autoindex:named, orphan
|
|
67
|
-
//
|
|
68
|
-
// All content outside the "// #region" section in this file will be
|
|
69
|
-
// preserved in situations where you need to do something paricularly awesome.
|
|
70
|
-
// Keep on being awesome.
|
|
47
|
+
// see https://github.com/inocan-group/do-devops/docs/autoindex.md
|
|
48
|
+
// for more info
|
package/src/types/kv/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
|
-
// #region
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
2
|
+
// #region auto-indexed files
|
|
3
|
+
// index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
|
|
4
|
+
// hash-code: 744ff3bf
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./DictFromKv";
|
|
@@ -9,30 +9,7 @@ export * from "./KeyValue";
|
|
|
9
9
|
export * from "./KvFrom";
|
|
10
10
|
export * from "./KvTuple";
|
|
11
11
|
|
|
12
|
-
// #endregion
|
|
12
|
+
// #endregion auto-indexed files
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// By default it assumes that exports are named exports but this can be changed by
|
|
18
|
-
// adding a modifier to the '// #autoindex' syntax:
|
|
19
|
-
//
|
|
20
|
-
// - autoindex:named same as default, exports "named symbols"
|
|
21
|
-
// - autoindex:default assumes each file is exporting a default export and
|
|
22
|
-
// converts the default export to the name of the file
|
|
23
|
-
// - autoindex:offset assumes files export "named symbols" but that each
|
|
24
|
-
// file's symbols should be offset by the file's name
|
|
25
|
-
//
|
|
26
|
-
// You may also exclude certain files or directories by adding it to the
|
|
27
|
-
// autoindex command. As an example:
|
|
28
|
-
//
|
|
29
|
-
// - autoindex:named, exclude: foo,bar,baz
|
|
30
|
-
//
|
|
31
|
-
// Inversely, if you state a file to be an "orphan" then autoindex files
|
|
32
|
-
// below this file will not reference this autoindex file:
|
|
33
|
-
//
|
|
34
|
-
// - autoindex:named, orphan
|
|
35
|
-
//
|
|
36
|
-
// All content outside the "// #region" section in this file will be
|
|
37
|
-
// preserved in situations where you need to do something paricularly awesome.
|
|
38
|
-
// Keep on being awesome.
|
|
14
|
+
// see https://github.com/inocan-group/do-devops/docs/autoindex.md
|
|
15
|
+
// for more info
|
package/src/types/lists/index.ts
CHANGED
|
@@ -1,36 +1,13 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
|
|
3
|
-
// #region
|
|
4
|
-
// index last changed at:
|
|
5
|
-
// hash-code:
|
|
3
|
+
// #region auto-indexed files
|
|
4
|
+
// index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
|
|
5
|
+
// hash-code: 582c0cf0
|
|
6
6
|
|
|
7
7
|
// file exports
|
|
8
8
|
export * from "./UniqueForProp";
|
|
9
9
|
|
|
10
|
-
// #endregion
|
|
10
|
+
// #endregion auto-indexed files
|
|
11
11
|
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// By default it assumes that exports are named exports but this can be changed by
|
|
16
|
-
// adding a modifier to the '// #autoindex' syntax:
|
|
17
|
-
//
|
|
18
|
-
// - autoindex:named same as default, exports "named symbols"
|
|
19
|
-
// - autoindex:default assumes each file is exporting a default export and
|
|
20
|
-
// converts the default export to the name of the file
|
|
21
|
-
// - autoindex:offset assumes files export "named symbols" but that each
|
|
22
|
-
// file's symbols should be offset by the file's name
|
|
23
|
-
//
|
|
24
|
-
// You may also exclude certain files or directories by adding it to the
|
|
25
|
-
// autoindex command. As an example:
|
|
26
|
-
//
|
|
27
|
-
// - autoindex:named, exclude: foo,bar,baz
|
|
28
|
-
//
|
|
29
|
-
// Inversely, if you state a file to be an "orphan" then autoindex files
|
|
30
|
-
// below this file will not reference this autoindex file:
|
|
31
|
-
//
|
|
32
|
-
// - autoindex:named, orphan
|
|
33
|
-
//
|
|
34
|
-
// All content outside the "// #region" section in this file will be
|
|
35
|
-
// preserved in situations where you need to do something paricularly awesome.
|
|
36
|
-
// Keep on being awesome.
|
|
12
|
+
// see https://github.com/inocan-group/do-devops/docs/autoindex.md
|
|
13
|
+
// for more info
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { OptionalKeys } from "./props";
|
|
3
|
-
import { SameKeys } from "./
|
|
1
|
+
import { TypeCondition } from "src/utility/runtime";
|
|
2
|
+
import { OptionalKeys } from "./dictionary/props";
|
|
3
|
+
import { SameKeys } from "./dictionary/SameKeys";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* **RuleDefinition**
|
package/src/types/runtime.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TypeGuard } from "~/types";
|
|
2
|
-
|
|
3
1
|
// runtime types relate to the types coming out of the runtime utilities
|
|
4
2
|
|
|
3
|
+
import { TypeGuard } from "./TypeGuard";
|
|
4
|
+
|
|
5
5
|
export type RuntimeType<T> = {
|
|
6
6
|
__kind: "type";
|
|
7
7
|
|
|
@@ -14,21 +14,21 @@ export type RuntimeProp<P extends Readonly<PropertyKey>, T extends RuntimeType<a
|
|
|
14
14
|
key: Readonly<P>;
|
|
15
15
|
valueType: Readonly<T["type"]>;
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
* Provides the _type_ to the type system when used with `typeof`.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* const t = number();
|
|
21
|
+
* // number
|
|
22
|
+
* type T = typeof t.type;
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* **Note:** _the runtime system will get a string equivalent name:_
|
|
26
|
+
* ```ts
|
|
27
|
+
* const t = number();
|
|
28
|
+
* // "number"
|
|
29
|
+
* console.log(t.type);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
32
|
type: Record<P, T["type"]>;
|
|
33
33
|
is: TypeGuard<Record<P, T["type"]>>;
|
|
34
34
|
};
|
|
@@ -36,4 +36,4 @@ export type RuntimeProp<P extends Readonly<PropertyKey>, T extends RuntimeType<a
|
|
|
36
36
|
export type TypeOptions<T extends Partial<object> = {}> = {
|
|
37
37
|
/** each type has a default type guard but you can override if you need to be more specific */
|
|
38
38
|
typeGuard?: TypeGuard<T>;
|
|
39
|
-
} & T;
|
|
39
|
+
} & T;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Replace } from "./Replace";
|
|
2
|
+
import { TrimLeft } from "./TrimLeft";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Provides the _left_ whitespace of a string
|
|
@@ -7,4 +8,6 @@ import type { Replace, TrimLeft } from "~/types";
|
|
|
7
8
|
* type T = LeftWhitespace<"\n\t foobar">;
|
|
8
9
|
* ```
|
|
9
10
|
*/
|
|
10
|
-
export type LeftWhitespace<S extends string> = string extends S
|
|
11
|
+
export type LeftWhitespace<S extends string> = string extends S
|
|
12
|
+
? string
|
|
13
|
+
: Replace<S, TrimLeft<S>, "">;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Replace } from "./Replace";
|
|
2
|
+
import { TrimRight } from "./TrimRight";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Provides the _left_ whitespace of a string
|
|
@@ -7,4 +8,6 @@ import type { Replace, TrimRight } from "~/types";
|
|
|
7
8
|
* type T = LeftWhitespace<"\n\t foobar">;
|
|
8
9
|
* ```
|
|
9
10
|
*/
|
|
10
|
-
export type RightWhitespace<S extends string> = string extends S
|
|
11
|
+
export type RightWhitespace<S extends string> = string extends S
|
|
12
|
+
? string
|
|
13
|
+
: Replace<S, TrimRight<S>, "">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
|
-
// #region
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
2
|
+
// #region auto-indexed files
|
|
3
|
+
// index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
|
|
4
|
+
// hash-code: d0cf1562
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./Break";
|
|
@@ -15,30 +15,7 @@ export * from "./TrimLeft";
|
|
|
15
15
|
export * from "./TrimRight";
|
|
16
16
|
export * from "./form-fields";
|
|
17
17
|
|
|
18
|
-
// #endregion
|
|
18
|
+
// #endregion auto-indexed files
|
|
19
19
|
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
// By default it assumes that exports are named exports but this can be changed by
|
|
24
|
-
// adding a modifier to the '// #autoindex' syntax:
|
|
25
|
-
//
|
|
26
|
-
// - autoindex:named same as default, exports "named symbols"
|
|
27
|
-
// - autoindex:default assumes each file is exporting a default export and
|
|
28
|
-
// converts the default export to the name of the file
|
|
29
|
-
// - autoindex:offset assumes files export "named symbols" but that each
|
|
30
|
-
// file's symbols should be offset by the file's name
|
|
31
|
-
//
|
|
32
|
-
// You may also exclude certain files or directories by adding it to the
|
|
33
|
-
// autoindex command. As an example:
|
|
34
|
-
//
|
|
35
|
-
// - autoindex:named, exclude: foo,bar,baz
|
|
36
|
-
//
|
|
37
|
-
// Inversely, if you state a file to be an "orphan" then autoindex files
|
|
38
|
-
// below this file will not reference this autoindex file:
|
|
39
|
-
//
|
|
40
|
-
// - autoindex:named, orphan
|
|
41
|
-
//
|
|
42
|
-
// All content outside the "// #region" section in this file will be
|
|
43
|
-
// preserved in situations where you need to do something paricularly awesome.
|
|
44
|
-
// Keep on being awesome.
|
|
20
|
+
// see https://github.com/inocan-group/do-devops/docs/autoindex.md
|
|
21
|
+
// for more info
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Keys } from "../Keys";
|
|
2
|
+
import { UnionToTuple } from "../type-conversion/UnionToTuple";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Returns the _first_ key in an object.
|
|
5
|
-
*
|
|
6
|
+
*
|
|
6
7
|
* **Note:** key order is not guarenteed so typically this is used
|
|
7
8
|
* for a key/value pair where only one key is expected
|
|
8
9
|
*/
|
|
9
10
|
export type FirstKey<T extends object> = UnionToTuple<Keys<T>>[0];
|
|
10
|
-
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExpandRecursively
|
|
2
|
-
|
|
1
|
+
import { ExpandRecursively } from "../ExpandRecursively";
|
|
2
|
+
import { UnionToIntersection } from "../type-conversion";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Typescript utility which receives `T` as shape which resembles `DictArray<D>`
|
|
@@ -9,5 +9,6 @@ import { ExpandRecursively, UnionToIntersection } from "~/types";
|
|
|
9
9
|
* type Dict = FromDictArray<[["foo", { foo: 1 }], ["bar", { bar: "hi" }]]>;
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
|
-
export type FromDictArray<T extends [string, Record<string, unknown>][]> =
|
|
13
|
-
|
|
12
|
+
export type FromDictArray<T extends [string, Record<string, unknown>][]> = ExpandRecursively<
|
|
13
|
+
UnionToIntersection<T[number][1]>
|
|
14
|
+
>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
|
-
// #region
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
2
|
+
// #region auto-indexed files
|
|
3
|
+
// index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
|
|
4
|
+
// hash-code: 582cd3f6
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./DictArray";
|
|
@@ -11,30 +11,7 @@ export * from "./FirstOfEach";
|
|
|
11
11
|
export * from "./FromDictArray";
|
|
12
12
|
export * from "./SecondOfEach";
|
|
13
13
|
|
|
14
|
-
// #endregion
|
|
14
|
+
// #endregion auto-indexed files
|
|
15
15
|
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// By default it assumes that exports are named exports but this can be changed by
|
|
20
|
-
// adding a modifier to the '// #autoindex' syntax:
|
|
21
|
-
//
|
|
22
|
-
// - autoindex:named same as default, exports "named symbols"
|
|
23
|
-
// - autoindex:default assumes each file is exporting a default export and
|
|
24
|
-
// converts the default export to the name of the file
|
|
25
|
-
// - autoindex:offset assumes files export "named symbols" but that each
|
|
26
|
-
// file's symbols should be offset by the file's name
|
|
27
|
-
//
|
|
28
|
-
// You may also exclude certain files or directories by adding it to the
|
|
29
|
-
// autoindex command. As an example:
|
|
30
|
-
//
|
|
31
|
-
// - autoindex:named, exclude: foo,bar,baz
|
|
32
|
-
//
|
|
33
|
-
// Inversely, if you state a file to be an "orphan" then autoindex files
|
|
34
|
-
// below this file will not reference this autoindex file:
|
|
35
|
-
//
|
|
36
|
-
// - autoindex:named, orphan
|
|
37
|
-
//
|
|
38
|
-
// All content outside the "// #region" section in this file will be
|
|
39
|
-
// preserved in situations where you need to do something paricularly awesome.
|
|
40
|
-
// Keep on being awesome.
|
|
16
|
+
// see https://github.com/inocan-group/do-devops/docs/autoindex.md
|
|
17
|
+
// for more info
|
|
@@ -1,41 +1,15 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
|
|
3
|
-
// #region
|
|
4
|
-
// index last changed at:
|
|
5
|
-
// hash-code:
|
|
3
|
+
// #region auto-indexed files
|
|
4
|
+
// index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
|
|
5
|
+
// hash-code: 200001fa
|
|
6
6
|
|
|
7
7
|
// file exports
|
|
8
|
-
export * from "./SameKeys";
|
|
9
8
|
export * from "./TupleToUnion";
|
|
10
9
|
export * from "./UnionToIntersection";
|
|
11
10
|
export * from "./UnionToTuple";
|
|
12
|
-
export * from "./UnwrapValue";
|
|
13
|
-
export * from "./WrapValue";
|
|
14
11
|
|
|
15
|
-
// #endregion
|
|
12
|
+
// #endregion auto-indexed files
|
|
16
13
|
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// By default it assumes that exports are named exports but this can be changed by
|
|
21
|
-
// adding a modifier to the '// #autoindex' syntax:
|
|
22
|
-
//
|
|
23
|
-
// - autoindex:named same as default, exports "named symbols"
|
|
24
|
-
// - autoindex:default assumes each file is exporting a default export and
|
|
25
|
-
// converts the default export to the name of the file
|
|
26
|
-
// - autoindex:offset assumes files export "named symbols" but that each
|
|
27
|
-
// file's symbols should be offset by the file's name
|
|
28
|
-
//
|
|
29
|
-
// You may also exclude certain files or directories by adding it to the
|
|
30
|
-
// autoindex command. As an example:
|
|
31
|
-
//
|
|
32
|
-
// - autoindex:named, exclude: foo,bar,baz
|
|
33
|
-
//
|
|
34
|
-
// Inversely, if you state a file to be an "orphan" then autoindex files
|
|
35
|
-
// below this file will not reference this autoindex file:
|
|
36
|
-
//
|
|
37
|
-
// - autoindex:named, orphan
|
|
38
|
-
//
|
|
39
|
-
// All content outside the "// #region" section in this file will be
|
|
40
|
-
// preserved in situations where you need to do something paricularly awesome.
|
|
41
|
-
// Keep on being awesome.
|
|
14
|
+
// see https://github.com/inocan-group/do-devops/docs/autoindex.md
|
|
15
|
+
// for more info
|
package/src/utility/api/api.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Narrowable } from "
|
|
1
|
+
import { Narrowable } from "src/types/Narrowable";
|
|
2
2
|
|
|
3
|
-
export const api =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
3
|
+
export const api =
|
|
4
|
+
<N extends Narrowable, TPrivate extends Readonly<Record<any, N>>>(priv: TPrivate) =>
|
|
5
|
+
<TPublic extends object>(pub: TPublic) => {
|
|
6
|
+
const surface = () => pub as TPublic;
|
|
7
|
+
surface.prototype.priv = () => priv as TPrivate;
|
|
9
8
|
|
|
9
|
+
return surface;
|
|
10
|
+
};
|
package/src/utility/api/index.ts
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
// #autoindex
|
|
2
|
-
// #region
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
2
|
+
// #region auto-indexed files
|
|
3
|
+
// index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
|
|
4
|
+
// hash-code: 57c2f8db
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./api";
|
|
8
8
|
|
|
9
|
-
// #endregion
|
|
9
|
+
// #endregion auto-indexed files
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// By default it assumes that exports are named exports but this can be changed by
|
|
15
|
-
// adding a modifier to the '// #autoindex' syntax:
|
|
16
|
-
//
|
|
17
|
-
// - autoindex:named same as default, exports "named symbols"
|
|
18
|
-
// - autoindex:default assumes each file is exporting a default export and
|
|
19
|
-
// converts the default export to the name of the file
|
|
20
|
-
// - autoindex:offset assumes files export "named symbols" but that each
|
|
21
|
-
// file's symbols should be offset by the file's name
|
|
22
|
-
//
|
|
23
|
-
// You may also exclude certain files or directories by adding it to the
|
|
24
|
-
// autoindex command. As an example:
|
|
25
|
-
//
|
|
26
|
-
// - autoindex:named, exclude: foo,bar,baz
|
|
27
|
-
//
|
|
28
|
-
// Inversely, if you state a file to be an "orphan" then autoindex files
|
|
29
|
-
// below this file will not reference this autoindex file:
|
|
30
|
-
//
|
|
31
|
-
// - autoindex:named, orphan
|
|
32
|
-
//
|
|
33
|
-
// All content outside the "// #region" section in this file will be
|
|
34
|
-
// preserved in situations where you need to do something paricularly awesome.
|
|
35
|
-
// Keep on being awesome.
|
|
11
|
+
// see https://github.com/inocan-group/do-devops/docs/autoindex.md
|
|
12
|
+
// for more info
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface DefinePropertiesApi<T extends {}> {
|
|
2
|
+
/**
|
|
3
|
+
* Makes a property on the object **readonly** on the Javascript runtime
|
|
4
|
+
*/
|
|
5
|
+
ro<K extends keyof T>(
|
|
6
|
+
prop: K,
|
|
7
|
+
errorMsg?: (p: K, v: any) => string
|
|
8
|
+
): Omit<T, K> & Record<K, Readonly<T[K]>>;
|
|
9
|
+
/**
|
|
10
|
+
* Makes a property on the object **read/writeable** on the Javascript runtime;
|
|
11
|
+
* this is the default so only use this where it is needed.
|
|
12
|
+
*/
|
|
13
|
+
rw<K extends keyof T>(prop: K): Omit<T, K> & Record<K, Readonly<T[K]>>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function defineProperties<T extends {}>(obj: T) {
|
|
17
|
+
return {
|
|
18
|
+
ro(prop, errorMsg) {
|
|
19
|
+
Object.defineProperty(obj, prop, {
|
|
20
|
+
writable: false,
|
|
21
|
+
set(v: any) {
|
|
22
|
+
const message = errorMsg
|
|
23
|
+
? errorMsg(prop, v)
|
|
24
|
+
: `The ${String(
|
|
25
|
+
prop
|
|
26
|
+
)} is readonly but an attempt was made to change it's value to "${JSON.stringify(
|
|
27
|
+
v
|
|
28
|
+
)}"!`;
|
|
29
|
+
throw new Error(message);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return obj;
|
|
33
|
+
},
|
|
34
|
+
} as DefinePropertiesApi<T>;
|
|
35
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-use-before-define */
|
|
2
|
-
|
|
3
|
-
import { SameKeys
|
|
2
|
+
|
|
3
|
+
import { SameKeys } from "src/types/dictionary";
|
|
4
|
+
import { Transformer } from "src/types/Transformer";
|
|
5
|
+
import { keys } from "../keys";
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Takes a dictionary of type `I` and converts it to a dictionary of type `O` where
|
|
@@ -13,9 +15,8 @@ export function dictionaryTransform<I extends object, O extends SameKeys<I>>(
|
|
|
13
15
|
input: I,
|
|
14
16
|
transform: Transformer<I, O>
|
|
15
17
|
) {
|
|
16
|
-
|
|
17
18
|
return keys(input).reduce((acc, i) => {
|
|
18
19
|
const key = i as string & keyof I;
|
|
19
|
-
return {...acc, [key]: transform(input, key)};
|
|
20
|
+
return { ...acc, [key]: transform(input, key) };
|
|
20
21
|
}, {} as O);
|
|
21
22
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { KeyValue
|
|
1
|
+
import { KeyValue } from "src/types/kv";
|
|
2
|
+
import { Narrowable } from "src/types/Narrowable";
|
|
2
3
|
import { keys } from "../keys";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* **entries**
|
|
6
7
|
*
|
|
7
|
-
* Provides an
|
|
8
|
+
* Provides an _iterable_ over the passed in dictionary object where each iteration
|
|
8
9
|
* provides a tuple of `[ key, value ]` which preserve type literals.
|
|
9
10
|
*
|
|
10
11
|
* For example:
|
|
@@ -14,8 +15,11 @@ import { keys } from "../keys";
|
|
|
14
15
|
* for (const [k, v] of entries(obj)) { ... }
|
|
15
16
|
* ```
|
|
16
17
|
*/
|
|
17
|
-
export function entries<
|
|
18
|
-
|
|
18
|
+
export function entries<
|
|
19
|
+
N extends Narrowable,
|
|
20
|
+
T extends Record<string, N>,
|
|
21
|
+
I extends KeyValue<T, keyof T>
|
|
22
|
+
>(obj: T) {
|
|
19
23
|
const iterable = {
|
|
20
24
|
*[Symbol.iterator]() {
|
|
21
25
|
for (const k of keys(obj)) {
|
|
@@ -26,4 +30,4 @@ export function entries<N extends Narrowable, T extends Record<string, N>, I ext
|
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
return iterable;
|
|
29
|
-
}
|
|
33
|
+
}
|
|
@@ -1,42 +1,19 @@
|
|
|
1
1
|
// #autoindex
|
|
2
|
-
// #region
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
2
|
+
// #region auto-indexed files
|
|
3
|
+
// index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
|
|
4
|
+
// hash-code: b0051c37
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./arrayToKeyLookup";
|
|
8
|
+
export * from "./defineProperties";
|
|
8
9
|
export * from "./dictionaryTransform";
|
|
9
10
|
export * from "./entries";
|
|
10
11
|
export * from "./mapValues";
|
|
11
12
|
export * from "./strArrayToDict";
|
|
12
|
-
export * from "./valuesOfProp";
|
|
13
13
|
// directory exports
|
|
14
14
|
export * from "./kv/index";
|
|
15
15
|
|
|
16
|
-
// #endregion
|
|
16
|
+
// #endregion auto-indexed files
|
|
17
17
|
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
// By default it assumes that exports are named exports but this can be changed by
|
|
22
|
-
// adding a modifier to the '// #autoindex' syntax:
|
|
23
|
-
//
|
|
24
|
-
// - autoindex:named same as default, exports "named symbols"
|
|
25
|
-
// - autoindex:default assumes each file is exporting a default export and
|
|
26
|
-
// converts the default export to the name of the file
|
|
27
|
-
// - autoindex:offset assumes files export "named symbols" but that each
|
|
28
|
-
// file's symbols should be offset by the file's name
|
|
29
|
-
//
|
|
30
|
-
// You may also exclude certain files or directories by adding it to the
|
|
31
|
-
// autoindex command. As an example:
|
|
32
|
-
//
|
|
33
|
-
// - autoindex:named, exclude: foo,bar,baz
|
|
34
|
-
//
|
|
35
|
-
// Inversely, if you state a file to be an "orphan" then autoindex files
|
|
36
|
-
// below this file will not reference this autoindex file:
|
|
37
|
-
//
|
|
38
|
-
// - autoindex:named, orphan
|
|
39
|
-
//
|
|
40
|
-
// All content outside the "// #region" section in this file will be
|
|
41
|
-
// preserved in situations where you need to do something paricularly awesome.
|
|
42
|
-
// Keep on being awesome.
|
|
18
|
+
// see https://github.com/inocan-group/do-devops/docs/autoindex.md
|
|
19
|
+
// for more info
|