theprogrammablemind_4wp 7.5.8-beta.18 → 7.5.8-beta.19

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 +8 -4
  2. package/package.json +1 -1
  3. package/src/config.js +33 -11
package/client.js CHANGED
@@ -549,10 +549,11 @@ const setupProcessB = ({ config, initializer, allowDelta=false } = {}) => {
549
549
  // console.log('config', config)
550
550
  data.delta = config.delta()
551
551
  } else {
552
- Object.assign(data, config.config)
552
+ config.toData(data)
553
+ // Object.assign(data, config.config)
553
554
  }
554
555
 
555
- config.toServer(data)
556
+ // config.toServer(data)
556
557
 
557
558
  if (data.namespaces) {
558
559
  for (const uuid of Object.keys(data.namespaces)) {
@@ -594,7 +595,7 @@ const processInstance = (config, instance) => {
594
595
  global.transitoryMode = transitoryMode
595
596
  }
596
597
 
597
- const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, saveDeveloper, testConfig, testsFN, errorHandler = defaultErrorHandler } = {}) => {
598
+ const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, saveDeveloper, rebuildingTemplate, testConfig, testsFN, errorHandler = defaultErrorHandler } = {}) => {
598
599
  if (credentials) {
599
600
  config.server(credentials.server, credentials.key)
600
601
  }
@@ -618,6 +619,9 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
618
619
  if (commandLineArgs && commandLineArgs.checkForLoop) {
619
620
  data.checkForLoop = true
620
621
  }
622
+ if (rebuildingTemplate) {
623
+ data.errors_ignore_contextual_priorities_non_existant_ops = true
624
+ }
621
625
  let queries = query.split('\\n')
622
626
 
623
627
  try {
@@ -1247,7 +1251,7 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
1247
1251
  }
1248
1252
 
1249
1253
  try {
1250
- const results = await _process(config, query.query, {initializer})
1254
+ const results = await _process(config, query.query, {initializer, rebuildingTemplate: true})
1251
1255
  if (config.config.debug) {
1252
1256
  // TODO pass in the error handler like the other ones
1253
1257
  defaultInnerProcess(config, defaultErrorHandler, results)
package/package.json CHANGED
@@ -63,6 +63,6 @@
63
63
  "json-stable-stringify": "^1.0.1",
64
64
  "node-fetch": "^2.6.1"
65
65
  },
66
- "version": "7.5.8-beta.18",
66
+ "version": "7.5.8-beta.19",
67
67
  "license": "ISC"
68
68
  }
package/src/config.js CHANGED
@@ -833,6 +833,11 @@ class Config {
833
833
  }
834
834
  }
835
835
 
