@hot-updater/plugin-core 0.28.0 → 0.29.0

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.
Files changed (50) hide show
  1. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +2 -4
  2. package/dist/calculatePagination.cjs +1 -3
  3. package/dist/{calculatePagination.d.ts → calculatePagination.d.mts} +1 -1
  4. package/dist/{calculatePagination.js → calculatePagination.mjs} +1 -2
  5. package/dist/compressionFormat.cjs +6 -8
  6. package/dist/{compressionFormat.js → compressionFormat.mjs} +2 -4
  7. package/dist/createBlobDatabasePlugin.cjs +31 -34
  8. package/dist/createBlobDatabasePlugin.d.cts +1 -1
  9. package/dist/{createBlobDatabasePlugin.d.ts → createBlobDatabasePlugin.d.mts} +2 -2
  10. package/dist/{createBlobDatabasePlugin.js → createBlobDatabasePlugin.mjs} +29 -31
  11. package/dist/createDatabasePlugin.cjs +26 -17
  12. package/dist/createDatabasePlugin.d.cts +11 -18
  13. package/dist/{createDatabasePlugin.d.ts → createDatabasePlugin.d.mts} +11 -18
  14. package/dist/{createDatabasePlugin.js → createDatabasePlugin.mjs} +26 -16
  15. package/dist/createStorageKeyBuilder.cjs +1 -3
  16. package/dist/{createStorageKeyBuilder.js → createStorageKeyBuilder.mjs} +1 -2
  17. package/dist/createStoragePlugin.cjs +4 -6
  18. package/dist/createStoragePlugin.d.cts +6 -7
  19. package/dist/{createStoragePlugin.d.ts → createStoragePlugin.d.mts} +7 -8
  20. package/dist/{createStoragePlugin.js → createStoragePlugin.mjs} +4 -5
  21. package/dist/filterCompatibleAppVersions.cjs +2 -4
  22. package/dist/{filterCompatibleAppVersions.js → filterCompatibleAppVersions.mjs} +2 -4
  23. package/dist/generateMinBundleId.cjs +1 -3
  24. package/dist/{generateMinBundleId.js → generateMinBundleId.mjs} +1 -2
  25. package/dist/index.cjs +17 -13
  26. package/dist/index.d.cts +3 -2
  27. package/dist/index.d.mts +14 -0
  28. package/dist/index.mjs +13 -0
  29. package/dist/parseStorageUri.cjs +1 -3
  30. package/dist/{parseStorageUri.js → parseStorageUri.mjs} +1 -2
  31. package/dist/queryBundles.cjs +40 -0
  32. package/dist/queryBundles.d.cts +8 -0
  33. package/dist/queryBundles.d.mts +8 -0
  34. package/dist/queryBundles.mjs +38 -0
  35. package/dist/semverSatisfies.cjs +3 -5
  36. package/dist/{semverSatisfies.js → semverSatisfies.mjs} +1 -3
  37. package/dist/types/index.cjs +1 -3
  38. package/dist/types/index.d.cts +45 -18
  39. package/dist/types/{index.d.ts → index.d.mts} +46 -19
  40. package/dist/types/{index.js → index.mjs} +1 -2
  41. package/package.json +6 -5
  42. package/dist/index.d.ts +0 -13
  43. package/dist/index.js +0 -13
  44. /package/dist/{compressionFormat.d.ts → compressionFormat.d.mts} +0 -0
  45. /package/dist/{createStorageKeyBuilder.d.ts → createStorageKeyBuilder.d.mts} +0 -0
  46. /package/dist/{filterCompatibleAppVersions.d.ts → filterCompatibleAppVersions.d.mts} +0 -0
  47. /package/dist/{generateMinBundleId.d.ts → generateMinBundleId.d.mts} +0 -0
  48. /package/dist/{parseStorageUri.d.ts → parseStorageUri.d.mts} +0 -0
  49. /package/dist/{semverSatisfies.d.ts → semverSatisfies.d.mts} +0 -0
  50. /package/dist/types/{utils.d.ts → utils.d.mts} +0 -0
