@dimah-s3/db 1.7.1 → 2.0.0-beta.0
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 +62 -17
- package/dist/adapters/drizzle.d.ts +7 -0
- package/dist/adapters/drizzle.d.ts.map +1 -0
- package/dist/adapters/drizzle.js +3 -0
- package/dist/adapters/drizzle.js.map +1 -0
- package/dist/adapters/kysely.d.ts +7 -0
- package/dist/adapters/kysely.d.ts.map +1 -0
- package/dist/adapters/kysely.js +3 -0
- package/dist/adapters/kysely.js.map +1 -0
- package/dist/adapters/prisma.d.ts +7 -0
- package/dist/adapters/prisma.d.ts.map +1 -0
- package/dist/adapters/prisma.js +3 -0
- package/dist/adapters/prisma.js.map +1 -0
- package/dist/cli.d.ts +33 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +192 -4
- package/dist/cli.js.map +1 -1
- package/dist/client/db-client.d.ts +9 -85
- package/dist/client/db-client.d.ts.map +1 -1
- package/dist/client/db-object-source.d.ts +25 -0
- package/dist/client/db-object-source.d.ts.map +1 -0
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +96 -42
- package/dist/client/index.js.map +1 -1
- package/dist/drizzle/mysql.d.ts +1024 -0
- package/dist/drizzle/mysql.d.ts.map +1 -0
- package/dist/drizzle/mysql.js +123 -0
- package/dist/drizzle/mysql.js.map +1 -0
- package/dist/drizzle/pg.d.ts +963 -0
- package/dist/drizzle/pg.d.ts.map +1 -0
- package/dist/drizzle/pg.js +104 -0
- package/dist/drizzle/pg.js.map +1 -0
- package/dist/drizzle/shared.d.ts +16 -0
- package/dist/drizzle/shared.d.ts.map +1 -0
- package/dist/drizzle/sqlite.d.ts +1023 -0
- package/dist/drizzle/sqlite.d.ts.map +1 -0
- package/dist/drizzle/sqlite.js +107 -0
- package/dist/drizzle/sqlite.js.map +1 -0
- package/dist/folder-path.d.ts +32 -0
- package/dist/folder-path.d.ts.map +1 -0
- package/dist/fuma-db.d.ts +47 -5
- package/dist/fuma-db.d.ts.map +1 -1
- package/dist/index.d.ts +9 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1452 -620
- package/dist/index.js.map +1 -1
- package/dist/plugin/create-database-endpoints.d.ts +105 -21
- package/dist/plugin/create-database-endpoints.d.ts.map +1 -1
- package/dist/plugin/create-database-lifecycle-hooks.d.ts +37 -19
- package/dist/plugin/create-database-lifecycle-hooks.d.ts.map +1 -1
- package/dist/plugin/db.d.ts +29 -118
- package/dist/plugin/db.d.ts.map +1 -1
- package/dist/plugin/object-access.d.ts +46 -0
- package/dist/plugin/object-access.d.ts.map +1 -0
- package/dist/plugin/public-stores.d.ts +33 -0
- package/dist/plugin/public-stores.d.ts.map +1 -0
- package/dist/plugin/purge.d.ts +49 -0
- package/dist/plugin/purge.d.ts.map +1 -0
- package/dist/plugin/quota.d.ts +25 -0
- package/dist/plugin/quota.d.ts.map +1 -0
- package/dist/plugin/schemas.d.ts +69 -0
- package/dist/plugin/schemas.d.ts.map +1 -0
- package/dist/plugin/scope.d.ts +31 -0
- package/dist/plugin/scope.d.ts.map +1 -0
- package/dist/plugin/to-db-client-object.d.ts +8 -4
- package/dist/plugin/to-db-client-object.d.ts.map +1 -1
- package/dist/schema/v1.d.ts +1 -8
- package/dist/schema/v1.d.ts.map +1 -1
- package/dist/schema/v2.d.ts +64 -0
- package/dist/schema/v2.d.ts.map +1 -0
- package/dist/standard-schema.d.ts +42 -0
- package/dist/standard-schema.d.ts.map +1 -0
- package/dist/store/create-db-store.d.ts +17 -0
- package/dist/store/create-db-store.d.ts.map +1 -0
- package/dist/store/folder-store.d.ts +36 -0
- package/dist/store/folder-store.d.ts.map +1 -0
- package/dist/store/list-cursor.d.ts +26 -4
- package/dist/store/list-cursor.d.ts.map +1 -1
- package/dist/store/map-row.d.ts +17 -8
- package/dist/store/map-row.d.ts.map +1 -1
- package/dist/store/object-store.d.ts +208 -0
- package/dist/store/object-store.d.ts.map +1 -0
- package/dist/store/schema-version.d.ts +7 -0
- package/dist/store/schema-version.d.ts.map +1 -0
- package/dist/types/client.d.ts +209 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +112 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/storage-object.d.ts +40 -85
- package/dist/types/storage-object.d.ts.map +1 -1
- package/package.json +50 -11
- package/prisma/dimah-s3.prisma +80 -0
- package/sql/mysql.sql +59 -0
- package/sql/pg.sql +53 -0
- package/sql/sqlite.sql +54 -0
- package/sql/upgrade/1.0.0-2.0.0/mysql.sql +71 -0
- package/sql/upgrade/1.0.0-2.0.0/pg.sql +47 -0
- package/sql/upgrade/1.0.0-2.0.0/sqlite.sql +119 -0
- package/dist/client/db-object-list-accessors.d.ts +0 -36
- package/dist/client/db-object-list-accessors.d.ts.map +0 -1
- package/dist/client/db-object-query.d.ts +0 -40
- package/dist/client/db-object-query.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -6
- package/dist/errors.d.ts.map +0 -1
- package/dist/hooks/create-object-access-guard.d.ts +0 -51
- package/dist/hooks/create-object-access-guard.d.ts.map +0 -1
- package/dist/hooks/create-quota-guard.d.ts +0 -28
- package/dist/hooks/create-quota-guard.d.ts.map +0 -1
- package/dist/jobs/purge-stale-pending.d.ts +0 -31
- package/dist/jobs/purge-stale-pending.d.ts.map +0 -1
- package/dist/plugin/list-query-schema.d.ts +0 -21
- package/dist/plugin/list-query-schema.d.ts.map +0 -1
- package/dist/plugin/memoize-scope-resolver.d.ts +0 -8
- package/dist/plugin/memoize-scope-resolver.d.ts.map +0 -1
- package/dist/store/storage-object-store.d.ts +0 -137
- package/dist/store/storage-object-store.d.ts.map +0 -1
- package/src/schema/examples/README.md +0 -10
- package/src/schema/examples/drizzle.ts +0 -92
- package/src/schema/examples/schema.prisma +0 -55
package/README.md
CHANGED
|
@@ -1,38 +1,83 @@
|
|
|
1
1
|
# @dimah-s3/db
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**2.0 beta.** Install with `@beta`. `@latest` stays on 1.x, and betas can include breaking changes until 2.0.0.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Optional database plugin for [dimah-s3](https://github.com/dimah-kz/dimah-s3). It tracks each upload in a `storage_object` table, binds uploads to the caller's scope, and adds logical folders, listings, and quotas.
|
|
6
|
+
|
|
7
|
+
**Docs:** [Database Setup](https://v2.s3.dimah.dev/docs/db/setup) · [Lifecycle Hooks](https://v2.s3.dimah.dev/docs/db/lifecycle-hooks) · [API](https://v2.s3.dimah.dev/docs/db/api) · [Purge](https://v2.s3.dimah.dev/docs/db/purge) · [llms.txt](https://v2.s3.dimah.dev/llms.txt) · **Example:** [`examples/with-db`](../../examples/with-db)
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @dimah-s3/db@beta @dimah-s3/server@beta
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
You do not install `fumadb`: the adapters ship from `@dimah-s3/db/adapters/*`.
|
|
16
|
+
|
|
17
|
+
## Tables
|
|
18
|
+
|
|
19
|
+
Create the schema with one of:
|
|
20
|
+
|
|
21
|
+
- Drizzle: add `dimahS3Tables` from `@dimah-s3/db/drizzle/{sqlite,pg,mysql}` to your Drizzle schema.
|
|
22
|
+
- Prisma: copy [`prisma/dimah-s3.prisma`](./prisma/dimah-s3.prisma) into your schema.
|
|
23
|
+
- Plain SQL: run [`sql/<dialect>.sql`](./sql).
|
|
24
|
+
- Kysely: call `migrate(client)` from `@dimah-s3/db/cli`. It steps one schema version at a time, so the indexes are created too. The FumaDB CLI from `runCli` does the same only with `migrate:up`; its `migrate` command jumps straight to the latest schema and skips them.
|
|
25
|
+
|
|
26
|
+
Upgrading from 1.x: run `sql/upgrade/1.0.0-2.0.0/<dialect>.sql`, or `migrate(client)` with Kysely. A database at an older schema throws on the first query; call `s3.db.checkSchema()` at startup to fail fast.
|
|
27
|
+
|
|
28
|
+
## Server
|
|
6
29
|
|
|
7
30
|
```ts
|
|
8
31
|
import { DimahS3DB, db } from "@dimah-s3/db";
|
|
32
|
+
import { drizzleAdapter } from "@dimah-s3/db/adapters/drizzle";
|
|
9
33
|
import { dimahS3, route } from "@dimah-s3/server";
|
|
10
|
-
import { drizzleAdapter } from "fumadb/adapters/drizzle";
|
|
11
|
-
|
|
12
|
-
export const dimahS3Db = DimahS3DB.client(
|
|
13
|
-
drizzleAdapter({ db: drizzleDb, provider: "sqlite" }),
|
|
14
|
-
);
|
|
15
34
|
|
|
16
35
|
export const s3 = dimahS3({
|
|
17
36
|
client: awsS3,
|
|
18
37
|
bucket: process.env.S3_BUCKET!,
|
|
19
38
|
plugins: [
|
|
20
39
|
db({
|
|
21
|
-
client:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
40
|
+
client: DimahS3DB.client(
|
|
41
|
+
drizzleAdapter({ db: drizzleDb, provider: "sqlite" }),
|
|
42
|
+
),
|
|
43
|
+
getSession: (request) => auth.getSession(request),
|
|
44
|
+
resolveScope: ({ session }) =>
|
|
45
|
+
session ? `user:${session.userId}` : null,
|
|
46
|
+
quota: { maxBytes: 1024 ** 3, maxFiles: 1000 },
|
|
26
47
|
}),
|
|
27
48
|
],
|
|
28
49
|
routes: {
|
|
29
|
-
uploads: route({
|
|
30
|
-
upload: true,
|
|
31
|
-
}),
|
|
50
|
+
uploads: route({ upload: true, download: true, delete: true }),
|
|
32
51
|
},
|
|
33
52
|
});
|
|
34
53
|
|
|
35
|
-
s3.db.objects.
|
|
54
|
+
await s3.db.objects.list({ scope: "user:1", folder: null });
|
|
55
|
+
await s3.db.purgeStale();
|
|
36
56
|
```
|
|
37
57
|
|
|
38
|
-
|
|
58
|
+
- `resolveScope` returns the owner of the request, or `null` to reject it with `UNAUTHORIZED`.
|
|
59
|
+
- `authorize` runs after it and returns `false` to reject with `FORBIDDEN`.
|
|
60
|
+
- `quota` is checked at upload and again with the verified size at confirm.
|
|
61
|
+
- `plugins: { db: false }` on a route turns tracking off. `plugins: { db: { replace: "overwrite" } }` lets an upload replace an active object at the same key; the object stays listed and downloadable until the new upload is confirmed.
|
|
62
|
+
|
|
63
|
+
## Browser
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { dbClient, dbObjectSource } from "@dimah-s3/db/client";
|
|
67
|
+
import { createS3Client, useObjectList } from "@dimah-s3/react";
|
|
68
|
+
|
|
69
|
+
export const s3Client = createS3Client({ plugins: [dbClient()] });
|
|
70
|
+
|
|
71
|
+
const list = useObjectList({
|
|
72
|
+
...dbObjectSource(s3Client.db, { route: "uploads" }),
|
|
73
|
+
queryKey: ["uploads"],
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`dbObjectSource` lists one folder at a time. Uploads go to the open folder, and "New folder" calls `api.db.createFolder`. Pass `folders: false` for a flat list.
|
|
78
|
+
|
|
79
|
+
`api.db` also has `getObject`, `updateObject` (rename, move, or set `attributes`), and `deleteFolder`.
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
MIT
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FumaDB Drizzle adapter. Pass a Drizzle instance whose schema includes
|
|
3
|
+
* `dimahS3Tables` from `@dimah-s3/db/drizzle/<dialect>`:
|
|
4
|
+
* `DimahS3DB.client(drizzleAdapter({ db, provider: "postgresql" }))`.
|
|
5
|
+
*/
|
|
6
|
+
export { drizzleAdapter, type DrizzleConfig } from "fumadb/adapters/drizzle";
|
|
7
|
+
//# sourceMappingURL=drizzle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drizzle.d.ts","sourceRoot":"","sources":["../../src/adapters/drizzle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"drizzle.js","sourcesContent":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FumaDB Kysely adapter. It can also migrate the schema:
|
|
3
|
+
* `DimahS3DB.client(kyselyAdapter({ db, provider: "postgresql" }))`.
|
|
4
|
+
*/
|
|
5
|
+
export { kyselyAdapter } from "fumadb/adapters/kysely";
|
|
6
|
+
export type { KyselyConfig } from "fumadb";
|
|
7
|
+
//# sourceMappingURL=kysely.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kysely.d.ts","sourceRoot":"","sources":["../../src/adapters/kysely.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"kysely.js","sourcesContent":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FumaDB Prisma adapter. Pass a Prisma client generated with the models
|
|
3
|
+
* from `prisma/dimah-s3.prisma`:
|
|
4
|
+
* `DimahS3DB.client(prismaAdapter({ prisma, provider: "postgresql" }))`.
|
|
5
|
+
*/
|
|
6
|
+
export { prismaAdapter, type PrismaConfig } from "fumadb/adapters/prisma";
|
|
7
|
+
//# sourceMappingURL=prisma.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/adapters/prisma.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"prisma.js","sourcesContent":[]}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type DimahS3DbClient } from "./fuma-db";
|
|
2
|
+
/**
|
|
3
|
+
* Runs the interactive FumaDB CLI: generate the ORM schema, or migrate when
|
|
4
|
+
* the client uses the Kysely adapter. Prefer {@link migrate} to migrate:
|
|
5
|
+
* only `migrate:up`, one version at a time, runs the steps 2.0.0 needs,
|
|
6
|
+
* and no CLI command converts 1.x SQLite sizes.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* // scripts/db.ts
|
|
10
|
+
* import { runCli } from "@dimah-s3/db/cli";
|
|
11
|
+
* import { dimahS3Db } from "../lib/s3";
|
|
12
|
+
*
|
|
13
|
+
* await runCli(dimahS3Db);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function runCli(client: DimahS3DbClient): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Migrates the database to the schema this version needs, from an empty
|
|
19
|
+
* database or from schema 1.0.0, one version at a time, so each version's
|
|
20
|
+
* own steps run (the 2.0.0 indexes among them). An upgrade from 1.0.0 also
|
|
21
|
+
* turns 1.x SQLite blob sizes into numbers, like
|
|
22
|
+
* `sql/upgrade/1.0.0-2.0.0/sqlite.sql`. It needs the Kysely adapter; with
|
|
23
|
+
* Drizzle or Prisma, use your ORM's migrations or the files in `sql/`.
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { DimahS3DB } from "@dimah-s3/db";
|
|
27
|
+
* import { kyselyAdapter } from "@dimah-s3/db/adapters/kysely";
|
|
28
|
+
* import { migrate } from "@dimah-s3/db/cli";
|
|
29
|
+
*
|
|
30
|
+
* await migrate(DimahS3DB.client(kyselyAdapter({ db: kysely, provider: "postgresql" })));
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function migrate(client: DimahS3DbClient): Promise<void>;
|
|
5
34
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAQpE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAS7D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAOpE"}
|
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,204 @@
|
|
|
1
1
|
import { createCli } from 'fumadb/cli';
|
|
2
|
+
import { fumadb } from 'fumadb';
|
|
3
|
+
import { table, column, idColumn, schema } from 'fumadb/schema';
|
|
2
4
|
|
|
3
5
|
// src/cli.ts
|
|
4
|
-
|
|
6
|
+
var storageObject = table("storage_object", {
|
|
7
|
+
id: idColumn("id", "varchar(255)").defaultTo$("auto"),
|
|
8
|
+
scope: column("scope", "string"),
|
|
9
|
+
bucket: column("bucket", "string"),
|
|
10
|
+
key: column("key", "string"),
|
|
11
|
+
route: column("route", "string"),
|
|
12
|
+
contentType: column("content_type", "string").nullable(),
|
|
13
|
+
size: column("size", "bigint").nullable(),
|
|
14
|
+
eTag: column("e_tag", "string").nullable(),
|
|
15
|
+
filename: column("filename", "string").nullable(),
|
|
16
|
+
status: column("status", "string"),
|
|
17
|
+
s3Metadata: column("metadata", "json").nullable(),
|
|
18
|
+
acl: column("acl", "string").nullable(),
|
|
19
|
+
uploadId: column("upload_id", "string").nullable(),
|
|
20
|
+
declaredSize: column("declared_size", "bigint").nullable(),
|
|
21
|
+
confirmedAt: column("confirmed_at", "timestamp").nullable(),
|
|
22
|
+
expiresAt: column("expires_at", "timestamp").nullable(),
|
|
23
|
+
createdAt: column("created_at", "timestamp").defaultTo$("now"),
|
|
24
|
+
updatedAt: column("updated_at", "timestamp").defaultTo$("now"),
|
|
25
|
+
deletedAt: column("deleted_at", "timestamp").nullable()
|
|
26
|
+
}).unique("storage_object_bucket_key_uk", ["bucket", "key"]);
|
|
27
|
+
var v1 = schema({
|
|
28
|
+
version: "1.0.0",
|
|
29
|
+
tables: {
|
|
30
|
+
storageObject
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
function byteCount(name) {
|
|
34
|
+
return column(name, "bigint").nullable();
|
|
35
|
+
}
|
|
36
|
+
var storageObject2 = table("storage_object", {
|
|
37
|
+
id: idColumn("id", "varchar(255)").defaultTo$("auto"),
|
|
38
|
+
/** Owner, for example `user:123` or `org:acme`. */
|
|
39
|
+
scope: column("scope", "string"),
|
|
40
|
+
bucket: column("bucket", "string"),
|
|
41
|
+
key: column("key", "string"),
|
|
42
|
+
/** Named dimah-s3 route that created the object. */
|
|
43
|
+
route: column("route", "string"),
|
|
44
|
+
/** Logical folder path. `null` is the root. */
|
|
45
|
+
folder: column("folder", "string").nullable(),
|
|
46
|
+
filename: column("filename", "string"),
|
|
47
|
+
contentType: column("content_type", "string").nullable(),
|
|
48
|
+
/** Verified size from HeadObject, set on confirm. */
|
|
49
|
+
size: byteCount("size"),
|
|
50
|
+
/** Size the client declared before confirm. Quota counts it while pending. */
|
|
51
|
+
declaredSize: byteCount("declared_size"),
|
|
52
|
+
eTag: column("e_tag", "string").nullable(),
|
|
53
|
+
status: column("status", "string"),
|
|
54
|
+
/** S3 user metadata of the verified object. */
|
|
55
|
+
s3Metadata: column("s3_metadata", "json").nullable(),
|
|
56
|
+
/** App attributes, validated by the plugin's `attributes.schema`. */
|
|
57
|
+
attributes: column("attributes", "json").nullable(),
|
|
58
|
+
acl: column("acl", "string").nullable(),
|
|
59
|
+
/** Multipart upload ID while the row is pending. */
|
|
60
|
+
uploadId: column("upload_id", "string").nullable(),
|
|
61
|
+
/** Token of the upload ticket that wrote the row. Confirm and purge match it. */
|
|
62
|
+
uploadToken: column("upload_token", "string").nullable(),
|
|
63
|
+
/** Confirm deadline of a pending row (the upload ticket's expiry). */
|
|
64
|
+
expiresAt: column("expires_at", "timestamp").nullable(),
|
|
65
|
+
confirmedAt: column("confirmed_at", "timestamp").nullable(),
|
|
66
|
+
createdAt: column("created_at", "timestamp").defaultTo$("now"),
|
|
67
|
+
updatedAt: column("updated_at", "timestamp").defaultTo$("now"),
|
|
68
|
+
deletedAt: column("deleted_at", "timestamp").nullable()
|
|
69
|
+
}).unique("storage_object_bucket_key_uk", ["bucket", "key"]);
|
|
70
|
+
var storageFolder = table("storage_folder", {
|
|
71
|
+
id: idColumn("id", "varchar(255)").defaultTo$("auto"),
|
|
72
|
+
scope: column("scope", "string"),
|
|
73
|
+
/** Full folder path. */
|
|
74
|
+
path: column("path", "string"),
|
|
75
|
+
/** Path of the containing folder. `null` is the root. */
|
|
76
|
+
parent: column("parent", "string").nullable(),
|
|
77
|
+
/** Last segment of `path`. */
|
|
78
|
+
name: column("name", "string"),
|
|
79
|
+
createdAt: column("created_at", "timestamp").defaultTo$("now")
|
|
80
|
+
}).unique("storage_folder_scope_path_uk", ["scope", "path"]);
|
|
81
|
+
var v2Indexes = [
|
|
82
|
+
{
|
|
83
|
+
name: "storage_object_scope_folder_idx",
|
|
84
|
+
table: "storage_object",
|
|
85
|
+
columns: ["scope", "status", "folder", "created_at"]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "storage_object_scope_updated_idx",
|
|
89
|
+
table: "storage_object",
|
|
90
|
+
columns: ["scope", "status", "updated_at"]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "storage_object_scope_filename_idx",
|
|
94
|
+
table: "storage_object",
|
|
95
|
+
columns: ["scope", "status", "filename"]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "storage_object_scope_size_idx",
|
|
99
|
+
table: "storage_object",
|
|
100
|
+
columns: ["scope", "status", "size"]
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "storage_object_status_expires_idx",
|
|
104
|
+
table: "storage_object",
|
|
105
|
+
columns: ["status", "expires_at"]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "storage_folder_scope_parent_idx",
|
|
109
|
+
table: "storage_folder",
|
|
110
|
+
columns: ["scope", "parent"]
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
var v1Indexes = [
|
|
114
|
+
"storage_object_scope_status_created_idx",
|
|
115
|
+
"storage_object_scope_route_idx",
|
|
116
|
+
"storage_object_status_created_idx"
|
|
117
|
+
];
|
|
118
|
+
var custom = (sql) => ({ type: "custom", sql });
|
|
119
|
+
var keyName = `COALESCE(NULLIF(substr("key", length(rtrim("key", replace("key", '/', ''))) + 1), ''), "key")`;
|
|
120
|
+
var beforeV2 = [
|
|
121
|
+
custom(
|
|
122
|
+
`UPDATE "storage_object" SET "filename" = ${keyName} WHERE "filename" IS NULL`
|
|
123
|
+
)
|
|
124
|
+
];
|
|
125
|
+
var afterV2 = [
|
|
126
|
+
...v1Indexes.map((name) => custom(`DROP INDEX IF EXISTS "${name}"`)),
|
|
127
|
+
...v2Indexes.map((index) => {
|
|
128
|
+
const columns = index.columns.map((name) => `"${name}"`).join(", ");
|
|
129
|
+
return custom(
|
|
130
|
+
`CREATE INDEX IF NOT EXISTS "${index.name}" ON "${index.table}" (${columns})`
|
|
131
|
+
);
|
|
132
|
+
})
|
|
133
|
+
];
|
|
134
|
+
var v2 = schema({
|
|
135
|
+
version: "2.0.0",
|
|
136
|
+
tables: {
|
|
137
|
+
storageObject: storageObject2,
|
|
138
|
+
storageFolder
|
|
139
|
+
},
|
|
140
|
+
async up({ auto }) {
|
|
141
|
+
return [...beforeV2, ...await auto(), ...afterV2];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// src/fuma-db.ts
|
|
146
|
+
fumadb({
|
|
147
|
+
namespace: "dimah_s3",
|
|
148
|
+
schemas: [v1, v2]
|
|
149
|
+
});
|
|
150
|
+
var DB_SCHEMA_VERSION = v2.version;
|
|
151
|
+
|
|
152
|
+
// src/cli.ts
|
|
153
|
+
var MIGRATE_BATCH = 500;
|
|
154
|
+
function runCli(client) {
|
|
5
155
|
const { main } = createCli({
|
|
6
|
-
db,
|
|
156
|
+
db: client,
|
|
7
157
|
command: "dimah-s3-db",
|
|
8
158
|
description: "FumaDB CLI for @dimah-s3/db",
|
|
9
|
-
version: "
|
|
159
|
+
version: "2.0.0-beta.0"
|
|
10
160
|
});
|
|
11
161
|
return main();
|
|
12
162
|
}
|
|
163
|
+
async function migrate(client) {
|
|
164
|
+
const migrator = client.createMigrator();
|
|
165
|
+
for (let next = await migrator.next(); next; next = await migrator.next()) {
|
|
166
|
+
const from = await migrator.getVersion();
|
|
167
|
+
await (await migrator.up()).execute();
|
|
168
|
+
if (from === v1.version) await rewriteSizes(client);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async function rewriteSizes(client) {
|
|
172
|
+
const orm = client.orm(DB_SCHEMA_VERSION);
|
|
173
|
+
const toNumber = (value) => value === null ? null : Number(value);
|
|
174
|
+
let after;
|
|
175
|
+
for (; ; ) {
|
|
176
|
+
const rows = await orm.findMany("storageObject", {
|
|
177
|
+
select: ["id", "size", "declaredSize"],
|
|
178
|
+
where: (b) => b.and(
|
|
179
|
+
b.or(b.isNotNull("size"), b.isNotNull("declaredSize")),
|
|
180
|
+
after === void 0 || b("id", ">", after)
|
|
181
|
+
),
|
|
182
|
+
orderBy: [["id", "asc"]],
|
|
183
|
+
limit: MIGRATE_BATCH
|
|
184
|
+
});
|
|
185
|
+
for (const row of rows) {
|
|
186
|
+
if (typeof row.size !== "bigint" && typeof row.declaredSize !== "bigint") {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
await orm.updateMany("storageObject", {
|
|
190
|
+
where: (b) => b("id", "=", row.id),
|
|
191
|
+
set: {
|
|
192
|
+
size: toNumber(row.size),
|
|
193
|
+
declaredSize: toNumber(row.declaredSize)
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
if (rows.length < MIGRATE_BATCH) return;
|
|
198
|
+
after = rows.at(-1)?.id;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
13
201
|
|
|
14
|
-
export { runCli };
|
|
202
|
+
export { migrate, runCli };
|
|
15
203
|
//# sourceMappingURL=cli.js.map
|
|
16
204
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"names":[],"mappings":";;;AAOO,SAAS,OAAO,EAAA,EAAmC;AACxD,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,SAAA,CAAU;AAAA,IACzB,EAAA;AAAA,IACA,OAAA,EAAS,aAAA;AAAA,IACT,WAAA,EAAa,6BAAA;AAAA,IACb,OAAA,EAAS;AAAA,GACV,CAAA;AAED,EAAA,OAAO,IAAA,EAAK;AACd","file":"cli.js","sourcesContent":["import { createCli } from \"fumadb/cli\";\nimport type { InferFumaDB } from \"fumadb\";\nimport type { DimahS3DB } from \"./fuma-db\";\n\ndeclare const __DIMAH_S3_DB_VERSION__: string;\n\n/** Run the interactive FumaDB CLI (generate schema, migrate when using Kysely, etc.). */\nexport function runCli(db: InferFumaDB<typeof DimahS3DB>) {\n const { main } = createCli({\n db,\n command: \"dimah-s3-db\",\n description: \"FumaDB CLI for @dimah-s3/db\",\n version: __DIMAH_S3_DB_VERSION__,\n });\n\n return main();\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/schema/v1.ts","../src/schema/v2.ts","../src/fuma-db.ts","../src/cli.ts"],"names":["column","storageObject","table","idColumn","schema"],"mappings":";;;;;AAUA,IAAM,aAAA,GAAgB,MAAM,gBAAA,EAAkB;AAAA,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,CAAU,cAAc,CAAC,CAAA;AAAA,QACrD,KAAA,KAAU,MAAA,IAAa,CAAA,CAAE,IAAA,EAAM,KAAK,KAAK;AAAA,OAC3C;AAAA,MACF,OAAA,EAAS,CAAC,CAAC,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA,MACvB,KAAA,EAAO;AAAA,KACR,CAAA;AACD,IAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,MAAA,IACE,OAAO,GAAA,CAAI,IAAA,KAAS,YACpB,OAAO,GAAA,CAAI,iBAAiB,QAAA,EAC5B;AACA,QAAA;AAAA,MACF;AACA,MAAA,MAAM,GAAA,CAAI,WAAW,eAAA,EAAiB;AAAA,QACpC,OAAO,CAAC,CAAA,KAAM,EAAE,IAAA,EAAM,GAAA,EAAK,IAAI,EAAE,CAAA;AAAA,QACjC,GAAA,EAAK;AAAA,UACH,IAAA,EAAM,QAAA,CAAS,GAAA,CAAI,IAAI,CAAA;AAAA,UACvB,YAAA,EAAc,QAAA,CAAS,GAAA,CAAI,YAAY;AAAA;AACzC,OACD,CAAA;AAAA,IACH;AACA,IAAA,IAAI,IAAA,CAAK,SAAS,aAAA,EAAe;AACjC,IAAA,KAAA,GAAQ,IAAA,CAAK,EAAA,CAAG,EAAE,CAAA,EAAG,EAAA;AAAA,EACvB;AACF","file":"cli.js","sourcesContent":["import { column, idColumn, schema, table } from \"fumadb/schema\";\n\n/**\n * Schema 1.0.0, kept so the FumaDB migrator can move a 1.x database to\n * 2.0.0 (`v2.ts`). Nothing queries it.\n *\n * The `metadata` column has the ORM name `s3Metadata`, the name it has in\n * 2.0.0, so the migrator renames the column (and SQLite's table rebuild\n * copies it) instead of dropping its data.\n */\nconst storageObject = table(\"storage_object\", {\n id: idColumn(\"id\", \"varchar(255)\").defaultTo$(\"auto\"),\n scope: column(\"scope\", \"string\"),\n bucket: column(\"bucket\", \"string\"),\n key: column(\"key\", \"string\"),\n route: column(\"route\", \"string\"),\n contentType: column(\"content_type\", \"string\").nullable(),\n size: column(\"size\", \"bigint\").nullable(),\n eTag: column(\"e_tag\", \"string\").nullable(),\n filename: column(\"filename\", \"string\").nullable(),\n status: column(\"status\", \"string\"),\n s3Metadata: column(\"metadata\", \"json\").nullable(),\n acl: column(\"acl\", \"string\").nullable(),\n uploadId: column(\"upload_id\", \"string\").nullable(),\n declaredSize: column(\"declared_size\", \"bigint\").nullable(),\n confirmedAt: column(\"confirmed_at\", \"timestamp\").nullable(),\n expiresAt: column(\"expires_at\", \"timestamp\").nullable(),\n createdAt: column(\"created_at\", \"timestamp\").defaultTo$(\"now\"),\n updatedAt: column(\"updated_at\", \"timestamp\").defaultTo$(\"now\"),\n deletedAt: column(\"deleted_at\", \"timestamp\").nullable(),\n}).unique(\"storage_object_bucket_key_uk\", [\"bucket\", \"key\"]);\n\nexport const v1 = schema({\n version: \"1.0.0\",\n tables: {\n storageObject,\n },\n});\n","import { column, idColumn, schema, table, type Column } from \"fumadb/schema\";\n\n/**\n * A byte count. The column is a `bigint` (int8 on PostgreSQL and MySQL), but\n * values are bound as numbers so SQLite stores a number instead of FumaDB's\n * 8-byte blob, which would sort after every number: INTEGER in the shipped\n * SQL, or REAL in a column FumaDB created, compared by value either way.\n * Drivers read int8 back as a number, a bigint, or a string, and a 1.x\n * SQLite row not yet migrated still holds a blob (read as a bigint).\n */\nfunction byteCount(name: string) {\n return column(name, \"bigint\").nullable() as unknown as Column<\n \"bigint\",\n number | null,\n number | bigint | string | null\n >;\n}\n\n/**\n * One row per tracked object:\n * `pending` (presigned) → `active` (confirmed) → `deleted` (soft delete).\n * `purging` marks a stale pending row that purge has claimed.\n */\nconst storageObject = table(\"storage_object\", {\n id: idColumn(\"id\", \"varchar(255)\").defaultTo$(\"auto\"),\n /** Owner, for example `user:123` or `org:acme`. */\n scope: column(\"scope\", \"string\"),\n bucket: column(\"bucket\", \"string\"),\n key: column(\"key\", \"string\"),\n /** Named dimah-s3 route that created the object. */\n route: column(\"route\", \"string\"),\n /** Logical folder path. `null` is the root. */\n folder: column(\"folder\", \"string\").nullable(),\n filename: column(\"filename\", \"string\"),\n contentType: column(\"content_type\", \"string\").nullable(),\n /** Verified size from HeadObject, set on confirm. */\n size: byteCount(\"size\"),\n /** Size the client declared before confirm. Quota counts it while pending. */\n declaredSize: byteCount(\"declared_size\"),\n eTag: column(\"e_tag\", \"string\").nullable(),\n status: column(\"status\", \"string\"),\n /** S3 user metadata of the verified object. */\n s3Metadata: column(\"s3_metadata\", \"json\").nullable(),\n /** App attributes, validated by the plugin's `attributes.schema`. */\n attributes: column(\"attributes\", \"json\").nullable(),\n acl: column(\"acl\", \"string\").nullable(),\n /** Multipart upload ID while the row is pending. */\n uploadId: column(\"upload_id\", \"string\").nullable(),\n /** Token of the upload ticket that wrote the row. Confirm and purge match it. */\n uploadToken: column(\"upload_token\", \"string\").nullable(),\n /** Confirm deadline of a pending row (the upload ticket's expiry). */\n expiresAt: column(\"expires_at\", \"timestamp\").nullable(),\n confirmedAt: column(\"confirmed_at\", \"timestamp\").nullable(),\n createdAt: column(\"created_at\", \"timestamp\").defaultTo$(\"now\"),\n updatedAt: column(\"updated_at\", \"timestamp\").defaultTo$(\"now\"),\n deletedAt: column(\"deleted_at\", \"timestamp\").nullable(),\n}).unique(\"storage_object_bucket_key_uk\", [\"bucket\", \"key\"]);\n\n/** One row per folder, so an empty folder still lists. */\nconst storageFolder = table(\"storage_folder\", {\n id: idColumn(\"id\", \"varchar(255)\").defaultTo$(\"auto\"),\n scope: column(\"scope\", \"string\"),\n /** Full folder path. */\n path: column(\"path\", \"string\"),\n /** Path of the containing folder. `null` is the root. */\n parent: column(\"parent\", \"string\").nullable(),\n /** Last segment of `path`. */\n name: column(\"name\", \"string\"),\n createdAt: column(\"created_at\", \"timestamp\").defaultTo$(\"now\"),\n}).unique(\"storage_folder_scope_path_uk\", [\"scope\", \"path\"]);\n\n/** A secondary index, by SQL table and column names. */\nexport type SchemaIndex = {\n name: string;\n table: \"storage_object\" | \"storage_folder\";\n columns: readonly string[];\n};\n\n/**\n * Secondary indexes of schema 2.0.0. FumaDB cannot declare them, so the SQL\n * files, the Drizzle tables, and the Prisma schema carry them.\n */\nexport const v2Indexes: readonly SchemaIndex[] = [\n {\n name: \"storage_object_scope_folder_idx\",\n table: \"storage_object\",\n columns: [\"scope\", \"status\", \"folder\", \"created_at\"],\n },\n {\n name: \"storage_object_scope_updated_idx\",\n table: \"storage_object\",\n columns: [\"scope\", \"status\", \"updated_at\"],\n },\n {\n name: \"storage_object_scope_filename_idx\",\n table: \"storage_object\",\n columns: [\"scope\", \"status\", \"filename\"],\n },\n {\n name: \"storage_object_scope_size_idx\",\n table: \"storage_object\",\n columns: [\"scope\", \"status\", \"size\"],\n },\n {\n name: \"storage_object_status_expires_idx\",\n table: \"storage_object\",\n columns: [\"status\", \"expires_at\"],\n },\n {\n name: \"storage_folder_scope_parent_idx\",\n table: \"storage_folder\",\n columns: [\"scope\", \"parent\"],\n },\n];\n\n/** The secondary indexes 1.x recommended that 2.0.0 replaces. */\nconst v1Indexes = [\n \"storage_object_scope_status_created_idx\",\n \"storage_object_scope_route_idx\",\n \"storage_object_status_created_idx\",\n];\n\nconst custom = (sql: string) => ({ type: \"custom\" as const, sql });\n\n/**\n * The last segment of `key`, or the whole key when it ends in `/`, in syntax\n * SQLite and PostgreSQL share. Trimming every character but `/` from the\n * right leaves the key up to its last `/`.\n */\nconst keyName = `COALESCE(NULLIF(substr(\"key\", length(rtrim(\"key\", replace(\"key\", '/', ''))) + 1), ''), \"key\")`;\n\n/**\n * Runs before the statements FumaDB generates for 1.0.0 → 2.0.0, in syntax\n * SQLite and PostgreSQL share. `filename` becomes required, so a missing one\n * is filled from the key the way `sql/upgrade/1.0.0-2.0.0/<dialect>.sql`\n * does. `migrate()` converts 1.x SQLite blob sizes afterwards.\n */\nconst beforeV2 = [\n custom(\n `UPDATE \"storage_object\" SET \"filename\" = ${keyName} WHERE \"filename\" IS NULL`,\n ),\n];\n\n/** Runs after them: the 1.x recommended indexes give way to {@link v2Indexes}. */\nconst afterV2 = [\n ...v1Indexes.map((name) => custom(`DROP INDEX IF EXISTS \"${name}\"`)),\n ...v2Indexes.map((index) => {\n const columns = index.columns.map((name) => `\"${name}\"`).join(\", \");\n return custom(\n `CREATE INDEX IF NOT EXISTS \"${index.name}\" ON \"${index.table}\" (${columns})`,\n );\n }),\n];\n\n/**\n * Schema 2.0.0: logical folders (`folder` plus `storage_folder`), S3 metadata\n * split from typed `attributes`, the upload token, and the sort indexes.\n */\nexport const v2 = schema({\n version: \"2.0.0\",\n tables: {\n storageObject,\n storageFolder,\n },\n async up({ auto }) {\n return [...beforeV2, ...(await auto()), ...afterV2];\n },\n});\n","import { fumadb, type InferFumaDB } from \"fumadb\";\nimport { v1 } from \"./schema/v1\";\nimport { v2 } from \"./schema/v2\";\n\n/**\n * The @dimah-s3/db FumaDB library. Call `DimahS3DB.client(adapter)` with an\n * adapter from `@dimah-s3/db/adapters/*` to get a {@link DimahS3DbClient}.\n */\nexport const DimahS3DB = fumadb({\n namespace: \"dimah_s3\",\n schemas: [v1, v2],\n});\n\n/** FumaDB client for the @dimah-s3/db schemas. */\nexport type DimahS3DbClient = InferFumaDB<typeof DimahS3DB>;\n\n/** The schema version the stores read and write. */\nexport const DB_SCHEMA_VERSION = v2.version;\n\nexport { v2 };\n","import { createCli } from \"fumadb/cli\";\nimport { DB_SCHEMA_VERSION, type DimahS3DbClient } from \"./fuma-db\";\nimport { v1 } from \"./schema/v1\";\n\ndeclare const __DIMAH_S3_DB_VERSION__: string;\n\n/** Rows `migrate` rewrites per query. */\nconst MIGRATE_BATCH = 500;\n\n/**\n * Runs the interactive FumaDB CLI: generate the ORM schema, or migrate when\n * the client uses the Kysely adapter. Prefer {@link migrate} to migrate:\n * only `migrate:up`, one version at a time, runs the steps 2.0.0 needs,\n * and no CLI command converts 1.x SQLite sizes.\n *\n * ```ts\n * // scripts/db.ts\n * import { runCli } from \"@dimah-s3/db/cli\";\n * import { dimahS3Db } from \"../lib/s3\";\n *\n * await runCli(dimahS3Db);\n * ```\n */\nexport function runCli(client: DimahS3DbClient): Promise<void> {\n const { main } = createCli({\n db: client,\n command: \"dimah-s3-db\",\n description: \"FumaDB CLI for @dimah-s3/db\",\n version: __DIMAH_S3_DB_VERSION__,\n });\n\n return main();\n}\n\n/**\n * Migrates the database to the schema this version needs, from an empty\n * database or from schema 1.0.0, one version at a time, so each version's\n * own steps run (the 2.0.0 indexes among them). An upgrade from 1.0.0 also\n * turns 1.x SQLite blob sizes into numbers, like\n * `sql/upgrade/1.0.0-2.0.0/sqlite.sql`. It needs the Kysely adapter; with\n * Drizzle or Prisma, use your ORM's migrations or the files in `sql/`.\n *\n * ```ts\n * import { DimahS3DB } from \"@dimah-s3/db\";\n * import { kyselyAdapter } from \"@dimah-s3/db/adapters/kysely\";\n * import { migrate } from \"@dimah-s3/db/cli\";\n *\n * await migrate(DimahS3DB.client(kyselyAdapter({ db: kysely, provider: \"postgresql\" })));\n * ```\n */\nexport async function migrate(client: DimahS3DbClient): Promise<void> {\n const migrator = client.createMigrator();\n for (let next = await migrator.next(); next; next = await migrator.next()) {\n const from = await migrator.getVersion();\n await (await migrator.up()).execute();\n if (from === v1.version) await rewriteSizes(client);\n }\n}\n\n/**\n * Rewrites the sizes 1.x stored as FumaDB bigints. SQLite kept those as\n * 8-byte blobs, which sort after every number. FumaDB reads a blob back as\n * a bigint and stores a number as a number.\n */\nasync function rewriteSizes(client: DimahS3DbClient): Promise<void> {\n const orm = client.orm(DB_SCHEMA_VERSION);\n const toNumber = (value: number | bigint | string | null) =>\n value === null ? null : Number(value);\n let after: string | undefined;\n for (;;) {\n const rows = await orm.findMany(\"storageObject\", {\n select: [\"id\", \"size\", \"declaredSize\"],\n where: (b) =>\n b.and(\n b.or(b.isNotNull(\"size\"), b.isNotNull(\"declaredSize\")),\n after === undefined || b(\"id\", \">\", after),\n ),\n orderBy: [[\"id\", \"asc\"]],\n limit: MIGRATE_BATCH,\n });\n for (const row of rows) {\n if (\n typeof row.size !== \"bigint\" &&\n typeof row.declaredSize !== \"bigint\"\n ) {\n continue;\n }\n await orm.updateMany(\"storageObject\", {\n where: (b) => b(\"id\", \"=\", row.id),\n set: {\n size: toNumber(row.size),\n declaredSize: toNumber(row.declaredSize),\n },\n });\n }\n if (rows.length < MIGRATE_BATCH) return;\n after = rows.at(-1)?.id;\n }\n}\n"]}
|
|
@@ -1,98 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type { DbClientGetInput, DbClientListInput, DbClientListResponse, DbClientObject, } from "../types/storage-object.js";
|
|
1
|
+
import type { DbClientActions } from "../types/client.js";
|
|
3
2
|
/**
|
|
4
|
-
* Client plugin for the server `db()` endpoints.
|
|
3
|
+
* Client plugin for the server `db()` endpoints. Its actions are
|
|
4
|
+
* {@link DbClientActions} on `api.db`. Pass `TClientAttributes` to type the
|
|
5
|
+
* `attributes` the plugin's `attributes.toClient` returns.
|
|
5
6
|
*
|
|
6
7
|
* ```ts
|
|
7
8
|
* import { createS3Client } from "@dimah-s3/react";
|
|
8
9
|
* import { dbClient } from "@dimah-s3/db/client";
|
|
9
10
|
*
|
|
10
|
-
* export const
|
|
11
|
+
* export const s3Client = createS3Client({
|
|
11
12
|
* plugins: [dbClient()],
|
|
12
13
|
* });
|
|
13
14
|
*
|
|
14
|
-
* await
|
|
15
|
+
* const page = await s3Client.db.listObjects({ folder: "" });
|
|
15
16
|
* ```
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* wrapper for `GET /db/objects`.
|
|
18
|
+
* The server resolves the scope from the request, so no action takes one.
|
|
19
|
+
* Server code skips HTTP and uses `s3.db.objects` and `s3.db.folders`.
|
|
20
20
|
*/
|
|
21
|
-
export declare function dbClient(): import("@dimah-s3/core").S3ClientPlugin<"db",
|
|
22
|
-
/**
|
|
23
|
-
* List the caller's objects and usage. Scope comes from server `resolveScope`
|
|
24
|
-
* — not a parameter here. For another scope, use `listByScope` on the server.
|
|
25
|
-
* Pass `init.signal` to cancel the request.
|
|
26
|
-
*/
|
|
27
|
-
listObjects: (input?: DbClientListInput, init?: {
|
|
28
|
-
signal?: AbortSignal;
|
|
29
|
-
}) => Promise<DbClientListResponse>;
|
|
30
|
-
getObject: (input: DbClientGetInput) => Promise<{
|
|
31
|
-
object: DbClientObject;
|
|
32
|
-
}>;
|
|
33
|
-
}, import("@dimah-s3/server").DimahS3Plugin<"db", {
|
|
34
|
-
objects: import("..").StorageObjectStore;
|
|
35
|
-
client: import("fumadb").FumaDB<import("fumadb/schema").Schema<"1.0.0", {
|
|
36
|
-
storageObject: import("fumadb/schema").Table<{
|
|
37
|
-
id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
|
|
38
|
-
scope: import("fumadb/schema").Column<"string", string, string>;
|
|
39
|
-
bucket: import("fumadb/schema").Column<"string", string, string>;
|
|
40
|
-
key: import("fumadb/schema").Column<"string", string, string>;
|
|
41
|
-
route: import("fumadb/schema").Column<"string", string, string>;
|
|
42
|
-
contentType: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
43
|
-
size: import("fumadb/schema").Column<"bigint", bigint | null, bigint | null>;
|
|
44
|
-
eTag: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
45
|
-
filename: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
46
|
-
status: import("fumadb/schema").Column<"string", string, string>;
|
|
47
|
-
metadata: import("fumadb/schema").Column<"json", unknown, unknown>;
|
|
48
|
-
acl: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
49
|
-
uploadId: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
50
|
-
declaredSize: import("fumadb/schema").Column<"bigint", bigint | null, bigint | null>;
|
|
51
|
-
confirmedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
52
|
-
expiresAt: 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>;
|
|
56
|
-
}, {}>;
|
|
57
|
-
}>[]> | import("..").StorageObjectStore;
|
|
58
|
-
}, {
|
|
59
|
-
objects: import("better-call").StrictEndpoint<string, {
|
|
60
|
-
use: import("better-call").MiddlewareHandler[];
|
|
61
|
-
} & {
|
|
62
|
-
method: "GET";
|
|
63
|
-
} & {
|
|
64
|
-
query: import("better-call").StandardSchemaV1<{
|
|
65
|
-
status?: "active" | "deleted" | "pending" | undefined;
|
|
66
|
-
limit?: string | number | undefined;
|
|
67
|
-
offset?: string | number | undefined;
|
|
68
|
-
cursor?: string | undefined;
|
|
69
|
-
route?: string | undefined;
|
|
70
|
-
contentType?: string | undefined;
|
|
71
|
-
prefix?: string | undefined;
|
|
72
|
-
}, {
|
|
73
|
-
status?: "active" | "deleted" | "pending" | undefined;
|
|
74
|
-
limit?: string | number | undefined;
|
|
75
|
-
offset?: string | number | undefined;
|
|
76
|
-
cursor?: string | undefined;
|
|
77
|
-
route?: string | undefined;
|
|
78
|
-
contentType?: string | undefined;
|
|
79
|
-
prefix?: string | undefined;
|
|
80
|
-
}>;
|
|
81
|
-
}, DbClientListResponse>;
|
|
82
|
-
object: import("better-call").StrictEndpoint<string, {
|
|
83
|
-
use: import("better-call").MiddlewareHandler[];
|
|
84
|
-
} & {
|
|
85
|
-
method: "GET";
|
|
86
|
-
} & {
|
|
87
|
-
query: import("better-call").StandardSchemaV1<{
|
|
88
|
-
key: string;
|
|
89
|
-
bucket?: string | undefined;
|
|
90
|
-
}, {
|
|
91
|
-
key: string;
|
|
92
|
-
bucket?: string | undefined;
|
|
93
|
-
}>;
|
|
94
|
-
}, {
|
|
95
|
-
object: DbClientObject;
|
|
96
|
-
}>;
|
|
97
|
-
}>>;
|
|
21
|
+
export declare function dbClient<TClientAttributes = never>(): import("@dimah-s3/core").S3ClientPlugin<"db", DbClientActions<TClientAttributes>, import("@dimah-s3/server/plugins").DimahS3Plugin<"db", import("../plugin/db.js").DbPluginContext<unknown>>>;
|
|
98
22
|
//# sourceMappingURL=db-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-client.d.ts","sourceRoot":"","sources":["../../src/client/db-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"db-client.d.ts","sourceRoot":"","sources":["../../src/client/db-client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EAKhB,MAAM,gBAAgB,CAAC;AAaxB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,iBAAiB,GAAG,KAAK,+LAkCjD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DbClientActions, DbObjectSource, DbObjectSourceOptions } from "../types/client.js";
|
|
2
|
+
/** The `api.db` actions {@link dbObjectSource} calls. */
|
|
3
|
+
export type DbObjectSourceActions<TClientAttributes = never> = Pick<DbClientActions<TClientAttributes>, "listObjects"> & Partial<Pick<DbClientActions<TClientAttributes>, "createFolder">>;
|
|
4
|
+
/**
|
|
5
|
+
* A `useObjectList` source over `api.db`.
|
|
6
|
+
*
|
|
7
|
+
* With `folders` on (the default), `parent` is a folder path: each page
|
|
8
|
+
* lists one folder, the first page carries its child folders, uploads go to
|
|
9
|
+
* the open folder, and "New folder" calls `api.db.createFolder`. With
|
|
10
|
+
* `folders: false`, the list is flat and has no folder actions.
|
|
11
|
+
*
|
|
12
|
+
* `search` matches the filename on the server. `sort` maps `name` to
|
|
13
|
+
* `filename`; `size` and `updatedAt` keep their names, and other fields keep
|
|
14
|
+
* the server's order (newest first). `usage` is the scope total with its
|
|
15
|
+
* caps, not the open folder's.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const list = useObjectList({
|
|
19
|
+
* ...dbObjectSource(api.db, { route: "docs" }),
|
|
20
|
+
* queryKey: ["docs"],
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function dbObjectSource<TClientAttributes = never>(db: DbObjectSourceActions<TClientAttributes>, options?: DbObjectSourceOptions): DbObjectSource<TClientAttributes>;
|
|
25
|
+
//# sourceMappingURL=db-object-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-object-source.d.ts","sourceRoot":"","sources":["../../src/client/db-object-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAKf,cAAc,EAEd,qBAAqB,EAEtB,MAAM,gBAAgB,CAAC;AAExB,yDAAyD;AACzD,MAAM,MAAM,qBAAqB,CAAC,iBAAiB,GAAG,KAAK,IAAI,IAAI,CACjE,eAAe,CAAC,iBAAiB,CAAC,EAClC,aAAa,CACd,GACC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;AA0BpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,iBAAiB,GAAG,KAAK,EACtD,EAAE,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,EAC5C,OAAO,GAAE,qBAA0B,GAClC,cAAc,CAAC,iBAAiB,CAAC,CAiDnC"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { dbClient } from "./db-client";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export type {
|
|
2
|
+
export { dbObjectSource, type DbObjectSourceActions } from "./db-object-source";
|
|
3
|
+
export type { DbClientActions, DbClientFolder, DbClientFolderInput, DbClientGetInput, DbClientListInput, DbClientListResponse, DbClientObject, DbClientObjectStatus, DbClientUpdateInput, DbListSort, DbListSortField, DbObjectSource, DbObjectSourceFile, DbObjectSourceFolder, DbObjectSourceOptions, DbObjectSourcePage, DbObjectSourceQueryInput, DbQuota, DbUsage, } from "../types/client.js";
|
|
4
|
+
export type { StorageObjectStatus } from "../types/storage-object.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChF,YAAY,EACV,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,OAAO,EACP,OAAO,GACR,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
|