@dimah-s3/db 2.0.0-beta.1 → 2.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +19 -10
  2. package/dist/adapters/drizzle.d.ts +2 -3
  3. package/dist/adapters/drizzle.d.ts.map +1 -1
  4. package/dist/adapters/kysely.d.ts +1 -1
  5. package/dist/adapters/prisma.d.ts +1 -1
  6. package/dist/cli.d.ts +18 -13
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +57 -84
  9. package/dist/cli.js.map +1 -1
  10. package/dist/client/db-client.d.ts +1 -1
  11. package/dist/client/db-client.d.ts.map +1 -1
  12. package/dist/client/db-object-source.d.ts +15 -9
  13. package/dist/client/db-object-source.d.ts.map +1 -1
  14. package/dist/client/index.d.ts +3 -3
  15. package/dist/client/index.d.ts.map +1 -1
  16. package/dist/client/index.js +101 -21
  17. package/dist/client/index.js.map +1 -1
  18. package/dist/folder-path.d.ts +17 -4
  19. package/dist/folder-path.d.ts.map +1 -1
  20. package/dist/fuma-db.d.ts +23 -23
  21. package/dist/fuma-db.d.ts.map +1 -1
  22. package/dist/index.d.ts +9 -9
  23. package/dist/index.js +595 -267
  24. package/dist/index.js.map +1 -1
  25. package/dist/plugin/create-database-endpoints.d.ts +46 -22
  26. package/dist/plugin/create-database-endpoints.d.ts.map +1 -1
  27. package/dist/plugin/create-database-lifecycle-hooks.d.ts +4 -4
  28. package/dist/plugin/create-database-lifecycle-hooks.d.ts.map +1 -1
  29. package/dist/plugin/db.d.ts +2 -2
  30. package/dist/plugin/db.d.ts.map +1 -1
  31. package/dist/plugin/object-access.d.ts +2 -2
  32. package/dist/plugin/object-access.d.ts.map +1 -1
  33. package/dist/plugin/public-stores.d.ts +5 -8
  34. package/dist/plugin/public-stores.d.ts.map +1 -1
  35. package/dist/plugin/quota.d.ts +1 -1
  36. package/dist/plugin/schemas.d.ts +25 -11
  37. package/dist/plugin/schemas.d.ts.map +1 -1
  38. package/dist/plugin/scope.d.ts +2 -0
  39. package/dist/plugin/scope.d.ts.map +1 -1
  40. package/dist/plugin/to-db-client-object.d.ts.map +1 -1
  41. package/dist/schema/schema.d.ts +48 -49
  42. package/dist/schema/schema.d.ts.map +1 -1
  43. package/dist/store/create-db-store.d.ts +2 -2
  44. package/dist/store/create-db-store.d.ts.map +1 -1
  45. package/dist/store/folder-store.d.ts +73 -15
  46. package/dist/store/folder-store.d.ts.map +1 -1
  47. package/dist/store/list-cursor.d.ts +3 -1
  48. package/dist/store/list-cursor.d.ts.map +1 -1
  49. package/dist/store/map-row.d.ts +3 -9
  50. package/dist/store/map-row.d.ts.map +1 -1
  51. package/dist/store/object-store.d.ts +20 -10
  52. package/dist/store/object-store.d.ts.map +1 -1
  53. package/dist/store/search-name.d.ts +7 -0
  54. package/dist/store/search-name.d.ts.map +1 -0
  55. package/dist/types/client.d.ts +114 -23
  56. package/dist/types/client.d.ts.map +1 -1
  57. package/dist/types/plugin.d.ts +17 -6
  58. package/dist/types/plugin.d.ts.map +1 -1
  59. package/dist/types/storage-object.d.ts +8 -7
  60. package/dist/types/storage-object.d.ts.map +1 -1
  61. package/package.json +15 -33
  62. package/dist/drizzle/mysql.d.ts +0 -1025
  63. package/dist/drizzle/mysql.d.ts.map +0 -1
  64. package/dist/drizzle/mysql.js +0 -117
  65. package/dist/drizzle/mysql.js.map +0 -1
  66. package/dist/drizzle/pg.d.ts +0 -964
  67. package/dist/drizzle/pg.d.ts.map +0 -1
  68. package/dist/drizzle/pg.js +0 -98
  69. package/dist/drizzle/pg.js.map +0 -1
  70. package/dist/drizzle/shared.d.ts +0 -7
  71. package/dist/drizzle/shared.d.ts.map +0 -1
  72. package/dist/drizzle/sqlite.d.ts +0 -1024
  73. package/dist/drizzle/sqlite.d.ts.map +0 -1
  74. package/dist/drizzle/sqlite.js +0 -101
  75. package/dist/drizzle/sqlite.js.map +0 -1
  76. package/prisma/dimah-s3.prisma +0 -80
  77. package/sql/mysql.sql +0 -59
  78. package/sql/pg.sql +0 -53
  79. package/sql/sqlite.sql +0 -54
  80. package/src/drizzle/mysql.ts +0 -172
  81. package/src/drizzle/pg.ts +0 -140
  82. 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` also creates the folder. */
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. The
25
- * first page also carries usage, the quota, and the child folders (those
26
- * whose name contains `search`, when it is set).
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` (op `update`): creates or
30
- * removes an empty folder.
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. `folder` omitted lists every folder. */
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
- folder?: string | undefined;
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
- folder?: string | undefined;
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
- * checks the target folder like an upload: validated, authorized, and
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
- folder?: string | null | undefined;
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
- folder?: string | null | undefined;
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 a folder and its missing ancestors. */
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
- path: string;
117
+ parentId?: string | null | undefined;
118
+ name: string;
113
119
  }, {
114
- path: string;
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
- path: string;
151
+ id: string;
128
152
  }, {
129
- path: string;
153
+ id: string;
130
154
  }>;
