theprogrammablemind_4wp 7.5.0-beta.1 → 7.5.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
 - package/src/config.js +41 -37
 - package/src/helpers.js +7 -0
 
    
        package/package.json
    CHANGED
    
    
    
        package/src/config.js
    CHANGED
    
    | 
         @@ -412,11 +412,11 @@ class Config { 
     | 
|
| 
       412 
412 
     | 
    
         
             
              }
         
     | 
| 
       413 
413 
     | 
    
         | 
| 
       414 
414 
     | 
    
         
             
              getSemantics (logs = []) {
         
     | 
| 
       415 
     | 
    
         
            -
                return new Semantics(this.config.semantics 
     | 
| 
      
 415 
     | 
    
         
            +
                return new Semantics(this.config.semantics, logs, { km: this.name })
         
     | 
| 
       416 
416 
     | 
    
         
             
              }
         
     | 
| 
       417 
417 
     | 
    
         | 
| 
       418 
418 
     | 
    
         
             
              getGenerators (logs = []) {
         
     | 
| 
       419 
     | 
    
         
            -
                return new Generators(this.config.generators 
     | 
| 
      
 419 
     | 
    
         
            +
                return new Generators(this.config.generators, logs, { km: this.name })
         
     | 
| 
       420 
420 
     | 
    
         
             
              }
         
     | 
| 
       421 
421 
     | 
    
         | 
| 
       422 
422 
     | 
    
         
             
              warningNotEvaluated (log, value) {
         
     | 
| 
         @@ -593,18 +593,21 @@ class Config { 
     | 
|
| 
       593 
593 
     | 
    
         
             
                }
         
     | 
| 
       594 
594 
     | 
    
         
             
              }
         
     | 
| 
       595 
595 
     | 
    
         | 
| 
       596 
     | 
    
         
            -
              addHierarchyProperties ( 
     | 
| 
       597 
     | 
    
         
            -
                 
     | 
| 
      
 596 
     | 
    
         
            +
              addHierarchyProperties (edge) {
         
     | 
| 
      
 597 
     | 
    
         
            +
                const { child, parent } = edge
         
     | 
| 
      
 598 
     | 
    
         
            +
                if (typeof child !== 'string') {
         
     | 
| 
       598 
599 
     | 
    
         
             
                  throw `addHierarchy expected child property to be a string. got ${JSON.stringify(child)}`
         
     | 
| 
       599 
600 
     | 
    
         
             
                }
         
     | 
| 
       600 
     | 
    
         
            -
                if (typeof  
     | 
| 
       601 
     | 
    
         
            -
                  throw `addHierarchy expected parent  
     | 
| 
      
 601 
     | 
    
         
            +
                if (typeof parent !== 'string') {
         
     | 
| 
      
 602 
     | 
    
         
            +
                  throw `addHierarchy expected parent property to be a string. got ${JSON.stringify(parent)}`
         
     | 
| 
       602 
603 
     | 
    
         
             
                }
         
     | 
| 
       603 
     | 
    
         
            -
                if ( 
     | 
| 
       604 
     | 
    
         
            -
                   
     | 
| 
      
 604 
     | 
    
         
            +
                if (global.entodictonDebugHierarchy) {
         
     | 
| 
      
 605 
     | 
    
         
            +
                  if (deepEqual(global.entodictonDebugHierarchy, [child, parent])) {
         
     | 
| 
      
 606 
     | 
    
         
            +
                    debugger; // debug hierarchy hit
         
     | 
| 
      
 607 
     | 
    
         
            +
                  }
         
     | 
| 
       605 
608 
     | 
    
         
             
                }
         
     | 
| 
       606 
     | 
    
         
            -
                 
     | 
| 
       607 
     | 
    
         
            -
                this. 
     | 
| 
      
 609 
     | 
    
         
            +
                this.config.hierarchy.push(edge)
         
     | 
| 
      
 610 
     | 
    
         
            +
                // TODO greg11 this.hierarchy.addEdge(edge)
         
     | 
| 
       608 
611 
     | 
    
         
             
                this._delta.json.hierarchy.push([child, parent])
         
     | 
| 
       609 
612 
     | 
    
         
             
              }
         
     | 
| 
       610 
613 
     | 
    
         | 
| 
         @@ -615,14 +618,13 @@ class Config { 
     | 
|
| 
       615 
618 
     | 
    
         
             
                if (typeof parent !== 'string') {
         
     | 
| 
       616 
619 
     | 
    
         
             
                  throw `addHierarchy expected parent to be a string. got ${JSON.stringify(parent)}`
         
     | 
| 
       617 
620 
     | 
    
         
             
                }
         
     | 
| 
       618 
     | 
    
         
            -
             
     | 
| 
       619 
     | 
    
         
            -
                  this.config.hierarchy = []
         
     | 
| 
       620 
     | 
    
         
            -
                }
         
     | 
| 
      
 621 
     | 
    
         
            +
             
     | 
| 
       621 
622 
     | 
    
         
             
                if (global.entodictonDebugHierarchy) {
         
     | 
| 
       622 
623 
     | 
    
         
             
                  if (deepEqual(global.entodictonDebugHierarchy, [child, parent])) {
         
     | 
| 
       623 
624 
     | 
    
         
             
                    debugger; // debug hierarchy hit
         
     | 
| 
       624 
625 
     | 
    
         
             
                  }
         
     | 
| 
       625 
626 
     | 
    
         
             
                }
         
     | 
| 
      
 627 
     | 
    
         
            +
             
     | 
| 
       626 
628 
     | 
    
         
             
                if (this.config.hierarchy.find( (element) => {
         
     | 
| 
       627 
629 
     | 
    
         
             
                  const hc = hierarchyCanonical(element) 
         
     | 
| 
       628 
630 
     | 
    
         
             
                  if (child == hc.child && parent == hc.parent) {
         
     | 
| 
         @@ -633,6 +635,7 @@ class Config { 
     | 
|
| 
       633 
635 
     | 
    
         
             
                }
         
     | 
| 
       634 
636 
     | 
    
         | 
| 
       635 
637 
     | 
    
         
             
                this.config.hierarchy.push([child, parent])
         
     | 
| 
      
 638 
     | 
    
         
            +
                // this.hierarchy.addEdge([child, parent])
         
     | 
| 
       636 
639 
     | 
    
         
             
                this._delta.json.hierarchy.push([child, parent])
         
     | 
| 
       637 
640 
     | 
    
         
             
              }
         
     | 
| 
       638 
641 
     | 
    
         | 
| 
         @@ -953,17 +956,11 @@ class Config { 
     | 
|
| 
       953 
956 
     | 
    
         
             
                if (!config) {
         
     | 
| 
       954 
957 
     | 
    
         
             
                  return
         
     | 
| 
       955 
958 
     | 
    
         
             
                }
         
     | 
| 
       956 
     | 
    
         
            -
                config.operators = config.operators || []
         
     | 
| 
       957 
     | 
    
         
            -
                config.bridges = config.bridges || []
         
     | 
| 
       958 
     | 
    
         
            -
                config.words = config.words || {}
         
     | 
| 
       959 
     | 
    
         
            -
                config.generators = config.generators || []
         
     | 
| 
       960 
     | 
    
         
            -
                config.semantics = config.semantics || []
         
     | 
| 
       961 
     | 
    
         
            -
             
     | 
| 
       962 
959 
     | 
    
         
             
                config.operators = config.operators.filter( (element) => !element.development )
         
     | 
| 
       963 
960 
     | 
    
         
             
                config.bridges = config.bridges.filter( (element) => !element.development )
         
     | 
| 
       964 
961 
     | 
    
         
             
                config.generators = config.generators.filter( (element) => !element.development )
         
     | 
| 
       965 
962 
     | 
    
         
             
                config.semantics = config.semantics.filter( (element) => !element.development )
         
     | 
| 
       966 
     | 
    
         
            -
                config.hierarchy = (config.hierarchy 
     | 
| 
      
 963 
     | 
    
         
            +
                config.hierarchy = (config.hierarchy).filter( (element) => !element.development )
         
     | 
| 
       967 
964 
     | 
    
         
             
                for (const word in config.words) {
         
     | 
| 
       968 
965 
     | 
    
         
             
                  const defs = config.words[word] || []
         
     | 
| 
       969 
966 
     | 
    
         
             
                  config.words[word] = defs.filter( (def) => !def.development )
         
     | 
| 
         @@ -1006,6 +1003,15 @@ class Config { 
     | 
|
| 
       1006 
1003 
     | 
    
         
             
                    'flatten',
         
     | 
| 
       1007 
1004 
     | 
    
         
             
                  ]
         
     | 
| 
       1008 
1005 
     | 
    
         
             
                  helpers.validProps(valid, config, 'config')
         
     | 
| 
      
 1006 
     | 
    
         
            +
             
     | 
| 
      
 1007 
     | 
    
         
            +
                  config.operators = config.operators || []
         
     | 
| 
      
 1008 
     | 
    
         
            +
                  config.bridges = config.bridges || []
         
     | 
| 
      
 1009 
     | 
    
         
            +
                  config.words = config.words || {}
         
     | 
| 
      
 1010 
     | 
    
         
            +
                  config.generators = config.generators || []
         
     | 
| 
      
 1011 
     | 
    
         
            +
                  config.semantics = config.semantics || []
         
     | 
| 
      
 1012 
     | 
    
         
            +
                  config.hierarchy = config.hierarchy || []
         
     | 
| 
      
 1013 
     | 
    
         
            +
                  config.associations = config.associations || { negative: [], positive: [] }
         
     | 
| 
      
 1014 
     | 
    
         
            +
                  config.priorities = config.priorities || []
         
     | 
| 
       1009 
1015 
     | 
    
         
             
                }
         
     | 
| 
       1010 
1016 
     | 
    
         | 
| 
       1011 
1017 
     | 
    
         
             
                this.allowDelta = false
         
     | 
| 
         @@ -1083,16 +1089,7 @@ class Config { 
     | 
|
| 
       1083 
1089 
     | 
    
         
             
                if (config) {
         
     | 
| 
       1084 
1090 
     | 
    
         
             
                  config = _.cloneDeep(config)
         
     | 
| 
       1085 
1091 
     | 
    
         
             
                  this.config = config
         
     | 
| 
       1086 
     | 
    
         
            -
                   
     | 
| 
       1087 
     | 
    
         
            -
                    this.config.generators = []
         
     | 
| 
       1088 
     | 
    
         
            -
                  }
         
     | 
| 
       1089 
     | 
    
         
            -
                  if (!this.config.semantics) {
         
     | 
| 
       1090 
     | 
    
         
            -
                    this.config.semantics = []
         
     | 
| 
       1091 
     | 
    
         
            -
                  }
         
     | 
| 
       1092 
     | 
    
         
            -
                  if (!this.config.words) {
         
     | 
| 
       1093 
     | 
    
         
            -
                    // this.config.words = {}
         
     | 
| 
       1094 
     | 
    
         
            -
                  }
         
     | 
| 
       1095 
     | 
    
         
            -
                  for (let bridge of (this.config.bridges || [])) {
         
     | 
| 
      
 1092 
     | 
    
         
            +
                  for (let bridge of this.config.bridges) {
         
     | 
| 
       1096 
1093 
     | 
    
         
             
                    const valid = [ 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generators', 'id', 'inverted', 'isA',
         
     | 
| 
       1097 
1094 
     | 
    
         
             
                                    'level', 'optional', 'selector', 'semantic',  'words', /Bridge$/, 'localHierarchy' ]
         
     | 
| 
       1098 
1095 
     | 
    
         
             
                    helpers.validProps(valid, bridge, 'bridge')
         
     | 
| 
         @@ -1178,6 +1175,7 @@ class Config { 
     | 
|
| 
       1178 
1175 
     | 
    
         
             
                    })
         
     | 
| 
       1179 
1176 
     | 
    
         
             
                  }
         
     | 
| 
       1180 
1177 
     | 
    
         
             
                }
         
     | 
| 
      
 1178 
     | 
    
         
            +
                this.hierarchy = new Digraph(this.config.hierarchy)
         
     | 
| 
       1181 
1179 
     | 
    
         
             
                this.initConfig = _.cloneDeep(this.config)
         
     | 
| 
       1182 
1180 
     | 
    
         
             
                this.configs.push(new KM({ config: this.config, getCounter: (name) => this.config.getCounter(name), uuid: this._uuid }))
         
     | 
| 
       1183 
1181 
     | 
    
         | 
| 
         @@ -1432,7 +1430,7 @@ class Config { 
     | 
|
| 
       1432 
1430 
     | 
    
         
             
                this.config.bridges && this.config.bridges.forEach((bridge) => { bridge.uuid = this._uuid })
         
     | 
| 
       1433 
1431 
     | 
    
         
             
                this.config.words && setWordsUUIDs(this.config.words, this._uuid)
         
     | 
| 
       1434 
1432 
     | 
    
         
             
                this.config.operators && this.config.operators.forEach((operator) => { operator.uuid = this._uuid })
         
     | 
| 
       1435 
     | 
    
         
            -
                const ids = Array.from(new Set( 
     | 
| 
      
 1433 
     | 
    
         
            +
                const ids = Array.from(new Set(this.config.bridges.map((bridge) => bridge.id)))
         
     | 
| 
       1436 
1434 
     | 
    
         
             
                ids.sort()
         
     | 
| 
       1437 
1435 
     | 
    
         
             
                this.config.namespaces = {}
         
     | 
| 
       1438 
1436 
     | 
    
         
             
                // if (true || ids.length > 0) {
         
     | 
| 
         @@ -1648,6 +1646,13 @@ class Config { 
     | 
|
| 
       1648 
1646 
     | 
    
         
             
                  return false
         
     | 
| 
       1649 
1647 
     | 
    
         
             
                }
         
     | 
| 
       1650 
1648 
     | 
    
         | 
| 
      
 1649 
     | 
    
         
            +
                /* TODO greg11
         
     | 
| 
      
 1650 
     | 
    
         
            +
                if (!this.hierarchy) {
         
     | 
| 
      
 1651 
     | 
    
         
            +
                  debugBreak()
         
     | 
| 
      
 1652 
     | 
    
         
            +
                  return false
         
     | 
| 
      
 1653 
     | 
    
         
            +
                }
         
     | 
| 
      
 1654 
     | 
    
         
            +
                */
         
     | 
| 
      
 1655 
     | 
    
         
            +
             
     | 
| 
       1651 
1656 
     | 
    
         
             
                for (const key in this.config.words) {
         
     | 
| 
       1652 
1657 
     | 
    
         
             
                  const values = this.config.words[key]
         
     | 
| 
       1653 
1658 
     | 
    
         
             
                  if (values.some((word) => (Object.keys(word).includes('uuid') && !word.uuid))) {
         
     | 
| 
         @@ -1657,7 +1662,7 @@ class Config { 
     | 
|
| 
       1657 
1662 
     | 
    
         
             
                }
         
     | 
| 
       1658 
1663 
     | 
    
         | 
| 
       1659 
1664 
     | 
    
         
             
                const kmsUuids = this.configs.map((km) => km.uuid)
         
     | 
| 
       1660 
     | 
    
         
            -
                const bridgesUuids =  
     | 
| 
      
 1665 
     | 
    
         
            +
                const bridgesUuids = this.config.bridges.map((bridge) => bridge.uuid).filter((uuid) => uuid)
         
     | 
| 
       1661 
1666 
     | 
    
         
             
                let result = true
         
     | 
| 
       1662 
1667 
     | 
    
         
             
                bridgesUuids.forEach((buuid) => {
         
     | 
| 
       1663 
1668 
     | 
    
         
             
                  if (!kmsUuids.includes(buuid)) {
         
     | 
| 
         @@ -1727,6 +1732,7 @@ class Config { 
     | 
|
| 
       1727 
1732 
     | 
    
         
             
                this.resetDelta()
         
     | 
| 
       1728 
1733 
     | 
    
         
             
                const debug = this.config.debug;
         
     | 
| 
       1729 
1734 
     | 
    
         
             
                this.config = _.cloneDeep(this.initConfig)
         
     | 
| 
      
 1735 
     | 
    
         
            +
                this.hierarchy = new Digraph(this.config.hierarchy)
         
     | 
| 
       1730 
1736 
     | 
    
         
             
                if (debug) {
         
     | 
| 
       1731 
1737 
     | 
    
         
             
                  this.config.debug = debug
         
     | 
| 
       1732 
1738 
     | 
    
         
             
                }
         
     | 
| 
         @@ -1786,8 +1792,8 @@ class Config { 
     | 
|
| 
       1786 
1792 
     | 
    
         
             
                  config.wasInitialized = false
         
     | 
| 
       1787 
1793 
     | 
    
         
             
                  // TODO change name of config: to baseConfig:
         
     | 
| 
       1788 
1794 
     | 
    
         
             
                  const kmFn = (name) => this.getConfig(name)
         
     | 
| 
       1789 
     | 
    
         
            -
                  const hierarchy = new Digraph((config.config || {}).hierarchy 
     | 
| 
       1790 
     | 
    
         
            -
                  const args = { isModule, addWord: aw, km: kmFn, hierarchy, config, baseConfig: this, currentConfig: config, uuid: config._uuid, objects: namespacedObjects, namespace, api: config.api }
         
     | 
| 
      
 1795 
     | 
    
         
            +
                  // const hierarchy = new Digraph((config.config || {}).hierarchy)
         
     | 
| 
      
 1796 
     | 
    
         
            +
                  const args = { isModule, addWord: aw, km: kmFn, hierarchy: this.hierarchy, config, baseConfig: this, currentConfig: config, uuid: config._uuid, objects: namespacedObjects, namespace, api: config.api }
         
     | 
| 
       1791 
1797 
     | 
    
         
             
                  config.initializerFn(args)
         
     | 
| 
       1792 
1798 
     | 
    
         
             
                  if (config.initAfterApi) {
         
     | 
| 
       1793 
1799 
     | 
    
         
             
                    initAfterApis.push({ config, args })
         
     | 
| 
         @@ -1984,8 +1990,7 @@ class Config { 
     | 
|
| 
       1984 
1990 
     | 
    
         
             
                }
         
     | 
| 
       1985 
1991 
     | 
    
         | 
| 
       1986 
1992 
     | 
    
         
             
                if (config.hierarchy) {
         
     | 
| 
       1987 
     | 
    
         
            -
                   
     | 
| 
       1988 
     | 
    
         
            -
                  hierarchy = hierarchy.map((h) => {
         
     | 
| 
      
 1993 
     | 
    
         
            +
                  helpers.mapInPlace(config.hierarchy, (h) => {
         
     | 
| 
       1989 
1994 
     | 
    
         
             
                    if (Array.isArray(h)) {
         
     | 
| 
       1990 
1995 
     | 
    
         
             
                      return h.map((id) => toNS(id))
         
     | 
| 
       1991 
1996 
     | 
    
         
             
                    } else {
         
     | 
| 
         @@ -1994,7 +1999,6 @@ class Config { 
     | 
|
| 
       1994 
1999 
     | 
    
         
             
                      return Object.assign({}, h, { child: toNS(h.child), parent: toNS(h.parent) })
         
     | 
| 
       1995 
2000 
     | 
    
         
             
                    }
         
     | 
| 
       1996 
2001 
     | 
    
         
             
                  })
         
     | 
| 
       1997 
     | 
    
         
            -
                  config.hierarchy = hierarchy
         
     | 
| 
       1998 
2002 
     | 
    
         
             
                }
         
     | 
| 
       1999 
2003 
     | 
    
         | 
| 
       2000 
2004 
     | 
    
         
             
                if (config.priorities) {
         
     | 
    
        package/src/helpers.js
    CHANGED
    
    | 
         @@ -232,7 +232,14 @@ const validProps = (valids, object, type) => { 
     | 
|
| 
       232 
232 
     | 
    
         
             
              }
         
     | 
| 
       233 
233 
     | 
    
         
             
            }
         
     | 
| 
       234 
234 
     | 
    
         | 
| 
      
 235 
     | 
    
         
            +
            const mapInPlace = (list, fn) => {
         
     | 
| 
      
 236 
     | 
    
         
            +
              for (let i = 0; i < list.length; ++i) {
         
     | 
| 
      
 237 
     | 
    
         
            +
                list[i] =fn(list[i])
         
     | 
| 
      
 238 
     | 
    
         
            +
              }
         
     | 
| 
      
 239 
     | 
    
         
            +
            }
         
     | 
| 
      
 240 
     | 
    
         
            +
             
     | 
| 
       235 
241 
     | 
    
         
             
            module.exports = { 
         
     | 
| 
      
 242 
     | 
    
         
            +
              mapInPlace,
         
     | 
| 
       236 
243 
     | 
    
         
             
              validProps, 
         
     | 
| 
       237 
244 
     | 
    
         
             
              args, 
         
     | 
| 
       238 
245 
     | 
    
         
             
              safeEquals, 
         
     |