@hot-updater/standalone 0.36.6 → 1.0.0-rc.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.
package/dist/index.cjs CHANGED
@@ -1,49 +1,332 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
2
+ let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
3
+ //#region src/standaloneBundleRows.ts
4
+ async function loadRows(remote, model) {
5
+ return model === "bundles" ? remote.loadBundleRows() : (await remote.loadBundles()).flatMap(_hot_updater_plugin_core.bundleToPatchRows);
6
+ }
7
+ //#endregion
8
+ //#region src/standaloneDatabaseQuery.ts
9
+ const compare$1 = (left, right) => {
10
+ if (typeof left === "number" && typeof right === "number") return left - right;
11
+ return String(left).localeCompare(String(right));
12
+ };
13
+ const compareString = (actual, expected, mode, predicate) => {
14
+ if (typeof actual !== "string") return false;
15
+ return mode === "insensitive" ? predicate(actual.toLocaleLowerCase(), expected.toLocaleLowerCase()) : predicate(actual, expected);
16
+ };
17
+ const matchesCondition = (row, condition) => {
18
+ const actual = Reflect.get(row, condition.field);
19
+ const expected = Reflect.get(condition, "value");
20
+ switch (Reflect.get(condition, "operator") ?? "eq") {
21
+ case "eq":
22
+ if (typeof expected === "string") return compareString(actual, expected, Reflect.get(condition, "mode"), (value, query) => value === query);
23
+ return actual === expected;
24
+ case "ne":
25
+ if (actual === null || actual === void 0) return false;
26
+ if (typeof expected === "string") return !compareString(actual, expected, Reflect.get(condition, "mode"), (value, query) => value === query);
27
+ return actual !== expected;
28
+ case "gt":
29
+ if (actual === null || actual === void 0) return false;
30
+ return compare$1(actual, expected) > 0;
31
+ case "gte":
32
+ if (actual === null || actual === void 0) return false;
33
+ return compare$1(actual, expected) >= 0;
34
+ case "lt":
35
+ if (actual === null || actual === void 0) return false;
36
+ return compare$1(actual, expected) < 0;
37
+ case "lte":
38
+ if (actual === null || actual === void 0) return false;
39
+ return compare$1(actual, expected) <= 0;
40
+ case "in": return Array.isArray(expected) && expected.some((candidate) => candidate === actual);
41
+ case "not_in": return Array.isArray(expected) && (expected.length === 0 || actual !== null && actual !== void 0 && expected.every((candidate) => candidate !== actual));
42
+ case "contains": return typeof expected === "string" ? compareString(actual, expected, Reflect.get(condition, "mode"), (value, query) => value.includes(query)) : false;
43
+ case "starts_with": return typeof expected === "string" ? compareString(actual, expected, Reflect.get(condition, "mode"), (value, query) => value.startsWith(query)) : false;
44
+ case "ends_with": return typeof expected === "string" ? compareString(actual, expected, Reflect.get(condition, "mode"), (value, query) => value.endsWith(query)) : false;
45
+ default: return false;
46
+ }
47
+ };
48
+ const matchesStandaloneWhere = (row, where) => {
49
+ if (!where || where.length === 0) return true;
50
+ let result = matchesCondition(row, where[0]);
51
+ for (const condition of where.slice(1)) {
52
+ const current = matchesCondition(row, condition);
53
+ result = condition.connector === "OR" ? result || current : result && current;
54
+ }
55
+ return result;
56
+ };
57
+ const queryStandaloneRows = (rows, input) => {
58
+ const filtered = rows.filter((row) => matchesStandaloneWhere(row, input.where));
59
+ if (input.orderBy) {
60
+ const direction = input.orderBy.direction === "asc" ? 1 : -1;
61
+ filtered.sort((left, right) => compare$1(Reflect.get(left, input.orderBy?.field ?? "id"), Reflect.get(right, input.orderBy?.field ?? "id")) * direction);
62
+ }
63
+ const offset = input.offset ?? 0;
64
+ return filtered.slice(offset, offset + (input.limit ?? filtered.length));
65
+ };
66
+ //#endregion
67
+ //#region src/standaloneBundleReads.ts
68
+ const compare = (left, right) => {
69
+ if (typeof left === "number" && typeof right === "number") return left - right;
70
+ return String(left).localeCompare(String(right));
71
+ };
72
+ const queryBundleRows = (rows, input) => {
73
+ const filtered = queryStandaloneRows(rows, { where: input.where });
74
+ const orderBy = input.orderBy;
75
+ if (orderBy !== void 0) filtered.sort((left, right) => {
76
+ for (const clause of orderBy) {
77
+ const leftValue = Reflect.get(left, clause.field);
78
+ const rightValue = Reflect.get(right, clause.field);
79
+ if (leftValue === rightValue) continue;
80
+ if (leftValue === null || rightValue === null) {
81
+ const nulls = clause.nulls ?? (clause.direction === "asc" ? "last" : "first");
82
+ return leftValue === null ? nulls === "first" ? -1 : 1 : nulls === "first" ? 1 : -1;
83
+ }
84
+ const result = compare(leftValue, rightValue);
85
+ if (result !== 0) return clause.direction === "asc" ? result : -result;
86
+ }
87
+ return 0;
88
+ });
89
+ return (input.distinctOn === void 0 ? filtered : filtered.filter((row, index, ordered) => ordered.findIndex((candidate) => JSON.stringify(input.distinctOn?.fields.map((field) => Reflect.get(candidate, field))) === JSON.stringify(input.distinctOn?.fields.map((field) => Reflect.get(row, field)))) === index)).slice(input.offset, input.offset + input.limit);
90
+ };
91
+ const countDistinctRows = (rows, fields) => fields === void 0 ? rows.length : new Set(rows.map((row) => JSON.stringify(fields.map((field) => Reflect.get(row, field))))).size;
92
+ const createBundleReads = (remote) => ({
93
+ async count(input) {
94
+ switch (input.model) {
95
+ case "bundles": {
96
+ const where = input.where;
97
+ if (input.distinct === void 0) {
98
+ const remoteWindow = await remote.loadBundleWindow({
99
+ where,
100
+ limit: 1,
101
+ offset: 0
102
+ });
103
+ if (remoteWindow) return remoteWindow.total;
104
+ }
105
+ return countDistinctRows(queryStandaloneRows(await loadRows(remote, "bundles"), { where }), input.distinct);
106
+ }
107
+ case "bundle_patches": return countDistinctRows(queryStandaloneRows(await loadRows(remote, "bundle_patches"), { where: input.where }), input.distinct);
108
+ }
109
+ },
110
+ async findOne(input) {
111
+ if (input.model === "bundles") {
112
+ const idSelector = input.where?.length === 1 ? input.where[0] : void 0;
113
+ if (idSelector?.field === "id" && (idSelector.operator === void 0 || idSelector.operator === "eq") && typeof idSelector.value === "string") {
114
+ const row = await remote.loadBundleRow(idSelector.value);
115
+ return row && matchesStandaloneWhere(row, input.where) ? row : null;
116
+ }
117
+ return queryStandaloneRows(await loadRows(remote, "bundles"), {
118
+ where: input.where,
119
+ limit: 1
120
+ })[0] ?? null;
121
+ }
122
+ return queryStandaloneRows(await loadRows(remote, "bundle_patches"), {
123
+ where: input.where,
124
+ limit: 1
125
+ })[0] ?? null;
126
+ },
127
+ async findMany(input) {
128
+ switch (input.model) {
129
+ case "bundles": {
130
+ const where = input.where;
131
+ const orderBy = input.orderBy;
132
+ const remoteSort = orderBy?.length === 1 && orderBy[0]?.field === "id" ? orderBy[0] : void 0;
133
+ if (input.distinctOn === void 0 && (orderBy === void 0 || remoteSort)) {
134
+ const remoteWindow = await remote.loadBundleWindow({
135
+ where,
136
+ limit: input.limit,
137
+ offset: input.offset,
138
+ orderBy: remoteSort
139
+ });
140
+ if (remoteWindow) return remoteWindow.rows;
141
+ }
142
+ return queryBundleRows(await loadRows(remote, "bundles"), {
143
+ distinctOn: input.distinctOn,
144
+ where,
145
+ limit: input.limit,
146
+ offset: input.offset,
147
+ orderBy: input.orderBy
148
+ });
149
+ }
150
+ case "bundle_patches": return queryBundleRows(await loadRows(remote, "bundle_patches"), {
151
+ distinctOn: input.distinctOn,
152
+ where: input.where,
153
+ limit: input.limit,
154
+ offset: input.offset,
155
+ orderBy: input.orderBy
156
+ });
157
+ }
158
+ }
159
+ });
160
+ //#endregion
161
+ //#region src/standaloneBundleReader.ts
162
+ const createStandaloneBundleReader = (remote) => createBundleReads(remote);
163
+ //#endregion
164
+ //#region src/standaloneBundleWhere.ts
165
+ const appendBundleWhere = (url, where) => {
166
+ const usedParameters = /* @__PURE__ */ new Set();
167
+ const setParameter = (parameter, value) => {
168
+ if (usedParameters.has(parameter)) return false;
169
+ usedParameters.add(parameter);
170
+ url.searchParams.set(parameter, value);
171
+ return true;
172
+ };
173
+ const appendParameter = (parameter, values) => {
174
+ if (values.length === 0 || usedParameters.has(parameter)) return false;
175
+ usedParameters.add(parameter);
176
+ for (const value of values) url.searchParams.append(parameter, value);
177
+ return true;
178
+ };
179
+ for (const [index, condition] of (where ?? []).entries()) {
180
+ if (index > 0 && condition.connector === "OR") return false;
181
+ const operator = condition.operator ?? "eq";
182
+ switch (condition.field) {
183
+ case "platform":
184
+ if (operator !== "eq" || typeof condition.value !== "string") return false;
185
+ if (!setParameter("platform", condition.value)) return false;
186
+ break;
187
+ case "id": {
188
+ let parameter;
189
+ switch (operator) {
190
+ case "eq":
191
+ parameter = "idEq";
192
+ break;
193
+ case "gt":
194
+ parameter = "idGt";
195
+ break;
196
+ case "gte":
197
+ parameter = "idGte";
198
+ break;
199
+ case "lt":
200
+ parameter = "idLt";
201
+ break;
202
+ case "lte":
203
+ parameter = "idLte";
204
+ break;
205
+ }
206
+ if (parameter && typeof condition.value === "string") {
207
+ if (!setParameter(parameter, condition.value)) return false;
208
+ break;
209
+ }
210
+ if (operator === "in" && Array.isArray(condition.value)) {
211
+ if (!condition.value.every((value) => typeof value === "string")) return false;
212
+ if (!appendParameter("idIn", condition.value)) return false;
213
+ break;
214
+ }
215
+ return false;
216
+ }
217
+ default: return false;
218
+ }
219
+ }
220
+ return true;
221
+ };
222
+ //#endregion
223
+ //#region src/standaloneHttp.ts
224
+ var StandaloneDatabaseError = class extends Error {
225
+ name = "StandaloneDatabaseError";
226
+ constructor(code, message, status) {
227
+ super(message);
228
+ this.code = code;
229
+ this.status = status;
230
+ }
231
+ };
232
+ const isRecord$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
233
+ const createStandaloneHttp = (config) => {
234
+ const baseUrl = config.baseUrl.replace(/\/+$/, "");
235
+ const buildUrl = (path) => `${baseUrl}${path}`;
236
+ const headers = (routeHeaders) => ({
237
+ "Content-Type": "application/json",
238
+ ...config.commonHeaders,
239
+ ...routeHeaders
240
+ });
241
+ const requestFailed = async (response) => {
242
+ let message = `Database request failed with status ${response.status}.`;
243
+ try {
244
+ const body = await response.json();
245
+ if (isRecord$2(body) && typeof body.message === "string") message = body.message;
246
+ else if (isRecord$2(body) && typeof body.error === "string") message = body.error;
247
+ } catch (error) {
248
+ if (!(error instanceof SyntaxError)) throw error;
249
+ }
250
+ throw new StandaloneDatabaseError("request-failed", message, response.status);
251
+ };
252
+ const parseJson = async (response) => {
253
+ if (!response.ok) return requestFailed(response);
254
+ try {
255
+ return await response.json();
256
+ } catch {
257
+ throw new StandaloneDatabaseError("invalid-response", "Database response must contain JSON.", response.status);
258
+ }
259
+ };
260
+ const load = async (route, searchParams, isResult, invalidMessage, signal) => {
261
+ const url = new URL(buildUrl(route.path));
262
+ for (const [key, value] of Object.entries(searchParams)) url.searchParams.set(key, value);
263
+ const response = await fetch(url, {
264
+ method: "GET",
265
+ headers: headers(route.headers),
266
+ signal
16
267
  });
268
+ const value = await parseJson(response);
269
+ if (!isResult(value)) throw new StandaloneDatabaseError("invalid-response", invalidMessage, response.status);
270
+ return value;
271
+ };
272
+ return {
273
+ buildUrl,
274
+ headers,
275
+ load,
276
+ parseJson,
277
+ requestFailed
278
+ };
279
+ };
280
+ //#endregion
281
+ //#region src/standaloneResponseGuards.ts
282
+ const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
283
+ const isNonNegativeInteger = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
284
+ const isByteSize = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
285
+ const isBundlePatch = (value) => isRecord$1(value) && typeof value.baseBundleId === "string" && typeof value.baseFileHash === "string" && isByteSize(value.byteSize) && typeof value.patchFileHash === "string" && typeof value.patchStorageUri === "string";
286
+ const isChannelText = (value) => {
287
+ if (typeof value !== "string" || value.length === 0) return false;
288
+ let codePoints = 0;
289
+ for (const _codePoint of value) {
290
+ codePoints += 1;
291
+ if (codePoints > 255) return false;
17
292
  }
18
- return to;
293
+ return true;
19
294
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
- value: mod,
22
- enumerable: true
23
- }) : target, mod));
295
+ const isChannelRow = (value) => isRecord$1(value) && isChannelText(value.id) && isChannelText(value.name);
296
+ const isBundle = (value) => isRecord$1(value) && typeof value.id === "string" && (value.platform === "ios" || value.platform === "android") && typeof value.fileHash === "string" && typeof value.storageUri === "string" && isByteSize(value.archiveByteSize) && (value.patches === void 0 || value.patches === null || Array.isArray(value.patches) && value.patches.every(isBundlePatch));
297
+ const isPaginationInfo = (value) => isRecord$1(value) && isNonNegativeInteger(value.total) && typeof value.hasNextPage === "boolean" && typeof value.hasPreviousPage === "boolean" && isNonNegativeInteger(value.currentPage) && value.currentPage >= 1 && isNonNegativeInteger(value.totalPages);
298
+ const isPaginatedResult = (value) => isRecord$1(value) && Array.isArray(value.data) && value.data.every(isBundle) && isPaginationInfo(value.pagination);
299
+ const hasChannels = (value) => isRecord$1(value) && isRecord$1(value.data) && Array.isArray(value.data.channels) && value.data.channels.every(isChannelRow);
300
+ const hasChannelInsertResult = (value) => isRecord$1(value) && isRecord$1(value.data) && isChannelRow(value.data.row) && typeof value.data.inserted === "boolean";
301
+ const hasChannelDeleteResult = (value) => isRecord$1(value) && isRecord$1(value.data) && (value.data.deleted === true || value.data.deleted === false && (value.data.reason === "not_empty" || value.data.reason === "not_found"));
24
302
  //#endregion
