@iamnnort/nestjs-serializer 2.2.8 → 2.10.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/README.md +1 -3
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +10 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -27,7 +27,6 @@ type SerializerFieldConfig = {
|
|
|
27
27
|
fieldTransform?: (value: any, entity: any) => any | Promise<any>;
|
|
28
28
|
};
|
|
29
29
|
type SerializerConfig = {
|
|
30
|
-
globalEntityNames?: string[];
|
|
31
30
|
globalLimitedScopes?: string[];
|
|
32
31
|
globalSecretScopes?: string[];
|
|
33
32
|
};
|
|
@@ -63,7 +62,7 @@ declare const SerializerInterceptor: (config: {
|
|
|
63
62
|
serializerService: SerializerService;
|
|
64
63
|
intercept(ctx: ExecutionContext, next: CallHandler<Promise<any>>): rxjs.Observable<Promise<any>>;
|
|
65
64
|
getScopes(ctx: ExecutionContext): string[];
|
|
66
|
-
|
|
65
|
+
withExtendedScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
67
66
|
withSecretScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
68
67
|
};
|
|
69
68
|
};
|
|
@@ -72,7 +71,7 @@ declare const SerializerIdInterceptor_base: {
|
|
|
72
71
|
serializerService: SerializerService;
|
|
73
72
|
intercept(ctx: ExecutionContext, next: CallHandler<Promise<any>>): rxjs.Observable<Promise<any>>;
|
|
74
73
|
getScopes(ctx: ExecutionContext): string[];
|
|
75
|
-
|
|
74
|
+
withExtendedScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
76
75
|
withSecretScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
77
76
|
};
|
|
78
77
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ type SerializerFieldConfig = {
|
|
|
27
27
|
fieldTransform?: (value: any, entity: any) => any | Promise<any>;
|
|
28
28
|
};
|
|
29
29
|
type SerializerConfig = {
|
|
30
|
-
globalEntityNames?: string[];
|
|
31
30
|
globalLimitedScopes?: string[];
|
|
32
31
|
globalSecretScopes?: string[];
|
|
33
32
|
};
|
|
@@ -63,7 +62,7 @@ declare const SerializerInterceptor: (config: {
|
|
|
63
62
|
serializerService: SerializerService;
|
|
64
63
|
intercept(ctx: ExecutionContext, next: CallHandler<Promise<any>>): rxjs.Observable<Promise<any>>;
|
|
65
64
|
getScopes(ctx: ExecutionContext): string[];
|
|
66
|
-
|
|
65
|
+
withExtendedScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
67
66
|
withSecretScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
68
67
|
};
|
|
69
68
|
};
|
|
@@ -72,7 +71,7 @@ declare const SerializerIdInterceptor_base: {
|
|
|
72
71
|
serializerService: SerializerService;
|
|
73
72
|
intercept(ctx: ExecutionContext, next: CallHandler<Promise<any>>): rxjs.Observable<Promise<any>>;
|
|
74
73
|
getScopes(ctx: ExecutionContext): string[];
|
|
75
|
-
|
|
74
|
+
withExtendedScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
76
75
|
withSecretScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
77
76
|
};
|
|
78
77
|
};
|
package/dist/index.js
CHANGED
|
@@ -9110,12 +9110,9 @@ var SerializerService = class {
|
|
|
9110
9110
|
return _lodash.pick.call(void 0, entity, config.fields);
|
|
9111
9111
|
}
|
|
9112
9112
|
const serializerFieldConfigs = global.serializerFieldConfigs.filter((fieldConfig) => {
|
|
9113
|
-
const isTarget = fieldConfig.target
|
|
9113
|
+
const isTarget = entity instanceof fieldConfig.target;
|
|
9114
9114
|
if (!isTarget) {
|
|
9115
|
-
|
|
9116
|
-
if (!isGlobalTarget) {
|
|
9117
|
-
return false;
|
|
9118
|
-
}
|
|
9115
|
+
return false;
|
|
9119
9116
|
}
|
|
9120
9117
|
const isScope = fieldConfig.scopes.some((scope) => {
|
|
9121
9118
|
if (!config.scopes) {
|
|
@@ -9228,7 +9225,7 @@ var SerializerInterceptor = /* @__PURE__ */ __name((config) => {
|
|
|
9228
9225
|
}
|
|
9229
9226
|
intercept(ctx, next) {
|
|
9230
9227
|
const request = ctx.switchToHttp().getRequest();
|
|
9231
|
-
request.scopes = this.
|
|
9228
|
+
request.scopes = this.getScopes(ctx);
|
|
9232
9229
|
return next.handle().pipe((0, import_operators.map)(async (responsePromise) => {
|
|
9233
9230
|
const response = await responsePromise;
|
|
9234
9231
|
if (!request.scopes && !config.fields) {
|
|
@@ -9246,18 +9243,18 @@ var SerializerInterceptor = /* @__PURE__ */ __name((config) => {
|
|
|
9246
9243
|
if (request.query.limited === "true") {
|
|
9247
9244
|
return config.limitedScopes || this.serializerService.config.globalLimitedScopes || scopes;
|
|
9248
9245
|
}
|
|
9249
|
-
if (request.query.
|
|
9250
|
-
return
|
|
9246
|
+
if (request.query.scopes && config.allowedScopes) {
|
|
9247
|
+
return _lodash.intersection.call(void 0, request.query.scopes, config.allowedScopes);
|
|
9251
9248
|
}
|
|
9252
|
-
return scopes;
|
|
9249
|
+
return this.withSecretScopes(ctx, this.withExtendedScopes(ctx, scopes));
|
|
9253
9250
|
}
|
|
9254
|
-
|
|
9251
|
+
withExtendedScopes(ctx, scopes) {
|
|
9255
9252
|
const request = ctx.switchToHttp().getRequest();
|
|
9256
|
-
if (request.query.
|
|
9257
|
-
const
|
|
9253
|
+
if (request.query.extended === "true") {
|
|
9254
|
+
const extendedScopes = config.extendedScopes || [];
|
|
9258
9255
|
return _lodash.uniq.call(void 0, [
|
|
9259
9256
|
...scopes,
|
|
9260
|
-
...
|
|
9257
|
+
...extendedScopes
|
|
9261
9258
|
]);
|
|
9262
9259
|
}
|
|
9263
9260
|
return scopes;
|