GithubHelp home page GithubHelp logo

strapi-to-typescript's Introduction

Strapi-to-TypeScript

NPM version NPM download contributors

THIS PROJECT IS NOT MAINTAINED ANYMORE. Don't hesitate to fork it.

THIS PROJECT DOESN'T SUPPORT VERSION 4 OR LATER OF STRAPI. (see PR#49)

Convert the Strapi models to TypeScript interfaces by processing each of the ./api/**/models/*.settings.json recursively.

Install and Run

npm install -g strapi-to-typescript

sts path/to/strapi/api/ -o path/to/your/types/dir/

# see all doc
sts -h

# external conf. see: strapi-to-typescript/index.d.ts for format
sts -c .stsconfig.js

Command line option

sts input -g components -o output ...

required

  • input
    Strapi folder(s)/file(s) with models *.settings.json
    You may define multiple inputs. In case your API models have relations to other plugins like 'users-permissions'. sts path/to/strapi/api/ path/to/strapi/plugins/users-permissions/models -o path/to/your/types/dir/

    • Order matters, if you have two models with the same name, the last one is used.
    • Add '!' to exclude folder or subfolder, ex: !path/to/strapi/plugins_excluded.
  • -g components
    Strapi folder(s) with components models

optional

  • -o output
    Output folder
  • -n nested
    Put all interfaces in a nested tree instead of directly under the output folder
  • -u collectionCanBeUndefined
    By default, all collection can not be undefined. You can turn this off, so only unrequired collections may be undefined.
  • -e Enumeration
    You may generate enumeration or string literal Example:
// enumeration (with -e option) 
export interface IOrder {
    payment: IOrderPayment;
}
export enum IOrderPayment {
    card = "card",
    check = "check",
}
// OR string literal types (by default)
export interface IOrder {
    payment: "card" | "check";
}
  • -c Advanced configuration
    path to configuration file

Advanced configuration

.stsconfig

/**
 * @type {import('strapi-to-typescript')}
 */
const config = {

    //required 
    input: [
      'api',
      './node_modules/strapi-plugin-users-permissions/models/',
      './node_modules/strapi-plugin-upload/models/',
      './extensions/users-permissions/models/'
    ],
    components: './components/',
    output: './sts/',

    // optional
    enum: true,
    nested: false,
    excludeField: (interfaceName, fieldName) => fieldName === 'hide_field',
    addField: (interfaceName) => [{ name: "created_by", type: "string" }],

    // optional, builtin function used if undefined return
    fieldType: (fieldType, fieldName, interfaceName) => { if(fieldType == 'datetime') return 'string' },
    fieldName: (fieldName) => fieldName.replace('_', ''),
    interfaceName: (name) => `X${name}`,
    enumName: (name, interfaceName) => `Enum${interfaceName}${name}`,
    importAsType: (interfaceName) => interfaceName === 'MyInterfaceThatWantsToImportAsTypes' /* or just true */,
    outputFileName: (interfaceName, filename) => interfaceName;
}
module.exports = config;

package.json

{
  "//" : "...",

  "scripts": {
    "sts": "sts -c .stsconfig"
  },

  "///" : "..."
}

Issue

If you want to create an issue. First of all, be nice. Take the time to explain and format your post.

The better solution to explain your issue (and for me, to fix it) is to create a pull request with your data:

  1. fork this repo with the button "fork" on github website. wait a minute.
  2. git clone your master branch from the newly created repository.
  3. yarn install or npm install
  4. add your api in src/test/api src/test/components (if necessary)
  5. add your test:
  6. src/test/test<issue id>.config.js copy an other test and modify output conf
  7. src/test/test<issue id>.assert.ts copy another assert and modify the import accordingly to your conf output
  8. run your test with ./node_modules/.bin/ts-node src/test.ts test<issue id> or run all test yarn test
  9. create pull request on this repo

Explanation

The input folder is recursively processed and each model file is read. When done, the expected output folder is generated, and finally, the Strapi models are converted to TypeScript.

Build

npm install && npm run build
# output files generated in dist folder

strapi-to-typescript's People

Contributors

