opacacms 0.1.21 → 0.2.0

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 (137) hide show
  1. package/README.md +792 -50
  2. package/dist/admin/auth-client.d.ts +39 -39
  3. package/dist/admin/index.js +2360 -1392
  4. package/dist/admin/react.d.ts +1 -1
  5. package/dist/admin/react.js +8 -0
  6. package/dist/admin/router.d.ts +1 -0
  7. package/dist/admin/stores/ui.d.ts +10 -0
  8. package/dist/admin/ui/admin-layout.d.ts +4 -4
  9. package/dist/admin/ui/components/DataDetailView.d.ts +1 -1
  10. package/dist/admin/ui/components/DetailSheet.d.ts +19 -0
  11. package/dist/admin/ui/components/PluginSettingsForm.d.ts +11 -0
  12. package/dist/admin/ui/components/fields/BooleanField.d.ts +2 -1
  13. package/dist/admin/ui/components/fields/DateField.d.ts +1 -1
  14. package/dist/admin/ui/components/fields/FieldLabel.d.ts +11 -0
  15. package/dist/admin/ui/components/fields/FileField.d.ts +1 -1
  16. package/dist/admin/ui/components/fields/NumberField.d.ts +1 -1
  17. package/dist/admin/ui/components/fields/RadioField.d.ts +1 -1
  18. package/dist/admin/ui/components/fields/RelationshipField.d.ts +3 -1
  19. package/dist/admin/ui/components/fields/SelectField.d.ts +1 -1
  20. package/dist/admin/ui/components/fields/TextAreaField.d.ts +1 -1
  21. package/dist/admin/ui/components/fields/TextField.d.ts +1 -1
  22. package/dist/admin/ui/components/fields/VirtualField.d.ts +1 -0
  23. package/dist/admin/ui/components/fields/index.d.ts +16 -16
  24. package/dist/admin/ui/components/fields/richtext-editor/index.d.ts +1 -1
  25. package/dist/admin/ui/components/media/AssetManagerModal.d.ts +1 -1
  26. package/dist/admin/ui/components/toast.d.ts +1 -1
  27. package/dist/admin/ui/components/ui/accordion.d.ts +1 -1
  28. package/dist/admin/ui/components/ui/button.d.ts +1 -1
  29. package/dist/admin/ui/components/ui/collapsible.d.ts +1 -1
  30. package/dist/admin/ui/components/ui/dialog.d.ts +1 -1
  31. package/dist/admin/ui/components/ui/group.d.ts +1 -1
  32. package/dist/admin/ui/components/ui/index.d.ts +17 -17
  33. package/dist/admin/ui/components/ui/input.d.ts +1 -1
  34. package/dist/admin/ui/components/ui/label.d.ts +1 -1
  35. package/dist/admin/ui/components/ui/radio-group.d.ts +1 -1
  36. package/dist/admin/ui/components/ui/relationship.d.ts +4 -4
  37. package/dist/admin/ui/components/ui/select.d.ts +1 -1
  38. package/dist/admin/ui/components/ui/sheet.d.ts +1 -1
  39. package/dist/admin/ui/components/ui/tabs.d.ts +1 -1
  40. package/dist/admin/ui/components/versions-sheet.d.ts +11 -0
  41. package/dist/admin/ui/views/media-registry-view.d.ts +1 -1
  42. package/dist/admin/ui/views/settings-view.d.ts +2 -2
  43. package/dist/admin/vue.js +8 -0
  44. package/dist/admin/webcomponent.js +2 -2
  45. package/dist/admin.css +1 -1
  46. package/dist/auth/index.d.ts +101 -41
  47. package/dist/{chunk-0sdceeys.js → chunk-0bq155dy.js} +86 -6
  48. package/dist/{chunk-59sg3pw9.js → chunk-0gtxnxmd.js} +90 -7
  49. package/dist/{chunk-v521d72w.js → chunk-3rdhbedb.js} +1 -1
  50. package/dist/chunk-51z3x7kq.js +20 -0
  51. package/dist/{chunk-7fyepksb.js → chunk-526a3gqx.js} +1 -1
  52. package/dist/{chunk-wmvjvn7b.js → chunk-6qq3ne6b.js} +39 -1
  53. package/dist/{chunk-0am1m47g.js → chunk-6v1fw7q7.js} +5 -5
  54. package/dist/{chunk-t9v845m2.js → chunk-7y1nbmw6.js} +34 -3
  55. package/dist/chunk-8scgdznr.js +44 -0
  56. package/dist/{chunk-mycmsjd9.js → chunk-b3kr8w41.js} +57 -6
  57. package/dist/chunk-bexcv7xe.js +36 -0
  58. package/dist/{chunk-16vgcf3k.js → chunk-byq8g0rd.js} +1 -1
  59. package/dist/{chunk-fqastxq9.js → chunk-d1asgtke.js} +86 -6
  60. package/dist/{chunk-cpw2y3pn.js → chunk-dykn5hr6.js} +7 -7
  61. package/dist/{chunk-61kwqve4.js → chunk-esrg9qj0.js} +90 -9
  62. package/dist/chunk-fj19qccp.js +78 -0
  63. package/dist/{chunk-ekxkvqjm.js → chunk-gmee4mdc.js} +90 -9
  64. package/dist/{chunk-xa7rjsn2.js → chunk-j53pz21t.js} +2 -2
  65. package/dist/{chunk-xrfhhz85.js → chunk-kc4jfnv7.js} +480 -85
  66. package/dist/chunk-mkn49zmy.js +102 -0
  67. package/dist/{chunk-n1xraw7j.js → chunk-qb6ztvw9.js} +1 -1
  68. package/dist/{chunk-2kyhqvhc.js → chunk-qxt9vge8.js} +1 -1
  69. package/dist/chunk-r39em4yj.js +29 -0
  70. package/dist/chunk-rqyjjqgy.js +91 -0
  71. package/dist/chunk-rsf0tpy1.js +8 -0
  72. package/dist/chunk-swtcpvhf.js +2442 -0
  73. package/dist/chunk-t0zg026p.js +71 -0
  74. package/dist/chunk-twpvxfce.js +64 -0
  75. package/dist/{chunk-ybbbqj63.js → chunk-v9z61v3g.js} +15 -0
  76. package/dist/{chunk-jwjk85ze.js → chunk-ywm4t2gm.js} +6 -2
  77. package/dist/cli/commands/plugin-build.d.ts +1 -0
  78. package/dist/cli/commands/plugin-init.d.ts +1 -0
  79. package/dist/cli/commands/plugin-sync.d.ts +1 -0
  80. package/dist/cli/index.js +24 -6
  81. package/dist/config-utils.d.ts +1 -1
  82. package/dist/config.d.ts +21 -4
  83. package/dist/db/better-sqlite.d.ts +1 -1
  84. package/dist/db/better-sqlite.js +5 -5
  85. package/dist/db/bun-sqlite.d.ts +1 -1
  86. package/dist/db/bun-sqlite.js +5 -5
  87. package/dist/db/d1.d.ts +1 -1
  88. package/dist/db/d1.js +5 -5
  89. package/dist/db/index.js +9 -9
  90. package/dist/db/postgres.d.ts +1 -1
  91. package/dist/db/postgres.js +5 -5
  92. package/dist/db/sqlite.d.ts +1 -1
  93. package/dist/db/sqlite.js +5 -5
  94. package/dist/index.js +4 -3
  95. package/dist/plugins/index.d.ts +1 -0
  96. package/dist/plugins/ui-bridge.d.ts +12 -0
  97. package/dist/plugins/utils.d.ts +5 -0
  98. package/dist/runtimes/bun.js +13 -7
  99. package/dist/runtimes/cloudflare-workers.js +5 -5
  100. package/dist/runtimes/next.js +5 -5
  101. package/dist/runtimes/node.js +13 -7
  102. package/dist/schema/collection.d.ts +9 -26
  103. package/dist/schema/fields/base.d.ts +3 -2
  104. package/dist/schema/fields/index.d.ts +12 -0
  105. package/dist/schema/fields/validation.test.d.ts +1 -0
  106. package/dist/schema/global.d.ts +10 -7
  107. package/dist/schema/index.js +22 -6
  108. package/dist/server/admin-router.d.ts +2 -2
  109. package/dist/server/admin.d.ts +2 -1
  110. package/dist/server/collection-router.d.ts +1 -1
  111. package/dist/server/handlers.d.ts +10 -0
  112. package/dist/server/middlewares/admin.d.ts +2 -2
  113. package/dist/server/middlewares/auth.d.ts +1 -1
  114. package/dist/server/middlewares/context.d.ts +2 -0
  115. package/dist/server/middlewares/rate-limit.d.ts +1 -1
  116. package/dist/server/openapi.d.ts +2 -0
  117. package/dist/server/plugins-loader.d.ts +6 -0
  118. package/dist/server/router.d.ts +3 -3
  119. package/dist/server/routers/admin.d.ts +2 -2
  120. package/dist/server/routers/auth.d.ts +1 -1
  121. package/dist/server/routers/collections.d.ts +1 -1
  122. package/dist/server/routers/plugins.d.ts +18 -0
  123. package/dist/server/setup-middlewares.d.ts +2 -2
  124. package/dist/server/system-router.d.ts +1 -1
  125. package/dist/server.js +11 -7
  126. package/dist/storage/adapters/local.d.ts +1 -1
  127. package/dist/storage/adapters/s3.d.ts +1 -1
  128. package/dist/types.d.ts +222 -15
  129. package/dist/utils/logger.d.ts +13 -35
  130. package/dist/validation.d.ts +40 -0
  131. package/dist/validator.d.ts +1 -1
  132. package/package.json +21 -7
  133. package/dist/admin/ui/components/DataDetailSheet.d.ts +0 -13
  134. package/dist/admin/ui/components/ui/relationship-detail-sheet.d.ts +0 -9
  135. package/dist/chunk-62ev8gnc.js +0 -41
  136. package/dist/chunk-j4d50hrx.js +0 -20
  137. package/dist/chunk-nb7ctdg8.js +0 -311
