@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
|
@@ -1,35 +1,93 @@
|
|
|
1
1
|
import type { StorageFolder } from "../types/storage-object.js";
|
|
2
|
-
import { type GetDbOrm } from "./object-store";
|
|
2
|
+
import { type GetDbOrm } from "./object-store.js";
|
|
3
3
|
/** Most child folders `children` returns when `limit` is not given. */
|
|
4
4
|
export declare const DEFAULT_FOLDER_CHILDREN_LIMIT = 1000;
|
|
5
|
+
/** Most folders `descendants` returns when `limit` is not given. */
|
|
6
|
+
export declare const DEFAULT_FOLDER_DESCENDANTS_LIMIT = 1000;
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
+
* Most folders below the open one that a recursive listing covers. Their
|
|
9
|
+
* ids go into one `in` list, well under every driver's parameter cap.
|
|
10
|
+
*/
|
|
11
|
+
export declare const FOLDER_SUBTREE_LIMIT = 10000;
|
|
12
|
+
/** Where a new or moved folder sits. `null` is the root. */
|
|
13
|
+
export type FolderPlacement = {
|
|
14
|
+
parentId: string | null;
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Data access for the `storage_folder` table. A folder is its `id`. The
|
|
19
|
+
* root is not a row: a top-level folder stores `parent_id` as `""`, because
|
|
20
|
+
* a nullable parent cannot be unique. `path` is rewritten when the folder
|
|
21
|
+
* or one of its ancestors is renamed or moved.
|
|
8
22
|
*/
|
|
9
23
|
export type StorageFolderStore = {
|
|
10
|
-
/** Loads one folder. */
|
|
11
|
-
find: (scope: string,
|
|
12
|
-
/**
|
|
13
|
-
|
|
24
|
+
/** Loads one folder of the scope. */
|
|
25
|
+
find: (scope: string, id: string) => Promise<StorageFolder | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Ids of the folders below `id` at any depth, up to
|
|
28
|
+
* {@link FOLDER_SUBTREE_LIMIT}, in no order. Empty for a folder the scope
|
|
29
|
+
* does not have. Lookups for the same folder that overlap share one walk.
|
|
30
|
+
* @internal Recursive listings use it.
|
|
31
|
+
*/
|
|
32
|
+
subtreeIds: (scope: string, id: string) => Promise<string[]>;
|
|
33
|
+
/** Direct child folders of `parentId` (`null` is the root), by name. */
|
|
34
|
+
children: (scope: string, parentId: string | null, options?: {
|
|
14
35
|
limit?: number;
|
|
15
36
|
}) => Promise<StorageFolder[]>;
|
|
16
37
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* The root (`null`) needs nothing.
|
|
38
|
+
* The folders from the root down to `id`, including `id`.
|
|
39
|
+
* @throws `FOLDER_NOT_FOUND` when the scope has no such folder.
|
|
20
40
|
*/
|
|
21
|
-
|
|
41
|
+
trail: (scope: string, id: string) => Promise<StorageFolder[]>;
|
|
22
42
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
43
|
+
* Folders below `parentId` at any depth (`null`: every folder of the
|
|
44
|
+
* scope), by name, then path. With `search`, only those whose name
|
|
45
|
+
* contains it, folded the way file search folds (case, accents, and
|
|
46
|
+
* look-alike letters do not count). `parentId` itself is not included.
|
|
47
|
+
* @throws `FOLDER_NOT_FOUND` when `parentId` is not in the scope.
|
|
25
48
|
*/
|
|
26
|
-
|
|
49
|
+
descendants: (scope: string, parentId: string | null, options?: {
|
|
50
|
+
search?: string;
|
|
51
|
+
limit?: number;
|
|
52
|
+
}) => Promise<StorageFolder[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Every folder from the top level down to each of `ids`, `ids` included,
|
|
55
|
+
* once each, in path order. Ids the scope does not have are skipped.
|
|
56
|
+
* Draws the location of rows that come from several folders.
|
|
57
|
+
*/
|
|
58
|
+
ancestors: (scope: string, ids: readonly string[]) => Promise<StorageFolder[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Creates `name` inside `parentId`. The parent must already exist.
|
|
61
|
+
* @throws `FOLDER_NOT_FOUND` when the parent is missing.
|
|
62
|
+
* @throws `FOLDER_INVALID` when the name or the resulting path is not a
|
|
63
|
+
* folder path.
|
|
64
|
+
* @throws `FOLDER_EXISTS` when that parent already has the name.
|
|
65
|
+
*/
|
|
66
|
+
create: (scope: string, input: FolderPlacement) => Promise<StorageFolder>;
|
|
67
|
+
/**
|
|
68
|
+
* Renames `id`, moves it, or both. An omitted field stays as it is.
|
|
69
|
+
* `parentId: null` moves the folder to the root. Descendants keep their
|
|
70
|
+
* ids; their paths are rewritten.
|
|
71
|
+
* @throws `FOLDER_NOT_FOUND` when the folder or its new parent is missing.
|
|
72
|
+
* @throws `FOLDER_INVALID` when the name is not a folder name, the folder
|
|
73
|
+
* would sit inside itself, or a path would be too long or too deep.
|
|
74
|
+
* @throws `FOLDER_EXISTS` when the destination already has the name.
|
|
75
|
+
*/
|
|
76
|
+
update: (scope: string, id: string, input: {
|
|
77
|
+
name?: string;
|
|
78
|
+
parentId?: string | null;
|
|
79
|
+
}) => Promise<StorageFolder>;
|
|
27
80
|
/**
|
|
28
81
|
* Removes an empty folder. Removing a missing folder does nothing.
|
|
29
82
|
* @throws `FOLDER_NOT_EMPTY` when it has child folders, or active or
|
|
30
83
|
* pending objects.
|
|
31
84
|
*/
|
|
32
|
-
delete: (scope: string,
|
|
85
|
+
delete: (scope: string, id: string) => Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Puts `folder` back when a concurrent delete removed it, with the same
|
|
88
|
+
* id. An object written in between still points at that id.
|
|
89
|
+
*/
|
|
90
|
+
retain: (folder: StorageFolder) => Promise<void>;
|
|
33
91
|
};
|
|
34
92
|
/** Creates the `storage_folder` store over `getOrm`. */
|
|
35
93
|
export declare function createFolderStore(getOrm: GetDbOrm): StorageFolderStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder-store.d.ts","sourceRoot":"","sources":["../../src/store/folder-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"folder-store.d.ts","sourceRoot":"","sources":["../../src/store/folder-store.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAA0B,KAAK,QAAQ,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AE,MAAM,EACb,GAAG,EAAE,SAAS,MAAM,EAAE,KACnB,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC9B;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1E;;;;;;;;OAQG;IACH,MAAM,EAAE,CACN,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,EACV,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,KAC/C,OAAO,CAAC,aAAa,CAAC,CAAC;IAC5B;;;;OAIG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD;;;OAGG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD,CAAC;AAoDF,wDAAwD;AACxD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,GAAG,kBAAkB,CAoVtE"}
|
|
@@ -5,7 +5,9 @@ export declare const DEFAULT_LIST_SORT: DbListSort;
|
|
|
5
5
|
/** What a listing is filtered and ordered by. A cursor is only valid for these. */
|
|
6
6
|
export type ListCursorFilters = {
|
|
7
7
|
/** `undefined` lists every folder; `null` is the root. */
|
|
8
|
-
|
|
8
|
+
folderId: string | null | undefined;
|
|
9
|
+
/** The folders below `folderId` are listed too. */
|
|
10
|
+
recursive: boolean;
|
|
9
11
|
search: string | undefined;
|
|
10
12
|
status: StorageObjectStatus;
|
|
11
13
|
route: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-cursor.d.ts","sourceRoot":"","sources":["../../src/store/list-cursor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAmB,M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B,UAAU,GAAG,IAAI,CAYnB"}
|
package/dist/store/map-row.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { StorageObject } from "../types/storage-object.js";
|
|
2
|
-
/**
|
|
3
|
-
* A byte count as a driver returns it: a number, a bigint, or a string
|
|
4
|
-
* (PostgreSQL int8).
|
|
5
|
-
*/
|
|
6
|
-
type ByteCount = number | bigint | string | null;
|
|
7
2
|
/** Raw `storage_object` row as the FumaDB ORM returns it. */
|
|
8
3
|
export type StorageObjectRow = {
|
|
9
4
|
id: string;
|
|
@@ -11,11 +6,11 @@ export type StorageObjectRow = {
|
|
|
11
6
|
bucket: string;
|
|
12
7
|
key: string;
|
|
13
8
|
route: string;
|
|
14
|
-
|
|
9
|
+
folderId: string | null;
|
|
15
10
|
filename: string;
|
|
16
11
|
contentType: string | null;
|
|
17
|
-
size:
|
|
18
|
-
declaredSize:
|
|
12
|
+
size: bigint | null;
|
|
13
|
+
declaredSize: bigint | null;
|
|
19
14
|
eTag: string | null;
|
|
20
15
|
status: string;
|
|
21
16
|
s3Metadata: unknown;
|
|
@@ -31,5 +26,4 @@ export type StorageObjectRow = {
|
|
|
31
26
|
};
|
|
32
27
|
/** Normalizes a raw row: sizes become numbers, JSON columns are cast. */
|
|
33
28
|
export declare function mapStorageObjectRow<TAttributes = never>(row: StorageObjectRow): StorageObject<TAttributes>;
|
|
34
|
-
export {};
|
|
35
29
|
//# sourceMappingURL=map-row.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-row.d.ts","sourceRoot":"","sources":["../../src/store/map-row.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAEhC
|
|
1
|
+
{"version":3,"file":"map-row.d.ts","sourceRoot":"","sources":["../../src/store/map-row.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAEhC,6DAA6D;AAC7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,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;AAOF,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,WAAW,GAAG,KAAK,EACrD,GAAG,EAAE,gBAAgB,GACpB,aAAa,CAAC,WAAW,CAAC,CAyB5B"}
|
|
@@ -30,8 +30,8 @@ export type UploadRef = ObjectRef & {
|
|
|
30
30
|
export type UpsertPendingInput = ObjectRef & {
|
|
31
31
|
scope: string;
|
|
32
32
|
route: string;
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/** Folder that holds the object. `null` is the root. */
|
|
34
|
+
folderId: string | null;
|
|
35
35
|
filename: string;
|
|
36
36
|
contentType?: string | null;
|
|
37
37
|
/** Size the client declared. Quota counts it until the row expires. */
|
|
@@ -59,11 +59,33 @@ export type MarkActiveInput = UploadRef & {
|
|
|
59
59
|
s3Metadata?: Record<string, string> | null;
|
|
60
60
|
acl?: string | null;
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* An object already in the bucket, recorded as active. The size and eTag
|
|
64
|
+
* come from HeadObject. There is no upload token: purge does not own it.
|
|
65
|
+
*/
|
|
66
|
+
export type InsertActiveInput = ObjectRef & {
|
|
67
|
+
scope: string;
|
|
68
|
+
route: string;
|
|
69
|
+
/** Folder that holds the object. `null` is the root. */
|
|
70
|
+
folderId: string | null;
|
|
71
|
+
filename: string;
|
|
72
|
+
contentType: string | null;
|
|
73
|
+
/** Verified size from HeadObject. */
|
|
74
|
+
size: number;
|
|
75
|
+
eTag: string | null;
|
|
76
|
+
s3Metadata: Record<string, string> | null;
|
|
77
|
+
};
|
|
62
78
|
/** Which rows of a scope a listing or count covers. */
|
|
63
79
|
export type ObjectFilter = {
|
|
64
80
|
scope: string;
|
|
65
81
|
/** Folder to cover. `null` is the root. Omit for every folder. */
|
|
66
|
-
|
|
82
|
+
folderId?: string | null;
|
|
83
|
+
/**
|
|
84
|
+
* With `folderId`, also cover every folder below it, up to
|
|
85
|
+
* `FOLDER_SUBTREE_LIMIT` (10,000) folders. At the root that is the whole
|
|
86
|
+
* scope. A folder the scope does not have covers nothing.
|
|
87
|
+
*/
|
|
88
|
+
recursive?: boolean;
|
|
67
89
|
/**
|
|
68
90
|
* @default "active". `pending` covers only rows that have not expired.
|
|
69
91
|
*/
|
|
@@ -72,9 +94,10 @@ export type ObjectFilter = {
|
|
|
72
94
|
/** Exact type, or `type/*` for every subtype (`image/*`). */
|
|
73
95
|
contentType?: string;
|
|
74
96
|
/**
|
|
75
|
-
* Text the `filename` contains
|
|
76
|
-
*
|
|
77
|
-
*
|
|
97
|
+
* Text the `filename` contains. Both sides are folded the same way on
|
|
98
|
+
* every database: case, accents, and look-alike letters (`ي`/`ی`,
|
|
99
|
+
* `ك`/`ک`) do not count, Persian and Arabic-Indic digits match `0`–`9`,
|
|
100
|
+
* and `%`, `_`, and `\` match as themselves.
|
|
78
101
|
*/
|
|
79
102
|
search?: string;
|
|
80
103
|
};
|
|
@@ -99,8 +122,8 @@ export type ListObjectsPage<TAttributes = never> = {
|
|
|
99
122
|
/** Fields `update` changes. Omitted fields stay as they are. */
|
|
100
123
|
export type UpdateObjectInput<TAttributes = never> = {
|
|
101
124
|
filename?: string;
|
|
102
|
-
/** Folder
|
|
103
|
-
|
|
125
|
+
/** Folder id. `null` moves the object to the root. */
|
|
126
|
+
folderId?: string | null;
|
|
104
127
|
attributes?: TAttributes | null;
|
|
105
128
|
};
|
|
106
129
|
/** Data access for the `storage_object` table. It never calls S3. */
|
|
@@ -142,6 +165,12 @@ export type StorageObjectStore<TAttributes = never> = {
|
|
|
142
165
|
* purging, or taken by another upload).
|
|
143
166
|
*/
|
|
144
167
|
markActive: (input: MarkActiveInput) => Promise<StorageObject<TAttributes>>;
|
|
168
|
+
/**
|
|
169
|
+
* Writes an active row for an object already in the bucket. A deleted row
|
|
170
|
+
* at the key is replaced by a new one. An active row is `OBJECT_EXISTS`.
|
|
171
|
+
* A pending or purging row, or a concurrent insert, is `CONFLICT`.
|
|
172
|
+
*/
|
|
173
|
+
insertActive: (input: InsertActiveInput) => Promise<StorageObject<TAttributes>>;
|
|
145
174
|
/**
|
|
146
175
|
* Changes an active row. With `id` or `scope`, only that row, so a check
|
|
147
176
|
* made on it still holds. Returns `null` when no row matches.
|
|
@@ -202,7 +231,10 @@ export declare function uploadTokenOf(object: StorageObject<unknown>): string |
|
|
|
202
231
|
export declare function isUploading(object: StorageObject<unknown>): boolean;
|
|
203
232
|
/** Active rows, and pending rows whose confirm deadline has not passed. */
|
|
204
233
|
export declare function liveObject(b: ObjectConditions, now: Date): Condition;
|
|
205
|
-
/**
|
|
206
|
-
|
|
234
|
+
/**
|
|
235
|
+
* Creates the `storage_object` store over `getOrm`. `subtreeIds` lists the
|
|
236
|
+
* folders below a folder, for recursive listings.
|
|
237
|
+
*/
|
|
238
|
+
export declare function createObjectStore<TAttributes = never>(getOrm: GetDbOrm, subtreeIds: (scope: string, folderId: string) => Promise<string[]>): StorageObjectStore<TAttributes>;
|
|
207
239
|
export {};
|
|
208
240
|
//# sourceMappingURL=object-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-store.d.ts","sourceRoot":"","sources":["../../src/store/object-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"object-store.d.ts","sourceRoot":"","sources":["../../src/store/object-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAWhC,qDAAqD;AACrD,MAAM,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEnD,2DAA2D;AAC3D,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;AAE5C,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,GAAG,UAAU,CACvC,WAAW,CACT,eAAe,CAAC,CAAC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,CACpE,CACF,CAAC,CAAC,CAAC,CAAC;AAEL,KAAK,SAAS,GAAG,UAAU,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC;AAExD,+CAA+C;AAC/C,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC;;;GAGG;AACH,eAAO,MA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AAI,GAAG,SAAS,CAKpE;AA8GD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,GAAG,KAAK,EACnD,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GACjE,kBAAkB,CAAC,WAAW,CAAC,CAwdjC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `search_name` of a file or folder name, or the text a search looks
|
|
3
|
+
* for: folded with `normalizeSearchText` from `@dimah-s3/core`, with the
|
|
4
|
+
* `LIKE` specials kept literal, and cut to the column's length.
|
|
5
|
+
*/
|
|
6
|
+
export declare function toSearchName(value: string): string;
|
|
7
|
+
//# sourceMappingURL=search-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-name.d.ts","sourceRoot":"","sources":["../../src/store/search-name.ts"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CASlD"}
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { S3RequestOptions, S3RouteName } from "@dimah-s3/core";
|
|
2
|
-
import type { StorageObjectStatus } from "./storage-object";
|
|
2
|
+
import type { StorageObjectStatus } from "./storage-object.js";
|
|
3
3
|
/** A row status the browser can see. Rows that purge has claimed stay internal. */
|
|
4
4
|
export type DbClientObjectStatus = Exclude<StorageObjectStatus, "purging">;
|
|
5
5
|
/**
|
|
@@ -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,16 +68,24 @@ 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;
|
|
72
|
+
/**
|
|
73
|
+
* With `folderId`, also list every folder below it: objects from the
|
|
74
|
+
* whole subtree, and every folder in it as `folders`. At the root that is
|
|
75
|
+
* the whole scope. Each page carries `locations`, so a row can say where
|
|
76
|
+
* it is. `authorize` sees `recursive: true`.
|
|
77
|
+
*/
|
|
78
|
+
recursive?: boolean;
|
|
68
79
|
route?: S3RouteName;
|
|
69
80
|
/** @default "active" */
|
|
70
81
|
status?: DbClientObjectStatus;
|
|
71
82
|
/** Exact type, or `type/*` for every subtype (`image/*`). */
|
|
72
83
|
contentType?: string;
|
|
73
84
|
/**
|
|
74
|
-
* Text the `filename` contains.
|
|
75
|
-
*
|
|
76
|
-
*
|
|
85
|
+
* Text the `filename` contains. Case, accents, and look-alike letters
|
|
86
|
+
* (`ي`/`ی`, `ك`/`ک`) do not count, Persian and Arabic-Indic digits match
|
|
87
|
+
* `0`–`9`, and `%` and `_` are plain text, the same on every database.
|
|
88
|
+
* With `folderId`, folder names are matched the same way.
|
|
77
89
|
*/
|
|
78
90
|
search?: string;
|
|
79
91
|
/** @default { field: "createdAt", direction: "desc" } */
|
|
@@ -92,10 +104,25 @@ export type DbClientListResponse<TClientAttributes = never> = {
|
|
|
92
104
|
/** `null` on the last page. */
|
|
93
105
|
nextCursor: string | null;
|
|
94
106
|
/**
|
|
95
|
-
* Direct child folders of `
|
|
96
|
-
* name
|
|
107
|
+
* Direct child folders of `folderId`, or with `recursive` every folder
|
|
108
|
+
* below it, by name. At most 1000, and only those whose name contains
|
|
109
|
+
* `search` when it is set. First page only, and only when `folderId` is
|
|
110
|
+
* set.
|
|
97
111
|
*/
|
|
98
112
|
folders?: DbClientFolder[];
|
|
113
|
+
/**
|
|
114
|
+
* Folders from the root down to the open folder. Empty at the root.
|
|
115
|
+
* First page only, and only when `folderId` is set.
|
|
116
|
+
*/
|
|
117
|
+
trail?: DbClientFolder[];
|
|
118
|
+
/**
|
|
119
|
+
* With `recursive`, every folder on the way to the objects of this page
|
|
120
|
+
* and, on the first page, to `folders`: walk `parentId` from a row's
|
|
121
|
+
* `folderId` to draw where it lives. Every page.
|
|
122
|
+
*/
|
|
123
|
+
locations?: DbClientFolder[];
|
|
124
|
+
/** Objects that match, across every page. First page of a search only. */
|
|
125
|
+
total?: number;
|
|
99
126
|
/** First page only. */
|
|
100
127
|
usage?: DbUsage;
|
|
101
128
|
/** Caps for the scope, `null` when there are none. First page only. */
|
|
@@ -109,17 +136,29 @@ export type DbClientGetInput = {
|
|
|
109
136
|
/** Body of `PATCH /db/object`. Omitted fields stay as they are. */
|
|
110
137
|
export type DbClientUpdateInput = DbClientGetInput & {
|
|
111
138
|
filename?: string;
|
|
112
|
-
/** Folder
|
|
113
|
-
|
|
139
|
+
/** Folder id. `null` moves the object to the root. */
|
|
140
|
+
folderId?: string | null;
|
|
114
141
|
/**
|
|
115
142
|
* Replaces the attributes, checked by the plugin's `attributes.schema`.
|
|
116
143
|
* `null` clears them.
|
|
117
144
|
*/
|
|
118
145
|
attributes?: Record<string, unknown> | null;
|
|
119
146
|
};
|
|
120
|
-
/** Body of `POST /db/folder`
|
|
121
|
-
export type
|
|
122
|
-
|
|
147
|
+
/** Body of `POST /db/folder`. `parentId` omitted or `null` is the root. */
|
|
148
|
+
export type DbClientCreateFolderInput = {
|
|
149
|
+
parentId?: string | null;
|
|
150
|
+
name: string;
|
|
151
|
+
};
|
|
152
|
+
/** Body of `PATCH /db/folder`. An omitted field stays as it is. */
|
|
153
|
+
export type DbClientUpdateFolderInput = {
|
|
154
|
+
id: string;
|
|
155
|
+
name?: string;
|
|
156
|
+
/** `null` moves the folder to the root. */
|
|
157
|
+
parentId?: string | null;
|
|
158
|
+
};
|
|
159
|
+
/** Query of `DELETE /db/folder`. */
|
|
160
|
+
export type DbClientDeleteFolderInput = {
|
|
161
|
+
id: string;
|
|
123
162
|
};
|
|
124
163
|
/**
|
|
125
164
|
* The db endpoints as client actions (`api.db`). Each takes the same
|
|
@@ -133,11 +172,14 @@ export type DbClientActions<TClientAttributes = never> = {
|
|
|
133
172
|
updateObject(input: DbClientUpdateInput, options?: S3RequestOptions): Promise<{
|
|
134
173
|
object: DbClientObject<TClientAttributes>;
|
|
135
174
|
}>;
|
|
136
|
-
createFolder(input:
|
|
175
|
+
createFolder(input: DbClientCreateFolderInput, options?: S3RequestOptions): Promise<{
|
|
137
176
|
folder: DbClientFolder;
|
|
138
177
|
}>;
|
|
139
|
-
|
|
140
|
-
|
|
178
|
+
updateFolder(input: DbClientUpdateFolderInput, options?: S3RequestOptions): Promise<{
|
|
179
|
+
folder: DbClientFolder;
|
|
180
|
+
}>;
|
|
181
|
+
deleteFolder(input: DbClientDeleteFolderInput, options?: S3RequestOptions): Promise<{
|
|
182
|
+
id: string;
|
|
141
183
|
}>;
|
|
142
184
|
};
|
|
143
185
|
/** Filters `dbObjectSource` sends with every page. */
|
|
@@ -151,15 +193,29 @@ export type DbObjectSourceOptions = {
|
|
|
151
193
|
limit?: number;
|
|
152
194
|
/** List one folder at a time, with folder rows. @default true */
|
|
153
195
|
folders?: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* With `folders` on, search the folders below the open one too, or the
|
|
198
|
+
* whole scope (`searchScopes`). Turn it off when `authorize` keeps
|
|
199
|
+
* listings to one folder: a search then matches the open folder only.
|
|
200
|
+
* @default true
|
|
201
|
+
*/
|
|
202
|
+
recursiveSearch?: boolean;
|
|
154
203
|
};
|
|
155
|
-
/**
|
|
204
|
+
/** Where a search looks. Mirrors react's `ObjectListSearchScope`. */
|
|
205
|
+
export type DbObjectSourceSearchScope = "folder" | "all";
|
|
206
|
+
/** A folder row of {@link DbObjectSource}. `id` is the folder id. */
|
|
156
207
|
export type DbObjectSourceFolder = {
|
|
157
208
|
id: string;
|
|
158
209
|
name: string;
|
|
210
|
+
/**
|
|
211
|
+
* Folders from the root down to the one that holds this folder. Set on
|
|
212
|
+
* the results of a search.
|
|
213
|
+
*/
|
|
214
|
+
location?: readonly DbObjectSourceFolder[];
|
|
159
215
|
};
|
|
160
216
|
/** The `useObjectList` query input. Mirrors react's `ObjectListQueryInput`. */
|
|
161
217
|
export type DbObjectSourceQueryInput = {
|
|
162
|
-
/** Folder
|
|
218
|
+
/** Folder id. `null` is the root. */
|
|
163
219
|
parent: string | null;
|
|
164
220
|
cursor: string | null;
|
|
165
221
|
/** `name`, `size`, or `updatedAt`. Other fields keep the default order. */
|
|
@@ -168,6 +224,11 @@ export type DbObjectSourceQueryInput = {
|
|
|
168
224
|
direction: "asc" | "desc";
|
|
169
225
|
} | null;
|
|
170
226
|
search: string;
|
|
227
|
+
/**
|
|
228
|
+
* `folder`: the open folder and every folder below it. `all`: the whole
|
|
229
|
+
* scope. @default "folder"
|
|
230
|
+
*/
|
|
231
|
+
searchScope?: DbObjectSourceSearchScope;
|
|
171
232
|
signal: AbortSignal;
|
|
172
233
|
};
|
|
173
234
|
/** One page of {@link DbObjectSource}. Mirrors react's `ObjectListPage`. */
|
|
@@ -175,9 +236,16 @@ export type DbObjectSourcePage<TClientAttributes = never> = {
|
|
|
175
236
|
items: DbClientObject<TClientAttributes>[];
|
|
176
237
|
/** First page only. */
|
|
177
238
|
folders?: DbObjectSourceFolder[];
|
|
239
|
+
/**
|
|
240
|
+
* Folders from the root down to `parent`. First page only.
|
|
241
|
+
* `useObjectList` shows these names in the breadcrumb.
|
|
242
|
+
*/
|
|
243
|
+
trail?: DbObjectSourceFolder[];
|
|
178
244
|
nextCursor: string | null;
|
|
179
245
|
/** Scope usage with its caps. First page only. */
|
|
180
246
|
usage?: DbUsage & DbQuota;
|
|
247
|
+
/** Files that match a search, across every page. First page only. */
|
|
248
|
+
total?: number;
|
|
181
249
|
};
|
|
182
250
|
/** How the list reads one row. Mirrors react's `ObjectListFile`. */
|
|
183
251
|
export type DbObjectSourceFile = {
|
|
@@ -187,6 +255,11 @@ export type DbObjectSourceFile = {
|
|
|
187
255
|
contentType: string | null;
|
|
188
256
|
/** The row's `updatedAt`. */
|
|
189
257
|
updatedAt: string;
|
|
258
|
+
/**
|
|
259
|
+
* Folders from the root down to the row's folder. Set on the rows of a
|
|
260
|
+
* search.
|
|
261
|
+
*/
|
|
262
|
+
location?: readonly DbObjectSourceFolder[];
|
|
190
263
|
};
|
|
191
264
|
/**
|
|
192
265
|
* A `useObjectList` source over `GET /db/objects`. Typed structurally so db
|
|
@@ -196,7 +269,9 @@ export type DbObjectSource<TClientAttributes = never> = {
|
|
|
196
269
|
query: (input: DbObjectSourceQueryInput) => Promise<DbObjectSourcePage<TClientAttributes>>;
|
|
197
270
|
getKey: (item: DbClientObject<TClientAttributes>) => string;
|
|
198
271
|
getFile: (item: DbClientObject<TClientAttributes>) => DbObjectSourceFile;
|
|
199
|
-
/**
|
|
272
|
+
/** `["folder", "all"]` with `folders` on: search reaches every folder. */
|
|
273
|
+
searchScopes?: readonly DbObjectSourceSearchScope[];
|
|
274
|
+
/** Upload options for files dropped into `parent`. The root sends `""`. */
|
|
200
275
|
uploadOptions?: (parent: string | null) => {
|
|
201
276
|
metadata: Record<string, string>;
|
|
202
277
|
};
|
|
@@ -205,5 +280,21 @@ export type DbObjectSource<TClientAttributes = never> = {
|
|
|
205
280
|
parent: string | null;
|
|
206
281
|
name: string;
|
|
207
282
|
}) => Promise<DbObjectSourceFolder>;
|
|
283
|
+
/**
|
|
284
|
+
* Renames a file's `filename`. The object `key` stays. Set when `api.db`
|
|
285
|
+
* has `updateObject`.
|
|
286
|
+
*/
|
|
287
|
+
renameFile?: (input: {
|
|
288
|
+
item: DbClientObject<TClientAttributes>;
|
|
289
|
+
name: string;
|
|
290
|
+
}) => Promise<DbClientObject<TClientAttributes>>;
|
|
291
|
+
/**
|
|
292
|
+
* Renames a folder. Its id stays. Set when `api.db` has `updateFolder`
|
|
293
|
+
* and `folders` is on.
|
|
294
|
+
*/
|
|
295
|
+
renameFolder?: (input: {
|
|
296
|
+
folder: DbObjectSourceFolder;
|
|
297
|
+
name: string;
|
|
298
|
+
}) => Promise<DbObjectSourceFolder>;
|
|
208
299
|
};
|
|
209
300
|
//# 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,KAAK,EAA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