@servable/tools 1.3.1 → 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 +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/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,11 +1,11 @@
1
1
  import preserveMostRestricted from './preserveMostRestricted.js'
2
2
 
3
3
  export default async (props) => {
4
- const { classSchema, feature } = props
4
+ const { classSchema, protocol } = props
5
5
  let _classSchema = { ...classSchema }
6
6
  try {
7
- //#TODO: feature.loader
8
- const _fields = await feature.loader.schemaFields()
7
+ //#TODO: protocol.loader
8
+ const _fields = await protocol.loader.schemaFields()
9
9
  if (_fields) {
10
10
  _classSchema.fields = {
11
11
  ..._classSchema.fields,
@@ -13,8 +13,8 @@ export default async (props) => {
13
13
  }
14
14
  }
15
15
 
16
- //#TODO: feature.loader
17
- const _indexes = await feature.loader.schemaIndexes()
16
+ //#TODO: protocol.loader
17
+ const _indexes = await protocol.loader.schemaIndexes()
18
18
  if (_indexes) {
19
19
  _classSchema.indexes = {
20
20
  ..._classSchema.indexes,
@@ -22,8 +22,8 @@ export default async (props) => {
22
22
  }
23
23
  }
24
24
 
25
- //#TODO: feature.loader
26
- const _classLevelPermissions = await feature.loader.schemaClassLevelPermissions()
25
+ //#TODO: protocol.loader
26
+ const _classLevelPermissions = await protocol.loader.schemaClassLevelPermissions()
27
27
  let __classLevelPermissions
28
28
  if (_classLevelPermissions && Object.keys(_classLevelPermissions).length) {
29
29
  __classLevelPermissions = preserveMostRestricted([_classSchema.classLevelPermissions, _classLevelPermissions])
@@ -0,0 +1,49 @@
1
+ import _ from 'underscore'
2
+
3
+ export default async ({
4
+ protocolsPayloads,
5
+ protocolFactory,
6
+ extractProtocol,
7
+ updateProtocolsExcerpt,
8
+ instancesPathId }) => {
9
+
10
+ let protocols = []
11
+
12
+ for (var i in protocolsPayloads) {
13
+ const protocolPayload = protocolsPayloads[i]
14
+
15
+ const protocol = await protocolFactory({
16
+ protocolPayload,
17
+ instancesPathId,
18
+ // instancesPathId: _instancesPathId
19
+ })
20
+
21
+ if (protocol && protocol.extractionStatus === 2) {
22
+ protocols.push(protocol)
23
+ continue
24
+ }
25
+
26
+ const extractedProtocolStruct = await extractProtocol({
27
+ protocolFactory,
28
+ updateProtocolsExcerpt,
29
+ protocol,
30
+ instancesPathId: [
31
+ ...instancesPathId,
32
+ { type: 'protocol', value: { id: protocolPayload.id } }
33
+ ]
34
+ })
35
+
36
+ protocols.push(extractedProtocolStruct)
37
+ }
38
+
39
+ if (!protocols || !protocols.length) {
40
+ return []
41
+ }
42
+
43
+ protocols = _.flatten(protocols)
44
+ protocols = protocols.filter(a => a)
45
+ protocols = _.flatten(_.flatten(protocols))
46
+ protocols = _.uniq(protocols, 'id')
47
+
48
+ return protocols
49
+ }
@@ -1,43 +1,43 @@
1
1
  import classStruct from './classStruct/index.js'
2
2
  import _ from 'underscore'
3
- import extractClassesFeature from './extractClassesFeature.js'
3
+ import extractClassesProtocol from './extractClassesProtocol.js'
4
4
 
5
5
  const perform = async ({
6
- featureFactory,
7
- feature,
8
- updateFeaturesExcerpt,
6
+ protocolFactory,
7
+ protocol,
8
+ updateProtocolsExcerpt,
9
9
  instancesPathId = []
10
10
  }) => {
11
11
 
12
12
  const defaultResult = [
13
- feature
13
+ protocol
14
14
  ]
15
15
 
16
- //#TODO: feature.loader
17
- if (!(await feature.loader.isValid())) {
18
- console.log('feature not valid', feature.id, feature.loader.path)
16
+ //#TODO: protocol.loader
17
+ if (!(await protocol.loader.isValid())) {
18
+ console.log('protocol not valid', protocol.id, protocol.loader.path)
19
19
  return defaultResult
20
20
  }
21
21
 
22
- //#TODO: feature.loader
23
- const classesSchemas = await feature.loader.classesSchemas()
22
+ //#TODO: protocol.loader
23
+ const classesSchemas = await protocol.loader.classesSchemas()
24
24
  if (!classesSchemas) {
25
25
  return defaultResult
26
26
  }
27
27
 
28
- if (feature.id === 'app') {
28
+ if (protocol.id === 'app') {
29
29
  await Servable.engine.formatAppClassesSchemas({ classesSchemas })
30
30
  }
31
31
 
32
32
  let adaptedClassesStructs = []
33
- let classesFeatures = []
33
+ let classesProtocols = []
34
34
 
35
35
  for (var i in classesSchemas) {
36
36
  const classSchema = classesSchemas[i]
37
37
  const adaptedClassStruct = await classStruct({
38
- feature,
38
+ protocol,
39
39
  classSchema,
40
- featureFactory,
40
+ protocolFactory,
41
41
  instancesPathId: [
42
42
  ...instancesPathId,
43
43
  { type: 'class', value: { className: classSchema.className } }
@@ -45,19 +45,19 @@ const perform = async ({
45
45
  })
46
46
  adaptedClassesStructs = adaptedClassesStructs.concat(adaptedClassStruct)
47
47
 
48
- let { featuresPayloads } = adaptedClassStruct
49
- if (!featuresPayloads || !featuresPayloads.length) {
48
+ let { protocolsPayloads } = adaptedClassStruct
49
+ if (!protocolsPayloads || !protocolsPayloads.length) {
50
50
  continue
51
51
  }
52
52
 
53
- featuresPayloads = featuresPayloads.filter(a => (a && a.id !== feature.id))
54
- //#TODO Move from uniq to cleanfeatures
55
- featuresPayloads = _.uniq(featuresPayloads, a => a.id)
53
+ protocolsPayloads = protocolsPayloads.filter(a => (a && a.id !== protocol.id))
54
+ //#TODO Move from uniq to cleanprotocols
55
+ protocolsPayloads = _.uniq(protocolsPayloads, a => a.id)
56
56
 
57
- const classFeatures = await extractClassesFeature({
58
- featuresPayloads,
59
- featureFactory,
60
- updateFeaturesExcerpt,
57
+ const classProtocols = await extractClassesProtocol({
58
+ protocolsPayloads,
59
+ protocolFactory,
60
+ updateProtocolsExcerpt,
61
61
  instancesPathId: [
62
62
  ...instancesPathId,
63
63
  {
@@ -65,41 +65,41 @@ const perform = async ({
65
65
  value: { className: classSchema.className }
66
66
  }
67
67
  ],
68
- extractFeature: perform
68
+ extractProtocol: perform
69
69
  })
70
- classesFeatures = classesFeatures.concat(classFeatures)
70
+ classesProtocols = classesProtocols.concat(classProtocols)
71
71
  }
72
72
 
73
- await updateFeaturesExcerpt({ adaptedClassesStructs })
73
+ await updateProtocolsExcerpt({ adaptedClassesStructs })
74
74
  let ownClasses = adaptedClassesStructs.map(i => i.classSchema).filter(a => a)
75
75
  let jsClasses = adaptedClassesStructs.map(i => i._class).filter(a => a)
76
76
 
77
77
 
78
- classesFeatures = _.uniq(classesFeatures, a => a.id)
79
- if (!classesFeatures.length) {
80
- //#TODO: feature.schema
81
- feature.schema = {
82
- ...feature.schema,
78
+ classesProtocols = _.uniq(classesProtocols, a => a.id)
79
+ if (!classesProtocols.length) {
80
+ //#TODO: protocol.schema
81
+ protocol.schema = {
82
+ ...protocol.schema,
83
83
  classes: {
84
84
  managed: ownClasses,
85
85
  all: ownClasses
86
86
  },
87
87
  jsClasses
88
88
  }
89
- return [feature]
89
+ return [protocol]
90
90
  }
91
91
 
92
- //#TODO: feature.schema
92
+ //#TODO: protocol.schema
93
93
  let all = [...ownClasses]
94
- classesFeatures.forEach(element => {
94
+ classesProtocols.forEach(element => {
95
95
  const { classes: { managed: _own = [], all: _all = [] } = {} } = element.schema
96
96
  all = [...all, ..._all]
97
97
  all = _.uniq(all, 'className')
98
98
  })
99
99
 
100
- //#TODO: feature.schema
101
- feature.schema = {
102
- ...feature.schema,
100
+ //#TODO: protocol.schema
101
+ protocol.schema = {
102
+ ...protocol.schema,
103
103
  classes: {
104
104
  managed: ownClasses,
105
105
  all
@@ -107,11 +107,11 @@ const perform = async ({
107
107
  jsClasses
108
108
  }
109
109
 
110
- feature.extractionStatus = 2
110
+ protocol.extractionStatus = 2
111
111
 
112
112
  return [
113
- feature,
114
- ...classesFeatures
113
+ protocol,
114
+ ...classesProtocols
115
115
  ]
116
116
  }
117
117
 
@@ -1,54 +1,54 @@
1
- import featureFactory from "../../domain/feature/factory/index.js"
2
- import getFeaturesLiveClasses from "./lib/getFeaturesLiveClasses.js"
1
+ import protocolFactory from "../../domain/protocol/factory/index.js"
2
+ import getProtocolsLiveClasses from "./lib/getProtocolsLiveClasses.js"
3
3
  import adaptConfigBasic from "../../lib/adaptConfig/basic.js"
4
- import buildFeature from './buildFeature/index.js'
5
- import updateFeaturesExcerpt from './lib/updateFeaturesExcerpt.js'
4
+ import buildProtocol from './buildProtocol/index.js'
5
+ import updateProtocolsExcerpt from './lib/updateProtocolsExcerpt.js'
6
6
 
7
7
  export default async ({ servableConfig }) => {
8
- const { rootFeaturePayload } = servableConfig
8
+ const { rootProtocolPayload } = servableConfig
9
9
  adaptConfigBasic({ servableConfig, live: false })
10
- const featuresCache = []
11
- const appFeature = await featureFactory({
12
- featurePayload: {
13
- id: rootFeaturePayload.id,
14
- type: rootFeaturePayload.type,
15
- path: rootFeaturePayload.path,
16
- version: rootFeaturePayload.version
10
+ const protocolsCache = []
11
+ const appProtocol = await protocolFactory({
12
+ protocolPayload: {
13
+ id: rootProtocolPayload.id,
14
+ type: rootProtocolPayload.type,
15
+ path: rootProtocolPayload.path,
16
+ version: rootProtocolPayload.version
17
17
  },
18
18
  servableConfig,
19
- featuresCache,
19
+ protocolsCache,
20
20
  instancesPathId: [
21
21
  // { type: 'class', value: { className: '_root' } },
22
- { type: 'feature', value: { id: 'app' } }
22
+ { type: 'protocol', value: { id: 'app' } }
23
23
  ],
24
24
  })
25
25
 
26
- const featuresExcerpt = {}
27
- const features = await buildFeature({
28
- feature: appFeature,
29
- featureFactory: async ({
30
- featurePayload,
26
+ const protocolsExcerpt = {}
27
+ const protocols = await buildProtocol({
28
+ protocol: appProtocol,
29
+ protocolFactory: async ({
30
+ protocolPayload,
31
31
  instancesPathId
32
32
  }) =>
33
- featureFactory({
34
- featurePayload,
33
+ protocolFactory({
34
+ protocolPayload,
35
35
  servableConfig,
36
- featuresCache,
36
+ protocolsCache,
37
37
  instancesPathId
38
38
  }),
39
- updateFeaturesExcerpt: async ({ adaptedClassesStructs }) =>
40
- updateFeaturesExcerpt({ adaptedClassesStructs, featuresExcerpt }),
39
+ updateProtocolsExcerpt: async ({ adaptedClassesStructs }) =>
40
+ updateProtocolsExcerpt({ adaptedClassesStructs, protocolsExcerpt }),
41
41
  instancesPathId: [
42
- { type: 'feature', value: { id: 'app' } }
42
+ { type: 'protocol', value: { id: 'app' } }
43
43
  ],
44
44
  })
45
45
 
46
- const liveClasses = await getFeaturesLiveClasses({ features })
46
+ const liveClasses = await getProtocolsLiveClasses({ protocols })
47
47
 
48
48
  return {
49
- features,
50
- featuresExcerpt,
51
- appFeature,
49
+ protocols,
50
+ protocolsExcerpt,
51
+ appProtocol,
52
52
  liveClasses
53
53
  }
54
54
  }
@@ -1,9 +1,9 @@
1
1
  import _ from 'underscore'
2
2
 
3
- export default async ({ features }) => {
4
- let items = (await Promise.all(features.map(async feature => {
5
- //#TODO: feature.loader
6
- const fn = await feature.loader.liveClasses()
3
+ export default async ({ protocols }) => {
4
+ let items = (await Promise.all(protocols.map(async protocol => {
5
+ //#TODO: protocol.loader
6
+ const fn = await protocol.loader.liveClasses()
7
7
  if (!fn) {
8
8
  return null
9
9
  }
@@ -0,0 +1,24 @@
1
+
2
+ export default async ({
3
+ adaptedClassesStructs,
4
+ protocolsExcerpt }) => {
5
+ const candidates = adaptedClassesStructs.filter(a =>
6
+ (a && a.protocols && a.protocols.length))
7
+
8
+ if (!candidates || !candidates.length) {
9
+ return
10
+ }
11
+ candidates.forEach(adaptedClassesStruct => {
12
+ const { protocols, classSchema: { className } } = adaptedClassesStruct
13
+ protocols.forEach(protocol => {
14
+ if (!protocolsExcerpt[protocol.id]) {
15
+ protocolsExcerpt[protocol.id] = {
16
+ classes: []
17
+ }
18
+ }
19
+ if (!protocolsExcerpt[protocol.id].classes.includes(className)) {
20
+ protocolsExcerpt[protocol.id].classes.push(className)
21
+ }
22
+ })
23
+ })
24
+ }
@@ -1,56 +1,56 @@
1
- import featureFactory from "../domain/feature/factory/index.js"
2
- import getFeaturesLiveClasses from "./lib/getFeaturesLiveClasses.js"
1
+ import protocolFactory from "../domain/protocol/factory/index.js"
2
+ import getProtocolsLiveClasses from "./build/lib/getProtocolsLiveClasses.js"
3
3
  import adaptConfigBasic from "../lib/adaptConfig/basic.js"
4
- import extractFeature from './extractFeature/index.js'
5
- import updateFeaturesExcerpt from './lib/updateFeaturesExcerpt.js'
4
+ import extractProtocol from './extractProtocol/index.js'
5
+ import updateProtocolsExcerpt from './build/lib/updateProtocolsExcerpt.js'
6
6
 
7
7
  export default async ({ servableConfig }) => {
8
- const { rootFeaturePayload } = servableConfig
8
+ const { rootProtocolPayload } = servableConfig
9
9
  adaptConfigBasic({ servableConfig, live: false })
10
- const featuresCache = []
11
- const appFeature = await featureFactory({
12
- featurePayload: {
13
- id: rootFeaturePayload.id,
14
- type: rootFeaturePayload.type,
15
- path: rootFeaturePayload.path,
16
- version: rootFeaturePayload.version
10
+ const protocolsCache = []
11
+ const appProtocol = await protocolFactory({
12
+ protocolPayload: {
13
+ id: rootProtocolPayload.id,
14
+ type: rootProtocolPayload.type,
15
+ path: rootProtocolPayload.path,
16
+ version: rootProtocolPayload.version
17
17
  },
18
18
  servableConfig,
19
- featuresCache,
19
+ protocolsCache,
20
20
  instancesPathId: [
21
- { type: 'feature', value: { id: 'app' } }
21
+ { type: 'protocol', value: { id: 'app' } }
22
22
  ],
23
23
  })
24
24
 
25
- const featuresExcerpt = {}
26
- const features = await extractFeature({
27
- feature: appFeature,
28
- featureFactory: async ({
29
- featurePayload,
25
+ const protocolsExcerpt = {}
26
+ const protocols = await extractProtocol({
27
+ protocol: appProtocol,
28
+ protocolFactory: async ({
29
+ protocolPayload,
30
30
  instancesPathId
31
31
  }) =>
32
- featureFactory({
33
- featurePayload,
32
+ protocolFactory({
33
+ protocolPayload,
34
34
  servableConfig,
35
- featuresCache,
35
+ protocolsCache,
36
36
  instancesPathId
37
37
  }),
38
- updateFeaturesExcerpt: async ({ adaptedClassesStructs }) =>
39
- updateFeaturesExcerpt({
38
+ updateProtocolsExcerpt: async ({ adaptedClassesStructs }) =>
39
+ updateProtocolsExcerpt({
40
40
  adaptedClassesStructs,
41
- featuresExcerpt
41
+ protocolsExcerpt
42
42
  }),
43
43
  instancesPathId: [
44
- { type: 'feature', value: { id: 'app' } }
44
+ { type: 'protocol', value: { id: 'app' } }
45
45
  ],
46
46
  })
47
47
 
48
- const liveClasses = await getFeaturesLiveClasses({ features })
48
+ const liveClasses = await getProtocolsLiveClasses({ protocols })
49
49
 
50
50
  return {
51
- features,
52
- featuresExcerpt,
53
- appFeature,
51
+ protocols,
52
+ protocolsExcerpt,
53
+ appProtocol,
54
54
  liveClasses
55
55
  }
56
56
  }
@@ -2,10 +2,10 @@ import semver from 'semver'
2
2
 
3
3
  export default async (props) => {
4
4
  const {
5
- feature,
5
+ protocol,
6
6
  } = props
7
7
 
8
- const { instances } = feature
8
+ const { instances } = protocol
9
9
  if (!instances || !instances.length) {
10
10
  return {}
11
11
  }
@@ -0,0 +1,5 @@
1
+ import computeVersions from './computeVersions.js'
2
+
3
+ export default async ({ protocol }) => {
4
+ return computeVersions({ protocol })
5
+ }
@@ -1,4 +1,4 @@
1
- import handleFeature from "./handleFeature/index.js"
1
+ import handleProtocol from "./handleProtocol/index.js"
2
2
  import semver from 'semver'
3
3
 
4
4
  export default async ({
@@ -6,13 +6,13 @@ export default async ({
6
6
  }) => {
7
7
 
8
8
  const {
9
- features
9
+ protocols
10
10
  } = schema
11
11
  const comparisons = []
12
- for (var i in features) {
13
- const feature = features[i]
14
- const comparison = await handleFeature({
15
- feature,
12
+ for (var i in protocols) {
13
+ const protocol = protocols[i]
14
+ const comparison = await handleProtocol({
15
+ protocol,
16
16
  })
17
17
  comparisons.push(comparison)
18
18
  }
@@ -1,41 +0,0 @@
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 featurePath = null
8
-
9
- if (typeof module === 'object'
10
- && Object.keys(module).length) {
11
- const item = Object.keys(module)[0]
12
- if (item) {
13
- featurePath = absoluteModuleSrcPath(item)
14
- return featurePath
15
- }
16
- }
17
-
18
- if (servableConfig.features
19
- && servableConfig.features.external
20
- && servableConfig.features.external[id]) {
21
- featurePath = absoluteModuleSrcPath(servableConfig.features.external[id])
22
- return featurePath
23
- }
24
-
25
- if (servableConfig.features
26
- && servableConfig.features.local
27
- && servableConfig.features.local.length) {
28
-
29
- let i = 0
30
- do {
31
- const repo = servableConfig.features.local[i]
32
- featurePath = `${repo}/${id}`
33
- if ((await checkFileExists(featurePath))) {
34
- return featurePath
35
- }
36
- i++
37
- } while (i < servableConfig.features.local.length)
38
- }
39
-
40
- return null
41
- }
@@ -1,71 +0,0 @@
1
- import featurePath from './featurePath.js'
2
-
3
- import _ from 'underscore'
4
- import FeatureClass from '../index.js'
5
-
6
- export default async ({
7
- featurePayload,
8
- servableConfig,
9
- featuresCache,
10
- instancesPathId
11
- }) => {
12
-
13
- const { id, module, version, type, } = featurePayload
14
- let path = featurePayload.path
15
- if (!path) {
16
- path = await featurePath({
17
- id,
18
- module,
19
- version,
20
- servableConfig
21
- })
22
- }
23
-
24
- if (!path) {
25
- return null
26
- }
27
-
28
- let feature = null
29
- const valueInCache = cacheValue({
30
- featurePayload: {
31
- ...featurePayload,
32
- path
33
- }, featuresCache
34
- })
35
-
36
- if (valueInCache) {
37
- feature = valueInCache.feature
38
- } else {
39
- feature = new FeatureClass({ id, type })
40
- featuresCache.push({
41
- id,
42
- module,
43
- version,
44
- path,
45
- feature
46
- })
47
- }
48
-
49
- await feature.addInstanceIfNeeded({
50
- featurePayload: {
51
- ...featurePayload,
52
- path
53
- },
54
- instancesPathId,
55
- servableConfig
56
- })
57
- // console.log(instancesPathId)
58
- return feature
59
- }
60
-
61
-
62
- const cacheValue = ({ featurePayload, featuresCache }) => {
63
- const { id, module, version, path } = featurePayload
64
- const candidates = _.where(featuresCache, {
65
- id,
66
- // version,
67
- // path,
68
- // module
69
- })
70
- return (candidates && candidates.length) ? candidates[0] : null
71
- }
@@ -1,7 +0,0 @@
1
- import * as FeatureLoaderFactory from '../../featureLoader/factory/index.js'
2
-
3
- export default async ({ featurePayload }) => {
4
- const { path, version } = featurePayload
5
- const _loader = await FeatureLoaderFactory.getByPathAndVersion({ path, version })
6
- return _loader
7
- }
@@ -1,17 +0,0 @@
1
- import cleanFeatures from "../../../lib/cleanFeatures.js"
2
-
3
-
4
- export default ({ items = [], _class, withFeaturesFeatures }) => {
5
- let classFeatures = _class.features ? _class.features : []
6
- if (!withFeaturesFeatures) {
7
- return cleanFeatures([...items, ...classFeatures])
8
- }
9
-
10
- return cleanFeatures([...items])
11
-
12
- // let inheritedFeatures = _class.inheritedFeatures ? _class.inheritedFeatures : []
13
- // return cleanFeatures([
14
- // ...classFeatures,
15
- // ...inheritedFeatures
16
- // ])
17
- }
@@ -1,29 +0,0 @@
1
- import _ from 'underscore'
2
- import adaptFeaturePayload from '../../../../lib/adaptFeaturePayload.js'
3
- import cleanFeatures from '../../../../lib/cleanFeatures.js'
4
-
5
- export default async ({
6
- featuresPayloads,
7
- featureFactory,
8
- instancesPathId }) => {
9
-
10
- let items = []
11
-
12
- for (var i in featuresPayloads) {
13
- const featurePayload = featuresPayloads[i]
14
- const feature = await featureFactory({
15
- featurePayload,
16
- instancesPathId
17
- })
18
- //#TODO: feature.loader
19
- const ownFeatures = await feature.loader.ownFeatures()
20
- let a = (ownFeatures && ownFeatures.length) ? ownFeatures.map(adaptFeaturePayload) : null
21
- if (a && a.length) {
22
- items = items.concat(a)
23
- }
24
- }
25
-
26
- items = _.flatten(items.filter(a => a)).filter(a => a)
27
- items = cleanFeatures(items)
28
- return items
29
- }