@dudousxd/nestjs-media-dashboard 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.
- package/dist/server/index.cjs +61 -5
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +55 -5
- package/dist/server/index.d.ts +55 -5
- package/dist/server/index.js +61 -5
- package/dist/server/index.js.map +1 -1
- package/dist/spa/assets/{index-35W065P0.js → index-CCjuiZ1u.js} +1 -1
- package/dist/spa/assets/{preview-1-uLt3oQ.js → preview-rp64mDIs.js} +1 -1
- package/dist/spa/assets/{styles-BxrXiuy2.js → styles-Bwprsevk.js} +22 -22
- package/dist/spa/index.html +2 -2
- package/dist/spa/preview.html +2 -2
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -80,6 +80,28 @@ function resolveConsoleAuth(options) {
|
|
|
80
80
|
}
|
|
81
81
|
__name(resolveConsoleAuth, "resolveConsoleAuth");
|
|
82
82
|
|
|
83
|
+
// src/server/guards.ts
|
|
84
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
85
|
+
var GUARDS_METADATA = "__guards__";
|
|
86
|
+
function isGuardClass(guard) {
|
|
87
|
+
return typeof guard === "function";
|
|
88
|
+
}
|
|
89
|
+
__name(isGuardClass, "isGuardClass");
|
|
90
|
+
function baseGuards(controller) {
|
|
91
|
+
return Reflect.getOwnMetadata(GUARDS_METADATA, controller) ?? [];
|
|
92
|
+
}
|
|
93
|
+
__name(baseGuards, "baseGuards");
|
|
94
|
+
function stampGuards(guards, entries) {
|
|
95
|
+
if (guards === void 0 || guards.length === 0) return;
|
|
96
|
+
for (const [controller, base] of entries) {
|
|
97
|
+
Reflect.defineMetadata(GUARDS_METADATA, [
|
|
98
|
+
...base,
|
|
99
|
+
...guards
|
|
100
|
+
], controller);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
__name(stampGuards, "stampGuards");
|
|
104
|
+
|
|
83
105
|
// src/server/media-console-api.module.ts
|
|
84
106
|
var import_common6 = require("@nestjs/common");
|
|
85
107
|
|
|
@@ -488,10 +510,15 @@ var MediaConsoleService = class {
|
|
|
488
510
|
limit: options.limit ?? DEFAULT_PAGE_LIMIT
|
|
489
511
|
});
|
|
490
512
|
return {
|
|
513
|
+
// Drop phantom folders whose name is empty — a CommonPrefix of only slashes (`/`, `//`),
|
|
514
|
+
// produced by a stray key with a leading slash. The S3 driver normalizes such a prefix back to
|
|
515
|
+
// the root, so listing INTO one returns the root again (the phantom included) — a self-reference
|
|
516
|
+
// that infinite-loops the folder tree. Filtering it out removes the trap; those leading-slash
|
|
517
|
+
// keys are unreachable from the console anyway (the driver strips the leading slash).
|
|
491
518
|
folders: result.folders.map((prefix) => ({
|
|
492
519
|
name: lastSegment(prefix),
|
|
493
520
|
prefix
|
|
494
|
-
})),
|
|
521
|
+
})).filter((folder) => folder.name !== ""),
|
|
495
522
|
// Drop the zero-byte "folder marker" (a key ending in `/`, whose name is empty after the
|
|
496
523
|
// prefix) that `createFolder` writes — it's the folder itself, not a file inside it.
|
|
497
524
|
files: result.files.filter((entry) => entry.name !== "").map((entry) => ({
|
|
@@ -1387,11 +1414,23 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1387
1414
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1388
1415
|
}
|
|
1389
1416
|
__name(_ts_decorate6, "_ts_decorate");
|
|
1417
|
+
var READ_BASE_GUARDS = baseGuards(MediaConsoleReadController);
|
|
1418
|
+
var ACTIONS_BASE_GUARDS = baseGuards(MediaConsoleActionsController);
|
|
1390
1419
|
var MediaConsoleApiModule = class _MediaConsoleApiModule {
|
|
1391
1420
|
static {
|
|
1392
1421
|
__name(this, "MediaConsoleApiModule");
|
|
1393
1422
|
}
|
|
1394
1423
|
static register(options) {
|
|
1424
|
+
stampGuards(options.guards, [
|
|
1425
|
+
[
|
|
1426
|
+
MediaConsoleReadController,
|
|
1427
|
+
READ_BASE_GUARDS
|
|
1428
|
+
],
|
|
1429
|
+
[
|
|
1430
|
+
MediaConsoleActionsController,
|
|
1431
|
+
ACTIONS_BASE_GUARDS
|
|
1432
|
+
]
|
|
1433
|
+
]);
|
|
1395
1434
|
return {
|
|
1396
1435
|
module: _MediaConsoleApiModule,
|
|
1397
1436
|
imports: options.imports ?? [],
|
|
@@ -1413,7 +1452,11 @@ var MediaConsoleApiModule = class _MediaConsoleApiModule {
|
|
|
1413
1452
|
provide: MEDIA_CONSOLE_COOKIE_PATH,
|
|
1414
1453
|
useValue: options.cookiePath
|
|
1415
1454
|
},
|
|
1416
|
-
options.authProvider
|
|
1455
|
+
options.authProvider,
|
|
1456
|
+
// Class guards need a DI provider so Nest can instantiate them in THIS module's context
|
|
1457
|
+
// (where `imports` above resolves their dependencies). An already-instantiated guard needs
|
|
1458
|
+
// none — it's used as-is.
|
|
1459
|
+
...(options.guards ?? []).filter(isGuardClass)
|
|
1417
1460
|
],
|
|
1418
1461
|
exports: [
|
|
1419
1462
|
MediaConsoleService
|
|
@@ -1547,7 +1590,7 @@ var MediaDashboardModule = class _MediaDashboardModule {
|
|
|
1547
1590
|
return _MediaDashboardModule.build(options, apiBasePath, {
|
|
1548
1591
|
provide: MEDIA_CONSOLE_AUTH,
|
|
1549
1592
|
useValue: resolveConsoleAuth(options.auth)
|
|
1550
|
-
});
|
|
1593
|
+
}, options.imports);
|
|
1551
1594
|
}
|
|
1552
1595
|
static forRootAsync(options) {
|
|
1553
1596
|
const apiBasePath = normalize(options.apiBasePath ?? `${normalize(options.basePath ?? "/media")}/api`);
|
|
@@ -1562,14 +1605,24 @@ var MediaDashboardModule = class _MediaDashboardModule {
|
|
|
1562
1605
|
static build(options, apiBasePath, authProvider, imports) {
|
|
1563
1606
|
const basePath = normalize(options.basePath ?? "/media");
|
|
1564
1607
|
const actions = options.actions === true;
|
|
1608
|
+
stampGuards(options.guards, [
|
|
1609
|
+
[
|
|
1610
|
+
MediaDashboardUiController,
|
|
1611
|
+
[]
|
|
1612
|
+
]
|
|
1613
|
+
]);
|
|
1565
1614
|
return {
|
|
1566
1615
|
module: _MediaDashboardModule,
|
|
1567
1616
|
imports: [
|
|
1617
|
+
...imports ?? [],
|
|
1568
1618
|
MediaConsoleApiModule.register({
|
|
1569
1619
|
actions,
|
|
1570
1620
|
cookiePath: apiBasePath,
|
|
1571
1621
|
authProvider,
|
|
1572
|
-
imports
|
|
1622
|
+
imports,
|
|
1623
|
+
...options.guards ? {
|
|
1624
|
+
guards: options.guards
|
|
1625
|
+
} : {}
|
|
1573
1626
|
}),
|
|
1574
1627
|
import_core.RouterModule.register([
|
|
1575
1628
|
{
|
|
@@ -1593,7 +1646,10 @@ var MediaDashboardModule = class _MediaDashboardModule {
|
|
|
1593
1646
|
{
|
|
1594
1647
|
provide: MEDIA_DASHBOARD_API_PATH,
|
|
1595
1648
|
useValue: apiBasePath
|
|
1596
|
-
}
|
|
1649
|
+
},
|
|
1650
|
+
// MediaDashboardUiController is hosted HERE, so its guards DI-instantiate from this
|
|
1651
|
+
// module — class guards need a provider; an already-instantiated guard needs none.
|
|
1652
|
+
...(options.guards ?? []).filter(isGuardClass)
|
|
1597
1653
|
],
|
|
1598
1654
|
// Re-export the API module so its MediaConsoleService reaches importers if they want it.
|
|
1599
1655
|
exports: [
|