Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@azuro-org/dictionaries
Advanced tools
CLI and set of helpers to work with Azuro protocol dictionaries
The Azuro Dictionaries package is designed to provide easy access to the Azuro Protocol dictionaries, which contain mappings between IDs and human-readable strings. The package includes several CLI and helpers to make it easy to work with these dictionaries in your project.
npm install @azuro-org/dictionaries
get-dictionaries
All dictionaries are stored in a public repository on GitHub. To download them use CLI.
In your package.json
file, add the following script:
"get-dictionaries": "get-dictionaries -o {OUTPUT_DIR} -v {VERSION} -t {FILES_TYPE}"
Replace the following placeholders:
{OUTPUT_DIR}
: the directory where to store the downloaded files.{VERSION}
: the version of the dictionaries to download (use latest
for the latest version).{FILES_TYPE}
: the file format (ts
, js
, maps
or arrays
)get-outcomes
If you need to get a list of outcomeId
s related to a specific market name, you can use the get-outcomes
command.
For example:
get-outcomes --market 'Full Time Result'
This will return an array of outcomeId
s that are related to the specified market.
You can use this list to filter conditions in a GraphQL query, like this:
query Games($filterConditions: Condition_Filter!) {
games {
conditions(where: $filterConditions) {
conditionId
core {
address
}
outcomes {
outcomeId
odds
}
}
}
}
const outcomeIds = [ '29', '30', '31', '6983', '6984' ] // taken from the result of the command execution
useQuery(GAMES_QUERY, {
variables: {
filterConditions: {
outcomes_: {
outcomeId_in: outcomeIds
}
}
}
})
To use the package in your project, you can import the desired helpers from the package:
import { getMarketKey, getMarketName, getMarketDescription, getSelectionName } from '@azuro-org/dictionaries'
The package provides the following helpers:
getMarketKey
This function generates a string marketKey
from an outcomeId
. A marketKey
is a combination of other IDs, including
the marketId
, gamePeriodId
, gameTypeId
, and teamPlayerId
(if applicable). This function takes an object with
the outcomeId
and dictionaries
as properties.
getMarketKey({ outcomeId: '1', dictionaries }) // "1-1-1"
getMarketName
This function returns the human-readable name of the market related to an outcomeId
or a marketKey
. This function takes
an object with either the outcomeId
or marketKey
and dictionaries
as properties.
getMarketName({ outcomeId: '1', dictionaries }) // "Full Time Result"
getMarketName({ marketKey: '1-1-1', dictionaries }) // "Full Time Result"
getMarketDescription
This function returns the human-readable description of the market related to an outcomeId
or a marketKey
. This
function takes an object with either the outcomeId
or marketKey
and dictionaries
as properties.
getMarketDescription({ outcomeId: '1', dictionaries }) // "You predict the result..."
getMarketDescription({ marketKey: '1-1-1', dictionaries }) // "You predict the result..."
It's important to note that not all outcomeId
values have a corresponding market name or description. If the name
doesn't exist in the dictionaries, the helper function will return a concatenated string of values taken from the
marketId
, gamePeriodId
, gameTypeId
, and teamPlayerId
IDs.
In cases where there is no market name for the provided outcomeId
, the helper function will return undefined
. It's
important to keep this in mind when using these helper functions to avoid any unexpected behavior.
getMarketName({ outcomeId: '42', dictionaries }) // "Whole game - Winner of match Goal"
getMarketDescription({ outcomeId: '42', dictionaries }) // undefined
getSelectionName
This function returns the human-readable name of the selection related to an outcomeId
. This function takes an object
with the outcomeId
, dictionaries
and withPoint
(if applicable) as properties.
getSelectionName({ outcomeId: '1', dictionaries }) // "Yes"
getSelectionName({ outcomeId: '4', dictionaries }) // "Team 2"
getSelectionName({ outcomeId: '4', dictionaries, withPoint: true }) // "Team 2 (4.5)"
import { getMarketName, getSelectionName } from '@azuro-org/dictionaries'
import dictionaries from './path/to/dictionaries'
const marketKey = getMarketKey({ outcomeId: '123', dictionaries })
const marketName = getMarketName({ marketKey, dictionaries })
const selectionName = getSelectionName({ outcomeId: '123', dictionaries })
FAQs
CLI and set of helpers to work with Azuro protocol dictionaries
The npm package @azuro-org/dictionaries receives a total of 276 weekly downloads. As such, @azuro-org/dictionaries popularity was classified as not popular.
We found that @azuro-org/dictionaries demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.