@appsemble/utils 0.32.1 → 0.32.2-test.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/README.md +3 -3
- package/api/paths/trainings/completedTrainings.js +8 -0
- package/authorization.js +2 -2
- package/examples.js +10 -0
- package/package.json +2 -2
- package/remap.js +22 -20
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble Utilities
|
|
1
|
+
#  Appsemble Utilities
|
|
2
2
|
|
|
3
3
|
> Internal utility functions used across multiple Appsemble projects.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/utils)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.32.1)
|
|
6
|
+
[](https://gitlab.com/appsemble/appsemble/-/releases/0.32.2-test.1)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -26,5 +26,5 @@ not guaranteed.
|
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
|
29
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.32.1/LICENSE.md) ©
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.32.2-test.1/LICENSE.md) ©
|
|
30
30
|
[Appsemble](https://appsemble.com)
|
|
@@ -17,5 +17,13 @@ export const pathItems = {
|
|
|
17
17
|
},
|
|
18
18
|
security: [{ studio: [] }],
|
|
19
19
|
},
|
|
20
|
+
delete: {
|
|
21
|
+
description: 'Delete all completed trainings from user',
|
|
22
|
+
operationId: 'resetTrainingProgress',
|
|
23
|
+
responses: {
|
|
24
|
+
204: { description: 'Trainings successfully reset ' },
|
|
25
|
+
},
|
|
26
|
+
security: [{ studio: [] }],
|
|
27
|
+
},
|
|
20
28
|
};
|
|
21
29
|
//# sourceMappingURL=completedTrainings.js.map
|
package/authorization.js
CHANGED
|
@@ -8,8 +8,8 @@ function checkAppPermissions(acquiredPermissions, requiredPermissions) {
|
|
|
8
8
|
return true;
|
|
9
9
|
}
|
|
10
10
|
if (customAppResourcePermissionPattern.test(p)) {
|
|
11
|
-
const [, , resourceAction] = p.split(':');
|
|
12
|
-
return acquiredPermissions.includes(`$resource:all:${resourceAction}`);
|
|
11
|
+
const [, , resourceAction, resourceExtenstion] = p.split(':');
|
|
12
|
+
return acquiredPermissions.includes(`$resource:all:${resourceAction}${resourceExtenstion ? `:${resourceExtenstion}` : ''}`);
|
|
13
13
|
}
|
|
14
14
|
if (customAppOwnResourcePermissionPattern.test(p)) {
|
|
15
15
|
const [, resourceName, , resourceAction] = p.split(':');
|
package/examples.js
CHANGED
|
@@ -611,6 +611,9 @@ export const examples = {
|
|
|
611
611
|
zip: 7500,
|
|
612
612
|
},
|
|
613
613
|
},
|
|
614
|
+
favoriteColors: {
|
|
615
|
+
'array.from': ['blue', 'green'],
|
|
616
|
+
},
|
|
614
617
|
},
|
|
615
618
|
},
|
|
616
619
|
{
|
|
@@ -623,12 +626,19 @@ export const examples = {
|
|
|
623
626
|
country: 'France',
|
|
624
627
|
},
|
|
625
628
|
},
|
|
629
|
+
favoriteColors: { 'array.from': ['red', 'green', 'blue'] },
|
|
626
630
|
},
|
|
627
631
|
},
|
|
628
632
|
],
|
|
629
633
|
},
|
|
630
634
|
result: [
|
|
631
635
|
{ path: ['age'], type: 'changed', from: 25, to: 26 },
|
|
636
|
+
{
|
|
637
|
+
path: ['favoriteColors'],
|
|
638
|
+
type: 'changed',
|
|
639
|
+
from: ['blue', 'green'],
|
|
640
|
+
to: ['red', 'green', 'blue'],
|
|
641
|
+
},
|
|
632
642
|
{ path: ['address', 'city'], type: 'changed', from: 'Paris', to: 'Lyon' },
|
|
633
643
|
{ path: ['address', 'zip'], type: 'removed', value: 7500 },
|
|
634
644
|
{ path: ['address', 'country'], type: 'added', value: 'France' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/utils",
|
|
3
|
-
"version": "0.32.1",
|
|
3
|
+
"version": "0.32.2-test.1",
|
|
4
4
|
"description": "Utility functions used in Appsemble internally",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "vitest"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@appsemble/types": "0.32.1",
|
|
42
|
+
"@appsemble/types": "0.32.2-test.1",
|
|
43
43
|
"@odata/parser": "^0.2.14",
|
|
44
44
|
"axios": "^1.0.0",
|
|
45
45
|
"cron-parser": "^4.0.0",
|
package/remap.js
CHANGED
|
@@ -230,29 +230,31 @@ const mapperImplementations = {
|
|
|
230
230
|
'object.compare'([remapper1, remapper2], input, context) {
|
|
231
231
|
const remapped1 = remap(remapper1, input, context);
|
|
232
232
|
const remapped2 = remap(remapper2, input, context);
|
|
233
|
-
function deepDiff(
|
|
233
|
+
function deepDiff(object1, object2) {
|
|
234
|
+
const stack = [{ obj1: object1, obj2: object2, path: [] }];
|
|
234
235
|
const diffs = [];
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
236
|
+
while (stack.length !== 0) {
|
|
237
|
+
const { obj1, obj2, path } = stack.pop();
|
|
238
|
+
const keys = new Set([...Object.keys(obj1 || {}), ...Object.keys(obj2 || {})]);
|
|
239
|
+
for (const key of keys) {
|
|
240
|
+
const val1 = obj1?.[key];
|
|
241
|
+
const val2 = obj2?.[key];
|
|
242
|
+
const currentPath = [...path, key];
|
|
243
|
+
if (isPlainObject(val1) && isPlainObject(val2)) {
|
|
244
|
+
stack.push({ obj1: val1, obj2: val2, path: currentPath });
|
|
245
|
+
}
|
|
246
|
+
else if (Array.isArray(val1) && Array.isArray(val2) && !isEqualArray(val1, val2)) {
|
|
247
|
+
diffs.push({ path: currentPath, type: 'changed', from: val1, to: val2 });
|
|
248
|
+
}
|
|
249
|
+
else if (!(key in obj1)) {
|
|
250
|
+
diffs.push({ path: currentPath, type: 'added', value: val2 });
|
|
251
|
+
}
|
|
252
|
+
else if (!(key in obj2)) {
|
|
253
|
+
diffs.push({ path: currentPath, type: 'removed', value: val1 });
|
|
254
|
+
}
|
|
255
|
+
else if (val1 !== val2) {
|
|
245
256
|
diffs.push({ path: currentPath, type: 'changed', from: val1, to: val2 });
|
|
246
257
|
}
|
|
247
|
-
}
|
|
248
|
-
else if (!(key in obj1)) {
|
|
249
|
-
diffs.push({ path: currentPath, type: 'added', value: val2 });
|
|
250
|
-
}
|
|
251
|
-
else if (!(key in obj2)) {
|
|
252
|
-
diffs.push({ path: currentPath, type: 'removed', value: val1 });
|
|
253
|
-
}
|
|
254
|
-
else if (val1 !== val2) {
|
|
255
|
-
diffs.push({ path: currentPath, type: 'changed', from: val1, to: val2 });
|
|
256
258
|
}
|
|
257
259
|
}
|
|
258
260
|
return diffs;
|