Socket
Socket
Sign inDemoInstall

@craftercms/models

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@craftercms/models

Crafter CMS data model definitions


Version published
Weekly downloads
169
decreased by-12.44%
Maintainers
3
Weekly downloads
 
Created
Source

@craftercms/models

This package contains data model definitions of different structures of Crafter CMS. This interfaces are useful when developing in typescript.

Usage

  • Install module using yarn or npm
    • Yarn: yarn add @craftercms/models
    • npm: npm install @craftercms/models
  • Import and use the models you need

Models


- CrafterConfig

Crafter configuration model for modules to work

Example

  • Default values:
  {
    site: "editorial",
    searchId: "editorial",
    baseUrl: "http://localhost:8080"
  }
  • Defining an object of type CrafterConfig:
  import { CrafterConfig } from "@craftercms/models";

  const config: CrafterConfig = {
    site: "editorial",
    searchId: 'editorial'   // if searchId is the same as site, this parameters is not needed
    baseUrl: "http://localhost:8090"
  };

- Item

Crafter item model with its base properties

Example

  • Defining an object of type Item:
  import { Item } from "@craftercms/models";

  const item: Item = {
    name: "index.xml",
    url: "/site/website/index.xml",
    descriptorUrl: "/site/website/index.xml",
    descriptorDom: { ... },
    folder: false
  };

- Descriptor

Crafter descriptor model with its base properties

Example

  • Defining an object of type Descriptor:
  import { Descriptor } from "@craftercms/models";

  const item: Descriptor = {
    page: { ... }
  };

- NavigationItem

Crafter navigation item model with its base properties

Example

  • Defining an object of type NavigationItem:
  import { NavigationItem } from "@craftercms/models";

  const item: NavigationItem = {
    url: "/site/website",
    active: boolean,
    subItems: [
      {
        //Each Item is a NavigationItem
      }
    ]
  };

- StateContainer

Describes the container of a redux state, with entries and optional childIds.

Example

  • Defining an object of type StateContainer:
  import { StateContainer } from "@craftercms/models";

  const item: StateContainer = {
    entries: { /* type = LookupTable */ },
    loading: { /* type = LookupTable */ }
    childIds: { /* type = LookupTable */ }
  };

Every property value in a state container is a LookupTable

- CrafterState

Describes the crafter state, each entry is as StateContainer

Example

  • Defining an object of type CrafterState:
  import { CrafterState } from "@craftercms/models";

  const item: CrafterState = {
    items: { /* type = StateContainer */ }
  };

- CrafterNamespacedState

Describes a namespaced state, with a CrafterState under the namespace

Example

  • Defining an object of type CrafterNamespacedState:
  import { CrafterNamespacedState } from "@craftercms/models";

  const item: CrafterNamespacedState = {
    craftercms: { /* type = CrafterState */ }
  };

- LookupTable

Describes an object consisting on keys (item id property) and values (content itself)

Example

  • Defining an object of type LookupTable:
  import { LookupTable } from "@craftercms/models";

  const item: LookupTable = {
    /site/website/index.xml: {
      name: "index.xml",
      url: "/site/website/index.xml",
      descriptorUrl: "/site/website/index.xml",
      descriptorDom: { ... },
      folder: false
    }
  };

Utils


createLookupTable

Creates a lookup table based on an array of items (of a type) and the items id identifier.

Example

  • Create a lookupTable of type Item:
  import { createLookupTable } from "@craftercms/models";
  import { Item } from "@craftercms/models";

  // item (type Item) - Defined on previous example
  const channelsTable = createLookupTable<Item>([item], 'url');

The lookupTable will look like this:

  {
    /site/website/index.xml: {
      name: "index.xml",
      url: "/site/website/index.xml",
      descriptorUrl: "/site/website/index.xml",
      descriptorDom: { ... },
      folder: false
    }
  }

Keywords

FAQs

Package last updated on 29 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc