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.
- package/README.md +792 -50
- package/dist/admin/auth-client.d.ts +39 -39
- package/dist/admin/index.js +2360 -1392
- 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.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-0sdceeys.js → chunk-0bq155dy.js} +86 -6
- package/dist/{chunk-59sg3pw9.js → chunk-0gtxnxmd.js} +90 -7
- 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-t9v845m2.js → chunk-7y1nbmw6.js} +34 -3
- package/dist/chunk-8scgdznr.js +44 -0
- package/dist/{chunk-mycmsjd9.js → chunk-b3kr8w41.js} +57 -6
- package/dist/chunk-bexcv7xe.js +36 -0
- package/dist/{chunk-16vgcf3k.js → chunk-byq8g0rd.js} +1 -1
- package/dist/{chunk-fqastxq9.js → chunk-d1asgtke.js} +86 -6
- package/dist/{chunk-cpw2y3pn.js → chunk-dykn5hr6.js} +7 -7
- package/dist/{chunk-61kwqve4.js → chunk-esrg9qj0.js} +90 -9
- package/dist/chunk-fj19qccp.js +78 -0
- package/dist/{chunk-ekxkvqjm.js → chunk-gmee4mdc.js} +90 -9
- package/dist/{chunk-xa7rjsn2.js → chunk-j53pz21t.js} +2 -2
- package/dist/{chunk-xrfhhz85.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 -26
- 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 -7
- package/dist/schema/index.js +22 -6
- 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 +222 -15
- package/dist/utils/logger.d.ts +13 -35
- package/dist/validation.d.ts +40 -0
- 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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/utils/logger.ts
|
|
2
|
+
var RESET = "\x1B[0m";
|
|
3
|
+
var BLUE = "\x1B[34m";
|
|
4
|
+
var GREEN = "\x1B[32m";
|
|
5
|
+
var YELLOW = "\x1B[33m";
|
|
6
|
+
var RED = "\x1B[31m";
|
|
7
|
+
var GRAY = "\x1B[90m";
|
|
8
|
+
var PREFIX = `${BLUE}[OpacaCMS]${RESET}`;
|
|
9
|
+
var LOG_LEVELS = {
|
|
10
|
+
debug: 0,
|
|
11
|
+
info: 1,
|
|
12
|
+
warn: 2,
|
|
13
|
+
error: 3
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
class OpacaLogger {
|
|
17
|
+
config;
|
|
18
|
+
constructor(config = {}) {
|
|
19
|
+
this.config = config;
|
|
20
|
+
}
|
|
21
|
+
shouldLog(level) {
|
|
22
|
+
if (this.config.disabled)
|
|
23
|
+
return false;
|
|
24
|
+
const configLevel = this.config.level || "info";
|
|
25
|
+
return LOG_LEVELS[level] >= LOG_LEVELS[configLevel];
|
|
26
|
+
}
|
|
27
|
+
info(message, ...args) {
|
|
28
|
+
if (!this.shouldLog("info"))
|
|
29
|
+
return;
|
|
30
|
+
console.log(`${PREFIX} ${message}`, ...args);
|
|
31
|
+
}
|
|
32
|
+
success(message, ...args) {
|
|
33
|
+
if (!this.shouldLog("info"))
|
|
34
|
+
return;
|
|
35
|
+
console.log(`${PREFIX} ${GREEN}${message}${RESET}`, ...args);
|
|
36
|
+
}
|
|
37
|
+
debug(message, ...args) {
|
|
38
|
+
if (!this.shouldLog("debug"))
|
|
39
|
+
return;
|
|
40
|
+
console.log(`${PREFIX} ${GRAY}${message}${RESET}`, ...args);
|
|
41
|
+
}
|
|
42
|
+
warn(message, ...args) {
|
|
43
|
+
if (!this.shouldLog("warn"))
|
|
44
|
+
return;
|
|
45
|
+
console.warn(`${PREFIX} ${YELLOW}Warning: ${message}${RESET}`, ...args);
|
|
46
|
+
}
|
|
47
|
+
error(message, ...args) {
|
|
48
|
+
if (!this.shouldLog("error"))
|
|
49
|
+
return;
|
|
50
|
+
console.error(`${PREFIX} ${RED}Error: ${message}${RESET}`, ...args);
|
|
51
|
+
}
|
|
52
|
+
format(color, msg) {
|
|
53
|
+
if (this.config.disableColors)
|
|
54
|
+
return msg;
|
|
55
|
+
switch (color) {
|
|
56
|
+
case "green":
|
|
57
|
+
return `${GREEN}${msg}${RESET}`;
|
|
58
|
+
case "red":
|
|
59
|
+
return `${RED}${msg}${RESET}`;
|
|
60
|
+
case "yellow":
|
|
61
|
+
return `${YELLOW}${msg}${RESET}`;
|
|
62
|
+
case "gray":
|
|
63
|
+
return `${GRAY}${msg}${RESET}`;
|
|
64
|
+
default:
|
|
65
|
+
return msg;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
var logger = new OpacaLogger;
|
|
70
|
+
|
|
71
|
+
export { OpacaLogger, logger };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-t0zg026p.js";
|
|
4
|
+
|
|
5
|
+
// src/cli/commands/plugin-sync.ts
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
async function pluginSyncCommand(projectRoot, watch = false) {
|
|
9
|
+
const srcDir = path.resolve(projectRoot, "src");
|
|
10
|
+
if (!fs.existsSync(srcDir)) {
|
|
11
|
+
logger.error(`No 'src' directory found in ${projectRoot}.`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const runSync = () => {
|
|
15
|
+
const uiFiles = ["dashboard.tsx", "dashboard.jsx", "ui.tsx", "ui.jsx"];
|
|
16
|
+
let uiEntry = "";
|
|
17
|
+
for (const file of uiFiles) {
|
|
18
|
+
const inSrc = path.join(srcDir, file);
|
|
19
|
+
if (fs.existsSync(inSrc)) {
|
|
20
|
+
uiEntry = inSrc;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!uiEntry) {
|
|
25
|
+
logger.warn("No UI entry found (e.g. dashboard.tsx). Skipping UI sync.");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const uiContent = fs.readFileSync(uiEntry, "utf-8");
|
|
30
|
+
const transpiler = new Bun.Transpiler({
|
|
31
|
+
loader: uiEntry.endsWith(".tsx") ? "tsx" : "jsx",
|
|
32
|
+
target: "browser",
|
|
33
|
+
inline: true,
|
|
34
|
+
minifyWhitespace: true
|
|
35
|
+
});
|
|
36
|
+
const transpiledUI = transpiler.transformSync(uiContent);
|
|
37
|
+
const safeUI = transpiledUI.replace(/\`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
38
|
+
const genPath = uiEntry.replace(/\.(tsx|jsx)$/, ".gen.ts");
|
|
39
|
+
const baseName = path.parse(uiEntry).name;
|
|
40
|
+
const genContent = `// This file is generated by opacacms plugin:sync. Do not edit manually.
|
|
41
|
+
export const ${baseName}Source = \`
|
|
42
|
+
${safeUI}
|
|
43
|
+
\`;
|
|
44
|
+
`;
|
|
45
|
+
fs.writeFileSync(genPath, genContent, "utf-8");
|
|
46
|
+
logger.success(`Generated: ${path.basename(genPath)}`);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
logger.error(`Failed to sync UI: ${err.message}`);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
runSync();
|
|
52
|
+
if (watch) {
|
|
53
|
+
logger.info("Watching for changes in src/...");
|
|
54
|
+
fs.watch(srcDir, { recursive: true }, (event, filename) => {
|
|
55
|
+
if (filename && (filename.endsWith(".tsx") || filename.endsWith(".jsx")) && !filename.endsWith(".gen.ts")) {
|
|
56
|
+
logger.info(`File changed: ${filename}. Syncing...`);
|
|
57
|
+
runSync();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return new Promise(() => {});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { pluginSyncCommand };
|
|
@@ -123,6 +123,21 @@ var getSystemCollections = () => [
|
|
|
123
123
|
],
|
|
124
124
|
timestamps: { createdAt: "createdAt", updatedAt: "updatedAt" },
|
|
125
125
|
hidden: true
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
slug: "_opaca_plugin_settings",
|
|
129
|
+
label: "Plugin Settings",
|
|
130
|
+
apiPath: "plugin-settings",
|
|
131
|
+
fields: [
|
|
132
|
+
{ name: "pluginName", type: "text", required: true, unique: true },
|
|
133
|
+
{ name: "config", type: "json", required: true }
|
|
134
|
+
],
|
|
135
|
+
timestamps: true,
|
|
136
|
+
hidden: false,
|
|
137
|
+
admin: {
|
|
138
|
+
hidden: true,
|
|
139
|
+
disableAdmin: true
|
|
140
|
+
}
|
|
126
141
|
}
|
|
127
142
|
];
|
|
128
143
|
var init_system_schema = () => {};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
+
$customSidebarItems,
|
|
2
3
|
$isSidebarCollapsed,
|
|
3
4
|
$toasts,
|
|
4
5
|
clearToast,
|
|
5
6
|
notify,
|
|
7
|
+
registerSidebarItem,
|
|
6
8
|
toggleSidebar
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-8scgdznr.js";
|
|
8
10
|
import"./chunk-8sqjbsgt.js";
|
|
9
11
|
export {
|
|
10
12
|
toggleSidebar,
|
|
13
|
+
registerSidebarItem,
|
|
11
14
|
notify,
|
|
12
15
|
clearToast,
|
|
13
16
|
$toasts,
|
|
14
|
-
$isSidebarCollapsed
|
|
17
|
+
$isSidebarCollapsed,
|
|
18
|
+
$customSidebarItems
|
|
15
19
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pluginBuildCommand(projectRoot: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pluginInitCommand(pluginName: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pluginSyncCommand(projectRoot: string, watch?: boolean): Promise<unknown>;
|
package/dist/cli/index.js
CHANGED
|
@@ -62,7 +62,8 @@ async function main() {
|
|
|
62
62
|
url: { type: "string" },
|
|
63
63
|
token: { type: "string" },
|
|
64
64
|
count: { type: "string" },
|
|
65
|
-
reset: { type: "boolean" }
|
|
65
|
+
reset: { type: "boolean" },
|
|
66
|
+
watch: { type: "boolean", short: "w" }
|
|
66
67
|
},
|
|
67
68
|
allowPositionals: true
|
|
68
69
|
});
|
|
@@ -78,6 +79,8 @@ Commands:`);
|
|
|
78
79
|
console.log(" seed Seed database with mock data");
|
|
79
80
|
console.log(" seed:assets Seed only assets");
|
|
80
81
|
console.log(" generate:types Generate TS definitions from instance");
|
|
82
|
+
console.log(" plugin:init [name] Initialize a new plugin project");
|
|
83
|
+
console.log(" plugin:sync Build a plugin project (transpile & bake)");
|
|
81
84
|
process.exit(0);
|
|
82
85
|
}
|
|
83
86
|
if (values.version) {
|
|
@@ -99,6 +102,21 @@ Commands:`);
|
|
|
99
102
|
await generateTypesCommand(values.url, values.token, values.out || "opaca-types.d.ts");
|
|
100
103
|
return;
|
|
101
104
|
}
|
|
105
|
+
if (command === "plugin:init") {
|
|
106
|
+
const { pluginInitCommand } = await import("../chunk-mkn49zmy.js");
|
|
107
|
+
await pluginInitCommand(positionals[1] || "my-opaca-plugin");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (command === "plugin:sync") {
|
|
111
|
+
const { pluginSyncCommand } = await import("../chunk-rsf0tpy1.js");
|
|
112
|
+
await pluginSyncCommand(process.cwd(), !!values.watch);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (command === "plugin:build") {
|
|
116
|
+
const { pluginBuildCommand } = await import("../chunk-fj19qccp.js");
|
|
117
|
+
await pluginBuildCommand(process.cwd());
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
102
120
|
let configPath = values.config ? resolve(process.cwd(), values.config) : "";
|
|
103
121
|
if (!configPath) {
|
|
104
122
|
const defaults = ["opacacms.config.ts", "opacacms.config.js", "src/opacacms.config.ts", "src/opacacms.config.js", "opaca.config.ts", "opaca.config.js"];
|
|
@@ -116,28 +134,28 @@ Commands:`);
|
|
|
116
134
|
const opaca = await loadConfig(configPath);
|
|
117
135
|
switch (command) {
|
|
118
136
|
case "migrate:create": {
|
|
119
|
-
const { migrateCreateCommand } = await import("../chunk-
|
|
137
|
+
const { migrateCreateCommand } = await import("../chunk-6v1fw7q7.js");
|
|
120
138
|
await migrateCreateCommand(opaca, positionals[1], values.out);
|
|
121
139
|
break;
|
|
122
140
|
}
|
|
123
141
|
case "migrate": {
|
|
124
|
-
const { migrateRunCommand } = await import("../chunk-
|
|
142
|
+
const { migrateRunCommand } = await import("../chunk-6v1fw7q7.js");
|
|
125
143
|
await migrateRunCommand(opaca.db);
|
|
126
144
|
break;
|
|
127
145
|
}
|
|
128
146
|
case "migrate:status": {
|
|
129
|
-
const { migrateStatusCommand } = await import("../chunk-
|
|
147
|
+
const { migrateStatusCommand } = await import("../chunk-6v1fw7q7.js");
|
|
130
148
|
await migrateStatusCommand(opaca);
|
|
131
149
|
break;
|
|
132
150
|
}
|
|
133
151
|
case "migrate:d1": {
|
|
134
|
-
const { migrateD1Command } = await import("../chunk-
|
|
152
|
+
const { migrateD1Command } = await import("../chunk-6v1fw7q7.js");
|
|
135
153
|
await migrateD1Command(values.out || "./migrations", !!values.remote, values.binding || "DB");
|
|
136
154
|
break;
|
|
137
155
|
}
|
|
138
156
|
case "seed":
|
|
139
157
|
case "seed:assets": {
|
|
140
|
-
const { seedCommand } = await import("../chunk-
|
|
158
|
+
const { seedCommand } = await import("../chunk-qb6ztvw9.js");
|
|
141
159
|
await seedCommand(opaca, parseInt(values.count) || 10, !!values.reset, command === "seed:assets" ? "assets" : "collections");
|
|
142
160
|
break;
|
|
143
161
|
}
|
package/dist/config-utils.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import type { OpacaConfig, SerializableConfig } from "./types";
|
|
|
3
3
|
* Sanitizes the OpacaConfig to ensure it's safe to pass to Client Components or over the API.
|
|
4
4
|
* Strips out functions (hooks, access) and the database adapter.
|
|
5
5
|
*/
|
|
6
|
-
export declare function sanitizeConfig(config: OpacaConfig): SerializableConfig;
|
|
6
|
+
export declare function sanitizeConfig(config: OpacaConfig, settings?: Record<string, any>): SerializableConfig;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Helper to define the OpacaCMS configuration with full type safety.
|
|
3
3
|
*/
|
|
4
|
-
import type { Collection, OpacaConfig } from "./types";
|
|
4
|
+
import type { Collection, Global, OpacaConfig } from "./types";
|
|
5
|
+
type BuiltResource<T> = T extends {
|
|
6
|
+
build: () => infer R;
|
|
7
|
+
} ? R : T;
|
|
8
|
+
type Buildable<T> = T | {
|
|
9
|
+
build: () => T;
|
|
10
|
+
};
|
|
11
|
+
type ResourceOf<C, G> = (C extends readonly (infer U)[] ? (BuiltResource<U> extends {
|
|
12
|
+
slug: infer S;
|
|
13
|
+
} ? S : never) : never) | (G extends readonly (infer U)[] ? (BuiltResource<U> extends {
|
|
14
|
+
slug: infer S;
|
|
15
|
+
} ? S : never) : never);
|
|
5
16
|
/**
|
|
6
|
-
* Helper logic to infer slugs from collections.
|
|
17
|
+
* Helper logic to infer slugs from collections and globals.
|
|
7
18
|
*/
|
|
8
|
-
export declare function defineConfig<const TCollections extends readonly Collection
|
|
19
|
+
export declare function defineConfig<const TCollections extends readonly Buildable<Collection & {
|
|
20
|
+
slug: string;
|
|
21
|
+
}>[], const TGlobals extends readonly Buildable<Global & {
|
|
22
|
+
slug: string;
|
|
23
|
+
}>[] = [], TResource extends string = ResourceOf<TCollections, TGlobals>>(config: Omit<OpacaConfig<TResource>, "collections" | "globals"> & {
|
|
9
24
|
collections: TCollections;
|
|
10
|
-
|
|
25
|
+
globals?: TGlobals;
|
|
26
|
+
}): OpacaConfig<TResource>;
|
|
27
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Kysely } from "kysely";
|
|
2
2
|
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
3
|
-
import { BaseDatabaseAdapter } from "
|
|
3
|
+
import { BaseDatabaseAdapter } from "../db/adapter";
|
|
4
4
|
export declare class BetterSQLiteAdapter extends BaseDatabaseAdapter {
|
|
5
5
|
name: string;
|
|
6
6
|
private _rawDb;
|
package/dist/db/better-sqlite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BetterSQLiteAdapter,
|
|
3
3
|
createBetterSQLiteAdapter
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import"../chunk-
|
|
4
|
+
} from "../chunk-gmee4mdc.js";
|
|
5
|
+
import"../chunk-dykn5hr6.js";
|
|
6
6
|
import"../chunk-s8mqwnm1.js";
|
|
7
|
-
import"../chunk-
|
|
8
|
-
import"../chunk-
|
|
9
|
-
import"../chunk-
|
|
7
|
+
import"../chunk-qxt9vge8.js";
|
|
8
|
+
import"../chunk-v9z61v3g.js";
|
|
9
|
+
import"../chunk-t0zg026p.js";
|
|
10
10
|
import"../chunk-8sqjbsgt.js";
|
|
11
11
|
export {
|
|
12
12
|
createBetterSQLiteAdapter,
|
package/dist/db/bun-sqlite.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Kysely } from "kysely";
|
|
2
2
|
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
3
|
-
import { BaseDatabaseAdapter } from "
|
|
3
|
+
import { BaseDatabaseAdapter } from "../db/adapter";
|
|
4
4
|
export declare class BunSQLiteAdapter extends BaseDatabaseAdapter {
|
|
5
5
|
name: string;
|
|
6
6
|
private _rawDb;
|
package/dist/db/bun-sqlite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BunSQLiteAdapter,
|
|
3
3
|
createBunSQLiteAdapter
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import"../chunk-
|
|
4
|
+
} from "../chunk-0gtxnxmd.js";
|
|
5
|
+
import"../chunk-dykn5hr6.js";
|
|
6
6
|
import"../chunk-s8mqwnm1.js";
|
|
7
|
-
import"../chunk-
|
|
8
|
-
import"../chunk-
|
|
9
|
-
import"../chunk-
|
|
7
|
+
import"../chunk-qxt9vge8.js";
|
|
8
|
+
import"../chunk-v9z61v3g.js";
|
|
9
|
+
import"../chunk-t0zg026p.js";
|
|
10
10
|
import"../chunk-8sqjbsgt.js";
|
|
11
11
|
export {
|
|
12
12
|
createBunSQLiteAdapter,
|
package/dist/db/d1.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { D1Database } from "@cloudflare/workers-types";
|
|
2
2
|
import { Kysely } from "kysely";
|
|
3
3
|
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
4
|
-
import { BaseDatabaseAdapter } from "
|
|
4
|
+
import { BaseDatabaseAdapter } from "../db/adapter";
|
|
5
5
|
export declare class D1Adapter extends BaseDatabaseAdapter {
|
|
6
6
|
name: string;
|
|
7
7
|
private _rawDb;
|
package/dist/db/d1.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
D1Adapter,
|
|
3
3
|
createD1Adapter
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import"../chunk-
|
|
4
|
+
} from "../chunk-d1asgtke.js";
|
|
5
|
+
import"../chunk-dykn5hr6.js";
|
|
6
6
|
import"../chunk-s8mqwnm1.js";
|
|
7
|
-
import"../chunk-
|
|
8
|
-
import"../chunk-
|
|
9
|
-
import"../chunk-
|
|
7
|
+
import"../chunk-qxt9vge8.js";
|
|
8
|
+
import"../chunk-v9z61v3g.js";
|
|
9
|
+
import"../chunk-t0zg026p.js";
|
|
10
10
|
import"../chunk-8sqjbsgt.js";
|
|
11
11
|
export {
|
|
12
12
|
createD1Adapter,
|
package/dist/db/index.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
D1Adapter,
|
|
3
3
|
createD1Adapter
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-d1asgtke.js";
|
|
5
5
|
import {
|
|
6
6
|
PostgresAdapter,
|
|
7
7
|
createPostgresAdapter
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-esrg9qj0.js";
|
|
9
9
|
import {
|
|
10
10
|
SQLiteAdapter,
|
|
11
11
|
createSQLiteAdapter
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-0bq155dy.js";
|
|
13
13
|
import {
|
|
14
14
|
BunSQLiteAdapter,
|
|
15
15
|
createBunSQLiteAdapter
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-0gtxnxmd.js";
|
|
17
17
|
import {
|
|
18
18
|
BetterSQLiteAdapter,
|
|
19
19
|
createBetterSQLiteAdapter
|
|
20
|
-
} from "../chunk-
|
|
21
|
-
import"../chunk-
|
|
20
|
+
} from "../chunk-gmee4mdc.js";
|
|
21
|
+
import"../chunk-dykn5hr6.js";
|
|
22
22
|
import {
|
|
23
23
|
BaseDatabaseAdapter
|
|
24
24
|
} from "../chunk-s8mqwnm1.js";
|
|
25
|
-
import"../chunk-
|
|
26
|
-
import"../chunk-
|
|
27
|
-
import"../chunk-
|
|
25
|
+
import"../chunk-qxt9vge8.js";
|
|
26
|
+
import"../chunk-v9z61v3g.js";
|
|
27
|
+
import"../chunk-t0zg026p.js";
|
|
28
28
|
import"../chunk-8sqjbsgt.js";
|
|
29
29
|
|
|
30
30
|
// src/db/index.ts
|
package/dist/db/postgres.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Kysely } from "kysely";
|
|
2
2
|
import postgres from "postgres";
|
|
3
3
|
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
4
|
-
import { BaseDatabaseAdapter } from "
|
|
4
|
+
import { BaseDatabaseAdapter } from "../db/adapter";
|
|
5
5
|
export interface PostgresConfig {
|
|
6
6
|
url?: string;
|
|
7
7
|
host?: string;
|
package/dist/db/postgres.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PostgresAdapter,
|
|
3
3
|
createPostgresAdapter
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import"../chunk-
|
|
4
|
+
} from "../chunk-esrg9qj0.js";
|
|
5
|
+
import"../chunk-dykn5hr6.js";
|
|
6
6
|
import"../chunk-s8mqwnm1.js";
|
|
7
|
-
import"../chunk-
|
|
8
|
-
import"../chunk-
|
|
9
|
-
import"../chunk-
|
|
7
|
+
import"../chunk-qxt9vge8.js";
|
|
8
|
+
import"../chunk-v9z61v3g.js";
|
|
9
|
+
import"../chunk-t0zg026p.js";
|
|
10
10
|
import"../chunk-8sqjbsgt.js";
|
|
11
11
|
export {
|
|
12
12
|
createPostgresAdapter,
|
package/dist/db/sqlite.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Kysely } from "kysely";
|
|
2
2
|
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
3
|
-
import { BaseDatabaseAdapter } from "
|
|
3
|
+
import { BaseDatabaseAdapter } from "../db/adapter";
|
|
4
4
|
export declare class SQLiteAdapter extends BaseDatabaseAdapter {
|
|
5
5
|
name: string;
|
|
6
6
|
private _rawDb;
|
package/dist/db/sqlite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SQLiteAdapter,
|
|
3
3
|
createSQLiteAdapter
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import"../chunk-
|
|
4
|
+
} from "../chunk-0bq155dy.js";
|
|
5
|
+
import"../chunk-dykn5hr6.js";
|
|
6
6
|
import"../chunk-s8mqwnm1.js";
|
|
7
|
-
import"../chunk-
|
|
8
|
-
import"../chunk-
|
|
9
|
-
import"../chunk-
|
|
7
|
+
import"../chunk-qxt9vge8.js";
|
|
8
|
+
import"../chunk-v9z61v3g.js";
|
|
9
|
+
import"../chunk-t0zg026p.js";
|
|
10
10
|
import"../chunk-8sqjbsgt.js";
|
|
11
11
|
export {
|
|
12
12
|
createSQLiteAdapter,
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,13 @@ import {
|
|
|
4
4
|
} from "./chunk-d3ffeqp9.js";
|
|
5
5
|
import {
|
|
6
6
|
defineConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7y1nbmw6.js";
|
|
8
8
|
import {
|
|
9
9
|
createAuth,
|
|
10
10
|
sanitizeConfig
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import"./chunk-
|
|
11
|
+
} from "./chunk-b3kr8w41.js";
|
|
12
|
+
import"./chunk-v9z61v3g.js";
|
|
13
|
+
import"./chunk-t0zg026p.js";
|
|
13
14
|
import"./chunk-8sqjbsgt.js";
|
|
14
15
|
export {
|
|
15
16
|
sanitizeConfig,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./utils";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
/**
|
|
3
|
+
* Serves a .ts or .tsx source as a transpiled browser-compatible JavaScript module.
|
|
4
|
+
*
|
|
5
|
+
* @param c - The Hono context.
|
|
6
|
+
* @param options - Options containing either the filePath or the raw source.
|
|
7
|
+
*/
|
|
8
|
+
export declare function servePluginUI(c: Context, options: {
|
|
9
|
+
filePath?: string;
|
|
10
|
+
source?: string;
|
|
11
|
+
loader?: 'tsx' | 'ts';
|
|
12
|
+
}): Promise<(Response & import("hono").TypedResponse<"No content provided", 400, "text">) | (Response & import("hono").TypedResponse<string, 200, "body">) | (Response & import("hono").TypedResponse<"Failed to serve plugin UI", 500, "text">)>;
|
package/dist/runtimes/bun.js
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadPluginSettings
|
|
3
|
+
} from "../chunk-51z3x7kq.js";
|
|
1
4
|
import {
|
|
2
5
|
createAPIRouter
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import"../chunk-
|
|
5
|
-
import"../chunk-
|
|
6
|
-
import"../chunk-
|
|
7
|
-
import"../chunk-
|
|
6
|
+
} from "../chunk-kc4jfnv7.js";
|
|
7
|
+
import"../chunk-b3kr8w41.js";
|
|
8
|
+
import"../chunk-qxt9vge8.js";
|
|
9
|
+
import"../chunk-v9z61v3g.js";
|
|
10
|
+
import"../chunk-t0zg026p.js";
|
|
8
11
|
import"../chunk-8sqjbsgt.js";
|
|
9
12
|
|
|
10
13
|
// src/runtimes/bun.ts
|
|
11
14
|
import { Hono } from "hono";
|
|
12
15
|
function createBunHandler(config, options) {
|
|
13
16
|
const app = new Hono;
|
|
14
|
-
const apiRouter = createAPIRouter(config);
|
|
15
|
-
app.route("/api", apiRouter);
|
|
16
17
|
const init = async () => {
|
|
17
18
|
console.log("\uD83D\uDE80 Initializing OpacaCMS (Bun runtime)...");
|
|
19
|
+
let settings = {};
|
|
18
20
|
if (config.db) {
|
|
19
21
|
await config.db.connect();
|
|
20
22
|
console.log(`\uD83D\uDCE6 Database "${config.db.name}" connected`);
|
|
21
23
|
await config.db.migrate(config.collections);
|
|
22
24
|
console.log("✅ Migrations completed");
|
|
25
|
+
settings = await loadPluginSettings(config);
|
|
26
|
+
console.log("\uD83D\uDD0C Plugin settings loaded");
|
|
23
27
|
}
|
|
28
|
+
const apiRouter = createAPIRouter(config, settings);
|
|
29
|
+
app.route("/api", apiRouter);
|
|
24
30
|
const port = options?.port || 3000;
|
|
25
31
|
Bun.serve({
|
|
26
32
|
fetch: app.fetch,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAPIRouter
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import"../chunk-
|
|
5
|
-
import"../chunk-
|
|
6
|
-
import"../chunk-
|
|
7
|
-
import"../chunk-
|
|
3
|
+
} from "../chunk-kc4jfnv7.js";
|
|
4
|
+
import"../chunk-b3kr8w41.js";
|
|
5
|
+
import"../chunk-qxt9vge8.js";
|
|
6
|
+
import"../chunk-v9z61v3g.js";
|
|
7
|
+
import"../chunk-t0zg026p.js";
|
|
8
8
|
import"../chunk-8sqjbsgt.js";
|
|
9
9
|
|
|
10
10
|
// src/runtimes/cloudflare-workers.ts
|
package/dist/runtimes/next.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAPIRouter
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import"../chunk-
|
|
5
|
-
import"../chunk-
|
|
6
|
-
import"../chunk-
|
|
7
|
-
import"../chunk-
|
|
3
|
+
} from "../chunk-kc4jfnv7.js";
|
|
4
|
+
import"../chunk-b3kr8w41.js";
|
|
5
|
+
import"../chunk-qxt9vge8.js";
|
|
6
|
+
import"../chunk-v9z61v3g.js";
|
|
7
|
+
import"../chunk-t0zg026p.js";
|
|
8
8
|
import"../chunk-8sqjbsgt.js";
|
|
9
9
|
|
|
10
10
|
// src/runtimes/next.ts
|
package/dist/runtimes/node.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadPluginSettings
|
|
3
|
+
} from "../chunk-51z3x7kq.js";
|
|
1
4
|
import {
|
|
2
5
|
createAPIRouter
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import"../chunk-
|
|
5
|
-
import"../chunk-
|
|
6
|
-
import"../chunk-
|
|
7
|
-
import"../chunk-
|
|
6
|
+
} from "../chunk-kc4jfnv7.js";
|
|
7
|
+
import"../chunk-b3kr8w41.js";
|
|
8
|
+
import"../chunk-qxt9vge8.js";
|
|
9
|
+
import"../chunk-v9z61v3g.js";
|
|
10
|
+
import"../chunk-t0zg026p.js";
|
|
8
11
|
import"../chunk-8sqjbsgt.js";
|
|
9
12
|
|
|
10
13
|
// src/runtimes/node.ts
|
|
@@ -12,16 +15,19 @@ import { serve } from "@hono/node-server";
|
|
|
12
15
|
import { Hono } from "hono";
|
|
13
16
|
function createNodeHandler(config, options) {
|
|
14
17
|
const app = new Hono;
|
|
15
|
-
const apiRouter = createAPIRouter(config);
|
|
16
|
-
app.route("/api", apiRouter);
|
|
17
18
|
const init = async () => {
|
|
18
19
|
console.log("\uD83D\uDE80 Initializing OpacaCMS (Node.js runtime)...");
|
|
20
|
+
let settings = {};
|
|
19
21
|
if (config.db) {
|
|
20
22
|
await config.db.connect();
|
|
21
23
|
console.log(`\uD83D\uDCE6 Database "${config.db.name}" connected`);
|
|
22
24
|
await config.db.migrate(config.collections);
|
|
23
25
|
console.log("✅ Migrations completed");
|
|
26
|
+
settings = await loadPluginSettings(config);
|
|
27
|
+
console.log("\uD83D\uDD0C Plugin settings loaded");
|
|
24
28
|
}
|
|
29
|
+
const apiRouter = createAPIRouter(config, settings);
|
|
30
|
+
app.route("/api", apiRouter);
|
|
25
31
|
const port = options?.port || 3000;
|
|
26
32
|
serve({
|
|
27
33
|
fetch: app.fetch,
|