camstreamerlib 4.0.8 → 4.0.9

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/cjs/VapixAPI.d.ts CHANGED
@@ -21,6 +21,17 @@ export declare class VapixAPI<Client extends IClient<TResponse, any>> extends Ba
21
21
  getSystemLog(options?: THttpRequestOptions): Promise<string>;
22
22
  getMaxFps(channel: number, options?: THttpRequestOptions): Promise<number>;
23
23
  getTimezone(options?: THttpRequestOptions): Promise<string>;
24
+ getAllDateTimeInfo(options?: THttpRequestOptions): Promise<{
25
+ data: {
26
+ dateTime: string;
27
+ dstEnabled: boolean;
28
+ localDateTime: string;
29
+ posixTimeZone: string;
30
+ maxYearSupported: number;
31
+ timeZones: string[];
32
+ timeZone?: string | undefined;
33
+ };
34
+ }>;
24
35
  getDateTimeInfo(options?: THttpRequestOptions): Promise<{
25
36
  data: {
26
37
  dateTime: string;
package/cjs/VapixAPI.js CHANGED
@@ -152,12 +152,17 @@ class VapixAPI extends BasicAPI_1.BasicAPI {
152
152
  console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
153
153
  console.warn('Falling back to deprecated time API v1');
154
154
  }
155
- const data = await this.getDateTimeInfo(options);
155
+ const data = await this.getAllDateTimeInfo(options);
156
156
  if (data.data.timeZone === undefined) {
157
157
  throw new errors_1.TimezoneNotSetupError();
158
158
  }
159
159
  return zod_1.z.string().parse(data.data.timeZone);
160
160
  }
161
+ async getAllDateTimeInfo(options) {
162
+ const data = { apiVersion: '1.0', method: 'getAll' };
163
+ const res = await this._postJsonEncoded('/axis-cgi/time.cgi', data, undefined, options);
164
+ return VapixAPI_1.allDateTimeInfoSchema.parse(await res.json());
165
+ }
161
166
  async getDateTimeInfo(options) {
162
167
  const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
163
168
  const res = await this._postJsonEncoded('/axis-cgi/time.cgi', data, undefined, options);
@@ -77,8 +77,8 @@ const parseVideoOptionsToVapixParams = (firmWareVersion, video) => {
77
77
  const nbrOfChannels = video.nbrOfChannels ? (video.audio === 1 ? `&nbrOfChannels=${video.nbrOfChannels}` : '') : '';
78
78
  const audioParams = `audio=${video.audio}${nbrOfChannels}`;
79
79
  const videoCodecParams = video.videoCodec === 'h264'
80
- ? `videoCodec=${video.videoCodec}&h264Profile=${video.h264Profile}`
81
- : `videoCodec=${video.videoCodec}`;
80
+ ? `videocodec=${video.videoCodec}&h264Profile=${video.h264Profile}`
81
+ : `videocodec=${video.videoCodec}`;
82
82
  const videoParams = `camera=${video.camera}&resolution=${video.resolution}&fps=${video.fps}&compression=${video.compression}&videokeyframeinterval=${video.govLength}&${videoCodecParams}${overlaysParams}`;
83
83
  return [videoParams, bitrateParams, audioParams].join('&');
84
84
  };
@@ -91,7 +91,7 @@ const parseVapixParamsToVideoOptions = (internalVapixParams) => {
91
91
  params[key] = value;
92
92
  });
93
93
  let h264Profile = undefined;
94
- if (params['videoCodec'] === 'h264') {
94
+ if (params['videocodec'] === 'h264') {
95
95
  h264Profile = (params['h264Profile'] ?? 'high');
96
96
  }
97
97
  let nbrOfChannels = undefined;
@@ -105,7 +105,7 @@ const parseVapixParamsToVideoOptions = (internalVapixParams) => {
105
105
  fps: parseInt(params['fps'] ?? '0', 10),
106
106
  compression: parseInt(params['compression'] ?? '0', 10),
107
107
  govLength: parseInt(params['videokeyframeinterval'] ?? '0', 10),
108
- videoCodec: (params['videoCodec'] ?? 'h264'),
108
+ videoCodec: (params['videocodec'] ?? 'h264'),
109
109
  h264Profile,
110
110
  audio: parseInt(params['audio'] ?? '0'),
111
111
  nbrOfChannels,
@@ -1576,6 +1576,54 @@ export declare const dateTimeinfoSchema: z.ZodObject<{
1576
1576
  timeZone?: string | undefined;
1577
1577
  };
1578
1578
  }>;
1579
+ export declare const allDateTimeInfoSchema: z.ZodObject<{
1580
+ data: z.ZodObject<{
1581
+ dateTime: z.ZodString;
1582
+ dstEnabled: z.ZodBoolean;
1583
+ localDateTime: z.ZodString;
1584
+ posixTimeZone: z.ZodString;
1585
+ timeZone: z.ZodOptional<z.ZodString>;
1586
+ } & {
1587
+ maxYearSupported: z.ZodNumber;
1588
+ timeZones: z.ZodArray<z.ZodString, "many">;
1589
+ }, "strip", z.ZodTypeAny, {
1590
+ dateTime: string;
1591
+ dstEnabled: boolean;
1592
+ localDateTime: string;
1593
+ posixTimeZone: string;
1594
+ maxYearSupported: number;
1595
+ timeZones: string[];
1596
+ timeZone?: string | undefined;
1597
+ }, {
1598
+ dateTime: string;
1599
+ dstEnabled: boolean;
1600
+ localDateTime: string;
1601
+ posixTimeZone: string;
1602
+ maxYearSupported: number;
1603
+ timeZones: string[];
1604
+ timeZone?: string | undefined;
1605
+ }>;
1606
+ }, "strip", z.ZodTypeAny, {
1607
+ data: {
1608
+ dateTime: string;
1609
+ dstEnabled: boolean;
1610
+ localDateTime: string;
1611
+ posixTimeZone: string;
1612
+ maxYearSupported: number;
1613
+ timeZones: string[];
1614
+ timeZone?: string | undefined;
1615
+ };
1616
+ }, {
1617
+ data: {
1618
+ dateTime: string;
1619
+ dstEnabled: boolean;
1620
+ localDateTime: string;
1621
+ posixTimeZone: string;
1622
+ maxYearSupported: number;
1623
+ timeZones: string[];
1624
+ timeZone?: string | undefined;
1625
+ };
1626
+ }>;
1579
1627
  export declare const timeZoneSchema: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
1580
1628
  status: z.ZodLiteral<"success">;
1581
1629
  data: z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recordingConfigItemSchema = exports.portSequenceStateSchema = exports.portSetSchema = exports.getPortsResponseSchema = exports.portStatusSchema = exports.audioSampleRatesResponseSchema = exports.timeZoneSchema = exports.dateTimeinfoSchema = exports.maxFpsResponseSchema = exports.audioDeviceRequestSchema = exports.audioDeviceSchema = exports.audioDeviceInputOutputSchema = exports.audioDeviceConnectionTypeSchema = exports.audioDeviceSignalingTypeSchema = exports.audioDeviceSignalingChannelTypeSchema = exports.cameraPTZItemSchema = exports.cameraPTZItemDataSchema = exports.ptzOverviewSchema = exports.sdCardInfoSchema = exports.sdCardWatchedStatuses = exports.guardTourSchema = exports.ALL_APP_IDS = exports.APP_IDS = exports.applicationListSchema = exports.applicationSchema = void 0;
3
+ exports.recordingConfigItemSchema = exports.portSequenceStateSchema = exports.portSetSchema = exports.getPortsResponseSchema = exports.portStatusSchema = exports.audioSampleRatesResponseSchema = exports.timeZoneSchema = exports.allDateTimeInfoSchema = exports.dateTimeinfoSchema = exports.maxFpsResponseSchema = exports.audioDeviceRequestSchema = exports.audioDeviceSchema = exports.audioDeviceInputOutputSchema = exports.audioDeviceConnectionTypeSchema = exports.audioDeviceSignalingTypeSchema = exports.audioDeviceSignalingChannelTypeSchema = exports.cameraPTZItemSchema = exports.cameraPTZItemDataSchema = exports.ptzOverviewSchema = exports.sdCardInfoSchema = exports.sdCardWatchedStatuses = exports.guardTourSchema = exports.ALL_APP_IDS = exports.APP_IDS = exports.applicationListSchema = exports.applicationSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const transformers_1 = require("../internal/transformers");
6
6
  exports.applicationSchema = zod_1.z.object({
@@ -123,13 +123,20 @@ exports.maxFpsResponseSchema = zod_1.z.object({
123
123
  }))
124
124
  .optional(),
125
125
  });
126
+ const timeInfoSchema = zod_1.z.object({
127
+ dateTime: zod_1.z.string(),
128
+ dstEnabled: zod_1.z.boolean(),
129
+ localDateTime: zod_1.z.string(),
130
+ posixTimeZone: zod_1.z.string(),
131
+ timeZone: zod_1.z.string().optional(),
132
+ });
126
133
  exports.dateTimeinfoSchema = zod_1.z.object({
127
- data: zod_1.z.object({
128
- dateTime: zod_1.z.string(),
129
- dstEnabled: zod_1.z.boolean(),
130
- localDateTime: zod_1.z.string(),
131
- posixTimeZone: zod_1.z.string(),
132
- timeZone: zod_1.z.string().optional(),
134
+ data: timeInfoSchema,
135
+ });
136
+ exports.allDateTimeInfoSchema = zod_1.z.object({
137
+ data: timeInfoSchema.extend({
138
+ maxYearSupported: zod_1.z.number(),
139
+ timeZones: zod_1.z.array(zod_1.z.string()),
133
140
  }),
134
141
  });
135
142
  exports.timeZoneSchema = zod_1.z.discriminatedUnion('status', [
package/esm/VapixAPI.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { arrayToUrl, isNullish, paramToUrl } from './internal/utils';
2
- import { sdCardWatchedStatuses, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, timeZoneSchema, getPortsResponseSchema, guardTourSchema, ptzOverviewSchema, cameraPTZItemDataSchema, applicationListSchema, sdCardInfoSchema, ALL_APP_IDS, } from './types/VapixAPI';
2
+ import { sdCardWatchedStatuses, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, timeZoneSchema, getPortsResponseSchema, guardTourSchema, ptzOverviewSchema, cameraPTZItemDataSchema, applicationListSchema, sdCardInfoSchema, ALL_APP_IDS, allDateTimeInfoSchema, } from './types/VapixAPI';
3
3
  import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, ErrorWithResponse, SDCardActionError, SDCardJobError, SettingParameterError, TimezoneFetchError, TimezoneNotSetupError, } from './errors/errors';
4
4
  import { z } from 'zod';
5
5
  import { XMLParser } from 'fast-xml-parser';
@@ -149,12 +149,17 @@ export class VapixAPI extends BasicAPI {
149
149
  console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
150
150
  console.warn('Falling back to deprecated time API v1');
151
151
  }
152
- const data = await this.getDateTimeInfo(options);
152
+ const data = await this.getAllDateTimeInfo(options);
153
153
  if (data.data.timeZone === undefined) {
154
154
  throw new TimezoneNotSetupError();
155
155
  }
156
156
  return z.string().parse(data.data.timeZone);
157
157
  }
158
+ async getAllDateTimeInfo(options) {
159
+ const data = { apiVersion: '1.0', method: 'getAll' };
160
+ const res = await this._postJsonEncoded('/axis-cgi/time.cgi', data, undefined, options);
161
+ return allDateTimeInfoSchema.parse(await res.json());
162
+ }
158
163
  async getDateTimeInfo(options) {
159
164
  const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
160
165
  const res = await this._postJsonEncoded('/axis-cgi/time.cgi', data, undefined, options);
@@ -72,8 +72,8 @@ export const parseVideoOptionsToVapixParams = (firmWareVersion, video) => {
72
72
  const nbrOfChannels = video.nbrOfChannels ? (video.audio === 1 ? `&nbrOfChannels=${video.nbrOfChannels}` : '') : '';
73
73
  const audioParams = `audio=${video.audio}${nbrOfChannels}`;
74
74
  const videoCodecParams = video.videoCodec === 'h264'
75
- ? `videoCodec=${video.videoCodec}&h264Profile=${video.h264Profile}`
76
- : `videoCodec=${video.videoCodec}`;
75
+ ? `videocodec=${video.videoCodec}&h264Profile=${video.h264Profile}`
76
+ : `videocodec=${video.videoCodec}`;
77
77
  const videoParams = `camera=${video.camera}&resolution=${video.resolution}&fps=${video.fps}&compression=${video.compression}&videokeyframeinterval=${video.govLength}&${videoCodecParams}${overlaysParams}`;
78
78
  return [videoParams, bitrateParams, audioParams].join('&');
79
79
  };
@@ -85,7 +85,7 @@ export const parseVapixParamsToVideoOptions = (internalVapixParams) => {
85
85
  params[key] = value;
86
86
  });
87
87
  let h264Profile = undefined;
88
- if (params['videoCodec'] === 'h264') {
88
+ if (params['videocodec'] === 'h264') {
89
89
  h264Profile = (params['h264Profile'] ?? 'high');
90
90
  }
91
91
  let nbrOfChannels = undefined;
@@ -99,7 +99,7 @@ export const parseVapixParamsToVideoOptions = (internalVapixParams) => {
99
99
  fps: parseInt(params['fps'] ?? '0', 10),
100
100
  compression: parseInt(params['compression'] ?? '0', 10),
101
101
  govLength: parseInt(params['videokeyframeinterval'] ?? '0', 10),
102
- videoCodec: (params['videoCodec'] ?? 'h264'),
102
+ videoCodec: (params['videocodec'] ?? 'h264'),
103
103
  h264Profile,
104
104
  audio: parseInt(params['audio'] ?? '0'),
105
105
  nbrOfChannels,
@@ -120,13 +120,20 @@ export const maxFpsResponseSchema = z.object({
120
120
  }))
121
121
  .optional(),
122
122
  });
123
+ const timeInfoSchema = z.object({
124
+ dateTime: z.string(),
125
+ dstEnabled: z.boolean(),
126
+ localDateTime: z.string(),
127
+ posixTimeZone: z.string(),
128
+ timeZone: z.string().optional(),
129
+ });
123
130
  export const dateTimeinfoSchema = z.object({
124
- data: z.object({
125
- dateTime: z.string(),
126
- dstEnabled: z.boolean(),
127
- localDateTime: z.string(),
128
- posixTimeZone: z.string(),
129
- timeZone: z.string().optional(),
131
+ data: timeInfoSchema,
132
+ });
133
+ export const allDateTimeInfoSchema = z.object({
134
+ data: timeInfoSchema.extend({
135
+ maxYearSupported: z.number(),
136
+ timeZones: z.array(z.string()),
130
137
  }),
131
138
  });
132
139
  export const timeZoneSchema = z.discriminatedUnion('status', [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "engine": {
@@ -21,6 +21,17 @@ export declare class VapixAPI<Client extends IClient<TResponse, any>> extends Ba
21
21
  getSystemLog(options?: THttpRequestOptions): Promise<string>;
22
22
  getMaxFps(channel: number, options?: THttpRequestOptions): Promise<number>;
23
23
  getTimezone(options?: THttpRequestOptions): Promise<string>;
24
+ getAllDateTimeInfo(options?: THttpRequestOptions): Promise<{
25
+ data: {
26
+ dateTime: string;
27
+ dstEnabled: boolean;
28
+ localDateTime: string;
29
+ posixTimeZone: string;
30
+ maxYearSupported: number;
31
+ timeZones: string[];
32
+ timeZone?: string | undefined;
33
+ };
34
+ }>;
24
35
  getDateTimeInfo(options?: THttpRequestOptions): Promise<{
25
36
  data: {
26
37
  dateTime: string;
@@ -1576,6 +1576,54 @@ export declare const dateTimeinfoSchema: z.ZodObject<{
1576
1576
  timeZone?: string | undefined;
1577
1577
  };
1578
1578
  }>;
1579
+ export declare const allDateTimeInfoSchema: z.ZodObject<{
1580
+ data: z.ZodObject<{
1581
+ dateTime: z.ZodString;
1582
+ dstEnabled: z.ZodBoolean;
1583
+ localDateTime: z.ZodString;
1584
+ posixTimeZone: z.ZodString;
1585
+ timeZone: z.ZodOptional<z.ZodString>;
1586
+ } & {
1587
+ maxYearSupported: z.ZodNumber;
1588
+ timeZones: z.ZodArray<z.ZodString, "many">;
1589
+ }, "strip", z.ZodTypeAny, {
1590
+ dateTime: string;
1591
+ dstEnabled: boolean;
1592
+ localDateTime: string;
1593
+ posixTimeZone: string;
1594
+ maxYearSupported: number;
1595
+ timeZones: string[];
1596
+ timeZone?: string | undefined;
1597
+ }, {
1598
+ dateTime: string;
1599
+ dstEnabled: boolean;
1600
+ localDateTime: string;
1601
+ posixTimeZone: string;
1602
+ maxYearSupported: number;
1603
+ timeZones: string[];
1604
+ timeZone?: string | undefined;
1605
+ }>;
1606
+ }, "strip", z.ZodTypeAny, {
1607
+ data: {
1608
+ dateTime: string;
1609
+ dstEnabled: boolean;
1610
+ localDateTime: string;
1611
+ posixTimeZone: string;
1612
+ maxYearSupported: number;
1613
+ timeZones: string[];
1614
+ timeZone?: string | undefined;
1615
+ };
1616
+ }, {
1617
+ data: {
1618
+ dateTime: string;
1619
+ dstEnabled: boolean;
1620
+ localDateTime: string;
1621
+ posixTimeZone: string;
1622
+ maxYearSupported: number;
1623
+ timeZones: string[];
1624
+ timeZone?: string | undefined;
1625
+ };
1626
+ }>;
1579
1627
  export declare const timeZoneSchema: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
1580
1628
  status: z.ZodLiteral<"success">;
1581
1629
  data: z.ZodObject<{