@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.
Files changed (114) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/src/config/candidates/index.js +5 -5
  4. package/src/config/candidates/{featureCandidates → protocolCandidates}/index.js +5 -5
  5. package/src/config/validate/index.js +2 -2
  6. package/src/config/validate/{feature → protocol}/index.js +1 -1
  7. package/src/document/{1.1.0/all/build/feature → 1.0.0/all/build/protocol}/index.js +23 -23
  8. package/src/document/1.0.0/all/index.js +4 -4
  9. package/src/document/1.0.0/all/write/index.js +3 -3
  10. package/src/document/1.0.0/chunks/build/class/class.js +2 -2
  11. package/src/document/1.0.0/chunks/build/class/functions.js +2 -2
  12. package/src/document/1.0.0/chunks/build/class/lib.js +2 -2
  13. package/src/document/1.0.0/chunks/build/class/seed.js +2 -2
  14. package/src/document/1.0.0/chunks/build/class/triggers.js +2 -2
  15. package/src/document/1.0.0/chunks/build/{feature → protocol}/afterInit.js +2 -2
  16. package/src/document/{1.1.0/chunks/build/feature → 1.0.0/chunks/build/protocol}/beforeInit.js +2 -2
  17. package/src/document/1.0.0/chunks/build/{feature → protocol}/class.js +3 -3
  18. package/src/document/{1.1.0/chunks/build/feature → 1.0.0/chunks/build/protocol}/config.js +2 -2
  19. package/src/document/{1.1.0/chunks/build/feature → 1.0.0/chunks/build/protocol}/functions.js +2 -2
  20. package/src/document/{1.1.0/chunks/build/feature → 1.0.0/chunks/build/protocol}/lib.js +2 -2
  21. package/src/document/1.0.0/chunks/build/{feature → protocol}/liveClasses.js +2 -2
  22. package/src/document/1.0.0/chunks/build/{feature → protocol}/schema.js +2 -2
  23. package/src/document/1.0.0/chunks/build/{feature → protocol}/seed.js +2 -2
  24. package/src/document/1.0.0/chunks/build/{feature → protocol}/system.js +2 -2
  25. package/src/document/{1.1.0/chunks/build/feature → 1.0.0/chunks/build/protocol}/triggers.js +2 -2
  26. package/src/document/1.0.0/generateGithubReadme/build/chunks/dependencies/index.js +2 -2
  27. package/src/document/1.0.0/generateGithubReadme/build/chunks/footer.js +1 -1
  28. package/src/document/1.0.0/generateGithubReadme/build/chunks/githubTags.js +3 -3
  29. package/src/document/1.0.0/generateGithubReadme/build/chunks/registry.js +2 -2
  30. package/src/document/1.0.0/generateGithubReadme/build/chunks/usage.js +1 -1
  31. package/src/document/1.0.0/generateGithubReadme/build/index.js +23 -23
  32. package/src/document/{1.0.0/all/build/feature → 1.1.0/all/build/protocol}/index.js +23 -23
  33. package/src/document/1.1.0/all/index.js +4 -4
  34. package/src/document/1.1.0/all/write/index.js +3 -3
  35. package/src/document/1.1.0/chunks/build/class/class.js +2 -2
  36. package/src/document/1.1.0/chunks/build/class/functions.js +2 -2
  37. package/src/document/1.1.0/chunks/build/class/lib.js +2 -2
  38. package/src/document/1.1.0/chunks/build/class/seed.js +2 -2
  39. package/src/document/1.1.0/chunks/build/class/triggers.js +2 -2
  40. package/src/document/1.1.0/chunks/build/{feature → protocol}/afterInit.js +2 -2
  41. package/src/document/{1.0.0/chunks/build/feature → 1.1.0/chunks/build/protocol}/beforeInit.js +2 -2
  42. package/src/document/1.1.0/chunks/build/{feature → protocol}/class.js +3 -3
  43. package/src/document/{1.0.0/chunks/build/feature → 1.1.0/chunks/build/protocol}/config.js +2 -2
  44. package/src/document/{1.0.0/chunks/build/feature → 1.1.0/chunks/build/protocol}/functions.js +2 -2
  45. package/src/document/{1.0.0/chunks/build/feature → 1.1.0/chunks/build/protocol}/lib.js +2 -2
  46. package/src/document/1.1.0/chunks/build/{feature → protocol}/liveClasses.js +2 -2
  47. package/src/document/1.1.0/chunks/build/{feature → protocol}/schema.js +2 -2
  48. package/src/document/1.1.0/chunks/build/{feature → protocol}/seed.js +2 -2
  49. package/src/document/1.1.0/chunks/build/{feature → protocol}/system.js +2 -2
  50. package/src/document/{1.0.0/chunks/build/feature → 1.1.0/chunks/build/protocol}/triggers.js +2 -2
  51. package/src/document/1.1.0/generateGithubReadme/build/chunks/dependencies/index.js +2 -2
  52. package/src/document/1.1.0/generateGithubReadme/build/chunks/footer.js +1 -1
  53. package/src/document/1.1.0/generateGithubReadme/build/chunks/githubTags.js +3 -3
  54. package/src/document/1.1.0/generateGithubReadme/build/chunks/registry.js +2 -2
  55. package/src/document/1.1.0/generateGithubReadme/build/chunks/usage.js +1 -1
  56. package/src/document/1.1.0/generateGithubReadme/build/index.js +23 -23
  57. package/src/document/gateway/all/index.js +2 -2
  58. package/src/document/gateway/generateGithubReadme/index.js +2 -2
  59. package/src/domain/{feature → protocol}/factory/absoluteModuleSrcPath.js +3 -3
  60. package/src/domain/protocol/factory/index.js +71 -0
  61. package/src/domain/protocol/factory/protocolPath.js +41 -0
  62. package/src/domain/{feature → protocol}/index.js +6 -6
  63. package/src/domain/{feature → protocol}/lib/instancesPathIdUniqueId.js +3 -3
  64. package/src/domain/protocolInstance/factory/getLoaderWithPayload.js +7 -0
  65. package/src/domain/{featureInstance → protocolInstance}/factory/index.js +7 -7
  66. package/src/domain/{featureInstance → protocolInstance}/index.js +16 -16
  67. package/src/domain/{featureLoader → protocolLoader}/base.js +9 -9
  68. package/src/domain/protocolLoader/lib/mergeClassProtocols.js +17 -0
  69. package/src/domain/{featureLoader → protocolLoader}/v1.0.0.js +66 -34
  70. package/src/domain/{featureLoader → protocolLoader}/v1.1.0.js +68 -31
  71. package/src/index.js +7 -7
  72. package/src/lib/adaptConfig/basic.js +59 -59
  73. package/src/manifest/access/index.js +1 -1
  74. package/src/manifest/data/1.0.0/class.json +3 -3
  75. package/src/manifest/data/1.0.0/enums.js +6 -6
  76. package/src/manifest/data/1.0.0/{feature.json → protocol.json} +5 -5
  77. package/src/manifest/data/1.1.0/class.json +3 -3
  78. package/src/manifest/data/1.1.0/enums.js +6 -6
  79. package/src/manifest/data/1.1.0/{feature.json → protocol.json} +4 -4
  80. package/src/manifest/extract/index.js +1 -1
  81. package/src/manifest/extract/templateDataForId.js +3 -3
  82. package/src/schema/build/buildProtocol/classStruct/extractProtocolsProtocols.js +29 -0
  83. package/src/schema/build/buildProtocol/classStruct/index.js +62 -0
  84. package/src/schema/build/{buildFeature/classStruct/featureInClassClassSchema.js → buildProtocol/classStruct/protocolInClassClassSchema.js} +7 -7
  85. package/src/schema/build/buildProtocol/extractClassesProtocol.js +49 -0
  86. package/src/schema/build/{buildFeature → buildProtocol}/index.js +40 -40
  87. package/src/schema/build/index.js +29 -29
  88. package/src/schema/build/lib/{getFeaturesLiveClasses.js → getProtocolsLiveClasses.js} +4 -4
  89. package/src/schema/build/lib/updateProtocolsExcerpt.js +24 -0
  90. package/src/schema/index.js +30 -30
  91. package/src/schema/validate/{handleFeature → handleProtocol}/computeVersions.js +2 -2
  92. package/src/schema/validate/handleProtocol/index.js +5 -0
  93. package/src/schema/validate/index.js +6 -6
  94. package/src/domain/feature/factory/featurePath.js +0 -41
  95. package/src/domain/feature/factory/index.js +0 -71
  96. package/src/domain/featureInstance/factory/getLoaderWithPayload.js +0 -7
  97. package/src/domain/featureLoader/lib/mergeClassFeatures.js +0 -17
  98. package/src/schema/build/buildFeature/classStruct/extractFeaturesFeatures.js +0 -29
  99. package/src/schema/build/buildFeature/classStruct/index.js +0 -62
  100. package/src/schema/build/buildFeature/extractClassesFeature.js +0 -49
  101. package/src/schema/build/lib/updateFeaturesExcerpt.js +0 -24
  102. package/src/schema/validate/handleFeature/index.js +0 -5
  103. /package/src/document/1.0.0/all/write/{feature → protocol}/index.js +0 -0
  104. /package/src/document/1.1.0/all/write/{feature → protocol}/index.js +0 -0
  105. /package/src/domain/{featureInstance → protocolInstance}/factory/instancesWithPath.js +0 -0
  106. /package/src/domain/{featureLoader → protocolLoader}/factory/getModule.js +0 -0
  107. /package/src/domain/{featureLoader → protocolLoader}/factory/index.js +0 -0
  108. /package/src/domain/{featureLoader → protocolLoader}/lib/importJSDefault.js +0 -0
  109. /package/src/domain/{featureLoader → protocolLoader}/lib/importJSONDefault.js +0 -0
  110. /package/src/domain/{featureLoader → protocolLoader}/lib/triggerItems.js +0 -0
  111. /package/src/lib/{adaptFeaturePayload.js → adaptProtocolPayload.js} +0 -0
  112. /package/src/lib/{cleanFeatures.js → cleanProtocols.js} +0 -0
  113. /package/src/lib/{featureApiVersion.js → protocolApiVersion.js} +0 -0
  114. /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 { FeatureEnum } from "../../../../manifest/data/1.0.0/enums.js"
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/feature/seed.js'
6
- import buildFeatureClass from '../../chunks/build/feature/class.js'
7
- import buildConfig from '../../chunks/build/feature/config.js'
8
- import buildLiveClasses from '../../chunks/build/feature/liveClasses.js'
9
- import buildAfterInit from '../../chunks/build/feature/afterInit.js'
10
- import buildBeforeInit from '../../chunks/build/feature/beforeInit.js'
11
- import buildFunctions from '../../chunks/build/feature/functions.js'
12
- import buildSchema from '../../chunks/build/feature/schema.js'
13
- import buildSystem from '../../chunks/build/feature/system.js'
14
- import buildLib from '../../chunks/build/feature/lib.js'
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/feature/triggers.js'
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: FeatureEnum.Index,
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} *feature for Servable*` })
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: FeatureEnum.Assets.Icon,
66
- // variant: FeatureEnum.Assets.Icon.variants.x2,
67
- mimeType: FeatureEnum.Assets.Icon.mimeTypes.SVG,
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: FeatureEnum.Assets.Icon,
85
- variant: FeatureEnum.Assets.Icon.variants.x2,
86
- mimeType: FeatureEnum.Assets.Icon.mimeTypes.PNG,
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.featureClass = await buildFeatureClass({ path })
172
- payload.push({ h2: chunks.featureClass.name })
173
- payload = payload.concat(chunks.featureClass.payload)
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 featureApiVersion from '../../../lib/featureApiVersion.js'
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 featureApiVersion({ path })
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 featureApiVersion from '../../../lib/featureApiVersion.js'
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 featureApiVersion({ path })
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 featurePath = getModuleDir(item)
5
- if (!featurePath) {
4
+ const protocolPath = getModuleDir(item)
5
+ if (!protocolPath) {
6
6
  return null
7
7
  }
8
8
 
9
- return `${featurePath}/src`
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 FeatureInstanceFactory from '../featureInstance/factory/index.js'
2
+ import * as protocolInstanceFactory from '../protocolInstance/factory/index.js'
3
3
 
4
- export default class Feature {
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
- featurePayload,
22
+ protocolPayload,
23
23
  servableConfig,
24
24
  instancesPathId }) {
25
- return FeatureInstanceFactory.getWithCache({
26
- featurePayload,
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
- featurePayload: instance.featurePayload,
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, currentFeatureId }) => {
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 'feature': {
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} 🐝 ${currentFeatureId}`
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 FeatureInstanceClass from '../index.js'
2
+ import ProtocolInstanceClass from '../index.js'
3
3
  import instancesWithPath from './instancesWithPath.js'
