@oracle/oraclejet-audit 14.1.3 → 15.0.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 (278) hide show
  1. package/corePackMigrator/cli.js +6 -0
  2. package/corePackMigrator/corePackMigrator.js +10 -0
  3. package/corePackMigrator/metadata/avatarMetadata.json +40 -0
  4. package/corePackMigrator/metadata/buttonMetadata.json +55 -0
  5. package/corePackMigrator/metadata/collapsibleMetadata.json +15 -0
  6. package/corePackMigrator/metadata/filePickerMetadata.json +8 -0
  7. package/corePackMigrator/metadata/inputNumberMetadata.json +56 -0
  8. package/corePackMigrator/metadata/inputPasswordMetadata.json +50 -0
  9. package/corePackMigrator/metadata/inputTextMetadata.json +62 -0
  10. package/corePackMigrator/metadata/legendItemMetadata.json +8 -0
  11. package/corePackMigrator/metadata/legendMetadata.json +18 -0
  12. package/corePackMigrator/metadata/legendSectionMetadata.json +8 -0
  13. package/corePackMigrator/metadata/listItemLayoutMetadata.json +15 -0
  14. package/corePackMigrator/metadata/listviewMetadata.json +8 -0
  15. package/corePackMigrator/metadata/messagesMetadata.json +35 -0
  16. package/corePackMigrator/metadata/progressBarMetadata.json +15 -0
  17. package/corePackMigrator/metadata/progressCircleMetadata.json +8 -0
  18. package/corePackMigrator/metadata/ratingGaugeMetadata.json +78 -0
  19. package/corePackMigrator/metadata/selectManyMetadata.json +39 -0
  20. package/corePackMigrator/metadata/selectSingleMetadata.json +39 -0
  21. package/corePackMigrator/metadata/statusMeterGaugeMetadata.json +99 -0
  22. package/corePackMigrator/metadata/textAreaMetadata.json +44 -0
  23. package/corePackMigrator/resource/astUtils.js +6 -0
  24. package/corePackMigrator/resource/componentMigrator.js +6 -0
  25. package/corePackMigrator/resource/fileScanner.js +6 -0
  26. package/corePackMigrator/resource/htmlUtils.js +6 -0
  27. package/corePackMigrator/resource/manifest.json +102 -0
  28. package/corePackMigrator/resource/migrationConfig.json +21 -0
  29. package/corePackMigrator/templates/componentMetaData.json +119 -0
  30. package/corePackMigrator/templates/migrationConfig.json +17 -0
  31. package/corePackMigrator/utilities/logging.js +6 -0
  32. package/jaf-amd.js +1 -1
  33. package/lib/AST_Ts.js +1 -1
  34. package/lib/Cli.js +1 -1
  35. package/lib/Components.js +1 -1
  36. package/lib/Config.js +1 -1
  37. package/lib/ConfigLib.js +1 -1
  38. package/lib/DomUtils.js +1 -1
  39. package/lib/FileIndex.js +1 -1
  40. package/lib/FileSet.js +1 -1
  41. package/lib/FsUtils.js +1 -1
  42. package/lib/HtmlUtils.js +1 -1
  43. package/lib/JsonLoader.js +1 -1
  44. package/lib/MetaLib.js +1 -1
  45. package/lib/NetUtils.js +1 -1
  46. package/lib/Parser.js +1 -1
  47. package/lib/RegTypes.js +1 -1
  48. package/lib/Registry.js +1 -1
  49. package/lib/Reporter.js +1 -1
  50. package/lib/RulePack.js +1 -1
  51. package/lib/RuleSet.js +1 -1
  52. package/lib/Rules.js +1 -1
  53. package/lib/Scope.js +1 -1
  54. package/lib/Ts.js +1 -1
  55. package/lib/TsxUtils.js +1 -1
  56. package/lib/TsxUtils2.js +6 -0
  57. package/lib/Utils.js +1 -1
  58. package/lib/ZipUtils.js +1 -1
  59. package/lib/checkage.js +1 -1
  60. package/lib/cmdline.js +1 -1
  61. package/lib/defaults.js +1 -1
  62. package/lib/exportRules.js +1 -1
  63. package/lib/filetypes.js +1 -1
  64. package/lib/groups.js +1 -1
  65. package/lib/help.js +1 -1
  66. package/lib/jetver.js +1 -1
  67. package/lib/jsx.js +1 -1
  68. package/lib/maint.js +6 -0
  69. package/lib/manpage.js +1 -1
  70. package/lib/manual.js +1 -1
  71. package/lib/migrator.js +6 -0
  72. package/lib/msgidLoader.js +1 -1
  73. package/lib/ns.js +1 -1
  74. package/lib/outfile.js +1 -1
  75. package/lib/schema.js +1 -1
  76. package/lib/scopewalker.js +1 -1
  77. package/libext/expparser.js +1 -1
  78. package/meta/14.0.0/jetauditmeta.js +1 -1
  79. package/meta/14.1.0/jetauditmeta.js +1 -1
  80. package/meta/15.0.0/jetauditmeta.js +9 -0
  81. package/meta/metaverlist.json +1 -1
  82. package/package.json +16 -8
  83. package/profiles/redwood-strict.json +2 -1
  84. package/rulepacks/csp/csp-html-script-unsafe-inline.js +1 -1
  85. package/rulepacks/csp/csp-html-unsafe-expr.js +1 -1
  86. package/rulepacks/csp/csp-js-script-unsafe-eval.js +1 -1
  87. package/rulepacks/csp/csp-js-style-unsafe-inline.js +1 -1
  88. package/rulepacks/csp/csp-json-unsafe-expr.js +6 -0
  89. package/rulepacks/csp/msgid.json +1 -1
  90. package/rulepacks/csp/rules.json +1 -1
  91. package/rulepacks/jetwc/jetwc-absolute-jetversion.js +1 -1
  92. package/rulepacks/jetwc/jetwc-aria-redefinition.js +1 -1
  93. package/rulepacks/jetwc/jetwc-bootstrap.js +1 -1
  94. package/rulepacks/jetwc/jetwc-compjson-bp-ar.js +1 -1
  95. package/rulepacks/jetwc/jetwc-compjson-bp-obj.js +1 -1
  96. package/rulepacks/jetwc/jetwc-component-dependencies.js +1 -1
  97. package/rulepacks/jetwc/jetwc-component-displayname.js +1 -1
  98. package/rulepacks/jetwc/jetwc-component-foldername.js +1 -1
  99. package/rulepacks/jetwc/jetwc-component-location.js +1 -1
  100. package/rulepacks/jetwc/jetwc-component-type.js +1 -1
  101. package/rulepacks/jetwc/jetwc-css-oj-complete.js +1 -1
  102. package/rulepacks/jetwc/jetwc-css-pack-load-path.js +6 -0
  103. package/rulepacks/jetwc/jetwc-css-scoping.js +1 -1
  104. package/rulepacks/jetwc/jetwc-data-property-prefix.js +1 -1
  105. package/rulepacks/jetwc/jetwc-deprecated-lifecycle.js +1 -1
  106. package/rulepacks/jetwc/jetwc-disabled-property.js +1 -1
  107. package/rulepacks/jetwc/jetwc-displayname.js +1 -1
  108. package/rulepacks/jetwc/jetwc-dynamic-slot-context.js +1 -1
  109. package/rulepacks/jetwc/jetwc-event-displayname.js +1 -1
  110. package/rulepacks/jetwc/jetwc-events.js +1 -1
  111. package/rulepacks/jetwc/jetwc-exchange-images.js +1 -1
  112. package/rulepacks/jetwc/jetwc-jet-version.js +1 -1
  113. package/rulepacks/jetwc/jetwc-loader-file.js +1 -1
  114. package/rulepacks/jetwc/jetwc-markdown-link.js +1 -1
  115. package/rulepacks/jetwc/jetwc-method-displayname.js +1 -1
  116. package/rulepacks/jetwc/jetwc-methods.js +1 -1
  117. package/rulepacks/jetwc/jetwc-namespace.js +1 -1
  118. package/rulepacks/jetwc/jetwc-nested-defaults.js +1 -1
  119. package/rulepacks/jetwc/jetwc-nls-languages.js +1 -1
  120. package/rulepacks/jetwc/jetwc-nls-root.js +1 -1
  121. package/rulepacks/jetwc/jetwc-oj-register.js +1 -1
  122. package/rulepacks/jetwc/jetwc-ojcss.js +1 -1
  123. package/rulepacks/jetwc/jetwc-pack-children.js +1 -1
  124. package/rulepacks/jetwc/jetwc-packable-components.js +1 -1
  125. package/rulepacks/jetwc/jetwc-prerelease-dependencies.js +1 -1
  126. package/rulepacks/jetwc/jetwc-prerelease-pattern.js +1 -1
  127. package/rulepacks/jetwc/jetwc-prerelease-version.js +1 -1
  128. package/rulepacks/jetwc/jetwc-property-changed.js +1 -1
  129. package/rulepacks/jetwc/jetwc-property-displayname.js +1 -1
  130. package/rulepacks/jetwc/jetwc-property-nesting.js +1 -1
  131. package/rulepacks/jetwc/jetwc-property-translatable.js +1 -1
  132. package/rulepacks/jetwc/jetwc-public-modules.js +1 -1
  133. package/rulepacks/jetwc/jetwc-reference-npm-path.js +6 -0
  134. package/rulepacks/jetwc/jetwc-register-css.js +1 -1
  135. package/rulepacks/jetwc/jetwc-register-with-promises.js +1 -1
  136. package/rulepacks/jetwc/jetwc-require-paths.js +1 -1
  137. package/rulepacks/jetwc/jetwc-required-subproperty.js +1 -1
  138. package/rulepacks/jetwc/jetwc-reserved-property.js +1 -1
  139. package/rulepacks/jetwc/jetwc-schema.js +1 -1
  140. package/rulepacks/jetwc/jetwc-semantic-version.js +1 -1
  141. package/rulepacks/jetwc/jetwc-slot-displayname.js +1 -1
  142. package/rulepacks/jetwc/jetwc-slots.js +1 -1
  143. package/rulepacks/jetwc/jetwc-standard-files.js +1 -1
  144. package/rulepacks/jetwc/jetwc-status-since.js +6 -0
  145. package/rulepacks/jetwc/jetwc-unused-events.js +1 -1
  146. package/rulepacks/jetwc/jetwc-unused-slots.js +1 -1
  147. package/rulepacks/jetwc/jetwc-vb-category.js +1 -1
  148. package/rulepacks/jetwc/jetwc-vb-icon.js +1 -1
  149. package/rulepacks/jetwc/jetwc-vcomponent-jetversion.js +1 -1
  150. package/rulepacks/jetwc/jetwc-vcomponent-loader.js +1 -1
  151. package/rulepacks/jetwc/jetwc-vcomponent-version.js +1 -1
  152. package/rulepacks/jetwc/jetwc-version-openrange.js +1 -1
  153. package/rulepacks/jetwc/jetwc-writeback-required.js +1 -1
  154. package/rulepacks/jetwc/msgid.json +1 -1
  155. package/rulepacks/jetwc/rules.json +1 -1
  156. package/rulepacks/jetwc-lib/jetwcutils-auditComponentCacheManager.js +1 -1
  157. package/rulepacks/jetwc-lib/jetwcutils-commonListenerImpls.js +1 -1
  158. package/rulepacks/jetwc-lib/jetwcutils-componentAuditUtils.js +1 -1
  159. package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +1 -1
  160. package/rulepacks/jetwc-lib/jetwcutils-preCompiler.js +1 -1
  161. package/rulepacks/jetwc-lib/jetwcutils-tsxUtils.js +1 -1
  162. package/rulepacks/jetwco/jetwco-bootstrap.js +1 -1
  163. package/rulepacks/jetwco/jetwco-cacc-componentType.js +1 -1
  164. package/rulepacks/jetwco/jetwco-cacc-dependencies.js +1 -1
  165. package/rulepacks/jetwco/jetwco-cacc-dynamicSlots.js +1 -1
  166. package/rulepacks/jetwco/jetwco-cacc-eventBubbles.js +1 -1
  167. package/rulepacks/jetwco/jetwco-cacc-eventCancelable.js +1 -1
  168. package/rulepacks/jetwco/jetwco-cacc-eventPayload.js +1 -1
  169. package/rulepacks/jetwco/jetwco-cacc-events.js +1 -1
  170. package/rulepacks/jetwco/jetwco-cacc-helpers.js +1 -1
  171. package/rulepacks/jetwco/jetwco-cacc-jetVer.js +1 -1
  172. package/rulepacks/jetwco/jetwco-cacc-methodParamTypes.js +1 -1
  173. package/rulepacks/jetwco/jetwco-cacc-methodParams.js +1 -1
  174. package/rulepacks/jetwco/jetwco-cacc-methodReturnType.js +1 -1
  175. package/rulepacks/jetwco/jetwco-cacc-methods.js +1 -1
  176. package/rulepacks/jetwco/jetwco-cacc-packBundle.js +1 -1
  177. package/rulepacks/jetwco/jetwco-cacc-packBundleContent.js +1 -1
  178. package/rulepacks/jetwco/jetwco-cacc-packContent.js +1 -1
  179. package/rulepacks/jetwco/jetwco-cacc-properties.js +1 -1
  180. package/rulepacks/jetwco/jetwco-cacc-propertyDefault.js +1 -1
  181. package/rulepacks/jetwco/jetwco-cacc-propertyEnumeration.js +1 -1
  182. package/rulepacks/jetwco/jetwco-cacc-propertyReadOnly.js +1 -1
  183. package/rulepacks/jetwco/jetwco-cacc-propertyRequired.js +1 -1
  184. package/rulepacks/jetwco/jetwco-cacc-propertyType.js +1 -1
  185. package/rulepacks/jetwco/jetwco-cacc-propertyWriteback.js +1 -1
  186. package/rulepacks/jetwco/jetwco-cacc-publicModules.js +1 -1
  187. package/rulepacks/jetwco/jetwco-cacc-slotDataVariable.js +1 -1
  188. package/rulepacks/jetwco/jetwco-cacc-slotDataVariableType.js +1 -1
  189. package/rulepacks/jetwco/jetwco-cacc-slots.js +1 -1
  190. package/rulepacks/jetwco/jetwco-cacc-styleClasses.js +1 -1
  191. package/rulepacks/jetwco/jetwco-cacc-styleVariables.js +1 -1
  192. package/rulepacks/jetwco/jetwco-cacc-typeMappingOverrides.js +6 -0
  193. package/rulepacks/jetwco/jetwco-compjson-ns-reg.js +1 -1
  194. package/rulepacks/jetwco/jetwco-component-api-baseline-changes.js +1 -1
  195. package/rulepacks/jetwco/jetwco-component-api-changes.js +1 -1
  196. package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +1 -1
  197. package/rulepacks/jetwco/jetwco-component-cdn.js +1 -1
  198. package/rulepacks/jetwco/jetwco-description-standards.js +1 -1
  199. package/rulepacks/jetwco/jetwco-displayname-standards.js +1 -1
  200. package/rulepacks/jetwco/jetwco-exchange-version-check.js +1 -1
  201. package/rulepacks/jetwco/jetwco-license-info.js +1 -1
  202. package/rulepacks/jetwco/jetwco-prerelease-cdn.js +1 -1
  203. package/rulepacks/jetwco/jetwco-thirdparty-ba.js +1 -1
  204. package/rulepacks/jetwco/msgid.json +1 -1
  205. package/rulepacks/jetwco/rules.json +1 -1
  206. package/rules/jaf/jaf-ts-noparser.js +6 -0
  207. package/rules/jaf/msgid.json +1 -1
  208. package/rules/jaf/rules.json +1 -1
  209. package/rules/jet/helpers/has-slot-name.js +1 -1
  210. package/rules/jet/helpers/style-selector.js +1 -1
  211. package/rules/jet/helpers/tsx/has-slot-name.js +6 -0
  212. package/rules/jet/msgid.json +1 -1
  213. package/rules/jet/oj-acc-aria-labelledby.js +1 -1
  214. package/rules/jet/oj-cca-compjson-bp-ar.js +1 -1
  215. package/rules/jet/oj-cca-compjson-bp-obj.js +1 -1
  216. package/rules/jet/oj-css-bp-dir-flow.js +1 -1
  217. package/rules/jet/oj-html-attr-$unique.js +1 -1
  218. package/rules/jet/oj-html-attr-expr-delims.js +6 -0
  219. package/rules/jet/oj-html-combo-converter.js +1 -1
  220. package/rules/jet/oj-html-file-pick-accept.js +1 -1
  221. package/rules/jet/oj-html-form-bindif.js +1 -1
  222. package/rules/jet/oj-html-input-isodate.js +1 -1
  223. package/rules/jet/oj-html-invalid-doctype.js +1 -1
  224. package/rules/jet/oj-html-msgs-cat-text.js +1 -1
  225. package/rules/jet/oj-html-ojattr-deprecated.js +1 -1
  226. package/rules/jet/oj-html-ojattr-enum-deprecated.js +1 -1
  227. package/rules/jet/oj-html-ojtag-deprecated.js +1 -1
  228. package/rules/jet/oj-html-ojtag-ns.js +1 -1
  229. package/rules/jet/oj-html-rating-gauge-track-resize.js +6 -0
  230. package/rules/jet/oj-html-self-close.js +1 -1
  231. package/rules/jet/oj-html-slot-deprecated.js +1 -1
  232. package/rules/jet/oj-html-slot-item-minmax.js +1 -1
  233. package/rules/jet/oj-html-slot-name.js +1 -1
  234. package/rules/jet/oj-html-slot-pref-content.js +1 -1
  235. package/rules/jet/oj-html-style.js +1 -1
  236. package/rules/jet/oj-html-stylesel.js +1 -1
  237. package/rules/jet/oj-html-tabbar-edge.js +6 -0
  238. package/rules/jet/oj-html-unsup-theme.js +1 -1
  239. package/rules/jet/oj-html-wctag-maintenance.js +1 -1
  240. package/rules/jet/oj-html-wctag-nested.js +1 -1
  241. package/rules/jet/oj-html-wctag-supersedes.js +6 -0
  242. package/rules/jet/oj-js-numconv-pattern.js +6 -0
  243. package/rules/jet/oj-ts-numconv-pattern.js +6 -0
  244. package/rules/jet/oj-tsx-5-tag-obs.js +1 -1
  245. package/rules/jet/oj-tsx-acc-avatar-aria-role.js +6 -0
  246. package/rules/jet/oj-tsx-acc-button-onclick.js +1 -1
  247. package/rules/jet/oj-tsx-aria-ojselector-labelledby.js +1 -1
  248. package/rules/jet/oj-tsx-aria-prop.js +1 -1
  249. package/rules/jet/oj-tsx-attr-req.js +1 -1
  250. package/rules/jet/oj-tsx-cca-tagname.js +1 -1
  251. package/rules/jet/oj-tsx-combo-converter.js +1 -1
  252. package/rules/jet/oj-tsx-databind-all.js +1 -1
  253. package/rules/jet/oj-tsx-dlg-title.js +1 -1
  254. package/rules/jet/oj-tsx-form-bindif.js +6 -0
  255. package/rules/jet/oj-tsx-form-noflex.js +6 -0
  256. package/rules/jet/oj-tsx-input-isodate.js +1 -1
  257. package/rules/jet/oj-tsx-ojattr-deprecated.js +6 -0
  258. package/rules/jet/oj-tsx-ojattr-enum-deprecated.js +6 -0
  259. package/rules/jet/oj-tsx-ojattr-value.js +1 -1
  260. package/rules/jet/oj-tsx-ojattr.js +1 -1
  261. package/rules/jet/oj-tsx-ojtag-deprecated.js +1 -1
  262. package/rules/jet/oj-tsx-ojtag-ns.js +6 -0
  263. package/rules/jet/oj-tsx-pageopts-type.js +1 -1
  264. package/rules/jet/oj-tsx-picker-attrs.js +1 -1
  265. package/rules/jet/oj-tsx-prop-inline-definition.js +1 -1
  266. package/rules/jet/oj-tsx-rating-gauge-size.js +1 -1
  267. package/rules/jet/oj-tsx-rating-gauge-track-resize.js +6 -0
  268. package/rules/jet/oj-tsx-slot-deprecated.js +6 -0
  269. package/rules/jet/oj-tsx-slot-pref-content.js +6 -0
  270. package/rules/jet/oj-tsx-tabbar-edge.js +6 -0
  271. package/rules/jet/oj-tsx-unsup-theme.js +1 -1
  272. package/rules/jet/oj-tsx-wctag-maintenance.js +1 -1
  273. package/rules/jet/oj-tsx-wctag-nested.js +1 -1
  274. package/rules/jet/rules.json +1 -1
  275. package/schema/component-schema.json +1 -1
  276. package/src/JafCore.js +1 -1
  277. package/types/index.d.ts +6 -4
  278. package/rules/jet/oj-html-cspexpr.js +0 -6
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const AuditComponentCacheManager=require('../jetwc-lib/jetwcutils-auditComponentCacheManager');const NetUtils=require('../../lib/NetUtils');const CommonImpl=require('../jetwc-lib/jetwcutils-commonListenerImpls');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-component-api-baseline-changes'};ruleDef.prototype.getShortDescription=function(){return'Check components for API changes against a base version'};ruleDef.prototype.getDescription=function(){return'This audit compares the APIs exposed by components with a designated baseline version of a component in the Exchange Catalog and checks if the component APIs have changed'};ruleDef.prototype.register=function(context){return{startaudit:this._auditPrep,closedownRP:this._dealWithCache,compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._auditPrep=function(context){let baselineConfigured=false;let baselineMetadata=[];this.exchangeURL=CommonImpl.checkForExchangeConfiguration(context);if(this.exchangeURL){this.acCache=new AuditComponentCacheManager(context,this.getName());if(this.acCache.isBaselineIndexAvailable()){const exchangeRoot=this.exchangeURL;let baselineIndex=this.acCache.readComponentCacheIndexFile();if(Object.entries(baselineIndex).length===0){const baselineConfiguration=this.acCache.getBaselineOpts();let exchangeReadError=false;for(const[baselineComponent,baselineComponentVersion]of Object.entries(baselineConfiguration)){const eachComponentInfo=this._cacheBaselineMetadataForComponent(context,baselineComponent,baselineComponentVersion,exchangeRoot);if(!eachComponentInfo.inError){baselineMetadata=baselineMetadata.concat(eachComponentInfo.metadata)}else{exchangeReadError=true}}if(!exchangeReadError){baselineMetadata.forEach(component=>{const fullName=Utils.getComponentFullName(component);baselineIndex[fullName]=component.version;if(!this.acCache.existsInComponentCache(fullName,component.version)){this.acCache.writeToComponentCache(fullName,component.version,component)}});this.acCache.writeComponentCacheIndexFile(baselineIndex)}}if(Object.entries(baselineIndex).length>0){baselineConfigured=true;if(Object.keys(baselineIndex).length>0){Utils.safeSetExtension(context,{baselineIndex:baselineIndex})}}}}};ruleDef.prototype._cacheBaselineMetadataForComponent=function(auditContext,componentName,componentVersion,exchangeUrl){const msg=auditContext.utils.msgLib;let componentMetaArray=[];let inErrorCondition=false;try{let componentMeta;if(this.acCache.existsInComponentCache(componentName,componentVersion)){componentMeta=this.acCache.readFromComponentCache(componentName,componentVersion)}else{const netUtils=new NetUtils;const componentMetaResp=netUtils.loadUrl(`${exchangeUrl}/components/${componentName}/versions/${componentVersion}`);if(componentMetaResp.statusCode===200&&componentMetaResp.body){const componentResponseMeta=JSON.parse(componentMetaResp.body);componentMeta=componentResponseMeta.component}else if(componentMetaResp.statusCode===403){msg.info(`${auditContext.ruleName} - Baseline component ${componentName}@${componentVersion} cannot be read - skipping`)}else{const issue=new auditContext.Issue(`Unexpected error for the rule ${auditContext.ruleName} reading ${componentName}@${componentVersion}: Response ${componentMetaResp.statusCode} (${exchangeUrl})`);issue.setMsgKey('jetwco-component-api-baseline-changes_2');auditContext.reporter.addIssue(issue,auditContext,'critical');inErrorCondition=true}}if(!inErrorCondition&&componentMeta){const compType=componentMeta.type?componentMeta.type:'composite';if(compType==='pack'){const dependents=componentMeta.dependencies;if(dependents){for(const[packComponent,packComponentVersion]of Object.entries(dependents)){const eachPackMemberInfo=this._cacheBaselineMetadataForComponent(auditContext,packComponent,packComponentVersion,exchangeUrl);if(!eachPackMemberInfo.inError){componentMetaArray=componentMetaArray.concat(eachPackMemberInfo.metadata)}else{inErrorCondition=true}}}}componentMetaArray.push(componentMeta)}}catch(e){msg.error(`Exchange read error ${JSON.stringify(e)}`);const issue=new auditContext.Issue(`The exchangeURL value specified for the rule ${auditContext.ruleName} is incorrect: ${exchangeUrl}`);issue.setMsgKey('jetwco-component-api-baseline-changes_2');auditContext.reporter.addIssue(issue,context,'critical');inErrorCondition=true};return{inError:inErrorCondition,metadata:componentMetaArray}};ruleDef.prototype._dealWithCache=function(context){const shouldClearCache=context.rulePack.getRuleOption('clearCache',this.getName());if(shouldClearCache&&this.acCache){this.acCache.removeLocalCache()}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);this._baselineCheck(context,fullName,componentType,meta)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){let remappedDependencies;if(componentInfo.dependencies){remappedDependencies=componentInfo.dependencies.reduce((asMap,entry)=>{asMap[entry.name]=entry.range;return asMap},{})}const meta={version:componentInfo.version,jetVersion:componentInfo.jetVersion,properties:componentInfo.properties,methods:componentInfo.methods,events:componentInfo.events,sots:componentInfo.slots,dependencies:remappedDependencies};this._baselineCheck(context,componentInfo.fullName,componentInfo.type,meta)}};ruleDef.prototype._baselineCheck=function(context,fullName,componentType,componentMeta){const baselineIndex=context.rulePack.getExtension().baselineIndex;if(componentMeta&&baselineIndex){const componentVersion=componentMeta.version;const baselineVersion=baselineIndex[fullName];if(baselineVersion){const semver=context.utils.semVerUtils;const baselineComponentMeta=this.acCache.readFromComponentCache(fullName,baselineVersion);try{switch(componentType){case'pack':this._conductCheck(this._packContentsDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._packBundlesDiff,componentMeta,baselineComponentMeta);break;case'composite':this._conductCheck(this._detectJetVersionDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectDependencyDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectMethodDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectEventDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectSlotDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectDynamicSlotDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectPropertyDiff,componentMeta,baselineComponentMeta);break;case'vbcs-pattern':this._conductCheck(this._detectDependencyDiff,semver,componentMeta,baselineComponentMeta);break;case'resource':this._conductCheck(this._detectJetVersionDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectDependencyDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectPublicModulesDiff,componentMeta,baselineComponentMeta);break;}}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${componentVersion} detected in comparison with baseline version ${baselineVersion}. Indication: ${auditDetail}`);issue.setMsgKey('jetwco-component-api-baseline-changes_1');context.reporter.addIssue(issue,context)}}}};ruleDef.prototype._conductCheck=function(checkCallback,semver,config,existingConfig){const result=checkCallback.call(this,semver,config,existingConfig);if(result){throw result}};ruleDef.prototype._detectJetVersionDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const componentJetVersion=config.jetVersion?config.jetVersion:'0.0.0';const existingJetVersion=existingConfig.jetVersion?existingConfig.jetVersion:'0.0.0';if(componentJetVersion!==existingJetVersion){if(existingJetVersion==='0.0.0'||componentJetVersion==='0.0.0'){explanation='JET version range has been added or removed'}else{const minVersion=semver.minVersion(componentJetVersion);const minExistingVersion=semver.minVersion(existingJetVersion);if(semver.major(minVersion)>semver.major(minExistingVersion)){explanation='minimum major JET version required has increased'}else if(semver.minor(minVersion)>semver.minor(minExistingVersion)){explanation='minimum minor JET version required has increased'}}}return explanation};ruleDef.prototype._packContentsDiff=function(config,existingConfig){let explanation;const configDeps=config.dependencies?Object.keys(config.dependencies):[];const existingDeps=existingConfig.dependencies?Object.keys(existingConfig.dependencies):[];if(configDeps.length>0){for(let i=0;i<existingDeps.length;i++){const key=existingDeps[i];if(!config.dependencies.hasOwnProperty(key)){explanation=`Pack component ${key} has been removed`;break}}}return explanation};ruleDef.prototype._packBundlesDiff=function(config,existingConfig){let explanation;const configBundles=config.bundles?Object.keys(config.bundles):[];const existingBundles=existingConfig.bundles?Object.keys(existingConfig.bundles):[];for(let i=0;i<existingBundles.length;i++){const key=existingBundles[i];if(!config.bundles.hasOwnProperty(key)){explanation=`Pack bundle '${key}' has been removed`;break}else{const configContents=config.bundles[key];const existingContents=existingConfig.bundles[key];for(let i=0;i<existingContents.length;i++){const module=existingContents[i];if(!configContents.includes(module)){explanation=`Pack bundle '${key}' entry '${module}' removed`;break}}}}return explanation};ruleDef.prototype._detectPublicModulesDiff=function(config,existingConfig){let explanation;const configPM=config.publicModules?config.publicModules:[];const existingPM=existingConfig.publicModules?existingConfig.publicModules:[];for(let i=0;i<existingPM.length;i++){const module=existingPM[i];if(!configPM.includes(module)){explanation=`Public Module entry '${module}' has been removed`;break}}return explanation};ruleDef.prototype._detectDependencyDiff=function(semver,config,existingConfig){let explanation;const configDeps=config.dependencies?Object.keys(config.dependencies):[];const existingDeps=existingConfig.dependencies?Object.keys(existingConfig.dependencies):[];if(configDeps.length>existingDeps.length){explanation='More dependencies are declared by component'}else{if(configDeps.length>0){for(let i=0;i<existingDeps.length;i++){const key=existingDeps[i];if(config.dependencies.hasOwnProperty(key)){const newDepVersion=semver.minVersion(config.dependencies[key]);const existingDepVersion=semver.minVersion(existingConfig.dependencies[key]);if(semver.major(newDepVersion)!==semver.major(existingDepVersion)){explanation='Different major version of dependency '+key;break}if(semver.minor(newDepVersion)!==semver.minor(existingDepVersion)){explanation='Different minor version of dependency '+key;break}}else{explanation=`Dependency ${key} has been removed`;break}}}}return explanation};ruleDef.prototype._detectMethodDiff=function(config,existingConfig){let explanation;const configMethods=config.methods?Object.keys(config.methods):[];const existingMethods=existingConfig.methods?Object.keys(existingConfig.methods):[];for(let i=0;i<existingMethods.length;i++){const key=existingMethods[i];if(config.methods.hasOwnProperty(key)){const configMethodParams=config.methods[key].params?config.methods[key].params:[];const existingMethodParams=existingConfig.methods[key].params?existingConfig.methods[key].params:[];for(let j=0;j<existingMethodParams.length;j++){if(j>=configMethodParams.length){explanation=`Existing method '${key}' has fewer parameters`;break}else{if(!this._compareType(configMethodParams[j],existingMethodParams[j])){explanation=`Method '${key}' parameter number:${j+1} has a changed type`;break}}}if(!explanation&&configMethodParams.length>existingMethodParams.length){explanation=`Existing method '${key}' has additional parameters`;break}}else{explanation=`Existing method '${key}' has been removed`;break}}return explanation};ruleDef.prototype._detectPropertyDiff=function(config,existingConfig){let explanation;const configProps=config.properties?Object.keys(config.properties):[];const existingProps=existingConfig.properties?Object.keys(existingConfig.properties):[];explanation=this._compareProperties(config.properties,existingConfig.properties);if(!explanation){const addedRequiredProps=configProps.filter(addedProp=>!existingProps.includes(addedProp)&&config[addedProp]&&config[addedProp].required);if(addedRequiredProps.length>0){explanation=`Required property(ies) added: ${addedRequiredProps.join(',')}`}}return explanation};ruleDef.prototype._detectEventDiff=function(config,existingConfig){let explanation;const configEvents=config.events?Object.keys(config.events):[];const existingEvents=existingConfig.events?Object.keys(existingConfig.events):[];for(let i=0;i<existingEvents.length;i++){const key=existingEvents[i];if(config.events.hasOwnProperty(key)){const configEventDetail=config.events[key].detail?config.events[key].detail:{};const existingEventDetail=existingConfig.events[key].detail?existingConfig.events[key].detail:{};const detailKeys=Object.keys(configEventDetail);const existingDetailKeys=Object.keys(existingEventDetail);for(let j=0;j<existingDetailKeys.length;j++){const detailKey=existingDetailKeys[j];if(j>=detailKeys.length||!configEventDetail.hasOwnProperty(detailKey)){explanation=`Event '${key}' has missing entries in the detail payload`;break}else{if(!this._compareType(configEventDetail[detailKey],existingEventDetail[detailKey])){explanation=`Event '${key}' detail attribute '${detailKey}' has a changed type`;break}}}if(!explanation&&config.events[key].bubbles!==existingConfig.events[key].bubbles){explanation=`Event '${key}' has a changed bubbling state`;break}if(!explanation&&config.events[key].cancelable!==existingConfig.events[key].cancelable){explanation=`Event '${key}' has changed cancelable state`;break}}else{explanation=`Event '${key}' has been removed`;break}}return explanation};ruleDef.prototype._detectSlotDiff=function(config,existingConfig){return this._detectTypedSlotDiff('slots',config,existingConfig)};ruleDef.prototype._detectDynamicSlotDiff=function(config,existingConfig){return this._detectTypedSlotDiff('dynamicSlots',config,existingConfig)};ruleDef.prototype._detectTypedSlotDiff=function(slotType,config,existingConfig){let explanation;const configSlots=config[slotType]?Object.keys(config[slotType]):[];const existingSlots=existingConfig[slotType]?Object.keys(existingConfig[slotType]):[];for(let i=0;i<existingSlots.length;i++){const key=existingSlots[i];if(config[slotType].hasOwnProperty(key)){const configSlotData=config[slotType][key].data?config[slotType][key].data:{};const existingSlotData=existingConfig[slotType][key].data?existingConfig[slotType][key].data:{};const dataKeys=Object.keys(configSlotData);const existingDataKeys=Object.keys(existingSlotData);for(let j=0;j<existingDataKeys.length;j++){const dataKey=existingDataKeys[j];if(j>=dataKeys.length||!configSlotData.hasOwnProperty(dataKey)){explanation=`Template slot '${key}' - '${dataKey}' has been removed from data definition`;break}else{if(!this._compareType(configSlotData[dataKey],existingSlotData[dataKey])){explanation=`Template slot '${key}' data attribute '${dataKey}' has a changed type`;break}}}}else{explanation=`Slot '${key}' has been removed`;break}}return explanation};ruleDef.prototype._compareType=function(newTyped,existingTyped){let matches=true;const newType=newTyped&&newTyped.type?newTyped.type:null;const existingType=existingTyped&&existingTyped.type?existingTyped.type:null;if(newType!==existingType){if(newType.includes('|')){const newTypeOptions=newType?newType.split('|'):[];const existingTypeOptions=existingType?existingType.split('|'):[];matches=existingTypeOptions.every(checkType=>newTypeOptions.includes(checkType))}else{matches=false}}return matches};ruleDef.prototype._compareProperties=function(newProps,oldProps,path){let explanation;const configProps=newProps?Object.keys(newProps):[];const existingProps=oldProps?Object.keys(oldProps):[];for(let i=0;i<existingProps.length;i++){const key=existingProps[i];if(newProps.hasOwnProperty(key)){const newProperty=newProps[key];const oldProperty=oldProps[key];if(!this._compareType(newProperty,oldProperty)){explanation=`Property type change for '${path?path:''}${key}'`;break}if(oldProperty.hasOwnProperty('enumValues')){const newOptions=newProperty.hasOwnProperty('enumValues')?newProperty.enumValues:[];if(!oldProperty.enumValues.every(checkOption=>newOptions.includes(checkOption))){explanation=`Enumeration value option removed from property '${path?path:''}${key}'`;break}}else if(newProperty.hasOwnProperty('enumValues')){explanation=`Property '${path?path:''}${key}' is now constrained by an enumeration`;break}if(!path){if(oldProperty.writeback&&!newProperty.writeback){explanation=`Property '${key}' is no longer writeback enabled`;break}if(!oldProperty.required&&newProperty.required){explanation=`Property '${key}' has been made required`;break}const oldROState=oldProperty.hasOwnProperty('readOnly')?oldProperty.readOnly:false;const newROState=newProperty.hasOwnProperty('readOnly')?newProperty.readOnly:false;if(oldROState!==newROState){explanation=`Property '${key}' readOnly state has changed`;break}const oldDefault=oldProperty.hasOwnProperty('value')?JSON.stringify(oldProperty.value):'';const newDefault=newProperty.hasOwnProperty('value')?JSON.stringify(newProperty.value):'';if(oldDefault!==newDefault){explanation=`Property '${key}' default value has changed`;break}}if(newProperty.hasOwnProperty('properties')||oldProperty.hasOwnProperty('properties')){const newSubProps=newProperty.properties?newProperty.properties:{};const oldSubProps=oldProperty.properties?oldProperty.properties:{};const propPath=path?path+key+'.':key+'.';explanation=this._compareProperties(newSubProps,oldSubProps,propPath);if(explanation){break}}}else{explanation=`Property '${path?path:''}${key}' has been removed`;break}}return explanation};module.exports=ruleDef;
6
+ const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const AuditComponentCacheManager=require("../jetwc-lib/jetwcutils-auditComponentCacheManager");const NetUtils=require("../../lib/NetUtils");const CommonImpl=require("../jetwc-lib/jetwcutils-commonListenerImpls");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-component-api-baseline-changes"};ruleDef.prototype.getShortDescription=function(){return"Check components for API changes against a base version"};ruleDef.prototype.getDescription=function(){return"This audit compares the APIs exposed by components with a designated baseline version of a component in the Exchange Catalog and checks if the component APIs have changed"};ruleDef.prototype.register=function(context){return{startaudit:this._auditPrep,closedownRP:this._dealWithCache,compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._auditPrep=function(context){let baselineConfigured=false;let baselineMetadata=[];this.exchangeURL=CommonImpl.checkForExchangeConfiguration(context);if(this.exchangeURL){this.acCache=new AuditComponentCacheManager(context,this.getName());if(this.acCache.isBaselineIndexAvailable()){const exchangeRoot=this.exchangeURL;let baselineIndex=this.acCache.readComponentCacheIndexFile();if(Object.entries(baselineIndex).length===0){const baselineConfiguration=this.acCache.getBaselineOpts();let exchangeReadError=false;for(const[baselineComponent,baselineComponentVersion]of Object.entries(baselineConfiguration)){const eachComponentInfo=this._cacheBaselineMetadataForComponent(context,baselineComponent,baselineComponentVersion,exchangeRoot);if(!eachComponentInfo.inError){baselineMetadata=baselineMetadata.concat(eachComponentInfo.metadata)}else{exchangeReadError=true}}if(!exchangeReadError){baselineMetadata.forEach(component=>{const fullName=Utils.getComponentFullName(component);baselineIndex[fullName]=component.version;if(!this.acCache.existsInComponentCache(fullName,component.version)){this.acCache.writeToComponentCache(fullName,component.version,component)}});this.acCache.writeComponentCacheIndexFile(baselineIndex)}}if(Object.entries(baselineIndex).length>0){baselineConfigured=true;if(Object.keys(baselineIndex).length>0){Utils.safeSetExtension(context,{baselineIndex:baselineIndex})}}}}};ruleDef.prototype._cacheBaselineMetadataForComponent=function(auditContext,componentName,componentVersion,exchangeUrl){const msg=auditContext.utils.msgLib;let componentMetaArray=[];let inErrorCondition=false;try{let componentMeta;if(this.acCache.existsInComponentCache(componentName,componentVersion)){componentMeta=this.acCache.readFromComponentCache(componentName,componentVersion)}else{const netUtils=new NetUtils;const componentMetaResp=netUtils.loadUrl(`${exchangeUrl}/components/${componentName}/versions/${componentVersion}`);if(componentMetaResp.statusCode===200&&componentMetaResp.body){const componentResponseMeta=JSON.parse(componentMetaResp.body);componentMeta=componentResponseMeta.component}else if(componentMetaResp.statusCode===403){msg.info(`${auditContext.ruleName} - Baseline component ${componentName}@${componentVersion} cannot be read - skipping`)}else{const issue=new auditContext.Issue(`Unexpected error for the rule ${auditContext.ruleName} reading ${componentName}@${componentVersion}: Response ${componentMetaResp.statusCode} (${exchangeUrl})`);issue.setMsgKey("jetwco-component-api-baseline-changes_2");auditContext.reporter.addIssue(issue,auditContext,"critical");inErrorCondition=true}}if(!inErrorCondition&&componentMeta){const compType=componentMeta.type?componentMeta.type:"composite";if(compType==="pack"){const dependents=componentMeta.dependencies;if(dependents){for(const[packComponent,packComponentVersion]of Object.entries(dependents)){const eachPackMemberInfo=this._cacheBaselineMetadataForComponent(auditContext,packComponent,packComponentVersion,exchangeUrl);if(!eachPackMemberInfo.inError){componentMetaArray=componentMetaArray.concat(eachPackMemberInfo.metadata)}else{inErrorCondition=true}}}}componentMetaArray.push(componentMeta)}}catch(e){msg.error(`Exchange read error ${JSON.stringify(e)}`);const issue=new auditContext.Issue(`The exchangeURL value specified for the rule ${auditContext.ruleName} is incorrect: ${exchangeUrl}`);issue.setMsgKey("jetwco-component-api-baseline-changes_2");auditContext.reporter.addIssue(issue,context,"critical");inErrorCondition=true};return{inError:inErrorCondition,metadata:componentMetaArray}};ruleDef.prototype._dealWithCache=function(context){const shouldClearCache=context.rulePack.getRuleOption("clearCache",this.getName());if(shouldClearCache&&this.acCache){this.acCache.removeLocalCache()}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);this._baselineCheck(context,fullName,componentType,meta)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){let remappedDependencies;if(componentInfo.dependencies){remappedDependencies=componentInfo.dependencies.reduce((asMap,entry)=>{asMap[entry.name]=entry.range;return asMap},{})}const meta={version:componentInfo.version,jetVersion:componentInfo.jetVersion,properties:componentInfo.properties,methods:componentInfo.methods,events:componentInfo.events,sots:componentInfo.slots,dependencies:remappedDependencies};this._baselineCheck(context,componentInfo.fullName,componentInfo.type,meta)}};ruleDef.prototype._baselineCheck=function(context,fullName,componentType,componentMeta){const baselineIndex=context.rulePack.getExtension().baselineIndex;if(componentMeta&&baselineIndex){const componentVersion=componentMeta.version;const baselineVersion=baselineIndex[fullName];if(baselineVersion){const semver=context.utils.semVerUtils;const baselineComponentMeta=this.acCache.readFromComponentCache(fullName,baselineVersion);try{switch(componentType){case"pack":this._conductCheck(this._packContentsDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._packBundlesDiff,componentMeta,baselineComponentMeta);break;case"composite":this._conductCheck(this._detectJetVersionDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectDependencyDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectMethodDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectEventDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectSlotDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectDynamicSlotDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectPropertyDiff,componentMeta,baselineComponentMeta);break;case"vbcs-pattern":this._conductCheck(this._detectDependencyDiff,semver,componentMeta,baselineComponentMeta);break;case"resource":this._conductCheck(this._detectJetVersionDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectDependencyDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectPublicModulesDiff,componentMeta,baselineComponentMeta);break}}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${componentVersion} detected in comparison with baseline version ${baselineVersion}. Indication: ${auditDetail}`);issue.setMsgKey("jetwco-component-api-baseline-changes_1");context.reporter.addIssue(issue,context)}}}};ruleDef.prototype._conductCheck=function(checkCallback,semver,config,existingConfig){const result=checkCallback.call(this,semver,config,existingConfig);if(result){throw result}};ruleDef.prototype._detectJetVersionDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const componentJetVersion=config.jetVersion?config.jetVersion:"0.0.0";const existingJetVersion=existingConfig.jetVersion?existingConfig.jetVersion:"0.0.0";if(componentJetVersion!==existingJetVersion){if(existingJetVersion==="0.0.0"||componentJetVersion==="0.0.0"){explanation="JET version range has been added or removed"}else{const minVersion=semver.minVersion(componentJetVersion);const minExistingVersion=semver.minVersion(existingJetVersion);if(semver.major(minVersion)>semver.major(minExistingVersion)){explanation="minimum major JET version required has increased"}else if(semver.minor(minVersion)>semver.minor(minExistingVersion)){explanation="minimum minor JET version required has increased"}}}return explanation};ruleDef.prototype._packContentsDiff=function(config,existingConfig){let explanation;const configDeps=config.dependencies?Object.keys(config.dependencies):[];const existingDeps=existingConfig.dependencies?Object.keys(existingConfig.dependencies):[];if(configDeps.length>0){for(let i=0;i<existingDeps.length;i++){const key=existingDeps[i];if(!config.dependencies.hasOwnProperty(key)){explanation=`Pack component ${key} has been removed`;break}}}return explanation};ruleDef.prototype._packBundlesDiff=function(config,existingConfig){let explanation;const configBundles=config.bundles?Object.keys(config.bundles):[];const existingBundles=existingConfig.bundles?Object.keys(existingConfig.bundles):[];for(let i=0;i<existingBundles.length;i++){const key=existingBundles[i];if(!config.bundles.hasOwnProperty(key)){explanation=`Pack bundle '${key}' has been removed`;break}else{const configContents=config.bundles[key];const existingContents=existingConfig.bundles[key];for(let i=0;i<existingContents.length;i++){const module=existingContents[i];if(!configContents.includes(module)){explanation=`Pack bundle '${key}' entry '${module}' removed`;break}}}}return explanation};ruleDef.prototype._detectPublicModulesDiff=function(config,existingConfig){let explanation;const configPM=config.publicModules?config.publicModules:[];const existingPM=existingConfig.publicModules?existingConfig.publicModules:[];for(let i=0;i<existingPM.length;i++){const module=existingPM[i];if(!configPM.includes(module)){explanation=`Public Module entry '${module}' has been removed`;break}}return explanation};ruleDef.prototype._detectDependencyDiff=function(semver,config,existingConfig){let explanation;const configDeps=config.dependencies?Object.keys(config.dependencies):[];const existingDeps=existingConfig.dependencies?Object.keys(existingConfig.dependencies):[];if(configDeps.length>existingDeps.length){explanation="More dependencies are declared by component"}else{if(configDeps.length>0){for(let i=0;i<existingDeps.length;i++){const key=existingDeps[i];if(config.dependencies.hasOwnProperty(key)){const newDepVersion=semver.minVersion(config.dependencies[key]);const existingDepVersion=semver.minVersion(existingConfig.dependencies[key]);if(semver.major(newDepVersion)!==semver.major(existingDepVersion)){explanation="Different major version of dependency "+key;break}if(semver.minor(newDepVersion)!==semver.minor(existingDepVersion)){explanation="Different minor version of dependency "+key;break}}else{explanation=`Dependency ${key} has been removed`;break}}}}return explanation};ruleDef.prototype._detectMethodDiff=function(config,existingConfig){let explanation;const configMethods=config.methods?Object.keys(config.methods):[];const existingMethods=existingConfig.methods?Object.keys(existingConfig.methods):[];for(let i=0;i<existingMethods.length;i++){const key=existingMethods[i];if(config.methods.hasOwnProperty(key)){const configMethodParams=config.methods[key].params?config.methods[key].params:[];const existingMethodParams=existingConfig.methods[key].params?existingConfig.methods[key].params:[];for(let j=0;j<existingMethodParams.length;j++){if(j>=configMethodParams.length){explanation=`Existing method '${key}' has fewer parameters`;break}else{if(!this._compareType(configMethodParams[j],existingMethodParams[j])){explanation=`Method '${key}' parameter number:${j+1} has a changed type`;break}}}if(!explanation&&configMethodParams.length>existingMethodParams.length){explanation=`Existing method '${key}' has additional parameters`;break}}else{explanation=`Existing method '${key}' has been removed`;break}}return explanation};ruleDef.prototype._detectPropertyDiff=function(config,existingConfig){let explanation;const configProps=config.properties?Object.keys(config.properties):[];const existingProps=existingConfig.properties?Object.keys(existingConfig.properties):[];explanation=this._compareProperties(config.properties,existingConfig.properties);if(!explanation){const addedRequiredProps=configProps.filter(addedProp=>!existingProps.includes(addedProp)&&config[addedProp]&&config[addedProp].required);if(addedRequiredProps.length>0){explanation=`Required property(ies) added: ${addedRequiredProps.join(",")}`}}return explanation};ruleDef.prototype._detectEventDiff=function(config,existingConfig){let explanation;const configEvents=config.events?Object.keys(config.events):[];const existingEvents=existingConfig.events?Object.keys(existingConfig.events):[];for(let i=0;i<existingEvents.length;i++){const key=existingEvents[i];if(config.events.hasOwnProperty(key)){const configEventDetail=config.events[key].detail?config.events[key].detail:{};const existingEventDetail=existingConfig.events[key].detail?existingConfig.events[key].detail:{};const detailKeys=Object.keys(configEventDetail);const existingDetailKeys=Object.keys(existingEventDetail);for(let j=0;j<existingDetailKeys.length;j++){const detailKey=existingDetailKeys[j];if(j>=detailKeys.length||!configEventDetail.hasOwnProperty(detailKey)){explanation=`Event '${key}' has missing entries in the detail payload`;break}else{if(!this._compareType(configEventDetail[detailKey],existingEventDetail[detailKey])){explanation=`Event '${key}' detail attribute '${detailKey}' has a changed type`;break}}}if(!explanation&&config.events[key].bubbles!==existingConfig.events[key].bubbles){explanation=`Event '${key}' has a changed bubbling state`;break}if(!explanation&&config.events[key].cancelable!==existingConfig.events[key].cancelable){explanation=`Event '${key}' has changed cancelable state`;break}}else{explanation=`Event '${key}' has been removed`;break}}return explanation};ruleDef.prototype._detectSlotDiff=function(config,existingConfig){return this._detectTypedSlotDiff("slots",config,existingConfig)};ruleDef.prototype._detectDynamicSlotDiff=function(config,existingConfig){return this._detectTypedSlotDiff("dynamicSlots",config,existingConfig)};ruleDef.prototype._detectTypedSlotDiff=function(slotType,config,existingConfig){let explanation;const configSlots=config[slotType]?Object.keys(config[slotType]):[];const existingSlots=existingConfig[slotType]?Object.keys(existingConfig[slotType]):[];for(let i=0;i<existingSlots.length;i++){const key=existingSlots[i];if(config[slotType].hasOwnProperty(key)){const configSlotData=config[slotType][key].data?config[slotType][key].data:{};const existingSlotData=existingConfig[slotType][key].data?existingConfig[slotType][key].data:{};const dataKeys=Object.keys(configSlotData);const existingDataKeys=Object.keys(existingSlotData);for(let j=0;j<existingDataKeys.length;j++){const dataKey=existingDataKeys[j];if(j>=dataKeys.length||!configSlotData.hasOwnProperty(dataKey)){explanation=`Template slot '${key}' - '${dataKey}' has been removed from data definition`;break}else{if(!this._compareType(configSlotData[dataKey],existingSlotData[dataKey])){explanation=`Template slot '${key}' data attribute '${dataKey}' has a changed type`;break}}}}else{explanation=`Slot '${key}' has been removed`;break}}return explanation};ruleDef.prototype._compareType=function(newTyped,existingTyped){let matches=true;const newType=newTyped&&newTyped.type?newTyped.type:null;const existingType=existingTyped&&existingTyped.type?existingTyped.type:null;if(newType!==existingType){if(newType.includes("|")){const newTypeOptions=newType?newType.split("|"):[];const existingTypeOptions=existingType?existingType.split("|"):[];matches=existingTypeOptions.every(checkType=>newTypeOptions.includes(checkType))}else{matches=false}}return matches};ruleDef.prototype._compareProperties=function(newProps,oldProps,path){let explanation;const configProps=newProps?Object.keys(newProps):[];const existingProps=oldProps?Object.keys(oldProps):[];for(let i=0;i<existingProps.length;i++){const key=existingProps[i];if(newProps.hasOwnProperty(key)){const newProperty=newProps[key];const oldProperty=oldProps[key];if(!this._compareType(newProperty,oldProperty)){explanation=`Property type change for '${path?path:""}${key}'`;break}if(oldProperty.hasOwnProperty("enumValues")){const newOptions=newProperty.hasOwnProperty("enumValues")?newProperty.enumValues:[];if(!oldProperty.enumValues.every(checkOption=>newOptions.includes(checkOption))){explanation=`Enumeration value option removed from property '${path?path:""}${key}'`;break}}else if(newProperty.hasOwnProperty("enumValues")){explanation=`Property '${path?path:""}${key}' is now constrained by an enumeration`;break}if(!path){if(oldProperty.writeback&&!newProperty.writeback){explanation=`Property '${key}' is no longer writeback enabled`;break}if(!oldProperty.required&&newProperty.required){explanation=`Property '${key}' has been made required`;break}const oldROState=oldProperty.hasOwnProperty("readOnly")?oldProperty.readOnly:false;const newROState=newProperty.hasOwnProperty("readOnly")?newProperty.readOnly:false;if(oldROState!==newROState){explanation=`Property '${key}' readOnly state has changed`;break}const oldDefault=oldProperty.hasOwnProperty("value")?JSON.stringify(oldProperty.value):"";const newDefault=newProperty.hasOwnProperty("value")?JSON.stringify(newProperty.value):"";if(oldDefault!==newDefault){explanation=`Property '${key}' default value has changed`;break}}if(newProperty.hasOwnProperty("properties")||oldProperty.hasOwnProperty("properties")){const newSubProps=newProperty.properties?newProperty.properties:{};const oldSubProps=oldProperty.properties?oldProperty.properties:{};const propPath=path?path+key+".":key+".";explanation=this._compareProperties(newSubProps,oldSubProps,propPath);if(explanation){break}}}else{explanation=`Property '${path?path:""}${key}' has been removed`;break}}return explanation};module.exports=ruleDef;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const AuditComponentCacheManager=require('../jetwc-lib/jetwcutils-auditComponentCacheManager');const NetUtils=require('../../lib/NetUtils');const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const CommonImpl=require('../jetwc-lib/jetwcutils-commonListenerImpls');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-component-api-changes'};ruleDef.prototype.getShortDescription=function(){return'Verify that any API changes are compatible with the version number change'};ruleDef.prototype.getDescription=function(){return'This audit compares the metadata of the previous version of a component in the Exchange Catalog and verifies that any API changes are matched with an appropriate version number change according to semver rules'};ruleDef.prototype.register=function(context){return{startaudit:this._auditPrep,closedownRP:this._dealWithCache,compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._auditPrep=function(context){this.exchangeURL=CommonImpl.checkForExchangeConfiguration(context);if(this.exchangeURL){this.acCache=new AuditComponentCacheManager(context,this.getName())}else{const issue=new context.Issue(`Invalid or Missing exchangeURL value specified for the rule ${context.ruleName}, rule execution is disabled`);issue.setMsgKey(`${context.ruleName}_2`);issue.setSeverity('critical');context.reporter.addIssue(issue,context)}};ruleDef.prototype._dealWithCache=function(context){const shouldClearCache=context.rulePack.getRuleOption('clearCache',this.getName());if(shouldClearCache&&this.acCache){this.acCache.removeLocalCache()}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);this._checkAPIs(context,fullName,meta)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){let remappedDependencies;if(componentInfo.dependencies){remappedDependencies=componentInfo.dependencies.reduce((asMap,entry)=>{asMap[entry.name]=entry.range;return asMap},{})}const meta={version:componentInfo.version,jetVersion:componentInfo.jetVersion,properties:componentInfo.properties,methods:componentInfo.methods,events:componentInfo.events,sots:componentInfo.slots,dependencies:remappedDependencies};this._checkAPIs(context,componentInfo.fullName,meta)}};ruleDef.prototype._checkAPIs=function(context,fullName,componentDef){const{msgLib,semVerUtils}=context.utils;let newVersion,latestMatchVersion;try{const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${this.exchangeURL}components/${fullName}/versions`);if(existingVersionsResp.statusCode===200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){newVersion=componentDef.version;let minorVersionUpdated=false;latestMatchVersion=this._findMostAppropriateComparitor(existingVersions,newVersion,semVerUtils);if(latestMatchVersion){if(this._isAPICheckNeeded(semVerUtils,newVersion,latestMatchVersion)){minorVersionUpdated=this._isEffectiveMinor(semVerUtils,newVersion,latestMatchVersion);let existingDef;if(this.acCache.existsInComponentCache(fullName,latestMatchVersion)){existingDef=this.acCache.readFromComponentCache(fullName,latestMatchVersion)}else{const uploadedResp=netUtils.loadUrl(`${this.exchangeURL}components/${fullName}/versions/${latestMatchVersion}`);if(uploadedResp.statusCode=200&&uploadedResp.body){existingDef=JSON.parse(uploadedResp.body).component;this.acCache.writeToComponentCache(fullName,latestMatchVersion,existingDef)}}if(existingDef){try{this._conductCheck(this._detectJetVersionDiff,semVerUtils,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectDependencyDiff,semVerUtils,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectMethodDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectPropertyDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectEventDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectSlotDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectDynamicSlotDiff,componentDef,existingDef,minorVersionUpdated)}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${newVersion} (compared with @${latestMatchVersion}) is not matched by appropriate version number update. Indication: ${auditDetail}`);issue.setMsgKey('jetwco-component-api-changes_1');context.reporter.addIssue(issue,context)}}else{msgLib.error(`Unable to obtain metadata for ${fullName}@${latestMatchVersion}`)}}else{}}}}else if(existingVersionsResp.statusCode===404||existingVersionsResp.eCode==='ENOTFOUND'){msgLib.info(`The component ${fullName} does not exist in the Exchange and so cannot be API verified against older versions. It will be skipped`)}}catch(e){msgLib.error(`Unexpected error in jetwco-component-api-changes processing component ${fullName}:\n ${JSON.stringify(e)}`)};};ruleDef.prototype._findMostAppropriateComparitor=function(existingVersions,newVersion,semver){const versions=existingVersions.items.reverse();let closestMatch,firstMatch,closestReleaseMatch;for(let i=0;i<versions.length;i++){if(semver.gte(newVersion,versions[i])){closestMatch=versions[i];if(!firstMatch){firstMatch=closestMatch}if(!this._isPreRelease(semver,closestMatch)||semver.major(closestMatch)===0){closestReleaseMatch=closestMatch;break}else{continue}}}return closestReleaseMatch?closestReleaseMatch:firstMatch};ruleDef.prototype._isPreRelease=function(semver,version){return Array.isArray(semver.prerelease(version))};ruleDef.prototype._isAPICheckNeeded=function(semver,newVersion,existingVersion){let doCheck=true;if(semver.major(newVersion)>semver.major(existingVersion)||semver.major(newVersion)===0&&semver.minor(newVersion)>semver.minor(existingVersion)){doCheck=false}return doCheck};ruleDef.prototype._isEffectiveMinor=function(semver,newVersion,existingVersion){let classAsMinor=false;if(semver.minor(newVersion)>semver.minor(existingVersion)||semver.major(newVersion)===0&&semver.patch(newVersion)>semver.patch(existingVersion)){classAsMinor=true}return classAsMinor};ruleDef.prototype._conductCheck=function(checkCallback,semver,config,existingConfig,claimedMinorDiff){const result=checkCallback.call(this,semver,config,existingConfig,claimedMinorDiff);if(result){throw result}};ruleDef.prototype._detectJetVersionDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const componentJetVersion=config.jetVersion?config.jetVersion:'0.0.0';const existingJetVersion=existingConfig.jetVersion?existingConfig.jetVersion:'0.0.0';if(componentJetVersion!==existingJetVersion){if(existingJetVersion==='0.0.0'||componentJetVersion==='0.0.0'){explanation='JET version range has been added or removed'}else{const minVersion=semver.minVersion(componentJetVersion);const minExistingVersion=semver.minVersion(existingJetVersion);if(semver.major(minVersion)>semver.major(minExistingVersion)){explanation='minimum major JET version required has increased'}else if(!claimedMinorDiff){if(semver.minor(minVersion)>semver.minor(minExistingVersion)){explanation='minimum minor JET version required has increased'}}}}return explanation};ruleDef.prototype._detectDependencyDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const configDeps=config.dependencies?Object.keys(config.dependencies):[];const existingDeps=existingConfig.dependencies?Object.keys(existingConfig.dependencies):[];if(configDeps.length>existingDeps.length){explanation='more dependencies are declared'}else{if(configDeps.length>0){for(let i=0;i<existingDeps.length;i++){const key=existingDeps[i];if(config.dependencies.hasOwnProperty(key)){const newDepVersion=semver.minVersion(config.dependencies[key]);const existingDepVersion=semver.minVersion(existingConfig.dependencies[key]);if(semver.major(newDepVersion)!==semver.major(existingDepVersion)){explanation='different major version of dependency '+key;break}if(!claimedMinorDiff){if(semver.minor(newDepVersion)!==semver.minor(existingDepVersion)){explanation='different minor version of dependency '+key;break}}}else{if(!claimedMinorDiff){explanation=`dependency ${key} has been removed`}break}}}}return explanation};ruleDef.prototype._detectMethodDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configMethods=config.methods?Object.keys(config.methods):[];const existingMethods=existingConfig.methods?Object.keys(existingConfig.methods):[];if(configMethods.length>=existingMethods.length){if(claimedMinorDiff){if(!existingMethods.every(checkName=>configMethods.includes(checkName))){explanation='existing method removed'}}else if(configMethods.length!==existingMethods.length){explanation='different number of methods declared'}}else{if(configMethods.length===0&&existingMethods.length>0){explanation='existing method(s) removed'}}if(!explanation){for(let i=0;i<existingMethods.length;i++){const key=existingMethods[i];if(config.methods.hasOwnProperty(key)){const configMethodParams=config.methods[key].params?config.methods[key].params:[];const existingMethodParams=existingConfig.methods[key].params?existingConfig.methods[key].params:[];for(let j=0;j<existingMethodParams.length;j++){if(j>=configMethodParams.length){explanation=`existing method '${key}' has fewer parameters`;break}else{if(!this._compareType(configMethodParams[j],existingMethodParams[j],claimedMinorDiff)){explanation=`method '${key}' parameter number:${j+1} has a changed type`;break}}}if(!explanation&&configMethodParams.length>existingMethodParams.length&&!claimedMinorDiff){explanation=`existing method '${key}' has additional parameters`;break}}else{explanation=`existing method '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._detectPropertyDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configProps=config.properties?Object.keys(config.properties):[];const existingProps=existingConfig.properties?Object.keys(existingConfig.properties):[];if(configProps.length>=existingProps.length){if(claimedMinorDiff){if(!existingProps.every(checkName=>configProps.includes(checkName))){explanation='existing property removed'}}else if(configProps.length!==existingProps.length){explanation='different number of properties declared'}}else{if(configProps.length===0&&existingProps.length>0){explanation='existing properties removed'}}if(!explanation){explanation=this._compareProperties(config.properties,existingConfig.properties,claimedMinorDiff)}return explanation};ruleDef.prototype._detectEventDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configEvents=config.events?Object.keys(config.events):[];const existingEvents=existingConfig.events?Object.keys(existingConfig.events):[];if(configEvents.length>=existingEvents.length){if(claimedMinorDiff){if(!existingEvents.every(checkName=>configEvents.includes(checkName))){explanation='existing event removed'}}else if(configEvents.length!==existingEvents.length){explanation='different number of events declared'}}else{if(configEvents.length===0&&existingEvents.length>0){explanation='existing event(s) removed'}}if(!explanation){for(let i=0;i<existingEvents.length;i++){const key=existingEvents[i];if(config.events.hasOwnProperty(key)){const configEventDetail=config.events[key].detail?config.events[key].detail:{};const existingEventDetail=existingConfig.events[key].detail?existingConfig.events[key].detail:{};const detailKeys=Object.keys(configEventDetail);const existingDetailKeys=Object.keys(existingEventDetail);for(let j=0;j<existingDetailKeys.length;j++){const detailKey=existingDetailKeys[j];if(j>=detailKeys.length||!configEventDetail.hasOwnProperty(detailKey)){explanation=`existing event '${key}' has missing entries in the detail payload`;break}else{if(!this._compareType(configEventDetail[detailKey],existingEventDetail[detailKey],claimedMinorDiff)){explanation=`event '${key}' detail attribute '${detailKey}' has a changed type`;break}}}if(!explanation&&detailKeys.length>existingDetailKeys.length&&!claimedMinorDiff){explanation=`existing event '${key}' has additional entries in the detail payload`;break}if(!explanation&&config.events[key].bubbles!==existingConfig.events[key].bubbles){explanation=`existing event '${key}' has changed bubbling state`;break}if(!explanation&&config.events[key].cancelable!==existingConfig.events[key].cancelable){explanation=`existing event '${key}' has changed cancelable state`;break}}else{explanation=`existing event '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._detectSlotDiff=function(config,existingConfig,claimedMinorDiff){return this._detectTypedSlotDiff('slots',config,existingConfig,claimedMinorDiff)};ruleDef.prototype._detectDynamicSlotDiff=function(config,existingConfig,claimedMinorDiff){return this._detectTypedSlotDiff('dynamicSlots',config,existingConfig,claimedMinorDiff)};ruleDef.prototype._detectTypedSlotDiff=function(slotType,config,existingConfig,claimedMinorDiff){let explanation;const configSlots=config[slotType]?Object.keys(config[slotType]):[];const existingSlots=existingConfig[slotType]?Object.keys(existingConfig[slotType]):[];if(configSlots.length>=existingSlots.length){if(claimedMinorDiff){if(!existingSlots.every(checkName=>configSlots.includes(checkName))){explanation='existing slot removed'}}else if(configSlots.length!==existingSlots.length){explanation='different number of slots declared'}}else{if(configSlots.length===0&&existingSlots.length>0){explanation='existing slot(s) removed'}}if(!explanation){for(let i=0;i<existingSlots.length;i++){const key=existingSlots[i];if(config[slotType].hasOwnProperty(key)){const configSlotData=config[slotType][key].data?config[slotType][key].data:{};const existingSlotData=existingConfig[slotType][key].data?existingConfig[slotType][key].data:{};const dataKeys=Object.keys(configSlotData);const existingDataKeys=Object.keys(existingSlotData);for(let j=0;j<existingDataKeys.length;j++){const dataKey=existingDataKeys[j];if(j>=dataKeys.length||!configSlotData.hasOwnProperty(dataKey)){explanation=`existing slot '${key}' has missing entries in the data payload`;break}else{if(!this._compareType(configSlotData[dataKey],existingSlotData[dataKey],claimedMinorDiff)){explanation=`slot '${key}' data attribute '${dataKey}' has a changed type`;break}}}if(!explanation&&dataKeys.length>existingDataKeys.length&&!claimedMinorDiff){explanation=`existing slot '${key}' has additional entries in the data payload`;break}}else{explanation=`existing slot '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._compareType=function(newTyped,existingTyped,claimedMinorDiff){let matches=true;const newType=newTyped&&newTyped.type?newTyped.type:null;const existingType=existingTyped&&existingTyped.type?existingTyped.type:null;if(newType!==existingType){if(claimedMinorDiff){const newTypeOptions=newType?newType.split('|'):[];const existingTypeOptions=existingType?existingType.split('|'):[];matches=existingTypeOptions.every(checkType=>newTypeOptions.includes(checkType))}else{matches=false}}return matches};ruleDef.prototype._compareProperties=function(newProps,oldProps,claimedMinorDiff,path){let explanation;const configProps=newProps?Object.keys(newProps):[];const existingProps=oldProps?Object.keys(oldProps):[];for(let i=0;i<existingProps.length;i++){const key=existingProps[i];if(newProps.hasOwnProperty(key)){const newProperty=newProps[key];const oldProperty=oldProps[key];if(!this._compareType(newProperty,oldProperty,claimedMinorDiff)){explanation=`type change for property ${path?path:''}${key}`;break}if(oldProperty.hasOwnProperty('enumValues')){const newOptions=newProperty.hasOwnProperty('enumValues')?newProperty.enumValues:[];if(!oldProperty.enumValues.every(checkOption=>newOptions.includes(checkOption))){explanation=`Enumeration value option removed from property '${path?path:''}${key}'`;break}}else if(newProperty.hasOwnProperty('enumValues')){explanation=`Property '${path?path:''}${key}' is now constrained by an enumeration`;break}if(!path){if(oldProperty.writeback&&!newProperty.writeback){explanation=`property ${key} is no longer writeback enabled`;break}if(!oldProperty.required&&newProperty.required){explanation=`property ${key} has been made required`;break}if(!oldProperty.required&&newProperty.required){explanation=`Property '${key}' has been made required`;break}const oldROState=oldProperty.hasOwnProperty('readOnly')?oldProperty.readOnly:false;const newROState=newProperty.hasOwnProperty('readOnly')?newProperty.readOnly:false;if(oldROState!==newROState){explanation=`Property '${key}' readOnly state has changed`;break}}if(newProperty.hasOwnProperty('properties')||oldProperty.hasOwnProperty('properties')){const newSubProps=newProperty.properties?newProperty.properties:{};const oldSubProps=oldProperty.properties?oldProperty.properties:{};const propPath=path?path+key+'.':key+'.';explanation=this._compareProperties(newSubProps,oldSubProps,claimedMinorDiff,propPath);if(explanation){break}}}else{explanation=`property ${path?path:''}${key} has been removed`;break}}if(!explanation){if(!claimedMinorDiff&&configProps.length>existingProps.length){explanation=`property added ${path?'as sub-property of '+path:''}`}}return explanation};module.exports=ruleDef;
6
+ const AuditComponentCacheManager=require("../jetwc-lib/jetwcutils-auditComponentCacheManager");const NetUtils=require("../../lib/NetUtils");const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const CommonImpl=require("../jetwc-lib/jetwcutils-commonListenerImpls");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-component-api-changes"};ruleDef.prototype.getShortDescription=function(){return"Verify that any API changes are compatible with the version number change"};ruleDef.prototype.getDescription=function(){return"This audit compares the metadata of the previous version of a component in the Exchange Catalog and verifies that any API changes are matched with an appropriate version number change according to semver rules"};ruleDef.prototype.register=function(context){return{startaudit:this._auditPrep,closedownRP:this._dealWithCache,compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._auditPrep=function(context){this.exchangeURL=CommonImpl.checkForExchangeConfiguration(context);if(this.exchangeURL){this.acCache=new AuditComponentCacheManager(context,this.getName())}else{const issue=new context.Issue(`Invalid or Missing exchangeURL value specified for the rule ${context.ruleName}, rule execution is disabled`);issue.setMsgKey(`${context.ruleName}_2`);issue.setSeverity("critical");context.reporter.addIssue(issue,context)}};ruleDef.prototype._dealWithCache=function(context){const shouldClearCache=context.rulePack.getRuleOption("clearCache",this.getName());if(shouldClearCache&&this.acCache){this.acCache.removeLocalCache()}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);this._checkAPIs(context,fullName,meta)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){let remappedDependencies;if(componentInfo.dependencies){remappedDependencies=componentInfo.dependencies.reduce((asMap,entry)=>{asMap[entry.name]=entry.range;return asMap},{})}const meta={version:componentInfo.version,jetVersion:componentInfo.jetVersion,properties:componentInfo.properties,methods:componentInfo.methods,events:componentInfo.events,sots:componentInfo.slots,dependencies:remappedDependencies};this._checkAPIs(context,componentInfo.fullName,meta)}};ruleDef.prototype._checkAPIs=function(context,fullName,componentDef){const{msgLib,semVerUtils}=context.utils;let newVersion,latestMatchVersion;try{const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${this.exchangeURL}components/${fullName}/versions`);if(existingVersionsResp.statusCode===200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){newVersion=componentDef.version;let minorVersionUpdated=false;latestMatchVersion=this._findMostAppropriateComparitor(existingVersions,newVersion,semVerUtils);if(latestMatchVersion){if(this._isAPICheckNeeded(semVerUtils,newVersion,latestMatchVersion)){minorVersionUpdated=this._isEffectiveMinor(semVerUtils,newVersion,latestMatchVersion);let existingDef;if(this.acCache.existsInComponentCache(fullName,latestMatchVersion)){existingDef=this.acCache.readFromComponentCache(fullName,latestMatchVersion)}else{const uploadedResp=netUtils.loadUrl(`${this.exchangeURL}components/${fullName}/versions/${latestMatchVersion}`);if(uploadedResp.statusCode=200&&uploadedResp.body){existingDef=JSON.parse(uploadedResp.body).component;this.acCache.writeToComponentCache(fullName,latestMatchVersion,existingDef)}}if(existingDef){try{this._conductCheck(this._detectJetVersionDiff,semVerUtils,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectDependencyDiff,semVerUtils,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectMethodDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectPropertyDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectEventDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectSlotDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectDynamicSlotDiff,componentDef,existingDef,minorVersionUpdated)}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${newVersion} (compared with @${latestMatchVersion}) is not matched by appropriate version number update. Indication: ${auditDetail}`);issue.setMsgKey("jetwco-component-api-changes_1");context.reporter.addIssue(issue,context)}}else{msgLib.error(`Unable to obtain metadata for ${fullName}@${latestMatchVersion}`)}}else{}}}}else if(existingVersionsResp.statusCode===404||existingVersionsResp.eCode==="ENOTFOUND"){msgLib.info(`The component ${fullName} does not exist in the Exchange and so cannot be API verified against older versions. It will be skipped`)}}catch(e){msgLib.error(`Unexpected error in jetwco-component-api-changes processing component ${fullName}:\n ${JSON.stringify(e)}`)};};ruleDef.prototype._findMostAppropriateComparitor=function(existingVersions,newVersion,semver){const versions=existingVersions.items.reverse();let closestMatch,firstMatch,closestReleaseMatch;for(let i=0;i<versions.length;i++){if(semver.gte(newVersion,versions[i])){closestMatch=versions[i];if(!firstMatch){firstMatch=closestMatch}if(!this._isPreRelease(semver,closestMatch)||semver.major(closestMatch)===0){closestReleaseMatch=closestMatch;break}else{continue}}}return closestReleaseMatch?closestReleaseMatch:firstMatch};ruleDef.prototype._isPreRelease=function(semver,version){return Array.isArray(semver.prerelease(version))};ruleDef.prototype._isAPICheckNeeded=function(semver,newVersion,existingVersion){let doCheck=true;if(semver.major(newVersion)>semver.major(existingVersion)||semver.major(newVersion)===0&&semver.minor(newVersion)>semver.minor(existingVersion)){doCheck=false}return doCheck};ruleDef.prototype._isEffectiveMinor=function(semver,newVersion,existingVersion){let classAsMinor=false;if(semver.minor(newVersion)>semver.minor(existingVersion)||semver.major(newVersion)===0&&semver.patch(newVersion)>semver.patch(existingVersion)){classAsMinor=true}return classAsMinor};ruleDef.prototype._conductCheck=function(checkCallback,semver,config,existingConfig,claimedMinorDiff){const result=checkCallback.call(this,semver,config,existingConfig,claimedMinorDiff);if(result){throw result}};ruleDef.prototype._detectJetVersionDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const componentJetVersion=config.jetVersion?config.jetVersion:"0.0.0";const existingJetVersion=existingConfig.jetVersion?existingConfig.jetVersion:"0.0.0";if(componentJetVersion!==existingJetVersion){if(existingJetVersion==="0.0.0"||componentJetVersion==="0.0.0"){explanation="JET version range has been added or removed"}else{const minVersion=semver.minVersion(componentJetVersion);const minExistingVersion=semver.minVersion(existingJetVersion);if(semver.major(minVersion)>semver.major(minExistingVersion)){explanation="minimum major JET version required has increased"}else if(!claimedMinorDiff){if(semver.minor(minVersion)>semver.minor(minExistingVersion)){explanation="minimum minor JET version required has increased"}}}}return explanation};ruleDef.prototype._detectDependencyDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const configDeps=config.dependencies?Object.keys(config.dependencies):[];const existingDeps=existingConfig.dependencies?Object.keys(existingConfig.dependencies):[];if(configDeps.length>existingDeps.length){explanation="more dependencies are declared"}else{if(configDeps.length>0){for(let i=0;i<existingDeps.length;i++){const key=existingDeps[i];if(config.dependencies.hasOwnProperty(key)){const newDepVersion=semver.minVersion(config.dependencies[key]);const existingDepVersion=semver.minVersion(existingConfig.dependencies[key]);if(semver.major(newDepVersion)!==semver.major(existingDepVersion)){explanation="different major version of dependency "+key;break}if(!claimedMinorDiff){if(semver.minor(newDepVersion)!==semver.minor(existingDepVersion)){explanation="different minor version of dependency "+key;break}}}else{if(!claimedMinorDiff){explanation=`dependency ${key} has been removed`}break}}}}return explanation};ruleDef.prototype._detectMethodDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configMethods=config.methods?Object.keys(config.methods):[];const existingMethods=existingConfig.methods?Object.keys(existingConfig.methods):[];if(configMethods.length>=existingMethods.length){if(claimedMinorDiff){if(!existingMethods.every(checkName=>configMethods.includes(checkName))){explanation="existing method removed"}}else if(configMethods.length!==existingMethods.length){explanation="different number of methods declared"}}else{if(configMethods.length===0&&existingMethods.length>0){explanation="existing method(s) removed"}}if(!explanation){for(let i=0;i<existingMethods.length;i++){const key=existingMethods[i];if(config.methods.hasOwnProperty(key)){const configMethodParams=config.methods[key].params?config.methods[key].params:[];const existingMethodParams=existingConfig.methods[key].params?existingConfig.methods[key].params:[];for(let j=0;j<existingMethodParams.length;j++){if(j>=configMethodParams.length){explanation=`existing method '${key}' has fewer parameters`;break}else{if(!this._compareType(configMethodParams[j],existingMethodParams[j],claimedMinorDiff)){explanation=`method '${key}' parameter number:${j+1} has a changed type`;break}}}if(!explanation&&configMethodParams.length>existingMethodParams.length&&!claimedMinorDiff){explanation=`existing method '${key}' has additional parameters`;break}}else{explanation=`existing method '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._detectPropertyDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configProps=config.properties?Object.keys(config.properties):[];const existingProps=existingConfig.properties?Object.keys(existingConfig.properties):[];if(configProps.length>=existingProps.length){if(claimedMinorDiff){if(!existingProps.every(checkName=>configProps.includes(checkName))){explanation="existing property removed"}}else if(configProps.length!==existingProps.length){explanation="different number of properties declared"}}else{if(configProps.length===0&&existingProps.length>0){explanation="existing properties removed"}}if(!explanation){explanation=this._compareProperties(config.properties,existingConfig.properties,claimedMinorDiff)}return explanation};ruleDef.prototype._detectEventDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configEvents=config.events?Object.keys(config.events):[];const existingEvents=existingConfig.events?Object.keys(existingConfig.events):[];if(configEvents.length>=existingEvents.length){if(claimedMinorDiff){if(!existingEvents.every(checkName=>configEvents.includes(checkName))){explanation="existing event removed"}}else if(configEvents.length!==existingEvents.length){explanation="different number of events declared"}}else{if(configEvents.length===0&&existingEvents.length>0){explanation="existing event(s) removed"}}if(!explanation){for(let i=0;i<existingEvents.length;i++){const key=existingEvents[i];if(config.events.hasOwnProperty(key)){const configEventDetail=config.events[key].detail?config.events[key].detail:{};const existingEventDetail=existingConfig.events[key].detail?existingConfig.events[key].detail:{};const detailKeys=Object.keys(configEventDetail);const existingDetailKeys=Object.keys(existingEventDetail);for(let j=0;j<existingDetailKeys.length;j++){const detailKey=existingDetailKeys[j];if(j>=detailKeys.length||!configEventDetail.hasOwnProperty(detailKey)){explanation=`existing event '${key}' has missing entries in the detail payload`;break}else{if(!this._compareType(configEventDetail[detailKey],existingEventDetail[detailKey],claimedMinorDiff)){explanation=`event '${key}' detail attribute '${detailKey}' has a changed type`;break}}}if(!explanation&&detailKeys.length>existingDetailKeys.length&&!claimedMinorDiff){explanation=`existing event '${key}' has additional entries in the detail payload`;break}if(!explanation&&config.events[key].bubbles!==existingConfig.events[key].bubbles){explanation=`existing event '${key}' has changed bubbling state`;break}if(!explanation&&config.events[key].cancelable!==existingConfig.events[key].cancelable){explanation=`existing event '${key}' has changed cancelable state`;break}}else{explanation=`existing event '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._detectSlotDiff=function(config,existingConfig,claimedMinorDiff){return this._detectTypedSlotDiff("slots",config,existingConfig,claimedMinorDiff)};ruleDef.prototype._detectDynamicSlotDiff=function(config,existingConfig,claimedMinorDiff){return this._detectTypedSlotDiff("dynamicSlots",config,existingConfig,claimedMinorDiff)};ruleDef.prototype._detectTypedSlotDiff=function(slotType,config,existingConfig,claimedMinorDiff){let explanation;const configSlots=config[slotType]?Object.keys(config[slotType]):[];const existingSlots=existingConfig[slotType]?Object.keys(existingConfig[slotType]):[];if(configSlots.length>=existingSlots.length){if(claimedMinorDiff){if(!existingSlots.every(checkName=>configSlots.includes(checkName))){explanation="existing slot removed"}}else if(configSlots.length!==existingSlots.length){explanation="different number of slots declared"}}else{if(configSlots.length===0&&existingSlots.length>0){explanation="existing slot(s) removed"}}if(!explanation){for(let i=0;i<existingSlots.length;i++){const key=existingSlots[i];if(config[slotType].hasOwnProperty(key)){const configSlotData=config[slotType][key].data?config[slotType][key].data:{};const existingSlotData=existingConfig[slotType][key].data?existingConfig[slotType][key].data:{};const dataKeys=Object.keys(configSlotData);const existingDataKeys=Object.keys(existingSlotData);for(let j=0;j<existingDataKeys.length;j++){const dataKey=existingDataKeys[j];if(j>=dataKeys.length||!configSlotData.hasOwnProperty(dataKey)){explanation=`existing slot '${key}' has missing entries in the data payload`;break}else{if(!this._compareType(configSlotData[dataKey],existingSlotData[dataKey],claimedMinorDiff)){explanation=`slot '${key}' data attribute '${dataKey}' has a changed type`;break}}}if(!explanation&&dataKeys.length>existingDataKeys.length&&!claimedMinorDiff){explanation=`existing slot '${key}' has additional entries in the data payload`;break}}else{explanation=`existing slot '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._compareType=function(newTyped,existingTyped,claimedMinorDiff){let matches=true;const newType=newTyped&&newTyped.type?newTyped.type:null;const existingType=existingTyped&&existingTyped.type?existingTyped.type:null;if(newType!==existingType){if(claimedMinorDiff){const newTypeOptions=newType?newType.split("|"):[];const existingTypeOptions=existingType?existingType.split("|"):[];matches=existingTypeOptions.every(checkType=>newTypeOptions.includes(checkType))}else{matches=false}}return matches};ruleDef.prototype._compareProperties=function(newProps,oldProps,claimedMinorDiff,path){let explanation;const configProps=newProps?Object.keys(newProps):[];const existingProps=oldProps?Object.keys(oldProps):[];for(let i=0;i<existingProps.length;i++){const key=existingProps[i];if(newProps.hasOwnProperty(key)){const newProperty=newProps[key];const oldProperty=oldProps[key];if(!this._compareType(newProperty,oldProperty,claimedMinorDiff)){explanation=`type change for property ${path?path:""}${key}`;break}if(oldProperty.hasOwnProperty("enumValues")){const newOptions=newProperty.hasOwnProperty("enumValues")?newProperty.enumValues:[];if(!oldProperty.enumValues.every(checkOption=>newOptions.includes(checkOption))){explanation=`Enumeration value option removed from property '${path?path:""}${key}'`;break}}else if(newProperty.hasOwnProperty("enumValues")){explanation=`Property '${path?path:""}${key}' is now constrained by an enumeration`;break}if(!path){if(oldProperty.writeback&&!newProperty.writeback){explanation=`property ${key} is no longer writeback enabled`;break}if(!oldProperty.required&&newProperty.required){explanation=`property ${key} has been made required`;break}if(!oldProperty.required&&newProperty.required){explanation=`Property '${key}' has been made required`;break}const oldROState=oldProperty.hasOwnProperty("readOnly")?oldProperty.readOnly:false;const newROState=newProperty.hasOwnProperty("readOnly")?newProperty.readOnly:false;if(oldROState!==newROState){explanation=`Property '${key}' readOnly state has changed`;break}}if(newProperty.hasOwnProperty("properties")||oldProperty.hasOwnProperty("properties")){const newSubProps=newProperty.properties?newProperty.properties:{};const oldSubProps=oldProperty.properties?oldProperty.properties:{};const propPath=path?path+key+".":key+".";explanation=this._compareProperties(newSubProps,oldSubProps,claimedMinorDiff,propPath);if(explanation){break}}}else{explanation=`property ${path?path:""}${key} has been removed`;break}}if(!explanation){if(!claimedMinorDiff&&configProps.length>existingProps.length){explanation=`property added ${path?"as sub-property of "+path:""}`}}return explanation};module.exports=ruleDef;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const AuditComponentCacheManager=require('../jetwc-lib/jetwcutils-auditComponentCacheManager');const NetUtils=require('../../lib/NetUtils');const CommonImpl=require('../jetwc-lib/jetwcutils-commonListenerImpls');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const VC=require('./jetwco-cacc-auditConstraints');const CaccHelpers=require('./jetwco-cacc-helpers');const jetVer=require('./jetwco-cacc-jetVer');const packContent=require('./jetwco-cacc-packContent');const packBundle=require('./jetwco-cacc-packBundle');const packBundleContent=require('./jetwco-cacc-packBundleContent');const dependencies=require('./jetwco-cacc-dependencies');const properties=require('./jetwco-cacc-properties');const propertyDefault=require('./jetwco-cacc-propertyDefault');const propertyRequired=require('./jetwco-cacc-propertyRequired');const propertyReadOnly=require('./jetwco-cacc-propertyReadOnly');const propertyWriteback=require('./jetwco-cacc-propertyWriteback');const propertyType=require('./jetwco-cacc-propertyType');const propertyEnumeration=require('./jetwco-cacc-propertyEnumeration');const methods=require('./jetwco-cacc-methods');const methodParams=require('./jetwco-cacc-methodParams');const methodParamTypes=require('./jetwco-cacc-methodParamTypes');const methodReturnType=require('./jetwco-cacc-methodReturnType');const events=require('./jetwco-cacc-events');const eventPayload=require('./jetwco-cacc-eventPayload');const eventBubbles=require('./jetwco-cacc-eventBubbles');const eventCancelable=require('./jetwco-cacc-eventCancelable');const slots=require('./jetwco-cacc-slots');const slotDataVariable=require('./jetwco-cacc-slotDataVariable');const slotDataVariableType=require('./jetwco-cacc-slotDataVariableType');const dynamicSlots=require('./jetwco-cacc-dynamicSlots');const styleVariables=require('./jetwco-cacc-styleVariables');const styleClasses=require('./jetwco-cacc-styleClasses');const publicModules=require('./jetwco-cacc-publicModules');const componentType=require('./jetwco-cacc-componentType');const CONTROL_PROFILE={jetVer:{callback:jetVer,add:VC.MAJOR,remove:VC.MAJOR,mutate:VC.MAJOR,description:'Validate the JET Version compatibility range'},packContent:{callback:packContent,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.SEMVER,description:'Validate the member components of a JET Pack'},packBundle:{callback:packBundle,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the list of bundles defined by a JET Pack'},packBundleContent:{callback:packBundleContent,add:VC.MAJOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the entries of each bundle defined by a JET Pack'},dependencies:{callback:dependencies,add:VC.MAJOR,remove:VC.MINOR,mutate:VC.SEMVER,description:'Validate the dependencies of a component'},properties:{callback:properties,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the properties of a component'},propertyDefault:{callback:propertyDefault,add:VC.PATCH,remove:VC.MAJOR_DEPRECATED,mutate:VC.MAJOR_DEPRECATED,description:'Validate the defaults assigned to properties of a component'},propertyRequired:{callback:propertyRequired,add:VC.MAJOR,remove:VC.PATCH,mutate:VC.NEVER,description:'Validate the required states of a components properties'},propertyReadOnly:{callback:propertyReadOnly,add:VC.MAJOR,remove:VC.PATCH,mutate:VC.NEVER,description:'Validate the read-only states of a components properties'},propertyWriteback:{callback:propertyWriteback,add:VC.PATCH,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the writeback states of a components properties'},propertyType:{callback:propertyType,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the assigned types of a components properties'},propertyEnumeration:{callback:propertyEnumeration,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.MAJOR,description:'Validate the enumValues of a components properties'},methods:{callback:methods,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of methods exposed by the component'},methodParams:{callback:methodParams,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of parameters passed to methods exposed by the component'},methodParamTypes:{callback:methodParamTypes,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of parameters passed to methods exposed by the component'},methodReturnType:{callback:methodReturnType,add:VC.PATCH,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the return type of the methods exposed by the component'},events:{callback:events,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of events exposed by the component'},eventPayload:{callback:eventPayload,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the event detail of events exposed by the component'},eventBubbles:{callback:eventBubbles,add:VC.MINOR,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the event bubbles flag'},eventCancelable:{callback:eventCancelable,add:VC.MINOR,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the event cancelable flag'},slots:{callback:slots,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of slots exposed by the component'},slotDataVariable:{callback:slotDataVariable,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of attributes in a slot data attribute exposed by the component'},slotDataVariableType:{callback:slotDataVariableType,add:VC.NEVER,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the type assigned to each attributes in a slot data attribute exposed by the component'},dynamicSlots:{callback:dynamicSlots,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the presence of the dynamicSlots marker on the component'},styleVariables:{callback:styleVariables,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of styleVariables supported by the component'},styleClasses:{callback:styleClasses,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of styleClasses supported by the component'},publicModules:{callback:publicModules,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the list of publicModules exposed by a resource component'},componentType:{callback:componentType,add:VC.NEVER,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the component type has not been changed'}};const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-component-api-controlled-changes'};ruleDef.prototype.getShortDescription=function(){return'Check components for API changes based on a configurable rule-set'};ruleDef.prototype.getDescription=function(){return'This audit compares the APIs exposed by components with older versions in the Exchange Catalog according to a set of rules which determine when given changes, such as the removal of deprecated properties can be made'};ruleDef.prototype.register=function(context){return{startaudit:this._auditPrep,closedownRP:this._dealWithCache,compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._auditPrep=function(context){this.exchangeURL=CommonImpl.checkForExchangeConfiguration(context);if(this.exchangeURL){this.acCache=new AuditComponentCacheManager(context,this.getName(),this.exchangeURL);this.componentExceptions=context.rulePack.getRuleOption('exceptions');const ipr=context.rulePack.getRuleOption('includePreReleases');if(ipr&&ipr===true){this.productionOnly=false}else{this.productionOnly=true}const ruleOverrides=context.rulePack.getRuleOption('controls');this.controlRules={};if(Object.keys(ruleOverrides).length>0){for(const[controlRule,controlRuleDef]of Object.entries(CONTROL_PROFILE)){this.controlRules[controlRule]={...controlRuleDef};if(ruleOverrides.hasOwnProperty(controlRule)){for(const[verb,override]of Object.entries(ruleOverrides[controlRule])){this.controlRules[controlRule][verb]=override}}}}else{this.controlRules={...CONTROL_PROFILE}}const activeControls=context.rulePack.getRuleOption('applyConditions');if(activeControls&&Array.isArray(activeControls)){Object.keys(this.controlRules).forEach(controlRule=>{if(!activeControls.includes(controlRule)){delete this.controlRules[controlRule]}})}this.requiredCheckVersions=CaccHelpers.calcRequiredVersionMatrix(this.controlRules)}else{const issue=new context.Issue(`Invalid or Missing exchangeURL value specified for the rule ${context.ruleName}, rule execution is disabled`);issue.setMsgKey(`${context.ruleName}_2`);issue.setSeverity('critical');context.reporter.addIssue(issue,context)}};ruleDef.prototype._dealWithCache=function(context){const shouldClearCache=context.rulePack.getRuleOption('clearCache',this.getName());if(shouldClearCache&&this.acCache){this.acCache.removeLocalCache()}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);this._conductChecks(context,fullName,componentType,meta)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){const meta={...componentInfo};if(componentInfo.dependencies){meta.dependencies=componentInfo.dependencies.reduce((asMap,entry)=>{asMap[entry.name]=entry.range;return asMap},{})}this._conductChecks(context,componentInfo.fullName,componentInfo.type,meta)}};ruleDef.prototype._conductChecks=function(context,fullName,componentType,componentMeta){const{msgLib,semVerUtils}=context.utils;const privateComponent=componentMeta.subcomponentType&&componentMeta.subcomponentType==='packPrivate';const skipPrivate=context.rulePack.getRuleOption('ignorePackPrivate',context.ruleName);let overrideTypeMappings=context.rulePack.getRuleOption('typeMappings',context.ruleName);if(!overrideTypeMappings){overrideTypeMappings={}}if(skipPrivate&&privateComponent){msgLib.info(`packPrivate component ${fullName} skipped due to ignorePackPrivate flag in ${context.ruleName} configuration`)}else{const baselines=this._grabRequiredVersions(context,fullName,componentMeta.version,this.requiredCheckVersions,this.productionOnly);if(baselines&&baselines.latest.version){const compareMetadata=CaccHelpers.deriveConstraintMetadata(baselines);const componentVersionDiff=CaccHelpers.semanticDiff(semVerUtils,componentMeta.version,compareMetadata.version);try{for(const[controlRuleName,controlRuleDef]of Object.entries(this.controlRules)){if(!this._isExemptFromCheck(fullName,controlRuleName)){msgLib.info(`${context.ruleName}(${controlRuleName}): ${controlRuleDef.description}`);const errorMsgContext=CaccHelpers.getStdErrorContext(fullName,controlRuleName);this._executeCheck(controlRuleName,controlRuleDef,semVerUtils,this.acCache,componentMeta,compareMetadata,componentVersionDiff,baselines,componentType,fullName,errorMsgContext,overrideTypeMappings)}}}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${componentMeta.version}: ${auditDetail}`);issue.setMsgKey(`${context.ruleName}_1`);context.reporter.addIssue(issue,context)}}}};ruleDef.prototype._grabRequiredVersions=function(context,fullName,versionUnderTest,requiredVersions,productionVersionsOnly){const{msgLib,semVerUtils}=context.utils;const checkVersions={'never':{isNeeded:true,version:null,metadata:null},'latest':{isNeeded:true,version:null,metadata:null},'patch':{isNeeded:requiredVersions.patch,version:null,metadata:null},'minor':{isNeeded:requiredVersions.minor,version:null,metadata:null},'major':{isNeeded:requiredVersions.major,version:null,metadata:null},'major+':{isNeeded:requiredVersions.major,version:null,metadata:null},'major2+':{isNeeded:requiredVersions.major2,version:null,metadata:null},'major3+':{isNeeded:requiredVersions.major3,version:null,metadata:null}};try{const versionsToCache=new Set;const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${this.exchangeURL}components/${fullName}/versions`);if(existingVersionsResp.statusCode===200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){const{major:vutMajor,minor:vutMinor,patch:vutPatch,prerelease:vutPreRel,version:vutVersion}=semVerUtils.parse(versionUnderTest);let historicalVersions;if(productionVersionsOnly){historicalVersions=existingVersions.items.reverse().filter(versionString=>{const{prerelease}=semVerUtils.parse(versionString);return prerelease.length===0})}else{historicalVersions=existingVersions.items.reverse()}const majorSequence=this._getOffsetMajorVersions(semVerUtils,historicalVersions,vutMajor);for(let i=0;i<historicalVersions.length;i++){const{major:hvMajor,minor:hvMinor,patch:hvPatch,prerelease:hvPreRel,version:hvVersion}=semVerUtils.parse(historicalVersions[i]);if(semVerUtils.lt(hvVersion,vutVersion)){if(!checkVersions.latest.version){checkVersions.latest.version=hvVersion;versionsToCache.add(hvVersion)}if(checkVersions.patch.isNeeded&&!checkVersions.patch.version){checkVersions.patch.version=hvVersion;versionsToCache.add(hvVersion)}if(checkVersions.minor.isNeeded&&!checkVersions.minor.version){if(hvMinor<vutMinor||hvMajor<vutMajor){checkVersions.minor.version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions.major.isNeeded&&!checkVersions.major.version){if(majorSequence[1]&&hvMajor===majorSequence[1]){checkVersions.major.version=hvVersion;checkVersions['major+'].version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions['major2+'].isNeeded&&!checkVersions['major2+'].version){if(majorSequence[2]&&hvMajor===majorSequence[2]){checkVersions['major2+'].version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions['major3+'].isNeeded&&!checkVersions['major3+'].version){if(majorSequence[3]&&hvMajor===majorSequence[3]){checkVersions['major3+'].version=hvVersion;versionsToCache.add(hvVersion);break}}}}versionsToCache.forEach(requiredVersion=>{const cachedDef=this.acCache.getComponentMetadata(fullName,requiredVersion);if(cachedDef){for(const[controlValue,settings]of Object.entries(checkVersions)){if(settings.isNeeded&&settings.version===requiredVersion){checkVersions[controlValue].metadata=cachedDef}}}})}}else if(existingVersionsResp.statusCode===404||existingVersionsResp.eCode==='ENOTFOUND'){msgLib.info(`The component ${fullName} does not exist in the Exchange and so cannot be API verified against older versions. It will be skipped`);if(!this.componentExceptions){this.componentExceptions={}}this.componentExceptions[fullName]=['*'];return}}catch(e){msgLib.error(`Unexpected error processing rule ${context.ruleName} for component ${fullName}:\n${JSON.stringify(e)}`)};return checkVersions};ruleDef.prototype._getOffsetMajorVersions=function(semVerUtils,versions,baseMajorVersion){const majors=[baseMajorVersion];let lastMajor=baseMajorVersion;versions.forEach(stringVersion=>{const{major:parsedMajor}=semVerUtils.parse(stringVersion);if(parsedMajor<lastMajor){lastMajor=parsedMajor;majors.push(parsedMajor)}});return majors};ruleDef.prototype._executeCheck=function(controlRuleName,controlRuleDef,semver,cacheManager,metadata,compareMetadata,componentVersionDiff,baselines,componentType,componentName,errorMsgContext,overrideTypeMappings){const result=controlRuleDef.callback.call(this,controlRuleName,controlRuleDef,semver,cacheManager,metadata,compareMetadata,componentVersionDiff,baselines,componentType,componentName,errorMsgContext,overrideTypeMappings);if(result){throw result}};ruleDef.prototype._isExemptFromCheck=function(fullName,controlRuleName){let exempt=false;let nameMatch;if(this.componentExceptions){if(this.componentExceptions.hasOwnProperty(fullName)){nameMatch=fullName}else{const wildcardNames=Object.keys(this.componentExceptions).reduce((wildcardList,wc)=>{if(wc.endsWith('*')){wildcardList.push(wc.substring(0,wc.length-1))}return wildcardList},[]);if(wildcardNames.length>0){wildcardNames.forEach(wildcard=>{if(fullName.startsWith(wildcard)){nameMatch=wildcard+'*'}})}}if(nameMatch){if(this.componentExceptions[nameMatch].includes('*')||this.componentExceptions[nameMatch].includes(controlRuleName)){exempt=true}}}return exempt};module.exports=ruleDef;
6
+ const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const AuditComponentCacheManager=require("../jetwc-lib/jetwcutils-auditComponentCacheManager");const NetUtils=require("../../lib/NetUtils");const CommonImpl=require("../jetwc-lib/jetwcutils-commonListenerImpls");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const VC=require("./jetwco-cacc-auditConstraints");const CaccHelpers=require("./jetwco-cacc-helpers");const{applyCustomMappings}=require("./jetwco-cacc-typeMappingOverrides");const jetVer=require("./jetwco-cacc-jetVer");const packContent=require("./jetwco-cacc-packContent");const packBundle=require("./jetwco-cacc-packBundle");const packBundleContent=require("./jetwco-cacc-packBundleContent");const dependencies=require("./jetwco-cacc-dependencies");const properties=require("./jetwco-cacc-properties");const propertyDefault=require("./jetwco-cacc-propertyDefault");const propertyRequired=require("./jetwco-cacc-propertyRequired");const propertyReadOnly=require("./jetwco-cacc-propertyReadOnly");const propertyWriteback=require("./jetwco-cacc-propertyWriteback");const propertyType=require("./jetwco-cacc-propertyType");const propertyEnumeration=require("./jetwco-cacc-propertyEnumeration");const methods=require("./jetwco-cacc-methods");const methodParams=require("./jetwco-cacc-methodParams");const methodParamTypes=require("./jetwco-cacc-methodParamTypes");const methodReturnType=require("./jetwco-cacc-methodReturnType");const events=require("./jetwco-cacc-events");const eventPayload=require("./jetwco-cacc-eventPayload");const eventBubbles=require("./jetwco-cacc-eventBubbles");const eventCancelable=require("./jetwco-cacc-eventCancelable");const slots=require("./jetwco-cacc-slots");const slotDataVariable=require("./jetwco-cacc-slotDataVariable");const slotDataVariableType=require("./jetwco-cacc-slotDataVariableType");const dynamicSlots=require("./jetwco-cacc-dynamicSlots");const styleVariables=require("./jetwco-cacc-styleVariables");const styleClasses=require("./jetwco-cacc-styleClasses");const publicModules=require("./jetwco-cacc-publicModules");const componentType=require("./jetwco-cacc-componentType");const CONTROL_PROFILE={jetVer:{callback:jetVer,add:VC.MAJOR,remove:VC.MAJOR,mutate:VC.MAJOR,description:"Validate the JET Version compatibility range"},packContent:{callback:packContent,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.SEMVER,description:"Validate the member components of a JET Pack"},packBundle:{callback:packBundle,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:"Validate the list of bundles defined by a JET Pack"},packBundleContent:{callback:packBundleContent,add:VC.MAJOR,remove:VC.MAJOR,mutate:VC.NEVER,description:"Validate the entries of each bundle defined by a JET Pack"},dependencies:{callback:dependencies,add:VC.MAJOR,remove:VC.MINOR,mutate:VC.SEMVER,description:"Validate the dependencies of a component"},properties:{callback:properties,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:"Validate the properties of a component"},propertyDefault:{callback:propertyDefault,add:VC.PATCH,remove:VC.MAJOR_DEPRECATED,mutate:VC.MAJOR_DEPRECATED,description:"Validate the defaults assigned to properties of a component"},propertyRequired:{callback:propertyRequired,add:VC.MAJOR,remove:VC.PATCH,mutate:VC.NEVER,description:"Validate the required states of a components properties"},propertyReadOnly:{callback:propertyReadOnly,add:VC.MAJOR,remove:VC.PATCH,mutate:VC.NEVER,description:"Validate the read-only states of a components properties"},propertyWriteback:{callback:propertyWriteback,add:VC.PATCH,remove:VC.NEVER,mutate:VC.NEVER,description:"Validate the writeback states of a components properties"},propertyType:{callback:propertyType,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:"Validate the assigned types of a components properties"},propertyEnumeration:{callback:propertyEnumeration,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.MAJOR,description:"Validate the enumValues of a components properties"},methods:{callback:methods,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:"Validate the list of methods exposed by the component"},methodParams:{callback:methodParams,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:"Validate the list of parameters passed to methods exposed by the component"},methodParamTypes:{callback:methodParamTypes,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:"Validate the list of parameters passed to methods exposed by the component"},methodReturnType:{callback:methodReturnType,add:VC.PATCH,remove:VC.MAJOR,mutate:VC.NEVER,description:"Validate the return type of the methods exposed by the component"},events:{callback:events,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:"Validate the list of events exposed by the component"},eventPayload:{callback:eventPayload,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:"Validate the event detail of events exposed by the component"},eventBubbles:{callback:eventBubbles,add:VC.MINOR,remove:VC.NEVER,mutate:VC.NEVER,description:"Validate the event bubbles flag"},eventCancelable:{callback:eventCancelable,add:VC.MINOR,remove:VC.NEVER,mutate:VC.NEVER,description:"Validate the event cancelable flag"},slots:{callback:slots,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:"Validate the list of slots exposed by the component"},slotDataVariable:{callback:slotDataVariable,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:"Validate the list of attributes in a slot data attribute exposed by the component"},slotDataVariableType:{callback:slotDataVariableType,add:VC.NEVER,remove:VC.NEVER,mutate:VC.NEVER,description:"Validate the type assigned to each attributes in a slot data attribute exposed by the component"},dynamicSlots:{callback:dynamicSlots,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:"Validate the presence of the dynamicSlots marker on the component"},styleVariables:{callback:styleVariables,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:"Validate the list of styleVariables supported by the component"},styleClasses:{callback:styleClasses,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:"Validate the list of styleClasses supported by the component"},publicModules:{callback:publicModules,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:"Validate the list of publicModules exposed by a resource component"},componentType:{callback:componentType,add:VC.NEVER,remove:VC.NEVER,mutate:VC.NEVER,description:"Validate the component type has not been changed"}};const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-component-api-controlled-changes"};ruleDef.prototype.getShortDescription=function(){return"Check components for API changes based on a configurable rule-set"};ruleDef.prototype.getDescription=function(){return"This audit compares the APIs exposed by components with older versions in the Exchange Catalog according to a set of rules which determine when given changes, such as the removal of deprecated properties can be made"};ruleDef.prototype.register=function(context){return{startaudit:this._auditPrep,closedownRP:this._dealWithCache,compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._auditPrep=function(context){this.exchangeURL=CommonImpl.checkForExchangeConfiguration(context);if(this.exchangeURL){this.acCache=new AuditComponentCacheManager(context,this.getName(),this.exchangeURL);this.componentExceptions=context.rulePack.getRuleOption("exceptions");const ipr=context.rulePack.getRuleOption("includePreReleases");if(ipr&&ipr===true){this.productionOnly=false}else{this.productionOnly=true}const ruleOverrides=context.rulePack.getRuleOption("controls");this.controlRules={};if(Object.keys(ruleOverrides).length>0){for(const[controlRule,controlRuleDef]of Object.entries(CONTROL_PROFILE)){this.controlRules[controlRule]={...controlRuleDef};if(ruleOverrides.hasOwnProperty(controlRule)){for(const[verb,override]of Object.entries(ruleOverrides[controlRule])){this.controlRules[controlRule][verb]=override}}}}else{this.controlRules={...CONTROL_PROFILE}}const activeControls=context.rulePack.getRuleOption("applyConditions");if(activeControls&&Array.isArray(activeControls)){Object.keys(this.controlRules).forEach(controlRule=>{if(!activeControls.includes(controlRule)){delete this.controlRules[controlRule]}})}this.requiredCheckVersions=CaccHelpers.calcRequiredVersionMatrix(this.controlRules)}else{const issue=new context.Issue(`Invalid or Missing exchangeURL value specified for the rule ${context.ruleName}, rule execution is disabled`);issue.setMsgKey(`${context.ruleName}_2`);issue.setSeverity("critical");context.reporter.addIssue(issue,context)}};ruleDef.prototype._dealWithCache=function(context){const shouldClearCache=context.rulePack.getRuleOption("clearCache",this.getName());if(shouldClearCache&&this.acCache){this.acCache.removeLocalCache()}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);this._conductChecks(context,fullName,componentType,meta)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){const meta={...componentInfo};if(componentInfo.dependencies){meta.dependencies=componentInfo.dependencies.reduce((asMap,entry)=>{asMap[entry.name]=entry.range;return asMap},{})}this._conductChecks(context,componentInfo.fullName,componentInfo.type,meta)}};ruleDef.prototype._conductChecks=function(context,fullName,componentType,componentMeta){const{msgLib,semVerUtils}=context.utils;const privateComponent=componentMeta.subcomponentType&&componentMeta.subcomponentType==="packPrivate";const skipPrivate=context.rulePack.getRuleOption("ignorePackPrivate",context.ruleName);const overrideTypeMappings=applyCustomMappings(context.rulePack.getRuleOption("typeMappings",context.ruleName));if(skipPrivate&&privateComponent){msgLib.info(`packPrivate component ${fullName} skipped due to ignorePackPrivate flag in ${context.ruleName} configuration`)}else{const baselines=this._grabRequiredVersions(context,fullName,componentMeta.version,this.requiredCheckVersions,this.productionOnly);if(baselines&&baselines.latest.version){const compareMetadata=CaccHelpers.deriveConstraintMetadata(baselines);const componentVersionDiff=CaccHelpers.semanticDiff(semVerUtils,componentMeta.version,compareMetadata.version);try{for(const[controlRuleName,controlRuleDef]of Object.entries(this.controlRules)){if(!this._isExemptFromCheck(fullName,controlRuleName)){msgLib.info(`${context.ruleName}(${controlRuleName}): ${controlRuleDef.description}`);const errorMsgContext=CaccHelpers.getStdErrorContext(fullName,controlRuleName);this._executeCheck(controlRuleName,controlRuleDef,semVerUtils,this.acCache,componentMeta,compareMetadata,componentVersionDiff,baselines,componentType,fullName,errorMsgContext,overrideTypeMappings)}}}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${componentMeta.version}: ${auditDetail}`);issue.setMsgKey(`${context.ruleName}_1`);context.reporter.addIssue(issue,context)}}}};ruleDef.prototype._grabRequiredVersions=function(context,fullName,versionUnderTest,requiredVersions,productionVersionsOnly){const{msgLib,semVerUtils}=context.utils;const checkVersions={"never":{isNeeded:true,version:null,metadata:null},"latest":{isNeeded:true,version:null,metadata:null},"patch":{isNeeded:requiredVersions.patch,version:null,metadata:null},"minor":{isNeeded:requiredVersions.minor,version:null,metadata:null},"major":{isNeeded:requiredVersions.major,version:null,metadata:null},"major+":{isNeeded:requiredVersions.major,version:null,metadata:null},"major2+":{isNeeded:requiredVersions.major2,version:null,metadata:null},"major3+":{isNeeded:requiredVersions.major3,version:null,metadata:null}};try{const versionsToCache=new Set;const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${this.exchangeURL}components/${fullName}/versions`);if(existingVersionsResp.statusCode===200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){const{major:vutMajor,minor:vutMinor,patch:vutPatch,prerelease:vutPreRel,version:vutVersion}=semVerUtils.parse(versionUnderTest);let historicalVersions;if(productionVersionsOnly){historicalVersions=existingVersions.items.reverse().filter(versionString=>{const{prerelease}=semVerUtils.parse(versionString);return prerelease.length===0})}else{historicalVersions=existingVersions.items.reverse()}const majorSequence=this._getOffsetMajorVersions(semVerUtils,historicalVersions,vutMajor);for(let i=0;i<historicalVersions.length;i++){const{major:hvMajor,minor:hvMinor,patch:hvPatch,prerelease:hvPreRel,version:hvVersion}=semVerUtils.parse(historicalVersions[i]);if(semVerUtils.lt(hvVersion,vutVersion)){if(!checkVersions.latest.version){checkVersions.latest.version=hvVersion;versionsToCache.add(hvVersion)}if(checkVersions.patch.isNeeded&&!checkVersions.patch.version){checkVersions.patch.version=hvVersion;versionsToCache.add(hvVersion)}if(checkVersions.minor.isNeeded&&!checkVersions.minor.version){if(hvMinor<vutMinor||hvMajor<vutMajor){checkVersions.minor.version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions.major.isNeeded&&!checkVersions.major.version){if(majorSequence[1]&&hvMajor===majorSequence[1]){checkVersions.major.version=hvVersion;checkVersions["major+"].version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions["major2+"].isNeeded&&!checkVersions["major2+"].version){if(majorSequence[2]&&hvMajor===majorSequence[2]){checkVersions["major2+"].version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions["major3+"].isNeeded&&!checkVersions["major3+"].version){if(majorSequence[3]&&hvMajor===majorSequence[3]){checkVersions["major3+"].version=hvVersion;versionsToCache.add(hvVersion);break}}}}versionsToCache.forEach(requiredVersion=>{const cachedDef=this.acCache.getComponentMetadata(fullName,requiredVersion);if(cachedDef){for(const[controlValue,settings]of Object.entries(checkVersions)){if(settings.isNeeded&&settings.version===requiredVersion){checkVersions[controlValue].metadata=cachedDef}}}})}}else if(existingVersionsResp.statusCode===404||existingVersionsResp.eCode==="ENOTFOUND"){msgLib.info(`The component ${fullName} does not exist in the Exchange and so cannot be API verified against older versions. It will be skipped`);if(!this.componentExceptions){this.componentExceptions={}}this.componentExceptions[fullName]=["*"];return}}catch(e){msgLib.error(`Unexpected error processing rule ${context.ruleName} for component ${fullName}:\n${JSON.stringify(e)}`)};return checkVersions};ruleDef.prototype._getOffsetMajorVersions=function(semVerUtils,versions,baseMajorVersion){const majors=[baseMajorVersion];let lastMajor=baseMajorVersion;versions.forEach(stringVersion=>{const{major:parsedMajor}=semVerUtils.parse(stringVersion);if(parsedMajor<lastMajor){lastMajor=parsedMajor;majors.push(parsedMajor)}});return majors};ruleDef.prototype._executeCheck=function(controlRuleName,controlRuleDef,semver,cacheManager,metadata,compareMetadata,componentVersionDiff,baselines,componentType,componentName,errorMsgContext,overrideTypeMappings){const result=controlRuleDef.callback.call(this,controlRuleName,controlRuleDef,semver,cacheManager,metadata,compareMetadata,componentVersionDiff,baselines,componentType,componentName,errorMsgContext,overrideTypeMappings);if(result){throw result}};ruleDef.prototype._isExemptFromCheck=function(fullName,controlRuleName){let exempt=false;let nameMatch;if(this.componentExceptions){if(this.componentExceptions.hasOwnProperty(fullName)){nameMatch=fullName}else{const wildcardNames=Object.keys(this.componentExceptions).reduce((wildcardList,wc)=>{if(wc.endsWith("*")){wildcardList.push(wc.substring(0,wc.length-1))}return wildcardList},[]);if(wildcardNames.length>0){wildcardNames.forEach(wildcard=>{if(fullName.startsWith(wildcard)){nameMatch=wildcard+"*"}})}}if(nameMatch){if(this.componentExceptions[nameMatch].includes("*")||this.componentExceptions[nameMatch].includes(controlRuleName)){exempt=true}}}return exempt};module.exports=ruleDef;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-component-cdn'};ruleDef.prototype.getShortDescription=function(){return'Checks to see if relevant components have a CDN location defined'};ruleDef.prototype.getDescription=function(){return'This rule flags any reference or pack components that do not have a CDN path defined'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){let issue;const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);const componentName=meta.name;switch(componentType){case'pack':case'reference':if(!meta.paths||!meta.paths.cdn||!meta.paths.cdn.hasOwnProperty('min')&&!meta.paths.cdn.hasOwnProperty('debug')){issue=new context.Issue(`${componentType} component ${componentName} does not have a CDN location defined`);context.reporter.addIssue(issue,context)}break;default:break;}}};module.exports=ruleDef;
6
+ const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-component-cdn"};ruleDef.prototype.getShortDescription=function(){return"Checks to see if relevant components have a CDN location defined"};ruleDef.prototype.getDescription=function(){return"This rule flags any reference or pack components that do not have a CDN path defined"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){let issue;const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);const componentName=meta.name;switch(componentType){case"pack":case"reference":if(!meta.paths||!meta.paths.cdn||!meta.paths.cdn.hasOwnProperty("min")&&!meta.paths.cdn.hasOwnProperty("debug")){issue=new context.Issue(`${componentType} component ${componentName} does not have a CDN location defined`);context.reporter.addIssue(issue,context)}break;default:break}}};module.exports=ruleDef;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const SENTENCE_PATTERN=/^([A-Z])/gm;const FORBIDDEN=[/spectra[\s\.,]/gmi,/vb[\s\.,]/gmi,/fa[\s\.,]/gmi];const INTERNAL_URLS=[/http(s?):\/\/(\w)*.(\w){2,}.oracle.com/gmi,/http(s?):\/\/(\w)*.oraclecorp.com/gmi];SCOPE_MAP={property:'properties',propertyEditorValues:'properties',slot:'slots',method:'methods',event:'events'};const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-description-standards'};ruleDef.prototype.getShortDescription=function(){return'Verifies the description attributes of a component meet the documented standards'};ruleDef.prototype.getDescription=function(){return'Internal Oracle standards for description dictate the use of sentence case with normal punctuation, but no trailing period on the final sentence. This audit does a basic scan for this.'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==='composite'){this._checkDescriptions(context,fullName,meta)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkDescriptions(context,componentInfo.fullName,componentInfo)}};ruleDef.prototype._checkDescriptions=function(context,fullName,metadata){if(metadata){this._checkInScope(context,fullName,metadata.description);if(metadata.properties){const flattenedProps=Utils.flattenComponentProperties(metadata,'description');flattenedProps.forEach(prop=>{this._checkInScope(context,fullName,prop.value,'property',prop.key)});const flattenedPEV=Utils.flattenComponentProperties(metadata,'propertyEditorValues');flattenedPEV.forEach(prop=>{if(prop.value){for([pevKey,pevDef]of Object.entries(prop.value)){this._checkInScope(context,fullName,pevDef.description,'propertyEditorValues',prop.key,pevKey)}}})}if(metadata.events){for(const[key,value]of Object.entries(metadata.events)){this._checkInScope(context,fullName,value.description,'event',key)}}if(metadata.methods){for(const[key,value]of Object.entries(metadata.methods)){if(!['setProperty','getProperty','setProperties'].includes(key)){this._checkInScope(context,fullName,value.description,'method',key)}}}if(metadata.slots){for(const[key,value]of Object.entries(metadata.slots)){this._checkInScope(context,fullName,value.description,'slot',key)}}}};ruleDef.prototype._checkInScope=function(context,fullName,checkDescription,scopeType,scope,scopeDetail){const ignore=Utils.shouldIgnoreCheck(context,context.ruleName,fullName,scopeType?SCOPE_MAP[scopeType]:null,scope);let description=new String(checkDescription);if(!ignore&&description&&description.length>0){if(description.endsWith('.')){const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+' > '+scope+' ':''}${scopeDetail?'('+scopeDetail+') ':''}description does not meet the Oracle standards. Indication: trailing full stop / period is not required`);issue.setMsgKey(context.ruleName+'_1');context.reporter.addIssue(issue,context)}description=description.replace('e.g.','');const endSent=/\.[^A-Z^a-z]/;const sentences=description.split(endSent);sentences.forEach(sentence=>{const cleaned=sentence.trim();if(cleaned&&cleaned.length>0){const ucMatches=cleaned.match(SENTENCE_PATTERN);if(!ucMatches){const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+' > '+scope+' ':''}${scopeDetail?'('+scopeDetail+') ':''}description does not meet the Oracle standards. Indication: sentences must begin with a capital letter`);issue.setMsgKey(context.ruleName+'_1');context.reporter.addIssue(issue,context)}}});FORBIDDEN.forEach(pattern=>{if(description.match(pattern)){const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+' > '+scope+' ':''}${scopeDetail?'('+scopeDetail+') ':''}description does not meet the Oracle standards. Indication: forbidden term '${pattern.toString().substring(1,pattern.toString().length-11)}'`);issue.setMsgKey(context.ruleName+'_2');context.reporter.addIssue(issue,context,'blocker')}});INTERNAL_URLS.forEach(pattern=>{const detectedUrls=description.match(pattern);if(detectedUrls){detectedUrls.forEach(url=>{const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+' > '+scope+' ':''}${scopeDetail?'('+scopeDetail+') ':''}description does not meet the Oracle standards. Indication: internal URL '${url}'`);issue.setMsgKey(context.ruleName+'_3');context.reporter.addIssue(issue,context,'blocker')})}})}};module.exports=ruleDef;
6
+ const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const SENTENCE_PATTERN=/^([A-Z])/gm;const FORBIDDEN=[/spectra[\s\.,]/gmi,/vb[\s\.,]/gmi,/fa[\s\.,]/gmi];const INTERNAL_URLS=[/http(s?):\/\/(\w)*.(\w){2,}.oracle.com/gmi,/http(s?):\/\/(\w)*.oraclecorp.com/gmi];SCOPE_MAP={property:"properties",propertyEditorValues:"properties",slot:"slots",method:"methods",event:"events"};const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-description-standards"};ruleDef.prototype.getShortDescription=function(){return"Verifies the description attributes of a component meet the documented standards"};ruleDef.prototype.getDescription=function(){return"Internal Oracle standards for description dictate the use of sentence case with normal punctuation, but no trailing period on the final sentence. This audit does a basic scan for this."};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==="composite"){this._checkDescriptions(context,fullName,meta)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkDescriptions(context,componentInfo.fullName,componentInfo)}};ruleDef.prototype._checkDescriptions=function(context,fullName,metadata){if(metadata){this._checkInScope(context,fullName,metadata.description);if(metadata.properties){const flattenedProps=Utils.flattenComponentProperties(metadata,"description");flattenedProps.forEach(prop=>{this._checkInScope(context,fullName,prop.value,"property",prop.key)});const flattenedPEV=Utils.flattenComponentProperties(metadata,"propertyEditorValues");flattenedPEV.forEach(prop=>{if(prop.value){for([pevKey,pevDef]of Object.entries(prop.value)){this._checkInScope(context,fullName,pevDef.description,"propertyEditorValues",prop.key,pevKey)}}})}if(metadata.events){for(const[key,value]of Object.entries(metadata.events)){this._checkInScope(context,fullName,value.description,"event",key)}}if(metadata.methods){for(const[key,value]of Object.entries(metadata.methods)){if(!["setProperty","getProperty","setProperties"].includes(key)){this._checkInScope(context,fullName,value.description,"method",key)}}}if(metadata.slots){for(const[key,value]of Object.entries(metadata.slots)){this._checkInScope(context,fullName,value.description,"slot",key)}}}};ruleDef.prototype._checkInScope=function(context,fullName,checkDescription,scopeType,scope,scopeDetail){const ignore=Utils.shouldIgnoreCheck(context,context.ruleName,fullName,scopeType?SCOPE_MAP[scopeType]:null,scope);let description=new String(checkDescription);if(!ignore&&description&&description.length>0){if(description.endsWith(".")){const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+" > "+scope+" ":""}${scopeDetail?"("+scopeDetail+") ":""}description does not meet the Oracle standards. Indication: trailing full stop / period is not required`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}description=description.replace("e.g.","");const endSent=/\.[^A-Z^a-z]/;const sentences=description.split(endSent);sentences.forEach(sentence=>{const cleaned=sentence.trim();if(cleaned&&cleaned.length>0){const ucMatches=cleaned.match(SENTENCE_PATTERN);if(!ucMatches){const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+" > "+scope+" ":""}${scopeDetail?"("+scopeDetail+") ":""}description does not meet the Oracle standards. Indication: sentences must begin with a capital letter`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}}});FORBIDDEN.forEach(pattern=>{if(description.match(pattern)){const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+" > "+scope+" ":""}${scopeDetail?"("+scopeDetail+") ":""}description does not meet the Oracle standards. Indication: forbidden term '${pattern.toString().substring(1,pattern.toString().length-11)}'`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context,"blocker")}});INTERNAL_URLS.forEach(pattern=>{const detectedUrls=description.match(pattern);if(detectedUrls){detectedUrls.forEach(url=>{const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+" > "+scope+" ":""}${scopeDetail?"("+scopeDetail+") ":""}description does not meet the Oracle standards. Indication: internal URL '${url}'`);issue.setMsgKey(context.ruleName+"_3");context.reporter.addIssue(issue,context,"blocker")})}})}};module.exports=ruleDef;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const DN_PATTERN=/^([A-Z][a-z0-9\-]*\s?)(([A-Z][a-z0-9\-]*\s?)|([0-9]*\s?))*[^\.]/gm;const FORBIDDEN=[/spectra[\s\.,]/gmi,/vb[\s\.,]/gmi,/fa[\s\.,]/gmi];SCOPE_MAP={property:'properties',propertyEditorValues:'properties',slot:'slots',method:'methods',event:'events'};const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-displayname-standards'};ruleDef.prototype.getShortDescription=function(){return'Verifies the displayName attributes of a component meet the documented standards'};ruleDef.prototype.getDescription=function(){return'Internal Oracle standards for displayName dictate the use of init-capped words and no punctuation. This audit does a basic scan for this.'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==='composite'){this._checkDisplayNames(context,fullName,meta)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkDisplayNames(context,componentInfo.fullName,componentInfo)}};ruleDef.prototype._checkDisplayNames=function(context,fullName,metadata){if(metadata){this._checkInScope(context,fullName,metadata.displayName);if(metadata.properties){const flattenedProps=Utils.flattenComponentProperties(metadata,'displayName');flattenedProps.forEach(prop=>{this._checkInScope(context,fullName,prop.value,'property',prop.key)});const flattenedPEV=Utils.flattenComponentProperties(metadata,'propertyEditorValues');flattenedPEV.forEach(prop=>{if(prop.value){for([pevKey,pevDef]of Object.entries(prop.value)){this._checkInScope(context,fullName,pevDef.displayName,'propertyEditorValues',prop.key,pevKey)}}})}if(metadata.events){for(const[key,value]of Object.entries(metadata.events)){this._checkInScope(context,fullName,value.displayName,'event',key)}}if(metadata.methods){for(const[key,value]of Object.entries(metadata.methods)){this._checkInScope(context,fullName,value.displayName,'method',key)}}if(metadata.slots){for(const[key,value]of Object.entries(metadata.slots)){this._checkInScope(context,fullName,value.displayName,'slot',key)}}}};ruleDef.prototype._checkInScope=function(context,fullName,displayName,scopeType,scope,scopeDetail){const ignore=Utils.shouldIgnoreCheck(context,context.ruleName,fullName,scopeType?SCOPE_MAP[scopeType]:null,scope);if(!ignore&&displayName&&displayName.length>0){const matches=displayName.match(DN_PATTERN);if(!matches||matches[0]!==displayName){const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+' > '+scope+' ':''}${scopeDetail?'('+scopeDetail+') ':''}displayName does not meet the Oracle standards of init-caps and no punctuation`);issue.setMsgKey(context.ruleName+'_1');context.reporter.addIssue(issue,context)}FORBIDDEN.forEach(pattern=>{if(displayName.match(pattern)){const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+' > '+scope+' ':''}${scopeDetail?'('+scopeDetail+') ':''}displayName contains a forbidden term '${pattern.toString().substring(1,pattern.toString().length-11)}'`);issue.setMsgKey(context.ruleName+'_2');context.reporter.addIssue(issue,context,'blocker')}})}};module.exports=ruleDef;
6
+ const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const DN_PATTERN=/^([A-Z][a-z0-9\-]*\s?)(([A-Z][a-z0-9\-]*\s?)|([0-9]*\s?))*[^\.]/gm;const FORBIDDEN=[/spectra[\s\.,]/gmi,/vb[\s\.,]/gmi,/fa[\s\.,]/gmi];SCOPE_MAP={property:"properties",propertyEditorValues:"properties",slot:"slots",method:"methods",event:"events"};const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-displayname-standards"};ruleDef.prototype.getShortDescription=function(){return"Verifies the displayName attributes of a component meet the documented standards"};ruleDef.prototype.getDescription=function(){return"Internal Oracle standards for displayName dictate the use of init-capped words and no punctuation. This audit does a basic scan for this."};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==="composite"){this._checkDisplayNames(context,fullName,meta)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkDisplayNames(context,componentInfo.fullName,componentInfo)}};ruleDef.prototype._checkDisplayNames=function(context,fullName,metadata){if(metadata){this._checkInScope(context,fullName,metadata.displayName);if(metadata.properties){const flattenedProps=Utils.flattenComponentProperties(metadata,"displayName");flattenedProps.forEach(prop=>{this._checkInScope(context,fullName,prop.value,"property",prop.key)});const flattenedPEV=Utils.flattenComponentProperties(metadata,"propertyEditorValues");flattenedPEV.forEach(prop=>{if(prop.value){for([pevKey,pevDef]of Object.entries(prop.value)){this._checkInScope(context,fullName,pevDef.displayName,"propertyEditorValues",prop.key,pevKey)}}})}if(metadata.events){for(const[key,value]of Object.entries(metadata.events)){this._checkInScope(context,fullName,value.displayName,"event",key)}}if(metadata.methods){for(const[key,value]of Object.entries(metadata.methods)){this._checkInScope(context,fullName,value.displayName,"method",key)}}if(metadata.slots){for(const[key,value]of Object.entries(metadata.slots)){this._checkInScope(context,fullName,value.displayName,"slot",key)}}}};ruleDef.prototype._checkInScope=function(context,fullName,displayName,scopeType,scope,scopeDetail){const ignore=Utils.shouldIgnoreCheck(context,context.ruleName,fullName,scopeType?SCOPE_MAP[scopeType]:null,scope);if(!ignore&&displayName&&displayName.length>0){const matches=displayName.match(DN_PATTERN);if(!matches||matches[0]!==displayName){const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+" > "+scope+" ":""}${scopeDetail?"("+scopeDetail+") ":""}displayName does not meet the Oracle standards of init-caps and no punctuation`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}FORBIDDEN.forEach(pattern=>{if(displayName.match(pattern)){const issue=new context.Issue(`Component ${fullName} ${scopeType?scopeType+" > "+scope+" ":""}${scopeDetail?"("+scopeDetail+") ":""}displayName contains a forbidden term '${pattern.toString().substring(1,pattern.toString().length-11)}'`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context,"blocker")}})}};module.exports=ruleDef;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const NetUtils=require('../../lib/NetUtils');const CommonImpl=require('../jetwc-lib/jetwcutils-commonListenerImpls');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-exchange-version-check'};ruleDef.prototype.getShortDescription=function(){return'Verify version is not already in Exchange'};ruleDef.prototype.getDescription=function(){return'This audit checks that the version specified for this component does not already exist in Exchange. This may not actually be an error, hence this informational only.'};ruleDef.prototype.register=function(context){return{startaudit:this._checkForExchangeConfiguration,compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._checkForExchangeConfiguration=function(context){this.exchangeURL=CommonImpl.checkForExchangeConfiguration(context);if(!this.exchangeURL){const issue=new context.Issue(`Invalid or Missing exchangeURL value specified for the rule ${context.ruleName}, rule execution is disabled`);issue.setMsgKey(`${context.ruleName}_3`);issue.setSeverity('critical');context.reporter.addIssue(issue,context)}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const componentDef=context.suppData.obj;const fullName=Utils.getComponentFullName(componentDef);this._checkForExchangeVersion(context,fullName,componentDef.version)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkForExchangeVersion(context,componentInfo.fullName,componentInfo.version)}};ruleDef.prototype._checkForExchangeVersion=function(context,fullName,newVersion){const semver=context.utils.semVerUtils;const msg=context.utils.msgLib;try{const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${this.exchangeURL}components/${fullName}/versions`);const responseCode=existingVersionsResp.statusCode;if(responseCode===200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){let latestMatchVersion,nextProjectedVersion;const versions=existingVersions.items.reverse();for(let i=0;i<versions.length;i++){if(semver.gte(newVersion,versions[i])){latestMatchVersion=versions[i];if(i>0){nextProjectedVersion=versions[i-1]}break}}if(latestMatchVersion){if(latestMatchVersion===newVersion){const sameissue=new context.Issue(`The version number defined for ${fullName} (${newVersion}) already exists in Exchange`);sameissue.setMsgKey('jetwco-exchange-version-check_1');context.reporter.addIssue(sameissue,context)}else if(nextProjectedVersion){const futureissue=new context.Issue(`The version number defined for ${fullName} (${newVersion}) is lower than existing versions in Exchange`);futureissue.setMsgKey('jetwco-exchange-version-check_2');context.reporter.addIssue(futureissue,context)}}}}else if(responseCode===404||existingVersionsResp.eCode==='ENOTFOUND'){msg.info(`The component ${fullName} does not exist in the Exchange and so cannot be API verified against older versions. It will be skipped`)}}catch(e){msg.error(`Unexpected Error in jetwco-exchange-version-check for ${fullName}: ${JSON.stringify(e)}`)};};module.exports=ruleDef;
6
+ const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const NetUtils=require("../../lib/NetUtils");const CommonImpl=require("../jetwc-lib/jetwcutils-commonListenerImpls");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-exchange-version-check"};ruleDef.prototype.getShortDescription=function(){return"Verify version is not already in Exchange"};ruleDef.prototype.getDescription=function(){return"This audit checks that the version specified for this component does not already exist in Exchange. This may not actually be an error, hence this informational only."};ruleDef.prototype.register=function(context){return{startaudit:this._checkForExchangeConfiguration,compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._checkForExchangeConfiguration=function(context){this.exchangeURL=CommonImpl.checkForExchangeConfiguration(context);if(!this.exchangeURL){const issue=new context.Issue(`Invalid or Missing exchangeURL value specified for the rule ${context.ruleName}, rule execution is disabled`);issue.setMsgKey(`${context.ruleName}_3`);issue.setSeverity("critical");context.reporter.addIssue(issue,context)}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const componentDef=context.suppData.obj;const fullName=Utils.getComponentFullName(componentDef);this._checkForExchangeVersion(context,fullName,componentDef.version)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkForExchangeVersion(context,componentInfo.fullName,componentInfo.version)}};ruleDef.prototype._checkForExchangeVersion=function(context,fullName,newVersion){const semver=context.utils.semVerUtils;const msg=context.utils.msgLib;try{const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${this.exchangeURL}components/${fullName}/versions`);const responseCode=existingVersionsResp.statusCode;if(responseCode===200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){let latestMatchVersion,nextProjectedVersion;const versions=existingVersions.items.reverse();for(let i=0;i<versions.length;i++){if(semver.gte(newVersion,versions[i])){latestMatchVersion=versions[i];if(i>0){nextProjectedVersion=versions[i-1]}break}}if(latestMatchVersion){if(latestMatchVersion===newVersion){const sameissue=new context.Issue(`The version number defined for ${fullName} (${newVersion}) already exists in Exchange`);sameissue.setMsgKey("jetwco-exchange-version-check_1");context.reporter.addIssue(sameissue,context)}else if(nextProjectedVersion){const futureissue=new context.Issue(`The version number defined for ${fullName} (${newVersion}) is lower than existing versions in Exchange`);futureissue.setMsgKey("jetwco-exchange-version-check_2");context.reporter.addIssue(futureissue,context)}}}}else if(responseCode===404||existingVersionsResp.eCode==="ENOTFOUND"){msg.info(`The component ${fullName} does not exist in the Exchange and so cannot be API verified against older versions. It will be skipped`)}}catch(e){msg.error(`Unexpected Error in jetwco-exchange-version-check for ${fullName}: ${JSON.stringify(e)}`)};};module.exports=ruleDef;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const path=require('path');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-license-info'};ruleDef.prototype.getShortDescription=function(){return'Validate Licence Information'};ruleDef.prototype.getDescription=function(){return'This rule is checks that a license file (LICENSE.txt) and third party license (THIRD_PARTY_LICENSE.txt) file is present if required'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const msg=context.utils.msgLib;const componentMetadata=context.suppData.obj;const rulePackState=context.rulePack.getExtension();if(componentMetadata){let issue;let licenseFound=false;let licenseCandidate='LICENSE.txt';const compRootFiles=context.utils.fsUtils.readDir(path.dirname(context.filepath));for(let i=0;i<compRootFiles.length;i++){const rootEntry=compRootFiles[i];if(rootEntry.isFile&&rootEntry.name===licenseCandidate){licenseFound=true;break}}if(!licenseFound){issue=new context.Issue(`Component is missing license information file in root, 'LICENSE.txt' is expected (case sensitive)`);issue.setMsgKey(context.ruleName+'_1');context.reporter.addIssue(issue,context)}let thirdPartyScan=false;if(componentMetadata.type&&componentMetadata.type==='reference'){thirdPartyScan=true}else{if(componentMetadata.dependencies){if(rulePackState.allReferenceComponents){Object.keys(componentMetadata.dependencies).forEach(dependency=>{if(rulePackState.allReferenceComponents.has(dependency)){thirdPartyScan=true}})}else{msg.error('JETWC: Unable to scan for reference component dependencies - JETWC-BOOTSTRAP was not run')}}}if(thirdPartyScan){licenseFound=false;licenseCandidate='THIRD_PARTY_LICENSE.txt';for(let i=0;i<compRootFiles.length;i++){const rootEntry=compRootFiles[i];if(rootEntry.isFile&&rootEntry.name===licenseCandidate){licenseFound=true;break}}if(!licenseFound){issue=new context.Issue(`Component with third party dependencies is missing 3rd party license information file in root, 'THIRD_PARTY_LICENSE.txt' is expected (case sensitive)`);issue.setMsgKey(context.ruleName+'_2');context.reporter.addIssue(issue,context)}}}};module.exports=ruleDef;
6
+ const path=require("path");const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-license-info"};ruleDef.prototype.getShortDescription=function(){return"Validate License Information"};ruleDef.prototype.getDescription=function(){return"This rule is checks that a license file (LICENSE.txt) or URL is supplied, and third party license (THIRD_PARTY_LICENSE.txt) file is present if required"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const msg=context.utils.msgLib;const componentMetadata=context.suppData.obj;const rulePackState=context.rulePack.getExtension();if(componentMetadata){let issue;let licenseFileFound=false;let isInMonoPack=Utils.isMonoPackMember(context,componentMetadata);;let licenseURL;let licenseCandidate="LICENSE.txt";const compRootFiles=context.utils.fsUtils.readDir(path.dirname(context.filepath));for(let i=0;i<compRootFiles.length;i++){const rootEntry=compRootFiles[i];if(rootEntry.isFile&&rootEntry.name===licenseCandidate){licenseFileFound=true;break}}if(componentMetadata.hasOwnProperty("license")&&typeof componentMetadata.license==="string"){licenseURL=componentMetadata.license}if(!isInMonoPack&&!licenseFileFound&&!licenseURL){issue=new context.Issue(`Component is missing license information. There should either be a 'LICENSE.txt' file (case sensitive) in the root, or a license attribute in the component metadata.`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}if(licenseURL){const allowedLicenses=context.rulePack.getRuleOptions().allowedLicenseURLs;if(Array.isArray(allowedLicenses)&&allowedLicenses.length>0){if(!allowedLicenses.includes(licenseURL)){issue=new context.Issue(`Component license metadata value does not specified one of the allowed values: ${allowedLicenses.join(", ")}`);issue.setMsgKey(context.ruleName+"_3");context.reporter.addIssue(issue,context)}}}let thirdPartyScan=false;if(componentMetadata.type&&componentMetadata.type==="reference"){thirdPartyScan=true}else{if(componentMetadata.dependencies){if(rulePackState.allReferenceComponents){Object.keys(componentMetadata.dependencies).forEach(dependency=>{if(rulePackState.allReferenceComponents.has(dependency)){thirdPartyScan=true}})}else{msg.error("JETWC: Unable to scan for reference component dependencies - JETWC-BOOTSTRAP was not run")}}}if(thirdPartyScan){licenseFileFound=false;licenseCandidate="THIRD_PARTY_LICENSE.txt";for(let i=0;i<compRootFiles.length;i++){const rootEntry=compRootFiles[i];if(rootEntry.isFile&&rootEntry.name===licenseCandidate){licenseFileFound=true;break}}if(!licenseFileFound){issue=new context.Issue(`Component with third party dependencies is missing 3rd party license information file in root, 'THIRD_PARTY_LICENSE.txt' is expected (case sensitive)`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)}}}};module.exports=ruleDef;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-prerelease-cdn'};ruleDef.prototype.getShortDescription=function(){return'Validates use of the production CDN'};ruleDef.prototype.getDescription=function(){return'This rule checks any CDN definitions to ensure that they point to assets on the production Oracle CDN, not the staging site or other sites'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const productionCDN=context.rulePack.getRuleOptions().cdnRoot.toLowerCase();if(context.suppData.obj){let issue;const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);const componentName=meta.name;if(meta.paths&&meta.paths.cdn){if(meta.paths.cdn.min&&!meta.paths.cdn.min.toLowerCase().startsWith(productionCDN)||meta.paths.cdn.debug&&!meta.paths.cdn.debug.toLowerCase().startsWith(productionCDN)){issue=new context.Issue(`${componentType} component '${componentName}' does not use the correct CDN (${productionCDN})`);context.reporter.addIssue(issue,context)}}}};module.exports=ruleDef;
6
+ const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-prerelease-cdn"};ruleDef.prototype.getShortDescription=function(){return"Validates use of the production CDN"};ruleDef.prototype.getDescription=function(){return"This rule checks any CDN definitions to ensure that they point to assets on the production Oracle CDN, not the staging site or other sites"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const productionCDN=context.rulePack.getRuleOptions().cdnRoot.toLowerCase();if(context.suppData.obj){let issue;const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);const componentName=meta.name;if(meta.paths&&meta.paths.cdn){if(meta.paths.cdn.min&&!meta.paths.cdn.min.toLowerCase().startsWith(productionCDN)||meta.paths.cdn.debug&&!meta.paths.cdn.debug.toLowerCase().startsWith(productionCDN)){issue=new context.Issue(`${componentType} component '${componentName}' does not use the correct CDN (${productionCDN})`);context.reporter.addIssue(issue,context)}}}};module.exports=ruleDef;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-thirdparty-ba'};ruleDef.prototype.getShortDescription=function(){return'Validate Business Approvals'};ruleDef.prototype.getDescription=function(){return'This rule is applied to reference component and any components that depend on reference components to ensure that the PLS Business Approval number is recorded'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);this._checkBA(context,componentType,meta.dependencies,meta.extension)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){let remappedDependencies;if(componentInfo.dependencies){remappedDependencies=componentInfo.dependencies.reduce((asMap,entry)=>{asMap[entry.name]=entry.range;return asMap},{})}this._checkBA(context,componentInfo.type,remappedDependencies,componentInfo.extension)}};ruleDef.prototype._checkBA=function(context,componentType,dependenciesMetadata,extensionMetadata){const referenceComponents=context.rulePack.getExtension().allReferenceComponents;if(componentType==='reference'){if(!(extensionMetadata&&extensionMetadata.oracle&&extensionMetadata.oracle.businessApprovals)){issue=new context.Issue(`Reference component is missing PLS Business Approval Information`);issue.setMsgKey('jetwco-thirdparty-ba_4');context.reporter.addIssue(issue,context)}}if(referenceComponents){let issue;if(dependenciesMetadata){Object.keys(dependenciesMetadata).forEach(dependency=>{if(referenceComponents.has(dependency)){const referencedLibs=referenceComponents.get(dependency);if(referencedLibs&&Object.keys(referencedLibs).length>0){if(!(extensionMetadata&&extensionMetadata.oracle&&extensionMetadata.oracle.businessApprovals)){issue=new context.Issue(`Component is missing PLS Business Approval Information relating to the reference '${dependency}'`);issue.setMsgKey('jetwco-thirdparty-ba_1');context.reporter.addIssue(issue,context)}else{Object.keys(referencedLibs).forEach(lib=>{if(!extensionMetadata.oracle.businessApprovals.hasOwnProperty(lib)){issue=new context.Issue(`Component is missing PLS Business Approval Information relating to '${lib}' from '${dependency}'`);issue.setMsgKey('jetwco-thirdparty-ba_2');context.reporter.addIssue(issue,context)}else{if(extensionMetadata.oracle.businessApprovals[lib]!==referencedLibs[lib]){issue=new context.Issue(`Component PLS Business Approval Information relating to '${lib}' from '${dependency}' does not match`);issue.setMsgKey('jetwco-thirdparty-ba_2');context.reporter.addIssue(issue,context)}}})}}else{issue=new context.Issue(`Reference component dependency '${dependency}' does not have supplied PLS Business Approval Information`);issue.setMsgKey('jetwco-thirdparty-ba_3');context.reporter.addIssue(issue,context)}}})}}};module.exports=ruleDef;
6
+ const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-thirdparty-ba"};ruleDef.prototype.getShortDescription=function(){return"Validate Business Approvals"};ruleDef.prototype.getDescription=function(){return"This rule is applied to reference component and any components that depend on reference components to ensure that the PLS Business Approval number is recorded"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);this._checkBA(context,componentType,meta.dependencies,meta.extension)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){let remappedDependencies;if(componentInfo.dependencies){remappedDependencies=componentInfo.dependencies.reduce((asMap,entry)=>{asMap[entry.name]=entry.range;return asMap},{})}this._checkBA(context,componentInfo.type,remappedDependencies,componentInfo.extension)}};ruleDef.prototype._checkBA=function(context,componentType,dependenciesMetadata,extensionMetadata){const referenceComponents=context.rulePack.getExtension().allReferenceComponents;if(componentType==="reference"){if(!(extensionMetadata&&extensionMetadata.oracle&&extensionMetadata.oracle.businessApprovals)){issue=new context.Issue(`Reference component is missing PLS Business Approval Information`);issue.setMsgKey("jetwco-thirdparty-ba_4");context.reporter.addIssue(issue,context)}}if(referenceComponents){let issue;if(dependenciesMetadata){Object.keys(dependenciesMetadata).forEach(dependency=>{if(referenceComponents.has(dependency)){const referencedLibs=referenceComponents.get(dependency);if(referencedLibs&&Object.keys(referencedLibs).length>0){if(!(extensionMetadata&&extensionMetadata.oracle&&extensionMetadata.oracle.businessApprovals)){issue=new context.Issue(`Component is missing PLS Business Approval Information relating to the reference '${dependency}'`);issue.setMsgKey("jetwco-thirdparty-ba_1");context.reporter.addIssue(issue,context)}else{Object.keys(referencedLibs).forEach(lib=>{if(!extensionMetadata.oracle.businessApprovals.hasOwnProperty(lib)){issue=new context.Issue(`Component is missing PLS Business Approval Information relating to '${lib}' from '${dependency}'`);issue.setMsgKey("jetwco-thirdparty-ba_2");context.reporter.addIssue(issue,context)}else{if(extensionMetadata.oracle.businessApprovals[lib]!==referencedLibs[lib]){issue=new context.Issue(`Component PLS Business Approval Information relating to '${lib}' from '${dependency}' does not match`);issue.setMsgKey("jetwco-thirdparty-ba_2");context.reporter.addIssue(issue,context)}}})}}else{issue=new context.Issue(`Reference component dependency '${dependency}' does not have supplied PLS Business Approval Information`);issue.setMsgKey("jetwco-thirdparty-ba_3");context.reporter.addIssue(issue,context)}}})}}};module.exports=ruleDef;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- {"jetwco-component-cdn":"0001","jetwco-license-info_1":"0002","jetwco-license-info_2":"0003","jetwco-prerelease-cdn":"0004","jetwco-thirdparty-ba_1":"0005","jetwco-thirdparty-ba_2":"0006","jetwco-thirdparty-ba_3":"0007","jetwco-thirdparty-ba_4":"0008","jetwco-exchange-version-check_1":"0009","jetwco-exchange-version-check_2":"0010","jetwco-exchange-version-check_3":"0014","jetwco-component-api-changes_1":"0011","jetwco-component-api-changes_2":"0015","jetwco-compjson-ns-reg":"0012","jetwco-component-api-baseline-changes_1":"0013","jetwco-component-api-baseline-changes_2":"0016","jetwco-displayname-standards_1":"0020","jetwco-displayname-standards_2":"0021","jetwco-description-standards_1":"0030","jetwco-description-standards_2":"0031","jetwco-description-standards_3":"0032","jetwco-component-api-controlled-changes_1":"0040","jetwco-component-api-controlled-changes_2":"0041"}
6
+ {"jetwco-component-cdn":"0001","jetwco-license-info_1":"0002","jetwco-license-info_2":"0003","jetwco-license-info_3":"0050","jetwco-prerelease-cdn":"0004","jetwco-thirdparty-ba_1":"0005","jetwco-thirdparty-ba_2":"0006","jetwco-thirdparty-ba_3":"0007","jetwco-thirdparty-ba_4":"0008","jetwco-exchange-version-check_1":"0009","jetwco-exchange-version-check_2":"0010","jetwco-exchange-version-check_3":"0014","jetwco-component-api-changes_1":"0011","jetwco-component-api-changes_2":"0015","jetwco-compjson-ns-reg":"0012","jetwco-component-api-baseline-changes_1":"0013","jetwco-component-api-baseline-changes_2":"0016","jetwco-displayname-standards_1":"0020","jetwco-displayname-standards_2":"0021","jetwco-description-standards_1":"0030","jetwco-description-standards_2":"0031","jetwco-description-standards_3":"0032","jetwco-component-api-controlled-changes_1":"0040","jetwco-component-api-controlled-changes_2":"0041"}
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- {"title":"Oracle Internal Audit Rules for JET Custom Component Authors","prefix":"JETWCO","version":"1.15.0","rules":{"jetwco-bootstrap":{"group":"jetwco-do-not-disable","enabled":true,"severity":"info","debug":false,"diagnosticFile":"jetwco-diagnostics","auditBuildOutput":false,"testMode":false,"$required":true,"amd":false},"jetwco-component-cdn":{"group":"jetwco-pre-release","severity":"major","filetype":["json"],"amd":false},"jetwco-prerelease-cdn":{"group":"jetwco-pre-release","enabled":true,"cdnRoot":"https://static.oracle.com/cdn/","severity":"blocker","filetype":["json"],"amd":false},"jetwco-thirdparty-ba":{"group":"jetwco-pre-release","enabled":true,"severity":"major","filetype":["json","tsx"],"amd":false},"jetwco-license-info":{"group":"jetwco-pre-release","enabled":true,"severity":"blocker","filetype":["json","tsx"],"amd":false},"jetwco-exchange-version-check":{"group":"jetwco-api","enabled":false,"severity":"info","filetype":["json","tsx"],"amd":false},"jetwco-component-api-changes":{"group":"jetwco-api","enabled":false,"severity":"blocker","filetype":["json","tsx"],"clearCache":false,"amd":false,"status":"deprecated"},"jetwco-compjson-ns-reg":{"group":"jetwco-api","enabled":true,"severity":"major","filetype":["json","tsx"],"amd":false},"jetwco-component-api-baseline-changes":{"group":"jetwco-api","enabled":false,"severity":"blocker","filetype":["json","tsx"],"baseline":{},"clearCache":false,"amd":false,"status":"deprecated"},"jetwco-displayname-standards":{"group":"jetwco-doc","enabled":true,"severity":"minor","filetype":["json","tsx"],"amd":false},"jetwco-description-standards":{"group":"jetwco-doc","enabled":true,"severity":"minor","filetype":["json","tsx"],"amd":false},"jetwco-component-api-controlled-changes":{"group":"jetwco-api","enabled":false,"severity":"blocker","filetype":["json","tsx"],"clearCache":false,"controls":{},"ignorePackPrivate":false,"amd":false}}}
6
+ {"title":"Oracle Internal Audit Rules for JET Custom Component Authors","prefix":"JETWCO","version":"1.16.2","rules":{"jetwco-bootstrap":{"group":"jetwco-do-not-disable","enabled":true,"severity":"info","debug":false,"diagnosticFile":"jetwco-diagnostics","auditBuildOutput":false,"testMode":false,"filetype":["tsx","css","html","js","json","md","ts"],"$required":true,"amd":false},"jetwco-component-cdn":{"group":"jetwco-pre-release","severity":"major","filetype":["json"],"amd":false},"jetwco-prerelease-cdn":{"group":"jetwco-pre-release","enabled":true,"cdnRoot":"https://static.oracle.com/cdn/","severity":"blocker","filetype":["json"],"amd":false},"jetwco-thirdparty-ba":{"group":"jetwco-pre-release","enabled":true,"severity":"major","filetype":["json","tsx"],"amd":false},"jetwco-license-info":{"group":"jetwco-pre-release","enabled":true,"severity":"blocker","filetype":["json","tsx"],"amd":false,"allowedLicenseURLs":[]},"jetwco-exchange-version-check":{"group":"jetwco-api","enabled":false,"severity":"info","filetype":["json","tsx"],"amd":false},"jetwco-component-api-changes":{"group":"jetwco-api","enabled":false,"severity":"blocker","filetype":["json","tsx"],"clearCache":false,"amd":false,"status":"deprecated"},"jetwco-compjson-ns-reg":{"group":"jetwco-api","enabled":true,"severity":"major","filetype":["json","tsx"],"amd":false},"jetwco-component-api-baseline-changes":{"group":"jetwco-api","enabled":false,"severity":"blocker","filetype":["json","tsx"],"baseline":{},"clearCache":false,"amd":false,"status":"deprecated"},"jetwco-displayname-standards":{"group":"jetwco-doc","enabled":true,"severity":"minor","filetype":["json","tsx"],"amd":false},"jetwco-description-standards":{"group":"jetwco-doc","enabled":true,"severity":"minor","filetype":["json","tsx"],"amd":false},"jetwco-component-api-controlled-changes":{"group":"jetwco-api","enabled":false,"severity":"blocker","filetype":["json","tsx"],"clearCache":false,"controls":{},"ignorePackPrivate":false,"tolerantAPICompare":false,"amd":false}}}
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ function getName(){return"jaf-ts-noparser"};function getShortDescription(){return"No .ts/.tsx parser loaded"};function getDescription(){return"While processing a .ts or .tsx file, no parser was loaded."};module.exports={getName,getDescription,getShortDescription};
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- {"jaf-js-diagnose":"1000","jaf-ts-diagnose":"1005","jaf-ts-walk":"1007","jaf-css-diagnose":"1010","jaf-html-diagnose":"1020","jaf-init-schema":"2000","jaf-sys-age":"9100"}
6
+ {"jaf-js-diagnose":"1000","jaf-ts-diagnose":"1005","jaf-ts-walk":"1007","jaf-css-diagnose":"1010","jaf-html-diagnose":"1020","jaf-ts-noparser":"1999","jaf-init-schema":"2000","jaf-sys-age":"9100"}
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- {"title":"JAF System Rules","version":"1.1.0","prefix":"JAF","rules":{"jaf-js-diagnose":{"severity":"blocker","filetype":["js","html"],"group":["jaf-js"],"status":"production","$internal":true},"jaf-ts-diagnose":{"severity":"blocker","filetype":["ts"],"group":["jaf-ts"],"status":"production","$internal":true},"jaf-ts-walk":{"severity":"blocker","filetype":["ts"],"group":["jaf-ts"],"status":"production","$internal":true},"jaf-html-diagnose":{"severity":"minor","filetype":["html"],"group":["jet-html"],"status":"production","$internal":true},"jaf-css-diagnose":{"severity":"minor","filetype":["css","html"],"group":["jet-css"],"status":"production","$internal":true},"jaf-init-schema":{"severity":"major","filetype":["json"],"group":["jet-json"],"status":"production","$internal":true},"jaf-sys-age":{"severity":"minor","group":["jaf-sys"],"status":"production","$internal":true}}}
6
+ {"title":"JAF System Rules","version":"1.2.0","prefix":"JAF","rules":{"jaf-js-diagnose":{"severity":"blocker","filetype":["js","html"],"group":["jaf-js"],"status":"production","$internal":true},"jaf-ts-diagnose":{"severity":"blocker","filetype":["ts"],"group":["jaf-ts"],"status":"production","$internal":true},"jaf-ts-noparser":{"severity":"blocker","filetype":["ts"],"group":["jaf-ts"],"status":"production","$internal":true},"jaf-ts-walk":{"severity":"blocker","filetype":["ts"],"group":["jaf-ts"],"status":"production","$internal":true},"jaf-html-diagnose":{"severity":"minor","filetype":["html"],"group":["jet-html"],"status":"production","$internal":true},"jaf-css-diagnose":{"severity":"minor","filetype":["css","html"],"group":["jet-css"],"status":"production","$internal":true},"jaf-init-schema":{"severity":"major","filetype":["json"],"group":["jet-json"],"status":"production","$internal":true},"jaf-sys-age":{"severity":"minor","group":["jaf-sys"],"status":"production","$internal":true}}}
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const TEMPLATE="template";const OJ_BIND="oj-bind";const OJ_DEFER="oj-defer";const BODY="body";module.exports=function(ruleCtx,slotName){return _getSlotParent(ruleCtx,slotName)};function _getSlotParent(ruleCtx,slotName){var parent,isOjDefer=false,ret=null;parent=ruleCtx.tagNode.parent;isOjDefer=ruleCtx.tag==="oj-defer";if(parent&&parent.name){if(parent.name!==BODY){if(ruleCtx.utils.DomUtils.isSelfClosingTag(parent.name)){ret=_continueUpwards(ruleCtx,parent,slotName)}else{if(ruleCtx.utils.metaLib.isTagSlotName(parent.name,slotName)){ret=parent}}if(!ret){if(isOjDefer&&parent.name===TEMPLATE||parent.name==="oj-switcher"){ret=parent}else if(parent.name===TEMPLATE||parent.name.startsWith(OJ_BIND)||parent.name===OJ_DEFER){ret=_continueUpwards(ruleCtx,parent,slotName)}}}}return ret};function _continueUpwards(ruleCtx,tag,slotName){var ret=null,parent;parent=tag.parent;while(parent){if(parent.name===TEMPLATE||parent.name.startsWith(OJ_BIND)||parent.name===OJ_DEFER||ruleCtx.utils.DomUtils.isSelfClosingTag(parent.name)){parent=parent.parent;continue}if(parent.name!==BODY){if(ruleCtx.utils.metaLib.isTagSlotName(parent.name,slotName)){ret=parent}}break}return ret};
6
+ const TEMPLATE="template";const OJ_BIND="oj-bind";const OJ_DEFER="oj-defer";const BODY="body";module.exports=function(ruleCtx,slotName){return _getSlotParent(ruleCtx,slotName)};function _getSlotParent(ruleCtx,slotName){var parent,isOjDefer=false,ret=null;parent=ruleCtx.tagNode.parent;isOjDefer=ruleCtx.tag==="oj-defer";if(parent?.name){if(parent.name!==BODY){if(ruleCtx.utils.DomUtils.isSelfClosingTag(parent.name)){ret=_continueUpwards(ruleCtx,parent,slotName)}else{if(ruleCtx.utils.metaLib.isTagSlotName(parent.name,slotName)){ret=parent}}if(!ret){if(isOjDefer&&parent.name===TEMPLATE||parent.name==="oj-switcher"){ret=parent}else if(parent.name===TEMPLATE||parent.name.startsWith(OJ_BIND)||parent.name===OJ_DEFER){ret=_continueUpwards(ruleCtx,parent,slotName)}}}}return ret};function _continueUpwards(ruleCtx,tag,slotName){var ret=null,parent;parent=tag.parent;while(parent?.name){if(parent.name===TEMPLATE||parent.name.startsWith(OJ_BIND)||parent.name===OJ_DEFER||ruleCtx.utils.DomUtils.isSelfClosingTag(parent.name)){parent=parent.parent;continue}if(parent.name!==BODY){if(ruleCtx.utils.metaLib.isTagSlotName(parent.name,slotName)){ret=parent}}break}return ret};
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const reMs=new RegExp(/\s+/,'g');const reInsertSp=new RegExp(/([\,\>])/,'g');const DOT='.';const COMMA=',';const GT='>';const STAR='*';const COLON_CLASS=':class';const OJ_BIND_FOR_EACH='oj-bind-for-each';const OJ_BIND_IF='oj-bind-if';const TEMPLATE='template';const SCRIPT='script';var _assertMsg;var _breakingTag=null;function match(ruleCtx,ss){var a,isGroup;if(Array.isArray(ss)){ss=ss.join(COMMA)}ss=_prepSS(ss);isGroup=ss.indexOf(COMMA)>0;a=ss.split(' ');if(a.length===0){return true}return a.length>1?_multi(ruleCtx,ss,a,isGroup):_single(ruleCtx,a[0])};function _single(ruleCtx,s){var elem,a,i;elem=ruleCtx.tag;if(s.charAt(0)===DOT){if(s.includes(DOT,1)){a=s.split(DOT);for(i=0;i<a.length;i++){if(!_testStyleOnTag(ruleCtx.tagNode.attribs,a[i])){return false}}return true}return _testStyleOnTag(ruleCtx.tagNode.attribs,s)}else{if(!s.includes(DOT,1)){return s===elem||s===STAR}a=s.split(DOT);if(a.length===2){return(elem===a[0]||elem===STAR)&&_testStyleOnTag(ruleCtx.tagNode.attribs,a[1])}_assertMsg(`UNHANDLED SS1 -> ${s} - '${ruleCtx.filepath}'`);return false}};function _multi(ruleCtx,ss,a,isGroup){if(isGroup){return _handleMultiGroup(ruleCtx,ss)}if(a.length===2){if(!a[0].startsWith(DOT)&&!a[1].startsWith(DOT)){if(a[0].includes(DOT,1)){if(ruleCtx.tag!==a[1]){return false}let s=a[0].split(DOT);return _findTagWithChainStyle(ruleCtx,ss,a)}if(a[1]!==STAR){if(ruleCtx.tag!==a[1]){return false}}return _findChildElem(ruleCtx,a[0]);_assertMsg(`UNHANDLED SS2 MULTI -> ${a.join(' ')} - '${ruleCtx.filepath}'`);return false}if(a[0].startsWith(DOT)&&!a[1].startsWith(DOT)){return(ruleCtx.tag===a[1]||a[1]===STAR)&&_findTagWithStyle(ruleCtx,'*',a[0])}else if(!a[0].startsWith(DOT)&&a[1].startsWith(DOT)){return _testStyleOnTag(ruleCtx.tagNode.attribs,a[1])&&_findParentTag(ruleCtx,a[0])}}if(a.length===3&&a[1]===GT){if(a[0].startsWith(DOT)&&!a[2].startsWith(DOT)){return(ruleCtx.tag===a[2]||a[2]===STAR)&&_findTagWithStyle(ruleCtx,'*',a[0],true)}else if(!a[0].startsWith(DOT)&&a[2].startsWith(DOT)){return _testStyleOnTag(ruleCtx.tagNode.attribs,a[0])&&_findParentTag(ruleCtx,a[2],true)}else if(!a[0].startsWith(DOT)&&!a[2].startsWith(DOT)){if(ruleCtx.tagNode.name===a[2]||a[2]===STAR){return _findChildElem(ruleCtx,a[0],true)}return false}_assertMsg(`UNHANDLED SS3 MULTI -> ${a.join(' ')} - '${ruleCtx.filepath}'`);return false}_assertMsg(`"UNHANDLED SS4 MULTI -> ${a.join(' ')} - '${ruleCtx.filepath}'`)};function _handleMultiGroup(ruleCtx,ss){var a,i;a=ss.split(COMMA);for(i=0;i<a.length;i++){a[i]=a[i].trim();if(match(ruleCtx,a[i])){return true}}return false};function _testStyleOnTag(attribs,style){var a,i;if(attribs){a=attribs.class||attribs[COLON_CLASS];if(!a){return false}if(_isExpr(a)){return true}a=a.replace(reMs,' ');a=a.split(' ');style=style.charAt(0)===DOT?style.substring(1):style;for(i=0;i<a.length;i++){if(a[i]===style){return true}}}return false};function _findTagWithStyle(ruleCtx,tag,style,direct){return _walkElemStackForTag(ruleCtx,tag,function(o){return _testStyleOnTag(o.attribs,style)},direct)};function _findTagWithChainStyle(ruleCtx,ss,a){return _walkElemStackForTag(ruleCtx,a[0],function(o){return _testStyleOnTag(o.attribs,a[1])},false)};function _findParentTag(ruleCtx,tag,direct){return _walkElemStackForTag(ruleCtx,tag,function(o){return true},direct)};function _findChildElem(ruleCtx,elem,direct){return _walkElemStackForTag(ruleCtx,elem,function(o){return o.name===elem||o.name===SCRIPT},direct)};function _walkElemStackForTag(ruleCtx,tag,cb,direct){var i,b,elem,name;var stack=ruleCtx.elemStack;_breakingTag=null;if(stack&&stack.length){b=false;for(i=stack.length-2;i>=0;i--){if(direct&&b){break}elem=stack[i];name=elem.name;if(name===OJ_BIND_IF||name===OJ_BIND_FOR_EACH||name===TEMPLATE){continue}if(elem.name===tag||tag===STAR||elem.name===SCRIPT){if(cb(elem)){_breakingTag=name;return true}}b=true}}return false};function _isExpr(s){var c=s.charAt(0);return c==='['||c==='{'};function _prepSS(ss){ss=ss.replace(reInsertSp,' $1').trim();return ss.replace(reMs,' ')};function setAssertMsg(fn){_assertMsg=fn};module.exports.match=match;module.exports.setAssertMsg=setAssertMsg;
6
+ const reMs=new RegExp(/\s+/,"g");const reInsertSp=new RegExp(/([\,\>])/,"g");const DOT=".";const COMMA=",";const GT=">";const STAR="*";const COLON_CLASS=":class";const OJ_BIND_FOR_EACH="oj-bind-for-each";const OJ_BIND_IF="oj-bind-if";const TEMPLATE="template";const SCRIPT="script";var _assertMsg;var _breakingTag=null;function match(ruleCtx,ss){var a,isGroup;if(Array.isArray(ss)){ss=ss.join(COMMA)}ss=_prepSS(ss);isGroup=ss.indexOf(COMMA)>0;a=ss.split(" ");if(a.length===0){return true}return a.length>1?_multi(ruleCtx,ss,a,isGroup):_single(ruleCtx,a[0])};function _single(ruleCtx,s){var elem,a,i;elem=ruleCtx.tag;if(s.charAt(0)===DOT){if(s.includes(DOT,1)){a=s.split(DOT);for(i=0;i<a.length;i++){if(!_testStyleOnTag(ruleCtx.tagNode.attribs,a[i])){return false}}return true}return _testStyleOnTag(ruleCtx.tagNode.attribs,s)}else{if(!s.includes(DOT,1)){return s===elem||s===STAR}a=s.split(DOT);if(a.length===2){return(elem===a[0]||elem===STAR)&&_testStyleOnTag(ruleCtx.tagNode.attribs,a[1])}_assertMsg(`UNHANDLED SS1 -> ${s} - '${ruleCtx.filepath}'`);return false}};function _multi(ruleCtx,ss,a,isGroup){if(isGroup){return _handleMultiGroup(ruleCtx,ss)}if(a.length===2){if(!a[0].startsWith(DOT)&&!a[1].startsWith(DOT)){if(a[0].includes(DOT,1)){if(ruleCtx.tag!==a[1]){return false}let s=a[0].split(DOT);return _findTagWithChainStyle(ruleCtx,ss,a)}if(a[1]!==STAR){if(ruleCtx.tag!==a[1]){return false}}return _findChildElem(ruleCtx,a[0]);_assertMsg(`UNHANDLED SS2 MULTI -> ${a.join(" ")} - '${ruleCtx.filepath}'`);return false}if(a[0].startsWith(DOT)&&!a[1].startsWith(DOT)){return(ruleCtx.tag===a[1]||a[1]===STAR)&&_findTagWithStyle(ruleCtx,"*",a[0])}else if(!a[0].startsWith(DOT)&&a[1].startsWith(DOT)){return _testStyleOnTag(ruleCtx.tagNode.attribs,a[1])&&_findParentTag(ruleCtx,a[0])}}if(a.length===3&&a[1]===GT){if(a[0].startsWith(DOT)&&!a[2].startsWith(DOT)){return(ruleCtx.tag===a[2]||a[2]===STAR)&&_findTagWithStyle(ruleCtx,"*",a[0],true)}else if(!a[0].startsWith(DOT)&&a[2].startsWith(DOT)){return _testStyleOnTag(ruleCtx.tagNode.attribs,a[0])&&_findParentTag(ruleCtx,a[2],true)}else if(!a[0].startsWith(DOT)&&!a[2].startsWith(DOT)){if(ruleCtx.tagNode.name===a[2]||a[2]===STAR){return _findChildElem(ruleCtx,a[0],true)}return false}_assertMsg(`UNHANDLED SS3 MULTI -> ${a.join(" ")} - '${ruleCtx.filepath}'`);return false}_assertMsg(`"UNHANDLED SS4 MULTI -> ${a.join(" ")} - '${ruleCtx.filepath}'`)};function _handleMultiGroup(ruleCtx,ss){var a,i;a=ss.split(COMMA);for(i=0;i<a.length;i++){a[i]=a[i].trim();if(match(ruleCtx,a[i])){return true}}return false};function _testStyleOnTag(attribs,style){var a,i;if(attribs){a=attribs.class||attribs[COLON_CLASS];if(!a){return false}if(_isExpr(a)){return true}a=a.replace(reMs," ");a=a.split(" ");style=style.charAt(0)===DOT?style.substring(1):style;for(i=0;i<a.length;i++){if(a[i]===style){return true}}}return false};function _findTagWithStyle(ruleCtx,tag,style,direct){return _walkElemStackForTag(ruleCtx,tag,function(o){return _testStyleOnTag(o.attribs,style)},direct)};function _findTagWithChainStyle(ruleCtx,ss,a){return _walkElemStackForTag(ruleCtx,a[0],function(o){return _testStyleOnTag(o.attribs,a[1])},false)};function _findParentTag(ruleCtx,tag,direct){return _walkElemStackForTag(ruleCtx,tag,function(o){return true},direct)};function _findChildElem(ruleCtx,elem,direct){return _walkElemStackForTag(ruleCtx,elem,function(o){return o.name===elem||o.name===SCRIPT},direct)};function _walkElemStackForTag(ruleCtx,tag,cb,direct){var i,b,elem,name;var stack=ruleCtx.elemStack;_breakingTag=null;if(stack&&stack.length){b=false;for(i=stack.length-2;i>=0;i--){if(direct&&b){break}elem=stack[i];name=elem.name;if(name===OJ_BIND_IF||name===OJ_BIND_FOR_EACH||name===TEMPLATE){continue}if(elem.name===tag||tag===STAR||elem.name===SCRIPT){if(cb(elem)){_breakingTag=name;return true}}b=true}}return false};function _isExpr(s){var c=s.charAt(0);return c==="["||c==="{"};function _prepSS(ss){ss=ss.replace(reInsertSp," $1").trim();return ss.replace(reMs," ")};function setAssertMsg(fn){_assertMsg=fn};module.exports.match=match;module.exports.setAssertMsg=setAssertMsg;
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ const TEMPLATE="template";const OJ_BIND="oj-bind";const OJ_DEFER="oj-defer";const BODY="body";module.exports=function(ruleCtx,tsxComp,slotName){return _getSlotParent(ruleCtx,tsxComp,slotName)};function _getSlotParent(ruleCtx,tsxComp,slotName){var parent,isOjDefer=false,ret=null;parent=tsxComp.parent;isOjDefer=tsxComp.name==="oj-defer";if(parent?.name){if(parent.name!==BODY){if(ruleCtx.utils.tsxUtils.isSelfClosingTag(parent.name)){ret=_continueUpwards(ruleCtx,parent,slotName)}else{if(ruleCtx.utils.metaLib.isTagSlotName(parent.name,slotName)){ret=parent}}if(!ret){if(isOjDefer&&parent.name===TEMPLATE||parent.name==="oj-switcher"){ret=parent}else if(parent.name===TEMPLATE||parent.name.startsWith(OJ_BIND)||parent.name===OJ_DEFER){ret=_continueUpwards(ruleCtx,parent,slotName)}}}}return ret};function _continueUpwards(ruleCtx,tag,slotName){var ret=null,parent;parent=tag.parent;while(parent?.name){if(parent.name===TEMPLATE||parent.name.startsWith(OJ_BIND)||parent.name===OJ_DEFER||ruleCtx.utils.tsxUtils.isSelfClosingTag(parent.name)){parent=parent.parent;continue}if(parent.name!==BODY){if(ruleCtx.utils.metaLib.isTagSlotName(parent.name,slotName)){ret=parent}}break}return ret};