opacacms 0.1.20 → 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.
- package/README.md +638 -732
- package/dist/admin/auth-client.d.ts +39 -39
- package/dist/admin/index.d.ts +1 -0
- package/dist/admin/index.js +2397 -1405
- package/dist/admin/react.d.ts +1 -1
- package/dist/admin/react.js +8 -0
- package/dist/admin/router.d.ts +1 -0
- package/dist/admin/stores/ui.d.ts +10 -0
- package/dist/admin/ui/admin-layout.d.ts +4 -4
- package/dist/admin/ui/components/DataDetailView.d.ts +1 -1
- package/dist/admin/ui/components/DetailSheet.d.ts +19 -0
- package/dist/admin/ui/components/PluginSettingsForm.d.ts +11 -0
- package/dist/admin/ui/components/fields/BooleanField.d.ts +2 -1
- package/dist/admin/ui/components/fields/DateField.d.ts +1 -1
- package/dist/admin/ui/components/fields/FieldLabel.d.ts +11 -0
- package/dist/admin/ui/components/fields/FileField.d.ts +1 -1
- package/dist/admin/ui/components/fields/NumberField.d.ts +1 -1
- package/dist/admin/ui/components/fields/RadioField.d.ts +1 -1
- package/dist/admin/ui/components/fields/RelationshipField.d.ts +3 -1
- package/dist/admin/ui/components/fields/SelectField.d.ts +1 -1
- package/dist/admin/ui/components/fields/TextAreaField.d.ts +1 -1
- package/dist/admin/ui/components/fields/TextField.d.ts +1 -1
- package/dist/admin/ui/components/fields/VirtualField.d.ts +1 -0
- package/dist/admin/ui/components/fields/index.d.ts +16 -16
- package/dist/admin/ui/components/fields/richtext-editor/index.d.ts +1 -1
- package/dist/admin/ui/components/media/AssetManagerModal.d.ts +1 -1
- package/dist/admin/ui/components/toast.d.ts +1 -1
- package/dist/admin/ui/components/ui/accordion.d.ts +1 -1
- package/dist/admin/ui/components/ui/button.d.ts +1 -1
- package/dist/admin/ui/components/ui/collapsible.d.ts +1 -1
- package/dist/admin/ui/components/ui/dialog.d.ts +1 -1
- package/dist/admin/ui/components/ui/group.d.ts +1 -1
- package/dist/admin/ui/components/ui/index.d.ts +17 -17
- package/dist/admin/ui/components/ui/input.d.ts +1 -1
- package/dist/admin/ui/components/ui/label.d.ts +1 -1
- package/dist/admin/ui/components/ui/radio-group.d.ts +1 -1
- package/dist/admin/ui/components/ui/relationship.d.ts +4 -4
- package/dist/admin/ui/components/ui/select.d.ts +1 -1
- package/dist/admin/ui/components/ui/sheet.d.ts +1 -1
- package/dist/admin/ui/components/ui/tabs.d.ts +1 -1
- package/dist/admin/ui/components/versions-sheet.d.ts +11 -0
- package/dist/admin/ui/views/media-registry-view.d.ts +1 -1
- package/dist/admin/ui/views/settings-view.d.ts +2 -2
- package/dist/admin/vue.d.ts +17 -0
- package/dist/admin/vue.js +8 -0
- package/dist/admin/webcomponent.js +2 -2
- package/dist/admin.css +1 -1
- package/dist/auth/index.d.ts +101 -41
- package/dist/{chunk-qkn1ykrj.js → chunk-0bq155dy.js} +94 -31
- package/dist/{chunk-2z8wxx9g.js → chunk-0gtxnxmd.js} +98 -25
- package/dist/{chunk-v521d72w.js → chunk-3rdhbedb.js} +1 -1
- package/dist/chunk-51z3x7kq.js +20 -0
- package/dist/{chunk-7fyepksb.js → chunk-526a3gqx.js} +1 -1
- package/dist/{chunk-wmvjvn7b.js → chunk-6qq3ne6b.js} +39 -1
- package/dist/{chunk-0am1m47g.js → chunk-6v1fw7q7.js} +5 -5
- package/dist/{chunk-zvwb67nd.js → chunk-7y1nbmw6.js} +36 -5
- package/dist/chunk-8scgdznr.js +44 -0
- package/dist/{chunk-erh6x75p.js → chunk-b3kr8w41.js} +58 -7
- package/dist/chunk-bexcv7xe.js +36 -0
- package/dist/{chunk-16vgcf3k.js → chunk-byq8g0rd.js} +1 -1
- package/dist/{chunk-wq314kkx.js → chunk-d1asgtke.js} +94 -31
- package/dist/{chunk-xtwc125q.js → chunk-dykn5hr6.js} +8 -8
- package/dist/{chunk-pxh5encs.js → chunk-esrg9qj0.js} +102 -44
- package/dist/chunk-fj19qccp.js +78 -0
- package/dist/{chunk-x2ejaftz.js → chunk-gmee4mdc.js} +98 -27
- package/dist/{chunk-xa7rjsn2.js → chunk-j53pz21t.js} +2 -2
- package/dist/{chunk-9y3m1xkx.js → chunk-kc4jfnv7.js} +480 -85
- package/dist/chunk-mkn49zmy.js +102 -0
- package/dist/{chunk-n1xraw7j.js → chunk-qb6ztvw9.js} +1 -1
- package/dist/{chunk-2kyhqvhc.js → chunk-qxt9vge8.js} +1 -1
- package/dist/chunk-r39em4yj.js +29 -0
- package/dist/chunk-rqyjjqgy.js +91 -0
- package/dist/chunk-rsf0tpy1.js +8 -0
- package/dist/chunk-swtcpvhf.js +2442 -0
- package/dist/chunk-t0zg026p.js +71 -0
- package/dist/chunk-twpvxfce.js +64 -0
- package/dist/{chunk-ybbbqj63.js → chunk-v9z61v3g.js} +15 -0
- package/dist/{chunk-jwjk85ze.js → chunk-ywm4t2gm.js} +6 -2
- package/dist/cli/commands/plugin-build.d.ts +1 -0
- package/dist/cli/commands/plugin-init.d.ts +1 -0
- package/dist/cli/commands/plugin-sync.d.ts +1 -0
- package/dist/cli/index.js +24 -6
- package/dist/config-utils.d.ts +1 -1
- package/dist/config.d.ts +21 -4
- package/dist/db/better-sqlite.d.ts +1 -1
- package/dist/db/better-sqlite.js +5 -5
- package/dist/db/bun-sqlite.d.ts +1 -1
- package/dist/db/bun-sqlite.js +5 -5
- package/dist/db/d1.d.ts +1 -1
- package/dist/db/d1.js +5 -5
- package/dist/db/index.js +9 -9
- package/dist/db/postgres.d.ts +1 -1
- package/dist/db/postgres.js +5 -5
- package/dist/db/sqlite.d.ts +1 -1
- package/dist/db/sqlite.js +5 -5
- package/dist/index.js +4 -3
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/ui-bridge.d.ts +12 -0
- package/dist/plugins/utils.d.ts +5 -0
- package/dist/runtimes/bun.js +13 -7
- package/dist/runtimes/cloudflare-workers.js +5 -5
- package/dist/runtimes/next.js +5 -5
- package/dist/runtimes/node.js +13 -7
- package/dist/schema/collection.d.ts +9 -30
- package/dist/schema/fields/base.d.ts +3 -2
- package/dist/schema/fields/index.d.ts +12 -0
- package/dist/schema/fields/validation.test.d.ts +1 -0
- package/dist/schema/global.d.ts +10 -15
- package/dist/schema/index.js +22 -14
- package/dist/server/admin-router.d.ts +2 -2
- package/dist/server/admin.d.ts +2 -1
- package/dist/server/collection-router.d.ts +1 -1
- package/dist/server/handlers.d.ts +10 -0
- package/dist/server/middlewares/admin.d.ts +2 -2
- package/dist/server/middlewares/auth.d.ts +1 -1
- package/dist/server/middlewares/context.d.ts +2 -0
- package/dist/server/middlewares/rate-limit.d.ts +1 -1
- package/dist/server/openapi.d.ts +2 -0
- package/dist/server/plugins-loader.d.ts +6 -0
- package/dist/server/router.d.ts +3 -3
- package/dist/server/routers/admin.d.ts +2 -2
- package/dist/server/routers/auth.d.ts +1 -1
- package/dist/server/routers/collections.d.ts +1 -1
- package/dist/server/routers/plugins.d.ts +18 -0
- package/dist/server/setup-middlewares.d.ts +2 -2
- package/dist/server/system-router.d.ts +1 -1
- package/dist/server.js +11 -7
- package/dist/storage/adapters/local.d.ts +1 -1
- package/dist/storage/adapters/s3.d.ts +1 -1
- package/dist/types.d.ts +227 -12
- package/dist/utils/logger.d.ts +13 -35
- package/dist/validation.d.ts +60 -8
- package/dist/validator.d.ts +1 -1
- package/package.json +21 -7
- package/dist/admin/ui/components/DataDetailSheet.d.ts +0 -13
- package/dist/admin/ui/components/ui/relationship-detail-sheet.d.ts +0 -9
- package/dist/chunk-62ev8gnc.js +0 -41
- package/dist/chunk-j4d50hrx.js +0 -20
- 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:
|
|
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:
|
|
10
|
+
constructor(slug: TSlug);
|
|
11
11
|
/**
|
|
12
12
|
* Sets the user-friendly label for the Collection.
|
|
13
13
|
*/
|
|
@@ -20,15 +20,11 @@ export declare class CollectionBuilder<TFields extends Record<string, any> = {}>
|
|
|
20
20
|
* Defines which field should be used as the title in the Admin UI.
|
|
21
21
|
*/
|
|
22
22
|
useAsTitle(fieldName: keyof TFields | (string & {})): this;
|
|
23
|
-
/**
|
|
24
|
-
* Enables or disables automatic timestamps (createdAt, updatedAt).
|
|
25
|
-
*/
|
|
26
|
-
timestamps(val?: boolean): this;
|
|
27
23
|
/**
|
|
28
24
|
* Defines the fields for this Collection.
|
|
29
25
|
* Re-instantiates the builder to capture the strong types of the fields.
|
|
30
26
|
*/
|
|
31
|
-
fields<T extends readonly any[]>(fields: [...T]): CollectionBuilder<InferFields<T>>;
|
|
27
|
+
fields<T extends readonly any[]>(fields: [...T]): CollectionBuilder<TSlug, InferFields<T>>;
|
|
32
28
|
/**
|
|
33
29
|
* Type-safe access control rules.
|
|
34
30
|
*/
|
|
@@ -46,23 +42,7 @@ export declare class CollectionBuilder<TFields extends Record<string, any> = {}>
|
|
|
46
42
|
apiKey?: any;
|
|
47
43
|
}) => TReturn | Promise<TReturn>;
|
|
48
44
|
returnType?: "string" | "number" | "boolean" | "json";
|
|
49
|
-
}): CollectionBuilder<TFields & {
|
|
50
|
-
[K in TName]: TReturn;
|
|
51
|
-
}>;
|
|
52
|
-
/**
|
|
53
|
-
* Alias for .virtual()
|
|
54
|
-
*/
|
|
55
|
-
computed<TName extends string, TReturn = any>(name: TName, options: {
|
|
56
|
-
label?: string;
|
|
57
|
-
resolve: (args: {
|
|
58
|
-
data: TFields;
|
|
59
|
-
req: any;
|
|
60
|
-
user: any;
|
|
61
|
-
session: any;
|
|
62
|
-
apiKey?: any;
|
|
63
|
-
}) => TReturn | Promise<TReturn>;
|
|
64
|
-
returnType?: "string" | "number" | "boolean" | "json";
|
|
65
|
-
}): CollectionBuilder<TFields & {
|
|
45
|
+
}): CollectionBuilder<TSlug, TFields & {
|
|
66
46
|
[K in TName]: TReturn;
|
|
67
47
|
}>;
|
|
68
48
|
/**
|
|
@@ -90,11 +70,10 @@ export declare class CollectionBuilder<TFields extends Record<string, any> = {}>
|
|
|
90
70
|
*/
|
|
91
71
|
extend(preset: any): this;
|
|
92
72
|
protected _ensureAdmin(): void;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
build(): BaseCollection;
|
|
73
|
+
build(): BaseCollection & {
|
|
74
|
+
slug: TSlug;
|
|
75
|
+
};
|
|
97
76
|
}
|
|
98
77
|
export declare const Collection: {
|
|
99
|
-
create: (slug:
|
|
78
|
+
create: <T extends string>(slug: T) => CollectionBuilder<T, {}>;
|
|
100
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(
|
|
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 {};
|
package/dist/schema/global.d.ts
CHANGED
|
@@ -5,18 +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:
|
|
12
|
-
/**
|
|
13
|
-
* Enables or disables timestamps (createdAt, updatedAt) for this global.
|
|
14
|
-
* Defaults to true.
|
|
15
|
-
*/
|
|
16
|
-
timestamps(enabled?: boolean | {
|
|
17
|
-
createdAt?: string;
|
|
18
|
-
updatedAt?: string;
|
|
19
|
-
}): this;
|
|
12
|
+
constructor(slug: TSlug);
|
|
20
13
|
/**
|
|
21
14
|
* Sets the label for this global in the Admin UI.
|
|
22
15
|
*/
|
|
@@ -28,7 +21,7 @@ export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
|
|
|
28
21
|
/**
|
|
29
22
|
* Defines the fields for this global schema.
|
|
30
23
|
*/
|
|
31
|
-
fields<T extends readonly any[]>(fields: [...T]): GlobalBuilder<InferFields<T>>;
|
|
24
|
+
fields<T extends readonly any[]>(fields: [...T]): GlobalBuilder<TSlug, InferFields<T>>;
|
|
32
25
|
/**
|
|
33
26
|
* Configuration for who can read and update this global.
|
|
34
27
|
*/
|
|
@@ -46,7 +39,7 @@ export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
|
|
|
46
39
|
apiKey?: any;
|
|
47
40
|
}) => TReturn | Promise<TReturn>;
|
|
48
41
|
returnType?: "string" | "number" | "boolean" | "json";
|
|
49
|
-
}): GlobalBuilder<TFields & {
|
|
42
|
+
}): GlobalBuilder<TSlug, TFields & {
|
|
50
43
|
[K in TName]: TReturn;
|
|
51
44
|
}>;
|
|
52
45
|
/**
|
|
@@ -62,7 +55,7 @@ export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
|
|
|
62
55
|
apiKey?: any;
|
|
63
56
|
}) => TReturn | Promise<TReturn>;
|
|
64
57
|
returnType?: "string" | "number" | "boolean" | "json";
|
|
65
|
-
}): GlobalBuilder<TFields & {
|
|
58
|
+
}): GlobalBuilder<TSlug, TFields & {
|
|
66
59
|
[K in TName]: TReturn;
|
|
67
60
|
}>;
|
|
68
61
|
/**
|
|
@@ -72,11 +65,13 @@ export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
|
|
|
72
65
|
/**
|
|
73
66
|
* Compiles the builder down into the raw Global object expected by OpacaCMS.
|
|
74
67
|
*/
|
|
75
|
-
build(): Global
|
|
68
|
+
build(): Global & {
|
|
69
|
+
slug: TSlug;
|
|
70
|
+
};
|
|
76
71
|
}
|
|
77
72
|
/**
|
|
78
73
|
* Singleton factory for creating Globals.
|
|
79
74
|
*/
|
|
80
75
|
export declare const Global: {
|
|
81
|
-
create: (slug:
|
|
76
|
+
create: <T extends string>(slug: T) => GlobalBuilder<T, {}>;
|
|
82
77
|
};
|
package/dist/schema/index.js
CHANGED
|
@@ -34,8 +34,8 @@ class FieldBuilder {
|
|
|
34
34
|
this.config.defaultValue = val;
|
|
35
35
|
return this;
|
|
36
36
|
}
|
|
37
|
-
validate(
|
|
38
|
-
this.config.validate =
|
|
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
|
|
@@ -403,14 +417,11 @@ class CollectionBuilder {
|
|
|
403
417
|
this.config.admin.useAsTitle = fieldName;
|
|
404
418
|
return this;
|
|
405
419
|
}
|
|
406
|
-
timestamps(val = true) {
|
|
407
|
-
this.config.timestamps = val;
|
|
408
|
-
return this;
|
|
409
|
-
}
|
|
410
420
|
fields(fields) {
|
|
411
421
|
const nextBuilder = new CollectionBuilder(this.config.slug);
|
|
412
422
|
nextBuilder.config = { ...this.config };
|
|
413
423
|
nextBuilder.fieldBuilders = [...fields];
|
|
424
|
+
nextBuilder.config.fields = nextBuilder.fieldBuilders.map((f) => f.build());
|
|
414
425
|
return nextBuilder;
|
|
415
426
|
}
|
|
416
427
|
access(rules) {
|
|
@@ -428,11 +439,9 @@ class CollectionBuilder {
|
|
|
428
439
|
const nextBuilder = new CollectionBuilder(this.config.slug);
|
|
429
440
|
nextBuilder.config = { ...this.config };
|
|
430
441
|
nextBuilder.fieldBuilders = [...this.fieldBuilders, builder];
|
|
442
|
+
nextBuilder.config.fields = nextBuilder.fieldBuilders.map((f) => f.build());
|
|
431
443
|
return nextBuilder;
|
|
432
444
|
}
|
|
433
|
-
computed(name, options) {
|
|
434
|
-
return this.virtual(name, options);
|
|
435
|
-
}
|
|
436
445
|
admin(opts) {
|
|
437
446
|
if (typeof opts === "boolean") {
|
|
438
447
|
this.config.admin = opts;
|
|
@@ -461,6 +470,7 @@ class CollectionBuilder {
|
|
|
461
470
|
const compiledFields = this.fieldBuilders.map((builder) => builder.build());
|
|
462
471
|
return {
|
|
463
472
|
...this.config,
|
|
473
|
+
slug: this.slug,
|
|
464
474
|
fields: compiledFields
|
|
465
475
|
};
|
|
466
476
|
}
|
|
@@ -470,17 +480,15 @@ var Collection = {
|
|
|
470
480
|
};
|
|
471
481
|
// src/schema/global.ts
|
|
472
482
|
class GlobalBuilder {
|
|
483
|
+
slug;
|
|
473
484
|
config = {};
|
|
474
485
|
_fields = [];
|
|
475
486
|
constructor(slug) {
|
|
487
|
+
this.slug = slug;
|
|
476
488
|
this.config.slug = slug;
|
|
477
489
|
this.config.fields = [];
|
|
478
490
|
this.config.timestamps = true;
|
|
479
491
|
}
|
|
480
|
-
timestamps(enabled = true) {
|
|
481
|
-
this.config.timestamps = enabled;
|
|
482
|
-
return this;
|
|
483
|
-
}
|
|
484
492
|
label(label) {
|
|
485
493
|
this.config.label = label;
|
|
486
494
|
return this;
|
|
@@ -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 "
|
|
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;
|
package/dist/server/admin.d.ts
CHANGED
|
@@ -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 "
|
|
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
|
-
},
|
|
4
|
+
}, 403, "json">) | (Response & import("hono").TypedResponse<{
|
|
5
5
|
message: string;
|
|
6
|
-
},
|
|
6
|
+
}, 401, "json">) | undefined>;
|
|
@@ -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;
|
|
@@ -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>>;
|
package/dist/server/router.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import type { OpacaConfig } from "../types";
|
|
3
|
-
import { type ApiContextVariables } from "
|
|
4
|
-
export type { ApiContextVariables } from "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
5
|
-
import { type OpacaContextVariables } from "
|
|
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 "
|
|
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
|
-
|
|
6
|
+
hydrateDoc,
|
|
7
|
+
parsePopulate,
|
|
8
|
+
populateDoc
|
|
9
|
+
} from "./chunk-kc4jfnv7.js";
|
|
8
10
|
import {
|
|
9
11
|
defineConfig
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import"./chunk-
|
|
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-
|
|
16
|
-
import"./chunk-
|
|
17
|
-
import"./chunk-
|
|
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,
|