2.2.734 • Published 1 year ago

@concepto/interface v2.2.734

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Description

Language Class Interface for creating DSL parsers for Concepto DSL

API Reference

Concepto DSL Base Class: A base class (to be extended) for defining new languages for Concepto to be compiled to.

concepto.init()

Initializes/starts the class

Kind: instance method of concepto

concepto.autocompleteContentTemplate(record, render) ⇒ string

Renders an HTML template for displaying an autocomplete item within the IDE Should return the rendered HTML

Kind: instance method of concepto
Returns: string - - HTML template

ParamTypeDescription
recordAutocompleteItemautocomplete item record
renderObjectrender object with default methods for rendering autocomplete items
render.placeholdersfunctioninternal function to escape {icon}:x placeholders; returns modified string with rendered icons
render.iconfunctioninternal function to call to render any given icon into an img tag; you can either call this or use your own method within the code
render.attrsfunctioninternal function to call to render the item attributes as an html table

concepto.addAutocompleteDefinition(extends_, parentsAll, parents, childrenTypes, id, text, type, icons, level, hint, attributes) ⇒ Object

Adds the given definition for the generation of autocomplete files recods

Kind: instance method of concepto

ParamTypeDescription
extends_Stringextends autocomplete record;
parentsAllArrayrequired node parents of this definition; empty means any; * means item must match all parents listed
parentsArrayposible node parents of this definition; empty means any; * means item must be partof
childrenTypesArrayposible children type nodes; empty means no restrictions
idStringUnique AC node identifier (usually the 'text')
textStringNode text (ex. 'consultar modelo "x",') to be shown to used within list
typeStringNode type (ex. 'view') to be shown to used within list; empty by default
iconsArrayArray of icons (in order) for autocomplete node detection
levelArrayArray of levels of node definition to be detected (1=root, 2=child, 3=grandchild, etc)
hintStringHint to show user for command completion
attributesObjectPossible node command attributes (ex. { 'id':{ required:true, type:'number', values:'1,2,3', hint:'id of datamodel' } })

concepto.reply_template(init) ⇒ Object

Sets the default reply Object for commands

Kind: instance method of concepto

ParamTypeDescription
initObjectMerges given object keys with default defined template

concepto.onInit()

Gets automatically executed after init method finishes. You should place any parser preparation steps here (ex. load commands)

Kind: instance method of concepto

concepto.onAfterProcess(processedNode) ⇒ Object

Gets automatically executed after parsing all nodes level 2 of the given dsl (before onCompleteCodeTemplate)

Kind: instance method of concepto

ParamTypeDescription
processedNodeObjectreply content of process method per processed level2 node (keys of reply_template method)

concepto.onDefineTitle(node) ⇒ String

Gets automatically executed within writer method for setting the title for a node level 2.

Kind: instance method of concepto

ParamTypeDescription
nodeNodeDSLnode to process

concepto.onDefineFilename(node) ⇒ String

Gets automatically executed for naming filename of class/page by testing node (you could use a slud method here).

Kind: instance method of concepto

ParamTypeDescription
nodeNodeDSLnode to process

concepto.onDefineNodeName(node) ⇒ String

Gets automatically called for naming the class/page by testing node (similar to a filename, but for objects reference).

Kind: instance method of concepto

ParamTypeDescription
nodeNodeDSLnode to process

concepto.onCompleteCodeTemplate(processedNode) ⇒ Object

Defines template for code given the processedNodes of writer(). Useful to prepend/append code before writting code to disk.

Kind: instance method of concepto

ParamTypeDescription
processedNodeObjectreply content of process method per processed level2 node (keys of reply_template method)

concepto.onPrepare()

Defines preparation steps before processing nodes.

Kind: instance method of concepto

concepto.onErrors(errors)

Gets automatically called after errors have being found while processing nodes (with the defined commands)

Kind: instance method of concepto

ParamTypeDescription
errorsArray.<string>array of errors messages

concepto.onCreateFiles(processedNodes)

Gets automatically called after all processing on nodes has being done. You usually create the files here using the received processedNodes array.

Kind: instance method of concepto

ParamTypeDescription
processedNodesArray.<Object>array of nodes already processed (keys of reply_template method) ready to be written to disk

