@dimah-s3/db 1.7.1 → 2.0.0-beta.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 (120) hide show
  1. package/README.md +62 -17
  2. package/dist/adapters/drizzle.d.ts +8 -0
  3. package/dist/adapters/drizzle.d.ts.map +1 -0
  4. package/dist/adapters/drizzle.js +3 -0
  5. package/dist/adapters/drizzle.js.map +1 -0
  6. package/dist/adapters/kysely.d.ts +7 -0
  7. package/dist/adapters/kysely.d.ts.map +1 -0
  8. package/dist/adapters/kysely.js +3 -0
  9. package/dist/adapters/kysely.js.map +1 -0
  10. package/dist/adapters/prisma.d.ts +7 -0
  11. package/dist/adapters/prisma.d.ts.map +1 -0
  12. package/dist/adapters/prisma.js +3 -0
  13. package/dist/adapters/prisma.js.map +1 -0
  14. package/dist/cli.d.ts +32 -4
  15. package/dist/cli.d.ts.map +1 -1
  16. package/dist/cli.js +135 -4
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client/db-client.d.ts +9 -85
  19. package/dist/client/db-client.d.ts.map +1 -1
  20. package/dist/client/db-object-source.d.ts +25 -0
  21. package/dist/client/db-object-source.d.ts.map +1 -0
  22. package/dist/client/index.d.ts +3 -3
  23. package/dist/client/index.d.ts.map +1 -1
  24. package/dist/client/index.js +96 -42
  25. package/dist/client/index.js.map +1 -1
  26. package/dist/drizzle/mysql.d.ts +1025 -0
  27. package/dist/drizzle/mysql.d.ts.map +1 -0
  28. package/dist/drizzle/mysql.js +117 -0
  29. package/dist/drizzle/mysql.js.map +1 -0
  30. package/dist/drizzle/pg.d.ts +964 -0
  31. package/dist/drizzle/pg.d.ts.map +1 -0
  32. package/dist/drizzle/pg.js +98 -0
  33. package/dist/drizzle/pg.js.map +1 -0
  34. package/dist/drizzle/shared.d.ts +7 -0
  35. package/dist/drizzle/shared.d.ts.map +1 -0
  36. package/dist/drizzle/sqlite.d.ts +1024 -0
  37. package/dist/drizzle/sqlite.d.ts.map +1 -0
  38. package/dist/drizzle/sqlite.js +101 -0
  39. package/dist/drizzle/sqlite.js.map +1 -0
  40. package/dist/folder-path.d.ts +32 -0
  41. package/dist/folder-path.d.ts.map +1 -0
  42. package/dist/fuma-db.d.ts +30 -9
  43. package/dist/fuma-db.d.ts.map +1 -1
  44. package/dist/index.d.ts +9 -13
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +1419 -623
  47. package/dist/index.js.map +1 -1
  48. package/dist/plugin/create-database-endpoints.d.ts +105 -21
  49. package/dist/plugin/create-database-endpoints.d.ts.map +1 -1
  50. package/dist/plugin/create-database-lifecycle-hooks.d.ts +37 -19
  51. package/dist/plugin/create-database-lifecycle-hooks.d.ts.map +1 -1
  52. package/dist/plugin/db.d.ts +29 -118
  53. package/dist/plugin/db.d.ts.map +1 -1
  54. package/dist/plugin/object-access.d.ts +46 -0
  55. package/dist/plugin/object-access.d.ts.map +1 -0
  56. package/dist/plugin/public-stores.d.ts +33 -0
  57. package/dist/plugin/public-stores.d.ts.map +1 -0
  58. package/dist/plugin/purge.d.ts +49 -0
  59. package/dist/plugin/purge.d.ts.map +1 -0
  60. package/dist/plugin/quota.d.ts +25 -0
  61. package/dist/plugin/quota.d.ts.map +1 -0
  62. package/dist/plugin/schemas.d.ts +69 -0
  63. package/dist/plugin/schemas.d.ts.map +1 -0
  64. package/dist/plugin/scope.d.ts +31 -0
  65. package/dist/plugin/scope.d.ts.map +1 -0
  66. package/dist/plugin/to-db-client-object.d.ts +8 -4
  67. package/dist/plugin/to-db-client-object.d.ts.map +1 -1
  68. package/dist/schema/schema.d.ts +73 -0
  69. package/dist/schema/schema.d.ts.map +1 -0
  70. package/dist/standard-schema.d.ts +42 -0
  71. package/dist/standard-schema.d.ts.map +1 -0
  72. package/dist/store/create-db-store.d.ts +17 -0
  73. package/dist/store/create-db-store.d.ts.map +1 -0
  74. package/dist/store/folder-store.d.ts +36 -0
  75. package/dist/store/folder-store.d.ts.map +1 -0
  76. package/dist/store/list-cursor.d.ts +26 -4
  77. package/dist/store/list-cursor.d.ts.map +1 -1
  78. package/dist/store/map-row.d.ts +17 -8
  79. package/dist/store/map-row.d.ts.map +1 -1
  80. package/dist/store/object-store.d.ts +208 -0
  81. package/dist/store/object-store.d.ts.map +1 -0
  82. package/dist/store/schema-version.d.ts +7 -0
  83. package/dist/store/schema-version.d.ts.map +1 -0
  84. package/dist/types/client.d.ts +209 -0
  85. package/dist/types/client.d.ts.map +1 -0
  86. package/dist/types/plugin.d.ts +112 -0
  87. package/dist/types/plugin.d.ts.map +1 -0
  88. package/dist/types/storage-object.d.ts +40 -85
  89. package/dist/types/storage-object.d.ts.map +1 -1
  90. package/package.json +53 -11
  91. package/prisma/dimah-s3.prisma +80 -0
  92. package/sql/mysql.sql +59 -0
  93. package/sql/pg.sql +53 -0
  94. package/sql/sqlite.sql +54 -0
  95. package/src/drizzle/mysql.ts +172 -0
  96. package/src/drizzle/pg.ts +140 -0
  97. package/src/drizzle/sqlite.ts +144 -0
  98. package/dist/client/db-object-list-accessors.d.ts +0 -36
  99. package/dist/client/db-object-list-accessors.d.ts.map +0 -1
  100. package/dist/client/db-object-query.d.ts +0 -40
  101. package/dist/client/db-object-query.d.ts.map +0 -1
  102. package/dist/errors.d.ts +0 -6
  103. package/dist/errors.d.ts.map +0 -1
  104. package/dist/hooks/create-object-access-guard.d.ts +0 -51
  105. package/dist/hooks/create-object-access-guard.d.ts.map +0 -1
  106. package/dist/hooks/create-quota-guard.d.ts +0 -28
  107. package/dist/hooks/create-quota-guard.d.ts.map +0 -1
  108. package/dist/jobs/purge-stale-pending.d.ts +0 -31
  109. package/dist/jobs/purge-stale-pending.d.ts.map +0 -1
  110. package/dist/plugin/list-query-schema.d.ts +0 -21
  111. package/dist/plugin/list-query-schema.d.ts.map +0 -1
  112. package/dist/plugin/memoize-scope-resolver.d.ts +0 -8
  113. package/dist/plugin/memoize-scope-resolver.d.ts.map +0 -1
  114. package/dist/schema/v1.d.ts +0 -31
  115. package/dist/schema/v1.d.ts.map +0 -1
  116. package/dist/store/storage-object-store.d.ts +0 -137
  117. package/dist/store/storage-object-store.d.ts.map +0 -1
  118. package/src/schema/examples/README.md +0 -10
  119. package/src/schema/examples/drizzle.ts +0 -92
  120. package/src/schema/examples/schema.prisma +0 -55