25
- let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
26
- let fs_promises = require("fs/promises");
27
- fs_promises = __toESM(fs_promises);
28
- let path = require("path");
29
- path = __toESM(path);
30
- //#region src/standaloneRepository.ts
303
+ //#region src/standaloneRoutes.ts
304
+ function bundlePath(bundleId) {
305
+ return `/bundles/${encodeURIComponent(bundleId)}`;
306
+ }
307
+ function channelPath(channelId) {
308
+ return `/channels/${encodeURIComponent(channelId)}`;
309
+ }
31
310
  const defaultRoutes$1 = {
32
- create: () => ({ path: "/api/bundles" }),
33
- update: (bundleId) => ({ path: `/api/bundles/${bundleId}` }),
311
+ create: () => ({ path: "/bundles" }),
312
+ update: (bundleId) => ({ path: bundlePath(bundleId) }),
34
313
  list: () => ({
35
- path: "/api/bundles",
314
+ path: "/bundles",
36
315
  headers: { "Cache-Control": "no-cache" }
37
316
  }),
38
317
  channels: () => ({
39
- path: "/api/bundles/channels",
318
+ path: "/channels",
40
319
  headers: { "Cache-Control": "no-cache" }
41
320
  }),
321
+ deleteChannel: (channelId) => ({
322
+ path: channelPath(channelId),
323
+ headers: {}
324
+ }),
42
325
  retrieve: (bundleId) => ({
43
- path: `/api/bundles/${bundleId}`,
326
+ path: bundlePath(bundleId),
44
327
  headers: { Accept: "application/json" }
45
328
  }),
46
- delete: (bundleId) => ({ path: `/api/bundles/${bundleId}` })
329
+ delete: (bundleId) => ({ path: bundlePath(bundleId) })
47
330
  };
