theprogrammablemind 7.3.9-beta.9 → 7.3.10-beta.0

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/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "tod": "node inspect node_modules/.bin/jest --runInBand -t ONE23",
16
16
  "lint:fix": "eslint \"**/*.js\" --fix",
17
17
  "lint": "eslint \"**/*.js\"",
18
- "to": "node node_modules/.bin/jest --runInBand -t NEO",
18
+ "to": "node node_modules/.bin/jest --runInBand -t ONE23",
19
19
  "test": "jest --config ./jest.config.json",
20
20
  "test:watch": "npm run test -- --watch"
21
21
  },
@@ -61,6 +61,6 @@
61
61
  "json-stable-stringify": "^1.0.1",
62
62
  "node-fetch": "^2.6.1"
63
63
  },
64
- "version": "7.3.9-beta.9",
64
+ "version": "7.3.10-beta.0",
65
65
  "license": "ISC"
66
66
  }
package/src/config.js CHANGED
@@ -1238,7 +1238,7 @@ class Config {
1238
1238
  runtime.fs.writeFileSync(fn, JSON.stringify(this.config, 0, 2))
1239
1239
  }
1240
1240
 
1241
- copy (options = {}) {
1241
+ copy (options = { callInitializers: true }) {
1242
1242
  this.valid()
1243
1243
  const cp = new Config()
1244
1244
  cp.logs = []
@@ -1257,6 +1257,7 @@ class Config {
1257
1257
  cp.isModule = this.isModule
1258
1258
  cp.initInstances = this.initInstances.slice()
1259
1259
  cp.instances = this.instances.slice()
1260
+ cp.configCounter = this.configCounter
1260
1261
 
1261
1262
  cp.initConfig = _.cloneDeep(this.initConfig)
1262
1263
  cp.defaultConfig()
@@ -1267,6 +1268,7 @@ class Config {
1267
1268
  Object.assign(cp.config.objects, _.cloneDeep(this.initConfig.objects || {}))
1268
1269
  }
1269
1270
  // cp.initializeConfigFromConfigs({ others: [], objects: cp.config.objects.namespaced, moreNames: [], ...options })
1271
+ // cp.initializeConfigFromConfigs(Object.assign({ others: [], objects: cp.config.objects.namespaced, moreNames: [] }, { callInitializers: false }))
1270
1272
  cp.initializeConfigFromConfigs(Object.assign({ others: [], objects: cp.config.objects.namespaced, moreNames: [] }, options))
1271
1273
  const map = {}
1272
1274
  for (let i = 0; i < this.configs.length; ++i) {
@@ -1274,6 +1276,9 @@ class Config {
1274
1276
  }
1275
1277
  cp.mapUUIDs(map)
1276
1278
 
1279
+ if (options.callInitializers) {
1280
+ cp.rebuild(options)
1281
+ }
1277
1282
  if (cp._api) {
1278
1283
  cp._api.objects = cp.config.objects
1279
1284
  cp._api.config = () => (cp instanceof Config) ? cp : cp.config
@@ -1290,9 +1295,6 @@ class Config {
1290
1295
  cp.config.objects.namespaced[km._uuid] = {}
1291
1296
  })
1292
1297
 
1293
- if (options.callInitializers) {
1294
- cp.rebuild(options)
1295
- }
1296
1298
  cp.valid()
1297
1299
  return cp
1298
1300
  }
@@ -1424,7 +1426,16 @@ class Config {
1424
1426
  }
1425
1427
  }
1426
1428
 
1427
- initializer (fn, { initAfterApi = false } = {}) {
1429
+ initializer (fn, options = {}) {
1430
+ if (options) {
1431
+ for (let option of Object.keys(options)) {
1432
+ const validOptions = ['initAfterApi']
1433
+ if (!['initAfterApi'].includes(option)) {
1434
+ throw `For Config.initializer, unrecognized option ${option}. The valid options are ${validOptions}`
1435
+ }
1436
+ }
1437
+ }
1438
+ const { initAfterApi = false } = options;
1428
1439
  this.wasInitialized = false
1429
1440
  this.initAfterApi = initAfterApi
1430
1441
  this.initializerFn = (args) => {
@@ -1770,7 +1781,7 @@ class Config {
1770
1781
  // initialize the configs in context
1771
1782
 
1772
1783
  if (callInitializers) {
1773
- this.configs.forEach(({ namespace, uuid, config, isSelf }) => {
1784
+ [...this.configs].reverse().forEach(({ namespace, uuid, config, isSelf }) => {
1774
1785
  if (isSelf) {
1775
1786
  config = this
1776
1787
  }
@@ -1939,7 +1950,17 @@ class Config {
1939
1950
  throw `Setting invalid property ${property}`
1940
1951
  }
1941
1952
 
1942
- if (['operators', 'bridges', 'words'].includes(property)) {
1953
+ if ('words' == property) {
1954
+ for (let word in value) {
1955
+ for (let def of value[word]) {
1956
+ if (!def['uuid']) {
1957
+ throw `All definitions for '${property}' must have the uuid property set (config.uuid). uuid is missing from ${JSON.stringify(def)} for the word '${word}'`
1958
+ }
1959
+ }
1960
+ }
1961
+ }
1962
+
1963
+ if (['operators', 'bridges'].includes(property)) {
1943
1964
  for (let def of value) {
1944
1965
  if (!def['uuid']) {
1945
1966
  throw `All definitions for '${property}' must have the uuid property set (config.uuid). uuid is missing from ${JSON.stringify(def)}`
package/src/generators.js CHANGED
@@ -171,7 +171,7 @@ class Generators {
171
171
  let context = contexts[icontext]
172
172
  context = Object.assign({}, context, assumed)
173
173
  // let context_prime = JSON.stringify(context);
174
- let contextPrime = context
174
+ let generated = context
175
175
  let applied = false
176
176
  const stack = args.calls.push()
177
177
  for (let igenerator = 0; igenerator < this.generators.length; ++igenerator) {
@@ -189,10 +189,10 @@ class Generators {
189
189
  // this.logs.push(`Generators: applied ${generator.toString()}\n to\n ${JSON.stringify(context)}`)
190
190
  let errorMessage = 'The apply function did not return a value'
191
191
  try {
192
- contextPrime = generator.apply(args, objects, g, args.gs, context, hierarchy, config, response, log)
192
+ generated= generator.apply(args, objects, g, args.gs, context, hierarchy, config, response, log)
193
193
  } catch( e ) {
194
194
  // the next if handle this
195
- contextPrime = null
195
+ generated = null
196
196
  if (e.stack && e.message) {
197
197
  errorMessage = `Error applying generator '${generator.notes}'. Error is ${e.toString()} stack is ${e.stack}. Generator is ${generator.toString()}`
198
198
  } else if (e.error) {
@@ -201,7 +201,7 @@ class Generators {
201
201
  errorMessage = e.toString()
202
202
  }
203
203
  }
204
- if (!contextPrime && contextPrime !== '') {
204
+ if (!generated && generated !== '') {
205
205
  const widths = [10, 10, 90]
206
206
  const lines = new Lines(widths)
207
207
  lines.setElement(0, 0, 'Generator')
@@ -244,7 +244,7 @@ class Generators {
244
244
  lines.setElement(0, 2, generator.toString())
245
245
  lines.newRow()
246
246
  lines.setElement(0, 1, 'RESULT')
247
- lines.setElement(0, 2, contextPrime)
247
+ lines.setElement(0, 2, generated)
248
248
  lines.newRow()
249
249
  lines.setElement(0, 1, 'STACK')
250
250
  lines.setElement(0, 2, stack)
@@ -275,7 +275,7 @@ class Generators {
275
275
  lines.setElement(0, 2, JSON.stringify(context, null, 2))
276
276
  this.logs.push(lines.toString())
277
277
  }
278
- contextsPrime.push(contextPrime)
278
+ contextsPrime.push(generated)
279
279
  }
280
280
  return contextsPrime
281
281
  }