@awarevue/api-types 1.0.70 → 1.0.71

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.
@@ -49,17 +49,19 @@ export type AlarmBehavior = z.infer<typeof sAlarmBehavior>;
49
49
  export type AlarmAutomationLevel = z.infer<typeof sAlarmAutomationLevel>;
50
50
  export type AlarmAutomationMetadata = z.infer<typeof sAlarmAutomationMetadata>;
51
51
  export declare const isAlarmAutomationMetadata: (metadata: unknown) => metadata is AlarmAutomationMetadata;
52
- export declare const formatByDeviceAutomationCode: (deviceId: string) => string;
53
- export declare const formatByTypeAutomationCode: (eventKind: DeviceEvent["kind"]) => string;
52
+ export declare const formatByDeviceAutomationCode: (eventKind: DeviceEvent["kind"], deviceId: string) => string;
53
+ export declare const formatByTypeAutomationCode: (eventKind: DeviceEvent["kind"], deviceType: DeviceType) => string;
54
54
  export declare const isByDeviceAutomationCode: (code: string) => boolean;
55
55
  export declare const isByTypeAutomationCode: (code: string) => boolean;
56
56
  export type ParsedByDeviceAutomationCode = {
57
57
  type: 'by-device';
58
58
  value: string;
59
+ eventKind: DeviceEvent['kind'];
59
60
  };
60
61
  export type ParsedByTypeAutomationCode = {
61
62
  type: 'by-type';
62
- value: DeviceEvent['kind'];
63
+ value: DeviceType;
64
+ eventKind: DeviceEvent['kind'];
63
65
  };
64
66
  export type ParsedAlarmAutomationCode = ParsedByDeviceAutomationCode | ParsedByTypeAutomationCode;
65
67
  export declare const parseAlarmAutomationCode: (code: string) => ParsedAlarmAutomationCode | null;
@@ -29,12 +29,12 @@ exports.isAlarmAutomationMetadata = isAlarmAutomationMetadata;
29
29
  // Alarm assigns automation rules with code that is either:
30
30
  // [by-event]:[event-kind]
31
31
  // [by-device]:[device-id]
32
- const formatByDeviceAutomationCode = (deviceId) => {
33
- return `by-device:${deviceId}`;
32
+ const formatByDeviceAutomationCode = (eventKind, deviceId) => {
33
+ return `by-device:${deviceId}:${eventKind}`;
34
34
  };
35
35
  exports.formatByDeviceAutomationCode = formatByDeviceAutomationCode;
36
- const formatByTypeAutomationCode = (eventKind) => {
37
- return `by-Type:${eventKind}`;
36
+ const formatByTypeAutomationCode = (eventKind, deviceType) => {
37
+ return `by-type:${deviceType}:${eventKind}`;
38
38
  };
39
39
  exports.formatByTypeAutomationCode = formatByTypeAutomationCode;
40
40
  const isByDeviceAutomationCode = (code) => {
@@ -47,15 +47,25 @@ const isByTypeAutomationCode = (code) => {
47
47
  exports.isByTypeAutomationCode = isByTypeAutomationCode;
48
48
  const parseAlarmAutomationCode = (code) => {
49
49
  if ((0, exports.isByDeviceAutomationCode)(code)) {
50
+ const parts = code.replace('by-device:', '').split(':');
51
+ if (parts.length !== 2) {
52
+ return null; // Invalid format
53
+ }
50
54
  return {
51
55
  type: 'by-device',
52
- value: code.replace('by-device:', ''),
56
+ value: parts[0], // deviceId
57
+ eventKind: parts[1], // eventKind
53
58
  };
54
59
  }
55
60
  if ((0, exports.isByTypeAutomationCode)(code)) {
61
+ const parts = code.replace('by-type:', '').split(':');
62
+ if (parts.length !== 2) {
63
+ return null; // Invalid format
64
+ }
56
65
  return {
57
66
  type: 'by-type',
58
- value: code.replace('by-type:', ''),
67
+ value: parts[0], // deviceType
68
+ eventKind: parts[1], // eventKind
59
69
  };
60
70
  }
61
71
  return null;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awarevue/api-types",
3
- "version": "1.0.70",
3
+ "version": "1.0.71",
4
4
  "description": "Common types between backend, agent(s) and frontend(s)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awarevue/api-types",
3
- "version": "1.0.70",
3
+ "version": "1.0.71",
4
4
  "description": "Common types between backend, agent(s) and frontend(s)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",