@roster-lock/shared 0.1.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 (314) hide show
  1. package/LICENSE.md +11 -0
  2. package/dist/index.js +19 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/match-lock-file/config-types.js +3 -0
  5. package/dist/match-lock-file/config-types.js.map +1 -0
  6. package/dist/match-lock-file/index.js +19 -0
  7. package/dist/match-lock-file/index.js.map +1 -0
  8. package/dist/match-lock-file/match-config/index.js +18 -0
  9. package/dist/match-lock-file/match-config/index.js.map +1 -0
  10. package/dist/match-lock-file/match-config/version-1/draft/index.js +44 -0
  11. package/dist/match-lock-file/match-config/version-1/draft/index.js.map +1 -0
  12. package/dist/match-lock-file/match-config/version-1/draft/roster-piece-info.js +32 -0
  13. package/dist/match-lock-file/match-config/version-1/draft/roster-piece-info.js.map +1 -0
  14. package/dist/match-lock-file/match-config/version-1/draft/selection-script-info.js +13 -0
  15. package/dist/match-lock-file/match-config/version-1/draft/selection-script-info.js.map +1 -0
  16. package/dist/match-lock-file/match-config/version-1/index.js +22 -0
  17. package/dist/match-lock-file/match-config/version-1/index.js.map +1 -0
  18. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/index.js +37 -0
  19. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/index.js.map +1 -0
  20. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/keywords.js +43 -0
  21. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/keywords.js.map +1 -0
  22. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/index.js +7 -0
  23. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/index.js.map +1 -0
  24. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/officialSelections.js +41 -0
  25. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/officialSelections.js.map +1 -0
  26. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/index.js +20 -0
  27. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/index.js.map +1 -0
  28. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/keywords.js +31 -0
  29. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/keywords.js.map +1 -0
  30. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/schema.js +40 -0
  31. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/schema.js.map +1 -0
  32. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/index.js +17 -0
  33. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/index.js.map +1 -0
  34. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/keywords.js +16 -0
  35. package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/keywords.js.map +1 -0
  36. package/dist/match-lock-file/match-config/version-1/lock/engine/index.js +19 -0
  37. package/dist/match-lock-file/match-config/version-1/lock/engine/index.js.map +1 -0
  38. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/error.js +25 -0
  39. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/error.js.map +1 -0
  40. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/index.js +33 -0
  41. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/index.js.map +1 -0
  42. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath-component.js +31 -0
  43. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath-component.js.map +1 -0
  44. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath.js +37 -0
  45. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath.js.map +1 -0
  46. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/index.js +22 -0
  47. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/index.js.map +1 -0
  48. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/pathvariables.js +24 -0
  49. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/pathvariables.js.map +1 -0
  50. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/index.js +39 -0
  51. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/index.js.map +1 -0
  52. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/index.js +46 -0
  53. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/index.js.map +1 -0
  54. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/path-variables.js +23 -0
  55. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/path-variables.js.map +1 -0
  56. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/requirements.js +99 -0
  57. package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/requirements.js.map +1 -0
  58. package/dist/match-lock-file/match-config/version-1/lock/index.js +56 -0
  59. package/dist/match-lock-file/match-config/version-1/lock/index.js.map +1 -0
  60. package/dist/match-lock-file/match-config/version-1/lock/piece-meta/caster-json-schema/index.js +87 -0
  61. package/dist/match-lock-file/match-config/version-1/lock/piece-meta/caster-json-schema/index.js.map +1 -0
  62. package/dist/match-lock-file/match-config/version-1/lock/piece-meta/index.js +19 -0
  63. package/dist/match-lock-file/match-config/version-1/lock/piece-meta/index.js.map +1 -0
  64. package/dist/match-lock-file/match-config/version-1/lock/piece-meta/validate/index.js +94 -0
  65. package/dist/match-lock-file/match-config/version-1/lock/piece-meta/validate/index.js.map +1 -0
  66. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/downloadableSources.js +18 -0
  67. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/downloadableSources.js.map +1 -0
  68. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/human.js +28 -0
  69. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/human.js.map +1 -0
  70. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/id.js +31 -0
  71. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/id.js.map +1 -0
  72. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/index.js +68 -0
  73. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/index.js.map +1 -0
  74. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/pathVariables.js +49 -0
  75. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/pathVariables.js.map +1 -0
  76. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/requiresPieces.js +62 -0
  77. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/requiresPieces.js.map +1 -0
  78. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/version.js +21 -0
  79. package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/version.js.map +1 -0
  80. package/dist/match-lock-file/match-config/version-1/lock/rosters/index.js +19 -0
  81. package/dist/match-lock-file/match-config/version-1/lock/rosters/index.js.map +1 -0
  82. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/downloadable-source.js +10 -0
  83. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/downloadable-source.js.map +1 -0
  84. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/human.js +27 -0
  85. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/human.js.map +1 -0
  86. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/id.js +27 -0
  87. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/id.js.map +1 -0
  88. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/index.js +74 -0
  89. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/index.js.map +1 -0
  90. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/path-variables.js +31 -0
  91. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/path-variables.js.map +1 -0
  92. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/required-pieces.js +25 -0
  93. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/required-pieces.js.map +1 -0
  94. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/utils.js +23 -0
  95. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/utils.js.map +1 -0
  96. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/version.js +19 -0
  97. package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/version.js.map +1 -0
  98. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/index.js +42 -0
  99. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/index.js.map +1 -0
  100. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/script.js +46 -0
  101. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/script.js.map +1 -0
  102. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/game-controlled.js +12 -0
  103. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/game-controlled.js.map +1 -0
  104. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/normal.js +49 -0
  105. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/normal.js.map +1 -0
  106. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/preselected.js +32 -0
  107. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/preselected.js.map +1 -0
  108. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/unselectable.js +12 -0
  109. package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/unselectable.js.map +1 -0
  110. package/dist/match-lock-file/match-config/version-1/lock/selection/index.js +19 -0
  111. package/dist/match-lock-file/match-config/version-1/lock/selection/index.js.map +1 -0
  112. package/dist/match-lock-file/match-config/version-1/lock/selection/validate/index.js +33 -0
  113. package/dist/match-lock-file/match-config/version-1/lock/selection/validate/index.js.map +1 -0
  114. package/dist/match-lock-file/match-config/version-1/lock/selection/validate/script.js +23 -0
  115. package/dist/match-lock-file/match-config/version-1/lock/selection/validate/script.js.map +1 -0
  116. package/dist/match-lock-file/match-config/version-1/lock/selection/validate/selections/normal.js +49 -0
  117. package/dist/match-lock-file/match-config/version-1/lock/selection/validate/selections/normal.js.map +1 -0
  118. package/dist/match-lock-file/match-config/version-1/lock/selection/validate/selections/preselected.js +14 -0
  119. package/dist/match-lock-file/match-config/version-1/lock/selection/validate/selections/preselected.js.map +1 -0
  120. package/dist/match-lock-file/match-config/version-1/piece-info/file-paths.js +5 -0
  121. package/dist/match-lock-file/match-config/version-1/piece-info/file-paths.js.map +1 -0
  122. package/dist/match-lock-file/match-config/version-1/piece-info/index.js +23 -0
  123. package/dist/match-lock-file/match-config/version-1/piece-info/index.js.map +1 -0
  124. package/dist/match-lock-file/match-config/version-1/piece-info/keywords.js +29 -0
  125. package/dist/match-lock-file/match-config/version-1/piece-info/keywords.js.map +1 -0
  126. package/dist/match-lock-file/match-config/version-1/piece-info/schema.js +19 -0
  127. package/dist/match-lock-file/match-config/version-1/piece-info/schema.js.map +1 -0
  128. package/dist/match-lock-file/match-config/version-1/shared/Identity.js +15 -0
  129. package/dist/match-lock-file/match-config/version-1/shared/Identity.js.map +1 -0
  130. package/dist/match-lock-file/match-config/version-1/shared/SelectedPiece.js +38 -0
  131. package/dist/match-lock-file/match-config/version-1/shared/SelectedPiece.js.map +1 -0
  132. package/dist/match-lock-file/match-config/version-1/shared/count.js +48 -0
  133. package/dist/match-lock-file/match-config/version-1/shared/count.js.map +1 -0
  134. package/dist/match-lock-file/match-config/version-1/shared/index.js +25 -0
  135. package/dist/match-lock-file/match-config/version-1/shared/index.js.map +1 -0
  136. package/dist/match-lock-file/match-config/version-1/usage/calculatePieceVersion.js +70 -0
  137. package/dist/match-lock-file/match-config/version-1/usage/calculatePieceVersion.js.map +1 -0
  138. package/dist/match-lock-file/match-config/version-1/usage/empty-configs.js +49 -0
  139. package/dist/match-lock-file/match-config/version-1/usage/empty-configs.js.map +1 -0
  140. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/constants.js +8 -0
  141. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/constants.js.map +1 -0
  142. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/getAssetsOfFiles.js +75 -0
  143. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/getAssetsOfFiles.js.map +1 -0
  144. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/getMatchingAsset.js +28 -0
  145. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/getMatchingAsset.js.map +1 -0
  146. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/index.js +20 -0
  147. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/index.js.map +1 -0
  148. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/types.js +3 -0
  149. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/types.js.map +1 -0
  150. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/validateAssetFileCount.js +33 -0
  151. package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/validateAssetFileCount.js.map +1 -0
  152. package/dist/match-lock-file/match-config/version-1/usage/index.js +22 -0
  153. package/dist/match-lock-file/match-config/version-1/usage/index.js.map +1 -0
  154. package/dist/match-lock-file/match-config/version-1/usage/publish/SemVer.js +63 -0
  155. package/dist/match-lock-file/match-config/version-1/usage/publish/SemVer.js.map +1 -0
  156. package/dist/match-lock-file/match-config/version-1/usage/publish/diffLocks.js +51 -0
  157. package/dist/match-lock-file/match-config/version-1/usage/publish/diffLocks.js.map +1 -0
  158. package/dist/match-lock-file/match-config/version-1/usage/publish/index.js +19 -0
  159. package/dist/match-lock-file/match-config/version-1/usage/publish/index.js.map +1 -0
  160. package/dist/match-lock-file/match-config/version-1/usage/validate-select/constants.js +14 -0
  161. package/dist/match-lock-file/match-config/version-1/usage/validate-select/constants.js.map +1 -0
  162. package/dist/match-lock-file/match-config/version-1/usage/validate-select/ensure-pieces-are-in-roster.js +53 -0
  163. package/dist/match-lock-file/match-config/version-1/usage/validate-select/ensure-pieces-are-in-roster.js.map +1 -0
  164. package/dist/match-lock-file/match-config/version-1/usage/validate-select/handle-validation.js +49 -0
  165. package/dist/match-lock-file/match-config/version-1/usage/validate-select/handle-validation.js.map +1 -0
  166. package/dist/match-lock-file/match-config/version-1/usage/validate-select/index.js +68 -0
  167. package/dist/match-lock-file/match-config/version-1/usage/validate-select/index.js.map +1 -0
  168. package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/game-controlled.js +38 -0
  169. package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/game-controlled.js.map +1 -0
  170. package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/cast-result.js +40 -0
  171. package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/cast-result.js.map +1 -0
  172. package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/index.js +78 -0
  173. package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/index.js.map +1 -0
  174. package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/validate-user-selection.js +43 -0
  175. package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/validate-user-selection.js.map +1 -0
  176. package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/preselected.js +26 -0
  177. package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/preselected.js.map +1 -0
  178. package/dist/match-lock-file/util-types/json-schema/JSONSchemaCaster.js +45 -0
  179. package/dist/match-lock-file/util-types/json-schema/JSONSchemaCaster.js.map +1 -0
  180. package/dist/match-lock-file/util-types/json-schema/defineKeyword.js +30 -0
  181. package/dist/match-lock-file/util-types/json-schema/defineKeyword.js.map +1 -0
  182. package/dist/match-lock-file/util-types/json-schema/index.js +21 -0
  183. package/dist/match-lock-file/util-types/json-schema/index.js.map +1 -0
  184. package/dist/match-lock-file/util-types/json-schema/safe-keyword.js +3 -0
  185. package/dist/match-lock-file/util-types/json-schema/safe-keyword.js.map +1 -0
  186. package/dist/match-lock-file/util-types/json-schema/schema-types.js +3 -0
  187. package/dist/match-lock-file/util-types/json-schema/schema-types.js.map +1 -0
  188. package/package.json +49 -0
  189. package/src/index.ts +3 -0
  190. package/src/match-lock-file/config-types.ts +10 -0
  191. package/src/match-lock-file/index.ts +4 -0
  192. package/src/match-lock-file/match-config/index.ts +2 -0
  193. package/src/match-lock-file/match-config/version-0/pieces/caster-runtypes/index.ts +99 -0
  194. package/src/match-lock-file/match-config/version-0/pieces/caster-runtypes/util-casters.ts +155 -0
  195. package/src/match-lock-file/match-config/version-0/pieces/index.ts +3 -0
  196. package/src/match-lock-file/match-config/version-0/pieces/types.ts +49 -0
  197. package/src/match-lock-file/match-config/version-0/pieces/validate/definition/assetCount.ts +33 -0
  198. package/src/match-lock-file/match-config/version-0/pieces/validate/definition/assetType.ts +22 -0
  199. package/src/match-lock-file/match-config/version-0/pieces/validate/definition/index.ts +30 -0
  200. package/src/match-lock-file/match-config/version-0/pieces/validate/definition/pathVariables.ts +39 -0
  201. package/src/match-lock-file/match-config/version-0/pieces/validate/index.ts +4 -0
  202. package/src/match-lock-file/match-config/version-0/pieces/validate/sha.ts +23 -0
  203. package/src/match-lock-file/match-config/version-0/pieces/validate/version.ts +66 -0
  204. package/src/match-lock-file/match-config/version-0/restriction/casters.ts +52 -0
  205. package/src/match-lock-file/match-config/version-0/restriction/index.ts +4 -0
  206. package/src/match-lock-file/match-config/version-0/restriction/types.ts +42 -0
  207. package/src/match-lock-file/match-config/version-0/restriction/validate/index.ts +15 -0
  208. package/src/match-lock-file/match-config/version-0/restriction/validate/piece/index.ts +46 -0
  209. package/src/match-lock-file/match-config/version-0/restriction/validate/sha.ts +19 -0
  210. package/src/match-lock-file/match-config/version-0/selection/casters.ts +105 -0
  211. package/src/match-lock-file/match-config/version-0/selection/validate/count.ts +16 -0
  212. package/src/match-lock-file/match-config/version-0/selection/validate/index.ts +40 -0
  213. package/src/match-lock-file/match-config/version-0/selection/validate/scriptMeta.ts +26 -0
  214. package/src/match-lock-file/match-config/version-1/draft/index.ts +52 -0
  215. package/src/match-lock-file/match-config/version-1/draft/roster-piece-info.ts +33 -0
  216. package/src/match-lock-file/match-config/version-1/draft/selection-script-info.ts +16 -0
  217. package/src/match-lock-file/match-config/version-1/index.ts +7 -0
  218. package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/index.ts +46 -0
  219. package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/keywords.ts +48 -0
  220. package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/index.ts +6 -0
  221. package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/officialSelections.ts +42 -0
  222. package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/index.ts +26 -0
  223. package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/keywords.ts +34 -0
  224. package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/schema.ts +47 -0
  225. package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/index.ts +22 -0
  226. package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/keywords.ts +14 -0
  227. package/src/match-lock-file/match-config/version-1/lock/engine/index.ts +3 -0
  228. package/src/match-lock-file/match-config/version-1/lock/engine/validate/constants.ts +7 -0
  229. package/src/match-lock-file/match-config/version-1/lock/engine/validate/error.ts +21 -0
  230. package/src/match-lock-file/match-config/version-1/lock/engine/validate/index.ts +18 -0
  231. package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath-component.ts +41 -0
  232. package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath.ts +55 -0
  233. package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/index.ts +21 -0
  234. package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/pathvariables.ts +28 -0
  235. package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/index.ts +46 -0
  236. package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/index.ts +37 -0
  237. package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/path-variables.ts +21 -0
  238. package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/requirements.ts +117 -0
  239. package/src/match-lock-file/match-config/version-1/lock/index.ts +51 -0
  240. package/src/match-lock-file/match-config/version-1/lock/piece-meta/caster-json-schema/index.ts +97 -0
  241. package/src/match-lock-file/match-config/version-1/lock/piece-meta/index.ts +3 -0
  242. package/src/match-lock-file/match-config/version-1/lock/piece-meta/validate/index.ts +114 -0
  243. package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/downloadableSources.ts +25 -0
  244. package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/human.ts +33 -0
  245. package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/id.ts +33 -0
  246. package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/index.ts +103 -0
  247. package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/pathVariables.ts +59 -0
  248. package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/requiresPieces.ts +71 -0
  249. package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/version.ts +22 -0
  250. package/src/match-lock-file/match-config/version-1/lock/rosters/index.ts +3 -0
  251. package/src/match-lock-file/match-config/version-1/lock/rosters/validate/downloadable-source.ts +9 -0
  252. package/src/match-lock-file/match-config/version-1/lock/rosters/validate/human.ts +22 -0
  253. package/src/match-lock-file/match-config/version-1/lock/rosters/validate/id.ts +20 -0
  254. package/src/match-lock-file/match-config/version-1/lock/rosters/validate/index.ts +83 -0
  255. package/src/match-lock-file/match-config/version-1/lock/rosters/validate/path-variables.ts +40 -0
  256. package/src/match-lock-file/match-config/version-1/lock/rosters/validate/required-pieces.ts +30 -0
  257. package/src/match-lock-file/match-config/version-1/lock/rosters/validate/utils.ts +17 -0
  258. package/src/match-lock-file/match-config/version-1/lock/rosters/validate/version.ts +22 -0
  259. package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/index.ts +53 -0
  260. package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/script.ts +54 -0
  261. package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/game-controlled.ts +11 -0
  262. package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/normal.ts +58 -0
  263. package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/preselected.ts +37 -0
  264. package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/unselectable.ts +11 -0
  265. package/src/match-lock-file/match-config/version-1/lock/selection/index.ts +3 -0
  266. package/src/match-lock-file/match-config/version-1/lock/selection/validate/index.ts +37 -0
  267. package/src/match-lock-file/match-config/version-1/lock/selection/validate/script.ts +28 -0
  268. package/src/match-lock-file/match-config/version-1/lock/selection/validate/selections/normal.ts +69 -0
  269. package/src/match-lock-file/match-config/version-1/lock/selection/validate/selections/preselected.ts +18 -0
  270. package/src/match-lock-file/match-config/version-1/piece-info/file-paths.ts +2 -0
  271. package/src/match-lock-file/match-config/version-1/piece-info/index.ts +14 -0
  272. package/src/match-lock-file/match-config/version-1/piece-info/keywords.ts +39 -0
  273. package/src/match-lock-file/match-config/version-1/piece-info/schema.ts +29 -0
  274. package/src/match-lock-file/match-config/version-1/shared/Identity.ts +14 -0
  275. package/src/match-lock-file/match-config/version-1/shared/SelectedPiece.ts +49 -0
  276. package/src/match-lock-file/match-config/version-1/shared/count.ts +47 -0
  277. package/src/match-lock-file/match-config/version-1/shared/index.ts +9 -0
  278. package/src/match-lock-file/match-config/version-1/usage/calculatePieceVersion.ts +85 -0
  279. package/src/match-lock-file/match-config/version-1/usage/empty-configs.ts +61 -0
  280. package/src/match-lock-file/match-config/version-1/usage/files-and-assets/constants.ts +6 -0
  281. package/src/match-lock-file/match-config/version-1/usage/files-and-assets/getAssetsOfFiles.ts +88 -0
  282. package/src/match-lock-file/match-config/version-1/usage/files-and-assets/getMatchingAsset.ts +42 -0
  283. package/src/match-lock-file/match-config/version-1/usage/files-and-assets/index.ts +4 -0
  284. package/src/match-lock-file/match-config/version-1/usage/files-and-assets/types.ts +5 -0
  285. package/src/match-lock-file/match-config/version-1/usage/files-and-assets/validateAssetFileCount.ts +34 -0
  286. package/src/match-lock-file/match-config/version-1/usage/index.ts +6 -0
  287. package/src/match-lock-file/match-config/version-1/usage/publish/SemVer.ts +67 -0
  288. package/src/match-lock-file/match-config/version-1/usage/publish/diffLocks.ts +66 -0
  289. package/src/match-lock-file/match-config/version-1/usage/publish/index.ts +2 -0
  290. package/src/match-lock-file/match-config/version-1/usage/validate-select/constants.ts +9 -0
  291. package/src/match-lock-file/match-config/version-1/usage/validate-select/ensure-pieces-are-in-roster.ts +61 -0
  292. package/src/match-lock-file/match-config/version-1/usage/validate-select/handle-validation.ts +54 -0
  293. package/src/match-lock-file/match-config/version-1/usage/validate-select/index.ts +98 -0
  294. package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/game-controlled.ts +49 -0
  295. package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/cast-result.ts +39 -0
  296. package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/include-mandatory-require.ts +44 -0
  297. package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/index.ts +101 -0
  298. package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/validate-user-selection.ts +51 -0
  299. package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/preselected.ts +36 -0
  300. package/src/match-lock-file/util-types/json-schema/JSONSchemaCaster.ts +52 -0
  301. package/src/match-lock-file/util-types/json-schema/checkVersion.ts +9 -0
  302. package/src/match-lock-file/util-types/json-schema/defineKeyword.ts +50 -0
  303. package/src/match-lock-file/util-types/json-schema/index.ts +4 -0
  304. package/src/match-lock-file/util-types/json-schema/safe-keyword.ts +27 -0
  305. package/src/match-lock-file/util-types/json-schema/schema-types.ts +5 -0
  306. package/tests/engine/assets.spec.ts +147 -0
  307. package/tests/engine/official-selections.spec.ts +67 -0
  308. package/tests/engine/requirements.spec.ts +43 -0
  309. package/tests/piece-info/cast.spec.ts +20 -0
  310. package/tests/piece-info/rosterlock.piece-info.json +15 -0
  311. package/tests/piece-meta/cast.spec.ts +60 -0
  312. package/tests/rosters/path-variables.spec.ts +52 -0
  313. package/tests/selection/cast-result.spec.ts +72 -0
  314. package/tsconfig.json +20 -0