@@ -12,29 +12,50 @@ interface PaginationInfo {
12
12
  currentPage: number;
13
13
  totalPages: number;
14
14
  }
15
+ interface DatabaseBundleIdFilter {
16
+ eq?: string;
17
+ gt?: string;
18
+ gte?: string;
19
+ lt?: string;
20
+ lte?: string;
21
+ in?: string[];
22
+ }
23
+ interface DatabaseBundleQueryWhere {
24
+ channel?: string;
25
+ platform?: Platform;
26
+ enabled?: boolean;
27
+ id?: DatabaseBundleIdFilter;
28
+ targetAppVersion?: string | null;
29
+ targetAppVersionIn?: string[];
30
+ targetAppVersionNotNull?: boolean;
31
+ fingerprintHash?: string | null;
32
+ }
33
+ interface DatabaseBundleQueryOrder {
34
+ field: "id";
35
+ direction: "asc" | "desc";
36
+ }
37
+ interface DatabaseBundleQueryOptions {
38
+ where?: DatabaseBundleQueryWhere;
39
+ limit: number;
40
+ offset: number;
41
+ orderBy?: DatabaseBundleQueryOrder;
42
+ }
15
43
  interface BuildPluginConfig {
16
44
  outDir?: string;
17
45
  }
18
- interface DatabasePlugin {
19
- getChannels: () => Promise<string[]>;
20
- getBundleById: (bundleId: string) => Promise<Bundle | null>;
21
- getBundles: (options: {
22
- where?: {
23
- channel?: string;
24
- platform?: string;
25
- };
26
- limit: number;
27
- offset: number;
28
- }) => Promise<{
46
+ interface DatabasePlugin<TContext = unknown> {
47
+ getChannels: (context?: HotUpdaterContext<TContext>) => Promise<string[]>;
48
+ getBundleById: (bundleId: string, context?: HotUpdaterContext<TContext>) => Promise<Bundle | null>;
49
+ getBundles: (options: DatabaseBundleQueryOptions, context?: HotUpdaterContext<TContext>) => Promise<{
29
50
  data: Bundle[];
30
51
  pagination: PaginationInfo;
31
52
  }>;
32
- updateBundle: (targetBundleId: string, newBundle: Partial<Bundle>) => Promise<void>;
33
- appendBundle: (insertBundle: Bundle) => Promise<void>;
34
- commitBundle: () => Promise<void>;
53
+ updateBundle: (targetBundleId: string, newBundle: Partial<Bundle>, context?: HotUpdaterContext<TContext>) => Promise<void>;
54
+ appendBundle: (insertBundle: Bundle, context?: HotUpdaterContext<TContext>) => Promise<void>;
55
+ commitBundle: (context?: HotUpdaterContext<TContext>) => Promise<void>;
35
56
  onUnmount?: () => Promise<void>;
36
57
  name: string;
37
- deleteBundle: (deleteBundle: Bundle) => Promise<void>;
58
+ deleteBundle: (deleteBundle: Bundle, context?: HotUpdaterContext<TContext>) => Promise<void>;
38
59
  }
39
60
  interface DatabasePluginHooks {
40
61
  onDatabaseUpdated?: () => Promise<void>;
@@ -215,7 +236,13 @@ interface NativeBuildArgs {
215
236
  */
216
237
  ios?: Record<string, NativeBuildIosScheme>;
217
238
  }
218
- interface StoragePlugin {
239
+ interface RequestEnvContext<TEnv = unknown> {
240
+ request?: Request;
241
+ env?: TEnv;
242
+ }
243
+ type HotUpdaterContext<TContext = unknown> = TContext;
244
+ type StorageResolveContext<TContext = unknown> = HotUpdaterContext<TContext>;
245
+ interface StoragePlugin<TContext = unknown> {
219
246
  /**
220
247
  * Protocol this storage plugin can resolve.
221
248
  * @example "s3", "r2", "supabase-storage".
@@ -225,7 +252,7 @@ interface StoragePlugin {
225
252
  storageUri: string;
226
253
  }>;
227
254
  delete: (storageUri: string) => Promise<void>;
228
- getDownloadUrl: (storageUri: string) => Promise<{
255
+ getDownloadUrl: (storageUri: string, context?: StorageResolveContext<TContext>) => Promise<{
229
256
  fileUrl: string;
230
257
  }>;
231
258
  name: string;
@@ -362,4 +389,4 @@ interface NativeBuildOptions {
362
389
  scheme?: string;
363
390
  }
364
391
  //#endregion
365
- export { ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, type Bundle$1 as Bundle, ConfigInput, DatabasePlugin, DatabasePluginHooks, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, PaginationInfo, type Platform$1 as Platform, PlatformConfig, SigningConfig, StoragePlugin, StoragePluginHooks, supportedIosPlatforms };
392
+ export { ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, type Bundle$1 as Bundle, ConfigInput, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, DatabasePlugin, DatabasePluginHooks, HotUpdaterContext, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, PaginationInfo, type Platform$1 as Platform, PlatformConfig, RequestEnvContext, SigningConfig, StoragePlugin, StoragePluginHooks, StorageResolveContext, supportedIosPlatforms };
@@ -1,4 +1,4 @@
1
- import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./utils.js";
1
+ import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./utils.mjs";
2
2
  import { Bundle, Bundle as Bundle$1, Platform, Platform as Platform$1 } from "@hot-updater/core";
3
3
 
4
4
  //#region src/types/index.d.ts
@@ -12,29 +12,50 @@ interface PaginationInfo {
12
12
  currentPage: number;
13
13
  totalPages: number;
14
14
  }
15
+ interface DatabaseBundleIdFilter {
16
+ eq?: string;
17
+ gt?: string;
18
+ gte?: string;
19
+ lt?: string;
20
+ lte?: string;
21
+ in?: string[];
22
+ }
23
+ interface DatabaseBundleQueryWhere {
24
+ channel?: string;
25
+ platform?: Platform;
26
+ enabled?: boolean;
27
+ id?: DatabaseBundleIdFilter;
28
+ targetAppVersion?: string | null;
29
+ targetAppVersionIn?: string[];
30
+ targetAppVersionNotNull?: boolean;
31
+ fingerprintHash?: string | null;
32
+ }
33
+ interface DatabaseBundleQueryOrder {
34
+ field: "id";
35
+ direction: "asc" | "desc";
36
+ }
37
+ interface DatabaseBundleQueryOptions {
38
+ where?: DatabaseBundleQueryWhere;
39
+ limit: number;
40
+ offset: number;
41
+ orderBy?: DatabaseBundleQueryOrder;
42
+ }
15
43
  interface BuildPluginConfig {
16
44
  outDir?: string;
17
45
  }
18
- interface DatabasePlugin {
19
- getChannels: () => Promise<string[]>;
20
- getBundleById: (bundleId: string) => Promise<Bundle | null>;
21
- getBundles: (options: {
22
- where?: {
23
- channel?: string;
24
- platform?: string;
25
- };
26
- limit: number;
27
- offset: number;
28
- }) => Promise<{
46
+ interface DatabasePlugin<TContext = unknown> {
47
+ getChannels: (context?: HotUpdaterContext<TContext>) => Promise<string[]>;
48
+ getBundleById: (bundleId: string, context?: HotUpdaterContext<TContext>) => Promise<Bundle | null>;
49
+ getBundles: (options: DatabaseBundleQueryOptions, context?: HotUpdaterContext<TContext>) => Promise<{
29
50
  data: Bundle[];
30
51
  pagination: PaginationInfo;
31
52
  }>;
32
- updateBundle: (targetBundleId: string, newBundle: Partial<Bundle>) => Promise<void>;
33
- appendBundle: (insertBundle: Bundle) => Promise<void>;
34
- commitBundle: () => Promise<void>;
53
+ updateBundle: (targetBundleId: string, newBundle: Partial<Bundle>, context?: HotUpdaterContext<TContext>) => Promise<void>;
54
+ appendBundle: (insertBundle: Bundle, context?: HotUpdaterContext<TContext>) => Promise<void>;
55
+ commitBundle: (context?: HotUpdaterContext<TContext>) => Promise<void>;
35
56
  onUnmount?: () => Promise<void>;
36
57
  name: string;
37
- deleteBundle: (deleteBundle: Bundle) => Promise<void>;
58
+ deleteBundle: (deleteBundle: Bundle, context?: HotUpdaterContext<TContext>) => Promise<void>;
38
59
  }
39
60
  interface DatabasePluginHooks {
40
61
  onDatabaseUpdated?: () => Promise<void>;
@@ -215,7 +236,13 @@ interface NativeBuildArgs {
215
236
  */
216
237
  ios?: Record<string, NativeBuildIosScheme>;
217
238
  }
218
- interface StoragePlugin {
239
+ interface RequestEnvContext<TEnv = unknown> {
240
+ request?: Request;
241
+ env?: TEnv;
242
+ }
243
+ type HotUpdaterContext<TContext = unknown> = TContext;
244
+ type StorageResolveContext<TContext = unknown> = HotUpdaterContext<TContext>;
245
+ interface StoragePlugin<TContext = unknown> {
219
246
  /**
220
247
  * Protocol this storage plugin can resolve.
221
248
  * @example "s3", "r2", "supabase-storage".
@@ -225,7 +252,7 @@ interface StoragePlugin {
225
252
  storageUri: string;
226
253
  }>;
227
254
  delete: (storageUri: string) => Promise<void>;
228
- getDownloadUrl: (storageUri: string) => Promise<{
255
+ getDownloadUrl: (storageUri: string, context?: StorageResolveContext<TContext>) => Promise<{
229
256
  fileUrl: string;
230
257
  }>;
231
258
  name: string;
@@ -362,4 +389,4 @@ interface NativeBuildOptions {
362
389
  scheme?: string;
363
390
  }
364
391
  //#endregion
365
- export { ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, type Bundle$1 as Bundle, ConfigInput, DatabasePlugin, DatabasePluginHooks, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, PaginationInfo, type Platform$1 as Platform, PlatformConfig, SigningConfig, StoragePlugin, StoragePluginHooks, supportedIosPlatforms };
392
+ export { ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, type Bundle$1 as Bundle, ConfigInput, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, DatabasePlugin, DatabasePluginHooks, HotUpdaterContext, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, PaginationInfo, type Platform$1 as Platform, PlatformConfig, RequestEnvContext, SigningConfig, StoragePlugin, StoragePluginHooks, StorageResolveContext, supportedIosPlatforms };
@@ -3,6 +3,5 @@
3
3
  * Supported Apple platforms for building and deployment
4
4
  */
5
5
  const supportedIosPlatforms = { ios: "ios" };
6
-
7
6
  //#endregion
8
- export { supportedIosPlatforms };
7
+ export { supportedIosPlatforms };
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@hot-updater/plugin-core",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "type": "module",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.cjs",
8
- "module": "./dist/index.js",
8
+ "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.cts",
10
10
  "exports": {
11
11
  ".": {
12
- "import": "./dist/index.js",
12
+ "import": "./dist/index.mjs",
13
13
  "require": "./dist/index.cjs"
14
14
  },
15
15
  "./package.json": "./package.json"
@@ -42,12 +42,13 @@
42
42
  "es-toolkit": "^1.32.0",
43
43
  "mime": "^4.0.4",
44
44
  "semver": "^7.7.2",
45
- "@hot-updater/core": "0.28.0"
45
+ "@hot-updater/core": "0.29.0"
46
46
  },
47
47
  "devDependencies": {
48
+ "@types/node": "^20",
48
49
  "@types/semver": "^7.5.8",
49
50
  "typescript": "5.8.2",
50
- "@hot-updater/test-utils": "0.28.0"
51
+ "@hot-updater/test-utils": "0.29.0"
51
52
  },
52
53
  "scripts": {
53
54
  "build": "tsdown",
package/dist/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./types/utils.js";
2
- import { ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, Bundle, ConfigInput, DatabasePlugin, DatabasePluginHooks, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, PaginationInfo, Platform, PlatformConfig, SigningConfig, StoragePlugin, StoragePluginHooks, supportedIosPlatforms } from "./types/index.js";
3
- import { PaginatedResult, PaginationOptions, calculatePagination } from "./calculatePagination.js";
4
- import { CompressionFormat, CompressionFormatInfo, detectCompressionFormat, getCompressionMimeType, getContentType } from "./compressionFormat.js";
5
- import { BlobOperations, createBlobDatabasePlugin } from "./createBlobDatabasePlugin.js";
6
- import { AbstractDatabasePlugin, CreateDatabasePluginOptions, createDatabasePlugin } from "./createDatabasePlugin.js";
7
- import { createStorageKeyBuilder } from "./createStorageKeyBuilder.js";
8
- import { CreateStoragePluginOptions, createStoragePlugin } from "./createStoragePlugin.js";
9
- import { filterCompatibleAppVersions } from "./filterCompatibleAppVersions.js";
10
- import { generateMinBundleId } from "./generateMinBundleId.js";
11
- import { ParsedStorageUri, parseStorageUri } from "./parseStorageUri.js";
12
- import { semverSatisfies } from "./semverSatisfies.js";
13
- export { AbstractDatabasePlugin, ApplePlatform, BasePluginArgs, BlobOperations, BuildPlugin, BuildPluginConfig, BuiltIns, Bundle, CompressionFormat, CompressionFormatInfo, ConfigInput, CreateDatabasePluginOptions, CreateStoragePluginOptions, DatabasePlugin, DatabasePluginHooks, HasMultipleCallSignatures, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, PaginatedResult, PaginationInfo, PaginationOptions, ParsedStorageUri, Platform, PlatformConfig, Primitive, RequiredDeep, SigningConfig, StoragePlugin, StoragePluginHooks, calculatePagination, createBlobDatabasePlugin, createDatabasePlugin, createStorageKeyBuilder, createStoragePlugin, detectCompressionFormat, filterCompatibleAppVersions, generateMinBundleId, getCompressionMimeType, getContentType, parseStorageUri, semverSatisfies, supportedIosPlatforms };
package/dist/index.js DELETED
@@ -1,13 +0,0 @@
1
- import { calculatePagination } from "./calculatePagination.js";
2
- import { detectCompressionFormat, getCompressionMimeType, getContentType } from "./compressionFormat.js";
3
- import { createDatabasePlugin } from "./createDatabasePlugin.js";
4
- import { createBlobDatabasePlugin } from "./createBlobDatabasePlugin.js";
5
- import { createStorageKeyBuilder } from "./createStorageKeyBuilder.js";
6
- import { createStoragePlugin } from "./createStoragePlugin.js";
7
- import { semverSatisfies } from "./semverSatisfies.js";
8
- import { filterCompatibleAppVersions } from "./filterCompatibleAppVersions.js";
9
- import { generateMinBundleId } from "./generateMinBundleId.js";
10
- import { parseStorageUri } from "./parseStorageUri.js";
11
- import { supportedIosPlatforms } from "./types/index.js";
12
-
13
- export { calculatePagination, createBlobDatabasePlugin, createDatabasePlugin, createStorageKeyBuilder, createStoragePlugin, detectCompressionFormat, filterCompatibleAppVersions, generateMinBundleId, getCompressionMimeType, getContentType, parseStorageUri, semverSatisfies, supportedIosPlatforms };
File without changes