@cardstack/core-types

The default blueprint for ember-cli addons.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
2496Jun 15, 2021Jan 15, 2017Minified + gzip package size for @cardstack/core-types in KB

Readme

@cardstack/core-types

The core-types package describes the field types available to Cardstack models. Example usage is:

factory.addResource('fields', 'my-field').withAttributes({
  fieldType: '@cardstack/core-types::<field-type>',
  ...
})

where <field-type> is one of:

  • string (ex. "sandwich", "Dave")
  • string-array (ex. ["red", "green", "blue"])
  • case-insensitive case insensitive string, used for email addresses, among other things (ex. "ChRiS.tSe@GmaiL.com")
  • integer (ex. 37)
  • boolean (ex. true)
  • date (ex. "2018-07-22")
  • object (ex. { flower: 'rose' })
  • any any data type, useful for external data sources
  • belongs-to belongs to relationship to another content-type (ex. "author")
  • has-many has many relationship to another content-type (ex. "pets")

Field Editors

When using the Cardstack Tools for editing, it will use the appropriate field editor for that type. For example, if your fieldType is @cardstack/core-types::string, the field-editors/string-editor (which is essentially just a bound <input type="text">) will be used. The core-types package contains several built-in field editors (string, integer, date, etc), but you can specify your own custom field editor by specifying editorComponent. This is particularly useful for relationship field types, for which there may not be a "standard" UI:

factory.addResource('fields', 'author').withAttributes({
  fieldType: '@cardstack/core-types::belongs-to',
  editorComponent: 'field-editors/author-picker'
})

Additionally, you can pass options to field editors using editorOptions:

factory.addResource('fields', 'is-admin-user').withAttributes({
  fieldType: '@cardstack/core-types::boolean',
  editorOptions: { style: 'switch' }
})

Installation

  • git clone <repository-url> this repository
  • cd @cardstack/core-types
  • npm install
  • bower install

Running

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit https://ember-cli.com/.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.