@adobe/alloy 2.17.0 → 2.18.0-beta.1
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/libEs5/components/ActivityCollector/configValidators.js +9 -5
- package/libEs5/components/ActivityCollector/utils.js +22 -3
- package/libEs5/components/Audiences/index.js +0 -1
- package/libEs5/components/Context/index.js +2 -2
- package/libEs5/components/DataCollector/index.js +1 -2
- package/libEs5/components/EventMerge/index.js +0 -1
- package/libEs5/components/Identity/configValidators.js +2 -2
- package/libEs5/components/Identity/getIdentity/createGetIdentity.js +8 -5
- package/libEs5/components/Identity/getIdentity/createIdentityRequest.js +5 -2
- package/libEs5/components/MachineLearning/index.js +0 -1
- package/libEs5/components/Personalization/index.js +2 -2
- package/libEs5/components/Privacy/createConsentRequest.js +5 -2
- package/libEs5/components/Privacy/injectSendSetConsentRequest.js +10 -6
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/buildAndValidateConfig.js +79 -26
- package/libEs5/core/config/createCoreConfigs.js +3 -3
- package/libEs5/core/createEventManager.js +15 -6
- package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
- package/libEs5/utils/request/createDataCollectionRequest.js +10 -6
- package/libEs5/utils/request/createRequest.js +5 -1
- package/libEs5/utils/request/createRequestParams.js +53 -0
- package/libEs5/utils/request/index.js +8 -0
- package/libEs5/utils/validation/booleanValidator.js +2 -2
- package/libEs5/utils/validation/callbackValidator.js +2 -2
- package/libEs5/utils/validation/createAnyOfValidator.js +8 -5
- package/libEs5/utils/validation/createArrayOfValidator.js +6 -4
- package/libEs5/utils/validation/createDeprecatedValidator.js +53 -0
- package/libEs5/utils/validation/createLiteralValidator.js +2 -2
- package/libEs5/utils/validation/createMapOfValuesValidator.js +6 -4
- package/libEs5/utils/validation/createMinimumValidator.js +2 -2
- package/libEs5/utils/validation/createNonEmptyValidator.js +3 -3
- package/libEs5/utils/validation/createObjectOfValidator.js +6 -4
- package/libEs5/utils/validation/createUniqueItemsValidator.js +2 -2
- package/libEs5/utils/validation/createUniqueValidator.js +2 -2
- package/libEs5/utils/validation/domainValidator.js +2 -2
- package/libEs5/utils/validation/index.js +54 -45
- package/libEs5/utils/validation/integerValidator.js +2 -2
- package/libEs5/utils/validation/numberValidator.js +2 -2
- package/libEs5/utils/validation/regexpValidator.js +2 -2
- package/libEs5/utils/validation/stringValidator.js +2 -2
- package/libEs5/utils/validation/utils.js +155 -0
- package/libEs6/components/ActivityCollector/configValidators.js +6 -5
- package/libEs6/components/ActivityCollector/utils.js +20 -3
- package/libEs6/components/Audiences/index.js +0 -1
- package/libEs6/components/Context/index.js +3 -3
- package/libEs6/components/DataCollector/index.js +1 -2
- package/libEs6/components/EventMerge/index.js +0 -1
- package/libEs6/components/Identity/configValidators.js +3 -3
- package/libEs6/components/Identity/getIdentity/createGetIdentity.js +7 -5
- package/libEs6/components/Identity/getIdentity/createIdentityRequest.js +6 -2
- package/libEs6/components/MachineLearning/index.js +0 -1
- package/libEs6/components/Personalization/index.js +3 -3
- package/libEs6/components/Privacy/createConsentRequest.js +6 -2
- package/libEs6/components/Privacy/injectSendSetConsentRequest.js +9 -6
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/buildAndValidateConfig.js +48 -19
- package/libEs6/core/config/createCoreConfigs.js +4 -4
- package/libEs6/core/createEventManager.js +14 -6
- package/libEs6/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
- package/libEs6/utils/request/createDataCollectionRequest.js +6 -2
- package/libEs6/utils/request/createRequest.js +6 -1
- package/libEs6/utils/request/createRequestParams.js +43 -0
- package/libEs6/utils/request/index.js +1 -0
- package/libEs6/utils/validation/booleanValidator.js +1 -1
- package/libEs6/utils/validation/callbackValidator.js +1 -1
- package/libEs6/utils/validation/createAnyOfValidator.js +5 -4
- package/libEs6/utils/validation/createArrayOfValidator.js +3 -3
- package/libEs6/utils/validation/createDeprecatedValidator.js +41 -0
- package/libEs6/utils/validation/createLiteralValidator.js +1 -1
- package/libEs6/utils/validation/createMapOfValuesValidator.js +3 -3
- package/libEs6/utils/validation/createMinimumValidator.js +1 -1
- package/libEs6/utils/validation/createNonEmptyValidator.js +1 -1
- package/libEs6/utils/validation/createObjectOfValidator.js +3 -3
- package/libEs6/utils/validation/createUniqueItemsValidator.js +1 -1
- package/libEs6/utils/validation/createUniqueValidator.js +1 -1
- package/libEs6/utils/validation/domainValidator.js +1 -1
- package/libEs6/utils/validation/index.js +84 -13
- package/libEs6/utils/validation/integerValidator.js +1 -1
- package/libEs6/utils/validation/numberValidator.js +1 -1
- package/libEs6/utils/validation/regexpValidator.js +1 -1
- package/libEs6/utils/validation/stringValidator.js +1 -1
- package/libEs6/utils/validation/utils.js +131 -0
- package/package.json +7 -4
- package/libEs5/utils/validation/assertValid.js +0 -22
- package/libEs5/utils/validation/chain.js +0 -76
- package/libEs5/utils/validation/nullSafeChain.js +0 -41
- package/libEs6/utils/validation/assertValid.js +0 -16
- package/libEs6/utils/validation/chain.js +0 -67
- package/libEs6/utils/validation/nullSafeChain.js +0 -32
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.default = void 0;
|
|
4
|
-
|
|
5
|
-
var _assign = require("../assign");
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
9
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
-
governing permissions and limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Chains two validators together.
|
|
21
|
-
*
|
|
22
|
-
* Validators are functions of two parameters (value and path) that return the computed value if
|
|
23
|
-
* the input is valid, or throw an exception if the input is invalid. In most cases the returned
|
|
24
|
-
* value is the same as the input value; however, reference createDefaultValidator.js
|
|
25
|
-
* to see an example where the computed value is different from the input. Additionally, if we ever
|
|
26
|
-
* wanted to coerce types (i.e. parse string values into integers) as part of the validation process
|
|
27
|
-
* we could use the computed value to accomplish that.
|
|
28
|
-
*
|
|
29
|
-
* The path parameter is used to generate informative error messages. It is created by the objectOf, and
|
|
30
|
-
* arrayOf validators so that any error message can describe which key within the object or array is
|
|
31
|
-
* invalid.
|
|
32
|
-
*
|
|
33
|
-
* The validators also have methods to chain additional validation logic. For example, when you call
|
|
34
|
-
* `string()` to start a validator chain, it returns a validator function but it also has methods
|
|
35
|
-
* like `required` and `nonEmpty`. In index.js you can see that these methods are actually calling `chain`.
|
|
36
|
-
* Specifically in this function, the leftValidator is called first and then the return value of that is
|
|
37
|
-
* sent to the rightValidator. For example, when calling `string().nonEmpty().required()` the following
|
|
38
|
-
* chain is built up:
|
|
39
|
-
* ```
|
|
40
|
-
* *
|
|
41
|
-
* / \
|
|
42
|
-
* * required
|
|
43
|
-
* / \
|
|
44
|
-
* * nonEmpty
|
|
45
|
-
* / \
|
|
46
|
-
* base string
|
|
47
|
-
* ```
|
|
48
|
-
* Where every * is a call to chain where the two are combined. The individual validators are called from
|
|
49
|
-
* left to right in the above tree. The base validator is simply the identity function `value => value`,
|
|
50
|
-
* representing an optional value.
|
|
51
|
-
*
|
|
52
|
-
* After combining the validators, the new validator function is then augmented with the methods from the
|
|
53
|
-
* leftValidator and from the additionalMethods parameter. For example, when the string() function is called
|
|
54
|
-
* it chains to the base validator, but also adds additional methods like (`regexp`, `domain`, `nonEmpty`,
|
|
55
|
-
* and `unique`). When `nonEmpty` is called, which calls chain again, the additional methods are carried
|
|
56
|
-
* forward because they are already defined on the leftValidator.
|
|
57
|
-
*
|
|
58
|
-
* The base validator also contains the two methods `required` and `default`, so these can be used anywhere
|
|
59
|
-
* after any of the exposed validator functions are called.
|
|
60
|
-
*/
|
|
61
|
-
var _default = function _default(leftValidator, rightValidator) {
|
|
62
|
-
var additionalMethods = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
63
|
-
|
|
64
|
-
// combine the two validators, calling left first and then right.
|
|
65
|
-
// pass the return value from left into right.
|
|
66
|
-
var combinedValidator = function combinedValidator(value, path) {
|
|
67
|
-
return rightValidator(leftValidator(value, path), path);
|
|
68
|
-
}; // add the methods already defined on the left validator, and the additionalMethods
|
|
69
|
-
// to the new combined validator function.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(0, _assign.default)(combinedValidator, leftValidator, additionalMethods);
|
|
73
|
-
return combinedValidator;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
exports.default = _default;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.default = void 0;
|
|
4
|
-
|
|
5
|
-
var _chain = require("./chain");
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
9
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
-
governing permissions and limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* This augments `chain` with a null check done before running the rightValidator.
|
|
21
|
-
* See chain for more info.
|
|
22
|
-
*
|
|
23
|
-
* For most validators, we want the validation to be optional (i.e. allow null or
|
|
24
|
-
* undefined values). To accomplish this, the validator needs to have a check
|
|
25
|
-
* at the begining of the function, short circuiting the validation logic and
|
|
26
|
-
* returning value if value is null or undefined. `default` and `required` do not
|
|
27
|
-
* want this null check though. Indeed, `default` should return the default value
|
|
28
|
-
* if value is null, and `required` should throw an error if value is null.
|
|
29
|
-
*
|
|
30
|
-
* So to keep from having to have a null check in front of most validators, this
|
|
31
|
-
* function allows you to chain a rightValidator that needs to have a null check.
|
|
32
|
-
*/
|
|
33
|
-
var _default = function _default(leftValidator, rightValidator, additionalMethods) {
|
|
34
|
-
var rightValidatorWithNullCheck = function rightValidatorWithNullCheck(value, path) {
|
|
35
|
-
return value == null ? value : rightValidator(value, path);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return (0, _chain.default)(leftValidator, rightValidatorWithNullCheck, additionalMethods);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
exports.default = _default;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
export default ((isValid, value, path, message) => {
|
|
13
|
-
if (!isValid) {
|
|
14
|
-
throw new Error(`'${path}': Expected ${message}, but got ${JSON.stringify(value)}.`);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import assign from "../assign";
|
|
13
|
-
/**
|
|
14
|
-
* Chains two validators together.
|
|
15
|
-
*
|
|
16
|
-
* Validators are functions of two parameters (value and path) that return the computed value if
|
|
17
|
-
* the input is valid, or throw an exception if the input is invalid. In most cases the returned
|
|
18
|
-
* value is the same as the input value; however, reference createDefaultValidator.js
|
|
19
|
-
* to see an example where the computed value is different from the input. Additionally, if we ever
|
|
20
|
-
* wanted to coerce types (i.e. parse string values into integers) as part of the validation process
|
|
21
|
-
* we could use the computed value to accomplish that.
|
|
22
|
-
*
|
|
23
|
-
* The path parameter is used to generate informative error messages. It is created by the objectOf, and
|
|
24
|
-
* arrayOf validators so that any error message can describe which key within the object or array is
|
|
25
|
-
* invalid.
|
|
26
|
-
*
|
|
27
|
-
* The validators also have methods to chain additional validation logic. For example, when you call
|
|
28
|
-
* `string()` to start a validator chain, it returns a validator function but it also has methods
|
|
29
|
-
* like `required` and `nonEmpty`. In index.js you can see that these methods are actually calling `chain`.
|
|
30
|
-
* Specifically in this function, the leftValidator is called first and then the return value of that is
|
|
31
|
-
* sent to the rightValidator. For example, when calling `string().nonEmpty().required()` the following
|
|
32
|
-
* chain is built up:
|
|
33
|
-
* ```
|
|
34
|
-
* *
|
|
35
|
-
* / \
|
|
36
|
-
* * required
|
|
37
|
-
* / \
|
|
38
|
-
* * nonEmpty
|
|
39
|
-
* / \
|
|
40
|
-
* base string
|
|
41
|
-
* ```
|
|
42
|
-
* Where every * is a call to chain where the two are combined. The individual validators are called from
|
|
43
|
-
* left to right in the above tree. The base validator is simply the identity function `value => value`,
|
|
44
|
-
* representing an optional value.
|
|
45
|
-
*
|
|
46
|
-
* After combining the validators, the new validator function is then augmented with the methods from the
|
|
47
|
-
* leftValidator and from the additionalMethods parameter. For example, when the string() function is called
|
|
48
|
-
* it chains to the base validator, but also adds additional methods like (`regexp`, `domain`, `nonEmpty`,
|
|
49
|
-
* and `unique`). When `nonEmpty` is called, which calls chain again, the additional methods are carried
|
|
50
|
-
* forward because they are already defined on the leftValidator.
|
|
51
|
-
*
|
|
52
|
-
* The base validator also contains the two methods `required` and `default`, so these can be used anywhere
|
|
53
|
-
* after any of the exposed validator functions are called.
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
export default ((leftValidator, rightValidator, additionalMethods = {}) => {
|
|
57
|
-
// combine the two validators, calling left first and then right.
|
|
58
|
-
// pass the return value from left into right.
|
|
59
|
-
const combinedValidator = (value, path) => {
|
|
60
|
-
return rightValidator(leftValidator(value, path), path);
|
|
61
|
-
}; // add the methods already defined on the left validator, and the additionalMethods
|
|
62
|
-
// to the new combined validator function.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
assign(combinedValidator, leftValidator, additionalMethods);
|
|
66
|
-
return combinedValidator;
|
|
67
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import chain from "./chain";
|
|
13
|
-
/**
|
|
14
|
-
* This augments `chain` with a null check done before running the rightValidator.
|
|
15
|
-
* See chain for more info.
|
|
16
|
-
*
|
|
17
|
-
* For most validators, we want the validation to be optional (i.e. allow null or
|
|
18
|
-
* undefined values). To accomplish this, the validator needs to have a check
|
|
19
|
-
* at the begining of the function, short circuiting the validation logic and
|
|
20
|
-
* returning value if value is null or undefined. `default` and `required` do not
|
|
21
|
-
* want this null check though. Indeed, `default` should return the default value
|
|
22
|
-
* if value is null, and `required` should throw an error if value is null.
|
|
23
|
-
*
|
|
24
|
-
* So to keep from having to have a null check in front of most validators, this
|
|
25
|
-
* function allows you to chain a rightValidator that needs to have a null check.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
export default ((leftValidator, rightValidator, additionalMethods) => {
|
|
29
|
-
const rightValidatorWithNullCheck = (value, path) => value == null ? value : rightValidator(value, path);
|
|
30
|
-
|
|
31
|
-
return chain(leftValidator, rightValidatorWithNullCheck, additionalMethods);
|
|
32
|
-
});
|