@hot-updater/server 0.28.0 → 0.29.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/adapters/drizzle.cjs +7 -7
- package/dist/adapters/drizzle.mjs +2 -0
- package/dist/adapters/kysely.cjs +7 -7
- package/dist/adapters/kysely.mjs +2 -0
- package/dist/adapters/mongodb.cjs +7 -7
- package/dist/adapters/mongodb.mjs +2 -0
- package/dist/adapters/prisma.cjs +7 -7
- package/dist/adapters/prisma.mjs +2 -0
- package/dist/calculatePagination.cjs +1 -3
- package/dist/{calculatePagination.js → calculatePagination.mjs} +1 -2
- package/dist/db/index.cjs +24 -15
- package/dist/db/index.d.cts +12 -9
- package/dist/db/index.d.mts +30 -0
- package/dist/db/index.mjs +45 -0
- package/dist/db/ormCore.cjs +247 -138
- package/dist/db/ormCore.d.cts +35 -17
- package/dist/db/ormCore.d.mts +44 -0
- package/dist/db/ormCore.mjs +386 -0
- package/dist/db/pluginCore.cjs +145 -40
- package/dist/db/pluginCore.mjs +176 -0
- package/dist/db/types.cjs +1 -3
- package/dist/db/types.d.cts +14 -21
- package/dist/db/types.d.mts +24 -0
- package/dist/db/{types.js → types.mjs} +1 -2
- package/dist/handler.cjs +117 -48
- package/dist/handler.d.cts +28 -18
- package/dist/handler.d.mts +47 -0
- package/dist/handler.mjs +217 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +4 -0
- package/dist/internalRouter.cjs +54 -0
- package/dist/internalRouter.mjs +52 -0
- package/dist/node.cjs +2 -3
- package/dist/node.d.cts +0 -1
- package/dist/{node.d.ts → node.d.mts} +1 -2
- package/dist/{node.js → node.mjs} +1 -2
- package/dist/route.cjs +7 -0
- package/dist/route.mjs +7 -0
- package/dist/runtime.cjs +42 -0
- package/dist/runtime.d.cts +21 -0
- package/dist/runtime.d.mts +21 -0
- package/dist/runtime.mjs +40 -0
- package/dist/schema/v0_21_0.cjs +1 -5
- package/dist/schema/{v0_21_0.js → v0_21_0.mjs} +1 -3
- package/dist/schema/v0_29_0.cjs +24 -0
- package/dist/schema/v0_29_0.mjs +24 -0
- package/dist/types/{index.d.ts → index.d.mts} +1 -1
- package/package.json +18 -18
- package/src/db/index.spec.ts +64 -29
- package/src/db/index.ts +55 -35
- package/src/db/ormCore.ts +438 -210
- package/src/db/ormUpdateCheck.bench.ts +261 -0
- package/src/db/pluginCore.ts +298 -49
- package/src/db/pluginUpdateCheck.bench.ts +250 -0
- package/src/db/types.ts +52 -27
- package/src/{handler-standalone-integration.spec.ts → handler-standalone.integration.spec.ts} +106 -0
- package/src/handler.spec.ts +156 -0
- package/src/handler.ts +296 -77
- package/src/internalRouter.ts +104 -0
- package/src/route.ts +7 -0
- package/src/runtime.spec.ts +277 -0
- package/src/runtime.ts +121 -0
- package/src/schema/v0_29_0.ts +26 -0
- package/dist/_virtual/rolldown_runtime.cjs +0 -25
- package/dist/adapters/drizzle.js +0 -3
- package/dist/adapters/kysely.js +0 -3
- package/dist/adapters/mongodb.js +0 -3
- package/dist/adapters/prisma.js +0 -3
- package/dist/db/index.d.ts +0 -27
- package/dist/db/index.js +0 -36
- package/dist/db/ormCore.d.ts +0 -26
- package/dist/db/ormCore.js +0 -273
- package/dist/db/pluginCore.js +0 -69
- package/dist/db/types.d.ts +0 -31
- package/dist/handler.d.ts +0 -37
- package/dist/handler.js +0 -146
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -5
- /package/dist/adapters/{drizzle.d.ts → drizzle.d.mts} +0 -0
- /package/dist/adapters/{kysely.d.ts → kysely.d.mts} +0 -0
- /package/dist/adapters/{mongodb.d.ts → mongodb.d.mts} +0 -0
- /package/dist/adapters/{prisma.d.ts → prisma.d.mts} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
var fumadb_adapters_drizzle = require("fumadb/adapters/drizzle");
|
|
4
|
-
Object.keys(fumadb_adapters_drizzle).forEach(function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.keys(fumadb_adapters_drizzle).forEach(function(k) {
|
|
3
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return fumadb_adapters_drizzle[k];
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
9
|
});
|
package/dist/adapters/kysely.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
var fumadb_adapters_kysely = require("fumadb/adapters/kysely");
|
|
4
|
-
Object.keys(fumadb_adapters_kysely).forEach(function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.keys(fumadb_adapters_kysely).forEach(function(k) {
|
|
3
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return fumadb_adapters_kysely[k];
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
9
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
var fumadb_adapters_mongodb = require("fumadb/adapters/mongodb");
|
|
4
|
-
Object.keys(fumadb_adapters_mongodb).forEach(function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.keys(fumadb_adapters_mongodb).forEach(function(k) {
|
|
3
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return fumadb_adapters_mongodb[k];
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
9
|
});
|
package/dist/adapters/prisma.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
var fumadb_adapters_prisma = require("fumadb/adapters/prisma");
|
|
4
|
-
Object.keys(fumadb_adapters_prisma).forEach(function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.keys(fumadb_adapters_prisma).forEach(function(k) {
|
|
3
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return fumadb_adapters_prisma[k];
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
9
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/calculatePagination.ts
|
|
3
2
|
/**
|
|
4
3
|
* Calculate pagination information based on total count, limit, and offset
|
|
@@ -22,6 +21,5 @@ function calculatePagination(total, options) {
|
|
|
22
21
|
totalPages
|
|
23
22
|
};
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
//#endregion
|
|
27
|
-
exports.calculatePagination = calculatePagination;
|
|
25
|
+
exports.calculatePagination = calculatePagination;
|
package/dist/db/index.cjs
CHANGED
|
@@ -1,36 +1,45 @@
|
|
|
1
|
-
const require_handler = require(
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
const require_handler = require("../handler.cjs");
|
|
2
|
+
const require_route = require("../route.cjs");
|
|
3
|
+
const require_ormCore = require("./ormCore.cjs");
|
|
4
|
+
const require_pluginCore = require("./pluginCore.cjs");
|
|
5
|
+
const require_types = require("./types.cjs");
|
|
6
6
|
//#region src/db/index.ts
|
|
7
7
|
function createHotUpdater(options) {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const basePath = require_route.normalizeBasePath(options.basePath ?? "/api");
|
|
9
|
+
const storagePlugins = (options.storages ?? options.storagePlugins ?? []).map((plugin) => typeof plugin === "function" ? plugin() : plugin);
|
|
10
|
+
const resolveStoragePluginUrl = async (storageUri, context) => {
|
|
10
11
|
if (!storageUri) return null;
|
|
11
12
|
const protocol = new URL(storageUri).protocol.replace(":", "");
|
|
12
13
|
if (protocol === "http" || protocol === "https") return storageUri;
|
|
13
14
|
const plugin = storagePlugins.find((p) => p.supportedProtocol === protocol);
|
|
14
15
|
if (!plugin) throw new Error(`No storage plugin for protocol: ${protocol}`);
|
|
15
|
-
const { fileUrl } = await plugin.getDownloadUrl(storageUri);
|
|
16
|
+
const { fileUrl } = await plugin.getDownloadUrl(storageUri, context);
|
|
16
17
|
if (!fileUrl) throw new Error("Storage plugin returned empty fileUrl");
|
|
17
18
|
return fileUrl;
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
+
const resolveFileUrl = async (storageUri, context) => {
|
|
21
|
+
return resolveStoragePluginUrl(storageUri, context);
|
|
22
|
+
};
|
|
20
23
|
const database = options.database;
|
|
21
|
-
|
|
22
|
-
else core = require_ormCore.createOrmDatabaseCore({
|
|
24
|
+
const core = require_types.isDatabasePluginFactory(database) || require_types.isDatabasePlugin(database) ? require_pluginCore.createPluginDatabaseCore(require_types.isDatabasePluginFactory(database) ? database() : database, resolveFileUrl) : require_ormCore.createOrmDatabaseCore({
|
|
23
25
|
database,
|
|
24
26
|
resolveFileUrl
|
|
25
27
|
});
|
|
26
|
-
|
|
28
|
+
const api = {
|
|
27
29
|
...core.api,
|
|
28
|
-
handler: require_handler.createHandler(core.api,
|
|
30
|
+
handler: require_handler.createHandler(core.api, {
|
|
31
|
+
basePath,
|
|
32
|
+
routes: options.routes
|
|
33
|
+
}),
|
|
29
34
|
adapterName: core.adapterName,
|
|
30
35
|
createMigrator: core.createMigrator,
|
|
31
36
|
generateSchema: core.generateSchema
|
|
32
37
|
};
|
|
38
|
+
return {
|
|
39
|
+
...api,
|
|
40
|
+
basePath,
|
|
41
|
+
handler: api.handler
|
|
42
|
+
};
|
|
33
43
|
}
|
|
34
|
-
|
|
35
44
|
//#endregion
|
|
36
|
-
exports.createHotUpdater = createHotUpdater;
|
|
45
|
+
exports.createHotUpdater = createHotUpdater;
|
package/dist/db/index.d.cts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
+
import { HandlerRoutes } from "../handler.cjs";
|
|
1
2
|
import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./types.cjs";
|
|
2
3
|
import { HotUpdaterClient, HotUpdaterDB, Migrator } from "./ormCore.cjs";
|
|
3
|
-
import { StoragePlugin } from "@hot-updater/plugin-core";
|
|
4
|
+
import { HotUpdaterContext, StoragePlugin } from "@hot-updater/plugin-core";
|
|
4
5
|
|
|
5
6
|
//#region src/db/index.d.ts
|
|
6
|
-
type HotUpdaterAPI = DatabaseAPI & {
|
|
7
|
-
|
|
7
|
+
type HotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
|
|
8
|
+
basePath: string;
|
|
9
|
+
handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
|
|
8
10
|
adapterName: string;
|
|
9
11
|
createMigrator: () => Migrator;
|
|
10
12
|
generateSchema: HotUpdaterClient["generateSchema"];
|
|
11
13
|
};
|
|
12
|
-
interface
|
|
13
|
-
database: DatabaseAdapter
|
|
14
|
+
interface CreateHotUpdaterOptions<TContext = unknown> {
|
|
15
|
+
database: DatabaseAdapter<TContext>;
|
|
14
16
|
/**
|
|
15
17
|
* Storage plugins for handling file uploads and downloads.
|
|
16
18
|
*/
|
|
17
|
-
storages?: (StoragePlugin | StoragePluginFactory)[];
|
|
19
|
+
storages?: (StoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
18
20
|
/**
|
|
19
21
|
* @deprecated Use `storages` instead. This field will be removed in a future version.
|
|
20
22
|
*/
|
|
21
|
-
storagePlugins?: (StoragePlugin | StoragePluginFactory)[];
|
|
23
|
+
storagePlugins?: (StoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
22
24
|
basePath?: string;
|
|
23
25
|
cwd?: string;
|
|
26
|
+
routes?: HandlerRoutes;
|
|
24
27
|
}
|
|
25
|
-
declare function createHotUpdater(options:
|
|
28
|
+
declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): HotUpdaterAPI<TContext>;
|
|
26
29
|
//#endregion
|
|
27
|
-
export { HotUpdaterAPI, createHotUpdater };
|
|
30
|
+
export { CreateHotUpdaterOptions, HotUpdaterAPI, createHotUpdater };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { HandlerRoutes } from "../handler.mjs";
|
|
2
|
+
import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./types.mjs";
|
|
3
|
+
import { HotUpdaterClient, HotUpdaterDB, Migrator } from "./ormCore.mjs";
|
|
4
|
+
import { HotUpdaterContext, StoragePlugin } from "@hot-updater/plugin-core";
|
|
5
|
+
|
|
6
|
+
//#region src/db/index.d.ts
|
|
7
|
+
type HotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
|
|
8
|
+
basePath: string;
|
|
9
|
+
handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
|
|
10
|
+
adapterName: string;
|
|
11
|
+
createMigrator: () => Migrator;
|
|
12
|
+
generateSchema: HotUpdaterClient["generateSchema"];
|
|
13
|
+
};
|
|
14
|
+
interface CreateHotUpdaterOptions<TContext = unknown> {
|
|
15
|
+
database: DatabaseAdapter<TContext>;
|
|
16
|
+
/**
|
|
17
|
+
* Storage plugins for handling file uploads and downloads.
|
|
18
|
+
*/
|
|
19
|
+
storages?: (StoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `storages` instead. This field will be removed in a future version.
|
|
22
|
+
*/
|
|
23
|
+
storagePlugins?: (StoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
24
|
+
basePath?: string;
|
|
25
|
+
cwd?: string;
|
|
26
|
+
routes?: HandlerRoutes;
|
|
27
|
+
}
|
|
28
|
+
declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): HotUpdaterAPI<TContext>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { CreateHotUpdaterOptions, HotUpdaterAPI, createHotUpdater };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createHandler } from "../handler.mjs";
|
|
2
|
+
import { normalizeBasePath } from "../route.mjs";
|
|
3
|
+
import { createOrmDatabaseCore } from "./ormCore.mjs";
|
|
4
|
+
import { createPluginDatabaseCore } from "./pluginCore.mjs";
|
|
5
|
+
import { isDatabasePlugin, isDatabasePluginFactory } from "./types.mjs";
|
|
6
|
+
//#region src/db/index.ts
|
|
7
|
+
function createHotUpdater(options) {
|
|
8
|
+
const basePath = normalizeBasePath(options.basePath ?? "/api");
|
|
9
|
+
const storagePlugins = (options.storages ?? options.storagePlugins ?? []).map((plugin) => typeof plugin === "function" ? plugin() : plugin);
|
|
10
|
+
const resolveStoragePluginUrl = async (storageUri, context) => {
|
|
11
|
+
if (!storageUri) return null;
|
|
12
|
+
const protocol = new URL(storageUri).protocol.replace(":", "");
|
|
13
|
+
if (protocol === "http" || protocol === "https") return storageUri;
|
|
14
|
+
const plugin = storagePlugins.find((p) => p.supportedProtocol === protocol);
|
|
15
|
+
if (!plugin) throw new Error(`No storage plugin for protocol: ${protocol}`);
|
|
16
|
+
const { fileUrl } = await plugin.getDownloadUrl(storageUri, context);
|
|
17
|
+
if (!fileUrl) throw new Error("Storage plugin returned empty fileUrl");
|
|
18
|
+
return fileUrl;
|
|
19
|
+
};
|
|
20
|
+
const resolveFileUrl = async (storageUri, context) => {
|
|
21
|
+
return resolveStoragePluginUrl(storageUri, context);
|
|
22
|
+
};
|
|
23
|
+
const database = options.database;
|
|
24
|
+
const core = isDatabasePluginFactory(database) || isDatabasePlugin(database) ? createPluginDatabaseCore(isDatabasePluginFactory(database) ? database() : database, resolveFileUrl) : createOrmDatabaseCore({
|
|
25
|
+
database,
|
|
26
|
+
resolveFileUrl
|
|
27
|
+
});
|
|
28
|
+
const api = {
|
|
29
|
+
...core.api,
|
|
30
|
+
handler: createHandler(core.api, {
|
|
31
|
+
basePath,
|
|
32
|
+
routes: options.routes
|
|
33
|
+
}),
|
|
34
|
+
adapterName: core.adapterName,
|
|
35
|
+
createMigrator: core.createMigrator,
|
|
36
|
+
generateSchema: core.generateSchema
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
...api,
|
|
40
|
+
basePath,
|
|
41
|
+
handler: api.handler
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { createHotUpdater };
|