motion-master-client 0.0.281 → 0.0.283
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/package.json +1 -1
- package/src/lib/fetch.d.ts +138 -53
- package/src/lib/fetch.js +175 -60
- package/src/lib/fetch.js.map +1 -1
- package/src/lib/integro-variant.d.ts +1 -1
- package/src/lib/integro-variant.js +13 -10
- package/src/lib/integro-variant.js.map +1 -1
- package/src/lib/motion-master-req-res-client.d.ts +35 -19
- package/src/lib/motion-master-req-res-client.js +126 -2
- package/src/lib/motion-master-req-res-client.js.map +1 -1
- package/src/lib/types.d.ts +47 -0
package/package.json
CHANGED
package/src/lib/fetch.d.ts
CHANGED
|
@@ -1,57 +1,101 @@
|
|
|
1
1
|
import { OblacDrivesRelease } from './oblac-drives-release';
|
|
2
|
+
import { PartConfigurationTable, FirmwareProductSupportedOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The brand ID for OBLAC Drives.
|
|
5
|
+
*/
|
|
2
6
|
export declare const oblacDrivesBrandId = "a7e925fa-57b7-4741-9126-0840a63cdb71";
|
|
7
|
+
/**
|
|
8
|
+
* The hostname of the current environment.
|
|
9
|
+
* Defaults to 'localhost' if running outside a browser (e.g., Node.js).
|
|
10
|
+
*/
|
|
3
11
|
export declare const hostname: string;
|
|
12
|
+
/**
|
|
13
|
+
* AWS API Gateway endpoint for OBLAC Drives services.
|
|
14
|
+
* S3 URI: s3://synapticon/oblac-drives/
|
|
15
|
+
*/
|
|
4
16
|
export declare const oblacDrivesApiGatewayOrigin = "https://pc27e3jixd.execute-api.us-east-1.amazonaws.com";
|
|
17
|
+
/**
|
|
18
|
+
* Base URL for the CDN hosting OBLAC Drives assets.
|
|
19
|
+
*/
|
|
5
20
|
export declare const cdnBasePath = "https://d9k1r8ajdoczx.cloudfront.net";
|
|
21
|
+
/**
|
|
22
|
+
* Hostname and port for the local cache server (OBLAC Drives Update Service).
|
|
23
|
+
*/
|
|
6
24
|
export declare const cacheHostname: string;
|
|
25
|
+
/**
|
|
26
|
+
* Base origin URL for the local cache server.
|
|
27
|
+
*/
|
|
7
28
|
export declare const cacheOrigin: string;
|
|
29
|
+
/**
|
|
30
|
+
* Base path for accessing cached S3 resources via the local cache server.
|
|
31
|
+
*/
|
|
8
32
|
export declare const cacheS3BasePath: string;
|
|
33
|
+
/**
|
|
34
|
+
* Base path for the local cache API.
|
|
35
|
+
*/
|
|
9
36
|
export declare const cacheApiBasePath: string;
|
|
10
37
|
/**
|
|
11
|
-
*
|
|
38
|
+
* Caches the specified object (file) locally, either on the box or within the native Electron app.
|
|
12
39
|
*
|
|
13
|
-
* @param path - The path
|
|
14
|
-
* @param body - The object (file) to cache.
|
|
15
|
-
* @returns A promise that resolves when
|
|
40
|
+
* @param path - The destination path where the object should be cached.
|
|
41
|
+
* @param body - The object (file) data to cache, provided as a Blob.
|
|
42
|
+
* @returns A promise that resolves when caching completes (only resolves in Electron;
|
|
43
|
+
* for other environments, caching is attempted but not awaited).
|
|
16
44
|
*/
|
|
17
45
|
export declare function cacheOnBox(path: string, body: Blob): Promise<void>;
|
|
18
46
|
/**
|
|
19
|
-
*
|
|
47
|
+
* Compares two OBLAC Drives bundle filenames by their embedded version strings,
|
|
48
|
+
* sorting them in descending order based on version.
|
|
49
|
+
*
|
|
50
|
+
* The version is extracted from the filename suffix matching the pattern `_<version>.odbx`.
|
|
51
|
+
*
|
|
52
|
+
* @param a - The first bundle filename to compare.
|
|
53
|
+
* @param b - The second bundle filename to compare.
|
|
54
|
+
* @returns A negative number if `b` has a newer version than `a`, positive if `a` is newer,
|
|
55
|
+
* or 0 if they are equal or the version cannot be determined.
|
|
20
56
|
*/
|
|
21
57
|
export declare function compareBundlesByVersionDesc(a: string, b: string): number;
|
|
22
58
|
/**
|
|
23
|
-
*
|
|
59
|
+
* Constructs a full CDN URL by appending the given path to the base CDN URL.
|
|
24
60
|
*
|
|
25
|
-
* @param path - The path to the object (file)
|
|
26
|
-
* @returns The
|
|
61
|
+
* @param path - The relative path to the object (file) on the CDN.
|
|
62
|
+
* @returns The complete URL pointing to the resource on the CDN.
|
|
27
63
|
*/
|
|
28
64
|
export declare function makeCdnUrl(path: string): string;
|
|
29
65
|
/**
|
|
30
|
-
*
|
|
66
|
+
* Retrieves a previously cached object (file) from the OBLAC box or native app cache.
|
|
31
67
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
68
|
+
* When running in an Electron app, it uses the native API to get the cached file,
|
|
69
|
+
* otherwise it fetches from a local cache HTTP path.
|
|
70
|
+
*
|
|
71
|
+
* @param path - The path to the cached object within the box or app cache.
|
|
72
|
+
* @param resolveTo - The format to resolve the fetched object to: `'blob'`, `'json'`, or `'text'`.
|
|
73
|
+
* @returns A promise that resolves to the cached object in the specified format,
|
|
74
|
+
* or `undefined` if the file could not be retrieved.
|
|
35
75
|
*/
|
|
36
76
|
export declare function fetchFromBox(path: string, resolveTo: 'blob' | 'json' | 'text'): Promise<any>;
|
|
37
77
|
/**
|
|
38
|
-
*
|
|
78
|
+
* Fetches an object (file) from S3, resolves it to the specified format (JSON, text, or binary),
|
|
79
|
+
* and optionally caches it locally (on the box or within the native app).
|
|
80
|
+
*
|
|
81
|
+
* **Note:** Cached data is stored under the `/synapticon/oblac-drives/` prefix to align with the bundle's cache location.
|
|
39
82
|
*
|
|
40
|
-
*
|
|
83
|
+
* If offline or if the fetch fails (including HTTP errors), the function falls back to retrieving the cached version.
|
|
41
84
|
*
|
|
42
|
-
* @param path - The path to the object
|
|
43
|
-
* @param resolveTo - The
|
|
44
|
-
* @param cache -
|
|
45
|
-
* @returns
|
|
85
|
+
* @param path - The S3 path to the object.
|
|
86
|
+
* @param resolveTo - The desired response format: `'blob'`, `'json'`, or `'text'`.
|
|
87
|
+
* @param cache - Whether to cache the fetched object locally. Defaults to false if not specified.
|
|
88
|
+
* @returns A promise that resolves to the fetched object in the specified format.
|
|
46
89
|
*/
|
|
47
90
|
export declare function fetchAndResolve(path: string, resolveTo: 'blob' | 'json' | 'text', cache: boolean): Promise<any>;
|
|
48
91
|
/**
|
|
49
|
-
*
|
|
92
|
+
* Fetches the brand JSON data, then retrieves and adds the logo and Bootstrap theme URLs to the object.
|
|
50
93
|
*
|
|
51
|
-
* @param brandJsonUrl - The URL of the brand JSON file.
|
|
52
|
-
* @param themeVersion - The version of the Bootstrap theme.
|
|
53
|
-
* @param cache -
|
|
54
|
-
* @returns
|
|
94
|
+
* @param brandJsonUrl - The URL of the brand JSON file. Defaults to `'brand.json'`.
|
|
95
|
+
* @param themeVersion - The version number of the Bootstrap theme to fetch. Defaults to `1`.
|
|
96
|
+
* @param cache - If `true`, caches the fetched resources locally. Defaults to `true`.
|
|
97
|
+
* @returns A promise that resolves to the brand object extended with `logo` and `bootstrap` CSS content,
|
|
98
|
+
* or `undefined` if fetching or parsing fails.
|
|
55
99
|
*/
|
|
56
100
|
export declare function fetchBrandData(brandJsonUrl?: string, themeVersion?: number, cache?: boolean): Promise<{
|
|
57
101
|
bootstrap: string;
|
|
@@ -60,60 +104,101 @@ export declare function fetchBrandData(brandJsonUrl?: string, themeVersion?: num
|
|
|
60
104
|
name: string;
|
|
61
105
|
} | undefined>;
|
|
62
106
|
/**
|
|
63
|
-
*
|
|
107
|
+
* Fetches the ESI file for a specified brand and firmware version.
|
|
64
108
|
*
|
|
65
|
-
* @param brandId - The
|
|
66
|
-
* @param version - The firmware version.
|
|
67
|
-
* @param cache -
|
|
68
|
-
* @returns
|
|
109
|
+
* @param brandId - The unique identifier of the brand.
|
|
110
|
+
* @param version - The firmware version to fetch the ESI file for.
|
|
111
|
+
* @param cache - If `true`, caches the fetched ESI file locally. Defaults to `true`.
|
|
112
|
+
* @returns A promise that resolves to the ESI file content as a string.
|
|
69
113
|
*/
|
|
70
114
|
export declare function fetchEsi(brandId: string, version: string, cache?: boolean): Promise<string>;
|
|
71
115
|
/**
|
|
72
|
-
*
|
|
116
|
+
* Fetches the content of a firmware package as a Blob.
|
|
73
117
|
*
|
|
74
|
-
* @param brandId - The
|
|
75
|
-
* @param filename - The name of the package file.
|
|
76
|
-
* @param cache -
|
|
77
|
-
* @returns
|
|
118
|
+
* @param brandId - The unique identifier of the brand.
|
|
119
|
+
* @param filename - The name of the firmware package file.
|
|
120
|
+
* @param cache - If `true`, caches the fetched package locally. Defaults to `true`.
|
|
121
|
+
* @returns A promise that resolves to the firmware package content as a Blob.
|
|
78
122
|
*/
|
|
79
123
|
export declare function fetchFirmwarePackage(brandId: string, filename: string, cache?: boolean): Promise<Blob>;
|
|
80
124
|
/**
|
|
81
|
-
*
|
|
125
|
+
* Fetches the SVG product image by product ID for the specified brand.
|
|
82
126
|
*
|
|
83
|
-
* @param brandId - The
|
|
84
|
-
* @param productId - The ID of the product.
|
|
85
|
-
* @param cache -
|
|
86
|
-
* @returns
|
|
127
|
+
* @param brandId - The unique identifier of the brand.
|
|
128
|
+
* @param productId - The ID of the product (number or string).
|
|
129
|
+
* @param cache - If `true`, caches the fetched image locally. Defaults to `true`.
|
|
130
|
+
* @returns A promise that resolves to the product image as an SVG string.
|
|
87
131
|
*/
|
|
88
132
|
export declare function fetchProductImage(brandId: string, productId: number | string, cache?: boolean): Promise<string>;
|
|
89
133
|
/**
|
|
90
|
-
*
|
|
134
|
+
* Fetches the firmware changelog in Markdown format for a specified minor version.
|
|
91
135
|
*
|
|
92
|
-
* @param brandId - The
|
|
93
|
-
* @param minorVersion - The minor version
|
|
94
|
-
* @param cache -
|
|
95
|
-
* @returns
|
|
136
|
+
* @param brandId - The unique identifier of the brand.
|
|
137
|
+
* @param minorVersion - The minor firmware version to fetch the changelog for.
|
|
138
|
+
* @param cache - If `true`, caches the fetched changelog locally. Defaults to `true`.
|
|
139
|
+
* @returns A promise that resolves to the changelog content as a Markdown string.
|
|
140
|
+
* Rejects if the fetched content is invalid or not found.
|
|
96
141
|
*/
|
|
97
142
|
export declare function fetchFirmwareChangelog(brandId: string, minorVersion: string, cache?: boolean): Promise<string>;
|
|
98
143
|
/**
|
|
99
|
-
*
|
|
144
|
+
* Fetches both production and development OBLAC Drives releases.
|
|
100
145
|
*
|
|
101
|
-
* @param cache -
|
|
102
|
-
* @returns
|
|
146
|
+
* @param cache - If `true`, caches the fetched data locally. Defaults to `true`.
|
|
147
|
+
* @returns A promise that resolves to a tuple containing two arrays:
|
|
148
|
+
* - The first array holds production releases (`OblacDrivesRelease[]`).
|
|
149
|
+
* - The second array holds development releases (`OblacDrivesRelease[]`).
|
|
103
150
|
*/
|
|
104
151
|
export declare function fetchOblacDrivesReleases(cache?: boolean): Promise<[OblacDrivesRelease[], OblacDrivesRelease[]]>;
|
|
105
152
|
/**
|
|
106
|
-
*
|
|
153
|
+
* Lists firmware package filenames for a given brand.
|
|
107
154
|
*
|
|
108
|
-
* @param brandId - The
|
|
109
|
-
* @param latestMinorVersionsOnly -
|
|
110
|
-
* @param cache -
|
|
111
|
-
* @returns
|
|
155
|
+
* @param brandId - The unique identifier of the brand.
|
|
156
|
+
* @param latestMinorVersionsOnly - If `true`, only includes the latest minor versions; otherwise includes all versions. Defaults to `false`.
|
|
157
|
+
* @param cache - If `true`, caches the fetched data locally. Defaults to `true`.
|
|
158
|
+
* @returns A promise that resolves to an array of firmware package filenames.
|
|
112
159
|
*/
|
|
113
160
|
export declare function listFirmwarePackages(brandId: string, latestMinorVersionsOnly?: boolean, cache?: boolean): Promise<string[]>;
|
|
114
161
|
/**
|
|
115
|
-
*
|
|
162
|
+
* Retrieves a list of available Oblac Drives Update Service versions.
|
|
163
|
+
*
|
|
164
|
+
* Waits for the online state to initialize, then fetches the version list
|
|
165
|
+
* either from the live API or a local cache depending on connectivity.
|
|
116
166
|
*
|
|
117
|
-
* @returns
|
|
167
|
+
* @returns A promise that resolves to an array of version strings.
|
|
118
168
|
*/
|
|
119
169
|
export declare function listOblacDrivesUpdateServiceVersions(): Promise<string[]>;
|
|
170
|
+
/**
|
|
171
|
+
* Retrieves the list of supported encoder configuration types from a JSON resource hosted on AWS S3.
|
|
172
|
+
*
|
|
173
|
+
* @returns A promise that resolves to a `FirmwareProductSupportedOptions` object
|
|
174
|
+
* containing the supported encoder configuration types.
|
|
175
|
+
*/
|
|
176
|
+
export declare function fetchSupportedEncoderConfigurationTypes(): Promise<FirmwareProductSupportedOptions>;
|
|
177
|
+
/**
|
|
178
|
+
* Retrieves the list of supported analog inputs from a JSON resource hosted on AWS S3.
|
|
179
|
+
*
|
|
180
|
+
* @returns A promise that resolves to a `FirmwareProductSupportedOptions` object
|
|
181
|
+
* containing the supported analog inputs.
|
|
182
|
+
*/
|
|
183
|
+
export declare function fetchSupportedAis(): Promise<FirmwareProductSupportedOptions>;
|
|
184
|
+
/**
|
|
185
|
+
* Retrieves the list of supported digital input/output from a JSON resource hosted on AWS S3.
|
|
186
|
+
*
|
|
187
|
+
* @returns A promise that resolves to a `FirmwareProductSupportedOptions` object
|
|
188
|
+
* containing the supported digital input/output.
|
|
189
|
+
*/
|
|
190
|
+
export declare function fetchSupportedDios(): Promise<FirmwareProductSupportedOptions>;
|
|
191
|
+
/**
|
|
192
|
+
* Retrieves the motor configuration data from a JSON resource hosted on AWS S3.
|
|
193
|
+
*
|
|
194
|
+
* @returns A promise that resolves to a `PartConfigurationTable` object
|
|
195
|
+
* containing available motor configurations.
|
|
196
|
+
*/
|
|
197
|
+
export declare function fetchMotorConfigurations(): Promise<PartConfigurationTable>;
|
|
198
|
+
/**
|
|
199
|
+
* Retrieves the encoder configuration data from a JSON resource hosted on AWS S3.
|
|
200
|
+
*
|
|
201
|
+
* @returns A promise that resolves to a `PartConfigurationTable` object
|
|
202
|
+
* containing available encoder configurations.
|
|
203
|
+
*/
|
|
204
|
+
export declare function fetchEncoderConfigurations(firmwareMajorVersion: number): Promise<PartConfigurationTable>;
|
package/src/lib/fetch.js
CHANGED
|
@@ -1,29 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listOblacDrivesUpdateServiceVersions = exports.listFirmwarePackages = exports.fetchOblacDrivesReleases = exports.fetchFirmwareChangelog = exports.fetchProductImage = exports.fetchFirmwarePackage = exports.fetchEsi = exports.fetchBrandData = exports.fetchAndResolve = exports.fetchFromBox = exports.makeCdnUrl = exports.compareBundlesByVersionDesc = exports.cacheOnBox = exports.cacheApiBasePath = exports.cacheS3BasePath = exports.cacheOrigin = exports.cacheHostname = exports.cdnBasePath = exports.oblacDrivesApiGatewayOrigin = exports.hostname = exports.oblacDrivesBrandId = void 0;
|
|
3
|
+
exports.fetchEncoderConfigurations = exports.fetchMotorConfigurations = exports.fetchSupportedDios = exports.fetchSupportedAis = exports.fetchSupportedEncoderConfigurationTypes = exports.listOblacDrivesUpdateServiceVersions = exports.listFirmwarePackages = exports.fetchOblacDrivesReleases = exports.fetchFirmwareChangelog = exports.fetchProductImage = exports.fetchFirmwarePackage = exports.fetchEsi = exports.fetchBrandData = exports.fetchAndResolve = exports.fetchFromBox = exports.makeCdnUrl = exports.compareBundlesByVersionDesc = exports.cacheOnBox = exports.cacheApiBasePath = exports.cacheS3BasePath = exports.cacheOrigin = exports.cacheHostname = exports.cdnBasePath = exports.oblacDrivesApiGatewayOrigin = exports.hostname = exports.oblacDrivesBrandId = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const rxjs_1 = require("rxjs");
|
|
6
6
|
const online_1 = require("./online");
|
|
7
7
|
const util_1 = require("./util");
|
|
8
8
|
const semver_1 = require("semver");
|
|
9
9
|
/* eslint-disable max-len */
|
|
10
|
+
/**
|
|
11
|
+
* The brand ID for OBLAC Drives.
|
|
12
|
+
*/
|
|
10
13
|
exports.oblacDrivesBrandId = 'a7e925fa-57b7-4741-9126-0840a63cdb71';
|
|
14
|
+
/**
|
|
15
|
+
* The hostname of the current environment.
|
|
16
|
+
* Defaults to 'localhost' if running outside a browser (e.g., Node.js).
|
|
17
|
+
*/
|
|
11
18
|
// @ts-ignore
|
|
12
19
|
exports.hostname = typeof window === 'undefined' ? 'localhost' : window.location.hostname;
|
|
13
|
-
|
|
20
|
+
/**
|
|
21
|
+
* AWS API Gateway endpoint for OBLAC Drives services.
|
|
22
|
+
* S3 URI: s3://synapticon/oblac-drives/
|
|
23
|
+
*/
|
|
14
24
|
exports.oblacDrivesApiGatewayOrigin = 'https://pc27e3jixd.execute-api.us-east-1.amazonaws.com';
|
|
25
|
+
/**
|
|
26
|
+
* Base URL for the CDN hosting OBLAC Drives assets.
|
|
27
|
+
*/
|
|
15
28
|
exports.cdnBasePath = 'https://d9k1r8ajdoczx.cloudfront.net';
|
|
16
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Hostname and port for the local cache server (OBLAC Drives Update Service).
|
|
31
|
+
*/
|
|
17
32
|
exports.cacheHostname = `${exports.hostname}:64000`;
|
|
33
|
+
/**
|
|
34
|
+
* Base origin URL for the local cache server.
|
|
35
|
+
*/
|
|
18
36
|
exports.cacheOrigin = `http://${exports.cacheHostname}`;
|
|
37
|
+
/**
|
|
38
|
+
* Base path for accessing cached S3 resources via the local cache server.
|
|
39
|
+
*/
|
|
19
40
|
exports.cacheS3BasePath = `${exports.cacheOrigin}/s3`;
|
|
41
|
+
/**
|
|
42
|
+
* Base path for the local cache API.
|
|
43
|
+
*/
|
|
20
44
|
exports.cacheApiBasePath = `${exports.cacheOrigin}/api`;
|
|
21
45
|
/**
|
|
22
|
-
*
|
|
46
|
+
* Caches the specified object (file) locally, either on the box or within the native Electron app.
|
|
23
47
|
*
|
|
24
|
-
* @param path - The path
|
|
25
|
-
* @param body - The object (file) to cache.
|
|
26
|
-
* @returns A promise that resolves when
|
|
48
|
+
* @param path - The destination path where the object should be cached.
|
|
49
|
+
* @param body - The object (file) data to cache, provided as a Blob.
|
|
50
|
+
* @returns A promise that resolves when caching completes (only resolves in Electron;
|
|
51
|
+
* for other environments, caching is attempted but not awaited).
|
|
27
52
|
*/
|
|
28
53
|
function cacheOnBox(path, body) {
|
|
29
54
|
var _a;
|
|
@@ -43,7 +68,15 @@ function cacheOnBox(path, body) {
|
|
|
43
68
|
}
|
|
44
69
|
exports.cacheOnBox = cacheOnBox;
|
|
45
70
|
/**
|
|
46
|
-
*
|
|
71
|
+
* Compares two OBLAC Drives bundle filenames by their embedded version strings,
|
|
72
|
+
* sorting them in descending order based on version.
|
|
73
|
+
*
|
|
74
|
+
* The version is extracted from the filename suffix matching the pattern `_<version>.odbx`.
|
|
75
|
+
*
|
|
76
|
+
* @param a - The first bundle filename to compare.
|
|
77
|
+
* @param b - The second bundle filename to compare.
|
|
78
|
+
* @returns A negative number if `b` has a newer version than `a`, positive if `a` is newer,
|
|
79
|
+
* or 0 if they are equal or the version cannot be determined.
|
|
47
80
|
*/
|
|
48
81
|
function compareBundlesByVersionDesc(a, b) {
|
|
49
82
|
const re = /_(.*).odbx$/;
|
|
@@ -55,17 +88,20 @@ function compareBundlesByVersionDesc(a, b) {
|
|
|
55
88
|
return 0;
|
|
56
89
|
}
|
|
57
90
|
exports.compareBundlesByVersionDesc = compareBundlesByVersionDesc;
|
|
91
|
+
/**
|
|
92
|
+
* Maps resolution types to their corresponding MIME types used for data conversion.
|
|
93
|
+
*/
|
|
58
94
|
const resolveToMimeType = {
|
|
59
95
|
blob: 'application/octet-stream',
|
|
60
96
|
json: 'application/json',
|
|
61
97
|
text: 'text/plain',
|
|
62
98
|
};
|
|
63
99
|
/**
|
|
64
|
-
*
|
|
100
|
+
* Converts a base64-encoded string into the specified data type: Blob, JSON, or text.
|
|
65
101
|
*
|
|
66
|
-
* @param base64 - The base64 string to convert.
|
|
67
|
-
* @param resolveTo - The
|
|
68
|
-
* @returns
|
|
102
|
+
* @param base64 - The base64-encoded string to convert.
|
|
103
|
+
* @param resolveTo - The desired output format: `'blob'`, `'json'`, or `'text'`.
|
|
104
|
+
* @returns A promise that resolves to the decoded data in the specified format.
|
|
69
105
|
*/
|
|
70
106
|
function base64ToData(base64, resolveTo) {
|
|
71
107
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -73,21 +109,25 @@ function base64ToData(base64, resolveTo) {
|
|
|
73
109
|
});
|
|
74
110
|
}
|
|
75
111
|
/**
|
|
76
|
-
*
|
|
112
|
+
* Constructs a full CDN URL by appending the given path to the base CDN URL.
|
|
77
113
|
*
|
|
78
|
-
* @param path - The path to the object (file)
|
|
79
|
-
* @returns The
|
|
114
|
+
* @param path - The relative path to the object (file) on the CDN.
|
|
115
|
+
* @returns The complete URL pointing to the resource on the CDN.
|
|
80
116
|
*/
|
|
81
117
|
function makeCdnUrl(path) {
|
|
82
118
|
return `${exports.cdnBasePath}${path}`;
|
|
83
119
|
}
|
|
84
120
|
exports.makeCdnUrl = makeCdnUrl;
|
|
85
121
|
/**
|
|
86
|
-
*
|
|
122
|
+
* Retrieves a previously cached object (file) from the OBLAC box or native app cache.
|
|
123
|
+
*
|
|
124
|
+
* When running in an Electron app, it uses the native API to get the cached file,
|
|
125
|
+
* otherwise it fetches from a local cache HTTP path.
|
|
87
126
|
*
|
|
88
|
-
* @param path - The path to the object
|
|
89
|
-
* @param resolveTo
|
|
90
|
-
* @returns
|
|
127
|
+
* @param path - The path to the cached object within the box or app cache.
|
|
128
|
+
* @param resolveTo - The format to resolve the fetched object to: `'blob'`, `'json'`, or `'text'`.
|
|
129
|
+
* @returns A promise that resolves to the cached object in the specified format,
|
|
130
|
+
* or `undefined` if the file could not be retrieved.
|
|
91
131
|
*/
|
|
92
132
|
function fetchFromBox(path, resolveTo) {
|
|
93
133
|
var _a;
|
|
@@ -107,14 +147,17 @@ function fetchFromBox(path, resolveTo) {
|
|
|
107
147
|
}
|
|
108
148
|
exports.fetchFromBox = fetchFromBox;
|
|
109
149
|
/**
|
|
110
|
-
*
|
|
150
|
+
* Fetches an object (file) from S3, resolves it to the specified format (JSON, text, or binary),
|
|
151
|
+
* and optionally caches it locally (on the box or within the native app).
|
|
111
152
|
*
|
|
112
|
-
* **
|
|
153
|
+
* **Note:** Cached data is stored under the `/synapticon/oblac-drives/` prefix to align with the bundle's cache location.
|
|
113
154
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* @param
|
|
117
|
-
* @
|
|
155
|
+
* If offline or if the fetch fails (including HTTP errors), the function falls back to retrieving the cached version.
|
|
156
|
+
*
|
|
157
|
+
* @param path - The S3 path to the object.
|
|
158
|
+
* @param resolveTo - The desired response format: `'blob'`, `'json'`, or `'text'`.
|
|
159
|
+
* @param cache - Whether to cache the fetched object locally. Defaults to false if not specified.
|
|
160
|
+
* @returns A promise that resolves to the fetched object in the specified format.
|
|
118
161
|
*/
|
|
119
162
|
function fetchAndResolve(path, resolveTo, cache) {
|
|
120
163
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -144,12 +187,13 @@ function fetchAndResolve(path, resolveTo, cache) {
|
|
|
144
187
|
}
|
|
145
188
|
exports.fetchAndResolve = fetchAndResolve;
|
|
146
189
|
/**
|
|
147
|
-
*
|
|
190
|
+
* Fetches the brand JSON data, then retrieves and adds the logo and Bootstrap theme URLs to the object.
|
|
148
191
|
*
|
|
149
|
-
* @param brandJsonUrl - The URL of the brand JSON file.
|
|
150
|
-
* @param themeVersion - The version of the Bootstrap theme.
|
|
151
|
-
* @param cache -
|
|
152
|
-
* @returns
|
|
192
|
+
* @param brandJsonUrl - The URL of the brand JSON file. Defaults to `'brand.json'`.
|
|
193
|
+
* @param themeVersion - The version number of the Bootstrap theme to fetch. Defaults to `1`.
|
|
194
|
+
* @param cache - If `true`, caches the fetched resources locally. Defaults to `true`.
|
|
195
|
+
* @returns A promise that resolves to the brand object extended with `logo` and `bootstrap` CSS content,
|
|
196
|
+
* or `undefined` if fetching or parsing fails.
|
|
153
197
|
*/
|
|
154
198
|
function fetchBrandData(brandJsonUrl = 'brand.json', themeVersion = 1, cache = true) {
|
|
155
199
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -170,12 +214,12 @@ function fetchBrandData(brandJsonUrl = 'brand.json', themeVersion = 1, cache = t
|
|
|
170
214
|
}
|
|
171
215
|
exports.fetchBrandData = fetchBrandData;
|
|
172
216
|
/**
|
|
173
|
-
*
|
|
217
|
+
* Fetches the ESI file for a specified brand and firmware version.
|
|
174
218
|
*
|
|
175
|
-
* @param brandId - The
|
|
176
|
-
* @param version - The firmware version.
|
|
177
|
-
* @param cache -
|
|
178
|
-
* @returns
|
|
219
|
+
* @param brandId - The unique identifier of the brand.
|
|
220
|
+
* @param version - The firmware version to fetch the ESI file for.
|
|
221
|
+
* @param cache - If `true`, caches the fetched ESI file locally. Defaults to `true`.
|
|
222
|
+
* @returns A promise that resolves to the ESI file content as a string.
|
|
179
223
|
*/
|
|
180
224
|
function fetchEsi(brandId, version, cache = true) {
|
|
181
225
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -186,12 +230,12 @@ function fetchEsi(brandId, version, cache = true) {
|
|
|
186
230
|
}
|
|
187
231
|
exports.fetchEsi = fetchEsi;
|
|
188
232
|
/**
|
|
189
|
-
*
|
|
233
|
+
* Fetches the content of a firmware package as a Blob.
|
|
190
234
|
*
|
|
191
|
-
* @param brandId - The
|
|
192
|
-
* @param filename - The name of the package file.
|
|
193
|
-
* @param cache -
|
|
194
|
-
* @returns
|
|
235
|
+
* @param brandId - The unique identifier of the brand.
|
|
236
|
+
* @param filename - The name of the firmware package file.
|
|
237
|
+
* @param cache - If `true`, caches the fetched package locally. Defaults to `true`.
|
|
238
|
+
* @returns A promise that resolves to the firmware package content as a Blob.
|
|
195
239
|
*/
|
|
196
240
|
function fetchFirmwarePackage(brandId, filename, cache = true) {
|
|
197
241
|
filename = encodeURIComponent(filename);
|
|
@@ -200,12 +244,12 @@ function fetchFirmwarePackage(brandId, filename, cache = true) {
|
|
|
200
244
|
}
|
|
201
245
|
exports.fetchFirmwarePackage = fetchFirmwarePackage;
|
|
202
246
|
/**
|
|
203
|
-
*
|
|
247
|
+
* Fetches the SVG product image by product ID for the specified brand.
|
|
204
248
|
*
|
|
205
|
-
* @param brandId - The
|
|
206
|
-
* @param productId - The ID of the product.
|
|
207
|
-
* @param cache -
|
|
208
|
-
* @returns
|
|
249
|
+
* @param brandId - The unique identifier of the brand.
|
|
250
|
+
* @param productId - The ID of the product (number or string).
|
|
251
|
+
* @param cache - If `true`, caches the fetched image locally. Defaults to `true`.
|
|
252
|
+
* @returns A promise that resolves to the product image as an SVG string.
|
|
209
253
|
*/
|
|
210
254
|
function fetchProductImage(brandId, productId, cache = true) {
|
|
211
255
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -216,12 +260,13 @@ function fetchProductImage(brandId, productId, cache = true) {
|
|
|
216
260
|
}
|
|
217
261
|
exports.fetchProductImage = fetchProductImage;
|
|
218
262
|
/**
|
|
219
|
-
*
|
|
263
|
+
* Fetches the firmware changelog in Markdown format for a specified minor version.
|
|
220
264
|
*
|
|
221
|
-
* @param brandId - The
|
|
222
|
-
* @param minorVersion - The minor version
|
|
223
|
-
* @param cache -
|
|
224
|
-
* @returns
|
|
265
|
+
* @param brandId - The unique identifier of the brand.
|
|
266
|
+
* @param minorVersion - The minor firmware version to fetch the changelog for.
|
|
267
|
+
* @param cache - If `true`, caches the fetched changelog locally. Defaults to `true`.
|
|
268
|
+
* @returns A promise that resolves to the changelog content as a Markdown string.
|
|
269
|
+
* Rejects if the fetched content is invalid or not found.
|
|
225
270
|
*/
|
|
226
271
|
function fetchFirmwareChangelog(brandId, minorVersion, cache = true) {
|
|
227
272
|
const path = `/brands/${brandId}/changelogs/v${encodeURIComponent(minorVersion)}.md`;
|
|
@@ -239,10 +284,12 @@ function fetchFirmwareChangelog(brandId, minorVersion, cache = true) {
|
|
|
239
284
|
}
|
|
240
285
|
exports.fetchFirmwareChangelog = fetchFirmwareChangelog;
|
|
241
286
|
/**
|
|
242
|
-
*
|
|
287
|
+
* Fetches both production and development OBLAC Drives releases.
|
|
243
288
|
*
|
|
244
|
-
* @param cache -
|
|
245
|
-
* @returns
|
|
289
|
+
* @param cache - If `true`, caches the fetched data locally. Defaults to `true`.
|
|
290
|
+
* @returns A promise that resolves to a tuple containing two arrays:
|
|
291
|
+
* - The first array holds production releases (`OblacDrivesRelease[]`).
|
|
292
|
+
* - The second array holds development releases (`OblacDrivesRelease[]`).
|
|
246
293
|
*/
|
|
247
294
|
function fetchOblacDrivesReleases(cache = true) {
|
|
248
295
|
return Promise.all([
|
|
@@ -252,12 +299,12 @@ function fetchOblacDrivesReleases(cache = true) {
|
|
|
252
299
|
}
|
|
253
300
|
exports.fetchOblacDrivesReleases = fetchOblacDrivesReleases;
|
|
254
301
|
/**
|
|
255
|
-
*
|
|
302
|
+
* Lists firmware package filenames for a given brand.
|
|
256
303
|
*
|
|
257
|
-
* @param brandId - The
|
|
258
|
-
* @param latestMinorVersionsOnly -
|
|
259
|
-
* @param cache -
|
|
260
|
-
* @returns
|
|
304
|
+
* @param brandId - The unique identifier of the brand.
|
|
305
|
+
* @param latestMinorVersionsOnly - If `true`, only includes the latest minor versions; otherwise includes all versions. Defaults to `false`.
|
|
306
|
+
* @param cache - If `true`, caches the fetched data locally. Defaults to `true`.
|
|
307
|
+
* @returns A promise that resolves to an array of firmware package filenames.
|
|
261
308
|
*/
|
|
262
309
|
function listFirmwarePackages(brandId, latestMinorVersionsOnly = false, cache = true) {
|
|
263
310
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -267,9 +314,12 @@ function listFirmwarePackages(brandId, latestMinorVersionsOnly = false, cache =
|
|
|
267
314
|
}
|
|
268
315
|
exports.listFirmwarePackages = listFirmwarePackages;
|
|
269
316
|
/**
|
|
270
|
-
*
|
|
317
|
+
* Retrieves a list of available Oblac Drives Update Service versions.
|
|
318
|
+
*
|
|
319
|
+
* Waits for the online state to initialize, then fetches the version list
|
|
320
|
+
* either from the live API or a local cache depending on connectivity.
|
|
271
321
|
*
|
|
272
|
-
* @returns
|
|
322
|
+
* @returns A promise that resolves to an array of version strings.
|
|
273
323
|
*/
|
|
274
324
|
function listOblacDrivesUpdateServiceVersions() {
|
|
275
325
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -282,4 +332,69 @@ function listOblacDrivesUpdateServiceVersions() {
|
|
|
282
332
|
});
|
|
283
333
|
}
|
|
284
334
|
exports.listOblacDrivesUpdateServiceVersions = listOblacDrivesUpdateServiceVersions;
|
|
335
|
+
/**
|
|
336
|
+
* Retrieves the list of supported encoder configuration types from a JSON resource hosted on AWS S3.
|
|
337
|
+
*
|
|
338
|
+
* @returns A promise that resolves to a `FirmwareProductSupportedOptions` object
|
|
339
|
+
* containing the supported encoder configuration types.
|
|
340
|
+
*/
|
|
341
|
+
function fetchSupportedEncoderConfigurationTypes() {
|
|
342
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
343
|
+
const path = `/supported-encoder-configuration-types.json`;
|
|
344
|
+
return yield fetchAndResolve(path, 'json', true);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
exports.fetchSupportedEncoderConfigurationTypes = fetchSupportedEncoderConfigurationTypes;
|
|
348
|
+
/**
|
|
349
|
+
* Retrieves the list of supported analog inputs from a JSON resource hosted on AWS S3.
|
|
350
|
+
*
|
|
351
|
+
* @returns A promise that resolves to a `FirmwareProductSupportedOptions` object
|
|
352
|
+
* containing the supported analog inputs.
|
|
353
|
+
*/
|
|
354
|
+
function fetchSupportedAis() {
|
|
355
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
356
|
+
const path = '/supported-ais.json';
|
|
357
|
+
return yield fetchAndResolve(path, 'json', true);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
exports.fetchSupportedAis = fetchSupportedAis;
|
|
361
|
+
/**
|
|
362
|
+
* Retrieves the list of supported digital input/output from a JSON resource hosted on AWS S3.
|
|
363
|
+
*
|
|
364
|
+
* @returns A promise that resolves to a `FirmwareProductSupportedOptions` object
|
|
365
|
+
* containing the supported digital input/output.
|
|
366
|
+
*/
|
|
367
|
+
function fetchSupportedDios() {
|
|
368
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
369
|
+
const path = '/supported-dios.json';
|
|
370
|
+
return yield fetchAndResolve(path, 'json', true);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
exports.fetchSupportedDios = fetchSupportedDios;
|
|
374
|
+
/**
|
|
375
|
+
* Retrieves the motor configuration data from a JSON resource hosted on AWS S3.
|
|
376
|
+
*
|
|
377
|
+
* @returns A promise that resolves to a `PartConfigurationTable` object
|
|
378
|
+
* containing available motor configurations.
|
|
379
|
+
*/
|
|
380
|
+
function fetchMotorConfigurations() {
|
|
381
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
382
|
+
const path = '/motor-configurations.json';
|
|
383
|
+
return fetchAndResolve(path, 'json', true);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
exports.fetchMotorConfigurations = fetchMotorConfigurations;
|
|
387
|
+
/**
|
|
388
|
+
* Retrieves the encoder configuration data from a JSON resource hosted on AWS S3.
|
|
389
|
+
*
|
|
390
|
+
* @returns A promise that resolves to a `PartConfigurationTable` object
|
|
391
|
+
* containing available encoder configurations.
|
|
392
|
+
*/
|
|
393
|
+
function fetchEncoderConfigurations(firmwareMajorVersion) {
|
|
394
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
395
|
+
const path = `/encoder-configurations-v${firmwareMajorVersion}.json`;
|
|
396
|
+
return fetchAndResolve(path, 'json', true);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
exports.fetchEncoderConfigurations = fetchEncoderConfigurations;
|
|
285
400
|
//# sourceMappingURL=fetch.js.map
|