camstreamerlib 4.0.0-beta.84 → 4.0.0-beta.86
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/CamStreamerAPI.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProxyClient } from './internal/ProxyClient';
|
|
2
|
-
import { IClient, TResponse } from './internal/types';
|
|
2
|
+
import { IClient, TBlobResponse, TResponse } from './internal/types';
|
|
3
3
|
import { TAudioFile, TAudioFileStorageType, TStream, TStreamList } from './types/CamStreamerAPI/CamStreamerAPI';
|
|
4
4
|
import { THttpRequestOptions, TProxyParams } from './types/common';
|
|
5
5
|
import { TOldStream, TOldStringStream } from './types/CamStreamerAPI/oldStreamSchema';
|
|
@@ -369,7 +369,11 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> {
|
|
|
369
369
|
type: "SD0";
|
|
370
370
|
SD0: string;
|
|
371
371
|
})[]>;
|
|
372
|
+
getFileFromCamera(path: string, options?: THttpRequestOptions): Promise<TBlobResponse<Client>>;
|
|
372
373
|
private _getJson;
|
|
374
|
+
private _getBlob;
|
|
375
|
+
private parseBlobResponse;
|
|
376
|
+
private _postUrlEncoded;
|
|
373
377
|
private _postJsonEncoded;
|
|
374
378
|
private _post;
|
|
375
379
|
}
|
package/cjs/CamStreamerAPI.js
CHANGED
|
@@ -6,6 +6,7 @@ const ProxyClient_1 = require("./internal/ProxyClient");
|
|
|
6
6
|
const CamStreamerAPI_1 = require("./types/CamStreamerAPI/CamStreamerAPI");
|
|
7
7
|
const errors_1 = require("./errors/errors");
|
|
8
8
|
const oldStreamSchema_1 = require("./types/CamStreamerAPI/oldStreamSchema");
|
|
9
|
+
const utils_1 = require("./internal/utils");
|
|
9
10
|
const BASE_PATH = '/local/camstreamer';
|
|
10
11
|
class CamStreamerAPI {
|
|
11
12
|
client;
|
|
@@ -98,15 +99,15 @@ class CamStreamerAPI {
|
|
|
98
99
|
}, options);
|
|
99
100
|
}
|
|
100
101
|
async removeFile(fileParams, options) {
|
|
101
|
-
await this.
|
|
102
|
-
action: 'remove',
|
|
103
|
-
...fileParams,
|
|
104
|
-
}, options);
|
|
102
|
+
await this._postUrlEncoded(`${BASE_PATH}/upload_audio.cgi`, { action: 'remove', ...fileParams }, options, undefined);
|
|
105
103
|
}
|
|
106
104
|
async getFileStorage(options) {
|
|
107
105
|
const res = await this._getJson(`${BASE_PATH}/upload_audio.cgi`, { action: 'get_storage' }, options);
|
|
108
106
|
return CamStreamerAPI_1.storageListSchema.parse(res.data);
|
|
109
107
|
}
|
|
108
|
+
async getFileFromCamera(path, options) {
|
|
109
|
+
return await this._getBlob(`${BASE_PATH}/audio.cgi`, { path }, options);
|
|
110
|
+
}
|
|
110
111
|
async _getJson(path, parameters, options) {
|
|
111
112
|
const agent = this.getClient(options?.proxyParams);
|
|
112
113
|
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
@@ -117,6 +118,29 @@ class CamStreamerAPI {
|
|
|
117
118
|
throw new errors_1.ErrorWithResponse(res);
|
|
118
119
|
}
|
|
119
120
|
}
|
|
121
|
+
async _getBlob(path, parameters, options) {
|
|
122
|
+
const agent = this.getClient(options?.proxyParams);
|
|
123
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
124
|
+
if (res.ok) {
|
|
125
|
+
return await this.parseBlobResponse(res);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async parseBlobResponse(response) {
|
|
132
|
+
try {
|
|
133
|
+
return (await response.blob());
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
throw new errors_1.ParsingBlobError(err);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async _postUrlEncoded(path, parameters, options, headers) {
|
|
140
|
+
const data = (0, utils_1.paramToUrl)(parameters);
|
|
141
|
+
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
142
|
+
return this._post(path, data, undefined, options, { ...baseHeaders, ...headers });
|
|
143
|
+
}
|
|
120
144
|
async _postJsonEncoded(path, data, parameters, options, headers) {
|
|
121
145
|
const agent = this.getClient(options?.proxyParams);
|
|
122
146
|
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
@@ -2140,7 +2140,7 @@ export declare enum AudioType {
|
|
|
2140
2140
|
}
|
|
2141
2141
|
export declare const audioFileStorageTypeSchema: z.ZodUnion<[z.ZodLiteral<"flash">, z.ZodLiteral<"SD0">, z.ZodLiteral<"url">]>;
|
|
2142
2142
|
export type TAudioFileStorageType = z.infer<typeof audioFileStorageTypeSchema>;
|
|
2143
|
-
export type
|
|
2143
|
+
export type TSourceType = 'local' | 'url';
|
|
2144
2144
|
export declare const storageListSchema: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
2145
2145
|
type: z.ZodLiteral<"flash">;
|
|
2146
2146
|
flash: z.ZodString;
|
package/esm/CamStreamerAPI.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ProxyClient } from './internal/ProxyClient';
|
|
3
3
|
import { audioFileListSchema, storageListSchema, streamSchema, } from './types/CamStreamerAPI/CamStreamerAPI';
|
|
4
|
-
import { ErrorWithResponse, UtcTimeFetchError, WsAuthorizationError, MigrationError } from './errors/errors';
|
|
4
|
+
import { ErrorWithResponse, UtcTimeFetchError, WsAuthorizationError, MigrationError, ParsingBlobError, } from './errors/errors';
|
|
5
5
|
import { oldStringStreamSchema, oldStringStreamSchemaWithId, } from './types/CamStreamerAPI/oldStreamSchema';
|
|
6
|
+
import { paramToUrl } from './internal/utils';
|
|
6
7
|
const BASE_PATH = '/local/camstreamer';
|
|
7
8
|
export class CamStreamerAPI {
|
|
8
9
|
client;
|
|
@@ -95,15 +96,15 @@ export class CamStreamerAPI {
|
|
|
95
96
|
}, options);
|
|
96
97
|
}
|
|
97
98
|
async removeFile(fileParams, options) {
|
|
98
|
-
await this.
|
|
99
|
-
action: 'remove',
|
|
100
|
-
...fileParams,
|
|
101
|
-
}, options);
|
|
99
|
+
await this._postUrlEncoded(`${BASE_PATH}/upload_audio.cgi`, { action: 'remove', ...fileParams }, options, undefined);
|
|
102
100
|
}
|
|
103
101
|
async getFileStorage(options) {
|
|
104
102
|
const res = await this._getJson(`${BASE_PATH}/upload_audio.cgi`, { action: 'get_storage' }, options);
|
|
105
103
|
return storageListSchema.parse(res.data);
|
|
106
104
|
}
|
|
105
|
+
async getFileFromCamera(path, options) {
|
|
106
|
+
return await this._getBlob(`${BASE_PATH}/audio.cgi`, { path }, options);
|
|
107
|
+
}
|
|
107
108
|
async _getJson(path, parameters, options) {
|
|
108
109
|
const agent = this.getClient(options?.proxyParams);
|
|
109
110
|
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
@@ -114,6 +115,29 @@ export class CamStreamerAPI {
|
|
|
114
115
|
throw new ErrorWithResponse(res);
|
|
115
116
|
}
|
|
116
117
|
}
|
|
118
|
+
async _getBlob(path, parameters, options) {
|
|
119
|
+
const agent = this.getClient(options?.proxyParams);
|
|
120
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
121
|
+
if (res.ok) {
|
|
122
|
+
return await this.parseBlobResponse(res);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
throw new ErrorWithResponse(res);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async parseBlobResponse(response) {
|
|
129
|
+
try {
|
|
130
|
+
return (await response.blob());
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
throw new ParsingBlobError(err);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async _postUrlEncoded(path, parameters, options, headers) {
|
|
137
|
+
const data = paramToUrl(parameters);
|
|
138
|
+
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
139
|
+
return this._post(path, data, undefined, options, { ...baseHeaders, ...headers });
|
|
140
|
+
}
|
|
117
141
|
async _postJsonEncoded(path, data, parameters, options, headers) {
|
|
118
142
|
const agent = this.getClient(options?.proxyParams);
|
|
119
143
|
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProxyClient } from './internal/ProxyClient';
|
|
2
|
-
import { IClient, TResponse } from './internal/types';
|
|
2
|
+
import { IClient, TBlobResponse, TResponse } from './internal/types';
|
|
3
3
|
import { TAudioFile, TAudioFileStorageType, TStream, TStreamList } from './types/CamStreamerAPI/CamStreamerAPI';
|
|
4
4
|
import { THttpRequestOptions, TProxyParams } from './types/common';
|
|
5
5
|
import { TOldStream, TOldStringStream } from './types/CamStreamerAPI/oldStreamSchema';
|
|
@@ -369,7 +369,11 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> {
|
|
|
369
369
|
type: "SD0";
|
|
370
370
|
SD0: string;
|
|
371
371
|
})[]>;
|
|
372
|
+
getFileFromCamera(path: string, options?: THttpRequestOptions): Promise<TBlobResponse<Client>>;
|
|
372
373
|
private _getJson;
|
|
374
|
+
private _getBlob;
|
|
375
|
+
private parseBlobResponse;
|
|
376
|
+
private _postUrlEncoded;
|
|
373
377
|
private _postJsonEncoded;
|
|
374
378
|
private _post;
|
|
375
379
|
}
|
|
@@ -2140,7 +2140,7 @@ export declare enum AudioType {
|
|
|
2140
2140
|
}
|
|
2141
2141
|
export declare const audioFileStorageTypeSchema: z.ZodUnion<[z.ZodLiteral<"flash">, z.ZodLiteral<"SD0">, z.ZodLiteral<"url">]>;
|
|
2142
2142
|
export type TAudioFileStorageType = z.infer<typeof audioFileStorageTypeSchema>;
|
|
2143
|
-
export type
|
|
2143
|
+
export type TSourceType = 'local' | 'url';
|
|
2144
2144
|
export declare const storageListSchema: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
2145
2145
|
type: z.ZodLiteral<"flash">;
|
|
2146
2146
|
flash: z.ZodString;
|