@servable/tools 1.3.1 → 1.4.1
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/README.md +1 -1
- package/package.json +2 -2
- package/src/config/candidates/index.js +5 -5
- package/src/config/candidates/{featureCandidates → protocolCandidates}/index.js +5 -5
- package/src/config/validate/index.js +2 -2
- package/src/config/validate/{feature → protocol}/index.js +1 -1
- package/src/document/{1.1.0/all/build/feature → 1.0.0/all/build/protocol}/index.js +23 -23
- package/src/document/1.0.0/all/index.js +4 -4
- package/src/document/1.0.0/all/write/index.js +3 -3
- package/src/document/1.0.0/chunks/build/class/class.js +2 -2
- package/src/document/1.0.0/chunks/build/class/functions.js +2 -2
- package/src/document/1.0.0/chunks/build/class/lib.js +2 -2
- package/src/document/1.0.0/chunks/build/class/seed.js +2 -2
- package/src/document/1.0.0/chunks/build/class/triggers.js +2 -2
- package/src/document/1.0.0/chunks/build/{feature → protocol}/afterInit.js +2 -2
- package/src/document/{1.1.0/chunks/build/feature → 1.0.0/chunks/build/protocol}/beforeInit.js +2 -2
- package/src/document/1.0.0/chunks/build/{feature → protocol}/class.js +3 -3
- package/src/document/{1.1.0/chunks/build/feature → 1.0.0/chunks/build/protocol}/config.js +2 -2
- package/src/document/{1.1.0/chunks/build/feature → 1.0.0/chunks/build/protocol}/functions.js +2 -2
- package/src/document/{1.1.0/chunks/build/feature → 1.0.0/chunks/build/protocol}/lib.js +2 -2
- package/src/document/1.0.0/chunks/build/{feature → protocol}/liveClasses.js +2 -2
- package/src/document/1.0.0/chunks/build/{feature → protocol}/schema.js +2 -2
- package/src/document/1.0.0/chunks/build/{feature → protocol}/seed.js +2 -2
- package/src/document/1.0.0/chunks/build/{feature → protocol}/system.js +2 -2
- package/src/document/{1.1.0/chunks/build/feature → 1.0.0/chunks/build/protocol}/triggers.js +2 -2
- package/src/document/1.0.0/generateGithubReadme/build/chunks/dependencies/index.js +2 -2
- package/src/document/1.0.0/generateGithubReadme/build/chunks/footer.js +1 -1
- package/src/document/1.0.0/generateGithubReadme/build/chunks/githubTags.js +3 -3
- package/src/document/1.0.0/generateGithubReadme/build/chunks/registry.js +2 -2
- package/src/document/1.0.0/generateGithubReadme/build/chunks/usage.js +1 -1
- package/src/document/1.0.0/generateGithubReadme/build/index.js +23 -23
- package/src/document/{1.0.0/all/build/feature → 1.1.0/all/build/protocol}/index.js +23 -23
- package/src/document/1.1.0/all/index.js +4 -4
- package/src/document/1.1.0/all/write/index.js +3 -3
- package/src/document/1.1.0/chunks/build/class/class.js +2 -2
- package/src/document/1.1.0/chunks/build/class/functions.js +2 -2
- package/src/document/1.1.0/chunks/build/class/lib.js +2 -2
- package/src/document/1.1.0/chunks/build/class/seed.js +2 -2
- package/src/document/1.1.0/chunks/build/class/triggers.js +2 -2
- package/src/document/1.1.0/chunks/build/{feature → protocol}/afterInit.js +2 -2
- package/src/document/{1.0.0/chunks/build/feature → 1.1.0/chunks/build/protocol}/beforeInit.js +2 -2
- package/src/document/1.1.0/chunks/build/{feature → protocol}/class.js +3 -3
- package/src/document/{1.0.0/chunks/build/feature → 1.1.0/chunks/build/protocol}/config.js +2 -2
- package/src/document/{1.0.0/chunks/build/feature → 1.1.0/chunks/build/protocol}/functions.js +2 -2
- package/src/document/{1.0.0/chunks/build/feature → 1.1.0/chunks/build/protocol}/lib.js +2 -2
- package/src/document/1.1.0/chunks/build/{feature → protocol}/liveClasses.js +2 -2
- package/src/document/1.1.0/chunks/build/{feature → protocol}/schema.js +2 -2
- package/src/document/1.1.0/chunks/build/{feature → protocol}/seed.js +2 -2
- package/src/document/1.1.0/chunks/build/{feature → protocol}/system.js +2 -2
- package/src/document/{1.0.0/chunks/build/feature → 1.1.0/chunks/build/protocol}/triggers.js +2 -2
- package/src/document/1.1.0/generateGithubReadme/build/chunks/dependencies/index.js +2 -2
- package/src/document/1.1.0/generateGithubReadme/build/chunks/footer.js +1 -1
- package/src/document/1.1.0/generateGithubReadme/build/chunks/githubTags.js +3 -3
- package/src/document/1.1.0/generateGithubReadme/build/chunks/registry.js +2 -2
- package/src/document/1.1.0/generateGithubReadme/build/chunks/usage.js +1 -1
- package/src/document/1.1.0/generateGithubReadme/build/index.js +23 -23
- package/src/document/gateway/all/index.js +2 -2
- package/src/document/gateway/generateGithubReadme/index.js +2 -2
- package/src/domain/{feature → protocol}/factory/absoluteModuleSrcPath.js +3 -3
- package/src/domain/protocol/factory/index.js +71 -0
- package/src/domain/protocol/factory/protocolPath.js +41 -0
- package/src/domain/{feature → protocol}/index.js +6 -6
- package/src/domain/{feature → protocol}/lib/instancesPathIdUniqueId.js +3 -3
- package/src/domain/protocolInstance/factory/getLoaderWithPayload.js +7 -0
- package/src/domain/{featureInstance → protocolInstance}/factory/index.js +7 -7
- package/src/domain/{featureInstance → protocolInstance}/index.js +16 -16
- package/src/domain/{featureLoader → protocolLoader}/base.js +9 -9
- package/src/domain/protocolLoader/lib/mergeClassProtocols.js +17 -0
- package/src/domain/{featureLoader → protocolLoader}/v1.0.0.js +24 -24
- package/src/domain/{featureLoader → protocolLoader}/v1.1.0.js +26 -26
- package/src/index.js +7 -7
- package/src/lib/adaptConfig/basic.js +59 -59
- package/src/manifest/access/index.js +1 -1
- package/src/manifest/data/1.0.0/class.json +3 -3
- package/src/manifest/data/1.0.0/enums.js +6 -6
- package/src/manifest/data/1.0.0/{feature.json → protocol.json} +5 -5
- package/src/manifest/data/1.1.0/class.json +3 -3
- package/src/manifest/data/1.1.0/enums.js +6 -6
- package/src/manifest/data/1.1.0/{feature.json → protocol.json} +4 -4
- package/src/manifest/extract/index.js +1 -1
- package/src/manifest/extract/route/index.js +1 -1
- package/src/manifest/extract/templateDataForId.js +3 -3
- package/src/schema/build/buildProtocol/classStruct/extractProtocolsProtocols.js +29 -0
- package/src/schema/build/buildProtocol/classStruct/index.js +62 -0
- package/src/schema/build/{buildFeature/classStruct/featureInClassClassSchema.js → buildProtocol/classStruct/protocolInClassClassSchema.js} +7 -7
- package/src/schema/build/buildProtocol/extractClassesProtocol.js +49 -0
- package/src/schema/build/{buildFeature → buildProtocol}/index.js +40 -40
- package/src/schema/build/index.js +29 -29
- package/src/schema/build/lib/{getFeaturesLiveClasses.js → getProtocolsLiveClasses.js} +4 -4
- package/src/schema/build/lib/updateProtocolsExcerpt.js +24 -0
- package/src/schema/index.js +30 -30
- package/src/schema/validate/{handleFeature → handleProtocol}/computeVersions.js +2 -2
- package/src/schema/validate/handleProtocol/index.js +5 -0
- package/src/schema/validate/index.js +6 -6
- package/src/domain/feature/factory/featurePath.js +0 -41
- package/src/domain/feature/factory/index.js +0 -71
- package/src/domain/featureInstance/factory/getLoaderWithPayload.js +0 -7
- package/src/domain/featureLoader/lib/mergeClassFeatures.js +0 -17
- package/src/schema/build/buildFeature/classStruct/extractFeaturesFeatures.js +0 -29
- package/src/schema/build/buildFeature/classStruct/index.js +0 -62
- package/src/schema/build/buildFeature/extractClassesFeature.js +0 -49
- package/src/schema/build/lib/updateFeaturesExcerpt.js +0 -24
- package/src/schema/validate/handleFeature/index.js +0 -5
- /package/src/document/1.0.0/all/write/{feature → protocol}/index.js +0 -0
- /package/src/document/1.1.0/all/write/{feature → protocol}/index.js +0 -0
- /package/src/domain/{featureInstance → protocolInstance}/factory/instancesWithPath.js +0 -0
- /package/src/domain/{featureLoader → protocolLoader}/factory/getModule.js +0 -0
- /package/src/domain/{featureLoader → protocolLoader}/factory/index.js +0 -0
- /package/src/domain/{featureLoader → protocolLoader}/lib/importJSDefault.js +0 -0
- /package/src/domain/{featureLoader → protocolLoader}/lib/importJSONDefault.js +0 -0
- /package/src/domain/{featureLoader → protocolLoader}/lib/triggerItems.js +0 -0
- /package/src/lib/{adaptFeaturePayload.js → adaptProtocolPayload.js} +0 -0
- /package/src/lib/{cleanFeatures.js → cleanProtocols.js} +0 -0
- /package/src/lib/{featureApiVersion.js → protocolApiVersion.js} +0 -0
- /package/src/schema/build/{buildFeature → buildProtocol}/classStruct/preserveMostRestricted.js +0 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import BaseClass from './base.js'
|
|
2
2
|
|
|
3
3
|
import directories from '../../lib/directories.js'
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import cleanProtocols from '../../lib/cleanProtocols.js'
|
|
5
|
+
import mergeClassProtocols from './lib/mergeClassProtocols.js'
|
|
6
6
|
|
|
7
7
|
import importJSONAsync from '../../lib/importJSONAsync.js'
|
|
8
8
|
import directoryGlob from '../../lib/directoryGlob.js'
|
|
9
9
|
|
|
10
10
|
import checkFileExists from '../../lib/checkFileExists.js'
|
|
11
11
|
import directoryFilesRecursive from '../../lib/directoryFilesRecursive.js'
|
|
12
|
-
import {
|
|
12
|
+
import { ProtocolEnum } from '../../manifest/data/1.0.0/enums.js'
|
|
13
13
|
|
|
14
14
|
import triggerItems from './lib/triggerItems.js'
|
|
15
15
|
import fs from 'fs'
|
|
16
16
|
import fspath from 'path'
|
|
17
17
|
import semver from 'semver'
|
|
18
18
|
|
|
19
|
-
export default class
|
|
19
|
+
export default class ProtocolLoaderV1_1_0 extends BaseClass {
|
|
20
20
|
|
|
21
21
|
// #region class
|
|
22
22
|
|
|
@@ -245,40 +245,40 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
|
|
248
|
-
async
|
|
248
|
+
async classProtocols({ className, withProtocolsProtocols = false }) {
|
|
249
249
|
const cacheKey = 'class'
|
|
250
|
-
// //console.log('
|
|
250
|
+
// //console.log('classProtocols>', className, 'enter')
|
|
251
251
|
if (this._valueInCache(cacheKey)) {
|
|
252
252
|
return this._valueInCache(cacheKey)
|
|
253
253
|
}
|
|
254
254
|
const items = []
|
|
255
255
|
const seedMode = await this.classSeedMode({ className })
|
|
256
|
-
// //console.log('
|
|
256
|
+
// //console.log('classProtocols>', className, 'seedmode', seedMode)
|
|
257
257
|
if (seedMode === 'auto') {
|
|
258
258
|
items.push({ id: 'servableautoseedable' })
|
|
259
259
|
}
|
|
260
260
|
const _class = await this.getClass({ className })
|
|
261
261
|
if (!_class) {
|
|
262
|
-
//console.log('
|
|
262
|
+
//console.log('classProtocols>', className, 'no _class')
|
|
263
263
|
return items
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
let data =
|
|
267
|
-
const path = `${this.path}/models/${className.toLowerCase()}/
|
|
266
|
+
let data = mergeClassProtocols({ items, _class, withProtocolsProtocols })
|
|
267
|
+
const path = `${this.path}/models/${className.toLowerCase()}/protocols.js`
|
|
268
268
|
|
|
269
269
|
if ((await checkFileExists(path))) {
|
|
270
270
|
|
|
271
271
|
let _data = (await import(path)).default
|
|
272
|
-
// //console.log('
|
|
272
|
+
// //console.log('classProtocols>', className, '_data', _data)
|
|
273
273
|
_data = _data ? _data : []
|
|
274
274
|
data = [...data,
|
|
275
275
|
..._data]
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
//this.cache[cacheKey] = data
|
|
279
|
-
data =
|
|
279
|
+
data = cleanProtocols(data)
|
|
280
280
|
// result = _.uniq(result, a => a.id)
|
|
281
|
-
// //console.log('
|
|
281
|
+
// //console.log('classProtocols>', className, 'finaldata', data)
|
|
282
282
|
return data
|
|
283
283
|
}
|
|
284
284
|
|
|
@@ -361,7 +361,7 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
361
361
|
return 'manual'
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
//Auto not handled yet for
|
|
364
|
+
//Auto not handled yet for protocols
|
|
365
365
|
// _path = `${seedFolder}/transformer.js`
|
|
366
366
|
// if (await checkFileExists(_path)) {
|
|
367
367
|
// return 'auto'
|
|
@@ -497,7 +497,7 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
497
497
|
let path = `${schemaPath}/classes.js`
|
|
498
498
|
|
|
499
499
|
if ((await checkFileExists(path))) {
|
|
500
|
-
const classes = await (await import(path)).default({
|
|
500
|
+
const classes = await (await import(path)).default({ protocol: this.protocolInstance })
|
|
501
501
|
// this.cache['classes'] = classes
|
|
502
502
|
return classes
|
|
503
503
|
}
|
|
@@ -554,7 +554,7 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
554
554
|
async schemaRaw(props = {}) {
|
|
555
555
|
const { ad } = props
|
|
556
556
|
const a = await this._accessManifestItem({
|
|
557
|
-
item:
|
|
557
|
+
item: ProtocolEnum.Schema,
|
|
558
558
|
})
|
|
559
559
|
// const cacheKey = 'schemaIndexes'
|
|
560
560
|
// if (this.valueInCache(cacheKey)) {
|
|
@@ -563,13 +563,13 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
563
563
|
|
|
564
564
|
const schemaPath = await this._schemaPath()
|
|
565
565
|
|
|
566
|
-
//#TODO: A dynamic schema needs
|
|
566
|
+
//#TODO: A dynamic schema needs protocols to be instantiated per class as to avoid class defintion collusions and edge case.
|
|
567
567
|
// let path = `${schemaPath}/index.js`
|
|
568
568
|
|
|
569
569
|
// if ((await checkFileExists(path))) {
|
|
570
570
|
// let data = (await import(path)).default
|
|
571
|
-
// //#TODO: don't use up
|
|
572
|
-
// data = await data({ ...props, params: this.
|
|
571
|
+
// //#TODO: don't use up protocol params
|
|
572
|
+
// data = await data({ ...props, params: this.protocolInstance.params })
|
|
573
573
|
// return data
|
|
574
574
|
// }
|
|
575
575
|
|
|
@@ -605,8 +605,8 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
605
605
|
}
|
|
606
606
|
|
|
607
607
|
async _schemaPath() {
|
|
608
|
-
//let version = this.
|
|
609
|
-
let version = this.
|
|
608
|
+
//let version = this.currentProtocolVersion ? this.currentProtocolVersion : this.protocolInstanceVersion
|
|
609
|
+
let version = this.protocolInstance.version
|
|
610
610
|
let versions = await this.schemaVersions()
|
|
611
611
|
|
|
612
612
|
if (!version) {
|
|
@@ -677,13 +677,13 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
677
677
|
|
|
678
678
|
|
|
679
679
|
|
|
680
|
-
async
|
|
681
|
-
const cacheKey = '
|
|
680
|
+
async ownProtocols() {
|
|
681
|
+
const cacheKey = 'ownProtocols'
|
|
682
682
|
if (this._valueInCache(cacheKey)) {
|
|
683
683
|
return this._valueInCache(cacheKey)
|
|
684
684
|
}
|
|
685
685
|
|
|
686
|
-
let path = `${this.path}/target/
|
|
686
|
+
let path = `${this.path}/target/protocols.js`
|
|
687
687
|
if (!(await checkFileExists(path))) {
|
|
688
688
|
return null
|
|
689
689
|
}
|
|
@@ -694,8 +694,8 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
694
694
|
return data
|
|
695
695
|
}
|
|
696
696
|
|
|
697
|
-
async
|
|
698
|
-
const cacheKey = '
|
|
697
|
+
async ownProtocolsClass() {
|
|
698
|
+
const cacheKey = 'ownProtocolsClass'
|
|
699
699
|
if (this._valueInCache(cacheKey)) {
|
|
700
700
|
return this._valueInCache(cacheKey)
|
|
701
701
|
}
|
package/src/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import extractProtocol from './manifest/extract/index.js'
|
|
2
2
|
import accessManifest from './manifest/access/index.js'
|
|
3
3
|
import * as ManifestEnums from './manifest/data/1.0.0/enums.js'
|
|
4
4
|
import * as ManifestEnumsV1_1_0 from './manifest/data/1.0.0/enums.js'
|
|
5
5
|
|
|
6
6
|
import buildSchema from './schema/build/index.js'
|
|
7
7
|
import validateSchema from './schema/validate/index.js'
|
|
8
|
-
// import
|
|
9
|
-
import
|
|
8
|
+
// import validateProtocol from './lib/config/validate/protocol/index.js'
|
|
9
|
+
import cleanProtocols from './lib/cleanProtocols.js'
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
import
|
|
12
|
+
import documentProtocol from './document/gateway/all/index.js'
|
|
13
13
|
import generateGithubReadme from './document/gateway/generateGithubReadme/index.js'
|
|
14
14
|
|
|
15
15
|
import Servable from './domain/servable/index.js'
|
|
@@ -17,13 +17,13 @@ const Domain = { Servable }
|
|
|
17
17
|
|
|
18
18
|
export {
|
|
19
19
|
accessManifest,
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
documentProtocol,
|
|
21
|
+
extractProtocol,
|
|
22
22
|
ManifestEnums,
|
|
23
23
|
ManifestEnumsV1_1_0,
|
|
24
24
|
buildSchema,
|
|
25
25
|
validateSchema,
|
|
26
|
-
|
|
26
|
+
cleanProtocols,
|
|
27
27
|
generateGithubReadme,
|
|
28
28
|
Domain
|
|
29
29
|
}
|
|
@@ -8,78 +8,78 @@ const __dirname = dirname(__filename)
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
export default ({ servableConfig }) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
11
|
+
if (servableConfig.adaptedBasic) {
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
// const __filename = callerPath({ depth: 1 })
|
|
15
|
+
// let __dirname = dirname(__filename)
|
|
16
|
+
// __dirname = __dirname.split('file://')[1]
|
|
17
|
+
|
|
18
|
+
// if (!servableConfig.nodeModulesPath) {
|
|
19
|
+
// servableConfig.nodeModulesPath = path.resolve(__dirname, `../node_modules`)
|
|
20
|
+
// }
|
|
21
|
+
|
|
22
|
+
if (!servableConfig.distribution) {
|
|
23
|
+
servableConfig.distribution = {
|
|
24
|
+
enabled: false,
|
|
26
25
|
}
|
|
26
|
+
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if (!servableConfig.distribution.databaseURI) {
|
|
29
|
+
servableConfig.distribution.databaseURI = process.env.SERVABLE_UTILS_DATABASE_URI
|
|
30
|
+
}
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (!servableConfig.system) {
|
|
34
|
+
servableConfig.system = {}
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
37
|
+
if (!servableConfig.system.docker) {
|
|
38
|
+
servableConfig.system.docker = {
|
|
39
|
+
enabled: true,
|
|
40
|
+
environments: ['development']
|
|
42
41
|
}
|
|
42
|
+
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
if (!servableConfig.protocols) {
|
|
45
|
+
servableConfig.protocols = {}
|
|
46
|
+
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
servableConfig.features.local = [
|
|
55
|
-
path.resolve(__dirname, `../../features`),
|
|
56
|
-
...servableConfig.features.local,
|
|
48
|
+
if (!servableConfig.protocols.local || !servableConfig.protocols.local.length) {
|
|
49
|
+
servableConfig.protocols.local = [
|
|
50
|
+
path.resolve('', 'lib/protocols')
|
|
57
51
|
]
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
servableConfig.protocols.local = [
|
|
55
|
+
path.resolve(__dirname, `../../protocols`),
|
|
56
|
+
...servableConfig.protocols.local,
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
if (!servableConfig.rootProtocolPayload) {
|
|
60
|
+
servableConfig.rootProtocolPayload = {
|
|
61
|
+
type: 'app',
|
|
62
|
+
id: 'app',
|
|
63
|
+
// path: path.resolve(__dirname, "./app")
|
|
64
|
+
path: path.resolve('', 'lib/app')
|
|
66
65
|
}
|
|
66
|
+
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
68
|
+
if (!servableConfig.rootProtocolPayload.path) {
|
|
69
|
+
servableConfig.rootProtocolPayload = {
|
|
70
|
+
...servableConfig.rootProtocolPayload,
|
|
71
|
+
path: path.resolve('', 'lib/app')
|
|
72
|
+
// path: path.resolve(__dirname, "./app")
|
|
74
73
|
}
|
|
74
|
+
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
76
|
+
if (!servableConfig.rootProtocolPayload.id || !servableConfig.rootProtocolPayload.type) {
|
|
77
|
+
servableConfig.rootProtocolPayload = {
|
|
78
|
+
...servableConfig.rootProtocolPayload,
|
|
79
|
+
id: 'app',
|
|
80
|
+
type: 'app',
|
|
82
81
|
}
|
|
82
|
+
}
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
servableConfig.adaptedBasic = true
|
|
85
85
|
}
|
|
@@ -80,14 +80,14 @@
|
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
|
-
"id": "
|
|
83
|
+
"id": "protocols",
|
|
84
84
|
"routes": [
|
|
85
85
|
{
|
|
86
86
|
"type": "file",
|
|
87
87
|
"mimeTypes": [
|
|
88
88
|
"text/javascript"
|
|
89
89
|
],
|
|
90
|
-
"path": "
|
|
90
|
+
"path": "protocols"
|
|
91
91
|
}
|
|
92
92
|
]
|
|
93
93
|
}
|
|
@@ -230,4 +230,4 @@
|
|
|
230
230
|
]
|
|
231
231
|
}
|
|
232
232
|
]
|
|
233
|
-
}
|
|
233
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const ProtocolEnum = {
|
|
2
2
|
Index: {
|
|
3
3
|
id: 'index'
|
|
4
4
|
},
|
|
@@ -51,8 +51,8 @@ export const FeatureEnum = {
|
|
|
51
51
|
id: 'index',
|
|
52
52
|
parents: ['class'],
|
|
53
53
|
},
|
|
54
|
-
|
|
55
|
-
id: '
|
|
54
|
+
Protocols: {
|
|
55
|
+
id: 'protocols',
|
|
56
56
|
parents: ['class']
|
|
57
57
|
},
|
|
58
58
|
},
|
|
@@ -154,8 +154,8 @@ export const ClassEnum = {
|
|
|
154
154
|
id: 'index',
|
|
155
155
|
parents: ['class']
|
|
156
156
|
},
|
|
157
|
-
|
|
158
|
-
id: '
|
|
157
|
+
Protocols: {
|
|
158
|
+
id: 'protocols',
|
|
159
159
|
parents: ['class']
|
|
160
160
|
},
|
|
161
161
|
},
|
|
@@ -249,7 +249,7 @@ export const SchemaEnum = {
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
export const DataTemplateType = {
|
|
252
|
-
|
|
252
|
+
Protocol: 'protocol',
|
|
253
253
|
Class: 'class',
|
|
254
254
|
Schema: 'schema',
|
|
255
255
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "root",
|
|
3
|
-
"name": "
|
|
4
|
-
"description": "
|
|
3
|
+
"name": "protocol",
|
|
4
|
+
"description": "protocol",
|
|
5
5
|
"routes": [
|
|
6
6
|
{
|
|
7
7
|
"type": "folder",
|
|
@@ -161,14 +161,14 @@
|
|
|
161
161
|
]
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
|
-
"id": "
|
|
164
|
+
"id": "protocols",
|
|
165
165
|
"routes": [
|
|
166
166
|
{
|
|
167
167
|
"type": "file",
|
|
168
168
|
"mimeTypes": [
|
|
169
169
|
"text/javascript"
|
|
170
170
|
],
|
|
171
|
-
"path": "
|
|
171
|
+
"path": "protocols"
|
|
172
172
|
}
|
|
173
173
|
]
|
|
174
174
|
}
|
|
@@ -500,4 +500,4 @@
|
|
|
500
500
|
]
|
|
501
501
|
}
|
|
502
502
|
]
|
|
503
|
-
}
|
|
503
|
+
}
|
|
@@ -80,14 +80,14 @@
|
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
|
-
"id": "
|
|
83
|
+
"id": "protocols",
|
|
84
84
|
"routes": [
|
|
85
85
|
{
|
|
86
86
|
"type": "file",
|
|
87
87
|
"mimeTypes": [
|
|
88
88
|
"text/javascript"
|
|
89
89
|
],
|
|
90
|
-
"path": "
|
|
90
|
+
"path": "protocols"
|
|
91
91
|
}
|
|
92
92
|
]
|
|
93
93
|
}
|
|
@@ -230,4 +230,4 @@
|
|
|
230
230
|
]
|
|
231
231
|
}
|
|
232
232
|
]
|
|
233
|
-
}
|
|
233
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const ProtocolEnum = {
|
|
2
2
|
Index: {
|
|
3
3
|
id: 'index'
|
|
4
4
|
},
|
|
@@ -57,8 +57,8 @@ export const FeatureEnum = {
|
|
|
57
57
|
id: 'index',
|
|
58
58
|
parents: ['class'],
|
|
59
59
|
},
|
|
60
|
-
|
|
61
|
-
id: '
|
|
60
|
+
Protocols: {
|
|
61
|
+
id: 'protocols',
|
|
62
62
|
parents: ['class']
|
|
63
63
|
},
|
|
64
64
|
},
|
|
@@ -166,8 +166,8 @@ export const ClassEnum = {
|
|
|
166
166
|
id: 'index',
|
|
167
167
|
parents: ['class']
|
|
168
168
|
},
|
|
169
|
-
|
|
170
|
-
id: '
|
|
169
|
+
Protocols: {
|
|
170
|
+
id: 'protocols',
|
|
171
171
|
parents: ['class']
|
|
172
172
|
},
|
|
173
173
|
},
|
|
@@ -261,7 +261,7 @@ export const SchemaEnum = {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
export const DataTemplateType = {
|
|
264
|
-
|
|
264
|
+
Protocol: 'protocol',
|
|
265
265
|
Class: 'class',
|
|
266
266
|
Schema: 'schema',
|
|
267
267
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "root",
|
|
3
|
-
"name": "
|
|
4
|
-
"description": "
|
|
3
|
+
"name": "protocol",
|
|
4
|
+
"description": "protocol",
|
|
5
5
|
"routes": [
|
|
6
6
|
{
|
|
7
7
|
"type": "folder",
|
|
@@ -167,14 +167,14 @@
|
|
|
167
167
|
]
|
|
168
168
|
},
|
|
169
169
|
{
|
|
170
|
-
"id": "
|
|
170
|
+
"id": "protocols",
|
|
171
171
|
"routes": [
|
|
172
172
|
{
|
|
173
173
|
"type": "file",
|
|
174
174
|
"mimeTypes": [
|
|
175
175
|
"text/javascript"
|
|
176
176
|
],
|
|
177
|
-
"path": "
|
|
177
|
+
"path": "protocols"
|
|
178
178
|
}
|
|
179
179
|
]
|
|
180
180
|
}
|
|
@@ -9,9 +9,9 @@ const __filename = fileURLToPath(import.meta.url)
|
|
|
9
9
|
const __dirname = dirname(__filename)
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
export default async ({ id, path:
|
|
12
|
+
export default async ({ id, path: protocolPath }) => {
|
|
13
13
|
let version = "1.0.0"
|
|
14
|
-
let index = await loadIndex(
|
|
14
|
+
let index = await loadIndex(protocolPath)
|
|
15
15
|
if (index && index.apiVersion) {
|
|
16
16
|
version = index.apiVersion
|
|
17
17
|
}
|
|
@@ -19,7 +19,7 @@ export default async ({ id, path: featurePath }) => {
|
|
|
19
19
|
let url = `${basePath}/${version}/${id}.json`
|
|
20
20
|
url = path.resolve(__dirname, url)
|
|
21
21
|
if (!(await checkFileExists(url))) {
|
|
22
|
-
throw { message: `Could not find template data ${id} at path ${
|
|
22
|
+
throw { message: `Could not find template data ${id} at path ${protocolPath}` }
|
|
23
23
|
}
|
|
24
24
|
let data = await importJSONAsync(url)
|
|
25
25
|
return data
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _ from 'underscore'
|
|
2
|
+
import adaptProtocolPayload from '../../../../lib/adaptProtocolPayload.js'
|
|
3
|
+
import cleanProtocols from '../../../../lib/cleanProtocols.js'
|
|
4
|
+
|
|
5
|
+
export default async ({
|
|
6
|
+
protocolsPayloads,
|
|
7
|
+
protocolFactory,
|
|
8
|
+
instancesPathId }) => {
|
|
9
|
+
|
|
10
|
+
let items = []
|
|
11
|
+
|
|
12
|
+
for (var i in protocolsPayloads) {
|
|
13
|
+
const protocolPayload = protocolsPayloads[i]
|
|
14
|
+
const protocol = await protocolFactory({
|
|
15
|
+
protocolPayload,
|
|
16
|
+
instancesPathId
|
|
17
|
+
})
|
|
18
|
+
//#TODO: protocol.loader
|
|
19
|
+
const ownProtocols = await protocol.loader.ownProtocols()
|
|
20
|
+
let a = (ownProtocols && ownProtocols.length) ? ownProtocols.map(adaptProtocolPayload) : null
|
|
21
|
+
if (a && a.length) {
|
|
22
|
+
items = items.concat(a)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
items = _.flatten(items.filter(a => a)).filter(a => a)
|
|
27
|
+
items = cleanProtocols(items)
|
|
28
|
+
return items
|
|
29
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import protocolInClassClassSchema from './protocolInClassClassSchema.js'
|
|
2
|
+
import adaptProtocolPayload from '../../../../lib/adaptProtocolPayload.js'
|
|
3
|
+
import extractProtocolProtocols from './extractProtocolsProtocols.js'
|
|
4
|
+
import cleanProtocols from '../../../../lib/cleanProtocols.js'
|
|
5
|
+
|
|
6
|
+
export default async ({
|
|
7
|
+
protocol,
|
|
8
|
+
classSchema,
|
|
9
|
+
protocolFactory,
|
|
10
|
+
instancesPathId
|
|
11
|
+
}) => {
|
|
12
|
+
|
|
13
|
+
const { className } = classSchema
|
|
14
|
+
|
|
15
|
+
//#TODO: protocol.loader
|
|
16
|
+
let protocolsPayloads = await protocol.loader.classProtocols({
|
|
17
|
+
className,
|
|
18
|
+
withProtocolsProtocols: false
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
if (!protocolsPayloads
|
|
22
|
+
|| !protocolsPayloads.length) {
|
|
23
|
+
return { classSchema }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protocolsPayloads = protocolsPayloads.map(adaptProtocolPayload)
|
|
27
|
+
|
|
28
|
+
if (!protocolsPayloads || !protocolsPayloads.length) {
|
|
29
|
+
return { classSchema }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let protocolsProtocols = await extractProtocolProtocols({
|
|
33
|
+
protocolsPayloads,
|
|
34
|
+
protocolFactory,
|
|
35
|
+
instancesPathId
|
|
36
|
+
})
|
|
37
|
+
protocolsPayloads = cleanProtocols([...protocolsPayloads, ...protocolsProtocols])
|
|
38
|
+
|
|
39
|
+
let _classSchema = { ...classSchema }
|
|
40
|
+
|
|
41
|
+
for (var i in protocolsPayloads) {
|
|
42
|
+
const protocolPayload = protocolsPayloads[i]
|
|
43
|
+
const protocol = await protocolFactory({
|
|
44
|
+
protocolPayload,
|
|
45
|
+
instancesPathId
|
|
46
|
+
})
|
|
47
|
+
_classSchema = await protocolInClassClassSchema({
|
|
48
|
+
protocol,
|
|
49
|
+
classSchema: _classSchema,
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
//#TODO: protocol.loader
|
|
55
|
+
const _class = await protocol.loader.getClass({ className })
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
classSchema: _classSchema,
|
|
59
|
+
protocolsPayloads,
|
|
60
|
+
_class
|
|
61
|
+
}
|
|
62
|
+
}
|