@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
package/src/runtime.spec.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
|
|
1
3
|
import type { Bundle } from "@hot-updater/core";
|
|
2
4
|
import { NIL_UUID } from "@hot-updater/core";
|
|
3
5
|
import type {
|
|
@@ -10,7 +12,8 @@ import { createDatabasePlugin } from "@hot-updater/plugin-core";
|
|
|
10
12
|
import { describe, expect, expectTypeOf, it, vi } from "vitest";
|
|
11
13
|
|
|
12
14
|
import type { DatabaseAdapterCapabilities, Migrator } from "./db/types";
|
|
13
|
-
import { createHotUpdater } from "./
|
|
15
|
+
import { createHotUpdater } from "./index";
|
|
16
|
+
import type { HandlerAPI, HandlerOptions, HandlerRoutes } from "./index";
|
|
14
17
|
import { HOT_UPDATER_SERVER_VERSION } from "./version";
|
|
15
18
|
|
|
16
19
|
const bundle: Bundle = {
|
|
@@ -97,6 +100,64 @@ const createSchemaManagedDatabase = (
|
|
|
97
100
|
});
|
|
98
101
|
|
|
99
102
|
describe("runtime createHotUpdater", () => {
|
|
103
|
+
it("publishes db tooling subpath and removes the runtime subpath", async () => {
|
|
104
|
+
const packageJson = JSON.parse(
|
|
105
|
+
await readFile(new URL("../package.json", import.meta.url), "utf-8"),
|
|
106
|
+
) as {
|
|
107
|
+
exports: Record<string, unknown>;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
expect(packageJson.exports["./db"]).toBeDefined();
|
|
111
|
+
expect(packageJson.exports["./runtime"]).toBeUndefined();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("exports runtime-safe handler types from the root entry", () => {
|
|
115
|
+
expectTypeOf<HandlerAPI>().toHaveProperty("getBundles");
|
|
116
|
+
expectTypeOf<HandlerOptions>().toHaveProperty("routes");
|
|
117
|
+
expectTypeOf<HandlerRoutes>().toEqualTypeOf<{
|
|
118
|
+
updateCheck: boolean;
|
|
119
|
+
bundles: boolean;
|
|
120
|
+
}>();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("exports the root runtime API without database capabilities", () => {
|
|
124
|
+
const database: DatabasePlugin<TestContext> = {
|
|
125
|
+
name: "testDatabase",
|
|
126
|
+
async appendBundle() {},
|
|
127
|
+
async commitBundle() {},
|
|
128
|
+
async deleteBundle() {},
|
|
129
|
+
async getBundleById() {
|
|
130
|
+
return null;
|
|
131
|
+
},
|
|
132
|
+
async getBundles() {
|
|
133
|
+
return {
|
|
134
|
+
data: [],
|
|
135
|
+
pagination: {
|
|
136
|
+
currentPage: 1,
|
|
137
|
+
hasNextPage: false,
|
|
138
|
+
hasPreviousPage: false,
|
|
139
|
+
total: 0,
|
|
140
|
+
totalPages: 0,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
async getChannels() {
|
|
145
|
+
return [];
|
|
146
|
+
},
|
|
147
|
+
async updateBundle() {},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const hotUpdater = createHotUpdater({ database });
|
|
151
|
+
|
|
152
|
+
expect(hotUpdater.basePath).toBe("/api");
|
|
153
|
+
expect(hotUpdater.adapterName).toBe("testDatabase");
|
|
154
|
+
expect(hotUpdater.handler).toEqual(expect.any(Function));
|
|
155
|
+
expect("createMigrator" in hotUpdater).toBe(false);
|
|
156
|
+
expect("generateSchema" in hotUpdater).toBe(false);
|
|
157
|
+
expectTypeOf(hotUpdater).not.toHaveProperty("createMigrator");
|
|
158
|
+
expectTypeOf(hotUpdater).not.toHaveProperty("generateSchema");
|
|
159
|
+
});
|
|
160
|
+
|
|
100
161
|
it("requires storages to implement the runtime profile", () => {
|
|
101
162
|
const database: DatabasePlugin<TestContext> = {
|
|
102
163
|
name: "testDatabase",
|
package/src/types/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Bundle } from "@hot-updater/core";
|
|
2
2
|
|
|
3
3
|
export type { Bundle } from "@hot-updater/core";
|
|
4
|
-
export type { HotUpdaterAPI } from "../
|
|
4
|
+
export type { HotUpdaterAPI } from "../createHotUpdaterCore";
|
|
5
5
|
|
|
6
6
|
export interface PaginationInfo {
|
|
7
7
|
total: number;
|
package/dist/runtime.d.cts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { HandlerRoutes, createHandler } from "./handler.cjs";
|
|
2
|
-
import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
|
|
3
|
-
import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./db/types.cjs";
|
|
4
|
-
import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
5
|
-
|
|
6
|
-
//#region src/runtime.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
|
-
};
|
|
12
|
-
interface CreateHotUpdaterOptions<TContext = unknown> {
|
|
13
|
-
database: DatabaseAdapter<TContext>;
|
|
14
|
-
storages?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
15
|
-
storagePlugins?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
16
|
-
basePath?: string;
|
|
17
|
-
cwd?: string;
|
|
18
|
-
routes?: HandlerRoutes;
|
|
19
|
-
}
|
|
20
|
-
declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): HotUpdaterAPI<TContext>;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { CreateHotUpdaterOptions, HOT_UPDATER_SERVER_VERSION, HotUpdaterAPI, createHandler, createHotUpdater };
|
package/dist/runtime.d.mts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { HandlerRoutes, createHandler } from "./handler.mjs";
|
|
2
|
-
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
3
|
-
import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./db/types.mjs";
|
|
4
|
-
import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
5
|
-
|
|
6
|
-
//#region src/runtime.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
|
-
};
|
|
12
|
-
interface CreateHotUpdaterOptions<TContext = unknown> {
|
|
13
|
-
database: DatabaseAdapter<TContext>;
|
|
14
|
-
storages?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
15
|
-
storagePlugins?: (RuntimeStoragePlugin<TContext> | StoragePluginFactory<TContext>)[];
|
|
16
|
-
basePath?: string;
|
|
17
|
-
cwd?: string;
|
|
18
|
-
routes?: HandlerRoutes;
|
|
19
|
-
}
|
|
20
|
-
declare function createHotUpdater<TContext = unknown>(options: CreateHotUpdaterOptions<TContext>): HotUpdaterAPI<TContext>;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { CreateHotUpdaterOptions, HOT_UPDATER_SERVER_VERSION, HotUpdaterAPI, createHandler, createHotUpdater };
|