@@ -3,11 +3,11 @@ import type { AccessRules, InferFields } from "./infer";
3
3
  /**
4
4
  * The Fluent API Collection Builder.
5
5
  */
6
- export declare class CollectionBuilder<TFields extends Record<string, any> = {}> {
7
- readonly slug: string;
6
+ export declare class CollectionBuilder<TSlug extends string, TFields extends Record<string, any> = {}> {
7
+ readonly slug: TSlug;
8
8
  private config;
9
9
  private fieldBuilders;
10
- constructor(slug: string);
10
+ constructor(slug: TSlug);
11
11
  /**
12
12
  * Sets the user-friendly label for the Collection.
13
13
  */
@@ -24,7 +24,7 @@ export declare class CollectionBuilder<TFields extends Record<string, any> = {}>
24
24
  * Defines the fields for this Collection.
25
25
  * Re-instantiates the builder to capture the strong types of the fields.
26
26
  */
27
- fields<T extends readonly any[]>(fields: [...T]): CollectionBuilder<InferFields<T>>;
27
+ fields<T extends readonly any[]>(fields: [...T]): CollectionBuilder<TSlug, InferFields<T>>;
28
28
  /**
29
29
  * Type-safe access control rules.
30
30
  */
@@ -42,23 +42,7 @@ export declare class CollectionBuilder<TFields extends Record<string, any> = {}>
42
42
  apiKey?: any;
43
43
  }) => TReturn | Promise<TReturn>;
