NPM module - Izara Core - Attribute Tree
Jump to navigation
Jump to search
Overview
Shared code for attribute trees such as Product Attributes or Sell Offer Terms
Repository
https://bitbucket.org/izara-core-libraries/izara-core-library-attribute-tree/src/master/
DataSchemaLib
Sets up standard schema for attribute tree system
Nodes
{
nodeLabel: "{attributeTag}Label",
schema: {
identifier: true,
restrictProperties: true,
restrictRelationships: true,
properties: {
labelId: {
identifier: true, // create unique id from request details
},
},
}
}
- groups product attributes, eg: "colour", "size", etc..
{
nodeLabel: "{attributeTag}",
schema: {
identifier: true,
restrictProperties: true,
restrictRelationships: true,
properties: {
{attributeTag}Id: {
identifier: true, // create unique id from request details
},
labelId: { // what attribute label this attribute belongs to
immutable: true,
},
},
}
}
- one attribute's value inside one label, eg: "green" under the "colour" label
{
nodeLabel: "{attributeTag}Link",
schema: {
identifier: true,
restrictProperties: true,
restrictRelationships: true,
properties: {
{attributeTag}LinkId: { // create unique id from request details
identifier: true,
},
{attributeTag}Id: { // which attribute this link points to
immutable: true,
},
topLevelParentIdentifierProperties: { // eg: product's product id
immutable: true,
},
parentNodeIdentifierLabel: { // eg "product" or "productAttribute" (if is a child of another attribute link
immutable: true,
},
parentNodeIdentifierProperties: { // eg productid id is topLevel, or productAttributeLinkId if is a child/sub-attribute
immutable: true,
},
},
}
}
- creates the attribute tree links
- if is top level attribute connected to eg Product, then topLevelParentId and identifierProperties will match
- if is a sub-attribute below another attribute (eg "shade" under "colour"), then identifierProperties will equal parent's attributeLinkId
{
nodeLabel: "{attributeTag}PropertyLabel",
}
{
nodeLabel: "{attributeTag}Property",
}
- see DataSchemaLib
Relationships
{
relationshipType: "has_{attributeTag}Link",
schema: {
elementCanBeRemoved: true,
allPropertiesImmutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
{
relationshipType: "disabled_{attributeTag}Link",
schema: {
elementCanBeRemoved: true,
allPropertiesImmutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
- creates a link in attribute tree between a parent node or attribute link, and a child attribute link
{
relationshipType: "is_{attributeTag}",
schema: {
elementCanBeRemoved: false,
allPropertiesImmutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
- connects one attribute link to one attribute
{
relationshipType: "is_{attributeTag}Label",
schema: {
elementCanBeRemoved: false,
allPropertiesImmutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
- links one attribute to one attribute label
{
relationshipType: "has_{attributeTag}Property",
}
{
relationshipType: "disabled_{attributeTag}Property",
}
{
relationshipType: "is_{attributeTag}PropertyLabel",
}
- see DataSchemaLib
BasicNodeSchemaLib
Creates the schema for basic nodes created by services in their initial setup
{
nodeLabel: "{attributeTag}Label",
schema: {
identifier: true,
restrictProperties: true,
restrictRelationships: true,
properties: {
labelId: {
identifier: true,
},
},
}
}
{
nodeLabel: "{attributeTag}",
schema: {
identifier: true,
restrictProperties: true,
restrictRelationships: true,
properties: {
{attributeTag}Id: {
identifier: true, //(random uuid)
},
},
}
}
{
nodeLabel: "{attributeTag}PropertyLabel",
}
{
nodeLabel: "{attributeTag}Property",
}