bruce-models 7.1.74 → 7.1.75

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.
@@ -6,6 +6,19 @@ import { EntityCoords } from "./entity-coords";
6
6
  import { Transform } from "../common/transform";
7
7
  import { Geometry } from "../common/geometry";
8
8
  export declare namespace EntityHistoricData {
9
+ type TSeriesInterval = "hour" | "day" | "week" | "month";
10
+ type TSeriesAggregate = "min" | "max" | "sum" | "avg" | "count";
11
+ let STATIC_CACHE_DURATION: number;
12
+ let LIVE_CACHE_DURATION: number;
13
+ interface IRecord {
14
+ "Entity.ID"?: string;
15
+ AttrKey?: string;
16
+ DateTime?: string;
17
+ Entity?: any;
18
+ Scenario?: string | number;
19
+ Created?: string;
20
+ Updated?: string;
21
+ }
9
22
  interface IData {
10
23
  attrKey: string;
11
24
  dateTime: string;
@@ -25,6 +38,7 @@ export declare namespace EntityHistoricData {
25
38
  /**
26
39
  * Returns historic data for an array of Entity IDs.
27
40
  * A maximum number of records will be returned per Entity ID, this information is returned in the response.
41
+ * @deprecated Don't use.
28
42
  * @param params
29
43
  * @returns
30
44
  */
@@ -41,6 +55,7 @@ export declare namespace EntityHistoricData {
41
55
  }>;
42
56
  /**
43
57
  * Returns historic data statistics for an array of Entity IDs.
58
+ * @deprecated Don't use.
44
59
  * @param params
45
60
  * @returns
46
61
  */
@@ -55,6 +70,7 @@ export declare namespace EntityHistoricData {
55
70
  /**
56
71
  * Creates or updates historic data records.
57
72
  * Please note that the expected input/output does not include internal fields found inside the "Bruce" attribute.
73
+ * @deprecated Don't use.
58
74
  * @param params
59
75
  * @returns
60
76
  */
@@ -69,6 +85,7 @@ export declare namespace EntityHistoricData {
69
85
  /**
70
86
  * Deletes historic data records for an array of Entity IDs.
71
87
  * This deletes all records within a provided key + range.
88
+ * @deprecated Don't use.
72
89
  * @param params
73
90
  * @returns
74
91
  */
@@ -80,6 +97,211 @@ export declare namespace EntityHistoricData {
80
97
  api?: BruceApi.Api;
81
98
  req?: Api.IReqParams;
82
99
  }): Promise<void>;
100
+ interface IAnalysisBucket {
101
+ From: string;
102
+ To: string;
103
+ Count: number;
104
+ }
105
+ interface IAnalysis {
106
+ AttrKey: string;
107
+ Count: number;
108
+ DateTimeMin: string;
109
+ DateTimeMax: string;
110
+ Buckets: IAnalysisBucket[];
111
+ }
112
+ interface ISeriesPoint {
113
+ Time: string;
114
+ Value: number;
115
+ Samples: number;
116
+ }
117
+ interface ISeries {
118
+ AttrKey: string;
119
+ "Entity.ID"?: string;
120
+ Aggregate: string;
121
+ Interval: string;
122
+ DateTimeMin: string;
123
+ DateTimeMax: string;
124
+ PointCount: number;
125
+ Points: ISeriesPoint[];
126
+ }
127
+ /**
128
+ * Returns a histogram of where historic records sit in time, without returning the records.
129
+ * Answers "when does this data exist" for a timeline in one request, at a cost that does not grow with the number of records.
130
+ * @param params
131
+ * @returns
132
+ */
133
+ function GetAnalysis(params: {
134
+ entityIds?: string[];
135
+ entityTypeId?: string;
136
+ attrKey?: string | string[];
137
+ dateTimeFrom?: string;
138
+ dateTimeTo?: string;
139
+ scenario?: string | number;
140
+ buckets?: number;
141
+ live?: boolean;
142
+ api?: BruceApi.Api;
143
+ req?: Api.IReqParams;
144
+ }): Promise<{
145
+ analysis: IAnalysis[];
146
+ }>;
147
+ /**
148
+ * Returns the date range and record count per attribute key, in the shape GetStats returns.
149
+ * Prefer GetAnalysis directly, which also carries the distribution.
150
+ * @param params
151
+ * @returns
152
+ */
153
+ function GetRanges(params: {
154
+ entityIds?: string[];
155
+ entityTypeId?: string;
156
+ attrKey?: string | string[];
157
+ dateTimeFrom?: string;
158
+ dateTimeTo?: string;
159
+ scenario?: string | number;
160
+ live?: boolean;
161
+ api?: BruceApi.Api;
162
+ req?: Api.IReqParams;
163
+ }): Promise<{
164
+ stats: IStats[];
165
+ }>;
166
+ /**
167
+ * Returns a numeric attribute aggregated into time buckets, computed in the database.
168
+ * This is what a chart wants: the reduction happens server-side, so the response is the size of
169
+ * the plotted series rather than the size of the underlying records.
170
+ * @param params
171
+ * @returns
172
+ */
173
+ function GetSeries(params: {
174
+ entityIds?: string[];
175
+ entityTypeId?: string;
176
+ attrKey?: string | string[];
177
+ valueAttrKey: string | string[];
178
+ dateTimeFrom?: string;
179
+ dateTimeTo?: string;
180
+ scenario?: string | number;
181
+ aggregate?: TSeriesAggregate;
182
+ interval?: TSeriesInterval;
183
+ live?: boolean;
184
+ api?: BruceApi.Api;
185
+ req?: Api.IReqParams;
186
+ }): Promise<{
187
+ series: ISeries;
188
+ }>;
189
+ /**
190
+ * Returns one aggregated series per Entity, computed in the database in a single request.
191
+ * @param params
192
+ * @returns
193
+ */
194
+ function GetSeriesByEntity(params: {
195
+ entityIds?: string[];
196
+ entityTypeId?: string;
197
+ attrKey?: string | string[];
198
+ valueAttrKey: string | string[];
199
+ dateTimeFrom?: string;
200
+ dateTimeTo?: string;
201
+ scenario?: string | number;
202
+ aggregate?: TSeriesAggregate;
203
+ interval?: TSeriesInterval;
204
+ live?: boolean;
205
+ api?: BruceApi.Api;
206
+ req?: Api.IReqParams;
207
+ }): Promise<{
208
+ seriesByIds: IDictionary<ISeries>;
209
+ }>;
210
+ /**
211
+ * Returns one page of historic records, newest first by default.
212
+ * @param params
213
+ * @returns
214
+ */
215
+ function GetPage(params: {
216
+ entityIds?: string[];
217
+ entityTypeId?: string;
218
+ attrKey?: string | string[];
219
+ dateTimeFrom?: string;
220
+ dateTimeTo?: string;
221
+ scenario?: string | number;
222
+ pageIndex?: number;
223
+ pageSize?: number;
224
+ sample?: number;
225
+ orderBy?: "id" | "datetime" | "attrkey" | "created";
226
+ orderDir?: "ASC" | "DESC";
227
+ live?: boolean;
228
+ api?: BruceApi.Api;
229
+ req?: Api.IReqParams;
230
+ }): Promise<{
231
+ items: any[];
232
+ pageIndex: number;
233
+ pageSize: number;
234
+ sample: number;
235
+ }>;
236
+ function ToDataRecord(record: any): IData;
237
+ /**
238
+ * Returns records grouped per Entity.
239
+ * @param params
240
+ * @returns
241
+ */
242
+ function GetRecordsByEntity(params: {
243
+ entityIds?: string[];
244
+ entityTypeId?: string;
245
+ attrKey?: string | string[];
246
+ dateTimeFrom?: string;
247
+ dateTimeTo?: string;
248
+ scenario?: string | number;
249
+ sample?: number;
250
+ pageSize?: number;
251
+ pageIndex?: number;
252
+ orderBy?: "id" | "datetime" | "attrkey" | "created";
253
+ orderDir?: "ASC" | "DESC";
254
+ live?: boolean;
255
+ api?: BruceApi.Api;
256
+ req?: Api.IReqParams;
257
+ }): Promise<{
258
+ recordsByIds: IDictionary<IData[]>;
259
+ sample: number;
260
+ }>;
261
+ function BuildRecord(params: {
262
+ entityId: string;
263
+ attrKey: string | string[];
264
+ dateTime: string;
265
+ values?: any;
266
+ internal?: {
267
+ Location?: EntityCoords.ILocation;
268
+ Transform?: Transform.ITransform;
269
+ Boundaries?: Bounds.IBounds;
270
+ VectorGeometry?: Geometry.IGeometry;
271
+ };
272
+ scenario?: string | number;
273
+ }): IRecord;
274
+ /**
275
+ * Creates or updates historic records.
276
+ * @param params
277
+ * @returns
278
+ */
279
+ function Save(params: {
280
+ records: IRecord[];
281
+ scenario?: string | number;
282
+ api?: BruceApi.Api;
283
+ req?: Api.IReqParams;
284
+ }): Promise<{
285
+ records: IRecord[];
286
+ warnings: string[];
287
+ }>;
288
+ /**
289
+ * Deletes every historic record matching the filter, and reports how many were removed.
290
+ * The filter is the one the reads accept, so a caller can delete exactly what it just listed.
291
+ * @param params
292
+ * @returns
293
+ */
294
+ function DeleteRange(params: {
295
+ entityIds: string[];
296
+ attrKey?: string | string[];
297
+ dateTimeFrom?: string;
298
+ dateTimeTo?: string;
299
+ scenario?: string | number;
300
+ api?: BruceApi.Api;
301
+ req?: Api.IReqParams;
302
+ }): Promise<{
303
+ deleted: number;
304
+ }>;
83
305
  function GetListCacheKey(entityIds: string[], attrKey: string, dateTimeFrom: string, dateTimeTo: string): string;
84
306
  function GetStatsCacheKey(entityIds?: string[], typeId?: string): string;
85
307
  function ClearCacheByEntityIds(api: BruceApi.Api, entityIds: string[]): void;
@@ -275,6 +275,7 @@ export declare namespace MenuItem {
275
275
  interface IEntitiesTileset extends IItem {
276
276
  BruceEntity?: {
277
277
  "EntityType.ID"?: string;
278
+ historicAttrKey?: string;
278
279
  historic?: boolean;
279
280
  };
280
281
  Type: EType.EntityTileset;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bruce-models",
3
- "version": "7.1.74",
3
+ "version": "7.1.75",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/bruce-models.umd.js",