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

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 (44) hide show
  1. package/README.md +3 -3
  2. package/dist/adapters/drizzle.d.ts +2 -1
  3. package/dist/adapters/drizzle.d.ts.map +1 -1
  4. package/dist/cli.d.ts +8 -9
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +31 -88
  7. package/dist/cli.js.map +1 -1
  8. package/dist/drizzle/mysql.d.ts +2 -1
  9. package/dist/drizzle/mysql.d.ts.map +1 -1
  10. package/dist/drizzle/mysql.js +5 -11
  11. package/dist/drizzle/mysql.js.map +1 -1
  12. package/dist/drizzle/pg.d.ts +2 -1
  13. package/dist/drizzle/pg.d.ts.map +1 -1
  14. package/dist/drizzle/pg.js +5 -11
  15. package/dist/drizzle/pg.js.map +1 -1
  16. package/dist/drizzle/shared.d.ts +3 -12
  17. package/dist/drizzle/shared.d.ts.map +1 -1
  18. package/dist/drizzle/sqlite.d.ts +2 -1
  19. package/dist/drizzle/sqlite.d.ts.map +1 -1
  20. package/dist/drizzle/sqlite.js +5 -11
  21. package/dist/drizzle/sqlite.js.map +1 -1
  22. package/dist/fuma-db.d.ts +5 -26
  23. package/dist/fuma-db.d.ts.map +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +25 -61
  27. package/dist/index.js.map +1 -1
  28. package/dist/schema/{v2.d.ts → schema.d.ts} +16 -7
  29. package/dist/schema/schema.d.ts.map +1 -0
  30. package/dist/store/create-db-store.d.ts +2 -2
  31. package/dist/store/map-row.d.ts +1 -1
  32. package/dist/store/object-store.d.ts +4 -4
  33. package/dist/store/object-store.d.ts.map +1 -1
  34. package/dist/store/schema-version.d.ts +1 -1
  35. package/package.json +9 -6
  36. package/src/drizzle/mysql.ts +172 -0
  37. package/src/drizzle/pg.ts +140 -0
  38. package/src/drizzle/sqlite.ts +144 -0
  39. package/dist/schema/v1.d.ts +0 -24
  40. package/dist/schema/v1.d.ts.map +0 -1
  41. package/dist/schema/v2.d.ts.map +0 -1
  42. package/sql/upgrade/1.0.0-2.0.0/mysql.sql +0 -71
  43. package/sql/upgrade/1.0.0-2.0.0/pg.sql +0 -47
  44. package/sql/upgrade/1.0.0-2.0.0/sqlite.sql +0 -119
@@ -6,15 +6,24 @@ export type SchemaIndex = {
6
6
  columns: readonly string[];
7
7
  };
8
8
  /**
9
- * Secondary indexes of schema 2.0.0. FumaDB cannot declare them, so the SQL
10
- * files, the Drizzle tables, and the Prisma schema carry them.
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.
11
12
  */
12
- export declare const v2Indexes: readonly SchemaIndex[];
13
+ export declare const schemaIndexes: readonly SchemaIndex[];
13
14
  /**
14
- * Schema 2.0.0: logical folders (`folder` plus `storage_folder`), S3 metadata
15
- * split from typed `attributes`, the upload token, and the sort indexes.
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}.
16
19
  */
