@devicechain/dashboards 0.14.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,48 @@
1
+ import type { TypedDocument } from '@devicechain/client';
2
+ import type { AlarmRow } from '../types';
3
+ export interface AlarmSearchCriteriaInput {
4
+ pageNumber: number;
5
+ pageSize: number;
6
+ originatorType?: string | null;
7
+ originator?: string | null;
8
+ state?: string | null;
9
+ severity?: string | null;
10
+ acknowledged?: boolean | null;
11
+ alarmKey?: string | null;
12
+ }
13
+ export interface AlarmsQueryResult {
14
+ alarms: {
15
+ results: AlarmRow[];
16
+ pagination: {
17
+ totalRecords: number;
18
+ };
19
+ };
20
+ }
21
+ export interface AlarmsQueryVariables {
22
+ criteria: AlarmSearchCriteriaInput;
23
+ }
24
+ export declare const ALARMS_QUERY: TypedDocument<AlarmsQueryResult, AlarmsQueryVariables>;
25
+ export interface AlarmStreamResult {
26
+ alarmStream: {
27
+ alarmToken: string;
28
+ eventType: string;
29
+ };
30
+ }
31
+ export interface AlarmStreamVariables {
32
+ originatorType?: string | null;
33
+ originator?: string | null;
34
+ state?: string | null;
35
+ severity?: string | null;
36
+ alarmKey?: string | null;
37
+ }
38
+ export declare const ALARM_STREAM: TypedDocument<AlarmStreamResult, AlarmStreamVariables>;
39
+ export interface AlarmMutationVariables {
40
+ token: string;
41
+ }
42
+ export interface AlarmMutationResult {
43
+ [key: string]: {
44
+ token: string;
45
+ };
46
+ }
47
+ export declare const ACKNOWLEDGE_ALARM: TypedDocument<AlarmMutationResult, AlarmMutationVariables>;
48
+ export declare const CLEAR_ALARM: TypedDocument<AlarmMutationResult, AlarmMutationVariables>;
@@ -0,0 +1,43 @@
1
+ import type { TypedDocument } from '@devicechain/client';
2
+ import type { CommandRow } from '../types';
3
+ export interface CommandSearchCriteriaInput {
4
+ pageNumber: number;
5
+ pageSize: number;
6
+ deviceToken?: string | null;
7
+ status?: string | null;
8
+ statuses?: string[] | null;
9
+ }
10
+ export interface CommandsQueryResult {
11
+ commands: {
12
+ results: CommandRow[];
13
+ pagination: {
14
+ totalRecords: number;
15
+ };
16
+ };
17
+ }
18
+ export interface CommandsQueryVariables {
19
+ criteria: CommandSearchCriteriaInput;
20
+ }
21
+ export declare const COMMANDS_QUERY: TypedDocument<CommandsQueryResult, CommandsQueryVariables>;
22
+ export interface CreateCommandRequestInput {
23
+ token: string;
24
+ deviceToken: string;
25
+ name: string;
26
+ payload?: string | null;
27
+ }
28
+ export interface CreateCommandResult {
29
+ createCommand: {
30
+ command: {
31
+ token: string;
32
+ status: string;
33
+ } | null;
34
+ rejection: {
35
+ code: string;
36
+ reason: string;
37
+ } | null;
38
+ };
39
+ }
40
+ export interface CreateCommandVariables {
41
+ request: CreateCommandRequestInput;
42
+ }
43
+ export declare const CREATE_COMMAND: TypedDocument<CreateCommandResult, CreateCommandVariables>;
@@ -0,0 +1,9 @@
1
+ import type { TypedDocument } from '@devicechain/client';
2
+ import type { LocationSample } from '../types';
3
+ export interface LatestLocationsResult {
4
+ latestLocations: LocationSample[];
5
+ }
6
+ export interface LatestLocationsVariables {
7
+ deviceTokens: string[];
8
+ }
9
+ export declare const LATEST_LOCATIONS_QUERY: TypedDocument<LatestLocationsResult, LatestLocationsVariables>;
@@ -0,0 +1,10 @@
1
+ import type { TypedDocument } from '@devicechain/client';
2
+ import type { MeasurementSample } from '../types';
3
+ export interface MeasurementStreamResult {
4
+ measurementStream: MeasurementSample;
5
+ }
6
+ export interface MeasurementStreamVariables {
7
+ deviceToken?: string | null;
8
+ name?: string | null;
9
+ }
10
+ export declare const MEASUREMENT_STREAM: TypedDocument<MeasurementStreamResult, MeasurementStreamVariables>;
@@ -0,0 +1,72 @@
1
+ import type { TypedDocument } from '@devicechain/client';
2
+ export interface EntityRelationshipsResult {
3
+ entityRelationships: {
4
+ results: Array<{
5
+ source: {
6
+ token: string;
7
+ };
8
+ }>;
9
+ };
10
+ }
11
+ export interface EntityRelationshipsVariables {
12
+ criteria: {
13
+ pageNumber: number;
14
+ pageSize: number;
15
+ sourceType: string;
16
+ targetType: string;
17
+ target: string;
18
+ relationshipType?: string | null;
19
+ };
20
+ }
21
+ export declare const DEVICES_FOR_ANCHOR: TypedDocument<EntityRelationshipsResult, EntityRelationshipsVariables>;
22
+ export interface DevicesByTokenResult {
23
+ devicesByToken: Array<{
24
+ token: string;
25
+ }>;
26
+ }
27
+ export interface DevicesByTokenVariables {
28
+ tokens: string[];
29
+ }
30
+ export declare const DEVICES_BY_TOKEN: TypedDocument<DevicesByTokenResult, DevicesByTokenVariables>;
31
+ export interface EntityListResult {
32
+ results: Array<{
33
+ token: string;
34
+ name: string | null;
35
+ }>;
36
+ }
37
+ export interface EntityListVariables {
38
+ criteria: {
39
+ pageNumber: number;
40
+ pageSize: number;
41
+ };
42
+ }
43
+ export declare const LIST_DEVICES: TypedDocument<{
44
+ devices: EntityListResult;
45
+ }, EntityListVariables>;
46
+ export declare const LIST_CUSTOMERS: TypedDocument<{
47
+ customers: EntityListResult;
48
+ }, EntityListVariables>;
49
+ export declare const LIST_AREAS: TypedDocument<{
50
+ areas: EntityListResult;
51
+ }, EntityListVariables>;
52
+ export declare const LIST_ASSETS: TypedDocument<{
53
+ assets: EntityListResult;
54
+ }, EntityListVariables>;
55
+ export interface MeasurementBucket {
56
+ bucketStart: string;
57
+ name: string;
58
+ avg: number | null;
59
+ }
60
+ export interface BucketedMeasurementsResult {
61
+ bucketedMeasurements: MeasurementBucket[];
62
+ }
63
+ export interface BucketedMeasurementsVariables {
64
+ criteria: {
65
+ deviceToken: string;
66
+ name?: string | null;
67
+ startTime: string;
68
+ endTime: string;
69
+ intervalSeconds: number;
70
+ };
71
+ }
72
+ export declare const BUCKETED_MEASUREMENTS: TypedDocument<BucketedMeasurementsResult, BucketedMeasurementsVariables>;
@@ -0,0 +1,2 @@
1
+ import type { DeviceResolver } from './hub';
2
+ export declare function createDeviceResolver(): DeviceResolver;
@@ -0,0 +1,22 @@
1
+ import type { AnchorTarget, DashboardDefinition, LocationSelection, SlotBinding, SlotScope, WidgetInstance } from './types';
2
+ export declare function sameBinding(a: SlotBinding | undefined, b: SlotBinding | undefined): boolean;
3
+ export declare function migrateToSlots(def: DashboardDefinition): DashboardDefinition;
4
+ export declare function bindWidgetSlot(def: DashboardDefinition, widgetId: string, binding: SlotBinding, measurements: string[], location?: LocationSelection): DashboardDefinition;
5
+ export declare function clearWidgetDatasource(def: DashboardDefinition, widgetId: string): DashboardDefinition;
6
+ export declare function pruneSlots(def: DashboardDefinition): DashboardDefinition;
7
+ export declare function anchorSlotNames(def: DashboardDefinition): string[];
8
+ export declare function setSlotScope(def: DashboardDefinition, slotName: string, scope: SlotScope | undefined): DashboardDefinition;
9
+ export declare function widgetBinding(def: DashboardDefinition, widget: WidgetInstance): SlotBinding | undefined;
10
+ export declare function widgetSlotName(widget: WidgetInstance): string | undefined;
11
+ export type ConcreteSelector = {
12
+ kind: 'device';
13
+ deviceToken: string;
14
+ measurements: string[];
15
+ location?: LocationSelection;
16
+ } | {
17
+ kind: 'anchor';
18
+ anchor: AnchorTarget;
19
+ measurements: string[];
20
+ location?: LocationSelection;
21
+ };
22
+ export declare function resolveConcrete(def: DashboardDefinition, widget: WidgetInstance): ConcreteSelector | undefined;
@@ -0,0 +1,36 @@
1
+ import type { AlarmStreamSink, AlarmSubscription, CommandDispatch, CommandStreamSink, CommandSubscription, LocationStreamSink, LocationSubscription, WidgetActions, WidgetDataSource, WidgetStreamSink } from './hub';
2
+ import type { DatasourceSelector } from './types';
3
+ export type SyntheticGenerator = 'sine' | 'ramp' | 'random-walk';
4
+ export declare const SYNTHETIC_GENERATORS: ReadonlyArray<{
5
+ value: SyntheticGenerator;
6
+ label: string;
7
+ }>;
8
+ export interface SyntheticDataSourceConfig {
9
+ generator?: SyntheticGenerator;
10
+ intervalMs?: number;
11
+ backfill?: number;
12
+ min?: number;
13
+ max?: number;
14
+ periodMs?: number;
15
+ }
16
+ export declare class SyntheticDataSource implements WidgetDataSource, WidgetActions {
17
+ private readonly generator;
18
+ private readonly intervalMs;
19
+ private readonly backfill;
20
+ private readonly min;
21
+ private readonly max;
22
+ private readonly periodMs;
23
+ private readonly timers;
24
+ constructor(config?: SyntheticDataSourceConfig);
25
+ subscribeWidget(datasource: DatasourceSelector, sink: WidgetStreamSink): () => void;
26
+ subscribeAlarms(subscription: AlarmSubscription, sink: AlarmStreamSink): () => void;
27
+ subscribeCommands(subscription: CommandSubscription, sink: CommandStreamSink): () => void;
28
+ subscribeLocations(subscription: LocationSubscription, sink: LocationStreamSink): () => void;
29
+ isDatasourceAvailable(): Promise<boolean>;
30
+ can(): boolean;
31
+ acknowledgeAlarm(): Promise<void>;
32
+ clearAlarm(): Promise<void>;
33
+ sendCommand(): Promise<CommandDispatch>;
34
+ disposeAll(): void;
35
+ private valueFor;
36
+ }
@@ -0,0 +1,190 @@
1
+ export type LocationSeries = 'latest';
2
+ export interface LocationSelection {
3
+ series: LocationSeries;
4
+ }
5
+ export interface DeviceSelector {
6
+ kind: 'device';
7
+ deviceToken: string;
8
+ measurements: string[];
9
+ location?: LocationSelection;
10
+ }
11
+ export interface AnchorTarget {
12
+ relationship: string;
13
+ targetType: 'customer' | 'area' | 'asset';
14
+ targetToken: string;
15
+ }
16
+ export interface AnchorAggregation {
17
+ window: string;
18
+ fn: 'avg' | 'min' | 'max' | 'sum' | 'count';
19
+ }
20
+ export interface AnchorSelector {
21
+ kind: 'anchor';
22
+ anchor: AnchorTarget;
23
+ measurements: string[];
24
+ location?: LocationSelection;
25
+ aggregation?: AnchorAggregation;
26
+ }
27
+ export interface DevicesSelector {
28
+ kind: 'devices';
29
+ deviceTokens: string[];
30
+ measurements: string[];
31
+ location?: LocationSelection;
32
+ }
33
+ export interface RelatedTraversalSelector {
34
+ kind: 'relatedTraversal';
35
+ from: string;
36
+ relationship: string;
37
+ measurements: string[];
38
+ location?: LocationSelection;
39
+ }
40
+ export interface SlotSelector {
41
+ kind: 'slot';
42
+ slot: string;
43
+ measurements: string[];
44
+ location?: LocationSelection;
45
+ }
46
+ export type DatasourceSelector = DeviceSelector | AnchorSelector | DevicesSelector | RelatedTraversalSelector | SlotSelector;
47
+ export declare const WIDGET_TYPES: readonly ['timeseries-chart', 'latest-card', 'gauge', 'table', 'label', 'image', 'alarm-table', 'alarm-count', 'command-button', 'entity-selector', 'map'];
48
+ export type WidgetType = (typeof WIDGET_TYPES)[number];
49
+ export interface WidgetBox {
50
+ col: number;
51
+ colSpan: number;
52
+ row: number;
53
+ rowSpan: number;
54
+ z: number;
55
+ offset?: {
56
+ x: number;
57
+ y: number;
58
+ };
59
+ }
60
+ export type WidgetLayout = Record<string, WidgetBox>;
61
+ export interface WidgetInstance {
62
+ id: string;
63
+ type: WidgetType;
64
+ layout: WidgetLayout;
65
+ datasource?: DatasourceSelector;
66
+ options?: Record<string, unknown>;
67
+ }
68
+ export interface CanvasBackground {
69
+ color?: string | null;
70
+ imageUrl?: string | null;
71
+ }
72
+ export interface CanvasGrid {
73
+ columns: number;
74
+ gap: number | {
75
+ row: number;
76
+ col: number;
77
+ };
78
+ rowHeight: number;
79
+ }
80
+ export type CanvasSizing = 'fill' | {
81
+ width: number;
82
+ } | {
83
+ height: number;
84
+ };
85
+ export type Breakpoints = Record<string, number>;
86
+ export interface Canvas {
87
+ background?: CanvasBackground;
88
+ grid: CanvasGrid;
89
+ sizing: CanvasSizing;
90
+ breakpoints: Breakpoints;
91
+ }
92
+ export type SlotBinding = {
93
+ kind: 'device';
94
+ deviceToken: string;
95
+ } | {
96
+ kind: 'anchor';
97
+ anchor: AnchorTarget;
98
+ };
99
+ export interface SlotScope {
100
+ parent: string;
101
+ strategy: 'first' | 'manual';
102
+ }
103
+ export interface SlotDefinition {
104
+ type: 'device' | 'anchor';
105
+ label?: string;
106
+ defaultBinding?: SlotBinding;
107
+ scope?: SlotScope;
108
+ }
109
+ export type EntityListKind = 'device' | 'customer' | 'area' | 'asset';
110
+ export type EntityCandidateLister = (kind: EntityListKind) => Promise<Array<{
111
+ token: string;
112
+ name?: string | null;
113
+ }>>;
114
+ export interface SelectionCandidate {
115
+ binding: SlotBinding;
116
+ label: string;
117
+ selected: boolean;
118
+ }
119
+ export interface SelectionTarget {
120
+ slot: string;
121
+ binding: SlotBinding;
122
+ }
123
+ export interface DashboardDefinition {
124
+ schemaVersion: number;
125
+ title: string;
126
+ canvas: Canvas;
127
+ widgets: WidgetInstance[];
128
+ slots?: Record<string, SlotDefinition>;
129
+ }
130
+ export interface MeasurementSample {
131
+ id: string;
132
+ deviceToken: string;
133
+ eventType: number;
134
+ occurredTime: string | null;
135
+ name: string;
136
+ value: number | null;
137
+ classifier: string | null;
138
+ }
139
+ export interface AlarmRow {
140
+ token: string;
141
+ originatorType: string;
142
+ originatorToken: string | null;
143
+ alarmKey: string;
144
+ metricKey: string;
145
+ state: string;
146
+ acknowledged: boolean;
147
+ severity: string;
148
+ raisedTime: string | null;
149
+ clearedTime: string | null;
150
+ acknowledgedTime: string | null;
151
+ acknowledgedBy: string | null;
152
+ lastValue: number | null;
153
+ message: string | null;
154
+ }
155
+ export interface LocationSample {
156
+ id: string;
157
+ deviceToken: string;
158
+ latitude: number | null;
159
+ longitude: number | null;
160
+ elevation: number | null;
161
+ accuracy: number | null;
162
+ speed: number | null;
163
+ heading: number | null;
164
+ occurredTime: string | null;
165
+ }
166
+ export interface CommandRow {
167
+ token: string;
168
+ name: string;
169
+ status: string;
170
+ payload: string | null;
171
+ responsePayload: string | null;
172
+ error: string | null;
173
+ queuedTime: string | null;
174
+ sentTime: string | null;
175
+ respondedTime: string | null;
176
+ }
177
+ export type CommandParamDataType = 'DOUBLE' | 'INT' | 'BOOLEAN' | 'STRING';
178
+ export interface CommandParameter {
179
+ name: string;
180
+ description?: string;
181
+ kind?: 'SCALAR' | 'OBJECT';
182
+ dataType?: CommandParamDataType;
183
+ unit?: string;
184
+ required?: boolean;
185
+ default?: string | null;
186
+ minValue?: number | null;
187
+ maxValue?: number | null;
188
+ enum?: string[];
189
+ parameters?: CommandParameter[];
190
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@devicechain/dashboards",
3
+ "version": "0.14.0-0",
4
+ "description": "DeviceChain dashboard runtime — the DashboardHub (telemetry subscription multiplexing over the client wire, plus the alarm, command and location channels) and the dashboard-definition, selector, slot, and binding-manifest types.",
5
+ "keywords": [
6
+ "devicechain",
7
+ "iot",
8
+ "dashboard",
9
+ "telemetry",
10
+ "graphql"
11
+ ],
12
+ "license": "Apache-2.0",
13
+ "homepage": "https://devicechain.io",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/devicechain-io/devicechain.git",
17
+ "directory": "frontend/packages/dashboards"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/devicechain-io/devicechain/issues"
21
+ },
22
+ "type": "module",
23
+ "main": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md",
35
+ "LICENSE"
36
+ ],
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "scripts": {
41
+ "build": "node ../../scripts/build-package.mjs",
42
+ "typecheck": "tsc --noEmit",
43
+ "test": "vitest run"
44
+ },
45
+ "dependencies": {
46
+ "@graphql-typed-document-node/core": "^3.2.0"
47
+ },
48
+ "peerDependencies": {
49
+ "@devicechain/client": "0.14.0-0",
50
+ "graphql": "^16.0.0 || ^17.0.0"
51
+ },
52
+ "devDependencies": {
53
+ "@devicechain/client": "0.14.0-0",
54
+ "graphql": "^17.0.2",
55
+ "typescript": "~7.0.2",
56
+ "vitest": "^4.1.11"
57
+ }
58
+ }