@jini-ai/admin 0.7.2 → 0.7.3-next.1
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/CHANGELOG.md +4 -6
- package/dist/agent-plugins/agent-plugins.module.d.ts +1 -1
- package/dist/agent-plugins/agent-plugins.module.js +1 -1
- package/dist/agent-plugins/controllers/agent-plugin-files.controller.d.ts +3 -3
- package/dist/agent-plugins/controllers/agent-plugin-files.controller.js +1 -1
- package/dist/agent-plugins/controllers/agent-plugins.controller.d.ts +3 -3
- package/dist/agent-plugins/controllers/agent-plugins.controller.js +30 -27
- package/dist/agent-plugins/index.d.ts +11 -8
- package/dist/agent-plugins/index.js +7 -8
- package/dist/agent-plugins/models.d.ts +19 -11
- package/dist/agent-plugins/ports.d.ts +1 -1
- package/dist/agent-plugins/ports.js +1 -1
- package/dist/agent-plugins/react/components/AgentPluginFileContent.d.ts +4 -2
- package/dist/agent-plugins/react/components/AgentPluginFileContent.js +3 -3
- package/dist/agent-plugins/react/components/AgentPluginFileTree.d.ts +4 -2
- package/dist/agent-plugins/react/components/AgentPluginFileTree.js +2 -2
- package/dist/agent-plugins/react/components/AgentPluginInspector.d.ts +4 -2
- package/dist/agent-plugins/react/components/AgentPluginInspector.js +3 -3
- package/dist/agent-plugins/react/components/AgentPluginListPanel.d.ts +5 -3
- package/dist/agent-plugins/react/components/AgentPluginListPanel.js +3 -3
- package/dist/agent-plugins/react/components/AgentPluginRow.d.ts +3 -1
- package/dist/agent-plugins/react/components/AgentPluginRow.js +3 -3
- package/dist/agent-plugins/react/hooks/AgentPluginInspector.hooks.js +2 -2
- package/dist/agent-plugins/react/hooks/AgentPluginPanel.hooks.d.ts +6 -5
- package/dist/agent-plugins/react/hooks/AgentPluginRow.hooks.d.ts +5 -4
- package/dist/agent-plugins/react/hooks/AgentPluginsPage.hooks.d.ts +11 -7
- package/dist/agent-plugins/react/hooks/AgentPluginsPage.hooks.js +3 -3
- package/dist/agent-plugins/react/hooks/AgentPluginsPorts.hooks.d.ts +5 -0
- package/dist/agent-plugins/react/hooks/AgentPluginsPorts.hooks.js +11 -1
- package/dist/agent-plugins/react/hooks/MarketplaceTab.hooks.d.ts +1 -1
- package/dist/agent-plugins/react/index.d.ts +25 -71
- package/dist/agent-plugins/react/index.js +9 -6
- package/dist/agent-plugins/react/pages/AgentPluginsPage.d.ts +8 -2
- package/dist/agent-plugins/react/pages/AgentPluginsPage.js +3 -3
- package/dist/agent-plugins/react/tabs/DownloadedTab.d.ts +2 -2
- package/dist/agent-plugins/react/tabs/DownloadedTab.js +1 -1
- package/dist/agent-plugins/react/tabs/InstalledTab.d.ts +2 -2
- package/dist/agent-plugins/react/tabs/InstalledTab.js +1 -1
- package/dist/agent-plugins/react/tabs/MarketplaceTab.d.ts +5 -2
- package/dist/agent-plugins/react/tabs/MarketplaceTab.js +3 -3
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/react-root-errors.d.ts +19 -0
- package/dist/browser/react-root-errors.js +16 -0
- package/dist/comments/adapters/http.js +2 -3
- package/dist/comments/adapters/memory.d.ts +5 -3
- package/dist/comments/adapters/memory.js +5 -6
- package/dist/comments/comments.module.d.ts +3 -3
- package/dist/comments/comments.module.js +1 -1
- package/dist/comments/controllers/comment-queue.controller.d.ts +14 -12
- package/dist/comments/controllers/comment-queue.controller.js +154 -155
- package/dist/comments/controllers/comment-settings.controller.d.ts +4 -4
- package/dist/comments/controllers/comment-settings.controller.js +40 -39
- package/dist/comments/controllers/comments.controller.d.ts +4 -4
- package/dist/comments/controllers/comments.controller.js +1 -2
- package/dist/comments/ports.d.ts +3 -3
- package/dist/comments/ports.js +1 -1
- package/dist/comments/react/components/QueueActionsCell.d.ts +20 -0
- package/dist/comments/react/components/QueueActionsCell.js +15 -0
- package/dist/comments/react/components/QueueSection.d.ts +20 -9
- package/dist/comments/react/components/QueueSection.js +9 -20
- package/dist/comments/react/components/SettingsFields.d.ts +13 -0
- package/dist/comments/react/components/SettingsFields.js +17 -0
- package/dist/comments/react/components/SettingsSection.d.ts +4 -1
- package/dist/comments/react/components/SettingsSection.js +5 -10
- package/dist/comments/react/hooks/CommentsPage.hooks.js +1 -1
- package/dist/comments/react/hooks/CommentsPorts.hooks.d.ts +5 -0
- package/dist/comments/react/hooks/CommentsPorts.hooks.js +11 -1
- package/dist/comments/react/hooks/QueueActionsCell.hooks.d.ts +13 -0
- package/dist/comments/react/hooks/QueueActionsCell.hooks.js +7 -0
- package/dist/comments/react/hooks/QueueSection.hooks.d.ts +3 -11
- package/dist/comments/react/hooks/QueueSection.hooks.js +8 -11
- package/dist/comments/react/hooks/use-comment-queue.hooks.js +4 -4
- package/dist/comments/react/hooks/use-comment-settings.hooks.js +3 -3
- package/dist/comments/react/hooks/use-comments.hooks.js +3 -3
- package/dist/comments/react/index.d.ts +27 -89
- package/dist/comments/react/index.js +5 -6
- package/dist/comments/react/pages/CommentsPage.d.ts +4 -1
- package/dist/comments/react/pages/CommentsPage.js +2 -2
- package/dist/comments/rules.d.ts +1 -1
- package/dist/comments/rules.js +2 -3
- package/dist/contracts/credential-management.d.ts +1 -1
- package/dist/contracts/credential-management.js +1 -1
- package/dist/contracts/media-picker.d.ts +1 -1
- package/dist/contracts/media-picker.js +1 -1
- package/dist/contracts/playground-render-target.d.ts +1 -1
- package/dist/contracts/playground-render-target.js +1 -1
- package/dist/core/entities/rules.d.ts +8 -2
- package/dist/core/entities/rules.js +3 -3
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.js +1 -3
- package/dist/core/ledger-slice.d.ts +3 -3
- package/dist/core/ledger-slice.js +3 -3
- package/dist/core/manifest/rules.js +1 -1
- package/dist/core/manifest/types.d.ts +11 -0
- package/dist/core/module/create-admin.d.ts +1 -8
- package/dist/core/module/create-admin.js +4 -9
- package/dist/core/module/index.d.ts +1 -5
- package/dist/core/module/index.js +1 -3
- package/dist/core/ports/auth.d.ts +2 -2
- package/dist/core/ports/auth.js +1 -1
- package/dist/core/ports/comment-repo.d.ts +53 -0
- package/dist/core/ports/comment-repo.js +2 -0
- package/dist/core/ports/comments.d.ts +1 -1
- package/dist/core/ports/comments.js +1 -1
- package/dist/core/ports/database.d.ts +1 -1
- package/dist/core/ports/embed-policy.d.ts +19 -0
- package/dist/core/ports/embed-policy.js +2 -0
- package/dist/core/ports/entities.d.ts +14 -0
- package/dist/core/ports/forms-catalog.d.ts +27 -0
- package/dist/core/ports/forms-catalog.js +2 -0
- package/dist/core/ports/forms.d.ts +3 -3
- package/dist/core/ports/identity.d.ts +1 -1
- package/dist/core/ports/identity.js +1 -1
- package/dist/core/ports/index.d.ts +3 -0
- package/dist/core/ports/media.d.ts +1 -1
- package/dist/core/ports/plugins.d.ts +1 -1
- package/dist/core/react/bind-react.d.ts +6 -16
- package/dist/core/react/bind-react.js +1 -1
- package/dist/core/react/index.d.ts +3 -2
- package/dist/core/react/index.js +3 -2
- package/dist/core/react/module-ui.d.ts +10 -0
- package/dist/core/react/module-ui.js +6 -0
- package/dist/core/react/use-controller.d.ts +1 -1
- package/dist/core/react/use-controller.js +2 -1
- package/dist/core/routing/route-template.d.ts +11 -0
- package/dist/core/routing/route-template.js +23 -0
- package/dist/core/transport/http.js +7 -5
- package/dist/core/transport/index.d.ts +0 -1
- package/dist/core/transport/index.js +0 -1
- package/dist/forms/adapters/http.js +2 -2
- package/dist/forms/adapters/memory.d.ts +1 -1
- package/dist/forms/adapters/memory.js +35 -26
- package/dist/forms/controllers/draft-store.d.ts +4 -4
- package/dist/forms/controllers/draft-store.js +1 -1
- package/dist/forms/controllers/field-attributes-dialog.controller.d.ts +7 -8
- package/dist/forms/controllers/field-attributes-dialog.controller.js +8 -6
- package/dist/forms/controllers/form-editor.controller.d.ts +8 -5
- package/dist/forms/controllers/form-editor.controller.js +2 -2
- package/dist/forms/controllers/form-fields-editor.controller.d.ts +4 -4
- package/dist/forms/controllers/form-submission-detail.controller.d.ts +4 -4
- package/dist/forms/controllers/form-submissions.controller.d.ts +4 -4
- package/dist/forms/controllers/forms-list.controller.d.ts +4 -4
- package/dist/forms/field-settings.d.ts +32 -16
- package/dist/forms/field-settings.js +52 -41
- package/dist/forms/forms.module.d.ts +5 -4
- package/dist/forms/forms.module.js +3 -3
- package/dist/forms/html-rules.d.ts +4 -2
- package/dist/forms/html-rules.js +19 -19
- package/dist/forms/index.d.ts +6 -4
- package/dist/forms/index.js +3 -3
- package/dist/forms/messages.en.js +1 -1
- package/dist/forms/models.d.ts +1 -1
- package/dist/forms/ports.d.ts +8 -4
- package/dist/forms/ports.js +3 -1
- package/dist/forms/react/components/FieldAttributesDialog.d.ts +4 -1
- package/dist/forms/react/components/FieldAttributesDialog.js +6 -28
- package/dist/forms/react/components/FieldAttributesStyling.d.ts +26 -0
- package/dist/forms/react/components/FieldAttributesStyling.js +42 -0
- package/dist/forms/react/components/FieldSettingsRows.js +3 -4
- package/dist/forms/react/components/FieldSettingsSection.d.ts +4 -1
- package/dist/forms/react/components/FieldSettingsSection.js +3 -3
- package/dist/forms/react/components/FormEditorFieldsBody.d.ts +5 -2
- package/dist/forms/react/components/FormEditorFieldsBody.js +3 -3
- package/dist/forms/react/components/FormEditorFieldsBodyParts.js +1 -1
- package/dist/forms/react/components/FormEditorFieldsSlot.d.ts +6 -0
- package/dist/forms/react/components/FormEditorFieldsSlot.js +10 -0
- package/dist/forms/react/components/FormEditorHeader.d.ts +9 -0
- package/dist/forms/react/components/FormEditorHeader.js +16 -0
- package/dist/forms/react/components/FormEditorHeaderText.d.ts +1 -1
- package/dist/forms/react/components/FormEditorHeaderText.js +1 -1
- package/dist/forms/react/components/FormEditorMainPanel.d.ts +1 -1
- package/dist/forms/react/components/FormEditorMainPanel.js +4 -4
- package/dist/forms/react/components/FormEditorTabStrip.d.ts +5 -2
- package/dist/forms/react/components/FormEditorTabStrip.js +3 -4
- package/dist/forms/react/components/FormFieldRow.d.ts +10 -0
- package/dist/forms/react/components/FormFieldRow.js +53 -0
- package/dist/forms/react/components/FormFieldsEditor.d.ts +4 -1
- package/dist/forms/react/components/FormFieldsEditor.js +6 -22
- package/dist/forms/react/components/FormFieldsTableParts.d.ts +10 -0
- package/dist/forms/react/components/FormFieldsTableParts.js +11 -0
- package/dist/forms/react/components/FormSubmissionDate.d.ts +1 -1
- package/dist/forms/react/components/FormSubmissionDate.js +1 -1
- package/dist/forms/react/components/FormSubmissionDetail.d.ts +4 -1
- package/dist/forms/react/components/FormSubmissionDetail.js +3 -3
- package/dist/forms/react/components/FormSubmissions.d.ts +6 -1
- package/dist/forms/react/components/FormSubmissions.js +3 -3
- package/dist/forms/react/components/FormSubmissionsTable.js +1 -1
- package/dist/forms/react/components/FormsListParts.d.ts +36 -0
- package/dist/forms/react/components/FormsListParts.js +41 -0
- package/dist/forms/react/hooks/FormsPorts.hooks.d.ts +7 -1
- package/dist/forms/react/hooks/FormsPorts.hooks.js +11 -1
- package/dist/forms/react/hooks/forms-view.hooks.d.ts +17 -11
- package/dist/forms/react/hooks/forms-view.hooks.js +13 -11
- package/dist/forms/react/hooks/use-field-attributes-dialog.hooks.d.ts +4 -1
- package/dist/forms/react/hooks/use-field-attributes-dialog.hooks.js +6 -4
- package/dist/forms/react/hooks/use-form-editor-parts.hooks.d.ts +127 -0
- package/dist/forms/react/hooks/use-form-editor-parts.hooks.js +223 -0
- package/dist/forms/react/hooks/use-form-editor.hooks.d.ts +13 -3
- package/dist/forms/react/hooks/use-form-editor.hooks.js +34 -210
- package/dist/forms/react/hooks/use-form-fields-editor.hooks.js +2 -2
- package/dist/forms/react/hooks/use-form-submission-detail.hooks.d.ts +2 -2
- package/dist/forms/react/hooks/use-form-submission-detail.hooks.js +4 -4
- package/dist/forms/react/hooks/use-form-submissions.hooks.d.ts +2 -2
- package/dist/forms/react/hooks/use-form-submissions.hooks.js +4 -5
- package/dist/forms/react/hooks/use-forms-list.hooks.js +3 -3
- package/dist/forms/react/index.d.ts +35 -26
- package/dist/forms/react/index.js +5 -6
- package/dist/forms/react/pages/FormEditor.d.ts +2 -2
- package/dist/forms/react/pages/FormEditor.js +7 -12
- package/dist/forms/react/pages/FormsList.d.ts +5 -2
- package/dist/forms/react/pages/FormsList.js +4 -30
- package/dist/forms/rules.d.ts +5 -5
- package/dist/forms/rules.js +8 -20
- package/dist/media/adapters/http.d.ts +24 -2
- package/dist/media/adapters/http.js +133 -10
- package/dist/media/adapters/memory.js +41 -46
- package/dist/media/conformance/media-api.conformance.js +60 -42
- package/dist/media/controllers/edit-media.controller.d.ts +5 -5
- package/dist/media/controllers/edit-media.controller.js +20 -17
- package/dist/media/controllers/library.controller.d.ts +14 -14
- package/dist/media/controllers/library.controller.js +180 -167
- package/dist/media/controllers/providers.controller.d.ts +4 -4
- package/dist/media/controllers/providers.controller.js +46 -40
- package/dist/media/html-attributes.d.ts +23 -13
- package/dist/media/html-attributes.js +15 -23
- package/dist/media/index.d.ts +5 -4
- package/dist/media/index.js +3 -3
- package/dist/media/media.module.d.ts +6 -5
- package/dist/media/media.module.js +3 -3
- package/dist/media/ports.d.ts +8 -3
- package/dist/media/ports.js +4 -1
- package/dist/media/react/components/EditMediaPanel.d.ts +4 -1
- package/dist/media/react/components/EditMediaPanel.js +3 -3
- package/dist/media/react/components/MediaCard.d.ts +7 -2
- package/dist/media/react/components/MediaCard.js +6 -6
- package/dist/media/react/components/MediaDialog.d.ts +4 -1
- package/dist/media/react/components/MediaDialog.js +3 -3
- package/dist/media/react/components/MediaGrid.d.ts +4 -1
- package/dist/media/react/components/MediaGrid.js +2 -2
- package/dist/media/react/components/MediaIcons.d.ts +9 -9
- package/dist/media/react/components/MediaIcons.js +9 -9
- package/dist/media/react/components/MediaLightbox.d.ts +4 -1
- package/dist/media/react/components/MediaLightbox.js +3 -3
- package/dist/media/react/components/MediaPicker.d.ts +4 -1
- package/dist/media/react/components/MediaPicker.js +3 -3
- package/dist/media/react/components/MediaPurgeDialog.d.ts +4 -1
- package/dist/media/react/components/MediaPurgeDialog.js +3 -3
- package/dist/media/react/components/UploadButton.d.ts +4 -1
- package/dist/media/react/components/UploadButton.js +3 -3
- package/dist/media/react/hooks/EditMediaPanel.hooks.d.ts +6 -3
- package/dist/media/react/hooks/EditMediaPanel.hooks.js +62 -50
- package/dist/media/react/hooks/LibraryTab.hooks.d.ts +23 -23
- package/dist/media/react/hooks/LibraryTab.hooks.js +52 -36
- package/dist/media/react/hooks/MediaCard.hooks.d.ts +1 -1
- package/dist/media/react/hooks/MediaCard.hooks.js +2 -1
- package/dist/media/react/hooks/MediaDialog.hooks.d.ts +1 -1
- package/dist/media/react/hooks/MediaPage.hooks.d.ts +22 -18
- package/dist/media/react/hooks/MediaPage.hooks.js +3 -3
- package/dist/media/react/hooks/MediaPicker.hooks.d.ts +1 -1
- package/dist/media/react/hooks/MediaPicker.hooks.js +2 -2
- package/dist/media/react/hooks/MediaPorts.hooks.d.ts +7 -0
- package/dist/media/react/hooks/MediaPorts.hooks.js +11 -1
- package/dist/media/react/hooks/MediaQuery.hooks.d.ts +3 -3
- package/dist/media/react/hooks/MediaQuery.hooks.js +1 -1
- package/dist/media/react/hooks/ProvidersTab.hooks.d.ts +7 -1
- package/dist/media/react/hooks/ProvidersTab.hooks.js +49 -46
- package/dist/media/react/index.d.ts +39 -114
- package/dist/media/react/index.js +55 -48
- package/dist/media/react/pages/MediaPage.d.ts +4 -1
- package/dist/media/react/pages/MediaPage.js +2 -2
- package/dist/media/react/tabs/LibraryTab.d.ts +5 -2
- package/dist/media/react/tabs/LibraryTab.js +3 -3
- package/dist/media/react/tabs/ProvidersTab.d.ts +5 -2
- package/dist/media/react/tabs/ProvidersTab.js +2 -2
- package/dist/media/rules.d.ts +0 -7
- package/dist/media/rules.js +0 -12
- package/dist/playground/controllers/playground.controller.d.ts +3 -3
- package/dist/playground/controllers/playground.controller.js +1 -1
- package/dist/playground/playground.module.d.ts +1 -1
- package/dist/playground/playground.module.js +1 -1
- package/dist/playground/react/components/Canvas.d.ts +5 -2
- package/dist/playground/react/components/Canvas.js +3 -3
- package/dist/playground/react/hooks/Canvas.hooks.d.ts +1 -1
- package/dist/playground/react/hooks/PlaygroundPage.hooks.d.ts +7 -3
- package/dist/playground/react/hooks/PlaygroundPorts.hooks.js +1 -1
- package/dist/playground/react/index.d.ts +9 -9
- package/dist/playground/react/pages/PlaygroundPage.d.ts +8 -2
- package/dist/playground/react/pages/PlaygroundPage.js +3 -3
- package/dist/playground/react/tabs/CanvasTab.d.ts +2 -2
- package/dist/playground/react/tabs/CanvasTab.js +1 -1
- package/dist/react/OverlayHost.d.ts +4 -1
- package/dist/react/OverlayHost.js +2 -2
- package/dist/react/components/ConfirmDialog/ConfirmDialog.d.ts +12 -2
- package/dist/react/components/ConfirmDialog/ConfirmDialog.hooks.js +1 -2
- package/dist/react/components/ConfirmDialog/ConfirmDialog.js +6 -4
- package/dist/react/components/ConfirmDialog/confirm-dialog-attrs.d.ts +1 -1
- package/dist/react/components/ConfirmDialog/confirm-dialog-attrs.js +1 -1
- package/dist/react/components/InteractiveHtmlEditor/InteractiveHtmlEditor.d.ts +2 -2
- package/dist/react/components/InteractiveHtmlEditor/InteractiveHtmlEditor.js +9 -8
- package/dist/react/components/RowMenu/RowMenu.hooks.js +66 -63
- package/dist/react/components/RowMenu/RowMenu.js +1 -1
- package/dist/react/components/Sidebar.d.ts +11 -4
- package/dist/react/components/Sidebar.js +11 -101
- package/dist/react/components/SidebarIcon.d.ts +4 -0
- package/dist/react/components/SidebarIcon.js +91 -0
- package/dist/react/components/ThemePreviewReloadControl.d.ts +7 -0
- package/dist/react/components/ThemePreviewReloadControl.js +5 -0
- package/dist/react/entities/EntityDetail.d.ts +4 -1
- package/dist/react/entities/EntityDetail.hooks.d.ts +14 -0
- package/dist/react/entities/EntityDetail.hooks.js +10 -0
- package/dist/react/entities/EntityDetail.js +3 -6
- package/dist/react/entities/EntityEdit.d.ts +6 -1
- package/dist/react/entities/EntityEdit.js +23 -6
- package/dist/react/entities/EntityField.d.ts +3 -1
- package/dist/react/entities/EntityField.js +9 -6
- package/dist/react/entities/EntityList.d.ts +4 -1
- package/dist/react/entities/EntityList.hooks.d.ts +33 -0
- package/dist/react/entities/EntityList.hooks.js +28 -0
- package/dist/react/entities/EntityList.js +3 -23
- package/dist/react/entities/FailureNotice.d.ts +29 -0
- package/dist/react/entities/FailureNotice.js +33 -0
- package/dist/react/entities/contribution.d.ts +2 -0
- package/dist/react/entities/contribution.js +2 -2
- package/dist/react/entities/rules.d.ts +6 -1
- package/dist/react/entities/rules.js +7 -4
- package/dist/react/entities/types.d.ts +19 -0
- package/dist/react/entities/use-entity-edit.d.ts +11 -2
- package/dist/react/entities/use-entity-edit.js +18 -12
- package/dist/react/entities/use-entity-read.d.ts +7 -2
- package/dist/react/entities/use-entity-read.js +9 -4
- package/dist/react/hooks/use-browser-telemetry-feed.d.ts +13 -0
- package/dist/react/hooks/use-browser-telemetry-feed.js +14 -0
- package/dist/react/hooks/use-overflow-title.d.ts +17 -0
- package/dist/react/hooks/use-overflow-title.js +29 -0
- package/dist/react/hooks/use-process-restart.d.ts +46 -0
- package/dist/react/hooks/use-process-restart.js +59 -0
- package/dist/react/hooks/use-rail-label-titles.d.ts +18 -0
- package/dist/react/hooks/use-rail-label-titles.js +44 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.js +5 -0
- package/dist/react/kit-media-providers.d.ts +187 -0
- package/dist/react/kit-media-providers.js +2 -0
- package/dist/react/kit.d.ts +478 -0
- package/dist/react/kit.js +75 -0
- package/dist/react/overlays.d.ts +4 -4
- package/dist/react/overlays.js +1 -1
- package/dist/react/shell/AdminShell.d.ts +2 -2
- package/dist/react/shell/AdminShell.js +56 -24
- package/dist/react/shell/index.d.ts +1 -1
- package/dist/react/shell/model.d.ts +9 -1
- package/dist/react/shell/model.js +31 -15
- package/dist/react/shell/shell-hooks.d.ts +34 -0
- package/dist/react/shell/shell-hooks.js +31 -0
- package/dist/react/shell/theme-ports.d.ts +1 -1
- package/dist/react/shell/types.d.ts +97 -3
- package/dist/react/shell/use-admin-theme.d.ts +4 -2
- package/dist/react/shell/use-admin-theme.js +4 -3
- package/dist/react/testing-kit-media-providers.d.ts +3 -0
- package/dist/react/testing-kit-media-providers.js +96 -0
- package/dist/react/testing-kit.d.ts +11 -0
- package/dist/react/testing-kit.js +114 -0
- package/dist/redirects/adapters/memory.js +42 -33
- package/dist/redirects/conformance/redirects-api.conformance.js +1 -1
- package/dist/redirects/controllers/hit-count.controller.d.ts +5 -5
- package/dist/redirects/controllers/hit-count.controller.js +1 -1
- package/dist/redirects/controllers/import-redirects.controller.d.ts +5 -5
- package/dist/redirects/controllers/import-redirects.controller.js +1 -1
- package/dist/redirects/controllers/redirects.controller.d.ts +5 -5
- package/dist/redirects/controllers/redirects.controller.js +1 -1
- package/dist/redirects/index.d.ts +11 -7
- package/dist/redirects/index.js +6 -7
- package/dist/redirects/ports.d.ts +2 -2
- package/dist/redirects/ports.js +1 -1
- package/dist/redirects/react/components/CreateRedirectForm.d.ts +17 -0
- package/dist/redirects/react/components/CreateRedirectForm.js +19 -0
- package/dist/redirects/react/components/HitCountCell.js +2 -2
- package/dist/redirects/react/components/ImportRedirectsForm.js +1 -1
- package/dist/redirects/react/hooks/RedirectsPage.hooks.d.ts +1 -1
- package/dist/redirects/react/hooks/RedirectsPorts.hooks.d.ts +5 -0
- package/dist/redirects/react/hooks/RedirectsPorts.hooks.js +11 -1
- package/dist/redirects/react/hooks/use-hit-count-cell.hooks.js +3 -3
- package/dist/redirects/react/hooks/use-import-redirects-form.hooks.js +4 -4
- package/dist/redirects/react/hooks/use-redirects.hooks.d.ts +1 -1
- package/dist/redirects/react/hooks/use-redirects.hooks.js +4 -4
- package/dist/redirects/react/hooks/wired.hooks.d.ts +1 -1
- package/dist/redirects/react/index.d.ts +25 -90
- package/dist/redirects/react/index.js +6 -7
- package/dist/redirects/react/pages/RedirectsPage.d.ts +3 -1
- package/dist/redirects/react/pages/RedirectsPage.js +5 -5
- package/dist/redirects/redirects.module.d.ts +2 -2
- package/dist/redirects/redirects.module.js +1 -1
- package/dist/security/controllers/access-tokens.controller.d.ts +4 -4
- package/dist/security/controllers/access-tokens.controller.js +20 -15
- package/dist/security/controllers/other-credentials.controller.d.ts +4 -4
- package/dist/security/controllers/other-credentials.controller.js +1 -1
- package/dist/security/controllers/root-key.controller.d.ts +4 -4
- package/dist/security/controllers/root-key.controller.js +1 -1
- package/dist/security/ports.d.ts +3 -3
- package/dist/security/ports.js +1 -1
- package/dist/security/react/components/CredentialEditor.d.ts +4 -2
- package/dist/security/react/components/CredentialEditor.js +3 -3
- package/dist/security/react/hooks/AccessTokensTab.hooks.d.ts +5 -5
- package/dist/security/react/hooks/RootKeyTab.hooks.d.ts +1 -1
- package/dist/security/react/hooks/SecurityPage.hooks.d.ts +7 -3
- package/dist/security/react/hooks/SecurityPorts.hooks.js +1 -1
- package/dist/security/react/index.d.ts +22 -22
- package/dist/security/react/pages/SecurityPage.d.ts +8 -2
- package/dist/security/react/pages/SecurityPage.js +3 -3
- package/dist/security/react/tabs/AccessTokensTab.d.ts +5 -2
- package/dist/security/react/tabs/AccessTokensTab.js +3 -3
- package/dist/security/react/tabs/RootKeyTab.d.ts +5 -2
- package/dist/security/react/tabs/RootKeyTab.js +3 -3
- package/dist/security/rules.d.ts +1 -1
- package/dist/security/security.module.d.ts +4 -4
- package/dist/security/security.module.js +1 -1
- package/dist/seo/controllers/entry-picker.controller.d.ts +7 -7
- package/dist/seo/controllers/entry-picker.controller.js +1 -1
- package/dist/seo/controllers/entry-section.controller.d.ts +9 -9
- package/dist/seo/controllers/entry-section.controller.js +1 -1
- package/dist/seo/controllers/media-ref.controller.d.ts +9 -9
- package/dist/seo/controllers/media-ref.controller.js +1 -1
- package/dist/seo/controllers/seo-entry.controller.d.ts +7 -7
- package/dist/seo/controllers/seo-entry.controller.js +1 -1
- package/dist/seo/controllers/seo.controller.d.ts +7 -7
- package/dist/seo/controllers/seo.controller.js +1 -1
- package/dist/seo/controllers/sitemap.controller.d.ts +7 -7
- package/dist/seo/controllers/sitemap.controller.js +2 -2
- package/dist/seo/index.d.ts +4 -2
- package/dist/seo/index.js +2 -2
- package/dist/seo/ports.d.ts +2 -2
- package/dist/seo/ports.js +1 -1
- package/dist/seo/react/components/AnalyzePanel.d.ts +13 -0
- package/dist/seo/react/components/AnalyzePanel.js +21 -0
- package/dist/seo/react/components/EntryPicker.d.ts +19 -0
- package/dist/seo/react/components/EntryPicker.js +25 -0
- package/dist/seo/react/components/MediaPickerBridge.d.ts +4 -1
- package/dist/seo/react/components/MediaPickerBridge.js +2 -2
- package/dist/seo/react/components/MediaRefField.d.ts +5 -2
- package/dist/seo/react/components/MediaRefField.js +5 -5
- package/dist/seo/react/components/SeoEntryFields.d.ts +19 -0
- package/dist/seo/react/components/SeoEntryFields.js +19 -0
- package/dist/seo/react/components/SeoEntryPanel.d.ts +31 -0
- package/dist/seo/react/components/SeoEntryPanel.js +64 -0
- package/dist/seo/react/components/SeoIcons.d.ts +3 -3
- package/dist/seo/react/components/SeoIcons.js +3 -3
- package/dist/seo/react/components/SeoSection.d.ts +27 -0
- package/dist/seo/react/components/SeoSection.js +24 -0
- package/dist/seo/react/components/SitemapModal.d.ts +42 -2
- package/dist/seo/react/components/SitemapModal.js +17 -17
- package/dist/seo/react/hooks/MediaRefField.hooks.js +6 -6
- package/dist/seo/react/hooks/SeoModuleTabs.d.ts +2 -2
- package/dist/seo/react/hooks/SeoModuleTabs.js +3 -1
- package/dist/seo/react/hooks/SeoPage.hooks.d.ts +2 -2
- package/dist/seo/react/hooks/SeoPorts.hooks.d.ts +5 -0
- package/dist/seo/react/hooks/SeoPorts.hooks.js +11 -1
- package/dist/seo/react/hooks/SeoQuery.hooks.d.ts +3 -3
- package/dist/seo/react/hooks/SeoQuery.hooks.js +1 -1
- package/dist/seo/react/hooks/SitemapModal.hooks.js +1 -1
- package/dist/seo/react/hooks/use-entry-picker.hooks.js +1 -1
- package/dist/seo/react/hooks/use-seo-entry-panel.hooks.js +3 -3
- package/dist/seo/react/hooks/use-seo-entry-section.hooks.js +2 -2
- package/dist/seo/react/hooks/use-seo.hooks.js +3 -3
- package/dist/seo/react/hooks/use-share-image-warning.hooks.js +1 -1
- package/dist/seo/react/hooks/use-sitemap-modal.hooks.d.ts +4 -1
- package/dist/seo/react/hooks/use-sitemap-modal.hooks.js +6 -5
- package/dist/seo/react/index.d.ts +28 -21
- package/dist/seo/react/index.js +5 -6
- package/dist/seo/react/pages/SeoPage.d.ts +16 -82
- package/dist/seo/react/pages/SeoPage.js +29 -216
- package/dist/seo/react/tabs/SeoDefaultsSections.d.ts +19 -0
- package/dist/seo/react/tabs/SeoDefaultsSections.js +48 -0
- package/dist/seo/react/tabs/SeoDefaultsTab.d.ts +24 -0
- package/dist/seo/react/tabs/SeoDefaultsTab.js +30 -0
- package/dist/seo/react/tabs/SeoSitemapTab.d.ts +24 -0
- package/dist/seo/react/tabs/SeoSitemapTab.js +38 -0
- package/dist/seo/rules.d.ts +3 -3
- package/dist/seo/rules.js +6 -6
- package/dist/seo/seo.module.d.ts +3 -3
- package/dist/seo/seo.module.js +1 -1
- package/dist/source-control/controllers/source-control.controller.d.ts +3 -3
- package/dist/source-control/controllers/source-control.controller.js +1 -1
- package/dist/source-control/ports.d.ts +1 -1
- package/dist/source-control/ports.js +1 -1
- package/dist/source-control/react/components/SourceControlCredentialFields.d.ts +4 -2
- package/dist/source-control/react/components/SourceControlCredentialFields.js +3 -3
- package/dist/source-control/react/components/SourceControlProviderRow.d.ts +1 -1
- package/dist/source-control/react/components/SourceControlProviderRow.js +2 -2
- package/dist/source-control/react/hooks/ProvidersTab.hooks.d.ts +1 -1
- package/dist/source-control/react/hooks/ProvidersTab.hooks.js +2 -2
- package/dist/source-control/react/hooks/SourceControlPage.hooks.d.ts +7 -3
- package/dist/source-control/react/hooks/SourceControlPorts.hooks.d.ts +5 -0
- package/dist/source-control/react/hooks/SourceControlPorts.hooks.js +11 -1
- package/dist/source-control/react/index.d.ts +25 -50
- package/dist/source-control/react/index.js +9 -6
- package/dist/source-control/react/pages/SourceControlPage.d.ts +8 -2
- package/dist/source-control/react/pages/SourceControlPage.js +3 -3
- package/dist/source-control/react/tabs/ProvidersTab.d.ts +5 -2
- package/dist/source-control/react/tabs/ProvidersTab.js +3 -3
- package/dist/source-control/source-control.module.d.ts +2 -2
- package/dist/source-control/source-control.module.js +1 -1
- package/dist/widgets/adapters/http.js +2 -2
- package/dist/widgets/adapters/memory.js +26 -20
- package/dist/widgets/controllers/instance-editor.controller.d.ts +3 -3
- package/dist/widgets/controllers/instance-editor.controller.js +48 -38
- package/dist/widgets/controllers/library.controller.d.ts +3 -3
- package/dist/widgets/controllers/library.controller.js +1 -2
- package/dist/widgets/controllers/region-editor.controller.d.ts +3 -3
- package/dist/widgets/controllers/region-editor.controller.js +5 -5
- package/dist/widgets/controllers/regions.controller.d.ts +3 -3
- package/dist/widgets/controllers/regions.controller.js +1 -2
- package/dist/widgets/index.d.ts +2 -1
- package/dist/widgets/index.js +1 -1
- package/dist/widgets/messages.en.js +1 -1
- package/dist/widgets/ports.d.ts +3 -3
- package/dist/widgets/ports.js +1 -1
- package/dist/widgets/react/components/RegionPlacementRow.d.ts +14 -0
- package/dist/widgets/react/components/RegionPlacementRow.js +8 -0
- package/dist/widgets/react/components/TrashWidgetDialog.d.ts +11 -0
- package/dist/widgets/react/components/TrashWidgetDialog.js +8 -0
- package/dist/widgets/react/components/WidgetInstanceNotices.js +1 -1
- package/dist/widgets/react/components/WidgetPageHeaders.d.ts +42 -0
- package/dist/widgets/react/components/WidgetPageHeaders.js +54 -0
- package/dist/widgets/react/components/WidgetRegionEditorHeaderActions.js +1 -1
- package/dist/widgets/react/components/WidgetTableColumns.d.ts +12 -0
- package/dist/widgets/react/components/WidgetTableColumns.js +47 -0
- package/dist/widgets/react/hooks/WidgetsPorts.hooks.d.ts +12 -7
- package/dist/widgets/react/hooks/WidgetsPorts.hooks.js +11 -0
- package/dist/widgets/react/hooks/WidgetsQuery.hooks.d.ts +2 -2
- package/dist/widgets/react/hooks/WidgetsQuery.hooks.js +1 -1
- package/dist/widgets/react/hooks/page-views.hooks.d.ts +1 -1
- package/dist/widgets/react/hooks/page-views.hooks.js +1 -1
- package/dist/widgets/react/hooks/use-widget-instance-editor.hooks.d.ts +2 -2
- package/dist/widgets/react/hooks/use-widget-instance-editor.hooks.js +3 -3
- package/dist/widgets/react/hooks/use-widget-region-editor.hooks.d.ts +1 -1
- package/dist/widgets/react/hooks/use-widget-region-editor.hooks.js +2 -2
- package/dist/widgets/react/hooks/use-widget-regions.hooks.d.ts +3 -1
- package/dist/widgets/react/hooks/use-widget-regions.hooks.js +7 -6
- package/dist/widgets/react/hooks/use-widgets-library.hooks.d.ts +4 -2
- package/dist/widgets/react/hooks/use-widgets-library.hooks.js +7 -6
- package/dist/widgets/react/index.d.ts +41 -34
- package/dist/widgets/react/index.js +5 -6
- package/dist/widgets/react/pages/WidgetInstanceEditor.d.ts +5 -1
- package/dist/widgets/react/pages/WidgetInstanceEditor.js +7 -9
- package/dist/widgets/react/pages/WidgetRegionEditor.d.ts +5 -1
- package/dist/widgets/react/pages/WidgetRegionEditor.js +8 -10
- package/dist/widgets/react/pages/WidgetRegions.d.ts +5 -1
- package/dist/widgets/react/pages/WidgetRegions.js +6 -8
- package/dist/widgets/react/pages/WidgetsLibrary.d.ts +5 -1
- package/dist/widgets/react/pages/WidgetsLibrary.js +8 -45
- package/dist/widgets/rules.d.ts +5 -3
- package/dist/widgets/rules.js +4 -9
- package/dist/widgets/widgets.module.d.ts +3 -3
- package/dist/widgets/widgets.module.js +1 -1
- package/package.json +23 -57
- package/dist/consent/react/ConsentFields.d.ts +0 -39
- package/dist/consent/react/ConsentFields.js +0 -87
- package/dist/consent/react/ConsentPreviewFrame.d.ts +0 -14
- package/dist/consent/react/ConsentPreviewFrame.js +0 -14
- package/dist/consent/react/ConsentSettingsPanel.d.ts +0 -54
- package/dist/consent/react/ConsentSettingsPanel.js +0 -13
- package/dist/consent/react/index.d.ts +0 -8
- package/dist/consent/react/index.js +0 -4
- package/dist/consent/react/settings-panel.hooks.d.ts +0 -49
- package/dist/consent/react/settings-panel.hooks.js +0 -57
- package/dist/core/module/controller-store.d.ts +0 -22
- package/dist/core/module/controller-store.js +0 -32
- package/dist/core/module/define-admin-module.d.ts +0 -4
- package/dist/core/module/define-admin-module.js +0 -5
- package/dist/core/module/token.d.ts +0 -19
- package/dist/core/module/token.js +0 -4
- package/dist/core/module/types.d.ts +0 -79
- package/dist/core/module/types.js +0 -2
- package/dist/core/permissions/rules.d.ts +0 -35
- package/dist/core/permissions/rules.js +0 -34
- package/dist/core/transport/errors.d.ts +0 -62
- package/dist/core/transport/errors.js +0 -63
- package/dist/core/transport/query-suffix.d.ts +0 -3
- package/dist/core/transport/query-suffix.js +0 -5
- package/dist/media/styles.d.ts +0 -4
- package/dist/media/styles.js +0 -5
- package/dist/react/bind-react.d.ts +0 -2
- package/dist/react/bind-react.js +0 -3
- package/dist/react/use-controller.d.ts +0 -2
- package/dist/react/use-controller.js +0 -3
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import { createControllerStore } from '
|
|
1
|
+
import { createControllerStore, describeApiError } from '@jini-ai/core/admin-runtime';
|
|
2
2
|
import { diffMediaMetadata, canReplaceMedia } from '../rules.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// from even as the live list advances underneath it. Never diff against a drifting item.
|
|
6
|
-
let baseline = Object.freeze({ ...item });
|
|
7
|
-
const store = createControllerStore({
|
|
8
|
-
initial: {
|
|
9
|
-
draft: metadataDraft({ item }),
|
|
10
|
-
saving: false,
|
|
11
|
-
error: null,
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
async function perform(run) {
|
|
3
|
+
function createMediaSavePerformer(store, accept) {
|
|
4
|
+
return async function perform(run) {
|
|
15
5
|
if (store.signal.aborted || store.getSnapshot().saving)
|
|
16
6
|
return false;
|
|
17
7
|
store.set({ patch: { saving: true, error: null } });
|
|
@@ -19,17 +9,17 @@ export function createEditMediaController({ api, item }, _optional = {}) {
|
|
|
19
9
|
const saved = await run();
|
|
20
10
|
if (store.signal.aborted)
|
|
21
11
|
return false;
|
|
22
|
-
|
|
12
|
+
accept(saved);
|
|
23
13
|
store.set({
|
|
24
14
|
patch: {
|
|
25
|
-
draft: metadataDraft({ item:
|
|
15
|
+
draft: metadataDraft({ item: saved }),
|
|
26
16
|
},
|
|
27
17
|
});
|
|
28
18
|
return true;
|
|
29
19
|
}
|
|
30
20
|
catch (error) {
|
|
31
21
|
store.set({
|
|
32
|
-
patch: { error:
|
|
22
|
+
patch: { error: describeApiError({ e: error, fallback: 'Failed to save media metadata' }) },
|
|
33
23
|
});
|
|
34
24
|
}
|
|
35
25
|
finally {
|
|
@@ -37,7 +27,20 @@ export function createEditMediaController({ api, item }, _optional = {}) {
|
|
|
37
27
|
}
|
|
38
28
|
// Reached only through the catch above: the failure is already recorded in `error`.
|
|
39
29
|
return false;
|
|
40
|
-
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function createEditMediaController({ api, item }, _optional = {}) {
|
|
33
|
+
// Frozen at mount, exactly like draft's initializer — stays the value draft was seeded
|
|
34
|
+
// from even as the live list advances underneath it. Never diff against a drifting item.
|
|
35
|
+
let baseline = Object.freeze({ ...item });
|
|
36
|
+
const store = createControllerStore({
|
|
37
|
+
initial: {
|
|
38
|
+
draft: metadataDraft({ item }),
|
|
39
|
+
saving: false,
|
|
40
|
+
error: null,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const perform = createMediaSavePerformer(store, saved => { baseline = saved; });
|
|
41
44
|
return {
|
|
42
45
|
getSnapshot: store.getSnapshot,
|
|
43
46
|
subscribe: store.subscribe,
|
|
@@ -17,35 +17,35 @@ export declare function createLibraryController({ api }: {
|
|
|
17
17
|
}, { query }?: {
|
|
18
18
|
query?: MediaQuery;
|
|
19
19
|
}): {
|
|
20
|
-
getSnapshot: () =>
|
|
21
|
-
subscribe: (
|
|
20
|
+
getSnapshot: (required?: Record<string, never>, optional?: Record<string, never>) => LibraryState;
|
|
21
|
+
subscribe: (required: {
|
|
22
22
|
listener: () => void;
|
|
23
|
-
}) => () => void;
|
|
23
|
+
}, optional?: Record<string, never>) => () => void;
|
|
24
24
|
load: (_required?: Record<string, never>, _optional?: Record<string, never>) => Promise<void>;
|
|
25
|
-
settleLibrary: (
|
|
25
|
+
settleLibrary: (args: {
|
|
26
26
|
all?: readonly MediaAsset[];
|
|
27
27
|
error?: Error | null;
|
|
28
28
|
}, _optional?: Record<string, never>) => void;
|
|
29
|
-
setQuery(
|
|
29
|
+
setQuery: (args: {
|
|
30
30
|
query: MediaQuery;
|
|
31
|
-
}, _optional?: Record<string, never>)
|
|
32
|
-
upload({ input, alt }: {
|
|
31
|
+
}, _optional?: Record<string, never>) => Promise<void>;
|
|
32
|
+
upload: ({ input, alt }: {
|
|
33
33
|
input: UploadInput;
|
|
34
34
|
alt?: string;
|
|
35
|
-
}, _optional?: Record<string, never>)
|
|
36
|
-
trash({ id }: {
|
|
35
|
+
}, _optional?: Record<string, never>) => Promise<boolean>;
|
|
36
|
+
trash: ({ id }: {
|
|
37
37
|
id: string;
|
|
38
|
-
}, _optional?: Record<string, never>)
|
|
39
|
-
restore(
|
|
38
|
+
}, _optional?: Record<string, never>) => Promise<boolean>;
|
|
39
|
+
restore: (args: {
|
|
40
40
|
id: string;
|
|
41
|
-
}, _optional?: Record<string, never>)
|
|
41
|
+
}, _optional?: Record<string, never>) => Promise<boolean>;
|
|
42
42
|
requestPurge({ item }: {
|
|
43
43
|
item: MediaAsset;
|
|
44
44
|
}, _optional?: Record<string, never>): void;
|
|
45
45
|
cancelPurge(_required?: Record<string, never>, _optional?: Record<string, never>): void;
|
|
46
|
-
confirmPurge(
|
|
46
|
+
confirmPurge: (args: {
|
|
47
47
|
confirmed: boolean;
|
|
48
|
-
}, _optional?: Record<string, never>)
|
|
48
|
+
}, _optional?: Record<string, never>) => Promise<boolean>;
|
|
49
49
|
dispose(_required?: Record<string, never>, _optional?: Record<string, never>): void;
|
|
50
50
|
};
|
|
51
51
|
//# sourceMappingURL=library.controller.d.ts.map
|
|
@@ -1,5 +1,170 @@
|
|
|
1
|
-
import { createControllerStore } from '
|
|
1
|
+
import { createControllerStore, describeApiError } from '@jini-ai/core/admin-runtime';
|
|
2
2
|
import { queryMedia, countMediaTabs, canRestoreMedia, isRetryableMediaError } from '../rules.js';
|
|
3
|
+
function cancelRetry({ ctx }) {
|
|
4
|
+
if (ctx.retryTimer !== null)
|
|
5
|
+
clearTimeout(ctx.retryTimer);
|
|
6
|
+
ctx.retryTimer = null;
|
|
7
|
+
}
|
|
8
|
+
/** Store patch for an accepted full library: filtered rows plus whole-library tab counts.
|
|
9
|
+
* @complexity O(n) in the library size. */
|
|
10
|
+
function libraryView({ ctx, media }) {
|
|
11
|
+
return { items: queryMedia({ media, query: ctx.store.getSnapshot().query }), counts: countMediaTabs({ media }) };
|
|
12
|
+
}
|
|
13
|
+
/** Commits a read that is still the latest one; items are frozen so consumers cannot mutate rows. */
|
|
14
|
+
function acceptRead({ ctx, all }) {
|
|
15
|
+
ctx.readFailed = false;
|
|
16
|
+
ctx.retryAttempt = 0;
|
|
17
|
+
ctx.library = all;
|
|
18
|
+
const { items, counts } = libraryView({ ctx, media: all });
|
|
19
|
+
ctx.store.set({
|
|
20
|
+
patch: {
|
|
21
|
+
items: Object.freeze(items.map((item) => Object.freeze({ ...item }))),
|
|
22
|
+
counts,
|
|
23
|
+
hasUntyped: all.some((item) => item.contentType === null),
|
|
24
|
+
error: null,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Publishes the latest read's failure and, when the failure is transient, schedules a retry. */
|
|
29
|
+
function failRead({ ctx, error }) {
|
|
30
|
+
ctx.readFailed = true;
|
|
31
|
+
ctx.store.set({
|
|
32
|
+
patch: { loading: false, error: describeApiError({ e: error, fallback: 'Failed to load media' }) },
|
|
33
|
+
});
|
|
34
|
+
// Retry reads only, never destructive writes. Keep trying at a capped delay so
|
|
35
|
+
// recovery needs no manual repair, while an offline service isn't hammered.
|
|
36
|
+
if (isRetryableMediaError({ error })) {
|
|
37
|
+
const delay = Math.min(1000 * 2 ** Math.min(ctx.retryAttempt, 5), 30000);
|
|
38
|
+
ctx.retryAttempt += 1;
|
|
39
|
+
ctx.retryTimer = setTimeout(() => { ctx.retryTimer = null; void load({ ctx }); }, delay);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function load({ ctx }) {
|
|
43
|
+
const { store } = ctx;
|
|
44
|
+
if (store.signal.aborted)
|
|
45
|
+
return;
|
|
46
|
+
cancelRetry({ ctx });
|
|
47
|
+
ctx.readAbort?.abort();
|
|
48
|
+
const abort = new AbortController();
|
|
49
|
+
ctx.readAbort = abort;
|
|
50
|
+
ctx.generation += 1;
|
|
51
|
+
const ticket = ctx.generation;
|
|
52
|
+
store.set({ patch: { loading: true, error: null } });
|
|
53
|
+
try {
|
|
54
|
+
const all = await ctx.api.list({}, { signal: abort.signal });
|
|
55
|
+
if (ticket === ctx.generation)
|
|
56
|
+
acceptRead({ ctx, all });
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
// A later background failure must not blank an already-rendered screen.
|
|
60
|
+
if (!abort.signal.aborted && ticket === ctx.generation)
|
|
61
|
+
failRead({ ctx, error });
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
if (ticket === ctx.generation)
|
|
65
|
+
store.set({ patch: { loading: false } });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// A reactive cache observer may refresh this library without calling load again. Keep
|
|
69
|
+
// filtering/counts in the headless domain; accepting cache data must spend no extra read.
|
|
70
|
+
function settleLibrary({ ctx, all, error }) {
|
|
71
|
+
if (ctx.store.signal.aborted)
|
|
72
|
+
return;
|
|
73
|
+
if (all) {
|
|
74
|
+
ctx.library = all;
|
|
75
|
+
ctx.store.set({ patch: { ...libraryView({ ctx, media: all }), hasUntyped: all.some(item => item.contentType === null), error: null } });
|
|
76
|
+
}
|
|
77
|
+
if (error)
|
|
78
|
+
ctx.store.set({ patch: { error: describeApiError({ e: error, fallback: 'Failed to load media' }) } });
|
|
79
|
+
}
|
|
80
|
+
/** True when a write for this id (or an exclusive write) must be refused. */
|
|
81
|
+
function writeBlocked({ ctx, id }) {
|
|
82
|
+
const snapshot = ctx.store.getSnapshot();
|
|
83
|
+
if (ctx.store.signal.aborted || ctx.exclusiveWrite)
|
|
84
|
+
return true;
|
|
85
|
+
return id === undefined ? snapshot.busy : snapshot.pendingIds.includes(id);
|
|
86
|
+
}
|
|
87
|
+
/** Runs one accepted write, then reloads; resolves true only when it saved and the store is live. */
|
|
88
|
+
async function runWrite({ ctx, run, id }) {
|
|
89
|
+
const { store } = ctx;
|
|
90
|
+
if (store.signal.aborted)
|
|
91
|
+
return false;
|
|
92
|
+
// Starting a write clears other writes' failures, so a stale failure from one must
|
|
93
|
+
// not survive past the start of an unrelated one.
|
|
94
|
+
ctx.generation++;
|
|
95
|
+
ctx.readAbort?.abort();
|
|
96
|
+
cancelRetry({ ctx });
|
|
97
|
+
store.set({ patch: { loading: false, error: null } });
|
|
98
|
+
// A single exit: a write disposed mid-flight or a failed write reports false.
|
|
99
|
+
let saved = false;
|
|
100
|
+
try {
|
|
101
|
+
await run();
|
|
102
|
+
if (!store.signal.aborted) {
|
|
103
|
+
await load({ ctx });
|
|
104
|
+
saved = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
// The store ignores patches once disposed, so a write failing after dispose publishes nothing.
|
|
109
|
+
store.set({ patch: { loading: false, error: describeApiError({ e: error, fallback: 'Media write failed' }) } });
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
if (id === undefined)
|
|
113
|
+
ctx.exclusiveWrite = false;
|
|
114
|
+
const pendingIds = store.getSnapshot().pendingIds.filter(value => value !== id);
|
|
115
|
+
store.set({ patch: { busy: pendingIds.length > 0, pendingIds } });
|
|
116
|
+
}
|
|
117
|
+
return saved;
|
|
118
|
+
}
|
|
119
|
+
function write({ ctx, run, id }) {
|
|
120
|
+
const { store } = ctx;
|
|
121
|
+
if (writeBlocked({ ctx, id }))
|
|
122
|
+
return Promise.resolve(false);
|
|
123
|
+
if (id === undefined)
|
|
124
|
+
ctx.exclusiveWrite = true;
|
|
125
|
+
// Serialize accepted writes rather than dropping another card's click. Reserve
|
|
126
|
+
// each id immediately so a double click on the same asset cannot enqueue twice.
|
|
127
|
+
const reserved = store.getSnapshot().pendingIds;
|
|
128
|
+
store.set({ patch: { busy: true, pendingIds: id === undefined ? reserved : [...reserved, id] } });
|
|
129
|
+
const operation = ctx.writes.then(() => runWrite({ ctx, run, id }));
|
|
130
|
+
ctx.writes = operation.catch(() => undefined);
|
|
131
|
+
return operation;
|
|
132
|
+
}
|
|
133
|
+
async function confirmPurge({ ctx, confirmed }) {
|
|
134
|
+
const { store, api } = ctx;
|
|
135
|
+
const item = store.getSnapshot().pendingPurge;
|
|
136
|
+
if (!confirmed || !item)
|
|
137
|
+
return false;
|
|
138
|
+
const saved = await write({ ctx, run: async () => {
|
|
139
|
+
const result = await api.delete({ id: item.id }, { signal: store.signal });
|
|
140
|
+
if (!result.purged)
|
|
141
|
+
throw new Error('The file was not permanently deleted');
|
|
142
|
+
// A failed follow-up read must not leave a permanently deleted card focusable.
|
|
143
|
+
if (ctx.library) {
|
|
144
|
+
ctx.library = ctx.library.filter(row => row.id !== item.id);
|
|
145
|
+
store.set({ patch: libraryView({ ctx, media: ctx.library }) });
|
|
146
|
+
}
|
|
147
|
+
} });
|
|
148
|
+
if (saved)
|
|
149
|
+
store.set({ patch: { pendingPurge: null } });
|
|
150
|
+
return saved;
|
|
151
|
+
}
|
|
152
|
+
async function setQuery({ ctx, query }) {
|
|
153
|
+
// Already-fetched full library owns display order/filtering. Tab/search/order changes
|
|
154
|
+
// never spend another request or flash a loading zero badge.
|
|
155
|
+
const { library } = ctx;
|
|
156
|
+
ctx.store.set({ patch: { query, ...(library ? { items: queryMedia({ media: library, query }) } : {}) } });
|
|
157
|
+
if (!library || ctx.readFailed)
|
|
158
|
+
await load({ ctx });
|
|
159
|
+
}
|
|
160
|
+
async function restore({ ctx, id }) {
|
|
161
|
+
const { api, store } = ctx;
|
|
162
|
+
if (!canRestoreMedia({ api })) {
|
|
163
|
+
store.set({ patch: { error: 'Restoring media is unavailable' } });
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return write({ ctx, run: () => api.restore({ id }, { signal: store.signal }), id });
|
|
167
|
+
}
|
|
3
168
|
export function createLibraryController({ api }, { query = {} } = {}) {
|
|
4
169
|
const store = createControllerStore({
|
|
5
170
|
initial: {
|
|
@@ -14,156 +179,21 @@ export function createLibraryController({ api }, { query = {} } = {}) {
|
|
|
14
179
|
counts: null,
|
|
15
180
|
},
|
|
16
181
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (retryTimer !== null)
|
|
22
|
-
clearTimeout(retryTimer);
|
|
23
|
-
retryTimer = null;
|
|
24
|
-
}
|
|
25
|
-
let readAbort = null, generation = 0;
|
|
26
|
-
/** Store patch for an accepted full library: filtered rows plus whole-library tab counts.
|
|
27
|
-
* @complexity O(n) in the library size. */
|
|
28
|
-
function libraryView({ media }, _optional = {}) {
|
|
29
|
-
return { items: queryMedia({ media, query: store.getSnapshot().query }), counts: countMediaTabs({ media }) };
|
|
30
|
-
}
|
|
31
|
-
/** Commits a read that is still the latest one; items are frozen so consumers cannot mutate rows. */
|
|
32
|
-
function acceptRead({ all }, _optional = {}) {
|
|
33
|
-
readFailed = false;
|
|
34
|
-
retryAttempt = 0;
|
|
35
|
-
library = all;
|
|
36
|
-
const { items, counts } = libraryView({ media: all });
|
|
37
|
-
store.set({
|
|
38
|
-
patch: {
|
|
39
|
-
items: Object.freeze(items.map((item) => Object.freeze({ ...item }))),
|
|
40
|
-
counts,
|
|
41
|
-
hasUntyped: all.some((item) => item.contentType === null),
|
|
42
|
-
error: null,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/** Publishes the latest read's failure and, when the failure is transient, schedules a retry. */
|
|
47
|
-
function failRead({ error }, _optional = {}) {
|
|
48
|
-
readFailed = true;
|
|
49
|
-
store.set({
|
|
50
|
-
patch: { loading: false, error: error instanceof Error ? error.message : 'Failed to load media' },
|
|
51
|
-
});
|
|
52
|
-
// Retry reads only, never destructive writes. Keep trying at a capped delay so
|
|
53
|
-
// recovery needs no manual repair, while an offline service isn't hammered.
|
|
54
|
-
if (isRetryableMediaError({ error })) {
|
|
55
|
-
const delay = Math.min(1000 * 2 ** Math.min(retryAttempt, 5), 30000);
|
|
56
|
-
retryAttempt += 1;
|
|
57
|
-
retryTimer = setTimeout(() => { retryTimer = null; void load(); }, delay);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async function load(_required = {}, _optional = {}) {
|
|
61
|
-
if (store.signal.aborted)
|
|
62
|
-
return;
|
|
63
|
-
cancelRetry();
|
|
64
|
-
readAbort?.abort();
|
|
65
|
-
const abort = new AbortController();
|
|
66
|
-
readAbort = abort;
|
|
67
|
-
generation += 1;
|
|
68
|
-
const ticket = generation;
|
|
69
|
-
store.set({ patch: { loading: true, error: null } });
|
|
70
|
-
try {
|
|
71
|
-
const all = await api.list({}, { signal: abort.signal });
|
|
72
|
-
if (ticket === generation)
|
|
73
|
-
acceptRead({ all });
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
// A later background failure must not blank an already-rendered screen.
|
|
77
|
-
if (!abort.signal.aborted && ticket === generation)
|
|
78
|
-
failRead({ error });
|
|
79
|
-
}
|
|
80
|
-
finally {
|
|
81
|
-
if (ticket === generation)
|
|
82
|
-
store.set({ patch: { loading: false } });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
// A reactive cache observer may refresh this library without calling load again. Keep
|
|
86
|
-
// filtering/counts in the headless domain; accepting cache data must spend no extra read.
|
|
87
|
-
function settleLibrary({ all, error }, _optional = {}) {
|
|
88
|
-
if (store.signal.aborted)
|
|
89
|
-
return;
|
|
90
|
-
if (all) {
|
|
91
|
-
library = all;
|
|
92
|
-
store.set({ patch: { ...libraryView({ media: all }), hasUntyped: all.some(item => item.contentType === null), error: null } });
|
|
93
|
-
}
|
|
94
|
-
if (error)
|
|
95
|
-
store.set({ patch: { error: error.message } });
|
|
96
|
-
}
|
|
97
|
-
let writes = Promise.resolve();
|
|
98
|
-
let exclusiveWrite = false;
|
|
99
|
-
function write(run, id) {
|
|
100
|
-
if (store.signal.aborted || exclusiveWrite || (id === undefined ? store.getSnapshot().busy : store.getSnapshot().pendingIds.includes(id)))
|
|
101
|
-
return Promise.resolve(false);
|
|
102
|
-
if (id === undefined)
|
|
103
|
-
exclusiveWrite = true;
|
|
104
|
-
// Serialize accepted writes rather than dropping another card's click. Reserve
|
|
105
|
-
// each id immediately so a double click on the same asset cannot enqueue twice.
|
|
106
|
-
store.set({ patch: { busy: true, pendingIds: id === undefined ? store.getSnapshot().pendingIds : [...store.getSnapshot().pendingIds, id] } });
|
|
107
|
-
const operation = writes.then(async () => {
|
|
108
|
-
if (store.signal.aborted)
|
|
109
|
-
return false;
|
|
110
|
-
// Starting a write clears other writes' failures, so a stale failure from one must
|
|
111
|
-
// not survive past the start of an unrelated one.
|
|
112
|
-
generation++;
|
|
113
|
-
readAbort?.abort();
|
|
114
|
-
cancelRetry();
|
|
115
|
-
store.set({ patch: { loading: false, error: null } });
|
|
116
|
-
// A single exit: a write disposed mid-flight or a failed write reports false.
|
|
117
|
-
let saved = false;
|
|
118
|
-
try {
|
|
119
|
-
await run();
|
|
120
|
-
if (!store.signal.aborted) {
|
|
121
|
-
await load();
|
|
122
|
-
saved = true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
// The store ignores patches once disposed, so a write failing after dispose publishes nothing.
|
|
127
|
-
store.set({ patch: { loading: false, error: error instanceof Error ? error.message : 'Media write failed' } });
|
|
128
|
-
}
|
|
129
|
-
finally {
|
|
130
|
-
if (id === undefined)
|
|
131
|
-
exclusiveWrite = false;
|
|
132
|
-
const pendingIds = store.getSnapshot().pendingIds.filter(value => value !== id);
|
|
133
|
-
store.set({ patch: { busy: pendingIds.length > 0, pendingIds } });
|
|
134
|
-
}
|
|
135
|
-
return saved;
|
|
136
|
-
});
|
|
137
|
-
writes = operation.catch(() => undefined);
|
|
138
|
-
return operation;
|
|
139
|
-
}
|
|
182
|
+
const ctx = {
|
|
183
|
+
store, api, library: null, readFailed: false, retryAttempt: 0, retryTimer: null,
|
|
184
|
+
readAbort: null, generation: 0, writes: Promise.resolve(), exclusiveWrite: false,
|
|
185
|
+
};
|
|
140
186
|
return {
|
|
141
187
|
getSnapshot: store.getSnapshot,
|
|
142
188
|
subscribe: store.subscribe,
|
|
143
|
-
load,
|
|
144
|
-
settleLibrary,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
// never spend another request or flash a loading zero badge.
|
|
148
|
-
store.set({ patch: { query, ...(library ? { items: queryMedia({ media: library, query }) } : {}) } });
|
|
149
|
-
if (!library || readFailed)
|
|
150
|
-
await load();
|
|
151
|
-
},
|
|
152
|
-
async upload({ input, alt = '' }, _optional = {}) {
|
|
153
|
-
return write(() => api.upload(input, { alt, signal: store.signal }));
|
|
154
|
-
},
|
|
189
|
+
load: (_required = {}, _optional = {}) => load({ ctx }),
|
|
190
|
+
settleLibrary: (args, _optional = {}) => settleLibrary({ ctx, ...args }),
|
|
191
|
+
setQuery: (args, _optional = {}) => setQuery({ ctx, ...args }),
|
|
192
|
+
upload: ({ input, alt = '' }, _optional = {}) => write({ ctx, run: () => api.upload(input, { alt, signal: store.signal }) }),
|
|
155
193
|
// Trashing (the reversible first rung of the ladder) has no confirm step — only
|
|
156
194
|
// the irreversible purge step gates on the dialog, matching the original asymmetry.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
},
|
|
160
|
-
async restore({ id }, _optional = {}) {
|
|
161
|
-
if (!canRestoreMedia({ api })) {
|
|
162
|
-
store.set({ patch: { error: 'Restoring media is unavailable' } });
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
return write(() => api.restore({ id }, { signal: store.signal }), id);
|
|
166
|
-
},
|
|
195
|
+
trash: ({ id }, _optional = {}) => write({ ctx, run: () => api.trash({ id }, { signal: store.signal }), id }),
|
|
196
|
+
restore: (args, _optional = {}) => restore({ ctx, ...args }),
|
|
167
197
|
requestPurge({ item }, _optional = {}) {
|
|
168
198
|
if (!store.getSnapshot().busy && item.status === 'trashed')
|
|
169
199
|
store.set({ patch: { pendingPurge: item } });
|
|
@@ -172,28 +202,11 @@ export function createLibraryController({ api }, { query = {} } = {}) {
|
|
|
172
202
|
if (!store.getSnapshot().busy)
|
|
173
203
|
store.set({ patch: { pendingPurge: null } });
|
|
174
204
|
},
|
|
175
|
-
|
|
176
|
-
const item = store.getSnapshot().pendingPurge;
|
|
177
|
-
if (!confirmed || !item)
|
|
178
|
-
return false;
|
|
179
|
-
const saved = await write(async () => {
|
|
180
|
-
const result = await api.delete({ id: item.id }, { signal: store.signal });
|
|
181
|
-
if (!result.purged)
|
|
182
|
-
throw new Error('The file was not permanently deleted');
|
|
183
|
-
// A failed follow-up read must not leave a permanently deleted card focusable.
|
|
184
|
-
if (library) {
|
|
185
|
-
library = library.filter(row => row.id !== item.id);
|
|
186
|
-
store.set({ patch: libraryView({ media: library }) });
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
if (saved)
|
|
190
|
-
store.set({ patch: { pendingPurge: null } });
|
|
191
|
-
return saved;
|
|
192
|
-
},
|
|
205
|
+
confirmPurge: (args, _optional = {}) => confirmPurge({ ctx, ...args }),
|
|
193
206
|
dispose(_required = {}, _optional = {}) {
|
|
194
|
-
generation++;
|
|
195
|
-
cancelRetry();
|
|
196
|
-
readAbort?.abort();
|
|
207
|
+
ctx.generation++;
|
|
208
|
+
cancelRetry({ ctx });
|
|
209
|
+
ctx.readAbort?.abort();
|
|
197
210
|
store.dispose();
|
|
198
211
|
},
|
|
199
212
|
};
|
|
@@ -3,15 +3,15 @@ import type { MediaProvider } from '../models.js';
|
|
|
3
3
|
export declare function createProvidersController({ api }: {
|
|
4
4
|
api: MediaProvidersPort;
|
|
5
5
|
}, _optional?: Record<string, never>): {
|
|
6
|
-
getSnapshot: () =>
|
|
6
|
+
getSnapshot: (required?: Record<string, never>, optional?: Record<string, never>) => {
|
|
7
7
|
items: readonly MediaProvider[];
|
|
8
8
|
loading: boolean;
|
|
9
9
|
saving: boolean;
|
|
10
10
|
error: string | null;
|
|
11
|
-
}
|
|
12
|
-
subscribe: (
|
|
11
|
+
};
|
|
12
|
+
subscribe: (required: {
|
|
13
13
|
listener: () => void;
|
|
14
|
-
}) => () => void;
|
|
14
|
+
}, optional?: Record<string, never>) => () => void;
|
|
15
15
|
load: (_required?: Record<string, never>, _optional?: Record<string, never>) => Promise<void>;
|
|
16
16
|
save({ id, credential }: {
|
|
17
17
|
id: string;
|
|
@@ -1,40 +1,6 @@
|
|
|
1
|
-
import { createControllerStore } from '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
initial: {
|
|
5
|
-
items: [],
|
|
6
|
-
loading: false,
|
|
7
|
-
saving: false,
|
|
8
|
-
error: null,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
let generation = 0;
|
|
12
|
-
async function load(_required = {}, _optional = {}) {
|
|
13
|
-
if (store.signal.aborted)
|
|
14
|
-
return;
|
|
15
|
-
generation += 1;
|
|
16
|
-
const ticket = generation;
|
|
17
|
-
store.set({ patch: { loading: true } });
|
|
18
|
-
try {
|
|
19
|
-
const items = await api.list({}, { signal: store.signal });
|
|
20
|
-
// null leaves local edits untouched; [] is an authoritative empty answer.
|
|
21
|
-
if (ticket === generation)
|
|
22
|
-
store.set({
|
|
23
|
-
patch: items === null
|
|
24
|
-
? { error: 'Provider service unavailable' }
|
|
25
|
-
: { items: Object.freeze([...items]), error: null },
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
if (ticket === generation)
|
|
30
|
-
store.set({ patch: { error: 'Provider service unavailable' } });
|
|
31
|
-
}
|
|
32
|
-
finally {
|
|
33
|
-
if (ticket === generation)
|
|
34
|
-
store.set({ patch: { loading: false } });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async function write(run) {
|
|
1
|
+
import { createControllerStore, describeApiError } from '@jini-ai/core/admin-runtime';
|
|
2
|
+
function createProviderWriter(store, load) {
|
|
3
|
+
return async function write(run) {
|
|
38
4
|
if (store.signal.aborted || store.getSnapshot().saving)
|
|
39
5
|
return false;
|
|
40
6
|
store.set({ patch: { saving: true, error: null } });
|
|
@@ -45,15 +11,55 @@ export function createProvidersController({ api }, _optional = {}) {
|
|
|
45
11
|
await load();
|
|
46
12
|
return true;
|
|
47
13
|
}
|
|
48
|
-
catch {
|
|
49
|
-
store.set({ patch: { error: 'Failed to save provider credentials' } });
|
|
14
|
+
catch (error) {
|
|
15
|
+
store.set({ patch: { error: describeApiError({ e: error, fallback: 'Failed to save provider credentials' }) } });
|
|
50
16
|
}
|
|
51
17
|
finally {
|
|
52
18
|
store.set({ patch: { saving: false } });
|
|
53
19
|
}
|
|
54
20
|
// Reached only through the catch above: the failure is already recorded in `error`.
|
|
55
21
|
return false;
|
|
56
|
-
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function createProviderLoader(store, api, { nextGeneration, isCurrent }) {
|
|
25
|
+
return async function load(_required = {}, _optional = {}) {
|
|
26
|
+
if (store.signal.aborted)
|
|
27
|
+
return;
|
|
28
|
+
const ticket = nextGeneration();
|
|
29
|
+
store.set({ patch: { loading: true } });
|
|
30
|
+
try {
|
|
31
|
+
const items = await api.list({}, { signal: store.signal });
|
|
32
|
+
// null leaves local edits untouched; [] is an authoritative empty answer.
|
|
33
|
+
if (isCurrent(ticket))
|
|
34
|
+
store.set({
|
|
35
|
+
patch: items === null
|
|
36
|
+
? { error: 'Provider service unavailable' }
|
|
37
|
+
: { items: Object.freeze([...items]), error: null },
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
// The host's API port reports the incident (Copy details); this line shows its approved words.
|
|
42
|
+
if (isCurrent(ticket))
|
|
43
|
+
store.set({ patch: { error: describeApiError({ e: error, fallback: 'Provider service unavailable' }) } });
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
if (isCurrent(ticket))
|
|
47
|
+
store.set({ patch: { loading: false } });
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function createProvidersController({ api }, _optional = {}) {
|
|
52
|
+
const store = createControllerStore({
|
|
53
|
+
initial: {
|
|
54
|
+
items: [],
|
|
55
|
+
loading: false,
|
|
56
|
+
saving: false,
|
|
57
|
+
error: null,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
let generation = 0;
|
|
61
|
+
const load = createProviderLoader(store, api, { nextGeneration: () => ++generation, isCurrent: ticket => ticket === generation });
|
|
62
|
+
const write = createProviderWriter(store, load);
|
|
57
63
|
return {
|
|
58
64
|
getSnapshot: store.getSnapshot,
|
|
59
65
|
subscribe: store.subscribe,
|