@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.
Files changed (115) 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 +24 -24
  70. package/src/domain/{featureLoader → protocolLoader}/v1.1.0.js +26 -26
  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/route/index.js +1 -1
  82. package/src/manifest/extract/templateDataForId.js +3 -3
  83. package/src/schema/build/buildProtocol/classStruct/extractProtocolsProtocols.js +29 -0
  84. package/src/schema/build/buildProtocol/classStruct/index.js +62 -0
  85. package/src/schema/build/{buildFeature/classStruct/featureInClassClassSchema.js → buildProtocol/classStruct/protocolInClassClassSchema.js} +7 -7
  86. package/src/schema/build/buildProtocol/extractClassesProtocol.js +49 -0
  87. package/src/schema/build/{buildFeature → buildProtocol}/index.js +40 -40
  88. package/src/schema/build/index.js +29 -29
  89. package/src/schema/build/lib/{getFeaturesLiveClasses.js → getProtocolsLiveClasses.js} +4 -4
  90. package/src/schema/build/lib/updateProtocolsExcerpt.js +24 -0
  91. package/src/schema/index.js +30 -30
  92. package/src/schema/validate/{handleFeature → handleProtocol}/computeVersions.js +2 -2
  93. package/src/schema/validate/handleProtocol/index.js +5 -0
  94. package/src/schema/validate/index.js +6 -6
  95. package/src/domain/feature/factory/featurePath.js +0 -41
  96. package/src/domain/feature/factory/index.js +0 -71
  97. package/src/domain/featureInstance/factory/getLoaderWithPayload.js +0 -7
  98. package/src/domain/featureLoader/lib/mergeClassFeatures.js +0 -17
  99. package/src/schema/build/buildFeature/classStruct/extractFeaturesFeatures.js +0 -29
  100. package/src/schema/build/buildFeature/classStruct/index.js +0 -62
  101. package/src/schema/build/buildFeature/extractClassesFeature.js +0 -49
  102. package/src/schema/build/lib/updateFeaturesExcerpt.js +0 -24
  103. package/src/schema/validate/handleFeature/index.js +0 -5
  104. /package/src/document/1.0.0/all/write/{feature → protocol}/index.js +0 -0
  105. /package/src/document/1.1.0/all/write/{feature → protocol}/index.js +0 -0
  106. /package/src/domain/{featureInstance → protocolInstance}/factory/instancesWithPath.js +0 -0
  107. /package/src/domain/{featureLoader → protocolLoader}/factory/getModule.js +0 -0
  108. /package/src/domain/{featureLoader → protocolLoader}/factory/index.js +0 -0
  109. /package/src/domain/{featureLoader → protocolLoader}/lib/importJSDefault.js +0 -0
  110. /package/src/domain/{featureLoader → protocolLoader}/lib/importJSONDefault.js +0 -0
  111. /package/src/domain/{featureLoader → protocolLoader}/lib/triggerItems.js +0 -0
  112. /package/src/lib/{adaptFeaturePayload.js → adaptProtocolPayload.js} +0 -0
  113. /package/src/lib/{cleanFeatures.js → cleanProtocols.js} +0 -0
  114. /package/src/lib/{featureApiVersion.js → protocolApiVersion.js} +0 -0
  115. /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
+ }
@@ -1,22 +1,22 @@
1
1
  import BaseClass from './base.js'
2
2
 
3
3
  import directories from '../../lib/directories.js'
