coh-content-db
v2.0.0-rc.16
Published
City of Heroes Content Database
Readme
coh-content-db
City of Heroes Content Database
Change Log
Installation
npm install coh-content-dbUsage
There are two ways to use this package; As a data provider, or a db consumer.
As a data provider
Data providers utilize the various -Data interfaces provided in this package to construct content bundles
that can be loaded into the db for consumption by DB consumers such as Badger.
For an example data package, see the coh-content-db-homecoming project.
Defining archetypes, zones, badges, etc.
To define content, create a new instance using the appropriate Data interface and provide values for the required fields:
///test-badge.ts
import { BadgeData } from 'coh-content-db'
export const TestBadge: BadgeData = {
key: 'test-badge',
type: 'achievement',
name: [{ value: 'Test Badge' }, { alignment: 'praetorian', value: 'My Badge for Praetorians' }],
releaseDate: '2020-03-01',
alignment: ['hero', 'praetorian'],
}Then, create a BundleData instance and load your content into the appropriate field.
import { BundleData } from 'coh-content-db'
export const MyBundle: BundleData = {
header: { name: 'My Content Bundle', version: '1.0.0', lastUpdateTime: '2025-04-21T00:00:00Z' },
badges: [TestBadge],
}Markdown and Links
Fields with long text values can typically accept Markdown format. These fields will also be typed with the tag type MarkdownString.
Within markdown, you can construct a link to a badge or zone using the special badge:// and zone:// protocol indicators that consumer apps can use to provide runtime links or tooltips.
This replaces the custom [badge:xyz] format from v1 and data packages will need to update accordingly.
To create a link, use the standard Markdown link format, with the url as following:
This is a link to the [Ghoulish](badge://ghoulish) badge.There are convenience functions also provided to construct the URI automatically that can be used as follows:
import { badgeLink, badgeUri } from 'coh-content-db'
const uri = `This is a link to the [Ghoulish](${badgeUri('ghoulish')}) badge.`
// This is a link to the [Ghoulish](badge://ghoulish) badge.
const link = `This is a link to the ${badgeLink('ghoulish')} badge.`
// This is a link to the [ghoulish](badge://ghoulish) badge.As a DB consumer
Create a new database instance from a content bundle, such as coh-content-db-homecoming:
import { CohContentDatabase } from 'coh-content-db'
import { HOMECOMING } from 'coh-content-db-homecoming'
const database = new CohContentDatabase(HOMECOMING)or from a JSON object:
import { BundleData, CohContentDatabase } from 'coh-content-db'
const response = await fetch('https://n15g.github.io/coh-content-db-homecoming/bundle.json')
const bundle = await response.json() as BundleData
const database = new CohContentDatabase(bundle)Access the content
for (const badge of db.badges) {
console.log(badge.key)
}Release
- Determine the next Semantic Release version, i.e.
2.0.0-rc.16 - Update the version and release notes in the CHANGELOG.md.
- Commit with the comment
Changelog <semver>
- Commit with the comment
npm version <semver>- Updates the package.json and commits + tags new version. Use semver syntax for version number.npm run push- Push the commit and tags to remote.- GitHub will release automatically.
Tags matching the pattern v<X>.<Y>.<Z> will attempt to publish to npm (this can only be achieved by the package manager (n15g).
The npm version command automatically prepends the v prefix to the version number.
npm version 1.4.x
npm run push