@hot-updater/cloudflare 1.0.0-rc.2 → 1.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +95 -870
- package/dist/index.d.cts +724 -6
- package/dist/index.d.mts +724 -6
- package/dist/index.mjs +93 -870
- package/dist/init/index.cjs +11768 -0
- package/dist/init/index.d.cts +5 -1
- package/dist/init/index.d.mts +5 -1
- package/dist/init/index.mjs +11761 -1
- package/dist/worker/index.cjs +59 -859
- package/dist/worker/index.d.cts +725 -11
- package/dist/worker/index.d.mts +725 -11
- package/dist/worker/index.mjs +62 -863
- package/package.json +9 -13
- package/sql/bundles.sql +109 -190
- package/src/d1Database.ts +61 -40
- package/src/d1Executor.ts +84 -0
- package/src/d1Schema.ts +26 -0
- package/src/index.ts +1 -0
- package/src/plugins.ts +8 -0
- package/src/r2S3Storage.ts +4 -4
- package/src/r2Storage.ts +2 -2
- package/src/r2WorkerStorage.ts +4 -4
- package/src/worker/d1Database.ts +21 -27
- package/src/worker/index.ts +1 -0
- package/worker/dist/README.md +1 -1
- package/worker/dist/index.js +9682 -6206
- package/worker/dist/index.js.map +4 -4
- package/worker/migrations/0001_hot-updater_1.0.0.sql +109 -205
- package/worker/src/index.ts +2 -2
- package/dist/iac/index.cjs +0 -12566
- package/dist/iac/index.d.cts +0 -9
- package/dist/iac/index.d.mts +0 -9
- package/dist/iac/index.mjs +0 -12558
- package/src/d1Database.spec.ts +0 -178
- package/src/d1Implementation.spec.ts +0 -252
- package/src/d1Implementation.ts +0 -742
- package/src/d1Query.spec.ts +0 -46
- package/src/d1Query.ts +0 -89
- package/src/d1Rows.spec.ts +0 -111
- package/src/d1Rows.ts +0 -326
- package/src/d1Sql.spec.ts +0 -30
- package/src/d1Sql.ts +0 -175
- package/src/r2Storage.spec.ts +0 -346
- package/src/r2WorkerStorage.spec.ts +0 -184
- package/src/utils/createWrangler.spec.ts +0 -75
- package/src/worker/d1Database.spec.ts +0 -33
- package/worker/src/databaseMigration.integration.spec.ts +0 -130
- package/worker/src/databasePlugins.integration.spec.ts +0 -292
- package/worker/src/index.integration.spec.ts +0 -190
- package/worker/src/storagePlugin.integration.spec.ts +0 -59
- package/worker/src/testWorker.ts +0 -5
package/src/r2S3Storage.ts
CHANGED
|
@@ -9,10 +9,10 @@ import { Upload } from "@aws-sdk/lib-storage";
|
|
|
9
9
|
import {
|
|
10
10
|
createStorageKeyBuilder,
|
|
11
11
|
createStorageDownloadUrl,
|
|
12
|
-
|
|
12
|
+
createStorageAdapter,
|
|
13
13
|
createStorageUri,
|
|
14
14
|
parseStorageUri,
|
|
15
|
-
type
|
|
15
|
+
type StorageAdapterWith,
|
|
16
16
|
} from "@hot-updater/plugin-core";
|
|
17
17
|
|
|
18
18
|
export interface R2S3StorageConfig extends S3ClientConfig {
|
|
@@ -43,7 +43,7 @@ const isObjectNotFoundError = (error: unknown) => {
|
|
|
43
43
|
|
|
44
44
|
export const createR2S3Storage = (
|
|
45
45
|
config: R2S3StorageConfig,
|
|
46
|
-
):
|
|
46
|
+
): StorageAdapterWith<"put" | "get" | "exists" | "delete"> => {
|
|
47
47
|
const {
|
|
48
48
|
accountId,
|
|
49
49
|
basePath,
|
|
@@ -75,7 +75,7 @@ export const createR2S3Storage = (
|
|
|
75
75
|
return parsed;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
return
|
|
78
|
+
return createStorageAdapter({
|
|
79
79
|
name: "r2Storage",
|
|
80
80
|
protocol: "r2",
|
|
81
81
|
async put({ key, body, contentLength, contentType }) {
|
package/src/r2Storage.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StorageAdapterWith } from "@hot-updater/plugin-core";
|
|
2
2
|
|
|
3
3
|
import { createR2S3Storage, type R2S3StorageConfig } from "./r2S3Storage";
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ export type { R2S3StorageConfig };
|
|
|
7
7
|
|
|
8
8
|
export const r2Storage = (
|
|
9
9
|
config: R2S3StorageConfig,
|
|
10
|
-
):
|
|
10
|
+
): StorageAdapterWith<"put" | "get" | "exists" | "delete"> => {
|
|
11
11
|
if (!config.credentials) {
|
|
12
12
|
throw new Error(
|
|
13
13
|
"r2Storage requires S3-compatible credentials. The Wrangler fallback was removed.",
|
package/src/r2WorkerStorage.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createStorageKeyBuilder,
|
|
3
3
|
createStorageDownloadUrl,
|
|
4
|
-
|
|
4
|
+
createStorageAdapter,
|
|
5
5
|
createStorageUri,
|
|
6
6
|
parseStorageUri,
|
|
7
|
-
type
|
|
7
|
+
type StorageAdapterWith,
|
|
8
8
|
} from "@hot-updater/plugin-core";
|
|
9
9
|
|
|
10
10
|
export interface CloudflareWorkerStorageConfig {
|
|
@@ -16,7 +16,7 @@ export interface CloudflareWorkerStorageConfig {
|
|
|
16
16
|
|
|
17
17
|
export const r2WorkerStorage = (
|
|
18
18
|
config: CloudflareWorkerStorageConfig,
|
|
19
|
-
):
|
|
19
|
+
): StorageAdapterWith<
|
|
20
20
|
"put" | "get" | "getDownloadUrl" | "exists" | "delete"
|
|
21
21
|
> => {
|
|
22
22
|
const getStorageKey = createStorageKeyBuilder(config.basePath);
|
|
@@ -32,7 +32,7 @@ export const r2WorkerStorage = (
|
|
|
32
32
|
return parsed;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
return
|
|
35
|
+
return createStorageAdapter({
|
|
36
36
|
name: "r2Storage",
|
|
37
37
|
protocol: "r2",
|
|
38
38
|
async put({ key, body, contentLength, contentType }) {
|
package/src/worker/d1Database.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createDatabasePluginAdapter } from "@hot-updater/plugin-core/internal";
|
|
1
|
+
import type { EngineDatabase } from "@hot-updater/plugin-core";
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import {
|
|
4
|
+
createD1Database,
|
|
5
|
+
D1ExecutionError,
|
|
6
|
+
type D1ResultLike,
|
|
7
|
+
toSqlResult,
|
|
8
|
+
} from "../d1Executor";
|
|
9
9
|
|
|
10
10
|
type D1BoundStatement = {
|
|
11
|
-
all: () => Promise<
|
|
11
|
+
all: () => Promise<D1ResultLike>;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
type D1PreparedStatement = {
|
|
@@ -17,36 +17,30 @@ type D1PreparedStatement = {
|
|
|
17
17
|
|
|
18
18
|
export type D1Like = {
|
|
19
19
|
prepare(sql: string): D1PreparedStatement;
|
|
20
|
-
batch(statements: D1BoundStatement[]): Promise<readonly
|
|
20
|
+
batch(statements: D1BoundStatement[]): Promise<readonly D1ResultLike[]>;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export interface CloudflareWorkerDatabaseEnv {
|
|
24
24
|
readonly DB: D1Like;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
/** Hot Updater's database on a D1 binding, inside a Worker. */
|
|
28
|
+
export const d1Database = (database: D1Like): EngineDatabase =>
|
|
29
|
+
createD1Database({
|
|
30
|
+
query: async ({ sql, params }) =>
|
|
31
|
+
toSqlResult(
|
|
32
|
+
await database
|
|
33
|
+
.prepare(sql)
|
|
34
|
+
.bind(...params)
|
|
35
|
+
.all(),
|
|
36
|
+
),
|
|
36
37
|
async batch(statements) {
|
|
37
38
|
const results = await database.batch(
|
|
38
39
|
statements.map(({ sql, params }) =>
|
|
39
40
|
database.prepare(sql).bind(...params),
|
|
40
41
|
),
|
|
41
42
|
);
|
|
42
|
-
|
|
43
|
+
if (results.length !== statements.length) throw new D1ExecutionError();
|
|
44
|
+
return results.map(toSqlResult);
|
|
43
45
|
},
|
|
44
46
|
});
|
|
45
|
-
const adapter = createDatabasePluginAdapter("d1Database", implementation);
|
|
46
|
-
return createDatabasePlugin({
|
|
47
|
-
name: "d1Database",
|
|
48
|
-
models: adapter.models,
|
|
49
|
-
commit: adapter.commit,
|
|
50
|
-
...(adapter.dispose ? { dispose: adapter.dispose } : {}),
|
|
51
|
-
});
|
|
52
|
-
};
|
package/src/worker/index.ts
CHANGED
package/worker/dist/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
This folder contains the built output assets for the worker "hot-updater" generated at 2026-
|
|
1
|
+
This folder contains the built output assets for the worker "hot-updater" generated at 2026-10-02T03:30:33.543Z.
|