theprogrammablemind 7.5.4-beta.5 → 7.5.4-beta.7
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 +9 -2
- package/package.json +1 -1
- package/src/config.js +38 -130
- package/src/generators.js +4 -2
- package/src/semantics.js +4 -2
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
|
}
|
@@ -1662,7 +1662,14 @@ function where(goUp = 2) {
|
|
1662
1662
|
const e = new Error();
|
1663
1663
|
const regexForm1 = /\((.*):(\d+):(\d+)\)$/
|
1664
1664
|
const regexForm2 = /at (.*):(\d+):(\d+)$/
|
1665
|
-
const
|
1665
|
+
const lines = e.stack.split("\n")
|
1666
|
+
let line
|
1667
|
+
for (line of lines.slice(1)) {
|
1668
|
+
if (!(line.includes("config.js:") || line.includes("client.js:"))) {
|
1669
|
+
break;
|
1670
|
+
}
|
1671
|
+
}
|
1672
|
+
// const line = e.stack.split("\n")[goUp];
|
1666
1673
|
const match = regexForm1.exec(line) || regexForm2.exec(line);
|
1667
1674
|
if (match) {
|
1668
1675
|
return `${match[1]}:${match[2]}`
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -74,31 +74,57 @@ const handleBridgeProps = (config, bridge) => {
|
|
74
74
|
}
|
75
75
|
if (bridge.generatorp) {
|
76
76
|
config.config.generators.unshift({
|
77
|
-
where: bridge.generatorp.where || client.where(
|
77
|
+
where: bridge.generatorp.where || bridge.where || client.where(4),
|
78
78
|
match: ({context}) => bridge.id == context.marker && context.paraphrase,
|
79
79
|
apply: (args) => bridge.generatorp(args),
|
80
|
+
applyWrapped: bridge.generatorp,
|
81
|
+
property: 'generatorp',
|
80
82
|
})
|
81
83
|
}
|
82
84
|
if (bridge.generatorr) {
|
83
85
|
config.config.generators.unshift({
|
84
86
|
// TODO merge response and isResponse
|
85
|
-
where: bridge.generatorr.where || client.where(3),
|
87
|
+
where: bridge.generatorr.where || bridge.where || client.where(3),
|
86
88
|
match: ({context}) => bridge.id == context.marker && !context.paraphrase && (context.response || context.isResponse),
|
87
89
|
apply: (args) => bridge.generatorr(args),
|
90
|
+
applyWrapped: bridge.generatorr,
|
91
|
+
property: 'generatorr',
|
88
92
|
})
|
89
93
|
}
|
90
94
|
if (bridge.evaluator) {
|
91
95
|
config.config.semantics.unshift({
|
92
|
-
where: bridge.evaluator.where || client.where(3),
|
96
|
+
where: bridge.evaluator.where || bridge.where || client.where(3),
|
93
97
|
match: ({context}) => bridge.id == context.marker && context.evaluate,
|
94
98
|
apply: (args) => bridge.evaluator(args),
|
99
|
+
applyWrapped: bridge.evaluator,
|
100
|
+
property: 'evaluator',
|
95
101
|
})
|
96
102
|
}
|
97
103
|
if (bridge.semantic) {
|
98
104
|
config.config.semantics.unshift({
|
99
|
-
where: bridge.semantic.where || client.where(3),
|
105
|
+
where: bridge.semantic.where || bridge.where || client.where(3),
|
100
106
|
match: ({context}) => bridge.id == context.marker,
|
101
107
|
apply: (args) => bridge.semantic(args),
|
108
|
+
applyWrapped: bridge.semantic,
|
109
|
+
property: 'semantic',
|
110
|
+
})
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
const handleCalculatedProps = (baseConfig, moreConfig) => {
|
115
|
+
for (let bridge of moreConfig.bridges) {
|
116
|
+
const valid = [ 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generators', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
|
117
|
+
'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy', 'where' ]
|
118
|
+
helpers.validProps(valid, bridge, 'bridge')
|
119
|
+
handleBridgeProps(baseConfig, bridge)
|
120
|
+
}
|
121
|
+
if (moreConfig.operators) {
|
122
|
+
moreConfig.operators = moreConfig.operators.map((operator) => {
|
123
|
+
if (typeof operator === 'string') {
|
124
|
+
return { pattern: operator }
|
125
|
+
} else {
|
126
|
+
return operator
|
127
|
+
}
|
102
128
|
})
|
103
129
|
}
|
104
130
|
}
|
@@ -1244,133 +1270,12 @@ class Config {
|
|
1244
1270
|
if (config) {
|
1245
1271
|
config = _.cloneDeep(config)
|
1246
1272
|
this.config = config
|
1247
|
-
|
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
|
-
}
|
1273
|
+
handleCalculatedProps(this, config)
|
1360
1274
|
}
|
1361
1275
|
this.hierarchy = new Digraph(this.config.hierarchy)
|
1362
1276
|
this.initConfig = _.cloneDeep(this.config)
|
1363
1277
|
this.configs.push(new KM({ config: this.config, getCounter: (name) => this.config.getCounter(name), uuid: this._uuid }))
|
1364
1278
|
|
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
1279
|
this.setUUIDs()
|
1375
1280
|
this.initDefaults()
|
1376
1281
|
if (!this.config.objects.namespaced) {
|
@@ -2026,7 +1931,6 @@ class Config {
|
|
2026
1931
|
} else {
|
2027
1932
|
addInternals.unshift(config)
|
2028
1933
|
}
|
2029
|
-
// this.addInternal(config, true, false, false, true)
|
2030
1934
|
} else {
|
2031
1935
|
if (interleaved) {
|
2032
1936
|
addInternals.unshift(null)
|
@@ -2049,7 +1953,7 @@ class Config {
|
|
2049
1953
|
if (!interleaved) {
|
2050
1954
|
for (const config of addInternals) {
|
2051
1955
|
if (!reverseIt) {
|
2052
|
-
this.addInternal(config,
|
1956
|
+
this.addInternal(config, { includeNamespace: false, allowNameToBeNull: true })
|
2053
1957
|
} else {
|
2054
1958
|
this.addInternalR(config, true, false, false, true)
|
2055
1959
|
}
|
@@ -2201,7 +2105,7 @@ class Config {
|
|
2201
2105
|
|
2202
2106
|
this.applyNamespace(configPrime, km.namespace, km.uuid)
|
2203
2107
|
first = false
|
2204
|
-
this.addInternal(configPrime, false, true)
|
2108
|
+
this.addInternal(configPrime, { useOldVersion: false, skipObjects: true })
|
2205
2109
|
applyUUID(configPrime, km.uuid)
|
2206
2110
|
})
|
2207
2111
|
|
@@ -2491,7 +2395,7 @@ class Config {
|
|
2491
2395
|
}
|
2492
2396
|
|
2493
2397
|
// TODO get rid of useOldVersion arg
|
2494
|
-
addInternal (more, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false) {
|
2398
|
+
addInternal (more, { useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false, handleCalculatedProps : hcps = false } = {}) {
|
2495
2399
|
if (more instanceof Config) {
|
2496
2400
|
more.initialize({ force: false })
|
2497
2401
|
if (useOldVersion) {
|
@@ -2501,6 +2405,10 @@ class Config {
|
|
2501
2405
|
more = _.cloneDeep(more.initConfig)
|
2502
2406
|
}
|
2503
2407
|
}
|
2408
|
+
if (hcps) {
|
2409
|
+
handleCalculatedProps(this, more)
|
2410
|
+
applyUUID(more, this._uuid)
|
2411
|
+
}
|
2504
2412
|
for (const key of Object.keys(more)) {
|
2505
2413
|
const value = more[key]
|
2506
2414
|
// TODO remove name and description on the config bag
|
package/src/generators.js
CHANGED
@@ -6,9 +6,11 @@ class Generator {
|
|
6
6
|
// constructor ({ match, apply, uuid, index, km, priority, notes }) {
|
7
7
|
constructor (generator) {
|
8
8
|
generator = normalizeGenerator(generator)
|
9
|
-
const { match, apply, uuid, index, km, priority, where, notes, debug } = generator
|
9
|
+
const { match, apply, uuid, index, km, priority, where, notes, debug, applyWrapped, property } = generator
|
10
10
|
this.match = match
|
11
11
|
this._apply = apply
|
12
|
+
this._applyWrapped = applyWrapped
|
13
|
+
this.property = property
|
12
14
|
this.uuid = uuid
|
13
15
|
this.index = index
|
14
16
|
this.km = km
|
@@ -39,7 +41,7 @@ class Generator {
|
|
39
41
|
}
|
40
42
|
|
41
43
|
toString () {
|
42
|
-
return `Generator(${this.match}, ${this._apply})`
|
44
|
+
return `Generator(${this.match}, ${this._applyWrapped || this._apply})${this.property ? `\nsee the ${this.property} property` : ''}`
|
43
45
|
}
|
44
46
|
|
45
47
|
matches (baseArgs, objects, context, hierarchy, config, options = {}) {
|
package/src/semantics.js
CHANGED
@@ -6,9 +6,11 @@ class Semantic {
|
|
6
6
|
// constructor ({match, apply, uuid, index, km, notes}) {
|
7
7
|
constructor (semantic) {
|
8
8
|
semantic = normalizeSemantic(semantic)
|
9
|
-
const { match, apply, uuid, index, km, notes, priority, debug, where } = semantic
|
9
|
+
const { match, apply, uuid, index, km, notes, priority, debug, where, applyWrapped, property } = semantic
|
10
10
|
this.matcher = match
|
11
11
|
this._apply = apply
|
12
|
+
this._applyWrapped = applyWrapped
|
13
|
+
this.property = property
|
12
14
|
this.uuid = uuid
|
13
15
|
this.index = index
|
14
16
|
this.km = km
|
@@ -27,7 +29,7 @@ class Semantic {
|
|
27
29
|
}
|
28
30
|
|
29
31
|
toString () {
|
30
|
-
return `Semantic(${this.matcher}, ${this._apply})`
|
32
|
+
return `Semantic(${this.matcher}, ${this._applyWrapped || this._apply})${this.property ? `\nsee the ${this.property} property` : ''}`
|
31
33
|
}
|
32
34
|
|
33
35
|
getAPI (config) {
|