@velocitycareerlabs/tests-helpers 1.16.0-dev-build.1c05f9227

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.
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Copyright 2023 Velocity Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ const baseAuth0User = {
18
+ sub: 'auth0|123654',
19
+ scope: 'admin:organizations admin:credentialTypes',
20
+ };
21
+
22
+ const auth0AdminOrganization = {
23
+ sub: 'auth0|236541',
24
+ scope: 'admin:organizations',
25
+ };
26
+
27
+ const testAuth0User = {
28
+ ...baseAuth0User,
29
+ 'http://velocitynetwork.foundation/groupId': 'did:ion:1234',
30
+ };
31
+
32
+ const testAuth0UserAdminUserScope = {
33
+ sub: 'auth0|123654',
34
+ scope: 'admin:users',
35
+ };
36
+
37
+ const testAuth0UserWriteUserScope = {
38
+ sub: 'auth0|123654',
39
+ scope: 'write:users',
40
+ 'http://velocitynetwork.foundation/groupId': 'did:ion:1234',
41
+ };
42
+
43
+ const testAuth0UserWriteOrganizationsScope = {
44
+ sub: 'auth0|123654',
45
+ scope: 'write:organizations',
46
+ };
47
+
48
+ const testAuth0ReadOrganizationScope = {
49
+ sub: 'auth0|123654',
50
+ scope: 'read:organizations',
51
+ 'http://velocitynetwork.foundation/groupId': 'did:ion:1234',
52
+ };
53
+
54
+ const testAuth0UserPurchaseCouponScope = {
55
+ sub: 'auth0|123654',
56
+ scope: 'purchase:coupons',
57
+ 'http://velocitynetwork.foundation/groupId': 'did:ion:1234',
58
+ };
59
+
60
+ const testAuth0UserAdminPayMethodsScope = {
61
+ sub: 'auth0|123654',
62
+ scope: 'admin:pay_methods',
63
+ };
64
+
65
+ module.exports = {
66
+ testAuth0User,
67
+ baseAuth0User,
68
+ testAuth0UserWriteOrganizationsScope,
69
+ testAuth0UserPurchaseCouponScope,
70
+ testAuth0UserAdminUserScope,
71
+ testAuth0UserWriteUserScope,
72
+ testAuth0ReadOrganizationScope,
73
+ testAuth0UserAdminPayMethodsScope,
74
+ auth0AdminOrganization,
75
+ };
package/src/timing.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright 2023 Velocity Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ const { isString } = require('lodash/fp');
18
+ const console = require('console');
19
+
20
+ const startTiming = (test) => {
21
+ const start = Date.now();
22
+ return (obj) => {
23
+ const data = isString(obj) ? { test, msg: obj } : { test, ...obj };
24
+ console.info(JSON.stringify({ data, elapsedMs: Date.now() - start }));
25
+ };
26
+ };
27
+
28
+ module.exports = { startTiming };