diff --git a/.releaserc b/.releaserc index c5635fd72..80e12f9ea 100644 --- a/.releaserc +++ b/.releaserc @@ -45,7 +45,7 @@ [ "@semantic-release/git", { - "assets": ["CHANGELOG.md", "package.json", "package-lock.json", "npm-shrinkwrap.json", "src/sdks/core/package.json", "src/sdks/manage/package.json"] + "assets": ["CHANGELOG.md", "package.json", "package-lock.json", "npm-shrinkwrap.json", "src/sdks/core/package.json", "src/sdks/manage/package.json", "src/sdks/discovery/package.json"] } ], [ diff --git a/CHANGELOG.md b/CHANGELOG.md index ca266e76a..e6261bf96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,160 @@ +# [1.3.0-next.1](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.1-next.4...v1.3.0-next.1) (2024-07-29) + + +### Features + +* CPP App-Passthrough Logic ([#286](https://github.com/rdkcentral/firebolt-apis/issues/286)) ([4eb84ee](https://github.com/rdkcentral/firebolt-apis/commit/4eb84ee08c463915e3b13afec6603541ea0b1ae4)) + +## [1.2.1-next.4](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.1-next.3...v1.2.1-next.4) (2024-07-29) + + +### Bug Fixes + +* Added Static Metrics template in CPP ([#293](https://github.com/rdkcentral/firebolt-apis/issues/293)) ([a1f75cb](https://github.com/rdkcentral/firebolt-apis/commit/a1f75cb22577c3eded0968ca51ca656336a88506)) + +## [1.2.1-next.3](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.1-next.2...v1.2.1-next.3) (2024-07-29) + + +### Bug Fixes + +* Added Lifecycle template in cpp ([#292](https://github.com/rdkcentral/firebolt-apis/issues/292)) ([046adc1](https://github.com/rdkcentral/firebolt-apis/commit/046adc18ca7f2d35d02b9ce597be6f330c3b1972)) + +## [1.2.1-next.2](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.1-next.1...v1.2.1-next.2) (2024-07-01) + + +### Bug Fixes + +* **core, manage:** update C++ tests to run simultaneously for core and manage SDKs ([ef7bc4c](https://github.com/rdkcentral/firebolt-apis/commit/ef7bc4ce117cbce799ddab8c9b44522730374514)) + +## [1.2.1-next.1](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.0...v1.2.1-next.1) (2024-06-26) + + +### Bug Fixes + +* Sort capabilities in Firebolt Specification JSON ([46dd188](https://github.com/rdkcentral/firebolt-apis/commit/46dd1887e09cc3c75ebb7b41028b10b3a8d3596e)) + +# [1.2.0](https://github.com/rdkcentral/firebolt-apis/compare/v1.1.0...v1.2.0) (2024-06-17) + + +### Bug Fixes + +* Add discovery to semantic-release ([#282](https://github.com/rdkcentral/firebolt-apis/issues/282)) ([7966bd3](https://github.com/rdkcentral/firebolt-apis/commit/7966bd34f7a5cdfa4d65c6a5e0e304ee777925c5)) +* Add PlaylistEntity to EntityIntent ([9769d6d](https://github.com/rdkcentral/firebolt-apis/commit/9769d6d7d43f1d61dfcda16ba4806175c5cf7658)) +* CHANGELOG formatting for Core SDK ([de051a4](https://github.com/rdkcentral/firebolt-apis/commit/de051a427ec4e9b287efd0c8b64d53e656539343)) +* Remove x-alternatives that don't exist ([#278](https://github.com/rdkcentral/firebolt-apis/issues/278)) ([e38ad5a](https://github.com/rdkcentral/firebolt-apis/commit/e38ad5a508fccb5c724cf0f03cbd67ad4a28378c)) +* Removed sdk as required field from Device.version ([#231](https://github.com/rdkcentral/firebolt-apis/issues/231)) ([ef3de3e](https://github.com/rdkcentral/firebolt-apis/commit/ef3de3e68619c6f666dd1d751b0acc25f6438122)) +* Update CHANGELOG.md ([85e6ccb](https://github.com/rdkcentral/firebolt-apis/commit/85e6ccb0f6d4f73a5a244a9914a78c2afc3e04aa)) + + +### Features + +* CI/CD docs (next-major) and merges (next-major/main) ([#245](https://github.com/rdkcentral/firebolt-apis/issues/245)) ([49ab03d](https://github.com/rdkcentral/firebolt-apis/commit/49ab03db9986b27dafd279fcc6121abe447784dc)) +* Command and Control Intents ([#251](https://github.com/rdkcentral/firebolt-apis/issues/251)) ([c8f8dae](https://github.com/rdkcentral/firebolt-apis/commit/c8f8dae5a9a0f14a3815c04df5a55763823d4898)) +* Firebolt CPP SDKs ([5ea5d4e](https://github.com/rdkcentral/firebolt-apis/commit/5ea5d4e2f486a7bc3861955cd98323fc2c26cce1)), closes [#189](https://github.com/rdkcentral/firebolt-apis/issues/189) [#190](https://github.com/rdkcentral/firebolt-apis/issues/190) [#191](https://github.com/rdkcentral/firebolt-apis/issues/191) [#192](https://github.com/rdkcentral/firebolt-apis/issues/192) [#205](https://github.com/rdkcentral/firebolt-apis/issues/205) [#209](https://github.com/rdkcentral/firebolt-apis/issues/209) [#218](https://github.com/rdkcentral/firebolt-apis/issues/218) [#222](https://github.com/rdkcentral/firebolt-apis/issues/222) [#228](https://github.com/rdkcentral/firebolt-apis/issues/228) [#230](https://github.com/rdkcentral/firebolt-apis/issues/230) [#237](https://github.com/rdkcentral/firebolt-apis/issues/237) [#238](https://github.com/rdkcentral/firebolt-apis/issues/238) [#249](https://github.com/rdkcentral/firebolt-apis/issues/249) +* Updated CHANGELOGS for SDKs for version 1.2.0 ([b20b38d](https://github.com/rdkcentral/firebolt-apis/commit/b20b38db5bd59efb7c31c562ba00666161dbf783)) +* User Interest ([#170](https://github.com/rdkcentral/firebolt-apis/issues/170)) ([48a1094](https://github.com/rdkcentral/firebolt-apis/commit/48a1094aaab6418f09db662dbc81f090a34f32ed)) + +# [1.2.0](https://github.com/rdkcentral/firebolt-apis/compare/v1.1.0...v1.2.0) (2024-06-17) + + +### Bug Fixes + +* Add PlaylistEntity to EntityIntent ([9769d6d](https://github.com/rdkcentral/firebolt-apis/commit/9769d6d7d43f1d61dfcda16ba4806175c5cf7658)) +* CHANGELOG formatting for Core SDK ([de051a4](https://github.com/rdkcentral/firebolt-apis/commit/de051a427ec4e9b287efd0c8b64d53e656539343)) +* Remove x-alternatives that don't exist ([#278](https://github.com/rdkcentral/firebolt-apis/issues/278)) ([e38ad5a](https://github.com/rdkcentral/firebolt-apis/commit/e38ad5a508fccb5c724cf0f03cbd67ad4a28378c)) +* Removed sdk as required field from Device.version ([#231](https://github.com/rdkcentral/firebolt-apis/issues/231)) ([ef3de3e](https://github.com/rdkcentral/firebolt-apis/commit/ef3de3e68619c6f666dd1d751b0acc25f6438122)) +* Update CHANGELOG.md ([85e6ccb](https://github.com/rdkcentral/firebolt-apis/commit/85e6ccb0f6d4f73a5a244a9914a78c2afc3e04aa)) + + +### Features + +* CI/CD docs (next-major) and merges (next-major/main) ([#245](https://github.com/rdkcentral/firebolt-apis/issues/245)) ([49ab03d](https://github.com/rdkcentral/firebolt-apis/commit/49ab03db9986b27dafd279fcc6121abe447784dc)) +* Command and Control Intents ([#251](https://github.com/rdkcentral/firebolt-apis/issues/251)) ([c8f8dae](https://github.com/rdkcentral/firebolt-apis/commit/c8f8dae5a9a0f14a3815c04df5a55763823d4898)) +* Firebolt CPP SDKs ([5ea5d4e](https://github.com/rdkcentral/firebolt-apis/commit/5ea5d4e2f486a7bc3861955cd98323fc2c26cce1)), closes [#189](https://github.com/rdkcentral/firebolt-apis/issues/189) [#190](https://github.com/rdkcentral/firebolt-apis/issues/190) [#191](https://github.com/rdkcentral/firebolt-apis/issues/191) [#192](https://github.com/rdkcentral/firebolt-apis/issues/192) [#205](https://github.com/rdkcentral/firebolt-apis/issues/205) [#209](https://github.com/rdkcentral/firebolt-apis/issues/209) [#218](https://github.com/rdkcentral/firebolt-apis/issues/218) [#222](https://github.com/rdkcentral/firebolt-apis/issues/222) [#228](https://github.com/rdkcentral/firebolt-apis/issues/228) [#230](https://github.com/rdkcentral/firebolt-apis/issues/230) [#237](https://github.com/rdkcentral/firebolt-apis/issues/237) [#238](https://github.com/rdkcentral/firebolt-apis/issues/238) [#249](https://github.com/rdkcentral/firebolt-apis/issues/249) +* Updated CHANGELOGS for SDKs for version 1.2.0 ([b20b38d](https://github.com/rdkcentral/firebolt-apis/commit/b20b38db5bd59efb7c31c562ba00666161dbf783)) +* User Interest ([#170](https://github.com/rdkcentral/firebolt-apis/issues/170)) ([48a1094](https://github.com/rdkcentral/firebolt-apis/commit/48a1094aaab6418f09db662dbc81f090a34f32ed)) + +# [1.2.0](https://github.com/rdkcentral/firebolt-apis/compare/v1.1.0...v1.2.0) (2024-06-17) + + +### Bug Fixes + +* Add PlaylistEntity to EntityIntent ([9769d6d](https://github.com/rdkcentral/firebolt-apis/commit/9769d6d7d43f1d61dfcda16ba4806175c5cf7658)) +* CHANGELOG formatting for Core SDK ([de051a4](https://github.com/rdkcentral/firebolt-apis/commit/de051a427ec4e9b287efd0c8b64d53e656539343)) +* Remove x-alternatives that don't exist ([#278](https://github.com/rdkcentral/firebolt-apis/issues/278)) ([e38ad5a](https://github.com/rdkcentral/firebolt-apis/commit/e38ad5a508fccb5c724cf0f03cbd67ad4a28378c)) +* Removed sdk as required field from Device.version ([#231](https://github.com/rdkcentral/firebolt-apis/issues/231)) ([ef3de3e](https://github.com/rdkcentral/firebolt-apis/commit/ef3de3e68619c6f666dd1d751b0acc25f6438122)) +* Update CHANGELOG.md ([85e6ccb](https://github.com/rdkcentral/firebolt-apis/commit/85e6ccb0f6d4f73a5a244a9914a78c2afc3e04aa)) + + +### Features + +* CI/CD docs (next-major) and merges (next-major/main) ([#245](https://github.com/rdkcentral/firebolt-apis/issues/245)) ([49ab03d](https://github.com/rdkcentral/firebolt-apis/commit/49ab03db9986b27dafd279fcc6121abe447784dc)) +* Command and Control Intents ([#251](https://github.com/rdkcentral/firebolt-apis/issues/251)) ([c8f8dae](https://github.com/rdkcentral/firebolt-apis/commit/c8f8dae5a9a0f14a3815c04df5a55763823d4898)) +* Firebolt CPP SDKs ([5ea5d4e](https://github.com/rdkcentral/firebolt-apis/commit/5ea5d4e2f486a7bc3861955cd98323fc2c26cce1)), closes [#189](https://github.com/rdkcentral/firebolt-apis/issues/189) [#190](https://github.com/rdkcentral/firebolt-apis/issues/190) [#191](https://github.com/rdkcentral/firebolt-apis/issues/191) [#192](https://github.com/rdkcentral/firebolt-apis/issues/192) [#205](https://github.com/rdkcentral/firebolt-apis/issues/205) [#209](https://github.com/rdkcentral/firebolt-apis/issues/209) [#218](https://github.com/rdkcentral/firebolt-apis/issues/218) [#222](https://github.com/rdkcentral/firebolt-apis/issues/222) [#228](https://github.com/rdkcentral/firebolt-apis/issues/228) [#230](https://github.com/rdkcentral/firebolt-apis/issues/230) [#237](https://github.com/rdkcentral/firebolt-apis/issues/237) [#238](https://github.com/rdkcentral/firebolt-apis/issues/238) [#249](https://github.com/rdkcentral/firebolt-apis/issues/249) +* Updated CHANGELOGS for SDKs for version 1.2.0 ([b20b38d](https://github.com/rdkcentral/firebolt-apis/commit/b20b38db5bd59efb7c31c562ba00666161dbf783)) +* User Interest ([#170](https://github.com/rdkcentral/firebolt-apis/issues/170)) ([48a1094](https://github.com/rdkcentral/firebolt-apis/commit/48a1094aaab6418f09db662dbc81f090a34f32ed)) + +# [1.2.0](https://github.com/rdkcentral/firebolt-apis/compare/v1.1.0...v1.2.0) (2024-06-14) + + +### Bug Fixes + +* Add PlaylistEntity to EntityIntent ([9769d6d](https://github.com/rdkcentral/firebolt-apis/commit/9769d6d7d43f1d61dfcda16ba4806175c5cf7658)) +* CHANGELOG formatting for Core SDK ([de051a4](https://github.com/rdkcentral/firebolt-apis/commit/de051a427ec4e9b287efd0c8b64d53e656539343)) +* Remove x-alternatives that don't exist ([#278](https://github.com/rdkcentral/firebolt-apis/issues/278)) ([e38ad5a](https://github.com/rdkcentral/firebolt-apis/commit/e38ad5a508fccb5c724cf0f03cbd67ad4a28378c)) +* Removed sdk as required field from Device.version ([#231](https://github.com/rdkcentral/firebolt-apis/issues/231)) ([ef3de3e](https://github.com/rdkcentral/firebolt-apis/commit/ef3de3e68619c6f666dd1d751b0acc25f6438122)) +* Update CHANGELOG.md ([85e6ccb](https://github.com/rdkcentral/firebolt-apis/commit/85e6ccb0f6d4f73a5a244a9914a78c2afc3e04aa)) + + +### Features + +* CI/CD docs (next-major) and merges (next-major/main) ([#245](https://github.com/rdkcentral/firebolt-apis/issues/245)) ([49ab03d](https://github.com/rdkcentral/firebolt-apis/commit/49ab03db9986b27dafd279fcc6121abe447784dc)) +* Command and Control Intents ([#251](https://github.com/rdkcentral/firebolt-apis/issues/251)) ([c8f8dae](https://github.com/rdkcentral/firebolt-apis/commit/c8f8dae5a9a0f14a3815c04df5a55763823d4898)) +* Firebolt CPP SDKs ([5ea5d4e](https://github.com/rdkcentral/firebolt-apis/commit/5ea5d4e2f486a7bc3861955cd98323fc2c26cce1)), closes [#189](https://github.com/rdkcentral/firebolt-apis/issues/189) [#190](https://github.com/rdkcentral/firebolt-apis/issues/190) [#191](https://github.com/rdkcentral/firebolt-apis/issues/191) [#192](https://github.com/rdkcentral/firebolt-apis/issues/192) [#205](https://github.com/rdkcentral/firebolt-apis/issues/205) [#209](https://github.com/rdkcentral/firebolt-apis/issues/209) [#218](https://github.com/rdkcentral/firebolt-apis/issues/218) [#222](https://github.com/rdkcentral/firebolt-apis/issues/222) [#228](https://github.com/rdkcentral/firebolt-apis/issues/228) [#230](https://github.com/rdkcentral/firebolt-apis/issues/230) [#237](https://github.com/rdkcentral/firebolt-apis/issues/237) [#238](https://github.com/rdkcentral/firebolt-apis/issues/238) [#249](https://github.com/rdkcentral/firebolt-apis/issues/249) +* Updated CHANGELOGS for SDKs for version 1.2.0 ([b20b38d](https://github.com/rdkcentral/firebolt-apis/commit/b20b38db5bd59efb7c31c562ba00666161dbf783)) +* User Interest ([#170](https://github.com/rdkcentral/firebolt-apis/issues/170)) ([48a1094](https://github.com/rdkcentral/firebolt-apis/commit/48a1094aaab6418f09db662dbc81f090a34f32ed)) + +# [1.2.0](https://github.com/rdkcentral/firebolt-apis/compare/v1.1.0...v1.2.0) (2024-06-14) + + +### Bug Fixes + +* Add PlaylistEntity to EntityIntent ([9769d6d](https://github.com/rdkcentral/firebolt-apis/commit/9769d6d7d43f1d61dfcda16ba4806175c5cf7658)) +* CHANGELOG formatting for Core SDK ([de051a4](https://github.com/rdkcentral/firebolt-apis/commit/de051a427ec4e9b287efd0c8b64d53e656539343)) +* Remove x-alternatives that don't exist ([#278](https://github.com/rdkcentral/firebolt-apis/issues/278)) ([e38ad5a](https://github.com/rdkcentral/firebolt-apis/commit/e38ad5a508fccb5c724cf0f03cbd67ad4a28378c)) +* Removed sdk as required field from Device.version ([#231](https://github.com/rdkcentral/firebolt-apis/issues/231)) ([ef3de3e](https://github.com/rdkcentral/firebolt-apis/commit/ef3de3e68619c6f666dd1d751b0acc25f6438122)) +* Update CHANGELOG.md ([85e6ccb](https://github.com/rdkcentral/firebolt-apis/commit/85e6ccb0f6d4f73a5a244a9914a78c2afc3e04aa)) + + +### Features + +* CI/CD docs (next-major) and merges (next-major/main) ([#245](https://github.com/rdkcentral/firebolt-apis/issues/245)) ([49ab03d](https://github.com/rdkcentral/firebolt-apis/commit/49ab03db9986b27dafd279fcc6121abe447784dc)) +* Command and Control Intents ([#251](https://github.com/rdkcentral/firebolt-apis/issues/251)) ([c8f8dae](https://github.com/rdkcentral/firebolt-apis/commit/c8f8dae5a9a0f14a3815c04df5a55763823d4898)) +* Firebolt CPP SDKs ([5ea5d4e](https://github.com/rdkcentral/firebolt-apis/commit/5ea5d4e2f486a7bc3861955cd98323fc2c26cce1)), closes [#189](https://github.com/rdkcentral/firebolt-apis/issues/189) [#190](https://github.com/rdkcentral/firebolt-apis/issues/190) [#191](https://github.com/rdkcentral/firebolt-apis/issues/191) [#192](https://github.com/rdkcentral/firebolt-apis/issues/192) [#205](https://github.com/rdkcentral/firebolt-apis/issues/205) [#209](https://github.com/rdkcentral/firebolt-apis/issues/209) [#218](https://github.com/rdkcentral/firebolt-apis/issues/218) [#222](https://github.com/rdkcentral/firebolt-apis/issues/222) [#228](https://github.com/rdkcentral/firebolt-apis/issues/228) [#230](https://github.com/rdkcentral/firebolt-apis/issues/230) [#237](https://github.com/rdkcentral/firebolt-apis/issues/237) [#238](https://github.com/rdkcentral/firebolt-apis/issues/238) [#249](https://github.com/rdkcentral/firebolt-apis/issues/249) +* Updated CHANGELOGS for SDKs for version 1.2.0 ([b20b38d](https://github.com/rdkcentral/firebolt-apis/commit/b20b38db5bd59efb7c31c562ba00666161dbf783)) +* User Interest ([#170](https://github.com/rdkcentral/firebolt-apis/issues/170)) ([48a1094](https://github.com/rdkcentral/firebolt-apis/commit/48a1094aaab6418f09db662dbc81f090a34f32ed)) + +# [1.2.0-next.5](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.0-next.4...v1.2.0-next.5) (2024-06-13) + + +### Bug Fixes + +* Remove x-alternatives that don't exist ([#278](https://github.com/rdkcentral/firebolt-apis/issues/278)) ([e38ad5a](https://github.com/rdkcentral/firebolt-apis/commit/e38ad5a508fccb5c724cf0f03cbd67ad4a28378c)) + +# [1.2.0-next.4](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.0-next.3...v1.2.0-next.4) (2024-06-06) + + +### Features + +* Command and Control Intents ([#251](https://github.com/rdkcentral/firebolt-apis/issues/251)) ([c8f8dae](https://github.com/rdkcentral/firebolt-apis/commit/c8f8dae5a9a0f14a3815c04df5a55763823d4898)) + +# [1.2.0-next.3](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.0-next.2...v1.2.0-next.3) (2024-06-06) + + +### Features + +* User Interest ([#170](https://github.com/rdkcentral/firebolt-apis/issues/170)) ([48a1094](https://github.com/rdkcentral/firebolt-apis/commit/48a1094aaab6418f09db662dbc81f090a34f32ed)) + # [1.2.0-next.2](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.0-next.1...v1.2.0-next.2) (2024-04-08) diff --git a/package-lock.json b/package-lock.json index 173940cab..49a4e0873 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,17 @@ { "name": "@firebolt-js/sdks", - "version": "1.2.0-next.2", + "version": "1.3.0-next.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@firebolt-js/sdks", - "version": "1.2.0-next.2", + "version": "1.3.0-next.1", "license": "Apache-2.0", "workspaces": [ "src/sdks/core", - "src/sdks/manage" + "src/sdks/manage", + "src/sdks/discovery" ], "bin": { "firebolt-version": "src/js/version.mjs" @@ -18,7 +19,7 @@ "devDependencies": { "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", - "@firebolt-js/openrpc": "3.0.0-next.3", + "@firebolt-js/openrpc": "3.0.0", "@firebolt-js/schemas": "2.0.0", "@saithodev/semantic-release-backmerge": "^3.2.0", "@semantic-release/changelog": "^6.0.1", @@ -1065,18 +1066,22 @@ "node": ">=8" } }, + "node_modules/@firebolt-js/discovery-sdk": { + "resolved": "src/sdks/discovery", + "link": true + }, "node_modules/@firebolt-js/manage-sdk": { "resolved": "src/sdks/manage", "link": true }, "node_modules/@firebolt-js/openrpc": { - "version": "3.0.0-next.3", - "resolved": "https://registry.npmjs.org/@firebolt-js/openrpc/-/openrpc-3.0.0-next.3.tgz", - "integrity": "sha512-hhNtHIpNwwN99Zd4ZABnQ3MIEMPYDN5rSZPNad4ah4R5rmLypWv79vfHSPYeCrTTmoQCwwCFhpObjhJk0EVX/g==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@firebolt-js/openrpc/-/openrpc-3.0.0.tgz", + "integrity": "sha512-oHRHsIGoVFYYwGJwlY5BMaI8pEi2cd96JHcPX3SaB7ehbyI//v3QwJTcNKmvuUzTnqJzP0pEbHjgCnG+AZIvbg==", "dev": true, "dependencies": { - "ajv": "^8.3.0", - "ajv-formats": "^2.1.0", + "ajv": "^8.12.0", + "ajv-formats": "^2.1.1", "array.prototype.groupby": "^1.1.0", "crocks": "^0.12.4", "deepmerge": "^4.2.2", @@ -1098,15 +1103,15 @@ "dev": true }, "node_modules/@firebolt-js/openrpc/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.16.0.tgz", + "integrity": "sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==", "dev": true, "dependencies": { - "fast-deep-equal": "^3.1.1", + "fast-deep-equal": "^3.1.3", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" + "uri-js": "^4.4.1" }, "funding": { "type": "github", @@ -16669,9 +16674,9 @@ } }, "node_modules/web-streams-polyfill": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", - "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", "dev": true, "engines": { "node": ">= 8" @@ -16951,6 +16956,17 @@ }, "src/sdks/core": { "name": "@firebolt-js/sdk", + "version": "1.2.0-next.5", + "license": "Apache-2.0", + "devDependencies": { + "jest": "^28.1.0", + "jest-environment-jsdom": "^28.1.3", + "prettier": "^3.1.0", + "typescript": "^4.6.4" + } + }, + "src/sdks/discovery": { + "name": "@firebolt-js/discovery-sdk", "version": "1.2.0-next.2", "license": "Apache-2.0", "devDependencies": { @@ -16962,7 +16978,7 @@ }, "src/sdks/manage": { "name": "@firebolt-js/manage-sdk", - "version": "1.2.0-next.2", + "version": "1.2.0-next.5", "license": "Apache-2.0", "devDependencies": { "jest": "^28.1.0", diff --git a/package.json b/package.json index f019e95da..a4400e2f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/sdks", - "version": "1.2.0-next.2", + "version": "1.3.0-next.1", "description": "The Firebolt JS SDK", "type": "module", "bin": { @@ -8,14 +8,15 @@ }, "workspaces": [ "src/sdks/core", - "src/sdks/manage" + "src/sdks/manage", + "src/sdks/discovery" ], "scripts": { "fs:setup": "npm run clean && mkdir -p dist", - "validate:each": "npx firebolt-openrpc validate --input src/openrpc --schemas node_modules/@firebolt-js/schemas/src/schemas --schemas src/schemas --transformations", - "validate:compiled": "npx firebolt-openrpc validate --input dist/firebolt-open-rpc.json && npm run validate --workspaces", + "validate:each": "npx firebolt-openrpc validate --input src/openrpc --schemas src/schemas --transformations", + "validate:compiled": "npx firebolt-openrpc validate --input dist/firebolt-open-rpc.json --pass-throughs && npm run validate --workspaces", "validate": "npm run validate:each && npm run validate:compiled ", - "compile": "npx firebolt-openrpc openrpc --input src --template src/template/openrpc/template.json --output ./dist/firebolt-open-rpc.json --schemas node_modules/@firebolt-js/schemas/src/schemas --schemas src/schemas", + "compile": "npx firebolt-openrpc openrpc --input src --template src/template/openrpc/template.json --output ./dist/firebolt-open-rpc.json --schemas src/schemas", "slice": "npm run slice --workspaces", "sdks": "npm run sdk --workspaces", "docs": "npm run docs --workspaces", @@ -44,7 +45,7 @@ "devDependencies": { "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", - "@firebolt-js/openrpc": "3.0.0-next.3", + "@firebolt-js/openrpc": "3.0.0", "@firebolt-js/schemas": "2.0.0", "@saithodev/semantic-release-backmerge": "^3.2.0", "@semantic-release/changelog": "^6.0.1", diff --git a/requirements/images/specifications/general/capabilities/image1.png b/requirements/images/specifications/general/capabilities/image1.png new file mode 100644 index 000000000..049fc70bf Binary files /dev/null and b/requirements/images/specifications/general/capabilities/image1.png differ diff --git a/requirements/images/specifications/general/capabilities/image2.png b/requirements/images/specifications/general/capabilities/image2.png new file mode 100644 index 000000000..7c0c10f7c Binary files /dev/null and b/requirements/images/specifications/general/capabilities/image2.png differ diff --git a/requirements/images/specifications/general/capabilities/image4.png b/requirements/images/specifications/general/capabilities/image4.png new file mode 100644 index 000000000..641c26847 Binary files /dev/null and b/requirements/images/specifications/general/capabilities/image4.png differ diff --git a/requirements/images/specifications/general/capabilities/user-grants/image1.png b/requirements/images/specifications/general/capabilities/user-grants/image1.png new file mode 100644 index 000000000..c836daebf Binary files /dev/null and b/requirements/images/specifications/general/capabilities/user-grants/image1.png differ diff --git a/requirements/images/specifications/general/capabilities/user-grants/image2.png b/requirements/images/specifications/general/capabilities/user-grants/image2.png new file mode 100644 index 000000000..bc0c978ea Binary files /dev/null and b/requirements/images/specifications/general/capabilities/user-grants/image2.png differ diff --git a/requirements/images/specifications/general/capabilities/user-grants/image3.png b/requirements/images/specifications/general/capabilities/user-grants/image3.png new file mode 100644 index 000000000..96d73b0ab Binary files /dev/null and b/requirements/images/specifications/general/capabilities/user-grants/image3.png differ diff --git a/requirements/images/specifications/general/capabilities/user-grants/image4.png b/requirements/images/specifications/general/capabilities/user-grants/image4.png new file mode 100644 index 000000000..0c9246bce Binary files /dev/null and b/requirements/images/specifications/general/capabilities/user-grants/image4.png differ diff --git a/requirements/images/specifications/general/capabilities/user-grants/image5.png b/requirements/images/specifications/general/capabilities/user-grants/image5.png new file mode 100644 index 000000000..26c583d2d Binary files /dev/null and b/requirements/images/specifications/general/capabilities/user-grants/image5.png differ diff --git a/requirements/images/specifications/general/capabilities/user-grants/image6.png b/requirements/images/specifications/general/capabilities/user-grants/image6.png new file mode 100644 index 000000000..4761e5ea4 Binary files /dev/null and b/requirements/images/specifications/general/capabilities/user-grants/image6.png differ diff --git a/requirements/images/specifications/general/capabilities/user-grants/image7.png b/requirements/images/specifications/general/capabilities/user-grants/image7.png new file mode 100644 index 000000000..0b09b1b76 Binary files /dev/null and b/requirements/images/specifications/general/capabilities/user-grants/image7.png differ diff --git a/requirements/images/specifications/intents/user-interest/media/image1.png b/requirements/images/specifications/intents/user-interest/media/image1.png new file mode 100644 index 000000000..b0171a9a4 Binary files /dev/null and b/requirements/images/specifications/intents/user-interest/media/image1.png differ diff --git a/requirements/images/specifications/intents/user-interest/media/image2.png b/requirements/images/specifications/intents/user-interest/media/image2.png new file mode 100644 index 000000000..94102a60f Binary files /dev/null and b/requirements/images/specifications/intents/user-interest/media/image2.png differ diff --git a/requirements/images/specifications/intents/user-interest/media/image3.png b/requirements/images/specifications/intents/user-interest/media/image3.png new file mode 100644 index 000000000..c7ddb6405 Binary files /dev/null and b/requirements/images/specifications/intents/user-interest/media/image3.png differ diff --git a/requirements/images/specifications/intents/user-interest/media/image4.png b/requirements/images/specifications/intents/user-interest/media/image4.png new file mode 100644 index 000000000..6a15fe0c6 Binary files /dev/null and b/requirements/images/specifications/intents/user-interest/media/image4.png differ diff --git a/requirements/specifications/discovery/user-interest.md b/requirements/specifications/discovery/user-interest.md new file mode 100644 index 000000000..f53e239ba --- /dev/null +++ b/requirements/specifications/discovery/user-interest.md @@ -0,0 +1,361 @@ +# User Interest + +Document Status: Candidate Specification + +See [Firebolt Requirements Governance](../../governance.md) for more info. + +| Contributor | Organization | +| -------------- | -------------- | +| Eugene Chung | Comcast | +| Tim Dibben | Sky | +| Mike Horwitz | Comcast | +| Jeremy LaCivita | Comcast | + +## 1. Overview + +In additional to traditional discovery APIs such as Watch History and +Watch Next, Firebolt provides a more abstract API that facilitates +impromptu content discovery connections between first-party Aggregated +Experiences and third-party Apps. + +The User Interest Capability enables Apps to provide meta-data on +content that the user has expressed an interest in to Aggregated +Experience Apps that have been given access to use this Capability. + +This allows for open ended design of Aggregated Experience App features +that present App-specific content to re-engage the user with the content +inside the originating App. + +While the functionality and UX is left to the Aggregated Experience App, +typically designed by each Firebolt Distributor, the Firebolt API +enables events to register user interest and pass entity meta-data: + +![Diagram Description automatically +generated](../../../requirements/images/specifications/intents/user-interest/media/image1.png) + +Which generally enables Aggregated Experiences to present that entity +meta-data in some way that leads to re-launching the original App at a +later point, using a `navigateTo` notification: + +![Diagram Description automatically +generated](../../../requirements/images/specifications/intents/user-interest/media/image2.png) + +This is just one example of what an Aggregated Experience App might do +with the User Interest API. + +Note that this API **SHOULD NOT** be used to implement Watch History or +Watch Next features. These concepts are much more fundamental to +Firebolt and have explicit APIs so that Firebolt Distributors can keep +track of which apps are using them separately. + +## 2. Table of Contents +- [1. Overview](#1-overview) +- [2. Table of Contents](#2-table-of-contents) +- [3. User Interest Flows](#3-user-interest-flows) + - [3.1. User Interest from an in-app UX](#31-user-interest-from-an-in-app-ux) + - [3.2. User Interest from a platform UX](#32-user-interest-from-a-platform-ux) + - [User Interest Errors](#user-interest-errors) + - [3.3. Upstream User Interest Intent](#33-upstream-user-interest-intent) + - [3.4. User Interest Bulk Updates](#34-user-interest-bulk-updates) +- [4. Core SDK APIs](#4-core-sdk-apis) + - [4.1. InterestType](#41-interesttype) + - [4.2. InterestReason](#42-interestreason) + - [4.3. Discovery.userInterest](#43-discoveryuserinterest) + - [4.4. Discovery Interest Provider](#44-discovery-interest-provider) + - [4.5. InterestIntent](#45-interestintent) +- [5. Discovery SDK APIs](#5-discovery-sdk-apis) + - [5.1. Interest Types](#51-interest-types) + - [5.2. Content.requestUserInterest](#52-contentrequestuserinterest) + - [5.3. Content.onUserInterest](#53-contentonuserinterest) + + +## 3. User Interest Flows +### 3.1. User Interest from an in-app UX + +Some Apps will have a built-in user interface for users to express +interest in content from the App. This could be a "Favorite" button, +an in-app "My List" button, etc. + +If the App wants to leverage any additional exposure from the device's +Aggregated Experience, it can wire up its own UI to the Firebolt User +Interest API, in addition to any in-app features that it's already +invoking. + +By calling the `Discovery.userInterest` method with the relevant entity +meta-data, the device's Aggregated Experience will be notified of the +user's interest in that entity: + +```typescript +Discovery.userInterest(type: InterestType, reason: InterestReason, entity: EntityDetails) +``` + +The `type` parameter denotes the directionality of the interest: + +- `interest` +- `disinterest` + +The `reason` parameter denotes why or how the user has expressed interest: + +| Reason | Description | +| ------ | ----------- | +| `playlist` | Interested in adding to a list | +| `reaction` | Interested in submitting a reaction, e.g. like or dislike | +| `recording` | Interest in scheduling a recording | +| `share` | Interest in sharing the content on social media | + +**NOTE**: We can remove some of these (not `playlist`) these are here for now to illustrate the purpose for the reason paramater. + +An app **MUST** `provide` the `xrn:firebolt:capability:discovery:interest` +capability in order to call `Discovery.userInterest`. + +When this method is called with a valid `EntityDetails`, the platform +**MUST** dispatch a `Content.onUserInterest` notification to all Apps +that have registered for it (typically Aggregated Experience Apps) with +information about the app, interest type, and the entity. + +The `Content.onUserInterest` event has a result type of `Interest`: + +| property | type | description | +|---------|------|-------------| +| appId | string | The id of the app that pushed the user interest. | +| type | `InterestType` | the type of interest. | +| reason | `InterestReason` | the reason for the interest | +| entity | `EntityDetails` | The entity the user expressed interest in. | + +An Aggregated Experience can register for the `Content.onUserInterest` +notification, and it will receive notifications when an `EntityDetails` is +returned from the active App after a `Discovery.userInterest` call is +fulfilled. + +An app **MUST** have permissions to `use` the +`xrn:firebolt:capability:discovery:interest` capability in order to +listen to the `Content.onUserInterest` notification. + +If the result is not a valid entity, i.e. does not match +the [EntityDetails](../entities/) schema, then no `Content.onUserInterest` +notification will be dispatched. + +The `Discovery.userInterest` method **SHOULD NOT** be used in place of more +specific Discovery methods, e.g. `Discovery.watchNext` or +`Discovery.watched`. These methods facilitate specific UX flows that may +have separate legal opt-outs for each user. + +The `Discovery.userInterest` method **SHOULD NOT** be called unless the user +is activating a UI element in the app, or in a second screen experience +that is communicating with the app, that implies interest of some kind. + +### 3.2. User Interest from a platform UX + +Firebolt platforms may provide a platform UX, e.g. voice or and RCU, to +express user interest in content from an active App. To facilitate this +Apps will need to be told about the user's expressed interest in their +content. + +First, the Aggregated Experience (or some app with this +capability) detects that the user is interested in something. In this +picture the interest is triggered by an RCU button, but how this occurs +is outside the scope of this document. When this happens, the Aggregated +Experience app calls `Content.requestUserInterest()`, which will trigger the +platform to identify the best [Provider Candidate](../openrpc-extensions/app-passthrough-apis.md#5-provider-candidates) +and call that app's `userInterest` method via the Provider RPC method: +`Discovery.onRequestUserInterest`. + +![](../../../requirements/images/specifications/intents/user-interest/media/image3.png) + +Next, the provider app receives and responds to the request with an +EntityDetails, which is returned as the result to the pending +`Content.requestUserInterest` method: + +![](../../../requirements/images/specifications/intents/user-interest/media/image4.png) + +Once an App's callback is invoked, that app will have `interestTimeout` +milliseconds to return a value or throw an error. Values returned after +that time **MUST** be ignored. The timeout value is stored in the +device's configuration manifest. + +To be notified when a user expresses interest in the currently displayed +content, an App **MUST** provide the +`xrn:firebolt:capability:discovery:interest` capability by enabling the +`Discovery.onRequestUserInterest` notification. + +If there is a valid entity to return, then the method registered by the +App **MUST** return the currently displayed entity meta-data. + +If there is no valid entity to return, then the method **MUST** throw an +exception. + +If the provider app returns a valid `EntityDetails` before the timeout, +then, the returned value **MUST** be used. + +If there is no app registered the an error **MUST** be returned. + +#### User Interest Errors +An app is expected return either a valid result or an appriate error. + +If neither happens before `interestTimeout` expires then the platform **MUST** return a Provider timed-out error: + +```json +{ + "id": 1, + "error": { + "code": -50400, + "message": "Provider timed-out", + "data": { + "capability": "xrn:firebolt:capability:discovery:interest", + } + } +} +``` + +If an app recieves a request for user interest when there is nothing appropriate to return, e.g. nothing selected or presented that maps to an Entity, then the app **SHOULD** return an error with a valid JSON-RPC error response, e.g.: + +```json +{ + "id": 1, + "error": { + "code": -40400, + "message": "No entities currently presented." + } +} +``` + +The platform API Gateway **MUST** append, or overwrite, the `data.capability` value to any errors returned by the app, e.g.: + +```json +{ + "id": 1, + "error": { + "code": -40400, + "message": "No entities currently presented.", + "data": { + "capability": "xrn:firebolt:capability:discovery:interest", + } + } +} +``` + +### 3.3. Upstream User Interest Intent +In some cases, e.g. a voice assistant, some upstream component will inform +the platform that the user is interested in whatever is currently being presented. + +To do this, the upstream system **MUST** send a `Interest` intent, which describes the type of and reason for the interest. + +```json +{ + "action": "interest", + "data": { + "type": "interest", + "reason": "playlist" + } +} +``` + +When a Firebolt platform receives this intent, it **SHOULD** initiate the platform's [user interest flow](#4-user-interest-from-a-platform-ux). + +### 3.4. User Interest Bulk Updates + +Sending bulk interest updates, e.g. Entities the user expressed interest +in on a different platform, is not supported. + +## 4. Core SDK APIs + +The following APIs are exposed by the Firebolt Core SDK as part of the +`Discovery` module. + +### 4.1. InterestType +This is an enum with the following values: + +- `"interest"` +- `"disinterest"` + +### 4.2. InterestReason +This is an enum with the following values: + +| Reason | Description | +| ------ | ----------- | +| `playlist` | Interested in adding to a list | +| `reaction` | Interested in submitting a reaction, e.g. like or dislike | +| `recording` | Interest in scheduling a recording | +| `share` | Interest in sharing the content on social media | + +### 4.3. Discovery.userInterest + +This is a push API that allows Apps to push entities that the user has +expressed interest in to the platform. + +To push an entity that the user is interested in pass an `EntityDetails` +object to the method: + +```typescript +Discovery.userInterest(type: InterestType, reason: InterestReason, entity: EntityDetails): Promise +``` + +### 4.4. Discovery Interest Provider +To respond to requests for the current entity, because the user has +expressed interest in some way that the platform manages, register a +provider: + +```typescript +interface IDiscoveryInterestProvider { + function userInterest(type: InterestType, reason: InterestReason): Promise +} + +Discovery.provide("xrn:firbolt:capability:discovery:interest", IDiscoveryInterestProvider) +``` + +### 4.5. InterestIntent + +An `InterestIntent` denotes that the user has expressed interest in the +currently displayed and/or selected content: + +```typescript +type InterestIntent { + action: "interest" + data: { + type: "interest" | "disinterest", + reason: "playlist" | "reaction" | "recording" + }, + context: { + source: "rcu" | "voice" + } +} +``` + +## 5. Discovery SDK APIs + +The following APIs are exposed by the Firebolt Discovery SDK as part of the +`Content` module. + +### 5.1. Interest Types +This type stores the various attributes of an Interest response or event: + +```typescript +type InterestType = "interest" | "disinterest" +type InterestReason = "playlist" | "reaction" | "recording" | "share" + +type Interest { + appId: string + entity: EntityDetails + type?: InterestType + reason?: InterestReason +} +``` + +### 5.2. Content.requestUserInterest +This method triggers the corresponding Discovery provider API for the +provider app. + +```typescript +Content.requestUserInterest(type: InterestType, reason: InterestReason): Promise +``` + +### 5.3. Content.onUserInterest + +This notification allows Aggregated Experience Apps to be informed when +a user expresses interest in some Content, and the content resolves to a +valid Entity from some App. + +`Content.listen('userInterest', Interest => void): Promise` + +The callback will be passed an `Interest` object with +the appId, type, reason, and information about the entity that the user expressed interest in. diff --git a/requirements/specifications/general/capabilities/capabilities.md b/requirements/specifications/general/capabilities/capabilities.md new file mode 100644 index 000000000..30430ec06 --- /dev/null +++ b/requirements/specifications/general/capabilities/capabilities.md @@ -0,0 +1,660 @@ +# Capabilities + +Document Status: Candidate Specification + +See [Firebolt Requirements Governance](../../../governance.md) for more info. + +| Contributor | Organization | +| -------------- | -------------- | +| Andrew Bennett | Sky | +| Tim Dibben | Sky | +| Jeremy LaCivita | Comcast | +| Kevin Pearson | Comcast | +| Peter Yu | Comcast | + +## 1. Overview + +This document introduces Firebolt Capabilities, which enable discovery +of supported features, negotiation of App permissions, and end-user +grants for Apps to access sensitive features. + +Apps can detect if Capabilities are supported and available. If so, Apps +can **Use**, **Provide**, or **Manage** capabilities that they are given +access to. + +The most common case is for an App to `use` a Capability, the platform +to `provide` it, and the Distributor\'s Settings App to `manage` it: + +![Diagram Description automatically +generated](../../../images/specifications/general/capabilities/image1.png) + +However, Apps may also provide Capabilities back to the platform: + +![Diagram Description automatically +generated](../../../images/specifications/general/capabilities/image2.png) + +## 2. Table of Contents +- [1. Overview](#1-overview) +- [2. Table of Contents](#2-table-of-contents) +- [3. Introduction to Capabilities](#3-introduction-to-capabilities) + - [3.1. Capabilities](#31-capabilities) + - [3.2. Availability](#32-availability) + - [3.3. Permissions](#33-permissions) + - [3.4. Roles](#34-roles) + - [3.5. User Grants](#35-user-grants) +- [4. How Capabilities Work](#4-how-capabilities-work) + - [4.1. Supported Capabilities](#41-supported-capabilities) + - [4.2. Available Capabilities](#42-available-capabilities) + - [4.3. Permitted Capabilities](#43-permitted-capabilities) + - [4.4. User Granted Capabilities](#44-user-granted-capabilities) + - [4.5. Invoking Capabilities](#45-invoking-capabilities) +- [5. Configuring Device Capabilities](#5-configuring-device-capabilities) + - [5.1. Device Supported Capabilities](#51-device-supported-capabilities) + - [5.2. Device Grant Policy Overrides](#52-device-grant-policy-overrides) +- [6. Capability Schemas](#6-capability-schemas) + - [6.1. Firebolt Specification Manifest](#61-firebolt-specification-manifest) + - [6.2. Firebolt Device Manifest](#62-firebolt-device-manifest) +- [7. Capability to Feature Mapping](#7-capability-to-feature-mapping) + - [7.1. App installation](#71-app-installation) + - [7.2. Firebolt APIs](#72-firebolt-apis) + - [7.3. Extension APIs](#73-extension-apis) + - [7.4. Hidden Permissions](#74-hidden-permissions) +- [8. Firebolt Capability Catalog](#8-firebolt-capability-catalog) +- [9. APIs](#9-apis) + - [9.1. Core SDK APIs](#91-core-sdk-apis) + - [9.2. Manage SDK APIs](#92-manage-sdk-apis) + +## 3. Introduction to Capabilities + +This section is non-normative and defines the key concepts behind the +Firebolt Capabilities system. Each portion of this section provides a +background and conversational definitions of the terms used in the rest +of this document, and through all Firebolt Requirements Specifications. + +### 3.1. Capabilities + +A Capability is a discrete unit of functionality that a Firebolt device +might be able to perform. It is granular enough to enable appropriate +access controls across all Firebolt Apps, but useful enough to be a +meaningful functional unit that an App might care about. Bluetooth is a +good example of a Capability. + +The Firebolt Specification determines the range of possible +Capabilities. + +Firebolt platforms advertise which Capabilities are supported. The set +of capabilities supported by a device is an immutable set and will never +change at runtime. Supporting Wi-Fi and having an active Wi-Fi +connection are two different things. + +Firebolt platforms determine if an App is allowed to invoke the +different aspects of a Capability (see [Roles](#roles), below). + +Firebolt Apps list which Capabilities are required and optional for the +App to be installed. + +Firebolt Apps inspect which Capabilities are supported and active. + +Firebolt Distributors sign off on some, or all, of the App's listed +required and optional Capabilities. + +### 3.2. Availability + +A Capability may rely on intermittently available resources, for example +a network capability requires an Ethernet or Wi-Fi network connection. + +A supported capability is only considered available if those resources +could be used by the App right now (without taking into account any needed permissions or [User Grants](#user-grants)). For example, the needed +resources are not disabled, not tied up by the platform, and not experiencing +any intermittent network, hardware, or signal issues. + +A supported capability is always supported, but it may not always be +*available*. + +Availability of a capability is a global status, not a per-app status. + +If a Capability is available, then it is considered available globally. +Capabilities can not be available to one app, while simultaneously being +unavailable to another app. This is handled by permissions, or by +capability-specific error management, e.g. returning an error to an app that +attempts to use the video pipeline while in the Inactive Lifecycle state. + +### 3.3. Permissions + +A Permission is what allows an App to attempt to invoke an aspect of a +Capability. Permissions to a Capability are assigned to an App with a +[Role](#roles), by a Firebolt Distributor. + +Firebolt documents and APIs will use the term "Permission" +interchangeably with phrases like: + +- An App's Assigned Role for a Capability + +- App + Capability + Role + +- Etc. + +The Firebolt Specification determines which Capabilities require +Permissions. + +The Firebolt Specification determines which Permission requirements may +be overridden by Distributors. + +An App is considered to have Permission to a Capability if it is: + +- Listed with a Role in the App's manifest and signed by the App + provider + +- Listed and signed again by the Distributor on the App's behalf + +- Listed and signed by the App Publisher when running in self-signed developer + mode + +An App can invoke a Capability if: + +- It has permission, which includes a Role, for that capability + +- The capability is supported by the current device + +- The App is invoking aspects of the capability that it has the + appropriate Role for + +- The capability is [Available](#availability) at time of invocation + +See [Permitted Capabilities](#permitted-capabilities) for more info. + +### 3.4. Roles + +Every Firebolt Capability has exactly three roles: + +- Use + +- Manage + +- Provide + +While these roles will be defined on a case-by-case basis for each +capability, they should generally follow the guidelines set here. + +The `Use` role is for providing basic access so that an App can leverage +the standard use cases of the Capability. The `Use` role will not enable +an App to perform management tasks such as turning the Capability on and +off for the entire device. The `Use` role will not enable an App to +perform administrative tasks such as renaming HDMI inputs, etc. + +The `Manage` role is for providing access to a Capability's management +and administrative features. This role may be used to allow an App to +build a Settings UI for the Capability, for example. The `Manage` role +is not for creating tiers of permissions within a Capability, but for +separating out administrative APIs, for example turning a feature on and +off. + +Most Capabilities are provided by the platform, denoted by making the +`Provide` role `private` for that Capability. However, there are use +cases where Apps may provide Capabilities. The `Provide` role allows for +declaring that an App *implements* the Capability and can be registered +with the platform for fulfilling the Capability's features. This could +be used for functionality that needs to be customized from Distributor +to Distributor. The `Provide` role may also be used to allow Apps to +contribute to aggregated functionality, for example a federated search +feature. By providing a capability, an App is signing up to implement +any `Use` or `Manage` APIs required by that capability. + +Each role must be explicitly assigned. An App *never* inherits the +operations from one role by virtue of being granted another. Roles may +have overlapping functionality. + +A [Permission](#permissions) is the combination of a Capability w/ a +Role and determines which specific operations are permitted. + +### 3.5. User Grants + +A User Grant allows some Permissions to depend on the User of the +Firebolt Device to explicitly grant access for one or all Apps to use a +specific Capability. This an additional layer of access control on top +of Permissions. + +The Firebolt Specification determines which Permissions require User +Grants by default. + +It is not possible to require a User Grant for a Capability that is open +to all Apps. + +Distributors may override any User Grant details that are defined by the +Firebolt Specification if that User Grant Policy is set to +`overridable: true`. + +Consumers want to know that their Smart TV platform treats +security as a first-class design principal. As such, table-stakes User +Grant policies, e.g. App access to Bluetooth, may be denoted as +overridable: false in the Firebolt Specification, to remove any +possibility of a security flaw. + +An App is considered to have a User Grant to a Capability if it: + +- Has Permission to the Capability + +- The User Grant is for the same Role as the Permission above + +- The Capability is **securely** approved by the device user + +If an App invokes a Capability but does not have an active User Grant, +then the platform will block invocation, prompt the user for a grant, +and then continue with the original invocation, e.g. the App does not +have to call the originating API again (assuming the user did give their +approval). + +See [User Granted Capabilities](#user-granted-capabilities) for more +info. + +## 4. How Capabilities Work + +A given Capability may or may not be supported or available. +Additionally, a given Role may or may not be permitted or granted for a +given Capability. + +While support and availability of a Capability is static and global, the +permission and grant status may differ from App to App. + +Determining the status of a Role and Capability is fundamental to +both the Platform and the Apps that run on it. + +### 4.1. Supported Capabilities + +Once an App has been launched, it may need to check if a certain +capability is supported to present the appropriate user experience. For +example, an App may want to put Dolby Atmos badges next to its content, +but only if the platform supports Dolby Atmos. + +The Firebolt Specification determines which capabilities **MUST** be +supported by all Firebolt Devices, by listing those Capabilities in the +[Firebolt Specification Schema](#61-firebolt-specification-schema) as `level: "must"` in the Capabilities +array. + +For a capability to be supported, it **MUST** have *one* or *both* of +the following: + +> A supported capability **MUST** have the necessary hardware and +> software to invoke all required aspects of all Roles of the +> capability. +> +> **OR** +> +> A supported capability **MUST** have the necessary hardware and +> software to support a *certified*, after-market peripheral that +> provides the capability. Note that this includes peripherals that have +> not yet been connected to or installed on the device. + +However, a Firebolt device **MUST NOT** be considered to support a +capability if the capability is disabled by the static distributor +configuration. + +The platform **MUST** return accurate responses based on these +requirements to all [APIs](#apis) outlined below. + +### 4.2. Available Capabilities + +Once an App has been launched, it may need to check if a certain +capability is available, to start the appropriate user experience. For +example, an App that uses an external camera may need to check if the +user has set up their camera before proceeding to the main user +experience. + +A Capability is available if **all** the following are true: + +> An available Capability **MUST** be supported. +> +> An available Capability **MUST** have a provider, either an App, an +> Extension SDK, or the OS itself. +> +> The provider of the Capability **MUST** consider it to be available +> +> An available Capability **MUST NOT** be currently disabled by any +> user, account, or device setting. +> +> An available Capability **MUST** be considered available by at least +> one provider of the capability. This is specified by the requirements +> for each feature. + +An available Capability **MAY** be tied to a User Grant, regardless of +whether the user has granted it yet. Secure user grants gate permission, +not availability. + +The platform **MUST** return accurate responses based on these +requirements to all [APIs](#apis) outlined below. + +### 4.3. Permitted Capabilities + +Capabilities may be permitted to *all* Apps by the [Firebolt +Specification Schema](../../firebolt-specification.json), or to individual Apps by the Distributor-signed +App Manifest. + +An App may need to know if a Capability is permitted to it once it has +been launched. For example, it may need to check if a certain capability +is permitted, to enable the correct features for the current +distributor. For example, an App that has just been installed might not +show a Returns true for capability/role combinations that do not r +Sign-up option when running on a distributor that has not allowed it to +`use` the `commerce:subscribe` capability, and only allow existing users +to sign in. + +Determining if a Capability is permitted requires knowing which **Role** +is being leveraged. + +Permitted capabilities **MUST** be denoted as `public` in the Specification Schema](#61-firebolt-specification-schema). + +Additionally, **one** of the following **MUST** be true as well: + +> The Role **MUST** have `negotiable` set to `false` +> +> **OR** +> +> The Role **MUST** be approved for the capability by the distributor in +> the App Manifest + +A permitted Capability **MAY** be tied to a User Grant, regardless of +whether the user has granted it yet. + +The platform **MUST** return accurate responses based on these +requirements to all [APIs](#apis) outlined below. + +### 4.4. User Granted Capabilities + +Some Capabilities may require a User Grant. It is the App's choice +whether it requests these grants at launch or allows the platform to +interrupt the App's experience when User Grant-gated Capabilities are +invoked. + +Determining if a Capability has been granted by the user requires +knowing which Role is being used. + +For a Capability to be considered granted, it **MUST** be supported. + +Additionally, a Capability + Role is granted to an App if **one** of the +following is true: + +> A granted capability **MUST** have the Role securely granted to the +> App by the user and that grant must not be expired. +> +> **OR** +> +> A granted capability **MUST** have the Role permanently granted to the +> App by the App Manifest, e.g., if the user implicitly granted these by +> virtue of an end user license agreement. + +Firebolt platforms **MUST** support acquiring a user grant *at the +moment the Capability is invoked*, without requiring any reinvocation of +the Capability. + +See [User Grants](./user-grants.md), for more info. + +The platform **MUST** return accurate responses based on these +requirements to all [APIs](#apis) outlined below. + +### 4.5. Invoking Capabilities + +When invoking a Capability, there are several factors that determine +whether the calling App will be allowed. The primary factor is which +Role is being leveraged by the invocation. + +A given Capability & Role can be public or not, and it can be negotiable +or not. + +If a Role for a Capability is public and non-negotiable, then all Apps +are allowed to invoke it, without any explicit permission from the +platform distributor. This is subject to support, availability, and any +required User Grants. + +If a Role for a Capability is public and negotiable, then Apps **MUST** +be permitted by each distributor to use it on that distributor\'s +devices. + +If a Role for a Capability is private, then it **MUST NOT** be permitted +or granted to any Apps. + +A Role for a Capability **MUST NOT** be flagged as negotiable if it is +private. + +If a Capability is gated by a User Grant requirement, then any +invocation **MUST** check the grant status for the Role in question, and +potentially re-acquire a User Grant for the App to invoke it. + +The following flow diagrams show the order of operations for determining +if a Firebolt API, that depends on one or more capabilities, may be +invoked. The checks in this diagram **MUST** be executed in this order +to ensure that error codes are consistent and User Grant prompts are not +displayed to end users in situations where the API call will still not +be allowed for other reasons. + +![](../../../images/specifications/general/capabilities/image4.png) + +Note that determining user grants may involve presenting a UX to the end +user. During this time, a necessary capability may become unavailable. +Due to this, necessary Capabilities MUST be reevaluated for availability +after determining user grant status. For a more detailed flow diagram +for evaluating User Grants, see [User Grants](./user-grants.md). + +## 5. Configuring Device Capabilities + +The Firebolt Specification describes all the possible, non-Extension +capabilities that a particular version of Firebolt allows. Individual +Firebolt devices, however, may not support every Capability and may want +to override certain aspects of those Capabilities. + +Every Firebolt-compliant device **MUST** include an official, versioned +Firebolt JSON configuration that conforms to the Specification Schema](#61-firebolt-specification-schema), so that the implementation +knows how to configure each capability, and which aspects are +overridable. + +Additionally, every Firebolt-compliant device **MUST** have a versioned + +Firebolt Device JSON configuration that conforms to the Firebolt Device +Schema, so that the implementation knows how each capability has been +overridden by the Distributor for this device. + +See [Firebolt Device Schema](#firebolt-device-schema) for more info. + +### 5.1. Device Supported Capabilities + +Firebolt-compliant devices **MUST** list all the Capabilities they +support in the Device Capabilities configuration file\'s `supported` +array. + +The `supported` array **MUST** contain a `CapabilityConfig` for every +Firebolt Capability supported by this device. + +The `supported` array **MUST** contain an entry for every Capability +from the Specification Schema](#61-firebolt-specification-schema) that has a level of `must`. + +The `supported` array **MAY** contain entries for any `should` or +`could` Capabilities. + +The supported array **MUST NOT** contain any entries for Capabilities +not found in the Firebolt Specification Schema. + +### 5.2. Device Grant Policy Overrides + +Firebolt-compliant devices **MAY** override any `GrantPolicies` that +have `overridable` set to `true`. + +This can be used to permanently disable a User Grant + +Firebolt-compliant devices **MUST NOT** override any `GrantPolicies` +that have `overridable` set to `false`. + +`GrantOverrides` are included in the `grantOverrides` array of the +`CapabilityConfig` for the Capability in question. + +If both the Firebolt Specification Schema and the Device Schema have +different, valid overrides for the same capability + appId, then the +device config **MUST** be used by that device. + +## 6. Capability Schemas + +This section describes how Capabilities are represented in the static +Firebolt configuration for a device. + +### 6.1. Firebolt Specification Manifest + +Each version of Firebolt **MUST** have a single Firebolt Specification +Manifest that is the source-of-truth for and contains all possible +capabilities provided, used, or managed by Apps or Firebolt platforms. + ++The Firebolt Specification Manifest **MUST** list all capabilities defined by that version of Firebolt. + +The Firebolt Specification Manifest **MUST** specify whether each capability `must`, `should`, or `could` be implemented by Firebolt devices. + +The Firebolt Specification Manifest **MUST** specify whether each role, i.e. `use`, `manage`, and `provide`, is a `public` permission that apps may call. + +See [Invoking Capabilities](#46-invoking-capabilities), for more info on public and negotiable capabilities. + +The Firebolt Specification Manifest **MUST** include the entire Firebolt OpenRPC specification for all APIs in the 'apis` block. + +The Firebolt Specification Manifest **MUST** specify which major versions of the Firebolt RPC APIs are required for backwards compatibility. + +The [Firebolt Version Manifest JSON-Schema](https://github.com/rdkcentral/firebolt-configuration/blob/main/src/schemas/version-manifest/version-manifest.json) defines the JSON semantics for this file. + +The latest version of the firebolt-specification.json **MUST** be available at this URL: + +``` +http://rdkcentral.github.io/firebolt/requirements/latest/specifications/firebolt-specification.json +``` + +The version of the firebolt-specification.json associated with this document **SHOULD** be available at [../../firebolt-specification.json](../../firebolt-specification.json). + +### 6.2. Firebolt Device Manifest + +Each Firebolt device will have a static configuration for overriding +which capabilities are supported, as well as any negotiable Capability +overrides. + +The Device Manifest **MUST** specify which capabilities the device supports. + +The Device Manfiest **MUST** include every capability from the Firebolt Specification Manifest that has a `level` of `must` in its supported list. + +The Device Manifest **MUST** specify which capabilities have distributor define Grant Policy Overrides. + +The Device Manfiest **MUST NOT** have any Grant Policies that override Grant Policies from the Firebolt Specification Manifest that have `overridable` set to `false`. + +The [Firebolt Device Manifest JSON-Schema](https://github.com/rdkcentral/firebolt-configuration/blob/main/src/schemas/device-manifest/device-manifest.json) defines the JSON semantics for this file. + +## 7. Capability to Feature Mapping + +Capabilities denote functionality, and functionality can manifest in several ways. + +### 7.1. App installation + +Some Apps may not be useful, and may even prove counter to their goals, +if installed on a device without certain capabilities. For example, a +Dolby Vision demonstration App that requires it only be installed on +devices that support Dolby Vision, to avoid playing back lower quality +content that users might mistake for Dolby Vision content. + +If an App includes a capability in one of its App Manifest's `required` +Capability lists: + +- `app.capabilities.used.required` + +- `app.capabilities.managed.required` + +- `app.capabilities.provided.required` + +Then that App **MUST NOT** be installable on Firebolt devices that do +not support that capability. + +Apps that have an unsupported capability inside one of its `optional` +lists **SHOULD NOT** be prevented from installation, unless there is +some other reason outside the scope of this document. + +### 7.2. Firebolt APIs + +Some Firebolt APIs may require the use of one or more Capabilities. +These methods **MUST** have all required Capabilities listed in the method's OpenRPC schema. + +Capabilities are listed in one of three OpenRPC extensions attached to +the `'capabilities' `tag on the method: `x-uses`, `x-manages`, +`x-provides`. + +If a method lists more than one Capability for a role, then it may +specify that those capabilities are either all required, any combination +of them is required, or one and only one is required. The platform **MUST parse any `x-uses-operator` values which will have values of either `allOf`, `anyOf`, or `oneOf`. This value defaults to `allOf` if not specified. An example of +this is an API to find and pair remotes, regardless of which connection +protocol is needed. This API requires `anyOf` `bluetooth:scan`, +`rf4ce:scan`, `wifi:scan`. If one or more of these capabilities is +available (and permitted) then the API will execute using the available +and permitted protocols. The same pattern applies to `x-manages-operator`. The `x-provides` extension only supports a single capability, so this pattern does not extend to providers. + +If a method *requires* a capability, and that capability requires a user +grant that the App does not have, then the platform **MUST** block and +initiate a User Grant flow. Once granted, the platform **MUST** return +the expected value without the App having to reinvoke the API. If not +granted after the User Grant flow, the platform **MUST** return an +error. + +Capabilities that enhance an API, but are not fundamentally required, +for example a `play` API optionally uses the `'hdr:dolbyvision'` +capability, **MUST NOT** be listed in the OpenRPC schema. These are considered *optional* capabilities of the method implementation. + +If a method leverages an *optional* Capability that is unavailable or +unpermitted, it **MUST** leave out or defer the optional functionality. + +If a method leverages an *optional* Capability that requires a user +grant the App does not have, it **MUST** leave out the optional +functionality, and it **MUST NOT** request a user grant. + +### 7.3. Extension APIs + +Extension SDKs implement their methods in the cloud but rely on +Firebolt's Permissions and Capabilities model. + +Requirements for Extension SDKS are outside of the scope of this document. + +### 7.4. Hidden Permissions + +A hidden permission arises when an API requires permission to one +Capability which in turn requires another Capability gated by a +different permission. This is not supported by Firebolt, and all +permission dependencies should be validated to avoid this. + +Firebolt Capabilities **MUST NOT** have hidden permissions. + +For example: + +- API `Module.methodOne()` requires permission to `use` the + `'contrived:capability1'` Capability + +- API `Module.methodTwo()` requires permission to `use` the + `'contrived:capability2'` Capability + +- `methodOne`'s implementation calls `methodTwo` + +There is now a hidden permission: `methodOne` requires both +`capability1` and `capabilty2`. + +Note that it's fine for a method to leverage an ungated, but also +unavailable Capability, such as a DIAL API failing because the network +capability is unavailable. + +## 8. Firebolt Capability Catalog + +Firebolt Capabilities are enumeraged in the [Firebolt Specification Manifest](../../firebolt-specification.json). + +## 9. APIs +All of the APIs below have full OpenRPC schemas in the [Firebolt OpenRPC JSON document](../../../specifications/firebolt-open-rpc.json). + +### 9.1. Core SDK APIs + +Several APIs are exposed by the Firebolt Core SDK as part of the +`Capabilities` module. This module is intended for App +developers to have one place to check for all aspects of "can I do +this." Including supported, available, permitted, and granted +Capabilities. It also provides bulk operations for figuring out which +needed Capabilities are unavailable, in order to wait for them, and +which ones are ungranted, in order to request them. + +### 9.2. Manage SDK APIs + +Several APIs are exposed by the Firebolt Manage SDK as part of the +`UserGrants` module. This module is intended for +Management UIs that show a list of grants per App or Capability, and +allow users to revoke them. diff --git a/requirements/specifications/general/capabilities/user-grants.md b/requirements/specifications/general/capabilities/user-grants.md new file mode 100644 index 000000000..f87342a5c --- /dev/null +++ b/requirements/specifications/general/capabilities/user-grants.md @@ -0,0 +1,593 @@ +# User Grants + +Document status: Candidate Specification + +See [Firebolt Requirements Governance](../../../governance.md) for more info. + +| Contributor | Organization | +| -------------- | -------------- | +| Andrew Bennet | Sky | +| Tim Dibben | Sky | +| Jeremy LaCivita | Comcast | +| Kevin Pearson | Comcast | +| Peter Yu | Comcast | + +## 1. Overview + +This document describes the requirements for Firebolt User Grants. User +Grants enable end-user control over which Apps have access to +potentially sensitive Firebolt Capabilities. For example, a user might +want to explicitly approve of any App attempting to purchase new content +by entering an account-holder PIN on the RCU. + +User Grants are also common when two apps need to share data, for +example, Firebolt has a `Discovery.watched` method that allows apps to +inform Firebolt that a user has finished watching some content. This +method allows an app to **provide** the watch history capability and the +aggregated experience to **use** it. See Firebolt +[Capabilities](./capabilities.md) requirements for more info on the `use` and `provide` roles of a +capability. + +This sort of data exchange involves several parties: minimally the user, +the publisher of the OTT app, and the distributor of the Firebolt +device. Additionally, this exchange could also involve privacy laws of +the user\'s home geo-political state, local I.T. best practices around +PII, or even a particular product\'s public position on their privacy +offering to the market. Because of the importance and complexity of +personal data, Firebolt allows each distributor to configure which +Firebolt capabilities require User Grants and what policies should be +applied to acquiring those grants. + +![Diagram Description automatically +generated](../../../images/specifications/general/capabilities/user-grants/image1.png) + +Distributors can configure what kind of user grant is required for a +particular capability, e.g. a simple acknowledgement of an \"OK\" +button, an account-owner PIN entry, an account-owner three-factor +authentication challenge, etc. + +Distributors can also configure whether certain user grants are opt-in +or opt-out, and whether explicit prompting of the user is required. + +## 2. Table of Contents +- [1. Overview](#1-overview) +- [2. Table of Contents](#2-table-of-contents) +- [3. Introduction to User Grants](#3-introduction-to-user-grants) + - [3.1. Active Grant](#31-active-grant) + - [3.2. Denied Grant](#32-denied-grant) + - [3.3. Unset Grant](#33-unset-grant) + - [3.4. Granting Capability](#34-granting-capability) + - [3.5. Grant Policy](#35-grant-policy) + - [3.6. Privacy Setting](#36-privacy-setting) +- [4. User Grant Requirements](#4-user-grant-requirements) + - [4.1. Granting Capability](#41-granting-capability) + - [4.1.1. Acknowledgement](#411-acknowledgement) + - [4.1.2. Pin Challenge](#412-pin-challenge) + - [4.2. Grant Policy](#42-grant-policy) + - [4.2.1. Grant Requirements](#421-grant-requirements) + - [4.2.2. Grant Lifespan](#422-grant-lifespan) + - [4.2.3. Grant Privacy Setting](#423-grant-privacy-setting) + - [4.3. Distributor Overrides](#43-distributor-overrides) + - [4.4. Application Overrides](#44-application-overrides) +- [5. Grant Execution](#5-grant-execution) + - [5.1. Capability Check](#51-capability-check) + - [5.2. Grant Policy Resolution](#52-grant-policy-resolution) + - [5.3. Active Grant Check](#53-active-grant-check) + - [5.4. Grant Prompt and Resolution](#54-grant-prompt-and-resolution) +- [6. Schemas](#6-schemas) + - [6.1. Grant Policy](#61-grant-policy) + - [6.2. GrantRequirements](#62-grantrequirements) + - [6.3. GrantStep](#63-grantstep) + - [6.4. GrantKey](#64-grantkey) + - [6.4.1. GrantScope](#641-grantscope) + - [6.4.2. GrantLifespan](#642-grantlifespan) + - [6.4.3. PrivacySetting](#643-privacysetting) +- [7. APIs](#7-apis) + - [7.1. Manage SDK APIs](#71-manage-sdk-apis) + - [7.1.1. GrantInfo Object](#711-grantinfo-object) + - [7.1.2. App Method](#712-app-method) + - [7.1.3. Device Method](#713-device-method) + - [7.1.4. Capability Method](#714-capability-method) + - [7.1.5. Grant Method](#715-grant-method) + - [7.1.6. Deny Method](#716-deny-method) + - [7.1.7. Clear Method](#717-clear-method) + + +## 3. Introduction to User Grants + +This section defines the key concepts behind the Firebolt User Grant +system. User Grants build on top of [Firebolt +Capabilities](./capabilities.md). +Since Capabilities are fundamental to user grants, it is recommended to +read the Capabilities requirements first before reading this document. + +Each portion of this section provides a background and conversational +definitions of the terms used in the rest of this document, and through +other Firebolt Requirements Specifications. + +As described in the Overview, a User Grant allows an end user to +explicitly allow (or not allow) an app to use certain Firebolt +Capabilities. Firebolt Distributors need flexibility in configuring +which Capabilities require what types of user interaction, PIN vs +password, etc. + +The following concepts inform how the Firebolt User Grant APIs and +architecture are designed. + +### 3.1. Active Grant + +An **Active Grant** is a User Grant that has already been granted by the +user for a Capability to a specific app (if the Grant Policy is per-app) +or all apps. Active Grants do not need to be granted again (until they +expire) and may be revoked or expire. + +### 3.2. Denied Grant + +A **Denied Grant** is a User Grant that has already been explicitly +*denied* by the user for a Capability to a specific app (if the Grant +Policy is per-app) or all apps. Denied Grants do not need to be denied +again (until they expire) and may be revoked or expire. This serves to +allow the Grant Policy lifetime to be applied to explicit denials as +well. + +### 3.3. Unset Grant + +An **Unset Grant** is a User Grant that has no persisted state. This +could be because the user has never granted or denied it, or because it +was previously granted/denied, but has since expired. Additionally, the +user or platform may clear out an active or denied grant, which results +in this state. + +### 3.4. Granting Capability + +User grants typically require some sort of user experience. Firebolt +delegates display of these user experiences to (typically) first-party +apps, which must provide them as **Granting Capabilities**. Therefore, +it\'s quite possible that using a capability such as watch history +initiates a User Grant request which itself requires another capability, +e.g. the \"acknowledge\" capability, to fulfill the original API. + +In the following diagram, an OTT App is calling an API that would share +watch history data with the 1st party aggregated experience on the +device. This capability is configured with a [Grant +Policy](#grant-policy) (see below) that specifies use of an +Acknowledgement Challenge Capability. the \"Watch History\" capability +is what is being accessed, and the \"Acknowledgement Challenge\" +capability is how this device is configured to grant access to that +capability. Said another way, the Acknowledgement Challenge is the +*Granting Capability*. + +![Diagram Description automatically +generated](../../../images/specifications/general/capabilities/user-grants/image2.png) + +Note that the granting capability UI is provided by another app. The +Provider APIs for each granting capability type are out of scope for +this document. + +A granting capability is generally agnostic to the original capability +that it is helping to grant and can be reused by several capabilities +via a Grant Policy. + +### 3.5. Grant Policy + +A **Grant Policy** ties a set of user grant-related configuration values +to a capability. This allows a Firebolt distributor, or the Firebolt +specification itself, to define the business policy of a particular user +grant. + +Grant Policies specify details like how long the grant lasts and what is +the scope of the grant, e.g. a single app, or all apps. + +### 3.6. Privacy Setting + +A **Privacy Setting** is a link between a Grant Policy and any Firebolt API that is tagged with the Property pattern and returns a +`boolean`. This allows User Grant state to be linked to Privacy Settings +on the device or account. + +![Diagram Description automatically +generated](../../../images/specifications/general/capabilities/user-grants/image3.png) + +How Firebolt devices persist Privacy Settings is outside the scope of +this document. + +## 4. User Grant Requirements + +### 4.1. Granting Capability + +A granting capability **MUST** have the category portion of its +capability key set to `usergrant`. For example: + +`xrn:firebolt:capability:usergrant:acknowledge` + +In order for a granting capability to be available, it **MUST** be +provided by some app that is currently loaded. + +Each granting capability **MUST** have a schema, in the Firebolt +Specification Schema, to validate that any configuration associated with +it is valid. + +#### 4.1.1. Acknowledgement + +The Acknowledgement capability enables a user to acknowledge a user +grant by simply clicking a button. + +This capability has the following key: + +`xrn:firebolt:capability:usergrant:acknowledgechallenge` + +The configuration for this capability is always `null`, i.e., there is +no configuration. + +For more info on how an app can provide the acknowledge capability, see +Acknowledge Provider. **TODO**: add link. + +#### 4.1.2. Pin Challenge + +The Pin Challenge capability enables a user to confirm that they are the +account owner, or a delegate of, by responding to a numeric PIN +challenge. + +This capability has the following key: + +`xrn:firebolt:capability:usergrant:pinchallenge` + +For more info on how an app can provide the acknowledge capability, see +Pin Challenge Provider. **TODO**: add link. + +### 4.2. Grant Policy + +If a Capability is configured with a `GrantPolicy` then the User Grants +specified by the Grant Policy **MUST** be evaluated before a GrantPolicy +llowing access to that Capability. + +A Grant Policy **MUST** have a `scope` for the grant, which determines +whether the user will be granting the capability to the current app or +to all apps. + +A Grant Policy **MUST** have an `overridable` flag that determines if it +may be overridden downstream. For Grant Policies in the Firebolt Version +Manifest, the Device Manifest may override if `overridable` is `true`. +For Grant Policies in the Device Manifest, individual [App +Manifests](https://github.com/rdkcentral/firebolt-configuration/src/schemas/app-manifest/app/app.json) may override the grant if `overridable` is `true`. + +#### 4.2.1. Grant Requirements + +A Grant Policy **MUST** have at least one `GrantRequirements` object, +which itself has a list of zero or more [Granting +Capabilities](#granting-capability) and their configurations. If all the +granting capabilities are supported and available, then they all +**MUST** be invoked. This allows for multiple security checks, e.g. +allow watch history data to be collected if the user has opted into +usage data collection **and** they confirm via an acknowledgement +challenge UI. If one or more of the granting capabilities is not +supported or available, then the entire Grant Requirements block is not +valid for acquiring a user grant. + +A Grant Policy **MAY** have more than one `GrantRequirements` object, +which are ranked in order of preference. This allows for low-friction +but high-security methods to be preferred, e.g. allow in-app purchases +with a passive facial recognition scan, with higher-friction fallbacks +to ensure security on devices with less capabilities, e.g. allow in-app +purchases if the account owner performs a multi-factor authentication +flow. This list of `GrantRequirements` objects is stored in the Grant +Policy\'s `options` field. + +If a Grant Policy has more than one `GrantRequirements` option, then the +highest priority list with all its required capabilities supported and +available **MUST** be used. Note that the app which initiated the +original capability check **does not** need to have permission (or a +grant) to any of the granting capabilities that might be invoked. The +app is not using them, the Firebolt device is using them. + +#### 4.2.2. Grant Lifespan + +A Grant Policy **MUST** have a `lifespan`, which determines how long a +grant is valid for. + +> If the lifespan is set to `once`, then any grant resulting from this +> policy **MUST** be active for a single API transaction. +> +> If the lifespan is set to `forever`, then any grant resulting from +> this policy **MUST** be active until explicitly revoked. +> +> If the lifespan is set to `appActive`, then any grant resulting from +> this policy **MUST** be active until the app goes into one of the +> `inactive`, `suspended`, or `unloading` states. +> +> If the lifespan is set to `powerActive`, then any grant resulting from +> this policy **MUST** be active until the device power goes into any +> state other than `active`. +> +> If the lifespan is set to `seconds`, then any grant resulting from +> this policy **MUST** be active until `lifespanTtl` seconds have passed +> since the grant was issued. + +If a Grant Policy has the `lifespan` set to `seconds`, then the +`lifespanTtl` **MUST** be set to a non-zero, positive number of seconds. + +#### 4.2.3. Grant Privacy Setting + +A Grant Policy **MAY** have a `PrivacySetting` object, which +associates any Firebolt `boolean` property API with this Grant Policy. +The Privacy Setting points to the RPC name of the property\'s getter +method. + +The associated property API **MUST** have an `x-allow-value` extension +on the \"property\" tag set to true or false. + +If a Grant Policy has a Privacy Setting, then the `PrivacySetting` +**MUST** be evaluated **before** any `GrantRequirements`. + +> The Privacy Setting **MUST** have an `autoApplyPolicy` which **MUST** +> be one of the following values: +> +> `always` - Silently grant if the getter for the `property` returns the +> property\'s `x-allow-value`. Silently deny if the getter for the +> `property` returns `!x-allow-value`. +> +> `allowed` - Silently grant if the getter for the `property` returns +> the property\'s `x-allow-value`. +> +> `disallowed` - Silently deny if the getter for the `property` returns +> the property\'s `!x-allow-value`. +> +> `never` - Do not silently grant or deny based on this Grant Policy. +> +> If the Privacy Setting has `revokeGrantsOnDisallow` set to `true`, +> then **all active** user grants that resulted from this Grant Policy +> **MUST** be revoked if and when the property value specified by +> `property` ever changes to `!x-allow-value`. This enables +> distributors to decide whether changes to a Privacy Setting affects +> only new User Grants or existing, active User Grants as well. +> +> If the Privacy Setting has `updateProperty` set to `true`, then a +> successful user grant from this Grant Policy **MUST** also result in +> updating the property value specified by `property` to +> `x-allow-value`. +> +> If the Privacy Setting has `updateProperty` set to `true`, then a +> rejected **or expiring** user grant from this Grant Policy **MUST** +> also result in updating the property value specified by `property` to +> `!x-allow-value`. This is considered a \"disallow\" and +> **MUST** initiate evaluation of the `revokeGrantsOnDisallow` value. +> +> If the Grant Policy `scope` is set to `app` then the property +> specified by `property` **MUST** have a single context +> parameter of type `string` and the requesting appId **MUST** be passed +> to all get/set/subscribe calls fulfilling this section of requirements. + +### 4.3. Distributor Overrides + +Capability Grant Policies in the Firebolt Version Manifest are designed +to be overridden by Distributors to allow for different privacy use +cases across businesses and geographic regions. These overrides go in +the Device Manifest under the `grantPolicies` section of the +`capabilities` section. + +Distributor overrides **MUST** be for Grant Policies that are +`overridable`. + +See the [Firebolt Configuration Schemas +repository](https://github.com/rdkcentral/firebolt-configuration/) for +more information on the Firebolt Version Manifest and Device Manifest. + +### 4.4. Application Overrides + +Firebolt supports creating active grants via the App manifest, which +allows distributors and App publishers to decide that a particular app +will already be granted some capability. This is typically used for +first-party apps that come pre-installed but could be used for other +purposes. + +If an app has a role/capability listed in its App Manifest, then it is +considered to have an active grant for that capability if the manifest +has a valid signature. + +App Manifests overrides **MUST** be for Grant Policies that are +`overridable` and scoped to `app`. + +See the [Firebolt Configuration Schemas +repository](https://github.com/rdkcentral/firebolt-configuration/) for +more information on Firebolt App Manifests. + +## 5. Grant Execution + +When a Firebolt API is called the platform **MUST** first collate all +the device User Grant configurations that apply to every capability that +the API uses. This list **MUST** then be filtered to remove any User +Grants that have already been granted for the current capability for +this app and role. + +### 5.1. Capability Check + +First, all capabilities necessary to fulfill the API are collected. + +![](../../../images/specifications/general/capabilities/user-grants/image4.png) + +### 5.2. Grant Policy Resolution + +Next, each capability is checked to see if there is a Firebolt, +Distributor, or App Grant Policy that applies, and that none of them are +invalid, e.g. an override that is now allowed. + +![Diagram Description automatically +generated](../../../images/specifications/general/capabilities/user-grants/image5.png) + +### 5.3. Active Grant Check + +Then, each Grant Policy is evaluated to see if there is already an +active grant, or if it is linked to a Privacy Setting configured to skip +user-prompts. + +![Diagram Description automatically +generated](../../../images/specifications/general/capabilities/user-grants/image6.png) + +### 5.4. Grant Prompt and Resolution + +Finally, each needed Granting Capability is invoked to present a UX to +the end user, and any linked Privacy Settings are updated as +appropriate. If all succeeds, then the API is invoked. + +![Diagram Description automatically +generated](../../../images/specifications/general/capabilities/user-grants/image7.png) + +## 6. Schemas + +The following schemas give an overview of the schemas outlined by this +document. See the [Firebolt Configuration Schemas +repository](https://github.com/rdkcentral/firebolt-configuration/) for +the latest versions of these schemas. + +### 6.1. Grant Policy + +Grant Policies have the following properties. + +| Property | Type | Description | +|-------------|-----------------------|-------------------------------------| +| `options` | `GrantRequirements[]` | An array of GrantRequirements, any one of which could be used to Grant a requested capability/role to an App. The first one that is completely supported by the current device should be used. | +| `scope` | `string` | Whether the resulting user grant applies to all Apps or just the requesting App. | +| `lifespan` | `string` | How long the resulting user grant (or deny) will last. | +| `lifespanTtl` | `integer` | If lifespan is `'seconds'` this represents the number of seconds. | +| `privacySetting` | `PrivacySetting` | Links this Grant Policy to a privacy setting. | +| `overridable` | `boolean` | Whether a distributor may override this GrantPolicy with their own. | + +### 6.2. GrantRequirements + +A list of `GrantSteps` objects describing which capabilities and any +optional configuration needed to fulfill this grant policy. These +capabilities must be from the capability category `usergrant` which +denotes special capabilities that perform user grants, e.g. an +acknowledge challenge capability. + +| Property | Type | Description | +|-------------|-----------------|-------------------------------------------| +| `steps` | `GrantStep[]` | An array of GrantSteps, all of which need to be verified to fulfill this GrantPolicy. | + +### 6.3. GrantStep + +| Property | Type | Description | +|-------------|----------------|-------------------------------------------| +| `capability` | `string` | The Granting Capability to use for this step in the grant flow. | +| `configuration ` | `object` | The configuration for the Granting Capability, which is specific to each type. | + +### 6.4. GrantKey + +A CapabilityKey with the \ set to `usergrant`: + +`/\^xrn:firebolt:capability:usergrant:\[a-zA-Z0-9\\-\]{1,32}\$/` + +#### 6.4.1. GrantScope + +A `string` enumeration. + +| Value | Description | +|----------------|--------------------------------------------------------| +| `device` | The resulting user grant will apply to all Apps on the device. | +| `app` | The resulting user grant will apply to the requesting App only. | + +#### 6.4.2. GrantLifespan + +A `string` enumeration. + +The resulting user grant will only be valid: + +| Value | Description | +|----------------|--------------------------------------------------------| +| `once` | for a single usage, e.g. one API call. | +| `forever` | until the end of time. | +| `appActive` | until the app enters a non-Active Lifecycle state: inactive, suspended | +| `powerActive` | until the device leaves the Active power state. | +| `seconds` | until \ seconds have passed. | + +#### 6.4.3. PrivacySetting + +| Value | | Description | +|--------------------|----------|------------------------------------------| +| `property` | string | The fully qualified RPC method name of the associated property setter, e.g. `Privacy.limitAdTracking` | +| `autoApplyPolicy` | string | Set the auto grant policy to `always`, `allowed`, `disallowed`, `never` | +| `revokeGrantsOnDisallow` | boolean | Any grants made from this policy will be revoked if/when the property is ever set to the deny value | +| `updateProperty` | boolean | Whether to update the property value to match the grant. | + +## 7. APIs + +APIs for User Grants are covered in the [Capabilities Requirements +document](./capabilities.md). + +### 7.1. Manage SDK APIs + +These APIs are intended for trusted apps to expose a UI for end-users to +manage the grants given to the device and various apps. Permission for +these APIs should only be given to a trusted settings app performing +this function. + +#### 7.1.1. GrantInfo Object + +Object describing a persisted active or denied Grant. + +```typescript +type GrantInfo = { + appId: string, + state: "active" | "denied", + capability: string, + role: "use" | "manage" | "provide" + lifespan: "once" | "forever" | "appActive" | " powerActive" | "seconds" + expires: integer +} +``` + +#### 7.1.2. App Method + +Returns all active and denied user grants for the given App, **NOT** +including those granted to all apps via the device. + +```typescript +UserGrants.app(appId: string): GrantInfo[] +``` + +#### 7.1.3. Device Method + +Returns all active and denied user grants for the Device. + +```typescript +UserGrants.device(): GrantInfo[] +``` + +#### 7.1.4. Capability Method + +Returns all active and denied user grants for the given Capability. + +```typescript +UserGrants.capability(capability: string): GrantInfo [] +``` + +#### 7.1.5. Grant Method + +Grants a given Capability, to a specific app if appropriate. Calling +this results in a persisted Active Grant that lasts for the duration of +the Grant Policy lifespan. + + +```typescript +UserGrants.grant(role: string, capability: string, appId?:string): void +``` + +#### 7.1.6. Deny Method + +Denies a given Capability, to a specific app if appropriate. Calling +this results in a persisted Denied Grant that lasts for the duration of +the Grant Policy lifespan. + +```typescript +UserGrants.deny(role: string, capability: string, appId?: string):void +``` + +#### 7.1.7. Clear Method + +Clears any persisted active or denied grant for a Capability, for a +specific app if appropriate. This results in an Unset Grant. This method +may take a wildcard value of `'*'` for role, capability, or appId, in +order to clear grant state in bulk. + +```typescript +UserGrants.clear(role: string, capability: string, appId?:string): void +``` diff --git a/requirements/specifications/general/context-parameters.md b/requirements/specifications/general/context-parameters.md new file mode 100644 index 000000000..761a03fd7 --- /dev/null +++ b/requirements/specifications/general/context-parameters.md @@ -0,0 +1,303 @@ +# Context Parameters +Document Status: Working Draft + +See [Firebolt Requirements Governance](../../governance.md) for more info. + +| Contributor | Organization | +| -------------- | -------------- | +| Jeremy LaCivita | Comcast | +| Yuri Pasquali | Sky | + +## 1. Overview + +**TODO**: This doc is old and need to be refreshed + +Context Parameters are parameters on an RPC method that provide context +for the call via a set of primitive types (string, number, integer, +boolean). This allows for sharing the context parameters across property +getters, setters, and subscribers, as well as filtering which events to +listen for by context. + +An example of a property method with context could be: + +```javascript +// get a context-driven property (context: appId=hulu) +const huluShare = await Privacy.shareWatchHistory('hulu') +``` + +```javascript +// set a context-driven property (context: appId=hulu) +Privacy.shareWatchHistory('hulu', false) +``` + +In the example above, 'hulu' is the context parameter for both the +shareWatchHistory getter and setter. + +Context parameters can also be applied to property subscribers, as well +as other, non-property events: + +```javascript +// subscribe to a context-driven property +Privacy.shareWatchHistory('hulu', (value) => { + console.log('hulu value changed to: ' + value) +}) + +Privacy.listen('shareWatchHistoryChanged', 'hulu', (value) => { + console.log('hulu value changed to: ' + value) +}) +``` + +For subscribers and events, the context parameters may be omitted, in +which case, all events will be dispatched to the listener: + +```javascript +// subscribe to a context-driven property w/out any context (get all of them) + +Privacy.shareWatchHistory((appId, value) => { + console.log(`App '${appId}' value changed to ${value}`) +}) + +Privacy.listen('shareWatchHistoryChanged', (appId, value) => { + console.log(`App '${appId}' value changed to: ${value}`) +}) +``` + +Context Parameters **MUST** be of a primitive type, to avoid complex +object-tree filtering. + +This document describes an OpenRPC pattern and JavaScript code +generation for a Firebolt method template that uses Context Parameters. + +## 2. Table of Contesnts +- [1. Overview](#1-overview) +- [2. Table of Contesnts](#2-table-of-contesnts) +- [3. Context Parameters Use Cases](#3-context-parameters-use-cases) +- [4. Context Parameters API](#4-context-parameters-api) + - [4.1. JSON-RPC API](#41-json-rpc-api) + - [4.1.1. Setter RPC generation](#411-setter-rpc-generation) + - [4.1.2. onChanged RPC generation](#412-onchanged-rpc-generation) + - [4.1.3. Temporal Set onAvailable / Unavailable RPC generation](#413-temporal-set-onavailable--unavailable-rpc-generation) + - [4.1.4. Event RPC Decoration](#414-event-rpc-decoration) + - [4.2. JavaScript API](#42-javascript-api) + - [4.2.1. Event Listener Signatures](#421-event-listener-signatures) + +## 3. Context Parameters Use Cases + +How each parameter affects it's corresponding API is out of scope for +this document. See each API spec for details on what each context +parameter does. + +Setting a context parameter to null is still setting it to a value. If a +context parameter is passed to the SDK with either a value of null or +undefined, then it **MUST** be explicitly set in the RPC request to the +value null. This is to avoid additional method signature permutations +being required for the SDK. + +An effort should be made to sort the context parameters in order of most +usefulness, since not all languages support undefined. + +## 4. Context Parameters API + +The section describes the RPC and JavaScript APIs. + +### 4.1. JSON-RPC API + +Simple getters and event listeners don't need any parameters. + +If a method is tagged as either a property (any kind) or an event, then +**all** the parameters in the RPC definition **MUST** be context +parameters. + +To facilitate this, the listen parameter that all events currently have +will be removed from the source module and inserted into the generated +RPC by the firebolt-openrpc tooling. + +If any Context Parameters have a type other than: + +- `string` +- `boolean` +- `number` +- `integer` + +Then the RPC method **MUST NOT** pass validation. This is to ensure that +implementing context parameters is not overly complicated. + +#### 4.1.1. Setter RPC generation + +When generating the setter for a property method, all the Context +Parameters **MUST** be copied to the setter. The context parameters +**MUST** be before the value parameter, which itself **MUST** be last. + +#### 4.1.2. onChanged RPC generation + +When generating the onChanged notification for a property +method, all the Context Parameters **MUST** be copied to the event +parameters. The context parameters **MUST** be before the listen +parameter, which itself **MUST** be last. + +#### 4.1.3. Temporal Set onAvailable / Unavailable RPC generation + +Generated Temporal Set events will treat the entire parameter list from +the original temporal-set method as Context Parameters and copy them to +the event parameters. The context parameters **MUST** be before the +listen parameter, which itself **MUST** be last. + +#### 4.1.4. Event RPC Decoration + +All RPC methods tagged as event **MUST** have the listen parameter, of +type boolean, automatically added when generating the final RPC. This +parameter will be added at the end of the parameters list. + +All RPC methods tagged as event that have context parameters **MUST** +have the result schema wrapped in an object. The original result schema +**MUST** be moved to a property called data. Each of the context +parameters **MUST** be copied to a property called context. + +So the following RPC event: + +```json +{ + "name": "onContextualEvent", + "tags": [ + { + "name": "event" + } + ], + "params": [ + { + "name": "a", + "required": true, + "schema": { + "type": "boolean" + } + }, + { + "name": "b", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "c", + "required": true, + "schema": { + "type": "number" + } + } + ], + "result": { + "name": "result", + "schema": { + "type": "object", + "properties": { + "foo": { + "type": "boolean" + } + } + } + } +} +``` + +Would have its result transformed to: + +```json +{ + "name": "result", + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "foo": { + "type": "boolean" + } + } + }, + "context": { + "type": "object", + "properties": { + "a": { + "type": "boolean" + }, + "b": { + "type": "string" + }, + "c": { + "type": "number" + } + }, + "required": [ + "a", "b", "c" + ] + } + } + } +} +``` + +### 4.2. JavaScript API + +TBD + +#### 4.2.1. Event Listener Signatures + +If any of the context parameters are optional, then a callback signature +must be generated for each left-to-right combination of the parameters. + +For example, the method: + +```json +{ + "name": "onFoo", + "tags": [ + { + "name": "event" + } + ], + "params": [ + { + "name": "a", + "required": true, + "schema": { + "type": "boolean" + } + }, + { + "name": "b", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "c", + "required": false, + "schema": { + "type": "number" + } + } + ] +} +``` + +Would result in the following method signatures: + +```typescript +listen(event: 'foo', a: boolean, callback: (b: string, c: number, data: any) => {}) + +listen(event: 'foo', a: boolean, b: string, callback: (c: number, data: any) => {}) + +listen(event: 'foo', a: boolean, b: string, c: number, callback: (data: any) => {}) +``` + +Which allows parameters to be omitted, from right-to-left, and included +as part of the result, instead. + +When invoking the callback, the SDK **MUST** pass the data portion of +the result to the data parameter of the callback, and each context +property to the corresponding callback parameter. + +This pattern also applies to property subscribers. diff --git a/requirements/specifications/intents/command-and-control.md b/requirements/specifications/intents/command-and-control.md new file mode 100644 index 000000000..db799cde9 --- /dev/null +++ b/requirements/specifications/intents/command-and-control.md @@ -0,0 +1,984 @@ +# Command and Control Intents + +Document Status: Proposed Specification + +See [Firebolt Requirements Governance](../../governance.md) for more info. + +| Contributor | Organization | +| ---------------- | ------------ | +| Saras Arveti | Comcast | +| Eileen Bengston | Comcast | +| Michael Driscoll | Comcast | +| Simon Grist | Sky | +| Jeremy LaCivita | Comcast | + +## 1. Overview + +This document outlines several basic Intents for controlling a Firebolt +compliant device. + +### 1.1. Message.type + +Message.type should be a useful grouping to bucket related intents +together for easier forwarding to appropriate components. + +## 2. Table of Contents +- [1. Overview](#1-overview) + - [1.1. Message.type](#11-messagetype) +- [2. Table of Contents](#2-table-of-contents) +- [3. Control Intents](#3-control-intents) + - [3.1. Power Intent](#31-power-intent) + - [3.2. Volume Intents](#32-volume-intents) + - [3.2.1. Volume Intent](#321-volume-intent) + - [3.2.2. Mute Intent](#322-mute-intent) + - [3.3. Channel Intent](#33-channel-intent) + - [3.4. Media Control Intents](#34-media-control-intents) + - [3.4.1. Pause, Play, Replay, and Stop Intents](#341-pause-play-replay-and-stop-intents) + - [3.4.2. Seek Intent](#342-seek-intent) + - [3.4.3. Fast-forward and Rewind Intents](#343-fast-forward-and-rewind-intents) + - [3.5. Accessibility Intents](#35-accessibility-intents) + - [3.5.1. Closed Captions Intent](#351-closed-captions-intent) + - [3.5.2. Voice Guidance Intent](#352-voice-guidance-intent) + - [3.5.3. Audio Descritions Intent](#353-audio-descritions-intent) + - [3.5.4. High Contrast Intent](#354-high-contrast-intent) + - [3.5.5. Screen Magnification Intent](#355-screen-magnification-intent) + - [3.6. Interaction Intents](#36-interaction-intents) + - [3.6.1. Focus Intent](#361-focus-intent) + - [3.6.2. Select Intent](#362-select-intent) + - [3.6.3. Scroll Intent](#363-scroll-intent) + - [3.6.4. Back Intent](#364-back-intent) + - [3.6.5. Exit Intent](#365-exit-intent) +- [4. Launch Intents](#4-launch-intents) + - [4.1. Content Discovery Launch Intents](#41-content-discovery-launch-intents) + - [4.2. Device Settings Launch Intent](#42-device-settings-launch-intent) + +## 3. Control Intents + +Control intents are for user intentions that will be needed regardless +of whether there are any apps installed. + +For example, these intents are all useful even if only using your TV +with a single HDMI input, and not for apps. + +### 3.1. Power Intent + +This intent allows a user to turn the device on or off. + +```json +{ + "type": "xrn:firebolt:intent:platform:power", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "power", + "data": { + "value": true | false + }, + "context": { + "source": "voice" + } + } +} +``` + +Additionally, this intent may specify a toggle: + +```json +{ + "type": "xrn:firebolt:intent:platform:power", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "power", + "data": { + "toggle": true + }, + "context": { + "source": "voice" + } + } +} +``` + +Additionally, this intent allows a user to set a timer for turning off +the power, aka a "sleep timer." + +This is handled by the optional field delay, which is measured in whole +seconds: + +```json +{ + "type": "xrn:firebolt:intent:platform:power", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "power", + "data": { + "value": true | false, + "delay": 3600 + }, + "context": { + "source": "voice" + } + } +} +``` + +To cancel a sleep timer, send a new intent without a delay. + +While it may not be implemented by all platforms, this could also be +used to turn on the TV with a timer. + +### 3.2. Volume Intents + +Volume Intents control the audio level of the device. + +#### 3.2.1. Volume Intent + +This intent allows setting the volume to an absolute or relative value. + +```json +{ + "type": "xrn:firebolt:intent:platform:volume", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "volume", + "data": { + "value": 70 + }, + "context": { + "source": "VOICE" + } + } +} + +``` + +The value is an integer value from 0 to 100. + +This intent also supports relative volume changes, by providing the +optional relative field: + +```json +{ + "type": "xrn:firebolt:intent:platform:volume", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "volume", + "data": { + "value": -10, + "relative": true + }, + "context": { + "source": "VOICE" + } + } +} + +``` + +The value is a positive or negative integer that is relative to a scale +of 0-100. + +Firebolt will not support complicated relative changes, e.g. "Set the +volume to 50% *of what it currently is\...*" + +Firebolt uses a size of 0-100 for this intent. It\'s up to each voice +integration if it wants to convert "5" to "50%" before generating +the intent, but convenience transformations like this are recommended. + +Whether or not a TV uses logarithmic or linear scale is irrelevant to +the VolumeIntent schema. + +#### 3.2.2. Mute Intent + +This intent allows the user to mute or unmute the device. + +```json +{ + "type": "xrn:firebolt:intent:platform:volume", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "mute", + "data": { + "value": true | false + }, + "context": { + "source": "VOICE" + } + } +} +``` + +### 3.3. Channel Intent + +For tuning to a specific channel, either OTA or in-app, see [Tune +Intents](./tune.md). + +The intents in this section are for relative next/previous channel user +intentions and are a separate type of Intent. This allows each app to +decide what "channel" means. For example, an App might simply take you +to the next section/genre if it doesn\'t have linear streams in it\'s +catalog. + +The goal of the action property to is tell the client how to parse the +Intent, so overloading the tune intent with a different structure is not +desirable. + +Also, +"tune" inherently means to zero in on a specific part of a +scale, e.g. tuning a harp. + +For relative "channel surfing" we\'ll use the more content-centric +action "channel" which will also align with non-linear apps that want +to leverage the channel up/down intent. + +The Channel Intent allows a user to scan "channels" in an app (or +actual OTA channels if not in an app). + +Users can scan to the next or previous channel. For scanning to the most +recent, i.e. "Last" channel, see [Interaction +Intent +](#interaction-intents). + +```json +{ + "type": "xrn:firebolt:intent:platform:channel", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "channel", + "data": { + "value": "next" | "previous" + }, + "context": { + "source": "voice" + } + } +} + +``` + +The value property MUST always be "next" or "previous". These are +chosen over up/down since not all use cases will be numeric. + +Since this intent is always relative to the current app, there is no +need for an appId. + +If this Intent needs to be passed to the current app, it can be passed +as-is, via the Discovery. onNavigateTo API, or a simulated RCU press of +one of the channel up/down buttons. + +### 3.4. Media Control Intents + +#### 3.4.1. Pause, Play, Replay, and Stop Intents + +These intents allow the user to pause and resume playback of the current +Media: + +```json +{ + "type": "xrn:firebolt:intent:platform:media-control", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "pause" | "play" | "replay" | "stop", + "context": { + "source": "voice" + } + } +} +``` + +If the action is pause, then the currently playing media should be +paused, with the frames on-screen and the video decoder ready to resume. + +If the action is play, and the current media is paused, then the +currently paused media should resume. + +If the action is play, and there is something playbable selected, then +playback of the selected asset should be initiated. + +If the action is replay, then the currently paused or playing media should restart +from the beginning. This should work even if the decoder has finished, +and its resources have been released. + +If the action is stop, then the currently playing media should be +stopped, frames removed from the screen, and any decoder resources +should be released. + +#### 3.4.2. Seek Intent + +The seek intent allows users to jump to a relative or absolute position +in the currently playing media. + +```json +{ + "type": "xrn:firebolt:intent:platform:media-control", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "seek", + "data": { + "seconds": 3600 + }, + "context": { + "source": "voice" + } + } +} +``` + +The seconds value is a positive integer representing where to seek. + +This intent also supports relative seeking, by providing the optional +relative field: + +```json +{ + "type": "xrn:firebolt:intent:platform:media-control", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "seek", + "data": { + "seconds": -30, + "relative": true + }, + "context": { + "source": "voice" + } + } +} +``` + +For relative seeking, the seconds value may be a positive or negative value. + +If a relative seek intent with a seconds value of `0` is received, the platform **SHOULD** ignore it, rather than rebuffering at the current position. + +#### 3.4.3. Fast-forward and Rewind Intents + +These intents allow users to fast-forward or rewind: + +```json +{ + "type": "xrn:firebolt:intent:platform:media-control", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "fast-forward" | "rewind", + "data": { + "speed": 2.5 + }, + "context": { + "source": "voice" + } + } +} +``` + +Speed is a float in the range of 0 (non-includsive) to 10 (inclusive), +with values between 0 and 1 denoting slow motion. + +It is a device-level decision how to implement different speeds, however +actual fast playback (with audio) should be used where possible and +reasonable, e.g. a speed of 1.5 should actually be playing the video w/ +sync\'d audio, while a speed of 10 will likely be using iframes and not +have audio. For rewind it is not important, and likely undesirable, to +provide audio. + +If speed is not provided then the device should cycle through a range +of speeds defined by the device. This range of speeds **COULD** include +the value `1` so that users can get back to normal speed if desired. + +### 3.5. Accessibility Intents + +These intents manipulate accessibility features on the device. + +#### 3.5.1. Closed Captions Intent + +This intent allows a user to turn closed captions on or off. + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "closed-captions", + "data": { + "value": true | false + }, + "context": { + "source": "voice" + } + } +} +``` + +Additionally, this intent may specify a toggle: + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "closed-captions", + "data": { + "toggle": true + }, + "context": { + "source": "voice" + } + } +} +``` + +#### 3.5.2. Voice Guidance Intent + +This intent allows a user to turn voice guidance on or off. + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "voice-guidance", + "data": { + "value": true | false + }, + "context": { + "source": "voice" + } + } +} + +``` + +Additionally, this intent may specify a toggle: + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "voice-guidance", + "data": { + "toggle": true + }, + "context": { + "source": "voice" + } + } +} +``` + +The intent **MAY** specify `speed` `number` property that specifies a speed from 0 to 10: + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "voice-guidance", + "data": { + "speed": 2 + }, + "context": { + "source": "voice" + } + } +} +``` + +When providing a `speed` this intent **MAY** also set the `relative` property to `true` denoting an increase or decrease in speed. The speed value may be between -5 and 5 inclusive: + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "voice-guidance", + "data": { + "speed": -1, + "relative": true + }, + "context": { + "source": "voice" + } + } +} +``` + +Finally, the intent **MAY** specify a `verbosity` property, which **MUST** use one of the following values is provided: + +| Value | Description | +|--------|-------------| +| `low` | to select shorter response, less context, and less detail; can use abbreviations and can selectively skip words | +| `high` | to select longer response, more context, and more detail; full comprehensive readout and explicit reflection of what is seen on screen | + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "voice-guidance", + "data": { + "value": true, + "verbosity": "low" + }, + "context": { + "source": "voice" + } + } +} +``` + +#### 3.5.3. Audio Descritions Intent + +This intent allows a user to turn audio descriptions of content on or off. + + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "audio-descriptions", + "data": { + "value": true | false + }, + "context": { + "source": "voice" + } + } +} + +``` + +This intent may specify a language: + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "audio-descriptions", + "data": { + "value": true, + "language": "eng" + }, + "context": { + "source": "voice" + } + } +} +``` + +The `language` must be a three character ISO 639 1/2 code, e.g. `eng`. + +Additionally, this intent may specify a toggle: + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "audio-descriptions", + "data": { + "toggle": true + }, + "context": { + "source": "voice" + } + } +} +``` + +#### 3.5.4. High Contrast Intent + +This intent allows a user to turn high contrast mode on or off. + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "high-contrast", + "data": { + "value": true | false + }, + "context": { + "source": "voice" + } + } +} + +``` + +Additionally, this intent may specify a toggle: + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "high-contrast", + "data": { + "toggle": true + }, + "context": { + "source": "voice" + } + } +} +``` + +#### 3.5.5. Screen Magnification Intent + +This intent allows a user to turn screen magnification on or off. + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "screen-magnification", + "data": { + "value": true | false + }, + "context": { + "source": "voice" + } + } +} + +``` + +Additionally, this intent may specify a toggle: + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "screen-magnification", + "data": { + "toggle": true + }, + "context": { + "source": "voice" + } + } +} +``` + +Finally, this intent may specify a magnification scale as a number: + +```json +{ + "type": "xrn:firebolt:intent:platform:accessibility", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "screen-magnification", + "data": { + "scale": 2.5 + }, + "context": { + "source": "voice" + } + } +} +``` + +Setting the scale to `1` turns off magnification. Setting the scale to a value greater than 1 turns on magnification. + +Even if a Firebolt platform does not support specifying the numeric scale, it **MUST** turn magnifacation on and off based on them. + +If the intent has the `toggle` property, then it **MUST NOT** have the `scale` or `value` property. + +If the intent has the `value` property, then it **MUST NOT** have the `toggle`. + +### 3.6. Interaction Intents + +Interaction Intents allow for voice (or other upstream intent service) +to control an on-screen UI without need for a keyboard or remote. + +#### 3.6.1. Focus Intent + +The Focus Intent allows users to move the focus / cursor +up/down/left/right: + +```json +{ + "type": "xrn:firebolt:intent:platform:interaction", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "focus", + "data": { + "direction": "up" | "down" | "left" | "right" + }, + "context": { + "source": "voice" + } + } +} + +``` + +Note that this does not give focus to a particular app, which is handled +by the "launch" action. + +These Intents will generate appropriate HTML browser keyCode events to +facilitate up/down/left/right key presses. + +#### 3.6.2. Select Intent + +The select intent allows users to tell an app select, e.g., +"click" on +whatever is focused. This is a platform-level intent that effectively +sends the "Ok" or "Select" key to the current app. + +```json +{ + "type": "xrn:firebolt:intent:platform:interaction", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "select", + "context": { + "source": "voice" + } + } +} +``` + +#### 3.6.3. Scroll Intent + +The Scroll Intent allows users to move the current view port +up/down/left/right: + +```json +{ + "type": "xrn:firebolt:intent:platform:interaction", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "scroll", + "data": { + "direction": "up" | "down" | "left" | "right", + "unit": "page" | "line" | "percent" + }, + "context": { + "source": "voice" + } + } +} +``` + +Both `direction` and `unit` are required. + +These Intents will generate appropriate browser / DOM scrolling +operations that don\'t require custom APIs. + +#### 3.6.4. Back Intent + +The back intent allows users to tell an app go to "back" like a +browser. This is a platform-level intent and will initiate a browser +back flow for web apps. For native apps, this will be converted to an +app Navigation Intent by the client and surfaced through the navigateTo +API. + +```json +{ + "type": "xrn:firebolt:intent:platform:interaction", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "back", + "context": { + "source": "voice" + } + } +} +``` + +#### 3.6.5. Exit Intent + +The exit intent allows users to tell an app close. This is a +platform-level intent and will simply move the current app into the +inactive state. + +```json +{ + "type": "xrn:firebolt:intent:platform:interaction", + "target": "client", + "metadata": { + "assistant": "XFINITY", + "lang": "eng-USA", + "micType": "NEAR_FIELD" + }, + "intent": { + "action": "exit", + "context": { + "source": "voice" + } + } +} +``` + +## 4. Launch Intents + +If a Firebolt app wants to launch the main or settings experience of the device, it can use one of the following abstract appIds with the `launch` intent. + +### 4.1. Content Discovery Launch Intents + +The following section IDs will be used, with the Firebolt application +type as the target App ID: + +`xrn:firebolt:application-type:main` + +### 4.2. Device Settings Launch Intent + +To launch the settings UI, a Launch Intent will be used, with the +Firebolt application type: + +`xrn:firebolt:application-type:settings` diff --git a/requirements/specifications/intents/index.md b/requirements/specifications/intents/index.md index 6925376e4..72d6138c8 100644 --- a/requirements/specifications/intents/index.md +++ b/requirements/specifications/intents/index.md @@ -7,6 +7,8 @@ See [Firebolt Requirements Governance](../../governance.md) for more info. | Contributor | Organization | | --------------- | ------------ | | Jeremy LaCivita | Comcast | +| Simon Grist | Sky | + ## 1. Overview Offen times an end-user has a specific intention that needs to be communicated @@ -27,18 +29,23 @@ additional `data` property. - [3. Intent Action](#3-intent-action) - [4. Intent Context](#4-intent-context) - [5. Intent Data](#5-intent-data) -- [Intent Types](#intent-types) +- [6. Intent Message](#6-intent-message) + - [6.1. App Intent Message](#61-app-intent-message) + - [6.2. Platform Intent Message](#62-platform-intent-message) + - [6.3. Intent Message Type](#63-intent-message-type) + - [6.4. Intent Message Metadata](#64-intent-message-metadata) +- [7. Intent Types](#7-intent-types) ## 3. Intent Action The intent `action` denotes what type of intent it is. -All intents **MUST** have a `string` attribute denoting the type of intent. +All intents **MUST** have an `action` `string` property denoting the type of intent. See the various [Intent Types](#intent-types) below for values. ## 4. Intent Context -The intent `context` provides information on where the intent orginated from. +The intent `context` provides information on where the intent orginated from. All intents **MUST** have a `context` property, which is an object. The `context` object **MUST** have a `source` string property with one of the @@ -56,7 +63,56 @@ any string value. This property denotes an editorial campaign. ## 5. Intent Data If an intent has any additional data, it **MUST** be in the `data` property. -## Intent Types +## 6. Intent Message +When an intent is sent to a Firebolt device from some other system, e.g. a cloud voice service, it **MUST** be wrapped in an `IntentMessage` object so that it can be properly routed after transport. + +An intent message **MUST** have an `intent` object property that is the intent being passed. + +An example intent message: + +```json +{ + "type": "xrn:firebolt:intent:app:launch", + "appId": "Netflix", + "intent": { + "action": "launch", + "context": { + "source": "voice" + } + }, + "metadata": { + "foo": "bar" + } +} +``` + +### 6.1. App Intent Message +If an intent is targeting a specific app, then the intent message **MUST** have an `appId` string property with the appId of the targeted app. + +### 6.2. Platform Intent Message +If an intent messagage does not have an `appId` property, then it **MUST** be targeting the device itself, e.g. a `power` intent to turn off the device. + +### 6.3. Intent Message Type +An intent message **MUST** have a `type` string property for categorizing the intent. + +The type property **MUST** match the regular expression: + +```regex +^xrn:firebolt:intent:(app|platform):[a-zA-Z]+$ +``` + +App Intent Messages **MUST** have the fourth section set to `app`. + +Platform Intent Messages **MUST** have the fourth section set to `platform` + +All Intent Messages **MUST** have the fifth section set to the same value as `intent.action`. + +Platforms may use this to route different types of intents to different subsystems without having to understand the internal structure of Firebolt intent objects. + +### 6.4. Intent Message Metadata +An intent message **MAY** have a `metadata` object property for adding distributor-specific metadata for logging or analytics. The values in `metadata` **MUST NOT** impact how the device interprets the intent. + +## 7. Intent Types - [Play](./play.md) - [Tune](./tune.md) diff --git a/requirements/specifications/intents/user-interest.md b/requirements/specifications/intents/user-interest.md new file mode 100644 index 000000000..eae60ecf7 --- /dev/null +++ b/requirements/specifications/intents/user-interest.md @@ -0,0 +1,15 @@ +# User Interest + +Document Status: Candidate Specification + +See [Firebolt Requirements Governance](../../governance.md) for more info. + +| Contributor | Organization | +| -------------- | -------------- | +| Eugene Chung | Comcast | +| Tim Dibben | Sky | +| Mike Horwitz | Comcast | +| Jeremy LaCivita | Comcast | + +## 1. Overview +This document describes the intent to initiate a [User Interest](../discovery/user-interest.md) flow from an upstream system, e.g. a voice assistant. diff --git a/requirements/specifications/localization/language.md b/requirements/specifications/localization/language.md new file mode 100644 index 000000000..0b3df80ef --- /dev/null +++ b/requirements/specifications/localization/language.md @@ -0,0 +1,99 @@ +# Language Settings + +Document Status: Candidate Specification + +See [Firebolt Requirements Governance](../../governance.md) for more info. + +| Contributor | Organization | +| -------------- | -------------- | +| Jeremy LaCivita | Comcast | +| Kevin Pearson | Comcast | +| Tim Dibben | Sky | + +## 1. Overview + +This document describes the requirements that Firebolt platforms must +fulfill when surfacing user language preferences. + +Exposing these settings, e.g. the main device language, or a list of +preferred audio languages, allows Apps to respect the device's current +setting so that the user has a seamless experience when switching from +app to app. + +This document covers how Firebolt platforms manage language settings and +expose to Apps. It does not cover the use cases Apps might apply these +APIs to. + +The key words "**MUST**", "**MUST NOT**", "**REQUIRED**", "**SHALL**", "**SHALL NOT**", "**SHOULD**", "**SHOULD NOT**", "**RECOMMENDED**", "**NOT RECOMMENDED**", "**MAY**", and "**OPTIONAL**" in this document are to be interpreted as described in [BCP 14](https://www.rfc-editor.org/rfc/rfc2119.txt) [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. + +- [1. Overview](#1-overview) +- [2. Language](#2-language) +- [3. Locale](#3-locale) +- [4. Preferred Audio Languages](#4-preferred-audio-languages) +- [5. Core SDK APIs](#5-core-sdk-apis) +- [6. Manage SDK APIs](#6-manage-sdk-apis) + +## 2. Language + +Language describes the ISO 639 1/2 code for the preferred language on +this device. All Apps **SHOULD** generally render their user experience +in this language. This is a guideline, not an absolute requirement, +since different Apps may have different target audiences with differing +languages prevalent within those audiences. + +This setting is represented by a mutable property which is a string +conforming to the ISO 639 1/2 standard, e.g. `'en'`. + +## 3. Locale + +Locale describes the *full* BCP 47 code, including script, region, +variant, etc., for the preferred language/locale on this device. Apps +**MAY** alter their user experience to match this locale to account for +local differences in the same language. + +This setting is represented by a mutable property which is a string +conforming to the full BCP 47 standard, e.g. `'en-US'`. + +## 4. Preferred Audio Languages + +The preferred audio languages setting provides a ranked list of +languages that the user prefers to be selected on this device. All +values are from the ISO 639 1/2 standard. Apps **MAY** use this list to +influence selection of an initial audio track when playing content with +multiple languages. For example, a bilingual user living in an English +speaking country may have the `language` set to `'en`\' and the +`preferredAudioLanguages` set to `['fr', 'en']`. This +enables them to typically consume content from apps whose catalogs are +mostly filmed in English, but automatically get the French language +track when watching a French movie that has both French and English +tracks. + +This setting is represented by a mutable property which is an array of +strings conforming to the ISO 639 1/2 standard, e.g. `'en'`. + +## 5. Core SDK APIs + +The following APIs are exposed by the Firebolt Core SDK as part of the +`core:localization` domain/module. + +Each of these APIs a read-only property. + +- `Localization.language():Promise` + +- `Localization.locale():Promise` + +- `Localization.preferredAudioLanguages():Promise` + +- `Localization.onLanguageChanged():Promise` + +- `Localization.onLocaleChanged():Promise` + +- `Localization.onPreferredAudioLanguagesChanged():Promise` + +## 6. Manage SDK APIs + +The following APIs are exposed by the Firebolt Manage SDK as part of the +`manage` domain. + +The Manage SDK APIs inclueare identical to the Core SDK, except that all +property APIs are mutable. diff --git a/requirements/specifications/openrpc-extensions/app-passthrough-apis.md b/requirements/specifications/openrpc-extensions/app-passthrough-apis.md new file mode 100644 index 000000000..826f7bed3 --- /dev/null +++ b/requirements/specifications/openrpc-extensions/app-passthrough-apis.md @@ -0,0 +1,463 @@ +# App Pass-through APIs + +Document Status: Working Draft + +See [Firebolt Requirements Governance](../../governance.md) for more info. + +| Contributor | Organization | +|-----------------|----------------| +| Jeremy LaCivita | Comcast | +| Kevin Pearson | Comcast | +| Yuri Pasquali | Sky | + +## 1. Overview +This document describes how one Firebolt App can provide a capability that may be used by another Firebolt App, with the platform as a permission broker that passes the requests and responses to each app without feature-specific logic. + +This document covers the App Pass-through Firebolt OpenRPC extension as well as how Firebolt implementations should detect and execute app provided pass-through APIs. + +Some APIs require an app to fulfill the request on behalf of another app, e.g. to provide a UX or cross-app data sharing. Generally the calling app doesn't care, or have a say in, which other app provides the API, that is up to the Firebolt distributor. + +To facilitate these APIs, Firebolt denotes an OpenRPC tag with OpenRPC extensions to connect the `provide` API to the `use` API. + +This document is written using the [IETF Best Common Practice 14](https://www.rfc-editor.org/rfc/rfc2119.txt) and should include the following summary in the Overview section: + +The key words "**MUST**", "**MUST NOT**", "**REQUIRED**", "**SHALL**", "**SHALL NOT**", "**SHOULD**", "**SHOULD NOT**", "**RECOMMENDED**", "**NOT RECOMMENDED**", "**MAY**", and "**OPTIONAL**" in this document are to be interpreted as described in [BCP 14](https://www.rfc-editor.org/rfc/rfc2119.txt) [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. + +## 2. Table of Contents +- [1. Overview](#1-overview) +- [2. Table of Contents](#2-table-of-contents) +- [3. Open RPC Extensions](#3-open-rpc-extensions) + - [3.1. Provided By Extension](#31-provided-by-extension) +- [4. Routing App pass-through APIs](#4-routing-app-pass-through-apis) + - [4.1. No available providers](#41-no-available-providers) + - [4.2. Direct pass-through](#42-direct-pass-through) + - [4.4. Pass-through notifications](#44-pass-through-notifications) +- [5. Provider Candidates](#5-provider-candidates) +- [6. Best Candidate](#6-best-candidate) +- [7. Result Transformations](#7-result-transformations) +- [8. Provider Parameter Injection](#8-provider-parameter-injection) +- [9. API Gateway](#9-api-gateway) +- [10. Example: User Interest](#10-example-user-interest) + - [10.1. User Interest Pull](#101-user-interest-pull) + - [10.2. User Interest Push](#102-user-interest-push) + +## 3. Open RPC Extensions + +### 3.1. Provided By Extension +Firebolt OpenRPC **MUST** support a `string` `x-provided-by` extension property on the `capabilities` tag that denotes a method is provided by some app on the device registering for the specified provider API, e.g.: + +```json +{ + "methods": [ + { + "name": "Keyboard.standard", + "tags": [ + { + "name": "capabilities", + "x-provided-by": "Keyboard.onRequestStandard", + "x-uses": [ + "xrn:firebolt:capability:input:keyboard" + ] + } + ] + } + ] +} +``` + +The method denoted by `x-provided-by` is referred to as the "*provider*" or "*provider method*" for the remainder of this document. + +The method with the `x-provided-by` extension is referred to as the "*platform method*" for the remainder of this document. + +To prevent unresolvable chaining of methods the `x-provided-by` extension **MUST NOT** be used on a method with any value in the `x-provides` extension. + +To prevent compound methods a platform method **MUST** `use` a single capability or `manage` a single capability, but not both. + +The provider method **MUST** provide the same capability that the platform method either uses or manages. + +If a platform method has no provider method then it is not a valid Firebolt OpenRPC method schema, and a validation error **MUST** be generated. + +## 4. Routing App pass-through APIs +App pass-through APIs may be routed in one of several ways. + +When an app calls a platform method, i.e. one with an `x-provided-by` extension, the platform **MUST** use one of the routing methods defined in this section based on various properties of the method. + +### 4.1. No available providers +When an app calls a platform method with an `x-provided-by` extension, the platform **MUST** return an unavailable error if there is no [candidate app](#7-provider-candidates) to execute the provider method. + +```json +{ + "id": 1, + "error": { + "code": -50300, + "message": "Capability is unavailable." + } +} +``` + +Where `` is the capability XRN string, e.g. `xrn:firebolt:capabilities:example:foo`. + +### 4.2. Direct pass-through +A direct pass-through is where a single app provides a single response to a single request by another app. + +This section only applies to app provider methods that do not have an `event` tag. + +The platform method result schema **MUST** either: + +> Match the `x-response` schema on the provider method so that the result can be passed through. +> +> or +> +> Have a property that matches the `x-response-name` string and `x-response` schema on the +> provider method so that the result can be composed and passed through. + +The platform **MUST** call the provider method from the [best candidate](#8-best-candidate) app and acquire the result. + +If the platform method result schema matches the `x-response` schema on the provider method then the value **MUST** be used as-is. + +Otherwise if the platform method result schema has a property that matches the `x-response` schema on the provider method then the value **MUST** be composed into an object under the corresponding property name and the platform **MUST** apply any [result transformations](#9-result-transformations) to the composed result. + +### 4.4. Pass-through notifications +Firebolt events have a synchronous subscriber registration method, e.g. `Lifecycle.onInactive(true)`, in addition to asynchronous notifications when the event actually happens. For events powered by an app pass-through, only the asynchronous notifications are passed in by the providing app. The initial event registration is handled by the platform, and the success response is not handled by the providing app. + +This section only applies to platform methods that have an `event` tag. + +App provided event registration **MUST** not return an availability error due to a lack of providers, since one may be launched at a future point. + +To ensure that event provider methods all behave the same the provider method **MUST** have a `result` schema with `"type"` set to `"null"`, since it will not expect any data in the response from the platform after pushing the notification. + +The platform method result schema **MUST** either: + +> Match the *last* parameter schema on the provider method so that the result can be passed through. +> +> Have a property that matches the *last* parameter name and schema on the provider method so that the result can be passed through. + +Example platform method with context: +```json +{ + "name": "onFoo", + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capabilities:example:foo" + ], + "x-provided-by": "foo" + }, + { + "name": "event" + } + ], + "params": [ + { + "name": "context1", + "schema":{ + "type": "string" + } + }, + { + "name": "context2", + "schema": { + "type": "number" + } + } + ], + "result": { + "name": "value", + "schema": { + "type": "boolean" + } + } +} +``` + +Matching provider method: + +```json +{ + "name": "foo", + "tags": [ + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capabilities:example:foo" + } + ], + "params": [ + { + "name": "context1", + "schema":{ + "type": "string" + } + }, + { + "name": "context2", + "schema": { + "type": "number" + } + }, + { + "name": "value", + "schema": { + "type": "boolean" + } + } + ] +} +``` + +When a provider app calls a provider method mapped to an event the platform **MUST** ignore the notification if the app is not a [candidate app](#7-provider-candidates) for this capability. + +If the platform method result schema matches the *last* parameter schema on the provider method then the value **MUST** be used as-is. + +Otherwise if the platform method result schema has a property that matches the *last* parameter schema on the provider method then the value **MUST** be composed into an object under the corresponding property name and the platform **MUST** apply any [result transformations](#9-result-transformations) to the composed result. + +If the value was composed into the platform method result under a matching property, then any context parameter values from the provider method that correspond to a property name and schema in the platform method result **MUST** also be composed into the platform method result under those properties. + +Finally the platform **MUST** dispatch the notification to the app that registered for the event via the original platform method, using all but the last parameter as context. + +## 5. Provider Candidates +When a platform method with an `x-provided-by` extension is called, then +all loaded apps that have permission to provide the capability **MUST** be +considered as candidates to fulfill the method. + +## 6. Best Candidate +Any provider candidates that have not registered to provide the method in +question **MUST NOT** be considered the best candidate and removed from +consideration. + +If there is only one candidate left then it **MUST** be the best candidate. + +If there is more than one candidate left, then the candidate app that most recently had RCU input focus **MUST** be the best candidate. + +If none of the candidates have had focus yet, then the candidate app that was most recently launched **MUST** be the best candidate. + +## 7. Result Transformations +A platform method may be configured to insert the providing app id into composite values. This is not allowed in non-composite results to avoid collisions with the provder method sending an appId and Firebolt overriding it. + +If a "composite result" was used to wrap the provider method value and the platform method's schema has an `appId` `string` property at the top level then the property's value **MUST** be set to the the appId of the providing app for that result. + +## 8. Provider Parameter Injection +If the provider method has a parameter named `appId` and the platform method *does not*, then the appId of the app calling the platform method **MUST** be sent to the provider in the `appId` parameter. + +If the platform method is an `event` and the provider method has context parameters then each context parameter from the provider that has a matching context parameter in the event **MUST** have it's value passed to that parameter. + +If the platform method is an `event` with a "composite result" and the provider method has context parameters then each context parameter from the provider that has a matching property on the `result` object **MUST** have it's value copied into that property. + +## 9. API Gateway +The Firebolt API Gateway **MUST** detect app-passthrough APIs and map the `use`/`manage` APIs to the corresponding `provide` APIs by parsing the Firebolt OpenRPC Specification and following the logic outline in this document. + +## 10. Example: User Interest + +The following schemas are referenced by these examples: + +```json +{ + "components": { + "schemas": { + "InterestType": { + "type": "string", + "enum": [ + "interest", + "disinterest" + ] + }, + "InterestReason": { + "type": "string", + "enum": [ + "playlist" + ] + }, + "EntityDetailsFromApp": { + "type": "object", + "properties": { + "appId": { + "type": "string" + }, + "entity": { + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails" + } + }, + "required": [ + "appId", + "entity" + ] + } + } + } +} +``` + +### 10.1. User Interest Pull + +Platform method: + +```json +{ + "methods": [ + { + "name": "requestUserInterest", + "tags": [ + { + "name": "capabilities", + "x-provided-by": "Discovery.onRequestUserInterest", + "x-uses": [ + "xrn:firebolt:capability:discovery:interest" + ] + } + ], + "params": [ + { + "name": "type", + "required": true, + "schema": { + "$ref": "#/components/schemas/InterestType" + } + }, + { + "name": "reason", + "required": true, + "schema": { + "$ref": "#/components/schemas/InterestReason" + } + } + ], + "result": { + "name": "interest", + "schema": { + "$ref": "#/components/schemas/EntityDetailsFromApp", + } + } + } + ] +} +``` + +Provider method: + +```json +{ + "methods": [ + { + "name": "onRequestUserInterest", + "tags": [ + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:discovery:interest" + }, + { + "name": "event", + "x-response": { + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails" + } + } + ], + "result": { + "name": "request", + "schema": { + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/InterestType", + }, + "reason": { + "$ref": "#/components/schemas/InterestReason", + } + } + } + } + } + ] +} +``` + +### 10.2. User Interest Push + +Provider method: + +```json +{ + "methods": [ + { + "name": "userInterest", + "tags": [ + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:discovery:interest" + } + ], + "params": [ + { + "name": "type", + "schema": { + "$ref": "#/components/schemas/InterestType", + } + }, + { + "name": "reason", + "schema": { + "$ref": "#/components/schemas/InterestReason", + } + }, + { + "name": "entity", + "schema": { + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails" + } + } + ], + "result": { + "name": "result", + "schema": { + "type": "null" + } + } + } + ] +} +``` + +Platform Method: + +```json +{ + "methods": [ + { + "name": "onUserInterest", + "tags": [ + { + "name": "capabilities", + "x-provided-by": "Discovery.userInterest", + "x-uses": [ + "xrn:firebolt:capability:discovery:interest" + ] + }, + { + "name": "event" + } + ], + "params": [], + "result": { + "name": "interest", + "schema": { + "type": "object", + "properties": { + "appId": { + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/InterestType" + }, + "reason": { + "$ref": "#/components/schemas/InterestReason" + }, + "entity": { + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails" + } + } + + } + } + } + ] +} +``` diff --git a/src/js/version-specification/capabilities.mjs b/src/js/version-specification/capabilities.mjs index de48d7298..bd5120bdb 100644 --- a/src/js/version-specification/capabilities.mjs +++ b/src/js/version-specification/capabilities.mjs @@ -48,7 +48,7 @@ const doImport = (source, target, clear=false, report=false) => { if (!result.capabilities[capability]) { logSuccess(`${report ? 'Missing' : 'Adding'} capability ${capability}.`) } - result.capabilities[capability] = Object.assign({ + result.capabilities[capability] = Object.assign({ level: 'must', use: { public: uses.includes(capability), @@ -62,19 +62,19 @@ const doImport = (source, target, clear=false, report=false) => { public: provides.includes(capability), negotiable: true && provides.includes(capability) } - }, result.capabilities[capability] || {}) - if (uses.includes(capability) != result.capabilities[capability].use.public) { - logSuccess(` - ${report ? 'Incorrect' : 'Setting'} use.public: ${uses.includes(capability)} for ${capability}.`) - result.capabilities[capability].use.public = uses.includes(capability) - } - if (manages.includes(capability) != result.capabilities[capability].manage.public) { - logSuccess(` - ${report ? 'Incorrect' : 'Setting'} manage.public: ${manages.includes(capability)} for ${capability}.`) - result.capabilities[capability].manage.public = manages.includes(capability) - } - if (provides.includes(capability) != result.capabilities[capability].provide.public) { - logSuccess(` - ${report ? 'Incorrect' : 'Setting'} provides.public: ${provides.includes(capability)} for ${capability}.`) - result.capabilities[capability].provide.public = provides.includes(capability) - } + }, result.capabilities[capability] || {}) + if (uses.includes(capability) != result.capabilities[capability].use.public) { + logSuccess(` - ${report ? 'Incorrect' : 'Setting'} use.public: ${uses.includes(capability)} for ${capability}.`) + result.capabilities[capability].use.public = uses.includes(capability) + } + if (manages.includes(capability) != result.capabilities[capability].manage.public) { + logSuccess(` - ${report ? 'Incorrect' : 'Setting'} manage.public: ${manages.includes(capability)} for ${capability}.`) + result.capabilities[capability].manage.public = manages.includes(capability) + } + if (provides.includes(capability) != result.capabilities[capability].provide.public) { + logSuccess(` - ${report ? 'Incorrect' : 'Setting'} provides.public: ${provides.includes(capability)} for ${capability}.`) + result.capabilities[capability].provide.public = provides.includes(capability) + } }) Object.keys(result.capabilities).forEach(cap => { @@ -117,6 +117,13 @@ const doImport = (source, target, clear=false, report=false) => { unused.forEach(c => logSuccess(' - ' + c)) } + const caps = result.capabilities + result.capabilities = {} + //.filter(([_, c]) => c.level != "could") + Object.entries(caps).sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0).forEach(([key, value]) => { + result.capabilities[key] = value + }) + return result } @@ -127,11 +134,11 @@ const run = async(version, parsedArgs) => { if (parsedArgs.report) { report = true } - + console.log() logHeader(`Adding OpenRPC Capabilities`) - return doImport(rpc, version, false, report) + return doImport(rpc, version, false, report) } export default run \ No newline at end of file diff --git a/src/openrpc/content.json b/src/openrpc/content.json new file mode 100644 index 000000000..0ffbeadbf --- /dev/null +++ b/src/openrpc/content.json @@ -0,0 +1,195 @@ +{ + "openrpc": "1.2.4", + "info": { + "title": "Content", + "version": "0.0.0", + "description": "" + }, + "methods": [ + { + "name": "requestUserInterest", + "tags": [ + { + "name": "capabilities", + "x-provided-by": "Discovery.onRequestUserInterest", + "x-uses": [ + "xrn:firebolt:capability:discovery:interest" + ] + } + ], + "summary": "Provide information about the entity currently displayed or selected on the screen.", + "description": "Provide information about the entity currently displayed or selected on the screen.", + "params": [ + { + "name": "type", + "required": true, + "schema": { + "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestType" + } + }, + { + "name": "reason", + "required": true, + "schema": { + "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestReason" + } + } + ], + "result": { + "name": "interest", + "schema": { + "$ref": "#/components/schemas/InterestResult" + }, + "summary": "The EntityDetails data." + }, + "examples": [ + { + "name": "Default Example", + "params": [ + { + "name": "type", + "value": "interest" + }, + { + "name": "reason", + "value": "playlist" + } + ], + "result": { + "name": "interest", + "value": { + "appId": "cool-app", + "entity": { + "identifiers": { + "entityId": "345", + "entityType": "program", + "programType": "movie" + }, + "info": { + "title": "Cool Runnings", + "synopsis": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc.", + "releaseDate": "1993-01-01T00:00:00.000Z", + "contentRatings": [ + { + "scheme": "US-Movie", + "rating": "PG" + }, + { + "scheme": "CA-Movie", + "rating": "G" + } + ] + } + } + } + } + } + ] + }, + { + "name": "onUserInterest", + "tags": [ + { + "name": "event" + }, + { + "name": "capabilities", + "x-provided-by": "Discovery.userInterest", + "x-uses": [ + "xrn:firebolt:capability:discovery:interest" + ] + } + ], + "summary": "Provide information about the entity currently displayed or selected on the screen.", + "description": "Provide information about the entity currently displayed or selected on the screen.", + "params": [], + "result": { + "name": "interest", + "schema": { + "$ref": "#/components/schemas/InterestEvent" + }, + "summary": "The EntityDetails data." + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "interest", + "value": { + "appId": "cool-app", + "type": "interest", + "reason": "playlist", + "entity": { + "identifiers": { + "entityId": "345", + "entityType": "program", + "programType": "movie" + }, + "info": { + "title": "Cool Runnings", + "synopsis": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc.", + "releaseDate": "1993-01-01T00:00:00.000Z", + "contentRatings": [ + { + "scheme": "US-Movie", + "rating": "PG" + }, + { + "scheme": "CA-Movie", + "rating": "G" + } + ] + } + } + } + } + } + ] + } + ], + "components": { + "schemas": { + "InterestResult": { + "title": "InterestResult", + "type": "object", + "properties": { + "appId": { + "type": "string" + }, + "entity": { + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails" + } + }, + "required": [ + "appId", + "entity" + ] + }, + "InterestEvent": { + "title": "InterestEvent", + "type": "object", + "properties": { + "appId": { + "type": "string" + }, + "type": { + "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestType" + }, + "reason": { + "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestReason" + }, + "entity": { + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails" + } + }, + "required": [ + "appId", + "entity", + "type", + "reason" + ] + } + } + } +} \ No newline at end of file diff --git a/src/openrpc/discovery.json b/src/openrpc/discovery.json index eb7530a35..01ab2205e 100644 --- a/src/openrpc/discovery.json +++ b/src/openrpc/discovery.json @@ -52,6 +52,9 @@ { "name": "capabilities", "x-provides": "xrn:firebolt:capability:discovery:entity-info" + }, + { + "name": "deprecated" } ], "summary": "Provide information about a program entity and its available watchable assets, such as entitlement status and price, via either a push or pull call flow.", @@ -409,7 +412,7 @@ } ], "result": { - "name": "success", + "name": "result", "value": true } } @@ -424,6 +427,9 @@ { "name": "capabilities", "x-provides": "xrn:firebolt:capability:discovery:purchased-content" + }, + { + "name": "deprecated" } ], "summary": "Provide a list of purchased content for the authenticated account, such as rentals and electronic sell through purchases.", @@ -1467,6 +1473,156 @@ } } ] + }, + { + "name": "userInterest", + "summary": "Send an entity that the user has expressed interest in to the platform.", + "tags": [ + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:discovery:interest" + } + ], + "params": [ + { + "name": "type", + "required": true, + "schema": { + "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestType" + } + }, + { + "name": "reason", + "required": true, + "schema": { + "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestReason" + } + }, + { + "name": "entity", + "required": true, + "schema": { + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails" + } + } + ], + "result": { + "name": "result", + "schema": { + "type": "null" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [ + { + "name": "type", + "value": "interest" + }, + { + "name": "reason", + "value": "playlist" + }, + { + "name": "entity", + "value": { + "identifiers": { + "entityId": "345", + "entityType": "program", + "programType": "movie" + }, + "info": {} + } + } + ], + "result": { + "name": "result", + "value": null + } + } + ] + }, + { + "name": "Discovery.onRequestUserInterest", + "tags": [ + { + "name": "rpc-only" + }, + { + "name": "event", + "x-response-name": "entity", + "x-response": { + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails", + "examples": [ + { + "identifiers": { + "entityId": "345", + "entityType": "program", + "programType": "movie" + }, + "info": { + "title": "Cool Runnings", + "synopsis": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc.", + "releaseDate": "1993-01-01T00:00:00.000Z", + "contentRatings": [ + { + "scheme": "US-Movie", + "rating": "PG" + }, + { + "scheme": "CA-Movie", + "rating": "G" + } + ] + } + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:discovery:interest" + } + ], + "summary": "Provide information about the entity currently displayed or selected on the screen.", + "description": "Provide information about the entity currently displayed or selected on the screen.", + "params": [], + "result": { + "name": "request", + "schema": { + "type": "object", + "required": [ + "correlationId", + "parameters" + ], + "properties": { + "correlationId": { + "type": "string" + }, + "parameters": { + "$ref": "#/components/schemas/UserInterestProviderParameters" + } + }, + "additionalProperties": false + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "request", + "value": { + "correlationId": "xyz", + "parameters": { + "type": "interest", + "reason": "playlist" + } + } + } + } + ] } ], "components": { @@ -1785,6 +1941,22 @@ "enum": [ "xrn:firebolt:channel:any" ] + }, + "UserInterestProviderParameters": { + "title": "UserInterestProviderParameters", + "type": "object", + "required": [ + "type", + "reason" + ], + "properties": { + "type": { + "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestType" + }, + "reason": { + "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestReason" + } + } } } } diff --git a/src/openrpc/keyboard.json b/src/openrpc/keyboard.json index 0ef1f725b..9d8e39412 100644 --- a/src/openrpc/keyboard.json +++ b/src/openrpc/keyboard.json @@ -11,6 +11,7 @@ "tags": [ { "name": "capabilities", + "x-provided-by": "Keyboard.onRequestEmail", "x-uses": [ "xrn:firebolt:capability:input:keyboard" ] @@ -84,6 +85,7 @@ "tags": [ { "name": "capabilities", + "x-provided-by": "Keyboard.onRequestPassword", "x-uses": [ "xrn:firebolt:capability:input:keyboard" ] @@ -128,6 +130,7 @@ "tags": [ { "name": "capabilities", + "x-provided-by": "Keyboard.onRequestStandard", "x-uses": [ "xrn:firebolt:capability:input:keyboard" ] @@ -175,11 +178,9 @@ { "name": "event", "x-response": { - "$ref": "#/components/schemas/KeyboardResult", + "type": "string", "examples": [ - { - "text": "username" - } + "username" ] } }, @@ -220,11 +221,9 @@ { "name": "event", "x-response": { - "$ref": "#/components/schemas/KeyboardResult", + "type": "string", "examples": [ - { - "text": "password" - } + "password" ] } }, @@ -265,11 +264,9 @@ { "name": "event", "x-response": { - "$ref": "#/components/schemas/KeyboardResult", + "type": "string", "examples": [ - { - "text": "email@address.com" - } + "email@address.com" ] } }, @@ -359,23 +356,6 @@ "$ref": "#/components/schemas/KeyboardParameters" } } - }, - "KeyboardResult": { - "title": "KeyboardResult", - "type": "object", - "required": [ - "text" - ], - "properties": { - "text": { - "type": "string", - "description": "The text the user entered into the keyboard" - }, - "canceled": { - "type": "boolean", - "description": "Whether the user canceled entering text before they were finished typing on the keyboard" - } - } } } } diff --git a/src/schemas/advertising.json b/src/schemas/advertising.json new file mode 100644 index 000000000..e3aca3ede --- /dev/null +++ b/src/schemas/advertising.json @@ -0,0 +1,23 @@ +{ + "$id": "https://meta.comcast.com/firebolt/advertising", + "title": "Advertising", + "oneOf": [ + { + "$ref": "#/definitions/SkipRestriction" + } + ], + "definitions": { + "SkipRestriction": { + "title": "SkipRestriction", + "$comment": "xrn:advertising:policy:skipRestriction:", + "type": "string", + "enum": [ + "none", + "adsUnwatched", + "adsAll", + "all" + ], + "description": "The advertisement skip restriction.\n\nApplies to fast-forward/rewind (e.g. trick mode), seeking over an entire opportunity (e.g. jump), seeking out of what's currently playing, and \"Skip this ad...\" features. Seeking over multiple ad opportunities only requires playback of the _last_ opportunity, not all opportunities, preceding the seek destination.\n\n| Value | Description |\n|--------------|--------------------------------------------------------------------------------|\n| none |No fast-forward, jump, or skip restrictions |\n| adsUnwatched | Restrict fast-forward, jump, and skip for unwatched ad opportunities only. |\n| adsAll | Restrict fast-forward, jump, and skip for all ad opportunities |\n| all | Restrict fast-forward, jump, and skip for all ad opportunities and all content |\n\nNamespace: `xrn:advertising:policy:skipRestriction:`\n\n" + } + } +} \ No newline at end of file diff --git a/src/schemas/discovery.json b/src/schemas/discovery.json new file mode 100644 index 000000000..1c13435a7 --- /dev/null +++ b/src/schemas/discovery.json @@ -0,0 +1,79 @@ +{ + "$id": "https://meta.comcast.com/firebolt/discovery", + "title": "Discovery", + "anyOf": [ + { + "$ref": "#/definitions/PurchasedContentResult" + } + ], + "definitions": { + "PurchasedContentResult": { + "title": "PurchasedContentResult", + "type": "object", + "properties": { + "expires": { + "type": "string", + "format": "date-time" + }, + "totalCount": { + "type": "integer", + "minimum": 0 + }, + "entries": { + "type": "array", + "items": { + "$ref": "https://meta.comcast.com/firebolt/entertainment#/definitions/EntityInfo" + } + } + }, + "required": [ + "expires", + "totalCount", + "entries" + ], + "additionalProperties": false + }, + "EntityInfoResult": { + "title": "EntityInfoResult", + "description": "The result for an `entityInfo()` push or pull.", + "type": "object", + "properties": { + "expires": { + "type": "string", + "format": "date-time" + }, + "entity": { + "$ref": "https://meta.comcast.com/firebolt/entertainment#/definitions/EntityInfo" + }, + "related": { + "type": "array", + "items": { + "$ref": "https://meta.comcast.com/firebolt/entertainment#/definitions/EntityInfo" + } + } + }, + "required": [ + "expires", + "entity" + ], + "additionalProperties": false + }, + "InterestType": { + "title": "InterestType", + "type": "string", + "enum": [ + "interest", + "disinterest" + ] + }, + "InterestReason": { + "title": "InterestReason", + "type": "string", + "enum": [ + "playlist", + "reaction", + "recording" + ] + } + } + } diff --git a/src/schemas/entertainment.json b/src/schemas/entertainment.json index 8fd14ee38..8f94854e8 100644 --- a/src/schemas/entertainment.json +++ b/src/schemas/entertainment.json @@ -80,7 +80,6 @@ "required": [ "identifiers", "entityType", - "programType", "title" ], "properties": { diff --git a/src/schemas/entity.json b/src/schemas/entity.json new file mode 100644 index 000000000..2e486e865 --- /dev/null +++ b/src/schemas/entity.json @@ -0,0 +1,456 @@ +{ + "$id": "https://meta.comcast.com/firebolt/entity", + "title": "Entity", + "oneOf": [ + { + "$ref": "#/definitions/Entity" + }, + { + "$ref": "#/definitions/PlayableEntity" + }, + { + "$ref": "#/definitions/EntityDetails" + } + ], + "definitions": { + "Entity": { + "oneOf": [ + { + "$ref": "#/definitions/ProgramEntity" + }, + { + "$ref": "#/definitions/MusicEntity" + }, + { + "$ref": "#/definitions/ChannelEntity" + }, + { + "$ref": "#/definitions/UntypedEntity" + }, + { + "$ref": "#/definitions/PlaylistEntity" + } + ] + }, + "EntityDetails": { + "title": "EntityDetails", + "type": "object", + "required": [ + "identifiers" + ], + "properties": { + "identifiers": { + "$ref": "#/definitions/Entity" + }, + "info": { + "$ref": "#/definitions/Metadata" + }, + "waysToWatch": { + "type": "array", + "items": { + "$ref": "https://meta.comcast.com/firebolt/entertainment#/definitions/WayToWatch" + }, + "description": "An array of ways a user is might watch this entity, regardless of entitlements." + } + } + }, + "ChannelEntity": { + "title": "ChannelEntity", + "type": "object", + "properties": { + "entityType": { + "const": "channel" + }, + "channelType": { + "type": "string", + "enum": [ + "streaming", + "overTheAir" + ] + }, + "entityId": { + "type": "string", + "description": "ID of the channel, in the target App's scope." + }, + "appContentData": { + "type": "string", + "maxLength": 256 + } + }, + "required": [ + "entityType", + "channelType", + "entityId" + ], + "additionalProperties": false + }, + "ProgramEntity": { + "title": "ProgramEntity", + "oneOf": [ + { + "$ref": "#/definitions/MovieEntity" + }, + { + "$ref": "#/definitions/TVEpisodeEntity" + }, + { + "$ref": "#/definitions/TVSeasonEntity" + }, + { + "$ref": "#/definitions/TVSeriesEntity" + }, + { + "$ref": "#/definitions/AdditionalEntity" + } + ] + }, + "MusicEntity": { + "title": "MusicEntity", + "type": "object", + "properties": { + "entityType": { + "const": "music" + }, + "musicType": { + "$ref": "https://meta.comcast.com/firebolt/entertainment#/definitions/MusicType" + }, + "entityId": { + "type": "string" + } + }, + "required": [ + "entityType", + "musicType", + "entityId" + ] + }, + "MovieEntity": { + "title": "MovieEntity", + "description": "A Firebolt compliant representation of a Movie entity.", + "type": "object", + "required": [ + "entityType", + "programType", + "entityId" + ], + "properties": { + "entityType": { + "const": "program" + }, + "programType": { + "const": "movie" + }, + "entityId": { + "type": "string" + }, + "assetId": { + "type": "string" + }, + "appContentData": { + "type": "string", + "maxLength": 256 + } + }, + "additionalProperties": false, + "examples": [ + { + "entityType": "program", + "programType": "movie", + "entityId": "el-camino" + } + ] + }, + "TVEpisodeEntity": { + "title": "TVEpisodeEntity", + "description": "A Firebolt compliant representation of a TV Episode entity.", + "type": "object", + "required": [ + "entityType", + "programType", + "entityId", + "seriesId", + "seasonId" + ], + "properties": { + "entityType": { + "const": "program" + }, + "programType": { + "const": "episode" + }, + "entityId": { + "type": "string" + }, + "seriesId": { + "type": "string" + }, + "seasonId": { + "type": "string" + }, + "assetId": { + "type": "string" + }, + "appContentData": { + "type": "string", + "maxLength": 256 + } + }, + "additionalProperties": false, + "examples": [ + { + "entityType": "program", + "programType": "episode", + "entityId": "breaking-bad-pilot", + "seriesId": "breaking-bad", + "seasonId": "breaking-bad-season-1" + } + ] + }, + "TVSeasonEntity": { + "title": "TVSeasonEntity", + "description": "A Firebolt compliant representation of a TV Season entity.", + "type": "object", + "required": [ + "entityType", + "programType", + "entityId", + "seriesId" + ], + "properties": { + "entityType": { + "const": "program" + }, + "programType": { + "const": "season" + }, + "entityId": { + "type": "string" + }, + "seriesId": { + "type": "string" + }, + "assetId": { + "type": "string" + }, + "appContentData": { + "type": "string", + "maxLength": 256 + } + }, + "additionalProperties": false, + "examples": [ + { + "entityType": "program", + "programType": "season", + "entityId": "breaking-bad-season-1", + "seriesId": "breaking-bad" + } + ] + }, + "TVSeriesEntity": { + "title": "TVSeriesEntity", + "description": "A Firebolt compliant representation of a TV Series entity.", + "type": "object", + "required": [ + "entityType", + "programType", + "entityId" + ], + "properties": { + "entityType": { + "const": "program" + }, + "programType": { + "const": "series" + }, + "entityId": { + "type": "string" + }, + "assetId": { + "type": "string" + }, + "appContentData": { + "type": "string", + "maxLength": 256 + } + }, + "additionalProperties": false, + "examples": [ + { + "entityType": "program", + "programType": "series", + "entityId": "breaking-bad" + } + ] + }, + "PlaylistEntity": { + "title": "PlaylistEntity", + "description": "A Firebolt compliant representation of a Playlist entity.", + "type": "object", + "required": [ + "entityType", + "entityId" + ], + "properties": { + "entityType": { + "const": "playlist" + }, + "entityId": { + "type": "string" + }, + "assetId": { + "type": "string" + }, + "appContentData": { + "type": "string", + "maxLength": 256 + } + }, + "additionalProperties": false, + "examples": [ + { + "entityType": "playlist", + "entityId": "playlist/xyz" + } + ] + }, + "PlayableEntity": { + "title": "PlayableEntity", + "anyOf": [ + { + "$ref": "#/definitions/MovieEntity" + }, + { + "$ref": "#/definitions/TVEpisodeEntity" + }, + { + "$ref": "#/definitions/PlaylistEntity" + }, + { + "$ref": "#/definitions/MusicEntity" + }, + { + "$ref": "#/definitions/AdditionalEntity" + } + ] + }, + "AdditionalEntity": { + "title": "AdditionalEntity", + "description": "A Firebolt compliant representation of the remaining program entity types.", + "type": "object", + "required": [ + "entityType", + "programType", + "entityId" + ], + "properties": { + "entityType": { + "const": "program" + }, + "programType": { + "type": "string", + "enum": [ + "concert", + "sportingEvent", + "preview", + "other", + "advertisement", + "musicVideo", + "minisode", + "extra" + ] + }, + "entityId": { + "type": "string" + }, + "assetId": { + "type": "string" + }, + "appContentData": { + "type": "string", + "maxLength": 256 + } + }, + "additionalProperties": false, + "examples": [ + { + "entityType": "program", + "programType": "concert", + "entityId": "live-aid" + } + ] + }, + "UntypedEntity": { + "title": "UntypedEntity", + "allOf": [ + { + "description": "A Firebolt compliant representation of the remaining entity types.", + "type": "object", + "required": [ + "entityId" + ], + "properties": { + "entityId": { + "type": "string" + }, + "assetId": { + "type": "string" + }, + "appContentData": { + "type": "string", + "maxLength": 256 + } + }, + "additionalProperties": false + } + ], + "examples": [ + { + "entityId": "an-entity" + } + ] + }, + "Metadata": { + "title": "Metadata", + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "Title of the entity." + }, + "synopsis": { + "type": "string", + "description": "Short description of the entity." + }, + "seasonNumber": { + "type": "number", + "description": "For TV seasons, the season number. For TV episodes, the season that the episode belongs to." + }, + "seasonCount": { + "type": "number", + "description": "For TV series, seasons, and episodes, the total number of seasons." + }, + "episodeNumber": { + "type": "number", + "description": "For TV episodes, the episode number." + }, + "episodeCount": { + "type": "number", + "description": "For TV seasons and episodes, the total number of episodes in the current season." + }, + "releaseDate": { + "type": "string", + "format": "date-time", + "description": "The date that the program or entity was released or first aired." + }, + "contentRatings": { + "type": "array", + "items": { + "$ref": "https://meta.comcast.com/firebolt/entertainment#/definitions/ContentRating" + }, + "description": "A list of ContentRating objects, describing the entity's ratings in various rating schemes." + } + } + } + } +} \ No newline at end of file diff --git a/src/schemas/intents.json b/src/schemas/intents.json index 6fa2a5807..8f5a86c38 100644 --- a/src/schemas/intents.json +++ b/src/schemas/intents.json @@ -243,12 +243,33 @@ { "$ref": "#/definitions/ButtonIntent" }, + { + "$ref": "#/definitions/FocusIntent" + }, + { + "$ref": "#/definitions/SelectIntent" + }, + { + "$ref": "#/definitions/BackIntent" + }, + { + "$ref": "#/definitions/ExitIntent" + }, + { + "$ref": "#/definitions/ChannelIntent" + }, + { + "$ref": "#/definitions/ScrollIntent" + }, { "$ref": "#/definitions/PowerIntent" }, { "$ref": "#/definitions/VolumeIntent" }, + { + "$ref": "#/definitions/MuteIntent" + }, { "$ref": "#/definitions/MicrophoneIntent" }, @@ -257,15 +278,36 @@ }, { "$ref": "#/definitions/TuneIntent" + }, + { + "$ref": "#/definitions/VoiceGuidanceIntent" + }, + { + "$ref": "#/definitions/HighContrastIntent" + }, + { + "$ref": "#/definitions/ScreenMagnificationIntent" } ] }, "PlaybackControlIntent": { "description": "A Firebolt compliant representation of a user intention to control some aspect of in-progress playback.", "anyOf": [ + { + "$ref": "#/definitions/PlayIntent" + }, { "$ref": "#/definitions/PauseIntent" }, + { + "$ref": "#/definitions/ReplayIntent" + }, + { + "$ref": "#/definitions/StopIntent" + }, + { + "$ref": "#/definitions/PlaybackSpeedIntent" + }, { "$ref": "#/definitions/SeekIntent" }, @@ -273,13 +315,16 @@ "$ref": "#/definitions/SkipIntent" }, { - "$ref": "#/definitions/TrickPlayIntent" + "$ref": "#/definitions/FastForwardIntent" + }, + { + "$ref": "#/definitions/RewindIntent" }, { "$ref": "#/definitions/ClosedCaptionsIntent" }, { - "$ref": "#/definitions/AudioDescriptionIntent" + "$ref": "#/definitions/AudioDescriptionsIntent" } ] }, @@ -307,6 +352,9 @@ "action": { "const": "launch" } + }, + "not": { + "required": [ "data" ] } } ], @@ -338,6 +386,9 @@ "action": { "const": "home" } + }, + "not": { + "required": [ "data" ] } } ], @@ -370,32 +421,7 @@ "const": "entity" }, "data": { - "anyOf": [ - { - "$ref": "#/definitions/MovieEntity" - }, - { - "$ref": "#/definitions/TVEpisodeEntity" - }, - { - "$ref": "#/definitions/TVSeriesEntity" - }, - { - "$ref": "#/definitions/TVSeasonEntity" - }, - { - "$ref": "#/definitions/MusicEntity" - }, - { - "$ref": "#/definitions/PlaylistEntity" - }, - { - "$ref": "#/definitions/AdditionalEntity" - }, - { - "$ref": "#/definitions/UntypedEntity" - } - ] + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/Entity" } } } @@ -414,395 +440,31 @@ } ] }, - "ChannelEntity": { - "title": "ChannelEntity", - "type": "object", - "properties": { - "entityType": { - "const": "channel" - }, - "channelType": { - "type": "string", - "enum": [ - "streaming", - "overTheAir" - ] - }, - "entityId": { - "type": "string", - "description": "ID of the channel, in the target App's scope." - }, - "appContentData": { - "type": "string", - "maxLength": 256 - } - }, - "required": [ - "entityType", - "channelType", - "entityId" - ], - "additionalProperties": false - }, - "ProgramEntity": { - "title": "ProgramEntity", - "type": "object", - "properties": { - "entityType": { - "const": "program" - }, - "programType": { - "$ref": "https://meta.comcast.com/firebolt/entertainment#/definitions/ProgramType" - }, - "entityId": { - "type": "string" - } - }, - "required": [ - "entityType", - "programType", - "entityId" - ] - }, - "MusicEntity": { - "title": "MusicEntity", - "type": "object", - "properties": { - "entityType": { - "const": "music" - }, - "musicType": { - "$ref": "https://meta.comcast.com/firebolt/entertainment#/definitions/MusicType" - }, - "entityId": { - "type": "string" - } - }, - "required": [ - "entityType", - "musicType", - "entityId" - ] - }, - "MovieEntity": { - "title": "MovieEntity", - "allOf": [ - { - "$ref": "#/definitions/ProgramEntity" - }, - { - "description": "A Firebolt compliant representation of a Movie entity.", - "title": "MovieEntity", - "type": "object", - "required": [ - "entityType", - "programType", - "entityId" - ], - "properties": { - "entityType": { - "const": "program" - }, - "programType": { - "const": "movie" - }, - "entityId": { - "$ref": "#/definitions/Identifier" - }, - "assetId": { - "$ref": "#/definitions/Identifier" - }, - "appContentData": { - "type": "string", - "maxLength": 256 - } - }, - "additionalProperties": false - } - ], - "examples": [ - { - "entityType": "program", - "programType": "movie", - "entityId": "el-camino" - } - ] - }, - "TVEpisodeEntity": { - "title": "TVEpisodeEntity", - "allOf": [ - { - "$ref": "#/definitions/ProgramEntity" - }, - { - "description": "A Firebolt compliant representation of a TV Episode entity.", - "title": "TVEpisodeEntity", - "type": "object", - "required": [ - "entityType", - "programType", - "entityId", - "seriesId", - "seasonId" - ], - "properties": { - "entityType": { - "const": "program" - }, - "programType": { - "const": "episode" - }, - "entityId": { - "$ref": "#/definitions/Identifier" - }, - "seriesId": { - "$ref": "#/definitions/Identifier" - }, - "seasonId": { - "$ref": "#/definitions/Identifier" - }, - "assetId": { - "$ref": "#/definitions/Identifier" - }, - "appContentData": { - "type": "string", - "maxLength": 256 - } - }, - "additionalProperties": false - } - ], - "examples": [ - { - "entityType": "program", - "programType": "episode", - "entityId": "breaking-bad-pilot", - "seriesId": "breaking-bad", - "seasonId": "breaking-bad-season-1" - } - ] - }, - "TVSeasonEntity": { - "title": "TVSeasonEntity", - "description": "A Firebolt compliant representation of a TV Season entity.", - "allOf": [ - { - "$ref": "#/definitions/ProgramEntity" - }, - { - "type": "object", - "required": [ - "entityType", - "programType", - "entityId", - "seriesId" - ], - "properties": { - "entityType": { - "const": "program" - }, - "programType": { - "const": "season" - }, - "entityId": { - "$ref": "#/definitions/Identifier" - }, - "seriesId": { - "$ref": "#/definitions/Identifier" - }, - "assetId": { - "$ref": "#/definitions/Identifier" - }, - "appContentData": { - "type": "string", - "maxLength": 256 - } - }, - "additionalProperties": false - } - ], - "examples": [ - { - "entityType": "program", - "programType": "season", - "entityId": "breaking-bad-season-1", - "seriesId": "breaking-bad" - } - ] - }, - "TVSeriesEntity": { - "title": "TVSeriesEntity", + "ChannelIntent": { + "description": "A Firebolt compliant representation of a user intent to 'surf' to the next or previous channel.", + "title": "ChannelIntent", "allOf": [ { - "$ref": "#/definitions/ProgramEntity" - }, - { - "description": "A Firebolt compliant representation of a TV Series entity.", - "type": "object", - "required": [ - "entityType", - "programType", - "entityId" - ], - "properties": { - "entityType": { - "const": "program" - }, - "programType": { - "const": "series" - }, - "entityId": { - "$ref": "#/definitions/Identifier" - }, - "assetId": { - "$ref": "#/definitions/Identifier" - }, - "appContentData": { - "type": "string", - "maxLength": 256 - } - }, - "additionalProperties": false - } - ], - "examples": [ - { - "entityType": "program", - "programType": "series", - "entityId": "breaking-bad" - } - ] - }, - "PlaylistEntity": { - "title": "PlaylistEntity", - "description": "A Firebolt compliant representation of a Playlist entity.", - "type": "object", - "required": [ - "entityType", - "entityId" - ], - "properties": { - "entityType": { - "const": "playlist" - }, - "entityId": { - "$ref": "#/definitions/Identifier" - }, - "assetId": { - "$ref": "#/definitions/Identifier" - }, - "appContentData": { - "type": "string", - "maxLength": 256 - } - }, - "additionalProperties": false, - "examples": [ - { - "entityType": "playlist", - "entityId": "playlist/xyz" - } - ] - }, - "PlayableEntity": { - "title": "PlayableEntity", - "anyOf": [ - { - "$ref": "#/definitions/MovieEntity" - }, - { - "$ref": "#/definitions/TVEpisodeEntity" - }, - { - "$ref": "#/definitions/PlaylistEntity" - }, - { - "$ref": "#/definitions/MusicEntity" + "$ref": "#/definitions/Intent" }, { - "$ref": "#/definitions/AdditionalEntity" - } - ] - }, - "AdditionalEntity": { - "title": "AdditionalEntity", - "allOf": [ - { - "$ref": "#/definitions/ProgramEntity" + "$ref": "#/definitions/IntentProperties" }, { - "description": "A Firebolt compliant representation of the remaining entity types.", "type": "object", - "required": [ - "entityType", - "entityId" - ], + "required": [ "data" ], "properties": { - "entityType": { - "const": "program" + "action": { + "const": "channel" }, - "programType": { + "data": { "type": "string", "enum": [ - "concert", - "sportingEvent", - "preview", - "other", - "advertisement", - "musicVideo", - "minisode", - "extra" + "next", + "previous" ] - }, - "entityId": { - "$ref": "#/definitions/Identifier" - }, - "assetId": { - "$ref": "#/definitions/Identifier" - }, - "appContentData": { - "type": "string", - "maxLength": 256 - } - }, - "additionalProperties": false - } - ], - "examples": [ - { - "entityType": "program", - "programType": "concert", - "entityId": "live-aid" - } - ] - }, - "UntypedEntity": { - "title": "UntypedEntity", - "allOf": [ - { - "description": "A Firebolt compliant representation of the remaining entity types.", - "type": "object", - "required": [ - "entityId" - ], - "properties": { - "entityId": { - "$ref": "#/definitions/Identifier" - }, - "assetId": { - "$ref": "#/definitions/Identifier" - }, - "appContentData": { - "type": "string", - "maxLength": 256 } - }, - "additionalProperties": false - } - ], - "examples": [ - { - "entityId": "an-entity" + } } ] }, @@ -833,7 +495,7 @@ "additionalProperties": false, "properties": { "entity": { - "$ref": "#/definitions/ChannelEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/ChannelEntity" }, "options": { "description": "The options property of the data property MUST have only one of the following fields.", @@ -902,7 +564,7 @@ "const": "playback" }, "data": { - "$ref": "#/definitions/PlayableEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/PlayableEntity" } } } @@ -994,7 +656,8 @@ }, "additionalProperties": false } - } + }, + "required": [ "data" ] } ], "examples": [ @@ -1032,7 +695,7 @@ "type": "object", "properties": { "entity": { - "$ref": "#/definitions/PlayableEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/PlayableEntity" }, "options": { "type": "object", @@ -1076,6 +739,7 @@ "type": "object", "properties": { "options": { + "type": "object", "maxProperties": 1 } } @@ -1084,6 +748,7 @@ "type": "object", "properties": { "options": { + "type": "object", "maxProperties": 0 } } @@ -1272,7 +937,7 @@ "menus": { "type": "array", "items": { - "$ref": "#/definitions/Identifier" + "type": "string" }, "minItems": 1, "maxItems": 100 @@ -1283,7 +948,7 @@ "type": "object", "properties": { "appId": { - "$ref": "#/definitions/Identifier" + "type": "string" }, "exclude": { "type": "boolean" @@ -1369,19 +1034,19 @@ "entity": { "anyOf": [ { - "$ref": "#/definitions/MovieEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/MovieEntity" }, { - "$ref": "#/definitions/TVEpisodeEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/TVEpisodeEntity" }, { - "$ref": "#/definitions/TVSeriesEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/TVSeriesEntity" }, { - "$ref": "#/definitions/TVSeasonEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/TVSeasonEntity" }, { - "$ref": "#/definitions/AdditionalEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/AdditionalEntity" } ] }, @@ -1391,24 +1056,24 @@ "type": "object", "properties": { "appId": { - "$ref": "#/definitions/Identifier" + "type": "string" }, "entity": { "anyOf": [ { - "$ref": "#/definitions/MovieEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/MovieEntity" }, { - "$ref": "#/definitions/TVEpisodeEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/TVEpisodeEntity" }, { - "$ref": "#/definitions/TVSeriesEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/TVSeriesEntity" }, { - "$ref": "#/definitions/TVSeasonEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/TVSeasonEntity" }, { - "$ref": "#/definitions/AdditionalEntity" + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/AdditionalEntity" } ] } @@ -1419,7 +1084,7 @@ "menus": { "type": "array", "items": { - "$ref": "#/definitions/Identifier" + "type": "string" }, "minItems": 1, "maxItems": 100 @@ -1430,7 +1095,7 @@ "type": "object", "properties": { "appId": { - "$ref": "#/definitions/Identifier" + "type": "string" }, "exclude": { "type": "boolean" @@ -1487,9 +1152,9 @@ } ] }, - "ButtonIntent": { - "description": "A Firebolt compliant representation of a user intention to interact with their device in a way analogous to pressing one of the remote buttons.", - "title": "ButtonIntent", + "FocusIntent": { + "description": "A Firebolt compliant representation of a user intention to interact with their device in a way analogous to pressing remote directional pad buttons.", + "title": "FocusIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -1499,30 +1164,24 @@ }, { "type": "object", + "required": [ "data" ], "properties": { "action": { - "const": "button" + "const": "focus" }, "data": { "type": "object", "required": [ - "operation" + "direction" ], "properties": { - "operation": { + "direction": { "type": "string", "enum": [ - "down", "up", - "prev", - "next", - "enter", - "exit", - "info", - "menu", - "back", - "cancel", - "record" + "down", + "left", + "right" ] } }, @@ -1533,9 +1192,9 @@ ], "examples": [ { - "action": "button", + "action": "focus", "data": { - "operation": "menu" + "direction": "up" }, "context": { "source": "voice" @@ -1543,9 +1202,9 @@ } ] }, - "VolumeIntent": { - "description": "A Firebolt compliant representation of a user intention to change the device volume.", - "title": "VolumeIntent", + "SelectIntent": { + "description": "A Firebolt compliant representation of a user intention to interact with their device in a way analogous to pressing the remote 'select' button.", + "title": "SelectIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -1557,79 +1216,88 @@ "type": "object", "properties": { "action": { - "const": "volume" - }, - "data": { - "anyOf": [ - { - "type": "object", - "properties": { - "value": { - "type": "number", - "minimum": 0, - "maximum": 1 - }, - "toggle": { - "const": true - } - }, - "minProperties": 1, - "maxProperties": 1, - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "value": { - "type": "number", - "minimum": 0, - "maximum": 1 - }, - "relative": { - "const": true - } - }, - "additionalProperties": false - } - ] + "const": "select" } + }, + "not": { + "required": [ "data" ] } } ], "examples": [ { - "action": "volume", - "data": { - "toggle": true - }, + "action": "select", "context": { "source": "voice" } + } + ] + }, + "BackIntent": { + "description": "A Firebolt compliant representation of a user intention to interact with their device in a way analogous to pressing the remote 'back' button.", + "title": "BackIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" }, { - "action": "volume", - "data": { - "value": 0.7 + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "back" + } }, + "not": { + "required": [ "data" ] + } + } + ], + "examples": [ + { + "action": "back", "context": { "source": "voice" } + } + ] + }, + "ExitIntent": { + "description": "A Firebolt compliant representation of a user intention to interact with their device in a way analogous to pressing the remote 'back' button.", + "title": "ExitIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" }, { - "action": "volume", - "data": { - "value": 0.1, - "relative": true + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "exit" + } }, + "not": { + "required": [ "data" ] + } + } + ], + "examples": [ + { + "action": "exit", "context": { "source": "voice" } } ] - }, - "PowerIntent": { - "description": "A Firebolt compliant representation of a user intention to turn their device on or off.", - "title": "PowerIntent", + }, + "ScrollIntent": { + "description": "A Firebolt compliant representation of a user intention to interact with their device in a way analogous to pressing remote directional pad buttons.", + "title": "ScrollIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -1639,30 +1307,101 @@ }, { "type": "object", + "required": [ "data" ], "properties": { "action": { - "const": "power" + "const": "scroll" }, "data": { - "$ref": "#/definitions/BooleanToggle" + "type": "object", + "required": [ + "direction" + ], + "properties": { + "direction": { + "type": "string", + "enum": [ + "up", + "down", + "left", + "right" + ] + }, + "unit": { + "type": "string", + "enum": [ + "line", + "page", + "percent" + ] + } + }, + "additionalProperties": false } } } ], "examples": [ { - "action": "power", + "action": "scroll", "data": { - "value": false + "direction": "up" }, "context": { "source": "voice" } + } + ] + }, + "ButtonIntent": { + "description": "A Firebolt compliant representation of a user intention to interact with their device in a way analogous to pressing one of the remote buttons.", + "title": "ButtonIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" }, { - "action": "power", + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "button" + }, + "data": { + "type": "object", + "required": [ + "operation" + ], + "properties": { + "operation": { + "type": "string", + "enum": [ + "down", + "up", + "prev", + "next", + "enter", + "exit", + "info", + "menu", + "back", + "cancel", + "record" + ] + } + }, + "additionalProperties": false + } + } + } + ], + "examples": [ + { + "action": "button", "data": { - "toggle": true + "operation": "menu" }, "context": { "source": "voice" @@ -1670,9 +1409,9 @@ } ] }, - "MicrophoneIntent": { - "description": "A Firebolt compliant representation of a user intention to turn their microphone on or off.", - "title": "MicrophoneIntent", + "VolumeIntent": { + "description": "A Firebolt compliant representation of a user intention to change the device volume.", + "title": "VolumeIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -1684,28 +1423,60 @@ "type": "object", "properties": { "action": { - "const": "microphone" + "const": "volume" }, "data": { - "$ref": "#/definitions/BooleanToggle" + "type": "object", + "properties": { + "value": { + "type": "number" + }, + "relative": { + "const": true + } + }, + "required": [ "value" ], + "if": { + "required": [ "relative" ] + }, + "then": { + "properties": { + "value": { + "type": "number", + "minimum": -50, + "maximum": 50 + } + } + }, + "else": { + "properties": { + "value": { + "type": "number", + "minimum": 0, + "maximum": 100 + } + } + }, + "additionalProperties": false } } } ], "examples": [ { - "action": "microphone", + "action": "volume", "data": { - "value": false + "value": 70 }, "context": { "source": "voice" } }, { - "action": "microphone", + "action": "volume", "data": { - "toggle": true + "value": 10, + "relative": true }, "context": { "source": "voice" @@ -1713,9 +1484,9 @@ } ] }, - "InputIntent": { - "description": "A Firebolt compliant representation of a user intention to change which video input is active.", - "title": "InputIntent", + "MuteIntent": { + "description": "A Firebolt compliant representation of a user intention to mute or unmute the device.", + "title": "MuteIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -1727,49 +1498,28 @@ "type": "object", "properties": { "action": { - "const": "input" + "const": "mute" }, "data": { - "type": "object", - "required": [ - "interface" - ], - "properties": { - "interface": { - "type": "string", - "enum": [ - "hdmi", - "rca", - "vga", - "etc..." - ] - }, - "number": { - "type": "integer", - "minimum": 1, - "maximum": 100 - } - }, - "additionalProperties": false + "$ref": "#/definitions/BooleanToggle" } } } ], "examples": [ { - "action": "input", + "action": "mute", "data": { - "interface": "hdmi" + "value": false }, "context": { "source": "voice" } }, { - "action": "input", + "action": "mute", "data": { - "interface": "hdmi", - "number": 1 + "toggle": true }, "context": { "source": "voice" @@ -1777,9 +1527,9 @@ } ] }, - "PauseIntent": { - "description": "A Firebolt compliant representation of a user intention to pause/unpause in-progress playback.", - "title": "PauseIntent", + "PowerIntent": { + "description": "A Firebolt compliant representation of a user intention to turn their device on or off.", + "title": "PowerIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -1791,28 +1541,529 @@ "type": "object", "properties": { "action": { - "const": "pause" + "const": "power" }, "data": { - "$ref": "#/definitions/BooleanToggle" + "type": "object", + "properties": { + "value": { + "type": "boolean" + }, + "toggle": { + "const": true + }, + "delay": { + "type": "integer", + "minimum": 0 + } + }, + "if": { + "required": [ "value" ] + }, + "then": { + "not": { + "required": [ "toggle" ] + } + }, + "else": { + "required": [ "toggle" ] + }, + "additionalProperties": false + } + } + } + ], + "examples": [ + { + "action": "power", + "data": { + "value": false + }, + "context": { + "source": "voice" + } + }, + { + "action": "power", + "data": { + "toggle": true + }, + "context": { + "source": "voice" + } + }, + { + "action": "power", + "data": { + "value": false, + "delay": 900 + }, + "context": { + "source": "voice" + } + } + ] + }, + "MicrophoneIntent": { + "description": "A Firebolt compliant representation of a user intention to turn their microphone on or off.", + "title": "MicrophoneIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" + }, + { + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "microphone" + }, + "data": { + "$ref": "#/definitions/BooleanToggle" + } + } + } + ], + "examples": [ + { + "action": "microphone", + "data": { + "value": false + }, + "context": { + "source": "voice" + } + }, + { + "action": "microphone", + "data": { + "toggle": true + }, + "context": { + "source": "voice" + } + } + ] + }, + "InputIntent": { + "description": "A Firebolt compliant representation of a user intention to change which video input is active.", + "title": "InputIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" + }, + { + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "input" + }, + "data": { + "type": "object", + "required": [ + "interface" + ], + "properties": { + "interface": { + "type": "string", + "enum": [ + "hdmi" + ] + }, + "number": { + "type": "integer", + "minimum": 1, + "maximum": 100 + } + }, + "additionalProperties": false + } + } + } + ], + "examples": [ + { + "action": "input", + "data": { + "interface": "hdmi" + }, + "context": { + "source": "voice" + } + }, + { + "action": "input", + "data": { + "interface": "hdmi", + "number": 1 + }, + "context": { + "source": "voice" + } + } + ] + }, + "PauseIntent": { + "description": "A Firebolt compliant representation of a user intention to pause in-progress playback.", + "title": "PauseIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" + }, + { + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "pause" + } + } + } + ], + "examples": [ + { + "action": "pause", + "context": { + "source": "voice" + } + } + ] + }, + "PlayIntent": { + "description": "A Firebolt compliant representation of a user intention to play/resume content.", + "title": "PlayIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" + }, + { + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "play" + } + } + } + ], + "examples": [ + { + "action": "play", + "context": { + "source": "voice" + } + } + ] + }, + "ReplayIntent": { + "description": "A Firebolt compliant representation of a user intention to replay content.", + "title": "ReplayIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" + }, + { + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "replay" + } + } + } + ], + "examples": [ + { + "action": "replay", + "context": { + "source": "voice" + } + } + ] + }, + "StopIntent": { + "description": "A Firebolt compliant representation of a user intention to stop content.", + "title": "StopIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" + }, + { + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "stop" + } + } + } + ], + "examples": [ + { + "action": "stop", + "context": { + "source": "voice" + } + } + ] + }, + "PlaybackSpeedIntent": { + "description": "A Firebolt compliant representation of a user intention to change the speed of in-progress playback.", + "title": "PlaybackSpeedIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" + }, + { + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "speed" + }, + "data": { + "type": "object", + "properties": { + "value": { + "type": "number", + "exclusiveMinimum": 0, + "maximum": 4 + }, + "toggle": { + "type": "boolean" + } + }, + "minProperties": 1, + "maxProperties": 1, + "additionalProperties": false + } + } + } + ], + "examples": [ + { + "action": "speed", + "data": { + "value": 2 + }, + "context": { + "source": "voice" + } + }, + { + "action": "speed", + "data": { + "toggle": true + }, + "context": { + "source": "voice" + } + } + ] + }, + "FastForwardIntent": { + "description": "A Firebolt compliant representation of a user intention to fast-forward in-progress playback.", + "title": "FastForwardIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" + }, + { + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "fast-forward" + }, + "data": { + "type": "object", + "properties": { + "speed": { + "type": "number", + "exclusiveMinimum": 0, + "maximum": 10 + } + } + } + } + } + ], + "examples": [ + { + "action": "fast-forward", + "data": { + "speed": 2 + }, + "context": { + "source": "voice" + } + }, + { + "action": "fast-forward", + "data": { + "speed": 0.5 + }, + "context": { + "source": "voice" + } + }, + { + "action": "fast-forward", + "context": { + "source": "voice" + } + } + ] + }, + "RewindIntent": { + "description": "A Firebolt compliant representation of a user intention to rewind in-progress playback.", + "title": "RewindIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" + }, + { + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "rewind" + }, + "data": { + "type": "object", + "properties": { + "speed": { + "type": "number", + "exclusiveMinimum": 0, + "maximum": 10 + } + } + } + } + } + ], + "examples": [ + { + "action": "rewind", + "data": { + "speed": 2 + }, + "context": { + "source": "voice" + } + }, + { + "action": "rewind", + "data": { + "speed": 0.5 + }, + "context": { + "source": "voice" + } + }, + { + "action": "rewind", + "context": { + "source": "voice" + } + } + ] + }, + "SeekIntent": { + "description": "A Firebolt compliant representation of a user intention to seek to a different time for in-progress playback.", + "title": "SeekIntent", + "allOf": [ + { + "$ref": "#/definitions/Intent" + }, + { + "$ref": "#/definitions/IntentProperties" + }, + { + "type": "object", + "properties": { + "action": { + "const": "seek" + }, + "data": { + "allOf": [ + { + "$ref": "#/definitions/DirectionalOperation" + }, + { + "type": "object", + "properties": { + "seconds": { + "type": "number" + }, + "relative": { + "const": true + } + }, + "required": [ "seconds" ], + "if": { + "not": { + "required": [ "relative" ] + } + }, + "then": { + "properties": { + "seconds": { + "type": "number", + "minimum": 0, + "maximum": 86400 + } + } + }, + "else": { + "properties": { + "seconds": { + "type": "number", + "minimum": -43200, + "maximum": 43200 + } + } + } + } + ] } } } ], "examples": [ { - "action": "pause", + "action": "seek", "data": { - "value": false + "seconds": 300 }, "context": { "source": "voice" } }, { - "action": "pause", + "action": "seek", "data": { - "toggle": true + "relative": true, + "seconds": -30 }, "context": { "source": "voice" @@ -1820,9 +2071,9 @@ } ] }, - "PlaybackSpeedIntent": { - "description": "A Firebolt compliant representation of a user intention to change the speed of in-progress playback.", - "title": "PlaybackSpeedIntent", + "SkipIntent": { + "description": "A Firebolt compliant representation of a user intention to skip a scene/chapter/ad during in-progress playback.", + "title": "SkipIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -1834,41 +2085,50 @@ "type": "object", "properties": { "action": { - "const": "speed" + "const": "skip" }, "data": { - "type": "object", - "properties": { - "value": { - "type": "number", - "exclusiveMinimum": 0, - "maximum": 4 + "allOf": [ + { + "$ref": "#/definitions/DirectionalOperation" }, - "toggle": { - "type": "boolean" + { + "type": "object", + "properties": { + "count": { + "type": "number", + "exclusiveMinimum": 0, + "maximum": 100 + } + }, + "propertyNames": { + "enum": [ + "direction", + "count" + ] + } } - }, - "minProperties": 1, - "maxProperties": 1, - "additionalProperties": false + ] } } } ], "examples": [ { - "action": "speed", + "action": "skip", "data": { - "value": 2 + "direction": "forward", + "count": 1 }, "context": { "source": "voice" } }, { - "action": "speed", + "action": "skip", "data": { - "toggle": true + "direction": "backward", + "count": 1 }, "context": { "source": "voice" @@ -1876,9 +2136,9 @@ } ] }, - "TrickPlayIntent": { - "description": "A Firebolt compliant representation of a user intention to fast-forward or rewind in-progress playback.", - "title": "TrickPlayIntent", + "ClosedCaptionsIntent": { + "description": "A Firebolt compliant representation of a user intention to enable/disable closed captions.", + "title": "ClosedCaptionsIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -1890,50 +2150,28 @@ "type": "object", "properties": { "action": { - "const": "trickplay" + "const": "closed-captions" }, "data": { - "allOf": [ - { - "$ref": "#/definitions/DirectionalOperation" - }, - { - "type": "object", - "properties": { - "speed": { - "type": "number", - "exclusiveMinimum": 0, - "maximum": 10 - } - }, - "propertyNames": { - "enum": [ - "direction", - "speed" - ] - } - } - ] + "$ref": "#/definitions/BooleanToggle" } } } ], "examples": [ { - "action": "trickplay", + "action": "closed-captions", "data": { - "direction": "forward", - "speed": 2 + "value": false }, "context": { "source": "voice" } }, { - "action": "trickplay", + "action": "closed-captions", "data": { - "direction": "backward", - "speed": 2 + "toggle": true }, "context": { "source": "voice" @@ -1941,9 +2179,9 @@ } ] }, - "SeekIntent": { - "description": "A Firebolt compliant representation of a user intention to seek to a different time for in-progress playback.", - "title": "SeekIntent", + "VoiceGuidanceIntent": { + "description": "A Firebolt compliant representation of a user intention to enable/disable voice guidance.", + "title": "VoiceGuidanceIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -1955,59 +2193,100 @@ "type": "object", "properties": { "action": { - "const": "seek" + "const": "voice-guidance" }, "data": { - "allOf": [ - { - "$ref": "#/definitions/DirectionalOperation" + "type": "object", + "properties": { + "value": { + "type": "boolean" }, - { - "type": "object", + "toggle": { + "const": true + }, + "speed": { + "type": "integer" + }, + "relative": { + "const": true + }, + "verbosity": { + "type": "string", + "enum": [ + "low", + "hight" + ] + } + }, + "if": { + "required": [ "value" ] + }, + "then": { + "not": { + "required": [ "toggle" ] + }, + "if": { + "required": [ "relative" ] + }, + "then": { "properties": { - "seconds": { - "type": "number", - "minimum": 0, - "maximum": 1800 + "speed": { + "type": "integer", + "minimum": -10, + "maximum": 10 + } + } + }, + "else": { + "properties": { + "speed": { + "type": "integer", + "exclusiveMinimum": 0, + "maximum": 10 } - }, - "propertyNames": { - "enum": [ - "direction", - "seconds" - ] } } - ] + }, + "else": { + "if": { + "required": [ "toggle" ] + }, + "then": { + "not": { + "required": [ "value" ] + } + } + }, + "additionalProperties": false } } } ], "examples": [ { - "action": "seek", + "action": "voice-guidance", "data": { - "seconds": 300 + "value": true, + "verbosity": "low" }, "context": { "source": "voice" } }, { - "action": "seek", + "action": "voice-guidance", "data": { - "direction": "forward", - "seconds": 30 + "speed": -1, + "relative": true }, "context": { "source": "voice" } - }, + }, { - "action": "seek", + "action": "voice-guidance", "data": { - "direction": "backward", - "seconds": 30 + "toggle": true }, "context": { "source": "voice" @@ -2015,9 +2294,9 @@ } ] }, - "SkipIntent": { - "description": "A Firebolt compliant representation of a user intention to skip a scene/chapter/ad during in-progress playback.", - "title": "SkipIntent", + "AudioDescriptionsIntent": { + "description": "A Firebolt compliant representation of a user intention to enable/disable audio descriptions.", + "title": "AudioDescriptionsIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -2029,50 +2308,61 @@ "type": "object", "properties": { "action": { - "const": "skip" + "const": "audio-descriptions" }, "data": { - "allOf": [ - { - "$ref": "#/definitions/DirectionalOperation" + "type": "object", + "properties": { + "value": { + "type": "boolean" }, - { - "type": "object", - "properties": { - "count": { - "type": "number", - "exclusiveMinimum": 0, - "maximum": 100 - } - }, - "propertyNames": { - "enum": [ - "direction", - "count" - ] - } + "toggle": { + "const": true + }, + "language": { + "$ref": "https://meta.comcast.com/firebolt/localization#/definitions/ISO639_2Language" } - ] + }, + "if": { + "required": [ "value" ] + }, + "then": { + "not": { + "required": [ "toggle" ] + } + }, + "else": { + "required": [ "toggle" ] + }, + "additionalProperties": false } } } ], "examples": [ { - "action": "skip", + "action": "audio-descriptions", "data": { - "direction": "forward", - "count": 1 + "value": false }, "context": { "source": "voice" } }, { - "action": "skip", + "action": "audio-descriptions", "data": { - "direction": "backward", - "count": 1 + "toggle": true + }, + "context": { + "source": "voice" + } + }, + { + "action": "audio-descriptions", + "data": { + "value": true, + "language": "eng" }, "context": { "source": "voice" @@ -2080,9 +2370,9 @@ } ] }, - "ClosedCaptionsIntent": { - "description": "A Firebolt compliant representation of a user intention to enable/disable closed captions.", - "title": "ClosedCaptionsIntent", + "HighContrastIntent": { + "description": "A Firebolt compliant representation of a user intention to enable or disable high contrast mode.", + "title": "HighContrastIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -2094,7 +2384,7 @@ "type": "object", "properties": { "action": { - "const": "closedcaptions" + "const": "high-contrast" }, "data": { "$ref": "#/definitions/BooleanToggle" @@ -2104,7 +2394,7 @@ ], "examples": [ { - "action": "closedcaptions", + "action": "high-contrast", "data": { "value": false }, @@ -2113,7 +2403,7 @@ } }, { - "action": "closedcaptions", + "action": "high-contrast", "data": { "toggle": true }, @@ -2122,10 +2412,10 @@ } } ] - }, - "AudioDescriptionIntent": { - "description": "A Firebolt compliant representation of a user intention to enable/disable audio descriptions.", - "title": "AudioDescriptionIntent", + }, + "ScreenMagnificationIntent": { + "description": "A Firebolt compliant representation of a user intention to turn screen magnification on or off.", + "title": "ScreenMagnificationIntent", "allOf": [ { "$ref": "#/definitions/Intent" @@ -2137,17 +2427,40 @@ "type": "object", "properties": { "action": { - "const": "audiodescriptions" + "const": "screen-magnification" }, "data": { - "$ref": "#/definitions/BooleanToggle" + "type": "object", + "properties": { + "value": { + "type": "boolean" + }, + "toggle": { + "const": true + }, + "scale": { + "type": "number", + "minimum": 1, + "maximum": 10 + } + }, + "if": { + "required": [ + "toggle" + ] + }, + "then": { + "type": "object", + "maxProperties": 1 + }, + "additionalProperties": false } } } ], "examples": [ { - "action": "audiodescriptions", + "action": "screen-magnification", "data": { "value": false }, @@ -2156,14 +2469,33 @@ } }, { - "action": "audiodescriptions", + "action": "screen-magnification", + "data": { + "value": true, + "scale": 2.5 + }, + "context": { + "source": "voice" + } + }, + { + "action": "screen-magnification", "data": { "toggle": true }, "context": { "source": "voice" } - } + }, + { + "action": "screen-magnification", + "data": { + "value": false + }, + "context": { + "source": "voice" + } + } ] }, "MessageIntent": { @@ -2205,6 +2537,7 @@ } ] }, + "Identifier": { "type": "string" }, @@ -2229,7 +2562,7 @@ "type": "string" }, "appId": { - "$ref": "#/definitions/Identifier" + "type": "string" } } }, diff --git a/src/schemas/lifecycle.json b/src/schemas/lifecycle.json new file mode 100644 index 000000000..906cf41ea --- /dev/null +++ b/src/schemas/lifecycle.json @@ -0,0 +1,38 @@ +{ + "$id": "https://meta.comcast.com/firebolt/lifecycle", + "title": "Lifecycle", + "oneOf": [ + { + "$ref": "#/definitions/LifecycleState" + }, + { + "$ref": "#/definitions/CloseReason" + } + ], + "definitions": { + "LifecycleState": { + "title": "LifecycleState", + "description": "The application lifecycle state", + "type": "string", + "enum": [ + "initializing", + "inactive", + "foreground", + "background", + "unloading", + "suspended" + ] + }, + "CloseReason": { + "title": "CloseReason", + "description": "The application close reason", + "type": "string", + "enum": [ + "remoteButton", + "userExit", + "done", + "error" + ] + } + } +} diff --git a/src/schemas/types.json b/src/schemas/types.json new file mode 100644 index 000000000..0caa49c1f --- /dev/null +++ b/src/schemas/types.json @@ -0,0 +1,194 @@ +{ + "$id": "https://meta.comcast.com/firebolt/types", + "title": "Types", + "definitions": { + "SemanticVersion": { + "title": "SemanticVersion", + "type": "object", + "properties": { + "major": { + "type": "integer", + "minimum": 0 + }, + "minor": { + "type": "integer", + "minimum": 0 + }, + "patch": { + "type": "integer", + "minimum": 0 + }, + "readable": { + "type": "string" + } + }, + "required": [ + "major", + "minor", + "patch", + "readable" + ], + "additionalProperties": false + }, + "AudioProfile": { + "title": "AudioProfile", + "type": "string", + "enum": [ + "stereo", + "dolbyDigital5.1", + "dolbyDigital7.1", + "dolbyDigital5.1+", + "dolbyDigital7.1+", + "dolbyAtmos" + ] + }, + "BooleanMap": { + "title": "BooleanMap", + "type": "object", + "additionalProperties": { + "type": "boolean" + } + }, + "FlatMap": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "number" + }, + { + "type": "boolean" + } + ] + } + }, + "LocalizedString": { + "title": "LocalizedString", + "description": "Localized string supports either a simple `string` or a Map of language codes to strings. When using a simple `string`, the current preferred langauge from `Localization.langauge()` is assumed.", + "oneOf": [ + { + "type": "string" + }, + { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + ], + "examples": [ + "A simple string, with no language code", + { + "en": "This is english", + "es": "esto es español" + } + ] + }, + "ListenResponse": { + "title": "ListenResponse", + "type": "object", + "required": [ + "event", + "listening" + ], + "properties": { + "event": { + "type": "string", + "pattern": "[a-zA-Z]+\\.on[A-Z][a-zA-Z]+" + }, + "listening": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "ProviderRequest": { + "title": "ProviderRequest", + "type": "object", + "required": [ + "correlationId" + ], + "additionalProperties": false, + "properties": { + "correlationId": { + "type": "string", + "description": "The id that was passed in to the event that triggered a provider method to be called" + }, + "parameters": { + "description": "The result of the provider response.", + "type": ["object", "null"] + } + } + }, + "ProviderResponse": { + "title": "ProviderResponse", + "type": "object", + "required": [ + "correlationId" + ], + "additionalProperties": false, + "properties": { + "correlationId": { + "type": "string", + "description": "The id that was passed in to the event that triggered a provider method to be called" + }, + "result": { + "description": "The result of the provider response." + } + } + }, + "Timeout": { + "title": "Timeout", + "description": "Defines the timeout in seconds. If the threshold for timeout is passed for any operation without a result it will throw an error.", + "type": "integer", + "default": 0, + "minimum": 0, + "maximum": 9999 + }, + "Dimensions": { + "type": "object", + "properties": { + "width": { + "type": "integer", + "minimum": 1 + }, + "height": { + "type": "integer", + "minimum": 1 + } + }, + "required": [ "width", "height" ] + }, + "Image": { + "type": "object", + "properties": { + "uri": { + "description": "URI for the image. May be a relative path (e.g. ./foo/image.png) or absolute (e.g. https://foo.com/bar.png) depending on usage.", + "type": "string" + }, + "aspectRatio": { + "description": "The aspect ratio of the image", + "type": "string", + "pattern": "^\\d+x\\d+" + }, + "description": { + "description": "Description of the image.", + "type": "string" + }, + "type": { + "description": "The type of the image.", + "type": "string", + "enum": [ + "icon", "poster", "banner", "splash", "hero" + ] + } + }, + "required": [ + "uri", "aspectRatio", "type" + ] + } + } +} \ No newline at end of file diff --git a/src/sdks/core/CHANGELOG.md b/src/sdks/core/CHANGELOG.md index 17b2ff8bb..7946afebf 100644 --- a/src/sdks/core/CHANGELOG.md +++ b/src/sdks/core/CHANGELOG.md @@ -1,9 +1,22 @@ +# 1.2.0 (https://github.com/rdkcentral/firebolt-apis/compare/v1.1.0...v1.2.0) (2024-06-14) + +### Bug Fixes + +* Add PlaylistEntity to EntityIntent (9769d6d (https://github.com/rdkcentral/firebolt-apis/commit/9769d6d7d43f1d61dfcda16ba4806175c5cf7658)) +* Remove x-alternatives that don't exist (#278 (https://github.com/rdkcentral/firebolt-apis/issues/278)) (e38ad5a (https://github.com/rdkcentral/firebolt-apis/commit/e38ad5a508fccb5c724cf0f03cbd67ad4a28378c)) +* Removed sdk as required field from Device.version (#231 (https://github.com/rdkcentral/firebolt-apis/issues/231)) (ef3de3e (https://github.com/rdkcentral/firebolt-apis/commit/ef3de3e68619c6f666dd1d751b0acc25f6438122)) + +### Features + +* [Command and Control Intents](https://github.com/rdkcentral/firebolt-apis/blob/main/requirements/specifications/intents/command-and-control.md) (#251 (https://github.com/rdkcentral/firebolt-apis/issues/251)) (c8f8dae (https://github.com/rdkcentral/firebolt-apis/commit/c8f8dae5a9a0f14a3815c04df5a55763823d4898)) +* [User Interest](https://github.com/rdkcentral/firebolt-apis/blob/main/requirements/specifications/discovery/user-interest.md) (#170 (https://github.com/rdkcentral/firebolt-apis/issues/170)) (48a1094 (https://github.com/rdkcentral/firebolt-apis/commit/48a1094aaab6418f09db662dbc81f090a34f32ed)) + # [1.1.0](https://github.com/rdkcentral/firebolt-apis/compare/v1.0.0...v1.1.0) (2024-02-09) ### Bug Fixes - * Add Music to Playable entities (#225 (https://github.com/rdkcentral/firebolt-apis/issues/225)) (22c9b71 (https://github.com/rdkcentral/firebolt-apis/commit/22c9b71d3c0ee98d32585d1b365afabf8e64d6ed)) - * Modified account:uid to SHOULD (#224 (https://github.com/rdkcentral/firebolt-apis/issues/224)) (70c8b24 (https://github.com/rdkcentral/firebolt-apis/commit/70c8b24decfcbff2c32fb1b0d21290afc00a8432)) +* Add Music to Playable entities (#225 (https://github.com/rdkcentral/firebolt-apis/issues/225)) (22c9b71 (https://github.com/rdkcentral/firebolt-apis/commit/22c9b71d3c0ee98d32585d1b365afabf8e64d6ed)) +* Modified account:uid to SHOULD (#224 (https://github.com/rdkcentral/firebolt-apis/issues/224)) (70c8b24 (https://github.com/rdkcentral/firebolt-apis/commit/70c8b24decfcbff2c32fb1b0d21290afc00a8432)) # [1.0.0](https://github.com/rdkcentral/firebolt-apis/compare/v0.17.1...v1.0.0) (2023-11-03) @@ -11,12 +24,12 @@ Upgraded to 1.0 at part of RDK6 release. This API is still compatibile with 0.x ### Bug Fixes - * Updated Discovery.launch example with xrn:firebolt: application-type (#187 (https://github.com/rdkcentral/firebolt-apis/issues/187)) (4dbbab3 (https://github.com/rdkcentral/firebolt-apis/commit/4dbbab3d9fa68c0e5185ca72fd0170bae8a30139)) +* Updated Discovery.launch example with xrn:firebolt: application-type (#187 (https://github.com/rdkcentral/firebolt-apis/issues/187)) (4dbbab3 (https://github.com/rdkcentral/firebolt-apis/commit/4dbbab3d9fa68c0e5185ca72fd0170bae8a30139)) ### Features - * Added scope parameter for advertisingId (#188 (https://github.com/rdkcentral/firebolt-apis/issues/188)) - * Play Intent (#151 (https://github.com/rdkcentral/firebolt-apis/issues/151)) (d1ddf3f (https://github.com/rdkcentral/firebolt-apis/commit/d1ddf3fb3b1f758315686ad2f6dc57c2b270f33a)) +* Added scope parameter for advertisingId (#188 (https://github.com/rdkcentral/firebolt-apis/issues/188)) +* Play Intent (#151 (https://github.com/rdkcentral/firebolt-apis/issues/151)) (d1ddf3f (https://github.com/rdkcentral/firebolt-apis/commit/d1ddf3fb3b1f758315686ad2f6dc57c2b270f33a)) # [0.17.1](https://github.com/rdkcentral/firebolt-apis/compare/v0.17.0...v0.17.1) (2023-09-15) diff --git a/src/sdks/core/package.json b/src/sdks/core/package.json index b97be4a3f..50ffe5878 100644 --- a/src/sdks/core/package.json +++ b/src/sdks/core/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/sdk", - "version": "1.2.0-next.2", + "version": "1.3.0-next.1", "description": "The Firebolt JS SDK", "main": "./dist/lib/firebolt.mjs", "types": "./dist/lib/firebolt.d.ts", diff --git a/src/sdks/core/sdk.config.json b/src/sdks/core/sdk.config.json index f406f8bea..14ba4d55c 100644 --- a/src/sdks/core/sdk.config.json +++ b/src/sdks/core/sdk.config.json @@ -69,7 +69,8 @@ ], "provide": [ "xrn:firebolt:capability:discovery:entity-info", - "xrn:firebolt:capability:discovery:purchased-content" + "xrn:firebolt:capability:discovery:purchased-content", + "xrn:firebolt:capability:discovery:interest" ] }, { diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp index 065cfea6b..e50d394de 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp @@ -18,8 +18,11 @@ #include #include +#include +#include #include "CoreSDKTest.h" + using namespace std; bool CoreSDKTest::_connected; CoreSDKTest::OnPolicyChangedNotification CoreSDKTest::_policyChangedNotification; @@ -93,9 +96,11 @@ void CoreSDKTest::GetAccountId() if (error == Firebolt::Error::None) { cout << "Get Account Id = " << id.c_str() << endl; } else { - cout << "Get Account Id status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAccountId failed. " + errorMessage); } } + void CoreSDKTest::GetAccountUid() { Firebolt::Error error = Firebolt::Error::None; @@ -103,7 +108,8 @@ void CoreSDKTest::GetAccountUid() if (error == Firebolt::Error::None) { cout << "Get Account Uid = " << uid.c_str() << endl; } else { - cout << "Get Account Uid status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAccountUid failed. " + errorMessage); } } @@ -143,6 +149,7 @@ void PrintAdvertisingPolicy(const Firebolt::Advertising::AdPolicy& policy) cout << "\tlimitAdTracking : " << policy.limitAdTracking.value() << endl; } } + void CoreSDKTest::GetAdvertisingPolicy() { Firebolt::Error error = Firebolt::Error::None; @@ -151,14 +158,17 @@ void CoreSDKTest::GetAdvertisingPolicy() cout << "Get Advertising policy --> " << endl; PrintAdvertisingPolicy(policy); } else { - cout << "Get Advertising policy status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAdvertisingPolicy failed. " + errorMessage); } } -void CoreSDKTest::OnPolicyChangedNotification::onPolicyChanged( const Firebolt::Advertising::AdPolicy& policy ) + +void CoreSDKTest::OnPolicyChangedNotification::onPolicyChanged(const Firebolt::Advertising::AdPolicy& policy) { cout << "New policy --> " << endl; PrintAdvertisingPolicy(policy); } + void CoreSDKTest::SubscribeAdvertisingPolicyChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -166,9 +176,11 @@ void CoreSDKTest::SubscribeAdvertisingPolicyChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Advertising PolicyChange is success" << endl; } else { - cout << "Subscribe Advertising PolicyChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeAdvertisingPolicyChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeAdvertisingPolicyChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -176,9 +188,11 @@ void CoreSDKTest::UnsubscribeAdvertisingPolicyChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Advertising PolicyChange is success" << endl; } else { - cout << "Unsubscribe Advertising PolicyChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeAdvertisingPolicyChanged failed. " + errorMessage); } } + void CoreSDKTest::BuildAdvertisingConfiguration() { Firebolt::Error error = Firebolt::Error::None; @@ -191,9 +205,11 @@ void CoreSDKTest::BuildAdvertisingConfiguration() if (error == Firebolt::Error::None) { cout << "Build AdvertisingConfiguration is success, adFrameworkConfig : " << adFrameworkConfig << endl; } else { - cout << "Build AdvertisingConfiguration status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("BuildAdvertisingConfiguration failed. " + errorMessage); } } + void CoreSDKTest::GetAdvertisingDeviceAttributes() { Firebolt::Error error = Firebolt::Error::None; @@ -201,7 +217,8 @@ void CoreSDKTest::GetAdvertisingDeviceAttributes() if (error == Firebolt::Error::None) { cout << "Get Advertising DeviceAttributes is success, deviceAttributes : " << deviceAttributes << endl; } else { - cout << "Get Advertising DeviceAttributes status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAdvertisingDeviceAttributes failed. " + errorMessage); } } @@ -213,11 +230,24 @@ void CoreSDKTest::GetDeviceName() if (error == Firebolt::Error::None) { cout << "Get Device Name = " << name.c_str() << endl; } else { - cout << "Get Device Name status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceName failed. " + errorMessage); } } -void CoreSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged( const std::string& name) +void CoreSDKTest::GetDeviceVersion() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string version = Firebolt::IFireboltAccessor::Instance().DeviceInterface().version(&error); + + if (error == Firebolt::Error::None) { + cout << "Get Device Version = " << version.c_str() << endl; + } else { + cout << "Get Device Version status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged(const std::string& name) { cout << "Name changed, new name --> " << name << endl; } @@ -229,7 +259,8 @@ void CoreSDKTest::SubscribeDeviceNameChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Device NameChange is success" << endl; } else { - cout << "Subscribe Device NameChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDeviceNameChanged failed. " + errorMessage); } } @@ -240,7 +271,8 @@ void CoreSDKTest::UnsubscribeDeviceNameChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Device NameChange is success" << endl; } else { - cout << "Unsubscribe Device NameChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDeviceNameChanged failed. " + errorMessage); } } @@ -252,7 +284,8 @@ void CoreSDKTest::GetDeviceModel() if (error == Firebolt::Error::None) { cout << "Get Device Model = " << model.c_str() << endl; } else { - cout << "Get Device Model status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceModel failed. " + errorMessage); } } @@ -264,17 +297,19 @@ void CoreSDKTest::GetDeviceSku() if (error == Firebolt::Error::None) { cout << "Get Device Sku = " << sku.c_str() << endl; } else { - cout << "Get Device Sku status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceSku failed. " + errorMessage); } } -void PrintDeviceAudioProfiles( const Firebolt::Device::AudioProfiles& audioProfiles ) +void PrintDeviceAudioProfiles(const Firebolt::Device::AudioProfiles& audioProfiles) { cout << "Get Device AudioProfiles :-> " << endl; for (auto& item : audioProfiles) { cout << "Profile: " << static_cast(item.first) << " status: " << item.second << endl; } } + void CoreSDKTest::GetDeviceAudio() { Firebolt::Error error = Firebolt::Error::None; @@ -282,14 +317,17 @@ void CoreSDKTest::GetDeviceAudio() if (error == Firebolt::Error::None) { PrintDeviceAudioProfiles(audioProfiles); } else { - cout << "Get Device AudioProfiles status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceAudio failed. " + errorMessage); } } -void CoreSDKTest::OnAudioChangedNotification::onAudioChanged( const Firebolt::Device::AudioProfiles& audioProfiles ) + +void CoreSDKTest::OnAudioChangedNotification::onAudioChanged(const Firebolt::Device::AudioProfiles& audioProfiles) { cout << "onAudioChanged event " << endl; PrintDeviceAudioProfiles(audioProfiles); } + void CoreSDKTest::SubscribeDeviceAudioChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -297,9 +335,11 @@ void CoreSDKTest::SubscribeDeviceAudioChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Device Audio Change is success" << endl; } else { - cout << "Subscribe Device Audio Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDeviceAudioChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeDeviceAudioChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -307,15 +347,17 @@ void CoreSDKTest::UnsubscribeDeviceAudioChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Device Audio Change is success" << endl; } else { - cout << "Unsubscribe Device Audio Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDeviceAudioChanged failed. " + errorMessage); } } -void PrintDeviceScreenResolution( const Firebolt::Device::Resolution& resolution ) +void PrintDeviceScreenResolution(const Firebolt::Device::Resolution& resolution) { cout << "Get Device ScreenResolution :-> " << endl; cout << resolution.first << " X " << resolution.second << endl; } + void CoreSDKTest::GetDeviceScreenResolution() { Firebolt::Error error = Firebolt::Error::None; @@ -323,14 +365,17 @@ void CoreSDKTest::GetDeviceScreenResolution() if (error == Firebolt::Error::None) { PrintDeviceScreenResolution(resolution); } else { - cout << "Get Device ScreenResolution status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceScreenResolution failed. " + errorMessage); } } -void CoreSDKTest::OnScreenResolutionChangedNotification::onScreenResolutionChanged( const Firebolt::Device::Resolution& resolution ) + +void CoreSDKTest::OnScreenResolutionChangedNotification::onScreenResolutionChanged(const Firebolt::Device::Resolution& resolution) { cout << "onScreenResolutionChanged event " << endl; PrintDeviceScreenResolution(resolution); } + void CoreSDKTest::SubscribeDeviceScreenResolutionChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -338,9 +383,11 @@ void CoreSDKTest::SubscribeDeviceScreenResolutionChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Device ScreenResolution Change is success" << endl; } else { - cout << "Subscribe Device ScreenResolution Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDeviceScreenResolutionChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeDeviceScreenResolutionChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -348,11 +395,12 @@ void CoreSDKTest::UnsubscribeDeviceScreenResolutionChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Device ScreenResolution Change is success" << endl; } else { - cout << "Unsubscribe Device ScreenResolution Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDeviceScreenResolutionChanged failed. " + errorMessage); } } -void PrintClosedCaptionsSettings( const Firebolt::Accessibility::ClosedCaptionsSettings& closedCaptionsSettings) +void PrintClosedCaptionsSettings(const Firebolt::Accessibility::ClosedCaptionsSettings& closedCaptionsSettings) { cout << "Get Accessibility ClosedCaptionsSettings :-> " << endl; cout << "ClosedCaptionsSettings::Enabled : " << closedCaptionsSettings.enabled << endl; @@ -400,6 +448,7 @@ void PrintClosedCaptionsSettings( const Firebolt::Accessibility::ClosedCaptionsS cout << endl; } } + void CoreSDKTest::GetAccessibilityClosedCaptionsSettings() { Firebolt::Error error = Firebolt::Error::None; @@ -407,14 +456,17 @@ void CoreSDKTest::GetAccessibilityClosedCaptionsSettings() if (error == Firebolt::Error::None) { PrintClosedCaptionsSettings(closedCaptionsSettings); } else { - cout << "Get Accessibility ClosedCaptionsSettings status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAccessibilityClosedCaptionsSettings failed. " + errorMessage); } } -void CoreSDKTest::OnClosedCaptionsSettingsChangedNotification::onClosedCaptionsSettingsChanged( const Firebolt::Accessibility::ClosedCaptionsSettings& closedCaptionsSettings ) + +void CoreSDKTest::OnClosedCaptionsSettingsChangedNotification::onClosedCaptionsSettingsChanged(const Firebolt::Accessibility::ClosedCaptionsSettings& closedCaptionsSettings) { cout << "ClosedCaptionsSettingsChanged event " << endl; PrintClosedCaptionsSettings(closedCaptionsSettings); } + void CoreSDKTest::SubscribeAccessibilityClosedCaptionsSettingsChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -422,9 +474,11 @@ void CoreSDKTest::SubscribeAccessibilityClosedCaptionsSettingsChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Accessibilty ClosedCaptionSettings Change is success" << endl; } else { - cout << "Subscribe Accessibilty ClosedCaptionSettings Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeAccessibilityClosedCaptionsSettingsChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeAccessibilityClosedCaptionsSettingsChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -432,7 +486,8 @@ void CoreSDKTest::UnsubscribeAccessibilityClosedCaptionsSettingsChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Accessibilty ClosedCaptionSettings Change is success" << endl; } else { - cout << "Unsubscribe Accessibilty ClosedCaptionSettings Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeAccessibilityClosedCaptionsSettingsChanged failed. " + errorMessage); } } @@ -447,9 +502,11 @@ void CoreSDKTest::GetLocalizationAdditionalInfo() cout << "key : " << element.first << ", value : " << element.second << endl; } } else { - cout << "Get Localization AdditionalInfo status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetLocalizationAdditionalInfo failed. " + errorMessage); } } + void CoreSDKTest::GetLocalizationLatlon() { Firebolt::Error error = Firebolt::Error::None; @@ -459,9 +516,11 @@ void CoreSDKTest::GetLocalizationLatlon() cout << "Get Localization LatLon pair value : " << endl; cout << "key : " << latlon.first << ", value : " << latlon.second << endl; } else { - cout << "Get Localization LatLon status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetLocalizationLatlon failed. " + errorMessage); } } + void CoreSDKTest::GetLocalizationPreferredAudioLanguages() { Firebolt::Error error = Firebolt::Error::None; @@ -470,19 +529,22 @@ void CoreSDKTest::GetLocalizationPreferredAudioLanguages() if (error == Firebolt::Error::None) { cout << "Get Localization PreferredAudioLanguages : " << endl; for (auto language: languages) { - cout << "----- > " < " << language << endl; } } else { - cout << "Get Localization PreferredAudioLanguages status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetLocalizationPreferredAudioLanguages failed. " + errorMessage); } } -void CoreSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged( const std::vector& languages) + +void CoreSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged(const std::vector& languages) { cout << "PreferredAudioLanguages Changed, new languages --> " << endl; for (auto language : languages) { cout << " -> " << language << endl; } } + void CoreSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -490,9 +552,11 @@ void CoreSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Localization PreferredAudioLanguagesChange is success" << endl; } else { - cout << "Subscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeLocalizationPreferredAudioLanguagesChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -500,7 +564,8 @@ void CoreSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Localization PreferredAudioLanguagesChange is success" << endl; } else { - cout << "Unsubscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeLocalizationPreferredAudioLanguagesChanged failed. " + errorMessage); } } @@ -512,23 +577,28 @@ void CoreSDKTest::KeyboardStandardAsyncResponse::response(const std::string& res cout << "Keyboard standard response: " << response << endl; } } + void CoreSDKTest::InvokeKeyboardStandard() { Firebolt::Error error = Firebolt::Error::None; std::string message = "Enter the name you'd like to associate with this device"; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().requestStandard(message, _keyboardStandardAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard standard request method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("InvokeKeyboardStandard failed. " + errorMessage); } } + void CoreSDKTest::AbortKeyboardStandard() { Firebolt::Error error = Firebolt::Error::None; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().abortStandard(_keyboardStandardAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard standard abort method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("AbortKeyboardStandard failed. " + errorMessage); } } + void CoreSDKTest::KeyboardPasswordAsyncResponse::response(const std::string& response, Firebolt::Error* error) { if (error && (*error != Firebolt::Error::None)) { @@ -537,23 +607,28 @@ void CoreSDKTest::KeyboardPasswordAsyncResponse::response(const std::string& res cout << "Keyboard password response: " << response << endl; } } + void CoreSDKTest::InvokeKeyboardPassword() { Firebolt::Error error = Firebolt::Error::None; std::string message = "Enter the password to associate with this device"; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().requestPassword(message, _keyboardPasswordAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard password request method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("InvokeKeyboardPassword failed. " + errorMessage); } } + void CoreSDKTest::AbortKeyboardPassword() { Firebolt::Error error = Firebolt::Error::None; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().abortPassword(_keyboardPasswordAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard password abort method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("AbortKeyboardPassword failed. " + errorMessage); } } + void CoreSDKTest::KeyboardEmailAsyncResponse::response(const std::string& response, Firebolt::Error* error) { if (error && (*error != Firebolt::Error::None)) { @@ -562,6 +637,7 @@ void CoreSDKTest::KeyboardEmailAsyncResponse::response(const std::string& respon cout << "Keyboard email response: " << response << endl; } } + void CoreSDKTest::InvokeKeyboardEmail() { Firebolt::Error error = Firebolt::Error::None; @@ -569,15 +645,18 @@ void CoreSDKTest::InvokeKeyboardEmail() std::string message = "Enter your email to sign into this app/device"; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().requestEmail(type, message, _keyboardEmailAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard email requeset method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("InvokeKeyboardEmail failed. " + errorMessage); } } + void CoreSDKTest::AbortKeyboardEmail() { Firebolt::Error error = Firebolt::Error::None; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().abortEmail(_keyboardEmailAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard email abort method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("AbortKeyboardEmail failed. " + errorMessage); } } @@ -588,9 +667,11 @@ void CoreSDKTest::VerifyProfileApproveContentRating() if (error == Firebolt::Error::None) { cout << "Verify Profile ApproveContentRating is success value : " << allow << endl; } else { - cout << "Verify Profile ApproveContentRating status : " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("VerifyProfileApproveContentRating failed. " + errorMessage); } } + void CoreSDKTest::VerifyProfileApprovePurchase() { Firebolt::Error error = Firebolt::Error::None; @@ -598,36 +679,41 @@ void CoreSDKTest::VerifyProfileApprovePurchase() if (error == Firebolt::Error::None) { cout << "Verify Profile ApprovePurchase is success value : " << allow << endl; } else { - cout << "Verify Profile ApprovePurchase status : " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("VerifyProfileApprovePurchase failed. " + errorMessage); } } + void CoreSDKTest::GetProfileFlags() { - Firebolt::Error error = Firebolt::Error::None; - Firebolt::Types::FlatMap flatMap = Firebolt::IFireboltAccessor::Instance().ProfileInterface().flags(&error); - if (error == Firebolt::Error::None) { + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Types::FlatMap flatMap = Firebolt::IFireboltAccessor::Instance().ProfileInterface().flags(&error); + if (error == Firebolt::Error::None) { cout << "Get Profile flags is success value : " << endl; for (const auto& item : flatMap) { - cout << "\t" << item.first << " : " << item.second << endl; + cout << "\t" << item.first << " : " << item.second << endl; } } else { - cout << "Get Profile flags status : " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetProfileFlags failed. " + errorMessage); } } void CoreSDKTest::LifecycleClose() { - Firebolt::Error error = Firebolt::Error::None; - cout << "Enter close reason remote button(0), user exit(1), done(2) or error(3)" << endl; - int32_t reason; - cin >> reason; - Firebolt::IFireboltAccessor::Instance().LifecycleInterface().close(static_cast(reason), &error); + Firebolt::Error error = Firebolt::Error::None; + cout << "Enter close reason remote button(0), user exit(1), done(2) or error(3)" << endl; + int32_t reason; + cin >> reason; + Firebolt::IFireboltAccessor::Instance().LifecycleInterface().close(static_cast(reason), &error); if (error == Firebolt::Error::None) { cout << "Lifecycle close is success" << endl; } else { - cout << "Lifecycle close status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("LifecycleClose failed. " + errorMessage); } } + EnumMap lifecycleStateMap = { { Firebolt::Lifecycle::LifecycleState::INITIALIZING, "initializing" }, { Firebolt::Lifecycle::LifecycleState::INACTIVE, "inactive" }, @@ -636,19 +722,56 @@ EnumMap lifecycleStateMap = { { Firebolt::Lifecycle::LifecycleState::UNLOADING, "unloading" }, { Firebolt::Lifecycle::LifecycleState::SUSPENDED, "suspended" } }; + EnumMap lifecycleEventSourceMap = { { Firebolt::Lifecycle::LifecycleEventSource::VOICE, "voice" }, { Firebolt::Lifecycle::LifecycleEventSource::REMOTE, "remote" } }; + +void CoreSDKTest::LifecycleReady() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().LifecycleInterface().ready(&error); + if (error == Firebolt::Error::None) { + cout << "Lifecycle ready is success" << endl; + } else { + cout << "Lifecycle ready status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::LifecycleFinished() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().LifecycleInterface().finished(&error); + if (error == Firebolt::Error::None) { + cout << "Lifecycle finished is success" << endl; + } else { + cout << "Lifecycle finished status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::LifecycleState() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string state = Firebolt::IFireboltAccessor::Instance().LifecycleInterface().state(&error); + + if (error == Firebolt::Error::None) { + cout << "State of the App = " << state.c_str() << endl; + } else { + cout << "State of the App throws an error = " << static_cast(error) << endl; + } +} + void CoreSDKTest::OnBackgroundNotification::onBackground( const Firebolt::Lifecycle::LifecycleEvent& lifecycleEvent) { cout <<"onBackground event is triggered" << endl; cout <<"\tstate: " << ConvertFromEnum(lifecycleStateMap, lifecycleEvent.state) << endl; cout <<"\tprevious: " << ConvertFromEnum(lifecycleStateMap, lifecycleEvent.previous) << endl; if (lifecycleEvent.source.has_value()) { - cout <<"\tsource: " << ConvertFromEnum(lifecycleEventSourceMap, lifecycleEvent.source.value()) << endl; + cout <<"\tsource: " << ConvertFromEnum(lifecycleEventSourceMap, lifecycleEvent.source.value()) << endl; } } + void CoreSDKTest::SubscribeLifecycleBackgroundNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -656,9 +779,11 @@ void CoreSDKTest::SubscribeLifecycleBackgroundNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Lifecycle BackgroundNotification is success" << endl; } else { - cout << "Subscribe Lifecycle BackgroundNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeLifecycleBackgroundNotification failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeLifecycleBackgroundNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -666,18 +791,21 @@ void CoreSDKTest::UnsubscribeLifecycleBackgroundNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Lifecycle BackgroundNotification is success" << endl; } else { - cout << "Unsubscribe Lifecycle BackgroundNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeLifecycleBackgroundNotification failed. " + errorMessage); } } -void CoreSDKTest::OnForegroundNotification::onForeground( const Firebolt::Lifecycle::LifecycleEvent& lifecycleEvent) + +void CoreSDKTest::OnForegroundNotification::onForeground(const Firebolt::Lifecycle::LifecycleEvent& lifecycleEvent) { cout <<"onForeground event is triggered" << endl; cout <<"\tstate: " << ConvertFromEnum(lifecycleStateMap, lifecycleEvent.state) << endl; cout <<"\tprevious: " << ConvertFromEnum(lifecycleStateMap, lifecycleEvent.previous) << endl; if (lifecycleEvent.source.has_value()) { - cout <<"\tsource: " << ConvertFromEnum(lifecycleEventSourceMap, lifecycleEvent.source.value()) << endl; + cout <<"\tsource: " << ConvertFromEnum(lifecycleEventSourceMap, lifecycleEvent.source.value()) << endl; } } + void CoreSDKTest::SubscribeLifecycleForegroundNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -685,9 +813,11 @@ void CoreSDKTest::SubscribeLifecycleForegroundNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Lifecycle ForegroundNotification is success" << endl; } else { - cout << "Subscribe Lifecycle ForegroundNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeLifecycleForegroundNotification failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeLifecycleForegroundNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -695,7 +825,8 @@ void CoreSDKTest::UnsubscribeLifecycleForegroundNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Lifecycle ForegroundNotification is success" << endl; } else { - cout << "Unsubscribe Lifecycle ForegroundNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeLifecycleForegroundNotification failed. " + errorMessage); } } @@ -707,9 +838,11 @@ void CoreSDKTest::GetAuthenticationDevice() if (error == Firebolt::Error::None) { cout << "Get Authentication of Device = " << device.c_str() << endl; } else { - cout << "Get Authentication of Device status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAuthenticationDevice failed. " + errorMessage); } } + void CoreSDKTest::GetAuthenticationSession() { Firebolt::Error error = Firebolt::Error::None; @@ -718,9 +851,11 @@ void CoreSDKTest::GetAuthenticationSession() if (error == Firebolt::Error::None) { cout << "Get Authentication of Session = " << session.c_str() << endl; } else { - cout << "Get Authentication of Session status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAuthenticationSession failed. " + errorMessage); } } + void CoreSDKTest::GetAuthenticationRoot() { Firebolt::Error error = Firebolt::Error::None; @@ -729,9 +864,11 @@ void CoreSDKTest::GetAuthenticationRoot() if (error == Firebolt::Error::None) { cout << "Get Authentication of Root = " << root.c_str() << endl; } else { - cout << "Get Authentication of Root status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAuthenticationRoot failed. " + errorMessage); } } + void CoreSDKTest::GetAuthenticationToken() { Firebolt::Error error = Firebolt::Error::None; @@ -750,14 +887,15 @@ void CoreSDKTest::GetAuthenticationToken() cout << "\ttype : " << token.type.value().c_str() << endl; } } else { - cout << "Get Authentication of Device status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAuthenticationToken failed. " + errorMessage); } } EnumMap denyReasonMap = { { Firebolt::Capabilities::DenyReason::UNPERMITTED, "unpermitted" }, { Firebolt::Capabilities::DenyReason::UNSUPPORTED, "unsupported" }, - { Firebolt::Capabilities::DenyReason::DISABLED, "disbaled" }, + { Firebolt::Capabilities::DenyReason::DISABLED, "disabled" }, { Firebolt::Capabilities::DenyReason::UNAVAILABLE, "unavailable" }, { Firebolt::Capabilities::DenyReason::GRANT_DENIED, "grant_denied" }, { Firebolt::Capabilities::DenyReason::UNGRANTED, "ungranted" } @@ -797,10 +935,11 @@ static void PrintCapabilityInfo(const Firebolt::Capabilities::CapabilityInfo& in if (info.details.has_value()) { cout << "\tdetails: " << endl; for (auto item : info.details.value()) { - cout << "\t\t" << ConvertFromEnum(denyReasonMap, item) << endl; + cout << "\t\t" << ConvertFromEnum(denyReasonMap, item) << endl; } } } + void CoreSDKTest::GetCapabilitiesAvailable() { Firebolt::Error error = Firebolt::Error::None; @@ -809,9 +948,11 @@ void CoreSDKTest::GetCapabilitiesAvailable() if (error == Firebolt::Error::None) { cout << "Capabilities Available = " << (status ? "true" : "false") << endl; } else { - cout << "Capabilities Available status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetCapabilitiesAvailable failed. " + errorMessage); } } + void CoreSDKTest::SubscribeCapabilitiesAvailableChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -820,9 +961,11 @@ void CoreSDKTest::SubscribeCapabilitiesAvailableChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Capabilities AvailableNotification is success" << endl; } else { - cout << "Subscribe Capabilities AvailableNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeCapabilitiesAvailableChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeCapabilitiesAvailableChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -830,15 +973,18 @@ void CoreSDKTest::UnsubscribeCapabilitiesAvailableChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Capabilities AvailableNotification is success" << endl; } else { - cout << "Unsubscribe Capabilities AvailableNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeCapabilitiesAvailableChanged failed. " + errorMessage); } } -void CoreSDKTest::OnAvailableNotification::onAvailable( const Firebolt::Capabilities::CapabilityInfo& info) + +void CoreSDKTest::OnAvailableNotification::onAvailable(const Firebolt::Capabilities::CapabilityInfo& info) { cout << "OnAvailableNotification is invoked " << endl; cout << "capabilityInfo: " << endl; PrintCapabilityInfo(info); } + void CoreSDKTest::GetCapabilitiesGranted() { Firebolt::Error error = Firebolt::Error::None; @@ -848,9 +994,11 @@ void CoreSDKTest::GetCapabilitiesGranted() if (error == Firebolt::Error::None) { cout << "Capabilities Granted = " << (status ? "true" : "false") << endl; } else { - cout << "Capabilities Granted status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetCapabilitiesGranted failed. " + errorMessage); } } + void CoreSDKTest::GetCapabilitiesPermitted() { Firebolt::Error error = Firebolt::Error::None; @@ -862,9 +1010,11 @@ void CoreSDKTest::GetCapabilitiesPermitted() if (error == Firebolt::Error::None) { cout << "Capabilities Permitted = " << (status ? "true" : "false") << endl; } else { - cout << "Capabilities Permitted status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetCapabilitiesPermitted failed. " + errorMessage); } } + void CoreSDKTest::GetCapabilitiesSupported() { Firebolt::Error error = Firebolt::Error::None; @@ -873,9 +1023,11 @@ void CoreSDKTest::GetCapabilitiesSupported() if (error == Firebolt::Error::None) { cout << "Capabilities Supported = " << (status ? "true" : "false") << endl; } else { - cout << "Capabilities Supported status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetCapabilitiesSupported failed. " + errorMessage); } } + void CoreSDKTest::GetCapabilitiesInfo() { Firebolt::Error error = Firebolt::Error::None; @@ -885,10 +1037,11 @@ void CoreSDKTest::GetCapabilitiesInfo() cout << "Capabilities Info : " << endl; for (auto element : info) { PrintCapabilityInfo(element); - cout << endl; + cout << endl; } } else { - cout << "Capabilities Info status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetCapabilitiesInfo failed. " + errorMessage); } } @@ -901,9 +1054,11 @@ void CoreSDKTest::MetricsStartContent() if (error == Firebolt::Error::None) { cout << "Metrics Start Content = " << (status ? "true" : "false") << endl; } else { - cout << "Metrics Start Content status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("MetricsStartContent failed. " + errorMessage); } } + void CoreSDKTest::MetricsStopContent() { Firebolt::Error error = Firebolt::Error::None; @@ -913,7 +1068,47 @@ void CoreSDKTest::MetricsStopContent() if (error == Firebolt::Error::None) { cout << "Metrics Stop Content = " << (status ? "true" : "false") << endl; } else { - cout << "Metrics Stop Content status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("MetricsStopContent failed. " + errorMessage); + } +} + +void CoreSDKTest::MetricsReady() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional entityId; + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().ready(&error); + + if (error == Firebolt::Error::None) { + cout << "Metrics Ready status = " << (status ? "true" : "false") << endl; + } else { + cout << "Metrics Ready status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::MetricsSignIn() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional entityId; + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signIn(&error); + + if (error == Firebolt::Error::None) { + cout << "Metrics signIn status = " << (status ? "true" : "false") << endl; + } else { + cout << "Metrics signIn status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::MetricsSignOut() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional entityId; + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signOut(&error); + + if (error == Firebolt::Error::None) { + cout << "Metrics signOut status = " << (status ? "true" : "false") << endl; + } else { + cout << "Metrics signOut status = " << static_cast(error) << endl; } } @@ -926,9 +1121,11 @@ void CoreSDKTest::GetSecondScreenDevice() if (error == Firebolt::Error::None) { cout << "Get SecondScreen Device : " << deviceId.c_str() << endl; } else { - cout << "Get SecondScreen Device status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetSecondScreenDevice failed. " + errorMessage); } } + void CoreSDKTest::GetSecondScreenProtocols() { Firebolt::Error error = Firebolt::Error::None; @@ -939,9 +1136,11 @@ void CoreSDKTest::GetSecondScreenProtocols() cout << element.first << " : " << (element.second ? "true" : "false") << endl; } } else { - cout << "Get SecondScreen Protocols status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetSecondScreenProtocols failed. " + errorMessage); } } + void CoreSDKTest::GetSecondScreenFriendlyName() { Firebolt::Error error = Firebolt::Error::None; @@ -950,13 +1149,16 @@ void CoreSDKTest::GetSecondScreenFriendlyName() if (error == Firebolt::Error::None) { cout << "Get SecondScreen FriendlyName : " << friendlyName.c_str() << endl; } else { - cout << "Get SecondScreen FriendlyName status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetSecondScreenFriendlyName failed. " + errorMessage); } } -void CoreSDKTest::OnFriendlyNameChangedNotification::onFriendlyNameChanged( const std::string& friendlyName) + +void CoreSDKTest::OnFriendlyNameChangedNotification::onFriendlyNameChanged(const std::string& friendlyName) { cout << "OnFriendlyNameChangedNotification friendlyName : " << friendlyName.c_str() << endl; } + void CoreSDKTest::SubscribeSecondScreenFriendlyNameChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -964,9 +1166,11 @@ void CoreSDKTest::SubscribeSecondScreenFriendlyNameChanged() if (error == Firebolt::Error::None) { cout << "Subscribe SecondScreen FriendlyNameChangedNotification is success" << endl; } else { - cout << "Subscribe SecondScreen FriendlyNameChangedNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeSecondScreenFriendlyNameChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeSecondScreenFriendlyNameChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -974,13 +1178,15 @@ void CoreSDKTest::UnsubscribeSecondScreenFriendlyNameChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe SecondScreen FriendlyNameChangedNotification is success" << endl; } else { - cout << "Unsubscribe SecondScreen FriendlyNameChangedNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeSecondScreenFriendlyNameChanged failed. " + errorMessage); } } EnumMap secondScreenEventTypeMap = { { Firebolt::SecondScreen::SecondScreenEventType::DIAL, "dial" } }; + void CoreSDKTest::ParametersInitialization() { Firebolt::Error error = Firebolt::Error::None; @@ -1001,17 +1207,18 @@ void CoreSDKTest::ParametersInitialization() if (appInitialization.secondScreen.has_value()) { if (appInitialization.secondScreen.value().launchRequest.has_value()) { Firebolt::SecondScreen::SecondScreenEvent event = appInitialization.secondScreen.value().launchRequest.value(); - cout <<"\tsecondScreen:launchRequest:type : " << ConvertFromEnum(secondScreenEventTypeMap, event.type) << endl; + cout << "\tsecondScreen:launchRequest:type : " << ConvertFromEnum(secondScreenEventTypeMap, event.type) << endl; if (event.version.has_value()) { - cout <<"\tsecondScreen:launchRequest:version : " << event.version.value().c_str() << endl; + cout << "\tsecondScreen:launchRequest:version : " << event.version.value().c_str() << endl; } if (event.data.has_value()) { - cout <<"\tsecondScreen:launchRequest:data : " << event.data.value().c_str() << endl; + cout << "\tsecondScreen:launchRequest:data : " << event.data.value().c_str() << endl; } } } } else { - cout << "Parameters Initialization status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("ParametersInitialization failed. " + errorMessage); } } @@ -1028,9 +1235,11 @@ void CoreSDKTest::DiscoverySignIn() if (error == Firebolt::Error::None) { cout << "Discovery SignIn is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery SignIn status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoverySignIn failed. " + errorMessage); } } + void CoreSDKTest::DiscoverySignOut() { Firebolt::Error error = Firebolt::Error::None; @@ -1038,7 +1247,8 @@ void CoreSDKTest::DiscoverySignOut() if (error == Firebolt::Error::None) { cout << "Discovery SignOut is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery SignOut status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoverySignOut failed. " + errorMessage); } } @@ -1046,7 +1256,7 @@ void CoreSDKTest::DiscoveryContentAccess() { Firebolt::Error error = Firebolt::Error::None; Firebolt::Discovery::ContentAccessIdentifiers contentAccessIdentifiers; - contentAccessIdentifiers.availabilities = std::make_optional>(); + contentAccessIdentifiers.availabilities = std::make_optional>(); Firebolt::Discovery::Availability availability; availability.type = Firebolt::Discovery::AvailabilityType::CHANNEL_LINEUP; availability.id = "partner.com/availability/123"; @@ -1064,9 +1274,11 @@ void CoreSDKTest::DiscoveryContentAccess() if (error == Firebolt::Error::None) { cout << "Discovery ContentAccess is success" << endl; } else { - cout << "Discovery ContentAccess status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryContentAccess failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryClearContentAccess() { Firebolt::Error error = Firebolt::Error::None; @@ -1074,9 +1286,11 @@ void CoreSDKTest::DiscoveryClearContentAccess() if (error == Firebolt::Error::None) { cout << "Discovery ClearContentAccess is success" << endl; } else { - cout << "Discovery ClearContentAccess status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryClearContentAccess failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryEntitlements() { Firebolt::Error error = Firebolt::Error::None; @@ -1090,9 +1304,11 @@ void CoreSDKTest::DiscoveryEntitlements() if (error == Firebolt::Error::None) { cout << "Discovery Entitlements is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Entitlements status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryEntitlements failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryWatchNext() { Firebolt::Error error = Firebolt::Error::None; @@ -1107,9 +1323,37 @@ void CoreSDKTest::DiscoveryWatchNext() if (error == Firebolt::Error::None) { cout << "Discovery Watched Next is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Watched Next status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryWatchNext failed. " + errorMessage); } } + +void CoreSDKTest::DiscoveryUserInterest() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Discovery::InterestType type = Firebolt::Discovery::InterestType::INTEREST; + Firebolt::Discovery::InterestReason reason = Firebolt::Discovery::InterestReason::PLAYLIST; + + // Set up the entity details + Firebolt::Entity::EntityDetails entity; + + // Identifiers + entity.identifiers = "{\"entityId\": \"123\"}"; + + // Optional Info Metadata + entity.info = Firebolt::Entity::Metadata(); + entity.info->title = "A Cool Show"; + entity.info->synopsis = "A cool show synopsis"; + + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().userInterest(type, reason, entity, &error); + + if (error == Firebolt::Error::None) { + cout << "Discovery User Interest is success" << endl; + } else { + cout << "Discovery User Interest status = " << static_cast(error) << endl; + } +} + void CoreSDKTest::DiscoveryPolicy() { Firebolt::Error error = Firebolt::Error::None; @@ -1120,9 +1364,11 @@ void CoreSDKTest::DiscoveryPolicy() cout << "\tshareWatchHistory: " << policy.shareWatchHistory << endl; cout << "\trememberWatchedPrograms: " << policy.rememberWatchedPrograms << endl; } else { - cout << "Discovery Policy status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryPolicy failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryEntityInfo() { Firebolt::Error error = Firebolt::Error::None; @@ -1199,9 +1445,11 @@ void CoreSDKTest::DiscoveryEntityInfo() if (error == Firebolt::Error::None) { cout << "Discovery EntityInfo is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery EntityInfo status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryEntityInfo failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryPurchasedContent() { Firebolt::Error error = Firebolt::Error::None; @@ -1255,21 +1503,20 @@ void CoreSDKTest::DiscoveryPurchasedContent() if (error == Firebolt::Error::None) { cout << "Discovery PurchasedContent is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery PurchasedContent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryPurchasedContent failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryLaunch() { Firebolt::Error error = Firebolt::Error::None; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "123"; { std::optional intent = std::make_optional(); intent.value().action = "tune"; intent.value().data.entity.entityType = "channel"; - intent.value().data.entity.channelType = Firebolt::Intents::ChannelEntityChannelType::STREAMING; + intent.value().data.entity.channelType = Firebolt::Entity::ChannelEntityChannelType::STREAMING; intent.value().data.entity.entityId = "an-ott-channel"; std::string entityId; std::optional appContentData; @@ -1278,14 +1525,16 @@ void CoreSDKTest::DiscoveryLaunch() intent.value().context.source = "voice"; cout << "Calling Discovery Launch TuneIntent method " << endl; bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().launch(appId, intent, &error); + if (error == Firebolt::Error::None) { cout << "Discovery Launch TuneIntent is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Launch TuneIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryLaunch failed. " + errorMessage); } } - { + { std::optional intent = std::make_optional(); intent.value().action = "entity"; intent.value().context.source = "voice"; @@ -1296,7 +1545,8 @@ void CoreSDKTest::DiscoveryLaunch() if (error == Firebolt::Error::None) { cout << "Discovery Launch EntityIntent is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Launch EntityIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryLaunch failed. " + errorMessage); } } @@ -1309,10 +1559,10 @@ void CoreSDKTest::DiscoveryLaunch() if (error == Firebolt::Error::None) { cout << "Discovery Launch HomeIntent is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Launch HomeIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryLaunch failed. " + errorMessage); } } - cin.putback('\n'); } #ifdef POLYMORPHICS_REDUCER_METHODS void CoreSDKTest::DiscoveryWatched() @@ -1327,9 +1577,11 @@ void CoreSDKTest::DiscoveryWatched() if (error == Firebolt::Error::None) { cout << "Discovery Watched is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Watched status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryWatched failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryWatchedReduced() { Firebolt::Error error = Firebolt::Error::None; @@ -1345,10 +1597,12 @@ void CoreSDKTest::DiscoveryWatchedReduced() if (error == Firebolt::Error::None) { cout << "Discovery Watched Reduced is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Watched Reduced status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryWatchedReduced failed. " + errorMessage); } } #endif + void CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -1356,7 +1610,8 @@ void CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Discovery OnNavigateToLaunch HomeIntent is success" << endl; } else { - cout << "Subscribe Discovery OnNavigateToLaunch HomeIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } error = Firebolt::Error::None; @@ -1364,7 +1619,8 @@ void CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Discovery OnNavigateToLaunch EntityIntent is success" << endl; } else { - cout << "Subscribe Discovery OnNavigateToLaunch EntityIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } error = Firebolt::Error::None; @@ -1372,9 +1628,11 @@ void CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Discovery OnNavigateToLaunch TuneIntent is success" << endl; } else { - cout << "Subscribe Discovery OnNavigateToLaunch TuneIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -1382,7 +1640,8 @@ void CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Discovery OnNavigateToLaunch HomeIntent is success" << endl; } else { - cout << "Unsubscribe Discovery OnNavigateToLaunch HomeIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } error = Firebolt::Error::None; @@ -1390,7 +1649,8 @@ void CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Discovery OnNavigateToLaunch EntityIntent is success" << endl; } else { - cout << "Unsubscribe Discovery OnNavigateToLaunch EntityIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } error = Firebolt::Error::None; @@ -1398,18 +1658,22 @@ void CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Discovery OnNavigateToLaunch TuneIntent is success" << endl; } else { - cout << "Unsubscribe Discovery OnNavigateToLaunch TuneIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } } -void CoreSDKTest::OnNavigateToHomeIntentNotification::onNavigateTo( const Firebolt::Intents::HomeIntent& intent) + +void CoreSDKTest::OnNavigateToHomeIntentNotification::onNavigateTo(const Firebolt::Intents::HomeIntent& intent) { cout << "onNavigateTo for action : " << intent.action << endl; } -void CoreSDKTest::OnNavigateToEntityIntentNotification::onNavigateTo( const Firebolt::Intents::EntityIntent& intent) + +void CoreSDKTest::OnNavigateToEntityIntentNotification::onNavigateTo(const Firebolt::Intents::EntityIntent& intent) { cout << "onNavigateTo for action : " << intent.action << endl; } -void CoreSDKTest::OnNavigateToTuneIntentNotification::onNavigateTo( const Firebolt::Intents::TuneIntent& intent) + +void CoreSDKTest::OnNavigateToTuneIntentNotification::onNavigateTo(const Firebolt::Intents::TuneIntent& intent) { cout << "onNavigateTo for action : " << intent.action << endl; -} +} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h index 9b8d056ea..d25521043 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h @@ -92,6 +92,7 @@ class CoreSDKTest { static void GetAccountUid(); static void GetDeviceName(); + static void GetDeviceVersion(); static void SubscribeDeviceNameChanged(); static void UnsubscribeDeviceNameChanged(); static void GetDeviceModel(); @@ -131,6 +132,9 @@ class CoreSDKTest { static void GetProfileFlags(); static void LifecycleClose(); + static void LifecycleFinished(); + static void LifecycleReady(); + static void LifecycleState(); static void SubscribeLifecycleBackgroundNotification(); static void UnsubscribeLifecycleBackgroundNotification(); static void SubscribeLifecycleForegroundNotification(); @@ -151,6 +155,9 @@ class CoreSDKTest { static void MetricsStartContent(); static void MetricsStopContent(); + static void MetricsReady(); + static void MetricsSignIn(); + static void MetricsSignOut(); static void GetSecondScreenDevice(); static void GetSecondScreenProtocols(); @@ -174,6 +181,7 @@ class CoreSDKTest { static void SubscribeDiscoveryOnNavigateToLaunchNotification(); static void UnsubscribeDiscoveryOnNavigateToLaunchNotification(); static void DiscoveryWatchNext(); + static void DiscoveryUserInterest(); static void ParametersInitialization(); @@ -199,4 +207,3 @@ class CoreSDKTest { static KeyboardPasswordAsyncResponse _keyboardPasswordAsyncResponse; static KeyboardStandardAsyncResponse _keyboardStandardAsyncResponse; }; - diff --git a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp index 2e8bbba9b..5b235dadb 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp @@ -1,654 +1,196 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + #include +#include +#include +#include +#include #include "CoreSDKTest.h" -void ShowMenu() -{ - printf("Enter\n" - "\tI : Get Account Id\n" - "\tU : Get Account Uid\n" - "\tM : Get Device Model\n" - "\tS : Get Device Sku\n" - "\tA : Handle Advertising methods\n" - "\tN : Get/Subscribe/Unsubscribe Device Name\n" - "\tP : Get/Subscribe/Unsubscribe Device Audio Profiles\n" - "\tR : Get/Subscribe/Unsubscribe Device Screen Resolution\n" - "\tL : Handle Localization methods\n" - "\tC : Get/Subscribe/Unsubscribe Closed Caption Settings\n" - "\tK : Invoke keyboard methods email/password/standard\n" - "\tV : Handle Profile methods\n" - "\tT : Handle Authentication methods\n" - "\tB : Handle Capabilities Method\n" - "\tE : Handle Metrics methods\n" - "\tF : Handle Lifecycle methods\n" - "\tD : Handle SecondScreen methods\n" - "\tY : Handle Discovery methods\n" - "\tZ : Parameters Initialization\n" - "\tQ : Quit\n\n" - ); -} - -void ShowPropertyMenu(std::string& module, std::string& property) -{ - printf("%s:%s property options \n" - "\tG : Get value\n" - "\tR : Show subscribe/unscribe event menu\n" - "\tQ : Quit\n", module.c_str(), property.c_str()); -} - -void ShowProfileMenu() -{ - printf("Options: \n" - "\tC : Verify ApproveContentRating\n" - "\tP : Verify ApprovePurchase\n" - "\tF : Get Flags\n" - "\tQ : Quit\n"); -} - -void ShowLocalizationMenu() -{ - printf("Options: \n" - "\tA: Get additionalInfo\n" - "\tL: Get LatLon\n" - "\tP: Get/Subscribe/Unsubscribe Preferred AudioLanguages\n" - "\tQ : Quit\n"); -} - -void ShowAuthenticationMenu() -{ - printf("Options: \n" - "\t Invoke lifecyclesession management sequence from postman before invoking methods\n" - "\tD : Get Authentication Device\n" - "\tS : Get Authentication Session\n" - "\tR : Get Authentication Root\n" - "\tT : Get Authentication Token\n" - "\tQ : Quit\n"); -} - -void ShowCapabilitiesMenu() -{ - printf("Options: \n" - "\tA : Get Capabilities Available\n" - "\tG : Get Capabilities Granted\n" - "\tP : Get Capabilities Permitted\n" - "\tS : Get Capabilities Supported\n" - "\tI : Get Capabilities Info\n" - "\tQ : Quit\n"); -} - -void ShowAdvertisingMenu() -{ - printf("Options: \n" - "\tP : Get/Subscribe/Unsubscribe Advertising Policy\n" - "\tC : Build configuration object for Ad Framework initialization\n" - "\tD : Get the device advertising device attributes\n" - "\tQ : Quit\n"); -} - -void ShowLifecycleMenu() -{ - printf("Options: \n" - "\tC : Close lifecycle of the app\n" - "\tB : Subscribe/Unsubscribe Background notification\n" - "\tF : Subscribe/Unsubscribe Foreground notification\n" - "\tQ : Quit\n"); -} - -void ShowMetricsMenu() -{ - printf("Options: \n" - "\tS : Start Content\n" - "\tT : Stop Content\n" - "\tQ : Quit\n"); -} - -void ShowSecondScreenMenu() -{ - printf("Options: \n" - "\tD : Get Device Id\n" - "\tF : Get/Subscribe/Unsubscribe FriendlyName\n" - "\tP : Get Protocols\n" - "\tQ : Quit\n"); -} - -void ShowDiscoveryMenu() -{ - printf("Options: \n" - "\tS : SignIn\n" - "\tO : SignOut\n" - "\tA : ContentAccess\n" - "\tC : ClearContentAccess\n" - "\tE : Entitlements\n" - "\tI : EntityInfo\n" - "\tP : Policy\n" - "\tU : PurchasedContent\n" - "\tN : WatchNext\n" - "\tL : Launch\n" +using namespace std; + +const char* options = ":hu:"; + +void RunAllTests() { + bool allTestsPassed = true; + vector errorMessages; + + auto runTest = [&allTestsPassed, &errorMessages](auto testFunction, const string& testName) { + try { + testFunction(); + } catch (const exception& e) { + errorMessages.push_back("Test " + testName + " failed: " + e.what()); + allTestsPassed = false; + } + }; + + // Ensure the connection is ready before running tests + if (CoreSDKTest::WaitOnConnectionReady()) { + // Account ID + runTest(CoreSDKTest::GetAccountId, "GetAccountId"); + + // Account UID + runTest(CoreSDKTest::GetAccountUid, "GetAccountUid"); + + // Advertising methods + runTest(CoreSDKTest::BuildAdvertisingConfiguration, "BuildAdvertisingConfiguration"); + runTest(CoreSDKTest::GetAdvertisingDeviceAttributes, "GetAdvertisingDeviceAttributes"); + runTest(CoreSDKTest::SubscribeAdvertisingPolicyChanged, "SubscribeAdvertisingPolicyChanged"); + runTest(CoreSDKTest::UnsubscribeAdvertisingPolicyChanged, "UnsubscribeAdvertisingPolicyChanged"); + + // Device properties + runTest(CoreSDKTest::GetDeviceModel, "GetDeviceModel"); + runTest(CoreSDKTest::GetDeviceSku, "GetDeviceSku"); + runTest(CoreSDKTest::GetDeviceName, "GetDeviceName"); + runTest(CoreSDKTest::GetDeviceName, "GetDeviceVersion"); + runTest(CoreSDKTest::SubscribeDeviceNameChanged, "SubscribeDeviceNameChanged"); + runTest(CoreSDKTest::UnsubscribeDeviceNameChanged, "UnsubscribeDeviceNameChanged"); + runTest(CoreSDKTest::GetDeviceAudio, "GetDeviceAudio"); + runTest(CoreSDKTest::SubscribeDeviceAudioChanged, "SubscribeDeviceAudioChanged"); + runTest(CoreSDKTest::UnsubscribeDeviceAudioChanged, "UnsubscribeDeviceAudioChanged"); + runTest(CoreSDKTest::GetDeviceScreenResolution, "GetDeviceScreenResolution"); + runTest(CoreSDKTest::SubscribeDeviceScreenResolutionChanged, "SubscribeDeviceScreenResolutionChanged"); + runTest(CoreSDKTest::UnsubscribeDeviceScreenResolutionChanged, "UnsubscribeDeviceScreenResolutionChanged"); + + // Localization methods + runTest(CoreSDKTest::GetLocalizationAdditionalInfo, "GetLocalizationAdditionalInfo"); + runTest(CoreSDKTest::GetLocalizationLatlon, "GetLocalizationLatlon"); + runTest(CoreSDKTest::GetLocalizationPreferredAudioLanguages, "GetLocalizationPreferredAudioLanguages"); + runTest(CoreSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged, "SubscribeLocalizationPreferredAudioLanguagesChanged"); + runTest(CoreSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged, "UnsubscribeLocalizationPreferredAudioLanguagesChanged"); + + // Accessibility - Closed Captions Settings + runTest(CoreSDKTest::GetAccessibilityClosedCaptionsSettings, "GetAccessibilityClosedCaptionsSettings"); + runTest(CoreSDKTest::SubscribeAccessibilityClosedCaptionsSettingsChanged, "SubscribeAccessibilityClosedCaptionsSettingsChanged"); + runTest(CoreSDKTest::UnsubscribeAccessibilityClosedCaptionsSettingsChanged, "UnsubscribeAccessibilityClosedCaptionsSettingsChanged"); + + // Keyboard methods + // runTest(CoreSDKTest::InvokeKeyboardEmail, "InvokeKeyboardEmail"); + // runTest(CoreSDKTest::AbortKeyboardEmail, "AbortKeyboardEmail"); + // runTest(CoreSDKTest::InvokeKeyboardPassword, "InvokeKeyboardPassword"); + // runTest(CoreSDKTest::AbortKeyboardPassword, "AbortKeyboardPassword"); + // runTest(CoreSDKTest::InvokeKeyboardStandard, "InvokeKeyboardStandard"); + // runTest(CoreSDKTest::AbortKeyboardStandard, "AbortKeyboardStandard"); + + // Profile methods + runTest(CoreSDKTest::VerifyProfileApproveContentRating, "VerifyProfileApproveContentRating"); + runTest(CoreSDKTest::VerifyProfileApprovePurchase, "VerifyProfileApprovePurchase"); + runTest(CoreSDKTest::GetProfileFlags, "GetProfileFlags"); + + // Authentication methods + runTest(CoreSDKTest::GetAuthenticationDevice, "GetAuthenticationDevice"); + runTest(CoreSDKTest::GetAuthenticationSession, "GetAuthenticationSession"); + runTest(CoreSDKTest::GetAuthenticationRoot, "GetAuthenticationRoot"); + runTest(CoreSDKTest::GetAuthenticationToken, "GetAuthenticationToken"); + + // Capabilities methods + runTest(CoreSDKTest::GetCapabilitiesAvailable, "GetCapabilitiesAvailable"); + runTest(CoreSDKTest::GetCapabilitiesGranted, "GetCapabilitiesGranted"); + runTest(CoreSDKTest::GetCapabilitiesPermitted, "GetCapabilitiesPermitted"); + runTest(CoreSDKTest::GetCapabilitiesSupported, "GetCapabilitiesSupported"); + runTest(CoreSDKTest::GetCapabilitiesInfo, "GetCapabilitiesInfo"); + + // Lifecycle methods + // runTest(CoreSDKTest::LifecycleClose, "LifecycleClose"); + runTest(CoreSDKTest::LifecycleReady, "LifecycleReady"); + runTest(CoreSDKTest::LifecycleFinished, "LifecycleFinished"); + runTest(CoreSDKTest::LifecycleState, "LifecycleState"); + runTest(CoreSDKTest::SubscribeLifecycleBackgroundNotification, "SubscribeLifecycleBackgroundNotification"); + runTest(CoreSDKTest::UnsubscribeLifecycleBackgroundNotification, "UnsubscribeLifecycleBackgroundNotification"); + runTest(CoreSDKTest::SubscribeLifecycleForegroundNotification, "SubscribeLifecycleForegroundNotification"); + runTest(CoreSDKTest::UnsubscribeLifecycleForegroundNotification, "UnsubscribeLifecycleForegroundNotification"); + + // Metrics methods + runTest(CoreSDKTest::MetricsReady, "MetricsReady"); + runTest(CoreSDKTest::MetricsSignIn, "MetricsSignIn"); + runTest(CoreSDKTest::MetricsSignOut, "MetricsSignOut"); + runTest(CoreSDKTest::MetricsStartContent, "MetricsStartContent"); + runTest(CoreSDKTest::MetricsStopContent, "MetricsStopContent"); + + + + // SecondScreen methods + runTest(CoreSDKTest::GetSecondScreenDevice, "GetSecondScreenDevice"); + runTest(CoreSDKTest::GetSecondScreenFriendlyName, "GetSecondScreenFriendlyName"); + runTest(CoreSDKTest::SubscribeSecondScreenFriendlyNameChanged, "SubscribeSecondScreenFriendlyNameChanged"); + runTest(CoreSDKTest::UnsubscribeSecondScreenFriendlyNameChanged, "UnsubscribeSecondScreenFriendlyNameChanged"); + runTest(CoreSDKTest::GetSecondScreenProtocols, "GetSecondScreenProtocols"); + + // Discovery methods + runTest(CoreSDKTest::DiscoverySignIn, "DiscoverySignIn"); + runTest(CoreSDKTest::DiscoverySignOut, "DiscoverySignOut"); + runTest(CoreSDKTest::DiscoveryContentAccess, "DiscoveryContentAccess"); + runTest(CoreSDKTest::DiscoveryClearContentAccess, "DiscoveryClearContentAccess"); + runTest(CoreSDKTest::DiscoveryEntitlements, "DiscoveryEntitlements"); + runTest(CoreSDKTest::DiscoveryEntityInfo, "DiscoveryEntityInfo"); + runTest(CoreSDKTest::DiscoveryPolicy, "DiscoveryPolicy"); + runTest(CoreSDKTest::DiscoveryPurchasedContent, "DiscoveryPurchasedContent"); + runTest(CoreSDKTest::DiscoveryWatchNext, "DiscoveryWatchNext"); + runTest(CoreSDKTest::DiscoveryLaunch, "DiscoveryLaunch"); #ifdef POLYMORPHICS_REDUCER_METHODS - "\tW : Watched\n" - "\tR : WatchedReduced\n" + runTest(CoreSDKTest::DiscoveryWatched, "DiscoveryWatched"); + runTest(CoreSDKTest::DiscoveryWatchedReduced, "DiscoveryWatchedReduced"); #endif - "\tB : Subscribe/Unsubscribe DiscoveryOnNavigateToLaunch\n" - "\tQ : Quit\n"); -} - -void ShowKeyboardMenu() -{ - printf("Enter\n" - "\tE : Invoke Email method\n" - "\tA : Abort Email method\n" - "\tP : Invoke Password method\n" - "\tC : Abort Password method\n" - "\tS : Invoke Standard method\n" - "\tK : Abort Standard method\n" - "\tQ : Quit\n"); -} - -void ShowEventMenu() -{ - printf("Enter\n" - "\tS : Subscribe Event\n" - "\tU : Unsubscribe Event\n" - "\tQ : Quit\n"); -} - -#define VALUE(string) #string -#define TO_STRING(string) VALUE(string) - -#define HandleEventListener(Module, eventFuncName) \ -{ \ - int opt; \ - do { \ - getchar(); \ - ShowEventMenu(); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'S': { \ - CoreSDKTest::Subscribe##Module##eventFuncName(); \ - break; \ - } \ - case 'U': { \ - CoreSDKTest::Unsubscribe##Module##eventFuncName(); \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - - -#define HandleProperty(Module, Property) \ -{ \ - int opt; \ - do { \ - getchar(); \ - std::string module = TO_STRING(Module); \ - std::string property = TO_STRING(Property); \ - ShowPropertyMenu(module, property); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'G': { \ - CoreSDKTest::Get##Module##Property(); \ - break; \ - } \ - case 'R': { \ - HandleEventListener(Module, Property##Changed) \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - -void HandleAuthenticationMethod() -{ - int opt; - do { - getchar(); - ShowAuthenticationMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'D': { - CoreSDKTest::GetAuthenticationDevice(); - break; - } - case 'S': { - CoreSDKTest::GetAuthenticationSession(); - break; - } - case 'R': { - CoreSDKTest::GetAuthenticationRoot(); - break; - } - case 'T': { - CoreSDKTest::GetAuthenticationToken(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} + runTest(CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification, "SubscribeDiscoveryOnNavigateToLaunchNotification"); + runTest(CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification, "UnsubscribeDiscoveryOnNavigateToLaunchNotification"); -void HandleCapabilitiesMethod() -{ - int opt; - do { - getchar(); - ShowCapabilitiesMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'A': { - HandleProperty(Capabilities, Available) - break; - } - case 'G': { - CoreSDKTest::GetCapabilitiesGranted(); - break; - } - case 'P': { - CoreSDKTest::GetCapabilitiesPermitted(); - break; - } - case 'S': { - CoreSDKTest::GetCapabilitiesSupported(); - break; - } - case 'I': { - CoreSDKTest::GetCapabilitiesInfo(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleProfileMethod() -{ - int opt; - do { - getchar(); - ShowProfileMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'C': { - CoreSDKTest::VerifyProfileApproveContentRating(); // Error while testing, need to cross check - break; - } - case 'P': { - CoreSDKTest::VerifyProfileApprovePurchase(); // Error while testing, need to cross check - break; - } - case 'F': { - CoreSDKTest::GetProfileFlags(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleLocalizationMethod() -{ - int opt; - do { - getchar(); - ShowLocalizationMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'A': { - CoreSDKTest::GetLocalizationAdditionalInfo(); - break; - } - case 'L': { - CoreSDKTest::GetLocalizationLatlon(); - break; - } - case 'P': { - HandleProperty(Localization, PreferredAudioLanguages) - break; - } - default: - break; - } - } while (opt != 'Q'); -} + // Parameters Initialization + runTest(CoreSDKTest::ParametersInitialization, "ParametersInitialization"); -void HandleAdvertisingMethod() -{ - int opt; - do { - getchar(); - ShowAdvertisingMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'P': { - HandleProperty(Advertising, Policy) - break; - } - case 'C': { - CoreSDKTest::BuildAdvertisingConfiguration(); // Error while testing need to check - break; - } - case 'D': { - CoreSDKTest::GetAdvertisingDeviceAttributes(); // Error while testing need to check - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleLifecycleMethod() -{ - int opt; - do { - getchar(); - ShowLifecycleMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'C': { - CoreSDKTest::LifecycleClose(); - break; - } - case 'B': { - HandleEventListener(Lifecycle, BackgroundNotification) - break; - } - case 'F': { - HandleEventListener(Lifecycle, ForegroundNotification) - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleMetricsMethod() -{ - int opt; - do { - getchar(); - ShowMetricsMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'S': { - CoreSDKTest::MetricsStartContent(); - break; - } - case 'T': { - CoreSDKTest::MetricsStopContent(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleSecondScreenMethod() -{ - int opt; - do { - getchar(); - ShowSecondScreenMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'D': { - CoreSDKTest::GetSecondScreenDevice(); - break; - } - case 'F': { - HandleProperty(SecondScreen, FriendlyName) - break; - } - case 'P': { - CoreSDKTest::GetSecondScreenProtocols(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleDiscoveryMethod() -{ - int opt; - do { - getchar(); - ShowDiscoveryMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'S': { - CoreSDKTest::DiscoverySignIn(); - break; - } - case 'O': { - CoreSDKTest::DiscoverySignOut(); - break; - } - case 'A': { - CoreSDKTest::DiscoveryContentAccess(); - break; - } - case 'C': { - CoreSDKTest::DiscoveryClearContentAccess(); - break; - } - case 'E': { - CoreSDKTest::DiscoveryEntitlements(); - break; - } - case 'I': { - CoreSDKTest::DiscoveryEntityInfo(); - break; - } - case 'P': { - CoreSDKTest::DiscoveryPolicy(); - break; - } - case 'U': { - CoreSDKTest::DiscoveryPurchasedContent(); - break; - } - case 'N': { - CoreSDKTest::DiscoveryWatchNext(); - break; - } - case 'L': { - CoreSDKTest::DiscoveryLaunch(); - break; - } -#ifdef POLYMORPHICS_REDUCER_METHODS - case 'W': { - CoreSDKTest::DiscoveryWatched(); - break; - } - case 'R': { - CoreSDKTest::DiscoveryWatchedReduced(); - break; - } -#endif - case 'B': { - HandleEventListener(Discovery, OnNavigateToLaunchNotification) - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleKeyboardMethodsInvokation() -{ - int opt; - do { - getchar(); - ShowKeyboardMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'E': { - CoreSDKTest::InvokeKeyboardEmail(); - break; - } - case 'A': { - CoreSDKTest::AbortKeyboardEmail(); - break; - } - case 'P': { - CoreSDKTest::InvokeKeyboardPassword(); - break; - } - case 'C': { - CoreSDKTest::AbortKeyboardPassword(); - break; - } - case 'S': { - CoreSDKTest::InvokeKeyboardStandard(); - break; - } - case 'K': { - CoreSDKTest::AbortKeyboardStandard(); - break; - } - default: - break; + if (allTestsPassed) { + cout << "============================" << endl; + cout << "ALL CORE SDK TESTS SUCCEEDED!" << endl; + cout << "============================" << endl; + } else { + cout << "============================" << endl; + cout << "SOME TESTS FAILED:" << endl; + for (const auto& errorMessage : errorMessages) { + cout << errorMessage << endl; + } + cout << "============================" << endl; + exit(1); } - } while (opt != 'Q'); + } else { + cout << "Core Test not able to connect with server..." << endl; + exit(1); + } } -#define options ":hu:" -int main (int argc, char* argv[]) -{ +int main(int argc, char* argv[]) { int c; - std::string url = "ws://127.0.0.1:9998"; - while ((c = getopt (argc, argv, options)) != -1) { - switch (c) - { + string url = "ws://127.0.0.1:9998"; + while ((c = getopt(argc, argv, options)) != -1) { + switch (c) { case 'u': - url = optarg; - break; - + url = optarg; + break; case 'h': - printf("./TestFireboltManage -u ws://ip:port\n"); - exit(1); + printf("./TestFireboltManage -u ws://ip:port\n"); + exit(1); } } printf("Firebolt Core SDK Test\n"); CoreSDKTest::CreateFireboltInstance(url); - int option; - if (CoreSDKTest::WaitOnConnectionReady() == true) { - do { - ShowMenu(); - printf("Enter option : "); - option = toupper(getchar()); - switch (option) { - case 'I' : { - CoreSDKTest::GetAccountId(); // Error while running need to cross check - break; - } - case 'U' : { - CoreSDKTest::GetAccountUid(); // Error while running need to cross check - break; - } - case 'A' : { - HandleAdvertisingMethod(); - break; - } - case 'N': { - HandleProperty(Device, Name) - break; - } - case 'M': { - CoreSDKTest::GetDeviceModel(); - break; - } - case 'S': { - CoreSDKTest::GetDeviceSku(); - break; - } - case 'P': { - HandleProperty(Device, Audio) - break; - } - case 'R': { - HandleProperty(Device, ScreenResolution) - break; - } - case 'L': { - HandleLocalizationMethod(); - break; - } - case 'C': { - HandleProperty(Accessibility, ClosedCaptionsSettings) - break; - } - case 'K': { - HandleKeyboardMethodsInvokation(); - break; - } - case 'V': { - HandleProfileMethod(); - break; - } - case 'T': { - HandleAuthenticationMethod(); - break; - } - case 'B': { - HandleCapabilitiesMethod(); - break; - } - case 'F': { - HandleLifecycleMethod(); - break; - } - case 'E': { - HandleMetricsMethod(); - break; - } - case 'D': { - HandleSecondScreenMethod(); - break; - } - case 'Y': { - HandleDiscoveryMethod(); - break; - } - case 'Z': { - CoreSDKTest::ParametersInitialization(); - break; - } - default: - break; - } - getchar(); // Skip white space - } while (option != 'Q'); - - } else { - printf("Core Test not able to connect with server.... \n"); - } - + RunAllTests(); CoreSDKTest::DestroyFireboltInstance(); return 0; -} +} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Device/include/module.h b/src/sdks/core/src/cpp/templates/Device/include/module.h new file mode 100644 index 000000000..a4d42be2c --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Device/include/module.h @@ -0,0 +1,37 @@ +/* Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include "error.h" +/* ${IMPORTS} */ + +${if.declarations} +namespace Firebolt { + namespace ${info.Title} { + ${if.enums}/* ${ENUMS} */${end.if.enums} + ${if.types}/* ${TYPES} */${end.if.types} + ${if.providers}/* ${PROVIDERS} */${end.if.providers}${if.xuses}/* ${XUSES} */${end.if.xuses} + ${if.methods}struct I${info.Title} { + // Methods & Events + /* ${METHODS:declarations} */ + virtual ~I${info.Title}() = default; + virtual std::string version( Firebolt::Error *err = nullptr ) const = 0; + }; + ${end.if.methods} + } //namespace ${info.Title} +} +${end.if.declarations} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp b/src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp new file mode 100644 index 000000000..242897d9d --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp @@ -0,0 +1,65 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "${info.title.lowercase}_impl.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.providers} +/* ${PROVIDERS} */${end.if.providers} + std::string ${info.Title}Impl::version(Firebolt::Error *err) const + { + JsonObject jsonParameters; + JsonData_Versions jsonResult; + std::string version; + + Firebolt::Error status = Firebolt::Error::NotConnected; + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + status = transport->Invoke("${info.title.lowercase}.version", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + !jsonResult.IsSet() ? jsonResult.Clear() : (void)0; + !jsonResult.Sdk.IsSet() ? jsonResult.Sdk.Clear() : (void)0; + jsonResult.Sdk.Major = static_cast(${major}); + jsonResult.Sdk.Minor = static_cast(${minor}); + jsonResult.Sdk.Patch = static_cast(${patch}); + jsonResult.Sdk.Readable = "${readable}"; + jsonResult.ToString(version); + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + return version; + } + // Methods + /* ${METHODS} */ + + // Events + /* ${EVENTS} */ + +}//namespace ${info.Title} +}${end.if.implementations} +${if.enums} + +namespace WPEFramework { + +/* ${ENUMS} */ +}${end.if.enums} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Device/src/module_impl.h b/src/sdks/core/src/cpp/templates/Device/src/module_impl.h new file mode 100644 index 000000000..b96de7778 --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Device/src/module_impl.h @@ -0,0 +1,54 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "FireboltSDK.h" +#include "IModule.h" +#include + + +/* ${IMPORTS} */ +#include "${info.title.lowercase}.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.enums} + +/* ${ENUMS:json-types} */${end.if.enums} +${if.types} + // Types +/* ${TYPES:json-types} */${end.if.types} + ${if.methods}class ${info.Title}Impl : public I${info.Title}, public IModule { + + public: + ${info.Title}Impl() = default; + ${info.Title}Impl(const ${info.Title}Impl&) = delete; + ${info.Title}Impl& operator=(const ${info.Title}Impl&) = delete; + + ~${info.Title}Impl() override = default; + + std::string version(Firebolt::Error *err = nullptr) const override; + + // Methods & Events + /* ${METHODS:declarations-override} */ + };${end.if.methods} + +}//namespace ${info.Title} +}${end.if.implementations} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Lifecycle/include/module.h b/src/sdks/core/src/cpp/templates/Lifecycle/include/module.h new file mode 100644 index 000000000..1f954f6de --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Lifecycle/include/module.h @@ -0,0 +1,60 @@ +/* Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "error.h" +#include +/* ${IMPORTS} */ + +${if.declarations}namespace Firebolt { +namespace ${info.Title} { + +${if.enums} +// Enums +/* ${ENUMS} */${end.if.enums} + +${if.types} +// Types +/* ${TYPES} */${end.if.types} + +${if.providers}/* ${PROVIDERS} */${end.if.providers}${if.xuses}/* ${XUSES} */${end.if.xuses} + +${if.methods}struct I${info.Title} { + + virtual ~I${info.Title}() = default; + virtual void ready(Firebolt::Error *err = nullptr) = 0; + virtual void finished(Firebolt::Error *err = nullptr) = 0; + virtual std::string state(Firebolt::Error *err = nullptr) = 0; + + // Methods & Events + /* ${METHODS:declarations} */ +};${end.if.methods} + +// Template for mapping enums to strings +template +using EnumMap = std::unordered_map; + +// Function to convert enum values to string representations +template +inline const std::string& ConvertEnum(EnumMap enumMap, T type) +{ + return enumMap[type]; +} + +} //namespace ${info.Title} +}${end.if.declarations} diff --git a/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.cpp b/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.cpp new file mode 100644 index 000000000..233d3f973 --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.cpp @@ -0,0 +1,152 @@ +/* Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + +#include "${info.title.lowercase}_impl.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.providers} +/* ${PROVIDERS} */${end.if.providers} + +EnumMap lifecycleStateMap = { + { Firebolt::Lifecycle::LifecycleState::INITIALIZING, "initializing" }, + { Firebolt::Lifecycle::LifecycleState::INACTIVE, "inactive" }, + { Firebolt::Lifecycle::LifecycleState::FOREGROUND, "foreground" }, + { Firebolt::Lifecycle::LifecycleState::BACKGROUND, "background" }, + { Firebolt::Lifecycle::LifecycleState::UNLOADING, "unloading" }, + { Firebolt::Lifecycle::LifecycleState::SUSPENDED, "suspended" } +}; + + +/* ready - Notify the platform that the app is ready */ +static void readyDispatcher(const void* result) { + Firebolt::IFireboltAccessor::Instance().MetricsInterface().ready(); +} + +// localCallback to update the state +static void onReadyInnerCallback(void* notification, const void* userData, void* jsonResponse ) +{ + const LifecycleImpl* selfConst = static_cast(userData); + LifecycleImpl* self = const_cast(selfConst); + + WPEFramework::Core::ProxyType& proxyResponse = *(reinterpret_cast*>(jsonResponse)); + ASSERT(proxyResponse.IsValid() == true); + + if (proxyResponse.IsValid() == true) { + LifecycleEvent value; + + value.state = proxyResponse->State; + std::string stateStr = ConvertEnum(lifecycleStateMap, value.state); + // Assign stateStr to currentState in ${info.Title}Impl instance + self->currentState = stateStr; + std::cout << "Updated the Current State to: " << self->currentState << std::endl; + + proxyResponse.Release(); + + } +} + + + +/* ready - Notify the platform that the app is ready */ +void ${info.Title}Impl::ready(Firebolt::Error *err) { + Firebolt::Error status = Firebolt::Error::NotConnected; + + JsonObject jsonParameters; + + // Call Prioritize to subscribe to corresponding event, add to internalMap, and prioritize its callback + status = FireboltSDK::Event::Instance().Prioritize("lifecycle.onForeground", jsonParameters, onReadyInnerCallback, (void*)nullptr, this); + status = FireboltSDK::Event::Instance().Prioritize("lifecycle.onBackground", jsonParameters, onReadyInnerCallback, (void*)nullptr, this); + status = FireboltSDK::Event::Instance().Prioritize("lifecycle.onInactive", jsonParameters, onReadyInnerCallback, (void*)nullptr, this); + status = FireboltSDK::Event::Instance().Prioritize("lifecycle.onSuspended", jsonParameters, onReadyInnerCallback, (void*)nullptr, this); + status = FireboltSDK::Event::Instance().Prioritize("lifecycle.onUnloading", jsonParameters, onReadyInnerCallback, (void*)nullptr, this); + + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + WPEFramework::Core::JSON::VariantContainer jsonResult; + status = transport->Invoke("lifecycle.ready", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Lifecycle.ready is successfully invoked"); + + WPEFramework::Core::ProxyType job = WPEFramework::Core::ProxyType(WPEFramework::Core::ProxyType::Create(readyDispatcher, nullptr)); + WPEFramework::Core::IWorkerPool::Instance().Submit(job); + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in invoking lifecycle.ready: %d", status); + if (err != nullptr) { + *err = status; + } + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + if (err != nullptr) { + *err = status; + } + } +} + + +/* state - return the state of the app */ +std::string ${info.Title}Impl::state(Firebolt::Error *err) { + std::cout << "**CURRENT STATE OF THE APP::::**" << currentState << std::endl; + return currentState; +} + + + +/* finished - Notify the platform that the app is done unloading */ +void ${info.Title}Impl::finished(Firebolt::Error *err) +{ + Firebolt::Error status = Firebolt::Error::NotConnected; + if(currentState == "unloading") + { + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + JsonObject jsonParameters; + + WPEFramework::Core::JSON::VariantContainer jsonResult; + status = transport->Invoke("lifecycle.finished", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Lifecycle.finished is successfully invoked"); + + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + } + + return; +} + +// Methods +/* ${METHODS} */ + +// Events +/* ${EVENTS} */ + +}//namespace Lifecycle +}${end.if.implementations} +${if.enums} + +namespace WPEFramework { + +/* ${ENUMS} */ +}${end.if.enums} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.h b/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.h new file mode 100644 index 000000000..79a582da5 --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.h @@ -0,0 +1,58 @@ +/* Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include "FireboltSDK.h" +#include "IModule.h" +#include "firebolt.h" +#include "jsondata_lifecycle.h" +#include "${info.title.lowercase}.h" + +/* ${IMPORTS} */ + + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.enums} + +/* ${ENUMS:json-types} */${end.if.enums} +${if.types} +// Types +/* ${TYPES:json-types} */${end.if.types} +${if.methods}class ${info.Title}Impl : public I${info.Title}, public IModule { + +public: + ${info.Title}Impl() = default; + ${info.Title}Impl(const ${info.Title}Impl&) = delete; + ${info.Title}Impl& operator=(const ${info.Title}Impl&) = delete; + ~${info.Title}Impl() override = default; + + std::string currentState = "INITIALIZING"; + + // Methods & Events + /* ${METHODS:declarations-override} */ + + void finished(Firebolt::Error *err = nullptr) override ; + void ready(Firebolt::Error *err = nullptr) override; + std::string state(Firebolt::Error *err = nullptr) override; + +};${end.if.methods} + +} // namespace ${info.Title} +} // namespace Firebolt +${end.if.implementations} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Metrics/include/module.h b/src/sdks/core/src/cpp/templates/Metrics/include/module.h new file mode 100644 index 000000000..ccca61a6a --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Metrics/include/module.h @@ -0,0 +1,36 @@ +#pragma once + +#include "error.h" +/* ${IMPORTS} */ + +${if.declarations}namespace Firebolt { +namespace ${info.Title} { +${if.enums} + +// Enums +/* ${ENUMS} */${end.if.enums} +${if.types} +// Types +/* ${TYPES} */${end.if.types} +${if.providers}/* ${PROVIDERS} */${end.if.providers}${if.xuses}/* ${XUSES} */${end.if.xuses} +${if.methods}struct I${info.Title} { + + virtual ~I${info.Title}() = default; + virtual bool ready( Firebolt::Error *err = nullptr ) = 0 ; + virtual bool signIn( Firebolt::Error *err = nullptr ) = 0 ; + virtual bool signOut( Firebolt::Error *err = nullptr ) = 0 ; + + // Methods & Events + /* ${METHODS:declarations} */ +};${end.if.methods} + +} //namespace ${info.Title} +}${end.if.declarations} + + + + + + + + diff --git a/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp index 59a50162d..085c4173a 100644 --- a/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp +++ b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp @@ -18,68 +18,95 @@ #include "${info.title.lowercase}_impl.h" + ${if.implementations} namespace Firebolt { namespace ${info.Title} { ${if.providers} /* ${PROVIDERS} */${end.if.providers} - void ${info.Title}Impl::signIn() + +/* ready - Inform the platform that your app is minimally usable. This method is called automatically by `Lifecycle.ready()` */ + bool ${info.Title}Impl::ready( Firebolt::Error *err ) { Firebolt::Error status = Firebolt::Error::NotConnected; + bool success = false; FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); if (transport != nullptr) { - + JsonObject jsonParameters; - + WPEFramework::Core::JSON::Boolean jsonResult; - status = transport->Invoke("${info.title.lowercase}.signIn", jsonParameters, jsonResult); + status = transport->Invoke("${info.title.lowercase}.ready", jsonParameters, jsonResult); if (status == Firebolt::Error::None) { - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title.signIn is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false")); + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Metrics.ready is successfully invoked"); + success = jsonResult.Value(); } } else { FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); } + if (err != nullptr) { + *err = status; + } + + return success; } - void ${info.Title}Impl::signOut() + + /* signIn - Log a sign In event, called by Discovery.signIn(). */ + bool ${info.Title}Impl::signIn( Firebolt::Error *err ) { Firebolt::Error status = Firebolt::Error::NotConnected; + bool success = false; FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); if (transport != nullptr) { - + JsonObject jsonParameters; - + WPEFramework::Core::JSON::Boolean jsonResult; - status = transport->Invoke("${info.title.lowercase}.signOut", jsonParameters, jsonResult); + status = transport->Invoke("${info.title.lowercase}.signIn", jsonParameters, jsonResult); if (status == Firebolt::Error::None) { - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.signOut is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false")); + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Metrics.signOut is successfully invoked"); + success = jsonResult.Value(); } } else { FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); } - } + if (err != nullptr) { + *err = status; + } + return success; - void ${info.Title}Impl::ready() + } + /* signOut - Log a sign out event, called by Discovery.signOut(). */ + bool ${info.Title}Impl::signOut( Firebolt::Error *err ) { Firebolt::Error status = Firebolt::Error::NotConnected; + bool success = false; FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); if (transport != nullptr) { - + JsonObject jsonParameters; - + WPEFramework::Core::JSON::Boolean jsonResult; - status = transport->Invoke("${info.title.lowercase}.ready", jsonParameters, jsonResult); + status = transport->Invoke("${info.title.lowercase}.signOut", jsonParameters, jsonResult); if (status == Firebolt::Error::None) { - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.ready is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false")); + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Metrics.signOut is successfully invoked"); + success = jsonResult.Value(); } } else { FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); } + if (err != nullptr) { + *err = status; + } + + return success; } + // Methods /* ${METHODS} */ @@ -93,4 +120,4 @@ namespace ${info.Title} { namespace WPEFramework { /* ${ENUMS} */ -}${end.if.enums} +}${end.if.enums} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h index d64b59695..219803938 100644 --- a/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h +++ b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h @@ -20,6 +20,7 @@ #include "FireboltSDK.h" #include "IModule.h" + /* ${IMPORTS} */ #include "${info.title.lowercase}.h" @@ -41,12 +42,16 @@ namespace ${info.Title} { ~${info.Title}Impl() override = default; - static void signIn(); - static void signOut(); - static void ready(); + + bool ready( Firebolt::Error *err = nullptr ) ; + bool signIn( Firebolt::Error *err = nullptr ) ; + bool signOut( Firebolt::Error *err = nullptr ) ; + + + // Methods & Events /* ${METHODS:declarations-override} */ };${end.if.methods} }//namespace ${info.Title} -}${end.if.implementations} +}${end.if.implementations} \ No newline at end of file diff --git a/src/sdks/core/test/suite/discovery.test.ts b/src/sdks/core/test/suite/discovery.test.ts index 638c57432..7402dce42 100644 --- a/src/sdks/core/test/suite/discovery.test.ts +++ b/src/sdks/core/test/suite/discovery.test.ts @@ -150,3 +150,12 @@ test("clear()", () => { const result: boolean = Discovery.clear(-1000); expect(result).toBeFalsy(); }); + +test("details() provider", () => { + + class myUserInterestProvider implements Discovery.UserInterestProvider { + userInterest(parameters?: object, session?: Discovery.ProviderSession): Promise { + return null + } + } +}) \ No newline at end of file diff --git a/src/sdks/discovery/.npmignore b/src/sdks/discovery/.npmignore new file mode 100644 index 000000000..0e2ba4d22 --- /dev/null +++ b/src/sdks/discovery/.npmignore @@ -0,0 +1,6 @@ +build/* +src/* +test/* +.DS_Store +jest.config.* +tsconfig.* \ No newline at end of file diff --git a/src/sdks/discovery/CHANGELOG.md b/src/sdks/discovery/CHANGELOG.md new file mode 100644 index 000000000..af3ac672a --- /dev/null +++ b/src/sdks/discovery/CHANGELOG.md @@ -0,0 +1,6 @@ +# 1.2.0 (https://github.com/rdkcentral/firebolt-apis/compare/v1.1.0...v1.2.0) (2024-06-14) + +### Features + +* Introduced Discovery SDK for first-party aggregated experiences to connect with third-party apps. +* [User Interest](https://github.com/rdkcentral/firebolt-apis/blob/main/requirements/specifications/discovery/user-interest.md) (#170 (https://github.com/rdkcentral/firebolt-apis/issues/170)) (48a1094 (https://github.com/rdkcentral/firebolt-apis/commit/48a1094aaab6418f09db662dbc81f090a34f32ed)) diff --git a/src/sdks/discovery/CONTRIBUTING.md b/src/sdks/discovery/CONTRIBUTING.md new file mode 120000 index 000000000..c97564d93 --- /dev/null +++ b/src/sdks/discovery/CONTRIBUTING.md @@ -0,0 +1 @@ +../../../CONTRIBUTING.md \ No newline at end of file diff --git a/src/sdks/discovery/LICENSE b/src/sdks/discovery/LICENSE new file mode 120000 index 000000000..5853aaea5 --- /dev/null +++ b/src/sdks/discovery/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/src/sdks/discovery/NOTICE b/src/sdks/discovery/NOTICE new file mode 120000 index 000000000..295f6bdb3 --- /dev/null +++ b/src/sdks/discovery/NOTICE @@ -0,0 +1 @@ +../../../NOTICE \ No newline at end of file diff --git a/src/sdks/discovery/README.md b/src/sdks/discovery/README.md new file mode 100644 index 000000000..2ec46b95d --- /dev/null +++ b/src/sdks/discovery/README.md @@ -0,0 +1,26 @@ +--- +title: Firebolt Discovery SDK +--- + +[![semantic-release: conventional](https://img.shields.io/badge/semantic--release-conventional-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) + +# Firebolt Discovery SDK +For building Firebolt compliant apps for discovering first-party content on Firebolt devices. + +## Usage +To install, run: + +``` +npm install @firebolt-js/discovery-sdk +``` + +To use the package, import one of it's modules, e.g.: + +```js +import { Content } from '@firebolt-js/discovery-sdk' +``` + +## Contributing +The Firebolt SDKs are built using the Firebolt OpenRPC toolset: + +See [Firebolt OpenRPC](https://www.github.com/rdkcentral/firebolt-openrpc/), for more info. diff --git a/src/sdks/discovery/jest.config.json b/src/sdks/discovery/jest.config.json new file mode 100644 index 000000000..745370cfa --- /dev/null +++ b/src/sdks/discovery/jest.config.json @@ -0,0 +1,8 @@ +{ + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|js?)$", + "transform": {}, + "testPathIgnorePatterns": ["/node_modules/", "/../../../test"], + "moduleFileExtensions": ["js", "jsx", "mjs"], + "verbose": true, + "testEnvironment": "jest-environment-jsdom" + } \ No newline at end of file diff --git a/src/sdks/discovery/package.json b/src/sdks/discovery/package.json new file mode 100644 index 000000000..549853107 --- /dev/null +++ b/src/sdks/discovery/package.json @@ -0,0 +1,56 @@ +{ + "name": "@firebolt-js/discovery-sdk", + "version": "1.3.0-next.1", + "description": "The Firebolt Discovery JS SDK", + "main": "./dist/lib/firebolt-discovery.mjs", + "types": "./dist/lib/firebolt-discovery.d.ts", + "exports": { + ".": "./dist/lib/firebolt-discovery.mjs" + }, + "type": "module", + "scripts": { + "validate": "npx firebolt-openrpc validate --input ./dist/firebolt-discovery-open-rpc.json", + "sdk": "npx firebolt-openrpc sdk --input ./dist/firebolt-discovery-open-rpc.json --template ./src/js --output ./build/javascript/src", + "native": "npx firebolt-openrpc sdk --input ./dist/firebolt-discovery-open-rpc.json --template ./src/js --output ./build/c/src --language ../../../node_modules/@firebolt-js/openrpc/languages/c", + "cpp": "npm run cpp:compile && npm run cpp:install", + "cpp:compile": "npx firebolt-openrpc sdk --input ./dist/firebolt-discovery-open-rpc.json --template ./src/cpp --output ./build/cpp/src --static-module Platform --language ../../../node_modules/@firebolt-js/openrpc/languages/cpp", + "cpp:install": "./build/cpp/src/scripts/install.sh -i ./build/cpp/src -s ./build/cpp/src/ -m discovery", + "compile": "cd ../../.. && npm run compile", + "slice": "npx firebolt-openrpc slice -i ../../../dist/firebolt-open-rpc.json --sdk ./sdk.config.json -o ./dist/firebolt-discovery-open-rpc.json", + "docs": "npx firebolt-openrpc docs --input ./dist/firebolt-discovery-open-rpc.json --output build/docs/markdown --as-path", + "wiki": "npx firebolt-openrpc docs --input ./dist/firebolt-discovery-open-rpc.json --output build/docs/markdown", + "dist:notest": "npm run clean && npm run slice && npm run validate && npm run sdk && npm run docs && npm run prettier && npm run dist:copy && echo 'Firebolt Discovery SDK /dist/ is ready.\n'", + "dist:copy": "npm run dist:copy:sdk && npm run dist:copy:docs", + "dist:copy:sdk": "mkdirp ./dist && cp -R build/javascript/src dist/lib && cp ./dist/firebolt-discovery-open-rpc.json ../../../dist/firebolt-discovery-open-rpc.json", + "dist:copy:docs": "mkdirp ./dist && cp -R build/docs/markdown dist/docs", + "dist": "npm run dist:notest && npm run test", + "clean": "rm -rf ./build && rm -rf ./dist", + "test:setup": "rm -rf test/transpiled-suite && npx tsc --target es6 --moduleResolution node --outDir test/transpiled-suite", + "test": "npm run test:setup && NODE_OPTIONS=--experimental-vm-modules npx --config=jest.config.json --detectOpenHandles jest", + "prepack": "node ../../js/version.mjs validate && npm run broilerplate", + "broilerplate": "rm ./CONTRIBUTING.md && cp ../../../CONTRIBUTING.md ./CONTRIBUTING.md && rm ./LICENSE && cp ../../../LICENSE ./LICENSE && rm ./NOTICE && cp ../../../NOTICE ./NOTICE", + "prettier": "prettier build/**/*.mjs --write --parser babel && prettier build/**/*.md --write --parser markdown" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/rdkcentral/firebolt-core-sdk", + "directory": "src/sdks/discovery" + }, + "author": "", + "bugs": { + "url": "https://github.com/rdkcentral/firebolt-core-sdk/issues" + }, + "homepage": "https://github.com/rdkcentral/firebolt-core-sdk#readme", + "devDependencies": { + "jest": "^28.1.0", + "jest-environment-jsdom": "^28.1.3", + "prettier": "^3.1.0", + "typescript": "^4.6.4" + }, + "keywords": [ + "firebolt", + "apps", + "sdk" + ], + "license": "Apache-2.0" +} \ No newline at end of file diff --git a/src/sdks/discovery/sdk.config.json b/src/sdks/discovery/sdk.config.json new file mode 100644 index 000000000..535d3bb12 --- /dev/null +++ b/src/sdks/discovery/sdk.config.json @@ -0,0 +1,15 @@ +{ + "info": { + "title": "Firebolt Discovery SDK" + }, + "methods": [ + { + "module": "Content", + "use": [ + "xrn:firebolt:capability:discovery:purchased-content", + "xrn:firebolt:capability:discovery:entity-info", + "xrn:firebolt:capability:discovery:interest" + ] + } + ] +} diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/CMakeLists.txt b/src/sdks/discovery/src/cpp/sdk/cpptest/CMakeLists.txt new file mode 100644 index 000000000..e2fc88793 --- /dev/null +++ b/src/sdks/discovery/src/cpp/sdk/cpptest/CMakeLists.txt @@ -0,0 +1,75 @@ +# Copyright 2023 Comcast Cable Communications Management, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.3) + +project(FireboltDiscoverySDKTests) + +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${SYSROOT_PATH}/usr" CACHE INTERNAL "" FORCE) + set(CMAKE_PREFIX_PATH ${SYSROOT_PATH}/usr/lib/cmake CACHE INTERNAL "" FORCE) +endif() + +list(APPEND CMAKE_MODULE_PATH + "${SYSROOT_PATH}/usr/lib/cmake" + "${SYSROOT_PATH}/tools/cmake") +message("FIREBOLT_PATH inside cmake " ${FIREBOLT_PATH}) +if (FIREBOLT_PATH) + set(CMAKE_FIREBOLT_PATH + "${FIREBOLT_PATH}/usr/lib/cmake/Firebolt" + "${FIREBOLT_PATH}/usr/lib/cmake/FireboltSDK") + list(APPEND CMAKE_PREFIX_PATH ${CMAKE_FIREBOLT_PATH}) + list(APPEND CMAKE_MODULE_PATH ${CMAKE_FIREBOLT_PATH}) +else () + set(FIREBOLT_PATH "${SYSROOT_PATH}" CACHE INTERNAL "" FORCE) +endif () + +find_package(WPEFramework CONFIG REQUIRED) +find_package(${NAMESPACE}Core CONFIG REQUIRED) +find_package(Firebolt CONFIG REQUIRED) +find_package(${FIREBOLT_NAMESPACE}SDK CONFIG REQUIRED) + +set(TESTAPP TestFireboltDiscovery) + +message("Setup ${TESTAPP}") + +add_executable(${TESTAPP} DiscoverySDKTest.cpp Main.cpp) + +target_link_libraries(${TESTAPP} + PRIVATE + ${NAMESPACE}Core::${NAMESPACE}Core + ${FIREBOLT_NAMESPACE}SDK::${FIREBOLT_NAMESPACE}SDK +) + +target_include_directories(${TESTAPP} + PRIVATE + $ + $ + $ +) + +set_target_properties(${TESTAPP} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED YES +) + +add_custom_command( + TARGET ${TESTAPP} + POST_BUILD + COMMENT "=================== Installing TestApp ======================" + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${TESTAPP} ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin +) diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.cpp b/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.cpp new file mode 100644 index 000000000..27fe67244 --- /dev/null +++ b/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.cpp @@ -0,0 +1,102 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include "DiscoverySDKTest.h" + +using namespace std; +bool DiscoverySDKTest::_connected; + +void DiscoverySDKTest::ConnectionChanged(const bool connected, const Firebolt::Error error) +{ + cout << "Change in connection: connected: " << connected << " error: " << static_cast(error) << endl; + _connected = connected; +} + +void DiscoverySDKTest::CreateFireboltInstance(const std::string& url) +{ + const std::string config = "{\ + \"waitTime\": 100000,\ + \"logLevel\": \"Info\",\ + \"workerPool\":{\ + \"queueSize\": 8,\ + \"threadCount\": 3\ + },\ + \"wsUrl\": " + url + "}"; + + _connected = false; + Firebolt::IFireboltAccessor::Instance().Initialize(config); + Firebolt::IFireboltAccessor::Instance().Connect(ConnectionChanged); +} + +void DiscoverySDKTest::DestroyFireboltInstance() +{ + Firebolt::IFireboltAccessor::Instance().Disconnect(); + Firebolt::IFireboltAccessor::Instance().Deinitialize(); + Firebolt::IFireboltAccessor::Instance().Dispose(); +} + +bool DiscoverySDKTest::WaitOnConnectionReady() +{ + uint32_t waiting = 10000; + static constexpr uint32_t SLEEPSLOT_TIME = 100; + + // Right, a wait till connection is closed is requested.. + while ((waiting > 0) && (_connected == false)) { + + uint32_t sleepSlot = (waiting > SLEEPSLOT_TIME ? SLEEPSLOT_TIME : waiting); + // Right, lets sleep in slices of 100 ms + usleep(sleepSlot); + waiting -= sleepSlot; + } + return _connected; +} + +template +using EnumMap = std::unordered_map; +template +inline const string& ConvertFromEnum(EnumMap enumMap, T type) +{ + return enumMap[type]; +} +template +inline const T ConvertToEnum(EnumMap enumMap, const string& str) +{ + T value; + for (auto element: enumMap) { + if (element.second == str) { + value = element.first; + break; + } + } + return value; +} + +void DiscoverySDKTest::SampleTest() +{ + Firebolt::Error error = Firebolt::Error::None; + + if (error == Firebolt::Error::None) { + cout << "Sample Test Passed!" << endl; + } else { + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SampleTest failed. " + errorMessage); + } +} diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.h b/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.h new file mode 100644 index 000000000..2fcd2bcc0 --- /dev/null +++ b/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.h @@ -0,0 +1,41 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include "firebolt.h" + +class DiscoverySDKTest { + +public: + DiscoverySDKTest() = default; + virtual ~DiscoverySDKTest() = default; + + static void CreateFireboltInstance(const std::string& url); + static void DestroyFireboltInstance(); + static void TestDiscoveryStaticSDK(); + + static void SampleTest(); + + static bool WaitOnConnectionReady(); + +private: + static void ConnectionChanged(const bool, const Firebolt::Error); + static bool _connected; +}; \ No newline at end of file diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/discovery/src/cpp/sdk/cpptest/Main.cpp new file mode 100644 index 000000000..26e2b5dc6 --- /dev/null +++ b/src/sdks/discovery/src/cpp/sdk/cpptest/Main.cpp @@ -0,0 +1,89 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include "DiscoverySDKTest.h" + +using namespace std; + +const char* options = ":hu:"; + +void RunAllTests() { + bool allTestsPassed = true; + vector errorMessages; + + auto runTest = [&allTestsPassed, &errorMessages](auto testFunction, const string& testName) { + try { + testFunction(); + } catch (const exception& e) { + errorMessages.push_back("Test " + testName + " failed: " + e.what()); + allTestsPassed = false; + } + }; + + // Ensure the connection is ready before running tests + if (DiscoverySDKTest::WaitOnConnectionReady()) { + // Add tests here + + runTest(DiscoverySDKTest::SampleTest, "SampleTest"); + + if (allTestsPassed) { + cout << "============================" << endl; + cout << "ALL DISCOVERY SDK TESTS SUCCEEDED!" << endl; + cout << "============================" << endl; + } else { + cout << "============================" << endl; + cout << "SOME TESTS FAILED:" << endl; + for (const auto& errorMessage : errorMessages) { + cout << errorMessage << endl; + } + cout << "============================" << endl; + exit(1); + } + } else { + cout << "Discovery Test not able to connect with server..." << endl; + exit(1); + } +} + +int main(int argc, char* argv[]) { + int c; + string url = "ws://127.0.0.1:9998"; + while ((c = getopt(argc, argv, options)) != -1) { + switch (c) { + case 'u': + url = optarg; + break; + case 'h': + printf("./TestFireboltDiscovery -u ws://ip:port\n"); + exit(1); + } + } + + printf("Firebolt Discovery SDK Test\n"); + + DiscoverySDKTest::CreateFireboltInstance(url); + RunAllTests(); + DiscoverySDKTest::DestroyFireboltInstance(); + + return 0; +} \ No newline at end of file diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/build.sh b/src/sdks/discovery/src/cpp/sdk/cpptest/build.sh new file mode 100644 index 000000000..4db39cbe8 --- /dev/null +++ b/src/sdks/discovery/src/cpp/sdk/cpptest/build.sh @@ -0,0 +1,40 @@ +#!/bin/bash +usage() +{ + echo "options:" + echo " -t test path" + echo " -s sysroot path" + echo " -f firebolt path" + echo " -c clear build" + echo " -h : help" + echo + echo "usage: " + echo " ./build.sh -t testpath -c -f fireboltpath -s sysrootpath" +} + +TestPath="." +FireboltPath=${FIREBOLT_PATH} +SysrootPath=${SYSROOT_PATH} +ClearBuild="N" +while getopts t:s:f:ch flag +do + case "${flag}" in + t) TestPath="${OPTARG}";; + s) SysrootPath="${OPTARG}";; + f) FireboltPath="${OPTARG}";; + c) ClearBuild="Y";; + h) usage && exit 1;; + esac +done + +if [ "${ClearBuild}" == "Y" ]; +then + rm -rf ${TestPath}/build +fi + +echo "TestPath" +echo "${TestPath}" +echo "FireboltPath" +echo ${FireboltPath} +cmake -B${TestPath}/build -S${TestPath} -DSYSROOT_PATH=${SysrootPath} -DFIREBOLT_PATH=${FireboltPath} +cmake --build ${TestPath}/build diff --git a/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.cpp b/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.cpp new file mode 100644 index 000000000..1b174038b --- /dev/null +++ b/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.cpp @@ -0,0 +1,380 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "${info.title.lowercase}_impl.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.providers} +/* ${PROVIDERS} */${end.if.providers} + + // Methods + /* requestUserInterest - Provide information about the entity currently displayed or selected on the screen. */ + InterestResult ContentImpl::requestUserInterest( const Discovery::InterestType& type, const Discovery::InterestReason& reason, Firebolt::Error *err ) + { + Firebolt::Error status = Firebolt::Error::NotConnected; + InterestResult interest; + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + JsonObject jsonParameters; + Firebolt::Discovery::JsonData_InterestType jsonType = type; + WPEFramework::Core::JSON::Variant typeVariant(jsonType.Data()); + jsonParameters.Set(_T("type"), typeVariant); + Firebolt::Discovery::JsonData_InterestReason jsonReason = reason; + WPEFramework::Core::JSON::Variant reasonVariant(jsonReason.Data()); + jsonParameters.Set(_T("reason"), reasonVariant); + JsonData_InterestResult jsonResult; + status = transport->Invoke("content.requestUserInterest", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Content.requestUserInterest is successfully invoked"); + InterestResult interestResult; + interestResult.appId = jsonResult.AppId.Value(); + { + string identifiersStr; + jsonResult.Entity.Identifiers.ToString(identifiersStr); + interestResult.entity.identifiers = identifiersStr; + if (jsonResult.Entity.Info.IsSet()) { + interestResult.entity.info = std::make_optional(); + if (jsonResult.Entity.Info.Title.IsSet()) { + interestResult.entity.info.value().title = jsonResult.Entity.Info.Title; + } + if (jsonResult.Entity.Info.Synopsis.IsSet()) { + interestResult.entity.info.value().synopsis = jsonResult.Entity.Info.Synopsis; + } + if (jsonResult.Entity.Info.SeasonNumber.IsSet()) { + interestResult.entity.info.value().seasonNumber = jsonResult.Entity.Info.SeasonNumber; + } + if (jsonResult.Entity.Info.SeasonCount.IsSet()) { + interestResult.entity.info.value().seasonCount = jsonResult.Entity.Info.SeasonCount; + } + if (jsonResult.Entity.Info.EpisodeNumber.IsSet()) { + interestResult.entity.info.value().episodeNumber = jsonResult.Entity.Info.EpisodeNumber; + } + if (jsonResult.Entity.Info.EpisodeCount.IsSet()) { + interestResult.entity.info.value().episodeCount = jsonResult.Entity.Info.EpisodeCount; + } + if (jsonResult.Entity.Info.ReleaseDate.IsSet()) { + interestResult.entity.info.value().releaseDate = jsonResult.Entity.Info.ReleaseDate; + } + if (jsonResult.Entity.Info.ContentRatings.IsSet()) { + interestResult.entity.info.value().contentRatings = std::make_optional>(); + auto index(jsonResult.Entity.Info.ContentRatings.Elements()); + while (index.Next() == true) { + Entertainment::ContentRating contentRatingsResult1; + Firebolt::Entertainment::JsonData_ContentRating jsonResult = index.Current(); + { + contentRatingsResult1.scheme = jsonResult.Scheme; + contentRatingsResult1.rating = jsonResult.Rating; + if (jsonResult.Advisories.IsSet()) { + contentRatingsResult1.advisories = std::make_optional>(); + auto index(jsonResult.Advisories.Elements()); + while (index.Next() == true) { + contentRatingsResult1.advisories.value().push_back(index.Current().Value()); + } + } + } + interestResult.entity.info.value().contentRatings->push_back(contentRatingsResult1); + } + } + } + if (jsonResult.Entity.WaysToWatch.IsSet()) { + interestResult.entity.waysToWatch = std::make_optional>(); + auto index(jsonResult.Entity.WaysToWatch.Elements()); + while (index.Next() == true) { + Entertainment::WayToWatch waysToWatchResult1; + Firebolt::Entertainment::JsonData_WayToWatch jsonResult = index.Current(); + { + { + if (jsonResult.Identifiers.AssetId.IsSet()) { + waysToWatchResult1.identifiers.assetId = jsonResult.Identifiers.AssetId; + } + if (jsonResult.Identifiers.EntityId.IsSet()) { + waysToWatchResult1.identifiers.entityId = jsonResult.Identifiers.EntityId; + } + if (jsonResult.Identifiers.SeasonId.IsSet()) { + waysToWatchResult1.identifiers.seasonId = jsonResult.Identifiers.SeasonId; + } + if (jsonResult.Identifiers.SeriesId.IsSet()) { + waysToWatchResult1.identifiers.seriesId = jsonResult.Identifiers.SeriesId; + } + if (jsonResult.Identifiers.AppContentData.IsSet()) { + waysToWatchResult1.identifiers.appContentData = jsonResult.Identifiers.AppContentData; + } + } + if (jsonResult.Expires.IsSet()) { + waysToWatchResult1.expires = jsonResult.Expires; + } + if (jsonResult.Entitled.IsSet()) { + waysToWatchResult1.entitled = jsonResult.Entitled; + } + if (jsonResult.EntitledExpires.IsSet()) { + waysToWatchResult1.entitledExpires = jsonResult.EntitledExpires; + } + if (jsonResult.OfferingType.IsSet()) { + waysToWatchResult1.offeringType = jsonResult.OfferingType; + } + if (jsonResult.HasAds.IsSet()) { + waysToWatchResult1.hasAds = jsonResult.HasAds; + } + if (jsonResult.Price.IsSet()) { + waysToWatchResult1.price = jsonResult.Price; + } + if (jsonResult.VideoQuality.IsSet()) { + waysToWatchResult1.videoQuality = std::make_optional>(); + auto index(jsonResult.VideoQuality.Elements()); + while (index.Next() == true) { + waysToWatchResult1.videoQuality.value().push_back(index.Current().Value()); + } + } + auto index(jsonResult.AudioProfile.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioProfile.push_back(index.Current().Value()); + } + if (jsonResult.AudioLanguages.IsSet()) { + waysToWatchResult1.audioLanguages = std::make_optional>(); + auto index(jsonResult.AudioLanguages.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioLanguages.value().push_back(index.Current().Value()); + } + } + if (jsonResult.ClosedCaptions.IsSet()) { + waysToWatchResult1.closedCaptions = std::make_optional>(); + auto index(jsonResult.ClosedCaptions.Elements()); + while (index.Next() == true) { + waysToWatchResult1.closedCaptions.value().push_back(index.Current().Value()); + } + } + if (jsonResult.Subtitles.IsSet()) { + waysToWatchResult1.subtitles = std::make_optional>(); + auto index(jsonResult.Subtitles.Elements()); + while (index.Next() == true) { + waysToWatchResult1.subtitles.value().push_back(index.Current().Value()); + } + } + if (jsonResult.AudioDescriptions.IsSet()) { + waysToWatchResult1.audioDescriptions = std::make_optional>(); + auto index(jsonResult.AudioDescriptions.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioDescriptions.value().push_back(index.Current().Value()); + } + } + } + interestResult.entity.waysToWatch->push_back(waysToWatchResult1); + } + } + } + interest = interestResult; + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + if (err != nullptr) { + *err = status; + } + + return interest; + } + + + // Events + /* onUserInterest - Provide information about the entity currently displayed or selected on the screen. */ + static void onUserInterestInnerCallback( void* notification, const void* userData, void* jsonResponse ) + { + WPEFramework::Core::ProxyType& proxyResponse = *(reinterpret_cast*>(jsonResponse)); + + ASSERT(proxyResponse.IsValid() == true); + + if (proxyResponse.IsValid() == true) { + InterestEvent interest; + + interest.appId = proxyResponse->AppId; + interest.type = proxyResponse->Type; + interest.reason = proxyResponse->Reason; + { + string identifiersStr; + (*proxyResponse).Entity.Identifiers.ToString(identifiersStr); + interest.entity.identifiers = identifiersStr; + if ((*proxyResponse).Entity.Info.IsSet()) { + interest.entity.info = std::make_optional(); + if ((*proxyResponse).Entity.Info.Title.IsSet()) { + interest.entity.info.value().title = (*proxyResponse).Entity.Info.Title; + } + if ((*proxyResponse).Entity.Info.Synopsis.IsSet()) { + interest.entity.info.value().synopsis = (*proxyResponse).Entity.Info.Synopsis; + } + if ((*proxyResponse).Entity.Info.SeasonNumber.IsSet()) { + interest.entity.info.value().seasonNumber = (*proxyResponse).Entity.Info.SeasonNumber; + } + if ((*proxyResponse).Entity.Info.SeasonCount.IsSet()) { + interest.entity.info.value().seasonCount = (*proxyResponse).Entity.Info.SeasonCount; + } + if ((*proxyResponse).Entity.Info.EpisodeNumber.IsSet()) { + interest.entity.info.value().episodeNumber = (*proxyResponse).Entity.Info.EpisodeNumber; + } + if ((*proxyResponse).Entity.Info.EpisodeCount.IsSet()) { + interest.entity.info.value().episodeCount = (*proxyResponse).Entity.Info.EpisodeCount; + } + if ((*proxyResponse).Entity.Info.ReleaseDate.IsSet()) { + interest.entity.info.value().releaseDate = (*proxyResponse).Entity.Info.ReleaseDate; + } + if ((*proxyResponse).Entity.Info.ContentRatings.IsSet()) { + interest.entity.info.value().contentRatings = std::make_optional>(); + auto index((*proxyResponse).Entity.Info.ContentRatings.Elements()); + while (index.Next() == true) { + Entertainment::ContentRating contentRatingsResult1; + Firebolt::Entertainment::JsonData_ContentRating jsonResult = index.Current(); + contentRatingsResult1.scheme = jsonResult.Scheme; + contentRatingsResult1.rating = jsonResult.Rating; + if (jsonResult.Advisories.IsSet()) { + contentRatingsResult1.advisories = std::make_optional>(); + auto index(jsonResult.Advisories.Elements()); + while (index.Next() == true) { + contentRatingsResult1.advisories.value().push_back(index.Current().Value()); + } + } + interest.entity.info.value().contentRatings.value().push_back(contentRatingsResult1); + } + } + } + if ((*proxyResponse).Entity.WaysToWatch.IsSet()) { + interest.entity.waysToWatch = std::make_optional>(); + auto index((*proxyResponse).Entity.WaysToWatch.Elements()); + while (index.Next() == true) { + Entertainment::WayToWatch waysToWatchResult1; + Firebolt::Entertainment::JsonData_WayToWatch jsonResult = index.Current(); + { + if (jsonResult.Identifiers.AssetId.IsSet()) { + waysToWatchResult1.identifiers.assetId = jsonResult.Identifiers.AssetId; + } + if (jsonResult.Identifiers.EntityId.IsSet()) { + waysToWatchResult1.identifiers.entityId = jsonResult.Identifiers.EntityId; + } + if (jsonResult.Identifiers.SeasonId.IsSet()) { + waysToWatchResult1.identifiers.seasonId = jsonResult.Identifiers.SeasonId; + } + if (jsonResult.Identifiers.SeriesId.IsSet()) { + waysToWatchResult1.identifiers.seriesId = jsonResult.Identifiers.SeriesId; + } + if (jsonResult.Identifiers.AppContentData.IsSet()) { + waysToWatchResult1.identifiers.appContentData = jsonResult.Identifiers.AppContentData; + } + } + if (jsonResult.Expires.IsSet()) { + waysToWatchResult1.expires = jsonResult.Expires; + } + if (jsonResult.Entitled.IsSet()) { + waysToWatchResult1.entitled = jsonResult.Entitled; + } + if (jsonResult.EntitledExpires.IsSet()) { + waysToWatchResult1.entitledExpires = jsonResult.EntitledExpires; + } + if (jsonResult.OfferingType.IsSet()) { + waysToWatchResult1.offeringType = jsonResult.OfferingType; + } + if (jsonResult.HasAds.IsSet()) { + waysToWatchResult1.hasAds = jsonResult.HasAds; + } + if (jsonResult.Price.IsSet()) { + waysToWatchResult1.price = jsonResult.Price; + } + if (jsonResult.VideoQuality.IsSet()) { + waysToWatchResult1.videoQuality = std::make_optional>(); + auto index(jsonResult.VideoQuality.Elements()); + while (index.Next() == true) { + waysToWatchResult1.videoQuality.value().push_back(index.Current().Value()); + } + } + auto index(jsonResult.AudioProfile.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioProfile.push_back(index.Current().Value()); + } + if (jsonResult.AudioLanguages.IsSet()) { + waysToWatchResult1.audioLanguages = std::make_optional>(); + auto index(jsonResult.AudioLanguages.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioLanguages.value().push_back(index.Current().Value()); + } + } + if (jsonResult.ClosedCaptions.IsSet()) { + waysToWatchResult1.closedCaptions = std::make_optional>(); + auto index(jsonResult.ClosedCaptions.Elements()); + while (index.Next() == true) { + waysToWatchResult1.closedCaptions.value().push_back(index.Current().Value()); + } + } + if (jsonResult.Subtitles.IsSet()) { + waysToWatchResult1.subtitles = std::make_optional>(); + auto index(jsonResult.Subtitles.Elements()); + while (index.Next() == true) { + waysToWatchResult1.subtitles.value().push_back(index.Current().Value()); + } + } + if (jsonResult.AudioDescriptions.IsSet()) { + waysToWatchResult1.audioDescriptions = std::make_optional>(); + auto index(jsonResult.AudioDescriptions.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioDescriptions.value().push_back(index.Current().Value()); + } + } + interest.entity.waysToWatch.value().push_back(waysToWatchResult1); + } + } + } + + proxyResponse.Release(); + + IContent::IOnUserInterestNotification& notifier = *(reinterpret_cast(notification)); + notifier.onUserInterest(interest); + } + } + void ContentImpl::subscribe( IContent::IOnUserInterestNotification& notification, Firebolt::Error *err ) + { + const string eventName = _T("content.onUserInterest"); + Firebolt::Error status = Firebolt::Error::None; + + JsonObject jsonParameters; + + status = FireboltSDK::Event::Instance().Subscribe(eventName, jsonParameters, onUserInterestInnerCallback, reinterpret_cast(¬ification), nullptr); + + if (err != nullptr) { + *err = status; + } + } + void ContentImpl::unsubscribe( IContent::IOnUserInterestNotification& notification, Firebolt::Error *err ) + { + Firebolt::Error status = FireboltSDK::Event::Instance().Unsubscribe(_T("content.onUserInterest"), reinterpret_cast(¬ification)); + + if (err != nullptr) { + *err = status; + } + } + + +}//namespace ${info.Title} +}${end.if.implementations} + +${if.enums} + +namespace WPEFramework { + +/* ${ENUMS} */ +}${end.if.enums} + diff --git a/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.h b/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.h new file mode 100644 index 000000000..a01a3eb3e --- /dev/null +++ b/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.h @@ -0,0 +1,136 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "FireboltSDK.h" +#include "IModule.h" +/* ${IMPORTS} */ +#include "${info.title.lowercase}.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { + + + // Types + class JsonData_InterestResult: public WPEFramework::Core::JSON::Container { + public: + ~JsonData_InterestResult() override = default; + + public: + JsonData_InterestResult() + : WPEFramework::Core::JSON::Container() + { + Add(_T("appId"), &AppId); + Add(_T("entity"), &Entity); + } + + JsonData_InterestResult(const JsonData_InterestResult& other) + { + Add(_T("appId"), &AppId); + AppId = other.AppId; + Add(_T("entity"), &Entity); + Entity = other.Entity; + } + + JsonData_InterestResult& operator=(const JsonData_InterestResult& other) + { + Add(_T("appId"), &AppId); + AppId = other.AppId; + Add(_T("entity"), &Entity); + Entity = other.Entity; + return (*this); + } + + public: + FireboltSDK::JSON::String AppId; + Firebolt::Entity::JsonData_EntityDetails Entity; + }; + + class JsonData_InterestEvent: public WPEFramework::Core::JSON::Container { + public: + ~JsonData_InterestEvent() override = default; + + public: + JsonData_InterestEvent() + : WPEFramework::Core::JSON::Container() + { + Add(_T("appId"), &AppId); + Add(_T("type"), &Type); + Add(_T("reason"), &Reason); + Add(_T("entity"), &Entity); + } + + JsonData_InterestEvent(const JsonData_InterestEvent& other) + { + Add(_T("appId"), &AppId); + AppId = other.AppId; + Add(_T("type"), &Type); + Type = other.Type; + Add(_T("reason"), &Reason); + Reason = other.Reason; + Add(_T("entity"), &Entity); + Entity = other.Entity; + } + + JsonData_InterestEvent& operator=(const JsonData_InterestEvent& other) + { + Add(_T("appId"), &AppId); + AppId = other.AppId; + Add(_T("type"), &Type); + Type = other.Type; + Add(_T("reason"), &Reason); + Reason = other.Reason; + Add(_T("entity"), &Entity); + Entity = other.Entity; + return (*this); + } + + public: + FireboltSDK::JSON::String AppId; + Firebolt::Discovery::JsonData_InterestType Type; + Firebolt::Discovery::JsonData_InterestReason Reason; + Firebolt::Entity::JsonData_EntityDetails Entity; + }; + + class ContentImpl : public IContent, public IModule { + + public: + ContentImpl() = default; + ContentImpl(const ContentImpl&) = delete; + ContentImpl& operator=(const ContentImpl&) = delete; + + ~ContentImpl() override = default; + + // Methods & Events + // signature callback params: + // method result properties : + void subscribe( IContent::IOnUserInterestNotification& notification, Firebolt::Error *err = nullptr ) override; + void unsubscribe( IContent::IOnUserInterestNotification& notification, Firebolt::Error *err = nullptr ) override; + + /* + requestUserInterest + Provide information about the entity currently displayed or selected on the screen. + */ + InterestResult requestUserInterest( const Discovery::InterestType& type, const Discovery::InterestReason& reason, Firebolt::Error *err = nullptr ) override; + + }; + +}//namespace ${info.Title} +}${end.if.implementations} diff --git a/src/sdks/discovery/src/js/sdk/index.mjs b/src/sdks/discovery/src/js/sdk/index.mjs new file mode 100644 index 000000000..a9f2f5ca6 --- /dev/null +++ b/src/sdks/discovery/src/js/sdk/index.mjs @@ -0,0 +1,30 @@ +/* + * Copyright 2021 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +import { setMockResponses } from './Transport/MockTransport.mjs' + +/* ${MOCK_IMPORTS} */ + +setMockResponses({ + /* ${MOCK_OBJECTS} */ +}) + +/* ${EXPORTS} */ +export { default as Log } from './Log/index.mjs' +export { default as Events } from './Events/index.mjs' +export { default as Settings } from './Settings/index.mjs' diff --git a/src/sdks/discovery/test/suite/content.test.ts b/src/sdks/discovery/test/suite/content.test.ts new file mode 100644 index 000000000..1ab4e98c8 --- /dev/null +++ b/src/sdks/discovery/test/suite/content.test.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2021 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +import { test, expect } from "@jest/globals"; +import { Content } from "../../build/javascript/src/firebolt-discovery"; + +test("Content.requestUserInterest()", () => { + return Content.requestUserInterest(Content.InterestType.INTEREST, Content.InterestReason.PLAYLIST).then((interest: Content.InterestResult) => { + const entity = interest.entity + const appId = interest.appId + expect(appId).toBeDefined() + expect(entity).toBeDefined() + expect(entity.info.title).toBe("Cool Runnings") + }) +}); + +test("Content.onUserInterest()", () => { + return Content.listen('userInterest', (interest: Content.InterestEvent) => { + const entity = interest.entity + const appId = interest.appId + const reason = interest.reason + expect(interest['type']).toBeDefined() + expect(reason).toBeDefined() + expect(appId).toBeDefined() + expect(entity).toBeDefined() + expect(entity.info.title).toBe("Cool Runnings") + }) +}); diff --git a/src/sdks/discovery/tsconfig.json b/src/sdks/discovery/tsconfig.json new file mode 100644 index 000000000..56ff58bc8 --- /dev/null +++ b/src/sdks/discovery/tsconfig.json @@ -0,0 +1,5 @@ +{ + "include": [ + "test/suite/*" + ] +} \ No newline at end of file diff --git a/src/sdks/manage/CHANGELOG.md b/src/sdks/manage/CHANGELOG.md index 167fdf9b0..23aeda267 100644 --- a/src/sdks/manage/CHANGELOG.md +++ b/src/sdks/manage/CHANGELOG.md @@ -1,3 +1,5 @@ +# 1.2.0 (https://github.com/rdkcentral/firebolt-apis/compare/v1.1.0...v1.2.0) (2024-06-14) + # [1.1.0](https://github.com/rdkcentral/firebolt-apis/compare/v1.0.0...v1.1.0) (2024-02-09) ### Bug Fixes diff --git a/src/sdks/manage/package.json b/src/sdks/manage/package.json index c21e6138e..dca9b6672 100644 --- a/src/sdks/manage/package.json +++ b/src/sdks/manage/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/manage-sdk", - "version": "1.2.0-next.2", + "version": "1.3.0-next.1", "description": "The Firebolt Manage JS SDK", "main": "./dist/lib/firebolt-manage.mjs", "types": "./dist/lib/firebolt-manage.d.ts", diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp index 1a0b1df3b..4d2698dbe 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp @@ -1,397 +1,163 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + #include +#include +#include +#include +#include #include "ManageSDKTest.h" -void ShowMenu() -{ - printf("Options ---- >\n" - "\tA : Get/Set Advertising skipRestriction\n" - "\tT : Set Account Session\n" - "\tE : Get/Set/Subscribe/Unsubscribe AudioDescriptions Enabled\n" - "\tN : Get/Set/Subscribe/Unsubscribe Device Name\n" - "\tB : Get/Set/Subscribe/Unsubscribe ClosedCaption Background Opacity\n" - "\tF : Get/Set/Subscribe/Unsubscribe ClosedCaption Font Family\n" - "\tL : Get/Set/Subscribe/Unsubscribe Localization Preferred AudioLanguages\n" - "\tC : Get/Set/Subscribe/Unsubscribe Privacy Allow ACR Collection\n" - "\tS : Get Privacy Settings\n" - "\tI : Subscribe/Unsubscribe SignIn notification\n" - "\tO : Subscribe/Unsubscribe SignOut notification\n" - "\tR : Reset Advertising Identifier\n" - "\tK : Register for Keyboard Provider and check sequence\n" - "\tG : Register for Acknowledge Challenge Provider and check sequence\n" - "\tP : Register for Pin Challenge Provider and check sequence\n" - "\tD : Operate on Localization Additional Info\n" - "\tU : Grant/Deny/Clear permission on App\n" - "\tW : Scan Wifi on device\n" - "\tQ : Quit\n\n" - ); -} - -void ShowWifiOperationsMenu() -{ - printf("Options \n" - "\tS : Scan access points\n" - "\tC : Connect to selected access point \n" - "\tD : Disconnect from access point \n" - "\tQ : Quit\n"); -} - -void ShowUserGrantsMenu() -{ - printf("Invoke lifecyclesession management sequence from postman \n" - "Once the permission granted/denies/cleared, please use provider + api test to validate it \n" - "Here capabilty used for the testing is hardcoded as device:model\n" - "\tG : Get Permission\n" - "\tR : Grant Permission\n" - "\tD : Deny Permission\n" - "\tC : Clear Permission\n" - "\tQ : Quit\n"); -} - -void ShowAdditionalInfoMenu() -{ - printf("Options \n" - "\tG : Get Additional Info\n" - "\tA : Add Additional Info\n" - "\tR : Remove Additional Info\n" - "\tQ : Quit\n"); -} - -void ShowPropertyMenu(std::string& module, std::string& property) -{ - printf("%s:%s property options \n" - "\tG : Get value\n" - "\tS : Set value\n" - "\tQ : Quit\n", module.c_str(), property.c_str()); -} - -void ShowPropertyWithEventMenu(std::string& module, std::string& property) -{ - printf("%s:%s property options \n" - "\tG : Get value\n" - "\tS : Set value\n" - "\tR : Show subscribe/unscribe event menu\n" - "\tQ : Quit\n", module.c_str(), property.c_str()); -} - -void ShowProviderMenu(std::string& module) -{ - printf("Invoke lifecyclesession management from postman and api sequence from other entity for %s and press\n" - "\tR : To Send Response\n" - "\tE : To Send Error\n" - "\tQ : Quit\n", module.c_str()); -} - -void ShowEventMenu() -{ - printf("Options \n" - "\tS : Subscribe Event\n" - "\tU : Unsubscribe Event\n" - "\tQ : Quit\n"); -} - -void HandleUserGrants() -{ - int opt; - do { - getchar(); - ShowUserGrantsMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'G': { - ManageSDKTest::GetUserGrantsPermission(); - break; - } - case 'R': { - ManageSDKTest::GrantUserGrantsPermission(); - break; - } - case 'D': { - ManageSDKTest::DenyUserGrantsPermission(); - break; - } - case 'C': { - ManageSDKTest::ClearUserGrantsPermission(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleAdditionalInfo() -{ - int opt; - do { - getchar(); - ShowAdditionalInfoMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'G': { - ManageSDKTest::GetLocalizationAdditionalInfo(); - break; - } - case 'A': { - ManageSDKTest::AddLocalizationAdditionalInfo(); - break; - } - case 'R': { - ManageSDKTest::RemoveLocalizationAdditionalInfo(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -#define VALUE(string) #string -#define TO_STRING(string) VALUE(string) - -#define HandleEventListener(Module, eventFuncName) \ -{ \ - int opt; \ - do { \ - getchar(); \ - ShowEventMenu(); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'S': { \ - ManageSDKTest::Subscribe##Module##eventFuncName(); \ - break; \ - } \ - case 'U': { \ - ManageSDKTest::Unsubscribe##Module##eventFuncName(); \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - -#define HandleProperty(Module, Property) \ -{ \ - int opt; \ - do { \ - getchar(); \ - std::string module = TO_STRING(Module); \ - std::string property = TO_STRING(Property); \ - ShowPropertyMenu(module, property); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'G': { \ - ManageSDKTest::Get##Module##Property(); \ - break; \ - } \ - case 'S': { \ - ManageSDKTest::Set##Module##Property(); \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - +using namespace std; -#define HandlePropertyWithEvent(Module, Property) \ -{ \ - int opt; \ - do { \ - getchar(); \ - std::string module = TO_STRING(Module); \ - std::string property = TO_STRING(Property); \ - ShowPropertyWithEventMenu(module, property); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'G': { \ - ManageSDKTest::Get##Module##Property(); \ - break; \ - } \ - case 'S': { \ - ManageSDKTest::Set##Module##Property(); \ - break; \ - } \ - case 'R': { \ - HandleEventListener(Module, Property##Changed) \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} +const char* options = ":hu:"; -#define HandleProviderSequence(Module) \ -{ \ - int opt; \ - do { \ - getchar(); \ - std::string module = TO_STRING(Module); \ - ShowProviderMenu(module); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'R': { \ - ManageSDKTest::SendResponseMessageTo##Module##Provider(); \ - break; \ - } \ - case 'E': { \ - ManageSDKTest::SendErrorMessageTo##Module##Provider(); \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} +void RunAllTests() { + bool allTestsPassed = true; + vector errorMessages; -void HandleWifiOperations() -{ - int opt; - do { - getchar(); - ShowWifiOperationsMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'S': { - ManageSDKTest::WifiScan(); - break; - } - case 'C': { - ManageSDKTest::WifiConnect(); - break; - } - case 'D': { - ManageSDKTest::WifiDisconnect(); // This method is not avaialble from ripple now - break; + auto runTest = [&allTestsPassed, &errorMessages](auto testFunction, const string& testName) { + try { + testFunction(); + } catch (const exception& e) { + errorMessages.push_back("Test " + testName + " failed: " + e.what()); + allTestsPassed = false; } - default: - break; + }; + + // Ensure the connection is ready before running tests + if (ManageSDKTest::WaitOnConnectionReady()) { + // Advertising methods + runTest(ManageSDKTest::GetAdvertisingSkipRestriction, "GetAdvertisingSkipRestriction"); + runTest(ManageSDKTest::SetAdvertisingSkipRestriction, "SetAdvertisingSkipRestriction"); + runTest(ManageSDKTest::ResetAdvertisingIdentifier, "ResetAdvertisingIdentifier"); + + // Account methods + runTest(ManageSDKTest::SetAccountSession, "SetAccountSession"); + + // AudioDescriptions methods + runTest(ManageSDKTest::GetAudioDescriptionsEnabled, "GetAudioDescriptionsEnabled"); + runTest(ManageSDKTest::SetAudioDescriptionsEnabled, "SetAudioDescriptionsEnabled"); + runTest(ManageSDKTest::SubscribeAudioDescriptionsEnabledChanged, "SubscribeAudioDescriptionsEnabledChanged"); + runTest(ManageSDKTest::UnsubscribeAudioDescriptionsEnabledChanged, "UnsubscribeAudioDescriptionsEnabledChanged"); + + // Device methods + runTest(ManageSDKTest::GetDeviceName, "GetDeviceName"); + runTest(ManageSDKTest::SetDeviceName, "SetDeviceName"); + runTest(ManageSDKTest::SubscribeDeviceNameChanged, "SubscribeDeviceNameChanged"); + runTest(ManageSDKTest::UnsubscribeDeviceNameChanged, "UnsubscribeDeviceNameChanged"); + + // ClosedCaptions methods + runTest(ManageSDKTest::GetClosedCaptionsBackgroundOpacity, "GetClosedCaptionsBackgroundOpacity"); + runTest(ManageSDKTest::SetClosedCaptionsBackgroundOpacity, "SetClosedCaptionsBackgroundOpacity"); + runTest(ManageSDKTest::SubscribeClosedCaptionsBackgroundOpacityChanged, "SubscribeClosedCaptionsBackgroundOpacityChanged"); + runTest(ManageSDKTest::UnsubscribeClosedCaptionsBackgroundOpacityChanged, "UnsubscribeClosedCaptionsBackgroundOpacityChanged"); + + runTest(ManageSDKTest::GetClosedCaptionsFontFamily, "GetClosedCaptionsFontFamily"); + runTest(ManageSDKTest::SetClosedCaptionsFontFamily, "SetClosedCaptionsFontFamily"); + runTest(ManageSDKTest::SubscribeClosedCaptionsFontFamilyChanged, "SubscribeClosedCaptionsFontFamilyChanged"); + runTest(ManageSDKTest::UnsubscribeClosedCaptionsFontFamilyChanged, "UnsubscribeClosedCaptionsFontFamilyChanged"); + + // Localization methods + runTest(ManageSDKTest::GetLocalizationPreferredAudioLanguages, "GetLocalizationPreferredAudioLanguages"); + runTest(ManageSDKTest::SetLocalizationPreferredAudioLanguages, "SetLocalizationPreferredAudioLanguages"); + runTest(ManageSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged, "SubscribeLocalizationPreferredAudioLanguagesChanged"); + runTest(ManageSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged, "UnsubscribeLocalizationPreferredAudioLanguagesChanged"); + + runTest(ManageSDKTest::GetLocalizationAdditionalInfo, "GetLocalizationAdditionalInfo"); + runTest(ManageSDKTest::AddLocalizationAdditionalInfo, "AddLocalizationAdditionalInfo"); + runTest(ManageSDKTest::RemoveLocalizationAdditionalInfo, "RemoveLocalizationAdditionalInfo"); + + // Privacy methods + runTest(ManageSDKTest::GetPrivacyAllowACRCollection, "GetPrivacyAllowACRCollection"); + runTest(ManageSDKTest::SetPrivacyAllowACRCollection, "SetPrivacyAllowACRCollection"); + runTest(ManageSDKTest::SubscribePrivacyAllowACRCollectionChanged, "SubscribePrivacyAllowACRCollectionChanged"); + runTest(ManageSDKTest::UnsubscribePrivacyAllowACRCollectionChanged, "UnsubscribePrivacyAllowACRCollectionChanged"); + + runTest(ManageSDKTest::GetPrivacySettings, "GetPrivacySettings"); + + // Discovery methods + runTest(ManageSDKTest::SubscribeDiscoverySignInNotification, "SubscribeDiscoverySignInNotification"); + runTest(ManageSDKTest::UnsubscribeDiscoverySignInNotification, "UnsubscribeDiscoverySignInNotification"); + runTest(ManageSDKTest::SubscribeDiscoverySignOutNotification, "SubscribeDiscoverySignOutNotification"); + runTest(ManageSDKTest::UnsubscribeDiscoverySignOutNotification, "UnsubscribeDiscoverySignOutNotification"); + + // UserGrants methods + runTest(ManageSDKTest::GetUserGrantsPermission, "GetUserGrantsPermission"); + runTest(ManageSDKTest::GrantUserGrantsPermission, "GrantUserGrantsPermission"); + runTest(ManageSDKTest::DenyUserGrantsPermission, "DenyUserGrantsPermission"); + runTest(ManageSDKTest::ClearUserGrantsPermission, "ClearUserGrantsPermission"); + + // Wifi methods + // runTest(ManageSDKTest::WifiScan, "WifiScan"); + // runTest(ManageSDKTest::WifiConnect, "WifiConnect"); + // runTest(ManageSDKTest::WifiDisconnect, "WifiDisconnect"); + + // Provider registration + runTest(ManageSDKTest::RegisterKeyboardProvider, "RegisterKeyboardProvider"); + runTest(ManageSDKTest::SendResponseMessageToKeyboardProvider, "SendResponseMessageToKeyboardProvider"); + runTest(ManageSDKTest::SendErrorMessageToKeyboardProvider, "SendErrorMessageToKeyboardProvider"); + + runTest(ManageSDKTest::RegisterAcknowledgeChallengeProvider, "RegisterAcknowledgeChallengeProvider"); + runTest(ManageSDKTest::SendResponseMessageToAcknowledgeChallengeProvider, "SendResponseMessageToAcknowledgeChallengeProvider"); + runTest(ManageSDKTest::SendErrorMessageToAcknowledgeChallengeProvider, "SendErrorMessageToAcknowledgeChallengeProvider"); + + runTest(ManageSDKTest::RegisterPinChallengeProvider, "RegisterPinChallengeProvider"); + runTest(ManageSDKTest::SendResponseMessageToPinChallengeProvider, "SendResponseMessageToPinChallengeProvider"); + runTest(ManageSDKTest::SendErrorMessageToPinChallengeProvider, "SendErrorMessageToPinChallengeProvider"); + + if (allTestsPassed) { + cout << "============================" << endl; + cout << "ALL MANAGE SDK TESTS SUCCEEDED!" << endl; + cout << "============================" << endl; + } else { + cout << "============================" << endl; + cout << "SOME TESTS FAILED:" << endl; + for (const auto& errorMessage : errorMessages) { + cout << errorMessage << endl; + } + cout << "============================" << endl; + exit(1); } - } while (opt != 'Q'); + } else { + cout << "Manage Test not able to connect with server..." << endl; + exit(1); + } } -#define options ":hu:" -int main (int argc, char* argv[]) -{ +int main(int argc, char* argv[]) { int c; - std::string url = "ws://127.0.0.1:9998"; - while ((c = getopt (argc, argv, options)) != -1) { - switch (c) - { + string url = "ws://127.0.0.1:9998"; + while ((c = getopt(argc, argv, options)) != -1) { + switch (c) { case 'u': - url = optarg; - break; - + url = optarg; + break; case 'h': - printf("./TestFireboltManage -u ws://ip:port\n"); - exit(1); + printf("./TestFireboltManage -u ws://ip:port\n"); + exit(1); } } printf("Firebolt Manage SDK Test\n"); - ManageSDKTest::CreateFireboltInstance(url); - int option; - - if (ManageSDKTest::WaitOnConnectionReady() == true) { - do { - ShowMenu(); - printf("Enter option : "); - option = toupper(getchar()); - switch (option) { - case 'A': { - HandleProperty(Advertising, SkipRestriction) - break; - } - case 'T': { - ManageSDKTest::SetAccountSession(); - break; - } - case 'E': { - HandlePropertyWithEvent(AudioDescriptions, Enabled) - break; - } - case 'N': { - HandlePropertyWithEvent(Device, Name) - break; - } - case 'B': { - HandlePropertyWithEvent(ClosedCaptions, BackgroundOpacity) - break; - } - case 'F': { - HandlePropertyWithEvent(ClosedCaptions, FontFamily) - break; - } - case 'L': { - HandlePropertyWithEvent(Localization, PreferredAudioLanguages) - break; - } - case 'C': { - HandlePropertyWithEvent(Privacy, AllowACRCollection) - break; - } - case 'S': { - ManageSDKTest::GetPrivacySettings(); - break; - } - case 'I': { - HandleEventListener(Discovery, SignInNotification) - break; - } - case 'O': { - HandleEventListener(Discovery, SignOutNotification) - break; - } - case 'R': { - ManageSDKTest::ResetAdvertisingIdentifier(); - break; - } - case 'K': { - ManageSDKTest::RegisterKeyboardProvider(); - HandleProviderSequence(Keyboard) - break; - } - case 'G': { - ManageSDKTest::RegisterAcknowledgeChallengeProvider(); - HandleProviderSequence(AcknowledgeChallenge) - break; - } - case 'P': { - ManageSDKTest::RegisterPinChallengeProvider(); - HandleProviderSequence(PinChallenge) - break; - } - case 'D': { - HandleAdditionalInfo(); - break; - } - case 'U': { - HandleUserGrants(); - break; - } - case 'W': { - HandleWifiOperations(); - break; - } - default: - break; - } - getchar(); // Skip white space - } while (option != 'Q'); - - } else { - printf("Manage Test not able to connect with server.... \n"); - } + ManageSDKTest::CreateFireboltInstance(url); + RunAllTests(); ManageSDKTest::DestroyFireboltInstance(); return 0; diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp index 47c128ab4..f8a388724 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp @@ -18,6 +18,7 @@ #include #include +#include #include "ManageSDKTest.h" using namespace std; @@ -105,6 +106,7 @@ EnumMap skipRestrictionMap = { { Firebolt::Advertising::SkipRestriction::ADS_UNWATCHED, "adsUnwatched" }, { Firebolt::Advertising::SkipRestriction::ADS_ALL, "adsAll" }, { Firebolt::Advertising::SkipRestriction::ALL, "all" }}; + void ManageSDKTest::GetAdvertisingSkipRestriction() { Firebolt::Error error = Firebolt::Error::None; @@ -112,9 +114,11 @@ void ManageSDKTest::GetAdvertisingSkipRestriction() if (error == Firebolt::Error::None) { cout << "Get Advertising SkipRestriction is success : " << ConvertFromEnum(skipRestrictionMap, skipRestriction) << endl; } else { - cout << "Get Advertising SkipRestriction status: " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAdvertisingSkipRestriction failed. " + errorMessage); } } + void ManageSDKTest::SetAdvertisingSkipRestriction() { Firebolt::Error error = Firebolt::Error::None; @@ -122,17 +126,18 @@ void ManageSDKTest::SetAdvertisingSkipRestriction() for (auto skipRestriction : skipRestrictionMap) { cout << skipRestriction.second << endl; } - std::string skipRestriction; - cout << "Enter new skipRestriction : "; - cin >> skipRestriction; + + std::string skipRestriction = "none"; Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().setSkipRestriction(ConvertToEnum(skipRestrictionMap, skipRestriction), &error); if (error == Firebolt::Error::None) { cout << "Set Advertising SkipRestriction is success " << endl; } else { - cout << "Set Advertising SkipRestriction status: " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetAdvertisingSkipRestriction failed. " + errorMessage); } } + void ManageSDKTest::ResetAdvertisingIdentifier() { Firebolt::Error error = Firebolt::Error::None; @@ -140,7 +145,8 @@ void ManageSDKTest::ResetAdvertisingIdentifier() if (error == Firebolt::Error::None) { cout << "Set Advertising Reset Identifier is success " << endl; } else { - cout << "Set Advertising Reset Identifier status: " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("ResetAdvertisingIdentifier failed. " + errorMessage); } } @@ -153,7 +159,8 @@ void ManageSDKTest::SetAccountSession() if (error == Firebolt::Error::None) { cout << "Set Account Session is success" << endl; } else { - cout << "Set Account Session status : " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetAccountSession failed. " + errorMessage); } } @@ -164,27 +171,29 @@ void ManageSDKTest::GetAudioDescriptionsEnabled() if (error == Firebolt::Error::None) { cout << "Get AudioDescriptions Enabled: " << (enabled ? "true" : "false") << endl; } else { - cout << "Get AudioDescriptions Enabled status: " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAudioDescriptionsEnabled failed. " + errorMessage); } } + void ManageSDKTest::SetAudioDescriptionsEnabled() { Firebolt::Error error = Firebolt::Error::None; - std::string strEnabled; - cout << "Enter enabled or not (true/false): "; - cin >> strEnabled; - bool enabled = strEnabled == "true" ? true : false; + bool enabled = true; Firebolt::IFireboltAccessor::Instance().AudioDescriptionsInterface().setEnabled(enabled, &error); if (error == Firebolt::Error::None) { cout << "Set AudioDescriptions Enabled: " << endl; } else { - cout << "Set AudioDescriptions Enabled status: " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetAudioDescriptionsEnabled failed. " + errorMessage); } } -void ManageSDKTest::OnAudioDescriptionsEnabledChangedNotification::onEnabledChanged( const bool enabled ) + +void ManageSDKTest::OnAudioDescriptionsEnabledChangedNotification::onEnabledChanged(const bool enabled) { cout << "AudioDescriptions Enabled changed, new value --> " << (enabled ? "true" : "false") << endl; } + void ManageSDKTest::SubscribeAudioDescriptionsEnabledChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -192,9 +201,11 @@ void ManageSDKTest::SubscribeAudioDescriptionsEnabledChanged() if (error == Firebolt::Error::None) { cout << "Subscribe AudioDescriptions EnabledChange is success" << endl; } else { - cout << "Subscribe AudioDescriptions EnabledChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeAudioDescriptionsEnabledChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeAudioDescriptionsEnabledChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -202,7 +213,8 @@ void ManageSDKTest::UnsubscribeAudioDescriptionsEnabledChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe AudioDescriptions EnabledChange is success" << endl; } else { - cout << "Unsubscribe AudioDescriptions EnabledChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeAudioDescriptionsEnabledChanged failed. " + errorMessage); } } @@ -214,29 +226,30 @@ void ManageSDKTest::GetDeviceName() if (error == Firebolt::Error::None) { cout << "Get Device Name = " << name.c_str() << endl; } else { - cout << "Get Device Name status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceName failed. " + errorMessage); } } + void ManageSDKTest::SetDeviceName() { Firebolt::Error error = Firebolt::Error::None; - std::string name; - cout << "Enter new device name :"; - getchar(); - getline(cin, name); + std::string name = "Kitchen"; Firebolt::IFireboltAccessor::Instance().DeviceInterface().setName(name, &error); if (error == Firebolt::Error::None) { - cout << "Set Device Name is success" << endl; + cout << "Set Device Name to " << name << " is success" << endl; } else { - cout << "Set Device Name status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetDeviceName failed. " + errorMessage); } - cin.putback('\n'); } -void ManageSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged( const std::string& name ) + +void ManageSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged(const std::string& name) { cout << "Name changed, new name --> " << name << endl; } + void ManageSDKTest::SubscribeDeviceNameChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -244,9 +257,11 @@ void ManageSDKTest::SubscribeDeviceNameChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Device NameChange is success" << endl; } else { - cout << "Subscribe Device NameChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDeviceNameChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeDeviceNameChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -254,7 +269,8 @@ void ManageSDKTest::UnsubscribeDeviceNameChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Device NameChange is success" << endl; } else { - cout << "Unsubscribe Device NameChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDeviceNameChanged failed. " + errorMessage); } } @@ -266,28 +282,31 @@ void ManageSDKTest::GetClosedCaptionsBackgroundOpacity() if (error == Firebolt::Error::None) { cout << "Get ClosedCaption BackgroundOpacity = " << value << endl; } else { - cout << "Get ClosedCaption BackgroundOpacity status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetClosedCaptionsBackgroundOpacity failed. " + errorMessage); } } + void ManageSDKTest::SetClosedCaptionsBackgroundOpacity() { Firebolt::Error error = Firebolt::Error::None; - uint32_t bgOpacity; - cout << "Enter new background opacity: "; - scanf("%d", &bgOpacity); + uint32_t bgOpacity = 1; Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setBackgroundOpacity(bgOpacity, &error); if (error == Firebolt::Error::None) { - cout << "Set ClosedCaption BackgroundOpacity is success" << endl; + cout << "Set ClosedCaption BackgroundOpacity to " << bgOpacity << " is success" << endl; } else { - cout << "Set ClosedCaption BackgroundOpacity status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetClosedCaptionsBackgroundOpacity failed. " + errorMessage); } } -void ManageSDKTest::OnBackgroundOpacityChangedNotification::onBackgroundOpacityChanged( const float opacity ) + +void ManageSDKTest::OnBackgroundOpacityChangedNotification::onBackgroundOpacityChanged(const float opacity) { cout << "BackgroundOpacity changed, new value --> " << opacity << endl; } + void ManageSDKTest::SubscribeClosedCaptionsBackgroundOpacityChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -295,9 +314,11 @@ void ManageSDKTest::SubscribeClosedCaptionsBackgroundOpacityChanged() if (error == Firebolt::Error::None) { cout << "Subscribe ClosedCaptions BackgroundOpacityChange is success" << endl; } else { - cout << "Subscribe ClosedCaptions BackgroundOpacityChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeClosedCaptionsBackgroundOpacityChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeClosedCaptionsBackgroundOpacityChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -305,7 +326,8 @@ void ManageSDKTest::UnsubscribeClosedCaptionsBackgroundOpacityChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe ClosedCaptions BackgroundOpacityChange is success" << endl; } else { - cout << "Unsubscribe ClosedCaptions BackgroundOpacityChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeClosedCaptionsBackgroundOpacityChanged failed. " + errorMessage); } } @@ -318,6 +340,7 @@ EnumMap fontFamilyMap = { { Firebolt::Accessibility::FontFamily::CURSIVE, "Cursive" }, { Firebolt::Accessibility::FontFamily::CASUAL, "Casual" } }; + void ManageSDKTest::GetClosedCaptionsFontFamily() { Firebolt::Error error = Firebolt::Error::None; @@ -326,31 +349,30 @@ void ManageSDKTest::GetClosedCaptionsFontFamily() if (error == Firebolt::Error::None) { cout << "Get ClosedCaption FontFamily value = " << ConvertFromEnum(fontFamilyMap, value) << endl; } else { - cout << "Get ClosedCaption FontFamily status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetClosedCaptionsFontFamily failed. " + errorMessage); } } + void ManageSDKTest::SetClosedCaptionsFontFamily() { Firebolt::Error error = Firebolt::Error::None; - std::string fontFamily; - cout << "Supported font family -> " << endl; - for (auto family : fontFamilyMap) { - cout << family.second << endl; - } - cout << "Enter new font family : "; - cin >> fontFamily; + Firebolt::Accessibility::FontFamily fontFamily = Firebolt::Accessibility::FontFamily::MONOSPACED_SERIF; - Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontFamily(ConvertToEnum(fontFamilyMap, fontFamily), &error); + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontFamily(fontFamily, &error); if (error == Firebolt::Error::None) { - cout << "Set ClosedCaption FontFamily is success" << endl; + cout << "Set ClosedCaption FontFamily to MonospacedSerif is success" << endl; } else { - cout << "Set ClosedCaption FontFamily status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetClosedCaptionsFontFamily failed. " + errorMessage); } } -void ManageSDKTest::OnFontFamilyChangedNotification::onFontFamilyChanged( const Firebolt::Accessibility::FontFamily& family ) + +void ManageSDKTest::OnFontFamilyChangedNotification::onFontFamilyChanged(const Firebolt::Accessibility::FontFamily& family) { cout << "FontFamily changed, new code --> " << ConvertFromEnum(fontFamilyMap, family) << endl; } + void ManageSDKTest::SubscribeClosedCaptionsFontFamilyChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -358,9 +380,11 @@ void ManageSDKTest::SubscribeClosedCaptionsFontFamilyChanged() if (error == Firebolt::Error::None) { cout << "Subscribe ClosedCaptions FontFamilyChange is success" << endl; } else { - cout << "Subscribe ClosedCaptions FontFamilyChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeClosedCaptionsFontFamilyChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeClosedCaptionsFontFamilyChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -368,7 +392,8 @@ void ManageSDKTest::UnsubscribeClosedCaptionsFontFamilyChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe ClosedCaptions FontFamilyChange is success" << endl; } else { - cout << "Unsubscribe ClosedCaptions FontFamilyChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeClosedCaptionsFontFamilyChanged failed. " + errorMessage); } } @@ -380,49 +405,37 @@ void ManageSDKTest::GetLocalizationPreferredAudioLanguages() if (error == Firebolt::Error::None) { cout << "Get Localization PreferredAudioLanguages : " << endl; for (auto language: languages) { - cout << "----- > " < " << language << endl; } } else { - cout << "Get Localization PreferredAudioLanguages status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetLocalizationPreferredAudioLanguages failed. " + errorMessage); } } + void ManageSDKTest::SetLocalizationPreferredAudioLanguages() { Firebolt::Error error = Firebolt::Error::None; - const std::vector languages = { "ara", "jpn", "hin", "eng", "per", "dut" }; - cout << "Sample language code --> " << endl; - for (auto language : languages) { - cout << language << " "; - } - std::string language; - cout << " enter new audio language code to set : "; - getchar(); - getline(cin, language); + std::vector newLanguages = { "eng" }; - std::vector newLanguages; - string delimeter = " "; - char* token = strtok(const_cast(language.c_str()), delimeter.c_str()); - while (token != nullptr) - { - newLanguages.push_back(string(token)); - token = strtok(nullptr, delimeter.c_str()); - } Firebolt::IFireboltAccessor::Instance().LocalizationInterface().setPreferredAudioLanguages(newLanguages, &error); if (error == Firebolt::Error::None) { - cout << "Set Localization PreferredAudioLanguages is success" << endl; + cout << "Set Localization PreferredAudioLanguages to eng is success" << endl; } else { - cout << "Get Localization PreferredAudioLanguages status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetLocalizationPreferredAudioLanguages failed. " + errorMessage); } - cin.putback('\n'); } -void ManageSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged( const std::vector& languages) + +void ManageSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged(const std::vector& languages) { cout << "PreferredAudioLanguages Changed, new languages --> " << endl; for (auto language : languages) { cout << " -> " << language << endl; } } + void ManageSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -430,9 +443,11 @@ void ManageSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Localization PreferredAudioLanguagesChange is success" << endl; } else { - cout << "Subscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeLocalizationPreferredAudioLanguagesChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -440,7 +455,8 @@ void ManageSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Localization PreferredAudioLanguagesChange is success" << endl; } else { - cout << "Unsubscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeLocalizationPreferredAudioLanguagesChanged failed. " + errorMessage); } } @@ -452,28 +468,30 @@ void ManageSDKTest::GetPrivacyAllowACRCollection() if (error == Firebolt::Error::None) { cout << "Get Privacy AllowACRCollection : " << (allowACRCollection ? "true" : "false") << endl; } else { - cout << "Get Privacy AllowACRCollection status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetPrivacyAllowACRCollection failed. " + errorMessage); } } + void ManageSDKTest::SetPrivacyAllowACRCollection() { Firebolt::Error error = Firebolt::Error::None; - std::string strAllowACRCollection; - cout << "Enter new allowACRCollection (true/false): "; - cin >> strAllowACRCollection; - bool allowACRCollection = strAllowACRCollection == "true" ? true : false; - Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowACRCollection(allowACRCollection , &error); + bool allowACRCollection = false; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowACRCollection(allowACRCollection, &error); if (error == Firebolt::Error::None) { cout << "Set Privacy AllowACRCollection is success" << endl; } else { - cout << "Get Privacy AllowACRCollection status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetPrivacyAllowACRCollection failed. " + errorMessage); } } -void ManageSDKTest::OnAllowACRCollectionChangedNotification::onAllowACRCollectionChanged( const bool allowACRCollection ) + +void ManageSDKTest::OnAllowACRCollectionChangedNotification::onAllowACRCollectionChanged(const bool allowACRCollection) { cout << "AllowACRCollection Changed, new value of allowACRCollection : " << (allowACRCollection ? "true" : "false") << endl; } + void ManageSDKTest::SubscribePrivacyAllowACRCollectionChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -481,9 +499,11 @@ void ManageSDKTest::SubscribePrivacyAllowACRCollectionChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Privacy AllowACRCollectionChanged is success" << endl; } else { - cout << "Subscribe Privacy AllowACRCollectionChanged status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribePrivacyAllowACRCollectionChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribePrivacyAllowACRCollectionChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -491,9 +511,11 @@ void ManageSDKTest::UnsubscribePrivacyAllowACRCollectionChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Privacy AllowACRCollectionChanged is success" << endl; } else { - cout << "Unsubscribe Privacy AllowACRCollectionChanged status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribePrivacyAllowACRCollectionChanged failed. " + errorMessage); } } + void ManageSDKTest::GetPrivacySettings() { Firebolt::Error error = Firebolt::Error::None; @@ -514,15 +536,16 @@ void ManageSDKTest::GetPrivacySettings() cout << "\tallowUnentitledResumePoints : " << privacySettings.allowUnentitledResumePoints << endl; cout << "\tallowWatchHistory : " << privacySettings.allowWatchHistory << endl; } else { - cout << "Get Privacy Settings status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetPrivacySettings failed. " + errorMessage); } - } -void ManageSDKTest::OnSignInNotification::onSignIn( const Firebolt::Discovery::Event& event ) +void ManageSDKTest::OnSignInNotification::onSignIn(const Firebolt::Discovery::Event& event) { cout << "Discovery SignIn Event for appId --> " << event.appId << endl; } + void ManageSDKTest::SubscribeDiscoverySignInNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -530,9 +553,11 @@ void ManageSDKTest::SubscribeDiscoverySignInNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Discovery SignIn Notification is success" << endl; } else { - cout << "Subscribe Discovery SignIn Notification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDiscoverySignInNotification failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeDiscoverySignInNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -540,14 +565,16 @@ void ManageSDKTest::UnsubscribeDiscoverySignInNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Discovery SignIn Notification is success" << endl; } else { - cout << "Unsubscribe Discovery SignIn Notification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDiscoverySignInNotification failed. " + errorMessage); } } -void ManageSDKTest::OnSignOutNotification::onSignOut( const Firebolt::Discovery::Event& event ) +void ManageSDKTest::OnSignOutNotification::onSignOut(const Firebolt::Discovery::Event& event) { cout << "Discovery SignOut Event for appId --> " << event.appId << endl; } + void ManageSDKTest::SubscribeDiscoverySignOutNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -555,9 +582,11 @@ void ManageSDKTest::SubscribeDiscoverySignOutNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Discovery SignOut Notification is success" << endl; } else { - cout << "Subscribe Discovery SignOut Notification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDiscoverySignOutNotification failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeDiscoverySignOutNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -565,7 +594,8 @@ void ManageSDKTest::UnsubscribeDiscoverySignOutNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Discovery SignOut Notification is success" << endl; } else { - cout << "Unsubscribe Discovery SignOut Notification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDiscoverySignOutNotification failed. " + errorMessage); } } @@ -575,6 +605,7 @@ ManageSDKTest::KeyboardProvider::KeyboardProvider() , _keyInput(false) { } + void ManageSDKTest::KeyboardProvider::SendMessage(bool response) { if (_keyInput) { @@ -605,35 +636,42 @@ void ManageSDKTest::KeyboardProvider::SendMessage(bool response) cout << " there is no active keyboard input session " << endl; } } + void ManageSDKTest::KeyboardProvider::standard(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) { cout << "KeyboardProvider Standard is invoked" << endl; startKeyboardSession(parameters, std::move(session)); } + void ManageSDKTest::KeyboardProvider::password(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) { cout << "KeyboardProvider Password is invoked" << endl; startKeyboardSession(parameters, std::move(session)); } + void ManageSDKTest::KeyboardProvider::email(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) { cout << "KeyboardProvider Email is invoked" << endl; startKeyboardSession(parameters, std::move(session)); } -void ManageSDKTest::KeyboardProvider::startKeyboardSession( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session ) + +void ManageSDKTest::KeyboardProvider::startKeyboardSession(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) { _session = std::move(session); _parameters = parameters; _keyInput = true; } + void ManageSDKTest::RegisterKeyboardProvider() { Firebolt::IFireboltAccessor::Instance().KeyboardInterface().provide(_keyboardProvider); } + void ManageSDKTest::SendResponseMessageToKeyboardProvider() { _keyboardProvider.SendMessage(true); } + void ManageSDKTest::SendErrorMessageToKeyboardProvider() { _keyboardProvider.SendMessage(false); @@ -645,6 +683,7 @@ ManageSDKTest::AcknowledgeChallengeProvider::AcknowledgeChallengeProvider() , _challengeInput(false) { } + void ManageSDKTest::AcknowledgeChallengeProvider::SendMessage(bool response) { if (_challengeInput) { @@ -674,25 +713,30 @@ void ManageSDKTest::AcknowledgeChallengeProvider::SendMessage(bool response) cout << " there is no active acknowledge challenge input session " << endl; } } + void ManageSDKTest::AcknowledgeChallengeProvider::challenge(const Firebolt::AcknowledgeChallenge::Challenge& parameters, std::unique_ptr session) { cout << "AcknowledgeChallengeProvider challenge is invoked" << endl; startAcknowledgeChallengeSession(parameters, std::move(session)); } -void ManageSDKTest::AcknowledgeChallengeProvider::startAcknowledgeChallengeSession( const Firebolt::AcknowledgeChallenge::Challenge& parameters, std::unique_ptr session ) + +void ManageSDKTest::AcknowledgeChallengeProvider::startAcknowledgeChallengeSession(const Firebolt::AcknowledgeChallenge::Challenge& parameters, std::unique_ptr session) { _session = std::move(session); _parameters = parameters; _challengeInput = true; } + void ManageSDKTest::RegisterAcknowledgeChallengeProvider() { Firebolt::IFireboltAccessor::Instance().AcknowledgeChallengeInterface().provide(_acknowledgeChallengeProvider); } + void ManageSDKTest::SendResponseMessageToAcknowledgeChallengeProvider() { _acknowledgeChallengeProvider.SendMessage(true); } + void ManageSDKTest::SendErrorMessageToAcknowledgeChallengeProvider() { _acknowledgeChallengeProvider.SendMessage(false); @@ -704,6 +748,7 @@ ManageSDKTest::PinChallengeProvider::PinChallengeProvider() , _challengeInput(false) { } + void ManageSDKTest::PinChallengeProvider::SendMessage(bool response) { if (_challengeInput) { @@ -738,25 +783,30 @@ void ManageSDKTest::PinChallengeProvider::SendMessage(bool response) cout << " there is no active pin challenge input session " << endl; } } + void ManageSDKTest::PinChallengeProvider::challenge(const Firebolt::PinChallenge::PinChallenge& parameters, std::unique_ptr session) { cout << "PinChallengeProvider challenge is invoked" << endl; startPinChallengeSession(parameters, std::move(session)); } -void ManageSDKTest::PinChallengeProvider::startPinChallengeSession( const Firebolt::PinChallenge::PinChallenge& parameters, std::unique_ptr session ) + +void ManageSDKTest::PinChallengeProvider::startPinChallengeSession(const Firebolt::PinChallenge::PinChallenge& parameters, std::unique_ptr session) { _session = std::move(session); _parameters = parameters; _challengeInput = true; } + void ManageSDKTest::RegisterPinChallengeProvider() { Firebolt::IFireboltAccessor::Instance().PinChallengeInterface().provide(_pinChallengeProvider); } + void ManageSDKTest::SendResponseMessageToPinChallengeProvider() { _pinChallengeProvider.SendMessage(true); } + void ManageSDKTest::SendErrorMessageToPinChallengeProvider() { _pinChallengeProvider.SendMessage(false); @@ -772,59 +822,49 @@ void ManageSDKTest::GetLocalizationAdditionalInfo() cout << " " << element.first << " : " << element.second << endl; } } else { - cout << "AdditionalInfo call status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetLocalizationAdditionalInfo failed. " + errorMessage); } } + void ManageSDKTest::AddLocalizationAdditionalInfo() { Firebolt::Error error = Firebolt::Error::None; - std::string key; - cout << "Enter new key :"; - getchar(); - getline(cin, key); - std::string value; - cout << "Enter new value :"; - getline(cin, value); + std::string key = "testKey"; + std::string value = "testValue"; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().addAdditionalInfo(key, value, &error); if (error == Firebolt::Error::None) { cout << "Add AdditionalInfo is success" << endl; } else { - cout << "Add AdditionalInfo status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("AddLocalizationAdditionalInfo failed. " + errorMessage); } - - cin.putback('\n'); } + void ManageSDKTest::RemoveLocalizationAdditionalInfo() { Firebolt::Error error = Firebolt::Error::None; - std::string key; - cout << "Enter key to be removed :"; - getchar(); - getline(cin, key); + std::string key = "testKey"; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().removeAdditionalInfo(key, &error); if (error == Firebolt::Error::None) { cout << "Remove AdditionalInfo is success" << endl; } else { - cout << "Remove AdditionalInfo status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("RemoveLocalizationAdditionalInfo failed. " + errorMessage); } - - cin.putback('\n'); } void ManageSDKTest::GetUserGrantsPermission() { Firebolt::Error error = Firebolt::Error::None; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "certApp"; std::vector grantInfo = Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().app(appId, &error); if (error == Firebolt::Error::None) { cout << "Get UserGrants Permission is success" << endl; - if (grantInfo.size() > 0) { + if (grantInfo.size() > 0) { cout << "Grant Permission list : " << endl; for (auto info : grantInfo) { cout << "GrantState : " << static_cast(info.state) << endl; @@ -832,69 +872,59 @@ void ManageSDKTest::GetUserGrantsPermission() cout << "Role : " << static_cast(info.role) << endl; cout << "Lifespan : " << static_cast(info.lifespan) << endl; } - } + } } else { - cout << "Get UserGrants Permission status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetUserGrantsPermission failed. " + errorMessage); } - - cin.putback('\n'); } + void ManageSDKTest::GrantUserGrantsPermission() { Firebolt::Error error = Firebolt::Error::None; Firebolt::UserGrants::GrantModificationOptions grantModificationOptions; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "certApp"; grantModificationOptions.appId = std::make_optional(appId); Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().grant(Firebolt::Capabilities::Role::USE, "xrn:firebolt:capability:device:model", grantModificationOptions, &error); if (error == Firebolt::Error::None) { cout << "Grant UserGrants Permission is success" << endl; } else { - cout << "Grant UserGrants Permission status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GrantUserGrantsPermission failed. " + errorMessage); } - - cin.putback('\n'); } + void ManageSDKTest::DenyUserGrantsPermission() { Firebolt::Error error = Firebolt::Error::None; Firebolt::UserGrants::GrantModificationOptions grantModificationOptions; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "certApp"; grantModificationOptions.appId = std::make_optional(appId); Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().deny(Firebolt::Capabilities::Role::USE, "xrn:firebolt:capability:device:model", grantModificationOptions, &error); if (error == Firebolt::Error::None) { cout << "Deny UserGrants Permission is success" << endl; } else { - cout << "Deny UserGrants Permission status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DenyUserGrantsPermission failed. " + errorMessage); } - - cin.putback('\n'); } + void ManageSDKTest::ClearUserGrantsPermission() { Firebolt::Error error = Firebolt::Error::None; Firebolt::UserGrants::GrantModificationOptions grantModificationOptions; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "certApp"; grantModificationOptions.appId = std::make_optional(appId); Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().clear(Firebolt::Capabilities::Role::USE, "xrn:firebolt:capability:device:model", grantModificationOptions, &error); if (error == Firebolt::Error::None) { cout << "Clear UserGrants Permission is success" << endl; } else { - cout << "Clear UserGrants Permission status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("ClearUserGrantsPermission failed. " + errorMessage); } - - cin.putback('\n'); } void PrintAP(const Firebolt::Wifi::AccessPoint ap) @@ -912,6 +942,7 @@ void PrintAP(const Firebolt::Wifi::AccessPoint ap) cout << " Frequency : " << ap.frequency.value() << endl; } } + void PrintAPList(const Firebolt::Wifi::AccessPointList& apList) { if (apList.list.has_value()) { @@ -927,18 +958,21 @@ void PrintAPList(const Firebolt::Wifi::AccessPointList& apList) cout << "empty list " << endl; } } + void ManageSDKTest::WifiScan() { Firebolt::Error error = Firebolt::Error::None; - int32_t timeout = -1; + int32_t timeout = 1; _apList = Firebolt::IFireboltAccessor::Instance().WifiInterface().scan(timeout, &error); if (error == Firebolt::Error::None) { cout << "Wifi Scan is success, "; PrintAPList(_apList); } else { - cout << "Wifi Scan status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("WifiScan failed. " + errorMessage); } } + void ManageSDKTest::WifiConnect() { Firebolt::Error error = Firebolt::Error::None; @@ -961,12 +995,14 @@ void ManageSDKTest::WifiConnect() cout << "Wifi Connect is success, "; PrintAP(connectedAP); } else { - cout << "Wifi Connect status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("WifiConnect failed. " + errorMessage); } } else { cout << "Empty AP list, please initiate scan before trying connect " << endl; } } + void ManageSDKTest::WifiDisconnect() { Firebolt::Error error = Firebolt::Error::None; @@ -974,6 +1010,7 @@ void ManageSDKTest::WifiDisconnect() if (error == Firebolt::Error::None) { cout << "Wifi Disconnect is success, "; } else { - cout << "Wifi Disconnect status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("WifiDisconnect failed. " + errorMessage); } } diff --git a/src/sdks/manage/test/suite/keyboard.test.ts b/src/sdks/manage/test/suite/keyboard.test.ts index c40b7d40e..6ee3a5aed 100644 --- a/src/sdks/manage/test/suite/keyboard.test.ts +++ b/src/sdks/manage/test/suite/keyboard.test.ts @@ -82,19 +82,19 @@ class DelegatingKBProvider implements Keyboard.KeyboardInputProvider { standard( parameters: Keyboard.KeyboardParameters, session: Keyboard.FocusableProviderSession - ): Promise { + ): Promise { return this.delegate.standard(parameters, session) } password( parameters: Keyboard.KeyboardParameters, session: Keyboard.FocusableProviderSession - ): Promise { + ): Promise { return this.delegate.password(parameters, session) } email( parameters: Keyboard.KeyboardParameters, session: Keyboard.FocusableProviderSession - ): Promise { + ): Promise { return this.delegate.email(parameters, session) } } @@ -103,21 +103,19 @@ class KBProvider implements Keyboard.KeyboardInputProvider { standard( parameters: Keyboard.KeyboardParameters, session: Keyboard.FocusableProviderSession - ): Promise { - return Promise.resolve({ - text: 'foo' - }); + ): Promise { + return Promise.resolve('foo'); } password( parameters: Keyboard.KeyboardParameters, session: Keyboard.FocusableProviderSession - ): Promise { + ): Promise { return Promise.resolve(null); } email( parameters: Keyboard.KeyboardParameters, session: Keyboard.FocusableProviderSession - ): Promise { + ): Promise { return Promise.resolve(null); } } @@ -126,19 +124,19 @@ class KBProviderWithError implements Keyboard.KeyboardInputProvider { async standard( parameters: Keyboard.KeyboardParameters, session: Keyboard.FocusableProviderSession - ): Promise { + ): Promise { throw new Error('failed') } async password( parameters: Keyboard.KeyboardParameters, session: Keyboard.FocusableProviderSession - ): Promise { + ): Promise { throw new Error('failed') } async email( parameters: Keyboard.KeyboardParameters, session: Keyboard.FocusableProviderSession - ): Promise { + ): Promise { throw new Error('failed') } } @@ -156,7 +154,7 @@ test("Keyboard.provide() declarations", async () => { let result = await promise console.log(result) expect(result.method).toStrictEqual('keyboard.standardResponse') - expect(result.params.result.text).toStrictEqual('foo') + expect(result.params.result).toStrictEqual('foo') }); test("Keyboard.provide() with blank object", () => { diff --git a/tsconfig.json b/tsconfig.json index 0e5a8d3af..014e7a98a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "include": [ "src/sdks/core/test/suite/*", - "src/sdks/manage/test/suite/*" + "src/sdks/manage/test/suite/*", + "src/sdks/discovery/test/suite/*" ] } \ No newline at end of file