camstreamerlib 4.0.0-beta.32 → 4.0.0-beta.33

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.
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  declare const cameraGuidsResponseSchema: z.ZodObject<{
3
3
  Rsp: z.ZodObject<{
4
- Status: z.ZodString;
4
+ Status: z.ZodLiteral<"Ok">;
5
5
  Result: z.ZodArray<z.ZodObject<{
6
6
  Guid: z.ZodString;
7
7
  }, "strip", z.ZodTypeAny, {
@@ -10,51 +10,33 @@ declare const cameraGuidsResponseSchema: z.ZodObject<{
10
10
  Guid: string;
11
11
  }>, "many">;
12
12
  }, "strip", z.ZodTypeAny, {
13
- Status: string;
13
+ Status: "Ok";
14
14
  Result: {
15
15
  Guid: string;
16
16
  }[];
17
17
  }, {
18
- Status: string;
18
+ Status: "Ok";
19
19
  Result: {
20
20
  Guid: string;
21
21
  }[];
22
22
  }>;
23
23
  }, "strip", z.ZodTypeAny, {
24
24
  Rsp: {
25
- Status: string;
25
+ Status: "Ok";
26
26
  Result: {
27
27
  Guid: string;
28
28
  }[];
29
29
  };
30
30
  }, {
31
31
  Rsp: {
32
- Status: string;
32
+ Status: "Ok";
33
33
  Result: {
34
34
  Guid: string;
35
35
  }[];
36
36
  };
37
37
  }>;
38
38
  export type TCameraGuidsResponse = z.infer<typeof cameraGuidsResponseSchema>;
39
- declare const connectionResponseSchema: z.ZodObject<{
40
- Rsp: z.ZodObject<{
41
- Status: z.ZodString;
42
- }, "strip", z.ZodTypeAny, {
43
- Status: string;
44
- }, {
45
- Status: string;
46
- }>;
47
- }, "strip", z.ZodTypeAny, {
48
- Rsp: {
49
- Status: string;
50
- };
51
- }, {
52
- Rsp: {
53
- Status: string;
54
- };
55
- }>;
56
- export type TConnectionResponse = z.infer<typeof connectionResponseSchema>;
57
- export declare const cameraDetailSchema: z.ZodObject<{
39
+ declare const cameraDetailSchema: z.ZodObject<{
58
40
  Guid: z.ZodOptional<z.ZodString>;
59
41
  Name: z.ZodOptional<z.ZodString>;
60
42
  EntityType: z.ZodOptional<z.ZodString>;
@@ -67,9 +49,9 @@ export declare const cameraDetailSchema: z.ZodObject<{
67
49
  Guid?: string | undefined;
68
50
  EntityType?: string | undefined;
69
51
  }>;
70
- export declare const cameraDetailsResponseSchema: z.ZodObject<{
52
+ declare const cameraDetailsResponseSchema: z.ZodObject<{
71
53
  Rsp: z.ZodObject<{
72
- Status: z.ZodString;
54
+ Status: z.ZodLiteral<"Ok">;
73
55
  Result: z.ZodUnion<[z.ZodArray<z.ZodObject<{
74
56
  Guid: z.ZodOptional<z.ZodString>;
75
57
  Name: z.ZodOptional<z.ZodString>;
@@ -96,7 +78,7 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
96
78
  EntityType?: string | undefined;
97
79
  }>]>;
98
80
  }, "strip", z.ZodTypeAny, {
99
- Status: string;
81
+ Status: "Ok";
100
82
  Result: {
101
83
  Name?: string | undefined;
102
84
  Guid?: string | undefined;
@@ -107,7 +89,7 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
107
89
  EntityType?: string | undefined;
108
90
  }[];
109
91
  }, {
110
- Status: string;
92
+ Status: "Ok";
111
93
  Result: {
112
94
  Name?: string | undefined;
113
95
  Guid?: string | undefined;
@@ -120,7 +102,7 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
120
102
  }>;
121
103
  }, "strip", z.ZodTypeAny, {
122
104
  Rsp: {
123
- Status: string;
105
+ Status: "Ok";
124
106
  Result: {
125
107
  Name?: string | undefined;
126
108
  Guid?: string | undefined;
@@ -133,7 +115,7 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
133
115
  };
134
116
  }, {
135
117
  Rsp: {
136
- Status: string;
118
+ Status: "Ok";
137
119
  Result: {
138
120
  Name?: string | undefined;
139
121
  Guid?: string | undefined;
@@ -164,12 +146,12 @@ export declare class GenetecAgent {
164
146
  private baseUrl;
165
147
  private credentials;
166
148
  constructor(options?: GenetecAgentOptions);
167
- checkConnection(): Promise<TConnectionResponse>;
149
+ checkConnection(): Promise<void>;
168
150
  getAllCameraGuids(): Promise<TCameraGuidsResponse>;
169
151
  getCameraDetails(guids: {
170
152
  Guid: string;
171
153
  }[], parameters: TParams): Promise<TCameraDetail[]>;
172
- sendBookmark(guids: string[], bookmarkText: string): Promise<Response>;
154
+ sendBookmark(guids: string[], bookmarkText: string): Promise<void>;
173
155
  private getRequestOptions;
174
156
  private getTimeStamp;
175
157
  private fetchWithTimeout;
@@ -1,31 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenetecAgent = exports.cameraDetailsResponseSchema = exports.cameraDetailSchema = void 0;
3
+ exports.GenetecAgent = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const utils_1 = require("../internal/utils");
6
- const ACTION = 'AddCameraBookmark';
7
- const GET_CAMERAS_URL = 'report/EntityConfiguration?q=EntityTypes@Camera';
8
- const GET_CAMERAS_DETAILS_URL = '/entity?q=';
9
- const cameraGuidsResponseSchema = zod_1.z.object({
6
+ const successResponseSchema = zod_1.z.object({
10
7
  Rsp: zod_1.z.object({
11
- Status: zod_1.z.string(),
12
- Result: zod_1.z.array(zod_1.z.object({ Guid: zod_1.z.string() })),
8
+ Status: zod_1.z.literal('Ok'),
13
9
  }),
14
10
  });
15
- const connectionResponseSchema = zod_1.z.object({
11
+ const cameraGuidsResponseSchema = zod_1.z.object({
16
12
  Rsp: zod_1.z.object({
17
- Status: zod_1.z.string(),
13
+ Status: zod_1.z.literal('Ok'),
14
+ Result: zod_1.z.array(zod_1.z.object({ Guid: zod_1.z.string() })),
18
15
  }),
19
16
  });
20
- exports.cameraDetailSchema = zod_1.z.object({
17
+ const cameraDetailSchema = zod_1.z.object({
21
18
  Guid: zod_1.z.string().optional(),
22
19
  Name: zod_1.z.string().optional(),
23
20
  EntityType: zod_1.z.string().optional(),
24
21
  });
25
- exports.cameraDetailsResponseSchema = zod_1.z.object({
22
+ const cameraDetailsResponseSchema = zod_1.z.object({
26
23
  Rsp: zod_1.z.object({
27
- Status: zod_1.z.string(),
28
- Result: zod_1.z.union([zod_1.z.array(exports.cameraDetailSchema), exports.cameraDetailSchema]),
24
+ Status: zod_1.z.literal('Ok'),
25
+ Result: zod_1.z.union([zod_1.z.array(cameraDetailSchema), cameraDetailSchema]),
29
26
  }),
30
27
  });
31
28
  class GenetecAgent {
@@ -48,56 +45,70 @@ class GenetecAgent {
48
45
  }
49
46
  async checkConnection() {
50
47
  const requestOptions = this.getRequestOptions('GET');
51
- const res = await this.fetchWithTimeout(`${this.baseUrl}/`, requestOptions);
48
+ const res = await this.fetchWithTimeout(new URL(this.baseUrl), requestOptions);
52
49
  if (!res.ok) {
53
50
  throw new Error(await (0, utils_1.responseStringify)(res));
54
51
  }
55
- return connectionResponseSchema.parse(await res.json());
52
+ const responseBody = await res.text();
53
+ const result = await successResponseSchema.safeParseAsync(JSON.parse(responseBody));
54
+ if (!result.success) {
55
+ throw new Error('Genetec connection test failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
56
+ }
56
57
  }
57
58
  async getAllCameraGuids() {
58
59
  const requestOptions = this.getRequestOptions('GET');
59
- const res = await this.fetchWithTimeout(`${this.baseUrl}/${GET_CAMERAS_URL}`, requestOptions);
60
+ const url = new URL(`${this.baseUrl}/report/EntityConfiguration`);
61
+ url.searchParams.set('q', 'EntityTypes@Camera');
62
+ const res = await this.fetchWithTimeout(url, requestOptions);
60
63
  if (!res.ok) {
61
64
  throw new Error(await (0, utils_1.responseStringify)(res));
62
65
  }
63
- return cameraGuidsResponseSchema.parse(await res.json());
66
+ const responseBody = await res.text();
67
+ const result = await cameraGuidsResponseSchema.safeParseAsync(JSON.parse(responseBody));
68
+ if (!result.success) {
69
+ throw new Error('Genetec get camera guids failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
70
+ }
71
+ return result.data;
64
72
  }
65
73
  async getCameraDetails(guids, parameters) {
66
74
  const params = parameters.join(',');
67
- let camerasGuids = [];
68
75
  const requestOptions = this.getRequestOptions('GET');
69
76
  const allCameras = [];
70
77
  const chunkSize = 10;
71
78
  while (guids.length > 0) {
72
79
  const chunk = guids.slice(0, chunkSize);
73
80
  guids.splice(0, chunkSize);
74
- camerasGuids = chunk.map((item) => item.Guid);
75
- const camerasDetailsUrl = [];
76
- for (const guid of camerasGuids) {
77
- camerasDetailsUrl.push(`entity=${guid},${params}`);
78
- }
79
- const res = await this.fetchWithTimeout(`${this.baseUrl}/${GET_CAMERAS_DETAILS_URL}${camerasDetailsUrl.join(',')}`, requestOptions);
81
+ const url = new URL(`${this.baseUrl}/entity`);
82
+ url.searchParams.set('q', chunk.map((item) => `entity=${item.Guid},${params}`).join(','));
83
+ const res = await this.fetchWithTimeout(url, requestOptions);
80
84
  if (!res.ok) {
81
85
  throw new Error(await (0, utils_1.responseStringify)(res));
82
86
  }
83
- const data = exports.cameraDetailsResponseSchema.parse(await res.json());
87
+ const responseBody = await res.text();
88
+ const result = await cameraDetailsResponseSchema.safeParseAsync(JSON.parse(responseBody));
89
+ if (!result.success) {
90
+ throw new Error('Genetec get camera details failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
91
+ }
92
+ const data = result.data;
84
93
  const resultArray = Array.isArray(data.Rsp.Result) ? data.Rsp.Result : [data.Rsp.Result];
85
94
  allCameras.push(...resultArray);
86
95
  }
87
96
  return allCameras;
88
97
  }
89
98
  async sendBookmark(guids, bookmarkText) {
90
- const cameraEntitiesUrl = [];
91
99
  const timeStamp = this.getTimeStamp();
92
100
  const requestOptions = this.getRequestOptions('POST');
93
- for (const guid of guids) {
94
- cameraEntitiesUrl.push(`${ACTION}(${guid},${timeStamp},${bookmarkText})`);
95
- }
96
- const res = await this.fetchWithTimeout(`${this.baseUrl}/action?q=${cameraEntitiesUrl.join(',')}`, requestOptions);
101
+ const url = new URL(`${this.baseUrl}/action`);
102
+ url.searchParams.set('q', guids.map((guid) => `AddCameraBookmark(${guid},${timeStamp},${bookmarkText})`).join(','));
103
+ const res = await this.fetchWithTimeout(url, requestOptions);
97
104
  if (!res.ok) {
98
105
  throw new Error(await (0, utils_1.responseStringify)(res));
99
106
  }
100
- return res;
107
+ const responseBody = await res.text();
108
+ const result = await successResponseSchema.safeParseAsync(JSON.parse(responseBody));
109
+ if (!result.success) {
110
+ throw new Error('Genetec send bookmark failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
111
+ }
101
112
  }
102
113
  getRequestOptions(method) {
103
114
  return {
@@ -1,4 +1,5 @@
1
- export { DefaultClient } from './DefaultClient';
2
- export { WsClient } from './WsClient';
3
- export { AxisCameraStationEvents } from '../events/AxisCameraStationEvents';
1
+ export * from './DefaultClient';
2
+ export * from './WsClient';
3
+ export * from './HttpServer';
4
+ export * from '../events/AxisCameraStationEvents';
4
5
  export * from '../events/GenetecAgent';
package/cjs/node/index.js CHANGED
@@ -14,11 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.AxisCameraStationEvents = exports.WsClient = exports.DefaultClient = void 0;
18
- var DefaultClient_1 = require("./DefaultClient");
19
- Object.defineProperty(exports, "DefaultClient", { enumerable: true, get: function () { return DefaultClient_1.DefaultClient; } });
20
- var WsClient_1 = require("./WsClient");
21
- Object.defineProperty(exports, "WsClient", { enumerable: true, get: function () { return WsClient_1.WsClient; } });
22
- var AxisCameraStationEvents_1 = require("../events/AxisCameraStationEvents");
23
- Object.defineProperty(exports, "AxisCameraStationEvents", { enumerable: true, get: function () { return AxisCameraStationEvents_1.AxisCameraStationEvents; } });
17
+ __exportStar(require("./DefaultClient"), exports);
18
+ __exportStar(require("./WsClient"), exports);
19
+ __exportStar(require("./HttpServer"), exports);
20
+ __exportStar(require("../events/AxisCameraStationEvents"), exports);
24
21
  __exportStar(require("../events/GenetecAgent"), exports);
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  declare const cameraGuidsResponseSchema: z.ZodObject<{
3
3
  Rsp: z.ZodObject<{
4
- Status: z.ZodString;
4
+ Status: z.ZodLiteral<"Ok">;
5
5
  Result: z.ZodArray<z.ZodObject<{
6
6
  Guid: z.ZodString;
7
7
  }, "strip", z.ZodTypeAny, {
@@ -10,51 +10,33 @@ declare const cameraGuidsResponseSchema: z.ZodObject<{
10
10
  Guid: string;
11
11
  }>, "many">;
12
12
  }, "strip", z.ZodTypeAny, {
13
- Status: string;
13
+ Status: "Ok";
14
14
  Result: {
15
15
  Guid: string;
16
16
  }[];
17
17
  }, {
18
- Status: string;
18
+ Status: "Ok";
19
19
  Result: {
20
20
  Guid: string;
21
21
  }[];
22
22
  }>;
23
23
  }, "strip", z.ZodTypeAny, {
24
24
  Rsp: {
25
- Status: string;
25
+ Status: "Ok";
26
26
  Result: {
27
27
  Guid: string;
28
28
  }[];
29
29
  };
30
30
  }, {
31
31
  Rsp: {
32
- Status: string;
32
+ Status: "Ok";
33
33
  Result: {
34
34
  Guid: string;
35
35
  }[];
36
36
  };
37
37
  }>;
38
38
  export type TCameraGuidsResponse = z.infer<typeof cameraGuidsResponseSchema>;
39
- declare const connectionResponseSchema: z.ZodObject<{
40
- Rsp: z.ZodObject<{
41
- Status: z.ZodString;
42
- }, "strip", z.ZodTypeAny, {
43
- Status: string;
44
- }, {
45
- Status: string;
46
- }>;
47
- }, "strip", z.ZodTypeAny, {
48
- Rsp: {
49
- Status: string;
50
- };
51
- }, {
52
- Rsp: {
53
- Status: string;
54
- };
55
- }>;
56
- export type TConnectionResponse = z.infer<typeof connectionResponseSchema>;
57
- export declare const cameraDetailSchema: z.ZodObject<{
39
+ declare const cameraDetailSchema: z.ZodObject<{
58
40
  Guid: z.ZodOptional<z.ZodString>;
59
41
  Name: z.ZodOptional<z.ZodString>;
60
42
  EntityType: z.ZodOptional<z.ZodString>;
@@ -67,9 +49,9 @@ export declare const cameraDetailSchema: z.ZodObject<{
67
49
  Guid?: string | undefined;
68
50
  EntityType?: string | undefined;
69
51
  }>;
70
- export declare const cameraDetailsResponseSchema: z.ZodObject<{
52
+ declare const cameraDetailsResponseSchema: z.ZodObject<{
71
53
  Rsp: z.ZodObject<{
72
- Status: z.ZodString;
54
+ Status: z.ZodLiteral<"Ok">;
73
55
  Result: z.ZodUnion<[z.ZodArray<z.ZodObject<{
74
56
  Guid: z.ZodOptional<z.ZodString>;
75
57
  Name: z.ZodOptional<z.ZodString>;
@@ -96,7 +78,7 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
96
78
  EntityType?: string | undefined;
97
79
  }>]>;
98
80
  }, "strip", z.ZodTypeAny, {
99
- Status: string;
81
+ Status: "Ok";
100
82
  Result: {
101
83
  Name?: string | undefined;
102
84
  Guid?: string | undefined;
@@ -107,7 +89,7 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
107
89
  EntityType?: string | undefined;
108
90
  }[];
109
91
  }, {
110
- Status: string;
92
+ Status: "Ok";
111
93
  Result: {
112
94
  Name?: string | undefined;
113
95
  Guid?: string | undefined;
@@ -120,7 +102,7 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
120
102
  }>;
121
103
  }, "strip", z.ZodTypeAny, {
122
104
  Rsp: {
123
- Status: string;
105
+ Status: "Ok";
124
106
  Result: {
125
107
  Name?: string | undefined;
126
108
  Guid?: string | undefined;
@@ -133,7 +115,7 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
133
115
  };
134
116
  }, {
135
117
  Rsp: {
136
- Status: string;
118
+ Status: "Ok";
137
119
  Result: {
138
120
  Name?: string | undefined;
139
121
  Guid?: string | undefined;
@@ -164,12 +146,12 @@ export declare class GenetecAgent {
164
146
  private baseUrl;
165
147
  private credentials;
166
148
  constructor(options?: GenetecAgentOptions);
167
- checkConnection(): Promise<TConnectionResponse>;
149
+ checkConnection(): Promise<void>;
168
150
  getAllCameraGuids(): Promise<TCameraGuidsResponse>;
169
151
  getCameraDetails(guids: {
170
152
  Guid: string;
171
153
  }[], parameters: TParams): Promise<TCameraDetail[]>;
172
- sendBookmark(guids: string[], bookmarkText: string): Promise<Response>;
154
+ sendBookmark(guids: string[], bookmarkText: string): Promise<void>;
173
155
  private getRequestOptions;
174
156
  private getTimeStamp;
175
157
  private fetchWithTimeout;
@@ -1,27 +1,24 @@
1
1
  import { z } from 'zod';
2
2
  import { responseStringify, pad } from '../internal/utils';
3
- const ACTION = 'AddCameraBookmark';
4
- const GET_CAMERAS_URL = 'report/EntityConfiguration?q=EntityTypes@Camera';
5
- const GET_CAMERAS_DETAILS_URL = '/entity?q=';
6
- const cameraGuidsResponseSchema = z.object({
3
+ const successResponseSchema = z.object({
7
4
  Rsp: z.object({
8
- Status: z.string(),
9
- Result: z.array(z.object({ Guid: z.string() })),
5
+ Status: z.literal('Ok'),
10
6
  }),
11
7
  });
12
- const connectionResponseSchema = z.object({
8
+ const cameraGuidsResponseSchema = z.object({
13
9
  Rsp: z.object({
14
- Status: z.string(),
10
+ Status: z.literal('Ok'),
11
+ Result: z.array(z.object({ Guid: z.string() })),
15
12
  }),
16
13
  });
17
- export const cameraDetailSchema = z.object({
14
+ const cameraDetailSchema = z.object({
18
15
  Guid: z.string().optional(),
19
16
  Name: z.string().optional(),
20
17
  EntityType: z.string().optional(),
21
18
  });
22
- export const cameraDetailsResponseSchema = z.object({
19
+ const cameraDetailsResponseSchema = z.object({
23
20
  Rsp: z.object({
24
- Status: z.string(),
21
+ Status: z.literal('Ok'),
25
22
  Result: z.union([z.array(cameraDetailSchema), cameraDetailSchema]),
26
23
  }),
27
24
  });
@@ -45,56 +42,70 @@ export class GenetecAgent {
45
42
  }
46
43
  async checkConnection() {
47
44
  const requestOptions = this.getRequestOptions('GET');
48
- const res = await this.fetchWithTimeout(`${this.baseUrl}/`, requestOptions);
45
+ const res = await this.fetchWithTimeout(new URL(this.baseUrl), requestOptions);
49
46
  if (!res.ok) {
50
47
  throw new Error(await responseStringify(res));
51
48
  }
52
- return connectionResponseSchema.parse(await res.json());
49
+ const responseBody = await res.text();
50
+ const result = await successResponseSchema.safeParseAsync(JSON.parse(responseBody));
51
+ if (!result.success) {
52
+ throw new Error('Genetec connection test failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
53
+ }
53
54
  }
54
55
  async getAllCameraGuids() {
55
56
  const requestOptions = this.getRequestOptions('GET');
56
- const res = await this.fetchWithTimeout(`${this.baseUrl}/${GET_CAMERAS_URL}`, requestOptions);
57
+ const url = new URL(`${this.baseUrl}/report/EntityConfiguration`);
58
+ url.searchParams.set('q', 'EntityTypes@Camera');
59
+ const res = await this.fetchWithTimeout(url, requestOptions);
57
60
  if (!res.ok) {
58
61
  throw new Error(await responseStringify(res));
59
62
  }
60
- return cameraGuidsResponseSchema.parse(await res.json());
63
+ const responseBody = await res.text();
64
+ const result = await cameraGuidsResponseSchema.safeParseAsync(JSON.parse(responseBody));
65
+ if (!result.success) {
66
+ throw new Error('Genetec get camera guids failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
67
+ }
68
+ return result.data;
61
69
  }
62
70
  async getCameraDetails(guids, parameters) {
63
71
  const params = parameters.join(',');
64
- let camerasGuids = [];
65
72
  const requestOptions = this.getRequestOptions('GET');
66
73
  const allCameras = [];
67
74
  const chunkSize = 10;
68
75
  while (guids.length > 0) {
69
76
  const chunk = guids.slice(0, chunkSize);
70
77
  guids.splice(0, chunkSize);
71
- camerasGuids = chunk.map((item) => item.Guid);
72
- const camerasDetailsUrl = [];
73
- for (const guid of camerasGuids) {
74
- camerasDetailsUrl.push(`entity=${guid},${params}`);
75
- }
76
- const res = await this.fetchWithTimeout(`${this.baseUrl}/${GET_CAMERAS_DETAILS_URL}${camerasDetailsUrl.join(',')}`, requestOptions);
78
+ const url = new URL(`${this.baseUrl}/entity`);
79
+ url.searchParams.set('q', chunk.map((item) => `entity=${item.Guid},${params}`).join(','));
80
+ const res = await this.fetchWithTimeout(url, requestOptions);
77
81
  if (!res.ok) {
78
82
  throw new Error(await responseStringify(res));
79
83
  }
80
- const data = cameraDetailsResponseSchema.parse(await res.json());
84
+ const responseBody = await res.text();
85
+ const result = await cameraDetailsResponseSchema.safeParseAsync(JSON.parse(responseBody));
86
+ if (!result.success) {
87
+ throw new Error('Genetec get camera details failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
88
+ }
89
+ const data = result.data;
81
90
  const resultArray = Array.isArray(data.Rsp.Result) ? data.Rsp.Result : [data.Rsp.Result];
82
91
  allCameras.push(...resultArray);
83
92
  }
84
93
  return allCameras;
85
94
  }
86
95
  async sendBookmark(guids, bookmarkText) {
87
- const cameraEntitiesUrl = [];
88
96
  const timeStamp = this.getTimeStamp();
89
97
  const requestOptions = this.getRequestOptions('POST');
90
- for (const guid of guids) {
91
- cameraEntitiesUrl.push(`${ACTION}(${guid},${timeStamp},${bookmarkText})`);
92
- }
93
- const res = await this.fetchWithTimeout(`${this.baseUrl}/action?q=${cameraEntitiesUrl.join(',')}`, requestOptions);
98
+ const url = new URL(`${this.baseUrl}/action`);
99
+ url.searchParams.set('q', guids.map((guid) => `AddCameraBookmark(${guid},${timeStamp},${bookmarkText})`).join(','));
100
+ const res = await this.fetchWithTimeout(url, requestOptions);
94
101
  if (!res.ok) {
95
102
  throw new Error(await responseStringify(res));
96
103
  }
97
- return res;
104
+ const responseBody = await res.text();
105
+ const result = await successResponseSchema.safeParseAsync(JSON.parse(responseBody));
106
+ if (!result.success) {
107
+ throw new Error('Genetec send bookmark failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
108
+ }
98
109
  }
99
110
  getRequestOptions(method) {
100
111
  return {
@@ -1,4 +1,5 @@
1
- export { DefaultClient } from './DefaultClient';
2
- export { WsClient } from './WsClient';
3
- export { AxisCameraStationEvents } from '../events/AxisCameraStationEvents';
1
+ export * from './DefaultClient';
2
+ export * from './WsClient';
3
+ export * from './HttpServer';
4
+ export * from '../events/AxisCameraStationEvents';
4
5
  export * from '../events/GenetecAgent';
package/esm/node/index.js CHANGED
@@ -1,4 +1,5 @@
1
- export { DefaultClient } from './DefaultClient';
2
- export { WsClient } from './WsClient';
3
- export { AxisCameraStationEvents } from '../events/AxisCameraStationEvents';
1
+ export * from './DefaultClient';
2
+ export * from './WsClient';
3
+ export * from './HttpServer';
4
+ export * from '../events/AxisCameraStationEvents';
4
5
  export * from '../events/GenetecAgent';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.0-beta.32",
3
+ "version": "4.0.0-beta.33",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "engine": {