theprogrammablemind_4wp 9.3.0-beta.4 → 9.3.0-beta.6

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 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, ErrorReason, listable, setupArgs, gs, processContext, getObjects, setupProcessB, processContextsB } = require('./src/configHelpers')
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, InitCalls, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps } = require('./src/helpers')
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) == JSON.stringify(sjson2)
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 == 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 == 'NOT_IN_CACHE') {
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,6 +345,7 @@ 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
  }
@@ -354,7 +354,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
354
354
  const { contextsPrime, generatedPrime, paraphrasesPrime, paraphrasesParenthesizedPrime, generatedParenthesizedPrime, responsesPrime } =
355
355
  await processContextsB({ isTest, 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 actual_config = getConfigForTest(config, testConfig)
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, actual_config, saveDeveloper, response.paraphrasesParenthesized, response.generatedParenthesized, response.summaries)
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
@@ -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 expected_objects = sortJson(convertToStable(expected.objects), { depth: 25 })
503
- delete expected_objects.nameToUUID
504
- const actual_objects = sortJson(convertToStable(config.config.objects), { depth: 25 })
505
- const failed_paraphrases = !matching(result.paraphrases, expected.paraphrases)
506
- let failed_paraphrasesParenthesized = !matching(result.paraphrasesParenthesized, expected.paraphrasesParenthesized)
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 failed_responses = !matching(result.responses, expected.responses)
510
- const failed_contexts = !matching(result.contexts, expected.contexts)
511
- const failed_objects = !matching(actual_objects, expected_objects)
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
- failed_paraphrasesParenthesized = false
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 expected_checked = sortJson(pickObjects(config, testConfig, expectedGetObjects), { depth: 25 })
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 == name)
533
+ const km = config.configs.find((km) => km.name === name)
534
534
  return config.config.objects.namespaced[km.uuid] || {}
535
535
  }
536
- const actual_checked = sortJson(pickObjects(config, testConfig, actualGetObjects), { depth: 25 })
537
- const failed_checked = !matching(actual_objects, expected_objects)
536
+ const actualChecked = sortJson(pickObjects(config, testConfig, actualGetObjects), { depth: 25 })
537
+ const failedChecked = !matching(actualObjects, expectedObjects)
538
538
 
539
- const failed_checks = !matching(actual_objects, expected_objects)
540
- const failed_checked_objects = !matching(actual_checked, expected_checked)
541
- const actual_config = sortJson(convertToStable(getConfigForTest(config, testConfig)), { depth: 25 })
542
- const expected_config = sortJson(convertToStable(expected.config), { depth: 25 })
543
- const failed_config = !matching(actual_config, expected_config)
544
- const failed = failed_checked_objects || failed_paraphrases || failed_paraphrasesParenthesized || failed_generatedParenthesized || failed_responses || failed_contexts || failed_objects || failed_config || failed_checked || failedCheckedContexts
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: expected_checked,
562
+ checked: expectedChecked,
563
563
  checkedContexts: pickedExpectedContexts,
564
- objects: expected_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: actual_checked,
574
+ checked: actualChecked,
575
575
  checkedContexts: pickedResultContexts,
576
- objects: actual_objects,
577
- config: actual_config,
576
+ objects: actualObjects,
577
+ config: actualConfig,
578
578
  summaries: result.summaries
579
579
  }
580
580
  }
