theprogrammablemind 7.3.9-beta.0 → 7.3.9-beta.10
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/package.json +2 -2
- package/src/config.js +36 -14
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"tod": "node inspect node_modules/.bin/jest --runInBand -t ONE23",
|
16
16
|
"lint:fix": "eslint \"**/*.js\" --fix",
|
17
17
|
"lint": "eslint \"**/*.js\"",
|
18
|
-
"to": "node node_modules/.bin/jest --runInBand -t
|
18
|
+
"to": "node node_modules/.bin/jest --runInBand -t ONE23",
|
19
19
|
"test": "jest --config ./jest.config.json",
|
20
20
|
"test:watch": "npm run test -- --watch"
|
21
21
|
},
|
@@ -61,6 +61,6 @@
|
|
61
61
|
"json-stable-stringify": "^1.0.1",
|
62
62
|
"node-fetch": "^2.6.1"
|
63
63
|
},
|
64
|
-
"version": "7.3.9-beta.
|
64
|
+
"version": "7.3.9-beta.10",
|
65
65
|
"license": "ISC"
|
66
66
|
}
|
package/src/config.js
CHANGED
@@ -172,7 +172,7 @@ class KM {
|
|
172
172
|
return this.toNS(this._name)
|
173
173
|
}
|
174
174
|
|
175
|
-
constructor ({ config, namespace = [], uuid, isSelf = false }) {
|
175
|
+
constructor ({ config, getCounter, namespace = [], uuid, isSelf = false }) {
|
176
176
|
if (uuid) {
|
177
177
|
this._uuid = uuid
|
178
178
|
this._class = 'KM'
|
@@ -226,6 +226,7 @@ class KM {
|
|
226
226
|
const config = configDup(this._config, options)
|
227
227
|
const km = new KM({
|
228
228
|
config,
|
229
|
+
getCounter: options.getCounter,
|
229
230
|
name: this._name,
|
230
231
|
_uuid: config._uuid,
|
231
232
|
namespace: this._namespace,
|
@@ -239,7 +240,8 @@ class KM {
|
|
239
240
|
name: this._name,
|
240
241
|
config: configDup(this._config),
|
241
242
|
// _uuid: uuidv4(),
|
242
|
-
_uuid: getCounter(this._config._name),
|
243
|
+
_uuid: this._config.getCounter(this._config._name),
|
244
|
+
getCounter: (name) => this._config.getCounter(name),
|
243
245
|
namespace: this._namespace,
|
244
246
|
isSelf: this._isSelf
|
245
247
|
})
|
@@ -319,15 +321,15 @@ const multiApiImpl = (initializer) => {
|
|
319
321
|
})
|
320
322
|
}
|
321
323
|
|
322
|
-
let configCounter = 1
|
323
|
-
|
324
|
-
const getCounter = (maybeName = '') => {
|
325
|
-
const counter = configCounter
|
326
|
-
configCounter += 1
|
327
|
-
return `${maybeName}${counter}`
|
328
|
-
}
|
329
324
|
|
330
325
|
class Config {
|
326
|
+
|
327
|
+
getCounter (maybeName = '') {
|
328
|
+
const counter = this.configCounter
|
329
|
+
this.configCounter += 1
|
330
|
+
return `${maybeName}${counter}`
|
331
|
+
}
|
332
|
+
|
331
333
|
defaultConfig () {
|
332
334
|
this.config = {
|
333
335
|
operators: [], // TODO
|
@@ -363,6 +365,7 @@ class Config {
|
|
363
365
|
for (const bag of bags) {
|
364
366
|
this.config[bag] = []
|
365
367
|
}
|
368
|
+
this.configCounter = 1
|
366
369
|
// this.wasInitialized = false
|
367
370
|
}
|
368
371
|
|
@@ -989,7 +992,7 @@ class Config {
|
|
989
992
|
this._namespace = []
|
990
993
|
this._eqClasses = []
|
991
994
|
// this._uuid = uuidv4()
|
992
|
-
this._uuid = getCounter(this.name)
|
995
|
+
this._uuid = this.getCounter(this.name)
|
993
996
|
if (config) {
|
994
997
|
config = _.cloneDeep(config)
|
995
998
|
this.config = config
|
@@ -1083,7 +1086,7 @@ class Config {
|
|
1083
1086
|
}
|
1084
1087
|
}
|
1085
1088
|
this.initConfig = _.cloneDeep(this.config)
|
1086
|
-
this.configs.push(new KM({ config: this.config, uuid: this._uuid }))
|
1089
|
+
this.configs.push(new KM({ config: this.config, getCounter: (name) => this.config.getCounter(name), uuid: this._uuid }))
|
1087
1090
|
|
1088
1091
|
/*
|
1089
1092
|
if (config) {
|
@@ -1166,7 +1169,7 @@ class Config {
|
|
1166
1169
|
set uuid (uuid) {
|
1167
1170
|
const map = { [this._uuid]: uuid }
|
1168
1171
|
this._uuid = uuid
|
1169
|
-
configCounter += 1
|
1172
|
+
this.configCounter += 1
|
1170
1173
|
this.mapUUIDs(map)
|
1171
1174
|
}
|
1172
1175
|
|
@@ -1240,7 +1243,7 @@ class Config {
|
|
1240
1243
|
const cp = new Config()
|
1241
1244
|
cp.logs = []
|
1242
1245
|
cp.transitoryMode = this.transitoryMode
|
1243
|
-
cp.configs = this.configs.map((km) => km.copy2(Object.assign({}, options, { callInitializers: false })))
|
1246
|
+
cp.configs = this.configs.map((km) => km.copy2(Object.assign({}, options, { getCounter: (name) => cp.getCounter(name), callInitializers: false })))
|
1244
1247
|
cp._uuid = cp.configs[0]._uuid
|
1245
1248
|
cp.initializerFn = this.initializerFn
|
1246
1249
|
cp.initAfterApi = this.initAfterApi
|
@@ -1935,6 +1938,25 @@ class Config {
|
|
1935
1938
|
if (!this.config.hasOwnProperty(property)) {
|
1936
1939
|
throw `Setting invalid property ${property}`
|
1937
1940
|
}
|
1941
|
+
|
1942
|
+
if ('words' == property) {
|
1943
|
+
for (let word in value) {
|
1944
|
+
for (let def of value[word]) {
|
1945
|
+
if (!def['uuid']) {
|
1946
|
+
throw `All definitions for '${property}' must have the uuid property set (config.uuid). uuid is missing from ${JSON.stringify(def)} for the word '${word}'`
|
1947
|
+
}
|
1948
|
+
}
|
1949
|
+
}
|
1950
|
+
}
|
1951
|
+
|
1952
|
+
if (['operators', 'bridges'].includes(property)) {
|
1953
|
+
for (let def of value) {
|
1954
|
+
if (!def['uuid']) {
|
1955
|
+
throw `All definitions for '${property}' must have the uuid property set (config.uuid). uuid is missing from ${JSON.stringify(def)}`
|
1956
|
+
}
|
1957
|
+
}
|
1958
|
+
}
|
1959
|
+
|
1938
1960
|
this.config[property] = value
|
1939
1961
|
// this.configs[0][property] = value
|
1940
1962
|
}
|
@@ -1982,7 +2004,7 @@ class Config {
|
|
1982
2004
|
// this.configs = this.configs.concat(new KM({config: more}));
|
1983
2005
|
// only set for the first one the rest have it set
|
1984
2006
|
const namespace = this._namespace.concat(more._namespace)
|
1985
|
-
const moreKMs1 = [new KM({ config: more, uuid: more.uuid, namespace })]
|
2007
|
+
const moreKMs1 = [new KM({ config: more, getCounter: (name) => this.getCounter(name), uuid: more.uuid, namespace })]
|
1986
2008
|
const moreKMs2 = more.configs.slice(1).map((km) => {
|
1987
2009
|
return km
|
1988
2010
|
// const cp = km.copy()
|