theprogrammablemind_4wp 7.10.0-beta.0 → 7.10.0-beta.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/client.js +11 -27
  2. package/package.json +1 -1
  3. package/src/config.js +26 -2
package/client.js CHANGED
@@ -362,7 +362,7 @@ const writeTest = (fn, query, objects, generated, paraphrases, responses, contex
362
362
  }
363
363
  associations.sort()
364
364
  // tests[query] = sortJson({ paraphrases, responses, contexts, objects: convertToStable(objects), associations, metadata, config, developerTest: saveDeveloper }, { depth: 25 })
365
- results = sortJson({
365
+ const results = sortJson({
366
366
  query,
367
367
  paraphrases,
368
368
  responses,
@@ -667,7 +667,11 @@ const loadInstance = (config, instance) => {
667
667
  global.transitoryMode = transitoryMode
668
668
  }
669
669
 
670
- const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, saveDeveloper, rebuildingTemplate, testConfig, testsFN, errorHandler = defaultErrorHandler } = {}) => {
670
+ const throwErrorHandler = (error) => {
671
+ throw error
672
+ }
673
+
674
+ const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, saveDeveloper, rebuildingTemplate, testConfig, testsFN, errorHandler = throwErrorHandler } = {}) => {
671
675
  if (credentials) {
672
676
  config.server(credentials.server, credentials.key)
673
677
  }
@@ -1025,31 +1029,7 @@ const showExamples = (testFile) => {
1025
1029
  */
1026
1030
 
1027
1031
  const showInfo = (description, section, config) => {
1028
- const name = config.name
1029
- const includes = config.configs.slice(1).map((km) => km.config.name)
1030
- const visibleExamples = []
1031
- for (const test of config.tests) {
1032
- if (!test.developerTest) {
1033
- visibleExamples.push(test.query)
1034
- }
1035
- }
1036
- const templateQueries = []
1037
- if (config.instances && config.instances.length > 0) {
1038
- for (let query of config.instances.slice(-1)[0].queries) {
1039
- if (typeof query == 'string') {
1040
- templateQueries.push(query)
1041
- }
1042
- }
1043
- }
1044
- const info = { name, description, examples: visibleExamples, template: templateQueries, section, includes, demo: config.demo }
1045
- /*
1046
- if (config.instances.length > 0) {
1047
- info.template = {
1048
- base: config.instances[0].base
1049
- }
1050
- }
1051
- */
1052
- console.log(JSON.stringify(info, null, 2))
1032
+ console.log(JSON.stringify(config.getInfo(), null, 2))
1053
1033
  }
1054
1034
 
1055
1035
  const submitBugToAPI = async (subscription_id, subscription_password, config) => {
@@ -1486,6 +1466,8 @@ const knowledgeModuleImpl = async ({
1486
1466
  ...rest
1487
1467
  } = {}) => {
1488
1468
 
1469
+ template = _.cloneDeep(template)
1470
+
1489
1471
  const unknownArgs = Object.keys(rest)
1490
1472
  if (unknownArgs.length > 0) {
1491
1473
  throw new Error(`Unknown arguments to knowledgeModule: ${unknownArgs.join()}`)
@@ -1788,6 +1770,7 @@ const knowledgeModuleImpl = async ({
1788
1770
 
1789
1771
  if (template) {
1790
1772
  let needsRebuild
1773
+ console.log('template.template needs rebuild', template.template)
1791
1774
  if (args.rebuildTemplate && !args.rebuildTemplateFull) {
1792
1775
  // get the startOfChanges for the partial rebuild
1793
1776
  needsRebuild = config.needsRebuild(template.template, template.instance, { ...options, rebuild: false })
@@ -2062,6 +2045,7 @@ const knowledgeModuleImpl = async ({
2062
2045
  }
2063
2046
 
2064
2047
  if (template) {
2048
+ console.log('template.template needs rebuild', template.template)
2065
2049
  if (config.needsRebuild(template.template, template.instance, { isModule: !isProcess }).needsRebuild) {
2066
2050
  const error = `This module "${config.name}" cannot be used because the instance file needs rebuilding. Run on the command line with no arguments or the -rt argument to rebuild.`
2067
2051
  throw new Error(error)
package/package.json CHANGED
@@ -65,6 +65,6 @@
65
65
  "json-stable-stringify": "^1.0.1",
66
66
  "node-fetch": "^2.6.1"
67
67
  },
68
- "version": "7.10.0-beta.0",
68
+ "version": "7.10.0-beta.10",
69
69
  "license": "ISC"
70
70
  }
package/src/config.js CHANGED
@@ -204,6 +204,9 @@ const handleBridgeProps = (config, bridge, addFirst) => {
204
204
  ecatch(`While processing the bridge for ${bridge.id}#${bridge.level}`,
205
205
  () => {
206
206
  if (!bridge.bridge) {
207
+ if (bridge.id == 'modification') {
208
+ debugger
209
+ }
207
210
  bridge.bridge = "{ ...next(operator) }"
208
211
  }
209
212
  if (!bridge.level) {
@@ -722,6 +725,27 @@ class Config {
722
725
  return base
723
726
  }
724
727
 
728
+ getInfo () {
729
+ const name = this.name
730
+ const includes = this.configs.slice(1).map((km) => km.config.name)
731
+ const visibleExamples = []
732
+ for (const test of this.tests) {
733
+ if (!test.developerTest) {
734
+ visibleExamples.push(test.query)
735
+ }
736
+ }
737
+ const templateQueries = []
738
+ if (this.instances && this.instances.length > 0) {
739
+ for (let query of this.instances.slice(-1)[0].queries) {
740
+ if (typeof query == 'string') {
741
+ templateQueries.push(query)
742
+ }
743
+ }
744
+ }
745
+ const info = { name, description: this.description, examples: visibleExamples, template: templateQueries, includes }
746
+ return info
747
+ }
748
+
725
749
  getPseudoConfig (uuid, config) {
726
750
  return {
727
751
  description: "this is a pseudo config that has limited functionality due to being available in the initializer function context",
@@ -1082,7 +1106,8 @@ class Config {
1082
1106
  }
1083
1107
  }
1084
1108
 
1085
- if (startOfChanges) {
1109
+ const debug = true
1110
+ if (debug && startOfChanges) {
1086
1111
  console.log('templateQueries[startOfChanges]', templateQueries[startOfChanges]);
1087
1112
  console.log('instanceQueries[startOfChanges]', instanceQueries[startOfChanges]);
1088
1113
  }
@@ -1093,7 +1118,6 @@ class Config {
1093
1118
  }
1094
1119
  // const sameQueries = helpers.safeEquals(toCanonicalQueries(template.queries || []).map(helpers.updateQueries), toCanonicalQueries(instance.queries || []))
1095
1120
 
1096
- const debug = false
1097
1121
  if (debug) {
1098
1122
  if (!(instance && sameQueries && sameFragments)) {
1099
1123
  if (!sameQueries) {