@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,17 +1,17 @@
|
|
|
1
1
|
import gitUrlParse from "git-url-parse"
|
|
2
|
-
import {
|
|
2
|
+
import { ProtocolEnum } from "../../../../manifest/data/1.0.0/enums.js"
|
|
3
3
|
// import append from "../utils/builder/append.js"
|
|
4
4
|
import access from '../../../../manifest/access/index.js'
|
|
5
|
-
import buildSeed from '../../chunks/build/
|
|
6
|
-
import
|
|
7
|
-
import buildConfig from '../../chunks/build/
|
|
8
|
-
import buildLiveClasses from '../../chunks/build/
|
|
9
|
-
import buildAfterInit from '../../chunks/build/
|
|
10
|
-
import buildBeforeInit from '../../chunks/build/
|
|
11
|
-
import buildFunctions from '../../chunks/build/
|
|
12
|
-
import buildSchema from '../../chunks/build/
|
|
13
|
-
import buildSystem from '../../chunks/build/
|
|
14
|
-
import buildLib from '../../chunks/build/
|
|
5
|
+
import buildSeed from '../../chunks/build/protocol/seed.js'
|
|
6
|
+
import buildProtocolClass from '../../chunks/build/protocol/class.js'
|
|
7
|
+
import buildConfig from '../../chunks/build/protocol/config.js'
|
|
8
|
+
import buildLiveClasses from '../../chunks/build/protocol/liveClasses.js'
|
|
9
|
+
import buildAfterInit from '../../chunks/build/protocol/afterInit.js'
|
|
10
|
+
import buildBeforeInit from '../../chunks/build/protocol/beforeInit.js'
|
|
11
|
+
import buildFunctions from '../../chunks/build/protocol/functions.js'
|
|
12
|
+
import buildSchema from '../../chunks/build/protocol/schema.js'
|
|
13
|
+
import buildSystem from '../../chunks/build/protocol/system.js'
|
|
14
|
+
import buildLib from '../../chunks/build/protocol/lib.js'
|
|
15
15
|
import buildGithubTags from './chunks/githubTags.js'
|
|
16
16
|
import buildRegistry from './chunks/registry.js'
|
|
17
17
|
import buildInstall from './chunks/install.js'
|
|
@@ -19,7 +19,7 @@ import buildUsage from './chunks/usage.js'
|
|
|
19
19
|
import buildFooter from './chunks/footer.js'
|
|
20
20
|
import buildPackages from './chunks/packages.js'
|
|
21
21
|
import buildDependencies from './chunks/dependencies/index.js'
|
|
22
|
-
import buildTriggers from '../../chunks/build/
|
|
22
|
+
import buildTriggers from '../../chunks/build/protocol/triggers.js'
|
|
23
23
|
import buildAdapters from './chunks/adapters.js'
|
|
24
24
|
import buildApis from './chunks/apis.js'
|
|
25
25
|
import buildCategories from './chunks/categories.js'
|
|
@@ -35,7 +35,7 @@ export default async props => {
|
|
|
35
35
|
let packages
|
|
36
36
|
let version = null
|
|
37
37
|
let index = await access({
|
|
38
|
-
item:
|
|
38
|
+
item: ProtocolEnum.Index,
|
|
39
39
|
extraction,
|
|
40
40
|
path
|
|
41
41
|
})
|
|
@@ -45,7 +45,7 @@ export default async props => {
|
|
|
45
45
|
mainPackage = index.data.module
|
|
46
46
|
const { name, description, id, } = mainPackage
|
|
47
47
|
version = mainPackage.version
|
|
48
|
-
payload.push({ h1: `${name} *
|
|
48
|
+
payload.push({ h1: `${name} *protocol for Servable*` })
|
|
49
49
|
payload.push({ p: `**${id}**` })
|
|
50
50
|
|
|
51
51
|
npmPackageName = id
|
|
@@ -62,9 +62,9 @@ export default async props => {
|
|
|
62
62
|
payload = payload.concat(chunks.githubTags.payload)
|
|
63
63
|
|
|
64
64
|
let icon = await access({
|
|
65
|
-
item:
|
|
66
|
-
// variant:
|
|
67
|
-
mimeType:
|
|
65
|
+
item: ProtocolEnum.Assets.Icon,
|
|
66
|
+
// variant: ProtocolEnum.Assets.Icon.variants.x2,
|
|
67
|
+
mimeType: ProtocolEnum.Assets.Icon.mimeTypes.SVG,
|
|
68
68
|
extraction,
|
|
69
69
|
path
|
|
70
70
|
})
|
|
@@ -81,9 +81,9 @@ export default async props => {
|
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
83
|
icon = await access({
|
|
84
|
-
item:
|
|
85
|
-
variant:
|
|
86
|
-
mimeType:
|
|
84
|
+
item: ProtocolEnum.Assets.Icon,
|
|
85
|
+
variant: ProtocolEnum.Assets.Icon.variants.x2,
|
|
86
|
+
mimeType: ProtocolEnum.Assets.Icon.mimeTypes.PNG,
|
|
87
87
|
extraction,
|
|
88
88
|
path
|
|
89
89
|
})
|
|
@@ -168,9 +168,9 @@ export default async props => {
|
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
|
|
171
|
-
chunks.
|
|
172
|
-
payload.push({ h2: chunks.
|
|
173
|
-
payload = payload.concat(chunks.
|
|
171
|
+
chunks.protocolClass = await buildProtocolClass({ path })
|
|
172
|
+
payload.push({ h2: chunks.protocolClass.name })
|
|
173
|
+
payload = payload.concat(chunks.protocolClass.payload)
|
|
174
174
|
|
|
175
175
|
chunks.beforeInit = await buildBeforeInit({ path })
|
|
176
176
|
payload.push({ h2: chunks.beforeInit.name })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import protocolApiVersion from '../../../lib/protocolApiVersion.js'
|
|
2
2
|
import _path from "path"
|
|
3
3
|
import { fileURLToPath } from "url"
|
|
4
4
|
import { dirname } from "path"
|
|
@@ -8,7 +8,7 @@ const __dirname = dirname(__filename)
|
|
|
8
8
|
|
|
9
9
|
export default async props => {
|
|
10
10
|
const { path, } = props
|
|
11
|
-
const apiVersion = await
|
|
11
|
+
const apiVersion = await protocolApiVersion({ path })
|
|
12
12
|
if (!apiVersion) {
|
|
13
13
|
throw new Error('No api version found')
|
|
14
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import protocolApiVersion from '../../../lib/protocolApiVersion.js'
|
|
2
2
|
import _path from "path"
|
|
3
3
|
import { fileURLToPath } from "url"
|
|
4
4
|
import { dirname } from "path"
|
|
@@ -8,7 +8,7 @@ const __dirname = dirname(__filename)
|
|
|
8
8
|
|
|
9
9
|
export default async props => {
|
|
10
10
|
const { path, } = props
|
|
11
|
-
const apiVersion = await
|
|
11
|
+
const apiVersion = await protocolApiVersion({ path })
|
|
12
12
|
if (!apiVersion) {
|
|
13
13
|
throw new Error('No api version found')
|
|
14
14
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import getModuleDir from '../../../lib/getModuleDir.js'
|
|
2
2
|
|
|
3
3
|
export default (item) => {
|
|
4
|
-
const
|
|
5
|
-
if (!
|
|
4
|
+
const protocolPath = getModuleDir(item)
|
|
5
|
+
if (!protocolPath) {
|
|
6
6
|
return null
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
return `${
|
|
9
|
+
return `${protocolPath}/src`
|
|
10
10
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import protocolPath from './protocolPath.js'
|
|
2
|
+
|
|
3
|
+
import _ from 'underscore'
|
|
4
|
+
import ProtocolClass from '../index.js'
|
|
5
|
+
|
|
6
|
+
export default async ({
|
|
7
|
+
protocolPayload,
|
|
8
|
+
servableConfig,
|
|
9
|
+
protocolsCache,
|
|
10
|
+
instancesPathId
|
|
11
|
+
}) => {
|
|
12
|
+
|
|
13
|
+
const { id, module, version, type, } = protocolPayload
|
|
14
|
+
let path = protocolPayload.path
|
|
15
|
+
if (!path) {
|
|
16
|
+
path = await protocolPath({
|
|
17
|
+
id,
|
|
18
|
+
module,
|
|
19
|
+
version,
|
|
20
|
+
servableConfig
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!path) {
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let protocol = null
|
|
29
|
+
const valueInCache = cacheValue({
|
|
30
|
+
protocolPayload: {
|
|
31
|
+
...protocolPayload,
|
|
32
|
+
path
|
|
33
|
+
}, protocolsCache
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
if (valueInCache) {
|
|
37
|
+
protocol = valueInCache.protocol
|
|
38
|
+
} else {
|
|
39
|
+
protocol = new ProtocolClass({ id, type })
|
|
40
|
+
protocolsCache.push({
|
|
41
|
+
id,
|
|
42
|
+
module,
|
|
43
|
+
version,
|
|
44
|
+
path,
|
|
45
|
+
protocol
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await protocol.addInstanceIfNeeded({
|
|
50
|
+
protocolPayload: {
|
|
51
|
+
...protocolPayload,
|
|
52
|
+
path
|
|
53
|
+
},
|
|
54
|
+
instancesPathId,
|
|
55
|
+
servableConfig
|
|
56
|
+
})
|
|
57
|
+
// console.log(instancesPathId)
|
|
58
|
+
return protocol
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const cacheValue = ({ protocolPayload, protocolsCache }) => {
|
|
63
|
+
const { id, module, version, path } = protocolPayload
|
|
64
|
+
const candidates = _.where(protocolsCache, {
|
|
65
|
+
id,
|
|
66
|
+
// version,
|
|
67
|
+
// path,
|
|
68
|
+
// module
|
|
69
|
+
})
|
|
70
|
+
return (candidates && candidates.length) ? candidates[0] : null
|
|
71
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
import checkFileExists from '../../../lib/checkFileExists.js'
|
|
3
|
+
import absoluteModuleSrcPath from './absoluteModuleSrcPath.js'
|
|
4
|
+
|
|
5
|
+
export default async (props) => {
|
|
6
|
+
const { id, module, servableConfig } = props
|
|
7
|
+
let protocolPath = null
|
|
8
|
+
|
|
9
|
+
if (typeof module === 'object'
|
|
10
|
+
&& Object.keys(module).length) {
|
|
11
|
+
const item = Object.keys(module)[0]
|
|
12
|
+
if (item) {
|
|
13
|
+
protocolPath = absoluteModuleSrcPath(item)
|
|
14
|
+
return protocolPath
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (servableConfig.protocols
|
|
19
|
+
&& servableConfig.protocols.external
|
|
20
|
+
&& servableConfig.protocols.external[id]) {
|
|
21
|
+
protocolPath = absoluteModuleSrcPath(servableConfig.protocols.external[id])
|
|
22
|
+
return protocolPath
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (servableConfig.protocols
|
|
26
|
+
&& servableConfig.protocols.local
|
|
27
|
+
&& servableConfig.protocols.local.length) {
|
|
28
|
+
|
|
29
|
+
let i = 0
|
|
30
|
+
do {
|
|
31
|
+
const repo = servableConfig.protocols.local[i]
|
|
32
|
+
protocolPath = `${repo}/${id}`
|
|
33
|
+
if ((await checkFileExists(protocolPath))) {
|
|
34
|
+
return protocolPath
|
|
35
|
+
}
|
|
36
|
+
i++
|
|
37
|
+
} while (i < servableConfig.protocols.local.length)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null
|
|
41
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import semver from 'semver'
|
|
2
|
-
import * as
|
|
2
|
+
import * as protocolInstanceFactory from '../protocolInstance/factory/index.js'
|
|
3
3
|
|
|
4
|
-
export default class
|
|
4
|
+
export default class Protocol {
|
|
5
5
|
_id = null
|
|
6
6
|
_type = null
|
|
7
7
|
|
|
@@ -19,11 +19,11 @@ export default class Feature {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
async addInstanceIfNeeded({
|
|
22
|
-
|
|
22
|
+
protocolPayload,
|
|
23
23
|
servableConfig,
|
|
24
24
|
instancesPathId }) {
|
|
25
|
-
return
|
|
26
|
-
|
|
25
|
+
return protocolInstanceFactory.getWithCache({
|
|
26
|
+
protocolPayload,
|
|
27
27
|
servableConfig,
|
|
28
28
|
instancesPathId,
|
|
29
29
|
instances: this.instances
|
|
@@ -41,7 +41,7 @@ export default class Feature {
|
|
|
41
41
|
instancesClassesPayloads() {
|
|
42
42
|
return this.instances.map(instance =>
|
|
43
43
|
({
|
|
44
|
-
|
|
44
|
+
protocolPayload: instance.protocolPayload,
|
|
45
45
|
instancesPathId: instance.instancesPathId,
|
|
46
46
|
instancesPathIdString: instance._instancesPathIdString,
|
|
47
47
|
instance
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
export default ({ instancesPathId,
|
|
2
|
+
export default ({ instancesPathId, currentProtocolId }) => {
|
|
3
3
|
const a = instancesPathId.map(i => {
|
|
4
4
|
switch (i.type) {
|
|
5
5
|
case 'class': {
|
|
6
6
|
return `🌸 ${i.value.className}`
|
|
7
7
|
}
|
|
8
|
-
case '
|
|
8
|
+
case 'protocol': {
|
|
9
9
|
return `🐝 ${i.value.id}`
|
|
10
10
|
}
|
|
11
11
|
default:
|
|
@@ -13,5 +13,5 @@ export default ({ instancesPathId, currentFeatureId }) => {
|
|
|
13
13
|
}
|
|
14
14
|
}).filter(a => a).join(' ')
|
|
15
15
|
|
|
16
|
-
return `${a} 🐝 ${
|
|
16
|
+
return `${a} 🐝 ${currentProtocolId}`
|
|
17
17
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as ProtocolLoaderFactory from '../../protocolLoader/factory/index.js'
|
|
2
|
+
|
|
3
|
+
export default async ({ protocolPayload }) => {
|
|
4
|
+
const { path, version } = protocolPayload
|
|
5
|
+
const _loader = await ProtocolLoaderFactory.getByPathAndVersion({ path, version })
|
|
6
|
+
return _loader
|
|
7
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import getLoaderWithPayload from './getLoaderWithPayload.js'
|
|
2
|
-
import
|
|
2
|
+
import ProtocolInstanceClass from '../index.js'
|
|
3
3
|
import instancesWithPath from './instancesWithPath.js'
|
|
4
4
|
|
|
5
5
|
export const getWithCache = async ({
|
|
6
|
-
|
|
6
|
+
protocolPayload,
|
|
7
7
|
servableConfig,
|
|
8
8
|
instancesPathId,
|
|
9
9
|
instances,
|
|
10
10
|
}) => {
|
|
11
11
|
|
|
12
|
-
const { id, module, version, path } =
|
|
12
|
+
const { id, module, version, path } = protocolPayload
|
|
13
13
|
|
|
14
14
|
if (!instancesPathId || !instancesPathId.length) {
|
|
15
15
|
return null
|
|
@@ -21,7 +21,7 @@ export const getWithCache = async ({
|
|
|
21
21
|
switch (type) {
|
|
22
22
|
case 'class': {
|
|
23
23
|
} break
|
|
24
|
-
case '
|
|
24
|
+
case 'protocol': {
|
|
25
25
|
if (instancePathOfInterest.value.id === 'app') {
|
|
26
26
|
className = '_root'
|
|
27
27
|
} break
|
|
@@ -41,9 +41,9 @@ export const getWithCache = async ({
|
|
|
41
41
|
return instance
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const loader = await getLoaderWithPayload({
|
|
45
|
-
instance = new
|
|
46
|
-
|
|
44
|
+
const loader = await getLoaderWithPayload({ protocolPayload })
|
|
45
|
+
instance = new ProtocolInstanceClass({
|
|
46
|
+
protocolPayload,
|
|
47
47
|
className,
|
|
48
48
|
loader,
|
|
49
49
|
instancesPathId
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import instancesPathIdUniqueId from '../
|
|
1
|
+
import instancesPathIdUniqueId from '../protocol/lib/instancesPathIdUniqueId.js'
|
|
2
2
|
import semver from 'semver'
|
|
3
3
|
const DEFAULT_VERSION = "1.0.0"
|
|
4
4
|
const DEFAULT_MIMIUM_COMAPATIBLE_VERSION = "0.0.0"
|
|
5
5
|
|
|
6
|
-
export default class
|
|
6
|
+
export default class ProtocolInstance {
|
|
7
7
|
_className = null
|
|
8
8
|
_params = {}
|
|
9
9
|
_instancesPathId = []
|
|
@@ -15,7 +15,7 @@ export default class FeatureInstance {
|
|
|
15
15
|
_module = {}
|
|
16
16
|
_path = null
|
|
17
17
|
_id = null
|
|
18
|
-
|
|
18
|
+
_protocolPayload = null
|
|
19
19
|
_schema = {
|
|
20
20
|
classes: {
|
|
21
21
|
managed: [],
|
|
@@ -27,18 +27,18 @@ export default class FeatureInstance {
|
|
|
27
27
|
const {
|
|
28
28
|
className,
|
|
29
29
|
instancesPathId,
|
|
30
|
-
|
|
30
|
+
protocolPayload,
|
|
31
31
|
loader
|
|
32
32
|
} = props
|
|
33
33
|
this._loader = loader
|
|
34
|
-
this._loader.
|
|
34
|
+
this._loader._protocolInstance = this
|
|
35
35
|
this._className = className
|
|
36
|
-
this._params = { ...
|
|
37
|
-
this._path =
|
|
38
|
-
this._id =
|
|
39
|
-
this.
|
|
36
|
+
this._params = { ...protocolPayload.params }
|
|
37
|
+
this._path = protocolPayload.path
|
|
38
|
+
this._id = protocolPayload.id
|
|
39
|
+
this._protocolPayload = { ...protocolPayload }
|
|
40
40
|
this._instancesPathId = [...instancesPathId]
|
|
41
|
-
this._instancesPathIdString = instancesPathIdUniqueId({ instancesPathId,
|
|
41
|
+
this._instancesPathIdString = instancesPathIdUniqueId({ instancesPathId, currentProtocolId: this._id })
|
|
42
42
|
console.log(this._instancesPathIdString)
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -89,17 +89,17 @@ export default class FeatureInstance {
|
|
|
89
89
|
this._params = value
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
get
|
|
93
|
-
return this.
|
|
92
|
+
get protocolPayload() {
|
|
93
|
+
return this._protocolPayload
|
|
94
94
|
}
|
|
95
|
-
set
|
|
96
|
-
this.
|
|
95
|
+
set protocolPayload(value) {
|
|
96
|
+
this._protocolPayload = value
|
|
97
97
|
}
|
|
98
98
|
// #endregion
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
toString() {
|
|
102
|
-
return `
|
|
102
|
+
return `ProtocolInstance: ${this.instancesPathIdString} (${this.path})`
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
|
|
@@ -181,7 +181,7 @@ export default class FeatureInstance {
|
|
|
181
181
|
|
|
182
182
|
set loader(value) {
|
|
183
183
|
this._loader = value
|
|
184
|
-
this._loader.
|
|
184
|
+
this._loader.protocol = this
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
get schema() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import extract from '../../manifest/extract/index.js'
|
|
2
|
-
import { DataTemplateType,
|
|
2
|
+
import { DataTemplateType, ProtocolEnum } from '../../manifest/data/1.0.0/enums.js'
|
|
3
3
|
import sanitizePath from '../../lib/sanitizePath.js'
|
|
4
4
|
import importJSDefault from './lib/importJSDefault.js'
|
|
5
5
|
import importJSONDefault from './lib/importJSONDefault.js'
|
|
@@ -7,13 +7,13 @@ import access from '../../manifest/access/index.js'
|
|
|
7
7
|
import fs from 'fs'
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
export default class
|
|
10
|
+
export default class ProtocolLoader {
|
|
11
11
|
_cache = {}
|
|
12
12
|
_extraClasses = {}
|
|
13
13
|
_extraction = null
|
|
14
14
|
|
|
15
15
|
_path = null
|
|
16
|
-
|
|
16
|
+
_protocolInstance = null
|
|
17
17
|
|
|
18
18
|
constructor(props) {
|
|
19
19
|
const { path, extraClasses } = props
|
|
@@ -35,8 +35,8 @@ export default class FeatureLoader {
|
|
|
35
35
|
set extraction(value) { this._extraction = value }
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
get
|
|
39
|
-
set
|
|
38
|
+
get protocolInstance() { return this._protocolInstance }
|
|
39
|
+
set protocolInstance(value) { this._protocolInstance = value }
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ export default class FeatureLoader {
|
|
|
44
44
|
try {
|
|
45
45
|
this.extraction = await extract({
|
|
46
46
|
path: `${sanitizePath(this.path)}`,
|
|
47
|
-
dataTemplateType: DataTemplateType.
|
|
47
|
+
dataTemplateType: DataTemplateType.Protocol
|
|
48
48
|
})
|
|
49
49
|
// const e = JSON.stringify(this.extraction)
|
|
50
50
|
// console.log(this.extraction)
|
|
@@ -53,11 +53,11 @@ export default class FeatureLoader {
|
|
|
53
53
|
// console.log(a)
|
|
54
54
|
|
|
55
55
|
// const schemaAa = await access({
|
|
56
|
-
// item:
|
|
56
|
+
// item: ProtocolEnum.Schema,
|
|
57
57
|
// extraction: this.extraction,
|
|
58
58
|
// })
|
|
59
59
|
// const schemaB = await access({
|
|
60
|
-
// item:
|
|
60
|
+
// item: ProtocolEnum.Schema,
|
|
61
61
|
// extraction: a,
|
|
62
62
|
// })
|
|
63
63
|
// console.log(schemaAa, schemaB)
|
|
@@ -83,7 +83,7 @@ export default class FeatureLoader {
|
|
|
83
83
|
|
|
84
84
|
async getModule() {
|
|
85
85
|
const mo = await this._accessManifestItem({
|
|
86
|
-
item:
|
|
86
|
+
item: ProtocolEnum.Index,
|
|
87
87
|
})
|
|
88
88
|
return mo.data.module
|
|
89
89
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import cleanProtocols from "../../../lib/cleanProtocols.js"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export default ({ items = [], _class, withProtocolsProtocols }) => {
|
|
5
|
+
let classProtocols = _class.protocols ? _class.protocols : []
|
|
6
|
+
if (!withProtocolsProtocols) {
|
|
7
|
+
return cleanProtocols([...items, ...classProtocols])
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return cleanProtocols([...items])
|
|
11
|
+
|
|
12
|
+
// let inheritedProtocols = _class.inheritedProtocols ? _class.inheritedProtocols : []
|
|
13
|
+
// return cleanProtocols([
|
|
14
|
+
// ...classProtocols,
|
|
15
|
+
// ...inheritedProtocols
|
|
16
|
+
// ])
|
|
17
|
+
}
|