opacacms 0.1.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/bun.lock +34 -0
- package/dist/admin/api-client.d.ts +8 -0
- package/dist/admin/auth-client.d.ts +940 -0
- package/dist/admin/custom-field.d.ts +71 -0
- package/dist/admin/index.d.ts +11 -0
- package/dist/admin/react.d.ts +3 -0
- package/dist/admin/router.d.ts +7 -0
- package/dist/admin/stores/admin-queries.d.ts +32 -0
- package/dist/admin/stores/auth.d.ts +33 -0
- package/dist/admin/stores/column-visibility.d.ts +21 -0
- package/dist/admin/stores/config.d.ts +7 -0
- package/dist/admin/stores/media.d.ts +44 -0
- package/dist/admin/stores/query.d.ts +4 -0
- package/dist/admin/stores/ui.d.ts +11 -0
- package/dist/admin/ui/admin-client.d.ts +7 -0
- package/dist/admin/ui/admin-layout.d.ts +14 -0
- package/dist/admin/ui/components/ColumnVisibilityToggle.d.ts +10 -0
- package/dist/admin/ui/components/DataDetailSheet.d.ts +13 -0
- package/dist/admin/ui/components/DataDetailView.d.ts +9 -0
- package/dist/admin/ui/components/Table.d.ts +10 -0
- package/dist/admin/ui/components/fields/ArrayField.d.ts +13 -0
- package/dist/admin/ui/components/fields/BlocksField.d.ts +17 -0
- package/dist/admin/ui/components/fields/BooleanField.d.ts +13 -0
- package/dist/admin/ui/components/fields/CollapsibleField.d.ts +16 -0
- package/dist/admin/ui/components/fields/DateField.d.ts +13 -0
- package/dist/admin/ui/components/fields/FileField.d.ts +23 -0
- package/dist/admin/ui/components/fields/GroupField.d.ts +13 -0
- package/dist/admin/ui/components/fields/JoinField.d.ts +15 -0
- package/dist/admin/ui/components/fields/NumberField.d.ts +14 -0
- package/dist/admin/ui/components/fields/RadioField.d.ts +17 -0
- package/dist/admin/ui/components/fields/RelationshipField.d.ts +16 -0
- package/dist/admin/ui/components/fields/RowField.d.ts +12 -0
- package/dist/admin/ui/components/fields/SelectField.d.ts +18 -0
- package/dist/admin/ui/components/fields/TabsField.d.ts +15 -0
- package/dist/admin/ui/components/fields/TextAreaField.d.ts +14 -0
- package/dist/admin/ui/components/fields/TextField.d.ts +14 -0
- package/dist/admin/ui/components/fields/VirtualField.d.ts +8 -0
- package/dist/admin/ui/components/fields/index.d.ts +28 -0
- package/dist/admin/ui/components/fields/richtext-editor/index.d.ts +10 -0
- package/dist/admin/ui/components/fields/richtext-editor/nodes/ImageComponent.d.ts +7 -0
- package/dist/admin/ui/components/fields/richtext-editor/nodes/ImageNode.d.ts +27 -0
- package/dist/admin/ui/components/fields/richtext-editor/plugins/ComponentPickerPlugin.d.ts +1 -0
- package/dist/admin/ui/components/fields/richtext-editor/plugins/EditableSyncPlugin.d.ts +5 -0
- package/dist/admin/ui/components/fields/richtext-editor/plugins/NotionToolbarPlugin.d.ts +1 -0
- package/dist/admin/ui/components/fields/richtext-editor/plugins/SimpleToolbarPlugin.d.ts +1 -0
- package/dist/admin/ui/components/fields/richtext-editor/plugins/ValueSyncPlugin.d.ts +5 -0
- package/dist/admin/ui/components/fields/utils.d.ts +1 -0
- package/dist/admin/ui/components/link.d.ts +8 -0
- package/dist/admin/ui/components/media/AssetManagerModal.d.ts +17 -0
- package/dist/admin/ui/components/toast.d.ts +10 -0
- package/dist/admin/ui/components/ui/accordion.d.ts +11 -0
- package/dist/admin/ui/components/ui/alert-dialog.d.ts +12 -0
- package/dist/admin/ui/components/ui/blocks.d.ts +5 -0
- package/dist/admin/ui/components/ui/breadcrumbs.d.ts +7 -0
- package/dist/admin/ui/components/ui/button.d.ts +7 -0
- package/dist/admin/ui/components/ui/collapsible.d.ts +16 -0
- package/dist/admin/ui/components/ui/dialog.d.ts +27 -0
- package/dist/admin/ui/components/ui/group.d.ts +6 -0
- package/dist/admin/ui/components/ui/index.d.ts +17 -0
- package/dist/admin/ui/components/ui/input.d.ts +5 -0
- package/dist/admin/ui/components/ui/join.d.ts +7 -0
- package/dist/admin/ui/components/ui/label.d.ts +3 -0
- package/dist/admin/ui/components/ui/radio-group.d.ts +13 -0
- package/dist/admin/ui/components/ui/relationship-detail-sheet.d.ts +9 -0
- package/dist/admin/ui/components/ui/relationship.d.ts +8 -0
- package/dist/admin/ui/components/ui/scroll-area.d.ts +7 -0
- package/dist/admin/ui/components/ui/select.d.ts +37 -0
- package/dist/admin/ui/components/ui/separator.d.ts +8 -0
- package/dist/admin/ui/components/ui/sheet.d.ts +28 -0
- package/dist/admin/ui/components/ui/tabs.d.ts +17 -0
- package/dist/admin/ui/components/ui/utils.d.ts +1 -0
- package/dist/admin/ui/hooks/use-debounce.d.ts +1 -0
- package/dist/admin/ui/views/collection-list-view.d.ts +5 -0
- package/dist/admin/ui/views/dashboard-view.d.ts +10 -0
- package/dist/admin/ui/views/document-edit-view.d.ts +7 -0
- package/dist/admin/ui/views/global-edit-view.d.ts +19 -0
- package/dist/admin/ui/views/init-view.d.ts +4 -0
- package/dist/admin/ui/views/login-view.d.ts +4 -0
- package/dist/admin/ui/views/media-registry-view.d.ts +7 -0
- package/dist/admin/ui/views/settings-view.d.ts +7 -0
- package/dist/admin/webcomponent.d.ts +1 -0
- package/dist/api.d.ts +6 -0
- package/dist/auth/index.d.ts +2107 -0
- package/dist/auth/migrations.d.ts +5 -0
- package/dist/auth/premissions.d.ts +6 -0
- package/dist/chunk-16vgcf3k.js +88 -0
- package/dist/chunk-2zm8cy1w.js +9482 -0
- package/dist/chunk-5gvbp2qa.js +167 -0
- package/dist/chunk-62ev8gnc.js +41 -0
- package/dist/chunk-6dhs73zq.js +126 -0
- package/dist/chunk-6ew02s0c.js +472 -0
- package/dist/chunk-7a9kn0np.js +116 -0
- package/dist/chunk-8gkhn1d4.js +309 -0
- package/dist/chunk-8sqjbsgt.js +42 -0
- package/dist/chunk-9kxpbcb1.js +85 -0
- package/dist/chunk-cvdd4eqh.js +110 -0
- package/dist/chunk-d3ffeqp9.js +87 -0
- package/dist/chunk-dy5t83hr.js +261 -0
- package/dist/chunk-f3nvxn63.js +17 -0
- package/dist/chunk-hmhcense.js +1352 -0
- package/dist/chunk-j4d50hrx.js +20 -0
- package/dist/chunk-jwjk85ze.js +15 -0
- package/dist/chunk-kwp83w8b.js +250 -0
- package/dist/chunk-s8mqwnm1.js +14 -0
- package/dist/chunk-srsac177.js +85 -0
- package/dist/chunk-v521d72w.js +10 -0
- package/dist/chunk-xa7rjsn2.js +20 -0
- package/dist/chunk-xg35h5a3.js +15 -0
- package/dist/chunk-ybbbqj63.js +130 -0
- package/dist/chunk-zvwb67nd.js +332 -0
- package/dist/cli/commands/generate-types.d.ts +1 -0
- package/dist/cli/commands/init.d.ts +1 -0
- package/dist/cli/commands/migrate-commands.d.ts +5 -0
- package/dist/cli/commands/seed-command.d.ts +2 -0
- package/dist/cli/d1-mock.d.ts +30 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.test.d.ts +1 -0
- package/dist/cli/r2-mock.d.ts +46 -0
- package/dist/cli/seeding.d.ts +17 -0
- package/dist/client.d.ts +51 -0
- package/dist/config-utils.d.ts +6 -0
- package/dist/config.d.ts +10 -0
- package/dist/db/adapter.d.ts +34 -0
- package/dist/db/better-sqlite.d.ts +40 -0
- package/dist/db/bun-sqlite.d.ts +40 -0
- package/dist/db/d1.d.ts +42 -0
- package/dist/db/kysely/data-mapper.d.ts +6 -0
- package/dist/db/kysely/field-mapper.d.ts +22 -0
- package/dist/db/kysely/migration-generator.d.ts +9 -0
- package/dist/db/kysely/query-builder.d.ts +9 -0
- package/dist/db/kysely/schema-builder.d.ts +15 -0
- package/dist/db/kysely/sql-utils.d.ts +1 -0
- package/dist/db/postgres.d.ts +51 -0
- package/dist/db/sqlite.d.ts +41 -0
- package/dist/db/system-schema.d.ts +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/runtimes/bun.d.ts +17 -0
- package/dist/runtimes/cloudflare-workers.d.ts +10 -0
- package/dist/runtimes/next.d.ts +16 -0
- package/dist/runtimes/node.d.ts +18 -0
- package/dist/schema/collection.d.ts +100 -0
- package/dist/schema/fields/base.d.ts +83 -0
- package/dist/schema/fields/index.d.ts +135 -0
- package/dist/schema/global.d.ts +82 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/infer.d.ts +55 -0
- package/dist/server/admin-router.d.ts +9 -0
- package/dist/server/admin.d.ts +18 -0
- package/dist/server/assets.d.ts +47 -0
- package/dist/server/collection-router.d.ts +14 -0
- package/dist/server/handlers.d.ts +76 -0
- package/dist/server/middlewares/admin.d.ts +6 -0
- package/dist/server/middlewares/auth.d.ts +16 -0
- package/dist/server/middlewares/context.d.ts +9 -0
- package/dist/server/middlewares/cors.d.ts +3 -0
- package/dist/server/middlewares/database-init.d.ts +11 -0
- package/dist/server/middlewares/rate-limit.d.ts +3 -0
- package/dist/server/router.d.ts +7 -0
- package/dist/server/setup-middlewares.d.ts +17 -0
- package/dist/server/system-router.d.ts +9 -0
- package/dist/server.d.ts +6 -0
- package/dist/src/admin/index.css +47 -0
- package/dist/src/admin/index.js +176 -0
- package/dist/src/admin/webcomponent.js +19 -0
- package/dist/src/api.js +27 -0
- package/dist/src/cli/index.js +157 -0
- package/dist/src/client.js +9 -0
- package/dist/src/db/bun-sqlite.js +523 -0
- package/dist/src/db/d1.js +568 -0
- package/dist/src/db/postgres.js +520 -0
- package/dist/src/db/sqlite.js +534 -0
- package/dist/src/index.js +20 -0
- package/dist/src/runtimes/bun.js +36 -0
- package/dist/src/runtimes/cloudflare-workers.js +29 -0
- package/dist/src/runtimes/next.js +26 -0
- package/dist/src/runtimes/node.js +38 -0
- package/dist/src/server.js +27 -0
- package/dist/src/storage/index.js +355 -0
- package/dist/storage/adapters/cloudflare-r2.d.ts +6 -0
- package/dist/storage/adapters/local.d.ts +6 -0
- package/dist/storage/adapters/s3.d.ts +13 -0
- package/dist/storage/errors.d.ts +12 -0
- package/dist/storage/index.d.ts +5 -0
- package/dist/storage/types.d.ts +31 -0
- package/dist/types.d.ts +484 -0
- package/dist/utils/lexical.d.ts +5 -0
- package/dist/utils/logger.d.ts +35 -0
- package/dist/validation.d.ts +300 -0
- package/dist/validator.d.ts +9 -0
- package/global.d.ts +11 -0
- package/package.json +151 -0
- package/src/admin/api-client.ts +63 -0
- package/src/admin/auth-client.ts +40 -0
- package/src/admin/custom-field.ts +179 -0
- package/src/admin/index.ts +15 -0
- package/src/admin/react.tsx +72 -0
- package/src/admin/router.ts +9 -0
- package/src/admin/stores/admin-queries.ts +121 -0
- package/src/admin/stores/auth.ts +61 -0
- package/src/admin/stores/column-visibility.ts +67 -0
- package/src/admin/stores/config.ts +15 -0
- package/src/admin/stores/media.ts +95 -0
- package/src/admin/stores/query.ts +13 -0
- package/src/admin/stores/ui.ts +29 -0
- package/src/admin/ui/admin-client.tsx +283 -0
- package/src/admin/ui/admin-layout.tsx +276 -0
- package/src/admin/ui/components/ColumnVisibilityToggle.tsx +141 -0
- package/src/admin/ui/components/DataDetailSheet.tsx +141 -0
- package/src/admin/ui/components/DataDetailView.tsx +175 -0
- package/src/admin/ui/components/Table.tsx +67 -0
- package/src/admin/ui/components/fields/ArrayField.tsx +166 -0
- package/src/admin/ui/components/fields/BlocksField.tsx +202 -0
- package/src/admin/ui/components/fields/BooleanField.tsx +50 -0
- package/src/admin/ui/components/fields/CollapsibleField.tsx +75 -0
- package/src/admin/ui/components/fields/DateField.tsx +45 -0
- package/src/admin/ui/components/fields/FileField.tsx +322 -0
- package/src/admin/ui/components/fields/GroupField.tsx +50 -0
- package/src/admin/ui/components/fields/JoinField.tsx +23 -0
- package/src/admin/ui/components/fields/NumberField.tsx +46 -0
- package/src/admin/ui/components/fields/RadioField.tsx +62 -0
- package/src/admin/ui/components/fields/RelationshipField.tsx +278 -0
- package/src/admin/ui/components/fields/RowField.tsx +40 -0
- package/src/admin/ui/components/fields/SelectField.tsx +59 -0
- package/src/admin/ui/components/fields/TabsField.tsx +101 -0
- package/src/admin/ui/components/fields/TextAreaField.tsx +54 -0
- package/src/admin/ui/components/fields/TextField.tsx +49 -0
- package/src/admin/ui/components/fields/VirtualField.tsx +53 -0
- package/src/admin/ui/components/fields/index.tsx +371 -0
- package/src/admin/ui/components/fields/richtext-editor/index.tsx +211 -0
- package/src/admin/ui/components/fields/richtext-editor/nodes/ImageComponent.tsx +142 -0
- package/src/admin/ui/components/fields/richtext-editor/nodes/ImageNode.tsx +95 -0
- package/src/admin/ui/components/fields/richtext-editor/plugins/ComponentPickerPlugin.tsx +226 -0
- package/src/admin/ui/components/fields/richtext-editor/plugins/EditableSyncPlugin.tsx +16 -0
- package/src/admin/ui/components/fields/richtext-editor/plugins/NotionToolbarPlugin.tsx +184 -0
- package/src/admin/ui/components/fields/richtext-editor/plugins/SimpleToolbarPlugin.tsx +240 -0
- package/src/admin/ui/components/fields/richtext-editor/plugins/ValueSyncPlugin.tsx +40 -0
- package/src/admin/ui/components/fields/utils.ts +1 -0
- package/src/admin/ui/components/link.tsx +41 -0
- package/src/admin/ui/components/media/AssetManagerModal.tsx +334 -0
- package/src/admin/ui/components/toast.tsx +72 -0
- package/src/admin/ui/components/ui/accordion.tsx +51 -0
- package/src/admin/ui/components/ui/alert-dialog.tsx +98 -0
- package/src/admin/ui/components/ui/blocks.tsx +32 -0
- package/src/admin/ui/components/ui/breadcrumbs.tsx +59 -0
- package/src/admin/ui/components/ui/button.tsx +26 -0
- package/src/admin/ui/components/ui/collapsible.tsx +124 -0
- package/src/admin/ui/components/ui/dialog.tsx +79 -0
- package/src/admin/ui/components/ui/group.tsx +20 -0
- package/src/admin/ui/components/ui/index.ts +17 -0
- package/src/admin/ui/components/ui/input.tsx +12 -0
- package/src/admin/ui/components/ui/join.tsx +53 -0
- package/src/admin/ui/components/ui/label.tsx +11 -0
- package/src/admin/ui/components/ui/radio-group.tsx +75 -0
- package/src/admin/ui/components/ui/relationship-detail-sheet.tsx +122 -0
- package/src/admin/ui/components/ui/relationship.tsx +58 -0
- package/src/admin/ui/components/ui/scroll-area.tsx +19 -0
- package/src/admin/ui/components/ui/select.tsx +187 -0
- package/src/admin/ui/components/ui/separator.tsx +21 -0
- package/src/admin/ui/components/ui/sheet.tsx +106 -0
- package/src/admin/ui/components/ui/tabs.tsx +116 -0
- package/src/admin/ui/components/ui/utils.ts +3 -0
- package/src/admin/ui/hooks/use-debounce.ts +15 -0
- package/src/admin/ui/styles/_locale-switcher.scss +33 -0
- package/src/admin/ui/styles/accordion.scss +60 -0
- package/src/admin/ui/styles/animations.scss +41 -0
- package/src/admin/ui/styles/asset-manager.scss +547 -0
- package/src/admin/ui/styles/badge.scss +13 -0
- package/src/admin/ui/styles/base.scss +22 -0
- package/src/admin/ui/styles/button.scss +161 -0
- package/src/admin/ui/styles/card.scss +13 -0
- package/src/admin/ui/styles/collapsible.scss +75 -0
- package/src/admin/ui/styles/data-detail.scss +92 -0
- package/src/admin/ui/styles/dialog.scss +102 -0
- package/src/admin/ui/styles/empty-state.scss +22 -0
- package/src/admin/ui/styles/group.scss +19 -0
- package/src/admin/ui/styles/index.scss +33 -0
- package/src/admin/ui/styles/input.scss +80 -0
- package/src/admin/ui/styles/label.scss +12 -0
- package/src/admin/ui/styles/layout.scss +56 -0
- package/src/admin/ui/styles/lexical.scss +469 -0
- package/src/admin/ui/styles/loading.scss +102 -0
- package/src/admin/ui/styles/media-registry.scss +597 -0
- package/src/admin/ui/styles/pagination.scss +20 -0
- package/src/admin/ui/styles/radio-group.scss +66 -0
- package/src/admin/ui/styles/row.scss +17 -0
- package/src/admin/ui/styles/scrollbar.scss +36 -0
- package/src/admin/ui/styles/select.scss +121 -0
- package/src/admin/ui/styles/separator.scss +14 -0
- package/src/admin/ui/styles/sheet.scss +152 -0
- package/src/admin/ui/styles/sidebar.scss +148 -0
- package/src/admin/ui/styles/switch.scss +59 -0
- package/src/admin/ui/styles/table.scss +207 -0
- package/src/admin/ui/styles/tabs.scss +62 -0
- package/src/admin/ui/styles/toast.scss +45 -0
- package/src/admin/ui/styles/variables.scss +24 -0
- package/src/admin/ui/views/collection-list-view.tsx +720 -0
- package/src/admin/ui/views/dashboard-view.tsx +263 -0
- package/src/admin/ui/views/document-edit-view.tsx +384 -0
- package/src/admin/ui/views/global-edit-view.tsx +226 -0
- package/src/admin/ui/views/init-view.tsx +182 -0
- package/src/admin/ui/views/login-view.tsx +123 -0
- package/src/admin/ui/views/media-registry-view.tsx +1104 -0
- package/src/admin/ui/views/settings-view.tsx +729 -0
- package/src/admin/webcomponent.tsx +15 -0
- package/src/api.ts +9 -0
- package/src/auth/index.ts +194 -0
- package/src/auth/migrations.ts +87 -0
- package/src/auth/premissions.ts +46 -0
- package/src/cli/commands/generate-types.ts +116 -0
- package/src/cli/commands/init.ts +95 -0
- package/src/cli/commands/migrate-commands.ts +160 -0
- package/src/cli/commands/seed-command.ts +11 -0
- package/src/cli/d1-mock.ts +101 -0
- package/src/cli/index.test.ts +84 -0
- package/src/cli/index.ts +183 -0
- package/src/cli/r2-mock.ts +217 -0
- package/src/cli/seeding.ts +405 -0
- package/src/client.ts +181 -0
- package/src/config-utils.ts +102 -0
- package/src/config.ts +49 -0
- package/src/db/adapter.ts +53 -0
- package/src/db/better-sqlite.ts +630 -0
- package/src/db/bun-sqlite.ts +646 -0
- package/src/db/d1.ts +711 -0
- package/src/db/kysely/data-mapper.ts +142 -0
- package/src/db/kysely/field-mapper.ts +148 -0
- package/src/db/kysely/migration-generator.ts +223 -0
- package/src/db/kysely/query-builder.ts +92 -0
- package/src/db/kysely/schema-builder.ts +439 -0
- package/src/db/kysely/sql-utils.ts +13 -0
- package/src/db/postgres.ts +621 -0
- package/src/db/sqlite.ts +658 -0
- package/src/db/system-schema.ts +121 -0
- package/src/index.ts +13 -0
- package/src/runtimes/README.md +59 -0
- package/src/runtimes/bun.ts +49 -0
- package/src/runtimes/cloudflare-workers.ts +38 -0
- package/src/runtimes/next.ts +26 -0
- package/src/runtimes/node.ts +52 -0
- package/src/schema/collection.ts +184 -0
- package/src/schema/fields/base.ts +164 -0
- package/src/schema/fields/index.ts +427 -0
- package/src/schema/global.ts +145 -0
- package/src/schema/index.ts +4 -0
- package/src/schema/infer.ts +72 -0
- package/src/server/admin-router.ts +20 -0
- package/src/server/admin.ts +142 -0
- package/src/server/assets.ts +306 -0
- package/src/server/collection-router.ts +55 -0
- package/src/server/handlers.ts +722 -0
- package/src/server/middlewares/admin.ts +27 -0
- package/src/server/middlewares/auth.ts +89 -0
- package/src/server/middlewares/context.ts +17 -0
- package/src/server/middlewares/cors.ts +24 -0
- package/src/server/middlewares/database-init.ts +74 -0
- package/src/server/middlewares/rate-limit.ts +71 -0
- package/src/server/router.ts +47 -0
- package/src/server/setup-middlewares.ts +58 -0
- package/src/server/system-router.ts +35 -0
- package/src/server.ts +9 -0
- package/src/storage/adapters/cloudflare-r2.ts +136 -0
- package/src/storage/adapters/local.ts +146 -0
- package/src/storage/adapters/s3.ts +186 -0
- package/src/storage/errors.ts +46 -0
- package/src/storage/index.ts +5 -0
- package/src/storage/types.ts +39 -0
- package/src/types.ts +577 -0
- package/src/utils/lexical.ts +37 -0
- package/src/utils/logger.ts +73 -0
- package/src/validation.ts +429 -0
- package/src/validator.ts +179 -0
- package/test/admin-custom-field.test.ts +162 -0
- package/test/admin-react-field.test.tsx +134 -0
- package/test/api-features.test.ts +78 -0
- package/test/api.test.ts +178 -0
- package/test/auth.test.ts +62 -0
- package/test/cli-integration.test.ts +146 -0
- package/test/cli.test.ts +25 -0
- package/test/db/postgres.test.ts +95 -0
- package/test/db/sqlite-filter.test.ts +53 -0
- package/test/db/sqlite.test.ts +82 -0
- package/test/engine-features.test.ts +79 -0
- package/test/globals.test.ts +74 -0
- package/test/integration-tmp/db-app/opacacms.config.ts +15 -0
- package/test/integration-tmp/my-sqlite-app/opacacms.config.ts +25 -0
- package/test/integration-tmp/my-test-app/index.ts +8 -0
- package/test/integration-tmp/my-test-app/opacacms.config.ts +16 -0
- package/test/integration-tmp/my-test-app/package.json +12 -0
- package/test/populate.test.ts +79 -0
- package/test/runtimes.test.ts +43 -0
- package/test/schema-builder.test.ts +107 -0
- package/test/schema-features.test.ts +63 -0
- package/test/seeding.test.ts +68 -0
- package/test/storage/local.test.ts +72 -0
- package/test/storage/s3.test.ts +60 -0
- package/test/structural-data.test.ts +100 -0
- package/test/test-setup.ts +11 -0
- package/test/validation.test.ts +162 -0
- package/tsconfig.json +42 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
// src/validation.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var FieldTypeSchema = z.enum([
|
|
4
|
+
"text",
|
|
5
|
+
"slug",
|
|
6
|
+
"textarea",
|
|
7
|
+
"number",
|
|
8
|
+
"richtext",
|
|
9
|
+
"relationship",
|
|
10
|
+
"select",
|
|
11
|
+
"radio",
|
|
12
|
+
"date",
|
|
13
|
+
"boolean",
|
|
14
|
+
"json",
|
|
15
|
+
"file",
|
|
16
|
+
"blocks",
|
|
17
|
+
"group",
|
|
18
|
+
"row",
|
|
19
|
+
"collapsible",
|
|
20
|
+
"tabs",
|
|
21
|
+
"join",
|
|
22
|
+
"array",
|
|
23
|
+
"virtual"
|
|
24
|
+
]);
|
|
25
|
+
var BaseFieldSchema = z.object({
|
|
26
|
+
name: z.string(),
|
|
27
|
+
label: z.string().optional(),
|
|
28
|
+
required: z.boolean().optional().default(false),
|
|
29
|
+
unique: z.boolean().optional().default(false),
|
|
30
|
+
localized: z.boolean().optional(),
|
|
31
|
+
defaultValue: z.any().optional(),
|
|
32
|
+
validate: z.function().optional(),
|
|
33
|
+
admin: z.object({
|
|
34
|
+
description: z.string().optional(),
|
|
35
|
+
condition: z.function().optional(),
|
|
36
|
+
hidden: z.boolean().optional(),
|
|
37
|
+
readOnly: z.boolean().optional(),
|
|
38
|
+
width: z.string().optional(),
|
|
39
|
+
style: z.any().optional(),
|
|
40
|
+
className: z.string().optional(),
|
|
41
|
+
components: z.object({
|
|
42
|
+
Field: z.string().optional(),
|
|
43
|
+
Cell: z.string().optional()
|
|
44
|
+
}).optional()
|
|
45
|
+
}).optional()
|
|
46
|
+
});
|
|
47
|
+
var FieldSchema = z.lazy(() => z.discriminatedUnion("type", [
|
|
48
|
+
BaseFieldSchema.extend({ type: z.literal("text") }),
|
|
49
|
+
BaseFieldSchema.extend({
|
|
50
|
+
type: z.literal("slug"),
|
|
51
|
+
from: z.string(),
|
|
52
|
+
format: z.function().optional()
|
|
53
|
+
}),
|
|
54
|
+
BaseFieldSchema.extend({ type: z.literal("textarea") }),
|
|
55
|
+
BaseFieldSchema.extend({ type: z.literal("number") }),
|
|
56
|
+
BaseFieldSchema.extend({ type: z.literal("date") }),
|
|
57
|
+
BaseFieldSchema.extend({
|
|
58
|
+
type: z.literal("boolean"),
|
|
59
|
+
options: z.object({
|
|
60
|
+
display: z.enum(["switch", "toggle", "checkbox", "select"]).optional().default("switch")
|
|
61
|
+
}).loose().optional()
|
|
62
|
+
}),
|
|
63
|
+
BaseFieldSchema.extend({
|
|
64
|
+
type: z.literal("richtext"),
|
|
65
|
+
options: z.object({
|
|
66
|
+
defaultMode: z.enum(["simple", "notion"]).optional()
|
|
67
|
+
}).loose().optional()
|
|
68
|
+
}),
|
|
69
|
+
BaseFieldSchema.extend({
|
|
70
|
+
type: z.literal("relationship"),
|
|
71
|
+
relationTo: z.string(),
|
|
72
|
+
hasMany: z.boolean().optional(),
|
|
73
|
+
displayField: z.string().optional(),
|
|
74
|
+
references: z.object({
|
|
75
|
+
table: z.string(),
|
|
76
|
+
column: z.string(),
|
|
77
|
+
onDelete: z.enum(["cascade", "set null", "restrict", "no action"]).optional()
|
|
78
|
+
}).optional()
|
|
79
|
+
}),
|
|
80
|
+
BaseFieldSchema.extend({
|
|
81
|
+
type: z.literal("select"),
|
|
82
|
+
options: z.object({
|
|
83
|
+
choices: z.array(z.union([z.string(), z.object({ label: z.string(), value: z.string() })]))
|
|
84
|
+
}).loose().optional()
|
|
85
|
+
}),
|
|
86
|
+
BaseFieldSchema.extend({
|
|
87
|
+
type: z.literal("radio"),
|
|
88
|
+
options: z.object({
|
|
89
|
+
choices: z.array(z.union([z.string(), z.object({ label: z.string(), value: z.string() })]))
|
|
90
|
+
}).loose()
|
|
91
|
+
}),
|
|
92
|
+
BaseFieldSchema.extend({
|
|
93
|
+
type: z.literal("file"),
|
|
94
|
+
bucket: z.string().optional(),
|
|
95
|
+
options: z.object({
|
|
96
|
+
allowedmime_types: z.array(z.string()).optional(),
|
|
97
|
+
maxFileSize: z.number().optional(),
|
|
98
|
+
metaFields: z.array(z.lazy(() => FieldSchema)).optional()
|
|
99
|
+
}).loose().optional()
|
|
100
|
+
}),
|
|
101
|
+
BaseFieldSchema.extend({
|
|
102
|
+
type: z.literal("json"),
|
|
103
|
+
fields: z.array(z.lazy(() => FieldSchema)).optional()
|
|
104
|
+
}),
|
|
105
|
+
BaseFieldSchema.extend({
|
|
106
|
+
type: z.literal("blocks"),
|
|
107
|
+
blocks: z.array(z.object({
|
|
108
|
+
slug: z.string(),
|
|
109
|
+
fields: z.array(z.lazy(() => FieldSchema)),
|
|
110
|
+
label: z.string().optional()
|
|
111
|
+
}))
|
|
112
|
+
}),
|
|
113
|
+
BaseFieldSchema.extend({
|
|
114
|
+
type: z.literal("group"),
|
|
115
|
+
fields: z.array(z.lazy(() => FieldSchema))
|
|
116
|
+
}),
|
|
117
|
+
z.object({
|
|
118
|
+
name: z.string().optional(),
|
|
119
|
+
type: z.literal("row"),
|
|
120
|
+
fields: z.array(z.lazy(() => FieldSchema)),
|
|
121
|
+
label: z.string().optional()
|
|
122
|
+
}),
|
|
123
|
+
z.object({
|
|
124
|
+
name: z.string().optional(),
|
|
125
|
+
type: z.literal("collapsible"),
|
|
126
|
+
fields: z.array(z.lazy(() => FieldSchema)),
|
|
127
|
+
label: z.string().optional(),
|
|
128
|
+
options: z.object({
|
|
129
|
+
initiallyCollapsed: z.boolean().optional()
|
|
130
|
+
}).loose().optional()
|
|
131
|
+
}),
|
|
132
|
+
z.object({
|
|
133
|
+
name: z.string().optional(),
|
|
134
|
+
type: z.literal("tabs"),
|
|
135
|
+
tabs: z.array(z.object({
|
|
136
|
+
label: z.string(),
|
|
137
|
+
fields: z.array(z.lazy(() => FieldSchema))
|
|
138
|
+
}))
|
|
139
|
+
}),
|
|
140
|
+
z.object({
|
|
141
|
+
name: z.string().optional().refine((val) => val === undefined, {
|
|
142
|
+
message: "Join fields are virtual and should not have a 'name' property. They are mapped dynamically via the API."
|
|
143
|
+
}).or(z.string()),
|
|
144
|
+
type: z.literal("join"),
|
|
145
|
+
collection: z.string(),
|
|
146
|
+
on: z.string(),
|
|
147
|
+
label: z.string().optional()
|
|
148
|
+
}),
|
|
149
|
+
BaseFieldSchema.extend({
|
|
150
|
+
type: z.literal("array"),
|
|
151
|
+
fields: z.array(z.lazy(() => FieldSchema)).optional()
|
|
152
|
+
}),
|
|
153
|
+
BaseFieldSchema.extend({
|
|
154
|
+
type: z.literal("virtual"),
|
|
155
|
+
resolve: z.function(),
|
|
156
|
+
returnType: z.string().optional()
|
|
157
|
+
})
|
|
158
|
+
]));
|
|
159
|
+
var AccessConfigSchema = z.object({
|
|
160
|
+
read: z.union([z.boolean(), z.function()]).optional(),
|
|
161
|
+
create: z.union([z.boolean(), z.function()]).optional(),
|
|
162
|
+
update: z.union([z.boolean(), z.function()]).optional(),
|
|
163
|
+
delete: z.union([z.boolean(), z.function()]).optional(),
|
|
164
|
+
requireApiKey: z.boolean().optional()
|
|
165
|
+
});
|
|
166
|
+
var CollectionHooksSchema = z.object({
|
|
167
|
+
beforeCreate: z.function().optional(),
|
|
168
|
+
afterCreate: z.function().optional(),
|
|
169
|
+
beforeUpdate: z.function().optional(),
|
|
170
|
+
afterUpdate: z.function().optional(),
|
|
171
|
+
beforeDelete: z.function().optional(),
|
|
172
|
+
afterDelete: z.function().optional()
|
|
173
|
+
});
|
|
174
|
+
var CollectionSchema = z.object({
|
|
175
|
+
slug: z.string(),
|
|
176
|
+
label: z.string().optional(),
|
|
177
|
+
icon: z.string().optional(),
|
|
178
|
+
apiPath: z.string().optional(),
|
|
179
|
+
fields: z.array(FieldSchema),
|
|
180
|
+
timestamps: z.union([
|
|
181
|
+
z.boolean(),
|
|
182
|
+
z.object({
|
|
183
|
+
createdAt: z.string().optional(),
|
|
184
|
+
updatedAt: z.string().optional()
|
|
185
|
+
})
|
|
186
|
+
]).optional(),
|
|
187
|
+
auth: z.boolean().optional(),
|
|
188
|
+
hooks: CollectionHooksSchema.optional(),
|
|
189
|
+
access: AccessConfigSchema.optional(),
|
|
190
|
+
versions: z.object({
|
|
191
|
+
drafts: z.boolean().optional(),
|
|
192
|
+
maxRevisions: z.number().optional(),
|
|
193
|
+
autosave: z.boolean().optional()
|
|
194
|
+
}).optional(),
|
|
195
|
+
webhooks: z.array(z.object({
|
|
196
|
+
events: z.array(z.string()),
|
|
197
|
+
url: z.string(),
|
|
198
|
+
headers: z.record(z.string(), z.string()).optional()
|
|
199
|
+
})).optional(),
|
|
200
|
+
admin: z.union([
|
|
201
|
+
z.boolean(),
|
|
202
|
+
z.object({
|
|
203
|
+
defaultColumns: z.array(z.string()).optional(),
|
|
204
|
+
useAsTitle: z.string().optional(),
|
|
205
|
+
hidden: z.boolean().optional(),
|
|
206
|
+
disableAdmin: z.boolean().optional(),
|
|
207
|
+
views: z.array(z.object({
|
|
208
|
+
name: z.string(),
|
|
209
|
+
filter: z.record(z.string(), z.any()),
|
|
210
|
+
defaultColumns: z.array(z.string()).optional()
|
|
211
|
+
})).optional(),
|
|
212
|
+
bulkActions: z.array(z.object({
|
|
213
|
+
label: z.string(),
|
|
214
|
+
action: z.function()
|
|
215
|
+
})).optional()
|
|
216
|
+
})
|
|
217
|
+
]).optional(),
|
|
218
|
+
hidden: z.boolean().optional()
|
|
219
|
+
});
|
|
220
|
+
var GlobalSchema = z.object({
|
|
221
|
+
slug: z.string(),
|
|
222
|
+
label: z.string().optional(),
|
|
223
|
+
icon: z.string().optional(),
|
|
224
|
+
fields: z.array(FieldSchema),
|
|
225
|
+
timestamps: z.union([
|
|
226
|
+
z.boolean(),
|
|
227
|
+
z.object({
|
|
228
|
+
createdAt: z.string().optional(),
|
|
229
|
+
updatedAt: z.string().optional()
|
|
230
|
+
})
|
|
231
|
+
]).optional(),
|
|
232
|
+
access: AccessConfigSchema.optional()
|
|
233
|
+
});
|
|
234
|
+
var AdminConfigSchema = z.object({
|
|
235
|
+
userCollection: z.string().optional(),
|
|
236
|
+
disableAdmin: z.boolean().optional(),
|
|
237
|
+
route: z.string().optional()
|
|
238
|
+
});
|
|
239
|
+
var OpacaAuthConfigSchema = z.object({
|
|
240
|
+
strategies: z.object({
|
|
241
|
+
emailPassword: z.boolean().optional(),
|
|
242
|
+
magicLink: z.object({
|
|
243
|
+
enabled: z.boolean(),
|
|
244
|
+
sendEmail: z.function()
|
|
245
|
+
}).optional()
|
|
246
|
+
}).optional(),
|
|
247
|
+
socialProviders: z.object({
|
|
248
|
+
github: z.object({
|
|
249
|
+
clientId: z.string(),
|
|
250
|
+
clientSecret: z.string()
|
|
251
|
+
}).optional(),
|
|
252
|
+
google: z.object({
|
|
253
|
+
clientId: z.string(),
|
|
254
|
+
clientSecret: z.string()
|
|
255
|
+
}).optional()
|
|
256
|
+
}).optional(),
|
|
257
|
+
session: z.object({
|
|
258
|
+
expiresInDays: z.number().optional(),
|
|
259
|
+
updateAgeSeconds: z.number().optional()
|
|
260
|
+
}).optional(),
|
|
261
|
+
features: z.object({
|
|
262
|
+
apiKeys: z.object({
|
|
263
|
+
enabled: z.boolean()
|
|
264
|
+
}).optional(),
|
|
265
|
+
mfa: z.object({
|
|
266
|
+
enabled: z.boolean(),
|
|
267
|
+
issuer: z.string()
|
|
268
|
+
}).optional()
|
|
269
|
+
}).optional()
|
|
270
|
+
});
|
|
271
|
+
var ApiConfigSchema = z.object({
|
|
272
|
+
maxLimit: z.number().optional(),
|
|
273
|
+
rateLimit: z.object({
|
|
274
|
+
windowMs: z.number().optional(),
|
|
275
|
+
limit: z.number().optional(),
|
|
276
|
+
enabled: z.boolean().optional(),
|
|
277
|
+
store: z.any().optional(),
|
|
278
|
+
provider: z.function().optional(),
|
|
279
|
+
keyGenerator: z.function().optional()
|
|
280
|
+
}).optional()
|
|
281
|
+
});
|
|
282
|
+
var OpacaConfigSchema = z.object({
|
|
283
|
+
collections: z.array(CollectionSchema),
|
|
284
|
+
globals: z.array(GlobalSchema).optional(),
|
|
285
|
+
db: z.any(),
|
|
286
|
+
storages: z.record(z.string(), z.any()).optional(),
|
|
287
|
+
runMigrationsOnStartup: z.boolean().optional(),
|
|
288
|
+
admin: AdminConfigSchema.optional(),
|
|
289
|
+
serverURL: z.string().optional(),
|
|
290
|
+
appName: z.string().optional(),
|
|
291
|
+
secret: z.string().optional(),
|
|
292
|
+
trustedOrigins: z.union([z.array(z.string()), z.function()]).optional(),
|
|
293
|
+
auth: OpacaAuthConfigSchema.optional(),
|
|
294
|
+
api: ApiConfigSchema.optional(),
|
|
295
|
+
access: z.object({
|
|
296
|
+
roles: z.record(z.string(), z.record(z.string(), z.array(z.string()))).optional()
|
|
297
|
+
}).optional(),
|
|
298
|
+
i18n: z.object({
|
|
299
|
+
locales: z.array(z.string()),
|
|
300
|
+
defaultLocale: z.string()
|
|
301
|
+
}).optional()
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
// src/config.ts
|
|
305
|
+
function recursivelyBuild(obj) {
|
|
306
|
+
if (!obj || typeof obj !== "object")
|
|
307
|
+
return obj;
|
|
308
|
+
if (typeof obj.build === "function") {
|
|
309
|
+
return recursivelyBuild(obj.build());
|
|
310
|
+
}
|
|
311
|
+
if (Array.isArray(obj)) {
|
|
312
|
+
return obj.map(recursivelyBuild);
|
|
313
|
+
}
|
|
314
|
+
if (obj.constructor !== Object) {
|
|
315
|
+
return obj;
|
|
316
|
+
}
|
|
317
|
+
const built = {};
|
|
318
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
319
|
+
built[key] = recursivelyBuild(value);
|
|
320
|
+
}
|
|
321
|
+
return built;
|
|
322
|
+
}
|
|
323
|
+
function defineConfig(config) {
|
|
324
|
+
const builtConfig = recursivelyBuild(config);
|
|
325
|
+
const result = OpacaConfigSchema.safeParse(builtConfig);
|
|
326
|
+
if (!result.success) {
|
|
327
|
+
throw new Error(`Invalid OpacaCMS Configuration: ${result.error.message}`);
|
|
328
|
+
}
|
|
329
|
+
return builtConfig;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export { defineConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateTypesCommand(url: string, token: string, out: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initCommand(target: string, example?: string): Promise<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DatabaseAdapter, OpacaConfig } from "../../types";
|
|
2
|
+
export declare function migrateCreateCommand(opaca: OpacaConfig, migrationName?: string, outDir?: string): Promise<void>;
|
|
3
|
+
export declare function migrateRunCommand(db: DatabaseAdapter): Promise<void>;
|
|
4
|
+
export declare function migrateStatusCommand(opaca: OpacaConfig): Promise<void>;
|
|
5
|
+
export declare function migrateD1Command(migrationDir: string, isRemote: boolean, binding?: string): Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal D1Database mock that wraps bun:sqlite to allow OpacaCMS CLI
|
|
3
|
+
* to run D1-based configurations locally.
|
|
4
|
+
*
|
|
5
|
+
* It prioritizes Wrangler's local state if found.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createD1Mock(dbPath?: string): {
|
|
8
|
+
prepare(query: string): {
|
|
9
|
+
bind(...params: any[]): /*elided*/ any;
|
|
10
|
+
first(): Promise<unknown>;
|
|
11
|
+
all(): Promise<{
|
|
12
|
+
results: unknown[];
|
|
13
|
+
success: boolean;
|
|
14
|
+
meta: {};
|
|
15
|
+
}>;
|
|
16
|
+
run(): Promise<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
meta: {
|
|
19
|
+
changes: number;
|
|
20
|
+
last_row_id: number | bigint;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
raw(): Promise<unknown[]>;
|
|
24
|
+
};
|
|
25
|
+
batch(statements: any[]): Promise<any[]>;
|
|
26
|
+
exec(query: string): Promise<{
|
|
27
|
+
count: number;
|
|
28
|
+
duration: number;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal R2Bucket mock for OpacaCMS CLI that uses Wrangler's local state.
|
|
3
|
+
* Stores metadata in _mf_objects table and blobs in .blobs sibling directory.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createR2Mock(dbPath?: string): {
|
|
6
|
+
put(key: string, value: any, options?: any): Promise<{
|
|
7
|
+
key: string;
|
|
8
|
+
size: number;
|
|
9
|
+
etag: string;
|
|
10
|
+
httpMetadata: any;
|
|
11
|
+
customMetadata: any;
|
|
12
|
+
}>;
|
|
13
|
+
get(key: string): Promise<{
|
|
14
|
+
key: any;
|
|
15
|
+
size: any;
|
|
16
|
+
etag: any;
|
|
17
|
+
uploaded: Date;
|
|
18
|
+
httpMetadata: any;
|
|
19
|
+
customMetadata: any;
|
|
20
|
+
body: ReadableStream<any>;
|
|
21
|
+
bodyUsed: boolean;
|
|
22
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
23
|
+
text(): Promise<string>;
|
|
24
|
+
json(): Promise<any>;
|
|
25
|
+
} | null>;
|
|
26
|
+
head(key: string): Promise<{
|
|
27
|
+
key: any;
|
|
28
|
+
size: any;
|
|
29
|
+
etag: any;
|
|
30
|
+
uploaded: Date;
|
|
31
|
+
httpMetadata: any;
|
|
32
|
+
customMetadata: any;
|
|
33
|
+
} | null>;
|
|
34
|
+
delete(key: string): Promise<void>;
|
|
35
|
+
list(): Promise<{
|
|
36
|
+
objects: {
|
|
37
|
+
key: any;
|
|
38
|
+
size: any;
|
|
39
|
+
etag: any;
|
|
40
|
+
uploaded: Date;
|
|
41
|
+
httpMetadata: any;
|
|
42
|
+
customMetadata: any;
|
|
43
|
+
}[];
|
|
44
|
+
truncated: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Collection, DatabaseAdapter, OpacaConfig } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Default generators for each field type.
|
|
4
|
+
*/
|
|
5
|
+
export declare const defaultFieldGenerators: Record<string, () => any>;
|
|
6
|
+
/**
|
|
7
|
+
* Generates a single record for a collection.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateRecord(db: DatabaseAdapter, collection: Collection, locales?: string[]): Promise<Record<string, any>>;
|
|
10
|
+
/**
|
|
11
|
+
* Topologically sorts collections based on their dependencies.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sortCollections(collections: Collection[]): Collection[];
|
|
14
|
+
/**
|
|
15
|
+
* Seeds the database with mock data.
|
|
16
|
+
*/
|
|
17
|
+
export declare function autoSeed(config: OpacaConfig, countPerCollection?: number, reset?: boolean, type?: "collections" | "assets" | "all"): Promise<void>;
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { OpacaConfig } from "./types";
|
|
2
|
+
export interface OpacaClientOptions {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
token?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A proxy-based client that provides a typed experience for interacting with the OpacaCMS API.
|
|
8
|
+
*/
|
|
9
|
+
export interface GeneratedTypes {
|
|
10
|
+
collections: Record<string, any>;
|
|
11
|
+
globals: Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Custom error class for OpacaCMS SDK errors.
|
|
15
|
+
*/
|
|
16
|
+
export declare class OpacaError extends Error {
|
|
17
|
+
status: number;
|
|
18
|
+
data: any;
|
|
19
|
+
constructor(message: string, status: number, data?: any);
|
|
20
|
+
}
|
|
21
|
+
export declare function createClient<T = any>(configOrOptions: T | OpacaClientOptions): {
|
|
22
|
+
getMetadata: () => Promise<any>;
|
|
23
|
+
getCollections: () => Promise<any[]>;
|
|
24
|
+
getSetupStatus: () => Promise<{
|
|
25
|
+
initialized: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
collections: { [K in T extends OpacaConfig<string> ? T["collections"] extends any[] ? T["collections"][number]["slug"] : string : T extends GeneratedTypes ? keyof T["collections"] : string]: {
|
|
28
|
+
find: (query?: any) => Promise<{
|
|
29
|
+
docs: (T extends GeneratedTypes ? K extends keyof T["collections"] ? T["collections"][K] : any : any)[];
|
|
30
|
+
totalDocs: number;
|
|
31
|
+
page: number;
|
|
32
|
+
totalPages: number;
|
|
33
|
+
}>;
|
|
34
|
+
findOne: (id: string) => Promise<T extends GeneratedTypes ? K extends keyof T["collections"] ? T["collections"][K] : any : any>;
|
|
35
|
+
list: () => Promise<{
|
|
36
|
+
docs: (T extends GeneratedTypes ? K extends keyof T["collections"] ? T["collections"][K] : any : any)[];
|
|
37
|
+
totalDocs: number;
|
|
38
|
+
page: number;
|
|
39
|
+
totalPages: number;
|
|
40
|
+
}>;
|
|
41
|
+
create: (data: Partial<T extends GeneratedTypes ? K extends keyof T["collections"] ? T["collections"][K] : any : any>) => Promise<T extends GeneratedTypes ? K extends keyof T["collections"] ? T["collections"][K] : any : any>;
|
|
42
|
+
update: (id: string, data: Partial<T extends GeneratedTypes ? K extends keyof T["collections"] ? T["collections"][K] : any : any>) => Promise<T extends GeneratedTypes ? K extends keyof T["collections"] ? T["collections"][K] : any : any>;
|
|
43
|
+
delete: (id: string) => Promise<{
|
|
44
|
+
success: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
}; };
|
|
47
|
+
globals: { [K in T extends OpacaConfig<string> ? T["globals"] extends any[] ? T["globals"][number]["slug"] : string : T extends GeneratedTypes ? keyof T["globals"] : string]: {
|
|
48
|
+
get: () => Promise<T extends GeneratedTypes ? K extends keyof T["globals"] ? T["globals"][K] : any : any>;
|
|
49
|
+
update: (data: Partial<T extends GeneratedTypes ? K extends keyof T["globals"] ? T["globals"][K] : any : any>) => Promise<T extends GeneratedTypes ? K extends keyof T["globals"] ? T["globals"][K] : any : any>;
|
|
50
|
+
}; };
|
|
51
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OpacaConfig, SerializableConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Sanitizes the OpacaConfig to ensure it's safe to pass to Client Components or over the API.
|
|
4
|
+
* Strips out functions (hooks, access) and the database adapter.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sanitizeConfig(config: OpacaConfig): SerializableConfig;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to define the OpacaCMS configuration with full type safety.
|
|
3
|
+
*/
|
|
4
|
+
import type { Collection, OpacaConfig } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Helper logic to infer slugs from collections.
|
|
7
|
+
*/
|
|
8
|
+
export declare function defineConfig<const TCollections extends readonly Collection[]>(config: OpacaConfig<TCollections[number]["slug"]> & {
|
|
9
|
+
collections: TCollections;
|
|
10
|
+
}): OpacaConfig<TCollections[number]["slug"]>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Collection, DatabaseAdapter, FindOptions, Global, PaginatedResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* BaseDatabaseAdapter is an abstract class that implements the DatabaseAdapter interface.
|
|
4
|
+
* It provides a foundation for database adapters and enforces the implementation of required methods.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class BaseDatabaseAdapter implements DatabaseAdapter {
|
|
7
|
+
abstract name: string;
|
|
8
|
+
get raw(): unknown;
|
|
9
|
+
get db(): unknown;
|
|
10
|
+
abstract connect(): Promise<void>;
|
|
11
|
+
abstract disconnect(): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Execute a raw SQL query directly on the database.
|
|
14
|
+
*/
|
|
15
|
+
abstract unsafe(sql: string, params?: any[]): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Count documents in a collection.
|
|
18
|
+
*/
|
|
19
|
+
abstract count(collection: string, query?: any): Promise<number>;
|
|
20
|
+
abstract create<T extends object>(collection: string, data: Partial<T>): Promise<T>;
|
|
21
|
+
abstract find<T extends object>(collection: string, query?: any, options?: FindOptions): Promise<PaginatedResult<T>>;
|
|
22
|
+
abstract findOne<T extends object>(collection: string, query: any): Promise<T | null>;
|
|
23
|
+
abstract update<T extends object>(collection: string, query: any, data: Partial<T>): Promise<T>;
|
|
24
|
+
abstract updateMany?<T extends object>(collection: string, query: any, data: Partial<T>): Promise<number>;
|
|
25
|
+
abstract delete(collection: string, query: any): Promise<boolean>;
|
|
26
|
+
abstract deleteMany?(collection: string, query: any): Promise<number>;
|
|
27
|
+
abstract findGlobal?<T extends object>(slug: string): Promise<T | null>;
|
|
28
|
+
abstract updateGlobal?<T extends object>(slug: string, data: Partial<T>): Promise<T>;
|
|
29
|
+
abstract migrate(collections: Collection[], globals?: Global[]): Promise<void>;
|
|
30
|
+
push?: boolean;
|
|
31
|
+
pushDestructive?: boolean;
|
|
32
|
+
migrationDir?: string;
|
|
33
|
+
runMigrations?(): Promise<void>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Kysely } from "kysely";
|
|
2
|
+
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
3
|
+
import { BaseDatabaseAdapter } from "./adapter";
|
|
4
|
+
export declare class BetterSQLiteAdapter extends BaseDatabaseAdapter {
|
|
5
|
+
name: string;
|
|
6
|
+
private _rawDb;
|
|
7
|
+
private _db;
|
|
8
|
+
private _collections;
|
|
9
|
+
push: boolean;
|
|
10
|
+
migrationDir: string;
|
|
11
|
+
pushDestructive: boolean;
|
|
12
|
+
get raw(): any;
|
|
13
|
+
get db(): Kysely<any>;
|
|
14
|
+
constructor(path: string, options?: {
|
|
15
|
+
push?: boolean;
|
|
16
|
+
pushDestructive?: boolean;
|
|
17
|
+
migrationDir?: string;
|
|
18
|
+
});
|
|
19
|
+
connect(): Promise<void>;
|
|
20
|
+
disconnect(): Promise<void>;
|
|
21
|
+
unsafe(query: string, params?: any[]): Promise<unknown>;
|
|
22
|
+
private coerceData;
|
|
23
|
+
count(collection: string, query?: Record<string, unknown>): Promise<number>;
|
|
24
|
+
create<T extends object>(collection: string, data: Partial<T>): Promise<T>;
|
|
25
|
+
findOne<T extends object>(collection: string, query: Record<string, unknown>, tx?: any): Promise<T | null>;
|
|
26
|
+
find<T extends object>(collection: string, query?: Record<string, unknown>, options?: FindOptions): Promise<PaginatedResult<T>>;
|
|
27
|
+
update<T extends object>(collection: string, query: Record<string, unknown> | string | number, data: Partial<T>): Promise<T>;
|
|
28
|
+
delete(collection: string, query: Record<string, unknown> | string | number): Promise<boolean>;
|
|
29
|
+
updateMany<T extends object>(collection: string, query: Record<string, unknown>, data: Partial<T>): Promise<number>;
|
|
30
|
+
deleteMany(collection: string, query: Record<string, unknown>): Promise<number>;
|
|
31
|
+
findGlobal<T extends object>(slug: string): Promise<T | null>;
|
|
32
|
+
updateGlobal<T extends object>(slug: string, data: Partial<T>): Promise<T>;
|
|
33
|
+
runMigrations(): Promise<void>;
|
|
34
|
+
migrate(collections: Collection[], globals?: Global[]): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export declare function createBetterSQLiteAdapter(path: string, options?: {
|
|
37
|
+
push?: boolean;
|
|
38
|
+
pushDestructive?: boolean;
|
|
39
|
+
migrationDir?: string;
|
|
40
|
+
}): BetterSQLiteAdapter;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Kysely } from "kysely";
|
|
2
|
+
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
3
|
+
import { BaseDatabaseAdapter } from "./adapter";
|
|
4
|
+
export declare class BunSQLiteAdapter extends BaseDatabaseAdapter {
|
|
5
|
+
name: string;
|
|
6
|
+
private _rawDb;
|
|
7
|
+
private _db;
|
|
8
|
+
private _collections;
|
|
9
|
+
push: boolean;
|
|
10
|
+
migrationDir: string;
|
|
11
|
+
pushDestructive: boolean;
|
|
12
|
+
get raw(): any;
|
|
13
|
+
get db(): Kysely<any>;
|
|
14
|
+
constructor(path: string, options?: {
|
|
15
|
+
push?: boolean;
|
|
16
|
+
pushDestructive?: boolean;
|
|
17
|
+
migrationDir?: string;
|
|
18
|
+
});
|
|
19
|
+
connect(): Promise<void>;
|
|
20
|
+
disconnect(): Promise<void>;
|
|
21
|
+
unsafe(query: string, params?: any[]): Promise<unknown>;
|
|
22
|
+
private coerceData;
|
|
23
|
+
count(collection: string, query?: Record<string, unknown>): Promise<number>;
|
|
24
|
+
create<T extends object>(collection: string, data: Partial<T>): Promise<T>;
|
|
25
|
+
findOne<T extends object>(collection: string, query: Record<string, unknown>, tx?: any): Promise<T | null>;
|
|
26
|
+
find<T extends object>(collection: string, query?: Record<string, unknown>, options?: FindOptions): Promise<PaginatedResult<T>>;
|
|
27
|
+
update<T extends object>(collection: string, query: Record<string, unknown> | string | number, data: Partial<T>): Promise<T>;
|
|
28
|
+
updateMany<T extends object>(collection: string, query: Record<string, unknown>, data: Partial<T>): Promise<number>;
|
|
29
|
+
delete(collection: string, query: Record<string, unknown> | string | number): Promise<boolean>;
|
|
30
|
+
deleteMany(collection: string, query: Record<string, unknown>): Promise<number>;
|
|
31
|
+
findGlobal<T extends object>(slug: string): Promise<T | null>;
|
|
32
|
+
updateGlobal<T extends object>(slug: string, data: Partial<T>): Promise<T>;
|
|
33
|
+
runMigrations(): Promise<void>;
|
|
34
|
+
migrate(collections: Collection[], globals?: Global[]): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export declare function createBunSQLiteAdapter(path: string, options?: {
|
|
37
|
+
push?: boolean;
|
|
38
|
+
pushDestructive?: boolean;
|
|
39
|
+
migrationDir?: string;
|
|
40
|
+
}): BunSQLiteAdapter;
|