theprogrammablemind_4wp 8.0.0-beta.20 → 8.0.0-beta.21
Sign up to get free protection for your applications and to get access to all the features.
- package/client.js +17 -22
- package/package.json +1 -1
- package/src/config.js +59 -135
- package/src/semantics.js +2 -2
package/client.js
CHANGED
@@ -447,7 +447,7 @@ const setupContexts = (rawContexts) => {
|
|
447
447
|
return contexts
|
448
448
|
}
|
449
449
|
|
450
|
-
const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, rebuildingTemplate, isInstance, instance, query, data, retries, url, commandLineArgs }) => {
|
450
|
+
const processContextsB = async ({ config, hierarchy, semantics, generators, json, isTest, rebuildingTemplate, isInstance, instance, query, data, retries, url, commandLineArgs }) => {
|
451
451
|
// TODO fix this name to contextsPrime
|
452
452
|
const contextsPrime = []
|
453
453
|
const generatedPrime = []
|
@@ -634,7 +634,7 @@ const setupProcessB = ({ config, initializer, allowDelta = false } = {}) => {
|
|
634
634
|
}
|
635
635
|
|
636
636
|
// instance template loadTemplate
|
637
|
-
const loadInstance = (config, instance) => {
|
637
|
+
const loadInstance = async (config, instance) => {
|
638
638
|
const transitoryMode = global.transitoryMode
|
639
639
|
global.transitoryMode = false
|
640
640
|
|
@@ -676,7 +676,7 @@ const loadInstance = (config, instance) => {
|
|
676
676
|
const args = { config, hierarchy, json: results, commandLineArgs: {} }
|
677
677
|
args.isInstance = `instance${i}`
|
678
678
|
args.instance = ''
|
679
|
-
processContextsB(args)
|
679
|
+
await processContextsB(args)
|
680
680
|
if (results.skipSemantics) {
|
681
681
|
config.config.skipSemantics = null
|
682
682
|
}
|
@@ -701,7 +701,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
701
701
|
// ensure same start state
|
702
702
|
try {
|
703
703
|
if (writeTests) {
|
704
|
-
config.rebuild()
|
704
|
+
await config.rebuild()
|
705
705
|
const objects = getObjects(config.config.objects)(config.uuid)
|
706
706
|
}
|
707
707
|
} catch (error) {
|
@@ -773,7 +773,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
773
773
|
start = runtime.performance.performance.now()
|
774
774
|
}
|
775
775
|
const { contextsPrime, generatedPrime, paraphrasesPrime, paraphrasesParenthesizedPrime, generatedParenthesizedPrime, responsesPrime } =
|
776
|
-
processContextsB({ isTest, rebuildingTemplate, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
|
776
|
+
await processContextsB({ isTest, rebuildingTemplate, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
|
777
777
|
if (isTest) {
|
778
778
|
end = runtime.performance.performance.now()
|
779
779
|
clientSideTime = end - start
|
@@ -870,7 +870,7 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug }) =
|
|
870
870
|
return
|
871
871
|
}
|
872
872
|
// initialize in between test so state is not preserved since the test was adding without state
|
873
|
-
config.rebuild()
|
873
|
+
await config.rebuild()
|
874
874
|
const errorHandler = (error) => {
|
875
875
|
if (error.metadata) {
|
876
876
|
const priorities = analyzeMetaData(expected.metadata, error.metadata)
|
@@ -1016,7 +1016,7 @@ const runTests = async (config, testFile, juicyBits) => {
|
|
1016
1016
|
}
|
1017
1017
|
|
1018
1018
|
const saveTest = async (testFile, config, test, expected, testConfig, saveDeveloper) => {
|
1019
|
-
config.rebuild()
|
1019
|
+
await config.rebuild()
|
1020
1020
|
const objects = getObjects(config.config.objects)(config.uuid)
|
1021
1021
|
console.log(test)
|
1022
1022
|
const result = await _process(config, test, { isTest: true })
|
@@ -1037,11 +1037,11 @@ const saveTestsHelper = async (testFile, config, tests, todo, testConfig, saveDe
|
|
1037
1037
|
return
|
1038
1038
|
}
|
1039
1039
|
const test = todo.pop()
|
1040
|
-
config.rebuild()
|
1040
|
+
await config.rebuild()
|
1041
1041
|
const result = await saveTest(testFile, config, test, tests[test], testConfig, saveDeveloper)
|
1042
1042
|
// initialize in between test so state is not preserved since the test was adding without state
|
1043
1043
|
// config.initialize({force: true})
|
1044
|
-
config.rebuild()
|
1044
|
+
await config.rebuild()
|
1045
1045
|
return saveTestsHelper(testFile, config, tests, todo, testConfig, saveDeveloper)
|
1046
1046
|
}
|
1047
1047
|
|
@@ -1360,7 +1360,7 @@ const rebuildTemplate = async ({ config, target, previousResultss, startOfChange
|
|
1360
1360
|
if (previousResults && previousResults.query == query.query) {
|
1361
1361
|
results = previousResults
|
1362
1362
|
prMessage = ' Using previous results. use -rtf for a hard rebuild of everything on the server side.'
|
1363
|
-
loadInstance(config, { resultss: [results] })
|
1363
|
+
await loadInstance(config, { resultss: [results] })
|
1364
1364
|
} else {
|
1365
1365
|
results = await _process(config, query.query, { initializer, rebuildingTemplate: true })
|
1366
1366
|
}
|
@@ -1632,7 +1632,7 @@ const knowledgeModuleImpl = async ({
|
|
1632
1632
|
global.pauseDebugging = true
|
1633
1633
|
}
|
1634
1634
|
|
1635
|
-
const config = createConfig()
|
1635
|
+
const config = await createConfig()
|
1636
1636
|
setupConfig(config)
|
1637
1637
|
processResults = processResults({ config, errorHandler })
|
1638
1638
|
|
@@ -1864,7 +1864,7 @@ const knowledgeModuleImpl = async ({
|
|
1864
1864
|
config.config.rebuild = true
|
1865
1865
|
}
|
1866
1866
|
try {
|
1867
|
-
config.load(template.template, template.instance, { rebuild: needsRebuild.needsRebuild || options.rebuild, previousResultss: needsRebuild.previousResultss, startOfChanges: needsRebuild.startOfChanges })
|
1867
|
+
await config.load(template.template, template.instance, { rebuild: needsRebuild.needsRebuild || options.rebuild, previousResultss: needsRebuild.previousResultss, startOfChanges: needsRebuild.startOfChanges })
|
1868
1868
|
} catch (e) {
|
1869
1869
|
console.error(`Error loading template for ${config.name}. ${e.error ? e.error : e}${e.stack ? e.stack : ''}`)
|
1870
1870
|
runtime.process.exit(-1)
|
@@ -2109,7 +2109,7 @@ const knowledgeModuleImpl = async ({
|
|
2109
2109
|
}
|
2110
2110
|
printConfig()
|
2111
2111
|
} else {
|
2112
|
-
const initConfig = (config) => {
|
2112
|
+
const initConfig = async (config) => {
|
2113
2113
|
if (template) {
|
2114
2114
|
if (config.needsRebuild(template.template, template.instance, { isModule: !isProcess }).needsRebuild) {
|
2115
2115
|
const error = `This module "${config.name}" cannot be used because the instance file needs rebuilding. Run on the command line with no arguments or the -rt argument to rebuild.`
|
@@ -2144,24 +2144,19 @@ const knowledgeModuleImpl = async ({
|
|
2144
2144
|
|
2145
2145
|
if (template) {
|
2146
2146
|
try {
|
2147
|
-
config.load(template.template, template.instance)
|
2147
|
+
await config.load(template.template, template.instance)
|
2148
2148
|
} catch (e) {
|
2149
2149
|
errorHandler(e)
|
2150
2150
|
}
|
2151
2151
|
}
|
2152
2152
|
}
|
2153
2153
|
|
2154
|
-
createConfigExport = (
|
2154
|
+
createConfigExport = async () => {
|
2155
2155
|
if (createConfig.cached) {
|
2156
2156
|
return createConfig.cached
|
2157
2157
|
}
|
2158
|
-
const config = createConfig(
|
2159
|
-
|
2160
|
-
config.stop_auto_rebuild()
|
2161
|
-
additionalConfig(config)
|
2162
|
-
config.restart_auto_rebuild()
|
2163
|
-
}
|
2164
|
-
initConfig(config)
|
2158
|
+
const config = await createConfig()
|
2159
|
+
await initConfig(config)
|
2165
2160
|
// config.rebuild({ isModule: true })
|
2166
2161
|
createConfig.cached = config
|
2167
2162
|
return createConfig.cached
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -564,7 +564,7 @@ function isLetter (char) {
|
|
564
564
|
}
|
565
565
|
*/
|
566
566
|
|
567
|
-
function configDup (config, options) {
|
567
|
+
async function configDup (config, options) {
|
568
568
|
if (config instanceof Config) {
|
569
569
|
return config.copy(options)
|
570
570
|
}
|
@@ -704,9 +704,9 @@ class KM {
|
|
704
704
|
return true
|
705
705
|
}
|
706
706
|
|
707
|
-
copy2 (options) {
|
707
|
+
async copy2 (options) {
|
708
708
|
// greg -> add a flag to say don't init the api's
|
709
|
-
const config = configDup(this._config, options)
|
709
|
+
const config = await configDup(this._config, options)
|
710
710
|
const km = new KM({
|
711
711
|
config,
|
712
712
|
getCounter: options.getCounter,
|
@@ -718,10 +718,10 @@ class KM {
|
|
718
718
|
return km // copy2()
|
719
719
|
}
|
720
720
|
|
721
|
-
copy () {
|
721
|
+
async copy () {
|
722
722
|
const km = new KM({
|
723
723
|
name: this._name,
|
724
|
-
config: configDup(this._config),
|
724
|
+
config: await configDup(this._config),
|
725
725
|
// _uuid: uuidv4(),
|
726
726
|
_uuid: this._config.getCounter(this._config._name),
|
727
727
|
getCounter: (name) => this._config.getCounter(name),
|
@@ -773,7 +773,7 @@ const multiApiImpl = (initializer) => {
|
|
773
773
|
multiApi: true,
|
774
774
|
|
775
775
|
// multi functions
|
776
|
-
add: (config, multiApi, api) => {
|
776
|
+
add: async (config, multiApi, api) => {
|
777
777
|
initializer(config, api)
|
778
778
|
const name = api.getName()
|
779
779
|
multiApi.apis[name] = api
|
@@ -811,17 +811,6 @@ class Config {
|
|
811
811
|
return config_toServer(config)
|
812
812
|
}
|
813
813
|
|
814
|
-
base () {
|
815
|
-
const base = new Config()
|
816
|
-
for (const km of this.configs.reverse()) {
|
817
|
-
if (km.isSelf) {
|
818
|
-
continue
|
819
|
-
}
|
820
|
-
base.add(km.config)
|
821
|
-
}
|
822
|
-
return base
|
823
|
-
}
|
824
|
-
|
825
814
|
getInfo () {
|
826
815
|
const name = this.name
|
827
816
|
const includes = this.configs.slice(1).map((km) => km.config.name)
|
@@ -1237,7 +1226,7 @@ class Config {
|
|
1237
1226
|
}
|
1238
1227
|
|
1239
1228
|
// loadTemplate
|
1240
|
-
load (template, instance, options = { rebuild: false, previousResultss: undefined, startOfChanges: undefined }) {
|
1229
|
+
async load (template, instance, options = { rebuild: false, previousResultss: undefined, startOfChanges: undefined }) {
|
1241
1230
|
this.validifyTemplate(template)
|
1242
1231
|
instance.template = template
|
1243
1232
|
this.logs.push(`loading template for ${this.name}`)
|
@@ -1270,7 +1259,7 @@ class Config {
|
|
1270
1259
|
instance.name = this.name
|
1271
1260
|
this.initInstances.push(instance)
|
1272
1261
|
this.instances.push(instance)
|
1273
|
-
client.loadInstance(this, instance)
|
1262
|
+
await client.loadInstance(this, instance)
|
1274
1263
|
}
|
1275
1264
|
}
|
1276
1265
|
}
|
@@ -1629,10 +1618,6 @@ class Config {
|
|
1629
1618
|
return params
|
1630
1619
|
}
|
1631
1620
|
|
1632
|
-
processContexts (contexts, params) {
|
1633
|
-
client.processContexts(contexts, this.getParams())
|
1634
|
-
}
|
1635
|
-
|
1636
1621
|
processContext (context) {
|
1637
1622
|
return client.processContext(context, this.getParams())
|
1638
1623
|
}
|
@@ -1882,9 +1867,9 @@ class Config {
|
|
1882
1867
|
this._stop_auto_rebuild = true
|
1883
1868
|
}
|
1884
1869
|
|
1885
|
-
restart_auto_rebuild() {
|
1870
|
+
async restart_auto_rebuild() {
|
1886
1871
|
this._stop_auto_rebuild = false
|
1887
|
-
this.rebuild()
|
1872
|
+
await this.rebuild()
|
1888
1873
|
}
|
1889
1874
|
|
1890
1875
|
getAddedArgs (args) {
|
@@ -1903,8 +1888,8 @@ class Config {
|
|
1903
1888
|
}
|
1904
1889
|
}
|
1905
1890
|
|
1906
|
-
|
1907
|
-
this.
|
1891
|
+
async setMultiApi (initializer) {
|
1892
|
+
await this.setApi(multiApiImpl(initializer))
|
1908
1893
|
}
|
1909
1894
|
|
1910
1895
|
get multiApi () {
|
@@ -1952,31 +1937,26 @@ class Config {
|
|
1952
1937
|
}
|
1953
1938
|
}
|
1954
1939
|
|
1955
|
-
addAPI (api) {
|
1940
|
+
async addAPI (api) {
|
1941
|
+
// console.trace()
|
1942
|
+
// throw "addAPI"
|
1956
1943
|
if (this._api && this._api.multiApi) {
|
1957
|
-
this._api.add(this, this._api, api)
|
1944
|
+
await this._api.add(this, this._api, api)
|
1958
1945
|
} else {
|
1959
1946
|
throw new Error('Can only add apis to a multi-api')
|
1960
1947
|
}
|
1961
1948
|
}
|
1962
1949
|
|
1963
|
-
|
1950
|
+
async setApi (value) {
|
1964
1951
|
if (!value.initialize) {
|
1965
1952
|
throw new Error(`Expected the API to have an initialize function for ${this.name}.`)
|
1966
1953
|
}
|
1967
1954
|
|
1968
1955
|
if (this._api && this._api.multiApi) {
|
1969
|
-
this._api.add(this, this._api, value)
|
1956
|
+
await this._api.add(this, this._api, value)
|
1970
1957
|
} else {
|
1971
1958
|
this._api = _.cloneDeep(value)
|
1972
|
-
|
1973
|
-
if (this._api) {
|
1974
|
-
// this._api.objects = this.config.objects
|
1975
|
-
// this._api.config = () => this
|
1976
|
-
// this._api.uuid = this._uuid
|
1977
|
-
}
|
1978
|
-
*/
|
1979
|
-
this.rebuild()
|
1959
|
+
await this.rebuild()
|
1980
1960
|
}
|
1981
1961
|
}
|
1982
1962
|
|
@@ -1996,7 +1976,7 @@ class Config {
|
|
1996
1976
|
}
|
1997
1977
|
|
1998
1978
|
// remove all added modules and initialize with the init config
|
1999
|
-
resetToOne () {
|
1979
|
+
async resetToOne () {
|
2000
1980
|
/*
|
2001
1981
|
this.config = _.cloneDeep(this.initConfig)
|
2002
1982
|
this.configs = [this.configs[0]]
|
@@ -2005,11 +1985,8 @@ class Config {
|
|
2005
1985
|
*/
|
2006
1986
|
this.configs = [this.configs[0]]
|
2007
1987
|
this.defaultConfig()
|
2008
|
-
|
2009
|
-
|
2010
|
-
Object.assign(this.config.objects, _.cloneDeep(this.initConfig.objects || {}))
|
2011
|
-
}
|
2012
|
-
this.initializeConfigFromConfigs({ others: [], objects: this.config.objects.namespaced, moreNames: [], callInitializers: false })
|
1988
|
+
Object.assign(this.config.objects, _.cloneDeep(this.initConfig.objects || {}))
|
1989
|
+
await this.initializeConfigFromConfigs({ others: [], objects: this.config.objects.namespaced, moreNames: [], callInitializers: false })
|
2013
1990
|
const map = {}
|
2014
1991
|
for (let i = 0; i < this.configs.length; ++i) {
|
2015
1992
|
map[this.configs[i].uuid] = this.configs[i].uuid
|
@@ -2031,17 +2008,18 @@ class Config {
|
|
2031
2008
|
runtime.fs.writeFileSync(fn, JSON.stringify(this.config, 0, 2))
|
2032
2009
|
}
|
2033
2010
|
|
2034
|
-
copy (options = { callInitializers: true }) {
|
2035
|
-
}
|
2036
|
-
|
2037
|
-
copy (options = { callInitializers: true }) {
|
2011
|
+
async copy (options = { callInitializers: true }) {
|
2038
2012
|
this.valid()
|
2039
2013
|
const cp = new Config()
|
2040
2014
|
cp.logs = []
|
2041
2015
|
cp.maxDepth = this.maxDepth
|
2042
2016
|
cp.debugLoops = this.debugLoops
|
2043
2017
|
cp.transitoryMode = this.transitoryMode
|
2044
|
-
cp.configs = this.configs.map((km) => km.copy2(Object.assign({}, options, { getCounter: (name) => cp.getCounter(name), callInitializers: false })))
|
2018
|
+
// cp.configs = this.configs.map((km) => await km.copy2(Object.assign({}, options, { getCounter: (name) => cp.getCounter(name), callInitializers: false })))
|
2019
|
+
cp.configs = []
|
2020
|
+
for (const km of this.configs) {
|
2021
|
+
cp.configs.push(await km.copy2(Object.assign({}, options, { getCounter: (name) => cp.getCounter(name), callInitializers: false })))
|
2022
|
+
}
|
2045
2023
|
cp._uuid = cp.configs[0]._uuid
|
2046
2024
|
// update uuid here set the uuid in the objects and add error checking
|
2047
2025
|
cp.initializerFn = this.initializerFn
|
@@ -2062,13 +2040,8 @@ class Config {
|
|
2062
2040
|
cp.defaultConfig()
|
2063
2041
|
// cp.wasInitialized = false; // since default config GREG
|
2064
2042
|
cp.resetWasInitialized()
|
2065
|
-
|
2066
|
-
|
2067
|
-
Object.assign(cp.config.objects, _.cloneDeep(this.initConfig.objects || {}))
|
2068
|
-
}
|
2069
|
-
// cp.initializeConfigFromConfigs({ others: [], objects: cp.config.objects.namespaced, moreNames: [], ...options })
|
2070
|
-
// cp.initializeConfigFromConfigs(Object.assign({ others: [], objects: cp.config.objects.namespaced, moreNames: [] }, { callInitializers: false }))
|
2071
|
-
cp.initializeConfigFromConfigs(Object.assign({ others: [], objects: cp.config.objects.namespaced, moreNames: [] }, options))
|
2043
|
+
Object.assign(cp.config.objects, _.cloneDeep(this.initConfig.objects || {}))
|
2044
|
+
await cp.initializeConfigFromConfigs(Object.assign({ others: [], objects: cp.config.objects.namespaced, moreNames: [] }, options))
|
2072
2045
|
const map = {}
|
2073
2046
|
for (let i = 0; i < this.configs.length; ++i) {
|
2074
2047
|
map[this.configs[i].uuid] = cp.configs[i].uuid
|
@@ -2079,33 +2052,16 @@ class Config {
|
|
2079
2052
|
// debugger
|
2080
2053
|
}
|
2081
2054
|
if (options.callInitializers) {
|
2082
|
-
cp.rebuild(options)
|
2055
|
+
await cp.rebuild(options) // in copy
|
2083
2056
|
} else {
|
2084
|
-
// this mess is for duplicate into a KM after resetToOne was called
|
2085
|
-
/*
|
2086
|
-
if (cp._api) {
|
2087
|
-
// cp._api.objects = cp.config.objects
|
2088
|
-
// cp._api.config = () => (cp instanceof Config) ? cp : cp.config
|
2089
|
-
// cp._api.uuid = cp._uuid
|
2090
|
-
}
|
2091
|
-
*/
|
2092
|
-
|
2093
2057
|
if (!cp.config.objects) {
|
2094
2058
|
cp.config.objects = { namespaced: {} }
|
2095
2059
|
} else if (!cp.config.objects.namespaced) {
|
2096
2060
|
cp.config.objects.namespaced = {}
|
2097
2061
|
}
|
2098
2062
|
cp.configs.forEach((km) => {
|
2099
|
-
// const namespace = km.namespace
|
2100
2063
|
cp.config.objects.namespaced[km._uuid] = {}
|
2101
2064
|
})
|
2102
|
-
/*
|
2103
|
-
if (cp._uuid == 'concept2') {
|
2104
|
-
if (!cp.api.objects.defaultTypesForHierarchy) {
|
2105
|
-
debugger
|
2106
|
-
}
|
2107
|
-
}
|
2108
|
-
*/
|
2109
2065
|
}
|
2110
2066
|
cp.valid()
|
2111
2067
|
return cp
|
@@ -2229,41 +2185,7 @@ class Config {
|
|
2229
2185
|
}
|
2230
2186
|
}
|
2231
2187
|
|
2232
|
-
|
2233
|
-
// [...this.configs].reverse().forEach(({ config, namespace, uuid }) => {
|
2234
|
-
[...this.configs].reverse().forEach(({ config, namespace, uuid }) => {
|
2235
|
-
/*
|
2236
|
-
let objects = this.get('objects')
|
2237
|
-
if (namespace) {
|
2238
|
-
objects = {}
|
2239
|
-
this.get('objects')['namespaced'][namespace] = objects
|
2240
|
-
}
|
2241
|
-
*/
|
2242
|
-
const objects = {}
|
2243
|
-
if (config instanceof Config) {
|
2244
|
-
this.get('objects').namespaced[config._uuid] = objects
|
2245
|
-
/*
|
2246
|
-
if (config._api) {
|
2247
|
-
// config._api.objects = objects
|
2248
|
-
// config._api.config = () => this
|
2249
|
-
}
|
2250
|
-
*/
|
2251
|
-
config.initializerFn(setupInitializerFNArgs(this, { testConfig: config, currentConfig: config, objects, namespace, uuid }))
|
2252
|
-
} else {
|
2253
|
-
this.get('objects').namespaced[this._uuid] = objects
|
2254
|
-
/*
|
2255
|
-
if (config._api) {
|
2256
|
-
// config._api.objects = objects
|
2257
|
-
// config._api.config = () => this
|
2258
|
-
}
|
2259
|
-
*/
|
2260
|
-
this.initializerFn(setupInitializerFNArgs(this, { testConfig: this, currentConfig: this, objects, namespace, uuid }))
|
2261
|
-
}
|
2262
|
-
})
|
2263
|
-
this.instances.forEach((instance) => client.loadInstance(this, instance))
|
2264
|
-
}
|
2265
|
-
|
2266
|
-
initialize ({ force = true } = {}) {
|
2188
|
+
initialize23 ({ force = true } = {}) {
|
2267
2189
|
if (force || !this.wasInitialized) {
|
2268
2190
|
const objects = this.config.objects.namespaced[this._uuid]
|
2269
2191
|
this.initializerFn(setupInitializerFNArgs(this, { testConfig: this, currentConfig: this, objects, uuid: this._uuid, namespace: '' }))
|
@@ -2271,7 +2193,7 @@ class Config {
|
|
2271
2193
|
}
|
2272
2194
|
}
|
2273
2195
|
|
2274
|
-
initializer (fn, options = {}) {
|
2196
|
+
async initializer (fn, options = {}) {
|
2275
2197
|
if (options) {
|
2276
2198
|
for (const option of Object.keys(options)) {
|
2277
2199
|
const validOptions = []
|
@@ -2293,8 +2215,7 @@ class Config {
|
|
2293
2215
|
currentConfig.wasInitialized = true
|
2294
2216
|
global.transitoryMode = transitoryMode
|
2295
2217
|
}
|
2296
|
-
|
2297
|
-
this.rebuild()
|
2218
|
+
await this.rebuild()
|
2298
2219
|
}
|
2299
2220
|
|
2300
2221
|
nsToString (id) {
|
@@ -2440,7 +2361,7 @@ class Config {
|
|
2440
2361
|
}
|
2441
2362
|
|
2442
2363
|
// rebuild ({ isModule: mainIsModule = false } = {}) {
|
2443
|
-
rebuild ({ isModule: mainIsModule } = {}) {
|
2364
|
+
async rebuild ({ isModule: mainIsModule } = {}) {
|
2444
2365
|
if (this._stop_auto_rebuild) {
|
2445
2366
|
return
|
2446
2367
|
}
|
@@ -2608,7 +2529,7 @@ class Config {
|
|
2608
2529
|
}
|
2609
2530
|
const instance = this.instances.find((instance) => instance.name == name)
|
2610
2531
|
if (instance) {
|
2611
|
-
client.loadInstance(this, instance)
|
2532
|
+
await client.loadInstance(this, instance)
|
2612
2533
|
}
|
2613
2534
|
this.hierarchy.edges = this.config.hierarchy
|
2614
2535
|
}
|
@@ -2628,6 +2549,7 @@ class Config {
|
|
2628
2549
|
// if undefined namespace applies to first loaded config
|
2629
2550
|
// if list of name then namespace applied only to those configs
|
2630
2551
|
// if true then namespace applies to all loaded configs
|
2552
|
+
/*
|
2631
2553
|
namespace (moreNames, others) {
|
2632
2554
|
const config = this.copy()
|
2633
2555
|
if (!Array.isArray(moreNames)) {
|
@@ -2663,6 +2585,7 @@ class Config {
|
|
2663
2585
|
config.rebuild()
|
2664
2586
|
return config
|
2665
2587
|
}
|
2588
|
+
*/
|
2666
2589
|
|
2667
2590
|
setupNamespace (km) {
|
2668
2591
|
let config = km.config
|
@@ -2681,7 +2604,7 @@ class Config {
|
|
2681
2604
|
|
2682
2605
|
// config.initializerFn({ config: this, objects, namespace })
|
2683
2606
|
// this goes through all the configs and sets up this.config
|
2684
|
-
initializeConfigFromConfigs ({ others, objects, moreNames, callInitializers = true }) {
|
2607
|
+
async initializeConfigFromConfigs ({ others, objects, moreNames, callInitializers = true }) {
|
2685
2608
|
// setup the namespace in the configs
|
2686
2609
|
let first = true
|
2687
2610
|
this.configs.forEach((km) => {
|
@@ -2924,25 +2847,29 @@ class Config {
|
|
2924
2847
|
}
|
2925
2848
|
}
|
2926
2849
|
|
2927
|
-
add (...
|
2928
|
-
|
2929
|
-
if (
|
2930
|
-
throw new Error(
|
2850
|
+
async add (...createConfigs) {
|
2851
|
+
createConfigs.forEach((createConfig, index) => {
|
2852
|
+
if (typeof createConfig !== 'function') {
|
2853
|
+
throw new Error(`Expected add argument number ${index+1} to be a function that constructs the config.`)
|
2931
2854
|
}
|
2932
2855
|
})
|
2933
2856
|
|
2934
|
-
mores =
|
2935
|
-
|
2936
|
-
|
2857
|
+
const mores = []
|
2858
|
+
for (const createConfig of createConfigs) {
|
2859
|
+
const more = await createConfig()
|
2860
|
+
if (mores.find( (km) => km.name == more.name)) {
|
2861
|
+
throw new Error(`Expected add argument number ${index+1} to be a function that constructs the config.`)
|
2937
2862
|
}
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2863
|
+
if (this === more) {
|
2864
|
+
throw new Error('Cannot add an object to itself.')
|
2865
|
+
}
|
2866
|
+
mores.push(more)
|
2867
|
+
}
|
2868
|
+
for (let more of mores) {
|
2942
2869
|
this.valid()
|
2943
2870
|
more.valid()
|
2944
2871
|
// copy so i don't have to copy later
|
2945
|
-
more = more.copy()
|
2872
|
+
more = await more.copy()
|
2946
2873
|
more.server(this._server, this._key, this._queryParams)
|
2947
2874
|
|
2948
2875
|
const moreConfigs = more.configs.map((km) => km.name || km.uuid)
|
@@ -2957,9 +2884,6 @@ class Config {
|
|
2957
2884
|
const moreKMs1 = [new KM({ config: more, getCounter: (name) => this.getCounter(name), uuid: more.uuid, namespace })]
|
2958
2885
|
const moreKMs2 = more.configs.slice(1).map((km) => {
|
2959
2886
|
return km
|
2960
|
-
// const cp = km.copy()
|
2961
|
-
// cp.namespace = namespace
|
2962
|
-
// return cp;
|
2963
2887
|
})
|
2964
2888
|
const moreKMs = moreKMs1.concat(moreKMs2)
|
2965
2889
|
const eqClass = moreKMs.map((km) => km.uuid)
|
@@ -2973,7 +2897,7 @@ class Config {
|
|
2973
2897
|
this.configs.push(moreKM)
|
2974
2898
|
}
|
2975
2899
|
}
|
2976
|
-
more.resetToOne()
|
2900
|
+
await more.resetToOne()
|
2977
2901
|
this.config.eqClasses = this._eqClasses
|
2978
2902
|
// greg
|
2979
2903
|
// setup instances
|
@@ -2988,8 +2912,8 @@ class Config {
|
|
2988
2912
|
}
|
2989
2913
|
}
|
2990
2914
|
this.instances = noDups
|
2991
|
-
}
|
2992
|
-
this.rebuild()
|
2915
|
+
}
|
2916
|
+
await this.rebuild() // in add(
|
2993
2917
|
this.valid()
|
2994
2918
|
return this
|
2995
2919
|
}
|
@@ -3145,7 +3069,7 @@ class Config {
|
|
3145
3069
|
// assumes this is called in reverse order
|
3146
3070
|
addInternalR (more, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false) {
|
3147
3071
|
if (more instanceof Config) {
|
3148
|
-
more.
|
3072
|
+
more.initialize23({ force: false })
|
3149
3073
|
if (useOldVersion) {
|
3150
3074
|
more = more.config
|
3151
3075
|
} else {
|
package/src/semantics.js
CHANGED
@@ -312,9 +312,9 @@ class Semantics {
|
|
312
312
|
|
313
313
|
applyToContexts (args, contexts, options) {
|
314
314
|
const contextsPrime = []
|
315
|
-
|
315
|
+
for (const context of contexts) {
|
316
316
|
contextsPrime.push(this.applyToContext(args, context, options))
|
317
|
-
}
|
317
|
+
}
|
318
318
|
return contextsPrime
|
319
319
|
}
|
320
320
|
|