theprogrammablemind_4wp 7.5.4-beta.5 → 7.5.4-beta.6

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 +1 -1
  2. package/package.json +1 -1
  3. package/src/config.js +26 -126
package/client.js CHANGED
@@ -518,7 +518,7 @@ const processInstance = (config, instance) => {
518
518
  for (const results of (instance.resultss || [])) {
519
519
  if (results.extraConfig) {
520
520
  // config.addInternal(results, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false)
521
- config.addInternal(results)
521
+ config.addInternal(results, { handleCalculatedProps: true } )
522
522
  } else {
523
523
  processContextsB({ config, hierarchy, json: results/*, generators, semantics */ })
524
524
  }
package/package.json CHANGED
@@ -62,6 +62,6 @@
62
62
  "json-stable-stringify": "^1.0.1",
63
63
  "node-fetch": "^2.6.1"
64
64
  },
65
- "version": "7.5.4-beta.5",
65
+ "version": "7.5.4-beta.6",
66
66
  "license": "ISC"
67
67
  }
package/src/config.js CHANGED
@@ -103,6 +103,24 @@ const handleBridgeProps = (config, bridge) => {
103
103
  }
104
104
  }
105
105
 
106
+ const handleCalculatedProps = (baseConfig, moreConfig) => {
107
+ for (let bridge of moreConfig.bridges) {
108
+ const valid = [ 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generators', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
109
+ 'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy' ]
110
+ helpers.validProps(valid, bridge, 'bridge')
111
+ handleBridgeProps(baseConfig, bridge)
112
+ }
113
+ if (moreConfig.operators) {
114
+ moreConfig.operators = moreConfig.operators.map((operator) => {
115
+ if (typeof operator === 'string') {
116
+ return { pattern: operator }
117
+ } else {
118
+ return operator
119
+ }
120
+ })
121
+ }
122
+ }
123
+
106
124
  if (runtime.process.env.DEBUG_HIERARCHY) {
107
125
  global.entodictonDebugHierarchy = JSON.parse(runtime.process.env.DEBUG_HIERARCHY)
108
126
  }
