@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
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@roster-lock/shared",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared utilities, variables, etc between client and server",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"roster-lock",
|
|
7
|
+
"game"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/formula1/roster-lock#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/formula1/roster-lock/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/formula1/roster-lock.git",
|
|
16
|
+
"directory": "core/shared"
|
|
17
|
+
},
|
|
18
|
+
"license": "JSON",
|
|
19
|
+
"author": "Sam Tobia",
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"types": "src/index.ts",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/is-glob": "^4.0.4",
|
|
27
|
+
"@types/magnet-uri": "^5.1.5",
|
|
28
|
+
"@types/micromatch": "^4.0.9",
|
|
29
|
+
"@types/node": "^22.14.1",
|
|
30
|
+
"rimraf": "^6.0.1",
|
|
31
|
+
"typescript": "^7.0.2",
|
|
32
|
+
"vitest": "^4.1.5"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"ajv": "^8.17.1",
|
|
36
|
+
"cids": "^1.1.9",
|
|
37
|
+
"is-glob": "^4.0.3",
|
|
38
|
+
"json-diff-ts": "^4.8.2",
|
|
39
|
+
"magnet-uri": "^7.0.7",
|
|
40
|
+
"micromatch": "^4.0.8",
|
|
41
|
+
"runtypes": "^7.0.4",
|
|
42
|
+
"@roster-lock/types": "1.0.0",
|
|
43
|
+
"@roster-lock/utils": "1.0.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"test": "vitest run tests/",
|
|
47
|
+
"build": "rimraf ./dist && tsc"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DateTimeCaster,
|
|
3
|
+
SemVerCaster,
|
|
4
|
+
Sha256Caster,
|
|
5
|
+
URLTypeCaster,
|
|
6
|
+
MagnetURICaster,
|
|
7
|
+
CountCaster,
|
|
8
|
+
} from "./util-casters";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
Record as CastRecord,
|
|
12
|
+
Object as CastObject,
|
|
13
|
+
Array as CastArray,
|
|
14
|
+
Tuple as CastTuple,
|
|
15
|
+
Literal,
|
|
16
|
+
Union as CastUnion,
|
|
17
|
+
String as CastString,
|
|
18
|
+
} from "runtypes"
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
MatchLockResolvable,
|
|
22
|
+
MatchLockAsset,
|
|
23
|
+
MatchLockPublishPiece,
|
|
24
|
+
MatchLockScanPiece,
|
|
25
|
+
} from "../types";
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const OwnableIdentificationCaster = {
|
|
29
|
+
name: CastString,
|
|
30
|
+
author: CastString,
|
|
31
|
+
published: DateTimeCaster,
|
|
32
|
+
preview: CastObject({
|
|
33
|
+
image: URLTypeCaster,
|
|
34
|
+
url: URLTypeCaster,
|
|
35
|
+
}),
|
|
36
|
+
sha256: Sha256Caster,
|
|
37
|
+
signature: CastString,
|
|
38
|
+
signatureVerificationUrl: URLTypeCaster,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const ResolvableCaster = CastUnion(
|
|
42
|
+
CastObject({
|
|
43
|
+
type: Literal("http"),
|
|
44
|
+
url: URLTypeCaster,
|
|
45
|
+
}),
|
|
46
|
+
CastObject({
|
|
47
|
+
type: Literal("torrent"),
|
|
48
|
+
uri: MagnetURICaster,
|
|
49
|
+
}),
|
|
50
|
+
CastObject({
|
|
51
|
+
type: Literal("git"),
|
|
52
|
+
url: URLTypeCaster,
|
|
53
|
+
ref: CastString.optional(),
|
|
54
|
+
}),
|
|
55
|
+
).conform<MatchLockResolvable>();
|
|
56
|
+
|
|
57
|
+
import { validatePathVariableName } from "../../../version-1/engine";
|
|
58
|
+
import { validatePathVariableValue } from "../validate/definition/pathVariables";
|
|
59
|
+
const AssetScanCaster = {
|
|
60
|
+
pieceDefinition: CastString,
|
|
61
|
+
version: CastObject({
|
|
62
|
+
logic: Sha256Caster,
|
|
63
|
+
media: Sha256Caster,
|
|
64
|
+
}),
|
|
65
|
+
pathVariables: CastRecord(
|
|
66
|
+
CastString.withConstraint((variableName)=>{
|
|
67
|
+
try {
|
|
68
|
+
validatePathVariableName(variableName);
|
|
69
|
+
return true;
|
|
70
|
+
}catch(e){
|
|
71
|
+
return (e as Error).message;
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
CastString.withConstraint((variableValue)=>{
|
|
75
|
+
try {
|
|
76
|
+
validatePathVariableValue(variableValue);
|
|
77
|
+
return true;
|
|
78
|
+
}catch(e){
|
|
79
|
+
return (e as Error).message;
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
),
|
|
83
|
+
assets: CastRecord(CastString, CastObject({
|
|
84
|
+
assetType: CastString,
|
|
85
|
+
sha256: Sha256Caster,
|
|
86
|
+
sizeBytes: CountCaster,
|
|
87
|
+
})),
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const MatchLockPublishPieceCaster = CastObject({
|
|
91
|
+
...OwnableIdentificationCaster,
|
|
92
|
+
...AssetScanCaster,
|
|
93
|
+
|
|
94
|
+
sources: CastArray(ResolvableCaster),
|
|
95
|
+
}).conform<MatchLockPublishPiece>();
|
|
96
|
+
|
|
97
|
+
export const MatchLockScanPieceCaster = (
|
|
98
|
+
CastObject(AssetScanCaster).conform<MatchLockScanPiece>()
|
|
99
|
+
);
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import {
|
|
2
|
+
String as CastString,
|
|
3
|
+
Number as CastNumber,
|
|
4
|
+
Boolean as CastBoolean,
|
|
5
|
+
Union as CastUnion,
|
|
6
|
+
Literal as CastLiteral,
|
|
7
|
+
} from "runtypes";
|
|
8
|
+
|
|
9
|
+
export type DateTime = string;
|
|
10
|
+
export function validateDateTime(value: string){
|
|
11
|
+
if(!Date.parse(value)) throw new Error(`${value} is not a valid date`);
|
|
12
|
+
}
|
|
13
|
+
export const DateTimeCaster = CastString.withConstraint(value => {
|
|
14
|
+
try {
|
|
15
|
+
validateDateTime(value);
|
|
16
|
+
return true;
|
|
17
|
+
}catch(e){
|
|
18
|
+
return (e as Error).message;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type SemVer = string;
|
|
23
|
+
export function validateSemver(value: string){
|
|
24
|
+
// 1. split on dots
|
|
25
|
+
const parts = value.split(".");
|
|
26
|
+
if (parts.length !== 3) {
|
|
27
|
+
throw new Error("SemVer must have three numeric parts separated by `.`");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
for (const part of parts) {
|
|
31
|
+
// 2. non‑empty
|
|
32
|
+
if (part.length === 0) {
|
|
33
|
+
throw new Error("SemVer parts may not be empty");
|
|
34
|
+
}
|
|
35
|
+
// 3. no leading zero (except “0” itself)
|
|
36
|
+
if (part.length > 1 && part[0] === "0") {
|
|
37
|
+
throw new Error(`Invalid leading zero in part “${part}”`);
|
|
38
|
+
}
|
|
39
|
+
// 4. all digits
|
|
40
|
+
if (!/^[0-9]+$/.test(part)) {
|
|
41
|
+
throw new Error(`Non-numeric SemVer part: “${part}”`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export const SemVerCaster = CastString.withConstraint((value) => {
|
|
46
|
+
try {
|
|
47
|
+
validateSemver(value);
|
|
48
|
+
return true;
|
|
49
|
+
}catch(e){
|
|
50
|
+
return (e as Error).message;
|
|
51
|
+
}
|
|
52
|
+
});;
|
|
53
|
+
|
|
54
|
+
export type Sha256 = string;
|
|
55
|
+
export function validateSha256(value: string){
|
|
56
|
+
// Must be exactly 64 hex chars (0–9, a–f, case‑insensitive)
|
|
57
|
+
if (!/^[0-9a-f]{64}$/i.test(value)) {
|
|
58
|
+
throw new Error(`${value} is not a valid SHA-256 (64-char hex)`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export const Sha256Caster = CastString.withConstraint(value => {
|
|
62
|
+
try {
|
|
63
|
+
validateSha256(value);
|
|
64
|
+
return true;
|
|
65
|
+
}catch(e){
|
|
66
|
+
return (e as Error).message;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
/*
|
|
72
|
+
export async function createSHA256Hash(data: string){
|
|
73
|
+
const encoder = new TextEncoder();
|
|
74
|
+
const dataBuffer = encoder.encode(data);
|
|
75
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', dataBuffer);
|
|
76
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
77
|
+
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
78
|
+
}
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
export type URLType = string;
|
|
82
|
+
export function validateURL(value: string){
|
|
83
|
+
if(!URL.canParse(value)) throw new Error(`${value} is not a valid URL`);
|
|
84
|
+
}
|
|
85
|
+
export const URLTypeCaster = CastString.withConstraint(value => {
|
|
86
|
+
try {
|
|
87
|
+
validateURL(value);
|
|
88
|
+
return true;
|
|
89
|
+
}catch(e){
|
|
90
|
+
return (e as Error).message;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
import parseMagnet from "magnet-uri";
|
|
96
|
+
export type MagnetUri = string;
|
|
97
|
+
export function validateMagnetURI(value: string){
|
|
98
|
+
try {
|
|
99
|
+
const parsed = parseMagnet(value);
|
|
100
|
+
if(!parsed.infoHash) throw new Error("Magnet URI parsed but missing infoHash");
|
|
101
|
+
} catch (err: any) {
|
|
102
|
+
throw new Error(`Invalid Magnet URI: ${err.message}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export const MagnetURICaster = CastString.withConstraint(value => {
|
|
106
|
+
try {
|
|
107
|
+
validateMagnetURI(value);
|
|
108
|
+
return true;
|
|
109
|
+
} catch (e) {
|
|
110
|
+
return (e as Error).message;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
export type Count = number;
|
|
115
|
+
export const CountCaster = CastNumber.withConstraint(value => {
|
|
116
|
+
if(value < 0) return `${value} is not a valid count`;
|
|
117
|
+
return true;
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
export type PublicKey = string;
|
|
122
|
+
export type SignedContent = string;
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
export type FilePath = string;
|
|
126
|
+
export function parseFilePath(filepath: string){
|
|
127
|
+
if(filepath.length === 0){
|
|
128
|
+
throw new Error("Filepath is empty");
|
|
129
|
+
}
|
|
130
|
+
if(filepath[0] !== "/"){
|
|
131
|
+
throw new Error("Filepath expected to start with \"/\"");
|
|
132
|
+
}
|
|
133
|
+
const dirParts = filepath.split("/");
|
|
134
|
+
const file = dirParts.pop();
|
|
135
|
+
if(!file){
|
|
136
|
+
throw new Error("Filepath expected to end with a file");
|
|
137
|
+
}
|
|
138
|
+
const fileParts = file.split(".")
|
|
139
|
+
const extension = fileParts.pop();
|
|
140
|
+
if(!extension){
|
|
141
|
+
throw new Error("Filepath expected to end with a file extension");
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
dir: dirParts.join("/"),
|
|
145
|
+
filename: fileParts.join("."),
|
|
146
|
+
extension,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const JSONPrimitiveCaster = CastUnion(
|
|
151
|
+
CastString,
|
|
152
|
+
CastNumber,
|
|
153
|
+
CastBoolean,
|
|
154
|
+
CastLiteral(null),
|
|
155
|
+
);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
import {
|
|
3
|
+
PieceType,
|
|
4
|
+
} from "../../../config-types";
|
|
5
|
+
import {
|
|
6
|
+
DateTime,
|
|
7
|
+
Sha256,
|
|
8
|
+
URLType,
|
|
9
|
+
MagnetUri,
|
|
10
|
+
Count,
|
|
11
|
+
FilePath,
|
|
12
|
+
SignedContent,
|
|
13
|
+
} from "./caster-runtypes/util-casters";
|
|
14
|
+
|
|
15
|
+
export type MatchLockResolvable = (
|
|
16
|
+
| { type: "http"; url: URLType }
|
|
17
|
+
| { type: "torrent"; uri: MagnetUri }
|
|
18
|
+
| { type: "git"; url: URLType; ref?: string }
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export type MatchLockAsset = {
|
|
23
|
+
assetType: string,
|
|
24
|
+
sha256: Sha256,
|
|
25
|
+
sizeBytes: Count,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type MatchLockPublishPiece = {
|
|
29
|
+
name: string,
|
|
30
|
+
author: string,
|
|
31
|
+
|
|
32
|
+
preview: {
|
|
33
|
+
image: URLType,
|
|
34
|
+
url: URLType,
|
|
35
|
+
},
|
|
36
|
+
sources: MatchLockResolvable[],
|
|
37
|
+
|
|
38
|
+
} & MatchLockScanPiece
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
export type MatchLockScanPiece = {
|
|
42
|
+
pieceDefinition: PieceType,
|
|
43
|
+
version: {
|
|
44
|
+
logic: Sha256,
|
|
45
|
+
media: Sha256,
|
|
46
|
+
}
|
|
47
|
+
pathVariables: Record<string, string>,
|
|
48
|
+
assets: Record<FilePath, MatchLockAsset>,
|
|
49
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MatchLockEngineConfig } from "../../../engine";
|
|
2
|
+
|
|
3
|
+
type ErrorInfo = {
|
|
4
|
+
pieceId: string,
|
|
5
|
+
assetType: string,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type AssetConfig = MatchLockEngineConfig["pieceDefinitions"][string]["assets"][0];
|
|
9
|
+
|
|
10
|
+
export function validateAssetCount(
|
|
11
|
+
assetConfig: AssetConfig, assetCount: number, errorInfo: ErrorInfo
|
|
12
|
+
){
|
|
13
|
+
const expectedCount = assetConfig.count;
|
|
14
|
+
if(!Array.isArray(expectedCount)){
|
|
15
|
+
if(expectedCount === "*"){
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if(assetCount !== expectedCount){
|
|
19
|
+
throw new Error(`Piece ${errorInfo.pieceId} has incorrect number of assets for ${errorInfo.assetType} expected ${expectedCount} but got ${assetCount}`);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const [min, max] = expectedCount;
|
|
24
|
+
if(assetCount < min){
|
|
25
|
+
throw new Error(`Piece ${errorInfo.pieceId} has less assets for ${errorInfo.assetType} then minimum ${min}`);
|
|
26
|
+
}
|
|
27
|
+
if(max === "*"){
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if(assetCount > max){
|
|
31
|
+
throw new Error(`Piece ${errorInfo.pieceId} has more assets for ${errorInfo.assetType} than maximum ${max}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { parseFilePath } from "../../../../util-types/runtypes";
|
|
2
|
+
import { MatchLockEngineConfig } from "../../../engine";
|
|
3
|
+
import { MatchLockScanPiece } from "../../version-0/types";
|
|
4
|
+
|
|
5
|
+
export function validateAssetType(
|
|
6
|
+
pieceConfig: MatchLockEngineConfig["pieceDefinitions"][string],
|
|
7
|
+
pieceId: string,
|
|
8
|
+
filePath: string,
|
|
9
|
+
assetInfo: MatchLockScanPiece["assets"][string]
|
|
10
|
+
){
|
|
11
|
+
const file = parseFilePath(filePath);
|
|
12
|
+
const assetType = file.extension.toLowerCase();
|
|
13
|
+
if(!(assetType in pieceConfig.assets)){
|
|
14
|
+
throw new Error(`Piece ${pieceId} references asset ${assetType} which is not in the piece definition`);
|
|
15
|
+
}
|
|
16
|
+
const assetTypeFromDef = assetInfo.assetType;
|
|
17
|
+
if(assetTypeFromDef !== assetType){
|
|
18
|
+
throw new Error(`Piece ${pieceId} references asset at ${filePath} which is of type ${assetTypeFromDef} but the piece is of type ${assetType}`);
|
|
19
|
+
}
|
|
20
|
+
return assetType;
|
|
21
|
+
}
|
|
22
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MatchLockEngineConfig } from "../../../engine";
|
|
2
|
+
import { MatchLockScanPiece } from "../../version-0/types";
|
|
3
|
+
|
|
4
|
+
import { getPieceId } from "../../utils";
|
|
5
|
+
import { validatePathVariableValues } from "./pathVariables";
|
|
6
|
+
import { validateAssetType } from "./assetType";
|
|
7
|
+
import { validateAssetCount } from "./assetCount";
|
|
8
|
+
|
|
9
|
+
export * from "./pathVariables";
|
|
10
|
+
|
|
11
|
+
export function validatePieceMatchesEngineDefinition(
|
|
12
|
+
engine: MatchLockEngineConfig, piece: MatchLockScanPiece
|
|
13
|
+
){
|
|
14
|
+
const pieceId = getPieceId(piece);
|
|
15
|
+
const pieceConfig = engine.pieceDefinitions[piece.pieceDefinition];
|
|
16
|
+
if(!pieceConfig){
|
|
17
|
+
throw new Error(`Piece ${pieceId} is of type ${piece.pieceDefinition} which is not in the engine config`);
|
|
18
|
+
}
|
|
19
|
+
validatePathVariableValues(pieceConfig, piece.pathVariables);
|
|
20
|
+
const counts = new Map<string, number>();
|
|
21
|
+
for(const [filePath, assetInfo] of Object.entries(piece.assets)){
|
|
22
|
+
const assetType = validateAssetType(pieceConfig, pieceId, filePath, assetInfo);
|
|
23
|
+
counts.set(assetType, (counts.get(assetType) ?? 0) + 1);
|
|
24
|
+
}
|
|
25
|
+
for(const [assetType, assetConfig] of Object.entries(pieceConfig.assets)){
|
|
26
|
+
const assetCount = counts.get(assetType) ?? 0;
|
|
27
|
+
validateAssetCount(assetConfig, assetCount, { pieceId: pieceId, assetType });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
package/src/match-lock-file/match-config/version-0/pieces/validate/definition/pathVariables.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { MatchLockEngineConfig } from "../../../../version-1/engine";
|
|
2
|
+
import { PATH_VARIABLE_VALUE_VALIDATION } from "../../../../version-1/engine/validate/piece/assets/glob/pathvariables";
|
|
3
|
+
|
|
4
|
+
export function validateAllExpectedPathVariableNamesSet(
|
|
5
|
+
pathVariableValues: pathVariables
|
|
6
|
+
pieceConfig: MatchLockEngineConfig["pieceDefinitions"][string],
|
|
7
|
+
){
|
|
8
|
+
for(const variableName of pieceConfig.pathVariables){
|
|
9
|
+
if(!(variableName in pathVariableValues)){
|
|
10
|
+
throw new Error(`Piece is missing value for path variable ${variableName}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function validatePathVariableValue(
|
|
16
|
+
variableValue: string,
|
|
17
|
+
){
|
|
18
|
+
if (variableValue.length < PATH_VARIABLE_VALUE_VALIDATION.minLength) {
|
|
19
|
+
throw new Error(`Path variable value is too short`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (variableValue.length > PATH_VARIABLE_VALUE_VALIDATION.maxLength) {
|
|
23
|
+
throw new Error(`Path variable value is too long`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const charsetRegex = new RegExp(`^[${PATH_VARIABLE_VALUE_VALIDATION.charset}]+$`);
|
|
27
|
+
if (!charsetRegex.test(variableValue)) {
|
|
28
|
+
throw new Error(`Path variable value contains invalid characters`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function validatePathVariableNameIsExpected(
|
|
33
|
+
variableName: string,
|
|
34
|
+
pieceConfig: MatchLockEngineConfig["pieceDefinitions"][string],
|
|
35
|
+
){
|
|
36
|
+
if(!pieceConfig.pathVariables.includes(variableName)){
|
|
37
|
+
throw new Error(`Piece does not have path variable ${variableName}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { canonicalJSONStringify } from "../../../../../utils/JSON";
|
|
2
|
+
import { MatchLockPublishPiece } from "../types";
|
|
3
|
+
import { createSHA256Hash } from "../../../../util-types/runtypes";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export async function validatePublishPieceSha(piece: MatchLockPublishPiece){
|
|
7
|
+
const predictableString = canonicalJSONStringify({
|
|
8
|
+
name: piece.name,
|
|
9
|
+
author: piece.author,
|
|
10
|
+
published: piece.published,
|
|
11
|
+
preview: piece.preview,
|
|
12
|
+
sources: piece.sources,
|
|
13
|
+
|
|
14
|
+
pieceDefinition: piece.pieceDefinition,
|
|
15
|
+
version: piece.version,
|
|
16
|
+
assets: piece.assets,
|
|
17
|
+
});
|
|
18
|
+
const sha = await createSHA256Hash(predictableString);
|
|
19
|
+
|
|
20
|
+
if(sha !== piece.sha256){
|
|
21
|
+
throw new Error("Restriction's sha isn't equal to the expected")
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { MatchLockEngineConfig, AssetClassification } from "../../engine";
|
|
2
|
+
import { MatchLockScanPiece } from "../version-0/types";
|
|
3
|
+
|
|
4
|
+
import { getPieceId } from "../utils";
|
|
5
|
+
|
|
6
|
+
export function validatePieceVersion(
|
|
7
|
+
engine: MatchLockEngineConfig, piece: MatchLockScanPiece
|
|
8
|
+
){
|
|
9
|
+
const pieceId = getPieceId(piece);
|
|
10
|
+
const logicSha = getCombinedAssetSha(engine, piece, "logic");
|
|
11
|
+
if(logicSha !== piece.version.logic){
|
|
12
|
+
throw new Error(`Logic SHA Mismatch for ${pieceId}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
import { canonicalJSONStringify } from "../../../../utils/JSON";
|
|
17
|
+
import { createHash } from "node:crypto";
|
|
18
|
+
function getCombinedAssetSha(
|
|
19
|
+
engine: MatchLockEngineConfig, piece: MatchLockScanPiece, type: AssetClassification
|
|
20
|
+
){
|
|
21
|
+
const pieceId = getPieceId(piece);
|
|
22
|
+
const assetShas: Array<string> = [];
|
|
23
|
+
for(const [filepath, asset] of Object.entries(piece.assets)){
|
|
24
|
+
const assetByFilename = getAssetByGlob(
|
|
25
|
+
engine.pieceDefinitions[piece.pieceDefinition], piece.pathVariables, filepath
|
|
26
|
+
);
|
|
27
|
+
const assetByName = getAssetByName(engine.pieceDefinitions[piece.pieceDefinition], assetByFilename.name);
|
|
28
|
+
if(assetByFilename.name !== assetByName.name){
|
|
29
|
+
throw new Error(`Asset Name Mismatch for ${pieceId}`);
|
|
30
|
+
}
|
|
31
|
+
if(assetByFilename.classification !== type) continue;
|
|
32
|
+
assetShas.push(canonicalJSONStringify(asset));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if(assetShas.length === 0) {
|
|
36
|
+
return ""
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 2) Sort
|
|
40
|
+
assetShas.sort();
|
|
41
|
+
|
|
42
|
+
// 3) Concatenate
|
|
43
|
+
const concatenated = Buffer.from(assetShas.join(""), "hex");
|
|
44
|
+
|
|
45
|
+
// 4) Hash it
|
|
46
|
+
return createHash("sha256").update(concatenated).digest("hex");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
import { getMatchingAssetsForFile } from "../../engine";
|
|
50
|
+
function getAssetByGlob(
|
|
51
|
+
pieceDefinition: MatchLockEngineConfig["pieceDefinitions"][string],
|
|
52
|
+
pathVariables: Record<string, string>,
|
|
53
|
+
filepath: string
|
|
54
|
+
){
|
|
55
|
+
const assets = getMatchingAssetsForFile(pieceDefinition, pathVariables, filepath);
|
|
56
|
+
if(assets.length === 0){
|
|
57
|
+
throw new Error(`No matching asset for ${filepath}`);
|
|
58
|
+
}
|
|
59
|
+
return assets[0];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getAssetByName(pieceDefinition: MatchLockEngineConfig["pieceDefinitions"][string], name: string){
|
|
63
|
+
const config = pieceDefinition.assets.find((a) => a.name === name);
|
|
64
|
+
if(!config) throw new Error(`No matching asset for ${name}`);
|
|
65
|
+
return config;
|
|
66
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
import {
|
|
3
|
+
DateTimeCaster,
|
|
4
|
+
SemVerCaster,
|
|
5
|
+
Sha256Caster,
|
|
6
|
+
URLTypeCaster,
|
|
7
|
+
MagnetURICaster,
|
|
8
|
+
CountCaster,
|
|
9
|
+
} from "../pieces/caster-runtypes/util-casters";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
Record as CastRecord,
|
|
13
|
+
Object as CastObject,
|
|
14
|
+
Array as CastArray,
|
|
15
|
+
Tuple as CastTuple,
|
|
16
|
+
Literal,
|
|
17
|
+
Union as CastUnion,
|
|
18
|
+
String as CastString,
|
|
19
|
+
} from "runtypes"
|
|
20
|
+
|
|
21
|
+
import { MatchLockRestrictionConfig } from "./types";
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
import { MatchLockEngineCaster } from "../../engine";
|
|
25
|
+
import { MatchLockPublishPieceCaster } from "../../piece";
|
|
26
|
+
import { MatchLockSelectionConfigCaster } from "../../selection";
|
|
27
|
+
|
|
28
|
+
export const MatchLockRestrictionConfigCaster = CastObject({
|
|
29
|
+
name: CastString,
|
|
30
|
+
version: SemVerCaster,
|
|
31
|
+
sha256: Sha256Caster,
|
|
32
|
+
|
|
33
|
+
published: DateTimeCaster,
|
|
34
|
+
|
|
35
|
+
signature: CastString,
|
|
36
|
+
signatureVerificationUrl: URLTypeCaster,
|
|
37
|
+
|
|
38
|
+
engine: MatchLockEngineCaster,
|
|
39
|
+
|
|
40
|
+
pieces: CastRecord(CastString, CastObject({
|
|
41
|
+
selectionConfig: MatchLockSelectionConfigCaster,
|
|
42
|
+
pieceDefinition: CastString,
|
|
43
|
+
pieces: CastArray(
|
|
44
|
+
CastObject({
|
|
45
|
+
...MatchLockPublishPieceCaster.fields,
|
|
46
|
+
id: CastString,
|
|
47
|
+
requiredPieces: CastRecord(CastString, CastArray(CastString)).optional(),
|
|
48
|
+
})
|
|
49
|
+
),
|
|
50
|
+
}))
|
|
51
|
+
}).conform<MatchLockRestrictionConfig>();
|
|
52
|
+
|