@dimah-s3/db 2.0.0-beta.1 → 2.0.0-beta.3
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/README.md +2 -2
- package/dist/cli.js +12 -16
- package/dist/cli.js.map +1 -1
- package/dist/client/db-client.d.ts +1 -1
- package/dist/client/db-client.d.ts.map +1 -1
- package/dist/client/db-object-source.d.ts +8 -5
- package/dist/client/db-object-source.d.ts.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +49 -12
- package/dist/client/index.js.map +1 -1
- package/dist/drizzle/mysql.d.ts +44 -12
- package/dist/drizzle/mysql.d.ts.map +1 -1
- package/dist/drizzle/mysql.js +11 -8
- package/dist/drizzle/mysql.js.map +1 -1
- package/dist/drizzle/pg.d.ts +42 -12
- package/dist/drizzle/pg.d.ts.map +1 -1
- package/dist/drizzle/pg.js +13 -7
- package/dist/drizzle/pg.js.map +1 -1
- package/dist/drizzle/shared.d.ts +1 -1
- package/dist/drizzle/sqlite.d.ts +44 -12
- package/dist/drizzle/sqlite.d.ts.map +1 -1
- package/dist/drizzle/sqlite.js +13 -7
- package/dist/drizzle/sqlite.js.map +1 -1
- package/dist/folder-path.d.ts +9 -2
- package/dist/folder-path.d.ts.map +1 -1
- package/dist/fuma-db.d.ts +6 -5
- package/dist/fuma-db.d.ts.map +1 -1
- package/dist/index.js +347 -170
- package/dist/index.js.map +1 -1
- package/dist/plugin/create-database-endpoints.d.ts +38 -18
- package/dist/plugin/create-database-endpoints.d.ts.map +1 -1
- package/dist/plugin/create-database-lifecycle-hooks.d.ts +1 -1
- package/dist/plugin/create-database-lifecycle-hooks.d.ts.map +1 -1
- package/dist/plugin/db.d.ts.map +1 -1
- package/dist/plugin/object-access.d.ts +1 -1
- package/dist/plugin/object-access.d.ts.map +1 -1
- package/dist/plugin/public-stores.d.ts +4 -7
- package/dist/plugin/public-stores.d.ts.map +1 -1
- package/dist/plugin/schemas.d.ts +21 -12
- package/dist/plugin/schemas.d.ts.map +1 -1
- package/dist/plugin/to-db-client-object.d.ts.map +1 -1
- package/dist/schema/schema.d.ts +9 -8
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/store/folder-store.d.ts +41 -14
- package/dist/store/folder-store.d.ts.map +1 -1
- package/dist/store/list-cursor.d.ts +1 -1
- package/dist/store/list-cursor.d.ts.map +1 -1
- package/dist/store/map-row.d.ts +1 -1
- package/dist/store/map-row.d.ts.map +1 -1
- package/dist/store/object-store.d.ts +5 -5
- package/dist/store/object-store.d.ts.map +1 -1
- package/dist/types/client.d.ts +63 -18
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +6 -1
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/storage-object.d.ts +8 -7
- package/dist/types/storage-object.d.ts.map +1 -1
- package/package.json +6 -6
- package/prisma/dimah-s3.prisma +14 -13
- package/sql/mysql.sql +12 -11
- package/sql/pg.sql +10 -10
- package/sql/sqlite.sql +10 -9
- package/src/drizzle/mysql.ts +10 -7
- package/src/drizzle/pg.ts +12 -6
- package/src/drizzle/sqlite.ts +12 -6
package/dist/types/client.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export type DbClientObject<TClientAttributes = never> = {
|
|
|
12
12
|
bucket: string;
|
|
13
13
|
key: string;
|
|
14
14
|
route: string;
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/** Folder that holds the object. `null` is the root. */
|
|
16
|
+
folderId: string | null;
|
|
17
17
|
filename: string;
|
|
18
18
|
contentType: string | null;
|
|
19
19
|
/** Verified size. `null` while the object is pending. */
|
|
@@ -28,12 +28,16 @@ export type DbClientObject<TClientAttributes = never> = {
|
|
|
28
28
|
};
|
|
29
29
|
/** Browser-facing folder row. */
|
|
30
30
|
export type DbClientFolder = {
|
|
31
|
-
|
|
31
|
+
id: string;
|
|
32
32
|
name: string;
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/** Containing folder. `null` is the root. */
|
|
34
|
+
parentId: string | null;
|
|
35
|
+
/** Full path, from the root. It changes when an ancestor is renamed. */
|
|
36
|
+
path: string;
|
|
35
37
|
/** ISO 8601 timestamp. */
|
|
36
38
|
createdAt: string;
|
|
39
|
+
/** ISO 8601 timestamp. */
|
|
40
|
+
updatedAt: string;
|
|
37
41
|
};
|
|
38
42
|
/** Column a listing can be ordered by. */
|
|
39
43
|
export type DbListSortField = "createdAt" | "updatedAt" | "size" | "filename";
|
|
@@ -64,7 +68,7 @@ export type DbClientListInput = {
|
|
|
64
68
|
* Folder to list. `null` (or `""`) is the root. Omit for a flat list of
|
|
65
69
|
* every folder.
|
|
66
70
|
*/
|
|
67
|
-
|
|
71
|
+
folderId?: string | null;
|
|
68
72
|
route?: S3RouteName;
|
|
69
73
|
/** @default "active" */
|
|
70
74
|
status?: DbClientObjectStatus;
|
|
@@ -92,10 +96,15 @@ export type DbClientListResponse<TClientAttributes = never> = {
|
|
|
92
96
|
/** `null` on the last page. */
|
|
93
97
|
nextCursor: string | null;
|
|
94
98
|
/**
|
|
95
|
-
* Direct child folders of `
|
|
99
|
+
* Direct child folders of `folderId`, at most 1000, and only those whose
|
|
96
100
|
* name contains `search` when it is set. First page only.
|
|
97
101
|
*/
|
|
98
102
|
folders?: DbClientFolder[];
|
|
103
|
+
/**
|
|
104
|
+
* Folders from the root down to the open folder. Empty at the root.
|
|
105
|
+
* First page only, and only when `folderId` is set.
|
|
106
|
+
*/
|
|
107
|
+
trail?: DbClientFolder[];
|
|
99
108
|
/** First page only. */
|
|
100
109
|
usage?: DbUsage;
|
|
101
110
|
/** Caps for the scope, `null` when there are none. First page only. */
|
|
@@ -109,17 +118,29 @@ export type DbClientGetInput = {
|
|
|
109
118
|
/** Body of `PATCH /db/object`. Omitted fields stay as they are. */
|
|
110
119
|
export type DbClientUpdateInput = DbClientGetInput & {
|
|
111
120
|
filename?: string;
|
|
112
|
-
/** Folder
|
|
113
|
-
|
|
121
|
+
/** Folder id. `null` moves the object to the root. */
|
|
122
|
+
folderId?: string | null;
|
|
114
123
|
/**
|
|
115
124
|
* Replaces the attributes, checked by the plugin's `attributes.schema`.
|
|
116
125
|
* `null` clears them.
|
|
117
126
|
*/
|
|
118
127
|
attributes?: Record<string, unknown> | null;
|
|
119
128
|
};
|
|
120
|
-
/** Body of `POST /db/folder`
|
|
121
|
-
export type
|
|
122
|
-
|
|
129
|
+
/** Body of `POST /db/folder`. `parentId` omitted or `null` is the root. */
|
|
130
|
+
export type DbClientCreateFolderInput = {
|
|
131
|
+
parentId?: string | null;
|
|
132
|
+
name: string;
|
|
133
|
+
};
|
|
134
|
+
/** Body of `PATCH /db/folder`. An omitted field stays as it is. */
|
|
135
|
+
export type DbClientUpdateFolderInput = {
|
|
136
|
+
id: string;
|
|
137
|
+
name?: string;
|
|
138
|
+
/** `null` moves the folder to the root. */
|
|
139
|
+
parentId?: string | null;
|
|
140
|
+
};
|
|
141
|
+
/** Query of `DELETE /db/folder`. */
|
|
142
|
+
export type DbClientDeleteFolderInput = {
|
|
143
|
+
id: string;
|
|
123
144
|
};
|
|
124
145
|
/**
|
|
125
146
|
* The db endpoints as client actions (`api.db`). Each takes the same
|
|
@@ -133,11 +154,14 @@ export type DbClientActions<TClientAttributes = never> = {
|
|
|
133
154
|
updateObject(input: DbClientUpdateInput, options?: S3RequestOptions): Promise<{
|
|
134
155
|
object: DbClientObject<TClientAttributes>;
|
|
135
156
|
}>;
|
|
136
|
-
createFolder(input:
|
|
157
|
+
createFolder(input: DbClientCreateFolderInput, options?: S3RequestOptions): Promise<{
|
|
158
|
+
folder: DbClientFolder;
|
|
159
|
+
}>;
|
|
160
|
+
updateFolder(input: DbClientUpdateFolderInput, options?: S3RequestOptions): Promise<{
|
|
137
161
|
folder: DbClientFolder;
|
|
138
162
|
}>;
|
|
139
|
-
deleteFolder(input:
|
|
140
|
-
|
|
163
|
+
deleteFolder(input: DbClientDeleteFolderInput, options?: S3RequestOptions): Promise<{
|
|
164
|
+
id: string;
|
|
141
165
|
}>;
|
|
142
166
|
};
|
|
143
167
|
/** Filters `dbObjectSource` sends with every page. */
|
|
@@ -152,14 +176,14 @@ export type DbObjectSourceOptions = {
|
|
|
152
176
|
/** List one folder at a time, with folder rows. @default true */
|
|
153
177
|
folders?: boolean;
|
|
154
178
|
};
|
|
155
|
-
/** A folder row of {@link DbObjectSource}. `id` is the folder
|
|
179
|
+
/** A folder row of {@link DbObjectSource}. `id` is the folder id. */
|
|
156
180
|
export type DbObjectSourceFolder = {
|
|
157
181
|
id: string;
|
|
158
182
|
name: string;
|
|
159
183
|
};
|
|
160
184
|
/** The `useObjectList` query input. Mirrors react's `ObjectListQueryInput`. */
|
|
161
185
|
export type DbObjectSourceQueryInput = {
|
|
162
|
-
/** Folder
|
|
186
|
+
/** Folder id. `null` is the root. */
|
|
163
187
|
parent: string | null;
|
|
164
188
|
cursor: string | null;
|
|
165
189
|
/** `name`, `size`, or `updatedAt`. Other fields keep the default order. */
|
|
@@ -175,6 +199,11 @@ export type DbObjectSourcePage<TClientAttributes = never> = {
|
|
|
175
199
|
items: DbClientObject<TClientAttributes>[];
|
|
176
200
|
/** First page only. */
|
|
177
201
|
folders?: DbObjectSourceFolder[];
|
|
202
|
+
/**
|
|
203
|
+
* Folders from the root down to `parent`. First page only.
|
|
204
|
+
* `useObjectList` shows these names in the breadcrumb.
|
|
205
|
+
*/
|
|
206
|
+
trail?: DbObjectSourceFolder[];
|
|
178
207
|
nextCursor: string | null;
|
|
179
208
|
/** Scope usage with its caps. First page only. */
|
|
180
209
|
usage?: DbUsage & DbQuota;
|
|
@@ -196,7 +225,7 @@ export type DbObjectSource<TClientAttributes = never> = {
|
|
|
196
225
|
query: (input: DbObjectSourceQueryInput) => Promise<DbObjectSourcePage<TClientAttributes>>;
|
|
197
226
|
getKey: (item: DbClientObject<TClientAttributes>) => string;
|
|
198
227
|
getFile: (item: DbClientObject<TClientAttributes>) => DbObjectSourceFile;
|
|
199
|
-
/** Upload options for files dropped into `parent`.
|
|
228
|
+
/** Upload options for files dropped into `parent`. The root sends `""`. */
|
|
200
229
|
uploadOptions?: (parent: string | null) => {
|
|
201
230
|
metadata: Record<string, string>;
|
|
202
231
|
};
|
|
@@ -205,5 +234,21 @@ export type DbObjectSource<TClientAttributes = never> = {
|
|
|
205
234
|
parent: string | null;
|
|
206
235
|
name: string;
|
|
207
236
|
}) => Promise<DbObjectSourceFolder>;
|
|
237
|
+
/**
|
|
238
|
+
* Renames a file's `filename`. The object `key` stays. Set when `api.db`
|
|
239
|
+
* has `updateObject`.
|
|
240
|
+
*/
|
|
241
|
+
renameFile?: (input: {
|
|
242
|
+
item: DbClientObject<TClientAttributes>;
|
|
243
|
+
name: string;
|
|
244
|
+
}) => Promise<DbClientObject<TClientAttributes>>;
|
|
245
|
+
/**
|
|
246
|
+
* Renames a folder. Its id stays. Set when `api.db` has `updateFolder`
|
|
247
|
+
* and `folders` is on.
|
|
248
|
+
*/
|
|
249
|
+
renameFolder?: (input: {
|
|
250
|
+
folder: DbObjectSourceFolder;
|
|
251
|
+
name: string;
|
|
252
|
+
}) => Promise<DbObjectSourceFolder>;
|
|
208
253
|
};
|
|
209
254
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +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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,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;IACpC;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QACnB,IAAI,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;QACxC,IAAI,EAAE,MAAM,CAAC;KACd,KAAK,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACjD;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QACrB,MAAM,EAAE,oBAAoB,CAAC;QAC7B,IAAI,EAAE,MAAM,CAAC;KACd,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACrC,CAAC"}
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -41,8 +41,13 @@ export type AuthorizeContext<TSession = undefined, TAttributes = never> = ScopeC
|
|
|
41
41
|
scope: string;
|
|
42
42
|
/** Object key. Absent on `list` and the folder endpoints. */
|
|
43
43
|
key?: string;
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Path of the target folder. `null` is the root. Absent when the call is
|
|
46
|
+
* not aimed at one folder. A rename or move reports the destination.
|
|
47
|
+
*/
|
|
45
48
|
folder?: string | null;
|
|
49
|
+
/** Id of the target folder. `null` is the root. */
|
|
50
|
+
folderId?: string | null;
|
|
46
51
|
/** Client extras of the upload. Set on `upload` only. */
|
|
47
52
|
clientMetadata?: Record<string, string>;
|
|
48
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,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IAClD,UAAU,CAAC,EAAE,mBAAmB,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;CAClE,CAAC"}
|
|
@@ -18,8 +18,8 @@ export type StorageObject<TAttributes = never> = {
|
|
|
18
18
|
key: string;
|
|
19
19
|
/** Named dimah-s3 route that created the object. */
|
|
20
20
|
route: string;
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/** Folder that holds the object. `null` is the root. */
|
|
22
|
+
folderId: string | null;
|
|
23
23
|
filename: string;
|
|
24
24
|
contentType: string | null;
|
|
25
25
|
/** Verified size in bytes, set on confirm. */
|
|
@@ -47,16 +47,17 @@ export type StorageObject<TAttributes = never> = {
|
|
|
47
47
|
updatedAt: Date;
|
|
48
48
|
deletedAt: Date | null;
|
|
49
49
|
};
|
|
50
|
-
/** A `storage_folder` row. A folder exists once per scope and
|
|
50
|
+
/** A `storage_folder` row. A folder exists once per scope and id. */
|
|
51
51
|
export type StorageFolder = {
|
|
52
52
|
id: string;
|
|
53
53
|
scope: string;
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
/** Path of the containing folder. `null` is the root. */
|
|
57
|
-
parent: string | null;
|
|
54
|
+
/** Containing folder. `null` is the root. */
|
|
55
|
+
parentId: string | null;
|
|
58
56
|
/** Last segment of `path`. */
|
|
59
57
|
name: string;
|
|
58
|
+
/** Full folder path, kept in step with `name` and the parents. */
|
|
59
|
+
path: string;
|
|
60
60
|
createdAt: Date;
|
|
61
|
+
updatedAt: Date;
|
|
61
62
|
};
|
|
62
63
|
//# sourceMappingURL=storage-object.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-object.d.ts","sourceRoot":"","sources":["../../src/types/storage-object.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/E;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,WAAW,GAA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AAG,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,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimah-s3/db",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "Optional database plugin for dimah-s3 — track S3 object ownership, listings, and resumable uploads",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"s3",
|
|
@@ -78,15 +78,15 @@
|
|
|
78
78
|
"src/drizzle/mysql.ts"
|
|
79
79
|
],
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@dimah-s3/core": "2.0.0-beta.
|
|
81
|
+
"@dimah-s3/core": "2.0.0-beta.3",
|
|
82
82
|
"@paralleldrive/cuid2": "^3.3.0",
|
|
83
83
|
"fumadb": "~0.6.0",
|
|
84
84
|
"zod": "^4.6.7"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@aws-sdk/client-s3": "^3.1161.0",
|
|
88
|
-
"@dimah-s3/react": "2.0.0-beta.
|
|
89
|
-
"@dimah-s3/server": "2.0.0-beta.
|
|
88
|
+
"@dimah-s3/react": "2.0.0-beta.3",
|
|
89
|
+
"@dimah-s3/server": "2.0.0-beta.3",
|
|
90
90
|
"@electric-sql/pglite": "^0.5.14",
|
|
91
91
|
"@types/better-sqlite3": "^9.6.0",
|
|
92
92
|
"@types/node": "^26.6.6",
|
|
@@ -102,11 +102,11 @@
|
|
|
102
102
|
"tsc-alias": "^1.9.10",
|
|
103
103
|
"tsup": "^9.0.0",
|
|
104
104
|
"typescript": "7.0.2",
|
|
105
|
-
"vitest": "^5.0
|
|
105
|
+
"vitest": "^5.1.0"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
108
|
"@aws-sdk/client-s3": ">=3",
|
|
109
|
-
"@dimah-s3/server": "2.0.0-beta.
|
|
109
|
+
"@dimah-s3/server": "2.0.0-beta.3",
|
|
110
110
|
"@prisma/client": "^6.0.0 || ^7.0.0",
|
|
111
111
|
"drizzle-orm": ">=1.0.0-rc.5 <2.0.0",
|
|
112
112
|
"kysely": "^0.29.5"
|
package/prisma/dimah-s3.prisma
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Prisma models for @dimah-s3/db schema 2.
|
|
1
|
+
// Prisma models for @dimah-s3/db schema 2.1.0.
|
|
2
2
|
//
|
|
3
3
|
// Copy this file next to your schema (Prisma reads every .prisma file in the
|
|
4
4
|
// schema folder) or paste the models into schema.prisma, then create the
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
// `prisma.private_dimah_s3_settings`.
|
|
8
8
|
//
|
|
9
9
|
// The models work as they are on PostgreSQL and SQLite. On MySQL, match
|
|
10
|
-
// `sql/mysql.sql`: add `@db.VarChar(1024)` to `key
|
|
11
|
-
//
|
|
12
|
-
// `@@unique([bucket, key(length: 512)])`.
|
|
10
|
+
// `sql/mysql.sql`: add `@db.VarChar(1024)` to `key` and `path`,
|
|
11
|
+
// `@db.DateTime(3)` to the timestamps, and index prefixes such as
|
|
12
|
+
// `@@unique([bucket, key(length: 512)])`. `parentId` is `""` at the root.
|
|
13
13
|
|
|
14
14
|
/// One row per tracked object: pending (presigned), active (confirmed),
|
|
15
15
|
/// deleted (soft delete), or purging (a stale pending row purge has claimed).
|
|
@@ -21,8 +21,8 @@ model StorageObject {
|
|
|
21
21
|
key String
|
|
22
22
|
/// Named dimah-s3 route that created the object.
|
|
23
23
|
route String
|
|
24
|
-
///
|
|
25
|
-
|
|
24
|
+
/// Folder that holds the object. `null` is the root.
|
|
25
|
+
folderId String? @map("folder_id")
|
|
26
26
|
filename String
|
|
27
27
|
contentType String? @map("content_type")
|
|
28
28
|
/// Verified size from HeadObject, set on confirm.
|
|
@@ -48,7 +48,7 @@ model StorageObject {
|
|
|
48
48
|
deletedAt DateTime? @map("deleted_at")
|
|
49
49
|
|
|
50
50
|
@@unique([bucket, key], map: "storage_object_bucket_key_uk")
|
|
51
|
-
@@index([scope, status,
|
|
51
|
+
@@index([scope, status, folderId, createdAt], map: "storage_object_scope_folder_idx")
|
|
52
52
|
@@index([scope, status, updatedAt], map: "storage_object_scope_updated_idx")
|
|
53
53
|
@@index([scope, status, filename], map: "storage_object_scope_filename_idx")
|
|
54
54
|
@@index([scope, status, size], map: "storage_object_scope_size_idx")
|
|
@@ -60,21 +60,22 @@ model StorageObject {
|
|
|
60
60
|
model StorageFolder {
|
|
61
61
|
id String @id @default(cuid())
|
|
62
62
|
scope String
|
|
63
|
-
///
|
|
64
|
-
|
|
65
|
-
/// Path of the containing folder. `null` is the root.
|
|
66
|
-
parent String?
|
|
63
|
+
/// Id of the containing folder. `""` is the root.
|
|
64
|
+
parentId String @map("parent_id")
|
|
67
65
|
/// Last segment of `path`.
|
|
68
66
|
name String
|
|
67
|
+
/// Full folder path.
|
|
68
|
+
path String
|
|
69
69
|
createdAt DateTime @default(now()) @map("created_at")
|
|
70
|
+
updatedAt DateTime @default(now()) @map("updated_at")
|
|
70
71
|
|
|
71
72
|
@@unique([scope, path], map: "storage_folder_scope_path_uk")
|
|
72
|
-
@@
|
|
73
|
+
@@unique([scope, parentId, name], map: "storage_folder_scope_parent_name_uk")
|
|
73
74
|
@@map("storage_folder")
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
/// FumaDB settings. The adapter reads the schema version from the `version` row.
|
|
77
78
|
model private_dimah_s3_settings {
|
|
78
79
|
key String @id
|
|
79
|
-
value String @default("2.
|
|
80
|
+
value String @default("2.1.0")
|
|
80
81
|
}
|
package/sql/mysql.sql
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
-- @dimah-s3/db schema 2.
|
|
1
|
+
-- @dimah-s3/db schema 2.1.0 for MySQL 8.
|
|
2
2
|
-- Keys, folders, and scopes compare byte for byte (utf8mb4_bin); file names
|
|
3
3
|
-- use a case-insensitive collation for search. An InnoDB index holds at most
|
|
4
|
-
-- 3072 bytes, so `key
|
|
5
|
-
--
|
|
6
|
-
--
|
|
4
|
+
-- 3072 bytes, so `key` and `path` are indexed by prefix: two values that
|
|
5
|
+
-- share their first 512 characters share an index entry, and the unique
|
|
6
|
+
-- keys treat them as equal. `parent_id` is `''` at the root.
|
|
7
7
|
|
|
8
8
|
CREATE TABLE `storage_object` (
|
|
9
9
|
`id` varchar(255) NOT NULL,
|
|
@@ -11,7 +11,7 @@ CREATE TABLE `storage_object` (
|
|
|
11
11
|
`bucket` varchar(255) NOT NULL,
|
|
12
12
|
`key` varchar(1024) NOT NULL,
|
|
13
13
|
`route` varchar(255) NOT NULL,
|
|
14
|
-
`
|
|
14
|
+
`folder_id` varchar(255),
|
|
15
15
|
`filename` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
16
16
|
`content_type` varchar(255),
|
|
17
17
|
`size` bigint,
|
|
@@ -30,7 +30,7 @@ CREATE TABLE `storage_object` (
|
|
|
30
30
|
`deleted_at` datetime(3),
|
|
31
31
|
PRIMARY KEY (`id`),
|
|
32
32
|
UNIQUE KEY `storage_object_bucket_key_uk` (`bucket`, `key`(512)),
|
|
33
|
-
KEY `storage_object_scope_folder_idx` (`scope`, `status`, `
|
|
33
|
+
KEY `storage_object_scope_folder_idx` (`scope`, `status`, `folder_id`, `created_at`),
|
|
34
34
|
KEY `storage_object_scope_updated_idx` (`scope`, `status`, `updated_at`),
|
|
35
35
|
KEY `storage_object_scope_filename_idx` (`scope`, `status`, `filename`),
|
|
36
36
|
KEY `storage_object_scope_size_idx` (`scope`, `status`, `size`),
|
|
@@ -40,20 +40,21 @@ CREATE TABLE `storage_object` (
|
|
|
40
40
|
CREATE TABLE `storage_folder` (
|
|
41
41
|
`id` varchar(255) NOT NULL,
|
|
42
42
|
`scope` varchar(255) NOT NULL,
|
|
43
|
-
`
|
|
44
|
-
`parent` varchar(1024),
|
|
43
|
+
`parent_id` varchar(255) NOT NULL DEFAULT '',
|
|
45
44
|
`name` varchar(255) NOT NULL,
|
|
45
|
+
`path` varchar(1024) NOT NULL,
|
|
46
46
|
`created_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
47
|
+
`updated_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
47
48
|
PRIMARY KEY (`id`),
|
|
48
49
|
UNIQUE KEY `storage_folder_scope_path_uk` (`scope`, `path`(512)),
|
|
49
|
-
KEY `
|
|
50
|
+
UNIQUE KEY `storage_folder_scope_parent_name_uk` (`scope`, `parent_id`, `name`)
|
|
50
51
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
|
51
52
|
|
|
52
53
|
-- Schema version for the Kysely and Prisma adapters.
|
|
53
54
|
CREATE TABLE `private_dimah_s3_settings` (
|
|
54
55
|
`key` varchar(255) NOT NULL,
|
|
55
|
-
`value` text NOT NULL DEFAULT ('2.
|
|
56
|
+
`value` text NOT NULL DEFAULT ('2.1.0'),
|
|
56
57
|
PRIMARY KEY (`key`)
|
|
57
58
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
|
58
59
|
|
|
59
|
-
INSERT INTO `private_dimah_s3_settings` (`key`, `value`) VALUES ('version', '2.
|
|
60
|
+
INSERT INTO `private_dimah_s3_settings` (`key`, `value`) VALUES ('version', '2.1.0');
|
package/sql/pg.sql
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
-- @dimah-s3/db schema 2.
|
|
1
|
+
-- @dimah-s3/db schema 2.1.0 for PostgreSQL.
|
|
2
2
|
|
|
3
3
|
CREATE TABLE "storage_object" (
|
|
4
4
|
"id" varchar(255) PRIMARY KEY NOT NULL,
|
|
@@ -6,7 +6,7 @@ CREATE TABLE "storage_object" (
|
|
|
6
6
|
"bucket" text NOT NULL,
|
|
7
7
|
"key" text NOT NULL,
|
|
8
8
|
"route" text NOT NULL,
|
|
9
|
-
"
|
|
9
|
+
"folder_id" text,
|
|
10
10
|
"filename" text NOT NULL,
|
|
11
11
|
"content_type" text,
|
|
12
12
|
"size" bigint,
|
|
@@ -26,7 +26,7 @@ CREATE TABLE "storage_object" (
|
|
|
26
26
|
CONSTRAINT "storage_object_bucket_key_uk" UNIQUE ("bucket", "key")
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
CREATE INDEX "storage_object_scope_folder_idx" ON "storage_object" ("scope", "status", "
|
|
29
|
+
CREATE INDEX "storage_object_scope_folder_idx" ON "storage_object" ("scope", "status", "folder_id", "created_at");
|
|
30
30
|
CREATE INDEX "storage_object_scope_updated_idx" ON "storage_object" ("scope", "status", "updated_at");
|
|
31
31
|
CREATE INDEX "storage_object_scope_filename_idx" ON "storage_object" ("scope", "status", "filename");
|
|
32
32
|
CREATE INDEX "storage_object_scope_size_idx" ON "storage_object" ("scope", "status", "size");
|
|
@@ -35,19 +35,19 @@ CREATE INDEX "storage_object_status_expires_idx" ON "storage_object" ("status",
|
|
|
35
35
|
CREATE TABLE "storage_folder" (
|
|
36
36
|
"id" varchar(255) PRIMARY KEY NOT NULL,
|
|
37
37
|
"scope" text NOT NULL,
|
|
38
|
-
"
|
|
39
|
-
"parent" text,
|
|
38
|
+
"parent_id" text NOT NULL DEFAULT '',
|
|
40
39
|
"name" text NOT NULL,
|
|
40
|
+
"path" text NOT NULL,
|
|
41
41
|
"created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
42
|
-
|
|
42
|
+
"updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
43
|
+
CONSTRAINT "storage_folder_scope_path_uk" UNIQUE ("scope", "path"),
|
|
44
|
+
CONSTRAINT "storage_folder_scope_parent_name_uk" UNIQUE ("scope", "parent_id", "name")
|
|
43
45
|
);
|
|
44
46
|
|
|
45
|
-
CREATE INDEX "storage_folder_scope_parent_idx" ON "storage_folder" ("scope", "parent");
|
|
46
|
-
|
|
47
47
|
-- Schema version for the Kysely and Prisma adapters.
|
|
48
48
|
CREATE TABLE "private_dimah_s3_settings" (
|
|
49
49
|
"key" varchar(255) PRIMARY KEY NOT NULL,
|
|
50
|
-
"value" text NOT NULL DEFAULT '2.
|
|
50
|
+
"value" text NOT NULL DEFAULT '2.1.0'
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
INSERT INTO "private_dimah_s3_settings" ("key", "value") VALUES ('version', '2.
|
|
53
|
+
INSERT INTO "private_dimah_s3_settings" ("key", "value") VALUES ('version', '2.1.0');
|
package/sql/sqlite.sql
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
-- @dimah-s3/db schema 2.
|
|
1
|
+
-- @dimah-s3/db schema 2.1.0 for SQLite.
|
|
2
2
|
-- Timestamps are epoch milliseconds. Sizes are INTEGER.
|
|
3
3
|
|
|
4
4
|
CREATE TABLE "storage_object" (
|
|
@@ -7,7 +7,7 @@ CREATE TABLE "storage_object" (
|
|
|
7
7
|
"bucket" text NOT NULL,
|
|
8
8
|
"key" text NOT NULL,
|
|
9
9
|
"route" text NOT NULL,
|
|
10
|
-
"
|
|
10
|
+
"folder_id" text,
|
|
11
11
|
"filename" text NOT NULL,
|
|
12
12
|
"content_type" text,
|
|
13
13
|
"size" integer,
|
|
@@ -27,7 +27,7 @@ CREATE TABLE "storage_object" (
|
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
CREATE UNIQUE INDEX "storage_object_bucket_key_uk" ON "storage_object" ("bucket", "key");
|
|
30
|
-
CREATE INDEX "storage_object_scope_folder_idx" ON "storage_object" ("scope", "status", "
|
|
30
|
+
CREATE INDEX "storage_object_scope_folder_idx" ON "storage_object" ("scope", "status", "folder_id", "created_at");
|
|
31
31
|
CREATE INDEX "storage_object_scope_updated_idx" ON "storage_object" ("scope", "status", "updated_at");
|
|
32
32
|
CREATE INDEX "storage_object_scope_filename_idx" ON "storage_object" ("scope", "status", "filename");
|
|
33
33
|
CREATE INDEX "storage_object_scope_size_idx" ON "storage_object" ("scope", "status", "size");
|
|
@@ -36,19 +36,20 @@ CREATE INDEX "storage_object_status_expires_idx" ON "storage_object" ("status",
|
|
|
36
36
|
CREATE TABLE "storage_folder" (
|
|
37
37
|
"id" text PRIMARY KEY NOT NULL,
|
|
38
38
|
"scope" text NOT NULL,
|
|
39
|
-
"
|
|
40
|
-
"parent" text,
|
|
39
|
+
"parent_id" text NOT NULL DEFAULT '',
|
|
41
40
|
"name" text NOT NULL,
|
|
42
|
-
"
|
|
41
|
+
"path" text NOT NULL,
|
|
42
|
+
"created_at" integer NOT NULL DEFAULT (strftime('%s', 'now') * 1000),
|
|
43
|
+
"updated_at" integer NOT NULL DEFAULT (strftime('%s', 'now') * 1000)
|
|
43
44
|
);
|
|
44
45
|
|
|
45
46
|
CREATE UNIQUE INDEX "storage_folder_scope_path_uk" ON "storage_folder" ("scope", "path");
|
|
46
|
-
CREATE INDEX "
|
|
47
|
+
CREATE UNIQUE INDEX "storage_folder_scope_parent_name_uk" ON "storage_folder" ("scope", "parent_id", "name");
|
|
47
48
|
|
|
48
49
|
-- Schema version for the Kysely and Prisma adapters.
|
|
49
50
|
CREATE TABLE "private_dimah_s3_settings" (
|
|
50
51
|
"key" text PRIMARY KEY NOT NULL,
|
|
51
|
-
"value" text NOT NULL DEFAULT '2.
|
|
52
|
+
"value" text NOT NULL DEFAULT '2.1.0'
|
|
52
53
|
);
|
|
53
54
|
|
|
54
|
-
INSERT INTO "private_dimah_s3_settings" ("key", "value") VALUES ('version', '2.
|
|
55
|
+
INSERT INTO "private_dimah_s3_settings" ("key", "value") VALUES ('version', '2.1.0');
|
package/src/drizzle/mysql.ts
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
|
|
32
32
|
type StorageObjectStatus = "pending" | "active" | "deleted" | "purging";
|
|
33
33
|
|
|
34
|
-
const SCHEMA_VERSION = "2.
|
|
34
|
+
const SCHEMA_VERSION = "2.1.0";
|
|
35
35
|
|
|
36
36
|
/** Collation of every text column but `filename`: byte for byte. */
|
|
37
37
|
const BINARY = "utf8mb4_bin";
|
|
@@ -75,7 +75,7 @@ export const storageObject = mysqlTable(
|
|
|
75
75
|
bucket: string("bucket").notNull(),
|
|
76
76
|
key: string("key", 1024).notNull(),
|
|
77
77
|
route: string("route").notNull(),
|
|
78
|
-
|
|
78
|
+
folderId: string("folder_id"),
|
|
79
79
|
filename: varchar("filename", { length: 255 })
|
|
80
80
|
.collate("utf8mb4_unicode_ci")
|
|
81
81
|
.notNull(),
|
|
@@ -103,7 +103,7 @@ export const storageObject = mysqlTable(
|
|
|
103
103
|
index("storage_object_scope_folder_idx").on(
|
|
104
104
|
table.scope,
|
|
105
105
|
table.status,
|
|
106
|
-
|
|
106
|
+
table.folderId,
|
|
107
107
|
table.createdAt,
|
|
108
108
|
),
|
|
109
109
|
index("storage_object_scope_updated_idx").on(
|
|
@@ -134,19 +134,22 @@ export const storageFolder = mysqlTable(
|
|
|
134
134
|
{
|
|
135
135
|
id: id(),
|
|
136
136
|
scope: string("scope").notNull(),
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
/** `""` is the root. */
|
|
138
|
+
parentId: string("parent_id").notNull().default(""),
|
|
139
139
|
name: string("name").notNull(),
|
|
140
|
+
path: string("path", 1024).notNull(),
|
|
140
141
|
createdAt: timestampNow("created_at"),
|
|
142
|
+
updatedAt: timestampNow("updated_at"),
|
|
141
143
|
},
|
|
142
144
|
(table) => [
|
|
143
145
|
uniqueIndex("storage_folder_scope_path_uk").on(
|
|
144
146
|
table.scope,
|
|
145
147
|
prefix(table.path, 512),
|
|
146
148
|
),
|
|
147
|
-
|
|
149
|
+
uniqueIndex("storage_folder_scope_parent_name_uk").on(
|
|
148
150
|
table.scope,
|
|
149
|
-
|
|
151
|
+
table.parentId,
|
|
152
|
+
table.name,
|
|
150
153
|
),
|
|
151
154
|
],
|
|
152
155
|
);
|
package/src/drizzle/pg.ts
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
|
|
27
27
|
type StorageObjectStatus = "pending" | "active" | "deleted" | "purging";
|
|
28
28
|
|
|
29
|
-
const SCHEMA_VERSION = "2.
|
|
29
|
+
const SCHEMA_VERSION = "2.1.0";
|
|
30
30
|
|
|
31
31
|
function id() {
|
|
32
32
|
return varchar("id", { length: 255 })
|
|
@@ -54,7 +54,7 @@ export const storageObject = pgTable(
|
|
|
54
54
|
bucket: text("bucket").notNull(),
|
|
55
55
|
key: text("key").notNull(),
|
|
56
56
|
route: text("route").notNull(),
|
|
57
|
-
|
|
57
|
+
folderId: text("folder_id"),
|
|
58
58
|
filename: text("filename").notNull(),
|
|
59
59
|
contentType: text("content_type"),
|
|
60
60
|
size: byteCount("size"),
|
|
@@ -77,7 +77,7 @@ export const storageObject = pgTable(
|
|
|
77
77
|
index("storage_object_scope_folder_idx").on(
|
|
78
78
|
table.scope,
|
|
79
79
|
table.status,
|
|
80
|
-
table.
|
|
80
|
+
table.folderId,
|
|
81
81
|
table.createdAt,
|
|
82
82
|
),
|
|
83
83
|
index("storage_object_scope_updated_idx").on(
|
|
@@ -108,14 +108,20 @@ export const storageFolder = pgTable(
|
|
|
108
108
|
{
|
|
109
109
|
id: id(),
|
|
110
110
|
scope: text("scope").notNull(),
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
/** `""` is the root. */
|
|
112
|
+
parentId: text("parent_id").notNull().default(""),
|
|
113
113
|
name: text("name").notNull(),
|
|
114
|
+
path: text("path").notNull(),
|
|
114
115
|
createdAt: timestampNow("created_at"),
|
|
116
|
+
updatedAt: timestampNow("updated_at"),
|
|
115
117
|
},
|
|
116
118
|
(table) => [
|
|
117
119
|
unique("storage_folder_scope_path_uk").on(table.scope, table.path),
|
|
118
|
-
|
|
120
|
+
unique("storage_folder_scope_parent_name_uk").on(
|
|
121
|
+
table.scope,
|
|
122
|
+
table.parentId,
|
|
123
|
+
table.name,
|
|
124
|
+
),
|
|
119
125
|
],
|
|
120
126
|
);
|
|
121
127
|
|