theprogrammablemind_4wp 7.6.0 → 7.7.0

Sign up to get free protection for your applications and to get access to all the features.
package/client.js CHANGED
@@ -173,22 +173,32 @@ const setupArgs = (args, config, logs, hierarchy) => {
173
173
  args.theDebugger = {
174
174
  breakOnSemantics: (value) => args.breakOnSemantics = value
175
175
  }
176
- args.s = (c) => config.getSemantics(logs).apply(args, c)
177
- args.g = (c) => config.getGenerators(logs).apply(args, c)
178
- args.gp = (c) => config.getGenerators(logs).apply(args, { ...c, paraphrase: true, isResponse: false, response: false})
179
- args.gr = (c) => config.getGenerators(logs).apply(args, { ...c, paraphrase: false, isResponse: true })
180
176
  if (!logs) {
181
177
  debugger
182
178
  }
183
- args.e = (c) => config.getEvaluator(args.s, args.calls, logs, c)
184
179
  args.log = (message) => logs.push(message)
185
- args.gs = gs(args.g)
186
- args.gsp = gs(args.gp)
187
- args.gsr = gs(args.gr)
180
+
181
+ args.addAssumedScoped = (args, assumed) => {
182
+ args.s = (c) => config.getSemantics(logs).apply(args, c)
183
+ args.g = (c) => config.getGenerators(logs).apply(args, c)
184
+ args.gp = (c) => config.getGenerators(logs).apply({...args, assumed: {paraphrase: true, isResponse: false, response: false}}, c, {paraphrase: true, isResponse: false, response: false})
185
+ args.gr = (c) => config.getGenerators(logs).apply({...args, assumed: {paraphrase: false, isResponse: true}}, { ...c, paraphrase: false, isResponse: true })
186
+ args.e = (c) => config.getEvaluator(args.s, args.calls, logs, c)
187
+ args.gs = gs(args.g)
188
+ args.gsp = gs(args.gp)
189
+ args.gsr = gs(args.gr)
190
+ }
191
+ // for semantics
192
+ args.addAssumedScoped(args, {})
188
193
  config.getAddedArgs(args)
189
194
  }
190
195
 
191
196
  const gs = (g) => (contexts, separator, lastSeparator) => {
197
+ if (!Array.isArray(contexts)) {
198
+ debugger
199
+ throw new Error("Expected a list")
200
+ }
201
+
192
202
  let s = ''
193
203
  if (!separator) {
194
204
  separator = ' '
@@ -276,8 +286,9 @@ const processContext = (context, { objects = {}, config, logs = [] }) => {
276
286
  setupArgs(args, config, logs, hierarchy)
277
287
 
278
288
  context = semantics.apply(args, context)
279
- const generated = generators.apply(args, context)[0]
280
- const paraphrases = generators.apply(args, context, { paraphrase: true, response: false, isResponse: false })[0]
289
+ const generated = generators.apply(args, context)
290
+ const assumed = { paraphrase: true, response: false, isResponse: false }
291
+ const paraphrases = generators.apply({...args, assumed}, context, { paraphrase: true, response: false, isResponse: false })
281
292
  let responses = []
282
293
  if (context.isResponse) {
283
294
  responses = generated
@@ -447,37 +458,29 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
447
458
  continue
448
459
  }
449
460
  let assumed = { isResponse: true };
450
- const generated = contextPrime.isResponse ? config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0] : ''
461
+ const generated = contextPrime.isResponse ? config.getGenerators(json.logs).apply({...args, assumed}, contextPrime, assumed) : ''
451
462
  let generatedParenthesized = []
452
463
  if (generateParenthesized) {
453
464
  config.parenthesized = true
454
- generatedParenthesized = contextPrime.isResponse ? config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0] : ''
465
+ generatedParenthesized = contextPrime.isResponse ? config.getGenerators(json.logs).apply({...args, assumed}, contextPrime, assumed) : ''
455
466
  config.parenthesized = false
456
467
  }
457
468
  // assumed = { paraphrase: true, response: false };
458
- assumed = { paraphrase: true };
459
- args.g = (c) => config.getGenerators(json.logs).apply(args, c, assumed)
460
- args.gp = (c) => config.getGenerators(json.logs).apply(args, {...c, paraphrase: true, isResponse: false, response: false }, assumed)
461
- args.gr = (c) => config.getGenerators(json.logs).apply(args, {...c, paraphrase: false }, assumed)
462
- args.gs = gs(args.g)
463
- args.gsp = gs(args.gsp)
464
- args.gsr = gs(args.gr)
469
+ assumed = { paraphrase: true, isResponse: false, response: false };
470
+ // args.g = (c) => config.getGenerators(json.logs).apply({...args, assumed}, c, assumed)
471
+ // args.gs = gs(args.g)
465
472
  if (generateParenthesized) {
466
473
  config.parenthesized = false
467
474
  }
468
- const paraphrases = config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0]
475
+ const paraphrases = config.getGenerators(json.logs).apply({...args, assumed}, contextPrime, assumed)
469
476
  let paraphrasesParenthesized = []