131
155
  }, {
132
- path: string;
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,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AASrC,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,uEAAuE;IACvE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC;IAChD,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC5C,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;AAuDF;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EACR,WAAW,EACX,iBAAiB,EAEjB,OAAO,EAAE,8BAA8B,CACrC,QAAQ,EACR,WAAW,EACX,iBAAiB,CAClB;IAoCC,6EAA6E;IAC7E,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2CP,wCAAwC;IACxC,MAAM;;;;;;;;;;;;;gBAG2B,cAAc,CAAC,iBAAiB,CAAC;;IAiBlE;;;;OAIG;IACH,YAAY;;;;;;;;;;;;;;;;;;gBAGqB,cAAc,CAAC,iBAAiB,CAAC;;IA+ClE,kDAAkD;IAClD,YAAY;;;;;;;;;;gBAGqB,cAAc;;IAW/C,iEAAiE;IACjE,YAAY;;;;;;;;;;;;cAGmB,MAAM;;EAWxC"}
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,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  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 folders. An overwrite leaves the active row in
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;AAEnE,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,O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yE;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"}
@@ -1,7 +1,7 @@
1
1
  import { type DimahS3Plugin } from "@dimah-s3/server/plugins";
2
2
  import type { DbPluginOptions } from "../types/plugin.js";
3
- import { type DbFolders, type DbObjects } from "./public-stores";
4
- import { type Purge } from "./purge";
3
+ import { type DbFolders, type DbObjects } from "./public-stores.js";
4
+ import { type Purge } from "./purge.js";
5
5
  /** What `db()` exposes on `s3.db` and `s3.context.db`. */
6
6
  export type DbPluginContext<TAttributes = never> = {
7
7
  /** The `storage_object` rows: listings, usage, and your own changes. */
@@ -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;AAQtE,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAKlD,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;;;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,CA0DnD"}
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;AAQtE,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAKlD,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;;;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,CA2DnD"}
@@ -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,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AAE,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 folder is validated
15
- * (`FOLDER_INVALID`) and created when missing. With `id` or `scope`, only
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
- * `s3.db.folders`: the `storage_folder` rows. Paths are validated as on the
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":"AAEA,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,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;;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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DAAkD;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"}
@@ -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. */
@@ -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`. `folder` is a wire folder (`""` is the root)
6
- * that the endpoint validates, so a bad path is `FOLDER_INVALID`. Blank
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
- folder: z.ZodOptional<z.ZodString>;
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`. `folder` is validated by the endpoint; `null`
52
- * and `""` are the root. `attributes` are checked by the plugin's
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
- folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
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 `POST /db/folder` and query of `DELETE /db/folder`. The endpoint
64
- * validates `path`, so a bad path is `FOLDER_INVALID`.
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 dbFolderInputSchema: z.ZodObject<{
67
- path: z.ZodString;
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;AAuDrC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAiB5B,CAAC;AAEH,iCAAiC;AACjC,eAAO,MAAM,mBAAmB;;;kBAG9B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;kBAOnC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;kBAE9B,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"}
@@ -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;AACtD,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;;;GAGG;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,CAmCzB"}
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/plugin/scope.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAA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ClC,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,CAOtE"}
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"}
@@ -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
- * Secondary indexes. FumaDB cannot declare them, so {@link dbSchema}'s
10
- * migration, the SQL files, the Drizzle tables, and the Prisma schema carry
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 schemaIndexes: readonly SchemaIndex[];
5
+ export declare const SEARCH_NAME_MAX_LENGTH = 1024;
14
6
  /**
15
- * FumaDB runs `up` only when migrating from the previous entry, and skips
16
- * `up` on the first one. This empty entry exists so {@link dbSchema} can
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 PREDECESSOR_VERSION = "0.0.1";
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.0.0`. The migration creates the
24
- * secondary indexes after the tables, because FumaDB cannot declare them.
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.0.0", {
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: Column<"string", string, string>;
31
- bucket: Column<"string", string, string>;
32
- key: Column<"string", string, string>;
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: Column<"string", string, string>;
35
- /** Logical folder path. `null` is the root. */
36
- folder: Column<"string", string | null, string | null>;
37
- filename: Column<"string", string, string>;
38
- contentType: Column<"string", string | null, string | null>;
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", number | null, string | number | bigint | null>;
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", number | null, string | number | bigint | null>;
43
- eTag: Column<"string", string | null, string | null>;
44
- status: Column<"string", string, string>;
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: Column<"string", string | null, string | null>;
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: Column<"string", string | null, string | null>;
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: Column<"string", string, string>;
64
- /** Full folder path. */
65
- path: Column<"string", string, string>;
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: Column<"string", string, string>;
70
- createdAt: Column<"timestamp", Date | null, Date>;
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":"AAAA,OAAO,EAAmC,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAsE7E,wDAAwD;AACxD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EA+B/C,CAAC;AAIF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C,eAAO,MAAM,WAAW,6CAGtB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;QA9GnB,mDAAmD;;;;QAInD,oDAAoD;;QAEpD,+CAA+C;;;;QAI/C,qDAAqD;;QAErD,8EAA8E;;;;QAI9E,+CAA+C;;QAE/C,qEAAqE;;;QAGrE,oDAAoD;;QAEpD,iFAAiF;;QAEjF,sEAAsE;;;;;;;;;;QAYtE,wBAAwB;;QAExB,yDAAyD;;QAEzD,8BAA8B;;;;EAoF9B,CAAC"}
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,CAkBtB"}
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"}