44
44
  returnType?: "string" | "number" | "boolean" | "json";
45
- }): CollectionBuilder<TFields & {
46
- [K in TName]: TReturn;
47
- }>;
48
- /**
49
- * Alias for .virtual()
50
- */
51
- computed<TName extends string, TReturn = any>(name: TName, options: {
52
- label?: string;
53
- resolve: (args: {
54
- data: TFields;
55
- req: any;
56
- user: any;
57
- session: any;
58
- apiKey?: any;
59
- }) => TReturn | Promise<TReturn>;
60
- returnType?: "string" | "number" | "boolean" | "json";
61
- }): CollectionBuilder<TFields & {
45
+ }): CollectionBuilder<TSlug, TFields & {
62
46
  [K in TName]: TReturn;
63
47
  }>;
64
48
  /**
@@ -86,11 +70,10 @@ export declare class CollectionBuilder<TFields extends Record<string, any> = {}>
86
70
  */
87
71
  extend(preset: any): this;
88
72
  protected _ensureAdmin(): void;
89
- /**
90
- * Compiles the collection builder down into the raw Object structure expected by OpacaCMS.
91
- */
92
- build(): BaseCollection;
73
+ build(): BaseCollection & {
74
+ slug: TSlug;
75
+ };
93
76
  }
94
77
  export declare const Collection: {
95
- create: (slug: string) => CollectionBuilder<{}>;
78
+ create: <T extends string>(slug: T) => CollectionBuilder<T, {}>;
96
79
  };
