@iamnnort/nestjs-serializer 2.2.2 → 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());
@@ -9222,28 +9227,27 @@ var SerializerInterceptor = /* @__PURE__ */ __name((config) => {
9222
9227
  }
9223
9228
  intercept(ctx, next) {
9224
9229
  const request = ctx.switchToHttp().getRequest();
9225
- const scopes = this.getScopes(ctx);
9226
- request.query.scopes = scopes;
9230
+ request.scopes = this.getScopes(ctx);
9227
9231
  return next.handle().pipe((0, import_operators.map)(async (responsePromise) => {
9228
9232
  const response = await responsePromise;
9229
- if (!scopes && !config.fields) {
9233
+ if (!request.scopes && !config.fields) {
9230
9234
  return response;
9231
9235
  }
9232
9236
  return this.serializerService.transform(response, {
9233
- scopes,
9237
+ scopes: request.scopes,
9234
9238
  fields: config.fields
9235
9239
  });
9236
9240
  }));
9237
9241
  }
9238
9242
  getScopes(ctx) {
9239
9243
  const request = ctx.switchToHttp().getRequest();
9240
- if (request.query.extended) {
9244
+ if (request.query.extended === "true") {
9241
9245
  return config.extendedScopes || config.scopes;
9242
9246
  }
9243
- if (request.query.limited) {
9247
+ if (request.query.limited === "true") {
9244
9248
  return config.limitedScopes || this.serializerService.config.globalLimitedScopes || config.scopes;
9245
9249
  }
9246
- if (request.query.secret) {
9250
+ if (request.query.secret === "true") {
9247
9251
  return config.secretScopes || this.serializerService.config.globalSecretScopes || config.scopes;
9248
9252
  }
9249
9253
  if (request.query.scopes && config.allowedScopes) {
@@ -9305,6 +9309,7 @@ export {
9305
9309
  SerializerIdInterceptor,
9306
9310
  SerializerInterceptor,
9307
9311
  SerializerModule,
9312
+ SerializerQuery,
9308
9313
  SerializerService
9309
9314
  };
9310
9315
  //# sourceMappingURL=index.mjs.map