48
331
  const createRoute$1 = (defaultRoute, customRoute) => ({
49
332
  path: customRoute?.path ?? defaultRoute.path,
@@ -52,1453 +335,339 @@ const createRoute$1 = (defaultRoute, customRoute) => ({
52
335
  ...customRoute?.headers
53
336
  }
54
337
  });
55
- const appendPathSegment = (path, segment) => `${path.replace(/\/+$/, "")}/${segment}`;
56
- const isRecord = (value) => typeof value === "object" && value !== null;
57
- const isStringArray = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
58
- const isPaginatedResult = (value) => isRecord(value) && Array.isArray(value.data) && isRecord(value.pagination);
59
- const hasDataChannels = (value) => isRecord(value) && isRecord(value.data) && isStringArray(value.data.channels);
60
- const setBooleanSearchParam = (url, key, value) => {
61
- if (value !== void 0) url.searchParams.set(key, String(value));
62
- };
63
- const setNullableStringSearchParam = (url, key, value) => {
64
- if (value !== void 0) url.searchParams.set(key, value === null ? "null" : value);
65
- };
66
- const appendStringArraySearchParams = (url, key, values) => {
67
- for (const value of values ?? []) url.searchParams.append(key, value);
68
- };
69
- const setBundleIdFilterSearchParams = (url, filter) => {
70
- if (!filter) return;
71
- if (filter.eq !== void 0) url.searchParams.set("idEq", filter.eq);
72
- if (filter.gt !== void 0) url.searchParams.set("idGt", filter.gt);
73
- if (filter.gte !== void 0) url.searchParams.set("idGte", filter.gte);
74
- if (filter.lt !== void 0) url.searchParams.set("idLt", filter.lt);
75
- if (filter.lte !== void 0) url.searchParams.set("idLte", filter.lte);
76
- appendStringArraySearchParams(url, "idIn", filter.in);
77
- };
78
- const standaloneRepository = (0, _hot_updater_plugin_core.createDatabasePlugin)({
79
- name: "standalone-repository",
80
- factory: (config) => {
81
- const customListRoute = config.routes?.list?.();
82
- const routes = {
83
- list: () => createRoute$1(defaultRoutes$1.list(), customListRoute),
84
- channels: () => {
85
- return createRoute$1(customListRoute ? {
86
- path: appendPathSegment(customListRoute.path, "channels"),
87
- headers: {
88
- ...defaultRoutes$1.channels().headers,
89
- ...customListRoute.headers
90
- }
91
- } : defaultRoutes$1.channels(), config.routes?.channels?.());
92
- },
93
- create: () => createRoute$1(defaultRoutes$1.create(), config.routes?.create?.()),
94
- update: (bundleId) => createRoute$1(defaultRoutes$1.update(bundleId), config.routes?.update?.(bundleId)),
95
- retrieve: (bundleId) => createRoute$1(defaultRoutes$1.retrieve(bundleId), config.routes?.retrieve?.(bundleId)),
96
- delete: (bundleId) => createRoute$1(defaultRoutes$1.delete(bundleId), config.routes?.delete?.(bundleId))
338
+ //#endregion
339
+ //#region src/standaloneBundleRemote.ts
340
+ const PAGE_SIZE = 100;
341
+ const createStandaloneBundleRemote = (config) => {
342
+ const routes = {
343
+ list: () => createRoute$1(defaultRoutes$1.list(), config.routes?.list?.()),
344
+ channels: defaultRoutes$1.channels,
345
+ deleteChannel: defaultRoutes$1.deleteChannel,
346
+ create: () => createRoute$1(defaultRoutes$1.create(), config.routes?.create?.()),
347
+ update: (bundleId) => createRoute$1(defaultRoutes$1.update(bundleId), config.routes?.update?.(bundleId)),
348
+ retrieve: (bundleId) => createRoute$1(defaultRoutes$1.retrieve(bundleId), config.routes?.retrieve?.(bundleId)),
349
+ delete: (bundleId) => createRoute$1(defaultRoutes$1.delete(bundleId), config.routes?.delete?.(bundleId))
350
+ };
351
+ const http = createStandaloneHttp(config);
352
+ const loadBundles = async () => {
353
+ const bundles = [];
354
+ for (let page = 1;; page += 1) {
355
+ const route = routes.list();
356
+ const url = new URL(http.buildUrl(route.path));
357
+ url.searchParams.set("limit", String(PAGE_SIZE));
358
+ url.searchParams.set("page", String(page));
359
+ const response = await fetch(url, {
360
+ method: "GET",
361
+ headers: http.headers(route.headers)
362
+ });
363
+ const value = await http.parseJson(response);
364
+ if (!isPaginatedResult(value)) throw new StandaloneDatabaseError("invalid-response", "Invalid bundle list response.", response.status);
365
+ bundles.push(...value.data);
366
+ if (value.data.length < PAGE_SIZE || value.pagination.hasNextPage === false || bundles.length >= value.pagination.total) return bundles;
367
+ }
368
+ };
369
+ const loadChannels = async () => {
370
+ const route = routes.channels();
371
+ const response = await fetch(http.buildUrl(route.path), {
372
+ method: "GET",
373
+ headers: http.headers(route.headers)
374
+ });
375
+ const value = await http.parseJson(response);
376
+ if (!hasChannels(value)) throw new StandaloneDatabaseError("invalid-response", "Invalid channels response.", response.status);
377
+ return value.data.channels;
378
+ };
379
+ const bundlesToRows = async (bundles) => bundles.map((bundle) => (0, _hot_updater_plugin_core.bundleToRow)(bundle));
380
+ const loadBundleWindow = async (input) => {
381
+ if (input.limit === 0) return {
382
+ rows: [],
383
+ total: 0
97
384
  };
98
- const buildUrl = (path) => `${config.baseUrl}${path}`;
99
- const getHeaders = (routeHeaders) => ({
100
- "Content-Type": "application/json",
101
- ...config.commonHeaders,
102
- ...routeHeaders
385
+ if (input.orderBy && input.orderBy.field !== "id") return null;
386
+ const route = routes.list();
387
+ const url = new URL(http.buildUrl(route.path));
388
+ if (!appendBundleWhere(url, input.where)) return null;
389
+ if (input.orderBy !== void 0) url.searchParams.set("orderDirection", input.orderBy.direction);
390
+ const pageAligned = input.limit > 0 && input.offset % input.limit === 0;
391
+ const remoteLimit = pageAligned ? input.limit : input.offset + input.limit;
392
+ if (remoteLimit > PAGE_SIZE) return null;
393
+ url.searchParams.set("limit", String(remoteLimit));
394
+ url.searchParams.set("page", String(pageAligned ? input.offset / input.limit + 1 : 1));
395
+ const response = await fetch(url, {
396
+ method: "GET",
397
+ headers: http.headers(route.headers)
103
398
  });
399
+ const value = await http.parseJson(response);
400
+ if (!isPaginatedResult(value)) throw new StandaloneDatabaseError("invalid-response", "Invalid bundle list response.", response.status);
104
401
  return {
105
- supportsCursorPagination: true,
106
- async getBundleById(bundleId) {
107
- try {
108
- const { path, headers: routeHeaders } = routes.retrieve(bundleId);
109
- const response = await fetch(buildUrl(path), {
110
- method: "GET",
111
- headers: getHeaders(routeHeaders)
112
- });
113
- if (!response.ok) return null;
114
- return await response.json();
115
- } catch {
116
- return null;
117
- }
118
- },
119
- async getBundles(options) {
120
- const { where, limit, cursor, page } = options ?? {};
121
- const internalOffset = options && typeof options === "object" && "offset" in options && typeof options.offset === "number" ? options.offset : void 0;
122
- const { path, headers: routeHeaders } = routes.list();
123
- const url = new URL(buildUrl(path));
124
- const resolvedPage = page ?? (internalOffset !== void 0 && limit > 0 ? Math.floor(internalOffset / limit) + 1 : void 0);
125
- if (where?.channel !== void 0) url.searchParams.set("channel", where.channel);
126
- if (where?.platform !== void 0) url.searchParams.set("platform", where.platform);
127
- setBooleanSearchParam(url, "enabled", where?.enabled);
128
- setBundleIdFilterSearchParams(url, where?.id);
129
- setNullableStringSearchParam(url, "targetAppVersion", where?.targetAppVersion);
130
- appendStringArraySearchParams(url, "targetAppVersionIn", where?.targetAppVersionIn);
131
- setBooleanSearchParam(url, "targetAppVersionNotNull", where?.targetAppVersionNotNull);
132
- setNullableStringSearchParam(url, "fingerprintHash", where?.fingerprintHash);
133
- if (limit !== void 0) url.searchParams.set("limit", String(limit));
134
- if (resolvedPage !== void 0) url.searchParams.set("page", String(resolvedPage));
135
- if (cursor?.after !== void 0) url.searchParams.set("after", cursor.after);
136
- if (cursor?.before !== void 0) url.searchParams.set("before", cursor.before);
137
- const response = await fetch(url.toString(), {
138
- method: "GET",
139
- headers: getHeaders(routeHeaders)
140
- });
141
- if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
142
- const result = await response.json();
143
- if (isPaginatedResult(result)) return result;
144
- throw new Error("API Error: Invalid bundle list response");
145
- },
146
- async getChannels() {
147
- const { path, headers: routeHeaders } = routes.channels();
148
- const response = await fetch(buildUrl(path), {
149
- method: "GET",
150
- headers: getHeaders(routeHeaders)
151
- });
152
- if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
153
- const result = await response.json();
154
- if (hasDataChannels(result)) return result.data.channels;
155
- throw new Error("API Error: Invalid channels response");
156
- },
157
- async commitBundle({ changedSets }) {
158
- if (changedSets.length === 0) return;
159
- for (const op of changedSets) if (op.operation === "delete") {
160
- const { path, headers: routeHeaders } = routes.delete(op.data.id);
161
- const response = await fetch(buildUrl(path), {
162
- method: "DELETE",
163
- headers: getHeaders(routeHeaders)
164
- });
165
- if (!response.ok) {
166
- if (response.status === 404) throw new Error(`Bundle with id ${op.data.id} not found`);
167
- throw new Error(`API Error: ${response.status} ${response.statusText}`);
168
- }
169
- if (response.headers.get("content-type")?.includes("application/json")) try {
170
- await response.json();
171
- } catch {
172
- if (!response.ok) throw new Error("Failed to parse response");
173
- }
174
- } else if (op.operation === "insert") {
175
- const { path, headers: routeHeaders } = routes.create();
176
- const response = await fetch(buildUrl(path), {
177
- method: "POST",
178
- headers: getHeaders(routeHeaders),
179
- body: JSON.stringify([op.data])
180
- });
181
- if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
182
- if (!(await response.json()).success) throw new Error("Failed to commit bundle");
183
- } else if (op.operation === "update") {
184
- const { path, headers: routeHeaders } = routes.update(op.data.id);
185
- const response = await fetch(buildUrl(path), {
186
- method: "PATCH",
187
- headers: getHeaders(routeHeaders),
188
- body: JSON.stringify(op.data)
189
- });
190
- if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
191
- if (!(await response.json()).success) throw new Error("Failed to commit bundle");
192
- }
193
- }
402
+ rows: await bundlesToRows(pageAligned ? value.data : value.data.slice(input.offset, input.offset + input.limit)),
403
+ total: value.pagination.total
194
404
  };
195
- }
196
- });
197
- //#endregion
198
- //#region ../../node_modules/.pnpm/mime@2.6.0/node_modules/mime/Mime.js
199
- var require_Mime = /* @__PURE__ */ __commonJSMin(((exports, module) => {
200
- /**
201
- * @param typeMap [Object] Map of MIME type -> Array[extensions]
202
- * @param ...
203
- */
204
- function Mime() {
205
- this._types = Object.create(null);
206
- this._extensions = Object.create(null);
207
- for (let i = 0; i < arguments.length; i++) this.define(arguments[i]);
208
- this.define = this.define.bind(this);
209
- this.getType = this.getType.bind(this);
210
- this.getExtension = this.getExtension.bind(this);
211
- }
212
- /**
213
- * Define mimetype -> extension mappings. Each key is a mime-type that maps
214
- * to an array of extensions associated with the type. The first extension is
215
- * used as the default extension for the type.
216
- *
217
- * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
218
- *
219
- * If a type declares an extension that has already been defined, an error will
220
- * be thrown. To suppress this error and force the extension to be associated
221
- * with the new type, pass `force`=true. Alternatively, you may prefix the
222
- * extension with "*" to map the type to extension, without mapping the
223
- * extension to the type.
224
- *
225
- * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
226
- *
227
- *
228
- * @param map (Object) type definitions
229
- * @param force (Boolean) if true, force overriding of existing definitions
230
- */
231
- Mime.prototype.define = function(typeMap, force) {
232
- for (let type in typeMap) {
233
- let extensions = typeMap[type].map(function(t) {
234
- return t.toLowerCase();
235
- });
236
- type = type.toLowerCase();
237
- for (let i = 0; i < extensions.length; i++) {
238
- const ext = extensions[i];
239
- if (ext[0] === "*") continue;
240
- if (!force && ext in this._types) throw new Error("Attempt to change mapping for \"" + ext + "\" extension from \"" + this._types[ext] + "\" to \"" + type + "\". Pass `force=true` to allow this, otherwise remove \"" + ext + "\" from the list of extensions for \"" + type + "\".");
241
- this._types[ext] = type;
242
- }
243
- if (force || !this._extensions[type]) {
244
- const ext = extensions[0];
245
- this._extensions[type] = ext[0] !== "*" ? ext : ext.substr(1);
246
- }
405
+ };
406
+ const insertChannel = async (input) => {
407
+ const route = routes.channels();
408
+ const response = await fetch(http.buildUrl(route.path), {
409
+ method: "POST",
410
+ headers: http.headers(route.headers),
411
+ body: JSON.stringify(input)
412
+ });
413
+ const value = await http.parseJson(response);
414
+ if (!hasChannelInsertResult(value)) throw new StandaloneDatabaseError("invalid-response", "Invalid Channel insert response.", response.status);
415
+ if (value.data.row.name !== input.row.name || value.data.inserted && value.data.row.id !== input.row.id) throw new StandaloneDatabaseError("invalid-response", "Invalid Channel insert response.", response.status);
416
+ return value.data;
417
+ };
418
+ const deleteChannel = async (input) => {
419
+ const route = routes.deleteChannel(input.id);
420
+ const response = await fetch(http.buildUrl(route.path), {
421
+ method: "DELETE",
422
+ headers: http.headers(route.headers)
423
+ });
424
+ if (response.status === 204) return { deleted: true };
425
+ let value;
426
+ try {
427
+ value = await response.json();
428
+ } catch {
429
+ throw new StandaloneDatabaseError("invalid-response", "Database response must contain JSON.", response.status);
247
430
  }
431
+ if (!hasChannelDeleteResult(value)) throw new StandaloneDatabaseError("invalid-response", "Invalid Channel delete response.", response.status);
432
+ return value.data;
248
433
  };
249
- /**
250
- * Lookup a mime type based on extension
251
- */
252
- Mime.prototype.getType = function(path) {
253
- path = String(path);
254
- let last = path.replace(/^.*[/\\]/, "").toLowerCase();
255
- let ext = last.replace(/^.*\./, "").toLowerCase();
256
- let hasPath = last.length < path.length;
257
- return (ext.length < last.length - 1 || !hasPath) && this._types[ext] || null;
434
+ const loadBundle = async (bundleId) => {
435
+ const route = routes.retrieve(bundleId);
436
+ const response = await fetch(http.buildUrl(route.path), {
437
+ method: "GET",
438
+ headers: http.headers(route.headers)
439
+ });
440
+ if (response.status === 404) return null;
441
+ const value = await http.parseJson(response);
442
+ if (!isBundle(value)) throw new StandaloneDatabaseError("invalid-response", "Invalid bundle response.", response.status);
443
+ return value;
258
444
  };
259
- /**
260
- * Return file extension associated with a mime type
261
- */
262
- Mime.prototype.getExtension = function(type) {
263
- type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
264
- return type && this._extensions[type.toLowerCase()] || null;
445
+ const loadBundleRow = async (bundleId) => {
446
+ const bundle = await loadBundle(bundleId);
447
+ return bundle ? (await bundlesToRows([bundle]))[0] ?? null : null;
265
448
  };
266
- module.exports = Mime;
267
- }));
268
- //#endregion
269
- //#region ../../node_modules/.pnpm/mime@2.6.0/node_modules/mime/types/standard.js
270
- var require_standard = /* @__PURE__ */ __commonJSMin(((exports, module) => {
271
- module.exports = {
272
- "application/andrew-inset": ["ez"],
273
- "application/applixware": ["aw"],
274
- "application/atom+xml": ["atom"],
275
- "application/atomcat+xml": ["atomcat"],
276
- "application/atomdeleted+xml": ["atomdeleted"],
277
- "application/atomsvc+xml": ["atomsvc"],
278
- "application/atsc-dwd+xml": ["dwd"],
279
- "application/atsc-held+xml": ["held"],
280
- "application/atsc-rsat+xml": ["rsat"],
281
- "application/bdoc": ["bdoc"],
282
- "application/calendar+xml": ["xcs"],
283
- "application/ccxml+xml": ["ccxml"],
284
- "application/cdfx+xml": ["cdfx"],
285
- "application/cdmi-capability": ["cdmia"],
286
- "application/cdmi-container": ["cdmic"],
287
- "application/cdmi-domain": ["cdmid"],
288
- "application/cdmi-object": ["cdmio"],
289
- "application/cdmi-queue": ["cdmiq"],
290
- "application/cu-seeme": ["cu"],
291
- "application/dash+xml": ["mpd"],
292
- "application/davmount+xml": ["davmount"],
293
- "application/docbook+xml": ["dbk"],
294
- "application/dssc+der": ["dssc"],
295
- "application/dssc+xml": ["xdssc"],
296
- "application/ecmascript": ["es", "ecma"],
297
- "application/emma+xml": ["emma"],
298
- "application/emotionml+xml": ["emotionml"],
299
- "application/epub+zip": ["epub"],
300
- "application/exi": ["exi"],
301
- "application/express": ["exp"],
302
- "application/fdt+xml": ["fdt"],
303
- "application/font-tdpfr": ["pfr"],
304
- "application/geo+json": ["geojson"],
305
- "application/gml+xml": ["gml"],
306
- "application/gpx+xml": ["gpx"],
307
- "application/gxf": ["gxf"],
308
- "application/gzip": ["gz"],
309
- "application/hjson": ["hjson"],
310
- "application/hyperstudio": ["stk"],
311
- "application/inkml+xml": ["ink", "inkml"],
312
- "application/ipfix": ["ipfix"],
313
- "application/its+xml": ["its"],
314
- "application/java-archive": [
315
- "jar",
316
- "war",
317
- "ear"
318
- ],
319
- "application/java-serialized-object": ["ser"],
320
- "application/java-vm": ["class"],
321
- "application/javascript": ["js", "mjs"],
322
- "application/json": ["json", "map"],
323
- "application/json5": ["json5"],
324
- "application/jsonml+json": ["jsonml"],
325
- "application/ld+json": ["jsonld"],
326
- "application/lgr+xml": ["lgr"],
327
- "application/lost+xml": ["lostxml"],
328
- "application/mac-binhex40": ["hqx"],
329
- "application/mac-compactpro": ["cpt"],
330
- "application/mads+xml": ["mads"],
331
- "application/manifest+json": ["webmanifest"],
332
- "application/marc": ["mrc"],
333
- "application/marcxml+xml": ["mrcx"],
334
- "application/mathematica": [
335
- "ma",
336
- "nb",
337
- "mb"
338
- ],
339
- "application/mathml+xml": ["mathml"],
340
- "application/mbox": ["mbox"],
341
- "application/mediaservercontrol+xml": ["mscml"],
342
- "application/metalink+xml": ["metalink"],
343
- "application/metalink4+xml": ["meta4"],
344
- "application/mets+xml": ["mets"],
345
- "application/mmt-aei+xml": ["maei"],
346
- "application/mmt-usd+xml": ["musd"],
347
- "application/mods+xml": ["mods"],
348
- "application/mp21": ["m21", "mp21"],
349
- "application/mp4": ["mp4s", "m4p"],
350
- "application/msword": ["doc", "dot"],
351
- "application/mxf": ["mxf"],
352
- "application/n-quads": ["nq"],
353
- "application/n-triples": ["nt"],
354
- "application/node": ["cjs"],
355
- "application/octet-stream": [
356
- "bin",
357
- "dms",
358
- "lrf",
359
- "mar",
360
- "so",
361
- "dist",
362
- "distz",
363
- "pkg",
364
- "bpk",
365
- "dump",
366
- "elc",
367
- "deploy",
368
- "exe",
369
- "dll",
370
- "deb",
371
- "dmg",
372
- "iso",
373
- "img",
374
- "msi",
375
- "msp",
376
- "msm",
377
- "buffer"
378
- ],
379
- "application/oda": ["oda"],
380
- "application/oebps-package+xml": ["opf"],
381
- "application/ogg": ["ogx"],
382
- "application/omdoc+xml": ["omdoc"],
383
- "application/onenote": [
384
- "onetoc",
385
- "onetoc2",
386
- "onetmp",
387
- "onepkg"
388
- ],
389
- "application/oxps": ["oxps"],
390
- "application/p2p-overlay+xml": ["relo"],
391
- "application/patch-ops-error+xml": ["xer"],
392
- "application/pdf": ["pdf"],
393
- "application/pgp-encrypted": ["pgp"],
394
- "application/pgp-signature": ["asc", "sig"],
395
- "application/pics-rules": ["prf"],
396
- "application/pkcs10": ["p10"],
397
- "application/pkcs7-mime": ["p7m", "p7c"],
398
- "application/pkcs7-signature": ["p7s"],
399
- "application/pkcs8": ["p8"],
400
- "application/pkix-attr-cert": ["ac"],
401
- "application/pkix-cert": ["cer"],
402
- "application/pkix-crl": ["crl"],
403
- "application/pkix-pkipath": ["pkipath"],
404
- "application/pkixcmp": ["pki"],
405
- "application/pls+xml": ["pls"],
406
- "application/postscript": [
407
- "ai",
408
- "eps",
409
- "ps"
410
- ],
411
- "application/provenance+xml": ["provx"],
412
- "application/pskc+xml": ["pskcxml"],
413
- "application/raml+yaml": ["raml"],
414
- "application/rdf+xml": ["rdf", "owl"],
415
- "application/reginfo+xml": ["rif"],
416
- "application/relax-ng-compact-syntax": ["rnc"],
417
- "application/resource-lists+xml": ["rl"],
418
- "application/resource-lists-diff+xml": ["rld"],
419
- "application/rls-services+xml": ["rs"],
420
- "application/route-apd+xml": ["rapd"],
421
- "application/route-s-tsid+xml": ["sls"],
422
- "application/route-usd+xml": ["rusd"],
423
- "application/rpki-ghostbusters": ["gbr"],
424
- "application/rpki-manifest": ["mft"],
425
- "application/rpki-roa": ["roa"],
426
- "application/rsd+xml": ["rsd"],
427
- "application/rss+xml": ["rss"],
428
- "application/rtf": ["rtf"],
429
- "application/sbml+xml": ["sbml"],
430
- "application/scvp-cv-request": ["scq"],
431
- "application/scvp-cv-response": ["scs"],
432
- "application/scvp-vp-request": ["spq"],
433
- "application/scvp-vp-response": ["spp"],
434
- "application/sdp": ["sdp"],
435
- "application/senml+xml": ["senmlx"],
436
- "application/sensml+xml": ["sensmlx"],
437
- "application/set-payment-initiation": ["setpay"],
438
- "application/set-registration-initiation": ["setreg"],
439
- "application/shf+xml": ["shf"],
440
- "application/sieve": ["siv", "sieve"],
441
- "application/smil+xml": ["smi", "smil"],
442
- "application/sparql-query": ["rq"],
443
- "application/sparql-results+xml": ["srx"],
444
- "application/srgs": ["gram"],
445
- "application/srgs+xml": ["grxml"],
446
- "application/sru+xml": ["sru"],
447
- "application/ssdl+xml": ["ssdl"],
448
- "application/ssml+xml": ["ssml"],
449
- "application/swid+xml": ["swidtag"],
450
- "application/tei+xml": ["tei", "teicorpus"],
451
- "application/thraud+xml": ["tfi"],
452
- "application/timestamped-data": ["tsd"],
453
- "application/toml": ["toml"],
454
- "application/trig": ["trig"],
455
- "application/ttml+xml": ["ttml"],
456
- "application/ubjson": ["ubj"],
457
- "application/urc-ressheet+xml": ["rsheet"],
458
- "application/urc-targetdesc+xml": ["td"],
459
- "application/voicexml+xml": ["vxml"],
460
- "application/wasm": ["wasm"],
461
- "application/widget": ["wgt"],
462
- "application/winhlp": ["hlp"],
463
- "application/wsdl+xml": ["wsdl"],
464
- "application/wspolicy+xml": ["wspolicy"],
465
- "application/xaml+xml": ["xaml"],
466
- "application/xcap-att+xml": ["xav"],
467
- "application/xcap-caps+xml": ["xca"],
468
- "application/xcap-diff+xml": ["xdf"],
469
- "application/xcap-el+xml": ["xel"],
470
- "application/xcap-ns+xml": ["xns"],
471
- "application/xenc+xml": ["xenc"],
472
- "application/xhtml+xml": ["xhtml", "xht"],
473
- "application/xliff+xml": ["xlf"],
474
- "application/xml": [
475
- "xml",
476
- "xsl",
477
- "xsd",
478
- "rng"
479
- ],
480
- "application/xml-dtd": ["dtd"],
481
- "application/xop+xml": ["xop"],
482
- "application/xproc+xml": ["xpl"],
483
- "application/xslt+xml": ["*xsl", "xslt"],
484
- "application/xspf+xml": ["xspf"],
485
- "application/xv+xml": [
486
- "mxml",
487
- "xhvml",
488
- "xvml",
489
- "xvm"
490
- ],
491
- "application/yang": ["yang"],
492
- "application/yin+xml": ["yin"],
493
- "application/zip": ["zip"],
494
- "audio/3gpp": ["*3gpp"],
495
- "audio/adpcm": ["adp"],
496
- "audio/amr": ["amr"],
497
- "audio/basic": ["au", "snd"],
498
- "audio/midi": [
499
- "mid",
500
- "midi",
501
- "kar",
502
- "rmi"
503
- ],
504
- "audio/mobile-xmf": ["mxmf"],
505
- "audio/mp3": ["*mp3"],
506
- "audio/mp4": ["m4a", "mp4a"],
507
- "audio/mpeg": [
508
- "mpga",
509
- "mp2",
510
- "mp2a",
511
- "mp3",
512
- "m2a",
513
- "m3a"
514
- ],
515
- "audio/ogg": [
516
- "oga",
517
- "ogg",
518
- "spx",
519
- "opus"
520
- ],
521
- "audio/s3m": ["s3m"],
522
- "audio/silk": ["sil"],
523
- "audio/wav": ["wav"],
524
- "audio/wave": ["*wav"],
525
- "audio/webm": ["weba"],
526
- "audio/xm": ["xm"],
527
- "font/collection": ["ttc"],
528
- "font/otf": ["otf"],
529
- "font/ttf": ["ttf"],
530
- "font/woff": ["woff"],
531
- "font/woff2": ["woff2"],
532
- "image/aces": ["exr"],
533
- "image/apng": ["apng"],
534
- "image/avif": ["avif"],
535
- "image/bmp": ["bmp"],
536
- "image/cgm": ["cgm"],
537
- "image/dicom-rle": ["drle"],
538
- "image/emf": ["emf"],
539
- "image/fits": ["fits"],
540
- "image/g3fax": ["g3"],
541
- "image/gif": ["gif"],
542
- "image/heic": ["heic"],
543
- "image/heic-sequence": ["heics"],
544
- "image/heif": ["heif"],
545
- "image/heif-sequence": ["heifs"],
546
- "image/hej2k": ["hej2"],
547
- "image/hsj2": ["hsj2"],
548
- "image/ief": ["ief"],
549
- "image/jls": ["jls"],
550
- "image/jp2": ["jp2", "jpg2"],
551
- "image/jpeg": [
552
- "jpeg",
553
- "jpg",
554
- "jpe"
555
- ],
556
- "image/jph": ["jph"],
557
- "image/jphc": ["jhc"],
558
- "image/jpm": ["jpm"],
559
- "image/jpx": ["jpx", "jpf"],
560
- "image/jxr": ["jxr"],
561
- "image/jxra": ["jxra"],
562
- "image/jxrs": ["jxrs"],
563
- "image/jxs": ["jxs"],
564
- "image/jxsc": ["jxsc"],
565
- "image/jxsi": ["jxsi"],
566
- "image/jxss": ["jxss"],
567
- "image/ktx": ["ktx"],
568
- "image/ktx2": ["ktx2"],
569
- "image/png": ["png"],
570
- "image/sgi": ["sgi"],
571
- "image/svg+xml": ["svg", "svgz"],
572
- "image/t38": ["t38"],
573
- "image/tiff": ["tif", "tiff"],
574
- "image/tiff-fx": ["tfx"],
575
- "image/webp": ["webp"],
576
- "image/wmf": ["wmf"],
577
- "message/disposition-notification": ["disposition-notification"],
578
- "message/global": ["u8msg"],
579
- "message/global-delivery-status": ["u8dsn"],
580
- "message/global-disposition-notification": ["u8mdn"],
581
- "message/global-headers": ["u8hdr"],
582
- "message/rfc822": ["eml", "mime"],
583
- "model/3mf": ["3mf"],
584
- "model/gltf+json": ["gltf"],
585
- "model/gltf-binary": ["glb"],
586
- "model/iges": ["igs", "iges"],
587
- "model/mesh": [
588
- "msh",
589
- "mesh",
590
- "silo"
591
- ],
592
- "model/mtl": ["mtl"],
593
- "model/obj": ["obj"],
594
- "model/step+xml": ["stpx"],
595
- "model/step+zip": ["stpz"],
596
- "model/step-xml+zip": ["stpxz"],
597
- "model/stl": ["stl"],
598
- "model/vrml": ["wrl", "vrml"],
599
- "model/x3d+binary": ["*x3db", "x3dbz"],
600
- "model/x3d+fastinfoset": ["x3db"],
601
- "model/x3d+vrml": ["*x3dv", "x3dvz"],
602
- "model/x3d+xml": ["x3d", "x3dz"],
603
- "model/x3d-vrml": ["x3dv"],
604
- "text/cache-manifest": ["appcache", "manifest"],
605
- "text/calendar": ["ics", "ifb"],
606
- "text/coffeescript": ["coffee", "litcoffee"],
607
- "text/css": ["css"],
608
- "text/csv": ["csv"],
609
- "text/html": [
610
- "html",
611
- "htm",
612
- "shtml"
613
- ],
614
- "text/jade": ["jade"],
615
- "text/jsx": ["jsx"],
616
- "text/less": ["less"],
617
- "text/markdown": ["markdown", "md"],
618
- "text/mathml": ["mml"],
619
- "text/mdx": ["mdx"],
620
- "text/n3": ["n3"],
621
- "text/plain": [
622
- "txt",
623
- "text",
624
- "conf",
625
- "def",
626
- "list",
627
- "log",
628
- "in",
629
- "ini"
630
- ],
631
- "text/richtext": ["rtx"],
632
- "text/rtf": ["*rtf"],
633
- "text/sgml": ["sgml", "sgm"],
634
- "text/shex": ["shex"],
635
- "text/slim": ["slim", "slm"],
636
- "text/spdx": ["spdx"],
637
- "text/stylus": ["stylus", "styl"],
638
- "text/tab-separated-values": ["tsv"],
639
- "text/troff": [
640
- "t",
641
- "tr",
642
- "roff",
643
- "man",
644
- "me",
645
- "ms"
646
- ],
647
- "text/turtle": ["ttl"],
648
- "text/uri-list": [
649
- "uri",
650
- "uris",
651
- "urls"
652
- ],
653
- "text/vcard": ["vcard"],
654
- "text/vtt": ["vtt"],
655
- "text/xml": ["*xml"],
656
- "text/yaml": ["yaml", "yml"],
657
- "video/3gpp": ["3gp", "3gpp"],
658
- "video/3gpp2": ["3g2"],
659
- "video/h261": ["h261"],
660
- "video/h263": ["h263"],
661
- "video/h264": ["h264"],
662
- "video/iso.segment": ["m4s"],
663
- "video/jpeg": ["jpgv"],
664
- "video/jpm": ["*jpm", "jpgm"],
665
- "video/mj2": ["mj2", "mjp2"],
666
- "video/mp2t": ["ts"],
667
- "video/mp4": [
668
- "mp4",
669
- "mp4v",
670
- "mpg4"
671
- ],
672
- "video/mpeg": [
673
- "mpeg",
674
- "mpg",
675
- "mpe",
676
- "m1v",
677
- "m2v"
678
- ],
679
- "video/ogg": ["ogv"],
680
- "video/quicktime": ["qt", "mov"],
681
- "video/webm": ["webm"]
449
+ const loadBundleRows = async () => bundlesToRows(await loadBundles());
450
+ const updateBundle = async (bundle) => {
451
+ const route = routes.update(bundle.id);
452
+ const response = await fetch(http.buildUrl(route.path), {
453
+ method: "PATCH",
454
+ headers: http.headers(route.headers),
455
+ body: JSON.stringify(bundle)
456
+ });
457
+ await http.parseJson(response);
458
+ };
459
+ const createBundles = async (bundles) => {
460
+ const route = routes.create();
461
+ const response = await fetch(http.buildUrl(route.path), {
462
+ method: "POST",
463
+ headers: http.headers(route.headers),
464
+ body: JSON.stringify(bundles)
465
+ });
466
+ await http.parseJson(response);
467
+ };
468
+ const deleteBundle = async (bundleId) => {
469
+ const route = routes.delete(bundleId);
470
+ const response = await fetch(http.buildUrl(route.path), {
471
+ method: "DELETE",
472
+ headers: http.headers(route.headers)
473
+ });
474
+ await http.parseJson(response);
475
+ };
476
+ return {
477
+ createBundle: (bundle) => createBundles([bundle]),
478
+ createBundles,
479
+ deleteBundle,
480
+ deleteChannel,
481
+ insertChannel,
482
+ loadBundle,
483
+ loadBundleRow,
484
+ loadBundleRows,
485
+ loadBundles,
486
+ loadBundleWindow,
487
+ loadChannels,
488
+ updateBundle
682
489
  };
683
- }));
490
+ };
684
491
  //#endregion
685
- //#region ../../node_modules/.pnpm/mime@2.6.0/node_modules/mime/types/other.js
686
- var require_other = /* @__PURE__ */ __commonJSMin(((exports, module) => {
687
- module.exports = {
688
- "application/prs.cww": ["cww"],
689
- "application/vnd.1000minds.decision-model+xml": ["1km"],
690
- "application/vnd.3gpp.pic-bw-large": ["plb"],
691
- "application/vnd.3gpp.pic-bw-small": ["psb"],
692
- "application/vnd.3gpp.pic-bw-var": ["pvb"],
693
- "application/vnd.3gpp2.tcap": ["tcap"],
694
- "application/vnd.3m.post-it-notes": ["pwn"],
695
- "application/vnd.accpac.simply.aso": ["aso"],
696
- "application/vnd.accpac.simply.imp": ["imp"],
697
- "application/vnd.acucobol": ["acu"],
698
- "application/vnd.acucorp": ["atc", "acutc"],
699
- "application/vnd.adobe.air-application-installer-package+zip": ["air"],
700
- "application/vnd.adobe.formscentral.fcdt": ["fcdt"],
701
- "application/vnd.adobe.fxp": ["fxp", "fxpl"],
702
- "application/vnd.adobe.xdp+xml": ["xdp"],
703
- "application/vnd.adobe.xfdf": ["xfdf"],
704
- "application/vnd.ahead.space": ["ahead"],
705
- "application/vnd.airzip.filesecure.azf": ["azf"],
706
- "application/vnd.airzip.filesecure.azs": ["azs"],
707
- "application/vnd.amazon.ebook": ["azw"],
708
- "application/vnd.americandynamics.acc": ["acc"],
709
- "application/vnd.amiga.ami": ["ami"],
710
- "application/vnd.android.package-archive": ["apk"],
711
- "application/vnd.anser-web-certificate-issue-initiation": ["cii"],
712
- "application/vnd.anser-web-funds-transfer-initiation": ["fti"],
713
- "application/vnd.antix.game-component": ["atx"],
714
- "application/vnd.apple.installer+xml": ["mpkg"],
715
- "application/vnd.apple.keynote": ["key"],
716
- "application/vnd.apple.mpegurl": ["m3u8"],
717
- "application/vnd.apple.numbers": ["numbers"],
718
- "application/vnd.apple.pages": ["pages"],
719
- "application/vnd.apple.pkpass": ["pkpass"],
720
- "application/vnd.aristanetworks.swi": ["swi"],
721
- "application/vnd.astraea-software.iota": ["iota"],
722
- "application/vnd.audiograph": ["aep"],
723
- "application/vnd.balsamiq.bmml+xml": ["bmml"],
724
- "application/vnd.blueice.multipass": ["mpm"],
725
- "application/vnd.bmi": ["bmi"],
726
- "application/vnd.businessobjects": ["rep"],
727
- "application/vnd.chemdraw+xml": ["cdxml"],
728
- "application/vnd.chipnuts.karaoke-mmd": ["mmd"],
729
- "application/vnd.cinderella": ["cdy"],
730
- "application/vnd.citationstyles.style+xml": ["csl"],
731
- "application/vnd.claymore": ["cla"],
732
- "application/vnd.cloanto.rp9": ["rp9"],
733
- "application/vnd.clonk.c4group": [
734
- "c4g",
735
- "c4d",
736
- "c4f",
737
- "c4p",
738
- "c4u"
739
- ],
740
- "application/vnd.cluetrust.cartomobile-config": ["c11amc"],
741
- "application/vnd.cluetrust.cartomobile-config-pkg": ["c11amz"],
742
- "application/vnd.commonspace": ["csp"],
743
- "application/vnd.contact.cmsg": ["cdbcmsg"],
744
- "application/vnd.cosmocaller": ["cmc"],
745
- "application/vnd.crick.clicker": ["clkx"],
746
- "application/vnd.crick.clicker.keyboard": ["clkk"],
747
- "application/vnd.crick.clicker.palette": ["clkp"],
748
- "application/vnd.crick.clicker.template": ["clkt"],
749
- "application/vnd.crick.clicker.wordbank": ["clkw"],
750
- "application/vnd.criticaltools.wbs+xml": ["wbs"],
751
- "application/vnd.ctc-posml": ["pml"],
752
- "application/vnd.cups-ppd": ["ppd"],
753
- "application/vnd.curl.car": ["car"],
754
- "application/vnd.curl.pcurl": ["pcurl"],
755
- "application/vnd.dart": ["dart"],
756
- "application/vnd.data-vision.rdz": ["rdz"],
757
- "application/vnd.dbf": ["dbf"],
758
- "application/vnd.dece.data": [
759
- "uvf",
760
- "uvvf",
761
- "uvd",
762
- "uvvd"
763
- ],
764
- "application/vnd.dece.ttml+xml": ["uvt", "uvvt"],
765
- "application/vnd.dece.unspecified": ["uvx", "uvvx"],
766
- "application/vnd.dece.zip": ["uvz", "uvvz"],
767
- "application/vnd.denovo.fcselayout-link": ["fe_launch"],
768
- "application/vnd.dna": ["dna"],
769
- "application/vnd.dolby.mlp": ["mlp"],
770
- "application/vnd.dpgraph": ["dpg"],
771
- "application/vnd.dreamfactory": ["dfac"],
772
- "application/vnd.ds-keypoint": ["kpxx"],
773
- "application/vnd.dvb.ait": ["ait"],
774
- "application/vnd.dvb.service": ["svc"],
775
- "application/vnd.dynageo": ["geo"],
776
- "application/vnd.ecowin.chart": ["mag"],
777
- "application/vnd.enliven": ["nml"],
778
- "application/vnd.epson.esf": ["esf"],
779
- "application/vnd.epson.msf": ["msf"],
780
- "application/vnd.epson.quickanime": ["qam"],
781
- "application/vnd.epson.salt": ["slt"],
782
- "application/vnd.epson.ssf": ["ssf"],
783
- "application/vnd.eszigno3+xml": ["es3", "et3"],
784
- "application/vnd.ezpix-album": ["ez2"],
785
- "application/vnd.ezpix-package": ["ez3"],
786
- "application/vnd.fdf": ["fdf"],
787
- "application/vnd.fdsn.mseed": ["mseed"],
788
- "application/vnd.fdsn.seed": ["seed", "dataless"],
789
- "application/vnd.flographit": ["gph"],
790
- "application/vnd.fluxtime.clip": ["ftc"],
791
- "application/vnd.framemaker": [
792
- "fm",
793
- "frame",
794
- "maker",
795
- "book"
796
- ],
797
- "application/vnd.frogans.fnc": ["fnc"],
798
- "application/vnd.frogans.ltf": ["ltf"],
799
- "application/vnd.fsc.weblaunch": ["fsc"],
800
- "application/vnd.fujitsu.oasys": ["oas"],
801
- "application/vnd.fujitsu.oasys2": ["oa2"],
802
- "application/vnd.fujitsu.oasys3": ["oa3"],
803
- "application/vnd.fujitsu.oasysgp": ["fg5"],
804
- "application/vnd.fujitsu.oasysprs": ["bh2"],
805
- "application/vnd.fujixerox.ddd": ["ddd"],
806
- "application/vnd.fujixerox.docuworks": ["xdw"],
807
- "application/vnd.fujixerox.docuworks.binder": ["xbd"],
808
- "application/vnd.fuzzysheet": ["fzs"],
809
- "application/vnd.genomatix.tuxedo": ["txd"],
810
- "application/vnd.geogebra.file": ["ggb"],
811
- "application/vnd.geogebra.tool": ["ggt"],
812
- "application/vnd.geometry-explorer": ["gex", "gre"],
813
- "application/vnd.geonext": ["gxt"],
814
- "application/vnd.geoplan": ["g2w"],
815
- "application/vnd.geospace": ["g3w"],
816
- "application/vnd.gmx": ["gmx"],
817
- "application/vnd.google-apps.document": ["gdoc"],
818
- "application/vnd.google-apps.presentation": ["gslides"],
819
- "application/vnd.google-apps.spreadsheet": ["gsheet"],
820
- "application/vnd.google-earth.kml+xml": ["kml"],
821
- "application/vnd.google-earth.kmz": ["kmz"],
822
- "application/vnd.grafeq": ["gqf", "gqs"],
823
- "application/vnd.groove-account": ["gac"],
824
- "application/vnd.groove-help": ["ghf"],
825
- "application/vnd.groove-identity-message": ["gim"],
826
- "application/vnd.groove-injector": ["grv"],
827
- "application/vnd.groove-tool-message": ["gtm"],
828
- "application/vnd.groove-tool-template": ["tpl"],
829
- "application/vnd.groove-vcard": ["vcg"],
830
- "application/vnd.hal+xml": ["hal"],
831
- "application/vnd.handheld-entertainment+xml": ["zmm"],
832
- "application/vnd.hbci": ["hbci"],
833
- "application/vnd.hhe.lesson-player": ["les"],
834
- "application/vnd.hp-hpgl": ["hpgl"],
835
- "application/vnd.hp-hpid": ["hpid"],
836
- "application/vnd.hp-hps": ["hps"],
837
- "application/vnd.hp-jlyt": ["jlt"],
838
- "application/vnd.hp-pcl": ["pcl"],
839
- "application/vnd.hp-pclxl": ["pclxl"],
840
- "application/vnd.hydrostatix.sof-data": ["sfd-hdstx"],
841
- "application/vnd.ibm.minipay": ["mpy"],
842
- "application/vnd.ibm.modcap": [
843
- "afp",
844
- "listafp",
845
- "list3820"
846
- ],
847
- "application/vnd.ibm.rights-management": ["irm"],
848
- "application/vnd.ibm.secure-container": ["sc"],
849
- "application/vnd.iccprofile": ["icc", "icm"],
850
- "application/vnd.igloader": ["igl"],
851
- "application/vnd.immervision-ivp": ["ivp"],
852
- "application/vnd.immervision-ivu": ["ivu"],
853
- "application/vnd.insors.igm": ["igm"],
854
- "application/vnd.intercon.formnet": ["xpw", "xpx"],
855
- "application/vnd.intergeo": ["i2g"],
856
- "application/vnd.intu.qbo": ["qbo"],
857
- "application/vnd.intu.qfx": ["qfx"],
858
- "application/vnd.ipunplugged.rcprofile": ["rcprofile"],
859
- "application/vnd.irepository.package+xml": ["irp"],
860
- "application/vnd.is-xpr": ["xpr"],
861
- "application/vnd.isac.fcs": ["fcs"],
862
- "application/vnd.jam": ["jam"],
863
- "application/vnd.jcp.javame.midlet-rms": ["rms"],
864
- "application/vnd.jisp": ["jisp"],
865
- "application/vnd.joost.joda-archive": ["joda"],
866
- "application/vnd.kahootz": ["ktz", "ktr"],
867
- "application/vnd.kde.karbon": ["karbon"],
868
- "application/vnd.kde.kchart": ["chrt"],
869
- "application/vnd.kde.kformula": ["kfo"],
870
- "application/vnd.kde.kivio": ["flw"],
871
- "application/vnd.kde.kontour": ["kon"],
872
- "application/vnd.kde.kpresenter": ["kpr", "kpt"],
873
- "application/vnd.kde.kspread": ["ksp"],
874
- "application/vnd.kde.kword": ["kwd", "kwt"],
875
- "application/vnd.kenameaapp": ["htke"],
876
- "application/vnd.kidspiration": ["kia"],
877
- "application/vnd.kinar": ["kne", "knp"],
878
- "application/vnd.koan": [
879
- "skp",
880
- "skd",
881
- "skt",
882
- "skm"
883
- ],
884
- "application/vnd.kodak-descriptor": ["sse"],
885
- "application/vnd.las.las+xml": ["lasxml"],
886
- "application/vnd.llamagraphics.life-balance.desktop": ["lbd"],
887
- "application/vnd.llamagraphics.life-balance.exchange+xml": ["lbe"],
888
- "application/vnd.lotus-1-2-3": ["123"],
889
- "application/vnd.lotus-approach": ["apr"],
890
- "application/vnd.lotus-freelance": ["pre"],
891
- "application/vnd.lotus-notes": ["nsf"],
892
- "application/vnd.lotus-organizer": ["org"],
893
- "application/vnd.lotus-screencam": ["scm"],
894
- "application/vnd.lotus-wordpro": ["lwp"],
895
- "application/vnd.macports.portpkg": ["portpkg"],
896
- "application/vnd.mapbox-vector-tile": ["mvt"],
897
- "application/vnd.mcd": ["mcd"],
898
- "application/vnd.medcalcdata": ["mc1"],
899
- "application/vnd.mediastation.cdkey": ["cdkey"],
900
- "application/vnd.mfer": ["mwf"],
901
- "application/vnd.mfmp": ["mfm"],
902
- "application/vnd.micrografx.flo": ["flo"],
903
- "application/vnd.micrografx.igx": ["igx"],
904
- "application/vnd.mif": ["mif"],
905
- "application/vnd.mobius.daf": ["daf"],
906
- "application/vnd.mobius.dis": ["dis"],
907
- "application/vnd.mobius.mbk": ["mbk"],
908
- "application/vnd.mobius.mqy": ["mqy"],
909
- "application/vnd.mobius.msl": ["msl"],
910
- "application/vnd.mobius.plc": ["plc"],
911
- "application/vnd.mobius.txf": ["txf"],
912
- "application/vnd.mophun.application": ["mpn"],
913
- "application/vnd.mophun.certificate": ["mpc"],
914
- "application/vnd.mozilla.xul+xml": ["xul"],
915
- "application/vnd.ms-artgalry": ["cil"],
916
- "application/vnd.ms-cab-compressed": ["cab"],
917
- "application/vnd.ms-excel": [
918
- "xls",
919
- "xlm",
920
- "xla",
921
- "xlc",
922
- "xlt",
923
- "xlw"
924
- ],
925
- "application/vnd.ms-excel.addin.macroenabled.12": ["xlam"],
926
- "application/vnd.ms-excel.sheet.binary.macroenabled.12": ["xlsb"],
927
- "application/vnd.ms-excel.sheet.macroenabled.12": ["xlsm"],
928
- "application/vnd.ms-excel.template.macroenabled.12": ["xltm"],
929
- "application/vnd.ms-fontobject": ["eot"],
930
- "application/vnd.ms-htmlhelp": ["chm"],
931
- "application/vnd.ms-ims": ["ims"],
932
- "application/vnd.ms-lrm": ["lrm"],
933
- "application/vnd.ms-officetheme": ["thmx"],
934
- "application/vnd.ms-outlook": ["msg"],
935
- "application/vnd.ms-pki.seccat": ["cat"],
936
- "application/vnd.ms-pki.stl": ["*stl"],
937
- "application/vnd.ms-powerpoint": [
938
- "ppt",
939
- "pps",
940
- "pot"
941
- ],
942
- "application/vnd.ms-powerpoint.addin.macroenabled.12": ["ppam"],
943
- "application/vnd.ms-powerpoint.presentation.macroenabled.12": ["pptm"],
944
- "application/vnd.ms-powerpoint.slide.macroenabled.12": ["sldm"],
945
- "application/vnd.ms-powerpoint.slideshow.macroenabled.12": ["ppsm"],
946
- "application/vnd.ms-powerpoint.template.macroenabled.12": ["potm"],
947
- "application/vnd.ms-project": ["mpp", "mpt"],
948
- "application/vnd.ms-word.document.macroenabled.12": ["docm"],
949
- "application/vnd.ms-word.template.macroenabled.12": ["dotm"],
950
- "application/vnd.ms-works": [
951
- "wps",
952
- "wks",
953
- "wcm",
954
- "wdb"
955
- ],
956
- "application/vnd.ms-wpl": ["wpl"],
957
- "application/vnd.ms-xpsdocument": ["xps"],
958
- "application/vnd.mseq": ["mseq"],
959
- "application/vnd.musician": ["mus"],
960
- "application/vnd.muvee.style": ["msty"],
961
- "application/vnd.mynfc": ["taglet"],
962
- "application/vnd.neurolanguage.nlu": ["nlu"],
963
- "application/vnd.nitf": ["ntf", "nitf"],
964
- "application/vnd.noblenet-directory": ["nnd"],
965
- "application/vnd.noblenet-sealer": ["nns"],
966
- "application/vnd.noblenet-web": ["nnw"],
967
- "application/vnd.nokia.n-gage.ac+xml": ["*ac"],
968
- "application/vnd.nokia.n-gage.data": ["ngdat"],
969
- "application/vnd.nokia.n-gage.symbian.install": ["n-gage"],
970
- "application/vnd.nokia.radio-preset": ["rpst"],
971
- "application/vnd.nokia.radio-presets": ["rpss"],
972
- "application/vnd.novadigm.edm": ["edm"],
973
- "application/vnd.novadigm.edx": ["edx"],
974
- "application/vnd.novadigm.ext": ["ext"],
975
- "application/vnd.oasis.opendocument.chart": ["odc"],
976
- "application/vnd.oasis.opendocument.chart-template": ["otc"],
977
- "application/vnd.oasis.opendocument.database": ["odb"],
978
- "application/vnd.oasis.opendocument.formula": ["odf"],
979
- "application/vnd.oasis.opendocument.formula-template": ["odft"],
980
- "application/vnd.oasis.opendocument.graphics": ["odg"],
981
- "application/vnd.oasis.opendocument.graphics-template": ["otg"],
982
- "application/vnd.oasis.opendocument.image": ["odi"],
983
- "application/vnd.oasis.opendocument.image-template": ["oti"],
984
- "application/vnd.oasis.opendocument.presentation": ["odp"],
985
- "application/vnd.oasis.opendocument.presentation-template": ["otp"],
986
- "application/vnd.oasis.opendocument.spreadsheet": ["ods"],
987
- "application/vnd.oasis.opendocument.spreadsheet-template": ["ots"],
988
- "application/vnd.oasis.opendocument.text": ["odt"],
989
- "application/vnd.oasis.opendocument.text-master": ["odm"],
990
- "application/vnd.oasis.opendocument.text-template": ["ott"],
991
- "application/vnd.oasis.opendocument.text-web": ["oth"],
992
- "application/vnd.olpc-sugar": ["xo"],
993
- "application/vnd.oma.dd2+xml": ["dd2"],
994
- "application/vnd.openblox.game+xml": ["obgx"],
995
- "application/vnd.openofficeorg.extension": ["oxt"],
996
- "application/vnd.openstreetmap.data+xml": ["osm"],
997
- "application/vnd.openxmlformats-officedocument.presentationml.presentation": ["pptx"],
998
- "application/vnd.openxmlformats-officedocument.presentationml.slide": ["sldx"],
999
- "application/vnd.openxmlformats-officedocument.presentationml.slideshow": ["ppsx"],
1000
- "application/vnd.openxmlformats-officedocument.presentationml.template": ["potx"],
1001
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ["xlsx"],
1002
- "application/vnd.openxmlformats-officedocument.spreadsheetml.template": ["xltx"],
1003
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document": ["docx"],
1004
- "application/vnd.openxmlformats-officedocument.wordprocessingml.template": ["dotx"],
1005
- "application/vnd.osgeo.mapguide.package": ["mgp"],
1006
- "application/vnd.osgi.dp": ["dp"],
1007
- "application/vnd.osgi.subsystem": ["esa"],
1008
- "application/vnd.palm": [
1009
- "pdb",
1010
- "pqa",
1011
- "oprc"
1012
- ],
1013
- "application/vnd.pawaafile": ["paw"],
1014
- "application/vnd.pg.format": ["str"],
1015
- "application/vnd.pg.osasli": ["ei6"],
1016
- "application/vnd.picsel": ["efif"],
1017
- "application/vnd.pmi.widget": ["wg"],
1018
- "application/vnd.pocketlearn": ["plf"],
1019
- "application/vnd.powerbuilder6": ["pbd"],
1020
- "application/vnd.previewsystems.box": ["box"],
1021
- "application/vnd.proteus.magazine": ["mgz"],
1022
- "application/vnd.publishare-delta-tree": ["qps"],
1023
- "application/vnd.pvi.ptid1": ["ptid"],
1024
- "application/vnd.quark.quarkxpress": [
1025
- "qxd",
1026
- "qxt",
1027
- "qwd",
1028
- "qwt",
1029
- "qxl",
1030
- "qxb"
1031
- ],
1032
- "application/vnd.rar": ["rar"],
1033
- "application/vnd.realvnc.bed": ["bed"],
1034
- "application/vnd.recordare.musicxml": ["mxl"],
1035
- "application/vnd.recordare.musicxml+xml": ["musicxml"],
1036
- "application/vnd.rig.cryptonote": ["cryptonote"],
1037
- "application/vnd.rim.cod": ["cod"],
1038
- "application/vnd.rn-realmedia": ["rm"],
1039
- "application/vnd.rn-realmedia-vbr": ["rmvb"],
1040
- "application/vnd.route66.link66+xml": ["link66"],
1041
- "application/vnd.sailingtracker.track": ["st"],
1042
- "application/vnd.seemail": ["see"],
1043
- "application/vnd.sema": ["sema"],
1044
- "application/vnd.semd": ["semd"],
1045
- "application/vnd.semf": ["semf"],
1046
- "application/vnd.shana.informed.formdata": ["ifm"],
1047
- "application/vnd.shana.informed.formtemplate": ["itp"],
1048
- "application/vnd.shana.informed.interchange": ["iif"],
1049
- "application/vnd.shana.informed.package": ["ipk"],
1050
- "application/vnd.simtech-mindmapper": ["twd", "twds"],
1051
- "application/vnd.smaf": ["mmf"],
1052
- "application/vnd.smart.teacher": ["teacher"],
1053
- "application/vnd.software602.filler.form+xml": ["fo"],
1054
- "application/vnd.solent.sdkm+xml": ["sdkm", "sdkd"],
1055
- "application/vnd.spotfire.dxp": ["dxp"],
1056
- "application/vnd.spotfire.sfs": ["sfs"],
1057
- "application/vnd.stardivision.calc": ["sdc"],
1058
- "application/vnd.stardivision.draw": ["sda"],
1059
- "application/vnd.stardivision.impress": ["sdd"],
1060
- "application/vnd.stardivision.math": ["smf"],
1061
- "application/vnd.stardivision.writer": ["sdw", "vor"],
1062
- "application/vnd.stardivision.writer-global": ["sgl"],
1063
- "application/vnd.stepmania.package": ["smzip"],
1064
- "application/vnd.stepmania.stepchart": ["sm"],
1065
- "application/vnd.sun.wadl+xml": ["wadl"],
1066
- "application/vnd.sun.xml.calc": ["sxc"],
1067
- "application/vnd.sun.xml.calc.template": ["stc"],
1068
- "application/vnd.sun.xml.draw": ["sxd"],
1069
- "application/vnd.sun.xml.draw.template": ["std"],
1070
- "application/vnd.sun.xml.impress": ["sxi"],
1071
- "application/vnd.sun.xml.impress.template": ["sti"],
1072
- "application/vnd.sun.xml.math": ["sxm"],
1073
- "application/vnd.sun.xml.writer": ["sxw"],
1074
- "application/vnd.sun.xml.writer.global": ["sxg"],
1075
- "application/vnd.sun.xml.writer.template": ["stw"],
1076
- "application/vnd.sus-calendar": ["sus", "susp"],
1077
- "application/vnd.svd": ["svd"],
1078
- "application/vnd.symbian.install": ["sis", "sisx"],
1079
- "application/vnd.syncml+xml": ["xsm"],
1080
- "application/vnd.syncml.dm+wbxml": ["bdm"],
1081
- "application/vnd.syncml.dm+xml": ["xdm"],
1082
- "application/vnd.syncml.dmddf+xml": ["ddf"],
1083
- "application/vnd.tao.intent-module-archive": ["tao"],
1084
- "application/vnd.tcpdump.pcap": [
1085
- "pcap",
1086
- "cap",
1087
- "dmp"
1088
- ],
1089
- "application/vnd.tmobile-livetv": ["tmo"],
1090
- "application/vnd.trid.tpt": ["tpt"],
1091
- "application/vnd.triscape.mxs": ["mxs"],
1092
- "application/vnd.trueapp": ["tra"],
1093
- "application/vnd.ufdl": ["ufd", "ufdl"],
1094
- "application/vnd.uiq.theme": ["utz"],
1095
- "application/vnd.umajin": ["umj"],
1096
- "application/vnd.unity": ["unityweb"],
1097
- "application/vnd.uoml+xml": ["uoml"],
1098
- "application/vnd.vcx": ["vcx"],
1099
- "application/vnd.visio": [
1100
- "vsd",
1101
- "vst",
1102
- "vss",
1103
- "vsw"
1104
- ],
1105
- "application/vnd.visionary": ["vis"],
1106
- "application/vnd.vsf": ["vsf"],
1107
- "application/vnd.wap.wbxml": ["wbxml"],
1108
- "application/vnd.wap.wmlc": ["wmlc"],
1109
- "application/vnd.wap.wmlscriptc": ["wmlsc"],
1110
- "application/vnd.webturbo": ["wtb"],
1111
- "application/vnd.wolfram.player": ["nbp"],
1112
- "application/vnd.wordperfect": ["wpd"],
1113
- "application/vnd.wqd": ["wqd"],
1114
- "application/vnd.wt.stf": ["stf"],
1115
- "application/vnd.xara": ["xar"],
1116
- "application/vnd.xfdl": ["xfdl"],
1117
- "application/vnd.yamaha.hv-dic": ["hvd"],
1118
- "application/vnd.yamaha.hv-script": ["hvs"],
1119
- "application/vnd.yamaha.hv-voice": ["hvp"],
1120
- "application/vnd.yamaha.openscoreformat": ["osf"],
1121
- "application/vnd.yamaha.openscoreformat.osfpvg+xml": ["osfpvg"],
1122
- "application/vnd.yamaha.smaf-audio": ["saf"],
1123
- "application/vnd.yamaha.smaf-phrase": ["spf"],
1124
- "application/vnd.yellowriver-custom-menu": ["cmp"],
1125
- "application/vnd.zul": ["zir", "zirz"],
1126
- "application/vnd.zzazz.deck+xml": ["zaz"],
1127
- "application/x-7z-compressed": ["7z"],
1128
- "application/x-abiword": ["abw"],
1129
- "application/x-ace-compressed": ["ace"],
1130
- "application/x-apple-diskimage": ["*dmg"],
1131
- "application/x-arj": ["arj"],
1132
- "application/x-authorware-bin": [
1133
- "aab",
1134
- "x32",
1135
- "u32",
1136
- "vox"
1137
- ],
1138
- "application/x-authorware-map": ["aam"],
1139
- "application/x-authorware-seg": ["aas"],
1140
- "application/x-bcpio": ["bcpio"],
1141
- "application/x-bdoc": ["*bdoc"],
1142
- "application/x-bittorrent": ["torrent"],
1143
- "application/x-blorb": ["blb", "blorb"],
1144
- "application/x-bzip": ["bz"],
1145
- "application/x-bzip2": ["bz2", "boz"],
1146
- "application/x-cbr": [
1147
- "cbr",
1148
- "cba",
1149
- "cbt",
1150
- "cbz",
1151
- "cb7"
1152
- ],
1153
- "application/x-cdlink": ["vcd"],
1154
- "application/x-cfs-compressed": ["cfs"],
1155
- "application/x-chat": ["chat"],
1156
- "application/x-chess-pgn": ["pgn"],
1157
- "application/x-chrome-extension": ["crx"],
1158
- "application/x-cocoa": ["cco"],
1159
- "application/x-conference": ["nsc"],
1160
- "application/x-cpio": ["cpio"],
1161
- "application/x-csh": ["csh"],
1162
- "application/x-debian-package": ["*deb", "udeb"],
1163
- "application/x-dgc-compressed": ["dgc"],
1164
- "application/x-director": [
1165
- "dir",
1166
- "dcr",
1167
- "dxr",
1168
- "cst",
1169
- "cct",
1170
- "cxt",
1171
- "w3d",
1172
- "fgd",
1173
- "swa"
1174
- ],
1175
- "application/x-doom": ["wad"],
1176
- "application/x-dtbncx+xml": ["ncx"],
1177
- "application/x-dtbook+xml": ["dtb"],
1178
- "application/x-dtbresource+xml": ["res"],
1179
- "application/x-dvi": ["dvi"],
1180
- "application/x-envoy": ["evy"],
1181
- "application/x-eva": ["eva"],
1182
- "application/x-font-bdf": ["bdf"],
1183
- "application/x-font-ghostscript": ["gsf"],
1184
- "application/x-font-linux-psf": ["psf"],
1185
- "application/x-font-pcf": ["pcf"],
1186
- "application/x-font-snf": ["snf"],
1187
- "application/x-font-type1": [
1188
- "pfa",
1189
- "pfb",
1190
- "pfm",
1191
- "afm"
1192
- ],
1193
- "application/x-freearc": ["arc"],
1194
- "application/x-futuresplash": ["spl"],
1195
- "application/x-gca-compressed": ["gca"],
1196
- "application/x-glulx": ["ulx"],
1197
- "application/x-gnumeric": ["gnumeric"],
1198
- "application/x-gramps-xml": ["gramps"],
1199
- "application/x-gtar": ["gtar"],
1200
- "application/x-hdf": ["hdf"],
1201
- "application/x-httpd-php": ["php"],
1202
- "application/x-install-instructions": ["install"],
1203
- "application/x-iso9660-image": ["*iso"],
1204
- "application/x-iwork-keynote-sffkey": ["*key"],
1205
- "application/x-iwork-numbers-sffnumbers": ["*numbers"],
1206
- "application/x-iwork-pages-sffpages": ["*pages"],
1207
- "application/x-java-archive-diff": ["jardiff"],
1208
- "application/x-java-jnlp-file": ["jnlp"],
1209
- "application/x-keepass2": ["kdbx"],
1210
- "application/x-latex": ["latex"],
1211
- "application/x-lua-bytecode": ["luac"],
1212
- "application/x-lzh-compressed": ["lzh", "lha"],
1213
- "application/x-makeself": ["run"],
1214
- "application/x-mie": ["mie"],
1215
- "application/x-mobipocket-ebook": ["prc", "mobi"],
1216
- "application/x-ms-application": ["application"],
1217
- "application/x-ms-shortcut": ["lnk"],
1218
- "application/x-ms-wmd": ["wmd"],
1219
- "application/x-ms-wmz": ["wmz"],
1220
- "application/x-ms-xbap": ["xbap"],
1221
- "application/x-msaccess": ["mdb"],
1222
- "application/x-msbinder": ["obd"],
1223
- "application/x-mscardfile": ["crd"],
1224
- "application/x-msclip": ["clp"],
1225
- "application/x-msdos-program": ["*exe"],
1226
- "application/x-msdownload": [
1227
- "*exe",
1228
- "*dll",
1229
- "com",
1230
- "bat",
1231
- "*msi"
1232
- ],
1233
- "application/x-msmediaview": [
1234
- "mvb",
1235
- "m13",
1236
- "m14"
1237
- ],
1238
- "application/x-msmetafile": [
1239
- "*wmf",
1240
- "*wmz",
1241
- "*emf",
1242
- "emz"
1243
- ],
1244
- "application/x-msmoney": ["mny"],
1245
- "application/x-mspublisher": ["pub"],
1246
- "application/x-msschedule": ["scd"],
1247
- "application/x-msterminal": ["trm"],
1248
- "application/x-mswrite": ["wri"],
1249
- "application/x-netcdf": ["nc", "cdf"],
1250
- "application/x-ns-proxy-autoconfig": ["pac"],
1251
- "application/x-nzb": ["nzb"],
1252
- "application/x-perl": ["pl", "pm"],
1253
- "application/x-pilot": ["*prc", "*pdb"],
1254
- "application/x-pkcs12": ["p12", "pfx"],
1255
- "application/x-pkcs7-certificates": ["p7b", "spc"],
1256
- "application/x-pkcs7-certreqresp": ["p7r"],
1257
- "application/x-rar-compressed": ["*rar"],
1258
- "application/x-redhat-package-manager": ["rpm"],
1259
- "application/x-research-info-systems": ["ris"],
1260
- "application/x-sea": ["sea"],
1261
- "application/x-sh": ["sh"],
1262
- "application/x-shar": ["shar"],
1263
- "application/x-shockwave-flash": ["swf"],
1264
- "application/x-silverlight-app": ["xap"],
1265
- "application/x-sql": ["sql"],
1266
- "application/x-stuffit": ["sit"],
1267
- "application/x-stuffitx": ["sitx"],
1268
- "application/x-subrip": ["srt"],
1269
- "application/x-sv4cpio": ["sv4cpio"],
1270
- "application/x-sv4crc": ["sv4crc"],
1271
- "application/x-t3vm-image": ["t3"],
1272
- "application/x-tads": ["gam"],
1273
- "application/x-tar": ["tar"],
1274
- "application/x-tcl": ["tcl", "tk"],
1275
- "application/x-tex": ["tex"],
1276
- "application/x-tex-tfm": ["tfm"],
1277
- "application/x-texinfo": ["texinfo", "texi"],
1278
- "application/x-tgif": ["*obj"],
1279
- "application/x-ustar": ["ustar"],
1280
- "application/x-virtualbox-hdd": ["hdd"],
1281
- "application/x-virtualbox-ova": ["ova"],
1282
- "application/x-virtualbox-ovf": ["ovf"],
1283
- "application/x-virtualbox-vbox": ["vbox"],
1284
- "application/x-virtualbox-vbox-extpack": ["vbox-extpack"],
1285
- "application/x-virtualbox-vdi": ["vdi"],
1286
- "application/x-virtualbox-vhd": ["vhd"],
1287
- "application/x-virtualbox-vmdk": ["vmdk"],
1288
- "application/x-wais-source": ["src"],
1289
- "application/x-web-app-manifest+json": ["webapp"],
1290
- "application/x-x509-ca-cert": [
1291
- "der",
1292
- "crt",
1293
- "pem"
1294
- ],
1295
- "application/x-xfig": ["fig"],
1296
- "application/x-xliff+xml": ["*xlf"],
1297
- "application/x-xpinstall": ["xpi"],
1298
- "application/x-xz": ["xz"],
1299
- "application/x-zmachine": [
1300
- "z1",
1301
- "z2",
1302
- "z3",
1303
- "z4",
1304
- "z5",
1305
- "z6",
1306
- "z7",
1307
- "z8"
1308
- ],
1309
- "audio/vnd.dece.audio": ["uva", "uvva"],
1310
- "audio/vnd.digital-winds": ["eol"],
1311
- "audio/vnd.dra": ["dra"],
1312
- "audio/vnd.dts": ["dts"],
1313
- "audio/vnd.dts.hd": ["dtshd"],
1314
- "audio/vnd.lucent.voice": ["lvp"],
1315
- "audio/vnd.ms-playready.media.pya": ["pya"],
1316
- "audio/vnd.nuera.ecelp4800": ["ecelp4800"],
1317
- "audio/vnd.nuera.ecelp7470": ["ecelp7470"],
1318
- "audio/vnd.nuera.ecelp9600": ["ecelp9600"],
1319
- "audio/vnd.rip": ["rip"],
1320
- "audio/x-aac": ["aac"],
1321
- "audio/x-aiff": [
1322
- "aif",
1323
- "aiff",
1324
- "aifc"
1325
- ],
1326
- "audio/x-caf": ["caf"],
1327
- "audio/x-flac": ["flac"],
1328
- "audio/x-m4a": ["*m4a"],
1329
- "audio/x-matroska": ["mka"],
1330
- "audio/x-mpegurl": ["m3u"],
1331
- "audio/x-ms-wax": ["wax"],
1332
- "audio/x-ms-wma": ["wma"],
1333
- "audio/x-pn-realaudio": ["ram", "ra"],
1334
- "audio/x-pn-realaudio-plugin": ["rmp"],
1335
- "audio/x-realaudio": ["*ra"],
1336
- "audio/x-wav": ["*wav"],
1337
- "chemical/x-cdx": ["cdx"],
1338
- "chemical/x-cif": ["cif"],
1339
- "chemical/x-cmdf": ["cmdf"],
1340
- "chemical/x-cml": ["cml"],
1341
- "chemical/x-csml": ["csml"],
1342
- "chemical/x-xyz": ["xyz"],
1343
- "image/prs.btif": ["btif"],
1344
- "image/prs.pti": ["pti"],
1345
- "image/vnd.adobe.photoshop": ["psd"],
1346
- "image/vnd.airzip.accelerator.azv": ["azv"],
1347
- "image/vnd.dece.graphic": [
1348
- "uvi",
1349
- "uvvi",
1350
- "uvg",
1351
- "uvvg"
1352
- ],
1353
- "image/vnd.djvu": ["djvu", "djv"],
1354
- "image/vnd.dvb.subtitle": ["*sub"],
1355
- "image/vnd.dwg": ["dwg"],
1356
- "image/vnd.dxf": ["dxf"],
1357
- "image/vnd.fastbidsheet": ["fbs"],
1358
- "image/vnd.fpx": ["fpx"],
1359
- "image/vnd.fst": ["fst"],
1360
- "image/vnd.fujixerox.edmics-mmr": ["mmr"],
1361
- "image/vnd.fujixerox.edmics-rlc": ["rlc"],
1362
- "image/vnd.microsoft.icon": ["ico"],
1363
- "image/vnd.ms-dds": ["dds"],
1364
- "image/vnd.ms-modi": ["mdi"],
1365
- "image/vnd.ms-photo": ["wdp"],
1366
- "image/vnd.net-fpx": ["npx"],
1367
- "image/vnd.pco.b16": ["b16"],
1368
- "image/vnd.tencent.tap": ["tap"],
1369
- "image/vnd.valve.source.texture": ["vtf"],
1370
- "image/vnd.wap.wbmp": ["wbmp"],
1371
- "image/vnd.xiff": ["xif"],
1372
- "image/vnd.zbrush.pcx": ["pcx"],
1373
- "image/x-3ds": ["3ds"],
1374
- "image/x-cmu-raster": ["ras"],
1375
- "image/x-cmx": ["cmx"],
1376
- "image/x-freehand": [
1377
- "fh",
1378
- "fhc",
1379
- "fh4",
1380
- "fh5",
1381
- "fh7"
1382
- ],
1383
- "image/x-icon": ["*ico"],
1384
- "image/x-jng": ["jng"],
1385
- "image/x-mrsid-image": ["sid"],
1386
- "image/x-ms-bmp": ["*bmp"],
1387
- "image/x-pcx": ["*pcx"],
1388
- "image/x-pict": ["pic", "pct"],
1389
- "image/x-portable-anymap": ["pnm"],
1390
- "image/x-portable-bitmap": ["pbm"],
1391
- "image/x-portable-graymap": ["pgm"],
1392
- "image/x-portable-pixmap": ["ppm"],
1393
- "image/x-rgb": ["rgb"],
1394
- "image/x-tga": ["tga"],
1395
- "image/x-xbitmap": ["xbm"],
1396
- "image/x-xpixmap": ["xpm"],
1397
- "image/x-xwindowdump": ["xwd"],
1398
- "message/vnd.wfa.wsc": ["wsc"],
1399
- "model/vnd.collada+xml": ["dae"],
1400
- "model/vnd.dwf": ["dwf"],
1401
- "model/vnd.gdl": ["gdl"],
1402
- "model/vnd.gtw": ["gtw"],
1403
- "model/vnd.mts": ["mts"],
1404
- "model/vnd.opengex": ["ogex"],
1405
- "model/vnd.parasolid.transmit.binary": ["x_b"],
1406
- "model/vnd.parasolid.transmit.text": ["x_t"],
1407
- "model/vnd.sap.vds": ["vds"],
1408
- "model/vnd.usdz+zip": ["usdz"],
1409
- "model/vnd.valve.source.compiled-map": ["bsp"],
1410
- "model/vnd.vtu": ["vtu"],
1411
- "text/prs.lines.tag": ["dsc"],
1412
- "text/vnd.curl": ["curl"],
1413
- "text/vnd.curl.dcurl": ["dcurl"],
1414
- "text/vnd.curl.mcurl": ["mcurl"],
1415
- "text/vnd.curl.scurl": ["scurl"],
1416
- "text/vnd.dvb.subtitle": ["sub"],
1417
- "text/vnd.fly": ["fly"],
1418
- "text/vnd.fmi.flexstor": ["flx"],
1419
- "text/vnd.graphviz": ["gv"],
1420
- "text/vnd.in3d.3dml": ["3dml"],
1421
- "text/vnd.in3d.spot": ["spot"],
1422
- "text/vnd.sun.j2me.app-descriptor": ["jad"],
1423
- "text/vnd.wap.wml": ["wml"],
1424
- "text/vnd.wap.wmlscript": ["wmls"],
1425
- "text/x-asm": ["s", "asm"],
1426
- "text/x-c": [
1427
- "c",
1428
- "cc",
1429
- "cxx",
1430
- "cpp",
1431
- "h",
1432
- "hh",
1433
- "dic"
1434
- ],
1435
- "text/x-component": ["htc"],
1436
- "text/x-fortran": [
1437
- "f",
1438
- "for",
1439
- "f77",
1440
- "f90"
1441
- ],
1442
- "text/x-handlebars-template": ["hbs"],
1443
- "text/x-java-source": ["java"],
1444
- "text/x-lua": ["lua"],
1445
- "text/x-markdown": ["mkd"],
1446
- "text/x-nfo": ["nfo"],
1447
- "text/x-opml": ["opml"],
1448
- "text/x-org": ["*org"],
1449
- "text/x-pascal": ["p", "pas"],
1450
- "text/x-processing": ["pde"],
1451
- "text/x-sass": ["sass"],
1452
- "text/x-scss": ["scss"],
1453
- "text/x-setext": ["etx"],
1454
- "text/x-sfv": ["sfv"],
1455
- "text/x-suse-ymp": ["ymp"],
1456
- "text/x-uuencode": ["uu"],
1457
- "text/x-vcalendar": ["vcs"],
1458
- "text/x-vcard": ["vcf"],
1459
- "video/vnd.dece.hd": ["uvh", "uvvh"],
1460
- "video/vnd.dece.mobile": ["uvm", "uvvm"],
1461
- "video/vnd.dece.pd": ["uvp", "uvvp"],
1462
- "video/vnd.dece.sd": ["uvs", "uvvs"],
1463
- "video/vnd.dece.video": ["uvv", "uvvv"],
1464
- "video/vnd.dvb.file": ["dvb"],
1465
- "video/vnd.fvt": ["fvt"],
1466
- "video/vnd.mpegurl": ["mxu", "m4u"],
1467
- "video/vnd.ms-playready.media.pyv": ["pyv"],
1468
- "video/vnd.uvvu.mp4": ["uvu", "uvvu"],
1469
- "video/vnd.vivo": ["viv"],
1470
- "video/x-f4v": ["f4v"],
1471
- "video/x-fli": ["fli"],
1472
- "video/x-flv": ["flv"],
1473
- "video/x-m4v": ["m4v"],
1474
- "video/x-matroska": [
1475
- "mkv",
1476
- "mk3d",
1477
- "mks"
1478
- ],
1479
- "video/x-mng": ["mng"],
1480
- "video/x-ms-asf": ["asf", "asx"],
1481
- "video/x-ms-vob": ["vob"],
1482
- "video/x-ms-wm": ["wm"],
1483
- "video/x-ms-wmv": ["wmv"],
1484
- "video/x-ms-wmx": ["wmx"],
1485
- "video/x-ms-wvx": ["wvx"],
1486
- "video/x-msvideo": ["avi"],
1487
- "video/x-sgi-movie": ["movie"],
1488
- "video/x-smv": ["smv"],
1489
- "x-conference/x-cooltalk": ["ice"]
492
+ //#region src/standaloneReleaseRemote.ts
493
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
494
+ const data = (value, message) => {
495
+ if (!isRecord(value) || !("data" in value)) throw new StandaloneDatabaseError("invalid-response", message);
496
+ return value.data;
497
+ };
498
+ const createStandaloneReleaseRemote = (config) => {
499
+ const http = createStandaloneHttp(config);
500
+ const headers = () => http.headers({ "Cache-Control": "no-cache" });
501
+ return {
502
+ async findReleaseById(id) {
503
+ const response = await fetch(http.buildUrl(`/releases/${encodeURIComponent(id)}`), { headers: headers() });
504
+ if (response.status === 404) return null;
505
+ return data(await http.parseJson(response), "Invalid Release response.");
506
+ },
507
+ async findReleasesByScope(input) {
508
+ const url = new URL(http.buildUrl("/releases"));
509
+ url.searchParams.set("scopeKey", input.scopeKey);
510
+ url.searchParams.set("limit", String(input.limit));
511
+ if (input.afterReleaseId !== void 0) url.searchParams.set("afterReleaseId", input.afterReleaseId);
512
+ const response = await fetch(url, { headers: headers() });
513
+ const rows = data(await http.parseJson(response), "Invalid Release list response.");
514
+ if (!Array.isArray(rows)) throw new StandaloneDatabaseError("invalid-response", "Invalid Release list response.", response.status);
515
+ return rows;
516
+ },
517
+ async findReleases(input) {
518
+ const url = new URL(http.buildUrl("/releases"));
519
+ url.searchParams.set("limit", String(input.limit));
520
+ for (const [key, value] of Object.entries(input)) if (key !== "limit" && value !== void 0) url.searchParams.set(key, String(value));
521
+ const response = await fetch(url, { headers: headers() });
522
+ const rows = data(await http.parseJson(response), "Invalid Release list response.");
523
+ if (!Array.isArray(rows)) throw new StandaloneDatabaseError("invalid-response", "Invalid Release list response.", response.status);
524
+ return rows;
525
+ },
526
+ async findCatalogByScopeKey(scopeKey) {
527
+ const response = await fetch(http.buildUrl(`/release-catalogs/${encodeURIComponent(scopeKey)}`), { headers: headers() });
528
+ if (response.status === 404) return null;
529
+ return data(await http.parseJson(response), "Invalid Release catalog response.");
530
+ },
531
+ async findCatalogs(input) {
532
+ const url = new URL(http.buildUrl("/release-catalogs"));
533
+ url.searchParams.set("limit", String(input.limit));
534
+ if (input.afterScopeKey !== void 0) url.searchParams.set("afterScopeKey", input.afterScopeKey);
535
+ const response = await fetch(url, { headers: headers() });
536
+ const rows = data(await http.parseJson(response), "Invalid Release catalog list response.");
537
+ if (!Array.isArray(rows)) throw new StandaloneDatabaseError("invalid-response", "Invalid Release catalog list response.", response.status);
538
+ return rows;
539
+ },
540
+ async commit(input) {
541
+ const response = await fetch(http.buildUrl("/database/commit"), {
542
+ body: JSON.stringify(input),
543
+ headers: http.headers(),
544
+ method: "POST"
545
+ });
546
+ return data(await http.parseJson(response), "Invalid database commit response.");
547
+ }
1490
548
  };
1491
- }));
549
+ };
550
+ //#endregion
551
+ //#region src/standaloneRepository.ts
552
+ const toBundleWhere = (where) => {
553
+ if (!where) return [];
554
+ const filters = [];
555
+ if (where.platform !== void 0) filters.push({
556
+ field: "platform",
557
+ value: where.platform
558
+ });
559
+ if (where.id?.eq !== void 0) filters.push({
560
+ field: "id",
561
+ value: where.id.eq
562
+ });
563
+ if (where.id?.gt !== void 0) filters.push({
564
+ field: "id",
565
+ operator: "gt",
566
+ value: where.id.gt
567
+ });
568
+ if (where.id?.gte !== void 0) filters.push({
569
+ field: "id",
570
+ operator: "gte",
571
+ value: where.id.gte
572
+ });
573
+ if (where.id?.lt !== void 0) filters.push({
574
+ field: "id",
575
+ operator: "lt",
576
+ value: where.id.lt
577
+ });
578
+ if (where.id?.lte !== void 0) filters.push({
579
+ field: "id",
580
+ operator: "lte",
581
+ value: where.id.lte
582
+ });
583
+ if (where.id?.in !== void 0) filters.push({
584
+ field: "id",
585
+ operator: "in",
586
+ value: where.id.in
587
+ });
588
+ return filters;
589
+ };
590
+ /**
591
+ * Bundle-only HTTP repository used by the CLI for a self-hosted server.
592
+ *
593
+ * This is intentionally not a database plugin: analytics and access-key
594
+ * persistence belong to the server's database provider.
595
+ */
596
+ const standaloneRepository = (config) => {
597
+ const remote = createStandaloneBundleRemote(config);
598
+ const releaseRemote = createStandaloneReleaseRemote(config);
599
+ const bundleReader = createStandaloneBundleReader(remote);
600
+ return Object.freeze({
601
+ name: "standalone-repository",
602
+ models: {
603
+ bundles: {
604
+ async findById(id) {
605
+ return await bundleReader.findOne({
606
+ model: "bundles",
607
+ where: [{
608
+ field: "id",
609
+ value: id
610
+ }]
611
+ });
612
+ },
613
+ async findMany(query) {
614
+ return await bundleReader.findMany({
615
+ model: "bundles",
616
+ where: toBundleWhere(query.where),
617
+ limit: query.limit,
618
+ offset: query.offset,
619
+ orderBy: [query.orderBy]
620
+ });
621
+ },
622
+ count: (where) => bundleReader.count({
623
+ model: "bundles",
624
+ where: toBundleWhere(where)
625
+ })
626
+ },
627
+ bundlePatches: { async findByBundleIds(bundleIds) {
628
+ if (bundleIds.length === 0) return [];
629
+ return await bundleReader.findMany({
630
+ model: "bundle_patches",
631
+ where: [{
632
+ field: "bundle_id",
633
+ operator: "in",
634
+ value: bundleIds
635
+ }],
636
+ orderBy: [{
637
+ field: "id",
638
+ direction: "asc"
639
+ }],
640
+ limit: Number.MAX_SAFE_INTEGER,
641
+ offset: 0
642
+ });
643
+ } },
644
+ releases: {
645
+ findById: (id) => releaseRemote.findReleaseById(id),
646
+ findMany: (input) => releaseRemote.findReleases(input),
647
+ findManyByScope: (input) => releaseRemote.findReleasesByScope(input)
648
+ },
649
+ releaseCatalogs: {
650
+ findByScopeKey: (scopeKey) => releaseRemote.findCatalogByScopeKey(scopeKey),
651
+ findMany: (input) => releaseRemote.findCatalogs(input)
652
+ },
653
+ channels: {
654
+ insert: (input) => remote.insertChannel(input),
655
+ delete: (input) => remote.deleteChannel(input),
656
+ async list() {
657
+ return { channels: await remote.loadChannels() };
658
+ }
659
+ }
660
+ },
661
+ commit: (input) => releaseRemote.commit(input)
662
+ });
663
+ };
1492
664
  //#endregion
1493
665
  //#region src/standaloneStorage.ts
1494
- var import_mime = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
1495
- module.exports = new (require_Mime())(require_standard(), require_other());
1496
- })))(), 1);
1497
666
  const defaultRoutes = {
1498
- upload: (_key, _filePath) => ({ path: "/upload" }),
1499
- delete: (_storageUri) => ({ path: "/delete" }),
1500
- readText: (_storageUri) => ({ path: "/readText" }),
1501
- getDownloadUrl: (_storageUri) => ({ path: "/getDownloadUrl" })
667
+ put: () => ({ path: "/upload" }),
668
+ get: () => ({ path: "/get" }),
669
+ exists: () => ({ path: "/exists" }),
670
+ delete: () => ({ path: "/delete" })
1502
671
  };
1503
672
  const createRoute = (defaultRoute, customRoute) => ({
1504
673
  path: customRoute?.path ?? defaultRoute.path,
@@ -1507,104 +676,71 @@ const createRoute = (defaultRoute, customRoute) => ({
1507
676
  ...customRoute?.headers
1508
677
  }
1509
678
  });
1510
- const standaloneStorage = (config, hooks) => () => {
1511
- const routes = {
1512
- upload: (key, filePath) => createRoute(defaultRoutes.upload(key, filePath), config.routes?.upload?.(key, filePath)),
1513
- delete: (storageUri) => createRoute(defaultRoutes.delete(storageUri), config.routes?.delete?.(storageUri)),
1514
- readText: (storageUri) => createRoute(defaultRoutes.readText(storageUri), config.routes?.readText?.(storageUri)),
1515
- getDownloadUrl: (storageUri) => createRoute(defaultRoutes.getDownloadUrl(storageUri), config.routes?.getDownloadUrl?.(storageUri))
1516
- };
679
+ const standaloneStorage = (config) => {
1517
680
  const getHeaders = (routeHeaders) => ({
1518
681
  ...config.commonHeaders,
1519
682
  ...routeHeaders
1520
683
  });
1521
- return {
1522
- name: "standaloneStorage",
1523
- supportedProtocol: "http",
1524
- profiles: {
1525
- node: {
1526
- async delete(storageUri) {
1527
- const { path: routePath, headers: routeHeaders } = routes.delete(storageUri);
1528
- const response = await fetch(`${config.baseUrl}${routePath}`, {
1529
- method: "DELETE",
1530
- headers: getHeaders(routeHeaders),
1531
- body: JSON.stringify({ storageUri })
1532
- });
1533
- if (!response.ok) {
1534
- const error = /* @__PURE__ */ new Error(`Failed to delete bundle: ${response.statusText}`);
1535
- console.error(error);
1536
- throw error;
1537
- }
1538
- },
1539
- async upload(key, filePath) {
1540
- const fileContent = await fs_promises.default.readFile(filePath);
1541
- const contentType = import_mime.default.getType(filePath) ?? "application/octet-stream";
1542
- const filename = path.default.basename(filePath);
1543
- const { path: routePath, headers: routeHeaders } = routes.upload(key, filePath);
1544
- const formData = new FormData();
1545
- formData.append("file", new Blob([fileContent], { type: contentType }), filename);
1546
- formData.append("key", key);
1547
- const response = await fetch(`${config.baseUrl}${routePath}`, {
1548
- method: "POST",
1549
- headers: getHeaders(routeHeaders),
1550
- body: formData
1551
- });
1552
- if (!response.ok) {
1553
- const error = `Failed to upload bundle: ${response.statusText}`;
1554
- console.error(`[upload] ${error}`);
1555
- throw new Error(error);
1556
- }
1557
- const result = await response.json();
1558
- if (!result.storageUri) {
1559
- const error = "Failed to upload bundle - no storageUri in response";
1560
- console.error(`[upload] ${error}`);
1561
- throw new Error(error);
1562
- }
1563
- await hooks?.onStorageUploaded?.();
1564
- return { storageUri: result.storageUri };
1565
- },
1566
- async exists(storageUri) {
1567
- const { fileUrl } = await getDownloadUrl(storageUri);
1568
- return (await fetch(fileUrl, { method: "HEAD" })).ok;
1569
- },
1570
- async downloadFile(storageUri, filePath) {
1571
- const { fileUrl } = await getDownloadUrl(storageUri);
1572
- const response = await fetch(fileUrl);
1573
- if (!response.ok) throw new Error(`Failed to download bundle: ${response.statusText}`);
1574
- await fs_promises.default.mkdir(path.default.dirname(filePath), { recursive: true });
1575
- await fs_promises.default.writeFile(filePath, new Uint8Array(await response.arrayBuffer()));
1576
- }
1577
- },
1578
- runtime: {
1579
- async readText(storageUri) {
1580
- const { path: routePath, headers: routeHeaders } = routes.readText(storageUri);
1581
- const response = await fetch(`${config.baseUrl}${routePath}`, {
1582
- method: "POST",
1583
- headers: getHeaders(routeHeaders),
1584
- body: JSON.stringify({ storageUri })
1585
- });
1586
- if (!response.ok) return null;
1587
- return response.text();
1588
- },
1589
- getDownloadUrl
1590
- }
1591
- }
684
+ const resolveRoute = (name, args) => {
685
+ const fallback = defaultRoutes[name];
686
+ const custom = config.routes?.[name];
687
+ return createRoute(fallback(...args), custom?.(...args));
1592
688
  };
1593
- async function getDownloadUrl(storageUri) {
1594
- const { path: routePath, headers: routeHeaders } = routes.getDownloadUrl(storageUri);
1595
- const response = await fetch(`${config.baseUrl}${routePath}`, {
1596
- method: "POST",
1597
- headers: getHeaders(routeHeaders),
689
+ const requestStorageUri = async (routeName, storageUri) => {
690
+ (0, _hot_updater_plugin_core.parseStorageUri)(storageUri, config.protocol);
691
+ const { path, headers } = resolveRoute(routeName, [{ storageUri }]);
692
+ const response = await fetch(`${config.baseUrl}${path}`, {
693
+ method: routeName === "delete" ? "DELETE" : "POST",
694
+ headers: {
695
+ "content-type": "application/json",
696
+ ...getHeaders(headers)
697
+ },
1598
698
  body: JSON.stringify({ storageUri })
1599
699
  });
1600
- if (!response.ok) {
1601
- const error = /* @__PURE__ */ new Error(`Failed to get download URL: ${response.statusText}`);
1602
- console.error(error);
1603
- throw error;
700
+ if (!response.ok && response.status !== 404) throw new Error(`Failed to ${routeName} storage object: ${response.statusText}`);
701
+ return response;
702
+ };
703
+ return (0, _hot_updater_plugin_core.createStoragePlugin)({
704
+ name: "standaloneStorage",
705
+ protocol: config.protocol,
706
+ async put({ key, body, contentType, contentLength }) {
707
+ const { path, headers } = resolveRoute("put", [{
708
+ key,
709
+ contentLength,
710
+ contentType
711
+ }]);
712
+ const bytes = await new Response(body).arrayBuffer();
713
+ if (contentLength !== void 0 && bytes.byteLength !== contentLength) throw new Error(`Storage upload length mismatch: expected ${contentLength}, got ${bytes.byteLength}`);
714
+ const formData = new FormData();
715
+ formData.append("file", new Blob([bytes], { type: contentType }), key.split("/").at(-1) ?? "object");
716
+ formData.append("key", key);
717
+ const response = await fetch(`${config.baseUrl}${path}`, {
718
+ method: "POST",
719
+ headers: getHeaders(headers),
720
+ body: formData
721
+ });
722
+ if (!response.ok) throw new Error(`Failed to upload bundle: ${response.statusText}`);
723
+ const result = await response.json();
724
+ if (!result.storageUri) throw new Error("Storage server returned an empty storage URI");
725
+ (0, _hot_updater_plugin_core.parseStorageUri)(result.storageUri, config.protocol);
726
+ return { storageUri: result.storageUri };
727
+ },
728
+ async get({ storageUri }) {
729
+ const response = await requestStorageUri("get", storageUri);
730
+ return { response: response.status === 404 ? null : response };
731
+ },
732
+ async exists({ storageUri }) {
733
+ const response = await requestStorageUri("exists", storageUri);
734
+ if (response.status === 404) return { exists: false };
735
+ return { exists: (await response.json()).exists };
736
+ },
737
+ async delete({ storageUri }) {
738
+ await requestStorageUri("delete", storageUri);
739
+ return { deleted: true };
1604
740
  }
1605
- return { fileUrl: (await response.json()).fileUrl };
1606
- }
741
+ });
1607
742
  };
1608
743
  //#endregion
744
+ exports.StandaloneDatabaseError = StandaloneDatabaseError;
1609
745
  exports.standaloneRepository = standaloneRepository;
1610
746
  exports.standaloneStorage = standaloneStorage;