payload 1.1.8 → 1.1.10
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/admin/components/elements/ReactSelect/index.scss +5 -1
- package/dist/admin/components/forms/field-types/Relationship/index.scss +0 -8
- package/dist/admin/components/forms/field-types/Select/index.scss +1 -9
- package/dist/collections/config/defaults.d.ts +5 -5
- package/dist/config/types.d.ts +6 -1
- package/dist/express/types.d.ts +2 -2
- package/dist/fields/config/types.d.ts +2 -2
- package/docs/access-control/overview.mdx +5 -0
- package/package.json +1 -1
- package/types.d.ts +4 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
export declare const defaults: {
|
|
2
2
|
access: {
|
|
3
3
|
create: ({ req: { user } }: {
|
|
4
|
-
req: import("../../types").PayloadRequest
|
|
4
|
+
req: import("../../types").PayloadRequest<any>;
|
|
5
5
|
}) => boolean;
|
|
6
6
|
read: ({ req: { user } }: {
|
|
7
|
-
req: import("../../types").PayloadRequest
|
|
7
|
+
req: import("../../types").PayloadRequest<any>;
|
|
8
8
|
}) => boolean;
|
|
9
9
|
update: ({ req: { user } }: {
|
|
10
|
-
req: import("../../types").PayloadRequest
|
|
10
|
+
req: import("../../types").PayloadRequest<any>;
|
|
11
11
|
}) => boolean;
|
|
12
12
|
delete: ({ req: { user } }: {
|
|
13
|
-
req: import("../../types").PayloadRequest
|
|
13
|
+
req: import("../../types").PayloadRequest<any>;
|
|
14
14
|
}) => boolean;
|
|
15
15
|
unlock: ({ req: { user } }: {
|
|
16
|
-
req: import("../../types").PayloadRequest
|
|
16
|
+
req: import("../../types").PayloadRequest<any>;
|
|
17
17
|
}) => boolean;
|
|
18
18
|
};
|
|
19
19
|
timestamps: boolean;
|
package/dist/config/types.d.ts
CHANGED
|
@@ -56,10 +56,15 @@ export declare type InitOptions = {
|
|
|
56
56
|
loggerOptions?: LoggerOptions;
|
|
57
57
|
};
|
|
58
58
|
export declare type AccessResult = boolean | Where;
|
|
59
|
+
declare type AccessArgs<T = any, U = any> = {
|
|
60
|
+
req: PayloadRequest<U>;
|
|
61
|
+
id?: string | number;
|
|
62
|
+
data?: T;
|
|
63
|
+
};
|
|
59
64
|
/**
|
|
60
65
|
* Access function
|
|
61
66
|
*/
|
|
62
|
-
export declare type Access = (args
|
|
67
|
+
export declare type Access<T = any, U = any> = (args: AccessArgs<T, U>) => AccessResult | Promise<AccessResult>;
|
|
63
68
|
export interface PayloadHandler {
|
|
64
69
|
(req: PayloadRequest, res: Response, next: NextFunction): void;
|
|
65
70
|
}
|
package/dist/express/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Collection } from '../collections/config/types';
|
|
|
7
7
|
import { User } from '../auth/types';
|
|
8
8
|
import { Document } from '../types';
|
|
9
9
|
import { TypeWithID } from '../globals/config/types';
|
|
10
|
-
export declare type PayloadRequest = Request & {
|
|
10
|
+
export declare type PayloadRequest<T = any> = Request & {
|
|
11
11
|
payload: Payload;
|
|
12
12
|
payloadDataLoader: DataLoader<string, TypeWithID>;
|
|
13
13
|
locale?: string;
|
|
@@ -17,7 +17,7 @@ export declare type PayloadRequest = Request & {
|
|
|
17
17
|
files?: {
|
|
18
18
|
file: UploadedFile;
|
|
19
19
|
};
|
|
20
|
-
user: User | null;
|
|
20
|
+
user: T & User | null;
|
|
21
21
|
payloadUploadSizes?: Record<string, Buffer>;
|
|
22
22
|
findByID?: {
|
|
23
23
|
[slug: string]: (q: unknown) => Document;
|
|
@@ -29,8 +29,8 @@ export declare type FieldHookArgs<T extends TypeWithID = any, P = any, S = any>
|
|
|
29
29
|
previousValue?: P;
|
|
30
30
|
};
|
|
31
31
|
export declare type FieldHook<T extends TypeWithID = any, P = any, S = any> = (args: FieldHookArgs<T, P, S>) => Promise<P> | P;
|
|
32
|
-
export declare type FieldAccess<T extends TypeWithID = any, P = any> = (args: {
|
|
33
|
-
req: PayloadRequest
|
|
32
|
+
export declare type FieldAccess<T extends TypeWithID = any, P = any, U = any> = (args: {
|
|
33
|
+
req: PayloadRequest<U>;
|
|
34
34
|
id?: string | number;
|
|
35
35
|
data?: Partial<T>;
|
|
36
36
|
siblingData?: Partial<P>;
|
|
@@ -8,6 +8,11 @@ keywords: overview, access control, permissions, documentation, Content Manageme
|
|
|
8
8
|
|
|
9
9
|
Access control within Payload is extremely powerful while remaining easy and intuitive to manage. Declaring who should have access to what documents is no more complex than writing a simple JavaScript function that either returns a `boolean` or a [`query`](/docs/queries/overview) constraint to restrict which documents users can interact with.
|
|
10
10
|
|
|
11
|
+
<YouTube
|
|
12
|
+
id="DoPLyXG26Dg"
|
|
13
|
+
title="Overview of Payload Access Control"
|
|
14
|
+
/>
|
|
15
|
+
|
|
11
16
|
**Example use cases:**
|
|
12
17
|
|
|
13
18
|
- Allowing anyone `read` access to all `Post`s
|
package/package.json
CHANGED