@hot-updater/plugin-core 0.29.5 → 0.29.6
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/createBlobDatabasePlugin.cjs +449 -41
- package/dist/createBlobDatabasePlugin.d.cts +4 -1
- package/dist/createBlobDatabasePlugin.d.mts +4 -1
- package/dist/createBlobDatabasePlugin.mjs +449 -41
- package/dist/createDatabasePlugin.cjs +143 -2
- package/dist/createDatabasePlugin.d.cts +4 -1
- package/dist/createDatabasePlugin.d.mts +4 -1
- package/dist/createDatabasePlugin.mjs +143 -2
- package/dist/createDatabasePluginGetUpdateInfo.cjs +28 -0
- package/dist/createDatabasePluginGetUpdateInfo.d.cts +27 -0
- package/dist/createDatabasePluginGetUpdateInfo.d.mts +27 -0
- package/dist/createDatabasePluginGetUpdateInfo.mjs +27 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +5 -3
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +3 -1
- package/dist/paginateBundles.cjs +53 -0
- package/dist/paginateBundles.d.cts +18 -0
- package/dist/paginateBundles.d.mts +18 -0
- package/dist/paginateBundles.mjs +53 -0
- package/dist/types/index.d.cts +27 -3
- package/dist/types/index.d.mts +27 -3
- package/package.json +4 -4
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Bundle, DatabaseBundleCursor, DatabaseBundleQueryOrder, Paginated } from "./types/index.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/paginateBundles.d.ts
|
|
4
|
+
declare function paginateBundles({
|
|
5
|
+
bundles,
|
|
6
|
+
limit,
|
|
7
|
+
offset,
|
|
8
|
+
cursor,
|
|
9
|
+
orderBy
|
|
10
|
+
}: {
|
|
11
|
+
bundles: Bundle[];
|
|
12
|
+
limit: number;
|
|
13
|
+
offset?: number;
|
|
14
|
+
cursor?: DatabaseBundleCursor;
|
|
15
|
+
orderBy?: DatabaseBundleQueryOrder;
|
|
16
|
+
}): Paginated<Bundle[]>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { paginateBundles };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { calculatePagination } from "./calculatePagination.mjs";
|
|
2
|
+
import { sortBundles } from "./queryBundles.mjs";
|
|
3
|
+
//#region src/paginateBundles.ts
|
|
4
|
+
function paginateBundles({ bundles, limit, offset, cursor, orderBy }) {
|
|
5
|
+
const sortedBundles = sortBundles(bundles, orderBy);
|
|
6
|
+
const direction = orderBy?.direction ?? "desc";
|
|
7
|
+
const total = sortedBundles.length;
|
|
8
|
+
if (offset !== void 0) {
|
|
9
|
+
const normalizedOffset = Math.max(0, offset);
|
|
10
|
+
const data = limit > 0 ? sortedBundles.slice(normalizedOffset, normalizedOffset + limit) : sortedBundles.slice(normalizedOffset);
|
|
11
|
+
const pagination = calculatePagination(total, {
|
|
12
|
+
limit,
|
|
13
|
+
offset: normalizedOffset
|
|
14
|
+
});
|
|
15
|
+
const nextCursor = data.length > 0 && normalizedOffset + data.length < total ? data.at(-1)?.id : void 0;
|
|
16
|
+
const previousCursor = data.length > 0 && normalizedOffset > 0 ? data[0]?.id : void 0;
|
|
17
|
+
return {
|
|
18
|
+
data,
|
|
19
|
+
pagination: {
|
|
20
|
+
...pagination,
|
|
21
|
+
...nextCursor ? { nextCursor } : {},
|
|
22
|
+
...previousCursor ? { previousCursor } : {}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
let data;
|
|
27
|
+
if (cursor?.after) {
|
|
28
|
+
const candidates = sortedBundles.filter((bundle) => direction === "desc" ? bundle.id.localeCompare(cursor.after) < 0 : bundle.id.localeCompare(cursor.after) > 0);
|
|
29
|
+
data = limit > 0 ? candidates.slice(0, limit) : candidates;
|
|
30
|
+
} else if (cursor?.before) {
|
|
31
|
+
const candidates = sortedBundles.filter((bundle) => direction === "desc" ? bundle.id.localeCompare(cursor.before) > 0 : bundle.id.localeCompare(cursor.before) < 0);
|
|
32
|
+
data = limit > 0 ? candidates.slice(Math.max(0, candidates.length - limit)) : candidates;
|
|
33
|
+
} else data = limit > 0 ? sortedBundles.slice(0, limit) : sortedBundles;
|
|
34
|
+
const startIndex = data.length > 0 ? sortedBundles.findIndex((bundle) => bundle.id === data[0].id) : cursor?.after ? total : 0;
|
|
35
|
+
const pagination = calculatePagination(total, {
|
|
36
|
+
limit,
|
|
37
|
+
offset: startIndex
|
|
38
|
+
});
|
|
39
|
+
const nextCursor = data.length > 0 && startIndex + data.length < total ? data.at(-1)?.id : void 0;
|
|
40
|
+
const previousCursor = data.length > 0 && startIndex > 0 ? data[0]?.id : void 0;
|
|
41
|
+
return {
|
|
42
|
+
data,
|
|
43
|
+
pagination: {
|
|
44
|
+
...pagination,
|
|
45
|
+
...nextCursor ? { nextCursor } : {},
|
|
46
|
+
...previousCursor ? { previousCursor } : {},
|
|
47
|
+
...data.length === 0 && cursor?.after ? { previousCursor: cursor.after } : {},
|
|
48
|
+
...data.length === 0 && cursor?.before ? { nextCursor: cursor.before } : {}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { paginateBundles };
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./utils.cjs";
|
|
2
|
-
import { AppVersionGetBundlesArgs, Bundle, Bundle as Bundle$1, FingerprintGetBundlesArgs, GetBundlesArgs, GetBundlesArgs as GetBundlesArgs$1, Platform, Platform as Platform$1, UpdateInfo, UpdateInfo as UpdateInfo$1 } from "@hot-updater/core";
|
|
2
|
+
import { AppVersionGetBundlesArgs as AppVersionGetBundlesArgs$1, Bundle, Bundle as Bundle$1, FingerprintGetBundlesArgs as FingerprintGetBundlesArgs$1, GetBundlesArgs, GetBundlesArgs as GetBundlesArgs$1, Platform, Platform as Platform$1, UpdateInfo, UpdateInfo as UpdateInfo$1 } from "@hot-updater/core";
|
|
3
3
|
|
|
4
4
|
//#region src/types/index.d.ts
|
|
5
5
|
interface BasePluginArgs {
|
|
@@ -11,6 +11,8 @@ interface PaginationInfo {
|
|
|
11
11
|
hasPreviousPage: boolean;
|
|
12
12
|
currentPage: number;
|
|
13
13
|
totalPages: number;
|
|
14
|
+
nextCursor?: string | null;
|
|
15
|
+
previousCursor?: string | null;
|
|
14
16
|
}
|
|
15
17
|
interface Paginated<TData> {
|
|
16
18
|
data: TData;
|
|
@@ -39,10 +41,32 @@ interface DatabaseBundleQueryOrder {
|
|
|
39
41
|
field: "id";
|
|
40
42
|
direction: "asc" | "desc";
|
|
41
43
|
}
|
|
44
|
+
interface DatabaseBundleCursor {
|
|
45
|
+
/**
|
|
46
|
+
* Fetch the next window after this bundle ID.
|
|
47
|
+
*
|
|
48
|
+
* This is the preferred pagination mode for bundle-management queries.
|
|
49
|
+
*/
|
|
50
|
+
after?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Fetch the previous window before this bundle ID.
|
|
53
|
+
*
|
|
54
|
+
* This is the preferred pagination mode for bundle-management queries.
|
|
55
|
+
*/
|
|
56
|
+
before?: string;
|
|
57
|
+
}
|
|
42
58
|
interface DatabaseBundleQueryOptions {
|
|
43
59
|
where?: DatabaseBundleQueryWhere;
|
|
44
60
|
limit: number;
|
|
45
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Optional page number used by management UIs to keep page boundaries stable
|
|
63
|
+
* even when new bundles are inserted ahead of the current cursor window.
|
|
64
|
+
*/
|
|
65
|
+
page?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Preferred cursor-based pagination for bundle-management queries.
|
|
68
|
+
*/
|
|
69
|
+
cursor?: DatabaseBundleCursor;
|
|
46
70
|
orderBy?: DatabaseBundleQueryOrder;
|
|
47
71
|
}
|
|
48
72
|
interface BuildPluginConfig {
|
|
@@ -392,4 +416,4 @@ interface NativeBuildOptions {
|
|
|
392
416
|
scheme?: string;
|
|
393
417
|
}
|
|
394
418
|
//#endregion
|
|
395
|
-
export { type AppVersionGetBundlesArgs, ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, type Bundle$1 as Bundle, ConfigInput, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, DatabasePlugin, DatabasePluginHooks, type FingerprintGetBundlesArgs, type GetBundlesArgs$1 as GetBundlesArgs, HotUpdaterContext, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, Paginated, PaginatedResult, PaginationInfo, type Platform$1 as Platform, PlatformConfig, RequestEnvContext, SigningConfig, StoragePlugin, StoragePluginHooks, StorageResolveContext, type UpdateInfo$1 as UpdateInfo, supportedIosPlatforms };
|
|
419
|
+
export { type AppVersionGetBundlesArgs$1 as AppVersionGetBundlesArgs, ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, type Bundle$1 as Bundle, ConfigInput, DatabaseBundleCursor, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, DatabasePlugin, DatabasePluginHooks, type FingerprintGetBundlesArgs$1 as FingerprintGetBundlesArgs, type GetBundlesArgs$1 as GetBundlesArgs, HotUpdaterContext, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, Paginated, PaginatedResult, PaginationInfo, type Platform$1 as Platform, PlatformConfig, RequestEnvContext, SigningConfig, StoragePlugin, StoragePluginHooks, StorageResolveContext, type UpdateInfo$1 as UpdateInfo, supportedIosPlatforms };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./utils.mjs";
|
|
2
|
-
import { AppVersionGetBundlesArgs, Bundle, Bundle as Bundle$1, FingerprintGetBundlesArgs, GetBundlesArgs, GetBundlesArgs as GetBundlesArgs$1, Platform, Platform as Platform$1, UpdateInfo, UpdateInfo as UpdateInfo$1 } from "@hot-updater/core";
|
|
2
|
+
import { AppVersionGetBundlesArgs as AppVersionGetBundlesArgs$1, Bundle, Bundle as Bundle$1, FingerprintGetBundlesArgs as FingerprintGetBundlesArgs$1, GetBundlesArgs, GetBundlesArgs as GetBundlesArgs$1, Platform, Platform as Platform$1, UpdateInfo, UpdateInfo as UpdateInfo$1 } from "@hot-updater/core";
|
|
3
3
|
|
|
4
4
|
//#region src/types/index.d.ts
|
|
5
5
|
interface BasePluginArgs {
|
|
@@ -11,6 +11,8 @@ interface PaginationInfo {
|
|
|
11
11
|
hasPreviousPage: boolean;
|
|
12
12
|
currentPage: number;
|
|
13
13
|
totalPages: number;
|
|
14
|
+
nextCursor?: string | null;
|
|
15
|
+
previousCursor?: string | null;
|
|
14
16
|
}
|
|
15
17
|
interface Paginated<TData> {
|
|
16
18
|
data: TData;
|
|
@@ -39,10 +41,32 @@ interface DatabaseBundleQueryOrder {
|
|
|
39
41
|
field: "id";
|
|
40
42
|
direction: "asc" | "desc";
|
|
41
43
|
}
|
|
44
|
+
interface DatabaseBundleCursor {
|
|
45
|
+
/**
|
|
46
|
+
* Fetch the next window after this bundle ID.
|
|
47
|
+
*
|
|
48
|
+
* This is the preferred pagination mode for bundle-management queries.
|
|
49
|
+
*/
|
|
50
|
+
after?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Fetch the previous window before this bundle ID.
|
|
53
|
+
*
|
|
54
|
+
* This is the preferred pagination mode for bundle-management queries.
|
|
55
|
+
*/
|
|
56
|
+
before?: string;
|
|
57
|
+
}
|
|
42
58
|
interface DatabaseBundleQueryOptions {
|
|
43
59
|
where?: DatabaseBundleQueryWhere;
|
|
44
60
|
limit: number;
|
|
45
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Optional page number used by management UIs to keep page boundaries stable
|
|
63
|
+
* even when new bundles are inserted ahead of the current cursor window.
|
|
64
|
+
*/
|
|
65
|
+
page?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Preferred cursor-based pagination for bundle-management queries.
|
|
68
|
+
*/
|
|
69
|
+
cursor?: DatabaseBundleCursor;
|
|
46
70
|
orderBy?: DatabaseBundleQueryOrder;
|
|
47
71
|
}
|
|
48
72
|
interface BuildPluginConfig {
|
|
@@ -392,4 +416,4 @@ interface NativeBuildOptions {
|
|
|
392
416
|
scheme?: string;
|
|
393
417
|
}
|
|
394
418
|
//#endregion
|
|
395
|
-
export { type AppVersionGetBundlesArgs, ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, type Bundle$1 as Bundle, ConfigInput, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, DatabasePlugin, DatabasePluginHooks, type FingerprintGetBundlesArgs, type GetBundlesArgs$1 as GetBundlesArgs, HotUpdaterContext, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, Paginated, PaginatedResult, PaginationInfo, type Platform$1 as Platform, PlatformConfig, RequestEnvContext, SigningConfig, StoragePlugin, StoragePluginHooks, StorageResolveContext, type UpdateInfo$1 as UpdateInfo, supportedIosPlatforms };
|
|
419
|
+
export { type AppVersionGetBundlesArgs$1 as AppVersionGetBundlesArgs, ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, type Bundle$1 as Bundle, ConfigInput, DatabaseBundleCursor, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, DatabasePlugin, DatabasePluginHooks, type FingerprintGetBundlesArgs$1 as FingerprintGetBundlesArgs, type GetBundlesArgs$1 as GetBundlesArgs, HotUpdaterContext, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, Paginated, PaginatedResult, PaginationInfo, type Platform$1 as Platform, PlatformConfig, RequestEnvContext, SigningConfig, StoragePlugin, StoragePluginHooks, StorageResolveContext, type UpdateInfo$1 as UpdateInfo, supportedIosPlatforms };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/plugin-core",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"es-toolkit": "^1.32.0",
|
|
43
43
|
"mime": "^4.0.4",
|
|
44
44
|
"semver": "^7.7.2",
|
|
45
|
-
"@hot-updater/core": "0.29.
|
|
46
|
-
"@hot-updater/js": "0.29.
|
|
45
|
+
"@hot-updater/core": "0.29.6",
|
|
46
|
+
"@hot-updater/js": "0.29.6"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^20",
|
|
50
50
|
"@types/semver": "^7.5.8",
|
|
51
51
|
"typescript": "6.0.2",
|
|
52
|
-
"@hot-updater/test-utils": "0.29.
|
|
52
|
+
"@hot-updater/test-utils": "0.29.6"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsdown",
|