@hot-updater/cloudflare 1.0.0-rc.5 → 1.0.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.
Files changed (51) hide show
  1. package/dist/index.cjs +90 -924
  2. package/dist/index.d.cts +16 -6
  3. package/dist/index.d.mts +16 -6
  4. package/dist/index.mjs +91 -926
  5. package/dist/init/index.cjs +11777 -0
  6. package/dist/init/index.d.cts +5 -1
  7. package/dist/init/index.d.mts +5 -1
  8. package/dist/init/index.mjs +11771 -1
  9. package/dist/worker/index.cjs +117 -916
  10. package/dist/worker/index.d.cts +45 -11
  11. package/dist/worker/index.d.mts +45 -11
  12. package/dist/worker/index.mjs +118 -917
  13. package/package.json +9 -14
  14. package/sql/bundles.sql +121 -212
  15. package/src/d1Database.ts +58 -43
  16. package/src/d1Executor.ts +84 -0
  17. package/src/d1Schema.ts +26 -0
  18. package/src/presignR2Url.ts +103 -0
  19. package/src/r2S3Storage.ts +20 -19
  20. package/src/r2Storage.ts +5 -3
  21. package/src/r2WorkerStorage.ts +55 -17
  22. package/src/worker/d1Database.ts +21 -39
  23. package/worker/dist/README.md +1 -1
  24. package/worker/dist/index.js +9859 -5696
  25. package/worker/dist/index.js.map +4 -4
  26. package/worker/migrations/0001_hot-updater_1.0.0.sql +121 -222
  27. package/worker/src/index.ts +15 -9
  28. package/worker/wrangler.json +1 -0
  29. package/dist/iac/index.cjs +0 -12687
  30. package/dist/iac/index.d.cts +0 -5
  31. package/dist/iac/index.d.mts +0 -5
  32. package/dist/iac/index.mjs +0 -12679
  33. package/src/d1Database.spec.ts +0 -277
  34. package/src/d1Implementation.spec.ts +0 -342
  35. package/src/d1Implementation.ts +0 -781
  36. package/src/d1Query.spec.ts +0 -46
  37. package/src/d1Query.ts +0 -92
  38. package/src/d1Rows.spec.ts +0 -143
  39. package/src/d1Rows.ts +0 -357
  40. package/src/d1Sql.spec.ts +0 -30
  41. package/src/d1Sql.ts +0 -175
  42. package/src/r2Storage.spec.ts +0 -346
  43. package/src/r2WorkerStorage.spec.ts +0 -184
  44. package/src/utils/createWrangler.spec.ts +0 -75
  45. package/src/worker/d1Database.spec.ts +0 -69
  46. package/worker/src/databaseMigration.integration.spec.ts +0 -191
  47. package/worker/src/databasePlugins.integration.spec.ts +0 -326
  48. package/worker/src/index.integration.spec.ts +0 -190
  49. package/worker/src/insightsMovement.integration.spec.ts +0 -73
  50. package/worker/src/storagePlugin.integration.spec.ts +0 -59
  51. package/worker/src/testWorker.ts +0 -5
@@ -1,28 +1,62 @@
1
- import { StoragePluginWith } from "@hot-updater/plugin-core";
2
- //#region src/worker/d1Database.d.ts
3
- type D1Result = {
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<D1Result>;
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 D1Result[]>;
21
+ batch(statements: D1BoundStatement[]): Promise<readonly D1ResultLike[]>;
16
22
  };
17
- declare const d1Database: (database: D1Like) => import("@hot-updater/plugin-core").DatabasePlugin;
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
- interface CloudflareWorkerStorageConfig {
34
+ type CloudflareWorkerStorageConfig = {
21
35
  readonly bucket: R2Bucket;
22
36
  readonly bucketName: string;
23
37
  readonly basePath?: string;
24
- readonly downloadUrlSigningKey: string;
25
- }
26
- declare const r2WorkerStorage: (config: CloudflareWorkerStorageConfig) => StoragePluginWith<"put" | "get" | "getDownloadUrl" | "exists" | "delete">;
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 };
@@ -1,28 +1,62 @@
1
- import { StoragePluginWith } from "@hot-updater/plugin-core";
2
- //#region src/worker/d1Database.d.ts
3
- type D1Result = {
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<D1Result>;
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 D1Result[]>;
21
+ batch(statements: D1BoundStatement[]): Promise<readonly D1ResultLike[]>;
16
22
  };
17
- declare const d1Database: (database: D1Like) => import("@hot-updater/plugin-core").DatabasePlugin;
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
- interface CloudflareWorkerStorageConfig {
34
+ type CloudflareWorkerStorageConfig = {
21
35
  readonly bucket: R2Bucket;
22
36
  readonly bucketName: string;
23
37
  readonly basePath?: string;
24
- readonly downloadUrlSigningKey: string;
25
- }
26
- declare const r2WorkerStorage: (config: CloudflareWorkerStorageConfig) => StoragePluginWith<"put" | "get" | "getDownloadUrl" | "exists" | "delete">;
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 };