@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,114 @@
|
|
|
1
|
+
import Ajv, { JSONSchemaType } from "ajv";
|
|
2
|
+
import {
|
|
3
|
+
RosterLockV1Config, PieceType, JSONShallowObject, SelectionPieceMeta
|
|
4
|
+
} from "@roster-lock/types";
|
|
5
|
+
import { cloneJSON } from "@roster-lock/utils";
|
|
6
|
+
|
|
7
|
+
export function validatePieceMeta(
|
|
8
|
+
config: RosterLockV1Config
|
|
9
|
+
){
|
|
10
|
+
for(const [pieceType, meta] of Object.entries(config.pieceMeta)){
|
|
11
|
+
validatePieceMetaConfig(meta, pieceType, config);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function validatePieceMetaConfig(
|
|
16
|
+
meta: SelectionPieceMeta<any>,
|
|
17
|
+
pieceType: PieceType,
|
|
18
|
+
{ engine, rosters }: RosterLockV1Config
|
|
19
|
+
){
|
|
20
|
+
const pieceDefinition = engine.pieceDefinitions[pieceType];
|
|
21
|
+
if(!pieceDefinition){
|
|
22
|
+
throw new Error(`Piece type ${pieceType} is not defined in engine`);
|
|
23
|
+
}
|
|
24
|
+
const roster = rosters[pieceType];
|
|
25
|
+
if(!roster){
|
|
26
|
+
throw new Error(`Piece type ${pieceType} is not defined in roster`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
validateMetaDefaultValue(meta.schema, meta.defaultMeta);
|
|
30
|
+
|
|
31
|
+
for(const [pieceId, pieceValue] of Object.entries(meta.values)){
|
|
32
|
+
validateMetaForPiece(meta.schema, pieceId, pieceValue, roster);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function simpleSchemaToJSONSchemaType(schema: SelectionPieceMeta<any>["schema"]): JSONSchemaType<JSONShallowObject> {
|
|
37
|
+
const required: Array<string> = [];
|
|
38
|
+
const properties: Record<string, JSONSchemaType<(
|
|
39
|
+
| boolean | number | string
|
|
40
|
+
| Array<boolean> | Array<number> | Array<string>
|
|
41
|
+
)>> = {};
|
|
42
|
+
for(const [key, value] of Object.entries(schema)){
|
|
43
|
+
required.push(key);
|
|
44
|
+
switch(value){
|
|
45
|
+
case "boolean":
|
|
46
|
+
properties[key] = { type: "boolean" };
|
|
47
|
+
break;
|
|
48
|
+
case "number":
|
|
49
|
+
properties[key] = { type: "number" };
|
|
50
|
+
break;
|
|
51
|
+
case "string":
|
|
52
|
+
properties[key] = { type: "string" };
|
|
53
|
+
break;
|
|
54
|
+
case "boolean[]":
|
|
55
|
+
properties[key] = { type: "array", items: { type: "boolean" } };
|
|
56
|
+
break;
|
|
57
|
+
case "number[]":
|
|
58
|
+
properties[key] = { type: "array", items: { type: "number" } };
|
|
59
|
+
break;
|
|
60
|
+
case "string[]":
|
|
61
|
+
properties[key] = { type: "array", items: { type: "string" } };
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const jsonSchema: JSONSchemaType<JSONShallowObject> = {
|
|
67
|
+
type: "object",
|
|
68
|
+
required,
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
properties,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return jsonSchema;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function validateMetaDefaultValue(
|
|
77
|
+
simpleSchema: SelectionPieceMeta<any>["schema"],
|
|
78
|
+
meta: SelectionPieceMeta<any>["defaultMeta"]
|
|
79
|
+
){
|
|
80
|
+
const metaSchema = simpleSchemaToJSONSchemaType(simpleSchema);
|
|
81
|
+
const defaultMeta = Object.keys(meta);
|
|
82
|
+
if(defaultMeta.length !== metaSchema.required.length){
|
|
83
|
+
throw new Error(`Piece meta default meta must have all required keys`);
|
|
84
|
+
}
|
|
85
|
+
for(const key of metaSchema.required){
|
|
86
|
+
if(!defaultMeta.includes(key)){
|
|
87
|
+
throw new Error(`Piece meta default meta must have all required keys`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const ajv = new Ajv();
|
|
91
|
+
if(!ajv.validate(metaSchema, meta)){
|
|
92
|
+
throw new Error(`Piece meta default meta does not match schema`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function validateMetaForPiece(
|
|
97
|
+
simpleSchema: SelectionPieceMeta<any>["schema"],
|
|
98
|
+
pieceId: string,
|
|
99
|
+
meta: SelectionPieceMeta<any>["values"][string],
|
|
100
|
+
roster: RosterLockV1Config["rosters"][string]
|
|
101
|
+
){
|
|
102
|
+
const metaSchema = simpleSchemaToJSONSchemaType(simpleSchema);
|
|
103
|
+
const piece = roster.find(p=>p.id === pieceId);
|
|
104
|
+
if(!piece){
|
|
105
|
+
throw new Error(`Piece meta references piece ${pieceId} which is not in the roster`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const cloned = cloneJSON(metaSchema);
|
|
109
|
+
cloned.required = [];
|
|
110
|
+
const ajv = new Ajv();
|
|
111
|
+
if(!ajv.validate(cloned, meta)){
|
|
112
|
+
throw new Error(`Piece meta does not match schema`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { JSONSchemaType } from "ajv";
|
|
2
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
3
|
+
type RosterLockPiece = RosterLockV1Config["rosters"][string][number];
|
|
4
|
+
import { defineKeyword } from "../../../../../util-types/json-schema";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
validateDownloadableSourceList
|
|
8
|
+
} from "../validate";
|
|
9
|
+
|
|
10
|
+
export const downloadableSourceListSchemaValidator = defineKeyword({
|
|
11
|
+
keyword: "rosterDownloadableSourceList",
|
|
12
|
+
type: "array",
|
|
13
|
+
validate: validateDownloadableSourceList
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export const downloadableSourcesSchema: JSONSchemaType<RosterLockPiece["downloadSources"]> = {
|
|
18
|
+
type: "array",
|
|
19
|
+
[downloadableSourceListSchemaValidator.keyword]: true,
|
|
20
|
+
items: {
|
|
21
|
+
type: "string",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { JSONSchemaType } from "ajv"
|
|
2
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
3
|
+
type RosterLockPiece = RosterLockV1Config["rosters"][string][number];
|
|
4
|
+
import { defineKeyword } from "../../../../../util-types/json-schema";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import { validateURL } from "../validate";
|
|
8
|
+
export const urlSchemaValidator = defineKeyword({
|
|
9
|
+
keyword: "URL",
|
|
10
|
+
type: "string",
|
|
11
|
+
validate: validateURL
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
import { validateFriendlyString } from "../validate/human";
|
|
15
|
+
export const friendlyStringSchemaValidator = defineKeyword({
|
|
16
|
+
keyword: "friendlyString",
|
|
17
|
+
type: "string",
|
|
18
|
+
validate: validateFriendlyString
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export const humanInfoSchema: JSONSchemaType<RosterLockPiece["humanInfo"]> = {
|
|
23
|
+
type: "object",
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
required: ["name", "author", "url"],
|
|
26
|
+
properties: {
|
|
27
|
+
name: { type: "string", [friendlyStringSchemaValidator.keyword]: true },
|
|
28
|
+
author: { type: "string", [friendlyStringSchemaValidator.keyword]: true },
|
|
29
|
+
url: { type: "string", [urlSchemaValidator.keyword]: true },
|
|
30
|
+
image: { type: "string", [urlSchemaValidator.keyword]: true, nullable: true },
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { JSONSchemaType } from "ajv";
|
|
2
|
+
|
|
3
|
+
import { defineKeyword } from "../../../../../util-types/json-schema";
|
|
4
|
+
import { validatePieceId, validatePieceIdUniqueness } from "../validate";
|
|
5
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const idSchemaValidator = defineKeyword({
|
|
9
|
+
keyword: "rosterPieceId",
|
|
10
|
+
type: "string",
|
|
11
|
+
validate: validatePieceId
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const idUniquenessSchemaValidator = defineKeyword({
|
|
15
|
+
keyword: "rosterPieceIdUniqueness",
|
|
16
|
+
type: "string",
|
|
17
|
+
validate: function (id: string, { rosters }: RosterLockV1Config, path){
|
|
18
|
+
// config/rosters/pieceType/pieceIndex/id
|
|
19
|
+
const pathParts = path.split("/");
|
|
20
|
+
const pieceIndex = Number(pathParts.at(-2));
|
|
21
|
+
if(Number.isNaN(pieceIndex)) throw new Error(`Invalid path: pieceIndex ${pieceIndex} is not a number`);
|
|
22
|
+
const pieceType = pathParts.at(-3);
|
|
23
|
+
if(!pieceType) throw new Error("Invalid path: no pieceType");
|
|
24
|
+
const pieceList = rosters[pieceType];
|
|
25
|
+
validatePieceIdUniqueness(id, pieceIndex, pieceList);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const idSchema: JSONSchemaType<string> = {
|
|
30
|
+
type: "string",
|
|
31
|
+
[idSchemaValidator.keyword]: true,
|
|
32
|
+
[idUniquenessSchemaValidator.keyword]: true,
|
|
33
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { JSONSchemaType } from "ajv";
|
|
2
|
+
import { defineKeyword } from "../../../../../util-types/json-schema";
|
|
3
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
4
|
+
type RosterLockPiece = RosterLockV1Config["rosters"][string][number];
|
|
5
|
+
|
|
6
|
+
import { idSchema, idUniquenessSchemaValidator, idSchemaValidator } from "./id";
|
|
7
|
+
import { versionSchema, sha256SchemaValidator } from "./version";
|
|
8
|
+
import { humanInfoSchema, urlSchemaValidator, friendlyStringSchemaValidator } from "./human";
|
|
9
|
+
import {
|
|
10
|
+
downloadableSourcesSchema,
|
|
11
|
+
downloadableSourceListSchemaValidator,
|
|
12
|
+
} from "./downloadableSources";
|
|
13
|
+
import {
|
|
14
|
+
pathVariablesSchema,
|
|
15
|
+
pathVariableNameSchemaValidator,
|
|
16
|
+
pathVariableValueSchemaValidator,
|
|
17
|
+
allPathVariableNameSetSchemaValidator,
|
|
18
|
+
} from "./pathVariables";
|
|
19
|
+
import {
|
|
20
|
+
requiredPiecesSchema,
|
|
21
|
+
allRequiredPieceTypesSetSchemaValidator,
|
|
22
|
+
requiredPieceValueSchemaValidator,
|
|
23
|
+
requiredPieceTypeSchemaValidator,
|
|
24
|
+
} from "./requiresPieces";
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const pieceTypeInEngineSchemaValidator = defineKeyword({
|
|
28
|
+
keyword: "rosterPieceTypeInEngine",
|
|
29
|
+
type: "object",
|
|
30
|
+
validate: function (piece: RosterLockPiece, { engine }: RosterLockV1Config, path){
|
|
31
|
+
// config/pieces/pieceType/pieceIndex
|
|
32
|
+
const pieceType = path.split("/").at(-2);
|
|
33
|
+
if(!pieceType) throw new Error("Invalid path");
|
|
34
|
+
validatePieceInEngine(pieceType, engine);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const rosterLockPiece: JSONSchemaType<RosterLockPiece> = {
|
|
39
|
+
type: "object",
|
|
40
|
+
[pieceTypeInEngineSchemaValidator.keyword]: true,
|
|
41
|
+
required: ["id", "version", "humanInfo", "downloadSources", "pathVariables", "requiredPieces"],
|
|
42
|
+
additionalProperties: false,
|
|
43
|
+
properties: {
|
|
44
|
+
id: idSchema,
|
|
45
|
+
version: versionSchema,
|
|
46
|
+
humanInfo: humanInfoSchema,
|
|
47
|
+
downloadSources: downloadableSourcesSchema,
|
|
48
|
+
pathVariables: pathVariablesSchema,
|
|
49
|
+
requiredPieces: requiredPiecesSchema,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
import { validateAllEnginePiecesDefined, validatePieceInEngine } from "../validate";
|
|
55
|
+
const allPieceTypesInEngineSchemaValidator = defineKeyword({
|
|
56
|
+
keyword: "allEnginePieceTypesInRoster",
|
|
57
|
+
type: "object",
|
|
58
|
+
validate: function (rosters: RosterLockV1Config["rosters"], { engine }: RosterLockV1Config, path){
|
|
59
|
+
validateAllEnginePiecesDefined(rosters, engine);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const rostersSchema: JSONSchemaType<RosterLockV1Config["rosters"]> = {
|
|
64
|
+
type: "object",
|
|
65
|
+
[allPieceTypesInEngineSchemaValidator.keyword]: true,
|
|
66
|
+
required: [],
|
|
67
|
+
additionalProperties: {
|
|
68
|
+
type: "array",
|
|
69
|
+
items: rosterLockPiece,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
export const rosterKeywords = [
|
|
75
|
+
// Download Related
|
|
76
|
+
downloadableSourceListSchemaValidator,
|
|
77
|
+
|
|
78
|
+
// Human Related
|
|
79
|
+
urlSchemaValidator,
|
|
80
|
+
friendlyStringSchemaValidator,
|
|
81
|
+
|
|
82
|
+
// Id Related
|
|
83
|
+
idSchemaValidator,
|
|
84
|
+
idUniquenessSchemaValidator,
|
|
85
|
+
|
|
86
|
+
// Path Variable Related
|
|
87
|
+
pathVariableNameSchemaValidator,
|
|
88
|
+
pathVariableValueSchemaValidator,
|
|
89
|
+
allPathVariableNameSetSchemaValidator,
|
|
90
|
+
|
|
91
|
+
// Required Piece Related
|
|
92
|
+
allRequiredPieceTypesSetSchemaValidator,
|
|
93
|
+
requiredPieceValueSchemaValidator,
|
|
94
|
+
requiredPieceTypeSchemaValidator,
|
|
95
|
+
|
|
96
|
+
// Version Related
|
|
97
|
+
sha256SchemaValidator,
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
// Defined Here
|
|
101
|
+
allPieceTypesInEngineSchemaValidator,
|
|
102
|
+
pieceTypeInEngineSchemaValidator,
|
|
103
|
+
];
|
package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/pathVariables.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { JSONSchemaType } from "ajv";
|
|
2
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
3
|
+
type RosterLockPiece = RosterLockV1Config["rosters"][string][number];
|
|
4
|
+
import { defineKeyword } from "../../../../../util-types/json-schema";
|
|
5
|
+
import {
|
|
6
|
+
validatePathVariableNameIsExpected,
|
|
7
|
+
validatePathVariableValue,
|
|
8
|
+
validateAllExpectedPathVariableNamesSet,
|
|
9
|
+
} from "../validate";
|
|
10
|
+
|
|
11
|
+
export const pathVariableNameSchemaValidator = defineKeyword({
|
|
12
|
+
keyword: "rosterPathVariableName",
|
|
13
|
+
type: "string",
|
|
14
|
+
validate: function (pathVariableValue, { engine }: RosterLockV1Config, path){
|
|
15
|
+
const pathParts = path.split("/");
|
|
16
|
+
// config/pieces/pieceType/pieceIndex/pathVariables/variableName
|
|
17
|
+
const variableName = pathParts.at(-1);
|
|
18
|
+
if(!variableName)
|
|
19
|
+
throw new Error(`Invalid variable name path`);
|
|
20
|
+
const pieceType = pathParts.at(-4);
|
|
21
|
+
if(!pieceType)
|
|
22
|
+
throw new Error(`Invalid piece type path`);
|
|
23
|
+
|
|
24
|
+
const pieceDefinition = engine.pieceDefinitions[pieceType];
|
|
25
|
+
validatePathVariableNameIsExpected(variableName, pieceDefinition);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const pathVariableValueSchemaValidator = defineKeyword({
|
|
30
|
+
keyword: "rosterPathVariableValue",
|
|
31
|
+
type: "string",
|
|
32
|
+
validate: function (pathVariableValue, { engine }: RosterLockV1Config, path){
|
|
33
|
+
validatePathVariableValue(pathVariableValue);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const allPathVariableNameSetSchemaValidator = defineKeyword({
|
|
38
|
+
keyword: "rosterAllPathVariableNameSet",
|
|
39
|
+
type: "object",
|
|
40
|
+
validate: function (pathVariables, { engine }: RosterLockV1Config, path){
|
|
41
|
+
// config/pieces/pieceType/pieceIndex/pathVariables
|
|
42
|
+
const pieceType = path.split("/").at(-3);
|
|
43
|
+
if(!pieceType)
|
|
44
|
+
throw new Error(`Invalid piece type path`);
|
|
45
|
+
const pieceDefinition = engine.pieceDefinitions[pieceType];
|
|
46
|
+
validateAllExpectedPathVariableNamesSet(pathVariables, pieceDefinition);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const pathVariablesSchema: JSONSchemaType<RosterLockPiece["pathVariables"]> = {
|
|
51
|
+
type: "object",
|
|
52
|
+
[allPathVariableNameSetSchemaValidator.keyword]: true,
|
|
53
|
+
required: [],
|
|
54
|
+
additionalProperties: {
|
|
55
|
+
type: "string",
|
|
56
|
+
[pathVariableNameSchemaValidator.keyword]: true,
|
|
57
|
+
[pathVariableValueSchemaValidator.keyword]: true,
|
|
58
|
+
},
|
|
59
|
+
}
|
package/src/match-lock-file/match-config/version-1/lock/rosters/caster-json-schema/requiresPieces.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { JSONSchemaType } from "ajv";
|
|
2
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
3
|
+
type RosterLockPiece = RosterLockV1Config["rosters"][string][number];
|
|
4
|
+
import { defineKeyword } from "../../../../../util-types/json-schema";
|
|
5
|
+
import {
|
|
6
|
+
validateAllExpectedRequiredPieceTypesSet,
|
|
7
|
+
validateRequiredPieceType,
|
|
8
|
+
validateRequiredPieceValue
|
|
9
|
+
} from "../validate";
|
|
10
|
+
|
|
11
|
+
export const allRequiredPieceTypesSetSchemaValidator = defineKeyword({
|
|
12
|
+
keyword: "rosterAllRequiredPieceTypesSet",
|
|
13
|
+
type: "object",
|
|
14
|
+
// config/pieces/pieceType/pieceIndex/requiredPieces
|
|
15
|
+
validate: function (requiredPieces, { engine }: RosterLockV1Config, path){
|
|
16
|
+
const pieceType = path.split("/").at(-3);
|
|
17
|
+
if(!pieceType) throw new Error("Invalid path");
|
|
18
|
+
const pieceDefinition = engine.pieceDefinitions[pieceType];
|
|
19
|
+
validateAllExpectedRequiredPieceTypesSet(requiredPieces, pieceDefinition);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const requiredPieceValueSchemaValidator = defineKeyword({
|
|
24
|
+
keyword: "rosterRequiredPieceValue",
|
|
25
|
+
type: "string",
|
|
26
|
+
// rosters/pieceType/pieceIndex/requiredPieces/requiredPieceType/expected/index
|
|
27
|
+
validate: function (requiredPiece: string, { rosters }: RosterLockV1Config, path){
|
|
28
|
+
const pathParts = path.split("/");
|
|
29
|
+
pathParts.pop();
|
|
30
|
+
const pieceType = pathParts.at(-2);
|
|
31
|
+
if(!pieceType) throw new Error("Invalid path");
|
|
32
|
+
const pieceValues = rosters[pieceType];
|
|
33
|
+
validateRequiredPieceValue(pieceType, requiredPiece, pieceValues);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const requiredPieceTypeSchemaValidator = defineKeyword({
|
|
38
|
+
keyword: "rosterRequiredPieceType",
|
|
39
|
+
type: "object",
|
|
40
|
+
// config/pieces/pieceType/pieceIndex/requiredPieces/pieceType
|
|
41
|
+
validate: function (requiredPiece: string, config: RosterLockV1Config, path){
|
|
42
|
+
const pathParts = path.split("/");
|
|
43
|
+
const pieceType = pathParts.at(-1);
|
|
44
|
+
if(!pieceType) throw new Error("Invalid path");
|
|
45
|
+
|
|
46
|
+
validateRequiredPieceType(pieceType, config);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
export const requiredPiecesSchema: JSONSchemaType<RosterLockPiece["requiredPieces"]> = {
|
|
52
|
+
type: "object",
|
|
53
|
+
[allRequiredPieceTypesSetSchemaValidator.keyword]: true,
|
|
54
|
+
required: [],
|
|
55
|
+
additionalProperties: {
|
|
56
|
+
type: "object",
|
|
57
|
+
[requiredPieceTypeSchemaValidator.keyword]: true,
|
|
58
|
+
required: ["expected", "selectable"],
|
|
59
|
+
additionalProperties: false,
|
|
60
|
+
properties: {
|
|
61
|
+
expected: {
|
|
62
|
+
type: "array",
|
|
63
|
+
items: {
|
|
64
|
+
type: "string",
|
|
65
|
+
[requiredPieceValueSchemaValidator.keyword]: true,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
selectable: { type: "boolean" },
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { JSONSchemaType } from "ajv";
|
|
2
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
3
|
+
type RosterLockPiece = RosterLockV1Config["rosters"][string][number];
|
|
4
|
+
import { defineKeyword } from "../../../../../util-types/json-schema";
|
|
5
|
+
|
|
6
|
+
import { validateSha256 } from "../validate";
|
|
7
|
+
export const sha256SchemaValidator = defineKeyword({
|
|
8
|
+
keyword: "sha256",
|
|
9
|
+
type: "string",
|
|
10
|
+
validate: validateSha256
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const versionSchema: JSONSchemaType<RosterLockPiece["version"]> = {
|
|
14
|
+
type: "object",
|
|
15
|
+
additionalProperties: false,
|
|
16
|
+
required: ["logic", "media", "docs"],
|
|
17
|
+
properties: {
|
|
18
|
+
logic: { type: "string", [sha256SchemaValidator.keyword]: true },
|
|
19
|
+
media: { type: "string", [sha256SchemaValidator.keyword]: true },
|
|
20
|
+
docs: { type: "string", [sha256SchemaValidator.keyword]: true },
|
|
21
|
+
},
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
2
|
+
import { validateURL } from "./utils";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function validateHumanInfo(
|
|
6
|
+
humanInfo: RosterLockV1Config["rosters"][string][0]["humanInfo"]
|
|
7
|
+
){
|
|
8
|
+
validateFriendlyString(humanInfo.name);
|
|
9
|
+
validateFriendlyString(humanInfo.author);
|
|
10
|
+
validateURL(humanInfo.url);
|
|
11
|
+
if(humanInfo.image) validateURL(humanInfo.image);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function validateFriendlyString(value: string){
|
|
15
|
+
if(!value.trim()) throw new Error("String is required");
|
|
16
|
+
if(value.length > 100) throw new Error("String is too long");
|
|
17
|
+
if(value.length < 3) throw new Error("String is too short");
|
|
18
|
+
|
|
19
|
+
if(value.includes('\0')) throw new Error("ID contains null character");
|
|
20
|
+
if(/[\x00-\x1F\x7F-\x9F]/.test(value)) throw new Error("ID contains control character");
|
|
21
|
+
if (/[\r\n\t\v\f]/.test(value)) throw new Error("ID contains whitespace character");
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
2
|
+
|
|
3
|
+
export function validatePieceId(id: string){
|
|
4
|
+
if(id.length === 0) throw new Error("ID is empty");
|
|
5
|
+
if(id.length > 128) throw new Error("ID is too long");
|
|
6
|
+
if(id !== id.trim()) throw new Error("ID contains a trailing or leading space");
|
|
7
|
+
|
|
8
|
+
if(id.includes('\0')) throw new Error("ID contains null character");
|
|
9
|
+
if(/[\x00-\x1F\x7F-\x9F]/.test(id)) throw new Error("ID contains control character");
|
|
10
|
+
if (/[\r\n\t\v\f]/.test(id)) throw new Error("ID contains whitespace character");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function validatePieceIdUniqueness(
|
|
14
|
+
id: string, index: number, rosters: RosterLockV1Config["rosters"][string]
|
|
15
|
+
){
|
|
16
|
+
for(let i = 0; i < rosters.length; i++){
|
|
17
|
+
if(i === index) continue;
|
|
18
|
+
if(rosters[i].id === id) throw new Error(`Duplicate ID ${id}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
2
|
+
|
|
3
|
+
export * from "./id";
|
|
4
|
+
export * from "./downloadable-source";
|
|
5
|
+
export * from "./human";
|
|
6
|
+
export * from "./path-variables";
|
|
7
|
+
export * from "./required-pieces";
|
|
8
|
+
export * from "./utils";
|
|
9
|
+
export * from "./version";
|
|
10
|
+
|
|
11
|
+
import { validateVersions, validateVersionUniqueness } from "./version";
|
|
12
|
+
import { validateHumanInfo } from "./human";
|
|
13
|
+
import {
|
|
14
|
+
validateDownloadableSourceList,
|
|
15
|
+
} from "./downloadable-source";
|
|
16
|
+
import {
|
|
17
|
+
validateAllExpectedPathVariableNamesSet,
|
|
18
|
+
validatePathVariableNameIsExpected,
|
|
19
|
+
validatePathVariableValue,
|
|
20
|
+
} from "./path-variables";
|
|
21
|
+
import {
|
|
22
|
+
validateAllExpectedRequiredPieceTypesSet,
|
|
23
|
+
validateRequiredPieceType,
|
|
24
|
+
validateRequiredPieceValue,
|
|
25
|
+
} from "./required-pieces";
|
|
26
|
+
import { validatePieceId, validatePieceIdUniqueness } from "./id";
|
|
27
|
+
export function validateRosterLockPieces(
|
|
28
|
+
config: RosterLockV1Config
|
|
29
|
+
){
|
|
30
|
+
const { engine, rosters } = config;
|
|
31
|
+
validateAllEnginePiecesDefined(rosters, engine);
|
|
32
|
+
for(const [pieceType, pieceList] of Object.entries(rosters)){
|
|
33
|
+
for(let i = 0; i < pieceList.length; i++){
|
|
34
|
+
const piece = pieceList[i];
|
|
35
|
+
validatePieceInEngine(pieceType, engine);
|
|
36
|
+
const pieceConfig = engine.pieceDefinitions[pieceType];
|
|
37
|
+
|
|
38
|
+
validatePieceId(piece.id);
|
|
39
|
+
validatePieceIdUniqueness(piece.id, i, pieceList);
|
|
40
|
+
|
|
41
|
+
validateVersions(piece.version);
|
|
42
|
+
validateVersionUniqueness(piece.version, i, pieceList);
|
|
43
|
+
|
|
44
|
+
validateHumanInfo(piece.humanInfo);
|
|
45
|
+
// Download Sources
|
|
46
|
+
validateDownloadableSourceList(piece.downloadSources);
|
|
47
|
+
|
|
48
|
+
// Path Variables
|
|
49
|
+
validateAllExpectedPathVariableNamesSet(piece.pathVariables, pieceConfig);
|
|
50
|
+
for(const [variableName, variableValue] of Object.entries(piece.pathVariables)){
|
|
51
|
+
validatePathVariableNameIsExpected(variableName, pieceConfig);
|
|
52
|
+
validatePathVariableValue(variableValue);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Required Pieces
|
|
56
|
+
validateAllExpectedRequiredPieceTypesSet(piece.requiredPieces, pieceConfig);
|
|
57
|
+
for(const [requiredPieceType, requiredPiece] of Object.entries(piece.requiredPieces)){
|
|
58
|
+
validateRequiredPieceType(requiredPieceType, config);
|
|
59
|
+
for(const pieceSha of requiredPiece.expected){
|
|
60
|
+
validateRequiredPieceValue(requiredPieceType, pieceSha, rosters[requiredPieceType]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function validateAllEnginePiecesDefined(
|
|
68
|
+
rosters: RosterLockV1Config["rosters"], engine: RosterLockV1Config["engine"]
|
|
69
|
+
){
|
|
70
|
+
for(const pieceType of Object.keys(engine.pieceDefinitions)){
|
|
71
|
+
if(!(pieceType in rosters)){
|
|
72
|
+
throw new Error(`Piece type ${pieceType} is defined in engine but not in roster`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function validatePieceInEngine(
|
|
78
|
+
pieceType: string, engine: RosterLockV1Config["engine"]
|
|
79
|
+
){
|
|
80
|
+
if(!(pieceType in engine.pieceDefinitions)){
|
|
81
|
+
throw new Error(`Piece type ${pieceType} is not defined in engine`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
2
|
+
import { PATH_VARIABLE_VALUE_VALIDATION } from "../../engine/validate/piece/assets/glob/pathvariables";
|
|
3
|
+
type RosterLockPiece = RosterLockV1Config["rosters"][string][number];
|
|
4
|
+
|
|
5
|
+
export function validateAllExpectedPathVariableNamesSet(
|
|
6
|
+
pathVariableValues: RosterLockPiece["pathVariables"],
|
|
7
|
+
pieceConfig: RosterLockV1Config["engine"]["pieceDefinitions"][string],
|
|
8
|
+
){
|
|
9
|
+
for(const variableName of pieceConfig.pathVariables){
|
|
10
|
+
if(!(variableName in pathVariableValues)){
|
|
11
|
+
throw new Error(`Piece is missing value for path variable ${variableName}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function validatePathVariableNameIsExpected(
|
|
17
|
+
variableName: string,
|
|
18
|
+
pieceConfig: RosterLockV1Config["engine"]["pieceDefinitions"][string],
|
|
19
|
+
){
|
|
20
|
+
if(!pieceConfig.pathVariables.includes(variableName)){
|
|
21
|
+
throw new Error(`Piece does not have path variable ${variableName}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function validatePathVariableValue(
|
|
26
|
+
variableValue: string,
|
|
27
|
+
){
|
|
28
|
+
if (variableValue.length < PATH_VARIABLE_VALUE_VALIDATION.minLength) {
|
|
29
|
+
throw new Error(`Path variable value is too short`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (variableValue.length > PATH_VARIABLE_VALUE_VALIDATION.maxLength) {
|
|
33
|
+
throw new Error(`Path variable value is too long`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const charsetRegex = new RegExp(`^[${PATH_VARIABLE_VALUE_VALIDATION.charset}]+$`);
|
|
37
|
+
if (!charsetRegex.test(variableValue)) {
|
|
38
|
+
throw new Error(`Path variable value contains invalid characters`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RosterLockV1Config } from "@roster-lock/types";
|
|
2
|
+
|
|
3
|
+
export function validateAllExpectedRequiredPieceTypesSet(
|
|
4
|
+
requiredPieces: RosterLockV1Config["rosters"][string][0]["requiredPieces"],
|
|
5
|
+
pieceConfig: RosterLockV1Config["engine"]["pieceDefinitions"][string],
|
|
6
|
+
){
|
|
7
|
+
for(const requiredPieceType of pieceConfig.requires){
|
|
8
|
+
if(!(requiredPieceType in requiredPieces)){
|
|
9
|
+
throw new Error(`Piece is missing required piece type ${requiredPieceType}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function validateRequiredPieceType(
|
|
15
|
+
pieceType: string, { engine, rosters }: RosterLockV1Config
|
|
16
|
+
){
|
|
17
|
+
const pieceDefinition = engine.pieceDefinitions[pieceType];
|
|
18
|
+
if(!pieceDefinition)
|
|
19
|
+
throw new Error(`Piece type ${pieceType} is not defined in engine`);
|
|
20
|
+
if(!(pieceType in rosters))
|
|
21
|
+
throw new Error(`Piece type ${pieceType} is not defined in roster`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function validateRequiredPieceValue(
|
|
25
|
+
pieceType: string, pieceId: string, roster: RosterLockV1Config["rosters"][string]
|
|
26
|
+
){
|
|
27
|
+
if(!roster.find((p) => p.id === pieceId)){
|
|
28
|
+
throw new Error(`Piece type ${pieceType} does not have the required piece with id ${pieceId}`);
|
|
29
|
+
}
|
|
30
|
+
}
|