836
+ toData (data) {
837
+ Object.assign(data, this.config)
838
+ config_toServer(data)
839
+ }
840
+
836
841
  load (template, instance, options = { rebuild: false } ) {
837
842
  this.validifyTemplate(template)
838
843
  instance.template = template
@@ -1654,6 +1659,7 @@ class Config {
1654
1659
  cp.transitoryMode = this.transitoryMode
1655
1660
  cp.configs = this.configs.map((km) => km.copy2(Object.assign({}, options, { getCounter: (name) => cp.getCounter(name), callInitializers: false })))
1656
1661
  cp._uuid = cp.configs[0]._uuid
1662
+ // update uuid here set the uuid in the objects and add error checking
1657
1663
  cp.initializerFn = this.initializerFn
1658
1664
  cp.initAfterApi = this.initAfterApi
1659
1665
  cp._api = _.cloneDeep(this._api)
@@ -1809,21 +1815,23 @@ class Config {
1809
1815
  if (config instanceof Config) {
1810
1816
  // const aw = addWord(this.config, config.uuid)
1811
1817
  const aw = (word, def) => this.addWord(word, def)
1818
+ const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
1812
1819
  this.get('objects').namespaced[config._uuid] = objects
1813
1820
  if (config._api) {
1814
1821
  config._api.objects = objects
1815
1822
  config._api.config = () => this
1816
1823
  }
1817
- config.initializerFn({ addWord: aw, km, config, baseConfig: this, currentConfig: config, objects, namespace, uuid, api: config.api })
1824
+ config.initializerFn({ addWord: aw, addGenerator: ag, km, config, baseConfig: this, currentConfig: config, objects, namespace, uuid, api: config.api })
1818
1825
  } else {
1819
1826
  // const aw = addWord(this.config, this.uuid)
1820
1827
  const aw = (word, def) => this.addWord(word, def)
1828
+ const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
1821
1829
  this.get('objects').namespaced[this._uuid] = objects
1822
1830
  if (config._api) {
1823
1831
  config._api.objects = objects
1824
1832
  config._api.config = () => this
1825
1833
  }
1826
- this.initializerFn({ addWord: aw, km, config: this, baseConfig: this, currentConfig: this, objects, namespace, uuid, api: this.api })
1834
+ this.initializerFn({ addWord: aw, addGenerator: ag, km, config: this, baseConfig: this, currentConfig: this, objects, namespace, uuid, api: this.api })
1827
1835
  }
1828
1836
  })
1829
1837
  this.instances.forEach((instance) => client.processInstance(this, instance))
@@ -1833,10 +1841,11 @@ class Config {
1833
1841
  if (force || !this.wasInitialized) {
1834
1842
  // const aw = addWord(this.config, this.uuid)
1835
1843
  const aw = (word, def) => this.addWord(word, def)
1844
+ const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
1836
1845
  const km = (name) => this.getConfig(name)
1837
1846
  // this.initializerFn({ addWord: aw, km, config: this, baseConfig: this, currentConfig: this, objects: this.get('objects'), uuid: this._uuid, namespace: '', api: this.api })
1838
1847
  const objects = this.config.objects.namespaced[this._uuid]
1839
- this.initializerFn({ addWord: aw, km, config: this, baseConfig: this, currentConfig: this, objects, uuid: this._uuid, namespace: '', api: this.api })
1848
+ this.initializerFn({ addWord: aw, addGenerator: ag, km, config: this, baseConfig: this, currentConfig: this, objects, uuid: this._uuid, namespace: '', api: this.api })
1840
1849
  this.wasInitialized = true
1841
1850
  }
1842
1851
  }
@@ -2054,6 +2063,7 @@ class Config {
2054
2063
  const initAfterApis = []
2055
2064
  const reverseIt = true
2056
2065
  const interleaved = true
2066
+ let isAfterApi = false
2057
2067
  this.configs.forEach((km) => {
2058
2068
  const namespace = km.namespace
2059
2069
  this.config.objects.namespaced[km._uuid] = {}
@@ -2061,6 +2071,7 @@ class Config {
2061
2071
  this.setupNamespace(km)
2062
2072
  // const aw = addWord(km.config.config ? km.config.config : km.config, km.config.uuid)
2063
2073
  const aw = (word, def) => this.addWord(word, def)
2074
+ const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
2064
2075
  let config = km.config
2065
2076
 
2066
2077
  if (config.addedArgss) {
@@ -2081,9 +2092,12 @@ class Config {
2081
2092
  }
2082
2093
  config.wasInitialized = false
2083
2094
  // TODO change name of config: to baseConfig:
2084
- const kmFn = (name) => this.getConfig(name)
2095
+ const kmFn = (name) => {
2096
+ const config = this.getConfig(name)
2097
+ return config
2098
+ }
2085
2099
  // const hierarchy = new DigraphInternal((config.config || {}).hierarchy)
2086
- const args = {
2100
+ const args = new Object({
2087
2101
  isModule,
2088
2102
  addWord: aw,
2089
2103
  km: kmFn,
@@ -2095,8 +2109,13 @@ class Config {
2095
2109
  objects: namespacedObjects,
2096
2110
  namespace,
2097
2111
  motivation: (m) => config.addMotivation(m),
2098
- api: config.api
2099
- }
2112
+ get api() {
2113
+ if (!isAfterApi) {
2114
+ throw new Error("APIs should not be accessed in the initializer until after they are all initialized. Call initializer like config.initializer(fn, { initAfterApi: true }). Then the args to the initalizer will include isAfterApi which can be used to determine if the initialize is being run before or after the API's are initialized. The default is before.")
2115
+ }
2116
+ return config.api
2117
+ }
2118
+ })
2100
2119
  config.initializerFn(args)
2101
2120
  if (config.initAfterApi) {
2102
2121
  // reverse the list
@@ -2148,6 +2167,7 @@ class Config {
2148
2167
  this.config.semantics = []
2149
2168
  }
2150
2169
 
2170
+ isAfterApi = true
2151
2171
  if (!interleaved) {
2152
2172
  for (const config of addInternals) {
2153
2173
  if (!reverseIt) {
@@ -2162,7 +2182,7 @@ class Config {
2162
2182
  }
2163
2183
  for (let init of initAfterApis) {
2164
2184
  // init.args.isAfterApi = true
2165
- init.config.initializerFn({ ...init.args, kms: this.getConfigs(), isAfterApi: true })
2185
+ init.config.initializerFn({ ...init.args, kms: this.getConfigs(), isAfterApi })
2166
2186
  }
2167
2187
  this.instances.forEach((instance) => client.processInstance(this, instance))
2168
2188
  } else {
@@ -2199,7 +2219,7 @@ class Config {
2199
2219
  }
2200
2220
  if (initAfterApis[i]) {
2201
2221
  const init = initAfterApis[i]
2202
- init.config.initializerFn({ ...init.args, kms: this.getConfigs(), isAfterApi: true })
2222
+ init.config.initializerFn({ ...init.args, kms: this.getConfigs(), isAfterApi})
2203
2223
  }
2204
2224
  const instance = this.instances.find((instance) => instance.name == name)
2205
2225
  if (instance) {
@@ -2332,11 +2352,13 @@ class Config {
2332
2352
  if (config instanceof Config) {
2333
2353
  // const aw = addWord(this.config, config.uuid)
2334
2354
  const aw = (word, def) => this.addWord(word, def)
2335
- config.initializerFn({ isModule: this.isModule, addWord: aw, baseConfig: this, km, currentConfig: config, config, objects: nsobjects, namespace, uuid, api: config.api })
2355
+ const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
2356
+ config.initializerFn({ isModule: this.isModule, addWord: aw, addGenerator: ag, baseConfig: this, km, currentConfig: config, config, objects: nsobjects, namespace, uuid, api: config.api })
2336
2357
  } else {
2337
2358
  // const aw = addWord(this.config, this.uuid)
2338
2359
  const aw = (word, def) => this.addWord(word, def)
2339
- this.initializerFn({ isModule: this.isModule, addWord: aw, baseConfig: this, km, currentConfig: this, config: this, objects: nsobjects, namespace, uuid, api: this.api })
2360
+ const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
2361
+ this.initializerFn({ isModule: this.isModule, addWord: aw, addGenerator: ag, baseConfig: this, km, currentConfig: this, config: this, objects: nsobjects, namespace, uuid, api: this.api })
2340
2362
  }
2341
2363
  })
2342
2364
  }