theprogrammablemind_4wp 7.5.8-beta.26 → 7.5.8-beta.27
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 +46 -30
- package/package.json +1 -1
- package/src/config.js +59 -84
- package/src/helpers.js +1 -1
- package/src/semantics.js +6 -1
package/client.js
CHANGED
@@ -15,14 +15,16 @@ const sortJson = runtime.sortJson
|
|
15
15
|
|
16
16
|
const getAsk = (config) => (uuid) => (asks) => {
|
17
17
|
for (let ask of asks) {
|
18
|
-
config.
|
18
|
+
config.addSemantic({
|
19
19
|
uuid,
|
20
|
+
oneShot: true,
|
20
21
|
match: (args) => ask.matchr(args),
|
21
22
|
apply: (args) => ask.applyr(args)
|
22
23
|
})
|
23
24
|
}
|
24
|
-
config.
|
25
|
+
config.addSemantic({
|
25
26
|
uuid,
|
27
|
+
oneShot: true,
|
26
28
|
match: ({context}) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
|
27
29
|
apply: (args) => {
|
28
30
|
for (let ask of asks) {
|
@@ -37,7 +39,7 @@ const getAsk = (config) => (uuid) => (asks) => {
|
|
37
39
|
}
|
38
40
|
}
|
39
41
|
if (matchq(args)) {
|
40
|
-
args.context.motivationKeep = true
|
42
|
+
// args.context.motivationKeep = true
|
41
43
|
args.context.verbatim = applyq(args)
|
42
44
|
args.context.isResponse = true;
|
43
45
|
delete args.context.controlRemove;
|
@@ -144,7 +146,6 @@ const setupArgs = (args, config, logs, hierarchy) => {
|
|
144
146
|
apis: getAPIs(uuid)
|
145
147
|
}
|
146
148
|
}
|
147
|
-
args.motivation = (m) => config.addMotivation(m)
|
148
149
|
args.breakOnSemantics = false
|
149
150
|
args.theDebugger = {
|
150
151
|
breakOnSemantics: (value) => args.breakOnSemantics = value
|
@@ -420,18 +421,16 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
420
421
|
}
|
421
422
|
const generateParenthesized = isTest || (commandLineArgs && commandLineArgs.save)
|
422
423
|
if (!config.get('skipSemantics')) {
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
e.message += `\nThe most called semantic was:\nnotes: ${mostCalled.notes}\nmatch: ${mostCalled.matcher.toString()}\napply: ${mostCalled._apply.toString()}\n`
|
431
|
-
}
|
432
|
-
// contextPrime = semantics.apply(args, { marker: 'error', context, error: e })
|
433
|
-
contextPrime = semantics.apply(args, { marker: 'error', context, reason: e.reason })
|
424
|
+
const semantics = config.getSemantics(json.logs)
|
425
|
+
try {
|
426
|
+
contextPrime = semantics.apply(args, context)
|
427
|
+
} catch( e ) {
|
428
|
+
if (e.message == 'Maximum call stack size exceeded') {
|
429
|
+
const mostCalled = semantics.getMostCalled()
|
430
|
+
e.message += `\nThe most called semantic was:\nnotes: ${mostCalled.notes}\nmatch: ${mostCalled.matcher.toString()}\napply: ${mostCalled._apply.toString()}\n`
|
434
431
|
}
|
432
|
+
// contextPrime = semantics.apply(args, { marker: 'error', context, error: e })
|
433
|
+
contextPrime = semantics.apply(args, { marker: 'error', context, reason: e.reason })
|
435
434
|
}
|
436
435
|
}
|
437
436
|
if (contextPrime.controlRemove) {
|
@@ -767,7 +766,6 @@ const runTest = async (config, expected, { args, verbose, afterTest, testConfig,
|
|
767
766
|
testConfigName = testConfig.testModuleName
|
768
767
|
}
|
769
768
|
config.beforeQuery({ query: test, isModule: false, objects })
|
770
|
-
// config.resetMotivations()
|
771
769
|
try {
|
772
770
|
const result = await _process(config, test, { errorHandler, isTest: true })
|
773
771
|
result.query = test
|
@@ -785,12 +783,17 @@ const runTest = async (config, expected, { args, verbose, afterTest, testConfig,
|
|
785
783
|
delete expected_objects.nameToUUID
|
786
784
|
const actual_objects = sortJson(convertToStable(config.config.objects), { depth: 25 })
|
787
785
|
const failed_paraphrases = !matching(result.paraphrases, expected.paraphrases)
|
788
|
-
|
789
|
-
|
786
|
+
let failed_paraphrasesParenthesized = !matching(result.paraphrasesParenthesized, expected.paraphrasesParenthesized)
|
787
|
+
let failed_generatedParenthesized = !matching(result.generatedParenthesized, expected.generatedParenthesized)
|
790
788
|
const failed_responses = !matching(result.responses, expected.responses)
|
791
789
|
const failed_contexts = !matching(result.contexts, expected.contexts)
|
792
790
|
const failed_objects = !matching(actual_objects, expected_objects)
|
793
791
|
|
792
|
+
if (args.testNoParenthesized) {
|
793
|
+
failed_paraphrasesParenthesized = false
|
794
|
+
failed_generatedParenthesized = false
|
795
|
+
}
|
796
|
+
|
794
797
|
const pickEm = (getObjects) => {
|
795
798
|
const picked = {}
|
796
799
|
for (let prop of (testConfig.check || [])) {
|
@@ -816,6 +819,11 @@ const runTest = async (config, expected, { args, verbose, afterTest, testConfig,
|
|
816
819
|
}
|
817
820
|
return expected.objects.namespaced[expected.objects.nameToUUID[name]]
|
818
821
|
}
|
822
|
+
try {
|
823
|
+
sortJson(pickEm(expectedGetObjects), { depth: 25 })
|
824
|
+
} catch ( e ) {
|
825
|
+
debugger
|
826
|
+
}
|
819
827
|
const expected_checked = sortJson(pickEm(expectedGetObjects), { depth: 25 })
|
820
828
|
const actualGetObjects = (name) => {
|
821
829
|
if (!name) {
|
@@ -942,7 +950,6 @@ const runTests = async (config, testFile, juicyBits) => {
|
|
942
950
|
const saveTest = async (testFile, config, test, expected, testConfig, saveDeveloper) => {
|
943
951
|
config.rebuild()
|
944
952
|
const objects = getObjects(config.config.objects)(config.uuid)
|
945
|
-
//config.resetMotivations()
|
946
953
|
config.beforeQuery({ query: test, isModule: false, objects })
|
947
954
|
console.log(test)
|
948
955
|
const result = await _process(config, test, { isTest: true })
|
@@ -1216,8 +1223,6 @@ entodicton.knowledgeModule( {
|
|
1216
1223
|
*/
|
1217
1224
|
|
1218
1225
|
const rebuildTemplate = async ({ config, target, template, errorHandler = defaultErrorHandler }) => {
|
1219
|
-
debugger
|
1220
|
-
// config = config.base()
|
1221
1226
|
const accumulators = {
|
1222
1227
|
resultss: [],
|
1223
1228
|
fragments: [],
|
@@ -1241,8 +1246,6 @@ const rebuildTemplate = async ({ config, target, template, errorHandler = defaul
|
|
1241
1246
|
if (property == 'fragments') {
|
1242
1247
|
global.transitoryMode = true
|
1243
1248
|
}
|
1244
|
-
// greg32
|
1245
|
-
// config.addInternal( query )
|
1246
1249
|
if (hierarchy) {
|
1247
1250
|
for (let edge of hierarchy) {
|
1248
1251
|
if (Array.isArray(edge)) {
|
@@ -1284,6 +1287,12 @@ const rebuildTemplate = async ({ config, target, template, errorHandler = defaul
|
|
1284
1287
|
// it will just get added to the config
|
1285
1288
|
const extraConfig = queryOrExtraConfig
|
1286
1289
|
console.log('config', extraConfig)
|
1290
|
+
try {
|
1291
|
+
config.addInternal(_.cloneDeep(extraConfig), { handleCalculatedProps: true } )
|
1292
|
+
} catch ( e ) {
|
1293
|
+
const where = extraConfig.where ? ` ${extraConfig.where}` : ''
|
1294
|
+
throw new Error(`Error processing extra config${where}: ${e.stack}}`)
|
1295
|
+
}
|
1287
1296
|
accumulators[property].push({ extraConfig: true, ...extraConfig })
|
1288
1297
|
await looper(queries)
|
1289
1298
|
}
|
@@ -1474,6 +1483,7 @@ const knowledgeModule = async ({
|
|
1474
1483
|
parser.add_argument('-t', '--test', { action: 'store_true', help: 'Run the tests. Create tests by running with the --query + --save flag' })
|
1475
1484
|
parser.add_argument('-tv', '--testVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. Create tests by running with the --query or --loop with the --save flag' })
|
1476
1485
|
parser.add_argument('-tva', '--testAllVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. All the tests will be run instead of stopping at first failure. Create tests by running with the --query or --loop with the --save flag' })
|
1486
|
+
parser.add_argument('-tnp', '--testNoParenthesized', { action: 'store_true', help: 'Don\' check parenthesized differences for the tests' })
|
1477
1487
|
parser.add_argument('-n', '--count', { help: 'Number of times to run the tests. Default is one. Use this to check for flakey test. If possible the system will print out a message with the word "hint" suggesting how to fix the problem' })
|
1478
1488
|
// parser.add_argument('-b', '--build', { help: 'Specify the template file name of the form <kmName>. There should be a file called <baseKmName>.<kmName>.template.json with the queries to run. For example { queries: [...] }. The template file will be run and generate an instantiation called <baseKmName>.<kmName>.instance.json and a file called <kmName>.js that will load the template file (this is file generated only if not already existing) and a test file called <KmName>.tests.json. This can then be loaded into an instance of the current knowledge module to setup initial conditions.' })
|
1479
1489
|
parser.add_argument('-rt', '--rebuildTemplate', { action: 'store_true', help: 'Force a template rebuild' })
|
@@ -1730,11 +1740,13 @@ const knowledgeModule = async ({
|
|
1730
1740
|
if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
|
1731
1741
|
hasError = true
|
1732
1742
|
}
|
1733
|
-
if (
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1743
|
+
if (!args.testNoParenthesized) {
|
1744
|
+
if (JSON.stringify(result.expected.paraphrasesParenthesized) !== JSON.stringify(result.actual.paraphrasesParenthesized)) {
|
1745
|
+
hasError = true
|
1746
|
+
}
|
1747
|
+
if (JSON.stringify(result.expected.generatedParenthesized) !== JSON.stringify(result.actual.generatedParenthesized)) {
|
1748
|
+
hasError = true
|
1749
|
+
}
|
1738
1750
|
}
|
1739
1751
|
if (JSON.stringify(result.expected.responses) !== JSON.stringify(result.actual.responses)) {
|
1740
1752
|
hasError = true
|
@@ -1760,9 +1772,13 @@ const knowledgeModule = async ({
|
|
1760
1772
|
}
|
1761
1773
|
}
|
1762
1774
|
show('paraphrases', result.expected.paraphrases, result.actual.paraphrases)
|
1763
|
-
|
1775
|
+
if (!args.testNoParenthesized) {
|
1776
|
+
show('paraphrases parenthesized', result.expected.paraphrasesParenthesized, result.actual.paraphrasesParenthesized)
|
1777
|
+
}
|
1764
1778
|
show('responses', result.expected.responses, result.actual.responses)
|
1765
|
-
|
1779
|
+
if (!args.testNoParenthesized) {
|
1780
|
+
show('responses parenthesized', result.expected.generatedParenthesized, result.actual.generatedParenthesized)
|
1781
|
+
}
|
1766
1782
|
/*
|
1767
1783
|
if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
|
1768
1784
|
if (!headerShown) {
|
package/package.json
CHANGED
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
|
-
|
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')
|
@@ -30,6 +30,41 @@ const config_toServer = (config) => {
|
|
30
30
|
}
|
31
31
|
}
|
32
32
|
|
33
|
+
const validConfigProps = (config) => {
|
34
|
+
const valid = [
|
35
|
+
'hierarchy',
|
36
|
+
'objects',
|
37
|
+
'bridges',
|
38
|
+
'operators',
|
39
|
+
'words',
|
40
|
+
'priorities',
|
41
|
+
'contextual_priorities',
|
42
|
+
'associations',
|
43
|
+
'name',
|
44
|
+
'version',
|
45
|
+
'generators',
|
46
|
+
'semantics',
|
47
|
+
'where',
|
48
|
+
'floaters',
|
49
|
+
'debug',
|
50
|
+
|
51
|
+
// TODO Fix these from the test app
|
52
|
+
'implicits',
|
53
|
+
'convolution',
|
54
|
+
'expected_generated',
|
55
|
+
'expected_results',
|
56
|
+
'skipSemantics',
|
57
|
+
'description',
|
58
|
+
'contexts',
|
59
|
+
'utterances',
|
60
|
+
'flatten',
|
61
|
+
|
62
|
+
'namespaces',
|
63
|
+
'eqClasses',
|
64
|
+
]
|
65
|
+
helpers.validProps(valid, config, 'config')
|
66
|
+
}
|
67
|
+
|
33
68
|
const setupInitializerFNArgs = (config, args) => {
|
34
69
|
const aw = (word, def) => config.addWord(word, def, args.uuid)
|
35
70
|
const ag = (generator) => config.addGenerator(generator, args.uuid, config.name)
|
@@ -169,7 +204,7 @@ const handleBridgeProps = (config, bridge) => {
|
|
169
204
|
config.addWordInternal(def, {"id": bridge.id, "initial": `{ value: "${def}"}` })
|
170
205
|
} else {
|
171
206
|
const word = def.word
|
172
|
-
def = { initial: JSON.stringify(def), id: bridge.id, word
|
207
|
+
def = { initial: JSON.stringify(def), id: bridge.id, word }
|
173
208
|
config.addWordInternal(word, def)
|
174
209
|
}
|
175
210
|
}
|
@@ -249,7 +284,7 @@ const handleBridgeProps = (config, bridge) => {
|
|
249
284
|
const handleCalculatedProps = (baseConfig, moreConfig) => {
|
250
285
|
for (let bridge of moreConfig.bridges) {
|
251
286
|
const valid = [ 'after', 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generatorpr', 'generators', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
|
252
|
-
'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy', 'levelSpecificHierarchy', 'where' ]
|
287
|
+
'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy', 'levelSpecificHierarchy', 'where', 'uuid' ]
|
253
288
|
helpers.validProps(valid, bridge, 'bridge')
|
254
289
|
handleBridgeProps(baseConfig, bridge)
|
255
290
|
}
|
@@ -357,6 +392,14 @@ const normalizeConfig = (config) => {
|
|
357
392
|
}
|
358
393
|
}
|
359
394
|
}
|
395
|
+
|
396
|
+
if (config.semantics) {
|
397
|
+
for (let semantic of config.semantics) {
|
398
|
+
if (semantic.oneShot) {
|
399
|
+
semantic.id = uuid()
|
400
|
+
}
|
401
|
+
}
|
402
|
+
}
|
360
403
|
}
|
361
404
|
}
|
362
405
|
|
@@ -606,10 +649,9 @@ class Config {
|
|
606
649
|
if (km.isSelf) {
|
607
650
|
continue
|
608
651
|
}
|
609
|
-
console.log(km.config.name)
|
610
652
|
base.add(km.config)
|
611
653
|
}
|
612
|
-
|
654
|
+
return base
|
613
655
|
}
|
614
656
|
|
615
657
|
getPseudoConfig (uuid, config) {
|
@@ -1111,6 +1153,7 @@ class Config {
|
|
1111
1153
|
if (!(typeof semantic.match === 'function')) {
|
1112
1154
|
throw new Error('addSemantic: Expected match to be a function')
|
1113
1155
|
}
|
1156
|
+
|
1114
1157
|
if (!(typeof semantic.apply === 'function')) {
|
1115
1158
|
throw new Error('addSemantic: Expected apply to be a function')
|
1116
1159
|
}
|
@@ -1124,10 +1167,17 @@ class Config {
|
|
1124
1167
|
}
|
1125
1168
|
|
1126
1169
|
const semantics = this.config.semantics
|
1127
|
-
Object.assign(semantic, { uuid: uuid || this._uuid, km: name || this.name, index: semantics.length })
|
1170
|
+
Object.assign(semantic, { uuid: uuid || this._uuid, km: name || this.name, index: semantics.length, id: uuidv4() })
|
1128
1171
|
semantics.unshift(semantic)
|
1129
1172
|
}
|
1130
1173
|
|
1174
|
+
removeSemantic(deleteSemantic) {
|
1175
|
+
const index = this.config.semantics.findIndex( (semantic) => semantic.id === deleteSemantic.id )
|
1176
|
+
if (index >= 0) {
|
1177
|
+
this.config.semantics.splice(index, 1)
|
1178
|
+
}
|
1179
|
+
}
|
1180
|
+
|
1131
1181
|
addOperator (objectOrPattern, uuid) {
|
1132
1182
|
if (!this.config.operators) {
|
1133
1183
|
this.config.operators = []
|
@@ -1390,34 +1440,7 @@ class Config {
|
|
1390
1440
|
}
|
1391
1441
|
|
1392
1442
|
if (config) {
|
1393
|
-
|
1394
|
-
'hierarchy',
|
1395
|
-
'objects',
|
1396
|
-
'bridges',
|
1397
|
-
'operators',
|
1398
|
-
'words',
|
1399
|
-
'priorities',
|
1400
|
-
'contextual_priorities',
|
1401
|
-
'associations',
|
1402
|
-
'name',
|
1403
|
-
'version',
|
1404
|
-
'generators',
|
1405
|
-
'semantics',
|
1406
|
-
'floaters',
|
1407
|
-
'debug',
|
1408
|
-
|
1409
|
-
// TODO Fix these from the test app
|
1410
|
-
'implicits',
|
1411
|
-
'convolution',
|
1412
|
-
'expected_generated',
|
1413
|
-
'expected_results',
|
1414
|
-
'skipSemantics',
|
1415
|
-
'description',
|
1416
|
-
'contexts',
|
1417
|
-
'utterances',
|
1418
|
-
'flatten',
|
1419
|
-
]
|
1420
|
-
helpers.validProps(valid, config, 'config')
|
1443
|
+
validConfigProps(config)
|
1421
1444
|
|
1422
1445
|
config.operators = config.operators || []
|
1423
1446
|
config.bridges = config.bridges || []
|
@@ -1500,7 +1523,6 @@ class Config {
|
|
1500
1523
|
if (config) {
|
1501
1524
|
this.name = config.name
|
1502
1525
|
}
|
1503
|
-
this.motivations = []
|
1504
1526
|
this.loadOrder = new DigraphInternal()
|
1505
1527
|
this.wasInitialized = false
|
1506
1528
|
this.configs = []
|
@@ -1654,40 +1676,6 @@ class Config {
|
|
1654
1676
|
// this.valid() init was not run because the kms are not all setup yet
|
1655
1677
|
}
|
1656
1678
|
|
1657
|
-
// motivation === { match, apply, uuid }
|
1658
|
-
addMotivation (motivation) {
|
1659
|
-
if (!motivation.uuid) {
|
1660
|
-
motivation.uuid = this.uuid
|
1661
|
-
}
|
1662
|
-
this.motivations.push(motivation)
|
1663
|
-
}
|
1664
|
-
|
1665
|
-
resetMotivations () {
|
1666
|
-
this.motivations = []
|
1667
|
-
}
|
1668
|
-
|
1669
|
-
doMotivations (args, context) {
|
1670
|
-
args = Object.assign({}, args, { context, api: this.api })
|
1671
|
-
// console.log('src/config doMotivations this.uuid', this.uuid)
|
1672
|
-
// args.objects = args.getObjects(this.uuid)
|
1673
|
-
const motivations = this.motivations
|
1674
|
-
this.motivations = []
|
1675
|
-
let done = false
|
1676
|
-
for (const motivation of motivations) {
|
1677
|
-
args.objects = args.getObjects(motivation.uuid)
|
1678
|
-
if (!done && motivation.match(args)) {
|
1679
|
-
motivation.apply(args)
|
1680
|
-
if (args.context.controlKeepMotivation || motivation.repeat) {
|
1681
|
-
this.motivations.push(motivation)
|
1682
|
-
}
|
1683
|
-
done = true
|
1684
|
-
} else {
|
1685
|
-
this.motivations.push(motivation)
|
1686
|
-
}
|
1687
|
-
}
|
1688
|
-
return done
|
1689
|
-
}
|
1690
|
-
|
1691
1679
|
// TODO add more details
|
1692
1680
|
equal(config) {
|
1693
1681
|
if (JSON.stringify(this.config) != JSON.stringify(config.config)) {
|
@@ -1721,7 +1709,6 @@ class Config {
|
|
1721
1709
|
cp.name = this.name
|
1722
1710
|
cp.description = this.description
|
1723
1711
|
cp.tests = this.tests
|
1724
|
-
cp.motivations = [...this.motivations]
|
1725
1712
|
cp.isModule = this.isModule
|
1726
1713
|
cp.loadedForTesting = this.loadedForTesting
|
1727
1714
|
cp.initInstances = this.initInstances.slice()
|
@@ -1924,16 +1911,6 @@ class Config {
|
|
1924
1911
|
// const baseConfig = args.baseConfig
|
1925
1912
|
const currentConfig = args.currentConfig
|
1926
1913
|
|
1927
|
-
/*
|
1928
|
-
if (currentConfig.api) {
|
1929
|
-
// currentConfig.api.objects = args.objects
|
1930
|
-
// GREG42 currentConfig.api.config = () => this
|
1931
|
-
// currentConfig.api.config = () => args.baseConfig
|
1932
|
-
// currentConfig.api.uuid = currentConfig._uuid
|
1933
|
-
}
|
1934
|
-
*/
|
1935
|
-
// this.instances.forEach( (instance) => client.processInstance(this, instance) )
|
1936
|
-
// greg55
|
1937
1914
|
if (args.isAfterApi) {
|
1938
1915
|
fn(args)
|
1939
1916
|
}
|
@@ -2103,7 +2080,6 @@ class Config {
|
|
2103
2080
|
}
|
2104
2081
|
this.config.objects.namespaced = {}
|
2105
2082
|
this.resetWasInitialized()
|
2106
|
-
this.resetMotivations()
|
2107
2083
|
|
2108
2084
|
// reorder configs base on load ordering
|
2109
2085
|
{
|
@@ -2164,7 +2140,6 @@ class Config {
|
|
2164
2140
|
uuid: config._uuid,
|
2165
2141
|
objects: namespacedObjects,
|
2166
2142
|
namespace,
|
2167
|
-
motivation: (m) => this.addMotivation(m),
|
2168
2143
|
api: config.api,
|
2169
2144
|
}))
|
2170
2145
|
|
@@ -2284,7 +2259,6 @@ class Config {
|
|
2284
2259
|
}
|
2285
2260
|
this.hierarchy.edges = this.config.hierarchy
|
2286
2261
|
}
|
2287
|
-
// this.instances.forEach((instance) => client.processInstance(this, instance))
|
2288
2262
|
}
|
2289
2263
|
|
2290
2264
|
if (reverseIt) {
|
@@ -2683,6 +2657,7 @@ class Config {
|
|
2683
2657
|
|
2684
2658
|
// TODO get rid of useOldVersion arg
|
2685
2659
|
addInternal (more, { useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false, handleCalculatedProps : hcps = false } = {}) {
|
2660
|
+
validConfigProps(more)
|
2686
2661
|
if (more instanceof Config) {
|
2687
2662
|
more.initialize({ force: false })
|
2688
2663
|
if (useOldVersion) {
|
@@ -2780,7 +2755,7 @@ class Config {
|
|
2780
2755
|
this.config[key].splice(iOldOne, 1)
|
2781
2756
|
break;
|
2782
2757
|
}
|
2783
|
-
}
|
2758
|
+
}
|
2784
2759
|
}
|
2785
2760
|
}
|
2786
2761
|
}
|
package/src/helpers.js
CHANGED
package/src/semantics.js
CHANGED
@@ -6,7 +6,7 @@ class Semantic {
|
|
6
6
|
// constructor ({match, apply, uuid, index, km, notes}) {
|
7
7
|
constructor (semantic) {
|
8
8
|
semantic = normalizeSemantic(semantic)
|
9
|
-
const { match, apply, uuid, index, km, notes, priority, debug, where, applyWrapped, property } = semantic
|
9
|
+
const { match, apply, uuid, index, km, notes, priority, debug, where, applyWrapped, property, oneShot, id } = semantic
|
10
10
|
this.matcher = match
|
11
11
|
this._apply = apply
|
12
12
|
this._applyWrapped = applyWrapped
|
@@ -18,6 +18,8 @@ class Semantic {
|
|
18
18
|
this.notes = notes
|
19
19
|
this.callId = debug
|
20
20
|
this.where = where
|
21
|
+
this.oneShot = oneShot
|
22
|
+
this.id = id
|
21
23
|
}
|
22
24
|
|
23
25
|
toLabel () {
|
@@ -197,6 +199,9 @@ class Semantics {
|
|
197
199
|
const log = (message) => { this.logs.push(message) }
|
198
200
|
try {
|
199
201
|
contextPrime = semantic.apply(args, context, s, log, options)
|
202
|
+
if (!contextPrime.controlKeepMotivation && semantic.oneShot) {
|
203
|
+
args.config.removeSemantic(semantic)
|
204
|
+
}
|
200
205
|
} catch( e ) {
|
201
206
|
contextPrime = null
|
202
207
|
let errorMessage
|