rdkcentral / mock-firebolt

An advanced, controllable mock Firebolt OS implementation, which can also act as a reverse proxy to a real Firebolt OS running on a real device
Apache License 2.0
4 stars 22 forks source link

update library state to override default parameters.initialization #109

Open ferchoglober opened 1 year ago

ferchoglober commented 1 year ago

Hello you all! I'm using this awesome library some days ago, this works pretty well in some tests I did, Now I'm trying to get the data inside a navigateTo param when my app is NOT running. I'm using the firebolt Prameters module to get that data.

To do so, I'm trying to override the default mock value for parameters.initialization by uploading my parameters-initialization.json which contains the following json

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "parameters.initialization",
  "result": {
    "lmt": 0,
    "us_privacy": "1-Y-",
    "discovery": {
      "navigateTo": {
        "action": "playback",
        "context": {
            "source": "device"
        },
        "data": {
          "entityType": "program",
          "programType": "movie",
          "entityId": "my-entity-id"
        }
      }
    }
  }
}

this is the executed command node cli.mjs --upload ../examples/parameters-initialization.json

The update seems to be well since the cli says { status: 'SUCCESS' } and the server says "Updating state for default user 12345" (my app is working with the default user) but when I reload my app I'm getting the default data again and again :(

After updating the state of mock-firebolt and reloading my app I'm getting the default data:

{
  "navigateTo": {
    "action": "entity",
    "data": {
      "entityId": "abc",
      "entityType": "program",
      "programType": "movie"
    },
    "context": {
      "source": "voice"
    }
  }
}

I want mock-firebolt to get the data in my app as I defined in the library state, something like this:

{
  "navigateTo": {
    "action": "playback",
    "context": {
      "source": "device"
    },
    "data": {
      "entityType": "program",
      "programType": "movie",
      "entityId": "my-entity-id"
    }
  }
}

Could you help me please?

ferchoglober commented 1 year ago

Hey, I found a solution for this, I just used a yaml file instead json to update the mock-firebolt state, my app is working now with this

command:

node cli.mjs --upload ../examples/parameters-initialization-playback.yaml

examples/parameters-initialization-playback.yaml:

---
methods:
  parameters.initialization:
    response: |
      function f(ctx, params) {
        const result = {"discovery":{"navigateTo":{"action":"playback","data":{"entityId":"my-entity-id","entityType":"program","programType":"movie"},"context":{"source":"device"}}}};
        return result;
      }