Giter Site home page Giter Site logo

lotas / contentful-graph Goto Github PK

View Code? Open in Web Editor NEW
59.0 4.0 7.0 566 KB

Visual representation of contentful content models in form of graphs

Home Page: https://www.contentful.com/blog/2017/08/08/how-to-quickly-visualize-your-content-model/

License: MIT License

JavaScript 99.35% Shell 0.65%
nodejs graph graphviz contentful svg pdf png graphviz-dot

contentful-graph's Issues

General issues

Hi there,

Jakub from Contentful here. Thank you for contributing to our open source ecosystem. There are some issues with https://github.com/lotas/contentful-graph/blob/master/src/get-relations.js. Allow me to list them to help you with making your project better:

  1. You check only for field.items.validations. It works only with multiple references fields (array of links). For singular links you'd have to check field.validations.
  2. There is a problem with field.validations: they are not available in CDA (contentful npm module). You'd have to use CMA (contentful-management npm module) response for the /content_types endpoint call.
  3. You always map over linkContentType validation (validation.linkContentType.map). It can fail for some other validations (e.g. array size validation) where linkContentType is undefined.
  4. The other thing is that linkContentType can be either an array or a string. If it's a string, it's an ID of a singular linked content type.

Please let me know if there's something I could help with.

J.

What do the different colors mean?

Thanks for this great tool.

I am new to contentful and I am not sure what the colors mean in the graph generated by contentful-graph.

What do the red, green, and yellow edges represent?

Thanks

throws TypeError if multiple reference field contains validation for non-existent content type

Consider the example of a content type which has a multiple reference field and that field has a validation to only accept entries of certain content types with the ids: series, season, video. The model has since changed and series has been deleted and replaced with show. The validation on that multiple reference field is now invalid.

When I use this tool in the above mentioned situation I get

(node:31538) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'name' of undefined
(node:31538) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I think this tool could deal with that invalid reference by either labeling it as invalid (with the benefit of alerting the user to this error) or by excluding it quietly.

Happy to provide a PR with a fix.

Use content type id's as dot node id's and escape labels

Hey there,

great tool, we love it here at Contentful and use it a lot internally :)

I discovered a few problems with more complex data models, just want to list them here, hoping to find time to file a pull request on my own.

The actual problem:

When having complex content type names with special chars like Layout > Image, the id of the dot-node or the label might be invalid:

digraph obj {
  "Layout > Image" [label="{Layout > Image ... }"];
  "Layout > Text" [label="{Layout > Text ... }"];

  "Layout > Image" -> "Layout > Text"
}

(This actually works but in more complex tests, this broke the graphviz rendering)

I'd love to see output like this, it might also be more readable:

digraph obj {
  layout_image [label="{Layout \> Image ... }"];
  layout_text [label="{Layout \> Text ... }"];

  layout_image -> layout_text
}
  1. Instead of content type name I took the content type id as dot node id
  2. I escaped the label text to avoid problems with special chars.

Thanks a lot,
Benedikt

RichText link does not reflect all configurations #19

The fix introduced in PR #21 for issue #19 does not reflect all possible states.

Missing / not working:

  • If there are no restrictions, it just fails / breaks
  • If there are no links / assets to entries allowed by disabling linking to any asset / entry, it will assume that everything is allowed

No 'latest' release

Due to this issue I cannot install pachage like @latest

npm ERR! 404  'contentul-graph@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

I'm getting status 403

I'm trying to get my schema as usually do. But without updating anything I'm getting a bad token result, it stopped working today

  var error = new Error();
              ^

AccessTokenInvalid: {
  "status": 403,
  "statusText": "Forbidden",
  "message": "The access token you sent could not be found or is invalid.",
  "details": {},
  "request": {
    "url": "/spaces/jq8d65xjulgq",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "Content-Type": "application/vnd.contentful.management.v1+json",
      "X-Contentful-User-Agent": "sdk contentful-management.js/7.54.2; platform node.js/v16.0.0; os macOS/v16.0.0;",
      "Authorization": "Bearer ...BaWpw",
      "user-agent": "node.js/v16.0.0",
      "Accept-Encoding": "gzip"
    },
    "method": "get"
  },
  "requestId": "d95706be-c9b6-4cdb-9fc9-d7c1f6c91b11"
}

I have my env variables already set up

Could you help me w this?

space.getEnvironment is not a function error

Hey lotas,

I'm having a Contentful user running into the attached error after following the instructions on the plugin page
space.GetEnvironment is not a function.

Thank you!

Update: Was able to resolve

Doesn't map out all relations

Not sure how I should capture a good repro for this, but I noticed that many but not all relations are mapped out by this utility. Some of our content types just end up without relationships with any other content-types (but they for sure have relationships with other types).

How do you suggest we proceed?

How can I give a better repro without sharing the entire data for the contentful space?

Update dependencies to "latest" version

Almost all dependencies are outdated.

I would also upgrade to the supported version of Node.JS.

Supported minimal version of node would be 10.*
Supported minimal version of npm would be 6.14.*

Output is missing edges for richtext embedded entries

The graph is really useful, thank you very much for this!

We noticed that embedded entry references within richtext fields aren't picked up yet and hence don't become edges in the graph.

By the way, is this repo still active? Would you also accept PRs?

Make it an npm module

Heyo. ๐Ÿ‘‹

I'm really digging this module. Do you have plans to make it a proper npm module?

Hyphens and spaces in element names lead to syntax error with dot

I'm getting this error message
Error: <stdin>: syntax error in line 31 near '-'
when running
CONTENTFUL_SPACE_ID=OMITTED CONTENTFUL_MANAGEMENT_TOKEN=OMITTED node_modules/contentful-graph/import.js | dot -Tpdf > model.pdf

import.js seems to run without issues, line #31 in the output looks like this:
UICOPYView:strings -> UI-COPY-String [dir=forward,label="0..*"];

So I'm wondering is the - character in the element name UI-COPY-String causing these issues? Should it be somehow escaped for dot to read correctly?

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.