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,300 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const FieldTypeSchema: z.ZodEnum<{
|
|
3
|
+
number: "number";
|
|
4
|
+
boolean: "boolean";
|
|
5
|
+
text: "text";
|
|
6
|
+
json: "json";
|
|
7
|
+
join: "join";
|
|
8
|
+
slug: "slug";
|
|
9
|
+
textarea: "textarea";
|
|
10
|
+
richtext: "richtext";
|
|
11
|
+
relationship: "relationship";
|
|
12
|
+
select: "select";
|
|
13
|
+
radio: "radio";
|
|
14
|
+
date: "date";
|
|
15
|
+
file: "file";
|
|
16
|
+
blocks: "blocks";
|
|
17
|
+
group: "group";
|
|
18
|
+
row: "row";
|
|
19
|
+
collapsible: "collapsible";
|
|
20
|
+
tabs: "tabs";
|
|
21
|
+
array: "array";
|
|
22
|
+
virtual: "virtual";
|
|
23
|
+
}>;
|
|
24
|
+
export type FieldType = z.infer<typeof FieldTypeSchema>;
|
|
25
|
+
export declare const FieldSchema: z.ZodType<unknown>;
|
|
26
|
+
export type Field = z.infer<typeof FieldSchema>;
|
|
27
|
+
export declare const AccessConfigSchema: z.ZodObject<{
|
|
28
|
+
read: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
29
|
+
create: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
30
|
+
update: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
31
|
+
delete: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
32
|
+
requireApiKey: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type AccessConfig = z.infer<typeof AccessConfigSchema>;
|
|
35
|
+
export declare const CollectionHooksSchema: z.ZodObject<{
|
|
36
|
+
beforeCreate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
37
|
+
afterCreate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
38
|
+
beforeUpdate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
39
|
+
afterUpdate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
40
|
+
beforeDelete: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
41
|
+
afterDelete: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type CollectionHooks = z.infer<typeof CollectionHooksSchema>;
|
|
44
|
+
export declare const CollectionSchema: z.ZodObject<{
|
|
45
|
+
slug: z.ZodString;
|
|
46
|
+
label: z.ZodOptional<z.ZodString>;
|
|
47
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
48
|
+
apiPath: z.ZodOptional<z.ZodString>;
|
|
49
|
+
fields: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
50
|
+
timestamps: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
51
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
52
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>]>>;
|
|
54
|
+
auth: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
hooks: z.ZodOptional<z.ZodObject<{
|
|
56
|
+
beforeCreate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
57
|
+
afterCreate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
58
|
+
beforeUpdate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
59
|
+
afterUpdate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
60
|
+
beforeDelete: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
61
|
+
afterDelete: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
access: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
read: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
65
|
+
create: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
66
|
+
update: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
67
|
+
delete: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
68
|
+
requireApiKey: z.ZodOptional<z.ZodBoolean>;
|
|
69
|
+
}, z.core.$strip>>;
|
|
70
|
+
versions: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
drafts: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
maxRevisions: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
autosave: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
webhooks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
76
|
+
events: z.ZodArray<z.ZodString>;
|
|
77
|
+
url: z.ZodString;
|
|
78
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
79
|
+
}, z.core.$strip>>>;
|
|
80
|
+
admin: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
81
|
+
defaultColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
82
|
+
useAsTitle: z.ZodOptional<z.ZodString>;
|
|
83
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
84
|
+
disableAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
+
views: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
86
|
+
name: z.ZodString;
|
|
87
|
+
filter: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
88
|
+
defaultColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
89
|
+
}, z.core.$strip>>>;
|
|
90
|
+
bulkActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
91
|
+
label: z.ZodString;
|
|
92
|
+
action: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
|
|
93
|
+
}, z.core.$strip>>>;
|
|
94
|
+
}, z.core.$strip>]>>;
|
|
95
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
export type Collection = z.infer<typeof CollectionSchema>;
|
|
98
|
+
export declare const GlobalSchema: z.ZodObject<{
|
|
99
|
+
slug: z.ZodString;
|
|
100
|
+
label: z.ZodOptional<z.ZodString>;
|
|
101
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
102
|
+
fields: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
103
|
+
timestamps: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
104
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
105
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
106
|
+
}, z.core.$strip>]>>;
|
|
107
|
+
access: z.ZodOptional<z.ZodObject<{
|
|
108
|
+
read: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
109
|
+
create: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
110
|
+
update: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
111
|
+
delete: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
112
|
+
requireApiKey: z.ZodOptional<z.ZodBoolean>;
|
|
113
|
+
}, z.core.$strip>>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
export type Global = z.infer<typeof GlobalSchema>;
|
|
116
|
+
export declare const AdminConfigSchema: z.ZodObject<{
|
|
117
|
+
userCollection: z.ZodOptional<z.ZodString>;
|
|
118
|
+
disableAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
119
|
+
route: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
export type AdminConfig = z.infer<typeof AdminConfigSchema>;
|
|
122
|
+
export declare const OpacaAuthConfigSchema: z.ZodObject<{
|
|
123
|
+
strategies: z.ZodOptional<z.ZodObject<{
|
|
124
|
+
emailPassword: z.ZodOptional<z.ZodBoolean>;
|
|
125
|
+
magicLink: z.ZodOptional<z.ZodObject<{
|
|
126
|
+
enabled: z.ZodBoolean;
|
|
127
|
+
sendEmail: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
|
|
128
|
+
}, z.core.$strip>>;
|
|
129
|
+
}, z.core.$strip>>;
|
|
130
|
+
socialProviders: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
github: z.ZodOptional<z.ZodObject<{
|
|
132
|
+
clientId: z.ZodString;
|
|
133
|
+
clientSecret: z.ZodString;
|
|
134
|
+
}, z.core.$strip>>;
|
|
135
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
136
|
+
clientId: z.ZodString;
|
|
137
|
+
clientSecret: z.ZodString;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
}, z.core.$strip>>;
|
|
140
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
141
|
+
expiresInDays: z.ZodOptional<z.ZodNumber>;
|
|
142
|
+
updateAgeSeconds: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
}, z.core.$strip>>;
|
|
144
|
+
features: z.ZodOptional<z.ZodObject<{
|
|
145
|
+
apiKeys: z.ZodOptional<z.ZodObject<{
|
|
146
|
+
enabled: z.ZodBoolean;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
mfa: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
enabled: z.ZodBoolean;
|
|
150
|
+
issuer: z.ZodString;
|
|
151
|
+
}, z.core.$strip>>;
|
|
152
|
+
}, z.core.$strip>>;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
export declare const ApiConfigSchema: z.ZodObject<{
|
|
155
|
+
maxLimit: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
rateLimit: z.ZodOptional<z.ZodObject<{
|
|
157
|
+
windowMs: z.ZodOptional<z.ZodNumber>;
|
|
158
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
159
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
160
|
+
store: z.ZodOptional<z.ZodAny>;
|
|
161
|
+
provider: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
162
|
+
keyGenerator: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
163
|
+
}, z.core.$strip>>;
|
|
164
|
+
}, z.core.$strip>;
|
|
165
|
+
export type ApiConfig = z.infer<typeof ApiConfigSchema>;
|
|
166
|
+
export declare const OpacaConfigSchema: z.ZodObject<{
|
|
167
|
+
collections: z.ZodArray<z.ZodObject<{
|
|
168
|
+
slug: z.ZodString;
|
|
169
|
+
label: z.ZodOptional<z.ZodString>;
|
|
170
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
171
|
+
apiPath: z.ZodOptional<z.ZodString>;
|
|
172
|
+
fields: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
173
|
+
timestamps: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
174
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
175
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
176
|
+
}, z.core.$strip>]>>;
|
|
177
|
+
auth: z.ZodOptional<z.ZodBoolean>;
|
|
178
|
+
hooks: z.ZodOptional<z.ZodObject<{
|
|
179
|
+
beforeCreate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
180
|
+
afterCreate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
181
|
+
beforeUpdate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
182
|
+
afterUpdate: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
183
|
+
beforeDelete: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
184
|
+
afterDelete: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
185
|
+
}, z.core.$strip>>;
|
|
186
|
+
access: z.ZodOptional<z.ZodObject<{
|
|
187
|
+
read: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
188
|
+
create: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
189
|
+
update: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
190
|
+
delete: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
191
|
+
requireApiKey: z.ZodOptional<z.ZodBoolean>;
|
|
192
|
+
}, z.core.$strip>>;
|
|
193
|
+
versions: z.ZodOptional<z.ZodObject<{
|
|
194
|
+
drafts: z.ZodOptional<z.ZodBoolean>;
|
|
195
|
+
maxRevisions: z.ZodOptional<z.ZodNumber>;
|
|
196
|
+
autosave: z.ZodOptional<z.ZodBoolean>;
|
|
197
|
+
}, z.core.$strip>>;
|
|
198
|
+
webhooks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
199
|
+
events: z.ZodArray<z.ZodString>;
|
|
200
|
+
url: z.ZodString;
|
|
201
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
202
|
+
}, z.core.$strip>>>;
|
|
203
|
+
admin: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
204
|
+
defaultColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
205
|
+
useAsTitle: z.ZodOptional<z.ZodString>;
|
|
206
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
207
|
+
disableAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
208
|
+
views: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
209
|
+
name: z.ZodString;
|
|
210
|
+
filter: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
211
|
+
defaultColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
212
|
+
}, z.core.$strip>>>;
|
|
213
|
+
bulkActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
214
|
+
label: z.ZodString;
|
|
215
|
+
action: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
|
|
216
|
+
}, z.core.$strip>>>;
|
|
217
|
+
}, z.core.$strip>]>>;
|
|
218
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
219
|
+
}, z.core.$strip>>;
|
|
220
|
+
globals: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
221
|
+
slug: z.ZodString;
|
|
222
|
+
label: z.ZodOptional<z.ZodString>;
|
|
223
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
224
|
+
fields: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
225
|
+
timestamps: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
226
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
227
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
228
|
+
}, z.core.$strip>]>>;
|
|
229
|
+
access: z.ZodOptional<z.ZodObject<{
|
|
230
|
+
read: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
231
|
+
create: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
232
|
+
update: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
233
|
+
delete: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
234
|
+
requireApiKey: z.ZodOptional<z.ZodBoolean>;
|
|
235
|
+
}, z.core.$strip>>;
|
|
236
|
+
}, z.core.$strip>>>;
|
|
237
|
+
db: z.ZodAny;
|
|
238
|
+
storages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
239
|
+
runMigrationsOnStartup: z.ZodOptional<z.ZodBoolean>;
|
|
240
|
+
admin: z.ZodOptional<z.ZodObject<{
|
|
241
|
+
userCollection: z.ZodOptional<z.ZodString>;
|
|
242
|
+
disableAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
243
|
+
route: z.ZodOptional<z.ZodString>;
|
|
244
|
+
}, z.core.$strip>>;
|
|
245
|
+
serverURL: z.ZodOptional<z.ZodString>;
|
|
246
|
+
appName: z.ZodOptional<z.ZodString>;
|
|
247
|
+
secret: z.ZodOptional<z.ZodString>;
|
|
248
|
+
trustedOrigins: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
|
|
249
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
250
|
+
strategies: z.ZodOptional<z.ZodObject<{
|
|
251
|
+
emailPassword: z.ZodOptional<z.ZodBoolean>;
|
|
252
|
+
magicLink: z.ZodOptional<z.ZodObject<{
|
|
253
|
+
enabled: z.ZodBoolean;
|
|
254
|
+
sendEmail: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
|
|
255
|
+
}, z.core.$strip>>;
|
|
256
|
+
}, z.core.$strip>>;
|
|
257
|
+
socialProviders: z.ZodOptional<z.ZodObject<{
|
|
258
|
+
github: z.ZodOptional<z.ZodObject<{
|
|
259
|
+
clientId: z.ZodString;
|
|
260
|
+
clientSecret: z.ZodString;
|
|
261
|
+
}, z.core.$strip>>;
|
|
262
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
263
|
+
clientId: z.ZodString;
|
|
264
|
+
clientSecret: z.ZodString;
|
|
265
|
+
}, z.core.$strip>>;
|
|
266
|
+
}, z.core.$strip>>;
|
|
267
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
268
|
+
expiresInDays: z.ZodOptional<z.ZodNumber>;
|
|
269
|
+
updateAgeSeconds: z.ZodOptional<z.ZodNumber>;
|
|
270
|
+
}, z.core.$strip>>;
|
|
271
|
+
features: z.ZodOptional<z.ZodObject<{
|
|
272
|
+
apiKeys: z.ZodOptional<z.ZodObject<{
|
|
273
|
+
enabled: z.ZodBoolean;
|
|
274
|
+
}, z.core.$strip>>;
|
|
275
|
+
mfa: z.ZodOptional<z.ZodObject<{
|
|
276
|
+
enabled: z.ZodBoolean;
|
|
277
|
+
issuer: z.ZodString;
|
|
278
|
+
}, z.core.$strip>>;
|
|
279
|
+
}, z.core.$strip>>;
|
|
280
|
+
}, z.core.$strip>>;
|
|
281
|
+
api: z.ZodOptional<z.ZodObject<{
|
|
282
|
+
maxLimit: z.ZodOptional<z.ZodNumber>;
|
|
283
|
+
rateLimit: z.ZodOptional<z.ZodObject<{
|
|
284
|
+
windowMs: z.ZodOptional<z.ZodNumber>;
|
|
285
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
286
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
287
|
+
store: z.ZodOptional<z.ZodAny>;
|
|
288
|
+
provider: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
289
|
+
keyGenerator: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
290
|
+
}, z.core.$strip>>;
|
|
291
|
+
}, z.core.$strip>>;
|
|
292
|
+
access: z.ZodOptional<z.ZodObject<{
|
|
293
|
+
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>>;
|
|
294
|
+
}, z.core.$strip>>;
|
|
295
|
+
i18n: z.ZodOptional<z.ZodObject<{
|
|
296
|
+
locales: z.ZodArray<z.ZodString>;
|
|
297
|
+
defaultLocale: z.ZodString;
|
|
298
|
+
}, z.core.$strip>>;
|
|
299
|
+
}, z.core.$strip>;
|
|
300
|
+
export type OpacaConfig = z.infer<typeof OpacaConfigSchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Field } from "./types";
|
|
3
|
+
export declare function generateSchemaForCollection(collection: {
|
|
4
|
+
fields: Field[];
|
|
5
|
+
versions?: any;
|
|
6
|
+
timestamps?: any;
|
|
7
|
+
}, isUpdate?: boolean): z.ZodObject<{
|
|
8
|
+
[x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
9
|
+
}, z.core.$strip>;
|
package/global.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opacacms",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "bun run ../../scripts/build.ts && tsc --emitDeclarationOnly",
|
|
6
|
+
"build:publish": "bun run ../../scripts/build.ts --publish && tsc --emitDeclarationOnly",
|
|
7
|
+
"build:dev": "bun run ../../scripts/build.ts --dev && tsc --emitDeclarationOnly",
|
|
8
|
+
"prepublishOnly": "bun run build:publish",
|
|
9
|
+
"postpublish": "bun run ../../scripts/build.ts --dev",
|
|
10
|
+
"test": "bun test",
|
|
11
|
+
"test:watch": "bun test --watch",
|
|
12
|
+
"test:coverage": "bun test --coverage",
|
|
13
|
+
"check-types": "tsc --noEmit",
|
|
14
|
+
"lint": "bunx biome check ."
|
|
15
|
+
},
|
|
16
|
+
"module": "dist/index.js",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"bin": {
|
|
19
|
+
"opacacms": "./dist/cli/index.js"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./server": {
|
|
27
|
+
"types": "./dist/server.d.ts",
|
|
28
|
+
"import": "./dist/server.js"
|
|
29
|
+
},
|
|
30
|
+
"./api": {
|
|
31
|
+
"types": "./dist/api.d.ts",
|
|
32
|
+
"import": "./dist/api.js"
|
|
33
|
+
},
|
|
34
|
+
"./admin": {
|
|
35
|
+
"types": "./dist/admin/index.d.ts",
|
|
36
|
+
"import": "./dist/admin/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./admin/webcomponent": {
|
|
39
|
+
"types": "./dist/admin/webcomponent.d.ts",
|
|
40
|
+
"import": "./dist/admin/webcomponent.js"
|
|
41
|
+
},
|
|
42
|
+
"./db/postgres": {
|
|
43
|
+
"types": "./dist/db/postgres.d.ts",
|
|
44
|
+
"import": "./dist/db/postgres.js"
|
|
45
|
+
},
|
|
46
|
+
"./db/sqlite": {
|
|
47
|
+
"types": "./dist/db/sqlite.d.ts",
|
|
48
|
+
"import": "./dist/db/sqlite.js"
|
|
49
|
+
},
|
|
50
|
+
"./db/better-sqlite": {
|
|
51
|
+
"types": "./dist/db/better-sqlite.d.ts",
|
|
52
|
+
"import": "./dist/db/better-sqlite.js"
|
|
53
|
+
},
|
|
54
|
+
"./db/bun-sqlite": {
|
|
55
|
+
"types": "./dist/db/bun-sqlite.d.ts",
|
|
56
|
+
"import": "./dist/db/bun-sqlite.js"
|
|
57
|
+
},
|
|
58
|
+
"./db/d1": {
|
|
59
|
+
"types": "./dist/db/d1.d.ts",
|
|
60
|
+
"import": "./dist/db/d1.js"
|
|
61
|
+
},
|
|
62
|
+
"./runtimes/next": {
|
|
63
|
+
"types": "./dist/runtimes/next.d.ts",
|
|
64
|
+
"import": "./dist/runtimes/next.js"
|
|
65
|
+
},
|
|
66
|
+
"./runtimes/bun": {
|
|
67
|
+
"types": "./dist/runtimes/bun.d.ts",
|
|
68
|
+
"import": "./dist/runtimes/bun.js"
|
|
69
|
+
},
|
|
70
|
+
"./runtimes/node": {
|
|
71
|
+
"types": "./dist/runtimes/node.d.ts",
|
|
72
|
+
"import": "./dist/runtimes/node.js"
|
|
73
|
+
},
|
|
74
|
+
"./runtimes/cloudflare-workers": {
|
|
75
|
+
"types": "./dist/runtimes/cloudflare-workers.d.ts",
|
|
76
|
+
"import": "./dist/runtimes/cloudflare-workers.js"
|
|
77
|
+
},
|
|
78
|
+
"./client": {
|
|
79
|
+
"types": "./dist/client.d.ts",
|
|
80
|
+
"import": "./dist/client.js"
|
|
81
|
+
},
|
|
82
|
+
"./storage": {
|
|
83
|
+
"types": "./dist/storage/index.d.ts",
|
|
84
|
+
"import": "./dist/storage/index.js"
|
|
85
|
+
},
|
|
86
|
+
"./schema": {
|
|
87
|
+
"types": "./dist/schema/index.d.ts",
|
|
88
|
+
"import": "./dist/schema/index.js"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"devDependencies": {
|
|
92
|
+
"@cloudflare/workers-types": "^4.20260313.1",
|
|
93
|
+
"@happy-dom/global-registrator": "^20.8.4",
|
|
94
|
+
"@testing-library/dom": "^10.4.1",
|
|
95
|
+
"@testing-library/react": "^16.3.2",
|
|
96
|
+
"@types/bun": "latest",
|
|
97
|
+
"@types/react": "^19.2.14",
|
|
98
|
+
"@types/react-dom": "^19.2.3",
|
|
99
|
+
"bun-plugin-scss": "^1.0.0",
|
|
100
|
+
"drizzle-kit": "^0.31.9",
|
|
101
|
+
"happy-dom": "^20.8.4",
|
|
102
|
+
"sass": "^1.98.0"
|
|
103
|
+
},
|
|
104
|
+
"peerDependencies": {
|
|
105
|
+
"typescript": "^5.9.3"
|
|
106
|
+
},
|
|
107
|
+
"dependencies": {
|
|
108
|
+
"@aws-sdk/client-s3": "^3.1009.0",
|
|
109
|
+
"@aws-sdk/s3-request-presigner": "^3.1009.0",
|
|
110
|
+
"@better-auth/api-key": "^1.5.5",
|
|
111
|
+
"@better-auth/core": "^1.5.5",
|
|
112
|
+
"@faker-js/faker": "^10.3.0",
|
|
113
|
+
"@hono-rate-limiter/cloudflare": "^0.2.2",
|
|
114
|
+
"@hono/node-server": "^1.19.11",
|
|
115
|
+
"@lexical/code": "^0.41.0",
|
|
116
|
+
"@lexical/history": "^0.41.0",
|
|
117
|
+
"@lexical/html": "^0.41.0",
|
|
118
|
+
"@lexical/link": "^0.41.0",
|
|
119
|
+
"@lexical/list": "^0.41.0",
|
|
120
|
+
"@lexical/mark": "^0.41.0",
|
|
121
|
+
"@lexical/react": "^0.41.0",
|
|
122
|
+
"@lexical/rich-text": "^0.41.0",
|
|
123
|
+
"@lexical/selection": "^0.41.0",
|
|
124
|
+
"@lexical/utils": "^0.41.0",
|
|
125
|
+
"@nanostores/persistent": "^1.3.3",
|
|
126
|
+
"@nanostores/query": "^0.3.4",
|
|
127
|
+
"@nanostores/react": "^1.0.0",
|
|
128
|
+
"@nanostores/router": "^1.0.0",
|
|
129
|
+
"@r2wc/react-to-web-component": "^2.1.1",
|
|
130
|
+
"@tanstack/react-form": "^1.28.5",
|
|
131
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
132
|
+
"better-auth": "^1.5.5",
|
|
133
|
+
"better-sqlite3": "^12.6.2",
|
|
134
|
+
"dotenv": "^17.3.1",
|
|
135
|
+
"drizzle-orm": "^0.45.1",
|
|
136
|
+
"hono": "^4.12.7",
|
|
137
|
+
"hono-rate-limiter": "^0.5.3",
|
|
138
|
+
"ky": "^1.14.3",
|
|
139
|
+
"kysely": "^0.28.11",
|
|
140
|
+
"kysely-bun-sqlite": "^0.4.0",
|
|
141
|
+
"kysely-d1": "^0.4.0",
|
|
142
|
+
"kysely-postgres-js": "^3.0.0",
|
|
143
|
+
"lexical": "^0.41.0",
|
|
144
|
+
"lucide-react": "^0.577.0",
|
|
145
|
+
"nanostores": "^1.1.1",
|
|
146
|
+
"postgres": "^3.4.8",
|
|
147
|
+
"react": "^19.2.4",
|
|
148
|
+
"react-dom": "^19.2.4",
|
|
149
|
+
"zod": "^4.3.6"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import ky from "ky";
|
|
2
|
+
|
|
3
|
+
let client: typeof ky | null = null;
|
|
4
|
+
let currentBaseURL: string | null = null;
|
|
5
|
+
|
|
6
|
+
export const configureAPI = (serverUrl: string) => {
|
|
7
|
+
if (!serverUrl || !serverUrl.startsWith("http")) return;
|
|
8
|
+
const url = serverUrl;
|
|
9
|
+
const baseURL = url.replace(/\/$/, "");
|
|
10
|
+
if (client && currentBaseURL === baseURL) return;
|
|
11
|
+
|
|
12
|
+
currentBaseURL = baseURL;
|
|
13
|
+
client = ky.create({
|
|
14
|
+
prefixUrl: baseURL,
|
|
15
|
+
credentials: "include",
|
|
16
|
+
retry: 0,
|
|
17
|
+
hooks: {
|
|
18
|
+
afterResponse: [
|
|
19
|
+
async (_request, _options, response) => {
|
|
20
|
+
if (response.status === 401 || response.status === 403) {
|
|
21
|
+
// Se o auth handler do backend falhar globalmente em qualquer requisição da API (sessão morreu/expirada)
|
|
22
|
+
// Lançamos a revalidação da store local para despachar o usuário pra tela de login.
|
|
23
|
+
try {
|
|
24
|
+
const { $session } = await import("./stores/auth");
|
|
25
|
+
const { notify } = await import("./stores/ui");
|
|
26
|
+
$session.set(null);
|
|
27
|
+
notify("Session expired. Please log in again.", "error");
|
|
28
|
+
} catch (e) {}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const getCurrentBaseURL = () => {
|
|
37
|
+
if (!currentBaseURL) {
|
|
38
|
+
throw new Error("API client not configured. Did you provide a valid serverUrl?");
|
|
39
|
+
}
|
|
40
|
+
return currentBaseURL as string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A proxy for ky that allows us to configure the baseURL late
|
|
45
|
+
* (e.g. after we have the serverURL from props).
|
|
46
|
+
* @param prop: string
|
|
47
|
+
*/
|
|
48
|
+
export const api = new Proxy({} as typeof ky, {
|
|
49
|
+
get(_, prop) {
|
|
50
|
+
if (!client) {
|
|
51
|
+
// No auto-fallback for web components.
|
|
52
|
+
throw new Error("API client not configured. Did you provide a valid serverUrl?");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!client) throw new Error("API client not configured");
|
|
56
|
+
|
|
57
|
+
const c = client;
|
|
58
|
+
if (c) {
|
|
59
|
+
return c[prop as keyof typeof ky];
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/client";
|
|
2
|
+
import { adminClient } from "better-auth/client/plugins";
|
|
3
|
+
import { logger } from "@/utils/logger";
|
|
4
|
+
|
|
5
|
+
let client: ReturnType<typeof createAuthClient> | null = null;
|
|
6
|
+
let currentURL: string | null = null;
|
|
7
|
+
|
|
8
|
+
export const configureAuth = (serverUrl: string) => {
|
|
9
|
+
if (!serverUrl || !serverUrl.startsWith("http")) return;
|
|
10
|
+
const url = serverUrl;
|
|
11
|
+
const baseURL = url.replace(/\/$/, "") + "/api/auth";
|
|
12
|
+
if (client && currentURL === baseURL) return;
|
|
13
|
+
|
|
14
|
+
currentURL = baseURL;
|
|
15
|
+
client = createAuthClient({
|
|
16
|
+
baseURL,
|
|
17
|
+
autoRefresh: true,
|
|
18
|
+
fetchOptions: {
|
|
19
|
+
credentials: "include",
|
|
20
|
+
},
|
|
21
|
+
plugins: [adminClient()],
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A proxy for the authClient that allows us to configure it late
|
|
27
|
+
* (e.g. after we have the user's config with serverURL).
|
|
28
|
+
*/
|
|
29
|
+
export const authClient = new Proxy({} as ReturnType<typeof createAuthClient>, {
|
|
30
|
+
get(_, prop) {
|
|
31
|
+
if (!client) {
|
|
32
|
+
// No auto-fallback to origin for web components.
|
|
33
|
+
// AdminClient will call configureAuth when it has the correct prop.
|
|
34
|
+
throw new Error("Auth client not configured. Did you provide a valid serverUrl?");
|
|
35
|
+
}
|
|
36
|
+
return (client as ReturnType<typeof createAuthClient>)[
|
|
37
|
+
prop as keyof ReturnType<typeof createAuthClient>
|
|
38
|
+
];
|
|
39
|
+
},
|
|
40
|
+
});
|