@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/drizzle/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIzB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { sqliteTable, text, uniqueIndex, index, integer } from 'drizzle-orm/sqlite-core';
|
|
3
|
+
import { createId } from '@paralleldrive/cuid2';
|
|
4
|
+
|
|
5
|
+
// src/drizzle/sqlite.ts
|
|
6
|
+
var DIMAH_S3_SCHEMA_VERSION = "2.0.0";
|
|
7
|
+
var runtimeDefaults = {
|
|
8
|
+
id: () => createId(),
|
|
9
|
+
now: () => /* @__PURE__ */ new Date()
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/drizzle/sqlite.ts
|
|
13
|
+
function id() {
|
|
14
|
+
return text("id").primaryKey().$defaultFn(runtimeDefaults.id);
|
|
15
|
+
}
|
|
16
|
+
function timestamp(name) {
|
|
17
|
+
return integer(name, { mode: "timestamp_ms" });
|
|
18
|
+
}
|
|
19
|
+
function timestampNow(name) {
|
|
20
|
+
return timestamp(name).notNull().default(sql`(strftime('%s', 'now') * 1000)`).$defaultFn(runtimeDefaults.now);
|
|
21
|
+
}
|
|
22
|
+
function byteCount(name) {
|
|
23
|
+
return integer(name, { mode: "number" });
|
|
24
|
+
}
|
|
25
|
+
var storageObject = sqliteTable(
|
|
26
|
+
"storage_object",
|
|
27
|
+
{
|
|
28
|
+
id: id(),
|
|
29
|
+
scope: text("scope").notNull(),
|
|
30
|
+
bucket: text("bucket").notNull(),
|
|
31
|
+
key: text("key").notNull(),
|
|
32
|
+
route: text("route").notNull(),
|
|
33
|
+
folder: text("folder"),
|
|
34
|
+
filename: text("filename").notNull(),
|
|
35
|
+
contentType: text("content_type"),
|
|
36
|
+
size: byteCount("size"),
|
|
37
|
+
declaredSize: byteCount("declared_size"),
|
|
38
|
+
eTag: text("e_tag"),
|
|
39
|
+
status: text("status").$type().notNull(),
|
|
40
|
+
s3Metadata: text("s3_metadata", { mode: "json" }).$type(),
|
|
41
|
+
attributes: text("attributes", { mode: "json" }),
|
|
42
|
+
acl: text("acl"),
|
|
43
|
+
uploadId: text("upload_id"),
|
|
44
|
+
uploadToken: text("upload_token"),
|
|
45
|
+
expiresAt: timestamp("expires_at"),
|
|
46
|
+
confirmedAt: timestamp("confirmed_at"),
|
|
47
|
+
createdAt: timestampNow("created_at"),
|
|
48
|
+
updatedAt: timestampNow("updated_at"),
|
|
49
|
+
deletedAt: timestamp("deleted_at")
|
|
50
|
+
},
|
|
51
|
+
(table) => [
|
|
52
|
+
uniqueIndex("storage_object_bucket_key_uk").on(table.bucket, table.key),
|
|
53
|
+
index("storage_object_scope_folder_idx").on(
|
|
54
|
+
table.scope,
|
|
55
|
+
table.status,
|
|
56
|
+
table.folder,
|
|
57
|
+
table.createdAt
|
|
58
|
+
),
|
|
59
|
+
index("storage_object_scope_updated_idx").on(
|
|
60
|
+
table.scope,
|
|
61
|
+
table.status,
|
|
62
|
+
table.updatedAt
|
|
63
|
+
),
|
|
64
|
+
index("storage_object_scope_filename_idx").on(
|
|
65
|
+
table.scope,
|
|
66
|
+
table.status,
|
|
67
|
+
table.filename
|
|
68
|
+
),
|
|
69
|
+
index("storage_object_scope_size_idx").on(
|
|
70
|
+
table.scope,
|
|
71
|
+
table.status,
|
|
72
|
+
table.size
|
|
73
|
+
),
|
|
74
|
+
index("storage_object_status_expires_idx").on(
|
|
75
|
+
table.status,
|
|
76
|
+
table.expiresAt
|
|
77
|
+
)
|
|
78
|
+
]
|
|
79
|
+
);
|
|
80
|
+
var storageFolder = sqliteTable(
|
|
81
|
+
"storage_folder",
|
|
82
|
+
{
|
|
83
|
+
id: id(),
|
|
84
|
+
scope: text("scope").notNull(),
|
|
85
|
+
path: text("path").notNull(),
|
|
86
|
+
parent: text("parent"),
|
|
87
|
+
name: text("name").notNull(),
|
|
88
|
+
createdAt: timestampNow("created_at")
|
|
89
|
+
},
|
|
90
|
+
(table) => [
|
|
91
|
+
uniqueIndex("storage_folder_scope_path_uk").on(table.scope, table.path),
|
|
92
|
+
index("storage_folder_scope_parent_idx").on(table.scope, table.parent)
|
|
93
|
+
]
|
|
94
|
+
);
|
|
95
|
+
var dimahS3Settings = sqliteTable("private_dimah_s3_settings", {
|
|
96
|
+
key: text("key").primaryKey(),
|
|
97
|
+
version: text("value").notNull().default(DIMAH_S3_SCHEMA_VERSION)
|
|
98
|
+
});
|
|
99
|
+
var dimahS3Tables = {
|
|
100
|
+
storageObject,
|
|
101
|
+
storageFolder,
|
|
102
|
+
private_dimah_s3_settings: dimahS3Settings
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export { dimahS3Settings, dimahS3Tables, storageFolder, storageObject };
|
|
106
|
+
//# sourceMappingURL=sqlite.js.map
|
|
107
|
+
//# sourceMappingURL=sqlite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/drizzle/shared.ts","../../src/drizzle/sqlite.ts"],"names":[],"mappings":";;;;;AAMO,IAAM,uBAAA,GAA0B,OAAA;AAQhC,IAAM,eAAA,GAAkB;AAAA,EAC7B,EAAA,EAAI,MAAM,QAAA,EAAS;AAAA,EACnB,GAAA,EAAK,sBAAM,IAAI,IAAA;AACjB,CAAA;;;ACFA,SAAS,EAAA,GAAK;AACZ,EAAA,OAAO,KAAK,IAAI,CAAA,CAAE,YAAW,CAAE,UAAA,CAAW,gBAAgB,EAAE,CAAA;AAC9D;AAEA,SAAS,UAAU,IAAA,EAAc;AAC/B,EAAA,OAAO,OAAA,CAAQ,IAAA,EAAM,EAAE,IAAA,EAAM,gBAAgB,CAAA;AAC/C;AAEA,SAAS,aAAa,IAAA,EAA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AAA,CAAE,OAAA,EAAQ;AAAA,IAC7B,IAAA,EAAM,IAAA,CAAK,MAAM,CAAA,CAAE,OAAA,EAAQ;AAAA,IAC3B,MAAA,EAAQ,KAAK,QAAQ,CAAA;AAAA,IACrB,IAAA,EAAM,IAAA,CAAK,MAAM,CAAA,CAAE,OAAA,EAAQ;AAAA,IAC3B,SAAA,EAAW,aAAa,YAAY;AAAA,GACtC;AAAA,EACA,CAAC,KAAA,KAAU;AAAA,IACT,YAAY,8BAA8B,CAAA,CAAE,GAAG,KAAA,CAAM,KAAA,EAAO,MAAM,IAAI,CAAA;AAAA,IACtE,MAAM,iCAAiC,CAAA,CAAE,GAAG,KAAA,CAAM,KAAA,EAAO,MAAM,MAAM;AAAA;AAEzE;AAMO,IAAM,eAAA,GAAkB,YAAY,2BAAA,EAA6B;AAAA,EACtE,GAAA,EAAK,IAAA,CAAK,KAAK,CAAA,CAAE,UAAA,EAAW;AAAA,EAC5B,SAAS,IAAA,CAAK,OAAO,EAAE,OAAA,EAAQ,CAAE,QAAQ,uBAAuB;AAClE,CAAC;AAOM,IAAM,aAAA,GAAgB;AAAA,EAC3B,aAAA;AAAA,EACA,aAAA;AAAA,EACA,yBAAA,EAA2B;AAC7B","file":"sqlite.js","sourcesContent":["import { createId } from \"@paralleldrive/cuid2\";\n\n/**\n * Schema version the Drizzle tables describe. The parity test checks it\n * against the FumaDB schema.\n */\nexport const DIMAH_S3_SCHEMA_VERSION = \"2.0.0\";\n\n/**\n * The FumaDB Drizzle adapter leaves runtime defaults to Drizzle, so the\n * tables fill ids and timestamps the way the other adapters do: a cuid and\n * the app's clock. The SQL defaults only keep generated DDL in line with\n * `sql/<dialect>.sql`.\n */\nexport const runtimeDefaults = {\n id: () => createId(),\n now: () => new Date(),\n};\n","/**\n * Drizzle tables for @dimah-s3/db schema 2.0.0 on SQLite. They match\n * `sql/sqlite.sql`: timestamps are epoch milliseconds and sizes are integers.\n */\nimport { sql } from \"drizzle-orm\";\nimport {\n index,\n integer,\n sqliteTable,\n text,\n uniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\nimport type { StorageObjectStatus } from \"@/types/storage-object\";\nimport { DIMAH_S3_SCHEMA_VERSION, runtimeDefaults } from \"./shared\";\n\nfunction id() {\n return text(\"id\").primaryKey().$defaultFn(runtimeDefaults.id);\n}\n\nfunction timestamp(name: string) {\n return integer(name, { mode: \"timestamp_ms\" });\n}\n\nfunction timestampNow(name: string) {\n return timestamp(name)\n .notNull()\n .default(sql`(strftime('%s', 'now') * 1000)`)\n .$defaultFn(runtimeDefaults.now);\n}\n\nfunction byteCount(name: string) {\n return integer(name, { mode: \"number\" });\n}\n\n/** The `storage_object` table: one row per tracked object. */\nexport const storageObject = sqliteTable(\n \"storage_object\",\n {\n id: id(),\n scope: text(\"scope\").notNull(),\n bucket: text(\"bucket\").notNull(),\n key: text(\"key\").notNull(),\n route: text(\"route\").notNull(),\n folder: text(\"folder\"),\n filename: text(\"filename\").notNull(),\n contentType: text(\"content_type\"),\n size: byteCount(\"size\"),\n declaredSize: byteCount(\"declared_size\"),\n eTag: text(\"e_tag\"),\n status: text(\"status\").$type<StorageObjectStatus>().notNull(),\n s3Metadata: text(\"s3_metadata\", { mode: \"json\" }).$type<\n Record<string, string>\n >(),\n attributes: text(\"attributes\", { mode: \"json\" }),\n acl: text(\"acl\"),\n uploadId: text(\"upload_id\"),\n uploadToken: text(\"upload_token\"),\n expiresAt: timestamp(\"expires_at\"),\n confirmedAt: timestamp(\"confirmed_at\"),\n createdAt: timestampNow(\"created_at\"),\n updatedAt: timestampNow(\"updated_at\"),\n deletedAt: timestamp(\"deleted_at\"),\n },\n (table) => [\n uniqueIndex(\"storage_object_bucket_key_uk\").on(table.bucket, table.key),\n index(\"storage_object_scope_folder_idx\").on(\n table.scope,\n table.status,\n table.folder,\n table.createdAt,\n ),\n index(\"storage_object_scope_updated_idx\").on(\n table.scope,\n table.status,\n table.updatedAt,\n ),\n index(\"storage_object_scope_filename_idx\").on(\n table.scope,\n table.status,\n table.filename,\n ),\n index(\"storage_object_scope_size_idx\").on(\n table.scope,\n table.status,\n table.size,\n ),\n index(\"storage_object_status_expires_idx\").on(\n table.status,\n table.expiresAt,\n ),\n ],\n);\n\n/** The `storage_folder` table: one row per folder, so empty folders list. */\nexport const storageFolder = sqliteTable(\n \"storage_folder\",\n {\n id: id(),\n scope: text(\"scope\").notNull(),\n path: text(\"path\").notNull(),\n parent: text(\"parent\"),\n name: text(\"name\").notNull(),\n createdAt: timestampNow(\"created_at\"),\n },\n (table) => [\n uniqueIndex(\"storage_folder_scope_path_uk\").on(table.scope, table.path),\n index(\"storage_folder_scope_parent_idx\").on(table.scope, table.parent),\n ],\n);\n\n/**\n * The FumaDB settings table. The Drizzle adapter reads the schema version\n * from the default of its `version` column, which is stored as `value`.\n */\nexport const dimahS3Settings = sqliteTable(\"private_dimah_s3_settings\", {\n key: text(\"key\").primaryKey(),\n version: text(\"value\").notNull().default(DIMAH_S3_SCHEMA_VERSION),\n});\n\n/**\n * Every @dimah-s3/db table. Spread it into your Drizzle schema and keep its\n * keys, because the FumaDB Drizzle adapter finds tables by them:\n * `drizzle({ client, relations: defineRelations({ ...dimahS3Tables }) })`.\n */\nexport const dimahS3Tables = {\n storageObject,\n storageFolder,\n private_dimah_s3_settings: dimahS3Settings,\n};\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logical folder paths. A path is NFC-normalized and `/`-separated, with no
|
|
3
|
+
* leading or trailing `/`. `null` is the root in types and JSON. On the wire
|
|
4
|
+
* (`?folder=`, `clientMetadata.folder`) the root is `""`.
|
|
5
|
+
*/
|
|
6
|
+
/** Longest folder path, in characters. */
|
|
7
|
+
export declare const FOLDER_PATH_MAX_LENGTH = 1024;
|
|
8
|
+
/** Longest folder name (one path segment), in characters. */
|
|
9
|
+
export declare const FOLDER_NAME_MAX_LENGTH = 255;
|
|
10
|
+
/** Most segments in a folder path. Each one is a row the server keeps. */
|
|
11
|
+
export declare const FOLDER_MAX_DEPTH = 32;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the NFC form of `path`, or `null` when it is not a valid folder
|
|
14
|
+
* path. The root (`""`) is not a folder path.
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeFolderPath(path: string): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Reads a wire folder value. `""` is the root and returns `null`.
|
|
19
|
+
* @throws `FOLDER_INVALID` when the value is not a valid folder path.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseFolder(value: string): string | null;
|
|
22
|
+
/** Writes a folder for the wire. The root becomes `""`. */
|
|
23
|
+
export declare function formatFolder(folder: string | null): string;
|
|
24
|
+
/** Appends `name` to `parent`. The result is not validated. */
|
|
25
|
+
export declare function joinFolderPath(parent: string | null, name: string): string;
|
|
26
|
+
/** The folder that contains `path`. `null` for a top-level folder. */
|
|
27
|
+
export declare function parentFolderPath(path: string): string | null;
|
|
28
|
+
/** The last segment of `path`. */
|
|
29
|
+
export declare function folderName(path: string): string;
|
|
30
|
+
/** Every folder from the top level down to `path` itself. */
|
|
31
|
+
export declare function folderAncestors(path: string): string[];
|
|
32
|
+
//# sourceMappingURL=folder-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folder-path.d.ts","sourceRoot":"","sources":["../src/folder-path.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,0CAA0C;AAC1C,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAqBnC;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO/D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKxD;AAED,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE1D;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG5D;AAED,kCAAkC;AAClC,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAGtD"}
|
package/dist/fuma-db.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type InferFumaDB } from "fumadb";
|
|
2
|
+
import { v2 } from "./schema/v2";
|
|
3
|
+
/**
|
|
4
|
+
* The @dimah-s3/db FumaDB library. Call `DimahS3DB.client(adapter)` with an
|
|
5
|
+
* adapter from `@dimah-s3/db/adapters/*` to get a {@link DimahS3DbClient}.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DimahS3DB: import("fumadb").FumaDBFactory<(import("fumadb/schema").Schema<"1.0.0", {
|
|
3
8
|
storageObject: import("fumadb/schema").Table<{
|
|
4
9
|
id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
|
|
5
10
|
scope: import("fumadb/schema").Column<"string", string, string>;
|
|
@@ -11,7 +16,7 @@ export declare const DimahS3DB: import("fumadb").FumaDBFactory<import("fumadb/sc
|
|
|
11
16
|
eTag: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
12
17
|
filename: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
13
18
|
status: import("fumadb/schema").Column<"string", string, string>;
|
|
14
|
-
|
|
19
|
+
s3Metadata: import("fumadb/schema").Column<"json", unknown, unknown>;
|
|
15
20
|
acl: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
16
21
|
uploadId: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
17
22
|
declaredSize: import("fumadb/schema").Column<"bigint", bigint | null, bigint | null>;
|
|
@@ -21,6 +26,43 @@ export declare const DimahS3DB: import("fumadb").FumaDBFactory<import("fumadb/sc
|
|
|
21
26
|
updatedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
|
|
22
27
|
deletedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
23
28
|
}, {}>;
|
|
24
|
-
}>
|
|
25
|
-
|
|
29
|
+
}> | import("fumadb/schema").Schema<"2.0.0", {
|
|
30
|
+
storageObject: import("fumadb/schema").Table<{
|
|
31
|
+
id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
|
|
32
|
+
scope: import("fumadb/schema").Column<"string", string, string>;
|
|
33
|
+
bucket: import("fumadb/schema").Column<"string", string, string>;
|
|
34
|
+
key: import("fumadb/schema").Column<"string", string, string>;
|
|
35
|
+
route: import("fumadb/schema").Column<"string", string, string>;
|
|
36
|
+
folder: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
37
|
+
filename: import("fumadb/schema").Column<"string", string, string>;
|
|
38
|
+
contentType: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
39
|
+
size: import("fumadb/schema").Column<"bigint", number | null, string | number | bigint | null>;
|
|
40
|
+
declaredSize: import("fumadb/schema").Column<"bigint", number | null, string | number | bigint | null>;
|
|
41
|
+
eTag: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
42
|
+
status: import("fumadb/schema").Column<"string", string, string>;
|
|
43
|
+
s3Metadata: import("fumadb/schema").Column<"json", unknown, unknown>;
|
|
44
|
+
attributes: import("fumadb/schema").Column<"json", unknown, unknown>;
|
|
45
|
+
acl: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
46
|
+
uploadId: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
47
|
+
uploadToken: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
48
|
+
expiresAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
49
|
+
confirmedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
50
|
+
createdAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
|
|
51
|
+
updatedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
|
|
52
|
+
deletedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
53
|
+
}, {}>;
|
|
54
|
+
storageFolder: import("fumadb/schema").Table<{
|
|
55
|
+
id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
|
|
56
|
+
scope: import("fumadb/schema").Column<"string", string, string>;
|
|
57
|
+
path: import("fumadb/schema").Column<"string", string, string>;
|
|
58
|
+
parent: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
59
|
+
name: import("fumadb/schema").Column<"string", string, string>;
|
|
60
|
+
createdAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
|
|
61
|
+
}, {}>;
|
|
62
|
+
}>)[]>;
|
|
63
|
+
/** FumaDB client for the @dimah-s3/db schemas. */
|
|
64
|
+
export type DimahS3DbClient = InferFumaDB<typeof DimahS3DB>;
|
|
65
|
+
/** The schema version the stores read and write. */
|
|
66
|
+
export declare const DB_SCHEMA_VERSION: "2.0.0";
|
|
67
|
+
export { v2 };
|
|
26
68
|
//# sourceMappingURL=fuma-db.d.ts.map
|
package/dist/fuma-db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuma-db.d.ts","sourceRoot":"","sources":["../src/fuma-db.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fuma-db.d.ts","sourceRoot":"","sources":["../src/fuma-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAGpB,CAAC;AAEH,kDAAkD;AAClD,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,OAAO,SAAS,CAAC,CAAC;AAE5D,oDAAoD;AACpD,eAAO,MAAM,iBAAiB,SAAa,CAAC;AAE5C,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
export { DimahS3DB,
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export type {
|
|
6
|
-
export {
|
|
7
|
-
export type {
|
|
8
|
-
export {
|
|
9
|
-
export type {
|
|
10
|
-
export { createQuotaGuard } from "./hooks/create-quota-guard";
|
|
11
|
-
export type { CreateQuotaGuardOptions, QuotaGuardContext, } from "./hooks/create-quota-guard";
|
|
12
|
-
export { purgeStalePendingObjects } from "./jobs/purge-stale-pending";
|
|
13
|
-
export type { PurgeStalePendingOptions, PurgeStalePendingResult, } from "./jobs/purge-stale-pending";
|
|
1
|
+
export { DB_SCHEMA_VERSION, DimahS3DB, v2, type DimahS3DbClient, } from "./fuma-db";
|
|
2
|
+
export { db, type DbPluginContext } from "./plugin/db";
|
|
3
|
+
export type { PruneDeletedOptions, PurgeStaleOptions, PurgeStaleResult, } from "./plugin/purge";
|
|
4
|
+
export type { DbFolders, DbObjects } from "./plugin/public-stores";
|
|
5
|
+
export type { AuthorizeContext, DbAttributesOptions, DbPluginOptions, DbQuotaOption, DbRouteOptions, ScopeContext, ScopeOperation, } from "./types/plugin";
|
|
6
|
+
export type { StorageFolder, StorageObject, StorageObjectStatus, } from "./types/storage-object";
|
|
7
|
+
export type { DbClientFolder, DbClientObject, DbListSort, DbListSortField, DbQuota, DbUsage, } from "./types/client";
|
|
8
|
+
export type { StandardSchemaV1 } from "./standard-schema";
|
|
9
|
+
export type { ListObjectsInput, ListObjectsPage, ObjectFilter, ObjectRef, UpdateObjectInput, } from "./store/object-store";
|
|
14
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,EAAE,EACF,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,EAAE,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnE,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,aAAa,EACb,aAAa,EACb,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,cAAc,EACd,cAAc,EACd,UAAU,EACV,eAAe,EACf,OAAO,EACP,OAAO,GACR,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,SAAS,EACT,iBAAiB,GAClB,MAAM,sBAAsB,CAAC"}
|