4
- import cleanFeatures from '../../lib/cleanFeatures.js'
5
- import mergeClassFeatures from './lib/mergeClassFeatures.js'
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 { FeatureEnum } from '../../manifest/data/1.0.0/enums.js'
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 FeatureLoaderV1_0_0 extends BaseClass {
19
+ export default class ProtocolLoaderV1_0_0 extends BaseClass {
20
20
 
21
21
  // #region class
22
22
 
@@ -242,40 +242,40 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
242
242
  }
243
243
 
244
244
 
245
- async classFeatures({ className, withFeaturesFeatures = false }) {
245
+ async classProtocols({ className, withProtocolsProtocols = false }) {
246
246
  const cacheKey = 'class'
247
- // //console.log('classFeatures>', className, 'enter')
247
+ // //console.log('classProtocols>', className, 'enter')
248
248
  if (this._valueInCache(cacheKey)) {
249
249
  return this._valueInCache(cacheKey)
250
250
  }
251
251
  const items = []
252
252
  const seedMode = await this.classSeedMode({ className })
253
- // //console.log('classFeatures>', className, 'seedmode', seedMode)
253
+ // //console.log('classProtocols>', className, 'seedmode', seedMode)
254
254
  if (seedMode === 'auto') {
255
255
  items.push({ id: 'servableautoseedable' })
256
256
  }
257
257
  const _class = await this.getClass({ className })
258
258
  if (!_class) {
259
- //console.log('classFeatures>', className, 'no _class')
259
+ //console.log('classProtocols>', className, 'no _class')
260
260
  return items
261
261
  }
262
262
 
263
- let data = mergeClassFeatures({ items, _class, withFeaturesFeatures })
263
+ let data = mergeClassProtocols({ items, _class, withProtocolsProtocols })
264
264
  const path = `${this.path}/classes/${className.toLowerCase()}/class/protocols.js`
265
265
 
266
266
  if ((await checkFileExists(path))) {
267
267
 
268
268
  let _data = (await import(path)).default
269
- // //console.log('classFeatures>', className, '_data', _data)
269
+ // //console.log('classProtocols>', className, '_data', _data)
270
270
  _data = _data ? _data : []
271
271
  data = [...data,
272
272
  ..._data]
273
273
  }
274
274
 
275
275
  //this.cache[cacheKey] = data
276
- data = cleanFeatures(data)
276
+ data = cleanProtocols(data)
277
277
  // result = _.uniq(result, a => a.id)
278
- // //console.log('classFeatures>', className, 'finaldata', data)
278
+ // //console.log('classProtocols>', className, 'finaldata', data)
279
279
  return data
280
280
  }
281
281
 
@@ -364,7 +364,7 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
364
364
  return 'manual'
365
365
  }
366
366
 
367
- //Auto not handled yet for features
367
+ //Auto not handled yet for protocols
368
368
  // _path = `${seedFolder}/transformer.js`
369
369
  // if (await checkFileExists(_path)) {
370
370
  // return 'auto'
@@ -500,7 +500,7 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
500
500
  let path = `${schemaPath}/classes.js`
501
501
 
502
502
  if ((await checkFileExists(path))) {
503
- const classes = await (await import(path)).default({ feature: this.featureInstance })
503
+ const classes = await (await import(path)).default({ protocol: this.protocolInstance })
504
504
  // this.cache['classes'] = classes
505
505
  return classes
506
506
  }
@@ -557,7 +557,7 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
557
557
  async schemaRaw(props = {}) {
558
558
  const { ad } = props
559
559
  const a = await this._accessManifestItem({
560
- item: FeatureEnum.Schema,
560
+ item: ProtocolEnum.Schema,
561
561
  })
562
562
  // const cacheKey = 'schemaIndexes'
563
563
  // if (this.valueInCache(cacheKey)) {
@@ -566,13 +566,13 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
566
566
 
567
567
  const schemaPath = await this._schemaPath()
568
568
 
569
- //#TODO: A dynamic schema needs features to be instantiated per class as to avoid class defintion collusions and edge case.
569
+ //#TODO: A dynamic schema needs protocols to be instantiated per class as to avoid class defintion collusions and edge case.
570
570
  // let path = `${schemaPath}/index.js`
571
571
 
572
572
  // if ((await checkFileExists(path))) {
573
573
  // let data = (await import(path)).default
574
- // //#TODO: don't use up feature params
575
- // data = await data({ ...props, params: this.featureInstance.params })
574
+ // //#TODO: don't use up protocol params
575
+ // data = await data({ ...props, params: this.protocolInstance.params })
576
576
  // return data
577
577
  // }
578
578
 
@@ -608,8 +608,8 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
608
608
  }
609
609
 
610
610
  async _schemaPath() {
611
- //let version = this.currentFeatureVersion ? this.currentFeatureVersion : this.featureInstanceVersion
612
- let version = this.featureInstance.version
611
+ //let version = this.currentProtocolVersion ? this.currentProtocolVersion : this.protocolInstanceVersion
612
+ let version = this.protocolInstance.version
613
613
  let versions = await this.schemaVersions()
614
614
 
615
615
  if (!version) {
@@ -679,8 +679,8 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
679
679
 
680
680
 
681
681
 
682
- async ownFeatures() {
683
- const cacheKey = 'ownFeatures'
682
+ async ownProtocols() {
683
+ const cacheKey = 'ownProtocols'
684
684
  if (this._valueInCache(cacheKey)) {
685
685
  return this._valueInCache(cacheKey)
686
686
  }
@@ -696,8 +696,8 @@ export default class FeatureLoaderV1_0_0 extends BaseClass {
696
696
  return data
697
697
  }
698
698
 
699
- async ownFeaturesClass() {
700
- const cacheKey = 'ownFeaturesClass'
699
+ async ownProtocolsClass() {
700
+ const cacheKey = 'ownProtocolsClass'
701
701
  if (this._valueInCache(cacheKey)) {
702
702
  return this._valueInCache(cacheKey)
703
703
  }