Your updated Connections Settings page has the new configs you need. Now we're going to write an init sync flow to populate options for each of those configs.
A Pandium integration can be run in normal mode or init mode. The initSync flow is for the init mode.
The goal in this initSync flow is to print a standard out with data that will populate the options for our two dynamic configurations:
The Slack user to receive the Pokémon of the day message.
The type of Pokémon allowed for Pokémon of the day.
To do this we will need to:
Within src/processLogic add initSync.ts.
Now your file structure should now look like this:
You should see the same information logged as before - except that now an array of Slack members from your workspace has also been printed. This confirms the Slack client within initSync is working.
You may recall from the work on the PANDIUM.yaml that the options printed to the initSync standard out for your slack_user config should only have the properties const and title. This means the elements of the Slack members array will need to be transformed to the proper const and title format.
Run npm run build && npm run start. The logs should look something like this:
> pokemon-of-the-day@1.0.0 start
> node build/src/
This run is in mode: init
------------------------CONFIG------------------------
Config {}
------------------------CONTEXT------------------------
Context {
run_mode: 'init',
last_successful_run_std_out: '{"last_pokemon_id":247}'
}
------------------------INIT SYNC------------------------
{"slack_users":[{"const":"UCEGPFQRX","title":"Jeff"},{"const":"UCEMD4QCX","title":"Juanita"},... other Slack users fetched from your Slack workspace.]}
During the work on the PANDIUM.yaml this is exactly what we'd said needed to be printed to the init sync standard out to populate options for the slack_user config.
Now do the same for the Pokémon types!
Fetch the Pokémon types by doing the following:
The initSync.ts file should look something like this:
Run npm run build && npm run start. You should see the same information logged as before - except that there should now also be an array of Pokémon types. This confirms the PokeClient within initSync is working.
Loop through each of the Pokémon types list and add its name to a list of pokemonTypes. Then add the pokemon_types to the standard out object returned by initSync.
Run npm run build && npm run start. The logs should look something like this:
> pokemon-of-the-day@1.0.0 start
> node build/src/
This run is in mode: init
------------------------CONFIG------------------------
Config {}
------------------------CONTEXT------------------------
Context { run_mode: 'init' }
------------------------INIT SYNC------------------------
{"slack_users":[{"const":"UCEGPFQRX","title":"Jeff"},{"const":"UCEMD4QCX","title":"Juanita"},... other slack users fetched from your Slack workspace.],"pokemon_types":["normal","fighting","flying","poison","ground","rock","bug","ghost","steel","fire","water","grass","electric","psychic","ice","dragon","dark","fairy","unknown","shadow"]}
The standard out of the initSync now lists options for both the slack_user and pokemon_type configs.