opacacms 0.2.0 → 0.3.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 +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 +20 -2
- 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-3j9zjfmn.js +376 -0
- package/dist/{chunk-byq8g0rd.js → chunk-48ywpd0a.js} +16 -22
- package/dist/{chunk-esrg9qj0.js → chunk-5422w4eq.js} +70 -54
- 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-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-0bq155dy.js → chunk-e0g6gn7n.js} +89 -100
- 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-gmee4mdc.js → chunk-naqcqj8n.js} +92 -106
- package/dist/chunk-q5sb5dcr.js +15 -0
- package/dist/{chunk-d1asgtke.js → chunk-qhdsjek6.js} +90 -121
- package/dist/{chunk-0gtxnxmd.js → chunk-qsh2nqz3.js} +85 -105
- 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/{chunk-kc4jfnv7.js → chunk-z3ffn2b7.js} +851 -324
- 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/adapter.d.ts +2 -2
- package/dist/db/better-sqlite.d.ts +3 -3
- package/dist/db/better-sqlite.js +6 -5
- package/dist/db/bun-sqlite.d.ts +3 -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 +4 -4
- package/dist/db/postgres.js +6 -5
- package/dist/db/sqlite.d.ts +3 -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 +39 -30
- package/dist/types.d.ts +255 -44
- 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 +36 -33
- 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-j53pz21t.js +0 -20
- package/dist/chunk-mkn49zmy.js +0 -102
- package/dist/chunk-qb6ztvw9.js +0 -17
- package/dist/chunk-r39em4yj.js +0 -29
- package/dist/chunk-rsf0tpy1.js +0 -8
- package/dist/chunk-srsac177.js +0 -85
- package/dist/chunk-swtcpvhf.js +0 -2442
- 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
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_picocolors
|
|
3
|
+
} from "./chunk-rwqwsanx.js";
|
|
4
|
+
import {
|
|
5
|
+
Ct,
|
|
6
|
+
Nt,
|
|
7
|
+
R,
|
|
8
|
+
Vt,
|
|
9
|
+
Zt
|
|
10
|
+
} from "./chunk-ec4jhybj.js";
|
|
11
|
+
import {
|
|
12
|
+
defineCommand
|
|
13
|
+
} from "./chunk-1qm0m8r8.js";
|
|
14
|
+
import {
|
|
15
|
+
__toESM
|
|
16
|
+
} from "./chunk-6bywt602.js";
|
|
17
|
+
|
|
18
|
+
// src/cli/commands/generate.ts
|
|
19
|
+
import fs2 from "node:fs";
|
|
20
|
+
import { resolve as resolve2 } from "node:path";
|
|
21
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
22
|
+
|
|
23
|
+
// src/cli/core/types/generate-types.ts
|
|
24
|
+
import fs from "node:fs";
|
|
25
|
+
import { resolve } from "node:path";
|
|
26
|
+
async function generateTypesCommand(url, token, out) {
|
|
27
|
+
console.log(`[OpacaCMS] Fetching metadata from ${url}/api/__admin/metadata...`);
|
|
28
|
+
let data;
|
|
29
|
+
try {
|
|
30
|
+
const res = await fetch(`${url.replace(/\/$/, "")}/api/__admin/metadata`, {
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${token}`
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
if (res.status === 401 || res.status === 403) {
|
|
37
|
+
throw new Error("Authentication failed. Ensure your API Key is correct and has the necessary permissions.");
|
|
38
|
+
}
|
|
39
|
+
const errorText = await res.text().catch(() => "Unknown error");
|
|
40
|
+
throw new Error(`Server responded with ${res.status}: ${errorText}`);
|
|
41
|
+
}
|
|
42
|
+
data = await res.json();
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.error(`[OpacaCMS] Failed to fetch metadata: ${err.message}`);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
console.log(`[OpacaCMS] Successfully fetched metadata for ${data.collections.length} collections and ${data.globals?.length || 0} globals.`);
|
|
48
|
+
let dtsContent = `// Automatically generated by OpacaCMS CLI
|
|
49
|
+
// Do not edit this file manually
|
|
50
|
+
|
|
51
|
+
export interface OpacaAsset {
|
|
52
|
+
assetId: string;
|
|
53
|
+
url: string;
|
|
54
|
+
filename: string;
|
|
55
|
+
mime_type: string;
|
|
56
|
+
filesize: number;
|
|
57
|
+
meta?: Record<string, any>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface OpacaCollections {
|
|
61
|
+
collections: {
|
|
62
|
+
`;
|
|
63
|
+
for (const collection of data.collections) {
|
|
64
|
+
dtsContent += ` "${collection.slug}": {
|
|
65
|
+
`;
|
|
66
|
+
dtsContent += ` id: string | number;
|
|
67
|
+
`;
|
|
68
|
+
for (const field of collection.fields) {
|
|
69
|
+
const typeStr = mapFieldToTsType(field.type);
|
|
70
|
+
const isOptional = field.required ? "" : "?";
|
|
71
|
+
dtsContent += ` ${field.name}${isOptional}: ${typeStr};
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
if (collection.timestamps) {
|
|
75
|
+
dtsContent += ` createdAt: string;
|
|
76
|
+
`;
|
|
77
|
+
dtsContent += ` updatedAt: string;
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
dtsContent += ` };
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
dtsContent += ` };
|
|
84
|
+
`;
|
|
85
|
+
if (data.globals && data.globals.length > 0) {
|
|
86
|
+
dtsContent += ` globals: {
|
|
87
|
+
`;
|
|
88
|
+
for (const globalConf of data.globals) {
|
|
89
|
+
dtsContent += ` "${globalConf.slug}": {
|
|
90
|
+
`;
|
|
91
|
+
for (const field of globalConf.fields) {
|
|
92
|
+
const typeStr = mapFieldToTsType(field.type);
|
|
93
|
+
const isOptional = field.required ? "" : "?";
|
|
94
|
+
dtsContent += ` ${field.name}${isOptional}: ${typeStr};
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
dtsContent += ` };
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
dtsContent += ` };
|
|
101
|
+
`;
|
|
102
|
+
} else {
|
|
103
|
+
dtsContent += ` globals: Record<string, any>;
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
dtsContent += `}
|
|
107
|
+
`;
|
|
108
|
+
const outputPath = resolve(process.cwd(), out || "opaca.d.ts");
|
|
109
|
+
fs.writeFileSync(outputPath, dtsContent);
|
|
110
|
+
console.log(`[OpacaCMS] Types successfully generated at ${outputPath}`);
|
|
111
|
+
}
|
|
112
|
+
function mapFieldToTsType(type) {
|
|
113
|
+
switch (type) {
|
|
114
|
+
case "text":
|
|
115
|
+
case "textarea":
|
|
116
|
+
case "richtext":
|
|
117
|
+
case "select":
|
|
118
|
+
case "date":
|
|
119
|
+
return "string";
|
|
120
|
+
case "number":
|
|
121
|
+
return "number";
|
|
122
|
+
case "boolean":
|
|
123
|
+
return "boolean";
|
|
124
|
+
case "json":
|
|
125
|
+
return "any | any[]";
|
|
126
|
+
case "file":
|
|
127
|
+
return "OpacaAsset";
|
|
128
|
+
case "relationship":
|
|
129
|
+
return "string | number | any";
|
|
130
|
+
default:
|
|
131
|
+
return "any";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/cli/commands/generate.ts
|
|
136
|
+
var generate_default = defineCommand({
|
|
137
|
+
meta: {
|
|
138
|
+
name: "generate",
|
|
139
|
+
description: "Generate boilerplates (collections/globals) or TypeScript definitions"
|
|
140
|
+
},
|
|
141
|
+
args: {
|
|
142
|
+
type: {
|
|
143
|
+
type: "positional",
|
|
144
|
+
description: "What to generate: 'types', 'collection', or 'global'",
|
|
145
|
+
required: true
|
|
146
|
+
},
|
|
147
|
+
name: {
|
|
148
|
+
type: "positional",
|
|
149
|
+
description: "The name of the collection or global to generate (if applicable)",
|
|
150
|
+
required: false
|
|
151
|
+
},
|
|
152
|
+
url: {
|
|
153
|
+
type: "string",
|
|
154
|
+
description: "The URL of the OpacaCMS instance (for 'types')"
|
|
155
|
+
},
|
|
156
|
+
token: {
|
|
157
|
+
type: "string",
|
|
158
|
+
description: "The API Key to use for fetching metadata (for 'types')"
|
|
159
|
+
},
|
|
160
|
+
out: {
|
|
161
|
+
type: "string",
|
|
162
|
+
alias: "o",
|
|
163
|
+
description: "The output file path (for 'types')"
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
async run({ args }) {
|
|
167
|
+
if (args.type === "types") {
|
|
168
|
+
if (!args.url || !args.token) {
|
|
169
|
+
R.error(import_picocolors.default.red("URL and Token are required to generate types from a remote instance."));
|
|
170
|
+
R.info("Usage: opacacms generate types --url <url> --token <token> [--out <file>]");
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
await generateTypesCommand(args.url, args.token, args.out || "opaca.d.ts");
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (args.type === "collection" || args.type === "global") {
|
|
177
|
+
let name = args.name;
|
|
178
|
+
if (!name) {
|
|
179
|
+
const response = await Zt({
|
|
180
|
+
message: `What should we name your ${args.type}? (e.g. ${args.type === "collection" ? "posts" : "site-settings"})`
|
|
181
|
+
});
|
|
182
|
+
if (Ct(response)) {
|
|
183
|
+
Nt("Operation cancelled.");
|
|
184
|
+
process.exit(0);
|
|
185
|
+
}
|
|
186
|
+
name = response;
|
|
187
|
+
}
|
|
188
|
+
const isCollection = args.type === "collection";
|
|
189
|
+
const folderName = isCollection ? "collections" : "globals";
|
|
190
|
+
const fileName = `${name}.ts`;
|
|
191
|
+
const filePath = resolve2(process.cwd(), folderName, fileName);
|
|
192
|
+
if (fs2.existsSync(filePath)) {
|
|
193
|
+
R.error(import_picocolors.default.red(`File already exists at ${folderName}/${fileName}`));
|
|
194
|
+
process.exit(1);
|
|
195
|
+
}
|
|
196
|
+
fs2.mkdirSync(resolve2(process.cwd(), folderName), { recursive: true });
|
|
197
|
+
const template = isCollection ? `import { z, defineCollection } from 'opacacms/schema';
|
|
198
|
+
|
|
199
|
+
export const ${name} = defineCollection({
|
|
200
|
+
slug: '${name}',
|
|
201
|
+
label: '${name.charAt(0).toUpperCase() + name.slice(1)}',
|
|
202
|
+
admin: {
|
|
203
|
+
useAsTitle: 'title',
|
|
204
|
+
icon: 'FileText'
|
|
205
|
+
},
|
|
206
|
+
schema: z.object({
|
|
207
|
+
id: z.text().default(() => crypto.randomUUID()),
|
|
208
|
+
title: z.text({ label: 'Title' }).required(),
|
|
209
|
+
content: z.richText({ label: 'Content' }),
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
` : `import { z, defineGlobal } from 'opacacms/schema';
|
|
213
|
+
|
|
214
|
+
export const ${name} = defineGlobal({
|
|
215
|
+
slug: '${name}',
|
|
216
|
+
label: '${name.charAt(0).toUpperCase() + name.slice(1)}',
|
|
217
|
+
admin: {
|
|
218
|
+
icon: 'Settings'
|
|
219
|
+
},
|
|
220
|
+
schema: z.object({
|
|
221
|
+
siteName: z.text({ label: 'Site Name' }).required(),
|
|
222
|
+
description: z.textarea({ label: 'Description' }),
|
|
223
|
+
})
|
|
224
|
+
});
|
|
225
|
+
`;
|
|
226
|
+
fs2.writeFileSync(filePath, template);
|
|
227
|
+
R.success(import_picocolors.default.green(`Successfully generated ${args.type} at ./${folderName}/${fileName}`));
|
|
228
|
+
Vt(`Don't forget to import it into your opacacms.config.ts and add it to the '${folderName}' array!`, "Reminder");
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
R.error(import_picocolors.default.red(`Unknown generation type: ${args.type}. Use 'types', 'collection', or 'global'.`));
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
export {
|
|
236
|
+
generate_default as default
|
|
237
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_compiler,
|
|
3
|
+
init_zod,
|
|
4
|
+
zodToOpacaFields
|
|
5
|
+
} from "./chunk-m5ems3hh.js";
|
|
6
|
+
|
|
7
|
+
// src/schema/collection.ts
|
|
8
|
+
init_compiler();
|
|
9
|
+
function defineCollection(config) {
|
|
10
|
+
const compiledSchema = config.schema.meta({
|
|
11
|
+
opaca: {
|
|
12
|
+
collectionConfig: {
|
|
13
|
+
slug: config.slug,
|
|
14
|
+
label: config.label,
|
|
15
|
+
useAsTitle: config.admin?.useAsTitle
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
...config,
|
|
21
|
+
schema: compiledSchema,
|
|
22
|
+
fields: zodToOpacaFields(compiledSchema),
|
|
23
|
+
seed: config.seed,
|
|
24
|
+
__type: null
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/schema/index.ts
|
|
29
|
+
init_compiler();
|
|
30
|
+
|
|
31
|
+
// src/schema/global.ts
|
|
32
|
+
init_compiler();
|
|
33
|
+
function defineGlobal(config) {
|
|
34
|
+
const compiledSchema = config.schema.meta({
|
|
35
|
+
opaca: {
|
|
36
|
+
globalConfig: {
|
|
37
|
+
slug: config.slug,
|
|
38
|
+
label: config.label
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
...config,
|
|
44
|
+
schema: compiledSchema,
|
|
45
|
+
fields: zodToOpacaFields(compiledSchema),
|
|
46
|
+
seed: config.seed,
|
|
47
|
+
__type: null
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/schema/index.ts
|
|
52
|
+
init_zod();
|
|
53
|
+
|
|
54
|
+
export { defineCollection, defineGlobal };
|