@@ -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 == 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 == 'fragments') {
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 == query.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 == 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 == associations j == JSON sent to server. for example --print wb' })
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] == 'string') {
1364
+ if (!typeof what[0] === 'string') {
1365
1365
  return false
1366
1366
  }
1367
- if (!typeof what[1] == 'number') {
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 == 'ECONNREFUSED') {
1859
+ if (e.errno === 'ECONNREFUSED') {
1860
1860
  console.log(e)
1861
1861
  readline.close()
1862
1862
  } else {
@@ -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 == 'unknown',
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 == 'went',
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
@@ -69,6 +69,6 @@
69
69
  "sort-json": "^2.0.0",
70
70
  "uuid": "^8.3.2"
71
71
  },
72
- "version": "9.3.0-beta.4",
72
+ "version": "9.3.0-beta.6",
73
73
  "license": "UNLICENSED"
74
74
  }
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 == bridge.id) {
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 == 'associations') {
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 == 'words') {
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 == args.context.marker && args.context.level == level && args.context.paraphrase && await match(args),
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 == args.context.marker && args.context.level == level && !args.context.paraphrase && (args.context.response || args.context.isResponse) && await match(args),
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 == semantic.apply or semantic there is one function that has apply defined for some reason even though not explicitly set
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 == args.context.marker && !!args.context.evaluate == evaluate && match(args),
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 == marker) {
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 == '${value.marker}' && context.evaluate && <other conditions as you like>`
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 == hc.child && parent == hc.parent) {
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 == id && bridge.level == level)
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 == 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 == bridge.id && b.level == bridge.level && b.bridge == bridge.bridge )) {
1522
- if (bridges.find((b) => b.id == bridge.id && b.level == bridge.level)) {
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 == -1) {
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 == operator.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 == 0) {
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 == name) {
2113
+ if (this.name === name) {
2114
2114
  return this._api.constructor
2115
2115
  } else {
2116
2116
  if (!this.getConfig(name)) {
@@ -2150,7 +2150,7 @@ class Config {
2150
2150
  }
2151
2151
  }
2152
2152
 
2153
- setApiKMs(apiKMs) {
2153
+ setApiKMs (apiKMs) {
2154
2154
  this._apiKMs = [...apiKMs]
2155
2155
  }
2156
2156
 
@@ -2269,7 +2269,7 @@ class Config {
2269
2269
  if (this._apiKMs.length > 0) {
2270
2270
  const apis = cp._apiConstructor(cp)
2271
2271
  for (const name of this._apiKMs) {
2272
- if (name == this.name) {
2272
+ if (name === this.name) {
2273
2273
  cp._api = apis[name]
2274
2274
  } else {
2275
2275
  cp.km(name)._api = apis[name]
@@ -2310,8 +2310,8 @@ class Config {
2310
2310
  await cp.rebuild(options) // in copy
2311
2311
  } else {
2312
2312
  if (!cp.config.objects) {
2313
- cp.config.objects = {
2314
- namespaced: {},
2313
+ cp.config.objects = {
2314
+ namespaced: {}
2315
2315
  }
2316
2316
  } else if (!cp.config.objects.namespaced) {
2317
2317
  cp.config.objects.namespaced = {}
@@ -2786,7 +2786,7 @@ class Config {
2786
2786
  const init = initAfterApis[i]
2787
2787
  init.config.initializerFn({ ...init.args, kms: this.getConfigs(), isAfterApi: true })
2788
2788
  }
2789
- const instance = this.instances.find((instance) => instance.name == name)
2789
+ const instance = this.instances.find((instance) => instance.name === name)
2790
2790
  if (instance) {
2791
2791
  await configHelpers.loadInstance(this, instance)
2792
2792
  }
@@ -2807,7 +2807,7 @@ class Config {
2807
2807
  }
2808
2808
 
2809
2809
  nameToUUID (name) {
2810
- return this.configs.find((km) => km._name == name)._uuid
2810
+ return this.configs.find((km) => km._name === name)._uuid
2811
2811
  }
2812
2812
 
2813
2813
  // name: namespace name
@@ -3072,7 +3072,7 @@ class Config {
3072
3072
  }
3073
3073
 
3074
3074
  // TODO trie
3075
- if (property == 'words') {
3075
+ if (property === 'words') {
3076
3076
  for (const word in value) {
3077
3077
  for (const def of value[word]) {
3078
3078
  if (!def.uuid) {
@@ -3125,7 +3125,7 @@ class Config {
3125
3125
  const mores = []
3126
3126
  for (const createConfig of createConfigs) {
3127
3127
  const more = await createConfig()
3128
- if (this.name && this.name == more.name) {
3128
+ if (this.name && this.name === more.name) {
3129
3129
  throw new Error('Cannot add an object to itself for argument number ${index+1}.')
3130
3130
  }
3131
3131
  if (this === more) {
@@ -3175,7 +3175,7 @@ class Config {
3175
3175
  })
3176
3176
  const noDups = []
3177
3177
  for (const instance of this.instances) {
3178
- if (!noDups.find((existing) => existing.name == instance.name)) {
3178
+ if (!noDups.find((existing) => existing.name === instance.name)) {
3179
3179
  noDups.push(instance)
3180
3180
  }
3181
3181
  }
@@ -3284,9 +3284,9 @@ class Config {
3284
3284
  }
3285
3285
  } else if (Array.isArray(value)) {
3286
3286
  // handle allowDups
3287
- if (key == 'operators') {
3287
+ if (key === 'operators') {
3288
3288
  // TODO what about other props
3289
- const isDup = (op1, op2) => op1.pattern == op2.pattern
3289
+ const isDup = (op1, op2) => op1.pattern === op2.pattern
3290
3290
  for (const newOne of more[key]) {
3291
3291
  for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
3292
3292
  const oldOne = this.config[key][iOldOne]
@@ -3300,13 +3300,13 @@ class Config {
3300
3300
  }
3301
3301
  }
3302
3302
  }
3303
- if (key == 'bridges') {
3303
+ if (key === 'bridges') {
3304
3304
  // TODO what about other props
3305
- const idDup = (b1, b2) => b1.id == b2.id && b1.level == b2.level && b1.bridge == b2.bridge
3305
+ const idDup = (b1, b2) => b1.id === b2.id && b1.level === b2.level && b1.bridge === b2.bridge
3306
3306
  for (const newOne of more[key]) {
3307
3307
  for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
3308
3308
  const oldOne = this.config[key][iOldOne]
3309
- if (newOne.id == oldOne.id) {
3309
+ if (newOne.id === oldOne.id) {
3310
3310
  if (oldOne.allowDups) {
3311
3311
  // the old one takes precedence to match what would happen during the original load
3312
3312
  this.config[key].splice(iOldOne, 1)
@@ -3320,7 +3320,7 @@ class Config {
3320
3320
  // console.log('key', key, 'XXX')
3321
3321
  // console.log('more', JSON.stringify(more, null, 2))
3322
3322
  // hierarchy must update in place and does not care about the list order
3323
- if (key == 'hierarchy') {
3323
+ if (key === 'hierarchy') {
3324
3324
  this.config[key].push(...more[key])
3325
3325
  } else {
3326
3326
  if (addFirst) {
@@ -3421,9 +3421,9 @@ class Config {
3421
3421
  }
3422
3422
  } else if (Array.isArray(value)) {
3423
3423
  // handle allowDups
3424
- if (key == 'operators') {
3424
+ if (key === 'operators') {
3425
3425
  // TODO what about other props
3426
- const isDup = (op1, op2) => op1.pattern == op2.pattern
3426
+ const isDup = (op1, op2) => op1.pattern === op2.pattern
3427
3427
  for (const newOne of more[key]) {
3428
3428
  for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
3429
3429
  const oldOne = this.config[key][iOldOne]
@@ -3437,13 +3437,13 @@ class Config {
3437
3437
  }
3438
3438
  }
3439
3439
  }
3440
- if (key == 'bridges') {
3440
+ if (key === 'bridges') {
3441
3441
  // TODO what about other props
3442
- const idDup = (b1, b2) => b1.id == b2.id && b1.level == b2.level && b1.bridge == b2.bridge
3442
+ const idDup = (b1, b2) => b1.id === b2.id && b1.level === b2.level && b1.bridge === b2.bridge
3443
3443
  for (const newOne of more[key]) {
3444
3444
  for (let iOldOne = 0; iOldOne < this.config[key].length; ++iOldOne) {
3445
3445
  const oldOne = this.config[key][iOldOne]
3446
- if (newOne.id == oldOne.id) {
3446
+ if (newOne.id === oldOne.id) {
3447
3447
  if (oldOne.allowDups) {
3448
3448
  // the old one takes precedence to match what would happen during the original load
3449
3449
  this.config[key].splice(iOldOne, 1)
@@ -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 == n) {
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] == child && edge[1] == parent)
187
+ return this._edges.find((edge) => edge[0] === child && edge[1] === parent)
188
188
  }
189
189
 
190
190
  addList (l) {
@@ -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] == existing[0] && edge[1] == existing[1])) {
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] == child && edge[1] == parent) != -1
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 == this.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 && sbaseArgs.calls.stack.length > config.maxDepth) {
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 == 'generatorp') {
119
+ if (this.property === 'generatorp') {
120
120
  args.g = args.gp
121
121
  }
122
122
  if ((options.debug || {}).apply ||
123
- callId == this.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 == '${args.calls.current()}'`)
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 == '${args.calls.current()}'`)
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 == 'number' || type == 'string') {
116
- return v1 == v2
117
- } else if (type == 'function') {
118
- return v1.toString() == v2.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 == v2
120
+ return v1 === v2
121
121
  } else {
122
- if (v1.length != v2.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 == 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 == valid
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] == key2[0] && key1[1] == key2[1]
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)) != undefined
403
- const hasOtherChosen = sup.choose.find((index) => equalKey(sup.context[index], subOther)) != undefined
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] == id2[0] && id1[1] == id2[1]
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 == this.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 == this.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 == '${args.calls.current()}'`)
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 == '${args.calls.current()}'`)
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 == 1) {
39
+ if (new Set(contexts.map((context) => context[property])).size === 1) {
40
40
  return property
41
41
  }
42
42
  }