@devicechain/dashboards 0.19.0-rc.1 → 0.20.0-rc.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 +18 -6
- package/dist/bindings.d.ts +2 -1
- package/dist/channel-snapshots.d.ts +26 -0
- package/dist/definition.d.ts +10 -2
- package/dist/editor-model.d.ts +3 -2
- package/dist/history.d.ts +2 -2
- package/dist/hub.d.ts +1 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +1701 -80
- package/dist/index.js.map +4 -4
- package/dist/option-schema.d.ts +86 -0
- package/dist/recorded.d.ts +80 -0
- package/dist/recording.d.ts +104 -0
- package/dist/slots.d.ts +1 -1
- package/dist/types.d.ts +45 -2
- package/dist/widget-catalog.d.ts +19 -0
- package/dist/widget-compat.d.ts +16 -0
- package/dist/widget-descriptor.d.ts +91 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -29,20 +29,24 @@ device" into what reads like an outage.
|
|
|
29
29
|
One hub serves a whole board. Widgets subscribe to it; it does the deduplication.
|
|
30
30
|
|
|
31
31
|
```ts
|
|
32
|
-
import { DashboardHub } from '@devicechain/dashboards';
|
|
32
|
+
import { DashboardHub, resolveWidgetDatasource } from '@devicechain/dashboards';
|
|
33
33
|
|
|
34
34
|
const hub = new DashboardHub({
|
|
35
35
|
resolver, // how a selector becomes device tokens
|
|
36
|
-
bindings, // slot name -> concrete entity, for templated boards
|
|
37
36
|
authorities: user.scopes, // what this viewer may do; drives hub.can(...)
|
|
38
37
|
});
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
// The hub holds no slot bindings: resolve a widget's `slot` selector through them
|
|
40
|
+
// first. A slot with no binding resolves to an explicit `unbound` selector, which the
|
|
41
|
+
// hub answers with no data; a raw `slot` selector is an error.
|
|
42
|
+
// It is undefined only for a widget that declares no datasource at all.
|
|
43
|
+
const datasource = resolveWidgetDatasource(widget.datasource, bindings);
|
|
44
|
+
const stop = datasource && hub.subscribeWidget(datasource, {
|
|
41
45
|
next: (sample) => setLatest(sample),
|
|
42
46
|
});
|
|
43
47
|
|
|
44
48
|
// later
|
|
45
|
-
stop();
|
|
49
|
+
stop?.();
|
|
46
50
|
hub.disposeAll();
|
|
47
51
|
```
|
|
48
52
|
|
|
@@ -84,8 +88,16 @@ and the `editor-model` transforms (`addWidget`, `setWidgetBox`, `deleteWidget`,
|
|
|
84
88
|
A board can be written once and pointed at many entities. A widget's datasource
|
|
85
89
|
may name a **slot** instead of a device, and the host supplies a binding for that
|
|
86
90
|
slot at view time — `effectiveBindings`, `resolveContextBindings`,
|
|
87
|
-
`applySelection` and `resolveSlotCandidates` are the machinery
|
|
88
|
-
|
|
91
|
+
`applySelection` and `resolveSlotCandidates` are the machinery.
|
|
92
|
+
|
|
93
|
+
The hub holds no bindings. A slot is resolved to a concrete selector before it
|
|
94
|
+
is subscribed — `resolveWidgetDatasource(datasource, bindings)`, which the
|
|
95
|
+
`DashboardRenderer` in `@devicechain/widgets` calls for every widget — so one
|
|
96
|
+
hub serves a board for its whole life, and re-pointing a slot re-subscribes only
|
|
97
|
+
the widgets bound to it. A slot with no binding resolves to `{ kind: 'unbound' }`,
|
|
98
|
+
which every channel treats as zero devices; it is never turned into an absent
|
|
99
|
+
datasource, which the alarm channel reads as tenant-wide. A raw `slot` selector
|
|
100
|
+
handed straight to the hub is an error.
|
|
89
101
|
|
|
90
102
|
## Synthetic data
|
|
91
103
|
|
package/dist/bindings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DashboardDefinition, SlotBinding } from './types';
|
|
1
|
+
import type { DashboardDefinition, DatasourceSelector, SlotBinding } from './types';
|
|
2
2
|
export declare function effectiveBindings(definition: DashboardDefinition, manifest?: Record<string, SlotBinding>): Record<string, SlotBinding>;
|
|
3
3
|
export interface ParsedBindingManifest {
|
|
4
4
|
bindings: Record<string, SlotBinding>;
|
|
@@ -6,3 +6,4 @@ export interface ParsedBindingManifest {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function parseBindingManifest(raw: unknown): ParsedBindingManifest;
|
|
8
8
|
export declare function stripDefaultBindings(def: DashboardDefinition): DashboardDefinition;
|
|
9
|
+
export declare function resolveWidgetDatasource(datasource: DatasourceSelector | undefined, bindings: Record<string, SlotBinding> | undefined): DatasourceSelector | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AlarmRow, CommandRow, LocationSample, MeasurementSample } from './types';
|
|
2
|
+
export interface MeasurementStreamState {
|
|
3
|
+
latest: Record<string, MeasurementSample>;
|
|
4
|
+
samples: MeasurementSample[];
|
|
5
|
+
error: unknown | null;
|
|
6
|
+
}
|
|
7
|
+
export interface AlarmStreamState {
|
|
8
|
+
alarms: AlarmRow[];
|
|
9
|
+
total: number;
|
|
10
|
+
loading: boolean;
|
|
11
|
+
error: unknown | null;
|
|
12
|
+
}
|
|
13
|
+
export interface CommandStreamState {
|
|
14
|
+
deviceToken: string | null;
|
|
15
|
+
commands: CommandRow[];
|
|
16
|
+
total: number;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
error: unknown | null;
|
|
19
|
+
}
|
|
20
|
+
export interface LocationStreamState {
|
|
21
|
+
locations: LocationSample[];
|
|
22
|
+
deviceTokens: string[];
|
|
23
|
+
forbidden: boolean;
|
|
24
|
+
loading: boolean;
|
|
25
|
+
error: unknown | null;
|
|
26
|
+
}
|
package/dist/definition.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import { type Breakpoints, type DashboardDefinition, type SlotBinding, type SlotDefinition, type WidgetBox, type WidgetLayout } from './types';
|
|
1
|
+
import { type Breakpoints, type DashboardDefinition, type ExtensionWidgetInstance, type KnownWidgetInstance, type SlotBinding, type SlotDefinition, type WidgetBox, type WidgetLayout } from './types';
|
|
2
|
+
import type { WidgetCatalog } from './widget-catalog';
|
|
2
3
|
export declare const BASE_BREAKPOINT = "base";
|
|
3
4
|
export declare class DashboardDefinitionError extends Error {
|
|
4
5
|
constructor(message: string);
|
|
5
6
|
}
|
|
6
|
-
export
|
|
7
|
+
export interface ParseDefinitionOptions {
|
|
8
|
+
catalog?: WidgetCatalog;
|
|
9
|
+
}
|
|
10
|
+
export declare function parseDashboardDefinition(raw: unknown, options?: ParseDefinitionOptions): DashboardDefinition;
|
|
7
11
|
export declare function canScopeSlot(slots: Record<string, SlotDefinition>, child: string, parentName: string): boolean;
|
|
8
12
|
export declare function parseSlotBinding(raw: unknown): SlotBinding | undefined;
|
|
13
|
+
export type StoredDashboardDefinition = Omit<DashboardDefinition, 'widgets'> & {
|
|
14
|
+
widgets: Array<KnownWidgetInstance | ExtensionWidgetInstance | Record<string, unknown>>;
|
|
15
|
+
};
|
|
16
|
+
export declare function storedDefinition(def: DashboardDefinition): StoredDashboardDefinition;
|
|
9
17
|
export declare function serializeDefinition(def: DashboardDefinition): string;
|
|
10
18
|
export declare function isDirty(a: DashboardDefinition, b: DashboardDefinition): boolean;
|
|
11
19
|
export declare function resolveWidgetBox(layout: WidgetLayout, breakpoint: string): WidgetBox;
|
package/dist/editor-model.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { CanvasGrid, CanvasSizing, DashboardDefinition, WidgetBox, WidgetInstance
|
|
1
|
+
import type { CanvasGrid, CanvasSizing, DashboardDefinition, WidgetBox, WidgetInstance } from './types';
|
|
2
|
+
import type { WidgetDescriptor } from './widget-descriptor';
|
|
2
3
|
export declare function baseBox(widget: WidgetInstance): WidgetBox;
|
|
3
4
|
export declare function setWidgetBox(def: DashboardDefinition, id: string, box: WidgetBox): DashboardDefinition;
|
|
4
5
|
export declare function deleteWidget(def: DashboardDefinition, id: string): DashboardDefinition;
|
|
@@ -7,7 +8,7 @@ export declare function setTitle(def: DashboardDefinition, title: string): Dashb
|
|
|
7
8
|
export declare function setCanvasGrid(def: DashboardDefinition, patch: Partial<CanvasGrid>): DashboardDefinition;
|
|
8
9
|
export declare function setCanvasSizing(def: DashboardDefinition, sizing: CanvasSizing): DashboardDefinition;
|
|
9
10
|
export declare function updateWidget(def: DashboardDefinition, id: string, next: WidgetInstance): DashboardDefinition;
|
|
10
|
-
export declare function addWidget(def: DashboardDefinition,
|
|
11
|
+
export declare function addWidget(def: DashboardDefinition, descriptor: Pick<WidgetDescriptor, 'id' | 'defaults' | 'version' | 'optionsVersion' | 'sdkApiVersion'>): {
|
|
11
12
|
definition: DashboardDefinition;
|
|
12
13
|
id: string;
|
|
13
14
|
};
|
package/dist/history.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { MeasurementSample,
|
|
1
|
+
import type { MeasurementSample, WidgetInstance } from './types';
|
|
2
2
|
export interface HistoryWindow {
|
|
3
3
|
startTime: string;
|
|
4
4
|
endTime: string;
|
|
5
5
|
intervalSeconds: number;
|
|
6
6
|
}
|
|
7
7
|
export declare function defaultHistoryWindow(): HistoryWindow;
|
|
8
|
-
export declare function fetchWidgetHistory(widget: WidgetInstance, window: HistoryWindow
|
|
8
|
+
export declare function fetchWidgetHistory(widget: WidgetInstance, window: HistoryWindow): Promise<MeasurementSample[]>;
|
package/dist/hub.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AlarmRow, AnchorTarget, CommandRow, DatasourceSelector, LocationSample, MeasurementSample
|
|
1
|
+
import type { AlarmRow, AnchorTarget, CommandRow, DatasourceSelector, LocationSample, MeasurementSample } from './types';
|
|
2
2
|
export interface DeviceResolver {
|
|
3
3
|
devicesForAnchor(anchor: AnchorTarget): Promise<string[]>;
|
|
4
4
|
deviceExists(deviceToken: string): Promise<boolean>;
|
|
@@ -65,7 +65,6 @@ export interface WidgetActions {
|
|
|
65
65
|
}
|
|
66
66
|
export interface DashboardHubConfig {
|
|
67
67
|
resolver: DeviceResolver;
|
|
68
|
-
bindings?: Record<string, SlotBinding>;
|
|
69
68
|
authorities?: string[];
|
|
70
69
|
}
|
|
71
70
|
export interface WidgetDataSource {
|
|
@@ -84,9 +83,7 @@ export declare class DashboardHub implements WidgetDataSource, WidgetActions {
|
|
|
84
83
|
private readonly alarmDisposers;
|
|
85
84
|
private readonly commandDisposers;
|
|
86
85
|
private readonly locationDisposers;
|
|
87
|
-
private bindings;
|
|
88
86
|
constructor(config: DashboardHubConfig);
|
|
89
|
-
setBindings(bindings: Record<string, SlotBinding>): void;
|
|
90
87
|
subscribeWidget(datasource: DatasourceSelector, sink: WidgetStreamSink): () => void;
|
|
91
88
|
subscribeAlarms(subscription: AlarmSubscription, sink: AlarmStreamSink): () => void;
|
|
92
89
|
private resolveAlarmScope;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
export type { DashboardDefinition, Canvas, CanvasBackground, CanvasGrid, CanvasSizing, Breakpoints, WidgetInstance, WidgetType, WidgetLayout, WidgetBox, DatasourceSelector, DeviceSelector, AnchorSelector, AnchorTarget, AnchorAggregation, DevicesSelector, RelatedTraversalSelector, SlotSelector, SlotDefinition, SlotScope, SlotBinding, SelectionTarget, SelectionCandidate, EntityCandidateLister, EntityListKind, MeasurementSample, LocationSample, LocationSeries, LocationSelection, AlarmRow, CommandRow, CommandParameter, CommandParamDataType, } from './types';
|
|
1
|
+
export type { DashboardDefinition, Canvas, CanvasBackground, CanvasGrid, CanvasSizing, Breakpoints, WidgetInstance, KnownWidgetInstance, ExtensionWidgetInstance, ExtensionWidgetType, ResolvedWidgetInstance, UnknownWidgetInstance, UnknownWidgetType, UnresolvedWidgetCode, UnresolvedWidgetReason, WidgetImplementationRef, WidgetType, WidgetLayout, WidgetBox, DatasourceSelector, DeviceSelector, AnchorSelector, AnchorTarget, AnchorAggregation, DevicesSelector, RelatedTraversalSelector, SlotSelector, UnboundSelector, SlotDefinition, SlotScope, SlotBinding, SelectionTarget, SelectionCandidate, EntityCandidateLister, EntityListKind, MeasurementSample, LocationSample, LocationSeries, LocationSelection, AlarmRow, CommandRow, CommandParameter, CommandParamDataType, } from './types';
|
|
2
2
|
export { COMMAND_STATUSES, isTerminalCommandStatus, isCancellableCommandStatus, type CommandStatus, } from './command-status';
|
|
3
|
-
export { effectiveBindings, parseBindingManifest, stripDefaultBindings, type ParsedBindingManifest, } from './bindings';
|
|
3
|
+
export { effectiveBindings, parseBindingManifest, resolveWidgetDatasource, stripDefaultBindings, type ParsedBindingManifest, } from './bindings';
|
|
4
4
|
export { resolveContextBindings, hasScopedSlots, applySelection, bindingsWithoutScopedSlots, type MemberResolver, } from './context';
|
|
5
5
|
export { migrateToSlots, bindWidgetSlot, clearWidgetDatasource, pruneSlots, widgetBinding, widgetSlotName, sameBinding, resolveConcrete, setSlotScope, anchorSlotNames, type ConcreteSelector, } from './slots';
|
|
6
6
|
export { resolveSlotCandidates } from './candidates';
|
|
7
7
|
export { createEntityLister } from './entity-lister';
|
|
8
|
-
export { WIDGET_TYPES } from './types';
|
|
8
|
+
export { WIDGET_TYPES, UNKNOWN_WIDGET_TYPE } from './types';
|
|
9
9
|
export { DashboardHub, type DashboardHubConfig, type DeviceResolver, type WidgetStreamSink, type WidgetDataSource, type AlarmSubscription, type AlarmSnapshot, type AlarmStreamSink, type CommandSubscription, type CommandSnapshot, type CommandStreamSink, type CommandDispatch, type LocationSubscription, type LocationSnapshot, type LocationStreamSink, type WidgetActions, } from './hub';
|
|
10
10
|
export { SyntheticDataSource, SYNTHETIC_GENERATORS, type SyntheticGenerator, type SyntheticDataSourceConfig, } from './synthetic';
|
|
11
|
-
export {
|
|
11
|
+
export { RECORDING_FORMAT_VERSION, RECORDING_KIND, RecordingFormatError, parseBoardRecording, recordedWallTimeMs, recordingBounds, simulationScaleAt, type BoardRecording, type RecordedAlarm, type RecordedAlarmEvent, type RecordedAlarmSnapshot, type RecordedChannels, type RecordedChapter, type RecordedClockSegment, type RecordedDevice, type RecordedMeasurementColumns, } from './recording';
|
|
12
|
+
export { PLAYBACK_RATES, RECORDED_HISTORY_WINDOW_MS, NotInRecordingError, RecordedClock, RecordedDataSource, createRecordedClock, createRecordedLister, createRecordedResolver, type ClockEvent, type ClockTicker, type PlaybackRate, type RecordedChannel, type RecordedSiteOptions, } from './recorded';
|
|
13
|
+
export { parseDashboardDefinition, type ParseDefinitionOptions, parseSlotBinding, serializeDefinition, storedDefinition, isDirty, resolveWidgetBox, activeBreakpoint, generateWidgetId, canScopeSlot, DashboardDefinitionError, BASE_BREAKPOINT, } from './definition';
|
|
12
14
|
export { baseBox, setWidgetBox, deleteWidget, bringToFront, setTitle, setCanvasGrid, setCanvasSizing, updateWidget, addWidget, gridBoxToPx, pxToGridBox, type PixelRect, type GridGeometry, } from './editor-model';
|
|
13
15
|
export { createDeviceResolver } from './resolver';
|
|
14
16
|
export { defaultHistoryWindow, fetchWidgetHistory, type HistoryWindow } from './history';
|
|
17
|
+
export type { AlarmStreamState, CommandStreamState, LocationStreamState, MeasurementStreamState, } from './channel-snapshots';
|
|
18
|
+
export { applyOptionPatch, clampNumberOption, enumValues, numberSpec, validateOptions, HOST_OPTION_CONTROLS, type HostOptionControl, type BooleanOptionSpec, type DefaultsOf, type EnumOptionSpec, type GreaterThanConstraint, type NumberOptionSpec, type OptionConstraint, type OptionIssue, type OptionIssueCode, type OptionKeysOfKind, type OptionSpec, type OptionsOf, type RequiredOptionKeys, type SpecValue, type StringOptionSpec, type ValidateOptionsContext, type WidgetOptionSpecs, } from './option-schema';
|
|
19
|
+
export { SDK_API_VERSION, defineWidgetDescriptor, isBuiltinWidgetId, isNamespacedWidgetId, type AckOptionRef, type BuiltinWidgetId, type ChannelBindingPolicy, type ChannelSnapshot, type ConstBinding, type DatasourcePolicy, type DatasourcePolicyFor, type DatasourceSelectorKind, type InteractionsFor, type NamespacedWidgetId, type NumberOptionRef, type StringOptionRef, type WidgetChannel, type WidgetDescriptor, type WidgetDisplay, type WidgetId, type WidgetInteractionDeclaration, } from './widget-descriptor';
|
|
20
|
+
export { WidgetCatalogError, collectCatalogIssues, createWidgetCatalog, describeIssues, validateWidgetDescriptor, type DescriptorIssue, type WidgetCatalog, } from './widget-catalog';
|
|
21
|
+
export { isBuiltinWidget, isResolvedWidget, parseWidgetRef, checkWidgetCompatibility, widgetVersionNotice, unresolvedWidgets, type UnresolvedWidgetReport, } from './widget-compat';
|