@@ -1244,133 +1262,12 @@ class Config {
1244
1262
  if (config) {
1245
1263
  config = _.cloneDeep(config)
1246
1264
  this.config = config
1247
- for (let bridge of this.config.bridges) {
1248
- const valid = [ 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generators', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
1249
- 'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy' ]
1250
- helpers.validProps(valid, bridge, 'bridge')
1251
- /* moved
1252
- if (!bridge.bridge) {
1253
- bridge.bridge = "{ ...next(operator) }"
1254
- }
1255
- */
1256
- handleBridgeProps(this, bridge)
1257
-
1258
- /* moved
1259
- if (!bridge.level) {
1260
- bridge.level = 0
1261
- }
1262
- */
1263
- /*
1264
- if (bridge.generator) {
1265
- this.config.generators.push({
1266
- match: ({context}) => bridge.id == context.marker,
1267
- apply: (args) => bridge.generator(args),
1268
- })
1269
- }
1270
- */
1271
- /* moved
1272
- if (bridge.children) {
1273
- for (let child of bridge.children) {
1274
- this.addHierarchy(child, bridge.id)
1275
- }
1276
- }
1277
- if (bridge.parents) {
1278
- for (let parent of bridge.parents) {
1279
- this.addHierarchy(bridge.id, parent)
1280
- }
1281
- }
1282
- if (bridge.isA) {
1283
- for (let parent of bridge.isA) {
1284
- this.addHierarchy(bridge.id, parent)
1285
- }
1286
- }
1287
- */
1288
- /* moved
1289
- if (bridge.before) {
1290
- for (let after of bridge.before) {
1291
- if (typeof after == 'string') {
1292
- after = [after, 0]
1293
- }
1294
- this.addPriorities([after, [bridge.id, bridge.level]])
1295
- }
1296
- }
1297
- if (bridge.words) {
1298
- for (let def of bridge.words) {
1299
- if (typeof def == 'string') {
1300
- this.addWordInternal(def, {"id": bridge.id, "initial": `{ value: "${def}"}` })
1301
- } else {
1302
- const word = def.word
1303
- def = { initial: JSON.stringify(def), id: bridge.id, word: undefined }
1304
- this.addWordInternal(word, def)
1305
- }
1306
- }
1307
- }
1308
- if (bridge.generator) {
1309
- this.config.generators.unshift(bridge.generator)
1310
- }
1311
- */
1312
- /* moved
1313
- if (bridge.generators) {
1314
- const generators = [...bridge.generators]
1315
- generators.reverse()
1316
- for (let generator of generators) {
1317
- this.config.generators.unshift(generator)
1318
- }
1319
- }
1320
- if (bridge.generatorp) {
1321
- this.config.generators.unshift({
1322
- where: bridge.generatorp.where || client.where(3),
1323
- match: ({context}) => bridge.id == context.marker && context.paraphrase,
1324
- apply: (args) => bridge.generatorp(args),
1325
- })
1326
- }
1327
- if (bridge.generatorr) {
1328
- this.config.generators.unshift({
1329
- // TODO merge response and isResponse
1330
- where: bridge.generatorr.where || client.where(3),
1331
- match: ({context}) => bridge.id == context.marker && !context.paraphrase && (context.response || context.isResponse),
1332
- apply: (args) => bridge.generatorr(args),
1333
- })
1334
- }
1335
- if (bridge.evaluator) {
1336
- this.config.semantics.unshift({
1337
- where: bridge.evaluator.where || client.where(3),
1338
- match: ({context}) => bridge.id == context.marker && context.evaluate,
1339
- apply: (args) => bridge.evaluator(args),
1340
- })
1341
- }
1342
- if (bridge.semantic) {
1343
- this.config.semantics.unshift({
1344
- where: bridge.semantic.where || client.where(3),
1345
- match: ({context}) => bridge.id == context.marker,
1346
- apply: (args) => bridge.semantic(args),
1347
- })
1348
- }
1349
- */
1350
- }
1351
- if (config.operators) {
1352
- config.operators = config.operators.map((operator) => {
1353
- if (typeof operator === 'string') {
1354
- return { pattern: operator }
1355
- } else {
1356
- return operator
1357
- }
1358
- })
1359
- }
1265
+ handleCalculatedProps(this, config)
1360
1266
  }
1361
1267
  this.hierarchy = new Digraph(this.config.hierarchy)
1362
1268
  this.initConfig = _.cloneDeep(this.config)
1363
1269
  this.configs.push(new KM({ config: this.config, getCounter: (name) => this.config.getCounter(name), uuid: this._uuid }))
1364
1270
 
1365
- /*
1366
- if (config) {
1367
- this.configs.push(new KM({config, isSelf: true}))
1368
- this.addInternal(Object.assign({}, config), false)
1369
- } else {
1370
- this.configs.push( new KM({config: this.config, isSelf: true}) )
1371
- }
1372
- */
1373
-
1374
1271
  this.setUUIDs()
1375
1272
  this.initDefaults()
1376
1273
  if (!this.config.objects.namespaced) {
@@ -2026,7 +1923,6 @@ class Config {
2026
1923
  } else {
2027
1924
  addInternals.unshift(config)
2028
1925
  }
2029
- // this.addInternal(config, true, false, false, true)
2030
1926
  } else {
2031
1927
  if (interleaved) {
2032
1928
  addInternals.unshift(null)
@@ -2049,7 +1945,7 @@ class Config {
2049
1945
  if (!interleaved) {
2050
1946
  for (const config of addInternals) {
2051
1947
  if (!reverseIt) {
2052
- this.addInternal(config, true, false, false, true)
1948
+ this.addInternal(config, { includeNamespace: false, allowNameToBeNull: true })
2053
1949
  } else {
2054
1950
  this.addInternalR(config, true, false, false, true)
2055
1951
  }
@@ -2201,7 +2097,7 @@ class Config {
2201
2097
 
2202
2098
  this.applyNamespace(configPrime, km.namespace, km.uuid)
2203
2099
  first = false
2204
- this.addInternal(configPrime, false, true)
2100
+ this.addInternal(configPrime, { useOldVersion: false, skipObjects: true })
2205
2101
  applyUUID(configPrime, km.uuid)
2206
2102
  })
2207
2103
 
@@ -2491,7 +2387,7 @@ class Config {
2491
2387
  }
2492
2388
 
2493
2389
  // TODO get rid of useOldVersion arg
2494
- addInternal (more, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false) {
2390
+ addInternal (more, { useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false, handleCalculatedProps : hcps = false } = {}) {
2495
2391
  if (more instanceof Config) {
2496
2392
  more.initialize({ force: false })
2497
2393
  if (useOldVersion) {
@@ -2501,6 +2397,10 @@ class Config {
2501
2397
  more = _.cloneDeep(more.initConfig)
2502
2398
  }
2503
2399
  }
2400
+ if (hcps) {
2401
+ handleCalculatedProps(this, more)
2402
+ applyUUID(more, this._uuid)
2403
+ }
2504
2404
  for (const key of Object.keys(more)) {
2505
2405
  const value = more[key]
2506
2406
  // TODO remove name and description on the config bag