@dudousxd/nestjs-media-database-drizzle 0.6.0 → 0.7.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.
@@ -0,0 +1,24 @@
1
+ import { MediaStore, MediaRecord, MediaCountFilter, MediaAggregateQuery, MediaAggregateResult, MediaListFilter, MediaListPage, MediaListResult } from '@dudousxd/nestjs-media-core';
2
+ import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
3
+
4
+ type DB = BetterSQLite3Database<Record<string, never>>;
5
+ /**
6
+ * Migration-first (§3.10): Drizzle has no auto-ensure. Run migrations with
7
+ * drizzle-kit in production; this helper creates the table for tests/dev.
8
+ */
9
+ declare function createMediaTable(db: DB): void;
10
+ /** MediaStore backed by Drizzle (better-sqlite3). POJO receiving the drizzle db. */
11
+ declare class DrizzleMediaStore implements MediaStore {
12
+ private readonly db;
13
+ constructor(db: DB);
14
+ save(record: MediaRecord): Promise<MediaRecord>;
15
+ find(id: string): Promise<MediaRecord | null>;
16
+ listByOwner(ownerType: string, ownerId: string, collection?: string): Promise<MediaRecord[]>;
17
+ delete(id: string): Promise<void>;
18
+ nextOrder(ownerType: string, ownerId: string, collection: string): Promise<number>;
19
+ count(filter?: MediaCountFilter): Promise<number>;
20
+ aggregate(query: MediaAggregateQuery): Promise<MediaAggregateResult>;
21
+ list(filter?: MediaListFilter, page?: MediaListPage): Promise<MediaListResult>;
22
+ }
23
+
24
+ export { DrizzleMediaStore as D, createMediaTable as c };
@@ -0,0 +1,24 @@
1
+ import { MediaStore, MediaRecord, MediaCountFilter, MediaAggregateQuery, MediaAggregateResult, MediaListFilter, MediaListPage, MediaListResult } from '@dudousxd/nestjs-media-core';
2
+ import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
3
+
4
+ type DB = BetterSQLite3Database<Record<string, never>>;
5
+ /**
6
+ * Migration-first (§3.10): Drizzle has no auto-ensure. Run migrations with
7
+ * drizzle-kit in production; this helper creates the table for tests/dev.
8
+ */
9
+ declare function createMediaTable(db: DB): void;
10
+ /** MediaStore backed by Drizzle (better-sqlite3). POJO receiving the drizzle db. */
11
+ declare class DrizzleMediaStore implements MediaStore {
12
+ private readonly db;
13
+ constructor(db: DB);
14
+ save(record: MediaRecord): Promise<MediaRecord>;
15
+ find(id: string): Promise<MediaRecord | null>;
16
+ listByOwner(ownerType: string, ownerId: string, collection?: string): Promise<MediaRecord[]>;
17
+ delete(id: string): Promise<void>;
18
+ nextOrder(ownerType: string, ownerId: string, collection: string): Promise<number>;
19
+ count(filter?: MediaCountFilter): Promise<number>;
20
+ aggregate(query: MediaAggregateQuery): Promise<MediaAggregateResult>;
21
+ list(filter?: MediaListFilter, page?: MediaListPage): Promise<MediaListResult>;
22
+ }
23
+
24
+ export { DrizzleMediaStore as D, createMediaTable as c };
@@ -0,0 +1,47 @@
1
+ import { MediaStore, MediaRecord, MediaCountFilter, MediaAggregateQuery, MediaAggregateResult, MediaListFilter, MediaListPage, MediaListResult, UploadSessionStore, UploadSession, MultipartPart, UploadSessionListFilter } from '@dudousxd/nestjs-media-core';
2
+ import { PgDatabase } from 'drizzle-orm/pg-core';
3
+
4
+ /**
5
+ * Any drizzle Postgres database — node-postgres (`NodePgDatabase`), postgres-js, neon, pglite, …
6
+ * and transactions of those. Kept deliberately loose so hosts on any drizzle Postgres driver /
7
+ * schema generic can pass their `db` handle straight in.
8
+ */
9
+ type DrizzlePgDatabase = PgDatabase<any, any, any>;
10
+
11
+ /**
12
+ * `MediaStore` backed by Drizzle on **PostgreSQL**. POJO receiving any drizzle Postgres db
13
+ * (see {@link DrizzlePgDatabase}). Migration-first: create the table with drizzle-kit from
14
+ * `mediaPgTable`, or `createMediaPgTables(db)` in tests/dev.
15
+ */
16
+ declare class DrizzlePgMediaStore implements MediaStore {
17
+ private readonly db;
18
+ constructor(db: DrizzlePgDatabase);
19
+ save(record: MediaRecord): Promise<MediaRecord>;
20
+ find(id: string): Promise<MediaRecord | null>;
21
+ listByOwner(ownerType: string, ownerId: string, collection?: string): Promise<MediaRecord[]>;
22
+ delete(id: string): Promise<void>;
23
+ nextOrder(ownerType: string, ownerId: string, collection: string): Promise<number>;
24
+ count(filter?: MediaCountFilter): Promise<number>;
25
+ aggregate(query: MediaAggregateQuery): Promise<MediaAggregateResult>;
26
+ list(filter?: MediaListFilter, page?: MediaListPage): Promise<MediaListResult>;
27
+ }
28
+
29
+ /**
30
+ * `UploadSessionStore` (resumable uploads) backed by Drizzle on **PostgreSQL**. Implements every
31
+ * optional method: `addPart` is a single atomic upsert on `(session_id, part_number)` so parallel
32
+ * part uploads never lose an ETag; `delete` cascades to the parts via the FK.
33
+ * Tables: `mediaUploadSessionsPgTable` + `mediaUploadPartsPgTable` (or `createMediaPgTables(db)`).
34
+ */
35
+ declare class DrizzlePgUploadSessionStore implements UploadSessionStore {
36
+ private readonly db;
37
+ constructor(db: DrizzlePgDatabase);
38
+ create(session: UploadSession): Promise<UploadSession>;
39
+ get(id: string): Promise<UploadSession | null>;
40
+ update(session: UploadSession): Promise<UploadSession>;
41
+ delete(id: string): Promise<void>;
42
+ addPart(id: string, part: MultipartPart): Promise<void>;
43
+ listParts(id: string): Promise<MultipartPart[]>;
44
+ list(filter?: UploadSessionListFilter): Promise<UploadSession[]>;
45
+ }
46
+
47
+ export { DrizzlePgMediaStore as D, DrizzlePgUploadSessionStore as a, type DrizzlePgDatabase as b };
@@ -0,0 +1,47 @@
1
+ import { MediaStore, MediaRecord, MediaCountFilter, MediaAggregateQuery, MediaAggregateResult, MediaListFilter, MediaListPage, MediaListResult, UploadSessionStore, UploadSession, MultipartPart, UploadSessionListFilter } from '@dudousxd/nestjs-media-core';
2
+ import { PgDatabase } from 'drizzle-orm/pg-core';
3
+
4
+ /**
5
+ * Any drizzle Postgres database — node-postgres (`NodePgDatabase`), postgres-js, neon, pglite, …
6
+ * and transactions of those. Kept deliberately loose so hosts on any drizzle Postgres driver /
7
+ * schema generic can pass their `db` handle straight in.
8
+ */
9
+ type DrizzlePgDatabase = PgDatabase<any, any, any>;
10
+
11
+ /**
12
+ * `MediaStore` backed by Drizzle on **PostgreSQL**. POJO receiving any drizzle Postgres db
13
+ * (see {@link DrizzlePgDatabase}). Migration-first: create the table with drizzle-kit from
14
+ * `mediaPgTable`, or `createMediaPgTables(db)` in tests/dev.
15
+ */
16
+ declare class DrizzlePgMediaStore implements MediaStore {
17
+ private readonly db;
18
+ constructor(db: DrizzlePgDatabase);
19
+ save(record: MediaRecord): Promise<MediaRecord>;
20
+ find(id: string): Promise<MediaRecord | null>;
21
+ listByOwner(ownerType: string, ownerId: string, collection?: string): Promise<MediaRecord[]>;
22
+ delete(id: string): Promise<void>;
23
+ nextOrder(ownerType: string, ownerId: string, collection: string): Promise<number>;
24
+ count(filter?: MediaCountFilter): Promise<number>;
25
+ aggregate(query: MediaAggregateQuery): Promise<MediaAggregateResult>;
26
+ list(filter?: MediaListFilter, page?: MediaListPage): Promise<MediaListResult>;
27
+ }
28
+
29
+ /**
30
+ * `UploadSessionStore` (resumable uploads) backed by Drizzle on **PostgreSQL**. Implements every
31
+ * optional method: `addPart` is a single atomic upsert on `(session_id, part_number)` so parallel
32
+ * part uploads never lose an ETag; `delete` cascades to the parts via the FK.
33
+ * Tables: `mediaUploadSessionsPgTable` + `mediaUploadPartsPgTable` (or `createMediaPgTables(db)`).
34
+ */
35
+ declare class DrizzlePgUploadSessionStore implements UploadSessionStore {
36
+ private readonly db;
37
+ constructor(db: DrizzlePgDatabase);
38
+ create(session: UploadSession): Promise<UploadSession>;
39
+ get(id: string): Promise<UploadSession | null>;
40
+ update(session: UploadSession): Promise<UploadSession>;
41
+ delete(id: string): Promise<void>;
42
+ addPart(id: string, part: MultipartPart): Promise<void>;
43
+ listParts(id: string): Promise<MultipartPart[]>;
44
+ list(filter?: UploadSessionListFilter): Promise<UploadSession[]>;
45
+ }
46
+
47
+ export { DrizzlePgMediaStore as D, DrizzlePgUploadSessionStore as a, type DrizzlePgDatabase as b };
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
2
- import { MediaStore, MediaRecord, MediaCountFilter, MediaAggregateQuery, MediaAggregateResult, MediaListFilter, MediaListPage, MediaListResult, Attachment } from '@dudousxd/nestjs-media-core';
3
- import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
2
+ export { D as DrizzleMediaStore, c as createMediaTable } from './drizzle-media-store-B_rsYG0g.cjs';
3
+ import { Attachment } from '@dudousxd/nestjs-media-core';
4
+ import 'drizzle-orm/better-sqlite3';
4
5
 
