@dudousxd/nestjs-media-dashboard 0.1.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/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/media-console-client.d.ts +40 -0
- package/dist/client/media-console-client.d.ts.map +1 -0
- package/dist/client/media-console-client.js +54 -0
- package/dist/client/media-console-client.js.map +1 -0
- package/dist/client/types.d.ts +100 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +5 -0
- package/dist/client/types.js.map +1 -0
- package/dist/server/index.cjs +828 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +195 -0
- package/dist/server/index.d.ts +195 -0
- package/dist/server/index.js +794 -0
- package/dist/server/index.js.map +1 -0
- package/dist/spa/assets/index-v1mdOPqe.js +1 -0
- package/dist/spa/assets/preview-Bdq6BX0n.js +1 -0
- package/dist/spa/assets/styles-B93akCcR.js +40 -0
- package/dist/spa/assets/styles-DStlWvmW.css +1 -0
- package/dist/spa/index.html +14 -0
- package/dist/spa/preview.html +14 -0
- package/package.json +63 -0
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/server/media-dashboard.module.ts
|
|
5
|
+
import { Module as Module2 } from "@nestjs/common";
|
|
6
|
+
import { RouterModule } from "@nestjs/core";
|
|
7
|
+
|
|
8
|
+
// src/server/media-console-api.module.ts
|
|
9
|
+
import { Module } from "@nestjs/common";
|
|
10
|
+
|
|
11
|
+
// src/server/media-console-actions.controller.ts
|
|
12
|
+
import { Body, Controller, Delete, HttpCode, Inject as Inject2, Param, Post, Query } from "@nestjs/common";
|
|
13
|
+
|
|
14
|
+
// src/server/media-console.service.ts
|
|
15
|
+
import { Inject, Injectable, NotFoundException, Optional } from "@nestjs/common";
|
|
16
|
+
|
|
17
|
+
// src/server/tokens.ts
|
|
18
|
+
var MEDIA_STORE = Symbol.for("nestjs-media:store");
|
|
19
|
+
var MEDIA_UPLOAD_SESSIONS = Symbol.for("nestjs-media:upload-sessions");
|
|
20
|
+
var MEDIA_STORAGE_SHARED = Symbol.for("nestjs-media:storage");
|
|
21
|
+
var MEDIA_DASHBOARD_BASE_PATH = Symbol("MEDIA_DASHBOARD_BASE_PATH");
|
|
22
|
+
var MEDIA_DASHBOARD_API_PATH = Symbol("MEDIA_DASHBOARD_API_PATH");
|
|
23
|
+
var MEDIA_DASHBOARD_ACTIONS = Symbol("MEDIA_DASHBOARD_ACTIONS");
|
|
24
|
+
|
|
25
|
+
// src/server/media-console.service.ts
|
|
26
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
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;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
}
|
|
32
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
33
|
+
function _ts_metadata(k, v) {
|
|
34
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35
|
+
}
|
|
36
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
37
|
+
function _ts_param(paramIndex, decorator) {
|
|
38
|
+
return function(target, key) {
|
|
39
|
+
decorator(target, key, paramIndex);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
__name(_ts_param, "_ts_param");
|
|
43
|
+
var URL_TTL_SECONDS = 300;
|
|
44
|
+
var DEFAULT_PAGE_LIMIT = 50;
|
|
45
|
+
function lastSegment(prefix) {
|
|
46
|
+
const trimmed = prefix.replace(/\/+$/, "");
|
|
47
|
+
const slash = trimmed.lastIndexOf("/");
|
|
48
|
+
return slash === -1 ? trimmed : trimmed.slice(slash + 1);
|
|
49
|
+
}
|
|
50
|
+
__name(lastSegment, "lastSegment");
|
|
51
|
+
function mapUpload(session) {
|
|
52
|
+
const percent = session.size !== void 0 && session.size > 0 ? Math.min(100, Math.round(session.offset / session.size * 100)) : null;
|
|
53
|
+
return {
|
|
54
|
+
id: session.id,
|
|
55
|
+
disk: session.disk,
|
|
56
|
+
key: session.key,
|
|
57
|
+
offset: session.offset,
|
|
58
|
+
size: session.size ?? null,
|
|
59
|
+
percent,
|
|
60
|
+
parts: session.parts,
|
|
61
|
+
multipart: session.multipartUploadId !== void 0,
|
|
62
|
+
...session.createdAt ? {
|
|
63
|
+
createdAt: session.createdAt.toISOString()
|
|
64
|
+
} : {}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
__name(mapUpload, "mapUpload");
|
|
68
|
+
function mapRecord(record) {
|
|
69
|
+
return {
|
|
70
|
+
id: record.id,
|
|
71
|
+
ownerType: record.ownerType,
|
|
72
|
+
ownerId: record.ownerId,
|
|
73
|
+
collection: record.collection,
|
|
74
|
+
name: record.name,
|
|
75
|
+
fileName: record.fileName,
|
|
76
|
+
mimeType: record.mimeType,
|
|
77
|
+
size: record.size,
|
|
78
|
+
disk: record.disk,
|
|
79
|
+
path: record.path,
|
|
80
|
+
createdAt: record.createdAt.toISOString()
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
__name(mapRecord, "mapRecord");
|
|
84
|
+
var MediaConsoleService = class {
|
|
85
|
+
static {
|
|
86
|
+
__name(this, "MediaConsoleService");
|
|
87
|
+
}
|
|
88
|
+
storage;
|
|
89
|
+
store;
|
|
90
|
+
uploads;
|
|
91
|
+
actionsEnabled;
|
|
92
|
+
constructor(storage, store, uploads, actionsEnabled) {
|
|
93
|
+
this.storage = storage;
|
|
94
|
+
this.store = store;
|
|
95
|
+
this.uploads = uploads;
|
|
96
|
+
this.actionsEnabled = actionsEnabled;
|
|
97
|
+
}
|
|
98
|
+
diskOrThrow(disk) {
|
|
99
|
+
if (!this.storage || !this.storage.diskNames().includes(disk)) {
|
|
100
|
+
throw new NotFoundException(`Unknown disk: ${disk}`);
|
|
101
|
+
}
|
|
102
|
+
return this.storage.disk(disk);
|
|
103
|
+
}
|
|
104
|
+
listDisks() {
|
|
105
|
+
const storage = this.storage;
|
|
106
|
+
if (!storage) return {
|
|
107
|
+
disks: []
|
|
108
|
+
};
|
|
109
|
+
const defaultDisk = storage.defaultDisk;
|
|
110
|
+
return {
|
|
111
|
+
disks: storage.diskNames().map((name) => ({
|
|
112
|
+
name,
|
|
113
|
+
default: name === defaultDisk,
|
|
114
|
+
capabilities: storage.disk(name).capabilities
|
|
115
|
+
}))
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async listObjects(disk, options) {
|
|
119
|
+
const driver = this.diskOrThrow(disk);
|
|
120
|
+
const result = await driver.list(options.prefix ?? "", {
|
|
121
|
+
delimiter: "/",
|
|
122
|
+
...options.cursor ? {
|
|
123
|
+
cursor: options.cursor
|
|
124
|
+
} : {},
|
|
125
|
+
limit: options.limit ?? DEFAULT_PAGE_LIMIT
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
folders: result.folders.map((prefix) => ({
|
|
129
|
+
name: lastSegment(prefix),
|
|
130
|
+
prefix
|
|
131
|
+
})),
|
|
132
|
+
files: result.files.map((entry) => ({
|
|
133
|
+
key: entry.key,
|
|
134
|
+
name: entry.name,
|
|
135
|
+
sizeBytes: entry.sizeBytes,
|
|
136
|
+
lastModified: entry.lastModified ? entry.lastModified.toISOString() : null
|
|
137
|
+
})),
|
|
138
|
+
...result.cursor ? {
|
|
139
|
+
cursor: result.cursor
|
|
140
|
+
} : {}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
async objectDetail(disk, key) {
|
|
144
|
+
const driver = this.diskOrThrow(disk);
|
|
145
|
+
const stat = driver.stat ? await driver.stat(key) : {
|
|
146
|
+
size: await driver.size(key)
|
|
147
|
+
};
|
|
148
|
+
const url = driver.capabilities.presign ? await driver.temporaryUrl(key, URL_TTL_SECONDS) : await driver.url(key);
|
|
149
|
+
return {
|
|
150
|
+
key,
|
|
151
|
+
size: stat.size,
|
|
152
|
+
...stat.contentType ? {
|
|
153
|
+
contentType: stat.contentType
|
|
154
|
+
} : {},
|
|
155
|
+
...stat.lastModified ? {
|
|
156
|
+
lastModified: stat.lastModified.toISOString()
|
|
157
|
+
} : {},
|
|
158
|
+
url
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
async deleteObject(disk, key) {
|
|
162
|
+
await this.diskOrThrow(disk).delete(key);
|
|
163
|
+
}
|
|
164
|
+
async copyObject(disk, from, to) {
|
|
165
|
+
await this.diskOrThrow(disk).copy(from, to);
|
|
166
|
+
}
|
|
167
|
+
async moveObject(disk, from, to) {
|
|
168
|
+
await this.diskOrThrow(disk).move(from, to);
|
|
169
|
+
}
|
|
170
|
+
async listUploads(filter) {
|
|
171
|
+
if (!this.uploads || typeof this.uploads.list !== "function") return {
|
|
172
|
+
uploads: []
|
|
173
|
+
};
|
|
174
|
+
const sessions = await this.uploads.list({
|
|
175
|
+
...filter.disk ? {
|
|
176
|
+
disk: filter.disk
|
|
177
|
+
} : {},
|
|
178
|
+
...filter.prefix ? {
|
|
179
|
+
keyPrefix: filter.prefix
|
|
180
|
+
} : {}
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
uploads: sessions.map(mapUpload)
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
async uploadDetail(id) {
|
|
187
|
+
if (!this.uploads) throw new NotFoundException("No upload store configured");
|
|
188
|
+
const session = await this.uploads.get(id);
|
|
189
|
+
if (!session) throw new NotFoundException(`Unknown upload: ${id}`);
|
|
190
|
+
const parts = this.uploads.listParts ? await this.uploads.listParts(id) : [];
|
|
191
|
+
return {
|
|
192
|
+
upload: mapUpload(session),
|
|
193
|
+
parts
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Cancels a resumable session by removing its record from the upload store, so it stops
|
|
198
|
+
* appearing as in-progress. NOTE: this does NOT tear down an underlying native multipart upload
|
|
199
|
+
* (e.g. an S3 multipart) or its temporary parts — the decoupled console resolves only the
|
|
200
|
+
* `UploadSessionStore`, not the `ResumableUploadManager` that owns `abort()`. An incomplete
|
|
201
|
+
* multipart is reaped by the bucket's lifecycle policy. Surfaced as "Cancel session" in the UI.
|
|
202
|
+
*/
|
|
203
|
+
async abortUpload(id) {
|
|
204
|
+
if (!this.uploads) throw new NotFoundException("No upload store configured");
|
|
205
|
+
await this.uploads.delete(id);
|
|
206
|
+
}
|
|
207
|
+
async listCollections() {
|
|
208
|
+
if (!this.store || typeof this.store.aggregate !== "function") return {
|
|
209
|
+
collections: []
|
|
210
|
+
};
|
|
211
|
+
const buckets = await this.store.aggregate({
|
|
212
|
+
groupBy: "collection",
|
|
213
|
+
sum: "size"
|
|
214
|
+
});
|
|
215
|
+
return {
|
|
216
|
+
collections: buckets
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
async listLibrary(filter) {
|
|
220
|
+
if (!this.store || typeof this.store.list !== "function") return {
|
|
221
|
+
records: []
|
|
222
|
+
};
|
|
223
|
+
const page = await this.store.list({
|
|
224
|
+
...filter.collection ? {
|
|
225
|
+
collection: filter.collection
|
|
226
|
+
} : {},
|
|
227
|
+
...filter.disk ? {
|
|
228
|
+
disk: filter.disk
|
|
229
|
+
} : {}
|
|
230
|
+
}, {
|
|
231
|
+
limit: filter.limit ?? DEFAULT_PAGE_LIMIT,
|
|
232
|
+
...filter.cursor ? {
|
|
233
|
+
cursor: filter.cursor
|
|
234
|
+
} : {}
|
|
235
|
+
});
|
|
236
|
+
return {
|
|
237
|
+
records: page.records.map(mapRecord),
|
|
238
|
+
...page.cursor ? {
|
|
239
|
+
cursor: page.cursor
|
|
240
|
+
} : {}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
async libraryDetail(id) {
|
|
244
|
+
if (!this.store) throw new NotFoundException("No media store configured");
|
|
245
|
+
const record = await this.store.find(id);
|
|
246
|
+
if (!record) throw new NotFoundException(`Unknown media record: ${id}`);
|
|
247
|
+
const variants = await Promise.all(Object.entries(record.conversions).map(async ([name, conversion]) => {
|
|
248
|
+
const driver = this.storage?.diskNames().includes(conversion.disk) ? this.storage.disk(conversion.disk) : null;
|
|
249
|
+
const url = driver?.capabilities.presign ? await driver.temporaryUrl(conversion.path, URL_TTL_SECONDS) : await driver?.url(conversion.path) ?? "";
|
|
250
|
+
return {
|
|
251
|
+
name,
|
|
252
|
+
url
|
|
253
|
+
};
|
|
254
|
+
}));
|
|
255
|
+
return {
|
|
256
|
+
record: mapRecord(record),
|
|
257
|
+
variants
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
async deleteLibraryRecord(id) {
|
|
261
|
+
if (!this.store) throw new NotFoundException("No media store configured");
|
|
262
|
+
await this.store.delete(id);
|
|
263
|
+
}
|
|
264
|
+
topology() {
|
|
265
|
+
return {
|
|
266
|
+
hasStore: this.store !== null && typeof this.store.list === "function",
|
|
267
|
+
hasUploads: this.uploads !== null && typeof this.uploads.list === "function",
|
|
268
|
+
disks: this.storage ? this.storage.diskNames().length : 0,
|
|
269
|
+
actions: this.actionsEnabled === true
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
MediaConsoleService = _ts_decorate([
|
|
274
|
+
Injectable(),
|
|
275
|
+
_ts_param(0, Optional()),
|
|
276
|
+
_ts_param(0, Inject(MEDIA_STORAGE_SHARED)),
|
|
277
|
+
_ts_param(1, Optional()),
|
|
278
|
+
_ts_param(1, Inject(MEDIA_STORE)),
|
|
279
|
+
_ts_param(2, Optional()),
|
|
280
|
+
_ts_param(2, Inject(MEDIA_UPLOAD_SESSIONS)),
|
|
281
|
+
_ts_param(3, Optional()),
|
|
282
|
+
_ts_param(3, Inject(MEDIA_DASHBOARD_ACTIONS)),
|
|
283
|
+
_ts_metadata("design:type", Function),
|
|
284
|
+
_ts_metadata("design:paramtypes", [
|
|
285
|
+
Object,
|
|
286
|
+
Object,
|
|
287
|
+
Object,
|
|
288
|
+
Object
|
|
289
|
+
])
|
|
290
|
+
], MediaConsoleService);
|
|
291
|
+
|
|
292
|
+
// src/server/media-console-actions.controller.ts
|
|
293
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
294
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
295
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
296
|
+
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;
|
|
297
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
298
|
+
}
|
|
299
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
300
|
+
function _ts_metadata2(k, v) {
|
|
301
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
302
|
+
}
|
|
303
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
304
|
+
function _ts_param2(paramIndex, decorator) {
|
|
305
|
+
return function(target, key) {
|
|
306
|
+
decorator(target, key, paramIndex);
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
__name(_ts_param2, "_ts_param");
|
|
310
|
+
var MediaConsoleActionsController = class {
|
|
311
|
+
static {
|
|
312
|
+
__name(this, "MediaConsoleActionsController");
|
|
313
|
+
}
|
|
314
|
+
service;
|
|
315
|
+
constructor(service) {
|
|
316
|
+
this.service = service;
|
|
317
|
+
}
|
|
318
|
+
deleteObject(disk, key) {
|
|
319
|
+
return this.service.deleteObject(disk, key);
|
|
320
|
+
}
|
|
321
|
+
copyObject(disk, body) {
|
|
322
|
+
return this.service.copyObject(disk, body.from, body.to);
|
|
323
|
+
}
|
|
324
|
+
moveObject(disk, body) {
|
|
325
|
+
return this.service.moveObject(disk, body.from, body.to);
|
|
326
|
+
}
|
|
327
|
+
abortUpload(id) {
|
|
328
|
+
return this.service.abortUpload(id);
|
|
329
|
+
}
|
|
330
|
+
deleteLibraryRecord(id) {
|
|
331
|
+
return this.service.deleteLibraryRecord(id);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
_ts_decorate2([
|
|
335
|
+
Delete("disks/:disk/object"),
|
|
336
|
+
HttpCode(204),
|
|
337
|
+
_ts_param2(0, Param("disk")),
|
|
338
|
+
_ts_param2(1, Query("key")),
|
|
339
|
+
_ts_metadata2("design:type", Function),
|
|
340
|
+
_ts_metadata2("design:paramtypes", [
|
|
341
|
+
String,
|
|
342
|
+
String
|
|
343
|
+
]),
|
|
344
|
+
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
345
|
+
], MediaConsoleActionsController.prototype, "deleteObject", null);
|
|
346
|
+
_ts_decorate2([
|
|
347
|
+
Post("disks/:disk/copy"),
|
|
348
|
+
HttpCode(204),
|
|
349
|
+
_ts_param2(0, Param("disk")),
|
|
350
|
+
_ts_param2(1, Body()),
|
|
351
|
+
_ts_metadata2("design:type", Function),
|
|
352
|
+
_ts_metadata2("design:paramtypes", [
|
|
353
|
+
String,
|
|
354
|
+
typeof CopyMoveBody === "undefined" ? Object : CopyMoveBody
|
|
355
|
+
]),
|
|
356
|
+
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
357
|
+
], MediaConsoleActionsController.prototype, "copyObject", null);
|
|
358
|
+
_ts_decorate2([
|
|
359
|
+
Post("disks/:disk/move"),
|
|
360
|
+
HttpCode(204),
|
|
361
|
+
_ts_param2(0, Param("disk")),
|
|
362
|
+
_ts_param2(1, Body()),
|
|
363
|
+
_ts_metadata2("design:type", Function),
|
|
364
|
+
_ts_metadata2("design:paramtypes", [
|
|
365
|
+
String,
|
|
366
|
+
typeof CopyMoveBody === "undefined" ? Object : CopyMoveBody
|
|
367
|
+
]),
|
|
368
|
+
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
369
|
+
], MediaConsoleActionsController.prototype, "moveObject", null);
|
|
370
|
+
_ts_decorate2([
|
|
371
|
+
Post("uploads/:id/abort"),
|
|
372
|
+
HttpCode(204),
|
|
373
|
+
_ts_param2(0, Param("id")),
|
|
374
|
+
_ts_metadata2("design:type", Function),
|
|
375
|
+
_ts_metadata2("design:paramtypes", [
|
|
376
|
+
String
|
|
377
|
+
]),
|
|
378
|
+
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
379
|
+
], MediaConsoleActionsController.prototype, "abortUpload", null);
|
|
380
|
+
_ts_decorate2([
|
|
381
|
+
Delete("library/:id"),
|
|
382
|
+
HttpCode(204),
|
|
383
|
+
_ts_param2(0, Param("id")),
|
|
384
|
+
_ts_metadata2("design:type", Function),
|
|
385
|
+
_ts_metadata2("design:paramtypes", [
|
|
386
|
+
String
|
|
387
|
+
]),
|
|
388
|
+
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
389
|
+
], MediaConsoleActionsController.prototype, "deleteLibraryRecord", null);
|
|
390
|
+
MediaConsoleActionsController = _ts_decorate2([
|
|
391
|
+
Controller(),
|
|
392
|
+
_ts_param2(0, Inject2(MediaConsoleService)),
|
|
393
|
+
_ts_metadata2("design:type", Function),
|
|
394
|
+
_ts_metadata2("design:paramtypes", [
|
|
395
|
+
typeof MediaConsoleService === "undefined" ? Object : MediaConsoleService
|
|
396
|
+
])
|
|
397
|
+
], MediaConsoleActionsController);
|
|
398
|
+
|
|
399
|
+
// src/server/media-console-read.controller.ts
|
|
400
|
+
import { Controller as Controller2, Get, Inject as Inject3, Param as Param2, Query as Query2 } from "@nestjs/common";
|
|
401
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
402
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
403
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
404
|
+
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;
|
|
405
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
406
|
+
}
|
|
407
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
408
|
+
function _ts_metadata3(k, v) {
|
|
409
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
410
|
+
}
|
|
411
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
412
|
+
function _ts_param3(paramIndex, decorator) {
|
|
413
|
+
return function(target, key) {
|
|
414
|
+
decorator(target, key, paramIndex);
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
__name(_ts_param3, "_ts_param");
|
|
418
|
+
function toLimit(value) {
|
|
419
|
+
if (value === void 0) return void 0;
|
|
420
|
+
const parsed = Number(value);
|
|
421
|
+
return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : void 0;
|
|
422
|
+
}
|
|
423
|
+
__name(toLimit, "toLimit");
|
|
424
|
+
var MediaConsoleReadController = class {
|
|
425
|
+
static {
|
|
426
|
+
__name(this, "MediaConsoleReadController");
|
|
427
|
+
}
|
|
428
|
+
service;
|
|
429
|
+
constructor(service) {
|
|
430
|
+
this.service = service;
|
|
431
|
+
}
|
|
432
|
+
disks() {
|
|
433
|
+
return this.service.listDisks();
|
|
434
|
+
}
|
|
435
|
+
objects(disk, prefix, cursor, limit) {
|
|
436
|
+
const limitValue = toLimit(limit);
|
|
437
|
+
return this.service.listObjects(disk, {
|
|
438
|
+
...prefix ? {
|
|
439
|
+
prefix
|
|
440
|
+
} : {},
|
|
441
|
+
...cursor ? {
|
|
442
|
+
cursor
|
|
443
|
+
} : {},
|
|
444
|
+
...limitValue !== void 0 ? {
|
|
445
|
+
limit: limitValue
|
|
446
|
+
} : {}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
object(disk, key) {
|
|
450
|
+
return this.service.objectDetail(disk, key);
|
|
451
|
+
}
|
|
452
|
+
uploads(disk, prefix) {
|
|
453
|
+
return this.service.listUploads({
|
|
454
|
+
...disk ? {
|
|
455
|
+
disk
|
|
456
|
+
} : {},
|
|
457
|
+
...prefix ? {
|
|
458
|
+
prefix
|
|
459
|
+
} : {}
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
upload(id) {
|
|
463
|
+
return this.service.uploadDetail(id);
|
|
464
|
+
}
|
|
465
|
+
collections() {
|
|
466
|
+
return this.service.listCollections();
|
|
467
|
+
}
|
|
468
|
+
library(collection, disk, cursor, limit) {
|
|
469
|
+
const limitValue = toLimit(limit);
|
|
470
|
+
return this.service.listLibrary({
|
|
471
|
+
...collection ? {
|
|
472
|
+
collection
|
|
473
|
+
} : {},
|
|
474
|
+
...disk ? {
|
|
475
|
+
disk
|
|
476
|
+
} : {},
|
|
477
|
+
...cursor ? {
|
|
478
|
+
cursor
|
|
479
|
+
} : {},
|
|
480
|
+
...limitValue !== void 0 ? {
|
|
481
|
+
limit: limitValue
|
|
482
|
+
} : {}
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
libraryRecord(id) {
|
|
486
|
+
return this.service.libraryDetail(id);
|
|
487
|
+
}
|
|
488
|
+
topology() {
|
|
489
|
+
return this.service.topology();
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
_ts_decorate3([
|
|
493
|
+
Get("disks"),
|
|
494
|
+
_ts_metadata3("design:type", Function),
|
|
495
|
+
_ts_metadata3("design:paramtypes", []),
|
|
496
|
+
_ts_metadata3("design:returntype", typeof DiskListResponse === "undefined" ? Object : DiskListResponse)
|
|
497
|
+
], MediaConsoleReadController.prototype, "disks", null);
|
|
498
|
+
_ts_decorate3([
|
|
499
|
+
Get("disks/:disk/objects"),
|
|
500
|
+
_ts_param3(0, Param2("disk")),
|
|
501
|
+
_ts_param3(1, Query2("prefix")),
|
|
502
|
+
_ts_param3(2, Query2("cursor")),
|
|
503
|
+
_ts_param3(3, Query2("limit")),
|
|
504
|
+
_ts_metadata3("design:type", Function),
|
|
505
|
+
_ts_metadata3("design:paramtypes", [
|
|
506
|
+
String,
|
|
507
|
+
String,
|
|
508
|
+
String,
|
|
509
|
+
String
|
|
510
|
+
]),
|
|
511
|
+
_ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
512
|
+
], MediaConsoleReadController.prototype, "objects", null);
|
|
513
|
+
_ts_decorate3([
|
|
514
|
+
Get("disks/:disk/object"),
|
|
515
|
+
_ts_param3(0, Param2("disk")),
|
|
516
|
+
_ts_param3(1, Query2("key")),
|
|
517
|
+
_ts_metadata3("design:type", Function),
|
|
518
|
+
_ts_metadata3("design:paramtypes", [
|
|
519
|
+
String,
|
|
520
|
+
String
|
|
521
|
+
]),
|
|
522
|
+
_ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
523
|
+
], MediaConsoleReadController.prototype, "object", null);
|
|
524
|
+
_ts_decorate3([
|
|
525
|
+
Get("uploads"),
|
|
526
|
+
_ts_param3(0, Query2("disk")),
|
|
527
|
+
_ts_param3(1, Query2("prefix")),
|
|
528
|
+
_ts_metadata3("design:type", Function),
|
|
529
|
+
_ts_metadata3("design:paramtypes", [
|
|
530
|
+
String,
|
|
531
|
+
String
|
|
532
|
+
]),
|
|
533
|
+
_ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
534
|
+
], MediaConsoleReadController.prototype, "uploads", null);
|
|
535
|
+
_ts_decorate3([
|
|
536
|
+
Get("uploads/:id"),
|
|
537
|
+
_ts_param3(0, Param2("id")),
|
|
538
|
+
_ts_metadata3("design:type", Function),
|
|
539
|
+
_ts_metadata3("design:paramtypes", [
|
|
540
|
+
String
|
|
541
|
+
]),
|
|
542
|
+
_ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
543
|
+
], MediaConsoleReadController.prototype, "upload", null);
|
|
544
|
+
_ts_decorate3([
|
|
545
|
+
Get("library/collections"),
|
|
546
|
+
_ts_metadata3("design:type", Function),
|
|
547
|
+
_ts_metadata3("design:paramtypes", []),
|
|
548
|
+
_ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
549
|
+
], MediaConsoleReadController.prototype, "collections", null);
|
|
550
|
+
_ts_decorate3([
|
|
551
|
+
Get("library"),
|
|
552
|
+
_ts_param3(0, Query2("collection")),
|
|
553
|
+
_ts_param3(1, Query2("disk")),
|
|
554
|
+
_ts_param3(2, Query2("cursor")),
|
|
555
|
+
_ts_param3(3, Query2("limit")),
|
|
556
|
+
_ts_metadata3("design:type", Function),
|
|
557
|
+
_ts_metadata3("design:paramtypes", [
|
|
558
|
+
String,
|
|
559
|
+
String,
|
|
560
|
+
String,
|
|
561
|
+
String
|
|
562
|
+
]),
|
|
563
|
+
_ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
564
|
+
], MediaConsoleReadController.prototype, "library", null);
|
|
565
|
+
_ts_decorate3([
|
|
566
|
+
Get("library/:id"),
|
|
567
|
+
_ts_param3(0, Param2("id")),
|
|
568
|
+
_ts_metadata3("design:type", Function),
|
|
569
|
+
_ts_metadata3("design:paramtypes", [
|
|
570
|
+
String
|
|
571
|
+
]),
|
|
572
|
+
_ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
573
|
+
], MediaConsoleReadController.prototype, "libraryRecord", null);
|
|
574
|
+
_ts_decorate3([
|
|
575
|
+
Get("topology"),
|
|
576
|
+
_ts_metadata3("design:type", Function),
|
|
577
|
+
_ts_metadata3("design:paramtypes", []),
|
|
578
|
+
_ts_metadata3("design:returntype", typeof Topology === "undefined" ? Object : Topology)
|
|
579
|
+
], MediaConsoleReadController.prototype, "topology", null);
|
|
580
|
+
MediaConsoleReadController = _ts_decorate3([
|
|
581
|
+
Controller2(),
|
|
582
|
+
_ts_param3(0, Inject3(MediaConsoleService)),
|
|
583
|
+
_ts_metadata3("design:type", Function),
|
|
584
|
+
_ts_metadata3("design:paramtypes", [
|
|
585
|
+
typeof MediaConsoleService === "undefined" ? Object : MediaConsoleService
|
|
586
|
+
])
|
|
587
|
+
], MediaConsoleReadController);
|
|
588
|
+
|
|
589
|
+
// src/server/media-console-api.module.ts
|
|
590
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
591
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
592
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
593
|
+
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;
|
|
594
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
595
|
+
}
|
|
596
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
597
|
+
var MediaConsoleApiModule = class _MediaConsoleApiModule {
|
|
598
|
+
static {
|
|
599
|
+
__name(this, "MediaConsoleApiModule");
|
|
600
|
+
}
|
|
601
|
+
static register(actions) {
|
|
602
|
+
return {
|
|
603
|
+
module: _MediaConsoleApiModule,
|
|
604
|
+
controllers: actions ? [
|
|
605
|
+
MediaConsoleReadController,
|
|
606
|
+
MediaConsoleActionsController
|
|
607
|
+
] : [
|
|
608
|
+
MediaConsoleReadController
|
|
609
|
+
],
|
|
610
|
+
providers: [
|
|
611
|
+
MediaConsoleService,
|
|
612
|
+
{
|
|
613
|
+
provide: MEDIA_DASHBOARD_ACTIONS,
|
|
614
|
+
useValue: actions
|
|
615
|
+
}
|
|
616
|
+
],
|
|
617
|
+
exports: [
|
|
618
|
+
MediaConsoleService
|
|
619
|
+
]
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
MediaConsoleApiModule = _ts_decorate4([
|
|
624
|
+
Module({})
|
|
625
|
+
], MediaConsoleApiModule);
|
|
626
|
+
|
|
627
|
+
// src/server/media-dashboard-ui.controller.ts
|
|
628
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
629
|
+
import { basename, extname, join, resolve, sep } from "node:path";
|
|
630
|
+
import { fileURLToPath } from "node:url";
|
|
631
|
+
import { Controller as Controller3, Get as Get2, Header, Inject as Inject4, NotFoundException as NotFoundException2, Param as Param3, StreamableFile } from "@nestjs/common";
|
|
632
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
633
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
634
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
635
|
+
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;
|
|
636
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
637
|
+
}
|
|
638
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
639
|
+
function _ts_metadata4(k, v) {
|
|
640
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
641
|
+
}
|
|
642
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
643
|
+
function _ts_param4(paramIndex, decorator) {
|
|
644
|
+
return function(target, key) {
|
|
645
|
+
decorator(target, key, paramIndex);
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
__name(_ts_param4, "_ts_param");
|
|
649
|
+
var BUILD_BASE = "/media";
|
|
650
|
+
function spaDir() {
|
|
651
|
+
return fileURLToPath(new URL("../spa", import.meta.url));
|
|
652
|
+
}
|
|
653
|
+
__name(spaDir, "spaDir");
|
|
654
|
+
var CONTENT_TYPES = {
|
|
655
|
+
".js": "text/javascript; charset=utf-8",
|
|
656
|
+
".css": "text/css; charset=utf-8",
|
|
657
|
+
".map": "application/json; charset=utf-8",
|
|
658
|
+
".svg": "image/svg+xml",
|
|
659
|
+
".json": "application/json; charset=utf-8",
|
|
660
|
+
".woff2": "font/woff2",
|
|
661
|
+
".ico": "image/x-icon"
|
|
662
|
+
};
|
|
663
|
+
var MediaDashboardUiController = class {
|
|
664
|
+
static {
|
|
665
|
+
__name(this, "MediaDashboardUiController");
|
|
666
|
+
}
|
|
667
|
+
basePath;
|
|
668
|
+
apiBasePath;
|
|
669
|
+
dir = spaDir();
|
|
670
|
+
constructor(basePath, apiBasePath) {
|
|
671
|
+
this.basePath = basePath;
|
|
672
|
+
this.apiBasePath = apiBasePath;
|
|
673
|
+
}
|
|
674
|
+
// index.html references hash-named bundles, so it MUST NOT be cached (stale bundle = "stuck
|
|
675
|
+
// loading after a deploy"). The hashed assets below are immutable.
|
|
676
|
+
index() {
|
|
677
|
+
const indexPath = join(this.dir, "index.html");
|
|
678
|
+
if (!existsSync(indexPath)) {
|
|
679
|
+
throw new NotFoundException2("Console SPA is not built. Run the package build.");
|
|
680
|
+
}
|
|
681
|
+
const html = readFileSync(indexPath, "utf8").replaceAll(`="${BUILD_BASE}/`, `="${this.basePath}/`);
|
|
682
|
+
const inject = `<script>window.__MEDIA_BASE__='${this.basePath}';window.__MEDIA_API__='${this.apiBasePath}';</script>`;
|
|
683
|
+
return html.includes("</head>") ? html.replace("</head>", `${inject}</head>`) : inject + html;
|
|
684
|
+
}
|
|
685
|
+
asset(file) {
|
|
686
|
+
const safe = basename(file);
|
|
687
|
+
if (safe !== file) throw new NotFoundException2();
|
|
688
|
+
const root = resolve(this.dir, "assets");
|
|
689
|
+
const assetPath = resolve(root, safe);
|
|
690
|
+
if (!assetPath.startsWith(root + sep) || !existsSync(assetPath)) {
|
|
691
|
+
throw new NotFoundException2();
|
|
692
|
+
}
|
|
693
|
+
const type = CONTENT_TYPES[extname(safe)] ?? "application/octet-stream";
|
|
694
|
+
return new StreamableFile(readFileSync(assetPath), {
|
|
695
|
+
type
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
_ts_decorate5([
|
|
700
|
+
Get2(),
|
|
701
|
+
Header("Content-Type", "text/html; charset=utf-8"),
|
|
702
|
+
Header("Cache-Control", "no-store, must-revalidate"),
|
|
703
|
+
_ts_metadata4("design:type", Function),
|
|
704
|
+
_ts_metadata4("design:paramtypes", []),
|
|
705
|
+
_ts_metadata4("design:returntype", String)
|
|
706
|
+
], MediaDashboardUiController.prototype, "index", null);
|
|
707
|
+
_ts_decorate5([
|
|
708
|
+
Get2("assets/:file"),
|
|
709
|
+
Header("Cache-Control", "public, max-age=31536000, immutable"),
|
|
710
|
+
_ts_param4(0, Param3("file")),
|
|
711
|
+
_ts_metadata4("design:type", Function),
|
|
712
|
+
_ts_metadata4("design:paramtypes", [
|
|
713
|
+
String
|
|
714
|
+
]),
|
|
715
|
+
_ts_metadata4("design:returntype", typeof StreamableFile === "undefined" ? Object : StreamableFile)
|
|
716
|
+
], MediaDashboardUiController.prototype, "asset", null);
|
|
717
|
+
MediaDashboardUiController = _ts_decorate5([
|
|
718
|
+
Controller3(),
|
|
719
|
+
_ts_param4(0, Inject4(MEDIA_DASHBOARD_BASE_PATH)),
|
|
720
|
+
_ts_param4(1, Inject4(MEDIA_DASHBOARD_API_PATH)),
|
|
721
|
+
_ts_metadata4("design:type", Function),
|
|
722
|
+
_ts_metadata4("design:paramtypes", [
|
|
723
|
+
String,
|
|
724
|
+
String
|
|
725
|
+
])
|
|
726
|
+
], MediaDashboardUiController);
|
|
727
|
+
|
|
728
|
+
// src/server/media-dashboard.module.ts
|
|
729
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
730
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
731
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
732
|
+
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;
|
|
733
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
734
|
+
}
|
|
735
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
736
|
+
function normalize(path) {
|
|
737
|
+
return `/${path.replace(/^\/+|\/+$/g, "")}`;
|
|
738
|
+
}
|
|
739
|
+
__name(normalize, "normalize");
|
|
740
|
+
var MediaDashboardModule = class _MediaDashboardModule {
|
|
741
|
+
static {
|
|
742
|
+
__name(this, "MediaDashboardModule");
|
|
743
|
+
}
|
|
744
|
+
static forRoot(options = {}) {
|
|
745
|
+
const basePath = normalize(options.basePath ?? "/media");
|
|
746
|
+
const apiBasePath = normalize(options.apiBasePath ?? `${basePath}/api`);
|
|
747
|
+
const actions = options.actions === true;
|
|
748
|
+
return {
|
|
749
|
+
module: _MediaDashboardModule,
|
|
750
|
+
imports: [
|
|
751
|
+
MediaConsoleApiModule.register(actions),
|
|
752
|
+
RouterModule.register([
|
|
753
|
+
{
|
|
754
|
+
path: basePath,
|
|
755
|
+
module: _MediaDashboardModule
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
path: apiBasePath,
|
|
759
|
+
module: MediaConsoleApiModule
|
|
760
|
+
}
|
|
761
|
+
])
|
|
762
|
+
],
|
|
763
|
+
controllers: [
|
|
764
|
+
MediaDashboardUiController
|
|
765
|
+
],
|
|
766
|
+
providers: [
|
|
767
|
+
{
|
|
768
|
+
provide: MEDIA_DASHBOARD_BASE_PATH,
|
|
769
|
+
useValue: basePath
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
provide: MEDIA_DASHBOARD_API_PATH,
|
|
773
|
+
useValue: apiBasePath
|
|
774
|
+
}
|
|
775
|
+
],
|
|
776
|
+
// Re-export the API module so its MediaConsoleService reaches importers if they want it.
|
|
777
|
+
exports: [
|
|
778
|
+
MediaConsoleApiModule
|
|
779
|
+
]
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
MediaDashboardModule = _ts_decorate6([
|
|
784
|
+
Module2({})
|
|
785
|
+
], MediaDashboardModule);
|
|
786
|
+
export {
|
|
787
|
+
MEDIA_STORAGE_SHARED,
|
|
788
|
+
MEDIA_STORE,
|
|
789
|
+
MEDIA_UPLOAD_SESSIONS,
|
|
790
|
+
MediaConsoleApiModule,
|
|
791
|
+
MediaConsoleService,
|
|
792
|
+
MediaDashboardModule
|
|
793
|
+
};
|
|
794
|
+
//# sourceMappingURL=index.js.map
|