entodicton 9.7.1-beta.1 → 9.7.1-beta.3
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 +2 -1
- package/index.js +3 -2
- package/package.json +1 -1
- package/src/config.js +8 -0
- package/src/helpers.js +18 -0
package/client.js
CHANGED
|
@@ -12,7 +12,7 @@ const _ = require('lodash')
|
|
|
12
12
|
const stringify = require('json-stable-stringify')
|
|
13
13
|
const Lines = require('./lines')
|
|
14
14
|
const flattens = require('./src/flatten')
|
|
15
|
-
const { sortJson, appendNoDups, InitCalls, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps } = require('./src/helpers')
|
|
15
|
+
const { sortJson, appendNoDups, InitCalls, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps, OverrideCheck, } = require('./src/helpers')
|
|
16
16
|
const runtime = require('./runtime')
|
|
17
17
|
const db = require('./src/debug')
|
|
18
18
|
|
|
@@ -2104,4 +2104,5 @@ module.exports = {
|
|
|
2104
2104
|
writeTest,
|
|
2105
2105
|
getConfigForTest,
|
|
2106
2106
|
debug: db,
|
|
2107
|
+
OverrideCheck,
|
|
2107
2108
|
}
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Semantics, Semantic } = require('./src/semantics')
|
|
2
2
|
const { Generators, Generator } = require('./src/generators')
|
|
3
3
|
const { Config } = require('./src/config')
|
|
4
|
-
const { w, where } = require('./src/helpers')
|
|
4
|
+
const { w, where, OverrideCheck } = require('./src/helpers')
|
|
5
5
|
const Digraph = require('./src/digraph')
|
|
6
6
|
const client = require('./client')
|
|
7
7
|
const flattens = require('./src/flatten')
|
|
@@ -28,5 +28,6 @@ module.exports = {
|
|
|
28
28
|
flattens: flattens.flattens,
|
|
29
29
|
flatten: flattens.flatten,
|
|
30
30
|
unflatten: unflatten.unflatten,
|
|
31
|
-
debug
|
|
31
|
+
debug,
|
|
32
|
+
OverrideCheck,
|
|
32
33
|
}
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -2313,6 +2313,7 @@ class Config {
|
|
|
2313
2313
|
}
|
|
2314
2314
|
}
|
|
2315
2315
|
|
|
2316
|
+
// TODO Api or API -> pick one and do that
|
|
2316
2317
|
async setMultiApi (initializer) {
|
|
2317
2318
|
await this.setApi(() => multiApiImpl(initializer))
|
|
2318
2319
|
}
|
|
@@ -2420,11 +2421,18 @@ class Config {
|
|
|
2420
2421
|
if (!api.initialize) {
|
|
2421
2422
|
throw new Error(`Expected the API for ${this.name} to have an initialize function.`)
|
|
2422
2423
|
}
|
|
2424
|
+
if (api.baseAPI) {
|
|
2425
|
+
debugger
|
|
2426
|
+
new helpers.OverrideCheck(api.baseAPI).check(api)
|
|
2427
|
+
}
|
|
2423
2428
|
}
|
|
2424
2429
|
} else {
|
|
2425
2430
|
if (!value.initialize) {
|
|
2426
2431
|
throw new Error(`Expected the API to have an initialize function for ${this.name}. If you are trying to pass in multiple API configs at once use setApiKMs to set the names of the configs that you want set.`)
|
|
2427
2432
|
}
|
|
2433
|
+
if (value.baseAPI) {
|
|
2434
|
+
new helpers.OverrideCheck(value.baseAPI).check(value)
|
|
2435
|
+
}
|
|
2428
2436
|
}
|
|
2429
2437
|
|
|
2430
2438
|
if (this._api && this._api.multiApi) {
|
package/src/helpers.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
const deepEqual = require('deep-equal')
|
|
2
2
|
const stringify = require('json-stable-stringify')
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
// check if member function of a class have been overriden by an subclass
|
|
6
|
+
class OverrideCheck {
|
|
7
|
+
constructor(base, suffix='API') {
|
|
8
|
+
this.base = base
|
|
9
|
+
this.checks = Object.getOwnPropertyNames(base.prototype).filter(key => typeof base.prototype[key] === 'function' && key.endsWith(suffix));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
check(obj) {
|
|
13
|
+
for (const check of this.checks) {
|
|
14
|
+
if (obj[check] == this.base.prototype[check]) {
|
|
15
|
+
throw new Error(`For ${obj.constructor.name} you need to override ${check}`)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
4
21
|
function pathEquals (p1, p2) {
|
|
5
22
|
if (p1.length !== p2.length) {
|
|
6
23
|
return false
|
|
@@ -611,4 +628,5 @@ module.exports = {
|
|
|
611
628
|
assignAssumed,
|
|
612
629
|
watchProperty,
|
|
613
630
|
pathEquals,
|
|
631
|
+
OverrideCheck,
|
|
614
632
|
}
|