@@ -0,0 +1,7 @@
1
+ import { type DimahS3DbClient } from "../fuma-db.js";
2
+ /**
3
+ * Throws unless the database is at the schema the stores use
4
+ * ({@link DB_SCHEMA_VERSION}).
5
+ */
6
+ export declare function checkSchemaVersion(client: DimahS3DbClient): Promise<void>;
7
+ //# sourceMappingURL=schema-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-version.d.ts","sourceRoot":"","sources":["../../src/store/schema-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEpE;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,IAAI,CAAC,CAoBf"}
@@ -0,0 +1,209 @@
1
+ import type { S3RequestOptions, S3RouteName } from "@dimah-s3/core";
2
+ import type { StorageObjectStatus } from "./storage-object";
3
+ /** A row status the browser can see. Rows that purge has claimed stay internal. */
4
+ export type DbClientObjectStatus = Exclude<StorageObjectStatus, "purging">;
5
+ /**
6
+ * Browser-facing object row. Narrower than `StorageObject`: no scope,
7
+ * S3 metadata, or upload state. `attributes` are the plugin's
8
+ * `attributes.toClient` output.
9
+ */
10
+ export type DbClientObject<TClientAttributes = never> = {
11
+ id: string;
12
+ bucket: string;
13
+ key: string;
14
+ route: string;
15
+ /** Logical folder path. `null` is the root. */
16
+ folder: string | null;
17
+ filename: string;
18
+ contentType: string | null;
19
+ /** Verified size. `null` while the object is pending. */
20
+ size: number | null;
21
+ declaredSize: number | null;
22
+ status: DbClientObjectStatus;
23
+ attributes: TClientAttributes | null;
24
+ /** ISO 8601 timestamp. */
25
+ createdAt: string;
26
+ /** ISO 8601 timestamp. */
27
+ updatedAt: string;
28
+ };
29
+ /** Browser-facing folder row. */
30
+ export type DbClientFolder = {
31
+ path: string;
32
+ name: string;
33
+ /** Path of the containing folder. `null` is the root. */
34
+ parent: string | null;
35
+ /** ISO 8601 timestamp. */
36
+ createdAt: string;
37
+ };
38
+ /** Column a listing can be ordered by. */
39
+ export type DbListSortField = "createdAt" | "updatedAt" | "size" | "filename";
40
+ /**
41
+ * Listing order. Ties break on row `id` in the same direction. Rows with no
42
+ * value for the field (a pending row's `size`) come last in both directions.
43
+ */
44
+ export type DbListSort = {
45
+ field: DbListSortField;
46
+ direction: "asc" | "desc";
47
+ };
48
+ /** Bytes and file count of a scope. Expired pending rows are not counted. */
49
+ export type DbUsage = {
50
+ totalBytes: number;
51
+ objectCount: number;
52
+ };
53
+ /** Caps for one scope. Omit a field for no cap. */
54
+ export type DbQuota = {
55
+ maxBytes?: number;
56
+ maxFiles?: number;
57
+ };
58
+ /**
59
+ * Query for `GET /db/objects`. The scope is not an input: the server
60
+ * resolves it from the request.
61
+ */
62
+ export type DbClientListInput = {
63
+ /**
64
+ * Folder to list. `null` (or `""`) is the root. Omit for a flat list of
65
+ * every folder.
66
+ */
67
+ folder?: string | null;
68
+ route?: S3RouteName;
69
+ /** @default "active" */
70
+ status?: DbClientObjectStatus;
71
+ /** Exact type, or `type/*` for every subtype (`image/*`). */
72
+ contentType?: string;
73
+ /**
74
+ * Text the `filename` contains. The database decides case: PostgreSQL
75
+ * matches it exactly, SQLite ignores ASCII case, and MySQL follows the
76
+ * column collation.
77
+ */
78
+ search?: string;
79
+ /** @default { field: "createdAt", direction: "desc" } */
80
+ sort?: DbListSort;
81
+ /** Rows per page, 1 to 100. @default 50 */
82
+ limit?: number;
83
+ /**
84
+ * `nextCursor` from the previous page. A cursor from other filters is
85
+ * ignored, and the list starts again at the first page.
86
+ */
87
+ cursor?: string;
88
+ };
89
+ /** One page of `GET /db/objects`. */
90
+ export type DbClientListResponse<TClientAttributes = never> = {
91
+ objects: DbClientObject<TClientAttributes>[];
92
+ /** `null` on the last page. */
93
+ nextCursor: string | null;
94
+ /**
95
+ * Direct child folders of `folder`, at most 1000, and only those whose
96
+ * name contains `search` when it is set. First page only.
97
+ */
98
+ folders?: DbClientFolder[];
99
+ /** First page only. */
100
+ usage?: DbUsage;
101
+ /** Caps for the scope, `null` when there are none. First page only. */
102
+ limits?: DbQuota | null;
103
+ };
104
+ /** Identifies one object. `bucket` defaults to the only configured bucket. */
105
+ export type DbClientGetInput = {
106
+ key: string;
107
+ bucket?: string;
108
+ };
109
+ /** Body of `PATCH /db/object`. Omitted fields stay as they are. */
110
+ export type DbClientUpdateInput = DbClientGetInput & {
111
+ filename?: string;
112
+ /** Folder path. `null` moves the object to the root. */
113
+ folder?: string | null;
114
+ /**
115
+ * Replaces the attributes, checked by the plugin's `attributes.schema`.
116
+ * `null` clears them.
117
+ */
118
+ attributes?: Record<string, unknown> | null;
119
+ };
120
+ /** Body of `POST /db/folder` and query of `DELETE /db/folder`. */
121
+ export type DbClientFolderInput = {
122
+ path: string;
123
+ };
124
+ /**
125
+ * The db endpoints as client actions (`api.db`). Each takes the same
126
+ * per-call `{ signal, headers }` as the core methods.
127
+ */
128
+ export type DbClientActions<TClientAttributes = never> = {
129
+ listObjects(input?: DbClientListInput, options?: S3RequestOptions): Promise<DbClientListResponse<TClientAttributes>>;
130
+ getObject(input: DbClientGetInput, options?: S3RequestOptions): Promise<{
131
+ object: DbClientObject<TClientAttributes>;
132
+ }>;
133
+ updateObject(input: DbClientUpdateInput, options?: S3RequestOptions): Promise<{
134
+ object: DbClientObject<TClientAttributes>;
135
+ }>;
136
+ createFolder(input: DbClientFolderInput, options?: S3RequestOptions): Promise<{
137
+ folder: DbClientFolder;
138
+ }>;
139
+ deleteFolder(input: DbClientFolderInput, options?: S3RequestOptions): Promise<{
140
+ path: string;
141
+ }>;
142
+ };
143
+ /** Filters `dbObjectSource` sends with every page. */
144
+ export type DbObjectSourceOptions = {
145
+ route?: S3RouteName;
146
+ /** @default "active" */
147
+ status?: DbClientObjectStatus;
148
+ /** Exact type, or `type/*` for every subtype (`image/*`). */
149
+ contentType?: string;
150
+ /** Rows per page. The server caps it at 100. */
151
+ limit?: number;
152
+ /** List one folder at a time, with folder rows. @default true */
153
+ folders?: boolean;
154
+ };
155
+ /** A folder row of {@link DbObjectSource}. `id` is the folder path. */
156
+ export type DbObjectSourceFolder = {
157
+ id: string;
158
+ name: string;
159
+ };
160
+ /** The `useObjectList` query input. Mirrors react's `ObjectListQueryInput`. */
161
+ export type DbObjectSourceQueryInput = {
162
+ /** Folder path. `null` is the root. */
163
+ parent: string | null;
164
+ cursor: string | null;
165
+ /** `name`, `size`, or `updatedAt`. Other fields keep the default order. */
166
+ sort: {
167
+ field: string;
168
+ direction: "asc" | "desc";
169
+ } | null;
170
+ search: string;
171
+ signal: AbortSignal;
172
+ };
173
+ /** One page of {@link DbObjectSource}. Mirrors react's `ObjectListPage`. */
174
+ export type DbObjectSourcePage<TClientAttributes = never> = {
175
+ items: DbClientObject<TClientAttributes>[];
176
+ /** First page only. */
177
+ folders?: DbObjectSourceFolder[];
178
+ nextCursor: string | null;
179
+ /** Scope usage with its caps. First page only. */
180
+ usage?: DbUsage & DbQuota;
181
+ };
182
+ /** How the list reads one row. Mirrors react's `ObjectListFile`. */
183
+ export type DbObjectSourceFile = {
184
+ name: string;
185
+ objectKey: string;
186
+ size: number | null;
187
+ contentType: string | null;
188
+ /** The row's `updatedAt`. */
189
+ updatedAt: string;
190
+ };
191
+ /**
192
+ * A `useObjectList` source over `GET /db/objects`. Typed structurally so db
193
+ * does not depend on react; a type test checks it against `ObjectListSource`.
194
+ */
195
+ export type DbObjectSource<TClientAttributes = never> = {
196
+ query: (input: DbObjectSourceQueryInput) => Promise<DbObjectSourcePage<TClientAttributes>>;
197
+ getKey: (item: DbClientObject<TClientAttributes>) => string;
198
+ getFile: (item: DbClientObject<TClientAttributes>) => DbObjectSourceFile;
199
+ /** Upload options for files dropped into `parent`. Root is `""`. */
200
+ uploadOptions?: (parent: string | null) => {
201
+ metadata: Record<string, string>;
202
+ };
203
+ /** Creates `name` inside `parent`. */
204
+ createFolder?: (input: {
205
+ parent: string | null;
206
+ name: string;
207
+ }) => Promise<DbObjectSourceFolder>;
208
+ };
209
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/types/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,mFAAmF;AACnF,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,iBAAiB,GAAG,KAAK,IAAI;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,yDAAyD;IACzD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,oBAAoB,CAAC;IAC7B,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACrC,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,iCAAiC;AACjC,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,MAAM,EAAE,MAAM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D,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC3B,CAAC;AAEF,oEAAoE;AACpE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,iBAAiB,GAAG,KAAK,IAAI;IACtD,KAAK,EAAE,CACL,KAAK,EAAE,wBAAwB,KAC5B,OAAO,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACpD,MAAM,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,iBAAiB,CAAC,KAAK,MAAM,CAAC;IAC5D,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,iBAAiB,CAAC,KAAK,kBAAkB,CAAC;IACzE,oEAAoE;IACpE,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK;QACzC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,CAAC;IACF,sCAAsC;IACtC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC;KACd,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACrC,CAAC"}
@@ -0,0 +1,112 @@
1
+ import type { DimahS3Locals } from "@dimah-s3/server";
2
+ import type { DimahS3DbClient } from "../fuma-db.js";
3
+ import type { StandardSchemaV1 } from "../standard-schema.js";
4
+ import type { DbQuota } from "./client";
5
+ import type { StorageObject } from "./storage-object";
6
+ /**
7
+ * What a scope is resolved for.
8
+ * - `upload`: presign, multipart init, and `s3.put`
9
+ * - `confirm`: confirm, and the confirm step of multipart complete
10
+ * - `multipart`: part, list, abort, and complete
11
+ * - `download`: presigned download and `GET /file`
12
+ * - `delete`: delete, and each key of `deleteMany`
13
+ * - `list`: `GET /db/objects`
14
+ * - `read`: `GET /db/object`
15
+ * - `update`: `PATCH /db/object` and the folder endpoints
16
+ */
17
+ export type ScopeOperation = "upload" | "confirm" | "multipart" | "download" | "delete" | "list" | "read" | "update";
18
+ /**
19
+ * Who is calling: what `resolveScope` and a `quota` function see. The
20
+ * scope comes from the caller alone, never from the target, so the same
21
+ * caller gets the same scope when a ticket is bound, used, and confirmed.
22
+ */
23
+ export type ScopeContext<TSession = undefined> = {
24
+ request: Request;
25
+ /** Locals the guards have set so far. */
26
+ locals: DimahS3Locals;
27
+ /** `getSession(request)`, resolved once per request. */
28
+ session: TSession;
29
+ operation: ScopeOperation;
30
+ /**
31
+ * Named route of the call. `list` has one only when the client filters
32
+ * by route; `read`, `update`, and the folder endpoints have none.
33
+ */
34
+ route?: string;
35
+ };
36
+ /**
37
+ * What `authorize` checks: the caller's resolved scope, and what the call
38
+ * targets.
39
+ */
40
+ export type AuthorizeContext<TSession = undefined, TAttributes = never> = ScopeContext<TSession> & {
41
+ scope: string;
42
+ /** Object key. Absent on `list` and the folder endpoints. */
43
+ key?: string;
44
+ /** Target folder of an upload, move, or folder endpoint. `null` is the root. */
45
+ folder?: string | null;
46
+ /** Client extras of the upload. Set on `upload` only. */
47
+ clientMetadata?: Record<string, string>;
48
+ /**
49
+ * The stored row, when the call targets one, including the active object
50
+ * an overwrite replaces. It is the server view: `scope`, `s3Metadata`, and
51
+ * the attributes as stored.
52
+ */
53
+ object?: StorageObject<TAttributes>;
54
+ };
55
+ /** Per-route options under `plugins: { db: … }`. */
56
+ export type DbRouteOptions = {
57
+ /**
58
+ * `"overwrite"` lets an upload replace an active object at the same key.
59
+ * Without it, that upload fails with `OBJECT_EXISTS`.
60
+ */
61
+ replace?: "overwrite";
62
+ };
63
+ declare module "@dimah-s3/server" {
64
+ interface DimahS3RoutePluginOptions {
65
+ /** `false` turns db tracking and every db hook off for the route. */
66
+ db?: false | DbRouteOptions;
67
+ }
68
+ }
69
+ /** Typed app attributes for `PATCH /db/object`. */
70
+ export type DbAttributesOptions<TAttributes, TClientAttributes = TAttributes> = {
71
+ /** Validates the `attributes` of a PATCH body. */
72
+ schema: StandardSchemaV1<unknown, TAttributes>;
73
+ /** Maps stored attributes to what the browser sees. Defaults to all of them. */
74
+ toClient?: (attributes: TAttributes) => TClientAttributes;
75
+ /** Largest JSON size of the attributes, in bytes. @default 16_384 */
76
+ maxBytes?: number;
77
+ };
78
+ /** Caps for a scope, or a function that returns them per request. */
79
+ export type DbQuotaOption<TSession = undefined> = DbQuota | ((context: ScopeContext<TSession> & {
80
+ scope: string;
81
+ }) => DbQuota | null | Promise<DbQuota | null>);
82
+ /**
83
+ * Options of the `db()` plugin. Without `attributes.toClient`, the browser
84
+ * sees the stored attributes, so `TClientAttributes` defaults to them.
85
+ */
86
+ export type DbPluginOptions<TSession = undefined, TAttributes = never, TClientAttributes = TAttributes> = {
87
+ /** `DimahS3DB.client(adapter)`. */
88
+ client: DimahS3DbClient;
89
+ /** Loads the session for a request. Called at most once per `Request`. */
90
+ getSession?: (request: Request) => TSession | Promise<TSession>;
91
+ /**
92
+ * Owning scope of the caller, such as `user:123`. `null` rejects the
93
+ * call with `UNAUTHORIZED`. It runs once per call and route, so the guard
94
+ * and the lifecycle hooks of one call share the result.
95
+ */
96
+ resolveScope: (context: ScopeContext<TSession>) => string | null | Promise<string | null>;
97
+ /**
98
+ * Runs after the scope is resolved and, for a stored object, after the
99
+ * ownership check, so it can only narrow access. `object` is set when the
100
+ * call targets a stored row, including the active object an overwrite
101
+ * replaces; that upload's `folder` is the folder of the object it
102
+ * replaces. `false` rejects the call with `FORBIDDEN`.
103
+ */
104
+ authorize?: (context: AuthorizeContext<TSession, TAttributes>) => boolean | Promise<boolean>;
105
+ /** Byte and file caps, checked at upload and again at confirm. */
106
+ quota?: DbQuotaOption<TSession>;
107
+ /** `"soft"` keeps a `deleted` row; `"hard"` removes it. @default "soft" */
108
+ deleteMode?: "soft" | "hard";
109
+ /** Enables `attributes` on `PATCH /db/object`. */
110
+ attributes?: DbAttributesOptions<TAttributes, TClientAttributes>;
111
+ };
112
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,SAAS,GACT,WAAW,GACX,UAAU,GACV,QAAQ,GACR,MAAM,GACN,MAAM,GACN,QAAQ,CAAC;AAEb;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,QAAQ,GAAG,SAAS,IAAI;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,MAAM,EAAE,aAAa,CAAC;IACtB,wDAAwD;IACxD,OAAO,EAAE,QAAQ,CAAC;IAClB,SAAS,EAAE,cAAc,CAAC;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAC1B,QAAQ,GAAG,SAAS,EACpB,WAAW,GAAG,KAAK,IACjB,YAAY,CAAC,QAAQ,CAAC,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gFAAgF;IA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,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChE;;;;OAIG;IACH,YAAY,EAAE,CACZ,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,KAC5B,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5C;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,CACV,OAAO,EAAE,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,KAC7C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,kEAAkE;IAClE,KAAK,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,kDAAkD;IAClD,UAAU,CAAC,EAAE,mBAAmB,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;CAClE,CAAC"}
@@ -1,107 +1,62 @@
1
- /** Lifecycle status of a tracked object. */
2
- export type StorageObjectStatus = "pending" | "active" | "deleted";
3
1
  /**
4
- * App-facing record for a `storage_object` row.
5
- * Sizes are normalized from bigint to number (safe — S3 caps objects at 5 TB).
2
+ * Lifecycle status of a tracked object.
3
+ * - `pending`: presigned or started, not confirmed yet
4
+ * - `active`: confirmed with HeadObject
5
+ * - `deleted`: soft-deleted
6
+ * - `purging`: a stale pending row that purge has claimed
6
7
  */
