Skip to content
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

chore: remove deprecated field data from keyboard_info usage 🎺 #204

Merged
merged 11 commits into from
Oct 25, 2023
7 changes: 6 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ if builder_start_action start:app; then

sleep 15;
builder_echo "Sleep 15 before attempting to connect to DB"
docker exec -i ${DOCKER_IMAGE[app]} sh -c "php /var/www/html/tools/db/build/build_cli.php"

# If we know we are immediately going to run tests, there's no need to build
# the database and then rebuild it again as a test database!
if [[ ! -f tier.txt ]] || [[ $(<tier.txt) != TIER_TEST ]]; then
docker exec -i ${DOCKER_IMAGE[app]} sh -c "php /var/www/html/tools/db/build/build_cli.php"
fi

builder_finish_action success start:app
fi
Expand Down
17 changes: 11 additions & 6 deletions schemas/.htaccess
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Rewrite old schema endpoints

# keyboard_info.distribution.json
# keyboard_info.schema.json
RewriteRule "^keyboard_info\.schema\.json$" "/schemas/keyboard_info/2.0/keyboard_info.schema.json" [END]

# keyboard_info.distribution.json (deprecated by keyboard_info.schema.json)
RewriteRule "^keyboard_info\.distribution\.json$" "/schemas/keyboard_info.distribution/1.0.6/keyboard_info.distribution.json" [END]

# keyboard_info.source.json
# keyboard_info.source.json (deprecated by keyboard_info.schema.json)
RewriteRule "^keyboard_info\.source\.json$" "/schemas/keyboard_info.source/1.0.6/keyboard_info.source.json" [END]

# keyboard_json.json
Expand All @@ -21,12 +24,14 @@ RewriteRule "^model-search\.json$" "/schemas/model-search/1.0.1/model-search.jso
#package.json
RewriteRule "^package\.json$" "/schemas/package/1.1.0/package.json" [END]


#package-version.json
RewriteRule "^package-version\.json$" "/schemas/package-version/1.0.1/package-version.json" [END]

#search.json"
RewriteRule "^search\.json$" "/schemas/search/1.0.2/search.json" [END]
#search.json
RewriteRule "^search\.json$" "/schemas/search/3.0/search.json" [END]

# "version.json"
#version.json
RewriteRule "^version\.json$" "/schemas/version/2.0/version.json" [END]

#windows-update.json
RewriteRule "^windows-update\.json$" "/schemas/windows-update/17.0/windows-update.json" [END]
25 changes: 20 additions & 5 deletions schemas/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
# keyboard_info

* **keyboard_info.source.json**
* **keyboard_info.distribution.json**
* **keyboard_info.schema.json**

Documentation at https://help.keyman.com/developer/cloud/keyboard_info

New versions should be deployed to
- **keymanapp/keyman/windows/src/global/inst/data/keyboard_info**
- **keymanapp/keyboards/tools**
- **keymanapp/keyboards-starter/tools**
- **keymanapp/keyman:common/schemas/keyboard_info**

# .keyboard_info version history

## 2023-10-12 2.0 stable
* Removed:
- `.documentationFilename`
- `.documentationFileSize`
- `.legacyId`
`.links`
`.related[].note`
`.languages[].example`
Added:
- `.languages[].examples[]`
Modified:
- `.languages[].font`, `.languages[].oskFont`: `.source` is `[string]`
- Source .keyboard_info files are no longer needed, so source vs distribution
keyboard_info distinction is removed