4
4
 
5
5
  export const getWithCache = async ({
6
- featurePayload,
6
+ protocolPayload,
7
7
  servableConfig,
8
8
  instancesPathId,
9
9
  instances,
10
10
  }) => {
11
11
 
12
- const { id, module, version, path } = featurePayload
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 'feature': {
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({ featurePayload })
45
- instance = new FeatureInstanceClass({
46
- featurePayload,
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 '../feature/lib/instancesPathIdUniqueId.js'
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 FeatureInstance {
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
- _featurePayload = null
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
- featurePayload,
30
+ protocolPayload,
31
31
  loader
32
32
  } = props
33
33
  this._loader = loader
34
- this._loader._featureInstance = this
34
+ this._loader._protocolInstance = this
35
35
  this._className = className
36
- this._params = { ...featurePayload.params }
37
- this._path = featurePayload.path
38
- this._id = featurePayload.id
39
- this._featurePayload = { ...featurePayload }
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, currentFeatureId: this._id })
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 featurePayload() {
93
- return this._featurePayload
92
+ get protocolPayload() {
93
+ return this._protocolPayload
94
94
  }
95
- set featurePayload(value) {
96
- this._featurePayload = value
95
+ set protocolPayload(value) {
96
+ this._protocolPayload = value
97
97
  }
98
98
  // #endregion
99
99
 
100
100
 
101
101
  toString() {
102
- return `FeatureInstance: ${this.instancesPathIdString} (${this.path})`
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.feature = this
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, FeatureEnum } from '../../manifest/data/1.0.0/enums.js'
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 FeatureLoader {
10
+ export default class ProtocolLoader {
11
11
  _cache = {}
12
12
  _extraClasses = {}
13
13
  _extraction = null
14
14
 
15
15
  _path = null
16
- _featureInstance = null
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 featureInstance() { return this._featureInstance }
39
- set featureInstance(value) { this._featureInstance = value }
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.Feature
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: FeatureEnum.Schema,
56
+ // item: ProtocolEnum.Schema,
57
57
  // extraction: this.extraction,
58
58
  // })
59
59
  // const schemaB = await access({
60
- // item: FeatureEnum.Schema,
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: FeatureEnum.Index,
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
+ }