theprogrammablemind 7.10.0-beta.14 → 7.10.0-beta.16

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/src/config.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // lookup = (name) => returns <config>
2
2
  const { Semantics, normalizeGenerator } = require('./semantics')
3
3
  const { Generators } = require('./generators')
4
- const { v4 : uuidv4 } = require('uuid');
4
+ const { v4: uuidv4 } = require('uuid')
5
5
  const client = require('../client')
6
6
  const DigraphInternal = require('./digraph_internal')
7
7
  const helpers = require('./helpers')
@@ -19,7 +19,7 @@ const bags = [
19
19
  ]
20
20
 
21
21
  const indent = (string, indent) => {
22
- return string.replace(/^/gm, ' '.repeat(indent));
22
+ return string.replace(/^/gm, ' '.repeat(indent))
23
23
  }
24
24
 
25
25
  const config_toServer = (config) => {
@@ -29,7 +29,7 @@ const config_toServer = (config) => {
29
29
  const debugPriority = (priority) => {
30
30
  if (global.entodictonDebugPriority) {
31
31
  if (helpers.subPriority(entodictonDebugPriority, priority)) {
32
- debugger; // debug hierarchy hit
32
+ debugger // debug hierarchy hit
33
33
  }
34
34
  }
35
35
  }
@@ -37,7 +37,7 @@ const debugPriority = (priority) => {
37
37
  const debugAssociation = (association) => {
38
38
  if (global.entodictonDebugAssociation) {
39
39
  if (helpers.safeEquals(global.entodictonDebugAssociation, association)) {
40
- debugger; // debug association hit
40
+ debugger // debug association hit
41
41
  }
42
42
  }
43
43
  }
@@ -45,15 +45,15 @@ const debugAssociation = (association) => {
45
45
  const debugHierarchy = (pair) => {
46
46
  if (global.entodictonDebugHierarchy) {
47
47
  if (helpers.safeEquals(global.entodictonDebugHierarchy, pair)) {
48
- debugger; // debug hierarchy hit
48
+ debugger // debug hierarchy hit
49
49
  }
50
50
  }
51
51
  }
52
52
 
53
- const debugBridge = (bridge) => {
53
+ const debugBridge = (bridge) => {
54
54
  if (global.entodictonDebugBridge) {
55
55
  if (global.entodictonDebugBridge[0] == bridge.id && global.entodictonDebugBridge[1] == bridge.level) {
56
- debugger; // debug hierarchy hit
56
+ debugger // debug hierarchy hit
57
57
  }
58
58
  }
59
59
  }
@@ -61,7 +61,7 @@ const debugBridge = (bridge) => {
61
61
  const debugOperator = (operator) => {
62
62
  if (global.entodictonDebugOperator) {
63
63
  if ((operator.pattern || operator) === global.entodictonDebugOperator) {
64
- debugger; // debug operator hit
64
+ debugger // debug operator hit
65
65
  }
66
66
  }
67
67
  }
@@ -75,7 +75,7 @@ const debugConfigProps = (config) => {
75
75
  { property: 'association', check: (v) => debugAssociation(v) },
76
76
  { property: 'hierarchy', check: (v) => debugHierarchy(v) },
77
77
  { property: 'operators', check: (v) => debugOperator(v) },
78
- { property: 'bridges', check: (v) => debugBridge(v) },
78
+ { property: 'bridges', check: (v) => debugBridge(v) }
79
79
  ]
80
80
  for (const { property, check } of checkProps) {
81
81
  if (config[property]) {
@@ -87,21 +87,21 @@ const debugConfigProps = (config) => {
87
87
  }
88
88
 
89
89
  const validConfigProps = (config) => {
90
- const valid = [
91
- 'hierarchy',
92
- 'objects',
93
- 'bridges',
94
- 'operators',
95
- 'words',
96
- 'priorities',
97
- 'associations',
98
- 'name',
99
- 'version',
100
- 'generatorp',
101
- 'generators',
102
- 'semantics',
103
- 'where',
104
- 'floaters',
90
+ const valid = [
91
+ 'hierarchy',
92
+ 'objects',
93
+ 'bridges',
94
+ 'operators',
95
+ 'words',
96
+ 'priorities',
97
+ 'associations',
98
+ 'name',
99
+ 'version',
100
+ 'generatorp',
101
+ 'generators',
102
+ 'semantics',
103
+ 'where',
104
+ 'floaters',
105
105
  'debug',
106
106
 
107
107
  // TODO Fix these from the test app
@@ -116,7 +116,7 @@ const validConfigProps = (config) => {
116
116
  'flatten',
117
117
 
118
118
  'namespaces',
119
- 'eqClasses',
119
+ 'eqClasses'
120
120
  ]
121
121
  helpers.validProps(valid, config, 'config')
122
122
  }
@@ -134,30 +134,29 @@ const setupInitializerFNArgs = (config, args) => {
134
134
  config: config.getPseudoConfig(args.uuid, args.currentConfig),
135
135
  km,
136
136
  baseConfig: config,
137
- apis,
137
+ apis
138
138
  }
139
139
  }
140
140
 
141
141
  const operatorKey_valid = (key) => {
142
142
  if (
143
- !_.isArray(key) ||
143
+ !_.isArray(key) ||
144
144
  key.length != 2 ||
145
145
  !_.isString(key[0]) ||
146
146
  !_.isInteger(key[1]) ||
147
147
  key[1] < 0
148
- ) {
149
-
148
+ ) {
150
149
  let details = ''
151
150
  if (!_.isArray(key)) {
152
- details = "Expected an array."
151
+ details = 'Expected an array.'
153
152
  } else if (key.length != 2) {
154
- details = "Expected an array of length two."
153
+ details = 'Expected an array of length two.'
155
154
  } else if (!_.isString(key[0])) {
156
- details = "Expected element zero to be a string that is an operator id."
155
+ details = 'Expected element zero to be a string that is an operator id.'
157
156
  } else if (!_.isInteger(key[1])) {
158
- details = "Expected element one to be a number that is an operator level."
157
+ details = 'Expected element one to be a number that is an operator level.'
159
158
  } else if (key[1] < 0) {
160
- details = "Expected element one to be a number that is an operator level which is greater than zero."
159
+ details = 'Expected element one to be a number that is an operator level which is greater than zero.'
161
160
  }
162
161
  throw new Error(`${JSON.stringify(key)} is not a valid operator key. Values are of the form [<operatorId>, <operatorLevel>]. ${details}`)
163
162
  }
@@ -167,13 +166,13 @@ const elist = (list, check, prefix) => {
167
166
  for ([index, element] of list.entries()) {
168
167
  try {
169
168
  check(element)
170
- } catch( e ) {
169
+ } catch (e) {
171
170
  throw new Error(prefix(index, e))
172
171
  }
173
172
  }
174
173
  }
175
174
  const priorities_valid = (cps) => {
176
- elist(cps, (cp) => priority_valid(cp), (index, e) => `priorities has an invalid priority at position ${index}. ${e}`)
175
+ elist(cps, (cp) => priority_valid(cp), (index, e) => `priorities has an invalid priority at position ${index}. ${e}`)
177
176
  }
178
177
 
179
178
  const priority_valid = (cp) => {
@@ -187,16 +186,16 @@ const priority_valid = (cp) => {
187
186
  if (!_.isArray(cp.choose)) {
188
187
  throw new Error(`The priority ${JSON.stringify(cp)} has an invalid "choose" value. The value should be a list of the operators in the context to consider for prioritization.`)
189
188
  }
190
- elist(cp.choose,
191
- (element) => {
192
- if (!element && element !== 0) {
193
- throw new Error(`The value should be an index into the "context" property of the operator that is to be considered for prioritization.`)
194
- }
195
- if (!_.isInteger(element) || element < 0 || element >= cp.context.length) {
196
- throw new Error(`The value should be an index into the "context" property of the operator that is to be considered for prioritization. Valid values are between 0 and ${cp.context.length-1}.`)
197
- }
198
- },
199
- (index, e) => `The choose property in the priority ${JSON.stringify(cp)} has an invalid index at position ${index}. ${e}`
189
+ elist(cp.choose,
190
+ (element) => {
191
+ if (!element && element !== 0) {
192
+ throw new Error('The value should be an index into the "context" property of the operator that is to be considered for prioritization.')
193
+ }
194
+ if (!_.isInteger(element) || element < 0 || element >= cp.context.length) {
195
+ throw new Error(`The value should be an index into the "context" property of the operator that is to be considered for prioritization. Valid values are between 0 and ${cp.context.length - 1}.`)
196
+ }
197
+ },
198
+ (index, e) => `The choose property in the priority ${JSON.stringify(cp)} has an invalid index at position ${index}. ${e}`
200
199
  )
201
200
  }
202
201
 
@@ -204,29 +203,29 @@ const handleBridgeProps = (config, bridge, addFirst) => {
204
203
  ecatch(`While processing the bridge for ${bridge.id}#${bridge.level}`,
205
204
  () => {
206
205
  if (!bridge.bridge) {
207
- bridge.bridge = "{ ...next(operator) }"
206
+ bridge.bridge = '{ ...next(operator) }'
208
207
  }
209
208
  if (!bridge.level) {
210
209
  bridge.level = 0
211
210
  }
212
211
  if (bridge.children) {
213
- for (let child of bridge.children) {
212
+ for (const child of bridge.children) {
214
213
  config.addHierarchy(child, bridge.id)
215
214
  }
216
215
  }
217
216
  if (bridge.parents) {
218
- for (let parent of bridge.parents) {
217
+ for (const parent of bridge.parents) {
219
218
  config.addHierarchy(bridge.id, parent)
220
219
  }
221
220
  }
222
221
  if (bridge.isA) {
223
- for (let parent of bridge.isA) {
222
+ for (const parent of bridge.isA) {
224
223
  config.addHierarchy(bridge.id, parent)
225
224
  }
226
225
  }
227
226
  if (bridge.before) {
228
227
  for (let after of bridge.before) {
229
- if (typeof after == 'string') {
228
+ if (typeof after === 'string') {
230
229
  after = [after, 0]
231
230
  }
232
231
  config.addPriority({ context: [[bridge.id, bridge.level], after], choose: [0] })
@@ -234,7 +233,7 @@ const handleBridgeProps = (config, bridge, addFirst) => {
234
233
  }
235
234
  if (bridge.after) {
236
235
  for (let before of bridge.after) {
237
- if (typeof before == 'string') {
236
+ if (typeof before === 'string') {
238
237
  before = [before, 0]
239
238
  }
240
239
  config.addPriority({ context: [before, [bridge.id, bridge.level]], choose: [0] })
@@ -242,8 +241,8 @@ const handleBridgeProps = (config, bridge, addFirst) => {
242
241
  }
243
242
  if (bridge.words) {
244
243
  for (let def of bridge.words) {
245
- if (typeof def == 'string') {
246
- config.addWordInternal(def, {"id": bridge.id, "initial": `{ value: "${def}"}` })
244
+ if (typeof def === 'string') {
245
+ config.addWordInternal(def, { id: bridge.id, initial: `{ value: "${def}"}` })
247
246
  } else {
248
247
  const word = def.word
249
248
  def = { initial: JSON.stringify(def), id: bridge.id, word }
@@ -263,7 +262,7 @@ const handleBridgeProps = (config, bridge, addFirst) => {
263
262
  if (bridge.generators) {
264
263
  const generators = [...bridge.generators]
265
264
  generators.reverse()
266
- for (let generator of generators) {
265
+ for (const generator of generators) {
267
266
  if (addFirst) {
268
267
  config.config.generators.unshift(generator)
269
268
  } else {
@@ -277,33 +276,32 @@ const handleBridgeProps = (config, bridge, addFirst) => {
277
276
  }
278
277
  if (bridge.generatorp) {
279
278
  const match = bridge.generatorp.match || (() => true)
280
- const apply = typeof bridge.generatorp == 'function' ? bridge.generatorp : bridge.generatorp.apply || bridge.generatorp
279
+ const apply = typeof bridge.generatorp === 'function' ? bridge.generatorp : bridge.generatorp.apply || bridge.generatorp
281
280
  const level = bridge.generatorp.level >= 0 ? bridge.generatorp.level : bridge.level + 1
282
-
281
+
283
282
  const generator = {
284
283
  where: bridge.generatorp.where || bridge.where || client.where(4),
285
284
  match: (args) => bridge.id == args.context.marker && args.context.level == level && args.context.paraphrase && match(args),
286
285
  apply: (args) => apply(args),
287
286
  applyWrapped: apply,
288
- property: 'generatorp',
287
+ property: 'generatorp'
289
288
  }
290
289
  if (addFirst) {
291
290
  config.config.generators.unshift(generator)
292
291
  } else {
293
292
  config.config.generators.push(generator)
294
293
  }
295
-
296
294
  }
297
295
  if (bridge.generatorr) {
298
296
  const match = bridge.generatorr.match || (() => true)
299
- const apply = typeof bridge.generatorr == 'function' ? bridge.generatorr : bridge.generatorr.apply || bridge.generatorr
297
+ const apply = typeof bridge.generatorr === 'function' ? bridge.generatorr : bridge.generatorr.apply || bridge.generatorr
300
298
  const level = bridge.generatorr.level >= 0 ? bridge.generatorr.level : bridge.level + 1
301
299
  const generator = {
302
300
  where: bridge.generatorr.where || bridge.where || client.where(4),
303
301
  match: (args) => bridge.id == args.context.marker && args.context.level == level && !args.context.paraphrase && (args.context.response || args.context.isResponse) && match(args),
304
302
  apply: (args) => apply(args),
305
303
  applyWrapped: apply,
306
- property: 'generatorr',
304
+ property: 'generatorr'
307
305
  }
308
306
  if (addFirst) {
309
307
  config.config.generators.unshift(generator)
@@ -314,10 +312,10 @@ const handleBridgeProps = (config, bridge, addFirst) => {
314
312
  if (bridge.evaluator) {
315
313
  const semantic = {
316
314
  where: bridge.evaluator.where || bridge.where || client.where(3),
317
- match: ({context}) => bridge.id == context.marker && context.evaluate,
315
+ match: ({ context }) => bridge.id == context.marker && context.evaluate,
318
316
  apply: (args) => bridge.evaluator(args),
319
317
  applyWrapped: bridge.evaluator,
320
- property: 'evaluator',
318
+ property: 'evaluator'
321
319
  }
322
320
  if (addFirst) {
323
321
  config.config.semantics.unshift(semantic)
@@ -328,10 +326,10 @@ const handleBridgeProps = (config, bridge, addFirst) => {
328
326
  if (bridge.semantic) {
329
327
  const semantic = {
330
328
  where: bridge.semantic.where || bridge.where || client.where(3),
331
- match: ({context}) => bridge.id == context.marker,
329
+ match: ({ context }) => bridge.id == context.marker,
332
330
  apply: (args) => bridge.semantic(args),
333
331
  applyWrapped: bridge.semantic,
334
- property: 'semantic',
332
+ property: 'semantic'
335
333
  }
336
334
  if (addFirst) {
337
335
  config.config.semantics.unshift(semantic)
@@ -346,9 +344,9 @@ const handleBridgeProps = (config, bridge, addFirst) => {
346
344
  const handleCalculatedProps = (baseConfig, moreConfig, addFirst) => {
347
345
  if (moreConfig.bridges) {
348
346
  moreConfig.bridges = moreConfig.bridges.map((bridge) => {
349
- bridge = {...bridge}
350
- const valid = [ 'after', 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generatorpr', 'generators', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
351
- 'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy', 'levelSpecificHierarchy', 'where', 'uuid' ]
347
+ bridge = { ...bridge }
348
+ const valid = ['after', 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generatorpr', 'generators', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
349
+ 'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy', 'levelSpecificHierarchy', 'where', 'uuid']
352
350
  helpers.validProps(valid, bridge, 'bridge')
353
351
  handleBridgeProps(baseConfig, bridge, addFirst)
354
352
  return bridge
@@ -369,7 +367,6 @@ if (runtime.process.env.DEBUG_HIERARCHY) {
369
367
  global.entodictonDebugHierarchy = JSON.parse(runtime.process.env.DEBUG_HIERARCHY)
370
368
  }
371
369
 
372
-
373
370
  // i keep randomly doing one of the other so I will just make both work the same way
374
371
  if (runtime.process.env.DEBUG_PRIORITIES) {
375
372
  global.entodictonDebugPriority = JSON.parse(runtime.process.env.DEBUG_PRIORITIES)
@@ -390,7 +387,7 @@ if (runtime.process.env.DEBUG_BRIDGE) {
390
387
  // id/level
391
388
  global.entodictonDebugBridge = runtime.process.env.DEBUG_BRIDGE.split('/')
392
389
  if (global.entodictonDebugBridge.length !== 2) {
393
- console.log('Expected DEBUG_BRIDGE to be of the form "id/level"');
390
+ console.log('Expected DEBUG_BRIDGE to be of the form "id/level"')
394
391
  process.exit(-1)
395
392
  }
396
393
  global.entodictonDebugBridge[1] = parseInt(global.entodictonDebugBridge[1])
@@ -402,12 +399,12 @@ if (runtime.process.env.DEBUG_OPERATOR) {
402
399
  }
403
400
 
404
401
  const hierarchyCanonical = (element) => {
405
- if (element.child && element.parent) {
406
- return element
407
- } else {
408
- return { child: element[0], parent: element[1] }
409
- }
402
+ if (element.child && element.parent) {
403
+ return element
404
+ } else {
405
+ return { child: element[0], parent: element[1] }
410
406
  }
407
+ }
411
408
 
412
409
  const isValidDef = (word, def, config) => {
413
410
  if (!def.id) {
@@ -452,21 +449,20 @@ const normalizeConfig = (config) => {
452
449
  config[bag][i].km = config.name
453
450
  }
454
451
  }
455
-
456
452
  }
457
- if (config['bridges']) {
458
- for (let bridge of config['bridges']) {
453
+ if (config.bridges) {
454
+ for (const bridge of config.bridges) {
459
455
  if (!bridge.level) {
460
456
  bridge.level = 0
461
457
  }
462
458
  if (!bridge.bridge) {
463
- bridge.bridge = "{ ...next(operator) }"
459
+ bridge.bridge = '{ ...next(operator) }'
464
460
  }
465
461
  }
466
462
  }
467
463
 
468
464
  if (config.semantics) {
469
- for (let semantic of config.semantics) {
465
+ for (const semantic of config.semantics) {
470
466
  if (semantic.oneShot) {
471
467
  semantic.id = uuid()
472
468
  }
@@ -611,7 +607,7 @@ class KM {
611
607
  const config = configDup(this._config, options)
612
608
  const km = new KM({
613
609
  config,
614
- getCounter: options.getCounter,
610
+ getCounter: options.getCounter,
615
611
  name: this._name,
616
612
  _uuid: config._uuid,
617
613
  namespace: this._namespace,
@@ -708,16 +704,14 @@ const multiApiImpl = (initializer) => {
708
704
  })
709
705
  }
710
706
 
711
-
712
707
  class Config {
713
-
714
708
  toServer (config) {
715
709
  return config_toServer(config)
716
710
  }
717
711
 
718
712
  base () {
719
713
  const base = new Config()
720
- for (let km of this.configs.reverse()) {
714
+ for (const km of this.configs.reverse()) {
721
715
  if (km.isSelf) {
722
716
  continue
723
717
  }
@@ -737,8 +731,8 @@ class Config {
737
731
  }
738
732
  const templateQueries = []
739
733
  if (this.instances && this.instances.length > 0) {
740
- for (let query of this.instances.slice(-1)[0].queries) {
741
- if (typeof query == 'string') {
734
+ for (const query of this.instances.slice(-1)[0].queries) {
735
+ if (typeof query === 'string') {
742
736
  templateQueries.push(query)
743
737
  }
744
738
  }
@@ -749,7 +743,7 @@ class Config {
749
743
 
750
744
  getPseudoConfig (uuid, config) {
751
745
  return {
752
- description: "this is a pseudo config that has limited functionality due to being available in the initializer function context",
746
+ description: 'this is a pseudo config that has limited functionality due to being available in the initializer function context',
753
747
  addAssociation: (...args) => this.addAssociation(...args),
754
748
  addAssociations: (...args) => this.addAssociations(...args),
755
749
  addBridge: (...args) => this.addBridge(...args, uuid),
@@ -769,7 +763,7 @@ class Config {
769
763
  getBridge: (...args) => this.getBridge(...args),
770
764
  fragment: (...args) => this.fragment(...args),
771
765
  exists: (...args) => this.exists(...args),
772
- addAPI: (...args) => this.addAPI(...args),
766
+ addAPI: (...args) => this.addAPI(...args)
773
767
  }
774
768
  }
775
769
 
@@ -783,7 +777,7 @@ class Config {
783
777
  }
784
778
 
785
779
  // return the config with just the elements from the included KM's
786
- baseConfig() {
780
+ baseConfig () {
787
781
  const operators = this.config.operators.filter((operator) => {
788
782
  return operator.uuid !== this.uuid
789
783
  })
@@ -791,8 +785,8 @@ class Config {
791
785
  return bridge.uuid !== this.uuid
792
786
  })
793
787
  const words = {}
794
- for (let word in this.config.words) {
795
- const defs = this.config.words[word].filter( (def) => def.uuid !== this.uuid )
788
+ for (const word in this.config.words) {
789
+ const defs = this.config.words[word].filter((def) => def.uuid !== this.uuid)
796
790
  if (defs.length > 0) {
797
791
  words[word] = defs
798
792
  }
@@ -810,11 +804,11 @@ class Config {
810
804
  return `${maybeName}${counter}`
811
805
  }
812
806
 
813
- setTestConfig(testConfig) {
807
+ setTestConfig (testConfig) {
814
808
  this.testConfig = testConfig
815
809
  }
816
810
 
817
- getTestConfig() {
811
+ getTestConfig () {
818
812
  return this.testConfig
819
813
  }
820
814
 
@@ -859,44 +853,44 @@ class Config {
859
853
 
860
854
  // applies only to config sent to the server
861
855
 
862
- watching() {
856
+ watching () {
863
857
  const props = [
864
- 'operators',
865
- 'bridges',
866
- 'hierarchy',
867
- 'namespaces',
868
- 'eqClasses',
869
- 'priorities',
870
- 'associations',
871
- 'words',
872
- 'floaters',
873
- 'implicits',
874
- 'flatten',
875
- ];
858
+ 'operators',
859
+ 'bridges',
860
+ 'hierarchy',
861
+ 'namespaces',
862
+ 'eqClasses',
863
+ 'priorities',
864
+ 'associations',
865
+ 'words',
866
+ 'floaters',
867
+ 'implicits',
868
+ 'flatten'
869
+ ]
876
870
  const watching = {}
877
- for (let prop of props) {
871
+ for (const prop of props) {
878
872
  watching[prop] = this.config[prop]
879
873
  }
880
874
  return JSON.stringify(watching)
881
875
  }
882
876
 
883
- watch() {
884
- this.watchStart = this.watching();
877
+ watch () {
878
+ this.watchStart = this.watching()
885
879
  }
886
880
 
887
- wasChanged() {
881
+ wasChanged () {
888
882
  if (!this.watchStart) {
889
- return false;
883
+ return false
890
884
  }
891
885
  return this.watchStart !== this.watching()
892
886
  }
893
887
 
894
- exists(marker) {
895
- for (let bridge of this.config.bridges) {
888
+ exists (marker) {
889
+ for (const bridge of this.config.bridges) {
896
890
  if (bridge.id == marker) {
897
- return true;
891
+ return true
898
892
  }
899
- }
893
+ }
900
894
  }
901
895
 
902
896
  getSemantics (logs = []) {
@@ -910,7 +904,7 @@ class Config {
910
904
  warningNotEvaluated (log, value) {
911
905
  const description = 'WARNING: for semantics, implement an evaluations handler, set "value" property of the operator to the value.'
912
906
  const match = `({context}) => context.marker == '${value.marker}' && context.evaluate && <other conditions as you like>`
913
- const apply = `({context}) => <do stuff...>; context.value = <value>`
907
+ const apply = '({context}) => <do stuff...>; context.value = <value>'
914
908
  const input = indent(JSON.stringify(value, null, 2), 2)
915
909
  const message = `${description}\nThe semantic would be\n match: ${match}\n apply: ${apply}\nThe input context would be:\n${input}\n`
916
910
  log.push(indent(message, 4))
@@ -937,18 +931,17 @@ class Config {
937
931
  const instance = s({ ...context, evaluate: true })
938
932
  calls.touch(instance)
939
933
  if (!instance.evalue && !instance.verbatim && !instance.value) {
940
- this.warningNotEvaluated(log, context);
934
+ this.warningNotEvaluated(log, context)
941
935
  }
942
936
  if (!instance.evalue) {
943
937
  instance.evalue = instance.value
944
938
  instance.edefault = true
945
939
  }
946
940
  delete instance.evaluate
947
- instance.instance = true;
941
+ instance.instance = true
948
942
  return instance
949
943
  }
950
944
 
951
-
952
945
  fragmentInstantiator (contexts) {
953
946
  return new Object({
954
947
  contexts: () => contexts,
@@ -970,7 +963,7 @@ class Config {
970
963
  continue
971
964
  }
972
965
  if (context[key].instantiated) {
973
- continue;
966
+ continue
974
967
  }
975
968
  todo.push(context[key])
976
969
  }
@@ -996,20 +989,20 @@ class Config {
996
989
  return true
997
990
  }
998
991
  const toCanonical = (f) => {
999
- if (typeof f == 'string') {
992
+ if (typeof f === 'string') {
1000
993
  return { query: f }
1001
994
  } else {
1002
995
  return f
1003
996
  }
1004
997
  }
1005
- const instanceFragments = (instance.fragments || []).map((fragment) => fragment.key || fragment.query).map( toCanonical )
1006
- const templateFragments = (template.fragments || []).concat(this.dynamicFragments).map( toCanonical )
998
+ const instanceFragments = (instance.fragments || []).map((fragment) => fragment.key || fragment.query).map(toCanonical)
999
+ const templateFragments = (template.fragments || []).concat(this.dynamicFragments).map(toCanonical)
1007
1000
  const sameFragments = helpers.safeEquals(templateFragments, instanceFragments)
1008
1001
  const toCanonicalQuery = (queryOrConfig) => {
1009
- if (typeof queryOrConfig == 'string') {
1002
+ if (typeof queryOrConfig === 'string') {
1010
1003
  const query = queryOrConfig
1011
1004
  return query
1012
- } else if (typeof queryOrConfig == 'function') {
1005
+ } else if (typeof queryOrConfig === 'function') {
1013
1006
  if (options.isModule) {
1014
1007
  return { apply: 'function in the browser has webpack rewrites so can not be compared' }
1015
1008
  } else {
@@ -1024,8 +1017,8 @@ class Config {
1024
1017
  } else {
1025
1018
  const config = { ...queryOrConfig }
1026
1019
  delete config.where
1027
- config.operators = (config.operators || []).map( (operator) => {
1028
- if (typeof operator == 'string') {
1020
+ config.operators = (config.operators || []).map((operator) => {
1021
+ if (typeof operator === 'string') {
1029
1022
  return { pattern: operator }
1030
1023
  } else {
1031
1024
  operator = { ...operator }
@@ -1033,7 +1026,7 @@ class Config {
1033
1026
  return operator
1034
1027
  }
1035
1028
  })
1036
- config.bridges = (config.bridges || []).map( (bridge) => {
1029
+ config.bridges = (config.bridges || []).map((bridge) => {
1037
1030
  bridge = { ...bridge },
1038
1031
  bridge.level = bridge.level || 0
1039
1032
  delete bridge.uuid
@@ -1041,10 +1034,10 @@ class Config {
1041
1034
  })
1042
1035
  if (options.isModule) {
1043
1036
  // things like webpack rewrite the functions if there are constants so this compare does not work
1044
- delete config.generators;
1045
- delete config.semantics;
1037
+ delete config.generators
1038
+ delete config.semantics
1046
1039
  config.bridges = (config.bridges || []).map((bridge) => {
1047
- bridge = {...bridge}
1040
+ bridge = { ...bridge }
1048
1041
  delete bridge.where
1049
1042
  delete bridge.generatorp
1050
1043
  delete bridge.generatorr
@@ -1052,24 +1045,24 @@ class Config {
1052
1045
  delete bridge.evaluator
1053
1046
  delete bridge.semantic
1054
1047
  return bridge
1055
- });
1048
+ })
1056
1049
  } else {
1057
1050
  config.generators = (config.generators || []).map((generator) => {
1058
- generator = {...generator}
1051
+ generator = { ...generator }
1059
1052
  delete generator.where
1060
1053
  generator.match = generator.match.toString()
1061
1054
  generator.apply = generator.apply.toString()
1062
1055
  return generator
1063
1056
  })
1064
1057
  config.semantics = (config.semantics || []).map((semantic) => {
1065
- semantic = {...semantic}
1058
+ semantic = { ...semantic }
1066
1059
  delete semantic.where
1067
1060
  semantic.match = semantic.match.toString()
1068
1061
  semantic.apply = semantic.apply.toString()
1069
1062
  return semantic
1070
1063
  })
1071
1064
  config.bridges = (config.bridges || []).map((bridge) => {
1072
- bridge = {...bridge}
1065
+ bridge = { ...bridge }
1073
1066
  delete bridge.where
1074
1067
  if (bridge.generatorp) {
1075
1068
  bridge.generatorp = bridge.generatorp.toString()
@@ -1093,13 +1086,13 @@ class Config {
1093
1086
  }
1094
1087
  }
1095
1088
  const toCanonicalQueries = (elements) => {
1096
- return elements.map( toCanonicalQuery )
1089
+ return elements.map(toCanonicalQuery)
1097
1090
  }
1098
1091
 
1099
1092
  const templateQueries = toCanonicalQueries(template.queries || []).map(helpers.updateQueries)
1100
1093
  const instanceQueries = toCanonicalQueries(instance.queries || [])
1101
1094
  let sameQueries = true
1102
- let startOfChanges;
1095
+ let startOfChanges
1103
1096
  for (let iq = 0; iq < templateQueries.length; ++iq) {
1104
1097
  if (!helpers.safeEquals(templateQueries[iq], instanceQueries[iq])) {
1105
1098
  sameQueries = false
@@ -1109,8 +1102,8 @@ class Config {
1109
1102
 
1110
1103
  const debug = true
1111
1104
  if (debug && startOfChanges) {
1112
- console.log('templateQueries[startOfChanges]', templateQueries[startOfChanges]);
1113
- console.log('instanceQueries[startOfChanges]', instanceQueries[startOfChanges]);
1105
+ console.log('templateQueries[startOfChanges]', templateQueries[startOfChanges])
1106
+ console.log('instanceQueries[startOfChanges]', instanceQueries[startOfChanges])
1114
1107
  }
1115
1108
 
1116
1109
  // things were deleted case
@@ -1126,8 +1119,8 @@ class Config {
1126
1119
  debugger
1127
1120
  }
1128
1121
  // console.log("instance", instance)
1129
- console.log("sameQueries", sameQueries)
1130
- console.log("sameFragments", sameFragments)
1122
+ console.log('sameQueries', sameQueries)
1123
+ console.log('sameFragments', sameFragments)
1131
1124
  // console.log("templateFragments", templateFragments)
1132
1125
  // console.log("instanceFragments", instanceFragments)
1133
1126
  // console.log('template.queries', JSON.stringify(toCanonicalQueries(template.queries || []).map(helpers.updateQueries), null, 2))
@@ -1145,8 +1138,8 @@ class Config {
1145
1138
  if (!template.queries && !template.fragments) {
1146
1139
  throw new Error(`Expected the template for ${this.name} to be an object that can have the properties: queries and fragments`)
1147
1140
  }
1148
- for (let query of template.queries || []) {
1149
- if (typeof query == 'string') {
1141
+ for (const query of template.queries || []) {
1142
+ if (typeof query === 'string') {
1150
1143
  } else if (query instanceof Config) {
1151
1144
  throw new Error(`For the template for ${this.name}, each element in queries should be either a string or a structure with a config (not a Config object).`)
1152
1145
  }
@@ -1159,7 +1152,7 @@ class Config {
1159
1152
  }
1160
1153
 
1161
1154
  // loadTemplate
1162
- load (template, instance, options = { rebuild: false, previousResultss: undefined, startOfChanges: undefined } ) {
1155
+ load (template, instance, options = { rebuild: false, previousResultss: undefined, startOfChanges: undefined }) {
1163
1156
  this.validifyTemplate(template)
1164
1157
  instance.template = template
1165
1158
  this.logs.push(`loading template for ${this.name}`)
@@ -1171,15 +1164,15 @@ class Config {
1171
1164
  } else {
1172
1165
  // no change
1173
1166
  // this.initInstances.push({ ...instance, name: config.name })
1174
- const isEmpty = ( instance ) => {
1167
+ const isEmpty = (instance) => {
1175
1168
  const properties = [
1176
- "queries",
1177
- "resultss",
1178
- "fragments",
1179
- "semantics",
1180
- "associations",
1169
+ 'queries',
1170
+ 'resultss',
1171
+ 'fragments',
1172
+ 'semantics',
1173
+ 'associations'
1181
1174
  ]
1182
- return !properties.find( (property) => instance[property] && instance[property].length > 0 )
1175
+ return !properties.find((property) => instance[property] && instance[property].length > 0)
1183
1176
  }
1184
1177
  if (!isEmpty(instance)) {
1185
1178
  // fix up apply functions
@@ -1197,7 +1190,7 @@ class Config {
1197
1190
  }
1198
1191
  }
1199
1192
 
1200
- addFragments(fragments) {
1193
+ addFragments (fragments) {
1201
1194
  // only run this if not loading as module write error if loading as module and different
1202
1195
  this.dynamicFragments = this.dynamicFragments.concat(fragments)
1203
1196
  }
@@ -1207,12 +1200,12 @@ class Config {
1207
1200
  }
1208
1201
 
1209
1202
  addAssociations (associations) {
1210
- for (let association of associations) {
1203
+ for (const association of associations) {
1211
1204
  this.addAssociation(association)
1212
1205
  }
1213
1206
  }
1214
1207
 
1215
- debugConfig() {
1208
+ debugConfig () {
1216
1209
  }
1217
1210
 
1218
1211
  addAssociation (association) {
@@ -1241,17 +1234,17 @@ class Config {
1241
1234
  }
1242
1235
 
1243
1236
  addPriorities (priorities) {
1244
- for (let priority of priorities) {
1237
+ for (const priority of priorities) {
1245
1238
  this.addPriority(priority)
1246
1239
  }
1247
1240
  }
1248
1241
 
1249
1242
  addHierarchy (child, parent) {
1250
- if (child && parent || !child || Array.isArray(child) || (typeof child == 'string' && !parent)) {
1243
+ if (child && parent || !child || Array.isArray(child) || (typeof child === 'string' && !parent)) {
1251
1244
  this.addHierarchyChildParent(child, parent)
1252
1245
  // this.addHierarchyProperties ({ child, parent })
1253
1246
  } else {
1254
- this.addHierarchyProperties (child)
1247
+ this.addHierarchyProperties(child)
1255
1248
  }
1256
1249
  }
1257
1250
 
@@ -1277,8 +1270,8 @@ class Config {
1277
1270
  throw new Error(`addHierarchy expected parent to be a string. got ${JSON.stringify(parent)}`)
1278
1271
  }
1279
1272
  debugHierarchy([child, parent])
1280
- if (this.config.hierarchy.find( (element) => {
1281
- const hc = hierarchyCanonical(element)
1273
+ if (this.config.hierarchy.find((element) => {
1274
+ const hc = hierarchyCanonical(element)
1282
1275
  if (child == hc.child && parent == hc.parent) {
1283
1276
  return true
1284
1277
  }
@@ -1293,9 +1286,9 @@ class Config {
1293
1286
 
1294
1287
  getBridge (id, level) {
1295
1288
  if (level) {
1296
- return this.config.bridges.find( (bridge) => bridge.id == id && bridge.level == level )
1289
+ return this.config.bridges.find((bridge) => bridge.id == id && bridge.level == level)
1297
1290
  } else {
1298
- return this.config.bridges.find( (bridge) => bridge.id == id)
1291
+ return this.config.bridges.find((bridge) => bridge.id == id)
1299
1292
  }
1300
1293
  }
1301
1294
 
@@ -1305,12 +1298,12 @@ class Config {
1305
1298
  }
1306
1299
  const bridges = this.config.bridges
1307
1300
  const def = Object.assign({}, bridge, { uuid: uuid || this._uuid })
1308
-
1301
+
1309
1302
  debugBridge(bridge)
1310
1303
  if (bridge.allowDups) {
1311
1304
  // if (bridges.find( (b) => b.id == bridge.id && b.level == bridge.level && b.bridge == bridge.bridge )) {
1312
- if (bridges.find( (b) => b.id == bridge.id && b.level == bridge.level)) {
1313
- return;
1305
+ if (bridges.find((b) => b.id == bridge.id && b.level == bridge.level)) {
1306
+ return
1314
1307
  }
1315
1308
  }
1316
1309
  if (global.transitoryMode) {
@@ -1318,7 +1311,7 @@ class Config {
1318
1311
  }
1319
1312
  handleBridgeProps(this, def)
1320
1313
  bridges.push(def)
1321
- this.checkBridges();
1314
+ this.checkBridges()
1322
1315
  this._delta.json.bridges.push({ action: 'add', bridge: def })
1323
1316
  }
1324
1317
 
@@ -1366,8 +1359,8 @@ class Config {
1366
1359
  semantics.unshift(semantic)
1367
1360
  }
1368
1361
 
1369
- removeSemantic(deleteSemantic) {
1370
- const index = this.config.semantics.findIndex( (semantic) => semantic.id === deleteSemantic.id )
1362
+ removeSemantic (deleteSemantic) {
1363
+ const index = this.config.semantics.findIndex((semantic) => semantic.id === deleteSemantic.id)
1371
1364
  if (index >= 0) {
1372
1365
  this.config.semantics.splice(index, 1)
1373
1366
  }
@@ -1380,7 +1373,7 @@ class Config {
1380
1373
 
1381
1374
  const operators = this.config.operators
1382
1375
 
1383
- let operator;
1376
+ let operator
1384
1377
  if (typeof objectOrPattern === 'string') {
1385
1378
  operator = { pattern: objectOrPattern, uuid: uuid || this._uuid }
1386
1379
  } else {
@@ -1390,8 +1383,8 @@ class Config {
1390
1383
  debugOperator(operator)
1391
1384
 
1392
1385
  if (operator.allowDups) {
1393
- if (operators.find( (o) => o.pattern == operator.pattern )) {
1394
- return;
1386
+ if (operators.find((o) => o.pattern == operator.pattern)) {
1387
+ return
1395
1388
  }
1396
1389
  }
1397
1390
 
@@ -1450,19 +1443,19 @@ class Config {
1450
1443
  }
1451
1444
  }
1452
1445
 
1453
- getServer() {
1446
+ getServer () {
1454
1447
  return this._server
1455
1448
  }
1456
1449
 
1457
- getAPIKey() {
1450
+ getAPIKey () {
1458
1451
  return this._key
1459
1452
  }
1460
1453
 
1461
- getQueryParams() {
1454
+ getQueryParams () {
1462
1455
  return this._queryParams
1463
1456
  }
1464
1457
 
1465
- setQueryParams(queryParams) {
1458
+ setQueryParams (queryParams) {
1466
1459
  this._queryParams = queryParams
1467
1460
  }
1468
1461
 
@@ -1570,14 +1563,14 @@ class Config {
1570
1563
  }
1571
1564
 
1572
1565
  getConfigs () {
1573
- const configs = {};
1566
+ const configs = {}
1574
1567
  configs[this.name] = this
1575
1568
  for (const config of this.configs) {
1576
1569
  if (config.config instanceof Config) {
1577
1570
  configs[config.config.name] = config.config
1578
1571
  }
1579
1572
  }
1580
- return configs;
1573
+ return configs
1581
1574
  }
1582
1575
 
1583
1576
  getConfigByUUID (uuid) {
@@ -1606,18 +1599,18 @@ class Config {
1606
1599
  }
1607
1600
  }
1608
1601
 
1609
- removeDevelopmentElements(config) {
1602
+ removeDevelopmentElements (config) {
1610
1603
  if (!config) {
1611
1604
  return
1612
1605
  }
1613
- config.operators = config.operators.filter( (element) => !element.development )
1614
- config.bridges = config.bridges.filter( (element) => !element.development )
1615
- config.generators = config.generators.filter( (element) => !element.development )
1616
- config.semantics = config.semantics.filter( (element) => !element.development )
1617
- config.hierarchy = (config.hierarchy).filter( (element) => !element.development )
1606
+ config.operators = config.operators.filter((element) => !element.development)
1607
+ config.bridges = config.bridges.filter((element) => !element.development)
1608
+ config.generators = config.generators.filter((element) => !element.development)
1609
+ config.semantics = config.semantics.filter((element) => !element.development)
1610
+ config.hierarchy = (config.hierarchy).filter((element) => !element.development)
1618
1611
  for (const word in config.words) {
1619
1612
  const defs = config.words[word] || []
1620
- config.words[word] = defs.filter( (def) => !def.development )
1613
+ config.words[word] = defs.filter((def) => !def.development)
1621
1614
  if (config.words[word].length == 0) {
1622
1615
  delete config.words[word]
1623
1616
  }
@@ -1740,11 +1733,11 @@ class Config {
1740
1733
  debugConfigProps(this.config)
1741
1734
  }
1742
1735
 
1743
- addArgs(moreArgs) {
1736
+ addArgs (moreArgs) {
1744
1737
  this.addedArgss.push(moreArgs)
1745
1738
  }
1746
1739
 
1747
- getAddedArgs(args) {
1740
+ getAddedArgs (args) {
1748
1741
  for (let addedArgs of this.addedArgss) {
1749
1742
  addedArgs = addedArgs(args)
1750
1743
  Object.assign(args, addedArgs)
@@ -1768,9 +1761,9 @@ class Config {
1768
1761
  }
1769
1762
 
1770
1763
  delta () {
1771
- return {
1772
- cacheKey: this._delta.cacheKey,
1773
- json: this._delta.json
1764
+ return {
1765
+ cacheKey: this._delta.cacheKey,
1766
+ json: this._delta.json
1774
1767
  }
1775
1768
  }
1776
1769
 
@@ -1783,7 +1776,7 @@ class Config {
1783
1776
  bridges: [],
1784
1777
  associations: [],
1785
1778
  priorities: [],
1786
- hierarchy: [],
1779
+ hierarchy: []
1787
1780
  }
1788
1781
  }
1789
1782
  }
@@ -1800,11 +1793,11 @@ class Config {
1800
1793
  }
1801
1794
  }
1802
1795
 
1803
- addAPI(api) {
1796
+ addAPI (api) {
1804
1797
  if (this._api && this._api.multiApi) {
1805
1798
  this._api.add(this, this._api, api)
1806
1799
  } else {
1807
- throw new Error("Can only add apis to a multi-api")
1800
+ throw new Error('Can only add apis to a multi-api')
1808
1801
  }
1809
1802
  }
1810
1803
 
@@ -1867,15 +1860,15 @@ class Config {
1867
1860
  }
1868
1861
 
1869
1862
  // TODO add more details
1870
- equal(config) {
1863
+ equal (config) {
1871
1864
  if (JSON.stringify(this.config) != JSON.stringify(config.config)) {
1872
- debugger;
1873
- return false;
1865
+ debugger
1866
+ return false
1874
1867
  }
1875
1868
  return true
1876
1869
  }
1877
1870
 
1878
- dump(fn) {
1871
+ dump (fn) {
1879
1872
  runtime.fs.writeFileSync(fn, JSON.stringify(this.config, 0, 2))
1880
1873
  }
1881
1874
 
@@ -1887,7 +1880,7 @@ class Config {
1887
1880
  const cp = new Config()
1888
1881
  cp.logs = []
1889
1882
  cp.maxDepth = this.maxDepth
1890
- cp.debugLoops = this.debugLoops
1883
+ cp.debugLoops = this.debugLoops
1891
1884
  cp.transitoryMode = this.transitoryMode
1892
1885
  cp.configs = this.configs.map((km) => km.copy2(Object.assign({}, options, { getCounter: (name) => cp.getCounter(name), callInitializers: false })))
1893
1886
  cp._uuid = cp.configs[0]._uuid
@@ -1924,7 +1917,7 @@ class Config {
1924
1917
  cp.mapUUIDs(map)
1925
1918
 
1926
1919
  if (cp._uuid == 'concept2') {
1927
- // debugger
1920
+ // debugger
1928
1921
  }
1929
1922
  if (options.callInitializers) {
1930
1923
  cp.rebuild(options)
@@ -1947,7 +1940,7 @@ class Config {
1947
1940
  // const namespace = km.namespace
1948
1941
  cp.config.objects.namespaced[km._uuid] = {}
1949
1942
  })
1950
- /*
1943
+ /*
1951
1944
  if (cp._uuid == 'concept2') {
1952
1945
  if (!cp.api.objects.defaultTypesForHierarchy) {
1953
1946
  debugger
@@ -2087,7 +2080,7 @@ class Config {
2087
2080
 
2088
2081
  initializer (fn, options = {}) {
2089
2082
  if (options) {
2090
- for (let option of Object.keys(options)) {
2083
+ for (const option of Object.keys(options)) {
2091
2084
  const validOptions = []
2092
2085
  if (!validOptions.includes(option)) {
2093
2086
  throw new Error(`For Config.initializer, unrecognized option ${option}. The valid options are ${validOptions}`)
@@ -2253,7 +2246,7 @@ class Config {
2253
2246
  // rebuild ({ isModule: mainIsModule = false } = {}) {
2254
2247
  rebuild ({ isModule: mainIsModule } = {}) {
2255
2248
  this.resetDelta()
2256
- const debug = this.config.debug;
2249
+ const debug = this.config.debug
2257
2250
  this.config = _.cloneDeep(this.initConfig)
2258
2251
  this.hierarchy = new DigraphInternal(this.config.hierarchy)
2259
2252
  if (debug) {
@@ -2296,8 +2289,8 @@ class Config {
2296
2289
  // const aw = (word, def) => this.addWord(word, def)
2297
2290
  // const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
2298
2291
  let config = km.config
2299
-
2300
- if (config.addedArgss) {
2292
+
2293
+ if (config.addedArgss) {
2301
2294
  this.addedArgss = this.addedArgss.concat(config.addedArgss)
2302
2295
  }
2303
2296
 
@@ -2320,15 +2313,15 @@ class Config {
2320
2313
  return config
2321
2314
  }
2322
2315
  // const hierarchy = new DigraphInternal((config.config || {}).hierarchy)
2323
- const args = new Object(setupInitializerFNArgs(this, {
2324
- isModule,
2325
- hierarchy: this.hierarchy,
2316
+ const args = new Object(setupInitializerFNArgs(this, {
2317
+ isModule,
2318
+ hierarchy: this.hierarchy,
2326
2319
  testConfig: config,
2327
- currentConfig: config,
2328
- uuid: config._uuid,
2329
- objects: namespacedObjects,
2330
- namespace,
2331
- api: config.api,
2320
+ currentConfig: config,
2321
+ uuid: config._uuid,
2322
+ objects: namespacedObjects,
2323
+ namespace,
2324
+ api: config.api
2332
2325
  }))
2333
2326
 
2334
2327
  const currentConfig = args.currentConfig
@@ -2345,12 +2338,12 @@ class Config {
2345
2338
  // debugger
2346
2339
  // greg55
2347
2340
  config.initializerFn(args, { dontCallFn: true })
2348
- initAfterApis.unshift({ config, args })
2341
+ initAfterApis.unshift({ config, args })
2349
2342
  if (config._api) {
2350
2343
  if (config._api.initialize) {
2351
2344
  // reverse the list
2352
2345
  // TODO sync up the args with initialize of config
2353
- inits.unshift( () => config._api.initialize({ config: this, km: kmFn, ...args, api: config._api }) )
2346
+ inits.unshift(() => config._api.initialize({ config: this, km: kmFn, ...args, api: config._api }))
2354
2347
  // config._api.initialize({ config, api: config._api })
2355
2348
  } else {
2356
2349
  inits.unshift(null)
@@ -2392,13 +2385,13 @@ class Config {
2392
2385
  this.config.priorities = []
2393
2386
  this.config.associations = { positive: [], negative: [] }
2394
2387
  this.config.words = {}
2395
-
2388
+
2396
2389
  for (let i = 0; i < addInternals.length; ++i) {
2397
- let name;
2390
+ let name
2398
2391
  if (addInternals[i]) {
2399
2392
  this.addInternalR(addInternals[i], true, false, false, true)
2400
2393
  name = addInternals[i].name
2401
- } else{
2394
+ } else {
2402
2395
  // the ones defined in config must come after the ones in the templates
2403
2396
  this.config.generators = generators.concat(this.config.generators)
2404
2397
  this.config.semantics = semantics.concat(this.config.semantics)
@@ -2412,7 +2405,7 @@ class Config {
2412
2405
  }
2413
2406
  if (initAfterApis[i]) {
2414
2407
  const init = initAfterApis[i]
2415
- init.config.initializerFn({ ...init.args, kms: this.getConfigs(), isAfterApi: true})
2408
+ init.config.initializerFn({ ...init.args, kms: this.getConfigs(), isAfterApi: true })
2416
2409
  }
2417
2410
  const instance = this.instances.find((instance) => instance.name == name)
2418
2411
  if (instance) {
@@ -2427,9 +2420,10 @@ class Config {
2427
2420
  this.checkBridges()
2428
2421
  }
2429
2422
 
2430
- nameToUUID(name) {
2423
+ nameToUUID (name) {
2431
2424
  return this.configs.find((km) => km._name == name)._uuid
2432
2425
  }
2426
+
2433
2427
  // name: namespace name
2434
2428
  // others
2435
2429
  // if undefined namespace applies to first loaded config
@@ -2606,7 +2600,7 @@ class Config {
2606
2600
  context: context.map((id) => {
2607
2601
  return [toNS(id[0]), id[1]]
2608
2602
  }),
2609
- choose,
2603
+ choose
2610
2604
  }
2611
2605
  if (ordered) {
2612
2606
  priority.ordered = ordered
@@ -2631,7 +2625,7 @@ class Config {
2631
2625
  }
2632
2626
 
2633
2627
  const seen = {}
2634
- for (let operator of this.config.operators) {
2628
+ for (const operator of this.config.operators) {
2635
2629
  if (seen[operator.pattern]) {
2636
2630
  const key = `${operator.pattern} (namespace: ${operator.uuid})`
2637
2631
  throw new Error(`Operator '${key}' is defined more than once in the operators`)
@@ -2704,10 +2698,10 @@ class Config {
2704
2698
  throw new Error(`Setting invalid property ${property}`)
2705
2699
  }
2706
2700
 
2707
- if ('words' == property) {
2708
- for (let word in value) {
2709
- for (let def of value[word]) {
2710
- if (!def['uuid']) {
2701
+ if (property == 'words') {
2702
+ for (const word in value) {
2703
+ for (const def of value[word]) {
2704
+ if (!def.uuid) {
2711
2705
  throw new Error(`All definitions for '${property}' must have the uuid property set (config.uuid). uuid is missing from ${JSON.stringify(def)} for the word '${word}'`)
2712
2706
  }
2713
2707
  }
@@ -2715,8 +2709,8 @@ class Config {
2715
2709
  }
2716
2710
 
2717
2711
  if (['operators', 'bridges'].includes(property)) {
2718
- for (let def of value) {
2719
- if (!def['uuid']) {
2712
+ for (const def of value) {
2713
+ if (!def.uuid) {
2720
2714
  throw new Error(`All definitions for '${property}' must have the uuid property set (config.uuid). uuid is missing from ${JSON.stringify(def)}`)
2721
2715
  }
2722
2716
  }
@@ -2796,9 +2790,9 @@ class Config {
2796
2790
  this.configs.forEach((km) => {
2797
2791
  this.instances = (km._config.instances || this.initInstances.slice()).concat(this.instances)
2798
2792
  })
2799
- let noDups = []
2800
- for (let instance of this.instances) {
2801
- if (!noDups.find( (existing) => existing.name == instance.name )) {
2793
+ const noDups = []
2794
+ for (const instance of this.instances) {
2795
+ if (!noDups.find((existing) => existing.name == instance.name)) {
2802
2796
  noDups.push(instance)
2803
2797
  }
2804
2798
  }
@@ -2810,7 +2804,7 @@ class Config {
2810
2804
  }
2811
2805
 
2812
2806
  // TODO get rid of useOldVersion arg
2813
- addInternal (more, { uuid, addFirst = false, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false, handleCalculatedProps : hcps = false } = {}) {
2807
+ addInternal (more, { uuid, addFirst = false, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false, handleCalculatedProps: hcps = false } = {}) {
2814
2808
  validConfigProps(more)
2815
2809
  if (more instanceof Config) {
2816
2810
  more.initialize({ force: false })
@@ -2892,12 +2886,12 @@ class Config {
2892
2886
  const isDup = (op1, op2) => op1.pattern == op2.pattern
2893
2887
  for (const newOne of more[key]) {
2894
2888
  for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
2895
- const oldOne = this.config[key][iOldOne];
2889
+ const oldOne = this.config[key][iOldOne]
2896
2890
  if (isDup(newOne, oldOne)) {
2897
2891
  if (oldOne.allowDups) {
2898
2892
  // the old one takes precedence to match what would happen during the original load
2899
2893
  this.config[key].splice(iOldOne, 1)
2900
- break;
2894
+ break
2901
2895
  }
2902
2896
  }
2903
2897
  }
@@ -2908,14 +2902,14 @@ class Config {
2908
2902
  const idDup = (b1, b2) => b1.id == b2.id && b1.level == b2.level && b1.bridge == b2.bridge
2909
2903
  for (const newOne of more[key]) {
2910
2904
  for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
2911
- const oldOne = this.config[key][iOldOne];
2905
+ const oldOne = this.config[key][iOldOne]
2912
2906
  if (newOne.id == oldOne.id) {
2913
2907
  if (oldOne.allowDups) {
2914
2908
  // the old one takes precedence to match what would happen during the original load
2915
2909
  this.config[key].splice(iOldOne, 1)
2916
- break;
2910
+ break
2917
2911
  }
2918
- }
2912
+ }
2919
2913
  }
2920
2914
  }
2921
2915
  }
@@ -3013,12 +3007,12 @@ class Config {
3013
3007
  const isDup = (op1, op2) => op1.pattern == op2.pattern
3014
3008
  for (const newOne of more[key]) {
3015
3009
  for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
3016
- const oldOne = this.config[key][iOldOne];
3010
+ const oldOne = this.config[key][iOldOne]
3017
3011
  if (isDup(newOne, oldOne)) {
3018
3012
  if (oldOne.allowDups) {
3019
3013
  // the old one takes precedence to match what would happen during the original load
3020
3014
  this.config[key].splice(iOldOne, 1)
3021
- break;
3015
+ break
3022
3016
  }
3023
3017
  }
3024
3018
  }
@@ -3029,12 +3023,12 @@ class Config {
3029
3023
  const idDup = (b1, b2) => b1.id == b2.id && b1.level == b2.level && b1.bridge == b2.bridge
3030
3024
  for (const newOne of more[key]) {
3031
3025
  for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
3032
- const oldOne = this.config[key][iOldOne];
3026
+ const oldOne = this.config[key][iOldOne]
3033
3027
  if (newOne.id == oldOne.id) {
3034
3028
  if (oldOne.allowDups) {
3035
3029
  // the old one takes precedence to match what would happen during the original load
3036
3030
  this.config[key].splice(iOldOne, 1)
3037
- break;
3031
+ break
3038
3032
  }
3039
3033
  }
3040
3034
  }
@@ -3060,5 +3054,5 @@ module.exports = {
3060
3054
  Config,
3061
3055
  config_toServer,
3062
3056
  operatorKey_valid,
3063
- handleBridgeProps,
3057
+ handleBridgeProps
3064
3058
  }