@@ -1,3 +1,4 @@
1
+ import type { z } from "zod";
1
2
  import type { BaseField, FieldAccessConfig } from "../../types";
2
3
  /**
3
4
  * The base class for all Fluent API Field Builders.
@@ -41,9 +42,9 @@ export declare abstract class FieldBuilder<TType extends string, TName extends s
41
42
  */
42
43
  defaultValue(val: TValue): this;
43
44
  /**
44
- * A custom validation callback function.
45
+ * A custom validation callback function or a Zod schema.
45
46
  */
46
- validate(fn: (value: unknown) => boolean | string): this;
47
+ validate(val: ((value: unknown) => boolean | string) | z.ZodTypeAny): this;
47
48
  /**
48
49
  * Configure granular access control for this specific field.
49
50
  */
@@ -23,6 +23,9 @@ export declare class RichTextFieldBuilder<TName extends string> extends FieldBui
23
23
  constructor(name: TName);
24
24
  mode(mode: "simple" | "notion"): this;
25
25
  }
26
+ export declare class UIFieldBuilder<TName extends string> extends FieldBuilder<"ui", TName, any> {
27
+ constructor(name: TName);
28
+ }
26
29
  export declare class RelationshipFieldBuilder<TName extends string> extends FieldBuilder<"relationship", TName, string | string[]> {
27
30
  constructor(name: TName);
28
31
  to(collection: string | {
@@ -38,6 +41,9 @@ export declare class FileFieldBuilder<TName extends string> extends FieldBuilder
38
41
  allowedmime_types(types: string[]): this;
39
42
  maxSize(bytes: number): this;
40
43
  }
44
+ export declare class JSONFieldBuilder<TName extends string> extends FieldBuilder<"json", TName, any> {
45
+ constructor(name: TName);
46
+ }
41
47
  export declare class DateFieldBuilder<TName extends string> extends FieldBuilder<"date", TName, string | Date> {
42
48
  constructor(name: TName);
43
49
  }
@@ -131,5 +137,11 @@ export declare const Field: {
131
137
  row: <S extends readonly FieldBuilder<any, any, any, any>[]>(fields?: S) => RowFieldBuilder<S>;
132
138
  blocks: <N extends string, TSub extends readonly BlockBuilder<any, any, any>[]>(name: N, ...blocks: TSub) => BlocksFieldBuilder<N, TSub>;
133
139
  block: <N extends string>(slug: N) => BlockBuilder<N, string, any[]>;
140
+ /**
141
+ * Inject a pure Custom UI Element (Web Component) directly into the Admin Form.
142
+ * This field is ignored by the database schema generator and backend validation.
143
+ */
144
+ ui: <N extends string>(name: N) => UIFieldBuilder<N>;
145
+ json: <N extends string>(name: N) => JSONFieldBuilder<N>;
134
146
  };
135
147
  export * from "./base";
@@ -0,0 +1 @@
1
+ export {};
@@ -5,10 +5,11 @@ export type Global = GlobalType;
5
5
  /**
6
6
  * A Fluent API Builder for defining OpacaCMS Globals.
7
7
  */
8
- export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
8
+ export declare class GlobalBuilder<TSlug extends string, TFields extends Record<string, any> = {}> {
9
+ readonly slug: TSlug;
9
10
  protected config: Partial<Global>;
10
11
  protected _fields: FieldBuilder<any, any>[];
11
- constructor(slug: string);
12
+ constructor(slug: TSlug);
12
13
  /**
13
14
  * Sets the label for this global in the Admin UI.
14
15
  */
@@ -20,7 +21,7 @@ export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
20
21
  /**
21
22
  * Defines the fields for this global schema.
22
23
  */
23
- fields<T extends readonly any[]>(fields: [...T]): GlobalBuilder<InferFields<T>>;
24
+ fields<T extends readonly any[]>(fields: [...T]): GlobalBuilder<TSlug, InferFields<T>>;
24
25
  /**
25
26
  * Configuration for who can read and update this global.
26
27
  */
@@ -38,7 +39,7 @@ export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
38
39
  apiKey?: any;
39
40
  }) => TReturn | Promise<TReturn>;
40
41
  returnType?: "string" | "number" | "boolean" | "json";
41
- }): GlobalBuilder<TFields & {
42
+ }): GlobalBuilder<TSlug, TFields & {
42
43
  [K in TName]: TReturn;
43
44
  }>;
