synapse-react-client 4.0.42 → 4.0.44
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/dist/SWC.index.js +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementList.d.ts +6 -20
- package/dist/components/AccessRequirementList/AccessRequirementList.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementList.js +165 -159
- package/dist/components/AccessRequirementList/AccessRequirementList.js.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementListItem.d.ts +3 -2
- package/dist/components/AccessRequirementList/AccessRequirementListItem.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementListItem.js +23 -22
- package/dist/components/AccessRequirementList/AccessRequirementListItem.js.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementListUtils.d.ts +4 -3
- package/dist/components/AccessRequirementList/AccessRequirementListUtils.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementListUtils.js +6 -4
- package/dist/components/AccessRequirementList/AccessRequirementListUtils.js.map +1 -1
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/JsonSchemaRequestWizard.d.ts +22 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/JsonSchemaRequestWizard.d.ts.map +1 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/JsonSchemaRequestWizard.js +166 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/JsonSchemaRequestWizard.js.map +1 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/RequesterInformationFields.d.ts +18 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/RequesterInformationFields.d.ts.map +1 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/RequesterInformationFields.js +91 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/RequesterInformationFields.js.map +1 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/requesterInformation.d.ts +33 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/requesterInformation.d.ts.map +1 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/requesterInformation.js +49 -0
- package/dist/components/AccessRequirementList/JsonSchemaAccessRequirementRequestFlow/requesterInformation.js.map +1 -0
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/CancelRequestDataAccess.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/CancelRequestDataAccess.js +26 -42
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/CancelRequestDataAccess.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/DataAccessRequestAccessorsFilesForm/DataAccessRequestAccessorsFilesForm.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/DataAccessRequestAccessorsFilesForm/DataAccessRequestAccessorsFilesForm.js +140 -155
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/DataAccessRequestAccessorsFilesForm/DataAccessRequestAccessorsFilesForm.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/EDucPreviewStep/EDucPreviewStep.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/EDucPreviewStep/EDucPreviewStep.js +43 -60
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/EDucPreviewStep/EDucPreviewStep.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManagedACTAccessRequirementFormWikiWrapper.d.ts +4 -5
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManagedACTAccessRequirementFormWikiWrapper.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManagedACTAccessRequirementFormWikiWrapper.js +5 -5
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManagedACTAccessRequirementFormWikiWrapper.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManualUploadDucStep/ManualUploadDucStep.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManualUploadDucStep/ManualUploadDucStep.js +88 -103
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManualUploadDucStep/ManualUploadDucStep.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/RequestDataAccessSuccess.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/RequestDataAccessSuccess.js +14 -30
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/RequestDataAccessSuccess.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/{ManagedACTAccessRequirementItem.d.ts → RequestableAccessRequirementItem.d.ts} +9 -8
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/RequestableAccessRequirementItem.d.ts.map +1 -0
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/{ManagedACTAccessRequirementItem.js → RequestableAccessRequirementItem.js} +16 -16
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/RequestableAccessRequirementItem.js.map +1 -0
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/{ManagedACTAccessRequirementItemView.d.ts → RequestableAccessRequirementItemView.d.ts} +5 -5
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/RequestableAccessRequirementItemView.d.ts.map +1 -0
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/{ManagedACTAccessRequirementItemView.js → RequestableAccessRequirementItemView.js} +3 -4
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/RequestableAccessRequirementItemView.js.map +1 -0
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ResearchProjectForm/ResearchProjectForm.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ResearchProjectForm/ResearchProjectForm.js +94 -110
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ResearchProjectForm/ResearchProjectForm.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ReviewDucStep/ReviewDucStep.d.ts +0 -2
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ReviewDucStep/ReviewDucStep.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ReviewDucStep/ReviewDucStep.js +35 -52
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ReviewDucStep/ReviewDucStep.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/SignatureStatusStep/SignatureStatusStep.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/SignatureStatusStep/SignatureStatusStep.js +79 -95
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/SignatureStatusStep/SignatureStatusStep.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/requestFlowTypes.d.ts +2 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/requestFlowTypes.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/RequestDataStep.d.ts +34 -0
- package/dist/components/AccessRequirementList/RequestDataStep.d.ts.map +1 -0
- package/dist/components/AccessRequirementList/RequestDataStep.js +37 -0
- package/dist/components/AccessRequirementList/RequestDataStep.js.map +1 -0
- package/dist/components/AccessRequirementList/RequirementItem/UnmanagedACTAccessRequirementItem.d.ts +1 -1
- package/dist/components/AccessRequirementList/RequirementItem/UnmanagedACTAccessRequirementItem.js.map +1 -1
- package/dist/components/DataGrid/DataGridWebSocket.d.ts +29 -1
- package/dist/components/DataGrid/DataGridWebSocket.d.ts.map +1 -1
- package/dist/components/DataGrid/DataGridWebSocket.js +48 -16
- package/dist/components/DataGrid/DataGridWebSocket.js.map +1 -1
- package/dist/components/DataGrid/components/GridLoadingState.d.ts +2 -2
- package/dist/components/DataGrid/components/GridLoadingState.d.ts.map +1 -1
- package/dist/components/DataGrid/components/GridLoadingState.js +2 -2
- package/dist/components/DataGrid/components/GridLoadingState.js.map +1 -1
- package/dist/components/DataGrid/useDataGridWebsocket.d.ts.map +1 -1
- package/dist/components/DataGrid/useDataGridWebsocket.js +2 -1
- package/dist/components/DataGrid/useDataGridWebsocket.js.map +1 -1
- package/dist/components/EntityViewScopeEditor/EntityViewMaskEditor.d.ts.map +1 -1
- package/dist/components/EntityViewScopeEditor/EntityViewMaskEditor.js +11 -10
- package/dist/components/EntityViewScopeEditor/EntityViewMaskEditor.js.map +1 -1
- package/dist/components/FormTemplateEditor/FormTemplatePreview.d.ts.map +1 -1
- package/dist/components/FormTemplateEditor/FormTemplatePreview.js +29 -30
- package/dist/components/FormTemplateEditor/FormTemplatePreview.js.map +1 -1
- package/dist/components/JsonSchemaForm/SchemaStepForm.d.ts +21 -0
- package/dist/components/JsonSchemaForm/SchemaStepForm.d.ts.map +1 -0
- package/dist/components/JsonSchemaForm/SchemaStepForm.js +29 -0
- package/dist/components/JsonSchemaForm/SchemaStepForm.js.map +1 -0
- package/dist/components/SetBasicAccessRequirementFields/GovernanceUtils.d.ts +2 -2
- package/dist/components/SetBasicAccessRequirementFields/GovernanceUtils.d.ts.map +1 -1
- package/dist/components/SetBasicAccessRequirementFields/GovernanceUtils.js +11 -10
- package/dist/components/SetBasicAccessRequirementFields/GovernanceUtils.js.map +1 -1
- package/dist/components/SetManagedAccessRequirementFields/DataUseCertificateFields.d.ts +10 -0
- package/dist/components/SetManagedAccessRequirementFields/DataUseCertificateFields.d.ts.map +1 -0
- package/dist/components/SetManagedAccessRequirementFields/DataUseCertificateFields.js +81 -0
- package/dist/components/SetManagedAccessRequirementFields/DataUseCertificateFields.js.map +1 -0
- package/dist/components/SetManagedAccessRequirementFields/ExpirationPeriodField.d.ts +9 -0
- package/dist/components/SetManagedAccessRequirementFields/ExpirationPeriodField.d.ts.map +1 -0
- package/dist/components/SetManagedAccessRequirementFields/ExpirationPeriodField.js +32 -0
- package/dist/components/SetManagedAccessRequirementFields/ExpirationPeriodField.js.map +1 -0
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.d.ts +0 -2
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.d.ts.map +1 -1
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.js +74 -151
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.js.map +1 -1
- package/dist/components/SynapseForm/SynapseForm.js +28 -28
- package/dist/components/TanStackTable/TanStackTableUtils.d.ts.map +1 -1
- package/dist/components/TanStackTable/TanStackTableUtils.js +8 -5
- package/dist/components/TanStackTable/TanStackTableUtils.js.map +1 -1
- package/dist/components/dataaccess/SubmissionPage/DataAccessSubmissionFileHandleLink.d.ts +5 -0
- package/dist/components/dataaccess/SubmissionPage/DataAccessSubmissionFileHandleLink.d.ts.map +1 -0
- package/dist/components/dataaccess/SubmissionPage/DataAccessSubmissionFileHandleLink.js +20 -0
- package/dist/components/dataaccess/SubmissionPage/DataAccessSubmissionFileHandleLink.js.map +1 -0
- package/dist/components/dataaccess/SubmissionPage/SubmissionPage.d.ts.map +1 -1
- package/dist/components/dataaccess/SubmissionPage/SubmissionPage.js +183 -188
- package/dist/components/dataaccess/SubmissionPage/SubmissionPage.js.map +1 -1
- package/dist/components/dataaccess/SubmissionPage/SubmissionSchemaAnswers.d.ts +25 -0
- package/dist/components/dataaccess/SubmissionPage/SubmissionSchemaAnswers.d.ts.map +1 -0
- package/dist/components/dataaccess/SubmissionPage/SubmissionSchemaAnswers.js +125 -0
- package/dist/components/dataaccess/SubmissionPage/SubmissionSchemaAnswers.js.map +1 -0
- package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.d.ts.map +1 -1
- package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.js +5 -4
- package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.js.map +1 -1
- package/dist/components/dataaccess/UserAccessRequestHistory/UserAccessRequestHistoryPlace.d.ts.map +1 -1
- package/dist/components/dataaccess/UserAccessRequestHistory/UserAccessRequestHistoryPlace.js +5 -4
- package/dist/components/dataaccess/UserAccessRequestHistory/UserAccessRequestHistoryPlace.js.map +1 -1
- package/dist/features/curator/dashboard/CuratorDashboardRouter.d.ts.map +1 -1
- package/dist/features/curator/dashboard/CuratorDashboardRouter.js +15 -15
- package/dist/features/curator/dashboard/CuratorDashboardRouter.js.map +1 -1
- package/dist/features/entity/metadata-task/components/MetadataTasksPageRouter.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/components/MetadataTasksPageRouter.js +15 -14
- package/dist/features/entity/metadata-task/components/MetadataTasksPageRouter.js.map +1 -1
- package/dist/mocks/accessRequirement/mockJsonSchemaAccessRequirements.d.ts +7 -0
- package/dist/mocks/accessRequirement/mockJsonSchemaAccessRequirements.d.ts.map +1 -1
- package/dist/mocks/accessRequirement/mockJsonSchemaAccessRequirements.js +30 -15
- package/dist/mocks/accessRequirement/mockJsonSchemaAccessRequirements.js.map +1 -1
- package/dist/mocks/dataaccess/MockDataAccessRequest.d.ts +3 -0
- package/dist/mocks/dataaccess/MockDataAccessRequest.d.ts.map +1 -1
- package/dist/mocks/dataaccess/MockDataAccessRequest.js +24 -12
- package/dist/mocks/dataaccess/MockDataAccessRequest.js.map +1 -1
- package/dist/mocks/dataaccess/MockSubmission.d.ts +76 -0
- package/dist/mocks/dataaccess/MockSubmission.d.ts.map +1 -1
- package/dist/mocks/dataaccess/MockSubmission.js +108 -63
- package/dist/mocks/dataaccess/MockSubmission.js.map +1 -1
- package/dist/mocks/msw/handlers/dataAccessRequestHandlers.d.ts.map +1 -1
- package/dist/mocks/msw/handlers/dataAccessRequestHandlers.js +42 -30
- package/dist/mocks/msw/handlers/dataAccessRequestHandlers.js.map +1 -1
- package/dist/style/components/_submission-page.scss +0 -4
- package/dist/style/main.css +1 -1
- package/dist/synapse-queries/dataaccess/useGeneratedRequestForm.d.ts +19 -0
- package/dist/synapse-queries/dataaccess/useGeneratedRequestForm.d.ts.map +1 -0
- package/dist/synapse-queries/dataaccess/useGeneratedRequestForm.js +26 -0
- package/dist/synapse-queries/dataaccess/useGeneratedRequestForm.js.map +1 -0
- package/dist/synapse-queries/dataaccess/useGeneratedSubmissionForm.d.ts +37 -0
- package/dist/synapse-queries/dataaccess/useGeneratedSubmissionForm.d.ts.map +1 -0
- package/dist/synapse-queries/dataaccess/useGeneratedSubmissionForm.js +35 -0
- package/dist/synapse-queries/dataaccess/useGeneratedSubmissionForm.js.map +1 -0
- package/dist/synapse-queries/grid/useEstablishWebsocketConnection.d.ts +2 -0
- package/dist/synapse-queries/grid/useEstablishWebsocketConnection.d.ts.map +1 -1
- package/dist/synapse-queries/grid/useEstablishWebsocketConnection.js.map +1 -1
- package/dist/synapse-queries/termsOfService/useTermsOfService.d.ts.map +1 -1
- package/dist/synapse-queries/termsOfService/useTermsOfService.js +21 -19
- package/dist/synapse-queries/termsOfService/useTermsOfService.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/functions/EntityTypeUtils.d.ts +2 -2
- package/dist/utils/functions/EntityTypeUtils.d.ts.map +1 -1
- package/dist/utils/functions/EntityTypeUtils.js +135 -135
- package/dist/utils/functions/EntityTypeUtils.js.map +1 -1
- package/dist/utils/hooks/useDetectSSOCode.d.ts.map +1 -1
- package/dist/utils/hooks/useDetectSSOCode.js +31 -26
- package/dist/utils/hooks/useDetectSSOCode.js.map +1 -1
- package/dist/utils/jsonschema/schemaData.d.ts +18 -0
- package/dist/utils/jsonschema/schemaData.d.ts.map +1 -0
- package/dist/utils/jsonschema/schemaData.js +26 -0
- package/dist/utils/jsonschema/schemaData.js.map +1 -0
- package/package.json +2 -2
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManagedACTAccessRequirementItem.d.ts.map +0 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManagedACTAccessRequirementItem.js.map +0 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManagedACTAccessRequirementItemView.d.ts.map +0 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManagedACTAccessRequirementItemView.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDataGridWebsocket.js","names":["GridModel","GridModelSnapshot","useCRDTModelView","normalizeWebsocketError","useCallback","useEffect","useMemo","useReducer","useRef","DataGridWebSocket","useEstablishWebsocketConnection","useDocumentVisibility","WebSocketState","model","hasCompletedInitialSync","hasCompletedInitialLoad","isSyncing","isConnected","isConnecting","connectionParams","replicaId","sessionId","websocketInstance","connectionAttemptId","connectionError","websocketError","WebSocketAction","type","payload","attemptId","websocketReducer","state","action","isSameConnection","initialWebSocketState","isModelRenderable","modelSnapshot","api","getSnapshot","columnNames","columnOrder","rows","columnsReady","length","orderReady","rowsReady","isInitialLoadReady","UseDataGridWebSocketOptions","onGridReady","onReplicaConnected","onReplicaDisconnected","useDataGridWebSocket","options","dispatch","connectionAttemptCounter","activeConnectionAttemptIdRef","isDocumentVisible","mutateAsync","establishWebsocketConnection","isPending","isEstablishingWebsocketConnection","error","errorEstablishingWebsocketConnection","presignedUrl","reset","resetEstablishWebsocketConnection","clearPresignedUrl","handleModelCreate","newModel","websocketOptionsWithoutModel","onStatusChange","open","onModelCreate","onSyncStart","onSyncEnd","onError","connect","isDifferentConnection","current","websocketOptions","then","ws","disconnect","catch","err","console","previousConnectionParams","previous"],"sources":["../../../src/components/DataGrid/useDataGridWebsocket.ts"],"sourcesContent":["import {\n GridModel,\n GridModelSnapshot,\n} from '@/components/DataGrid/DataGridTypes'\nimport { useCRDTModelView } from '@/components/DataGrid/useCRDTModelView'\nimport { normalizeWebsocketError } from '@/components/DataGrid/utils/normalizeWebsocketError'\nimport { useCallback, useEffect, useMemo, useReducer, useRef } from 'react'\nimport { DataGridWebSocket } from './DataGridWebSocket'\nimport { useEstablishWebsocketConnection } from '@/synapse-queries/grid/useEstablishWebsocketConnection'\nimport { useDocumentVisibility } from '@react-hookz/web'\n\n// State type\nexport interface WebSocketState {\n model: GridModel | null\n /**\n * True if the WebSocket has finished a sync exchange on the current connection\n * and can process CRDT updates. Set by `GRID_READY`; cleared on disconnect until\n * `hasCompletedInitialLoad` is set, since a drop mid-replay leaves the model\n * holding only part of the server's data.\n */\n hasCompletedInitialSync: boolean\n /**\n * True once the first connection for the current session has finished replaying\n * the server's data into the model. A one-way transition: later sync activity\n * never takes it back to false, and only connecting to a different\n * session/replica resets it.\n */\n hasCompletedInitialLoad: boolean\n /**\n * True while a clock-sync exchange is in progress. Set on every outgoing\n * `synchronize-clock` and cleared on `ResponseComplete`, which the server\n * sends once per exchange to signal \"we're synchronized\" — not per request.\n */\n isSyncing: boolean\n isConnected: boolean\n isConnecting: boolean\n connectionParams: {\n replicaId: number\n sessionId: string\n } | null\n websocketInstance: DataGridWebSocket | null\n connectionAttemptId: number | null\n connectionError: unknown\n websocketError: unknown\n}\n\n// Action types\nexport type WebSocketAction =\n | {\n type: 'CONNECT_REQUESTED'\n payload: { replicaId: number; sessionId: string; attemptId: number }\n }\n | { type: 'CONNECTION_ESTABLISHED'; payload: DataGridWebSocket }\n | { type: 'CONNECTION_OPENED' }\n | { type: 'CONNECTION_CLOSED' }\n | { type: 'GRID_READY' }\n | { type: 'INITIAL_LOAD_COMPLETE' }\n | { type: 'SYNC_STARTED' }\n | { type: 'SYNC_ENDED' }\n | { type: 'MODEL_CREATED'; payload: GridModel }\n | { type: 'CONNECTION_ERROR'; payload: unknown }\n | { type: 'WEBSOCKET_ERROR'; payload: unknown }\n\n// Reducer function\nexport function websocketReducer(\n state: WebSocketState,\n action: WebSocketAction,\n): WebSocketState {\n switch (action.type) {\n case 'CONNECT_REQUESTED': {\n const isSameConnection =\n state.connectionParams &&\n state.connectionParams.replicaId === action.payload.replicaId &&\n state.connectionParams.sessionId === action.payload.sessionId\n\n return {\n ...state,\n connectionParams: {\n replicaId: action.payload.replicaId,\n sessionId: action.payload.sessionId,\n },\n hasCompletedInitialSync: isSameConnection\n ? state.hasCompletedInitialSync\n : false,\n hasCompletedInitialLoad: isSameConnection\n ? state.hasCompletedInitialLoad\n : false,\n isSyncing: false,\n model: isSameConnection ? state.model : null,\n isConnected: false,\n isConnecting: false,\n connectionAttemptId: action.payload.attemptId,\n connectionError: null,\n }\n }\n\n case 'CONNECTION_ESTABLISHED':\n return {\n ...state,\n websocketInstance: action.payload,\n isConnecting: true,\n }\n\n case 'CONNECTION_OPENED':\n return {\n ...state,\n isConnected: true,\n isConnecting: false,\n }\n\n case 'CONNECTION_CLOSED':\n return {\n ...state,\n isConnected: false,\n isConnecting: false,\n isSyncing: false,\n // A drop before the initial load finishes invalidates the completed-exchange\n // signal: the model may hold only the part of the data that arrived so far.\n // Clearing it makes the readiness gate wait for the reconnect's replay\n // instead of latching onto a partially loaded model. Once the load is done,\n // drops are ordinary reconnects and the signal must survive them.\n hasCompletedInitialSync: state.hasCompletedInitialLoad\n ? state.hasCompletedInitialSync\n : false,\n }\n\n case 'GRID_READY':\n return {\n ...state,\n hasCompletedInitialSync: true,\n }\n\n case 'INITIAL_LOAD_COMPLETE':\n return {\n ...state,\n hasCompletedInitialLoad: true,\n }\n\n case 'SYNC_STARTED':\n return {\n ...state,\n isSyncing: true,\n }\n\n case 'SYNC_ENDED':\n return {\n ...state,\n isSyncing: false,\n }\n\n case 'MODEL_CREATED':\n return {\n ...state,\n model: action.payload,\n }\n\n case 'CONNECTION_ERROR':\n return {\n ...state,\n connectionError: action.payload,\n isConnecting: false,\n }\n\n case 'WEBSOCKET_ERROR':\n return {\n ...state,\n websocketError: action.payload,\n }\n\n default:\n return state\n }\n}\n\nexport const initialWebSocketState: WebSocketState = {\n model: null,\n hasCompletedInitialSync: false,\n hasCompletedInitialLoad: false,\n isSyncing: false,\n isConnected: false,\n isConnecting: false,\n connectionParams: null,\n websocketInstance: null,\n connectionAttemptId: null,\n connectionError: null,\n websocketError: null,\n}\n\n/**\n * Checks if the model snapshot contains the minimum data required for rendering (columns and rows).\n */\nfunction isModelRenderable(\n model: GridModel | null,\n modelSnapshot: GridModelSnapshot | null | undefined,\n) {\n if (!model?.api.getSnapshot() || !modelSnapshot) {\n return false\n }\n const { columnNames, columnOrder, rows } = modelSnapshot\n const columnsReady = columnNames.length >= 1\n const orderReady = columnOrder.length >= 1\n const rowsReady = rows.length >= 0\n return columnsReady && orderReady && rowsReady\n}\n\n/**\n * Whether the server has finished replaying its data into the model, so the grid\n * can be shown and edited. Drives the one-way `INITIAL_LOAD_COMPLETE` transition.\n *\n * Returns false once `hasCompletedInitialLoad` is set, so callers can dispatch\n * unconditionally on a true result without re-entering the transition.\n *\n * `hasCompletedInitialSync` alone is not sufficient: the server may complete the\n * snapshot request before the client has fetched and decoded the snapshot, which\n * leaves that flag true while the rows are still arriving. Requiring an idle sync\n * exchange holds the transition until the replay drains.\n */\nexport function isInitialLoadReady(\n state: WebSocketState,\n modelSnapshot: GridModelSnapshot | null | undefined,\n): boolean {\n return (\n !state.hasCompletedInitialLoad &&\n state.hasCompletedInitialSync &&\n !state.isSyncing &&\n isModelRenderable(state.model, modelSnapshot)\n )\n}\n\n/**\n * Custom hook to manage a DataGrid WebSocket connection.\n * Handles:\n * - Fetching presigned URLs via a mutation hook\n * - Instantiating the DataGridWebSocket\n * - Connection status tracking\n * - Reconnection on disconnect\n * - Grid model updates and snapshot tracking\n */\nexport interface UseDataGridWebSocketOptions {\n onGridReady?: () => void\n onReplicaConnected?: () => void\n onReplicaDisconnected?: () => void\n}\n\nexport function useDataGridWebSocket(options?: UseDataGridWebSocketOptions) {\n const [state, dispatch] = useReducer(websocketReducer, initialWebSocketState)\n\n const connectionAttemptCounter = useRef(0)\n const activeConnectionAttemptIdRef = useRef<number | null>(null)\n\n const modelSnapshot = useCRDTModelView(state.model)\n\n const isDocumentVisible = useDocumentVisibility()\n\n const {\n mutateAsync: establishWebsocketConnection,\n isPending: isEstablishingWebsocketConnection,\n error: errorEstablishingWebsocketConnection,\n presignedUrl,\n reset: resetEstablishWebsocketConnection,\n clearPresignedUrl,\n } = useEstablishWebsocketConnection()\n\n // Update model creation handler - only set model, don't reset to null on disconnect\n const handleModelCreate = useCallback(\n (newModel: GridModel) => {\n dispatch({ type: 'MODEL_CREATED', payload: newModel })\n },\n [dispatch],\n )\n\n // Memoize websocket options to prevent unnecessary re-renders (excluding model to avoid circular deps)\n const websocketOptionsWithoutModel = useMemo(\n () => ({\n onGridReady: () => {\n dispatch({ type: 'GRID_READY' })\n options?.onGridReady?.()\n },\n onStatusChange: (open: boolean) =>\n dispatch({ type: open ? 'CONNECTION_OPENED' : 'CONNECTION_CLOSED' }),\n onModelCreate: handleModelCreate,\n onReplicaConnected: options?.onReplicaConnected,\n onReplicaDisconnected: options?.onReplicaDisconnected,\n onSyncStart: () => dispatch({ type: 'SYNC_STARTED' }),\n onSyncEnd: () => dispatch({ type: 'SYNC_ENDED' }),\n onError: (error: unknown) =>\n dispatch({\n type: 'WEBSOCKET_ERROR',\n payload: normalizeWebsocketError(error),\n }),\n }),\n [\n handleModelCreate,\n options?.onGridReady,\n options?.onReplicaConnected,\n options?.onReplicaDisconnected,\n ],\n )\n\n // Initiate (or re-initiate) a connection\n const connect = useCallback(\n (replicaId: number, sessionId: string) => {\n resetEstablishWebsocketConnection()\n\n const isDifferentConnection =\n !state.connectionParams ||\n state.connectionParams.replicaId !== replicaId ||\n state.connectionParams.sessionId !== sessionId\n\n if (isDifferentConnection) {\n clearPresignedUrl()\n }\n\n connectionAttemptCounter.current += 1\n const attemptId = connectionAttemptCounter.current\n\n dispatch({\n type: 'CONNECT_REQUESTED',\n payload: { replicaId, sessionId, attemptId },\n })\n },\n [\n dispatch,\n state.connectionParams,\n resetEstablishWebsocketConnection,\n clearPresignedUrl,\n connectionAttemptCounter,\n ],\n )\n\n /**\n * Establish the WebSocket connection when conditions are met.\n * Uses the current model state at connection time for reconnections to the same session.\n * Note: Changes to `model` alone do NOT trigger reconnection - only changes to connection\n * params, visibility, or connection status will trigger a new connection attempt.\n */\n useEffect(() => {\n // Don't attempt connection if conditions aren't met\n const { connectionParams, connectionAttemptId } = state\n\n if (\n !connectionParams ||\n connectionAttemptId === null ||\n state.isConnected ||\n state.isConnecting ||\n isEstablishingWebsocketConnection ||\n errorEstablishingWebsocketConnection ||\n state.connectionError ||\n !isDocumentVisible\n ) {\n return\n }\n\n activeConnectionAttemptIdRef.current = connectionAttemptId\n\n // Use current model state for reconnections to same session\n // (model may have been created by a previous connection)\n establishWebsocketConnection({\n replicaId: connectionParams.replicaId,\n sessionId: connectionParams.sessionId,\n websocketOptions: {\n ...websocketOptionsWithoutModel,\n model: state.model, // Current model at connection time\n },\n })\n .then(ws => {\n if (activeConnectionAttemptIdRef.current !== connectionAttemptId) {\n ws.disconnect()\n return\n }\n\n dispatch({ type: 'CONNECTION_ESTABLISHED', payload: ws })\n })\n .catch(err => {\n dispatch({ type: 'CONNECTION_ERROR', payload: err })\n console.error('Failed to establish WebSocket', err)\n })\n }, [\n state,\n state.connectionParams,\n state.connectionAttemptId,\n state.isConnected,\n state.isConnecting,\n isEstablishingWebsocketConnection,\n errorEstablishingWebsocketConnection,\n isDocumentVisible,\n establishWebsocketConnection,\n websocketOptionsWithoutModel,\n ])\n\n const previousConnectionParams =\n useRef<WebSocketState['connectionParams']>(null)\n\n useEffect(() => {\n const previous = previousConnectionParams.current\n const current = state.connectionParams\n\n if (\n previous &&\n current &&\n (previous.replicaId !== current.replicaId ||\n previous.sessionId !== current.sessionId)\n ) {\n state.websocketInstance?.disconnect()\n }\n\n previousConnectionParams.current = current\n }, [state.connectionParams, state.websocketInstance])\n\n useEffect(() => {\n return () => {\n state.websocketInstance?.disconnect()\n activeConnectionAttemptIdRef.current = null\n }\n }, [state.websocketInstance])\n\n useEffect(() => {\n if (isInitialLoadReady(state, modelSnapshot)) {\n dispatch({ type: 'INITIAL_LOAD_COMPLETE' })\n }\n }, [state, modelSnapshot])\n\n return {\n isConnected: state.isConnected,\n websocketInstance: state.websocketInstance,\n hasCompletedInitialSync: state.hasCompletedInitialSync,\n hasCompletedInitialLoad: state.hasCompletedInitialLoad,\n isSyncing: state.isSyncing,\n model: state.model,\n modelSnapshot,\n connect,\n presignedUrl,\n errorEstablishingWebsocketConnection:\n state.connectionError ?? errorEstablishingWebsocketConnection,\n websocketError: state.websocketError,\n }\n}\n"],"mappings":";;;;;;AAgEA,SAAgB8B,EACdC,GACAC,GACgB;CAChB,QAAQA,EAAOL,MAAf;EACE,KAAK,qBAAqB;GACxB,IAAMM,IACJF,EAAMZ,oBACNY,EAAMZ,iBAAiBC,cAAcY,EAAOJ,QAAQR,aACpDW,EAAMZ,iBAAiBE,cAAcW,EAAOJ,QAAQP;GAEtD,OAAO;IACL,GAAGU;IACHZ,kBAAkB;KAChBC,WAAWY,EAAOJ,QAAQR;KAC1BC,WAAWW,EAAOJ,QAAQP;IAC5B;IACAP,yBAAyBmB,IACrBF,EAAMjB,0BACN;IACJC,yBAAyBkB,IACrBF,EAAMhB,0BACN;IACJC,WAAW;IACXH,OAAOoB,IAAmBF,EAAMlB,QAAQ;IACxCI,aAAa;IACbC,cAAc;IACdK,qBAAqBS,EAAOJ,QAAQC;IACpCL,iBAAiB;GACnB;EACF;EAEA,KAAK,0BACH,OAAO;GACL,GAAGO;GACHT,mBAAmBU,EAAOJ;GAC1BV,cAAc;EAChB;EAEF,KAAK,qBACH,OAAO;GACL,GAAGa;GACHd,aAAa;GACbC,cAAc;EAChB;EAEF,KAAK,qBACH,OAAO;GACL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,MAAM,wBAAwB,CAAC;CAE9C,GAAG,CAACI,GAAOK,CAAa,CAAC,GAElB;EACLnB,aAAac,EAAMd;EACnBK,mBAAmBS,EAAMT;EACzBR,yBAAyBiB,EAAMjB;EAC/BC,yBAAyBgB,EAAMhB;EAC/BC,WAAWe,EAAMf;EACjBH,OAAOkB,EAAMlB;EACbuB;EACAwC;EACAb;EACAD,sCACE/B,EAAMP,mBAAmBsC;EAC3BrC,gBAAgBM,EAAMN;CACxB;AACF"}
|
|
1
|
+
{"version":3,"file":"useDataGridWebsocket.js","names":["GridModel","GridModelSnapshot","useCRDTModelView","normalizeWebsocketError","useCallback","useEffect","useMemo","useReducer","useRef","DataGridWebSocket","useEstablishWebsocketConnection","useDocumentVisibility","WebSocketState","model","hasCompletedInitialSync","hasCompletedInitialLoad","isSyncing","isConnected","isConnecting","connectionParams","replicaId","sessionId","websocketInstance","connectionAttemptId","connectionError","websocketError","WebSocketAction","type","payload","attemptId","websocketReducer","state","action","isSameConnection","initialWebSocketState","isModelRenderable","modelSnapshot","api","getSnapshot","columnNames","columnOrder","rows","columnsReady","length","orderReady","rowsReady","isInitialLoadReady","UseDataGridWebSocketOptions","onGridReady","onReplicaConnected","onReplicaDisconnected","useDataGridWebSocket","options","dispatch","connectionAttemptCounter","activeConnectionAttemptIdRef","isDocumentVisible","mutateAsync","establishWebsocketConnection","isPending","isEstablishingWebsocketConnection","error","errorEstablishingWebsocketConnection","presignedUrl","reset","resetEstablishWebsocketConnection","clearPresignedUrl","handleModelCreate","newModel","websocketOptionsWithoutModel","onStatusChange","open","onModelCreate","onSyncStart","onSyncEnd","onError","connect","isDifferentConnection","current","websocketOptions","pendingPatches","getPendingPatches","undefined","then","ws","disconnect","catch","err","console","previousConnectionParams","previous"],"sources":["../../../src/components/DataGrid/useDataGridWebsocket.ts"],"sourcesContent":["import {\n GridModel,\n GridModelSnapshot,\n} from '@/components/DataGrid/DataGridTypes'\nimport { useCRDTModelView } from '@/components/DataGrid/useCRDTModelView'\nimport { normalizeWebsocketError } from '@/components/DataGrid/utils/normalizeWebsocketError'\nimport { useCallback, useEffect, useMemo, useReducer, useRef } from 'react'\nimport { DataGridWebSocket } from './DataGridWebSocket'\nimport { useEstablishWebsocketConnection } from '@/synapse-queries/grid/useEstablishWebsocketConnection'\nimport { useDocumentVisibility } from '@react-hookz/web'\n\n// State type\nexport interface WebSocketState {\n model: GridModel | null\n /**\n * True if the WebSocket has finished a sync exchange on the current connection\n * and can process CRDT updates. Set by `GRID_READY`; cleared on disconnect until\n * `hasCompletedInitialLoad` is set, since a drop mid-replay leaves the model\n * holding only part of the server's data.\n */\n hasCompletedInitialSync: boolean\n /**\n * True once the first connection for the current session has finished replaying\n * the server's data into the model. A one-way transition: later sync activity\n * never takes it back to false, and only connecting to a different\n * session/replica resets it.\n */\n hasCompletedInitialLoad: boolean\n /**\n * True while a clock-sync exchange is in progress. Set on every outgoing\n * `synchronize-clock` and cleared on `ResponseComplete`, which the server\n * sends once per exchange to signal \"we're synchronized\" — not per request.\n */\n isSyncing: boolean\n isConnected: boolean\n isConnecting: boolean\n connectionParams: {\n replicaId: number\n sessionId: string\n } | null\n websocketInstance: DataGridWebSocket | null\n connectionAttemptId: number | null\n connectionError: unknown\n websocketError: unknown\n}\n\n// Action types\nexport type WebSocketAction =\n | {\n type: 'CONNECT_REQUESTED'\n payload: { replicaId: number; sessionId: string; attemptId: number }\n }\n | { type: 'CONNECTION_ESTABLISHED'; payload: DataGridWebSocket }\n | { type: 'CONNECTION_OPENED' }\n | { type: 'CONNECTION_CLOSED' }\n | { type: 'GRID_READY' }\n | { type: 'INITIAL_LOAD_COMPLETE' }\n | { type: 'SYNC_STARTED' }\n | { type: 'SYNC_ENDED' }\n | { type: 'MODEL_CREATED'; payload: GridModel }\n | { type: 'CONNECTION_ERROR'; payload: unknown }\n | { type: 'WEBSOCKET_ERROR'; payload: unknown }\n\n// Reducer function\nexport function websocketReducer(\n state: WebSocketState,\n action: WebSocketAction,\n): WebSocketState {\n switch (action.type) {\n case 'CONNECT_REQUESTED': {\n const isSameConnection =\n state.connectionParams &&\n state.connectionParams.replicaId === action.payload.replicaId &&\n state.connectionParams.sessionId === action.payload.sessionId\n\n return {\n ...state,\n connectionParams: {\n replicaId: action.payload.replicaId,\n sessionId: action.payload.sessionId,\n },\n hasCompletedInitialSync: isSameConnection\n ? state.hasCompletedInitialSync\n : false,\n hasCompletedInitialLoad: isSameConnection\n ? state.hasCompletedInitialLoad\n : false,\n isSyncing: false,\n model: isSameConnection ? state.model : null,\n isConnected: false,\n isConnecting: false,\n connectionAttemptId: action.payload.attemptId,\n connectionError: null,\n }\n }\n\n case 'CONNECTION_ESTABLISHED':\n return {\n ...state,\n websocketInstance: action.payload,\n isConnecting: true,\n }\n\n case 'CONNECTION_OPENED':\n return {\n ...state,\n isConnected: true,\n isConnecting: false,\n }\n\n case 'CONNECTION_CLOSED':\n return {\n ...state,\n isConnected: false,\n isConnecting: false,\n isSyncing: false,\n // A drop before the initial load finishes invalidates the completed-exchange\n // signal: the model may hold only the part of the data that arrived so far.\n // Clearing it makes the readiness gate wait for the reconnect's replay\n // instead of latching onto a partially loaded model. Once the load is done,\n // drops are ordinary reconnects and the signal must survive them.\n hasCompletedInitialSync: state.hasCompletedInitialLoad\n ? state.hasCompletedInitialSync\n : false,\n }\n\n case 'GRID_READY':\n return {\n ...state,\n hasCompletedInitialSync: true,\n }\n\n case 'INITIAL_LOAD_COMPLETE':\n return {\n ...state,\n hasCompletedInitialLoad: true,\n }\n\n case 'SYNC_STARTED':\n return {\n ...state,\n isSyncing: true,\n }\n\n case 'SYNC_ENDED':\n return {\n ...state,\n isSyncing: false,\n }\n\n case 'MODEL_CREATED':\n return {\n ...state,\n model: action.payload,\n }\n\n case 'CONNECTION_ERROR':\n return {\n ...state,\n connectionError: action.payload,\n isConnecting: false,\n }\n\n case 'WEBSOCKET_ERROR':\n return {\n ...state,\n websocketError: action.payload,\n }\n\n default:\n return state\n }\n}\n\nexport const initialWebSocketState: WebSocketState = {\n model: null,\n hasCompletedInitialSync: false,\n hasCompletedInitialLoad: false,\n isSyncing: false,\n isConnected: false,\n isConnecting: false,\n connectionParams: null,\n websocketInstance: null,\n connectionAttemptId: null,\n connectionError: null,\n websocketError: null,\n}\n\n/**\n * Checks if the model snapshot contains the minimum data required for rendering (columns and rows).\n */\nfunction isModelRenderable(\n model: GridModel | null,\n modelSnapshot: GridModelSnapshot | null | undefined,\n) {\n if (!model?.api.getSnapshot() || !modelSnapshot) {\n return false\n }\n const { columnNames, columnOrder, rows } = modelSnapshot\n const columnsReady = columnNames.length >= 1\n const orderReady = columnOrder.length >= 1\n const rowsReady = rows.length >= 0\n return columnsReady && orderReady && rowsReady\n}\n\n/**\n * Whether the server has finished replaying its data into the model, so the grid\n * can be shown and edited. Drives the one-way `INITIAL_LOAD_COMPLETE` transition.\n *\n * Returns false once `hasCompletedInitialLoad` is set, so callers can dispatch\n * unconditionally on a true result without re-entering the transition.\n *\n * `hasCompletedInitialSync` alone is not sufficient: the server may complete the\n * snapshot request before the client has fetched and decoded the snapshot, which\n * leaves that flag true while the rows are still arriving. Requiring an idle sync\n * exchange holds the transition until the replay drains.\n */\nexport function isInitialLoadReady(\n state: WebSocketState,\n modelSnapshot: GridModelSnapshot | null | undefined,\n): boolean {\n return (\n !state.hasCompletedInitialLoad &&\n state.hasCompletedInitialSync &&\n !state.isSyncing &&\n isModelRenderable(state.model, modelSnapshot)\n )\n}\n\n/**\n * Custom hook to manage a DataGrid WebSocket connection.\n * Handles:\n * - Fetching presigned URLs via a mutation hook\n * - Instantiating the DataGridWebSocket\n * - Connection status tracking\n * - Reconnection on disconnect\n * - Grid model updates and snapshot tracking\n */\nexport interface UseDataGridWebSocketOptions {\n onGridReady?: () => void\n onReplicaConnected?: () => void\n onReplicaDisconnected?: () => void\n}\n\nexport function useDataGridWebSocket(options?: UseDataGridWebSocketOptions) {\n const [state, dispatch] = useReducer(websocketReducer, initialWebSocketState)\n\n const connectionAttemptCounter = useRef(0)\n const activeConnectionAttemptIdRef = useRef<number | null>(null)\n\n const modelSnapshot = useCRDTModelView(state.model)\n\n const isDocumentVisible = useDocumentVisibility()\n\n const {\n mutateAsync: establishWebsocketConnection,\n isPending: isEstablishingWebsocketConnection,\n error: errorEstablishingWebsocketConnection,\n presignedUrl,\n reset: resetEstablishWebsocketConnection,\n clearPresignedUrl,\n } = useEstablishWebsocketConnection()\n\n // Update model creation handler - only set model, don't reset to null on disconnect\n const handleModelCreate = useCallback(\n (newModel: GridModel) => {\n dispatch({ type: 'MODEL_CREATED', payload: newModel })\n },\n [dispatch],\n )\n\n // Memoize websocket options to prevent unnecessary re-renders (excluding model to avoid circular deps)\n const websocketOptionsWithoutModel = useMemo(\n () => ({\n onGridReady: () => {\n dispatch({ type: 'GRID_READY' })\n options?.onGridReady?.()\n },\n onStatusChange: (open: boolean) =>\n dispatch({ type: open ? 'CONNECTION_OPENED' : 'CONNECTION_CLOSED' }),\n onModelCreate: handleModelCreate,\n onReplicaConnected: options?.onReplicaConnected,\n onReplicaDisconnected: options?.onReplicaDisconnected,\n onSyncStart: () => dispatch({ type: 'SYNC_STARTED' }),\n onSyncEnd: () => dispatch({ type: 'SYNC_ENDED' }),\n onError: (error: unknown) =>\n dispatch({\n type: 'WEBSOCKET_ERROR',\n payload: normalizeWebsocketError(error),\n }),\n }),\n [\n handleModelCreate,\n options?.onGridReady,\n options?.onReplicaConnected,\n options?.onReplicaDisconnected,\n ],\n )\n\n // Initiate (or re-initiate) a connection\n const connect = useCallback(\n (replicaId: number, sessionId: string) => {\n resetEstablishWebsocketConnection()\n\n const isDifferentConnection =\n !state.connectionParams ||\n state.connectionParams.replicaId !== replicaId ||\n state.connectionParams.sessionId !== sessionId\n\n if (isDifferentConnection) {\n clearPresignedUrl()\n }\n\n connectionAttemptCounter.current += 1\n const attemptId = connectionAttemptCounter.current\n\n dispatch({\n type: 'CONNECT_REQUESTED',\n payload: { replicaId, sessionId, attemptId },\n })\n },\n [\n dispatch,\n state.connectionParams,\n resetEstablishWebsocketConnection,\n clearPresignedUrl,\n connectionAttemptCounter,\n ],\n )\n\n /**\n * Establish the WebSocket connection when conditions are met.\n * Uses the current model state at connection time for reconnections to the same session.\n * Note: Changes to `model` alone do NOT trigger reconnection - only changes to connection\n * params, visibility, or connection status will trigger a new connection attempt.\n */\n useEffect(() => {\n // Don't attempt connection if conditions aren't met\n const { connectionParams, connectionAttemptId } = state\n\n if (\n !connectionParams ||\n connectionAttemptId === null ||\n state.isConnected ||\n state.isConnecting ||\n isEstablishingWebsocketConnection ||\n errorEstablishingWebsocketConnection ||\n state.connectionError ||\n !isDocumentVisible\n ) {\n return\n }\n\n activeConnectionAttemptIdRef.current = connectionAttemptId\n\n // Use current model state for reconnections to same session\n // (model may have been created by a previous connection)\n establishWebsocketConnection({\n replicaId: connectionParams.replicaId,\n sessionId: connectionParams.sessionId,\n websocketOptions: {\n ...websocketOptionsWithoutModel,\n model: state.model, // Current model at connection time\n // A model only survives for the same session, so patches only carry over with it\n pendingPatches: state.model\n ? state.websocketInstance?.getPendingPatches()\n : undefined,\n },\n })\n .then(ws => {\n if (activeConnectionAttemptIdRef.current !== connectionAttemptId) {\n ws.disconnect()\n return\n }\n\n dispatch({ type: 'CONNECTION_ESTABLISHED', payload: ws })\n })\n .catch(err => {\n dispatch({ type: 'CONNECTION_ERROR', payload: err })\n console.error('Failed to establish WebSocket', err)\n })\n }, [\n state,\n state.connectionParams,\n state.connectionAttemptId,\n state.isConnected,\n state.isConnecting,\n isEstablishingWebsocketConnection,\n errorEstablishingWebsocketConnection,\n isDocumentVisible,\n establishWebsocketConnection,\n websocketOptionsWithoutModel,\n ])\n\n const previousConnectionParams =\n useRef<WebSocketState['connectionParams']>(null)\n\n useEffect(() => {\n const previous = previousConnectionParams.current\n const current = state.connectionParams\n\n if (\n previous &&\n current &&\n (previous.replicaId !== current.replicaId ||\n previous.sessionId !== current.sessionId)\n ) {\n state.websocketInstance?.disconnect()\n }\n\n previousConnectionParams.current = current\n }, [state.connectionParams, state.websocketInstance])\n\n useEffect(() => {\n return () => {\n state.websocketInstance?.disconnect()\n activeConnectionAttemptIdRef.current = null\n }\n }, [state.websocketInstance])\n\n useEffect(() => {\n if (isInitialLoadReady(state, modelSnapshot)) {\n dispatch({ type: 'INITIAL_LOAD_COMPLETE' })\n }\n }, [state, modelSnapshot])\n\n return {\n isConnected: state.isConnected,\n websocketInstance: state.websocketInstance,\n hasCompletedInitialSync: state.hasCompletedInitialSync,\n hasCompletedInitialLoad: state.hasCompletedInitialLoad,\n isSyncing: state.isSyncing,\n model: state.model,\n modelSnapshot,\n connect,\n presignedUrl,\n errorEstablishingWebsocketConnection:\n state.connectionError ?? errorEstablishingWebsocketConnection,\n websocketError: state.websocketError,\n }\n}\n"],"mappings":";;;;;;AAgEA,SAAgB8B,EACdC,GACAC,GACgB;CAChB,QAAQA,EAAOL,MAAf;EACE,KAAK,qBAAqB;GACxB,IAAMM,IACJF,EAAMZ,oBACNY,EAAMZ,iBAAiBC,cAAcY,EAAOJ,QAAQR,aACpDW,EAAMZ,iBAAiBE,cAAcW,EAAOJ,QAAQP;GAEtD,OAAO;IACL,GAAGU;IACHZ,kBAAkB;KAChBC,WAAWY,EAAOJ,QAAQR;KAC1BC,WAAWW,EAAOJ,QAAQP;IAC5B;IACAP,yBAAyBmB,IACrBF,EAAMjB,0BACN;IACJC,yBAAyBkB,IACrBF,EAAMhB,0BACN;IACJC,WAAW;IACXH,OAAOoB,IAAmBF,EAAMlB,QAAQ;IACxCI,aAAa;IACbC,cAAc;IACdK,qBAAqBS,EAAOJ,QAAQC;IACpCL,iBAAiB;GACnB;EACF;EAEA,KAAK,0BACH,OAAO;GACL,GAAGO;GACHT,mBAAmBU,EAAOJ;GAC1BV,cAAc;EAChB;EAEF,KAAK,qBACH,OAAO;GACL,GAAGa;GACHd,aAAa;GACbC,cAAc;EAChB;EAEF,KAAK,qBACH,OAAO;GACL,GAAGa;GACHd,aAAa;GACbC,cAAc;GACdF,WAAW;GAMXF,yBAAyBi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zCiB,EAAS,EAAE1B,MAAM,wBAAwB,CAAC;CAE9C,GAAG,CAACI,GAAOK,CAAa,CAAC,GAElB;EACLnB,aAAac,EAAMd;EACnBK,mBAAmBS,EAAMT;EACzBR,yBAAyBiB,EAAMjB;EAC/BC,yBAAyBgB,EAAMhB;EAC/BC,WAAWe,EAAMf;EACjBH,OAAOkB,EAAMlB;EACbuB;EACAwC;EACAb;EACAD,sCACE/B,EAAMP,mBAAmBsC;EAC3BrC,gBAAgBM,EAAMN;CACxB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityViewMaskEditor.d.ts","sourceRoot":"","sources":["../../../src/components/EntityViewScopeEditor/EntityViewMaskEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EntityViewMaskEditor.d.ts","sourceRoot":"","sources":["../../../src/components/EntityViewScopeEditor/EntityViewMaskEditor.tsx"],"names":[],"mappings":"AAgBA,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAWD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,WAShD;AAED,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,2CA0C5E"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { Alert as e, Checkbox as t, FormControlLabel as n, FormGroup as r, Typography as i } from "@mui/material";
|
|
2
2
|
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
3
|
-
import { ENTITY_VIEW_TYPE_MASK_DATASET as c, ENTITY_VIEW_TYPE_MASK_DOCKER as l, ENTITY_VIEW_TYPE_MASK_FILE as u, ENTITY_VIEW_TYPE_MASK_FOLDER as d,
|
|
3
|
+
import { ENTITY_VIEW_TYPE_MASK_DATASET as c, ENTITY_VIEW_TYPE_MASK_DOCKER as l, ENTITY_VIEW_TYPE_MASK_FILE as u, ENTITY_VIEW_TYPE_MASK_FOLDER as d, ENTITY_VIEW_TYPE_MASK_RECORDSET as f, ENTITY_VIEW_TYPE_MASK_TABLE as p } from "@sage-bionetworks/synapse-types";
|
|
4
4
|
//#region src/components/EntityViewScopeEditor/EntityViewMaskEditor.tsx
|
|
5
|
-
var
|
|
5
|
+
var m = [
|
|
6
6
|
["Files", u],
|
|
7
7
|
["Folders", d],
|
|
8
|
-
["Tables",
|
|
8
|
+
["Tables", p],
|
|
9
9
|
["Datasets", c],
|
|
10
|
-
["Docker Repositories", l]
|
|
10
|
+
["Docker Repositories", l],
|
|
11
|
+
["Record Sets", f]
|
|
11
12
|
];
|
|
12
|
-
function
|
|
13
|
-
return
|
|
13
|
+
function h(e) {
|
|
14
|
+
return m.forEach(([, t]) => {
|
|
14
15
|
(e & t) !== 0 && (e -= t);
|
|
15
16
|
}), e === 0;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
let { value: l, onChange: u, disabled: d = !1 } = c, f = !
|
|
18
|
+
function g(c) {
|
|
19
|
+
let { value: l, onChange: u, disabled: d = !1 } = c, f = !h(l);
|
|
19
20
|
return /* @__PURE__ */ s(a, { children: [
|
|
20
21
|
/* @__PURE__ */ o(i, {
|
|
21
22
|
variant: "body1",
|
|
@@ -28,7 +29,7 @@ function h(c) {
|
|
|
28
29
|
}),
|
|
29
30
|
/* @__PURE__ */ o(r, {
|
|
30
31
|
sx: { gap: 1 },
|
|
31
|
-
children:
|
|
32
|
+
children: m.map(([e, r]) => /* @__PURE__ */ o(n, {
|
|
32
33
|
control: /* @__PURE__ */ o(t, {}),
|
|
33
34
|
label: e,
|
|
34
35
|
checked: (l & r) > 0,
|
|
@@ -46,6 +47,6 @@ function h(c) {
|
|
|
46
47
|
] });
|
|
47
48
|
}
|
|
48
49
|
//#endregion
|
|
49
|
-
export {
|
|
50
|
+
export { g as default, h as isMaskSupportedInUI };
|
|
50
51
|
|
|
51
52
|
//# sourceMappingURL=EntityViewMaskEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityViewMaskEditor.js","names":[],"sources":["../../../src/components/EntityViewScopeEditor/EntityViewMaskEditor.tsx"],"sourcesContent":["import {\n Alert,\n Checkbox,\n FormControlLabel,\n FormGroup,\n Typography,\n} from '@mui/material'\nimport {\n ENTITY_VIEW_TYPE_MASK_DATASET,\n ENTITY_VIEW_TYPE_MASK_FILE,\n ENTITY_VIEW_TYPE_MASK_FOLDER,\n ENTITY_VIEW_TYPE_MASK_TABLE,\n ENTITY_VIEW_TYPE_MASK_DOCKER,\n} from '@sage-bionetworks/synapse-types'\n\nexport type EntityViewMaskEditorProps = {\n value: number\n onChange: (mask: number) => void\n disabled?: boolean\n}\n\nconst maskLabelPairs: [string, number][] = [\n ['Files', ENTITY_VIEW_TYPE_MASK_FILE],\n ['Folders', ENTITY_VIEW_TYPE_MASK_FOLDER],\n ['Tables', ENTITY_VIEW_TYPE_MASK_TABLE],\n ['Datasets', ENTITY_VIEW_TYPE_MASK_DATASET],\n ['Docker Repositories', ENTITY_VIEW_TYPE_MASK_DOCKER],\n]\n\nexport function isMaskSupportedInUI(value: number) {\n maskLabelPairs.forEach(([, mask]) => {\n // Remove each supported bit\n if ((value & mask) !== 0) {\n value = value - mask\n }\n })\n // If value is not zero, then some unsupported bit remains\n return value === 0\n}\n\nexport default function EntityViewMaskEditor(props: EntityViewMaskEditorProps) {\n const { value, onChange, disabled = false } = props\n\n const customMaskInUse = !isMaskSupportedInUI(value)\n\n return (\n <>\n <Typography\n variant={'body1'}\n sx={{\n mt: 2.5,\n mb: 1.25,\n fontWeight: 700,\n }}\n >\n Include in View\n </Typography>\n <FormGroup sx={{ gap: 1 }}>\n {maskLabelPairs.map(([label, mask]) => (\n <FormControlLabel\n control={<Checkbox />}\n key={label}\n label={label}\n checked={\n // Checked if the mask bit is set\n (value & mask) > 0\n }\n disabled={customMaskInUse || disabled}\n onChange={() => {\n // Toggle the clicked mask value with XOR\n onChange(value ^ mask)\n }}\n />\n ))}\n </FormGroup>\n {customMaskInUse && (\n <Alert severity={'warning'} sx={{ my: 2.25 }}>\n A custom mask is in use. Changes cannot be made in the UI.\n </Alert>\n )}\n </>\n )\n}\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"EntityViewMaskEditor.js","names":[],"sources":["../../../src/components/EntityViewScopeEditor/EntityViewMaskEditor.tsx"],"sourcesContent":["import {\n Alert,\n Checkbox,\n FormControlLabel,\n FormGroup,\n Typography,\n} from '@mui/material'\nimport {\n ENTITY_VIEW_TYPE_MASK_DATASET,\n ENTITY_VIEW_TYPE_MASK_FILE,\n ENTITY_VIEW_TYPE_MASK_FOLDER,\n ENTITY_VIEW_TYPE_MASK_TABLE,\n ENTITY_VIEW_TYPE_MASK_DOCKER,\n ENTITY_VIEW_TYPE_MASK_RECORDSET,\n} from '@sage-bionetworks/synapse-types'\n\nexport type EntityViewMaskEditorProps = {\n value: number\n onChange: (mask: number) => void\n disabled?: boolean\n}\n\nconst maskLabelPairs: [string, number][] = [\n ['Files', ENTITY_VIEW_TYPE_MASK_FILE],\n ['Folders', ENTITY_VIEW_TYPE_MASK_FOLDER],\n ['Tables', ENTITY_VIEW_TYPE_MASK_TABLE],\n ['Datasets', ENTITY_VIEW_TYPE_MASK_DATASET],\n ['Docker Repositories', ENTITY_VIEW_TYPE_MASK_DOCKER],\n ['Record Sets', ENTITY_VIEW_TYPE_MASK_RECORDSET],\n]\n\nexport function isMaskSupportedInUI(value: number) {\n maskLabelPairs.forEach(([, mask]) => {\n // Remove each supported bit\n if ((value & mask) !== 0) {\n value = value - mask\n }\n })\n // If value is not zero, then some unsupported bit remains\n return value === 0\n}\n\nexport default function EntityViewMaskEditor(props: EntityViewMaskEditorProps) {\n const { value, onChange, disabled = false } = props\n\n const customMaskInUse = !isMaskSupportedInUI(value)\n\n return (\n <>\n <Typography\n variant={'body1'}\n sx={{\n mt: 2.5,\n mb: 1.25,\n fontWeight: 700,\n }}\n >\n Include in View\n </Typography>\n <FormGroup sx={{ gap: 1 }}>\n {maskLabelPairs.map(([label, mask]) => (\n <FormControlLabel\n control={<Checkbox />}\n key={label}\n label={label}\n checked={\n // Checked if the mask bit is set\n (value & mask) > 0\n }\n disabled={customMaskInUse || disabled}\n onChange={() => {\n // Toggle the clicked mask value with XOR\n onChange(value ^ mask)\n }}\n />\n ))}\n </FormGroup>\n {customMaskInUse && (\n <Alert severity={'warning'} sx={{ my: 2.25 }}>\n A custom mask is in use. Changes cannot be made in the UI.\n </Alert>\n )}\n </>\n )\n}\n"],"mappings":";;;;AAsBA,IAAM,IAAqC;CACzC,CAAC,SAAS,CAA0B;CACpC,CAAC,WAAW,CAA4B;CACxC,CAAC,UAAU,CAA2B;CACtC,CAAC,YAAY,CAA6B;CAC1C,CAAC,uBAAuB,CAA4B;CACpD,CAAC,eAAe,CAA+B;AACjD;AAEA,SAAgB,EAAoB,GAAe;CAQjD,OAPA,EAAe,SAAS,GAAG,OAAU;EAEnC,CAAK,IAAQ,OAAU,MACrB,KAAgB;CAEpB,CAAC,GAEM,MAAU;AACnB;AAEA,SAAwB,EAAqB,GAAkC;CAC7E,IAAM,EAAE,UAAO,aAAU,cAAW,OAAU,GAExC,IAAkB,CAAC,EAAoB,CAAK;CAElD,OACE,kBAAA,GAAA,EAAA,UAAA;EACE,kBAAC,GAAD;GACE,SAAS;GACT,IAAI;IACF,IAAI;IACJ,IAAI;IACJ,YAAY;GACd;aACD;EAEW,CAAA;EACZ,kBAAC,GAAD;GAAW,IAAI,EAAE,KAAK,EAAE;aACrB,EAAe,KAAK,CAAC,GAAO,OAC3B,kBAAC,GAAD;IACE,SAAS,kBAAC,GAAD,CAAW,CAAA;IAEb;IACP,UAEG,IAAQ,KAAQ;IAEnB,UAAU,KAAmB;IAC7B,gBAAgB;KAEd,EAAS,IAAQ,CAAI;IACvB;GACD,GAXM,CAWN,CACF;EACQ,CAAA;EACV,KACC,kBAAC,GAAD;GAAO,UAAU;GAAW,IAAI,EAAE,IAAI,KAAK;aAAG;EAEvC,CAAA;CAET,EAAA,CAAA;AAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormTemplatePreview.d.ts","sourceRoot":"","sources":["../../../src/components/FormTemplateEditor/FormTemplatePreview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormTemplatePreview.d.ts","sourceRoot":"","sources":["../../../src/components/FormTemplateEditor/FormTemplatePreview.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,YAAY,EACb,MAAM,kCAAkC,CAAA;AAWzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,EAAE,YAAY,CAAA;IACtB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,UAAU,GACX,EAAE,wBAAwB,2CAoE1B"}
|
|
@@ -1,68 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { generateDataAccessSchema as e } from "../../utils/jsonschema/generateDataAccessSchema.js";
|
|
2
|
+
import { getStepTitle as t } from "../../utils/jsonschema/schemaData.js";
|
|
3
|
+
import n from "../JsonSchemaForm/SchemaStepForm.js";
|
|
4
|
+
import { useMemo as r, useState as i } from "react";
|
|
5
|
+
import { Box as a, Paper as o, Step as s, StepButton as c, Stepper as l, ToggleButton as u, ToggleButtonGroup as d, Typography as f } from "@mui/material";
|
|
6
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
6
7
|
import { DataAccessRequestType as h } from "@sage-bionetworks/synapse-client";
|
|
7
8
|
//#region src/components/FormTemplateEditor/FormTemplatePreview.tsx
|
|
8
9
|
function g({ template: g, jsonSchema: _ }) {
|
|
9
|
-
let [v, y] =
|
|
10
|
+
let [v, y] = i(0), [b, x] = i({}), [S, C] = i(h.REQUEST), { steps: w } = r(() => e(g, _, S), [
|
|
10
11
|
g,
|
|
11
12
|
_,
|
|
12
|
-
|
|
13
|
+
S
|
|
13
14
|
]);
|
|
14
|
-
if (
|
|
15
|
+
if (w.length === 0) return /* @__PURE__ */ p(o, {
|
|
15
16
|
variant: "outlined",
|
|
16
17
|
sx: { p: 2 },
|
|
17
|
-
children: /* @__PURE__ */ p(
|
|
18
|
+
children: /* @__PURE__ */ p(a, {
|
|
18
19
|
sx: {
|
|
19
20
|
py: 4,
|
|
20
21
|
textAlign: "center"
|
|
21
22
|
},
|
|
22
|
-
children: /* @__PURE__ */ p(
|
|
23
|
+
children: /* @__PURE__ */ p(f, {
|
|
23
24
|
variant: "body2",
|
|
24
25
|
color: "text.secondary",
|
|
25
26
|
children: "Add at least one step with a bound field to preview the form."
|
|
26
27
|
})
|
|
27
28
|
})
|
|
28
29
|
});
|
|
29
|
-
let
|
|
30
|
-
return /* @__PURE__ */ m(
|
|
30
|
+
let T = Math.min(v, w.length - 1), E = w[T];
|
|
31
|
+
return /* @__PURE__ */ m(o, {
|
|
31
32
|
variant: "outlined",
|
|
32
33
|
sx: { p: 2 },
|
|
33
34
|
children: [
|
|
34
|
-
/* @__PURE__ */ m(
|
|
35
|
-
value:
|
|
35
|
+
/* @__PURE__ */ m(d, {
|
|
36
|
+
value: S,
|
|
36
37
|
exclusive: !0,
|
|
37
38
|
size: "small",
|
|
38
39
|
onChange: (e, t) => {
|
|
39
|
-
t &&
|
|
40
|
+
t && C(t);
|
|
40
41
|
},
|
|
41
42
|
sx: { mb: 2 },
|
|
42
|
-
children: [/* @__PURE__ */ p(
|
|
43
|
+
children: [/* @__PURE__ */ p(u, {
|
|
43
44
|
value: h.REQUEST,
|
|
44
45
|
children: "Request"
|
|
45
|
-
}), /* @__PURE__ */ p(
|
|
46
|
+
}), /* @__PURE__ */ p(u, {
|
|
46
47
|
value: h.RENEWAL,
|
|
47
48
|
children: "Renewal"
|
|
48
49
|
})]
|
|
49
50
|
}),
|
|
50
|
-
|
|
51
|
-
activeStep:
|
|
51
|
+
w.length > 1 && /* @__PURE__ */ p(l, {
|
|
52
|
+
activeStep: T,
|
|
52
53
|
nonLinear: !0,
|
|
53
54
|
sx: { mb: 2 },
|
|
54
|
-
children:
|
|
55
|
-
onClick: () => y(
|
|
56
|
-
children: e
|
|
57
|
-
}) },
|
|
55
|
+
children: w.map((e, n) => /* @__PURE__ */ p(s, { children: /* @__PURE__ */ p(c, {
|
|
56
|
+
onClick: () => y(n),
|
|
57
|
+
children: t(e, n + 1)
|
|
58
|
+
}) }, n))
|
|
58
59
|
}),
|
|
59
|
-
/* @__PURE__ */ p(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
liveValidate: !1
|
|
65
|
-
})
|
|
60
|
+
/* @__PURE__ */ p(n, {
|
|
61
|
+
step: E,
|
|
62
|
+
schemaData: b,
|
|
63
|
+
onSchemaDataChange: x
|
|
64
|
+
}, T)
|
|
66
65
|
]
|
|
67
66
|
});
|
|
68
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormTemplatePreview.js","names":[],"sources":["../../../src/components/FormTemplateEditor/FormTemplatePreview.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"FormTemplatePreview.js","names":[],"sources":["../../../src/components/FormTemplateEditor/FormTemplatePreview.tsx"],"sourcesContent":["import SchemaStepForm from '@/components/JsonSchemaForm/SchemaStepForm'\nimport { generateDataAccessSchema } from '@/utils/jsonschema/generateDataAccessSchema'\nimport { getStepTitle, SchemaData } from '@/utils/jsonschema/schemaData'\nimport {\n DataAccessRequestType,\n FormTemplate,\n} from '@sage-bionetworks/synapse-client'\nimport {\n Box,\n Paper,\n Step,\n StepButton,\n Stepper,\n ToggleButton,\n ToggleButtonGroup,\n Typography,\n} from '@mui/material'\nimport { RJSFSchema } from '@rjsf/utils'\nimport { useMemo, useState } from 'react'\n\ntype FormTemplatePreviewProps = {\n template: FormTemplate\n jsonSchema: RJSFSchema\n}\n\n/**\n * Renders a live preview of how a FormTemplate + its referenced JSON Schema will appear to a\n * requester. Computed client-side against the unsaved draft, purely to give ACT instant feedback\n * while editing.\n */\nexport function FormTemplatePreview({\n template,\n jsonSchema,\n}: FormTemplatePreviewProps) {\n const [activeStep, setActiveStep] = useState(0)\n // Kept across steps and request types so ACT can see how answers carry through the form\n const [schemaData, setSchemaData] = useState<SchemaData>({})\n const [requestType, setRequestType] = useState<DataAccessRequestType>(\n DataAccessRequestType.REQUEST,\n )\n\n const { steps } = useMemo(\n () => generateDataAccessSchema(template, jsonSchema, requestType),\n [template, jsonSchema, requestType],\n )\n\n if (steps.length === 0) {\n return (\n <Paper variant=\"outlined\" sx={{ p: 2 }}>\n <Box sx={{ py: 4, textAlign: 'center' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n Add at least one step with a bound field to preview the form.\n </Typography>\n </Box>\n </Paper>\n )\n }\n\n const safeIndex = Math.min(activeStep, steps.length - 1)\n const currentStep = steps[safeIndex]\n\n return (\n <Paper variant=\"outlined\" sx={{ p: 2 }}>\n <ToggleButtonGroup\n value={requestType}\n exclusive\n size=\"small\"\n onChange={(_, next: DataAccessRequestType | null) => {\n if (next) setRequestType(next)\n }}\n sx={{ mb: 2 }}\n >\n <ToggleButton value={DataAccessRequestType.REQUEST}>\n Request\n </ToggleButton>\n <ToggleButton value={DataAccessRequestType.RENEWAL}>\n Renewal\n </ToggleButton>\n </ToggleButtonGroup>\n\n {steps.length > 1 && (\n <Stepper activeStep={safeIndex} nonLinear sx={{ mb: 2 }}>\n {steps.map((step, index) => (\n <Step key={index}>\n <StepButton onClick={() => setActiveStep(index)}>\n {getStepTitle(step, index + 1)}\n </StepButton>\n </Step>\n ))}\n </Stepper>\n )}\n\n <SchemaStepForm\n // Each step is a separate form, as it is for a requester\n key={safeIndex}\n step={currentStep}\n schemaData={schemaData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A;GAGX,kBAAC,GAAD;IAGE,MAAM;IACM;IACZ,oBAAoB;GACrB,GAJM,CAIN;EACI;;AAEX"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GeneratedFormStepForRjsf } from '@/utils/jsonschema/generateDataAccessSchema';
|
|
2
|
+
import { SchemaData } from '@/utils/jsonschema/schemaData';
|
|
3
|
+
import { Ref } from 'react';
|
|
4
|
+
export type SchemaStepFormHandle = {
|
|
5
|
+
/** Validates the step's answers, showing errors against invalid fields. */
|
|
6
|
+
submit: () => void;
|
|
7
|
+
};
|
|
8
|
+
export type SchemaStepFormProps = {
|
|
9
|
+
ref?: Ref<SchemaStepFormHandle>;
|
|
10
|
+
step: GeneratedFormStepForRjsf;
|
|
11
|
+
schemaData: SchemaData;
|
|
12
|
+
onSchemaDataChange: (schemaData: SchemaData) => void;
|
|
13
|
+
/** Invoked with the complete answers when the step's answers pass validation. */
|
|
14
|
+
onValid?: (schemaData: SchemaData) => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A single step of a form generated from a FormTemplate, rendered as a requester sees it. The answers of all steps
|
|
18
|
+
* are kept in `schemaData`; the step shows and updates only its own.
|
|
19
|
+
*/
|
|
20
|
+
export default function SchemaStepForm(props: SchemaStepFormProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=SchemaStepForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaStepForm.d.ts","sourceRoot":"","sources":["../../../src/components/JsonSchemaForm/SchemaStepForm.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAe,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAEvE,OAAO,EAAE,GAAG,EAA+B,MAAM,OAAO,CAAA;AAExD,MAAM,MAAM,oBAAoB,GAAG;IACjC,2EAA2E;IAC3E,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,CAAC,EAAE,GAAG,CAAC,oBAAoB,CAAC,CAAA;IAC/B,IAAI,EAAE,wBAAwB,CAAA;IAC9B,UAAU,EAAE,UAAU,CAAA;IACtB,kBAAkB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAA;IACpD,iFAAiF;IACjF,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAA;CAC3C,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CA0BhE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { JsonSchemaForm as e } from "./JsonSchemaForm.js";
|
|
2
|
+
import { getStepData as t } from "../../utils/jsonschema/schemaData.js";
|
|
3
|
+
import { useImperativeHandle as n, useRef as r } from "react";
|
|
4
|
+
import { Fragment as i, jsx as a } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/JsonSchemaForm/SchemaStepForm.tsx
|
|
6
|
+
function o(o) {
|
|
7
|
+
let { ref: s, step: c, schemaData: l, onSchemaDataChange: u, onValid: d } = o, f = r(null);
|
|
8
|
+
return n(s, () => ({ submit: () => f.current?.submit() })), /* @__PURE__ */ a(e, {
|
|
9
|
+
formRef: f,
|
|
10
|
+
schema: c.jsonSchema,
|
|
11
|
+
uiSchema: c.uiSchema,
|
|
12
|
+
formData: t(l, c),
|
|
13
|
+
formContext: { descriptionVariant: "inline" },
|
|
14
|
+
liveValidate: !1,
|
|
15
|
+
onChange: (e) => u({
|
|
16
|
+
...l,
|
|
17
|
+
...e.formData
|
|
18
|
+
}),
|
|
19
|
+
onSubmit: (e) => d?.({
|
|
20
|
+
...l,
|
|
21
|
+
...e.formData
|
|
22
|
+
}),
|
|
23
|
+
children: /* @__PURE__ */ a(i, {})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { o as default };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=SchemaStepForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaStepForm.js","names":[],"sources":["../../../src/components/JsonSchemaForm/SchemaStepForm.tsx"],"sourcesContent":["import { JsonSchemaForm } from '@/components/JsonSchemaForm/JsonSchemaForm'\nimport { GeneratedFormStepForRjsf } from '@/utils/jsonschema/generateDataAccessSchema'\nimport { getStepData, SchemaData } from '@/utils/jsonschema/schemaData'\nimport RJSFForm from '@rjsf/core'\nimport { Ref, useImperativeHandle, useRef } from 'react'\n\nexport type SchemaStepFormHandle = {\n /** Validates the step's answers, showing errors against invalid fields. */\n submit: () => void\n}\n\nexport type SchemaStepFormProps = {\n ref?: Ref<SchemaStepFormHandle>\n step: GeneratedFormStepForRjsf\n schemaData: SchemaData\n onSchemaDataChange: (schemaData: SchemaData) => void\n /** Invoked with the complete answers when the step's answers pass validation. */\n onValid?: (schemaData: SchemaData) => void\n}\n\n/**\n * A single step of a form generated from a FormTemplate, rendered as a requester sees it. The answers of all steps\n * are kept in `schemaData`; the step shows and updates only its own.\n */\nexport default function SchemaStepForm(props: SchemaStepFormProps) {\n const { ref, step, schemaData, onSchemaDataChange, onValid } = props\n const formRef = useRef<RJSFForm>(null)\n\n useImperativeHandle(ref, () => ({\n submit: () => formRef.current?.submit(),\n }))\n\n return (\n <JsonSchemaForm\n formRef={formRef}\n schema={step.jsonSchema}\n uiSchema={step.uiSchema}\n formData={getStepData(schemaData, step)}\n formContext={{ descriptionVariant: 'inline' }}\n liveValidate={false}\n onChange={event =>\n onSchemaDataChange({ ...schemaData, ...event.formData })\n }\n onSubmit={event =>\n onValid?.({ ...schemaData, ...(event.formData as SchemaData) })\n }\n >\n <></>\n </JsonSchemaForm>\n )\n}\n"],"mappings":";;;;;AAwBA,SAAwB,EAAe,GAA4B;CACjE,IAAM,EAAE,QAAK,SAAM,eAAY,uBAAoB,eAAY,GACzD,IAAU,EAAiB,IAAI;CAMrC,OAJA,EAAoB,UAAY,EAC9B,cAAc,EAAQ,SAAS,OAAO,EACxC,EAAE,GAGA,kBAAC,GAAD;EACW;EACT,QAAQ,EAAK;EACb,UAAU,EAAK;EACf,UAAU,EAAY,GAAY,CAAI;EACtC,aAAa,EAAE,oBAAoB,SAAS;EAC5C,cAAc;EACd,WAAU,MACR,EAAmB;GAAE,GAAG;GAAY,GAAG,EAAM;EAAS,CAAC;EAEzD,WAAU,MACR,IAAU;GAAE,GAAG;GAAY,GAAI,EAAM;EAAwB,CAAC;YAGhE,kBAAA,GAAA,CAAI,CAAA;CACU,CAAA;AAEpB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AccessRequirement, ManagedACTAccessRequirement, SelfSignAccessRequirement } from '@sage-bionetworks/synapse-types';
|
|
1
|
+
import { AccessRequirement, JsonSchemaAccessRequirement, ManagedACTAccessRequirement, SelfSignAccessRequirement } from '@sage-bionetworks/synapse-types';
|
|
2
2
|
export declare const LOCK_ACCESS_REQUIREMENT_TEXT = "Access restricted pending review by Synapse Access and Compliance Team.";
|
|
3
3
|
export declare const getOldAccessRequirementInstructions: (ar: AccessRequirement) => string | undefined;
|
|
4
4
|
/**
|
|
5
5
|
* Returns true iff the access requirement can apply restrictions based on
|
|
6
6
|
* accessor qualities, such as certification or validation status
|
|
7
7
|
*/
|
|
8
|
-
export declare const hasAccessorRequirement: (ar: AccessRequirement) => ar is SelfSignAccessRequirement | ManagedACTAccessRequirement;
|
|
8
|
+
export declare const hasAccessorRequirement: (ar: AccessRequirement) => ar is SelfSignAccessRequirement | ManagedACTAccessRequirement | JsonSchemaAccessRequirement;
|
|
9
9
|
//# sourceMappingURL=GovernanceUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GovernanceUtils.d.ts","sourceRoot":"","sources":["../../../src/components/SetBasicAccessRequirementFields/GovernanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"GovernanceUtils.d.ts","sourceRoot":"","sources":["../../../src/components/SetBasicAccessRequirementFields/GovernanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,2BAA2B,EAG3B,2BAA2B,EAE3B,yBAAyB,EAE1B,MAAM,iCAAiC,CAAA;AAExC,eAAO,MAAM,4BAA4B,4EACkC,CAAA;AAE3E,eAAO,MAAM,mCAAmC,GAAI,IAAI,iBAAiB,uBAcxE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,IAAI,iBAAiB,KACpB,EAAE,IACD,yBAAyB,GACzB,2BAA2B,GAC3B,2BAMH,CAAA"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as e,
|
|
1
|
+
import { ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as e, JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as t, LOCK_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as n, MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as r, SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as i, TERMS_OF_USE_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as a } from "@sage-bionetworks/synapse-types";
|
|
2
2
|
//#region src/components/SetBasicAccessRequirementFields/GovernanceUtils.ts
|
|
3
|
-
var
|
|
4
|
-
switch (
|
|
5
|
-
case
|
|
6
|
-
case
|
|
7
|
-
case i: return
|
|
8
|
-
case
|
|
9
|
-
case
|
|
3
|
+
var o = "Access restricted pending review by Synapse Access and Compliance Team.", s = (s) => {
|
|
4
|
+
switch (s.concreteType) {
|
|
5
|
+
case r:
|
|
6
|
+
case t:
|
|
7
|
+
case i: return "";
|
|
8
|
+
case a: return s.termsOfUse;
|
|
9
|
+
case e: return s.actContactInfo;
|
|
10
|
+
case n: return o;
|
|
10
11
|
}
|
|
11
|
-
},
|
|
12
|
+
}, c = (e) => e.concreteType === i || e.concreteType == r || e.concreteType == t;
|
|
12
13
|
//#endregion
|
|
13
|
-
export {
|
|
14
|
+
export { o as LOCK_ACCESS_REQUIREMENT_TEXT, s as getOldAccessRequirementInstructions, c as hasAccessorRequirement };
|
|
14
15
|
|
|
15
16
|
//# sourceMappingURL=GovernanceUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GovernanceUtils.js","names":[],"sources":["../../../src/components/SetBasicAccessRequirementFields/GovernanceUtils.ts"],"sourcesContent":["import {\n ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n AccessRequirement,\n LOCK_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n ManagedACTAccessRequirement,\n SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n SelfSignAccessRequirement,\n TERMS_OF_USE_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n} from '@sage-bionetworks/synapse-types'\n\nexport const LOCK_ACCESS_REQUIREMENT_TEXT =\n 'Access restricted pending review by Synapse Access and Compliance Team.'\n\nexport const getOldAccessRequirementInstructions = (ar: AccessRequirement) => {\n switch (ar.concreteType) {\n case MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n case SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n // uses wiki to store instructions\n return ''\n case TERMS_OF_USE_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n return ar.termsOfUse\n case ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n return ar.actContactInfo\n case LOCK_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n return LOCK_ACCESS_REQUIREMENT_TEXT\n }\n}\n\n/**\n * Returns true iff the access requirement can apply restrictions based on\n * accessor qualities, such as certification or validation status\n */\nexport const hasAccessorRequirement = (\n ar: AccessRequirement,\n): ar is SelfSignAccessRequirement
|
|
1
|
+
{"version":3,"file":"GovernanceUtils.js","names":[],"sources":["../../../src/components/SetBasicAccessRequirementFields/GovernanceUtils.ts"],"sourcesContent":["import {\n ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n AccessRequirement,\n JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n JsonSchemaAccessRequirement,\n LOCK_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n ManagedACTAccessRequirement,\n SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n SelfSignAccessRequirement,\n TERMS_OF_USE_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n} from '@sage-bionetworks/synapse-types'\n\nexport const LOCK_ACCESS_REQUIREMENT_TEXT =\n 'Access restricted pending review by Synapse Access and Compliance Team.'\n\nexport const getOldAccessRequirementInstructions = (ar: AccessRequirement) => {\n switch (ar.concreteType) {\n case MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n case JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n case SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n // uses wiki to store instructions\n return ''\n case TERMS_OF_USE_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n return ar.termsOfUse\n case ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n return ar.actContactInfo\n case LOCK_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE:\n return LOCK_ACCESS_REQUIREMENT_TEXT\n }\n}\n\n/**\n * Returns true iff the access requirement can apply restrictions based on\n * accessor qualities, such as certification or validation status\n */\nexport const hasAccessorRequirement = (\n ar: AccessRequirement,\n): ar is\n | SelfSignAccessRequirement\n | ManagedACTAccessRequirement\n | JsonSchemaAccessRequirement => {\n return (\n ar.concreteType === SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE ||\n ar.concreteType == MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE ||\n ar.concreteType == JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE\n )\n}\n"],"mappings":";;AAaA,IAAa,IACX,2EAEW,KAAuC,MAA0B;CAC5E,QAAQ,EAAG,cAAX;EACE,KAAK;EACL,KAAK;EACL,KAAK,GAEH,OAAO;EACT,KAAK,GACH,OAAO,EAAG;EACZ,KAAK,GACH,OAAO,EAAG;EACZ,KAAK,GACH,OAAO;CACX;AACF,GAMa,KACX,MAME,EAAG,iBAAiB,KACpB,EAAG,gBAAgB,KACnB,EAAG,gBAAgB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ManagedACTAccessRequirement } from '@sage-bionetworks/synapse-types';
|
|
2
|
+
export declare const DUC_TEMPLATE_UPLOAD_ERROR = "There was an error uploading the DUC template. ";
|
|
3
|
+
export type DataUseCertificateSettings = Pick<ManagedACTAccessRequirement, 'id' | 'isDUCRequired' | 'ducTemplateFileHandleId' | 'eDucTemplateId'>;
|
|
4
|
+
export type DataUseCertificateFieldsProps = {
|
|
5
|
+
accessRequirement: DataUseCertificateSettings;
|
|
6
|
+
onChange: (changes: Partial<DataUseCertificateSettings>) => void;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function DataUseCertificateFields(props: DataUseCertificateFieldsProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=DataUseCertificateFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataUseCertificateFields.d.ts","sourceRoot":"","sources":["../../../src/components/SetManagedAccessRequirementFields/DataUseCertificateFields.tsx"],"names":[],"mappings":"AAYA,OAAO,EAIL,2BAA2B,EAE5B,MAAM,iCAAiC,CAAA;AAKxC,eAAO,MAAM,yBAAyB,oDACa,CAAA;AAEnD,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,2BAA2B,EAC3B,IAAI,GAAG,eAAe,GAAG,yBAAyB,GAAG,gBAAgB,CACtE,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,iBAAiB,EAAE,0BAA0B,CAAA;IAE7C,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,0BAA0B,CAAC,KAAK,IAAI,CAAA;IAChE,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,2CA8H5E"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { SynapseErrorBoundary as e } from "../error/ErrorBanner.js";
|
|
2
|
+
import { useListEDucTemplates as t } from "../../synapse-queries/dataaccess/useEDuc.js";
|
|
3
|
+
import "../../synapse-queries/index.js";
|
|
4
|
+
import { UploadDocumentField as n } from "../AccessRequirementList/ManagedACTAccessRequirementRequestFlow/UploadDocumentField.js";
|
|
5
|
+
import { useEffect as r, useMemo as i, useState as a } from "react";
|
|
6
|
+
import { Alert as o, Autocomplete as s, Box as c, Checkbox as l, FormControlLabel as u, TextField as d, Typography as f } from "@mui/material";
|
|
7
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
8
|
+
import { FileHandleAssociateType as g } from "@sage-bionetworks/synapse-types";
|
|
9
|
+
//#region src/components/SetManagedAccessRequirementFields/DataUseCertificateFields.tsx
|
|
10
|
+
var _ = "There was an error uploading the DUC template. ";
|
|
11
|
+
function v(v) {
|
|
12
|
+
let { accessRequirement: y, onChange: b, isLoading: x } = v, [S, C] = a(null), w = i(() => {
|
|
13
|
+
if (y.ducTemplateFileHandleId) return {
|
|
14
|
+
fileHandleId: y.ducTemplateFileHandleId,
|
|
15
|
+
associateObjectType: g.AccessRequirementAttachment,
|
|
16
|
+
associateObjectId: y.id.toString()
|
|
17
|
+
};
|
|
18
|
+
}, [y.ducTemplateFileHandleId, y.id]), { data: T, isLoading: E, hasNextPage: D, fetchNextPage: O } = t();
|
|
19
|
+
r(() => {
|
|
20
|
+
D && O();
|
|
21
|
+
}, [D, O]);
|
|
22
|
+
let k = i(() => T?.pages.flatMap((e) => e.results ?? []) ?? [], [T]), A = i(() => k.find((e) => e.templateId === y.eDucTemplateId) ?? null, [k, y.eDucTemplateId]), j = (e) => {
|
|
23
|
+
if (e.resp && e.success) {
|
|
24
|
+
C(null);
|
|
25
|
+
let t = e.resp;
|
|
26
|
+
b({
|
|
27
|
+
ducTemplateFileHandleId: t.fileHandleId,
|
|
28
|
+
eDucTemplateId: void 0
|
|
29
|
+
});
|
|
30
|
+
} else !e.success && e.error && C(`${_} ${e.error.reason}`);
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ h(p, { children: [
|
|
33
|
+
/* @__PURE__ */ m(f, {
|
|
34
|
+
variant: "body1",
|
|
35
|
+
sx: { fontWeight: 700 },
|
|
36
|
+
children: "DUC"
|
|
37
|
+
}),
|
|
38
|
+
/* @__PURE__ */ m(u, {
|
|
39
|
+
control: /* @__PURE__ */ m(l, {}),
|
|
40
|
+
label: "DUC is required.",
|
|
41
|
+
checked: y.isDUCRequired,
|
|
42
|
+
onChange: (e, t) => b({ isDUCRequired: t })
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ h(e, { children: [/* @__PURE__ */ m(n, {
|
|
45
|
+
id: "duc",
|
|
46
|
+
isLoading: x,
|
|
47
|
+
disabled: !y.isDUCRequired,
|
|
48
|
+
uploadCallback: (e) => j(e),
|
|
49
|
+
documentName: "Template DUC",
|
|
50
|
+
fileHandleAssociations: w ? [w] : void 0,
|
|
51
|
+
isMultiFileUpload: !1,
|
|
52
|
+
uploadBtnVariant: "contained"
|
|
53
|
+
}), S && /* @__PURE__ */ m(o, {
|
|
54
|
+
severity: "error",
|
|
55
|
+
sx: { marginTop: 2 },
|
|
56
|
+
children: S
|
|
57
|
+
})] }),
|
|
58
|
+
/* @__PURE__ */ m(c, {
|
|
59
|
+
sx: { mt: 2 },
|
|
60
|
+
children: /* @__PURE__ */ m(s, {
|
|
61
|
+
id: "eDucTemplate",
|
|
62
|
+
options: k,
|
|
63
|
+
loading: E,
|
|
64
|
+
disabled: !y.isDUCRequired,
|
|
65
|
+
value: A,
|
|
66
|
+
onChange: (e, t) => b({ eDucTemplateId: t?.templateId }),
|
|
67
|
+
getOptionLabel: (e) => e.name ?? "",
|
|
68
|
+
isOptionEqualToValue: (e, t) => e.templateId === t.templateId,
|
|
69
|
+
renderInput: (e) => /* @__PURE__ */ m(d, {
|
|
70
|
+
...e,
|
|
71
|
+
label: "eDUC template (electronic signing)",
|
|
72
|
+
helperText: "Optional. Select a DocuSign template to enable the eDUC signing flow for this Access Requirement."
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
] });
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { _ as DUC_TEMPLATE_UPLOAD_ERROR, v as DataUseCertificateFields };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=DataUseCertificateFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataUseCertificateFields.js","names":[],"sources":["../../../src/components/SetManagedAccessRequirementFields/DataUseCertificateFields.tsx"],"sourcesContent":["import { useListEDucTemplates } from '@/synapse-queries'\nimport {\n Alert,\n Autocomplete,\n Box,\n Checkbox,\n FormControlLabel,\n TextField,\n Typography,\n} from '@mui/material'\nimport { EDucTemplate } from '@sage-bionetworks/synapse-client'\nimport { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'\nimport {\n FileHandleAssociateType,\n FileHandleAssociation,\n FileUploadComplete,\n ManagedACTAccessRequirement,\n UploadCallbackResp,\n} from '@sage-bionetworks/synapse-types'\nimport { useEffect, useMemo, useState } from 'react'\nimport { UploadDocumentField } from '../AccessRequirementList/ManagedACTAccessRequirementRequestFlow/UploadDocumentField'\nimport { SynapseErrorBoundary } from '../error/ErrorBanner'\n\nexport const DUC_TEMPLATE_UPLOAD_ERROR =\n 'There was an error uploading the DUC template. '\n\nexport type DataUseCertificateSettings = Pick<\n ManagedACTAccessRequirement,\n 'id' | 'isDUCRequired' | 'ducTemplateFileHandleId' | 'eDucTemplateId'\n>\n\nexport type DataUseCertificateFieldsProps = {\n accessRequirement: DataUseCertificateSettings\n /* Called with the settings that changed; the caller merges them into its copy of the AR. */\n onChange: (changes: Partial<DataUseCertificateSettings>) => void\n isLoading: boolean\n}\n\nexport function DataUseCertificateFields(props: DataUseCertificateFieldsProps) {\n const { accessRequirement, onChange, isLoading } = props\n\n const [uploadDucTemplateError, setUploadDucTemplateError] = useState<\n string | null\n >(null)\n\n const ducTemplateFileHandleAssociation = useMemo(() => {\n if (accessRequirement.ducTemplateFileHandleId) {\n const ducTemplateFileHandleAssociation: FileHandleAssociation = {\n fileHandleId: accessRequirement.ducTemplateFileHandleId,\n associateObjectType:\n FileHandleAssociateType.AccessRequirementAttachment,\n associateObjectId: accessRequirement.id.toString(),\n }\n return ducTemplateFileHandleAssociation\n }\n return undefined\n }, [accessRequirement.ducTemplateFileHandleId, accessRequirement.id])\n\n const {\n data: eDucTemplateData,\n isLoading: isLoadingEDucTemplates,\n hasNextPage: hasNextEDucTemplatePage,\n fetchNextPage: fetchNextEDucTemplatePage,\n } = useListEDucTemplates()\n // Auto-fetch all pages so the dropdown always shows the complete template list.\n useEffect(() => {\n if (hasNextEDucTemplatePage) {\n void fetchNextEDucTemplatePage()\n }\n }, [hasNextEDucTemplatePage, fetchNextEDucTemplatePage])\n const eDucTemplates = useMemo(\n () => eDucTemplateData?.pages.flatMap(page => page.results ?? []) ?? [],\n [eDucTemplateData],\n )\n const selectedEDucTemplate = useMemo(\n () =>\n eDucTemplates.find(\n template => template.templateId === accessRequirement.eDucTemplateId,\n ) ?? null,\n [eDucTemplates, accessRequirement.eDucTemplateId],\n )\n\n const uploadDucTemplateCallback = (data: UploadCallbackResp) => {\n if (data.resp && data.success) {\n setUploadDucTemplateError(null)\n // Files are uploaded and synced with the server immediately\n const uploadResponse: FileUploadComplete = data.resp\n onChange({\n ducTemplateFileHandleId: uploadResponse.fileHandleId,\n eDucTemplateId: undefined, // mutually exclusive with file upload\n })\n } else if (!data.success && data.error) {\n setUploadDucTemplateError(\n `${DUC_TEMPLATE_UPLOAD_ERROR} ${\n (data.error as SynapseClientError).reason\n }`,\n )\n }\n }\n\n return (\n <>\n <Typography\n variant=\"body1\"\n sx={{\n fontWeight: 700,\n }}\n >\n DUC\n </Typography>\n <FormControlLabel\n control={<Checkbox />}\n label=\"DUC is required.\"\n checked={accessRequirement.isDUCRequired}\n onChange={(_event, checked: boolean) =>\n onChange({ isDUCRequired: checked })\n }\n />\n <SynapseErrorBoundary>\n <UploadDocumentField\n id=\"duc\"\n isLoading={isLoading}\n disabled={!accessRequirement.isDUCRequired}\n uploadCallback={resp => uploadDucTemplateCallback(resp)}\n documentName=\"Template DUC\"\n fileHandleAssociations={\n ducTemplateFileHandleAssociation\n ? [ducTemplateFileHandleAssociation]\n : undefined\n }\n isMultiFileUpload={false}\n uploadBtnVariant=\"contained\"\n />\n {uploadDucTemplateError && (\n <Alert severity=\"error\" sx={{ marginTop: 2 }}>\n {uploadDucTemplateError}\n </Alert>\n )}\n </SynapseErrorBoundary>\n <Box sx={{ mt: 2 }}>\n <Autocomplete<EDucTemplate>\n id=\"eDucTemplate\"\n options={eDucTemplates}\n loading={isLoadingEDucTemplates}\n disabled={!accessRequirement.isDUCRequired}\n value={selectedEDucTemplate}\n onChange={(_event, template) =>\n onChange({ eDucTemplateId: template?.templateId })\n }\n getOptionLabel={template => template.name ?? ''}\n isOptionEqualToValue={(option, value) =>\n option.templateId === value.templateId\n }\n renderInput={params => (\n <TextField\n {...params}\n label=\"eDUC template (electronic signing)\"\n helperText=\"Optional. Select a DocuSign template to enable the eDUC signing flow for this Access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AAE,eAAe,EAAQ,CAAC;EAEtC,CAAA;EACD,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;GACE,IAAG;GACQ;GACX,UAAU,CAAC,EAAkB;GAC7B,iBAAgB,MAAQ,EAA0B,CAAI;GACtD,cAAa;GACb,wBACE,IACI,CAAC,CAAgC,IACjC,KAAA;GAEN,mBAAmB;GACnB,kBAAiB;EAClB,CAAA,GACA,KACC,kBAAC,GAAD;GAAO,UAAS;GAAQ,IAAI,EAAE,WAAW,EAAE;aACxC;EACI,CAAA,CAEW,EAAA,CAAA;EACtB,kBAAC,GAAD;GAAK,IAAI,EAAE,IAAI,EAAE;aACf,kBAAC,GAAD;IACE,IAAG;IACH,SAAS;IACT,SAAS;IACT,UAAU,CAAC,EAAkB;IAC7B,OAAO;IACP,WAAW,GAAQ,MACjB,EAAS,EAAE,gBAAgB,GAAU,WAAW,CAAC;IAEnD,iBAAgB,MAAY,EAAS,QAAQ;IAC7C,uBAAuB,GAAQ,MAC7B,EAAO,eAAe,EAAM;IAE9B,cAAa,MACX,kBAAC,GAAD;KACE,GAAI;KACJ,OAAM;KACN,YAAW;IACZ,CAAA;GAEJ,CAAA;EACE,CAAA;CACL,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const getValidExpirationPeriodOrErrorMessage: (expirationPeriodDays: string) => string | number;
|
|
2
|
+
export type ExpirationPeriodFieldProps = {
|
|
3
|
+
days: string;
|
|
4
|
+
error: string | null;
|
|
5
|
+
onChange: (days: string) => void;
|
|
6
|
+
onBlur: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function ExpirationPeriodField(props: ExpirationPeriodFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=ExpirationPeriodField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpirationPeriodField.d.ts","sourceRoot":"","sources":["../../../src/components/SetManagedAccessRequirementFields/ExpirationPeriodField.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,sCAAsC,GACjD,sBAAsB,MAAM,oBAa7B,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IAEvC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB,CAAA;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,2CAgBtE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DAY_IN_MS as e } from "../../utils/SynapseConstants.js";
|
|
2
|
+
import { TextField as t } from "@mui/material";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/SetManagedAccessRequirementFields/ExpirationPeriodField.tsx
|
|
5
|
+
var r = (t) => {
|
|
6
|
+
if (t === "") return 0;
|
|
7
|
+
let n = "Please enter a valid expiration period (in days): ";
|
|
8
|
+
if (/^[-]?\d+$/.test(t)) {
|
|
9
|
+
let r = Number(t);
|
|
10
|
+
return r < 0 ? `${n}If expiration period is set, then it must be greater than 0.` : r * e;
|
|
11
|
+
}
|
|
12
|
+
return `${n}For input string: "${t}"`;
|
|
13
|
+
};
|
|
14
|
+
function i(e) {
|
|
15
|
+
let { days: r, error: i, onChange: a, onBlur: o } = e;
|
|
16
|
+
return /* @__PURE__ */ n(t, {
|
|
17
|
+
id: "expirationPeriod",
|
|
18
|
+
name: "expirationPeriod",
|
|
19
|
+
label: "Expiration period (days)",
|
|
20
|
+
value: r,
|
|
21
|
+
error: !!i,
|
|
22
|
+
helperText: i,
|
|
23
|
+
sx: { mt: 1 },
|
|
24
|
+
fullWidth: !0,
|
|
25
|
+
onChange: (e) => a(e.target.value),
|
|
26
|
+
onBlur: o
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { i as ExpirationPeriodField, r as getValidExpirationPeriodOrErrorMessage };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=ExpirationPeriodField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpirationPeriodField.js","names":[],"sources":["../../../src/components/SetManagedAccessRequirementFields/ExpirationPeriodField.tsx"],"sourcesContent":["import { DAY_IN_MS } from '@/utils/SynapseConstants'\nimport { TextField } from '@mui/material'\n\nexport const getValidExpirationPeriodOrErrorMessage = (\n expirationPeriodDays: string,\n) => {\n if (expirationPeriodDays === '') return 0\n\n const msgPrefix = 'Please enter a valid expiration period (in days): '\n if (/^[-]?\\d+$/.test(expirationPeriodDays)) {\n const num = Number(expirationPeriodDays)\n if (num < 0) {\n return `${msgPrefix}If expiration period is set, then it must be greater than 0.`\n }\n return num * DAY_IN_MS\n }\n return `${msgPrefix}For input string: \"${expirationPeriodDays}\"`\n}\n\nexport type ExpirationPeriodFieldProps = {\n /* The expiration period in days, as typed by the user */\n days: string\n error: string | null\n onChange: (days: string) => void\n onBlur: () => void\n}\n\nexport function ExpirationPeriodField(props: ExpirationPeriodFieldProps) {\n const { days, error, onChange, onBlur } = props\n return (\n <TextField\n id=\"expirationPeriod\"\n name=\"expirationPeriod\"\n label=\"Expiration period (days)\"\n value={days}\n error={Boolean(error)}\n helperText={error}\n sx={{ mt: 1 }}\n fullWidth\n onChange={event => onChange(event.target.value)}\n onBlur={onBlur}\n />\n )\n}\n"],"mappings":";;;;AAGA,IAAa,KACX,MACG;CACH,IAAI,MAAyB,IAAI,OAAO;CAExC,IAAM,IAAY;CAClB,IAAI,YAAY,KAAK,CAAoB,GAAG;EAC1C,IAAM,IAAM,OAAO,CAAoB;EAIvC,OAHI,IAAM,IACD,GAAG,EAAU,gEAEf,IAAM;CACf;CACA,OAAO,GAAG,EAAU,qBAAqB,EAAqB;AAChE;AAUA,SAAgB,EAAsB,GAAmC;CACvE,IAAM,EAAE,SAAM,UAAO,aAAU,cAAW;CAC1C,OACE,kBAAC,GAAD;EACE,IAAG;EACH,MAAK;EACL,OAAM;EACN,OAAO;EACP,OAAO,EAAQ;EACf,YAAY;EACZ,IAAI,EAAE,IAAI,EAAE;EACZ,WAAA;EACA,WAAU,MAAS,EAAS,EAAM,OAAO,KAAK;EACtC;CACT,CAAA;AAEL"}
|