theprogrammablemind
Advanced tools
Comparing version 7.3.9 to 7.3.10-beta.0
@@ -18,3 +18,3 @@ { | ||
"lint": "eslint \"**/*.js\"", | ||
"to": "node node_modules/.bin/jest --runInBand -t NEO", | ||
"to": "node node_modules/.bin/jest --runInBand -t ONE23", | ||
"test": "jest --config ./jest.config.json", | ||
@@ -65,4 +65,4 @@ "test:watch": "npm run test -- --watch" | ||
}, | ||
"version": "7.3.9", | ||
"version": "7.3.10-beta.0", | ||
"license": "ISC" | ||
} |
@@ -175,3 +175,3 @@ // lookup = (name) => returns <config> | ||
constructor ({ config, namespace = [], uuid, isSelf = false }) { | ||
constructor ({ config, getCounter, namespace = [], uuid, isSelf = false }) { | ||
if (uuid) { | ||
@@ -230,2 +230,3 @@ this._uuid = uuid | ||
config, | ||
getCounter: options.getCounter, | ||
name: this._name, | ||
@@ -244,3 +245,4 @@ _uuid: config._uuid, | ||
// _uuid: uuidv4(), | ||
_uuid: getCounter(this._config._name), | ||
_uuid: this._config.getCounter(this._config._name), | ||
getCounter: (name) => this._config.getCounter(name), | ||
namespace: this._namespace, | ||
@@ -325,11 +327,11 @@ isSelf: this._isSelf | ||
let configCounter = 1 | ||
const getCounter = (maybeName = '') => { | ||
const counter = configCounter | ||
configCounter += 1 | ||
return `${maybeName}${counter}` | ||
} | ||
class Config { | ||
class Config { | ||
getCounter (maybeName = '') { | ||
const counter = this.configCounter | ||
this.configCounter += 1 | ||
return `${maybeName}${counter}` | ||
} | ||
defaultConfig () { | ||
@@ -370,2 +372,3 @@ this.config = { | ||
} | ||
this.configCounter = 1 | ||
// this.wasInitialized = false | ||
@@ -997,3 +1000,3 @@ } | ||
// this._uuid = uuidv4() | ||
this._uuid = getCounter(this.name) | ||
this._uuid = this.getCounter(this.name) | ||
if (config) { | ||
@@ -1092,3 +1095,3 @@ config = _.cloneDeep(config) | ||
this.initConfig = _.cloneDeep(this.config) | ||
this.configs.push(new KM({ config: this.config, uuid: this._uuid })) | ||
this.configs.push(new KM({ config: this.config, getCounter: (name) => this.config.getCounter(name), uuid: this._uuid })) | ||
@@ -1176,3 +1179,3 @@ /* | ||
this._uuid = uuid | ||
configCounter += 1 | ||
this.configCounter += 1 | ||
this.mapUUIDs(map) | ||
@@ -1246,3 +1249,3 @@ } | ||
copy (options = {}) { | ||
copy (options = { callInitializers: true }) { | ||
this.valid() | ||
@@ -1252,3 +1255,3 @@ const cp = new Config() | ||
cp.transitoryMode = this.transitoryMode | ||
cp.configs = this.configs.map((km) => km.copy2(Object.assign({}, options, { callInitializers: false }))) | ||
cp.configs = this.configs.map((km) => km.copy2(Object.assign({}, options, { getCounter: (name) => cp.getCounter(name), callInitializers: false }))) | ||
cp._uuid = cp.configs[0]._uuid | ||
@@ -1267,2 +1270,3 @@ cp.initializerFn = this.initializerFn | ||
cp.instances = this.instances.slice() | ||
cp.configCounter = this.configCounter | ||
@@ -1278,2 +1282,3 @@ cp.initConfig = _.cloneDeep(this.initConfig) | ||
// cp.initializeConfigFromConfigs({ others: [], objects: cp.config.objects.namespaced, moreNames: [], ...options }) | ||
// cp.initializeConfigFromConfigs(Object.assign({ others: [], objects: cp.config.objects.namespaced, moreNames: [] }, { callInitializers: false })) | ||
cp.initializeConfigFromConfigs(Object.assign({ others: [], objects: cp.config.objects.namespaced, moreNames: [] }, options)) | ||
@@ -1286,2 +1291,5 @@ const map = {} | ||
if (options.callInitializers) { | ||
cp.rebuild(options) | ||
} | ||
if (cp._api) { | ||
@@ -1303,5 +1311,2 @@ cp._api.objects = cp.config.objects | ||
if (options.callInitializers) { | ||
cp.rebuild(options) | ||
} | ||
cp.valid() | ||
@@ -1438,3 +1443,12 @@ return cp | ||
initializer (fn, { initAfterApi = false } = {}) { | ||
initializer (fn, options = {}) { | ||
if (options) { | ||
for (let option of Object.keys(options)) { | ||
const validOptions = ['initAfterApi'] | ||
if (!['initAfterApi'].includes(option)) { | ||
throw `For Config.initializer, unrecognized option ${option}. The valid options are ${validOptions}` | ||
} | ||
} | ||
} | ||
const { initAfterApi = false } = options; | ||
this.wasInitialized = false | ||
@@ -1785,3 +1799,3 @@ this.initAfterApi = initAfterApi | ||
if (callInitializers) { | ||
this.configs.forEach(({ namespace, uuid, config, isSelf }) => { | ||
[...this.configs].reverse().forEach(({ namespace, uuid, config, isSelf }) => { | ||
if (isSelf) { | ||
@@ -1954,2 +1968,21 @@ config = this | ||
} | ||
if ('words' == property) { | ||
for (let word in value) { | ||
for (let def of value[word]) { | ||
if (!def['uuid']) { | ||
throw `All definitions for '${property}' must have the uuid property set (config.uuid). uuid is missing from ${JSON.stringify(def)} for the word '${word}'` | ||
} | ||
} | ||
} | ||
} | ||
if (['operators', 'bridges'].includes(property)) { | ||
for (let def of value) { | ||
if (!def['uuid']) { | ||
throw `All definitions for '${property}' must have the uuid property set (config.uuid). uuid is missing from ${JSON.stringify(def)}` | ||
} | ||
} | ||
} | ||
this.config[property] = value | ||
@@ -2002,3 +2035,3 @@ // this.configs[0][property] = value | ||
const namespace = this._namespace.concat(more._namespace) | ||
const moreKMs1 = [new KM({ config: more, uuid: more.uuid, namespace })] | ||
const moreKMs1 = [new KM({ config: more, getCounter: (name) => this.getCounter(name), uuid: more.uuid, namespace })] | ||
const moreKMs2 = more.configs.slice(1).map((km) => { | ||
@@ -2005,0 +2038,0 @@ return km |
@@ -174,3 +174,3 @@ const { args: contextArgs, normalizeGenerator } = require('./helpers') | ||
// let context_prime = JSON.stringify(context); | ||
let contextPrime = context | ||
let generated = context | ||
let applied = false | ||
@@ -193,6 +193,6 @@ const stack = args.calls.push() | ||
try { | ||
contextPrime = generator.apply(args, objects, g, args.gs, context, hierarchy, config, response, log) | ||
generated= generator.apply(args, objects, g, args.gs, context, hierarchy, config, response, log) | ||
} catch( e ) { | ||
// the next if handle this | ||
contextPrime = null | ||
generated = null | ||
if (e.stack && e.message) { | ||
@@ -206,3 +206,3 @@ errorMessage = `Error applying generator '${generator.notes}'. Error is ${e.toString()} stack is ${e.stack}. Generator is ${generator.toString()}` | ||
} | ||
if (!contextPrime && contextPrime !== '') { | ||
if (!generated && generated !== '') { | ||
const widths = [10, 10, 90] | ||
@@ -250,3 +250,3 @@ const lines = new Lines(widths) | ||
lines.setElement(0, 1, 'RESULT') | ||
lines.setElement(0, 2, contextPrime) | ||
lines.setElement(0, 2, generated) | ||
lines.newRow() | ||
@@ -282,3 +282,3 @@ lines.setElement(0, 1, 'STACK') | ||
} | ||
contextsPrime.push(contextPrime) | ||
contextsPrime.push(generated) | ||
} | ||
@@ -285,0 +285,0 @@ return contextsPrime |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
161755
4636
2