5
6
  /**
6
7
  * Drizzle (sqlite) media table. `order` maps to the `position` column. JSON columns
@@ -288,26 +289,6 @@ declare const mediaTable: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
288
289
  dialect: "sqlite";
289
290
  }>;
290
291
 
291
- type DB = BetterSQLite3Database<Record<string, never>>;
292
- /**
293
- * Migration-first (§3.10): Drizzle has no auto-ensure. Run migrations with
294
- * drizzle-kit in production; this helper creates the table for tests/dev.
295
- */
296
- declare function createMediaTable(db: DB): void;
297
- /** MediaStore backed by Drizzle (better-sqlite3). POJO receiving the drizzle db. */
298
- declare class DrizzleMediaStore implements MediaStore {
299
- private readonly db;
300
- constructor(db: DB);
301
- save(record: MediaRecord): Promise<MediaRecord>;
302
- find(id: string): Promise<MediaRecord | null>;
303
- listByOwner(ownerType: string, ownerId: string, collection?: string): Promise<MediaRecord[]>;
304
- delete(id: string): Promise<void>;
305
- nextOrder(ownerType: string, ownerId: string, collection: string): Promise<number>;
306
- count(filter?: MediaCountFilter): Promise<number>;
307
- aggregate(query: MediaAggregateQuery): Promise<MediaAggregateResult>;
308
- list(filter?: MediaListFilter, page?: MediaListPage): Promise<MediaListResult>;
309
- }
310
-
311
292
  /**
312
293
  * Drizzle (sqlite) custom column for an Attachment value:
313
294
  * `avatar: attachment('avatar')` → stored as JSON text, rehydrated to an `Attachment`.
@@ -339,4 +320,4 @@ declare const attachment: {
339
320
  }>;
340
321
  };
341
322
 
342
- export { DrizzleMediaStore, attachment, createMediaTable, mediaTable };
323
+ export { attachment, mediaTable };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
2
- import { MediaStore, MediaRecord, MediaCountFilter, MediaAggregateQuery, MediaAggregateResult, MediaListFilter, MediaListPage, MediaListResult, Attachment } from '@dudousxd/nestjs-media-core';
3
- import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
2
+ export { D as DrizzleMediaStore, c as createMediaTable } from './drizzle-media-store-B_rsYG0g.js';
3
+ import { Attachment } from '@dudousxd/nestjs-media-core';
4
+ import 'drizzle-orm/better-sqlite3';
4
5
 
5
6
  /**
6
7
  * Drizzle (sqlite) media table. `order` maps to the `position` column. JSON columns
@@ -288,26 +289,6 @@ declare const mediaTable: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
288
289
  dialect: "sqlite";
289
290
  }>;
290
291
 
291
- type DB = BetterSQLite3Database<Record<string, never>>;
292
- /**
293
- * Migration-first (§3.10): Drizzle has no auto-ensure. Run migrations with
294
- * drizzle-kit in production; this helper creates the table for tests/dev.
295
- */
296
- declare function createMediaTable(db: DB): void;
297
- /** MediaStore backed by Drizzle (better-sqlite3). POJO receiving the drizzle db. */
298
- declare class DrizzleMediaStore implements MediaStore {
299
- private readonly db;
300
- constructor(db: DB);
301
- save(record: MediaRecord): Promise<MediaRecord>;
302
- find(id: string): Promise<MediaRecord | null>;
303
- listByOwner(ownerType: string, ownerId: string, collection?: string): Promise<MediaRecord[]>;
304
- delete(id: string): Promise<void>;
305
- nextOrder(ownerType: string, ownerId: string, collection: string): Promise<number>;
306
- count(filter?: MediaCountFilter): Promise<number>;
307
- aggregate(query: MediaAggregateQuery): Promise<MediaAggregateResult>;
308
- list(filter?: MediaListFilter, page?: MediaListPage): Promise<MediaListResult>;
309
- }
310
-
311
292
  /**
312
293
  * Drizzle (sqlite) custom column for an Attachment value:
313
294
  * `avatar: attachment('avatar')` → stored as JSON text, rehydrated to an `Attachment`.
@@ -339,4 +320,4 @@ declare const attachment: {
339
320
  }>;
340
321
  };
341
322
 
342
- export { DrizzleMediaStore, attachment, createMediaTable, mediaTable };
323
+ export { attachment, mediaTable };