@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.
- package/LICENSE.md +11 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/match-lock-file/config-types.js +3 -0
- package/dist/match-lock-file/config-types.js.map +1 -0
- package/dist/match-lock-file/index.js +19 -0
- package/dist/match-lock-file/index.js.map +1 -0
- package/dist/match-lock-file/match-config/index.js +18 -0
- package/dist/match-lock-file/match-config/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/draft/index.js +44 -0
- package/dist/match-lock-file/match-config/version-1/draft/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/draft/roster-piece-info.js +32 -0
- package/dist/match-lock-file/match-config/version-1/draft/roster-piece-info.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/draft/selection-script-info.js +13 -0
- package/dist/match-lock-file/match-config/version-1/draft/selection-script-info.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/index.js +22 -0
- package/dist/match-lock-file/match-config/version-1/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/index.js +37 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/keywords.js +43 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/keywords.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/index.js +7 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/officialSelections.js +41 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/officialSelections.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/index.js +20 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/keywords.js +31 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/keywords.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/schema.js +40 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/schema.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/index.js +17 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/keywords.js +16 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/keywords.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/index.js +19 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/error.js +25 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/error.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/index.js +33 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath-component.js +31 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath-component.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath.js +37 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/index.js +22 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/pathvariables.js +24 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/pathvariables.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/index.js +39 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/index.js +46 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/path-variables.js +23 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/path-variables.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/requirements.js +99 -0
- package/dist/match-lock-file/match-config/version-1/lock/engine/validate/piece/requirements.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/index.js +56 -0
- package/dist/match-lock-file/match-config/version-1/lock/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/piece-meta/caster-json-schema/index.js +87 -0
- package/dist/match-lock-file/match-config/version-1/lock/piece-meta/caster-json-schema/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/piece-meta/index.js +19 -0
- package/dist/match-lock-file/match-config/version-1/lock/piece-meta/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/piece-meta/validate/index.js +94 -0
- package/dist/match-lock-file/match-config/version-1/lock/piece-meta/validate/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/downloadableSources.js +18 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/downloadableSources.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/human.js +28 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/human.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/id.js +31 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/id.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/index.js +68 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/pathVariables.js +49 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/pathVariables.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/requiresPieces.js +62 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/requiresPieces.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/version.js +21 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/version.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/index.js +19 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/downloadable-source.js +10 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/downloadable-source.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/human.js +27 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/human.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/id.js +27 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/id.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/index.js +74 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/path-variables.js +31 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/path-variables.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/required-pieces.js +25 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/required-pieces.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/utils.js +23 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/utils.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/version.js +19 -0
- package/dist/match-lock-file/match-config/version-1/lock/rosters/validate/version.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/index.js +42 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/script.js +46 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/script.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/game-controlled.js +12 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/game-controlled.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/normal.js +49 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/normal.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/preselected.js +32 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/preselected.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/unselectable.js +12 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/unselectable.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/index.js +19 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/validate/index.js +33 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/validate/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/validate/script.js +23 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/validate/script.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/validate/selections/normal.js +49 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/validate/selections/normal.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/validate/selections/preselected.js +14 -0
- package/dist/match-lock-file/match-config/version-1/lock/selection/validate/selections/preselected.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/piece-info/file-paths.js +5 -0
- package/dist/match-lock-file/match-config/version-1/piece-info/file-paths.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/piece-info/index.js +23 -0
- package/dist/match-lock-file/match-config/version-1/piece-info/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/piece-info/keywords.js +29 -0
- package/dist/match-lock-file/match-config/version-1/piece-info/keywords.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/piece-info/schema.js +19 -0
- package/dist/match-lock-file/match-config/version-1/piece-info/schema.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/shared/Identity.js +15 -0
- package/dist/match-lock-file/match-config/version-1/shared/Identity.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/shared/SelectedPiece.js +38 -0
- package/dist/match-lock-file/match-config/version-1/shared/SelectedPiece.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/shared/count.js +48 -0
- package/dist/match-lock-file/match-config/version-1/shared/count.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/shared/index.js +25 -0
- package/dist/match-lock-file/match-config/version-1/shared/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/calculatePieceVersion.js +70 -0
- package/dist/match-lock-file/match-config/version-1/usage/calculatePieceVersion.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/empty-configs.js +49 -0
- package/dist/match-lock-file/match-config/version-1/usage/empty-configs.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/constants.js +8 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/constants.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/getAssetsOfFiles.js +75 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/getAssetsOfFiles.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/getMatchingAsset.js +28 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/getMatchingAsset.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/index.js +20 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/types.js +3 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/types.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/validateAssetFileCount.js +33 -0
- package/dist/match-lock-file/match-config/version-1/usage/files-and-assets/validateAssetFileCount.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/index.js +22 -0
- package/dist/match-lock-file/match-config/version-1/usage/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/publish/SemVer.js +63 -0
- package/dist/match-lock-file/match-config/version-1/usage/publish/SemVer.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/publish/diffLocks.js +51 -0
- package/dist/match-lock-file/match-config/version-1/usage/publish/diffLocks.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/publish/index.js +19 -0
- package/dist/match-lock-file/match-config/version-1/usage/publish/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/constants.js +14 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/constants.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/ensure-pieces-are-in-roster.js +53 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/ensure-pieces-are-in-roster.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/handle-validation.js +49 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/handle-validation.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/index.js +68 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/game-controlled.js +38 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/game-controlled.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/cast-result.js +40 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/cast-result.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/index.js +78 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/index.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/validate-user-selection.js +43 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/validate-user-selection.js.map +1 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/preselected.js +26 -0
- package/dist/match-lock-file/match-config/version-1/usage/validate-select/selection-types/preselected.js.map +1 -0
- package/dist/match-lock-file/util-types/json-schema/JSONSchemaCaster.js +45 -0
- package/dist/match-lock-file/util-types/json-schema/JSONSchemaCaster.js.map +1 -0
- package/dist/match-lock-file/util-types/json-schema/defineKeyword.js +30 -0
- package/dist/match-lock-file/util-types/json-schema/defineKeyword.js.map +1 -0
- package/dist/match-lock-file/util-types/json-schema/index.js +21 -0
- package/dist/match-lock-file/util-types/json-schema/index.js.map +1 -0
- package/dist/match-lock-file/util-types/json-schema/safe-keyword.js +3 -0
- package/dist/match-lock-file/util-types/json-schema/safe-keyword.js.map +1 -0
- package/dist/match-lock-file/util-types/json-schema/schema-types.js +3 -0
- package/dist/match-lock-file/util-types/json-schema/schema-types.js.map +1 -0
- package/package.json +49 -0
- package/src/index.ts +3 -0
- package/src/match-lock-file/config-types.ts +10 -0
- package/src/match-lock-file/index.ts +4 -0
- package/src/match-lock-file/match-config/index.ts +2 -0
- package/src/match-lock-file/match-config/version-0/pieces/caster-runtypes/index.ts +99 -0
- package/src/match-lock-file/match-config/version-0/pieces/caster-runtypes/util-casters.ts +155 -0
- package/src/match-lock-file/match-config/version-0/pieces/index.ts +3 -0
- package/src/match-lock-file/match-config/version-0/pieces/types.ts +49 -0
- package/src/match-lock-file/match-config/version-0/pieces/validate/definition/assetCount.ts +33 -0
- package/src/match-lock-file/match-config/version-0/pieces/validate/definition/assetType.ts +22 -0
- package/src/match-lock-file/match-config/version-0/pieces/validate/definition/index.ts +30 -0
- package/src/match-lock-file/match-config/version-0/pieces/validate/definition/pathVariables.ts +39 -0
- package/src/match-lock-file/match-config/version-0/pieces/validate/index.ts +4 -0
- package/src/match-lock-file/match-config/version-0/pieces/validate/sha.ts +23 -0
- package/src/match-lock-file/match-config/version-0/pieces/validate/version.ts +66 -0
- package/src/match-lock-file/match-config/version-0/restriction/casters.ts +52 -0
- package/src/match-lock-file/match-config/version-0/restriction/index.ts +4 -0
- package/src/match-lock-file/match-config/version-0/restriction/types.ts +42 -0
- package/src/match-lock-file/match-config/version-0/restriction/validate/index.ts +15 -0
- package/src/match-lock-file/match-config/version-0/restriction/validate/piece/index.ts +46 -0
- package/src/match-lock-file/match-config/version-0/restriction/validate/sha.ts +19 -0
- package/src/match-lock-file/match-config/version-0/selection/casters.ts +105 -0
- package/src/match-lock-file/match-config/version-0/selection/validate/count.ts +16 -0
- package/src/match-lock-file/match-config/version-0/selection/validate/index.ts +40 -0
- package/src/match-lock-file/match-config/version-0/selection/validate/scriptMeta.ts +26 -0
- package/src/match-lock-file/match-config/version-1/draft/index.ts +52 -0
- package/src/match-lock-file/match-config/version-1/draft/roster-piece-info.ts +33 -0
- package/src/match-lock-file/match-config/version-1/draft/selection-script-info.ts +16 -0
- package/src/match-lock-file/match-config/version-1/index.ts +7 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/index.ts +46 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/asset/keywords.ts +48 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/index.ts +6 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/officialSelections.ts +42 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/index.ts +26 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/requirements/keywords.ts +34 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/schema.ts +47 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/index.ts +22 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/caster-json-schema/variables/keywords.ts +14 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/index.ts +3 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/constants.ts +7 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/error.ts +21 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/index.ts +18 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath-component.ts +41 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/filepath.ts +55 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/index.ts +21 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/glob/pathvariables.ts +28 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/assets/index.ts +46 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/index.ts +37 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/path-variables.ts +21 -0
- package/src/match-lock-file/match-config/version-1/lock/engine/validate/piece/requirements.ts +117 -0
- package/src/match-lock-file/match-config/version-1/lock/index.ts +51 -0
- package/src/match-lock-file/match-config/version-1/lock/piece-meta/caster-json-schema/index.ts +97 -0
- package/src/match-lock-file/match-config/version-1/lock/piece-meta/index.ts +3 -0
- package/src/match-lock-file/match-config/version-1/lock/piece-meta/validate/index.ts +114 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/downloadableSources.ts +25 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/human.ts +33 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/id.ts +33 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/index.ts +103 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/pathVariables.ts +59 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/requiresPieces.ts +71 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/version.ts +22 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/index.ts +3 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/validate/downloadable-source.ts +9 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/validate/human.ts +22 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/validate/id.ts +20 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/validate/index.ts +83 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/validate/path-variables.ts +40 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/validate/required-pieces.ts +30 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/validate/utils.ts +17 -0
- package/src/match-lock-file/match-config/version-1/lock/rosters/validate/version.ts +22 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/index.ts +53 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/script.ts +54 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/game-controlled.ts +11 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/normal.ts +58 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/preselected.ts +37 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/selection-types/unselectable.ts +11 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/index.ts +3 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/validate/index.ts +37 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/validate/script.ts +28 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/validate/selections/normal.ts +69 -0
- package/src/match-lock-file/match-config/version-1/lock/selection/validate/selections/preselected.ts +18 -0
- package/src/match-lock-file/match-config/version-1/piece-info/file-paths.ts +2 -0
- package/src/match-lock-file/match-config/version-1/piece-info/index.ts +14 -0
- package/src/match-lock-file/match-config/version-1/piece-info/keywords.ts +39 -0
- package/src/match-lock-file/match-config/version-1/piece-info/schema.ts +29 -0
- package/src/match-lock-file/match-config/version-1/shared/Identity.ts +14 -0
- package/src/match-lock-file/match-config/version-1/shared/SelectedPiece.ts +49 -0
- package/src/match-lock-file/match-config/version-1/shared/count.ts +47 -0
- package/src/match-lock-file/match-config/version-1/shared/index.ts +9 -0
- package/src/match-lock-file/match-config/version-1/usage/calculatePieceVersion.ts +85 -0
- package/src/match-lock-file/match-config/version-1/usage/empty-configs.ts +61 -0
- package/src/match-lock-file/match-config/version-1/usage/files-and-assets/constants.ts +6 -0
- package/src/match-lock-file/match-config/version-1/usage/files-and-assets/getAssetsOfFiles.ts +88 -0
- package/src/match-lock-file/match-config/version-1/usage/files-and-assets/getMatchingAsset.ts +42 -0
- package/src/match-lock-file/match-config/version-1/usage/files-and-assets/index.ts +4 -0
- package/src/match-lock-file/match-config/version-1/usage/files-and-assets/types.ts +5 -0
- package/src/match-lock-file/match-config/version-1/usage/files-and-assets/validateAssetFileCount.ts +34 -0
- package/src/match-lock-file/match-config/version-1/usage/index.ts +6 -0
- package/src/match-lock-file/match-config/version-1/usage/publish/SemVer.ts +67 -0
- package/src/match-lock-file/match-config/version-1/usage/publish/diffLocks.ts +66 -0
- package/src/match-lock-file/match-config/version-1/usage/publish/index.ts +2 -0
- package/src/match-lock-file/match-config/version-1/usage/validate-select/constants.ts +9 -0
- package/src/match-lock-file/match-config/version-1/usage/validate-select/ensure-pieces-are-in-roster.ts +61 -0
- package/src/match-lock-file/match-config/version-1/usage/validate-select/handle-validation.ts +54 -0
- package/src/match-lock-file/match-config/version-1/usage/validate-select/index.ts +98 -0
- package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/game-controlled.ts +49 -0
- package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/cast-result.ts +39 -0
- package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/include-mandatory-require.ts +44 -0
- package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/index.ts +101 -0
- package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/normal/validate-user-selection.ts +51 -0
- package/src/match-lock-file/match-config/version-1/usage/validate-select/selection-types/preselected.ts +36 -0
- package/src/match-lock-file/util-types/json-schema/JSONSchemaCaster.ts +52 -0
- package/src/match-lock-file/util-types/json-schema/checkVersion.ts +9 -0
- package/src/match-lock-file/util-types/json-schema/defineKeyword.ts +50 -0
- package/src/match-lock-file/util-types/json-schema/index.ts +4 -0
- package/src/match-lock-file/util-types/json-schema/safe-keyword.ts +27 -0
- package/src/match-lock-file/util-types/json-schema/schema-types.ts +5 -0
- package/tests/engine/assets.spec.ts +147 -0
- package/tests/engine/official-selections.spec.ts +67 -0
- package/tests/engine/requirements.spec.ts +43 -0
- package/tests/piece-info/cast.spec.ts +20 -0
- package/tests/piece-info/rosterlock.piece-info.json +15 -0
- package/tests/piece-meta/cast.spec.ts +60 -0
- package/tests/rosters/path-variables.spec.ts +52 -0
- package/tests/selection/cast-result.spec.ts +72 -0
- 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
|
+
];
|
package/src/match-lock-file/match-config/version-1/lock/selection/caster-json-schema/script.ts
ADDED
|
@@ -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,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
|
+
}
|
package/src/match-lock-file/match-config/version-1/lock/selection/validate/selections/normal.ts
ADDED
|
@@ -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
|
+
}
|
package/src/match-lock-file/match-config/version-1/lock/selection/validate/selections/preselected.ts
ADDED
|
@@ -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,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
|
+
}
|