theprogrammablemind 9.1.1-beta.13 → 9.1.1-beta.15

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 CHANGED
@@ -1161,7 +1161,7 @@ const checkTemplate = (template) => {
1161
1161
  if (template.checks) {
1162
1162
  throw new Error("The 'checks' property should be in the 'test' property not the 'template' property")
1163
1163
  }
1164
- validProps([ 'fragments', 'configs' ], template.template, 'template.template')
1164
+ validProps(['fragments', 'configs'], template.template, 'template.template')
1165
1165
  }
1166
1166
 
1167
1167
  const checkTest = (testConfig) => {
package/package.json CHANGED
@@ -69,6 +69,6 @@
69
69
  "sort-json": "^2.0.0",
70
70
  "uuid": "^8.3.2"
71
71
  },
72
- "version": "9.1.1-beta.13",
72
+ "version": "9.1.1-beta.15",
73
73
  "license": "UNLICENSED"
74
74
  }
package/src/config.js CHANGED
@@ -865,6 +865,7 @@ class Config {
865
865
  async fixtures () {
866
866
  if (this.testConfig?.fixtures) {
867
867
  const args = {}
868
+ args.uuid = this._uuid
868
869
  configHelpers.setupArgs(args, this)
869
870
  return this.testConfig.fixtures(args)
870
871
  }
@@ -893,7 +894,7 @@ class Config {
893
894
 
894
895
  getPseudoConfig (uuid, config) {
895
896
  return {
896
- description: 'this is a pseudo config that has limited functionality due to being available in the initializer function context',
897
+ description: 'this is a pseudo config that has limited functionality due to being available in the initializer and fixtures function context',
897
898
  addAssociation: (...args) => this.addAssociation(...args),
898
899
  addAssociations: (...args) => this.addAssociations(...args),
899
900
  addBridge: (...args) => this.addBridge(...args, uuid),
@@ -2089,9 +2090,17 @@ class Config {
2089
2090
  this.resetDelta(cacheKey)
2090
2091
  }
2091
2092
 
2093
+ base_api () {
2094
+ if (this._api && this._api.multiApi) {
2095
+ throw new Error('This is intended to be used to instantiate a new class based on the existing API.')
2096
+ } else {
2097
+ return this._api
2098
+ }
2099
+ }
2100
+
2092
2101
  get api () {
2093
2102
  if (this._stop_auto_rebuild) {
2094
- throw new Error("The API cannot be accessed until the auto rebuild is restarted")
2103
+ throw new Error('The API cannot be accessed until the auto rebuild is restarted')
2095
2104
  }
2096
2105
 
2097
2106
  if (this._api && this._api.multiApi) {
@@ -2121,8 +2130,20 @@ class Config {
2121
2130
  throw new Error(`Expected the argument to be an API constructor for ${this.name}.`)
2122
2131
  }
2123
2132
  const value = constructor()
2124
- if (!value.initialize) {
2125
- throw new Error(`Expected the API to have an initialize function for ${this.name}.`)
2133
+ if (this._apiKMs.length > 0) {
2134
+ for (const name of this._apiKMs) {
2135
+ const api = value[name]
2136
+ if (!api) {
2137
+ throw new Error(`The API for ${this.name} is not being provided by the API constructor.`)
2138
+ }
2139
+ if (!api.initialize) {
2140
+ throw new Error(`Expected the API for ${this.name} to have an initialize function.`)
2141
+ }
2142
+ }
2143
+ } else {
2144
+ if (!value.initialize) {
2145
+ throw new Error(`Expected the API to have an initialize function for ${this.name}.`)
2146
+ }
2126
2147
  }
2127
2148
 
2128
2149
  if (this._api && this._api.multiApi) {
@@ -2135,13 +2156,13 @@ class Config {
2135
2156
  return api
2136
2157
  }
2137
2158
  } else {
2138
- this._api = value
2139
2159
  this._apiConstructor = constructor
2140
- for (const name of this._apiKMs) {
2141
- if (this.name == name) {
2142
- continue
2160
+ if (this._apiKMs.length > 0) {
2161
+ for (const name of this._apiKMs) {
2162
+ this.km(name)._api = value[name]
2143
2163
  }
2144
- this.km(name).setApi(() => this._api)
2164
+ } else {
2165
+ this._api = value
2145
2166
  }
2146
2167
  await this.rebuild()
2147
2168
  }
@@ -2210,10 +2231,21 @@ class Config {
2210
2231
  // update uuid here set the uuid in the objects and add error checking
2211
2232
  cp.initializerFn = this.initializerFn
2212
2233
  cp.terminatorFn = this.terminatorFn
2213
- if (this._apiConstructor) {
2214
- cp._api = this._apiConstructor(cp)
2215
- cp._apiConstructor = this._apiConstructor
2216
- cp._apiKMs = this._apiKMs
2234
+ cp._apiKMs = this._apiKMs
2235
+ cp._apiConstructor = this._apiConstructor
2236
+ if (cp._apiConstructor) {
2237
+ if (this._apiKMs.length > 0) {
2238
+ const apis = cp._apiConstructor(cp)
2239
+ for (const name of this._apiKMs) {
2240
+ if (name == this.name) {
2241
+ cp._api = apis[name]
2242
+ } else {
2243
+ cp.km(name)._api = apis[name]
2244
+ }
2245
+ }
2246
+ } else {
2247
+ cp._api = cp._apiConstructor(cp)
2248
+ }
2217
2249
  }
2218
2250
  cp._namespace = this._namespace
2219
2251
  cp._eqClasses = this._eqClasses
@@ -2593,7 +2625,9 @@ class Config {
2593
2625
  const initAfterApis = []
2594
2626
  this.configs.forEach((km) => {
2595
2627
  const namespace = km.namespace
2596
- this.config.objects.namespaced[km._uuid] = {}
2628
+ this.config.objects.namespaced[km._uuid] = {
2629
+ km: km._uuid
2630
+ }
2597
2631
  const namespacedObjects = this.config.objects.namespaced[km._uuid]
2598
2632
  this.setupNamespace(km)
2599
2633
  // const aw = (word, def) => this.addWord(word, def)
@@ -85,6 +85,9 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
85
85
  args.objects = config.get('objects')
86
86
  args.getObjects = getObjects(args.objects)
87
87
  }
88
+ if (args.uuid) {
89
+ args.objects = args.getObjects(args.uuid)
90
+ }
88
91
  if (!hierarchy) {
89
92
  hierarchy = config.hierarchy
90
93
  }
@@ -249,7 +252,7 @@ const setupContexts = (rawContexts) => {
249
252
  let first = true
250
253
  const contexts = []
251
254
  contexts.push({ marker: 'controlStart', controlRemove: true })
252
- let previous;
255
+ let previous
253
256
  for (const context of rawContexts) {
254
257
  if (first) {
255
258
  first = false
@@ -337,9 +340,9 @@ const processContextsB = async ({ config, hierarchy, semantics, generators, json
337
340
  if (contextPrime.controlRemove) {
338
341
  continue
339
342
  }
340
- let paraphrases = []
341
- let paraphrasesParenthesized = []
342
- let generatedParenthesized = []
343
+ const paraphrases = []
344
+ const paraphrasesParenthesized = []
345
+ const generatedParenthesized = []
343
346
  if (forTemplate) {
344
347
  // noop
345
348
  } else {