@dimah-s3/db 2.0.0-beta.1 → 2.0.0-beta.11
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 +19 -10
- package/dist/adapters/drizzle.d.ts +2 -3
- package/dist/adapters/drizzle.d.ts.map +1 -1
- package/dist/adapters/kysely.d.ts +1 -1
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/cli.d.ts +18 -13
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +57 -84
- 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 +15 -9
- package/dist/client/db-object-source.d.ts.map +1 -1
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +101 -21
- package/dist/client/index.js.map +1 -1
- package/dist/folder-path.d.ts +17 -4
- package/dist/folder-path.d.ts.map +1 -1
- package/dist/fuma-db.d.ts +23 -23
- package/dist/fuma-db.d.ts.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +843 -268
- package/dist/index.js.map +1 -1
- package/dist/plugin/create-database-endpoints.d.ts +46 -22
- package/dist/plugin/create-database-endpoints.d.ts.map +1 -1
- package/dist/plugin/create-database-lifecycle-hooks.d.ts +4 -4
- package/dist/plugin/create-database-lifecycle-hooks.d.ts.map +1 -1
- package/dist/plugin/db.d.ts +10 -2
- package/dist/plugin/db.d.ts.map +1 -1
- package/dist/plugin/object-access.d.ts +2 -2
- package/dist/plugin/object-access.d.ts.map +1 -1
- package/dist/plugin/public-stores.d.ts +5 -8
- package/dist/plugin/public-stores.d.ts.map +1 -1
- package/dist/plugin/quota.d.ts +1 -1
- package/dist/plugin/record.d.ts +58 -0
- package/dist/plugin/record.d.ts.map +1 -0
- package/dist/plugin/schemas.d.ts +25 -11
- package/dist/plugin/schemas.d.ts.map +1 -1
- package/dist/plugin/scope.d.ts +2 -0
- package/dist/plugin/scope.d.ts.map +1 -1
- package/dist/plugin/to-db-client-object.d.ts.map +1 -1
- package/dist/schema/schema.d.ts +48 -49
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/store/create-db-store.d.ts +2 -2
- package/dist/store/create-db-store.d.ts.map +1 -1
- package/dist/store/folder-store.d.ts +73 -15
- package/dist/store/folder-store.d.ts.map +1 -1
- package/dist/store/list-cursor.d.ts +3 -1
- package/dist/store/list-cursor.d.ts.map +1 -1
- package/dist/store/map-row.d.ts +3 -9
- package/dist/store/map-row.d.ts.map +1 -1
- package/dist/store/object-store.d.ts +42 -10
- package/dist/store/object-store.d.ts.map +1 -1
- package/dist/store/search-name.d.ts +7 -0
- package/dist/store/search-name.d.ts.map +1 -0
- package/dist/types/client.d.ts +114 -23
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +19 -7
- 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 +15 -33
- package/dist/drizzle/mysql.d.ts +0 -1025
- package/dist/drizzle/mysql.d.ts.map +0 -1
- package/dist/drizzle/mysql.js +0 -117
- package/dist/drizzle/mysql.js.map +0 -1
- package/dist/drizzle/pg.d.ts +0 -964
- package/dist/drizzle/pg.d.ts.map +0 -1
- package/dist/drizzle/pg.js +0 -98
- package/dist/drizzle/pg.js.map +0 -1
- package/dist/drizzle/shared.d.ts +0 -7
- package/dist/drizzle/shared.d.ts.map +0 -1
- package/dist/drizzle/sqlite.d.ts +0 -1024
- package/dist/drizzle/sqlite.d.ts.map +0 -1
- package/dist/drizzle/sqlite.js +0 -101
- package/dist/drizzle/sqlite.js.map +0 -1
- package/prisma/dimah-s3.prisma +0 -80
- package/sql/mysql.sql +0 -59
- package/sql/pg.sql +0 -53
- package/sql/sqlite.sql +0 -54
- package/src/drizzle/mysql.ts +0 -172
- package/src/drizzle/pg.ts +0 -140
- package/src/drizzle/sqlite.ts +0 -144
|
@@ -2,16 +2,18 @@ import type { DbStore } from "../store/create-db-store.js";
|
|
|
2
2
|
import type { DbClientFolder, DbClientListResponse, DbClientObject } from "../types/client.js";
|
|
3
3
|
import type { DbAttributesOptions } from "../types/plugin.js";
|
|
4
4
|
import type { StorageObject } from "../types/storage-object.js";
|
|
5
|
-
import type { ObjectAccess } from "./object-access";
|
|
6
|
-
import type { DbObjects } from "./public-stores";
|
|
7
|
-
import type { Quota } from "./quota";
|
|
5
|
+
import type { ObjectAccess } from "./object-access.js";
|
|
6
|
+
import type { DbObjects } from "./public-stores.js";
|
|
7
|
+
import type { Quota } from "./quota.js";
|
|
8
|
+
import type { ScopeResolver } from "./scope.js";
|
|
8
9
|
/** Largest JSON size of stored attributes when `maxBytes` is not set. */
|
|
9
10
|
export declare const DEFAULT_ATTRIBUTES_MAX_BYTES = 16384;
|
|
10
11
|
export type CreateDatabaseEndpointsOptions<TSession, TAttributes, TClientAttributes> = {
|
|
11
12
|
store: Pick<DbStore<TAttributes>, "objects" | "folders">;
|
|
12
|
-
/** The public object store, whose `update`
|
|
13
|
+
/** The public object store, whose `update` checks the folder and retains it. */
|
|
13
14
|
objects: Pick<DbObjects<TAttributes>, "update">;
|
|
14
15
|
access: ObjectAccess<TSession, TAttributes>;
|
|
16
|
+
resolveScope: ScopeResolver<TSession>;
|
|
15
17
|
quota: Pick<Quota<TSession>, "limits">;
|
|
16
18
|
/** The plugin's `attributes` option. Without it, PATCH refuses `attributes`. */
|
|
17
19
|
attributes?: DbAttributesOptions<TAttributes, TClientAttributes>;
|
|
@@ -21,23 +23,26 @@ export type CreateDatabaseEndpointsOptions<TSession, TAttributes, TClientAttribu
|
|
|
21
23
|
* The `db` plugin's HTTP endpoints. Each one resolves the caller's scope and
|
|
22
24
|
* runs `authorize` before it reads or writes a row:
|
|
23
25
|
*
|
|
24
|
-
* - `GET /db/objects` (op `list`): one page of the scope's objects
|
|
25
|
-
*
|
|
26
|
-
*
|
|
26
|
+
* - `GET /db/objects` (op `list`): one page of the scope's objects, from
|
|
27
|
+
* one folder or, with `recursive`, from it and every folder below. The
|
|
28
|
+
* first page also carries usage, the quota, the folders (those whose name
|
|
29
|
+
* contains `search`, when it is set), the breadcrumb trail, and a
|
|
30
|
+
* search's `total`. A recursive page carries the `locations` of its rows.
|
|
27
31
|
* - `GET /db/object` (op `read`): one object.
|
|
28
32
|
* - `PATCH /db/object` (op `update`): renames, moves, or sets attributes.
|
|
29
|
-
* - `POST /db/folder` and `DELETE /db/folder`
|
|
30
|
-
*
|
|
33
|
+
* - `POST /db/folder`, `PATCH /db/folder`, and `DELETE /db/folder`
|
|
34
|
+
* (op `update`): create a folder, rename or move it, or remove an empty one.
|
|
31
35
|
*/
|
|
32
36
|
export declare function createDatabaseEndpoints<TSession, TAttributes, TClientAttributes>(options: CreateDatabaseEndpointsOptions<TSession, TAttributes, TClientAttributes>): {
|
|
33
|
-
/** One page of the caller's objects. `
|
|
37
|
+
/** One page of the caller's objects. `folderId` omitted lists every folder. */
|
|
34
38
|
objects: import("better-call").StrictEndpoint<string, {
|
|
35
39
|
use: import("better-call").MiddlewareHandler[];
|
|
36
40
|
} & {
|
|
37
41
|
method: "GET";
|
|
38
42
|
} & {
|
|
39
43
|
query: import("better-call").StandardSchemaV1<{
|
|
40
|
-
|
|
44
|
+
folderId?: string | undefined;
|
|
45
|
+
recursive?: "false" | "true" | boolean | undefined;
|
|
41
46
|
route?: string | undefined;
|
|
42
47
|
status?: "active" | "deleted" | "pending" | undefined;
|
|
43
48
|
contentType?: unknown;
|
|
@@ -49,7 +54,8 @@ export declare function createDatabaseEndpoints<TSession, TAttributes, TClientAt
|
|
|
49
54
|
limit?: string | number | undefined;
|
|
50
55
|
cursor?: unknown;
|
|
51
56
|
}, {
|
|
52
|
-
|
|
57
|
+
folderId?: string | undefined;
|
|
58
|
+
recursive?: "false" | "true" | boolean | undefined;
|
|
53
59
|
route?: string | undefined;
|
|
54
60
|
status?: "active" | "deleted" | "pending" | undefined;
|
|
55
61
|
contentType?: unknown;
|
|
@@ -80,8 +86,7 @@ export declare function createDatabaseEndpoints<TSession, TAttributes, TClientAt
|
|
|
80
86
|
}>;
|
|
81
87
|
/**
|
|
82
88
|
* Renames, moves, or sets the attributes of an active object. A move
|
|
83
|
-
*
|
|
84
|
-
* created when missing.
|
|
89
|
+
* requires the target folder to exist and authorizes that folder.
|
|
85
90
|
*/
|
|
86
91
|
updateObject: import("better-call").StrictEndpoint<string, {
|
|
87
92
|
use: import("better-call").MiddlewareHandler[];
|
|
@@ -91,27 +96,46 @@ export declare function createDatabaseEndpoints<TSession, TAttributes, TClientAt
|
|
|
91
96
|
key: string;
|
|
92
97
|
bucket?: string | undefined;
|
|
93
98
|
filename?: string | undefined;
|
|
94
|
-
|
|
99
|
+
folderId?: string | null | undefined;
|
|
95
100
|
attributes?: Record<string, unknown> | null | undefined;
|
|
96
101
|
}, {
|
|
97
102
|
key: string;
|
|
98
103
|
bucket?: string | undefined;
|
|
99
104
|
filename?: string | undefined;
|
|
100
|
-
|
|
105
|
+
folderId?: string | null | undefined;
|
|
101
106
|
attributes?: Record<string, unknown> | null | undefined;
|
|
102
107
|
}>;
|
|
103
108
|
}, {
|
|
104
109
|
object: DbClientObject<TClientAttributes>;
|
|
105
110
|
}>;
|
|
106
|
-
/** Creates
|
|
111
|
+
/** Creates one folder inside a parent that already exists. */
|
|
107
112
|
createFolder: import("better-call").StrictEndpoint<string, {
|
|
108
113
|
use: import("better-call").MiddlewareHandler[];
|
|
109
114
|
} & {
|
|
110
115
|
method: "POST";
|
|
111
116
|
body: import("better-call").StandardSchemaV1<{
|
|
112
|
-
|
|
117
|
+
parentId?: string | null | undefined;
|
|
118
|
+
name: string;
|
|
113
119
|
}, {
|
|
114
|
-
|
|
120
|
+
parentId?: string | null | undefined;
|
|
121
|
+
name: string;
|
|
122
|
+
}>;
|
|
123
|
+
}, {
|
|
124
|
+
folder: DbClientFolder;
|
|
125
|
+
}>;
|
|
126
|
+
/** Renames a folder, moves it, or both. */
|
|
127
|
+
updateFolder: import("better-call").StrictEndpoint<string, {
|
|
128
|
+
use: import("better-call").MiddlewareHandler[];
|
|
129
|
+
} & {
|
|
130
|
+
method: "PATCH";
|
|
131
|
+
body: import("better-call").StandardSchemaV1<{
|
|
132
|
+
id: string;
|
|
133
|
+
name?: string | undefined;
|
|
134
|
+
parentId?: string | null | undefined;
|
|
135
|
+
}, {
|
|
136
|
+
id: string;
|
|
137
|
+
name?: string | undefined;
|
|
138
|
+
parentId?: string | null | undefined;
|
|
115
139
|
}>;
|
|
116
140
|
}, {
|
|
117
141
|
folder: DbClientFolder;
|
|
@@ -124,12 +148,12 @@ export declare function createDatabaseEndpoints<TSession, TAttributes, TClientAt
|
|
|
124
148
|
body: import("better-call").StandardSchemaV1<unknown, unknown>;
|
|
125
149
|
} & {
|
|
126
150
|
query: import("better-call").StandardSchemaV1<{
|
|
127
|
-
|
|
151
|
+
id: string;
|
|
128
152
|
}, {
|
|
129
|
-
|
|
153
|
+
id: string;
|
|
130
154
|
}>;
|
|
131
155
|
}, {
|
|
132
|
-
|
|
156
|
+
id: string;
|
|
133
157
|
}>;
|
|
134
158
|
};
|
|
135
159
|
//# sourceMappingURL=create-database-endpoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-database-endpoints.d.ts","sourceRoot":"","sources":["../../src/plugin/create-database-endpoints.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,cAAc,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"create-database-endpoints.d.ts","sourceRoot":"","sources":["../../src/plugin/create-database-endpoints.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,cAAc,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAW7C,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD,MAAM,MAAM,8BAA8B,CACxC,QAAQ,EACR,WAAW,EACX,iBAAiB,IACf;IACF,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IACzD,gFAAgF;IAChF,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC;IAChD,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC5C,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACtC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;IACvC,gFAAgF;IAChF,UAAU,CAAC,EAAE,mBAAmB,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;IACjE,cAAc,EAAE,CACd,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,KAC/B,cAAc,CAAC,iBAAiB,CAAC,CAAC;CACxC,CAAC;AA+DF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EACR,WAAW,EACX,iBAAiB,EAEjB,OAAO,EAAE,8BAA8B,CACrC,QAAQ,EACR,WAAW,EACX,iBAAiB,CAClB;IAiDC,+EAA+E;IAC/E,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwFP,wCAAwC;IACxC,MAAM;;;;;;;;;;;;;gBAG2B,cAAc,CAAC,iBAAiB,CAAC;;IAiBlE;;;OAGG;IACH,YAAY;;;;;;;;;;;;;;;;;;gBAGqB,cAAc,CAAC,iBAAiB,CAAC;;IAmDlE,8DAA8D;IAC9D,YAAY;;;;;;;;;;;;gBAGqB,cAAc;;IAmB/C,2CAA2C;IAC3C,YAAY;;;;;;;;;;;;;;gBAGqB,cAAc;;IA4B/C,iEAAiE;IACjE,YAAY;;;;;;;;;;;;YAGiB,MAAM;;EAatC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type S3Client } from "@aws-sdk/client-s3";
|
|
2
2
|
import type { DimahS3PluginHooks } from "@dimah-s3/server/plugins";
|
|
3
3
|
import type { DbStore } from "../store/create-db-store.js";
|
|
4
|
-
import type { ObjectAccess } from "./object-access";
|
|
5
|
-
import type { Quota } from "./quota";
|
|
6
|
-
import type { ScopeResolver } from "./scope";
|
|
4
|
+
import type { ObjectAccess } from "./object-access.js";
|
|
5
|
+
import type { Quota } from "./quota.js";
|
|
6
|
+
import type { ScopeResolver } from "./scope.js";
|
|
7
7
|
/** What the hooks read from the dimah-s3 config, once `init` has run. */
|
|
8
8
|
export type DbRoutes = {
|
|
9
9
|
/** False when the route sets `plugins: { db: false }`. */
|
|
@@ -29,7 +29,7 @@ export type CreateDatabaseLifecycleHooksOptions<TSession, TAttributes> = {
|
|
|
29
29
|
* - `ticketSubject` binds upload tickets to the scope.
|
|
30
30
|
* - `upload.guard` checks the folder, ownership of the key, `authorize`
|
|
31
31
|
* (with the object an overwrite replaces), and the quota; `onStart` writes
|
|
32
|
-
* the pending row, then its
|
|
32
|
+
* the pending row, then retains its folder. An overwrite leaves the active row in
|
|
33
33
|
* place until it is confirmed.
|
|
34
34
|
* - `confirmGuard` and `multipart.guard` accept only the row of the ticket's
|
|
35
35
|
* upload, or a confirm it already finished; `onConfirmed` checks the quota
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-database-lifecycle-hooks.d.ts","sourceRoot":"","sources":["../../src/plugin/create-database-lifecycle-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"create-database-lifecycle-hooks.d.ts","sourceRoot":"","sources":["../../src/plugin/create-database-lifecycle-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIvD,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG;IACrB,0DAA0D;IAC1D,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACpC,wCAAwC;IACxC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IACpD,8BAA8B;IAC9B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,QAAQ,GAAG,SAAS,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,mCAAmC,CAAC,QAAQ,EAAE,WAAW,IAAI;IACvE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IACzD,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC5C,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvB,sBAAsB;IACtB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,MAAM,EAAE,QAAQ,CAAC;CAClB,CAAC;AA6DF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,WAAW,EAChE,OAAO,EAAE,mCAAmC,CAAC,QAAQ,EAAE,WAAW,CAAC,GAClE,kBAAkB,CA4PpB"}
|
package/dist/plugin/db.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { type DimahS3Plugin } from "@dimah-s3/server/plugins";
|
|
2
2
|
import type { DbPluginOptions } from "../types/plugin.js";
|
|
3
|
-
import
|
|
4
|
-
import { type
|
|
3
|
+
import type { StorageObject } from "../types/storage-object.js";
|
|
4
|
+
import { type DbFolders, type DbObjects } from "./public-stores.js";
|
|
5
|
+
import { type Purge } from "./purge.js";
|
|
6
|
+
import { type RecordObjectCall, type RecordObjectInput } from "./record.js";
|
|
5
7
|
/** What `db()` exposes on `s3.db` and `s3.context.db`. */
|
|
6
8
|
export type DbPluginContext<TAttributes = never> = {
|
|
7
9
|
/** The `storage_object` rows: listings, usage, and your own changes. */
|
|
8
10
|
objects: DbObjects<TAttributes>;
|
|
9
11
|
/** The `storage_folder` rows. */
|
|
10
12
|
folders: DbFolders;
|
|
13
|
+
/**
|
|
14
|
+
* Writes an active row for an object already in the bucket. It HEADs the
|
|
15
|
+
* object, runs the instance and route guards, then the scope, authorize,
|
|
16
|
+
* route file limits, and quota. It does not copy or delete bytes.
|
|
17
|
+
*/
|
|
18
|
+
record: (input: RecordObjectInput, call?: RecordObjectCall) => Promise<StorageObject<TAttributes>>;
|
|
11
19
|
/**
|
|
12
20
|
* Throws unless the database is at the schema this version needs. Call it
|
|
13
21
|
* at startup to fail fast; the first query runs the same check.
|
package/dist/plugin/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/plugin/db.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/plugin/db.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAO5D,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,UAAU,CAAC;AAIlB,0DAA0D;AAC1D,MAAM,MAAM,eAAe,CAAC,WAAW,GAAG,KAAK,IAAI;IACjD,wEAAwE;IACxE,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAChC,iCAAiC;IACjC,OAAO,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,MAAM,EAAE,CACN,KAAK,EAAE,iBAAiB,EACxB,IAAI,CAAC,EAAE,gBAAgB,KACpB,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;IACzC;;;OAGG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,GAAG,KAAK,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,EAAE,CAChB,QAAQ,GAAG,SAAS,EACpB,WAAW,GAAG,KAAK,EACnB,iBAAiB,GAAG,WAAW,EAE/B,OAAO,EAAE,eAAe,CAAC,QAAQ,EAAE,WAAW,EAAE,iBAAiB,CAAC,GACjE,aAAa,CAAC,IAAI,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC,CAmEnD"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ObjectRef, StorageObjectStore } from "../store/object-store.js";
|
|
2
2
|
import type { AuthorizeContext, DbPluginOptions } from "../types/plugin.js";
|
|
3
3
|
import type { StorageObject } from "../types/storage-object.js";
|
|
4
|
-
import type { ResolvedScope, ScopeCall, ScopeResolver, ScopeTarget } from "./scope";
|
|
4
|
+
import type { ResolvedScope, ScopeCall, ScopeResolver, ScopeTarget } from "./scope.js";
|
|
5
5
|
/** What a call targets: its scope target, plus what `authorize` checks. */
|
|
6
|
-
export type AccessTarget = ScopeTarget & Pick<AuthorizeContext, "key" | "folder" | "clientMetadata">;
|
|
6
|
+
export type AccessTarget = ScopeTarget & Pick<AuthorizeContext, "key" | "folder" | "folderId" | "recursive" | "clientMetadata">;
|
|
7
7
|
export type CreateObjectAccessOptions<TSession, TAttributes> = Pick<DbPluginOptions<TSession, TAttributes>, "authorize"> & {
|
|
8
8
|
objects: Pick<StorageObjectStore<TAttributes>, "find">;
|
|
9
9
|
resolveScope: ScopeResolver<TSession>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-access.d.ts","sourceRoot":"","sources":["../../src/plugin/object-access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACb,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,2EAA2E;AAC3E,MAAM,MAAM,YAAY,GAAG,WAAW,GACpC,IAAI,
|
|
1
|
+
{"version":3,"file":"object-access.d.ts","sourceRoot":"","sources":["../../src/plugin/object-access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACb,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,2EAA2E;AAC3E,MAAM,MAAM,YAAY,GAAG,WAAW,GACpC,IAAI,CACF,gBAAgB,EAChB,KAAK,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,gBAAgB,CAC/D,CAAC;AAEJ,MAAM,MAAM,yBAAyB,CAAC,QAAQ,EAAE,WAAW,IAAI,IAAI,CACjE,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC,EACtC,WAAW,CACZ,GAAG;IACF,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;IACvD,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CACvC,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,CAAC,QAAQ,EAAE,WAAW,IAAI;IACpD,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,YAAY,CAAC,QAAQ,EAAE,WAAW,IAAI;IAChD;;;;OAIG;IACH,KAAK,EAAE,CACL,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,YAAY,KACjB,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtC;;;;;;;OAOG;IACH,MAAM,EAAE,CACN,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,EACd,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,KACjC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IACtD;;;OAGG;IACH,WAAW,EAAE,CACX,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,EAC9B,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,EAClC,MAAM,CAAC,EAAE,YAAY,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,WAAW,EACtD,OAAO,EAAE,yBAAyB,CAAC,QAAQ,EAAE,WAAW,CAAC,GACxD,YAAY,CAAC,QAAQ,EAAE,WAAW,CAAC,CAiDrC"}
|
|
@@ -11,20 +11,17 @@ import type { StorageObject } from "../types/storage-object.js";
|
|
|
11
11
|
export type DbObjects<TAttributes = never> = Pick<StorageObjectStore<TAttributes>, "find" | "list" | "count" | "getUsage"> & {
|
|
12
12
|
/**
|
|
13
13
|
* Renames, moves, or sets the attributes of an active row, like
|
|
14
|
-
* `PATCH /db/object` without its access check. A
|
|
15
|
-
* (`
|
|
16
|
-
* that row changes. Returns `null` when no active row matches.
|
|
14
|
+
* `PATCH /db/object` without its access check. A `folderId` must already
|
|
15
|
+
* exist in the row's scope (`FOLDER_NOT_FOUND`). With `id` or `scope`,
|
|
16
|
+
* only that row changes. Returns `null` when no active row matches.
|
|
17
17
|
*/
|
|
18
18
|
update: (ref: ObjectRef & {
|
|
19
19
|
id?: string;
|
|
20
20
|
scope?: string;
|
|
21
21
|
}, input: UpdateObjectInput<TAttributes>) => Promise<StorageObject<TAttributes> | null>;
|
|
22
22
|
};
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
* HTTP endpoints (`FOLDER_INVALID`); the root (`null`) is never stored.
|
|
26
|
-
*/
|
|
27
|
-
export type DbFolders = StorageFolderStore;
|
|
23
|
+
/** `s3.db.folders`: the `storage_folder` rows. The root is never stored. */
|
|
24
|
+
export type DbFolders = Omit<StorageFolderStore, "subtreeIds">;
|
|
28
25
|
/** The public stores over the plugin's stores. */
|
|
29
26
|
export declare function createPublicStores<TAttributes>(store: Pick<DbStore<TAttributes>, "objects" | "folders">): {
|
|
30
27
|
objects: DbObjects<TAttributes>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-stores.d.ts","sourceRoot":"","sources":["../../src/plugin/public-stores.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"public-stores.d.ts","sourceRoot":"","sources":["../../src/plugin/public-stores.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,MAAM,SAAS,CAAC,WAAW,GAAG,KAAK,IAAI,IAAI,CAC/C,kBAAkB,CAAC,WAAW,CAAC,EAC/B,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CACvC,GAAG;IACF;;;;;OAKG;IACH,MAAM,EAAE,CACN,GAAG,EAAE,SAAS,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAChD,KAAK,EAAE,iBAAiB,CAAC,WAAW,CAAC,KAClC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;CACjD,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;AAwB/D,kDAAkD;AAClD,wBAAgB,kBAAkB,CAAC,WAAW,EAC5C,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC,GACvD;IAAE,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAAC,OAAO,EAAE,SAAS,CAAA;CAAE,CA2BzD"}
|
package/dist/plugin/quota.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ObjectRef, StorageObjectStore } from "../store/object-store.js";
|
|
2
2
|
import type { DbQuota } from "../types/client.js";
|
|
3
3
|
import type { DbQuotaOption } from "../types/plugin.js";
|
|
4
|
-
import type { ResolvedScope } from "./scope";
|
|
4
|
+
import type { ResolvedScope } from "./scope.js";
|
|
5
5
|
/** An upload checked against the caps of its scope. */
|
|
6
6
|
export type QuotaInput = {
|
|
7
7
|
/** Bytes the upload adds: the declared size, or the verified size at confirm. */
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { S3ServerCallOptions } from "@dimah-s3/server";
|
|
2
|
+
import { type PluginInitEnv } from "@dimah-s3/server/plugins";
|
|
3
|
+
import type { DbStore } from "../store/create-db-store.js";
|
|
4
|
+
import type { StorageObject } from "../types/storage-object.js";
|
|
5
|
+
import type { ObjectAccess } from "./object-access.js";
|
|
6
|
+
import type { Quota } from "./quota.js";
|
|
7
|
+
import type { ScopeResolver } from "./scope.js";
|
|
8
|
+
/**
|
|
9
|
+
* An object already in the bucket, to record as a row. The app put the
|
|
10
|
+
* bytes there itself: a copy, an import, or another writer. dimah-s3 does
|
|
11
|
+
* not copy them and does not delete them.
|
|
12
|
+
*/
|
|
13
|
+
export type RecordObjectInput = {
|
|
14
|
+
/** Named route whose namespace holds `key`. */
|
|
15
|
+
route: string;
|
|
16
|
+
/**
|
|
17
|
+
* Object key the app wrote, inside the route namespace. A key outside it
|
|
18
|
+
* is `KEY_INVALID`.
|
|
19
|
+
*/
|
|
20
|
+
key: string;
|
|
21
|
+
/**
|
|
22
|
+
* Folder that holds the object. `null` and `""` are the root. A missing
|
|
23
|
+
* id is `FOLDER_NOT_FOUND`.
|
|
24
|
+
*/
|
|
25
|
+
folderId?: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Display name, one path segment, at most 255 characters. Defaults to
|
|
28
|
+
* the last segment of `key`.
|
|
29
|
+
*/
|
|
30
|
+
name?: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Who is recording: the same options as an in-process `s3.api` call.
|
|
34
|
+
* Instance and route guards run first and see `operation: "record"`.
|
|
35
|
+
* `locals` seeds them. `request` wins over `headers` and `signal`.
|
|
36
|
+
*/
|
|
37
|
+
export type RecordObjectCall = Pick<S3ServerCallOptions, "request" | "headers" | "signal" | "locals">;
|
|
38
|
+
export type CreateRecordOptions<TSession, TAttributes> = {
|
|
39
|
+
store: Pick<DbStore<TAttributes>, "objects" | "folders">;
|
|
40
|
+
resolveScope: ScopeResolver<TSession>;
|
|
41
|
+
access: ObjectAccess<TSession, TAttributes>;
|
|
42
|
+
quota: Quota<TSession>;
|
|
43
|
+
/** Set in `init`. `record` before `dimahS3()` returns cannot run. */
|
|
44
|
+
env: () => PluginInitEnv | undefined;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Records an object the app already put in the bucket. The size, type, and
|
|
48
|
+
* eTag come from HeadObject. Guards, `resolveScope`, and `authorize` run
|
|
49
|
+
* with `operation: "record"`, then the route's `fileTypes` and
|
|
50
|
+
* `maxFileSize`, then the quota.
|
|
51
|
+
*
|
|
52
|
+
* A second call for the same bytes (the same eTag and size, in the same
|
|
53
|
+
* scope) returns the row. A different object at that key is
|
|
54
|
+
* `OBJECT_EXISTS`. A row an upload or purge holds is `CONFLICT`. A deleted
|
|
55
|
+
* row is replaced. A refusal leaves the object where it is.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createRecord<TSession, TAttributes>(options: CreateRecordOptions<TSession, TAttributes>): (input: RecordObjectInput, call?: RecordObjectCall) => Promise<StorageObject<TAttributes>>;
|
|
58
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/plugin/record.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAMV,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAa,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,mBAAmB,EACnB,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAC5C,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,QAAQ,EAAE,WAAW,IAAI;IACvD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IACzD,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC5C,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvB,qEAAqE;IACrE,GAAG,EAAE,MAAM,aAAa,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,WAAW,EAChD,OAAO,EAAE,mBAAmB,CAAC,QAAQ,EAAE,WAAW,CAAC,WAK1C,iBAAiB,SAClB,gBAAgB,KACrB,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAoFvC"}
|
package/dist/plugin/schemas.d.ts
CHANGED
|
@@ -2,12 +2,16 @@ import * as z from "zod";
|
|
|
2
2
|
/** Most rows one page of `GET /db/objects` returns. */
|
|
3
3
|
export declare const DB_LIST_MAX_LIMIT = 100;
|
|
4
4
|
/**
|
|
5
|
-
* Query of `GET /db/objects`. `
|
|
6
|
-
*
|
|
5
|
+
* Query of `GET /db/objects`. `folderId` of `""` is the root. Omit it for a
|
|
6
|
+
* flat list. `recursive` also lists the folders below `folderId`. Blank
|
|
7
7
|
* `search`, `contentType`, and `cursor` values are omitted.
|
|
8
8
|
*/
|
|
9
9
|
export declare const dbListQuerySchema: z.ZodObject<{
|
|
10
|
-
|
|
10
|
+
folderId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
recursive: z.ZodOptional<z.ZodCodec<z.ZodUnion<readonly [z.ZodEnum<{
|
|
12
|
+
false: "false";
|
|
13
|
+
true: "true";
|
|
14
|
+
}>, z.ZodBoolean]>, z.ZodBoolean>>;
|
|
11
15
|
route: z.ZodOptional<z.ZodString>;
|
|
12
16
|
status: z.ZodOptional<z.ZodEnum<{
|
|
13
17
|
active: "active";
|
|
@@ -48,22 +52,32 @@ export declare const dbObjectQuerySchema: z.ZodObject<{
|
|
|
48
52
|
bucket: z.ZodOptional<z.ZodString>;
|
|
49
53
|
}, z.core.$strict>;
|
|
50
54
|
/**
|
|
51
|
-
* Body of `PATCH /db/object`. `
|
|
52
|
-
*
|
|
53
|
-
* `attributes.schema`.
|
|
55
|
+
* Body of `PATCH /db/object`. `folderId` of `null` or `""` is the root.
|
|
56
|
+
* `attributes` are checked by the plugin's `attributes.schema`.
|
|
54
57
|
*/
|
|
55
58
|
export declare const dbUpdateObjectBodySchema: z.ZodObject<{
|
|
56
59
|
key: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
57
60
|
bucket: z.ZodOptional<z.ZodString>;
|
|
58
61
|
filename: z.ZodOptional<z.ZodString>;
|
|
59
|
-
|
|
62
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
63
|
attributes: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
61
64
|
}, z.core.$strict>;
|
|
65
|
+
/** Body of `POST /db/folder`. `parentId` omitted, `null`, or `""` is the root. */
|
|
66
|
+
export declare const dbCreateFolderBodySchema: z.ZodObject<{
|
|
67
|
+
parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
68
|
+
name: z.ZodString;
|
|
69
|
+
}, z.core.$strict>;
|
|
62
70
|
/**
|
|
63
|
-
* Body of `
|
|
64
|
-
*
|
|
71
|
+
* Body of `PATCH /db/folder`. `parentId` of `null` or `""` is the root.
|
|
72
|
+
* The endpoint checks the name and that the folder is not moved into itself.
|
|
65
73
|
*/
|
|
66
|
-
export declare const
|
|
67
|
-
|
|
74
|
+
export declare const dbUpdateFolderBodySchema: z.ZodObject<{
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
name: z.ZodOptional<z.ZodString>;
|
|
77
|
+
parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
/** Query of `DELETE /db/folder`. */
|
|
80
|
+
export declare const dbDeleteFolderQuerySchema: z.ZodObject<{
|
|
81
|
+
id: z.ZodString;
|
|
68
82
|
}, z.core.$strict>;
|
|
69
83
|
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/plugin/schemas.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,uDAAuD;AACvD,eAAO,MAAM,iBAAiB,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/plugin/schemas.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,uDAAuD;AACvD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAiErC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAkB5B,CAAC;AAEH,iCAAiC;AACjC,eAAO,MAAM,mBAAmB;;;kBAG9B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;kBAOnC,CAAC;AAEH,kFAAkF;AAClF,eAAO,MAAM,wBAAwB;;;kBAGnC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;kBAInC,CAAC;AAEH,oCAAoC;AACpC,eAAO,MAAM,yBAAyB;;kBAEpC,CAAC"}
|
package/dist/plugin/scope.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export type ResolvedScope<TSession = undefined> = ScopeContext<TSession> & {
|
|
|
14
14
|
/**
|
|
15
15
|
* Resolves the scope of a call.
|
|
16
16
|
* @throws `UNAUTHORIZED` when `resolveScope` returns `null`.
|
|
17
|
+
* @throws a config error when the scope is longer than
|
|
18
|
+
* {@link SCOPE_MAX_LENGTH} characters.
|
|
17
19
|
*/
|
|
18
20
|
export type ScopeResolver<TSession = undefined> = (call: ScopeCall, target: ScopeTarget) => Promise<ResolvedScope<TSession>>;
|
|
19
21
|
export type CreateScopeResolverOptions<TSession> = Pick<DbPluginOptions<TSession>, "getSession" | "resolveScope">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/plugin/scope.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/plugin/scope.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEpE,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC;AAEpE,sDAAsD;AACtD,MAAM,MAAM,aAAa,CAAC,QAAQ,GAAG,SAAS,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG;IACzE,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,QAAQ,GAAG,SAAS,IAAI,CAChD,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,WAAW,KAChB,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEtC,MAAM,MAAM,0BAA0B,CAAC,QAAQ,IAAI,IAAI,CACrD,eAAe,CAAC,QAAQ,CAAC,EACzB,YAAY,GAAG,cAAc,CAC9B,CAAC;AAgBF;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAC1C,OAAO,EAAE,0BAA0B,CAAC,QAAQ,CAAC,GAC5C,aAAa,CAAC,QAAQ,CAAC,CA2CzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-db-client-object.d.ts","sourceRoot":"","sources":["../../src/plugin/to-db-client-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EAEf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE3E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,GAAG,WAAW,EAC3E,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,EAClC,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,WAAW,KAAK,iBAAiB,GACxD,cAAc,CAAC,iBAAiB,CAAC,CAyBnC;AAED,6DAA6D;AAC7D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"to-db-client-object.d.ts","sourceRoot":"","sources":["../../src/plugin/to-db-client-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EAEf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE3E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,GAAG,WAAW,EAC3E,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,EAClC,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,WAAW,KAAK,iBAAiB,GACxD,cAAc,CAAC,iBAAiB,CAAC,CAyBnC;AAED,6DAA6D;AAC7D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc,CAStE"}
|
package/dist/schema/schema.d.ts
CHANGED
|
@@ -1,73 +1,72 @@
|
|
|
1
|
-
import { type Column } from "fumadb/schema";
|
|
2
|
-
/** A secondary index, by SQL table and column names. */
|
|
3
|
-
export type SchemaIndex = {
|
|
4
|
-
name: string;
|
|
5
|
-
table: "storage_object" | "storage_folder";
|
|
6
|
-
columns: readonly string[];
|
|
7
|
-
};
|
|
8
1
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* them.
|
|
2
|
+
* Longest `search_name`, in characters. Folding can lengthen a name (`ß`
|
|
3
|
+
* becomes `ss`), so it has more room than the 255-character name.
|
|
12
4
|
*/
|
|
13
|
-
export declare const
|
|
5
|
+
export declare const SEARCH_NAME_MAX_LENGTH = 1024;
|
|
14
6
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* create the indexes on a new database. A finished database is at
|
|
18
|
-
* {@link dbSchema}.
|
|
7
|
+
* Longest scope `resolveScope` may return, in characters. The `scope`
|
|
8
|
+
* columns are `varchar(255)`.
|
|
19
9
|
*/
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const predecessor: import("fumadb/schema").Schema<"0.0.1", {}>;
|
|
10
|
+
export declare const SCOPE_MAX_LENGTH = 255;
|
|
22
11
|
/**
|
|
23
|
-
* The @dimah-s3/db schema, version `2.
|
|
24
|
-
*
|
|
12
|
+
* The @dimah-s3/db schema, version `2.2.0`. The tables, their indexes, and
|
|
13
|
+
* the MySQL collations and prefix lengths are all declared here, so FumaDB
|
|
14
|
+
* creates them (`migrate`) and generates them for Drizzle and Prisma.
|
|
25
15
|
*/
|
|
26
|
-
export declare const dbSchema: import("fumadb/schema").Schema<"2.
|
|
16
|
+
export declare const dbSchema: import("fumadb/schema").Schema<"2.2.0", {
|
|
27
17
|
storageObject: import("fumadb/schema").Table<{
|
|
28
18
|
id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
|
|
29
19
|
/** Owner, for example `user:123` or `org:acme`. */
|
|
30
|
-
scope:
|
|
31
|
-
bucket:
|
|
32
|
-
key:
|
|
20
|
+
scope: import("fumadb/schema").Column<`varchar(${number})`, string, string>;
|
|
21
|
+
bucket: import("fumadb/schema").Column<`varchar(${number})`, string, string>;
|
|
22
|
+
key: import("fumadb/schema").Column<`varchar(${number})`, string, string>;
|
|
33
23
|
/** Named dimah-s3 route that created the object. */
|
|
34
|
-
route:
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
filename: Column<"
|
|
38
|
-
|
|
24
|
+
route: import("fumadb/schema").Column<`varchar(${number})`, string, string>;
|
|
25
|
+
/** Folder that holds the object. `null` is the root. */
|
|
26
|
+
folderId: import("fumadb/schema").Column<`varchar(${number})`, string | null, string | null>;
|
|
27
|
+
filename: import("fumadb/schema").Column<"varchar(255)", string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* `filename` folded for search: lowercase, without accents, with `%`,
|
|
30
|
+
* `_`, and `\` kept literal. Search matches it on every database the
|
|
31
|
+
* same way.
|
|
32
|
+
*/
|
|
33
|
+
searchName: import("fumadb/schema").Column<`varchar(${number})`, string, string>;
|
|
34
|
+
contentType: import("fumadb/schema").Column<`varchar(${number})`, string | null, string | null>;
|
|
39
35
|
/** Verified size from HeadObject, set on confirm. */
|
|
40
|
-
size: Column<"bigint",
|
|
36
|
+
size: import("fumadb/schema").Column<"bigint", bigint | null, bigint | null>;
|
|
41
37
|
/** Size the client declared before confirm. Quota counts it while pending. */
|
|
42
|
-
declaredSize: Column<"bigint",
|
|
43
|
-
eTag:
|
|
44
|
-
status:
|
|
38
|
+
declaredSize: import("fumadb/schema").Column<"bigint", bigint | null, bigint | null>;
|
|
39
|
+
eTag: import("fumadb/schema").Column<`varchar(${number})`, string | null, string | null>;
|
|
40
|
+
status: import("fumadb/schema").Column<`varchar(${number})`, string, string>;
|
|
45
41
|
/** S3 user metadata of the verified object. */
|
|
46
|
-
s3Metadata: Column<"json", unknown, unknown>;
|
|
42
|
+
s3Metadata: import("fumadb/schema").Column<"json", unknown, unknown>;
|
|
47
43
|
/** App attributes, validated by the plugin's `attributes.schema`. */
|
|
48
|
-
attributes: Column<"json", unknown, unknown>;
|
|
49
|
-
acl:
|
|
44
|
+
attributes: import("fumadb/schema").Column<"json", unknown, unknown>;
|
|
45
|
+
acl: import("fumadb/schema").Column<`varchar(${number})`, string | null, string | null>;
|
|
50
46
|
/** Multipart upload ID while the row is pending. */
|
|
51
|
-
uploadId: Column<"string", string | null, string | null>;
|
|
47
|
+
uploadId: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
52
48
|
/** Token of the upload ticket that wrote the row. Confirm and purge match it. */
|
|
53
|
-
uploadToken:
|
|
49
|
+
uploadToken: import("fumadb/schema").Column<`varchar(${number})`, string | null, string | null>;
|
|
54
50
|
/** Confirm deadline of a pending row (the upload ticket's expiry). */
|
|
55
|
-
expiresAt: Column<"timestamp", Date | null, Date | null>;
|
|
56
|
-
confirmedAt: Column<"timestamp", Date | null, Date | null>;
|
|
57
|
-
createdAt: Column<"timestamp", Date | null, Date>;
|
|
58
|
-
updatedAt: Column<"timestamp", Date | null, Date>;
|
|
59
|
-
deletedAt: Column<"timestamp", Date | null, Date | null>;
|
|
51
|
+
expiresAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
52
|
+
confirmedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
53
|
+
createdAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
|
|
54
|
+
updatedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
|
|
55
|
+
deletedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
60
56
|
}, {}>;
|
|
61
57
|
storageFolder: import("fumadb/schema").Table<{
|
|
62
58
|
id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
|
|
63
|
-
scope:
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
/** Path of the containing folder. `null` is the root. */
|
|
67
|
-
parent: Column<"string", string | null, string | null>;
|
|
59
|
+
scope: import("fumadb/schema").Column<`varchar(${number})`, string, string>;
|
|
60
|
+
/** Id of the containing folder. `""` is the root. */
|
|
61
|
+
parentId: import("fumadb/schema").Column<`varchar(${number})`, string | null, string>;
|
|
68
62
|
/** Last segment of `path`. */
|
|
69
|
-
name:
|
|
70
|
-
|
|
63
|
+
name: import("fumadb/schema").Column<`varchar(${number})`, string, string>;
|
|
64
|
+
/** `name` folded for search, like `storage_object.search_name`. */
|
|
65
|
+
searchName: import("fumadb/schema").Column<`varchar(${number})`, string, string>;
|
|
66
|
+
/** Full folder path. */
|
|
67
|
+
path: import("fumadb/schema").Column<`varchar(${number})`, string, string>;
|
|
68
|
+
createdAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
|
|
69
|
+
updatedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
|
|
71
70
|
}, {}>;
|
|
72
71
|
}>;
|
|
73
72
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema/schema.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAS3C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,MAAM,CAAC;AA0FpC;;;;GAIG;AACH,eAAO,MAAM,QAAQ;;;QAlFnB,mDAAmD;;;;QAInD,oDAAoD;;QAEpD,wDAAwD;;;QAGxD;;;;WAIG;;;QAGH,qDAAqD;;QAErD,8EAA8E;;;;QAI9E,+CAA+C;;QAE/C,qEAAqE;;;QAGrE,oDAAoD;;QAEpD,iFAAiF;;QAEjF,sEAAsE;;;;;;;;;;QA8BtE,qDAAqD;;QAErD,8BAA8B;;QAE9B,mEAAmE;;QAEnE,wBAAwB;;;;;EAqBxB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DimahS3DbClient } from "../fuma-db.js";
|
|
2
|
-
import { type StorageFolderStore } from "./folder-store";
|
|
3
|
-
import { type StorageObjectStore } from "./object-store";
|
|
2
|
+
import { type StorageFolderStore } from "./folder-store.js";
|
|
3
|
+
import { type StorageObjectStore } from "./object-store.js";
|
|
4
4
|
/** The stores over one FumaDB client. */
|
|
5
5
|
export type DbStore<TAttributes = never> = {
|
|
6
6
|
objects: StorageObjectStore<TAttributes>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-db-store.d.ts","sourceRoot":"","sources":["../../src/store/create-db-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAqB,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAqB,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAG5E,yCAAyC;AACzC,MAAM,MAAM,OAAO,CAAC,WAAW,GAAG,KAAK,IAAI;IACzC,OAAO,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACzC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,kEAAkE;IAClE,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,WAAW,GAAG,KAAK,EAC/C,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"create-db-store.d.ts","sourceRoot":"","sources":["../../src/store/create-db-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAqB,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAqB,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAG5E,yCAAyC;AACzC,MAAM,MAAM,OAAO,CAAC,WAAW,GAAG,KAAK,IAAI;IACzC,OAAO,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACzC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,kEAAkE;IAClE,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,WAAW,GAAG,KAAK,EAC/C,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,WAAW,CAAC,CAmBtB"}
|