470
477
  if (generateParenthesized) {
471
478
  config.parenthesized = true
472
- paraphrasesParenthesized = config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0]
479
+ paraphrasesParenthesized = config.getGenerators(json.logs).apply({...args, assumed}, contextPrime, assumed)
473
480
  config.parenthesized = false
474
481
  }
475
- args.g = (c) => config.getGenerators(json.logs).apply(args, c)
476
- args.gp = (c) => config.getGenerators(json.logs).apply(args, {...c, paraphrase: true, isResponse: false, response: false })
477
- args.gr = (c) => config.getGenerators(json.logs).apply(args, {...c, paraphrase: false })
478
- args.gs = gs(args.g)
479
- args.gsp = gs(args.gp)
480
- args.gsr = gs(args.gr)
482
+ // args.g = (c) => config.getGenerators(json.logs).apply(args, c)
483
+ // args.gs = gs(args.g)
481
484
  contextsPrime.push(contextPrime)
482
485
  generatedPrime.push(generated)
483
486
  paraphrasesPrime.push(paraphrases)
@@ -660,6 +663,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
660
663
  opChoices: []
661
664
  },
662
665
  times: 0.0,
666
+ clientSideTimes: 0.0,
663
667
  trace: '',
664
668
  contexts: [],
665
669
  generated: [],
@@ -701,8 +705,16 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
701
705
  if (json.status !== 200) {
702
706
  throw json
703
707
  } else {
708
+ let clientSideTime
709
+ if (isTest) {
710
+ start = runtime.performance.performance.now()
711
+ }
704
712
  const { contextsPrime, generatedPrime, paraphrasesPrime, paraphrasesParenthesizedPrime, generatedParenthesizedPrime, responsesPrime } =
705
713
  processContextsB({ isTest, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
714
+ if (isTest) {
715
+ end = runtime.performance.performance.now()
716
+ clientSideTime = end - start
717
+ }
706
718
  response.associations = json.associations
707
719
  response.learned_contextual_priorities = json.learned_contextual_priorities
708
720
  response.hierarchy = json.hierarchy
@@ -713,6 +725,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
713
725
  // appendNoDups(response.metadata.priorities, json.metadata.priorities)
714
726
  appendNoDups(response.metadata.opChoices, json.metadata.opChoices)
715
727
  response.times += json.times
728
+ response.clientSideTimes += clientSideTime
716
729
  response.trace = response.trace.concat(json.trace)
717
730
  response.version = json.version
718
731
  response.explain_priorities = json.explain_priorities
@@ -778,10 +791,6 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug }) =
778
791
  const test = expected.query
779
792
  // initialize in between test so state is not preserved since the test was adding without state
780
793
  config.rebuild()
781
- if (!args.dontAddAssociations) {
782
- config.addAssociationsFromTests(config.tests)
783
- }
784
- // config.addAssocationsFromTests(
785
794
  const errorHandler = (error) => {
786
795
  if (error.metadata) {
787
796
  const priorities = analyzeMetaData(expected.metadata, error.metadata)
@@ -806,10 +815,10 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug }) =
806
815
  defaultInnerProcess(config, errorHandler, result)
807
816
  }
