@hotcodepush/node 0.1.0 → 0.2.1
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/README.md +24 -20
- package/dist/index.d.mts +317 -176
- package/dist/index.mjs +53 -21
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region package.json
|
|
2
|
-
var version = "0.1
|
|
2
|
+
var version = "0.2.1";
|
|
3
3
|
//#endregion
|
|
4
4
|
//#region src/errors.ts
|
|
5
5
|
/**
|
|
@@ -64,9 +64,16 @@ var HttpClient = class {
|
|
|
64
64
|
this.timeoutMs = options.timeout ?? JSON_TIMEOUT_MS;
|
|
65
65
|
}
|
|
66
66
|
async fetchBlob(options) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
return (await this.fetchOkResponse(options)).blob();
|
|
68
|
+
}
|
|
69
|
+
async fetchBufferedResponse(options) {
|
|
70
|
+
const response = await this.fetchOkResponse(options);
|
|
71
|
+
const body = response.body === null ? null : await response.arrayBuffer();
|
|
72
|
+
return new Response(body, {
|
|
73
|
+
headers: response.headers,
|
|
74
|
+
status: response.status,
|
|
75
|
+
statusText: response.statusText
|
|
76
|
+
});
|
|
70
77
|
}
|
|
71
78
|
async fetchCreatingPost(options) {
|
|
72
79
|
return this.fetchJson({
|
|
@@ -81,9 +88,7 @@ var HttpClient = class {
|
|
|
81
88
|
return parseResponseBody(await this.fetchResponse(options));
|
|
82
89
|
}
|
|
83
90
|
async fetchStatus(options) {
|
|
84
|
-
|
|
85
|
-
await assertResponseOk(response);
|
|
86
|
-
await response.body?.cancel();
|
|
91
|
+
await (await this.fetchOkResponse(options)).body?.cancel();
|
|
87
92
|
}
|
|
88
93
|
async fetchUpload(options) {
|
|
89
94
|
const fetchWithTimeout = withTimeout(fetch, { timeoutMs: UPLOAD_TIMEOUT_MS });
|
|
@@ -100,6 +105,11 @@ var HttpClient = class {
|
|
|
100
105
|
method: "PUT"
|
|
101
106
|
}));
|
|
102
107
|
}
|
|
108
|
+
async fetchOkResponse(options) {
|
|
109
|
+
const response = await this.fetchResponse(options);
|
|
110
|
+
await assertResponseOk(response);
|
|
111
|
+
return response;
|
|
112
|
+
}
|
|
103
113
|
async fetchResponse(options) {
|
|
104
114
|
const fetchWithTimeout = withTimeout(fetch, { timeoutMs: this.timeoutMs });
|
|
105
115
|
return (options.isRetryable ?? IDEMPOTENT_METHODS.has(options.method) ? withRetry(fetchWithTimeout) : fetchWithTimeout)(this.resolveUrl(options), this.resolveRequestInit(options));
|
|
@@ -123,7 +133,10 @@ var HttpClient = class {
|
|
|
123
133
|
};
|
|
124
134
|
}
|
|
125
135
|
resolveRouteUrl(path) {
|
|
126
|
-
|
|
136
|
+
if (!path.startsWith("/")) throw new Error(`The path ${path} does not start with a slash.`);
|
|
137
|
+
const url = new URL(this.baseUrl + path);
|
|
138
|
+
if (!url.href.startsWith(new URL(`${this.baseUrl}/`).href)) throw new Error(`The path ${path} leaves the base URL.`);
|
|
139
|
+
return url;
|
|
127
140
|
}
|
|
128
141
|
resolveUrl(options) {
|
|
129
142
|
const url = this.resolveRouteUrl(options.path);
|
|
@@ -238,9 +251,14 @@ var BinariesResource = class {
|
|
|
238
251
|
});
|
|
239
252
|
}
|
|
240
253
|
async get(options) {
|
|
254
|
+
const { appId, binaryId, ...query } = options;
|
|
241
255
|
return this.httpClient.fetchJson({
|
|
242
256
|
method: "GET",
|
|
243
|
-
path: resolvePath("/v1/apps/{appId}/binaries/{binaryId}",
|
|
257
|
+
path: resolvePath("/v1/apps/{appId}/binaries/{binaryId}", {
|
|
258
|
+
appId,
|
|
259
|
+
binaryId
|
|
260
|
+
}),
|
|
261
|
+
query
|
|
244
262
|
});
|
|
245
263
|
}
|
|
246
264
|
/**
|
|
@@ -613,6 +631,7 @@ var ChannelReleasesResource = class {
|
|
|
613
631
|
}
|
|
614
632
|
/**
|
|
615
633
|
* Releases a ready bundle, or what another channel serves, in this channel.
|
|
634
|
+
* With `fromChannelId`, `platform` picks the newest active release of that channel serving the platform.
|
|
616
635
|
* The release gets the next number of the channel.
|
|
617
636
|
*/
|
|
618
637
|
async create(options) {
|
|
@@ -651,8 +670,8 @@ var RollbacksResource = class {
|
|
|
651
670
|
this.httpClient = httpClient;
|
|
652
671
|
}
|
|
653
672
|
/**
|
|
654
|
-
* Rolls the channel back to its
|
|
655
|
-
* A rollback is a new release.
|
|
673
|
+
* Rolls the channel back to the release before its newest active one, or before the newest active one serving `platform`.
|
|
674
|
+
* `toReleaseId` names the target instead. A rollback is a new release.
|
|
656
675
|
*/
|
|
657
676
|
async create(options) {
|
|
658
677
|
const { appId, channelId, idempotencyKey, ...body } = options;
|
|
@@ -1156,7 +1175,7 @@ var StatisticsFleetResource = class {
|
|
|
1156
1175
|
this.httpClient = httpClient;
|
|
1157
1176
|
}
|
|
1158
1177
|
/**
|
|
1159
|
-
* Gets a snapshot of the fleet from the registry, for one channel when `channelId` is set.
|
|
1178
|
+
* Gets a snapshot of the fleet from the registry, for one channel when `channelId` is set and for one binary when `binaryId` is set.
|
|
1160
1179
|
*/
|
|
1161
1180
|
async get(options) {
|
|
1162
1181
|
const { appId, ...query } = options;
|
|
@@ -2394,16 +2413,29 @@ var HotCodePush = class {
|
|
|
2394
2413
|
organizations;
|
|
2395
2414
|
qrCodes;
|
|
2396
2415
|
users;
|
|
2416
|
+
httpClient;
|
|
2397
2417
|
constructor(options = {}) {
|
|
2398
|
-
|
|
2399
|
-
this.apps = new AppsResource(httpClient);
|
|
2400
|
-
this.health = new HealthResource(httpClient);
|
|
2401
|
-
this.invitations = new InvitationsResource(httpClient);
|
|
2402
|
-
this.notificationPreferences = new NotificationPreferencesResource(httpClient);
|
|
2403
|
-
this.notifications = new NotificationsResource(httpClient);
|
|
2404
|
-
this.organizations = new OrganizationsResource(httpClient);
|
|
2405
|
-
this.qrCodes = new QrCodesResource(httpClient);
|
|
2406
|
-
this.users = new UsersResource(httpClient);
|
|
2418
|
+
this.httpClient = new HttpClient(options);
|
|
2419
|
+
this.apps = new AppsResource(this.httpClient);
|
|
2420
|
+
this.health = new HealthResource(this.httpClient);
|
|
2421
|
+
this.invitations = new InvitationsResource(this.httpClient);
|
|
2422
|
+
this.notificationPreferences = new NotificationPreferencesResource(this.httpClient);
|
|
2423
|
+
this.notifications = new NotificationsResource(this.httpClient);
|
|
2424
|
+
this.organizations = new OrganizationsResource(this.httpClient);
|
|
2425
|
+
this.qrCodes = new QrCodesResource(this.httpClient);
|
|
2426
|
+
this.users = new UsersResource(this.httpClient);
|
|
2427
|
+
}
|
|
2428
|
+
/**
|
|
2429
|
+
* Sends one request to a path of the API, for what no resource method covers.
|
|
2430
|
+
* Returns the response with its status, its headers and its body already received.
|
|
2431
|
+
* Throws a `HotCodePushError` on a status outside 2xx.
|
|
2432
|
+
*/
|
|
2433
|
+
request({ body, method, path }) {
|
|
2434
|
+
return this.httpClient.fetchBufferedResponse({
|
|
2435
|
+
body,
|
|
2436
|
+
method,
|
|
2437
|
+
path
|
|
2438
|
+
});
|
|
2407
2439
|
}
|
|
2408
2440
|
};
|
|
2409
2441
|
//#endregion
|