Giter VIP home page Giter VIP logo

contentstack-cli-tsgen's People

Contributors

abhinav-from-contentstack avatar aman19k avatar antonyagustine avatar aravindbuilt avatar cs-raj avatar daanstolp avatar dependabot[bot] avatar johncarmack1984 avatar michaeled avatar netrajpatel avatar shafeeqd959 avatar tohaker avatar vkalta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

contentstack-cli-tsgen's Issues

Wrong types for references

CS always sends references as an array of entries. It means that all references must be like arrays, and empty arrays in case if reference is not specified. Even if this field is not mandatory, it will be an empty array.

{
  someEntryReference: EntryModel[]
}

But for some reason TSGen gives you:

{
  someEntryReference?: EntryModel
}

Looks like a bug or not documented behavior.

SyntaxError: Declaration or statement expected

Hi, I just tried to use the package, but it failed with the following output:

% csdx tsgen -a "test" -o "test.d.ts"

    SyntaxError: Declaration or statement expected. (3111:1)
      3109 | }
      3110 |
    > 3111 | export interface 1Feature
           | ^
      3112 | {
      3113 | /** Version */
      3114 | version:  4 ;

I'm using CLI v1.9.1 with tsgen v2.1.7 - all freshly installed today.

The credentials do work, by the way. Before I got this error message, I used wrong credentials and received the respective credential error.

Type Error for empty Date and Select Fields

I have a content model with two non-mandatory fields of type Date and Select. The tsgen plugin exports this content model as follows:

export interface TestModel {
  title: string;
  date?: string;
  select?: "lorem" | "ipsum";
}

However, this is what is actually sent from the API with the two non-optional fields left empty (generic fields removed from output):

{
    "date": null,
    "select": null,
    "title": "Test TSGen",
}

This causes a TS error: Type 'null' is not assignable to type 'string | undefined'.

GraphQL dependency missing when using rest as API type

GraphQL dependency missing when using rest as API type

After the release of 2.3.0 it broke our codegen as grapql is missing even though we're not using GraphQL.

(node:25983) [MODULE_NOT_FOUND] ModuleLoadError Plugin: contentstack-cli-tsgen: [MODULE_NOT_FOUND] require failed to load /Users/user/.local/share/@contentstack/cli/node_modules/contentstack-cli-tsgen/lib/commands/tsgen.js: Cannot find module 'graphql'

Types for extensions/custom fields

Hello,

thank you for creating this fantastic package. We've recently begun using it, and it has significantly improved our contentstack typing.

One observation we've made is that every extension/custom field currently returns the type any. Is there a possibility to implement typing for these cases too? In most instances, we know the types returned by various extensions, at least in about 99% of the cases.

tsgen doesn't work

❯ csdx tsgen -a "delivery-token" -o "./contenstack/generated.d.ts"
Currently using NA region
SyntaxError: '=>' expected. (38:16)
36 | title: string;
37 | /** Image Block /
> 38 | image_block: ()[];
| ^
39 | /
* Banner Title /
40 | banner_title?: string;
41 | /
* Banner Description */

This is the output of my tsgen. It stop working on image_block because of this non-speaking error.

Single reference is generated as "multiple" (array)

A referenced field that is not set as "multiple" has the type generated as an array.

Example from the demo data (from the starters): a header object has a reference to a page - page_reference. It looks like this

  {
      "data_type": "reference",
      "display_name": "Page Reference",
      "reference_to": [
          "page"
      ],
      "field_metadata": {
          "ref_multiple": false,
          "ref_multiple_content_types": true,
          "description": "Refers a linked entity of type page",
          "instruction": "Refers a linked entity of type page"
      },
      "uid": "page_reference",
      "non_localizable": false,
      "mandatory": false,
      "multiple": false,  
      "unique": false
  }

However, the generated type looks like this:

    navigation_menu?: [
        {
            /** Label */
            label?: string;
            /** Page Reference */
            page_reference?: Page[]; // <--- should not be an array unless "multiple" is set to "true"
        },
    ]

I tried changing it to multiple and back to single, but nothing changes with regards to the generated type.

Version:

❯ csdx plugins
contentstack-cli-tsgen 2.1.6

Syntax error when generating types

Hi!

I'm trying to generate types for the Stack, but when I run the tsgen it returns the following Syntax error:
SyntaxError: '=>' expected.

reference: ()[];
| ^

Let me know if you need more information!

tsgen cannot read added tokens

Cannot run tsgen, when trying to generate the typing file I get the following error:

$ csdx tsgen -a "Token" -o "contentstack/generated.d.ts"
  TypeError: Cannot read properties of undefined (reading 'token-alias')

Tried with both Delivery and Management tokens
Was working a few weeks back but I got a new machine and started getting this error, not sure if it was a new update in the meantime.

@contentstack/cli/1.3.0 win32-x64 node-v16.14.1
NPM 9.1.1
contentstack-cli-tsgen 1.0.13

Thanks in advance

csdx tsgen generation reports error

WARNING! Obsolete function called. Function 'Contentstack.Stack(api_key, delivery_token, environment)' has been deprecated, please use 'Contentstack.Stack({api_key, delivery_token, environment, region, branch, fetchOptions})' function instead!

Generated typings do not name refrences correctly

Content stack appends Connection after all field names that are references, and also adds subfields in GraphQL.

example:

Content type field:

Reference to ContentBelt type

GraphQL request response:

"content_beltsConnection": { "edges": [ { "node": { "title": "Collapsibles test", "system": { "uid": "blt847f4e37080902a8" } } },] }

however the tsgen result of that is just the field name, with an array of the content type:

navigation_menu: ContentBelt[]

Added "version" to global fields

In the last version of contentstack-cli-tsgen
The file __generated__.types.ts includes the field version on the global fields interfaces

why you added version to global fields? is this intended?

I've resolved that when I've installed a previous version
csdx plugins:install [email protected]

Error: Token not found

I am unable to run csdx tsgen. I am getting an Error: "Token not found" although I included a created token alias. Could you help me with this, please?

Command that I am running with the error

➜  ~ csdx tsgen -a "my-token" -o "generated.d.ts"          

 Currently using NA region 

    Error: Token not found

Token creation

I created my-token-alias with

csdx auth:tokens

So running csdx auth:tokens I can see

Alias            Token             Apikey              Environment  Type       
 ───────────────────────────────────────────────────────────────────────────────────────
 my-token    <mytoken>  <my API key>   production     delivery 

Thanks in advance!

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.