@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
package/src/drizzle/pg.ts DELETED
@@ -1,140 +0,0 @@
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
- };
@@ -1,144 +0,0 @@
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
- };