opacacms 0.2.1 → 0.3.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.
Files changed (185) hide show
  1. package/README.md +31 -22
  2. package/dist/admin/auth-client.d.ts +39 -39
  3. package/dist/admin/index.d.ts +2 -2
  4. package/dist/admin/index.js +15 -10520
  5. package/dist/admin/plugin-client.d.ts +65 -0
  6. package/dist/admin/react.d.ts +2 -2
  7. package/dist/admin/react.js +34 -4
  8. package/dist/admin/stores/ui.d.ts +19 -4
  9. package/dist/admin/ui/components/PluginSettingsForm.d.ts +2 -2
  10. package/dist/admin/ui/components/custom-alert.d.ts +7 -0
  11. package/dist/admin/ui/components/{DetailSheet.d.ts → detail-sheet.d.ts} +1 -2
  12. package/dist/admin/ui/components/fields/FieldLabel.d.ts +1 -1
  13. package/dist/admin/ui/components/fields/RelationshipField.d.ts +1 -1
  14. package/dist/admin/ui/components/media/AssetManagerModal.d.ts +2 -2
  15. package/dist/admin/ui/components/plugin-iframe.d.ts +7 -0
  16. package/dist/admin/ui/components/ui/accordion.d.ts +17 -7
  17. package/dist/admin/ui/components/ui/alert-dialog.d.ts +16 -12
  18. package/dist/admin/ui/components/ui/button.d.ts +11 -7
  19. package/dist/admin/ui/components/ui/relationship.d.ts +1 -1
  20. package/dist/admin/ui/components/ui/sheet.d.ts +14 -27
  21. package/dist/admin/ui/components/ui/tooltip.d.ts +7 -0
  22. package/dist/admin/ui/components/versions-sheet.d.ts +4 -5
  23. package/dist/admin/ui/views/collection-list-view.d.ts +1 -1
  24. package/dist/admin/ui/views/dashboard-view.d.ts +1 -1
  25. package/dist/admin/ui/views/media-registry-view.d.ts +3 -3
  26. package/dist/admin/ui/views/settings-view.d.ts +2 -2
  27. package/dist/admin/vue.js +27 -4
  28. package/dist/admin/webcomponent.js +66 -16
  29. package/dist/admin.css +1 -1
  30. package/dist/auth/index.d.ts +43 -43
  31. package/dist/{chunk-7y1nbmw6.js → chunk-1bd7fz7n.js} +32 -2
  32. package/dist/chunk-1qm0m8r8.js +413 -0
  33. package/dist/chunk-2k3ysje3.js +31 -0
  34. package/dist/{chunk-jdfw4v3r.js → chunk-3j9zjfmn.js} +95 -30
  35. package/dist/{chunk-byq8g0rd.js → chunk-48ywpd0a.js} +16 -22
  36. package/dist/{chunk-tfnaf41w.js → chunk-5422w4eq.js} +41 -25
  37. package/dist/chunk-56n342hs.js +95 -0
  38. package/dist/chunk-5b8r0v8c.js +47 -0
  39. package/dist/chunk-63yg00vx.js +263 -0
  40. package/dist/{chunk-8sqjbsgt.js → chunk-6bywt602.js} +26 -1
  41. package/dist/{chunk-v9z61v3g.js → chunk-6qs0g65f.js} +43 -3
  42. package/dist/chunk-7rr5p01g.js +581 -0
  43. package/dist/{chunk-2es275xs.js → chunk-941zxavt.js} +867 -322
  44. package/dist/{chunk-51z3x7kq.js → chunk-a3qae86h.js} +1 -1
  45. package/dist/{chunk-3rdhbedb.js → chunk-adq2b75c.js} +2 -2
  46. package/dist/chunk-d0tb1xjw.js +93 -0
  47. package/dist/chunk-d7cgd6vn.js +318 -0
  48. package/dist/{chunk-6d1vdfwa.js → chunk-e0g6gn7n.js} +54 -75
  49. package/dist/chunk-ec4jhybj.js +1137 -0
  50. package/dist/chunk-fatyf6f7.js +221 -0
  51. package/dist/{chunk-526a3gqx.js → chunk-fnsf1dfm.js} +1 -1
  52. package/dist/chunk-g9bxb6h0.js +205 -0
  53. package/dist/chunk-gyaf5kgf.js +10 -0
  54. package/dist/{chunk-9kxpbcb1.js → chunk-h6dhexzr.js} +16 -7
  55. package/dist/{chunk-dykn5hr6.js → chunk-j8js1y0h.js} +31 -74
  56. package/dist/{chunk-t0zg026p.js → chunk-jq1drsen.js} +12 -1
  57. package/dist/{chunk-b3kr8w41.js → chunk-m24yqkeq.js} +38 -26
  58. package/dist/chunk-m5ems3hh.js +410 -0
  59. package/dist/{chunk-8scgdznr.js → chunk-m83ybzf8.js} +15 -18
  60. package/dist/chunk-majsbncm.js +98 -0
  61. package/dist/chunk-mp2gt9yh.js +237 -0
  62. package/dist/chunk-n1twhqmf.js +54 -0
  63. package/dist/{chunk-bygjkgrx.js → chunk-naqcqj8n.js} +57 -80
  64. package/dist/chunk-q5sb5dcr.js +15 -0
  65. package/dist/{chunk-06ks4ggh.js → chunk-qhdsjek6.js} +49 -89
  66. package/dist/{chunk-n133qpsm.js → chunk-qsh2nqz3.js} +50 -81
  67. package/dist/chunk-r0ms5tk1.js +76 -0
  68. package/dist/chunk-rwqwsanx.js +75 -0
  69. package/dist/chunk-sqsfk9p4.js +700 -0
  70. package/dist/{chunk-5gvbp2qa.js → chunk-x7bnzswh.js} +25 -18
  71. package/dist/cli/commands/dev.d.ts +8 -0
  72. package/dist/cli/commands/doctor.d.ts +8 -0
  73. package/dist/cli/commands/generate.d.ts +26 -0
  74. package/dist/cli/commands/init.d.ts +13 -1
  75. package/dist/cli/commands/migrate.d.ts +33 -0
  76. package/dist/cli/commands/plugin.d.ts +13 -0
  77. package/dist/cli/commands/seed.d.ts +21 -0
  78. package/dist/cli/{commands/migrate-commands.d.ts → core/migrations/migrate-logic.d.ts} +2 -2
  79. package/dist/cli/core/migrations/schema-diff-engine.d.ts +12 -0
  80. package/dist/cli/core/migrations/schema-diff.d.ts +11 -0
  81. package/dist/cli/{seeding.d.ts → core/seeding/auto-seed.d.ts} +7 -4
  82. package/dist/cli/core/seeding/seed-logic.d.ts +2 -0
  83. package/dist/cli/index.d.ts +4 -0
  84. package/dist/cli/index.js +6 -170
  85. package/dist/client/RichText.d.ts +5 -0
  86. package/dist/client/rich-text-utils.d.ts +5 -0
  87. package/dist/client.js +3 -2
  88. package/dist/config.d.ts +3 -3
  89. package/dist/db/better-sqlite.d.ts +2 -3
  90. package/dist/db/better-sqlite.js +6 -5
  91. package/dist/db/bun-sqlite.d.ts +2 -3
  92. package/dist/db/bun-sqlite.js +6 -5
  93. package/dist/db/d1.d.ts +13 -7
  94. package/dist/db/d1.js +6 -5
  95. package/dist/db/index.d.ts +2 -2
  96. package/dist/db/index.js +10 -12
  97. package/dist/db/kysely/factory.d.ts +29 -0
  98. package/dist/db/kysely/plugins/audit-logging.d.ts +48 -0
  99. package/dist/db/kysely/plugins/auto-timestamps.d.ts +38 -0
  100. package/dist/db/kysely/plugins/cursor-pagination.d.ts +42 -0
  101. package/dist/db/kysely/plugins/deadlock-handler.d.ts +47 -0
  102. package/dist/db/kysely/plugins/draft-swapper.d.ts +33 -0
  103. package/dist/db/kysely/plugins/field-masking.d.ts +45 -0
  104. package/dist/db/kysely/plugins/fts-normalizer.d.ts +38 -0
  105. package/dist/db/kysely/plugins/i18n-fallback.d.ts +48 -0
  106. package/dist/db/kysely/plugins/id-generation.d.ts +42 -0
  107. package/dist/db/kysely/plugins/index.d.ts +16 -0
  108. package/dist/db/kysely/plugins/json-flattener.d.ts +38 -0
  109. package/dist/db/kysely/plugins/relationship-preloading.d.ts +39 -0
  110. package/dist/db/kysely/plugins/slug-generation.d.ts +37 -0
  111. package/dist/db/kysely/plugins/soft-delete.d.ts +42 -0
  112. package/dist/db/kysely/plugins/tree-resolver.d.ts +39 -0
  113. package/dist/db/kysely/plugins/virtual-field-resolver.d.ts +54 -0
  114. package/dist/db/kysely/plugins/zod-coercion.d.ts +34 -0
  115. package/dist/db/kysely/snapshot/snapshot-manager.d.ts +18 -0
  116. package/dist/db/postgres.d.ts +2 -2
  117. package/dist/db/postgres.js +6 -5
  118. package/dist/db/sqlite.d.ts +2 -3
  119. package/dist/db/sqlite.js +6 -5
  120. package/dist/index.d.ts +3 -0
  121. package/dist/index.js +161 -7
  122. package/dist/runtimes/bun.js +9 -6
  123. package/dist/runtimes/cloudflare-workers.d.ts +3 -1
  124. package/dist/runtimes/cloudflare-workers.js +36 -7
  125. package/dist/runtimes/next.js +8 -5
  126. package/dist/runtimes/node.js +9 -6
  127. package/dist/schema/collection.d.ts +116 -70
  128. package/dist/schema/compiler.d.ts +6 -0
  129. package/dist/schema/global.d.ts +38 -71
  130. package/dist/schema/index.d.ts +5 -4
  131. package/dist/schema/index.js +35 -550
  132. package/dist/schema/zod.d.ts +564 -0
  133. package/dist/server/admin-router.d.ts +1 -1
  134. package/dist/server/collection-router.d.ts +1 -1
  135. package/dist/server/graphql.d.ts +6 -0
  136. package/dist/server/handlers.d.ts +25 -7
  137. package/dist/server/middlewares/auth.d.ts +1 -1
  138. package/dist/server/plugins-loader.d.ts +1 -1
  139. package/dist/server/router.d.ts +2 -2
  140. package/dist/server/routers/admin.d.ts +1 -1
  141. package/dist/server/routers/auth.d.ts +1 -1
  142. package/dist/server/routers/collections.d.ts +4 -1
  143. package/dist/server/routers/plugins.d.ts +2 -2
  144. package/dist/server/setup-middlewares.d.ts +1 -1
  145. package/dist/server/system-router.d.ts +1 -1
  146. package/dist/server.js +11 -6
  147. package/dist/storage/adapters/cloudflare-r2.d.ts +11 -2
  148. package/dist/storage/index.js +5 -5
  149. package/dist/types.d.ts +253 -42
  150. package/dist/utils/context.d.ts +14 -0
  151. package/dist/utils/logger.d.ts +2 -0
  152. package/dist/utils/string.d.ts +10 -0
  153. package/dist/utils/webhooks-engine.d.ts +24 -0
  154. package/dist/validation.d.ts +67 -1
  155. package/dist/validator.d.ts +1 -0
  156. package/package.json +50 -11
  157. package/src/cli/index.ts +117 -0
  158. package/dist/chunk-6qq3ne6b.js +0 -288
  159. package/dist/chunk-6v1fw7q7.js +0 -126
  160. package/dist/chunk-7a9kn0np.js +0 -116
  161. package/dist/chunk-bexcv7xe.js +0 -36
  162. package/dist/chunk-d3ffeqp9.js +0 -87
  163. package/dist/chunk-fj19qccp.js +0 -78
  164. package/dist/chunk-g1jb60xd.js +0 -17
  165. package/dist/chunk-j53pz21t.js +0 -20
  166. package/dist/chunk-mkn49zmy.js +0 -102
  167. package/dist/chunk-r39em4yj.js +0 -29
  168. package/dist/chunk-rsf0tpy1.js +0 -8
  169. package/dist/chunk-srsac177.js +0 -85
  170. package/dist/chunk-twpvxfce.js +0 -64
  171. package/dist/chunk-ywm4t2gm.js +0 -19
  172. package/dist/cli/commands/plugin-sync.d.ts +0 -1
  173. package/dist/cli/commands/seed-command.d.ts +0 -2
  174. package/dist/plugins/ui-bridge.d.ts +0 -12
  175. package/dist/schema/fields/base.d.ts +0 -84
  176. package/dist/schema/fields/index.d.ts +0 -147
  177. package/dist/schema/infer.d.ts +0 -55
  178. /package/dist/admin/ui/components/{ColumnVisibilityToggle.d.ts → column-visibility-toggle.d.ts} +0 -0
  179. /package/dist/admin/ui/components/{DataDetailView.d.ts → data-detail-view.d.ts} +0 -0
  180. /package/dist/cli/{d1-mock.d.ts → core/mocks/d1-mock.d.ts} +0 -0
  181. /package/dist/cli/{r2-mock.d.ts → core/mocks/r2-mock.d.ts} +0 -0
  182. /package/dist/cli/{commands → core/plugins}/plugin-build.d.ts +0 -0
  183. /package/dist/cli/{commands → core/plugins}/plugin-init.d.ts +0 -0
  184. /package/dist/cli/{commands → core/types}/generate-types.d.ts +0 -0
  185. /package/dist/{schema/fields/validation.test.d.ts → cli/seeding.test.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
1
  import type { Context } from "hono";
2
- import type { Collection, Global, OpacaConfig } from "../types";
2
+ import type { Collection, Global, OpacaConfig, WebhookConfig } from "../types";
3
3
  /**
4
4
  * Hydrates a document with virtual fields and nested fields.
5
5
  * @param doc document to hydrate
@@ -20,12 +20,10 @@ export declare function parsePopulate(populate: string | any): Record<string, an
20
20
  export declare const populateDoc: (db: any, fields: any[], doc: any, populate: Record<string, any>, config: OpacaConfig) => Promise<any>;
21
21
  /**
22
22
  * Creates handlers for a collection
23
- * @param config opaca config
24
- * @param collection collection config
25
- * @param getAuth auth function
26
- * @returns collection handlers
23
+ * Creates a standard set of CRUD handlers for a given collection.
24
+ * These handlers manage database operations, access control, versioning, and webhooks.
27
25
  */
28
- export declare function createHandlers(config: OpacaConfig, collection: Collection, getAuth?: () => any): {
26
+ export declare function createHandlers(collection: Collection, config: OpacaConfig): {
29
27
  find(c: Context): Promise<(Response & import("hono").TypedResponse<{
30
28
  message: string;
31
29
  }, 403, "json">) | (Response & import("hono").TypedResponse<{
@@ -40,6 +38,8 @@ export declare function createHandlers(config: OpacaConfig, collection: Collecti
40
38
  hasNextPage: boolean;
41
39
  prevPage: number | null;
42
40
  nextPage: number | null;
41
+ nextCursor?: string | null | undefined;
42
+ prevCursor?: string | null | undefined;
43
43
  }, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
44
44
  findOne(c: Context): Promise<Response & import("hono").TypedResponse<any, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
45
45
  create(c: Context): Promise<(Response & import("hono").TypedResponse<{
@@ -60,7 +60,9 @@ export declare function createHandlers(config: OpacaConfig, collection: Collecti
60
60
  }, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
61
61
  findVersions(c: Context): Promise<(Response & import("hono").TypedResponse<{
62
62
  message: string;
63
- }, 403, "json">) | (Response & import("hono").TypedResponse<never, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
63
+ }, 403, "json">) | (Response & import("hono").TypedResponse<{
64
+ docs: any;
65
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
64
66
  message: string;
65
67
  error: any;
66
68
  }, 500, "json">)>;
@@ -73,6 +75,22 @@ export declare function createHandlers(config: OpacaConfig, collection: Collecti
73
75
  error: any;
74
76
  }, 500, "json">)>;
75
77
  };
78
+ /**
79
+ * Creates a handler for an incoming webhook configuration.
80
+ * Manages signature verification, payload mapping, and automatic record upserts.
81
+ */
82
+ export declare function createIncomingWebhookHandler(webhookConfig: Extract<WebhookConfig, {
83
+ type: "incoming";
84
+ }>, collection: Collection, config: OpacaConfig): (c: Context) => Promise<(Response & import("hono").TypedResponse<{
85
+ message: string;
86
+ }, 401, "json">) | (Response & import("hono").TypedResponse<{
87
+ success: true;
88
+ operation: "create" | "update";
89
+ id: any;
90
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
91
+ message: string;
92
+ error: any;
93
+ }, 500, "json">)>;
76
94
  /**
77
95
  * Creates handlers for global collections
78
96
  * @param config opaca config
@@ -1,6 +1,6 @@
1
- import type { Session, User } from "../../types";
2
1
  import type { MiddlewareHandler } from "hono";
3
2
  import type { Auth } from "../../auth";
3
+ import type { Session, User } from "../../types";
4
4
  export type AuthContextVariables = {
5
5
  user: User | null;
6
6
  session: Session | null;
@@ -1,6 +1,6 @@
1
1
  import type { OpacaConfig } from "@/types";
2
2
  /**
3
- * Loads all plugin settings from the `_opaca_plugin_settings` collection.
3
+ * Loads all plugin settings from the `_plugin_settings` collection.
4
4
  * Returns a Record where keys are plugin names and values are their configurations.
5
5
  */
6
6
  export declare function loadPluginSettings(config: OpacaConfig): Promise<Record<string, any>>;
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import type { OpacaConfig } from "../types";
3
2
  import { type ApiContextVariables } from "../server/setup-middlewares";
3
+ import type { OpacaConfig } from "../types";
4
4
  export type { ApiContextVariables } from "../server/setup-middlewares";
5
- export declare function createAPIRouter(config: OpacaConfig, settings?: Record<string, any>): Hono<{
5
+ export declare function createAPIRouter(config: OpacaConfig, settings?: Record<string, any>, env?: any): Hono<{
6
6
  Variables: ApiContextVariables;
7
7
  }>;
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
2
  import type { Auth } from "../../auth";
3
- import type { OpacaConfig } from "../../types";
4
3
  import type { ApiContextVariables } from "../../server/router";
4
+ import type { OpacaConfig } from "../../types";
5
5
  export declare function createAdminRouter(config: OpacaConfig, settings: Record<string, any>, state: {
6
6
  auth: Auth | undefined;
7
7
  }): Hono<{
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
2
  import type { Auth } from "../../auth";
3
- import type { OpacaConfig } from "../../types";
4
3
  import type { ApiContextVariables } from "../../server/router";
4
+ import type { OpacaConfig } from "../../types";
5
5
  export declare function createAuthRouter(config: OpacaConfig, state: {
6
6
  auth: Auth | undefined;
7
7
  }): Hono<{
@@ -1,12 +1,15 @@
1
1
  import { Hono } from "hono";
2
2
  import type { Auth } from "../../auth";
3
- import type { OpacaConfig } from "../../types";
4
3
  import type { ApiContextVariables } from "../../server/router";
4
+ import type { OpacaConfig } from "../../types";
5
5
  export declare function mountCollectionRoutes(router: Hono<{
6
6
  Variables: ApiContextVariables;
7
7
  }>, config: OpacaConfig, state: {
8
8
  auth: Auth | undefined;
9
9
  }): void;
10
+ export declare function mountIncomingWebhookRoutes(router: Hono<{
11
+ Variables: ApiContextVariables;
12
+ }>, config: OpacaConfig): void;
10
13
  export declare function mountGlobalRoutes(router: Hono<{
11
14
  Variables: ApiContextVariables;
12
15
  }>, config: OpacaConfig, state: {
@@ -11,8 +11,8 @@ import type { ApiContextVariables } from "../setup-middlewares";
11
11
  */
12
12
  export declare function mountPluginRoutes(config: OpacaConfig, settings: Record<string, any>, logger: typeof import("../../utils/logger").logger, router: Hono<{
13
13
  Variables: ApiContextVariables;
14
- }>): void;
14
+ }>, env?: any): void;
15
15
  /**
16
16
  * Fires the onInitComplete hook for all plugins.
17
17
  */
18
- export declare function firePluginInitComplete(config: OpacaConfig, settings: Record<string, any>, logger: typeof import("../../utils/logger").logger): void;
18
+ export declare function firePluginInitComplete(config: OpacaConfig, settings: Record<string, any>, logger: typeof import("../../utils/logger").logger, env?: any): void;
@@ -1,8 +1,8 @@
1
1
  import type { Hono } from "hono";
2
2
  import type { Auth } from "../auth";
3
- import type { OpacaConfig } from "../types";
4
3
  import { type AuthContextVariables } from "../server/middlewares/auth";
5
4
  import { type OpacaContextVariables } from "../server/middlewares/context";
5
+ import type { OpacaConfig } from "../types";
6
6
  export type ApiContextVariables = OpacaContextVariables & AuthContextVariables;
7
7
  export declare function setupMiddlewares(router: Hono<{
8
8
  Variables: ApiContextVariables;
@@ -1,6 +1,6 @@
1
1
  import { Hono } from "hono";
2
- import type { OpacaConfig } from "../types";
3
2
  import type { ApiContextVariables } from "../server/router";
3
+ import type { OpacaConfig } from "../types";
4
4
  export declare function createSystemRouter(config: OpacaConfig): Hono<{
5
5
  Variables: ApiContextVariables;
6
6
  }, import("hono/types").BlankSchema, "/">;
package/dist/server.js CHANGED
@@ -3,26 +3,31 @@ import {
3
3
  createAdminHandlers,
4
4
  createGlobalHandlers,
5
5
  createHandlers,
6
+ createIncomingWebhookHandler,
6
7
  hydrateDoc,
7
8
  parsePopulate,
8
9
  populateDoc
9
- } from "./chunk-2es275xs.js";
10
+ } from "./chunk-941zxavt.js";
10
11
  import {
11
12
  defineConfig
12
- } from "./chunk-7y1nbmw6.js";
13
- import"./chunk-b3kr8w41.js";
13
+ } from "./chunk-1bd7fz7n.js";
14
+ import"./chunk-m24yqkeq.js";
15
+ import"./chunk-5b8r0v8c.js";
16
+ import"./chunk-m5ems3hh.js";
14
17
  import {
15
18
  BaseDatabaseAdapter
16
19
  } from "./chunk-s8mqwnm1.js";
20
+ import"./chunk-q5sb5dcr.js";
17
21
  import"./chunk-qxt9vge8.js";
18
- import"./chunk-v9z61v3g.js";
19
- import"./chunk-t0zg026p.js";
20
- import"./chunk-8sqjbsgt.js";
22
+ import"./chunk-jq1drsen.js";
23
+ import"./chunk-6qs0g65f.js";
24
+ import"./chunk-6bywt602.js";
21
25
  export {
22
26
  populateDoc,
23
27
  parsePopulate,
24
28
  hydrateDoc,
25
29
  defineConfig,
30
+ createIncomingWebhookHandler,
26
31
  createHandlers,
27
32
  createGlobalHandlers,
28
33
  createAdminHandlers,
@@ -1,6 +1,15 @@
1
- import type { R2Bucket } from "@cloudflare/workers-types";
2
1
  import type { StorageAdapter, StorageAdapterConfig } from "../types";
2
+ /**
3
+ * A compatible interface for R2Bucket that avoids version mismatches
4
+ * between different @cloudflare/workers-types versions.
5
+ */
6
+ export interface OpacaR2Bucket {
7
+ put(key: string, value: any, options?: any): Promise<any>;
8
+ get(key: string, options?: any): Promise<any>;
9
+ delete(key: string): Promise<any>;
10
+ head(key: string): Promise<any>;
11
+ }
3
12
  export interface R2AdapterConfig extends StorageAdapterConfig {
4
- bucketBinding: R2Bucket;
13
+ bucketBinding: OpacaR2Bucket;
5
14
  }
6
15
  export declare function createR2Storage(config: R2AdapterConfig): StorageAdapter;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __require
3
- } from "../chunk-8sqjbsgt.js";
3
+ } from "../chunk-6bywt602.js";
4
4
 
5
5
  // src/storage/errors.ts
6
6
  class StorageError extends Error {
@@ -146,8 +146,8 @@ function createLocalAdapter(config) {
146
146
  if (!fullPath.startsWith(path.resolve(config.uploadDir))) {
147
147
  throw new StorageError("local", "upload", "Path traversal attempt detected.");
148
148
  }
149
- if (file.buffer && typeof Bun !== "undefined") {
150
- await Bun.write(fullPath, file.buffer);
149
+ if (file.buffer && typeof globalThis.Bun !== "undefined") {
150
+ await globalThis.Bun.write(fullPath, file.buffer);
151
151
  } else if (file.buffer) {
152
152
  await fs.writeFile(fullPath, file.buffer);
153
153
  } else if (file.stream) {
@@ -201,8 +201,8 @@ function createLocalAdapter(config) {
201
201
  },
202
202
  async download(filename) {
203
203
  const fullPath = getFullPath(path.basename(filename));
204
- if (typeof Bun !== "undefined") {
205
- return Bun.file(fullPath).stream();
204
+ if (typeof globalThis.Bun !== "undefined") {
205
+ return globalThis.Bun.file(fullPath).stream();
206
206
  }
207
207
  const nodeStream = __require("node:fs").createReadStream(fullPath);
208
208
  return new ReadableStream({