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.
- package/README.md +31 -22
- package/dist/admin/auth-client.d.ts +39 -39
- package/dist/admin/index.d.ts +2 -2
- package/dist/admin/index.js +15 -10520
- package/dist/admin/plugin-client.d.ts +65 -0
- package/dist/admin/react.d.ts +2 -2
- package/dist/admin/react.js +34 -4
- package/dist/admin/stores/ui.d.ts +19 -4
- package/dist/admin/ui/components/PluginSettingsForm.d.ts +2 -2
- package/dist/admin/ui/components/custom-alert.d.ts +7 -0
- package/dist/admin/ui/components/{DetailSheet.d.ts → detail-sheet.d.ts} +1 -2
- package/dist/admin/ui/components/fields/FieldLabel.d.ts +1 -1
- package/dist/admin/ui/components/fields/RelationshipField.d.ts +1 -1
- package/dist/admin/ui/components/media/AssetManagerModal.d.ts +2 -2
- package/dist/admin/ui/components/plugin-iframe.d.ts +7 -0
- package/dist/admin/ui/components/ui/accordion.d.ts +17 -7
- package/dist/admin/ui/components/ui/alert-dialog.d.ts +16 -12
- package/dist/admin/ui/components/ui/button.d.ts +11 -7
- package/dist/admin/ui/components/ui/relationship.d.ts +1 -1
- package/dist/admin/ui/components/ui/sheet.d.ts +14 -27
- package/dist/admin/ui/components/ui/tooltip.d.ts +7 -0
- package/dist/admin/ui/components/versions-sheet.d.ts +4 -5
- package/dist/admin/ui/views/collection-list-view.d.ts +1 -1
- package/dist/admin/ui/views/dashboard-view.d.ts +1 -1
- package/dist/admin/ui/views/media-registry-view.d.ts +3 -3
- package/dist/admin/ui/views/settings-view.d.ts +2 -2
- package/dist/admin/vue.js +27 -4
- package/dist/admin/webcomponent.js +66 -16
- package/dist/admin.css +1 -1
- package/dist/auth/index.d.ts +43 -43
- package/dist/{chunk-7y1nbmw6.js → chunk-1bd7fz7n.js} +32 -2
- package/dist/chunk-1qm0m8r8.js +413 -0
- package/dist/chunk-2k3ysje3.js +31 -0
- package/dist/{chunk-jdfw4v3r.js → chunk-3j9zjfmn.js} +95 -30
- package/dist/{chunk-byq8g0rd.js → chunk-48ywpd0a.js} +16 -22
- package/dist/{chunk-tfnaf41w.js → chunk-5422w4eq.js} +41 -25
- package/dist/chunk-56n342hs.js +95 -0
- package/dist/chunk-5b8r0v8c.js +47 -0
- package/dist/chunk-63yg00vx.js +263 -0
- package/dist/{chunk-8sqjbsgt.js → chunk-6bywt602.js} +26 -1
- package/dist/{chunk-v9z61v3g.js → chunk-6qs0g65f.js} +43 -3
- package/dist/chunk-7rr5p01g.js +581 -0
- package/dist/{chunk-2es275xs.js → chunk-941zxavt.js} +867 -322
- package/dist/{chunk-51z3x7kq.js → chunk-a3qae86h.js} +1 -1
- package/dist/{chunk-3rdhbedb.js → chunk-adq2b75c.js} +2 -2
- package/dist/chunk-d0tb1xjw.js +93 -0
- package/dist/chunk-d7cgd6vn.js +318 -0
- package/dist/{chunk-6d1vdfwa.js → chunk-e0g6gn7n.js} +54 -75
- package/dist/chunk-ec4jhybj.js +1137 -0
- package/dist/chunk-fatyf6f7.js +221 -0
- package/dist/{chunk-526a3gqx.js → chunk-fnsf1dfm.js} +1 -1
- package/dist/chunk-g9bxb6h0.js +205 -0
- package/dist/chunk-gyaf5kgf.js +10 -0
- package/dist/{chunk-9kxpbcb1.js → chunk-h6dhexzr.js} +16 -7
- package/dist/{chunk-dykn5hr6.js → chunk-j8js1y0h.js} +31 -74
- package/dist/{chunk-t0zg026p.js → chunk-jq1drsen.js} +12 -1
- package/dist/{chunk-b3kr8w41.js → chunk-m24yqkeq.js} +38 -26
- package/dist/chunk-m5ems3hh.js +410 -0
- package/dist/{chunk-8scgdznr.js → chunk-m83ybzf8.js} +15 -18
- package/dist/chunk-majsbncm.js +98 -0
- package/dist/chunk-mp2gt9yh.js +237 -0
- package/dist/chunk-n1twhqmf.js +54 -0
- package/dist/{chunk-bygjkgrx.js → chunk-naqcqj8n.js} +57 -80
- package/dist/chunk-q5sb5dcr.js +15 -0
- package/dist/{chunk-06ks4ggh.js → chunk-qhdsjek6.js} +49 -89
- package/dist/{chunk-n133qpsm.js → chunk-qsh2nqz3.js} +50 -81
- package/dist/chunk-r0ms5tk1.js +76 -0
- package/dist/chunk-rwqwsanx.js +75 -0
- package/dist/chunk-sqsfk9p4.js +700 -0
- package/dist/{chunk-5gvbp2qa.js → chunk-x7bnzswh.js} +25 -18
- package/dist/cli/commands/dev.d.ts +8 -0
- package/dist/cli/commands/doctor.d.ts +8 -0
- package/dist/cli/commands/generate.d.ts +26 -0
- package/dist/cli/commands/init.d.ts +13 -1
- package/dist/cli/commands/migrate.d.ts +33 -0
- package/dist/cli/commands/plugin.d.ts +13 -0
- package/dist/cli/commands/seed.d.ts +21 -0
- package/dist/cli/{commands/migrate-commands.d.ts → core/migrations/migrate-logic.d.ts} +2 -2
- package/dist/cli/core/migrations/schema-diff-engine.d.ts +12 -0
- package/dist/cli/core/migrations/schema-diff.d.ts +11 -0
- package/dist/cli/{seeding.d.ts → core/seeding/auto-seed.d.ts} +7 -4
- package/dist/cli/core/seeding/seed-logic.d.ts +2 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.js +6 -170
- package/dist/client/RichText.d.ts +5 -0
- package/dist/client/rich-text-utils.d.ts +5 -0
- package/dist/client.js +3 -2
- package/dist/config.d.ts +3 -3
- package/dist/db/better-sqlite.d.ts +2 -3
- package/dist/db/better-sqlite.js +6 -5
- package/dist/db/bun-sqlite.d.ts +2 -3
- package/dist/db/bun-sqlite.js +6 -5
- package/dist/db/d1.d.ts +13 -7
- package/dist/db/d1.js +6 -5
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.js +10 -12
- package/dist/db/kysely/factory.d.ts +29 -0
- package/dist/db/kysely/plugins/audit-logging.d.ts +48 -0
- package/dist/db/kysely/plugins/auto-timestamps.d.ts +38 -0
- package/dist/db/kysely/plugins/cursor-pagination.d.ts +42 -0
- package/dist/db/kysely/plugins/deadlock-handler.d.ts +47 -0
- package/dist/db/kysely/plugins/draft-swapper.d.ts +33 -0
- package/dist/db/kysely/plugins/field-masking.d.ts +45 -0
- package/dist/db/kysely/plugins/fts-normalizer.d.ts +38 -0
- package/dist/db/kysely/plugins/i18n-fallback.d.ts +48 -0
- package/dist/db/kysely/plugins/id-generation.d.ts +42 -0
- package/dist/db/kysely/plugins/index.d.ts +16 -0
- package/dist/db/kysely/plugins/json-flattener.d.ts +38 -0
- package/dist/db/kysely/plugins/relationship-preloading.d.ts +39 -0
- package/dist/db/kysely/plugins/slug-generation.d.ts +37 -0
- package/dist/db/kysely/plugins/soft-delete.d.ts +42 -0
- package/dist/db/kysely/plugins/tree-resolver.d.ts +39 -0
- package/dist/db/kysely/plugins/virtual-field-resolver.d.ts +54 -0
- package/dist/db/kysely/plugins/zod-coercion.d.ts +34 -0
- package/dist/db/kysely/snapshot/snapshot-manager.d.ts +18 -0
- package/dist/db/postgres.d.ts +2 -2
- package/dist/db/postgres.js +6 -5
- package/dist/db/sqlite.d.ts +2 -3
- package/dist/db/sqlite.js +6 -5
- package/dist/index.d.ts +3 -0
- package/dist/index.js +161 -7
- package/dist/runtimes/bun.js +9 -6
- package/dist/runtimes/cloudflare-workers.d.ts +3 -1
- package/dist/runtimes/cloudflare-workers.js +36 -7
- package/dist/runtimes/next.js +8 -5
- package/dist/runtimes/node.js +9 -6
- package/dist/schema/collection.d.ts +116 -70
- package/dist/schema/compiler.d.ts +6 -0
- package/dist/schema/global.d.ts +38 -71
- package/dist/schema/index.d.ts +5 -4
- package/dist/schema/index.js +35 -550
- package/dist/schema/zod.d.ts +564 -0
- package/dist/server/admin-router.d.ts +1 -1
- package/dist/server/collection-router.d.ts +1 -1
- package/dist/server/graphql.d.ts +6 -0
- package/dist/server/handlers.d.ts +25 -7
- package/dist/server/middlewares/auth.d.ts +1 -1
- package/dist/server/plugins-loader.d.ts +1 -1
- package/dist/server/router.d.ts +2 -2
- package/dist/server/routers/admin.d.ts +1 -1
- package/dist/server/routers/auth.d.ts +1 -1
- package/dist/server/routers/collections.d.ts +4 -1
- package/dist/server/routers/plugins.d.ts +2 -2
- package/dist/server/setup-middlewares.d.ts +1 -1
- package/dist/server/system-router.d.ts +1 -1
- package/dist/server.js +11 -6
- package/dist/storage/adapters/cloudflare-r2.d.ts +11 -2
- package/dist/storage/index.js +5 -5
- package/dist/types.d.ts +253 -42
- package/dist/utils/context.d.ts +14 -0
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/string.d.ts +10 -0
- package/dist/utils/webhooks-engine.d.ts +24 -0
- package/dist/validation.d.ts +67 -1
- package/dist/validator.d.ts +1 -0
- package/package.json +50 -11
- package/src/cli/index.ts +117 -0
- package/dist/chunk-6qq3ne6b.js +0 -288
- package/dist/chunk-6v1fw7q7.js +0 -126
- package/dist/chunk-7a9kn0np.js +0 -116
- package/dist/chunk-bexcv7xe.js +0 -36
- package/dist/chunk-d3ffeqp9.js +0 -87
- package/dist/chunk-fj19qccp.js +0 -78
- package/dist/chunk-g1jb60xd.js +0 -17
- package/dist/chunk-j53pz21t.js +0 -20
- package/dist/chunk-mkn49zmy.js +0 -102
- package/dist/chunk-r39em4yj.js +0 -29
- package/dist/chunk-rsf0tpy1.js +0 -8
- package/dist/chunk-srsac177.js +0 -85
- package/dist/chunk-twpvxfce.js +0 -64
- package/dist/chunk-ywm4t2gm.js +0 -19
- package/dist/cli/commands/plugin-sync.d.ts +0 -1
- package/dist/cli/commands/seed-command.d.ts +0 -2
- package/dist/plugins/ui-bridge.d.ts +0 -12
- package/dist/schema/fields/base.d.ts +0 -84
- package/dist/schema/fields/index.d.ts +0 -147
- package/dist/schema/infer.d.ts +0 -55
- /package/dist/admin/ui/components/{ColumnVisibilityToggle.d.ts → column-visibility-toggle.d.ts} +0 -0
- /package/dist/admin/ui/components/{DataDetailView.d.ts → data-detail-view.d.ts} +0 -0
- /package/dist/cli/{d1-mock.d.ts → core/mocks/d1-mock.d.ts} +0 -0
- /package/dist/cli/{r2-mock.d.ts → core/mocks/r2-mock.d.ts} +0 -0
- /package/dist/cli/{commands → core/plugins}/plugin-build.d.ts +0 -0
- /package/dist/cli/{commands → core/plugins}/plugin-init.d.ts +0 -0
- /package/dist/cli/{commands → core/types}/generate-types.d.ts +0 -0
- /package/dist/{schema/fields/validation.test.d.ts → cli/seeding.test.d.ts} +0 -0
|
@@ -1,79 +1,125 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
55
|
+
* Seed function for the collection.
|
|
56
|
+
* @param faker faker instance
|
|
57
|
+
* @returns Partial<T> or Promise<Partial<T>>
|
|
70
58
|
*/
|
|
71
|
-
|
|
72
|
-
protected _ensureAdmin(): void;
|
|
73
|
-
build(): BaseCollection & {
|
|
74
|
-
slug: TSlug;
|
|
75
|
-
};
|
|
59
|
+
seed?: (faker: Faker) => Partial<T> | Promise<Partial<T>>;
|
|
76
60
|
}
|
|
77
|
-
export
|
|
78
|
-
|
|
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[];
|
package/dist/schema/global.d.ts
CHANGED
|
@@ -1,77 +1,44 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
*
|
|
16
|
+
* Seed function for the global.
|
|
17
|
+
* @param faker faker instance
|
|
18
|
+
* @returns Partial<T> or Promise<Partial<T>>
|
|
67
19
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
*
|
|
26
|
+
* Zod-based replacement for the legacy GlobalBuilder.
|
|
74
27
|
*/
|
|
75
|
-
export declare
|
|
76
|
-
|
|
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
|
};
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { Collection,
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export type { Collection, Field } from "../types";
|
|
2
|
+
export * from "./collection";
|
|
3
|
+
export * from "./compiler";
|
|
4
|
+
export * from "./global";
|
|
5
|
+
export * from "./zod";
|