## 2019-09-06 1.0.6 stable
* No changes (see api.keyman.com#36 and api.keyman.com#59. Reverted in 2020-06-10.).

## 2018-11-26 1.0.5 stable
* Add deprecated field - true if the keyboard is deprecated (generated at deployment time).

Expand Down
105 changes: 105 additions & 0 deletions schemas/keyboard_info/2.0/keyboard_info.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"$schema": "http://json-schema.org/schema#",
"$ref": "#/definitions/KeyboardInfo",

"definitions": {
"KeyboardInfo": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"authorName": { "type": "string" },
"authorEmail": { "type": "string", "format": "email" },
"description": { "type": "string" },
"license": { "type": "string", "enum": ["freeware", "shareware", "commercial", "mit", "other"] },
"languages": { "anyOf": [
{ "type": "array", "items": { "type": "string" }, "uniqueItems": true },
{ "$ref": "#/definitions/KeyboardLanguageInfo" }
]},
"lastModifiedDate": { "type": "string", "format": "date-time" },
"packageFilename": { "type": "string", "pattern": "\\.km[xp]$" },
"packageFileSize": { "type": "number" },
"jsFilename": { "type": "string", "pattern": "\\.js$" },
"jsFileSize": { "type": "number" },
"isRTL": { "type": "boolean" },
"encodings": { "type": "array", "items": { "type": "string", "enum": ["ansi", "unicode"] } },
"packageIncludes": { "type": "array", "items": { "type": "string", "enum": ["welcome", "documentation", "fonts", "visualKeyboard"] } },
"version": { "type": "string" },
"minKeymanVersion": { "type": "string", "pattern": "^\\d+\\.\\d$" },
"helpLink": { "type": "string", "pattern": "^https://help\\.keyman\\.com/keyboard/" },
"platformSupport": { "$ref": "#/definitions/KeyboardPlatformInfo" },
"sourcePath": { "type": "string", "pattern": "^(release|legacy|experimental)/.+/.+$" },
"related": { "type": "object", "patternProperties": {
".": { "$ref": "#/definitions/KeyboardRelatedInfo" }
},
"additionalProperties": false
},
"deprecated": { "type": "boolean" }
},
"required": [ "id", "name", "license", "languages", "lastModifiedDate", "platformSupport" ]
},

"KeyboardLanguageInfo": {
"type": "object",
"patternProperties": {
".": { "$ref": "#/definitions/KeyboardLanguageInfoItem" }
},
"additionalProperties": false
},

"KeyboardLanguageInfoItem": {
"type": "object",
"properties": {
"font": { "$ref": "#/definitions/KeyboardFontInfo" },
"oskFont": { "$ref": "#/definitions/KeyboardFontInfo" },
"examples": { "type": "array", "items": { "$ref": "#/definitions/KeyboardExampleInfo" } },
"displayName": { "type": "string" },
"languageName": { "type": "string" },
"scriptName": { "type": "string" },
"regionName": { "type": "string" }
},
"required": [],
"additionalProperties": false
},

"KeyboardFontInfo": {
"type": "object",
"properties": {
"family": { "type": "string" },
"source": { "type": "array", "items": { "type": "string" } }
},
"required": ["family", "source"],
"additionalProperties": false
},

"KeyboardExampleInfo": {
"type": "object",
"properties": {
"keys": { "type": "string" },
"text": { "type": "string" },
"note": { "type": "string" }
},
"required": ["keys", "text"],
"additionalProperties": false
},

"KeyboardPlatformInfo": {
"type": "object",
"patternProperties": {
"^(windows|macos|desktopWeb|ios|android|mobileWeb|linux)$": { "type": "string", "enum": ["dictionary", "full", "basic", "none"] }
},
"required": [],
"additionalProperties": false
},

"KeyboardRelatedInfo": {
"type": "object",
"properties": {
"deprecates": { "type": "boolean" },
"deprecatedBy": { "type": "boolean" }
},
"required": [],
"additionalProperties": false
}
}
}
60 changes: 60 additions & 0 deletions schemas/search/3.0/search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"$schema": "http://json-schema.org/schema#",
"$ref": "#/definitions/Search",

