@wildo-ai/saas-frontend-lib 1.1.15 → 1.1.17
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/esm/components/compliance/EmbeddedSigningFrame.d.ts.map +1 -1
- package/dist/esm/components/compliance/EmbeddedSigningFrame.js +17 -6
- package/dist/esm/components/compliance/EmbeddedSigningFrame.js.map +1 -1
- package/dist/esm/components/data-display/approval-seal.d.ts +7 -5
- package/dist/esm/components/data-display/approval-seal.d.ts.map +1 -1
- package/dist/esm/components/data-display/approval-seal.js +10 -4
- package/dist/esm/components/data-display/approval-seal.js.map +1 -1
- package/dist/esm/components/data-display/signature-requests.d.ts +81 -0
- package/dist/esm/components/data-display/signature-requests.d.ts.map +1 -0
- package/dist/esm/components/data-display/signature-requests.js +123 -0
- package/dist/esm/components/data-display/signature-requests.js.map +1 -0
- package/dist/esm/components/flows-actors/approval.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/approval.js +8 -15
- package/dist/esm/components/flows-actors/approval.js.map +1 -1
- package/dist/esm/components/flows-actors/approval.labels.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/approval.labels.js +3 -0
- package/dist/esm/components/flows-actors/approval.labels.js.map +1 -1
- package/dist/esm/components/flows-actors/task-detail.d.ts +12 -1
- package/dist/esm/components/flows-actors/task-detail.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/task-detail.js +2 -2
- package/dist/esm/components/flows-actors/task-detail.js.map +1 -1
- package/dist/esm/components/form/automated/ResourceAutomatedForm.d.ts.map +1 -1
- package/dist/esm/components/form/automated/ResourceAutomatedForm.js +44 -29
- package/dist/esm/components/form/automated/ResourceAutomatedForm.js.map +1 -1
- package/dist/esm/components/navigation/NavigationItemBadge.d.ts +16 -0
- package/dist/esm/components/navigation/NavigationItemBadge.d.ts.map +1 -1
- package/dist/esm/components/navigation/NavigationItemBadge.js +14 -2
- package/dist/esm/components/navigation/NavigationItemBadge.js.map +1 -1
- package/dist/esm/components/navigation/app-level/ApplicationLevel_NavigationBack.d.ts +3 -3
- package/dist/esm/components/navigation/app-level/ApplicationLevel_NavigationBack.js +3 -3
- package/dist/esm/components/navigation/app-level/ApplicationLevel_NavigationBack.js.map +1 -1
- package/dist/esm/components/navigation/app-level/SidebarResourceBrowser.d.ts +5 -13
- package/dist/esm/components/navigation/app-level/SidebarResourceBrowser.d.ts.map +1 -1
- package/dist/esm/components/navigation/app-level/SidebarResourceBrowser.js +30 -255
- package/dist/esm/components/navigation/app-level/SidebarResourceBrowser.js.map +1 -1
- package/dist/esm/components/navigation/app-level/useCommandMenuBehavior.d.ts +22 -1
- package/dist/esm/components/navigation/app-level/useCommandMenuBehavior.d.ts.map +1 -1
- package/dist/esm/components/navigation/app-level/useCommandMenuBehavior.js +57 -26
- package/dist/esm/components/navigation/app-level/useCommandMenuBehavior.js.map +1 -1
- package/dist/esm/components/navigation/app-level/useMenuBarBehavior.d.ts +1 -1
- package/dist/esm/components/navigation/app-level/useMenuBarBehavior.d.ts.map +1 -1
- package/dist/esm/components/navigation/app-level/useMenuBarBehavior.js +35 -1
- package/dist/esm/components/navigation/app-level/useMenuBarBehavior.js.map +1 -1
- package/dist/esm/components/navigation/app-level/useMenuUserOrgBehavior.d.ts +1 -1
- package/dist/esm/components/navigation/app-level/useMenuUserOrgBehavior.d.ts.map +1 -1
- package/dist/esm/components/navigation/app-level/useMenuUserOrgBehavior.js +26 -4
- package/dist/esm/components/navigation/app-level/useMenuUserOrgBehavior.js.map +1 -1
- package/dist/esm/components/navigation/app-level/useNavigationBackBehavior.d.ts +31 -0
- package/dist/esm/components/navigation/app-level/useNavigationBackBehavior.d.ts.map +1 -0
- package/dist/esm/components/navigation/app-level/useNavigationBackBehavior.js +42 -0
- package/dist/esm/components/navigation/app-level/useNavigationBackBehavior.js.map +1 -0
- package/dist/esm/components/navigation/app-level/useSidebarResourceBrowser.d.ts +76 -0
- package/dist/esm/components/navigation/app-level/useSidebarResourceBrowser.d.ts.map +1 -0
- package/dist/esm/components/navigation/app-level/useSidebarResourceBrowser.js +268 -0
- package/dist/esm/components/navigation/app-level/useSidebarResourceBrowser.js.map +1 -0
- package/dist/esm/components/navigation/command.d.ts +5 -0
- package/dist/esm/components/navigation/command.d.ts.map +1 -1
- package/dist/esm/components/navigation/command.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_DangerZone.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_DangerZone.js +5 -2
- package/dist/esm/components/resources/ResourceLayout_DangerZone.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_InsertedViews.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_InsertedViews.js +5 -1
- package/dist/esm/components/resources/ResourceLayout_InsertedViews.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_List.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_List.js +4 -1
- package/dist/esm/components/resources/ResourceLayout_List.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_RecordSharing.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_RecordSharing.js +4 -1
- package/dist/esm/components/resources/ResourceLayout_RecordSharing.js.map +1 -1
- package/dist/esm/components/resources/collection/board/ResourceCollectionBody_Board.d.ts.map +1 -1
- package/dist/esm/components/resources/collection/board/ResourceCollectionBody_Board.js +4 -1
- package/dist/esm/components/resources/collection/board/ResourceCollectionBody_Board.js.map +1 -1
- package/dist/esm/components/resources/collection/calendar/ResourceCollectionBody_Calendar.d.ts.map +1 -1
- package/dist/esm/components/resources/collection/calendar/ResourceCollectionBody_Calendar.js +4 -1
- package/dist/esm/components/resources/collection/calendar/ResourceCollectionBody_Calendar.js.map +1 -1
- package/dist/esm/components/resources/collection/timeline/ResourceCollectionBody_Timeline.d.ts.map +1 -1
- package/dist/esm/components/resources/collection/timeline/ResourceCollectionBody_Timeline.js +4 -1
- package/dist/esm/components/resources/collection/timeline/ResourceCollectionBody_Timeline.js.map +1 -1
- package/dist/esm/components/resources/skeleton/Group.d.ts.map +1 -1
- package/dist/esm/components/resources/skeleton/Group.js +4 -1
- package/dist/esm/components/resources/skeleton/Group.js.map +1 -1
- package/dist/esm/components/sections/ContentSectionContainer.d.ts.map +1 -1
- package/dist/esm/components/sections/ContentSectionContainer.js +11 -7
- package/dist/esm/components/sections/ContentSectionContainer.js.map +1 -1
- package/dist/esm/components/sections/content-section.d.ts +1 -3
- package/dist/esm/components/sections/content-section.d.ts.map +1 -1
- package/dist/esm/components/sections/content-section.js.map +1 -1
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.d.ts +79 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.d.ts.map +1 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.js +272 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.js.map +1 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.d.ts +3 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.d.ts.map +1 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.js +66 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.js.map +1 -0
- package/dist/esm/components/settings/AppPage_ConnectedAccountsSettings.d.ts +12 -0
- package/dist/esm/components/settings/AppPage_ConnectedAccountsSettings.d.ts.map +1 -1
- package/dist/esm/components/settings/AppPage_ConnectedAccountsSettings.js +28 -6
- package/dist/esm/components/settings/AppPage_ConnectedAccountsSettings.js.map +1 -1
- package/dist/esm/components/settings/SettingsHub.d.ts.map +1 -1
- package/dist/esm/components/settings/SettingsHub.js +6 -0
- package/dist/esm/components/settings/SettingsHub.js.map +1 -1
- package/dist/esm/components/typography/document-heading-level.d.ts +28 -0
- package/dist/esm/components/typography/document-heading-level.d.ts.map +1 -0
- package/dist/esm/components/typography/document-heading-level.js +63 -0
- package/dist/esm/components/typography/document-heading-level.js.map +1 -0
- package/dist/esm/components/views/chart-view/ChartView.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/ChartView.js +20 -16
- package/dist/esm/components/views/chart-view/ChartView.js.map +1 -1
- package/dist/esm/components/views/chart-view/ChartView.labels.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/ChartView.labels.js +7 -0
- package/dist/esm/components/views/chart-view/ChartView.labels.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builder-utils.d.ts +12 -3
- package/dist/esm/components/views/chart-view/option-builder/builder-utils.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builder-utils.js +18 -11
- package/dist/esm/components/views/chart-view/option-builder/builder-utils.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/bar-family.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/bar-family.builder.js +2 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/bar-family.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/funnel.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/funnel.builder.js +7 -3
- package/dist/esm/components/views/chart-view/option-builder/builders/funnel.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/gauge.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/gauge.builder.js +6 -2
- package/dist/esm/components/views/chart-view/option-builder/builders/gauge.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/heatmap.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/heatmap.builder.js +7 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/heatmap.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/hierarchical-family.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/hierarchical-family.builder.js +13 -9
- package/dist/esm/components/views/chart-view/option-builder/builders/hierarchical-family.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/line-family.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/line-family.builder.js +2 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/line-family.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/parallel.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/parallel.builder.js +2 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/parallel.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/pie-family.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/pie-family.builder.js +4 -3
- package/dist/esm/components/views/chart-view/option-builder/builders/pie-family.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/radar.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/radar.builder.js +2 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/radar.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/sankey.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/sankey.builder.js +5 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/sankey.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/statistical-family.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/statistical-family.builder.js +4 -3
- package/dist/esm/components/views/chart-view/option-builder/builders/statistical-family.builder.js.map +1 -1
- package/dist/esm/components/views/composite-view/CompositeView.d.ts +6 -0
- package/dist/esm/components/views/composite-view/CompositeView.d.ts.map +1 -1
- package/dist/esm/components/views/composite-view/CompositeView.js +12 -2
- package/dist/esm/components/views/composite-view/CompositeView.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.d.ts +57 -0
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.d.ts.map +1 -0
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.js +136 -0
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.js.map +1 -0
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.d.ts +20 -0
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.d.ts.map +1 -1
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.js +139 -22
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.d.ts.map +1 -1
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.js +5 -0
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.d.ts +4 -0
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.d.ts.map +1 -1
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.js +19 -0
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.d.ts +26 -0
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.d.ts.map +1 -0
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.js +3 -0
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.js.map +1 -0
- package/dist/esm/core/app-shell/app-shell.schemas.d.ts +87 -16
- package/dist/esm/core/app-shell/app-shell.schemas.d.ts.map +1 -1
- package/dist/esm/core/app-shell/app-shell.schemas.js +16 -0
- package/dist/esm/core/app-shell/app-shell.schemas.js.map +1 -1
- package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.d.ts.map +1 -1
- package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.js +1 -0
- package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.js.map +1 -1
- package/dist/esm/core/config/composite-view.schemas.d.ts +19 -0
- package/dist/esm/core/config/composite-view.schemas.d.ts.map +1 -1
- package/dist/esm/core/config/composite-view.schemas.js.map +1 -1
- package/dist/esm/core/config/engine-settings-destinations.d.ts.map +1 -1
- package/dist/esm/core/config/engine-settings-destinations.js +23 -0
- package/dist/esm/core/config/engine-settings-destinations.js.map +1 -1
- package/dist/esm/core/config/settings-hub-presentation.frontend.utils.d.ts.map +1 -1
- package/dist/esm/core/config/settings-hub-presentation.frontend.utils.js +3 -0
- package/dist/esm/core/config/settings-hub-presentation.frontend.utils.js.map +1 -1
- package/dist/esm/core/config/settings-hub.frontend.schemas.d.ts +12 -0
- package/dist/esm/core/config/settings-hub.frontend.schemas.d.ts.map +1 -1
- package/dist/esm/core/config/settings-hub.frontend.schemas.js +12 -0
- package/dist/esm/core/config/settings-hub.frontend.schemas.js.map +1 -1
- package/dist/esm/core/events/events.frontend.schemas.d.ts +16 -0
- package/dist/esm/core/events/events.frontend.schemas.d.ts.map +1 -1
- package/dist/esm/core/flows-actors/FlowsActorsContext.d.ts +10 -1
- package/dist/esm/core/flows-actors/FlowsActorsContext.d.ts.map +1 -1
- package/dist/esm/core/flows-actors/FlowsActorsContext.js +12 -3
- package/dist/esm/core/flows-actors/FlowsActorsContext.js.map +1 -1
- package/dist/esm/core/flows-actors/conversation-history.model.d.ts +19 -1
- package/dist/esm/core/flows-actors/conversation-history.model.d.ts.map +1 -1
- package/dist/esm/core/flows-actors/conversation-history.model.js +45 -4
- package/dist/esm/core/flows-actors/conversation-history.model.js.map +1 -1
- package/dist/esm/core/navigation/NavigationContentAreas.d.ts +0 -5
- package/dist/esm/core/navigation/NavigationContentAreas.d.ts.map +1 -1
- package/dist/esm/core/navigation/NavigationContentAreas.js +27 -1
- package/dist/esm/core/navigation/NavigationContentAreas.js.map +1 -1
- package/dist/esm/core/navigation/navigation.schemas.d.ts +20 -0
- package/dist/esm/core/navigation/navigation.schemas.d.ts.map +1 -1
- package/dist/esm/core/navigation/navigation.schemas.js +4 -0
- package/dist/esm/core/navigation/navigation.schemas.js.map +1 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.d.ts.map +1 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.js +5 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.js.map +1 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts +59 -5
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts.map +1 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.js +58 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.js.map +1 -1
- package/dist/esm/core/resources/hooks/useOperationEnabled.d.ts.map +1 -1
- package/dist/esm/core/resources/hooks/useOperationEnabled.js +41 -3
- package/dist/esm/core/resources/hooks/useOperationEnabled.js.map +1 -1
- package/dist/esm/core/resources/resources-repository.frontend.service.d.ts.map +1 -1
- package/dist/esm/core/resources/resources-repository.frontend.service.js +2 -0
- package/dist/esm/core/resources/resources-repository.frontend.service.js.map +1 -1
- package/dist/esm/core/runtime/AppRouter.d.ts.map +1 -1
- package/dist/esm/core/runtime/AppRouter.js +2 -1
- package/dist/esm/core/runtime/AppRouter.js.map +1 -1
- package/dist/esm/core/runtime/routes.frontend.definitions.d.ts +6 -0
- package/dist/esm/core/runtime/routes.frontend.definitions.d.ts.map +1 -1
- package/dist/esm/core/runtime/routes.frontend.definitions.js +7 -1
- package/dist/esm/core/runtime/routes.frontend.definitions.js.map +1 -1
- package/dist/esm/core/search/command-score.d.ts +33 -0
- package/dist/esm/core/search/command-score.d.ts.map +1 -0
- package/dist/esm/core/search/command-score.js +109 -0
- package/dist/esm/core/search/command-score.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedSigningFrame.d.ts","sourceRoot":"","sources":["../../../../src/components/compliance/EmbeddedSigningFrame.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"EmbeddedSigningFrame.d.ts","sourceRoot":"","sources":["../../../../src/components/compliance/EmbeddedSigningFrame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+D,MAAM,OAAO,CAAC;AAoBpF,4IAA4I;AAC5I;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,yBAAyB;IACxC,2FAA2F;IAC3F,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,yFAAyF;IACzF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,6GAA6G;IAC7G,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yGAAyG;IACzG,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAsCD,wBAAgB,oBAAoB,CAAC,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,EAAE,yBAAyB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAmFvK"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { CoreResourceType, ErrorType, ResourceOperationVariantType, ResourcesConfig_OperationPathUtils, SIGNING_RETURN_PAGE_PATH, SignatureRequestSigners_Operations, } from '@wildo-ai/saas-models';
|
|
2
|
+
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { CoreResourceType, coreResourceShared_FieldIdentifier, ErrorType, ResourceOperationVariantType, ResourcesConfig_OperationPathUtils, SIGNING_RETURN_PAGE_PATH, SignatureRequestSigners_Operations, } from '@wildo-ai/saas-models';
|
|
4
4
|
import { LoadingSpinner } from '../../components/feedback/loading-spinner.js';
|
|
5
5
|
import { Alert, AlertDescription } from '../../components/overlays/containers/alert.js';
|
|
6
6
|
import { isBackendRefusal } from '../../core/errors/backend-refusal.frontend.js';
|
|
7
7
|
import { useUserFacingErrorMessage } from '../../core/errors/useUserFacingErrorMessage.js';
|
|
8
8
|
import { useResourceRegistry } from '../../core/resources/useResourceRegistry.js';
|
|
9
|
+
import { ApplicationContext } from '../../core/runtime/ApplicationContext.shared.js';
|
|
10
|
+
import { useAppScopeSafe } from '../../core/scope/useAppScope.js';
|
|
9
11
|
import { cn } from '../../core/ui/cn.js';
|
|
10
12
|
/** @wildo_source:part:end saas.frontend.electronic-signatures.embedded-signing-frame */
|
|
11
13
|
/** Where the frame is. */
|
|
@@ -31,6 +33,8 @@ const OPEN_SIGNING_SESSION_KEY = ResourcesConfig_OperationPathUtils.createOperat
|
|
|
31
33
|
* Whether the frame has reached the application's signing-return page. While it shows the vendor's page, reading its
|
|
32
34
|
* location throws (another origin): that is "not yet".
|
|
33
35
|
*/
|
|
36
|
+
/** The route parameter that names the application in `/applications/{applicationId}/…`. */
|
|
37
|
+
const APPLICATION_FIELD_IDENTIFIER = coreResourceShared_FieldIdentifier[CoreResourceType.APPLICATION];
|
|
34
38
|
function frameReturned(frame) {
|
|
35
39
|
try {
|
|
36
40
|
return frame?.contentWindow?.location.pathname === SIGNING_RETURN_PAGE_PATH;
|
|
@@ -46,6 +50,15 @@ export function EmbeddedSigningFrame({ linkedResourceType, linkedResourceId, tit
|
|
|
46
50
|
const [url, setUrl] = useState(null);
|
|
47
51
|
const [failure, setFailure] = useState(null);
|
|
48
52
|
const frameRef = useRef(null);
|
|
53
|
+
// The signing session is an APPLICATION-scoped operation (`/applications/{applicationId}/…`), asked from an
|
|
54
|
+
// organization's record page. The id comes from the application's identity, never from the scope: the access token
|
|
55
|
+
// carries no applicationId claim, so the scope's `currentApplicationId` is null and its injection supplies nothing
|
|
56
|
+
// (the same correction `useVisibleSettingsHubConfig` made). Without it the call cannot be addressed and the frame
|
|
57
|
+
// showed "Service unavailable" on every page (Wonder Ledger's Yousign e2e lane, 2026-11-18). The scope stays a
|
|
58
|
+
// fallback, so the day the token carries the claim nothing here changes.
|
|
59
|
+
const applicationIdentityId = useContext(ApplicationContext)?.appIdentity?.applicationId;
|
|
60
|
+
const scopedApplicationId = useAppScopeSafe()?.currentApplicationId;
|
|
61
|
+
const applicationId = applicationIdentityId ?? scopedApplicationId ?? undefined;
|
|
49
62
|
// Read through refs so a provider handing out new function identities cannot make the frame ask again.
|
|
50
63
|
const doOperationRef = useRef(doOperation);
|
|
51
64
|
doOperationRef.current = doOperation;
|
|
@@ -56,9 +69,7 @@ export function EmbeddedSigningFrame({ linkedResourceType, linkedResourceId, tit
|
|
|
56
69
|
useEffect(() => {
|
|
57
70
|
let cancelled = false;
|
|
58
71
|
setStatus(EmbeddedSigningFrameStatus.OPENING);
|
|
59
|
-
doOperationRef.current(OPEN_SIGNING_SESSION_KEY,
|
|
60
|
-
// The application scope (its id in the route) is merged in by the scoped registry.
|
|
61
|
-
{ contextualParameters: {}, requestData: { linkedResourceType, linkedResourceId, returnUrl: `${window.location.origin}${SIGNING_RETURN_PAGE_PATH}` } },
|
|
72
|
+
doOperationRef.current(OPEN_SIGNING_SESSION_KEY, { contextualParameters: applicationId ? { [APPLICATION_FIELD_IDENTIFIER]: applicationId } : {}, requestData: { linkedResourceType, linkedResourceId, returnUrl: `${window.location.origin}${SIGNING_RETURN_PAGE_PATH}` } },
|
|
62
73
|
// A person with nothing to sign is the common case, not an error: no global error toast.
|
|
63
74
|
{ silent: true })
|
|
64
75
|
.then((session) => {
|
|
@@ -81,7 +92,7 @@ export function EmbeddedSigningFrame({ linkedResourceType, linkedResourceId, tit
|
|
|
81
92
|
return () => {
|
|
82
93
|
cancelled = true;
|
|
83
94
|
};
|
|
84
|
-
}, [linkedResourceType, linkedResourceId]);
|
|
95
|
+
}, [linkedResourceType, linkedResourceId, applicationId]);
|
|
85
96
|
const handleLoad = useCallback(() => {
|
|
86
97
|
if (!frameReturned(frameRef.current))
|
|
87
98
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedSigningFrame.js","sourceRoot":"","sources":["../../../../src/components/compliance/Embe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,0BAA0B,CAAC,OAAO;QAAE,OAAO,KAAC,cAAc,KAAG,CAAC;IAC7E,IAAI,MAAM,KAAK,0BAA0B,CAAC,MAAM,EAAE,CAAC;QACjD,OAAO,CACL,KAAC,KAAK,IAAC,OAAO,EAAC,aAAa,YAC1B,KAAC,gBAAgB,cAAE,OAAO,GAAoB,GACxC,CACT,CAAC;IACJ,CAAC;IACD,OAAO,CACL,iBACE,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,GAAG,IAAI,SAAS,EACrB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,UAAU;QAClB,kHAAkH;QAClH,kDAAkD;QAClD,OAAO,EAAC,yFAAyF;QACjG,oHAAoH;QACpH,cAAc,EAAC,eAAe,EAC9B,SAAS,EAAE,EAAE,CAAC,qCAAqC,EAAE,SAAS,CAAC,GAC/D,CACH,CAAC;AACJ,CAAC","sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport {\n CoreResourceType,\n ErrorType,\n ResourceOperationVariantType,\n ResourcesConfig_OperationPathUtils,\n SIGNING_RETURN_PAGE_PATH,\n SignatureRequestSigners_Operations,\n type SignatureRequestSigners_OpenSigningSessionResponse,\n} from '@wildo-ai/saas-models';\nimport { LoadingSpinner } from '~wildo-frontend-lib/components/feedback/loading-spinner';\nimport { Alert, AlertDescription } from '~wildo-frontend-lib/components/overlays/containers/alert';\nimport { isBackendRefusal } from '~wildo-frontend-lib/core/errors/backend-refusal.frontend';\nimport { useUserFacingErrorMessage } from '~wildo-frontend-lib/core/errors/useUserFacingErrorMessage';\nimport { useResourceRegistry } from '~wildo-frontend-lib/core/resources/useResourceRegistry';\nimport { cn } from '~wildo-frontend-lib/core/ui/cn';\n\n/** @wildo_source:part:start saas.frontend.electronic-signatures.embedded-signing-frame facet:layer:frontend facet:audience:app-developer */\n/**\n * Embedded signing: the signed-in person signs a record's deliverable at the signature vendor, inside a frame of the\n * application, instead of following the vendor's e-mail. Import from `@wildo-ai/saas-frontend-lib`.\n *\n * Place it where the person meets the record (an engagement letter's page, say). On mount it asks the backend for the\n * vendor's signing page (`signatureRequestSigners.openSigningSession`). The answer is given only to a signer an open\n * request on that record names and the vendor says has not signed yet, so for anybody else, once the person has signed,\n * and when the request's provider signs from its e-mail only, the component renders NOTHING. The page is valid for\n * minutes and is never stored, which is why it is asked for here, when the person is in front of it. A signer whose turn\n * has not come (signers who sign in turn) is shown nothing either, until it does.\n *\n * When the person is done, a vendor that redirects sends the frame to the application's own {@link SIGNING_RETURN_PAGE_PATH};\n * the frame sees it arrive (it is now same-origin), closes, and calls `onSigningReturned`. A vendor that does not redirect\n * (or redirects to another of the application's origins) keeps showing its own end page. Either way nothing here says the\n * document is signed: every vendor's own guidance is that the end of the frame is not the outcome, and the request becomes\n * SIGNED only once the engine has validated the signed document, at its next re-read (poll or vendor notification).\n *\n * What it needs elsewhere: a provider that claims `EMBEDDED_ELECTRONIC_SIGNATURE` and declares `embeddedSigning`, and a\n * `wildo config sync` then `wildo dev sync-csp` since it was added, which put the vendor's signing origins in the SaaS\n * frontend's CSP `frame-src` from the provider's own declaration; without them the browser refuses to load the frame.\n *\n * It renders no words of its own: the application passes the frame's accessible `title`.\n */\nexport interface EmbeddedSigningFrameProps {\n /** The record the deliverable belongs to: the signature request's `linkedResourceType`. */\n readonly linkedResourceType: string;\n /** The record the deliverable belongs to: the signature request's `linkedResourceId`. */\n readonly linkedResourceId: string;\n /** The frame's accessible name (WCAG 4.1.2), in the person's language, e.g. \"Sign the engagement letter\". */\n readonly title: string;\n /** Called once the person left the vendor's page. Re-read the record if you show its signature state. */\n readonly onSigningReturned?: () => void;\n readonly className?: string;\n}\n/** @wildo_source:part:end saas.frontend.electronic-signatures.embedded-signing-frame */\n\n/** Where the frame is. */\nenum EmbeddedSigningFrameStatus {\n /** Asking the backend for the signing page. */\n OPENING = 'opening',\n /** The vendor's page is in the frame. */\n SIGNING = 'signing',\n /** Nothing for this person to sign here, or they have left the vendor's page: nothing is rendered. */\n NOTHING = 'nothing',\n /** The page could not be opened. */\n FAILED = 'failed',\n}\n\nconst OPEN_SIGNING_SESSION_KEY = ResourcesConfig_OperationPathUtils.createOperationPathKey({\n resourceIdentifier: CoreResourceType.SIGNATURE_REQUEST_SIGNERS,\n operationIdentifier: SignatureRequestSigners_Operations.OPEN_SIGNING_SESSION,\n variantType: ResourceOperationVariantType.API_CALL,\n isOperationDefault: true,\n isBulkOperation: false,\n});\n\n/**\n * Whether the frame has reached the application's signing-return page. While it shows the vendor's page, reading its\n * location throws (another origin): that is \"not yet\".\n */\nfunction frameReturned(frame: HTMLIFrameElement | null): boolean {\n try {\n return frame?.contentWindow?.location.pathname === SIGNING_RETURN_PAGE_PATH;\n } catch {\n return false;\n }\n}\n\nexport function EmbeddedSigningFrame({ linkedResourceType, linkedResourceId, title, onSigningReturned, className }: EmbeddedSigningFrameProps): React.JSX.Element | null {\n const { doOperation } = useResourceRegistry();\n const toUserFacingErrorMessage = useUserFacingErrorMessage();\n const [status, setStatus] = useState<EmbeddedSigningFrameStatus>(EmbeddedSigningFrameStatus.OPENING);\n const [url, setUrl] = useState<string | null>(null);\n const [failure, setFailure] = useState<string | null>(null);\n const frameRef = useRef<HTMLIFrameElement | null>(null);\n // Read through refs so a provider handing out new function identities cannot make the frame ask again.\n const doOperationRef = useRef(doOperation);\n doOperationRef.current = doOperation;\n const toMessageRef = useRef(toUserFacingErrorMessage);\n toMessageRef.current = toUserFacingErrorMessage;\n const onReturnedRef = useRef(onSigningReturned);\n onReturnedRef.current = onSigningReturned;\n\n useEffect(() => {\n let cancelled = false;\n setStatus(EmbeddedSigningFrameStatus.OPENING);\n doOperationRef.current<SignatureRequestSigners_OpenSigningSessionResponse>(\n OPEN_SIGNING_SESSION_KEY,\n // The application scope (its id in the route) is merged in by the scoped registry.\n { contextualParameters: {}, requestData: { linkedResourceType, linkedResourceId, returnUrl: `${window.location.origin}${SIGNING_RETURN_PAGE_PATH}` } },\n // A person with nothing to sign is the common case, not an error: no global error toast.\n { silent: true },\n )\n .then((session) => {\n if (cancelled) return;\n setUrl(session.url);\n setStatus(EmbeddedSigningFrameStatus.SIGNING);\n })\n .catch((error: unknown) => {\n if (cancelled) return;\n // Nothing to sign here (404), or the request's provider signs from its e-mail only (409): nothing to show.\n if (isBackendRefusal(error) && (error.errorType === ErrorType.NOT_FOUND || error.errorType === ErrorType.CONFLICT)) {\n setStatus(EmbeddedSigningFrameStatus.NOTHING);\n return;\n }\n setFailure(toMessageRef.current(error));\n setStatus(EmbeddedSigningFrameStatus.FAILED);\n });\n return () => {\n cancelled = true;\n };\n }, [linkedResourceType, linkedResourceId]);\n\n const handleLoad = useCallback(() => {\n if (!frameReturned(frameRef.current)) return;\n setStatus(EmbeddedSigningFrameStatus.NOTHING);\n setUrl(null);\n onReturnedRef.current?.();\n }, []);\n\n if (status === EmbeddedSigningFrameStatus.NOTHING) return null;\n if (status === EmbeddedSigningFrameStatus.OPENING) return <LoadingSpinner />;\n if (status === EmbeddedSigningFrameStatus.FAILED) {\n return (\n <Alert variant=\"destructive\">\n <AlertDescription>{failure}</AlertDescription>\n </Alert>\n );\n }\n return (\n <iframe\n ref={frameRef}\n src={url ?? undefined}\n title={title}\n onLoad={handleLoad}\n // The vendor's page runs its own scripts and forms, on its own origin, and may open a window (an identity check);\n // it may not navigate the application's own page.\n sandbox=\"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox\"\n // The origin only, never the path: some vendors admit a frame by the embedding site's domain (Yousign's allowlist).\n referrerPolicy=\"strict-origin\"\n className={cn('h-[80vh] w-full rounded-md border-0', className)}\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EmbeddedSigningFrame.js","sourceRoot":"","sources":["../../../../src/components/compliance/EmbeddedSigningFrame.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,EACL,gBAAgB,EAChB,kCAAkC,E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AC,kBAAkB,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAC,CAAC;IAE1D,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;QAClC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,OAAO;QAC7C,SAAS,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,CAAC,IAAI,CAAC,CAAC;QACb,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC;IAC5B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAI,MAAM,KAAK,0BAA0B,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC/D,IAAI,MAAM,KAAK,0BAA0B,CAAC,OAAO;QAAE,OAAO,KAAC,cAAc,KAAG,CAAC;IAC7E,IAAI,MAAM,KAAK,0BAA0B,CAAC,MAAM,EAAE,CAAC;QACjD,OAAO,CACL,KAAC,KAAK,IAAC,OAAO,EAAC,aAAa,YAC1B,KAAC,gBAAgB,cAAE,OAAO,GAAoB,GACxC,CACT,CAAC;IACJ,CAAC;IACD,OAAO,CACL,iBACE,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,GAAG,IAAI,SAAS,EACrB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,UAAU;QAClB,kHAAkH;QAClH,kDAAkD;QAClD,OAAO,EAAC,yFAAyF;QACjG,oHAAoH;QACpH,cAAc,EAAC,eAAe,EAC9B,SAAS,EAAE,EAAE,CAAC,qCAAqC,EAAE,SAAS,CAAC,GAC/D,CACH,CAAC;AACJ,CAAC","sourcesContent":["import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport {\n CoreResourceType,\n coreResourceShared_FieldIdentifier,\n ErrorType,\n ResourceOperationVariantType,\n ResourcesConfig_OperationPathUtils,\n SIGNING_RETURN_PAGE_PATH,\n SignatureRequestSigners_Operations,\n type SignatureRequestSigners_OpenSigningSessionResponse,\n} from '@wildo-ai/saas-models';\nimport { LoadingSpinner } from '~wildo-frontend-lib/components/feedback/loading-spinner';\nimport { Alert, AlertDescription } from '~wildo-frontend-lib/components/overlays/containers/alert';\nimport { isBackendRefusal } from '~wildo-frontend-lib/core/errors/backend-refusal.frontend';\nimport { useUserFacingErrorMessage } from '~wildo-frontend-lib/core/errors/useUserFacingErrorMessage';\nimport { useResourceRegistry } from '~wildo-frontend-lib/core/resources/useResourceRegistry';\nimport { ApplicationContext } from '~wildo-frontend-lib/core/runtime/ApplicationContext.shared';\nimport { useAppScopeSafe } from '~wildo-frontend-lib/core/scope/useAppScope';\nimport { cn } from '~wildo-frontend-lib/core/ui/cn';\n\n/** @wildo_source:part:start saas.frontend.electronic-signatures.embedded-signing-frame facet:layer:frontend facet:audience:app-developer */\n/**\n * Embedded signing: the signed-in person signs a record's deliverable at the signature vendor, inside a frame of the\n * application, instead of following the vendor's e-mail. Import from `@wildo-ai/saas-frontend-lib`.\n *\n * Place it where the person meets the record (an engagement letter's page, say). On mount it asks the backend for the\n * vendor's signing page (`signatureRequestSigners.openSigningSession`). The answer is given only to a signer an open\n * request on that record names and the vendor says has not signed yet, so for anybody else, once the person has signed,\n * and when the request's provider signs from its e-mail only, the component renders NOTHING. The page is valid for\n * minutes and is never stored, which is why it is asked for here, when the person is in front of it. A signer whose turn\n * has not come (signers who sign in turn) is shown nothing either, until it does.\n *\n * When the person is done, a vendor that redirects sends the frame to the application's own {@link SIGNING_RETURN_PAGE_PATH};\n * the frame sees it arrive (it is now same-origin), closes, and calls `onSigningReturned`. A vendor that does not redirect\n * (or redirects to another of the application's origins) keeps showing its own end page. Either way nothing here says the\n * document is signed: every vendor's own guidance is that the end of the frame is not the outcome, and the request becomes\n * SIGNED only once the engine has validated the signed document, at its next re-read (poll or vendor notification).\n *\n * What it needs elsewhere: a provider that claims `EMBEDDED_ELECTRONIC_SIGNATURE` and declares `embeddedSigning`, and a\n * `wildo config sync` then `wildo dev sync-csp` since it was added, which put the vendor's signing origins in the SaaS\n * frontend's CSP `frame-src` from the provider's own declaration; without them the browser refuses to load the frame.\n *\n * It renders no words of its own: the application passes the frame's accessible `title`.\n */\nexport interface EmbeddedSigningFrameProps {\n /** The record the deliverable belongs to: the signature request's `linkedResourceType`. */\n readonly linkedResourceType: string;\n /** The record the deliverable belongs to: the signature request's `linkedResourceId`. */\n readonly linkedResourceId: string;\n /** The frame's accessible name (WCAG 4.1.2), in the person's language, e.g. \"Sign the engagement letter\". */\n readonly title: string;\n /** Called once the person left the vendor's page. Re-read the record if you show its signature state. */\n readonly onSigningReturned?: () => void;\n readonly className?: string;\n}\n/** @wildo_source:part:end saas.frontend.electronic-signatures.embedded-signing-frame */\n\n/** Where the frame is. */\nenum EmbeddedSigningFrameStatus {\n /** Asking the backend for the signing page. */\n OPENING = 'opening',\n /** The vendor's page is in the frame. */\n SIGNING = 'signing',\n /** Nothing for this person to sign here, or they have left the vendor's page: nothing is rendered. */\n NOTHING = 'nothing',\n /** The page could not be opened. */\n FAILED = 'failed',\n}\n\nconst OPEN_SIGNING_SESSION_KEY = ResourcesConfig_OperationPathUtils.createOperationPathKey({\n resourceIdentifier: CoreResourceType.SIGNATURE_REQUEST_SIGNERS,\n operationIdentifier: SignatureRequestSigners_Operations.OPEN_SIGNING_SESSION,\n variantType: ResourceOperationVariantType.API_CALL,\n isOperationDefault: true,\n isBulkOperation: false,\n});\n\n/**\n * Whether the frame has reached the application's signing-return page. While it shows the vendor's page, reading its\n * location throws (another origin): that is \"not yet\".\n */\n/** The route parameter that names the application in `/applications/{applicationId}/…`. */\nconst APPLICATION_FIELD_IDENTIFIER = coreResourceShared_FieldIdentifier[CoreResourceType.APPLICATION];\n\nfunction frameReturned(frame: HTMLIFrameElement | null): boolean {\n try {\n return frame?.contentWindow?.location.pathname === SIGNING_RETURN_PAGE_PATH;\n } catch {\n return false;\n }\n}\n\nexport function EmbeddedSigningFrame({ linkedResourceType, linkedResourceId, title, onSigningReturned, className }: EmbeddedSigningFrameProps): React.JSX.Element | null {\n const { doOperation } = useResourceRegistry();\n const toUserFacingErrorMessage = useUserFacingErrorMessage();\n const [status, setStatus] = useState<EmbeddedSigningFrameStatus>(EmbeddedSigningFrameStatus.OPENING);\n const [url, setUrl] = useState<string | null>(null);\n const [failure, setFailure] = useState<string | null>(null);\n const frameRef = useRef<HTMLIFrameElement | null>(null);\n // The signing session is an APPLICATION-scoped operation (`/applications/{applicationId}/…`), asked from an\n // organization's record page. The id comes from the application's identity, never from the scope: the access token\n // carries no applicationId claim, so the scope's `currentApplicationId` is null and its injection supplies nothing\n // (the same correction `useVisibleSettingsHubConfig` made). Without it the call cannot be addressed and the frame\n // showed \"Service unavailable\" on every page (Wonder Ledger's Yousign e2e lane, 2026-11-18). The scope stays a\n // fallback, so the day the token carries the claim nothing here changes.\n const applicationIdentityId = useContext(ApplicationContext)?.appIdentity?.applicationId;\n const scopedApplicationId = useAppScopeSafe()?.currentApplicationId;\n const applicationId = applicationIdentityId ?? scopedApplicationId ?? undefined;\n // Read through refs so a provider handing out new function identities cannot make the frame ask again.\n const doOperationRef = useRef(doOperation);\n doOperationRef.current = doOperation;\n const toMessageRef = useRef(toUserFacingErrorMessage);\n toMessageRef.current = toUserFacingErrorMessage;\n const onReturnedRef = useRef(onSigningReturned);\n onReturnedRef.current = onSigningReturned;\n\n useEffect(() => {\n let cancelled = false;\n setStatus(EmbeddedSigningFrameStatus.OPENING);\n doOperationRef.current<SignatureRequestSigners_OpenSigningSessionResponse>(\n OPEN_SIGNING_SESSION_KEY,\n { contextualParameters: applicationId ? { [APPLICATION_FIELD_IDENTIFIER]: applicationId } : {}, requestData: { linkedResourceType, linkedResourceId, returnUrl: `${window.location.origin}${SIGNING_RETURN_PAGE_PATH}` } },\n // A person with nothing to sign is the common case, not an error: no global error toast.\n { silent: true },\n )\n .then((session) => {\n if (cancelled) return;\n setUrl(session.url);\n setStatus(EmbeddedSigningFrameStatus.SIGNING);\n })\n .catch((error: unknown) => {\n if (cancelled) return;\n // Nothing to sign here (404), or the request's provider signs from its e-mail only (409): nothing to show.\n if (isBackendRefusal(error) && (error.errorType === ErrorType.NOT_FOUND || error.errorType === ErrorType.CONFLICT)) {\n setStatus(EmbeddedSigningFrameStatus.NOTHING);\n return;\n }\n setFailure(toMessageRef.current(error));\n setStatus(EmbeddedSigningFrameStatus.FAILED);\n });\n return () => {\n cancelled = true;\n };\n }, [linkedResourceType, linkedResourceId, applicationId]);\n\n const handleLoad = useCallback(() => {\n if (!frameReturned(frameRef.current)) return;\n setStatus(EmbeddedSigningFrameStatus.NOTHING);\n setUrl(null);\n onReturnedRef.current?.();\n }, []);\n\n if (status === EmbeddedSigningFrameStatus.NOTHING) return null;\n if (status === EmbeddedSigningFrameStatus.OPENING) return <LoadingSpinner />;\n if (status === EmbeddedSigningFrameStatus.FAILED) {\n return (\n <Alert variant=\"destructive\">\n <AlertDescription>{failure}</AlertDescription>\n </Alert>\n );\n }\n return (\n <iframe\n ref={frameRef}\n src={url ?? undefined}\n title={title}\n onLoad={handleLoad}\n // The vendor's page runs its own scripts and forms, on its own origin, and may open a window (an identity check);\n // it may not navigate the application's own page.\n sandbox=\"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox\"\n // The origin only, never the path: some vendors admit a frame by the embedding site's domain (Yousign's allowlist).\n referrerPolicy=\"strict-origin\"\n className={cn('h-[80vh] w-full rounded-md border-0', className)}\n />\n );\n}\n"]}
|
|
@@ -75,22 +75,24 @@ export interface FileApprovalSealProps {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* The approval seal that attests a file, under the file (#2913): drawn by `DisplayFieldFile` on a DISPLAY surface, and
|
|
78
|
-
* nothing at all for the many files no seal attests
|
|
78
|
+
* nothing at all for the many files no seal attests, which the door answers `null` rather than a 404 the browser would
|
|
79
|
+
* log as a failed load (#3868). It asks `GET /approval-seals/files/:fileId`, admitted by the READ
|
|
79
80
|
* of the record the file belongs to, and only for a seal its own record still names (an approval whose effect failed
|
|
80
81
|
* shows nothing). Currency is not drawn here: it is a statement about the record the approval is about.
|
|
81
82
|
*/
|
|
82
83
|
export declare function FileApprovalSeal({ fileId, className }: FileApprovalSealProps): React.JSX.Element | null;
|
|
83
84
|
export interface DecisionApprovalSealProps {
|
|
84
|
-
/** The decision the signed-in person
|
|
85
|
+
/** The decision whose seal is shown: one the signed-in person answered, or one raised in their conversation (#4062). */
|
|
85
86
|
readonly decisionRef: string;
|
|
86
87
|
/** What the decision was about, in the card's own words (the title the inbox showed). */
|
|
87
88
|
readonly description?: string;
|
|
88
89
|
readonly className?: string;
|
|
89
90
|
}
|
|
90
91
|
/**
|
|
91
|
-
* The seal of a decision
|
|
92
|
-
* `GET /approval-seals/decisions/:decisionRef`, which answers the
|
|
93
|
-
*
|
|
92
|
+
* The seal of a decision (#2913), once it is decided: under the inbox for the answers given there, and on a conversation's
|
|
93
|
+
* line for the call that waited on it (#4062). Asked of `GET /approval-seals/decisions/:decisionRef`, which answers the
|
|
94
|
+
* decider, and anyone else only when the record the seal is about names it and that record's own READ admits them. The
|
|
95
|
+
* seal is signed seconds after the decision, so a PENDING seal is asked again until it is signed (about a minute at most); a decision that sealed nothing
|
|
94
96
|
* draws nothing.
|
|
95
97
|
*/
|
|
96
98
|
export declare function DecisionApprovalSeal({ decisionRef, description, className }: DecisionApprovalSealProps): React.JSX.Element | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approval-seal.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/approval-seal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAA;AACvE,OAAO,EAML,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kFAAkF,CAAA;AAW5H,yDAAyD;AACzD,oBAAY,qBAAqB;IAC/B,+BAA+B;IAC/B,OAAO,YAAY;IACnB,2DAA2D;IAC3D,KAAK,UAAU;IACf,sEAAsE;IACtE,MAAM,WAAW;CAClB;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C5B;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,yBAAyB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAWjI"}
|
|
@@ -71,6 +71,10 @@ function useApprovalSealView(source) {
|
|
|
71
71
|
.then((view) => {
|
|
72
72
|
if (!current)
|
|
73
73
|
return;
|
|
74
|
+
if (view === null) {
|
|
75
|
+
setNone(true);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
74
78
|
setRead({ state: ApprovalSealReadState.READY, view });
|
|
75
79
|
if (source.pollWhilePending && view.state === ApprovalSealOnRecordState.PENDING && polls < PENDING_SEAL_POLL_MAX) {
|
|
76
80
|
polls += 1;
|
|
@@ -170,7 +174,8 @@ function useRecordVersion(record) {
|
|
|
170
174
|
}
|
|
171
175
|
/**
|
|
172
176
|
* The approval seal that attests a file, under the file (#2913): drawn by `DisplayFieldFile` on a DISPLAY surface, and
|
|
173
|
-
* nothing at all for the many files no seal attests
|
|
177
|
+
* nothing at all for the many files no seal attests, which the door answers `null` rather than a 404 the browser would
|
|
178
|
+
* log as a failed load (#3868). It asks `GET /approval-seals/files/:fileId`, admitted by the READ
|
|
174
179
|
* of the record the file belongs to, and only for a seal its own record still names (an approval whose effect failed
|
|
175
180
|
* shows nothing). Currency is not drawn here: it is a statement about the record the approval is about.
|
|
176
181
|
*/
|
|
@@ -187,9 +192,10 @@ export function FileApprovalSeal({ fileId, className }) {
|
|
|
187
192
|
return _jsx(ApprovalSealOf, { state: state, ...(className ? { className } : {}) });
|
|
188
193
|
}
|
|
189
194
|
/**
|
|
190
|
-
* The seal of a decision
|
|
191
|
-
* `GET /approval-seals/decisions/:decisionRef`, which answers the
|
|
192
|
-
*
|
|
195
|
+
* The seal of a decision (#2913), once it is decided: under the inbox for the answers given there, and on a conversation's
|
|
196
|
+
* line for the call that waited on it (#4062). Asked of `GET /approval-seals/decisions/:decisionRef`, which answers the
|
|
197
|
+
* decider, and anyone else only when the record the seal is about names it and that record's own READ admits them. The
|
|
198
|
+
* seal is signed seconds after the decision, so a PENDING seal is asked again until it is signed (about a minute at most); a decision that sealed nothing
|
|
193
199
|
* draws nothing.
|
|
194
200
|
*/
|
|
195
201
|
export function DecisionApprovalSeal({ decisionRef, description, className }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approval-seal.js","sourceRoot":"","sources":["../../../../src/components/data-display/approval-seal.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,0BAA0B,GAG3B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,iFAAiF,CAAA;AAEzH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mFAAmF,CAAA;AAC5H,OAAO,EAAE,cAAc,EAAE,MAAM,mEAAmE,CAAA;AAClG,OAAO,EAAE,yBAAyB,EAAE,MAAM,uEAAuE,CAAA;AACjH,OAAO,EAAE,iCAAiC,EAAE,MAAM,oEAAoE,CAAA;AACtH,OAAO,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAA;AAE3F,kHAAkH;AAClH,MAAM,cAAc,GAAG,gBAAgB,CAAC,cAAc,CAAA;AAEtD,yDAAyD;AACzD,MAAM,CAAN,IAAY,qBAOX;AAPD,WAAY,qBAAqB;IAC/B,+BAA+B;IAC/B,4CAAmB,CAAA;IACnB,2DAA2D;IAC3D,wCAAe,CAAA;IACf,sEAAsE;IACtE,0CAAiB,CAAA;AACnB,CAAC,EAPW,qBAAqB,KAArB,qBAAqB,Q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Y,EAAE,YAAY,MAAM,MAAM;QACtC,cAAc,EAAE,IAAI;KACrB,CAAC,CAAA;IACF,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IACjF,OAAO,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,KAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAI,CAAA;AAC/E,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAA6B;IACrG,MAAM,KAAK,GAAG,mBAAmB,CAAC;QAChC,GAAG,EAAE,WAAW;QAChB,IAAI,EAAE,GAAG,EAAE,CAAC,wBAAwB,EAAE,CAAC,0BAA0B,CAAC,WAAW,CAAC;QAC9E,YAAY,EAAE,YAAY,WAAW,MAAM;QAC3C,cAAc,EAAE,IAAI;QACpB,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAA;IACF,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAC3B,2GAA2G;IAC3G,OAAO,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,KAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAI,CAAA;AAC5I,CAAC","sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react'\nimport {\n ApprovalSealOnRecordState,\n ApprovalSealSchema,\n CoreResourceType,\n ErrorType,\n approvalSealCheckOutcomeOf,\n type ApprovalSealCheckOutcome,\n type ApprovalSealOnRecordView,\n} from '@wildo-ai/saas-models'\nimport { FrontendComponentType, CorePresetNames } from '@wildo-ai/presets-components-models'\nimport { createComponentResolver } from '~wildo-frontend-lib/core/components-registry/component-resolver.frontend.helper'\nimport type { ComponentPresetProps } from '~wildo-frontend-lib/core/components-registry/component-registry.frontend.schemas'\nimport { getManualCallsHttpClient } from '~wildo-frontend-lib/core/requests/wildo-http-client-manual-calls.frontend.service'\nimport { saveBlobAsFile } from '~wildo-frontend-lib/core/commons/save-blob-as-file.frontend.utils'\nimport { useResourceDisplayContext } from '~wildo-frontend-lib/components/data-display/automatic-displayer.utils'\nimport { useOptionalDisplayTemplateContext } from '~wildo-frontend-lib/components/data-display/DisplayTemplateContext'\nimport { useI18n } from '~wildo-frontend-lib/core/i18n/useI18n'\nimport { isBackendRefusal } from '~wildo-frontend-lib/core/errors/backend-refusal.frontend'\n\n/** The seal's own resource, whose fields declare the vocabularies the meaning and the outcome are worded from. */\nconst APPROVAL_SEALS = CoreResourceType.APPROVAL_SEALS\n\n/** Where the read of a record's approval seal stands. */\nexport enum ApprovalSealReadState {\n /** Asked, not answered yet. */\n LOADING = 'loading',\n /** Answered: `view` says how the record shows its seal. */\n READY = 'ready',\n /** The read failed: said so, never shown as a record with no seal. */\n FAILED = 'failed',\n}\n\n/** Where a check of the seal (the public verifier, run on demand) stands. */\nexport enum ApprovalSealCheckState {\n /** Not asked. */\n IDLE = 'idle',\n CHECKING = 'checking',\n /** Answered: `checkOutcome` says what the verifier found. */\n DONE = 'done',\n /** The check could not be made (the request failed): not a verdict on the seal. */\n FAILED = 'failed',\n}\n\n// --- Contract ---\n\n/**\n * What the preset draws (#2913). Presentational: the wrapper reads the seal, labels the moved fields in the record's own\n * words and runs the actions; the preset never decides what a reader may see, the door already did.\n */\nexport interface ApprovalSealProps {\n readonly readState: ApprovalSealReadState\n /** Present when `readState` is READY. */\n readonly view?: ApprovalSealOnRecordView\n /** The record's own labels of `view.currency.movedFields`, in the same order. Never their values. */\n readonly movedFieldLabels?: readonly string[]\n /** The approval's meaning, in its vocabulary's words (`system_enums.ApprovalSealMeaning`). */\n readonly meaningLabel?: string\n /** The decision's outcome, in its vocabulary's words (`system_enums.HumanDecision_Outcome`). */\n readonly outcomeLabel?: string\n readonly checkState?: ApprovalSealCheckState\n /** Present when `checkState` is DONE. */\n readonly checkOutcome?: ApprovalSealCheckOutcome\n /** Runs the public verifier on the seal; offered only for a signed seal. */\n readonly onCheck?: () => void\n /** Downloads the deliverable's manifested copy; offered only when the seal holds one that can be served. */\n readonly onDownloadManifestedCopy?: () => void\n readonly downloadingManifestedCopy?: boolean\n /** What the seal is about, when the surface does not already say it (a decided card: the decision's title). */\n readonly description?: string\n readonly className?: string\n}\n\n// --- Wrapper ---\n\n/** The preset, resolved from the registry: an application may replace how a seal is drawn. */\nexport function ApprovalSeal({ preset = CorePresetNames.DEFAULT, ...props }: ApprovalSealProps & ComponentPresetProps): React.JSX.Element {\n const Component = createComponentResolver<ApprovalSealProps>(FrontendComponentType.LOW_LEVEL_APPROVAL_SEAL, 'ApprovalSeal')(preset)\n return <Component {...props} />\n}\n\n/** A stored id as a string; anything else is not an id. */\nfunction sealIdOf(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\nexport interface RecordApprovalSealProps {\n /**\n * The record's field holding the seal's id (`signOffApprovalSealId`). A top-level field: the door checks that the record\n * stores this seal there, so a seal whose approved effect failed (one the record does not name) is never shown.\n */\n readonly field: string\n /** Draw nothing when the record names no seal in the field, instead of saying it has none. */\n readonly hideWhenNone?: boolean\n readonly className?: string\n}\n\n/** How a wrapper reads one seal view, downloads its copy, and whether a missing seal is an answer or a failure. */\ninterface ApprovalSealSource {\n /** Changes when what is asked changes (and, for a record, when the record does). */\n readonly key: string\n readonly load: () => Promise<ApprovalSealOnRecordView>\n /** Absent where the view offers no copy (the decider's view: the deliverable is downloaded where its record is read). */\n readonly download?: () => Promise<Blob>\n readonly downloadName: string\n /** A 404 means \"no seal here\" (a file nothing attests, a decision that sealed nothing): draw nothing, not a failure. */\n readonly notFoundIsNone?: boolean\n /** Ask again while the seal is PENDING: a decision just made is signed seconds later. */\n readonly pollWhilePending?: boolean\n}\n\n/** How often, and how many times, a PENDING seal is asked again after a decision (about a minute in all). */\nconst PENDING_SEAL_POLL_INTERVAL_MS = 3_000\nconst PENDING_SEAL_POLL_MAX = 20\n\n/** Whether a failed read is the door answering \"nothing here\" (404), never a failure the reader should see. */\nfunction isNotFound(error: unknown): boolean {\n return isBackendRefusal(error) && error.errorType === ErrorType.NOT_FOUND\n}\n\n/** The state shared by every seal wrapper: the read, the check, the download. */\nfunction useApprovalSealView(source: ApprovalSealSource | undefined): {\n readonly read: { readonly state: ApprovalSealReadState; readonly view?: ApprovalSealOnRecordView }\n readonly none: boolean\n readonly check: { readonly state: ApprovalSealCheckState; readonly outcome?: ApprovalSealCheckOutcome }\n readonly onCheck: () => void\n readonly onDownloadManifestedCopy: () => void\n readonly downloading: boolean\n} {\n const [read, setRead] = useState<{ readonly state: ApprovalSealReadState; readonly view?: ApprovalSealOnRecordView }>({ state: ApprovalSealReadState.LOADING })\n const [none, setNone] = useState(false)\n const [check, setCheck] = useState<{ readonly state: ApprovalSealCheckState; readonly outcome?: ApprovalSealCheckOutcome }>({ state: ApprovalSealCheckState.IDLE })\n const [downloading, setDownloading] = useState(false)\n const key = source?.key\n\n useEffect(() => {\n if (!source) return\n let current = true\n let polls = 0\n let timer: ReturnType<typeof setTimeout> | undefined\n setRead({ state: ApprovalSealReadState.LOADING })\n setNone(false)\n setCheck({ state: ApprovalSealCheckState.IDLE })\n const ask = (): void => {\n // Through a promise, so a load that throws before it returns one is a failed read like any other.\n Promise.resolve().then(source.load)\n .then((view) => {\n if (!current) return\n setRead({ state: ApprovalSealReadState.READY, view })\n if (source.pollWhilePending && view.state === ApprovalSealOnRecordState.PENDING && polls < PENDING_SEAL_POLL_MAX) {\n polls += 1\n timer = setTimeout(ask, PENDING_SEAL_POLL_INTERVAL_MS)\n }\n })\n .catch((error: unknown) => {\n if (!current) return\n if (source.notFoundIsNone && isNotFound(error)) setNone(true)\n else setRead({ state: ApprovalSealReadState.FAILED })\n })\n }\n ask()\n return () => { current = false; if (timer) clearTimeout(timer) }\n // `key` names what is asked; the source object itself is rebuilt on every render.\n }, [key])\n\n const jws = read.view?.jws\n const onCheck = useCallback(() => {\n if (!jws) return\n setCheck({ state: ApprovalSealCheckState.CHECKING })\n getManualCallsHttpClient().checkApprovalSeal(jws)\n .then((verdict) => setCheck({ state: ApprovalSealCheckState.DONE, outcome: approvalSealCheckOutcomeOf(verdict) }))\n .catch(() => setCheck({ state: ApprovalSealCheckState.FAILED }))\n }, [jws])\n\n const onDownloadManifestedCopy = useCallback(() => {\n if (!source?.download) return\n setDownloading(true)\n source.download()\n .then((blob) => saveBlobAsFile(blob, source.downloadName))\n .catch(() => undefined)\n .finally(() => setDownloading(false))\n }, [key])\n\n return { read, none, check, onCheck, onDownloadManifestedCopy, downloading }\n}\n\n/** Draws one seal view through the preset, with the meaning and outcome in their vocabularies' words. */\nfunction ApprovalSealOf({ state, offersCopy = true, movedFieldLabels, description, className }: {\n readonly state: ReturnType<typeof useApprovalSealView>\n readonly offersCopy?: boolean\n readonly movedFieldLabels?: readonly string[]\n readonly description?: string\n readonly className?: string\n}): React.JSX.Element {\n const { tResourceFieldEnumValue } = useI18n()\n const { read, check, onCheck, onDownloadManifestedCopy, downloading } = state\n const view = read.view\n const shape = ApprovalSealSchema.shape\n return (\n <ApprovalSeal\n readState={read.state}\n {...(view ? { view } : {})}\n {...(movedFieldLabels ? { movedFieldLabels } : {})}\n {...(description ? { description } : {})}\n {...(view?.meaning ? { meaningLabel: tResourceFieldEnumValue(APPROVAL_SEALS, 'meaning', view.meaning, shape.meaning) } : {})}\n {...(view?.outcome ? { outcomeLabel: tResourceFieldEnumValue(APPROVAL_SEALS, 'outcome', view.outcome, shape.outcome) } : {})}\n checkState={check.state}\n {...(check.outcome ? { checkOutcome: check.outcome } : {})}\n {...(view?.jws ? { onCheck } : {})}\n {...(offersCopy && view?.deliverable?.manifestedCopyAvailable ? { onDownloadManifestedCopy, downloadingManifestedCopy: downloading } : {})}\n {...(className ? { className } : {})}\n />\n )\n}\n\n/**\n * The approval seal the record on this display surface stores in `field` (#2913): who approved it, when, with what\n * meaning, whether the approval still describes the record, its deliverable's manifested copy and a check of the seal.\n *\n * Place it in a resource's DISPLAY template (`*.ui-behavior.tsx`), where the record and its resource are in context. It\n * asks `GET /approval-seals/:sealId/records/:resourceType/:resourceId/:field`, which admits exactly the readers the\n * record's own READ admits, and asks again when the record changes, since whether the approval is current depends on it.\n * Moved fields are labelled with the record's own field labels; their values are never shown.\n */\nexport function RecordApprovalSeal({ field, hideWhenNone, className }: RecordApprovalSealProps): React.JSX.Element | null {\n const { resourceType, resourceId } = useResourceDisplayContext()\n const template = useOptionalDisplayTemplateContext()\n const record = template?.data\n const sealId = sealIdOf(record?.[field])\n const recordVersion = useRecordVersion(record)\n const target = sealId && resourceType && resourceId ? { sealId, resourceType: String(resourceType), resourceId: String(resourceId), field } : undefined\n const state = useApprovalSealView(target ? {\n // The record is part of what is asked: a value the approval covers may have moved.\n key: `${target.sealId}|${target.resourceType}|${target.resourceId}|${field}|${recordVersion}`,\n load: () => getManualCallsHttpClient().readApprovalSealOnRecord(target),\n download: () => getManualCallsHttpClient().downloadApprovalSealManifestedCopy(target),\n downloadName: `approval-${target.sealId}.pdf`,\n } : undefined)\n\n if (!record) return null\n if (!target) {\n if (hideWhenNone || !resourceType) return null\n return <ApprovalSeal readState={ApprovalSealReadState.READY} view={{ sealId: '', state: ApprovalSealOnRecordState.NO_SEAL }} {...(className ? { className } : {})} />\n }\n const movedFieldLabels = state.read.view?.currency?.movedFields.map((name) => template?.fieldLabels?.[name] ?? name)\n return <ApprovalSealOf state={state} {...(movedFieldLabels ? { movedFieldLabels } : {})} {...(className ? { className } : {})} />\n}\n\n/** A record's identity in time, so the record's seal is asked again when the record changes. */\nfunction useRecordVersion(record: Record<string, unknown> | undefined): string {\n const updatedAt = record?.updatedAt\n const stamp = updatedAt instanceof Date ? updatedAt.toISOString() : typeof updatedAt === 'string' ? updatedAt : ''\n // Without a stamp, the object's identity is the version: a re-read hands a new object.\n const [identity, setIdentity] = useState(0)\n const last = useRef(record)\n useEffect(() => {\n if (last.current !== record) { last.current = record; if (!stamp) setIdentity((value) => value + 1) }\n }, [record, stamp])\n return stamp || String(identity)\n}\n\nexport interface FileApprovalSealProps {\n /** The file a seal may attest: the deliverable a person approved by its hash (a close report's PDF). */\n readonly fileId: string\n readonly className?: string\n}\n\n/**\n * The approval seal that attests a file, under the file (#2913): drawn by `DisplayFieldFile` on a DISPLAY surface, and\n * nothing at all for the many files no seal attests. It asks `GET /approval-seals/files/:fileId`, admitted by the READ\n * of the record the file belongs to, and only for a seal its own record still names (an approval whose effect failed\n * shows nothing). Currency is not drawn here: it is a statement about the record the approval is about.\n */\nexport function FileApprovalSeal({ fileId, className }: FileApprovalSealProps): React.JSX.Element | null {\n const state = useApprovalSealView({\n key: fileId,\n load: () => getManualCallsHttpClient().readApprovalSealOnFile(fileId),\n download: () => getManualCallsHttpClient().downloadApprovalSealFileManifestedCopy(fileId),\n downloadName: `approval-${fileId}.pdf`,\n notFoundIsNone: true,\n })\n if (state.none || state.read.state === ApprovalSealReadState.LOADING) return null\n return <ApprovalSealOf state={state} {...(className ? { className } : {})} />\n}\n\nexport interface DecisionApprovalSealProps {\n /** The decision the signed-in person just answered. */\n readonly decisionRef: string\n /** What the decision was about, in the card's own words (the title the inbox showed). */\n readonly description?: string\n readonly className?: string\n}\n\n/**\n * The seal of a decision the signed-in person answered (#2913), for a decision card once it is decided: asked of\n * `GET /approval-seals/decisions/:decisionRef`, which answers the decider only. The seal is signed seconds after the\n * decision, so a PENDING seal is asked again until it is signed (about a minute at most); a decision that sealed nothing\n * draws nothing.\n */\nexport function DecisionApprovalSeal({ decisionRef, description, className }: DecisionApprovalSealProps): React.JSX.Element | null {\n const state = useApprovalSealView({\n key: decisionRef,\n load: () => getManualCallsHttpClient().readApprovalSealOfDecision(decisionRef),\n downloadName: `approval-${decisionRef}.pdf`,\n notFoundIsNone: true,\n pollWhilePending: true,\n })\n if (state.none) return null\n // The decider's view offers no copy: the deliverable is the record's, downloaded where the record is read.\n return <ApprovalSealOf state={state} offersCopy={false} {...(description ? { description } : {})} {...(className ? { className } : {})} />\n}\n"]}
|
|
1
|
+
{"version":3,"file":"approval-seal.js","sourceRoot":"","sources":["../../../../src/components/data-display/approval-seal.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,0BAA0B,GAG3B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,iFAAiF,CAAA;AAEzH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mFAAmF,CAAA;AAC5H,OAAO,EAAE,cAAc,EAAE,MAAM,mEAAmE,CAAA;AAClG,OAAO,EAAE,yBAAyB,EAAE,MAAM,uEAAuE,CAAA;AACjH,OAAO,EAAE,iCAAiC,EAAE,MAAM,oEAAoE,CAAA;AACtH,OAAO,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAA;AAE3F,kHAAkH;AAClH,MAAM,cAAc,GAAG,gBAAgB,CAAC,cAAc,CAAA;AAEtD,yDAAyD;AACzD,MAAM,CAAN,IAAY,qBAOX;AAPD,WAAY,qBAAqB;IAC/B,+BAA+B;IAC/B,4CAAmB,CAAA;IACnB,2DAA2D;IAC3D,wCAAe,CAAA;IACf,sEAAsE;IACtE,0CAAiB,CAAA;AACnB,CAAC,EAPW,qBAAqB,KAArB,qBAAqB,QAOhC;AAED,6EAA6E;AAC7E,MAAM,CAAN,IAAY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AAC,wBAAwB,EAAE,CAAC,sCAAsC,CAAC,MAAM,CAAC;QACzF,YAAY,EAAE,YAAY,MAAM,MAAM;QACtC,cAAc,EAAE,IAAI;KACrB,CAAC,CAAA;IACF,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,qBAAqB,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IACjF,OAAO,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,KAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAI,CAAA;AAC/E,CAAC;AAUD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAA6B;IACrG,MAAM,KAAK,GAAG,mBAAmB,CAAC;QAChC,GAAG,EAAE,WAAW;QAChB,IAAI,EAAE,GAAG,EAAE,CAAC,wBAAwB,EAAE,CAAC,0BAA0B,CAAC,WAAW,CAAC;QAC9E,YAAY,EAAE,YAAY,WAAW,MAAM;QAC3C,cAAc,EAAE,IAAI;QACpB,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAA;IACF,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAC3B,2GAA2G;IAC3G,OAAO,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,KAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAI,CAAA;AAC5I,CAAC","sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react'\nimport {\n ApprovalSealOnRecordState,\n ApprovalSealSchema,\n CoreResourceType,\n ErrorType,\n approvalSealCheckOutcomeOf,\n type ApprovalSealCheckOutcome,\n type ApprovalSealOnRecordView,\n} from '@wildo-ai/saas-models'\nimport { FrontendComponentType, CorePresetNames } from '@wildo-ai/presets-components-models'\nimport { createComponentResolver } from '~wildo-frontend-lib/core/components-registry/component-resolver.frontend.helper'\nimport type { ComponentPresetProps } from '~wildo-frontend-lib/core/components-registry/component-registry.frontend.schemas'\nimport { getManualCallsHttpClient } from '~wildo-frontend-lib/core/requests/wildo-http-client-manual-calls.frontend.service'\nimport { saveBlobAsFile } from '~wildo-frontend-lib/core/commons/save-blob-as-file.frontend.utils'\nimport { useResourceDisplayContext } from '~wildo-frontend-lib/components/data-display/automatic-displayer.utils'\nimport { useOptionalDisplayTemplateContext } from '~wildo-frontend-lib/components/data-display/DisplayTemplateContext'\nimport { useI18n } from '~wildo-frontend-lib/core/i18n/useI18n'\nimport { isBackendRefusal } from '~wildo-frontend-lib/core/errors/backend-refusal.frontend'\n\n/** The seal's own resource, whose fields declare the vocabularies the meaning and the outcome are worded from. */\nconst APPROVAL_SEALS = CoreResourceType.APPROVAL_SEALS\n\n/** Where the read of a record's approval seal stands. */\nexport enum ApprovalSealReadState {\n /** Asked, not answered yet. */\n LOADING = 'loading',\n /** Answered: `view` says how the record shows its seal. */\n READY = 'ready',\n /** The read failed: said so, never shown as a record with no seal. */\n FAILED = 'failed',\n}\n\n/** Where a check of the seal (the public verifier, run on demand) stands. */\nexport enum ApprovalSealCheckState {\n /** Not asked. */\n IDLE = 'idle',\n CHECKING = 'checking',\n /** Answered: `checkOutcome` says what the verifier found. */\n DONE = 'done',\n /** The check could not be made (the request failed): not a verdict on the seal. */\n FAILED = 'failed',\n}\n\n// --- Contract ---\n\n/**\n * What the preset draws (#2913). Presentational: the wrapper reads the seal, labels the moved fields in the record's own\n * words and runs the actions; the preset never decides what a reader may see, the door already did.\n */\nexport interface ApprovalSealProps {\n readonly readState: ApprovalSealReadState\n /** Present when `readState` is READY. */\n readonly view?: ApprovalSealOnRecordView\n /** The record's own labels of `view.currency.movedFields`, in the same order. Never their values. */\n readonly movedFieldLabels?: readonly string[]\n /** The approval's meaning, in its vocabulary's words (`system_enums.ApprovalSealMeaning`). */\n readonly meaningLabel?: string\n /** The decision's outcome, in its vocabulary's words (`system_enums.HumanDecision_Outcome`). */\n readonly outcomeLabel?: string\n readonly checkState?: ApprovalSealCheckState\n /** Present when `checkState` is DONE. */\n readonly checkOutcome?: ApprovalSealCheckOutcome\n /** Runs the public verifier on the seal; offered only for a signed seal. */\n readonly onCheck?: () => void\n /** Downloads the deliverable's manifested copy; offered only when the seal holds one that can be served. */\n readonly onDownloadManifestedCopy?: () => void\n readonly downloadingManifestedCopy?: boolean\n /** What the seal is about, when the surface does not already say it (a decided card: the decision's title). */\n readonly description?: string\n readonly className?: string\n}\n\n// --- Wrapper ---\n\n/** The preset, resolved from the registry: an application may replace how a seal is drawn. */\nexport function ApprovalSeal({ preset = CorePresetNames.DEFAULT, ...props }: ApprovalSealProps & ComponentPresetProps): React.JSX.Element {\n const Component = createComponentResolver<ApprovalSealProps>(FrontendComponentType.LOW_LEVEL_APPROVAL_SEAL, 'ApprovalSeal')(preset)\n return <Component {...props} />\n}\n\n/** A stored id as a string; anything else is not an id. */\nfunction sealIdOf(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\nexport interface RecordApprovalSealProps {\n /**\n * The record's field holding the seal's id (`signOffApprovalSealId`). A top-level field: the door checks that the record\n * stores this seal there, so a seal whose approved effect failed (one the record does not name) is never shown.\n */\n readonly field: string\n /** Draw nothing when the record names no seal in the field, instead of saying it has none. */\n readonly hideWhenNone?: boolean\n readonly className?: string\n}\n\n/** How a wrapper reads one seal view, downloads its copy, and whether a missing seal is an answer or a failure. */\ninterface ApprovalSealSource {\n /** Changes when what is asked changes (and, for a record, when the record does). */\n readonly key: string\n /** `null` is the door answering \"no seal here\" (a file nothing attests, #3868): draw nothing, not a failure. */\n readonly load: () => Promise<ApprovalSealOnRecordView | null>\n /** Absent where the view offers no copy (the decider's view: the deliverable is downloaded where its record is read). */\n readonly download?: () => Promise<Blob>\n readonly downloadName: string\n /**\n * A 404 means \"nothing to draw\" (a decision that sealed nothing, a file the caller may not read): draw nothing, not a\n * failure.\n */\n readonly notFoundIsNone?: boolean\n /** Ask again while the seal is PENDING: a decision just made is signed seconds later. */\n readonly pollWhilePending?: boolean\n}\n\n/** How often, and how many times, a PENDING seal is asked again after a decision (about a minute in all). */\nconst PENDING_SEAL_POLL_INTERVAL_MS = 3_000\nconst PENDING_SEAL_POLL_MAX = 20\n\n/** Whether a failed read is the door answering \"nothing here\" (404), never a failure the reader should see. */\nfunction isNotFound(error: unknown): boolean {\n return isBackendRefusal(error) && error.errorType === ErrorType.NOT_FOUND\n}\n\n/** The state shared by every seal wrapper: the read, the check, the download. */\nfunction useApprovalSealView(source: ApprovalSealSource | undefined): {\n readonly read: { readonly state: ApprovalSealReadState; readonly view?: ApprovalSealOnRecordView }\n readonly none: boolean\n readonly check: { readonly state: ApprovalSealCheckState; readonly outcome?: ApprovalSealCheckOutcome }\n readonly onCheck: () => void\n readonly onDownloadManifestedCopy: () => void\n readonly downloading: boolean\n} {\n const [read, setRead] = useState<{ readonly state: ApprovalSealReadState; readonly view?: ApprovalSealOnRecordView }>({ state: ApprovalSealReadState.LOADING })\n const [none, setNone] = useState(false)\n const [check, setCheck] = useState<{ readonly state: ApprovalSealCheckState; readonly outcome?: ApprovalSealCheckOutcome }>({ state: ApprovalSealCheckState.IDLE })\n const [downloading, setDownloading] = useState(false)\n const key = source?.key\n\n useEffect(() => {\n if (!source) return\n let current = true\n let polls = 0\n let timer: ReturnType<typeof setTimeout> | undefined\n setRead({ state: ApprovalSealReadState.LOADING })\n setNone(false)\n setCheck({ state: ApprovalSealCheckState.IDLE })\n const ask = (): void => {\n // Through a promise, so a load that throws before it returns one is a failed read like any other.\n Promise.resolve().then(source.load)\n .then((view) => {\n if (!current) return\n if (view === null) {\n setNone(true)\n return\n }\n setRead({ state: ApprovalSealReadState.READY, view })\n if (source.pollWhilePending && view.state === ApprovalSealOnRecordState.PENDING && polls < PENDING_SEAL_POLL_MAX) {\n polls += 1\n timer = setTimeout(ask, PENDING_SEAL_POLL_INTERVAL_MS)\n }\n })\n .catch((error: unknown) => {\n if (!current) return\n if (source.notFoundIsNone && isNotFound(error)) setNone(true)\n else setRead({ state: ApprovalSealReadState.FAILED })\n })\n }\n ask()\n return () => { current = false; if (timer) clearTimeout(timer) }\n // `key` names what is asked; the source object itself is rebuilt on every render.\n }, [key])\n\n const jws = read.view?.jws\n const onCheck = useCallback(() => {\n if (!jws) return\n setCheck({ state: ApprovalSealCheckState.CHECKING })\n getManualCallsHttpClient().checkApprovalSeal(jws)\n .then((verdict) => setCheck({ state: ApprovalSealCheckState.DONE, outcome: approvalSealCheckOutcomeOf(verdict) }))\n .catch(() => setCheck({ state: ApprovalSealCheckState.FAILED }))\n }, [jws])\n\n const onDownloadManifestedCopy = useCallback(() => {\n if (!source?.download) return\n setDownloading(true)\n source.download()\n .then((blob) => saveBlobAsFile(blob, source.downloadName))\n .catch(() => undefined)\n .finally(() => setDownloading(false))\n }, [key])\n\n return { read, none, check, onCheck, onDownloadManifestedCopy, downloading }\n}\n\n/** Draws one seal view through the preset, with the meaning and outcome in their vocabularies' words. */\nfunction ApprovalSealOf({ state, offersCopy = true, movedFieldLabels, description, className }: {\n readonly state: ReturnType<typeof useApprovalSealView>\n readonly offersCopy?: boolean\n readonly movedFieldLabels?: readonly string[]\n readonly description?: string\n readonly className?: string\n}): React.JSX.Element {\n const { tResourceFieldEnumValue } = useI18n()\n const { read, check, onCheck, onDownloadManifestedCopy, downloading } = state\n const view = read.view\n const shape = ApprovalSealSchema.shape\n return (\n <ApprovalSeal\n readState={read.state}\n {...(view ? { view } : {})}\n {...(movedFieldLabels ? { movedFieldLabels } : {})}\n {...(description ? { description } : {})}\n {...(view?.meaning ? { meaningLabel: tResourceFieldEnumValue(APPROVAL_SEALS, 'meaning', view.meaning, shape.meaning) } : {})}\n {...(view?.outcome ? { outcomeLabel: tResourceFieldEnumValue(APPROVAL_SEALS, 'outcome', view.outcome, shape.outcome) } : {})}\n checkState={check.state}\n {...(check.outcome ? { checkOutcome: check.outcome } : {})}\n {...(view?.jws ? { onCheck } : {})}\n {...(offersCopy && view?.deliverable?.manifestedCopyAvailable ? { onDownloadManifestedCopy, downloadingManifestedCopy: downloading } : {})}\n {...(className ? { className } : {})}\n />\n )\n}\n\n/**\n * The approval seal the record on this display surface stores in `field` (#2913): who approved it, when, with what\n * meaning, whether the approval still describes the record, its deliverable's manifested copy and a check of the seal.\n *\n * Place it in a resource's DISPLAY template (`*.ui-behavior.tsx`), where the record and its resource are in context. It\n * asks `GET /approval-seals/:sealId/records/:resourceType/:resourceId/:field`, which admits exactly the readers the\n * record's own READ admits, and asks again when the record changes, since whether the approval is current depends on it.\n * Moved fields are labelled with the record's own field labels; their values are never shown.\n */\nexport function RecordApprovalSeal({ field, hideWhenNone, className }: RecordApprovalSealProps): React.JSX.Element | null {\n const { resourceType, resourceId } = useResourceDisplayContext()\n const template = useOptionalDisplayTemplateContext()\n const record = template?.data\n const sealId = sealIdOf(record?.[field])\n const recordVersion = useRecordVersion(record)\n const target = sealId && resourceType && resourceId ? { sealId, resourceType: String(resourceType), resourceId: String(resourceId), field } : undefined\n const state = useApprovalSealView(target ? {\n // The record is part of what is asked: a value the approval covers may have moved.\n key: `${target.sealId}|${target.resourceType}|${target.resourceId}|${field}|${recordVersion}`,\n load: () => getManualCallsHttpClient().readApprovalSealOnRecord(target),\n download: () => getManualCallsHttpClient().downloadApprovalSealManifestedCopy(target),\n downloadName: `approval-${target.sealId}.pdf`,\n } : undefined)\n\n if (!record) return null\n if (!target) {\n if (hideWhenNone || !resourceType) return null\n return <ApprovalSeal readState={ApprovalSealReadState.READY} view={{ sealId: '', state: ApprovalSealOnRecordState.NO_SEAL }} {...(className ? { className } : {})} />\n }\n const movedFieldLabels = state.read.view?.currency?.movedFields.map((name) => template?.fieldLabels?.[name] ?? name)\n return <ApprovalSealOf state={state} {...(movedFieldLabels ? { movedFieldLabels } : {})} {...(className ? { className } : {})} />\n}\n\n/** A record's identity in time, so the record's seal is asked again when the record changes. */\nfunction useRecordVersion(record: Record<string, unknown> | undefined): string {\n const updatedAt = record?.updatedAt\n const stamp = updatedAt instanceof Date ? updatedAt.toISOString() : typeof updatedAt === 'string' ? updatedAt : ''\n // Without a stamp, the object's identity is the version: a re-read hands a new object.\n const [identity, setIdentity] = useState(0)\n const last = useRef(record)\n useEffect(() => {\n if (last.current !== record) { last.current = record; if (!stamp) setIdentity((value) => value + 1) }\n }, [record, stamp])\n return stamp || String(identity)\n}\n\nexport interface FileApprovalSealProps {\n /** The file a seal may attest: the deliverable a person approved by its hash (a close report's PDF). */\n readonly fileId: string\n readonly className?: string\n}\n\n/**\n * The approval seal that attests a file, under the file (#2913): drawn by `DisplayFieldFile` on a DISPLAY surface, and\n * nothing at all for the many files no seal attests, which the door answers `null` rather than a 404 the browser would\n * log as a failed load (#3868). It asks `GET /approval-seals/files/:fileId`, admitted by the READ\n * of the record the file belongs to, and only for a seal its own record still names (an approval whose effect failed\n * shows nothing). Currency is not drawn here: it is a statement about the record the approval is about.\n */\nexport function FileApprovalSeal({ fileId, className }: FileApprovalSealProps): React.JSX.Element | null {\n const state = useApprovalSealView({\n key: fileId,\n load: () => getManualCallsHttpClient().readApprovalSealOnFile(fileId),\n download: () => getManualCallsHttpClient().downloadApprovalSealFileManifestedCopy(fileId),\n downloadName: `approval-${fileId}.pdf`,\n notFoundIsNone: true,\n })\n if (state.none || state.read.state === ApprovalSealReadState.LOADING) return null\n return <ApprovalSealOf state={state} {...(className ? { className } : {})} />\n}\n\nexport interface DecisionApprovalSealProps {\n /** The decision whose seal is shown: one the signed-in person answered, or one raised in their conversation (#4062). */\n readonly decisionRef: string\n /** What the decision was about, in the card's own words (the title the inbox showed). */\n readonly description?: string\n readonly className?: string\n}\n\n/**\n * The seal of a decision (#2913), once it is decided: under the inbox for the answers given there, and on a conversation's\n * line for the call that waited on it (#4062). Asked of `GET /approval-seals/decisions/:decisionRef`, which answers the\n * decider, and anyone else only when the record the seal is about names it and that record's own READ admits them. The\n * seal is signed seconds after the decision, so a PENDING seal is asked again until it is signed (about a minute at most); a decision that sealed nothing\n * draws nothing.\n */\nexport function DecisionApprovalSeal({ decisionRef, description, className }: DecisionApprovalSealProps): React.JSX.Element | null {\n const state = useApprovalSealView({\n key: decisionRef,\n load: () => getManualCallsHttpClient().readApprovalSealOfDecision(decisionRef),\n downloadName: `approval-${decisionRef}.pdf`,\n notFoundIsNone: true,\n pollWhilePending: true,\n })\n if (state.none) return null\n // The decider's view offers no copy: the deliverable is the record's, downloaded where the record is read.\n return <ApprovalSealOf state={state} offersCopy={false} {...(description ? { description } : {})} {...(className ? { className } : {})} />\n}\n"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SignatureRequestOnRecordView, type SignatureRequestUnsentApprovalOnRecord } from '@wildo-ai/saas-models';
|
|
3
|
+
import type { ComponentPresetProps } from '../../core/components-registry/component-registry.frontend.schemas';
|
|
4
|
+
/** Where the read of a record's signature requests stands. */
|
|
5
|
+
export declare enum SignatureRequestsReadState {
|
|
6
|
+
/** Asked, not answered yet. */
|
|
7
|
+
LOADING = "loading",
|
|
8
|
+
/** Answered: `entries` hold the record's requests, newest first (none: nothing was sent for signature). */
|
|
9
|
+
READY = "ready",
|
|
10
|
+
/** The read failed: said so, never shown as a record nothing was sent for. */
|
|
11
|
+
FAILED = "failed"
|
|
12
|
+
}
|
|
13
|
+
/** Which of a SIGNED request's two files a download asks for. */
|
|
14
|
+
export declare enum SignatureRequestDownload {
|
|
15
|
+
SIGNED_DOCUMENT = "signed_document",
|
|
16
|
+
VALIDATION_EVIDENCE = "validation_evidence"
|
|
17
|
+
}
|
|
18
|
+
/** One request, with its state and level already in their vocabularies' words. */
|
|
19
|
+
export interface SignatureRequestEntry {
|
|
20
|
+
readonly request: SignatureRequestOnRecordView;
|
|
21
|
+
/** `system_enums.SignatureRequest_State`, for the request's state. */
|
|
22
|
+
readonly stateLabel: string;
|
|
23
|
+
/** `system_enums.ElectronicSignature_Level`, for the level required. */
|
|
24
|
+
readonly levelLabel: string;
|
|
25
|
+
}
|
|
26
|
+
/** One approval whose deliverable has no request yet (#2925 review), with its level in its vocabulary's word. */
|
|
27
|
+
export interface SignatureRequestUnsentApprovalEntry {
|
|
28
|
+
readonly approval: SignatureRequestUnsentApprovalOnRecord;
|
|
29
|
+
/** `system_enums.ElectronicSignature_Level`, for the level required. */
|
|
30
|
+
readonly levelLabel: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* What the preset draws (#2925). Presentational: the wrapper reads the requests, words their state and level, and runs
|
|
34
|
+
* the actions; the preset never decides what a reader may see or do, the door already did (a resend is offered only for
|
|
35
|
+
* a request the door marked `resendable`, a download only for one whose files it marked available).
|
|
36
|
+
*/
|
|
37
|
+
export interface SignatureRequestsProps {
|
|
38
|
+
readonly readState: SignatureRequestsReadState;
|
|
39
|
+
/** Present when `readState` is READY, newest first; empty when nothing was sent for signature. */
|
|
40
|
+
readonly entries?: readonly SignatureRequestEntry[];
|
|
41
|
+
/**
|
|
42
|
+
* Present when `readState` is READY: the approvals whose deliverable is approved and has no request yet (#2925 review).
|
|
43
|
+
* Each is drawn as approved and UNSIGNED, never as nothing.
|
|
44
|
+
*/
|
|
45
|
+
readonly unsentApprovals?: readonly SignatureRequestUnsentApprovalEntry[];
|
|
46
|
+
readonly onDownload?: (signatureRequestId: string, which: SignatureRequestDownload) => void;
|
|
47
|
+
readonly onResend?: (signatureRequestId: string) => void;
|
|
48
|
+
/** Offered only when the door marked an unsent approval `sendable`. */
|
|
49
|
+
readonly onSend?: (approvalSealId: string) => void;
|
|
50
|
+
/** The request an action is running for, so its buttons show it. */
|
|
51
|
+
readonly busyRequestId?: string;
|
|
52
|
+
/** The approval a send is running for. */
|
|
53
|
+
readonly busyApprovalSealId?: string;
|
|
54
|
+
/** The last resend was refused or failed: said so beside the request it was asked for. */
|
|
55
|
+
readonly resendFailedRequestId?: string;
|
|
56
|
+
/** The last send was refused or failed: said so beside the approval it was asked for. */
|
|
57
|
+
readonly sendFailedApprovalSealId?: string;
|
|
58
|
+
/** The last download failed (a file that does not match its hash is refused): said so beside its request. */
|
|
59
|
+
readonly downloadFailedRequestId?: string;
|
|
60
|
+
readonly className?: string;
|
|
61
|
+
}
|
|
62
|
+
/** The preset, resolved from the registry: an application may replace how the requests are drawn. */
|
|
63
|
+
export declare function SignatureRequests({ preset, ...props }: SignatureRequestsProps & ComponentPresetProps): React.JSX.Element;
|
|
64
|
+
export interface RecordSignatureRequestsProps {
|
|
65
|
+
/** Draw nothing when nothing was sent for signature, instead of saying so. */
|
|
66
|
+
readonly hideWhenNone?: boolean;
|
|
67
|
+
readonly className?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The electronic-signature requests sent for the deliverable of the record on this display surface (#2925): where each
|
|
71
|
+
* stands, the signed document and its evidence once signed, and a resend of one that ended unsigned.
|
|
72
|
+
*
|
|
73
|
+
* Place it in a resource's DISPLAY template (`*.ui-behavior.tsx`), beside `EmbeddedSigningFrame` when signers sign inside
|
|
74
|
+
* the application. It asks `GET /signature-requests/records/:resourceType/:resourceId`, which admits exactly the readers
|
|
75
|
+
* the record's own READ admits; a resend is offered only to a caller the record's UPDATE admits, and only for the newest
|
|
76
|
+
* request of its approval that ended unsigned and was not replaced. An approved deliverable with no request yet is shown
|
|
77
|
+
* as approved and unsigned, with a send for the same callers. An unsigned request is never drawn as signed, and a request
|
|
78
|
+
* a vendor's test environment accepted without validating says so.
|
|
79
|
+
*/
|
|
80
|
+
export declare function RecordSignatureRequests({ hideWhenNone, className }: RecordSignatureRequestsProps): React.JSX.Element | null;
|
|
81
|
+
//# sourceMappingURL=signature-requests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature-requests.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/signature-requests.tsx"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E;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAA;IAClD,oEAAoE;IACpE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;IAC/B,0CAA0C;IAC1C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IACpC,0FAA0F;IAC1F,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IACvC,yFAAyF;IACzF,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAA;IAC1C,6GAA6G;IAC7G,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAA;IACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAID,qGAAqG;AACrG,wBAAgB,iBAAiB,CAAC,EAAE,MAAgC,EAAE,GAAG,KAAK,EAAE,EAAE,sBAAsB,GAAG,oBAAoB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAGlJ;AAED,MAAM,WAAW,4BAA4B;IAC3C,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAA;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,4BAA4B,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAwF3H"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { CoreResourceType, SignatureRequestSchema, } from '@wildo-ai/saas-models';
|
|
4
|
+
import { FrontendComponentType, CorePresetNames } from '@wildo-ai/presets-components-models';
|
|
5
|
+
import { createComponentResolver } from '../../core/components-registry/component-resolver.frontend.helper.js';
|
|
6
|
+
import { getManualCallsHttpClient } from '../../core/requests/wildo-http-client-manual-calls.frontend.service.js';
|
|
7
|
+
import { saveBlobAsFile } from '../../core/commons/save-blob-as-file.frontend.utils.js';
|
|
8
|
+
import { useResourceDisplayContext } from '../../components/data-display/automatic-displayer.utils.js';
|
|
9
|
+
import { useOptionalDisplayTemplateContext } from '../../components/data-display/DisplayTemplateContext.js';
|
|
10
|
+
import { useI18n } from '../../core/i18n/useI18n.js';
|
|
11
|
+
/** The requests' own resource, whose fields declare the vocabularies the state and the level are worded from. */
|
|
12
|
+
const SIGNATURE_REQUESTS = CoreResourceType.SIGNATURE_REQUESTS;
|
|
13
|
+
/** Where the read of a record's signature requests stands. */
|
|
14
|
+
export var SignatureRequestsReadState;
|
|
15
|
+
(function (SignatureRequestsReadState) {
|
|
16
|
+
/** Asked, not answered yet. */
|
|
17
|
+
SignatureRequestsReadState["LOADING"] = "loading";
|
|
18
|
+
/** Answered: `entries` hold the record's requests, newest first (none: nothing was sent for signature). */
|
|
19
|
+
SignatureRequestsReadState["READY"] = "ready";
|
|
20
|
+
/** The read failed: said so, never shown as a record nothing was sent for. */
|
|
21
|
+
SignatureRequestsReadState["FAILED"] = "failed";
|
|
22
|
+
})(SignatureRequestsReadState || (SignatureRequestsReadState = {}));
|
|
23
|
+
/** Which of a SIGNED request's two files a download asks for. */
|
|
24
|
+
export var SignatureRequestDownload;
|
|
25
|
+
(function (SignatureRequestDownload) {
|
|
26
|
+
SignatureRequestDownload["SIGNED_DOCUMENT"] = "signed_document";
|
|
27
|
+
SignatureRequestDownload["VALIDATION_EVIDENCE"] = "validation_evidence";
|
|
28
|
+
})(SignatureRequestDownload || (SignatureRequestDownload = {}));
|
|
29
|
+
// --- Wrapper ---
|
|
30
|
+
/** The preset, resolved from the registry: an application may replace how the requests are drawn. */
|
|
31
|
+
export function SignatureRequests({ preset = CorePresetNames.DEFAULT, ...props }) {
|
|
32
|
+
const Component = createComponentResolver(FrontendComponentType.LOW_LEVEL_SIGNATURE_REQUESTS, 'SignatureRequests')(preset);
|
|
33
|
+
return _jsx(Component, { ...props });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The electronic-signature requests sent for the deliverable of the record on this display surface (#2925): where each
|
|
37
|
+
* stands, the signed document and its evidence once signed, and a resend of one that ended unsigned.
|
|
38
|
+
*
|
|
39
|
+
* Place it in a resource's DISPLAY template (`*.ui-behavior.tsx`), beside `EmbeddedSigningFrame` when signers sign inside
|
|
40
|
+
* the application. It asks `GET /signature-requests/records/:resourceType/:resourceId`, which admits exactly the readers
|
|
41
|
+
* the record's own READ admits; a resend is offered only to a caller the record's UPDATE admits, and only for the newest
|
|
42
|
+
* request of its approval that ended unsigned and was not replaced. An approved deliverable with no request yet is shown
|
|
43
|
+
* as approved and unsigned, with a send for the same callers. An unsigned request is never drawn as signed, and a request
|
|
44
|
+
* a vendor's test environment accepted without validating says so.
|
|
45
|
+
*/
|
|
46
|
+
export function RecordSignatureRequests({ hideWhenNone, className }) {
|
|
47
|
+
const { resourceType, resourceId } = useResourceDisplayContext();
|
|
48
|
+
const template = useOptionalDisplayTemplateContext();
|
|
49
|
+
const { tResourceFieldEnumValue } = useI18n();
|
|
50
|
+
const target = resourceType && resourceId ? { resourceType: String(resourceType), resourceId: String(resourceId) } : undefined;
|
|
51
|
+
const [read, setRead] = useState({ state: SignatureRequestsReadState.LOADING });
|
|
52
|
+
const [version, setVersion] = useState(0);
|
|
53
|
+
const [busyRequestId, setBusyRequestId] = useState(undefined);
|
|
54
|
+
const [busyApprovalSealId, setBusyApprovalSealId] = useState(undefined);
|
|
55
|
+
const [resendFailedRequestId, setResendFailedRequestId] = useState(undefined);
|
|
56
|
+
const [sendFailedApprovalSealId, setSendFailedApprovalSealId] = useState(undefined);
|
|
57
|
+
const [downloadFailedRequestId, setDownloadFailedRequestId] = useState(undefined);
|
|
58
|
+
const key = target ? `${target.resourceType}|${target.resourceId}|${version}` : undefined;
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!target)
|
|
61
|
+
return;
|
|
62
|
+
let current = true;
|
|
63
|
+
setRead({ state: SignatureRequestsReadState.LOADING });
|
|
64
|
+
Promise.resolve().then(() => getManualCallsHttpClient().readSignatureRequestsOnRecord(target))
|
|
65
|
+
.then((view) => { if (current)
|
|
66
|
+
setRead({ state: SignatureRequestsReadState.READY, view }); })
|
|
67
|
+
.catch(() => { if (current)
|
|
68
|
+
setRead({ state: SignatureRequestsReadState.FAILED }); });
|
|
69
|
+
return () => { current = false; };
|
|
70
|
+
// `key` names what is asked; `target` is rebuilt on every render.
|
|
71
|
+
}, [key]);
|
|
72
|
+
const onDownload = useCallback((signatureRequestId, which) => {
|
|
73
|
+
if (!target)
|
|
74
|
+
return;
|
|
75
|
+
const params = { ...target, signatureRequestId };
|
|
76
|
+
setBusyRequestId(signatureRequestId);
|
|
77
|
+
setDownloadFailedRequestId(undefined);
|
|
78
|
+
const client = getManualCallsHttpClient();
|
|
79
|
+
const download = which === SignatureRequestDownload.SIGNED_DOCUMENT
|
|
80
|
+
? client.downloadSignatureRequestSignedDocument(params).then((blob) => saveBlobAsFile(blob, `signed-${signatureRequestId}.pdf`))
|
|
81
|
+
: client.downloadSignatureRequestValidationEvidence(params).then((blob) => saveBlobAsFile(blob, `signature-evidence-${signatureRequestId}.json`));
|
|
82
|
+
// A failed download is said, never swallowed: a file whose bytes no longer match its hash is refused (409).
|
|
83
|
+
download.catch(() => setDownloadFailedRequestId(signatureRequestId)).finally(() => setBusyRequestId(undefined));
|
|
84
|
+
}, [key]);
|
|
85
|
+
const onSend = useCallback((approvalSealId) => {
|
|
86
|
+
if (!target)
|
|
87
|
+
return;
|
|
88
|
+
setBusyApprovalSealId(approvalSealId);
|
|
89
|
+
setSendFailedApprovalSealId(undefined);
|
|
90
|
+
getManualCallsHttpClient().sendSignatureRequestForApproval({ ...target, approvalSealId })
|
|
91
|
+
.then(() => setVersion((value) => value + 1))
|
|
92
|
+
.catch(() => setSendFailedApprovalSealId(approvalSealId))
|
|
93
|
+
.finally(() => setBusyApprovalSealId(undefined));
|
|
94
|
+
}, [key]);
|
|
95
|
+
const onResend = useCallback((signatureRequestId) => {
|
|
96
|
+
if (!target)
|
|
97
|
+
return;
|
|
98
|
+
setBusyRequestId(signatureRequestId);
|
|
99
|
+
setResendFailedRequestId(undefined);
|
|
100
|
+
getManualCallsHttpClient().resendSignatureRequest({ ...target, signatureRequestId })
|
|
101
|
+
.then(() => setVersion((value) => value + 1))
|
|
102
|
+
.catch(() => setResendFailedRequestId(signatureRequestId))
|
|
103
|
+
.finally(() => setBusyRequestId(undefined));
|
|
104
|
+
}, [key]);
|
|
105
|
+
if (!template?.data || !target)
|
|
106
|
+
return null;
|
|
107
|
+
const shape = SignatureRequestSchema.shape;
|
|
108
|
+
const entries = read.view?.requests.map((request) => ({
|
|
109
|
+
request,
|
|
110
|
+
stateLabel: tResourceFieldEnumValue(SIGNATURE_REQUESTS, 'state', request.state, shape.state),
|
|
111
|
+
levelLabel: tResourceFieldEnumValue(SIGNATURE_REQUESTS, 'requiredLevel', request.requiredLevel, shape.requiredLevel),
|
|
112
|
+
}));
|
|
113
|
+
const unsentApprovals = read.view?.unsentApprovals.map((approval) => ({
|
|
114
|
+
approval,
|
|
115
|
+
levelLabel: tResourceFieldEnumValue(SIGNATURE_REQUESTS, 'requiredLevel', approval.requiredLevel, shape.requiredLevel),
|
|
116
|
+
}));
|
|
117
|
+
if (hideWhenNone && read.state === SignatureRequestsReadState.READY && entries?.length === 0 && unsentApprovals?.length === 0)
|
|
118
|
+
return null;
|
|
119
|
+
const resendable = entries?.some((entry) => entry.request.resendable) === true;
|
|
120
|
+
const sendable = unsentApprovals?.some((entry) => entry.approval.sendable) === true;
|
|
121
|
+
return (_jsx(SignatureRequests, { readState: read.state, ...(entries ? { entries } : {}), ...(unsentApprovals ? { unsentApprovals } : {}), onDownload: onDownload, ...(resendable ? { onResend } : {}), ...(sendable ? { onSend } : {}), ...(busyRequestId ? { busyRequestId } : {}), ...(busyApprovalSealId ? { busyApprovalSealId } : {}), ...(resendFailedRequestId ? { resendFailedRequestId } : {}), ...(sendFailedApprovalSealId ? { sendFailedApprovalSealId } : {}), ...(downloadFailedRequestId ? { downloadFailedRequestId } : {}), ...(className ? { className } : {}) }));
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=signature-requests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature-requests.js","sourceRoot":"","sources":["../../../../src/components/data-display/signature-requests.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC/D,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GAIvB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,iFAAiF,CAAA;AAEzH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mFAAmF,CAAA;AAC5H,OAAO,EAAE,cAAc,EAAE,MAAM,mEAAmE,CAAA;AAClG,OAAO,EAAE,yBAAyB,EAAE,MAAM,uEAAuE,CAAA;AACjH,OAAO,EAAE,iCAAiC,EAAE,MAAM,oEAAoE,CAAA;AACtH,OAAO,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAA;AAE/D,iHAAiH;AACjH,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,kBAAkB,CAAA;AAE9D,8DAA8D;AAC9D,MAAM,CAAN,IAAY,0BAOX;AAPD,WAAY,0BAA0B;IACpC,+BAA+B;IAC/B,iDAAmB,CAAA;IACnB,2GAA2G;IAC3G,6CAAe,CAAA;IACf,8EAA8E;IAC9E,+CAAiB,CAAA;AACnB,CAAC,EAPW,0BAA0B,KAA1B,0BAA0B,QAOrC;AAED,iEAAiE;AACjE,MAAM,CAAN,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAClC,+DAAmC,CAAA;IACnC,uEAA2C,CAAA;AAC7C,C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EAAE,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACxD,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,wBAAwB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAC9D,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAC5D,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACpC,CACH,CAAA;AACH,CAAC","sourcesContent":["import React, { useCallback, useEffect, useState } from 'react'\nimport {\n CoreResourceType,\n SignatureRequestSchema,\n type SignatureRequestOnRecordView,\n type SignatureRequestUnsentApprovalOnRecord,\n type SignatureRequestsOnRecordView,\n} from '@wildo-ai/saas-models'\nimport { FrontendComponentType, CorePresetNames } from '@wildo-ai/presets-components-models'\nimport { createComponentResolver } from '~wildo-frontend-lib/core/components-registry/component-resolver.frontend.helper'\nimport type { ComponentPresetProps } from '~wildo-frontend-lib/core/components-registry/component-registry.frontend.schemas'\nimport { getManualCallsHttpClient } from '~wildo-frontend-lib/core/requests/wildo-http-client-manual-calls.frontend.service'\nimport { saveBlobAsFile } from '~wildo-frontend-lib/core/commons/save-blob-as-file.frontend.utils'\nimport { useResourceDisplayContext } from '~wildo-frontend-lib/components/data-display/automatic-displayer.utils'\nimport { useOptionalDisplayTemplateContext } from '~wildo-frontend-lib/components/data-display/DisplayTemplateContext'\nimport { useI18n } from '~wildo-frontend-lib/core/i18n/useI18n'\n\n/** The requests' own resource, whose fields declare the vocabularies the state and the level are worded from. */\nconst SIGNATURE_REQUESTS = CoreResourceType.SIGNATURE_REQUESTS\n\n/** Where the read of a record's signature requests stands. */\nexport enum SignatureRequestsReadState {\n /** Asked, not answered yet. */\n LOADING = 'loading',\n /** Answered: `entries` hold the record's requests, newest first (none: nothing was sent for signature). */\n READY = 'ready',\n /** The read failed: said so, never shown as a record nothing was sent for. */\n FAILED = 'failed',\n}\n\n/** Which of a SIGNED request's two files a download asks for. */\nexport enum SignatureRequestDownload {\n SIGNED_DOCUMENT = 'signed_document',\n VALIDATION_EVIDENCE = 'validation_evidence',\n}\n\n/** One request, with its state and level already in their vocabularies' words. */\nexport interface SignatureRequestEntry {\n readonly request: SignatureRequestOnRecordView\n /** `system_enums.SignatureRequest_State`, for the request's state. */\n readonly stateLabel: string\n /** `system_enums.ElectronicSignature_Level`, for the level required. */\n readonly levelLabel: string\n}\n\n/** One approval whose deliverable has no request yet (#2925 review), with its level in its vocabulary's word. */\nexport interface SignatureRequestUnsentApprovalEntry {\n readonly approval: SignatureRequestUnsentApprovalOnRecord\n /** `system_enums.ElectronicSignature_Level`, for the level required. */\n readonly levelLabel: string\n}\n\n// --- Contract ---\n\n/**\n * What the preset draws (#2925). Presentational: the wrapper reads the requests, words their state and level, and runs\n * the actions; the preset never decides what a reader may see or do, the door already did (a resend is offered only for\n * a request the door marked `resendable`, a download only for one whose files it marked available).\n */\nexport interface SignatureRequestsProps {\n readonly readState: SignatureRequestsReadState\n /** Present when `readState` is READY, newest first; empty when nothing was sent for signature. */\n readonly entries?: readonly SignatureRequestEntry[]\n /**\n * Present when `readState` is READY: the approvals whose deliverable is approved and has no request yet (#2925 review).\n * Each is drawn as approved and UNSIGNED, never as nothing.\n */\n readonly unsentApprovals?: readonly SignatureRequestUnsentApprovalEntry[]\n readonly onDownload?: (signatureRequestId: string, which: SignatureRequestDownload) => void\n readonly onResend?: (signatureRequestId: string) => void\n /** Offered only when the door marked an unsent approval `sendable`. */\n readonly onSend?: (approvalSealId: string) => void\n /** The request an action is running for, so its buttons show it. */\n readonly busyRequestId?: string\n /** The approval a send is running for. */\n readonly busyApprovalSealId?: string\n /** The last resend was refused or failed: said so beside the request it was asked for. */\n readonly resendFailedRequestId?: string\n /** The last send was refused or failed: said so beside the approval it was asked for. */\n readonly sendFailedApprovalSealId?: string\n /** The last download failed (a file that does not match its hash is refused): said so beside its request. */\n readonly downloadFailedRequestId?: string\n readonly className?: string\n}\n\n// --- Wrapper ---\n\n/** The preset, resolved from the registry: an application may replace how the requests are drawn. */\nexport function SignatureRequests({ preset = CorePresetNames.DEFAULT, ...props }: SignatureRequestsProps & ComponentPresetProps): React.JSX.Element {\n const Component = createComponentResolver<SignatureRequestsProps>(FrontendComponentType.LOW_LEVEL_SIGNATURE_REQUESTS, 'SignatureRequests')(preset)\n return <Component {...props} />\n}\n\nexport interface RecordSignatureRequestsProps {\n /** Draw nothing when nothing was sent for signature, instead of saying so. */\n readonly hideWhenNone?: boolean\n readonly className?: string\n}\n\n/**\n * The electronic-signature requests sent for the deliverable of the record on this display surface (#2925): where each\n * stands, the signed document and its evidence once signed, and a resend of one that ended unsigned.\n *\n * Place it in a resource's DISPLAY template (`*.ui-behavior.tsx`), beside `EmbeddedSigningFrame` when signers sign inside\n * the application. It asks `GET /signature-requests/records/:resourceType/:resourceId`, which admits exactly the readers\n * the record's own READ admits; a resend is offered only to a caller the record's UPDATE admits, and only for the newest\n * request of its approval that ended unsigned and was not replaced. An approved deliverable with no request yet is shown\n * as approved and unsigned, with a send for the same callers. An unsigned request is never drawn as signed, and a request\n * a vendor's test environment accepted without validating says so.\n */\nexport function RecordSignatureRequests({ hideWhenNone, className }: RecordSignatureRequestsProps): React.JSX.Element | null {\n const { resourceType, resourceId } = useResourceDisplayContext()\n const template = useOptionalDisplayTemplateContext()\n const { tResourceFieldEnumValue } = useI18n()\n const target = resourceType && resourceId ? { resourceType: String(resourceType), resourceId: String(resourceId) } : undefined\n const [read, setRead] = useState<{ readonly state: SignatureRequestsReadState; readonly view?: SignatureRequestsOnRecordView }>({ state: SignatureRequestsReadState.LOADING })\n const [version, setVersion] = useState(0)\n const [busyRequestId, setBusyRequestId] = useState<string | undefined>(undefined)\n const [busyApprovalSealId, setBusyApprovalSealId] = useState<string | undefined>(undefined)\n const [resendFailedRequestId, setResendFailedRequestId] = useState<string | undefined>(undefined)\n const [sendFailedApprovalSealId, setSendFailedApprovalSealId] = useState<string | undefined>(undefined)\n const [downloadFailedRequestId, setDownloadFailedRequestId] = useState<string | undefined>(undefined)\n const key = target ? `${target.resourceType}|${target.resourceId}|${version}` : undefined\n\n useEffect(() => {\n if (!target) return\n let current = true\n setRead({ state: SignatureRequestsReadState.LOADING })\n Promise.resolve().then(() => getManualCallsHttpClient().readSignatureRequestsOnRecord(target))\n .then((view) => { if (current) setRead({ state: SignatureRequestsReadState.READY, view }) })\n .catch(() => { if (current) setRead({ state: SignatureRequestsReadState.FAILED }) })\n return () => { current = false }\n // `key` names what is asked; `target` is rebuilt on every render.\n }, [key])\n\n const onDownload = useCallback((signatureRequestId: string, which: SignatureRequestDownload) => {\n if (!target) return\n const params = { ...target, signatureRequestId }\n setBusyRequestId(signatureRequestId)\n setDownloadFailedRequestId(undefined)\n const client = getManualCallsHttpClient()\n const download = which === SignatureRequestDownload.SIGNED_DOCUMENT\n ? client.downloadSignatureRequestSignedDocument(params).then((blob) => saveBlobAsFile(blob, `signed-${signatureRequestId}.pdf`))\n : client.downloadSignatureRequestValidationEvidence(params).then((blob) => saveBlobAsFile(blob, `signature-evidence-${signatureRequestId}.json`))\n // A failed download is said, never swallowed: a file whose bytes no longer match its hash is refused (409).\n download.catch(() => setDownloadFailedRequestId(signatureRequestId)).finally(() => setBusyRequestId(undefined))\n }, [key])\n\n const onSend = useCallback((approvalSealId: string) => {\n if (!target) return\n setBusyApprovalSealId(approvalSealId)\n setSendFailedApprovalSealId(undefined)\n getManualCallsHttpClient().sendSignatureRequestForApproval({ ...target, approvalSealId })\n .then(() => setVersion((value) => value + 1))\n .catch(() => setSendFailedApprovalSealId(approvalSealId))\n .finally(() => setBusyApprovalSealId(undefined))\n }, [key])\n\n const onResend = useCallback((signatureRequestId: string) => {\n if (!target) return\n setBusyRequestId(signatureRequestId)\n setResendFailedRequestId(undefined)\n getManualCallsHttpClient().resendSignatureRequest({ ...target, signatureRequestId })\n .then(() => setVersion((value) => value + 1))\n .catch(() => setResendFailedRequestId(signatureRequestId))\n .finally(() => setBusyRequestId(undefined))\n }, [key])\n\n if (!template?.data || !target) return null\n const shape = SignatureRequestSchema.shape\n const entries = read.view?.requests.map((request): SignatureRequestEntry => ({\n request,\n stateLabel: tResourceFieldEnumValue(SIGNATURE_REQUESTS, 'state', request.state, shape.state),\n levelLabel: tResourceFieldEnumValue(SIGNATURE_REQUESTS, 'requiredLevel', request.requiredLevel, shape.requiredLevel),\n }))\n const unsentApprovals = read.view?.unsentApprovals.map((approval): SignatureRequestUnsentApprovalEntry => ({\n approval,\n levelLabel: tResourceFieldEnumValue(SIGNATURE_REQUESTS, 'requiredLevel', approval.requiredLevel, shape.requiredLevel),\n }))\n if (hideWhenNone && read.state === SignatureRequestsReadState.READY && entries?.length === 0 && unsentApprovals?.length === 0) return null\n const resendable = entries?.some((entry) => entry.request.resendable) === true\n const sendable = unsentApprovals?.some((entry) => entry.approval.sendable) === true\n return (\n <SignatureRequests\n readState={read.state}\n {...(entries ? { entries } : {})}\n {...(unsentApprovals ? { unsentApprovals } : {})}\n onDownload={onDownload}\n {...(resendable ? { onResend } : {})}\n {...(sendable ? { onSend } : {})}\n {...(busyRequestId ? { busyRequestId } : {})}\n {...(busyApprovalSealId ? { busyApprovalSealId } : {})}\n {...(resendFailedRequestId ? { resendFailedRequestId } : {})}\n {...(sendFailedApprovalSealId ? { sendFailedApprovalSealId } : {})}\n {...(downloadFailedRequestId ? { downloadFailedRequestId } : {})}\n {...(className ? { className } : {})}\n />\n )\n}\n"]}
|