theprogrammablemind 9.1.1-beta.6 → 9.1.1-beta.8
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 +12 -3
- package/package.json +3 -2
- package/src/config.js +19 -12
- package/src/configHelpers.js +4 -2
- package/src/semantics.js +9 -0
package/client.js
CHANGED
@@ -15,6 +15,7 @@ const flattens = require('./src/flatten')
|
|
15
15
|
const { appendNoDups, InitCalls, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps } = require('./src/helpers')
|
16
16
|
const runtime = require('./runtime')
|
17
17
|
const sortJson = runtime.sortJson
|
18
|
+
const debug = require('./src/debug')
|
18
19
|
|
19
20
|
const getConfig_getObjectsCheck = (config, testConfig) => {
|
20
21
|
let testConfigName = config.name
|
@@ -1181,7 +1182,7 @@ const checkTest = (testConfig) => {
|
|
1181
1182
|
const knowledgeModuleImpl = async ({
|
1182
1183
|
includes,
|
1183
1184
|
config: configStruct,
|
1184
|
-
api,
|
1185
|
+
api, apiKMs,
|
1185
1186
|
initializer,
|
1186
1187
|
terminator,
|
1187
1188
|
multiApiInitializer,
|
@@ -1237,11 +1238,12 @@ const knowledgeModuleImpl = async ({
|
|
1237
1238
|
const createConfig = async () => {
|
1238
1239
|
const config = new Config(configStruct, moduleFromJSFile, _process)
|
1239
1240
|
setupConfig(config)
|
1241
|
+
config.expect_template = !!template
|
1240
1242
|
config.setTerminator(terminator)
|
1241
1243
|
config.stop_auto_rebuild()
|
1242
1244
|
await config.add(...(includes || []))
|
1243
1245
|
if (api) {
|
1244
|
-
config.setApi(api)
|
1246
|
+
config.setApi(api, apiKMs)
|
1245
1247
|
}
|
1246
1248
|
if (multiApiInitializer) {
|
1247
1249
|
await config.setMultiApi(multiApiInitializer)
|
@@ -1324,7 +1326,6 @@ const knowledgeModuleImpl = async ({
|
|
1324
1326
|
if (args.rebuildTemplateFull) {
|
1325
1327
|
args.rebuildTemplate = true
|
1326
1328
|
}
|
1327
|
-
|
1328
1329
|
config = await createConfig()
|
1329
1330
|
|
1330
1331
|
// dont debug the load of the KM's if rebuild template is on since we want to debug the template rebuild not the load
|
@@ -1568,6 +1569,7 @@ const knowledgeModuleImpl = async ({
|
|
1568
1569
|
}
|
1569
1570
|
try {
|
1570
1571
|
await config.load(rebuildTemplate, template.template, template.instance, { rebuild: needsRebuild.needsRebuild || options.rebuild, previousResultss: needsRebuild.previousResultss, startOfChanges: needsRebuild.startOfChanges })
|
1572
|
+
config.fixtures()
|
1571
1573
|
} catch (e) {
|
1572
1574
|
console.error(`Error loading template for ${config.name}. ${e.error ? e.error : e}${e.stack ? e.stack : ''}`)
|
1573
1575
|
runtime.process.exit(-1)
|
@@ -1867,6 +1869,7 @@ const knowledgeModuleImpl = async ({
|
|
1867
1869
|
config.terminate()
|
1868
1870
|
}
|
1869
1871
|
}
|
1872
|
+
moduleFromJSFile.exports = createConfig
|
1870
1873
|
} else {
|
1871
1874
|
const initConfig = async (config) => {
|
1872
1875
|
if (template) {
|
@@ -1936,6 +1939,11 @@ const test = (name) => {
|
|
1936
1939
|
}
|
1937
1940
|
*/
|
1938
1941
|
|
1942
|
+
// for testing
|
1943
|
+
const getRequireMain = () => {
|
1944
|
+
return require.main
|
1945
|
+
}
|
1946
|
+
|
1939
1947
|
const ensureTestFile = (module, name, type) => {
|
1940
1948
|
const isProcess = require.main === module
|
1941
1949
|
if (isProcess) {
|
@@ -1957,6 +1965,7 @@ const knowledgeModule = async (...args) => {
|
|
1957
1965
|
module.exports = {
|
1958
1966
|
process: _process,
|
1959
1967
|
stableId,
|
1968
|
+
getRequireMain, // for testing
|
1960
1969
|
ensureTestFile,
|
1961
1970
|
rebuildTemplate,
|
1962
1971
|
processContext,
|
package/package.json
CHANGED
@@ -9,7 +9,8 @@
|
|
9
9
|
"eslint-plugin-node": "^11.1.0",
|
10
10
|
"eslint-plugin-promise": "^5.1.0",
|
11
11
|
"globals": "^16.0.0",
|
12
|
-
"jest": "^29.7.0"
|
12
|
+
"jest": "^29.7.0",
|
13
|
+
"argparse": "^2.0.1"
|
13
14
|
},
|
14
15
|
"scripts": {
|
15
16
|
"to:debug": "node inspect node_modules/.bin/jest --runInBand -t NEO23",
|
@@ -68,6 +69,6 @@
|
|
68
69
|
"sort-json": "^2.0.0",
|
69
70
|
"uuid": "^8.3.2"
|
70
71
|
},
|
71
|
-
"version": "9.1.1-beta.
|
72
|
+
"version": "9.1.1-beta.8",
|
72
73
|
"license": "UNLICENSED"
|
73
74
|
}
|
package/src/config.js
CHANGED
@@ -845,14 +845,6 @@ const multiApiImpl = (initializer) => {
|
|
845
845
|
}
|
846
846
|
},
|
847
847
|
|
848
|
-
/*
|
849
|
-
set objects (value) {
|
850
|
-
for (const key in Object.keys(this.apis)) {
|
851
|
-
this.apis[key].objects = value
|
852
|
-
}
|
853
|
-
},
|
854
|
-
*/
|
855
|
-
|
856
848
|
// "product1": apiInstance(testData1),
|
857
849
|
apis: {
|
858
850
|
},
|
@@ -1372,6 +1364,7 @@ class Config {
|
|
1372
1364
|
this.instances.push(instance)
|
1373
1365
|
await configHelpers.loadInstance(this, instance)
|
1374
1366
|
}
|
1367
|
+
this.expect_template = false
|
1375
1368
|
}
|
1376
1369
|
}
|
1377
1370
|
|
@@ -1952,7 +1945,7 @@ class Config {
|
|
1952
1945
|
this.resetDelta()
|
1953
1946
|
|
1954
1947
|
this.addedArgss = []
|
1955
|
-
|
1948
|
+
const isProcess = require.main === module
|
1956
1949
|
if (global.theprogrammablemind && config) {
|
1957
1950
|
if (global.theprogrammablemind.loadForTesting[config.name]) {
|
1958
1951
|
isProcess = true
|
@@ -2112,7 +2105,11 @@ class Config {
|
|
2112
2105
|
}
|
2113
2106
|
}
|
2114
2107
|
|
2115
|
-
|
2108
|
+
// constructors is a constructor
|
2109
|
+
async setApi (constructor, apiKMs) {
|
2110
|
+
if (!apiKMs) {
|
2111
|
+
apiKMs = [this.name]
|
2112
|
+
}
|
2116
2113
|
if (typeof constructor !== 'function') {
|
2117
2114
|
throw new Error(`Expected the argument to be an API constructor for ${this.name}.`)
|
2118
2115
|
}
|
@@ -2133,6 +2130,13 @@ class Config {
|
|
2133
2130
|
} else {
|
2134
2131
|
this._api = value
|
2135
2132
|
this._apiConstructor = constructor
|
2133
|
+
this._apiKMs = apiKMs
|
2134
|
+
for (const name of this._apiKMs) {
|
2135
|
+
if (this.name == name) {
|
2136
|
+
continue
|
2137
|
+
}
|
2138
|
+
this.km(name).setApi(() => this._api)
|
2139
|
+
}
|
2136
2140
|
await this.rebuild()
|
2137
2141
|
}
|
2138
2142
|
}
|
@@ -2200,10 +2204,10 @@ class Config {
|
|
2200
2204
|
// update uuid here set the uuid in the objects and add error checking
|
2201
2205
|
cp.initializerFn = this.initializerFn
|
2202
2206
|
cp.terminatorFn = this.terminatorFn
|
2203
|
-
// cp._api = _.cloneDeep(this._api)
|
2204
2207
|
if (this._apiConstructor) {
|
2205
2208
|
cp._api = this._apiConstructor(cp)
|
2206
2209
|
cp._apiConstructor = this._apiConstructor
|
2210
|
+
cp._apiKMs = this._apiKMs
|
2207
2211
|
}
|
2208
2212
|
cp._namespace = this._namespace
|
2209
2213
|
cp._eqClasses = this._eqClasses
|
@@ -2621,6 +2625,7 @@ class Config {
|
|
2621
2625
|
currentConfig: config,
|
2622
2626
|
uuid: config._uuid,
|
2623
2627
|
objects: namespacedObjects,
|
2628
|
+
globals: this.config.objects,
|
2624
2629
|
namespace,
|
2625
2630
|
api: config.api
|
2626
2631
|
}))
|
@@ -2717,7 +2722,9 @@ class Config {
|
|
2717
2722
|
this.hierarchy.edges = this.config.hierarchy
|
2718
2723
|
|
2719
2724
|
if (!this.isModule) {
|
2720
|
-
|
2725
|
+
if (this.template || !this.expect_template) {
|
2726
|
+
await this.fixtures()
|
2727
|
+
}
|
2721
2728
|
}
|
2722
2729
|
|
2723
2730
|
this.valid()
|
package/src/configHelpers.js
CHANGED
@@ -249,15 +249,17 @@ const setupContexts = (rawContexts) => {
|
|
249
249
|
let first = true
|
250
250
|
const contexts = []
|
251
251
|
contexts.push({ marker: 'controlStart', controlRemove: true })
|
252
|
+
let previous;
|
252
253
|
for (const context of rawContexts) {
|
253
254
|
if (first) {
|
254
255
|
first = false
|
255
256
|
} else {
|
256
|
-
contexts.push({ marker: 'controlBetween', controlRemove: true })
|
257
|
+
contexts.push({ marker: 'controlBetween', controlRemove: true, previous })
|
257
258
|
}
|
258
259
|
contexts.push(context)
|
260
|
+
previous = context
|
259
261
|
}
|
260
|
-
contexts.push({ marker: 'controlEnd', controlRemove: true })
|
262
|
+
contexts.push({ marker: 'controlEnd', controlRemove: true, previous })
|
261
263
|
|
262
264
|
let _index = 0
|
263
265
|
const id = (context) => {
|
package/src/semantics.js
CHANGED
@@ -183,7 +183,16 @@ class Semantics {
|
|
183
183
|
deferWasCalled = true
|
184
184
|
}
|
185
185
|
args.defer = defer
|
186
|
+
|
187
|
+
let continueWasCalled = false
|
188
|
+
const _continue = () => {
|
189
|
+
continueWasCalled = true
|
190
|
+
}
|
191
|
+
args._continue = _continue
|
186
192
|
contextPrime = await semantic.apply(args, context, s, options)
|
193
|
+
if (continueWasCalled) {
|
194
|
+
continue
|
195
|
+
}
|
187
196
|
if (deferWasCalled) {
|
188
197
|
continue
|
189
198
|
}
|