@hot-updater/standalone 1.2.0-rc.2 → 1.2.0-rc.20

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/index.cjs CHANGED
@@ -12,11 +12,13 @@ var StandaloneDatabaseError = class extends Error {
12
12
  }
13
13
  };
14
14
  const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
15
+ /** `headers` with each lazy value resolved. */
16
+ const resolveHeaders = async (headers = {}) => Object.fromEntries(await Promise.all(Object.entries(headers).map(async ([name, value]) => [name, await (0, _hot_updater_plugin_core.resolveLazy)(value)])));
15
17
  const createStandaloneHttp = (config) => {
16
18
  const buildUrl = (path) => `${config.baseUrl.replace(/\/+$/, "")}${path}`;
17
- const headers = (routeHeaders) => ({
19
+ const headers = async (routeHeaders) => ({
18
20
  "Content-Type": "application/json",
19
- ...config.commonHeaders,
21
+ ...await resolveHeaders(config.commonHeaders),
20
22
  ...routeHeaders
21
23
  });
22
24
  const requestFailed = async (response) => {
@@ -108,7 +110,7 @@ const createStandaloneCoreApi = (config) => {
108
110
  const http = createStandaloneHttp(config);
109
111
  let checked;
110
112
  const checkProtocol = async () => {
111
- const response = await fetch(http.buildUrl("/version"), { headers: http.headers({ "Cache-Control": "no-cache" }) });
113
+ const response = await fetch(http.buildUrl("/version"), { headers: await http.headers({ "Cache-Control": "no-cache" }) });
112
114
  const body = response.status === 404 ? {} : await http.parseJson(response);
113
115
  const protocol = isRecord(body) ? body.adminProtocol : void 0;
114
116
  if (typeof protocol !== "number" || protocol < 2) throw new StandaloneDatabaseError("request-failed", `The server at ${config.baseUrl} does not report Hot Updater admin API protocol 2 at /version. Set baseUrl to the path where the server mounts handlers.admin, such as https://example.com/hot-updater/admin.`, response.status);
@@ -125,7 +127,7 @@ const createStandaloneCoreApi = (config) => {
125
127
  for (const [key, value] of Object.entries(query)) url.searchParams.set(key, value);
126
128
  const response = await fetch(url, {
127
129
  method,
128
- headers: http.headers(method === "GET" ? { "Cache-Control": "no-cache" } : void 0),
130
+ headers: await http.headers(method === "GET" ? { "Cache-Control": "no-cache" } : void 0),
129
131
  ...body === void 0 ? {} : { body: JSON.stringify(body) }
130
132
  });
131
133
  if (response.status === 204) return null;
@@ -188,11 +190,15 @@ const createStandaloneCoreApi = (config) => {
188
190
  const row = await call("GET", "/native-builds/latest", {
189
191
  query: {
190
192
  ...nativeBuildScopeParams(scope),
191
- ...buildKey === void 0 ? {} : { buildKey }
193
+ ...buildKey === void 0 ? {} : { buildKey },
194
+ ...options?.storeBuild ? { storeBuild: "true" } : {},
195
+ ...options?.builtInOlderThan === void 0 ? {} : { builtInOlderThan: options.builtInOlderThan }
192
196
  },
193
197
  requiredRoute: "native build"
194
198
  });
195
- return buildKey !== void 0 && row?.build_key !== buildKey ? null : row;
199
+ if (buildKey !== void 0 && row?.build_key !== buildKey) return null;
200
+ if (options?.storeBuild && row?.store_build !== true) return null;
201
+ return row;
196
202
  },
197
203
  listNativeBuilds: ({ channelId, ...input }) => list("/native-builds", {
198
204
  ...keysetParams(input),
@@ -236,6 +242,10 @@ const createStandaloneCoreApi = (config) => {
236
242
  body: submission,
237
243
  requiredRoute: "native build submission"
238
244
  }),
245
+ markNativeBuild: (id, mark) => call("POST", `/native-builds/${encode(id)}/store-build`, {
246
+ body: mark,
247
+ requiredRoute: "native build store mark"
248
+ }),
239
249
  deleteNativeBuild: async (id) => await call("DELETE", `/native-builds/${encode(id)}`, { requiredRoute: "native build deletion" })
240
250
  };
241
251
  };
@@ -252,8 +262,8 @@ const standaloneRepository = (config) => {
252
262
  return Object.freeze({
253
263
  name: "standalone-repository",
254
264
  core: createStandaloneCoreApi(config),
255
- fetchAdmin: (path, init = {}) => {
256
- const headers = new Headers(http.headers({ "Cache-Control": "no-cache" }));
265
+ fetchAdmin: async (path, init = {}) => {
266
+ const headers = new Headers(await http.headers({ "Cache-Control": "no-cache" }));
257
267
  new Headers(init.headers).forEach((value, name) => {
258
268
  headers.set(name, value);
259
269
  });
@@ -270,8 +280,12 @@ const defaultRoutes = {
270
280
  put: () => ({ path: "/upload" }),
271
281
  get: () => ({ path: "/get" }),
272
282
  exists: () => ({ path: "/exists" }),
273
- delete: () => ({ path: "/delete" })
283
+ delete: () => ({ path: "/delete" }),
284
+ listObjects: () => ({ path: "/list" }),
285
+ deleteObjects: () => ({ path: "/delete-objects" })
274
286
  };
287
+ /** Keys sent in one `deleteObjects` request. */
288
+ const DELETE_BATCH_SIZE = 1e3;
275
289
  const createRoute = (defaultRoute, customRoute) => ({
276
290
  path: customRoute?.path ?? defaultRoute.path,
277
291
  headers: {
@@ -280,8 +294,8 @@ const createRoute = (defaultRoute, customRoute) => ({
280
294
  }
281
295
  });
282
296
  const standaloneStorage = (config) => {
283
- const getHeaders = (routeHeaders) => ({
284
- ...config.commonHeaders,
297
+ const getHeaders = async (routeHeaders) => ({
298
+ ...await resolveHeaders(config.commonHeaders),
285
299
  ...routeHeaders
286
300
  });
287
301
  const resolveRoute = (name, args) => {
@@ -289,6 +303,14 @@ const standaloneStorage = (config) => {
289
303
  const custom = config.routes?.[name];
290
304
  return createRoute(fallback(...args), custom?.(...args));
291
305
  };
306
+ const postJson = async (path, headers, body) => fetch(`${config.baseUrl}${path}`, {
307
+ method: "POST",
308
+ headers: {
309
+ "content-type": "application/json",
310
+ ...await getHeaders(headers)
311
+ },
312
+ body: JSON.stringify(body)
313
+ });
292
314
  const requestStorageUri = async (routeName, storageUri) => {
293
315
  (0, _hot_updater_plugin_core.parseStorageUri)(storageUri, config.protocol);
294
316
  const { path, headers } = resolveRoute(routeName, [{ storageUri }]);
@@ -296,7 +318,7 @@ const standaloneStorage = (config) => {
296
318
  method: routeName === "delete" ? "DELETE" : "POST",
297
319
  headers: {
298
320
  "content-type": "application/json",
299
- ...getHeaders(headers)
321
+ ...await getHeaders(headers)
300
322
  },
301
323
  body: JSON.stringify({ storageUri })
302
324
  });
@@ -319,7 +341,7 @@ const standaloneStorage = (config) => {
319
341
  formData.append("key", key);
320
342
  const response = await fetch(`${config.baseUrl}${path}`, {
321
343
  method: "POST",
322
- headers: getHeaders(headers),
344
+ headers: await getHeaders(headers),
323
345
  body: formData
324
346
  });
325
347
  if (!response.ok) throw new Error(`Failed to upload bundle: ${response.statusText}`);
@@ -340,6 +362,39 @@ const standaloneStorage = (config) => {
340
362
  async delete({ storageUri }) {
341
363
  await requestStorageUri("delete", storageUri);
342
364
  return { deleted: true };
365
+ },
366
+ async listObjects(prefix) {
367
+ const { path, headers } = resolveRoute("listObjects", [{ prefix }]);
368
+ const objects = [];
369
+ let cursor;
370
+ do {
371
+ const response = await postJson(path, headers, {
372
+ prefix,
373
+ cursor
374
+ });
375
+ if (response.status === 404) throw new Error(`The storage service has no ${path} route, which storage prune needs.`);
376
+ if (!response.ok) throw new Error(`Failed to list storage objects: ${response.statusText}`);
377
+ const page = await response.json();
378
+ for (const object of page.objects) {
379
+ (0, _hot_updater_plugin_core.parseStorageUri)(object.storageUri, config.protocol);
380
+ objects.push({
381
+ key: object.key,
382
+ storageUri: object.storageUri,
383
+ size: object.size,
384
+ ...object.lastModifiedAt === void 0 ? {} : { lastModifiedAt: new Date(object.lastModifiedAt) }
385
+ });
386
+ }
387
+ cursor = page.cursor;
388
+ } while (cursor !== void 0);
389
+ return objects;
390
+ },
391
+ async deleteObjects(keys) {
392
+ for (let offset = 0; offset < keys.length; offset += DELETE_BATCH_SIZE) {
393
+ const batch = keys.slice(offset, offset + DELETE_BATCH_SIZE);
394
+ const { path, headers } = resolveRoute("deleteObjects", [{ keys: batch }]);
395
+ const response = await postJson(path, headers, { keys: batch });
396
+ if (!response.ok) throw new Error(`Failed to delete storage objects: ${response.statusText}`);
397
+ }
343
398
  }
344
399
  });
345
400
  };
package/dist/index.d.cts CHANGED
@@ -1,10 +1,14 @@
1
- import { HotUpdaterCoreApi, RemoteDatabase, StorageDeleteInput, StorageExistsInput, StorageGetInput, StoragePutInput } from "@hot-updater/plugin-core";
1
+ import { HotUpdaterCoreApi, Lazy, RemoteDatabase, StorageDeleteInput, StorageExistsInput, StorageGetInput, StorageObject, StoragePutInput } from "@hot-updater/plugin-core";
2
2
  //#region src/standaloneRoutes.d.ts
3
3
  interface StandaloneRepositoryConfig {
4
4
  /** Base URL of the Hot Updater admin handler. */
5
5
  readonly baseUrl: string;
6
- /** Headers sent with every admin request, such as its authorization. */
7
- readonly commonHeaders?: Readonly<Record<string, string>>;
6
+ /**
7
+ * Headers sent with every admin request, such as its authorization. A
8
+ * value may be a function that returns it, such as `secret("<name>")` in
9
+ * `hot-updater.config.ts`, called on the first request.
10
+ */
11
+ readonly commonHeaders?: Readonly<Record<string, Lazy<string>>>;
8
12
  }
9
13
  //#endregion
10
14
  //#region src/standaloneCore.d.ts
@@ -48,12 +52,25 @@ interface StorageRoutes {
48
52
  get: (input: StorageGetInput) => RouteConfig;
49
53
  exists: (input: StorageExistsInput) => RouteConfig;
50
54
  delete: (input: StorageDeleteInput) => RouteConfig;
55
+ /** Lists objects for `hot-updater storage prune`. */
56
+ listObjects: (input: {
57
+ readonly prefix?: string;
58
+ }) => RouteConfig;
59
+ /** Deletes exact keys for `hot-updater storage prune --yes`. */
60
+ deleteObjects: (input: {
61
+ readonly keys: readonly string[];
62
+ }) => RouteConfig;
51
63
  }
52
64
  interface StandaloneStorageConfig {
53
65
  baseUrl: string;
54
66
  /** Storage URI protocol owned by the remote implementation. */
55
67
  protocol: string;
56
- commonHeaders?: Record<string, string>;
68
+ /**
69
+ * Headers sent with every request. A value may be a function that returns
70
+ * it, such as `secret("<name>")` in `hot-updater.config.ts`, called on
71
+ * the first request.
72
+ */
73
+ commonHeaders?: Record<string, Lazy<string>>;
57
74
  routes?: Partial<StorageRoutes>;
58
75
  }
59
76
  declare const standaloneStorage: (config: StandaloneStorageConfig) => {
@@ -71,6 +88,8 @@ declare const standaloneStorage: (config: StandaloneStorageConfig) => {
71
88
  readonly delete: ({ storageUri }: StorageDeleteInput) => Promise<{
72
89
  deleted: true;
73
90
  }>;
91
+ readonly listObjects: (prefix?: string) => Promise<StorageObject[]>;
92
+ readonly deleteObjects: (keys: readonly string[]) => Promise<void>;
74
93
  };
75
94
  //#endregion
76
95
  export { RouteConfig, STANDALONE_ADMIN_PROTOCOL, StandaloneDatabaseError, StandaloneRepository, type StandaloneRepositoryConfig, StandaloneStorageConfig, StorageRoutes, createStandaloneCoreApi, standaloneRepository, standaloneStorage };
package/dist/index.d.mts CHANGED
@@ -1,10 +1,14 @@
1
- import { HotUpdaterCoreApi, RemoteDatabase, StorageDeleteInput, StorageExistsInput, StorageGetInput, StoragePutInput } from "@hot-updater/plugin-core";
1
+ import { HotUpdaterCoreApi, Lazy, RemoteDatabase, StorageDeleteInput, StorageExistsInput, StorageGetInput, StorageObject, StoragePutInput } from "@hot-updater/plugin-core";
2
2
  //#region src/standaloneRoutes.d.ts
3
3
  interface StandaloneRepositoryConfig {
4
4
  /** Base URL of the Hot Updater admin handler. */
5
5
  readonly baseUrl: string;
6
- /** Headers sent with every admin request, such as its authorization. */
7
- readonly commonHeaders?: Readonly<Record<string, string>>;
6
+ /**
7
+ * Headers sent with every admin request, such as its authorization. A
8
+ * value may be a function that returns it, such as `secret("<name>")` in
9
+ * `hot-updater.config.ts`, called on the first request.
10
+ */
11
+ readonly commonHeaders?: Readonly<Record<string, Lazy<string>>>;
8
12
  }
9
13
  //#endregion
10
14
  //#region src/standaloneCore.d.ts
@@ -48,12 +52,25 @@ interface StorageRoutes {
48
52
  get: (input: StorageGetInput) => RouteConfig;
49
53
  exists: (input: StorageExistsInput) => RouteConfig;
50
54
  delete: (input: StorageDeleteInput) => RouteConfig;
55
+ /** Lists objects for `hot-updater storage prune`. */
56
+ listObjects: (input: {
57
+ readonly prefix?: string;
58
+ }) => RouteConfig;
59
+ /** Deletes exact keys for `hot-updater storage prune --yes`. */
60
+ deleteObjects: (input: {
61
+ readonly keys: readonly string[];
62
+ }) => RouteConfig;
51
63
  }
52
64
  interface StandaloneStorageConfig {
53
65
  baseUrl: string;
54
66
  /** Storage URI protocol owned by the remote implementation. */
55
67
  protocol: string;
56
- commonHeaders?: Record<string, string>;
68
+ /**
69
+ * Headers sent with every request. A value may be a function that returns
70
+ * it, such as `secret("<name>")` in `hot-updater.config.ts`, called on
71
+ * the first request.
72
+ */
73
+ commonHeaders?: Record<string, Lazy<string>>;
57
74
  routes?: Partial<StorageRoutes>;
58
75
  }
59
76
  declare const standaloneStorage: (config: StandaloneStorageConfig) => {
@@ -71,6 +88,8 @@ declare const standaloneStorage: (config: StandaloneStorageConfig) => {
71
88
  readonly delete: ({ storageUri }: StorageDeleteInput) => Promise<{
72
89
  deleted: true;
73
90
  }>;
91
+ readonly listObjects: (prefix?: string) => Promise<StorageObject[]>;
92
+ readonly deleteObjects: (keys: readonly string[]) => Promise<void>;
74
93
  };
75
94
  //#endregion
76
95
  export { RouteConfig, STANDALONE_ADMIN_PROTOCOL, StandaloneDatabaseError, StandaloneRepository, type StandaloneRepositoryConfig, StandaloneStorageConfig, StorageRoutes, createStandaloneCoreApi, standaloneRepository, standaloneStorage };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { DatabaseBundleNotFoundError, ReleaseCatalogMutationError, ReleaseManagementError, createStorageAdapter, parseStorageUri } from "@hot-updater/plugin-core";
1
+ import { DatabaseBundleNotFoundError, ReleaseCatalogMutationError, ReleaseManagementError, createStorageAdapter, parseStorageUri, resolveLazy } from "@hot-updater/plugin-core";
2
2
  //#region src/standaloneHttp.ts
3
3
  var StandaloneDatabaseError = class extends Error {
4
4
  code;
@@ -11,11 +11,13 @@ var StandaloneDatabaseError = class extends Error {
11
11
  }
12
12
  };
13
13
  const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
14
+ /** `headers` with each lazy value resolved. */
15
+ const resolveHeaders = async (headers = {}) => Object.fromEntries(await Promise.all(Object.entries(headers).map(async ([name, value]) => [name, await resolveLazy(value)])));
14
16
  const createStandaloneHttp = (config) => {
15
17
  const buildUrl = (path) => `${config.baseUrl.replace(/\/+$/, "")}${path}`;
16
- const headers = (routeHeaders) => ({
18
+ const headers = async (routeHeaders) => ({
17
19
  "Content-Type": "application/json",
18
- ...config.commonHeaders,
20
+ ...await resolveHeaders(config.commonHeaders),
19
21
  ...routeHeaders
20
22
  });
21
23
  const requestFailed = async (response) => {
@@ -107,7 +109,7 @@ const createStandaloneCoreApi = (config) => {
107
109
  const http = createStandaloneHttp(config);
108
110
  let checked;
109
111
  const checkProtocol = async () => {
110
- const response = await fetch(http.buildUrl("/version"), { headers: http.headers({ "Cache-Control": "no-cache" }) });
112
+ const response = await fetch(http.buildUrl("/version"), { headers: await http.headers({ "Cache-Control": "no-cache" }) });
111
113
  const body = response.status === 404 ? {} : await http.parseJson(response);
112
114
  const protocol = isRecord(body) ? body.adminProtocol : void 0;
113
115
  if (typeof protocol !== "number" || protocol < 2) throw new StandaloneDatabaseError("request-failed", `The server at ${config.baseUrl} does not report Hot Updater admin API protocol 2 at /version. Set baseUrl to the path where the server mounts handlers.admin, such as https://example.com/hot-updater/admin.`, response.status);
@@ -124,7 +126,7 @@ const createStandaloneCoreApi = (config) => {
124
126
  for (const [key, value] of Object.entries(query)) url.searchParams.set(key, value);
125
127
  const response = await fetch(url, {
126
128
  method,
127
- headers: http.headers(method === "GET" ? { "Cache-Control": "no-cache" } : void 0),
129
+ headers: await http.headers(method === "GET" ? { "Cache-Control": "no-cache" } : void 0),
128
130
  ...body === void 0 ? {} : { body: JSON.stringify(body) }
129
131
  });
130
132
  if (response.status === 204) return null;
@@ -187,11 +189,15 @@ const createStandaloneCoreApi = (config) => {
187
189
  const row = await call("GET", "/native-builds/latest", {
188
190
  query: {
189
191
  ...nativeBuildScopeParams(scope),
190
- ...buildKey === void 0 ? {} : { buildKey }
192
+ ...buildKey === void 0 ? {} : { buildKey },
193
+ ...options?.storeBuild ? { storeBuild: "true" } : {},
194
+ ...options?.builtInOlderThan === void 0 ? {} : { builtInOlderThan: options.builtInOlderThan }
191
195
  },
192
196
  requiredRoute: "native build"
193
197
  });
194
- return buildKey !== void 0 && row?.build_key !== buildKey ? null : row;
198
+ if (buildKey !== void 0 && row?.build_key !== buildKey) return null;
199
+ if (options?.storeBuild && row?.store_build !== true) return null;
200
+ return row;
195
201
  },
196
202
  listNativeBuilds: ({ channelId, ...input }) => list("/native-builds", {
197
203
  ...keysetParams(input),
@@ -235,6 +241,10 @@ const createStandaloneCoreApi = (config) => {
235
241
  body: submission,
236
242
  requiredRoute: "native build submission"
237
243
  }),
244
+ markNativeBuild: (id, mark) => call("POST", `/native-builds/${encode(id)}/store-build`, {
245
+ body: mark,
246
+ requiredRoute: "native build store mark"
247
+ }),
238
248
  deleteNativeBuild: async (id) => await call("DELETE", `/native-builds/${encode(id)}`, { requiredRoute: "native build deletion" })
239
249
  };
240
250
  };
@@ -251,8 +261,8 @@ const standaloneRepository = (config) => {
251
261
  return Object.freeze({
252
262
  name: "standalone-repository",
253
263
  core: createStandaloneCoreApi(config),
254
- fetchAdmin: (path, init = {}) => {
255
- const headers = new Headers(http.headers({ "Cache-Control": "no-cache" }));
264
+ fetchAdmin: async (path, init = {}) => {
265
+ const headers = new Headers(await http.headers({ "Cache-Control": "no-cache" }));
256
266
  new Headers(init.headers).forEach((value, name) => {
257
267
  headers.set(name, value);
258
268
  });
@@ -269,8 +279,12 @@ const defaultRoutes = {
269
279
  put: () => ({ path: "/upload" }),
270
280
  get: () => ({ path: "/get" }),
271
281
  exists: () => ({ path: "/exists" }),
272
- delete: () => ({ path: "/delete" })
282
+ delete: () => ({ path: "/delete" }),
283
+ listObjects: () => ({ path: "/list" }),
284
+ deleteObjects: () => ({ path: "/delete-objects" })
273
285
  };
286
+ /** Keys sent in one `deleteObjects` request. */
287
+ const DELETE_BATCH_SIZE = 1e3;
274
288
  const createRoute = (defaultRoute, customRoute) => ({
275
289
  path: customRoute?.path ?? defaultRoute.path,
276
290
  headers: {
@@ -279,8 +293,8 @@ const createRoute = (defaultRoute, customRoute) => ({
279
293
  }
280
294
  });
281
295
  const standaloneStorage = (config) => {
282
- const getHeaders = (routeHeaders) => ({
283
- ...config.commonHeaders,
296
+ const getHeaders = async (routeHeaders) => ({
297
+ ...await resolveHeaders(config.commonHeaders),
284
298
  ...routeHeaders
285
299
  });
286
300
  const resolveRoute = (name, args) => {
@@ -288,6 +302,14 @@ const standaloneStorage = (config) => {
288
302
  const custom = config.routes?.[name];
289
303
  return createRoute(fallback(...args), custom?.(...args));
290
304
  };
305
+ const postJson = async (path, headers, body) => fetch(`${config.baseUrl}${path}`, {
306
+ method: "POST",
307
+ headers: {
308
+ "content-type": "application/json",
309
+ ...await getHeaders(headers)
310
+ },
311
+ body: JSON.stringify(body)
312
+ });
291
313
  const requestStorageUri = async (routeName, storageUri) => {
292
314
  parseStorageUri(storageUri, config.protocol);
293
315
  const { path, headers } = resolveRoute(routeName, [{ storageUri }]);
@@ -295,7 +317,7 @@ const standaloneStorage = (config) => {
295
317
  method: routeName === "delete" ? "DELETE" : "POST",
296
318
  headers: {
297
319
  "content-type": "application/json",
298
- ...getHeaders(headers)
320
+ ...await getHeaders(headers)
299
321
  },
300
322
  body: JSON.stringify({ storageUri })
301
323
  });
@@ -318,7 +340,7 @@ const standaloneStorage = (config) => {
318
340
  formData.append("key", key);
319
341
  const response = await fetch(`${config.baseUrl}${path}`, {
320
342
  method: "POST",
321
- headers: getHeaders(headers),
343
+ headers: await getHeaders(headers),
322
344
  body: formData
323
345
  });
324
346
  if (!response.ok) throw new Error(`Failed to upload bundle: ${response.statusText}`);
@@ -339,6 +361,39 @@ const standaloneStorage = (config) => {
339
361
  async delete({ storageUri }) {
340
362
  await requestStorageUri("delete", storageUri);
341
363
  return { deleted: true };
364
+ },
365
+ async listObjects(prefix) {
366
+ const { path, headers } = resolveRoute("listObjects", [{ prefix }]);
367
+ const objects = [];
368
+ let cursor;
369
+ do {
370
+ const response = await postJson(path, headers, {
371
+ prefix,
372
+ cursor
373
+ });
374
+ if (response.status === 404) throw new Error(`The storage service has no ${path} route, which storage prune needs.`);
375
+ if (!response.ok) throw new Error(`Failed to list storage objects: ${response.statusText}`);
376
+ const page = await response.json();
377
+ for (const object of page.objects) {
378
+ parseStorageUri(object.storageUri, config.protocol);
379
+ objects.push({
380
+ key: object.key,
381
+ storageUri: object.storageUri,
382
+ size: object.size,
383
+ ...object.lastModifiedAt === void 0 ? {} : { lastModifiedAt: new Date(object.lastModifiedAt) }
384
+ });
385
+ }
386
+ cursor = page.cursor;
387
+ } while (cursor !== void 0);
388
+ return objects;
389
+ },
390
+ async deleteObjects(keys) {
391
+ for (let offset = 0; offset < keys.length; offset += DELETE_BATCH_SIZE) {
392
+ const batch = keys.slice(offset, offset + DELETE_BATCH_SIZE);
393
+ const { path, headers } = resolveRoute("deleteObjects", [{ keys: batch }]);
394
+ const response = await postJson(path, headers, { keys: batch });
395
+ if (!response.ok) throw new Error(`Failed to delete storage objects: ${response.statusText}`);
396
+ }
342
397
  }
343
398
  });
344
399
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/standalone",
3
- "version": "1.2.0-rc.2",
3
+ "version": "1.2.0-rc.20",
4
4
  "type": "module",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "sideEffects": false,
@@ -42,8 +42,8 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@hot-updater/protocol": "1.2.0-rc.2",
46
- "@hot-updater/plugin-core": "1.2.0-rc.2"
45
+ "@hot-updater/protocol": "1.2.0-rc.20",
46
+ "@hot-updater/plugin-core": "1.2.0-rc.20"
47
47
  },
48
48
  "devDependencies": {
49
49
  "mime": "2.6.0",
@@ -52,12 +52,7 @@
52
52
  "msw": "^2.7.0",
53
53
  "verkit": "0.4.0",
54
54
  "vitest": "4.1.4",
55
- "@hot-updater/test-utils": "1.2.0-rc.2"
56
- },
57
- "nx": {
58
- "implicitDependencies": [
59
- "!@hot-updater/test-utils"
60
- ]
55
+ "@hot-updater/test-utils": "1.2.0-rc.20"
61
56
  },
62
57
  "scripts": {
63
58
  "build": "tsdown",