7
- export type StorageObject = {
8
+ export type StorageObjectStatus = "pending" | "active" | "deleted" | "purging";
9
+ /**
10
+ * A `storage_object` row as the stores return it. Sizes are numbers (S3
11
+ * caps an object at 5 TiB, well inside the safe integer range).
12
+ */
13
+ export type StorageObject<TAttributes = never> = {
8
14
  id: string;
9
- /** Owner, e.g. `user:123` or `org:acme`. */
15
+ /** Owner, for example `user:123` or `org:acme`. */
10
16
  scope: string;
11
17
  bucket: string;
12
18
  key: string;
13
- /** Named dimah-s3 route. */
19
+ /** Named dimah-s3 route that created the object. */
14
20
  route: string;
21
+ /** Logical folder path. `null` is the root. */
22
+ folder: string | null;
23
+ filename: string;
15
24
  contentType: string | null;
16
- /** Verified size in bytes (set on confirm). */
25
+ /** Verified size in bytes, set on confirm. */
17
26
  size: number | null;
27
+ /** Size the client declared before confirm. Quota counts it while pending. */
28
+ declaredSize: number | null;
18
29
  eTag: string | null;
19
- filename: string | null;
20
30
  status: StorageObjectStatus;
21
- /** App-specific labels, visibility, publicUrl, etc. */
22
- metadata: Record<string, unknown> | null;
31
+ /** S3 user metadata of the verified object. */
32
+ s3Metadata: Record<string, string> | null;
33
+ /** App attributes, validated by the plugin's `attributes.schema`. */
34
+ attributes: TAttributes | null;
23
35
  acl: string | null;
24
- /** Multipart upload ID while status = pending. */
36
+ /** Multipart upload ID while the row is pending. */
25
37
  uploadId: string | null;
26
- /** Client-declared size before confirm (quota reservation). */
27
- declaredSize: number | null;
28
- confirmedAt: Date | null;
29
- /** Pending TTL or temporary object expiry. */
38
+ /**
39
+ * Token of the upload ticket that wrote the row. While purge cleans up an
40
+ * unconfirmed overwrite, it carries a `purge:` prefix.
41
+ */
42
+ uploadToken: string | null;
43
+ /** Confirm deadline of a pending row (the upload ticket's expiry). */
30
44
  expiresAt: Date | null;
45
+ confirmedAt: Date | null;
31
46
  createdAt: Date;
32
47
  updatedAt: Date;
33
48
  deletedAt: Date | null;
34
49
  };
35
- /**
36
- * Endpoint a scope is resolved for.
37
- * - `upload`: presign and multipart init
38
- * - `confirm`: confirm, and the confirm step of multipart complete
39
- * - `multipart`: part, list, abort, and complete
40
- * - `download`: presigned download and `GET /file`
41
- * - `delete`: delete, and each key of a batch delete
42
- * - `list`: `GET /db/objects` and `GET /db/object`
43
- */
44
- export type ScopeOperation = "upload" | "confirm" | "multipart" | "download" | "delete" | "list";
45
- /** Values the endpoint already validated, passed to {@link ScopeResolver}. */
46
- export type ScopeContext = {
47
- operation: ScopeOperation;
48
- /** Named route. On `list`, set only when the client filtered by route. */
49
- route?: string;
50
- /** Object key. Absent on `GET /db/objects`. */
51
- key?: string;
52
- /** Client extras from presign or multipart init. Set on `upload` only. */
53
- clientMetadata?: Record<string, string>;
54
- };
55
- /**
56
- * Resolves the owning scope for a request (e.g. from a session cookie).
57
- * `context` carries the operation, route, and key, so a scope that depends
58
- * on the object key does not have to parse the request. A batch delete
59
- * resolves once per key. Return `null` to reject the request as
60
- * unauthenticated (401).
61
- */
62
- export type ScopeResolver = (request: Request, context: ScopeContext) => string | null | Promise<string | null>;
63
- /**
64
- * Browser-facing object row from `GET /db/objects`.
65
- * Deliberately narrower than {@link StorageObject} — omits server-only fields.
66
- */
67
- export type DbClientObject = {
50
+ /** A `storage_folder` row. A folder exists once per scope and path. */
51
+ export type StorageFolder = {
68
52
  id: string;
69
- bucket: string;
70
- key: string;
71
- route: string;
72
- filename: string | null;
73
- contentType: string | null;
74
- size: number | null;
75
- declaredSize: number | null;
76
- status: StorageObjectStatus;
77
- /** ISO-8601 timestamp. */
78
- createdAt: string;
79
- };
80
- export type DbClientListResponse = {
81
- /** Scope resolved on the server via `resolveScope` (not a client input). */
82
53
  scope: string;
83
- usage: {
84
- totalBytes: number;
85
- objectCount: number;
86
- };
87
- objects: DbClientObject[];
88
- nextCursor?: string | null;
89
- };
90
- /**
91
- * Query params for browser `api.db.listObjects`.
92
- * Scope is not accepted — the server derives it from `resolveScope` on the request.
93
- */
94
- export type DbClientListInput = {
95
- status?: StorageObjectStatus;
96
- limit?: number;
97
- offset?: number;
98
- cursor?: string;
99
- route?: string;
100
- contentType?: string;
101
- prefix?: string;
102
- };
103
- export type DbClientGetInput = {
104
- key: string;
105
- bucket?: string;
54
+ /** Full folder path. */
55
+ path: string;
56
+ /** Path of the containing folder. `null` is the root. */
57
+ parent: string | null;
58
+ /** Last segment of `path`. */
59
+ name: string;
60
+ createdAt: Date;
106
61
  };
107
62
  //# sourceMappingURL=storage-object.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage-object.d.ts","sourceRoot":"","sources":["../../src/types/storage-object.ts"],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WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,sEAAsE;IACtE,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimah-s3/db",
3
- "version": "1.7.1",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Optional database plugin for dimah-s3 — track S3 object ownership, listings, and resumable uploads",
5
5
  "keywords": [
6
6
  "s3",
@@ -18,7 +18,7 @@
18
18
  "fumadb",
19
19
  "typescript"
20
20
  ],
21
- "homepage": "https://s3.dimah.dev/docs/db",
21
+ "homepage": "https://v2.s3.dimah.dev/docs/db",
22
22
  "bugs": {
23
23
  "url": "https://github.com/dimah-kz/dimah-s3/issues"
24
24
  },
@@ -43,44 +43,86 @@
43
43
  "./cli": {
44
44
  "types": "./dist/cli.d.ts",
45
45
  "default": "./dist/cli.js"
46
+ },
47
+ "./drizzle/sqlite": {
48
+ "types": "./dist/drizzle/sqlite.d.ts",
49
+ "default": "./dist/drizzle/sqlite.js"
50
+ },
51
+ "./drizzle/pg": {
52
+ "types": "./dist/drizzle/pg.d.ts",
53
+ "default": "./dist/drizzle/pg.js"
54
+ },
55
+ "./drizzle/mysql": {
56
+ "types": "./dist/drizzle/mysql.d.ts",
57
+ "default": "./dist/drizzle/mysql.js"
58
+ },
59
+ "./adapters/drizzle": {
60
+ "types": "./dist/adapters/drizzle.d.ts",
61
+ "default": "./dist/adapters/drizzle.js"
62
+ },
63
+ "./adapters/kysely": {
64
+ "types": "./dist/adapters/kysely.d.ts",
65
+ "default": "./dist/adapters/kysely.js"
66
+ },
67
+ "./adapters/prisma": {
68
+ "types": "./dist/adapters/prisma.d.ts",
69
+ "default": "./dist/adapters/prisma.js"
46
70
  }
47
71
  },
48
72
  "files": [
49
73
  "dist",
50
- "src/schema/examples"
74
+ "sql",
75
+ "prisma",
76
+ "src/drizzle/sqlite.ts",
77
+ "src/drizzle/pg.ts",
78
+ "src/drizzle/mysql.ts"
51
79
  ],
52
80
  "dependencies": {
53
- "@dimah-s3/core": "1.7.1",
81
+ "@dimah-s3/core": "2.0.0-beta.1",
54
82
  "@paralleldrive/cuid2": "^3.3.0",
55
- "fumadb": "^0.6.0",
83
+ "fumadb": "~0.6.0",
56
84
  "zod": "^4.6.7"
57
85
  },
58
86
  "devDependencies": {
59
- "@aws-sdk/client-s3": "^3.1159.0",
60
- "@dimah-s3/server": "1.7.1",
87
+ "@aws-sdk/client-s3": "^3.1161.0",
88
+ "@dimah-s3/react": "2.0.0-beta.1",
89
+ "@dimah-s3/server": "2.0.0-beta.1",
90
+ "@electric-sql/pglite": "^0.5.14",
91
+ "@types/better-sqlite3": "^9.6.0",
61
92
  "@types/node": "^26.6.6",
93
+ "@types/react": "^19.3.0",
62
94
  "@workspace/eslint-config": "0.0.1",
63
95
  "@workspace/tsup-config": "0.0.0",
64
96
  "@workspace/typescript-config": "0.0.1",
65
97
  "@workspace/vitest-config": "0.0.7",
98
+ "better-sqlite3": "^13.0.3",
66
99
  "drizzle-orm": "1.0.0-rc.5",
67
- "eslint": "^10.13.0",
68
- "tsc-alias": "^1.9.9",
100
+ "eslint": "^10.14.0",
101
+ "kysely": "^0.29.8",
102
+ "tsc-alias": "^1.9.10",
69
103
  "tsup": "^9.0.0",
70
104
  "typescript": "7.0.2",
71
105
  "vitest": "^5.0.5"
72
106
  },
73
107
  "peerDependencies": {
74
108
  "@aws-sdk/client-s3": ">=3",
75
- "@dimah-s3/server": "1.7.1",
76
- "drizzle-orm": "^0.44.0 || ^0.45.0 || >=1.0.0-rc.1 <2.0.0"
109
+ "@dimah-s3/server": "2.0.0-beta.1",
110
+ "@prisma/client": "^6.0.0 || ^7.0.0",
111
+ "drizzle-orm": ">=1.0.0-rc.5 <2.0.0",
112
+ "kysely": "^0.29.5"
77
113
  },
78
114
  "peerDependenciesMeta": {
79
115
  "@aws-sdk/client-s3": {
80
116
  "optional": true
81
117
  },
118
+ "@prisma/client": {
119
+ "optional": true
120
+ },
82
121
  "drizzle-orm": {
83
122
  "optional": true
123
+ },
124
+ "kysely": {
125
+ "optional": true
84
126
  }
85
127
  },
86
128
  "publishConfig": {