theprogrammablemind 9.4.5 → 9.5.0
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 +7 -7
- package/src/configHelpers.js +17 -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.
|
|
74
|
+
"version": "9.5.0",
|
|
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,
|
|
@@ -490,7 +489,7 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
|
|
|
490
489
|
moreConfig.bridges = moreConfig.bridges.map((bridge) => {
|
|
491
490
|
bridge = { ...bridge }
|
|
492
491
|
const valid = ['after', 'conditional', 'associations', 'before', 'bridge', 'check', 'disabled', 'development', 'skipable', 'return_type_selector', 'evaluator', 'evaluators', 'generatorp', 'generatorr', 'generatorpr', 'generators', 'operator', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
|
|
493
|
-
'level', 'optional', 'selector', 'semantic', 'semantics', 'words', /Bridge$/, 'localHierarchy', 'levelSpecificHierarchy', 'where', 'uuid']
|
|
492
|
+
'level', 'optional', 'selector', 'separators', 'semantic', 'semantics', 'words', /Bridge$/, 'localHierarchy', 'levelSpecificHierarchy', 'where', 'uuid']
|
|
494
493
|
helpers.validProps(valid, bridge, 'bridge')
|
|
495
494
|
handleBridgeProps(baseConfig, bridge, { addFirst, uuid })
|
|
496
495
|
return bridge
|
|
@@ -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
|
@@ -15,6 +15,7 @@ const gs = (g) => async (contexts, separator, lastSeparator) => {
|
|
|
15
15
|
lastSeparator = separator
|
|
16
16
|
}
|
|
17
17
|
let nextSeparator = ''
|
|
18
|
+
let lastEnd = 0
|
|
18
19
|
for (let i = 0; i < contexts.length; ++i) {
|
|
19
20
|
const context = contexts[i]
|
|
20
21
|
const value = await g(context)
|
|
@@ -25,6 +26,10 @@ const gs = (g) => async (contexts, separator, lastSeparator) => {
|
|
|
25
26
|
nextSeparator = separator
|
|
26
27
|
}
|
|
27
28
|
}
|
|
29
|
+
if (lastEnd + 1 == context.range?.start) {
|
|
30
|
+
nextSeparator = ''
|
|
31
|
+
}
|
|
32
|
+
lastEnd = context.range?.end
|
|
28
33
|
s += nextSeparator + value
|
|
29
34
|
}
|
|
30
35
|
return s
|
|
@@ -124,6 +129,10 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
124
129
|
}
|
|
125
130
|
args.log = (message) => logs.push(message)
|
|
126
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
|
+
|
|
127
136
|
args.addAssumedScoped = (args, assumed) => {
|
|
128
137
|
const addAssumed = (args, ...moreAssumed) => {
|
|
129
138
|
return { ...args, assumed: Object.assign({}, assumed, (args.assumed || {}), ...moreAssumed) }
|
|
@@ -462,6 +471,14 @@ const loadInstance = async (config, instance) => {
|
|
|
462
471
|
|
|
463
472
|
const uuid = config.nameToUUID(instance.name)
|
|
464
473
|
setupArgs(args, config, config.logs, hierarchy, uuid)
|
|
474
|
+
if (config.name == instance.name) {
|
|
475
|
+
args.isModule = !!config.isModule
|
|
476
|
+
args.isProcess = !config.isModule
|
|
477
|
+
} else {
|
|
478
|
+
// only main can load as process
|
|
479
|
+
args.isModule = true
|
|
480
|
+
args.isProcess = false
|
|
481
|
+
}
|
|
465
482
|
await results.apply(args)
|
|
466
483
|
} else if (results.isFragment) {
|
|
467
484
|
} else {
|