@hot-updater/cloudflare 1.0.0-rc.5 → 1.0.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.cjs +90 -924
- package/dist/index.d.cts +16 -6
- package/dist/index.d.mts +16 -6
- package/dist/index.mjs +91 -926
- package/dist/init/index.cjs +11777 -0
- package/dist/init/index.d.cts +5 -1
- package/dist/init/index.d.mts +5 -1
- package/dist/init/index.mjs +11771 -1
- package/dist/worker/index.cjs +117 -916
- package/dist/worker/index.d.cts +45 -11
- package/dist/worker/index.d.mts +45 -11
- package/dist/worker/index.mjs +118 -917
- package/package.json +9 -14
- package/sql/bundles.sql +121 -212
- package/src/d1Database.ts +58 -43
- package/src/d1Executor.ts +84 -0
- package/src/d1Schema.ts +26 -0
- package/src/presignR2Url.ts +103 -0
- package/src/r2S3Storage.ts +20 -19
- package/src/r2Storage.ts +5 -3
- package/src/r2WorkerStorage.ts +55 -17
- package/src/worker/d1Database.ts +21 -39
- package/worker/dist/README.md +1 -1
- package/worker/dist/index.js +9859 -5696
- package/worker/dist/index.js.map +4 -4
- package/worker/migrations/0001_hot-updater_1.0.0.sql +121 -222
- package/worker/src/index.ts +15 -9
- package/worker/wrangler.json +1 -0
- package/dist/iac/index.cjs +0 -12687
- package/dist/iac/index.d.cts +0 -5
- package/dist/iac/index.d.mts +0 -5
- package/dist/iac/index.mjs +0 -12679
- package/src/d1Database.spec.ts +0 -277
- package/src/d1Implementation.spec.ts +0 -342
- package/src/d1Implementation.ts +0 -781
- package/src/d1Query.spec.ts +0 -46
- package/src/d1Query.ts +0 -92
- package/src/d1Rows.spec.ts +0 -143
- package/src/d1Rows.ts +0 -357
- 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 -69
- package/worker/src/databaseMigration.integration.spec.ts +0 -191
- package/worker/src/databasePlugins.integration.spec.ts +0 -326
- package/worker/src/index.integration.spec.ts +0 -190
- package/worker/src/insightsMovement.integration.spec.ts +0 -73
- package/worker/src/storagePlugin.integration.spec.ts +0 -59
- package/worker/src/testWorker.ts +0 -5
package/dist/worker/index.d.cts
CHANGED
|
@@ -1,28 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/
|
|
3
|
-
|
|
1
|
+
import { EngineDatabase, StorageAdapterWith } from "@hot-updater/plugin-core";
|
|
2
|
+
//#region src/d1Executor.d.ts
|
|
3
|
+
/** A D1 result, from the binding or the REST API. */
|
|
4
|
+
interface D1ResultLike {
|
|
4
5
|
readonly results?: readonly unknown[];
|
|
5
6
|
readonly success?: boolean;
|
|
6
|
-
|
|
7
|
+
readonly meta?: {
|
|
8
|
+
readonly changes?: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/worker/d1Database.d.ts
|
|
7
13
|
type D1BoundStatement = {
|
|
8
|
-
all: () => Promise<
|
|
14
|
+
all: () => Promise<D1ResultLike>;
|
|
9
15
|
};
|
|
10
16
|
type D1PreparedStatement = {
|
|
11
17
|
bind: (...values: readonly unknown[]) => D1BoundStatement;
|
|
12
18
|
};
|
|
13
19
|
type D1Like = {
|
|
14
20
|
prepare(sql: string): D1PreparedStatement;
|
|
15
|
-
batch(statements: D1BoundStatement[]): Promise<readonly
|
|
21
|
+
batch(statements: D1BoundStatement[]): Promise<readonly D1ResultLike[]>;
|
|
16
22
|
};
|
|
17
|
-
|
|
23
|
+
/** Hot Updater's database on a D1 binding, inside a Worker. */
|
|
24
|
+
declare const d1Database: (database: D1Like) => EngineDatabase;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/presignR2Url.d.ts
|
|
27
|
+
/** R2's S3-compatible credentials. */
|
|
28
|
+
interface R2Credentials {
|
|
29
|
+
readonly accessKeyId: string;
|
|
30
|
+
readonly secretAccessKey: string;
|
|
31
|
+
}
|
|
18
32
|
//#endregion
|
|
19
33
|
//#region src/r2WorkerStorage.d.ts
|
|
20
|
-
|
|
34
|
+
type CloudflareWorkerStorageConfig = {
|
|
21
35
|
readonly bucket: R2Bucket;
|
|
22
36
|
readonly bucketName: string;
|
|
23
37
|
readonly basePath?: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
} & ({
|
|
39
|
+
/** The account whose R2 endpoint download URLs name. */
|
|
40
|
+
readonly accountId: string;
|
|
41
|
+
/**
|
|
42
|
+
* R2's S3-compatible credentials, which presign download URLs, as
|
|
43
|
+
* `r2Storage` from `@hot-updater/cloudflare` does: what a server needs
|
|
44
|
+
* to serve downloads.
|
|
45
|
+
*/
|
|
46
|
+
readonly credentials: R2Credentials;
|
|
47
|
+
} | {
|
|
48
|
+
readonly accountId?: undefined;
|
|
49
|
+
readonly credentials?: undefined;
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Storage on the Worker's R2 binding. With R2's S3-compatible credentials,
|
|
53
|
+
* its download URLs are presigned and devices download from the bucket;
|
|
54
|
+
* without them, it has no `getDownloadUrl`, as a Console that only reads
|
|
55
|
+
* needs.
|
|
56
|
+
*/
|
|
57
|
+
declare function r2WorkerStorage(config: CloudflareWorkerStorageConfig & {
|
|
58
|
+
readonly credentials: R2Credentials;
|
|
59
|
+
}): StorageAdapterWith<"put" | "get" | "getDownloadUrl" | "exists" | "delete">;
|
|
60
|
+
declare function r2WorkerStorage(config: CloudflareWorkerStorageConfig): StorageAdapterWith<"put" | "get" | "exists" | "delete">;
|
|
27
61
|
//#endregion
|
|
28
62
|
export { type CloudflareWorkerStorageConfig, type D1Like, d1Database, r2WorkerStorage as r2Storage };
|
package/dist/worker/index.d.mts
CHANGED
|
@@ -1,28 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/
|
|
3
|
-
|
|
1
|
+
import { EngineDatabase, StorageAdapterWith } from "@hot-updater/plugin-core";
|
|
2
|
+
//#region src/d1Executor.d.ts
|
|
3
|
+
/** A D1 result, from the binding or the REST API. */
|
|
4
|
+
interface D1ResultLike {
|
|
4
5
|
readonly results?: readonly unknown[];
|
|
5
6
|
readonly success?: boolean;
|
|
6
|
-
|
|
7
|
+
readonly meta?: {
|
|
8
|
+
readonly changes?: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/worker/d1Database.d.ts
|
|
7
13
|
type D1BoundStatement = {
|
|
8
|
-
all: () => Promise<
|
|
14
|
+
all: () => Promise<D1ResultLike>;
|
|
9
15
|
};
|
|
10
16
|
type D1PreparedStatement = {
|
|
11
17
|
bind: (...values: readonly unknown[]) => D1BoundStatement;
|
|
12
18
|
};
|
|
13
19
|
type D1Like = {
|
|
14
20
|
prepare(sql: string): D1PreparedStatement;
|
|
15
|
-
batch(statements: D1BoundStatement[]): Promise<readonly
|
|
21
|
+
batch(statements: D1BoundStatement[]): Promise<readonly D1ResultLike[]>;
|
|
16
22
|
};
|
|
17
|
-
|
|
23
|
+
/** Hot Updater's database on a D1 binding, inside a Worker. */
|
|
24
|
+
declare const d1Database: (database: D1Like) => EngineDatabase;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/presignR2Url.d.ts
|
|
27
|
+
/** R2's S3-compatible credentials. */
|
|
28
|
+
interface R2Credentials {
|
|
29
|
+
readonly accessKeyId: string;
|
|
30
|
+
readonly secretAccessKey: string;
|
|
31
|
+
}
|
|
18
32
|
//#endregion
|
|
19
33
|
//#region src/r2WorkerStorage.d.ts
|
|
20
|
-
|
|
34
|
+
type CloudflareWorkerStorageConfig = {
|
|
21
35
|
readonly bucket: R2Bucket;
|
|
22
36
|
readonly bucketName: string;
|
|
23
37
|
readonly basePath?: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
} & ({
|
|
39
|
+
/** The account whose R2 endpoint download URLs name. */
|
|
40
|
+
readonly accountId: string;
|
|
41
|
+
/**
|
|
42
|
+
* R2's S3-compatible credentials, which presign download URLs, as
|
|
43
|
+
* `r2Storage` from `@hot-updater/cloudflare` does: what a server needs
|
|
44
|
+
* to serve downloads.
|
|
45
|
+
*/
|
|
46
|
+
readonly credentials: R2Credentials;
|
|
47
|
+
} | {
|
|
48
|
+
readonly accountId?: undefined;
|
|
49
|
+
readonly credentials?: undefined;
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Storage on the Worker's R2 binding. With R2's S3-compatible credentials,
|
|
53
|
+
* its download URLs are presigned and devices download from the bucket;
|
|
54
|
+
* without them, it has no `getDownloadUrl`, as a Console that only reads
|
|
55
|
+
* needs.
|
|
56
|
+
*/
|
|
57
|
+
declare function r2WorkerStorage(config: CloudflareWorkerStorageConfig & {
|
|
58
|
+
readonly credentials: R2Credentials;
|
|
59
|
+
}): StorageAdapterWith<"put" | "get" | "getDownloadUrl" | "exists" | "delete">;
|
|
60
|
+
declare function r2WorkerStorage(config: CloudflareWorkerStorageConfig): StorageAdapterWith<"put" | "get" | "exists" | "delete">;
|
|
27
61
|
//#endregion
|
|
28
62
|
export { type CloudflareWorkerStorageConfig, type D1Like, d1Database, r2WorkerStorage as r2Storage };
|