opacacms 0.2.1 → 0.3.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.
Files changed (185) hide show
  1. package/README.md +31 -22
  2. package/dist/admin/auth-client.d.ts +39 -39
  3. package/dist/admin/index.d.ts +2 -2
  4. package/dist/admin/index.js +15 -10520
  5. package/dist/admin/plugin-client.d.ts +65 -0
  6. package/dist/admin/react.d.ts +2 -2
  7. package/dist/admin/react.js +34 -4
  8. package/dist/admin/stores/ui.d.ts +19 -4
  9. package/dist/admin/ui/components/PluginSettingsForm.d.ts +2 -2
  10. package/dist/admin/ui/components/custom-alert.d.ts +7 -0
  11. package/dist/admin/ui/components/{DetailSheet.d.ts → detail-sheet.d.ts} +1 -2
  12. package/dist/admin/ui/components/fields/FieldLabel.d.ts +1 -1
  13. package/dist/admin/ui/components/fields/RelationshipField.d.ts +1 -1
  14. package/dist/admin/ui/components/media/AssetManagerModal.d.ts +2 -2
  15. package/dist/admin/ui/components/plugin-iframe.d.ts +7 -0
  16. package/dist/admin/ui/components/ui/accordion.d.ts +17 -7
  17. package/dist/admin/ui/components/ui/alert-dialog.d.ts +16 -12
  18. package/dist/admin/ui/components/ui/button.d.ts +11 -7
  19. package/dist/admin/ui/components/ui/relationship.d.ts +1 -1
  20. package/dist/admin/ui/components/ui/sheet.d.ts +14 -27
  21. package/dist/admin/ui/components/ui/tooltip.d.ts +7 -0
  22. package/dist/admin/ui/components/versions-sheet.d.ts +4 -5
  23. package/dist/admin/ui/views/collection-list-view.d.ts +1 -1
  24. package/dist/admin/ui/views/dashboard-view.d.ts +1 -1
  25. package/dist/admin/ui/views/media-registry-view.d.ts +3 -3
  26. package/dist/admin/ui/views/settings-view.d.ts +2 -2
  27. package/dist/admin/vue.js +27 -4
  28. package/dist/admin/webcomponent.js +66 -16
  29. package/dist/admin.css +1 -1
  30. package/dist/auth/index.d.ts +43 -43
  31. package/dist/{chunk-7y1nbmw6.js → chunk-1bd7fz7n.js} +32 -2
  32. package/dist/chunk-1qm0m8r8.js +413 -0
  33. package/dist/chunk-2k3ysje3.js +31 -0
  34. package/dist/{chunk-jdfw4v3r.js → chunk-3j9zjfmn.js} +95 -30
  35. package/dist/{chunk-byq8g0rd.js → chunk-48ywpd0a.js} +16 -22
  36. package/dist/{chunk-tfnaf41w.js → chunk-5422w4eq.js} +41 -25
  37. package/dist/chunk-56n342hs.js +95 -0
  38. package/dist/chunk-5b8r0v8c.js +47 -0
  39. package/dist/chunk-63yg00vx.js +263 -0
  40. package/dist/{chunk-8sqjbsgt.js → chunk-6bywt602.js} +26 -1
  41. package/dist/{chunk-v9z61v3g.js → chunk-6qs0g65f.js} +43 -3
  42. package/dist/chunk-7rr5p01g.js +581 -0
  43. package/dist/{chunk-2es275xs.js → chunk-941zxavt.js} +867 -322
  44. package/dist/{chunk-51z3x7kq.js → chunk-a3qae86h.js} +1 -1
  45. package/dist/{chunk-3rdhbedb.js → chunk-adq2b75c.js} +2 -2
  46. package/dist/chunk-d0tb1xjw.js +93 -0
  47. package/dist/chunk-d7cgd6vn.js +318 -0
  48. package/dist/{chunk-6d1vdfwa.js → chunk-e0g6gn7n.js} +54 -75
  49. package/dist/chunk-ec4jhybj.js +1137 -0
  50. package/dist/chunk-fatyf6f7.js +221 -0
  51. package/dist/{chunk-526a3gqx.js → chunk-fnsf1dfm.js} +1 -1
  52. package/dist/chunk-g9bxb6h0.js +205 -0
  53. package/dist/chunk-gyaf5kgf.js +10 -0
  54. package/dist/{chunk-9kxpbcb1.js → chunk-h6dhexzr.js} +16 -7
  55. package/dist/{chunk-dykn5hr6.js → chunk-j8js1y0h.js} +31 -74
  56. package/dist/{chunk-t0zg026p.js → chunk-jq1drsen.js} +12 -1
  57. package/dist/{chunk-b3kr8w41.js → chunk-m24yqkeq.js} +38 -26
  58. package/dist/chunk-m5ems3hh.js +410 -0
  59. package/dist/{chunk-8scgdznr.js → chunk-m83ybzf8.js} +15 -18
  60. package/dist/chunk-majsbncm.js +98 -0
  61. package/dist/chunk-mp2gt9yh.js +237 -0
  62. package/dist/chunk-n1twhqmf.js +54 -0
  63. package/dist/{chunk-bygjkgrx.js → chunk-naqcqj8n.js} +57 -80
  64. package/dist/chunk-q5sb5dcr.js +15 -0
  65. package/dist/{chunk-06ks4ggh.js → chunk-qhdsjek6.js} +49 -89
  66. package/dist/{chunk-n133qpsm.js → chunk-qsh2nqz3.js} +50 -81
  67. package/dist/chunk-r0ms5tk1.js +76 -0
  68. package/dist/chunk-rwqwsanx.js +75 -0
  69. package/dist/chunk-sqsfk9p4.js +700 -0
  70. package/dist/{chunk-5gvbp2qa.js → chunk-x7bnzswh.js} +25 -18
  71. package/dist/cli/commands/dev.d.ts +8 -0
  72. package/dist/cli/commands/doctor.d.ts +8 -0
  73. package/dist/cli/commands/generate.d.ts +26 -0
  74. package/dist/cli/commands/init.d.ts +13 -1
  75. package/dist/cli/commands/migrate.d.ts +33 -0
  76. package/dist/cli/commands/plugin.d.ts +13 -0
  77. package/dist/cli/commands/seed.d.ts +21 -0
  78. package/dist/cli/{commands/migrate-commands.d.ts → core/migrations/migrate-logic.d.ts} +2 -2
  79. package/dist/cli/core/migrations/schema-diff-engine.d.ts +12 -0
  80. package/dist/cli/core/migrations/schema-diff.d.ts +11 -0
  81. package/dist/cli/{seeding.d.ts → core/seeding/auto-seed.d.ts} +7 -4
  82. package/dist/cli/core/seeding/seed-logic.d.ts +2 -0
  83. package/dist/cli/index.d.ts +4 -0
  84. package/dist/cli/index.js +6 -170
  85. package/dist/client/RichText.d.ts +5 -0
  86. package/dist/client/rich-text-utils.d.ts +5 -0
  87. package/dist/client.js +3 -2
  88. package/dist/config.d.ts +3 -3
  89. package/dist/db/better-sqlite.d.ts +2 -3
  90. package/dist/db/better-sqlite.js +6 -5
  91. package/dist/db/bun-sqlite.d.ts +2 -3
  92. package/dist/db/bun-sqlite.js +6 -5
  93. package/dist/db/d1.d.ts +13 -7
  94. package/dist/db/d1.js +6 -5
  95. package/dist/db/index.d.ts +2 -2
  96. package/dist/db/index.js +10 -12
  97. package/dist/db/kysely/factory.d.ts +29 -0
  98. package/dist/db/kysely/plugins/audit-logging.d.ts +48 -0
  99. package/dist/db/kysely/plugins/auto-timestamps.d.ts +38 -0
  100. package/dist/db/kysely/plugins/cursor-pagination.d.ts +42 -0
  101. package/dist/db/kysely/plugins/deadlock-handler.d.ts +47 -0
  102. package/dist/db/kysely/plugins/draft-swapper.d.ts +33 -0
  103. package/dist/db/kysely/plugins/field-masking.d.ts +45 -0
  104. package/dist/db/kysely/plugins/fts-normalizer.d.ts +38 -0
  105. package/dist/db/kysely/plugins/i18n-fallback.d.ts +48 -0
  106. package/dist/db/kysely/plugins/id-generation.d.ts +42 -0
  107. package/dist/db/kysely/plugins/index.d.ts +16 -0
  108. package/dist/db/kysely/plugins/json-flattener.d.ts +38 -0
  109. package/dist/db/kysely/plugins/relationship-preloading.d.ts +39 -0
  110. package/dist/db/kysely/plugins/slug-generation.d.ts +37 -0
  111. package/dist/db/kysely/plugins/soft-delete.d.ts +42 -0
  112. package/dist/db/kysely/plugins/tree-resolver.d.ts +39 -0
  113. package/dist/db/kysely/plugins/virtual-field-resolver.d.ts +54 -0
  114. package/dist/db/kysely/plugins/zod-coercion.d.ts +34 -0
  115. package/dist/db/kysely/snapshot/snapshot-manager.d.ts +18 -0
  116. package/dist/db/postgres.d.ts +2 -2
  117. package/dist/db/postgres.js +6 -5
  118. package/dist/db/sqlite.d.ts +2 -3
  119. package/dist/db/sqlite.js +6 -5
  120. package/dist/index.d.ts +3 -0
  121. package/dist/index.js +161 -7
  122. package/dist/runtimes/bun.js +9 -6
  123. package/dist/runtimes/cloudflare-workers.d.ts +3 -1
  124. package/dist/runtimes/cloudflare-workers.js +36 -7
  125. package/dist/runtimes/next.js +8 -5
  126. package/dist/runtimes/node.js +9 -6
  127. package/dist/schema/collection.d.ts +116 -70
  128. package/dist/schema/compiler.d.ts +6 -0
  129. package/dist/schema/global.d.ts +38 -71
  130. package/dist/schema/index.d.ts +5 -4
  131. package/dist/schema/index.js +35 -550
  132. package/dist/schema/zod.d.ts +564 -0
  133. package/dist/server/admin-router.d.ts +1 -1
  134. package/dist/server/collection-router.d.ts +1 -1
  135. package/dist/server/graphql.d.ts +6 -0
  136. package/dist/server/handlers.d.ts +25 -7
  137. package/dist/server/middlewares/auth.d.ts +1 -1
  138. package/dist/server/plugins-loader.d.ts +1 -1
  139. package/dist/server/router.d.ts +2 -2
  140. package/dist/server/routers/admin.d.ts +1 -1
  141. package/dist/server/routers/auth.d.ts +1 -1
  142. package/dist/server/routers/collections.d.ts +4 -1
  143. package/dist/server/routers/plugins.d.ts +2 -2
  144. package/dist/server/setup-middlewares.d.ts +1 -1
  145. package/dist/server/system-router.d.ts +1 -1
  146. package/dist/server.js +11 -6
  147. package/dist/storage/adapters/cloudflare-r2.d.ts +11 -2
  148. package/dist/storage/index.js +5 -5
  149. package/dist/types.d.ts +253 -42
  150. package/dist/utils/context.d.ts +14 -0
  151. package/dist/utils/logger.d.ts +2 -0
  152. package/dist/utils/string.d.ts +10 -0
  153. package/dist/utils/webhooks-engine.d.ts +24 -0
  154. package/dist/validation.d.ts +67 -1
  155. package/dist/validator.d.ts +1 -0
  156. package/package.json +50 -11
  157. package/src/cli/index.ts +117 -0
  158. package/dist/chunk-6qq3ne6b.js +0 -288
  159. package/dist/chunk-6v1fw7q7.js +0 -126
  160. package/dist/chunk-7a9kn0np.js +0 -116
  161. package/dist/chunk-bexcv7xe.js +0 -36
  162. package/dist/chunk-d3ffeqp9.js +0 -87
  163. package/dist/chunk-fj19qccp.js +0 -78
  164. package/dist/chunk-g1jb60xd.js +0 -17
  165. package/dist/chunk-j53pz21t.js +0 -20
  166. package/dist/chunk-mkn49zmy.js +0 -102
  167. package/dist/chunk-r39em4yj.js +0 -29
  168. package/dist/chunk-rsf0tpy1.js +0 -8
  169. package/dist/chunk-srsac177.js +0 -85
  170. package/dist/chunk-twpvxfce.js +0 -64
  171. package/dist/chunk-ywm4t2gm.js +0 -19
  172. package/dist/cli/commands/plugin-sync.d.ts +0 -1
  173. package/dist/cli/commands/seed-command.d.ts +0 -2
  174. package/dist/plugins/ui-bridge.d.ts +0 -12
  175. package/dist/schema/fields/base.d.ts +0 -84
  176. package/dist/schema/fields/index.d.ts +0 -147
  177. package/dist/schema/infer.d.ts +0 -55
  178. /package/dist/admin/ui/components/{ColumnVisibilityToggle.d.ts → column-visibility-toggle.d.ts} +0 -0
  179. /package/dist/admin/ui/components/{DataDetailView.d.ts → data-detail-view.d.ts} +0 -0
  180. /package/dist/cli/{d1-mock.d.ts → core/mocks/d1-mock.d.ts} +0 -0
  181. /package/dist/cli/{r2-mock.d.ts → core/mocks/r2-mock.d.ts} +0 -0
  182. /package/dist/cli/{commands → core/plugins}/plugin-build.d.ts +0 -0
  183. /package/dist/cli/{commands → core/plugins}/plugin-init.d.ts +0 -0
  184. /package/dist/cli/{commands → core/types}/generate-types.d.ts +0 -0
  185. /package/dist/{schema/fields/validation.test.d.ts → cli/seeding.test.d.ts} +0 -0
