@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
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { calculatePagination } from "../calculatePagination.js";
|
|
2
|
+
import { v0_21_0 } from "../schema/v0_21_0.js";
|
|
3
|
+
import { NIL_UUID } from "@hot-updater/core";
|
|
4
|
+
import { filterCompatibleAppVersions } from "@hot-updater/plugin-core";
|
|
5
|
+
import { fumadb } from "fumadb";
|
|
6
|
+
|
|
7
|
+
//#region src/db/ormCore.ts
|
|
8
|
+
const HotUpdaterDB = fumadb({
|
|
9
|
+
namespace: "hot_updater",
|
|
10
|
+
schemas: [v0_21_0]
|
|
11
|
+
});
|
|
12
|
+
function createOrmDatabaseCore({ database, resolveFileUrl }) {
|
|
13
|
+
const client = HotUpdaterDB.client(database);
|
|
14
|
+
return {
|
|
15
|
+
api: {
|
|
16
|
+
async getBundleById(id) {
|
|
17
|
+
const version = await client.version();
|
|
18
|
+
const result = await client.orm(version).findFirst("bundles", {
|
|
19
|
+
select: [
|
|
20
|
+
"id",
|
|
21
|
+
"platform",
|
|
22
|
+
"should_force_update",
|
|
23
|
+
"enabled",
|
|
24
|
+
"file_hash",
|
|
25
|
+
"git_commit_hash",
|
|
26
|
+
"message",
|
|
27
|
+
"channel",
|
|
28
|
+
"storage_uri",
|
|
29
|
+
"target_app_version",
|
|
30
|
+
"fingerprint_hash",
|
|
31
|
+
"metadata"
|
|
32
|
+
],
|
|
33
|
+
where: (b) => b("id", "=", id)
|
|
34
|
+
});
|
|
35
|
+
if (!result) return null;
|
|
36
|
+
return {
|
|
37
|
+
id: result.id,
|
|
38
|
+
platform: result.platform,
|
|
39
|
+
shouldForceUpdate: Boolean(result.should_force_update),
|
|
40
|
+
enabled: Boolean(result.enabled),
|
|
41
|
+
fileHash: result.file_hash,
|
|
42
|
+
gitCommitHash: result.git_commit_hash ?? null,
|
|
43
|
+
message: result.message ?? null,
|
|
44
|
+
channel: result.channel,
|
|
45
|
+
storageUri: result.storage_uri,
|
|
46
|
+
targetAppVersion: result.target_app_version ?? null,
|
|
47
|
+
fingerprintHash: result.fingerprint_hash ?? null
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
async getUpdateInfo(args) {
|
|
51
|
+
const version = await client.version();
|
|
52
|
+
const orm = client.orm(version);
|
|
53
|
+
const toUpdateInfo = (row, status) => ({
|
|
54
|
+
id: row.id,
|
|
55
|
+
shouldForceUpdate: status === "ROLLBACK" ? true : Boolean(row.should_force_update),
|
|
56
|
+
message: row.message ?? null,
|
|
57
|
+
status,
|
|
58
|
+
storageUri: row.storage_uri ?? null,
|
|
59
|
+
fileHash: row.file_hash ?? null
|
|
60
|
+
});
|
|
61
|
+
const INIT_BUNDLE_ROLLBACK_UPDATE_INFO = {
|
|
62
|
+
id: NIL_UUID,
|
|
63
|
+
message: null,
|
|
64
|
+
shouldForceUpdate: true,
|
|
65
|
+
status: "ROLLBACK",
|
|
66
|
+
storageUri: null,
|
|
67
|
+
fileHash: null
|
|
68
|
+
};
|
|
69
|
+
const appVersionStrategy = async ({ platform, appVersion, bundleId, minBundleId = NIL_UUID, channel = "production" }) => {
|
|
70
|
+
const versionRows = await orm.findMany("bundles", {
|
|
71
|
+
select: ["target_app_version"],
|
|
72
|
+
where: (b) => b.and(b("platform", "=", platform))
|
|
73
|
+
});
|
|
74
|
+
const compatibleVersions = filterCompatibleAppVersions(Array.from(new Set((versionRows ?? []).map((r) => r.target_app_version).filter((v) => Boolean(v)))), appVersion);
|
|
75
|
+
const candidates = ((compatibleVersions.length === 0 ? [] : await orm.findMany("bundles", {
|
|
76
|
+
select: [
|
|
77
|
+
"id",
|
|
78
|
+
"should_force_update",
|
|
79
|
+
"message",
|
|
80
|
+
"storage_uri",
|
|
81
|
+
"file_hash",
|
|
82
|
+
"channel",
|
|
83
|
+
"target_app_version",
|
|
84
|
+
"enabled"
|
|
85
|
+
],
|
|
86
|
+
where: (b) => b.and(b("enabled", "=", true), b("platform", "=", platform), b("id", ">=", minBundleId ?? NIL_UUID), b("channel", "=", channel), b.isNotNull("target_app_version"))
|
|
87
|
+
})) ?? []).filter((r) => r.target_app_version ? compatibleVersions.includes(r.target_app_version) : false);
|
|
88
|
+
const byIdDesc = (a, b) => b.id.localeCompare(a.id);
|
|
89
|
+
const sorted = (candidates ?? []).slice().sort(byIdDesc);
|
|
90
|
+
const latestCandidate = sorted[0] ?? null;
|
|
91
|
+
const currentBundle = sorted.find((b) => b.id === bundleId);
|
|
92
|
+
const updateCandidate = sorted.find((b) => b.id.localeCompare(bundleId) > 0) ?? null;
|
|
93
|
+
const rollbackCandidate = sorted.find((b) => b.id.localeCompare(bundleId) < 0) ?? null;
|
|
94
|
+
if (bundleId === NIL_UUID) {
|
|
95
|
+
if (latestCandidate && latestCandidate.id !== bundleId) return toUpdateInfo(latestCandidate, "UPDATE");
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
if (currentBundle) {
|
|
99
|
+
if (latestCandidate && latestCandidate.id.localeCompare(currentBundle.id) > 0) return toUpdateInfo(latestCandidate, "UPDATE");
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
if (updateCandidate) return toUpdateInfo(updateCandidate, "UPDATE");
|
|
103
|
+
if (rollbackCandidate) return toUpdateInfo(rollbackCandidate, "ROLLBACK");
|
|
104
|
+
if (minBundleId && bundleId.localeCompare(minBundleId) <= 0) return null;
|
|
105
|
+
return INIT_BUNDLE_ROLLBACK_UPDATE_INFO;
|
|
106
|
+
};
|
|
107
|
+
const fingerprintStrategy = async ({ platform, fingerprintHash, bundleId, minBundleId = NIL_UUID, channel = "production" }) => {
|
|
108
|
+
const candidates = await orm.findMany("bundles", {
|
|
109
|
+
select: [
|
|
110
|
+
"id",
|
|
111
|
+
"should_force_update",
|
|
112
|
+
"message",
|
|
113
|
+
"storage_uri",
|
|
114
|
+
"file_hash",
|
|
115
|
+
"channel",
|
|
116
|
+
"fingerprint_hash",
|
|
117
|
+
"enabled"
|
|
118
|
+
],
|
|
119
|
+
where: (b) => b.and(b("enabled", "=", true), b("platform", "=", platform), b("id", ">=", minBundleId ?? NIL_UUID), b("channel", "=", channel), b("fingerprint_hash", "=", fingerprintHash))
|
|
120
|
+
});
|
|
121
|
+
const byIdDesc = (a, b) => b.id.localeCompare(a.id);
|
|
122
|
+
const sorted = (candidates ?? []).slice().sort(byIdDesc);
|
|
123
|
+
const latestCandidate = sorted[0] ?? null;
|
|
124
|
+
const currentBundle = sorted.find((b) => b.id === bundleId);
|
|
125
|
+
const updateCandidate = sorted.find((b) => b.id.localeCompare(bundleId) > 0) ?? null;
|
|
126
|
+
const rollbackCandidate = sorted.find((b) => b.id.localeCompare(bundleId) < 0) ?? null;
|
|
127
|
+
if (bundleId === NIL_UUID) {
|
|
128
|
+
if (latestCandidate && latestCandidate.id !== bundleId) return toUpdateInfo(latestCandidate, "UPDATE");
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
if (currentBundle) {
|
|
132
|
+
if (latestCandidate && latestCandidate.id.localeCompare(currentBundle.id) > 0) return toUpdateInfo(latestCandidate, "UPDATE");
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
if (updateCandidate) return toUpdateInfo(updateCandidate, "UPDATE");
|
|
136
|
+
if (rollbackCandidate) return toUpdateInfo(rollbackCandidate, "ROLLBACK");
|
|
137
|
+
if (minBundleId && bundleId.localeCompare(minBundleId) <= 0) return null;
|
|
138
|
+
return INIT_BUNDLE_ROLLBACK_UPDATE_INFO;
|
|
139
|
+
};
|
|
140
|
+
if (args._updateStrategy === "appVersion") return appVersionStrategy(args);
|
|
141
|
+
if (args._updateStrategy === "fingerprint") return fingerprintStrategy(args);
|
|
142
|
+
return null;
|
|
143
|
+
},
|
|
144
|
+
async getAppUpdateInfo(args) {
|
|
145
|
+
const info = await this.getUpdateInfo(args);
|
|
146
|
+
if (!info) return null;
|
|
147
|
+
const { storageUri,...rest } = info;
|
|
148
|
+
const fileUrl = await resolveFileUrl(storageUri ?? null);
|
|
149
|
+
return {
|
|
150
|
+
...rest,
|
|
151
|
+
fileUrl
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
async getChannels() {
|
|
155
|
+
const version = await client.version();
|
|
156
|
+
const rows = await client.orm(version).findMany("bundles", { select: ["channel"] });
|
|
157
|
+
const set = new Set(rows?.map((r) => r.channel) ?? []);
|
|
158
|
+
return Array.from(set);
|
|
159
|
+
},
|
|
160
|
+
async getBundles(options) {
|
|
161
|
+
const version = await client.version();
|
|
162
|
+
const orm = client.orm(version);
|
|
163
|
+
const { where, limit, offset } = options;
|
|
164
|
+
const all = (await orm.findMany("bundles", {
|
|
165
|
+
select: [
|
|
166
|
+
"id",
|
|
167
|
+
"platform",
|
|
168
|
+
"should_force_update",
|
|
169
|
+
"enabled",
|
|
170
|
+
"file_hash",
|
|
171
|
+
"git_commit_hash",
|
|
172
|
+
"message",
|
|
173
|
+
"channel",
|
|
174
|
+
"storage_uri",
|
|
175
|
+
"target_app_version",
|
|
176
|
+
"fingerprint_hash",
|
|
177
|
+
"metadata"
|
|
178
|
+
],
|
|
179
|
+
where: (b) => {
|
|
180
|
+
const conditions = [];
|
|
181
|
+
if (where?.channel) conditions.push(b("channel", "=", where.channel));
|
|
182
|
+
if (where?.platform) conditions.push(b("platform", "=", where.platform));
|
|
183
|
+
return conditions.length > 0 ? b.and(...conditions) : true;
|
|
184
|
+
}
|
|
185
|
+
})).map((r) => ({
|
|
186
|
+
id: r.id,
|
|
187
|
+
platform: r.platform,
|
|
188
|
+
shouldForceUpdate: Boolean(r.should_force_update),
|
|
189
|
+
enabled: Boolean(r.enabled),
|
|
190
|
+
fileHash: r.file_hash,
|
|
191
|
+
gitCommitHash: r.git_commit_hash ?? null,
|
|
192
|
+
message: r.message ?? null,
|
|
193
|
+
channel: r.channel,
|
|
194
|
+
storageUri: r.storage_uri,
|
|
195
|
+
targetAppVersion: r.target_app_version ?? null,
|
|
196
|
+
fingerprintHash: r.fingerprint_hash ?? null
|
|
197
|
+
})).sort((a, b) => b.id.localeCompare(a.id));
|
|
198
|
+
const total = all.length;
|
|
199
|
+
return {
|
|
200
|
+
data: all.slice(offset, offset + limit),
|
|
201
|
+
pagination: calculatePagination(total, {
|
|
202
|
+
limit,
|
|
203
|
+
offset
|
|
204
|
+
})
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
async insertBundle(bundle) {
|
|
208
|
+
const version = await client.version();
|
|
209
|
+
const orm = client.orm(version);
|
|
210
|
+
const values = {
|
|
211
|
+
id: bundle.id,
|
|
212
|
+
platform: bundle.platform,
|
|
213
|
+
should_force_update: bundle.shouldForceUpdate,
|
|
214
|
+
enabled: bundle.enabled,
|
|
215
|
+
file_hash: bundle.fileHash,
|
|
216
|
+
git_commit_hash: bundle.gitCommitHash,
|
|
217
|
+
message: bundle.message,
|
|
218
|
+
channel: bundle.channel,
|
|
219
|
+
storage_uri: bundle.storageUri,
|
|
220
|
+
target_app_version: bundle.targetAppVersion,
|
|
221
|
+
fingerprint_hash: bundle.fingerprintHash,
|
|
222
|
+
metadata: bundle.metadata ?? {}
|
|
223
|
+
};
|
|
224
|
+
const { id,...updateValues } = values;
|
|
225
|
+
await orm.upsert("bundles", {
|
|
226
|
+
where: (b) => b("id", "=", id),
|
|
227
|
+
create: values,
|
|
228
|
+
update: updateValues
|
|
229
|
+
});
|
|
230
|
+
},
|
|
231
|
+
async updateBundleById(bundleId, newBundle) {
|
|
232
|
+
const version = await client.version();
|
|
233
|
+
const orm = client.orm(version);
|
|
234
|
+
const current = await this.getBundleById(bundleId);
|
|
235
|
+
if (!current) throw new Error("targetBundleId not found");
|
|
236
|
+
const merged = {
|
|
237
|
+
...current,
|
|
238
|
+
...newBundle
|
|
239
|
+
};
|
|
240
|
+
const values = {
|
|
241
|
+
id: merged.id,
|
|
242
|
+
platform: merged.platform,
|
|
243
|
+
should_force_update: merged.shouldForceUpdate,
|
|
244
|
+
enabled: merged.enabled,
|
|
245
|
+
file_hash: merged.fileHash,
|
|
246
|
+
git_commit_hash: merged.gitCommitHash,
|
|
247
|
+
message: merged.message,
|
|
248
|
+
channel: merged.channel,
|
|
249
|
+
storage_uri: merged.storageUri,
|
|
250
|
+
target_app_version: merged.targetAppVersion,
|
|
251
|
+
fingerprint_hash: merged.fingerprintHash,
|
|
252
|
+
metadata: merged.metadata ?? {}
|
|
253
|
+
};
|
|
254
|
+
const { id: id2,...updateValues2 } = values;
|
|
255
|
+
await orm.upsert("bundles", {
|
|
256
|
+
where: (b) => b("id", "=", id2),
|
|
257
|
+
create: values,
|
|
258
|
+
update: updateValues2
|
|
259
|
+
});
|
|
260
|
+
},
|
|
261
|
+
async deleteBundleById(bundleId) {
|
|
262
|
+
const version = await client.version();
|
|
263
|
+
await client.orm(version).deleteMany("bundles", { where: (b) => b("id", "=", bundleId) });
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
adapterName: client.adapter.name,
|
|
267
|
+
createMigrator: () => client.createMigrator(),
|
|
268
|
+
generateSchema: client.generateSchema
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
//#endregion
|
|
273
|
+
export { HotUpdaterDB, createOrmDatabaseCore };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __hot_updater_js = require("@hot-updater/js");
|
|
3
|
+
__hot_updater_js = require_rolldown_runtime.__toESM(__hot_updater_js);
|
|
4
|
+
|
|
5
|
+
//#region src/db/pluginCore.ts
|
|
6
|
+
function createPluginDatabaseCore(plugin, resolveFileUrl) {
|
|
7
|
+
return {
|
|
8
|
+
api: {
|
|
9
|
+
async getBundleById(id) {
|
|
10
|
+
return plugin.getBundleById(id);
|
|
11
|
+
},
|
|
12
|
+
async getUpdateInfo(args) {
|
|
13
|
+
const where = {};
|
|
14
|
+
if ("platform" in args && args.platform) where.platform = args.platform;
|
|
15
|
+
where.channel = "channel" in args && args.channel ? args.channel : "production";
|
|
16
|
+
const { pagination } = await plugin.getBundles({
|
|
17
|
+
where,
|
|
18
|
+
limit: 1,
|
|
19
|
+
offset: 0
|
|
20
|
+
});
|
|
21
|
+
if (pagination.total === 0) return (0, __hot_updater_js.getUpdateInfo)([], args);
|
|
22
|
+
const { data } = await plugin.getBundles({
|
|
23
|
+
where,
|
|
24
|
+
limit: pagination.total,
|
|
25
|
+
offset: 0
|
|
26
|
+
});
|
|
27
|
+
return (0, __hot_updater_js.getUpdateInfo)(data, args);
|
|
28
|
+
},
|
|
29
|
+
async getAppUpdateInfo(args) {
|
|
30
|
+
const info = await this.getUpdateInfo(args);
|
|
31
|
+
if (!info) return null;
|
|
32
|
+
const { storageUri,...rest } = info;
|
|
33
|
+
const fileUrl = await resolveFileUrl(storageUri ?? null);
|
|
34
|
+
return {
|
|
35
|
+
...rest,
|
|
36
|
+
fileUrl
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
async getChannels() {
|
|
40
|
+
return plugin.getChannels();
|
|
41
|
+
},
|
|
42
|
+
async getBundles(options) {
|
|
43
|
+
return plugin.getBundles(options);
|
|
44
|
+
},
|
|
45
|
+
async insertBundle(bundle) {
|
|
46
|
+
await plugin.appendBundle(bundle);
|
|
47
|
+
await plugin.commitBundle();
|
|
48
|
+
},
|
|
49
|
+
async updateBundleById(bundleId, newBundle) {
|
|
50
|
+
await plugin.updateBundle(bundleId, newBundle);
|
|
51
|
+
await plugin.commitBundle();
|
|
52
|
+
},
|
|
53
|
+
async deleteBundleById(bundleId) {
|
|
54
|
+
const bundle = await plugin.getBundleById(bundleId);
|
|
55
|
+
if (!bundle) return;
|
|
56
|
+
await plugin.deleteBundle(bundle);
|
|
57
|
+
await plugin.commitBundle();
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
adapterName: plugin.name,
|
|
61
|
+
createMigrator: () => {
|
|
62
|
+
throw new Error("createMigrator is only available for Kysely/Prisma/Drizzle database adapters.");
|
|
63
|
+
},
|
|
64
|
+
generateSchema: () => {
|
|
65
|
+
throw new Error("generateSchema is only available for Kysely/Prisma/Drizzle database adapters.");
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
exports.createPluginDatabaseCore = createPluginDatabaseCore;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { getUpdateInfo } from "@hot-updater/js";
|
|
2
|
+
|
|
3
|
+
//#region src/db/pluginCore.ts
|
|
4
|
+
function createPluginDatabaseCore(plugin, resolveFileUrl) {
|
|
5
|
+
return {
|
|
6
|
+
api: {
|
|
7
|
+
async getBundleById(id) {
|
|
8
|
+
return plugin.getBundleById(id);
|
|
9
|
+
},
|
|
10
|
+
async getUpdateInfo(args) {
|
|
11
|
+
const where = {};
|
|
12
|
+
if ("platform" in args && args.platform) where.platform = args.platform;
|
|
13
|
+
where.channel = "channel" in args && args.channel ? args.channel : "production";
|
|
14
|
+
const { pagination } = await plugin.getBundles({
|
|
15
|
+
where,
|
|
16
|
+
limit: 1,
|
|
17
|
+
offset: 0
|
|
18
|
+
});
|
|
19
|
+
if (pagination.total === 0) return getUpdateInfo([], args);
|
|
20
|
+
const { data } = await plugin.getBundles({
|
|
21
|
+
where,
|
|
22
|
+
limit: pagination.total,
|
|
23
|
+
offset: 0
|
|
24
|
+
});
|
|
25
|
+
return getUpdateInfo(data, args);
|
|
26
|
+
},
|
|
27
|
+
async getAppUpdateInfo(args) {
|
|
28
|
+
const info = await this.getUpdateInfo(args);
|
|
29
|
+
if (!info) return null;
|
|
30
|
+
const { storageUri,...rest } = info;
|
|
31
|
+
const fileUrl = await resolveFileUrl(storageUri ?? null);
|
|
32
|
+
return {
|
|
33
|
+
...rest,
|
|
34
|
+
fileUrl
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
async getChannels() {
|
|
38
|
+
return plugin.getChannels();
|
|
39
|
+
},
|
|
40
|
+
async getBundles(options) {
|
|
41
|
+
return plugin.getBundles(options);
|
|
42
|
+
},
|
|
43
|
+
async insertBundle(bundle) {
|
|
44
|
+
await plugin.appendBundle(bundle);
|
|
45
|
+
await plugin.commitBundle();
|
|
46
|
+
},
|
|
47
|
+
async updateBundleById(bundleId, newBundle) {
|
|
48
|
+
await plugin.updateBundle(bundleId, newBundle);
|
|
49
|
+
await plugin.commitBundle();
|
|
50
|
+
},
|
|
51
|
+
async deleteBundleById(bundleId) {
|
|
52
|
+
const bundle = await plugin.getBundleById(bundleId);
|
|
53
|
+
if (!bundle) return;
|
|
54
|
+
await plugin.deleteBundle(bundle);
|
|
55
|
+
await plugin.commitBundle();
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
adapterName: plugin.name,
|
|
59
|
+
createMigrator: () => {
|
|
60
|
+
throw new Error("createMigrator is only available for Kysely/Prisma/Drizzle database adapters.");
|
|
61
|
+
},
|
|
62
|
+
generateSchema: () => {
|
|
63
|
+
throw new Error("generateSchema is only available for Kysely/Prisma/Drizzle database adapters.");
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
export { createPluginDatabaseCore };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/db/types.ts
|
|
3
|
+
function isDatabasePluginFactory(adapter) {
|
|
4
|
+
return typeof adapter === "function";
|
|
5
|
+
}
|
|
6
|
+
function isDatabasePlugin(adapter) {
|
|
7
|
+
return typeof adapter === "object" && adapter !== null && "getBundleById" in adapter && "getBundles" in adapter && "getChannels" in adapter;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.isDatabasePlugin = isDatabasePlugin;
|
|
12
|
+
exports.isDatabasePluginFactory = isDatabasePluginFactory;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PaginationInfo } from "../types/index.cjs";
|
|
2
|
+
import { DatabasePlugin, StoragePlugin } from "@hot-updater/plugin-core";
|
|
3
|
+
import { FumaDBAdapter } from "fumadb/adapters";
|
|
4
|
+
import { AppUpdateInfo, Bundle, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
|
|
5
|
+
|
|
6
|
+
//#region src/db/types.d.ts
|
|
7
|
+
type DatabasePluginFactory = () => DatabasePlugin;
|
|
8
|
+
type DatabaseAdapter = FumaDBAdapter | DatabasePlugin | DatabasePluginFactory;
|
|
9
|
+
interface DatabaseAPI {
|
|
10
|
+
getBundleById(id: string): Promise<Bundle | null>;
|
|
11
|
+
getUpdateInfo(args: GetBundlesArgs): Promise<UpdateInfo | null>;
|
|
12
|
+
getAppUpdateInfo(args: GetBundlesArgs): Promise<AppUpdateInfo | null>;
|
|
13
|
+
getChannels(): Promise<string[]>;
|
|
14
|
+
getBundles(options: {
|
|
15
|
+
where?: {
|
|
16
|
+
channel?: string;
|
|
17
|
+
platform?: string;
|
|
18
|
+
};
|
|
19
|
+
limit: number;
|
|
20
|
+
offset: number;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
data: Bundle[];
|
|
23
|
+
pagination: PaginationInfo;
|
|
24
|
+
}>;
|
|
25
|
+
insertBundle(bundle: Bundle): Promise<void>;
|
|
26
|
+
updateBundleById(bundleId: string, newBundle: Partial<Bundle>): Promise<void>;
|
|
27
|
+
deleteBundleById(bundleId: string): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
type StoragePluginFactory = () => StoragePlugin;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { DatabaseAPI, DatabaseAdapter, StoragePluginFactory };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PaginationInfo } from "../types/index.js";
|
|
2
|
+
import { AppUpdateInfo, Bundle, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
|
|
3
|
+
import { DatabasePlugin, StoragePlugin } from "@hot-updater/plugin-core";
|
|
4
|
+
import { FumaDBAdapter } from "fumadb/adapters";
|
|
5
|
+
|
|
6
|
+
//#region src/db/types.d.ts
|
|
7
|
+
type DatabasePluginFactory = () => DatabasePlugin;
|
|
8
|
+
type DatabaseAdapter = FumaDBAdapter | DatabasePlugin | DatabasePluginFactory;
|
|
9
|
+
interface DatabaseAPI {
|
|
10
|
+
getBundleById(id: string): Promise<Bundle | null>;
|
|
11
|
+
getUpdateInfo(args: GetBundlesArgs): Promise<UpdateInfo | null>;
|
|
12
|
+
getAppUpdateInfo(args: GetBundlesArgs): Promise<AppUpdateInfo | null>;
|
|
13
|
+
getChannels(): Promise<string[]>;
|
|
14
|
+
getBundles(options: {
|
|
15
|
+
where?: {
|
|
16
|
+
channel?: string;
|
|
17
|
+
platform?: string;
|
|
18
|
+
};
|
|
19
|
+
limit: number;
|
|
20
|
+
offset: number;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
data: Bundle[];
|
|
23
|
+
pagination: PaginationInfo;
|
|
24
|
+
}>;
|
|
25
|
+
insertBundle(bundle: Bundle): Promise<void>;
|
|
26
|
+
updateBundleById(bundleId: string, newBundle: Partial<Bundle>): Promise<void>;
|
|
27
|
+
deleteBundleById(bundleId: string): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
type StoragePluginFactory = () => StoragePlugin;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { DatabaseAPI, DatabaseAdapter, StoragePluginFactory };
|
package/dist/db/types.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/db/types.ts
|
|
2
|
+
function isDatabasePluginFactory(adapter) {
|
|
3
|
+
return typeof adapter === "function";
|
|
4
|
+
}
|
|
5
|
+
function isDatabasePlugin(adapter) {
|
|
6
|
+
return typeof adapter === "object" && adapter !== null && "getBundleById" in adapter && "getBundles" in adapter && "getChannels" in adapter;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { isDatabasePlugin, isDatabasePluginFactory };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_handler = require('./handler.cjs');
|
|
2
|
+
const require_ormCore = require('./db/ormCore.cjs');
|
|
2
3
|
const require_index = require('./db/index.cjs');
|
|
3
4
|
|
|
4
|
-
exports.HotUpdaterDB =
|
|
5
|
+
exports.HotUpdaterDB = require_ormCore.HotUpdaterDB;
|
|
5
6
|
exports.createHandler = require_handler.createHandler;
|
|
6
7
|
exports.createHotUpdater = require_index.createHotUpdater;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Bundle, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.cjs";
|
|
2
|
-
import {
|
|
2
|
+
import { HotUpdaterClient, HotUpdaterDB, Migrator } from "./db/ormCore.cjs";
|
|
3
|
+
import { HotUpdaterAPI, createHotUpdater } from "./db/index.cjs";
|
|
3
4
|
import { HandlerAPI, HandlerOptions, createHandler } from "./handler.cjs";
|
|
4
|
-
export { Bundle,
|
|
5
|
+
export { Bundle, HandlerAPI, HandlerOptions, HotUpdaterAPI, HotUpdaterClient, HotUpdaterDB, Migrator, PaginatedResult, PaginationInfo, PaginationOptions, createHandler, createHotUpdater };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Bundle, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { HotUpdaterClient, HotUpdaterDB, Migrator } from "./db/ormCore.js";
|
|
3
|
+
import { HotUpdaterAPI, createHotUpdater } from "./db/index.js";
|
|
3
4
|
import { HandlerAPI, HandlerOptions, createHandler } from "./handler.js";
|
|
4
|
-
export { Bundle,
|
|
5
|
+
export { Bundle, HandlerAPI, HandlerOptions, HotUpdaterAPI, HotUpdaterClient, HotUpdaterDB, Migrator, PaginatedResult, PaginationInfo, PaginationOptions, createHandler, createHotUpdater };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHandler } from "./handler.js";
|
|
2
|
-
import { HotUpdaterDB
|
|
2
|
+
import { HotUpdaterDB } from "./db/ormCore.js";
|
|
3
|
+
import { createHotUpdater } from "./db/index.js";
|
|
3
4
|
|
|
4
5
|
export { HotUpdaterDB, createHandler, createHotUpdater };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/server",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -49,8 +49,9 @@
|
|
|
49
49
|
"fumadb": "0.2.0",
|
|
50
50
|
"rou3": "0.7.9",
|
|
51
51
|
"semver": "^7.7.2",
|
|
52
|
-
"@hot-updater/core": "0.21.
|
|
53
|
-
"@hot-updater/
|
|
52
|
+
"@hot-updater/core": "0.21.11",
|
|
53
|
+
"@hot-updater/js": "0.21.11",
|
|
54
|
+
"@hot-updater/plugin-core": "0.21.11"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@electric-sql/pglite": "^0.2.17",
|
|
@@ -61,12 +62,12 @@
|
|
|
61
62
|
"kysely-pglite-dialect": "^1.2.0",
|
|
62
63
|
"msw": "^2.7.0",
|
|
63
64
|
"uuidv7": "^1.0.2",
|
|
64
|
-
"@hot-updater/aws": "0.21.
|
|
65
|
-
"@hot-updater/cloudflare": "0.21.
|
|
66
|
-
"@hot-updater/firebase": "0.21.
|
|
67
|
-
"@hot-updater/standalone": "0.21.
|
|
68
|
-
"@hot-updater/
|
|
69
|
-
"@hot-updater/
|
|
65
|
+
"@hot-updater/aws": "0.21.11",
|
|
66
|
+
"@hot-updater/cloudflare": "0.21.11",
|
|
67
|
+
"@hot-updater/firebase": "0.21.11",
|
|
68
|
+
"@hot-updater/standalone": "0.21.11",
|
|
69
|
+
"@hot-updater/test-utils": "0.21.11",
|
|
70
|
+
"@hot-updater/supabase": "0.21.11"
|
|
70
71
|
},
|
|
71
72
|
"scripts": {
|
|
72
73
|
"build": "tsdown",
|