7frank avatar aperron avatar blefevre avatar chris-schra avatar clorichel avatar erikvullings avatar iamgoddog avatar jeremiferre avatar s-com-orths avatar scmx avatar sirtimbly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

strapi-to-typescript's Issues

components containing a "-" not replaced

Hello !
During the transformation from the component JSON to the interface, problematic char are not replaced.

// e-shop.json
{
  "collectionName": ",components_content_e_shops",
  "info": {
    "name": "e-shop",
    // ...
  }
 // ...
}
// e-shop.ts

export interface IE-shop {
  id: string;
  title?: string;
 // ...
}

I don't quite understood if the function in the .stsconfig could help, but i don't think so

For a quick fix you could force the interface you create to be always snake_case and later maybe enforce the coding style via a argument/property.

// .stsconfig
module.exports = {
  input: [
    './api',
    './node_modules/strapi-plugin-users-permissions',
    './node_modules/strapi-plugin-upload',
    './node_modules/strapi-plugin-i18n',
  ],
  components: './Strapi/components',
  output: './sts/',
  enum: true,
  nested: false,
  fieldType: (fieldType, fieldName) => {
    if (fieldName === 'id') return number;
    if (fieldType === 'datetime' || fieldType === 'date') return string;
  }
}

TypeError: Cannot read property 'name' of undefined

command: sts ./api

TypeError: Cannot read property 'name' of undefined
    at /home/sundowndev/.nvm/versions/node/v12.18.3/lib/node_modules/strapi-to-typescript/dist/importer.js:116:61
    at Array.map (<anonymous>)
    at /home/sundowndev/.nvm/versions/node/v12.18.3/lib/node_modules/strapi-to-typescript/dist/importer.js:116:45
    at Array.forEach (<anonymous>)
    at /home/sundowndev/.nvm/versions/node/v12.18.3/lib/node_modules/strapi-to-typescript/dist/importer.js:110:11
    at new Promise (<anonymous>)
    at Object.importFiles (/home/sundowndev/.nvm/versions/node/v12.18.3/lib/node_modules/strapi-to-typescript/dist/importer.js:108:58)
    at /home/sundowndev/.nvm/versions/node/v12.18.3/lib/node_modules/strapi-to-typescript/dist/processor.js:20:45
    at Generator.next (<anonymous>)
    at fulfilled (/home/sundowndev/.nvm/versions/node/v12.18.3/lib/node_modules/strapi-to-typescript/dist/processor.js:5:58)

content of api folder :

api         config      favicon.ico     migrations    public     tests           yarn.lock
build       Dockerfile  jest.config.js  node_modules  README.md  types
components  extensions  knexfile.js     package.json  seeds   
  • node v12.18.3
  • strapi v3.5.4

Generating non-model types?

How would I go about generating stuff like

    type UsersPermissionsLoginPayload {
      jwt: String
      user: UsersPermissionsMe!
    }

    type UserPermissionsPasswordPayload {
      ok: Boolean!
    }

⬆️ This is a snippet from node_modules/strapi-plugin-users-permissions/config/schema.graphql.js... In case you're wondering what the entire file looks like, click here!

I can't find a .settings.json file containing those types anywhere. I even performed a search for the word jwt throughout the entire strapi directory and this is the only mention of it (Translation files aside)

I need this to handle authentication response data

Question: __typename and how handle it with Typescript

Hello,

I'm working on migrate my portfolio from JS to TS and i got the next problem:
I have a model with a dynamic zone as follows:

export interface IPage {
  id: string;
  title?: string;
  slug: string;
  thumbnail?: IFile;
  body: (
    | ({ __component: "content.rich-text" } & IRichText)
    | ({ __component: "content.experience" } & IExperience)
    | ({ __component: "content.personal-information" } & IPersonalInformation)
    | ({ __component: "fields.skill" } & ISkill)
  )[]; // IComponent[]
  tags?: ITag[];
  description?: string;
}

I have a component how renderizes this body:

export const Body = ({ body }) => {
  return body.map((component) => (
    <DynamicZone key={`component${component.id}`} component={component} />
  ));
};

And the dynamic zone component is:

