entodicton 9.7.1-beta.7 → 9.7.1-beta.8
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 +11 -7
- package/package.json +1 -1
- package/src/config.js +7 -1
- package/src/configHelpers.js +14 -1
- package/src/flatten.js +9 -17
- package/src/helpers.js +4 -0
- package/src/semantics.js +3 -3
package/client.js
CHANGED
|
@@ -12,7 +12,7 @@ const _ = require('lodash')
|
|
|
12
12
|
const stringify = require('json-stable-stringify')
|
|
13
13
|
const Lines = require('./lines')
|
|
14
14
|
const flattens = require('./src/flatten')
|
|
15
|
-
const { sortJson, appendNoDups, InitCalls, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps, OverrideCheck, } = require('./src/helpers')
|
|
15
|
+
const { helpDebugHierarchy, sortJson, appendNoDups, InitCalls, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps, OverrideCheck, } = require('./src/helpers')
|
|
16
16
|
const runtime = require('./runtime')
|
|
17
17
|
const db = require('./src/debug')
|
|
18
18
|
|
|
@@ -479,7 +479,7 @@ const getConfigForTest = (config, testConfig) => {
|
|
|
479
479
|
return configForTest
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
const runTest = async (config, expected, { args, verbose, testConfig, debug, timings = { server: 0, client: 0 } }) => {
|
|
482
|
+
const runTest = async (config, expected, { args, verbose, testConfig, debug, timings = { server: 0, client: 0 }, index = 0 }) => {
|
|
483
483
|
const test = expected.query
|
|
484
484
|
if (args.query && args.query != test) {
|
|
485
485
|
// no run this
|
|
@@ -512,10 +512,11 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
|
512
512
|
defaultInnerProcess(config, errorHandler, result)
|
|
513
513
|
}
|
|
514
514
|
if (verbose) {
|
|
515
|
-
const widths = [100, 60]
|
|
515
|
+
const widths = [4, 100, 60]
|
|
516
516
|
const lines = new Lines(widths)
|
|
517
|
-
lines.setElement(0, 0,
|
|
518
|
-
lines.setElement(0, 1,
|
|
517
|
+
lines.setElement(0, 0, index)
|
|
518
|
+
lines.setElement(0, 1, test)
|
|
519
|
+
lines.setElement(0, 2, `time on server: ${result.times.toFixed(2)} client: ${(result.clientSideTimes / 1000).toFixed(2)}`)
|
|
519
520
|
timings.server += result.times
|
|
520
521
|
timings.client += result.clientSideTimes / 1000
|
|
521
522
|
lines.log()
|
|
@@ -618,18 +619,22 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
|
618
619
|
|
|
619
620
|
const runTestsHelper = async (config, tests, failed, juicyBits) => {
|
|
620
621
|
const { stopAtFirstError } = juicyBits
|
|
622
|
+
let index = 0
|
|
621
623
|
while (true) {
|
|
622
624
|
if (tests.length === 0) {
|
|
623
625
|
return Promise.resolve(failed)
|
|
624
626
|
}
|
|
625
627
|
const test = tests.shift()
|
|
628
|
+
juicyBits.index = index
|
|
626
629
|
const result = await runTest(config, test, juicyBits)
|
|
627
630
|
if (result != null) {
|
|
631
|
+
result.index = index
|
|
628
632
|
failed.push(result)
|
|
629
633
|
if (stopAtFirstError) {
|
|
630
634
|
return failed
|
|
631
635
|
}
|
|
632
636
|
}
|
|
637
|
+
index += 1
|
|
633
638
|
}
|
|
634
639
|
}
|
|
635
640
|
|
|
@@ -1314,7 +1319,6 @@ const knowledgeModuleImpl = async ({
|
|
|
1314
1319
|
|
|
1315
1320
|
const helpDebugWord = 'In order to get a debug break when a specific word is created set the DEBUG_WORD environment variable to the JSON of the association to break on. For example DEBUG_WORD=\'"the"\''
|
|
1316
1321
|
const helpDebugAssociation = 'In order to get a debug break when a specific association is created set the DEBUG_ASSOCIATION environment variable to the JSON of the association to break on. For example DEBUG_ASSOCIATION=\'[["the", 0], ["mammal", 1]]\''
|
|
1317
|
-
const helpDebugHierarchy = 'In order to get a debug break when a specific hierarchy is created set the DEBUG_HIERARCHY environment variable to the JSON of the child-parent pair to break on. For example DEBUG_HIERARCHY=\'[["cat", 1], ["mammel", 1]]\''
|
|
1318
1322
|
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]]\''
|
|
1319
1323
|
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}\''
|
|
1320
1324
|
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\''
|
|
@@ -1773,7 +1777,7 @@ const knowledgeModuleImpl = async ({
|
|
|
1773
1777
|
newError = true
|
|
1774
1778
|
headerShown = true
|
|
1775
1779
|
if (args.vimdiff) {
|
|
1776
|
-
vimdiff(actual, expected, `"${label} - ${result.utterance}"`)
|
|
1780
|
+
vimdiff(actual, expected, `"${label} - ${result.index} ${result.utterance}"`)
|
|
1777
1781
|
}
|
|
1778
1782
|
result.hasError = true
|
|
1779
1783
|
}
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -572,6 +572,7 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
|
|
|
572
572
|
'operator',
|
|
573
573
|
'optional',
|
|
574
574
|
'parents',
|
|
575
|
+
'preferOver',
|
|
575
576
|
'return_type_selector',
|
|
576
577
|
'scope',
|
|
577
578
|
'selector',
|
|
@@ -601,7 +602,12 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
|
|
|
601
602
|
}
|
|
602
603
|
|
|
603
604
|
if (runtime.process.env.DEBUG_HIERARCHY) {
|
|
604
|
-
|
|
605
|
+
try {
|
|
606
|
+
global.entodictonDebugHierarchy = JSON.parse(runtime.process.env.DEBUG_HIERARCHY)
|
|
607
|
+
} catch( e ) {
|
|
608
|
+
console.error("Invalid valid for DEBUG_HIERARCHY")
|
|
609
|
+
console.error(helpers.helpDebugHierarchy)
|
|
610
|
+
}
|
|
605
611
|
}
|
|
606
612
|
|
|
607
613
|
// i keep randomly doing one of the other so I will just make both work the same way
|
package/src/configHelpers.js
CHANGED
|
@@ -145,6 +145,7 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
145
145
|
args.objects = config.get('objects')
|
|
146
146
|
args.getObjects = getObjects(args.objects)
|
|
147
147
|
}
|
|
148
|
+
args.debug = debug
|
|
148
149
|
args.enable = (key) => {
|
|
149
150
|
config.addEnable(key)
|
|
150
151
|
}
|
|
@@ -163,7 +164,19 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
args.contextHierarchy = new ContextHierarchy()
|
|
166
|
-
args.
|
|
167
|
+
args.namespaced = {
|
|
168
|
+
get: (km, context, property) => {
|
|
169
|
+
context.namespaced ??= {}
|
|
170
|
+
context.namespaced[km] ??= {}
|
|
171
|
+
return context.namespaced[km][property]
|
|
172
|
+
},
|
|
173
|
+
set: (km, context, property, value) => {
|
|
174
|
+
context.namespaced ??= {}
|
|
175
|
+
context.namespaced[km] ??= {}
|
|
176
|
+
return context.namespaced[km][property] = value
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
args.stack = new HandlerStack()
|
|
167
180
|
args.cleanAssign = cleanAssign
|
|
168
181
|
args.km = (name) => config.getConfig(name)
|
|
169
182
|
args.api = (name) => config.getConfig(name).api
|
package/src/flatten.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
const { isArray, isObject, isCompound } = require('./helpers')
|
|
1
|
+
const { isArray, isObject, isCompound, } = require('./helpers')
|
|
2
|
+
const debug = require('./debug')
|
|
2
3
|
const _ = require('lodash')
|
|
3
4
|
|
|
4
|
-
const DEBUG = (
|
|
5
|
+
const DEBUG = (label, details) => {
|
|
5
6
|
// DEBUG(...args)
|
|
6
7
|
}
|
|
7
8
|
|
|
@@ -46,33 +47,24 @@ const zip = (a1, a2) => {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
const flattenListHelper = (markers, values) => {
|
|
49
|
-
const flats = []
|
|
50
50
|
let wasFlattened = false
|
|
51
|
-
|
|
51
|
+
const all = []
|
|
52
52
|
for (const value of values) {
|
|
53
53
|
if (!isCompound(value)) {
|
|
54
|
-
|
|
54
|
+
all.push([value])
|
|
55
55
|
} else {
|
|
56
56
|
const [more, wf] = flatten(markers, value)
|
|
57
57
|
if (wf) {
|
|
58
58
|
wasFlattened = wasFlattened || wf
|
|
59
|
-
|
|
59
|
+
all.push(more)
|
|
60
60
|
} else {
|
|
61
|
-
|
|
61
|
+
all.push(...more.map((m) => [m]))
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return [[singles], wasFlattened]
|
|
69
|
-
} else {
|
|
70
|
-
const results = []
|
|
71
|
-
for (const flat of cartesian(...flats)) {
|
|
72
|
-
results.push(singles.concat(flat))
|
|
73
|
-
}
|
|
74
|
-
return [results, wasFlattened]
|
|
75
|
-
}
|
|
66
|
+
const result = cartesian(...all)
|
|
67
|
+
return [result, wasFlattened]
|
|
76
68
|
}
|
|
77
69
|
|
|
78
70
|
// returns (list, wasFlattened)
|
package/src/helpers.js
CHANGED
|
@@ -600,7 +600,11 @@ function setByPath(obj, path, value) {
|
|
|
600
600
|
return value;
|
|
601
601
|
}
|
|
602
602
|
|
|
603
|
+
const helpDebugHierarchy = 'In order to get a debug break when a specific hierarchy is created set the DEBUG_HIERARCHY environment variable to the JSON of the child-parent pair to break on. For example DEBUG_HIERARCHY=\'["cat", "mammel"]\''
|
|
604
|
+
|
|
603
605
|
module.exports = {
|
|
606
|
+
helpDebugHierarchy,
|
|
607
|
+
|
|
604
608
|
stableId,
|
|
605
609
|
ecatch,
|
|
606
610
|
functionsToStrings,
|
package/src/semantics.js
CHANGED
|
@@ -108,11 +108,11 @@ class Semantic {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
try {
|
|
111
|
-
args.
|
|
111
|
+
args.stack.push(this)
|
|
112
112
|
await this._apply(args)
|
|
113
|
-
args.
|
|
113
|
+
args.stack.pop()
|
|
114
114
|
} catch( e ) {
|
|
115
|
-
args.
|
|
115
|
+
args.stack.pop()
|
|
116
116
|
throw e
|
|
117
117
|
}
|
|
118
118
|
return contextPrime
|