@dudousxd/nestjs-catalog-dashboard 0.3.3 → 0.4.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 +128 -118
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +122 -112
- package/dist/server/index.js.map +1 -1
- package/dist/spa/assets/{index-CK21cSYi.js → index-CaOjuXIq.js} +76 -76
- package/dist/spa/assets/index-CkTR3G5F.css +1 -0
- package/dist/spa/index.html +2 -2
- package/package.json +2 -2
- package/dist/spa/assets/index-CweNfj1K.css +0 -1
package/dist/server/index.js
CHANGED
|
@@ -949,124 +949,16 @@ CatalogAuthController = _ts_decorate4([
|
|
|
949
949
|
// src/server/catalog-dashboard.module.ts
|
|
950
950
|
import { Module, UseGuards } from "@nestjs/common";
|
|
951
951
|
import { RouterModule } from "@nestjs/core";
|
|
952
|
-
function _ts_decorate5(decorators, target, key, desc) {
|
|
953
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
954
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
955
|
-
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;
|
|
956
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
957
|
-
}
|
|
958
|
-
__name(_ts_decorate5, "_ts_decorate");
|
|
959
|
-
var CatalogDashboardModule = class {
|
|
960
|
-
static {
|
|
961
|
-
__name(this, "CatalogDashboardModule");
|
|
962
|
-
}
|
|
963
|
-
static forRoot(options = {}) {
|
|
964
|
-
return build(options, {
|
|
965
|
-
provide: DASHBOARD_AUTH,
|
|
966
|
-
useValue: options.auth ? resolveDashboardAuth(options.auth) : null
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
/**
|
|
970
|
-
* Same mount, but the auth is built from DI.
|
|
971
|
-
*
|
|
972
|
-
* Needed whenever validating a session means asking something the host owns —
|
|
973
|
-
* a user store, a session service. `forRoot` cannot express that: `guards` and
|
|
974
|
-
* the router are bound at module-DEFINITION time, before any injector exists,
|
|
975
|
-
* which is why `guards` stays a static option on both forms.
|
|
976
|
-
*/
|
|
977
|
-
static forRootAsync(options) {
|
|
978
|
-
const factory = options.useDashboardAuth;
|
|
979
|
-
const mounted = build(options, {
|
|
980
|
-
provide: DASHBOARD_AUTH,
|
|
981
|
-
// Same resolution as `forRoot`, wrapped around the host's factory so the
|
|
982
|
-
// async path cannot skip it.
|
|
983
|
-
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
984
|
-
const auth = await factory(...args);
|
|
985
|
-
return auth ? resolveDashboardAuth(auth) : null;
|
|
986
|
-
}, "useFactory"),
|
|
987
|
-
inject: options.inject ?? []
|
|
988
|
-
});
|
|
989
|
-
return {
|
|
990
|
-
...mounted,
|
|
991
|
-
imports: [
|
|
992
|
-
...mounted.imports ?? [],
|
|
993
|
-
...options.imports ?? []
|
|
994
|
-
]
|
|
995
|
-
};
|
|
996
|
-
}
|
|
997
|
-
};
|
|
998
|
-
CatalogDashboardModule = _ts_decorate5([
|
|
999
|
-
Module({})
|
|
1000
|
-
], CatalogDashboardModule);
|
|
1001
|
-
function build(options, auth) {
|
|
1002
|
-
const path = normalise(options.path ?? "/catalog");
|
|
1003
|
-
const apiPath = normalise(options.apiPath ?? "/api/catalog-service");
|
|
1004
|
-
for (const guard of options.guards ?? []) {
|
|
1005
|
-
UseGuards(guard)(CatalogUiController);
|
|
1006
|
-
UseGuards(guard)(CatalogAuthController);
|
|
1007
|
-
}
|
|
1008
|
-
const providers = [
|
|
1009
|
-
{
|
|
1010
|
-
provide: DASHBOARD_BASE_PATH,
|
|
1011
|
-
useValue: path
|
|
1012
|
-
},
|
|
1013
|
-
{
|
|
1014
|
-
provide: DASHBOARD_API_PATH,
|
|
1015
|
-
useValue: apiPath
|
|
1016
|
-
},
|
|
1017
|
-
auth
|
|
1018
|
-
];
|
|
1019
|
-
return {
|
|
1020
|
-
module: CatalogDashboardModule,
|
|
1021
|
-
// The controllers are `@Controller()` with no path of their own, and the
|
|
1022
|
-
// prefix arrives here instead. That is what lets `path` be configurable at
|
|
1023
|
-
// all: a decorator argument is fixed at class-definition time, so a
|
|
1024
|
-
// hardcoded one would pin every host to the same mount point.
|
|
1025
|
-
//
|
|
1026
|
-
// Without this the controllers inherit whatever the host's global prefix is
|
|
1027
|
-
// — they answered on `/api` — and the console 404s at its configured path
|
|
1028
|
-
// while the module reports itself initialised, which is a confusing pair of
|
|
1029
|
-
// symptoms to hold at once.
|
|
1030
|
-
imports: [
|
|
1031
|
-
RouterModule.register([
|
|
1032
|
-
{
|
|
1033
|
-
path,
|
|
1034
|
-
module: CatalogDashboardModule
|
|
1035
|
-
}
|
|
1036
|
-
])
|
|
1037
|
-
],
|
|
1038
|
-
controllers: [
|
|
1039
|
-
CatalogUiController,
|
|
1040
|
-
CatalogAuthController
|
|
1041
|
-
],
|
|
1042
|
-
providers,
|
|
1043
|
-
exports: providers
|
|
1044
|
-
};
|
|
1045
|
-
}
|
|
1046
|
-
__name(build, "build");
|
|
1047
|
-
function catalogDashboardMountPaths(options = {}) {
|
|
1048
|
-
const base = normalise(options.path ?? "/catalog").replace(/^\//, "");
|
|
1049
|
-
return [
|
|
1050
|
-
base,
|
|
1051
|
-
`${base}/{*splat}`
|
|
1052
|
-
];
|
|
1053
|
-
}
|
|
1054
|
-
__name(catalogDashboardMountPaths, "catalogDashboardMountPaths");
|
|
1055
|
-
function normalise(path) {
|
|
1056
|
-
const withLeading = path.startsWith("/") ? path : `/${path}`;
|
|
1057
|
-
return withLeading.length > 1 ? withLeading.replace(/\/+$/, "") : withLeading;
|
|
1058
|
-
}
|
|
1059
|
-
__name(normalise, "normalise");
|
|
1060
952
|
|
|
1061
953
|
// src/server/catalog-session.guard.ts
|
|
1062
954
|
import { Inject as Inject4, Injectable, UnauthorizedException as UnauthorizedException2 } from "@nestjs/common";
|
|
1063
|
-
function
|
|
955
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1064
956
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1065
957
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1066
958
|
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;
|
|
1067
959
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1068
960
|
}
|
|
1069
|
-
__name(
|
|
961
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
1070
962
|
function _ts_metadata4(k, v) {
|
|
1071
963
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1072
964
|
}
|
|
@@ -1117,7 +1009,7 @@ var CatalogUiSessionGuard = class {
|
|
|
1117
1009
|
throw new DashboardLoginRedirectException(`${this.basePath}/login?returnTo=${returnTo}`);
|
|
1118
1010
|
}
|
|
1119
1011
|
};
|
|
1120
|
-
CatalogUiSessionGuard =
|
|
1012
|
+
CatalogUiSessionGuard = _ts_decorate5([
|
|
1121
1013
|
Injectable(),
|
|
1122
1014
|
_ts_param4(0, Inject4(DASHBOARD_AUTH)),
|
|
1123
1015
|
_ts_param4(1, Inject4(DASHBOARD_BASE_PATH)),
|
|
@@ -1161,7 +1053,7 @@ var CatalogApiSessionGuard = class {
|
|
|
1161
1053
|
});
|
|
1162
1054
|
}
|
|
1163
1055
|
};
|
|
1164
|
-
CatalogApiSessionGuard =
|
|
1056
|
+
CatalogApiSessionGuard = _ts_decorate5([
|
|
1165
1057
|
Injectable(),
|
|
1166
1058
|
_ts_param4(0, Inject4(DASHBOARD_AUTH)),
|
|
1167
1059
|
_ts_metadata4("design:type", Function),
|
|
@@ -1169,6 +1061,124 @@ CatalogApiSessionGuard = _ts_decorate6([
|
|
|
1169
1061
|
Object
|
|
1170
1062
|
])
|
|
1171
1063
|
], CatalogApiSessionGuard);
|
|
1064
|
+
|
|
1065
|
+
// src/server/catalog-dashboard.module.ts
|
|
1066
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1067
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1068
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1069
|
+
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;
|
|
1070
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1071
|
+
}
|
|
1072
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
1073
|
+
var CatalogDashboardModule = class {
|
|
1074
|
+
static {
|
|
1075
|
+
__name(this, "CatalogDashboardModule");
|
|
1076
|
+
}
|
|
1077
|
+
static forRoot(options = {}) {
|
|
1078
|
+
return build(options, {
|
|
1079
|
+
provide: DASHBOARD_AUTH,
|
|
1080
|
+
useValue: options.auth ? resolveDashboardAuth(options.auth) : null
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Same mount, but the auth is built from DI.
|
|
1085
|
+
*
|
|
1086
|
+
* Needed whenever validating a session means asking something the host owns —
|
|
1087
|
+
* a user store, a session service. `forRoot` cannot express that: `guards` and
|
|
1088
|
+
* the router are bound at module-DEFINITION time, before any injector exists,
|
|
1089
|
+
* which is why `guards` stays a static option on both forms.
|
|
1090
|
+
*/
|
|
1091
|
+
static forRootAsync(options) {
|
|
1092
|
+
const factory = options.useDashboardAuth;
|
|
1093
|
+
const mounted = build(options, {
|
|
1094
|
+
provide: DASHBOARD_AUTH,
|
|
1095
|
+
// Same resolution as `forRoot`, wrapped around the host's factory so the
|
|
1096
|
+
// async path cannot skip it.
|
|
1097
|
+
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
1098
|
+
const auth = await factory(...args);
|
|
1099
|
+
return auth ? resolveDashboardAuth(auth) : null;
|
|
1100
|
+
}, "useFactory"),
|
|
1101
|
+
inject: options.inject ?? []
|
|
1102
|
+
});
|
|
1103
|
+
return {
|
|
1104
|
+
...mounted,
|
|
1105
|
+
imports: [
|
|
1106
|
+
...mounted.imports ?? [],
|
|
1107
|
+
...options.imports ?? []
|
|
1108
|
+
]
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
CatalogDashboardModule = _ts_decorate6([
|
|
1113
|
+
Module({})
|
|
1114
|
+
], CatalogDashboardModule);
|
|
1115
|
+
var sessionGuardStamped = false;
|
|
1116
|
+
function build(options, auth) {
|
|
1117
|
+
const path = normalise(options.path ?? "/catalog");
|
|
1118
|
+
const apiPath = normalise(options.apiPath ?? "/api/catalog-service");
|
|
1119
|
+
if (!sessionGuardStamped) {
|
|
1120
|
+
UseGuards(CatalogUiSessionGuard)(CatalogUiController);
|
|
1121
|
+
sessionGuardStamped = true;
|
|
1122
|
+
}
|
|
1123
|
+
for (const guard of options.guards ?? []) {
|
|
1124
|
+
UseGuards(guard)(CatalogUiController);
|
|
1125
|
+
UseGuards(guard)(CatalogAuthController);
|
|
1126
|
+
}
|
|
1127
|
+
const providers = [
|
|
1128
|
+
{
|
|
1129
|
+
provide: DASHBOARD_BASE_PATH,
|
|
1130
|
+
useValue: path
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
provide: DASHBOARD_API_PATH,
|
|
1134
|
+
useValue: apiPath
|
|
1135
|
+
},
|
|
1136
|
+
auth,
|
|
1137
|
+
// Constructed by Nest, so it must be declared here — a guard stamped by
|
|
1138
|
+
// `UseGuards` is still resolved from the declaring module's injector.
|
|
1139
|
+
CatalogUiSessionGuard
|
|
1140
|
+
];
|
|
1141
|
+
return {
|
|
1142
|
+
module: CatalogDashboardModule,
|
|
1143
|
+
// The controllers are `@Controller()` with no path of their own, and the
|
|
1144
|
+
// prefix arrives here instead. That is what lets `path` be configurable at
|
|
1145
|
+
// all: a decorator argument is fixed at class-definition time, so a
|
|
1146
|
+
// hardcoded one would pin every host to the same mount point.
|
|
1147
|
+
//
|
|
1148
|
+
// Without this the controllers inherit whatever the host's global prefix is
|
|
1149
|
+
// — they answered on `/api` — and the console 404s at its configured path
|
|
1150
|
+
// while the module reports itself initialised, which is a confusing pair of
|
|
1151
|
+
// symptoms to hold at once.
|
|
1152
|
+
imports: [
|
|
1153
|
+
RouterModule.register([
|
|
1154
|
+
{
|
|
1155
|
+
path,
|
|
1156
|
+
module: CatalogDashboardModule
|
|
1157
|
+
}
|
|
1158
|
+
])
|
|
1159
|
+
],
|
|
1160
|
+
controllers: [
|
|
1161
|
+
CatalogUiController,
|
|
1162
|
+
CatalogAuthController
|
|
1163
|
+
],
|
|
1164
|
+
providers,
|
|
1165
|
+
exports: providers
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
__name(build, "build");
|
|
1169
|
+
function catalogDashboardMountPaths(options = {}) {
|
|
1170
|
+
const base = normalise(options.path ?? "/catalog").replace(/^\//, "");
|
|
1171
|
+
return [
|
|
1172
|
+
base,
|
|
1173
|
+
`${base}/{*splat}`
|
|
1174
|
+
];
|
|
1175
|
+
}
|
|
1176
|
+
__name(catalogDashboardMountPaths, "catalogDashboardMountPaths");
|
|
1177
|
+
function normalise(path) {
|
|
1178
|
+
const withLeading = path.startsWith("/") ? path : `/${path}`;
|
|
1179
|
+
return withLeading.length > 1 ? withLeading.replace(/\/+$/, "") : withLeading;
|
|
1180
|
+
}
|
|
1181
|
+
__name(normalise, "normalise");
|
|
1172
1182
|
export {
|
|
1173
1183
|
CatalogApiSessionGuard,
|
|
1174
1184
|
CatalogAuthController,
|