@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,110 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { limit as limitFn, orderBy as orderByFn, query as queryFn, where as whereFn, } from 'pyric/firestore';
|
|
3
|
+
export const QUERY_OPS = [
|
|
4
|
+
'==',
|
|
5
|
+
'!=',
|
|
6
|
+
'<',
|
|
7
|
+
'<=',
|
|
8
|
+
'>',
|
|
9
|
+
'>=',
|
|
10
|
+
'in',
|
|
11
|
+
'not-in',
|
|
12
|
+
'array-contains',
|
|
13
|
+
'array-contains-any',
|
|
14
|
+
];
|
|
15
|
+
/** Ops that accept an array of values. The value editor in the
|
|
16
|
+
* bundled <QueryBuilder> parses the input as JSON for these. */
|
|
17
|
+
export const MULTI_VALUE_OPS = new Set([
|
|
18
|
+
'in',
|
|
19
|
+
'not-in',
|
|
20
|
+
'array-contains-any',
|
|
21
|
+
]);
|
|
22
|
+
const EMPTY_STATE = { conditions: [] };
|
|
23
|
+
/**
|
|
24
|
+
* Headless query-builder state machine. Single-level — no nested
|
|
25
|
+
* `and()`/`or()` groups in v1. Consumers compose the state into a
|
|
26
|
+
* Firestore `Query` via `buildQuery(base)` and feed that into
|
|
27
|
+
* `useDocumentList` / `useFirestoreCollection`.
|
|
28
|
+
*/
|
|
29
|
+
export function useQueryBuilder(options = {}) {
|
|
30
|
+
const [state, setState] = useState(() => ({
|
|
31
|
+
...EMPTY_STATE,
|
|
32
|
+
...options.initial,
|
|
33
|
+
conditions: options.initial?.conditions ?? [],
|
|
34
|
+
}));
|
|
35
|
+
const addCondition = useCallback((c) => {
|
|
36
|
+
setState((prev) => ({
|
|
37
|
+
...prev,
|
|
38
|
+
conditions: [
|
|
39
|
+
...prev.conditions,
|
|
40
|
+
{
|
|
41
|
+
id: crypto.randomUUID(),
|
|
42
|
+
field: c?.field ?? '',
|
|
43
|
+
op: c?.op ?? '==',
|
|
44
|
+
value: c?.value ?? '',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
}));
|
|
48
|
+
}, []);
|
|
49
|
+
const updateCondition = useCallback((id, patch) => {
|
|
50
|
+
setState((prev) => ({
|
|
51
|
+
...prev,
|
|
52
|
+
conditions: prev.conditions.map((c) => c.id === id ? { ...c, ...patch } : c),
|
|
53
|
+
}));
|
|
54
|
+
}, []);
|
|
55
|
+
const removeCondition = useCallback((id) => {
|
|
56
|
+
setState((prev) => ({
|
|
57
|
+
...prev,
|
|
58
|
+
conditions: prev.conditions.filter((c) => c.id !== id),
|
|
59
|
+
}));
|
|
60
|
+
}, []);
|
|
61
|
+
const setOrderBy = useCallback((next) => {
|
|
62
|
+
setState((prev) => ({ ...prev, orderBy: next }));
|
|
63
|
+
}, []);
|
|
64
|
+
const setLimit = useCallback((next) => {
|
|
65
|
+
setState((prev) => ({ ...prev, limit: next }));
|
|
66
|
+
}, []);
|
|
67
|
+
const reset = useCallback(() => {
|
|
68
|
+
setState(EMPTY_STATE);
|
|
69
|
+
}, []);
|
|
70
|
+
const buildQuery = useCallback((base) => {
|
|
71
|
+
const constraints = [];
|
|
72
|
+
const orderByConstraints = [];
|
|
73
|
+
const limitConstraints = [];
|
|
74
|
+
for (const cond of state.conditions) {
|
|
75
|
+
if (!cond.field)
|
|
76
|
+
continue;
|
|
77
|
+
constraints.push(whereFn(cond.field, cond.op, cond.value));
|
|
78
|
+
}
|
|
79
|
+
if (state.orderBy && state.orderBy.field) {
|
|
80
|
+
orderByConstraints.push(orderByFn(state.orderBy.field, state.orderBy.direction));
|
|
81
|
+
}
|
|
82
|
+
if (typeof state.limit === 'number' && state.limit > 0) {
|
|
83
|
+
limitConstraints.push(limitFn(state.limit));
|
|
84
|
+
}
|
|
85
|
+
const all = [...constraints, ...orderByConstraints, ...limitConstraints];
|
|
86
|
+
if (all.length === 0)
|
|
87
|
+
return base;
|
|
88
|
+
return queryFn(base, ...all);
|
|
89
|
+
}, [state]);
|
|
90
|
+
return useMemo(() => ({
|
|
91
|
+
...state,
|
|
92
|
+
addCondition,
|
|
93
|
+
updateCondition,
|
|
94
|
+
removeCondition,
|
|
95
|
+
setOrderBy,
|
|
96
|
+
setLimit,
|
|
97
|
+
reset,
|
|
98
|
+
buildQuery,
|
|
99
|
+
}), [
|
|
100
|
+
state,
|
|
101
|
+
addCondition,
|
|
102
|
+
updateCondition,
|
|
103
|
+
removeCondition,
|
|
104
|
+
setOrderBy,
|
|
105
|
+
setLimit,
|
|
106
|
+
reset,
|
|
107
|
+
buildQuery,
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=useQueryBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useQueryBuilder.js","sourceRoot":"","sources":["../../../src/firestore/hooks/useQueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,KAAK,IAAI,OAAO,EAChB,OAAO,IAAI,SAAS,EACpB,KAAK,IAAI,OAAO,EAChB,KAAK,IAAI,OAAO,GAKjB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,CAAC,MAAM,SAAS,GAAuB;IAC3C,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,gBAAgB;IAChB,oBAAoB;CACZ,CAAC;AAEX;iEACiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAyB,IAAI,GAAG,CAAU;IACpE,IAAI;IACJ,QAAQ;IACR,oBAAoB;CACrB,CAAC,CAAC;AAoCH,MAAM,WAAW,GAAsB,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;AAO1D;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAkC,EAAE;IAEpC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAoB,GAAG,EAAE,CAAC,CAAC;QAC3D,GAAG,WAAW;QACd,GAAG,OAAO,CAAC,OAAO;QAClB,UAAU,EA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,CAAC,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YACvD,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,GAAG,GAAG,CAAC,GAAG,WAAW,EAAE,GAAG,kBAAkB,EAAE,GAAG,gBAAgB,CAAC,CAAC;QACzE,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAa,CAAC;QAC3C,OAAO,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC;IAC/B,CAAC,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,KAAK;QACR,YAAY;QACZ,eAAe;QACf,eAAe;QACf,UAAU;QACV,QAAQ;QACR,KAAK;QACL,UAAU;KACX,CAAC,EACF;QACE,KAAK;QACL,YAAY;QACZ,eAAe;QACf,eAAe;QACf,UAAU;QACV,QAAQ;QACR,KAAK;QACL,UAAU;KACX,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CollectionReference, DocumentReference } from 'pyric/firestore';
|
|
2
|
+
export interface RecursiveDeleteProgress {
|
|
3
|
+
/** Total nodes deleted so far. */
|
|
4
|
+
deletedCount: number;
|
|
5
|
+
/** True for the final emission. */
|
|
6
|
+
done: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Implementation injected by the consumer. The library doesn't ship
|
|
10
|
+
* one — sandbox-backed apps usually walk `pyric/sandbox`'s in-process
|
|
11
|
+
* tree; production apps usually call a Cloud Function. Either way,
|
|
12
|
+
* `start` returns an async iterator emitting progress.
|
|
13
|
+
*/
|
|
14
|
+
export interface RecursiveDeleteImpl {
|
|
15
|
+
start: (target: DocumentReference | CollectionReference) => AsyncIterableIterator<RecursiveDeleteProgress>;
|
|
16
|
+
}
|
|
17
|
+
export interface UseRecursiveDeleteResult {
|
|
18
|
+
/** Run the delete. Resolves when the iterator signals `done`. */
|
|
19
|
+
delete: (target: DocumentReference | CollectionReference) => Promise<void>;
|
|
20
|
+
/** Number of nodes deleted in the current/last run. */
|
|
21
|
+
progress: number;
|
|
22
|
+
/** True while an iteration is in flight. */
|
|
23
|
+
isRunning: boolean;
|
|
24
|
+
/** Error thrown by the iterator, if any. Cleared at the start of
|
|
25
|
+
* the next call. */
|
|
26
|
+
error: Error | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Drive a {@link RecursiveDeleteImpl} from a React component. Tracks
|
|
30
|
+
* progress + running state so the consumer can render a progress
|
|
31
|
+
* indicator. Errors are caught and surfaced via the returned state,
|
|
32
|
+
* not thrown.
|
|
33
|
+
*
|
|
34
|
+
* Stale-run protection: if the component remounts (or the user
|
|
35
|
+
* cancels and starts a new run) before a previous iteration
|
|
36
|
+
* finishes, the older run's progress updates are dropped via a
|
|
37
|
+
* generation token.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useRecursiveDelete(impl: RecursiveDeleteImpl): UseRecursiveDeleteResult;
|
|
40
|
+
//# sourceMappingURL=useRecursiveDelete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRecursiveDelete.d.ts","sourceRoot":"","sources":["../../../src/firestore/hooks/useRecursiveDelete.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,MAAM,WAAW,uBAAuB;IACtC,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,CACL,MAAM,EAAE,iBAAiB,GAAG,mBAAmB,KAC5C,qBAAqB,CAAC,uBAAuB,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,wBAAwB;IACvC,iEAAiE;IACjE,MAAM,EAAE,CAAC,MAAM,EAAE,iBAAiB,GAAG,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB;yBACqB;IACrB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,mBAAmB,GACxB,wBAAwB,CA6B1B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Drive a {@link RecursiveDeleteImpl} from a React component. Tracks
|
|
4
|
+
* progress + running state so the consumer can render a progress
|
|
5
|
+
* indicator. Errors are caught and surfaced via the returned state,
|
|
6
|
+
* not thrown.
|
|
7
|
+
*
|
|
8
|
+
* Stale-run protection: if the component remounts (or the user
|
|
9
|
+
* cancels and starts a new run) before a previous iteration
|
|
10
|
+
* finishes, the older run's progress updates are dropped via a
|
|
11
|
+
* generation token.
|
|
12
|
+
*/
|
|
13
|
+
export function useRecursiveDelete(impl) {
|
|
14
|
+
const [progress, setProgress] = useState(0);
|
|
15
|
+
const [isRunning, setIsRunning] = useState(false);
|
|
16
|
+
const [error, setError] = useState(undefined);
|
|
17
|
+
const generationRef = useRef(0);
|
|
18
|
+
const del = useCallback(async (target) => {
|
|
19
|
+
const myGen = ++generationRef.current;
|
|
20
|
+
setProgress(0);
|
|
21
|
+
setError(undefined);
|
|
22
|
+
setIsRunning(true);
|
|
23
|
+
try {
|
|
24
|
+
for await (const evt of impl.start(target)) {
|
|
25
|
+
if (myGen !== generationRef.current)
|
|
26
|
+
return;
|
|
27
|
+
setProgress(evt.deletedCount);
|
|
28
|
+
if (evt.done)
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
if (myGen !== generationRef.current)
|
|
34
|
+
return;
|
|
35
|
+
setError(e instanceof Error ? e : new Error(String(e)));
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
if (myGen === generationRef.current)
|
|
39
|
+
setIsRunning(false);
|
|
40
|
+
}
|
|
41
|
+
}, [impl]);
|
|
42
|
+
return { delete: del, progress, isRunning, error };
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=useRecursiveDelete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRecursiveDelete.js","sourceRoot":"","sources":["../../../src/firestore/hooks/useRecursiveDelete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAkCtD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAyB;IAEzB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAoB,SAAS,CAAC,CAAC;IACjE,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAEhC,MAAM,GAAG,GAAG,WAAW,CACrB,KAAK,EAAE,MAA+C,EAAE,EAAE;QACxD,MAAM,KAAK,GAAG,EAAE,aAAa,CAAC,OAAO,CAAC;QACtC,WAAW,CAAC,CAAC,CAAC,CAAC;QACf,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpB,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,IAAI,CAAC;YACH,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3C,IAAI,KAAK,KAAK,aAAa,CAAC,OAAO;oBAAE,OAAO;gBAC5C,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;gBAC9B,IAAI,GAAG,CAAC,IAAI;oBAAE,MAAM;YACtB,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,KAAK,KAAK,aAAa,CAAC,OAAO;gBAAE,OAAO;YAC5C,QAAQ,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;gBAAS,CAAC;YACT,IAAI,KAAK,KAAK,aAAa,CAAC,OAAO;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC,EACD,CAAC,IAAI,CAAC,CACP,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type CollectionReference, type DocumentReference, type Firestore, type QueryDocumentSnapshot } from 'pyric/firestore';
|
|
2
|
+
export type BrowseLocation = {
|
|
3
|
+
kind: 'root';
|
|
4
|
+
} | {
|
|
5
|
+
kind: 'document';
|
|
6
|
+
ref: DocumentReference;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'collection';
|
|
9
|
+
ref: CollectionReference;
|
|
10
|
+
};
|
|
11
|
+
export interface UseReferencePickerOptions {
|
|
12
|
+
firestore: Firestore;
|
|
13
|
+
/**
|
|
14
|
+
* Lister for subcollections under a parent (or root when
|
|
15
|
+
* `parent == null`). The library does not ship a default — see
|
|
16
|
+
* `useCollectionList` for the same rationale (the modular Web SDK
|
|
17
|
+
* can't enumerate collections client-side).
|
|
18
|
+
*/
|
|
19
|
+
listCollections: (firestore: Firestore, parent: DocumentReference | null) => Promise<CollectionReference[]>;
|
|
20
|
+
/** Default page size for the document list when browsing inside
|
|
21
|
+
* a collection. Default 20. */
|
|
22
|
+
pageSize?: number;
|
|
23
|
+
/** Initial value to pre-populate the text input + parse. */
|
|
24
|
+
initialPath?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface UseReferencePickerResult {
|
|
27
|
+
/** Current text input value. */
|
|
28
|
+
pathInput: string;
|
|
29
|
+
/** Validated `DocumentReference` parsed from `pathInput`, or
|
|
30
|
+
* `null` when the path is empty / invalid. */
|
|
31
|
+
reference: DocumentReference | null;
|
|
32
|
+
/** Parse error, or `null` when valid. */
|
|
33
|
+
error: string | null;
|
|
34
|
+
/** Current browse position in the tree. */
|
|
35
|
+
browseLocation: BrowseLocation;
|
|
36
|
+
/** Whether `drillBack` has anywhere to go. */
|
|
37
|
+
canDrillBack: boolean;
|
|
38
|
+
/** Collections available at the current browse level. Populated
|
|
39
|
+
* when `browseLocation` is `root` or `document`. */
|
|
40
|
+
collections: CollectionReference[];
|
|
41
|
+
/** First page of documents in the current collection — populated
|
|
42
|
+
* when `browseLocation.kind === 'collection'`. */
|
|
43
|
+
documents: QueryDocumentSnapshot[];
|
|
44
|
+
/** True while a fetch is in flight. */
|
|
45
|
+
isLoading: boolean;
|
|
46
|
+
/** Set the text-input value. Parses on every change. */
|
|
47
|
+
setPathInput: (path: string) => void;
|
|
48
|
+
/** Commit a chosen reference. Updates `pathInput` (and therefore
|
|
49
|
+
* the parsed `reference`). */
|
|
50
|
+
pick: (ref: DocumentReference) => void;
|
|
51
|
+
/** Drill into a collection — fetches its first page of documents. */
|
|
52
|
+
drillIntoCollection: (ref: CollectionReference) => void;
|
|
53
|
+
/** Drill into a document — fetches its subcollections. */
|
|
54
|
+
drillIntoDocument: (ref: DocumentReference) => void;
|
|
55
|
+
/** Step back one level. No-op when at root. */
|
|
56
|
+
drillBack: () => void;
|
|
57
|
+
/** Clear the path input + reset browse to root. */
|
|
58
|
+
clear: () => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Picker state machine. Browses a Firestore tree level-by-level
|
|
62
|
+
* (root → collection → document → collection → ...), maintains a
|
|
63
|
+
* separately-validated text-input path, and commits a chosen
|
|
64
|
+
* reference via `pick`.
|
|
65
|
+
*
|
|
66
|
+
* Headless — consumers compose the resulting state into their own
|
|
67
|
+
* UI, or use the bundled `<ReferencePicker>` component.
|
|
68
|
+
*/
|
|
69
|
+
export declare function useReferencePicker({ firestore, listCollections, pageSize, initialPath, }: UseReferencePickerOptions): UseReferencePickerResult;
|
|
70
|
+
//# sourceMappingURL=useReferencePicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferencePicker.d.ts","sourceRoot":"","sources":["../../../src/firestore/hooks/useReferencePicker.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,iBAAiB,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAErD,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,SAAS,CAAC;IACrB;;;;;OAKG;IACH,eAAe,EAAE,CACf,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,iBAAiB,GAAG,IAAI,KAC7B,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACpC;oCACgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB;IACvC,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB;mDAC+C;IAC/C,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC,yCAAyC;IACzC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,2CAA2C;IAC3C,cAAc,EAAE,cAAc,CAAC;IAC/B,8CAA8C;IAC9C,YAAY,EAAE,OAAO,CAAC;IACtB;yDACqD;IACrD,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC;uDACmD;IACnD,SAAS,EAAE,qBAAqB,EAAE,CAAC;IACnC,uCAAuC;IACvC,SAAS,EAAE,OAAO,CAAC;IAEnB,wDAAwD;IACxD,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC;mCAC+B;IAC/B,IAAI,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACvC,qEAAqE;IACrE,mBAAmB,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACxD,0DAA0D;IAC1D,iBAAiB,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACpD,+CAA+C;IAC/C,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,mDAAmD;IACnD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AA8BD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,EACT,eAAe,EACf,QAAa,EACb,WAAgB,GACjB,EAAE,yBAAyB,GAAG,wBAAwB,CAiHtD"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { doc as docFn, getDocs, limit as limitFn, query as queryFn, } from 'pyric/firestore';
|
|
3
|
+
function parseReferencePath(firestore, path) {
|
|
4
|
+
const trimmed = path.trim();
|
|
5
|
+
if (!trimmed)
|
|
6
|
+
return { ref: null, error: null };
|
|
7
|
+
const segments = trimmed.split('/').filter(Boolean);
|
|
8
|
+
if (segments.length === 0)
|
|
9
|
+
return { ref: null, error: 'Empty path' };
|
|
10
|
+
if (segments.length % 2 !== 0)
|
|
11
|
+
return { ref: null, error: 'Must point to a document (even segment count)' };
|
|
12
|
+
try {
|
|
13
|
+
const ref = docFn(firestore, trimmed);
|
|
14
|
+
return { ref, error: null };
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
return {
|
|
18
|
+
ref: null,
|
|
19
|
+
error: e instanceof Error ? e.message : 'Invalid path',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const ROOT = { kind: 'root' };
|
|
24
|
+
/**
|
|
25
|
+
* Picker state machine. Browses a Firestore tree level-by-level
|
|
26
|
+
* (root → collection → document → collection → ...), maintains a
|
|
27
|
+
* separately-validated text-input path, and commits a chosen
|
|
28
|
+
* reference via `pick`.
|
|
29
|
+
*
|
|
30
|
+
* Headless — consumers compose the resulting state into their own
|
|
31
|
+
* UI, or use the bundled `<ReferencePicker>` component.
|
|
32
|
+
*/
|
|
33
|
+
export function useReferencePicker({ firestore, listCollections, pageSize = 20, initialPath = '', }) {
|
|
34
|
+
const [pathInput, setPathInputState] = useState(initialPath);
|
|
35
|
+
const [browse, setBrowse] = useState({
|
|
36
|
+
current: ROOT,
|
|
37
|
+
history: [],
|
|
38
|
+
});
|
|
39
|
+
const [collections, setCollections] = useState([]);
|
|
40
|
+
const [documents, setDocuments] = useState([]);
|
|
41
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
42
|
+
const parsed = useMemo(() => parseReferencePath(firestore, pathInput), [firestore, pathInput]);
|
|
43
|
+
// Keep the injected `listCollections` in a ref so the fetch
|
|
44
|
+
// effect's deps don't include it. Consumers commonly pass an
|
|
45
|
+
// inline arrow function whose identity churns on every render;
|
|
46
|
+
// depending on it would loop the effect forever.
|
|
47
|
+
const listCollectionsRef = useRef(listCollections);
|
|
48
|
+
listCollectionsRef.current = listCollections;
|
|
49
|
+
// Re-fetch contents whenever the browse location changes.
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
let cancelled = false;
|
|
52
|
+
setIsLoading(true);
|
|
53
|
+
const loc = browse.current;
|
|
54
|
+
if (loc.kind === 'root' || loc.kind === 'document') {
|
|
55
|
+
const parent = loc.kind === 'document' ? loc.ref : null;
|
|
56
|
+
setDocuments([]);
|
|
57
|
+
listCollectionsRef.current(firestore, parent)
|
|
58
|
+
.then((cs) => {
|
|
59
|
+
if (cancelled)
|
|
60
|
+
return;
|
|
61
|
+
setCollections(cs);
|
|
62
|
+
setIsLoading(false);
|
|
63
|
+
})
|
|
64
|
+
.catch(() => {
|
|
65
|
+
if (cancelled)
|
|
66
|
+
return;
|
|
67
|
+
setCollections([]);
|
|
68
|
+
setIsLoading(false);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
setCollections([]);
|
|
73
|
+
const pagedQuery = queryFn(loc.ref, limitFn(pageSize));
|
|
74
|
+
getDocs(pagedQuery)
|
|
75
|
+
.then((snap) => {
|
|
76
|
+
if (cancelled)
|
|
77
|
+
return;
|
|
78
|
+
setDocuments([...snap.docs]);
|
|
79
|
+
setIsLoading(false);
|
|
80
|
+
})
|
|
81
|
+
.catch(() => {
|
|
82
|
+
if (cancelled)
|
|
83
|
+
return;
|
|
84
|
+
setDocuments([]);
|
|
85
|
+
setIsLoading(false);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return () => {
|
|
89
|
+
cancelled = true;
|
|
90
|
+
};
|
|
91
|
+
}, [browse.current, firestore, pageSize]);
|
|
92
|
+
const setPathInput = useCallback((path) => {
|
|
93
|
+
setPathInputState(path);
|
|
94
|
+
}, []);
|
|
95
|
+
const pick = useCallback((ref) => {
|
|
96
|
+
setPathInputState(ref.path);
|
|
97
|
+
}, []);
|
|
98
|
+
const drillIntoCollection = useCallback((ref) => {
|
|
99
|
+
setBrowse((prev) => ({
|
|
100
|
+
current: { kind: 'collection', ref },
|
|
101
|
+
history: [...prev.history, prev.current],
|
|
102
|
+
}));
|
|
103
|
+
}, []);
|
|
104
|
+
const drillIntoDocument = useCallback((ref) => {
|
|
105
|
+
setBrowse((prev) => ({
|
|
106
|
+
current: { kind: 'document', ref },
|
|
107
|
+
history: [...prev.history, prev.current],
|
|
108
|
+
}));
|
|
109
|
+
}, []);
|
|
110
|
+
const drillBack = useCallback(() => {
|
|
111
|
+
setBrowse((prev) => {
|
|
112
|
+
if (prev.history.length === 0)
|
|
113
|
+
return prev;
|
|
114
|
+
const next = prev.history.slice(0, -1);
|
|
115
|
+
const popped = prev.history[prev.history.length - 1];
|
|
116
|
+
return { current: popped, history: next };
|
|
117
|
+
});
|
|
118
|
+
}, []);
|
|
119
|
+
const clear = useCallback(() => {
|
|
120
|
+
setPathInputState('');
|
|
121
|
+
setBrowse({ current: ROOT, history: [] });
|
|
122
|
+
}, []);
|
|
123
|
+
return {
|
|
124
|
+
pathInput,
|
|
125
|
+
reference: parsed.ref,
|
|
126
|
+
error: parsed.error,
|
|
127
|
+
browseLocation: browse.current,
|
|
128
|
+
canDrillBack: browse.history.length > 0,
|
|
129
|
+
collections,
|
|
130
|
+
documents,
|
|
131
|
+
isLoading,
|
|
132
|
+
setPathInput,
|
|
133
|
+
pick,
|
|
134
|
+
drillIntoCollection,
|
|
135
|
+
drillIntoDocument,
|
|
136
|
+
drillBack,
|
|
137
|
+
clear,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=useReferencePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferencePicker.js","sourceRoot":"","sources":["../../../src/firestore/hooks/useReferencePicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EACL,GAAG,IAAI,KAAK,EACZ,OAAO,EACP,KAAK,IAAI,OAAO,EAChB,KAAK,IAAI,OAAO,GAKjB,MAAM,iBAAiB,CAAC;AAmEzB,SAAS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;IAC5C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,SAAS;QACT,SAAS,EAAE,MAAM,CAAC,GAAG;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,cAAc,EAAE,MAAM,CAAC,OAAO;QAC9B,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QACvC,WAAW;QACX,SAAS;QACT,SAAS;QACT,YAAY;QACZ,IAAI;QACJ,mBAAmB;QACnB,iBAAiB;QACjB,SAAS;QACT,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON import parsing + collision detection for the Firestore "import JSON
|
|
3
|
+
* into a collection" flow.
|
|
4
|
+
*
|
|
5
|
+
* Pure, no React, no I/O: `parseImport` takes the raw pasted/loaded text and
|
|
6
|
+
* returns the documents it would create plus any per-item errors; the caller
|
|
7
|
+
* (the Studio pane) owns showing the "will create N documents" preview,
|
|
8
|
+
* disclosing a collision policy ONLY when {@link detectCollisions} finds an
|
|
9
|
+
* overlap, and actually writing through the existing Firestore write handle.
|
|
10
|
+
*
|
|
11
|
+
* Two accepted shapes:
|
|
12
|
+
* 1. A map: `{ "docId": { ...fields }, "docId2": { ...fields } }`
|
|
13
|
+
* — each key becomes the document id (validated), each value its data.
|
|
14
|
+
* 2. An array: `[ { ...fields }, { ...fields } ]`
|
|
15
|
+
* — each element becomes a document with `id: null` (auto-id at write
|
|
16
|
+
* time), since a bare array carries no natural id.
|
|
17
|
+
*/
|
|
18
|
+
/** One document to create. `id === null` means "let Firestore auto-id it"
|
|
19
|
+
* (only produced by the array shape when no `generateId` option is given —
|
|
20
|
+
* a map key is always a chosen id). */
|
|
21
|
+
export interface ParsedImportDoc {
|
|
22
|
+
id: string | null;
|
|
23
|
+
data: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
export interface ParseImportOptions {
|
|
26
|
+
/** When provided, array-shape entries get their auto-id GENERATED AT PARSE
|
|
27
|
+
* TIME (instead of `id: null` / addDoc-at-write-time). Fixing ids at parse
|
|
28
|
+
* makes a retry after a partial failure idempotent: the same parse's ids
|
|
29
|
+
* are reused, so re-running the import cannot duplicate already-written
|
|
30
|
+
* docs. Use {@link firestoreAutoId} for prod-parity ids. */
|
|
31
|
+
generateId?: () => string;
|
|
32
|
+
}
|
|
33
|
+
/** A Firestore-style 20-char auto id (same alphabet/length the SDK uses). */
|
|
34
|
+
export declare function firestoreAutoId(): string;
|
|
35
|
+
export interface ParseImportResult {
|
|
36
|
+
docs: ParsedImportDoc[];
|
|
37
|
+
/** Human-readable problems found while parsing. A non-empty `errors` does
|
|
38
|
+
* NOT necessarily mean `docs` is empty — the parser is per-item tolerant
|
|
39
|
+
* so one bad entry doesn't block the rest; the caller decides whether to
|
|
40
|
+
* block on any error or proceed with the valid subset. */
|
|
41
|
+
errors: string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Parse raw JSON text into the documents it would create. Never throws —
|
|
45
|
+
* a JSON syntax error or a wrong top-level shape becomes an entry in
|
|
46
|
+
* `errors` with an empty `docs` array.
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseImport(input: string, options?: ParseImportOptions): ParseImportResult;
|
|
49
|
+
/**
|
|
50
|
+
* Ids in `docs` (map-shape entries only — `id !== null`) that already exist
|
|
51
|
+
* in `existingIds`. The UI shows the skip-or-overwrite policy choice ONLY
|
|
52
|
+
* when this returns a non-empty list.
|
|
53
|
+
*/
|
|
54
|
+
export declare function detectCollisions(existingIds: readonly string[], docs: readonly ParsedImportDoc[]): string[];
|
|
55
|
+
//# sourceMappingURL=parseImport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseImport.d.ts","sourceRoot":"","sources":["../../../src/firestore/import/parseImport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH;;wCAEwC;AACxC,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;iEAI6D;IAC7D,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC;CAC3B;AAID,6EAA6E;AAC7E,wBAAgB,eAAe,IAAI,MAAM,CAMxC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB;;;+DAG2D;IAC3D,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAMD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,CA+C1F;AAQD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,IAAI,EAAE,SAAS,eAAe,EAAE,GAC/B,MAAM,EAAE,CAOV"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON import parsing + collision detection for the Firestore "import JSON
|
|
3
|
+
* into a collection" flow.
|
|
4
|
+
*
|
|
5
|
+
* Pure, no React, no I/O: `parseImport` takes the raw pasted/loaded text and
|
|
6
|
+
* returns the documents it would create plus any per-item errors; the caller
|
|
7
|
+
* (the Studio pane) owns showing the "will create N documents" preview,
|
|
8
|
+
* disclosing a collision policy ONLY when {@link detectCollisions} finds an
|
|
9
|
+
* overlap, and actually writing through the existing Firestore write handle.
|
|
10
|
+
*
|
|
11
|
+
* Two accepted shapes:
|
|
12
|
+
* 1. A map: `{ "docId": { ...fields }, "docId2": { ...fields } }`
|
|
13
|
+
* — each key becomes the document id (validated), each value its data.
|
|
14
|
+
* 2. An array: `[ { ...fields }, { ...fields } ]`
|
|
15
|
+
* — each element becomes a document with `id: null` (auto-id at write
|
|
16
|
+
* time), since a bare array carries no natural id.
|
|
17
|
+
*/
|
|
18
|
+
import { validateDocumentId } from '../validation/ids.js';
|
|
19
|
+
const AUTO_ID_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
20
|
+
/** A Firestore-style 20-char auto id (same alphabet/length the SDK uses). */
|
|
21
|
+
export function firestoreAutoId() {
|
|
22
|
+
let id = '';
|
|
23
|
+
for (let i = 0; i < 20; i++) {
|
|
24
|
+
id += AUTO_ID_ALPHABET.charAt(Math.floor(Math.random() * AUTO_ID_ALPHABET.length));
|
|
25
|
+
}
|
|
26
|
+
return id;
|
|
27
|
+
}
|
|
28
|
+
function isPlainObject(value) {
|
|
29
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parse raw JSON text into the documents it would create. Never throws —
|
|
33
|
+
* a JSON syntax error or a wrong top-level shape becomes an entry in
|
|
34
|
+
* `errors` with an empty `docs` array.
|
|
35
|
+
*/
|
|
36
|
+
export function parseImport(input, options) {
|
|
37
|
+
const trimmed = input.trim();
|
|
38
|
+
if (trimmed === '') {
|
|
39
|
+
return { docs: [], errors: ['Input is empty'] };
|
|
40
|
+
}
|
|
41
|
+
let parsed;
|
|
42
|
+
try {
|
|
43
|
+
parsed = JSON.parse(trimmed);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
return { docs: [], errors: [`Invalid JSON: ${e instanceof Error ? e.message : String(e)}`] };
|
|
47
|
+
}
|
|
48
|
+
const docs = [];
|
|
49
|
+
const errors = [];
|
|
50
|
+
if (Array.isArray(parsed)) {
|
|
51
|
+
parsed.forEach((item, i) => {
|
|
52
|
+
if (!isPlainObject(item)) {
|
|
53
|
+
errors.push(`Item ${i}: expected an object, got ${describeType(item)}`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
docs.push({ id: options?.generateId ? options.generateId() : null, data: item });
|
|
57
|
+
});
|
|
58
|
+
return { docs, errors };
|
|
59
|
+
}
|
|
60
|
+
if (isPlainObject(parsed)) {
|
|
61
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
62
|
+
const idError = validateDocumentId(key);
|
|
63
|
+
if (idError) {
|
|
64
|
+
errors.push(`"${key}": invalid document id — ${idError}`);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (!isPlainObject(value)) {
|
|
68
|
+
errors.push(`"${key}": expected an object of fields, got ${describeType(value)}`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
docs.push({ id: key, data: value });
|
|
72
|
+
}
|
|
73
|
+
return { docs, errors };
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
docs: [],
|
|
77
|
+
errors: ['Input must be a JSON object mapping docId -> fields, or an array of objects'],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function describeType(value) {
|
|
81
|
+
if (value === null)
|
|
82
|
+
return 'null';
|
|
83
|
+
if (Array.isArray(value))
|
|
84
|
+
return 'an array';
|
|
85
|
+
return typeof value;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Ids in `docs` (map-shape entries only — `id !== null`) that already exist
|
|
89
|
+
* in `existingIds`. The UI shows the skip-or-overwrite policy choice ONLY
|
|
90
|
+
* when this returns a non-empty list.
|
|
91
|
+
*/
|
|
92
|
+
export function detectCollisions(existingIds, docs) {
|
|
93
|
+
const existing = new Set(existingIds);
|
|
94
|
+
const collisions = [];
|
|
95
|
+
for (const doc of docs) {
|
|
96
|
+
if (doc.id !== null && existing.has(doc.id))
|
|
97
|
+
collisions.push(doc.id);
|
|
98
|
+
}
|
|
99
|
+
return collisions;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=parseImport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseImport.js","sourceRoot":"","sources":["../../../src/firestore/import/parseImport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE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I,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO;QACL,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,CAAC,6EAA6E,CAAC;KACxF,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC;IAC5C,OAAO,OAAO,KAAK,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAA8B,EAC9B,IAAgC;IAEhC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IACtC,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,CAAC,EAAE,KAAK,IAAI,IAAI,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './hooks/index.js';
|
|
2
|
+
export { FirestoreApiProvider, useFirestoreApi, type FirestoreApi, } from './firestoreApi.js';
|
|
3
|
+
export { inferType, asVectorView, vectorPreview, truncateVectorsForDisplay, type FieldType, type VectorView, } from './types.js';
|
|
4
|
+
export { defaultFieldEditors, mergeFieldEditors, } from './fieldEditors/registry.js';
|
|
5
|
+
export type { FieldEditorContract, FieldEditorRegistry, FieldDisplayProps, FieldEditProps, } from './fieldEditors/types.js';
|
|
6
|
+
export { FieldRenderer, type FieldRendererProps } from './components/FieldRenderer.js';
|
|
7
|
+
export { DocumentPreview, type DocumentPreviewProps, } from './components/DocumentPreview.js';
|
|
8
|
+
export type { FieldNode, EditorTree, DocumentEditorAction, DocumentEditorState, } from './reducers/types.js';
|
|
9
|
+
export { validateLeaf, validateTree } from './reducers/validation.js';
|
|
10
|
+
export { treeFromData, treeToData } from './reducers/tree.js';
|
|
11
|
+
export { initState, reducer } from './reducers/documentEditor.js';
|
|
12
|
+
export { DocumentEditor, DocumentEditorRoot, DocumentEditorFields, useDocumentEditorContext, type DocumentEditorRootProps, } from './components/DocumentEditor.js';
|
|
13
|
+
export { CollectionList, type CollectionListProps } from './components/CollectionList.js';
|
|
14
|
+
export { DocumentList, type DocumentListProps } from './components/DocumentList.js';
|
|
15
|
+
export { DeleteWithConfirm, type DeleteWithConfirmProps, } from './components/DeleteWithConfirm.js';
|
|
16
|
+
export { ReferencePicker, type ReferencePickerProps, } from './components/ReferencePicker.js';
|
|
17
|
+
export { QueryBuilder, type QueryBuilderProps, } from './components/QueryBuilder.js';
|
|
18
|
+
export { validateCollectionId, validateDocumentId } from './validation/ids.js';
|
|
19
|
+
export { parseImport, detectCollisions, firestoreAutoId, type ParsedImportDoc, type ParseImportResult, type ParseImportOptions, } from './import/parseImport.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/firestore/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AAIjC,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,KAAK,YAAY,GAClB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,SAAS,EACT,YAAY,EACZ,aAAa,EACb,yBAAyB,EACzB,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,KAAK,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