@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,542 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Circuit Breaker Pattern
|
|
3
|
+
*
|
|
4
|
+
* Prevents cascading failures by stopping requests to failing services
|
|
5
|
+
*/
|
|
6
|
+
import { logger } from '../observability/logger.js';
|
|
7
|
+
const DEFAULT_CONFIG = {
|
|
8
|
+
failureThreshold: 5,
|
|
9
|
+
successThreshold: 2,
|
|
10
|
+
timeout: 60000,
|
|
11
|
+
resetTimeout: 30000,
|
|
12
|
+
volumeThreshold: 10,
|
|
13
|
+
errorFilter: () => true,
|
|
14
|
+
onStateChange: () => { },
|
|
15
|
+
onTrip: () => { },
|
|
16
|
+
onReset: () => { },
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Circuit Breaker implementation
|
|
20
|
+
*/
|
|
21
|
+
export class CircuitBreaker {
|
|
22
|
+
state = 'closed';
|
|
23
|
+
failures = 0;
|
|
24
|
+
successes = 0;
|
|
25
|
+
consecutiveFailures = 0;
|
|
26
|
+
consecutiveSuccesses = 0;
|
|
27
|
+
totalCalls = 0;
|
|
28
|
+
totalFailures = 0;
|
|
29
|
+
totalSuccesses = 0;
|
|
30
|
+
lastFailureTime;
|
|
31
|
+
lastSuccessTime;
|
|
32
|
+
stateChangedAt = Date.now();
|
|
33
|
+
resetTimer;
|
|
34
|
+
config;
|
|
35
|
+
constructor(config = {}) {
|
|
36
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Execute function with circuit breaker
|
|
40
|
+
*/
|
|
41
|
+
async execute(fn) {
|
|
42
|
+
// Check if circuit is open
|
|
43
|
+
if (this.state === 'open') {
|
|
44
|
+
// Check if reset timeout has passed
|
|
45
|
+
if (Date.now() - this.stateChangedAt >= this.config.resetTimeout) {
|
|
46
|
+
this.transitionTo('half-open');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw new CircuitBreakerOpenError('Circuit breaker is open');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
this.totalCalls++;
|
|
53
|
+
try {
|
|
54
|
+
const result = await fn();
|
|
55
|
+
this.onSuccess();
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
60
|
+
this.onFailure(err);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Handle successful execution
|
|
66
|
+
*/
|
|
67
|
+
onSuccess() {
|
|
68
|
+
this.successes++;
|
|
69
|
+
this.consecutiveSuccesses++;
|
|
70
|
+
this.totalSuccesses++;
|
|
71
|
+
this.consecutiveFailures = 0;
|
|
72
|
+
this.lastSuccessTime = Date.now();
|
|
73
|
+
if (this.state === 'half-open') {
|
|
74
|
+
// Check if we can close the circuit
|
|
75
|
+
if (this.consecutiveSuccesses >= this.config.successThreshold) {
|
|
76
|
+
this.transitionTo('closed');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Reset failure count in closed state
|
|
80
|
+
if (this.state === 'closed') {
|
|
81
|
+
this.failures = 0;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Handle failed execution
|
|
86
|
+
*/
|
|
87
|
+
onFailure(error) {
|
|
88
|
+
// Check if error should count
|
|
89
|
+
if (!this.config.errorFilter(error)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.failures++;
|
|
93
|
+
this.consecutiveFailures++;
|
|
94
|
+
this.totalFailures++;
|
|
95
|
+
this.consecutiveSuccesses = 0;
|
|
96
|
+
this.lastFailureTime = Date.now();
|
|
97
|
+
if (this.state === 'half-open') {
|
|
98
|
+
// Immediately open circuit on failure in half-open state
|
|
99
|
+
this.transitionTo('open');
|
|
100
|
+
}
|
|
101
|
+
else if (this.state === 'closed') {
|
|
102
|
+
// Check if we should open the circuit
|
|
103
|
+
if (this.consecutiveFailures >= this.config.failureThreshold &&
|
|
104
|
+
this.totalCalls >= this.config.volumeThreshold) {
|
|
105
|
+
this.transitionTo('open');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Transition to new state
|
|
111
|
+
*/
|
|
112
|
+
transitionTo(newState) {
|
|
113
|
+
if (this.state === newState)
|
|
114
|
+
return;
|
|
115
|
+
const oldState = this.state;
|
|
116
|
+
this.state = newState;
|
|
117
|
+
this.stateChangedAt = Date.now();
|
|
118
|
+
// Reset counters
|
|
119
|
+
if (newState === 'half-open' || newState === 'closed') {
|
|
120
|
+
this.consecutiveFailures = 0;
|
|
121
|
+
this.consecutiveSuccesses = 0;
|
|
122
|
+
}
|
|
123
|
+
// Clear reset timer
|
|
124
|
+
if (this.resetTimer) {
|
|
125
|
+
clearTimeout(this.resetTimer);
|
|
126
|
+
this.resetTimer = undefined;
|
|
127
|
+
}
|
|
128
|
+
// Set reset timer for open state
|
|
129
|
+
if (newState === 'open') {
|
|
130
|
+
this.resetTimer = setTimeout(() => {
|
|
131
|
+
this.transitionTo('half-open');
|
|
132
|
+
}, this.config.resetTimeout);
|
|
133
|
+
this.config.onTrip();
|
|
134
|
+
}
|
|
135
|
+
// Circuit reset
|
|
136
|
+
if (newState === 'closed' && oldState === 'half-open') {
|
|
137
|
+
this.failures = 0;
|
|
138
|
+
this.config.onReset();
|
|
139
|
+
}
|
|
140
|
+
this.config.onStateChange(newState);
|
|
141
|
+
logger.info(`Circuit breaker state changed: ${oldState} -> ${newState}`, this.getStats());
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get current state
|
|
145
|
+
*/
|
|
146
|
+
getState() {
|
|
147
|
+
return this.state;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get statistics
|
|
151
|
+
*/
|
|
152
|
+
getStats() {
|
|
153
|
+
return {
|
|
154
|
+
state: this.state,
|
|
155
|
+
failures: this.failures,
|
|
156
|
+
successes: this.successes,
|
|
157
|
+
consecutiveFailures: this.consecutiveFailures,
|
|
158
|
+
consecutiveSuccesses: this.consecutiveSuccesses,
|
|
159
|
+
totalCalls: this.totalCalls,
|
|
160
|
+
totalFailures: this.totalFailures,
|
|
161
|
+
totalSuccesses: this.totalSuccesses,
|
|
162
|
+
lastFailureTime: this.lastFailureTime,
|
|
163
|
+
lastSuccessTime: this.lastSuccessTime,
|
|
164
|
+
stateChangedAt: this.stateChangedAt,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Manually open circuit
|
|
169
|
+
*/
|
|
170
|
+
trip() {
|
|
171
|
+
this.transitionTo('open');
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Manually close circuit
|
|
175
|
+
*/
|
|
176
|
+
reset() {
|
|
177
|
+
this.failures = 0;
|
|
178
|
+
this.successes = 0;
|
|
179
|
+
this.consecutiveFailures = 0;
|
|
180
|
+
this.consecutiveSuccesses = 0;
|
|
181
|
+
this.transitionTo('closed');
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Force state to half-open
|
|
185
|
+
*/
|
|
186
|
+
halfOpen() {
|
|
187
|
+
this.transitionTo('half-open');
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Check if circuit is open
|
|
191
|
+
*/
|
|
192
|
+
isOpen() {
|
|
193
|
+
return this.state === 'open';
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Check if circuit is closed
|
|
197
|
+
*/
|
|
198
|
+
isClosed() {
|
|
199
|
+
return this.state === 'closed';
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Check if circuit is half-open
|
|
203
|
+
*/
|
|
204
|
+
isHalfOpen() {
|
|
205
|
+
return this.state === 'half-open';
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Get failure rate
|
|
209
|
+
*/
|
|
210
|
+
getFailureRate() {
|
|
211
|
+
if (this.totalCalls === 0)
|
|
212
|
+
return 0;
|
|
213
|
+
return this.totalFailures / this.totalCalls;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Get success rate
|
|
217
|
+
*/
|
|
218
|
+
getSuccessRate() {
|
|
219
|
+
if (this.totalCalls === 0)
|
|
220
|
+
return 0;
|
|
221
|
+
return this.totalSuccesses / this.totalCalls;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Cleanup
|
|
225
|
+
*/
|
|
226
|
+
destroy() {
|
|
227
|
+
if (this.resetTimer) {
|
|
228
|
+
clearTimeout(this.resetTimer);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Circuit breaker open error
|
|
234
|
+
*/
|
|
235
|
+
export class CircuitBreakerOpenError extends Error {
|
|
236
|
+
constructor(message = 'Circuit breaker is open') {
|
|
237
|
+
super(message);
|
|
238
|
+
this.name = 'CircuitBreakerOpenError';
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Circuit breaker registry
|
|
243
|
+
*/
|
|
244
|
+
export class CircuitBreakerRegistry {
|
|
245
|
+
breakers = new Map();
|
|
246
|
+
/**
|
|
247
|
+
* Get or create circuit breaker
|
|
248
|
+
*/
|
|
249
|
+
get(name, config) {
|
|
250
|
+
let breaker = this.breakers.get(name);
|
|
251
|
+
if (!breaker) {
|
|
252
|
+
breaker = new CircuitBreaker(config);
|
|
253
|
+
this.breakers.set(name, breaker);
|
|
254
|
+
}
|
|
255
|
+
return breaker;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Check if breaker exists
|
|
259
|
+
*/
|
|
260
|
+
has(name) {
|
|
261
|
+
return this.breakers.has(name);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Remove circuit breaker
|
|
265
|
+
*/
|
|
266
|
+
remove(name) {
|
|
267
|
+
const breaker = this.breakers.get(name);
|
|
268
|
+
if (breaker) {
|
|
269
|
+
breaker.destroy();
|
|
270
|
+
return this.breakers.delete(name);
|
|
271
|
+
}
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Get all breakers
|
|
276
|
+
*/
|
|
277
|
+
getAll() {
|
|
278
|
+
return new Map(this.breakers);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Get all statistics
|
|
282
|
+
*/
|
|
283
|
+
getAllStats() {
|
|
284
|
+
const stats = {};
|
|
285
|
+
for (const [name, breaker] of this.breakers) {
|
|
286
|
+
stats[name] = breaker.getStats();
|
|
287
|
+
}
|
|
288
|
+
return stats;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Reset all breakers
|
|
292
|
+
*/
|
|
293
|
+
resetAll() {
|
|
294
|
+
for (const breaker of this.breakers.values()) {
|
|
295
|
+
breaker.reset();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Clear all breakers
|
|
300
|
+
*/
|
|
301
|
+
clear() {
|
|
302
|
+
for (const breaker of this.breakers.values()) {
|
|
303
|
+
breaker.destroy();
|
|
304
|
+
}
|
|
305
|
+
this.breakers.clear();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Global circuit breaker registry
|
|
310
|
+
*/
|
|
311
|
+
export const circuitBreakerRegistry = new CircuitBreakerRegistry();
|
|
312
|
+
/**
|
|
313
|
+
* Create circuit breaker decorator
|
|
314
|
+
*/
|
|
315
|
+
export function CircuitBreak(nameOrConfig = {}) {
|
|
316
|
+
return (target, propertyKey, descriptor) => {
|
|
317
|
+
const originalMethod = descriptor.value;
|
|
318
|
+
const name = typeof nameOrConfig === 'string'
|
|
319
|
+
? nameOrConfig
|
|
320
|
+
: `${target.constructor.name}.${propertyKey}`;
|
|
321
|
+
const config = typeof nameOrConfig === 'object' ? nameOrConfig : undefined;
|
|
322
|
+
descriptor.value = async function (...args) {
|
|
323
|
+
const breaker = circuitBreakerRegistry.get(name, config);
|
|
324
|
+
return breaker.execute(() => originalMethod.apply(this, args));
|
|
325
|
+
};
|
|
326
|
+
return descriptor;
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Execute with circuit breaker
|
|
331
|
+
*/
|
|
332
|
+
export async function withCircuitBreaker(name, fn, config) {
|
|
333
|
+
const breaker = circuitBreakerRegistry.get(name, config);
|
|
334
|
+
return breaker.execute(fn);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Create circuit breaker middleware
|
|
338
|
+
*/
|
|
339
|
+
export function createCircuitBreakerMiddleware(name, config) {
|
|
340
|
+
const breaker = circuitBreakerRegistry.get(name, config);
|
|
341
|
+
return async (_request, next) => {
|
|
342
|
+
return breaker.execute(next);
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Circuit breaker for fetch
|
|
347
|
+
*/
|
|
348
|
+
export async function fetchWithCircuitBreaker(name, url, init, config) {
|
|
349
|
+
const breaker = circuitBreakerRegistry.get(name, config);
|
|
350
|
+
return breaker.execute(async () => {
|
|
351
|
+
const response = await fetch(url, init);
|
|
352
|
+
// Treat 5xx errors as failures
|
|
353
|
+
if (response.status >= 500) {
|
|
354
|
+
const error = new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
355
|
+
error.statusCode = response.status;
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
358
|
+
return response;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Adaptive circuit breaker with dynamic thresholds
|
|
363
|
+
*/
|
|
364
|
+
export class AdaptiveCircuitBreaker extends CircuitBreaker {
|
|
365
|
+
errorRateWindow = [];
|
|
366
|
+
windowSize = 100;
|
|
367
|
+
adaptiveThreshold;
|
|
368
|
+
constructor(config = {}) {
|
|
369
|
+
super(config);
|
|
370
|
+
this.adaptiveThreshold = config.failureThreshold || 5;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Execute with adaptive thresholds
|
|
374
|
+
*/
|
|
375
|
+
async execute(fn) {
|
|
376
|
+
try {
|
|
377
|
+
const result = await super.execute(fn);
|
|
378
|
+
this.recordSuccess();
|
|
379
|
+
return result;
|
|
380
|
+
}
|
|
381
|
+
catch (error) {
|
|
382
|
+
this.recordFailure();
|
|
383
|
+
throw error;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Record success in window
|
|
388
|
+
*/
|
|
389
|
+
recordSuccess() {
|
|
390
|
+
this.errorRateWindow.push(0);
|
|
391
|
+
this.trimWindow();
|
|
392
|
+
this.adjustThreshold();
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Record failure in window
|
|
396
|
+
*/
|
|
397
|
+
recordFailure() {
|
|
398
|
+
this.errorRateWindow.push(1);
|
|
399
|
+
this.trimWindow();
|
|
400
|
+
this.adjustThreshold();
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Trim window to size
|
|
404
|
+
*/
|
|
405
|
+
trimWindow() {
|
|
406
|
+
if (this.errorRateWindow.length > this.windowSize) {
|
|
407
|
+
this.errorRateWindow.shift();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Adjust threshold based on error rate
|
|
412
|
+
*/
|
|
413
|
+
adjustThreshold() {
|
|
414
|
+
const errorRate = this.getWindowErrorRate();
|
|
415
|
+
// Increase threshold if error rate is low
|
|
416
|
+
if (errorRate < 0.1) {
|
|
417
|
+
this.adaptiveThreshold = Math.min(this.adaptiveThreshold + 1, 20);
|
|
418
|
+
}
|
|
419
|
+
// Decrease threshold if error rate is high
|
|
420
|
+
else if (errorRate > 0.5) {
|
|
421
|
+
this.adaptiveThreshold = Math.max(this.adaptiveThreshold - 1, 2);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Get error rate in window
|
|
426
|
+
*/
|
|
427
|
+
getWindowErrorRate() {
|
|
428
|
+
if (this.errorRateWindow.length === 0)
|
|
429
|
+
return 0;
|
|
430
|
+
const errors = this.errorRateWindow.reduce((sum, val) => sum + val, 0);
|
|
431
|
+
return errors / this.errorRateWindow.length;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Get adaptive threshold
|
|
435
|
+
*/
|
|
436
|
+
getAdaptiveThreshold() {
|
|
437
|
+
return this.adaptiveThreshold;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Bulkhead pattern - limit concurrent executions
|
|
442
|
+
*/
|
|
443
|
+
export class Bulkhead {
|
|
444
|
+
activeRequests = 0;
|
|
445
|
+
queue = [];
|
|
446
|
+
maxConcurrent;
|
|
447
|
+
maxQueue;
|
|
448
|
+
constructor(maxConcurrent = 10, maxQueue = 100) {
|
|
449
|
+
this.maxConcurrent = maxConcurrent;
|
|
450
|
+
this.maxQueue = maxQueue;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Execute with bulkhead
|
|
454
|
+
*/
|
|
455
|
+
async execute(fn) {
|
|
456
|
+
// Check if at capacity
|
|
457
|
+
if (this.activeRequests >= this.maxConcurrent) {
|
|
458
|
+
// Check queue capacity
|
|
459
|
+
if (this.queue.length >= this.maxQueue) {
|
|
460
|
+
throw new Error('Bulkhead queue is full');
|
|
461
|
+
}
|
|
462
|
+
// Wait for slot
|
|
463
|
+
await new Promise((resolve) => {
|
|
464
|
+
this.queue.push(resolve);
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
this.activeRequests++;
|
|
468
|
+
try {
|
|
469
|
+
return await fn();
|
|
470
|
+
}
|
|
471
|
+
finally {
|
|
472
|
+
this.activeRequests--;
|
|
473
|
+
// Process queue
|
|
474
|
+
const next = this.queue.shift();
|
|
475
|
+
if (next) {
|
|
476
|
+
next();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Get active requests
|
|
482
|
+
*/
|
|
483
|
+
getActiveRequests() {
|
|
484
|
+
return this.activeRequests;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Get queue size
|
|
488
|
+
*/
|
|
489
|
+
getQueueSize() {
|
|
490
|
+
return this.queue.length;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Get statistics
|
|
494
|
+
*/
|
|
495
|
+
getStats() {
|
|
496
|
+
return {
|
|
497
|
+
activeRequests: this.activeRequests,
|
|
498
|
+
queueSize: this.queue.length,
|
|
499
|
+
maxConcurrent: this.maxConcurrent,
|
|
500
|
+
maxQueue: this.maxQueue,
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Combined resilience wrapper
|
|
506
|
+
*/
|
|
507
|
+
export class ResilientOperation {
|
|
508
|
+
fn;
|
|
509
|
+
circuitBreaker;
|
|
510
|
+
bulkhead;
|
|
511
|
+
constructor(fn, circuitBreaker, bulkhead) {
|
|
512
|
+
this.fn = fn;
|
|
513
|
+
this.circuitBreaker = circuitBreaker;
|
|
514
|
+
this.bulkhead = bulkhead;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Execute with all resilience patterns
|
|
518
|
+
*/
|
|
519
|
+
async execute() {
|
|
520
|
+
const executeFn = async () => {
|
|
521
|
+
if (this.bulkhead) {
|
|
522
|
+
return this.bulkhead.execute(this.fn);
|
|
523
|
+
}
|
|
524
|
+
return this.fn();
|
|
525
|
+
};
|
|
526
|
+
if (this.circuitBreaker) {
|
|
527
|
+
return this.circuitBreaker.execute(executeFn);
|
|
528
|
+
}
|
|
529
|
+
return executeFn();
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Create resilient function
|
|
534
|
+
*/
|
|
535
|
+
export function createResilientFunction(fn, options = {}) {
|
|
536
|
+
const breaker = options.circuitBreaker ? new CircuitBreaker(options.circuitBreaker) : undefined;
|
|
537
|
+
const bulkhead = options.bulkhead
|
|
538
|
+
? new Bulkhead(options.bulkhead.maxConcurrent, options.bulkhead.maxQueue)
|
|
539
|
+
: undefined;
|
|
540
|
+
const operation = new ResilientOperation(fn, breaker, bulkhead);
|
|
541
|
+
return () => operation.execute();
|
|
542
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Error Boundary Components
|
|
3
|
+
*
|
|
4
|
+
* Catch and handle React component errors gracefully
|
|
5
|
+
*/
|
|
6
|
+
import React, { Component, type ReactNode } from 'react';
|
|
7
|
+
export interface ErrorInfo {
|
|
8
|
+
componentStack: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ErrorBoundaryProps {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
fallback?: ReactNode | ((error: Error, errorInfo?: ErrorInfo) => ReactNode);
|
|
13
|
+
onError?: (error: Error, errorInfo?: ErrorInfo) => void;
|
|
14
|
+
onReset?: () => void;
|
|
15
|
+
resetKeys?: unknown[];
|
|
16
|
+
isolate?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ErrorBoundaryState {
|
|
19
|
+
hasError: boolean;
|
|
20
|
+
error: Error | null;
|
|
21
|
+
errorInfo: ErrorInfo | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Error Boundary Component
|
|
25
|
+
*/
|
|
26
|
+
export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
27
|
+
constructor(props: ErrorBoundaryProps);
|
|
28
|
+
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
|
|
29
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
30
|
+
componentDidUpdate(prevProps: ErrorBoundaryProps): void;
|
|
31
|
+
reset: () => void;
|
|
32
|
+
render(): ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Error Boundary with retry
|
|
36
|
+
*/
|
|
37
|
+
export interface ErrorBoundaryWithRetryProps extends ErrorBoundaryProps {
|
|
38
|
+
maxRetries?: number;
|
|
39
|
+
retryDelay?: number;
|
|
40
|
+
}
|
|
41
|
+
export declare class ErrorBoundaryWithRetry extends Component<ErrorBoundaryWithRetryProps, ErrorBoundaryState & {
|
|
42
|
+
retryCount: number;
|
|
43
|
+
}> {
|
|
44
|
+
private retryTimeout?;
|
|
45
|
+
constructor(props: ErrorBoundaryWithRetryProps);
|
|
46
|
+
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
|
|
47
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
48
|
+
componentWillUnmount(): void;
|
|
49
|
+
reset: () => void;
|
|
50
|
+
render(): ReactNode;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* withErrorBoundary HOC
|
|
54
|
+
*/
|
|
55
|
+
export declare function withErrorBoundary<P extends object>(Component: React.ComponentType<P>, errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>): React.ComponentType<P>;
|
|
56
|
+
/**
|
|
57
|
+
* useErrorHandler hook
|
|
58
|
+
*/
|
|
59
|
+
export declare function useErrorHandler(error?: Error | null): (error: Error) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Error types
|
|
62
|
+
*/
|
|
63
|
+
export declare class NetworkError extends Error {
|
|
64
|
+
statusCode?: number | undefined;
|
|
65
|
+
constructor(message: string, statusCode?: number | undefined);
|
|
66
|
+
}
|
|
67
|
+
export declare class ValidationError extends Error {
|
|
68
|
+
fields?: Record<string, string> | undefined;
|
|
69
|
+
constructor(message: string, fields?: Record<string, string> | undefined);
|
|
70
|
+
}
|
|
71
|
+
export declare class AuthenticationError extends Error {
|
|
72
|
+
constructor(message: string);
|
|
73
|
+
}
|
|
74
|
+
export declare class NotFoundError extends Error {
|
|
75
|
+
resource?: string | undefined;
|
|
76
|
+
constructor(message: string, resource?: string | undefined);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Error classification
|
|
80
|
+
*/
|
|
81
|
+
export declare function isNetworkError(error: unknown): error is NetworkError;
|
|
82
|
+
export declare function isValidationError(error: unknown): error is ValidationError;
|
|
83
|
+
export declare function isAuthenticationError(error: unknown): error is AuthenticationError;
|
|
84
|
+
export declare function isNotFoundError(error: unknown): error is NotFoundError;
|
|
85
|
+
/**
|
|
86
|
+
* Error severity
|
|
87
|
+
*/
|
|
88
|
+
export type ErrorSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
89
|
+
export declare function getErrorSeverity(error: Error): ErrorSeverity;
|
|
90
|
+
/**
|
|
91
|
+
* Should retry error
|
|
92
|
+
*/
|
|
93
|
+
export declare function shouldRetryError(error: Error): boolean;
|
|
94
|
+
//# sourceMappingURL=error-boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../src/error-handling/error-boundary.tsx"],"names":[],"mappings":"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"}
|