@@ -1,79 +1,125 @@
1
- import type { Collection as BaseCollection, IconName } from "../types";
2
- import type { AccessRules, InferFields } from "./infer";
3
- /**
4
- * The Fluent API Collection Builder.
5
- */
6
- export declare class CollectionBuilder<TSlug extends string, TFields extends Record<string, any> = {}> {
7
- readonly slug: TSlug;
8
- private config;
9
- private fieldBuilders;
10
- constructor(slug: TSlug);
11
- /**
12
- * Sets the user-friendly label for the Collection.
13
- */
14
- label(label: string): this;
15
- /**
16
- * Sets the Lucide icon for this collection.
17
- */
18
- icon(iconName: IconName): this;
19
- /**
20
- * Defines which field should be used as the title in the Admin UI.
21
- */
22
- useAsTitle(fieldName: keyof TFields | (string & {})): this;
23
- /**
24
- * Defines the fields for this Collection.
25
- * Re-instantiates the builder to capture the strong types of the fields.
26
- */
27
- fields<T extends readonly any[]>(fields: [...T]): CollectionBuilder<TSlug, InferFields<T>>;
28
- /**
29
- * Type-safe access control rules.
30
- */
31
- access(rules: AccessRules<TFields>): this;
32
- /**
33
- * Defines a virtual/computed field with full type inference of the current collection data.
34
- */
35
- virtual<TName extends string, TReturn = any>(name: TName, options: {
36
- label?: string;
37
- resolve: (args: {
38
- data: TFields;
39
- req: any;
40
- user: any;
41
- session: any;
42
- apiKey?: any;
43
- }) => TReturn | Promise<TReturn>;
44
- returnType?: "string" | "number" | "boolean" | "json";
45
- }): CollectionBuilder<TSlug, TFields & {
46
- [K in TName]: TReturn;
47
- }>;
48
- /**
49
- * Advanced Admin UI configuration.
50
- */
51
- admin(opts: BaseCollection["admin"]): this;
52
- /**
53
- * Adds automated versioning and drafts.
54
- */
55
- versions(opts: {
1
+ import type { Faker } from "@faker-js/faker";
2
+ import type { AccessConfig, CollectionHooks, LucideIcons } from "@/types";
3
+ import { type ZodObject, type ZodRawShape, type infer as zInfer } from "./zod";
4
+ export interface CollectionConfig<T = any> {
5
+ slug: string;
6
+ label?: string;
7
+ admin?: {
8
+ useAsTitle?: string;
9
+ hidden?: boolean;
10
+ group?: string;
11
+ icon?: LucideIcons;
12
+ defaultColumns?: string[];
13
+ disableAdmin?: boolean;
14
+ views?: Array<{
15
+ name: string;
16
+ filter: Record<string, any>;
17
+ }>;
18
+ };
19
+ timestamps?: boolean | {
20
+ createdAt?: string;
21
+ updatedAt?: string;
22
+ };
23
+ access?: AccessConfig;
24
+ hooks?: CollectionHooks<T>;
25
+ versions?: {
56
26
  drafts?: boolean;
57
27
  maxRevisions?: number;
58
28
  autosave?: boolean;
59
- }): this;
60
- /**
61
- * Adds webhooks to be triggered on document lifecycle events.
62
- */
63
- webhooks(webhooks: {
64
- events: string[];
29
+ };
30
+ webhooks?: Array<{
31
+ type: "outgoing";
32
+ events: Array<"after:create" | "after:update" | "after:delete">;
65
33
  url: string;
66
34
  headers?: Record<string, string>;
67
- }[]): this;
35
+ retries?: number;
36
+ timeoutMs?: number;
37
+ transform?: (data: T) => any;
38
+ } | {
39
+ type: "incoming";
40
+ /** The public URL path where OpacaCMS will listen for requests. */
41
+ path: string;
42
+ /** Secret or function used to verify the request signature (HMAC-SHA256). */
43
+ verifySignature?: string | ((req: Request) => boolean | Promise<boolean>);
44
+ /** The HTTP header that contains the signature (defaults to 'x-opaca-signature'). */
45
+ signatureHeader?: string;
46
+ /** Function to map the third-party payload to your CMS collection fields. */
47
+ mapPayload?: (payload: any) => Partial<T> | Promise<Partial<T>>;
48
+ onSuccess?: (args: {
49
+ data: T;
50
+ payload: any;
51
+ operation: "create" | "update";
52
+ }) => void | Promise<void>;
53
+ }>;
68
54
  /**
69
- * Spreads configuration from presets (Proposed Feature stub)
55
+ * Seed function for the collection.
56
+ * @param faker faker instance
57
+ * @returns Partial<T> or Promise<Partial<T>>
70
58
  */
71
- extend(preset: any): this;
72
- protected _ensureAdmin(): void;
73
- build(): BaseCollection & {
74
- slug: TSlug;
75
- };
59
+ seed?: (faker: Faker) => Partial<T> | Promise<Partial<T>>;
76
60
  }
77
- export declare const Collection: {
78
- create: <T extends string>(slug: T) => CollectionBuilder<T, {}>;
61
+ export interface DefineCollectionArgs<T extends ZodRawShape> extends CollectionConfig<zInfer<ZodObject<T>>> {
62
+ schema: ZodObject<T>;
63
+ }
64
+ /**
65
+ * Replaces the legacy Collection.create() Builder API.
66
+ * Wraps a Zod Schema and attaches collection-level metadata to it.
67
+ */
68
+ export declare function defineCollection<T extends ZodRawShape>(config: DefineCollectionArgs<T>): {
69
+ schema: ZodObject<T, import("better-auth").$strip>;
70
+ fields: any[];
71
+ seed: ((faker: Faker) => Partial<import("better-auth").$InferObjectOutput<T, {}>> | Promise<Partial<import("better-auth").$InferObjectOutput<T, {}>>>) | undefined;
72
+ __type: zInfer<ZodObject<T, import("better-auth").$strip>>;
73
+ slug: string;
74
+ label?: string;
75
+ admin?: {
76
+ useAsTitle?: string;
77
+ hidden?: boolean;
78
+ group?: string;
79
+ icon?: LucideIcons;
80
+ defaultColumns?: string[];
81
+ disableAdmin?: boolean;
82
+ views?: Array<{
83
+ name: string;
84
+ filter: Record<string, any>;
85
+ }>;
86
+ };
87
+ timestamps?: boolean | {
88
+ createdAt?: string;
89
+ updatedAt?: string;
90
+ };
91
+ access?: AccessConfig;
92
+ hooks?: CollectionHooks<import("better-auth").$InferObjectOutput<T, {}>> | undefined;
93
+ versions?: {
94
+ drafts?: boolean;
95
+ maxRevisions?: number;
96
+ autosave?: boolean;
97
+ };
98
+ webhooks?: ({
99
+ type: "outgoing";
100
+ events: Array<"after:create" | "after:update" | "after:delete">;
101
+ url: string;
102
+ headers?: Record<string, string>;
103
+ retries?: number;
104
+ timeoutMs?: number;
105
+ transform?: ((data: import("better-auth").$InferObjectOutput<T, {}>) => any) | undefined;
106
+ } | {
107
+ type: "incoming";
108
+ /** The public URL path where OpacaCMS will listen for requests. */
109
+ path: string;
110
+ /** Secret or function used to verify the request signature (HMAC-SHA256). */
111
+ verifySignature?: string | ((req: Request) => boolean | Promise<boolean>);
112
+ /** The HTTP header that contains the signature (defaults to 'x-opaca-signature'). */
113
+ signatureHeader?: string;
114
+ /** Function to map the third-party payload to your CMS collection fields. */
115
+ mapPayload?: ((payload: any) => Partial<import("better-auth").$InferObjectOutput<T, {}>> | Promise<Partial<import("better-auth").$InferObjectOutput<T, {}>>>) | undefined;
116
+ onSuccess?: ((args: {
117
+ data: import("better-auth").$InferObjectOutput<T, {}>;
118
+ payload: any;
119
+ operation: "create" | "update";
120
+ }) => void | Promise<void>) | undefined;
121
+ })[] | undefined;
79
122
  };
123
+ export type InferCollection<T extends {
124
+ __type: any;
125
+ }> = T["__type"];
@@ -0,0 +1,6 @@
1
+ import { type ZodTypeAny } from "./zod";
2
+ /**
3
+ * Translates a Zod schema tree into OpacaCMS legacy JSON field configuration.
4
+ * This is used to bridge the new Zod-based definitions with the Admin UI and legacy core.
5
+ */
6
+ export declare function zodToOpacaFields(schema: ZodTypeAny, currentPath?: string): any[];
@@ -1,77 +1,44 @@
1
- import type { AccessConfig, Global as GlobalType, IconName } from "../types";
2
- import { type FieldBuilder } from "./fields";
3
- import type { InferFields } from "./infer";
4
- export type Global = GlobalType;
5
- /**
6
- * A Fluent API Builder for defining OpacaCMS Globals.
7
- */
8
- export declare class GlobalBuilder<TSlug extends string, TFields extends Record<string, any> = {}> {
9
- readonly slug: TSlug;
10
- protected config: Partial<Global>;
11
- protected _fields: FieldBuilder<any, any>[];
12
- constructor(slug: TSlug);
13
- /**
14
- * Sets the label for this global in the Admin UI.
15
- */
16
- label(label: string): this;
17
- /**
18
- * Sets the Lucide icon for this global.
19
- */
20
- icon(iconName: IconName): this;
21
- /**
22
- * Defines the fields for this global schema.
23
- */
24
- fields<T extends readonly any[]>(fields: [...T]): GlobalBuilder<TSlug, InferFields<T>>;
25
- /**
26
- * Configuration for who can read and update this global.
27
- */
28
- access(rules: AccessConfig): this;
29
- /**
30
- * Defines a virtual/computed field with full type inference of the current global data.
31
- */
32
- virtual<TName extends string, TReturn = any>(name: TName, options: {
33
- label?: string;
34
- resolve: (args: {
35
- data: TFields;
36
- req: any;
37
- user: any;
38
- session: any;
39
- apiKey?: any;
40
- }) => TReturn | Promise<TReturn>;
41
- returnType?: "string" | "number" | "boolean" | "json";
42
- }): GlobalBuilder<TSlug, TFields & {
43
- [K in TName]: TReturn;
44
- }>;
45
- /**
46
- * Alias for .virtual()
47
- */
48
- computed<TName extends string, TReturn = any>(name: TName, options: {
49
- label?: string;
50
- resolve: (args: {
51
- data: TFields;
52
- req: any;
53
- user: any;
54
- session: any;
55
- apiKey?: any;
56
- }) => TReturn | Promise<TReturn>;
57
- returnType?: "string" | "number" | "boolean" | "json";
58
- }): GlobalBuilder<TSlug, TFields & {
59
- [K in TName]: TReturn;
60
- }>;
61
- /**
62
- * Extends the global with arbitrary configuration.
63
- */
64
- extend(opts: Record<string, any>): this;
1
+ import type { Faker } from "@faker-js/faker";
2
+ import { type ZodObject, type ZodRawShape, type infer as zInfer } from "./zod";
3
+ export interface GlobalConfig {
4
+ slug: string;
5
+ label?: string;
6
+ admin?: {
7
+ hidden?: boolean;
8
+ group?: string;
9
+ icon?: string;
10
+ };
11
+ access?: {
12
+ read?: (context: any) => boolean | Promise<boolean>;
13
+ update?: (context: any) => boolean | Promise<boolean>;
14
+ };
65
15
  /**
66
- * Compiles the builder down into the raw Global object expected by OpacaCMS.
16
+ * Seed function for the global.
17
+ * @param faker faker instance
18
+ * @returns Partial<T> or Promise<Partial<T>>
67
19
  */
68
- build(): Global & {
69
- slug: TSlug;
70
- };
20
+ seed?: (faker: Faker) => any | Promise<any>;
21
+ }
22
+ export interface DefineGlobalArgs<T extends ZodRawShape> extends GlobalConfig {
23
+ schema: ZodObject<T>;
71
24
  }
72
25
  /**
73
- * Singleton factory for creating Globals.
26
+ * Zod-based replacement for the legacy GlobalBuilder.
74
27
  */
75
- export declare const Global: {
76
- create: <T extends string>(slug: T) => GlobalBuilder<T, {}>;
28
+ export declare function defineGlobal<T extends ZodRawShape>(config: DefineGlobalArgs<T>): {
29
+ schema: ZodObject<T, import("better-auth").$strip>;
30
+ fields: any[];
31
+ seed: ((faker: Faker) => any | Promise<any>) | undefined;
32
+ __type: zInfer<ZodObject<T, import("better-auth").$strip>>;
33
+ slug: string;
34
+ label?: string;
35
+ admin?: {
36
+ hidden?: boolean;
37
+ group?: string;
38
+ icon?: string;
39
+ };
40
+ access?: {
41
+ read?: (context: any) => boolean | Promise<boolean>;
42
+ update?: (context: any) => boolean | Promise<boolean>;
43
+ };
77
44
  };
@@ -1,4 +1,5 @@
1
- export { Collection, CollectionBuilder } from "./collection";
2
- export { Field, FieldBuilder } from "./fields/index";
3
- export { Global, GlobalBuilder } from "./global";
4
- export type { AccessRules, InferFields } from "./infer";
1
+ export type { Collection, Field } from "../types";
2
+ export * from "./collection";
3
+ export * from "./compiler";
4
+ export * from "./global";
5
+ export * from "./zod";