Skip to content

Commit

Permalink
Dev to Master Merge 7/03 (#174)
Browse files Browse the repository at this point in the history
* FIRECERT-2025:Response format change for method calls

* FIRECERT-2025: Response format changes in callMethodHandler

* FIRECERT-2025-lifecycle and event schema migration

* FIRECERT-2025-unit test fix

* FIRECERT-2025-lint fix

* FIRECERT-2100: Added template for userinterest provider

* FIRECERT-2025-standalone changes

* FIRECERT-2025-standalone changes

* FIRECERT-2025-lint fix

* FIRECERT-2025-coverity fix

* FIRECERT-2100: Added user intreset provider

* FIRECERT-2025-test fix 1

* FIRECERT-2025-test fix 2

* FIRECERT-2025-test fix 3

* FIRECERT-2025-test fix

* FIRECERT-2025-test fix

* FIRECERT-2100: Added discovery sdk changes

* FIRECERT-2100: Invoker changes

* FIRECERT-2100: Minor changes in userInterest providers

* Minor spelling correction

* Updated SDK version

* Updated SDK version

* Updated the SDK version

* FIRECERT-2100: Changes in userInterest provider

* FIRECERT-2100: Reverted federated changes

* Ci build fix

* Updated SDK version

* Updated SDK version

* FIRECERT-2025-to merge dev

* FIRECERT-2100: Added userInterest.json

* Updated SDK version

* authentication-root-fix replaced authentication.token with authentication.root

* fix

* Updated user interest capability

* Corrected logs messages

* FIRECERT-2100: keyboard provider changes from object to string format

* FIRECERT-1789: [FCS] - Use window values for language

* Updated 1.2.0-next.4 SDK version

* Constants Import fix

* FIRECERT-2148: Sending error from provider for userinterest

* UserInterest provider timeout

* FIRECERT-2148: Added flag to register provider

* FIRECERT-2025-merge latest dev

* Provider changes

* Fix for userInterestProvider

* FIRECERT-2100: Updated SDK version to 1.2.0

* Update version to 1.2.0

* copying changes from 9779 branch (#166)

* Resolve merge conflicts

* Removed else block for register provider

---------

Co-authored-by: Kummithi Guru Eswar Sainath Reddy <kummithi.sai00@gmail.com>
Co-authored-by: Nandana-NNR <nandana.n.raj97@gmail.com>
Co-authored-by: SnehalP251 <snehal89.patil@gmail.com>
Co-authored-by: SnehalP251 <103021599+SnehalP251@users.noreply.github.com>
Co-authored-by: Abhishek urs C J <43801187+Abhishk123@users.noreply.github.com>
Co-authored-by: jbigel <111541614+jbigel@users.noreply.github.com>
Co-authored-by: Nandana-NNR <118901484+Nandana-NNR@users.noreply.github.com>
  • Loading branch information
8 people authored Jul 3, 2024
1 parent bf61096 commit e10f773
Show file tree
Hide file tree
Showing 31 changed files with 592 additions and 758 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Mode of execution implies the way in which an API is invoked. There are 2 modes
- Steps to convert into `html report`
1. Move the `json report` to root folder
2. Run the command `yarn marge filename.json -f report -o /destination_path`
3. Check the `html report` on the destination path.
3. Check the `html report` on the destination path

## Supported Report Parameters

Expand Down Expand Up @@ -154,4 +154,3 @@ The prompt is displayed when the user needs to grant/deny a particular api, or t
If user wants to grant an api, yes button is pressed, for deniel - no button, and incase if the user wants to dismiss the prompt without any action, back button is pressed.



7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"version": "1.1.0",
"version": "1.2.0",
"name": "firebolt-certification",
"description": "Reference App to demonstrate Firebolt APIs and Lifecycle",
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^9.0.9",
"@firebolt-js/manage-sdk": "1.1.0",
"@firebolt-js/sdk": "1.1.0",
"@firebolt-js/discovery-sdk": "1.2.0",
"@firebolt-js/manage-sdk": "1.2.0",
"@firebolt-js/sdk": "1.2.0",
"@lightningjs/core": "2.11.0",
"@lightningjs/sdk": "^5.0.1",
"@lightningjs/ui-components": "^2.2.2",
Expand Down
2 changes: 1 addition & 1 deletion plugins/pubsub.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ If you would like to extend the functionality of the existing PubSub client or c

Here is an overview of the functions provided by the PubSubClient class:

- `initialize()` - Initializes a WebSocket connection to the specified URL.
- `initialize()` - Initializes a WebSocket connection to the specified URL. By default, it points to 'ws://localhost:8080'.

- `publish(topic, message)` - Publishes a message to the specified topic.

Expand Down
30 changes: 25 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import lng from '@lightningjs/core';
import Menu from './Menu';
import MenuBuilder from './MenuBuilder';
import LifecycleHistory from './LifeCycleHistory';
import { Settings, Accessibility } from '@firebolt-js/sdk';
import { Settings, Accessibility, Discovery } from '@firebolt-js/sdk';
import FireboltExampleInvoker from './FireboltExampleInvoker';
import Modal from './Modal';
import PubSubCommunication from './PubSubCommunication';
Expand All @@ -31,6 +31,7 @@ import { AcknowledgeChallenge, Keyboard, PinChallenge } from '@firebolt-js/manag
import PinChallengeProviderDelegater from './providers/PinChallengeDelegater';
import KeyboardProviderDelegater from './providers/KeyboardProviderDelegater';
import AckChallengeProviderDelegater from './providers/AckChallengeDelegater';
import UserInterestDelegater from './providers/UserInterestDelegater';
const logger = require('./utils/Logger')('App.js');
import FireboltTransportInvoker from './FireboltTransportInvoker';
import { handleAsyncFunction } from './utils/Utils';
Expand Down Expand Up @@ -114,6 +115,12 @@ export default class App extends Base {
process.env.REPORTINGID = reportingId;
process.env.STANDALONE = standalone;
process.env.STANDALONE_PREFIX = standalonePrefix;
process.env.ID = 0;
process.env.REGISTERPROVIDER = true;

// Set the pubSub URL if present
process.env.PUB_SUB_URL = new URLSearchParams(window.location.search).get('pubSubUrl');

if (platform) {
process.env.PLATFORM = platform;
} else {
Expand Down Expand Up @@ -198,14 +205,18 @@ export default class App extends Base {
if (!this.appContinue) {
const systemui = new URLSearchParams(window.location.search).get('systemui');

if (systemui) {
try {
try {
if (systemui) {
AcknowledgeChallenge.provide('xrn:firebolt:capability:usergrant:acknowledgechallenge', new AckChallengeProviderDelegater(this));
Keyboard.provide('xrn:firebolt:capability:input:keyboard', new KeyboardProviderDelegater(this));
PinChallenge.provide('xrn:firebolt:capability:usergrant:pinchallenge', new PinChallengeProviderDelegater(this));
} catch (err) {
logger.error('Could not set up providers' + err, 'LoadedState');
} else {
if (process.env.REGISTERPROVIDER) {
Discovery.provide('xrn:firebolt:capability:discovery:interest', new UserInterestDelegater(this));
}
}
} catch (err) {
logger.error('Could not set up providers' + err, 'LoadedState');
}
process.env.APPOBJECT = this;
const menusBuilder = new MenuBuilder();
Expand Down Expand Up @@ -407,6 +418,15 @@ export default class App extends Base {
logger.error('No Mac Address Found in Parameter Initialization response...', 'getParameterInitializationValues');
}

if (query.params.hasOwnProperty(CONSTANTS.REGISTERPROVIDER)) {
process.env.REGISTERPROVIDER = query.params.registerprovider;
}

// Set the pubSub URL if present
if (query.params.pubSubUrl) {
process.env.PUB_SUB_URL = query.params.pubSubUrl;
}

if (query.task) {
setTimeout(() => {
const intentReader = new IntentReader();
Expand Down
125 changes: 79 additions & 46 deletions src/EventInvocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class EventHandler {
this.moduleWithEventName = moduleWithEventName;
const event = moduleWithEventName.split('.')[1];
this.eventName = this.parseEventName(event);
this.eventSchema = this.getSchema(moduleWithEventName, schemaList);
if (process.env.STANDALONE == true) {
this.eventSchema = this.getSchema(moduleWithEventName, schemaList);
}
this.initializationTime = new Date();
this.eventListener = null;
}
Expand Down Expand Up @@ -67,16 +69,27 @@ class EventHandler {
}
return schemaMap;
}

// Handle, parse and store the resolved event data from listener
handleEvent(eventData) {
const eventSchemaResponse = this.eventSchemaValidation(eventData);
const eventDataObject = {
eventName: this.eventName,
eventListenerId: this.eventListener.eventListenerId,
eventResponse: eventData,
eventSchemaResult: eventSchemaResponse,
eventTime: new Date(),
};
let eventDataObject;
if (process.env.STANDALONE == true) {
const eventSchemaResponse = this.eventSchemaValidation(eventData);
eventDataObject = {
eventName: this.eventName,
eventListenerId: this.eventListener.eventListenerId,
eventResponse: eventData,
eventSchemaResult: eventSchemaResponse,
eventTime: new Date(),
};
} else {
eventDataObject = {
eventName: this.eventName,
eventListenerId: this.eventListener.id,
eventResponse: eventData,
eventTime: new Date(),
};
}
eventHistory.push(eventDataObject);
}
// Schema validation for resolved event data
Expand Down Expand Up @@ -107,53 +120,68 @@ class EventHandler {
export class EventInvocation {
// This method accepts the message params and return the listener response and schema response
async northBoundEventHandling(message) {
let responseCode;
const eventParams = message.params;
const moduleWithEventName = eventParams.event;
const params = eventParams.params;
const [listenerResponse, uniqueListenerKey] = await this.registerEvent(moduleWithEventName, params);

const registrationResponse = {};
registrationResponse['eventName'] = moduleWithEventName;
registrationResponse['eventListenerId'] = uniqueListenerKey;
if (listenerResponse && Number.isInteger(listenerResponse) && listenerResponse > 0) {
registrationResponse['eventListenerResponse'] = {
listenerResponse: listenerResponse,
error: null,
};
// Handling not supported api to check error schema if it gives a valid response
let schemaValidationResult = {};
let schemaValidationStatus = CONSTANTS.PASS;
if (message.params.isNotSupportedApi == true) {
schemaValidationResult = errorSchemaCheck(listenerResponse, process.env.COMMUNICATION_MODE);
schemaValidationStatus = CONSTANTS.FAIL;
}
registrationResponse['eventListenerSchemaResult'] = {
status: schemaValidationStatus,
eventSchemaResult: schemaValidationResult,
};
eventHandlerMap.get(uniqueListenerKey).setEventListener(registrationResponse);
} else {
if (CONSTANTS.ERROR_LIST.includes(listenerResponse.message)) {
responseCode = CONSTANTS.STATUS_CODE[3];
registrationResponse['responseCode'] = responseCode;
}
registrationResponse['eventListenerResponse'] = { result: null, error: listenerResponse };
// In case of error, validate error against errorschema
const schemaValidationResult = errorSchemaCheck(listenerResponse, process.env.COMMUNICATION_MODE);
if (schemaValidationResult && schemaValidationResult.errors && schemaValidationResult.errors.length > 0) {
registrationResponse['eventListenerSchemaResult'] = {
status: CONSTANTS.FAIL,
eventSchemaResult: {},

if (process.env.STANDALONE == true) {
registrationResponse['eventName'] = moduleWithEventName;
registrationResponse['eventListenerId'] = uniqueListenerKey;
if (listenerResponse && Number.isInteger(listenerResponse) && listenerResponse > 0) {
registrationResponse['eventListenerResponse'] = {
listenerResponse: listenerResponse,
error: null,
};
} else {
// Handling not supported api to check error schema if it gives a valid response
let schemaValidationResult = {};
let schemaValidationStatus = CONSTANTS.PASS;
if (message.params.isNotSupportedApi == true) {
schemaValidationResult = errorSchemaCheck(listenerResponse, process.env.COMMUNICATION_MODE);
schemaValidationStatus = CONSTANTS.FAIL;
}
registrationResponse['eventListenerSchemaResult'] = {
status: CONSTANTS.PASS,
status: schemaValidationStatus,
eventSchemaResult: schemaValidationResult,
};
eventHandlerMap.get(uniqueListenerKey).setEventListener(registrationResponse);
} else {
if (CONSTANTS.ERROR_LIST.includes(listenerResponse.message)) {
const responseCode = CONSTANTS.STATUS_CODE[3];
registrationResponse['responseCode'] = responseCode;
}
registrationResponse['eventListenerResponse'] = { result: null, error: listenerResponse };
// In case of error, validate error against errorschema
const schemaValidationResult = errorSchemaCheck(listenerResponse, process.env.COMMUNICATION_MODE);
if (schemaValidationResult && schemaValidationResult.errors && schemaValidationResult.errors.length > 0) {
registrationResponse['eventListenerSchemaResult'] = {
status: CONSTANTS.FAIL,
eventSchemaResult: {},
};
} else {
registrationResponse['eventListenerSchemaResult'] = {
status: CONSTANTS.PASS,
eventSchemaResult: schemaValidationResult,
};
}
}
return registrationResponse;
} else {
registrationResponse['jsonrpc'] = '2.0';
registrationResponse['id'] = null;
if (listenerResponse && Number.isInteger(listenerResponse) && listenerResponse > 0) {
registrationResponse['id'] = listenerResponse;
registrationResponse['result'] = {
listening: true,
event: moduleWithEventName,
};
eventHandlerMap.get(uniqueListenerKey).setEventListener(registrationResponse);
} else {
registrationResponse['error'] = listenerResponse;
}
return registrationResponse;
}
return registrationResponse;
}

// This method will listen to event and capture the event response after triggering
Expand Down Expand Up @@ -298,8 +326,13 @@ export class EventInvocation {
// Return the event response object for the eventName passed as the param
getEventResponse(message) {
try {
let filteredEventDataObjectList;
const eventName = message.params.event;
const filteredEventDataObjectList = eventHistory.filter((element) => element.eventListenerId == eventName);
if (process.env.STANDALONE == true) {
filteredEventDataObjectList = eventHistory.filter((element) => element.eventListenerId == eventName);
} else {
filteredEventDataObjectList = eventHistory.filter((element) => element.eventListenerId.toString() == eventName.split('-').pop());
}
if (filteredEventDataObjectList.length) {
const eventDataObject = filteredEventDataObjectList[filteredEventDataObjectList.length - 1];
return eventDataObject;
Expand Down
8 changes: 7 additions & 1 deletion src/FireboltExampleInvoker.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
AudioDescriptions,
HDMIInput,
} from '@firebolt-js/manage-sdk';
import { Content } from '@firebolt-js/discovery-sdk';
import DiscoveryInvoker from './invokers/DiscoveryInvoker';
const discoveryInvoker = new DiscoveryInvoker();
const logger = require('./utils/Logger')('FireboltExampleInvoker.js');
Expand All @@ -48,7 +49,7 @@ const MAP = {
'discovery.purchasedContent': discoveryInvoker.purchasedContent.bind(discoveryInvoker),
'discovery.entityInfo': discoveryInvoker.entityInfo.bind(discoveryInvoker),
// 'content.purchases': discoveryInvoker.getPurchasedContent.bind(discoveryInvoker),
// 'content.entity': discoveryInvoker.getEntityInfo.bind(discoveryInvoker)
// 'content.entity': discoveryInvoker.getEntityInfo.bind(discoveryInvoker),
};

const CORE_MODULE_MAP = {
Expand Down Expand Up @@ -89,9 +90,14 @@ const MANAGE_MODULE_MAP = {
hdmiinput: HDMIInput,
};

const DISCOVERY_MODULE_MAP = {
content: Content,
};

export const MODULE_MAP = {
core: CORE_MODULE_MAP,
manage: MANAGE_MODULE_MAP,
discovery: DISCOVERY_MODULE_MAP,
};

let instance = null;
Expand Down
10 changes: 5 additions & 5 deletions src/MenuBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,18 @@ export default class MenuBuilder {
const certificationMenu = [];

const sdkMenuArray = this.constructMenuBasedOnMode(CONSTANTS.SDK);
const sdkMenuObject = this.createMenuObject(CONSTANTS.SDK, sdkMenuArray);
certificationMenu.push(sdkMenuObject);

const transportMenuArray = this.constructMenuBasedOnMode(CONSTANTS.TRANSPORT);
CONSTANTS.additionalSDKs.forEach(
function (sdkObject) {
const sdkObjectCopy = { ...sdkObject };
// dynamically construct menu items using additionalSDKs config
const menuObject = this.createSubMenuObject(sdkObjectCopy.name, ValidationView, sdkObjectCopy.name, CONSTANTS.SDK);
sdkMenuArray.push(menuObject);
transportMenuArray.push(menuObject);
}.bind(this)
);
const sdkMenuObject = this.createMenuObject(CONSTANTS.SDK, sdkMenuArray);
certificationMenu.push(sdkMenuObject);

const transportMenuArray = this.constructMenuBasedOnMode(CONSTANTS.TRANSPORT);
const transportMenuObject = this.createMenuObject(CONSTANTS.TRANSPORT, transportMenuArray);
certificationMenu.push(transportMenuObject);
return [...certificationMenu];
Expand Down
Loading

0 comments on commit e10f773

Please sign in to comment.