@revealui/core 0.0.1-pre.4 → 0.2.1
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/LICENSE +22 -202
- package/README.md +108 -152
- package/dist/api/compression.d.ts +83 -0
- package/dist/api/compression.d.ts.map +1 -0
- package/dist/api/compression.js +233 -0
- package/dist/api/payload-optimization.d.ts +138 -0
- package/dist/api/payload-optimization.d.ts.map +1 -0
- package/dist/api/payload-optimization.js +320 -0
- package/dist/api/rate-limit.d.ts +113 -0
- package/dist/api/rate-limit.d.ts.map +1 -0
- package/dist/api/rate-limit.js +316 -0
- package/dist/api/response-cache.d.ts +125 -0
- package/dist/api/response-cache.d.ts.map +1 -0
- package/dist/api/response-cache.js +335 -0
- package/dist/api/rest.d.ts +54 -0
- package/dist/api/rest.d.ts.map +1 -0
- package/dist/api/rest.js +464 -0
- package/dist/auth/access.d.ts +25 -0
- package/dist/auth/access.d.ts.map +1 -0
- package/dist/auth/access.js +20 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/cache/query-cache.d.ts +98 -0
- package/dist/cache/query-cache.d.ts.map +1 -0
- package/dist/cache/query-cache.js +260 -0
- package/dist/caching/app-cache.d.ts +237 -0
- package/dist/caching/app-cache.d.ts.map +1 -0
- package/dist/caching/app-cache.js +430 -0
- package/dist/caching/cdn-config.d.ts +155 -0
- package/dist/caching/cdn-config.d.ts.map +1 -0
- package/dist/caching/cdn-config.js +411 -0
- package/dist/caching/edge-cache.d.ts +177 -0
- package/dist/caching/edge-cache.d.ts.map +1 -0
- package/dist/caching/edge-cache.js +385 -0
- package/dist/caching/service-worker.d.ts +154 -0
- package/dist/caching/service-worker.d.ts.map +1 -0
- package/dist/caching/service-worker.js +437 -0
- package/dist/client/admin/RichText.d.ts +12 -0
- package/dist/client/admin/RichText.d.ts.map +1 -0
- package/dist/client/admin/RichText.js +5 -0
- package/dist/client/admin/components/AdminDashboard.d.ts +7 -0
- package/dist/client/admin/components/AdminDashboard.d.ts.map +1 -0
- package/dist/client/admin/components/AdminDashboard.js +318 -0
- package/dist/client/admin/components/CollectionList.d.ts +16 -0
- package/dist/client/admin/components/CollectionList.d.ts.map +1 -0
- package/dist/client/admin/components/CollectionList.js +67 -0
- package/dist/client/admin/components/DocumentForm.d.ts +11 -0
- package/dist/client/admin/components/DocumentForm.d.ts.map +1 -0
- package/dist/client/admin/components/DocumentForm.js +99 -0
- package/dist/client/admin/components/GlobalForm.d.ts +11 -0
- package/dist/client/admin/components/GlobalForm.d.ts.map +1 -0
- package/dist/client/admin/components/GlobalForm.js +74 -0
- package/dist/client/admin/i18n/en.d.ts +25 -0
- package/dist/client/admin/i18n/en.d.ts.map +1 -0
- package/dist/client/admin/i18n/en.js +25 -0
- package/dist/client/admin/index.d.ts +10 -0
- package/dist/client/admin/index.d.ts.map +1 -0
- package/dist/client/admin/index.js +10 -0
- package/dist/client/admin/layout.d.ts +10 -0
- package/dist/client/admin/layout.d.ts.map +1 -0
- package/dist/client/admin/layout.js +6 -0
- package/dist/client/admin/page.d.ts +38 -0
- package/dist/client/admin/page.d.ts.map +1 -0
- package/dist/client/admin/page.js +15 -0
- package/dist/client/admin/utils/apiClient.d.ts +110 -0
- package/dist/client/admin/utils/apiClient.d.ts.map +1 -0
- package/dist/client/admin/utils/apiClient.js +220 -0
- package/dist/client/admin/utils/auth.d.ts +23 -0
- package/dist/client/admin/utils/auth.d.ts.map +1 -0
- package/dist/client/admin/utils/auth.js +52 -0
- package/dist/client/admin/utils/index.d.ts +6 -0
- package/dist/client/admin/utils/index.d.ts.map +1 -0
- package/dist/client/admin/utils/index.js +5 -0
- package/dist/client/admin/utils/serializeConfig.d.ts +7 -0
- package/dist/client/admin/utils/serializeConfig.d.ts.map +1 -0
- package/dist/client/admin/utils/serializeConfig.js +35 -0
- package/dist/client/hooks.d.ts +18 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +29 -0
- package/dist/client/http/client.d.ts +15 -0
- package/dist/client/http/client.d.ts.map +1 -0
- package/dist/client/http/client.js +49 -0
- package/dist/client/http/fetchBanner.d.ts +18 -0
- package/dist/client/http/fetchBanner.d.ts.map +1 -0
- package/dist/client/http/fetchBanner.js +44 -0
- package/dist/client/http/fetchCard.d.ts +18 -0
- package/dist/client/http/fetchCard.d.ts.map +1 -0
- package/dist/client/http/fetchCard.js +46 -0
- package/dist/client/http/fetchEvents.d.ts +18 -0
- package/dist/client/http/fetchEvents.d.ts.map +1 -0
- package/dist/client/http/fetchEvents.js +44 -0
- package/dist/client/http/fetchHero.d.ts +17 -0
- package/dist/client/http/fetchHero.d.ts.map +1 -0
- package/dist/client/http/fetchHero.js +55 -0
- package/dist/client/http/fetchMainInfos.d.ts +17 -0
- package/dist/client/http/fetchMainInfos.d.ts.map +1 -0
- package/dist/client/http/fetchMainInfos.js +44 -0
- package/dist/client/http/fetchVideos.d.ts +13 -0
- package/dist/client/http/fetchVideos.d.ts.map +1 -0
- package/dist/client/http/fetchVideos.js +36 -0
- package/dist/client/http/index.d.ts +19 -0
- package/dist/client/http/index.d.ts.map +1 -0
- package/dist/client/http/index.js +11 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +13 -0
- package/dist/client/richtext/RichTextEditor.d.ts +48 -0
- package/dist/client/richtext/RichTextEditor.d.ts.map +1 -0
- package/dist/client/richtext/RichTextEditor.js +360 -0
- package/dist/client/richtext/components/ImageNodeComponent.d.ts +9 -0
- package/dist/client/richtext/components/ImageNodeComponent.d.ts.map +1 -0
- package/dist/client/richtext/components/ImageNodeComponent.js +99 -0
- package/dist/client/richtext/components/ImageUploadButton.d.ts +11 -0
- package/dist/client/richtext/components/ImageUploadButton.d.ts.map +1 -0
- package/dist/client/richtext/components/ImageUploadButton.js +103 -0
- package/dist/client/richtext/index.d.ts +92 -0
- package/dist/client/richtext/index.d.ts.map +1 -0
- package/dist/client/richtext/index.js +74 -0
- package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts +20 -0
- package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts.map +1 -0
- package/dist/client/richtext/nodes/DecoratorBlockNode.js +29 -0
- package/dist/client/richtext/nodes/ImageNode.d.ts +51 -0
- package/dist/client/richtext/nodes/ImageNode.d.ts.map +1 -0
- package/dist/client/richtext/nodes/ImageNode.js +95 -0
- package/dist/client/richtext/plugins/CollaborationPlugin.d.ts +13 -0
- package/dist/client/richtext/plugins/CollaborationPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/CollaborationPlugin.js +8 -0
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts +4 -0
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.js +50 -0
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts +7 -0
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +248 -0
- package/dist/client/richtext/plugins/ImagePlugin.d.ts +3 -0
- package/dist/client/richtext/plugins/ImagePlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/ImagePlugin.js +73 -0
- package/dist/client/richtext/plugins/PastePlugin.d.ts +2 -0
- package/dist/client/richtext/plugins/PastePlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/PastePlugin.js +36 -0
- package/dist/client/richtext/plugins/ToolbarPlugin.d.ts +8 -0
- package/dist/client/richtext/plugins/ToolbarPlugin.d.ts.map +1 -0
- package/dist/client/richtext/plugins/ToolbarPlugin.js +204 -0
- package/dist/client/ui/index.d.ts +111 -0
- package/dist/client/ui/index.d.ts.map +1 -0
- package/dist/client/ui/index.js +130 -0
- package/dist/collections/CollectionOperations.d.ts +27 -0
- package/dist/collections/CollectionOperations.d.ts.map +1 -0
- package/dist/collections/CollectionOperations.js +34 -0
- package/dist/collections/hooks.d.ts +11 -0
- package/dist/collections/hooks.d.ts.map +1 -0
- package/dist/collections/hooks.js +35 -0
- package/dist/collections/index.d.ts +2 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/index.js +1 -0
- package/dist/collections/operations/create.d.ts +10 -0
- package/dist/collections/operations/create.d.ts.map +1 -0
- package/dist/collections/operations/create.js +101 -0
- package/dist/collections/operations/delete.d.ts +10 -0
- package/dist/collections/operations/delete.d.ts.map +1 -0
- package/dist/collections/operations/delete.js +16 -0
- package/dist/collections/operations/fieldHooks.d.ts +21 -0
- package/dist/collections/operations/fieldHooks.d.ts.map +1 -0
- package/dist/collections/operations/fieldHooks.js +51 -0
- package/dist/collections/operations/find.d.ts +10 -0
- package/dist/collections/operations/find.d.ts.map +1 -0
- package/dist/collections/operations/find.js +124 -0
- package/dist/collections/operations/findById.d.ts +15 -0
- package/dist/collections/operations/findById.d.ts.map +1 -0
- package/dist/collections/operations/findById.js +59 -0
- package/dist/collections/operations/update.d.ts +10 -0
- package/dist/collections/operations/update.d.ts.map +1 -0
- package/dist/collections/operations/update.js +134 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +61 -0
- package/dist/config/runtime.d.ts +22 -0
- package/dist/config/runtime.d.ts.map +1 -0
- package/dist/config/runtime.js +32 -0
- package/dist/config/utils.d.ts +12 -0
- package/dist/config/utils.d.ts.map +1 -0
- package/dist/config/utils.js +34 -0
- package/dist/database/index.d.ts +1 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +6 -0
- package/dist/database/safe-parse.d.ts +26 -0
- package/dist/database/safe-parse.d.ts.map +1 -0
- package/dist/database/safe-parse.js +42 -0
- package/dist/database/ssl-config.d.ts +9 -0
- package/dist/database/ssl-config.d.ts.map +1 -0
- package/dist/database/ssl-config.js +7 -0
- package/dist/database/type-adapter.d.ts +113 -0
- package/dist/database/type-adapter.d.ts.map +1 -0
- package/dist/database/type-adapter.js +97 -0
- package/dist/database/universal-postgres.d.ts +45 -0
- package/dist/database/universal-postgres.d.ts.map +1 -0
- package/dist/database/universal-postgres.js +526 -0
- package/dist/dataloader.d.ts +26 -0
- package/dist/dataloader.d.ts.map +1 -0
- package/dist/dataloader.js +176 -0
- package/dist/error-handling/circuit-breaker.d.ts +262 -0
- package/dist/error-handling/circuit-breaker.d.ts.map +1 -0
- package/dist/error-handling/circuit-breaker.js +542 -0
- package/dist/error-handling/error-boundary.d.ts +94 -0
- package/dist/error-handling/error-boundary.d.ts.map +1 -0
- package/dist/error-handling/error-boundary.js +285 -0
- package/dist/error-handling/error-reporter.d.ts +214 -0
- package/dist/error-handling/error-reporter.d.ts.map +1 -0
- package/dist/error-handling/error-reporter.js +477 -0
- package/dist/error-handling/fallback-components.d.ts +131 -0
- package/dist/error-handling/fallback-components.d.ts.map +1 -0
- package/dist/error-handling/fallback-components.js +371 -0
- package/dist/error-handling/index.d.ts +16 -0
- package/dist/error-handling/index.d.ts.map +1 -0
- package/dist/error-handling/index.js +15 -0
- package/dist/error-handling/retry.d.ts +194 -0
- package/dist/error-handling/retry.d.ts.map +1 -0
- package/dist/error-handling/retry.js +450 -0
- package/dist/errors/index.d.ts +23 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +40 -0
- package/dist/factories/builders.d.ts +50 -0
- package/dist/factories/builders.d.ts.map +1 -0
- package/dist/factories/builders.js +77 -0
- package/dist/factories/index.d.ts +2 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +1 -0
- package/dist/features.d.ts +86 -0
- package/dist/features.d.ts.map +1 -0
- package/dist/features.js +92 -0
- package/dist/fieldTraversal.d.ts +26 -0
- package/dist/fieldTraversal.d.ts.map +1 -0
- package/dist/fieldTraversal.js +132 -0
- package/dist/fields/config/types.d.ts +48 -0
- package/dist/fields/config/types.d.ts.map +1 -0
- package/dist/fields/config/types.js +20 -0
- package/dist/fields/getDefaultValue.d.ts +16 -0
- package/dist/fields/getDefaultValue.d.ts.map +1 -0
- package/dist/fields/getDefaultValue.js +20 -0
- package/dist/fields/getFieldPaths.d.ts +25 -0
- package/dist/fields/getFieldPaths.d.ts.map +1 -0
- package/dist/fields/getFieldPaths.js +23 -0
- package/dist/fields/hooks/afterRead/index.d.ts +36 -0
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -0
- package/dist/fields/hooks/afterRead/index.js +70 -0
- package/dist/fields/hooks/afterRead/promise.d.ts +46 -0
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -0
- package/dist/fields/hooks/afterRead/promise.js +178 -0
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +44 -0
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -0
- package/dist/fields/hooks/afterRead/traverseFields.js +37 -0
- package/dist/generated/agents/index.d.ts +8 -0
- package/dist/generated/agents/index.d.ts.map +1 -0
- package/dist/generated/agents/index.js +7 -0
- package/dist/generated/components/index.d.ts +8 -0
- package/dist/generated/components/index.d.ts.map +1 -0
- package/dist/generated/components/index.js +7 -0
- package/dist/generated/functions/index.d.ts +8 -0
- package/dist/generated/functions/index.d.ts.map +1 -0
- package/dist/generated/functions/index.js +7 -0
- package/dist/generated/hooks/index.d.ts +8 -0
- package/dist/generated/hooks/index.d.ts.map +1 -0
- package/dist/generated/hooks/index.js +7 -0
- package/dist/generated/index.d.ts +10 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +9 -0
- package/dist/generated/plans/index.d.ts +8 -0
- package/dist/generated/plans/index.d.ts.map +1 -0
- package/dist/generated/plans/index.js +7 -0
- package/dist/generated/prompts/index.d.ts +8 -0
- package/dist/generated/prompts/index.d.ts.map +1 -0
- package/dist/generated/prompts/index.js +7 -0
- package/dist/generated/tools/index.d.ts +8 -0
- package/dist/generated/tools/index.d.ts.map +1 -0
- package/dist/generated/tools/index.js +7 -0
- package/dist/generated/types/cms.d.ts +1766 -0
- package/dist/generated/types/cms.d.ts.map +1 -0
- package/dist/generated/types/cms.js +12 -0
- package/dist/generated/types/index.d.ts +16 -0
- package/dist/generated/types/index.d.ts.map +1 -0
- package/dist/generated/types/index.js +21 -0
- package/dist/generated/types/neon.d.ts +11 -0
- package/dist/generated/types/neon.d.ts.map +1 -0
- package/dist/generated/types/neon.js +11 -0
- package/dist/generated/types/supabase.d.ts +193 -0
- package/dist/generated/types/supabase.d.ts.map +1 -0
- package/dist/generated/types/supabase.js +5 -0
- package/dist/globals/GlobalOperations.d.ts +24 -0
- package/dist/globals/GlobalOperations.d.ts.map +1 -0
- package/dist/globals/GlobalOperations.js +149 -0
- package/dist/globals/index.d.ts +2 -0
- package/dist/globals/index.d.ts.map +1 -0
- package/dist/globals/index.js +1 -0
- package/dist/index.d.ts +64 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +126 -33
- package/dist/instance/RevealUIInstance.d.ts +6 -0
- package/dist/instance/RevealUIInstance.d.ts.map +1 -0
- package/dist/instance/RevealUIInstance.js +306 -0
- package/dist/instance/index.d.ts +3 -0
- package/dist/instance/index.d.ts.map +1 -0
- package/dist/instance/index.js +2 -0
- package/dist/instance/logger.d.ts +31 -0
- package/dist/instance/logger.d.ts.map +1 -0
- package/dist/instance/logger.js +42 -0
- package/dist/instance/methods/create.d.ts +10 -0
- package/dist/instance/methods/create.d.ts.map +1 -0
- package/dist/instance/methods/create.js +41 -0
- package/dist/instance/methods/delete.d.ts +10 -0
- package/dist/instance/methods/delete.d.ts.map +1 -0
- package/dist/instance/methods/delete.js +27 -0
- package/dist/instance/methods/find.d.ts +10 -0
- package/dist/instance/methods/find.d.ts.map +1 -0
- package/dist/instance/methods/find.js +23 -0
- package/dist/instance/methods/findById.d.ts +13 -0
- package/dist/instance/methods/findById.d.ts.map +1 -0
- package/dist/instance/methods/findById.js +23 -0
- package/dist/instance/methods/hooks.d.ts +14 -0
- package/dist/instance/methods/hooks.d.ts.map +1 -0
- package/dist/instance/methods/hooks.js +34 -0
- package/dist/instance/methods/update.d.ts +10 -0
- package/dist/instance/methods/update.d.ts.map +1 -0
- package/dist/instance/methods/update.js +45 -0
- package/dist/license.d.ts +82 -0
- package/dist/license.d.ts.map +1 -0
- package/dist/license.js +193 -0
- package/dist/monitoring/alerts.d.ts +118 -0
- package/dist/monitoring/alerts.d.ts.map +1 -0
- package/dist/monitoring/alerts.js +324 -0
- package/dist/monitoring/cleanup-manager.d.ts +71 -0
- package/dist/monitoring/cleanup-manager.d.ts.map +1 -0
- package/dist/monitoring/cleanup-manager.js +226 -0
- package/dist/monitoring/health-monitor.d.ts +22 -0
- package/dist/monitoring/health-monitor.d.ts.map +1 -0
- package/dist/monitoring/health-monitor.js +142 -0
- package/dist/monitoring/index.d.ts +14 -0
- package/dist/monitoring/index.d.ts.map +1 -0
- package/dist/monitoring/index.js +17 -0
- package/dist/monitoring/process-registry.d.ts +97 -0
- package/dist/monitoring/process-registry.d.ts.map +1 -0
- package/dist/monitoring/process-registry.js +222 -0
- package/dist/monitoring/query-monitor.d.ts +153 -0
- package/dist/monitoring/query-monitor.d.ts.map +1 -0
- package/dist/monitoring/query-monitor.js +209 -0
- package/dist/monitoring/types.d.ts +231 -0
- package/dist/monitoring/types.d.ts.map +1 -0
- package/dist/monitoring/types.js +42 -0
- package/dist/monitoring/zombie-detector.d.ts +81 -0
- package/dist/monitoring/zombie-detector.d.ts.map +1 -0
- package/dist/monitoring/zombie-detector.js +231 -0
- package/dist/nextjs/index.d.ts +4 -0
- package/dist/nextjs/index.d.ts.map +1 -0
- package/dist/nextjs/index.js +3 -0
- package/dist/nextjs/utilities.d.ts +5 -0
- package/dist/nextjs/utilities.d.ts.map +1 -0
- package/dist/nextjs/utilities.js +16 -0
- package/dist/nextjs/withRevealUI.d.ts +20 -0
- package/dist/nextjs/withRevealUI.d.ts.map +1 -0
- package/dist/nextjs/withRevealUI.js +181 -0
- package/dist/observability/alerts.d.ts +138 -0
- package/dist/observability/alerts.d.ts.map +1 -0
- package/dist/observability/alerts.js +390 -0
- package/dist/observability/health-check.d.ts +95 -0
- package/dist/observability/health-check.d.ts.map +1 -0
- package/dist/observability/health-check.js +375 -0
- package/dist/observability/index.d.ts +12 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +11 -0
- package/dist/observability/logger.d.ts +47 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +140 -0
- package/dist/observability/metrics.d.ts +205 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +429 -0
- package/dist/observability/tracing.d.ts +149 -0
- package/dist/observability/tracing.d.ts.map +1 -0
- package/dist/observability/tracing.js +381 -0
- package/dist/optimization/asset-optimizer.d.ts +202 -0
- package/dist/optimization/asset-optimizer.d.ts.map +1 -0
- package/dist/optimization/asset-optimizer.js +312 -0
- package/dist/optimization/build-optimizer.d.ts +202 -0
- package/dist/optimization/build-optimizer.d.ts.map +1 -0
- package/dist/optimization/build-optimizer.js +271 -0
- package/dist/optimization/bundle-analyzer.d.ts +98 -0
- package/dist/optimization/bundle-analyzer.d.ts.map +1 -0
- package/dist/optimization/bundle-analyzer.js +322 -0
- package/dist/optimization/code-splitting.d.ts +131 -0
- package/dist/optimization/code-splitting.d.ts.map +1 -0
- package/dist/optimization/code-splitting.js +277 -0
- package/dist/plugin/index.d.ts +12 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +4 -0
- package/dist/plugins/form-builder.d.ts +115 -0
- package/dist/plugins/form-builder.d.ts.map +1 -0
- package/dist/plugins/form-builder.js +239 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/nested-docs.d.ts +8 -0
- package/dist/plugins/nested-docs.d.ts.map +1 -0
- package/dist/plugins/nested-docs.js +67 -0
- package/dist/plugins/redirects.d.ts +17 -0
- package/dist/plugins/redirects.d.ts.map +1 -0
- package/dist/plugins/redirects.js +62 -0
- package/dist/queries/index.d.ts +2 -0
- package/dist/queries/index.d.ts.map +1 -0
- package/dist/queries/index.js +1 -0
- package/dist/queries/queryBuilder.d.ts +47 -0
- package/dist/queries/queryBuilder.d.ts.map +1 -0
- package/dist/queries/queryBuilder.js +255 -0
- package/dist/relationships/analyzer.d.ts +39 -0
- package/dist/relationships/analyzer.d.ts.map +1 -0
- package/dist/relationships/analyzer.js +127 -0
- package/dist/relationships/index.d.ts +3 -0
- package/dist/relationships/index.d.ts.map +1 -0
- package/dist/relationships/index.js +2 -0
- package/dist/relationships/populate-helpers.d.ts +104 -0
- package/dist/relationships/populate-helpers.d.ts.map +1 -0
- package/dist/relationships/populate-helpers.js +187 -0
- package/dist/relationships/population.d.ts +42 -0
- package/dist/relationships/population.d.ts.map +1 -0
- package/dist/relationships/population.js +188 -0
- package/dist/revealui.d.ts +46 -0
- package/dist/revealui.d.ts.map +1 -0
- package/dist/revealui.js +92 -0
- package/dist/richtext/exports/client/rcc.d.ts +37 -0
- package/dist/richtext/exports/client/rcc.d.ts.map +1 -0
- package/dist/richtext/exports/client/rcc.js +182 -0
- package/dist/richtext/exports/server/rsc.d.ts +117 -0
- package/dist/richtext/exports/server/rsc.d.ts.map +1 -0
- package/dist/richtext/exports/server/rsc.js +288 -0
- package/dist/richtext/index.d.ts +161 -0
- package/dist/richtext/index.d.ts.map +1 -0
- package/dist/richtext/index.js +243 -0
- package/dist/richtext/lexical.d.ts +23 -0
- package/dist/richtext/lexical.d.ts.map +1 -0
- package/dist/richtext/lexical.js +35 -0
- package/dist/security/audit.d.ts +188 -0
- package/dist/security/audit.d.ts.map +1 -0
- package/dist/security/audit.js +431 -0
- package/dist/security/auth.d.ts +241 -0
- package/dist/security/auth.d.ts.map +1 -0
- package/dist/security/auth.js +476 -0
- package/dist/security/authorization.d.ts +235 -0
- package/dist/security/authorization.d.ts.map +1 -0
- package/dist/security/authorization.js +434 -0
- package/dist/security/encryption.d.ts +214 -0
- package/dist/security/encryption.d.ts.map +1 -0
- package/dist/security/encryption.js +517 -0
- package/dist/security/gdpr.d.ts +300 -0
- package/dist/security/gdpr.d.ts.map +1 -0
- package/dist/security/gdpr.js +465 -0
- package/dist/security/headers.d.ts +182 -0
- package/dist/security/headers.d.ts.map +1 -0
- package/dist/security/headers.js +402 -0
- package/dist/security/index.d.ts +19 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +18 -0
- package/dist/server/index.d.ts +21 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +28 -0
- package/dist/server/renderPage.d.ts +69 -0
- package/dist/server/renderPage.d.ts.map +1 -0
- package/dist/server/renderPage.js +109 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +4 -0
- package/dist/storage/vercel-blob.d.ts +17 -0
- package/dist/storage/vercel-blob.d.ts.map +1 -0
- package/dist/storage/vercel-blob.js +83 -0
- package/dist/translations/index.d.ts +17 -0
- package/dist/translations/index.d.ts.map +1 -0
- package/dist/translations/index.js +1 -0
- package/dist/types/access.d.ts +67 -0
- package/dist/types/access.d.ts.map +1 -0
- package/dist/types/access.js +8 -0
- package/dist/types/api.d.ts +57 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +8 -0
- package/dist/types/cms.d.ts +8 -0
- package/dist/types/cms.d.ts.map +1 -0
- package/dist/types/cms.js +6 -0
- package/dist/types/config.d.ts +152 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +9 -0
- package/dist/types/core.d.ts +11 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +9 -0
- package/dist/types/extensions.d.ts +116 -0
- package/dist/types/extensions.d.ts.map +1 -0
- package/dist/types/extensions.js +8 -0
- package/dist/types/frontend.d.ts +53 -0
- package/dist/types/frontend.d.ts.map +1 -0
- package/dist/types/frontend.js +7 -0
- package/dist/types/generated.d.ts +12 -0
- package/dist/types/generated.d.ts.map +1 -0
- package/dist/types/generated.js +10 -0
- package/dist/types/hooks.d.ts +53 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/hooks.js +8 -0
- package/dist/types/index.d.ts +49 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +61 -0
- package/dist/types/interfaces/app.d.ts +50 -0
- package/dist/types/interfaces/app.d.ts.map +1 -0
- package/dist/types/interfaces/app.js +5 -0
- package/dist/types/jobs.d.ts +112 -0
- package/dist/types/jobs.d.ts.map +1 -0
- package/dist/types/jobs.js +7 -0
- package/dist/types/legacy.d.ts +147 -0
- package/dist/types/legacy.d.ts.map +1 -0
- package/dist/types/legacy.js +8 -0
- package/dist/types/plugins.d.ts +17 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/plugins.js +8 -0
- package/dist/types/query.d.ts +99 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/query.js +24 -0
- package/dist/types/request.d.ts +40 -0
- package/dist/types/request.d.ts.map +1 -0
- package/dist/types/request.js +8 -0
- package/dist/types/richtext.d.ts +23 -0
- package/dist/types/richtext.d.ts.map +1 -0
- package/dist/types/richtext.js +8 -0
- package/dist/types/runtime.d.ts +216 -0
- package/dist/types/runtime.d.ts.map +1 -0
- package/dist/types/runtime.js +9 -0
- package/dist/types/schema.d.ts +9 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +7 -0
- package/dist/types/user.d.ts +48 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/user.js +8 -0
- package/dist/utils/access-conversion.d.ts +17 -0
- package/dist/utils/access-conversion.d.ts.map +1 -0
- package/dist/utils/access-conversion.js +96 -0
- package/dist/utils/api-wrapper.d.ts +63 -0
- package/dist/utils/api-wrapper.d.ts.map +1 -0
- package/dist/utils/api-wrapper.js +151 -0
- package/dist/utils/block-conversion.d.ts +21 -0
- package/dist/utils/block-conversion.d.ts.map +1 -0
- package/dist/utils/block-conversion.js +109 -0
- package/dist/utils/cache.d.ts +86 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +154 -0
- package/dist/utils/deep-clone.d.ts +25 -0
- package/dist/utils/deep-clone.d.ts.map +1 -0
- package/dist/utils/deep-clone.js +115 -0
- package/dist/utils/error-responses.d.ts +57 -0
- package/dist/utils/error-responses.d.ts.map +1 -0
- package/dist/utils/error-responses.js +96 -0
- package/dist/utils/errors.d.ts +97 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +397 -0
- package/dist/utils/field-conversion.d.ts +40 -0
- package/dist/utils/field-conversion.d.ts.map +1 -0
- package/dist/utils/field-conversion.js +275 -0
- package/dist/utils/flattenResult.d.ts +7 -0
- package/dist/utils/flattenResult.d.ts.map +1 -0
- package/dist/utils/flattenResult.js +23 -0
- package/dist/utils/getBlockSelect.d.ts +12 -0
- package/dist/utils/getBlockSelect.d.ts.map +1 -0
- package/dist/utils/getBlockSelect.js +12 -0
- package/dist/utils/getSelectMode.d.ts +8 -0
- package/dist/utils/getSelectMode.d.ts.map +1 -0
- package/dist/utils/getSelectMode.js +21 -0
- package/dist/utils/isValidID.d.ts +5 -0
- package/dist/utils/isValidID.d.ts.map +1 -0
- package/dist/utils/isValidID.js +13 -0
- package/dist/utils/json-parsing.d.ts +48 -0
- package/dist/utils/json-parsing.d.ts.map +1 -0
- package/dist/utils/json-parsing.js +130 -0
- package/dist/utils/jwt-validation.d.ts +14 -0
- package/dist/utils/jwt-validation.d.ts.map +1 -0
- package/dist/utils/jwt-validation.js +36 -0
- package/dist/utils/logger-client.d.ts +32 -0
- package/dist/utils/logger-client.d.ts.map +1 -0
- package/dist/utils/logger-client.js +55 -0
- package/dist/utils/logger-server.d.ts +32 -0
- package/dist/utils/logger-server.d.ts.map +1 -0
- package/dist/utils/logger-server.js +68 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +12 -0
- package/dist/utils/request-context.d.ts +143 -0
- package/dist/utils/request-context.d.ts.map +1 -0
- package/dist/utils/request-context.js +168 -0
- package/dist/utils/request-headers.d.ts +15 -0
- package/dist/utils/request-headers.d.ts.map +1 -0
- package/dist/utils/request-headers.js +31 -0
- package/dist/utils/stripUnselectedFields.d.ts +10 -0
- package/dist/utils/stripUnselectedFields.d.ts.map +1 -0
- package/dist/utils/stripUnselectedFields.js +20 -0
- package/dist/utils/type-guards.d.ts +33 -0
- package/dist/utils/type-guards.d.ts.map +1 -0
- package/dist/utils/type-guards.js +63 -0
- package/dist/utils/user.d.ts +14 -0
- package/dist/utils/user.d.ts.map +1 -0
- package/dist/utils/user.js +15 -0
- package/package.json +241 -724
- package/LICENSE_SUMMARY.md +0 -55
- package/NOTICE +0 -34
- package/dist/exports/RenderErrorPage.js +0 -3
- package/dist/exports/__internal.js +0 -3
- package/dist/exports/abort.js +0 -3
- package/dist/exports/bin-entry.js +0 -5
- package/dist/exports/client.js +0 -3
- package/dist/exports/config.js +0 -1
- package/dist/exports/helpers.js +0 -1
- package/dist/exports/index.js +0 -33
- package/dist/exports/plugin.js +0 -3
- package/dist/exports/prerender.js +0 -3
- package/dist/exports/router.js +0 -3
- package/dist/exports/routing.js +0 -3
- package/dist/exports/server.js +0 -3
- package/dist/exports/setup.js +0 -3
- package/dist/exports/types.js +0 -1
- package/dist/integration/styles.css +0 -141
- package/dist/shared/RenderErrorPage.d.ts +0 -3
- package/dist/shared/RenderErrorPage.js +0 -3
- package/dist/shared/abort.js +0 -3
- package/dist/shared/route/routing.js +0 -3
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find Operation
|
|
3
|
+
*
|
|
4
|
+
* Finds multiple documents with pagination, filtering, sorting, and relationship population.
|
|
5
|
+
*/
|
|
6
|
+
import { afterRead } from '../../fields/hooks/afterRead/index.js';
|
|
7
|
+
import { buildWhereClause } from '../../queries/queryBuilder.js';
|
|
8
|
+
import { deserializeJsonFields } from '../../utils/json-parsing.js';
|
|
9
|
+
export async function find(config, db, options) {
|
|
10
|
+
const { where, limit = 10, page = 1, sort, depth = 0, req, populate: populateOption } = options;
|
|
11
|
+
// Validate depth
|
|
12
|
+
if (depth < 0 || depth > 3) {
|
|
13
|
+
throw new Error(`Depth must be between 0 and 3, got ${depth}`);
|
|
14
|
+
}
|
|
15
|
+
// Build query based on database adapter
|
|
16
|
+
if (db?.query) {
|
|
17
|
+
const offset = (page - 1) * limit;
|
|
18
|
+
const tableName = config.slug;
|
|
19
|
+
// Build WHERE clause using query builder
|
|
20
|
+
const params = [];
|
|
21
|
+
const whereClause = buildWhereClause(where, params, {
|
|
22
|
+
parameterStyle: 'postgres',
|
|
23
|
+
includeWhereKeyword: false,
|
|
24
|
+
quoteFields: true,
|
|
25
|
+
});
|
|
26
|
+
// Build ORDER BY clause
|
|
27
|
+
let orderByClause = '';
|
|
28
|
+
if (sort) {
|
|
29
|
+
const sortConditions = [];
|
|
30
|
+
Object.entries(sort).forEach(([key, direction]) => {
|
|
31
|
+
sortConditions.push(`"${key}" ${direction === '-1' ? 'DESC' : 'ASC'}`);
|
|
32
|
+
});
|
|
33
|
+
orderByClause = sortConditions.length > 0 ? `ORDER BY ${sortConditions.join(', ')}` : '';
|
|
34
|
+
}
|
|
35
|
+
// Execute count query (PostgreSQL)
|
|
36
|
+
// whereClause should never start with "WHERE" when includeWhereKeyword: false
|
|
37
|
+
// Add validation to catch any bugs
|
|
38
|
+
if (whereClause?.trim().toUpperCase().startsWith('WHERE')) {
|
|
39
|
+
throw new Error(`WHERE clause unexpectedly starts with "WHERE" keyword. This indicates a bug in buildWhereClause. Clause: ${whereClause}`);
|
|
40
|
+
}
|
|
41
|
+
const countQuery = whereClause
|
|
42
|
+
? `SELECT COUNT(*) as total FROM "${tableName}" WHERE ${whereClause}`
|
|
43
|
+
: `SELECT COUNT(*) as total FROM "${tableName}"`;
|
|
44
|
+
const countResult = await db.query(countQuery, params);
|
|
45
|
+
const totalDocs = Number(countResult.rows[0]?.total) || 0;
|
|
46
|
+
// Execute data query (PostgreSQL uses $1, $2 for parameters)
|
|
47
|
+
// whereClause should never start with "WHERE" when includeWhereKeyword: false
|
|
48
|
+
// Add validation to catch any bugs
|
|
49
|
+
if (whereClause?.trim().toUpperCase().startsWith('WHERE')) {
|
|
50
|
+
throw new Error(`WHERE clause unexpectedly starts with "WHERE" keyword. This indicates a bug in buildWhereClause. Clause: ${whereClause}`);
|
|
51
|
+
}
|
|
52
|
+
// Verify parameter count matches placeholder count
|
|
53
|
+
const wherePlaceholderCount = (whereClause.match(/\$\d+/g) || []).length;
|
|
54
|
+
const limitOffsetPlaceholders = 2; // LIMIT and OFFSET
|
|
55
|
+
const totalPlaceholderCount = wherePlaceholderCount + limitOffsetPlaceholders;
|
|
56
|
+
const totalParamCount = params.length + 2; // params from WHERE + limit + offset
|
|
57
|
+
if (totalPlaceholderCount !== totalParamCount) {
|
|
58
|
+
throw new Error(`Parameter count mismatch: Expected ${totalPlaceholderCount} placeholders (${wherePlaceholderCount} from WHERE + ${limitOffsetPlaceholders} for LIMIT/OFFSET), but got ${totalParamCount} parameters (${params.length} from WHERE + 2 for LIMIT/OFFSET). WHERE clause: ${whereClause}`);
|
|
59
|
+
}
|
|
60
|
+
const limitParam = params.length + 1;
|
|
61
|
+
const offsetParam = params.length + 2;
|
|
62
|
+
const dataQuery = `SELECT * FROM "${tableName}" ${whereClause ? `WHERE ${whereClause}` : ''} ${orderByClause} LIMIT $${limitParam} OFFSET $${offsetParam}`;
|
|
63
|
+
const docsResult = await db.query(dataQuery, [...params, limit, offset]);
|
|
64
|
+
let docs = docsResult.rows.map((row) => {
|
|
65
|
+
return deserializeJsonFields(row, tableName);
|
|
66
|
+
});
|
|
67
|
+
// Apply relationship population if depth > 0
|
|
68
|
+
if (req && depth > 0) {
|
|
69
|
+
// RevealCollectionConfig extends CollectionConfig, which matches SanitizedCollectionConfig structure
|
|
70
|
+
const sanitizedConfig = {
|
|
71
|
+
...config,
|
|
72
|
+
fields: config.fields,
|
|
73
|
+
flattenedFields: config.fields,
|
|
74
|
+
endpoints: config.endpoints === false ? undefined : config.endpoints,
|
|
75
|
+
};
|
|
76
|
+
docs = await Promise.all(docs.map(async (doc) => {
|
|
77
|
+
return await afterRead({
|
|
78
|
+
collection: sanitizedConfig,
|
|
79
|
+
context: req.context || {},
|
|
80
|
+
currentDepth: 1,
|
|
81
|
+
depth,
|
|
82
|
+
doc,
|
|
83
|
+
draft: false,
|
|
84
|
+
fallbackLocale: req.fallbackLocale || 'en',
|
|
85
|
+
findMany: true,
|
|
86
|
+
flattenLocales: true,
|
|
87
|
+
global: null,
|
|
88
|
+
locale: req.locale || 'en',
|
|
89
|
+
overrideAccess: false,
|
|
90
|
+
populate: populateOption,
|
|
91
|
+
req,
|
|
92
|
+
select: undefined,
|
|
93
|
+
showHiddenFields: false,
|
|
94
|
+
});
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
const totalPages = Math.ceil(totalDocs / limit);
|
|
98
|
+
return {
|
|
99
|
+
docs,
|
|
100
|
+
totalDocs,
|
|
101
|
+
limit,
|
|
102
|
+
totalPages,
|
|
103
|
+
page,
|
|
104
|
+
pagingCounter: offset + 1,
|
|
105
|
+
hasPrevPage: page > 1,
|
|
106
|
+
hasNextPage: page < totalPages,
|
|
107
|
+
prevPage: page > 1 ? page - 1 : null,
|
|
108
|
+
nextPage: page < totalPages ? page + 1 : null,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Fallback for no database
|
|
112
|
+
return {
|
|
113
|
+
docs: [],
|
|
114
|
+
totalDocs: 0,
|
|
115
|
+
limit,
|
|
116
|
+
totalPages: 0,
|
|
117
|
+
page,
|
|
118
|
+
pagingCounter: 0,
|
|
119
|
+
hasPrevPage: false,
|
|
120
|
+
hasNextPage: false,
|
|
121
|
+
prevPage: null,
|
|
122
|
+
nextPage: null,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find By ID Operation
|
|
3
|
+
*
|
|
4
|
+
* Finds a single document by ID with optional relationship population.
|
|
5
|
+
*/
|
|
6
|
+
import type { DatabaseResult, PopulateType, RevealCollectionConfig, RevealDocument, RevealRequest } from '../../types/index.js';
|
|
7
|
+
export declare function findByID(config: RevealCollectionConfig, db: {
|
|
8
|
+
query: (query: string, values?: unknown[]) => Promise<DatabaseResult>;
|
|
9
|
+
} | null, options: {
|
|
10
|
+
id: string | number;
|
|
11
|
+
depth?: number;
|
|
12
|
+
req?: RevealRequest;
|
|
13
|
+
populate?: PopulateType;
|
|
14
|
+
}): Promise<RevealDocument | null>;
|
|
15
|
+
//# sourceMappingURL=findById.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findById.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/findById.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,cAAc,EACd,aAAa,EAEd,MAAM,sBAAsB,CAAA;AAG7B,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,sBAAsB,EAC9B,EAAE,EAAE;IACF,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;CACtE,GAAG,IAAI,EACR,OAAO,EAAE;IACP,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,aAAa,CAAA;IACnB,QAAQ,CAAC,EAAE,YAAY,CAAA;CACxB,GACA,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CA2DhC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find By ID Operation
|
|
3
|
+
*
|
|
4
|
+
* Finds a single document by ID with optional relationship population.
|
|
5
|
+
*/
|
|
6
|
+
import { afterRead } from '../../fields/hooks/afterRead/index.js';
|
|
7
|
+
import { deserializeJsonFields } from '../../utils/json-parsing.js';
|
|
8
|
+
export async function findByID(config, db, options) {
|
|
9
|
+
const { id, depth = 0, req, populate: populateOption } = options;
|
|
10
|
+
// Validate depth
|
|
11
|
+
if (depth < 0 || depth > 3) {
|
|
12
|
+
throw new Error(`Depth must be between 0 and 3, got ${depth}`);
|
|
13
|
+
}
|
|
14
|
+
if (db?.query) {
|
|
15
|
+
const tableName = config.slug;
|
|
16
|
+
// Ensure id is a string for consistent comparison
|
|
17
|
+
const idString = String(id);
|
|
18
|
+
const query = `SELECT * FROM "${tableName}" WHERE id = $1 LIMIT 1`;
|
|
19
|
+
const result = await db.query(query, [idString]);
|
|
20
|
+
const rawDoc = result.rows[0];
|
|
21
|
+
if (!rawDoc) {
|
|
22
|
+
// Don't throw here, just return null as expected
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
// Deserialize JSON strings back to objects/arrays for SQLite compatibility
|
|
26
|
+
const doc = deserializeJsonFields(rawDoc, `${tableName}.id=${id}`);
|
|
27
|
+
// Use afterRead hook system for relationship population
|
|
28
|
+
if (req && depth > 0) {
|
|
29
|
+
// Adapt collection config to sanitized format
|
|
30
|
+
// RevealCollectionConfig extends CollectionConfig, which matches SanitizedCollectionConfig structure
|
|
31
|
+
const sanitizedConfig = {
|
|
32
|
+
...config,
|
|
33
|
+
fields: config.fields,
|
|
34
|
+
flattenedFields: config.fields,
|
|
35
|
+
endpoints: config.endpoints === false ? undefined : config.endpoints,
|
|
36
|
+
};
|
|
37
|
+
return await afterRead({
|
|
38
|
+
collection: sanitizedConfig,
|
|
39
|
+
context: req.context || {},
|
|
40
|
+
currentDepth: 1,
|
|
41
|
+
depth,
|
|
42
|
+
doc,
|
|
43
|
+
draft: false,
|
|
44
|
+
fallbackLocale: req.fallbackLocale || 'en',
|
|
45
|
+
findMany: false,
|
|
46
|
+
flattenLocales: true,
|
|
47
|
+
global: null,
|
|
48
|
+
locale: req.locale || 'en',
|
|
49
|
+
overrideAccess: false,
|
|
50
|
+
populate: populateOption,
|
|
51
|
+
req,
|
|
52
|
+
select: undefined,
|
|
53
|
+
showHiddenFields: false,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return doc;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update Operation
|
|
3
|
+
*
|
|
4
|
+
* Updates an existing document with validation, password hashing, and JSON field handling.
|
|
5
|
+
*/
|
|
6
|
+
import type { DatabaseResult, RevealCollectionConfig, RevealDocument, RevealUpdateOptions } from '../../types/index.js';
|
|
7
|
+
export declare function update(config: RevealCollectionConfig, db: {
|
|
8
|
+
query: (query: string, values?: unknown[]) => Promise<DatabaseResult>;
|
|
9
|
+
} | null, options: RevealUpdateOptions): Promise<RevealDocument>;
|
|
10
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/update.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,cAAc,EAEd,mBAAmB,EACpB,MAAM,sBAAsB,CAAA;AAM7B,wBAAsB,MAAM,CAC1B,MAAM,EAAE,sBAAsB,EAC9B,EAAE,EAAE;IACF,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;CACtE,GAAG,IAAI,EACR,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,cAAc,CAAC,CAgJzB"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update Operation
|
|
3
|
+
*
|
|
4
|
+
* Updates an existing document with validation, password hashing, and JSON field handling.
|
|
5
|
+
*/
|
|
6
|
+
import bcrypt from 'bcryptjs';
|
|
7
|
+
import { defaultLogger } from '../../instance/logger.js';
|
|
8
|
+
import { collectJsonFields, serializeValueForDatabase } from '../../utils/json-parsing.js';
|
|
9
|
+
import { flattenFields, isJsonFieldType } from '../../utils/type-guards.js';
|
|
10
|
+
import { runBeforeFieldHooks } from './fieldHooks.js';
|
|
11
|
+
import { findByID } from './findById.js';
|
|
12
|
+
export async function update(config, db, options) {
|
|
13
|
+
const { id, data } = options;
|
|
14
|
+
// Run beforeValidate field hooks before validation so they can transform values.
|
|
15
|
+
await runBeforeFieldHooks(config, data, 'update', 'beforeValidate');
|
|
16
|
+
// Validate email format if email field is being updated
|
|
17
|
+
if (config.fields) {
|
|
18
|
+
for (const field of config.fields) {
|
|
19
|
+
// Skip fields without a name (should not happen, but TypeScript requires this check)
|
|
20
|
+
if (!field.name) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
// Validate email format if field type is email OR field name is "email"
|
|
24
|
+
// This handles cases where field is named "email" but type might be "text"
|
|
25
|
+
const isEmailField = field.type === 'email' || field.name.toLowerCase() === 'email';
|
|
26
|
+
if (isEmailField &&
|
|
27
|
+
field.name in data &&
|
|
28
|
+
data[field.name] !== null &&
|
|
29
|
+
data[field.name] !== undefined) {
|
|
30
|
+
const emailValue = data[field.name];
|
|
31
|
+
if (typeof emailValue !== 'string') {
|
|
32
|
+
throw new Error(`Field '${field.name}' must be a string`);
|
|
33
|
+
}
|
|
34
|
+
// Stricter email validation regex (RFC 5322 compliant subset)
|
|
35
|
+
// Allows: alphanumeric, dots, hyphens, plus signs, underscores before @
|
|
36
|
+
// Requires: valid domain with at least one dot (TLD required)
|
|
37
|
+
const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/;
|
|
38
|
+
if (!emailRegex.test(emailValue)) {
|
|
39
|
+
throw new Error(`Field '${field.name}' must be a valid email address`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Run beforeChange field hooks after validation but before the DB write.
|
|
45
|
+
await runBeforeFieldHooks(config, data, 'update', 'beforeChange');
|
|
46
|
+
// Hash password if present and not already hashed (doesn't start with $2a$ or $2b$)
|
|
47
|
+
if (data.password && typeof data.password === 'string' && !data.password.startsWith('$2')) {
|
|
48
|
+
const saltRounds = 10;
|
|
49
|
+
data.password = await bcrypt.hash(data.password, saltRounds);
|
|
50
|
+
}
|
|
51
|
+
if (db?.query) {
|
|
52
|
+
const tableName = config.slug;
|
|
53
|
+
// Build UPDATE query (PostgreSQL uses $1, $2 style)
|
|
54
|
+
// Serialize complex values (objects, arrays) to JSON strings for SQLite
|
|
55
|
+
// Filter out fields that should be stored as JSON (not as columns)
|
|
56
|
+
const jsonFieldNames = new Set(flattenFields(config.fields || [])
|
|
57
|
+
.filter((field) => isJsonFieldType(field) && field.name)
|
|
58
|
+
.map((field) => field.name)
|
|
59
|
+
.filter((name) => typeof name === 'string'));
|
|
60
|
+
const keys = Object.keys(data).filter((k) => k !== 'id' && !jsonFieldNames.has(k));
|
|
61
|
+
const jsonKeys = Object.keys(data).filter((k) => k !== 'id' && jsonFieldNames.has(k));
|
|
62
|
+
// Collect JSON fields to update using collectJsonFields utility
|
|
63
|
+
const jsonUpdates = collectJsonFields(data, jsonFieldNames);
|
|
64
|
+
// Fetch existing _json to merge with updates (single query instead of two)
|
|
65
|
+
// Also verify document exists by checking if row exists
|
|
66
|
+
// If collection has JSON fields, we always fetch _json to preserve existing JSON when updating non-JSON fields
|
|
67
|
+
let existingJson = {};
|
|
68
|
+
if (jsonFieldNames.size > 0) {
|
|
69
|
+
// Fetch _json to preserve existing JSON fields (even when only updating non-JSON fields)
|
|
70
|
+
const rawQuery = `SELECT _json FROM "${tableName}" WHERE id = $1 LIMIT 1`;
|
|
71
|
+
const rawResult = await db.query(rawQuery, [String(id)]);
|
|
72
|
+
if (!rawResult.rows[0]) {
|
|
73
|
+
throw new Error(`Document with id ${id} not found`);
|
|
74
|
+
}
|
|
75
|
+
if (rawResult.rows[0]._json !== null && rawResult.rows[0]._json !== undefined) {
|
|
76
|
+
try {
|
|
77
|
+
const rawJson = rawResult.rows[0]._json;
|
|
78
|
+
if (typeof rawJson === 'string') {
|
|
79
|
+
const parsed = JSON.parse(rawJson);
|
|
80
|
+
existingJson =
|
|
81
|
+
parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
82
|
+
? parsed
|
|
83
|
+
: {};
|
|
84
|
+
}
|
|
85
|
+
else if (rawJson && typeof rawJson === 'object' && !Array.isArray(rawJson)) {
|
|
86
|
+
existingJson = rawJson;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
// Log JSON parse error for debugging
|
|
91
|
+
defaultLogger.warn(`[CollectionOperations] Failed to parse _json for ${tableName}.id=${id}:`, error);
|
|
92
|
+
existingJson = {};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (keys.length > 0) {
|
|
97
|
+
// No JSON fields in collection - just verify document exists
|
|
98
|
+
const checkQuery = `SELECT id FROM "${tableName}" WHERE id = $1 LIMIT 1`;
|
|
99
|
+
const checkResult = await db.query(checkQuery, [String(id)]);
|
|
100
|
+
if (!checkResult.rows[0]) {
|
|
101
|
+
throw new Error(`Document with id ${id} not found`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Merge existing JSON with updates (only if we have JSON fields)
|
|
105
|
+
let mergedJson = {};
|
|
106
|
+
if (jsonFieldNames.size > 0) {
|
|
107
|
+
mergedJson = { ...existingJson, ...jsonUpdates };
|
|
108
|
+
// Only include _json in UPDATE if there are actual changes or existing JSON to preserve
|
|
109
|
+
if (jsonKeys.length > 0 || Object.keys(existingJson).length > 0) {
|
|
110
|
+
keys.push('_json');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const setClause = keys.map((key, i) => `"${key}" = $${i + 1}`).join(', ');
|
|
114
|
+
const values = keys.map((key) => {
|
|
115
|
+
if (key === '_json') {
|
|
116
|
+
// Serialize merged JSON fields object to JSON string
|
|
117
|
+
return serializeValueForDatabase(mergedJson);
|
|
118
|
+
}
|
|
119
|
+
// Serialize non-primitive values to JSON strings for SQLite compatibility
|
|
120
|
+
return serializeValueForDatabase(data[key]);
|
|
121
|
+
});
|
|
122
|
+
// Ensure id is a string for consistent comparison
|
|
123
|
+
const idString = String(id);
|
|
124
|
+
const query = `UPDATE "${tableName}" SET ${setClause} WHERE id = $${keys.length + 1}`;
|
|
125
|
+
await db.query(query, [...values, idString]);
|
|
126
|
+
// Return updated document (use idString for consistency)
|
|
127
|
+
const updatedDoc = await findByID(config, db, { id: idString });
|
|
128
|
+
if (!updatedDoc) {
|
|
129
|
+
throw new Error(`Document with id ${idString} not found after update`);
|
|
130
|
+
}
|
|
131
|
+
return updatedDoc;
|
|
132
|
+
}
|
|
133
|
+
return { ...data, id };
|
|
134
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Config } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build and validate a RevealUI configuration
|
|
4
|
+
*
|
|
5
|
+
* Generic type T allows accepting both base Config and extended types (like RevealConfig)
|
|
6
|
+
* while preserving the specific type through the return value.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildConfig<T extends Config>(config: T): T;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAG/C;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAyD1D"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ConfigValidationError, validateConfigStructure } from '@revealui/contracts/cms';
|
|
2
|
+
import { deepMerge } from './utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Build and validate a RevealUI configuration
|
|
5
|
+
*
|
|
6
|
+
* Generic type T allows accepting both base Config and extended types (like RevealConfig)
|
|
7
|
+
* while preserving the specific type through the return value.
|
|
8
|
+
*/
|
|
9
|
+
export function buildConfig(config) {
|
|
10
|
+
// Validate the configuration structure using ConfigContract
|
|
11
|
+
// This provides runtime validation with detailed error messages
|
|
12
|
+
const validationResult = validateConfigStructure(config);
|
|
13
|
+
if (!validationResult.success) {
|
|
14
|
+
// Use ConfigValidationError for structured error reporting
|
|
15
|
+
throw new ConfigValidationError(validationResult.errors, 'config');
|
|
16
|
+
}
|
|
17
|
+
// Type narrowing: after validation, we know the structure is valid
|
|
18
|
+
// The validated config structure matches ConfigContractType
|
|
19
|
+
const validatedConfig = validationResult.data;
|
|
20
|
+
// Apply default values
|
|
21
|
+
// Use validatedConfig as base to ensure type safety
|
|
22
|
+
const defaultConfig = {
|
|
23
|
+
serverURL: process.env.REVEALUI_PUBLIC_SERVER_URL || '',
|
|
24
|
+
admin: {
|
|
25
|
+
importMap: {
|
|
26
|
+
autoGenerate: true,
|
|
27
|
+
},
|
|
28
|
+
...validatedConfig.admin,
|
|
29
|
+
},
|
|
30
|
+
typescript: {
|
|
31
|
+
autoGenerate: true,
|
|
32
|
+
outputFile: 'src/types/revealui.ts',
|
|
33
|
+
...validatedConfig.typescript,
|
|
34
|
+
},
|
|
35
|
+
localization: {
|
|
36
|
+
locales: ['en'],
|
|
37
|
+
defaultLocale: 'en',
|
|
38
|
+
fallback: true,
|
|
39
|
+
...(typeof validatedConfig.localization === 'object' ? validatedConfig.localization : {}),
|
|
40
|
+
},
|
|
41
|
+
collections: validatedConfig.collections || [],
|
|
42
|
+
globals: validatedConfig.globals || [],
|
|
43
|
+
plugins: validatedConfig.plugins || [],
|
|
44
|
+
};
|
|
45
|
+
// Merge with user config (use original config to preserve function contracts)
|
|
46
|
+
const finalConfig = deepMerge(defaultConfig, config);
|
|
47
|
+
// Apply plugins
|
|
48
|
+
if (Array.isArray(finalConfig.plugins)) {
|
|
49
|
+
for (const plugin of finalConfig.plugins) {
|
|
50
|
+
if (typeof plugin === 'function') {
|
|
51
|
+
const pluginFn = plugin;
|
|
52
|
+
const result = pluginFn(finalConfig);
|
|
53
|
+
if (result && typeof result.then === 'function') {
|
|
54
|
+
throw new Error('Async plugins are not supported in buildConfig.');
|
|
55
|
+
}
|
|
56
|
+
Object.assign(finalConfig, result);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return finalConfig;
|
|
61
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Config as ContractsConfig } from '@revealui/contracts/cms';
|
|
2
|
+
import type { RevealConfig, RevealUIInstance } from '../types/index.js';
|
|
3
|
+
/** Accepted config types for getRevealUI */
|
|
4
|
+
type AcceptedConfig = RevealConfig | ContractsConfig | Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Creates or returns a cached RevealUI instance
|
|
7
|
+
*
|
|
8
|
+
* @param options.config - RevealUI configuration object. Accepts:
|
|
9
|
+
* - `RevealConfig`: Framework configuration type (preferred for type safety)
|
|
10
|
+
* - `Config` from @revealui/contracts/cms: CMS configuration from buildConfig()
|
|
11
|
+
* - `Record<string, unknown>`: Loose typing for flexibility
|
|
12
|
+
*
|
|
13
|
+
* Note: Generated Config types have a different structure (collections as record vs array)
|
|
14
|
+
* but are runtime-compatible. The function accepts both for convenience.
|
|
15
|
+
*
|
|
16
|
+
* @returns A RevealUI instance that provides CMS functionality
|
|
17
|
+
*/
|
|
18
|
+
export declare function getRevealUI(options: {
|
|
19
|
+
config: AcceptedConfig;
|
|
20
|
+
}): Promise<RevealUIInstance>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/config/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEvE,4CAA4C;AAC5C,KAAK,cAAc,GAAG,YAAY,GAAG,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAK9E;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,cAAc,CAAA;CAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoBhG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
let revealInstance = null;
|
|
2
|
+
let configInstance = null;
|
|
3
|
+
/**
|
|
4
|
+
* Creates or returns a cached RevealUI instance
|
|
5
|
+
*
|
|
6
|
+
* @param options.config - RevealUI configuration object. Accepts:
|
|
7
|
+
* - `RevealConfig`: Framework configuration type (preferred for type safety)
|
|
8
|
+
* - `Config` from @revealui/contracts/cms: CMS configuration from buildConfig()
|
|
9
|
+
* - `Record<string, unknown>`: Loose typing for flexibility
|
|
10
|
+
*
|
|
11
|
+
* Note: Generated Config types have a different structure (collections as record vs array)
|
|
12
|
+
* but are runtime-compatible. The function accepts both for convenience.
|
|
13
|
+
*
|
|
14
|
+
* @returns A RevealUI instance that provides CMS functionality
|
|
15
|
+
*/
|
|
16
|
+
export async function getRevealUI(options) {
|
|
17
|
+
// In development, always create a new instance to support HMR
|
|
18
|
+
if (process.env.NODE_ENV === 'development') {
|
|
19
|
+
revealInstance = null;
|
|
20
|
+
configInstance = null;
|
|
21
|
+
}
|
|
22
|
+
if (revealInstance && configInstance === options.config) {
|
|
23
|
+
return revealInstance;
|
|
24
|
+
}
|
|
25
|
+
// Import the RevealUI implementation
|
|
26
|
+
const { createRevealUIInstance } = await import('../revealui.js');
|
|
27
|
+
// Type assertion is safe here: generated Config types are runtime-compatible with RevealConfig
|
|
28
|
+
// even though TypeScript sees them as structurally different types
|
|
29
|
+
revealInstance = await createRevealUIInstance(options.config);
|
|
30
|
+
configInstance = options.config;
|
|
31
|
+
return revealInstance;
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function deepMerge<T extends object>(target: Partial<T>, source: T): T;
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated This function is deprecated. Use ConfigContract validation instead.
|
|
4
|
+
* Validation is now handled by the contract system in @revealui/contracts/cms.
|
|
5
|
+
* This function is kept for backward compatibility but should not be used in new code.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateConfig(config: {
|
|
8
|
+
secret?: string;
|
|
9
|
+
collections?: unknown[];
|
|
10
|
+
globals?: unknown[];
|
|
11
|
+
}): void;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/config/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAuB5E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE;IACrC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,OAAO,EAAE,CAAA;IACvB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAA;CACpB,GAAG,IAAI,CAQP"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export function deepMerge(target, source) {
|
|
2
|
+
const result = { ...target };
|
|
3
|
+
for (const key of Object.keys(source)) {
|
|
4
|
+
const s = source[key];
|
|
5
|
+
const t = target[key];
|
|
6
|
+
if (Array.isArray(s)) {
|
|
7
|
+
result[key] = s;
|
|
8
|
+
}
|
|
9
|
+
else if (s !== null &&
|
|
10
|
+
typeof s === 'object' &&
|
|
11
|
+
t !== null &&
|
|
12
|
+
typeof t === 'object' &&
|
|
13
|
+
!Array.isArray(t)) {
|
|
14
|
+
result[key] = deepMerge(t, s);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
result[key] = s;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated This function is deprecated. Use ConfigContract validation instead.
|
|
24
|
+
* Validation is now handled by the contract system in @revealui/contracts/cms.
|
|
25
|
+
* This function is kept for backward compatibility but should not be used in new code.
|
|
26
|
+
*/
|
|
27
|
+
export function validateConfig(config) {
|
|
28
|
+
if (!config.secret) {
|
|
29
|
+
throw new Error('RevealUI config requires a secret');
|
|
30
|
+
}
|
|
31
|
+
if (!(config.collections || config.globals)) {
|
|
32
|
+
throw new Error('RevealUI config must have at least one collection or global');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Re-export database adapters and types (PostgreSQL/PGlite only)
|
|
3
|
+
// Temporarily commented out to get CMS running
|
|
4
|
+
// export type { DatabaseResult } from '../types/index.js'
|
|
5
|
+
// export type { UniversalPostgresAdapterConfig } from './universal-postgres.js'
|
|
6
|
+
// export { universalPostgresAdapter } from './universal-postgres.js'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe row parsing for database results.
|
|
3
|
+
*
|
|
4
|
+
* Database drivers return untyped rows — this module provides a type guard
|
|
5
|
+
* that filters out malformed rows (missing `id`) before they reach the application.
|
|
6
|
+
* All RevealUI tables have `id` as a non-nullable primary key, so filtering these
|
|
7
|
+
* out prevents crashes from unexpected driver behavior or schema migrations.
|
|
8
|
+
*/
|
|
9
|
+
import type { RevealDocument } from '../types/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Validate that a raw database row is a valid RevealDocument.
|
|
12
|
+
*
|
|
13
|
+
* Checks only the structural requirement: the row must be a non-null object
|
|
14
|
+
* with an `id` field of type string or number. All other fields are passed
|
|
15
|
+
* through as-is (trusting the database schema).
|
|
16
|
+
*
|
|
17
|
+
* @param row - Raw value from database driver (unknown type)
|
|
18
|
+
* @returns The row typed as RevealDocument, or null if malformed
|
|
19
|
+
*/
|
|
20
|
+
export declare function safeParseRevealDocument(row: unknown): RevealDocument | null;
|
|
21
|
+
/**
|
|
22
|
+
* Parse an array of raw database rows into RevealDocument[], filtering out
|
|
23
|
+
* any malformed rows and logging warnings for each one skipped.
|
|
24
|
+
*/
|
|
25
|
+
export declare function safeParseRevealDocuments(rows: unknown[]): RevealDocument[];
|
|
26
|
+
//# sourceMappingURL=safe-parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-parse.d.ts","sourceRoot":"","sources":["../../src/database/safe-parse.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAgB3E;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAI1E"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe row parsing for database results.
|
|
3
|
+
*
|
|
4
|
+
* Database drivers return untyped rows — this module provides a type guard
|
|
5
|
+
* that filters out malformed rows (missing `id`) before they reach the application.
|
|
6
|
+
* All RevealUI tables have `id` as a non-nullable primary key, so filtering these
|
|
7
|
+
* out prevents crashes from unexpected driver behavior or schema migrations.
|
|
8
|
+
*/
|
|
9
|
+
import { defaultLogger } from '../instance/logger.js';
|
|
10
|
+
/**
|
|
11
|
+
* Validate that a raw database row is a valid RevealDocument.
|
|
12
|
+
*
|
|
13
|
+
* Checks only the structural requirement: the row must be a non-null object
|
|
14
|
+
* with an `id` field of type string or number. All other fields are passed
|
|
15
|
+
* through as-is (trusting the database schema).
|
|
16
|
+
*
|
|
17
|
+
* @param row - Raw value from database driver (unknown type)
|
|
18
|
+
* @returns The row typed as RevealDocument, or null if malformed
|
|
19
|
+
*/
|
|
20
|
+
export function safeParseRevealDocument(row) {
|
|
21
|
+
if (row === null || typeof row !== 'object') {
|
|
22
|
+
defaultLogger.warn('Database row is not an object — skipping', { row });
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const r = row;
|
|
26
|
+
if (typeof r.id !== 'string' && typeof r.id !== 'number') {
|
|
27
|
+
defaultLogger.warn('Database row missing required id field — skipping', {
|
|
28
|
+
keys: Object.keys(r),
|
|
29
|
+
});
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return r;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parse an array of raw database rows into RevealDocument[], filtering out
|
|
36
|
+
* any malformed rows and logging warnings for each one skipped.
|
|
37
|
+
*/
|
|
38
|
+
export function safeParseRevealDocuments(rows) {
|
|
39
|
+
return rows
|
|
40
|
+
.map((row) => safeParseRevealDocument(row))
|
|
41
|
+
.filter((doc) => doc !== null);
|
|
42
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSL Configuration Utility
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from @revealui/utils to maintain backward compatibility.
|
|
5
|
+
* The actual implementation has been moved to @revealui/utils to break circular dependencies.
|
|
6
|
+
*/
|
|
7
|
+
export type { SSLConfig } from '@revealui/utils/database';
|
|
8
|
+
export { getSSLConfig, validateSSLConfig } from '@revealui/utils/database';
|
|
9
|
+
//# sourceMappingURL=ssl-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssl-config.d.ts","sourceRoot":"","sources":["../../src/database/ssl-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSL Configuration Utility
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from @revealui/utils to maintain backward compatibility.
|
|
5
|
+
* The actual implementation has been moved to @revealui/utils to break circular dependencies.
|
|
6
|
+
*/
|
|
7
|
+
export { getSSLConfig, validateSSLConfig } from '@revealui/utils/database';
|