Skip to content

Commit

Permalink
feat: Add player apis in new provider SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
kpears201 committed Sep 14, 2023
1 parent 1f41401 commit e74d213
Show file tree
Hide file tree
Showing 17 changed files with 252 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ dist/*
src/sdks/core/build/*
src/sdks/core/dist/*
src/sdks/core/test/transpiled-suite/*
src/sdks/discovery/build/*
src/sdks/discovery/dist/*
src/sdks/discovery/test/transpiled-suite/*
src/sdks/provider/build/*
src/sdks/provider/dist/*
src/sdks/provider/test/transpiled-suite/*
src/sdks/manage/build/*
src/sdks/manage/dist/*
src/sdks/manage/test/transpiled-suite/*
Expand Down
16 changes: 15 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},
"workspaces": [
"src/sdks/core",
"src/sdks/manage"
"src/sdks/manage",
"src/sdks/provider"
],
"scripts": {
"fs:setup": "npm run clean && mkdir -p dist",
Expand Down Expand Up @@ -51,12 +52,12 @@
"@semantic-release/npm": "^9.0.1",
"@semantic-release/release-notes-generator": "^10.0.1",
"ajv": "^6.12.6",
"production-changelog": "./src/js/production-changelog/",
"husky": "^8.0.0",
"jest": "^28.1.0",
"jest-environment-jsdom": "^28.1.3",
"mkdirp": "^2.1.6",
"nopt": "^7.1.0",
"production-changelog": "./src/js/production-changelog/",
"semantic-release": "^19.0.5",
"typescript": "^4.6.4"
},
Expand All @@ -66,4 +67,4 @@
"sdk"
],
"license": "Apache-2.0"
}
}
6 changes: 0 additions & 6 deletions src/sdks/manage/sdk.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,12 @@
"module": "Player",
"use": [
"xrn:firebolt:capability:player:base"
],
"provide": [
"xrn:firebolt:capability:player:base"
]
},
{
"module": "BroadcastPlayer",
"use": [
"xrn:firebolt:capability:player:broadcast"
],
"provide": [
"xrn:firebolt:capability:player:broadcast"
]
}
]
Expand Down
6 changes: 6 additions & 0 deletions src/sdks/provider/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build/*
src/*
test/*
.DS_Store
jest.config.*
tsconfig.*
Empty file added src/sdks/provider/CHANGELOG.md
Empty file.
1 change: 1 addition & 0 deletions src/sdks/provider/CONTRIBUTING.md
1 change: 1 addition & 0 deletions src/sdks/provider/LICENSE
1 change: 1 addition & 0 deletions src/sdks/provider/NOTICE
26 changes: 26 additions & 0 deletions src/sdks/provider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: Firebolt Provider SDK
---

[![semantic-release: conventional](https://img.shields.io/badge/semantic--release-conventional-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)

# Firebolt Provider SDK
For building Firebolt compliant apps that manage Firebolt devices.

## Usage
To install, run:

```
npm install @firebolt-js/provider-sdk
```

To use the package, import one of it's modules, e.g.:

```js
import { Privacy } from '@firebolt-js/provider-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.
36 changes: 36 additions & 0 deletions src/sdks/provider/Setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
if (!window.__firebolt) {
window.__firebolt = {}
}

// wires up the mock transport w/out waiting
window.__firebolt.mockTransportLayer = true

// sets a flag that mock defaults impls can use to speed things up, e.g. Lifecycle/defaults.js
window.__firebolt.automation = true

let sendListener
let receiver

export const transport = {
send: function(message) {
const json = JSON.parse(message)
sendListener && sendListener(json)
},
receive: function(callback) {
// store the callback
receiver = callback
},
onSend: function(listener) {
sendListener = listener
},
response: function(id, result) {
let response = {
jsonrpc: '2.0',
id: id,
result: result
}
receiver && receiver(JSON.stringify(response))
}
}

window.__firebolt.setTransportLayer(transport)
8 changes: 8 additions & 0 deletions src/sdks/provider/jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|js?)$",
"transform": {},
"testPathIgnorePatterns": ["<rootDir>/node_modules/", "<rootDir>/../../../test"],
"moduleFileExtensions": ["js", "jsx", "mjs"],
"verbose": true,
"testEnvironment": "jest-environment-jsdom"
}
51 changes: 51 additions & 0 deletions src/sdks/provider/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@firebolt-js/provider-sdk",
"version": "0.16.0-next.3",
"description": "The Firebolt Provider JS SDK",
"main": "./dist/lib/firebolt-provider.mjs",
"types": "./dist/lib/firebolt-provider.d.ts",
"exports": {
".": "./dist/lib/firebolt-provider.mjs"
},
"type": "module",
"scripts": {
"validate": "npx firebolt-openrpc validate --input ./dist/firebolt-provider-open-rpc.json",
"sdk": "npx firebolt-openrpc sdk --input ./dist/firebolt-provider-open-rpc.json --template ./src/js --output ./build/javascript/src",
"native": "npx firebolt-openrpc sdk --input ./dist/firebolt-provider-open-rpc.json --template ./src/js --output ./build/c/src --language ../../../node_modules/@firebolt-js/openrpc/languages/c",
"compile": "cd ../../.. && npm run compile",
"slice": "npx firebolt-openrpc slice -i ../../../dist/firebolt-open-rpc.json --sdk ./sdk.config.json -o ./dist/firebolt-provider-open-rpc.json",
"docs": "npx firebolt-openrpc docs --input ./dist/firebolt-provider-open-rpc.json --output build/docs/markdown --as-path",
"wiki": "npx firebolt-openrpc docs --input ./dist/firebolt-provider-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 dist:copy && echo 'Firebolt Provider 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-provider-open-rpc.json ../../../dist/firebolt-provider-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"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rdkcentral/firebolt-core-sdk",
"directory": "src/sdks/provider"
},
"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",
"typescript": "^4.6.4"
},
"keywords": [
"firebolt",
"apps",
"sdk"
],
"license": "Apache-2.0"
}
26 changes: 26 additions & 0 deletions src/sdks/provider/sdk.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"info": {
"title": "Firebolt Provider SDK",
"x-interface-names": {}
},
"methods": [
{
"module": "Player",
"provide": [
"xrn:firebolt:capability:player:base"
]
},
{
"module": "BroadcastPlayer",
"provide": [
"xrn:firebolt:capability:player:broadcast"
]
},
{
"module": "StreamingPlayer",
"provide": [
"xrn:firebolt:capability:player:streaming"
]
}
]
}
30 changes: 30 additions & 0 deletions src/sdks/provider/src/js/sdk/index.mjs
Original file line number Diff line number Diff line change
@@ -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'
39 changes: 39 additions & 0 deletions src/sdks/provider/test/suite/player.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 { Player } from '../../build/javascript/src/firebolt-provider'

test('Player.provideStatus()', async () => {
const resp = await Player.provideStatus('abc', {
mediaSessionId: '123',
state: 'PLAYING'
})
expect(resp).toEqual(null)
})

test('Player.provideProgress', async () => {
const resp = await Player.provideProgress('abc', {
startPosition: 0,
position: 60000,
endPosition: 3600000,
liveSyncTime: '2021-04-23T18:25:43.511Z',
speed: 1
})
expect(resp).toEqual(null)
})
5 changes: 5 additions & 0 deletions src/sdks/provider/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"include": [
"test/suite/*"
]
}

0 comments on commit e74d213

Please sign in to comment.