17
- export declare const v2: import("fumadb/schema").Schema<"2.0.0", {
20
+ export declare const PREDECESSOR_VERSION = "0.0.1";
21
+ export declare const predecessor: import("fumadb/schema").Schema<"0.0.1", {}>;
22
+ /**
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.
25
+ */
26
+ export declare const dbSchema: import("fumadb/schema").Schema<"2.0.0", {
18
27
  storageObject: import("fumadb/schema").Table<{
19
28
  id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
20
29
  /** Owner, for example `user:123` or `org:acme`. */
@@ -61,4 +70,4 @@ export declare const v2: import("fumadb/schema").Schema<"2.0.0", {
61
70
  createdAt: Column<"timestamp", Date | null, Date>;
62
71
  }, {}>;
63
72
  }>;
64
- //# sourceMappingURL=v2.d.ts.map
73
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +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"}
@@ -10,8 +10,8 @@ export type DbStore<TAttributes = never> = {
10
10
  };
11
11
  /**
12
12
  * Creates the object and folder stores. The first query checks the schema
13
- * version, so a 1.x database throws instead of being read with the wrong
14
- * columns. A failed check runs again on the next query.
13
+ * version, so a database at another version throws instead of being read
14
+ * with the wrong columns. A failed check runs again on the next query.
15
15
  */
16
16
  export declare function createDbStore<TAttributes = never>(client: DimahS3DbClient): DbStore<TAttributes>;
17
17
  //# sourceMappingURL=create-db-store.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import type { StorageObject } from "../types/storage-object.js";
2
2
  /**
3
3
  * A byte count as a driver returns it: a number, a bigint, or a string
4
- * (PostgreSQL int8). A 1.x SQLite row still holds a blob, read as a bigint.
4
+ * (PostgreSQL int8).
5
5
  */
6
6
  type ByteCount = number | bigint | string | null;
7
7
  /** Raw `storage_object` row as the FumaDB ORM returns it. */
@@ -1,13 +1,13 @@
1
1
  import type { AbstractQuery, FindManyOptions } from "fumadb/query";
2
- import type { v2 } from "../schema/v2.js";
2
+ import type { dbSchema } from "../schema/schema.js";
3
3
  import type { DbListSort, DbUsage } from "../types/client.js";
4
4
  import type { StorageObject, StorageObjectStatus } from "../types/storage-object.js";
5
- /** The FumaDB ORM for schema 2.0.0. */
6
- export type DbOrm = AbstractQuery<typeof v2>;
5
+ /** The FumaDB ORM for the schema the stores read. */
6
+ export type DbOrm = AbstractQuery<typeof dbSchema>;
7
7
  /** Resolves the ORM once the schema version is checked. */
8
8
  export type GetDbOrm = () => Promise<DbOrm>;
9
9
  /** Condition builder of a `storage_object` query. */
10
- export type ObjectConditions = Parameters<NonNullable<FindManyOptions<(typeof v2.tables)["storageObject"]>["where"]>>[0];
10
+ export type ObjectConditions = Parameters<NonNullable<FindManyOptions<(typeof dbSchema.tables)["storageObject"]>["where"]>>[0];
11
11
  type Condition = ReturnType<ObjectConditions> | boolean;
12
12
  /** Rows per page when `limit` is not given. */
13
13
  export declare const DEFAULT_LIST_LIMIT = 50;
@@ -1 +1 @@
1
- {"version":3,"file":"object-store.d.ts","sourceRoot":"","sources":["../../src/store/object-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAUhC,uCAAuC;AACv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Y,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,2EAA2E;IAC3E,YAAY,EAAE,CAAC,SAAS,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACpD,CAAC;AAiBF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,iBAK3D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,CAMnE;AAED,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,GAAG,SAAS,CAKpE;AAwFD,wDAAwD;AACxD,wBAAgB,iBAAiB,CAAC,WAAW,GAAG,KAAK,EACnD,MAAM,EAAE,QAAQ,GACf,kBAAkB,CAAC,WAAW,CAAC,CAqZjC"}
@@ -1,7 +1,7 @@
1
1
  import { type DimahS3DbClient } from "../fuma-db.js";
2
2
  /**
3
3
  * Throws unless the database is at the schema the stores use
4
- * ({@link DB_SCHEMA_VERSION}). A 1.x database must be upgraded first.
4
+ * ({@link DB_SCHEMA_VERSION}).
5
5
  */
6
6
  export declare function checkSchemaVersion(client: DimahS3DbClient): Promise<void>;
7
7
  //# sourceMappingURL=schema-version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimah-s3/db",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Optional database plugin for dimah-s3 — track S3 object ownership, listings, and resumable uploads",
5
5
  "keywords": [
6
6
  "s3",
@@ -72,18 +72,21 @@
72
72
  "files": [
73
73
  "dist",
74
74
  "sql",
75
- "prisma"
75
+ "prisma",
76
+ "src/drizzle/sqlite.ts",
77
+ "src/drizzle/pg.ts",
78
+ "src/drizzle/mysql.ts"
76
79
  ],
77
80
  "dependencies": {
78
- "@dimah-s3/core": "2.0.0-beta.0",
81
+ "@dimah-s3/core": "2.0.0-beta.1",
79
82
  "@paralleldrive/cuid2": "^3.3.0",
80
83
  "fumadb": "~0.6.0",
81
84
  "zod": "^4.6.7"
82
85
  },
83
86
  "devDependencies": {
84
87
  "@aws-sdk/client-s3": "^3.1161.0",
85
- "@dimah-s3/react": "2.0.0-beta.0",
86
- "@dimah-s3/server": "2.0.0-beta.0",
88
+ "@dimah-s3/react": "2.0.0-beta.1",
89
+ "@dimah-s3/server": "2.0.0-beta.1",
87
90
  "@electric-sql/pglite": "^0.5.14",
88
91
  "@types/better-sqlite3": "^9.6.0",
89
92
  "@types/node": "^26.6.6",
@@ -103,7 +106,7 @@
103
106
  },
104
107
  "peerDependencies": {
105
108
  "@aws-sdk/client-s3": ">=3",
106
- "@dimah-s3/server": "2.0.0-beta.0",
109
+ "@dimah-s3/server": "2.0.0-beta.1",
107
110
  "@prisma/client": "^6.0.0 || ^7.0.0",
108
111
  "drizzle-orm": ">=1.0.0-rc.5 <2.0.0",
109
112
  "kysely": "^0.29.5"
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Drizzle schema for @dimah-s3/db on MySQL 8. Copy this file into your app
3
+ * (`db/schema.ts`) to own the tables and add columns. Keep the table names,
4
+ * the column names, and the `dimahS3Tables` keys: the adapter finds the
5
+ * tables by those keys. A column you add must be nullable or have a default.
6
+ * The plugin does not read or write it.
7
+ *
8
+ * Import `dimahS3Tables` from `@dimah-s3/db/drizzle/mysql` when the tables
9
+ * stay as they are. `drizzle-kit` then follows that import, and a later push
10
+ * drops a column that is not part of it.
11
+ *
12
+ * Columns, collations and indexes match `sql/mysql.sql`, including the
13
+ * prefix indexes on `key`, `folder`, `path` and `parent`. Keys, folders and
14
+ * scopes compare byte for byte (`utf8mb4_bin`), and file names
15
+ * case-insensitively (`utf8mb4_unicode_ci`). Requires `drizzle-orm` and
16
+ * `@paralleldrive/cuid2`.
17
+ */
18
+ import { createId } from "@paralleldrive/cuid2";
19
+ import { sql } from "drizzle-orm";
20
+ import {
21
+ bigint,
22
+ datetime,
23
+ index,
24
+ json,
25
+ mysqlTable,
26
+ text,
27
+ uniqueIndex,
28
+ varchar,
29
+ type MySqlColumn,
30
+ } from "drizzle-orm/mysql-core";
31
+
32
+ type StorageObjectStatus = "pending" | "active" | "deleted" | "purging";
33
+
34
+ const SCHEMA_VERSION = "2.0.0";
35
+
36
+ /** Collation of every text column but `filename`: byte for byte. */
37
+ const BINARY = "utf8mb4_bin";
38
+
39
+ function id() {
40
+ return string("id")
41
+ .primaryKey()
42
+ .$defaultFn(() => createId());
43
+ }
44
+
45
+ function string(name: string, length = 255) {
46
+ return varchar(name, { length }).collate(BINARY);
47
+ }
48
+
49
+ function timestamp(name: string) {
50
+ return datetime(name, { mode: "date", fsp: 3 });
51
+ }
52
+
53
+ function timestampNow(name: string) {
54
+ return timestamp(name)
55
+ .notNull()
56
+ .default(sql`CURRENT_TIMESTAMP(3)`)
57
+ .$defaultFn(() => new Date());
58
+ }
59
+
60
+ function byteCount(name: string) {
61
+ return bigint(name, { mode: "number" });
62
+ }
63
+
64
+ /** An index on the first `length` characters of a long column. */
65
+ function prefix(column: MySqlColumn, length: number) {
66
+ return sql`${column}(${sql.raw(String(length))})`;
67
+ }
68
+
69
+ /** The `storage_object` table: one row per tracked object. */
70
+ export const storageObject = mysqlTable(
71
+ "storage_object",
72
+ {
73
+ id: id(),
74
+ scope: string("scope").notNull(),
75
+ bucket: string("bucket").notNull(),
76
+ key: string("key", 1024).notNull(),
77
+ route: string("route").notNull(),
78
+ folder: string("folder", 1024),
79
+ filename: varchar("filename", { length: 255 })
80
+ .collate("utf8mb4_unicode_ci")
81
+ .notNull(),
82
+ contentType: string("content_type"),
83
+ size: byteCount("size"),
84
+ declaredSize: byteCount("declared_size"),
85
+ eTag: string("e_tag"),
86
+ status: string("status", 16).$type<StorageObjectStatus>().notNull(),
87
+ s3Metadata: json("s3_metadata").$type<Record<string, string>>(),
88
+ attributes: json("attributes"),
89
+ acl: string("acl"),
90
+ uploadId: text("upload_id").collate(BINARY),
91
+ uploadToken: string("upload_token", 64),
92
+ expiresAt: timestamp("expires_at"),
93
+ confirmedAt: timestamp("confirmed_at"),
94
+ createdAt: timestampNow("created_at"),
95
+ updatedAt: timestampNow("updated_at"),
96
+ deletedAt: timestamp("deleted_at"),
97
+ },
98
+ (table) => [
99
+ uniqueIndex("storage_object_bucket_key_uk").on(
100
+ table.bucket,
101
+ prefix(table.key, 512),
102
+ ),
103
+ index("storage_object_scope_folder_idx").on(
104
+ table.scope,
105
+ table.status,
106
+ prefix(table.folder, 255),
107
+ table.createdAt,
108
+ ),
109
+ index("storage_object_scope_updated_idx").on(
110
+ table.scope,
111
+ table.status,
112
+ table.updatedAt,
113
+ ),
114
+ index("storage_object_scope_filename_idx").on(
115
+ table.scope,
116
+ table.status,
117
+ table.filename,
118
+ ),
119
+ index("storage_object_scope_size_idx").on(
120
+ table.scope,
121
+ table.status,
122
+ table.size,
123
+ ),
124
+ index("storage_object_status_expires_idx").on(
125
+ table.status,
126
+ table.expiresAt,
127
+ ),
128
+ ],
129
+ );
130
+
131
+ /** The `storage_folder` table: one row per folder, so empty folders list. */
132
+ export const storageFolder = mysqlTable(
133
+ "storage_folder",
134
+ {
135
+ id: id(),
136
+ scope: string("scope").notNull(),
137
+ path: string("path", 1024).notNull(),
138
+ parent: string("parent", 1024),
139
+ name: string("name").notNull(),
140
+ createdAt: timestampNow("created_at"),
141
+ },
142
+ (table) => [
143
+ uniqueIndex("storage_folder_scope_path_uk").on(
144
+ table.scope,
145
+ prefix(table.path, 512),
146
+ ),
147
+ index("storage_folder_scope_parent_idx").on(
148
+ table.scope,
149
+ prefix(table.parent, 512),
150
+ ),
151
+ ],
152
+ );
153
+
154
+ /**
155
+ * The FumaDB settings table. The Drizzle adapter reads the schema version
156
+ * from the default of its `version` column, which is stored as `value`.
157
+ */
158
+ export const dimahS3Settings = mysqlTable("private_dimah_s3_settings", {
159
+ key: string("key").primaryKey(),
160
+ version: text("value").collate(BINARY).notNull().default(SCHEMA_VERSION),
161
+ });
162
+
163
+ /**
164
+ * Every @dimah-s3/db table. Spread it into your Drizzle schema and keep its
165
+ * keys, because the FumaDB Drizzle adapter finds tables by them:
166
+ * `drizzle({ client, relations: defineRelations({ ...dimahS3Tables }) })`.
167
+ */
168
+ export const dimahS3Tables = {
169
+ storageObject,
170
+ storageFolder,
171
+ private_dimah_s3_settings: dimahS3Settings,
172
+ };
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Drizzle schema for @dimah-s3/db on PostgreSQL. Copy this file into your
3
+ * app (`db/schema.ts`) to own the tables and add columns. Keep the table
4
+ * names, the column names, and the `dimahS3Tables` keys: the adapter finds
5
+ * the tables by those keys. A column you add must be nullable or have a
6
+ * default. The plugin does not read or write it.
7
+ *
8
+ * Import `dimahS3Tables` from `@dimah-s3/db/drizzle/pg` when the tables stay
9
+ * as they are. `drizzle-kit` then follows that import, and a later push
10
+ * drops a column that is not part of it.
11
+ *
12
+ * Matches `sql/pg.sql`. Requires `drizzle-orm` and `@paralleldrive/cuid2`.
13
+ */
14
+ import { createId } from "@paralleldrive/cuid2";
15
+ import { sql } from "drizzle-orm";
16
+ import {
17
+ bigint,
18
+ index,
19
+ json,
20
+ pgTable,
21
+ text,
22
+ timestamp,
23
+ unique,
24
+ varchar,
25
+ } from "drizzle-orm/pg-core";
26
+
27
+ type StorageObjectStatus = "pending" | "active" | "deleted" | "purging";
28
+
29
+ const SCHEMA_VERSION = "2.0.0";
30
+
31
+ function id() {
32
+ return varchar("id", { length: 255 })
33
+ .primaryKey()
34
+ .$defaultFn(() => createId());
35
+ }
36
+
37
+ function timestampNow(name: string) {
38
+ return timestamp(name)
39
+ .notNull()
40
+ .default(sql`CURRENT_TIMESTAMP`)
41
+ .$defaultFn(() => new Date());
42
+ }
43
+
44
+ function byteCount(name: string) {
45
+ return bigint(name, { mode: "number" });
46
+ }
47
+
48
+ /** The `storage_object` table: one row per tracked object. */
49
+ export const storageObject = pgTable(
50
+ "storage_object",
51
+ {
52
+ id: id(),
53
+ scope: text("scope").notNull(),
54
+ bucket: text("bucket").notNull(),
55
+ key: text("key").notNull(),
56
+ route: text("route").notNull(),
57
+ folder: text("folder"),
58
+ filename: text("filename").notNull(),
59
+ contentType: text("content_type"),
60
+ size: byteCount("size"),
61
+ declaredSize: byteCount("declared_size"),
62
+ eTag: text("e_tag"),
63
+ status: text("status").$type<StorageObjectStatus>().notNull(),
64
+ s3Metadata: json("s3_metadata").$type<Record<string, string>>(),
65
+ attributes: json("attributes"),
66
+ acl: text("acl"),
67
+ uploadId: text("upload_id"),
68
+ uploadToken: text("upload_token"),
69
+ expiresAt: timestamp("expires_at"),
70
+ confirmedAt: timestamp("confirmed_at"),
71
+ createdAt: timestampNow("created_at"),
72
+ updatedAt: timestampNow("updated_at"),
73
+ deletedAt: timestamp("deleted_at"),
74
+ },
75
+ (table) => [
76
+ unique("storage_object_bucket_key_uk").on(table.bucket, table.key),
77
+ index("storage_object_scope_folder_idx").on(
78
+ table.scope,
79
+ table.status,
80
+ table.folder,
81
+ table.createdAt,
82
+ ),
83
+ index("storage_object_scope_updated_idx").on(
84
+ table.scope,
85
+ table.status,
86
+ table.updatedAt,
87
+ ),
88
+ index("storage_object_scope_filename_idx").on(
89
+ table.scope,
90
+ table.status,
91
+ table.filename,
92
+ ),
93
+ index("storage_object_scope_size_idx").on(
94
+ table.scope,
95
+ table.status,
96
+ table.size,
97
+ ),
98
+ index("storage_object_status_expires_idx").on(
99
+ table.status,
100
+ table.expiresAt,
101
+ ),
102
+ ],
103
+ );
104
+
105
+ /** The `storage_folder` table: one row per folder, so empty folders list. */
106
+ export const storageFolder = pgTable(
107
+ "storage_folder",
108
+ {
109
+ id: id(),
110
+ scope: text("scope").notNull(),
111
+ path: text("path").notNull(),
112
+ parent: text("parent"),
113
+ name: text("name").notNull(),
114
+ createdAt: timestampNow("created_at"),
115
+ },
116
+ (table) => [
117
+ unique("storage_folder_scope_path_uk").on(table.scope, table.path),
118
+ index("storage_folder_scope_parent_idx").on(table.scope, table.parent),
119
+ ],
120
+ );
121
+
122
+ /**
123
+ * The FumaDB settings table. The Drizzle adapter reads the schema version
124
+ * from the default of its `version` column, which is stored as `value`.
125
+ */
126
+ export const dimahS3Settings = pgTable("private_dimah_s3_settings", {
127
+ key: varchar("key", { length: 255 }).primaryKey(),
128
+ version: text("value").notNull().default(SCHEMA_VERSION),
129
+ });
130
+
131
+ /**
132
+ * Every @dimah-s3/db table. Spread it into your Drizzle schema and keep its
133
+ * keys, because the FumaDB Drizzle adapter finds tables by them:
134
+ * `drizzle({ client, relations: defineRelations({ ...dimahS3Tables }) })`.
135
+ */
136
+ export const dimahS3Tables = {
137
+ storageObject,
138
+ storageFolder,
139
+ private_dimah_s3_settings: dimahS3Settings,
140
+ };
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Drizzle schema for @dimah-s3/db on SQLite. Copy this file into your app
3
+ * (`db/schema.ts`) to own the tables and add columns. Keep the table names,
4
+ * the column names, and the `dimahS3Tables` keys: the adapter finds the
5
+ * tables by those keys. A column you add must be nullable or have a default.
6
+ * The plugin does not read or write it.
7
+ *
8
+ * Import `dimahS3Tables` from `@dimah-s3/db/drizzle/sqlite` when the tables
9
+ * stay as they are. `drizzle-kit` then follows that import, and a later push
10
+ * drops a column that is not part of it.
11
+ *
12
+ * Timestamps are epoch milliseconds and sizes are integers, matching
13
+ * `sql/sqlite.sql`. Requires `drizzle-orm` and `@paralleldrive/cuid2`.
14
+ */
15
+ import { createId } from "@paralleldrive/cuid2";
16
+ import { sql } from "drizzle-orm";
17
+ import {
18
+ index,
19
+ integer,
20
+ sqliteTable,
21
+ text,
22
+ uniqueIndex,
23
+ } from "drizzle-orm/sqlite-core";
24
+
25
+ type StorageObjectStatus = "pending" | "active" | "deleted" | "purging";
26
+
27
+ const SCHEMA_VERSION = "2.0.0";
28
+
29
+ function id() {
30
+ return text("id")
31
+ .primaryKey()
32
+ .$defaultFn(() => createId());
33
+ }
34
+
35
+ function timestamp(name: string) {
36
+ return integer(name, { mode: "timestamp_ms" });
37
+ }
38
+
39
+ function timestampNow(name: string) {
40
+ return timestamp(name)
41
+ .notNull()
42
+ .default(sql`(strftime('%s', 'now') * 1000)`)
43
+ .$defaultFn(() => new Date());
44
+ }
45
+
46
+ function byteCount(name: string) {
47
+ return integer(name, { mode: "number" });
48
+ }
49
+
50
+ /** The `storage_object` table: one row per tracked object. */
51
+ export const storageObject = sqliteTable(
52
+ "storage_object",
53
+ {
54
+ id: id(),
55
+ scope: text("scope").notNull(),
56
+ bucket: text("bucket").notNull(),
57
+ key: text("key").notNull(),
58
+ route: text("route").notNull(),
59
+ folder: text("folder"),
60
+ filename: text("filename").notNull(),
61
+ contentType: text("content_type"),
62
+ size: byteCount("size"),
63
+ declaredSize: byteCount("declared_size"),
64
+ eTag: text("e_tag"),
65
+ status: text("status").$type<StorageObjectStatus>().notNull(),
66
+ s3Metadata: text("s3_metadata", { mode: "json" }).$type<
67
+ Record<string, string>
68
+ >(),
69
+ attributes: text("attributes", { mode: "json" }),
70
+ acl: text("acl"),
71
+ uploadId: text("upload_id"),
72
+ uploadToken: text("upload_token"),
73
+ expiresAt: timestamp("expires_at"),
74
+ confirmedAt: timestamp("confirmed_at"),
75
+ createdAt: timestampNow("created_at"),
76
+ updatedAt: timestampNow("updated_at"),
77
+ deletedAt: timestamp("deleted_at"),
78
+ },
79
+ (table) => [
80
+ uniqueIndex("storage_object_bucket_key_uk").on(table.bucket, table.key),
81
+ index("storage_object_scope_folder_idx").on(
82
+ table.scope,
83
+ table.status,
84
+ table.folder,
85
+ table.createdAt,
86
+ ),
87
+ index("storage_object_scope_updated_idx").on(
88
+ table.scope,
89
+ table.status,
90
+ table.updatedAt,
91
+ ),
92
+ index("storage_object_scope_filename_idx").on(
93
+ table.scope,
94
+ table.status,
95
+ table.filename,
96
+ ),
97
+ index("storage_object_scope_size_idx").on(
98
+ table.scope,
99
+ table.status,
100
+ table.size,
101
+ ),
102
+ index("storage_object_status_expires_idx").on(
103
+ table.status,
104
+ table.expiresAt,
105
+ ),
106
+ ],
107
+ );
108
+
109
+ /** The `storage_folder` table: one row per folder, so empty folders list. */
110
+ export const storageFolder = sqliteTable(
111
+ "storage_folder",
112
+ {
113
+ id: id(),
114
+ scope: text("scope").notNull(),
115
+ path: text("path").notNull(),
116
+ parent: text("parent"),
117
+ name: text("name").notNull(),
118
+ createdAt: timestampNow("created_at"),
119
+ },
120
+ (table) => [
121
+ uniqueIndex("storage_folder_scope_path_uk").on(table.scope, table.path),
122
+ index("storage_folder_scope_parent_idx").on(table.scope, table.parent),
123
+ ],
124
+ );
125
+
126
+ /**
127
+ * The FumaDB settings table. The Drizzle adapter reads the schema version
128
+ * from the default of its `version` column, which is stored as `value`.
129
+ */
130
+ export const dimahS3Settings = sqliteTable("private_dimah_s3_settings", {
131
+ key: text("key").primaryKey(),
132
+ version: text("value").notNull().default(SCHEMA_VERSION),
133
+ });
134
+
135
+ /**
136
+ * Every @dimah-s3/db table. Spread it into your Drizzle schema and keep its
137
+ * keys, because the FumaDB Drizzle adapter finds tables by them:
138
+ * `drizzle({ client, relations: defineRelations({ ...dimahS3Tables }) })`.
139
+ */
140
+ export const dimahS3Tables = {
141
+ storageObject,
142
+ storageFolder,
143
+ private_dimah_s3_settings: dimahS3Settings,
144
+ };
@@ -1,24 +0,0 @@
1
- export declare const v1: import("fumadb/schema").Schema<"1.0.0", {
2
- storageObject: import("fumadb/schema").Table<{
3
- id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
4
- scope: import("fumadb/schema").Column<"string", string, string>;
5
- bucket: import("fumadb/schema").Column<"string", string, string>;
6
- key: import("fumadb/schema").Column<"string", string, string>;
7
- route: import("fumadb/schema").Column<"string", string, string>;
8
- contentType: import("fumadb/schema").Column<"string", string | null, string | null>;
9
- size: import("fumadb/schema").Column<"bigint", bigint | null, bigint | null>;
10
- eTag: import("fumadb/schema").Column<"string", string | null, string | null>;
11
- filename: import("fumadb/schema").Column<"string", string | null, string | null>;
12
- status: import("fumadb/schema").Column<"string", string, string>;
13
- s3Metadata: import("fumadb/schema").Column<"json", unknown, unknown>;
14
- acl: import("fumadb/schema").Column<"string", string | null, string | null>;
15
- uploadId: import("fumadb/schema").Column<"string", string | null, string | null>;
16
- declaredSize: import("fumadb/schema").Column<"bigint", bigint | null, bigint | null>;
17
- confirmedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
18
- expiresAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
19
- createdAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
20
- updatedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
21
- deletedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
22
- }, {}>;
23
- }>;
24
- //# sourceMappingURL=v1.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v1.d.ts","sourceRoot":"","sources":["../../src/schema/v1.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;EAKb,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../src/schema/v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAuE7E,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;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,WAAW,EA+B3C,CAAC;AAyCF;;;GAGG;AACH,eAAO,MAAM,EAAE;;;QArIb,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;;;;EAqG9B,CAAC"}