@hot-updater/server 0.21.10 → 0.21.11
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/db/index.cjs +16 -276
- package/dist/db/index.d.cts +3 -48
- package/dist/db/index.d.ts +3 -48
- package/dist/db/index.js +17 -272
- package/dist/db/ormCore.cjs +278 -0
- package/dist/db/ormCore.d.cts +26 -0
- package/dist/db/ormCore.d.ts +26 -0
- package/dist/db/ormCore.js +273 -0
- package/dist/db/pluginCore.cjs +71 -0
- package/dist/db/pluginCore.js +69 -0
- package/dist/db/types.cjs +12 -0
- package/dist/db/types.d.cts +31 -0
- package/dist/db/types.d.ts +31 -0
- package/dist/db/types.js +10 -0
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/package.json +10 -9
- package/src/db/index.spec.ts +99 -1
- package/src/db/index.ts +38 -446
- package/src/db/ormCore.ts +441 -0
- package/src/db/pluginCore.ts +119 -0
- package/src/db/types.ts +57 -0
- package/src/handler-standalone-integration.spec.ts +9 -9
package/dist/db/index.cjs
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_calculatePagination = require('../calculatePagination.cjs');
|
|
3
1
|
const require_handler = require('../handler.cjs');
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let __hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
8
|
-
__hot_updater_plugin_core = require_rolldown_runtime.__toESM(__hot_updater_plugin_core);
|
|
9
|
-
let fumadb = require("fumadb");
|
|
10
|
-
fumadb = require_rolldown_runtime.__toESM(fumadb);
|
|
2
|
+
const require_ormCore = require('./ormCore.cjs');
|
|
3
|
+
const require_pluginCore = require('./pluginCore.cjs');
|
|
4
|
+
const require_types = require('./types.cjs');
|
|
11
5
|
|
|
12
6
|
//#region src/db/index.ts
|
|
13
|
-
const HotUpdaterDB = (0, fumadb.fumadb)({
|
|
14
|
-
namespace: "hot_updater",
|
|
15
|
-
schemas: [require_v0_21_0.v0_21_0]
|
|
16
|
-
});
|
|
17
7
|
function createHotUpdater(options) {
|
|
18
|
-
const
|
|
19
|
-
const cwd = options.cwd ?? process.cwd();
|
|
20
|
-
const storagePlugins = (options?.storagePlugins ?? []).map((plugin) => typeof plugin === "function" ? plugin({ cwd }) : plugin);
|
|
8
|
+
const storagePlugins = (options?.storagePlugins ?? []).map((plugin) => typeof plugin === "function" ? plugin() : plugin);
|
|
21
9
|
const resolveFileUrl = async (storageUri) => {
|
|
22
10
|
if (!storageUri) return null;
|
|
23
11
|
const protocol = new URL(storageUri).protocol.replace(":", "");
|
|
@@ -28,269 +16,21 @@ function createHotUpdater(options) {
|
|
|
28
16
|
if (!fileUrl) throw new Error("Storage plugin returned empty fileUrl");
|
|
29
17
|
return fileUrl;
|
|
30
18
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"should_force_update",
|
|
39
|
-
"enabled",
|
|
40
|
-
"file_hash",
|
|
41
|
-
"git_commit_hash",
|
|
42
|
-
"message",
|
|
43
|
-
"channel",
|
|
44
|
-
"storage_uri",
|
|
45
|
-
"target_app_version",
|
|
46
|
-
"fingerprint_hash",
|
|
47
|
-
"metadata"
|
|
48
|
-
],
|
|
49
|
-
where: (b) => b.and(b.isNotNull("id"), b("id", "=", id))
|
|
50
|
-
});
|
|
51
|
-
if (!result) return null;
|
|
52
|
-
return {
|
|
53
|
-
id: result.id,
|
|
54
|
-
platform: result.platform,
|
|
55
|
-
shouldForceUpdate: Boolean(result.should_force_update),
|
|
56
|
-
enabled: Boolean(result.enabled),
|
|
57
|
-
fileHash: result.file_hash,
|
|
58
|
-
gitCommitHash: result.git_commit_hash ?? null,
|
|
59
|
-
message: result.message ?? null,
|
|
60
|
-
channel: result.channel,
|
|
61
|
-
storageUri: result.storage_uri,
|
|
62
|
-
targetAppVersion: result.target_app_version ?? null,
|
|
63
|
-
fingerprintHash: result.fingerprint_hash ?? null
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
async getUpdateInfo(args) {
|
|
67
|
-
const version = await client.version();
|
|
68
|
-
const orm = client.orm(version);
|
|
69
|
-
const toUpdateInfo = (row, status) => ({
|
|
70
|
-
id: row.id,
|
|
71
|
-
shouldForceUpdate: status === "ROLLBACK" ? true : Boolean(row.should_force_update),
|
|
72
|
-
message: row.message ?? null,
|
|
73
|
-
status,
|
|
74
|
-
storageUri: row.storage_uri ?? null,
|
|
75
|
-
fileHash: row.file_hash ?? null
|
|
76
|
-
});
|
|
77
|
-
const INIT_BUNDLE_ROLLBACK_UPDATE_INFO = {
|
|
78
|
-
id: __hot_updater_core.NIL_UUID,
|
|
79
|
-
message: null,
|
|
80
|
-
shouldForceUpdate: true,
|
|
81
|
-
status: "ROLLBACK",
|
|
82
|
-
storageUri: null,
|
|
83
|
-
fileHash: null
|
|
84
|
-
};
|
|
85
|
-
const appVersionStrategy = async ({ platform, appVersion, bundleId, minBundleId = __hot_updater_core.NIL_UUID, channel = "production" }) => {
|
|
86
|
-
const versionRows = await orm.findMany("bundles", {
|
|
87
|
-
select: ["target_app_version"],
|
|
88
|
-
where: (b) => b.and(b("platform", "=", platform))
|
|
89
|
-
});
|
|
90
|
-
const compatibleVersions = (0, __hot_updater_plugin_core.filterCompatibleAppVersions)(Array.from(new Set((versionRows ?? []).map((r) => r.target_app_version).filter((v) => Boolean(v)))), appVersion);
|
|
91
|
-
const candidates = ((compatibleVersions.length === 0 ? [] : await orm.findMany("bundles", {
|
|
92
|
-
select: [
|
|
93
|
-
"id",
|
|
94
|
-
"should_force_update",
|
|
95
|
-
"message",
|
|
96
|
-
"storage_uri",
|
|
97
|
-
"file_hash",
|
|
98
|
-
"channel",
|
|
99
|
-
"target_app_version",
|
|
100
|
-
"enabled"
|
|
101
|
-
],
|
|
102
|
-
where: (b) => b.and(b("enabled", "=", true), b("platform", "=", platform), b("id", ">=", minBundleId ?? __hot_updater_core.NIL_UUID), b("channel", "=", channel), b.isNotNull("target_app_version"))
|
|
103
|
-
})) ?? []).filter((r) => r.target_app_version ? compatibleVersions.includes(r.target_app_version) : false);
|
|
104
|
-
const byIdDesc = (a, b) => b.id.localeCompare(a.id);
|
|
105
|
-
const sorted = (candidates ?? []).slice().sort(byIdDesc);
|
|
106
|
-
const latestCandidate = sorted[0] ?? null;
|
|
107
|
-
const currentBundle = sorted.find((b) => b.id === bundleId);
|
|
108
|
-
const updateCandidate = sorted.find((b) => b.id.localeCompare(bundleId) > 0) ?? null;
|
|
109
|
-
const rollbackCandidate = sorted.find((b) => b.id.localeCompare(bundleId) < 0) ?? null;
|
|
110
|
-
if (bundleId === __hot_updater_core.NIL_UUID) {
|
|
111
|
-
if (latestCandidate && latestCandidate.id !== bundleId) return toUpdateInfo(latestCandidate, "UPDATE");
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
if (currentBundle) {
|
|
115
|
-
if (latestCandidate && latestCandidate.id.localeCompare(currentBundle.id) > 0) return toUpdateInfo(latestCandidate, "UPDATE");
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
if (updateCandidate) return toUpdateInfo(updateCandidate, "UPDATE");
|
|
119
|
-
if (rollbackCandidate) return toUpdateInfo(rollbackCandidate, "ROLLBACK");
|
|
120
|
-
if (minBundleId && bundleId.localeCompare(minBundleId) <= 0) return null;
|
|
121
|
-
return INIT_BUNDLE_ROLLBACK_UPDATE_INFO;
|
|
122
|
-
};
|
|
123
|
-
const fingerprintStrategy = async ({ platform, fingerprintHash, bundleId, minBundleId = __hot_updater_core.NIL_UUID, channel = "production" }) => {
|
|
124
|
-
const candidates = await orm.findMany("bundles", {
|
|
125
|
-
select: [
|
|
126
|
-
"id",
|
|
127
|
-
"should_force_update",
|
|
128
|
-
"message",
|
|
129
|
-
"storage_uri",
|
|
130
|
-
"file_hash",
|
|
131
|
-
"channel",
|
|
132
|
-
"fingerprint_hash",
|
|
133
|
-
"enabled"
|
|
134
|
-
],
|
|
135
|
-
where: (b) => b.and(b("enabled", "=", true), b("platform", "=", platform), b("id", ">=", minBundleId ?? __hot_updater_core.NIL_UUID), b("channel", "=", channel), b("fingerprint_hash", "=", fingerprintHash))
|
|
136
|
-
});
|
|
137
|
-
const byIdDesc = (a, b) => b.id.localeCompare(a.id);
|
|
138
|
-
const sorted = (candidates ?? []).slice().sort(byIdDesc);
|
|
139
|
-
const latestCandidate = sorted[0] ?? null;
|
|
140
|
-
const currentBundle = sorted.find((b) => b.id === bundleId);
|
|
141
|
-
const updateCandidate = sorted.find((b) => b.id.localeCompare(bundleId) > 0) ?? null;
|
|
142
|
-
const rollbackCandidate = sorted.find((b) => b.id.localeCompare(bundleId) < 0) ?? null;
|
|
143
|
-
if (bundleId === __hot_updater_core.NIL_UUID) {
|
|
144
|
-
if (latestCandidate && latestCandidate.id !== bundleId) return toUpdateInfo(latestCandidate, "UPDATE");
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
if (currentBundle) {
|
|
148
|
-
if (latestCandidate && latestCandidate.id.localeCompare(currentBundle.id) > 0) return toUpdateInfo(latestCandidate, "UPDATE");
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
if (updateCandidate) return toUpdateInfo(updateCandidate, "UPDATE");
|
|
152
|
-
if (rollbackCandidate) return toUpdateInfo(rollbackCandidate, "ROLLBACK");
|
|
153
|
-
if (minBundleId && bundleId.localeCompare(minBundleId) <= 0) return null;
|
|
154
|
-
return INIT_BUNDLE_ROLLBACK_UPDATE_INFO;
|
|
155
|
-
};
|
|
156
|
-
if (args._updateStrategy === "appVersion") return appVersionStrategy(args);
|
|
157
|
-
if (args._updateStrategy === "fingerprint") return fingerprintStrategy(args);
|
|
158
|
-
return null;
|
|
159
|
-
},
|
|
160
|
-
async getAppUpdateInfo(args) {
|
|
161
|
-
const info = await this.getUpdateInfo(args);
|
|
162
|
-
if (!info) return null;
|
|
163
|
-
const { storageUri,...rest } = info;
|
|
164
|
-
const fileUrl = await resolveFileUrl(storageUri ?? null);
|
|
165
|
-
return {
|
|
166
|
-
...rest,
|
|
167
|
-
fileUrl
|
|
168
|
-
};
|
|
169
|
-
},
|
|
170
|
-
async getChannels() {
|
|
171
|
-
const version = await client.version();
|
|
172
|
-
const rows = await client.orm(version).findMany("bundles", {
|
|
173
|
-
select: ["channel"],
|
|
174
|
-
where: (b) => b.isNotNull("channel")
|
|
175
|
-
});
|
|
176
|
-
const set = new Set(rows?.map((r) => r.channel) ?? []);
|
|
177
|
-
return Array.from(set);
|
|
178
|
-
},
|
|
179
|
-
async getBundles(options$1) {
|
|
180
|
-
const version = await client.version();
|
|
181
|
-
const orm = client.orm(version);
|
|
182
|
-
const { where, limit, offset } = options$1;
|
|
183
|
-
const all = (await orm.findMany("bundles", {
|
|
184
|
-
select: [
|
|
185
|
-
"id",
|
|
186
|
-
"platform",
|
|
187
|
-
"should_force_update",
|
|
188
|
-
"enabled",
|
|
189
|
-
"file_hash",
|
|
190
|
-
"git_commit_hash",
|
|
191
|
-
"message",
|
|
192
|
-
"channel",
|
|
193
|
-
"storage_uri",
|
|
194
|
-
"target_app_version",
|
|
195
|
-
"fingerprint_hash",
|
|
196
|
-
"metadata"
|
|
197
|
-
],
|
|
198
|
-
where: (b) => {
|
|
199
|
-
const conditions = [];
|
|
200
|
-
if (where?.channel) conditions.push(b("channel", "=", where.channel));
|
|
201
|
-
if (where?.platform) conditions.push(b("platform", "=", where.platform));
|
|
202
|
-
return conditions.length > 0 ? b.and(...conditions) : true;
|
|
203
|
-
}
|
|
204
|
-
})).map((r) => ({
|
|
205
|
-
id: r.id,
|
|
206
|
-
platform: r.platform,
|
|
207
|
-
shouldForceUpdate: Boolean(r.should_force_update),
|
|
208
|
-
enabled: Boolean(r.enabled),
|
|
209
|
-
fileHash: r.file_hash,
|
|
210
|
-
gitCommitHash: r.git_commit_hash ?? null,
|
|
211
|
-
message: r.message ?? null,
|
|
212
|
-
channel: r.channel,
|
|
213
|
-
storageUri: r.storage_uri,
|
|
214
|
-
targetAppVersion: r.target_app_version ?? null,
|
|
215
|
-
fingerprintHash: r.fingerprint_hash ?? null
|
|
216
|
-
})).sort((a, b) => b.id.localeCompare(a.id));
|
|
217
|
-
const total = all.length;
|
|
218
|
-
return {
|
|
219
|
-
data: all.slice(offset, offset + limit),
|
|
220
|
-
pagination: require_calculatePagination.calculatePagination(total, {
|
|
221
|
-
limit,
|
|
222
|
-
offset
|
|
223
|
-
})
|
|
224
|
-
};
|
|
225
|
-
},
|
|
226
|
-
async insertBundle(bundle) {
|
|
227
|
-
const version = await client.version();
|
|
228
|
-
const orm = client.orm(version);
|
|
229
|
-
const values = {
|
|
230
|
-
id: bundle.id,
|
|
231
|
-
platform: bundle.platform,
|
|
232
|
-
should_force_update: bundle.shouldForceUpdate,
|
|
233
|
-
enabled: bundle.enabled,
|
|
234
|
-
file_hash: bundle.fileHash,
|
|
235
|
-
git_commit_hash: bundle.gitCommitHash,
|
|
236
|
-
message: bundle.message,
|
|
237
|
-
channel: bundle.channel,
|
|
238
|
-
storage_uri: bundle.storageUri,
|
|
239
|
-
target_app_version: bundle.targetAppVersion,
|
|
240
|
-
fingerprint_hash: bundle.fingerprintHash,
|
|
241
|
-
metadata: bundle.metadata ?? {}
|
|
242
|
-
};
|
|
243
|
-
const { id,...updateValues } = values;
|
|
244
|
-
await orm.upsert("bundles", {
|
|
245
|
-
where: (b) => b("id", "=", id),
|
|
246
|
-
create: values,
|
|
247
|
-
update: updateValues
|
|
248
|
-
});
|
|
249
|
-
},
|
|
250
|
-
async updateBundleById(bundleId, newBundle) {
|
|
251
|
-
const version = await client.version();
|
|
252
|
-
const orm = client.orm(version);
|
|
253
|
-
const current = await this.getBundleById(bundleId);
|
|
254
|
-
if (!current) throw new Error("targetBundleId not found");
|
|
255
|
-
const merged = {
|
|
256
|
-
...current,
|
|
257
|
-
...newBundle
|
|
258
|
-
};
|
|
259
|
-
const values = {
|
|
260
|
-
id: merged.id,
|
|
261
|
-
platform: merged.platform,
|
|
262
|
-
should_force_update: merged.shouldForceUpdate,
|
|
263
|
-
enabled: merged.enabled,
|
|
264
|
-
file_hash: merged.fileHash,
|
|
265
|
-
git_commit_hash: merged.gitCommitHash,
|
|
266
|
-
message: merged.message,
|
|
267
|
-
channel: merged.channel,
|
|
268
|
-
storage_uri: merged.storageUri,
|
|
269
|
-
target_app_version: merged.targetAppVersion,
|
|
270
|
-
fingerprint_hash: merged.fingerprintHash,
|
|
271
|
-
metadata: merged.metadata ?? {}
|
|
272
|
-
};
|
|
273
|
-
const { id: id2,...updateValues2 } = values;
|
|
274
|
-
await orm.upsert("bundles", {
|
|
275
|
-
where: (b) => b("id", "=", id2),
|
|
276
|
-
create: values,
|
|
277
|
-
update: updateValues2
|
|
278
|
-
});
|
|
279
|
-
},
|
|
280
|
-
async deleteBundleById(bundleId) {
|
|
281
|
-
const version = await client.version();
|
|
282
|
-
await client.orm(version).deleteMany("bundles", { where: (b) => b("id", "=", bundleId) });
|
|
283
|
-
}
|
|
284
|
-
};
|
|
19
|
+
let core;
|
|
20
|
+
const database = options.database;
|
|
21
|
+
if (require_types.isDatabasePluginFactory(database) || require_types.isDatabasePlugin(database)) core = require_pluginCore.createPluginDatabaseCore(require_types.isDatabasePluginFactory(database) ? database() : database, resolveFileUrl);
|
|
22
|
+
else core = require_ormCore.createOrmDatabaseCore({
|
|
23
|
+
database,
|
|
24
|
+
resolveFileUrl
|
|
25
|
+
});
|
|
285
26
|
return {
|
|
286
|
-
...api,
|
|
287
|
-
handler: require_handler.createHandler(api, options?.basePath ? { basePath: options.basePath } : {}),
|
|
288
|
-
adapterName:
|
|
289
|
-
createMigrator:
|
|
290
|
-
generateSchema:
|
|
27
|
+
...core.api,
|
|
28
|
+
handler: require_handler.createHandler(core.api, options?.basePath ? { basePath: options.basePath } : {}),
|
|
29
|
+
adapterName: core.adapterName,
|
|
30
|
+
createMigrator: core.createMigrator,
|
|
31
|
+
generateSchema: core.generateSchema
|
|
291
32
|
};
|
|
292
33
|
}
|
|
293
34
|
|
|
294
35
|
//#endregion
|
|
295
|
-
exports.HotUpdaterDB = HotUpdaterDB;
|
|
296
36
|
exports.createHotUpdater = createHotUpdater;
|
package/dist/db/index.d.cts
CHANGED
|
@@ -1,59 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import * as fumadb0 from "fumadb";
|
|
4
|
-
import { InferFumaDB } from "fumadb";
|
|
5
|
-
import { AppUpdateInfo, Bundle, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
|
|
1
|
+
import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./types.cjs";
|
|
2
|
+
import { HotUpdaterClient, HotUpdaterDB, Migrator } from "./ormCore.cjs";
|
|
6
3
|
import { StoragePlugin } from "@hot-updater/plugin-core";
|
|
7
4
|
|
|
8
5
|
//#region src/db/index.d.ts
|
|
9
|
-
declare const HotUpdaterDB: fumadb0.FumaDBFactory<fumadb_schema0.Schema<"0.21.0", {
|
|
10
|
-
bundles: fumadb_schema0.Table<{
|
|
11
|
-
id: fumadb_schema0.IdColumn<"uuid", string, string>;
|
|
12
|
-
platform: fumadb_schema0.Column<"string", string, string>;
|
|
13
|
-
should_force_update: fumadb_schema0.Column<"bool", boolean, boolean>;
|
|
14
|
-
enabled: fumadb_schema0.Column<"bool", boolean, boolean>;
|
|
15
|
-
file_hash: fumadb_schema0.Column<"string", string, string>;
|
|
16
|
-
git_commit_hash: fumadb_schema0.Column<"string", string | null, string | null>;
|
|
17
|
-
message: fumadb_schema0.Column<"string", string | null, string | null>;
|
|
18
|
-
channel: fumadb_schema0.Column<"string", string, string>;
|
|
19
|
-
storage_uri: fumadb_schema0.Column<"string", string, string>;
|
|
20
|
-
target_app_version: fumadb_schema0.Column<"string", string | null, string | null>;
|
|
21
|
-
fingerprint_hash: fumadb_schema0.Column<"string", string | null, string | null>;
|
|
22
|
-
metadata: fumadb_schema0.Column<"json", unknown, unknown>;
|
|
23
|
-
}, {}>;
|
|
24
|
-
}>[]>;
|
|
25
|
-
type HotUpdaterClient = InferFumaDB<typeof HotUpdaterDB>;
|
|
26
|
-
type DatabaseAdapter = Parameters<typeof HotUpdaterDB.client>[0];
|
|
27
|
-
interface DatabaseAPI {
|
|
28
|
-
getBundleById(id: string): Promise<Bundle | null>;
|
|
29
|
-
getUpdateInfo(args: GetBundlesArgs): Promise<UpdateInfo | null>;
|
|
30
|
-
getAppUpdateInfo(args: GetBundlesArgs): Promise<AppUpdateInfo | null>;
|
|
31
|
-
getChannels(): Promise<string[]>;
|
|
32
|
-
getBundles(options: {
|
|
33
|
-
where?: {
|
|
34
|
-
channel?: string;
|
|
35
|
-
platform?: string;
|
|
36
|
-
};
|
|
37
|
-
limit: number;
|
|
38
|
-
offset: number;
|
|
39
|
-
}): Promise<{
|
|
40
|
-
data: Bundle[];
|
|
41
|
-
pagination: PaginationInfo;
|
|
42
|
-
}>;
|
|
43
|
-
insertBundle(bundle: Bundle): Promise<void>;
|
|
44
|
-
updateBundleById(bundleId: string, newBundle: Partial<Bundle>): Promise<void>;
|
|
45
|
-
deleteBundleById(bundleId: string): Promise<void>;
|
|
46
|
-
}
|
|
47
6
|
type HotUpdaterAPI = DatabaseAPI & {
|
|
48
7
|
handler: (request: Request) => Promise<Response>;
|
|
49
8
|
adapterName: string;
|
|
50
9
|
createMigrator: () => Migrator;
|
|
51
10
|
generateSchema: HotUpdaterClient["generateSchema"];
|
|
52
11
|
};
|
|
53
|
-
type Migrator = ReturnType<HotUpdaterClient["createMigrator"]>;
|
|
54
|
-
type StoragePluginFactory = (args: {
|
|
55
|
-
cwd: string;
|
|
56
|
-
}) => StoragePlugin;
|
|
57
12
|
interface HotUpdaterOptions {
|
|
58
13
|
database: DatabaseAdapter;
|
|
59
14
|
storagePlugins?: (StoragePlugin | StoragePluginFactory)[];
|
|
@@ -62,4 +17,4 @@ interface HotUpdaterOptions {
|
|
|
62
17
|
}
|
|
63
18
|
declare function createHotUpdater(options: HotUpdaterOptions): HotUpdaterAPI;
|
|
64
19
|
//#endregion
|
|
65
|
-
export {
|
|
20
|
+
export { HotUpdaterAPI, createHotUpdater };
|
package/dist/db/index.d.ts
CHANGED
|
@@ -1,59 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./types.js";
|
|
2
|
+
import { HotUpdaterClient, HotUpdaterDB, Migrator } from "./ormCore.js";
|
|
3
3
|
import { StoragePlugin } from "@hot-updater/plugin-core";
|
|
4
|
-
import * as fumadb0 from "fumadb";
|
|
5
|
-
import { InferFumaDB } from "fumadb";
|
|
6
|
-
import * as fumadb_schema0 from "fumadb/schema";
|
|
7
4
|
|
|
8
5
|
//#region src/db/index.d.ts
|
|
9
|
-
declare const HotUpdaterDB: fumadb0.FumaDBFactory<fumadb_schema0.Schema<"0.21.0", {
|
|
10
|
-
bundles: fumadb_schema0.Table<{
|
|
11
|
-
id: fumadb_schema0.IdColumn<"uuid", string, string>;
|
|
12
|
-
platform: fumadb_schema0.Column<"string", string, string>;
|
|
13
|
-
should_force_update: fumadb_schema0.Column<"bool", boolean, boolean>;
|
|
14
|
-
enabled: fumadb_schema0.Column<"bool", boolean, boolean>;
|
|
15
|
-
file_hash: fumadb_schema0.Column<"string", string, string>;
|
|
16
|
-
git_commit_hash: fumadb_schema0.Column<"string", string | null, string | null>;
|
|
17
|
-
message: fumadb_schema0.Column<"string", string | null, string | null>;
|
|
18
|
-
channel: fumadb_schema0.Column<"string", string, string>;
|
|
19
|
-
storage_uri: fumadb_schema0.Column<"string", string, string>;
|
|
20
|
-
target_app_version: fumadb_schema0.Column<"string", string | null, string | null>;
|
|
21
|
-
fingerprint_hash: fumadb_schema0.Column<"string", string | null, string | null>;
|
|
22
|
-
metadata: fumadb_schema0.Column<"json", unknown, unknown>;
|
|
23
|
-
}, {}>;
|
|
24
|
-
}>[]>;
|
|
25
|
-
type HotUpdaterClient = InferFumaDB<typeof HotUpdaterDB>;
|
|
26
|
-
type DatabaseAdapter = Parameters<typeof HotUpdaterDB.client>[0];
|
|
27
|
-
interface DatabaseAPI {
|
|
28
|
-
getBundleById(id: string): Promise<Bundle | null>;
|
|
29
|
-
getUpdateInfo(args: GetBundlesArgs): Promise<UpdateInfo | null>;
|
|
30
|
-
getAppUpdateInfo(args: GetBundlesArgs): Promise<AppUpdateInfo | null>;
|
|
31
|
-
getChannels(): Promise<string[]>;
|
|
32
|
-
getBundles(options: {
|
|
33
|
-
where?: {
|
|
34
|
-
channel?: string;
|
|
35
|
-
platform?: string;
|
|
36
|
-
};
|
|
37
|
-
limit: number;
|
|
38
|
-
offset: number;
|
|
39
|
-
}): Promise<{
|
|
40
|
-
data: Bundle[];
|
|
41
|
-
pagination: PaginationInfo;
|
|
42
|
-
}>;
|
|
43
|
-
insertBundle(bundle: Bundle): Promise<void>;
|
|
44
|
-
updateBundleById(bundleId: string, newBundle: Partial<Bundle>): Promise<void>;
|
|
45
|
-
deleteBundleById(bundleId: string): Promise<void>;
|
|
46
|
-
}
|
|
47
6
|
type HotUpdaterAPI = DatabaseAPI & {
|
|
48
7
|
handler: (request: Request) => Promise<Response>;
|
|
49
8
|
adapterName: string;
|
|
50
9
|
createMigrator: () => Migrator;
|
|
51
10
|
generateSchema: HotUpdaterClient["generateSchema"];
|
|
52
11
|
};
|
|
53
|
-
type Migrator = ReturnType<HotUpdaterClient["createMigrator"]>;
|
|
54
|
-
type StoragePluginFactory = (args: {
|
|
55
|
-
cwd: string;
|
|
56
|
-
}) => StoragePlugin;
|
|
57
12
|
interface HotUpdaterOptions {
|
|
58
13
|
database: DatabaseAdapter;
|
|
59
14
|
storagePlugins?: (StoragePlugin | StoragePluginFactory)[];
|
|
@@ -62,4 +17,4 @@ interface HotUpdaterOptions {
|
|
|
62
17
|
}
|
|
63
18
|
declare function createHotUpdater(options: HotUpdaterOptions): HotUpdaterAPI;
|
|
64
19
|
//#endregion
|
|
65
|
-
export {
|
|
20
|
+
export { HotUpdaterAPI, createHotUpdater };
|