"definitions": {
"Search": {
"type": "object",
"properties": {
"keyboards": { "type": "array", "items": { "$ref": "#/definitions/SearchKeyboard" } },
"context": { "$ref": "#/definitions/Context" }
},
"required": ["keyboards","context"]
},

"Context": {
"type": "object",
"properties": {
"range": { "type": "string" },
"text": { "type": "string" },
"platform": { "type": "string", "enum": ["android", "ios", "linux", "macos", "web", "windows"] },
"pageSize": { "type": "number" },
"pageNumber": { "type": "number" },
"totalRows": { "type": "number" },
"totalPages": { "type": "number" }
},
"required": ["range", "text", "pageSize", "pageNumber", "totalRows", "totalPages"],
"additionalProperties": false
},

"SearchKeyboard": {
"allOf": [
{ "$ref": "/keyboard_info/2.0/keyboard_info.schema.json#/definitions/KeyboardInfo" },
{
"properties": {
"match": {
"type": "object",
"properties": {
"name": { "oneOf": [ { "type": "string" }, { "type": "null"} ] },
"type": { "type": "string", "enum": [
"keyboard", "keyboard_id", "description", "legacy_keyboard_id",
"language", "language_bcp47_tag",
"country", "country_iso3166_code",
"script", "script_iso15924_code"
] },
"tag": { "type": "string" },
"weight": { "type": "number" },
"downloads": { "type": "number" },
"totalDownloads": { "type": "number" },
"finalWeight": { "type": "number" }
},
"required": ["name","type","weight","downloads","finalWeight"],
"additionalProperties": false
}
},
"required": ["match"]
}
]
}
}
}
106 changes: 106 additions & 0 deletions schemas/windows-update/17.0/windows-update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$ref": "#/definitions/windows-update",

"definitions": {
"windows-update": {
"type": "object",
"required": ["msi", "setup", "bundle", "keyboards"],
"additionalProperties": true,
"properties": {
"msi": {
"$ref": "#/definitions/optional-file"
},
"setup": {
"$ref": "#/definitions/optional-file"
},
"bundle": {
"$ref": "#/definitions/optional-file"
},
"keyboards": {
"$ref": "#/definitions/keyboards"
}
}
},

"optional-file": {
"anyOf": [{ "$ref": "#/definitions/file" }, { "type": "boolean" }]
},

"file": {
"type": "object",
"required": [
"name",
"version",
"date",
"platform",
"stability",
"file",
"md5",
"type",
"build",
"size",
"url"
],
"additionalProperties": true,
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
},
"date": {
"type": "string"
},
"platform": {
"type": "string"
},
"stability": {
"type": "string"
},
"file": {
"type": "string"
},
"md5": {
"type": "string"
},
"type": {
"type": "string"
},
"build": {
"type": "string"
},
"size": {
"type": "integer"
},
"url": {
"type": "string"
}
}
},
"keyboards": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
".+": {
"$ref": "#/definitions/keyboard"
}
}
},
"keyboard": {
"allOf": [
{
"$ref": "/keyboard_info/2.0/keyboard_info.schema.json#/definitions/KeyboardInfo"
},
{
"properties": {
"url": {
"type": "string"
}
}
}
]
}
}
}
17 changes: 0 additions & 17 deletions tests/Search20Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,6 @@ public function testSearchByKeyboardId()
$this->assertEquals('keyboard_id', $json->keyboards[0]->match->type);
}

public function testSearchByLegacyKeyboardId()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this get removed in a Search30Test.php?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand the question?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Search20Test.php uses /search/2.0/search.json
https://github.com/keymanapp/api.keyman.com/blob/be87e96ec10df73534eb758403e1fdcd88f8d55c/tests/Search20Test.php#L14C37-L14C61

Do we need a Search30Test.php that uses /search/3.0/search.json for tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because this is a test of the search 2.0 api, and we haven't got a search 3.0 api.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've got a search 3.0 schema but not a search 3.0 api. Confuse much? Basically search 3.0 less data than search 2.0.

{
$json = $this->s->GetSearchMatches(null, 'legacy:681', 1, 1);
$json = json_decode(json_encode($json));
$this->schema->in($json);
$this->assertEquals(1, $json->context->totalRows);
$this->assertEquals('acoli', $json->keyboards[0]->id);
$this->assertEquals('legacy_keyboard_id', $json->keyboards[0]->match->type);

$json = $this->s->GetSearchMatches(null, 'k:legacy:681', 1, 1);
$json = json_decode(json_encode($json));
$this->schema->in($json);
$this->assertEquals(1, $json->context->totalRows);
$this->assertEquals('acoli', $json->keyboards[0]->id);
$this->assertEquals('legacy_keyboard_id', $json->keyboards[0]->match->type);
}

public function testSearchByLanguageBcp47Tag()
{
$json = $this->s->GetSearchMatches(null, 'l:id:ach', 1, 1);
Expand Down
Loading