@manta-eu/react 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/dist/components/AppErrorBoundary.d.ts.map +1 -1
- package/dist/components/AppErrorBoundary.js +14 -11
- package/dist/components/AppErrorBoundary.js.map +1 -1
- package/dist/components/app-gate/AppGate.d.ts +8 -0
- package/dist/components/app-gate/AppGate.d.ts.map +1 -0
- package/dist/components/app-gate/AppGate.js +68 -0
- package/dist/components/app-gate/AppGate.js.map +1 -0
- package/dist/components/app-gate/AwaitingDatastoreStatus.d.ts +7 -0
- package/dist/components/app-gate/AwaitingDatastoreStatus.d.ts.map +1 -0
- package/dist/components/app-gate/AwaitingDatastoreStatus.js +19 -0
- package/dist/components/app-gate/AwaitingDatastoreStatus.js.map +1 -0
- package/dist/components/app-gate/EnterDatastoreRoute.d.ts +2 -0
- package/dist/components/app-gate/EnterDatastoreRoute.d.ts.map +1 -0
- package/dist/components/app-gate/EnterDatastoreRoute.js +25 -0
- package/dist/components/app-gate/EnterDatastoreRoute.js.map +1 -0
- package/dist/components/app-gate/ErrorRoute.d.ts +2 -0
- package/dist/components/app-gate/ErrorRoute.d.ts.map +1 -0
- package/dist/components/app-gate/ErrorRoute.js +27 -0
- package/dist/components/app-gate/ErrorRoute.js.map +1 -0
- package/dist/components/app-gate/FailureAlert.d.ts +5 -0
- package/dist/components/app-gate/FailureAlert.d.ts.map +1 -0
- package/dist/components/app-gate/FailureAlert.js +9 -0
- package/dist/components/app-gate/FailureAlert.js.map +1 -0
- package/dist/components/app-gate/NoDatastoreAccess.d.ts +8 -0
- package/dist/components/app-gate/NoDatastoreAccess.d.ts.map +1 -0
- package/dist/components/app-gate/NoDatastoreAccess.js +9 -0
- package/dist/components/app-gate/NoDatastoreAccess.js.map +1 -0
- package/dist/components/app-gate/NotFoundRoute.d.ts +2 -0
- package/dist/components/app-gate/NotFoundRoute.d.ts.map +1 -0
- package/dist/components/app-gate/NotFoundRoute.js +9 -0
- package/dist/components/app-gate/NotFoundRoute.js.map +1 -0
- package/dist/components/app-gate/PendingInvitations.d.ts +5 -0
- package/dist/components/app-gate/PendingInvitations.d.ts.map +1 -0
- package/dist/components/app-gate/PendingInvitations.js +58 -0
- package/dist/components/app-gate/PendingInvitations.js.map +1 -0
- package/dist/components/app-gate/ServiceError.d.ts +8 -0
- package/dist/components/app-gate/ServiceError.d.ts.map +1 -0
- package/dist/components/app-gate/ServiceError.js +10 -0
- package/dist/components/app-gate/ServiceError.js.map +1 -0
- package/dist/components/app-gate/index.d.ts +3 -0
- package/dist/components/app-gate/index.d.ts.map +1 -0
- package/dist/components/app-gate/index.js +3 -0
- package/dist/components/app-gate/index.js.map +1 -0
- package/dist/components/app-gate/sdk-route-elements.d.ts +23 -0
- package/dist/components/app-gate/sdk-route-elements.d.ts.map +1 -0
- package/dist/components/app-gate/sdk-route-elements.js +35 -0
- package/dist/components/app-gate/sdk-route-elements.js.map +1 -0
- package/dist/components/app-shell/AppShell.d.ts +7 -0
- package/dist/components/app-shell/AppShell.d.ts.map +1 -0
- package/dist/components/app-shell/AppShell.js +10 -0
- package/dist/components/app-shell/AppShell.js.map +1 -0
- package/dist/components/app-shell/AppShellRoutes.d.ts +9 -0
- package/dist/components/app-shell/AppShellRoutes.d.ts.map +1 -0
- package/dist/components/app-shell/AppShellRoutes.js +20 -0
- package/dist/components/app-shell/AppShellRoutes.js.map +1 -0
- package/dist/components/app-shell/GroupDatastores.d.ts +8 -0
- package/dist/components/app-shell/GroupDatastores.d.ts.map +1 -0
- package/dist/components/app-shell/GroupDatastores.js +15 -0
- package/dist/components/app-shell/GroupDatastores.js.map +1 -0
- package/dist/components/app-shell/GroupRoute.d.ts +2 -0
- package/dist/components/app-shell/GroupRoute.d.ts.map +1 -0
- package/dist/components/app-shell/GroupRoute.js +22 -0
- package/dist/components/app-shell/GroupRoute.js.map +1 -0
- package/dist/components/app-shell/index.d.ts +3 -0
- package/dist/components/app-shell/index.d.ts.map +1 -0
- package/dist/components/app-shell/index.js +3 -0
- package/dist/components/app-shell/index.js.map +1 -0
- package/dist/components/authenticated-chat/index.d.ts +1 -2
- package/dist/components/authenticated-chat/index.d.ts.map +1 -1
- package/dist/components/authenticated-chat/index.js +1 -12
- package/dist/components/authenticated-chat/index.js.map +1 -1
- package/dist/components/chat-view/Chat.d.ts +2 -1
- package/dist/components/chat-view/Chat.d.ts.map +1 -1
- package/dist/components/chat-view/Chat.js +3 -2
- package/dist/components/chat-view/Chat.js.map +1 -1
- package/dist/components/chat-view/MessageItem.d.ts.map +1 -1
- package/dist/components/chat-view/MessageItem.js +4 -2
- package/dist/components/chat-view/MessageItem.js.map +1 -1
- package/dist/components/chat-view/tool-part-rendering.d.ts +1 -0
- package/dist/components/chat-view/tool-part-rendering.d.ts.map +1 -1
- package/dist/components/chat-view/tool-part-rendering.js +8 -1
- package/dist/components/chat-view/tool-part-rendering.js.map +1 -1
- package/dist/components/chip/index.d.ts +1 -0
- package/dist/components/chip/index.d.ts.map +1 -1
- package/dist/components/chip/index.js +2 -1
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/embedded-chat/index.d.ts +1 -1
- package/dist/components/embedded-chat/index.d.ts.map +1 -1
- package/dist/components/embedded-chat/index.js +1 -1
- package/dist/components/embedded-chat/index.js.map +1 -1
- package/dist/components/input/input-date-time.d.ts +6 -0
- package/dist/components/input/input-date-time.d.ts.map +1 -1
- package/dist/components/input/input-date-time.js +2 -1
- package/dist/components/input/input-date-time.js.map +1 -1
- package/dist/components/input/input-date.d.ts +22 -0
- package/dist/components/input/input-date.d.ts.map +1 -1
- package/dist/components/input/input-date.js +28 -14
- package/dist/components/input/input-date.js.map +1 -1
- package/dist/components/input/input-time.d.ts +9 -0
- package/dist/components/input/input-time.d.ts.map +1 -1
- package/dist/components/input/input-time.js +29 -18
- package/dist/components/input/input-time.js.map +1 -1
- package/dist/components/layouts/RouteLayout.d.ts +0 -9
- package/dist/components/layouts/RouteLayout.d.ts.map +1 -1
- package/dist/components/layouts/RouteLayout.js +7 -4
- package/dist/components/layouts/RouteLayout.js.map +1 -1
- package/dist/components/layouts/Sidebar.d.ts +1 -8
- package/dist/components/layouts/Sidebar.d.ts.map +1 -1
- package/dist/components/layouts/Sidebar.js +7 -14
- package/dist/components/layouts/Sidebar.js.map +1 -1
- package/dist/components/plan-limits/PlanLimitsDialog.d.ts +20 -0
- package/dist/components/plan-limits/PlanLimitsDialog.d.ts.map +1 -0
- package/dist/components/plan-limits/PlanLimitsDialog.js +109 -0
- package/dist/components/plan-limits/PlanLimitsDialog.js.map +1 -0
- package/dist/components/plan-limits/index.d.ts +4 -0
- package/dist/components/plan-limits/index.d.ts.map +1 -0
- package/dist/components/plan-limits/index.js +2 -0
- package/dist/components/plan-limits/index.js.map +1 -0
- package/dist/components/plan-limits/plan-limits-client.d.ts +15 -0
- package/dist/components/plan-limits/plan-limits-client.d.ts.map +1 -0
- package/dist/components/plan-limits/plan-limits-client.js +44 -0
- package/dist/components/plan-limits/plan-limits-client.js.map +1 -0
- package/dist/components/plan-limits/plan-limits-model.d.ts +66 -0
- package/dist/components/plan-limits/plan-limits-model.d.ts.map +1 -0
- package/dist/components/plan-limits/plan-limits-model.js +123 -0
- package/dist/components/plan-limits/plan-limits-model.js.map +1 -0
- package/dist/components/plan-limits/plan-limits-save.d.ts +31 -0
- package/dist/components/plan-limits/plan-limits-save.d.ts.map +1 -0
- package/dist/components/plan-limits/plan-limits-save.js +43 -0
- package/dist/components/plan-limits/plan-limits-save.js.map +1 -0
- package/dist/components/planning/PlanLimitsAction.d.ts +6 -0
- package/dist/components/planning/PlanLimitsAction.d.ts.map +1 -0
- package/dist/components/planning/PlanLimitsAction.js +19 -0
- package/dist/components/planning/PlanLimitsAction.js.map +1 -0
- package/dist/components/slider/index.d.ts.map +1 -1
- package/dist/components/slider/index.js +2 -1
- package/dist/components/slider/index.js.map +1 -1
- package/dist/datastore-picker/datastore-picker-rows.d.ts +7 -0
- package/dist/datastore-picker/datastore-picker-rows.d.ts.map +1 -1
- package/dist/datastore-picker/datastore-picker-rows.js +26 -22
- package/dist/datastore-picker/datastore-picker-rows.js.map +1 -1
- package/dist/globals.css +85 -2
- package/dist/hooks/use-action-plans-list.d.ts +3 -0
- package/dist/hooks/use-action-plans-list.d.ts.map +1 -1
- package/dist/hooks/use-action-plans-list.js +8 -9
- package/dist/hooks/use-action-plans-list.js.map +1 -1
- package/dist/hooks/use-activity-feed.d.ts +10 -1
- package/dist/hooks/use-activity-feed.d.ts.map +1 -1
- package/dist/hooks/use-activity-feed.js +9 -11
- package/dist/hooks/use-activity-feed.js.map +1 -1
- package/dist/hooks/use-entity.d.ts +4 -3
- package/dist/hooks/use-entity.d.ts.map +1 -1
- package/dist/hooks/use-entity.js +4 -4
- package/dist/hooks/use-entity.js.map +1 -1
- package/dist/hooks/use-manual-actions.d.ts +1 -1
- package/dist/hooks/use-manual-actions.d.ts.map +1 -1
- package/dist/hooks/use-manual-actions.js +5 -5
- package/dist/hooks/use-manual-actions.js.map +1 -1
- package/dist/hooks/use-unsaved-changes-warning.d.ts +2 -0
- package/dist/hooks/use-unsaved-changes-warning.d.ts.map +1 -0
- package/dist/hooks/use-unsaved-changes-warning.js +13 -0
- package/dist/hooks/use-unsaved-changes-warning.js.map +1 -0
- package/dist/hooks/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth.js +4 -3
- package/dist/hooks/useAuth.js.map +1 -1
- package/dist/hooks/useChatPanelSync.d.ts.map +1 -1
- package/dist/hooks/useChatPanelSync.js +2 -3
- package/dist/hooks/useChatPanelSync.js.map +1 -1
- package/dist/hooks/useDatastoreSelection.d.ts.map +1 -1
- package/dist/hooks/useDatastoreSelection.js +11 -4
- package/dist/hooks/useDatastoreSelection.js.map +1 -1
- package/dist/hooks/useExecuteAction.d.ts +1 -0
- package/dist/hooks/useExecuteAction.d.ts.map +1 -1
- package/dist/hooks/useExecuteAction.js.map +1 -1
- package/dist/hooks/useLoginRedirect.d.ts +6 -0
- package/dist/hooks/useLoginRedirect.d.ts.map +1 -0
- package/dist/hooks/useLoginRedirect.js +51 -0
- package/dist/hooks/useLoginRedirect.js.map +1 -0
- package/dist/hooks/usePlanLimits.d.ts +18 -0
- package/dist/hooks/usePlanLimits.d.ts.map +1 -0
- package/dist/hooks/usePlanLimits.js +56 -0
- package/dist/hooks/usePlanLimits.js.map +1 -0
- package/dist/ldo-ui.d.ts +1 -1
- package/dist/ldo-ui.d.ts.map +1 -1
- package/dist/ldo-ui.js.map +1 -1
- package/dist/lib/app-tools.d.ts +18 -0
- package/dist/lib/app-tools.d.ts.map +1 -0
- package/dist/lib/app-tools.js +42 -0
- package/dist/lib/app-tools.js.map +1 -0
- package/dist/lib/chat-types.d.ts +3 -0
- package/dist/lib/chat-types.d.ts.map +1 -1
- package/dist/lib/chat-types.js.map +1 -1
- package/dist/lib/datastore-route-table.d.ts +3 -0
- package/dist/lib/datastore-route-table.d.ts.map +1 -1
- package/dist/lib/datastore-route-table.js +6 -0
- package/dist/lib/datastore-route-table.js.map +1 -1
- package/dist/lib/graphql-error.d.ts +2 -0
- package/dist/lib/graphql-error.d.ts.map +1 -0
- package/dist/lib/graphql-error.js +7 -0
- package/dist/lib/graphql-error.js.map +1 -0
- package/dist/lib/update-notice.d.ts +2 -1
- package/dist/lib/update-notice.d.ts.map +1 -1
- package/dist/lib/update-notice.js +8 -2
- package/dist/lib/update-notice.js.map +1 -1
- package/dist/providers/ActiveChatProvider.d.ts +2 -0
- package/dist/providers/ActiveChatProvider.d.ts.map +1 -1
- package/dist/providers/ActiveChatProvider.js +6 -3
- package/dist/providers/ActiveChatProvider.js.map +1 -1
- package/dist/providers/ActiveDatastoreProvider.d.ts +12 -0
- package/dist/providers/ActiveDatastoreProvider.d.ts.map +1 -1
- package/dist/providers/ActiveDatastoreProvider.js +114 -11
- package/dist/providers/ActiveDatastoreProvider.js.map +1 -1
- package/dist/providers/AuthContext.d.ts +1 -0
- package/dist/providers/AuthContext.d.ts.map +1 -1
- package/dist/providers/AuthContext.js.map +1 -1
- package/dist/providers/MantaClientProvider.d.ts.map +1 -1
- package/dist/providers/MantaClientProvider.js +3 -3
- package/dist/providers/MantaClientProvider.js.map +1 -1
- package/dist/providers/index.d.ts +3 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +2 -2
- package/dist/providers/index.js.map +1 -1
- package/dist/routes/activity/detail/ActivityDetailRoute.d.ts.map +1 -1
- package/dist/routes/activity/detail/ActivityDetailRoute.js +1 -3
- package/dist/routes/activity/detail/ActivityDetailRoute.js.map +1 -1
- package/dist/routes/activity/index.d.ts.map +1 -1
- package/dist/routes/activity/index.js +1 -3
- package/dist/routes/activity/index.js.map +1 -1
- package/dist/routes/chat/index.d.ts +2 -21
- package/dist/routes/chat/index.d.ts.map +1 -1
- package/dist/routes/chat/index.js +4 -2
- package/dist/routes/chat/index.js.map +1 -1
- package/dist/routes/data-collection/index.d.ts.map +1 -1
- package/dist/routes/data-collection/index.js +1 -3
- package/dist/routes/data-collection/index.js.map +1 -1
- package/dist/routes/data-explorer/components/DataExplorerLayout.d.ts.map +1 -1
- package/dist/routes/data-explorer/components/DataExplorerLayout.js +1 -3
- package/dist/routes/data-explorer/components/DataExplorerLayout.js.map +1 -1
- package/dist/routes/data-explorer/components/class-detail/UsedByRules.js +2 -2
- package/dist/routes/data-explorer/components/class-detail/UsedByRules.js.map +1 -1
- package/dist/routes/datastores/index.d.ts.map +1 -1
- package/dist/routes/datastores/index.js +2 -2
- package/dist/routes/datastores/index.js.map +1 -1
- package/dist/routes/explain/index.d.ts.map +1 -1
- package/dist/routes/explain/index.js +1 -3
- package/dist/routes/explain/index.js.map +1 -1
- package/dist/routes/integrations/components/connect-forms/DashConnectForm.d.ts.map +1 -1
- package/dist/routes/integrations/components/connect-forms/DashConnectForm.js +0 -1
- package/dist/routes/integrations/components/connect-forms/DashConnectForm.js.map +1 -1
- package/dist/routes/integrations/components/connect-forms/GoogleAdsConnectForm.d.ts.map +1 -1
- package/dist/routes/integrations/components/connect-forms/GoogleAdsConnectForm.js +0 -1
- package/dist/routes/integrations/components/connect-forms/GoogleAdsConnectForm.js.map +1 -1
- package/dist/routes/integrations/components/connect-forms/GoogleAnalyticsConnectForm.d.ts.map +1 -1
- package/dist/routes/integrations/components/connect-forms/GoogleAnalyticsConnectForm.js +0 -1
- package/dist/routes/integrations/components/connect-forms/GoogleAnalyticsConnectForm.js.map +1 -1
- package/dist/routes/integrations/components/connect-forms/GoogleMerchantCenterConnectForm.d.ts.map +1 -1
- package/dist/routes/integrations/components/connect-forms/GoogleMerchantCenterConnectForm.js +0 -1
- package/dist/routes/integrations/components/connect-forms/GoogleMerchantCenterConnectForm.js.map +1 -1
- package/dist/routes/integrations/components/connect-forms/InferalCredentialConnectForm.d.ts +0 -1
- package/dist/routes/integrations/components/connect-forms/InferalCredentialConnectForm.d.ts.map +1 -1
- package/dist/routes/integrations/components/connect-forms/InferalCredentialConnectForm.js +3 -2
- package/dist/routes/integrations/components/connect-forms/InferalCredentialConnectForm.js.map +1 -1
- package/dist/routes/integrations/components/connect-forms/KlaviyoConnectForm.d.ts.map +1 -1
- package/dist/routes/integrations/components/connect-forms/KlaviyoConnectForm.js +0 -1
- package/dist/routes/integrations/components/connect-forms/KlaviyoConnectForm.js.map +1 -1
- package/dist/routes/integrations/components/connect-forms/MicrosoftAdsConnectForm.d.ts.map +1 -1
- package/dist/routes/integrations/components/connect-forms/MicrosoftAdsConnectForm.js +0 -1
- package/dist/routes/integrations/components/connect-forms/MicrosoftAdsConnectForm.js.map +1 -1
- package/dist/routes/integrations/components/connect-forms/OAuthSetupConnectForm.d.ts +0 -1
- package/dist/routes/integrations/components/connect-forms/OAuthSetupConnectForm.d.ts.map +1 -1
- package/dist/routes/integrations/components/connect-forms/OAuthSetupConnectForm.js +4 -3
- package/dist/routes/integrations/components/connect-forms/OAuthSetupConnectForm.js.map +1 -1
- package/dist/routes/integrations/components/connect-forms/TriplewhaleConnectForm.d.ts.map +1 -1
- package/dist/routes/integrations/components/connect-forms/TriplewhaleConnectForm.js +0 -1
- package/dist/routes/integrations/components/connect-forms/TriplewhaleConnectForm.js.map +1 -1
- package/dist/routes/integrations/components/connect-forms/WoocommerceConnectForm.d.ts.map +1 -1
- package/dist/routes/integrations/components/connect-forms/WoocommerceConnectForm.js +0 -1
- package/dist/routes/integrations/components/connect-forms/WoocommerceConnectForm.js.map +1 -1
- package/dist/routes/integrations/types.d.ts +2 -1
- package/dist/routes/integrations/types.d.ts.map +1 -1
- package/dist/routes/integrations/types.js +16 -0
- package/dist/routes/integrations/types.js.map +1 -1
- package/dist/routes/memories/components/DateValueInput.d.ts +16 -0
- package/dist/routes/memories/components/DateValueInput.d.ts.map +1 -0
- package/dist/routes/memories/components/DateValueInput.js +35 -0
- package/dist/routes/memories/components/DateValueInput.js.map +1 -0
- package/dist/routes/memories/components/EntityValuePicker.d.ts +11 -0
- package/dist/routes/memories/components/EntityValuePicker.d.ts.map +1 -0
- package/dist/routes/memories/components/EntityValuePicker.js +61 -0
- package/dist/routes/memories/components/EntityValuePicker.js.map +1 -0
- package/dist/routes/memories/components/FieldLabel.d.ts +12 -0
- package/dist/routes/memories/components/FieldLabel.d.ts.map +1 -0
- package/dist/routes/memories/components/FieldLabel.js +12 -0
- package/dist/routes/memories/components/FieldLabel.js.map +1 -0
- package/dist/routes/memories/components/ImportanceSlider.d.ts +2 -0
- package/dist/routes/memories/components/ImportanceSlider.d.ts.map +1 -1
- package/dist/routes/memories/components/ImportanceSlider.js +4 -1
- package/dist/routes/memories/components/ImportanceSlider.js.map +1 -1
- package/dist/routes/memories/components/MemoriesFilters.d.ts +2 -2
- package/dist/routes/memories/components/MemoriesFilters.d.ts.map +1 -1
- package/dist/routes/memories/components/MemoriesFilters.js.map +1 -1
- package/dist/routes/memories/components/MemoriesPanel.d.ts.map +1 -1
- package/dist/routes/memories/components/MemoriesPanel.js +4 -0
- package/dist/routes/memories/components/MemoriesPanel.js.map +1 -1
- package/dist/routes/memories/components/MemoriesTabPanel.d.ts +2 -2
- package/dist/routes/memories/components/MemoriesTabPanel.d.ts.map +1 -1
- package/dist/routes/memories/components/MemoryActions.d.ts +2 -0
- package/dist/routes/memories/components/MemoryActions.d.ts.map +1 -1
- package/dist/routes/memories/components/MemoryActions.js +3 -3
- package/dist/routes/memories/components/MemoryActions.js.map +1 -1
- package/dist/routes/memories/components/MemoryFields.d.ts +15 -3
- package/dist/routes/memories/components/MemoryFields.d.ts.map +1 -1
- package/dist/routes/memories/components/MemoryFields.js +34 -5
- package/dist/routes/memories/components/MemoryFields.js.map +1 -1
- package/dist/routes/memories/components/MemoryFormDialog.d.ts +6 -3
- package/dist/routes/memories/components/MemoryFormDialog.d.ts.map +1 -1
- package/dist/routes/memories/components/MemoryFormDialog.js +105 -59
- package/dist/routes/memories/components/MemoryFormDialog.js.map +1 -1
- package/dist/routes/memories/components/MemoryPropertyFields.d.ts +10 -0
- package/dist/routes/memories/components/MemoryPropertyFields.d.ts.map +1 -0
- package/dist/routes/memories/components/MemoryPropertyFields.js +67 -0
- package/dist/routes/memories/components/MemoryPropertyFields.js.map +1 -0
- package/dist/routes/memories/components/RuleDraftDialog.d.ts +7 -0
- package/dist/routes/memories/components/RuleDraftDialog.d.ts.map +1 -0
- package/dist/routes/memories/components/RuleDraftDialog.js +20 -0
- package/dist/routes/memories/components/RuleDraftDialog.js.map +1 -0
- package/dist/routes/memories/components/SchemasTab.d.ts +17 -2
- package/dist/routes/memories/components/SchemasTab.d.ts.map +1 -1
- package/dist/routes/memories/components/SchemasTab.js +146 -28
- package/dist/routes/memories/components/SchemasTab.js.map +1 -1
- package/dist/routes/memories/components/badges.d.ts +7 -0
- package/dist/routes/memories/components/badges.d.ts.map +1 -1
- package/dist/routes/memories/components/badges.js +11 -3
- package/dist/routes/memories/components/badges.js.map +1 -1
- package/dist/routes/memories/hooks/useMemoryColumns.d.ts +4 -2
- package/dist/routes/memories/hooks/useMemoryColumns.d.ts.map +1 -1
- package/dist/routes/memories/hooks/useMemoryColumns.js +31 -15
- package/dist/routes/memories/hooks/useMemoryColumns.js.map +1 -1
- package/dist/routes/memories/index.d.ts +2 -1
- package/dist/routes/memories/index.d.ts.map +1 -1
- package/dist/routes/memories/index.js +72 -30
- package/dist/routes/memories/index.js.map +1 -1
- package/dist/routes/memories/memory-mutation-input.d.ts.map +1 -1
- package/dist/routes/memories/memory-mutation-input.js +5 -2
- package/dist/routes/memories/memory-mutation-input.js.map +1 -1
- package/dist/routes/memories/memory-property-values.d.ts +13 -0
- package/dist/routes/memories/memory-property-values.d.ts.map +1 -0
- package/dist/routes/memories/memory-property-values.js +40 -0
- package/dist/routes/memories/memory-property-values.js.map +1 -0
- package/dist/routes/memories/schemas/AllowedValuesField.d.ts +14 -0
- package/dist/routes/memories/schemas/AllowedValuesField.d.ts.map +1 -0
- package/dist/routes/memories/schemas/AllowedValuesField.js +64 -0
- package/dist/routes/memories/schemas/AllowedValuesField.js.map +1 -0
- package/dist/routes/memories/schemas/MemorySchemaPage.d.ts +127 -0
- package/dist/routes/memories/schemas/MemorySchemaPage.d.ts.map +1 -0
- package/dist/routes/memories/schemas/MemorySchemaPage.js +285 -0
- package/dist/routes/memories/schemas/MemorySchemaPage.js.map +1 -0
- package/dist/routes/memories/schemas/SchemaChangeReviewDialog.d.ts +20 -0
- package/dist/routes/memories/schemas/SchemaChangeReviewDialog.d.ts.map +1 -0
- package/dist/routes/memories/schemas/SchemaChangeReviewDialog.js +54 -0
- package/dist/routes/memories/schemas/SchemaChangeReviewDialog.js.map +1 -0
- package/dist/routes/memories/schemas/SchemaConfirmDialog.d.ts +15 -0
- package/dist/routes/memories/schemas/SchemaConfirmDialog.d.ts.map +1 -0
- package/dist/routes/memories/schemas/SchemaConfirmDialog.js +8 -0
- package/dist/routes/memories/schemas/SchemaConfirmDialog.js.map +1 -0
- package/dist/routes/memories/schemas/SchemaDetailPage.d.ts +15 -0
- package/dist/routes/memories/schemas/SchemaDetailPage.d.ts.map +1 -0
- package/dist/routes/memories/schemas/SchemaDetailPage.js +74 -0
- package/dist/routes/memories/schemas/SchemaDetailPage.js.map +1 -0
- package/dist/routes/memories/schemas/SchemaEditorForm.d.ts +10 -0
- package/dist/routes/memories/schemas/SchemaEditorForm.d.ts.map +1 -0
- package/dist/routes/memories/schemas/SchemaEditorForm.js +242 -0
- package/dist/routes/memories/schemas/SchemaEditorForm.js.map +1 -0
- package/dist/routes/memories/schemas/SchemaTemplatesDialog.d.ts +13 -0
- package/dist/routes/memories/schemas/SchemaTemplatesDialog.d.ts.map +1 -0
- package/dist/routes/memories/schemas/SchemaTemplatesDialog.js +13 -0
- package/dist/routes/memories/schemas/SchemaTemplatesDialog.js.map +1 -0
- package/dist/routes/memories/schemas/ValueTypeSelect.d.ts +12 -0
- package/dist/routes/memories/schemas/ValueTypeSelect.d.ts.map +1 -0
- package/dist/routes/memories/schemas/ValueTypeSelect.js +10 -0
- package/dist/routes/memories/schemas/ValueTypeSelect.js.map +1 -0
- package/dist/routes/memories/schemas/schema-form.d.ts +72 -0
- package/dist/routes/memories/schemas/schema-form.d.ts.map +1 -0
- package/dist/routes/memories/schemas/schema-form.js +279 -0
- package/dist/routes/memories/schemas/schema-form.js.map +1 -0
- package/dist/routes/memories/schemas/schema-impact.d.ts +13 -0
- package/dist/routes/memories/schemas/schema-impact.d.ts.map +1 -0
- package/dist/routes/memories/schemas/schema-impact.js +40 -0
- package/dist/routes/memories/schemas/schema-impact.js.map +1 -0
- package/dist/routes/memories/schemas/schema-route.d.ts +18 -0
- package/dist/routes/memories/schemas/schema-route.d.ts.map +1 -0
- package/dist/routes/memories/schemas/schema-route.js +21 -0
- package/dist/routes/memories/schemas/schema-route.js.map +1 -0
- package/dist/routes/memories/schemas/schema-rule-context.d.ts +17 -0
- package/dist/routes/memories/schemas/schema-rule-context.d.ts.map +1 -0
- package/dist/routes/memories/schemas/schema-rule-context.js +83 -0
- package/dist/routes/memories/schemas/schema-rule-context.js.map +1 -0
- package/dist/routes/memories/schemas/schema-table.d.ts +11 -0
- package/dist/routes/memories/schemas/schema-table.d.ts.map +1 -0
- package/dist/routes/memories/schemas/schema-table.js +34 -0
- package/dist/routes/memories/schemas/schema-table.js.map +1 -0
- package/dist/routes/memories/schemas/useMemorySchemaMutations.d.ts +32 -0
- package/dist/routes/memories/schemas/useMemorySchemaMutations.d.ts.map +1 -0
- package/dist/routes/memories/schemas/useMemorySchemaMutations.js +31 -0
- package/dist/routes/memories/schemas/useMemorySchemaMutations.js.map +1 -0
- package/dist/routes/memories/schemas/useSchemaChangeReview.d.ts +51 -0
- package/dist/routes/memories/schemas/useSchemaChangeReview.d.ts.map +1 -0
- package/dist/routes/memories/schemas/useSchemaChangeReview.js +175 -0
- package/dist/routes/memories/schemas/useSchemaChangeReview.js.map +1 -0
- package/dist/routes/memories/schemas/useSchemaLifecycle.d.ts +46 -0
- package/dist/routes/memories/schemas/useSchemaLifecycle.d.ts.map +1 -0
- package/dist/routes/memories/schemas/useSchemaLifecycle.js +93 -0
- package/dist/routes/memories/schemas/useSchemaLifecycle.js.map +1 -0
- package/dist/routes/memories/schemas/useSchemasTab.d.ts +18 -0
- package/dist/routes/memories/schemas/useSchemasTab.d.ts.map +1 -0
- package/dist/routes/memories/schemas/useSchemasTab.js +92 -0
- package/dist/routes/memories/schemas/useSchemasTab.js.map +1 -0
- package/dist/routes/plans/index.d.ts.map +1 -1
- package/dist/routes/plans/index.js +2 -2
- package/dist/routes/plans/index.js.map +1 -1
- package/dist/routes/rules/components/CreateRuleChatModal.d.ts +7 -1
- package/dist/routes/rules/components/CreateRuleChatModal.d.ts.map +1 -1
- package/dist/routes/rules/components/CreateRuleChatModal.js +9 -4
- package/dist/routes/rules/components/CreateRuleChatModal.js.map +1 -1
- package/dist/routes/rules/components/RuleValueControls.d.ts.map +1 -1
- package/dist/routes/rules/components/RuleValueControls.js +3 -24
- package/dist/routes/rules/components/RuleValueControls.js.map +1 -1
- package/dist/routes/rules/components/rule-value-input.d.ts +11 -0
- package/dist/routes/rules/components/rule-value-input.d.ts.map +1 -0
- package/dist/routes/rules/components/rule-value-input.js +24 -0
- package/dist/routes/rules/components/rule-value-input.js.map +1 -0
- package/dist/routes/rules/components/rules.utils.d.ts +5 -0
- package/dist/routes/rules/components/rules.utils.d.ts.map +1 -1
- package/dist/routes/rules/components/rules.utils.js +18 -3
- package/dist/routes/rules/components/rules.utils.js.map +1 -1
- package/dist/routes/rules/pages.d.ts +1 -1
- package/dist/routes/rules/pages.d.ts.map +1 -1
- package/dist/routes/rules/pages.js +1 -1
- package/dist/routes/rules/pages.js.map +1 -1
- package/dist/shared/graph-derived-queries.d.ts.map +1 -1
- package/dist/shared/graph-derived-queries.js +4 -1
- package/dist/shared/graph-derived-queries.js.map +1 -1
- package/dist/worker/index.d.ts +22 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +110 -0
- package/dist/worker/index.js.map +1 -0
- package/dist/worker/policy.d.ts +21 -0
- package/dist/worker/policy.d.ts.map +1 -0
- package/dist/worker/policy.js +42 -0
- package/dist/worker/policy.js.map +1 -0
- package/dist/worker/proxy.d.ts +14 -0
- package/dist/worker/proxy.d.ts.map +1 -0
- package/dist/worker/proxy.js +58 -0
- package/dist/worker/proxy.js.map +1 -0
- package/dist/worker/session.d.ts +24 -0
- package/dist/worker/session.d.ts.map +1 -0
- package/dist/worker/session.js +72 -0
- package/dist/worker/session.js.map +1 -0
- package/package.json +52 -7
- package/src/app-subpaths.json +9 -1
- package/src/components/AppErrorBoundary.tsx +14 -11
- package/src/components/app-gate/AppGate.tsx +122 -0
- package/src/components/app-gate/AwaitingDatastoreStatus.tsx +35 -0
- package/src/components/app-gate/EnterDatastoreRoute.tsx +30 -0
- package/src/components/app-gate/ErrorRoute.tsx +43 -0
- package/src/components/app-gate/FailureAlert.tsx +15 -0
- package/src/components/app-gate/NoDatastoreAccess.tsx +26 -0
- package/src/components/app-gate/NotFoundRoute.tsx +20 -0
- package/src/components/app-gate/PendingInvitations.tsx +134 -0
- package/src/components/app-gate/ServiceError.tsx +27 -0
- package/src/components/app-gate/index.ts +2 -0
- package/src/components/app-gate/sdk-route-elements.tsx +46 -0
- package/src/components/app-shell/AppShell.tsx +22 -0
- package/src/components/app-shell/AppShellRoutes.tsx +34 -0
- package/src/components/app-shell/GroupDatastores.tsx +28 -0
- package/src/components/app-shell/GroupRoute.tsx +34 -0
- package/src/components/app-shell/index.ts +2 -0
- package/src/components/authenticated-chat/index.tsx +1 -34
- package/src/components/chat-view/Chat.tsx +9 -3
- package/src/components/chat-view/MessageItem.tsx +10 -2
- package/src/components/chat-view/tool-part-rendering.ts +10 -1
- package/src/components/chip/index.tsx +8 -1
- package/src/components/embedded-chat/index.tsx +2 -1
- package/src/components/input/input-date-time.tsx +10 -3
- package/src/components/input/input-date.tsx +93 -21
- package/src/components/input/input-time.tsx +59 -26
- package/src/components/layouts/RouteLayout.tsx +11 -50
- package/src/components/layouts/Sidebar.tsx +21 -23
- package/src/components/plan-limits/PlanLimitsDialog.tsx +331 -0
- package/src/components/plan-limits/index.tsx +3 -0
- package/src/components/plan-limits/plan-limits-client.ts +71 -0
- package/src/components/plan-limits/plan-limits-model.ts +180 -0
- package/src/components/plan-limits/plan-limits-save.ts +68 -0
- package/src/components/planning/PlanLimitsAction.tsx +44 -0
- package/src/components/slider/index.tsx +2 -1
- package/src/datastore-picker/datastore-picker-rows.ts +36 -20
- package/src/hooks/use-action-plans-list.ts +20 -12
- package/src/hooks/use-activity-feed.ts +30 -14
- package/src/hooks/use-entity.ts +11 -6
- package/src/hooks/use-manual-actions.ts +11 -6
- package/src/hooks/use-unsaved-changes-warning.ts +12 -0
- package/src/hooks/useAuth.ts +5 -3
- package/src/hooks/useChatPanelSync.ts +2 -3
- package/src/hooks/useDatastoreSelection.ts +10 -4
- package/src/hooks/useExecuteAction.ts +2 -0
- package/src/hooks/useLoginRedirect.ts +66 -0
- package/src/hooks/usePlanLimits.ts +97 -0
- package/src/ldo-ui.ts +1 -0
- package/src/lib/app-tools.ts +63 -0
- package/src/lib/chat-types.ts +5 -0
- package/src/lib/datastore-route-table.ts +9 -0
- package/src/lib/graphql-error.ts +7 -0
- package/src/lib/update-notice.ts +12 -2
- package/src/providers/ActiveChatProvider.tsx +8 -3
- package/src/providers/ActiveDatastoreProvider.tsx +179 -9
- package/src/providers/AuthContext.ts +1 -0
- package/src/providers/MantaClientProvider.tsx +8 -3
- package/src/providers/index.tsx +7 -4
- package/src/routes/activity/detail/ActivityDetailRoute.tsx +1 -10
- package/src/routes/activity/index.tsx +1 -10
- package/src/routes/chat/index.tsx +11 -47
- package/src/routes/data-collection/index.tsx +1 -11
- package/src/routes/data-explorer/components/DataExplorerLayout.tsx +1 -11
- package/src/routes/data-explorer/components/class-detail/UsedByRules.tsx +2 -2
- package/src/routes/datastores/index.tsx +3 -9
- package/src/routes/explain/index.tsx +1 -11
- package/src/routes/integrations/components/connect-forms/DashConnectForm.tsx +0 -1
- package/src/routes/integrations/components/connect-forms/GoogleAdsConnectForm.tsx +0 -1
- package/src/routes/integrations/components/connect-forms/GoogleAnalyticsConnectForm.tsx +0 -1
- package/src/routes/integrations/components/connect-forms/GoogleMerchantCenterConnectForm.tsx +0 -1
- package/src/routes/integrations/components/connect-forms/InferalCredentialConnectForm.tsx +5 -3
- package/src/routes/integrations/components/connect-forms/KlaviyoConnectForm.tsx +0 -1
- package/src/routes/integrations/components/connect-forms/MicrosoftAdsConnectForm.tsx +0 -1
- package/src/routes/integrations/components/connect-forms/OAuthSetupConnectForm.tsx +7 -7
- package/src/routes/integrations/components/connect-forms/TriplewhaleConnectForm.tsx +0 -1
- package/src/routes/integrations/components/connect-forms/WoocommerceConnectForm.tsx +0 -1
- package/src/routes/integrations/types.ts +22 -6
- package/src/routes/memories/components/DateValueInput.tsx +72 -0
- package/src/routes/memories/components/EntityValuePicker.tsx +132 -0
- package/src/routes/memories/components/FieldLabel.tsx +49 -0
- package/src/routes/memories/components/ImportanceSlider.tsx +5 -1
- package/src/routes/memories/components/MemoriesFilters.tsx +2 -2
- package/src/routes/memories/components/MemoriesPanel.tsx +7 -3
- package/src/routes/memories/components/MemoriesTabPanel.tsx +2 -2
- package/src/routes/memories/components/MemoryActions.tsx +26 -2
- package/src/routes/memories/components/MemoryFields.tsx +75 -12
- package/src/routes/memories/components/MemoryFormDialog.tsx +305 -199
- package/src/routes/memories/components/MemoryPropertyFields.tsx +288 -0
- package/src/routes/memories/components/RuleDraftDialog.tsx +35 -0
- package/src/routes/memories/components/SchemasTab.tsx +481 -118
- package/src/routes/memories/components/badges.tsx +16 -4
- package/src/routes/memories/hooks/useMemoryColumns.tsx +69 -35
- package/src/routes/memories/index.tsx +125 -51
- package/src/routes/memories/memory-mutation-input.ts +5 -2
- package/src/routes/memories/memory-property-values.ts +83 -0
- package/src/routes/memories/schemas/AllowedValuesField.tsx +188 -0
- package/src/routes/memories/schemas/MemorySchemaPage.tsx +476 -0
- package/src/routes/memories/schemas/SchemaChangeReviewDialog.tsx +290 -0
- package/src/routes/memories/schemas/SchemaConfirmDialog.tsx +62 -0
- package/src/routes/memories/schemas/SchemaDetailPage.tsx +373 -0
- package/src/routes/memories/schemas/SchemaEditorForm.tsx +990 -0
- package/src/routes/memories/schemas/SchemaTemplatesDialog.tsx +81 -0
- package/src/routes/memories/schemas/ValueTypeSelect.tsx +37 -0
- package/src/routes/memories/schemas/schema-form.ts +360 -0
- package/src/routes/memories/schemas/schema-impact.ts +66 -0
- package/src/routes/memories/schemas/schema-route.ts +30 -0
- package/src/routes/memories/schemas/schema-rule-context.ts +103 -0
- package/src/routes/memories/schemas/schema-table.ts +54 -0
- package/src/routes/memories/schemas/useMemorySchemaMutations.ts +49 -0
- package/src/routes/memories/schemas/useSchemaChangeReview.ts +238 -0
- package/src/routes/memories/schemas/useSchemaLifecycle.tsx +151 -0
- package/src/routes/memories/schemas/useSchemasTab.ts +119 -0
- package/src/routes/plans/index.tsx +3 -14
- package/src/routes/rules/components/CreateRuleChatModal.tsx +46 -22
- package/src/routes/rules/components/RuleValueControls.tsx +3 -35
- package/src/routes/rules/components/rule-value-input.ts +34 -0
- package/src/routes/rules/components/rules.utils.ts +25 -3
- package/src/routes/rules/pages.ts +5 -1
- package/src/shared/graph-derived-queries.ts +6 -0
- package/src/themes/manta-dark.css +4 -0
- package/src/worker/index.ts +175 -0
- package/src/worker/policy.ts +62 -0
- package/src/worker/proxy.ts +101 -0
- package/src/worker/session.ts +111 -0
|
@@ -30,16 +30,20 @@ const createRuleChatFormSchema = z.object({
|
|
|
30
30
|
|
|
31
31
|
type CreateRuleChatFormValues = z.infer<typeof createRuleChatFormSchema>;
|
|
32
32
|
|
|
33
|
+
export type CreateRuleChatSubject = { name: string; context: string };
|
|
34
|
+
|
|
33
35
|
export type CreateRuleChatModalProps = {
|
|
34
36
|
open: boolean;
|
|
35
37
|
onOpenChange: (open: boolean) => void;
|
|
36
|
-
onStartFromBlankRule
|
|
38
|
+
onStartFromBlankRule?: () => void;
|
|
39
|
+
subject?: CreateRuleChatSubject;
|
|
40
|
+
onDraftStarted?: () => void;
|
|
37
41
|
model: OperatorAllowedModel;
|
|
38
42
|
ruleSuggestions?: string[];
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
export function CreateRuleChatModal(props: CreateRuleChatModalProps) {
|
|
42
|
-
const { open, onOpenChange, onStartFromBlankRule, model, ruleSuggestions } = props;
|
|
46
|
+
const { open, onOpenChange, onStartFromBlankRule, subject, onDraftStarted, model, ruleSuggestions } = props;
|
|
43
47
|
const { startContextConversation } = useChatManagerConnection();
|
|
44
48
|
const { open: openChat } = useChatPanel();
|
|
45
49
|
const formId = useId();
|
|
@@ -53,11 +57,12 @@ export function CreateRuleChatModal(props: CreateRuleChatModalProps) {
|
|
|
53
57
|
try {
|
|
54
58
|
const conversation = await startContextConversation(
|
|
55
59
|
{ kind: ChatContextKind.RuleCreate, draftIri: generateRuleDraftIri() },
|
|
56
|
-
createUserMessage({ text: values.intent, model }),
|
|
60
|
+
createUserMessage({ text: subject ? `${values.intent}\n\n${subject.context}` : values.intent, model }),
|
|
57
61
|
);
|
|
58
62
|
if (!conversation) return;
|
|
59
63
|
|
|
60
|
-
|
|
64
|
+
if (onDraftStarted) onDraftStarted();
|
|
65
|
+
else openChat();
|
|
61
66
|
form.reset();
|
|
62
67
|
onOpenChange(false);
|
|
63
68
|
} catch (err) {
|
|
@@ -78,14 +83,18 @@ export function CreateRuleChatModal(props: CreateRuleChatModalProps) {
|
|
|
78
83
|
}}
|
|
79
84
|
>
|
|
80
85
|
<DialogHeader>
|
|
81
|
-
<DialogTitle text="Create a rule" />
|
|
86
|
+
<DialogTitle text={subject ? `Write a rule for ${subject.name}` : "Create a rule"} />
|
|
82
87
|
<DialogDescription>Describe it in your words — Manta drafts the rule for your review.</DialogDescription>
|
|
83
88
|
</DialogHeader>
|
|
84
89
|
|
|
85
90
|
<DialogBody className="space-y-4">
|
|
86
91
|
<form id={formId} onSubmit={form.handleSubmit(handleDraft)}>
|
|
87
92
|
<Textarea
|
|
88
|
-
placeholder=
|
|
93
|
+
placeholder={
|
|
94
|
+
subject
|
|
95
|
+
? `e.g. When a company ${subject.name} memory says…, then…`
|
|
96
|
+
: "e.g. Pause underperforming ads when their CTR stays below the account average for a week…"
|
|
97
|
+
}
|
|
89
98
|
className="min-h-32 border rounded border-default-border bg-base-background"
|
|
90
99
|
autoFocus
|
|
91
100
|
{...form.register("intent")}
|
|
@@ -98,26 +107,41 @@ export function CreateRuleChatModal(props: CreateRuleChatModalProps) {
|
|
|
98
107
|
</form>
|
|
99
108
|
|
|
100
109
|
{isPresent(ruleSuggestions) && (
|
|
101
|
-
<
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
<section className="flex flex-col gap-1.5" aria-labelledby={`${formId}-suggestions`}>
|
|
111
|
+
<h3 id={`${formId}-suggestions`} className="typography-small text-muted-foreground">
|
|
112
|
+
Suggestions
|
|
113
|
+
</h3>
|
|
114
|
+
<ul className="flex flex-col">
|
|
115
|
+
{ruleSuggestions.map((suggestion, index) => (
|
|
116
|
+
<li key={`${suggestion}-${index}`}>
|
|
117
|
+
<button
|
|
118
|
+
type="button"
|
|
119
|
+
onClick={() => form.setValue("intent", suggestion, { shouldValidate: true, shouldDirty: true })}
|
|
120
|
+
className="flex w-full cursor-pointer items-start gap-2.5 rounded-md-v4 px-3 py-2 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-active-border/50"
|
|
121
|
+
title={suggestion}
|
|
122
|
+
>
|
|
123
|
+
<span aria-hidden className="mt-[0.45rem] size-1.5 shrink-0 rounded-full bg-muted-foreground" />
|
|
124
|
+
<span className="typography-small text-default-foreground">{suggestion}</span>
|
|
125
|
+
</button>
|
|
126
|
+
</li>
|
|
127
|
+
))}
|
|
128
|
+
</ul>
|
|
129
|
+
</section>
|
|
114
130
|
)}
|
|
115
131
|
</DialogBody>
|
|
116
132
|
|
|
117
133
|
<DialogFooter>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
134
|
+
{onStartFromBlankRule && (
|
|
135
|
+
<Button
|
|
136
|
+
type="button"
|
|
137
|
+
variant="secondary"
|
|
138
|
+
icon={FileCode2}
|
|
139
|
+
className="mr-auto"
|
|
140
|
+
onClick={onStartFromBlankRule}
|
|
141
|
+
>
|
|
142
|
+
Start from blank rule
|
|
143
|
+
</Button>
|
|
144
|
+
)}
|
|
121
145
|
<Button type="button" variant="ghost" disabled={!form.formState.isDirty} onClick={() => form.reset()}>
|
|
122
146
|
Clear
|
|
123
147
|
</Button>
|
|
@@ -1,50 +1,18 @@
|
|
|
1
1
|
import { isPresent } from "@manta-eu/lib/present";
|
|
2
2
|
import type { Awaitable } from "@manta-eu/lib/types";
|
|
3
3
|
import { RotateCcw, Save, SlidersHorizontal } from "lucide-react";
|
|
4
|
-
import { identity } from "ramda";
|
|
5
4
|
import { useEffect, useId, useMemo, useState } from "react";
|
|
6
|
-
import { buildUpdatedRuleText
|
|
5
|
+
import { buildUpdatedRuleText } from "./rule-value-edit";
|
|
6
|
+
import { ruleValueInputDescriptors } from "./rule-value-input";
|
|
7
7
|
import { Button } from "#components/button/index";
|
|
8
8
|
import { Input } from "#components/input/index";
|
|
9
9
|
import {
|
|
10
10
|
type EditableRuleValue,
|
|
11
|
-
type EditableRuleValueKind,
|
|
12
11
|
narrativeSegmentsAroundEdit,
|
|
13
12
|
RuleNarrativeSegments,
|
|
14
13
|
type RuleSetupModel,
|
|
15
14
|
} from "#ldo-ui";
|
|
16
15
|
|
|
17
|
-
type RuleValueInputDescriptor = {
|
|
18
|
-
type: "date" | "datetime-local" | "number";
|
|
19
|
-
step?: string;
|
|
20
|
-
inputMode?: "decimal";
|
|
21
|
-
helperText?: string;
|
|
22
|
-
toInputValue: (value: string) => string;
|
|
23
|
-
fromInputValue: (value: string) => string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const inputDescriptorByKind: Record<EditableRuleValueKind, RuleValueInputDescriptor> = {
|
|
27
|
-
number: {
|
|
28
|
-
type: "number",
|
|
29
|
-
step: "any",
|
|
30
|
-
inputMode: "decimal",
|
|
31
|
-
toInputValue: identity,
|
|
32
|
-
fromInputValue: identity,
|
|
33
|
-
},
|
|
34
|
-
date: {
|
|
35
|
-
type: "date",
|
|
36
|
-
toInputValue: identity,
|
|
37
|
-
fromInputValue: identity,
|
|
38
|
-
},
|
|
39
|
-
dateTime: {
|
|
40
|
-
type: "datetime-local",
|
|
41
|
-
step: "1",
|
|
42
|
-
helperText: "UTC timezone",
|
|
43
|
-
toInputValue: dateTimeValueForInput,
|
|
44
|
-
fromInputValue: dateTimeValueFromInput,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
16
|
export type RuleValueControlsProps = {
|
|
49
17
|
model: RuleSetupModel;
|
|
50
18
|
onStageChange: (newRuleText: string) => Awaitable<boolean>;
|
|
@@ -110,7 +78,7 @@ export function RuleValueControls(props: RuleValueControlsProps) {
|
|
|
110
78
|
{model.editableValues.map(({ edit: editableValue, segments }) => {
|
|
111
79
|
const value = values[editableValue.id] ?? editableValue.value;
|
|
112
80
|
const inputId = `${idPrefix}-${editableValue.id}`;
|
|
113
|
-
const inputDescriptor =
|
|
81
|
+
const inputDescriptor = ruleValueInputDescriptors[editableValue.kind];
|
|
114
82
|
const inputValue = inputDescriptor.toInputValue(value);
|
|
115
83
|
const contextSegments = narrativeSegmentsAroundEdit(segments, editableValue.id);
|
|
116
84
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { identity } from "ramda";
|
|
2
|
+
import { dateTimeValueForInput, dateTimeValueFromInput } from "./rule-value-edit";
|
|
3
|
+
import type { EditableRuleValueKind } from "#ldo-ui";
|
|
4
|
+
|
|
5
|
+
export type RuleValueInputDescriptor = {
|
|
6
|
+
type: "date" | "datetime-local" | "number";
|
|
7
|
+
step?: string;
|
|
8
|
+
inputMode?: "decimal";
|
|
9
|
+
helperText?: string;
|
|
10
|
+
toInputValue: (value: string) => string;
|
|
11
|
+
fromInputValue: (value: string) => string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const ruleValueInputDescriptors: Record<EditableRuleValueKind, RuleValueInputDescriptor> = {
|
|
15
|
+
number: {
|
|
16
|
+
type: "number",
|
|
17
|
+
step: "any",
|
|
18
|
+
inputMode: "decimal",
|
|
19
|
+
toInputValue: identity,
|
|
20
|
+
fromInputValue: identity,
|
|
21
|
+
},
|
|
22
|
+
date: {
|
|
23
|
+
type: "date",
|
|
24
|
+
toInputValue: identity,
|
|
25
|
+
fromInputValue: identity,
|
|
26
|
+
},
|
|
27
|
+
dateTime: {
|
|
28
|
+
type: "datetime-local",
|
|
29
|
+
step: "1",
|
|
30
|
+
helperText: "UTC timezone",
|
|
31
|
+
toInputValue: dateTimeValueForInput,
|
|
32
|
+
fromInputValue: dateTimeValueFromInput,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { GQLRule } from "@manta-eu/client";
|
|
2
2
|
import { humanizeEntityName } from "@manta-eu/client/shared/agent-mode";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
compactUri,
|
|
5
|
+
expandPrefix,
|
|
6
|
+
formatEntityName,
|
|
7
|
+
iriLocalName,
|
|
8
|
+
isValidFullIri,
|
|
9
|
+
} from "@manta-eu/client/shared/rdf-namespaces";
|
|
4
10
|
import { isPresent } from "@manta-eu/lib/present";
|
|
5
11
|
import type { Awaitable } from "@manta-eu/lib/types";
|
|
6
12
|
import { ascend, descend, sortWith } from "ramda";
|
|
@@ -39,15 +45,31 @@ export function sortRulesForDisplay(rules: readonly GQLRule[]): GQLRule[] {
|
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
export function getRuleDisplayName(ruleIri: string): string {
|
|
42
|
-
const localName = formatEntityName(ruleIri);
|
|
48
|
+
const localName = isValidFullIri(compactUri(ruleIri)) ? iriLocalName(ruleIri) : formatEntityName(ruleIri);
|
|
43
49
|
const nameWithoutRulePrefix = localName.replace(/^Rule_/, "").replace(/^Rule(?=[A-Z0-9])/, "");
|
|
44
50
|
return humanizeEntityName(nameWithoutRulePrefix) || localName;
|
|
45
51
|
}
|
|
46
52
|
|
|
53
|
+
const iriSchemePattern = /^[a-z][a-z\d+.-]*:/i;
|
|
54
|
+
|
|
55
|
+
// The local name inside the realm's vocabulary and the whole IRI anywhere else, whatever its scheme. A local name that
|
|
56
|
+
// would itself read as an IRI is routed whole too, so every route reads back to the rule it came from.
|
|
47
57
|
export function getRuleRouteName(ruleIri: string): string {
|
|
48
|
-
|
|
58
|
+
const compacted = compactUri(ruleIri);
|
|
59
|
+
const localName = compacted.startsWith(":") ? compacted.slice(1) : null;
|
|
60
|
+
if (localName === null) return ruleIri;
|
|
61
|
+
return iriSchemePattern.test(localName) ? expandPrefix(compacted) : localName;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Takes the route param as the router gives it, already decoded; decoding again would change an IRI holding an escape.
|
|
65
|
+
export function ruleIriFromRouteName(routeName: string): string {
|
|
66
|
+
return iriSchemePattern.test(routeName) ? routeName : expandPrefix(`:${routeName}`);
|
|
49
67
|
}
|
|
50
68
|
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use `ruleIriFromRouteName` on the route param as the router gives it, already decoded, instead;
|
|
71
|
+
* removed in 1.0.
|
|
72
|
+
*/
|
|
51
73
|
export function decodeRuleRouteName(ruleName: string): string {
|
|
52
74
|
try {
|
|
53
75
|
return decodeURIComponent(ruleName);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// The rule screens the application mounts. The route entry itself stays in `agents`, because the
|
|
2
2
|
// Datalog editor it reaches carries the CodeMirror stack this package does not depend on.
|
|
3
|
-
export {
|
|
3
|
+
export {
|
|
4
|
+
CreateRuleChatModal,
|
|
5
|
+
type CreateRuleChatModalProps,
|
|
6
|
+
type CreateRuleChatSubject,
|
|
7
|
+
} from "./components/CreateRuleChatModal";
|
|
4
8
|
export { RuleDetailsPage, type RuleDetailsPageProps } from "./components/RuleDetailsPage";
|
|
5
9
|
export {
|
|
6
10
|
RulesOverviewHeaderActions,
|
|
@@ -12,7 +12,10 @@ import {
|
|
|
12
12
|
useGetActionPlansSummaryQuery,
|
|
13
13
|
useManualActionProgressQuery,
|
|
14
14
|
useMemoriesQuery,
|
|
15
|
+
useMemorySchemaRuleCountsQuery,
|
|
15
16
|
useMemorySchemasQuery,
|
|
17
|
+
useMemorySchemaTemplatesQuery,
|
|
18
|
+
useMemorySchemaUsageQuery,
|
|
16
19
|
useNodePropertiesQuery,
|
|
17
20
|
useNodeRelationshipsQuery,
|
|
18
21
|
useRulesQuery,
|
|
@@ -39,7 +42,10 @@ export const graphDerivedQueries: QueryWithGetKey[] = [
|
|
|
39
42
|
useGetActionPlansSummaryQuery,
|
|
40
43
|
useManualActionProgressQuery,
|
|
41
44
|
useMemoriesQuery,
|
|
45
|
+
useMemorySchemaRuleCountsQuery,
|
|
42
46
|
useMemorySchemasQuery,
|
|
47
|
+
useMemorySchemaTemplatesQuery,
|
|
48
|
+
useMemorySchemaUsageQuery,
|
|
43
49
|
useNodePropertiesQuery,
|
|
44
50
|
useNodeRelationshipsQuery,
|
|
45
51
|
useRulesQuery,
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { originAllowsRequest } from "@manta-eu/auth/request-origin";
|
|
2
|
+
import { safeReturnTo } from "@manta-eu/auth/sealed-cookies";
|
|
3
|
+
import { operationRootFields } from "@manta-eu/client/operations";
|
|
4
|
+
import {
|
|
5
|
+
authErrorParam,
|
|
6
|
+
chatManagerBasePath,
|
|
7
|
+
mantaGQLPath,
|
|
8
|
+
switchDatastoreRoutePath,
|
|
9
|
+
} from "@manta-eu/client/shared/constants";
|
|
10
|
+
import { isValidDatastoreId } from "@manta-eu/client/shared/datastore-id";
|
|
11
|
+
import {
|
|
12
|
+
datastoreScopedRoutePattern,
|
|
13
|
+
imageRoutePath,
|
|
14
|
+
redirectRoutePath,
|
|
15
|
+
sparqlRoutePath,
|
|
16
|
+
uploadedFileRoutePath,
|
|
17
|
+
uploadPartRoutePath,
|
|
18
|
+
} from "@manta-eu/client/shared/datastore-path";
|
|
19
|
+
import { signedOutLoginStatus } from "@manta-eu/client/shared/login-status";
|
|
20
|
+
import { isPresent } from "@manta-eu/lib/present";
|
|
21
|
+
import { Hono, type Context } from "hono";
|
|
22
|
+
import {
|
|
23
|
+
crossOriginBlockedMessage,
|
|
24
|
+
graphqlAllowed,
|
|
25
|
+
graphqlBlockedMessage,
|
|
26
|
+
graphqlShapeMessage,
|
|
27
|
+
isJsonGraphQLRequest,
|
|
28
|
+
methodAllowed,
|
|
29
|
+
methodBlockedMessage,
|
|
30
|
+
namedOperations,
|
|
31
|
+
type GraphQLAllowlist,
|
|
32
|
+
type ProxyRoute,
|
|
33
|
+
} from "./policy";
|
|
34
|
+
import { proxyToAgents, type ProxyArgs } from "./proxy";
|
|
35
|
+
import { clearSessionSetCookies, isSignedIn, readSession, type SessionCookies } from "./session";
|
|
36
|
+
|
|
37
|
+
export type { GraphQLAllowlist, ProxyRoute } from "./policy";
|
|
38
|
+
|
|
39
|
+
export type AppWorkerEnv = {
|
|
40
|
+
MANTA_AGENTS_URL?: string;
|
|
41
|
+
MANTA_SESSION_SECRET?: string;
|
|
42
|
+
AGENTS?: { fetch: typeof fetch };
|
|
43
|
+
ASSETS?: { fetch: typeof fetch };
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type AppWorkerOptions = {
|
|
47
|
+
cookiePrefix?: string;
|
|
48
|
+
graphqlOperations?: GraphQLAllowlist;
|
|
49
|
+
proxyRoutes?: readonly ProxyRoute[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const scoped = (path: string) => [path, datastoreScopedRoutePattern(path)];
|
|
53
|
+
|
|
54
|
+
const sdkProxyRoutes: readonly ProxyRoute[] = [
|
|
55
|
+
{ path: mantaGQLPath, methods: ["POST"], graphql: true },
|
|
56
|
+
...scoped(sparqlRoutePath).map((path) => ({ path, methods: ["GET", "POST"] })),
|
|
57
|
+
{ path: datastoreScopedRoutePattern(redirectRoutePath), methods: ["GET"] },
|
|
58
|
+
...scoped(imageRoutePath).map((path) => ({ path, methods: ["GET"] })),
|
|
59
|
+
{ path: switchDatastoreRoutePath, methods: ["POST"] },
|
|
60
|
+
...scoped(uploadedFileRoutePath).map((path) => ({ path, methods: ["GET"] })),
|
|
61
|
+
...scoped(uploadPartRoutePath).map((path) => ({ path, methods: ["PUT"] })),
|
|
62
|
+
{ path: `/${chatManagerBasePath}/*`, methods: ["GET", "POST"], websocket: true },
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const unreachableMessage = "Manta could not be reached, so signing in is not possible right now.";
|
|
66
|
+
|
|
67
|
+
export function createAppWorker<E extends AppWorkerEnv>(options: AppWorkerOptions = {}) {
|
|
68
|
+
const { cookiePrefix = "manta_session", graphqlOperations = {}, proxyRoutes = [] } = options;
|
|
69
|
+
|
|
70
|
+
const allowlist = { ...operationRootFields, ...graphqlOperations };
|
|
71
|
+
const app = new Hono<{ Bindings: E }>();
|
|
72
|
+
|
|
73
|
+
type AppContext = Context<{ Bindings: E }>;
|
|
74
|
+
|
|
75
|
+
const sessionCookiesOf = (c: AppContext): SessionCookies => ({
|
|
76
|
+
prefix: cookiePrefix,
|
|
77
|
+
secret: c.env.MANTA_SESSION_SECRET ?? "",
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
app.use("*", async (c, next) => {
|
|
81
|
+
if (!isPresent(c.env.MANTA_AGENTS_URL) || (c.env.MANTA_SESSION_SECRET ?? "").length < 32) {
|
|
82
|
+
return c.json({ error: "Set MANTA_AGENTS_URL, and MANTA_SESSION_SECRET to at least 32 characters." }, 500);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return next();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const proxy = (c: AppContext, extra: Pick<ProxyArgs, "body" | "clearSession" | "session"> = {}) =>
|
|
89
|
+
proxyToAgents({
|
|
90
|
+
request: c.req.raw,
|
|
91
|
+
agentsUrl: c.env.MANTA_AGENTS_URL ?? "",
|
|
92
|
+
agents: c.env.AGENTS,
|
|
93
|
+
cookies: sessionCookiesOf(c),
|
|
94
|
+
...extra,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const signInStep = async (c: AppContext) => {
|
|
98
|
+
try {
|
|
99
|
+
return await proxy(c);
|
|
100
|
+
} catch {
|
|
101
|
+
const target = new URL("/", c.req.url);
|
|
102
|
+
target.searchParams.set(authErrorParam, unreachableMessage);
|
|
103
|
+
|
|
104
|
+
return c.redirect(target.toString());
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
app.get("/login", signInStep);
|
|
109
|
+
app.get("/auth/callback", signInStep);
|
|
110
|
+
|
|
111
|
+
app.on(["GET", "POST"], "/logout", async (c) => {
|
|
112
|
+
if (!originAllowsRequest(c.req.raw)) return c.json({ error: crossOriginBlockedMessage }, 403);
|
|
113
|
+
|
|
114
|
+
const response = await proxy(c, { clearSession: true }).catch(() => undefined);
|
|
115
|
+
|
|
116
|
+
if (isPresent(response) && response.status < 500) return response;
|
|
117
|
+
|
|
118
|
+
const url = new URL(c.req.url);
|
|
119
|
+
const location = safeReturnTo({ raw: url.searchParams.get("redirect"), fallback: "/", appUrl: url });
|
|
120
|
+
|
|
121
|
+
for (const cookie of clearSessionSetCookies(sessionCookiesOf(c), c.req.raw)) {
|
|
122
|
+
c.header("set-cookie", cookie, { append: true });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
c.header("cache-control", "no-store");
|
|
126
|
+
|
|
127
|
+
return c.redirect(location);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
app.get("/api/login", async (c) => {
|
|
131
|
+
if (!originAllowsRequest(c.req.raw)) return c.json({ error: crossOriginBlockedMessage }, 403);
|
|
132
|
+
|
|
133
|
+
const session = await readSession(sessionCookiesOf(c), c.req.raw);
|
|
134
|
+
|
|
135
|
+
if (!isSignedIn(session)) return c.json(signedOutLoginStatus);
|
|
136
|
+
|
|
137
|
+
const response = await proxy(c, { session }).catch(() => undefined);
|
|
138
|
+
|
|
139
|
+
return response ?? c.json({ error: unreachableMessage }, 503);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
for (const route of [...sdkProxyRoutes, ...proxyRoutes]) {
|
|
143
|
+
app.all(route.path, async (c) => {
|
|
144
|
+
const { raw } = c.req;
|
|
145
|
+
|
|
146
|
+
if (!originAllowsRequest(raw)) return c.json({ error: crossOriginBlockedMessage }, 403);
|
|
147
|
+
if (!methodAllowed(route, raw)) return c.json({ error: methodBlockedMessage }, 405);
|
|
148
|
+
|
|
149
|
+
const datastoreId = c.req.param("datastoreId");
|
|
150
|
+
|
|
151
|
+
if (isPresent(datastoreId) && !isValidDatastoreId(datastoreId)) {
|
|
152
|
+
return c.json({ error: "Unknown datastore." }, 404);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const session = await readSession(sessionCookiesOf(c), raw);
|
|
156
|
+
|
|
157
|
+
if (!isSignedIn(session)) return c.json({ error: "Not signed in." }, 401);
|
|
158
|
+
if (!route.graphql) return proxy(c, { session });
|
|
159
|
+
if (!isJsonGraphQLRequest(raw)) return c.json({ errors: [{ message: graphqlShapeMessage }] }, 415);
|
|
160
|
+
|
|
161
|
+
const body = await raw.text();
|
|
162
|
+
const operations = namedOperations(body);
|
|
163
|
+
|
|
164
|
+
if (graphqlAllowed(operations, allowlist)) return proxy(c, { body, session });
|
|
165
|
+
|
|
166
|
+
console.warn("Refused GraphQL operations", JSON.stringify(operations ?? "unparsable"));
|
|
167
|
+
|
|
168
|
+
return c.json({ errors: [{ message: graphqlBlockedMessage }] }, 403);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
app.notFound((c) => c.env.ASSETS?.fetch(c.req.raw) ?? c.text("Not found", 404));
|
|
173
|
+
|
|
174
|
+
return app;
|
|
175
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isWebSocket } from "@manta-eu/auth/request-origin";
|
|
2
|
+
import { isPresent } from "@manta-eu/lib/present";
|
|
3
|
+
import { operationRootFieldsOf, type OperationRootFields } from "@manta-eu/client/shared/operation-root-fields";
|
|
4
|
+
import { parse } from "graphql";
|
|
5
|
+
|
|
6
|
+
export type GraphQLAllowlist = Record<string, readonly string[]>;
|
|
7
|
+
|
|
8
|
+
type NamedOperation = OperationRootFields & { name: string };
|
|
9
|
+
|
|
10
|
+
export type ProxyRoute = {
|
|
11
|
+
path: string;
|
|
12
|
+
methods: readonly string[];
|
|
13
|
+
websocket?: true;
|
|
14
|
+
graphql?: true;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const crossOriginBlockedMessage = "Cross-origin requests to this app's proxy are blocked.";
|
|
18
|
+
export const methodBlockedMessage = "This proxy does not allow that method on this path.";
|
|
19
|
+
export const graphqlShapeMessage = "This proxy only forwards GraphQL as a JSON body, with nothing in the query string.";
|
|
20
|
+
export const graphqlBlockedMessage = "This proxy only forwards the SDK's GraphQL operations and the app's own.";
|
|
21
|
+
|
|
22
|
+
const maxGraphQLTokens = 5_000;
|
|
23
|
+
const maxGraphQLQueryLength = 100_000;
|
|
24
|
+
|
|
25
|
+
export function isJsonGraphQLRequest(request: Request): boolean {
|
|
26
|
+
const mediaType = request.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
|
|
27
|
+
|
|
28
|
+
return mediaType === "application/json" && !isPresent(new URL(request.url).search);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function methodAllowed(route: ProxyRoute, request: Request): boolean {
|
|
32
|
+
return isWebSocket(request) ? route.websocket === true : route.methods.includes(request.method);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function namedOperations(bodyText: string): NamedOperation[] | undefined {
|
|
36
|
+
try {
|
|
37
|
+
const body: unknown = JSON.parse(bodyText);
|
|
38
|
+
|
|
39
|
+
if (typeof body !== "object" || body === null || !("query" in body) || typeof body.query !== "string")
|
|
40
|
+
return undefined;
|
|
41
|
+
|
|
42
|
+
if (body.query.length > maxGraphQLQueryLength) return undefined;
|
|
43
|
+
|
|
44
|
+
const operations = operationRootFieldsOf(parse(body.query, { maxTokens: maxGraphQLTokens }));
|
|
45
|
+
|
|
46
|
+
return operations.every((operation): operation is NamedOperation => isPresent(operation.name))
|
|
47
|
+
? operations
|
|
48
|
+
: undefined;
|
|
49
|
+
} catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function graphqlAllowed(operations: NamedOperation[] | undefined, allowlist: GraphQLAllowlist): boolean {
|
|
55
|
+
if (!isPresent(operations)) return false;
|
|
56
|
+
|
|
57
|
+
return operations.every(({ name, fields }) => {
|
|
58
|
+
const allowed = Object.hasOwn(allowlist, name) ? allowlist[name] : undefined;
|
|
59
|
+
|
|
60
|
+
return isPresent(allowed) && fields.every((field) => allowed.includes(field));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { isWebSocket } from "@manta-eu/auth/request-origin";
|
|
2
|
+
import { forwardedOriginHeader } from "@manta-eu/client/shared/constants";
|
|
3
|
+
import { isPresent } from "@manta-eu/lib/present";
|
|
4
|
+
import { equals } from "ramda";
|
|
5
|
+
import {
|
|
6
|
+
captureUpstreamCookies,
|
|
7
|
+
clearSessionSetCookies,
|
|
8
|
+
readSession,
|
|
9
|
+
sessionSetCookies,
|
|
10
|
+
upstreamCookieHeader,
|
|
11
|
+
type SessionCookies,
|
|
12
|
+
type SessionState,
|
|
13
|
+
} from "./session";
|
|
14
|
+
|
|
15
|
+
export type ProxyArgs = {
|
|
16
|
+
request: Request;
|
|
17
|
+
agentsUrl: string;
|
|
18
|
+
agents?: { fetch: typeof fetch };
|
|
19
|
+
cookies: SessionCookies;
|
|
20
|
+
session?: SessionState;
|
|
21
|
+
body?: string;
|
|
22
|
+
clearSession?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type UpstreamRequestArgs = Pick<ProxyArgs, "request" | "agentsUrl" | "session" | "body">;
|
|
26
|
+
|
|
27
|
+
type CookiesToWriteArgs = Pick<ProxyArgs, "cookies" | "request"> & {
|
|
28
|
+
previous: SessionState;
|
|
29
|
+
after: SessionState;
|
|
30
|
+
clear: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function upstreamRequest(args: UpstreamRequestArgs) {
|
|
34
|
+
const { request, agentsUrl, session, body } = args;
|
|
35
|
+
|
|
36
|
+
const incoming = new URL(request.url);
|
|
37
|
+
const url = new URL(`${agentsUrl.replace(/\/+$/, "")}${incoming.pathname}${incoming.search}`);
|
|
38
|
+
const headers = new Headers(request.headers);
|
|
39
|
+
|
|
40
|
+
for (const name of ["host", "cookie", "authorization", "referer", "sec-fetch-site"]) headers.delete(name);
|
|
41
|
+
|
|
42
|
+
headers.set("origin", url.origin);
|
|
43
|
+
headers.set(forwardedOriginHeader, incoming.origin);
|
|
44
|
+
|
|
45
|
+
if (isPresent(session)) headers.set("cookie", upstreamCookieHeader(session));
|
|
46
|
+
|
|
47
|
+
const sendsBody = !isWebSocket(request) && request.method !== "GET" && request.method !== "HEAD";
|
|
48
|
+
const init: RequestInit & { duplex?: "half" } = {
|
|
49
|
+
method: request.method,
|
|
50
|
+
headers,
|
|
51
|
+
redirect: "manual",
|
|
52
|
+
...(sendsBody && { body: body ?? request.body, duplex: "half" as const }),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return { url, init };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function withAppCookies(response: Response, written: string[]): Response {
|
|
59
|
+
const upgraded = (response as Response & { webSocket?: unknown }).webSocket;
|
|
60
|
+
|
|
61
|
+
if (!isPresent(written) && !isPresent(response.headers.getSetCookie())) return response;
|
|
62
|
+
|
|
63
|
+
const headers = new Headers(response.headers);
|
|
64
|
+
|
|
65
|
+
headers.delete("set-cookie");
|
|
66
|
+
|
|
67
|
+
for (const cookie of written) headers.append("set-cookie", cookie);
|
|
68
|
+
|
|
69
|
+
if (response.status === 101 || isPresent(upgraded)) {
|
|
70
|
+
return new Response(null, { status: response.status, headers, webSocket: upgraded } as ResponseInit);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
headers.delete("content-encoding");
|
|
74
|
+
headers.delete("content-length");
|
|
75
|
+
|
|
76
|
+
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function cookiesToWrite(args: CookiesToWriteArgs) {
|
|
80
|
+
const { cookies, request, previous, after, clear } = args;
|
|
81
|
+
|
|
82
|
+
if (!clear && equals(previous, after)) return [];
|
|
83
|
+
|
|
84
|
+
return clear || !isPresent(after.upstreamCookies)
|
|
85
|
+
? clearSessionSetCookies(cookies, request)
|
|
86
|
+
: sessionSetCookies({ cookies, state: after, request });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export async function proxyToAgents(args: ProxyArgs): Promise<Response> {
|
|
90
|
+
const { request, agentsUrl, agents, cookies, session, body, clearSession = false } = args;
|
|
91
|
+
|
|
92
|
+
const before = session ?? (await readSession(cookies, request));
|
|
93
|
+
const { url, init } = upstreamRequest({ request, agentsUrl, session: before, body });
|
|
94
|
+
|
|
95
|
+
const response = await (agents?.fetch ?? fetch)(url, init);
|
|
96
|
+
|
|
97
|
+
const previous = before ?? { upstreamCookies: {} };
|
|
98
|
+
const after = captureUpstreamCookies({ state: previous, response });
|
|
99
|
+
|
|
100
|
+
return withAppCookies(response, await cookiesToWrite({ cookies, request, previous, after, clear: clearSession }));
|
|
101
|
+
}
|