@jonloucks/variants-ts 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,6 +21,7 @@ import { SourceFactory } from "@jonloucks/variants-ts/api/SourceFactory";
|
|
|
21
21
|
import { ValueType } from "@jonloucks/variants-ts/api/Types";
|
|
22
22
|
import { Variant, Config as VariantConfig } from "@jonloucks/variants-ts/api/Variant";
|
|
23
23
|
import { VariantFactory } from "@jonloucks/variants-ts/api/VariantFactory";
|
|
24
|
+
import { Transform } from "@jonloucks/contracts-ts/auxiliary/Transform";
|
|
24
25
|
/**
|
|
25
26
|
* Creates a variant based on the provided configuration.
|
|
26
27
|
*
|
|
@@ -72,5 +73,84 @@ declare function createRecordSource(record: Record<string, ValueType>): Required
|
|
|
72
73
|
* @returns a Source instance that retrieves values from the process environment variables
|
|
73
74
|
*/
|
|
74
75
|
declare function createProcessSource(): RequiredType<Source>;
|
|
75
|
-
|
|
76
|
+
/**
|
|
77
|
+
* @returns a parser that converts a valid text into a String
|
|
78
|
+
*/
|
|
79
|
+
declare function stringParser(): Transform<ValueType, string>;
|
|
80
|
+
/**
|
|
81
|
+
* No trimming or skipping empty values
|
|
82
|
+
* @returns a text conversion to a String instance
|
|
83
|
+
*/
|
|
84
|
+
declare function ofRawString(): Transform<OptionalType<ValueType>, OptionalType<string>>;
|
|
85
|
+
/**
|
|
86
|
+
* Input is trimmed and empty values are skipped
|
|
87
|
+
*
|
|
88
|
+
* @returns a text conversion to a String instance
|
|
89
|
+
*/
|
|
90
|
+
declare function ofString(): Transform<OptionalType<ValueType>, OptionalType<string>>;
|
|
91
|
+
/**
|
|
92
|
+
* @returns a parser that converts a valid text value into a Boolean instance
|
|
93
|
+
*/
|
|
94
|
+
declare function booleanParser(): Transform<RequiredType<ValueType>, RequiredType<boolean>>;
|
|
95
|
+
/**
|
|
96
|
+
* Input is trimmed and empty values are skipped
|
|
97
|
+
*
|
|
98
|
+
* @returns a text conversion to a Boolean instance
|
|
99
|
+
*/
|
|
100
|
+
declare function ofBoolean(): Transform<OptionalType<ValueType>, OptionalType<boolean>>;
|
|
101
|
+
/**
|
|
102
|
+
* @returns a parser that converts a valid text value into a Float instance
|
|
103
|
+
*/
|
|
104
|
+
declare function numberParser(): Transform<RequiredType<ValueType>, RequiredType<number>>;
|
|
105
|
+
/**
|
|
106
|
+
* Input is trimmed and empty values are skipped
|
|
107
|
+
*
|
|
108
|
+
* @returns a text conversion to a Float instance
|
|
109
|
+
*/
|
|
110
|
+
declare function ofNumber(): Transform<OptionalType<ValueType>, OptionalType<number>>;
|
|
111
|
+
/**
|
|
112
|
+
* @returns a parser that converts a valid text value into a BigInt instance
|
|
113
|
+
*/
|
|
114
|
+
declare function bigIntParser(): Transform<RequiredType<ValueType>, RequiredType<bigint>>;
|
|
115
|
+
/**
|
|
116
|
+
* Input is trimmed and empty values are skipped
|
|
117
|
+
*
|
|
118
|
+
* @returns a text conversion to a BigInt instance
|
|
119
|
+
*/
|
|
120
|
+
declare function ofBigInt(): Transform<OptionalType<ValueType>, OptionalType<bigint>>;
|
|
121
|
+
/**
|
|
122
|
+
* trim leading and trailing white space
|
|
123
|
+
*
|
|
124
|
+
* @param text the text to trim
|
|
125
|
+
* @returns the trimmed text
|
|
126
|
+
*/
|
|
127
|
+
declare function trim(text: RequiredType<ValueType>): RequiredType<ValueType>;
|
|
128
|
+
/**
|
|
129
|
+
* A parser that converts text to a String
|
|
130
|
+
*
|
|
131
|
+
* @param parser the parser that accepts the String
|
|
132
|
+
* @returns the new parser
|
|
133
|
+
* @param <T> the return type of the given parser
|
|
134
|
+
*/
|
|
135
|
+
declare function string<T>(parser: Transform<string, T>): Transform<ValueType, T>;
|
|
136
|
+
/**
|
|
137
|
+
* Text to parser helper.
|
|
138
|
+
* Trims text
|
|
139
|
+
* Skips empty values
|
|
140
|
+
*
|
|
141
|
+
* @param parser the delegate parser
|
|
142
|
+
* @returns the new 'of' function
|
|
143
|
+
* @param <T> the return type of the given parser
|
|
144
|
+
*/
|
|
145
|
+
declare function ofTrimAndSkipEmpty<T>(parser: Transform<ValueType, T>): Transform<ValueType, OptionalType<T>>;
|
|
146
|
+
/**
|
|
147
|
+
* Split the input text and parse each part into a list
|
|
148
|
+
*
|
|
149
|
+
* @param of the delegate text to value function
|
|
150
|
+
* @param delimiter the string delimiter.
|
|
151
|
+
* @returns the new parser
|
|
152
|
+
* @param <T> the return type of the given parser
|
|
153
|
+
*/
|
|
154
|
+
declare function ofList<T>(of: Transform<ValueType, OptionalType<T>>, delimiter: string): Transform<ValueType, OptionalType<Array<T>>>;
|
|
155
|
+
export { CONTRACTS, createEnvironment, createKeySource, createLookupSource, createMapSource, createProcessSource, createRecordSource, createVariant, VERSION, type Environment, type EnvironmentConfig, type EnvironmentFactory, type OptionalType, type RequiredType, type Source, type SourceFactory, type SupplierType, type ValueType, type Variant, type VariantConfig, type VariantFactory, type Transform, stringParser, ofRawString, ofString, booleanParser, ofBoolean, numberParser, ofNumber, bigIntParser, ofBigInt, trim, string, ofTrimAndSkipEmpty, ofList };
|
|
76
156
|
//# sourceMappingURL=Convenience.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Convenience.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAClG,OAAO,EAA4C,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAC7H,OAAO,EAAE,MAAM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AAkB,EAClB,aAAa,EACb,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,kBAAkB,EAClB,MAAM,EACP,CAAC"}
|
package/auxiliary/Convenience.js
CHANGED
|
@@ -15,9 +15,11 @@ import { VERSION } from "@jonloucks/variants-ts";
|
|
|
15
15
|
import { CONTRACT as ENVIRONMENT_FACTORY_CONTRACT } from "@jonloucks/variants-ts/api/EnvironmentFactory";
|
|
16
16
|
import { CONTRACT as SOURCE_FACTORY_CONTRACT } from "@jonloucks/variants-ts/api/SourceFactory";
|
|
17
17
|
import { CONTRACT as VARIANT_FACTORY_CONTRACT } from "@jonloucks/variants-ts/api/VariantFactory";
|
|
18
|
+
import { CONTRACT as PARSER_FACTORY_CONTRACT } from "@jonloucks/variants-ts/api/ParserFactory";
|
|
18
19
|
const ENVIRONMENT_FACTORY = CONTRACTS.enforce(ENVIRONMENT_FACTORY_CONTRACT);
|
|
19
20
|
const VARIANT_FACTORY = CONTRACTS.enforce(VARIANT_FACTORY_CONTRACT);
|
|
20
21
|
const SOURCE_FACTORY = CONTRACTS.enforce(SOURCE_FACTORY_CONTRACT);
|
|
22
|
+
const PARSER_FACTORY = CONTRACTS.enforce(PARSER_FACTORY_CONTRACT);
|
|
21
23
|
/**
|
|
22
24
|
* Creates a variant based on the provided configuration.
|
|
23
25
|
*
|
|
@@ -83,5 +85,110 @@ function createRecordSource(record) {
|
|
|
83
85
|
function createProcessSource() {
|
|
84
86
|
return SOURCE_FACTORY.createProcessSource();
|
|
85
87
|
}
|
|
86
|
-
|
|
88
|
+
/**
|
|
89
|
+
* @returns a parser that converts a valid text into a String
|
|
90
|
+
*/
|
|
91
|
+
function stringParser() {
|
|
92
|
+
return PARSER_FACTORY.stringParser();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* No trimming or skipping empty values
|
|
96
|
+
* @returns a text conversion to a String instance
|
|
97
|
+
*/
|
|
98
|
+
function ofRawString() {
|
|
99
|
+
return PARSER_FACTORY.ofRawString();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Input is trimmed and empty values are skipped
|
|
103
|
+
*
|
|
104
|
+
* @returns a text conversion to a String instance
|
|
105
|
+
*/
|
|
106
|
+
function ofString() {
|
|
107
|
+
return PARSER_FACTORY.ofString();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @returns a parser that converts a valid text value into a Boolean instance
|
|
111
|
+
*/
|
|
112
|
+
function booleanParser() {
|
|
113
|
+
return PARSER_FACTORY.booleanParser();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Input is trimmed and empty values are skipped
|
|
117
|
+
*
|
|
118
|
+
* @returns a text conversion to a Boolean instance
|
|
119
|
+
*/
|
|
120
|
+
function ofBoolean() {
|
|
121
|
+
return PARSER_FACTORY.ofBoolean();
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @returns a parser that converts a valid text value into a Float instance
|
|
125
|
+
*/
|
|
126
|
+
function numberParser() {
|
|
127
|
+
return PARSER_FACTORY.numberParser();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Input is trimmed and empty values are skipped
|
|
131
|
+
*
|
|
132
|
+
* @returns a text conversion to a Float instance
|
|
133
|
+
*/
|
|
134
|
+
function ofNumber() {
|
|
135
|
+
return PARSER_FACTORY.ofNumber();
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @returns a parser that converts a valid text value into a BigInt instance
|
|
139
|
+
*/
|
|
140
|
+
function bigIntParser() {
|
|
141
|
+
return PARSER_FACTORY.bigIntParser();
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Input is trimmed and empty values are skipped
|
|
145
|
+
*
|
|
146
|
+
* @returns a text conversion to a BigInt instance
|
|
147
|
+
*/
|
|
148
|
+
function ofBigInt() {
|
|
149
|
+
return PARSER_FACTORY.ofBigInt();
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* trim leading and trailing white space
|
|
153
|
+
*
|
|
154
|
+
* @param text the text to trim
|
|
155
|
+
* @returns the trimmed text
|
|
156
|
+
*/
|
|
157
|
+
function trim(text) {
|
|
158
|
+
return PARSER_FACTORY.trim(text);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* A parser that converts text to a String
|
|
162
|
+
*
|
|
163
|
+
* @param parser the parser that accepts the String
|
|
164
|
+
* @returns the new parser
|
|
165
|
+
* @param <T> the return type of the given parser
|
|
166
|
+
*/
|
|
167
|
+
function string(parser) {
|
|
168
|
+
return PARSER_FACTORY.string(parser);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Text to parser helper.
|
|
172
|
+
* Trims text
|
|
173
|
+
* Skips empty values
|
|
174
|
+
*
|
|
175
|
+
* @param parser the delegate parser
|
|
176
|
+
* @returns the new 'of' function
|
|
177
|
+
* @param <T> the return type of the given parser
|
|
178
|
+
*/
|
|
179
|
+
function ofTrimAndSkipEmpty(parser) {
|
|
180
|
+
return PARSER_FACTORY.ofTrimAndSkipEmpty(parser);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Split the input text and parse each part into a list
|
|
184
|
+
*
|
|
185
|
+
* @param of the delegate text to value function
|
|
186
|
+
* @param delimiter the string delimiter.
|
|
187
|
+
* @returns the new parser
|
|
188
|
+
* @param <T> the return type of the given parser
|
|
189
|
+
*/
|
|
190
|
+
function ofList(of, delimiter) {
|
|
191
|
+
return PARSER_FACTORY.ofList(of, delimiter);
|
|
192
|
+
}
|
|
193
|
+
export { CONTRACTS, createEnvironment, createKeySource, createLookupSource, createMapSource, createProcessSource, createRecordSource, createVariant, VERSION, stringParser, ofRawString, ofString, booleanParser, ofBoolean, numberParser, ofNumber, bigIntParser, ofBigInt, trim, string, ofTrimAndSkipEmpty, ofList };
|
|
87
194
|
//# sourceMappingURL=Convenience.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Convenience.js","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,QAAQ,IAAI,4BAA4B,EAAsB,MAAM,+CAA+C,CAAC;AAE7H,OAAO,EAAE,QAAQ,IAAI,uBAAuB,EAAiB,MAAM,0CAA0C,CAAC;AAG9G,OAAO,EAAE,QAAQ,IAAI,wBAAwB,EAAkB,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"Convenience.js","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,QAAQ,IAAI,4BAA4B,EAAsB,MAAM,+CAA+C,CAAC;AAE7H,OAAO,EAAE,QAAQ,IAAI,uBAAuB,EAAiB,MAAM,0CAA0C,CAAC;AAG9G,OAAO,EAAE,QAAQ,IAAI,wBAAwB,EAAkB,MAAM,2CAA2C,CAAC;AACjH,OAAO,EAAE,QAAQ,IAAI,uBAAuB,EAAiB,MAAM,0CAA0C,CAAC;AAG9G,MAAM,mBAAmB,GAAqC,SAAS,CAAC,OAAO,CAAC,4BAA4B,CAAC,C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AS,EACT,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,kBAAkB,EAClB,MAAM,EACP,CAAC"}
|
package/impl/Variant.impl.js
CHANGED
|
@@ -21,7 +21,6 @@ export function create(config) {
|
|
|
21
21
|
return VariantImpl.createInternal(config);
|
|
22
22
|
}
|
|
23
23
|
;
|
|
24
|
-
// ---- Implementation details below ----
|
|
25
24
|
class VariantImpl {
|
|
26
25
|
get keys() {
|
|
27
26
|
return __classPrivateFieldGet(this, _VariantImpl_keys, "f");
|
|
@@ -69,23 +68,17 @@ function compileOf(config) {
|
|
|
69
68
|
return fromType(config.of);
|
|
70
69
|
}
|
|
71
70
|
else if (isPresent(config.parser)) {
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return compilePassThru();
|
|
76
|
-
}
|
|
77
|
-
function compileUsingParser() {
|
|
78
|
-
const parserTransform = fromType(config.parser);
|
|
71
|
+
const parseValue = fromType(config.parser);
|
|
79
72
|
return {
|
|
80
73
|
transform: (input) => {
|
|
81
74
|
if (isPresent(input)) {
|
|
82
|
-
return
|
|
75
|
+
return parseValue.transform(input);
|
|
83
76
|
}
|
|
84
77
|
return input;
|
|
85
78
|
}
|
|
86
79
|
};
|
|
87
80
|
}
|
|
88
|
-
|
|
81
|
+
else {
|
|
89
82
|
return {
|
|
90
83
|
transform: (input) => {
|
|
91
84
|
return input;
|
package/impl/Variant.impl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Variant.impl.js","sourceRoot":"","sources":["../../src/impl/Variant.impl.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAA6C,MAAM,mCAAmC,CAAC;AACzG,OAAO,EAAE,QAAQ,EAAa,MAAM,6CAA6C,CAAC;AAIlF;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAI,MAAyB;IACjD,OAAO,WAAW,CAAC,cAAc,CAAC,M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1.1.0",
|
|
4
4
|
"description": "Node.js Typescript Configuration Library, normalize how configuration is loaded from various sources is retrieved.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"build": "tsc",
|
|
38
38
|
"test": "tsx --test $(find src -name '*.test.ts')",
|
|
39
39
|
"test:watch": "tsx --test --watch $(find src -name '*.test.ts')",
|
|
40
|
-
"test:coverage": "npx c8 --check-coverage --lines 95 --functions 95 --branches
|
|
40
|
+
"test:coverage": "npx c8 --check-coverage --lines 95 --functions 95 --branches 95 --statements 95 --reporter=lcov npx tsx --test $(find src -name '*.test.ts')",
|
|
41
41
|
"lint": "eslint . --ext .ts",
|
|
42
42
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
43
43
|
"prepublishOnly": "npm run build",
|
package/version.js
CHANGED