opacacms 0.1.0 → 0.1.2
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/dist/admin/index.js +49 -0
- package/dist/{chunk-2zm8cy1w.js → admin/webcomponent.js} +116 -168
- package/dist/{chunk-6dhs73zq.js → chunk-2yz1nsxs.js} +1 -1
- package/dist/chunk-fa5mg0hr.js +96 -0
- package/dist/{chunk-kwp83w8b.js → chunk-m09hahe2.js} +7 -7
- package/dist/{chunk-hmhcense.js → chunk-ry15hke8.js} +253 -4
- package/dist/chunk-vtvqfhgy.js +2442 -0
- package/dist/{chunk-f3nvxn63.js → chunk-y8hc6nm4.js} +1 -1
- package/dist/{src/cli → cli}/index.js +10 -10
- package/dist/{src/client.js → client.js} +2 -2
- package/dist/{src/db → db}/bun-sqlite.js +10 -10
- package/dist/{src/db → db}/d1.js +8 -8
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.js +7 -0
- package/dist/db/migration.d.ts +39 -0
- package/dist/{src/db → db}/postgres.js +10 -10
- package/dist/{src/db → db}/sqlite.js +8 -8
- package/dist/index.d.ts +0 -2
- package/dist/index.js +13 -0
- package/dist/{src/runtimes → runtimes}/bun.js +5 -6
- package/dist/{src/runtimes → runtimes}/cloudflare-workers.js +5 -6
- package/dist/{src/runtimes → runtimes}/next.js +5 -6
- package/dist/{src/runtimes → runtimes}/node.js +5 -6
- package/dist/{src/server.js → server.js} +7 -8
- package/dist/storage/index.d.ts +0 -3
- package/dist/storage/index.js +35 -0
- package/dist/types.d.ts +5 -2
- package/package.json +161 -39
- package/bun.lock +0 -34
- package/dist/api.d.ts +0 -6
- package/dist/chunk-8gkhn1d4.js +0 -309
- package/dist/chunk-dy5t83hr.js +0 -261
- package/dist/src/admin/index.js +0 -176
- package/dist/src/admin/webcomponent.js +0 -19
- package/dist/src/api.js +0 -27
- package/dist/src/index.js +0 -20
- package/dist/src/storage/index.js +0 -355
- package/global.d.ts +0 -11
- package/src/admin/api-client.ts +0 -63
- package/src/admin/auth-client.ts +0 -40
- package/src/admin/custom-field.ts +0 -179
- package/src/admin/index.ts +0 -15
- package/src/admin/react.tsx +0 -72
- package/src/admin/router.ts +0 -9
- package/src/admin/stores/admin-queries.ts +0 -121
- package/src/admin/stores/auth.ts +0 -61
- package/src/admin/stores/column-visibility.ts +0 -67
- package/src/admin/stores/config.ts +0 -15
- package/src/admin/stores/media.ts +0 -95
- package/src/admin/stores/query.ts +0 -13
- package/src/admin/stores/ui.ts +0 -29
- package/src/admin/ui/admin-client.tsx +0 -283
- package/src/admin/ui/admin-layout.tsx +0 -276
- package/src/admin/ui/components/ColumnVisibilityToggle.tsx +0 -141
- package/src/admin/ui/components/DataDetailSheet.tsx +0 -141
- package/src/admin/ui/components/DataDetailView.tsx +0 -175
- package/src/admin/ui/components/Table.tsx +0 -67
- package/src/admin/ui/components/fields/ArrayField.tsx +0 -166
- package/src/admin/ui/components/fields/BlocksField.tsx +0 -202
- package/src/admin/ui/components/fields/BooleanField.tsx +0 -50
- package/src/admin/ui/components/fields/CollapsibleField.tsx +0 -75
- package/src/admin/ui/components/fields/DateField.tsx +0 -45
- package/src/admin/ui/components/fields/FileField.tsx +0 -322
- package/src/admin/ui/components/fields/GroupField.tsx +0 -50
- package/src/admin/ui/components/fields/JoinField.tsx +0 -23
- package/src/admin/ui/components/fields/NumberField.tsx +0 -46
- package/src/admin/ui/components/fields/RadioField.tsx +0 -62
- package/src/admin/ui/components/fields/RelationshipField.tsx +0 -278
- package/src/admin/ui/components/fields/RowField.tsx +0 -40
- package/src/admin/ui/components/fields/SelectField.tsx +0 -59
- package/src/admin/ui/components/fields/TabsField.tsx +0 -101
- package/src/admin/ui/components/fields/TextAreaField.tsx +0 -54
- package/src/admin/ui/components/fields/TextField.tsx +0 -49
- package/src/admin/ui/components/fields/VirtualField.tsx +0 -53
- package/src/admin/ui/components/fields/index.tsx +0 -371
- package/src/admin/ui/components/fields/richtext-editor/index.tsx +0 -211
- package/src/admin/ui/components/fields/richtext-editor/nodes/ImageComponent.tsx +0 -142
- package/src/admin/ui/components/fields/richtext-editor/nodes/ImageNode.tsx +0 -95
- package/src/admin/ui/components/fields/richtext-editor/plugins/ComponentPickerPlugin.tsx +0 -226
- package/src/admin/ui/components/fields/richtext-editor/plugins/EditableSyncPlugin.tsx +0 -16
- package/src/admin/ui/components/fields/richtext-editor/plugins/NotionToolbarPlugin.tsx +0 -184
- package/src/admin/ui/components/fields/richtext-editor/plugins/SimpleToolbarPlugin.tsx +0 -240
- package/src/admin/ui/components/fields/richtext-editor/plugins/ValueSyncPlugin.tsx +0 -40
- package/src/admin/ui/components/fields/utils.ts +0 -1
- package/src/admin/ui/components/link.tsx +0 -41
- package/src/admin/ui/components/media/AssetManagerModal.tsx +0 -334
- package/src/admin/ui/components/toast.tsx +0 -72
- package/src/admin/ui/components/ui/accordion.tsx +0 -51
- package/src/admin/ui/components/ui/alert-dialog.tsx +0 -98
- package/src/admin/ui/components/ui/blocks.tsx +0 -32
- package/src/admin/ui/components/ui/breadcrumbs.tsx +0 -59
- package/src/admin/ui/components/ui/button.tsx +0 -26
- package/src/admin/ui/components/ui/collapsible.tsx +0 -124
- package/src/admin/ui/components/ui/dialog.tsx +0 -79
- package/src/admin/ui/components/ui/group.tsx +0 -20
- package/src/admin/ui/components/ui/index.ts +0 -17
- package/src/admin/ui/components/ui/input.tsx +0 -12
- package/src/admin/ui/components/ui/join.tsx +0 -53
- package/src/admin/ui/components/ui/label.tsx +0 -11
- package/src/admin/ui/components/ui/radio-group.tsx +0 -75
- package/src/admin/ui/components/ui/relationship-detail-sheet.tsx +0 -122
- package/src/admin/ui/components/ui/relationship.tsx +0 -58
- package/src/admin/ui/components/ui/scroll-area.tsx +0 -19
- package/src/admin/ui/components/ui/select.tsx +0 -187
- package/src/admin/ui/components/ui/separator.tsx +0 -21
- package/src/admin/ui/components/ui/sheet.tsx +0 -106
- package/src/admin/ui/components/ui/tabs.tsx +0 -116
- package/src/admin/ui/components/ui/utils.ts +0 -3
- package/src/admin/ui/hooks/use-debounce.ts +0 -15
- package/src/admin/ui/styles/_locale-switcher.scss +0 -33
- package/src/admin/ui/styles/accordion.scss +0 -60
- package/src/admin/ui/styles/animations.scss +0 -41
- package/src/admin/ui/styles/asset-manager.scss +0 -547
- package/src/admin/ui/styles/badge.scss +0 -13
- package/src/admin/ui/styles/base.scss +0 -22
- package/src/admin/ui/styles/button.scss +0 -161
- package/src/admin/ui/styles/card.scss +0 -13
- package/src/admin/ui/styles/collapsible.scss +0 -75
- package/src/admin/ui/styles/data-detail.scss +0 -92
- package/src/admin/ui/styles/dialog.scss +0 -102
- package/src/admin/ui/styles/empty-state.scss +0 -22
- package/src/admin/ui/styles/group.scss +0 -19
- package/src/admin/ui/styles/index.scss +0 -33
- package/src/admin/ui/styles/input.scss +0 -80
- package/src/admin/ui/styles/label.scss +0 -12
- package/src/admin/ui/styles/layout.scss +0 -56
- package/src/admin/ui/styles/lexical.scss +0 -469
- package/src/admin/ui/styles/loading.scss +0 -102
- package/src/admin/ui/styles/media-registry.scss +0 -597
- package/src/admin/ui/styles/pagination.scss +0 -20
- package/src/admin/ui/styles/radio-group.scss +0 -66
- package/src/admin/ui/styles/row.scss +0 -17
- package/src/admin/ui/styles/scrollbar.scss +0 -36
- package/src/admin/ui/styles/select.scss +0 -121
- package/src/admin/ui/styles/separator.scss +0 -14
- package/src/admin/ui/styles/sheet.scss +0 -152
- package/src/admin/ui/styles/sidebar.scss +0 -148
- package/src/admin/ui/styles/switch.scss +0 -59
- package/src/admin/ui/styles/table.scss +0 -207
- package/src/admin/ui/styles/tabs.scss +0 -62
- package/src/admin/ui/styles/toast.scss +0 -45
- package/src/admin/ui/styles/variables.scss +0 -24
- package/src/admin/ui/views/collection-list-view.tsx +0 -720
- package/src/admin/ui/views/dashboard-view.tsx +0 -263
- package/src/admin/ui/views/document-edit-view.tsx +0 -384
- package/src/admin/ui/views/global-edit-view.tsx +0 -226
- package/src/admin/ui/views/init-view.tsx +0 -182
- package/src/admin/ui/views/login-view.tsx +0 -123
- package/src/admin/ui/views/media-registry-view.tsx +0 -1104
- package/src/admin/ui/views/settings-view.tsx +0 -729
- package/src/admin/webcomponent.tsx +0 -15
- package/src/api.ts +0 -9
- package/src/auth/index.ts +0 -194
- package/src/auth/migrations.ts +0 -87
- package/src/auth/premissions.ts +0 -46
- package/src/cli/commands/generate-types.ts +0 -116
- package/src/cli/commands/init.ts +0 -95
- package/src/cli/commands/migrate-commands.ts +0 -160
- package/src/cli/commands/seed-command.ts +0 -11
- package/src/cli/d1-mock.ts +0 -101
- package/src/cli/index.test.ts +0 -84
- package/src/cli/index.ts +0 -183
- package/src/cli/r2-mock.ts +0 -217
- package/src/cli/seeding.ts +0 -405
- package/src/client.ts +0 -181
- package/src/config-utils.ts +0 -102
- package/src/config.ts +0 -49
- package/src/db/adapter.ts +0 -53
- package/src/db/better-sqlite.ts +0 -630
- package/src/db/bun-sqlite.ts +0 -646
- package/src/db/d1.ts +0 -711
- package/src/db/kysely/data-mapper.ts +0 -142
- package/src/db/kysely/field-mapper.ts +0 -148
- package/src/db/kysely/migration-generator.ts +0 -223
- package/src/db/kysely/query-builder.ts +0 -92
- package/src/db/kysely/schema-builder.ts +0 -439
- package/src/db/kysely/sql-utils.ts +0 -13
- package/src/db/postgres.ts +0 -621
- package/src/db/sqlite.ts +0 -658
- package/src/db/system-schema.ts +0 -121
- package/src/index.ts +0 -13
- package/src/runtimes/README.md +0 -59
- package/src/runtimes/bun.ts +0 -49
- package/src/runtimes/cloudflare-workers.ts +0 -38
- package/src/runtimes/next.ts +0 -26
- package/src/runtimes/node.ts +0 -52
- package/src/schema/collection.ts +0 -184
- package/src/schema/fields/base.ts +0 -164
- package/src/schema/fields/index.ts +0 -427
- package/src/schema/global.ts +0 -145
- package/src/schema/index.ts +0 -4
- package/src/schema/infer.ts +0 -72
- package/src/server/admin-router.ts +0 -20
- package/src/server/admin.ts +0 -142
- package/src/server/assets.ts +0 -306
- package/src/server/collection-router.ts +0 -55
- package/src/server/handlers.ts +0 -722
- package/src/server/middlewares/admin.ts +0 -27
- package/src/server/middlewares/auth.ts +0 -89
- package/src/server/middlewares/context.ts +0 -17
- package/src/server/middlewares/cors.ts +0 -24
- package/src/server/middlewares/database-init.ts +0 -74
- package/src/server/middlewares/rate-limit.ts +0 -71
- package/src/server/router.ts +0 -47
- package/src/server/setup-middlewares.ts +0 -58
- package/src/server/system-router.ts +0 -35
- package/src/server.ts +0 -9
- package/src/storage/adapters/cloudflare-r2.ts +0 -136
- package/src/storage/adapters/local.ts +0 -146
- package/src/storage/adapters/s3.ts +0 -186
- package/src/storage/errors.ts +0 -46
- package/src/storage/index.ts +0 -5
- package/src/storage/types.ts +0 -39
- package/src/types.ts +0 -577
- package/src/utils/lexical.ts +0 -37
- package/src/utils/logger.ts +0 -73
- package/src/validation.ts +0 -429
- package/src/validator.ts +0 -179
- package/test/admin-custom-field.test.ts +0 -162
- package/test/admin-react-field.test.tsx +0 -134
- package/test/api-features.test.ts +0 -78
- package/test/api.test.ts +0 -178
- package/test/auth.test.ts +0 -62
- package/test/cli-integration.test.ts +0 -146
- package/test/cli.test.ts +0 -25
- package/test/db/postgres.test.ts +0 -95
- package/test/db/sqlite-filter.test.ts +0 -53
- package/test/db/sqlite.test.ts +0 -82
- package/test/engine-features.test.ts +0 -79
- package/test/globals.test.ts +0 -74
- package/test/integration-tmp/db-app/opacacms.config.ts +0 -15
- package/test/integration-tmp/my-sqlite-app/opacacms.config.ts +0 -25
- package/test/integration-tmp/my-test-app/index.ts +0 -8
- package/test/integration-tmp/my-test-app/opacacms.config.ts +0 -16
- package/test/integration-tmp/my-test-app/package.json +0 -12
- package/test/populate.test.ts +0 -79
- package/test/runtimes.test.ts +0 -43
- package/test/schema-builder.test.ts +0 -107
- package/test/schema-features.test.ts +0 -63
- package/test/seeding.test.ts +0 -68
- package/test/storage/local.test.ts +0 -72
- package/test/storage/s3.test.ts +0 -60
- package/test/structural-data.test.ts +0 -100
- package/test/test-setup.ts +0 -11
- package/test/validation.test.ts +0 -162
- package/tsconfig.json +0 -42
- /package/dist/{src/admin/index.css → admin/webcomponent.css} +0 -0
package/dist/chunk-dy5t83hr.js
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getSystemCollections,
|
|
3
|
-
init_system_schema
|
|
4
|
-
} from "./chunk-ybbbqj63.js";
|
|
5
|
-
import {
|
|
6
|
-
__require
|
|
7
|
-
} from "./chunk-8sqjbsgt.js";
|
|
8
|
-
|
|
9
|
-
// src/auth/index.ts
|
|
10
|
-
import { apiKey } from "@better-auth/api-key";
|
|
11
|
-
import { betterAuth } from "better-auth";
|
|
12
|
-
import { admin } from "better-auth/plugins";
|
|
13
|
-
import { CamelCasePlugin } from "kysely";
|
|
14
|
-
|
|
15
|
-
// src/auth/premissions.ts
|
|
16
|
-
import { createAccessControl } from "better-auth/plugins/access";
|
|
17
|
-
function createPermissions(config) {
|
|
18
|
-
const resources = {
|
|
19
|
-
user: ["create", "read", "update", "delete", "ban", "impersonate"],
|
|
20
|
-
session: ["read", "revoke", "delete"]
|
|
21
|
-
};
|
|
22
|
-
for (const collection of config.collections) {
|
|
23
|
-
resources[collection.slug] = ["create", "read", "update", "delete"];
|
|
24
|
-
}
|
|
25
|
-
const ac = createAccessControl(resources);
|
|
26
|
-
const adminRole = ac.newRole({
|
|
27
|
-
user: ["create", "read", "update", "delete", "ban", "impersonate"],
|
|
28
|
-
session: ["read", "revoke", "delete"]
|
|
29
|
-
});
|
|
30
|
-
for (const collection of config.collections) {
|
|
31
|
-
adminRole[collection.slug] = ["create", "read", "update", "delete"];
|
|
32
|
-
}
|
|
33
|
-
const userRole = ac.newRole({});
|
|
34
|
-
const roles = {
|
|
35
|
-
admin: adminRole,
|
|
36
|
-
user: userRole
|
|
37
|
-
};
|
|
38
|
-
if (config.access?.roles) {
|
|
39
|
-
for (const [roleName, permissions] of Object.entries(config.access.roles)) {
|
|
40
|
-
roles[roleName] = ac.newRole(permissions);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
ac,
|
|
45
|
-
roles
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/auth/index.ts
|
|
50
|
-
async function createAuth(config) {
|
|
51
|
-
const userAuth = config.auth || {};
|
|
52
|
-
const trustedOrigins = config.trustedOrigins;
|
|
53
|
-
const { ac, roles } = createPermissions(config);
|
|
54
|
-
const rawDb = config.db.raw;
|
|
55
|
-
const env = typeof process !== "undefined" ? process.env : {};
|
|
56
|
-
const baseURL = String(config.serverURL || env.BETTER_AUTH_URL || "").replace(/\/$/, "");
|
|
57
|
-
if (!baseURL) {
|
|
58
|
-
throw new Error("[OpacaAuth] baseURL could not be determined. Please provide 'serverURL' in your config or 'BETTER_AUTH_URL' in your environment.");
|
|
59
|
-
}
|
|
60
|
-
const authURL = `${baseURL}/api/auth`;
|
|
61
|
-
const secret = env.OPACA_SECRET || env.BETTER_AUTH_SECRET || config.secret;
|
|
62
|
-
if (!secret) {
|
|
63
|
-
throw new Error("[OpacaAuth] No secret found for authentication. Please provide 'OPACA_SECRET' or 'BETTER_AUTH_SECRET'.");
|
|
64
|
-
}
|
|
65
|
-
if (typeof process !== "undefined" && !env.BETTER_AUTH_URL) {
|
|
66
|
-
process.env.BETTER_AUTH_URL = authURL;
|
|
67
|
-
}
|
|
68
|
-
let databaseConfig;
|
|
69
|
-
if (config.db.name === "postgres" && rawDb) {
|
|
70
|
-
const { PostgresJSDialect } = await import("kysely-postgres-js");
|
|
71
|
-
const { Kysely } = await import("kysely");
|
|
72
|
-
const kysely = new Kysely({
|
|
73
|
-
dialect: new PostgresJSDialect({ postgres: rawDb }),
|
|
74
|
-
plugins: [new CamelCasePlugin]
|
|
75
|
-
});
|
|
76
|
-
databaseConfig = {
|
|
77
|
-
db: kysely,
|
|
78
|
-
type: "pg"
|
|
79
|
-
};
|
|
80
|
-
} else if (config.db.name === "d1" && rawDb) {
|
|
81
|
-
const { D1Dialect } = await import("kysely-d1");
|
|
82
|
-
const { Kysely } = await import("kysely");
|
|
83
|
-
const kysely = new Kysely({
|
|
84
|
-
dialect: new D1Dialect({ database: rawDb }),
|
|
85
|
-
plugins: [new CamelCasePlugin]
|
|
86
|
-
});
|
|
87
|
-
databaseConfig = {
|
|
88
|
-
db: kysely,
|
|
89
|
-
type: "sqlite"
|
|
90
|
-
};
|
|
91
|
-
} else {
|
|
92
|
-
databaseConfig = {
|
|
93
|
-
db: rawDb,
|
|
94
|
-
type: "sqlite"
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
const isSecure = baseURL.startsWith("https");
|
|
98
|
-
const plugins = [
|
|
99
|
-
admin({
|
|
100
|
-
ac,
|
|
101
|
-
roles
|
|
102
|
-
}),
|
|
103
|
-
...userAuth.features?.apiKeys?.enabled ? [
|
|
104
|
-
apiKey({
|
|
105
|
-
defaultPrefix: "opaca_",
|
|
106
|
-
schema: {
|
|
107
|
-
apikey: {
|
|
108
|
-
modelName: "_api_keys"
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
] : []
|
|
113
|
-
];
|
|
114
|
-
const socialProviders = {};
|
|
115
|
-
if (userAuth.socialProviders?.github) {
|
|
116
|
-
socialProviders.github = userAuth.socialProviders.github;
|
|
117
|
-
}
|
|
118
|
-
if (userAuth.socialProviders?.google) {
|
|
119
|
-
socialProviders.google = userAuth.socialProviders.google;
|
|
120
|
-
}
|
|
121
|
-
return betterAuth({
|
|
122
|
-
database: databaseConfig,
|
|
123
|
-
baseURL,
|
|
124
|
-
basePath: "/api/auth",
|
|
125
|
-
secret,
|
|
126
|
-
trustedOrigins,
|
|
127
|
-
emailAndPassword: {
|
|
128
|
-
enabled: userAuth.strategies?.emailPassword !== false
|
|
129
|
-
},
|
|
130
|
-
socialProviders,
|
|
131
|
-
user: {
|
|
132
|
-
modelName: "_users"
|
|
133
|
-
},
|
|
134
|
-
session: {
|
|
135
|
-
modelName: "_sessions",
|
|
136
|
-
expiresIn: (userAuth.session?.expiresInDays || 30) * 86400,
|
|
137
|
-
updateAge: userAuth.session?.updateAgeSeconds || 86400
|
|
138
|
-
},
|
|
139
|
-
account: {
|
|
140
|
-
modelName: "_accounts"
|
|
141
|
-
},
|
|
142
|
-
verification: {
|
|
143
|
-
modelName: "_verifications"
|
|
144
|
-
},
|
|
145
|
-
advanced: {
|
|
146
|
-
useSecureCookies: isSecure,
|
|
147
|
-
defaultCookieAttributes: {
|
|
148
|
-
sameSite: isSecure ? "none" : "lax",
|
|
149
|
-
secure: isSecure
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
databaseHooks: {
|
|
153
|
-
user: {
|
|
154
|
-
create: {
|
|
155
|
-
before: async (user) => {
|
|
156
|
-
try {
|
|
157
|
-
let userCount = 0;
|
|
158
|
-
try {
|
|
159
|
-
userCount = await config.db.count("_users");
|
|
160
|
-
} catch (e) {
|
|
161
|
-
const result = await config.db.unsafe("SELECT COUNT(*) as count FROM _users");
|
|
162
|
-
const rows = result?.results || result || [];
|
|
163
|
-
userCount = Number(rows[0]?.count || rows[0]?.["count(*)"] || 0);
|
|
164
|
-
}
|
|
165
|
-
if (userCount === 0) {
|
|
166
|
-
return {
|
|
167
|
-
data: {
|
|
168
|
-
...user,
|
|
169
|
-
role: "admin"
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
} catch (e) {
|
|
174
|
-
console.error("[OpacaAuth] Failed to check user count in hook:", e);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
plugins
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// src/config-utils.ts
|
|
185
|
-
init_system_schema();
|
|
186
|
-
function sanitizeConfig(config) {
|
|
187
|
-
const collections = [...config.collections];
|
|
188
|
-
const supportsAuth = config.db.name === "sqlite" || config.db.name === "postgres" || config.db.name === "d1";
|
|
189
|
-
const systemCollections = getSystemCollections();
|
|
190
|
-
for (const systemCol of systemCollections) {
|
|
191
|
-
const isAsset = systemCol.slug === "_opaca_assets";
|
|
192
|
-
const isAuth = ["_users", "_sessions", "_accounts", "_verifications", "_api_keys"].includes(systemCol.slug);
|
|
193
|
-
if (isAsset && config.storages || isAuth && supportsAuth) {
|
|
194
|
-
if (!collections.find((col) => col.slug === systemCol.slug)) {
|
|
195
|
-
collections.push({
|
|
196
|
-
...systemCol,
|
|
197
|
-
admin: true
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
const sanitizeField = (f) => ({
|
|
203
|
-
name: f.name,
|
|
204
|
-
type: f.type,
|
|
205
|
-
label: f.label,
|
|
206
|
-
required: f.required,
|
|
207
|
-
unique: f.unique,
|
|
208
|
-
defaultValue: f.defaultValue,
|
|
209
|
-
localized: f.localized,
|
|
210
|
-
admin: f.admin ? {
|
|
211
|
-
description: f.admin.description,
|
|
212
|
-
hidden: f.admin.hidden,
|
|
213
|
-
readOnly: f.admin.readOnly,
|
|
214
|
-
components: f.admin.components
|
|
215
|
-
} : undefined,
|
|
216
|
-
options: f.options,
|
|
217
|
-
fields: f.fields ? f.fields.map(sanitizeField) : undefined,
|
|
218
|
-
relationTo: f.relationTo,
|
|
219
|
-
displayField: f.displayField,
|
|
220
|
-
collection: f.collection,
|
|
221
|
-
on: f.on,
|
|
222
|
-
blocks: f.blocks ? f.blocks.map((b) => ({
|
|
223
|
-
slug: b.slug,
|
|
224
|
-
label: b.label,
|
|
225
|
-
fields: b.fields.map(sanitizeField)
|
|
226
|
-
})) : undefined,
|
|
227
|
-
tabs: f.tabs ? f.tabs.map((t) => ({
|
|
228
|
-
label: t.label,
|
|
229
|
-
fields: t.fields.map(sanitizeField)
|
|
230
|
-
})) : undefined
|
|
231
|
-
});
|
|
232
|
-
return {
|
|
233
|
-
appName: config.appName,
|
|
234
|
-
serverURL: config.serverURL,
|
|
235
|
-
collections: collections.map((col) => ({
|
|
236
|
-
slug: col.slug,
|
|
237
|
-
apiPath: col.apiPath,
|
|
238
|
-
label: col.label,
|
|
239
|
-
icon: col.icon,
|
|
240
|
-
admin: col.admin,
|
|
241
|
-
hidden: col.hidden,
|
|
242
|
-
fields: col.fields.map(sanitizeField),
|
|
243
|
-
timestamps: col.timestamps,
|
|
244
|
-
auth: col.auth,
|
|
245
|
-
versions: col.versions
|
|
246
|
-
})),
|
|
247
|
-
globals: config.globals?.map((g) => ({
|
|
248
|
-
slug: g.slug,
|
|
249
|
-
label: g.label,
|
|
250
|
-
icon: g.icon,
|
|
251
|
-
fields: g.fields.map(sanitizeField)
|
|
252
|
-
})),
|
|
253
|
-
storages: config.storages ? Object.keys(config.storages).reduce((acc, key) => {
|
|
254
|
-
acc[key] = {};
|
|
255
|
-
return acc;
|
|
256
|
-
}, {}) : {},
|
|
257
|
-
i18n: config.i18n
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export { createAuth, sanitizeConfig };
|
package/dist/src/admin/index.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
$config,
|
|
3
|
-
$hasMetadataError,
|
|
4
|
-
$isFetchingConfig,
|
|
5
|
-
$needsInit,
|
|
6
|
-
$router,
|
|
7
|
-
AdminClient,
|
|
8
|
-
AdminLayout,
|
|
9
|
-
Breadcrumbs,
|
|
10
|
-
Link,
|
|
11
|
-
Toast,
|
|
12
|
-
ToastContainer,
|
|
13
|
-
createFetcherStore,
|
|
14
|
-
createMutatorStore,
|
|
15
|
-
invalidateKeys,
|
|
16
|
-
mutateCache,
|
|
17
|
-
revalidateKeys,
|
|
18
|
-
setConfig,
|
|
19
|
-
setNeedsInit
|
|
20
|
-
} from "../../chunk-2zm8cy1w.js";
|
|
21
|
-
import"../../chunk-16vgcf3k.js";
|
|
22
|
-
import {
|
|
23
|
-
$isSidebarCollapsed,
|
|
24
|
-
$toasts,
|
|
25
|
-
clearToast,
|
|
26
|
-
notify,
|
|
27
|
-
toggleSidebar
|
|
28
|
-
} from "../../chunk-j4d50hrx.js";
|
|
29
|
-
import"../../chunk-8sqjbsgt.js";
|
|
30
|
-
|
|
31
|
-
// src/admin/custom-field.ts
|
|
32
|
-
function defineCustomField(tagName, adapter) {
|
|
33
|
-
if (typeof window === "undefined")
|
|
34
|
-
return;
|
|
35
|
-
if (customElements.get(tagName)) {
|
|
36
|
-
console.warn(`[OpacaCMS] Custom field tag "${tagName}" is already defined.`);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class OpacaCustomFieldElement extends HTMLElement {
|
|
41
|
-
_value;
|
|
42
|
-
_fieldConfig;
|
|
43
|
-
_error;
|
|
44
|
-
_parentData;
|
|
45
|
-
_isMounted = false;
|
|
46
|
-
handleChange = (newValue) => {
|
|
47
|
-
this.dispatchEvent(new CustomEvent("opacachange", {
|
|
48
|
-
detail: { value: newValue },
|
|
49
|
-
bubbles: true,
|
|
50
|
-
composed: true
|
|
51
|
-
}));
|
|
52
|
-
};
|
|
53
|
-
getProps() {
|
|
54
|
-
return {
|
|
55
|
-
value: this._value,
|
|
56
|
-
fieldConfig: this._fieldConfig,
|
|
57
|
-
disabled: this.getAttribute("data-disabled") === "true",
|
|
58
|
-
readOnly: this.getAttribute("data-readonly") === "true",
|
|
59
|
-
error: this._error,
|
|
60
|
-
parentData: this._parentData,
|
|
61
|
-
onChange: this.handleChange
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
set error(err) {
|
|
65
|
-
if (this._error !== err) {
|
|
66
|
-
this._error = err;
|
|
67
|
-
if (this._isMounted && adapter.update) {
|
|
68
|
-
adapter.update(this, this.getProps());
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
get error() {
|
|
73
|
-
return this._error;
|
|
74
|
-
}
|
|
75
|
-
set parentData(data) {
|
|
76
|
-
this._parentData = data;
|
|
77
|
-
if (this._isMounted && adapter.update) {
|
|
78
|
-
adapter.update(this, this.getProps());
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
get parentData() {
|
|
82
|
-
return this._parentData;
|
|
83
|
-
}
|
|
84
|
-
set value(val) {
|
|
85
|
-
const oldValue = this._value;
|
|
86
|
-
this._value = val;
|
|
87
|
-
if (this._isMounted && adapter.update && oldValue !== val) {
|
|
88
|
-
adapter.update(this, this.getProps());
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
get value() {
|
|
92
|
-
return this._value;
|
|
93
|
-
}
|
|
94
|
-
set fieldConfig(config) {
|
|
95
|
-
this._fieldConfig = config;
|
|
96
|
-
if (this._isMounted && adapter.update) {
|
|
97
|
-
adapter.update(this, this.getProps());
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
get fieldConfig() {
|
|
101
|
-
return this._fieldConfig;
|
|
102
|
-
}
|
|
103
|
-
connectedCallback() {
|
|
104
|
-
if (!this._isMounted) {
|
|
105
|
-
adapter.mount(this, this.getProps());
|
|
106
|
-
this._isMounted = true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
disconnectedCallback() {
|
|
110
|
-
if (this._isMounted) {
|
|
111
|
-
if (adapter.unmount) {
|
|
112
|
-
adapter.unmount(this);
|
|
113
|
-
}
|
|
114
|
-
this._isMounted = false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
customElements.define(tagName, OpacaCustomFieldElement);
|
|
119
|
-
}
|
|
120
|
-
// src/admin/react.tsx
|
|
121
|
-
import React from "react";
|
|
122
|
-
import { createRoot } from "react-dom/client";
|
|
123
|
-
function defineReactField(tagName, Component) {
|
|
124
|
-
defineCustomField(tagName, {
|
|
125
|
-
mount: (container, props) => {
|
|
126
|
-
const el = container;
|
|
127
|
-
const root = createRoot(el);
|
|
128
|
-
el._opacaReactRoot = root;
|
|
129
|
-
root.render(React.createElement(Component, props));
|
|
130
|
-
},
|
|
131
|
-
update: (container, props) => {
|
|
132
|
-
const el = container;
|
|
133
|
-
const root = el._opacaReactRoot;
|
|
134
|
-
if (root) {
|
|
135
|
-
root.render(React.createElement(Component, props));
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
unmount: (container) => {
|
|
139
|
-
const el = container;
|
|
140
|
-
const root = el._opacaReactRoot;
|
|
141
|
-
if (root) {
|
|
142
|
-
setTimeout(() => {
|
|
143
|
-
root.unmount();
|
|
144
|
-
delete el._opacaReactRoot;
|
|
145
|
-
}, 0);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
export {
|
|
151
|
-
toggleSidebar,
|
|
152
|
-
setNeedsInit,
|
|
153
|
-
setConfig,
|
|
154
|
-
revalidateKeys,
|
|
155
|
-
notify,
|
|
156
|
-
mutateCache,
|
|
157
|
-
invalidateKeys,
|
|
158
|
-
defineReactField,
|
|
159
|
-
defineCustomField,
|
|
160
|
-
createMutatorStore,
|
|
161
|
-
createFetcherStore,
|
|
162
|
-
clearToast,
|
|
163
|
-
ToastContainer,
|
|
164
|
-
Toast,
|
|
165
|
-
Link,
|
|
166
|
-
Breadcrumbs,
|
|
167
|
-
AdminLayout,
|
|
168
|
-
AdminClient,
|
|
169
|
-
$toasts,
|
|
170
|
-
$router,
|
|
171
|
-
$needsInit,
|
|
172
|
-
$isSidebarCollapsed,
|
|
173
|
-
$isFetchingConfig,
|
|
174
|
-
$hasMetadataError,
|
|
175
|
-
$config
|
|
176
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AdminClient
|
|
3
|
-
} from "../../chunk-2zm8cy1w.js";
|
|
4
|
-
import"../../chunk-16vgcf3k.js";
|
|
5
|
-
import"../../chunk-j4d50hrx.js";
|
|
6
|
-
import"../../chunk-8sqjbsgt.js";
|
|
7
|
-
|
|
8
|
-
// src/admin/webcomponent.tsx
|
|
9
|
-
import r2wc from "@r2wc/react-to-web-component";
|
|
10
|
-
var OpacaAdminWebComponent = r2wc(AdminClient, {
|
|
11
|
-
props: {
|
|
12
|
-
serverUrl: "string",
|
|
13
|
-
config: "json",
|
|
14
|
-
initialNeedsInit: "boolean"
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
if (typeof window !== "undefined" && !customElements.get("opaca-admin")) {
|
|
18
|
-
customElements.define("opaca-admin", OpacaAdminWebComponent);
|
|
19
|
-
}
|
package/dist/src/api.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createAPIRouter,
|
|
3
|
-
createAdminHandlers,
|
|
4
|
-
createGlobalHandlers,
|
|
5
|
-
createHandlers,
|
|
6
|
-
hydrateDoc
|
|
7
|
-
} from "../chunk-hmhcense.js";
|
|
8
|
-
import {
|
|
9
|
-
defineConfig
|
|
10
|
-
} from "../chunk-zvwb67nd.js";
|
|
11
|
-
import"../chunk-dy5t83hr.js";
|
|
12
|
-
import {
|
|
13
|
-
BaseDatabaseAdapter
|
|
14
|
-
} from "../chunk-s8mqwnm1.js";
|
|
15
|
-
import"../chunk-62ev8gnc.js";
|
|
16
|
-
import"../chunk-cvdd4eqh.js";
|
|
17
|
-
import"../chunk-ybbbqj63.js";
|
|
18
|
-
import"../chunk-8sqjbsgt.js";
|
|
19
|
-
export {
|
|
20
|
-
hydrateDoc,
|
|
21
|
-
defineConfig,
|
|
22
|
-
createHandlers,
|
|
23
|
-
createGlobalHandlers,
|
|
24
|
-
createAdminHandlers,
|
|
25
|
-
createAPIRouter,
|
|
26
|
-
BaseDatabaseAdapter
|
|
27
|
-
};
|
package/dist/src/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
OpacaError,
|
|
3
|
-
createClient
|
|
4
|
-
} from "../chunk-d3ffeqp9.js";
|
|
5
|
-
import {
|
|
6
|
-
defineConfig
|
|
7
|
-
} from "../chunk-zvwb67nd.js";
|
|
8
|
-
import {
|
|
9
|
-
createAuth,
|
|
10
|
-
sanitizeConfig
|
|
11
|
-
} from "../chunk-dy5t83hr.js";
|
|
12
|
-
import"../chunk-ybbbqj63.js";
|
|
13
|
-
import"../chunk-8sqjbsgt.js";
|
|
14
|
-
export {
|
|
15
|
-
sanitizeConfig,
|
|
16
|
-
defineConfig,
|
|
17
|
-
createClient,
|
|
18
|
-
createAuth,
|
|
19
|
-
OpacaError
|
|
20
|
-
};
|