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,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-t0zg026p.js";
|
|
4
|
+
import"./chunk-8sqjbsgt.js";
|
|
5
|
+
|
|
6
|
+
// src/cli/commands/plugin-init.ts
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
async function pluginInitCommand(pluginName) {
|
|
10
|
+
if (!pluginName) {
|
|
11
|
+
logger.error("Please provide a plugin name. Usage: opacacms plugin:init <plugin_name>");
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const targetDir = path.resolve(process.cwd(), pluginName);
|
|
15
|
+
if (fs.existsSync(targetDir)) {
|
|
16
|
+
logger.error(`Directory ${targetDir} already exists.`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
logger.info(`Initializing new plugin in ${targetDir}...`);
|
|
20
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
21
|
+
fs.mkdirSync(path.join(targetDir, "src"), { recursive: true });
|
|
22
|
+
const packageJson = {
|
|
23
|
+
name: pluginName,
|
|
24
|
+
version: "1.0.0",
|
|
25
|
+
description: "An OpacaCMS plugin",
|
|
26
|
+
main: "dist/index.js",
|
|
27
|
+
types: "dist/index.d.ts",
|
|
28
|
+
scripts: {
|
|
29
|
+
build: "opacacms plugin:build",
|
|
30
|
+
dev: "bun run build --watch"
|
|
31
|
+
},
|
|
32
|
+
peerDependencies: {
|
|
33
|
+
opacacms: "workspace:*"
|
|
34
|
+
},
|
|
35
|
+
devDependencies: {
|
|
36
|
+
typescript: "^5.0.0",
|
|
37
|
+
"@types/node": "^20.0.0"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
fs.writeFileSync(path.join(targetDir, "package.json"), JSON.stringify(packageJson, null, 2), "utf-8");
|
|
41
|
+
const tsconfig = {
|
|
42
|
+
compilerOptions: {
|
|
43
|
+
target: "ESNext",
|
|
44
|
+
module: "ESNext",
|
|
45
|
+
moduleResolution: "bundler",
|
|
46
|
+
strict: true,
|
|
47
|
+
esModuleInterop: true,
|
|
48
|
+
skipLibCheck: true,
|
|
49
|
+
forceConsistentCasingInFileNames: true,
|
|
50
|
+
outDir: "./dist",
|
|
51
|
+
declaration: true,
|
|
52
|
+
jsx: "react"
|
|
53
|
+
},
|
|
54
|
+
include: ["src/**/*"]
|
|
55
|
+
};
|
|
56
|
+
fs.writeFileSync(path.join(targetDir, "tsconfig.json"), JSON.stringify(tsconfig, null, 2), "utf-8");
|
|
57
|
+
const indexTsx = `import type { OpacaPlugin, OpacaPluginContext } from 'opacacms/types';
|
|
58
|
+
import { definePlugin } from 'opacacms/plugins';
|
|
59
|
+
|
|
60
|
+
export const myPlugin = (): OpacaPlugin => definePlugin({
|
|
61
|
+
name: '${pluginName}',
|
|
62
|
+
label: 'My Custom Plugin',
|
|
63
|
+
description: 'A great new plugin for OpacaCMS.',
|
|
64
|
+
version: '1.0.0',
|
|
65
|
+
icon: 'Box',
|
|
66
|
+
|
|
67
|
+
onInit: (ctx: OpacaPluginContext) => {
|
|
68
|
+
ctx.logger.info('[${pluginName}] Plugin initialized!');
|
|
69
|
+
return ctx.config;
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
adminUI: {
|
|
73
|
+
component: 'my-plugin-dashboard',
|
|
74
|
+
// The CLI will automatically compile dashboard.tsx into this 'source' field during build.
|
|
75
|
+
source: '',
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
`;
|
|
79
|
+
fs.writeFileSync(path.join(targetDir, "src", "index.tsx"), indexTsx, "utf-8");
|
|
80
|
+
const dashboardTsx = `class MyPluginDashboard extends HTMLElement {
|
|
81
|
+
connectedCallback() {
|
|
82
|
+
this.innerHTML = \`
|
|
83
|
+
<div style="padding: 2rem; font-family: sans-serif;">
|
|
84
|
+
<h2>Welcome to ${pluginName} Dashboard!</h2>
|
|
85
|
+
<p>This UI component is built as a self-contained Web Component.</p>
|
|
86
|
+
</div>
|
|
87
|
+
\`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
customElements.define('my-plugin-dashboard', MyPluginDashboard);
|
|
92
|
+
`;
|
|
93
|
+
fs.writeFileSync(path.join(targetDir, "src", "dashboard.tsx"), dashboardTsx, "utf-8");
|
|
94
|
+
logger.success(`Plugin ${pluginName} initialized successfully!`);
|
|
95
|
+
logger.info(`Next steps:
|
|
96
|
+
cd ${pluginName}
|
|
97
|
+
bun install
|
|
98
|
+
bun run build`);
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
pluginInitCommand
|
|
102
|
+
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/cli/commands/seed-command.ts
|
|
6
6
|
async function seedCommand(opaca, count, reset, type) {
|
|
7
|
-
const { autoSeed } = await import("./chunk-
|
|
7
|
+
const { autoSeed } = await import("./chunk-swtcpvhf.js");
|
|
8
8
|
try {
|
|
9
9
|
await autoSeed(opaca, count, reset, type);
|
|
10
10
|
} catch (error) {
|
|
@@ -49,7 +49,7 @@ function mapFieldToSQLiteType(field) {
|
|
|
49
49
|
function flattenFields(fields, prefix = "") {
|
|
50
50
|
const result = [];
|
|
51
51
|
for (const field of fields) {
|
|
52
|
-
if (field.type === "join" || field.type === "virtual")
|
|
52
|
+
if (field.type === "join" || field.type === "virtual" || field.type === "ui")
|
|
53
53
|
continue;
|
|
54
54
|
const currentName = field.name ? `${prefix}${field.name}` : undefined;
|
|
55
55
|
if (field.type === "group") {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineCustomField
|
|
3
|
+
} from "./chunk-rqyjjqgy.js";
|
|
4
|
+
|
|
5
|
+
// src/admin/vue.tsx
|
|
6
|
+
function defineVueField(tagName, Component, options) {
|
|
7
|
+
defineCustomField(tagName, {
|
|
8
|
+
mount: (container, props) => {
|
|
9
|
+
const app = options.createApp(Component, props);
|
|
10
|
+
container._opacaVueApp = app;
|
|
11
|
+
app.mount(container);
|
|
12
|
+
},
|
|
13
|
+
update: (container, props) => {
|
|
14
|
+
const app = container._opacaVueApp;
|
|
15
|
+
if (app && app._instance) {
|
|
16
|
+
Object.assign(app._instance.props, props);
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
unmount: (container) => {
|
|
20
|
+
const app = container._opacaVueApp;
|
|
21
|
+
if (app) {
|
|
22
|
+
app.unmount();
|
|
23
|
+
delete container._opacaVueApp;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { defineVueField };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// src/admin/custom-field.ts
|
|
2
|
+
function defineCustomField(tagName, adapter) {
|
|
3
|
+
if (typeof window === "undefined")
|
|
4
|
+
return;
|
|
5
|
+
if (customElements.get(tagName)) {
|
|
6
|
+
console.warn(`[OpacaCMS] Custom field tag "${tagName}" is already defined.`);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class OpacaCustomFieldElement extends HTMLElement {
|
|
11
|
+
_value;
|
|
12
|
+
_fieldConfig;
|
|
13
|
+
_error;
|
|
14
|
+
_parentData;
|
|
15
|
+
_isMounted = false;
|
|
16
|
+
handleChange = (newValue) => {
|
|
17
|
+
this.dispatchEvent(new CustomEvent("opacachange", {
|
|
18
|
+
detail: { value: newValue },
|
|
19
|
+
bubbles: true,
|
|
20
|
+
composed: true
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
getProps() {
|
|
24
|
+
return {
|
|
25
|
+
value: this._value,
|
|
26
|
+
fieldConfig: this._fieldConfig,
|
|
27
|
+
disabled: this.getAttribute("data-disabled") === "true",
|
|
28
|
+
readOnly: this.getAttribute("data-readonly") === "true",
|
|
29
|
+
error: this._error,
|
|
30
|
+
parentData: this._parentData,
|
|
31
|
+
onChange: this.handleChange
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
set error(err) {
|
|
35
|
+
if (this._error !== err) {
|
|
36
|
+
this._error = err;
|
|
37
|
+
if (this._isMounted && adapter.update) {
|
|
38
|
+
adapter.update(this, this.getProps());
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
get error() {
|
|
43
|
+
return this._error;
|
|
44
|
+
}
|
|
45
|
+
set parentData(data) {
|
|
46
|
+
this._parentData = data;
|
|
47
|
+
if (this._isMounted && adapter.update) {
|
|
48
|
+
adapter.update(this, this.getProps());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
get parentData() {
|
|
52
|
+
return this._parentData;
|
|
53
|
+
}
|
|
54
|
+
set value(val) {
|
|
55
|
+
const oldValue = this._value;
|
|
56
|
+
this._value = val;
|
|
57
|
+
if (this._isMounted && adapter.update && oldValue !== val) {
|
|
58
|
+
adapter.update(this, this.getProps());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
get value() {
|
|
62
|
+
return this._value;
|
|
63
|
+
}
|
|
64
|
+
set fieldConfig(config) {
|
|
65
|
+
this._fieldConfig = config;
|
|
66
|
+
if (this._isMounted && adapter.update) {
|
|
67
|
+
adapter.update(this, this.getProps());
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
get fieldConfig() {
|
|
71
|
+
return this._fieldConfig;
|
|
72
|
+
}
|
|
73
|
+
connectedCallback() {
|
|
74
|
+
if (!this._isMounted) {
|
|
75
|
+
adapter.mount(this, this.getProps());
|
|
76
|
+
this._isMounted = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
disconnectedCallback() {
|
|
80
|
+
if (this._isMounted) {
|
|
81
|
+
if (adapter.unmount) {
|
|
82
|
+
adapter.unmount(this);
|
|
83
|
+
}
|
|
84
|
+
this._isMounted = false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
customElements.define(tagName, OpacaCustomFieldElement);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { defineCustomField };
|