@servable/tools 1.3.0 → 1.4.0
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 +66 -34
- package/src/domain/{featureLoader → protocolLoader}/v1.1.0.js +68 -31
- 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/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,19 +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
|
+
import fs from 'fs'
|
|
16
|
+
import fspath from 'path'
|
|
17
|
+
import semver from 'semver'
|
|
15
18
|
|
|
16
|
-
export default class
|
|
19
|
+
export default class ProtocolLoaderV1_0_0 extends BaseClass {
|
|
17
20
|
|
|
18
21
|
// #region class
|
|
19
22
|
|
|
@@ -239,40 +242,40 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
|
|
|
239
242
|
}
|
|
240
243
|
|
|
241
244
|
|
|
242
|
-
async
|
|
245
|
+
async classProtocols({ className, withProtocolsProtocols = false }) {
|
|
243
246
|
const cacheKey = 'class'
|
|
244
|
-
// //console.log('
|
|
247
|
+
// //console.log('classProtocols>', className, 'enter')
|
|
245
248
|
if (this._valueInCache(cacheKey)) {
|
|
246
249
|
return this._valueInCache(cacheKey)
|
|
247
250
|
}
|
|
248
251
|
const items = []
|
|
249
252
|
const seedMode = await this.classSeedMode({ className })
|
|
250
|
-
// //console.log('
|
|
253
|
+
// //console.log('classProtocols>', className, 'seedmode', seedMode)
|
|
251
254
|
if (seedMode === 'auto') {
|
|
252
255
|
items.push({ id: 'servableautoseedable' })
|
|
253
256
|
}
|
|
254
257
|
const _class = await this.getClass({ className })
|
|
255
258
|
if (!_class) {
|
|
256
|
-
//console.log('
|
|
259
|
+
//console.log('classProtocols>', className, 'no _class')
|
|
257
260
|
return items
|
|
258
261
|
}
|
|
259
262
|
|
|
260
|
-
let data =
|
|
263
|
+
let data = mergeClassProtocols({ items, _class, withProtocolsProtocols })
|
|
261
264
|
const path = `${this.path}/classes/${className.toLowerCase()}/class/protocols.js`
|
|
262
265
|
|
|
263
266
|
if ((await checkFileExists(path))) {
|
|
264
267
|
|
|
265
268
|
let _data = (await import(path)).default
|
|
266
|
-
// //console.log('
|
|
269
|
+
// //console.log('classProtocols>', className, '_data', _data)
|
|
267
270
|
_data = _data ? _data : []
|
|
268
271
|
data = [...data,
|
|
269
272
|
..._data]
|
|
270
273
|
}
|
|
271
274
|
|
|
272
275
|
//this.cache[cacheKey] = data
|
|
273
|
-
data =
|
|
276
|
+
data = cleanProtocols(data)
|
|
274
277
|
// result = _.uniq(result, a => a.id)
|
|
275
|
-
// //console.log('
|
|
278
|
+
// //console.log('classProtocols>', className, 'finaldata', data)
|
|
276
279
|
return data
|
|
277
280
|
}
|
|
278
281
|
|
|
@@ -361,7 +364,7 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
|
|
|
361
364
|
return 'manual'
|
|
362
365
|
}
|
|
363
366
|
|
|
364
|
-
//Auto not handled yet for
|
|
367
|
+
//Auto not handled yet for protocols
|
|
365
368
|
// _path = `${seedFolder}/transformer.js`
|
|
366
369
|
// if (await checkFileExists(_path)) {
|
|
367
370
|
// return 'auto'
|
|
@@ -497,7 +500,7 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
|
|
|
497
500
|
let path = `${schemaPath}/classes.js`
|
|
498
501
|
|
|
499
502
|
if ((await checkFileExists(path))) {
|
|
500
|
-
const classes = await (await import(path)).default({
|
|
503
|
+
const classes = await (await import(path)).default({ protocol: this.protocolInstance })
|
|
501
504
|
// this.cache['classes'] = classes
|
|
502
505
|
return classes
|
|
503
506
|
}
|
|
@@ -554,7 +557,7 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
|
|
|
554
557
|
async schemaRaw(props = {}) {
|
|
555
558
|
const { ad } = props
|
|
556
559
|
const a = await this._accessManifestItem({
|
|
557
|
-
item:
|
|
560
|
+
item: ProtocolEnum.Schema,
|
|
558
561
|
})
|
|
559
562
|
// const cacheKey = 'schemaIndexes'
|
|
560
563
|
// if (this.valueInCache(cacheKey)) {
|
|
@@ -563,13 +566,13 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
|
|
|
563
566
|
|
|
564
567
|
const schemaPath = await this._schemaPath()
|
|
565
568
|
|
|
566
|
-
//#TODO: A dynamic schema needs
|
|
569
|
+
//#TODO: A dynamic schema needs protocols to be instantiated per class as to avoid class defintion collusions and edge case.
|
|
567
570
|
// let path = `${schemaPath}/index.js`
|
|
568
571
|
|
|
569
572
|
// if ((await checkFileExists(path))) {
|
|
570
573
|
// let data = (await import(path)).default
|
|
571
|
-
// //#TODO: don't use up
|
|
572
|
-
// data = await data({ ...props, params: this.
|
|
574
|
+
// //#TODO: don't use up protocol params
|
|
575
|
+
// data = await data({ ...props, params: this.protocolInstance.params })
|
|
573
576
|
// return data
|
|
574
577
|
// }
|
|
575
578
|
|
|
@@ -605,8 +608,8 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
|
|
|
605
608
|
}
|
|
606
609
|
|
|
607
610
|
async _schemaPath() {
|
|
608
|
-
//let version = this.
|
|
609
|
-
let version = this.
|
|
611
|
+
//let version = this.currentProtocolVersion ? this.currentProtocolVersion : this.protocolInstanceVersion
|
|
612
|
+
let version = this.protocolInstance.version
|
|
610
613
|
let versions = await this.schemaVersions()
|
|
611
614
|
|
|
612
615
|
if (!version) {
|
|
@@ -676,8 +679,8 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
|
|
|
676
679
|
|
|
677
680
|
|
|
678
681
|
|
|
679
|
-
async
|
|
680
|
-
const cacheKey = '
|
|
682
|
+
async ownProtocols() {
|
|
683
|
+
const cacheKey = 'ownProtocols'
|
|
681
684
|
if (this._valueInCache(cacheKey)) {
|
|
682
685
|
return this._valueInCache(cacheKey)
|
|
683
686
|
}
|
|
@@ -693,8 +696,8 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
|
|
|
693
696
|
return data
|
|
694
697
|
}
|
|
695
698
|
|
|
696
|
-
async
|
|
697
|
-
const cacheKey = '
|
|
699
|
+
async ownProtocolsClass() {
|
|
700
|
+
const cacheKey = 'ownProtocolsClass'
|
|
698
701
|
if (this._valueInCache(cacheKey)) {
|
|
699
702
|
return this._valueInCache(cacheKey)
|
|
700
703
|
}
|
|
@@ -825,25 +828,54 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
|
|
|
825
828
|
}
|
|
826
829
|
|
|
827
830
|
async routes() {
|
|
828
|
-
const cacheKey = 'routes'
|
|
829
|
-
if (this._valueInCache(cacheKey)) {
|
|
830
|
-
return this._valueInCache(cacheKey)
|
|
831
|
-
}
|
|
832
|
-
|
|
833
831
|
let path = `${this.path}/routes`
|
|
834
832
|
if (!(await checkFileExists(path))) {
|
|
835
833
|
return null
|
|
836
834
|
}
|
|
837
835
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
836
|
+
let data = {}
|
|
837
|
+
const items = await fs.promises.readdir(path)
|
|
838
|
+
if (!items || !items.length) {
|
|
839
|
+
return null
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
for (let i = 0; i < items.length; i++) {
|
|
843
|
+
const item = items[i]
|
|
844
|
+
if (!item) {
|
|
845
|
+
continue
|
|
842
846
|
}
|
|
843
|
-
|
|
847
|
+
|
|
848
|
+
if (item[0] !== 'v') {
|
|
849
|
+
continue
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
if (!semver.valid(semver.coerce(item))) {
|
|
853
|
+
continue
|
|
854
|
+
}
|
|
855
|
+
const __path = fspath.join(path, item)
|
|
856
|
+
const _stat = await fs.promises.stat(__path)
|
|
857
|
+
if (!_stat) {
|
|
858
|
+
continue
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
const isDir = _stat.isDirectory()
|
|
862
|
+
if (!isDir) {
|
|
863
|
+
continue
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
let _data = (await directoryGlob({
|
|
867
|
+
path: `${__path}/**/*.js`, globOptions: {
|
|
868
|
+
mark: true,
|
|
869
|
+
ignore: ['**/lib/**']
|
|
870
|
+
}
|
|
871
|
+
}))
|
|
872
|
+
data[item] = _data
|
|
873
|
+
}
|
|
874
|
+
|
|
844
875
|
return data
|
|
845
876
|
}
|
|
846
877
|
|
|
878
|
+
|
|
847
879
|
async liveQueries() {
|
|
848
880
|
let path = `${this.path}/livequeries`
|
|
849
881
|
if (!(await checkFileExists(path))) {
|
|
@@ -1,19 +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
|
+
import fs from 'fs'
|
|
16
|
+
import fspath from 'path'
|
|
17
|
+
import semver from 'semver'
|
|
15
18
|
|
|
16
|
-
export default class
|
|
19
|
+
export default class ProtocolLoaderV1_1_0 extends BaseClass {
|
|
17
20
|
|
|
18
21
|
// #region class
|
|
19
22
|
|
|
@@ -242,40 +245,40 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
242
245
|
}
|
|
243
246
|
|
|
244
247
|
|
|
245
|
-
async
|
|
248
|
+
async classProtocols({ className, withProtocolsProtocols = false }) {
|
|
246
249
|
const cacheKey = 'class'
|
|
247
|
-
// //console.log('
|
|
250
|
+
// //console.log('classProtocols>', className, 'enter')
|
|
248
251
|
if (this._valueInCache(cacheKey)) {
|
|
249
252
|
return this._valueInCache(cacheKey)
|
|
250
253
|
}
|
|
251
254
|
const items = []
|
|
252
255
|
const seedMode = await this.classSeedMode({ className })
|
|
253
|
-
// //console.log('
|
|
256
|
+
// //console.log('classProtocols>', className, 'seedmode', seedMode)
|
|
254
257
|
if (seedMode === 'auto') {
|
|
255
258
|
items.push({ id: 'servableautoseedable' })
|
|
256
259
|
}
|
|
257
260
|
const _class = await this.getClass({ className })
|
|
258
261
|
if (!_class) {
|
|
259
|
-
//console.log('
|
|
262
|
+
//console.log('classProtocols>', className, 'no _class')
|
|
260
263
|
return items
|
|
261
264
|
}
|
|
262
265
|
|
|
263
|
-
let data =
|
|
264
|
-
const path = `${this.path}/models/${className.toLowerCase()}/
|
|
266
|
+
let data = mergeClassProtocols({ items, _class, withProtocolsProtocols })
|
|
267
|
+
const path = `${this.path}/models/${className.toLowerCase()}/protocols.js`
|
|
265
268
|
|
|
266
269
|
if ((await checkFileExists(path))) {
|
|
267
270
|
|
|
268
271
|
let _data = (await import(path)).default
|
|
269
|
-
// //console.log('
|
|
272
|
+
// //console.log('classProtocols>', className, '_data', _data)
|
|
270
273
|
_data = _data ? _data : []
|
|
271
274
|
data = [...data,
|
|
272
275
|
..._data]
|
|
273
276
|
}
|
|
274
277
|
|
|
275
278
|
//this.cache[cacheKey] = data
|
|
276
|
-
data =
|
|
279
|
+
data = cleanProtocols(data)
|
|
277
280
|
// result = _.uniq(result, a => a.id)
|
|
278
|
-
// //console.log('
|
|
281
|
+
// //console.log('classProtocols>', className, 'finaldata', data)
|
|
279
282
|
return data
|
|
280
283
|
}
|
|
281
284
|
|
|
@@ -358,7 +361,7 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
358
361
|
return 'manual'
|
|
359
362
|
}
|
|
360
363
|
|
|
361
|
-
//Auto not handled yet for
|
|
364
|
+
//Auto not handled yet for protocols
|
|
362
365
|
// _path = `${seedFolder}/transformer.js`
|
|
363
366
|
// if (await checkFileExists(_path)) {
|
|
364
367
|
// return 'auto'
|
|
@@ -494,7 +497,7 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
494
497
|
let path = `${schemaPath}/classes.js`
|
|
495
498
|
|
|
496
499
|
if ((await checkFileExists(path))) {
|
|
497
|
-
const classes = await (await import(path)).default({
|
|
500
|
+
const classes = await (await import(path)).default({ protocol: this.protocolInstance })
|
|
498
501
|
// this.cache['classes'] = classes
|
|
499
502
|
return classes
|
|
500
503
|
}
|
|
@@ -551,7 +554,7 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
551
554
|
async schemaRaw(props = {}) {
|
|
552
555
|
const { ad } = props
|
|
553
556
|
const a = await this._accessManifestItem({
|
|
554
|
-
item:
|
|
557
|
+
item: ProtocolEnum.Schema,
|
|
555
558
|
})
|
|
556
559
|
// const cacheKey = 'schemaIndexes'
|
|
557
560
|
// if (this.valueInCache(cacheKey)) {
|
|
@@ -560,13 +563,13 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
560
563
|
|
|
561
564
|
const schemaPath = await this._schemaPath()
|
|
562
565
|
|
|
563
|
-
//#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.
|
|
564
567
|
// let path = `${schemaPath}/index.js`
|
|
565
568
|
|
|
566
569
|
// if ((await checkFileExists(path))) {
|
|
567
570
|
// let data = (await import(path)).default
|
|
568
|
-
// //#TODO: don't use up
|
|
569
|
-
// data = await data({ ...props, params: this.
|
|
571
|
+
// //#TODO: don't use up protocol params
|
|
572
|
+
// data = await data({ ...props, params: this.protocolInstance.params })
|
|
570
573
|
// return data
|
|
571
574
|
// }
|
|
572
575
|
|
|
@@ -602,8 +605,8 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
602
605
|
}
|
|
603
606
|
|
|
604
607
|
async _schemaPath() {
|
|
605
|
-
//let version = this.
|
|
606
|
-
let version = this.
|
|
608
|
+
//let version = this.currentProtocolVersion ? this.currentProtocolVersion : this.protocolInstanceVersion
|
|
609
|
+
let version = this.protocolInstance.version
|
|
607
610
|
let versions = await this.schemaVersions()
|
|
608
611
|
|
|
609
612
|
if (!version) {
|
|
@@ -674,13 +677,13 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
674
677
|
|
|
675
678
|
|
|
676
679
|
|
|
677
|
-
async
|
|
678
|
-
const cacheKey = '
|
|
680
|
+
async ownProtocols() {
|
|
681
|
+
const cacheKey = 'ownProtocols'
|
|
679
682
|
if (this._valueInCache(cacheKey)) {
|
|
680
683
|
return this._valueInCache(cacheKey)
|
|
681
684
|
}
|
|
682
685
|
|
|
683
|
-
let path = `${this.path}/target/
|
|
686
|
+
let path = `${this.path}/target/protocols.js`
|
|
684
687
|
if (!(await checkFileExists(path))) {
|
|
685
688
|
return null
|
|
686
689
|
}
|
|
@@ -691,8 +694,8 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
691
694
|
return data
|
|
692
695
|
}
|
|
693
696
|
|
|
694
|
-
async
|
|
695
|
-
const cacheKey = '
|
|
697
|
+
async ownProtocolsClass() {
|
|
698
|
+
const cacheKey = 'ownProtocolsClass'
|
|
696
699
|
if (this._valueInCache(cacheKey)) {
|
|
697
700
|
return this._valueInCache(cacheKey)
|
|
698
701
|
}
|
|
@@ -830,16 +833,50 @@ export default class FeatureLoaderV1_1_0 extends BaseClass {
|
|
|
830
833
|
return null
|
|
831
834
|
}
|
|
832
835
|
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
836
|
+
let data = {}
|
|
837
|
+
const items = await fs.promises.readdir(path)
|
|
838
|
+
if (!items || !items.length) {
|
|
839
|
+
return null
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
for (let i = 0; i < items.length; i++) {
|
|
843
|
+
const item = items[i]
|
|
844
|
+
if (!item) {
|
|
845
|
+
continue
|
|
837
846
|
}
|
|
838
|
-
|
|
847
|
+
|
|
848
|
+
if (item[0] !== 'v') {
|
|
849
|
+
continue
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
if (!semver.valid(semver.coerce(item))) {
|
|
853
|
+
continue
|
|
854
|
+
}
|
|
855
|
+
const __path = fspath.join(path, item)
|
|
856
|
+
const _stat = await fs.promises.stat(__path)
|
|
857
|
+
if (!_stat) {
|
|
858
|
+
continue
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
const isDir = _stat.isDirectory()
|
|
862
|
+
if (!isDir) {
|
|
863
|
+
continue
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
let _data = (await directoryGlob({
|
|
867
|
+
path: `${__path}/**/*.js`, globOptions: {
|
|
868
|
+
mark: true,
|
|
869
|
+
ignore: ['**/lib/**']
|
|
870
|
+
}
|
|
871
|
+
}))
|
|
872
|
+
data[item] = _data
|
|
873
|
+
}
|
|
874
|
+
|
|
839
875
|
return data
|
|
840
876
|
}
|
|
841
877
|
|
|
842
878
|
async targetRoutes() {
|
|
879
|
+
//#TODO:
|
|
843
880
|
let path = `${this.path}/target/routes`
|
|
844
881
|
if (!(await checkFileExists(path))) {
|
|
845
882
|
return null
|
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
|
}
|