concepto.onEnd()

Gets automatically called after all processes have finished. Useful for cleaning the enviroment.

Kind: instance method of concepto

concepto.addCommands(command_func)

Add commands for processing nodes with the current class

Kind: instance method of concepto

ParamTypeDescription
command_funcfunctionasync function returning an object with commands objects (Command) where each key is the command id, and its value a Command object.

concepto.cacheCommands()

Detects which x_commands changed their code since last persistant cache usage. To be called before process().

Kind: instance method of concepto

concepto.findCommand(node, justone) ⇒ Command | Array.<Command>

Finds one or more commands defined that matches the specs of the given node.

Kind: instance method of concepto

ParamTypeDefaultDescription
nodeNodeDSLnode for which to find commands that match
justonebooleantrueindicates if you want just the first match (true), or all commands that match the given node (false)

concepto.abortProcessing() ⇒ Command | boolean

Signals an abort event for the processing methods.

Kind: instance method of concepto

concepto.findValidCommand(node, object) ⇒ Command | boolean

Finds the valid/best command match for the given node. Also tests the command for its 'valid' attribute, in case the command func specified aditional conditions. If no command is found, returns false.

Kind: instance method of concepto

ParamTypeDefaultDescription
nodeNodeDSLnode for which to find the command
objectbooleanfalseif false returns the command reference, true returns the command execution answer

concepto.process() ⇒ Object

This method traverses the dsl parsed tree, finds/execute x_commands and generated code as files.

Kind: instance method of concepto

concepto.array_intersect(arr1, arr2) ⇒ Array.<string> | Array.<Object> | Array.<boolean>

Helper method for obtaining the common values (which can be anything) between two arrays.

Kind: instance method of concepto

ParamTypeDescription
arr1Array.<string> | Array.<Object> | Array.<boolean>first array
arr2Array.<string> | Array.<Object> | Array.<boolean>second array

concepto.array_substract(arr1, arr2) ⇒ Array.<string> | Array.<Object> | Array.<boolean>

Helper method for obtaining the first array items minus the second array items (which can be anything).

Kind: instance method of concepto

ParamTypeDescription
arr1Array.<string> | Array.<Object> | Array.<boolean>first array from which to substract
arr2Array.<string> | Array.<Object> | Array.<boolean>second array with items to substract from arr1

concepto.array_difference(arr1, arr2) ⇒ Array.<string> | Array.<Object> | Array.<boolean>

Helper method for obtaining the unique values (which can be anything) between two arrays.

Kind: instance method of concepto

ParamTypeDescription
arr1Array.<string> | Array.<Object> | Array.<boolean>first array
arr2Array.<string> | Array.<Object> | Array.<boolean>second array

concepto.array_union(arr1, arr2) ⇒ Array.<string> | Array.<Object> | Array.<boolean>

Helper method for joining the values (which can be anything) between two arrays.

Kind: instance method of concepto

ParamTypeDescription
arr1Array.<string> | Array.<Object> | Array.<boolean>first array
arr2Array.<string> | Array.<Object> | Array.<boolean>second array

concepto.debug(message, data)

Helper method for defining how to display (or do with them; if you overload it) debug messages.

Kind: instance method of concepto

ParamTypeDescription
messagestring | Objectmessage to display. It can also be an Object of open-console params.
data*data variable to show with message

concepto.debug_time(id)

Helper method for measuring (start) time in ms from this method until debug_timeEnd() method and show it in the console.

Kind: instance method of concepto

ParamTypeDescription
idstringid key (which can also have spaces and/or symbols) with a unique id to identify the stopwatch.

concepto.exists(dir_or_file) ⇒ boolean

Helper to test if a given file exists or not

Kind: instance method of concepto

ParamTypeDescription
dir_or_filestringfull directory or file to test

concepto.debug_timeEnd(id)

Helper method for measuring (end) time in ms from the call of debug_time() method.

Kind: instance method of concepto

ParamTypeDescription
idstringid key used in the call for debug_time() method.

concepto.debug_table(title)

Helper method for showing a table with each command execution time and amount of calls

Kind: instance method of concepto

ParamTypeDescription
titlestringOptional custom title for table.

