camstreamerlib 5.0.0-9647f54 → 5.0.1-5fad3e0
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.js +6 -5
- package/cjs/internal/posixTimeZone.d.ts +1 -0
- package/cjs/internal/posixTimeZone.js +6 -0
- package/cjs/internal/posixTimeZone.test.d.ts +1 -0
- package/cjs/internal/posixTimeZone.test.js +23 -0
- package/esm/VapixAPI.js +6 -5
- package/esm/internal/posixTimeZone.js +2 -0
- package/esm/internal/posixTimeZone.test.js +21 -0
- package/package.json +1 -1
- package/types/internal/posixTimeZone.d.ts +1 -0
- package/types/internal/posixTimeZone.test.d.ts +1 -0
package/cjs/VapixAPI.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VapixAPI = void 0;
|
|
4
4
|
const utils_1 = require("./internal/utils");
|
|
5
|
+
const posixTimeZone_1 = require("./internal/posixTimeZone");
|
|
5
6
|
const VapixAPI_1 = require("./types/VapixAPI");
|
|
6
7
|
const errors_1 = require("./errors/errors");
|
|
7
8
|
const zod_1 = require("zod");
|
|
@@ -159,13 +160,13 @@ class VapixAPI extends BasicAPI_1.BasicAPI {
|
|
|
159
160
|
}
|
|
160
161
|
catch (error) {
|
|
161
162
|
console.warn('Could not retreive timezone from either API endpoints, reading param.cgi');
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
163
|
+
const params = await this.getParameter(['Time.POSIXTimeZone', 'Time.DST.Enabled'], options);
|
|
164
|
+
const posixTimezone = params['Time.POSIXTimeZone'];
|
|
165
|
+
if (posixTimezone === undefined) {
|
|
167
166
|
throw error;
|
|
168
167
|
}
|
|
168
|
+
const posix = zod_1.z.string().parse(posixTimezone);
|
|
169
|
+
return params['Time.DST.Enabled'] === 'no' ? (0, posixTimeZone_1.stripPosixDst)(posix) : posix;
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
async getAllDateTimeInfo(options) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const stripPosixDst: (posix: string) => string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripPosixDst = void 0;
|
|
4
|
+
const POSIX_STANDARD_PART_REGEX = /^(<[^>]+>|[A-Za-z]{3,})[+-]?\d{1,2}(?::\d{2}){0,2}/;
|
|
5
|
+
const stripPosixDst = (posix) => posix.match(POSIX_STANDARD_PART_REGEX)?.[0] ?? posix;
|
|
6
|
+
exports.stripPosixDst = stripPosixDst;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const posixTimeZone_1 = require("./posixTimeZone");
|
|
4
|
+
const globals_1 = require("@jest/globals");
|
|
5
|
+
(0, globals_1.describe)('posixTimeZone', () => {
|
|
6
|
+
(0, globals_1.describe)('stripPosixDst', () => {
|
|
7
|
+
globals_1.test.each([
|
|
8
|
+
{ name: 'Sydney', input: 'EST-10EST,M10.1.0,M4.1.0/3', expected: 'EST-10' },
|
|
9
|
+
{ name: 'Honolulu', input: 'HAST10HADT,M3.2.0,M11.1.0', expected: 'HAST10' },
|
|
10
|
+
{ name: 'Denver', input: 'MST7MDT,M3.2.0,M11.1.0', expected: 'MST7' },
|
|
11
|
+
{ name: 'bracketed names', input: '<+10>-10<+11>,M10.1.0,M4.1.0/3', expected: '<+10>-10' },
|
|
12
|
+
{ name: 'half-hour offset', input: 'CST-9:30CST,M10.1.0,M4.1.0/3', expected: 'CST-9:30' },
|
|
13
|
+
])('removes the DST part for $name', ({ input, expected }) => {
|
|
14
|
+
(0, globals_1.expect)((0, posixTimeZone_1.stripPosixDst)(input)).toBe(expected);
|
|
15
|
+
});
|
|
16
|
+
globals_1.test.each(['EST-10', 'HAST10', '<+10>-10', 'CST-9:30', 'UTC0'])('keeps DST-free input %s unchanged', (input) => {
|
|
17
|
+
(0, globals_1.expect)((0, posixTimeZone_1.stripPosixDst)(input)).toBe(input);
|
|
18
|
+
});
|
|
19
|
+
(0, globals_1.test)('returns unparseable input unchanged', () => {
|
|
20
|
+
(0, globals_1.expect)((0, posixTimeZone_1.stripPosixDst)('garbage')).toBe('garbage');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
package/esm/VapixAPI.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { arrayToUrl, isNullish, paramToUrl } from './internal/utils';
|
|
2
|
+
import { stripPosixDst } from './internal/posixTimeZone';
|
|
2
3
|
import { sdCardWatchedStatuses, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, applicationSchema, timeZoneSchema, getPortsResponseSchema, guardTourSchema, ptzOverviewSchema, cameraPTZItemDataSchema, sdCardInfoSchema, ALL_APP_IDS, allDateTimeInfoSchema, } from './types/VapixAPI';
|
|
3
4
|
import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, ErrorWithResponse, SDCardActionError, SDCardJobError, SettingParameterError, TimezoneFetchError, } from './errors/errors';
|
|
4
5
|
import { z } from 'zod';
|
|
@@ -156,13 +157,13 @@ export class VapixAPI extends BasicAPI {
|
|
|
156
157
|
}
|
|
157
158
|
catch (error) {
|
|
158
159
|
console.warn('Could not retreive timezone from either API endpoints, reading param.cgi');
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
160
|
+
const params = await this.getParameter(['Time.POSIXTimeZone', 'Time.DST.Enabled'], options);
|
|
161
|
+
const posixTimezone = params['Time.POSIXTimeZone'];
|
|
162
|
+
if (posixTimezone === undefined) {
|
|
164
163
|
throw error;
|
|
165
164
|
}
|
|
165
|
+
const posix = z.string().parse(posixTimezone);
|
|
166
|
+
return params['Time.DST.Enabled'] === 'no' ? stripPosixDst(posix) : posix;
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
async getAllDateTimeInfo(options) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { stripPosixDst } from './posixTimeZone';
|
|
2
|
+
import { describe, test, expect } from '@jest/globals';
|
|
3
|
+
describe('posixTimeZone', () => {
|
|
4
|
+
describe('stripPosixDst', () => {
|
|
5
|
+
test.each([
|
|
6
|
+
{ name: 'Sydney', input: 'EST-10EST,M10.1.0,M4.1.0/3', expected: 'EST-10' },
|
|
7
|
+
{ name: 'Honolulu', input: 'HAST10HADT,M3.2.0,M11.1.0', expected: 'HAST10' },
|
|
8
|
+
{ name: 'Denver', input: 'MST7MDT,M3.2.0,M11.1.0', expected: 'MST7' },
|
|
9
|
+
{ name: 'bracketed names', input: '<+10>-10<+11>,M10.1.0,M4.1.0/3', expected: '<+10>-10' },
|
|
10
|
+
{ name: 'half-hour offset', input: 'CST-9:30CST,M10.1.0,M4.1.0/3', expected: 'CST-9:30' },
|
|
11
|
+
])('removes the DST part for $name', ({ input, expected }) => {
|
|
12
|
+
expect(stripPosixDst(input)).toBe(expected);
|
|
13
|
+
});
|
|
14
|
+
test.each(['EST-10', 'HAST10', '<+10>-10', 'CST-9:30', 'UTC0'])('keeps DST-free input %s unchanged', (input) => {
|
|
15
|
+
expect(stripPosixDst(input)).toBe(input);
|
|
16
|
+
});
|
|
17
|
+
test('returns unparseable input unchanged', () => {
|
|
18
|
+
expect(stripPosixDst('garbage')).toBe('garbage');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const stripPosixDst: (posix: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|