@hot-updater/plugin-core 0.18.0 → 0.18.2

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.d.cts CHANGED
@@ -8,29 +8,39 @@ declare const log: {
8
8
  error: (message: string | number | null | undefined) => void;
9
9
  warn: (message: string | number | null | undefined) => void;
10
10
  debug: (message: string | number | null | undefined) => void;
11
- }; //#endregion
11
+ };
12
+ //#endregion
12
13
  //#region src/cwd.d.ts
13
14
  declare const getCwd: () => string;
14
-
15
15
  //#endregion
16
16
  //#region src/types/index.d.ts
17
17
  interface BasePluginArgs {
18
18
  cwd: string;
19
19
  }
20
+ interface PaginationInfo {
21
+ total: number;
22
+ hasNextPage: boolean;
23
+ hasPreviousPage: boolean;
24
+ currentPage: number;
25
+ totalPages: number;
26
+ }
20
27
  interface BuildPluginConfig {
21
28
  outDir?: string;
22
29
  }
23
30
  interface DatabasePlugin {
24
31
  getChannels: () => Promise<string[]>;
25
32
  getBundleById: (bundleId: string) => Promise<Bundle$1 | null>;
26
- getBundles: (options?: {
33
+ getBundles: (options: {
27
34
  where?: {
28
35
  channel?: string;
29
- platform?: Platform$1;
36
+ platform?: string;
30
37
  };
31
- limit?: number;
32
- offset?: number;
33
- }) => Promise<Bundle$1[]>;
38
+ limit: number;
39
+ offset: number;
40
+ }) => Promise<{
41
+ data: Bundle$1[];
42
+ pagination: PaginationInfo;
43
+ }>;
34
44
  updateBundle: (targetBundleId: string, newBundle: Partial<Bundle$1>) => Promise<void>;
35
45
  appendBundle: (bundles: Bundle$1) => Promise<void>;
36
46
  commitBundle: () => Promise<void>;
@@ -101,7 +111,8 @@ type ConfigInput = {
101
111
  build: (args: BasePluginArgs) => Promise<BuildPlugin> | BuildPlugin;
102
112
  storage: (args: BasePluginArgs) => Promise<StoragePlugin> | StoragePlugin;
103
113
  database: (args: BasePluginArgs) => Promise<DatabasePlugin> | DatabasePlugin;
104
- }; //#endregion
114
+ };
115
+ //#endregion
105
116
  //#region src/types/utils.d.ts
106
117
  type Primitive = null | undefined | string | number | boolean | symbol | bigint;
107
118
  type BuiltIns = Primitive | void | Date | RegExp;
@@ -112,7 +123,6 @@ type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T
112
123
  } ? B extends A ? A extends B ? false : true : true : false;
113
124
  type RequiredDeep<T, E extends ExcludeUndefined<T> = ExcludeUndefined<T>> = E extends BuiltIns ? E : E extends Map<infer KeyType, infer ValueType> ? Map<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends Set<infer ItemType> ? Set<RequiredDeep<ItemType>> : E extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends ReadonlySet<infer ItemType> ? ReadonlySet<RequiredDeep<ItemType>> : E extends WeakMap<infer KeyType, infer ValueType> ? WeakMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends WeakSet<infer ItemType> ? WeakSet<RequiredDeep<ItemType>> : E extends Promise<infer ValueType> ? Promise<RequiredDeep<ValueType>> : E extends ((...arguments_: any[]) => unknown) ? {} extends RequiredObjectDeep<E> ? E : HasMultipleCallSignatures<E> extends true ? E : ((...arguments_: Parameters<E>) => ReturnType<E>) & RequiredObjectDeep<E> : E extends object ? E extends Array<infer ItemType> ? ItemType[] extends E ? Array<RequiredDeep<ItemType>> : RequiredObjectDeep<E> : RequiredObjectDeep<E> : unknown;
114
125
  type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
115
-
116
126
  //#endregion
117
127
  //#region src/loadConfig.d.ts
