@shakerquiz/utilities 0.3.44 → 0.3.45
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/package.json
CHANGED
|
@@ -65,33 +65,33 @@ export var getFeatureFetch = configuration => {
|
|
|
65
65
|
|
|
66
66
|
default:
|
|
67
67
|
throw TypeError(
|
|
68
|
-
`Parameter configuration '${configuration}' must be either 'String' or 'Object'.`,
|
|
68
|
+
`[getFeatureFetch] Parameter configuration '${configuration}' must be either 'String' or 'Object'.`,
|
|
69
69
|
)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
if (!(feature in Features))
|
|
73
73
|
throw TypeError(
|
|
74
|
-
`Feature '${feature}' must be a member of 'Features'.`,
|
|
74
|
+
`[getFeatureFetch] Feature '${feature}' must be a member of 'Features'.`,
|
|
75
75
|
)
|
|
76
76
|
|
|
77
77
|
if (!(kind in Kinds))
|
|
78
78
|
throw TypeError(
|
|
79
|
-
`Kind '${kind}' must be a member of 'Kinds'.`,
|
|
79
|
+
`[getFeatureFetch] Kind '${kind}' must be a member of 'Kinds'.`,
|
|
80
80
|
)
|
|
81
81
|
|
|
82
82
|
if (!(service in Services))
|
|
83
83
|
throw TypeError(
|
|
84
|
-
`Service '${service}' must be a member of 'Services'.`,
|
|
84
|
+
`[getFeatureFetch] Service '${service}' must be a member of 'Services'.`,
|
|
85
85
|
)
|
|
86
86
|
|
|
87
87
|
if (!(network in Networks))
|
|
88
88
|
throw TypeError(
|
|
89
|
-
`Network '${network}' must be a member of 'Networks'.`,
|
|
89
|
+
`[getFeatureFetch] Network '${network}' must be a member of 'Networks'.`,
|
|
90
90
|
)
|
|
91
91
|
|
|
92
92
|
if (!ServiceFeatures[service].includes(feature))
|
|
93
93
|
throw TypeError(
|
|
94
|
-
`Feature '${feature}' must be a member of 'ServiceFeatures[${service}]'.`,
|
|
94
|
+
`[getFeatureFetch] Feature '${feature}' must be a member of 'ServiceFeatures[${service}]'.`,
|
|
95
95
|
)
|
|
96
96
|
|
|
97
97
|
/**
|
|
@@ -106,7 +106,7 @@ export var getFeatureFetch = configuration => {
|
|
|
106
106
|
return (input, init) => {
|
|
107
107
|
if (!(init.method in Methods))
|
|
108
108
|
throw TypeError(
|
|
109
|
-
`Method '${init.method}' is not listed in 'Methods'.`,
|
|
109
|
+
`[featureFetch] Method '${init.method}' is not listed in 'Methods'.`,
|
|
110
110
|
)
|
|
111
111
|
|
|
112
112
|
var request = new Request(
|
|
@@ -19,37 +19,37 @@ export var getFeatureOrigin = (
|
|
|
19
19
|
) => {
|
|
20
20
|
if (!(feature in Features))
|
|
21
21
|
throw TypeError(
|
|
22
|
-
`Parameter 'feature' must be a member of 'Features'.`,
|
|
22
|
+
`[getFeatureOrigin] Parameter 'feature' must be a member of 'Features'.`,
|
|
23
23
|
)
|
|
24
24
|
|
|
25
25
|
if (!(service in Services))
|
|
26
26
|
throw TypeError(
|
|
27
|
-
`Parameter 'service' must be a member of 'Services'.`,
|
|
27
|
+
`[getFeatureOrigin] Parameter 'service' must be a member of 'Services'.`,
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
if (!(network in Networks))
|
|
31
31
|
throw TypeError(
|
|
32
|
-
`Parameter 'network' must be a member of 'Networks'.`,
|
|
32
|
+
`[getFeatureOrigin] Parameter 'network' must be a member of 'Networks'.`,
|
|
33
33
|
)
|
|
34
34
|
|
|
35
35
|
if (!(feature in FeatureServiceNetworkOrigins))
|
|
36
36
|
throw TypeError(
|
|
37
|
-
`Feature '${feature}' is not defined in 'FeatureServiceNetworkOrigins'.`,
|
|
37
|
+
`[getFeatureOrigin] Feature '${feature}' is not defined in 'FeatureServiceNetworkOrigins'.`,
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
if (!(service in FeatureServiceNetworkOrigins[feature]))
|
|
41
41
|
throw TypeError(
|
|
42
|
-
`Feature's '${feature}' Service '${service}' is not defined in 'FeatureServiceNetworkOrigins[${feature}]'.`,
|
|
42
|
+
`[getFeatureOrigin] Feature's '${feature}' Service '${service}' is not defined in 'FeatureServiceNetworkOrigins[${feature}]'.`,
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
if (!(network in FeatureServiceNetworkOrigins[feature][service]))
|
|
46
46
|
throw TypeError(
|
|
47
|
-
`Feature's '${feature}' Service '${service}' Network '${network}' is not defined in 'FeatureServiceNetworkOrigins[${feature}][${network}]'.`,
|
|
47
|
+
`[getFeatureOrigin] Feature's '${feature}' Service '${service}' Network '${network}' is not defined in 'FeatureServiceNetworkOrigins[${feature}][${network}]'.`,
|
|
48
48
|
)
|
|
49
49
|
|
|
50
50
|
if (!URL.canParse(FeatureServiceNetworkOrigins[feature][service][network]))
|
|
51
51
|
throw TypeError(
|
|
52
|
-
`Feature's '${feature}' Service '${service}' Network '${network}' must be URL-like.`,
|
|
52
|
+
`[getFeatureOrigin] Feature's '${feature}' Service '${service}' Network '${network}' must be URL-like.`,
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
return FeatureServiceNetworkOrigins[feature][service][network]
|
|
@@ -62,39 +62,39 @@ export var setFeatureOrigin = origins => {
|
|
|
62
62
|
for (var feature in origins) {
|
|
63
63
|
if (!(feature in Features))
|
|
64
64
|
throw TypeError(
|
|
65
|
-
`Parameter 'feature' must be a member of 'Features'.`,
|
|
65
|
+
`[setFeatureOrigin] Parameter 'feature' must be a member of 'Features'.`,
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
if (!(feature in FeatureServiceNetworkOrigins))
|
|
69
69
|
throw TypeError(
|
|
70
|
-
`Feature '${feature}' is not defined 'FeatureServiceNetworkOrigins'.`,
|
|
70
|
+
`[setFeatureOrigin] Feature '${feature}' is not defined 'FeatureServiceNetworkOrigins'.`,
|
|
71
71
|
)
|
|
72
72
|
|
|
73
73
|
for (var service in origins[feature]) {
|
|
74
74
|
if (!(service in Services))
|
|
75
75
|
throw TypeError(
|
|
76
|
-
`Parameter 'service' must be a member of 'Services'.`,
|
|
76
|
+
`[setFeatureOrigin] Parameter 'service' must be a member of 'Services'.`,
|
|
77
77
|
)
|
|
78
78
|
|
|
79
79
|
if (!(service in FeatureServiceNetworkOrigins[feature]))
|
|
80
80
|
throw TypeError(
|
|
81
|
-
`Feature's '${feature}' Service '${service}' is not defined 'FeatureServiceNetworkOrigins[${feature}]'.`,
|
|
81
|
+
`[setFeatureOrigin] Feature's '${feature}' Service '${service}' is not defined 'FeatureServiceNetworkOrigins[${feature}]'.`,
|
|
82
82
|
)
|
|
83
83
|
|
|
84
84
|
for (var network in origins[feature][service]) {
|
|
85
85
|
if (!(network in Networks))
|
|
86
86
|
throw TypeError(
|
|
87
|
-
`Parameter 'network' must be a member of 'Networks'.`,
|
|
87
|
+
`[setFeatureOrigin] Parameter 'network' must be a member of 'Networks'.`,
|
|
88
88
|
)
|
|
89
89
|
|
|
90
90
|
if (!(network in FeatureServiceNetworkOrigins[feature][service]))
|
|
91
91
|
throw TypeError(
|
|
92
|
-
`Feature's '${feature}' Service '${service}' Network '${network}' is not defined 'FeatureServiceNetworkOrigins[${feature}][${service}]'.`,
|
|
92
|
+
`[setFeatureOrigin] Feature's '${feature}' Service '${service}' Network '${network}' is not defined 'FeatureServiceNetworkOrigins[${feature}][${service}]'.`,
|
|
93
93
|
)
|
|
94
94
|
|
|
95
95
|
if (!URL.canParse(origins[feature][service][network]))
|
|
96
96
|
throw TypeError(
|
|
97
|
-
`Feature's '${feature}' Service '${service}' Network '${network}' must be URL-like.`,
|
|
97
|
+
`[setFeatureOrigin] Feature's '${feature}' Service '${service}' Network '${network}' must be URL-like.`,
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
FeatureServiceNetworkOrigins[feature][service][network] =
|
|
@@ -115,13 +115,13 @@ export var setServiceOrigin = origins => {
|
|
|
115
115
|
for (var service in origins) {
|
|
116
116
|
if (!(service in Services))
|
|
117
117
|
throw TypeError(
|
|
118
|
-
`Service '${service}' must be a member of 'Services'.`,
|
|
118
|
+
`[setServiceOrigin] Service '${service}' must be a member of 'Services'.`,
|
|
119
119
|
)
|
|
120
120
|
|
|
121
121
|
for (var network in origins[service]) {
|
|
122
122
|
if (!(network in Networks))
|
|
123
123
|
throw TypeError(
|
|
124
|
-
`Network '${network}' must be a member of 'Networks'.`,
|
|
124
|
+
`[setServiceOrigin] Network '${network}' must be a member of 'Networks'.`,
|
|
125
125
|
)
|
|
126
126
|
|
|
127
127
|
for (var feature of ServiceFeatures[service]) {
|
|
@@ -13,27 +13,27 @@ export var getFeaturePathname = (
|
|
|
13
13
|
) => {
|
|
14
14
|
if (!(feature in Features))
|
|
15
15
|
throw TypeError(
|
|
16
|
-
`Parameter 'feature' must be a member of 'Features'.`,
|
|
16
|
+
`[getFeaturePathname] Parameter 'feature' must be a member of 'Features'.`,
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
if (!(kind in Kinds))
|
|
20
20
|
throw TypeError(
|
|
21
|
-
`Parameter 'kind' must be a member of 'Kinds'.`,
|
|
21
|
+
`[getFeaturePathname] Parameter 'kind' must be a member of 'Kinds'.`,
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
if (!(feature in FeatureKindPathnames))
|
|
25
25
|
throw TypeError(
|
|
26
|
-
`Feature '${feature}' is not defined in 'FeatureKindPathnames'.`,
|
|
26
|
+
`[getFeaturePathname] Feature '${feature}' is not defined in 'FeatureKindPathnames'.`,
|
|
27
27
|
)
|
|
28
28
|
|
|
29
29
|
if (!(kind in FeatureKindPathnames[feature]))
|
|
30
30
|
throw TypeError(
|
|
31
|
-
`Feature's '${feature}' Kind '${kind}' is not defined in 'FeatureKindPathnames[${feature}]'.`,
|
|
31
|
+
`[getFeaturePathname] Feature's '${feature}' Kind '${kind}' is not defined in 'FeatureKindPathnames[${feature}]'.`,
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
if (!is('String', FeatureKindPathnames[feature][kind]))
|
|
35
35
|
throw TypeError(
|
|
36
|
-
`Feature's '${feature}' Kind '${kind}' must be a 'String'.`,
|
|
36
|
+
`[getFeaturePathname] Feature's '${feature}' Kind '${kind}' must be a 'String'.`,
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
return FeatureKindPathnames[feature][kind]
|
|
@@ -7,61 +7,50 @@ import { Schemas } from '../enumerations/schemas.js'
|
|
|
7
7
|
export function validateSchema(feature, object) {
|
|
8
8
|
if (!(feature in Schemas))
|
|
9
9
|
throw TypeError(
|
|
10
|
-
`Parameter 'feature' '${feature}' must be a member of 'Schemas'.`,
|
|
10
|
+
`[validateSchema] Parameter 'feature' '${feature}' must be a member of 'Schemas'.`,
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
let schema = Schemas[feature]
|
|
14
14
|
|
|
15
15
|
for (let property in object)
|
|
16
|
-
if (!(property in schema))
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
16
|
+
if (!(property in schema))
|
|
17
|
+
throw TypeError(
|
|
18
|
+
`[validateSchema] Property '${property}' must be a member of '${columns}'.`,
|
|
19
|
+
)
|
|
21
20
|
|
|
22
21
|
for (let property in object) {
|
|
23
22
|
let descriptor = schema[property]
|
|
24
23
|
let value = value[property]
|
|
25
24
|
|
|
26
|
-
if (!is(descriptor.type, value))
|
|
27
|
-
|
|
28
|
-
`Property '${property}' must be of type '${descriptor.type}'
|
|
29
|
-
|
|
30
|
-
throw TypeError(message)
|
|
31
|
-
}
|
|
25
|
+
if (!is(descriptor.type, value))
|
|
26
|
+
throw TypeError(
|
|
27
|
+
`[validateSchema] Property '${property}' must be of type '${descriptor.type}'.`,
|
|
28
|
+
)
|
|
32
29
|
|
|
33
30
|
switch (descriptor.type) {
|
|
34
31
|
case 'String':
|
|
35
32
|
if ('minLength' in descriptor) {
|
|
36
|
-
if (!is('Number', descriptor.minLength))
|
|
37
|
-
|
|
38
|
-
`Descriptor 'minLength' must be a 'Number' when presented
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
`String '${value}' length should not be less than '${descriptor.minLength}'.`
|
|
46
|
-
|
|
47
|
-
throw TypeError(message)
|
|
48
|
-
}
|
|
33
|
+
if (!is('Number', descriptor.minLength))
|
|
34
|
+
throw TypeError(
|
|
35
|
+
`[validateSchema] Descriptor 'minLength' must be a 'Number' when presented.`,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
if (value.length < descriptor.minLength)
|
|
39
|
+
throw TypeError(
|
|
40
|
+
`[validateSchema] String '${value}' length should not be less than '${descriptor.minLength}'.`,
|
|
41
|
+
)
|
|
49
42
|
}
|
|
50
43
|
|
|
51
44
|
if ('maxLength' in descriptor) {
|
|
52
|
-
if (!is('Number', descriptor.maxLength))
|
|
53
|
-
|
|
54
|
-
`Descriptor 'maxLength' must be a 'Number' when presented
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
`String '${value}' length should not be more than '${descriptor.maxLength}'.`
|
|
62
|
-
|
|
63
|
-
throw TypeError(message)
|
|
64
|
-
}
|
|
45
|
+
if (!is('Number', descriptor.maxLength))
|
|
46
|
+
throw TypeError(
|
|
47
|
+
`[validateSchema] Descriptor 'maxLength' must be a 'Number' when presented.`,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
if (value.length > descriptor.maxLength)
|
|
51
|
+
throw TypeError(
|
|
52
|
+
`[validateSchema] String '${value}' length should not be more than '${descriptor.maxLength}'.`,
|
|
53
|
+
)
|
|
65
54
|
}
|
|
66
55
|
|
|
67
56
|
break
|
package/source/functions/url.js
CHANGED
|
@@ -20,22 +20,22 @@ export var getFeatureUrl = (
|
|
|
20
20
|
) => {
|
|
21
21
|
if (!(feature in Features))
|
|
22
22
|
throw TypeError(
|
|
23
|
-
`Parameter 'feature' must be a member of 'Features'.`,
|
|
23
|
+
`[getFeatureUrl] Parameter 'feature' must be a member of 'Features'.`,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
if (!(service in Services))
|
|
27
27
|
throw TypeError(
|
|
28
|
-
`Parameter 'service' must be a member of 'Services'.`,
|
|
28
|
+
`[getFeatureUrl] Parameter 'service' must be a member of 'Services'.`,
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
if (!(network in Networks))
|
|
32
32
|
throw TypeError(
|
|
33
|
-
`Parameter 'network' must be a member of 'Networks'.`,
|
|
33
|
+
`[getFeatureUrl] Parameter 'network' must be a member of 'Networks'.`,
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
if (!(kind in Kinds))
|
|
37
37
|
throw TypeError(
|
|
38
|
-
`Parameter 'kind' must be a member of 'Kinds'.`,
|
|
38
|
+
`[getFeatureUrl] Parameter 'kind' must be a member of 'Kinds'.`,
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
return new URL(
|