@memberjunction/ng-conversations 6.2.0-edge.3 → 6.2.0-edge.4
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 +4 -7
- package/dist/lib/components/collection/collection-view.component.d.ts.map +1 -1
- package/dist/lib/components/collection/collection-view.component.js +1 -0
- package/dist/lib/components/collection/collection-view.component.js.map +1 -1
- package/dist/lib/components/composer/ai-composer.component.d.ts +14 -2
- package/dist/lib/components/composer/ai-composer.component.d.ts.map +1 -1
- package/dist/lib/components/composer/ai-composer.component.js +35 -4
- package/dist/lib/components/composer/ai-composer.component.js.map +1 -1
- package/dist/lib/components/conversation/conversation-chat-area.component.d.ts +588 -51
- package/dist/lib/components/conversation/conversation-chat-area.component.d.ts.map +1 -1
- package/dist/lib/components/conversation/conversation-chat-area.component.js +2654 -665
- package/dist/lib/components/conversation/conversation-chat-area.component.js.map +1 -1
- package/dist/lib/components/conversation/forks-popover.component.d.ts +37 -0
- package/dist/lib/components/conversation/forks-popover.component.d.ts.map +1 -0
- package/dist/lib/components/conversation/forks-popover.component.js +164 -0
- package/dist/lib/components/conversation/forks-popover.component.js.map +1 -0
- package/dist/lib/components/export/export-modal.component.d.ts +7 -2
- package/dist/lib/components/export/export-modal.component.d.ts.map +1 -1
- package/dist/lib/components/export/export-modal.component.js +16 -3
- package/dist/lib/components/export/export-modal.component.js.map +1 -1
- package/dist/lib/components/message/conversation-message-rating.component.d.ts.map +1 -1
- package/dist/lib/components/message/conversation-message-rating.component.js +11 -9
- package/dist/lib/components/message/conversation-message-rating.component.js.map +1 -1
- package/dist/lib/components/message/message-input.component.d.ts +96 -11
- package/dist/lib/components/message/message-input.component.d.ts.map +1 -1
- package/dist/lib/components/message/message-input.component.js +244 -103
- package/dist/lib/components/message/message-input.component.js.map +1 -1
- package/dist/lib/components/message/message-item.component.d.ts +171 -4
- package/dist/lib/components/message/message-item.component.d.ts.map +1 -1
- package/dist/lib/components/message/message-item.component.js +899 -298
- package/dist/lib/components/message/message-item.component.js.map +1 -1
- package/dist/lib/components/message/message-list.component.d.ts +82 -21
- package/dist/lib/components/message/message-list.component.d.ts.map +1 -1
- package/dist/lib/components/message/message-list.component.js +299 -52
- package/dist/lib/components/message/message-list.component.js.map +1 -1
- package/dist/lib/components/realtime/avatar/realtime-avatar-channel.d.ts +34 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-channel.d.ts.map +1 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-channel.js +75 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-channel.js.map +1 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-surface.component.d.ts +80 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-surface.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-surface.component.js +202 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-surface.component.js.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-camera-check-card.component.d.ts +45 -0
- package/dist/lib/components/realtime/capture/realtime-camera-check-card.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-camera-check-card.component.js +123 -0
- package/dist/lib/components/realtime/capture/realtime-camera-check-card.component.js.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-channel.d.ts +90 -0
- package/dist/lib/components/realtime/capture/realtime-capture-channel.d.ts.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-channel.js +223 -0
- package/dist/lib/components/realtime/capture/realtime-capture-channel.js.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-model.d.ts +98 -0
- package/dist/lib/components/realtime/capture/realtime-capture-model.d.ts.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-model.js +161 -0
- package/dist/lib/components/realtime/capture/realtime-capture-model.js.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-surface.component.d.ts +48 -0
- package/dist/lib/components/realtime/capture/realtime-capture-surface.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-surface.component.js +205 -0
- package/dist/lib/components/realtime/capture/realtime-capture-surface.component.js.map +1 -0
- package/dist/lib/components/realtime/channels/client-context-channel.d.ts +19 -2
- package/dist/lib/components/realtime/channels/client-context-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/channels/client-context-channel.js +83 -9
- package/dist/lib/components/realtime/channels/client-context-channel.js.map +1 -1
- package/dist/lib/components/realtime/channels/realtime-channel-pane.component.d.ts +30 -9
- package/dist/lib/components/realtime/channels/realtime-channel-pane.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/channels/realtime-channel-pane.component.js +78 -14
- package/dist/lib/components/realtime/channels/realtime-channel-pane.component.js.map +1 -1
- package/dist/lib/components/realtime/identity-verification/identity-verification-channel.d.ts +71 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-channel.d.ts.map +1 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-channel.js +259 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-channel.js.map +1 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-model.d.ts +129 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-model.d.ts.map +1 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-model.js +373 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-model.js.map +1 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-surface.component.d.ts +77 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-surface.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-surface.component.js +420 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-surface.component.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-contract.d.ts +83 -0
- package/dist/lib/components/realtime/interactive-component/component-contract.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-contract.js +292 -0
- package/dist/lib/components/realtime/interactive-component/component-contract.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-data-state.d.ts +39 -0
- package/dist/lib/components/realtime/interactive-component/component-data-state.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-data-state.js +152 -0
- package/dist/lib/components/realtime/interactive-component/component-data-state.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-instance-engine.d.ts +109 -0
- package/dist/lib/components/realtime/interactive-component/component-instance-engine.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-instance-engine.js +146 -0
- package/dist/lib/components/realtime/interactive-component/component-instance-engine.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-spec-content.d.ts +19 -0
- package/dist/lib/components/realtime/interactive-component/component-spec-content.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-spec-content.js +39 -0
- package/dist/lib/components/realtime/interactive-component/component-spec-content.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts +183 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js +761 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-config.d.ts +25 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-config.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-config.js +57 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-config.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-host.component.d.ts +40 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-host.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-host.component.js +97 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-host.component.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-types.d.ts +144 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-types.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-types.js +57 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-types.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/react-component-handle.d.ts +36 -0
- package/dist/lib/components/realtime/interactive-component/react-component-handle.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/react-component-handle.js +55 -0
- package/dist/lib/components/realtime/interactive-component/react-component-handle.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/realtime-interactive-component-surface.component.d.ts +55 -0
- package/dist/lib/components/realtime/interactive-component/realtime-interactive-component-surface.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/realtime-interactive-component-surface.component.js +210 -0
- package/dist/lib/components/realtime/interactive-component/realtime-interactive-component-surface.component.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/run-view-component-artifact-source.d.ts +32 -0
- package/dist/lib/components/realtime/interactive-component/run-view-component-artifact-source.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/run-view-component-artifact-source.js +90 -0
- package/dist/lib/components/realtime/interactive-component/run-view-component-artifact-source.js.map +1 -0
- package/dist/lib/components/realtime/media/media-channel.d.ts +7 -0
- package/dist/lib/components/realtime/media/media-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/media/media-channel.js +28 -1
- package/dist/lib/components/realtime/media/media-channel.js.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-banner.component.d.ts +8 -1
- package/dist/lib/components/realtime/realtime-agent-banner.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-banner.component.js +89 -71
- package/dist/lib/components/realtime/realtime-agent-banner.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-orb.component.d.ts +21 -0
- package/dist/lib/components/realtime/realtime-agent-orb.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/realtime-agent-orb.component.js +49 -0
- package/dist/lib/components/realtime/realtime-agent-orb.component.js.map +1 -0
- package/dist/lib/components/realtime/realtime-agent-picker.component.d.ts +44 -11
- package/dist/lib/components/realtime/realtime-agent-picker.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-picker.component.js +162 -50
- package/dist/lib/components/realtime/realtime-agent-picker.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-audio-visuals.d.ts +8 -2
- package/dist/lib/components/realtime/realtime-audio-visuals.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-audio-visuals.js +14 -18
- package/dist/lib/components/realtime/realtime-audio-visuals.js.map +1 -1
- package/dist/lib/components/realtime/realtime-composer.component.d.ts +42 -2
- package/dist/lib/components/realtime/realtime-composer.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-composer.component.js +137 -102
- package/dist/lib/components/realtime/realtime-composer.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-perception-chip.component.d.ts +71 -0
- package/dist/lib/components/realtime/realtime-perception-chip.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/realtime-perception-chip.component.js +221 -0
- package/dist/lib/components/realtime/realtime-perception-chip.component.js.map +1 -0
- package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts +264 -22
- package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-session-overlay.component.js +851 -135
- package/dist/lib/components/realtime/realtime-session-overlay.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-placement-prefs.d.ts +14 -0
- package/dist/lib/components/realtime/realtime-surface-placement-prefs.d.ts.map +1 -0
- package/dist/lib/components/realtime/realtime-surface-placement-prefs.js +14 -0
- package/dist/lib/components/realtime/realtime-surface-placement-prefs.js.map +1 -0
- package/dist/lib/components/realtime/realtime-surface-stage.model.d.ts +74 -0
- package/dist/lib/components/realtime/realtime-surface-stage.model.d.ts.map +1 -0
- package/dist/lib/components/realtime/realtime-surface-stage.model.js +171 -0
- package/dist/lib/components/realtime/realtime-surface-stage.model.js.map +1 -0
- package/dist/lib/components/realtime/realtime-surface-tabs.component.d.ts +71 -13
- package/dist/lib/components/realtime/realtime-surface-tabs.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-tabs.component.js +232 -73
- package/dist/lib/components/realtime/realtime-surface-tabs.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts +5 -0
- package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-tabs.model.js +8 -0
- package/dist/lib/components/realtime/realtime-surface-tabs.model.js.map +1 -1
- package/dist/lib/components/realtime/realtime-ui-config.d.ts +12 -2
- package/dist/lib/components/realtime/realtime-ui-config.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-ui-config.js +5 -1
- package/dist/lib/components/realtime/realtime-ui-config.js.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts +10 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-channel.js +42 -2
- package/dist/lib/components/realtime/remote-browser/remote-browser-channel.js.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.d.ts +20 -3
- package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js +44 -10
- package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js.map +1 -1
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.d.ts +28 -44
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js +76 -162
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js.map +1 -1
- package/dist/lib/components/search/search-panel.component.d.ts +2 -0
- package/dist/lib/components/search/search-panel.component.d.ts.map +1 -1
- package/dist/lib/components/search/search-panel.component.js +25 -12
- package/dist/lib/components/search/search-panel.component.js.map +1 -1
- package/dist/lib/components/workspace/conversation-workspace.component.d.ts +22 -31
- package/dist/lib/components/workspace/conversation-workspace.component.d.ts.map +1 -1
- package/dist/lib/components/workspace/conversation-workspace.component.js +50 -63
- package/dist/lib/components/workspace/conversation-workspace.component.js.map +1 -1
- package/dist/lib/conversations.module.d.ts +30 -29
- package/dist/lib/conversations.module.d.ts.map +1 -1
- package/dist/lib/conversations.module.js +27 -5
- package/dist/lib/conversations.module.js.map +1 -1
- package/dist/lib/events/chat-events.d.ts +25 -0
- package/dist/lib/events/chat-events.d.ts.map +1 -1
- package/dist/lib/events/chat-events.js +36 -0
- package/dist/lib/events/chat-events.js.map +1 -1
- package/dist/lib/models/agent-turn.model.d.ts +5 -0
- package/dist/lib/models/agent-turn.model.d.ts.map +1 -1
- package/dist/lib/models/agent-turn.model.js.map +1 -1
- package/dist/lib/services/agent-state.service.d.ts +34 -8
- package/dist/lib/services/agent-state.service.d.ts.map +1 -1
- package/dist/lib/services/agent-state.service.js +82 -29
- package/dist/lib/services/agent-state.service.js.map +1 -1
- package/dist/lib/services/artifact-state.service.d.ts +0 -9
- package/dist/lib/services/artifact-state.service.d.ts.map +1 -1
- package/dist/lib/services/artifact-state.service.js +1 -32
- package/dist/lib/services/artifact-state.service.js.map +1 -1
- package/dist/lib/services/browser-realtime-media-host.d.ts +12 -0
- package/dist/lib/services/browser-realtime-media-host.d.ts.map +1 -1
- package/dist/lib/services/browser-realtime-media-host.js +19 -0
- package/dist/lib/services/browser-realtime-media-host.js.map +1 -1
- package/dist/lib/services/browser-recording-unload-guard.d.ts +30 -0
- package/dist/lib/services/browser-recording-unload-guard.d.ts.map +1 -0
- package/dist/lib/services/browser-recording-unload-guard.js +43 -0
- package/dist/lib/services/browser-recording-unload-guard.js.map +1 -0
- package/dist/lib/services/conversation-agent.service.d.ts +35 -11
- package/dist/lib/services/conversation-agent.service.d.ts.map +1 -1
- package/dist/lib/services/conversation-agent.service.js +65 -20
- package/dist/lib/services/conversation-agent.service.js.map +1 -1
- package/dist/lib/services/conversation-detail-window.store.d.ts +22 -4
- package/dist/lib/services/conversation-detail-window.store.d.ts.map +1 -1
- package/dist/lib/services/conversation-detail-window.store.js +50 -9
- package/dist/lib/services/conversation-detail-window.store.js.map +1 -1
- package/dist/lib/services/conversation-naming.d.ts +72 -22
- package/dist/lib/services/conversation-naming.d.ts.map +1 -1
- package/dist/lib/services/conversation-naming.js +84 -10
- package/dist/lib/services/conversation-naming.js.map +1 -1
- package/dist/lib/services/data-cache.service.d.ts +13 -5
- package/dist/lib/services/data-cache.service.d.ts.map +1 -1
- package/dist/lib/services/data-cache.service.js +39 -19
- package/dist/lib/services/data-cache.service.js.map +1 -1
- package/dist/lib/services/export.service.d.ts +26 -9
- package/dist/lib/services/export.service.d.ts.map +1 -1
- package/dist/lib/services/export.service.js +61 -18
- package/dist/lib/services/export.service.js.map +1 -1
- package/dist/lib/services/realtime-audio-recorder.d.ts +33 -5
- package/dist/lib/services/realtime-audio-recorder.d.ts.map +1 -1
- package/dist/lib/services/realtime-audio-recorder.js +71 -11
- package/dist/lib/services/realtime-audio-recorder.js.map +1 -1
- package/dist/lib/services/realtime-pairing.d.ts +10 -5
- package/dist/lib/services/realtime-pairing.d.ts.map +1 -1
- package/dist/lib/services/realtime-pairing.js +15 -6
- package/dist/lib/services/realtime-pairing.js.map +1 -1
- package/dist/lib/services/realtime-session.service.d.ts +3 -2
- package/dist/lib/services/realtime-session.service.d.ts.map +1 -1
- package/dist/lib/services/realtime-session.service.js +7 -2
- package/dist/lib/services/realtime-session.service.js.map +1 -1
- package/dist/lib/services/search.service.d.ts +7 -2
- package/dist/lib/services/search.service.d.ts.map +1 -1
- package/dist/lib/services/search.service.js +13 -4
- package/dist/lib/services/search.service.js.map +1 -1
- package/dist/lib/utils/conversation-branching.d.ts +4 -0
- package/dist/lib/utils/conversation-branching.d.ts.map +1 -0
- package/dist/lib/utils/conversation-branching.js +5 -0
- package/dist/lib/utils/conversation-branching.js.map +1 -0
- package/dist/lib/utils/conversation-forks.d.ts +315 -0
- package/dist/lib/utils/conversation-forks.d.ts.map +1 -0
- package/dist/lib/utils/conversation-forks.js +456 -0
- package/dist/lib/utils/conversation-forks.js.map +1 -0
- package/dist/public-api.d.ts +23 -1
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +30 -1
- package/dist/public-api.js.map +1 -1
- package/package.json +37 -33
- package/dist/lib/components/thread/thread-panel.component.d.ts +0 -126
- package/dist/lib/components/thread/thread-panel.component.d.ts.map +0 -1
- package/dist/lib/components/thread/thread-panel.component.js +0 -440
- package/dist/lib/components/thread/thread-panel.component.js.map +0 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Derives what an agent can do with a component from the component's own specification.
|
|
3
|
+
*
|
|
4
|
+
* A component artifact already says what it accepts and emits: its `properties` (inputs), its `events`, and its
|
|
5
|
+
* `methods` (standard methods it supports plus custom ones with typed parameters). This module turns that into the
|
|
6
|
+
* channel contract's vocabulary, so an agent can operate a component nobody wrote channel code for:
|
|
7
|
+
*
|
|
8
|
+
* | spec | contract |
|
|
9
|
+
* |---|---|
|
|
10
|
+
* | `methods.customMethods[]` | a verb per method, parameters schema from the declared parameter types |
|
|
11
|
+
* | `methods.standardMethodsSupported` | `refresh`, `print`, `validate`, `is_dirty`, `reset`, `scroll_to`, `focus`, and `get_data_state` |
|
|
12
|
+
* | `methods.standardMethodsSupported.getCurrentDataState` | the instance's `data` in the channel's state (the noun) |
|
|
13
|
+
* | `events[]` | channel events, payload schema from the event parameters |
|
|
14
|
+
* | `properties[]` | the schema of the `inputs` accepted when opening it |
|
|
15
|
+
*
|
|
16
|
+
* A verb whose result carries what the component holds (`get_data_state`, `validate`, `is_dirty`, and any custom method that
|
|
17
|
+
* returns something) is marked `ReturnsChannelData: 'state'`, so the agent is refused it when it may not perceive the
|
|
18
|
+
* component's state (see `RealtimeChannelVerb.ReturnsChannelData`).
|
|
19
|
+
*
|
|
20
|
+
* Pure functions over plain data: no component is rendered and nothing is invoked here.
|
|
21
|
+
*
|
|
22
|
+
* @module @memberjunction/ng-conversations
|
|
23
|
+
*/
|
|
24
|
+
import type { RealtimeChannelEventSpec, RealtimeChannelSchema, RealtimeChannelVerb } from '@memberjunction/ai-core-plus';
|
|
25
|
+
import type { ComponentSpec } from '@memberjunction/interactive-component-types';
|
|
26
|
+
import { STANDARD_VERBS } from './interactive-component-types';
|
|
27
|
+
/** How a verb reaches the component. */
|
|
28
|
+
export type VerbBinding = {
|
|
29
|
+
Kind: 'standard';
|
|
30
|
+
Standard: keyof typeof STANDARD_VERBS;
|
|
31
|
+
} | {
|
|
32
|
+
Kind: 'custom';
|
|
33
|
+
Method: string;
|
|
34
|
+
ParameterNames: string[];
|
|
35
|
+
};
|
|
36
|
+
/** One verb derived from a spec, with how to run it. */
|
|
37
|
+
export interface DerivedVerb {
|
|
38
|
+
/** The verb as the agent sees it. */
|
|
39
|
+
Verb: RealtimeChannelVerb;
|
|
40
|
+
/** How the channel runs it. */
|
|
41
|
+
Binding: VerbBinding;
|
|
42
|
+
}
|
|
43
|
+
/** A method the contract could not expose, and why (kept so a spec problem is visible rather than silently dropped). */
|
|
44
|
+
export interface SkippedMethod {
|
|
45
|
+
/** The method's name. */
|
|
46
|
+
Name: string;
|
|
47
|
+
/** Why it was not exposed. */
|
|
48
|
+
Reason: string;
|
|
49
|
+
}
|
|
50
|
+
/** Everything an agent can do with one component, derived from its spec. */
|
|
51
|
+
export interface ComponentContract {
|
|
52
|
+
/** The verbs, standard and custom. */
|
|
53
|
+
Verbs: DerivedVerb[];
|
|
54
|
+
/** The events the component can emit. */
|
|
55
|
+
Events: RealtimeChannelEventSpec[];
|
|
56
|
+
/** The schema of the `inputs` accepted when opening it (from the spec's `properties`). */
|
|
57
|
+
InputsSchema: RealtimeChannelSchema;
|
|
58
|
+
/** Whether the component reports a data state (`getCurrentDataState` is supported), i.e. whether the instance has `data` to describe. */
|
|
59
|
+
SupportsDataState: boolean;
|
|
60
|
+
/** Methods that could not be exposed. */
|
|
61
|
+
Skipped: SkippedMethod[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Derives the full contract of one component from its spec.
|
|
65
|
+
*
|
|
66
|
+
* @param spec The component's specification.
|
|
67
|
+
*/
|
|
68
|
+
export declare function DeriveComponentContract(spec: ComponentSpec): ComponentContract;
|
|
69
|
+
/**
|
|
70
|
+
* Merges the same verb offered by several open components into the single verb the channel declares.
|
|
71
|
+
*
|
|
72
|
+
* Verbs from different components can share a name with different parameters (two components that both have
|
|
73
|
+
* `setFilter`). The channel declares one verb per name; its schema is the UNION of the parameters with nothing
|
|
74
|
+
* required, so a call that suits any of them passes the dispatcher, and the exact per-component check
|
|
75
|
+
* (against that component's own schema) happens when the verb runs. The description lists each component's signature.
|
|
76
|
+
*
|
|
77
|
+
* @param offers Each component's verb of this name, with the component's display name.
|
|
78
|
+
*/
|
|
79
|
+
export declare function MergeVerbOffers(offers: ReadonlyArray<{
|
|
80
|
+
Component: string;
|
|
81
|
+
Verb: RealtimeChannelVerb;
|
|
82
|
+
}>): RealtimeChannelVerb;
|
|
83
|
+
//# sourceMappingURL=component-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-contract.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/interactive-component/component-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACzH,OAAO,KAAK,EAAE,aAAa,EAAyB,MAAM,6CAA6C,CAAC;AACxG,OAAO,EAAE,cAAc,EAAiB,MAAM,+BAA+B,CAAC;AAE9E,wCAAwC;AACxC,MAAM,MAAM,WAAW,GACjB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,cAAc,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEnE,wDAAwD;AACxD,MAAM,WAAW,WAAW;IACxB,qCAAqC;IACrC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,+BAA+B;IAC/B,OAAO,EAAE,WAAW,CAAC;CACxB;AAED,wHAAwH;AACxH,MAAM,WAAW,aAAa;IAC1B,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,4EAA4E;AAC5E,MAAM,WAAW,iBAAiB;IAC9B,sCAAsC;IACtC,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,yCAAyC;IACzC,MAAM,EAAE,wBAAwB,EAAE,CAAC;IACnC,0FAA0F;IAC1F,YAAY,EAAE,qBAAqB,CAAC;IACpC,yIAAyI;IACzI,iBAAiB,EAAE,OAAO,CAAC;IAC3B,yCAAyC;IACzC,OAAO,EAAE,aAAa,EAAE,CAAC;CAC5B;AA4OD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,aAAa,GAAG,iBAAiB,CAW9E;AAQD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC,GAAG,mBAAmB,CAwB5H"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Derives what an agent can do with a component from the component's own specification.
|
|
3
|
+
*
|
|
4
|
+
* A component artifact already says what it accepts and emits: its `properties` (inputs), its `events`, and its
|
|
5
|
+
* `methods` (standard methods it supports plus custom ones with typed parameters). This module turns that into the
|
|
6
|
+
* channel contract's vocabulary, so an agent can operate a component nobody wrote channel code for:
|
|
7
|
+
*
|
|
8
|
+
* | spec | contract |
|
|
9
|
+
* |---|---|
|
|
10
|
+
* | `methods.customMethods[]` | a verb per method, parameters schema from the declared parameter types |
|
|
11
|
+
* | `methods.standardMethodsSupported` | `refresh`, `print`, `validate`, `is_dirty`, `reset`, `scroll_to`, `focus`, and `get_data_state` |
|
|
12
|
+
* | `methods.standardMethodsSupported.getCurrentDataState` | the instance's `data` in the channel's state (the noun) |
|
|
13
|
+
* | `events[]` | channel events, payload schema from the event parameters |
|
|
14
|
+
* | `properties[]` | the schema of the `inputs` accepted when opening it |
|
|
15
|
+
*
|
|
16
|
+
* A verb whose result carries what the component holds (`get_data_state`, `validate`, `is_dirty`, and any custom method that
|
|
17
|
+
* returns something) is marked `ReturnsChannelData: 'state'`, so the agent is refused it when it may not perceive the
|
|
18
|
+
* component's state (see `RealtimeChannelVerb.ReturnsChannelData`).
|
|
19
|
+
*
|
|
20
|
+
* Pure functions over plain data: no component is rendered and nothing is invoked here.
|
|
21
|
+
*
|
|
22
|
+
* @module @memberjunction/ng-conversations
|
|
23
|
+
*/
|
|
24
|
+
import { STANDARD_VERBS, BUILTIN_VERBS } from './interactive-component-types';
|
|
25
|
+
/** Verb names that belong to the channel, which a custom method may not take. */
|
|
26
|
+
const RESERVED_VERB_NAMES = new Set([
|
|
27
|
+
...Object.values(BUILTIN_VERBS),
|
|
28
|
+
...Object.values(STANDARD_VERBS),
|
|
29
|
+
'open',
|
|
30
|
+
]);
|
|
31
|
+
/** The JSON-schema for a type name as a spec author writes it, or `null` when it cannot be expressed. */
|
|
32
|
+
function schemaForTypeName(typeName) {
|
|
33
|
+
const type = typeName.trim().toLowerCase().replace(/\s+/g, ' ');
|
|
34
|
+
if (type === 'string') {
|
|
35
|
+
return { type: 'string' };
|
|
36
|
+
}
|
|
37
|
+
if (type === 'number' || type === 'float' || type === 'double') {
|
|
38
|
+
return { type: 'number' };
|
|
39
|
+
}
|
|
40
|
+
if (type === 'integer' || type === 'int') {
|
|
41
|
+
return { type: 'integer' };
|
|
42
|
+
}
|
|
43
|
+
if (type === 'boolean' || type === 'bool') {
|
|
44
|
+
return { type: 'boolean' };
|
|
45
|
+
}
|
|
46
|
+
if (type === 'date' || type === 'datetime') {
|
|
47
|
+
return { type: 'string', format: 'date-time' };
|
|
48
|
+
}
|
|
49
|
+
if (type === 'array' || type.startsWith('array<') || type.endsWith('[]')) {
|
|
50
|
+
return { type: 'array' };
|
|
51
|
+
}
|
|
52
|
+
if (type === 'object' || type.startsWith('record<') || type.startsWith('{')) {
|
|
53
|
+
return { type: 'object' };
|
|
54
|
+
}
|
|
55
|
+
return type === 'function' ? null : {};
|
|
56
|
+
}
|
|
57
|
+
/** Whether a method parameter is optional, judged from its name, type and description. */
|
|
58
|
+
function isOptionalParameter(parameter) {
|
|
59
|
+
return (parameter.name.trim().endsWith('?') ||
|
|
60
|
+
/\bundefined\b/i.test(parameter.type) ||
|
|
61
|
+
/^\s*optional\b/i.test(parameter.description ?? ''));
|
|
62
|
+
}
|
|
63
|
+
/** The bare parameter name (a trailing `?` marks it optional and is not part of the name). */
|
|
64
|
+
function parameterName(parameter) {
|
|
65
|
+
return parameter.name.trim().replace(/\?$/, '');
|
|
66
|
+
}
|
|
67
|
+
/** Builds the parameters schema of a custom method; `null` when a required parameter cannot be passed by a model (a function). */
|
|
68
|
+
function buildParametersSchema(method) {
|
|
69
|
+
const properties = {};
|
|
70
|
+
const required = [];
|
|
71
|
+
const names = [];
|
|
72
|
+
for (const parameter of method.parameters ?? []) {
|
|
73
|
+
const name = parameterName(parameter);
|
|
74
|
+
const schema = schemaForTypeName(parameter.type ?? '');
|
|
75
|
+
const optional = isOptionalParameter(parameter);
|
|
76
|
+
if (schema === null) {
|
|
77
|
+
if (!optional) {
|
|
78
|
+
return { Problem: `parameter "${name}" is a function, which an agent cannot pass` };
|
|
79
|
+
}
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const described = { ...schema, description: parameter.description ?? `${name} (${parameter.type})` };
|
|
83
|
+
if (Object.keys(schema).length === 0) {
|
|
84
|
+
described['description'] = `${parameter.description ?? name} (declared type: ${parameter.type})`;
|
|
85
|
+
}
|
|
86
|
+
properties[name] = described;
|
|
87
|
+
names.push(name);
|
|
88
|
+
if (!optional) {
|
|
89
|
+
required.push(name);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const schema = { type: 'object', properties, additionalProperties: false };
|
|
93
|
+
if (required.length > 0) {
|
|
94
|
+
schema['required'] = required;
|
|
95
|
+
}
|
|
96
|
+
return { Schema: schema, Names: names };
|
|
97
|
+
}
|
|
98
|
+
/** The verb name for a custom method: its own name, unless that is taken by the channel. */
|
|
99
|
+
function customVerbName(method, taken) {
|
|
100
|
+
let name = method;
|
|
101
|
+
if (RESERVED_VERB_NAMES.has(name.toLowerCase()) || taken.has(name.toLowerCase())) {
|
|
102
|
+
name = `custom_${method}`;
|
|
103
|
+
}
|
|
104
|
+
taken.add(name.toLowerCase());
|
|
105
|
+
return name;
|
|
106
|
+
}
|
|
107
|
+
/** Derives the verb for each custom method. */
|
|
108
|
+
function deriveCustomVerbs(spec, taken, skipped) {
|
|
109
|
+
const verbs = [];
|
|
110
|
+
for (const method of spec.methods?.customMethods ?? []) {
|
|
111
|
+
if (typeof method?.name !== 'string' || method.name.trim().length === 0) {
|
|
112
|
+
skipped.push({ Name: '(unnamed)', Reason: 'a custom method has no name' });
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const built = buildParametersSchema(method);
|
|
116
|
+
if ('Problem' in built) {
|
|
117
|
+
skipped.push({ Name: method.name, Reason: built.Problem });
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const returns = method.returnType && method.returnType !== 'void' ? ` Returns ${method.returnType}.` : '';
|
|
121
|
+
verbs.push({
|
|
122
|
+
Verb: {
|
|
123
|
+
Name: customVerbName(method.name, taken),
|
|
124
|
+
Description: `${method.description || `Calls the component's ${method.name} method.`}${returns}`,
|
|
125
|
+
ParametersSchema: built.Schema,
|
|
126
|
+
InvokableBy: 'both',
|
|
127
|
+
// Unsure what a method hands back, so a method that returns anything is treated as returning the component's data.
|
|
128
|
+
...(returnsData(method) ? { ReturnsChannelData: 'state' } : {}),
|
|
129
|
+
},
|
|
130
|
+
Binding: { Kind: 'custom', Method: method.name, ParameterNames: built.Names },
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return verbs;
|
|
134
|
+
}
|
|
135
|
+
/** Return types that carry nothing back. Anything else is treated as a result that carries the component's data. */
|
|
136
|
+
const VOID_RETURN_TYPES = new Set(['', 'void', 'undefined', 'null', 'never', 'promise<void>', 'promise<undefined>']);
|
|
137
|
+
/** Whether a custom method returns something (and so needs `state` exposure to be given to the agent). */
|
|
138
|
+
function returnsData(method) {
|
|
139
|
+
return !VOID_RETURN_TYPES.has((method.returnType ?? '').trim().toLowerCase());
|
|
140
|
+
}
|
|
141
|
+
/** A verb with no parameters. */
|
|
142
|
+
function noParameters() {
|
|
143
|
+
return { type: 'object', properties: {}, additionalProperties: false };
|
|
144
|
+
}
|
|
145
|
+
/** The standard verbs, in the order they are described. Each is present only when the spec says the component supports it. */
|
|
146
|
+
function deriveStandardVerbs(spec) {
|
|
147
|
+
const supported = spec.methods?.standardMethodsSupported ?? {};
|
|
148
|
+
const standard = (key, description, schema = noParameters(), returnsChannelData) => ({
|
|
149
|
+
Verb: { Name: STANDARD_VERBS[key], Description: description, ParametersSchema: schema, InvokableBy: 'both', ...(returnsChannelData ? { ReturnsChannelData: returnsChannelData } : {}) },
|
|
150
|
+
Binding: { Kind: 'standard', Standard: key },
|
|
151
|
+
});
|
|
152
|
+
const verbs = [];
|
|
153
|
+
if (supported.refresh) {
|
|
154
|
+
verbs.push(standard('Refresh', 'Reloads the component\'s data.'));
|
|
155
|
+
}
|
|
156
|
+
if (supported.getCurrentDataState) {
|
|
157
|
+
verbs.push(standard('GetDataState', 'Reads what the component is showing right now (its data state: tables, rows, filters). Use it when you need detail the state notes do not carry.', noParameters(), 'state'));
|
|
158
|
+
}
|
|
159
|
+
if (supported.validate) {
|
|
160
|
+
verbs.push(standard('Validate', 'Checks whether what the user entered is valid; reports the problems.', noParameters(), 'state'));
|
|
161
|
+
}
|
|
162
|
+
if (supported.isDirty) {
|
|
163
|
+
verbs.push(standard('IsDirty', 'Reports whether the user has unsaved changes in the component.', noParameters(), 'state'));
|
|
164
|
+
}
|
|
165
|
+
if (supported.reset) {
|
|
166
|
+
verbs.push(standard('Reset', 'Discards the user\'s changes and returns the component to its initial state.'));
|
|
167
|
+
}
|
|
168
|
+
if (supported.print) {
|
|
169
|
+
verbs.push(standard('Print', 'Opens the browser\'s print dialog for the component.'));
|
|
170
|
+
}
|
|
171
|
+
if (supported.scrollTo) {
|
|
172
|
+
verbs.push(standard('ScrollTo', 'Scrolls the component to an element (a CSS selector) or position.', {
|
|
173
|
+
type: 'object',
|
|
174
|
+
properties: {
|
|
175
|
+
target: { type: 'string', description: 'A CSS selector of the element to scroll to.' },
|
|
176
|
+
top: { type: 'number', description: 'Vertical scroll offset in pixels (instead of a target).' },
|
|
177
|
+
left: { type: 'number', description: 'Horizontal scroll offset in pixels (instead of a target).' },
|
|
178
|
+
},
|
|
179
|
+
additionalProperties: false,
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
if (supported.focus) {
|
|
183
|
+
verbs.push(standard('Focus', 'Moves keyboard focus to an element inside the component.', {
|
|
184
|
+
type: 'object',
|
|
185
|
+
properties: { target: { type: 'string', description: 'A CSS selector of the element to focus (default: the component\'s first focusable element).' } },
|
|
186
|
+
additionalProperties: false,
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
return verbs;
|
|
190
|
+
}
|
|
191
|
+
/** The event specs from the component's declared events. */
|
|
192
|
+
function deriveEvents(spec) {
|
|
193
|
+
const events = [];
|
|
194
|
+
for (const event of spec.events ?? []) {
|
|
195
|
+
if (typeof event?.name !== 'string' || event.name.length === 0) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const properties = {};
|
|
199
|
+
for (const parameter of event.parameters ?? []) {
|
|
200
|
+
const schema = schemaForTypeName(parameter.type ?? 'any') ?? {};
|
|
201
|
+
properties[parameter.name] = { ...schema, description: parameter.description };
|
|
202
|
+
}
|
|
203
|
+
events.push({
|
|
204
|
+
Name: event.name,
|
|
205
|
+
Description: event.description,
|
|
206
|
+
PayloadSchema: { type: 'object', properties },
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return events;
|
|
210
|
+
}
|
|
211
|
+
/** The schema of the opening `inputs`, from the spec's `properties`. Function-typed properties (callbacks) cannot be supplied by a model and are left out. */
|
|
212
|
+
function deriveInputsSchema(spec) {
|
|
213
|
+
const properties = {};
|
|
214
|
+
const required = [];
|
|
215
|
+
for (const property of spec.properties ?? []) {
|
|
216
|
+
const schema = schemaForTypeName(property.type ?? 'any');
|
|
217
|
+
if (schema === null || typeof property.name !== 'string' || property.name.length === 0) {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const described = { ...schema, description: property.description };
|
|
221
|
+
if (Array.isArray(property.possibleValues) && property.possibleValues.length > 0 && schema['type'] === 'string') {
|
|
222
|
+
described['enum'] = property.possibleValues;
|
|
223
|
+
}
|
|
224
|
+
properties[property.name] = described;
|
|
225
|
+
if (property.required) {
|
|
226
|
+
required.push(property.name);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const schema = { type: 'object', properties };
|
|
230
|
+
if (required.length > 0) {
|
|
231
|
+
schema['required'] = required;
|
|
232
|
+
}
|
|
233
|
+
return schema;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Derives the full contract of one component from its spec.
|
|
237
|
+
*
|
|
238
|
+
* @param spec The component's specification.
|
|
239
|
+
*/
|
|
240
|
+
export function DeriveComponentContract(spec) {
|
|
241
|
+
const skipped = [];
|
|
242
|
+
const standardVerbs = deriveStandardVerbs(spec);
|
|
243
|
+
const taken = new Set(standardVerbs.map((v) => v.Verb.Name.toLowerCase()));
|
|
244
|
+
return {
|
|
245
|
+
Verbs: [...standardVerbs, ...deriveCustomVerbs(spec, taken, skipped)],
|
|
246
|
+
Events: deriveEvents(spec),
|
|
247
|
+
InputsSchema: deriveInputsSchema(spec),
|
|
248
|
+
SupportsDataState: spec.methods?.standardMethodsSupported?.getCurrentDataState === true,
|
|
249
|
+
Skipped: skipped,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/** Whether a verb schema is the permissive one a merge produces. */
|
|
253
|
+
function schemaProperties(verb) {
|
|
254
|
+
const properties = verb.ParametersSchema['properties'];
|
|
255
|
+
return properties !== null && typeof properties === 'object' && !Array.isArray(properties) ? properties : {};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Merges the same verb offered by several open components into the single verb the channel declares.
|
|
259
|
+
*
|
|
260
|
+
* Verbs from different components can share a name with different parameters (two components that both have
|
|
261
|
+
* `setFilter`). The channel declares one verb per name; its schema is the UNION of the parameters with nothing
|
|
262
|
+
* required, so a call that suits any of them passes the dispatcher, and the exact per-component check
|
|
263
|
+
* (against that component's own schema) happens when the verb runs. The description lists each component's signature.
|
|
264
|
+
*
|
|
265
|
+
* @param offers Each component's verb of this name, with the component's display name.
|
|
266
|
+
*/
|
|
267
|
+
export function MergeVerbOffers(offers) {
|
|
268
|
+
if (offers.length === 1) {
|
|
269
|
+
return { ...offers[0].Verb };
|
|
270
|
+
}
|
|
271
|
+
const properties = {};
|
|
272
|
+
for (const offer of offers) {
|
|
273
|
+
for (const [name, schema] of Object.entries(schemaProperties(offer.Verb))) {
|
|
274
|
+
if (!(name in properties)) {
|
|
275
|
+
properties[name] = schema;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// The dispatcher checks the merged verb, so it may refuse only what EVERY component would refuse; the exact check against
|
|
280
|
+
// the addressed component happens when the verb runs.
|
|
281
|
+
const levels = offers.map((offer) => offer.Verb.ReturnsChannelData);
|
|
282
|
+
const returnsChannelData = levels.every((level) => level !== undefined) ? (levels.includes('state') ? 'state' : 'pixels') : undefined;
|
|
283
|
+
const signatures = offers.map((offer) => `${offer.Component}: ${Object.keys(schemaProperties(offer.Verb)).join(', ') || '(no parameters)'}`);
|
|
284
|
+
return {
|
|
285
|
+
Name: offers[0].Verb.Name,
|
|
286
|
+
Description: `${offers[0].Verb.Description} Several open components have this action; pass the instance you mean. Parameters per component — ${signatures.join('; ')}.`,
|
|
287
|
+
ParametersSchema: { type: 'object', properties, additionalProperties: false },
|
|
288
|
+
InvokableBy: 'both',
|
|
289
|
+
...(returnsChannelData ? { ReturnsChannelData: returnsChannelData } : {}),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=component-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-contract.js","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/interactive-component/component-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAqC9E,iFAAiF;AACjF,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC;IACrD,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;IAC/B,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;IAChC,MAAM;CACT,CAAC,CAAC;AAEH,yGAAyG;AACzG,SAAS,iBAAiB,CAAC,QAAgB;IACvC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChE,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC9B,CAAC;IACD,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC9B,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACvC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,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S,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACtI,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;IAC7I,OAAO;QACH,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI;QACzB,WAAW,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,qGAAqG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QACvK,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,EAAE;QAC7E,WAAW,EAAE,MAAM;QACnB,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5E,CAAC;AACN,CAAC","sourcesContent":["/**\n * @fileoverview Derives what an agent can do with a component from the component's own specification.\n *\n * A component artifact already says what it accepts and emits: its `properties` (inputs), its `events`, and its\n * `methods` (standard methods it supports plus custom ones with typed parameters). This module turns that into the\n * channel contract's vocabulary, so an agent can operate a component nobody wrote channel code for:\n *\n * | spec | contract |\n * |---|---|\n * | `methods.customMethods[]` | a verb per method, parameters schema from the declared parameter types |\n * | `methods.standardMethodsSupported` | `refresh`, `print`, `validate`, `is_dirty`, `reset`, `scroll_to`, `focus`, and `get_data_state` |\n * | `methods.standardMethodsSupported.getCurrentDataState` | the instance's `data` in the channel's state (the noun) |\n * | `events[]` | channel events, payload schema from the event parameters |\n * | `properties[]` | the schema of the `inputs` accepted when opening it |\n *\n * A verb whose result carries what the component holds (`get_data_state`, `validate`, `is_dirty`, and any custom method that\n * returns something) is marked `ReturnsChannelData: 'state'`, so the agent is refused it when it may not perceive the\n * component's state (see `RealtimeChannelVerb.ReturnsChannelData`).\n *\n * Pure functions over plain data: no component is rendered and nothing is invoked here.\n *\n * @module @memberjunction/ng-conversations\n */\n\nimport type { JSONObject } from '@memberjunction/ai';\nimport type { RealtimeChannelEventSpec, RealtimeChannelSchema, RealtimeChannelVerb } from '@memberjunction/ai-core-plus';\nimport type { ComponentSpec, CustomComponentMethod } from '@memberjunction/interactive-component-types';\nimport { STANDARD_VERBS, BUILTIN_VERBS } from './interactive-component-types';\n\n/** How a verb reaches the component. */\nexport type VerbBinding =\n | { Kind: 'standard'; Standard: keyof typeof STANDARD_VERBS }\n | { Kind: 'custom'; Method: string; ParameterNames: string[] };\n\n/** One verb derived from a spec, with how to run it. */\nexport interface DerivedVerb {\n /** The verb as the agent sees it. */\n Verb: RealtimeChannelVerb;\n /** How the channel runs it. */\n Binding: VerbBinding;\n}\n\n/** A method the contract could not expose, and why (kept so a spec problem is visible rather than silently dropped). */\nexport interface SkippedMethod {\n /** The method's name. */\n Name: string;\n /** Why it was not exposed. */\n Reason: string;\n}\n\n/** Everything an agent can do with one component, derived from its spec. */\nexport interface ComponentContract {\n /** The verbs, standard and custom. */\n Verbs: DerivedVerb[];\n /** The events the component can emit. */\n Events: RealtimeChannelEventSpec[];\n /** The schema of the `inputs` accepted when opening it (from the spec's `properties`). */\n InputsSchema: RealtimeChannelSchema;\n /** Whether the component reports a data state (`getCurrentDataState` is supported), i.e. whether the instance has `data` to describe. */\n SupportsDataState: boolean;\n /** Methods that could not be exposed. */\n Skipped: SkippedMethod[];\n}\n\n/** Verb names that belong to the channel, which a custom method may not take. */\nconst RESERVED_VERB_NAMES: ReadonlySet<string> = new Set([\n ...Object.values(BUILTIN_VERBS),\n ...Object.values(STANDARD_VERBS),\n 'open',\n]);\n\n/** The JSON-schema for a type name as a spec author writes it, or `null` when it cannot be expressed. */\nfunction schemaForTypeName(typeName: string): JSONObject | null {\n const type = typeName.trim().toLowerCase().replace(/\\s+/g, ' ');\n if (type === 'string') {\n return { type: 'string' };\n }\n if (type === 'number' || type === 'float' || type === 'double') {\n return { type: 'number' };\n }\n if (type === 'integer' || type === 'int') {\n return { type: 'integer' };\n }\n if (type === 'boolean' || type === 'bool') {\n return { type: 'boolean' };\n }\n if (type === 'date' || type === 'datetime') {\n return { type: 'string', format: 'date-time' };\n }\n if (type === 'array' || type.startsWith('array<') || type.endsWith('[]')) {\n return { type: 'array' };\n }\n if (type === 'object' || type.startsWith('record<') || type.startsWith('{')) {\n return { type: 'object' };\n }\n return type === 'function' ? null : {};\n}\n\n/** Whether a method parameter is optional, judged from its name, type and description. */\nfunction isOptionalParameter(parameter: { name: string; type: string; description?: string }): boolean {\n return (\n parameter.name.trim().endsWith('?') ||\n /\\bundefined\\b/i.test(parameter.type) ||\n /^\\s*optional\\b/i.test(parameter.description ?? '')\n );\n}\n\n/** The bare parameter name (a trailing `?` marks it optional and is not part of the name). */\nfunction parameterName(parameter: { name: string }): string {\n return parameter.name.trim().replace(/\\?$/, '');\n}\n\n/** Builds the parameters schema of a custom method; `null` when a required parameter cannot be passed by a model (a function). */\nfunction buildParametersSchema(method: CustomComponentMethod): { Schema: RealtimeChannelSchema; Names: string[] } | { Problem: string } {\n const properties: JSONObject = {};\n const required: string[] = [];\n const names: string[] = [];\n for (const parameter of method.parameters ?? []) {\n const name = parameterName(parameter);\n const schema = schemaForTypeName(parameter.type ?? '');\n const optional = isOptionalParameter(parameter);\n if (schema === null) {\n if (!optional) {\n return { Problem: `parameter \"${name}\" is a function, which an agent cannot pass` };\n }\n continue;\n }\n const described: JSONObject = { ...schema, description: parameter.description ?? `${name} (${parameter.type})` };\n if (Object.keys(schema).length === 0) {\n described['description'] = `${parameter.description ?? name} (declared type: ${parameter.type})`;\n }\n properties[name] = described;\n names.push(name);\n if (!optional) {\n required.push(name);\n }\n }\n const schema: RealtimeChannelSchema = { type: 'object', properties, additionalProperties: false };\n if (required.length > 0) {\n schema['required'] = required;\n }\n return { Schema: schema, Names: names };\n}\n\n/** The verb name for a custom method: its own name, unless that is taken by the channel. */\nfunction customVerbName(method: string, taken: Set<string>): string {\n let name = method;\n if (RESERVED_VERB_NAMES.has(name.toLowerCase()) || taken.has(name.toLowerCase())) {\n name = `custom_${method}`;\n }\n taken.add(name.toLowerCase());\n return name;\n}\n\n/** Derives the verb for each custom method. */\nfunction deriveCustomVerbs(spec: ComponentSpec, taken: Set<string>, skipped: SkippedMethod[]): DerivedVerb[] {\n const verbs: DerivedVerb[] = [];\n for (const method of spec.methods?.customMethods ?? []) {\n if (typeof method?.name !== 'string' || method.name.trim().length === 0) {\n skipped.push({ Name: '(unnamed)', Reason: 'a custom method has no name' });\n continue;\n }\n const built = buildParametersSchema(method);\n if ('Problem' in built) {\n skipped.push({ Name: method.name, Reason: built.Problem });\n continue;\n }\n const returns = method.returnType && method.returnType !== 'void' ? ` Returns ${method.returnType}.` : '';\n verbs.push({\n Verb: {\n Name: customVerbName(method.name, taken),\n Description: `${method.description || `Calls the component's ${method.name} method.`}${returns}`,\n ParametersSchema: built.Schema,\n InvokableBy: 'both',\n // Unsure what a method hands back, so a method that returns anything is treated as returning the component's data.\n ...(returnsData(method) ? { ReturnsChannelData: 'state' as const } : {}),\n },\n Binding: { Kind: 'custom', Method: method.name, ParameterNames: built.Names },\n });\n }\n return verbs;\n}\n\n/** Return types that carry nothing back. Anything else is treated as a result that carries the component's data. */\nconst VOID_RETURN_TYPES: ReadonlySet<string> = new Set(['', 'void', 'undefined', 'null', 'never', 'promise<void>', 'promise<undefined>']);\n\n/** Whether a custom method returns something (and so needs `state` exposure to be given to the agent). */\nfunction returnsData(method: CustomComponentMethod): boolean {\n return !VOID_RETURN_TYPES.has((method.returnType ?? '').trim().toLowerCase());\n}\n\n/** A verb with no parameters. */\nfunction noParameters(): RealtimeChannelSchema {\n return { type: 'object', properties: {}, additionalProperties: false };\n}\n\n/** The standard verbs, in the order they are described. Each is present only when the spec says the component supports it. */\nfunction deriveStandardVerbs(spec: ComponentSpec): DerivedVerb[] {\n const supported = spec.methods?.standardMethodsSupported ?? {};\n const standard = (\n key: keyof typeof STANDARD_VERBS,\n description: string,\n schema: RealtimeChannelSchema = noParameters(),\n returnsChannelData?: 'state'\n ): DerivedVerb => ({\n Verb: { Name: STANDARD_VERBS[key], Description: description, ParametersSchema: schema, InvokableBy: 'both', ...(returnsChannelData ? { ReturnsChannelData: returnsChannelData } : {}) },\n Binding: { Kind: 'standard', Standard: key },\n });\n const verbs: DerivedVerb[] = [];\n if (supported.refresh) {\n verbs.push(standard('Refresh', 'Reloads the component\\'s data.'));\n }\n if (supported.getCurrentDataState) {\n verbs.push(standard('GetDataState', 'Reads what the component is showing right now (its data state: tables, rows, filters). Use it when you need detail the state notes do not carry.', noParameters(), 'state'));\n }\n if (supported.validate) {\n verbs.push(standard('Validate', 'Checks whether what the user entered is valid; reports the problems.', noParameters(), 'state'));\n }\n if (supported.isDirty) {\n verbs.push(standard('IsDirty', 'Reports whether the user has unsaved changes in the component.', noParameters(), 'state'));\n }\n if (supported.reset) {\n verbs.push(standard('Reset', 'Discards the user\\'s changes and returns the component to its initial state.'));\n }\n if (supported.print) {\n verbs.push(standard('Print', 'Opens the browser\\'s print dialog for the component.'));\n }\n if (supported.scrollTo) {\n verbs.push(\n standard('ScrollTo', 'Scrolls the component to an element (a CSS selector) or position.', {\n type: 'object',\n properties: {\n target: { type: 'string', description: 'A CSS selector of the element to scroll to.' },\n top: { type: 'number', description: 'Vertical scroll offset in pixels (instead of a target).' },\n left: { type: 'number', description: 'Horizontal scroll offset in pixels (instead of a target).' },\n },\n additionalProperties: false,\n })\n );\n }\n if (supported.focus) {\n verbs.push(\n standard('Focus', 'Moves keyboard focus to an element inside the component.', {\n type: 'object',\n properties: { target: { type: 'string', description: 'A CSS selector of the element to focus (default: the component\\'s first focusable element).' } },\n additionalProperties: false,\n })\n );\n }\n return verbs;\n}\n\n/** The event specs from the component's declared events. */\nfunction deriveEvents(spec: ComponentSpec): RealtimeChannelEventSpec[] {\n const events: RealtimeChannelEventSpec[] = [];\n for (const event of spec.events ?? []) {\n if (typeof event?.name !== 'string' || event.name.length === 0) {\n continue;\n }\n const properties: JSONObject = {};\n for (const parameter of event.parameters ?? []) {\n const schema = schemaForTypeName(parameter.type ?? 'any') ?? {};\n properties[parameter.name] = { ...schema, description: parameter.description };\n }\n events.push({\n Name: event.name,\n Description: event.description,\n PayloadSchema: { type: 'object', properties },\n });\n }\n return events;\n}\n\n/** The schema of the opening `inputs`, from the spec's `properties`. Function-typed properties (callbacks) cannot be supplied by a model and are left out. */\nfunction deriveInputsSchema(spec: ComponentSpec): RealtimeChannelSchema {\n const properties: JSONObject = {};\n const required: string[] = [];\n for (const property of spec.properties ?? []) {\n const schema = schemaForTypeName(property.type ?? 'any');\n if (schema === null || typeof property.name !== 'string' || property.name.length === 0) {\n continue;\n }\n const described: JSONObject = { ...schema, description: property.description };\n if (Array.isArray(property.possibleValues) && property.possibleValues.length > 0 && schema['type'] === 'string') {\n described['enum'] = property.possibleValues;\n }\n properties[property.name] = described;\n if (property.required) {\n required.push(property.name);\n }\n }\n const schema: RealtimeChannelSchema = { type: 'object', properties };\n if (required.length > 0) {\n schema['required'] = required;\n }\n return schema;\n}\n\n/**\n * Derives the full contract of one component from its spec.\n *\n * @param spec The component's specification.\n */\nexport function DeriveComponentContract(spec: ComponentSpec): ComponentContract {\n const skipped: SkippedMethod[] = [];\n const standardVerbs = deriveStandardVerbs(spec);\n const taken = new Set(standardVerbs.map((v) => v.Verb.Name.toLowerCase()));\n return {\n Verbs: [...standardVerbs, ...deriveCustomVerbs(spec, taken, skipped)],\n Events: deriveEvents(spec),\n InputsSchema: deriveInputsSchema(spec),\n SupportsDataState: spec.methods?.standardMethodsSupported?.getCurrentDataState === true,\n Skipped: skipped,\n };\n}\n\n/** Whether a verb schema is the permissive one a merge produces. */\nfunction schemaProperties(verb: RealtimeChannelVerb): JSONObject {\n const properties = verb.ParametersSchema['properties'];\n return properties !== null && typeof properties === 'object' && !Array.isArray(properties) ? (properties as JSONObject) : {};\n}\n\n/**\n * Merges the same verb offered by several open components into the single verb the channel declares.\n *\n * Verbs from different components can share a name with different parameters (two components that both have\n * `setFilter`). The channel declares one verb per name; its schema is the UNION of the parameters with nothing\n * required, so a call that suits any of them passes the dispatcher, and the exact per-component check\n * (against that component's own schema) happens when the verb runs. The description lists each component's signature.\n *\n * @param offers Each component's verb of this name, with the component's display name.\n */\nexport function MergeVerbOffers(offers: ReadonlyArray<{ Component: string; Verb: RealtimeChannelVerb }>): RealtimeChannelVerb {\n if (offers.length === 1) {\n return { ...offers[0].Verb };\n }\n const properties: JSONObject = {};\n for (const offer of offers) {\n for (const [name, schema] of Object.entries(schemaProperties(offer.Verb))) {\n if (!(name in properties)) {\n properties[name] = schema;\n }\n }\n }\n // The dispatcher checks the merged verb, so it may refuse only what EVERY component would refuse; the exact check against\n // the addressed component happens when the verb runs.\n const levels = offers.map((offer) => offer.Verb.ReturnsChannelData);\n const returnsChannelData = levels.every((level) => level !== undefined) ? (levels.includes('state') ? 'state' : 'pixels') : undefined;\n const signatures = offers.map((offer) => `${offer.Component}: ${Object.keys(schemaProperties(offer.Verb)).join(', ') || '(no parameters)'}`);\n return {\n Name: offers[0].Verb.Name,\n Description: `${offers[0].Verb.Description} Several open components have this action; pass the instance you mean. Parameters per component — ${signatures.join('; ')}.`,\n ParametersSchema: { type: 'object', properties, additionalProperties: false },\n InvokableBy: 'both',\n ...(returnsChannelData ? { ReturnsChannelData: returnsChannelData } : {}),\n };\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bounds a component's data state before it is described to the model.
|
|
3
|
+
*
|
|
4
|
+
* A component's `getCurrentDataState()` can hold thousands of rows. A perception note that carried them all
|
|
5
|
+
* would flood the model's context and, when the component shows private data, leak far more than the model
|
|
6
|
+
* needs to answer "what is the user looking at". This turns an arbitrary data state into a small JSON summary:
|
|
7
|
+
* the per-table row count and columns always, and only the first `MaxRows` rows; long strings are clipped;
|
|
8
|
+
* the whole thing is held under a character budget.
|
|
9
|
+
*
|
|
10
|
+
* The input is whatever the component returned, so it is treated as untrusted: it may be cyclic, hold functions,
|
|
11
|
+
* dates or class instances. The output is always plain JSON.
|
|
12
|
+
*
|
|
13
|
+
* @module @memberjunction/ng-conversations
|
|
14
|
+
*/
|
|
15
|
+
import type { JSONObject, JSONValue } from '@memberjunction/ai';
|
|
16
|
+
/** Limits applied to a data state. */
|
|
17
|
+
export interface DataStateLimits {
|
|
18
|
+
/** The most rows kept per table. */
|
|
19
|
+
MaxRows: number;
|
|
20
|
+
/** The most characters of the serialized summary; beyond it rows are dropped until it fits. */
|
|
21
|
+
MaxChars: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Converts one arbitrary value into JSON, bounded in depth, breadth and string length.
|
|
25
|
+
* Functions and symbols become a marker, dates their ISO string, cycles a marker.
|
|
26
|
+
*/
|
|
27
|
+
export declare function ToBoundedJson(value: unknown, depth?: number, seen?: WeakSet<object>): JSONValue;
|
|
28
|
+
/**
|
|
29
|
+
* Summarizes a component's data state for the model.
|
|
30
|
+
*
|
|
31
|
+
* The result is plain JSON no larger than `limits.MaxChars`: when the first attempt is over budget the per-table
|
|
32
|
+
* row cap is halved until it fits, down to zero rows (counts and columns only).
|
|
33
|
+
*
|
|
34
|
+
* @param state The value `getCurrentDataState()` returned (a `DataSnapshot` or anything else), or nothing.
|
|
35
|
+
* @param limits The row and size caps.
|
|
36
|
+
* @returns The summary, or `null` when the component has no data state.
|
|
37
|
+
*/
|
|
38
|
+
export declare function SummarizeDataState(state: object | null | undefined, limits: DataStateLimits): JSONObject | null;
|
|
39
|
+
//# sourceMappingURL=component-data-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-data-state.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/interactive-component/component-data-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEhE,sCAAsC;AACtC,MAAM,WAAW,eAAe;IAC5B,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,+FAA+F;IAC/F,QAAQ,EAAE,MAAM,CAAC;CACpB;AAmBD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,GAAE,MAAU,EAAE,IAAI,GAAE,OAAO,CAAC,MAAM,CAAiB,GAAG,SAAS,CAoBjH;AA6ED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,eAAe,GAAG,UAAU,GAAG,IAAI,CAc/G"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bounds a component's data state before it is described to the model.
|
|
3
|
+
*
|
|
4
|
+
* A component's `getCurrentDataState()` can hold thousands of rows. A perception note that carried them all
|
|
5
|
+
* would flood the model's context and, when the component shows private data, leak far more than the model
|
|
6
|
+
* needs to answer "what is the user looking at". This turns an arbitrary data state into a small JSON summary:
|
|
7
|
+
* the per-table row count and columns always, and only the first `MaxRows` rows; long strings are clipped;
|
|
8
|
+
* the whole thing is held under a character budget.
|
|
9
|
+
*
|
|
10
|
+
* The input is whatever the component returned, so it is treated as untrusted: it may be cyclic, hold functions,
|
|
11
|
+
* dates or class instances. The output is always plain JSON.
|
|
12
|
+
*
|
|
13
|
+
* @module @memberjunction/ng-conversations
|
|
14
|
+
*/
|
|
15
|
+
/** The deepest nesting kept; deeper values are replaced by a marker. */
|
|
16
|
+
const MAX_DEPTH = 5;
|
|
17
|
+
/** The longest string kept before it is clipped. */
|
|
18
|
+
const MAX_STRING_CHARS = 200;
|
|
19
|
+
/** The most keys kept per object or items per non-table array. */
|
|
20
|
+
const MAX_BREADTH = 30;
|
|
21
|
+
/** The most columns listed per table. */
|
|
22
|
+
const MAX_COLUMNS = 40;
|
|
23
|
+
/** Marker for a value the summary could not or would not carry. */
|
|
24
|
+
const OMITTED = '[omitted]';
|
|
25
|
+
/** True for a non-null object that is not an array. */
|
|
26
|
+
function isRecord(value) {
|
|
27
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Converts one arbitrary value into JSON, bounded in depth, breadth and string length.
|
|
31
|
+
* Functions and symbols become a marker, dates their ISO string, cycles a marker.
|
|
32
|
+
*/
|
|
33
|
+
export function ToBoundedJson(value, depth = 0, seen = new WeakSet()) {
|
|
34
|
+
if (value === null || value === undefined) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
switch (typeof value) {
|
|
38
|
+
case 'string':
|
|
39
|
+
return value.length > MAX_STRING_CHARS ? `${value.slice(0, MAX_STRING_CHARS)}… (${value.length} chars)` : value;
|
|
40
|
+
case 'number':
|
|
41
|
+
return Number.isFinite(value) ? value : null;
|
|
42
|
+
case 'boolean':
|
|
43
|
+
return value;
|
|
44
|
+
case 'bigint':
|
|
45
|
+
return value.toString();
|
|
46
|
+
case 'function':
|
|
47
|
+
case 'symbol':
|
|
48
|
+
return OMITTED;
|
|
49
|
+
default:
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
return objectToBoundedJson(value, depth, seen);
|
|
53
|
+
}
|
|
54
|
+
/** The object half of {@link ToBoundedJson}. */
|
|
55
|
+
function objectToBoundedJson(value, depth, seen) {
|
|
56
|
+
if (value instanceof Date) {
|
|
57
|
+
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
|
58
|
+
}
|
|
59
|
+
if (seen.has(value)) {
|
|
60
|
+
return '[circular]';
|
|
61
|
+
}
|
|
62
|
+
if (depth >= MAX_DEPTH) {
|
|
63
|
+
return '[too deep]';
|
|
64
|
+
}
|
|
65
|
+
seen.add(value);
|
|
66
|
+
try {
|
|
67
|
+
if (Array.isArray(value)) {
|
|
68
|
+
const items = value.slice(0, MAX_BREADTH).map((item) => ToBoundedJson(item, depth + 1, seen));
|
|
69
|
+
return value.length > MAX_BREADTH ? [...items, `… ${value.length - MAX_BREADTH} more`] : items;
|
|
70
|
+
}
|
|
71
|
+
const out = {};
|
|
72
|
+
for (const key of Object.keys(value).slice(0, MAX_BREADTH)) {
|
|
73
|
+
// Component state is untrusted; never copy a key that would reach Object.prototype.
|
|
74
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
out[key] = ToBoundedJson(value[key], depth + 1, seen);
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
seen.delete(value);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Summarizes one table-shaped entry (`{ name, columns, rows }`). */
|
|
86
|
+
function summarizeTable(table, index, maxRows) {
|
|
87
|
+
if (!isRecord(table)) {
|
|
88
|
+
return { name: `table ${index + 1}`, rowCount: 0 };
|
|
89
|
+
}
|
|
90
|
+
const rows = Array.isArray(table['rows']) ? table['rows'] : [];
|
|
91
|
+
const columns = Array.isArray(table['columns']) ? table['columns'] : [];
|
|
92
|
+
const columnNames = columns
|
|
93
|
+
.map((column) => (typeof column === 'string' ? column : isRecord(column) && typeof column['name'] === 'string' ? column['name'] : null))
|
|
94
|
+
.filter((name) => name !== null)
|
|
95
|
+
.slice(0, MAX_COLUMNS);
|
|
96
|
+
const summary = {
|
|
97
|
+
name: typeof table['name'] === 'string' ? table['name'] : `table ${index + 1}`,
|
|
98
|
+
rowCount: rows.length,
|
|
99
|
+
columns: columnNames,
|
|
100
|
+
rows: rows.slice(0, maxRows).map((row) => ToBoundedJson(row, 1)),
|
|
101
|
+
};
|
|
102
|
+
if (rows.length > maxRows) {
|
|
103
|
+
summary['rowsOmitted'] = rows.length - maxRows;
|
|
104
|
+
}
|
|
105
|
+
return summary;
|
|
106
|
+
}
|
|
107
|
+
/** Builds the summary with at most `maxRows` rows per table. */
|
|
108
|
+
function buildSummary(state, maxRows) {
|
|
109
|
+
const summary = {};
|
|
110
|
+
for (const key of ['title', 'activeTab', 'searchText', 'interpretation']) {
|
|
111
|
+
const value = state[key];
|
|
112
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
113
|
+
summary[key] = ToBoundedJson(value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (Array.isArray(state['drillPath']) && state['drillPath'].length > 0) {
|
|
117
|
+
summary['drillPath'] = ToBoundedJson(state['drillPath']);
|
|
118
|
+
}
|
|
119
|
+
if (Array.isArray(state['tables'])) {
|
|
120
|
+
summary['tables'] = state['tables'].slice(0, MAX_BREADTH).map((table, i) => summarizeTable(table, i, maxRows));
|
|
121
|
+
}
|
|
122
|
+
if (isRecord(state['custom']) && Object.keys(state['custom']).length > 0) {
|
|
123
|
+
summary['custom'] = ToBoundedJson(state['custom']);
|
|
124
|
+
}
|
|
125
|
+
return summary;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Summarizes a component's data state for the model.
|
|
129
|
+
*
|
|
130
|
+
* The result is plain JSON no larger than `limits.MaxChars`: when the first attempt is over budget the per-table
|
|
131
|
+
* row cap is halved until it fits, down to zero rows (counts and columns only).
|
|
132
|
+
*
|
|
133
|
+
* @param state The value `getCurrentDataState()` returned (a `DataSnapshot` or anything else), or nothing.
|
|
134
|
+
* @param limits The row and size caps.
|
|
135
|
+
* @returns The summary, or `null` when the component has no data state.
|
|
136
|
+
*/
|
|
137
|
+
export function SummarizeDataState(state, limits) {
|
|
138
|
+
if (!isRecord(state)) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
let rows = Math.max(0, Math.floor(limits.MaxRows));
|
|
142
|
+
let summary = buildSummary(state, rows);
|
|
143
|
+
while (rows > 0 && JSON.stringify(summary).length > limits.MaxChars) {
|
|
144
|
+
rows = Math.floor(rows / 2);
|
|
145
|
+
summary = buildSummary(state, rows);
|
|
146
|
+
}
|
|
147
|
+
if (JSON.stringify(summary).length > limits.MaxChars) {
|
|
148
|
+
return { truncated: true, note: `The data state is larger than ${limits.MaxChars} characters; ask for specifics.` };
|
|
149
|
+
}
|
|
150
|
+
return summary;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=component-data-state.js.map
|