concepto.hasBrotherID(id, x_id) ⇒ Boolean

Helper method to return true if given node id has a brother of given command x_id

Kind: instance method of concepto

ParamTypeDescription
idstringID of NodeDSL object to query
x_idstringCommand object x_id to test for

concepto.hasBrotherBefore(id) ⇒ Boolean

Helper method to return true if given node ID has a brother before it

Kind: instance method of concepto

ParamTypeDescription
idstringID of NodeDSL object to query

concepto.hasBrotherNext(id) ⇒ Boolean

Helper method to return true if given node ID has a brother following it

Kind: instance method of concepto

ParamTypeDescription
idstringID of NodeDSL object to query

concepto.isExactParentID(id, x_id) ⇒ Boolean

Helper method to return true if given Command object x_id is the exact parent for the given NodeDSL object id

Kind: instance method of concepto

ParamTypeDescription
idstringID of NodeDSL object to query
x_idstringCommand object x_id to test for

concepto.hasParentID(id, x_id) ⇒ Boolean

Helper method to return true if given Command object x_id is the parent or is an ancestor for the given NodeDSL object id

Kind: instance method of concepto

ParamTypeDescription
idstringID of NodeDSL object to query
x_idstringCommand object x_id to test for

concepto.getParentIDs(id, array) ⇒ string | Array.<Object>

Helper method to return all Command object x_ids parents of given NodeDSL id; if array=true,

Kind: instance method of concepto

ParamTypeDefaultDescription
idstringID of NodeDSL object to query
arrayBooleanfalseIf true, returns array of objects with x_id and ids, instead of a list of NodeDSL ids.

concepto.getParentIDs2Array(id) ⇒ Array.<Object>

Helper method to return all Command object x_ids parents of given NodeDSL id as an array (its an alias for getParentIDs)

Kind: instance method of concepto

ParamTypeDescription
idstringID of NodeDSL object to query

concepto.getParentIDs2ArrayWXID(id) ⇒ Array.<Object>

Deprecated

Helper method to return all NodeDSL ids parents of given NodeDSL id

Kind: instance method of concepto

ParamTypeDescription
idstringID of NodeDSL object to query

concepto.tagParams(struct) ⇒ string

Helper method to return a tag with key/values as tag attributes

Kind: instance method of concepto

ParamTypeDescription
structObjectObject with keys and values to transform from.

concepto.struct2params(struct) ⇒ string

Helper method to transform object keys/values into params for customtags usage

Kind: instance method of concepto

ParamTypeDescription
structObjectObject with keys and values to transform from.

concepto~AutocompleteItem : Object

An autocomplete object representing an item within the autocomplete list

Kind: inner typedef of concepto
Properties

NameTypeDescription
parentsAllArray.<string>Optionally indicates if this node item needs to have all of these parents (node texts for now).
parentsArray.<string>Optionally indicates if this node item needs to have any of these parents (node texts for now).
extends_stringOptionally indicates if this item extends another existing one.
textstringIndicates the text to show; aka keyword to complete.
hintstringIndicates the html to show as the summary for the keyword.
iconsArray.<string>Array with icon names used in the node.
levelArray.<number>Array with supported level numbers.
attributesObjectObject with a key for each attribute supported by the node (the key is the attribute name, the value is an object with keys: type, default, hint - supports icon placeholders like {icon:idea} within their texts).
eventsObjectObject with a key for each event supported by the node.

concepto~NodeDSL : Object

A node object representation of a DSL node.

Kind: inner typedef of concepto
Properties

NameTypeDescription
idnumberNode unique ID.
levelnumberIndicates the depth level from the center of the dsl map.
textstringIndicates the text defined in the node itself.
text_richstringIndicates the html defined in the node itself.
text_notestringIndicates the text/html defined in the notes view of the node (if any).
imagestringImage link defined as an image within the node.
cloudObjectCloud information of the node.
cloud.bgcolorstringBackground color of cloud.
cloud.usedbooleanTrue if cloud is used, false otherwise.
arrowsArray.<Arrow>Visual connections of this node with other nodes #module_concepto..Arrow.
nodesArray.<NodeDSL>Children nodes of current node.
fontObjectDefine font, size and styles of node texts.
font.faceObjectFont face type used on node.
font.sizeObjectFont size used on node.
font.boldObjectTrue if node text is in bold.
font.italicObjectTrue if node text is in italics.
stylestringStyle applied to the node.
colorstringText color of node.
bgcolorstringBackground color of node.
linkstringLink defined on node.
positionstringPosition in relation of central node (left,right).
attributesObjectObject with each attribute (key is attribute name, value is attribute value).
iconsArray.<string>Array with icon names used in the node.
date_modifieddateDate of node when it was last modified.
date_createddateDate of node when it was created.

