@iamnnort/nestjs-serializer 2.2.1 → 2.2.3

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/index.mjs CHANGED
@@ -8991,6 +8991,7 @@ var require_operators = __commonJS({
8991
8991
  });
8992
8992
 
8993
8993
  // src/decorator.ts
8994
+ import { createParamDecorator } from "@nestjs/common";
8994
8995
  global.serializerFieldConfigs = [];
8995
8996
  var SerializeField = /* @__PURE__ */ __name((configs) => {
8996
8997
  return (target, name) => {
@@ -9018,6 +9019,10 @@ var SerializeRelation = /* @__PURE__ */ __name((configs) => {
9018
9019
  });
9019
9020
  };
9020
9021
  }, "SerializeRelation");
9022
+ var SerializerQuery = createParamDecorator((data, ctx) => {
9023
+ const request = ctx.switchToHttp().getRequest();
9024
+ return request.scopes;
9025
+ });
9021
9026
 
9022
9027
  // src/interceptor.ts
9023
9028
  var import_operators = __toESM(require_operators());
@@ -9221,27 +9226,28 @@ var SerializerInterceptor = /* @__PURE__ */ __name((config) => {
9221
9226
  this.serializerService = serializerService;
9222
9227
  }
9223
9228
  intercept(ctx, next) {
9224
- const scopes = this.getScopes(ctx);
9229
+ const request = ctx.switchToHttp().getRequest();
9230
+ request.scopes = this.getScopes(ctx);
9225
9231
  return next.handle().pipe((0, import_operators.map)(async (responsePromise) => {
9226
9232
  const response = await responsePromise;
9227
- if (!scopes && !config.fields) {
9233
+ if (!request.scopes && !config.fields) {
9228
9234
  return response;
9229
9235
  }
9230
9236
  return this.serializerService.transform(response, {
9231
- scopes,
9237
+ scopes: request.scopes,
9232
9238
  fields: config.fields
9233
9239
  });
9234
9240
  }));
9235
9241
  }
9236
9242
  getScopes(ctx) {
9237
9243
  const request = ctx.switchToHttp().getRequest();
9238
- if (request.query.extended) {
9244
+ if (request.query.extended === "true") {
9239
9245
  return config.extendedScopes || config.scopes;
9240
9246
  }
9241
- if (request.query.limited) {
9247
+ if (request.query.limited === "true") {
9242
9248
  return config.limitedScopes || this.serializerService.config.globalLimitedScopes || config.scopes;
9243
9249
  }
9244
- if (request.query.secret) {
9250
+ if (request.query.secret === "true") {
9245
9251
  return config.secretScopes || this.serializerService.config.globalSecretScopes || config.scopes;
9246
9252
  }
9247
9253
  if (request.query.scopes && config.allowedScopes) {
@@ -9303,6 +9309,7 @@ export {
9303
9309
  SerializerIdInterceptor,
9304
9310
  SerializerInterceptor,
9305
9311
  SerializerModule,
9312
+ SerializerQuery,
9306
9313
  SerializerService
9307
9314
  };
9308
9315
  //# sourceMappingURL=index.mjs.map