theprogrammablemind_4wp 9.3.0-beta.1 → 9.3.0-beta.11
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 +53 -53
- package/demo.js +2 -2
- package/package.json +1 -1
- package/src/config.js +53 -45
- package/src/configHelpers.js +3 -3
- 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 +16 -15
- package/src/project.js +3 -0
- 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
|
}
|
@@ -261,7 +260,7 @@ const throwErrorHandler = (error) => {
|
|
261
260
|
throw error
|
262
261
|
}
|
263
262
|
|
264
|
-
const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, saveDeveloper, rebuildingTemplate, testConfig, testsFN, errorHandler = throwErrorHandler } = {}) => {
|
263
|
+
const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, isProcess, isModule, saveDeveloper, rebuildingTemplate, testConfig, testsFN, errorHandler = throwErrorHandler } = {}) => {
|
265
264
|
if (credentials) {
|
266
265
|
config.server(credentials.server, credentials.key)
|
267
266
|
}
|
@@ -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
|
@@ -346,15 +345,16 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
346
345
|
throw json
|
347
346
|
} else {
|
348
347
|
let clientSideTime
|
348
|
+
let start
|
349
349
|
if (isTest) {
|
350
350
|
start = runtime.performance.performance.now()
|
351
351
|
}
|
352
352
|
const summary = { summaries: json.summaries, length: json.contexts.length }
|
353
353
|
summaries.push(summary)
|
354
354
|
const { contextsPrime, generatedPrime, paraphrasesPrime, paraphrasesParenthesizedPrime, generatedParenthesizedPrime, responsesPrime } =
|
355
|
-
await processContextsB({ isTest, rebuildingTemplate, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
|
355
|
+
await processContextsB({ isTest, isProcess, isModule, rebuildingTemplate, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
|
356
356
|
if (isTest) {
|
357
|
-
end = runtime.performance.performance.now()
|
357
|
+
const end = runtime.performance.performance.now()
|
358
358
|
clientSideTime = end - start
|
359
359
|
}
|
360
360
|
response.associations = json.associations
|
@@ -386,13 +386,13 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
386
386
|
}
|
387
387
|
|
388
388
|
if (writeTests) {
|
389
|
-
const
|
389
|
+
const actualConfig = getConfigForTest(config, testConfig)
|
390
390
|
const saveObjects = { ...config.config.objects }
|
391
391
|
saveObjects.nameToUUID = {}
|
392
392
|
for (const km of config.configs) {
|
393
393
|
saveObjects.nameToUUID[km.name] = km.uuid
|
394
394
|
}
|
395
|
-
writeTest(testsFN, query, saveObjects, response.generated, response.paraphrases, response.responses, response.contexts, response.associations, response.metadata,
|
395
|
+
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
396
|
}
|
397
397
|
|
398
398
|
return response
|
@@ -485,7 +485,7 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
485
485
|
setupArgs(args, config)
|
486
486
|
await testConfig.initializer(args)
|
487
487
|
}
|
488
|
-
const result = await _process(config, test, { errorHandler, isTest: true })
|
488
|
+
const result = await _process(config, test, { errorHandler, isTest: true, isProcess: true, isModule: false })
|
489
489
|
result.query = test
|
490
490
|
if (debug) {
|
491
491
|
defaultInnerProcess(config, errorHandler, result)
|
@@ -499,19 +499,19 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
499
499
|
timings.client += result.clientSideTimes / 1000
|
500
500
|
lines.log()
|
501
501
|
}
|
502
|
-
const
|
503
|
-
delete
|
504
|
-
const
|
505
|
-
const
|
506
|
-
let
|
502
|
+
const expectedObjects = sortJson(convertToStable(expected.objects), { depth: 25 })
|
503
|
+
delete expectedObjects.nameToUUID
|
504
|
+
const actualObjects = sortJson(convertToStable(config.config.objects), { depth: 25 })
|
505
|
+
const failedParaphrases = !matching(result.paraphrases, expected.paraphrases)
|
506
|
+
let failedParaphrasesParenthesized = !matching(result.paraphrasesParenthesized, expected.paraphrasesParenthesized)
|
507
507
|
let failed_generatedParenthesized = !matching(result.generatedParenthesized, expected.generatedParenthesized)
|
508
508
|
// TODO fix the naming conventions: camelcase + use actual instead of result
|
509
|
-
const
|
510
|
-
const
|
511
|
-
const
|
509
|
+
const failedResponses = !matching(result.responses, expected.responses)
|
510
|
+
const failedContexts = !matching(result.contexts, expected.contexts)
|
511
|
+
const failedObjects = !matching(actualObjects, expectedObjects)
|
512
512
|
|
513
513
|
if (args.testNoParenthesized) {
|
514
|
-
|
514
|
+
failedParaphrasesParenthesized = false
|
515
515
|
failed_generatedParenthesized = false
|
516
516
|
}
|
517
517
|
|
@@ -525,23 +525,23 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
525
525
|
}
|
526
526
|
return expected.objects.namespaced[expected.objects.nameToUUID[name]] || {}
|
527
527
|
}
|
528
|
-
const
|
528
|
+
const expectedChecked = sortJson(pickObjects(config, testConfig, expectedGetObjects), { depth: 25 })
|
529
529
|
const actualGetObjects = (name) => {
|
530
530
|
if (!name) {
|
531
531
|
name = config.name
|
532
532
|
}
|
533
|
-
const km = config.configs.find((km) => km.name
|
533
|
+
const km = config.configs.find((km) => km.name === name)
|
534
534
|
return config.config.objects.namespaced[km.uuid] || {}
|
535
535
|
}
|
536
|
-
const
|
537
|
-
const
|
536
|
+
const actualChecked = sortJson(pickObjects(config, testConfig, actualGetObjects), { depth: 25 })
|
537
|
+
const failedChecked = !matching(actualObjects, expectedObjects)
|
538
538
|
|
539
|
-
const
|
540
|
-
const
|
541
|
-
const
|
542
|
-
const
|
543
|
-
const
|
544
|
-
const failed =
|
539
|
+
const failedChecks = !matching(actualObjects, expectedObjects)
|
540
|
+
const failedChecked_objects = !matching(actualChecked, expectedChecked)
|
541
|
+
const actualConfig = sortJson(convertToStable(getConfigForTest(config, testConfig)), { depth: 25 })
|
542
|
+
const expectedConfig = sortJson(convertToStable(expected.config), { depth: 25 })
|
543
|
+
const failedConfig = !matching(actualConfig, expectedConfig)
|
544
|
+
const failed = failedChecked_objects || failedParaphrases || failedParaphrasesParenthesized || failed_generatedParenthesized || failedResponses || failedContexts || failedObjects || failedConfig || failedChecked || failedCheckedContexts
|
545
545
|
|
546
546
|
if (expected.metadata && result.metadata && failed) {
|
547
547
|
const priorities = analyzeMetaData(expected.metadata, result.metadata)
|
@@ -559,9 +559,9 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
559
559
|
paraphrasesParenthesized: expected.paraphrasesParenthesized,
|
560
560
|
generatedParenthesized: expected.generatedParenthesized,
|
561
561
|
results: expected.contexts,
|
562
|
-
checked:
|
562
|
+
checked: expectedChecked,
|
563
563
|
checkedContexts: pickedExpectedContexts,
|
564
|
-
objects:
|
564
|
+
objects: expectedObjects,
|
565
565
|
config: expected.config,
|
566
566
|
summaries: expected.summaries
|
567
567
|
},
|
@@ -571,10 +571,10 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
|
|
571
571
|
paraphrasesParenthesized: result.paraphrasesParenthesized,
|
572
572
|
generatedParenthesized: result.generatedParenthesized,
|
573
573
|
results: result.contexts,
|
574
|
-
checked:
|
574
|
+
checked: actualChecked,
|
575
575
|
checkedContexts: pickedResultContexts,
|
576
|
-
objects:
|
577
|
-
config:
|
576
|
+
objects: actualObjects,
|
577
|
+
config: actualConfig,
|
578
578
|
summaries: result.summaries
|
579
579
|
}
|
580
580
|
}
|
@@ -624,7 +624,7 @@ const saveTest = async (testFile, config, test, expected, testConfig, saveDevelo
|
|
624
624
|
await config.rebuild()
|
625
625
|
const objects = getObjects(config.config.objects)(config.uuid)
|
626
626
|
console.log(test)
|
627
|
-
const result = await _process(config, test, { isTest: true })
|
627
|
+
const result = await _process(config, test, { isTest: true, isProcess: true, isModule: false })
|
628
628
|
// const actualObjects = config.config.objects
|
629
629
|
const actualConfig = getConfigForTest(config, testConfig)
|
630
630
|
const args = {
|
@@ -667,6 +667,7 @@ const showInfo = (description, section, config) => {
|
|
667
667
|
console.log(JSON.stringify(config.getInfo(), null, 2))
|
668
668
|
}
|
669
669
|
|
670
|
+
/*
|
670
671
|
const submitBugToAPI = async (subscription_id, subscription_password, config) => {
|
671
672
|
console.log('********* Submitting bug *********')
|
672
673
|
const body = { description: config.config.description, config: config.config }
|
@@ -689,7 +690,6 @@ const submitBugToAPI = async (subscription_id, subscription_password, config) =>
|
|
689
690
|
})
|
690
691
|
}
|
691
692
|
|
692
|
-
/*
|
693
693
|
const submitBug = async (subscription_id, subscription_password, config, utterance, retries = 2) => {
|
694
694
|
// TODO remove these from the config
|
695
695
|
const properties = ['expected_contexts', 'expected_generated']
|
@@ -862,7 +862,7 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
|
|
862
862
|
|
863
863
|
if (responses.explain_priorities) {
|
864
864
|
console.log('Explain Priorities')
|
865
|
-
for ([inputs, output, reason] of responses.explain_priorities) {
|
865
|
+
for (const [inputs, output, reason] of responses.explain_priorities) {
|
866
866
|
console.log(` inputs: ${JSON.stringify(inputs)} output: ${JSON.stringify(output)} reason: ${reason}`)
|
867
867
|
}
|
868
868
|
}
|
@@ -871,7 +871,7 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
|
|
871
871
|
if (!name) {
|
872
872
|
name = config.name
|
873
873
|
}
|
874
|
-
const km = config.configs.find((km) => km.name
|
874
|
+
const km = config.configs.find((km) => km.name === name)
|
875
875
|
return config.config.objects.namespaced[km.uuid] || {}
|
876
876
|
}
|
877
877
|
const picked = sortJson(pickObjects(config, config.testConfig, actualGetObjects), { depth: 25 })
|
@@ -967,7 +967,7 @@ const rebuildTemplate = async ({ config, instance, target, previousResultss, reb
|
|
967
967
|
}
|
968
968
|
config.config.skipSemantics = skipSemantics && !isFragment
|
969
969
|
const transitoryMode = global.transitoryMode
|
970
|
-
if (isFragment || property
|
970
|
+
if (isFragment || property === 'fragments') {
|
971
971
|
global.transitoryMode = true
|
972
972
|
}
|
973
973
|
if (hierarchy) {
|
@@ -991,7 +991,7 @@ const rebuildTemplate = async ({ config, instance, target, previousResultss, reb
|
|
991
991
|
console.log(getSuggestionMessage(suggestion))
|
992
992
|
}
|
993
993
|
}
|
994
|
-
if (!rebuild && previousResults && previousResults.query
|
994
|
+
if (!rebuild && previousResults && previousResults.query === query.query) {
|
995
995
|
results = previousResults
|
996
996
|
prMessage = ' Using previous results. use -rtf for a hard rebuild of everything on the server side.'
|
997
997
|
await loadInstance(config, { resultss: [results] })
|
@@ -1139,7 +1139,7 @@ const rebuildTemplate = async ({ config, instance, target, previousResultss, reb
|
|
1139
1139
|
for (let configsIndex = 0; configsIndex < template.configs.length; ++configsIndex) {
|
1140
1140
|
const query = template.configs[configsIndex]
|
1141
1141
|
// account for things for example associations being added to the config while debugginer
|
1142
|
-
const pr = previousResultss && previousResultss.find((pr) => pr.query
|
1142
|
+
const pr = previousResultss && previousResultss.find((pr) => pr.query === query)
|
1143
1143
|
todo.push({ property: 'resultss', query, previousResults: pr, skipSemantics: false || query.skipSemantics })
|
1144
1144
|
}
|
1145
1145
|
}
|
@@ -1309,7 +1309,7 @@ const knowledgeModuleImpl = async ({
|
|
1309
1309
|
parser.add_argument('--parenthesized', { action: 'store_true', help: 'Show the generated phrases with parenthesis.' })
|
1310
1310
|
parser.add_argument('-c', '--clean', { help: 'Remove data from the test files. a === association' })
|
1311
1311
|
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
|
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 === associations j === JSON sent to server. for example --print wb' })
|
1313
1313
|
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
1314
|
parser.add_argument('-fr', '--failRebuild', { action: 'store_true', help: 'If a rebuild is required fail out.' })
|
1315
1315
|
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 +1361,10 @@ const knowledgeModuleImpl = async ({
|
|
1361
1361
|
if (what.length !== 2) {
|
1362
1362
|
return false
|
1363
1363
|
}
|
1364
|
-
if (!typeof what[0]
|
1364
|
+
if (!typeof what[0] === 'string') {
|
1365
1365
|
return false
|
1366
1366
|
}
|
1367
|
-
if (!typeof what[1]
|
1367
|
+
if (!typeof what[1] === 'number') {
|
1368
1368
|
return false
|
1369
1369
|
}
|
1370
1370
|
return true
|
@@ -1682,9 +1682,9 @@ const knowledgeModuleImpl = async ({
|
|
1682
1682
|
const tidy_summaries = (summaries) => {
|
1683
1683
|
const summaries_prime = []
|
1684
1684
|
for (const chunk of summaries) {
|
1685
|
-
chunk_prime = { length: chunk.length, summaries: [] }
|
1685
|
+
const chunk_prime = { length: chunk.length, summaries: [] }
|
1686
1686
|
for (const summary of chunk.summaries) {
|
1687
|
-
const summary_prime = { counter: summary.counter, operators: [] }
|
1687
|
+
const summary_prime = { counter: summary.counter, operators: [] }
|
1688
1688
|
for (const operator of summary.operators) {
|
1689
1689
|
summary_prime.operators.push(`{ marker: [${operator.marker[0]}, ${operator.marker[1]}] range: { start: ${operator.range.start}, end: ${operator.range.end} } }`)
|
1690
1690
|
}
|
@@ -1716,7 +1716,7 @@ const knowledgeModuleImpl = async ({
|
|
1716
1716
|
if (lengths > iDiff) {
|
1717
1717
|
const suggestion = suggestAssociationsFix(result.expected.summaries[iSummaries].summaries, result.actual.summaries[iSummaries].summaries)
|
1718
1718
|
if (suggestion) {
|
1719
|
-
suggestedFix = suggestion
|
1719
|
+
const suggestedFix = suggestion
|
1720
1720
|
// console.log(`Try adding this to the associations: { context: ${JSON.stringify(getSuggestion(suggestedFix))}, choose: <indexOfMainElement> },`)
|
1721
1721
|
console.log(getSuggestionMessage(suggestedFix))
|
1722
1722
|
return
|
@@ -1856,7 +1856,7 @@ const knowledgeModuleImpl = async ({
|
|
1856
1856
|
f()
|
1857
1857
|
})
|
1858
1858
|
.catch((e) => {
|
1859
|
-
if (e.errno
|
1859
|
+
if (e.errno === 'ECONNREFUSED') {
|
1860
1860
|
console.log(e)
|
1861
1861
|
readline.close()
|
1862
1862
|
} else {
|
@@ -1880,7 +1880,7 @@ const knowledgeModuleImpl = async ({
|
|
1880
1880
|
global.beforeObjects = _.cloneDeep(objects)
|
1881
1881
|
}
|
1882
1882
|
try {
|
1883
|
-
await processResults(_process(config, args.query, { commandLineArgs: args, dontAddAssociations: args.dontAddAssociations, writeTests: args.save || args.saveDeveloper, saveDeveloper: args.saveDeveloper, testConfig, testsFN: test }))
|
1883
|
+
await processResults(_process(config, args.query, { isProcess, isModule: !isProcess, commandLineArgs: args, dontAddAssociations: args.dontAddAssociations, writeTests: args.save || args.saveDeveloper, saveDeveloper: args.saveDeveloper, testConfig, testsFN: test }))
|
1884
1884
|
} catch (error) {
|
1885
1885
|
console.log('Error', error)
|
1886
1886
|
}
|
@@ -1938,7 +1938,7 @@ const knowledgeModuleImpl = async ({
|
|
1938
1938
|
|
1939
1939
|
// no cache 21 minutes + rebuild fails "node tester_rebuild -m colors"
|
1940
1940
|
// cache okay
|
1941
|
-
createConfigExport = async () => {
|
1941
|
+
const createConfigExport = async () => {
|
1942
1942
|
if (createConfig.cached) {
|
1943
1943
|
return createConfig.cached
|
1944
1944
|
}
|
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,9 +2110,12 @@ 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
|
+
if (!this.getConfig(name)) {
|
2117
|
+
throw new Error(`Config.apiBase: The requested KM '${name}' has not been loaded`)
|
2118
|
+
}
|
2116
2119
|
return this.getConfig(name)._api.constructor
|
2117
2120
|
}
|
2118
2121
|
} else {
|
@@ -2147,7 +2150,12 @@ class Config {
|
|
2147
2150
|
}
|
2148
2151
|
}
|
2149
2152
|
|
2153
|
+
setApiKMs (apiKMs) {
|
2154
|
+
this._apiKMs = [...apiKMs]
|
2155
|
+
}
|
2156
|
+
|
2150
2157
|
// constructors is a constructor
|
2158
|
+
// TODO fix Api to be API WTF
|
2151
2159
|
async setApi (constructor) {
|
2152
2160
|
if (typeof constructor !== 'function') {
|
2153
2161
|
throw new Error(`Expected the argument to be an API constructor for ${this.name}.`)
|
@@ -2165,7 +2173,7 @@ class Config {
|
|
2165
2173
|
}
|
2166
2174
|
} else {
|
2167
2175
|
if (!value.initialize) {
|
2168
|
-
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.`)
|
2169
2177
|
}
|
2170
2178
|
}
|
2171
2179
|
|
@@ -2260,7 +2268,7 @@ class Config {
|
|
2260
2268
|
if (this._apiKMs.length > 0) {
|
2261
2269
|
const apis = cp._apiConstructor(cp)
|
2262
2270
|
for (const name of this._apiKMs) {
|
2263
|
-
if (name
|
2271
|
+
if (name === this.name) {
|
2264
2272
|
cp._api = apis[name]
|
2265
2273
|
} else {
|
2266
2274
|
cp.km(name)._api = apis[name]
|
@@ -2301,8 +2309,8 @@ class Config {
|
|
2301
2309
|
await cp.rebuild(options) // in copy
|
2302
2310
|
} else {
|
2303
2311
|
if (!cp.config.objects) {
|
2304
|
-
cp.config.objects = {
|
2305
|
-
namespaced: {}
|
2312
|
+
cp.config.objects = {
|
2313
|
+
namespaced: {}
|
2306
2314
|
}
|
2307
2315
|
} else if (!cp.config.objects.namespaced) {
|
2308
2316
|
cp.config.objects.namespaced = {}
|
@@ -2777,7 +2785,7 @@ class Config {
|
|
2777
2785
|
const init = initAfterApis[i]
|
2778
2786
|
init.config.initializerFn({ ...init.args, kms: this.getConfigs(), isAfterApi: true })
|
2779
2787
|
}
|
2780
|
-
const instance = this.instances.find((instance) => instance.name
|
2788
|
+
const instance = this.instances.find((instance) => instance.name === name)
|
2781
2789
|
if (instance) {
|
2782
2790
|
await configHelpers.loadInstance(this, instance)
|
2783
2791
|
}
|
@@ -2798,7 +2806,7 @@ class Config {
|
|
2798
2806
|
}
|
2799
2807
|
|
2800
2808
|
nameToUUID (name) {
|
2801
|
-
return this.configs.find((km) => km._name
|
2809
|
+
return this.configs.find((km) => km._name === name)._uuid
|
2802
2810
|
}
|
2803
2811
|
|
2804
2812
|
// name: namespace name
|
@@ -3063,7 +3071,7 @@ class Config {
|
|
3063
3071
|
}
|
3064
3072
|
|
3065
3073
|
// TODO trie
|
3066
|
-
if (property
|
3074
|
+
if (property === 'words') {
|
3067
3075
|
for (const word in value) {
|
3068
3076
|
for (const def of value[word]) {
|
3069
3077
|
if (!def.uuid) {
|
@@ -3116,7 +3124,7 @@ class Config {
|
|
3116
3124
|
const mores = []
|
3117
3125
|
for (const createConfig of createConfigs) {
|
3118
3126
|
const more = await createConfig()
|
3119
|
-
if (this.name && this.name
|
3127
|
+
if (this.name && this.name === more.name) {
|
3120
3128
|
throw new Error('Cannot add an object to itself for argument number ${index+1}.')
|
3121
3129
|
}
|
3122
3130
|
if (this === more) {
|
@@ -3166,7 +3174,7 @@ class Config {
|
|
3166
3174
|
})
|
3167
3175
|
const noDups = []
|
3168
3176
|
for (const instance of this.instances) {
|
3169
|
-
if (!noDups.find((existing) => existing.name
|
3177
|
+
if (!noDups.find((existing) => existing.name === instance.name)) {
|
3170
3178
|
noDups.push(instance)
|
3171
3179
|
}
|
3172
3180
|
}
|
@@ -3275,9 +3283,9 @@ class Config {
|
|
3275
3283
|
}
|
3276
3284
|
} else if (Array.isArray(value)) {
|
3277
3285
|
// handle allowDups
|
3278
|
-
if (key
|
3286
|
+
if (key === 'operators') {
|
3279
3287
|
// TODO what about other props
|
3280
|
-
const isDup = (op1, op2) => op1.pattern
|
3288
|
+
const isDup = (op1, op2) => op1.pattern === op2.pattern
|
3281
3289
|
for (const newOne of more[key]) {
|
3282
3290
|
for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
|
3283
3291
|
const oldOne = this.config[key][iOldOne]
|
@@ -3291,13 +3299,13 @@ class Config {
|
|
3291
3299
|
}
|
3292
3300
|
}
|
3293
3301
|
}
|
3294
|
-
if (key
|
3302
|
+
if (key === 'bridges') {
|
3295
3303
|
// TODO what about other props
|
3296
|
-
const idDup = (b1, b2) => b1.id
|
3304
|
+
const idDup = (b1, b2) => b1.id === b2.id && b1.level === b2.level && b1.bridge === b2.bridge
|
3297
3305
|
for (const newOne of more[key]) {
|
3298
3306
|
for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
|
3299
3307
|
const oldOne = this.config[key][iOldOne]
|
3300
|
-
if (newOne.id
|
3308
|
+
if (newOne.id === oldOne.id) {
|
3301
3309
|
if (oldOne.allowDups) {
|
3302
3310
|
// the old one takes precedence to match what would happen during the original load
|
3303
3311
|
this.config[key].splice(iOldOne, 1)
|
@@ -3311,7 +3319,7 @@ class Config {
|
|
3311
3319
|
// console.log('key', key, 'XXX')
|
3312
3320
|
// console.log('more', JSON.stringify(more, null, 2))
|
3313
3321
|
// hierarchy must update in place and does not care about the list order
|
3314
|
-
if (key
|
3322
|
+
if (key === 'hierarchy') {
|
3315
3323
|
this.config[key].push(...more[key])
|
3316
3324
|
} else {
|
3317
3325
|
if (addFirst) {
|
@@ -3412,9 +3420,9 @@ class Config {
|
|
3412
3420
|
}
|
3413
3421
|
} else if (Array.isArray(value)) {
|
3414
3422
|
// handle allowDups
|
3415
|
-
if (key
|
3423
|
+
if (key === 'operators') {
|
3416
3424
|
// TODO what about other props
|
3417
|
-
const isDup = (op1, op2) => op1.pattern
|
3425
|
+
const isDup = (op1, op2) => op1.pattern === op2.pattern
|
3418
3426
|
for (const newOne of more[key]) {
|
3419
3427
|
for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
|
3420
3428
|
const oldOne = this.config[key][iOldOne]
|
@@ -3428,13 +3436,13 @@ class Config {
|
|
3428
3436
|
}
|
3429
3437
|
}
|
3430
3438
|
}
|
3431
|
-
if (key
|
3439
|
+
if (key === 'bridges') {
|
3432
3440
|
// TODO what about other props
|
3433
|
-
const idDup = (b1, b2) => b1.id
|
3441
|
+
const idDup = (b1, b2) => b1.id === b2.id && b1.level === b2.level && b1.bridge === b2.bridge
|
3434
3442
|
for (const newOne of more[key]) {
|
3435
3443
|
for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
|
3436
3444
|
const oldOne = this.config[key][iOldOne]
|
3437
|
-
if (newOne.id
|
3445
|
+
if (newOne.id === oldOne.id) {
|
3438
3446
|
if (oldOne.allowDups) {
|
3439
3447
|
// the old one takes precedence to match what would happen during the original load
|
3440
3448
|
this.config[key].splice(iOldOne, 1)
|
package/src/configHelpers.js
CHANGED
@@ -279,7 +279,7 @@ const setupContexts = (rawContexts) => {
|
|
279
279
|
return contexts
|
280
280
|
}
|
281
281
|
|
282
|
-
const processContextsB = async ({ config, hierarchy, semantics, generators, json, isTest, rebuildingTemplate, isInstance, instance, query, data, retries, url, commandLineArgs, forTemplate }) => {
|
282
|
+
const processContextsB = async ({ config, isProcess, isModule, hierarchy, semantics, generators, json, isTest, rebuildingTemplate, isInstance, instance, query, data, retries, url, commandLineArgs, forTemplate }) => {
|
283
283
|
// TODO fix this name to contextsPrime
|
284
284
|
const contextsPrime = []
|
285
285
|
const generatedPrime = []
|
@@ -290,7 +290,7 @@ const processContextsB = async ({ config, hierarchy, semantics, generators, json
|
|
290
290
|
const contexts = setupContexts(json.contexts)
|
291
291
|
|
292
292
|
const objects = config.get('objects')
|
293
|
-
const args = { objects, isResponse: true, response: json, isTest, isInstance, getObjects: getObjects(objects), instance, contexts }
|
293
|
+
const args = { objects, isResponse: true, response: json, isTest, isInstance, getObjects: getObjects(objects), instance, contexts, isProcess, isModule }
|
294
294
|
if (!json.logs) {
|
295
295
|
json.logs = []
|
296
296
|
}
|
@@ -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
|
}
|
@@ -310,6 +310,7 @@ const validProps = (valids, object, type) => {
|
|
310
310
|
}
|
311
311
|
}
|
312
312
|
if (!okay) {
|
313
|
+
valids.sort()
|
313
314
|
throw new Error(`Unknown property "${prop}" in the ${type}. Valid properties are ${valids.join(', ')}. The ${type} is ${JSON.stringify(object)}`)
|
314
315
|
}
|
315
316
|
}
|
@@ -334,7 +335,7 @@ const updateQueries = (queryOrConfig) => {
|
|
334
335
|
|
335
336
|
const functionsToStrings = (config) => {
|
336
337
|
config = { ...config }
|
337
|
-
defToStrings = (def) => {
|
338
|
+
const defToStrings = (def) => {
|
338
339
|
if (def.apply) {
|
339
340
|
// return { ...def, match: def.match.toString(), apply: def.apply.toString() }
|
340
341
|
return { match: def.match.toString(), apply: def.apply.toString() }
|
@@ -390,7 +391,7 @@ const ecatch = (where, call) => {
|
|
390
391
|
}
|
391
392
|
|
392
393
|
const equalKey = (key1, key2) => {
|
393
|
-
return key1[0]
|
394
|
+
return key1[0] === key2[0] && key1[1] === key2[1]
|
394
395
|
}
|
395
396
|
|
396
397
|
// matches for { context: ..., [ordered], choose: ... } exactely OR
|
@@ -399,8 +400,8 @@ const subPriority = (sub, sup) => {
|
|
399
400
|
if (Array.isArray(sub)) {
|
400
401
|
const subChoosen = sub[0]
|
401
402
|
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))
|
403
|
+
const hasChoosen = sup.choose.find((index) => equalKey(sup.context[index], subChoosen)) !== undefined
|
404
|
+
const hasOtherChosen = sup.choose.find((index) => equalKey(sup.context[index], subOther)) !== undefined
|
404
405
|
const hasOther = sup.context.find((other) => equalKey(other, subOther)) !== undefined
|
405
406
|
return !!(hasChoosen && hasOther) && !hasOtherChosen
|
406
407
|
}
|
@@ -418,7 +419,7 @@ const subPriority = (sub, sup) => {
|
|
418
419
|
}
|
419
420
|
const chosen1 = choose(sub)
|
420
421
|
const chosen2 = choose(sup)
|
421
|
-
const sameId = (id1, id2) => id1[0]
|
422
|
+
const sameId = (id1, id2) => id1[0] === id2[0] && id1[1] === id2[1]
|
422
423
|
// same length so only need one way
|
423
424
|
const missing1 = chosen1.find((id1) => !chosen2.find((id2) => sameId(id1, id2)))
|
424
425
|
if (missing1) {
|
package/src/project.js
CHANGED
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
|
}
|