theprogrammablemind 9.8.0-beta.9 → 9.9.0-beta.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 CHANGED
@@ -16,6 +16,18 @@ const { helpDebugHierarchy, sortJson, appendNoDups, InitCalls, updateQueries, sa
16
16
  const runtime = require('./runtime')
17
17
  const db = require('./src/debug')
18
18
 
19
+ class ErrorJSON extends Error {
20
+ constructor (json) {
21
+ super()
22
+ this.json = json
23
+ }
24
+
25
+ toString() {
26
+ return JSON.stringify(json.error)
27
+ }
28
+
29
+ }
30
+
19
31
  const getConfig_getObjectsCheck = (config, testConfig) => {
20
32
  let testConfigName = config.name
21
33
  if (testConfig.testModuleName) {
@@ -158,13 +170,6 @@ const writeTest = (fn, query, objects, generated, paraphrases, responses, contex
158
170
  if (runtime.fs.existsSync(fn)) {
159
171
  tests = JSON.parse(runtime.fs.readFileSync(fn))
160
172
  }
161
- /*
162
- for (const association of associations) {
163
- association.sort()
164
- }
165
- associations.sort()
166
- */
167
- // tests[query] = sortJson({ paraphrases, responses, contexts, objects: convertToStable(objects), associations, metadata, config, developerTest: saveDeveloper }, { depth: 25 })
168
173
  const results = sortJson({
169
174
  query,
170
175
  summaries,
@@ -189,7 +194,6 @@ const writeTest = (fn, query, objects, generated, paraphrases, responses, contex
189
194
  if (!wasSet) {
190
195
  tests.push(results)
191
196
  }
192
- // fs.writeFileSync(fn, stringify(tests, { space: 2 }), { encoding: 'utf8', flag: 'w+' })
193
197
  writeTestFile(fn, tests)
194
198
  }
195
199
 
@@ -258,7 +262,7 @@ const throwErrorHandler = (error) => {
258
262
  throw error
259
263
  }
260
264
 
261
- const _process = async (config, query, { queryNumber, initializer, commandLineArgs, credentials, writeTests, logs, isProcess, isModule, isTest, saveDeveloper, rebuildingTemplate, testConfig, testsFN, errorHandler = throwErrorHandler } = {}) => {
265
+ const _process = async (config, query, { isFragment, queryNumber, initializer, commandLineArgs, credentials, writeTests, logs, isProcess, isModule, isTest, saveDeveloper, rebuildingTemplate, testConfig, testsFN, errorHandler = throwErrorHandler } = {}) => {
262
266
  if (credentials) {
263
267
  config.server(credentials.server, credentials.key)
264
268
  }
@@ -354,7 +358,7 @@ const _process = async (config, query, { queryNumber, initializer, commandLineAr
354
358
  startCounter = json.end_counter + 1
355
359
  delete json.results
356
360
  if (json.status !== 200) {
357
- throw json
361
+ throw new ErrorJSON(json)
358
362
  } else {
359
363
  let clientSideTime
360
364
  let start
@@ -364,7 +368,7 @@ const _process = async (config, query, { queryNumber, initializer, commandLineAr
364
368
  const summary = { summaries: json.summaries, length: json.contexts.length }
365
369
  summaries.push(summary)
366
370
  const { updatedContextIdCounter, contextsPrime, generatedPrime, paraphrasesPrime, paraphrasesParenthesizedPrime, generatedParenthesizedPrime, responsesPrime } =
367
- await processContextsB({ contextIdCounter, logs, calls, isTest, isProcess, isModule, rebuildingTemplate, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
371
+ await processContextsB({ skipSemantics: isFragment, isFragment, contextIdCounter, logs, calls, isTest, isProcess, isModule, rebuildingTemplate, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
368
372
  contextIdCounter = updatedContextIdCounter
369
373
  if (isTest) {
370
374
  const end = runtime.performance.performance.now()
@@ -384,7 +388,6 @@ const _process = async (config, query, { queryNumber, initializer, commandLineAr
384
388
  response.explain_associations_details = (response.explain_associations_details || []).concat(json.explain_associations_details)
385
389
  response.explain_associations_trie = json.explain_associations_trie
386
390
  response.contextual_priorities_ambiguities = json.contextual_priorities_ambiguities
387
- // response.rtf_associations = json.rtf_associations
388
391
 
389
392
  response.contexts = response.contexts.concat(contextsPrime)
390
393
  response.generated = response.generated.concat(generatedPrime)
@@ -409,9 +412,11 @@ const _process = async (config, query, { queryNumber, initializer, commandLineAr
409
412
 
410
413
  return response
411
414
  } catch (error) {
412
- error.summaries = summaries
413
- error.queryNumber = queryNumber
414
- error.query = query
415
+ if (error.json) {
416
+ error.json.summaries = summaries
417
+ error.json.queryNumber = queryNumber
418
+ error.json.query = query
419
+ }
415
420
  errorHandler(error)
416
421
  }
417
422
  }
@@ -747,30 +752,43 @@ const submitBug = async (subscription_id, subscription_password, config, utteran
747
752
  */
748
753
 
749
754
  const defaultErrorHandler = async (error) => {
750
- if (error.logs) {
755
+ const json = error.json || error
756
+
757
+ if (json.explain_associations_details) {
758
+ console.log("EXPLAIN ASSOCIATIONS START")
759
+ console.log("EXPLAIN ASSOCIATIONS TRIE START")
760
+ console.log(json.explain_associations_trie)
761
+ console.log("EXPLAIN ASSOCIATIONS TRIE END")
762
+ console.log("EXPLAIN ASSOCIATIONS DETAILS START")
763
+ debugger
764
+ console.log(json.explain_associations_details)
765
+ console.log("EXPLAIN ASSOCIATIONS DETAILS END")
766
+ console.log("EXPLAIN ASSOCIATIONS END")
767
+ }
768
+
769
+ if (json.logs) {
751
770
  console.log('\nlogs: ')
752
- for (const log of error.logs) {
771
+ for (const log of json.logs) {
753
772
  console.log('\n ', log)
754
773
  }
755
774
  }
756
775
 
757
- if (error.trace) {
758
- console.log('trace: ', error.trace)
776
+ if (json.trace) {
777
+ console.log('trace: ', json.trace)
759
778
  }
760
779
 
761
- if (false && error.config) {
762
- console.log('objects', runtime.util.inspect(error.config.get('objects'), { depth: Infinity, sorted: true }))
763
- }
764
-
765
- if (error.stack) {
780
+ if (json.stack) {
781
+ console.log('error: ')
782
+ console.log(json.stack)
783
+ } else if (error.stack) {
766
784
  console.log('error: ')
767
785
  console.log(error.stack)
768
786
  }
769
787
 
770
788
  let doErrorExit = false
771
- if (error.errors) {
789
+ if (json.errors) {
772
790
  console.log('error: ')
773
- for (const e of error.errors) {
791
+ for (const e of json.errors) {
774
792
  if (e.logs) {
775
793
  console.log('\nlogs: ')
776
794
  for (const log of e.logs) {
@@ -785,16 +803,16 @@ const defaultErrorHandler = async (error) => {
785
803
  doErrorExit = true
786
804
  }
787
805
  }
788
- if (error.error) {
806
+ if (json.error) {
789
807
  console.log('error: ')
790
- for (const e of error.error) {
808
+ for (const e of json.error) {
791
809
  console.log('\n ', e)
792
810
  doErrorExit = true
793
811
  }
794
812
  }
795
813
 
796
- if (error.query) {
797
- console.log(`query: #${error.queryNumber} ${error.query}`)
814
+ if (json.query) {
815
+ console.log(`query: #${json.queryNumber} ${json.query}`)
798
816
  doErrorExit = true
799
817
  }
800
818
 
@@ -802,7 +820,7 @@ const defaultErrorHandler = async (error) => {
802
820
  runtime.process.exit(-1)
803
821
  }
804
822
 
805
- error.config = null // otherwise it dumps to much on the console
823
+ json.config = null // otherwise it dumps too much on the console
806
824
 
807
825
  throw error
808
826
  }
@@ -902,6 +920,7 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
902
920
  const km = config.configs.find((km) => km.name === name)
903
921
  return config.config.objects.namespaced[km.uuid] || {}
904
922
  }
923
+
905
924
  const picked = sortJson(pickObjects(config, config.testConfig, actualGetObjects), { depth: 25 })
906
925
  if (!_.isEmpty(picked)) {
907
926
  console.log('--- Object showing only the checked values ---')
@@ -1036,7 +1055,7 @@ const rebuildTemplate = async ({ config, instance, target, previousResultss, reb
1036
1055
  await loadInstance(config, { resultss: [results] })
1037
1056
  } else {
1038
1057
  try {
1039
- results = await _process(config, query.query, { initializer, rebuildingTemplate: true })
1058
+ results = await _process(config, query.query, { initializer, rebuildingTemplate: true, isFragment })
1040
1059
  } catch (e) {
1041
1060
  if (e.summaries && e.summaries.length > 0) {
1042
1061
  suggestFix(e.summaries)
@@ -1064,7 +1083,7 @@ const rebuildTemplate = async ({ config, instance, target, previousResultss, reb
1064
1083
  results.isFragment = isFragment
1065
1084
  results.skipSemantics = skipSemantics
1066
1085
  results.development = query.development
1067
- results.key = { query: query.query, hierarchy }
1086
+ results.key = { query: query.query, hierarchy, preserve: query.preserve }
1068
1087
  accumulators[property].push(results)
1069
1088
  if (isFragment) {
1070
1089
  config.fragmentsBeingBuilt.push({ query: query.query, contexts: results.contexts })
package/lines.js CHANGED
@@ -40,7 +40,7 @@ class Lines {
40
40
  this.newRow()
41
41
  let result = ''
42
42
  for (const row of this.rows) {
43
- result += row
43
+ result += row.trimEnd()
44
44
  result += '\n'
45
45
  }
46
46
  return result
package/package.json CHANGED
@@ -15,12 +15,14 @@
15
15
  },
16
16
  "scripts": {
17
17
  "to:debug": "node inspect node_modules/.bin/jest --runInBand -t NEO23",
18
- "test:debug": "node inspect node_modules/.bin/jest --runInBand --config ./jest.config.json",
18
+ "testd": "node inspect node_modules/.bin/jest --runInBand --config ./jest.config.json",
19
19
  "td": "node inspect node_modules/.bin/jest --runInBand --config ./jest.config.json",
20
20
  "tod": "node inspect node_modules/.bin/jest --runInBand -t NEO23",
21
+ "toda": "node inspect node_modules/.bin/jest --runInBand -t NEO23A",
21
22
  "lint:fix": "eslint \"**/*.js\" --fix",
22
23
  "lint": "eslint \"**/*.js\"",
23
24
  "to": "node node_modules/.bin/jest --runInBand -t NEO23",
25
+ "toa": "node node_modules/.bin/jest --runInBand -t NEO23A",
24
26
  "tos": "node node_modules/.bin/jest --runInBand -t NEOS23",
25
27
  "test": "jest --config ./jest.config.json",
26
28
  "test:python": "node node_modules/.bin/jest --runInBand -t PYTHON",
@@ -73,6 +75,6 @@
73
75
  "scriptjs": "^2.5.9",
74
76
  "uuid": "^8.3.2"
75
77
  },
76
- "version": "9.8.0-beta.9",
78
+ "version": "9.9.0-beta.0",
77
79
  "license": "UNLICENSED"
78
80
  }
package/src/config.js CHANGED
@@ -3,7 +3,7 @@ const { Semantics, normalizeGenerator } = require('./semantics')
3
3
  const { Generators } = require('./generators')
4
4
  const { v4: uuidv4 } = require('uuid')
5
5
  const configHelpers = require('./configHelpers')
6
- const DigraphInternal = require('./digraph_internal')
6
+ const Digraph = require('./digraph')
7
7
  const helpers = require('./helpers')
8
8
  const { InitCalls } = require('./helpers')
9
9
  const { ecatch } = require('./helpers')
@@ -30,7 +30,7 @@ const config_toServer = (config) => {
30
30
  }
31
31
 
32
32
  const updateHierarchy = (config) => {
33
- config.hierarchy = new DigraphInternal(config.config.hierarchy)
33
+ config.hierarchy = new Digraph(config.config.hierarchy)
34
34
  }
35
35
 
36
36
  const initWords = (words) => {
@@ -390,7 +390,7 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
390
390
 
391
391
  if (!bridge.where) {
392
392
  if (bridge.generator || bridge.generatorp || bridge.generatorr || bridge.generator ||
393
- bridge.semantic || bridge.evaluator || bridge.evaluator2 || bridge.semantics) {
393
+ bridge.semantic || bridge.semantics) {
394
394
  throw new Error(`In the KM "${config.name}", for the bridge ${bridge.id} the where property is missing. Use where: where().`)
395
395
  }
396
396
  }
@@ -494,18 +494,10 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
494
494
  applyWrapped: semantic,
495
495
  }
496
496
  } else {
497
- if (property == 'evaluator2') {
498
- semanticDef = {
499
- match: (args) => bridge.id === args.context.marker && match(args),
500
- apply: (args) => apply(args),
501
- applyWrapped: semantic,
502
- }
503
- } else {
504
- semanticDef = {
505
- match: (args) => bridge.id === args.context.marker && !!args.context.evaluate === evaluate && match(args),
506
- apply: (args) => apply(args),
507
- applyWrapped: semantic,
508
- }
497
+ semanticDef = {
498
+ match: (args) => bridge.id === args.context.marker && match(args),
499
+ apply: (args) => apply(args),
500
+ applyWrapped: semantic,
509
501
  }
510
502
  }
511
503
  semanticDef.where = semantic.where || bridge.where || helpers.where(4)
@@ -521,28 +513,10 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
521
513
  }
522
514
  }
523
515
 
524
- if (bridge.evaluator) {
525
- addSemantic(bridge.evaluator, true, 'evaluator')
526
- }
527
-
528
- if (bridge.evaluator2) {
529
- addSemantic(bridge.evaluator2, false, 'evaluator2')
530
- }
531
-
532
516
  if (bridge.semantic) {
533
517
  addSemantic(bridge.semantic, false, 'semantic')
534
518
  }
535
519
 
536
- if (bridge.evaluators) {
537
- const evaluators = [...bridge.evaluators]
538
- evaluators.reverse()
539
- if (evaluators) {
540
- for (const evaluator of evaluators) {
541
- addSemantic(evaluator, true, 'evaluator')
542
- }
543
- }
544
- }
545
-
546
520
  if (bridge.semantics) {
547
521
  const semantics = [...bridge.semantics]
548
522
  semantics.reverse()
@@ -572,9 +546,6 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
572
546
  'convolution',
573
547
  'disabled',
574
548
  'enhanced_associations',
575
- 'evaluator',
576
- 'evaluator2',
577
- 'evaluators',
578
549
  'generatorp',
579
550
  'generatorpr',
580
551
  'generatorr',
@@ -586,6 +557,7 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
586
557
  'level',
587
558
  'levelSpecificHierarchy',
588
559
  'localHierarchy',
560
+ 'match',
589
561
  'operator',
590
562
  'optional',
591
563
  'parents',
@@ -1047,6 +1019,7 @@ class Config {
1047
1019
  return {
1048
1020
  pseudo: true,
1049
1021
  description: 'this is a pseudo config that has limited functionality due to being available in the initializer and fixtures function context',
1022
+ nextFragmentContextId: () => this.nextFragmentContextId(),
1050
1023
  addAssociation: (...args) => this.addAssociation(...args),
1051
1024
  addAssociations: (...args) => this.addAssociations(...args),
1052
1025
  addBridge: (...args) => this.addBridge(...args, uuid),
@@ -1261,7 +1234,7 @@ class Config {
1261
1234
 
1262
1235
  warningNotEvaluated (log, value) {
1263
1236
  const description = 'WARNING: for semantics, implement an evaluations handler, set "value" property of the operator to the value.'
1264
- const match = `({context}) => context.marker === '${value.marker}' && context.evaluate && <other conditions as you like>`
1237
+ const match = `({context}) => context.marker === '${value.marker}' && <other conditions as you like>`
1265
1238
  const apply = '({context}) => <do stuff...>; context.value = <value>'
1266
1239
  const input = indent(JSON.stringify(value, null, 2), 2)
1267
1240
  const message = `${description}\nThe semantic would be\n match: ${match}\n apply: ${apply}\nThe input context would be:\n${input}\n`
@@ -1270,18 +1243,15 @@ class Config {
1270
1243
 
1271
1244
  // value is in response field
1272
1245
  // TODO maybe generalize out query+evaluate along the lines of set value and set reference
1273
- async getEvaluator (s, calls, log, context, args) {
1274
- const instance = await s({ ...args, ...context })
1275
- calls.touch(instance)
1276
- if (instance.evalue == null && !instance.verbatim && !instance.value) {
1277
- this.warningNotEvaluated(log, context)
1246
+ async evaluate (args, logs, context) {
1247
+ const apply = (c) => this.getSemantics(logs).apply(args, c)
1248
+ const instance = await apply(context)
1249
+ if (typeof instance !== 'string') {
1250
+ args.calls.touch(instance)
1278
1251
  }
1279
- if (instance.evalue == null) {
1280
- instance.evalue = instance.value
1281
- instance.edefault = true
1252
+ if (instance.evalue == null && !instance.verbatim && !instance.value) {
1253
+ this.warningNotEvaluated(logs, context)
1282
1254
  }
1283
- delete instance.evaluate
1284
- instance.instance = true
1285
1255
  return instance
1286
1256
  }
1287
1257
 
@@ -1312,10 +1282,14 @@ class Config {
1312
1282
  let fi = fragmentInstantiator(args, fragment.contexts)
1313
1283
  if (mappings) {
1314
1284
  fi = await fi
1315
- return fi.instantiate([{
1285
+ const instantiated = await fi.instantiate([{
1316
1286
  match: ({context}) => !!mappings[context.value], // is the value in the mappings
1317
1287
  apply: ({context}) => Object.assign(context, mappings[context.value]),
1318
- }])
1288
+ }], fragment.key?.preserve)
1289
+ if (process.env.DEBUG_CONTEXT_ID && process.env.DEBUG_CONTEXT_ID == instantiated.context_id) {
1290
+ debugger
1291
+ }
1292
+ return instantiated
1319
1293
  } else {
1320
1294
  return fi
1321
1295
  }
@@ -1324,6 +1298,7 @@ class Config {
1324
1298
  }
1325
1299
  }
1326
1300
 
1301
+ /*
1327
1302
  fragmentMapper (args, values, fromModelQuery, toModelQuery) {
1328
1303
  const fromModelFragment = this.getFragment(fromModelQuery)
1329
1304
  console.dir(fromModelFragment)
@@ -1332,6 +1307,7 @@ class Config {
1332
1307
  const mapper = fragmentMapperInstantiator(values, fromModelFragment.contexts, toModelFragment.contexts)
1333
1308
  return mapper
1334
1309
  }
1310
+ */
1335
1311
 
1336
1312
  // { rebuild: false, isModule: false }
1337
1313
  needsRebuild (template, instance, options) {
@@ -1403,6 +1379,7 @@ class Config {
1403
1379
  bridge = { ...bridge },
1404
1380
  bridge.level = bridge.level || 0
1405
1381
  delete bridge.uuid
1382
+ delete bridge.where
1406
1383
  return bridge
1407
1384
  })
1408
1385
  if (options.isModule) {
@@ -1415,9 +1392,6 @@ class Config {
1415
1392
  delete bridge.generatorp
1416
1393
  delete bridge.generatorr
1417
1394
  delete bridge.generatorpr
1418
- delete bridge.evaluator
1419
- delete bridge.evaluator2
1420
- delete bridge.evaluators
1421
1395
  delete bridge.semantic
1422
1396
  delete bridge.semantics
1423
1397
  if (false && !bridge.bridge) {
@@ -2199,6 +2173,12 @@ class Config {
2199
2173
  // await this.demoInitializer(this)
2200
2174
  }
2201
2175
 
2176
+ nextFragmentContextId() {
2177
+ const id = this.fragmentNextContextId
2178
+ this.fragmentNextContextId = this.fragmentNextContextId + 1
2179
+ return id
2180
+ }
2181
+
2202
2182
  // configs = [ { config, namespace } ... ]
2203
2183
  constructor (config, module, clientProcess, apiKMs, rootIsProcess, testingModuleName) {
2204
2184
  if (config instanceof Config) {
@@ -2209,6 +2189,8 @@ class Config {
2209
2189
  apiKMs = []
2210
2190
  }
2211
2191
 
2192
+ this.fragmentNextContextId = 1000
2193
+
2212
2194
  if (config) {
2213
2195
  validConfigProps(config)
2214
2196
 
@@ -2293,7 +2275,7 @@ class Config {
2293
2275
  }
2294
2276
  }
2295
2277
  this.terminatorFn = () => {}
2296
- this.loadOrder = new DigraphInternal()
2278
+ this.loadOrder = new Digraph()
2297
2279
  this.wasInitialized = false
2298
2280
  this.configs = []
2299
2281
  this._api = undefined
@@ -2301,13 +2283,13 @@ class Config {
2301
2283
  this._namespace = []
2302
2284
  this._eqClasses = []
2303
2285
  // this._uuid = uuidv4()
2304
- this._uuid = this.getCounter(this.name)
2286
+ this._uuid = (this.name || '') + this.getCounter(this.name)
2305
2287
  if (config) {
2306
2288
  config = _.cloneDeep(config)
2307
2289
  this.config = config
2308
2290
  handleCalculatedProps(this, config)
2309
2291
  }
2310
- this.hierarchy = new DigraphInternal(this.config.hierarchy)
2292
+ this.hierarchy = new Digraph(this.config.hierarchy)
2311
2293
  this.initConfig = _.cloneDeep(this.config)
2312
2294
  this.configs.push(new KM({ config: this.config, getCounter: (name) => this.config.getCounter(name), uuid: this._uuid }))
2313
2295
 
@@ -2548,6 +2530,7 @@ class Config {
2548
2530
  cp.logs = []
2549
2531
  cp.demoInitializer = this.demoInitializer
2550
2532
  cp.maxDepth = this.maxDepth
2533
+ cp.loadOrder = this.loadOrder
2551
2534
  cp.debugLoops = this.debugLoops
2552
2535
  cp.transitoryMode = this.transitoryMode
2553
2536
  // cp.configs = this.configs.map((km) => await km.copy2(Object.assign({}, options, { getCounter: (name) => cp.getCounter(name), callInitializers: false })))
@@ -2588,7 +2571,7 @@ class Config {
2588
2571
  cp.configCounter = this.configCounter
2589
2572
  cp.testConfig = this.testConfig
2590
2573
  cp._server = this._server
2591
- cp.hierarchy = new DigraphInternal(this.config.hierarchy)
2574
+ cp.hierarchy = new Digraph(this.config.hierarchy)
2592
2575
  cp.sendObjectsToServer = this.sendObjectsToServer
2593
2576
 
2594
2577
  cp.scope = this.scope
@@ -2976,7 +2959,7 @@ class Config {
2976
2959
  this.resetDelta()
2977
2960
  const debug = this.config.debug
2978
2961
  this.config = _.cloneDeep(this.initConfig)
2979
- this.hierarchy = new DigraphInternal(this.config.hierarchy)
2962
+ this.hierarchy = new Digraph(this.config.hierarchy)
2980
2963
  if (debug) {
2981
2964
  this.config.debug = debug
2982
2965
  }
@@ -2994,7 +2977,7 @@ class Config {
2994
2977
 
2995
2978
  // reorder configs base on load ordering
2996
2979
  {
2997
- const ordering = this.loadOrder.order(this.configs.map((km) => km.name || km.uuid))
2980
+ const ordering = this.getLoadOrder().order(this.configs.map((km) => km.name || km.uuid))
2998
2981
  this.loadOrdering = ordering
2999
2982
  const oconfigs = []
3000
2983
  for (const nameOrUUID of ordering) {
@@ -3036,7 +3019,7 @@ class Config {
3036
3019
  }
3037
3020
  if (!isSelf) {
3038
3021
  config.config = _.cloneDeep(config.initConfig)
3039
- config.hierarchy = new DigraphInternal(config.config.hierarchy)
3022
+ config.hierarchy = new Digraph(config.config.hierarchy)
3040
3023
  }
3041
3024
  config.wasInitialized = false
3042
3025
  // TODO change name of config: to baseConfig:
@@ -3044,7 +3027,7 @@ class Config {
3044
3027
  const config = this.getConfig(name)
3045
3028
  return config
3046
3029
  }
3047
- // const hierarchy = new DigraphInternal((config.config || {}).hierarchy)
3030
+ // const hierarchy = new Digraph((config.config || {}).hierarchy)
3048
3031
  const args = new Object(setupInitializerFNArgs(this, {
3049
3032
  isModule,
3050
3033
  hierarchy: this.hierarchy,
@@ -3509,8 +3492,6 @@ class Config {
3509
3492
  more = await more.copy()
3510
3493
  more.server(this._server, this._key, this._queryParams)
3511
3494
 
3512
- const moreConfigs = more.configs.map((km) => km.name || km.uuid)
3513
- this.loadOrder.addList(moreConfigs)
3514
3495
 
3515
3496
  // get the new ones
3516
3497
  // remove the dups
@@ -3550,11 +3531,28 @@ class Config {
3550
3531
  }
3551
3532
  this.instances = noDups
3552
3533
  }
3534
+
3535
+ this.loadOrder = this.getLoadOrder()
3536
+
3553
3537
  await this.rebuild() // in add(
3554
3538
  this.valid()
3555
3539
  return this
3556
3540
  }
3557
3541
 
3542
+ getLoadOrder() {
3543
+ const loadOrder = new Digraph()
3544
+ for (const [i, config] of this.configs.entries()) {
3545
+ if (i == 0) {
3546
+ } else {
3547
+ loadOrder.add( this.name, config.name )
3548
+ for (const edge of config.config?.loadOrder.edges || []) {
3549
+ loadOrder.addEdge(edge)
3550
+ }
3551
+ }
3552
+ }
3553
+ return loadOrder
3554
+ }
3555
+
3558
3556
  // TODO get rid of useOldVersion arg
3559
3557
  addInternal (more,
3560
3558
  { uuid, km, addFirst = false, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false, handleCalculatedProps: hcps = false } = {}) {