44
45
  /**
@@ -54,7 +55,7 @@ export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
54
55
  apiKey?: any;
55
56
  }) => TReturn | Promise<TReturn>;
56
57
  returnType?: "string" | "number" | "boolean" | "json";
57
- }): GlobalBuilder<TFields & {
58
+ }): GlobalBuilder<TSlug, TFields & {
58
59
  [K in TName]: TReturn;
59
60
  }>;
60
61
  /**
@@ -64,11 +65,13 @@ export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
64
65
  /**
65
66
  * Compiles the builder down into the raw Global object expected by OpacaCMS.
66
67
  */
67
- build(): Global;
68
+ build(): Global & {
69
+ slug: TSlug;
70
+ };
68
71
  }
69
72
  /**
70
73
  * Singleton factory for creating Globals.
71
74
  */
72
75
  export declare const Global: {
73
- create: (slug: string) => GlobalBuilder<{}>;
76
+ create: <T extends string>(slug: T) => GlobalBuilder<T, {}>;
74
77
  };
@@ -34,8 +34,8 @@ class FieldBuilder {
34
34
  this.config.defaultValue = val;
35
35
  return this;
36
36
  }
37
- validate(fn) {
38
- this.config.validate = fn;
37
+ validate(val) {
38
+ this.config.validate = val;
39
39
  return this;
40
40
  }
41
41
  access(config) {
@@ -146,6 +146,12 @@ class RichTextFieldBuilder extends FieldBuilder {
146
146
  }
147
147
  }
148
148
 
149
+ class UIFieldBuilder extends FieldBuilder {
150
+ constructor(name) {
151
+ super("ui", name);
152
+ }
153
+ }
154
+
149
155
  class RelationshipFieldBuilder extends FieldBuilder {
150
156
  constructor(name) {
151
157
  super("relationship", name);
@@ -188,6 +194,12 @@ class FileFieldBuilder extends FieldBuilder {
188
194
  }
189
195
  }
190
196
 
197
+ class JSONFieldBuilder extends FieldBuilder {
198
+ constructor(name) {
199
+ super("json", name);
200
+ }
201
+ }
202
+
191
203
  class DateFieldBuilder extends FieldBuilder {
192
204
  constructor(name) {
193
205
  super("date", name);
@@ -375,7 +387,9 @@ var Field = {
375
387
  builder.blocks(...blocks);
376
388
  return builder;
377
389
  },
378
- block: (slug) => new BlockBuilder(slug)
390
+ block: (slug) => new BlockBuilder(slug),
391
+ ui: (name) => new UIFieldBuilder(name),
392
+ json: (name) => new JSONFieldBuilder(name)
379
393
  };
380
394
 
381
395
  // src/schema/collection.ts
@@ -407,6 +421,7 @@ class CollectionBuilder {
407
421
  const nextBuilder = new CollectionBuilder(this.config.slug);
408
422
  nextBuilder.config = { ...this.config };
409
423
  nextBuilder.fieldBuilders = [...fields];
424
+ nextBuilder.config.fields = nextBuilder.fieldBuilders.map((f) => f.build());
410
425
  return nextBuilder;
411
426
  }
412
427
  access(rules) {
@@ -424,11 +439,9 @@ class CollectionBuilder {
424
439
  const nextBuilder = new CollectionBuilder(this.config.slug);
425
440
  nextBuilder.config = { ...this.config };
426
441
  nextBuilder.fieldBuilders = [...this.fieldBuilders, builder];
442
+ nextBuilder.config.fields = nextBuilder.fieldBuilders.map((f) => f.build());
427
443
  return nextBuilder;
428
444
  }
429
- computed(name, options) {
430
- return this.virtual(name, options);
431
- }
432
445
  admin(opts) {
433
446
  if (typeof opts === "boolean") {
434
447
  this.config.admin = opts;
@@ -457,6 +470,7 @@ class CollectionBuilder {
457
470
  const compiledFields = this.fieldBuilders.map((builder) => builder.build());
458
471
  return {
459
472
  ...this.config,
473
+ slug: this.slug,
460
474
  fields: compiledFields
461
475
  };
462
476
  }
@@ -466,9 +480,11 @@ var Collection = {
466
480
  };
467
481
  // src/schema/global.ts
468
482
  class GlobalBuilder {
483
+ slug;
469
484
  config = {};
470
485
  _fields = [];
471
486
  constructor(slug) {
487
+ this.slug = slug;
472
488
  this.config.slug = slug;
473
489
  this.config.fields = [];
474
490
  this.config.timestamps = true;
@@ -1,8 +1,8 @@
1
1
  import { Hono } from "hono";
2
2
  import type { Auth } from "../auth";
3
3
  import type { OpacaConfig } from "../types";
4
- import type { ApiContextVariables } from "./router";
5
- export declare function createAdminRouter(config: OpacaConfig, state: {
4
+ import type { ApiContextVariables } from "../server/router";
5
+ export declare function createAdminRouter(config: OpacaConfig, settings: Record<string, any>, state: {
6
6
  auth: Auth | undefined;
7
7
  }): Hono<{
8
8
  Variables: ApiContextVariables;
@@ -7,6 +7,7 @@ type AdminHandlers = {
7
7
  getConfig: (c: Context) => Promise<Response>;
8
8
  getSetupStatus: (c: Context) => Promise<Response>;
9
9
  createApiKey: (c: Context) => Promise<Response>;
10
+ getPluginSettings: (c: Context) => Promise<Response>;
10
11
  };
11
12
  /**
12
13
  * Creates the admin handlers for the OpacaCMS.
@@ -14,5 +15,5 @@ type AdminHandlers = {
14
15
  * @param getAuth A function that returns the authentication instance.
15
16
  * @returns An object containing the admin handlers for hono integration.
16
17
  */
17
- export declare function createAdminHandlers(config: OpacaConfig, getAuth: () => Auth | undefined): AdminHandlers;
18
+ export declare function createAdminHandlers(config: OpacaConfig, settings: Record<string, any>, getAuth: () => Auth | undefined): AdminHandlers;
18
19
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { Hono } from "hono";
2
2
  import type { Auth } from "../auth";
3
3
  import type { OpacaConfig } from "../types";
4
- import type { ApiContextVariables } from "./router";
4
+ import type { ApiContextVariables } from "../server/router";
5
5
  export declare function mountCollectionRoutes(router: Hono<{
6
6
  Variables: ApiContextVariables;
7
7
  }>, config: OpacaConfig, state: {
@@ -8,6 +8,16 @@ import type { Collection, Global, OpacaConfig } from "../types";
8
8
  * @returns hydrated document
9
9
  */
10
10
  export declare const hydrateDoc: (doc: any, fields: any[], c: Context, config: OpacaConfig) => Promise<any>;
11
+ /**
12
+ * Parses the populate query parameter into a nested map.
13
+ * Supports comma-separated dot notation (e.g. "author,comments.user")
14
+ * or a JSON string.
15
+ */
16
+ export declare function parsePopulate(populate: string | any): Record<string, any>;
17
+ /**
18
+ * Populates a document with related documents recursively.
19
+ */
20
+ export declare const populateDoc: (db: any, fields: any[], doc: any, populate: Record<string, any>, config: OpacaConfig) => Promise<any>;
11
21
  /**
12
22
  * Creates handlers for a collection
13
23
  * @param config opaca config
@@ -1,6 +1,6 @@
1
1
  import type { Context, Next } from "hono";
2
2
  export declare const adminMiddleware: (c: Context, next: Next) => Promise<(Response & import("hono").TypedResponse<{
3
3
  message: string;
4
- }, 401, "json">) | (Response & import("hono").TypedResponse<{
4
+ }, 403, "json">) | (Response & import("hono").TypedResponse<{
5
5
  message: string;
6
- }, 403, "json">) | undefined>;
6
+ }, 401, "json">) | undefined>;
@@ -1,4 +1,4 @@
1
- import type { Session, User } from "better-auth";
1
+ import type { Session, User } from "../../types";
2
2
  import type { MiddlewareHandler } from "hono";
3
3
  import type { Auth } from "../../auth";
4
4
  export type AuthContextVariables = {
@@ -1,8 +1,10 @@
1
1
  import type { MiddlewareHandler } from "hono";
2
2
  import type { OpacaConfig } from "../../types";
3
+ import { OpacaLogger } from "../../utils/logger";
3
4
  export type OpacaContextVariables = {
4
5
  config: OpacaConfig;
5
6
  db: OpacaConfig["db"];
7
+ logger: OpacaLogger;
6
8
  };
7
9
  export declare function createContextMiddleware(config: OpacaConfig): MiddlewareHandler<{
8
10
  Variables: OpacaContextVariables;
@@ -1,3 +1,3 @@
1
1
  import type { MiddlewareHandler } from "hono";
2
- import type { OpacaConfig } from "@/types";
2
+ import type { OpacaConfig } from "../../types";
3
3
  export declare function createRateLimitMiddleware(config: OpacaConfig): MiddlewareHandler;
@@ -0,0 +1,2 @@
1
+ import type { OpacaConfig } from "../types";
2
+ export declare function generateOpenAPISchema(config: OpacaConfig): any;
@@ -0,0 +1,6 @@
1
+ import type { OpacaConfig } from "@/types";
2
+ /**
3
+ * Loads all plugin settings from the `_opaca_plugin_settings` collection.
4
+ * Returns a Record where keys are plugin names and values are their configurations.
5
+ */
6
+ export declare function loadPluginSettings(config: OpacaConfig): Promise<Record<string, any>>;
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
2
  import type { OpacaConfig } from "../types";
3
- import { type ApiContextVariables } from "./setup-middlewares";
4
- export type { ApiContextVariables } from "./setup-middlewares";
5
- export declare function createAPIRouter(config: OpacaConfig): Hono<{
3
+ import { type ApiContextVariables } from "../server/setup-middlewares";
4
+ export type { ApiContextVariables } from "../server/setup-middlewares";
5
+ export declare function createAPIRouter(config: OpacaConfig, settings?: Record<string, any>): Hono<{
6
6
  Variables: ApiContextVariables;
7
7
  }>;
@@ -1,8 +1,8 @@
1
1
  import { Hono } from "hono";
2
2
  import type { Auth } from "../../auth";
3
3
  import type { OpacaConfig } from "../../types";
4
- import type { ApiContextVariables } from "../router";
5
- export declare function createAdminRouter(config: OpacaConfig, state: {
4
+ import type { ApiContextVariables } from "../../server/router";
5
+ export declare function createAdminRouter(config: OpacaConfig, settings: Record<string, any>, state: {
6
6
  auth: Auth | undefined;
7
7
  }): Hono<{
8
8
  Variables: ApiContextVariables;
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
2
  import type { Auth } from "../../auth";
3
3
  import type { OpacaConfig } from "../../types";
4
- import type { ApiContextVariables } from "../router";
4
+ import type { ApiContextVariables } from "../../server/router";
5
5
  export declare function createAuthRouter(config: OpacaConfig, state: {
6
6
  auth: Auth | undefined;
7
7
  }): Hono<{
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
2
  import type { Auth } from "../../auth";
3
3
  import type { OpacaConfig } from "../../types";
4
- import type { ApiContextVariables } from "../router";
4
+ import type { ApiContextVariables } from "../../server/router";
5
5
  export declare function mountCollectionRoutes(router: Hono<{
6
6
  Variables: ApiContextVariables;
7
7
  }>, config: OpacaConfig, state: {
@@ -0,0 +1,18 @@
1
+ import type { Hono } from "hono";
2
+ import type { OpacaConfig } from "../../types";
3
+ import type { ApiContextVariables } from "../setup-middlewares";
4
+ /**
5
+ * Mounts all plugin-specific routes and middlewares.
6
+ *
7
+ * @param config - The OpacaCMS configuration.
8
+ * @param settings - The loaded plugin settings.
9
+ * @param logger - The system logger.
10
+ * @param router - The Hono router instance.
11
+ */
12
+ export declare function mountPluginRoutes(config: OpacaConfig, settings: Record<string, any>, logger: typeof import("../../utils/logger").logger, router: Hono<{
13
+ Variables: ApiContextVariables;
14
+ }>): void;
15
+ /**
16
+ * Fires the onInitComplete hook for all plugins.
17
+ */
18
+ export declare function firePluginInitComplete(config: OpacaConfig, settings: Record<string, any>, logger: typeof import("../../utils/logger").logger): void;
@@ -1,8 +1,8 @@
1
1
  import type { Hono } from "hono";
2
2
  import type { Auth } from "../auth";
3
3
  import type { OpacaConfig } from "../types";
4
- import { type AuthContextVariables } from "./middlewares/auth";
5
- import { type OpacaContextVariables } from "./middlewares/context";
4
+ import { type AuthContextVariables } from "../server/middlewares/auth";
5
+ import { type OpacaContextVariables } from "../server/middlewares/context";
6
6
  export type ApiContextVariables = OpacaContextVariables & AuthContextVariables;
7
7
  export declare function setupMiddlewares(router: Hono<{
8
8
  Variables: ApiContextVariables;
@@ -1,6 +1,6 @@
1
1
  import { Hono } from "hono";
2
2
  import type { OpacaConfig } from "../types";
3
- import type { ApiContextVariables } from "./router";
3
+ import type { ApiContextVariables } from "../server/router";
4
4
  export declare function createSystemRouter(config: OpacaConfig): Hono<{
5
5
  Variables: ApiContextVariables;
6
6
  }, import("hono/types").BlankSchema, "/">;
package/dist/server.js CHANGED
@@ -3,20 +3,24 @@ import {
3
3
  createAdminHandlers,
4
4
  createGlobalHandlers,
5
5
  createHandlers,
6
- hydrateDoc
7
- } from "./chunk-xrfhhz85.js";
6
+ hydrateDoc,
7
+ parsePopulate,
8
+ populateDoc
9
+ } from "./chunk-kc4jfnv7.js";
8
10
  import {
9
11
  defineConfig
10
- } from "./chunk-t9v845m2.js";
11
- import"./chunk-mycmsjd9.js";
12
+ } from "./chunk-7y1nbmw6.js";
13
+ import"./chunk-b3kr8w41.js";
12
14
  import {
13
15
  BaseDatabaseAdapter
14
16
  } from "./chunk-s8mqwnm1.js";
15
- import"./chunk-62ev8gnc.js";
16
- import"./chunk-2kyhqvhc.js";
17
- import"./chunk-ybbbqj63.js";
17
+ import"./chunk-qxt9vge8.js";
18
+ import"./chunk-v9z61v3g.js";
19
+ import"./chunk-t0zg026p.js";
18
20
  import"./chunk-8sqjbsgt.js";
19
21
  export {
22
+ populateDoc,
23
+ parsePopulate,
20
24
  hydrateDoc,
21
25
  defineConfig,
22
26
  createHandlers,
@@ -1,4 +1,4 @@
1
- import type { StorageAdapter, StorageAdapterConfig } from "../types";
1
+ import type { StorageAdapter, StorageAdapterConfig } from "../../storage/types";
2
2
  export interface LocalAdapterConfig extends StorageAdapterConfig {
3
3
  uploadDir: string;
4
4
  publicUrl: string;
@@ -1,4 +1,4 @@
1
- import type { StorageAdapter, StorageAdapterConfig } from "../types";
1
+ import type { StorageAdapter, StorageAdapterConfig } from "../../storage/types";
2
2
  export interface S3AdapterConfig extends StorageAdapterConfig {
3
3
  region: string;
4
4
  bucket: string;