@pyric/ui 0.1.0-alpha.7
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/README.md +79 -0
- package/dist/agents/ContextWindowUsage.d.ts +67 -0
- package/dist/agents/ContextWindowUsage.d.ts.map +1 -0
- package/dist/agents/ContextWindowUsage.js +115 -0
- package/dist/agents/ContextWindowUsage.js.map +1 -0
- package/dist/agents/EmptyState.d.ts +18 -0
- package/dist/agents/EmptyState.d.ts.map +1 -0
- package/dist/agents/EmptyState.js +11 -0
- package/dist/agents/EmptyState.js.map +1 -0
- package/dist/agents/Fold.d.ts +37 -0
- package/dist/agents/Fold.d.ts.map +1 -0
- package/dist/agents/Fold.js +18 -0
- package/dist/agents/Fold.js.map +1 -0
- package/dist/agents/Modal.d.ts +25 -0
- package/dist/agents/Modal.d.ts.map +1 -0
- package/dist/agents/Modal.js +28 -0
- package/dist/agents/Modal.js.map +1 -0
- package/dist/agents/PulsingDot.d.ts +21 -0
- package/dist/agents/PulsingDot.d.ts.map +1 -0
- package/dist/agents/PulsingDot.js +18 -0
- package/dist/agents/PulsingDot.js.map +1 -0
- package/dist/agents/index.d.ts +15 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +15 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/auth/authApi.d.ts +32 -0
- package/dist/auth/authApi.d.ts.map +1 -0
- package/dist/auth/authApi.js +27 -0
- package/dist/auth/authApi.js.map +1 -0
- package/dist/auth/claims.d.ts +27 -0
- package/dist/auth/claims.d.ts.map +1 -0
- package/dist/auth/claims.js +58 -0
- package/dist/auth/claims.js.map +1 -0
- package/dist/auth/components/AuthProviderToggles.d.ts +31 -0
- package/dist/auth/components/AuthProviderToggles.d.ts.map +1 -0
- package/dist/auth/components/AuthProviderToggles.js +48 -0
- package/dist/auth/components/AuthProviderToggles.js.map +1 -0
- package/dist/auth/components/AuthSignInHelper.d.ts +57 -0
- package/dist/auth/components/AuthSignInHelper.d.ts.map +1 -0
- package/dist/auth/components/AuthSignInHelper.js +69 -0
- package/dist/auth/components/AuthSignInHelper.js.map +1 -0
- package/dist/auth/components/AuthUserForm.d.ts +84 -0
- package/dist/auth/components/AuthUserForm.d.ts.map +1 -0
- package/dist/auth/components/AuthUserForm.js +89 -0
- package/dist/auth/components/AuthUserForm.js.map +1 -0
- package/dist/auth/components/AuthUserList.d.ts +51 -0
- package/dist/auth/components/AuthUserList.d.ts.map +1 -0
- package/dist/auth/components/AuthUserList.js +46 -0
- package/dist/auth/components/AuthUserList.js.map +1 -0
- package/dist/auth/components/ClaimsField.d.ts +22 -0
- package/dist/auth/components/ClaimsField.d.ts.map +1 -0
- package/dist/auth/components/ClaimsField.js +11 -0
- package/dist/auth/components/ClaimsField.js.map +1 -0
- package/dist/auth/components/confirmActions.d.ts +40 -0
- package/dist/auth/components/confirmActions.d.ts.map +1 -0
- package/dist/auth/components/confirmActions.js +49 -0
- package/dist/auth/components/confirmActions.js.map +1 -0
- package/dist/auth/controller.d.ts +73 -0
- package/dist/auth/controller.d.ts.map +1 -0
- package/dist/auth/controller.js +139 -0
- package/dist/auth/controller.js.map +1 -0
- package/dist/auth/hooks/index.d.ts +7 -0
- package/dist/auth/hooks/index.d.ts.map +1 -0
- package/dist/auth/hooks/index.js +7 -0
- package/dist/auth/hooks/index.js.map +1 -0
- package/dist/auth/hooks/useAuthFlowHelper.d.ts +30 -0
- package/dist/auth/hooks/useAuthFlowHelper.d.ts.map +1 -0
- package/dist/auth/hooks/useAuthFlowHelper.js +30 -0
- package/dist/auth/hooks/useAuthFlowHelper.js.map +1 -0
- package/dist/auth/hooks/useAuthProviderConfig.d.ts +37 -0
- package/dist/auth/hooks/useAuthProviderConfig.d.ts.map +1 -0
- package/dist/auth/hooks/useAuthProviderConfig.js +98 -0
- package/dist/auth/hooks/useAuthProviderConfig.js.map +1 -0
- package/dist/auth/hooks/useAuthUserEditor.d.ts +30 -0
- package/dist/auth/hooks/useAuthUserEditor.d.ts.map +1 -0
- package/dist/auth/hooks/useAuthUserEditor.js +27 -0
- package/dist/auth/hooks/useAuthUserEditor.js.map +1 -0
- package/dist/auth/hooks/useAuthUsers.d.ts +38 -0
- package/dist/auth/hooks/useAuthUsers.d.ts.map +1 -0
- package/dist/auth/hooks/useAuthUsers.js +111 -0
- package/dist/auth/hooks/useAuthUsers.js.map +1 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +13 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/providers.d.ts +11 -0
- package/dist/auth/providers.d.ts.map +1 -0
- package/dist/auth/providers.js +28 -0
- package/dist/auth/providers.js.map +1 -0
- package/dist/auth/reducers/userEditor.d.ts +55 -0
- package/dist/auth/reducers/userEditor.d.ts.map +1 -0
- package/dist/auth/reducers/userEditor.js +136 -0
- package/dist/auth/reducers/userEditor.js.map +1 -0
- package/dist/events/components/ActivityActionItems.d.ts +45 -0
- package/dist/events/components/ActivityActionItems.d.ts.map +1 -0
- package/dist/events/components/ActivityActionItems.js +68 -0
- package/dist/events/components/ActivityActionItems.js.map +1 -0
- package/dist/events/components/ActivityGrid.d.ts +65 -0
- package/dist/events/components/ActivityGrid.d.ts.map +1 -0
- package/dist/events/components/ActivityGrid.js +61 -0
- package/dist/events/components/ActivityGrid.js.map +1 -0
- package/dist/events/components/ActivityGridRow.d.ts +31 -0
- package/dist/events/components/ActivityGridRow.d.ts.map +1 -0
- package/dist/events/components/ActivityGridRow.js +23 -0
- package/dist/events/components/ActivityGridRow.js.map +1 -0
- package/dist/events/components/ProposedChangeDiff.d.ts +46 -0
- package/dist/events/components/ProposedChangeDiff.d.ts.map +1 -0
- package/dist/events/components/ProposedChangeDiff.js +60 -0
- package/dist/events/components/ProposedChangeDiff.js.map +1 -0
- package/dist/events/components/format.d.ts +11 -0
- package/dist/events/components/format.d.ts.map +1 -0
- package/dist/events/components/format.js +26 -0
- package/dist/events/components/format.js.map +1 -0
- package/dist/events/components/index.d.ts +6 -0
- package/dist/events/components/index.d.ts.map +1 -0
- package/dist/events/components/index.js +6 -0
- package/dist/events/components/index.js.map +1 -0
- package/dist/events/digest.d.ts +167 -0
- package/dist/events/digest.d.ts.map +1 -0
- package/dist/events/digest.js +426 -0
- package/dist/events/digest.js.map +1 -0
- package/dist/events/hooks/index.d.ts +3 -0
- package/dist/events/hooks/index.d.ts.map +1 -0
- package/dist/events/hooks/index.js +3 -0
- package/dist/events/hooks/index.js.map +1 -0
- package/dist/events/hooks/useActivityDigest.d.ts +27 -0
- package/dist/events/hooks/useActivityDigest.d.ts.map +1 -0
- package/dist/events/hooks/useActivityDigest.js +18 -0
- package/dist/events/hooks/useActivityDigest.js.map +1 -0
- package/dist/events/hooks/useActivityStream.d.ts +44 -0
- package/dist/events/hooks/useActivityStream.d.ts.map +1 -0
- package/dist/events/hooks/useActivityStream.js +38 -0
- package/dist/events/hooks/useActivityStream.js.map +1 -0
- package/dist/events/index.d.ts +15 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +14 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/types.d.ts +160 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +21 -0
- package/dist/events/types.js.map +1 -0
- package/dist/firestore/components/CollectionList.d.ts +22 -0
- package/dist/firestore/components/CollectionList.d.ts.map +1 -0
- package/dist/firestore/components/CollectionList.js +21 -0
- package/dist/firestore/components/CollectionList.js.map +1 -0
- package/dist/firestore/components/DeleteWithConfirm.d.ts +38 -0
- package/dist/firestore/components/DeleteWithConfirm.d.ts.map +1 -0
- package/dist/firestore/components/DeleteWithConfirm.js +33 -0
- package/dist/firestore/components/DeleteWithConfirm.js.map +1 -0
- package/dist/firestore/components/DocumentEditor.d.ts +47 -0
- package/dist/firestore/components/DocumentEditor.d.ts.map +1 -0
- package/dist/firestore/components/DocumentEditor.js +176 -0
- package/dist/firestore/components/DocumentEditor.js.map +1 -0
- package/dist/firestore/components/DocumentList.d.ts +60 -0
- package/dist/firestore/components/DocumentList.d.ts.map +1 -0
- package/dist/firestore/components/DocumentList.js +39 -0
- package/dist/firestore/components/DocumentList.js.map +1 -0
- package/dist/firestore/components/DocumentPreview.d.ts +68 -0
- package/dist/firestore/components/DocumentPreview.d.ts.map +1 -0
- package/dist/firestore/components/DocumentPreview.js +76 -0
- package/dist/firestore/components/DocumentPreview.js.map +1 -0
- package/dist/firestore/components/FieldRenderer.d.ts +17 -0
- package/dist/firestore/components/FieldRenderer.d.ts.map +1 -0
- package/dist/firestore/components/FieldRenderer.js +16 -0
- package/dist/firestore/components/FieldRenderer.js.map +1 -0
- package/dist/firestore/components/QueryBuilder.d.ts +25 -0
- package/dist/firestore/components/QueryBuilder.d.ts.map +1 -0
- package/dist/firestore/components/QueryBuilder.js +78 -0
- package/dist/firestore/components/QueryBuilder.js.map +1 -0
- package/dist/firestore/components/ReferencePicker.d.ts +33 -0
- package/dist/firestore/components/ReferencePicker.d.ts.map +1 -0
- package/dist/firestore/components/ReferencePicker.js +42 -0
- package/dist/firestore/components/ReferencePicker.js.map +1 -0
- package/dist/firestore/components/TreeEntry.d.ts +15 -0
- package/dist/firestore/components/TreeEntry.d.ts.map +1 -0
- package/dist/firestore/components/TreeEntry.js +23 -0
- package/dist/firestore/components/TreeEntry.js.map +1 -0
- package/dist/firestore/components/context.d.ts +18 -0
- package/dist/firestore/components/context.d.ts.map +1 -0
- package/dist/firestore/components/context.js +7 -0
- package/dist/firestore/components/context.js.map +1 -0
- package/dist/firestore/fieldEditors/array.d.ts +3 -0
- package/dist/firestore/fieldEditors/array.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/array.js +16 -0
- package/dist/firestore/fieldEditors/array.js.map +1 -0
- package/dist/firestore/fieldEditors/boolean.d.ts +3 -0
- package/dist/firestore/fieldEditors/boolean.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/boolean.js +13 -0
- package/dist/firestore/fieldEditors/boolean.js.map +1 -0
- package/dist/firestore/fieldEditors/bytes.d.ts +4 -0
- package/dist/firestore/fieldEditors/bytes.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/bytes.js +31 -0
- package/dist/firestore/fieldEditors/bytes.js.map +1 -0
- package/dist/firestore/fieldEditors/geopoint.d.ts +4 -0
- package/dist/firestore/fieldEditors/geopoint.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/geopoint.js +32 -0
- package/dist/firestore/fieldEditors/geopoint.js.map +1 -0
- package/dist/firestore/fieldEditors/map.d.ts +3 -0
- package/dist/firestore/fieldEditors/map.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/map.js +19 -0
- package/dist/firestore/fieldEditors/map.js.map +1 -0
- package/dist/firestore/fieldEditors/null.d.ts +3 -0
- package/dist/firestore/fieldEditors/null.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/null.js +17 -0
- package/dist/firestore/fieldEditors/null.js.map +1 -0
- package/dist/firestore/fieldEditors/number.d.ts +3 -0
- package/dist/firestore/fieldEditors/number.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/number.js +24 -0
- package/dist/firestore/fieldEditors/number.js.map +1 -0
- package/dist/firestore/fieldEditors/reference.d.ts +4 -0
- package/dist/firestore/fieldEditors/reference.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/reference.js +49 -0
- package/dist/firestore/fieldEditors/reference.js.map +1 -0
- package/dist/firestore/fieldEditors/registry.d.ts +16 -0
- package/dist/firestore/fieldEditors/registry.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/registry.js +42 -0
- package/dist/firestore/fieldEditors/registry.js.map +1 -0
- package/dist/firestore/fieldEditors/string.d.ts +3 -0
- package/dist/firestore/fieldEditors/string.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/string.js +13 -0
- package/dist/firestore/fieldEditors/string.js.map +1 -0
- package/dist/firestore/fieldEditors/timestamp.d.ts +4 -0
- package/dist/firestore/fieldEditors/timestamp.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/timestamp.js +52 -0
- package/dist/firestore/fieldEditors/timestamp.js.map +1 -0
- package/dist/firestore/fieldEditors/types.d.ts +64 -0
- package/dist/firestore/fieldEditors/types.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/types.js +2 -0
- package/dist/firestore/fieldEditors/types.js.map +1 -0
- package/dist/firestore/fieldEditors/vector.d.ts +29 -0
- package/dist/firestore/fieldEditors/vector.d.ts.map +1 -0
- package/dist/firestore/fieldEditors/vector.js +93 -0
- package/dist/firestore/fieldEditors/vector.js.map +1 -0
- package/dist/firestore/firestoreApi.d.ts +35 -0
- package/dist/firestore/firestoreApi.d.ts.map +1 -0
- package/dist/firestore/firestoreApi.js +28 -0
- package/dist/firestore/firestoreApi.js.map +1 -0
- package/dist/firestore/hooks/coerceError.d.ts +17 -0
- package/dist/firestore/hooks/coerceError.d.ts.map +1 -0
- package/dist/firestore/hooks/coerceError.js +41 -0
- package/dist/firestore/hooks/coerceError.js.map +1 -0
- package/dist/firestore/hooks/index.d.ts +10 -0
- package/dist/firestore/hooks/index.d.ts.map +1 -0
- package/dist/firestore/hooks/index.js +10 -0
- package/dist/firestore/hooks/index.js.map +1 -0
- package/dist/firestore/hooks/useCollectionList.d.ts +37 -0
- package/dist/firestore/hooks/useCollectionList.d.ts.map +1 -0
- package/dist/firestore/hooks/useCollectionList.js +51 -0
- package/dist/firestore/hooks/useCollectionList.js.map +1 -0
- package/dist/firestore/hooks/useDocumentEditor.d.ts +58 -0
- package/dist/firestore/hooks/useDocumentEditor.d.ts.map +1 -0
- package/dist/firestore/hooks/useDocumentEditor.js +68 -0
- package/dist/firestore/hooks/useDocumentEditor.js.map +1 -0
- package/dist/firestore/hooks/useDocumentList.d.ts +45 -0
- package/dist/firestore/hooks/useDocumentList.d.ts.map +1 -0
- package/dist/firestore/hooks/useDocumentList.js +112 -0
- package/dist/firestore/hooks/useDocumentList.js.map +1 -0
- package/dist/firestore/hooks/useDocumentSubcollections.d.ts +29 -0
- package/dist/firestore/hooks/useDocumentSubcollections.d.ts.map +1 -0
- package/dist/firestore/hooks/useDocumentSubcollections.js +48 -0
- package/dist/firestore/hooks/useDocumentSubcollections.js.map +1 -0
- package/dist/firestore/hooks/useFirestoreCollection.d.ts +14 -0
- package/dist/firestore/hooks/useFirestoreCollection.d.ts.map +1 -0
- package/dist/firestore/hooks/useFirestoreCollection.js +35 -0
- package/dist/firestore/hooks/useFirestoreCollection.js.map +1 -0
- package/dist/firestore/hooks/useFirestoreDoc.d.ts +17 -0
- package/dist/firestore/hooks/useFirestoreDoc.d.ts.map +1 -0
- package/dist/firestore/hooks/useFirestoreDoc.js +34 -0
- package/dist/firestore/hooks/useFirestoreDoc.js.map +1 -0
- package/dist/firestore/hooks/useQueryBuilder.d.ts +51 -0
- package/dist/firestore/hooks/useQueryBuilder.d.ts.map +1 -0
- package/dist/firestore/hooks/useQueryBuilder.js +110 -0
- package/dist/firestore/hooks/useQueryBuilder.js.map +1 -0
- package/dist/firestore/hooks/useRecursiveDelete.d.ts +40 -0
- package/dist/firestore/hooks/useRecursiveDelete.d.ts.map +1 -0
- package/dist/firestore/hooks/useRecursiveDelete.js +44 -0
- package/dist/firestore/hooks/useRecursiveDelete.js.map +1 -0
- package/dist/firestore/hooks/useReferencePicker.d.ts +70 -0
- package/dist/firestore/hooks/useReferencePicker.d.ts.map +1 -0
- package/dist/firestore/hooks/useReferencePicker.js +140 -0
- package/dist/firestore/hooks/useReferencePicker.js.map +1 -0
- package/dist/firestore/import/parseImport.d.ts +55 -0
- package/dist/firestore/import/parseImport.d.ts.map +1 -0
- package/dist/firestore/import/parseImport.js +101 -0
- package/dist/firestore/import/parseImport.js.map +1 -0
- package/dist/firestore/index.d.ts +20 -0
- package/dist/firestore/index.d.ts.map +1 -0
- package/dist/firestore/index.js +28 -0
- package/dist/firestore/index.js.map +1 -0
- package/dist/firestore/reducers/defaults.d.ts +10 -0
- package/dist/firestore/reducers/defaults.d.ts.map +1 -0
- package/dist/firestore/reducers/defaults.js +37 -0
- package/dist/firestore/reducers/defaults.js.map +1 -0
- package/dist/firestore/reducers/documentEditor.d.ts +23 -0
- package/dist/firestore/reducers/documentEditor.d.ts.map +1 -0
- package/dist/firestore/reducers/documentEditor.js +199 -0
- package/dist/firestore/reducers/documentEditor.js.map +1 -0
- package/dist/firestore/reducers/tree.d.ts +28 -0
- package/dist/firestore/reducers/tree.d.ts.map +1 -0
- package/dist/firestore/reducers/tree.js +129 -0
- package/dist/firestore/reducers/tree.js.map +1 -0
- package/dist/firestore/reducers/types.d.ts +112 -0
- package/dist/firestore/reducers/types.d.ts.map +1 -0
- package/dist/firestore/reducers/types.js +2 -0
- package/dist/firestore/reducers/types.js.map +1 -0
- package/dist/firestore/reducers/validation.d.ts +25 -0
- package/dist/firestore/reducers/validation.d.ts.map +1 -0
- package/dist/firestore/reducers/validation.js +121 -0
- package/dist/firestore/reducers/validation.js.map +1 -0
- package/dist/firestore/types.d.ts +77 -0
- package/dist/firestore/types.d.ts.map +1 -0
- package/dist/firestore/types.js +196 -0
- package/dist/firestore/types.js.map +1 -0
- package/dist/firestore/validation/ids.d.ts +23 -0
- package/dist/firestore/validation/ids.d.ts.map +1 -0
- package/dist/firestore/validation/ids.js +46 -0
- package/dist/firestore/validation/ids.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/primitives/Badge.d.ts +28 -0
- package/dist/primitives/Badge.d.ts.map +1 -0
- package/dist/primitives/Badge.js +11 -0
- package/dist/primitives/Badge.js.map +1 -0
- package/dist/primitives/ConfirmDialog.d.ts +42 -0
- package/dist/primitives/ConfirmDialog.d.ts.map +1 -0
- package/dist/primitives/ConfirmDialog.js +61 -0
- package/dist/primitives/ConfirmDialog.js.map +1 -0
- package/dist/primitives/CopyButton.d.ts +28 -0
- package/dist/primitives/CopyButton.d.ts.map +1 -0
- package/dist/primitives/CopyButton.js +27 -0
- package/dist/primitives/CopyButton.js.map +1 -0
- package/dist/primitives/JsonView.d.ts +29 -0
- package/dist/primitives/JsonView.d.ts.map +1 -0
- package/dist/primitives/JsonView.js +56 -0
- package/dist/primitives/JsonView.js.map +1 -0
- package/dist/primitives/SegmentedControl.d.ts +37 -0
- package/dist/primitives/SegmentedControl.d.ts.map +1 -0
- package/dist/primitives/SegmentedControl.js +18 -0
- package/dist/primitives/SegmentedControl.js.map +1 -0
- package/dist/primitives/Toast.d.ts +48 -0
- package/dist/primitives/Toast.d.ts.map +1 -0
- package/dist/primitives/Toast.js +60 -0
- package/dist/primitives/Toast.js.map +1 -0
- package/dist/primitives/VirtualList.d.ts +37 -0
- package/dist/primitives/VirtualList.d.ts.map +1 -0
- package/dist/primitives/VirtualList.js +47 -0
- package/dist/primitives/VirtualList.js.map +1 -0
- package/dist/primitives/hooks/useContainerSize.d.ts +29 -0
- package/dist/primitives/hooks/useContainerSize.d.ts.map +1 -0
- package/dist/primitives/hooks/useContainerSize.js +45 -0
- package/dist/primitives/hooks/useContainerSize.js.map +1 -0
- package/dist/primitives/index.d.ts +10 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +10 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/useConfirm.d.ts +34 -0
- package/dist/primitives/useConfirm.d.ts.map +1 -0
- package/dist/primitives/useConfirm.js +63 -0
- package/dist/primitives/useConfirm.js.map +1 -0
- package/dist/rtdb/components/RtdbPathBar.d.ts +31 -0
- package/dist/rtdb/components/RtdbPathBar.d.ts.map +1 -0
- package/dist/rtdb/components/RtdbPathBar.js +47 -0
- package/dist/rtdb/components/RtdbPathBar.js.map +1 -0
- package/dist/rtdb/components/RtdbTree.d.ts +38 -0
- package/dist/rtdb/components/RtdbTree.d.ts.map +1 -0
- package/dist/rtdb/components/RtdbTree.js +103 -0
- package/dist/rtdb/components/RtdbTree.js.map +1 -0
- package/dist/rtdb/editor.d.ts +25 -0
- package/dist/rtdb/editor.d.ts.map +1 -0
- package/dist/rtdb/editor.js +79 -0
- package/dist/rtdb/editor.js.map +1 -0
- package/dist/rtdb/hooks/useRtdbTree.d.ts +31 -0
- package/dist/rtdb/hooks/useRtdbTree.d.ts.map +1 -0
- package/dist/rtdb/hooks/useRtdbTree.js +49 -0
- package/dist/rtdb/hooks/useRtdbTree.js.map +1 -0
- package/dist/rtdb/index.d.ts +17 -0
- package/dist/rtdb/index.d.ts.map +1 -0
- package/dist/rtdb/index.js +21 -0
- package/dist/rtdb/index.js.map +1 -0
- package/dist/rtdb/pathInput.d.ts +28 -0
- package/dist/rtdb/pathInput.d.ts.map +1 -0
- package/dist/rtdb/pathInput.js +40 -0
- package/dist/rtdb/pathInput.js.map +1 -0
- package/dist/rtdb/reducers/tree.d.ts +86 -0
- package/dist/rtdb/reducers/tree.d.ts.map +1 -0
- package/dist/rtdb/reducers/tree.js +131 -0
- package/dist/rtdb/reducers/tree.js.map +1 -0
- package/dist/rtdb/rtdbApi.d.ts +20 -0
- package/dist/rtdb/rtdbApi.d.ts.map +1 -0
- package/dist/rtdb/rtdbApi.js +2 -0
- package/dist/rtdb/rtdbApi.js.map +1 -0
- package/dist/rtdb/values.d.ts +44 -0
- package/dist/rtdb/values.d.ts.map +1 -0
- package/dist/rtdb/values.js +143 -0
- package/dist/rtdb/values.js.map +1 -0
- package/dist/rules/components/DenialInspector.d.ts +18 -0
- package/dist/rules/components/DenialInspector.d.ts.map +1 -0
- package/dist/rules/components/DenialInspector.js +58 -0
- package/dist/rules/components/DenialInspector.js.map +1 -0
- package/dist/rules/components/format.d.ts +56 -0
- package/dist/rules/components/format.d.ts.map +1 -0
- package/dist/rules/components/format.js +137 -0
- package/dist/rules/components/format.js.map +1 -0
- package/dist/rules/components/index.d.ts +4 -0
- package/dist/rules/components/index.d.ts.map +1 -0
- package/dist/rules/components/index.js +4 -0
- package/dist/rules/components/index.js.map +1 -0
- package/dist/rules/components/scope.d.ts +10 -0
- package/dist/rules/components/scope.d.ts.map +1 -0
- package/dist/rules/components/scope.js +72 -0
- package/dist/rules/components/scope.js.map +1 -0
- package/dist/rules/hooks/index.d.ts +2 -0
- package/dist/rules/hooks/index.d.ts.map +1 -0
- package/dist/rules/hooks/index.js +2 -0
- package/dist/rules/hooks/index.js.map +1 -0
- package/dist/rules/hooks/useDenialTrace.d.ts +51 -0
- package/dist/rules/hooks/useDenialTrace.d.ts.map +1 -0
- package/dist/rules/hooks/useDenialTrace.js +58 -0
- package/dist/rules/hooks/useDenialTrace.js.map +1 -0
- package/dist/rules/index.d.ts +14 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +13 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/types.d.ts +75 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +2 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/storage/collisionRename.d.ts +73 -0
- package/dist/storage/collisionRename.d.ts.map +1 -0
- package/dist/storage/collisionRename.js +113 -0
- package/dist/storage/collisionRename.js.map +1 -0
- package/dist/storage/components/DeleteSelectionWithConfirm.d.ts +68 -0
- package/dist/storage/components/DeleteSelectionWithConfirm.d.ts.map +1 -0
- package/dist/storage/components/DeleteSelectionWithConfirm.js +82 -0
- package/dist/storage/components/DeleteSelectionWithConfirm.js.map +1 -0
- package/dist/storage/components/ObjectBrowser.d.ts +75 -0
- package/dist/storage/components/ObjectBrowser.d.ts.map +1 -0
- package/dist/storage/components/ObjectBrowser.js +59 -0
- package/dist/storage/components/ObjectBrowser.js.map +1 -0
- package/dist/storage/components/ObjectInspector.d.ts +43 -0
- package/dist/storage/components/ObjectInspector.d.ts.map +1 -0
- package/dist/storage/components/ObjectInspector.js +92 -0
- package/dist/storage/components/ObjectInspector.js.map +1 -0
- package/dist/storage/components/PathBreadcrumb.d.ts +30 -0
- package/dist/storage/components/PathBreadcrumb.d.ts.map +1 -0
- package/dist/storage/components/PathBreadcrumb.js +26 -0
- package/dist/storage/components/PathBreadcrumb.js.map +1 -0
- package/dist/storage/components/UploadDropzone.d.ts +50 -0
- package/dist/storage/components/UploadDropzone.d.ts.map +1 -0
- package/dist/storage/components/UploadDropzone.js +109 -0
- package/dist/storage/components/UploadDropzone.js.map +1 -0
- package/dist/storage/folderPlaceholder.d.ts +14 -0
- package/dist/storage/folderPlaceholder.d.ts.map +1 -0
- package/dist/storage/folderPlaceholder.js +27 -0
- package/dist/storage/folderPlaceholder.js.map +1 -0
- package/dist/storage/hooks/index.d.ts +9 -0
- package/dist/storage/hooks/index.d.ts.map +1 -0
- package/dist/storage/hooks/index.js +9 -0
- package/dist/storage/hooks/index.js.map +1 -0
- package/dist/storage/hooks/useMetadataEditor.d.ts +114 -0
- package/dist/storage/hooks/useMetadataEditor.d.ts.map +1 -0
- package/dist/storage/hooks/useMetadataEditor.js +193 -0
- package/dist/storage/hooks/useMetadataEditor.js.map +1 -0
- package/dist/storage/hooks/useObjectUpload.d.ts +109 -0
- package/dist/storage/hooks/useObjectUpload.d.ts.map +1 -0
- package/dist/storage/hooks/useObjectUpload.js +134 -0
- package/dist/storage/hooks/useObjectUpload.js.map +1 -0
- package/dist/storage/hooks/usePathState.d.ts +43 -0
- package/dist/storage/hooks/usePathState.d.ts.map +1 -0
- package/dist/storage/hooks/usePathState.js +42 -0
- package/dist/storage/hooks/usePathState.js.map +1 -0
- package/dist/storage/hooks/useStorageDelete.d.ts +73 -0
- package/dist/storage/hooks/useStorageDelete.d.ts.map +1 -0
- package/dist/storage/hooks/useStorageDelete.js +114 -0
- package/dist/storage/hooks/useStorageDelete.js.map +1 -0
- package/dist/storage/hooks/useStorageList.d.ts +74 -0
- package/dist/storage/hooks/useStorageList.d.ts.map +1 -0
- package/dist/storage/hooks/useStorageList.js +167 -0
- package/dist/storage/hooks/useStorageList.js.map +1 -0
- package/dist/storage/hooks/useStorageObject.d.ts +34 -0
- package/dist/storage/hooks/useStorageObject.d.ts.map +1 -0
- package/dist/storage/hooks/useStorageObject.js +114 -0
- package/dist/storage/hooks/useStorageObject.js.map +1 -0
- package/dist/storage/hooks/useStorageRulesGate.d.ts +128 -0
- package/dist/storage/hooks/useStorageRulesGate.d.ts.map +1 -0
- package/dist/storage/hooks/useStorageRulesGate.js +158 -0
- package/dist/storage/hooks/useStorageRulesGate.js.map +1 -0
- package/dist/storage/hooks/useStorageSelection.d.ts +32 -0
- package/dist/storage/hooks/useStorageSelection.d.ts.map +1 -0
- package/dist/storage/hooks/useStorageSelection.js +55 -0
- package/dist/storage/hooks/useStorageSelection.js.map +1 -0
- package/dist/storage/index.d.ts +11 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +17 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/pendingPrefixes.d.ts +73 -0
- package/dist/storage/pendingPrefixes.d.ts.map +1 -0
- package/dist/storage/pendingPrefixes.js +98 -0
- package/dist/storage/pendingPrefixes.js.map +1 -0
- package/dist/storage/previews.d.ts +51 -0
- package/dist/storage/previews.d.ts.map +1 -0
- package/dist/storage/previews.js +73 -0
- package/dist/storage/previews.js.map +1 -0
- package/dist/storage/storageApi.d.ts +30 -0
- package/dist/storage/storageApi.d.ts.map +1 -0
- package/dist/storage/storageApi.js +13 -0
- package/dist/storage/storageApi.js.map +1 -0
- package/dist/traffic/components/RuleHeatmap.d.ts +34 -0
- package/dist/traffic/components/RuleHeatmap.d.ts.map +1 -0
- package/dist/traffic/components/RuleHeatmap.js +40 -0
- package/dist/traffic/components/RuleHeatmap.js.map +1 -0
- package/dist/traffic/components/TrafficDetail.d.ts +33 -0
- package/dist/traffic/components/TrafficDetail.d.ts.map +1 -0
- package/dist/traffic/components/TrafficDetail.js +28 -0
- package/dist/traffic/components/TrafficDetail.js.map +1 -0
- package/dist/traffic/components/TrafficGroupRow.d.ts +28 -0
- package/dist/traffic/components/TrafficGroupRow.d.ts.map +1 -0
- package/dist/traffic/components/TrafficGroupRow.js +18 -0
- package/dist/traffic/components/TrafficGroupRow.js.map +1 -0
- package/dist/traffic/components/TrafficLineChart.d.ts +34 -0
- package/dist/traffic/components/TrafficLineChart.d.ts.map +1 -0
- package/dist/traffic/components/TrafficLineChart.js +49 -0
- package/dist/traffic/components/TrafficLineChart.js.map +1 -0
- package/dist/traffic/components/TrafficLog.d.ts +52 -0
- package/dist/traffic/components/TrafficLog.d.ts.map +1 -0
- package/dist/traffic/components/TrafficLog.js +34 -0
- package/dist/traffic/components/TrafficLog.js.map +1 -0
- package/dist/traffic/components/TrafficMetricCards.d.ts +26 -0
- package/dist/traffic/components/TrafficMetricCards.d.ts.map +1 -0
- package/dist/traffic/components/TrafficMetricCards.js +24 -0
- package/dist/traffic/components/TrafficMetricCards.js.map +1 -0
- package/dist/traffic/components/TrafficRow.d.ts +40 -0
- package/dist/traffic/components/TrafficRow.d.ts.map +1 -0
- package/dist/traffic/components/TrafficRow.js +27 -0
- package/dist/traffic/components/TrafficRow.js.map +1 -0
- package/dist/traffic/components/TrafficStats.d.ts +18 -0
- package/dist/traffic/components/TrafficStats.d.ts.map +1 -0
- package/dist/traffic/components/TrafficStats.js +19 -0
- package/dist/traffic/components/TrafficStats.js.map +1 -0
- package/dist/traffic/components/TrafficTimeline.d.ts +81 -0
- package/dist/traffic/components/TrafficTimeline.d.ts.map +1 -0
- package/dist/traffic/components/TrafficTimeline.js +72 -0
- package/dist/traffic/components/TrafficTimeline.js.map +1 -0
- package/dist/traffic/components/format.d.ts +13 -0
- package/dist/traffic/components/format.d.ts.map +1 -0
- package/dist/traffic/components/format.js +24 -0
- package/dist/traffic/components/format.js.map +1 -0
- package/dist/traffic/components/index.d.ts +11 -0
- package/dist/traffic/components/index.d.ts.map +1 -0
- package/dist/traffic/components/index.js +11 -0
- package/dist/traffic/components/index.js.map +1 -0
- package/dist/traffic/hooks/index.d.ts +8 -0
- package/dist/traffic/hooks/index.d.ts.map +1 -0
- package/dist/traffic/hooks/index.js +8 -0
- package/dist/traffic/hooks/index.js.map +1 -0
- package/dist/traffic/hooks/useRuleHeatmap.d.ts +33 -0
- package/dist/traffic/hooks/useRuleHeatmap.d.ts.map +1 -0
- package/dist/traffic/hooks/useRuleHeatmap.js +54 -0
- package/dist/traffic/hooks/useRuleHeatmap.js.map +1 -0
- package/dist/traffic/hooks/useTrafficBuckets.d.ts +71 -0
- package/dist/traffic/hooks/useTrafficBuckets.d.ts.map +1 -0
- package/dist/traffic/hooks/useTrafficBuckets.js +74 -0
- package/dist/traffic/hooks/useTrafficBuckets.js.map +1 -0
- package/dist/traffic/hooks/useTrafficFilter.d.ts +40 -0
- package/dist/traffic/hooks/useTrafficFilter.d.ts.map +1 -0
- package/dist/traffic/hooks/useTrafficFilter.js +33 -0
- package/dist/traffic/hooks/useTrafficFilter.js.map +1 -0
- package/dist/traffic/hooks/useTrafficGroups.d.ts +47 -0
- package/dist/traffic/hooks/useTrafficGroups.d.ts.map +1 -0
- package/dist/traffic/hooks/useTrafficGroups.js +73 -0
- package/dist/traffic/hooks/useTrafficGroups.js.map +1 -0
- package/dist/traffic/hooks/useTrafficMetrics.d.ts +66 -0
- package/dist/traffic/hooks/useTrafficMetrics.d.ts.map +1 -0
- package/dist/traffic/hooks/useTrafficMetrics.js +156 -0
- package/dist/traffic/hooks/useTrafficMetrics.js.map +1 -0
- package/dist/traffic/hooks/useTrafficMonitor.d.ts +56 -0
- package/dist/traffic/hooks/useTrafficMonitor.d.ts.map +1 -0
- package/dist/traffic/hooks/useTrafficMonitor.js +58 -0
- package/dist/traffic/hooks/useTrafficMonitor.js.map +1 -0
- package/dist/traffic/hooks/useTrafficStats.d.ts +32 -0
- package/dist/traffic/hooks/useTrafficStats.d.ts.map +1 -0
- package/dist/traffic/hooks/useTrafficStats.js +45 -0
- package/dist/traffic/hooks/useTrafficStats.js.map +1 -0
- package/dist/traffic/index.d.ts +4 -0
- package/dist/traffic/index.d.ts.map +1 -0
- package/dist/traffic/index.js +3 -0
- package/dist/traffic/index.js.map +1 -0
- package/dist/traffic/types.d.ts +72 -0
- package/dist/traffic/types.d.ts.map +1 -0
- package/dist/traffic/types.js +10 -0
- package/dist/traffic/types.js.map +1 -0
- package/package.json +116 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { TrafficEvent } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A half-open time window `[start, end)` in epoch-ms. The timeline
|
|
4
|
+
* buckets events whose `at` falls inside it; events outside are
|
|
5
|
+
* dropped from the histogram (but still counted in `outOfWindow`).
|
|
6
|
+
*/
|
|
7
|
+
export interface TimeWindow {
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TrafficBucket {
|
|
12
|
+
/** 0-based bucket index, left (oldest) to right (newest). */
|
|
13
|
+
index: number;
|
|
14
|
+
/** Half-open bounds of this bucket `[start, end)` in epoch-ms. */
|
|
15
|
+
start: number;
|
|
16
|
+
end: number;
|
|
17
|
+
/** Total events that fell in this bucket. */
|
|
18
|
+
count: number;
|
|
19
|
+
/** How many of `count` were denied. */
|
|
20
|
+
denies: number;
|
|
21
|
+
/** `count - denies` — allowed + unsupported. The "non-deny" stack. */
|
|
22
|
+
allows: number;
|
|
23
|
+
/**
|
|
24
|
+
* `count / maxCount` across all buckets — 0..1. The full bar
|
|
25
|
+
* height as a fraction of the tallest bucket. Drives
|
|
26
|
+
* `--pyric-bucket-h`.
|
|
27
|
+
*/
|
|
28
|
+
heightRatio: number;
|
|
29
|
+
/**
|
|
30
|
+
* `denies / maxCount` — 0..1. The deny sub-stack height as a
|
|
31
|
+
* fraction of the tallest bucket, so the deny segment is drawn to
|
|
32
|
+
* the same scale as the full bar. Drives `--pyric-bucket-deny-h`.
|
|
33
|
+
*/
|
|
34
|
+
denyHeightRatio: number;
|
|
35
|
+
}
|
|
36
|
+
export interface UseTrafficBucketsOptions {
|
|
37
|
+
events: TrafficEvent[];
|
|
38
|
+
/** The time range to bucket over. */
|
|
39
|
+
window: TimeWindow;
|
|
40
|
+
/** Number of buckets to divide the window into. Default 30. */
|
|
41
|
+
bucketCount?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface UseTrafficBucketsResult {
|
|
44
|
+
buckets: TrafficBucket[];
|
|
45
|
+
/** Sum of `count` across buckets (events inside the window). */
|
|
46
|
+
total: number;
|
|
47
|
+
/** Sum of `denies` across buckets. */
|
|
48
|
+
denies: number;
|
|
49
|
+
/** The largest single-bucket `count` — the height-ratio divisor. */
|
|
50
|
+
maxCount: number;
|
|
51
|
+
/** Events whose `at` fell outside `[window.start, window.end)`. */
|
|
52
|
+
outOfWindow: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Buckets a traffic buffer into `bucketCount` equal time slices over
|
|
56
|
+
* `window`, counting total + denied events per slice. Pure
|
|
57
|
+
* derivation — the histogram component renders the result, this hook
|
|
58
|
+
* (and `bucketTraffic` under it) owns the math.
|
|
59
|
+
*
|
|
60
|
+
* Each bucket carries a `heightRatio` and `denyHeightRatio`
|
|
61
|
+
* (0..1, scaled to the tallest bucket) so the consumer can map them
|
|
62
|
+
* straight onto a bar height without re-finding the max.
|
|
63
|
+
*/
|
|
64
|
+
export declare function useTrafficBuckets({ events, window, bucketCount, }: UseTrafficBucketsOptions): UseTrafficBucketsResult;
|
|
65
|
+
/**
|
|
66
|
+
* The pure bucketing kernel behind {@link useTrafficBuckets} — usable
|
|
67
|
+
* outside React. Returns an empty result for a non-positive
|
|
68
|
+
* `bucketCount` or a zero/negative-width window.
|
|
69
|
+
*/
|
|
70
|
+
export declare function bucketTraffic(events: TrafficEvent[], window: TimeWindow, bucketCount?: number): UseTrafficBucketsResult;
|
|
71
|
+
//# sourceMappingURL=useTrafficBuckets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrafficBuckets.d.ts","sourceRoot":"","sources":["../../../src/traffic/hooks/useTrafficBuckets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,a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/**
|
|
10
|
+
* Buckets a traffic buffer into `bucketCount` equal time slices over
|
|
11
|
+
* `window`, counting total + denied events per slice. Pure
|
|
12
|
+
* derivation — the histogram component renders the result, this hook
|
|
13
|
+
* (and `bucketTraffic` under it) owns the math.
|
|
14
|
+
*
|
|
15
|
+
* Each bucket carries a `heightRatio` and `denyHeightRatio`
|
|
16
|
+
* (0..1, scaled to the tallest bucket) so the consumer can map them
|
|
17
|
+
* straight onto a bar height without re-finding the max.
|
|
18
|
+
*/
|
|
19
|
+
export function useTrafficBuckets({ events, window, bucketCount = 30, }) {
|
|
20
|
+
return useMemo(() => bucketTraffic(events, window, bucketCount), [events, window.start, window.end, bucketCount]);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The pure bucketing kernel behind {@link useTrafficBuckets} — usable
|
|
24
|
+
* outside React. Returns an empty result for a non-positive
|
|
25
|
+
* `bucketCount` or a zero/negative-width window.
|
|
26
|
+
*/
|
|
27
|
+
export function bucketTraffic(events, window, bucketCount = 30) {
|
|
28
|
+
const span = window.end - window.start;
|
|
29
|
+
if (bucketCount <= 0 || span <= 0)
|
|
30
|
+
return EMPTY_RESULT;
|
|
31
|
+
const width = span / bucketCount;
|
|
32
|
+
const counts = new Array(bucketCount).fill(0);
|
|
33
|
+
const denyCounts = new Array(bucketCount).fill(0);
|
|
34
|
+
let total = 0;
|
|
35
|
+
let denies = 0;
|
|
36
|
+
let outOfWindow = 0;
|
|
37
|
+
for (const event of events) {
|
|
38
|
+
const at = event.at;
|
|
39
|
+
if (at < window.start || at >= window.end) {
|
|
40
|
+
outOfWindow++;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
// Floor into a bucket; clamp the right edge so an `at` exactly at
|
|
44
|
+
// `window.end - epsilon` never spills past the last bucket.
|
|
45
|
+
let i = Math.floor((at - window.start) / width);
|
|
46
|
+
if (i >= bucketCount)
|
|
47
|
+
i = bucketCount - 1;
|
|
48
|
+
counts[i]++;
|
|
49
|
+
total++;
|
|
50
|
+
if (event.result === 'deny') {
|
|
51
|
+
denyCounts[i]++;
|
|
52
|
+
denies++;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
let maxCount = 0;
|
|
56
|
+
for (const c of counts)
|
|
57
|
+
if (c > maxCount)
|
|
58
|
+
maxCount = c;
|
|
59
|
+
const buckets = counts.map((count, index) => {
|
|
60
|
+
const denyCount = denyCounts[index];
|
|
61
|
+
return {
|
|
62
|
+
index,
|
|
63
|
+
start: window.start + index * width,
|
|
64
|
+
end: window.start + (index + 1) * width,
|
|
65
|
+
count,
|
|
66
|
+
denies: denyCount,
|
|
67
|
+
allows: count - denyCount,
|
|
68
|
+
heightRatio: maxCount === 0 ? 0 : count / maxCount,
|
|
69
|
+
denyHeightRatio: maxCount === 0 ? 0 : denyCount / maxCount,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
return { buckets, total, denies, maxCount, outOfWindow };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=useTrafficBuckets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrafficBuckets.js","sourceRoot":"","sources":["../../../src/traffic/hooks/useTrafficBuckets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AA2DhC,MAAM,YAAY,GAA4B;IAC5C,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,WAAW,EAAE,CAAC;CACf,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,MAAM,EACN,MAAM,EACN,WAAW,GAAG,EAAE,GACS;IACzB,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAChD,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,WAAW,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M,EAAE,CAAC;QACX,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,IAAI,CAAC,GAAG,QAAQ;YAAE,QAAQ,GAAG,CAAC,CAAC;IAEvD,MAAM,OAAO,GAAoB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC3D,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,OAAO;YACL,KAAK;YACL,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,KAAK;YACnC,GAAG,EAAE,MAAM,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK;YACvC,KAAK;YACL,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,KAAK,GAAG,SAAS;YACzB,WAAW,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,QAAQ;YAClD,eAAe,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,QAAQ;SAC3D,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { TrafficEvent } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* `user` keeps everything that isn't a listener re-eval (user ops
|
|
4
|
+
* plus their transaction/batch sub-ops); `listener` keeps only
|
|
5
|
+
* listener re-evals; `all` keeps everything.
|
|
6
|
+
*/
|
|
7
|
+
export type TrafficOriginFilter = 'user' | 'all' | 'listener';
|
|
8
|
+
export type TrafficResultFilter = 'all' | 'allow' | 'deny';
|
|
9
|
+
export interface UseTrafficFilterOptions {
|
|
10
|
+
events: TrafficEvent[];
|
|
11
|
+
/**
|
|
12
|
+
* Default `user` — the probe found listener traffic is 94–99.6%
|
|
13
|
+
* of events, so it's hidden until explicitly asked for.
|
|
14
|
+
*/
|
|
15
|
+
initialOrigin?: TrafficOriginFilter;
|
|
16
|
+
/** Default `all` — the probe found ~75–80% allow in realistic
|
|
17
|
+
* sessions, so hiding either side loses diagnostic signal. */
|
|
18
|
+
initialResult?: TrafficResultFilter;
|
|
19
|
+
initialPathQuery?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface TrafficFilterState {
|
|
22
|
+
origin: TrafficOriginFilter;
|
|
23
|
+
result: TrafficResultFilter;
|
|
24
|
+
pathQuery: string;
|
|
25
|
+
}
|
|
26
|
+
export interface UseTrafficFilterResult {
|
|
27
|
+
/** Events passing all three filters, in the input order. */
|
|
28
|
+
filtered: TrafficEvent[];
|
|
29
|
+
filter: TrafficFilterState;
|
|
30
|
+
setOrigin: (origin: TrafficOriginFilter) => void;
|
|
31
|
+
setResult: (result: TrafficResultFilter) => void;
|
|
32
|
+
setPathQuery: (pathQuery: string) => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Derives a filtered view over a traffic buffer along three
|
|
36
|
+
* dimensions: origin, result, and a case-insensitive path substring.
|
|
37
|
+
* Owns the filter state; pure derivation otherwise.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useTrafficFilter({ events, initialOrigin, initialResult, initialPathQuery, }: UseTrafficFilterOptions): UseTrafficFilterResult;
|
|
40
|
+
//# sourceMappingURL=useTrafficFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrafficFilter.d.ts","sourceRoot":"","sources":["../../../src/traffic/hooks/useTrafficFilter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3D,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC;mEAC+D;IAC/D,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,4DAA4D;IAC5D,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACjD,SAAS,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACjD,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,aAAsB,EACtB,aAAqB,EACrB,gBAAqB,GACtB,EAAE,uBAAuB,GAAG,sBAAsB,CAuBlD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Derives a filtered view over a traffic buffer along three
|
|
4
|
+
* dimensions: origin, result, and a case-insensitive path substring.
|
|
5
|
+
* Owns the filter state; pure derivation otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export function useTrafficFilter({ events, initialOrigin = 'user', initialResult = 'all', initialPathQuery = '', }) {
|
|
8
|
+
const [origin, setOrigin] = useState(initialOrigin);
|
|
9
|
+
const [result, setResult] = useState(initialResult);
|
|
10
|
+
const [pathQuery, setPathQuery] = useState(initialPathQuery);
|
|
11
|
+
const filtered = useMemo(() => {
|
|
12
|
+
const needle = pathQuery.trim().toLowerCase();
|
|
13
|
+
return events.filter((e) => {
|
|
14
|
+
if (origin === 'user' && e.origin === 'listener')
|
|
15
|
+
return false;
|
|
16
|
+
if (origin === 'listener' && e.origin !== 'listener')
|
|
17
|
+
return false;
|
|
18
|
+
if (result !== 'all' && e.result !== result)
|
|
19
|
+
return false;
|
|
20
|
+
if (needle && !e.path.toLowerCase().includes(needle))
|
|
21
|
+
return false;
|
|
22
|
+
return true;
|
|
23
|
+
});
|
|
24
|
+
}, [events, origin, result, pathQuery]);
|
|
25
|
+
return {
|
|
26
|
+
filtered,
|
|
27
|
+
filter: { origin, result, pathQuery },
|
|
28
|
+
setOrigin,
|
|
29
|
+
setResult,
|
|
30
|
+
setPathQuery,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=useTrafficFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrafficFilter.js","sourceRoot":"","sources":["../../../src/traffic/hooks/useTrafficFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAwC1C;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EACN,aAAa,GAAG,MAAM,EACtB,aAAa,GAAG,KAAK,EACrB,gBAAgB,GAAG,EAAE,GACG;IACxB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAsB,aAAa,CAAC,CAAC;IACzE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAsB,aAAa,CAAC,CAAC;IACzE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAE7D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;YACzB,IAAI,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,UAAU;gBAAE,OAAO,KAAK,CAAC;YAC/D,IAAI,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,MAAM,KAAK,UAAU;gBAAE,OAAO,KAAK,CAAC;YACnE,IAAI,MAAM,KAAK,KAAK,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM;gBAAE,OAAO,KAAK,CAAC;YAC1D,IAAI,MAAM,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAAE,OAAO,KAAK,CAAC;YACnE,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAExC,OAAO;QACL,QAAQ;QACR,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE;QACrC,SAAS;QACT,SAAS;QACT,YAAY;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { TrafficEvent } from '../types.js';
|
|
2
|
+
export type TrafficGroupKind = 'batch' | 'transaction' | 'listener-run';
|
|
3
|
+
export interface TrafficGroup {
|
|
4
|
+
type: 'group';
|
|
5
|
+
kind: TrafficGroupKind;
|
|
6
|
+
/** `groupId` for batch/transaction; a synthetic key for listener
|
|
7
|
+
* runs. Stable enough for a React key. */
|
|
8
|
+
key: string;
|
|
9
|
+
events: TrafficEvent[];
|
|
10
|
+
count: number;
|
|
11
|
+
denies: number;
|
|
12
|
+
}
|
|
13
|
+
export interface TrafficSingle {
|
|
14
|
+
type: 'single';
|
|
15
|
+
event: TrafficEvent;
|
|
16
|
+
}
|
|
17
|
+
export type TrafficLogItem = TrafficGroup | TrafficSingle;
|
|
18
|
+
export interface UseTrafficGroupsOptions {
|
|
19
|
+
events: TrafficEvent[];
|
|
20
|
+
/** Collapse consecutive ops sharing a `groupId`. Default true. */
|
|
21
|
+
groupBatches?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Collapse a consecutive run of listener re-evals from the same
|
|
24
|
+
* originating op into one group — the probe found a single write
|
|
25
|
+
* can trigger 250+ re-evals. Default true.
|
|
26
|
+
*/
|
|
27
|
+
groupListenerRuns?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface UseTrafficGroupsResult {
|
|
30
|
+
/** Events folded into a flat list of singles and groups, in the
|
|
31
|
+
* input order. */
|
|
32
|
+
items: TrafficLogItem[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Folds a traffic buffer into a list of singles and collapsible
|
|
36
|
+
* groups. Two grouping modes, both over *consecutive* events:
|
|
37
|
+
*
|
|
38
|
+
* - `groupId` — batch/transaction sub-ops sharing an id collapse
|
|
39
|
+
* into one `batch` / `transaction` group.
|
|
40
|
+
* - listener runs — a consecutive run of listener re-evals from the
|
|
41
|
+
* same originating op collapses into one `listener-run` group.
|
|
42
|
+
* A run of length 1 stays a single (no point collapsing one row).
|
|
43
|
+
*
|
|
44
|
+
* Pure derivation; the input order is preserved.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useTrafficGroups({ events, groupBatches, groupListenerRuns, }: UseTrafficGroupsOptions): UseTrafficGroupsResult;
|
|
47
|
+
//# sourceMappingURL=useTrafficGroups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrafficGroups.d.ts","sourceRoot":"","sources":["../../../src/traffic/hooks/useTrafficGroups.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,aAAa,GAAG,cAAc,CAAC;AAExE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,gBAAgB,CAAC;IACvB;+CAC2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,aAAa,CAAC;AAE1D,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,sBAAsB;IACrC;uBACmB;IACnB,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAoBD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,YAAmB,EACnB,iBAAwB,GACzB,EAAE,uBAAuB,GAAG,sBAAsB,CAkDlD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
function sameTrigger(a, b) {
|
|
3
|
+
const ta = a.triggeredBy;
|
|
4
|
+
const tb = b.triggeredBy;
|
|
5
|
+
if (!ta && !tb)
|
|
6
|
+
return true;
|
|
7
|
+
if (!ta || !tb)
|
|
8
|
+
return false;
|
|
9
|
+
return ta.method === tb.method && ta.path === tb.path;
|
|
10
|
+
}
|
|
11
|
+
function makeGroup(kind, key, events) {
|
|
12
|
+
let denies = 0;
|
|
13
|
+
for (const e of events)
|
|
14
|
+
if (e.result === 'deny')
|
|
15
|
+
denies++;
|
|
16
|
+
return { type: 'group', kind, key, events, count: events.length, denies };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Folds a traffic buffer into a list of singles and collapsible
|
|
20
|
+
* groups. Two grouping modes, both over *consecutive* events:
|
|
21
|
+
*
|
|
22
|
+
* - `groupId` — batch/transaction sub-ops sharing an id collapse
|
|
23
|
+
* into one `batch` / `transaction` group.
|
|
24
|
+
* - listener runs — a consecutive run of listener re-evals from the
|
|
25
|
+
* same originating op collapses into one `listener-run` group.
|
|
26
|
+
* A run of length 1 stays a single (no point collapsing one row).
|
|
27
|
+
*
|
|
28
|
+
* Pure derivation; the input order is preserved.
|
|
29
|
+
*/
|
|
30
|
+
export function useTrafficGroups({ events, groupBatches = true, groupListenerRuns = true, }) {
|
|
31
|
+
return useMemo(() => {
|
|
32
|
+
const items = [];
|
|
33
|
+
let i = 0;
|
|
34
|
+
while (i < events.length) {
|
|
35
|
+
const event = events[i];
|
|
36
|
+
if (groupBatches && event.groupId) {
|
|
37
|
+
let j = i + 1;
|
|
38
|
+
while (j < events.length && events[j].groupId === event.groupId)
|
|
39
|
+
j++;
|
|
40
|
+
const run = events.slice(i, j);
|
|
41
|
+
const kind = event.origin === 'transaction' ? 'transaction' : 'batch';
|
|
42
|
+
items.push(makeGroup(kind, event.groupId, run));
|
|
43
|
+
i = j;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (groupListenerRuns && event.origin === 'listener') {
|
|
47
|
+
let j = i + 1;
|
|
48
|
+
while (j < events.length &&
|
|
49
|
+
events[j].origin === 'listener' &&
|
|
50
|
+
!events[j].groupId &&
|
|
51
|
+
sameTrigger(events[j], event)) {
|
|
52
|
+
j++;
|
|
53
|
+
}
|
|
54
|
+
const run = events.slice(i, j);
|
|
55
|
+
if (run.length > 1) {
|
|
56
|
+
const trigger = event.triggeredBy
|
|
57
|
+
? `${event.triggeredBy.method}:${event.triggeredBy.path}`
|
|
58
|
+
: 'unknown';
|
|
59
|
+
items.push(makeGroup('listener-run', `listener-run:${trigger}:${i}`, run));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
items.push({ type: 'single', event });
|
|
63
|
+
}
|
|
64
|
+
i = j;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
items.push({ type: 'single', event });
|
|
68
|
+
i++;
|
|
69
|
+
}
|
|
70
|
+
return { items };
|
|
71
|
+
}, [events, groupBatches, groupListenerRuns]);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=useTrafficGroups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrafficGroups.js","sourceRoot":"","sources":["../../../src/traffic/hooks/useTrafficGroups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAyChC,SAAS,WAAW,CAAC,CAAe,EAAE,CAAe;IACnD,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,CAAC;IACzB,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,CAAC;IACzB,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;IAC7B,OAAO,EAAE,CAAC,MAAM,KAAK,EAAE,CAAC,MAAM,IAAI,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC;AACxD,CAAC;AAED,SAAS,SAAS,CAChB,IAAsB,EACtB,GAAW,EACX,MAAsB;IAEtB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM;YAAE,MAAM,EAAE,CAAC;IAC1D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EAC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D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC/B,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACnB,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW;wBAC/B,CAAC,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE;wBACzD,CAAC,CAAC,SAAS,CAAC;oBACd,KAAK,CAAC,IAAI,CACR,SAAS,CAAC,cAAc,EAAE,gBAAgB,OAAO,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAC/D,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;gBACxC,CAAC;gBACD,CAAC,GAAG,CAAC,CAAC;gBACN,SAAS;YACX,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;YACtC,CAAC,EAAE,CAAC;QACN,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { TimeWindow } from './useTrafficBuckets.js';
|
|
2
|
+
import type { TrafficEvent } from '../types.js';
|
|
3
|
+
export type BillableSeriesKey = 'reads' | 'writes' | 'deletes';
|
|
4
|
+
export type RulesSeriesKey = 'allows' | 'denies' | 'errors';
|
|
5
|
+
export declare const BILLABLE_SERIES_DEFS: ReadonlyArray<{
|
|
6
|
+
key: BillableSeriesKey;
|
|
7
|
+
label: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const RULES_SERIES_DEFS: ReadonlyArray<{
|
|
10
|
+
key: RulesSeriesKey;
|
|
11
|
+
label: string;
|
|
12
|
+
}>;
|
|
13
|
+
/** Default admin predicate: the one signal the public `TrafficEvent`
|
|
14
|
+
* type declares. See the module doc for the known Firestore gap. */
|
|
15
|
+
export declare function isAdminEvent(event: Pick<TrafficEvent, 'origin'>): boolean;
|
|
16
|
+
/** Classify a billable op, or `null` if it isn't one / never ran. */
|
|
17
|
+
export declare function classifyBillable(event: Pick<TrafficEvent, 'method' | 'result' | 'origin'>, isAdmin?: (event: Pick<TrafficEvent, 'origin'>) => boolean): BillableSeriesKey | null;
|
|
18
|
+
/** Classify a rules-engine verdict, or `null` if it isn't one (bypassed,
|
|
19
|
+
* unsupported, or not-applicable). */
|
|
20
|
+
export declare function classifyRules(event: Pick<TrafficEvent, 'result' | 'origin'>, isAdmin?: (event: Pick<TrafficEvent, 'origin'>) => boolean): RulesSeriesKey | null;
|
|
21
|
+
export interface MetricPoint {
|
|
22
|
+
/** 0-based bucket index, left (oldest) to right (newest). */
|
|
23
|
+
index: number;
|
|
24
|
+
/** Half-open bounds of this bucket `[start, end)` in epoch-ms. */
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
}
|
|
28
|
+
export interface MetricSeries {
|
|
29
|
+
key: string;
|
|
30
|
+
label: string;
|
|
31
|
+
/** One count per bucket, aligned with `points`. */
|
|
32
|
+
values: number[];
|
|
33
|
+
/** Sum of `values` — the period total (the legend/card number). */
|
|
34
|
+
total: number;
|
|
35
|
+
}
|
|
36
|
+
export interface TrafficMetricsResult {
|
|
37
|
+
points: MetricPoint[];
|
|
38
|
+
series: MetricSeries[];
|
|
39
|
+
/** The largest single-bucket value across every series — the shared
|
|
40
|
+
* y-scale divisor a chart would use by default. */
|
|
41
|
+
maxValue: number;
|
|
42
|
+
}
|
|
43
|
+
/** Pure kernel behind {@link useBillableMetrics} — usable outside React. */
|
|
44
|
+
export declare function bucketBillableMetrics(events: readonly TrafficEvent[], window: TimeWindow, bucketCount?: number, isAdmin?: (event: Pick<TrafficEvent, 'origin'>) => boolean): TrafficMetricsResult;
|
|
45
|
+
/** Pure kernel behind {@link useRulesMetrics} — usable outside React. */
|
|
46
|
+
export declare function bucketRulesMetrics(events: readonly TrafficEvent[], window: TimeWindow, bucketCount?: number, isAdmin?: (event: Pick<TrafficEvent, 'origin'>) => boolean): TrafficMetricsResult;
|
|
47
|
+
export interface UseTrafficMetricsOptions {
|
|
48
|
+
events: TrafficEvent[];
|
|
49
|
+
window: TimeWindow;
|
|
50
|
+
/** Number of buckets to divide the window into. The window itself
|
|
51
|
+
* should already be sized to the session (sandbox sessions run
|
|
52
|
+
* minutes, not days) — bucket count doesn't need to change, only the
|
|
53
|
+
* window a caller passes in. Default 24. */
|
|
54
|
+
bucketCount?: number;
|
|
55
|
+
/** Override admin classification (e.g. a Studio caller with
|
|
56
|
+
* `authLens` provenance available — see the module doc). Defaults to
|
|
57
|
+
* `origin === 'admin'`. */
|
|
58
|
+
isAdmin?: (event: Pick<TrafficEvent, 'origin'>) => boolean;
|
|
59
|
+
}
|
|
60
|
+
/** Reads / writes / deletes, bucketed over `window`. See the module doc
|
|
61
|
+
* for the billable mapping + the "read ops, not billable reads" caveat. */
|
|
62
|
+
export declare function useBillableMetrics({ events, window, bucketCount, isAdmin, }: UseTrafficMetricsOptions): TrafficMetricsResult;
|
|
63
|
+
/** Allows / denies / errors, bucketed over `window`. Excludes
|
|
64
|
+
* rules-bypassed (admin) ops — see the module doc. */
|
|
65
|
+
export declare function useRulesMetrics({ events, window, bucketCount, isAdmin, }: UseTrafficMetricsOptions): TrafficMetricsResult;
|
|
66
|
+
//# sourceMappingURL=useTrafficMetrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrafficMetrics.d.ts","sourceRoot":"","sources":["../../../src/traffic/hooks/useTrafficMetrics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MA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1
|
+
import { useMemo } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Billable-metrics + rules-metrics aggregation (Traffic tab: "Billable
|
|
4
|
+
* metrics" and "Subscriptions & Rules"). Mirrors the Firebase Console
|
|
5
|
+
* Usage tab's shape (per-series totals + a bucketed time series), built
|
|
6
|
+
* on top of the same half-open `[window.start, window.end)` bucketing
|
|
7
|
+
* kernel {@link bucketTraffic} already uses.
|
|
8
|
+
*
|
|
9
|
+
* ── Billable mapping (documented; verified against the sandbox source) ──
|
|
10
|
+
* reads = get + list
|
|
11
|
+
* writes = create + update + set
|
|
12
|
+
* deletes = delete + remove
|
|
13
|
+
*
|
|
14
|
+
* A `list` event does NOT carry the number of documents the query
|
|
15
|
+
* returned — `local-environment.ts` emits ONE `allow` event per query
|
|
16
|
+
* before it computes/constrains the doc set, and the returned doc array
|
|
17
|
+
* never rides back onto the event. Real Firestore bills a list as one
|
|
18
|
+
* read PER RETURNED DOCUMENT; this stream can only honestly count list
|
|
19
|
+
* OPERATIONS, not documents. So this series is "read ops", not "billable
|
|
20
|
+
* reads" — an op-count proxy, not a byte-accurate bill. See the gap note
|
|
21
|
+
* in the Traffic feature's tracking issue.
|
|
22
|
+
*
|
|
23
|
+
* An op only bills if it actually ran against data: a `deny`/`error`/
|
|
24
|
+
* `unsupported`/`not-applicable` result means nothing was read or
|
|
25
|
+
* written, so those never count toward billable totals. An `admin`
|
|
26
|
+
* (rules-bypassed) op DOES run — admin reads/writes still bill in real
|
|
27
|
+
* Firestore — so admin ops count toward billable totals even though they
|
|
28
|
+
* never touch the rules-metrics series below.
|
|
29
|
+
*
|
|
30
|
+
* ── Rules metrics ──
|
|
31
|
+
* Allows / denies / errors are rules-ENGINE verdicts: how many times the
|
|
32
|
+
* rules engine actually ran and what it decided. An admin (bypassed) op
|
|
33
|
+
* never reaches rules, so it must never inflate "allows" — that would
|
|
34
|
+
* misrepresent the rules engine as having evaluated something it never
|
|
35
|
+
* saw. `unsupported` / `not-applicable` results aren't rules verdicts
|
|
36
|
+
* either (the simulator declined to evaluate) and are excluded too.
|
|
37
|
+
*
|
|
38
|
+
* ── Admin classification ──
|
|
39
|
+
* The base `TrafficEvent` carries only `origin` (no `detail` field — the
|
|
40
|
+
* sandbox-layer `RequestEvent.detail.admin` doesn't survive the
|
|
41
|
+
* `operation`-kind adapter path, and rides untyped through the
|
|
42
|
+
* `request`-kind cast). `origin === 'admin'` is the one signal declared
|
|
43
|
+
* on the public type, so it's the default `isAdmin` predicate here.
|
|
44
|
+
* Firestore's admin-lens ops don't currently set `origin: 'admin'`
|
|
45
|
+
* (RTDB's do) — callers that can see the richer Studio provenance
|
|
46
|
+
* (`authLens.mode === 'admin'`, as `verdict.ts#verdictFor` already
|
|
47
|
+
* checks) should pass their own `isAdmin` predicate to close that gap.
|
|
48
|
+
*/
|
|
49
|
+
const READ_METHODS = new Set(['get', 'list']);
|
|
50
|
+
const WRITE_METHODS = new Set(['create', 'update', 'set']);
|
|
51
|
+
const DELETE_METHODS = new Set(['delete', 'remove']);
|
|
52
|
+
export const BILLABLE_SERIES_DEFS = [
|
|
53
|
+
{ key: 'reads', label: 'Read ops' },
|
|
54
|
+
{ key: 'writes', label: 'Writes' },
|
|
55
|
+
{ key: 'deletes', label: 'Deletes' },
|
|
56
|
+
];
|
|
57
|
+
export const RULES_SERIES_DEFS = [
|
|
58
|
+
{ key: 'allows', label: 'Allows' },
|
|
59
|
+
{ key: 'denies', label: 'Denies' },
|
|
60
|
+
{ key: 'errors', label: 'Errors' },
|
|
61
|
+
];
|
|
62
|
+
/** Default admin predicate: the one signal the public `TrafficEvent`
|
|
63
|
+
* type declares. See the module doc for the known Firestore gap. */
|
|
64
|
+
export function isAdminEvent(event) {
|
|
65
|
+
return event.origin === 'admin';
|
|
66
|
+
}
|
|
67
|
+
/** Classify a billable op, or `null` if it isn't one / never ran. */
|
|
68
|
+
export function classifyBillable(event, isAdmin = isAdminEvent) {
|
|
69
|
+
const executed = event.result === 'allow' || isAdmin(event);
|
|
70
|
+
if (!executed)
|
|
71
|
+
return null;
|
|
72
|
+
if (READ_METHODS.has(event.method))
|
|
73
|
+
return 'reads';
|
|
74
|
+
if (WRITE_METHODS.has(event.method))
|
|
75
|
+
return 'writes';
|
|
76
|
+
if (DELETE_METHODS.has(event.method))
|
|
77
|
+
return 'deletes';
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
/** Classify a rules-engine verdict, or `null` if it isn't one (bypassed,
|
|
81
|
+
* unsupported, or not-applicable). */
|
|
82
|
+
export function classifyRules(event, isAdmin = isAdminEvent) {
|
|
83
|
+
if (isAdmin(event))
|
|
84
|
+
return null;
|
|
85
|
+
if (event.result === 'allow')
|
|
86
|
+
return 'allows';
|
|
87
|
+
if (event.result === 'deny')
|
|
88
|
+
return 'denies';
|
|
89
|
+
if (event.result === 'error')
|
|
90
|
+
return 'errors';
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const EMPTY = (seriesDefs) => ({
|
|
94
|
+
points: [],
|
|
95
|
+
series: seriesDefs.map((d) => ({ key: d.key, label: d.label, values: [], total: 0 })),
|
|
96
|
+
maxValue: 0,
|
|
97
|
+
});
|
|
98
|
+
/** The shared bucketing kernel behind both metric hooks below. */
|
|
99
|
+
function bucketMetrics(events, window, bucketCount, seriesDefs, classify) {
|
|
100
|
+
const span = window.end - window.start;
|
|
101
|
+
if (bucketCount <= 0 || span <= 0)
|
|
102
|
+
return EMPTY(seriesDefs);
|
|
103
|
+
const width = span / bucketCount;
|
|
104
|
+
const valuesByKey = new Map(seriesDefs.map((d) => [d.key, new Array(bucketCount).fill(0)]));
|
|
105
|
+
const totals = new Map(seriesDefs.map((d) => [d.key, 0]));
|
|
106
|
+
for (const event of events) {
|
|
107
|
+
const at = event.at;
|
|
108
|
+
if (at < window.start || at >= window.end)
|
|
109
|
+
continue;
|
|
110
|
+
const key = classify(event);
|
|
111
|
+
if (key == null)
|
|
112
|
+
continue;
|
|
113
|
+
let i = Math.floor((at - window.start) / width);
|
|
114
|
+
if (i >= bucketCount)
|
|
115
|
+
i = bucketCount - 1;
|
|
116
|
+
const bucketValues = valuesByKey.get(key);
|
|
117
|
+
bucketValues[i]++;
|
|
118
|
+
totals.set(key, (totals.get(key) ?? 0) + 1);
|
|
119
|
+
}
|
|
120
|
+
let maxValue = 0;
|
|
121
|
+
for (const values of valuesByKey.values()) {
|
|
122
|
+
for (const v of values)
|
|
123
|
+
if (v > maxValue)
|
|
124
|
+
maxValue = v;
|
|
125
|
+
}
|
|
126
|
+
const points = new Array(bucketCount);
|
|
127
|
+
for (let i = 0; i < bucketCount; i++) {
|
|
128
|
+
points[i] = { index: i, start: window.start + i * width, end: window.start + (i + 1) * width };
|
|
129
|
+
}
|
|
130
|
+
const series = seriesDefs.map((d) => ({
|
|
131
|
+
key: d.key,
|
|
132
|
+
label: d.label,
|
|
133
|
+
values: valuesByKey.get(d.key),
|
|
134
|
+
total: totals.get(d.key) ?? 0,
|
|
135
|
+
}));
|
|
136
|
+
return { points, series, maxValue };
|
|
137
|
+
}
|
|
138
|
+
/** Pure kernel behind {@link useBillableMetrics} — usable outside React. */
|
|
139
|
+
export function bucketBillableMetrics(events, window, bucketCount = 24, isAdmin = isAdminEvent) {
|
|
140
|
+
return bucketMetrics(events, window, bucketCount, BILLABLE_SERIES_DEFS, (e) => classifyBillable(e, isAdmin));
|
|
141
|
+
}
|
|
142
|
+
/** Pure kernel behind {@link useRulesMetrics} — usable outside React. */
|
|
143
|
+
export function bucketRulesMetrics(events, window, bucketCount = 24, isAdmin = isAdminEvent) {
|
|
144
|
+
return bucketMetrics(events, window, bucketCount, RULES_SERIES_DEFS, (e) => classifyRules(e, isAdmin));
|
|
145
|
+
}
|
|
146
|
+
/** Reads / writes / deletes, bucketed over `window`. See the module doc
|
|
147
|
+
* for the billable mapping + the "read ops, not billable reads" caveat. */
|
|
148
|
+
export function useBillableMetrics({ events, window, bucketCount = 24, isAdmin, }) {
|
|
149
|
+
return useMemo(() => bucketBillableMetrics(events, window, bucketCount, isAdmin), [events, window.start, window.end, bucketCount, isAdmin]);
|
|
150
|
+
}
|
|
151
|
+
/** Allows / denies / errors, bucketed over `window`. Excludes
|
|
152
|
+
* rules-bypassed (admin) ops — see the module doc. */
|
|
153
|
+
export function useRulesMetrics({ events, window, bucketCount = 24, isAdmin, }) {
|
|
154
|
+
return useMemo(() => bucketRulesMetrics(events, window, bucketCount, isAdmin), [events, window.start, window.end, bucketCount, isAdmin]);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=useTrafficMetrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrafficMetrics.js","sourceRoot":"","sources":["../../../src/traffic/hooks/useTrafficMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;AAC3D,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAKrD,MAAM,CAAC,MAAM,oBAAoB,GAA6D;IAC5F,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE;IACnC,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IAClC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAA0D;IACtF,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IAClC,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,E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