concepto~Arrow : Object

Arrow object definition, for connections to other nodes within a DSL.

Kind: inner typedef of concepto
Properties

NameTypeDescription
targetstringTarget node ID of connection.
colorstringColor of visual connection.
stylestringGraphical representation type of link (source-to-target, target-to-source, both-ways).

concepto~Command : Object

A command object specifying requirements for a node to execute its function.

Kind: inner typedef of concepto
Properties

NameTypeDescription
x_iconsstringList of required icons that the node must define to be a match for this command.
x_not_iconsstringList of icons that the node cannot define to be a match for this command.
x_not_emptystringList of keys that must not be empty to be a match for this command (can be any key from a NodeDSL object). Example: 'attributesrc,color'
x_not_text_containsstringList of strings, which cannot be within the node text.
x_emptystringList of NodeDSL keys that must be empty to be a match for this command.
x_text_containsstringList of strings, that can be contain in node text (if delimiter is) or that must be all contained within the node text (if delimiter is comma).
x_text_patternstring | Array.<string>Minimatch pattern to match to be a match for this command. Can also be an array of patterns (one must match).
x_levelstringNumeric conditions that the level of the node must met (example: '>2,<5' or '2,3,4').
x_all_hasparentstringList of commands ids (keys), which must be ancestors of the node to be a match for this command.
x_or_hasparentstringList of commands ids (keys), which at least one must be an ancestor of the node to be a match for this command.
x_or_isparentstringList of commands ids (keys), which at least one must be the exact parent of the node to be a match for this command.
autocompleteObjectDescribes the node for the autocomplete feature of Concepto DSL software and its related documentation. The feature also takes into account the definition of the command (x_level and x_icons)
autocomplete.key_textstringString that the node text must have for this command to be suggested.
autocomplete.hintstringText description for this command to be shown on Concepto DSL.
funcfunctionFunction to execute with a matching node. Receives one argument and it must be a NodeDSL object.

© 2020-2022 Pablo Schaffner <pablo@puntorigen.com>.

2.2.722

1 year ago

2.2.721

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.2.3

1 year ago

2.2.2

1 year ago

2.2.5

1 year ago

2.2.4

1 year ago

2.2.7

1 year ago

2.2.6

1 year ago

2.2.68

1 year ago

2.2.69

1 year ago

2.2.66

1 year ago

2.2.67

1 year ago

2.2.64

1 year ago

2.2.65

1 year ago

2.2.62

1 year ago

2.2.63

1 year ago

2.2.61

1 year ago

2.2.734

1 year ago

2.2.71

1 year ago

2.2.72

1 year ago

2.1.998

1 year ago

2.1.997

1 year ago

2.1.999

1 year ago

2.2.692

1 year ago

2.2.691

1 year ago

2.2.696

1 year ago

2.2.695

1 year ago

2.2.694

1 year ago

2.2.693

1 year ago

2.2.733

1 year ago

2.2.732

1 year ago

2.2.731

1 year ago

2.2.730

1 year ago

2.2.726

1 year ago

2.2.725

1 year ago

2.2.724

1 year ago

2.2.723

1 year ago

2.2.729

1 year ago

2.2.728

1 year ago

2.2.727

1 year ago

2.1.996

2 years ago

2.1.995

2 years ago

2.1.993

2 years ago

2.1.992

2 years ago

2.1.991

2 years ago

2.1.99

2 years ago

2.1.98

2 years ago

2.1.97

2 years ago

2.1.96

2 years ago

2.1.95

2 years ago

2.1.94

2 years ago

2.1.93

2 years ago