@awarevue/api-types 2.0.23 → 2.0.25
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/dist/_legacy/index.js +18 -2
- package/dist/_legacy/milestone.js +2 -1
- package/dist/_legacy/orchid.js +2 -1
- package/dist/alarm-automation.js +37 -26
- package/dist/api/agent-protocol/index.js +17 -1
- package/dist/api/agent-protocol/protocol.js +219 -212
- package/dist/api/commands/alarm.js +46 -43
- package/dist/api/commands/all.js +25 -22
- package/dist/api/commands/camera-lift.js +13 -10
- package/dist/api/commands/camera.js +65 -61
- package/dist/api/commands/display.js +27 -24
- package/dist/api/commands/door.js +21 -18
- package/dist/api/commands/index.js +28 -12
- package/dist/api/commands/intercom-terminal.js +2 -1
- package/dist/api/commands/io-board.js +11 -8
- package/dist/api/commands/nvr-exporter.js +20 -17
- package/dist/api/commands/pbx.js +13 -10
- package/dist/api/commands/presence-tracker.js +25 -22
- package/dist/api/commands/server.js +21 -18
- package/dist/api/error.js +93 -89
- package/dist/api/events/alarm.js +53 -50
- package/dist/api/events/all.js +57 -53
- package/dist/api/events/camera.js +68 -65
- package/dist/api/events/display.js +6 -3
- package/dist/api/events/door.js +60 -57
- package/dist/api/events/index.js +28 -12
- package/dist/api/events/intercom-terminal.js +16 -13
- package/dist/api/events/io-board.js +10 -7
- package/dist/api/events/nvr-exporter.js +14 -11
- package/dist/api/events/panic-button.js +8 -5
- package/dist/api/events/presence-tracker.js +29 -26
- package/dist/api/events/reader.js +11 -8
- package/dist/api/events/server.js +12 -9
- package/dist/api/index.js +25 -9
- package/dist/api/mqtt/index.js +17 -1
- package/dist/api/mqtt/payloads.js +15 -12
- package/dist/api/queries/all.js +23 -20
- package/dist/api/queries/camera.js +19 -16
- package/dist/api/queries/index.js +21 -5
- package/dist/api/queries/nvr-analytics-server.js +57 -54
- package/dist/api/queries/nvr-exporter.js +26 -23
- package/dist/api/queries/nvr-recorder.js +32 -29
- package/dist/api/rest/access-rule.js +14 -8
- package/dist/api/rest/agreement.js +6 -3
- package/dist/api/rest/alarm.js +2 -1
- package/dist/api/rest/api-keys.js +11 -8
- package/dist/api/rest/app.js +11 -8
- package/dist/api/rest/auth.js +12 -9
- package/dist/api/rest/automation.js +13 -10
- package/dist/api/rest/aware-config.js +2 -1
- package/dist/api/rest/bookmarks.js +17 -14
- package/dist/api/rest/cast.js +11 -5
- package/dist/api/rest/custom-field.js +6 -3
- package/dist/api/rest/device-event.js +2 -1
- package/dist/api/rest/device-group.js +19 -13
- package/dist/api/rest/file.js +2 -1
- package/dist/api/rest/index.js +50 -34
- package/dist/api/rest/io-device.js +21 -14
- package/dist/api/rest/layout.js +23 -17
- package/dist/api/rest/macros.js +6 -3
- package/dist/api/rest/media.js +55 -52
- package/dist/api/rest/module-config.js +2 -1
- package/dist/api/rest/notifications.js +11 -8
- package/dist/api/rest/person-agreement.js +11 -5
- package/dist/api/rest/person-presence.js +26 -23
- package/dist/api/rest/person-type.js +6 -3
- package/dist/api/rest/person.js +11 -5
- package/dist/api/rest/query.js +13 -8
- package/dist/api/rest/schedule.js +11 -8
- package/dist/api/rest/security-level.js +6 -3
- package/dist/api/rest/template.js +13 -10
- package/dist/api/rest/token-conversion.js +6 -3
- package/dist/api/rest/user.js +31 -28
- package/dist/api/rest/view.js +20 -14
- package/dist/api/rest/webrtc-playback.js +12 -6
- package/dist/api/rest/zone.js +14 -8
- package/dist/api/state/index.js +2 -1
- package/dist/api/ws/device-communication.js +46 -38
- package/dist/api/ws/index.js +21 -5
- package/dist/api/ws/notifications.js +17 -10
- package/dist/api/ws/progress.js +37 -30
- package/dist/api/ws/web-rtc-signaling.js +72 -65
- package/dist/api/ws/web-socket.js +5 -2
- package/dist/index.js +22 -6
- package/dist/objects/access-rule.js +32 -29
- package/dist/objects/agent-metadata.js +33 -30
- package/dist/objects/agreement.js +10 -7
- package/dist/objects/all.js +7 -4
- package/dist/objects/api-key.js +10 -7
- package/dist/objects/automation-rule.js +28 -25
- package/dist/objects/bookmark.js +14 -11
- package/dist/objects/credential.js +15 -9
- package/dist/objects/custom-field.js +11 -8
- package/dist/objects/device/alarm.js +6 -3
- package/dist/objects/device/any-device.js +206 -203
- package/dist/objects/device/camera-lift.js +6 -3
- package/dist/objects/device/camera.js +30 -27
- package/dist/objects/device/device-gateway.js +4 -1
- package/dist/objects/device/device-import.js +26 -23
- package/dist/objects/device/device-relation.js +16 -13
- package/dist/objects/device/display.js +6 -3
- package/dist/objects/device/door.js +10 -7
- package/dist/objects/device/index.js +38 -22
- package/dist/objects/device/intercom-operator.js +4 -1
- package/dist/objects/device/intercom-terminal.js +20 -17
- package/dist/objects/device/io-board.js +8 -5
- package/dist/objects/device/motion-sensor.js +6 -3
- package/dist/objects/device/nvr-analytics-server.js +8 -5
- package/dist/objects/device/nvr-exporter.js +9 -6
- package/dist/objects/device/nvr-recorder.js +8 -5
- package/dist/objects/device/panic-button.js +6 -3
- package/dist/objects/device/pbx.js +7 -4
- package/dist/objects/device/presence-tracker.js +4 -1
- package/dist/objects/device/reader.js +4 -1
- package/dist/objects/device/server.js +4 -1
- package/dist/objects/device/system.js +7 -4
- package/dist/objects/device-group.js +11 -8
- package/dist/objects/index.d.ts +1 -0
- package/dist/objects/index.js +44 -27
- package/dist/objects/layout.js +23 -20
- package/dist/objects/macro.js +20 -17
- package/dist/objects/module-config.js +2 -1
- package/dist/objects/notification.js +15 -12
- package/dist/objects/person-agreement.js +10 -7
- package/dist/objects/person-presence.js +32 -29
- package/dist/objects/person-type.js +17 -11
- package/dist/objects/person.js +42 -39
- package/dist/objects/role.js +11 -8
- package/dist/objects/schedule.js +45 -39
- package/dist/objects/security-level.js +13 -10
- package/dist/objects/template.js +10 -7
- package/dist/objects/token-conversion.js +10 -7
- package/dist/objects/user.js +14 -11
- package/dist/objects/view.js +53 -50
- package/dist/objects/world-object.js +8 -5
- package/dist/objects/zone.js +16 -13
- package/dist/package.json +1 -1
- package/dist/permissions.js +149 -146
- package/dist/primitives.js +30 -27
- package/package.json +1 -1
|
@@ -1,323 +1,328 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMessageFromAgent = exports.getAgentMessageIssues = exports.sAbortChange = exports.sApplyChangeProgress = exports.sApplyChangeRs = exports.sApplyChange = exports.sValidateChangeRs = exports.sChangeIssue = exports.sChangeIssueCode = exports.sValidateChangeRq = exports.sRefMap = exports.sDeviceMap = exports.sAccessMutation = exports.sObjectDelete = exports.sObjectMerge = exports.sGetAvailableDevicesRs = exports.sGetAvailableDevicesRq = exports.sPushEventRs = exports.sPushEventRq = exports.sPushStateUpdateRs = exports.sPushStateUpdateRq = exports.sPushFile = exports.sQueryRs = exports.sQueryRq = exports.sRunCommandRs = exports.sRunCommandRq = exports.sStopServiceRs = exports.sStopServiceRq = exports.sStartServiceRs = exports.sStartServiceRq = exports.sValidateProviderConfigRs = exports.sConfigurationIssue = exports.sValidateProviderConfigRq = exports.sUnregister = exports.sRegisterRs = exports.sRegisterRq = exports.sErrorPayload = exports.sAgentErrorCode = exports.sResponsePayload = exports.sMessageWithPayload = exports.sMessageHeader = void 0;
|
|
4
|
+
const device_import_1 = require("../../objects/device/device-import");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const rest_1 = require("../rest");
|
|
7
|
+
const primitives_1 = require("../../primitives");
|
|
8
|
+
const agent_metadata_1 = require("../../objects/agent-metadata");
|
|
6
9
|
// PROTOCOL ENVELOPE
|
|
7
|
-
|
|
8
|
-
version: z.number().describe('Protocol version'),
|
|
9
|
-
id: z.string().nonempty('ID is required').describe('Unique message ID'),
|
|
10
|
-
from: z
|
|
10
|
+
exports.sMessageHeader = zod_1.z.object({
|
|
11
|
+
version: zod_1.z.number().describe('Protocol version'),
|
|
12
|
+
id: zod_1.z.string().nonempty('ID is required').describe('Unique message ID'),
|
|
13
|
+
from: zod_1.z
|
|
11
14
|
.string()
|
|
12
15
|
.nonempty('Agent name required')
|
|
13
16
|
.describe("Sender ID (Agent ID or 'server')"),
|
|
14
|
-
on: z.number().describe('Timestamp in milliseconds since epoch'),
|
|
17
|
+
on: zod_1.z.number().describe('Timestamp in milliseconds since epoch'),
|
|
15
18
|
});
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
const sMessageWithPayload = (sPayload) => exports.sMessageHeader.and(sPayload).describe('Message with payload');
|
|
20
|
+
exports.sMessageWithPayload = sMessageWithPayload;
|
|
21
|
+
const sResponsePayload = (kind, sPayload) =>
|
|
18
22
|
// success branch
|
|
19
|
-
z.object({ requestId: z.string().nonempty(), kind }).and(sPayload);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
zod_1.z.object({ requestId: zod_1.z.string().nonempty(), kind }).and(sPayload);
|
|
24
|
+
exports.sResponsePayload = sResponsePayload;
|
|
25
|
+
exports.sAgentErrorCode = zod_1.z.enum(['NOT_SUPPORTED', 'TIMEOUT']);
|
|
26
|
+
exports.sErrorPayload = (0, exports.sResponsePayload)(zod_1.z.literal('error-rs'), zod_1.z.object({
|
|
27
|
+
error: zod_1.z.string().nonempty().describe('Error message if request failed'),
|
|
28
|
+
code: exports.sAgentErrorCode.optional().describe('Optional error code'),
|
|
24
29
|
}));
|
|
25
30
|
// REGISTER
|
|
26
|
-
|
|
27
|
-
kind: z.literal('register'),
|
|
28
|
-
providers: z
|
|
29
|
-
.record(sProviderSpecs)
|
|
31
|
+
exports.sRegisterRq = zod_1.z.object({
|
|
32
|
+
kind: zod_1.z.literal('register'),
|
|
33
|
+
providers: zod_1.z
|
|
34
|
+
.record(agent_metadata_1.sProviderSpecs)
|
|
30
35
|
.describe('Map of providers and their specs, ones that the agent can handle'),
|
|
31
|
-
accessControlProviders: z.record(sAccessControlCapabilityReport).optional(),
|
|
36
|
+
accessControlProviders: zod_1.z.record(agent_metadata_1.sAccessControlCapabilityReport).optional(),
|
|
32
37
|
});
|
|
33
|
-
|
|
38
|
+
exports.sRegisterRs = (0, exports.sResponsePayload)(zod_1.z.literal('register-rs'), zod_1.z.object({}));
|
|
34
39
|
// UNREGISTER
|
|
35
|
-
|
|
40
|
+
exports.sUnregister = zod_1.z
|
|
36
41
|
.object({
|
|
37
|
-
kind: z.literal('unregister'),
|
|
38
|
-
provider: z.string().nonempty(),
|
|
42
|
+
kind: zod_1.z.literal('unregister'),
|
|
43
|
+
provider: zod_1.z.string().nonempty(),
|
|
39
44
|
})
|
|
40
45
|
.describe('Request to unregister a provider');
|
|
41
46
|
// VALIDATE PROVIDER CONFIG
|
|
42
|
-
|
|
43
|
-
kind: z.literal('validate-config'),
|
|
44
|
-
provider: z.string().nonempty(),
|
|
45
|
-
config: z.record(z.unknown()),
|
|
47
|
+
exports.sValidateProviderConfigRq = zod_1.z.object({
|
|
48
|
+
kind: zod_1.z.literal('validate-config'),
|
|
49
|
+
provider: zod_1.z.string().nonempty(),
|
|
50
|
+
config: zod_1.z.record(zod_1.z.unknown()),
|
|
46
51
|
});
|
|
47
|
-
|
|
52
|
+
exports.sConfigurationIssue = zod_1.z
|
|
48
53
|
.object({
|
|
49
|
-
paths: z.array(z.string()),
|
|
50
|
-
message: z.string(),
|
|
54
|
+
paths: zod_1.z.array(zod_1.z.string()),
|
|
55
|
+
message: zod_1.z.string(),
|
|
51
56
|
})
|
|
52
57
|
.describe('A configuration issue that can be reported by agents');
|
|
53
|
-
|
|
54
|
-
issues: z.array(sConfigurationIssue),
|
|
58
|
+
exports.sValidateProviderConfigRs = (0, exports.sResponsePayload)(zod_1.z.literal('validate-config-rs'), zod_1.z.object({
|
|
59
|
+
issues: zod_1.z.array(exports.sConfigurationIssue),
|
|
55
60
|
})).describe('Validation result for provider configuration');
|
|
56
61
|
// START SERVICE
|
|
57
|
-
|
|
62
|
+
exports.sStartServiceRq = zod_1.z
|
|
58
63
|
.object({
|
|
59
|
-
kind: z.literal('start'),
|
|
60
|
-
provider: z.string().nonempty(),
|
|
61
|
-
config: z.record(z.unknown()),
|
|
62
|
-
lastEventForeignRef: z
|
|
64
|
+
kind: zod_1.z.literal('start'),
|
|
65
|
+
provider: zod_1.z.string().nonempty(),
|
|
66
|
+
config: zod_1.z.record(zod_1.z.unknown()),
|
|
67
|
+
lastEventForeignRef: zod_1.z
|
|
63
68
|
.string()
|
|
64
69
|
.nullable()
|
|
65
70
|
.describe('Last event foreign reference that the agent should start from'),
|
|
66
|
-
lastEventTimestamp: z
|
|
71
|
+
lastEventTimestamp: zod_1.z
|
|
67
72
|
.number()
|
|
68
73
|
.nullable()
|
|
69
74
|
.describe('Last event timestamp that the agent should start from'),
|
|
70
75
|
})
|
|
71
76
|
.describe('Request to start a service for a provider');
|
|
72
|
-
|
|
77
|
+
exports.sStartServiceRs = (0, exports.sResponsePayload)(zod_1.z.literal('start-rs'), zod_1.z.object({})).describe('Response for starting a service for a provider');
|
|
73
78
|
// STOP SERVICE
|
|
74
|
-
|
|
79
|
+
exports.sStopServiceRq = zod_1.z
|
|
75
80
|
.object({
|
|
76
|
-
kind: z.literal('stop'),
|
|
77
|
-
provider: z.string().nonempty(),
|
|
81
|
+
kind: zod_1.z.literal('stop'),
|
|
82
|
+
provider: zod_1.z.string().nonempty(),
|
|
78
83
|
})
|
|
79
84
|
.describe('Request to stop a service for a provider');
|
|
80
|
-
|
|
85
|
+
exports.sStopServiceRs = (0, exports.sResponsePayload)(zod_1.z.literal('stop-rs'), zod_1.z.object({})).describe('Response for starting a service for a provider');
|
|
81
86
|
// RUN COMMAND
|
|
82
|
-
|
|
87
|
+
exports.sRunCommandRq = zod_1.z
|
|
83
88
|
.object({
|
|
84
|
-
kind: z.literal('command'),
|
|
85
|
-
device: sAgentDeviceInfo,
|
|
86
|
-
command: z.string().nonempty(),
|
|
87
|
-
batchId: z
|
|
89
|
+
kind: zod_1.z.literal('command'),
|
|
90
|
+
device: primitives_1.sAgentDeviceInfo,
|
|
91
|
+
command: zod_1.z.string().nonempty(),
|
|
92
|
+
batchId: zod_1.z
|
|
88
93
|
.string()
|
|
89
94
|
.optional()
|
|
90
95
|
.describe('Batch ID for the command of the command was part of a macro'),
|
|
91
|
-
params: z.record(z.unknown()).optional(),
|
|
96
|
+
params: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
92
97
|
})
|
|
93
98
|
.describe('Request to run a device command');
|
|
94
|
-
|
|
99
|
+
exports.sRunCommandRs = (0, exports.sResponsePayload)(zod_1.z.literal('command-rs'), zod_1.z.object({})).describe('Response for running a device command');
|
|
95
100
|
// QUERIES
|
|
96
|
-
|
|
97
|
-
kind: z.literal('query'),
|
|
98
|
-
query: z.string().nonempty(),
|
|
99
|
-
device: sAgentDeviceInfo,
|
|
100
|
-
args: z.unknown().describe('Query arguments, depends on the query type'),
|
|
101
|
+
exports.sQueryRq = zod_1.z.object({
|
|
102
|
+
kind: zod_1.z.literal('query'),
|
|
103
|
+
query: zod_1.z.string().nonempty(),
|
|
104
|
+
device: primitives_1.sAgentDeviceInfo,
|
|
105
|
+
args: zod_1.z.unknown().describe('Query arguments, depends on the query type'),
|
|
101
106
|
});
|
|
102
|
-
|
|
103
|
-
result: z.unknown().describe('Query result, depends on the query type'),
|
|
107
|
+
exports.sQueryRs = (0, exports.sResponsePayload)(zod_1.z.literal('query-rs'), zod_1.z.object({
|
|
108
|
+
result: zod_1.z.unknown().describe('Query result, depends on the query type'),
|
|
104
109
|
})).describe('Response for a query');
|
|
105
110
|
// FILE PUSH INSTRUCTIONS
|
|
106
|
-
|
|
111
|
+
exports.sPushFile = zod_1.z
|
|
107
112
|
.object({
|
|
108
|
-
kind: z.literal('push-file'),
|
|
109
|
-
query: z.string().nonempty(),
|
|
110
|
-
device: sAgentDeviceInfo,
|
|
111
|
-
args: z.unknown().describe('Query arguments, depends on the query type'),
|
|
112
|
-
url: z.string().nonempty().describe('URL to pull the file from'),
|
|
113
|
+
kind: zod_1.z.literal('push-file'),
|
|
114
|
+
query: zod_1.z.string().nonempty(),
|
|
115
|
+
device: primitives_1.sAgentDeviceInfo,
|
|
116
|
+
args: zod_1.z.unknown().describe('Query arguments, depends on the query type'),
|
|
117
|
+
url: zod_1.z.string().nonempty().describe('URL to pull the file from'),
|
|
113
118
|
})
|
|
114
119
|
.describe('Instruction to push a file from an agent to file relay');
|
|
115
120
|
// PUSH DEVICE STATE UPDATE
|
|
116
|
-
|
|
121
|
+
exports.sPushStateUpdateRq = zod_1.z
|
|
117
122
|
.object({
|
|
118
|
-
kind: z.literal('state'),
|
|
119
|
-
foreignRef: z.string().nonempty(),
|
|
120
|
-
provider: z.string().nonempty(),
|
|
121
|
-
mergeProps: z.record(z.unknown()),
|
|
122
|
-
removeProps: z.array(z.string().nonempty()),
|
|
123
|
+
kind: zod_1.z.literal('state'),
|
|
124
|
+
foreignRef: zod_1.z.string().nonempty(),
|
|
125
|
+
provider: zod_1.z.string().nonempty(),
|
|
126
|
+
mergeProps: zod_1.z.record(zod_1.z.unknown()),
|
|
127
|
+
removeProps: zod_1.z.array(zod_1.z.string().nonempty()),
|
|
123
128
|
})
|
|
124
129
|
.describe('Request to push a device state update');
|
|
125
|
-
|
|
130
|
+
exports.sPushStateUpdateRs = (0, exports.sResponsePayload)(zod_1.z.literal('state-rs'), zod_1.z.object({})).describe('Response for pushing a device state update');
|
|
126
131
|
// PUSH DEVICE EVENT
|
|
127
|
-
|
|
132
|
+
exports.sPushEventRq = zod_1.z
|
|
128
133
|
.object({
|
|
129
|
-
kind: z.literal('event'),
|
|
130
|
-
foreignRef: z.string().nonempty(),
|
|
131
|
-
provider: z.string().nonempty(),
|
|
132
|
-
eventTimestamp: z
|
|
134
|
+
kind: zod_1.z.literal('event'),
|
|
135
|
+
foreignRef: zod_1.z.string().nonempty(),
|
|
136
|
+
provider: zod_1.z.string().nonempty(),
|
|
137
|
+
eventTimestamp: zod_1.z
|
|
133
138
|
.number()
|
|
134
139
|
.describe('Event timestamp in milliseconds since epoch, as reported by origin'),
|
|
135
|
-
eventForeignRef: z.string().nonempty(),
|
|
136
|
-
event: z.unknown().describe('Event data'),
|
|
140
|
+
eventForeignRef: zod_1.z.string().nonempty(),
|
|
141
|
+
event: zod_1.z.unknown().describe('Event data'),
|
|
137
142
|
})
|
|
138
143
|
.describe('Request to push a device event');
|
|
139
|
-
|
|
144
|
+
exports.sPushEventRs = (0, exports.sResponsePayload)(zod_1.z.literal('event-rs'), zod_1.z.object({})).describe('Response for pushing a device event');
|
|
140
145
|
// REQUEST AVAILABLE DEVICES (DISCOVERY)
|
|
141
|
-
|
|
146
|
+
exports.sGetAvailableDevicesRq = zod_1.z
|
|
142
147
|
.object({
|
|
143
|
-
kind: z.literal('get-available-devices'),
|
|
144
|
-
provider: z.string().nonempty(),
|
|
148
|
+
kind: zod_1.z.literal('get-available-devices'),
|
|
149
|
+
provider: zod_1.z.string().nonempty(),
|
|
145
150
|
})
|
|
146
151
|
.describe('Request to get available devices from a provider via an agent');
|
|
147
|
-
|
|
152
|
+
exports.sGetAvailableDevicesRs = (0, exports.sResponsePayload)(zod_1.z.literal('get-available-devices-rs'), device_import_1.sDeviceDiscoveryDto).describe('Response for getting available devices from a provider via an agent');
|
|
148
153
|
// ACCESS SYNC SECTION
|
|
149
154
|
// ————————————————————————————————————————————————————
|
|
150
155
|
// Merge (insert vs update) variants, all listed explicitly
|
|
151
156
|
// ————————————————————————————————————————————————————
|
|
152
|
-
|
|
157
|
+
exports.sObjectMerge = zod_1.z
|
|
153
158
|
.union([
|
|
154
159
|
// accessRule insert
|
|
155
|
-
z.object({
|
|
156
|
-
kind: z.literal('merge'),
|
|
157
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
158
|
-
objectKind: z.literal('accessRule'),
|
|
159
|
-
original: z.null(),
|
|
160
|
-
props: sCreateAccessRuleRequest,
|
|
160
|
+
zod_1.z.object({
|
|
161
|
+
kind: zod_1.z.literal('merge'),
|
|
162
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
163
|
+
objectKind: zod_1.z.literal('accessRule'),
|
|
164
|
+
original: zod_1.z.null(),
|
|
165
|
+
props: rest_1.sCreateAccessRuleRequest,
|
|
161
166
|
}),
|
|
162
167
|
// accessRule update
|
|
163
|
-
z.object({
|
|
164
|
-
kind: z.literal('merge'),
|
|
165
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
166
|
-
objectKind: z.literal('accessRule'),
|
|
167
|
-
original: sCreateAccessRuleRequest,
|
|
168
|
-
props: sCreateAccessRuleRequest.partial(),
|
|
168
|
+
zod_1.z.object({
|
|
169
|
+
kind: zod_1.z.literal('merge'),
|
|
170
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
171
|
+
objectKind: zod_1.z.literal('accessRule'),
|
|
172
|
+
original: rest_1.sCreateAccessRuleRequest,
|
|
173
|
+
props: rest_1.sCreateAccessRuleRequest.partial(),
|
|
169
174
|
}),
|
|
170
175
|
// schedule insert
|
|
171
|
-
z.object({
|
|
172
|
-
kind: z.literal('merge'),
|
|
173
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
174
|
-
objectKind: z.literal('schedule'),
|
|
175
|
-
original: z.null(),
|
|
176
|
-
props: sCreateScheduleRequest,
|
|
176
|
+
zod_1.z.object({
|
|
177
|
+
kind: zod_1.z.literal('merge'),
|
|
178
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
179
|
+
objectKind: zod_1.z.literal('schedule'),
|
|
180
|
+
original: zod_1.z.null(),
|
|
181
|
+
props: rest_1.sCreateScheduleRequest,
|
|
177
182
|
}),
|
|
178
183
|
// schedule update
|
|
179
|
-
z.object({
|
|
180
|
-
kind: z.literal('merge'),
|
|
181
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
182
|
-
objectKind: z.literal('schedule'),
|
|
183
|
-
original: sCreateScheduleRequest,
|
|
184
|
-
props: sCreateScheduleRequest.partial(),
|
|
184
|
+
zod_1.z.object({
|
|
185
|
+
kind: zod_1.z.literal('merge'),
|
|
186
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
187
|
+
objectKind: zod_1.z.literal('schedule'),
|
|
188
|
+
original: rest_1.sCreateScheduleRequest,
|
|
189
|
+
props: rest_1.sCreateScheduleRequest.partial(),
|
|
185
190
|
}),
|
|
186
191
|
// person insert
|
|
187
|
-
z.object({
|
|
188
|
-
kind: z.literal('merge'),
|
|
189
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
190
|
-
objectKind: z.literal('person'),
|
|
191
|
-
original: z.null(),
|
|
192
|
-
props: sCreatePersonRequest,
|
|
192
|
+
zod_1.z.object({
|
|
193
|
+
kind: zod_1.z.literal('merge'),
|
|
194
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
195
|
+
objectKind: zod_1.z.literal('person'),
|
|
196
|
+
original: zod_1.z.null(),
|
|
197
|
+
props: rest_1.sCreatePersonRequest,
|
|
193
198
|
}),
|
|
194
199
|
// person update
|
|
195
|
-
z.object({
|
|
196
|
-
kind: z.literal('merge'),
|
|
197
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
198
|
-
objectKind: z.literal('person'),
|
|
199
|
-
original: sCreatePersonRequest,
|
|
200
|
-
props: sCreatePersonRequest.partial(),
|
|
200
|
+
zod_1.z.object({
|
|
201
|
+
kind: zod_1.z.literal('merge'),
|
|
202
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
203
|
+
objectKind: zod_1.z.literal('person'),
|
|
204
|
+
original: rest_1.sCreatePersonRequest,
|
|
205
|
+
props: rest_1.sCreatePersonRequest.partial(),
|
|
201
206
|
}),
|
|
202
207
|
// zone insert
|
|
203
|
-
z.object({
|
|
204
|
-
kind: z.literal('merge'),
|
|
205
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
206
|
-
objectKind: z.literal('zone'),
|
|
207
|
-
original: z.null(),
|
|
208
|
-
props: sCreateZoneRequest,
|
|
208
|
+
zod_1.z.object({
|
|
209
|
+
kind: zod_1.z.literal('merge'),
|
|
210
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
211
|
+
objectKind: zod_1.z.literal('zone'),
|
|
212
|
+
original: zod_1.z.null(),
|
|
213
|
+
props: rest_1.sCreateZoneRequest,
|
|
209
214
|
}),
|
|
210
215
|
// zone update
|
|
211
|
-
z.object({
|
|
212
|
-
kind: z.literal('merge'),
|
|
213
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
214
|
-
objectKind: z.literal('zone'),
|
|
215
|
-
original: sCreateZoneRequest,
|
|
216
|
-
props: sCreateZoneRequest.partial(),
|
|
216
|
+
zod_1.z.object({
|
|
217
|
+
kind: zod_1.z.literal('merge'),
|
|
218
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
219
|
+
objectKind: zod_1.z.literal('zone'),
|
|
220
|
+
original: rest_1.sCreateZoneRequest,
|
|
221
|
+
props: rest_1.sCreateZoneRequest.partial(),
|
|
217
222
|
}),
|
|
218
223
|
])
|
|
219
224
|
.describe('Object merge request');
|
|
220
225
|
// ————————————————————————————————————————————————————
|
|
221
226
|
// Delete variants, also fully expanded
|
|
222
227
|
// ————————————————————————————————————————————————————
|
|
223
|
-
|
|
228
|
+
exports.sObjectDelete = zod_1.z
|
|
224
229
|
.union([
|
|
225
|
-
z.object({
|
|
226
|
-
kind: z.literal('delete'),
|
|
227
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
228
|
-
objectKind: z.literal('accessRule'),
|
|
229
|
-
original: sCreateAccessRuleRequest,
|
|
230
|
+
zod_1.z.object({
|
|
231
|
+
kind: zod_1.z.literal('delete'),
|
|
232
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
233
|
+
objectKind: zod_1.z.literal('accessRule'),
|
|
234
|
+
original: rest_1.sCreateAccessRuleRequest,
|
|
230
235
|
}),
|
|
231
|
-
z.object({
|
|
232
|
-
kind: z.literal('delete'),
|
|
233
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
234
|
-
objectKind: z.literal('schedule'),
|
|
235
|
-
original: sCreateScheduleRequest,
|
|
236
|
+
zod_1.z.object({
|
|
237
|
+
kind: zod_1.z.literal('delete'),
|
|
238
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
239
|
+
objectKind: zod_1.z.literal('schedule'),
|
|
240
|
+
original: rest_1.sCreateScheduleRequest,
|
|
236
241
|
}),
|
|
237
|
-
z.object({
|
|
238
|
-
kind: z.literal('delete'),
|
|
239
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
240
|
-
objectKind: z.literal('person'),
|
|
241
|
-
original: sCreatePersonRequest,
|
|
242
|
+
zod_1.z.object({
|
|
243
|
+
kind: zod_1.z.literal('delete'),
|
|
244
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
245
|
+
objectKind: zod_1.z.literal('person'),
|
|
246
|
+
original: rest_1.sCreatePersonRequest,
|
|
242
247
|
}),
|
|
243
|
-
z.object({
|
|
244
|
-
kind: z.literal('delete'),
|
|
245
|
-
objectId: z.string().nonempty().describe('Object ID as in backend'),
|
|
246
|
-
objectKind: z.literal('zone'),
|
|
247
|
-
original: sCreateZoneRequest,
|
|
248
|
+
zod_1.z.object({
|
|
249
|
+
kind: zod_1.z.literal('delete'),
|
|
250
|
+
objectId: zod_1.z.string().nonempty().describe('Object ID as in backend'),
|
|
251
|
+
objectKind: zod_1.z.literal('zone'),
|
|
252
|
+
original: rest_1.sCreateZoneRequest,
|
|
248
253
|
}),
|
|
249
254
|
])
|
|
250
255
|
.describe('Object delete request');
|
|
251
|
-
|
|
252
|
-
.union([sObjectMerge, sObjectDelete])
|
|
256
|
+
exports.sAccessMutation = zod_1.z
|
|
257
|
+
.union([exports.sObjectMerge, exports.sObjectDelete])
|
|
253
258
|
.describe('Access object change description');
|
|
254
|
-
|
|
255
|
-
.record(z.record(z.unknown()))
|
|
259
|
+
exports.sDeviceMap = zod_1.z
|
|
260
|
+
.record(zod_1.z.record(zod_1.z.unknown()))
|
|
256
261
|
.describe('Map of devices (readers) and their stashed provider metadata');
|
|
257
|
-
|
|
258
|
-
.record(z.record(z.array(z.string().nonempty())))
|
|
262
|
+
exports.sRefMap = zod_1.z
|
|
263
|
+
.record(zod_1.z.record(zod_1.z.array(zod_1.z.string().nonempty())))
|
|
259
264
|
.describe('Map of foreign references to object IDs');
|
|
260
265
|
// A. VALIDATE ACCESS CHANGES
|
|
261
|
-
|
|
266
|
+
exports.sValidateChangeRq = zod_1.z
|
|
262
267
|
.object({
|
|
263
|
-
kind: z.literal('validate-change'),
|
|
264
|
-
provider: z.string().nonempty(),
|
|
265
|
-
devices: sDeviceMap,
|
|
266
|
-
refMap: sRefMap,
|
|
267
|
-
mutations: z.array(sAccessMutation),
|
|
268
|
+
kind: zod_1.z.literal('validate-change'),
|
|
269
|
+
provider: zod_1.z.string().nonempty(),
|
|
270
|
+
devices: exports.sDeviceMap,
|
|
271
|
+
refMap: exports.sRefMap,
|
|
272
|
+
mutations: zod_1.z.array(exports.sAccessMutation),
|
|
268
273
|
})
|
|
269
274
|
.describe('Request to validate access changes');
|
|
270
|
-
|
|
275
|
+
exports.sChangeIssueCode = zod_1.z.enum([
|
|
271
276
|
'BAD_REFERENCE',
|
|
272
277
|
'NOT_FOUND',
|
|
273
278
|
'NOT_UNIQUE',
|
|
274
279
|
'INVALID',
|
|
275
280
|
'NOT_SUPPORTED',
|
|
276
281
|
]);
|
|
277
|
-
|
|
282
|
+
exports.sChangeIssue = zod_1.z
|
|
278
283
|
.object({
|
|
279
|
-
objectId: z.string().optional().describe('Object ID as in backend'),
|
|
280
|
-
objectKind: sAccessObjectKind.optional(),
|
|
281
|
-
code: sChangeIssueCode
|
|
284
|
+
objectId: zod_1.z.string().optional().describe('Object ID as in backend'),
|
|
285
|
+
objectKind: agent_metadata_1.sAccessObjectKind.optional(),
|
|
286
|
+
code: exports.sChangeIssueCode
|
|
282
287
|
.optional()
|
|
283
288
|
.describe('Issue code that describes the issue to UI agent(s) or bots'),
|
|
284
|
-
path: z
|
|
289
|
+
path: zod_1.z
|
|
285
290
|
.string()
|
|
286
291
|
.optional()
|
|
287
292
|
.describe('Path - inside object referenced by ObjectID, points to a field or a related object'),
|
|
288
|
-
index: z
|
|
293
|
+
index: zod_1.z
|
|
289
294
|
.number()
|
|
290
295
|
.optional()
|
|
291
296
|
.describe('Index ofa value in field pointed at by path'),
|
|
292
|
-
message: z
|
|
297
|
+
message: zod_1.z
|
|
293
298
|
.string()
|
|
294
299
|
.optional()
|
|
295
300
|
.describe('Message that describes the issue to user or the details of what went wrong'),
|
|
296
301
|
})
|
|
297
302
|
.describe('Access change issue description');
|
|
298
|
-
|
|
299
|
-
issues: z.array(sChangeIssue),
|
|
303
|
+
exports.sValidateChangeRs = (0, exports.sResponsePayload)(zod_1.z.literal('validate-change-rs'), zod_1.z.object({
|
|
304
|
+
issues: zod_1.z.array(exports.sChangeIssue),
|
|
300
305
|
})).describe('Response for validating access changes');
|
|
301
306
|
// B. APPLY ACCESS CHANGES
|
|
302
|
-
|
|
307
|
+
exports.sApplyChange = zod_1.z
|
|
303
308
|
.object({
|
|
304
|
-
kind: z.literal('apply-change'),
|
|
305
|
-
provider: z.string().nonempty(),
|
|
306
|
-
devices: sDeviceMap,
|
|
307
|
-
refMap: sRefMap,
|
|
308
|
-
mutations: z.array(sAccessMutation),
|
|
309
|
+
kind: zod_1.z.literal('apply-change'),
|
|
310
|
+
provider: zod_1.z.string().nonempty(),
|
|
311
|
+
devices: exports.sDeviceMap,
|
|
312
|
+
refMap: exports.sRefMap,
|
|
313
|
+
mutations: zod_1.z.array(exports.sAccessMutation),
|
|
309
314
|
})
|
|
310
315
|
.describe('Request to apply access changes');
|
|
311
|
-
|
|
312
|
-
requestId: z.string().nonempty(),
|
|
316
|
+
exports.sApplyChangeRs = (0, exports.sResponsePayload)(zod_1.z.literal('apply-change-rs'), zod_1.z.object({
|
|
317
|
+
requestId: zod_1.z.string().nonempty(),
|
|
313
318
|
//error: z.string().optional().describe('Error message if request failed'),
|
|
314
|
-
refs: sRefMap,
|
|
319
|
+
refs: exports.sRefMap,
|
|
315
320
|
})).describe('Response for applying access changes');
|
|
316
|
-
|
|
321
|
+
exports.sApplyChangeProgress = zod_1.z
|
|
317
322
|
.object({
|
|
318
|
-
kind: z.literal('apply-change-progress'),
|
|
319
|
-
requestId: z.string().nonempty(),
|
|
320
|
-
mutationIndex: z
|
|
323
|
+
kind: zod_1.z.literal('apply-change-progress'),
|
|
324
|
+
requestId: zod_1.z.string().nonempty(),
|
|
325
|
+
mutationIndex: zod_1.z
|
|
321
326
|
.number()
|
|
322
327
|
.describe('Index of the finished mutation in the batch'),
|
|
323
328
|
// total: z.number().describe('Progress of the access changes'),
|
|
@@ -325,31 +330,31 @@ export const sApplyChangeProgress = z
|
|
|
325
330
|
})
|
|
326
331
|
.describe('Progress of the access changes');
|
|
327
332
|
// C. ABORT CHANGES
|
|
328
|
-
|
|
333
|
+
exports.sAbortChange = zod_1.z
|
|
329
334
|
.object({
|
|
330
|
-
kind: z.literal('abort-change'),
|
|
331
|
-
provider: z.string().nonempty(),
|
|
332
|
-
policyVersion: z.number().describe('Version of the access changes'),
|
|
335
|
+
kind: zod_1.z.literal('abort-change'),
|
|
336
|
+
provider: zod_1.z.string().nonempty(),
|
|
337
|
+
policyVersion: zod_1.z.number().describe('Version of the access changes'),
|
|
333
338
|
})
|
|
334
339
|
.describe('Request to abort access changes');
|
|
335
340
|
const fromAgentSchemaByKind = {
|
|
336
|
-
register: sRegisterRq,
|
|
337
|
-
unregister: sUnregister,
|
|
338
|
-
'validate-config-rs': sValidateProviderConfigRs,
|
|
339
|
-
'start-rs': sStartServiceRs,
|
|
340
|
-
'stop-rs': sStopServiceRs,
|
|
341
|
-
'command-rs': sRunCommandRs,
|
|
342
|
-
'query-rs': sQueryRs,
|
|
343
|
-
state: sPushStateUpdateRq,
|
|
344
|
-
event: sPushEventRq,
|
|
345
|
-
'get-available-devices-rs': sGetAvailableDevicesRs,
|
|
346
|
-
'validate-change-rs': sValidateChangeRs,
|
|
347
|
-
'apply-change-rs': sApplyChangeRs,
|
|
348
|
-
'apply-change-progress': sApplyChangeProgress,
|
|
349
|
-
'error-rs': sErrorPayload,
|
|
341
|
+
register: exports.sRegisterRq,
|
|
342
|
+
unregister: exports.sUnregister,
|
|
343
|
+
'validate-config-rs': exports.sValidateProviderConfigRs,
|
|
344
|
+
'start-rs': exports.sStartServiceRs,
|
|
345
|
+
'stop-rs': exports.sStopServiceRs,
|
|
346
|
+
'command-rs': exports.sRunCommandRs,
|
|
347
|
+
'query-rs': exports.sQueryRs,
|
|
348
|
+
state: exports.sPushStateUpdateRq,
|
|
349
|
+
event: exports.sPushEventRq,
|
|
350
|
+
'get-available-devices-rs': exports.sGetAvailableDevicesRs,
|
|
351
|
+
'validate-change-rs': exports.sValidateChangeRs,
|
|
352
|
+
'apply-change-rs': exports.sApplyChangeRs,
|
|
353
|
+
'apply-change-progress': exports.sApplyChangeProgress,
|
|
354
|
+
'error-rs': exports.sErrorPayload,
|
|
350
355
|
};
|
|
351
|
-
|
|
352
|
-
const result = sMessageHeader.safeParse(message);
|
|
356
|
+
const getAgentMessageIssues = (message) => {
|
|
357
|
+
const result = exports.sMessageHeader.safeParse(message);
|
|
353
358
|
if (!result.success) {
|
|
354
359
|
return result.error.errors.map((e) => `${e.path.map((p) => p.toString()).join('.')} - ${e.message}`);
|
|
355
360
|
}
|
|
@@ -364,11 +369,12 @@ export const getAgentMessageIssues = (message) => {
|
|
|
364
369
|
}
|
|
365
370
|
return [];
|
|
366
371
|
};
|
|
367
|
-
|
|
372
|
+
exports.getAgentMessageIssues = getAgentMessageIssues;
|
|
373
|
+
const isMessageFromAgent = (message) => {
|
|
368
374
|
if (typeof message !== 'object' || message === null) {
|
|
369
375
|
return false;
|
|
370
376
|
}
|
|
371
|
-
const headerResult = sMessageHeader.safeParse(message);
|
|
377
|
+
const headerResult = exports.sMessageHeader.safeParse(message);
|
|
372
378
|
if (!headerResult.success) {
|
|
373
379
|
return false;
|
|
374
380
|
}
|
|
@@ -380,3 +386,4 @@ export const isMessageFromAgent = (message) => {
|
|
|
380
386
|
const result = schema.safeParse(message);
|
|
381
387
|
return result.success;
|
|
382
388
|
};
|
|
389
|
+
exports.isMessageFromAgent = isMessageFromAgent;
|