theprogrammablemind 7.12.4-beta.0 → 7.12.4-beta.1
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 +56 -17
- package/package.json +1 -1
- package/src/config.js +7 -6
package/client.js
CHANGED
@@ -14,8 +14,17 @@ const { appendNoDups, InitCalls, updateQueries, safeNoDups } = require('./src/he
|
|
14
14
|
const runtime = require('./runtime')
|
15
15
|
const sortJson = runtime.sortJson
|
16
16
|
|
17
|
-
const getConfig_getObjectsCheck = (testConfig) => {
|
18
|
-
|
17
|
+
const getConfig_getObjectsCheck = (config, testConfig) => {
|
18
|
+
let testConfigName = config.name
|
19
|
+
if (testConfig.testModuleName) {
|
20
|
+
testConfigName = testConfig.testModuleName
|
21
|
+
}
|
22
|
+
const checks = (testConfig.checks && testConfig.checks.objects) || []
|
23
|
+
if (Array.isArray(checks)) {
|
24
|
+
return { [testConfigName]: checks }
|
25
|
+
} else {
|
26
|
+
return checks
|
27
|
+
}
|
19
28
|
}
|
20
29
|
|
21
30
|
const getConfig_getContextCheck = (testConfig) => {
|
@@ -26,8 +35,24 @@ const pickContext = (testConfig) => (context) => {
|
|
26
35
|
return project(context, getConfig_getContextCheck(testConfig))
|
27
36
|
}
|
28
37
|
|
29
|
-
const pickObjects = (testConfig,
|
30
|
-
|
38
|
+
const pickObjects = (config, testConfig, getObjects) => {
|
39
|
+
/*
|
40
|
+
let testConfigName = config.name
|
41
|
+
if (testConfig.testModuleName) {
|
42
|
+
objects = getObjects(config.config.objects)(config.getConfigs()[testConfig.testModuleName].uuid)
|
43
|
+
testConfigName = testConfig.testModuleName
|
44
|
+
}
|
45
|
+
*/
|
46
|
+
const checks = getConfig_getObjectsCheck(config, testConfig)
|
47
|
+
const projection = {}
|
48
|
+
for (let km in checks) {
|
49
|
+
const objects = getObjects(km)
|
50
|
+
if (!objects) {
|
51
|
+
throw new Error(`In the checks for ${config.name} the KM ${km} does not exist`)
|
52
|
+
}
|
53
|
+
projection[km] = project(objects, checks[km])
|
54
|
+
}
|
55
|
+
return projection
|
31
56
|
}
|
32
57
|
|
33
58
|
// move ask to the KM's since verbatim is called
|
@@ -105,6 +130,9 @@ const vimdiff = (actualJSON, expectedJSON, title) => {
|
|
105
130
|
}
|
106
131
|
|
107
132
|
const listable = (hierarchy) => (c, type) => {
|
133
|
+
if (!c) {
|
134
|
+
return false
|
135
|
+
}
|
108
136
|
if (hierarchy.isA(c.marker, type)) {
|
109
137
|
return true
|
110
138
|
}
|
@@ -119,6 +147,9 @@ const listable = (hierarchy) => (c, type) => {
|
|
119
147
|
}
|
120
148
|
|
121
149
|
const isA = (hierarchy) => (child, parent) => {
|
150
|
+
if (!child || !parent) {
|
151
|
+
return false
|
152
|
+
}
|
122
153
|
if (child.marker) {
|
123
154
|
child = child.marker
|
124
155
|
}
|
@@ -148,6 +179,7 @@ class ErrorReason extends Error {
|
|
148
179
|
|
149
180
|
const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
150
181
|
config.setArgs(args)
|
182
|
+
// callId
|
151
183
|
args.calls = new InitCalls(args.isInstance ? `${args.isInstance}#${config.name}` : config.name)
|
152
184
|
if (global.theprogrammablemind && global.theprogrammablemind.loadForTesting) {
|
153
185
|
args.calls = new InitCalls(Object.keys(global.theprogrammablemind.loadForTesting)[0])
|
@@ -657,10 +689,8 @@ const loadInstance = (config, instance) => {
|
|
657
689
|
config.config.skipSemantics = results.skipSemantics
|
658
690
|
}
|
659
691
|
const args = { config, hierarchy, json: results, commandLineArgs: {} }
|
660
|
-
|
661
|
-
|
662
|
-
args.instance = instance.queries[i]
|
663
|
-
}
|
692
|
+
args.isInstance = `instance${i}`
|
693
|
+
args.instance = ''
|
664
694
|
processContextsB(args)
|
665
695
|
if (results.skipSemantics) {
|
666
696
|
config.config.skipSemantics = null
|
@@ -852,11 +882,6 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug }) =
|
|
852
882
|
}
|
853
883
|
|
854
884
|
let objects = getObjects(config.config.objects)(config.uuid)
|
855
|
-
let testConfigName = config.name
|
856
|
-
if (testConfig.testModuleName) {
|
857
|
-
objects = getObjects(config.config.objects)(config.getConfigs()[testConfig.testModuleName].uuid)
|
858
|
-
testConfigName = testConfig.testModuleName
|
859
|
-
}
|
860
885
|
try {
|
861
886
|
const result = await _process(config, test, { errorHandler, isTest: true })
|
862
887
|
result.query = test
|
@@ -896,7 +921,7 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug }) =
|
|
896
921
|
}
|
897
922
|
return expected.objects.namespaced[expected.objects.nameToUUID[name]] || {}
|
898
923
|
}
|
899
|
-
const expected_checked = sortJson(pickObjects(testConfig, expectedGetObjects
|
924
|
+
const expected_checked = sortJson(pickObjects(config, testConfig, expectedGetObjects), { depth: 25 })
|
900
925
|
const actualGetObjects = (name) => {
|
901
926
|
if (!name) {
|
902
927
|
name = config.name
|
@@ -904,7 +929,7 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug }) =
|
|
904
929
|
const km = config.configs.find((km) => km.name == name)
|
905
930
|
return config.config.objects.namespaced[km.uuid] || {}
|
906
931
|
}
|
907
|
-
const actual_checked = sortJson(pickObjects(testConfig, actualGetObjects
|
932
|
+
const actual_checked = sortJson(pickObjects(config, testConfig, actualGetObjects), { depth: 25 })
|
908
933
|
const failed_checked = !matching(actual_objects, expected_objects)
|
909
934
|
|
910
935
|
const failed_checks = !matching(actual_objects, expected_objects)
|
@@ -1233,8 +1258,15 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
|
|
1233
1258
|
console.log(` inputs: ${JSON.stringify(inputs)} output: ${JSON.stringify(output)} reason: ${reason}`)
|
1234
1259
|
}
|
1235
1260
|
}
|
1236
|
-
const objects = config.get('objects').namespaced[config.uuid]
|
1237
|
-
const
|
1261
|
+
// const objects = config.get('objects').namespaced[config.uuid]
|
1262
|
+
const actualGetObjects = (name) => {
|
1263
|
+
if (!name) {
|
1264
|
+
name = config.name
|
1265
|
+
}
|
1266
|
+
const km = config.configs.find((km) => km.name == name)
|
1267
|
+
return config.config.objects.namespaced[km.uuid] || {}
|
1268
|
+
}
|
1269
|
+
const picked = sortJson(pickObjects(config, config.testConfig, actualGetObjects), { depth: 25 })
|
1238
1270
|
if (!_.isEmpty(picked)) {
|
1239
1271
|
console.log('--- Object showing only the checked values ---')
|
1240
1272
|
console.log(JSON.stringify(picked, null, 2))
|
@@ -2046,6 +2078,13 @@ const knowledgeModuleImpl = async ({
|
|
2046
2078
|
})
|
2047
2079
|
f()
|
2048
2080
|
} else if (args.query) {
|
2081
|
+
let useTestConfig = testConfig
|
2082
|
+
if (args.testModuleName) {
|
2083
|
+
config.testConfig.testModuleName = args.testModuleName
|
2084
|
+
config.testConfig.checks = config.getConfigs()[args.testModuleName].getTestConfig().checks
|
2085
|
+
// useTestConfig = config.getConfigs()[args.testModuleName].getTestConfig()
|
2086
|
+
// useTestConfig.testModuleName = args.testModuleName
|
2087
|
+
}
|
2049
2088
|
const objects = getObjects(config.config.objects)(config.uuid)
|
2050
2089
|
// for the compare
|
2051
2090
|
if (args.objectDiff) {
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -199,7 +199,7 @@ const priority_valid = (cp) => {
|
|
199
199
|
)
|
200
200
|
}
|
201
201
|
|
202
|
-
const handleBridgeProps = (config, bridge, addFirst) => {
|
202
|
+
const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
203
203
|
ecatch(`While processing the bridge for ${bridge.id}#${bridge.level}`,
|
204
204
|
() => {
|
205
205
|
if (!bridge.bridge) {
|
@@ -260,7 +260,8 @@ const handleBridgeProps = (config, bridge, addFirst) => {
|
|
260
260
|
}
|
261
261
|
*/
|
262
262
|
|
263
|
-
const addUUID = (obj) => { return { ...obj, uuid: config.uuid } }
|
263
|
+
const addUUID = (obj) => { return { ...obj, uuid: uuid || config.uuid } }
|
264
|
+
|
264
265
|
if (bridge.generators) {
|
265
266
|
const generators = [...bridge.generators]
|
266
267
|
generators.reverse()
|
@@ -343,14 +344,14 @@ const handleBridgeProps = (config, bridge, addFirst) => {
|
|
343
344
|
)
|
344
345
|
}
|
345
346
|
|
346
|
-
const handleCalculatedProps = (baseConfig, moreConfig, addFirst) => {
|
347
|
+
const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {}) => {
|
347
348
|
if (moreConfig.bridges) {
|
348
349
|
moreConfig.bridges = moreConfig.bridges.map((bridge) => {
|
349
350
|
bridge = { ...bridge }
|
350
351
|
const valid = ['after', 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generatorpr', 'generators', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
|
351
352
|
'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy', 'levelSpecificHierarchy', 'where', 'uuid']
|
352
353
|
helpers.validProps(valid, bridge, 'bridge')
|
353
|
-
handleBridgeProps(baseConfig, bridge, addFirst)
|
354
|
+
handleBridgeProps(baseConfig, bridge, { addFirst, uuid })
|
354
355
|
return bridge
|
355
356
|
})
|
356
357
|
}
|
@@ -1314,7 +1315,7 @@ class Config {
|
|
1314
1315
|
if (global.transitoryMode) {
|
1315
1316
|
def.transitoryMode = true
|
1316
1317
|
}
|
1317
|
-
handleBridgeProps(this, def)
|
1318
|
+
handleBridgeProps(this, def, { uuid })
|
1318
1319
|
bridges.push(def)
|
1319
1320
|
this.checkBridges()
|
1320
1321
|
this._delta.json.bridges.push({ action: 'add', bridge: def })
|
@@ -2842,7 +2843,7 @@ class Config {
|
|
2842
2843
|
debugConfigProps(more)
|
2843
2844
|
|
2844
2845
|
if (hcps) {
|
2845
|
-
handleCalculatedProps(this, more, addFirst)
|
2846
|
+
handleCalculatedProps(this, more, { addFirst, uuid })
|
2846
2847
|
applyUUID(more, uuid || this._uuid)
|
2847
2848
|
}
|
2848
2849
|
for (const key of Object.keys(more)) {
|