@@ -0,0 +1,17 @@
1
+
2
+ export function validateSha256(value: string){
3
+ // Must be exactly 64 hex chars (0–9, a–f, case‑insensitive)
4
+ if (/^[0-9a-f]{64}$/i.test(value)) return;
5
+ throw new Error(`${value} is not a valid SHA-256 (64-char hex)`);
6
+ }
7
+
8
+ export function validateURL(value: string){
9
+ let url: URL;
10
+ try {
11
+ url = new URL(value);
12
+ } catch {
13
+ throw new Error(`${value} is not a valid URL`);
14
+ }
15
+ if(url.protocol === "http:" && url.hostname === "localhost") return;
16
+ if(!["https:"].includes(url.protocol)) throw new Error(`${value} is not a valid https`);
17
+ }
@@ -0,0 +1,22 @@
1
+
2
+ import { RosterLockV1Config } from "@roster-lock/types";
3
+
4
+ import { validateSha256 } from "./utils";
5
+
6
+ type PieceVersion = RosterLockV1Config["rosters"][string][0]["version"];
7
+ export function validateVersions(
8
+ versions: PieceVersion
9
+ ){
10
+ validateSha256(versions.logic);
11
+ validateSha256(versions.media);
12
+ validateSha256(versions.docs);
13
+ }
14
+
15
+ export function validateVersionUniqueness(
16
+ versions: PieceVersion, index: number, rosters: RosterLockV1Config["rosters"][string]
17
+ ){
18
+ for(let i = 0; i < rosters.length; i++){
19
+ if(i === index) continue;
20
+ if(rosters[i].version.logic === versions.logic) throw new Error(`Duplicate Logic Version ${versions.logic}`);
21
+ }
22
+ }
@@ -0,0 +1,53 @@
1
+ import { JSONSchemaType } from "ajv";
2
+
3
+
4
+ import { RosterLockV1Config } from "@roster-lock/types";
5
+
6
+ import { preselectedSelectionSchema } from "./selection-types/preselected";
7
+ import { normalSelectionSchema } from "./selection-types/normal";
8
+ import { gameControlledSelectionSchema } from "./selection-types/game-controlled";
9
+ import { unselectableSelectionSchema } from "./selection-types/unselectable";
10
+
11
+ import {
12
+ untrustedScriptRefSchema, scriptRefSrcSchemaValidator, scriptRefMethodSchemaValidator,
13
+ untrustedScriptDictionarySchema
14
+ } from "./script";
15
+ export { untrustedScriptRefSchema };
16
+
17
+ export const selectionConfigSchema: JSONSchemaType<RosterLockV1Config["selection"]> = {
18
+ type: "object",
19
+ required: ["piece", "scriptDictionary"],
20
+ additionalProperties: false,
21
+ properties: {
22
+ piece: {
23
+ type: "object",
24
+ required: [],
25
+ additionalProperties: {
26
+ oneOf: [
27
+ preselectedSelectionSchema,
28
+ normalSelectionSchema,
29
+ gameControlledSelectionSchema,
30
+ unselectableSelectionSchema
31
+ ],
32
+ },
33
+ },
34
+ globalValidation: {
35
+ type: "array",
36
+ items: untrustedScriptRefSchema,
37
+ },
38
+ scriptDictionary: untrustedScriptDictionarySchema
39
+ },
40
+ };
41
+
42
+
43
+ import { banListSchemaValidator } from "./selection-types/normal";
44
+ import { preselectedSchemaValidator } from "./selection-types/preselected";
45
+
46
+ export const selectionKeywords = [
47
+ banListSchemaValidator,
48
+
49
+ preselectedSchemaValidator,
50
+
51
+ scriptRefSrcSchemaValidator,
52
+ scriptRefMethodSchemaValidator,
53
+ ];
@@ -0,0 +1,54 @@
1
+
2
+ import { JSONSchemaType } from "ajv";
3
+ import { RosterLockV1Config, UntrustedScriptRef } from "@roster-lock/types";
4
+ import { defineKeyword } from "../../../../../util-types/json-schema";
5
+
6
+ import {
7
+ validateUntrustedScriptSrc,
8
+ validateUntrustedScriptMethod,
9
+ } from "../validate/script";
10
+
11
+ export const scriptRefSrcSchemaValidator = defineKeyword({
12
+ keyword: "untrustedScriptSrc",
13
+ type: "string",
14
+ validate(value, config: RosterLockV1Config){
15
+ validateUntrustedScriptSrc(value, config);
16
+ }
17
+ });
18
+
19
+ export const scriptRefMethodSchemaValidator = defineKeyword({
20
+ keyword: "untrustedScriptMethod",
21
+ type: "string",
22
+ validate(value, config: RosterLockV1Config){
23
+ validateUntrustedScriptMethod(value);
24
+ }
25
+ });
26
+
27
+ export const untrustedScriptRefSchema: JSONSchemaType<UntrustedScriptRef> = {
28
+ type: "object",
29
+ required: ["src"],
30
+ additionalProperties: false,
31
+ properties: {
32
+ src: {
33
+ type: "string",
34
+ [scriptRefSrcSchemaValidator.keyword]: true
35
+ },
36
+ method: {
37
+ type: "string", nullable: true,
38
+ [scriptRefMethodSchemaValidator.keyword]: true
39
+ }
40
+ },
41
+ };
42
+
43
+
44
+ export const untrustedScriptDictionarySchema: JSONSchemaType<RosterLockV1Config["selection"]["scriptDictionary"]> = {
45
+ type: "object", required: [],
46
+ propertyNames: { type: "string" },
47
+ additionalProperties: {
48
+ type: "object", required: ["content"],
49
+ additionalProperties: false,
50
+ properties: {
51
+ content: { type: "string" },
52
+ }
53
+ }
54
+ };
@@ -0,0 +1,11 @@
1
+ import { JSONSchemaType } from "ajv";
2
+ import { SelectionGameControlledConfig } from "@roster-lock/types";
3
+
4
+ export const gameControlledSelectionSchema: JSONSchemaType<SelectionGameControlledConfig> = {
5
+ type: "object",
6
+ required: ["type"],
7
+ additionalProperties: false,
8
+ properties: {
9
+ type: { type: "string", const: "game-controlled" },
10
+ },
11
+ };
@@ -0,0 +1,58 @@
1
+
2
+ import { JSONSchemaType } from "ajv";
3
+ import {
4
+ RosterLockV1Config,
5
+ SelectionNormalConfig,
6
+ UserSelectionValidation,
7
+ } from "@roster-lock/types";
8
+
9
+ import { untrustedScriptRefSchema } from "../script";
10
+ import { validateSelectionBanList } from "../../validate/selections/normal";
11
+ import { defineKeyword } from "../../../../../../util-types/json-schema";
12
+ import { countSchema } from "../../../../shared/count";
13
+
14
+ export const banListSchemaValidator = defineKeyword({
15
+ keyword: "selectionBanList",
16
+ type: "array",
17
+ validate: function (banList: Array<string>, { rosters }: RosterLockV1Config, path){
18
+ if(!banList) return;
19
+ // /selection/piece/pieceType/validation/banList
20
+ const pieceType = path.split("/").at(-3);
21
+ if(!pieceType) throw new Error("Invalid path");
22
+ const roster = rosters[pieceType];
23
+ validateSelectionBanList(banList, roster);
24
+ }
25
+ });
26
+
27
+
28
+ const userSelectionValidationSchema: JSONSchemaType<UserSelectionValidation> = {
29
+ type: "object",
30
+ required: ["count", "unique", "customValidation"],
31
+ additionalProperties: false,
32
+ properties: {
33
+ count: countSchema,
34
+ unique: { type: "boolean" },
35
+ banList: {
36
+ type: "array",
37
+ items: { type: "string" },
38
+ [banListSchemaValidator.keyword]: true,
39
+ },
40
+ customValidation: {
41
+ type: "array",
42
+ items: untrustedScriptRefSchema,
43
+ },
44
+ },
45
+ };
46
+
47
+ export const normalSelectionSchema: JSONSchemaType<SelectionNormalConfig> = {
48
+ type: "object",
49
+ required: ["type"],
50
+ additionalProperties: false,
51
+ properties: {
52
+ type: { type: "string", const: "normal" },
53
+ validation: userSelectionValidationSchema,
54
+ mergeAlgorithm: { ...untrustedScriptRefSchema, nullable: true },
55
+ },
56
+ };
57
+
58
+
@@ -0,0 +1,37 @@
1
+
2
+ import { JSONSchemaType } from "ajv";
3
+ import { RosterLockV1Config, SelectionPreselectedConfig } from "@roster-lock/types";
4
+ import { validatePreselected } from "../../validate/selections/preselected";
5
+ import { defineKeyword } from "../../../../../../util-types/json-schema";
6
+ import { SelectedPieceSchema, SelectedPieceSchemaDef } from "../../../../shared";
7
+
8
+ export const preselectedSchemaValidator = defineKeyword({
9
+ keyword: "selectionPreselected",
10
+ type: "array",
11
+ validate: function (
12
+ selection: SelectionPreselectedConfig["pieces"],
13
+ config: RosterLockV1Config,
14
+ path
15
+ ){
16
+ // /selection/piece/pieceType/pieces
17
+ const pieceType = path.split("/").at(-2);
18
+ if(!pieceType) throw new Error("Invalid path");
19
+ validatePreselected(selection, pieceType, config);
20
+ }
21
+ });
22
+
23
+ export const preselectedSelectionSchema = {
24
+ $id: "preselectedSelectionSchema",
25
+ type: "object",
26
+ required: ["type", "pieces"],
27
+ additionalProperties: false,
28
+ ...SelectedPieceSchemaDef,
29
+ properties: {
30
+ type: { type: "string", const: "preselected" },
31
+ pieces: {
32
+ type: "array",
33
+ [preselectedSchemaValidator.keyword]: true,
34
+ items: SelectedPieceSchema,
35
+ },
36
+ },
37
+ } as unknown as JSONSchemaType<SelectionPreselectedConfig>;
@@ -0,0 +1,11 @@
1
+ import { JSONSchemaType } from "ajv";
2
+ import { SelectionUnselectableConfig } from "@roster-lock/types/src/v1/lock/selection/selection-types/unselectable";
3
+
4
+ export const unselectableSelectionSchema: JSONSchemaType<SelectionUnselectableConfig> = {
5
+ type: "object",
6
+ required: ["type"],
7
+ additionalProperties: false,
8
+ properties: {
9
+ type: { type: "string", const: "unselectable" },
10
+ },
11
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./validate";
2
+ export * from "./caster-json-schema";
3
+
@@ -0,0 +1,37 @@
1
+ import { RosterLockV1Config } from "@roster-lock/types";
2
+
3
+ import { validateNormal } from "./selections/normal";
4
+ import { validatePreselected } from "./selections/preselected";
5
+
6
+ import { validateUntrustedScript } from "./script";
7
+
8
+ export function validateSelectionConfig(
9
+ selectionConfig: RosterLockV1Config["selection"],
10
+ config: RosterLockV1Config
11
+ ){
12
+ const { engine, rosters } = config;
13
+ for(const [pieceType, selection] of Object.entries(selectionConfig.piece)){
14
+ const pieceDefinition = engine.pieceDefinitions[pieceType];
15
+ if(!pieceDefinition){
16
+ throw new Error(`Piece type ${pieceType} is not defined in engine`);
17
+ }
18
+ switch(selection.type){
19
+ case "preselected":
20
+ validatePreselected(selection.pieces, pieceType, config);
21
+ break;
22
+ case "normal":
23
+ validateNormal(selection, pieceType, config);
24
+ break;
25
+ case "game-controlled":
26
+ break;
27
+ case "unselectable":
28
+ break;
29
+ }
30
+ }
31
+ if(selectionConfig.globalValidation){
32
+ for(const script of selectionConfig.globalValidation){
33
+ validateUntrustedScript(script, config);
34
+ }
35
+ }
36
+ }
37
+
@@ -0,0 +1,28 @@
1
+ import { UntrustedScriptRef, RosterLockV1Config } from "@roster-lock/types";
2
+
3
+ export function validateUntrustedScript(
4
+ script: UntrustedScriptRef,
5
+ config: RosterLockV1Config
6
+ ){
7
+ validateUntrustedScriptSrc(script.src, config);
8
+ validateUntrustedScriptMethod(script.method);
9
+ }
10
+
11
+ export function validateUntrustedScriptSrc(
12
+ scriptSrc: UntrustedScriptRef["src"],
13
+ { selection }: RosterLockV1Config
14
+ ){
15
+ if(!(scriptSrc in selection.scriptDictionary)){
16
+ throw new Error("Script src is not in scripts");
17
+ }
18
+ }
19
+
20
+ const VALID_IDENTIFIER = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
21
+ export function validateUntrustedScriptMethod(
22
+ method: UntrustedScriptRef["method"]
23
+ ){
24
+ if(method === undefined) return;
25
+ if(!VALID_IDENTIFIER.test(method)){
26
+ throw new Error("Script method must be a valid identifier");
27
+ }
28
+ }
@@ -0,0 +1,69 @@
1
+
2
+ import { RosterLockV1Config, SelectionNormalConfig, PieceType } from "@roster-lock/types";
3
+ import { validateUntrustedScript } from "../script";
4
+ import { validateCount } from "../../../../shared/count";
5
+
6
+ export function validateNormal(
7
+ selection: SelectionNormalConfig,
8
+ pieceType: PieceType,
9
+ config: RosterLockV1Config
10
+ ){
11
+ validateRequiredProperties(selection, pieceType, config);
12
+
13
+ if("validation" in selection && selection.validation){
14
+ validateSelection(selection.validation, pieceType, config);
15
+ }
16
+ if(selection.mergeAlgorithm){
17
+ validateUntrustedScript(selection.mergeAlgorithm, config);
18
+ }
19
+ }
20
+
21
+ function validateRequiredProperties(
22
+ selection: SelectionNormalConfig,
23
+ pieceType: PieceType,
24
+ config: RosterLockV1Config
25
+ ){
26
+ const pieceDefinition = config.engine.pieceDefinitions[pieceType];
27
+ if(pieceDefinition.selectionStrategy === "on demand"){
28
+ if("validation" in selection && selection.validation){
29
+ throw new Error(`On demand piece ${pieceType} cannot have validation`);
30
+ }
31
+ if("mergeAlgorithm" in selection && selection.mergeAlgorithm){
32
+ throw new Error(`On demand piece ${pieceType} cannot have a merge algorithm`);
33
+ }
34
+ return;
35
+ }
36
+
37
+ if(pieceDefinition.selectionStrategy === "shared"){
38
+ if(!("mergeAlgorithm" in selection && selection.mergeAlgorithm)){
39
+ throw new Error(`Shared piece ${pieceType} must have a merge algorithm`);
40
+ }
41
+ return;
42
+ }
43
+ }
44
+
45
+ type SelectionValidation = NonNullable<SelectionNormalConfig["validation"]>;
46
+
47
+ export function validateSelection(
48
+ validation: SelectionValidation,
49
+ pieceType: PieceType,
50
+ config: RosterLockV1Config
51
+ ){
52
+ validateCount(validation.count);
53
+ validateSelectionBanList(validation.banList || [], config.rosters[pieceType]);
54
+ for(const script of validation.customValidation){
55
+ validateUntrustedScript(script, config);
56
+ }
57
+ }
58
+
59
+
60
+ export function validateSelectionBanList(
61
+ banList: Array<string>,
62
+ roster: RosterLockV1Config["rosters"][string]
63
+ ){
64
+ for(const pieceId of banList){
65
+ if(!roster.find(p=>p.id === pieceId)){
66
+ throw new Error(`Ban list contains piece ${pieceId} which does not exist`);
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,18 @@
1
+
2
+ import { RosterLockV1Config, SelectionPreselectedConfig, PieceType } from "@roster-lock/types";
3
+
4
+ import { ensurePiecesAreInRoster } from "../../../../usage/validate-select/ensure-pieces-are-in-roster";
5
+
6
+ const PRESELECTABLE_STRATEGIES = ["shared", "personal"];
7
+ export function validatePreselected(
8
+ selections: SelectionPreselectedConfig["pieces"],
9
+ pieceType: PieceType,
10
+ config: RosterLockV1Config
11
+ ){
12
+ const { engine } = config;
13
+ const defintion = engine.pieceDefinitions[pieceType];
14
+ if(!PRESELECTABLE_STRATEGIES.includes(defintion.selectionStrategy)){
15
+ throw new Error(`Piece type ${pieceType} is not preselectable`);
16
+ }
17
+ ensurePiecesAreInRoster(config, pieceType, selections);
18
+ }
@@ -0,0 +1,2 @@
1
+
2
+ export const PATH_ROSTERLOCK_PIECE_INFO = "rosterlock.piece-info.json"
@@ -0,0 +1,14 @@
1
+ import { JSONSchemaCaster } from "../../../util-types/json-schema";
2
+
3
+ import { RosterLockV1PieceInfo } from "@roster-lock/types";
4
+
5
+ import { rosterLockPieceInfoKeywords } from "./keywords";
6
+
7
+ import { rosterLockPieceInfoSchema } from "./schema";
8
+
9
+ export const ROSTERLOCK_V1_PIECEINFO_CASTER_JSONSCHEMA = new JSONSchemaCaster<RosterLockV1PieceInfo>(
10
+ rosterLockPieceInfoSchema,
11
+ rosterLockPieceInfoKeywords
12
+ );
13
+
14
+ export * from "./file-paths"
@@ -0,0 +1,39 @@
1
+
2
+ import {
3
+ urlSchemaValidator,
4
+ friendlyStringSchemaValidator,
5
+ } from "../lock/rosters/caster-json-schema/human";
6
+ import {
7
+ downloadableSourceListSchemaValidator,
8
+ } from "../lock/rosters/caster-json-schema/downloadableSources";
9
+ import {
10
+ pathVariableNameSchemaValidator,
11
+ pathVariableValueSchemaValidator,
12
+ allPathVariableNameSetSchemaValidator,
13
+ } from "../lock/rosters/caster-json-schema/pathVariables";
14
+
15
+ import { defineKeyword } from "../../../util-types/json-schema";
16
+
17
+ function ignore(){ return true; }
18
+
19
+ export const rosterLockPieceInfoKeywords = [
20
+ urlSchemaValidator,
21
+ friendlyStringSchemaValidator,
22
+
23
+ downloadableSourceListSchemaValidator,
24
+ defineKeyword({
25
+ keyword: pathVariableNameSchemaValidator.keyword,
26
+ type: pathVariableNameSchemaValidator.type,
27
+ validate: ignore,
28
+ }),
29
+ defineKeyword({
30
+ keyword: pathVariableValueSchemaValidator.keyword,
31
+ type: pathVariableValueSchemaValidator.type,
32
+ validate: ignore,
33
+ }),
34
+ defineKeyword({
35
+ keyword: allPathVariableNameSetSchemaValidator.keyword,
36
+ type: allPathVariableNameSetSchemaValidator.type,
37
+ validate: ignore,
38
+ }),
39
+ ];
@@ -0,0 +1,29 @@
1
+
2
+ import { humanInfoSchema } from "../lock/rosters/caster-json-schema/human";
3
+ import {
4
+ downloadableSourcesSchema,
5
+ } from "../lock/rosters/caster-json-schema/downloadableSources";
6
+ import {
7
+ pathVariablesSchema,
8
+ } from "../lock/rosters/caster-json-schema/pathVariables";
9
+
10
+ import { JSONSchemaType } from "ajv";
11
+
12
+ import { RosterLockV1PieceInfo } from "@roster-lock/types";
13
+
14
+ import { buildIdentity } from "../shared";
15
+
16
+
17
+ export const rosterLockPieceInfoSchema: JSONSchemaType<RosterLockV1PieceInfo> = {
18
+ type: "object",
19
+ required: ["configIdentity", "humanInfo", "downloadSources", "pathVariables"],
20
+ additionalProperties: false,
21
+ properties: {
22
+ configIdentity: buildIdentity("piece-info", 1),
23
+
24
+ humanInfo: humanInfoSchema,
25
+ downloadSources: downloadableSourcesSchema,
26
+ pathVariables: pathVariablesSchema,
27
+ },
28
+ }
29
+
@@ -0,0 +1,14 @@
1
+
2
+ export function buildIdentity<P extends string, V extends number>(
3
+ purpose: P, version: V
4
+ ){
5
+ return {
6
+ type: "object" as const, required: ["namespace", "purpose", "version"] as const,
7
+ additionalProperties: false,
8
+ properties: {
9
+ namespace: { type: "string" as const, const: "roster-lock" as const },
10
+ purpose: { type: "string" as const, const: purpose },
11
+ version: { type: "number" as const, const: version },
12
+ }
13
+ };
14
+ }
@@ -0,0 +1,49 @@
1
+ import { JSONSchemaType } from "ajv";
2
+ import { SelectedPiece } from "@roster-lock/types";
3
+
4
+ /*
5
+ type SelectedPiece = {
6
+ id: string;
7
+ required: Record<string, {
8
+ mandatory: Array<SelectedPiece>;
9
+ selectable: Array<SelectedPiece>;
10
+ }>;
11
+ }
12
+ */
13
+
14
+ export const SelectedPieceSchemaDef = {
15
+ $defs: {
16
+ SelectedPiece: {
17
+ type: "object",
18
+ required: ["id", "required"],
19
+ additionalProperties: false,
20
+ properties: {
21
+ id: { type: "string" },
22
+ required: {
23
+ type: "object",
24
+ required: [],
25
+ additionalProperties: {
26
+ type: "object",
27
+ required: ["mandatory", "selectable"],
28
+ additionalProperties: false,
29
+ properties: {
30
+ mandatory: {
31
+ type: "array",
32
+ items: { $ref: "#/$defs/SelectedPiece" },
33
+ },
34
+ selectable: {
35
+ type: "array",
36
+ items: { $ref: "#/$defs/SelectedPiece" },
37
+ }
38
+ }
39
+ },
40
+ },
41
+ },
42
+ },
43
+ },
44
+ };
45
+
46
+ // AJV's JSONSchemaType doesn't support $ref-only schemas; cast is safe at runtime
47
+ export const SelectedPieceSchema = {
48
+ $ref: "#/$defs/SelectedPiece"
49
+ } as unknown as JSONSchemaType<SelectedPiece>;
@@ -0,0 +1,47 @@
1
+
2
+ import { JSONSchemaType } from "ajv";
3
+ import { Count } from "@roster-lock/types";
4
+ import { defineKeyword } from "../../../util-types/json-schema";
5
+
6
+ export const countSchemaValidator = defineKeyword({
7
+ keyword: "Count",
8
+ type: ["number", "string", "array"],
9
+ validate: validateCount
10
+ });
11
+
12
+
13
+ export const countSchema: JSONSchemaType<Count> = {
14
+ [countSchemaValidator.keyword]: true,
15
+ type: ["number", "string", "array"],
16
+ anyOf: [
17
+ { type: "number", minimum: 1 },
18
+ { type: "string", const: "*" },
19
+ {
20
+ type: "array",
21
+ items: [
22
+ { type: "number", minimum: 0 },
23
+ { anyOf: [{ type: "number", minimum: 1 }, { type: "string", const: "*" }] },
24
+ ],
25
+ minItems: 2,
26
+ maxItems: 2,
27
+ },
28
+ ],
29
+ };
30
+
31
+ export function validateCount(count: Count){
32
+ if(!Array.isArray(count)){
33
+ if(count === "*") return;
34
+ if(count <= 0) throw new Error("count should be greater than 0");
35
+ return;
36
+ }
37
+ if(count.length !== 2){
38
+ throw new Error("range should be a single value or a range of two values");
39
+ }
40
+ if(count[0] < 0){
41
+ throw new Error("range should not have a negative minimum");
42
+ }
43
+ if(count[1] === "*") return;
44
+ if(count[0] >= count[1]){
45
+ throw new Error("maximum should be greater than the minimum");
46
+ }
47
+ }
@@ -0,0 +1,9 @@
1
+
2
+ export * from "./count";
3
+ export * from "./Identity";
4
+ export * from "./SelectedPiece";
5
+
6
+ import { countSchemaValidator } from "./count";
7
+ export const sharedKeywords = [
8
+ countSchemaValidator,
9
+ ];