theprogrammablemind_4wp 9.5.1 → 9.6.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 +100 -57
- package/lines.js +7 -0
- package/package.json +5 -4
- package/runtime.js +0 -1
- package/src/config.js +330 -76
- package/src/configHelpers.js +68 -35
- package/src/fragments.js +83 -0
- package/src/generators.js +20 -14
- package/src/helpers.js +107 -3
- package/src/project2.js +54 -4
- package/src/semantics.js +21 -16
package/src/config.js
CHANGED
|
@@ -10,6 +10,7 @@ const { ecatch } = require('./helpers')
|
|
|
10
10
|
const runtime = require('../runtime')
|
|
11
11
|
const _ = require('lodash')
|
|
12
12
|
const db = require('./debug')
|
|
13
|
+
const { fragmentInstantiator, fragmentMapperInstantiator } = require('./fragments')
|
|
13
14
|
|
|
14
15
|
const debugBreak = () => {
|
|
15
16
|
// debugger
|
|
@@ -287,7 +288,7 @@ const priority_valid = (cp) => {
|
|
|
287
288
|
const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
288
289
|
ecatch(`While processing the bridge for ${bridge.id}#${bridge.level}`,
|
|
289
290
|
() => {
|
|
290
|
-
if (bridge.
|
|
291
|
+
if (bridge.scope && config.isModule) {
|
|
291
292
|
return
|
|
292
293
|
}
|
|
293
294
|
if (false && !bridge.bridge) {
|
|
@@ -334,6 +335,8 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
334
335
|
config.addPriority({ context: [[bridge.id, bridge.level], after], choose: [0] })
|
|
335
336
|
}
|
|
336
337
|
}
|
|
338
|
+
|
|
339
|
+
// done in setTestConfig
|
|
337
340
|
if (bridge.check) {
|
|
338
341
|
if (!config.testConfig) {
|
|
339
342
|
config.testConfig = {}
|
|
@@ -344,12 +347,15 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
344
347
|
if (!config.testConfig?.checks?.context) {
|
|
345
348
|
config.testConfig.checks.context = []
|
|
346
349
|
}
|
|
347
|
-
config.
|
|
350
|
+
config.contextChecksFromBridges.push({
|
|
351
|
+
'bridge.id': bridge.id,
|
|
352
|
+
'bridge.check': bridge.check,
|
|
348
353
|
match: ({context}) => context.marker == bridge.id,
|
|
349
354
|
exported: true,
|
|
350
355
|
apply: ({context}) => bridge.check,
|
|
351
356
|
})
|
|
352
357
|
}
|
|
358
|
+
|
|
353
359
|
if (bridge.after) {
|
|
354
360
|
for (let before of bridge.after) {
|
|
355
361
|
if (typeof before === 'string') {
|
|
@@ -399,11 +405,15 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
399
405
|
if (bridge.generatorp) {
|
|
400
406
|
const match = bridge.generatorp.match || (() => true)
|
|
401
407
|
const apply = typeof bridge.generatorp === 'function' ? bridge.generatorp : bridge.generatorp.apply || bridge.generatorp
|
|
402
|
-
|
|
408
|
+
let level = bridge.generatorp.level >= 0 ? bridge.generatorp.level : bridge.level + 1
|
|
409
|
+
if (!bridge.bridge) {
|
|
410
|
+
level = 0
|
|
411
|
+
}
|
|
403
412
|
|
|
404
413
|
const generator = {
|
|
405
414
|
where: bridge.generatorp.where || bridge.where || helpers.where(4),
|
|
406
|
-
match: async (args) => bridge.id === args.context.marker && args.context.level === level && args.context.paraphrase && await match(args),
|
|
415
|
+
// match: async (args) => bridge.id === args.context.marker && args.context.level === level && args.context.paraphrase && await match(args),
|
|
416
|
+
match: async (args) => args.isA(args.context.marker, bridge.id) && args.context.level === level && args.context.paraphrase && await match(args),
|
|
407
417
|
apply: (args) => apply(args),
|
|
408
418
|
applyWrapped: apply,
|
|
409
419
|
property: 'generatorp'
|
|
@@ -420,7 +430,8 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
420
430
|
const level = bridge.generatorr.level >= 0 ? bridge.generatorr.level : bridge.level + 1
|
|
421
431
|
const generator = {
|
|
422
432
|
where: bridge.generatorr.where || bridge.where || helpers.where(4),
|
|
423
|
-
match: async (args) => bridge.id === args.context.marker && args.context.level === level && !args.context.paraphrase && (args.context.response || args.context.isResponse) && await match(args),
|
|
433
|
+
// match: async (args) => bridge.id === args.context.marker && args.context.level === level && !args.context.paraphrase && (args.context.response || args.context.isResponse) && await match(args),
|
|
434
|
+
match: async (args) => args.isA(args.context.marker, bridge.id) && args.context.level === level && !args.context.paraphrase && (args.context.response || args.context.isResponse) && await match(args),
|
|
424
435
|
apply: (args) => apply(args),
|
|
425
436
|
applyWrapped: apply,
|
|
426
437
|
property: 'generatorr'
|
|
@@ -439,13 +450,32 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
439
450
|
if (semantic.apply && typeof semantic !== 'function') {
|
|
440
451
|
apply = semantic.apply
|
|
441
452
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
453
|
+
let semanticDef
|
|
454
|
+
if (semantic.raw) {
|
|
455
|
+
if (!semantic.match) {
|
|
456
|
+
throw new Error(`In the KM "${config.name}", for the bridge ${bridge.id} the semantic is missing the "match" property.`)
|
|
457
|
+
}
|
|
458
|
+
if (!semantic.apply) {
|
|
459
|
+
throw new Error(`In the KM "${config.name}", for the bridge ${bridge.id} the semantic is missing the "apply" property.`)
|
|
460
|
+
}
|
|
461
|
+
semanticDef = {
|
|
462
|
+
match: semantic.match,
|
|
463
|
+
apply: semantic.apply,
|
|
464
|
+
applyWrapped: semantic,
|
|
465
|
+
}
|
|
466
|
+
} else {
|
|
467
|
+
semanticDef = {
|
|
468
|
+
match: (args) => bridge.id === args.context.marker && !!args.context.evaluate === evaluate && match(args),
|
|
469
|
+
apply: (args) => apply(args),
|
|
470
|
+
applyWrapped: semantic,
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
semanticDef.where = semantic.where || bridge.where || helpers.where(4)
|
|
474
|
+
semanticDef.property = evaluate ? 'evaluator' : 'semantic'
|
|
475
|
+
if (semantic.priority) {
|
|
476
|
+
semanticDef.priority = semantic.priority
|
|
448
477
|
}
|
|
478
|
+
|
|
449
479
|
if (addFirst) {
|
|
450
480
|
config.config.semantics.unshift(addUUID(semanticDef))
|
|
451
481
|
} else {
|
|
@@ -488,8 +518,43 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
|
|
|
488
518
|
if (moreConfig.bridges) {
|
|
489
519
|
moreConfig.bridges = moreConfig.bridges.map((bridge) => {
|
|
490
520
|
bridge = { ...bridge }
|
|
491
|
-
const valid = [
|
|
492
|
-
'
|
|
521
|
+
const valid = [
|
|
522
|
+
'after',
|
|
523
|
+
'associations',
|
|
524
|
+
'before',
|
|
525
|
+
'bridge',
|
|
526
|
+
'check',
|
|
527
|
+
'children',
|
|
528
|
+
'conditional',
|
|
529
|
+
'convolution',
|
|
530
|
+
'disabled',
|
|
531
|
+
'enhanced_associations',
|
|
532
|
+
'evaluator',
|
|
533
|
+
'evaluators',
|
|
534
|
+
'generatorp',
|
|
535
|
+
'generatorpr',
|
|
536
|
+
'generatorr',
|
|
537
|
+
'generators',
|
|
538
|
+
'id',
|
|
539
|
+
'inverted',
|
|
540
|
+
'isA',
|
|
541
|
+
'level',
|
|
542
|
+
'levelSpecificHierarchy',
|
|
543
|
+
'localHierarchy',
|
|
544
|
+
'operator',
|
|
545
|
+
'optional',
|
|
546
|
+
'parents',
|
|
547
|
+
'return_type_selector',
|
|
548
|
+
'scope',
|
|
549
|
+
'selector',
|
|
550
|
+
'semantic',
|
|
551
|
+
'semantics',
|
|
552
|
+
'separators',
|
|
553
|
+
'skipable',
|
|
554
|
+
'uuid',
|
|
555
|
+
'where',
|
|
556
|
+
'words', /Bridge$/,
|
|
557
|
+
]
|
|
493
558
|
helpers.validProps(valid, bridge, 'bridge')
|
|
494
559
|
handleBridgeProps(baseConfig, bridge, { addFirst, uuid })
|
|
495
560
|
return bridge
|
|
@@ -652,7 +717,7 @@ function setWordsUUIDs (words, uuid) {
|
|
|
652
717
|
for (const key in literals) {
|
|
653
718
|
literals[key] = literals[key].map((o) => Object.assign(o, { uuid }))
|
|
654
719
|
}
|
|
655
|
-
const patterns = words.patterns
|
|
720
|
+
const patterns = words.patterns || []
|
|
656
721
|
for (const pattern of patterns) {
|
|
657
722
|
pattern.defs.map((def) => Object.assign(def, { uuid }))
|
|
658
723
|
}
|
|
@@ -881,6 +946,10 @@ class Config {
|
|
|
881
946
|
return config_toServer(config)
|
|
882
947
|
}
|
|
883
948
|
|
|
949
|
+
async run(handler) {
|
|
950
|
+
return configHelpers.run(this, handler)
|
|
951
|
+
}
|
|
952
|
+
|
|
884
953
|
async fixtures () {
|
|
885
954
|
if (this.testConfig?.fixtures) {
|
|
886
955
|
const args = {}
|
|
@@ -914,6 +983,7 @@ class Config {
|
|
|
914
983
|
|
|
915
984
|
getPseudoConfig (uuid, config) {
|
|
916
985
|
return {
|
|
986
|
+
pseudo: true,
|
|
917
987
|
description: 'this is a pseudo config that has limited functionality due to being available in the initializer and fixtures function context',
|
|
918
988
|
addAssociation: (...args) => this.addAssociation(...args),
|
|
919
989
|
addAssociations: (...args) => this.addAssociations(...args),
|
|
@@ -927,6 +997,22 @@ class Config {
|
|
|
927
997
|
removeSemantic: (...args) => this.removeSemantic(...args, uuid, config.name),
|
|
928
998
|
addWord: (...args) => this.addWord(...args, uuid),
|
|
929
999
|
addPattern: (...args) => this.addPattern(...args, uuid),
|
|
1000
|
+
updateBridge: (...args) => this.updateBridge(...args),
|
|
1001
|
+
processContext: (...args) => this.processContext(...args),
|
|
1002
|
+
|
|
1003
|
+
semantics: () => this.config.semantics,
|
|
1004
|
+
getConfigs: () => this.configs,
|
|
1005
|
+
getTestConfig: () => this.getTestConfig(),
|
|
1006
|
+
getTests: () => this.getTests(),
|
|
1007
|
+
getName: () => this.getName(),
|
|
1008
|
+
getDescription: () => this.getDescription(),
|
|
1009
|
+
getDebug: () => this.getDebug(),
|
|
1010
|
+
getDebugLoops: () => this.getDebugLoops(),
|
|
1011
|
+
getMaxDepth: () => this.getMaxDepth(),
|
|
1012
|
+
getAPIs: (...args) => this.getAPIs(...args),
|
|
1013
|
+
getAPI: (...args) => this.getAPI(...args),
|
|
1014
|
+
getUUID: (...args) => this.getUUID(...args),
|
|
1015
|
+
nsToString: (...args) => this.nsToString(...args),
|
|
930
1016
|
|
|
931
1017
|
getHierarchy: (...args) => this.config.hierarchy,
|
|
932
1018
|
getBridges: (...args) => this.config.bridges,
|
|
@@ -936,10 +1022,53 @@ class Config {
|
|
|
936
1022
|
fragment: (...args) => this.fragment(...args),
|
|
937
1023
|
server: (...args) => this.server(...args),
|
|
938
1024
|
exists: (...args) => this.exists(...args),
|
|
939
|
-
addAPI: (...args) => this.addAPI(...args)
|
|
1025
|
+
addAPI: (...args) => this.addAPI(...args),
|
|
1026
|
+
|
|
1027
|
+
getParenthesized: () => this.getParenthesized(),
|
|
1028
|
+
setParenthesized: (...args) => this.setParenthesized(...args),
|
|
940
1029
|
}
|
|
941
1030
|
}
|
|
942
1031
|
|
|
1032
|
+
getUUID() {
|
|
1033
|
+
return this.uuid
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
getTestConfig() {
|
|
1037
|
+
return this.testConfig
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
getMaxDepth() {
|
|
1041
|
+
return this.config.maxDepth
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
getDebug() {
|
|
1045
|
+
return this.config.debug
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
getDebugLoops() {
|
|
1049
|
+
return this.config.debugLoops
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
getName() {
|
|
1053
|
+
return this.name
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
getDescription() {
|
|
1057
|
+
return this.description
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
getTests() {
|
|
1061
|
+
return this.tests
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
getParenthesized(value) {
|
|
1065
|
+
return this.parenthesized
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
setParenthesized(value) {
|
|
1069
|
+
this.parenthesized = value
|
|
1070
|
+
}
|
|
1071
|
+
|
|
943
1072
|
inDevelopmentMode (call) {
|
|
944
1073
|
config.developmentModeOn += 1
|
|
945
1074
|
try {
|
|
@@ -956,7 +1085,27 @@ class Config {
|
|
|
956
1085
|
}
|
|
957
1086
|
|
|
958
1087
|
setTestConfig (testConfig) {
|
|
959
|
-
this.testConfig = testConfig
|
|
1088
|
+
this.testConfig = { ...testConfig }
|
|
1089
|
+
if (!this.testConfig.checks) {
|
|
1090
|
+
this.testConfig.checks = {}
|
|
1091
|
+
}
|
|
1092
|
+
if (!this.testConfig?.checks?.context) {
|
|
1093
|
+
this.testConfig.checks.context = []
|
|
1094
|
+
}
|
|
1095
|
+
this.testConfig.checks.context = this.contextChecksFromBridges.concat(this.testConfig.checks.context)
|
|
1096
|
+
/*
|
|
1097
|
+
const currentTestConfig = testConfig // add bridge has added check.context's
|
|
1098
|
+
|
|
1099
|
+
if (!this.testConfig.checks) {
|
|
1100
|
+
debugger
|
|
1101
|
+
// this.testConfig.checks =
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
// set during bridge setup
|
|
1105
|
+
if (currentTestConfig.checks?.context) {
|
|
1106
|
+
this.testConfig.checks.context = currentTestConfig.checks.context.concat(this.testConfig.checks.context)
|
|
1107
|
+
}
|
|
1108
|
+
*/
|
|
960
1109
|
}
|
|
961
1110
|
|
|
962
1111
|
getTestConfig () {
|
|
@@ -1086,59 +1235,52 @@ class Config {
|
|
|
1086
1235
|
return instance
|
|
1087
1236
|
}
|
|
1088
1237
|
|
|
1089
|
-
|
|
1090
|
-
return new Object({
|
|
1091
|
-
contexts: () => contexts,
|
|
1092
|
-
instantiate: async (mappings) => {
|
|
1093
|
-
const instantiated = _.cloneDeep(contexts)
|
|
1094
|
-
// const todo = [...instantiated]
|
|
1095
|
-
// const todo = [...instantiated]
|
|
1096
|
-
const todo = _.clone(instantiated)
|
|
1097
|
-
args = { ...args }
|
|
1098
|
-
while (todo.length > 0) {
|
|
1099
|
-
const context = todo.pop()
|
|
1100
|
-
args.context = context
|
|
1101
|
-
for (const mapping of mappings) {
|
|
1102
|
-
if (await mapping.match(args)) {
|
|
1103
|
-
await mapping.apply(args)
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
for (const key of Object.keys(context)) {
|
|
1107
|
-
// if (['number', 'string', 'boolean'].includes(typeof (context[key]))) {
|
|
1108
|
-
if (!helpers.isCompound(context[key])) {
|
|
1109
|
-
continue
|
|
1110
|
-
}
|
|
1111
|
-
if (context[key].instantiated) {
|
|
1112
|
-
continue
|
|
1113
|
-
}
|
|
1114
|
-
todo.push(context[key])
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
return instantiated
|
|
1118
|
-
}
|
|
1119
|
-
})
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
fragment (args, query) {
|
|
1238
|
+
getFragment(query) {
|
|
1123
1239
|
for (const instance of (this.instances || [])) {
|
|
1124
1240
|
for (const fragment of (instance.fragments || [])) {
|
|
1125
1241
|
if (fragment.query === query) {
|
|
1126
|
-
return
|
|
1242
|
+
return fragment
|
|
1127
1243
|
}
|
|
1128
1244
|
}
|
|
1129
1245
|
for (const fragment of (instance.resultss || [])) {
|
|
1130
1246
|
if (fragment.isFragment && fragment.query === query) {
|
|
1131
|
-
return
|
|
1247
|
+
return fragment
|
|
1132
1248
|
}
|
|
1133
1249
|
}
|
|
1134
1250
|
for (const fragment of (this.fragmentsBeingBuilt || [])) {
|
|
1135
1251
|
if (fragment.query === query) {
|
|
1136
|
-
return
|
|
1252
|
+
return fragment
|
|
1137
1253
|
}
|
|
1138
1254
|
}
|
|
1139
1255
|
}
|
|
1140
1256
|
}
|
|
1141
1257
|
|
|
1258
|
+
// mappings are optional
|
|
1259
|
+
async fragment (args, query, mappings) {
|
|
1260
|
+
const fragment = this.getFragment(query)
|
|
1261
|
+
if (fragment) {
|
|
1262
|
+
let fi = fragmentInstantiator(args, fragment.contexts)
|
|
1263
|
+
if (mappings) {
|
|
1264
|
+
fi = await fi
|
|
1265
|
+
return fi.instantiate([{
|
|
1266
|
+
match: ({context}) => !!mappings[context.value], // is the value in the mappings
|
|
1267
|
+
apply: ({context}) => Object.assign(context, mappings[context.value]),
|
|
1268
|
+
}])
|
|
1269
|
+
} else {
|
|
1270
|
+
return fi
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
fragmentMapper (args, values, fromModelQuery, toModelQuery) {
|
|
1276
|
+
const fromModelFragment = this.getFragment(fromModelQuery)
|
|
1277
|
+
console.dir(fromModelFragment)
|
|
1278
|
+
const toModelFragment = this.getFragment(toModelQuery)
|
|
1279
|
+
console.dir(toModelFragment)
|
|
1280
|
+
const mapper = fragmentMapperInstantiator(values, fromModelFragment.contexts, toModelFragment.contexts)
|
|
1281
|
+
return mapper
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1142
1284
|
// { rebuild: false, isModule: false }
|
|
1143
1285
|
needsRebuild (template, instance, options) {
|
|
1144
1286
|
if (options.rebuild) {
|
|
@@ -1497,6 +1639,11 @@ class Config {
|
|
|
1497
1639
|
}
|
|
1498
1640
|
}
|
|
1499
1641
|
|
|
1642
|
+
updateBridge(id, updater) {
|
|
1643
|
+
const bridge = this.config.bridges.find((b) => b.id === id)
|
|
1644
|
+
updater({ config: this, bridge })
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1500
1647
|
addBridge (bridge, uuid) {
|
|
1501
1648
|
if (!this.config.bridges) {
|
|
1502
1649
|
this.config.bridges = []
|
|
@@ -1681,7 +1828,9 @@ class Config {
|
|
|
1681
1828
|
|
|
1682
1829
|
getAPIs (uuid) {
|
|
1683
1830
|
let config
|
|
1684
|
-
if (
|
|
1831
|
+
if (!uuid) {
|
|
1832
|
+
config = this
|
|
1833
|
+
} else if (this._uuid === uuid) {
|
|
1685
1834
|
config = this
|
|
1686
1835
|
} else {
|
|
1687
1836
|
for (const km of this.configs) {
|
|
@@ -1696,6 +1845,14 @@ class Config {
|
|
|
1696
1845
|
}
|
|
1697
1846
|
}
|
|
1698
1847
|
|
|
1848
|
+
/*
|
|
1849
|
+
getAPIs (config) {
|
|
1850
|
+
if (config && config._api && config._api.multiApi) {
|
|
1851
|
+
return config._api.apis
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
*/
|
|
1855
|
+
|
|
1699
1856
|
getServer () {
|
|
1700
1857
|
return this._server
|
|
1701
1858
|
}
|
|
@@ -1798,7 +1955,7 @@ class Config {
|
|
|
1798
1955
|
|
|
1799
1956
|
// set the args in the api's
|
|
1800
1957
|
setArgs (args) {
|
|
1801
|
-
const
|
|
1958
|
+
const setConfigArgs = (config) => {
|
|
1802
1959
|
if (!config._api) {
|
|
1803
1960
|
return
|
|
1804
1961
|
}
|
|
@@ -1811,10 +1968,10 @@ class Config {
|
|
|
1811
1968
|
}
|
|
1812
1969
|
}
|
|
1813
1970
|
|
|
1814
|
-
|
|
1971
|
+
setConfigArgs(this)
|
|
1815
1972
|
for (const config of this.configs) {
|
|
1816
1973
|
if (config.config instanceof Config) {
|
|
1817
|
-
|
|
1974
|
+
setConfigArgs(config.config)
|
|
1818
1975
|
}
|
|
1819
1976
|
}
|
|
1820
1977
|
}
|
|
@@ -1843,6 +2000,16 @@ class Config {
|
|
|
1843
2000
|
}
|
|
1844
2001
|
}
|
|
1845
2002
|
|
|
2003
|
+
getObjects () {
|
|
2004
|
+
const configs = {}
|
|
2005
|
+
const ns = this.config.objects.namespaced
|
|
2006
|
+
configs[this.name] = this
|
|
2007
|
+
for (const config of this.configs) {
|
|
2008
|
+
configs[config._name] = ns[config._uuid]
|
|
2009
|
+
}
|
|
2010
|
+
return configs
|
|
2011
|
+
}
|
|
2012
|
+
|
|
1846
2013
|
getConfig (name) {
|
|
1847
2014
|
if (this.name === name) {
|
|
1848
2015
|
return this
|
|
@@ -1867,20 +2034,68 @@ class Config {
|
|
|
1867
2034
|
return kms
|
|
1868
2035
|
}
|
|
1869
2036
|
|
|
2037
|
+
// scope == 'testing' -> remove none
|
|
2038
|
+
// scope == 'development' -> remove testing
|
|
2039
|
+
// !scope -> remove 'testing' and 'development'
|
|
1870
2040
|
removeDevelopmentElements (config) {
|
|
1871
2041
|
if (!config) {
|
|
1872
2042
|
return
|
|
1873
2043
|
}
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
2044
|
+
|
|
2045
|
+
const idToScope = {}
|
|
2046
|
+
for (const bridge in config.bridges) {
|
|
2047
|
+
if (bridge.scope) {
|
|
2048
|
+
idToScope[bridge.id] = scope
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
const keep = (element) => {
|
|
2053
|
+
const old_result = element.scope !== 'testing'
|
|
2054
|
+
let new_result = false
|
|
2055
|
+
if (!this.scope) {
|
|
2056
|
+
new_result = !(element.scope === 'testing' || element.scope == 'development')
|
|
2057
|
+
} else if (this.scope == 'development') {
|
|
2058
|
+
new_result = !(element.scope === 'testing')
|
|
2059
|
+
}
|
|
2060
|
+
return new_result
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
config.operators = config.operators.filter((element) => keep(element))
|
|
2064
|
+
config.bridges = config.bridges.filter((element) => keep(element))
|
|
2065
|
+
config.generators = config.generators.filter((element) => keep(element))
|
|
2066
|
+
config.semantics = config.semantics.filter((element) => keep(element))
|
|
2067
|
+
|
|
2068
|
+
// account for element missing correct scope
|
|
2069
|
+
config.hierarchy = (config.hierarchy).filter((element) => {
|
|
2070
|
+
if (!keep(element)) {
|
|
2071
|
+
return false
|
|
2072
|
+
}
|
|
2073
|
+
const discard = (id) => {
|
|
2074
|
+
if (idToScope[id]) {
|
|
2075
|
+
return !keep({ scope: idToScope[id] })
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
if (element.child && discard(element.child)) {
|
|
2079
|
+
return false
|
|
2080
|
+
}
|
|
2081
|
+
if (element.parent && discard(element.parent)) {
|
|
2082
|
+
return false
|
|
2083
|
+
}
|
|
2084
|
+
if (Array.isArray(element)) {
|
|
2085
|
+
if (discard(element[0])) {
|
|
2086
|
+
return false
|
|
2087
|
+
}
|
|
2088
|
+
if (discard(element[1])) {
|
|
2089
|
+
return false
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
return true
|
|
2093
|
+
})
|
|
1879
2094
|
|
|
1880
2095
|
const literals = config.words.literals
|
|
1881
2096
|
for (const word in literals) {
|
|
1882
2097
|
const defs = literals[word] || []
|
|
1883
|
-
literals[word] = defs.filter((def) =>
|
|
2098
|
+
literals[word] = defs.filter((def) => keep(def))
|
|
1884
2099
|
if (literals[word].length === 0) {
|
|
1885
2100
|
delete literals[word]
|
|
1886
2101
|
}
|
|
@@ -1890,7 +2105,7 @@ class Config {
|
|
|
1890
2105
|
const patternsPrime = []
|
|
1891
2106
|
for (const pattern of patterns) {
|
|
1892
2107
|
let defs = pattern.defs || []
|
|
1893
|
-
defs = defs.filter((def) =>
|
|
2108
|
+
defs = defs.filter((def) => keep(def))
|
|
1894
2109
|
if (defs.length !== 0) {
|
|
1895
2110
|
patternsPrime.push({ ...pattern, defs })
|
|
1896
2111
|
}
|
|
@@ -1900,7 +2115,7 @@ class Config {
|
|
|
1900
2115
|
const hierarchy = config.words.hierarchy || []
|
|
1901
2116
|
const hierarchyPrime = []
|
|
1902
2117
|
for (const pair of hierarchy) {
|
|
1903
|
-
if (
|
|
2118
|
+
if (keep(pair)) {
|
|
1904
2119
|
hierarchyPrime.push(pair)
|
|
1905
2120
|
}
|
|
1906
2121
|
}
|
|
@@ -1925,7 +2140,7 @@ class Config {
|
|
|
1925
2140
|
}
|
|
1926
2141
|
|
|
1927
2142
|
// configs = [ { config, namespace } ... ]
|
|
1928
|
-
constructor (config, module, clientProcess, apiKMs) {
|
|
2143
|
+
constructor (config, module, clientProcess, apiKMs, rootIsProcess, testingModuleName) {
|
|
1929
2144
|
if (config instanceof Config) {
|
|
1930
2145
|
throw new Error('Excepted the config argument to be a hash not a Config object')
|
|
1931
2146
|
}
|
|
@@ -1947,6 +2162,8 @@ class Config {
|
|
|
1947
2162
|
config.priorities = config.priorities || []
|
|
1948
2163
|
}
|
|
1949
2164
|
|
|
2165
|
+
this.contextChecksFromBridges = []
|
|
2166
|
+
|
|
1950
2167
|
this._enable = []
|
|
1951
2168
|
this._apiKMs = apiKMs
|
|
1952
2169
|
|
|
@@ -1965,9 +2182,26 @@ class Config {
|
|
|
1965
2182
|
this.loadedForTesting = true
|
|
1966
2183
|
}
|
|
1967
2184
|
}
|
|
2185
|
+
if (config) {
|
|
2186
|
+
this.name = config.name
|
|
2187
|
+
}
|
|
1968
2188
|
this.isModule = !isProcess
|
|
2189
|
+
this.scope = null
|
|
2190
|
+
this.rootIsProcess = rootIsProcess
|
|
2191
|
+
this.testingModuleName = testingModuleName
|
|
1969
2192
|
if (this.isModule) {
|
|
2193
|
+
if (rootIsProcess) {
|
|
2194
|
+
if (testingModuleName == this.name) {
|
|
2195
|
+
this.scope = 'testing'
|
|
2196
|
+
} else {
|
|
2197
|
+
this.scope = 'development'
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
1970
2200
|
this.removeDevelopmentElements(config)
|
|
2201
|
+
} else {
|
|
2202
|
+
if (testingModuleName == this.name) {
|
|
2203
|
+
this.scope = 'testing'
|
|
2204
|
+
}
|
|
1971
2205
|
}
|
|
1972
2206
|
this.initInstances = []
|
|
1973
2207
|
this.instances = []
|
|
@@ -1989,7 +2223,7 @@ class Config {
|
|
|
1989
2223
|
|
|
1990
2224
|
// set the default server so stuff just works
|
|
1991
2225
|
// this.server('https://184.67.27.82:3000', '6804954f-e56d-471f-bbb8-08e3c54d9321')
|
|
1992
|
-
this.server('https://thinktelligence.com
|
|
2226
|
+
this.server('https://thinktelligence.com/entodicton', '6804954f-e56d-471f-bbb8-08e3c54d9321')
|
|
1993
2227
|
|
|
1994
2228
|
this.defaultConfig()
|
|
1995
2229
|
this.initializerFn = ({ currentConfig }) => {
|
|
@@ -1998,9 +2232,6 @@ class Config {
|
|
|
1998
2232
|
}
|
|
1999
2233
|
}
|
|
2000
2234
|
this.terminatorFn = () => {}
|
|
2001
|
-
if (config) {
|
|
2002
|
-
this.name = config.name
|
|
2003
|
-
}
|
|
2004
2235
|
this.loadOrder = new DigraphInternal()
|
|
2005
2236
|
this.wasInitialized = false
|
|
2006
2237
|
this.configs = []
|
|
@@ -2259,6 +2490,7 @@ class Config {
|
|
|
2259
2490
|
// update uuid here set the uuid in the objects and add error checking
|
|
2260
2491
|
cp.initializerFn = this.initializerFn
|
|
2261
2492
|
cp.terminatorFn = this.terminatorFn
|
|
2493
|
+
cp.contextChecksFromBridges = this.contextChecksFromBridges
|
|
2262
2494
|
cp._apiKMs = this._apiKMs
|
|
2263
2495
|
cp._apiConstructor = this._apiConstructor
|
|
2264
2496
|
if (cp._apiConstructor) {
|
|
@@ -2290,6 +2522,10 @@ class Config {
|
|
|
2290
2522
|
cp.hierarchy = new DigraphInternal(this.config.hierarchy)
|
|
2291
2523
|
cp.sendObjectsToServer = this.sendObjectsToServer
|
|
2292
2524
|
|
|
2525
|
+
cp.scope = this.scope
|
|
2526
|
+
cp.rootIsProcess = this.rootIsProcess
|
|
2527
|
+
cp.testingModuleName = this.testingModuleName
|
|
2528
|
+
|
|
2293
2529
|
cp.initConfig = _.cloneDeep(this.initConfig)
|
|
2294
2530
|
cp.defaultConfig()
|
|
2295
2531
|
// cp.wasInitialized = false; // since default config GREG
|
|
@@ -2615,19 +2851,37 @@ class Config {
|
|
|
2615
2851
|
|
|
2616
2852
|
getContextChecks() {
|
|
2617
2853
|
const allChecks = []
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
for (const
|
|
2621
|
-
|
|
2622
|
-
|
|
2854
|
+
let defaults = () => []
|
|
2855
|
+
if (this.loadOrdering) {
|
|
2856
|
+
for (const name of this.loadOrdering) {
|
|
2857
|
+
const checks = this.kms[name].testConfig?.checks?.context || []
|
|
2858
|
+
const oldDefaults = defaults
|
|
2859
|
+
for (const check of checks) {
|
|
2860
|
+
if (!check.match) {
|
|
2861
|
+
const oldDefaults = defaults
|
|
2862
|
+
defaults = () => helpers.safeNoDups([...check.apply(), ...oldDefaults()])
|
|
2863
|
+
continue
|
|
2864
|
+
}
|
|
2865
|
+
if (check.exported) {
|
|
2866
|
+
allChecks.push(check)
|
|
2867
|
+
}
|
|
2623
2868
|
}
|
|
2624
2869
|
}
|
|
2625
2870
|
}
|
|
2626
2871
|
for (const check of this.testConfig?.checks?.context || []) {
|
|
2872
|
+
if (!check.match) {
|
|
2873
|
+
const oldDefaults = defaults
|
|
2874
|
+
defaults = () => [...new Set([...check.apply(), ...oldDefaults()])]
|
|
2875
|
+
continue
|
|
2876
|
+
}
|
|
2627
2877
|
if (!check.exported) {
|
|
2628
2878
|
allChecks.push(check)
|
|
2629
2879
|
}
|
|
2630
2880
|
}
|
|
2881
|
+
allChecks.push({
|
|
2882
|
+
match: () => true,
|
|
2883
|
+
apply: defaults
|
|
2884
|
+
})
|
|
2631
2885
|
return allChecks
|
|
2632
2886
|
}
|
|
2633
2887
|
|
|
@@ -3144,7 +3398,7 @@ class Config {
|
|
|
3144
3398
|
|
|
3145
3399
|
const mores = []
|
|
3146
3400
|
for (const createConfig of createConfigs) {
|
|
3147
|
-
const more = await createConfig()
|
|
3401
|
+
const more = await createConfig({ rootIsProcess: this.rootIsProcess, testingModuleName: this.testingModuleName })
|
|
3148
3402
|
if (this.name && this.name === more.name) {
|
|
3149
3403
|
throw new Error('Cannot add an object to itself for argument number ${index+1}.')
|
|
3150
3404
|
}
|