@hot-updater/standalone 0.36.7 → 1.0.0-rc.1

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