@aeriajs/security 0.0.62 → 0.0.64
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/dist/use.d.ts +2 -2
- package/dist/use.js +6 -1
- package/dist/use.mjs +4 -1
- package/package.json +7 -7
package/dist/use.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context, Description, GetAllPayload, InsertPayload } from '@aeriajs/types';
|
|
2
2
|
export declare const useSecurity: <TDescription extends Description>(context: Context<TDescription>) => {
|
|
3
|
-
beforeRead: <TPayload extends Partial<GetAllPayload<any>>>(payload?: TPayload) => Promise<import("@aeriajs/types").Left<import("@aeriajs/types").ACErrors> | import("@aeriajs/types").Right<
|
|
4
|
-
beforeWrite: <TPayload_1 extends Partial<InsertPayload<any>>>(payload?: TPayload_1 | undefined) => Promise<import("@aeriajs/types").Left<import("@aeriajs/types").ACErrors> | import("@aeriajs/types").Right<
|
|
3
|
+
beforeRead: <TPayload extends Partial<GetAllPayload<any>>>(payload?: TPayload) => Promise<import("@aeriajs/types").Left<import("@aeriajs/types").ACErrors> | import("@aeriajs/types").Right<any>>;
|
|
4
|
+
beforeWrite: <TPayload_1 extends Partial<InsertPayload<any>>>(payload?: TPayload_1 | undefined) => Promise<import("@aeriajs/types").Left<import("@aeriajs/types").ACErrors> | import("@aeriajs/types").Right<any>>;
|
|
5
5
|
};
|
package/dist/use.js
CHANGED
|
@@ -8,6 +8,9 @@ const chainFunctions = async (_props, context, functions) => {
|
|
|
8
8
|
filters: {},
|
|
9
9
|
}, _props);
|
|
10
10
|
for (const fn of functions) {
|
|
11
|
+
if (!fn) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
11
14
|
const resultEither = await fn(props, context);
|
|
12
15
|
if ((0, common_1.isLeft)(resultEither)) {
|
|
13
16
|
return resultEither;
|
|
@@ -32,7 +35,9 @@ const useSecurity = (context) => {
|
|
|
32
35
|
};
|
|
33
36
|
return chainFunctions(props, context, [
|
|
34
37
|
index_js_1.checkPagination,
|
|
35
|
-
|
|
38
|
+
context.description.owned === 'on-write'
|
|
39
|
+
? null
|
|
40
|
+
: index_js_1.checkOwnershipRead,
|
|
36
41
|
]);
|
|
37
42
|
};
|
|
38
43
|
const beforeWrite = async (payload) => {
|
package/dist/use.mjs
CHANGED
|
@@ -11,6 +11,9 @@ const chainFunctions = async (_props, context, functions) => {
|
|
|
11
11
|
filters: {}
|
|
12
12
|
}, _props);
|
|
13
13
|
for (const fn of functions) {
|
|
14
|
+
if (!fn) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
14
17
|
const resultEither = await fn(props, context);
|
|
15
18
|
if (isLeft(resultEither)) {
|
|
16
19
|
return resultEither;
|
|
@@ -36,7 +39,7 @@ export const useSecurity = (context) => {
|
|
|
36
39
|
};
|
|
37
40
|
return chainFunctions(props, context, [
|
|
38
41
|
checkPagination,
|
|
39
|
-
checkOwnershipRead
|
|
42
|
+
context.description.owned === "on-write" ? null : checkOwnershipRead
|
|
40
43
|
]);
|
|
41
44
|
};
|
|
42
45
|
const beforeWrite = async (payload) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/security",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.64",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@aeriajs/
|
|
26
|
-
"@aeriajs/common": "^0.0.
|
|
27
|
-
"@aeriajs/types": "^0.0.
|
|
25
|
+
"@aeriajs/core": "^0.0.64",
|
|
26
|
+
"@aeriajs/common": "^0.0.35",
|
|
27
|
+
"@aeriajs/types": "^0.0.32",
|
|
28
28
|
"mongodb": "^6.5.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@aeriajs/
|
|
32
|
-
"@aeriajs/common": "^0.0.
|
|
33
|
-
"@aeriajs/types": "^0.0.
|
|
31
|
+
"@aeriajs/core": "^0.0.64",
|
|
32
|
+
"@aeriajs/common": "^0.0.35",
|
|
33
|
+
"@aeriajs/types": "^0.0.32",
|
|
34
34
|
"mongodb": "^6.1.0"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|