Skip to content

Latest commit

 

History

History
954 lines (556 loc) · 28.9 KB

File metadata and controls

954 lines (556 loc) · 28.9 KB

@onzag/itemize / Modules / base/Root/Module/ItemDefinition/Include / default

Class: default

base/Root/Module/ItemDefinition/Include.default

This class provides the utilities for the description of an item it's one of the most important classes that defines how an item is added based on an existant item defintion

An item is described mainly by its name and such name must be a valid import for the item definition that its parent holds, for example lets say we have an item definition for Car which has wheels in it

{ "name": "wheels", "enforcedProperties": { "mainAmount": 4 }, "predefinedProperties": { "spares": 1 }, "excludedIf": { "property": "hover-car", "comparator": "equals", "value": true }, "sinkIn": [ "material" ] },

An item might also be a group of items with a gate

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new default(rawJSON, parentModule, parentItemDefinition): default

The constructor for an Include

Parameters

Name Type Description
rawJSON IIncludeRawJSONDataType the raw data as JSON
parentModule default the parent module
parentItemDefinition default the item definition that this node is located, for example if this include is for a car wheel, and is included in vehicle, this parentItemDefinition would be the vehicle definition

Returns

default

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:210

Properties

canUserExcludeIf

Private Optional canUserExcludeIf: default

The allowance of exclusion (compiled)

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:159


defaultExcludedIf

Private Optional defaultExcludedIf: default

The default exclusion state rule (compiled)

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:163


enforcedProperties

Private Optional enforcedProperties: default

Enforced properties (compiled)

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:168


excludedIf

Private Optional excludedIf: default

The excluded if rules (compiled)

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:155


itemDefinition

Private itemDefinition: default

The item definition the include refers to

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:151


parentItemDefinition

parentItemDefinition: default

The parent item definition of this include

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:142


parentModule

parentModule: default

The parent module where this include sits

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:146


predefinedProperties

Private Optional predefinedProperties: default

Predefined properties (compiled)

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:172


rawData

rawData: IIncludeRawJSONDataType

The raw data that comes from the compiled schema

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:138


stateExclusion

Private stateExclusion: Object

This is the state exclusion of the class, not the defaulted, not the enforced, but the stateful

Index signature

▪ [mergedID: string]: IncludeExclusionState

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:178


stateExclusionApplied

Private stateExclusionApplied: Object

The applied exclusion

Index signature

▪ [mergedID: string]: IncludeExclusionState

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:191


stateExclusionHasBeenManuallySet

Private stateExclusionHasBeenManuallySet: Object

This also shows whether the state has been modified, either by the user or a value has been applied

Index signature

▪ [mergedID: string]: boolean

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:198


stateExclusionModified

Private stateExclusionModified: Object

This also shows whether the state has been modified, either by the user or a value has been applied

Index signature

▪ [mergedID: string]: boolean

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:185

Methods

applySoftReadRoleAccessTo

applySoftReadRoleAccessTo(role, userId, ownerUserId, rolesManager, value): Promise<void>

For a given requested rq value it will tell which fields need to be filtered for soft read role access

Parameters

Name Type
role string
userId string
ownerUserId string
rolesManager ICustomRoleManager
value IRQValue

Returns

Promise<void>

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:340


applyValue

applyValue(id, version, value, exclusionState, doNotApplyValueInPropertyIfPropertyHasBeenManuallySet): void

Applies a value to an include

Parameters

Name Type Description
id string the slot id to use
version string the slot version to use
value IRQValue the value that is applied
exclusionState IncludeExclusionState the exclusion state
doNotApplyValueInPropertyIfPropertyHasBeenManuallySet boolean to avoid hot updating values when the user is modifying them and an apply value has been called because it has been updated somewhere else, we use this to avoid overriding, note that the value must also not be equal, as in, it must differs; otherwise the value is applied, and manually set will go back to false as it's been used applyValue on it, it's been set now by the computer

Returns

void

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:670


buildFieldsForRoleAccess

buildFieldsForRoleAccess(action, role, userId, ownerUserId, rolesManager): Promise<IRQRequestFields>

Builds the fileds as rq fields for a given role that wants to execute a given action, that will be the maximum fields of the include this user can request

Parameters

Name Type Description
action ItemDefinitionIOActions the action that is to be executed
role string the role that is executing it
userId string the user id of that user
ownerUserId string the owner of the item definition where the include is localed
rolesManager ICustomRoleManager -

Returns

Promise<IRQRequestFields>

a rq fields object

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:400


canExclusionBeSet

canExclusionBeSet(id, version): boolean

Tells whether the exclusion state can be toggled externally This is for when an item might be included like how a car might have a spare wheel or not usually the case is true but it might be false as well

Parameters

Name Type Description
id string the id of the given exclusion state slot id
version string the version for the given exclusion state slot id

Returns

boolean

a boolean that tells whether if it can be toggled

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:495


checkRoleAccessFor

checkRoleAccessFor(action, role, userId, ownerUserId, requestedFields, rolesManager, throwError): Promise<boolean>

Checks the role access for a given include to be accessed given a IO action

Parameters

Name Type Description
action ItemDefinitionIOActions the action that wants to be executed
role string the role of the user wanting to execute that action
userId string the user id of the user wanting to execute (can be null)
ownerUserId string the owner of the user wanting to execute (or UNSPECIFIED_OWNER)
requestedFields IRQRequestFields the requested fields that are requested from the include these basically represent the sinking properties where the IO action is being applied
rolesManager ICustomRoleManager -
throwError boolean whether to throw an error in failure

