@placeos/ts-client 4.6.0 → 4.7.0
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/alerts/functions.d.ts +7 -10
- package/dist/alerts/interfaces.d.ts +22 -0
- package/dist/api.d.ts +30 -19
- package/dist/applications/functions.d.ts +2 -5
- package/dist/applications/interfaces.d.ts +5 -11
- package/dist/assets/functions.d.ts +5 -5
- package/dist/assets/interfaces.d.ts +38 -0
- package/dist/clusters/functions.d.ts +16 -7
- package/dist/clusters/interfaces.d.ts +18 -3
- package/dist/domains/functions.d.ts +10 -6
- package/dist/drivers/functions.d.ts +3 -5
- package/dist/drivers/interfaces.d.ts +9 -7
- package/dist/edge/functions.d.ts +8 -7
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +2232 -1895
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/ldap-sources/functions.d.ts +2 -5
- package/dist/metadata/functions.d.ts +8 -9
- package/dist/metadata/interfaces.d.ts +18 -4
- package/dist/modules/functions.d.ts +10 -4
- package/dist/modules/interfaces.d.ts +14 -12
- package/dist/oauth-sources/functions.d.ts +2 -5
- package/dist/repositories/functions.d.ts +17 -29
- package/dist/repositories/interfaces.d.ts +31 -3
- package/dist/resources/interface.d.ts +9 -4
- package/dist/saml-sources/functions.d.ts +4 -7
- package/dist/settings/functions.d.ts +6 -8
- package/dist/settings/interfaces.d.ts +7 -0
- package/dist/short-url/functions.d.ts +60 -0
- package/dist/short-url/interfaces.d.ts +22 -0
- package/dist/short-url/short-url.class.d.ts +17 -0
- package/dist/signage/interfaces.d.ts +9 -1
- package/dist/storages/functions.d.ts +31 -0
- package/dist/storages/interfaces.d.ts +6 -0
- package/dist/storages/storage.class.d.ts +18 -0
- package/dist/systems/functions.d.ts +38 -10
- package/dist/systems/interfaces.d.ts +58 -5
- package/dist/triggers/functions.d.ts +5 -7
- package/dist/triggers/interfaces.d.ts +9 -0
- package/dist/users/functions.d.ts +50 -10
- package/dist/users/interfaces.d.ts +35 -2
- package/dist/webrtc/functions.d.ts +52 -0
- package/dist/webrtc/interfaces.d.ts +73 -0
- package/dist/zones/functions.d.ts +12 -6
- package/dist/zones/interfaces.d.ts +9 -4
- package/package.json +1 -1
- package/src/alerts/functions.ts +14 -22
- package/src/alerts/interfaces.ts +25 -0
- package/src/api.ts +116 -3
- package/src/applications/functions.ts +4 -7
- package/src/applications/interfaces.ts +6 -12
- package/src/assets/functions.ts +10 -5
- package/src/assets/interfaces.ts +41 -0
- package/src/clusters/functions.ts +39 -8
- package/src/clusters/interfaces.ts +21 -3
- package/src/domains/functions.ts +17 -6
- package/src/drivers/functions.ts +4 -6
- package/src/drivers/interfaces.ts +11 -7
- package/src/edge/functions.ts +18 -10
- package/src/ldap-sources/functions.ts +4 -7
- package/src/metadata/functions.ts +16 -10
- package/src/metadata/interfaces.ts +20 -4
- package/src/modules/functions.ts +29 -7
- package/src/modules/interfaces.ts +15 -12
- package/src/oauth-sources/functions.ts +4 -7
- package/src/repositories/functions.ts +35 -35
- package/src/repositories/interfaces.ts +35 -3
- package/src/resources/interface.ts +9 -4
- package/src/saml-sources/functions.ts +6 -9
- package/src/settings/functions.ts +14 -10
- package/src/settings/interfaces.ts +8 -0
- package/src/short-url/functions.ts +155 -0
- package/src/short-url/interfaces.ts +25 -0
- package/src/short-url/short-url.class.ts +33 -0
- package/src/signage/interfaces.ts +10 -1
- package/src/storages/functions.ts +88 -0
- package/src/storages/interfaces.ts +7 -0
- package/src/storages/storage.class.ts +34 -0
- package/src/systems/functions.ts +113 -13
- package/src/systems/interfaces.ts +65 -5
- package/src/triggers/functions.ts +9 -8
- package/src/triggers/interfaces.ts +10 -0
- package/src/users/functions.ts +104 -9
- package/src/users/interfaces.ts +40 -2
- package/src/webrtc/functions.ts +120 -0
- package/src/webrtc/interfaces.ts +77 -0
- package/src/zones/functions.ts +28 -7
- package/src/zones/interfaces.ts +10 -4
- package/dist/assets/types.d.ts +0 -1
- package/src/assets/types.ts +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PlaceAuthSourceQueryOptions } from '../auth-sources/interfaces';
|
|
2
2
|
import { create, query, remove, show, update } from '../resources/functions';
|
|
3
|
-
import { HashMap } from '../utilities/types';
|
|
4
3
|
import { PlaceSAMLSource } from './saml-source';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -24,12 +23,11 @@ export function querySAMLSources(
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
|
-
* Get the data for
|
|
26
|
+
* Get the data for a SAML source
|
|
28
27
|
* @param id ID of the SAML source to retrieve
|
|
29
|
-
* @param query_params Query parameters to add the to request URL
|
|
30
28
|
*/
|
|
31
|
-
export function showSAMLSource(id: string
|
|
32
|
-
return show({ id, query_params, fn: process, path: PATH });
|
|
29
|
+
export function showSAMLSource(id: string) {
|
|
30
|
+
return show({ id, query_params: {}, fn: process, path: PATH });
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
/**
|
|
@@ -64,10 +62,9 @@ export function addSAMLSource(form_data: Partial<PlaceSAMLSource>) {
|
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
/**
|
|
67
|
-
* Remove
|
|
65
|
+
* Remove a SAML source from the database
|
|
68
66
|
* @param id ID of the SAML source
|
|
69
|
-
* @param query_params Query parameters to add the to request URL
|
|
70
67
|
*/
|
|
71
|
-
export function removeSAMLSource(id: string
|
|
72
|
-
return remove({ id, query_params, path: PATH });
|
|
68
|
+
export function removeSAMLSource(id: string) {
|
|
69
|
+
return remove({ id, query_params: {}, path: PATH });
|
|
73
70
|
}
|
|
@@ -7,7 +7,10 @@ import {
|
|
|
7
7
|
update,
|
|
8
8
|
} from '../resources/functions';
|
|
9
9
|
import { HashMap } from '../utilities/types';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
PlaceSettingsHistoryOptions,
|
|
12
|
+
PlaceSettingsQueryOptions,
|
|
13
|
+
} from './interfaces';
|
|
11
14
|
import { PlaceSettings } from './settings';
|
|
12
15
|
|
|
13
16
|
/**
|
|
@@ -31,10 +34,9 @@ export function querySettings(query_params: PlaceSettingsQueryOptions = {}) {
|
|
|
31
34
|
/**
|
|
32
35
|
* Get the data for settings
|
|
33
36
|
* @param id ID of the settings to retrieve
|
|
34
|
-
* @param query_params Query parameters to add the to request URL
|
|
35
37
|
*/
|
|
36
|
-
export function showSettings(id: string
|
|
37
|
-
return show({ id, query_params, fn: process, path: PATH });
|
|
38
|
+
export function showSettings(id: string) {
|
|
39
|
+
return show({ id, query_params: {}, fn: process, path: PATH });
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
/**
|
|
@@ -73,20 +75,22 @@ export function addSettings(
|
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
|
-
* Remove
|
|
78
|
+
* Remove settings from the database
|
|
77
79
|
* @param id ID of the settings
|
|
78
|
-
* @param query_params Query parameters to add the to request URL
|
|
79
80
|
*/
|
|
80
|
-
export function removeSettings(id: string
|
|
81
|
-
return remove({ id, query_params, path: PATH });
|
|
81
|
+
export function removeSettings(id: string) {
|
|
82
|
+
return remove({ id, query_params: {}, path: PATH });
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
|
-
* Get historical
|
|
86
|
+
* Get historical versions of settings
|
|
86
87
|
* @param id ID of the settings to retrieve
|
|
87
88
|
* @param query_params Query parameters to add the to request URL
|
|
88
89
|
*/
|
|
89
|
-
export function settingsHistory(
|
|
90
|
+
export function settingsHistory(
|
|
91
|
+
id: string,
|
|
92
|
+
query_params: PlaceSettingsHistoryOptions = {},
|
|
93
|
+
) {
|
|
90
94
|
return task({
|
|
91
95
|
id,
|
|
92
96
|
task_name: 'history',
|
|
@@ -17,3 +17,11 @@ export interface PlaceSettingsQueryOptions extends PlaceResourceQueryOptions {
|
|
|
17
17
|
/** ID of the parent zone, system, module or driver to grab settings for */
|
|
18
18
|
parent_id?: string;
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
/** Allowable query parameters for settings history endpoint */
|
|
22
|
+
export interface PlaceSettingsHistoryOptions {
|
|
23
|
+
/** Maximum number of results to return */
|
|
24
|
+
limit?: number;
|
|
25
|
+
/** Starting offset of the result set for pagination */
|
|
26
|
+
offset?: number;
|
|
27
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { create, query, remove, show, update } from '../api';
|
|
2
|
+
import { apiEndpoint } from '../auth';
|
|
3
|
+
import { get } from '../http/functions';
|
|
4
|
+
import { toQueryString } from '../utilities/api';
|
|
5
|
+
import { PlaceShortUrl } from './short-url.class';
|
|
6
|
+
import {
|
|
7
|
+
PlaceQrCodeOptions,
|
|
8
|
+
PlaceShortUrlPngQrOptions,
|
|
9
|
+
PlaceShortUrlQueryOptions,
|
|
10
|
+
} from './interfaces';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
const PATH = 'short_url';
|
|
16
|
+
|
|
17
|
+
/** Convert raw server data to a short URL object */
|
|
18
|
+
function processShortUrl(item: Partial<PlaceShortUrl>) {
|
|
19
|
+
return new PlaceShortUrl(item);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Query the available short URLs
|
|
24
|
+
* @param query_params Query parameters to add to the request URL
|
|
25
|
+
*/
|
|
26
|
+
export function queryShortUrls(query_params: PlaceShortUrlQueryOptions = {}) {
|
|
27
|
+
return query({
|
|
28
|
+
query_params,
|
|
29
|
+
fn: processShortUrl,
|
|
30
|
+
path: PATH,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get the data for a short URL
|
|
36
|
+
* @param id ID of the short URL to retrieve
|
|
37
|
+
* @param query_params Query parameters to add to the request URL
|
|
38
|
+
*/
|
|
39
|
+
export function showShortUrl(
|
|
40
|
+
id: string,
|
|
41
|
+
query_params: Record<string, any> = {},
|
|
42
|
+
) {
|
|
43
|
+
return show({
|
|
44
|
+
id,
|
|
45
|
+
query_params,
|
|
46
|
+
fn: processShortUrl,
|
|
47
|
+
path: PATH,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Update a short URL in the database
|
|
53
|
+
* @param id ID of the short URL
|
|
54
|
+
* @param form_data New values for the short URL
|
|
55
|
+
* @param method HTTP verb to use on request. Defaults to `patch`
|
|
56
|
+
*/
|
|
57
|
+
export function updateShortUrl(
|
|
58
|
+
id: string,
|
|
59
|
+
form_data: Partial<PlaceShortUrl>,
|
|
60
|
+
method: 'put' | 'patch' = 'patch',
|
|
61
|
+
) {
|
|
62
|
+
return update({
|
|
63
|
+
id,
|
|
64
|
+
form_data,
|
|
65
|
+
query_params: {},
|
|
66
|
+
method,
|
|
67
|
+
fn: processShortUrl,
|
|
68
|
+
path: PATH,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Add a new short URL to the database
|
|
74
|
+
* @param form_data Short URL data
|
|
75
|
+
*/
|
|
76
|
+
export function addShortUrl(form_data: Partial<PlaceShortUrl>) {
|
|
77
|
+
return create({
|
|
78
|
+
form_data,
|
|
79
|
+
query_params: {},
|
|
80
|
+
fn: processShortUrl,
|
|
81
|
+
path: PATH,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Remove a short URL from the database
|
|
87
|
+
* @param id ID of the short URL
|
|
88
|
+
* @param query_params Query parameters to add to the request URL
|
|
89
|
+
*/
|
|
90
|
+
export function removeShortUrl(
|
|
91
|
+
id: string,
|
|
92
|
+
query_params: Record<string, any> = {},
|
|
93
|
+
) {
|
|
94
|
+
return remove({ id, query_params, path: PATH });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get the redirect URL for a short URL.
|
|
99
|
+
* Returns the full redirect URL that can be used to navigate to the short URL destination.
|
|
100
|
+
* @param id ID of the short URL
|
|
101
|
+
*/
|
|
102
|
+
export function shortUrlRedirectUrl(
|
|
103
|
+
id: string,
|
|
104
|
+
): string {
|
|
105
|
+
return `${apiEndpoint()}${PATH}/${encodeURIComponent(id)}/redirect`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Get an SVG QR code for a short URL
|
|
110
|
+
* @param id ID of the short URL
|
|
111
|
+
*/
|
|
112
|
+
export function getShortUrlQrCodeSvg(id: string) {
|
|
113
|
+
return get(
|
|
114
|
+
`${apiEndpoint()}${PATH}/${encodeURIComponent(id)}/qr_code.svg`,
|
|
115
|
+
{ response_type: 'text' },
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get the URL for a PNG QR code for a short URL.
|
|
121
|
+
* Use this URL directly in an img tag or fetch it separately.
|
|
122
|
+
* @param id ID of the short URL
|
|
123
|
+
* @param options Options including size (between 72px and 512px)
|
|
124
|
+
*/
|
|
125
|
+
export function shortUrlQrCodePngUrl(
|
|
126
|
+
id: string,
|
|
127
|
+
options: PlaceShortUrlPngQrOptions = {},
|
|
128
|
+
): string {
|
|
129
|
+
const q = toQueryString(options);
|
|
130
|
+
return `${apiEndpoint()}${PATH}/${encodeURIComponent(id)}/qr_code.png${q ? '?' + q : ''}`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Get the URL for generating a QR code with user-defined content.
|
|
135
|
+
* @param options Options for QR code generation including content, format, and size
|
|
136
|
+
*/
|
|
137
|
+
export function qrCodeUrl(options: PlaceQrCodeOptions): string {
|
|
138
|
+
const { format = 'svg', ...params } = options;
|
|
139
|
+
const query_params = { ...params, format };
|
|
140
|
+
const q = toQueryString(query_params);
|
|
141
|
+
return `${apiEndpoint()}${PATH}/qr_code${q ? '?' + q : ''}`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Generate an SVG QR code with user-defined content.
|
|
146
|
+
* For PNG format, use qrCodeUrl() and fetch the URL directly.
|
|
147
|
+
* @param options Options for QR code generation including content and size
|
|
148
|
+
*/
|
|
149
|
+
export function generateQrCode(options: Omit<PlaceQrCodeOptions, 'format'>) {
|
|
150
|
+
const query_params = { ...options, format: 'svg' };
|
|
151
|
+
const q = toQueryString(query_params);
|
|
152
|
+
return get(`${apiEndpoint()}${PATH}/qr_code${q ? '?' + q : ''}`, {
|
|
153
|
+
response_type: 'text',
|
|
154
|
+
});
|
|
155
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PlaceResourceQueryOptions } from '../resources/interface';
|
|
2
|
+
|
|
3
|
+
/** Mapping of available query parameters for the short_url index endpoint */
|
|
4
|
+
export interface PlaceShortUrlQueryOptions extends PlaceResourceQueryOptions {}
|
|
5
|
+
|
|
6
|
+
/** Format options for QR code generation */
|
|
7
|
+
export type QrCodeFormat = 'svg' | 'png';
|
|
8
|
+
|
|
9
|
+
/** Options for generating a QR code with custom content */
|
|
10
|
+
export interface PlaceQrCodeOptions {
|
|
11
|
+
/** The contents of the QR code (required) */
|
|
12
|
+
content: string;
|
|
13
|
+
/** Identifier for the QR code (required) */
|
|
14
|
+
id: string;
|
|
15
|
+
/** File format of the response */
|
|
16
|
+
format?: QrCodeFormat;
|
|
17
|
+
/** Size of the QR code in pixels (between 72px and 512px) */
|
|
18
|
+
size?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Options for generating a PNG QR code for a short URL */
|
|
22
|
+
export interface PlaceShortUrlPngQrOptions {
|
|
23
|
+
/** Size of the QR code in pixels (between 72px and 512px) */
|
|
24
|
+
size?: number;
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class PlaceShortUrl {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly uri: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly user_id: string;
|
|
7
|
+
readonly user_email: string;
|
|
8
|
+
readonly user_name: string;
|
|
9
|
+
readonly redirect_count: number;
|
|
10
|
+
readonly enabled: boolean;
|
|
11
|
+
readonly valid_from: string;
|
|
12
|
+
readonly valid_until: string;
|
|
13
|
+
readonly authority_id: string;
|
|
14
|
+
readonly created_at: number;
|
|
15
|
+
readonly updated_at: number;
|
|
16
|
+
|
|
17
|
+
constructor(data: Partial<PlaceShortUrl>) {
|
|
18
|
+
this.id = data.id || '';
|
|
19
|
+
this.name = data.name || '';
|
|
20
|
+
this.uri = data.uri || '';
|
|
21
|
+
this.description = data.description || '';
|
|
22
|
+
this.user_id = data.user_id || '';
|
|
23
|
+
this.user_email = data.user_email || '';
|
|
24
|
+
this.user_name = data.user_name || '';
|
|
25
|
+
this.redirect_count = data.redirect_count || 0;
|
|
26
|
+
this.enabled = data.enabled ?? true;
|
|
27
|
+
this.valid_from = data.valid_from || '';
|
|
28
|
+
this.valid_until = data.valid_until || '';
|
|
29
|
+
this.authority_id = data.authority_id || '';
|
|
30
|
+
this.created_at = data.created_at || 0;
|
|
31
|
+
this.updated_at = data.updated_at || 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -6,8 +6,17 @@ export interface SignageMetrics {
|
|
|
6
6
|
media_counts: Record<string, number>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
/** Allowable query parameters for
|
|
9
|
+
/** Allowable query parameters for signage media index endpoint */
|
|
10
10
|
export interface SignageMediaQueryOptions extends PlaceResourceQueryOptions {
|
|
11
11
|
/** ID of the authority to filter the returned values on */
|
|
12
12
|
authority_id?: string;
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
/** Allowable query parameters for signage playlists index endpoint */
|
|
16
|
+
export interface SignagePlaylistQueryOptions extends PlaceResourceQueryOptions {}
|
|
17
|
+
|
|
18
|
+
/** Allowable query parameters for signage playlist media revisions endpoint */
|
|
19
|
+
export interface SignagePlaylistRevisionsOptions {
|
|
20
|
+
/** Maximum number of revisions to return */
|
|
21
|
+
limit?: number;
|
|
22
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { create, query, remove, show, update } from '../resources/functions';
|
|
2
|
+
import { PlaceStorage } from './storage.class';
|
|
3
|
+
import { PlaceStorageQueryOptions } from './interfaces';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
const PATH = 'storages';
|
|
9
|
+
|
|
10
|
+
/** Convert raw server data to a storage object */
|
|
11
|
+
function processStorage(item: Partial<PlaceStorage>) {
|
|
12
|
+
return new PlaceStorage(item);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Query the available storages
|
|
17
|
+
* @param query_params Query parameters to add to the request URL
|
|
18
|
+
*/
|
|
19
|
+
export function queryStorages(query_params: PlaceStorageQueryOptions = {}) {
|
|
20
|
+
return query({
|
|
21
|
+
query_params,
|
|
22
|
+
fn: processStorage,
|
|
23
|
+
path: PATH,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get the data for a storage
|
|
29
|
+
* @param id ID of the storage to retrieve
|
|
30
|
+
* @param query_params Query parameters to add to the request URL
|
|
31
|
+
*/
|
|
32
|
+
export function showStorage(
|
|
33
|
+
id: string,
|
|
34
|
+
query_params: Record<string, any> = {},
|
|
35
|
+
) {
|
|
36
|
+
return show({
|
|
37
|
+
id,
|
|
38
|
+
query_params,
|
|
39
|
+
fn: processStorage,
|
|
40
|
+
path: PATH,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Update a storage in the database
|
|
46
|
+
* @param id ID of the storage
|
|
47
|
+
* @param form_data New values for the storage
|
|
48
|
+
* @param method HTTP verb to use on request. Defaults to `patch`
|
|
49
|
+
*/
|
|
50
|
+
export function updateStorage(
|
|
51
|
+
id: string,
|
|
52
|
+
form_data: Partial<PlaceStorage>,
|
|
53
|
+
method: 'put' | 'patch' = 'patch',
|
|
54
|
+
) {
|
|
55
|
+
return update({
|
|
56
|
+
id,
|
|
57
|
+
form_data,
|
|
58
|
+
query_params: {},
|
|
59
|
+
method,
|
|
60
|
+
fn: processStorage,
|
|
61
|
+
path: PATH,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Add a new storage to the database
|
|
67
|
+
* @param form_data Storage data
|
|
68
|
+
*/
|
|
69
|
+
export function addStorage(form_data: Partial<PlaceStorage>) {
|
|
70
|
+
return create({
|
|
71
|
+
form_data,
|
|
72
|
+
query_params: {},
|
|
73
|
+
fn: processStorage,
|
|
74
|
+
path: PATH,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Remove a storage from the database
|
|
80
|
+
* @param id ID of the storage
|
|
81
|
+
* @param query_params Query parameters to add to the request URL
|
|
82
|
+
*/
|
|
83
|
+
export function removeStorage(
|
|
84
|
+
id: string,
|
|
85
|
+
query_params: Record<string, any> = {},
|
|
86
|
+
) {
|
|
87
|
+
return remove({ id, query_params, path: PATH });
|
|
88
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PlaceResourceQueryOptions } from '../resources/interface';
|
|
2
|
+
|
|
3
|
+
/** Mapping of available query parameters for the storages index endpoint */
|
|
4
|
+
export interface PlaceStorageQueryOptions extends PlaceResourceQueryOptions {
|
|
5
|
+
/** Return storages which are in the authority provided */
|
|
6
|
+
auth_id?: string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Storage type enumeration */
|
|
2
|
+
export type StorageType = 's3' | 'azure' | 'google';
|
|
3
|
+
|
|
4
|
+
export class PlaceStorage {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly storage_type: StorageType | null;
|
|
7
|
+
readonly bucket_name: string;
|
|
8
|
+
readonly region: string;
|
|
9
|
+
readonly access_key: string;
|
|
10
|
+
readonly access_secret: string;
|
|
11
|
+
readonly authority_id: string;
|
|
12
|
+
readonly endpoint: string;
|
|
13
|
+
readonly is_default: boolean;
|
|
14
|
+
readonly ext_filter: string[];
|
|
15
|
+
readonly mime_filter: string[];
|
|
16
|
+
readonly created_at: number;
|
|
17
|
+
readonly updated_at: number;
|
|
18
|
+
|
|
19
|
+
constructor(data: Partial<PlaceStorage>) {
|
|
20
|
+
this.id = data.id || '';
|
|
21
|
+
this.storage_type = data.storage_type || null;
|
|
22
|
+
this.bucket_name = data.bucket_name || '';
|
|
23
|
+
this.region = data.region || '';
|
|
24
|
+
this.access_key = data.access_key || '';
|
|
25
|
+
this.access_secret = data.access_secret || '';
|
|
26
|
+
this.authority_id = data.authority_id || '';
|
|
27
|
+
this.endpoint = data.endpoint || '';
|
|
28
|
+
this.is_default = data.is_default ?? false;
|
|
29
|
+
this.ext_filter = data.ext_filter || [];
|
|
30
|
+
this.mime_filter = data.mime_filter || [];
|
|
31
|
+
this.created_at = data.created_at || 0;
|
|
32
|
+
this.updated_at = data.updated_at || 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/systems/functions.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
+
import { apiEndpoint } from '../auth/functions';
|
|
2
3
|
import {
|
|
3
4
|
create,
|
|
4
5
|
query,
|
|
@@ -11,7 +12,17 @@ import { PlaceSettings } from '../settings/settings';
|
|
|
11
12
|
import { PlaceTrigger } from '../triggers/trigger';
|
|
12
13
|
import { HashMap } from '../utilities/types';
|
|
13
14
|
import { PlaceZone } from '../zones/zone';
|
|
14
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
PlaceModuleFunctionMap,
|
|
17
|
+
PlaceSystemControlOptions,
|
|
18
|
+
PlaceSystemMetadataOptions,
|
|
19
|
+
PlaceSystemShowOptions,
|
|
20
|
+
PlaceSystemsQueryOptions,
|
|
21
|
+
PlaceSystemsWithEmailsOptions,
|
|
22
|
+
PlaceSystemStartStopOptions,
|
|
23
|
+
PlaceSystemTriggerShowOptions,
|
|
24
|
+
PlaceSystemTriggersQueryOptions,
|
|
25
|
+
} from './interfaces';
|
|
15
26
|
import { PlaceSystem } from './system';
|
|
16
27
|
|
|
17
28
|
/**
|
|
@@ -33,11 +44,11 @@ export function querySystems(query_params: PlaceSystemsQueryOptions = {}) {
|
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
/**
|
|
36
|
-
* Query the available systems
|
|
47
|
+
* Query the available systems by email addresses
|
|
37
48
|
* @param query_params Query parameters to add the to request URL
|
|
38
49
|
*/
|
|
39
50
|
export function querySystemsWithEmails(
|
|
40
|
-
query_params:
|
|
51
|
+
query_params: PlaceSystemsWithEmailsOptions,
|
|
41
52
|
) {
|
|
42
53
|
return query({ query_params, fn: process, path: `${PATH}/with_emails` });
|
|
43
54
|
}
|
|
@@ -49,7 +60,7 @@ export function querySystemsWithEmails(
|
|
|
49
60
|
*/
|
|
50
61
|
export function showSystem(
|
|
51
62
|
id: string,
|
|
52
|
-
query_params:
|
|
63
|
+
query_params: PlaceSystemShowOptions = {},
|
|
53
64
|
) {
|
|
54
65
|
return show({ id, query_params, fn: process, path: PATH });
|
|
55
66
|
}
|
|
@@ -86,12 +97,11 @@ export function addSystem(form_data: Partial<PlaceSystem>) {
|
|
|
86
97
|
}
|
|
87
98
|
|
|
88
99
|
/**
|
|
89
|
-
* Remove
|
|
100
|
+
* Remove a system from the database
|
|
90
101
|
* @param id ID of the system
|
|
91
|
-
* @param query_params Query parameters to add the to request URL
|
|
92
102
|
*/
|
|
93
|
-
export function removeSystem(id: string
|
|
94
|
-
return remove({ id, query_params, path: PATH });
|
|
103
|
+
export function removeSystem(id: string) {
|
|
104
|
+
return remove({ id, query_params: {}, path: PATH });
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
/**
|
|
@@ -136,12 +146,16 @@ export function removeSystemModule(
|
|
|
136
146
|
/**
|
|
137
147
|
* Start the given system and clears any existing caches
|
|
138
148
|
* @param id System ID
|
|
149
|
+
* @param query_params Query parameters to add the to request URL
|
|
139
150
|
*/
|
|
140
|
-
export function startSystem(
|
|
151
|
+
export function startSystem(
|
|
152
|
+
id: string,
|
|
153
|
+
query_params: PlaceSystemStartStopOptions = {},
|
|
154
|
+
): Observable<void> {
|
|
141
155
|
return task<void>({
|
|
142
156
|
id,
|
|
143
157
|
task_name: 'start',
|
|
144
|
-
form_data:
|
|
158
|
+
form_data: query_params,
|
|
145
159
|
path: PATH,
|
|
146
160
|
});
|
|
147
161
|
}
|
|
@@ -149,11 +163,16 @@ export function startSystem(id: string): Observable<void> {
|
|
|
149
163
|
/**
|
|
150
164
|
* Stops all modules in the given system
|
|
151
165
|
* @param id System ID
|
|
166
|
+
* @param query_params Query parameters to add the to request URL
|
|
152
167
|
*/
|
|
153
|
-
export function stopSystem(
|
|
168
|
+
export function stopSystem(
|
|
169
|
+
id: string,
|
|
170
|
+
query_params: PlaceSystemStartStopOptions = {},
|
|
171
|
+
): Observable<void> {
|
|
154
172
|
return task<void>({
|
|
155
173
|
id,
|
|
156
174
|
task_name: 'stop',
|
|
175
|
+
form_data: query_params,
|
|
157
176
|
path: PATH,
|
|
158
177
|
});
|
|
159
178
|
}
|
|
@@ -282,10 +301,14 @@ export function listSystemZones(id: string) {
|
|
|
282
301
|
/**
|
|
283
302
|
* Get list of triggers for system
|
|
284
303
|
* @param id System ID
|
|
304
|
+
* @param query_params Query parameters to add the to request URL
|
|
285
305
|
*/
|
|
286
|
-
export function listSystemTriggers(
|
|
306
|
+
export function listSystemTriggers(
|
|
307
|
+
id: string,
|
|
308
|
+
query_params: PlaceSystemTriggersQueryOptions = {},
|
|
309
|
+
) {
|
|
287
310
|
return query({
|
|
288
|
-
query_params
|
|
311
|
+
query_params,
|
|
289
312
|
fn: (i: HashMap) => new PlaceTrigger(i),
|
|
290
313
|
path: `${PATH}/${id}/triggers`,
|
|
291
314
|
});
|
|
@@ -341,3 +364,80 @@ export function systemSettings(id: string): Observable<PlaceSettings[]> {
|
|
|
341
364
|
path: PATH,
|
|
342
365
|
});
|
|
343
366
|
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Get the websocket API endpoint URL for system control.
|
|
370
|
+
* @param query_params Query parameters to add to the URL
|
|
371
|
+
*/
|
|
372
|
+
export function systemControlUrl(query_params: PlaceSystemControlOptions = {}): string {
|
|
373
|
+
const endpoint = apiEndpoint();
|
|
374
|
+
const wsProtocol = endpoint.startsWith('https') ? 'wss:' : 'ws:';
|
|
375
|
+
const httpProtocol = endpoint.startsWith('https') ? 'https:' : 'http:';
|
|
376
|
+
let url = endpoint.replace(httpProtocol, wsProtocol) + `${PATH}/control`;
|
|
377
|
+
if (query_params.fixed_device) {
|
|
378
|
+
url += `?fixed_device=${encodeURIComponent(String(query_params.fixed_device))}`;
|
|
379
|
+
}
|
|
380
|
+
return url;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Get metadata for the system
|
|
385
|
+
* @param id System ID
|
|
386
|
+
* @param query_params Query parameters to add to the request
|
|
387
|
+
*/
|
|
388
|
+
export function systemMetadata(
|
|
389
|
+
id: string,
|
|
390
|
+
query_params: PlaceSystemMetadataOptions = {},
|
|
391
|
+
): Observable<HashMap> {
|
|
392
|
+
return task({
|
|
393
|
+
id,
|
|
394
|
+
task_name: 'metadata',
|
|
395
|
+
form_data: query_params,
|
|
396
|
+
method: 'get',
|
|
397
|
+
path: PATH,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Get a particular trigger instance
|
|
403
|
+
* @param sys_id System ID
|
|
404
|
+
* @param trig_id Trigger ID
|
|
405
|
+
* @param query_params Query parameters to add to the request
|
|
406
|
+
*/
|
|
407
|
+
export function showSystemTrigger(
|
|
408
|
+
sys_id: string,
|
|
409
|
+
trig_id: string,
|
|
410
|
+
query_params: PlaceSystemTriggerShowOptions = {},
|
|
411
|
+
): Observable<PlaceTrigger> {
|
|
412
|
+
return task({
|
|
413
|
+
id: sys_id,
|
|
414
|
+
task_name: `triggers/${encodeURIComponent(trig_id)}`,
|
|
415
|
+
form_data: query_params,
|
|
416
|
+
method: 'get',
|
|
417
|
+
callback: (item: Partial<PlaceTrigger>) => new PlaceTrigger(item),
|
|
418
|
+
path: PATH,
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Update the details of a trigger instance
|
|
424
|
+
* @param sys_id System ID
|
|
425
|
+
* @param trig_id Trigger ID
|
|
426
|
+
* @param data Values for trigger properties
|
|
427
|
+
* @param method HTTP verb to use on request. Defaults to `patch`
|
|
428
|
+
*/
|
|
429
|
+
export function updateSystemTrigger(
|
|
430
|
+
sys_id: string,
|
|
431
|
+
trig_id: string,
|
|
432
|
+
data: Partial<PlaceTrigger>,
|
|
433
|
+
method: 'put' | 'patch' = 'patch',
|
|
434
|
+
): Observable<PlaceTrigger> {
|
|
435
|
+
return task({
|
|
436
|
+
id: sys_id,
|
|
437
|
+
task_name: `triggers/${encodeURIComponent(trig_id)}`,
|
|
438
|
+
form_data: data,
|
|
439
|
+
method,
|
|
440
|
+
callback: (item: Partial<PlaceTrigger>) => new PlaceTrigger(item),
|
|
441
|
+
path: PATH,
|
|
442
|
+
});
|
|
443
|
+
}
|