@awarevue/api-types 1.0.1
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/access-control/access-rule.d.ts +243 -0
- package/dist/access-control/access-rule.js +49 -0
- package/dist/access-control/credential.d.ts +14 -0
- package/dist/access-control/credential.js +12 -0
- package/dist/access-control/index.d.ts +7 -0
- package/dist/access-control/index.js +23 -0
- package/dist/access-control/person-presence.d.ts +249 -0
- package/dist/access-control/person-presence.js +61 -0
- package/dist/access-control/person.d.ts +209 -0
- package/dist/access-control/person.js +49 -0
- package/dist/access-control/schedule.d.ts +500 -0
- package/dist/access-control/schedule.js +65 -0
- package/dist/access-control/sync.d.ts +3 -0
- package/dist/access-control/sync.js +2 -0
- package/dist/access-control/zone.d.ts +65 -0
- package/dist/access-control/zone.js +28 -0
- package/dist/agent-communication/index.d.ts +1 -0
- package/dist/agent-communication/index.js +17 -0
- package/dist/agent-communication/protocol.d.ts +1692 -0
- package/dist/agent-communication/protocol.js +341 -0
- package/dist/api/alarm.d.ts +23 -0
- package/dist/api/alarm.js +2 -0
- package/dist/api/auth.d.ts +31 -0
- package/dist/api/auth.js +19 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.js +20 -0
- package/dist/api/media.d.ts +187 -0
- package/dist/api/media.js +59 -0
- package/dist/api/query.d.ts +33 -0
- package/dist/api/query.js +41 -0
- package/dist/app.d.ts +12 -0
- package/dist/app.js +8 -0
- package/dist/automation.d.ts +334 -0
- package/dist/automation.js +49 -0
- package/dist/aware-config.d.ts +3 -0
- package/dist/aware-config.js +2 -0
- package/dist/custom-field.d.ts +52 -0
- package/dist/custom-field.js +19 -0
- package/dist/device/alarm.d.ts +265 -0
- package/dist/device/alarm.js +66 -0
- package/dist/device/any-device.d.ts +2376 -0
- package/dist/device/any-device.js +185 -0
- package/dist/device/camera-lift.d.ts +17 -0
- package/dist/device/camera-lift.js +7 -0
- package/dist/device/camera.d.ts +829 -0
- package/dist/device/camera.js +120 -0
- package/dist/device/device-gateway.d.ts +3 -0
- package/dist/device/device-gateway.js +4 -0
- package/dist/device/door.d.ts +217 -0
- package/dist/device/door.js +57 -0
- package/dist/device/index.d.ts +15 -0
- package/dist/device/index.js +31 -0
- package/dist/device/intercom-operator.d.ts +13 -0
- package/dist/device/intercom-operator.js +5 -0
- package/dist/device/intercom-terminal.d.ts +244 -0
- package/dist/device/intercom-terminal.js +48 -0
- package/dist/device/io-board.d.ts +55 -0
- package/dist/device/io-board.js +19 -0
- package/dist/device/motion-sensor.d.ts +8 -0
- package/dist/device/motion-sensor.js +8 -0
- package/dist/device/panic-button.d.ts +26 -0
- package/dist/device/panic-button.js +14 -0
- package/dist/device/pbx.d.ts +20 -0
- package/dist/device/pbx.js +11 -0
- package/dist/device/presence-tracker.d.ts +127 -0
- package/dist/device/presence-tracker.js +27 -0
- package/dist/device/reader/commands.d.ts +1 -0
- package/dist/device/reader/commands.js +2 -0
- package/dist/device/reader/events.d.ts +37 -0
- package/dist/device/reader/events.js +13 -0
- package/dist/device/reader/index.d.ts +3 -0
- package/dist/device/reader/index.js +19 -0
- package/dist/device/reader/specs.d.ts +2 -0
- package/dist/device/reader/specs.js +4 -0
- package/dist/device/server.d.ts +73 -0
- package/dist/device/server.js +33 -0
- package/dist/device-command.d.ts +23 -0
- package/dist/device-command.js +110 -0
- package/dist/device-event.d.ts +682 -0
- package/dist/device-event.js +87 -0
- package/dist/device-factory.d.ts +112 -0
- package/dist/device-factory.js +25 -0
- package/dist/device-group.d.ts +74 -0
- package/dist/device-group.js +31 -0
- package/dist/device-import.d.ts +1412 -0
- package/dist/device-import.js +33 -0
- package/dist/device-relation.d.ts +30 -0
- package/dist/device-relation.js +68 -0
- package/dist/device-state.d.ts +10 -0
- package/dist/device-state.js +2 -0
- package/dist/error.d.ts +13 -0
- package/dist/error.js +10 -0
- package/dist/file.d.ts +3 -0
- package/dist/file.js +2 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +44 -0
- package/dist/layout.d.ts +188 -0
- package/dist/layout.js +40 -0
- package/dist/macros.d.ts +160 -0
- package/dist/macros.js +26 -0
- package/dist/messages/device-communication.d.ts +121 -0
- package/dist/messages/device-communication.js +63 -0
- package/dist/messages/index.d.ts +5 -0
- package/dist/messages/index.js +21 -0
- package/dist/messages/progress.d.ts +118 -0
- package/dist/messages/progress.js +51 -0
- package/dist/messages/provider-api/index.d.ts +1 -0
- package/dist/messages/provider-api/index.js +17 -0
- package/dist/messages/provider-api/sync-protocol.d.ts +83 -0
- package/dist/messages/provider-api/sync-protocol.js +2 -0
- package/dist/messages/web-rtc-signaling.d.ts +265 -0
- package/dist/messages/web-rtc-signaling.js +82 -0
- package/dist/messages/web-socket.d.ts +7 -0
- package/dist/messages/web-socket.js +5 -0
- package/dist/milestone.d.ts +5 -0
- package/dist/milestone.js +2 -0
- package/dist/module-config.d.ts +27 -0
- package/dist/module-config.js +2 -0
- package/dist/orchid.d.ts +19 -0
- package/dist/orchid.js +2 -0
- package/dist/package.json +40 -0
- package/dist/permissions.d.ts +6 -0
- package/dist/permissions.js +168 -0
- package/dist/template.d.ts +50 -0
- package/dist/template.js +21 -0
- package/dist/user.d.ts +184 -0
- package/dist/user.js +56 -0
- package/dist/view.d.ts +775 -0
- package/dist/view.js +74 -0
- package/dist/webrtc-playback.d.ts +20 -0
- package/dist/webrtc-playback.js +14 -0
- package/package.json +40 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMessageFromAgent = exports.getAgentMessageIssues = exports.abortChange = exports.sApplyChangeProgress = exports.sApplyChangeComplete = exports.sApplyChange = exports.sValidateChangeRs = exports.sChangeIssue = exports.sValidateChangeRq = exports.sDeviceMap = exports.sAccessMutation = exports.sRelationMerge = exports.sObjectDelete = exports.sObjectMerge = exports.sRegisterAccessControlAgentRs = exports.sRegisterAccessControlAgentRq = exports.sCapabilityReport = exports.sTokenSpecs = exports.sAccessObjectKind = exports.sGetAvailableDevicesRs = exports.sGetAvailableDevicesRq = exports.sPushEventRs = exports.sPushEventRq = exports.sPushStateUpdateRs = exports.sPushStateUpdateRq = 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.sProviderSpecs = exports.sUiHint = exports.sUiWidgetHint = exports.sUiOrderHint = exports.sErrorPayload = exports.sResponsePayload = exports.sMessageWithPayload = exports.sMessageHeader = void 0;
|
|
4
|
+
const device_1 = require("../device");
|
|
5
|
+
const device_import_1 = require("../device-import");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
// PROTOCOL ENVELOPE
|
|
8
|
+
exports.sMessageHeader = zod_1.z.object({
|
|
9
|
+
version: zod_1.z.number().describe('Protocol version'),
|
|
10
|
+
id: zod_1.z.string().nonempty('ID is required').describe('Unique message ID'),
|
|
11
|
+
from: zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.nonempty('Agent name required')
|
|
14
|
+
.describe("Sender ID (Agent ID or 'server')"),
|
|
15
|
+
on: zod_1.z.number().describe('Timestamp in milliseconds since epoch'),
|
|
16
|
+
});
|
|
17
|
+
const sMessageWithPayload = (sPayload) => exports.sMessageHeader.and(sPayload).describe('Message with payload');
|
|
18
|
+
exports.sMessageWithPayload = sMessageWithPayload;
|
|
19
|
+
const sResponsePayload = (kind, sPayload) =>
|
|
20
|
+
// success branch
|
|
21
|
+
zod_1.z.object({ requestId: zod_1.z.string().nonempty(), kind }).and(sPayload);
|
|
22
|
+
exports.sResponsePayload = sResponsePayload;
|
|
23
|
+
exports.sErrorPayload = (0, exports.sResponsePayload)(zod_1.z.literal('error-rs'), zod_1.z.object({
|
|
24
|
+
error: zod_1.z.string().nonempty().describe('Error message if request failed'),
|
|
25
|
+
}));
|
|
26
|
+
// REGISTER
|
|
27
|
+
exports.sUiOrderHint = zod_1.z.object({
|
|
28
|
+
kind: zod_1.z.literal('order'),
|
|
29
|
+
path: zod_1.z.string(),
|
|
30
|
+
fields: zod_1.z.array(zod_1.z.string().nonempty()),
|
|
31
|
+
});
|
|
32
|
+
exports.sUiWidgetHint = zod_1.z.object({
|
|
33
|
+
kind: zod_1.z.literal('widget'),
|
|
34
|
+
path: zod_1.z.string(),
|
|
35
|
+
spanColumns: zod_1.z.number().optional(),
|
|
36
|
+
password: zod_1.z.boolean().optional(),
|
|
37
|
+
placeHolder: zod_1.z.string().optional(),
|
|
38
|
+
});
|
|
39
|
+
exports.sUiHint = zod_1.z.union([exports.sUiOrderHint, exports.sUiWidgetHint]);
|
|
40
|
+
exports.sProviderSpecs = zod_1.z.object({
|
|
41
|
+
title: zod_1.z
|
|
42
|
+
.string()
|
|
43
|
+
.nonempty()
|
|
44
|
+
.describe('a human-readable name for the provider'),
|
|
45
|
+
configSchema: zod_1.z
|
|
46
|
+
.unknown()
|
|
47
|
+
.describe('a valid JSON schema that describes provider config data structure'), // We can use AJV to validate the definition of a JSON schema
|
|
48
|
+
configDefault: zod_1.z
|
|
49
|
+
.record(zod_1.z.unknown())
|
|
50
|
+
.describe('Default initialized values for configuration'),
|
|
51
|
+
configFormUiHints: zod_1.z
|
|
52
|
+
.array(exports.sUiHint)
|
|
53
|
+
.optional()
|
|
54
|
+
.describe('UI hints for configuration form visuals'),
|
|
55
|
+
});
|
|
56
|
+
exports.sRegisterRq = zod_1.z.object({
|
|
57
|
+
kind: zod_1.z.literal('register'),
|
|
58
|
+
providers: zod_1.z
|
|
59
|
+
.record(exports.sProviderSpecs)
|
|
60
|
+
.describe('Map of providers and their specs, ones that the agent can handle'),
|
|
61
|
+
});
|
|
62
|
+
exports.sRegisterRs = (0, exports.sResponsePayload)(zod_1.z.literal('register-rs'), zod_1.z.object({}));
|
|
63
|
+
// UNREGISTER
|
|
64
|
+
exports.sUnregister = zod_1.z
|
|
65
|
+
.object({
|
|
66
|
+
kind: zod_1.z.literal('unregister'),
|
|
67
|
+
provider: zod_1.z.string().nonempty(),
|
|
68
|
+
})
|
|
69
|
+
.describe('Request to unregister a provider');
|
|
70
|
+
// VALIDATE PROVIDER CONFIG
|
|
71
|
+
exports.sValidateProviderConfigRq = zod_1.z.object({
|
|
72
|
+
kind: zod_1.z.literal('validate-config'),
|
|
73
|
+
provider: zod_1.z.string().nonempty(),
|
|
74
|
+
config: zod_1.z.record(zod_1.z.unknown()),
|
|
75
|
+
});
|
|
76
|
+
exports.sConfigurationIssue = zod_1.z
|
|
77
|
+
.object({
|
|
78
|
+
paths: zod_1.z.array(zod_1.z.string()),
|
|
79
|
+
message: zod_1.z.string(),
|
|
80
|
+
})
|
|
81
|
+
.describe('A configuration issue that can be reported by agents');
|
|
82
|
+
exports.sValidateProviderConfigRs = (0, exports.sResponsePayload)(zod_1.z.literal('validate-config-rs'), zod_1.z.object({
|
|
83
|
+
issues: zod_1.z.array(exports.sConfigurationIssue),
|
|
84
|
+
})).describe('Validation result for provider configuration');
|
|
85
|
+
// START SERVICE
|
|
86
|
+
exports.sStartServiceRq = zod_1.z
|
|
87
|
+
.object({
|
|
88
|
+
kind: zod_1.z.literal('start'),
|
|
89
|
+
provider: zod_1.z.string().nonempty(),
|
|
90
|
+
config: zod_1.z.record(zod_1.z.unknown()),
|
|
91
|
+
lastEventForeignRef: zod_1.z
|
|
92
|
+
.string()
|
|
93
|
+
.nullable()
|
|
94
|
+
.describe('Last event foreign reference that the agent should start from'),
|
|
95
|
+
lastEventTimestamp: zod_1.z
|
|
96
|
+
.number()
|
|
97
|
+
.nullable()
|
|
98
|
+
.describe('Last event timestamp that the agent should start from'),
|
|
99
|
+
})
|
|
100
|
+
.describe('Request to start a service for a provider');
|
|
101
|
+
exports.sStartServiceRs = (0, exports.sResponsePayload)(zod_1.z.literal('start-rs'), zod_1.z.object({})).describe('Response for starting a service for a provider');
|
|
102
|
+
// STOP SERVICE
|
|
103
|
+
exports.sStopServiceRq = zod_1.z
|
|
104
|
+
.object({
|
|
105
|
+
kind: zod_1.z.literal('stop'),
|
|
106
|
+
provider: zod_1.z.string().nonempty(),
|
|
107
|
+
})
|
|
108
|
+
.describe('Request to stop a service for a provider');
|
|
109
|
+
exports.sStopServiceRs = (0, exports.sResponsePayload)(zod_1.z.literal('stop-rs'), zod_1.z.object({})).describe('Response for starting a service for a provider');
|
|
110
|
+
// RUN COMMAND
|
|
111
|
+
exports.sRunCommandRq = zod_1.z
|
|
112
|
+
.object({
|
|
113
|
+
kind: zod_1.z.literal('command'),
|
|
114
|
+
device: device_1.sForeignDeviceInfo,
|
|
115
|
+
command: zod_1.z.string().nonempty(),
|
|
116
|
+
batchId: zod_1.z
|
|
117
|
+
.string()
|
|
118
|
+
.optional()
|
|
119
|
+
.describe('Batch ID for the command of the command was part of a macro'),
|
|
120
|
+
params: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
121
|
+
})
|
|
122
|
+
.describe('Request to run a device command');
|
|
123
|
+
exports.sRunCommandRs = (0, exports.sResponsePayload)(zod_1.z.literal('command-rs'), zod_1.z.object({})).describe('Response for running a device command');
|
|
124
|
+
// PUSH DEVICE STATE UPDATE
|
|
125
|
+
exports.sPushStateUpdateRq = zod_1.z
|
|
126
|
+
.object({
|
|
127
|
+
kind: zod_1.z.literal('state'),
|
|
128
|
+
foreignRef: zod_1.z.string().nonempty(),
|
|
129
|
+
provider: zod_1.z.string().nonempty(),
|
|
130
|
+
mergeProps: zod_1.z.record(zod_1.z.unknown()),
|
|
131
|
+
removeProps: zod_1.z.array(zod_1.z.string().nonempty()),
|
|
132
|
+
})
|
|
133
|
+
.describe('Request to push a device state update');
|
|
134
|
+
exports.sPushStateUpdateRs = (0, exports.sResponsePayload)(zod_1.z.literal('state-rs'), zod_1.z.object({})).describe('Response for pushing a device state update');
|
|
135
|
+
// PUSH DEVICE EVENT
|
|
136
|
+
exports.sPushEventRq = zod_1.z
|
|
137
|
+
.object({
|
|
138
|
+
kind: zod_1.z.literal('event'),
|
|
139
|
+
foreignRef: zod_1.z.string().nonempty(),
|
|
140
|
+
provider: zod_1.z.string().nonempty(),
|
|
141
|
+
eventTimestamp: zod_1.z
|
|
142
|
+
.number()
|
|
143
|
+
.describe('Event timestamp in milliseconds since epoch, as reported by origin'),
|
|
144
|
+
eventForeignRef: zod_1.z.string().nonempty(),
|
|
145
|
+
event: zod_1.z.unknown().describe('Event data'),
|
|
146
|
+
})
|
|
147
|
+
.describe('Request to push a device event');
|
|
148
|
+
exports.sPushEventRs = (0, exports.sResponsePayload)(zod_1.z.literal('event-rs'), zod_1.z.object({})).describe('Response for pushing a device event');
|
|
149
|
+
// REQUEST AVAILABLE DEVICES (DISCOVERY)
|
|
150
|
+
exports.sGetAvailableDevicesRq = zod_1.z
|
|
151
|
+
.object({
|
|
152
|
+
kind: zod_1.z.literal('get-available-devices'),
|
|
153
|
+
provider: zod_1.z.string().nonempty(),
|
|
154
|
+
})
|
|
155
|
+
.describe('Request to get available devices from a provider via an agent');
|
|
156
|
+
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');
|
|
157
|
+
// REGISTER ACCESS CONTROL AGENT
|
|
158
|
+
exports.sAccessObjectKind = zod_1.z.enum([
|
|
159
|
+
'access-rule',
|
|
160
|
+
'schedule',
|
|
161
|
+
'zone',
|
|
162
|
+
'person',
|
|
163
|
+
'reader',
|
|
164
|
+
]);
|
|
165
|
+
exports.sTokenSpecs = zod_1.z.object({
|
|
166
|
+
type: zod_1.z.enum(['card', 'pin', 'finger-print', 'face']), // etc, those map to a AWARE-standardized set of token types
|
|
167
|
+
regex: zod_1.z.string().optional(),
|
|
168
|
+
formatDescription: zod_1.z.string().optional(),
|
|
169
|
+
maxPerPerson: zod_1.z.number().optional(),
|
|
170
|
+
});
|
|
171
|
+
exports.sCapabilityReport = zod_1.z.object({
|
|
172
|
+
tokens: zod_1.z.array(exports.sTokenSpecs),
|
|
173
|
+
accessbjects: zod_1.z.array(exports.sAccessObjectKind),
|
|
174
|
+
});
|
|
175
|
+
exports.sRegisterAccessControlAgentRq = zod_1.z
|
|
176
|
+
.object({
|
|
177
|
+
kind: zod_1.z.literal('register-access-control-agent'),
|
|
178
|
+
provider: zod_1.z.string().nonempty(),
|
|
179
|
+
})
|
|
180
|
+
.and(exports.sCapabilityReport);
|
|
181
|
+
exports.sRegisterAccessControlAgentRs = (0, exports.sResponsePayload)(zod_1.z.literal('register-access-control-agent-rs'), zod_1.z.object({})).describe('Response for registering an access control agent');
|
|
182
|
+
// ACCESS SYNC SECTION
|
|
183
|
+
exports.sObjectMerge = zod_1.z
|
|
184
|
+
.object({
|
|
185
|
+
kind: zod_1.z.literal('merge'),
|
|
186
|
+
objectId: zod_1.z
|
|
187
|
+
.string()
|
|
188
|
+
.optional()
|
|
189
|
+
.describe('Object ID as in backend. Can be undefined if object is new to backend and agent is trying to create it'),
|
|
190
|
+
objectForeignRefs: zod_1.z
|
|
191
|
+
.array(zod_1.z.string())
|
|
192
|
+
.describe("Object foreign references as in target provider's repos. Can be undefined if object is new to agent and backend is trying to create it. It can be an array in case one access rule maps to many foreign refs"),
|
|
193
|
+
objectKind: exports.sAccessObjectKind,
|
|
194
|
+
props: zod_1.z.record(zod_1.z.unknown()),
|
|
195
|
+
})
|
|
196
|
+
.describe('Object merge request');
|
|
197
|
+
exports.sObjectDelete = zod_1.z
|
|
198
|
+
.object({
|
|
199
|
+
kind: zod_1.z.literal('delete'),
|
|
200
|
+
objectId: zod_1.z
|
|
201
|
+
.string()
|
|
202
|
+
.optional()
|
|
203
|
+
.describe('Object ID as in backend. Can be undefined if object is new to backend and agent is trying to create it'),
|
|
204
|
+
objectForeignRefs: zod_1.z
|
|
205
|
+
.array(zod_1.z.string())
|
|
206
|
+
.describe("Object foreign reference as in target provider's repos. Can be undefined if object is new to agent and backend is trying to create it"),
|
|
207
|
+
objectKind: exports.sAccessObjectKind,
|
|
208
|
+
})
|
|
209
|
+
.describe('Object delete request');
|
|
210
|
+
exports.sRelationMerge = zod_1.z.object({
|
|
211
|
+
kind: zod_1.z.literal('relation-merge'),
|
|
212
|
+
left: zod_1.z.object({
|
|
213
|
+
kind: exports.sAccessObjectKind,
|
|
214
|
+
objectId: zod_1.z
|
|
215
|
+
.string()
|
|
216
|
+
.optional()
|
|
217
|
+
.describe('Object ID as in backend. Can be undefined if object is new to backend and agent is trying to create it'),
|
|
218
|
+
objectForeignRefs: zod_1.z
|
|
219
|
+
.array(zod_1.z.string())
|
|
220
|
+
.describe("Object foreign reference as in target provider's repos. Can be undefined if object is new to agent and backend is trying to create it"),
|
|
221
|
+
}),
|
|
222
|
+
right: zod_1.z.object({
|
|
223
|
+
kind: exports.sAccessObjectKind,
|
|
224
|
+
objectId: zod_1.z
|
|
225
|
+
.string()
|
|
226
|
+
.optional()
|
|
227
|
+
.describe('Object ID as in backend. Can be undefined if object is new to backend and agent is trying to create it'),
|
|
228
|
+
objectForeignRefs: zod_1.z
|
|
229
|
+
.array(zod_1.z.string())
|
|
230
|
+
.describe("Object foreign reference as in target provider's repos. Can be undefined if object is new to agent and backend is trying to create it"),
|
|
231
|
+
}),
|
|
232
|
+
linkExists: zod_1.z.boolean(),
|
|
233
|
+
});
|
|
234
|
+
exports.sAccessMutation = zod_1.z
|
|
235
|
+
.union([exports.sObjectMerge, exports.sObjectDelete, exports.sRelationMerge])
|
|
236
|
+
.describe('Access object change description');
|
|
237
|
+
exports.sDeviceMap = zod_1.z
|
|
238
|
+
.record(zod_1.z.record(zod_1.z.unknown()))
|
|
239
|
+
.describe('Map of devices (readers) and their stashed provider metadata');
|
|
240
|
+
// A. VALIDATE ACCESS CHANGES
|
|
241
|
+
exports.sValidateChangeRq = zod_1.z
|
|
242
|
+
.object({
|
|
243
|
+
kind: zod_1.z.literal('validate-change'),
|
|
244
|
+
provider: zod_1.z.string().nonempty(),
|
|
245
|
+
devices: exports.sDeviceMap,
|
|
246
|
+
mutations: zod_1.z.array(exports.sAccessMutation),
|
|
247
|
+
})
|
|
248
|
+
.describe('Request to validate access changes');
|
|
249
|
+
exports.sChangeIssue = zod_1.z
|
|
250
|
+
.object({
|
|
251
|
+
objectId: zod_1.z.string().optional(),
|
|
252
|
+
objectForeignRef: zod_1.z.string().optional(),
|
|
253
|
+
issue: zod_1.z.string().nonempty(),
|
|
254
|
+
})
|
|
255
|
+
.describe('Access change issue description');
|
|
256
|
+
exports.sValidateChangeRs = (0, exports.sResponsePayload)(zod_1.z.literal('validate-change-rs'), zod_1.z.object({
|
|
257
|
+
issues: zod_1.z.array(exports.sChangeIssue),
|
|
258
|
+
})).describe('Response for validating access changes');
|
|
259
|
+
// B. APPLY ACCESS CHANGES
|
|
260
|
+
exports.sApplyChange = zod_1.z
|
|
261
|
+
.object({
|
|
262
|
+
kind: zod_1.z.literal('apply-change'),
|
|
263
|
+
provider: zod_1.z.string().nonempty(),
|
|
264
|
+
devices: exports.sDeviceMap,
|
|
265
|
+
mutations: zod_1.z.array(exports.sAccessMutation),
|
|
266
|
+
policyVersion: zod_1.z.number().describe('Version of the access changes'),
|
|
267
|
+
})
|
|
268
|
+
.describe('Request to apply access changes');
|
|
269
|
+
exports.sApplyChangeComplete = (0, exports.sResponsePayload)(zod_1.z.literal('apply-change-complete'), zod_1.z.object({
|
|
270
|
+
policyVersion: zod_1.z.number().describe('Version of the access changes'),
|
|
271
|
+
error: zod_1.z.string().optional().describe('Error message if request failed'),
|
|
272
|
+
refs: zod_1.z
|
|
273
|
+
.record(zod_1.z.record(zod_1.z.string().nonempty()))
|
|
274
|
+
.describe('Map of foreign references to object IDs'),
|
|
275
|
+
})).describe('Response for applying access changes');
|
|
276
|
+
exports.sApplyChangeProgress = zod_1.z
|
|
277
|
+
.object({
|
|
278
|
+
kind: zod_1.z.literal('apply-change-progress'),
|
|
279
|
+
policyVersion: zod_1.z.number().describe('Version of desired access snapshot'),
|
|
280
|
+
total: zod_1.z.number().describe('Progress of the access changes'),
|
|
281
|
+
completed: zod_1.z.number().describe('Progress of the access changes'),
|
|
282
|
+
})
|
|
283
|
+
.describe('Progress of the access changes');
|
|
284
|
+
// C. ABORT CHANGES
|
|
285
|
+
exports.abortChange = zod_1.z
|
|
286
|
+
.object({
|
|
287
|
+
kind: zod_1.z.literal('abort-change'),
|
|
288
|
+
provider: zod_1.z.string().nonempty(),
|
|
289
|
+
policyVersion: zod_1.z.number().describe('Version of the access changes'),
|
|
290
|
+
})
|
|
291
|
+
.describe('Request to abort access changes');
|
|
292
|
+
const fromAgentSchemaByKind = {
|
|
293
|
+
register: exports.sRegisterRq,
|
|
294
|
+
unregister: exports.sUnregister,
|
|
295
|
+
'validate-config-rs': exports.sValidateProviderConfigRs,
|
|
296
|
+
'start-rs': exports.sStartServiceRs,
|
|
297
|
+
'stop-rs': exports.sStopServiceRs,
|
|
298
|
+
'command-rs': exports.sRunCommandRs,
|
|
299
|
+
state: exports.sPushStateUpdateRq,
|
|
300
|
+
event: exports.sPushEventRq,
|
|
301
|
+
'get-available-devices-rs': exports.sGetAvailableDevicesRs,
|
|
302
|
+
'register-access-control-agent': exports.sRegisterAccessControlAgentRq,
|
|
303
|
+
'validate-change-rs': exports.sValidateChangeRs,
|
|
304
|
+
'apply-change-complete': exports.sApplyChangeComplete,
|
|
305
|
+
'apply-change-progress': exports.sApplyChangeProgress,
|
|
306
|
+
'error-rs': exports.sErrorPayload,
|
|
307
|
+
};
|
|
308
|
+
const getAgentMessageIssues = (message) => {
|
|
309
|
+
const result = exports.sMessageHeader.safeParse(message);
|
|
310
|
+
if (!result.success) {
|
|
311
|
+
return result.error.errors.map((e) => `${e.path.map((p) => p.toString()).join('.')} - ${e.message}`);
|
|
312
|
+
}
|
|
313
|
+
const { kind } = message;
|
|
314
|
+
const schema = fromAgentSchemaByKind[kind];
|
|
315
|
+
if (!schema) {
|
|
316
|
+
return [`Unknown message kind: ${kind}`];
|
|
317
|
+
}
|
|
318
|
+
const result2 = schema.safeParse(message);
|
|
319
|
+
if (!result2.success) {
|
|
320
|
+
return result2.error.errors.map((e) => e.message);
|
|
321
|
+
}
|
|
322
|
+
return [];
|
|
323
|
+
};
|
|
324
|
+
exports.getAgentMessageIssues = getAgentMessageIssues;
|
|
325
|
+
const isMessageFromAgent = (message) => {
|
|
326
|
+
if (typeof message !== 'object' || message === null) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
const headerResult = exports.sMessageHeader.safeParse(message);
|
|
330
|
+
if (!headerResult.success) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
const { kind } = message;
|
|
334
|
+
const schema = fromAgentSchemaByKind[kind];
|
|
335
|
+
if (!schema) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
const result = schema.safeParse(message);
|
|
339
|
+
return result.success;
|
|
340
|
+
};
|
|
341
|
+
exports.isMessageFromAgent = isMessageFromAgent;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DeviceEvent } from '../device-event';
|
|
2
|
+
export interface AlarmSearchQueryDto {
|
|
3
|
+
deviceId?: string[];
|
|
4
|
+
kind?: string[];
|
|
5
|
+
userId?: string[];
|
|
6
|
+
personId?: string[];
|
|
7
|
+
timeFrom?: number;
|
|
8
|
+
timeTo?: number;
|
|
9
|
+
offset?: number;
|
|
10
|
+
limit?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface AlarmSearchItemDto {
|
|
13
|
+
id: string;
|
|
14
|
+
triggeredOn: number;
|
|
15
|
+
acknowledgedOn: number | null;
|
|
16
|
+
acknowledgedBy: string | null;
|
|
17
|
+
triggers: {
|
|
18
|
+
id: string;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
deviceId: string;
|
|
21
|
+
kind: DeviceEvent['kind'];
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const sLoginByCredentialsRequest: z.ZodObject<{
|
|
3
|
+
username: z.ZodString;
|
|
4
|
+
password: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
username: string;
|
|
7
|
+
password: string;
|
|
8
|
+
}, {
|
|
9
|
+
username: string;
|
|
10
|
+
password: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const sLoginByRefreshTokenRequest: z.ZodObject<{
|
|
13
|
+
refreshToken: z.ZodString;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
refreshToken: string;
|
|
16
|
+
}, {
|
|
17
|
+
refreshToken: string;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const sLoginResponse: z.ZodObject<{
|
|
20
|
+
accessToken: z.ZodString;
|
|
21
|
+
refreshToken: z.ZodString;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
refreshToken: string;
|
|
24
|
+
accessToken: string;
|
|
25
|
+
}, {
|
|
26
|
+
refreshToken: string;
|
|
27
|
+
accessToken: string;
|
|
28
|
+
}>;
|
|
29
|
+
export type LoginByCredentialsRequest = z.infer<typeof sLoginByCredentialsRequest>;
|
|
30
|
+
export type LoginByRefreshTokenRequest = z.infer<typeof sLoginByRefreshTokenRequest>;
|
|
31
|
+
export type LoginResponse = z.infer<typeof sLoginResponse>;
|
package/dist/api/auth.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sLoginResponse = exports.sLoginByRefreshTokenRequest = exports.sLoginByCredentialsRequest = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.sLoginByCredentialsRequest = zod_1.z.object({
|
|
6
|
+
username: zod_1.z.string().nonempty('Username must not be empty'),
|
|
7
|
+
password: zod_1.z.string().nonempty('Password must not be empty'),
|
|
8
|
+
});
|
|
9
|
+
exports.sLoginByRefreshTokenRequest = zod_1.z.object({
|
|
10
|
+
refreshToken: zod_1.z.string().nonempty('Refresh token must not be empty'),
|
|
11
|
+
});
|
|
12
|
+
exports.sLoginResponse = zod_1.z.object({
|
|
13
|
+
accessToken: zod_1.z
|
|
14
|
+
.string()
|
|
15
|
+
.describe('Access token to be used for authentication with short expiry time. Apply this token in the Authorization header as a Bearer token.'),
|
|
16
|
+
refreshToken: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.describe('Refresh token to be used to obtain a new access token when the current one expires.'),
|
|
19
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./alarm"), exports);
|
|
18
|
+
__exportStar(require("./auth"), exports);
|
|
19
|
+
__exportStar(require("./query"), exports);
|
|
20
|
+
__exportStar(require("./media"), exports);
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const sRecordingSequence: z.ZodObject<{
|
|
3
|
+
start: z.ZodNumber;
|
|
4
|
+
end: z.ZodNumber;
|
|
5
|
+
motion: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
objects: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
end: number;
|
|
9
|
+
start: number;
|
|
10
|
+
motion?: number | undefined;
|
|
11
|
+
objects?: number | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
end: number;
|
|
14
|
+
start: number;
|
|
15
|
+
motion?: number | undefined;
|
|
16
|
+
objects?: number | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const sGetRecordingsRequest: z.ZodObject<{
|
|
19
|
+
deviceId: z.ZodString;
|
|
20
|
+
timeFrom: z.ZodNumber;
|
|
21
|
+
timeTo: z.ZodNumber;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
deviceId: string;
|
|
24
|
+
timeFrom: number;
|
|
25
|
+
timeTo: number;
|
|
26
|
+
}, {
|
|
27
|
+
deviceId: string;
|
|
28
|
+
timeFrom: number;
|
|
29
|
+
timeTo: number;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const sGetRecordingsResponse: z.ZodObject<{
|
|
32
|
+
items: z.ZodArray<z.ZodObject<{
|
|
33
|
+
start: z.ZodNumber;
|
|
34
|
+
end: z.ZodNumber;
|
|
35
|
+
motion: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
objects: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
end: number;
|
|
39
|
+
start: number;
|
|
40
|
+
motion?: number | undefined;
|
|
41
|
+
objects?: number | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
end: number;
|
|
44
|
+
start: number;
|
|
45
|
+
motion?: number | undefined;
|
|
46
|
+
objects?: number | undefined;
|
|
47
|
+
}>, "many">;
|
|
48
|
+
total: z.ZodNumber;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
total: number;
|
|
51
|
+
items: {
|
|
52
|
+
end: number;
|
|
53
|
+
start: number;
|
|
54
|
+
motion?: number | undefined;
|
|
55
|
+
objects?: number | undefined;
|
|
56
|
+
}[];
|
|
57
|
+
}, {
|
|
58
|
+
total: number;
|
|
59
|
+
items: {
|
|
60
|
+
end: number;
|
|
61
|
+
start: number;
|
|
62
|
+
motion?: number | undefined;
|
|
63
|
+
objects?: number | undefined;
|
|
64
|
+
}[];
|
|
65
|
+
}>;
|
|
66
|
+
export declare const sGetPreviewImageRequest: z.ZodObject<{
|
|
67
|
+
deviceId: z.ZodString;
|
|
68
|
+
time: z.ZodNumber;
|
|
69
|
+
height: z.ZodNumber;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
time: number;
|
|
72
|
+
height: number;
|
|
73
|
+
deviceId: string;
|
|
74
|
+
}, {
|
|
75
|
+
time: number;
|
|
76
|
+
height: number;
|
|
77
|
+
deviceId: string;
|
|
78
|
+
}>;
|
|
79
|
+
export declare const sGetScenePreviewClipRequest: z.ZodObject<{
|
|
80
|
+
deviceId: z.ZodString;
|
|
81
|
+
providerAssignedRef: z.ZodString;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
providerAssignedRef: string;
|
|
84
|
+
deviceId: string;
|
|
85
|
+
}, {
|
|
86
|
+
providerAssignedRef: string;
|
|
87
|
+
deviceId: string;
|
|
88
|
+
}>;
|
|
89
|
+
export declare const sGetObjectSnapshotRequest: z.ZodObject<{
|
|
90
|
+
deviceId: z.ZodString;
|
|
91
|
+
providerAssignedRef: z.ZodString;
|
|
92
|
+
crop: z.ZodBoolean;
|
|
93
|
+
boxes: z.ZodBoolean;
|
|
94
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
quality: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
providerAssignedRef: string;
|
|
98
|
+
deviceId: string;
|
|
99
|
+
crop: boolean;
|
|
100
|
+
boxes: boolean;
|
|
101
|
+
height?: number | undefined;
|
|
102
|
+
quality?: number | undefined;
|
|
103
|
+
}, {
|
|
104
|
+
providerAssignedRef: string;
|
|
105
|
+
deviceId: string;
|
|
106
|
+
crop: boolean;
|
|
107
|
+
boxes: boolean;
|
|
108
|
+
height?: number | undefined;
|
|
109
|
+
quality?: number | undefined;
|
|
110
|
+
}>;
|
|
111
|
+
export declare const sGetObjectThumbnailRequest: z.ZodObject<{
|
|
112
|
+
deviceId: z.ZodString;
|
|
113
|
+
providerAssignedRef: z.ZodString;
|
|
114
|
+
}, "strip", z.ZodTypeAny, {
|
|
115
|
+
providerAssignedRef: string;
|
|
116
|
+
deviceId: string;
|
|
117
|
+
}, {
|
|
118
|
+
providerAssignedRef: string;
|
|
119
|
+
deviceId: string;
|
|
120
|
+
}>;
|
|
121
|
+
export declare const sGetExportLinkResponse: z.ZodObject<{
|
|
122
|
+
relativeUrl: z.ZodString;
|
|
123
|
+
}, "strip", z.ZodTypeAny, {
|
|
124
|
+
relativeUrl: string;
|
|
125
|
+
}, {
|
|
126
|
+
relativeUrl: string;
|
|
127
|
+
}>;
|
|
128
|
+
export declare const sMediaSearchQueryDto: z.ZodObject<{
|
|
129
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
q: z.ZodOptional<z.ZodString>;
|
|
131
|
+
deviceId: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
132
|
+
similarTo: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
133
|
+
label: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
134
|
+
timeFrom: z.ZodOptional<z.ZodNumber>;
|
|
135
|
+
timeTo: z.ZodOptional<z.ZodNumber>;
|
|
136
|
+
sortBy: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"time_asc">, z.ZodLiteral<"time_desc">]>>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
label?: string[] | undefined;
|
|
139
|
+
q?: string | undefined;
|
|
140
|
+
deviceId?: string[] | undefined;
|
|
141
|
+
limit?: number | undefined;
|
|
142
|
+
timeFrom?: number | undefined;
|
|
143
|
+
timeTo?: number | undefined;
|
|
144
|
+
similarTo?: string | undefined;
|
|
145
|
+
sortBy?: "time_asc" | "time_desc" | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
label?: string[] | undefined;
|
|
148
|
+
q?: string | undefined;
|
|
149
|
+
deviceId?: string[] | undefined;
|
|
150
|
+
limit?: number | undefined;
|
|
151
|
+
timeFrom?: number | undefined;
|
|
152
|
+
timeTo?: number | undefined;
|
|
153
|
+
similarTo?: string | undefined;
|
|
154
|
+
sortBy?: "time_asc" | "time_desc" | undefined;
|
|
155
|
+
}>;
|
|
156
|
+
export declare const sGetLatestFrameRequest: z.ZodObject<{
|
|
157
|
+
deviceId: z.ZodString;
|
|
158
|
+
width: z.ZodNumber;
|
|
159
|
+
height: z.ZodNumber;
|
|
160
|
+
}, "strip", z.ZodTypeAny, {
|
|
161
|
+
height: number;
|
|
162
|
+
width: number;
|
|
163
|
+
deviceId: string;
|
|
164
|
+
}, {
|
|
165
|
+
height: number;
|
|
166
|
+
width: number;
|
|
167
|
+
deviceId: string;
|
|
168
|
+
}>;
|
|
169
|
+
export type RecordingSequence = z.infer<typeof sRecordingSequence>;
|
|
170
|
+
export type GetRecordingsRequest = z.infer<typeof sGetRecordingsRequest>;
|
|
171
|
+
export type GetRecordingsResponse = z.infer<typeof sGetRecordingsResponse>;
|
|
172
|
+
export type GetPreviewImageRequest = z.infer<typeof sGetPreviewImageRequest>;
|
|
173
|
+
export type GetScenePreviewClipRequest = z.infer<typeof sGetScenePreviewClipRequest>;
|
|
174
|
+
export type GetObjectSnapshotRequest = z.infer<typeof sGetObjectSnapshotRequest>;
|
|
175
|
+
export type GetObjectThumbnailRequest = z.infer<typeof sGetObjectThumbnailRequest>;
|
|
176
|
+
export type GetExportLinkResponse = z.infer<typeof sGetExportLinkResponse>;
|
|
177
|
+
export type MediaSearchQueryDto = z.infer<typeof sMediaSearchQueryDto>;
|
|
178
|
+
export type GetLatestFrameRequest = z.infer<typeof sGetLatestFrameRequest>;
|
|
179
|
+
export type MediaSearchMatchDto = {
|
|
180
|
+
relevance: number;
|
|
181
|
+
providerAssignedRef: string;
|
|
182
|
+
deviceId: string;
|
|
183
|
+
probability: number;
|
|
184
|
+
objectKind: string;
|
|
185
|
+
startTime: number;
|
|
186
|
+
endTime: number | null;
|
|
187
|
+
};
|