-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add keyman-version check to package-version API #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mcdurdin
merged 2 commits into
master
from
feat/325-add-keyman-version-check-to-package-version
Jun 29, 2026
+108
−73
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,14 +8,16 @@ | |||||
| * | ||||||
| * https://api.keyman.com/schemas/package-version.json is JSON schema for valid responses | ||||||
| * | ||||||
| * @param keyboard Optional. keyboard id, can be repeated (either with comma or repeated param). | ||||||
| * @param model Optional. model id, can be repeated (either with comma or repeated param). | ||||||
| * @param platform Optional. Filter by platform support for keyboards: | ||||||
| * android, ios, linux, mac, [web], windows (web does not currently support .kmp) | ||||||
| * This stops the API returning keyboard packages that are invalid for the target | ||||||
| * platform. If not supplied, does not filter by platform support. | ||||||
| * @return JSON blob or HTTP/400 (with JSON error) on invalid parameters | ||||||
| * The valid blob will contain latest version and url for the keyboards/lexical models. | ||||||
| * @param keyboard Optional. keyboard id, can be repeated (either with comma or repeated param). | ||||||
| * @param model Optional. model id, can be repeated (either with comma or repeated param). | ||||||
| * @param platform Optional. Filter by platform support for keyboards: | ||||||
| * android, ios, linux, mac, [web], windows (web does not currently support .kmp) | ||||||
| * This stops the API returning keyboard packages that are invalid for the target | ||||||
| * platform. If not supplied, does not filter by platform support. | ||||||
| * @param keyman-version Optional. Version of Keyman requesting the keyboard, will filter out keyboards | ||||||
| * that depend on a newer version of Keyman. | ||||||
| * @return JSON blob or HTTP/400 (with JSON error) on invalid parameters | ||||||
| * The valid blob will contain latest version and url for the keyboards/lexical models. | ||||||
| */ | ||||||
|
|
||||||
| require_once('../../tools/util.php'); | ||||||
|
|
@@ -39,22 +41,34 @@ | |||||
| $available_platforms = PackageVersion::available_platforms(); | ||||||
|
|
||||||
| foreach($params as $param => $value) { | ||||||
| if(!in_array($param, ['keyboard', 'model', 'platform'])) { | ||||||
| fail("Invalid parameter $param"); | ||||||
| if(!in_array($param, ['keyboard', 'model', 'platform', 'keyman-version'])) { | ||||||
| fail("Unrecognized parameter '$param'"); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if(isset($params['platform'])) { | ||||||
| $platform = $params['platform']; | ||||||
| if(!in_array($platform, $available_platforms)) { | ||||||
| fail("Invalid platform $platform"); | ||||||
| fail("Invalid platform' $platform'"); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
| } | ||||||
| else $platform = null; | ||||||
|
|
||||||
| // Prepare results | ||||||
|
|
||||||
| $PackageVersion = new Keyman\Site\com\keyman\api\PackageVersion(); | ||||||
| $json = $PackageVersion->execute($mssql, $params, $platform); | ||||||
| if(isset($params['keyman-version'])) { | ||||||
| $keymanVersion = $params['keyman-version']; | ||||||
| if(!preg_match('/^(\d+)\.(\d+)\.(\d+)$/', $keymanVersion)) { | ||||||
| fail("Invalid keyman-version '$keymanVersion', expected a.b.c format"); | ||||||
| } | ||||||
| } | ||||||
| else $keymanVersion = null; | ||||||
|
|
||||||
| $keyboards = isset($params['keyboard']) ? $params['keyboard'] : []; | ||||||
| $models = isset($params['model']) ? $params['model'] : []; | ||||||
|
|
||||||
| $PackageVersion = new Keyman\Site\com\keyman\api\PackageVersion($mssql); | ||||||
| $json = $PackageVersion->execute($keyboards, $models, $platform, $keymanVersion); | ||||||
|
|
||||||
| echo json_encode($json, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); | ||||||
|
|
||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing new, but the order of the fields in the
SELECTstatement and inavailable_patforms()is different (k.platform_android, k.platform_linux, k.platform_macos, k.platform_ios, k.platform_web, k.platform_windowsvs'android', 'ios', 'linux', 'mac', 'web', 'windows'), so the results will be wrong for Linux, Mac and iOS (flagged by devin.ai).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I had fixed one of the issues but missed this one, thanks