theprogrammablemind_4wp 7.7.0-beta.9 → 7.8.0-beta.0
Sign up to get free protection for your applications and to get access to all the features.
- package/client.js +42 -6
- package/package.json +1 -1
- package/src/config.js +36 -42
- package/src/helpers.js +2 -0
package/client.js
CHANGED
@@ -30,18 +30,29 @@ const pickObjects = (testConfig, objects) => {
|
|
30
30
|
return project(objects, getConfig_getObjectsCheck(testConfig))
|
31
31
|
}
|
32
32
|
|
33
|
+
// move ask to the KM's since verbatim is called
|
33
34
|
const getAsk = (config) => (uuid) => (asks) => {
|
34
35
|
for (let ask of asks) {
|
36
|
+
let oneShot = true // default
|
37
|
+
if (ask.oneShot === false) {
|
38
|
+
oneShot = false
|
39
|
+
}
|
35
40
|
config.addSemantic({
|
36
41
|
uuid,
|
37
|
-
oneShot
|
42
|
+
oneShot,
|
38
43
|
match: (args) => ask.matchr(args),
|
39
44
|
apply: (args) => ask.applyr(args)
|
40
45
|
})
|
41
46
|
}
|
47
|
+
let oneShot = true
|
48
|
+
for (let ask of asks) {
|
49
|
+
if (ask.oneShot === false) {
|
50
|
+
oneShot = false
|
51
|
+
}
|
52
|
+
}
|
42
53
|
config.addSemantic({
|
43
54
|
uuid,
|
44
|
-
oneShot
|
55
|
+
oneShot,
|
45
56
|
match: ({context}) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
|
46
57
|
apply: (args) => {
|
47
58
|
for (let ask of asks) {
|
@@ -57,14 +68,18 @@ const getAsk = (config) => (uuid) => (asks) => {
|
|
57
68
|
}
|
58
69
|
if (matchq(args)) {
|
59
70
|
// args.context.motivationKeep = true
|
71
|
+
args.verbatim(applyq(args))
|
72
|
+
/*
|
60
73
|
args.context.verbatim = applyq(args)
|
61
74
|
args.context.isResponse = true;
|
62
75
|
delete args.context.controlRemove;
|
76
|
+
*/
|
63
77
|
args.context.controlKeepMotivation = true;
|
64
78
|
break
|
65
79
|
}
|
66
80
|
}
|
67
|
-
|
81
|
+
args.context.cascade = true
|
82
|
+
}
|
68
83
|
})
|
69
84
|
}
|
70
85
|
|
@@ -622,6 +637,15 @@ const loadInstance = (config, instance) => {
|
|
622
637
|
// config.addInternal(results, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false)
|
623
638
|
// config.addInternal(config.template.queries[i], { handleCalculatedProps: true } )
|
624
639
|
config.addInternal(instance.template.queries[i], { addFirst: true, handleCalculatedProps: true } )
|
640
|
+
} else if (results.apply) {
|
641
|
+
const objects = config.get('objects')
|
642
|
+
const args = { objects, getObjects: getObjects(objects) }
|
643
|
+
if (instance.queries) {
|
644
|
+
args.isInstance = `instance${i}`
|
645
|
+
args.instance = instance.queries[i]
|
646
|
+
}
|
647
|
+
setupArgs(args, config, config.logs, hierarchy)
|
648
|
+
results.apply(args)
|
625
649
|
} else {
|
626
650
|
if (results.skipSemantics) {
|
627
651
|
config.config.skipSemantics = results.skipSemantics
|
@@ -1326,6 +1350,15 @@ const rebuildTemplate = async ({ config, target, previousResultss, startOfChange
|
|
1326
1350
|
config.config.skipSemantics = null
|
1327
1351
|
errorHandler(error)
|
1328
1352
|
}
|
1353
|
+
} else if (typeof queryOrExtraConfig == 'function') {
|
1354
|
+
console.log('calling initialize function')
|
1355
|
+
const initFunction = queryOrExtraConfig
|
1356
|
+
const objects = config.get('objects')
|
1357
|
+
const args = { objects, getObjects: getObjects(objects) }
|
1358
|
+
setupArgs(args, config, config.logs, hierarchy)
|
1359
|
+
initFunction(args)
|
1360
|
+
accumulators[property].push({ apply: queryOrExtraConfig })
|
1361
|
+
await looper(queries)
|
1329
1362
|
} else {
|
1330
1363
|
// extra config is def from a time like operators or bridges or words etc
|
1331
1364
|
// it will just get added to the config
|
@@ -1358,8 +1391,11 @@ const rebuildTemplate = async ({ config, target, previousResultss, startOfChange
|
|
1358
1391
|
const stabilizeOutput = (template) => {
|
1359
1392
|
stabilizeAssociations(template.associations)
|
1360
1393
|
const stabilize = (results) => {
|
1361
|
-
for (let
|
1362
|
-
|
1394
|
+
for (let i = 0; i < results.length; ++i) {
|
1395
|
+
const result = results[i]
|
1396
|
+
if (result.apply) {
|
1397
|
+
result.apply = result.apply.toString()
|
1398
|
+
} else if (result.extraConfig) {
|
1363
1399
|
} else {
|
1364
1400
|
delete result.load_cache_time
|
1365
1401
|
delete result.times
|
@@ -1768,7 +1804,7 @@ const knowledgeModuleImpl = async ({
|
|
1768
1804
|
try {
|
1769
1805
|
config.load(template.template, template.instance, { rebuild: needsRebuild.needsRebuild || options.rebuild, previousResultss: needsRebuild.previousResultss, startOfChanges: needsRebuild.startOfChanges })
|
1770
1806
|
} catch( e ) {
|
1771
|
-
console.error(`Error loading template for ${config.name}. ${e.error ? e.error : e}`)
|
1807
|
+
console.error(`Error loading template for ${config.name}. ${e.error ? e.error : e}${e.stack ? e.stack : ''}`)
|
1772
1808
|
runtime.process.exit(-1)
|
1773
1809
|
}
|
1774
1810
|
if (!args.query) {
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -983,6 +983,18 @@ class Config {
|
|
983
983
|
if (typeof queryOrConfig == 'string') {
|
984
984
|
const query = queryOrConfig
|
985
985
|
return query
|
986
|
+
} else if (typeof queryOrConfig == 'function') {
|
987
|
+
if (options.isModule) {
|
988
|
+
return { apply: 'function in the browser has webpack rewrites so can not be compared' }
|
989
|
+
} else {
|
990
|
+
return { apply: queryOrConfig.toString() }
|
991
|
+
}
|
992
|
+
} else if (queryOrConfig.apply) {
|
993
|
+
if (options.isModule) {
|
994
|
+
return { apply: 'function in the browser has webpack rewrites so can not be compared' }
|
995
|
+
} else {
|
996
|
+
return { apply: queryOrConfig.apply }
|
997
|
+
}
|
986
998
|
} else {
|
987
999
|
const config = { ...queryOrConfig }
|
988
1000
|
delete config.where
|
@@ -1068,6 +1080,12 @@ class Config {
|
|
1068
1080
|
startOfChanges = iq
|
1069
1081
|
}
|
1070
1082
|
}
|
1083
|
+
|
1084
|
+
if (startOfChanges) {
|
1085
|
+
console.log('templateQueries[startOfChanges]', templateQueries[startOfChanges]);
|
1086
|
+
console.log('instanceQueries[startOfChanges]', instanceQueries[startOfChanges]);
|
1087
|
+
}
|
1088
|
+
|
1071
1089
|
// things were deleted case
|
1072
1090
|
if (templateQueries.length < instanceQueries.length) {
|
1073
1091
|
startOfChanges = instanceQueries.length
|
@@ -1138,6 +1156,13 @@ class Config {
|
|
1138
1156
|
return !properties.find( (property) => instance[property] && instance[property].length > 0 )
|
1139
1157
|
}
|
1140
1158
|
if (!isEmpty(instance)) {
|
1159
|
+
// fix up apply functions
|
1160
|
+
for (let i = 0; i < instance.resultss.length; ++i) {
|
1161
|
+
const result = instance.resultss[i]
|
1162
|
+
if (result.apply) {
|
1163
|
+
result.apply = template.queries[i]
|
1164
|
+
}
|
1165
|
+
}
|
1141
1166
|
instance.name = this.name
|
1142
1167
|
this.initInstances.push(instance)
|
1143
1168
|
this.instances.push(instance)
|
@@ -2237,8 +2262,6 @@ class Config {
|
|
2237
2262
|
const addInternals = []
|
2238
2263
|
const inits = []
|
2239
2264
|
const initAfterApis = []
|
2240
|
-
const reverseIt = true
|
2241
|
-
const interleaved = true
|
2242
2265
|
this.configs.forEach((km) => {
|
2243
2266
|
const namespace = km.namespace
|
2244
2267
|
this.config.objects.namespaced[km._uuid] = {}
|
@@ -2304,58 +2327,30 @@ class Config {
|
|
2304
2327
|
inits.unshift( () => config._api.initialize({ config: this, km: kmFn, ...args, api: config._api }) )
|
2305
2328
|
// config._api.initialize({ config, api: config._api })
|
2306
2329
|
} else {
|
2307
|
-
|
2308
|
-
inits.unshift(null)
|
2309
|
-
}
|
2330
|
+
inits.unshift(null)
|
2310
2331
|
}
|
2311
2332
|
// config._api.objects = namespacedObjects
|
2312
2333
|
// config._api.config = () => this
|
2313
2334
|
// config._api.uuid = config._uuid
|
2314
2335
|
} else {
|
2315
|
-
|
2316
|
-
inits.unshift(null)
|
2317
|
-
}
|
2336
|
+
inits.unshift(null)
|
2318
2337
|
}
|
2319
2338
|
config.setUUIDs()
|
2320
2339
|
config.applyNamespace(config.config, namespace, config.uuid)
|
2321
2340
|
if (!isSelf) {
|
2322
|
-
|
2323
|
-
addInternals.push(config)
|
2324
|
-
} else {
|
2325
|
-
addInternals.unshift(config)
|
2326
|
-
}
|
2341
|
+
addInternals.unshift(config)
|
2327
2342
|
} else {
|
2328
|
-
|
2329
|
-
addInternals.unshift(null)
|
2330
|
-
}
|
2343
|
+
addInternals.unshift(null)
|
2331
2344
|
}
|
2332
2345
|
km.valid()
|
2333
2346
|
})
|
2334
2347
|
|
2335
2348
|
const generators = this.config.generators
|
2336
2349
|
const semantics = this.config.semantics
|
2337
|
-
|
2338
|
-
|
2339
|
-
this.config.semantics = []
|
2340
|
-
}
|
2350
|
+
this.config.generators = []
|
2351
|
+
this.config.semantics = []
|
2341
2352
|
|
2342
|
-
|
2343
|
-
for (const config of addInternals) {
|
2344
|
-
if (!reverseIt) {
|
2345
|
-
this.addInternal(config, { includeNamespace: false, allowNameToBeNull: true })
|
2346
|
-
} else {
|
2347
|
-
this.addInternalR(config, true, false, false, true)
|
2348
|
-
}
|
2349
|
-
}
|
2350
|
-
// console.log('inits from config', inits)
|
2351
|
-
for (const init of inits) {
|
2352
|
-
init()
|
2353
|
-
}
|
2354
|
-
for (let init of initAfterApis) {
|
2355
|
-
init.config.initializerFn({ ...init.args, kms: this.getConfigs(), isAfterApi: true })
|
2356
|
-
}
|
2357
|
-
this.instances.forEach((instance) => client.loadInstance(this, instance))
|
2358
|
-
} else {
|
2353
|
+
{
|
2359
2354
|
const base = {
|
2360
2355
|
operators: this.config.operators,
|
2361
2356
|
bridges: this.config.bridges,
|
@@ -2371,13 +2366,16 @@ class Config {
|
|
2371
2366
|
this.config.priorities = []
|
2372
2367
|
this.config.associations = { positive: [], negative: [] }
|
2373
2368
|
this.config.words = {}
|
2374
|
-
|
2369
|
+
|
2375
2370
|
for (let i = 0; i < addInternals.length; ++i) {
|
2376
2371
|
let name;
|
2377
2372
|
if (addInternals[i]) {
|
2378
2373
|
this.addInternalR(addInternals[i], true, false, false, true)
|
2379
2374
|
name = addInternals[i].name
|
2380
2375
|
} else{
|
2376
|
+
// the ones defined in config must come after the ones in the templates
|
2377
|
+
this.config.generators = generators.concat(this.config.generators)
|
2378
|
+
this.config.semantics = semantics.concat(this.config.semantics)
|
2381
2379
|
this.addInternalR(base, true, false, false, true)
|
2382
2380
|
name = this.name
|
2383
2381
|
}
|
@@ -2398,10 +2396,6 @@ class Config {
|
|
2398
2396
|
}
|
2399
2397
|
}
|
2400
2398
|
|
2401
|
-
if (reverseIt) {
|
2402
|
-
this.config.generators = generators.concat(this.config.generators)
|
2403
|
-
this.config.semantics = semantics.concat(this.config.semantics)
|
2404
|
-
}
|
2405
2399
|
this.hierarchy.edges = this.config.hierarchy
|
2406
2400
|
this.valid()
|
2407
2401
|
this.checkBridges()
|
package/src/helpers.js
CHANGED
@@ -272,6 +272,8 @@ const mapInPlace = (list, fn) => {
|
|
272
272
|
const updateQueries = (queryOrConfig) => {
|
273
273
|
if (typeof queryOrConfig == 'string' || queryOrConfig.query) {
|
274
274
|
return queryOrConfig
|
275
|
+
} else if (typeof queryOrConfig == 'function') {
|
276
|
+
return { apply: queryOrConfig.toString() }
|
275
277
|
} else {
|
276
278
|
const config = queryOrConfig
|
277
279
|
return functionsToStrings(config)
|