118
128
  type HotUpdaterConfigOptions = {
@@ -122,14 +132,12 @@ type HotUpdaterConfigOptions = {
122
132
  type ConfigResponse = RequiredDeep<ConfigInput>;
123
133
  declare const loadConfig: (options: HotUpdaterConfigOptions) => Promise<ConfigResponse>;
124
134
  declare const loadConfigSync: (options: HotUpdaterConfigOptions) => ConfigResponse;
125
-
126
135
  //#endregion
127
136
  //#region src/copyDirToTmp.d.ts
128
137
  declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
129
138
  tmpDir: string;
130
139
  removeTmpDir: () => Promise<void>;
131
140
  }>;
132
-
133
141
  //#endregion
134
142
  //#region src/createDatabasePlugin.d.ts
135
143
  interface BaseDatabaseUtils {
@@ -138,14 +146,17 @@ interface BaseDatabaseUtils {
138
146
  interface AbstractDatabasePlugin<TContext = object> {
139
147
  getContext?: () => TContext;
140
148
  getBundleById: (context: TContext, bundleId: string) => Promise<Bundle$1 | null>;
141
- getBundles: (context: TContext, options?: {
149
+ getBundles: (context: TContext, options: {
142
150
  where?: {
143
151
  channel?: string;
144
152
  platform?: string;
145
153
  };
146
- limit?: number;
147
- offset?: number;
148
- }) => Promise<Bundle$1[]>;
154
+ limit: number;
155
+ offset: number;
156
+ }) => Promise<{
157
+ data: Bundle$1[];
158
+ pagination: PaginationInfo;
159
+ }>;
149
160
  getChannels: (context: TContext) => Promise<string[]>;
150
161
  onUnmount?: (context: TContext) => void;
151
162
  commitBundle: (context: TContext, {
@@ -191,13 +202,11 @@ interface AbstractDatabasePlugin<TContext = object> {
191
202
  * @returns A function that creates a database plugin instance
192
203
  */
193
204
  declare function createDatabasePlugin<TContext = object>(name: string, abstractPlugin: AbstractDatabasePlugin<TContext>, hooks?: DatabasePluginHooks): (options: BasePluginArgs) => DatabasePlugin;
194
-
195
205
  //#endregion
196
206
  //#region src/banner.d.ts
197
207
  declare const link: (url: string) => string;
198
208
  declare const banner: (version?: string) => string;
199
209
  declare const printBanner: (version?: string) => void;
200
-
201
210
  //#endregion
202
211
  //#region src/transformTemplate.d.ts
203
212
  type ExtractPlaceholders<T extends string> = T extends `${infer _Start}%%${infer Key}%%${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
@@ -212,11 +221,9 @@ type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]
212
221
  * // Result: "Hello John, you are 20 years old."
213
222
  */
214
223
  declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
215
-
216
224
  //#endregion
217
225
  //#region src/transformEnv.d.ts
218
226
  declare const transformEnv: <T extends Record<string, string>>(filename: string, env: T) => string;
219
-
220
227
  //#endregion
221
228
  //#region src/makeEnv.d.ts
222
229
  type EnvVarValue = string | {
@@ -224,7 +231,6 @@ type EnvVarValue = string | {
224
231
  value: string;
225
232
  };
226
233
  declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
227
-
228
234
  //#endregion
229
235
  //#region src/createZip.d.ts
230
236
  declare const createZipTargetFiles: ({
@@ -246,7 +252,6 @@ declare const createZip: ({
246
252
  outfile: string;
247
253
  excludeExts?: string[];
248
254
  }) => Promise<string>;
249
-
250
255
  //#endregion
251
256
  //#region src/createBlobDatabasePlugin.d.ts
252
257
  /**
@@ -281,7 +286,6 @@ declare const createBlobDatabasePlugin: <TContext = object>({
281
286
  hooks?: DatabasePluginHooks;
282
287
  apiBasePath: string;
283
288
  }) => (options: BasePluginArgs) => DatabasePlugin;
284
-
285
289
  //#endregion
286
290
  //#region src/ConfigBuilder.d.ts
287
291
  type BuildType = "bare" | "rnef" | "expo";
@@ -324,6 +328,19 @@ declare class ConfigBuilder implements IConfigBuilder {
324
328
  setIntermediateCode(code: string): this;
325
329
  getResult(): string;
326
330
  }
327
-
328
331
  //#endregion
329
- export { AbstractDatabasePlugin, BaseDatabaseUtils, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuildType, Bundle, ConfigBuilder, ConfigInput, ConfigResponse, DatabasePlugin, DatabasePluginHooks, HotUpdaterConfigOptions, IConfigBuilder, ImportInfo, Platform, ProviderConfig, StoragePlugin, StoragePluginHooks, banner, copyDirToTmp, createBlobDatabasePlugin, createDatabasePlugin, createZip, createZipTargetFiles, getCwd, link, loadConfig, loadConfigSync, log, makeEnv, printBanner, transformEnv, transformTemplate };
332
+ //#region src/calculatePagination.d.ts
333
+ interface PaginationOptions {
334
+ limit: number;
335
+ offset: number;
336
+ }
337
+ interface PaginatedResult {
338
+ data: Bundle[];
339
+ pagination: PaginationInfo;
340
+ }
341
+ /**
342
+ * Calculate pagination information based on total count, limit, and offset
343
+ */
344
+ declare function calculatePagination(total: number, options: PaginationOptions): PaginationInfo;
345
+ //#endregion
346
+ export { AbstractDatabasePlugin, BaseDatabaseUtils, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuildType, Bundle, ConfigBuilder, ConfigInput, ConfigResponse, DatabasePlugin, DatabasePluginHooks, HotUpdaterConfigOptions, IConfigBuilder, ImportInfo, PaginatedResult, PaginationInfo, PaginationOptions, Platform, ProviderConfig, StoragePlugin, StoragePluginHooks, banner, calculatePagination, copyDirToTmp, createBlobDatabasePlugin, createDatabasePlugin, createZip, createZipTargetFiles, getCwd, link, loadConfig, loadConfigSync, log, makeEnv, printBanner, transformEnv, transformTemplate };
package/dist/index.d.ts CHANGED
@@ -8,29 +8,39 @@ declare const log: {
8
8
  error: (message: string | number | null | undefined) => void;
9
9
  warn: (message: string | number | null | undefined) => void;
10
10
  debug: (message: string | number | null | undefined) => void;
11
- }; //#endregion
11
+ };
12
+ //#endregion
12
13
  //#region src/cwd.d.ts
13
14
  declare const getCwd: () => string;
14
-
15
15
  //#endregion
16
16
  //#region src/types/index.d.ts
17
17
  interface BasePluginArgs {
18
18
  cwd: string;
19
19
  }
20
+ interface PaginationInfo {
21
+ total: number;
22
+ hasNextPage: boolean;
23
+ hasPreviousPage: boolean;
24
+ currentPage: number;
25
+ totalPages: number;
26
+ }
20
27
  interface BuildPluginConfig {
21
28
  outDir?: string;
22
29
  }
23
30
  interface DatabasePlugin {
24
31
  getChannels: () => Promise<string[]>;
25
32
  getBundleById: (bundleId: string) => Promise<Bundle$1 | null>;
26
- getBundles: (options?: {
33
+ getBundles: (options: {
27
34
  where?: {
28
35
  channel?: string;
29
- platform?: Platform$1;
36
+ platform?: string;
30
37
  };
31
- limit?: number;
32
- offset?: number;
33
- }) => Promise<Bundle$1[]>;
38
+ limit: number;
39
+ offset: number;
40
+ }) => Promise<{
41
+ data: Bundle$1[];
42
+ pagination: PaginationInfo;
43
+ }>;
34
44
  updateBundle: (targetBundleId: string, newBundle: Partial<Bundle$1>) => Promise<void>;
35
45
  appendBundle: (bundles: Bundle$1) => Promise<void>;
36
46
  commitBundle: () => Promise<void>;
@@ -101,7 +111,8 @@ type ConfigInput = {
101
111
  build: (args: BasePluginArgs) => Promise<BuildPlugin> | BuildPlugin;
102
112
  storage: (args: BasePluginArgs) => Promise<StoragePlugin> | StoragePlugin;
103
113
  database: (args: BasePluginArgs) => Promise<DatabasePlugin> | DatabasePlugin;
104
- }; //#endregion
114
+ };
115
+ //#endregion
105
116
  //#region src/types/utils.d.ts
106
117
  type Primitive = null | undefined | string | number | boolean | symbol | bigint;
107
118
  type BuiltIns = Primitive | void | Date | RegExp;
@@ -112,7 +123,6 @@ type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T
112
123
  } ? B extends A ? A extends B ? false : true : true : false;
113
124
  type RequiredDeep<T, E extends ExcludeUndefined<T> = ExcludeUndefined<T>> = E extends BuiltIns ? E : E extends Map<infer KeyType, infer ValueType> ? Map<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends Set<infer ItemType> ? Set<RequiredDeep<ItemType>> : E extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends ReadonlySet<infer ItemType> ? ReadonlySet<RequiredDeep<ItemType>> : E extends WeakMap<infer KeyType, infer ValueType> ? WeakMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends WeakSet<infer ItemType> ? WeakSet<RequiredDeep<ItemType>> : E extends Promise<infer ValueType> ? Promise<RequiredDeep<ValueType>> : E extends ((...arguments_: any[]) => unknown) ? {} extends RequiredObjectDeep<E> ? E : HasMultipleCallSignatures<E> extends true ? E : ((...arguments_: Parameters<E>) => ReturnType<E>) & RequiredObjectDeep<E> : E extends object ? E extends Array<infer ItemType> ? ItemType[] extends E ? Array<RequiredDeep<ItemType>> : RequiredObjectDeep<E> : RequiredObjectDeep<E> : unknown;
114
125
  type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
115
-
116
126
  //#endregion
117
127
  //#region src/loadConfig.d.ts
118
128
  type HotUpdaterConfigOptions = {
@@ -122,14 +132,12 @@ type HotUpdaterConfigOptions = {
122
132
  type ConfigResponse = RequiredDeep<ConfigInput>;
123
133
  declare const loadConfig: (options: HotUpdaterConfigOptions) => Promise<ConfigResponse>;
124
134
  declare const loadConfigSync: (options: HotUpdaterConfigOptions) => ConfigResponse;
125
-
126
135
  //#endregion
127
136
  //#region src/copyDirToTmp.d.ts
128
137
  declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
129
138
  tmpDir: string;
130
139
  removeTmpDir: () => Promise<void>;
131
140
  }>;
132
-
133
141
  //#endregion
134
142
  //#region src/createDatabasePlugin.d.ts
135
143
  interface BaseDatabaseUtils {
@@ -138,14 +146,17 @@ interface BaseDatabaseUtils {
138
146
  interface AbstractDatabasePlugin<TContext = object> {
139
147
  getContext?: () => TContext;
140
148
  getBundleById: (context: TContext, bundleId: string) => Promise<Bundle$1 | null>;
141
- getBundles: (context: TContext, options?: {
149
+ getBundles: (context: TContext, options: {
142
150
  where?: {
143
151
  channel?: string;
144
152
  platform?: string;
145
153
  };
146
- limit?: number;
147
- offset?: number;
148
- }) => Promise<Bundle$1[]>;
154
+ limit: number;
155
+ offset: number;
156
+ }) => Promise<{
157
+ data: Bundle$1[];
158
+ pagination: PaginationInfo;
159
+ }>;
149
160
  getChannels: (context: TContext) => Promise<string[]>;
150
161
  onUnmount?: (context: TContext) => void;
151
162
  commitBundle: (context: TContext, {
@@ -191,13 +202,11 @@ interface AbstractDatabasePlugin<TContext = object> {
191
202
  * @returns A function that creates a database plugin instance
192
203
  */
193
204
  declare function createDatabasePlugin<TContext = object>(name: string, abstractPlugin: AbstractDatabasePlugin<TContext>, hooks?: DatabasePluginHooks): (options: BasePluginArgs) => DatabasePlugin;
194
-
195
205
  //#endregion
196
206
  //#region src/banner.d.ts
197
207
  declare const link: (url: string) => string;
198
208
  declare const banner: (version?: string) => string;
199
209
  declare const printBanner: (version?: string) => void;
200
-
201
210
  //#endregion
202
211
  //#region src/transformTemplate.d.ts
203
212
  type ExtractPlaceholders<T extends string> = T extends `${infer _Start}%%${infer Key}%%${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
@@ -212,11 +221,9 @@ type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]
212
221
  * // Result: "Hello John, you are 20 years old."
213
222
  */
214
223
  declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
215
-
216
224
  //#endregion
217
225
  //#region src/transformEnv.d.ts
218
226
  declare const transformEnv: <T extends Record<string, string>>(filename: string, env: T) => string;
219
-
220
227
  //#endregion
221
228
  //#region src/makeEnv.d.ts
222
229
  type EnvVarValue = string | {
@@ -224,7 +231,6 @@ type EnvVarValue = string | {
224
231
  value: string;
225
232
  };
226
233
  declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
227
-
228
234
  //#endregion
229
235
  //#region src/createZip.d.ts
230
236
  declare const createZipTargetFiles: ({
@@ -246,7 +252,6 @@ declare const createZip: ({
246
252
  outfile: string;
247
253
  excludeExts?: string[];
248
254
  }) => Promise<string>;
249
-
250
255
  //#endregion
251
256
  //#region src/createBlobDatabasePlugin.d.ts
252
257
  /**
@@ -281,7 +286,6 @@ declare const createBlobDatabasePlugin: <TContext = object>({
281
286
  hooks?: DatabasePluginHooks;
282
287
  apiBasePath: string;
283
288
  }) => (options: BasePluginArgs) => DatabasePlugin;
284
-
285
289
  //#endregion
286
290
  //#region src/ConfigBuilder.d.ts
287
291
  type BuildType = "bare" | "rnef" | "expo";
@@ -324,6 +328,19 @@ declare class ConfigBuilder implements IConfigBuilder {
324
328
  setIntermediateCode(code: string): this;
325
329
  getResult(): string;
326
330
  }
327
-
328
331
  //#endregion
329
- export { AbstractDatabasePlugin, BaseDatabaseUtils, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuildType, Bundle, ConfigBuilder, ConfigInput, ConfigResponse, DatabasePlugin, DatabasePluginHooks, HotUpdaterConfigOptions, IConfigBuilder, ImportInfo, Platform, ProviderConfig, StoragePlugin, StoragePluginHooks, banner, copyDirToTmp, createBlobDatabasePlugin, createDatabasePlugin, createZip, createZipTargetFiles, getCwd, link, loadConfig, loadConfigSync, log, makeEnv, printBanner, transformEnv, transformTemplate };
332
+ //#region src/calculatePagination.d.ts
333
+ interface PaginationOptions {
334
+ limit: number;
335
+ offset: number;
336
+ }
337
+ interface PaginatedResult {
338
+ data: Bundle[];
339
+ pagination: PaginationInfo;
340
+ }
341
+ /**
342
+ * Calculate pagination information based on total count, limit, and offset
343
+ */
344
+ declare function calculatePagination(total: number, options: PaginationOptions): PaginationInfo;
345
+ //#endregion
346
+ export { AbstractDatabasePlugin, BaseDatabaseUtils, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuildType, Bundle, ConfigBuilder, ConfigInput, ConfigResponse, DatabasePlugin, DatabasePluginHooks, HotUpdaterConfigOptions, IConfigBuilder, ImportInfo, PaginatedResult, PaginationInfo, PaginationOptions, Platform, ProviderConfig, StoragePlugin, StoragePluginHooks, banner, calculatePagination, copyDirToTmp, createBlobDatabasePlugin, createDatabasePlugin, createZip, createZipTargetFiles, getCwd, link, loadConfig, loadConfigSync, log, makeEnv, printBanner, transformEnv, transformTemplate };