@iamnnort/nestjs-serializer 2.2.2 → 2.2.4

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) => {
@@ -8999,7 +9000,8 @@ var SerializeField = /* @__PURE__ */ __name((configs) => {
8999
9000
  scopes: config.scopes,
9000
9001
  target: target.constructor,
9001
9002
  name,
9002
- fieldName: config.fieldName
9003
+ fieldName: config.fieldName,
9004
+ fieldTransform: config.fieldTransform
9003
9005
  });
9004
9006
  });
9005
9007
  };
@@ -9018,6 +9020,10 @@ var SerializeRelation = /* @__PURE__ */ __name((configs) => {
9018
9020
  });
9019
9021
  };
9020
9022
  }, "SerializeRelation");
9023
+ var SerializerQuery = createParamDecorator((data, ctx) => {
9024
+ const request = ctx.switchToHttp().getRequest();
9025
+ return request.scopes;
9026
+ });
9021
9027
 
9022
9028
  // src/interceptor.ts
9023
9029
  var import_operators = __toESM(require_operators());
@@ -9222,28 +9228,27 @@ var SerializerInterceptor = /* @__PURE__ */ __name((config) => {
9222
9228
  }
9223
9229
  intercept(ctx, next) {
9224
9230
  const request = ctx.switchToHttp().getRequest();
9225
- const scopes = this.getScopes(ctx);
9226
- request.query.scopes = scopes;
9231
+ request.scopes = this.getScopes(ctx);
9227
9232
  return next.handle().pipe((0, import_operators.map)(async (responsePromise) => {
9228
9233
  const response = await responsePromise;
9229
- if (!scopes && !config.fields) {
9234
+ if (!request.scopes && !config.fields) {
9230
9235
  return response;
9231
9236
  }
9232
9237
  return this.serializerService.transform(response, {
9233
- scopes,
9238
+ scopes: request.scopes,
9234
9239
  fields: config.fields
9235
9240
  });
9236
9241
  }));
9237
9242
  }
9238
9243
  getScopes(ctx) {
9239
9244
  const request = ctx.switchToHttp().getRequest();
9240
- if (request.query.extended) {
9245
+ if (request.query.extended === "true") {
9241
9246
  return config.extendedScopes || config.scopes;
9242
9247
  }
9243
- if (request.query.limited) {
9248
+ if (request.query.limited === "true") {
9244
9249
  return config.limitedScopes || this.serializerService.config.globalLimitedScopes || config.scopes;
9245
9250
  }
9246
- if (request.query.secret) {
9251
+ if (request.query.secret === "true") {
9247
9252
  return config.secretScopes || this.serializerService.config.globalSecretScopes || config.scopes;
9248
9253
  }
9249
9254
  if (request.query.scopes && config.allowedScopes) {
@@ -9305,6 +9310,7 @@ export {
9305
9310
  SerializerIdInterceptor,
9306
9311
  SerializerInterceptor,
9307
9312
  SerializerModule,
9313
+ SerializerQuery,
9308
9314
  SerializerService
9309
9315
  };
9310
9316
  //# sourceMappingURL=index.mjs.map