@hot-updater/server 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{runtime.cjs → createHotUpdaterCore.cjs} +29 -14
- package/dist/createHotUpdaterCore.d.cts +25 -0
- package/dist/createHotUpdaterCore.d.mts +25 -0
- package/dist/{runtime.mjs → createHotUpdaterCore.mjs} +29 -12
- package/dist/db/createBundleDiff.cjs +1 -1
- package/dist/db/createBundleDiff.mjs +1 -1
- package/dist/db/index.cjs +23 -43
- package/dist/db/index.d.cts +6 -25
- package/dist/db/index.d.mts +6 -25
- package/dist/db/index.mjs +18 -42
- package/dist/db/schemaGenerators.cjs +1 -1
- package/dist/db/schemaGenerators.mjs +1 -1
- package/dist/index.cjs +2 -6
- package/dist/index.d.cts +3 -6
- package/dist/index.d.mts +3 -6
- package/dist/index.mjs +2 -4
- package/dist/node.cjs +2 -0
- package/dist/node.d.cts +7 -3
- package/dist/node.d.mts +7 -3
- package/dist/node.mjs +2 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/package.json +11 -11
- package/src/adapters/drizzle.spec.ts +3 -2
- package/src/adapters/kysely.spec.ts +1 -1
- package/src/{runtime.ts → createHotUpdaterCore.ts} +73 -23
- package/src/db/index.spec.ts +15 -14
- package/src/db/index.ts +34 -106
- package/src/handler-standalone.integration.spec.ts +3 -2
- package/src/index.ts +9 -3
- package/src/node.spec.ts +50 -0
- package/src/node.ts +7 -3
- package/src/runtime.spec.ts +62 -1
- package/src/types/index.ts +1 -1
- package/dist/runtime.d.cts +0 -22
- package/dist/runtime.d.mts +0 -22
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
1
|
require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
const require_version = require("./version.cjs");
|
|
4
2
|
const require_handler = require("./handler.cjs");
|
|
5
|
-
const require_route = require("./route.cjs");
|
|
6
|
-
const require_storageAccess = require("./storageAccess.cjs");
|
|
7
3
|
const require_pluginCore = require("./db/pluginCore.cjs");
|
|
8
|
-
const require_types = require("./db/types.cjs");
|
|
9
4
|
const require_schemaReadiness = require("./db/schemaReadiness.cjs");
|
|
5
|
+
const require_types = require("./db/types.cjs");
|
|
6
|
+
const require_route = require("./route.cjs");
|
|
7
|
+
const require_storageAccess = require("./storageAccess.cjs");
|
|
10
8
|
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
11
|
-
//#region src/
|
|
12
|
-
|
|
9
|
+
//#region src/createHotUpdaterCore.ts
|
|
10
|
+
const hotUpdaterCoreMetadata = Symbol.for("@hot-updater/server/core-metadata");
|
|
11
|
+
function getHotUpdaterCoreMetadata(hotUpdater) {
|
|
12
|
+
return hotUpdater[hotUpdaterCoreMetadata];
|
|
13
|
+
}
|
|
14
|
+
function createHotUpdaterCore(options) {
|
|
13
15
|
const database = options.database;
|
|
14
16
|
const basePath = require_route.normalizeBasePath(options.basePath ?? "/api");
|
|
15
17
|
const { readStorageText, resolveFileUrl } = require_storageAccess.createStorageAccess((options.storages ?? options.storagePlugins ?? []).map((plugin) => {
|
|
@@ -17,10 +19,10 @@ function createHotUpdater(options) {
|
|
|
17
19
|
(0, _hot_updater_plugin_core.assertRuntimeStoragePlugin)(storagePlugin);
|
|
18
20
|
return storagePlugin;
|
|
19
21
|
}));
|
|
20
|
-
if (!require_types.isDatabasePluginFactory(database) && !require_types.isDatabasePlugin(database)) throw new Error("@hot-updater/server
|
|
21
|
-
const
|
|
22
|
+
if (!require_types.isDatabasePluginFactory(database) && !require_types.isDatabasePlugin(database)) throw new Error("@hot-updater/server only supports database plugins.");
|
|
23
|
+
const adapterCapabilities = database;
|
|
22
24
|
const plugin = require_types.isDatabasePluginFactory(database) ? database() : database;
|
|
23
|
-
const assertSchemaReady = require_schemaReadiness.createSchemaReadinessChecker(
|
|
25
|
+
const assertSchemaReady = require_schemaReadiness.createSchemaReadinessChecker(adapterCapabilities.adapterName ?? plugin.name, adapterCapabilities.createMigrator);
|
|
24
26
|
const core = require_pluginCore.createPluginDatabaseCore(() => plugin, resolveFileUrl, require_types.isDatabasePluginFactory(database) ? {
|
|
25
27
|
createMutationPlugin: () => database(),
|
|
26
28
|
beforeOperation: assertSchemaReady,
|
|
@@ -39,13 +41,26 @@ function createHotUpdater(options) {
|
|
|
39
41
|
};
|
|
40
42
|
const api = {
|
|
41
43
|
basePath,
|
|
42
|
-
adapterName: core.adapterName,
|
|
44
|
+
adapterName: adapterCapabilities.adapterName ?? core.adapterName,
|
|
43
45
|
handler
|
|
44
46
|
};
|
|
45
47
|
Object.defineProperties(api, Object.getOwnPropertyDescriptors(core.api));
|
|
46
|
-
|
|
48
|
+
Object.defineProperty(api, hotUpdaterCoreMetadata, {
|
|
49
|
+
enumerable: false,
|
|
50
|
+
value: {
|
|
51
|
+
adapterCapabilities,
|
|
52
|
+
core
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
api,
|
|
57
|
+
adapterCapabilities,
|
|
58
|
+
core
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function createHotUpdater(options) {
|
|
62
|
+
return createHotUpdaterCore(options).api;
|
|
47
63
|
}
|
|
48
64
|
//#endregion
|
|
49
|
-
exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
|
|
50
|
-
exports.createHandler = require_handler.createHandler;
|
|
51
65
|
exports.createHotUpdater = createHotUpdater;
|
|
66
|
+
exports.getHotUpdaterCoreMetadata = getHotUpdaterCoreMetadata;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HandlerRoutes } from "./handler.cjs";
|
|
2
|
+
import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./db/types.cjs";
|
|
3
|
+
import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
4
|
+
|
|
5
|
+
//#region src/createHotUpdaterCore.d.ts
|
|
6
|
+
type RuntimeHotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
|
|
7
|
+
readonly basePath: string;
|
|
8
|
+
readonly handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
|
|
9
|
+
readonly adapterName: string;
|
|
10
|
+
};
|
|
11
|
+
type HotUpdaterAPI<TContext = unknown> = RuntimeHotUpdaterAPI<TContext>;
|
|
12
|
+
interface CreateHotUpdaterOptions<TContext = unknown> {
|
|
13
|
+
readonly database: DatabaseAdapter<TContext>;
|
|
14
|
+
readonly storages?: readonly (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use `storages` instead. This field will be removed in a future version.
|
|
17
|
+
*/
|
|
18
|
+
readonly storagePlugins?: readonly (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
19
|
+
readonly basePath?: string;
|
|
20
|
+
readonly cwd?: string;
|
|
21
|
+
readonly routes?: HandlerRoutes;
|
|
22
|
+
}
|
|
23
|
+
declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): RuntimeHotUpdaterAPI<TContext>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HandlerRoutes } from "./handler.mjs";
|
|
2
|
+
import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./db/types.mjs";
|
|
3
|
+
import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
4
|
+
|
|
5
|
+
//#region src/createHotUpdaterCore.d.ts
|
|
6
|
+
type RuntimeHotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
|
|
7
|
+
readonly basePath: string;
|
|
8
|
+
readonly handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
|
|
9
|
+
readonly adapterName: string;
|
|
10
|
+
};
|
|
11
|
+
type HotUpdaterAPI<TContext = unknown> = RuntimeHotUpdaterAPI<TContext>;
|
|
12
|
+
interface CreateHotUpdaterOptions<TContext = unknown> {
|
|
13
|
+
readonly database: DatabaseAdapter<TContext>;
|
|
14
|
+
readonly storages?: readonly (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use `storages` instead. This field will be removed in a future version.
|
|
17
|
+
*/
|
|
18
|
+
readonly storagePlugins?: readonly (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
19
|
+
readonly basePath?: string;
|
|
20
|
+
readonly cwd?: string;
|
|
21
|
+
readonly routes?: HandlerRoutes;
|
|
22
|
+
}
|
|
23
|
+
declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): RuntimeHotUpdaterAPI<TContext>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
2
1
|
import { createHandler } from "./handler.mjs";
|
|
3
|
-
import { normalizeBasePath } from "./route.mjs";
|
|
4
|
-
import { createStorageAccess } from "./storageAccess.mjs";
|
|
5
2
|
import { createPluginDatabaseCore } from "./db/pluginCore.mjs";
|
|
6
|
-
import { isDatabasePlugin, isDatabasePluginFactory } from "./db/types.mjs";
|
|
7
3
|
import { createSchemaReadinessChecker } from "./db/schemaReadiness.mjs";
|
|
4
|
+
import { isDatabasePlugin, isDatabasePluginFactory } from "./db/types.mjs";
|
|
5
|
+
import { normalizeBasePath } from "./route.mjs";
|
|
6
|
+
import { createStorageAccess } from "./storageAccess.mjs";
|
|
8
7
|
import { assertRuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
9
|
-
//#region src/
|
|
10
|
-
|
|
8
|
+
//#region src/createHotUpdaterCore.ts
|
|
9
|
+
const hotUpdaterCoreMetadata = Symbol.for("@hot-updater/server/core-metadata");
|
|
10
|
+
function getHotUpdaterCoreMetadata(hotUpdater) {
|
|
11
|
+
return hotUpdater[hotUpdaterCoreMetadata];
|
|
12
|
+
}
|
|
13
|
+
function createHotUpdaterCore(options) {
|
|
11
14
|
const database = options.database;
|
|
12
15
|
const basePath = normalizeBasePath(options.basePath ?? "/api");
|
|
13
16
|
const { readStorageText, resolveFileUrl } = createStorageAccess((options.storages ?? options.storagePlugins ?? []).map((plugin) => {
|
|
@@ -15,10 +18,10 @@ function createHotUpdater(options) {
|
|
|
15
18
|
assertRuntimeStoragePlugin(storagePlugin);
|
|
16
19
|
return storagePlugin;
|
|
17
20
|
}));
|
|
18
|
-
if (!isDatabasePluginFactory(database) && !isDatabasePlugin(database)) throw new Error("@hot-updater/server
|
|
19
|
-
const
|
|
21
|
+
if (!isDatabasePluginFactory(database) && !isDatabasePlugin(database)) throw new Error("@hot-updater/server only supports database plugins.");
|
|
22
|
+
const adapterCapabilities = database;
|
|
20
23
|
const plugin = isDatabasePluginFactory(database) ? database() : database;
|
|
21
|
-
const assertSchemaReady = createSchemaReadinessChecker(
|
|
24
|
+
const assertSchemaReady = createSchemaReadinessChecker(adapterCapabilities.adapterName ?? plugin.name, adapterCapabilities.createMigrator);
|
|
22
25
|
const core = createPluginDatabaseCore(() => plugin, resolveFileUrl, isDatabasePluginFactory(database) ? {
|
|
23
26
|
createMutationPlugin: () => database(),
|
|
24
27
|
beforeOperation: assertSchemaReady,
|
|
@@ -37,11 +40,25 @@ function createHotUpdater(options) {
|
|
|
37
40
|
};
|
|
38
41
|
const api = {
|
|
39
42
|
basePath,
|
|
40
|
-
adapterName: core.adapterName,
|
|
43
|
+
adapterName: adapterCapabilities.adapterName ?? core.adapterName,
|
|
41
44
|
handler
|
|
42
45
|
};
|
|
43
46
|
Object.defineProperties(api, Object.getOwnPropertyDescriptors(core.api));
|
|
44
|
-
|
|
47
|
+
Object.defineProperty(api, hotUpdaterCoreMetadata, {
|
|
48
|
+
enumerable: false,
|
|
49
|
+
value: {
|
|
50
|
+
adapterCapabilities,
|
|
51
|
+
core
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
api,
|
|
56
|
+
adapterCapabilities,
|
|
57
|
+
core
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function createHotUpdater(options) {
|
|
61
|
+
return createHotUpdaterCore(options).api;
|
|
45
62
|
}
|
|
46
63
|
//#endregion
|
|
47
|
-
export {
|
|
64
|
+
export { createHotUpdater, getHotUpdaterCoreMetadata };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
3
|
+
let _hot_updater_core = require("@hot-updater/core");
|
|
3
4
|
let node_crypto = require("node:crypto");
|
|
4
5
|
node_crypto = require_runtime.__toESM(node_crypto);
|
|
5
6
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -11,7 +12,6 @@ node_path = require_runtime.__toESM(node_path);
|
|
|
11
12
|
let node_util = require("node:util");
|
|
12
13
|
let node_zlib = require("node:zlib");
|
|
13
14
|
let _hot_updater_bsdiff = require("@hot-updater/bsdiff");
|
|
14
|
-
let _hot_updater_core = require("@hot-updater/core");
|
|
15
15
|
//#region src/db/createBundleDiff.ts
|
|
16
16
|
const HBC_ASSET_PATH_RE = /\.bundle$/;
|
|
17
17
|
const BR_COMPRESSED_ASSET_PATH_RE = /(^|\/)index\.[^/]+\.bundle$/;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolveManifestAssetStorageUri } from "@hot-updater/plugin-core";
|
|
2
|
+
import { getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getManifestStorageUri } from "@hot-updater/core";
|
|
2
3
|
import crypto, { randomUUID } from "node:crypto";
|
|
3
4
|
import fs from "node:fs/promises";
|
|
4
5
|
import os from "node:os";
|
|
@@ -6,7 +7,6 @@ import path from "node:path";
|
|
|
6
7
|
import { promisify } from "node:util";
|
|
7
8
|
import { brotliDecompress } from "node:zlib";
|
|
8
9
|
import { hdiff } from "@hot-updater/bsdiff";
|
|
9
|
-
import { getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getManifestStorageUri } from "@hot-updater/core";
|
|
10
10
|
//#region src/db/createBundleDiff.ts
|
|
11
11
|
const HBC_ASSET_PATH_RE = /\.bundle$/;
|
|
12
12
|
const BR_COMPRESSED_ASSET_PATH_RE = /(^|\/)index\.[^/]+\.bundle$/;
|
package/dist/db/index.cjs
CHANGED
|
@@ -1,47 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
require("
|
|
3
|
-
require("../version.cjs");
|
|
4
|
-
const require_handler = require("../handler.cjs");
|
|
5
|
-
const require_route = require("../route.cjs");
|
|
6
|
-
const require_storageAccess = require("../storageAccess.cjs");
|
|
7
|
-
const require_pluginCore = require("./pluginCore.cjs");
|
|
8
|
-
const require_types = require("./types.cjs");
|
|
9
|
-
const require_schemaGenerators = require("./schemaGenerators.cjs");
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_version = require("../version.cjs");
|
|
10
3
|
const require_schemaReadiness = require("./schemaReadiness.cjs");
|
|
11
|
-
|
|
4
|
+
const require_createHotUpdaterCore = require("../createHotUpdaterCore.cjs");
|
|
5
|
+
const require_schemaGenerators = require("./schemaGenerators.cjs");
|
|
6
|
+
const require_createBundleDiff = require("./createBundleDiff.cjs");
|
|
12
7
|
//#region src/db/index.ts
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
beforeOperation: assertSchemaReady,
|
|
27
|
-
readStorageText
|
|
28
|
-
} : {
|
|
29
|
-
beforeOperation: assertSchemaReady,
|
|
30
|
-
readStorageText
|
|
31
|
-
});
|
|
32
|
-
const generateSchema = capabilities.generateSchema ?? core.generateSchema;
|
|
33
|
-
const api = {
|
|
34
|
-
basePath,
|
|
35
|
-
adapterName: capabilities.adapterName ?? core.adapterName,
|
|
36
|
-
createMigrator: capabilities.createMigrator ?? core.createMigrator,
|
|
37
|
-
generateSchema: (...args) => require_schemaGenerators.generateSchemaFromHotUpdaterSchema(api.adapterName, capabilities.provider, args[0], generateSchema(...args)),
|
|
38
|
-
handler: require_handler.createHandler(core.api, {
|
|
39
|
-
basePath,
|
|
40
|
-
routes: options.routes
|
|
41
|
-
})
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperties(api, Object.getOwnPropertyDescriptors(core.api));
|
|
44
|
-
return api;
|
|
8
|
+
const getDBMetadata = (hotUpdater) => {
|
|
9
|
+
const metadata = require_createHotUpdaterCore.getHotUpdaterCoreMetadata(hotUpdater);
|
|
10
|
+
if (!metadata) throw new Error("Database tooling requires a hotUpdater instance created by @hot-updater/server.");
|
|
11
|
+
return metadata;
|
|
12
|
+
};
|
|
13
|
+
function createMigrator(hotUpdater) {
|
|
14
|
+
const { adapterCapabilities, core } = getDBMetadata(hotUpdater);
|
|
15
|
+
return (adapterCapabilities.createMigrator ?? core.createMigrator)();
|
|
16
|
+
}
|
|
17
|
+
function generateSchema(hotUpdater, ...args) {
|
|
18
|
+
const { adapterCapabilities, core } = getDBMetadata(hotUpdater);
|
|
19
|
+
const schemaGenerator = adapterCapabilities.generateSchema ?? core.generateSchema;
|
|
20
|
+
return require_schemaGenerators.generateSchemaFromHotUpdaterSchema(hotUpdater.adapterName, adapterCapabilities.provider, args[0], schemaGenerator(...args));
|
|
45
21
|
}
|
|
46
22
|
//#endregion
|
|
47
|
-
exports.
|
|
23
|
+
exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
|
|
24
|
+
exports.HotUpdaterSchemaMigrationRequiredError = require_schemaReadiness.HotUpdaterSchemaMigrationRequiredError;
|
|
25
|
+
exports.createBundleDiff = require_createBundleDiff.createBundleDiff;
|
|
26
|
+
exports.createMigrator = createMigrator;
|
|
27
|
+
exports.generateSchema = generateSchema;
|
package/dist/db/index.d.cts
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
|
+
import { Migrator, SchemaGenerator } from "./types.cjs";
|
|
1
2
|
import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./createBundleDiff.cjs";
|
|
2
|
-
import { HandlerRoutes } from "../handler.cjs";
|
|
3
3
|
import { HotUpdaterSchemaMigrationRequiredError } from "./schemaReadiness.cjs";
|
|
4
4
|
import { HOT_UPDATER_SERVER_VERSION } from "../version.cjs";
|
|
5
|
-
import { DatabaseAPI, DatabaseAdapter, Migrator, SchemaGenerator, StoragePluginFactory } from "./types.cjs";
|
|
6
|
-
import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
7
5
|
|
|
8
6
|
//#region src/db/index.d.ts
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
|
|
12
|
-
adapterName: string;
|
|
13
|
-
createMigrator: () => Migrator;
|
|
14
|
-
generateSchema: SchemaGenerator;
|
|
7
|
+
type HotUpdaterDBTarget = {
|
|
8
|
+
readonly adapterName: string;
|
|
15
9
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Storage plugins for handling file uploads and downloads.
|
|
20
|
-
*/
|
|
21
|
-
storages?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated Use `storages` instead. This field will be removed in a future version.
|
|
24
|
-
*/
|
|
25
|
-
storagePlugins?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
26
|
-
basePath?: string;
|
|
27
|
-
cwd?: string;
|
|
28
|
-
routes?: HandlerRoutes;
|
|
29
|
-
}
|
|
30
|
-
declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): HotUpdaterAPI<TContext>;
|
|
10
|
+
declare function createMigrator(hotUpdater: HotUpdaterDBTarget): Migrator;
|
|
11
|
+
declare function generateSchema(hotUpdater: HotUpdaterDBTarget, ...args: Parameters<SchemaGenerator>): ReturnType<SchemaGenerator>;
|
|
31
12
|
//#endregion
|
|
32
|
-
export {
|
|
13
|
+
export { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, HOT_UPDATER_SERVER_VERSION, HotUpdaterDBTarget, HotUpdaterSchemaMigrationRequiredError, type Migrator, type SchemaGenerator, createBundleDiff, createMigrator, generateSchema };
|
package/dist/db/index.d.mts
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
|
+
import { Migrator, SchemaGenerator } from "./types.mjs";
|
|
1
2
|
import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./createBundleDiff.mjs";
|
|
2
|
-
import { HandlerRoutes } from "../handler.mjs";
|
|
3
3
|
import { HotUpdaterSchemaMigrationRequiredError } from "./schemaReadiness.mjs";
|
|
4
4
|
import { HOT_UPDATER_SERVER_VERSION } from "../version.mjs";
|
|
5
|
-
import { DatabaseAPI, DatabaseAdapter, Migrator, SchemaGenerator, StoragePluginFactory } from "./types.mjs";
|
|
6
|
-
import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
7
5
|
|
|
8
6
|
//#region src/db/index.d.ts
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
|
|
12
|
-
adapterName: string;
|
|
13
|
-
createMigrator: () => Migrator;
|
|
14
|
-
generateSchema: SchemaGenerator;
|
|
7
|
+
type HotUpdaterDBTarget = {
|
|
8
|
+
readonly adapterName: string;
|
|
15
9
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Storage plugins for handling file uploads and downloads.
|
|
20
|
-
*/
|
|
21
|
-
storages?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated Use `storages` instead. This field will be removed in a future version.
|
|
24
|
-
*/
|
|
25
|
-
storagePlugins?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
26
|
-
basePath?: string;
|
|
27
|
-
cwd?: string;
|
|
28
|
-
routes?: HandlerRoutes;
|
|
29
|
-
}
|
|
30
|
-
declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): HotUpdaterAPI<TContext>;
|
|
10
|
+
declare function createMigrator(hotUpdater: HotUpdaterDBTarget): Migrator;
|
|
11
|
+
declare function generateSchema(hotUpdater: HotUpdaterDBTarget, ...args: Parameters<SchemaGenerator>): ReturnType<SchemaGenerator>;
|
|
31
12
|
//#endregion
|
|
32
|
-
export {
|
|
13
|
+
export { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, HOT_UPDATER_SERVER_VERSION, HotUpdaterDBTarget, HotUpdaterSchemaMigrationRequiredError, type Migrator, type SchemaGenerator, createBundleDiff, createMigrator, generateSchema };
|
package/dist/db/index.mjs
CHANGED
|
@@ -1,46 +1,22 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
4
|
-
import { normalizeBasePath } from "../route.mjs";
|
|
5
|
-
import { createStorageAccess } from "../storageAccess.mjs";
|
|
6
|
-
import { createPluginDatabaseCore } from "./pluginCore.mjs";
|
|
7
|
-
import { isDatabasePluginFactory } from "./types.mjs";
|
|
1
|
+
import { HOT_UPDATER_SERVER_VERSION } from "../version.mjs";
|
|
2
|
+
import { HotUpdaterSchemaMigrationRequiredError } from "./schemaReadiness.mjs";
|
|
3
|
+
import { getHotUpdaterCoreMetadata } from "../createHotUpdaterCore.mjs";
|
|
8
4
|
import { generateSchemaFromHotUpdaterSchema } from "./schemaGenerators.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { assertRuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
5
|
+
import { createBundleDiff } from "./createBundleDiff.mjs";
|
|
11
6
|
//#region src/db/index.ts
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
beforeOperation: assertSchemaReady,
|
|
26
|
-
readStorageText
|
|
27
|
-
} : {
|
|
28
|
-
beforeOperation: assertSchemaReady,
|
|
29
|
-
readStorageText
|
|
30
|
-
});
|
|
31
|
-
const generateSchema = capabilities.generateSchema ?? core.generateSchema;
|
|
32
|
-
const api = {
|
|
33
|
-
basePath,
|
|
34
|
-
adapterName: capabilities.adapterName ?? core.adapterName,
|
|
35
|
-
createMigrator: capabilities.createMigrator ?? core.createMigrator,
|
|
36
|
-
generateSchema: (...args) => generateSchemaFromHotUpdaterSchema(api.adapterName, capabilities.provider, args[0], generateSchema(...args)),
|
|
37
|
-
handler: createHandler(core.api, {
|
|
38
|
-
basePath,
|
|
39
|
-
routes: options.routes
|
|
40
|
-
})
|
|
41
|
-
};
|
|
42
|
-
Object.defineProperties(api, Object.getOwnPropertyDescriptors(core.api));
|
|
43
|
-
return api;
|
|
7
|
+
const getDBMetadata = (hotUpdater) => {
|
|
8
|
+
const metadata = getHotUpdaterCoreMetadata(hotUpdater);
|
|
9
|
+
if (!metadata) throw new Error("Database tooling requires a hotUpdater instance created by @hot-updater/server.");
|
|
10
|
+
return metadata;
|
|
11
|
+
};
|
|
12
|
+
function createMigrator(hotUpdater) {
|
|
13
|
+
const { adapterCapabilities, core } = getDBMetadata(hotUpdater);
|
|
14
|
+
return (adapterCapabilities.createMigrator ?? core.createMigrator)();
|
|
15
|
+
}
|
|
16
|
+
function generateSchema(hotUpdater, ...args) {
|
|
17
|
+
const { adapterCapabilities, core } = getDBMetadata(hotUpdater);
|
|
18
|
+
const schemaGenerator = adapterCapabilities.generateSchema ?? core.generateSchema;
|
|
19
|
+
return generateSchemaFromHotUpdaterSchema(hotUpdater.adapterName, adapterCapabilities.provider, args[0], schemaGenerator(...args));
|
|
44
20
|
}
|
|
45
21
|
//#endregion
|
|
46
|
-
export {
|
|
22
|
+
export { HOT_UPDATER_SERVER_VERSION, HotUpdaterSchemaMigrationRequiredError, createBundleDiff, createMigrator, generateSchema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("../schema/types.cjs");
|
|
2
|
-
const require_registry = require("./schema/registry.cjs");
|
|
3
2
|
const require_types$1 = require("./types.cjs");
|
|
3
|
+
const require_registry = require("./schema/registry.cjs");
|
|
4
4
|
//#region src/db/schemaGenerators.ts
|
|
5
5
|
const literal = (value) => JSON.stringify(value);
|
|
6
6
|
const toPascalCase = (value) => value.split("_").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../schema/types.mjs";
|
|
2
|
-
import { getHotUpdaterSchemaVersion, hotUpdaterSchema, schemaIndexAppliesToProvider } from "./schema/registry.mjs";
|
|
3
2
|
import { getSQLProvider } from "./types.mjs";
|
|
3
|
+
import { getHotUpdaterSchemaVersion, hotUpdaterSchema, schemaIndexAppliesToProvider } from "./schema/registry.mjs";
|
|
4
4
|
//#region src/db/schemaGenerators.ts
|
|
5
5
|
const literal = (value) => JSON.stringify(value);
|
|
6
6
|
const toPascalCase = (value) => value.split("_").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("");
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_createBundleDiff = require("./db/createBundleDiff.cjs");
|
|
3
2
|
const require_version = require("./version.cjs");
|
|
4
3
|
const require_handler = require("./handler.cjs");
|
|
5
|
-
const
|
|
6
|
-
const require_index = require("./db/index.cjs");
|
|
4
|
+
const require_createHotUpdaterCore = require("./createHotUpdaterCore.cjs");
|
|
7
5
|
exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
|
|
8
|
-
exports.HotUpdaterSchemaMigrationRequiredError = require_schemaReadiness.HotUpdaterSchemaMigrationRequiredError;
|
|
9
|
-
exports.createBundleDiff = require_createBundleDiff.createBundleDiff;
|
|
10
6
|
exports.createHandler = require_handler.createHandler;
|
|
11
|
-
exports.createHotUpdater =
|
|
7
|
+
exports.createHotUpdater = require_createHotUpdaterCore.createHotUpdater;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./db/createBundleDiff.cjs";
|
|
2
1
|
import { HandlerAPI, HandlerOptions, HandlerRoutes, createHandler } from "./handler.cjs";
|
|
3
|
-
import {
|
|
4
|
-
import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
|
|
5
|
-
import { CreateHotUpdaterOptions, HotUpdaterAPI, createHotUpdater } from "./db/index.cjs";
|
|
2
|
+
import { CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.cjs";
|
|
6
3
|
import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.cjs";
|
|
7
|
-
import {
|
|
8
|
-
export { Bundle, ChannelsResponse,
|
|
4
|
+
import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
|
|
5
|
+
export { Bundle, ChannelsResponse, type CreateHotUpdaterOptions, DataResponse, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HandlerOptions, type HandlerRoutes, type HotUpdaterAPI, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, type RuntimeHotUpdaterAPI, createHandler, createHotUpdater };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./db/createBundleDiff.mjs";
|
|
2
1
|
import { HandlerAPI, HandlerOptions, HandlerRoutes, createHandler } from "./handler.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
5
|
-
import { CreateHotUpdaterOptions, HotUpdaterAPI, createHotUpdater } from "./db/index.mjs";
|
|
2
|
+
import { CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.mjs";
|
|
6
3
|
import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.mjs";
|
|
7
|
-
import {
|
|
8
|
-
export { Bundle, ChannelsResponse,
|
|
4
|
+
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
5
|
+
export { Bundle, ChannelsResponse, type CreateHotUpdaterOptions, DataResponse, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HandlerOptions, type HandlerRoutes, type HotUpdaterAPI, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, type RuntimeHotUpdaterAPI, createHandler, createHotUpdater };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { createBundleDiff } from "./db/createBundleDiff.mjs";
|
|
2
1
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
3
2
|
import { createHandler } from "./handler.mjs";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export { HOT_UPDATER_SERVER_VERSION, HotUpdaterSchemaMigrationRequiredError, createBundleDiff, createHandler, createHotUpdater };
|
|
3
|
+
import { createHotUpdater } from "./createHotUpdaterCore.mjs";
|
|
4
|
+
export { HOT_UPDATER_SERVER_VERSION, createHandler, createHotUpdater };
|
package/dist/node.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_version = require("./version.cjs");
|
|
2
3
|
//#region src/node.ts
|
|
3
4
|
/**
|
|
4
5
|
* Converts a Hot Updater handler to a Node.js-compatible middleware
|
|
@@ -47,4 +48,5 @@ function toNodeHandler(hotUpdater) {
|
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
//#endregion
|
|
51
|
+
exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
|
|
50
52
|
exports.toNodeHandler = toNodeHandler;
|
package/dist/node.d.cts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
|
|
2
|
+
|
|
2
3
|
//#region src/node.d.ts
|
|
4
|
+
type HandlerHotUpdaterAPI = {
|
|
5
|
+
readonly handler: (request: Request) => Promise<Response>;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* Converts a Hot Updater handler to a Node.js-compatible middleware
|
|
5
9
|
* Works with Express, Connect, and other frameworks using Node.js req/res
|
|
@@ -18,6 +22,6 @@ import { HotUpdaterAPI } from "./db/index.cjs";
|
|
|
18
22
|
* app.all("/hot-updater/*", toNodeHandler(hotUpdater));
|
|
19
23
|
* ```
|
|
20
24
|
*/
|
|
21
|
-
declare function toNodeHandler(hotUpdater:
|
|
25
|
+
declare function toNodeHandler(hotUpdater: HandlerHotUpdaterAPI): (req: any, res: any, next?: any) => Promise<void>;
|
|
22
26
|
//#endregion
|
|
23
|
-
export { toNodeHandler };
|
|
27
|
+
export { HOT_UPDATER_SERVER_VERSION, toNodeHandler };
|
package/dist/node.d.mts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
2
|
+
|
|
2
3
|
//#region src/node.d.ts
|
|
4
|
+
type HandlerHotUpdaterAPI = {
|
|
5
|
+
readonly handler: (request: Request) => Promise<Response>;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* Converts a Hot Updater handler to a Node.js-compatible middleware
|
|
5
9
|
* Works with Express, Connect, and other frameworks using Node.js req/res
|
|
@@ -18,6 +22,6 @@ import { HotUpdaterAPI } from "./db/index.mjs";
|
|
|
18
22
|
* app.all("/hot-updater/*", toNodeHandler(hotUpdater));
|
|
19
23
|
* ```
|
|
20
24
|
*/
|
|
21
|
-
declare function toNodeHandler(hotUpdater:
|
|
25
|
+
declare function toNodeHandler(hotUpdater: HandlerHotUpdaterAPI): (req: any, res: any, next?: any) => Promise<void>;
|
|
22
26
|
//#endregion
|
|
23
|
-
export { toNodeHandler };
|
|
27
|
+
export { HOT_UPDATER_SERVER_VERSION, toNodeHandler };
|
package/dist/node.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
1
2
|
//#region src/node.ts
|
|
2
3
|
/**
|
|
3
4
|
* Converts a Hot Updater handler to a Node.js-compatible middleware
|
|
@@ -46,4 +47,4 @@ function toNodeHandler(hotUpdater) {
|
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
//#endregion
|
|
49
|
-
export { toNodeHandler };
|
|
50
|
+
export { HOT_UPDATER_SERVER_VERSION, toNodeHandler };
|
package/dist/package.cjs
CHANGED
package/dist/package.mjs
CHANGED
package/dist/types/index.d.cts
CHANGED
package/dist/types/index.d.mts
CHANGED