strapi-community / strapi-plugin-transformer

A plugin for Strapi Headless CMS that provides the ability to transform the API request or response.
https://market.strapi.io/plugins/strapi-plugin-transformer
MIT License
140 stars 22 forks source link

Issue with plugin content types and admin routes #104

Closed kevinvugts closed 3 months ago

kevinvugts commented 3 months ago

Hi @ComfortablyCoding

There is an issue with this plugin. Individual plugins contentTypes cannot be transformed individually. The only thing that works is basically allowing them all by proving the "id" of the plugin in the plugins.ids object. However, it would be nice if we could allow individual contentTypes like you can with the contentTypeFilter "api::content-type-name.name"

I checked your code in the register.js and it seems to be because the way you are checking the UIDS from the strapi[apiType].

This config does seem to pass some checks

  "some-plugin": {
    enabled: true,
    resolve: "./src/plugins/some-plugin",
  },
  transformer: {
    enabled: true,
    config: {
      responseTransforms: {
        removeAttributesKey: true,
        removeDataKey: true,
      },
      contentTypeFilter: {
        mode: "allow",
        uids: {
          "some-plugin": true, // This line bypasses the checks in isAvailableApi and isAvailableMethod. However it does not allow for allowing individual content types from a plugin..
          "api::blog.blog": true,
        },
      },
      plugins: {
        mode: "allow",
        ids: {
          "some-plugin": true,
        },
      },
    },
  },
};

However, as you can see I have to remove the plugin:: prefix to make it pass those checks. Also, admin api routes are not transformed on purpose, this shouldn't be the case since these should also be able to be transformed.

Can you support this?

https://github.com/strapi-community/strapi-plugin-transformer/blob/3cb78550a28e91b6cfdfd1b349a832d94637271b/server/register.js#L70

kevinvugts commented 3 months ago

I opened up a pull request #105

ComfortablyCoding commented 3 months ago

As discussed I am unfortunately no longer maintaining this plugin nor do I have the permissions to merge any longer.

A maintainer would need to take this over and review as needed.

P.S. The PR is present for anyone who wishes to patch it for themselves in the meantime.

kevinvugts commented 3 months ago

As discussed I am unfortunately no longer maintaining this plugin nor do I have the permissions to merge any longer.

A maintainer would need to take this over and review as needed.

P.S. The PR is present for anyone who wishes to patch it for themselves in the meantime.

Thanks for your response. As discussed per Discord I am unable to maintain this library either. Anyhow, for anyone that wants this change. Please do!