808
817
  if (verbose) {
809
- const widths = [100, 20]
818
+ const widths = [100, 60]
810
819
  const lines = new Lines(widths)
811
820
  lines.setElement(0, 0, test)
812
- lines.setElement(0, 1, `time on server ${result.times.toFixed(2)}`)
821
+ lines.setElement(0, 1, `time on server: ${result.times.toFixed(2)} client: ${(result.clientSideTimes/1000).toFixed(2)}`)
813
822
  lines.log()
814
823
  }
815
824
  const expected_objects = sortJson(convertToStable(expected.objects), { depth: 25 })
@@ -1327,6 +1336,7 @@ const rebuildTemplate = async ({ config, target, template, errorHandler = defaul
1327
1336
  } else {
1328
1337
  delete result.load_cache_time
1329
1338
  delete result.times
1339
+ delete result.clientSideTimes
1330
1340
  delete result.memory_free_percent
1331
1341
  delete result.logs
1332
1342
  delete result.version
@@ -1366,6 +1376,28 @@ const rebuildTemplate = async ({ config, target, template, errorHandler = defaul
1366
1376
  await looper(Object.assign([], todo))
1367
1377
  }
1368
1378
 
1379
+ const checkTemplate = (template) => {
1380
+ return
1381
+ if (!template) {
1382
+ return
1383
+ }
1384
+ if (template.checks) {
1385
+ throw new Error("The 'checks' property should be in the 'test' property not the 'template' property")
1386
+ }
1387
+ }
1388
+
1389
+ const checkTest = (testConfig) => {
1390
+ if (!testConfig) {
1391
+ return
1392
+ }
1393
+ if (!testConfig.name) {
1394
+ throw new Error("The 'test' property is missing the 'name' property that contains the name of the '<km>.test.json' file")
1395
+ }
1396
+ if (!testConfig.contents) {
1397
+ throw new Error("The 'test' property is missing the 'contents' property that contains contents of the '<km>.test.json' file")
1398
+ }
1399
+ }
1400
+
1369
1401
  const knowledgeModule = async ({
1370
1402
  module: moduleFromJSFile,
1371
1403
  description,
@@ -1399,9 +1431,10 @@ const knowledgeModule = async ({
1399
1431
  if (!description) {
1400
1432
  throw new Error("'description' is a required parameter. The value should the description of the knowledge module.")
1401
1433
  }
1402
- if (!test) {
1434
+ if (!testConfig) {
1403
1435
  throw new Error("'test' is a required parameter. The value should the path to the file used to store the tests of the knowledge module and the contents of the file in the form { name: <filePath>, contexts: <json> }.")
1404
1436
  }
1437
+ checkTest(testConfig)
1405
1438
 
1406
1439
  const isProcess = require.main === moduleFromJSFile
1407
1440
 
@@ -1466,7 +1499,6 @@ const knowledgeModule = async ({
1466
1499
  parser.add_argument('--parenthesized', { action: 'store_true', help: 'Show the generated phrases with parenthesis.' })
1467
1500
  parser.add_argument('-c', '--clean', { help: 'Remove data from the test files. a === association' })
1468
1501
  parser.add_argument('-od', '--objectDiff', { action: 'store_true', help: 'When showing the objects use a colour diff' })
1469
- parser.add_argument('-daa', '--dontAddAssociations', { action: 'store_true', help: 'Do not add associations from the tests.' })
1470
1502
  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' })
1471
1503
  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.' })
1472
1504
  parser.add_argument('-sd', '--saveDeveloper', { action: 'store_true', help: 'Same as -s but the query will not show up in the info command.' })
@@ -1671,6 +1703,8 @@ const knowledgeModule = async ({
1671
1703
  }
1672
1704
  }
1673
1705
 
1706
+ checkTemplate(template)
1707
+
1674
1708
  if (template) {
1675
1709
  const needsRebuild = config.needsRebuild(template.template, template.instance, options)
1676
1710
  if (needsRebuild) {
@@ -1679,16 +1713,14 @@ const knowledgeModule = async ({
1679
1713
  config.config.rebuild = true
1680
1714
  }
1681
1715
  config.load(template.template, template.instance, { rebuild: needsRebuild })
1682
- printConfig()
1716
+ if (!args.query) {
1717
+ printConfig()
1718
+ }
1683
1719
  if (needsRebuild) {
1684
1720
  return
1685
1721
  }
1686
1722
  }
1687
1723
 
1688
- if (!args.save && !args.rebuildTemplate && !args.dontAddAssociations) {
1689
- config.addAssociationsFromTests(config.tests);
1690
- }
1691
-
1692
1724
  if (args.retrain) {
1693
1725
  config.config.retrain = true
1694
1726
  }
@@ -1696,7 +1728,6 @@ const knowledgeModule = async ({
1696
1728
  if (args.test || args.testVerbose || args.testAllVerbose || args.save) {
1697
1729
  global.transitoryMode = true
1698
1730
  }
1699
-
1700
1731
  if (!args.query && !args.test && !args.info && (args.save || args.saveDeveloper)) {
1701
1732
  global.transitoryMode = true
1702
1733
  saveTests(config, test, testConfig, args.saveDeveloper)
@@ -1718,7 +1749,6 @@ const knowledgeModule = async ({
1718
1749
  useTestConfig = config.getConfigs()[args.testModuleName].getTestConfig()
1719
1750
  useTestConfig.testModuleName = args.testModuleName
1720
1751
  test = useTestConfig.name
1721
-
1722
1752
  }
1723
1753
  runTests(config, test, { args, debug: args.debug, testConfig: useTestConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
1724
1754
  let newError = false
@@ -1767,12 +1797,16 @@ const knowledgeModule = async ({
1767
1797
  show('paraphrases', result.expected.paraphrases, result.actual.paraphrases)
1768
1798
  if (!args.testNoParenthesized) {
1769
1799
  show('paraphrases parenthesized', result.expected.paraphrasesParenthesized, result.actual.paraphrasesParenthesized)
1800
+ if (args.vimdiff) {
1801
+ vimdiff(result.actual.paraphrasesParenthesized, result.expected.paraphrasesParenthesized)
1802
+ }
1803
+ }
1804
+ /*
1770
1805
  }
1771
1806
  show('responses', result.expected.responses, result.actual.responses)
1772
1807
  if (!args.testNoParenthesized) {
1773
1808
  show('responses parenthesized', result.expected.generatedParenthesized, result.actual.generatedParenthesized)
1774
1809
  }
1775
- /*
1776
1810
  if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
1777
1811
  if (!headerShown) {
1778
1812
  console.log(' Failure')
@@ -1836,16 +1870,18 @@ const knowledgeModule = async ({
1836
1870
  }
1837
1871
  }
1838
1872
  }
1839
- if (!headerShown) {
1873
+ if (hasError) {
1874
+ if (!headerShown) {
1875
+ if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
1876
+ console.log('There are failures due to things other than paraphrases, responses and checked properties being different. They are not shown because you ran -tv or -tva which only shows difference in paraphrase and results. Usually what I do is -s and do a diff to make sure there are no other problems. If the paraphrases or results were different they would have shown here.')
1877
+ }
1878
+ }
1840
1879
  if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
1841
- console.log('There are failures due to things other than paraphrases, responses and checked properties being different. They are not shown because you ran -tv or -tva which only shows difference in paraphrase and results. Usually what I do is -s and do a diff to make sure there are no other problems. If the paraphrases or results were different they would have shown here.')
1880
+ console.log('use -v arg to write files expected.json and actual.json in the current directory for detailed comparison. Or do -s and then git diff the changes.')
1881
+ // console.log(JSON.stringify(contexts))
1882
+ console.log('**************************** ERRORS ************************')
1842
1883
  }
1843
1884
  }
1844
- if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
1845
- console.log('use -v arg to write files expected.json and actual.json in the current directory for detailed comparison. Or do -s and then git diff the changes.')
1846
- // console.log(JSON.stringify(contexts))
1847
- console.log('**************************** ERRORS ************************')
1848
- }
1849
1885
  }
1850
1886
  // const contexts = { failures: results }
1851
1887
  l(n - 1, hasError || newError)
@@ -1939,8 +1975,6 @@ const knowledgeModule = async ({
1939
1975
  errorHandler(e)
1940
1976
  }
1941
1977
  }
1942
-
1943
- config.addAssociationsFromTests(config.tests);
1944
1978
  }
1945
1979
 
1946
1980
  createConfigExport = () => {
package/package.json CHANGED
@@ -64,6 +64,6 @@
64
64
  "json-stable-stringify": "^1.0.1",
65
65
  "node-fetch": "^2.6.1"
66
66
  },
67
- "version": "7.6.0",
67
+ "version": "7.7.0",
68
68
  "license": "ISC"
69
69
  }
package/runtime.js CHANGED
@@ -14,4 +14,5 @@ module.exports = {
14
14
  jsonDiff: "Should not be called in the browser",
15
15
  sortJson: "Should not be called in the browser",
16
16
  util: "Should not be called in the browser",
17
+ performance: "Should not be called in the browser",
17
18
  }
package/src/config.js CHANGED
@@ -1137,12 +1137,6 @@ class Config {
1137
1137
  return this.config.objects.namespaced[this._uuid]
1138
1138
  }
1139
1139
 
1140
- addAssociationsFromTests(tests = []) {
1141
- for (let test of tests) {
1142
- this.addAssociations(test.associations || []);
1143
- }
1144
- }
1145
-
1146
1140
  addAssociations (associations) {
1147
1141
  for (let association of associations) {
1148
1142
  this.addAssociation(association)
package/src/flatten.js CHANGED
@@ -81,6 +81,9 @@ const flatten = (markers, value) => {
81
81
  return flattenListHelper(markers, value)
82
82
  }
83
83
 
84
+ if (value.flatten === false) {
85
+ return [[value], false]
86
+ }
84
87
  const marker = value.marker
85
88
  let properties = value
86
89
 
package/src/generators.js CHANGED
@@ -73,7 +73,8 @@ class Generator {
73
73
  return matches
74
74
  }
75
75
 
76
- apply (baseArgs, objects, g, gs, context, hierarchy, config, response, log, options = {}) {
76
+ // apply (baseArgs, objects, g, gs, context, hierarchy, config, response, log, options = {}) {
77
+ apply (baseArgs, objects, context, hierarchy, config, response, log, options = {}) {
77
78
  if (!log) {
78
79
  throw new Error('generators.apply argument log is required')
79
80
  }
@@ -103,12 +104,12 @@ class Generator {
103
104
  log,
104
105
  global:
105
106
  objects,
106
- g,
107
+ // g,
107
108
  n,
108
109
  hierarchy,
109
110
  context,
110
111
  uuid: this.uuid,
111
- gs,
112
+ // gs,
112
113
  config,
113
114
  response,
114
115
  api: this.getAPI(config),
@@ -165,136 +166,125 @@ class Generators {
165
166
  this.logs = logs
166
167
  };
167
168
 
168
- // assumed - properties added to contexts before the generators are called. For setting paraphrase property
169
- apply (args, contexts, assumed = {}, options = {}) {
169
+ // assumed - properties added to context before the generators are called. For setting paraphrase property
170
+ apply (args, context, assumed = {}, options = {}) {
171
+ if (Array.isArray(context)) {
172
+ return new Error("Expected a context not an array")
173
+ }
174
+ if (typeof context !== 'object') {
175
+ return String(context)
176
+ }
177
+
170
178
  const config = args.config
171
179
  const objects = args.objects
172
180
  const hierarchy = args.hierarchy
173
181
  const response = args.response
174
- if (Array.isArray(contexts)) {
175
- // no-op
176
- } else if (typeof contexts === 'object') {
177
- contexts = [contexts]
178
- } else {
179
- return String(contexts)
180
- }
181
182
 
182
- const contextsPrime = []
183
- for (const icontext in contexts) {
184
- let context = contexts[icontext]
185
- context = Object.assign({}, context, assumed)
186
- // let context_prime = JSON.stringify(context);
187
- let generated = context
188
- let applied = false
189
- const stack = args.calls.push()
190
- for (let igenerator = 0; igenerator < this.generators.length; ++igenerator) {
191
- const generator = this.generators[igenerator]
192
- if (generator.matches(args, objects, context, hierarchy, config, options)) {
193
- const g = (context, options) => {
194
- const r = this.apply(args, context, Object.assign({}, ((options||{}).assumed || {}), assumed), options)
195
- if (Array.isArray(r)) {
196
- return r.join(' ')
197
- } else {
198
- return r
199
- }
200
- }
201
- const log = (message) => { this.logs.push(message) }
202
- // this.logs.push(`Generators: applied ${generator.toString()}\n to\n ${JSON.stringify(context)}`)
203
- let errorMessage = 'The apply function did not return a value'
204
- try {
205
- generated= generator.apply(args, objects, g, args.gs, context, hierarchy, config, response, log)
206
- } catch( e ) {
207
- // the next if handle this
208
- generated = null
209
- e.retryCall = () => generator.apply(args, objects, g, args.gs, context, hierarchy, config, response, log)
210
- const help = 'The error has a retryCall property that will recall the function that failed.'
211
- if (e.stack && e.message) {
212
- const info = `${generator.notes ? generator.notes : ''}${generator.where ? generator.where : ''}`
213
- errorMessage = `Error applying generator '${info}. Error is ${e.toString()} stack is ${e.stack}. Generator is ${generator.toString()}. ${help}`
214
- } else if (e.error) {
215
- const info = `${generator.notes ? generator.notes : ''}${generator.where ? generator.where : ''}`
216
- errorMessage = `Error applying generator '${info}. Error is ${e.error.join()}. Generator is ${generator.toString()}. ${help}`
217
- } else {
218
- errorMessage = e.toString()
219
- }
183
+
184
+ // args = { ...args, ...args.getAssumedScoped(assumed) }
185
+ args.addAssumedScoped(args, assumed)
186
+ context = Object.assign({}, context, args.assumed)
187
+ let generated = ''
188
+ let applied = false
189
+ const stack = args.calls.push()
190
+ for (let igenerator = 0; igenerator < this.generators.length; ++igenerator) {
191
+ const generator = this.generators[igenerator]
192
+ if (generator.matches(args, objects, context, hierarchy, config, options)) {
193
+ const log = (message) => { this.logs.push(message) }
194
+ // this.logs.push(`Generators: applied ${generator.toString()}\n to\n ${JSON.stringify(context)}`)
195
+ let errorMessage = 'The apply function did not return a value'
196
+ try {
197
+ generated= generator.apply(args, objects, context, hierarchy, config, response, log)
198
+ } catch( e ) {
199
+ // the next if handle this
200
+ generated = null
201
+ e.retryCall = () => generator.apply(args, objects, context, hierarchy, config, response, log)
202
+ const help = 'The error has a retryCall property that will recall the function that failed.'
203
+ if (e.stack && e.message) {
204
+ const info = `${generator.notes ? generator.notes : ''}${generator.where ? generator.where : ''}`
205
+ errorMessage = `Error applying generator '${info}. Error is ${e.toString()} stack is ${e.stack}. Generator is ${generator.toString()}. ${help}`
206
+ } else if (e.error) {
207
+ const info = `${generator.notes ? generator.notes : ''}${generator.where ? generator.where : ''}`
208
+ errorMessage = `Error applying generator '${info}. Error is ${e.error.join()}. Generator is ${generator.toString()}. ${help}`
209
+ } else {
210
+ errorMessage = e.toString()
220
211
  }
221
- if (!generated && generated !== '') {
222
- const widths = [10, 10, 90]
223
- const lines = new Lines(widths)
224
- lines.setElement(0, 0, 'Generator')
225
- const source = `${generator.km}/#${generator.index}`
226
- lines.setElement(0, 2, `ERROR while applying (${source}) ${generator.toLabel()}`)
227
- lines.newRow()
228
- lines.setElement(0, 2, generator.toString())
229
- lines.newRow()
230
- lines.setElement(0, 1, 'TO')
231
- lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(context, { depth: 25 })))})`)
232
- lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
233
- lines.newRow()
234
- lines.setElement(0, 1, 'STACK')
235
- lines.setElement(0, 2, stack)
236
- lines.newRow()
237
- lines.setElement(0, 1, 'DEBUG')
238
- lines.setElement(0, 2, `To debug this use args.callId == '${args.calls.current()}'`)
239
- lines.newRow()
240
- lines.setElement(0, 1, 'ERROR')
241
- lines.setElement(0, 2, errorMessage)
242
- this.logs.push(lines.toString())
243
- const message = `ERROR while applying (${source}) ${generator.toLabel()}\n to\n ${JSON.stringify(context, null, 2)}.\n${errorMessage}'`
244
- // this.logs.push(message)
245
- // return [message]
246
- args.calls.pop()
247
- throw { error: [message], logs: this.logs }
248
- }
249
- if (((config || {}).config || {}).debug) {
250
- const widths = [10, 10, 90]
251
- const lines = new Lines(widths)
252
- lines.setElement(0, 0, 'Generator')
253
- if (generator.index > -1 && generator.km) {
254
- // lines.setElement(0, 2, `KM '${generator.km}' ordinal: ${generator.index}`)
255
- lines.setElement(0, 2, generator.toLabel())
256
- }
257
- lines.newRow()
258
- lines.setElement(0, 1, 'APPLIED')
212
+ }
213
+ if (!generated && generated !== '') {
214
+ const widths = [10, 10, 90]
215
+ const lines = new Lines(widths)
216
+ lines.setElement(0, 0, 'Generator')
217
+ const source = `${generator.km}/#${generator.index}`
218
+ lines.setElement(0, 2, `ERROR while applying (${source}) ${generator.toLabel()}`)
219
+ lines.newRow()
220
+ lines.setElement(0, 2, generator.toString())
221
+ lines.newRow()
222
+ lines.setElement(0, 1, 'TO')
223
+ lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(context, { depth: 25 })))})`)
224
+ lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
225
+ lines.newRow()
226
+ lines.setElement(0, 1, 'STACK')
227
+ lines.setElement(0, 2, stack)
228
+ lines.newRow()
229
+ lines.setElement(0, 1, 'DEBUG')
230
+ lines.setElement(0, 2, `To debug this use args.callId == '${args.calls.current()}'`)
231
+ lines.newRow()
232
+ lines.setElement(0, 1, 'ERROR')
233
+ lines.setElement(0, 2, errorMessage)
234
+ this.logs.push(lines.toString())
235
+ const message = `ERROR while applying (${source}) ${generator.toLabel()}\n to\n ${JSON.stringify(context, null, 2)}.\n${errorMessage}'`
236
+ // this.logs.push(message)
237
+ // return [message]
238
+ args.calls.pop()
239
+ throw { error: [message], logs: this.logs }
240
+ }
241
+ if (((config || {}).config || {}).debug) {
242
+ const widths = [10, 10, 90]
243
+ const lines = new Lines(widths)
244
+ lines.setElement(0, 0, 'Generator')
245
+ if (generator.index > -1 && generator.km) {
246
+ // lines.setElement(0, 2, `KM '${generator.km}' ordinal: ${generator.index}`)
259
247
  lines.setElement(0, 2, generator.toLabel())
260
- lines.newRow()
261
- lines.setElement(0, 2, generator.toString())
262
- lines.newRow()
263
- lines.setElement(0, 1, 'RESULT')
264
- lines.setElement(0, 2, generated)
265
- lines.newRow()
266
- lines.setElement(0, 1, 'STACK')
267
- lines.setElement(0, 2, stack)
268
- lines.newRow()
269
- lines.setElement(0, 1, 'DEBUG')
270
- lines.setElement(0, 2, `To debug this use args.callId == '${args.calls.current()}'`)
271
- lines.newRow()
272
- lines.setElement(0, 1, 'TO')
273
- lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(context, { depth: 25 })))})`)
274
- lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
275
- this.logs.push(lines.toString())
276
248
  }
277
- applied = true
278
- break
249
+ lines.newRow()
250
+ lines.setElement(0, 1, 'APPLIED')
251
+ lines.setElement(0, 2, generator.toLabel())
252
+ lines.newRow()
253
+ lines.setElement(0, 2, generator.toString())
254
+ lines.newRow()
255
+ lines.setElement(0, 1, 'RESULT')
256
+ lines.setElement(0, 2, generated)
257
+ lines.newRow()
258
+ lines.setElement(0, 1, 'STACK')
259
+ lines.setElement(0, 2, stack)
260
+ lines.newRow()
261
+ lines.setElement(0, 1, 'DEBUG')
262
+ lines.setElement(0, 2, `To debug this use args.callId == '${args.calls.current()}'`)
263
+ lines.newRow()
264
+ lines.setElement(0, 1, 'TO')
265
+ lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(context, { depth: 25 })))})`)
266
+ lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
267
+ this.logs.push(lines.toString())
279
268
  }
269
+ applied = true
270
+ break
280
271
  }
281
- args.calls.pop()
282
- if (!applied && ((config || {}).config || {}).debug) {
283
- const widths = [10, 10, 90]
284
- const lines = new Lines(widths)
285
- lines.setElement(0, 0, 'Generator')
286
- lines.setElement(0, 2, 'No generator applied')
287
- lines.newRow()
288
- lines.setElement(0, 1, 'STACK')
289
- lines.setElement(0, 2, stack)
290
- lines.newRow()
291
- lines.setElement(0, 1, 'TO')
292
- lines.setElement(0, 2, JSON.stringify(context, null, 2))
293
- this.logs.push(lines.toString())
294
- }
295
- contextsPrime.push((config || {}).parenthesized ? "(" + generated + ")" : generated)
296
272
  }
297
- return contextsPrime
273
+ args.calls.pop()
274
+ if (!applied && ((config || {}).config || {}).debug) {
275
+ const widths = [10, 10, 90]
276
+ const lines = new Lines(widths)
277
+ lines.setElement(0, 0, 'Generator')
278
+ lines.setElement(0, 2, 'No generator applied')
279
+ lines.newRow()
280
+ lines.setElement(0, 1, 'STACK')
281
+ lines.setElement(0, 2, stack)
282
+ lines.newRow()
283
+ lines.setElement(0, 1, 'TO')
284
+ lines.setElement(0, 2, JSON.stringify(context, null, 2))
285
+ this.logs.push(lines.toString())
286
+ }
287
+ return ((config || {}).parenthesized ? "(" + generated + ")" : generated)
298
288
  }
299
289
  }
300
290
 
package/src/project.js CHANGED
@@ -45,7 +45,6 @@ const project = (object, filter) => {
45
45
  if (properties.property) {
46
46
  const property = properties.property
47
47
  if (properties.isPropertyList) {
48
- debugger
49
48
  if (!Array.isArray(object[property])) {
50
49
  return projection
51
50
  }