theprogrammablemind_4wp 9.4.5-beta.3 → 9.4.5-beta.5
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/client.js +17 -9
 - package/package.json +2 -1
 - package/src/config.js +6 -6
 - package/src/configHelpers.js +4 -0
 
    
        package/client.js
    CHANGED
    
    | 
         @@ -416,17 +416,17 @@ const getConfigForTest = (config, testConfig) => { 
     | 
|
| 
       416 
416 
     | 
    
         
             
              const configForTest = {}
         
     | 
| 
       417 
417 
     | 
    
         
             
              for (const key of Object.keys(includes)) {
         
     | 
| 
       418 
418 
     | 
    
         
             
                if (key === 'words') {
         
     | 
| 
       419 
     | 
    
         
            -
                  const  
     | 
| 
      
 419 
     | 
    
         
            +
                  const all = typeof includes.words == 'boolean'
         
     | 
| 
       420 
420 
     | 
    
         
             
                  configForTest.words = {
         
     | 
| 
       421 
421 
     | 
    
         
             
                    literals: {},
         
     | 
| 
       422 
422 
     | 
    
         
             
                    patterns: [],
         
     | 
| 
       423 
423 
     | 
    
         
             
                    hierarchy: []
         
     | 
| 
       424 
424 
     | 
    
         
             
                  }
         
     | 
| 
       425 
     | 
    
         
            -
             
     | 
| 
       426 
     | 
    
         
            -
                  const literals =  
     | 
| 
      
 425 
     | 
    
         
            +
                  const words = config.config.words
         
     | 
| 
      
 426 
     | 
    
         
            +
                  const literals = words.literals
         
     | 
| 
       427 
427 
     | 
    
         
             
                  let includesWord = (word) => true
         
     | 
| 
       428 
     | 
    
         
            -
                  if (Array.isArray(includes.words)) {
         
     | 
| 
       429 
     | 
    
         
            -
                    includesWord = (word) => includes.words.includes(word)
         
     | 
| 
      
 428 
     | 
    
         
            +
                  if (Array.isArray(includes.words.literals)) {
         
     | 
| 
      
 429 
     | 
    
         
            +
                    includesWord = (word) => includes.words.literals.includes(word)
         
     | 
| 
       430 
430 
     | 
    
         
             
                  }
         
     | 
| 
       431 
431 
     | 
    
         
             
                  for (const key in literals) {
         
     | 
| 
       432 
432 
     | 
    
         
             
                    if (!includesWord(key)) {
         
     | 
| 
         @@ -440,11 +440,15 @@ const getConfigForTest = (config, testConfig) => { 
     | 
|
| 
       440 
440 
     | 
    
         
             
                    configForTest.words.literals[key] = defs
         
     | 
| 
       441 
441 
     | 
    
         
             
                  }
         
     | 
| 
       442 
442 
     | 
    
         | 
| 
       443 
     | 
    
         
            -
                   
     | 
| 
       444 
     | 
    
         
            -
             
     | 
| 
      
 443 
     | 
    
         
            +
                  if (all || includes.words.patterns) {
         
     | 
| 
      
 444 
     | 
    
         
            +
                    const patterns = config.config.words.patterns || []
         
     | 
| 
      
 445 
     | 
    
         
            +
                    configForTest.words.patterns = patterns.map((pattern) => Object.assign({}, pattern, { uuid: undefined }))
         
     | 
| 
      
 446 
     | 
    
         
            +
                  }
         
     | 
| 
       445 
447 
     | 
    
         | 
| 
       446 
     | 
    
         
            -
                   
     | 
| 
       447 
     | 
    
         
            -
             
     | 
| 
      
 448 
     | 
    
         
            +
                  if (all || includes.words.hierarchy) {
         
     | 
| 
      
 449 
     | 
    
         
            +
                    const hierarchy = config.config.words.hierarchy || []
         
     | 
| 
      
 450 
     | 
    
         
            +
                    configForTest.words.hierarchy = hierarchy.map((hierarchy) => Object.assign({}, hierarchy, { uuid: undefined }))
         
     | 
| 
      
 451 
     | 
    
         
            +
                  }
         
     | 
| 
       448 
452 
     | 
    
         
             
                } else if (key === 'operators') {
         
     | 
| 
       449 
453 
     | 
    
         
             
                  let include = (operator) => true
         
     | 
| 
       450 
454 
     | 
    
         
             
                  if (Array.isArray(includes.operators)) {
         
     | 
| 
         @@ -893,6 +897,10 @@ const defaultInnerProcess = (config, errorHandler, responses) => { 
     | 
|
| 
       893 
897 
     | 
    
         
             
                console.log(JSON.stringify(pickedResultContexts, null, 2))
         
     | 
| 
       894 
898 
     | 
    
         
             
              }
         
     | 
| 
       895 
899 
     | 
    
         | 
| 
      
 900 
     | 
    
         
            +
              const actualConfig = sortJson(convertToStable(getConfigForTest(config, config.testConfig)), { depth: 25 })
         
     | 
| 
      
 901 
     | 
    
         
            +
              console.log('--- Config showing only the checked values')
         
     | 
| 
      
 902 
     | 
    
         
            +
              console.log(JSON.stringify(actualConfig, null, 2))
         
     | 
| 
      
 903 
     | 
    
         
            +
             
     | 
| 
       896 
904 
     | 
    
         
             
              console.log('--- The contexts are ----------')
         
     | 
| 
       897 
905 
     | 
    
         
             
              console.log(JSON.stringify(sortJson(responses.contexts, { depth: 25 }), null, 2))
         
     | 
| 
       898 
906 
     | 
    
         
             
              console.log('')
         
     | 
    
        package/package.json
    CHANGED
    
    | 
         @@ -22,6 +22,7 @@ 
     | 
|
| 
       22 
22 
     | 
    
         
             
                "to": "node node_modules/.bin/jest --runInBand -t NEO23",
         
     | 
| 
       23 
23 
     | 
    
         
             
                "tos": "node node_modules/.bin/jest --runInBand -t NEOS23",
         
     | 
| 
       24 
24 
     | 
    
         
             
                "test": "jest --config ./jest.config.json",
         
     | 
| 
      
 25 
     | 
    
         
            +
                "test:python": "node node_modules/.bin/jest --runInBand -t PYTHON",
         
     | 
| 
       25 
26 
     | 
    
         
             
                "test:watch": "npm run test -- --watch"
         
     | 
| 
       26 
27 
     | 
    
         
             
              },
         
     | 
| 
       27 
28 
     | 
    
         
             
              "keywords": [
         
     | 
| 
         @@ -70,6 +71,6 @@ 
     | 
|
| 
       70 
71 
     | 
    
         
             
                "sort-json": "^2.0.0",
         
     | 
| 
       71 
72 
     | 
    
         
             
                "uuid": "^8.3.2"
         
     | 
| 
       72 
73 
     | 
    
         
             
              },
         
     | 
| 
       73 
     | 
    
         
            -
              "version": "9.4.5-beta. 
     | 
| 
      
 74 
     | 
    
         
            +
              "version": "9.4.5-beta.5",
         
     | 
| 
       74 
75 
     | 
    
         
             
              "license": "UNLICENSED"
         
     | 
| 
       75 
76 
     | 
    
         
             
            }
         
     | 
    
        package/src/config.js
    CHANGED
    
    | 
         @@ -207,11 +207,10 @@ const validConfigProps = (config) => { 
     | 
|
| 
       207 
207 
     | 
    
         | 
| 
       208 
208 
     | 
    
         
             
            const setupInitializerFNArgs = (config, args) => {
         
     | 
| 
       209 
209 
     | 
    
         
             
              const aw = (word, def) => config.addWord(word, def, args.uuid)
         
     | 
| 
       210 
     | 
    
         
            -
              const ap = (pattern, def) => config.addPattern(pattern,  
     | 
| 
      
 210 
     | 
    
         
            +
              const ap = (pattern, def) => config.addPattern(pattern, args.uuid)
         
     | 
| 
       211 
211 
     | 
    
         
             
              const ag = (generator) => config.addGenerator(generator, args.uuid, config.name)
         
     | 
| 
       212 
212 
     | 
    
         
             
              const km = (name) => config.getConfig(name)
         
     | 
| 
       213 
213 
     | 
    
         
             
              const apis = (name) => config.getConfig(name).api
         
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
       215 
214 
     | 
    
         
             
              return {
         
     | 
| 
       216 
215 
     | 
    
         
             
                ...args,
         
     | 
| 
       217 
216 
     | 
    
         
             
                addWord: aw,
         
     | 
| 
         @@ -1653,7 +1652,7 @@ class Config { 
     | 
|
| 
       1653 
1652 
     | 
    
         
             
                this._delta.json.words.push({ action: 'add', word, def })
         
     | 
| 
       1654 
1653 
     | 
    
         
             
              }
         
     | 
| 
       1655 
1654 
     | 
    
         | 
| 
       1656 
     | 
    
         
            -
              addPattern (pattern,  
     | 
| 
      
 1655 
     | 
    
         
            +
              addPattern (pattern, uuid) {
         
     | 
| 
       1657 
1656 
     | 
    
         
             
                if (!this.config.words) {
         
     | 
| 
       1658 
1657 
     | 
    
         
             
                  this.config.words = {
         
     | 
| 
       1659 
1658 
     | 
    
         
             
                    literals: {},
         
     | 
| 
         @@ -1662,10 +1661,11 @@ class Config { 
     | 
|
| 
       1662 
1661 
     | 
    
         
             
                  }
         
     | 
| 
       1663 
1662 
     | 
    
         
             
                }
         
     | 
| 
       1664 
1663 
     | 
    
         | 
| 
      
 1664 
     | 
    
         
            +
                pattern.defs = pattern.defs.map((def) => Object.assign({}, def, { uuid: uuid || this._uuid }) )
         
     | 
| 
      
 1665 
     | 
    
         
            +
             
     | 
| 
       1665 
1666 
     | 
    
         
             
                const patterns = this.config.words.patterns
         
     | 
| 
       1666 
     | 
    
         
            -
                 
     | 
| 
       1667 
     | 
    
         
            -
                 
     | 
| 
       1668 
     | 
    
         
            -
                this._delta.json.words.push({ action: 'add', pattern, defs: [def] })
         
     | 
| 
      
 1667 
     | 
    
         
            +
                patterns.unshift(pattern)
         
     | 
| 
      
 1668 
     | 
    
         
            +
                this._delta.json.words.push({ action: 'add', pattern })
         
     | 
| 
       1669 
1669 
     | 
    
         
             
              }
         
     | 
| 
       1670 
1670 
     | 
    
         | 
| 
       1671 
1671 
     | 
    
         
             
              getAPI (uuid) {
         
     | 
    
        package/src/configHelpers.js
    CHANGED
    
    | 
         @@ -129,6 +129,10 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => { 
     | 
|
| 
       129 
129 
     | 
    
         
             
              }
         
     | 
| 
       130 
130 
     | 
    
         
             
              args.log = (message) => logs.push(message)
         
     | 
| 
       131 
131 
     | 
    
         | 
| 
      
 132 
     | 
    
         
            +
              args.addWord = (word, def) => config.addWord(word, def, args.uuid)
         
     | 
| 
      
 133 
     | 
    
         
            +
              args.addPattern = (pattern, def) => config.addPattern(pattern, args.uuid)
         
     | 
| 
      
 134 
     | 
    
         
            +
              args.addGenerator = (generator) => config.addGenerator(generator, args.uuid, config.name)
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
       132 
136 
     | 
    
         
             
              args.addAssumedScoped = (args, assumed) => {
         
     | 
| 
       133 
137 
     | 
    
         
             
                const addAssumed = (args, ...moreAssumed) => {
         
     | 
| 
       134 
138 
     | 
    
         
             
                  return { ...args, assumed: Object.assign({}, assumed, (args.assumed || {}), ...moreAssumed) }
         
     |