opacacms 0.3.14 → 0.3.15
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/index.d.ts +1 -1
- package/dist/schema/collection.d.ts +4 -3
- package/dist/schema/global.d.ts +5 -10
- package/dist/types/access.d.ts +7 -7
- package/dist/types.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Faker } from "@faker-js/faker";
|
|
2
|
-
import type { AccessConfig
|
|
2
|
+
import type { AccessConfig } from "../types/access";
|
|
3
|
+
import type { CollectionHooks, LucideIcons } from "@/types";
|
|
3
4
|
import { type ZodObject, type ZodRawShape, type infer as zInfer } from "./zod";
|
|
4
5
|
export interface CollectionConfig<T = any, S extends string = string> {
|
|
5
6
|
slug: S;
|
|
@@ -20,7 +21,7 @@ export interface CollectionConfig<T = any, S extends string = string> {
|
|
|
20
21
|
createdAt?: string;
|
|
21
22
|
updatedAt?: string;
|
|
22
23
|
};
|
|
23
|
-
access?: AccessConfig
|
|
24
|
+
access?: AccessConfig<T>;
|
|
24
25
|
hooks?: CollectionHooks<T>;
|
|
25
26
|
versions?: {
|
|
26
27
|
drafts?: boolean;
|
|
@@ -88,7 +89,7 @@ export declare function defineCollection<T extends ZodRawShape, S extends string
|
|
|
88
89
|
createdAt?: string;
|
|
89
90
|
updatedAt?: string;
|
|
90
91
|
};
|
|
91
|
-
access?: AccessConfig;
|
|
92
|
+
access?: AccessConfig<import("better-auth").$InferObjectOutput<T, {}>> | undefined;
|
|
92
93
|
hooks?: CollectionHooks<import("better-auth").$InferObjectOutput<T, {}>> | undefined;
|
|
93
94
|
versions?: {
|
|
94
95
|
drafts?: boolean;
|
package/dist/schema/global.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Faker } from "@faker-js/faker";
|
|
2
|
+
import type { AccessConfig } from "../types/access";
|
|
2
3
|
import { type ZodObject, type ZodRawShape, type infer as zInfer } from "./zod";
|
|
3
|
-
export interface GlobalConfig<S extends string = string> {
|
|
4
|
+
export interface GlobalConfig<T = any, S extends string = string> {
|
|
4
5
|
slug: S;
|
|
5
6
|
label?: string;
|
|
6
7
|
admin?: {
|
|
@@ -8,10 +9,7 @@ export interface GlobalConfig<S extends string = string> {
|
|
|
8
9
|
group?: string;
|
|
9
10
|
icon?: string;
|
|
10
11
|
};
|
|
11
|
-
access?:
|
|
12
|
-
read?: (context: any) => boolean | Promise<boolean>;
|
|
13
|
-
update?: (context: any) => boolean | Promise<boolean>;
|
|
14
|
-
};
|
|
12
|
+
access?: AccessConfig<T>;
|
|
15
13
|
/**
|
|
16
14
|
* Seed function for the global.
|
|
17
15
|
* @param faker faker instance
|
|
@@ -19,7 +17,7 @@ export interface GlobalConfig<S extends string = string> {
|
|
|
19
17
|
*/
|
|
20
18
|
seed?: (faker: Faker) => any | Promise<any>;
|
|
21
19
|
}
|
|
22
|
-
export interface DefineGlobalArgs<T extends ZodRawShape, S extends string> extends GlobalConfig<S> {
|
|
20
|
+
export interface DefineGlobalArgs<T extends ZodRawShape, S extends string> extends GlobalConfig<zInfer<ZodObject<T>>, S> {
|
|
23
21
|
schema: ZodObject<T>;
|
|
24
22
|
}
|
|
25
23
|
/**
|
|
@@ -37,8 +35,5 @@ export declare function defineGlobal<T extends ZodRawShape, S extends string>(co
|
|
|
37
35
|
group?: string;
|
|
38
36
|
icon?: string;
|
|
39
37
|
};
|
|
40
|
-
access?: {
|
|
41
|
-
read?: (context: any) => boolean | Promise<boolean>;
|
|
42
|
-
update?: (context: any) => boolean | Promise<boolean>;
|
|
43
|
-
};
|
|
38
|
+
access?: AccessConfig<import("better-auth").$InferObjectOutput<T, {}>> | undefined;
|
|
44
39
|
};
|
package/dist/types/access.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { Context } from "hono";
|
|
2
|
-
export interface AccessArgs {
|
|
2
|
+
export interface AccessArgs<T = any> {
|
|
3
3
|
req: Context;
|
|
4
4
|
user: any;
|
|
5
5
|
session: any;
|
|
6
6
|
apiKey: any;
|
|
7
7
|
/** The document being created/updated or the search query */
|
|
8
|
-
data?:
|
|
8
|
+
data?: T;
|
|
9
9
|
/** The ID of the document being read/updated/deleted */
|
|
10
10
|
id?: string;
|
|
11
11
|
operation: "read" | "create" | "update" | "delete";
|
|
12
12
|
}
|
|
13
|
-
export interface AccessConfig {
|
|
14
|
-
read?: boolean | ((args: AccessArgs) => boolean | Promise<boolean>);
|
|
15
|
-
create?: boolean | ((args: AccessArgs) => boolean | Promise<boolean>);
|
|
16
|
-
update?: boolean | ((args: AccessArgs) => boolean | Promise<boolean>);
|
|
17
|
-
delete?: boolean | ((args: AccessArgs) => boolean | Promise<boolean>);
|
|
13
|
+
export interface AccessConfig<T = any> {
|
|
14
|
+
read?: boolean | ((args: AccessArgs<T>) => boolean | Promise<boolean>);
|
|
15
|
+
create?: boolean | ((args: AccessArgs<T>) => boolean | Promise<boolean>);
|
|
16
|
+
update?: boolean | ((args: AccessArgs<T>) => boolean | Promise<boolean>);
|
|
17
|
+
delete?: boolean | ((args: AccessArgs<T>) => boolean | Promise<boolean>);
|
|
18
18
|
requireApiKey?: boolean;
|
|
19
19
|
}
|
|
20
20
|
export interface FieldAccessArgs extends AccessArgs {
|
package/dist/types.d.ts
CHANGED
|
@@ -349,7 +349,7 @@ export interface Collection<T = any> {
|
|
|
349
349
|
/** Lifecycle hooks for custom logic before/after database operations. */
|
|
350
350
|
hooks?: CollectionHooks<T>;
|
|
351
351
|
/** Access control configuration for the collection. */
|
|
352
|
-
access?: AccessConfig
|
|
352
|
+
access?: AccessConfig<T>;
|
|
353
353
|
/** Versioning and draft support configuration. */
|
|
354
354
|
versions?: {
|
|
355
355
|
/** Enable draft/published states for records. */
|
|
@@ -404,10 +404,10 @@ export interface Collection<T = any> {
|
|
|
404
404
|
hidden?: boolean;
|
|
405
405
|
seed?: (faker: Faker) => Partial<T> | Promise<Partial<T>>;
|
|
406
406
|
}
|
|
407
|
-
export interface Global {
|
|
407
|
+
export interface Global<T = any> {
|
|
408
408
|
slug: string;
|
|
409
409
|
fields: Field[];
|
|
410
|
-
access?: AccessConfig
|
|
410
|
+
access?: AccessConfig<T>;
|
|
411
411
|
label?: string;
|
|
412
412
|
icon?: LucideIcons;
|
|
413
413
|
timestamps?: boolean | {
|