theprogrammablemind_4wp 9.3.0-beta.3 → 9.3.0-beta.5
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 +48 -49
- package/demo.js +2 -2
- package/package.json +1 -1
- package/src/config.js +51 -45
- package/src/configHelpers.js +1 -1
- package/src/digraph.js +2 -2
- package/src/digraph_internal.js +2 -2
- package/src/flatten.js +1 -1
- package/src/generators.js +6 -6
- package/src/helpers.js +15 -15
- package/src/semantics.js +4 -4
- package/src/unflatten.js +1 -1
package/client.js
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
const { Semantics, Semantic } = require('./src/semantics')
|
2
2
|
const { Generators, Generator } = require('./src/generators')
|
3
3
|
const { Config } = require('./src/config')
|
4
|
-
const { loadInstance,
|
5
|
-
const DigraphInternal = require('./src/digraph_internal')
|
4
|
+
const { loadInstance, setupArgs, gs, processContext, getObjects, setupProcessB, processContextsB } = require('./src/configHelpers')
|
6
5
|
const Digraph = require('./src/digraph')
|
7
6
|
const { project } = require('./src/project')
|
8
7
|
const fetch = require('node-fetch')
|
@@ -12,7 +11,7 @@ const _ = require('lodash')
|
|
12
11
|
const stringify = require('json-stable-stringify')
|
13
12
|
const Lines = require('./lines')
|
14
13
|
const flattens = require('./src/flatten')
|
15
|
-
const { appendNoDups,
|
14
|
+
const { appendNoDups, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps } = require('./src/helpers')
|
16
15
|
const runtime = require('./runtime')
|
17
16
|
const sortJson = runtime.sortJson
|
18
17
|
const debug = require('./src/debug')
|
@@ -77,7 +76,7 @@ const pickObjects = (config, testConfig, getObjects) => {
|
|
77
76
|
const sameJSON = (json1, json2) => {
|
78
77
|
const sjson1 = sortJson(json1, { depth: 25 })
|
79
78
|
const sjson2 = sortJson(json2, { depth: 25 })
|
80
|
-
return JSON.stringify(sjson1)
|
79
|
+
return JSON.stringify(sjson1) === JSON.stringify(sjson2)
|
81
80
|
}
|
82
81
|
|
83
82
|
const vimdiff = (actualJSON, expectedJSON, title) => {
|
@@ -149,7 +148,7 @@ const convertToStable = (objects) => {
|
|
149
148
|
const writeTestFile = (fn, tests) => {
|
150
149
|
const stabilize = (tests) => {
|
151
150
|
for (const test of tests) {
|
152
|
-
for (opChoice of test.metadata.opChoices) {
|
151
|
+
for (const opChoice of test.metadata.opChoices) {
|
153
152
|
opChoice.ops.sort()
|
154
153
|
}
|
155
154
|
test.metadata.opChoices.sort()
|
@@ -185,7 +184,7 @@ const writeTest = (fn, query, objects, generated, paraphrases, responses, contex
|
|
185
184
|
}, { depth: 25 })
|
186
185
|
let wasSet = false
|
187
186
|
tests.forEach((test, index) => {
|
188
|
-
if (test.query
|
187
|
+
if (test.query === query) {
|
189
188
|
tests[index] = results
|
190
189
|
wasSet = true
|
191
190
|
}
|
@@ -321,7 +320,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
321
320
|
data.start_counter = startCounter
|
322
321
|
let json = await doWithRetries(retries, url, queryParams, data)
|
323
322
|
let resetData = false
|
324
|
-
if (json.code
|
323
|
+
if (json.code === 'NOT_IN_CACHE') {
|
325
324
|
resetData = true
|
326
325
|
const setupB = setupProcessB({ config, allowDelta: false })
|
327
326
|
data = setupB.data
|
@@ -347,14 +346,14 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
347
346
|
} else {
|
348
347
|
let clientSideTime
|
349
348
|
if (isTest) {
|
350
|
-
start = runtime.performance.performance.now()
|
349
|
+
const start = runtime.performance.performance.now()
|
351
350
|
}
|
352
351
|
const summary = { summaries: json.summaries, length: json.contexts.length }
|
353
352
|
summaries.push(summary)
|
354
353
|
const { contextsPrime, generatedPrime, paraphrasesPrime, paraphrasesParenthesizedPrime, generatedParenthesizedPrime, responsesPrime } =
|
355
354
|
await processContextsB({ isTest, rebuildingTemplate, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
|
356
355
|
if (isTest) {
|
357
|
-
end = runtime.performance.performance.now()
|
356
|
+
const end = runtime.performance.performance.now()
|
358
357
|
clientSideTime = end - start
|
359
358
|
}
|
360
359
|
response.associations = json.associations
|
@@ -386,13 +385,13 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
386
385
|
}
|
387
386
|
|
388
387
|
if (writeTests) {
|
389
|
-
const
|
388
|
+
const actualConfig = getConfigForTest(config, testConfig)
|
390
389
|
const saveObjects = { ...config.config.objects }
|
391
390
|
saveObjects.nameToUUID = {}
|
392
391
|
for (const km of config.configs) {
|
393
392
|
saveObjects.nameToUUID[km.name] = km.uuid
|
394
393
|
}
|
395
|
-
writeTest(testsFN, query, saveObjects, response.generated, response.paraphrases, response.responses, response.contexts, response.associations, response.metadata,
|
394
|
+
writeTest(testsFN, query, saveObjects, response.generated, response.paraphrases, response.responses, response.contexts, response.associations, response.metadata, actualConfig, saveDeveloper, response.paraphrasesParenthesized, response.generatedParenthesized, response.summaries)
|
396
395
|
}
|
397
396
|
|
398
397
|
return response
|
@@ -499,19 +498,19 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
499
498
|
timings.client += result.clientSideTimes / 1000
|
500
499
|
lines.log()
|
501
500
|
}
|
502
|
-
const
|
503
|
-
delete
|
504
|
-
const
|
505
|
-
const
|
506
|
-
let
|
501
|
+
const expectedObjects = sortJson(convertToStable(expected.objects), { depth: 25 })
|
502
|
+
delete expectedObjects.nameToUUID
|
503
|
+
const actualObjects = sortJson(convertToStable(config.config.objects), { depth: 25 })
|
504
|
+
const failedParaphrases = !matching(result.paraphrases, expected.paraphrases)
|
505
|
+
let failedParaphrasesParenthesized = !matching(result.paraphrasesParenthesized, expected.paraphrasesParenthesized)
|
507
506
|
let failed_generatedParenthesized = !matching(result.generatedParenthesized, expected.generatedParenthesized)
|
508
507
|
// TODO fix the naming conventions: camelcase + use actual instead of result
|
509
|
-
const
|
510
|
-
const
|
511
|
-
const
|
508
|
+
const failedResponses = !matching(result.responses, expected.responses)
|
509
|
+
const failedContexts = !matching(result.contexts, expected.contexts)
|
510
|
+
const failedObjects = !matching(actualObjects, expectedObjects)
|
512
511
|
|
513
512
|
if (args.testNoParenthesized) {
|
514
|
-
|
513
|
+
failedParaphrasesParenthesized = false
|
515
514
|
failed_generatedParenthesized = false
|
516
515
|
}
|
517
516
|
|
@@ -525,23 +524,23 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
525
524
|
}
|
526
525
|
return expected.objects.namespaced[expected.objects.nameToUUID[name]] || {}
|
527
526
|
}
|
528
|
-
const
|
527
|
+
const expectedChecked = sortJson(pickObjects(config, testConfig, expectedGetObjects), { depth: 25 })
|
529
528
|
const actualGetObjects = (name) => {
|
530
529
|
if (!name) {
|
531
530
|
name = config.name
|
532
531
|
}
|
533
|
-
const km = config.configs.find((km) => km.name
|
532
|
+
const km = config.configs.find((km) => km.name === name)
|
534
533
|
return config.config.objects.namespaced[km.uuid] || {}
|
535
534
|
}
|
536
|
-
const
|
537
|
-
const
|
535
|
+
const actualChecked = sortJson(pickObjects(config, testConfig, actualGetObjects), { depth: 25 })
|
536
|
+
const failedChecked = !matching(actualObjects, expectedObjects)
|
538
537
|
|
539
|
-
const
|
540
|
-
const
|
541
|
-
const
|
542
|
-
const
|
543
|
-
const
|
544
|
-
const failed =
|
538
|
+
const failedChecks = !matching(actualObjects, expectedObjects)
|
539
|
+
const failedChecked_objects = !matching(actualChecked, expectedChecked)
|
540
|
+
const actualConfig = sortJson(convertToStable(getConfigForTest(config, testConfig)), { depth: 25 })
|
541
|
+
const expectedConfig = sortJson(convertToStable(expected.config), { depth: 25 })
|
542
|
+
const failedConfig = !matching(actualConfig, expectedConfig)
|
543
|
+
const failed = failedChecked_objects || failedParaphrases || failedParaphrasesParenthesized || failed_generatedParenthesized || failedResponses || failedContexts || failedObjects || failedConfig || failedChecked || failedCheckedContexts
|
545
544
|
|
546
545
|
if (expected.metadata && result.metadata && failed) {
|
547
546
|
const priorities = analyzeMetaData(expected.metadata, result.metadata)
|
@@ -559,9 +558,9 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
559
558
|
paraphrasesParenthesized: expected.paraphrasesParenthesized,
|
560
559
|
generatedParenthesized: expected.generatedParenthesized,
|
561
560
|
results: expected.contexts,
|
562
|
-
checked:
|
561
|
+
checked: expectedChecked,
|
563
562
|
checkedContexts: pickedExpectedContexts,
|
564
|
-
objects:
|
563
|
+
objects: expectedObjects,
|
565
564
|
config: expected.config,
|
566
565
|
summaries: expected.summaries
|
567
566
|
},
|
@@ -571,10 +570,10 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
571
570
|
paraphrasesParenthesized: result.paraphrasesParenthesized,
|
572
571
|
generatedParenthesized: result.generatedParenthesized,
|
573
572
|
results: result.contexts,
|
574
|
-
checked:
|
573
|
+
checked: actualChecked,
|
575
574
|
checkedContexts: pickedResultContexts,
|
576
|
-
objects:
|
577
|
-
config:
|
575
|
+
objects: actualObjects,
|
576
|
+
config: actualConfig,
|
578
577
|
summaries: result.summaries
|
579
578
|
}
|
580
579
|
}
|
@@ -667,6 +666,7 @@ const showInfo = (description, section, config) => {
|
|
667
666
|
console.log(JSON.stringify(config.getInfo(), null, 2))
|
668
667
|
}
|
669
668
|
|
669
|
+
/*
|
670
670
|
const submitBugToAPI = async (subscription_id, subscription_password, config) => {
|
671
671
|
console.log('********* Submitting bug *********')
|
672
672
|
const body = { description: config.config.description, config: config.config }
|
@@ -689,7 +689,6 @@ const submitBugToAPI = async (subscription_id, subscription_password, config) =>
|
|
689
689
|
})
|
690
690
|
}
|
691
691
|
|
692
|
-
/*
|
693
692
|
const submitBug = async (subscription_id, subscription_password, config, utterance, retries = 2) => {
|
694
693
|
// TODO remove these from the config
|
695
694
|
const properties = ['expected_contexts', 'expected_generated']
|
@@ -862,7 +861,7 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
|
|
862
861
|
|
863
862
|
if (responses.explain_priorities) {
|
864
863
|
console.log('Explain Priorities')
|
865
|
-
for ([inputs, output, reason] of responses.explain_priorities) {
|
864
|
+
for (const [inputs, output, reason] of responses.explain_priorities) {
|
866
865
|
console.log(` inputs: ${JSON.stringify(inputs)} output: ${JSON.stringify(output)} reason: ${reason}`)
|
867
866
|
}
|
868
867
|
}
|
@@ -871,7 +870,7 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
|
|
871
870
|
if (!name) {
|
872
871
|
name = config.name
|
873
872
|
}
|
874
|
-
const km = config.configs.find((km) => km.name
|
873
|
+
const km = config.configs.find((km) => km.name === name)
|
875
874
|
return config.config.objects.namespaced[km.uuid] || {}
|
876
875
|
}
|
877
876
|
const picked = sortJson(pickObjects(config, config.testConfig, actualGetObjects), { depth: 25 })
|
@@ -967,7 +966,7 @@ const rebuildTemplate = async ({ config, instance, target, previousResultss, reb
|
|
967
966
|
}
|
968
967
|
config.config.skipSemantics = skipSemantics && !isFragment
|
969
968
|
const transitoryMode = global.transitoryMode
|
970
|
-
if (isFragment || property
|
969
|
+
if (isFragment || property === 'fragments') {
|
971
970
|
global.transitoryMode = true
|
972
971
|
}
|
973
972
|
if (hierarchy) {
|
@@ -991,7 +990,7 @@ const rebuildTemplate = async ({ config, instance, target, previousResultss, reb
|
|
991
990
|
console.log(getSuggestionMessage(suggestion))
|
992
991
|
}
|
993
992
|
}
|
994
|
-
if (!rebuild && previousResults && previousResults.query
|
993
|
+
if (!rebuild && previousResults && previousResults.query === query.query) {
|
995
994
|
results = previousResults
|
996
995
|
prMessage = ' Using previous results. use -rtf for a hard rebuild of everything on the server side.'
|
997
996
|
await loadInstance(config, { resultss: [results] })
|
@@ -1139,7 +1138,7 @@ const rebuildTemplate = async ({ config, instance, target, previousResultss, reb
|
|
1139
1138
|
for (let configsIndex = 0; configsIndex < template.configs.length; ++configsIndex) {
|
1140
1139
|
const query = template.configs[configsIndex]
|
1141
1140
|
// account for things for example associations being added to the config while debugginer
|
1142
|
-
const pr = previousResultss && previousResultss.find((pr) => pr.query
|
1141
|
+
const pr = previousResultss && previousResultss.find((pr) => pr.query === query)
|
1143
1142
|
todo.push({ property: 'resultss', query, previousResults: pr, skipSemantics: false || query.skipSemantics })
|
1144
1143
|
}
|
1145
1144
|
}
|
@@ -1309,7 +1308,7 @@ const knowledgeModuleImpl = async ({
|
|
1309
1308
|
parser.add_argument('--parenthesized', { action: 'store_true', help: 'Show the generated phrases with parenthesis.' })
|
1310
1309
|
parser.add_argument('-c', '--clean', { help: 'Remove data from the test files. a === association' })
|
1311
1310
|
parser.add_argument('-od', '--objectDiff', { action: 'store_true', help: 'When showing the objects use a colour diff' })
|
1312
|
-
parser.add_argument('-p', '--print', { help: 'Print the specified elements c === config, w === words, b === bridges, o === operators d === objects (d for data), h === hierarchy, g === generators, s === semantics, l === load t=tests ordering p === priorities a
|
1311
|
+
parser.add_argument('-p', '--print', { help: 'Print the specified elements c === config, w === words, b === bridges, o === operators d === objects (d for data), h === hierarchy, g === generators, s === semantics, l === load t=tests ordering p === priorities a === associations j === JSON sent to server. for example --print wb' })
|
1313
1312
|
parser.add_argument('-s', '--save', { action: 'store_true', help: 'When running with the --query flag this will save the current run to the test file. When running without the --query flag all tests will be run and resaved.' })
|
1314
1313
|
parser.add_argument('-fr', '--failRebuild', { action: 'store_true', help: 'If a rebuild is required fail out.' })
|
1315
1314
|
parser.add_argument('-sd', '--saveDeveloper', { action: 'store_true', help: 'Same as -s but the query will not show up in the info command.' })
|
@@ -1361,10 +1360,10 @@ const knowledgeModuleImpl = async ({
|
|
1361
1360
|
if (what.length !== 2) {
|
1362
1361
|
return false
|
1363
1362
|
}
|
1364
|
-
if (!typeof what[0]
|
1363
|
+
if (!typeof what[0] === 'string') {
|
1365
1364
|
return false
|
1366
1365
|
}
|
1367
|
-
if (!typeof what[1]
|
1366
|
+
if (!typeof what[1] === 'number') {
|
1368
1367
|
return false
|
1369
1368
|
}
|
1370
1369
|
return true
|
@@ -1682,9 +1681,9 @@ const knowledgeModuleImpl = async ({
|
|
1682
1681
|
const tidy_summaries = (summaries) => {
|
1683
1682
|
const summaries_prime = []
|
1684
1683
|
for (const chunk of summaries) {
|
1685
|
-
chunk_prime = { length: chunk.length, summaries: [] }
|
1684
|
+
const chunk_prime = { length: chunk.length, summaries: [] }
|
1686
1685
|
for (const summary of chunk.summaries) {
|
1687
|
-
const summary_prime = { counter: summary.counter, operators: [] }
|
1686
|
+
const summary_prime = { counter: summary.counter, operators: [] }
|
1688
1687
|
for (const operator of summary.operators) {
|
1689
1688
|
summary_prime.operators.push(`{ marker: [${operator.marker[0]}, ${operator.marker[1]}] range: { start: ${operator.range.start}, end: ${operator.range.end} } }`)
|
1690
1689
|
}
|
@@ -1716,7 +1715,7 @@ const knowledgeModuleImpl = async ({
|
|
1716
1715
|
if (lengths > iDiff) {
|
1717
1716
|
const suggestion = suggestAssociationsFix(result.expected.summaries[iSummaries].summaries, result.actual.summaries[iSummaries].summaries)
|
1718
1717
|
if (suggestion) {
|
1719
|
-
suggestedFix = suggestion
|
1718
|
+
const suggestedFix = suggestion
|
1720
1719
|
// console.log(`Try adding this to the associations: { context: ${JSON.stringify(getSuggestion(suggestedFix))}, choose: <indexOfMainElement> },`)
|
1721
1720
|
console.log(getSuggestionMessage(suggestedFix))
|
1722
1721
|
return
|
@@ -1856,7 +1855,7 @@ const knowledgeModuleImpl = async ({
|
|
1856
1855
|
f()
|
1857
1856
|
})
|
1858
1857
|
.catch((e) => {
|
1859
|
-
if (e.errno
|
1858
|
+
if (e.errno === 'ECONNREFUSED') {
|
1860
1859
|
console.log(e)
|
1861
1860
|
readline.close()
|
1862
1861
|
} else {
|
@@ -1938,7 +1937,7 @@ const knowledgeModuleImpl = async ({
|
|
1938
1937
|
|
1939
1938
|
// no cache 21 minutes + rebuild fails "node tester_rebuild -m colors"
|
1940
1939
|
// cache okay
|
1941
|
-
createConfigExport = async () => {
|
1940
|
+
const createConfigExport = async () => {
|
1942
1941
|
if (createConfig.cached) {
|
1943
1942
|
return createConfig.cached
|
1944
1943
|
}
|
package/demo.js
CHANGED
@@ -34,13 +34,13 @@ let config = {
|
|
34
34
|
apply: ({ context }) => context.evalue
|
35
35
|
},
|
36
36
|
{
|
37
|
-
match: ({ context }) => context.marker
|
37
|
+
match: ({ context }) => context.marker === 'unknown',
|
38
38
|
apply: ({ context }) => context.text
|
39
39
|
}
|
40
40
|
],
|
41
41
|
semantics: [
|
42
42
|
{
|
43
|
-
match: ({ context }) => context.marker
|
43
|
+
match: ({ context }) => context.marker === 'went',
|
44
44
|
apply: ({ context }) => {
|
45
45
|
// same way as kms that I wrote. you dont have to do this though
|
46
46
|
context.isResponse = true
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -98,7 +98,7 @@ const debugBridge = (bridge) => {
|
|
98
98
|
return
|
99
99
|
}
|
100
100
|
if (global.entodictonDebugBridge) {
|
101
|
-
if (global.entodictonDebugBridge
|
101
|
+
if (global.entodictonDebugBridge === bridge.id) {
|
102
102
|
// debug hierarchy hit
|
103
103
|
debugger // eslint-disable-line no-debugger
|
104
104
|
}
|
@@ -128,13 +128,13 @@ const debugConfigProps = (config) => {
|
|
128
128
|
{ property: 'priorities', check: (v) => debugPriority(v) },
|
129
129
|
{ property: 'associations', check: (v) => debugAssociation(v) },
|
130
130
|
// TODO implement debugWords
|
131
|
-
{ property: 'words', check: (v) => debugWords(v) },
|
131
|
+
// { property: 'words', check: (v) => debugWords(v) },
|
132
132
|
{ property: 'hierarchy', check: (v) => debugHierarchy(v) },
|
133
133
|
{ property: 'operators', check: (v) => debugOperator(v) },
|
134
134
|
{ property: 'bridges', check: (v) => debugBridge(v) }
|
135
135
|
]
|
136
136
|
for (const { property, check } of checkProps) {
|
137
|
-
if (property
|
137
|
+
if (property === 'associations') {
|
138
138
|
if (config[property]) {
|
139
139
|
if (config[property].negative) {
|
140
140
|
for (const value of config[property].negative) {
|
@@ -147,7 +147,7 @@ const debugConfigProps = (config) => {
|
|
147
147
|
}
|
148
148
|
}
|
149
149
|
}
|
150
|
-
} else if (property
|
150
|
+
} else if (property === 'words') {
|
151
151
|
/*
|
152
152
|
if (config[property]) {
|
153
153
|
for (const value of config[property].literals) {
|
@@ -249,7 +249,7 @@ const operatorKey_valid = (key) => {
|
|
249
249
|
}
|
250
250
|
|
251
251
|
const elist = (list, check, prefix) => {
|
252
|
-
for ([index, element] of list.entries()) {
|
252
|
+
for (const [index, element] of list.entries()) {
|
253
253
|
try {
|
254
254
|
check(element)
|
255
255
|
} catch (e) {
|
@@ -388,7 +388,7 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
388
388
|
|
389
389
|
const generator = {
|
390
390
|
where: bridge.generatorp.where || bridge.where || helpers.where(4),
|
391
|
-
match: async (args) => bridge.id
|
391
|
+
match: async (args) => bridge.id === args.context.marker && args.context.level === level && args.context.paraphrase && await match(args),
|
392
392
|
apply: (args) => apply(args),
|
393
393
|
applyWrapped: apply,
|
394
394
|
property: 'generatorp'
|
@@ -405,7 +405,7 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
405
405
|
const level = bridge.generatorr.level >= 0 ? bridge.generatorr.level : bridge.level + 1
|
406
406
|
const generator = {
|
407
407
|
where: bridge.generatorr.where || bridge.where || helpers.where(4),
|
408
|
-
match: async (args) => bridge.id
|
408
|
+
match: async (args) => bridge.id === args.context.marker && args.context.level === level && !args.context.paraphrase && (args.context.response || args.context.isResponse) && await match(args),
|
409
409
|
apply: (args) => apply(args),
|
410
410
|
applyWrapped: apply,
|
411
411
|
property: 'generatorr'
|
@@ -420,13 +420,13 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
420
420
|
const addSemantic = (semantic, evaluate) => {
|
421
421
|
const match = semantic.match || (() => true)
|
422
422
|
let apply = semantic
|
423
|
-
// if I do apply
|
423
|
+
// if I do apply === semantic.apply or semantic there is one function that has apply defined for some reason even though not explicitly set
|
424
424
|
if (semantic.apply && typeof semantic !== 'function') {
|
425
425
|
apply = semantic.apply
|
426
426
|
}
|
427
427
|
const semanticDef = {
|
428
428
|
where: semantic.where || bridge.where || helpers.where(4),
|
429
|
-
match: (args) => bridge.id
|
429
|
+
match: (args) => bridge.id === args.context.marker && !!args.context.evaluate === evaluate && match(args),
|
430
430
|
apply: (args) => apply(args),
|
431
431
|
applyWrapped: semantic,
|
432
432
|
property: evaluate ? 'evaluator' : 'semantic'
|
@@ -577,7 +577,7 @@ const addWord = (config, uuid) => ({ word, id, initial }) => {
|
|
577
577
|
const normalizeConfig = (config) => {
|
578
578
|
if (config) {
|
579
579
|
if (!config.objects) {
|
580
|
-
config.objects = { namespaced: {}
|
580
|
+
config.objects = { namespaced: {} }
|
581
581
|
}
|
582
582
|
|
583
583
|
for (const bag of bags) {
|
@@ -966,7 +966,7 @@ class Config {
|
|
966
966
|
},
|
967
967
|
objects: {
|
968
968
|
// this is where the namespaced configs have their objects
|
969
|
-
namespaced: {}
|
969
|
+
namespaced: {}
|
970
970
|
},
|
971
971
|
description: '',
|
972
972
|
words: {
|
@@ -1026,7 +1026,7 @@ class Config {
|
|
1026
1026
|
|
1027
1027
|
exists (marker) {
|
1028
1028
|
for (const bridge of this.config.bridges) {
|
1029
|
-
if (bridge.id
|
1029
|
+
if (bridge.id === marker) {
|
1030
1030
|
return true
|
1031
1031
|
}
|
1032
1032
|
}
|
@@ -1046,7 +1046,7 @@ class Config {
|
|
1046
1046
|
|
1047
1047
|
warningNotEvaluated (log, value) {
|
1048
1048
|
const description = 'WARNING: for semantics, implement an evaluations handler, set "value" property of the operator to the value.'
|
1049
|
-
const match = `({context}) => context.marker
|
1049
|
+
const match = `({context}) => context.marker === '${value.marker}' && context.evaluate && <other conditions as you like>`
|
1050
1050
|
const apply = '({context}) => <do stuff...>; context.value = <value>'
|
1051
1051
|
const input = indent(JSON.stringify(value, null, 2), 2)
|
1052
1052
|
const message = `${description}\nThe semantic would be\n match: ${match}\n apply: ${apply}\nThe input context would be:\n${input}\n`
|
@@ -1331,7 +1331,7 @@ class Config {
|
|
1331
1331
|
toData (data) {
|
1332
1332
|
Object.assign(data, this.config)
|
1333
1333
|
// greg99 delete data.objects
|
1334
|
-
data.objects = {...this.config.objects}
|
1334
|
+
data.objects = { ...this.config.objects }
|
1335
1335
|
if (!this.sendObjectsToServer) {
|
1336
1336
|
delete data.objects.namespaced
|
1337
1337
|
}
|
@@ -1490,7 +1490,7 @@ class Config {
|
|
1490
1490
|
debugHierarchy([child, parent])
|
1491
1491
|
if (this.config.hierarchy.find((element) => {
|
1492
1492
|
const hc = hierarchyCanonical(element)
|
1493
|
-
if (child
|
1493
|
+
if (child === hc.child && parent === hc.parent) {
|
1494
1494
|
return true
|
1495
1495
|
}
|
1496
1496
|
})) {
|
@@ -1503,9 +1503,9 @@ class Config {
|
|
1503
1503
|
|
1504
1504
|
getBridge (id, level) {
|
1505
1505
|
if (level) {
|
1506
|
-
return this.config.bridges.find((bridge) => bridge.id
|
1506
|
+
return this.config.bridges.find((bridge) => bridge.id === id && bridge.level === level)
|
1507
1507
|
} else {
|
1508
|
-
return this.config.bridges.find((bridge) => bridge.id
|
1508
|
+
return this.config.bridges.find((bridge) => bridge.id === id)
|
1509
1509
|
}
|
1510
1510
|
}
|
1511
1511
|
|
@@ -1518,8 +1518,8 @@ class Config {
|
|
1518
1518
|
|
1519
1519
|
debugBridge(bridge)
|
1520
1520
|
if (bridge.allowDups) {
|
1521
|
-
// if (bridges.find( (b) => b.id
|
1522
|
-
if (bridges.find((b) => b.id
|
1521
|
+
// if (bridges.find( (b) => b.id === bridge.id && b.level === bridge.level && b.bridge === bridge.bridge )) {
|
1522
|
+
if (bridges.find((b) => b.id === bridge.id && b.level === bridge.level)) {
|
1523
1523
|
return
|
1524
1524
|
}
|
1525
1525
|
}
|
@@ -1588,7 +1588,7 @@ class Config {
|
|
1588
1588
|
}
|
1589
1589
|
seen.add(id)
|
1590
1590
|
const index = this.config.semantics.findIndex((semantic) => semantic.id === id)
|
1591
|
-
if (index
|
1591
|
+
if (index === -1) {
|
1592
1592
|
continue
|
1593
1593
|
}
|
1594
1594
|
for (const tied_id of this.config.semantics[index].tied_ids || []) {
|
@@ -1619,7 +1619,7 @@ class Config {
|
|
1619
1619
|
debugOperator(operator)
|
1620
1620
|
|
1621
1621
|
if (operator.allowDups) {
|
1622
|
-
if (operators.find((o) => o.pattern
|
1622
|
+
if (operators.find((o) => o.pattern === operator.pattern)) {
|
1623
1623
|
return
|
1624
1624
|
}
|
1625
1625
|
}
|
@@ -1776,7 +1776,7 @@ class Config {
|
|
1776
1776
|
if (!config.objects) {
|
1777
1777
|
config.objects = {
|
1778
1778
|
namespaced: {
|
1779
|
-
}
|
1779
|
+
}
|
1780
1780
|
}
|
1781
1781
|
}
|
1782
1782
|
|
@@ -1885,7 +1885,7 @@ class Config {
|
|
1885
1885
|
for (const word in literals) {
|
1886
1886
|
const defs = literals[word] || []
|
1887
1887
|
literals[word] = defs.filter((def) => !def.development)
|
1888
|
-
if (literals[word].length
|
1888
|
+
if (literals[word].length === 0) {
|
1889
1889
|
delete literals[word]
|
1890
1890
|
}
|
1891
1891
|
}
|
@@ -2033,7 +2033,7 @@ class Config {
|
|
2033
2033
|
debugConfigProps(this.config)
|
2034
2034
|
}
|
2035
2035
|
|
2036
|
-
setSendObjectsToServer() {
|
2036
|
+
setSendObjectsToServer () {
|
2037
2037
|
this.sendObjectsToServer = true
|
2038
2038
|
}
|
2039
2039
|
|
@@ -2110,7 +2110,7 @@ class Config {
|
|
2110
2110
|
throw new Error('This is intended to be used to instantiate a new class based on the existing API.')
|
2111
2111
|
} else {
|
2112
2112
|
if (name) {
|
2113
|
-
if (this.name
|
2113
|
+
if (this.name === name) {
|
2114
2114
|
return this._api.constructor
|
2115
2115
|
} else {
|
2116
2116
|
if (!this.getConfig(name)) {
|
@@ -2150,7 +2150,12 @@ class Config {
|
|
2150
2150
|
}
|
2151
2151
|
}
|
2152
2152
|
|
2153
|
+
setApiKMs (apiKMs) {
|
2154
|
+
this._apiKMs = [...apiKMs]
|
2155
|
+
}
|
2156
|
+
|
2153
2157
|
// constructors is a constructor
|
2158
|
+
// TODO fix Api to be API WTF
|
2154
2159
|
async setApi (constructor) {
|
2155
2160
|
if (typeof constructor !== 'function') {
|
2156
2161
|
throw new Error(`Expected the argument to be an API constructor for ${this.name}.`)
|
@@ -2168,7 +2173,7 @@ class Config {
|
|
2168
2173
|
}
|
2169
2174
|
} else {
|
2170
2175
|
if (!value.initialize) {
|
2171
|
-
throw new Error(`Expected the API to have an initialize function for ${this.name}.`)
|
2176
|
+
throw new Error(`Expected the API to have an initialize function for ${this.name}. If you are trying to pass in multiple API configs at once use setApiKMs to set the names of the configs that you want set.`)
|
2172
2177
|
}
|
2173
2178
|
}
|
2174
2179
|
|
@@ -2185,6 +2190,7 @@ class Config {
|
|
2185
2190
|
this._apiConstructor = constructor
|
2186
2191
|
if (this._apiKMs.length > 0) {
|
2187
2192
|
for (const name of this._apiKMs) {
|
2193
|
+
debugger
|
2188
2194
|
this.km(name)._api = value[name]
|
2189
2195
|
}
|
2190
2196
|
} else {
|
@@ -2263,7 +2269,7 @@ class Config {
|
|
2263
2269
|
if (this._apiKMs.length > 0) {
|
2264
2270
|
const apis = cp._apiConstructor(cp)
|
2265
2271
|
for (const name of this._apiKMs) {
|
2266
|
-
if (name
|
2272
|
+
if (name === this.name) {
|
2267
2273
|
cp._api = apis[name]
|
2268
2274
|
} else {
|
2269
2275
|
cp.km(name)._api = apis[name]
|
@@ -2304,8 +2310,8 @@ class Config {
|
|
2304
2310
|
await cp.rebuild(options) // in copy
|
2305
2311
|
} else {
|
2306
2312
|
if (!cp.config.objects) {
|
2307
|
-
cp.config.objects = {
|
2308
|
-
namespaced: {}
|
2313
|
+
cp.config.objects = {
|
2314
|
+
namespaced: {}
|
2309
2315
|
}
|
2310
2316
|
} else if (!cp.config.objects.namespaced) {
|
2311
2317
|
cp.config.objects.namespaced = {}
|
@@ -2780,7 +2786,7 @@ class Config {
|
|
2780
2786
|
const init = initAfterApis[i]
|
2781
2787
|
init.config.initializerFn({ ...init.args, kms: this.getConfigs(), isAfterApi: true })
|
2782
2788
|
}
|
2783
|
-
const instance = this.instances.find((instance) => instance.name
|
2789
|
+
const instance = this.instances.find((instance) => instance.name === name)
|
2784
2790
|
if (instance) {
|
2785
2791
|
await configHelpers.loadInstance(this, instance)
|
2786
2792
|
}
|
@@ -2801,7 +2807,7 @@ class Config {
|
|
2801
2807
|
}
|
2802
2808
|
|
2803
2809
|
nameToUUID (name) {
|
2804
|
-
return this.configs.find((km) => km._name
|
2810
|
+
return this.configs.find((km) => km._name === name)._uuid
|
2805
2811
|
}
|
2806
2812
|
|
2807
2813
|
// name: namespace name
|
@@ -3066,7 +3072,7 @@ class Config {
|
|
3066
3072
|
}
|
3067
3073
|
|
3068
3074
|
// TODO trie
|
3069
|
-
if (property
|
3075
|
+
if (property === 'words') {
|
3070
3076
|
for (const word in value) {
|
3071
3077
|
for (const def of value[word]) {
|
3072
3078
|
if (!def.uuid) {
|
@@ -3119,7 +3125,7 @@ class Config {
|
|
3119
3125
|
const mores = []
|
3120
3126
|
for (const createConfig of createConfigs) {
|
3121
3127
|
const more = await createConfig()
|
3122
|
-
if (this.name && this.name
|
3128
|
+
if (this.name && this.name === more.name) {
|
3123
3129
|
throw new Error('Cannot add an object to itself for argument number ${index+1}.')
|
3124
3130
|
}
|
3125
3131
|
if (this === more) {
|
@@ -3169,7 +3175,7 @@ class Config {
|
|
3169
3175
|
})
|
3170
3176
|
const noDups = []
|
3171
3177
|
for (const instance of this.instances) {
|
3172
|
-
if (!noDups.find((existing) => existing.name
|
3178
|
+
if (!noDups.find((existing) => existing.name === instance.name)) {
|
3173
3179
|
noDups.push(instance)
|
3174
3180
|
}
|
3175
3181
|
}
|
@@ -3278,9 +3284,9 @@ class Config {
|
|
3278
3284
|
}
|
3279
3285
|
} else if (Array.isArray(value)) {
|
3280
3286
|
// handle allowDups
|
3281
|
-
if (key
|
3287
|
+
if (key === 'operators') {
|
3282
3288
|
// TODO what about other props
|
3283
|
-
const isDup = (op1, op2) => op1.pattern
|
3289
|
+
const isDup = (op1, op2) => op1.pattern === op2.pattern
|
3284
3290
|
for (const newOne of more[key]) {
|
3285
3291
|
for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
|
3286
3292
|
const oldOne = this.config[key][iOldOne]
|
@@ -3294,13 +3300,13 @@ class Config {
|
|
3294
3300
|
}
|
3295
3301
|
}
|
3296
3302
|
}
|
3297
|
-
if (key
|
3303
|
+
if (key === 'bridges') {
|
3298
3304
|
// TODO what about other props
|
3299
|
-
const idDup = (b1, b2) => b1.id
|
3305
|
+
const idDup = (b1, b2) => b1.id === b2.id && b1.level === b2.level && b1.bridge === b2.bridge
|
3300
3306
|
for (const newOne of more[key]) {
|
3301
3307
|
for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
|
3302
3308
|
const oldOne = this.config[key][iOldOne]
|
3303
|
-
if (newOne.id
|
3309
|
+
if (newOne.id === oldOne.id) {
|
3304
3310
|
if (oldOne.allowDups) {
|
3305
3311
|
// the old one takes precedence to match what would happen during the original load
|
3306
3312
|
this.config[key].splice(iOldOne, 1)
|
@@ -3314,7 +3320,7 @@ class Config {
|
|
3314
3320
|
// console.log('key', key, 'XXX')
|
3315
3321
|
// console.log('more', JSON.stringify(more, null, 2))
|
3316
3322
|
// hierarchy must update in place and does not care about the list order
|
3317
|
-
if (key
|
3323
|
+
if (key === 'hierarchy') {
|
3318
3324
|
this.config[key].push(...more[key])
|
3319
3325
|
} else {
|
3320
3326
|
if (addFirst) {
|
@@ -3415,9 +3421,9 @@ class Config {
|
|
3415
3421
|
}
|
3416
3422
|
} else if (Array.isArray(value)) {
|
3417
3423
|
// handle allowDups
|
3418
|
-
if (key
|
3424
|
+
if (key === 'operators') {
|
3419
3425
|
// TODO what about other props
|
3420
|
-
const isDup = (op1, op2) => op1.pattern
|
3426
|
+
const isDup = (op1, op2) => op1.pattern === op2.pattern
|
3421
3427
|
for (const newOne of more[key]) {
|
3422
3428
|
for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
|
3423
3429
|
const oldOne = this.config[key][iOldOne]
|
@@ -3431,13 +3437,13 @@ class Config {
|
|
3431
3437
|
}
|
3432
3438
|
}
|
3433
3439
|
}
|
3434
|
-
if (key
|
3440
|
+
if (key === 'bridges') {
|
3435
3441
|
// TODO what about other props
|
3436
|
-
const idDup = (b1, b2) => b1.id
|
3442
|
+
const idDup = (b1, b2) => b1.id === b2.id && b1.level === b2.level && b1.bridge === b2.bridge
|
3437
3443
|
for (const newOne of more[key]) {
|
3438
3444
|
for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
|
3439
3445
|
const oldOne = this.config[key][iOldOne]
|
3440
|
-
if (newOne.id
|
3446
|
+
if (newOne.id === oldOne.id) {
|
3441
3447
|
if (oldOne.allowDups) {
|
3442
3448
|
// the old one takes precedence to match what would happen during the original load
|
3443
3449
|
this.config[key].splice(iOldOne, 1)
|
package/src/configHelpers.js
CHANGED
@@ -424,7 +424,7 @@ const loadInstance = async (config, instance) => {
|
|
424
424
|
*/
|
425
425
|
const rl = instance.resultss.length
|
426
426
|
if (rl > 0) {
|
427
|
-
config.addAssociations(instance.resultss[instance.resultss.length-1].rtf_associations || [])
|
427
|
+
config.addAssociations(instance.resultss[instance.resultss.length - 1].rtf_associations || [])
|
428
428
|
}
|
429
429
|
/*
|
430
430
|
TODO needs updating if still wanted
|
package/src/digraph.js
CHANGED
@@ -22,7 +22,7 @@ class Digraph {
|
|
22
22
|
while (Object.keys(frontier).length > 0) {
|
23
23
|
const n = Object.keys(frontier)[0]
|
24
24
|
const ps = frontier[n]
|
25
|
-
if (to
|
25
|
+
if (to === n) {
|
26
26
|
return ps[0]
|
27
27
|
}
|
28
28
|
if (done.has(n)) {
|
@@ -184,7 +184,7 @@ class Digraph {
|
|
184
184
|
}
|
185
185
|
|
186
186
|
exists (child, parent) {
|
187
|
-
return this._edges.find((edge) => edge[0]
|
187
|
+
return this._edges.find((edge) => edge[0] === child && edge[1] === parent)
|
188
188
|
}
|
189
189
|
|
190
190
|
addList (l) {
|
package/src/digraph_internal.js
CHANGED
@@ -24,7 +24,7 @@ class DigraphInternal {
|
|
24
24
|
addEdge (edge) {
|
25
25
|
edge = toA(edge)
|
26
26
|
// if (this._edges.find((existing) => _.isEqual(edge, existing))) {
|
27
|
-
if (this._edges.find((existing) => edge[0]
|
27
|
+
if (this._edges.find((existing) => edge[0] === existing[0] && edge[1] === existing[1])) {
|
28
28
|
return false
|
29
29
|
}
|
30
30
|
this._edges.push(edge)
|
@@ -154,7 +154,7 @@ class DigraphInternal {
|
|
154
154
|
}
|
155
155
|
|
156
156
|
exists (child, parent) {
|
157
|
-
return this._edges.findIndex((edge) => edge[0]
|
157
|
+
return this._edges.findIndex((edge) => edge[0] === child && edge[1] === parent) != -1
|
158
158
|
}
|
159
159
|
|
160
160
|
addList (l) {
|
package/src/flatten.js
CHANGED
@@ -92,7 +92,7 @@ const flatten = (markers, value) => {
|
|
92
92
|
const split = markers.includes(marker)
|
93
93
|
if (split) {
|
94
94
|
if ('value' in properties) {
|
95
|
-
flattenedValues = []
|
95
|
+
let flattenedValues = []
|
96
96
|
for (const v of properties.value) {
|
97
97
|
if (v.flatten) {
|
98
98
|
flattenedValues = flattenedValues.concat(flatten(markers, v)[0])
|
package/src/generators.js
CHANGED
@@ -65,7 +65,7 @@ class Generator {
|
|
65
65
|
// return this.match(args)
|
66
66
|
const matches = await this.match(args)
|
67
67
|
if ((matches && (options.debug || {}).match) ||
|
68
|
-
callId
|
68
|
+
callId === this.callId) {
|
69
69
|
// next line is the matcher
|
70
70
|
debugger // eslint-disable-line no-debugger
|
71
71
|
await this.match(args)
|
@@ -78,7 +78,7 @@ class Generator {
|
|
78
78
|
if (!log) {
|
79
79
|
throw new Error('generators.apply argument log is required')
|
80
80
|
}
|
81
|
-
if (baseArgs.call && config &&
|
81
|
+
if (baseArgs.call && config && baseArgs.calls.stack.length > config.maxDepth) {
|
82
82
|
throw new Error(`Max depth of ${config.maxDepth} for calls has been exceeded. maxDepth can be set on the config object. To see the calls run with the --dl or set the debugLoops property on the config`)
|
83
83
|
}
|
84
84
|
|
@@ -116,11 +116,11 @@ class Generator {
|
|
116
116
|
apis: this.getAPIs(config)
|
117
117
|
}
|
118
118
|
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
|
119
|
-
if (this.property
|
119
|
+
if (this.property === 'generatorp') {
|
120
120
|
args.g = args.gp
|
121
121
|
}
|
122
122
|
if ((options.debug || {}).apply ||
|
123
|
-
callId
|
123
|
+
callId === this.callId) {
|
124
124
|
debugger // eslint-disable-line no-debugger
|
125
125
|
}
|
126
126
|
return await this._apply(args)
|
@@ -218,7 +218,7 @@ class Generators {
|
|
218
218
|
lines.setElement(0, 2, stack)
|
219
219
|
lines.newRow()
|
220
220
|
lines.setElement(0, 1, 'DEBUG')
|
221
|
-
lines.setElement(0, 2, `To debug this use args.callId
|
221
|
+
lines.setElement(0, 2, `To debug this use args.callId === '${args.calls.current()}'`)
|
222
222
|
lines.newRow()
|
223
223
|
lines.setElement(0, 1, 'ERROR')
|
224
224
|
lines.setElement(0, 2, errorMessage)
|
@@ -250,7 +250,7 @@ class Generators {
|
|
250
250
|
lines.setElement(0, 2, stack)
|
251
251
|
lines.newRow()
|
252
252
|
lines.setElement(0, 1, 'DEBUG')
|
253
|
-
lines.setElement(0, 2, `To debug this use args.callId
|
253
|
+
lines.setElement(0, 2, `To debug this use args.callId === '${args.calls.current()}'`)
|
254
254
|
lines.newRow()
|
255
255
|
lines.setElement(0, 1, 'TO')
|
256
256
|
lines.setElement(0, 2, `context_id: ${context.context_id}`)
|
package/src/helpers.js
CHANGED
@@ -97,7 +97,7 @@ const appendNoDups = (l1, l2) => {
|
|
97
97
|
}
|
98
98
|
|
99
99
|
const safeNoDups = (list) => {
|
100
|
-
noDups = []
|
100
|
+
const noDups = []
|
101
101
|
for (const element of list) {
|
102
102
|
if (!noDups.find((e) => safeEquals(e, element))) {
|
103
103
|
noDups.push(element)
|
@@ -112,14 +112,14 @@ const safeEquals = (v1, v2) => {
|
|
112
112
|
}
|
113
113
|
|
114
114
|
const type = typeof v1
|
115
|
-
if (type
|
116
|
-
return v1
|
117
|
-
} else if (type
|
118
|
-
return v1.toString()
|
115
|
+
if (type === 'number' || type === 'string') {
|
116
|
+
return v1 === v2
|
117
|
+
} else if (type === 'function') {
|
118
|
+
return v1.toString() === v2.toString()
|
119
119
|
} else if (v1 == undefined || v2 == undefined) {
|
120
|
-
return v1
|
120
|
+
return v1 === v2
|
121
121
|
} else {
|
122
|
-
if (v1.length
|
122
|
+
if (v1.length !== v2.length) {
|
123
123
|
return false
|
124
124
|
}
|
125
125
|
for (const key in v1) {
|
@@ -148,7 +148,7 @@ const semanticsGenerate = (from, known) => {
|
|
148
148
|
}
|
149
149
|
|
150
150
|
return {
|
151
|
-
match: ({context}) => marker
|
151
|
+
match: ({context}) => marker === marker,
|
152
152
|
apply: ({context}) => {
|
153
153
|
},
|
154
154
|
}
|
@@ -299,9 +299,9 @@ const sortJson = (json) => {
|
|
299
299
|
const validProps = (valids, object, type) => {
|
300
300
|
for (const prop of Object.keys(object)) {
|
301
301
|
let okay = false
|
302
|
-
for (valid of valids) {
|
302
|
+
for (const valid of valids) {
|
303
303
|
if (typeof valid === 'string') {
|
304
|
-
okay = prop
|
304
|
+
okay = prop === valid
|
305
305
|
} else {
|
306
306
|
okay = prop.match(valid)
|
307
307
|
}
|
@@ -334,7 +334,7 @@ const updateQueries = (queryOrConfig) => {
|
|
334
334
|
|
335
335
|
const functionsToStrings = (config) => {
|
336
336
|
config = { ...config }
|
337
|
-
defToStrings = (def) => {
|
337
|
+
const defToStrings = (def) => {
|
338
338
|
if (def.apply) {
|
339
339
|
// return { ...def, match: def.match.toString(), apply: def.apply.toString() }
|
340
340
|
return { match: def.match.toString(), apply: def.apply.toString() }
|
@@ -390,7 +390,7 @@ const ecatch = (where, call) => {
|
|
390
390
|
}
|
391
391
|
|
392
392
|
const equalKey = (key1, key2) => {
|
393
|
-
return key1[0]
|
393
|
+
return key1[0] === key2[0] && key1[1] === key2[1]
|
394
394
|
}
|
395
395
|
|
396
396
|
// matches for { context: ..., [ordered], choose: ... } exactely OR
|
@@ -399,8 +399,8 @@ const subPriority = (sub, sup) => {
|
|
399
399
|
if (Array.isArray(sub)) {
|
400
400
|
const subChoosen = sub[0]
|
401
401
|
const subOther = sub[1]
|
402
|
-
const hasChoosen = sup.choose.find((index) => equalKey(sup.context[index], subChoosen))
|
403
|
-
const hasOtherChosen = sup.choose.find((index) => equalKey(sup.context[index], subOther))
|
402
|
+
const hasChoosen = sup.choose.find((index) => equalKey(sup.context[index], subChoosen)) !== undefined
|
403
|
+
const hasOtherChosen = sup.choose.find((index) => equalKey(sup.context[index], subOther)) !== undefined
|
404
404
|
const hasOther = sup.context.find((other) => equalKey(other, subOther)) !== undefined
|
405
405
|
return !!(hasChoosen && hasOther) && !hasOtherChosen
|
406
406
|
}
|
@@ -418,7 +418,7 @@ const subPriority = (sub, sup) => {
|
|
418
418
|
}
|
419
419
|
const chosen1 = choose(sub)
|
420
420
|
const chosen2 = choose(sup)
|
421
|
-
const sameId = (id1, id2) => id1[0]
|
421
|
+
const sameId = (id1, id2) => id1[0] === id2[0] && id1[1] === id2[1]
|
422
422
|
// same length so only need one way
|
423
423
|
const missing1 = chosen1.find((id1) => !chosen2.find((id2) => sameId(id1, id2)))
|
424
424
|
if (missing1) {
|
package/src/semantics.js
CHANGED
@@ -72,7 +72,7 @@ class Semantic {
|
|
72
72
|
async matches (args, context, options = {}) {
|
73
73
|
this.fixUpArgs(args, context)
|
74
74
|
const matches = await this.matcher(args)
|
75
|
-
if (matches && (options.debug || {}).match || args.callId
|
75
|
+
if (matches && (options.debug || {}).match || args.callId === this.callId) {
|
76
76
|
// next line is the matcher
|
77
77
|
debugger // eslint-disable-line no-debugger
|
78
78
|
await this.matcher(args)
|
@@ -92,7 +92,7 @@ class Semantic {
|
|
92
92
|
const contextPrime = Object.assign({}, context)
|
93
93
|
this.fixUpArgs(args, contextPrime)
|
94
94
|
|
95
|
-
if ((options.debug || {}).apply || args.callId
|
95
|
+
if ((options.debug || {}).apply || args.callId === this.callId) {
|
96
96
|
debugger // eslint-disable-line no-debugger
|
97
97
|
}
|
98
98
|
if (args.breakOnSemantics) {
|
@@ -234,7 +234,7 @@ class Semantics {
|
|
234
234
|
lines.setElement(0, 2, stack)
|
235
235
|
lines.newRow()
|
236
236
|
lines.setElement(0, 1, 'DEBUG')
|
237
|
-
lines.setElement(0, 2, `To debug this use args.callId
|
237
|
+
lines.setElement(0, 2, `To debug this use args.callId === '${args.calls.current()}'`)
|
238
238
|
lines.newRow()
|
239
239
|
lines.setElement(0, 1, 'ERROR')
|
240
240
|
lines.setElement(0, 2, errorMessage)
|
@@ -269,7 +269,7 @@ class Semantics {
|
|
269
269
|
lines.setElement(0, 2, stack)
|
270
270
|
lines.newRow()
|
271
271
|
lines.setElement(0, 1, 'DEBUG')
|
272
|
-
lines.setElement(0, 2, `To debug this use args.callId
|
272
|
+
lines.setElement(0, 2, `To debug this use args.callId === '${args.calls.current()}'`)
|
273
273
|
lines.newRow()
|
274
274
|
lines.setElement(0, 1, 'RESULT')
|
275
275
|
lines.setElement(0, 2, `context_id: ${context.context_id}`)
|
package/src/unflatten.js
CHANGED
@@ -36,7 +36,7 @@ const concatLists = (l1, l2) => {
|
|
36
36
|
|
37
37
|
const findPropertyWithManyValues = (contexts, properties) => {
|
38
38
|
for (const property of properties) {
|
39
|
-
if (new Set(contexts.map((context) => context[property])).size
|
39
|
+
if (new Set(contexts.map((context) => context[property])).size === 1) {
|
40
40
|
return property
|
41
41
|
}
|
42
42
|
}
|