@nestjs-dash/media 0.1.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.
@@ -0,0 +1,3 @@
1
+ export { MediaEntity } from './media.entity.js';
2
+ export { MediaService, type MediaOwner, type PendingMediaItem } from './media.service.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { MediaEntity } from './media.entity.js';
2
+ export { MediaService } from './media.service.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAA0C,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,16 @@
1
+ export declare class MediaEntity {
2
+ id: number;
3
+ modelType: string;
4
+ modelId: string;
5
+ collectionName: string;
6
+ disk: string;
7
+ fileName: string;
8
+ mimeType: string | null;
9
+ size: number;
10
+ path: string;
11
+ orderColumn: number;
12
+ customProperties: Record<string, unknown> | null;
13
+ createdAt: Date;
14
+ updatedAt: Date;
15
+ }
16
+ //# sourceMappingURL=media.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.entity.d.ts","sourceRoot":"","sources":["../src/media.entity.ts"],"names":[],"mappings":"AASA,qBAEa,WAAW;IAEtB,EAAE,EAAG,MAAM,CAAC;IAGZ,SAAS,EAAG,MAAM,CAAC;IAGnB,OAAO,EAAG,MAAM,CAAC;IAGjB,cAAc,EAAG,MAAM,CAAC;IAGxB,IAAI,EAAG,MAAM,CAAC;IAGd,QAAQ,EAAG,MAAM,CAAC;IAGlB,QAAQ,EAAG,MAAM,GAAG,IAAI,CAAC;IAGzB,IAAI,EAAG,MAAM,CAAC;IAId,IAAI,EAAG,MAAM,CAAC;IAGd,WAAW,EAAG,MAAM,CAAC;IAGrB,gBAAgB,EAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAGlD,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAClB"}
@@ -0,0 +1,70 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn, } from 'typeorm';
11
+ let MediaEntity = class MediaEntity {
12
+ };
13
+ __decorate([
14
+ PrimaryGeneratedColumn(),
15
+ __metadata("design:type", Number)
16
+ ], MediaEntity.prototype, "id", void 0);
17
+ __decorate([
18
+ Column({ name: 'model_type', type: 'varchar', length: 255 }),
19
+ __metadata("design:type", String)
20
+ ], MediaEntity.prototype, "modelType", void 0);
21
+ __decorate([
22
+ Column({ name: 'model_id', type: 'varchar', length: 64 }),
23
+ __metadata("design:type", String)
24
+ ], MediaEntity.prototype, "modelId", void 0);
25
+ __decorate([
26
+ Column({ name: 'collection_name', type: 'varchar', length: 255, default: 'default' }),
27
+ __metadata("design:type", String)
28
+ ], MediaEntity.prototype, "collectionName", void 0);
29
+ __decorate([
30
+ Column({ type: 'varchar', length: 64 }),
31
+ __metadata("design:type", String)
32
+ ], MediaEntity.prototype, "disk", void 0);
33
+ __decorate([
34
+ Column({ name: 'file_name', type: 'varchar', length: 255 }),
35
+ __metadata("design:type", String)
36
+ ], MediaEntity.prototype, "fileName", void 0);
37
+ __decorate([
38
+ Column({ name: 'mime_type', type: 'varchar', length: 127, nullable: true }),
39
+ __metadata("design:type", Object)
40
+ ], MediaEntity.prototype, "mimeType", void 0);
41
+ __decorate([
42
+ Column({ type: 'int', unsigned: true, default: 0 }),
43
+ __metadata("design:type", Number)
44
+ ], MediaEntity.prototype, "size", void 0);
45
+ __decorate([
46
+ Column({ type: 'varchar', length: 512 }),
47
+ __metadata("design:type", String)
48
+ ], MediaEntity.prototype, "path", void 0);
49
+ __decorate([
50
+ Column({ name: 'order_column', type: 'int', unsigned: true, default: 0 }),
51
+ __metadata("design:type", Number)
52
+ ], MediaEntity.prototype, "orderColumn", void 0);
53
+ __decorate([
54
+ Column({ name: 'custom_properties', type: 'json', nullable: true }),
55
+ __metadata("design:type", Object)
56
+ ], MediaEntity.prototype, "customProperties", void 0);
57
+ __decorate([
58
+ CreateDateColumn({ name: 'created_at' }),
59
+ __metadata("design:type", Date)
60
+ ], MediaEntity.prototype, "createdAt", void 0);
61
+ __decorate([
62
+ UpdateDateColumn({ name: 'updated_at' }),
63
+ __metadata("design:type", Date)
64
+ ], MediaEntity.prototype, "updatedAt", void 0);
65
+ MediaEntity = __decorate([
66
+ Entity('nestjs_dash_media'),
67
+ Index(['modelType', 'modelId', 'collectionName'])
68
+ ], MediaEntity);
69
+ export { MediaEntity };
70
+ //# sourceMappingURL=media.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.entity.js","sourceRoot":"","sources":["../src/media.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL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AE,CAAC,EAAE,CAAC;;gDACrD;AAGrB;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDAClB;AAGlD;IADC,gBAAgB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC7B,IAAI;8CAAC;AAGjB;IADC,gBAAgB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC7B,IAAI;8CAAC;AAvCN,WAAW;IAFvB,MAAM,CAAC,mBAAmB,CAAC;IAC3B,KAAK,CAAC,CAAC,WAAW,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;GACrC,WAAW,CAwCvB"}
@@ -0,0 +1,49 @@
1
+ import { type AdminModuleOptions } from '@nestjs-dash/nestjs';
2
+ import { StorageService } from '@nestjs-dash/storage';
3
+ import { MediaEntity } from './media.entity.js';
4
+ export type MediaOwner = {
5
+ modelType: string;
6
+ modelId: string | number;
7
+ };
8
+ export type PendingMediaItem = {
9
+ id?: string | number;
10
+ path?: string;
11
+ disk?: string;
12
+ fileName?: string;
13
+ mimeType?: string;
14
+ size?: number;
15
+ url?: string;
16
+ };
17
+ export declare class MediaService {
18
+ private readonly storage;
19
+ private readonly options;
20
+ private readonly enabled;
21
+ constructor(storage: StorageService, options?: AdminModuleOptions | null);
22
+ isEnabled(): boolean;
23
+ private getRepository;
24
+ getMedia(owner: MediaOwner, collection: string): Promise<MediaEntity[]>;
25
+ getFirst(owner: MediaOwner, collection: string): Promise<MediaEntity | null>;
26
+ addFromUpload(owner: MediaOwner, collection: string, upload: {
27
+ path: string;
28
+ disk: string;
29
+ fileName: string;
30
+ mimeType?: string;
31
+ size?: number;
32
+ customProperties?: Record<string, unknown>;
33
+ }): Promise<MediaEntity>;
34
+ remove(mediaId: string | number): Promise<void>;
35
+ clearCollection(owner: MediaOwner, collection: string): Promise<void>;
36
+ reorder(owner: MediaOwner, collection: string, ids: Array<string | number>): Promise<void>;
37
+ syncCollection(owner: MediaOwner, collection: string, items: PendingMediaItem[], defaults?: {
38
+ disk?: string;
39
+ }): Promise<MediaEntity[]>;
40
+ toClientItems(owner: MediaOwner, collection: string): Promise<Array<{
41
+ id: number;
42
+ path: string;
43
+ disk: string;
44
+ fileName: string;
45
+ url: string;
46
+ size: number;
47
+ }>>;
48
+ }
49
+ //# sourceMappingURL=media.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.service.d.ts","sourceRoot":"","sources":["../src/media.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBACa,YAAY;IAOG,OAAO,CAAC,QAAQ,CAAC,OAAO;IAGhD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAT1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAMS,OAAO,EAAE,cAAc,EAG/C,OAAO,GAAE,kBAAkB,GAAG,IAAW;IAK5D,SAAS,IAAI,OAAO;IAIpB,OAAO,CAAC,aAAa;IAUf,QAAQ,CAAC,KAAK,EAAE,UAAU,EA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CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAC/F;CAaF"}
@@ -0,0 +1,156 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { NESTJS_DASH_OPTIONS } from '@nestjs-dash/nestjs';
14
+ import { StorageService } from '@nestjs-dash/storage';
15
+ import { Inject, Injectable, Optional } from '@nestjs/common';
16
+ import { MediaEntity } from './media.entity.js';
17
+ let MediaService = class MediaService {
18
+ constructor(storage, options = null) {
19
+ this.storage = storage;
20
+ this.options = options;
21
+ this.enabled = options?.media?.enabled === true;
22
+ }
23
+ isEnabled() {
24
+ return this.enabled;
25
+ }
26
+ getRepository() {
27
+ const dataSource = this.options?.dataSource;
28
+ if (!dataSource || typeof dataSource.getRepository !== 'function') {
29
+ throw new Error('MediaService requires AdminModule.forRoot({ media: { enabled: true }, dataSource })');
30
+ }
31
+ return dataSource.getRepository(MediaEntity);
32
+ }
33
+ async getMedia(owner, collection) {
34
+ if (!this.enabled)
35
+ return [];
36
+ return this.getRepository().find({
37
+ where: {
38
+ modelType: owner.modelType,
39
+ modelId: String(owner.modelId),
40
+ collectionName: collection,
41
+ },
42
+ order: { orderColumn: 'ASC', id: 'ASC' },
43
+ });
44
+ }
45
+ async getFirst(owner, collection) {
46
+ const items = await this.getMedia(owner, collection);
47
+ return items[0] ?? null;
48
+ }
49
+ async addFromUpload(owner, collection, upload) {
50
+ const repo = this.getRepository();
51
+ const existing = await this.getMedia(owner, collection);
52
+ const orderColumn = existing.length;
53
+ const row = repo.create({
54
+ modelType: owner.modelType,
55
+ modelId: String(owner.modelId),
56
+ collectionName: collection,
57
+ disk: upload.disk,
58
+ fileName: upload.fileName,
59
+ mimeType: upload.mimeType ?? null,
60
+ size: upload.size ?? 0,
61
+ path: upload.path,
62
+ orderColumn,
63
+ customProperties: upload.customProperties ?? null,
64
+ });
65
+ return repo.save(row);
66
+ }
67
+ async remove(mediaId) {
68
+ const repo = this.getRepository();
69
+ const row = await repo.findOne({ where: { id: Number(mediaId) } });
70
+ if (!row)
71
+ return;
72
+ await this.storage.delete(row.disk, row.path);
73
+ await repo.remove(row);
74
+ }
75
+ async clearCollection(owner, collection) {
76
+ const items = await this.getMedia(owner, collection);
77
+ for (const item of items) {
78
+ await this.storage.delete(item.disk, item.path);
79
+ await this.getRepository().remove(item);
80
+ }
81
+ }
82
+ async reorder(owner, collection, ids) {
83
+ const repo = this.getRepository();
84
+ const items = await this.getMedia(owner, collection);
85
+ const byId = new Map(items.map((item) => [String(item.id), item]));
86
+ let order = 0;
87
+ for (const id of ids) {
88
+ const item = byId.get(String(id));
89
+ if (!item)
90
+ continue;
91
+ item.orderColumn = order++;
92
+ await repo.save(item);
93
+ }
94
+ }
95
+ async syncCollection(owner, collection, items, defaults) {
96
+ if (!this.enabled)
97
+ return [];
98
+ const repo = this.getRepository();
99
+ const existing = await this.getMedia(owner, collection);
100
+ const keepIds = new Set(items.filter((item) => item.id != null && item.id !== '').map((item) => String(item.id)));
101
+ for (const row of existing) {
102
+ if (!keepIds.has(String(row.id))) {
103
+ await this.storage.delete(row.disk, row.path);
104
+ await repo.remove(row);
105
+ }
106
+ }
107
+ const result = [];
108
+ let order = 0;
109
+ for (const item of items) {
110
+ if (item.id != null && item.id !== '') {
111
+ const row = existing.find((e) => String(e.id) === String(item.id));
112
+ if (row) {
113
+ row.orderColumn = order++;
114
+ result.push(await repo.save(row));
115
+ }
116
+ continue;
117
+ }
118
+ if (!item.path)
119
+ continue;
120
+ const created = repo.create({
121
+ modelType: owner.modelType,
122
+ modelId: String(owner.modelId),
123
+ collectionName: collection,
124
+ disk: item.disk ?? defaults?.disk ?? this.storage.getDefaultDiskName(),
125
+ fileName: item.fileName ?? item.path.split('/').pop() ?? 'file',
126
+ mimeType: item.mimeType ?? null,
127
+ size: item.size ?? 0,
128
+ path: item.path,
129
+ orderColumn: order++,
130
+ customProperties: null,
131
+ });
132
+ result.push(await repo.save(created));
133
+ }
134
+ return result;
135
+ }
136
+ async toClientItems(owner, collection) {
137
+ const items = await this.getMedia(owner, collection);
138
+ return Promise.all(items.map(async (item) => ({
139
+ id: Number(item.id),
140
+ path: item.path,
141
+ disk: item.disk,
142
+ fileName: item.fileName,
143
+ size: item.size,
144
+ url: await this.storage.urlFor(item.disk, item.path),
145
+ })));
146
+ }
147
+ };
148
+ MediaService = __decorate([
149
+ Injectable(),
150
+ __param(0, Inject(StorageService)),
151
+ __param(1, Optional()),
152
+ __param(1, Inject(NESTJS_DASH_OPTIONS)),
153
+ __metadata("design:paramtypes", [StorageService, Object])
154
+ ], MediaService);
155
+ export { MediaService };
156
+ //# sourceMappingURL=media.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.service.js","sourceRoot":"","sources":["../src/media.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAA2B,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAkBzC,IAA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AAC,IAAI;YACf,GAAG,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;SACrD,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC;CACF,CAAA;AAhLY,YAAY;IADxB,UAAU,EAAE;IAQR,WAAA,MAAM,CAAC,cAAc,CAAC,CAAA;IACtB,WAAA,QAAQ,EAAE,CAAA;IACV,WAAA,MAAM,CAAC,mBAAmB,CAAC,CAAA;qCAFsB,cAAc;GAPvD,YAAY,CAgLxB"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@nestjs-dash/media",
3
+ "version": "0.1.1",
4
+ "description": "Polymorphic media library plugin for NestJS Dash (Spatie-style media collections on top of @nestjs-dash/storage)",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "dependencies": {
20
+ "@nestjs-dash/nestjs": "0.1.1",
21
+ "@nestjs-dash/storage": "0.1.1"
22
+ },
23
+ "devDependencies": {
24
+ "@nestjs-dash/typescript-config": "0.1.0",
25
+ "@nestjs/common": "^12.0.1",
26
+ "reflect-metadata": "^0.2.2",
27
+ "typeorm": "^1.1.1",
28
+ "typescript": "6.0.3",
29
+ "vitest": "^5.0.0"
30
+ },
31
+ "peerDependencies": {
32
+ "@nestjs/common": "^12.0.0",
33
+ "reflect-metadata": "^0.2.2",
34
+ "typeorm": ">=0.2.41 <0.3.0-0 || ^0.3.20 || ^1.0.0",
35
+ "vitest": "^5.0.0"
36
+ },
37
+ "peerDependenciesMeta": {
38
+ "reflect-metadata": {
39
+ "optional": true
40
+ },
41
+ "vitest": {
42
+ "optional": true
43
+ }
44
+ },
45
+ "scripts": {
46
+ "build": "tsc -p tsconfig.json",
47
+ "check-types": "tsc -p tsconfig.json --noEmit",
48
+ "format": "oxfmt",
49
+ "lint": "oxlint src",
50
+ "test": "vitest run",
51
+ "test:coverage": "vitest run --coverage",
52
+ "dev": "tsc -p tsconfig.json --watch"
53
+ }
54
+ }