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
package/dist/db/d1.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { D1Database } from "@cloudflare/workers-types";
|
|
2
|
+
import { Kysely } from "kysely";
|
|
3
|
+
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
4
|
+
import { BaseDatabaseAdapter } from "./adapter";
|
|
5
|
+
export declare class D1Adapter extends BaseDatabaseAdapter {
|
|
6
|
+
name: string;
|
|
7
|
+
private _rawDb;
|
|
8
|
+
private _db;
|
|
9
|
+
private _collections;
|
|
10
|
+
private _globals;
|
|
11
|
+
push: boolean;
|
|
12
|
+
migrationDir: string;
|
|
13
|
+
pushDestructive: boolean;
|
|
14
|
+
get raw(): D1Database;
|
|
15
|
+
get db(): Kysely<any>;
|
|
16
|
+
constructor(db: D1Database, options?: {
|
|
17
|
+
push?: boolean;
|
|
18
|
+
pushDestructive?: boolean;
|
|
19
|
+
migrationDir?: string;
|
|
20
|
+
});
|
|
21
|
+
connect(): Promise<void>;
|
|
22
|
+
disconnect(): Promise<void>;
|
|
23
|
+
unsafe(query: string, params?: unknown[]): Promise<unknown>;
|
|
24
|
+
private coerceData;
|
|
25
|
+
count(collection: string, query?: Record<string, unknown>): Promise<number>;
|
|
26
|
+
create<T extends object>(collection: string, data: Partial<T>): Promise<T>;
|
|
27
|
+
findOne<T extends object>(collection: string, query: Record<string, unknown>, tx?: any): Promise<T | null>;
|
|
28
|
+
find<T extends object>(collection: string, query?: Record<string, unknown>, options?: FindOptions): Promise<PaginatedResult<T>>;
|
|
29
|
+
update<T extends object>(collection: string, query: Record<string, unknown> | string | number, data: Partial<T>): Promise<T>;
|
|
30
|
+
updateMany<T extends object>(collection: string, query: Record<string, unknown>, data: Partial<T>): Promise<number>;
|
|
31
|
+
delete(collection: string, query: Record<string, unknown> | string | number): Promise<boolean>;
|
|
32
|
+
deleteMany(collection: string, query: Record<string, unknown>): Promise<number>;
|
|
33
|
+
findGlobal<T extends object>(slug: string): Promise<T | null>;
|
|
34
|
+
updateGlobal<T extends object>(slug: string, data: Partial<T>): Promise<T>;
|
|
35
|
+
runMigrations(): Promise<void>;
|
|
36
|
+
migrate(collections: Collection[], globals?: Global[]): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export declare function createD1Adapter(db: D1Database, options?: {
|
|
39
|
+
push?: boolean;
|
|
40
|
+
pushDestructive?: boolean;
|
|
41
|
+
migrationDir?: string;
|
|
42
|
+
}): D1Adapter;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a snake_case string to camelCase.
|
|
3
|
+
*/
|
|
4
|
+
export declare function toCamelCase(str: string): string;
|
|
5
|
+
export declare function flattenPayload(payload: any, prefix?: string, excludeKeys?: string[]): any;
|
|
6
|
+
export declare function unflattenRow(row: any): any;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Field } from "../../types";
|
|
2
|
+
export declare function toSnakeCase(str: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Maps an OpacaCMS FieldType to a Kysely column data type for PostgreSQL.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mapFieldToPostgresType(field: Field): string;
|
|
7
|
+
/**
|
|
8
|
+
* Maps an OpacaCMS FieldType to a Kysely column data type for SQLite/D1.
|
|
9
|
+
*/
|
|
10
|
+
export declare function mapFieldToSQLiteType(field: Field): string;
|
|
11
|
+
/**
|
|
12
|
+
* Recursively flattens a field list, collecting only fields with a 'name'.
|
|
13
|
+
* This skips layout fields like 'row', 'collapsible', 'tabs' while preserving their nested named fields.
|
|
14
|
+
* Group and Blocks fields are also flattened, prefixing their children's names to avoid collisions.
|
|
15
|
+
* It explicitly excludes virtual fields like 'join' since they are resolved at runtime.
|
|
16
|
+
*/
|
|
17
|
+
export declare function flattenFields(fields: Field[], prefix?: string): Field[];
|
|
18
|
+
/**
|
|
19
|
+
* Recursively find all relational fields (relationship with hasMany or blocks).
|
|
20
|
+
* This is used by adapters to fetch related data during findOne/find.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getRelationalFields(fields: Field[], prefix?: string): Field[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Collection, Global } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Generates Kysely migration code for 'up' and 'down' functions based on schema definitions.
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateMigrationCode(collections: Collection[], globals: Global[] | undefined, dialect: "postgres" | "sqlite" | "d1"): string;
|
|
6
|
+
/**
|
|
7
|
+
* Generates raw SQL migration code for Cloudflare D1.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateSQLCode(collections: Collection[], globals?: Global[]): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExpressionBuilder } from "kysely";
|
|
2
|
+
/**
|
|
3
|
+
* Builds a Kysely expression from a generic query object.
|
|
4
|
+
*
|
|
5
|
+
* @param eb The Kysely ExpressionBuilder (e.g., from .where((eb) => buildKyselyWhere(eb, query)))
|
|
6
|
+
* @param query The query object (e.g., { age: { gt: 18 }, name: 'John' })
|
|
7
|
+
* @returns A single Expression combining all conditions with AND, or undefined.
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildKyselyWhere(eb: ExpressionBuilder<any, any>, query: Record<string, any> | undefined): any;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
import type { Collection, Global } from "../../types";
|
|
3
|
+
export type DialectType = "postgres" | "sqlite" | "d1";
|
|
4
|
+
/**
|
|
5
|
+
* Dynamically pushes schemas to the database using Kysely's safe Schema Builder API.
|
|
6
|
+
*
|
|
7
|
+
* @param db The Kysely database instance
|
|
8
|
+
* @param dialect "postgres", "sqlite", or "d1"
|
|
9
|
+
* @param collections The user collections
|
|
10
|
+
* @param globals The user globals
|
|
11
|
+
* @param options Push options
|
|
12
|
+
*/
|
|
13
|
+
export declare function pushSchema(db: Kysely<any>, dialect: DialectType, collections: Collection[], globals?: Global[], options?: {
|
|
14
|
+
pushDestructive?: boolean;
|
|
15
|
+
}): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function assertSafeIdentifier(identifier: string): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Kysely } from "kysely";
|
|
2
|
+
import postgres from "postgres";
|
|
3
|
+
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
4
|
+
import { BaseDatabaseAdapter } from "./adapter";
|
|
5
|
+
export interface PostgresConfig {
|
|
6
|
+
url?: string;
|
|
7
|
+
host?: string;
|
|
8
|
+
port?: number;
|
|
9
|
+
database?: string;
|
|
10
|
+
username?: string;
|
|
11
|
+
password?: string;
|
|
12
|
+
ssl?: boolean | "require" | "allow" | "prefer" | "verify-full" | Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export declare class PostgresAdapter extends BaseDatabaseAdapter {
|
|
15
|
+
name: string;
|
|
16
|
+
private _rawDb;
|
|
17
|
+
private _db;
|
|
18
|
+
private _collections;
|
|
19
|
+
private _globals;
|
|
20
|
+
private config;
|
|
21
|
+
push: boolean;
|
|
22
|
+
migrationDir: string;
|
|
23
|
+
pushDestructive: boolean;
|
|
24
|
+
get raw(): postgres.Sql<{}> | null;
|
|
25
|
+
get db(): Kysely<any> | null;
|
|
26
|
+
constructor(config: PostgresConfig | string, options?: {
|
|
27
|
+
push?: boolean;
|
|
28
|
+
pushDestructive?: boolean;
|
|
29
|
+
migrationDir?: string;
|
|
30
|
+
});
|
|
31
|
+
connect(): Promise<void>;
|
|
32
|
+
disconnect(): Promise<void>;
|
|
33
|
+
unsafe(query: string, params?: unknown[]): Promise<unknown>;
|
|
34
|
+
count(collection: string, query?: Record<string, unknown>): Promise<number>;
|
|
35
|
+
create<T extends object>(collection: string, data: Partial<T>): Promise<T>;
|
|
36
|
+
findOne<T extends object>(collection: string, query: Record<string, unknown>, tx?: any): Promise<T | null>;
|
|
37
|
+
find<T extends object>(collection: string, query?: Record<string, unknown>, options?: FindOptions): Promise<PaginatedResult<T>>;
|
|
38
|
+
update<T extends object>(collection: string, query: Record<string, unknown> | string | number, data: Partial<T>): Promise<T>;
|
|
39
|
+
updateMany<T extends object>(collection: string, query: Record<string, unknown>, data: Partial<T>): Promise<number>;
|
|
40
|
+
delete(collection: string, query: Record<string, unknown> | string | number): Promise<boolean>;
|
|
41
|
+
deleteMany(collection: string, query: Record<string, unknown>): Promise<number>;
|
|
42
|
+
findGlobal<T extends object>(slug: string): Promise<T | null>;
|
|
43
|
+
updateGlobal<T extends object>(slug: string, data: Partial<T>): Promise<T>;
|
|
44
|
+
runMigrations(): Promise<void>;
|
|
45
|
+
migrate(collections: Collection[], globals?: Global[]): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export declare function createPostgresAdapter(config: PostgresConfig | string, options?: {
|
|
48
|
+
push?: boolean;
|
|
49
|
+
pushDestructive?: boolean;
|
|
50
|
+
migrationDir?: string;
|
|
51
|
+
}): PostgresAdapter;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Kysely } from "kysely";
|
|
2
|
+
import type { Collection, FindOptions, Global, PaginatedResult } from "../types";
|
|
3
|
+
import { BaseDatabaseAdapter } from "./adapter";
|
|
4
|
+
export declare class SQLiteAdapter extends BaseDatabaseAdapter {
|
|
5
|
+
name: string;
|
|
6
|
+
private _rawDb;
|
|
7
|
+
private _db;
|
|
8
|
+
private _collections;
|
|
9
|
+
private _globals;
|
|
10
|
+
push: boolean;
|
|
11
|
+
migrationDir: string;
|
|
12
|
+
pushDestructive: boolean;
|
|
13
|
+
get raw(): any;
|
|
14
|
+
get db(): Kysely<any>;
|
|
15
|
+
constructor(path: string, options?: {
|
|
16
|
+
push?: boolean;
|
|
17
|
+
pushDestructive?: boolean;
|
|
18
|
+
migrationDir?: string;
|
|
19
|
+
});
|
|
20
|
+
connect(): Promise<void>;
|
|
21
|
+
disconnect(): Promise<void>;
|
|
22
|
+
unsafe(query: string, params?: any[]): Promise<unknown>;
|
|
23
|
+
private coerceData;
|
|
24
|
+
count(collection: string, query?: Record<string, unknown>): Promise<number>;
|
|
25
|
+
create<T extends object>(collection: string, data: Partial<T>): Promise<T>;
|
|
26
|
+
findOne<T extends object>(collection: string, query: Record<string, unknown>, tx?: any): Promise<T | null>;
|
|
27
|
+
find<T extends object>(collection: string, query?: Record<string, unknown>, options?: FindOptions): Promise<PaginatedResult<T>>;
|
|
28
|
+
update<T extends object>(collection: string, query: Record<string, unknown> | string | number, data: Partial<T>): Promise<T>;
|
|
29
|
+
delete(collection: string, query: Record<string, unknown> | string | number): Promise<boolean>;
|
|
30
|
+
updateMany<T extends object>(collection: string, query: Record<string, unknown>, data: Partial<T>): Promise<number>;
|
|
31
|
+
deleteMany(collection: string, query: Record<string, unknown>): Promise<number>;
|
|
32
|
+
findGlobal<T extends object>(slug: string): Promise<T | null>;
|
|
33
|
+
updateGlobal<T extends object>(slug: string, data: Partial<T>): Promise<T>;
|
|
34
|
+
runMigrations(): Promise<void>;
|
|
35
|
+
migrate(collections: Collection[], globals?: Global[]): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export declare function createSQLiteAdapter(path: string, options?: {
|
|
38
|
+
push?: boolean;
|
|
39
|
+
pushDestructive?: boolean;
|
|
40
|
+
migrationDir?: string;
|
|
41
|
+
}): SQLiteAdapter;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { OpacaConfig } from "../types";
|
|
3
|
+
export interface BunServerOptions {
|
|
4
|
+
port?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates a standalone Bun server running OpacaCMS.
|
|
8
|
+
* Bun has native support for the `fetch` API, making it extremely fast.
|
|
9
|
+
*
|
|
10
|
+
* @param config - The OpacaCMS configuration object.
|
|
11
|
+
* @param options - Options for the Bun server (e.g., port).
|
|
12
|
+
* @returns The Hono application instance and an `init` function to start the server.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createBunHandler(config: OpacaConfig, options?: BunServerOptions): {
|
|
15
|
+
app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
16
|
+
init: () => Promise<Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { OpacaConfig } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Cloudflare Workers compatible handler for OpacaCMS.
|
|
5
|
+
* Returns an object with a `fetch` method, perfectly matched for CF Workers.
|
|
6
|
+
*
|
|
7
|
+
* @param configOrFactory - Either the OpacaCMS configuration object or a function that returns it.
|
|
8
|
+
* @returns An object with a standard `fetch` method signature.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createCloudflareWorkersHandler(configOrFactory: OpacaConfig | ((env: any, request: Request) => OpacaConfig | Promise<OpacaConfig>)): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OpacaConfig } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Next.js App Router compatible route handler for OpacaCMS.
|
|
4
|
+
* Wraps the internal Hono router using `hono/vercel`.
|
|
5
|
+
*
|
|
6
|
+
* @param config - The OpacaCMS configuration object.
|
|
7
|
+
* @returns An object containing the HTTP methods to be exported in `app/api/[[...route]]/route.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createNextHandler(config: OpacaConfig): {
|
|
10
|
+
GET: (req: Request) => Response | Promise<Response>;
|
|
11
|
+
POST: (req: Request) => Response | Promise<Response>;
|
|
12
|
+
PUT: (req: Request) => Response | Promise<Response>;
|
|
13
|
+
DELETE: (req: Request) => Response | Promise<Response>;
|
|
14
|
+
PATCH: (req: Request) => Response | Promise<Response>;
|
|
15
|
+
OPTIONS: (req: Request) => Response | Promise<Response>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { OpacaConfig } from "../types";
|
|
3
|
+
export interface NodeServerOptions {
|
|
4
|
+
port?: number;
|
|
5
|
+
fetch?: (request: Request) => Promise<Response>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates a standalone Node.js server running OpacaCMS.
|
|
9
|
+
* Uses `@hono/node-server` to serve the API.
|
|
10
|
+
*
|
|
11
|
+
* @param config - The OpacaCMS configuration object.
|
|
12
|
+
* @param options - Options for the Node server (e.g., port).
|
|
13
|
+
* @returns The Hono application instance and an `init` function to start the server.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createNodeHandler(config: OpacaConfig, options?: NodeServerOptions): {
|
|
16
|
+
app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
17
|
+
init: () => Promise<Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Collection as BaseCollection, IconName } from "../types";
|
|
2
|
+
import type { AccessRules, InferFields } from "./infer";
|
|
3
|
+
/**
|
|
4
|
+
* The Fluent API Collection Builder.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CollectionBuilder<TFields extends Record<string, any> = {}> {
|
|
7
|
+
readonly slug: string;
|
|
8
|
+
private config;
|
|
9
|
+
private fieldBuilders;
|
|
10
|
+
constructor(slug: string);
|
|
11
|
+
/**
|
|
12
|
+
* Sets the user-friendly label for the Collection.
|
|
13
|
+
*/
|
|
14
|
+
label(label: string): this;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the Lucide icon for this collection.
|
|
17
|
+
*/
|
|
18
|
+
icon(iconName: IconName): this;
|
|
19
|
+
/**
|
|
20
|
+
* Defines which field should be used as the title in the Admin UI.
|
|
21
|
+
*/
|
|
22
|
+
useAsTitle(fieldName: keyof TFields | (string & {})): this;
|
|
23
|
+
/**
|
|
24
|
+
* Enables or disables automatic timestamps (createdAt, updatedAt).
|
|
25
|
+
*/
|
|
26
|
+
timestamps(val?: boolean): this;
|
|
27
|
+
/**
|
|
28
|
+
* Defines the fields for this Collection.
|
|
29
|
+
* Re-instantiates the builder to capture the strong types of the fields.
|
|
30
|
+
*/
|
|
31
|
+
fields<T extends readonly any[]>(fields: [...T]): CollectionBuilder<InferFields<T>>;
|
|
32
|
+
/**
|
|
33
|
+
* Type-safe access control rules.
|
|
34
|
+
*/
|
|
35
|
+
access(rules: AccessRules<TFields>): this;
|
|
36
|
+
/**
|
|
37
|
+
* Defines a virtual/computed field with full type inference of the current collection data.
|
|
38
|
+
*/
|
|
39
|
+
virtual<TName extends string, TReturn = any>(name: TName, options: {
|
|
40
|
+
label?: string;
|
|
41
|
+
resolve: (args: {
|
|
42
|
+
data: TFields;
|
|
43
|
+
req: any;
|
|
44
|
+
user: any;
|
|
45
|
+
session: any;
|
|
46
|
+
apiKey?: any;
|
|
47
|
+
}) => TReturn | Promise<TReturn>;
|
|
48
|
+
returnType?: "string" | "number" | "boolean" | "json";
|
|
49
|
+
}): CollectionBuilder<TFields & {
|
|
50
|
+
[K in TName]: TReturn;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Alias for .virtual()
|
|
54
|
+
*/
|
|
55
|
+
computed<TName extends string, TReturn = any>(name: TName, options: {
|
|
56
|
+
label?: string;
|
|
57
|
+
resolve: (args: {
|
|
58
|
+
data: TFields;
|
|
59
|
+
req: any;
|
|
60
|
+
user: any;
|
|
61
|
+
session: any;
|
|
62
|
+
apiKey?: any;
|
|
63
|
+
}) => TReturn | Promise<TReturn>;
|
|
64
|
+
returnType?: "string" | "number" | "boolean" | "json";
|
|
65
|
+
}): CollectionBuilder<TFields & {
|
|
66
|
+
[K in TName]: TReturn;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Advanced Admin UI configuration.
|
|
70
|
+
*/
|
|
71
|
+
admin(opts: BaseCollection["admin"]): this;
|
|
72
|
+
/**
|
|
73
|
+
* Adds automated versioning and drafts.
|
|
74
|
+
*/
|
|
75
|
+
versions(opts: {
|
|
76
|
+
drafts?: boolean;
|
|
77
|
+
maxRevisions?: number;
|
|
78
|
+
autosave?: boolean;
|
|
79
|
+
}): this;
|
|
80
|
+
/**
|
|
81
|
+
* Adds webhooks to be triggered on document lifecycle events.
|
|
82
|
+
*/
|
|
83
|
+
webhooks(webhooks: {
|
|
84
|
+
events: string[];
|
|
85
|
+
url: string;
|
|
86
|
+
headers?: Record<string, string>;
|
|
87
|
+
}[]): this;
|
|
88
|
+
/**
|
|
89
|
+
* Spreads configuration from presets (Proposed Feature stub)
|
|
90
|
+
*/
|
|
91
|
+
extend(preset: any): this;
|
|
92
|
+
protected _ensureAdmin(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Compiles the collection builder down into the raw Object structure expected by OpacaCMS.
|
|
95
|
+
*/
|
|
96
|
+
build(): BaseCollection;
|
|
97
|
+
}
|
|
98
|
+
export declare const Collection: {
|
|
99
|
+
create: (slug: string) => CollectionBuilder<{}>;
|
|
100
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { BaseField, FieldAccessConfig } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* The base class for all Fluent API Field Builders.
|
|
4
|
+
* Accumulates configuration state linearly.
|
|
5
|
+
*
|
|
6
|
+
* @template TType The literal string type of the field (e.g., 'text', 'relationship').
|
|
7
|
+
* @template TName The literal string name of the field.
|
|
8
|
+
* @template TValue The TypeScript literal value type this field produces (e.g., string, number).
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class FieldBuilder<TType extends string, TName extends string = string, TValue = any, TSubFields extends readonly any[] = any[]> {
|
|
11
|
+
readonly type: TType;
|
|
12
|
+
readonly name: TName;
|
|
13
|
+
readonly __type: TType;
|
|
14
|
+
readonly __name: TName;
|
|
15
|
+
readonly __value: TValue;
|
|
16
|
+
readonly __sub: TSubFields;
|
|
17
|
+
protected config: Partial<BaseField & Record<string, any>>;
|
|
18
|
+
constructor(type: TType, name: TName);
|
|
19
|
+
/**
|
|
20
|
+
* Defines a user-friendly label for the Admin UI.
|
|
21
|
+
*/
|
|
22
|
+
label(label: string): this;
|
|
23
|
+
/**
|
|
24
|
+
* Sets the placeholder text for the input field.
|
|
25
|
+
*/
|
|
26
|
+
placeholder(text: string): this;
|
|
27
|
+
/**
|
|
28
|
+
* Marks the field as strictly required.
|
|
29
|
+
*/
|
|
30
|
+
required(val?: boolean): this;
|
|
31
|
+
/**
|
|
32
|
+
* Marks the field as unique within the database table.
|
|
33
|
+
*/
|
|
34
|
+
unique(val?: boolean): this;
|
|
35
|
+
/**
|
|
36
|
+
* Enables native field-level internationalization.
|
|
37
|
+
*/
|
|
38
|
+
localized(val?: boolean): this;
|
|
39
|
+
/**
|
|
40
|
+
* Sets a default value for the field.
|
|
41
|
+
*/
|
|
42
|
+
defaultValue(val: TValue): this;
|
|
43
|
+
/**
|
|
44
|
+
* A custom validation callback function.
|
|
45
|
+
*/
|
|
46
|
+
validate(fn: (value: unknown) => boolean | string): this;
|
|
47
|
+
/**
|
|
48
|
+
* Configure granular access control for this specific field.
|
|
49
|
+
*/
|
|
50
|
+
access(config: FieldAccessConfig): this;
|
|
51
|
+
/**
|
|
52
|
+
* Add a descriptive text below the field in the Admin UI.
|
|
53
|
+
*/
|
|
54
|
+
description(text: string): this;
|
|
55
|
+
/**
|
|
56
|
+
* Override Admin UI with custom React components.
|
|
57
|
+
*/
|
|
58
|
+
admin(opts: NonNullable<BaseField["admin"]>): this;
|
|
59
|
+
/**
|
|
60
|
+
* Completely hide the field from the Admin UI and API responses (depending on access).
|
|
61
|
+
*/
|
|
62
|
+
hidden(val?: boolean): this;
|
|
63
|
+
/**
|
|
64
|
+
* Mark the field as read-only in the Admin UI.
|
|
65
|
+
*/
|
|
66
|
+
readOnly(val?: boolean): this;
|
|
67
|
+
/**
|
|
68
|
+
* Spreads arbitrary runtime configuration for any non-strongly-typed features.
|
|
69
|
+
*/
|
|
70
|
+
extend(opts: Record<string, any>): this;
|
|
71
|
+
/**
|
|
72
|
+
* Helper to ensure the `admin` options object is initialized.
|
|
73
|
+
*/
|
|
74
|
+
protected _ensureAdmin(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Helper to ensure the `options` object is initialized.
|
|
77
|
+
*/
|
|
78
|
+
protected _ensureOptions(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Compiles the accumulated builder state down into the raw Object structure expected by OpacaCMS.
|
|
81
|
+
*/
|
|
82
|
+
build(): any;
|
|
83
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { FieldBuilder } from "./base";
|
|
2
|
+
export declare class TextFieldBuilder<TName extends string> extends FieldBuilder<"text", TName, string> {
|
|
3
|
+
constructor(name: TName);
|
|
4
|
+
}
|
|
5
|
+
export declare class SlugFieldBuilder<TName extends string> extends FieldBuilder<"slug", TName, string> {
|
|
6
|
+
constructor(name: TName);
|
|
7
|
+
from(sourceField: string): this;
|
|
8
|
+
format(fn: (val: string) => string): this;
|
|
9
|
+
}
|
|
10
|
+
export declare class TextAreaFieldBuilder<TName extends string> extends FieldBuilder<"textarea", TName, string> {
|
|
11
|
+
constructor(name: TName);
|
|
12
|
+
}
|
|
13
|
+
export declare class NumberFieldBuilder<TName extends string> extends FieldBuilder<"number", TName, number> {
|
|
14
|
+
constructor(name: TName);
|
|
15
|
+
min(val: number): this;
|
|
16
|
+
max(val: number): this;
|
|
17
|
+
}
|
|
18
|
+
export declare class BooleanFieldBuilder<TName extends string> extends FieldBuilder<"boolean", TName, boolean> {
|
|
19
|
+
constructor(name: TName);
|
|
20
|
+
display(type: "switch" | "toggle" | "checkbox" | "select"): this;
|
|
21
|
+
}
|
|
22
|
+
export declare class RichTextFieldBuilder<TName extends string> extends FieldBuilder<"richtext", TName, string> {
|
|
23
|
+
constructor(name: TName);
|
|
24
|
+
mode(mode: "simple" | "notion"): this;
|
|
25
|
+
}
|
|
26
|
+
export declare class RelationshipFieldBuilder<TName extends string> extends FieldBuilder<"relationship", TName, string | string[]> {
|
|
27
|
+
constructor(name: TName);
|
|
28
|
+
to(collection: string | {
|
|
29
|
+
slug: string;
|
|
30
|
+
}): this;
|
|
31
|
+
single(): this;
|
|
32
|
+
many(): this;
|
|
33
|
+
displayField(field: string): this;
|
|
34
|
+
}
|
|
35
|
+
export declare class FileFieldBuilder<TName extends string> extends FieldBuilder<"file", TName, unknown> {
|
|
36
|
+
constructor(name: TName);
|
|
37
|
+
bucket(bucketName: string): this;
|
|
38
|
+
allowedmime_types(types: string[]): this;
|
|
39
|
+
maxSize(bytes: number): this;
|
|
40
|
+
}
|
|
41
|
+
export declare class DateFieldBuilder<TName extends string> extends FieldBuilder<"date", TName, string | Date> {
|
|
42
|
+
constructor(name: TName);
|
|
43
|
+
}
|
|
44
|
+
export declare class SelectFieldBuilder<TName extends string> extends FieldBuilder<"select", TName, string> {
|
|
45
|
+
constructor(name: TName);
|
|
46
|
+
choices(choices: string[] | {
|
|
47
|
+
label: string;
|
|
48
|
+
value: string;
|
|
49
|
+
}[]): this;
|
|
50
|
+
}
|
|
51
|
+
export declare class RadioFieldBuilder<TName extends string> extends FieldBuilder<"radio", TName, string> {
|
|
52
|
+
constructor(name: TName);
|
|
53
|
+
choices(choices: string[] | {
|
|
54
|
+
label: string;
|
|
55
|
+
value: string;
|
|
56
|
+
}[]): this;
|
|
57
|
+
}
|
|
58
|
+
export declare class TabsFieldBuilder<TTabs extends readonly any[] = []> extends FieldBuilder<"tabs", "", unknown, TTabs> {
|
|
59
|
+
constructor();
|
|
60
|
+
tab<TLabel extends string, TSub extends readonly FieldBuilder<any, any, any, any>[]>(label: TLabel, ...fields: TSub): TabsFieldBuilder<[...TTabs, {
|
|
61
|
+
label: TLabel;
|
|
62
|
+
fields: TSub;
|
|
63
|
+
}]>;
|
|
64
|
+
}
|
|
65
|
+
export declare class CollapsibleFieldBuilder<TNames extends string = string, TSub extends readonly any[] = any[]> extends FieldBuilder<"collapsible", "", unknown, TSub> {
|
|
66
|
+
constructor(fields?: FieldBuilder<any, TNames, any, any>[]);
|
|
67
|
+
initiallyCollapsed(val?: boolean): this;
|
|
68
|
+
useAsTitle(fieldName: TNames | (string & {})): this;
|
|
69
|
+
fields<NewSub extends readonly FieldBuilder<any, any, any>[]>(...fields: NewSub): CollapsibleFieldBuilder<ExtractNames<NewSub>, NewSub>;
|
|
70
|
+
}
|
|
71
|
+
type ExtractNames<T extends readonly any[]> = T[number]["name"];
|
|
72
|
+
export declare class JoinFieldBuilder<TName extends string> extends FieldBuilder<"join", TName, any[]> {
|
|
73
|
+
constructor(name: TName);
|
|
74
|
+
collection(collectionSlug: string): this;
|
|
75
|
+
on(fieldName: string): this;
|
|
76
|
+
}
|
|
77
|
+
export declare class ArrayFieldBuilder<TName extends string, TSub extends readonly any[] = any[]> extends FieldBuilder<"array", TName, unknown[], TSub> {
|
|
78
|
+
constructor(name: TName);
|
|
79
|
+
of<NewSub extends readonly FieldBuilder<any, any, any, any>[]>(...fields: NewSub): ArrayFieldBuilder<TName, NewSub>;
|
|
80
|
+
}
|
|
81
|
+
export declare class GroupFieldBuilder<TName extends string, TNames extends string = string, TSub extends readonly any[] = any[]> extends FieldBuilder<"group", TName, Record<string, any>, TSub> {
|
|
82
|
+
constructor(name: TName, fields?: FieldBuilder<any, TNames, any, any>[]);
|
|
83
|
+
fields<NewSub extends readonly FieldBuilder<any, any, any, any>[]>(...fields: NewSub): GroupFieldBuilder<TName, ExtractNames<NewSub>, NewSub>;
|
|
84
|
+
}
|
|
85
|
+
export declare class RowFieldBuilder<TSub extends readonly any[] = any[]> extends FieldBuilder<"row", "", unknown, TSub> {
|
|
86
|
+
constructor(fields?: FieldBuilder<any, any, any, any>[]);
|
|
87
|
+
fields<NewSub extends readonly FieldBuilder<any, any, any, any>[]>(...fields: NewSub): RowFieldBuilder<NewSub>;
|
|
88
|
+
}
|
|
89
|
+
export declare class BlockBuilder<TSlug extends string, TNames extends string = string, TSub extends readonly any[] = any[]> {
|
|
90
|
+
private config;
|
|
91
|
+
constructor(slug: TSlug);
|
|
92
|
+
label(label: string): this;
|
|
93
|
+
fields<NewSub extends readonly FieldBuilder<any, any, any, any>[]>(...fields: NewSub): BlockBuilder<TSlug, ExtractNames<NewSub>, NewSub>;
|
|
94
|
+
build(): Record<string, any>;
|
|
95
|
+
}
|
|
96
|
+
export declare class VirtualFieldBuilder<TName extends string, TData = any> extends FieldBuilder<"virtual", TName, any> {
|
|
97
|
+
constructor(name: TName);
|
|
98
|
+
resolve(fn: (args: {
|
|
99
|
+
data: TData;
|
|
100
|
+
req: any;
|
|
101
|
+
user: any;
|
|
102
|
+
session: any;
|
|
103
|
+
apiKey?: any;
|
|
104
|
+
}) => any | Promise<any>): this;
|
|
105
|
+
returnType(type: "string" | "number" | "boolean" | "json"): this;
|
|
106
|
+
}
|
|
107
|
+
export declare class BlocksFieldBuilder<TName extends string, TBlocks extends readonly any[] = any[]> extends FieldBuilder<"blocks", TName, any[], TBlocks> {
|
|
108
|
+
constructor(name: TName);
|
|
109
|
+
blocks<NewBlocks extends readonly BlockBuilder<any, any, any>[]>(...blocks: NewBlocks): BlocksFieldBuilder<TName, NewBlocks>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The Field Factory object containing methods to instantiate specific field builders.
|
|
113
|
+
*/
|
|
114
|
+
export declare const Field: {
|
|
115
|
+
text: <N extends string>(name: N) => TextFieldBuilder<N>;
|
|
116
|
+
slug: <N extends string>(name: N) => SlugFieldBuilder<N>;
|
|
117
|
+
textarea: <N extends string>(name: N) => TextAreaFieldBuilder<N>;
|
|
118
|
+
number: <N extends string>(name: N) => NumberFieldBuilder<N>;
|
|
119
|
+
boolean: <N extends string>(name: N) => BooleanFieldBuilder<N>;
|
|
120
|
+
date: <N extends string>(name: N) => DateFieldBuilder<N>;
|
|
121
|
+
select: <N extends string>(name: N) => SelectFieldBuilder<N>;
|
|
122
|
+
radio: <N extends string>(name: N) => RadioFieldBuilder<N>;
|
|
123
|
+
richText: <N extends string>(name: N) => RichTextFieldBuilder<N>;
|
|
124
|
+
relationship: <N extends string>(name: N) => RelationshipFieldBuilder<N>;
|
|
125
|
+
join: <N extends string>(name: N) => JoinFieldBuilder<N>;
|
|
126
|
+
file: <N extends string>(name: N) => FileFieldBuilder<N>;
|
|
127
|
+
array: <N extends string>(name: N) => ArrayFieldBuilder<N, any[]>;
|
|
128
|
+
group: <N extends string, TSub extends readonly FieldBuilder<any, any, any, any>[]>(name: N, fields?: TSub) => GroupFieldBuilder<N, any, TSub>;
|
|
129
|
+
tabs: () => TabsFieldBuilder<[]>;
|
|
130
|
+
collapsible: <N extends string, S extends readonly FieldBuilder<any, any, any, any>[]>(fields?: S) => CollapsibleFieldBuilder<ExtractNames<S>, S>;
|
|
131
|
+
row: <S extends readonly FieldBuilder<any, any, any, any>[]>(fields?: S) => RowFieldBuilder<S>;
|
|
132
|
+
blocks: <N extends string, TSub extends readonly BlockBuilder<any, any, any>[]>(name: N, ...blocks: TSub) => BlocksFieldBuilder<N, TSub>;
|
|
133
|
+
block: <N extends string>(slug: N) => BlockBuilder<N, string, any[]>;
|
|
134
|
+
};
|
|
135
|
+
export * from "./base";
|