theprogrammablemind_4wp 7.12.3 → 7.12.4-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/client.js +117 -41
- package/package.json +1 -1
- package/src/config.js +78 -58
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
|
@@ -89,12 +114,12 @@ const sameJSON = (json1, json2) => {
|
|
89
114
|
return JSON.stringify(sjson1) == JSON.stringify(sjson2)
|
90
115
|
}
|
91
116
|
|
92
|
-
const vimdiff = (actualJSON, expectedJSON) => {
|
117
|
+
const vimdiff = (actualJSON, expectedJSON, title) => {
|
93
118
|
const path = '.'
|
94
119
|
const actual = sortJson(actualJSON, { depth: 25 })
|
95
|
-
runtime.fs.writeFileSync(`${path}/actual.json`, JSON.stringify(actual, 0, 2))
|
120
|
+
runtime.fs.writeFileSync(`${path}/actual.json`, JSON.stringify({ title, actual}, 0, 2))
|
96
121
|
const expected = sortJson(expectedJSON, { depth: 25 })
|
97
|
-
runtime.fs.writeFileSync(`${path}/expected.json`, JSON.stringify(expected, 0, 2))
|
122
|
+
runtime.fs.writeFileSync(`${path}/expected.json`, JSON.stringify({ title, expected}, 0, 2))
|
98
123
|
// console.log(`vimdiff ${path}/actual.json ${path}/expected.json`)
|
99
124
|
{
|
100
125
|
const editor = runtime.process.env.EDITOR || 'vimdiff'
|
@@ -105,6 +130,9 @@ const vimdiff = (actualJSON, expectedJSON) => {
|
|
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])
|
@@ -196,7 +228,7 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
196
228
|
|
197
229
|
args.addAssumedScoped = (args, assumed) => {
|
198
230
|
const addAssumed = (args, ...moreAssumed) => {
|
199
|
-
return { ...args, assumed: Object.assign({}, (args.assumed || {}), ...moreAssumed) }
|
231
|
+
return { ...args, assumed: Object.assign({}, assumed, (args.assumed || {}), ...moreAssumed) }
|
200
232
|
}
|
201
233
|
|
202
234
|
args.s = (c) => config.getSemantics(logs).apply(args, c)
|
@@ -638,7 +670,9 @@ const loadInstance = (config, instance) => {
|
|
638
670
|
// config.addInternal(results, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false)
|
639
671
|
// config.addInternal(config.template.queries[i], { handleCalculatedProps: true } )
|
640
672
|
const uuid = config.nameToUUID(instance.name)
|
641
|
-
|
673
|
+
// used to do a CLONE
|
674
|
+
// config.addInternal(_.cloneDeep(instance.template.queries[i]), { uuid, addFirst: true, handleCalculatedProps: true })
|
675
|
+
config.addInternal(instance.template.queries[i], { uuid, addFirst: true, handleCalculatedProps: true })
|
642
676
|
} else if (results.apply) {
|
643
677
|
const objects = config.get('objects')
|
644
678
|
const args = { objects, getObjects: getObjects(objects) }
|
@@ -655,10 +689,8 @@ const loadInstance = (config, instance) => {
|
|
655
689
|
config.config.skipSemantics = results.skipSemantics
|
656
690
|
}
|
657
691
|
const args = { config, hierarchy, json: results, commandLineArgs: {} }
|
658
|
-
|
659
|
-
|
660
|
-
args.instance = instance.queries[i]
|
661
|
-
}
|
692
|
+
args.isInstance = `instance${i}`
|
693
|
+
args.instance = ''
|
662
694
|
processContextsB(args)
|
663
695
|
if (results.skipSemantics) {
|
664
696
|
config.config.skipSemantics = null
|
@@ -775,6 +807,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
775
807
|
response.trace = response.trace.concat(json.trace)
|
776
808
|
response.version = json.version
|
777
809
|
response.explain_priorities = json.explain_priorities
|
810
|
+
response.contextual_priorities_ambiguities = json.contextual_priorities_ambiguities
|
778
811
|
|
779
812
|
response.contexts = response.contexts.concat(contextsPrime)
|
780
813
|
response.generated = response.generated.concat(generatedPrime)
|
@@ -849,11 +882,6 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug }) =
|
|
849
882
|
}
|
850
883
|
|
851
884
|
let objects = getObjects(config.config.objects)(config.uuid)
|
852
|
-
let testConfigName = config.name
|
853
|
-
if (testConfig.testModuleName) {
|
854
|
-
objects = getObjects(config.config.objects)(config.getConfigs()[testConfig.testModuleName].uuid)
|
855
|
-
testConfigName = testConfig.testModuleName
|
856
|
-
}
|
857
885
|
try {
|
858
886
|
const result = await _process(config, test, { errorHandler, isTest: true })
|
859
887
|
result.query = test
|
@@ -893,7 +921,7 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug }) =
|
|
893
921
|
}
|
894
922
|
return expected.objects.namespaced[expected.objects.nameToUUID[name]] || {}
|
895
923
|
}
|
896
|
-
const expected_checked = sortJson(pickObjects(testConfig, expectedGetObjects
|
924
|
+
const expected_checked = sortJson(pickObjects(config, testConfig, expectedGetObjects), { depth: 25 })
|
897
925
|
const actualGetObjects = (name) => {
|
898
926
|
if (!name) {
|
899
927
|
name = config.name
|
@@ -901,7 +929,7 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug }) =
|
|
901
929
|
const km = config.configs.find((km) => km.name == name)
|
902
930
|
return config.config.objects.namespaced[km.uuid] || {}
|
903
931
|
}
|
904
|
-
const actual_checked = sortJson(pickObjects(testConfig, actualGetObjects
|
932
|
+
const actual_checked = sortJson(pickObjects(config, testConfig, actualGetObjects), { depth: 25 })
|
905
933
|
const failed_checked = !matching(actual_objects, expected_objects)
|
906
934
|
|
907
935
|
const failed_checks = !matching(actual_objects, expected_objects)
|
@@ -1153,6 +1181,24 @@ const defaultErrorHandler = async (error) => {
|
|
1153
1181
|
throw error
|
1154
1182
|
}
|
1155
1183
|
|
1184
|
+
const printContextualPrioritiesAmbiguities = (cpa) => {
|
1185
|
+
console.log('Contextual Priorities Ambiguities')
|
1186
|
+
for (const counter in cpa) {
|
1187
|
+
console.log(` Counter ${counter}`)
|
1188
|
+
for (const choices of cpa[counter]) {
|
1189
|
+
console.log(' [')
|
1190
|
+
for (const choice of choices) {
|
1191
|
+
console.log(' [')
|
1192
|
+
for (const element of choice) {
|
1193
|
+
console.log(` ${JSON.stringify(element)},`)
|
1194
|
+
}
|
1195
|
+
console.log(' ],')
|
1196
|
+
}
|
1197
|
+
console.log(' ],')
|
1198
|
+
}
|
1199
|
+
}
|
1200
|
+
}
|
1201
|
+
|
1156
1202
|
const defaultInnerProcess = (config, errorHandler, responses) => {
|
1157
1203
|
if (responses.errors) {
|
1158
1204
|
console.log('Errors')
|
@@ -1171,6 +1217,9 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
|
|
1171
1217
|
console.log('Logs')
|
1172
1218
|
responses.logs.forEach((log) => console.log(` ${log}`))
|
1173
1219
|
}
|
1220
|
+
if (responses.contextual_priorities_ambiguities) {
|
1221
|
+
printContextualPrioritiesAmbiguities(responses.contextual_priorities_ambiguities)
|
1222
|
+
}
|
1174
1223
|
console.log(responses.trace)
|
1175
1224
|
|
1176
1225
|
if (global.beforeObjects) {
|
@@ -1209,8 +1258,15 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
|
|
1209
1258
|
console.log(` inputs: ${JSON.stringify(inputs)} output: ${JSON.stringify(output)} reason: ${reason}`)
|
1210
1259
|
}
|
1211
1260
|
}
|
1212
|
-
const objects = config.get('objects').namespaced[config.uuid]
|
1213
|
-
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 })
|
1214
1270
|
if (!_.isEmpty(picked)) {
|
1215
1271
|
console.log('--- Object showing only the checked values ---')
|
1216
1272
|
console.log(JSON.stringify(picked, null, 2))
|
@@ -1464,6 +1520,7 @@ const knowledgeModuleImpl = async ({
|
|
1464
1520
|
errorHandler = defaultErrorHandler,
|
1465
1521
|
process: processResults = defaultProcess,
|
1466
1522
|
stopAtFirstFailure = true,
|
1523
|
+
acceptsAdditionalConfig = false,
|
1467
1524
|
...rest
|
1468
1525
|
} = {}) => {
|
1469
1526
|
/*
|
@@ -1843,34 +1900,33 @@ const knowledgeModuleImpl = async ({
|
|
1843
1900
|
if (results.length > 0) {
|
1844
1901
|
let headerShown = false
|
1845
1902
|
|
1846
|
-
let
|
1903
|
+
let hasError = false
|
1847
1904
|
for (const result of results) {
|
1848
|
-
let hasError = false
|
1849
1905
|
if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
|
1850
|
-
hasError = true
|
1906
|
+
result.hasError = true
|
1851
1907
|
}
|
1852
1908
|
if (!args.testNoParenthesized) {
|
1853
1909
|
if (JSON.stringify(result.expected.paraphrasesParenthesized) !== JSON.stringify(result.actual.paraphrasesParenthesized)) {
|
1854
|
-
hasError = true
|
1910
|
+
result.hasError = true
|
1855
1911
|
}
|
1856
1912
|
if (JSON.stringify(result.expected.generatedParenthesized) !== JSON.stringify(result.actual.generatedParenthesized)) {
|
1857
|
-
hasError = true
|
1913
|
+
result.hasError = true
|
1858
1914
|
}
|
1859
1915
|
}
|
1860
1916
|
if (JSON.stringify(result.expected.responses) !== JSON.stringify(result.actual.responses)) {
|
1861
|
-
hasError = true
|
1917
|
+
result.hasError = true
|
1862
1918
|
}
|
1863
1919
|
if (JSON.stringify(result.expected.checked) !== JSON.stringify(result.actual.checked)) {
|
1864
|
-
hasError = true
|
1920
|
+
result.hasError = true
|
1865
1921
|
}
|
1866
1922
|
if (!sameJSON(result.expected.checkedContexts, result.actual.checkedContexts)) {
|
1867
|
-
hasError = true
|
1923
|
+
result.hasError = true
|
1868
1924
|
}
|
1869
|
-
if (hasError) {
|
1870
|
-
|
1925
|
+
if (result.hasError) {
|
1926
|
+
hasError = true
|
1871
1927
|
}
|
1872
1928
|
}
|
1873
|
-
|
1929
|
+
|
1874
1930
|
if (hasError) {
|
1875
1931
|
console.log('**************************** ERRORS ************************')
|
1876
1932
|
for (const result of results) {
|
@@ -1885,21 +1941,20 @@ const knowledgeModuleImpl = async ({
|
|
1885
1941
|
newError = true
|
1886
1942
|
headerShown = true
|
1887
1943
|
if (args.vimdiff) {
|
1888
|
-
vimdiff(
|
1944
|
+
vimdiff(actual, expected, `"${result.utterance}" - ${label}`)
|
1889
1945
|
}
|
1890
|
-
|
1946
|
+
result.hasError = true
|
1891
1947
|
}
|
1892
1948
|
}
|
1893
1949
|
show('paraphrases', result.expected.paraphrases, result.actual.paraphrases)
|
1894
1950
|
if (!args.testNoParenthesized) {
|
1895
1951
|
show('paraphrases parenthesized', result.expected.paraphrasesParenthesized, result.actual.paraphrasesParenthesized)
|
1896
1952
|
}
|
1897
|
-
/*
|
1898
|
-
}
|
1899
1953
|
show('responses', result.expected.responses, result.actual.responses)
|
1900
1954
|
if (!args.testNoParenthesized) {
|
1901
1955
|
show('responses parenthesized', result.expected.generatedParenthesized, result.actual.generatedParenthesized)
|
1902
1956
|
}
|
1957
|
+
/*
|
1903
1958
|
if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
|
1904
1959
|
if (!headerShown) {
|
1905
1960
|
console.log(' Failure')
|
@@ -1972,7 +2027,13 @@ const knowledgeModuleImpl = async ({
|
|
1972
2027
|
if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
|
1973
2028
|
console.log('use -v arg to write files expected.json and actual.json in the current directory for detailed comparison. Or do -s and then git diff the changes.')
|
1974
2029
|
// console.log(JSON.stringify(contexts))
|
1975
|
-
|
2030
|
+
let errorCount = 0
|
2031
|
+
for (const result of results) {
|
2032
|
+
if (result.hasError) {
|
2033
|
+
errorCount += 1
|
2034
|
+
}
|
2035
|
+
}
|
2036
|
+
console.log(`**************************** THERE WERE ${errorCount} TEST FAILURES ************************`)
|
1976
2037
|
}
|
1977
2038
|
}
|
1978
2039
|
}
|
@@ -2017,6 +2078,13 @@ const knowledgeModuleImpl = async ({
|
|
2017
2078
|
})
|
2018
2079
|
f()
|
2019
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
|
+
}
|
2020
2088
|
const objects = getObjects(config.config.objects)(config.uuid)
|
2021
2089
|
// for the compare
|
2022
2090
|
if (args.objectDiff) {
|
@@ -2072,11 +2140,16 @@ const knowledgeModuleImpl = async ({
|
|
2072
2140
|
}
|
2073
2141
|
}
|
2074
2142
|
|
2075
|
-
createConfigExport = () => {
|
2143
|
+
createConfigExport = (additionalConfig) => {
|
2076
2144
|
if (createConfig.cached) {
|
2077
2145
|
return createConfig.cached
|
2078
2146
|
}
|
2079
|
-
const config = createConfig()
|
2147
|
+
const config = createConfig(acceptsAdditionalConfig ? additionalConfig : null)
|
2148
|
+
if (!acceptsAdditionalConfig && additionalConfig) {
|
2149
|
+
config.stop_auto_rebuild()
|
2150
|
+
additionalConfig(config)
|
2151
|
+
config.restart_auto_rebuild()
|
2152
|
+
}
|
2080
2153
|
initConfig(config)
|
2081
2154
|
// config.rebuild({ isModule: true })
|
2082
2155
|
createConfig.cached = config
|
@@ -2132,7 +2205,10 @@ function w (func) {
|
|
2132
2205
|
}
|
2133
2206
|
|
2134
2207
|
const knowledgeModule = async (...args) => {
|
2135
|
-
await knowledgeModuleImpl(...args).catch((e) =>
|
2208
|
+
await knowledgeModuleImpl(...args).catch((e) => {
|
2209
|
+
console.error(e)
|
2210
|
+
process.exit(-1)
|
2211
|
+
})
|
2136
2212
|
}
|
2137
2213
|
|
2138
2214
|
module.exports = {
|
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 })
|
@@ -1742,6 +1743,15 @@ class Config {
|
|
1742
1743
|
this.addedArgss.push(moreArgs)
|
1743
1744
|
}
|
1744
1745
|
|
1746
|
+
stop_auto_rebuild() {
|
1747
|
+
this._stop_auto_rebuild = true
|
1748
|
+
}
|
1749
|
+
|
1750
|
+
restart_auto_rebuild() {
|
1751
|
+
this._stop_auto_rebuild = false
|
1752
|
+
this.rebuild()
|
1753
|
+
}
|
1754
|
+
|
1745
1755
|
getAddedArgs (args) {
|
1746
1756
|
for (let addedArgs of this.addedArgss) {
|
1747
1757
|
addedArgs = addedArgs(args)
|
@@ -2250,6 +2260,9 @@ class Config {
|
|
2250
2260
|
|
2251
2261
|
// rebuild ({ isModule: mainIsModule = false } = {}) {
|
2252
2262
|
rebuild ({ isModule: mainIsModule } = {}) {
|
2263
|
+
if (this._stop_auto_rebuild) {
|
2264
|
+
return
|
2265
|
+
}
|
2253
2266
|
this.resetDelta()
|
2254
2267
|
const debug = this.config.debug
|
2255
2268
|
this.config = _.cloneDeep(this.initConfig)
|
@@ -2746,63 +2759,70 @@ class Config {
|
|
2746
2759
|
}
|
2747
2760
|
}
|
2748
2761
|
|
2749
|
-
add (
|
2750
|
-
|
2751
|
-
|
2752
|
-
|
2753
|
-
|
2754
|
-
|
2755
|
-
}
|
2762
|
+
add (...mores) {
|
2763
|
+
mores.forEach((km) => {
|
2764
|
+
if (km === this) {
|
2765
|
+
throw new Error('Cannot add an object to itself.')
|
2766
|
+
}
|
2767
|
+
})
|
2756
2768
|
|
2757
|
-
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
more.server(this._server, this._key, this._queryParams)
|
2762
|
-
|
2763
|
-
this.loadOrder.addList(more.configs.map((km) => km.name || km.uuid))
|
2764
|
-
|
2765
|
-
// get the new ones
|
2766
|
-
// remove the dups
|
2767
|
-
// run the initialize one all new ones
|
2768
|
-
// this.configs = this.configs.concat(new KM({config: more}));
|
2769
|
-
// only set for the first one the rest have it set
|
2770
|
-
const namespace = this._namespace.concat(more._namespace)
|
2771
|
-
const moreKMs1 = [new KM({ config: more, getCounter: (name) => this.getCounter(name), uuid: more.uuid, namespace })]
|
2772
|
-
const moreKMs2 = more.configs.slice(1).map((km) => {
|
2769
|
+
mores = mores.map((km) => {
|
2770
|
+
if (!(km instanceof Config)) {
|
2771
|
+
km = new Config(km)
|
2772
|
+
}
|
2773
2773
|
return km
|
2774
|
-
// const cp = km.copy()
|
2775
|
-
// cp.namespace = namespace
|
2776
|
-
// return cp;
|
2777
2774
|
})
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2775
|
+
|
2776
|
+
mores.forEach((more) => {
|
2777
|
+
this.valid()
|
2778
|
+
more.valid()
|
2779
|
+
// copy so i don't have to copy later
|
2780
|
+
more = more.copy()
|
2781
|
+
more.server(this._server, this._key, this._queryParams)
|
2782
|
+
|
2783
|
+
this.loadOrder.addList(more.configs.map((km) => km.name || km.uuid))
|
2784
|
+
|
2785
|
+
// get the new ones
|
2786
|
+
// remove the dups
|
2787
|
+
// run the initialize one all new ones
|
2788
|
+
// this.configs = this.configs.concat(new KM({config: more}));
|
2789
|
+
// only set for the first one the rest have it set
|
2790
|
+
const namespace = this._namespace.concat(more._namespace)
|
2791
|
+
const moreKMs1 = [new KM({ config: more, getCounter: (name) => this.getCounter(name), uuid: more.uuid, namespace })]
|
2792
|
+
const moreKMs2 = more.configs.slice(1).map((km) => {
|
2793
|
+
return km
|
2794
|
+
// const cp = km.copy()
|
2795
|
+
// cp.namespace = namespace
|
2796
|
+
// return cp;
|
2797
|
+
})
|
2798
|
+
const moreKMs = moreKMs1.concat(moreKMs2)
|
2799
|
+
const eqClass = moreKMs.map((km) => km.uuid)
|
2800
|
+
this._eqClasses.push(eqClass)
|
2801
|
+
// look for dups and combine them with the eqclasses
|
2802
|
+
for (const moreKM of moreKMs) {
|
2803
|
+
const existingKM = this.configs.find((km) => moreKM._name && km.name === moreKM.name)
|
2804
|
+
if (existingKM) {
|
2805
|
+
this.addEqClass(existingKM, moreKM)
|
2806
|
+
} else {
|
2807
|
+
this.configs.push(moreKM)
|
2808
|
+
}
|
2788
2809
|
}
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
|
2793
|
-
|
2794
|
-
|
2795
|
-
|
2796
|
-
|
2797
|
-
|
2798
|
-
|
2799
|
-
|
2800
|
-
|
2801
|
-
|
2810
|
+
more.resetToOne()
|
2811
|
+
this.config.eqClasses = this._eqClasses
|
2812
|
+
// greg
|
2813
|
+
// setup instances
|
2814
|
+
this.instances = []
|
2815
|
+
this.configs.forEach((km) => {
|
2816
|
+
this.instances = (km._config.instances || this.initInstances.slice()).concat(this.instances)
|
2817
|
+
})
|
2818
|
+
const noDups = []
|
2819
|
+
for (const instance of this.instances) {
|
2820
|
+
if (!noDups.find((existing) => existing.name == instance.name)) {
|
2821
|
+
noDups.push(instance)
|
2822
|
+
}
|
2802
2823
|
}
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2824
|
+
this.instances = noDups
|
2825
|
+
})
|
2806
2826
|
this.rebuild()
|
2807
2827
|
this.valid()
|
2808
2828
|
return this
|
@@ -2823,7 +2843,7 @@ class Config {
|
|
2823
2843
|
debugConfigProps(more)
|
2824
2844
|
|
2825
2845
|
if (hcps) {
|
2826
|
-
handleCalculatedProps(this, more, addFirst)
|
2846
|
+
handleCalculatedProps(this, more, { addFirst, uuid })
|
2827
2847
|
applyUUID(more, uuid || this._uuid)
|
2828
2848
|
}
|
2829
2849
|
for (const key of Object.keys(more)) {
|