Returns

Promise<boolean>

a boolean on whether it has role access

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:371


cleanState

cleanState(init?): void

Cleans the state of the include so that is empty and clears the memory

Parameters

Name Type Description
init? boolean whether it was called in the constructor for initialization

Returns

void

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:267


cleanValueFor

cleanValueFor(id, version): void

Memory cleans the value in an item

Parameters

Name Type Description
id string the slot id
version string the slot version

Returns

void

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:719


containsAnExternallyCheckedProperty

containsAnExternallyCheckedProperty(): boolean

Returns true if the item contains a property that needs to be extenrally checked, either an indexed one

Returns

boolean

a boolean on whether it contains such a property or not

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:794


getAppliedExclusionState

getAppliedExclusionState(id, version): IncludeExclusionState

Provides the applied value for a property

Parameters

Name Type Description
id string the id
version string the version

Returns

IncludeExclusionState

the applied value

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:591


getExclusionState

getExclusionState(id, version): IncludeExclusionState

Tells whether the current item is excluded

Parameters

Name Type Description
id string the id of the given exclusion state slot id
version string the version for the given exclusion state slot id

Returns

IncludeExclusionState

a boolean whether it's excluded or not

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:444


getI18nDataFor

getI18nDataFor(locale): Object

Provides the item definition item locale data

Parameters

Name Type Description
locale string the locale in iso form

Returns

Object

an object or null (if locale not valid)

Name Type
any_label? string
callout_excluded_label? string
excluded_label? string
exclusion_selector_label? string
exclusion_ternary_selector_label? string
included_label? string
name? string

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:777


getI18nNameFor

getI18nNameFor(locale): string

Gives the i18 name that was specified or otherwise gives the item definition i18 name

Parameters

Name Type Description
locale string the locale iso form

Returns

string

a string or null (if locale not valid)

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:761


getId

getId(): string

Provides the unique id of this item definition the unique id is, well, unique for this item

Returns

string

the unique id of the include

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:555


getItemDefinition

getItemDefinition(): default

Provides the item definition that this include refers to

Returns

default

the item definition

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:802


getItemDefinitionName

getItemDefinitionName(): string

Provides the name for this item, the name represents the item definition children this item is attached to

Returns

string

a string with the item definition name

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:546


getPrefixedQualifiedIdentifier

getPrefixedQualifiedIdentifier(): string

Provides the qualified identifier for prefixing other things

Returns

string

a prefixed string that is the prefixed qualified identifier

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:573


getQualifiedExclusionStateIdentifier

getQualifiedExclusionStateIdentifier(): string

Provides the qualfiied name for the exclusion state

Returns

string

the string that represents the exclusion identifier

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:581


getQualifiedIdentifier

getQualifiedIdentifier(): string

Provides the qualified identifier of the include that is an INCLUDE prefixed with the identifier

Returns

string

a string that is the qualified identifier

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:564


getSinkingProperties

getSinkingProperties(): default[]

Provides all the sinking properties as property definition instances

Returns

default[]

all sinking properties as instances

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:325


getSinkingPropertiesIds

getSinkingPropertiesIds(): string[]

Provides the ids of the sinking properties

Returns

string[]

an array of the sinking properties ids

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:303


getSinkingPropertyFor

getSinkingPropertyFor(id): default

Propvides a single sinking property for a given id

Parameters

Name Type Description
id string the property id

Returns

default

a single property, if available, otherwise throws an error

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:312


getState

getState(id, version, onlySinkingProperties): Promise<IIncludeState>

Provides the current value of this item

Parameters

Name Type Description
id string the id of the stored item definition or module
version string the version
onlySinkingProperties string[] -

Returns

Promise<IIncludeState>

a promise for the state of the include

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:637


getStateNoExternalChecking

getStateNoExternalChecking(id, version, onlySinkingProperties, emulateExternalChecking?): IIncludeState

Provides the current value of this item

Parameters

Name Type Description
id string the id of the stored item definition or module
version string the slot version
onlySinkingProperties string[] -
emulateExternalChecking? boolean whether to emulate the external checking results using previous cached results

Returns

IIncludeState

the state of the include

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:608


isExclusionCallout

isExclusionCallout(): boolean

Checks whether excluding this item (while possible) will cause a callout, that is, a clear display that the item definition instance is missing it, this is for key items, eg. car, wheels missing.

Returns

boolean

a boolean on whether the exclusion must be called out

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:524


isExclusionTernary

isExclusionTernary(): boolean

Checks whether the exclusion state is a ternary type, this basically only exists in search item definition items because it's used during the search mode

Returns

boolean

a boolean on whether the exclusion is ternary

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:514


mergeWithI18n

mergeWithI18n(includeRaw): void

Merges the i18n data of another include in another language

Parameters

Name Type Description
includeRaw IIncludeRawJSONDataType the include itself

Returns

void

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:810


restoreValueFor

restoreValueFor(id, version): void

restores the include value to the applied value

Parameters

Name Type Description
id string the slot id
version string the slot version

Returns

void

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:737


setExclusionState

setExclusionState(id, version, value): void

Sets the exclusion state to a new value

Parameters

Name Type Description
id string the id of the given exclusion state slot id
version string the version for the given exclusion state slot id
value IncludeExclusionState the value for the exclusion state

Returns

void

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:534


toJSON

toJSON(): IIncludeRawJSONDataType

Basically returns the raw data of this item

Returns

IIncludeRawJSONDataType

the json value raw data

Defined in

base/Root/Module/ItemDefinition/Include/index.ts:785