theprogrammablemind 9.6.0-beta.3 → 9.6.0-beta.32
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 +17 -5
- package/package.json +2 -1
- package/src/config.js +60 -23
- package/src/configHelpers.js +36 -0
- package/src/debug.js +1 -0
- package/src/fragments.js +13 -0
- package/src/helpers.js +27 -0
- package/src/semantics.js +10 -0
package/client.js
CHANGED
|
@@ -292,7 +292,9 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
|
292
292
|
if (rebuildingTemplate) {
|
|
293
293
|
data.errors_ignore_contextual_priorities_non_existant_ops = true
|
|
294
294
|
}
|
|
295
|
-
|
|
295
|
+
|
|
296
|
+
// '\\n' from tests of '\n' from users. the former is because newline is not a valid json character so the testfile has it encoded
|
|
297
|
+
let queries = query.split(/\\n|\n/)
|
|
296
298
|
const summaries = [] // for error
|
|
297
299
|
try {
|
|
298
300
|
const response = {
|
|
@@ -796,6 +798,8 @@ const defaultErrorHandler = async (error) => {
|
|
|
796
798
|
if (typeof runtime.process.exit === 'function' && doErrorExit) {
|
|
797
799
|
runtime.process.exit(-1)
|
|
798
800
|
}
|
|
801
|
+
|
|
802
|
+
error.config = null // otherwise it dumps to much on the console
|
|
799
803
|
|
|
800
804
|
throw error
|
|
801
805
|
}
|
|
@@ -1222,6 +1226,7 @@ const knowledgeModuleImpl = async ({
|
|
|
1222
1226
|
errorHandler = defaultErrorHandler,
|
|
1223
1227
|
process: processResults = defaultProcess,
|
|
1224
1228
|
stopAtFirstFailure = true,
|
|
1229
|
+
demoInitializer,
|
|
1225
1230
|
...rest
|
|
1226
1231
|
} = {}) => {
|
|
1227
1232
|
const unknownArgs = Object.keys(rest)
|
|
@@ -1271,13 +1276,13 @@ const knowledgeModuleImpl = async ({
|
|
|
1271
1276
|
config.stop_auto_rebuild()
|
|
1272
1277
|
await config.add(...(includes || []))
|
|
1273
1278
|
if (api) {
|
|
1274
|
-
config.setApi(api)
|
|
1279
|
+
await config.setApi(api)
|
|
1275
1280
|
}
|
|
1276
1281
|
if (multiApiInitializer) {
|
|
1277
1282
|
await config.setMultiApi(multiApiInitializer)
|
|
1278
1283
|
}
|
|
1279
1284
|
if (initializer) {
|
|
1280
|
-
config.initializer(initializer)
|
|
1285
|
+
await config.initializer(initializer)
|
|
1281
1286
|
}
|
|
1282
1287
|
await config.restart_auto_rebuild()
|
|
1283
1288
|
return config
|
|
@@ -1306,7 +1311,7 @@ const knowledgeModuleImpl = async ({
|
|
|
1306
1311
|
const helpDebugPriority = 'In order to get a debug break when a specific set of priorities is created set set DEBUG_PRIORITY environment variable to the JSON of the priorities that you want to break on. For example DEBUG_PRIORITY=\'[["verb", 0], ["article", 0]]\''
|
|
1307
1312
|
const helpDebugContextualPriority = 'In order to get a debug break when a specific set of contextual priorities is created set set DEBUG_CONTEXTUAL_PRIORITY environment variable to the JSON of the priorities that you want to break on. For example DEBUG_CONTEXTUAL_PRIORITY=\'{ context: [["verb", 0], ["article", 0], select: 1}\''
|
|
1308
1313
|
const helpDebugBridge = 'In order to get a debug break when a specific bridge is created set the DEBUG_BRIDGE environment variable to id to break on. For example DEBUG_BRIDGE=\'car\''
|
|
1309
|
-
const helpDebugOperator = 'In order to get a debug break when a specific
|
|
1314
|
+
const helpDebugOperator = 'In order to get a debug break when a specific hierarchy is created set the DEBUG_OPERATOR environment variable to debug any config loaded. For example DEBUG_OPERATOR=\'([operator] ([arg]))\''
|
|
1310
1315
|
|
|
1311
1316
|
parser.add_argument('-tmn', '--testModuleName', { help: 'When running tests instead of using the current modules tests use the specified modules tests' })
|
|
1312
1317
|
parser.add_argument('-t', '--test', { action: 'store_true', help: 'Run the tests. Create tests by running with the --query + --save flag' })
|
|
@@ -1375,6 +1380,10 @@ const knowledgeModuleImpl = async ({
|
|
|
1375
1380
|
}
|
|
1376
1381
|
config = await createConfig(true, configStruct.name)
|
|
1377
1382
|
|
|
1383
|
+
if (demoInitializer) {
|
|
1384
|
+
await config.setDemoInitializer(demoInitializer)
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1378
1387
|
// dont debug the load of the KM's if rebuild template is on since we want to debug the template rebuild not the load
|
|
1379
1388
|
if (args.rebuildTemplate) {
|
|
1380
1389
|
global.pauseDebugging = true
|
|
@@ -1457,7 +1466,7 @@ const knowledgeModuleImpl = async ({
|
|
|
1457
1466
|
let tests = JSON.parse(runtime.fs.readFileSync(testConfig.name))
|
|
1458
1467
|
tests = tests.filter((test) => test.query !== args.deleteTest)
|
|
1459
1468
|
writeTestFile(testConfig.name, tests)
|
|
1460
|
-
console.log(`
|
|
1469
|
+
console.log(`Delete the test for "${args.deleteTest}"`)
|
|
1461
1470
|
return
|
|
1462
1471
|
}
|
|
1463
1472
|
|
|
@@ -2011,6 +2020,9 @@ const knowledgeModuleImpl = async ({
|
|
|
2011
2020
|
}
|
|
2012
2021
|
const config = await createConfig(rootIsProcess, testingModuleName)
|
|
2013
2022
|
await initConfig(config)
|
|
2023
|
+
if (demoInitializer) {
|
|
2024
|
+
config.setDemoInitializer(demoInitializer)
|
|
2025
|
+
}
|
|
2014
2026
|
// config.rebuild({ isModule: true })
|
|
2015
2027
|
createConfig.cached = config
|
|
2016
2028
|
return createConfig.cached
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"@typescript-eslint/eslint-plugin": "^4.28.4",
|
|
5
5
|
"@typescript-eslint/parser": "^4.28.4",
|
|
6
6
|
"argparse": "^2.0.1",
|
|
7
|
+
"baseline-browser-mapping": "^2.9.19",
|
|
7
8
|
"eslint": "^7.32.0",
|
|
8
9
|
"eslint-config-standard": "^16.0.3",
|
|
9
10
|
"eslint-plugin-import": "^2.23.4",
|
|
@@ -72,6 +73,6 @@
|
|
|
72
73
|
"scriptjs": "^2.5.9",
|
|
73
74
|
"uuid": "^8.3.2"
|
|
74
75
|
},
|
|
75
|
-
"version": "9.6.0-beta.
|
|
76
|
+
"version": "9.6.0-beta.32",
|
|
76
77
|
"license": "UNLICENSED"
|
|
77
78
|
}
|
package/src/config.js
CHANGED
|
@@ -338,6 +338,7 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
338
338
|
|
|
339
339
|
// done in setTestConfig
|
|
340
340
|
if (bridge.check) {
|
|
341
|
+
/*
|
|
341
342
|
if (!config.testConfig) {
|
|
342
343
|
config.testConfig = {}
|
|
343
344
|
}
|
|
@@ -347,6 +348,7 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
347
348
|
if (!config.testConfig?.checks?.context) {
|
|
348
349
|
config.testConfig.checks.context = []
|
|
349
350
|
}
|
|
351
|
+
*/
|
|
350
352
|
config.contextChecksFromBridges.push({
|
|
351
353
|
'bridge.id': bridge.id,
|
|
352
354
|
'bridge.check': bridge.check,
|
|
@@ -405,9 +407,15 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
405
407
|
if (bridge.generatorp) {
|
|
406
408
|
const match = bridge.generatorp.match || (() => true)
|
|
407
409
|
const apply = typeof bridge.generatorp === 'function' ? bridge.generatorp : bridge.generatorp.apply || bridge.generatorp
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
410
|
+
|
|
411
|
+
let level
|
|
412
|
+
if (bridge.generatorp.level >= 0) {
|
|
413
|
+
level = bridge.generatorp.level
|
|
414
|
+
} else {
|
|
415
|
+
level = bridge.level + 1
|
|
416
|
+
if (!bridge.bridge ) {
|
|
417
|
+
level = 0
|
|
418
|
+
}
|
|
411
419
|
}
|
|
412
420
|
|
|
413
421
|
const generator = {
|
|
@@ -427,11 +435,25 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
427
435
|
if (bridge.generatorr) {
|
|
428
436
|
const match = bridge.generatorr.match || (() => true)
|
|
429
437
|
const apply = typeof bridge.generatorr === 'function' ? bridge.generatorr : bridge.generatorr.apply || bridge.generatorr
|
|
430
|
-
const level = bridge.generatorr.level >= 0 ? bridge.generatorr.level : bridge.level + 1
|
|
438
|
+
// const level = bridge.generatorr.level >= 0 ? bridge.generatorr.level : bridge.level + 1
|
|
439
|
+
let level
|
|
440
|
+
if (bridge.generatorr.level >= 0) {
|
|
441
|
+
level = bridge.generatorr.level
|
|
442
|
+
} else {
|
|
443
|
+
level = bridge.level + 1
|
|
444
|
+
if (!bridge.bridge ) {
|
|
445
|
+
level = 0
|
|
446
|
+
}
|
|
447
|
+
}
|
|
431
448
|
const generator = {
|
|
432
449
|
where: bridge.generatorr.where || bridge.where || helpers.where(4),
|
|
433
450
|
// 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) =>
|
|
451
|
+
match: async (args) => {
|
|
452
|
+
if (bridge.callId == args.callId) {
|
|
453
|
+
debugger
|
|
454
|
+
}
|
|
455
|
+
return args.isA(args.context.marker, bridge.id) && args.context.level === level && !args.context.paraphrase && (args.context.response != null || args.context.isResponse) && await match(args)
|
|
456
|
+
},
|
|
435
457
|
apply: (args) => apply(args),
|
|
436
458
|
applyWrapped: apply,
|
|
437
459
|
property: 'generatorr'
|
|
@@ -523,6 +545,7 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
|
|
|
523
545
|
'associations',
|
|
524
546
|
'before',
|
|
525
547
|
'bridge',
|
|
548
|
+
'callId',
|
|
526
549
|
'check',
|
|
527
550
|
'children',
|
|
528
551
|
'conditional',
|
|
@@ -536,6 +559,7 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
|
|
|
536
559
|
'generatorr',
|
|
537
560
|
'generators',
|
|
538
561
|
'id',
|
|
562
|
+
'init',
|
|
539
563
|
'inverted',
|
|
540
564
|
'isA',
|
|
541
565
|
'level',
|
|
@@ -1094,19 +1118,6 @@ class Config {
|
|
|
1094
1118
|
this.testConfig.checks.context = []
|
|
1095
1119
|
}
|
|
1096
1120
|
this.testConfig.checks.context = this.contextChecksFromBridges.concat(this.testConfig.checks.context)
|
|
1097
|
-
/*
|
|
1098
|
-
const currentTestConfig = testConfig // add bridge has added check.context's
|
|
1099
|
-
|
|
1100
|
-
if (!this.testConfig.checks) {
|
|
1101
|
-
debugger
|
|
1102
|
-
// this.testConfig.checks =
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
// set during bridge setup
|
|
1106
|
-
if (currentTestConfig.checks?.context) {
|
|
1107
|
-
this.testConfig.checks.context = currentTestConfig.checks.context.concat(this.testConfig.checks.context)
|
|
1108
|
-
}
|
|
1109
|
-
*/
|
|
1110
1121
|
}
|
|
1111
1122
|
|
|
1112
1123
|
getTestConfig () {
|
|
@@ -1224,10 +1235,10 @@ class Config {
|
|
|
1224
1235
|
async getEvaluator (s, calls, log, context, args) {
|
|
1225
1236
|
const instance = await s({ ...args, ...context, evaluate: true })
|
|
1226
1237
|
calls.touch(instance)
|
|
1227
|
-
if (
|
|
1238
|
+
if (instance.evalue == null && !instance.verbatim && !instance.value) {
|
|
1228
1239
|
this.warningNotEvaluated(log, context)
|
|
1229
1240
|
}
|
|
1230
|
-
if (
|
|
1241
|
+
if (instance.evalue == null) {
|
|
1231
1242
|
instance.evalue = instance.value
|
|
1232
1243
|
instance.edefault = true
|
|
1233
1244
|
}
|
|
@@ -2140,6 +2151,11 @@ class Config {
|
|
|
2140
2151
|
}
|
|
2141
2152
|
}
|
|
2142
2153
|
|
|
2154
|
+
async setDemoInitializer(demoInitializer) {
|
|
2155
|
+
this.demoInitializer = demoInitializer
|
|
2156
|
+
// await this.demoInitializer(this)
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2143
2159
|
// configs = [ { config, namespace } ... ]
|
|
2144
2160
|
constructor (config, module, clientProcess, apiKMs, rootIsProcess, testingModuleName) {
|
|
2145
2161
|
if (config instanceof Config) {
|
|
@@ -2163,6 +2179,7 @@ class Config {
|
|
|
2163
2179
|
config.priorities = config.priorities || []
|
|
2164
2180
|
}
|
|
2165
2181
|
|
|
2182
|
+
this.demoInitializer = null
|
|
2166
2183
|
this.contextChecksFromBridges = []
|
|
2167
2184
|
|
|
2168
2185
|
this._enable = []
|
|
@@ -2276,7 +2293,7 @@ class Config {
|
|
|
2276
2293
|
|
|
2277
2294
|
async restart_auto_rebuild () {
|
|
2278
2295
|
this._stop_auto_rebuild = false
|
|
2279
|
-
await this.rebuild()
|
|
2296
|
+
return await this.rebuild()
|
|
2280
2297
|
}
|
|
2281
2298
|
|
|
2282
2299
|
getAddedArgs (args) {
|
|
@@ -2479,6 +2496,7 @@ class Config {
|
|
|
2479
2496
|
this.valid()
|
|
2480
2497
|
const cp = new Config()
|
|
2481
2498
|
cp.logs = []
|
|
2499
|
+
cp.demoInitializer = this.demoInitializer
|
|
2482
2500
|
cp.maxDepth = this.maxDepth
|
|
2483
2501
|
cp.debugLoops = this.debugLoops
|
|
2484
2502
|
cp.transitoryMode = this.transitoryMode
|
|
@@ -2553,6 +2571,11 @@ class Config {
|
|
|
2553
2571
|
cp.config.objects.namespaced[km._uuid] = {}
|
|
2554
2572
|
})
|
|
2555
2573
|
}
|
|
2574
|
+
|
|
2575
|
+
if (cp.demoInitializer) {
|
|
2576
|
+
await cp.demoInitializer(cp)
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2556
2579
|
cp.valid()
|
|
2557
2580
|
return cp
|
|
2558
2581
|
}
|
|
@@ -2855,7 +2878,11 @@ class Config {
|
|
|
2855
2878
|
let defaults = () => []
|
|
2856
2879
|
if (this.loadOrdering) {
|
|
2857
2880
|
for (const name of this.loadOrdering) {
|
|
2858
|
-
const
|
|
2881
|
+
const config = this.kms[name]
|
|
2882
|
+
let checks = config.testConfig?.checks?.context || []
|
|
2883
|
+
if (config.contextChecksFromBridges) {
|
|
2884
|
+
checks = config.contextChecksFromBridges.concat(checks)
|
|
2885
|
+
}
|
|
2859
2886
|
const oldDefaults = defaults
|
|
2860
2887
|
for (const check of checks) {
|
|
2861
2888
|
if (!check.match) {
|
|
@@ -3077,6 +3104,15 @@ class Config {
|
|
|
3077
3104
|
this.removeDevelopmentElements(this.config)
|
|
3078
3105
|
}
|
|
3079
3106
|
|
|
3107
|
+
if (this.testConfig?.testModuleName) {
|
|
3108
|
+
const km = this.km(this.testConfig.testModuleName)
|
|
3109
|
+
if (km.demoInitializer) {
|
|
3110
|
+
await km.demoInitializer(km)
|
|
3111
|
+
}
|
|
3112
|
+
} else if (this.demoInitializer) {
|
|
3113
|
+
await this.demoInitializer(this)
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3080
3116
|
this.valid()
|
|
3081
3117
|
this.checks()
|
|
3082
3118
|
}
|
|
@@ -3462,7 +3498,8 @@ class Config {
|
|
|
3462
3498
|
}
|
|
3463
3499
|
|
|
3464
3500
|
// TODO get rid of useOldVersion arg
|
|
3465
|
-
addInternal (more,
|
|
3501
|
+
addInternal (more,
|
|
3502
|
+
{ uuid, km, addFirst = false, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false, handleCalculatedProps: hcps = false } = {}) {
|
|
3466
3503
|
validConfigProps(more)
|
|
3467
3504
|
if (more instanceof Config) {
|
|
3468
3505
|
more.initialize({ force: false })
|
package/src/configHelpers.js
CHANGED
|
@@ -86,6 +86,28 @@ const cleanAssign = (dest, ...srcs) => {
|
|
|
86
86
|
Object.assign(dest, ...srcs)
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
class ContextHierarchy {
|
|
90
|
+
constructor(contexts = []) {
|
|
91
|
+
this.contexts = [...contexts]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
push(context) {
|
|
95
|
+
this.contexts.push(context)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
pop() {
|
|
99
|
+
this.contexts.pop()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
under(marker) {
|
|
103
|
+
for (let i = this.contexts.length - 1; i >= 0; --i) {
|
|
104
|
+
if (this.contexts[i].marker == marker) {
|
|
105
|
+
return true
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
89
111
|
const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
90
112
|
if (!args.objects) {
|
|
91
113
|
args.objects = config.get('objects')
|
|
@@ -105,6 +127,7 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
105
127
|
if (global.theprogrammablemind && global.theprogrammablemind.loadForTesting) {
|
|
106
128
|
args.calls = new InitCalls(Object.keys(global.theprogrammablemind.loadForTesting)[0])
|
|
107
129
|
}
|
|
130
|
+
args.contextHierarchy = new ContextHierarchy()
|
|
108
131
|
args.cleanAssign = cleanAssign
|
|
109
132
|
args.km = (name) => config.getConfig(name)
|
|
110
133
|
args.api = (name) => config.getConfig(name).api
|
|
@@ -151,12 +174,22 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
151
174
|
// debugger
|
|
152
175
|
// }
|
|
153
176
|
const { assumed = {}, options = {} } = rest
|
|
177
|
+
// have it default to paraphrase
|
|
178
|
+
if (['number', 'string', 'boolean'].includes(typeof c)) {
|
|
179
|
+
return `${c}`
|
|
180
|
+
}
|
|
181
|
+
if (false && !(assumed.isResponse && assumed.response)) {
|
|
182
|
+
assumed.paraphrase = true
|
|
183
|
+
}
|
|
154
184
|
return config.getGenerators(logs).apply(addAssumed(args, assumed), c, assumed, options)
|
|
155
185
|
}
|
|
156
186
|
args.gp = (c, rest = {}) => {
|
|
157
187
|
// if (JSON.stringify(rest) !== '{}' && !(rest.assumed || rest.options)) {
|
|
158
188
|
// debugger
|
|
159
189
|
// }
|
|
190
|
+
if (['number', 'string', 'boolean'].includes(typeof c)) {
|
|
191
|
+
return `${c}`
|
|
192
|
+
}
|
|
160
193
|
const { assumed = {}, options = {} } = rest
|
|
161
194
|
return config.getGenerators(logs).apply(addAssumed(args, assumed, { paraphrase: true, isResponse: false, response: false }), c, { paraphrase: true, isResponse: false, response: false }, options)
|
|
162
195
|
}
|
|
@@ -164,6 +197,9 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
164
197
|
// if (JSON.stringify(rest) !== '{}' && !(rest.assumed || rest.options)) {
|
|
165
198
|
// debugger
|
|
166
199
|
// }
|
|
200
|
+
if (['number', 'string', 'boolean'].includes(typeof c)) {
|
|
201
|
+
return `${c}`
|
|
202
|
+
}
|
|
167
203
|
const { assumed = {}, options = {} } = rest
|
|
168
204
|
return config.getGenerators(logs).apply(addAssumed(args, assumed, { paraphrase: false, isResponse: true }), { ...c, paraphrase: false, isResponse: true }, options)
|
|
169
205
|
}
|
package/src/debug.js
CHANGED
package/src/fragments.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
const _ = require('lodash')
|
|
2
2
|
const helpers = require('./helpers')
|
|
3
3
|
|
|
4
|
+
function pathEquals (p1, p2) {
|
|
5
|
+
if (p1.length !== p2.length) {
|
|
6
|
+
return false
|
|
7
|
+
}
|
|
8
|
+
for (let i = 0; i < p1.length; ++i) {
|
|
9
|
+
if (p1[i] !== p2[i]) {
|
|
10
|
+
return false
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return true
|
|
14
|
+
}
|
|
15
|
+
|
|
4
16
|
function fragmentInstantiator (args, contexts) {
|
|
5
17
|
return new Object({
|
|
6
18
|
contexts: () => {
|
|
@@ -10,6 +22,7 @@ function fragmentInstantiator (args, contexts) {
|
|
|
10
22
|
const instantiated = _.cloneDeep(contexts)
|
|
11
23
|
const todo = [{ context: instantiated, path: [] }]
|
|
12
24
|
args = { ...args }
|
|
25
|
+
args.pathEquals = pathEquals
|
|
13
26
|
while (todo.length > 0) {
|
|
14
27
|
const { context, path } = todo.pop()
|
|
15
28
|
args.context = context
|
package/src/helpers.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
const deepEqual = require('deep-equal')
|
|
2
2
|
const stringify = require('json-stable-stringify')
|
|
3
3
|
|
|
4
|
+
function watchProperty(obj, propName) {
|
|
5
|
+
let value = obj[propName];
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(obj, propName, {
|
|
8
|
+
get() {
|
|
9
|
+
return value;
|
|
10
|
+
},
|
|
11
|
+
set(newValue) {
|
|
12
|
+
console.log(`%c${propName} changed →`, 'color: #e83', newValue);
|
|
13
|
+
debugger; // ← Chrome/Firefox will pause here automatically
|
|
14
|
+
value = newValue;
|
|
15
|
+
},
|
|
16
|
+
configurable: true // allows us to delete/restore later if needed
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function assignAssumed(object, assumed) {
|
|
21
|
+
for (const key in assumed) {
|
|
22
|
+
if (object[key] == null) {
|
|
23
|
+
object[key] = assumed[key]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return object
|
|
27
|
+
}
|
|
28
|
+
|
|
4
29
|
function where (goUp = 2) {
|
|
5
30
|
const e = new Error()
|
|
6
31
|
const regexForm1 = /\((.*):(\d+):(\d+)\)$/
|
|
@@ -567,4 +592,6 @@ module.exports = {
|
|
|
567
592
|
suggestAssociationsFixFromSummaries,
|
|
568
593
|
getByPath,
|
|
569
594
|
setByPath,
|
|
595
|
+
assignAssumed,
|
|
596
|
+
watchProperty,
|
|
570
597
|
}
|
package/src/semantics.js
CHANGED
|
@@ -156,11 +156,21 @@ class Semantics {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
async applyToContext (args, context, options) {
|
|
159
|
+
args.contextHierarchy.push(context)
|
|
160
|
+
try {
|
|
161
|
+
return await this.applyToContextHelper(args, context, options)
|
|
162
|
+
} finally {
|
|
163
|
+
args.contextHierarchy.pop()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async applyToContextHelper (args, context, options) {
|
|
159
168
|
// let context_prime = {}
|
|
160
169
|
if (!(context instanceof Array || context instanceof Object)) {
|
|
161
170
|
return context
|
|
162
171
|
}
|
|
163
172
|
args = { ...args }
|
|
173
|
+
|
|
164
174
|
const config = args.config
|
|
165
175
|
const debug = config.getDebug()
|
|
166
176
|
let contextPrime = Object.assign({}, context)
|