@hot-updater/standalone 0.12.7 → 0.13.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/dist/index.cjs +61 -70
- package/dist/index.js +61 -70
- package/dist/standaloneRepository.d.ts +2 -2
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -3298,18 +3298,20 @@ var __webpack_exports__ = {};
|
|
|
3298
3298
|
throw new Error(error);
|
|
3299
3299
|
}
|
|
3300
3300
|
const result = await response.json();
|
|
3301
|
-
if (!result.
|
|
3302
|
-
const error = "Failed to upload bundle - no
|
|
3301
|
+
if (!result.bucketName || !result.key) {
|
|
3302
|
+
const error = "Failed to upload bundle - no bucketName or key in response";
|
|
3303
3303
|
console.error(`[uploadBundle] ${error}`);
|
|
3304
3304
|
throw new Error(error);
|
|
3305
3305
|
}
|
|
3306
3306
|
hooks?.onStorageUploaded?.();
|
|
3307
3307
|
return {
|
|
3308
|
-
|
|
3308
|
+
bucketName: result.bucketName,
|
|
3309
|
+
key: result.key
|
|
3309
3310
|
};
|
|
3310
3311
|
}
|
|
3311
3312
|
};
|
|
3312
3313
|
};
|
|
3314
|
+
const plugin_core_namespaceObject = require("@hot-updater/plugin-core");
|
|
3313
3315
|
const standaloneRepository_defaultRoutes = {
|
|
3314
3316
|
upsert: ()=>({
|
|
3315
3317
|
path: "/bundles"
|
|
@@ -3334,78 +3336,67 @@ var __webpack_exports__ = {};
|
|
|
3334
3336
|
...customRoute?.headers
|
|
3335
3337
|
}
|
|
3336
3338
|
});
|
|
3337
|
-
const standaloneRepository = (config, hooks)=>
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
}
|
|
3353
|
-
return {
|
|
3354
|
-
name: "standalone-repository",
|
|
3355
|
-
async commitBundle () {
|
|
3356
|
-
if (0 === changedIds.size) return;
|
|
3357
|
-
const changedBundles = bundles.filter((b)=>changedIds.has(b.id));
|
|
3358
|
-
if (0 === changedBundles.length) return;
|
|
3359
|
-
const { path, headers: routeHeaders } = routes.upsert();
|
|
3360
|
-
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
3361
|
-
method: "POST",
|
|
3362
|
-
headers: getHeaders(routeHeaders),
|
|
3363
|
-
body: JSON.stringify(changedBundles)
|
|
3364
|
-
});
|
|
3365
|
-
if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
|
|
3366
|
-
const result = await response.json();
|
|
3367
|
-
if (!result.success) throw new Error("Failed to commit bundles");
|
|
3368
|
-
changedIds.clear();
|
|
3369
|
-
hooks?.onDatabaseUpdated?.();
|
|
3370
|
-
},
|
|
3371
|
-
async updateBundle (targetBundleId, newBundle) {
|
|
3372
|
-
bundles = await this.getBundles();
|
|
3373
|
-
const targetIndex = bundles.findIndex((u)=>u.id === targetBundleId);
|
|
3374
|
-
if (-1 === targetIndex) throw new Error("target bundle version not found");
|
|
3375
|
-
Object.assign(bundles[targetIndex], newBundle);
|
|
3376
|
-
markChanged(targetBundleId);
|
|
3377
|
-
},
|
|
3378
|
-
async appendBundle (inputBundle) {
|
|
3379
|
-
bundles = await this.getBundles();
|
|
3380
|
-
bundles.unshift(inputBundle);
|
|
3381
|
-
markChanged(inputBundle.id);
|
|
3382
|
-
},
|
|
3383
|
-
async getBundleById (bundleId) {
|
|
3384
|
-
try {
|
|
3385
|
-
const { path, headers: routeHeaders } = routes.retrieve(bundleId);
|
|
3386
|
-
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
3387
|
-
method: "GET",
|
|
3388
|
-
headers: getHeaders(routeHeaders)
|
|
3389
|
-
});
|
|
3390
|
-
if (!response.ok) return null;
|
|
3391
|
-
return await response.json();
|
|
3392
|
-
} catch (error) {
|
|
3393
|
-
return null;
|
|
3394
|
-
}
|
|
3395
|
-
},
|
|
3396
|
-
async getBundles (refresh = false) {
|
|
3397
|
-
if (bundles.length > 0 && !refresh) return bundles;
|
|
3398
|
-
const { path, headers: routeHeaders } = routes.list();
|
|
3339
|
+
const standaloneRepository = (config, hooks)=>{
|
|
3340
|
+
const routes = {
|
|
3341
|
+
upsert: ()=>standaloneRepository_createRoute(standaloneRepository_defaultRoutes.upsert(), config.routes?.upsert?.()),
|
|
3342
|
+
list: ()=>standaloneRepository_createRoute(standaloneRepository_defaultRoutes.list(), config.routes?.list?.()),
|
|
3343
|
+
retrieve: (bundleId)=>standaloneRepository_createRoute(standaloneRepository_defaultRoutes.retrieve(bundleId), config.routes?.retrieve?.(bundleId))
|
|
3344
|
+
};
|
|
3345
|
+
const getHeaders = (routeHeaders)=>({
|
|
3346
|
+
"Content-Type": "application/json",
|
|
3347
|
+
...config.commonHeaders,
|
|
3348
|
+
...routeHeaders
|
|
3349
|
+
});
|
|
3350
|
+
return (0, plugin_core_namespaceObject.createDatabasePlugin)("standalone-repository", {
|
|
3351
|
+
async getBundleById (bundleId) {
|
|
3352
|
+
try {
|
|
3353
|
+
const { path, headers: routeHeaders } = routes.retrieve(bundleId);
|
|
3399
3354
|
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
3400
3355
|
method: "GET",
|
|
3401
3356
|
headers: getHeaders(routeHeaders)
|
|
3402
3357
|
});
|
|
3403
|
-
if (!response.ok)
|
|
3404
|
-
|
|
3405
|
-
|
|
3358
|
+
if (!response.ok) return null;
|
|
3359
|
+
return await response.json();
|
|
3360
|
+
} catch (error) {
|
|
3361
|
+
return null;
|
|
3406
3362
|
}
|
|
3407
|
-
}
|
|
3408
|
-
|
|
3363
|
+
},
|
|
3364
|
+
async getBundles (options) {
|
|
3365
|
+
const { where, limit, offset = 0 } = options ?? {};
|
|
3366
|
+
const { path, headers: routeHeaders } = routes.list();
|
|
3367
|
+
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
3368
|
+
method: "GET",
|
|
3369
|
+
headers: getHeaders(routeHeaders)
|
|
3370
|
+
});
|
|
3371
|
+
if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
|
|
3372
|
+
const bundles = await response.json();
|
|
3373
|
+
let filteredBundles = bundles;
|
|
3374
|
+
if (where?.channel) filteredBundles = filteredBundles.filter((b)=>b.channel === where.channel);
|
|
3375
|
+
if (where?.platform) filteredBundles = filteredBundles.filter((b)=>b.platform === where.platform);
|
|
3376
|
+
if (limit) return filteredBundles.slice(offset, offset + limit);
|
|
3377
|
+
return filteredBundles;
|
|
3378
|
+
},
|
|
3379
|
+
async getChannels () {
|
|
3380
|
+
const allBundles = await this.getBundles();
|
|
3381
|
+
return [
|
|
3382
|
+
...new Set(allBundles.map((b)=>b.channel))
|
|
3383
|
+
];
|
|
3384
|
+
},
|
|
3385
|
+
async commitBundle ({ changedSets }) {
|
|
3386
|
+
const changedBundles = changedSets.map((set)=>set.data);
|
|
3387
|
+
if (0 === changedBundles.length) return;
|
|
3388
|
+
const { path, headers: routeHeaders } = routes.upsert();
|
|
3389
|
+
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
3390
|
+
method: "POST",
|
|
3391
|
+
headers: getHeaders(routeHeaders),
|
|
3392
|
+
body: JSON.stringify(changedBundles)
|
|
3393
|
+
});
|
|
3394
|
+
if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
|
|
3395
|
+
const result = await response.json();
|
|
3396
|
+
if (!result.success) throw new Error("Failed to commit bundles");
|
|
3397
|
+
}
|
|
3398
|
+
}, hooks);
|
|
3399
|
+
};
|
|
3409
3400
|
})();
|
|
3410
3401
|
var __webpack_export_target__ = exports;
|
|
3411
3402
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_fs_promises_400951f8__ from "fs/promises";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__ from "@hot-updater/plugin-core";
|
|
3
4
|
var __webpack_modules__ = {
|
|
4
5
|
"../../node_modules/.pnpm/mime@2.6.0/node_modules/mime/Mime.js": function(module) {
|
|
5
6
|
function Mime() {
|
|
@@ -3276,14 +3277,15 @@ const standaloneStorage = (config, hooks)=>(_)=>{
|
|
|
3276
3277
|
throw new Error(error);
|
|
3277
3278
|
}
|
|
3278
3279
|
const result = await response.json();
|
|
3279
|
-
if (!result.
|
|
3280
|
-
const error = "Failed to upload bundle - no
|
|
3280
|
+
if (!result.bucketName || !result.key) {
|
|
3281
|
+
const error = "Failed to upload bundle - no bucketName or key in response";
|
|
3281
3282
|
console.error(`[uploadBundle] ${error}`);
|
|
3282
3283
|
throw new Error(error);
|
|
3283
3284
|
}
|
|
3284
3285
|
hooks?.onStorageUploaded?.();
|
|
3285
3286
|
return {
|
|
3286
|
-
|
|
3287
|
+
bucketName: result.bucketName,
|
|
3288
|
+
key: result.key
|
|
3287
3289
|
};
|
|
3288
3290
|
}
|
|
3289
3291
|
};
|
|
@@ -3312,76 +3314,65 @@ const standaloneRepository_createRoute = (defaultRoute, customRoute)=>({
|
|
|
3312
3314
|
...customRoute?.headers
|
|
3313
3315
|
}
|
|
3314
3316
|
});
|
|
3315
|
-
const standaloneRepository = (config, hooks)=>
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
}
|
|
3331
|
-
return {
|
|
3332
|
-
name: "standalone-repository",
|
|
3333
|
-
async commitBundle () {
|
|
3334
|
-
if (0 === changedIds.size) return;
|
|
3335
|
-
const changedBundles = bundles.filter((b)=>changedIds.has(b.id));
|
|
3336
|
-
if (0 === changedBundles.length) return;
|
|
3337
|
-
const { path, headers: routeHeaders } = routes.upsert();
|
|
3338
|
-
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
3339
|
-
method: "POST",
|
|
3340
|
-
headers: getHeaders(routeHeaders),
|
|
3341
|
-
body: JSON.stringify(changedBundles)
|
|
3342
|
-
});
|
|
3343
|
-
if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
|
|
3344
|
-
const result = await response.json();
|
|
3345
|
-
if (!result.success) throw new Error("Failed to commit bundles");
|
|
3346
|
-
changedIds.clear();
|
|
3347
|
-
hooks?.onDatabaseUpdated?.();
|
|
3348
|
-
},
|
|
3349
|
-
async updateBundle (targetBundleId, newBundle) {
|
|
3350
|
-
bundles = await this.getBundles();
|
|
3351
|
-
const targetIndex = bundles.findIndex((u)=>u.id === targetBundleId);
|
|
3352
|
-
if (-1 === targetIndex) throw new Error("target bundle version not found");
|
|
3353
|
-
Object.assign(bundles[targetIndex], newBundle);
|
|
3354
|
-
markChanged(targetBundleId);
|
|
3355
|
-
},
|
|
3356
|
-
async appendBundle (inputBundle) {
|
|
3357
|
-
bundles = await this.getBundles();
|
|
3358
|
-
bundles.unshift(inputBundle);
|
|
3359
|
-
markChanged(inputBundle.id);
|
|
3360
|
-
},
|
|
3361
|
-
async getBundleById (bundleId) {
|
|
3362
|
-
try {
|
|
3363
|
-
const { path, headers: routeHeaders } = routes.retrieve(bundleId);
|
|
3364
|
-
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
3365
|
-
method: "GET",
|
|
3366
|
-
headers: getHeaders(routeHeaders)
|
|
3367
|
-
});
|
|
3368
|
-
if (!response.ok) return null;
|
|
3369
|
-
return await response.json();
|
|
3370
|
-
} catch (error) {
|
|
3371
|
-
return null;
|
|
3372
|
-
}
|
|
3373
|
-
},
|
|
3374
|
-
async getBundles (refresh = false) {
|
|
3375
|
-
if (bundles.length > 0 && !refresh) return bundles;
|
|
3376
|
-
const { path, headers: routeHeaders } = routes.list();
|
|
3317
|
+
const standaloneRepository = (config, hooks)=>{
|
|
3318
|
+
const routes = {
|
|
3319
|
+
upsert: ()=>standaloneRepository_createRoute(standaloneRepository_defaultRoutes.upsert(), config.routes?.upsert?.()),
|
|
3320
|
+
list: ()=>standaloneRepository_createRoute(standaloneRepository_defaultRoutes.list(), config.routes?.list?.()),
|
|
3321
|
+
retrieve: (bundleId)=>standaloneRepository_createRoute(standaloneRepository_defaultRoutes.retrieve(bundleId), config.routes?.retrieve?.(bundleId))
|
|
3322
|
+
};
|
|
3323
|
+
const getHeaders = (routeHeaders)=>({
|
|
3324
|
+
"Content-Type": "application/json",
|
|
3325
|
+
...config.commonHeaders,
|
|
3326
|
+
...routeHeaders
|
|
3327
|
+
});
|
|
3328
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__.createDatabasePlugin)("standalone-repository", {
|
|
3329
|
+
async getBundleById (bundleId) {
|
|
3330
|
+
try {
|
|
3331
|
+
const { path, headers: routeHeaders } = routes.retrieve(bundleId);
|
|
3377
3332
|
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
3378
3333
|
method: "GET",
|
|
3379
3334
|
headers: getHeaders(routeHeaders)
|
|
3380
3335
|
});
|
|
3381
|
-
if (!response.ok)
|
|
3382
|
-
|
|
3383
|
-
|
|
3336
|
+
if (!response.ok) return null;
|
|
3337
|
+
return await response.json();
|
|
3338
|
+
} catch (error) {
|
|
3339
|
+
return null;
|
|
3384
3340
|
}
|
|
3385
|
-
}
|
|
3386
|
-
|
|
3341
|
+
},
|
|
3342
|
+
async getBundles (options) {
|
|
3343
|
+
const { where, limit, offset = 0 } = options ?? {};
|
|
3344
|
+
const { path, headers: routeHeaders } = routes.list();
|
|
3345
|
+
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
3346
|
+
method: "GET",
|
|
3347
|
+
headers: getHeaders(routeHeaders)
|
|
3348
|
+
});
|
|
3349
|
+
if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
|
|
3350
|
+
const bundles = await response.json();
|
|
3351
|
+
let filteredBundles = bundles;
|
|
3352
|
+
if (where?.channel) filteredBundles = filteredBundles.filter((b)=>b.channel === where.channel);
|
|
3353
|
+
if (where?.platform) filteredBundles = filteredBundles.filter((b)=>b.platform === where.platform);
|
|
3354
|
+
if (limit) return filteredBundles.slice(offset, offset + limit);
|
|
3355
|
+
return filteredBundles;
|
|
3356
|
+
},
|
|
3357
|
+
async getChannels () {
|
|
3358
|
+
const allBundles = await this.getBundles();
|
|
3359
|
+
return [
|
|
3360
|
+
...new Set(allBundles.map((b)=>b.channel))
|
|
3361
|
+
];
|
|
3362
|
+
},
|
|
3363
|
+
async commitBundle ({ changedSets }) {
|
|
3364
|
+
const changedBundles = changedSets.map((set)=>set.data);
|
|
3365
|
+
if (0 === changedBundles.length) return;
|
|
3366
|
+
const { path, headers: routeHeaders } = routes.upsert();
|
|
3367
|
+
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
3368
|
+
method: "POST",
|
|
3369
|
+
headers: getHeaders(routeHeaders),
|
|
3370
|
+
body: JSON.stringify(changedBundles)
|
|
3371
|
+
});
|
|
3372
|
+
if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
|
|
3373
|
+
const result = await response.json();
|
|
3374
|
+
if (!result.success) throw new Error("Failed to commit bundles");
|
|
3375
|
+
}
|
|
3376
|
+
}, hooks);
|
|
3377
|
+
};
|
|
3387
3378
|
export { standaloneRepository, standaloneStorage };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DatabasePluginHooks } from "@hot-updater/plugin-core";
|
|
2
2
|
export interface RouteConfig {
|
|
3
3
|
path: string;
|
|
4
4
|
headers?: Record<string, string>;
|
|
@@ -13,4 +13,4 @@ export interface StandaloneRepositoryConfig {
|
|
|
13
13
|
commonHeaders?: Record<string, string>;
|
|
14
14
|
routes?: Routes;
|
|
15
15
|
}
|
|
16
|
-
export declare const standaloneRepository: (config: StandaloneRepositoryConfig, hooks?: DatabasePluginHooks) => (
|
|
16
|
+
export declare const standaloneRepository: (config: StandaloneRepositoryConfig, hooks?: DatabasePluginHooks) => (options: import("@hot-updater/plugin-core").BasePluginArgs) => import("@hot-updater/plugin-core").DatabasePlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/standalone",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@hot-updater/core": "0.
|
|
42
|
-
"@hot-updater/plugin-core": "0.
|
|
41
|
+
"@hot-updater/core": "0.13.1",
|
|
42
|
+
"@hot-updater/plugin-core": "0.13.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"mime": "2.6.0",
|