Skip to content

Commit

Permalink
Merge pull request #204 from keymanapp/chore/keyboard_info-remove-dep
Browse files Browse the repository at this point in the history
chore: remove deprecated field data from keyboard_info usage 🎺
  • Loading branch information
mcdurdin authored Oct 25, 2023
2 parents 8eb81b6 + ef3204d commit 11d2e46
Show file tree
Hide file tree
Showing 9 changed files with 311 additions and 75 deletions.
7 changes: 6 additions & 1 deletion resources/init-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@

echo "---- Sleep 15 Before Generating DB ----"
sleep 15;
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 /var/www/html/tier.txt ]] || [[ $(</var/www/html/tier.txt) != TIER_TEST ]]; then
php /var/www/html/tools/db/build/build_cli.php
fi
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()
{
$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

0 comments on commit 11d2e46

Please sign in to comment.