export const DynamicZone = ({ component, className }) => {
  const classes = useStyles();
  const { i18n } = useTranslation();

  return (
    <Typography
      variant="body1"
      component="section"
      className={clsx(classes.root, className)}
    >
      {
        {
          ComponentContentContent: (
            <Content>
                component
            </Content>
          ),
          ComponentFieldsSkill: <Skill {...component} />,
        }[component.__typename]
      }
    </Typography>
  );
};

It is like that since the normal GraphQL json response comes like:

"body": [
        {
          "__typename": "ComponentContentPersonalInformation",
          "id": "2",
          "name": "José Luis Sandoval Alaguna",
          "photo": {
            "alternativeText": "Profile photo.",
            "caption": "José Luis Sandoval Alaguna",
            "url": "https://res.cloudinary.com/dqhx2k8cf/image/upload/v1608399687/fotodeperfil_029e62c5d9.jpg",
            "width": 970,
            "height": 1296
          },
          "position": "Front-End Developer at CloudNesil",
          "nationality": "Colombian",
          "address": {
            "address": "6438 Sokak. Yunusemre Mah. No: 5 Daire: 1, Pamukkale",
            "city": "Denizli",
            "country": "Turkey",
            "postalCode": null
          },
          "telephone": [
            {
              "id": "1",
              "type": "Mobile",
              "number": 5373749236
            }
          ],
          "mail": "[email protected]",
          "links": [
            {
              "id": "1",
              "type": "LinkedIn",
              "url": "www.linkedin.com/in/jluissalaguna/"
            },
            {
              "id": "2",
              "type": "Github",
              "url": "www.github.com/SalahAdDin"
            },
            {
              "id": "3",
              "type": "StackOverflow",
              "url": "stackoverflow.com/users/3826549/salahaddin"
            }
          ],
          "aboutMe": null
        },
        {
          "__typename": "ComponentFieldsSkill",
          "type": "Language",
          "id": "6",
          "name": "Español (Native)",
          "level": 5
        },

Hance, following the format and the generated TypeScript model, how can must i handle this?

Why does this package not export the __typescript field?

Thanks

Strapi components doesn't work for me

Hi! I see errors like this:

type 'page' unknown on IHomepage[page] => fallback to 'any'. Add in the input arguments the folder that contains *.settings.json with info.name === 'page'

My config file is:

input: [
    "api",
    "./node_modules/strapi-plugin-upload/models/",
    "./extensions/users-permissions/models/",
  ],
  inputGroup: "./components",
  output: "../next/typings/",

My homepage.settings.json is:

{
  "kind": "singleType",
  "collectionName": "homepages",
  "info": {
    "name": "Homepage",
    "description": ""
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": true
  },
  "attributes": {
    "title": {
      "type": "string"
    },
    "description": {
      "type": "text"
    },
    "page": {
      "type": "component",
      "repeatable": false,
      "component": "meta.page"
    }
  }
}

My components folder is like:

/components
-- common/
---- page.json
---- meta-tag.json
---- open-graph.json
-- meta/

My page.json is like:

{
  "collectionName": "components_meta_pages",
  "info": {
    "name": "page",
    "icon": "file-powerpoint"
  },
  "options": {},
  "attributes": {
    "seo": {
      "type": "component",
      "repeatable": false,
      "component": "meta.seo"
    },
    "metaTags": {
      "type": "component",
      "repeatable": true,
      "component": "meta.meta-tag"
    },
    "openGraph": {
      "type": "component",
      "component": "meta.open-graph"
    }
  }
}

I checked this and this issues, didn't help.

I also checked source code, but wasn't able to figure out the solution.

Fails with changed collection names

When collection name is changed, fails to match collection in other objects. Errors like
type 'mytype' unknown on somefield[mytype2] => fallback to 'any'. Add in the input arguments the folder that contains *.settings.json with info.name === 'mytype'
Plus fails to remove other symbols than spaces from collection names when generating interface names - that luckily can be fixed by providing a custom name generation function in interface (used plenty of dashes)

2.0.7 completely broken on Windows

Generates imports with wrong slash, like
import { User } from '.\user';
This was working right till 2.0.6. Also, on linux issue is not present.

Underscore issue

Underscores inside relation fields are missing

I have a members collection:

// members
{
  "kind": "collectionType",
  "collectionName": "members",
  "attributes": {
    "users_permissions_user": {
      "plugin": "users-permissions",
      "model": "user",
      "via": "member"
    },
    "title": {
      "type": "string"
    },
    "supervised_projects": {
      "via": "supervisor",
      "collection": "projects"
    },

Which generates the following types:

export interface IMembers {
  id: string;
  userspermissions_user?: IUser;
  title?: string;
  supervisedprojects: IProjects[];
}

The noticeable part here is that only the first underscore is missing.

Strapi v4 support?

Does this tool already support v4? I've been trying to use it in my project but only an empty sts/index.ts was generated. A quick peek into the source looked like it does not search for the schema.json.

I've run the sts as a script from package.json as follows:

"scripts": {
  "srs": "sts ./src -o ./sts"
}

Empty type in interface if `type` is missing from *.settings.json

Hello!

I noticed an error in the output of the interface on two of my models. The model I have is called Aboutme and this is the aboutme.settings.json

{
  "kind": "singleType",
  "collectionName": "aboutmes",
  "info": {
    "name": "Aboutme",
    "description": ""
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": true
  },
  "attributes": {
    "text": {
      "type": "richtext"
    },
    "avatar": {
      "model": "file",
      "via": "related",
      "allowedTypes": [
        "images"
      ],
      "plugin": "upload",
      "required": false
    }
  }
}

The produced output is

export interface IAboutme {
  id: string;
  text?: string;
  avatar?: ;
}

If you look at the avatar field it is missing the type. For this example, avatar is an image field (single image).

I noticed it also happens for files(single file), for example, my Resume model

{
  "kind": "singleType",
  "collectionName": "resumes",
  "info": {
    "name": "Resume",
    "description": ""
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": true
  },
  "attributes": {
    "pdf": {
      "model": "file",
      "via": "related",
      "allowedTypes": [
        "files"
      ],
      "plugin": "upload",
      "required": false
    },
    "date": {
      "type": "date"
    }
  }
}

Output

export interface IResume {
  id: string;
  pdf?: ;
  date?: Date;
}

Hopefully this makes sense or is useful!

Dynamic zone, Date types bug

First of all, I would like to say a big thank you for the quick solutions of my previous issues.

I notices couple of errors regarding the current types generation.

Dynamic zone

Strapi generates it always as an array of component-types. But the current implementation differs:

dynamicZone?: (IComponentA|IComponentB);

Which produces conflicts , and the real type should be like:

dynamicZone: (
    | IComponentA
    | IComponentB
  )[];

// or
dynamicZone: Array<IComponentA|IComponentB>

Date type

The plugin generates it as a Date type, but in real it's just a string.

JSON type

It's not a bug, but it's a suggestion to improve.
Right now json is typed as

{ [key: string]: any }

but the better solution is:

type JsonPrimitive = string | number | boolean | null
interface JsonMap extends Record<string, JsonPrimitive | JsonArray | JsonMap> {}
interface JsonArray extends Array<JsonPrimitive | JsonArray | JsonMap> {}
type Json = JsonPrimitive | JsonMap | JsonArray

Add support for Strapi version 4

Creating a new issue since there's no way to reopen #47.

@chris-schra kindly provided a fix via #48 , however even with the fix strapi-to-typescript fails to generate types for Strapi 4.

Anything that used to go under api directory now lives under src/api and has a different folder structure, as such all strapi content types get ignored entirely and you get an empty index.ts file as a result.

Fails to link component types in generated interfaces

Hello,

That's a little miss to properly link component types from what was fixed in 2.0.6. API models have files ending with ".settings.json" but components with just ".json". A little fix gets around that (I may make a PR if you think it's worth it, but you could just incorporate that change).
In ts-exporter.ts

    this.strapiModels = strapiModelsParse.map(m => {
      return {
        ...m,
        snakeName: m.info.name
          .split(/(?=[A-Z])/)
          .join('-')
          .replace(/[\/\- ]+/g, "-")
          .toLowerCase(),
        interfaceName: util.toInterfaceName(m.info.name, m._filename),
        modelName: path.basename(m._filename, '.settings.json')
      }
    });

change the modelName to

modelName: m._filename.endsWith('.settings.json') ? path.basename(m._filename, '.settings.json') : path.basename(m._filename, '.json')

Content type with relation to itself tries to import itself causing an error

I have a content type Treatment which has a relation to itself "parentTreatment" to create a hierarchy.

This results in the following being generated

import { ITreatment } from './treatment';

/**
 * Model definition for treatment
 */
export interface ITreatment {
  id: string;
  parentTreatment?: ITreatment;
}

This prevents the build due to ITreatment already being defined.

Compatibility with `strapi-supercharged`

Hello!
I recently published strapi-supercharged package, which contains ts declaration for 80/90% of the strapi core. The goal is to enable tsc to parse either strapi plugins or application, and allow user to extend strapi with interface merging.

I have not managed the entity generation, but it would be a huge improvement!
Are you interested to work together to make both of our projects work seemlessly ?

Failure when /components is empty

When .stsConfig.js file has configuration for /components folder like this one
components: './components/',
Code generation fails silently when there's nothing in components folder yet. This is inconvenient - as I'm preparing a working stub for new project structure, and can't simply turn on component generation ahead.

Already have model 'user' OR type 'role' unknown on IUser[role] => fallback to 'any'

From the example of config file we can get the following input folders:

"api",
"./node_modules/strapi-plugin-users-permissions/models/",
"./node_modules/strapi-plugin-upload/models/",
"./extensions/users-permissions/models/",

That works fine, but in the console we get a message:

Already have model 'user' => skip <root>\node_modules\strapi-plugin-users-permissions\models\User.settings.json use <root>\extensions\users-permissions\models\User.settings.json

Which is reasonable. But if we remove node_modules version, then we get this:

type 'role' unknown on IUser[role] => fallback to 'any'. Add in the input arguments the folder that contains *.settings.json with info.name === 'role'

So, there are two options, and both of them works not so good.

Possible fix

Add an ability to add *.settings.json files directly, without folder. Then we could've do the following:

"api",
"./node_modules/strapi-plugin-users-permissions/models/roles.settings.json",
"./node_modules/strapi-plugin-upload/models/",
"./extensions/users-permissions/models/",

type 'file' unknown

This issue is addressing a feature request.

  • generate media models.

Steps to reproduce:

  • add a media field to a component.

Context:

I created a media field (image only) on one of my components, but it seems that STS couldn't generate the resulting native file type given by Strapi models.

type 'file' unknown on IMenu_entry[icon] => fallback to 'any'. Add in the input arguments the folder that contains *.settings.json with info.name === 'file'

Here's my component icon field (media) inside components/menu-entry.json:

"icon": {
      "model": "file",
      "via": "related",
      "allowedTypes": [
        "images"
      ],
      "plugin": "upload",
      "required": true,
      "pluginOptions": {}
}

The file type should look something like this (judging by the api response):

"icon": {
        "id": 1,
        "name": "some-icon.svg",
        "alternativeText": "",
        "caption": "",
        "width": 512,
        "height": 512,
        "formats": null,
        "hash": "some_icon_3faea55b59",
        "ext": ".svg",
        "mime": "image/svg+xml",
        "size": 4.28,
        "url": "/uploads/some_icon_3faea55b59.svg",
        "previewUrl": null,
        "provider": "local",
        "provider_metadata": null,
        "created_at": "2021-06-09T13:10:26.000Z",
        "updated_at": "2021-06-09T13:10:26.000Z"
}

Did I miss a way to connect STS to strapi native models or is it just not supported yet or impossible to implement?

Also, I thank you for this amazing tool. I feel like STS could be part of the official Strapi organization as it's a must have for TypeScript frontend integrations!

Altering generated file name?

Is there a feature that supports the same kind of option for file name as field/interface name? I am not at liberty to change the names from strapi directly.

For clarity, I mean an option in stsconfig like fileName: (fileName) => `Changed${fileName}`;

Question - Constructing GraphQL queries

How would you go about generating the query?

Doing something like:

import { gql, useQuery } from "@apollo/client";

const GET_ARTICLES = gql`
    {
        articles {
            id
            published_at
            title
            content
            cover {
                url
            }
        }
    }
`;

// Somewhere else
const { loading, error, data } = useQuery(GET_ARTICLES);

would kind of defeat the whole point of generating interfaces for all the collections.

If I make a change to the collection, like deleting the content field. Then there would be hidden issues that I would only be able to discover during run-time.

Any suggestions? Am I missing something obvious? This is my first time using Strapi/GraphQL/Apollo

Can we exclude files/folders from the generation?

I can't see anything in the docs, but it seems like it might exist, so thought I'd ask.

I've tried:

const config = {
    //required
    input: [
      'api',
      '!api/folder-ii-want-to-ignore',
      // './node_modules/strapi-plugin-users-permissions/models/',
      // './node_modules/strapi-plugin-upload/models/',
      // './extensions/users-permissions/models/'
    ],
    ...
}

But this just looks for a folder with '!'.

I'm just curious, it's not big issue.

Fields of an interface referencing itself generates an invalid import statement

Steps to reproduce

The following settings file is taken from the strapi navigation plugin: navigationItem.settings.json (unnecessary information removed)

{
  "collectionName": "navigations_items",
  "info": {
    "name": "navigationItem",
    "description": ""
  },
  "attributes": {
    "parent": {
      "columnName": "parent",
      "model": "navigationItem",
      "plugin": "navigation",
      "configurable": false,
      "default": null
    },
  }
}

This produces a file "navigationitem.ts" with the following contents:

import { INavigationItem } from './navigationitem';

/**
 * Model definition for navigationItem
 */
export interface INavigationItem {
  parent?: INavigationItem;
}

The self-import should be omitted to solve the issue.

Possible fix

The problem seems to be the following case-sensitive comparison during the import processing:

if ((a.collection || a.model || a.component) === m.modelName) continue;

m.modelName was previously changed to lowercase ("navigationitem") and is now compared with the attribute's model property, which is "navigationItem".

It might be possible to always compare the model property with the info object's name property. This worked in my tests:

if ((a.collection || a.model || a.component) === m.info.name) continue;

Kind regards,
mat

Strapi models

Hi Folks,

First of all, thanks sooo much for this!!
You're doing great work.

I'm not sure if this is the right method to communicate/ask for a feature, but here goes:
I see that strapi models like user, file, role and I have some questions about them:

  1. Some of the fields are required, but perhaps they shouldn't be, for example permissions and users below.
  2. Is there a config to capitalize them?
    I'm currently managing to capitalize interface names with interfaceName: (name) => '${name}', but this did nothing for the strapi stuff I mentioned.

my role.ts:

import { permission } from './permission';
import { user } from './user';

/**
 * Model definition for role
 */
export interface role {  // as opposed to Role
  id: string;
  name: string;
  description?: string;
  type?: string;
  permissions: permission[];
  users: user[];
}

For context,
I'm writing a script to upload seed data to strapi, and some things like uploading a user that has a role, but a role has an array of user[], which makes it cyclical and tough to manage. In fact, if the user[] attribute was optional (which it is in terms of strapi's API - it only requires the id), then it would be significantly easier to do this task.

Thanks!

"id" field type on relational vs mongo

By default "id" field is generated as string type, which matches Mongo id type (mostly, as there's more issues with type of mongo id). However Mongo is planned to be dropped in version 4, and as I just found out, "id" field type on Postgres (and pretty surely all relational) is number. Which causes issues, I got around them by adding this to config

    type: (fieldType, fieldName, interfaceName) => { if(fieldName == 'id') return 'number' }, 

But I think it would be nicer if this is default behavior, and/or have a separate option for controlling type of "id" field.

component with the same name not created

I have two components who do have the same name but not in the same category.
Unfortunately, none of them are created, thus replaced by "any" inside my dynamiczone interface.

Is it possible to tackle this with one of the functions available in the stsconfig or is that currently impossible?

// .stsconfig
module.exports = {
  input: [
    './api',
    './node_modules/strapi-plugin-users-permissions',
    './node_modules/strapi-plugin-upload',
    './node_modules/strapi-plugin-i18n',
  ],
  components: './Strapi/components',
  output: './sts/',
  enum: true,
  nested: false,
  fieldType: (fieldType, fieldName) => {
    if (fieldName === 'id') return number;
    if (fieldType === 'datetime' || fieldType === 'date') return string;
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.