coh-content-db 2.0.0-rc.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build.yml +3 -1
- package/CHANGELOG.md +11 -2
- package/README.md +33 -19
- package/dist/coh-content-db.d.ts +230 -170
- package/dist/coh-content-db.js +495 -296
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +488 -294
- package/dist/coh-content-db.mjs.map +1 -1
- package/jest.config.mjs +1 -0
- package/package.json +14 -14
- package/src/main/api/badge-data.ts +13 -7
- package/src/main/api/bundle-data.ts +1 -1
- package/src/main/api/bundle-header-data.ts +13 -6
- package/src/main/api/contact-data.ts +2 -1
- package/src/main/api/level-range-data.ts +4 -0
- package/src/main/api/mission-data.ts +3 -29
- package/src/main/api/mission-flashback-data.ts +31 -0
- package/src/main/api/morality.ts +27 -9
- package/src/main/api/set-title-data.ts +4 -0
- package/src/main/api/variant-context.ts +11 -0
- package/src/main/api/{alternate-data.ts → variant-data.ts} +4 -4
- package/src/main/api/zone-data.ts +24 -0
- package/src/main/api/zone-type.ts +59 -0
- package/src/main/db/abstract-index.ts +12 -16
- package/src/main/db/badge-index.ts +53 -27
- package/src/main/db/badge-requirement.ts +1 -1
- package/src/main/db/badge-search-options.ts +15 -14
- package/src/main/db/badge.ts +46 -29
- package/src/main/db/bundle-header.ts +18 -10
- package/src/main/db/coh-content-database.ts +17 -17
- package/src/main/db/contact.ts +5 -4
- package/src/main/db/level-range.ts +15 -0
- package/src/main/db/mission.ts +11 -10
- package/src/main/db/paged.ts +7 -3
- package/src/main/db/set-title-ids.ts +10 -0
- package/src/main/db/variants.ts +84 -0
- package/src/main/db/zone.ts +29 -0
- package/src/main/index.ts +11 -4
- package/src/main/util/coalesce-to-array.ts +13 -0
- package/src/main/{util.ts → util/links.ts} +8 -22
- package/src/main/util/to-date.ts +9 -0
- package/src/test/api/alignment.test.ts +2 -2
- package/src/test/api/badge-data.fixture.ts +1 -0
- package/src/test/api/badge-data.test.ts +1 -0
- package/src/test/api/bundle-data.fixture.ts +3 -2
- package/src/test/api/bundle-header-data.fixture.ts +4 -2
- package/src/test/api/morality.test.ts +31 -0
- package/src/test/api/sex.test.ts +2 -2
- package/src/test/api/zone-data.fixture.ts +1 -0
- package/src/test/db/abstract-index.test.ts +12 -43
- package/src/test/db/badge-index.test.ts +197 -101
- package/src/test/db/badge.test.ts +122 -16
- package/src/test/db/bundle-header.test.ts +25 -12
- package/src/test/db/coh-content-database.test.ts +134 -175
- package/src/test/db/contact.test.ts +2 -1
- package/src/test/db/level-range.test.ts +47 -0
- package/src/test/db/mission.test.ts +8 -6
- package/src/test/db/morality-list.test.ts +1 -1
- package/src/test/db/set-title-ids.test.ts +19 -0
- package/src/test/db/{alternates.test.ts → variants.test.ts} +24 -24
- package/src/test/db/zone.test.ts +45 -0
- package/src/test/integration.test.ts +3 -3
- package/src/test/util/coalese-to-array.test.ts +17 -0
- package/src/test/{util.test.ts → util/links.test.ts} +5 -21
- package/src/test/util/to-date.test.ts +15 -0
- package/src/main/db/alternates.ts +0 -67
package/CHANGELOG.md
CHANGED
|
@@ -5,33 +5,42 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [2.0.0
|
|
8
|
+
## [2.0.0] - 2026-01-05
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
|
+
|
|
11
12
|
- Introduced a simple indexing and search function for badge names, text, and acquisition info.
|
|
12
13
|
- Enabled formal support for Missions and Contacts in badge requirements.
|
|
14
|
+
- Optional level range and morality to `Zone` data.
|
|
15
|
+
- Formal objects for level range and set title ids.
|
|
16
|
+
- Badges now require a `releaseDate`.
|
|
17
|
+
- Bundle header is now mandatory and requires at least a name, version and last update time.
|
|
13
18
|
- Added GitHub Actions for continuous integration (CI).
|
|
14
19
|
- Included `eslint` for linting.
|
|
15
20
|
- Added `jest` for unit testing.
|
|
16
21
|
- CHANGELOG.md
|
|
17
22
|
|
|
18
23
|
### Changed
|
|
19
|
-
|
|
24
|
+
|
|
20
25
|
- Server groups are now referred to as "forks".
|
|
21
26
|
- Enum types were replaced with union types, and values now use `kebab-case`.
|
|
22
27
|
- The `IServerGroupData` interface was renamed to `BundleData`, and databases are now scoped to a single bundle.
|
|
28
|
+
- Database instance is now immutable and bundle data is loaded in the constructor.
|
|
23
29
|
- `GameMap` was renamed to `Zone`.
|
|
24
30
|
- Badge partials are now referred to as badge requirements.
|
|
31
|
+
- `Badge.getRequirement()` now returns undefined instead of throwing an error on unknown key.
|
|
25
32
|
- Exploration badge locations were moved into the badge requirements list.
|
|
26
33
|
- References to zones and badges now use a standard Markdown link format (`badge://`, `map://`).
|
|
27
34
|
- Some field names were updated for consistent pluralization (e.g., `name`, `icon`).
|
|
28
35
|
- `VidiotMap` data was folded into `Location` data.
|
|
29
36
|
- `settitle` IDs were consolidated into a single tuple field.
|
|
30
37
|
- Bundle metadata is now found in the `BundleData.header` field.
|
|
38
|
+
- Redundant interfaces have been replaced with their concrete equivalents.
|
|
31
39
|
- The project license was changed from GNU to [The Unlicense](https://unlicense.org/).
|
|
32
40
|
- Switched the build system from Webpack to Rollup.
|
|
33
41
|
|
|
34
42
|
### Removed
|
|
43
|
+
|
|
35
44
|
- The `serverGroup` property was removed from entities to simplify the object model, since only one context is allowed per database.
|
|
36
45
|
- All third-party dependencies were removed.
|
|
37
46
|
- VidiotMap data was removed from the Zone API.
|
package/README.md
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
City of Heroes Content Database
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
----
|
|
12
|
+
|
|
13
|
+
# Changelog
|
|
12
14
|
|
|
13
15
|
[CHANGELOG.md](CHANGELOG.md)
|
|
14
16
|
|
|
@@ -18,6 +20,8 @@ City of Heroes Content Database
|
|
|
18
20
|
npm install coh-content-db
|
|
19
21
|
```
|
|
20
22
|
|
|
23
|
+
----
|
|
24
|
+
|
|
21
25
|
# Usage
|
|
22
26
|
|
|
23
27
|
There are two ways to use this package; As a data provider, or a db consumer.
|
|
@@ -37,10 +41,11 @@ To define content, create a new instance using the appropriate `Data` interface
|
|
|
37
41
|
///test-badge.ts
|
|
38
42
|
import { BadgeData } from 'coh-content-db'
|
|
39
43
|
|
|
40
|
-
export const
|
|
44
|
+
export const TestBadge: BadgeData = {
|
|
41
45
|
key: 'test-badge',
|
|
42
46
|
type: 'achievement',
|
|
43
47
|
name: [{ value: 'Test Badge' }, { alignment: 'praetorian', value: 'My Badge for Praetorians' }],
|
|
48
|
+
releaseDate: '2020-03-01',
|
|
44
49
|
alignment: ['hero', 'praetorian'],
|
|
45
50
|
}
|
|
46
51
|
```
|
|
@@ -49,11 +54,10 @@ Then, create a `BundleData` instance and load your content into the appropriate
|
|
|
49
54
|
|
|
50
55
|
```typescript
|
|
51
56
|
import { BundleData } from 'coh-content-db'
|
|
52
|
-
import { TEST_BADGE } from './test-badge'
|
|
53
57
|
|
|
54
|
-
export const
|
|
55
|
-
header: { name: 'My Content Bundle' },
|
|
56
|
-
badges: [
|
|
58
|
+
export const MyBundle: BundleData = {
|
|
59
|
+
header: { name: 'My Content Bundle', version: '1.0.0', lastUpdateTime: '2025-04-21T00:00:00Z' },
|
|
60
|
+
badges: [TestBadge],
|
|
57
61
|
}
|
|
58
62
|
```
|
|
59
63
|
|
|
@@ -83,15 +87,13 @@ const link = `This is a link to the ${badgeLink('ghoulish')} badge.`
|
|
|
83
87
|
|
|
84
88
|
## As a DB consumer
|
|
85
89
|
|
|
86
|
-
Create a new database instance
|
|
90
|
+
Create a new database instance from a content bundle, such as [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming):
|
|
87
91
|
|
|
88
92
|
```typescript
|
|
89
93
|
import { CohContentDatabase } from 'coh-content-db'
|
|
90
94
|
import { HOMECOMING } from 'coh-content-db-homecoming'
|
|
91
95
|
|
|
92
|
-
const database = new CohContentDatabase()
|
|
93
|
-
|
|
94
|
-
database.load(HOMECOMING)
|
|
96
|
+
const database = new CohContentDatabase(HOMECOMING)
|
|
95
97
|
```
|
|
96
98
|
|
|
97
99
|
or from a JSON object:
|
|
@@ -99,11 +101,10 @@ or from a JSON object:
|
|
|
99
101
|
```typescript
|
|
100
102
|
import { BundleData, CohContentDatabase } from 'coh-content-db'
|
|
101
103
|
|
|
102
|
-
const database = new CohContentDatabase()
|
|
103
|
-
|
|
104
104
|
const response = await fetch('https://n15g.github.io/coh-content-db-homecoming/bundle.json')
|
|
105
105
|
const bundle = await response.json() as BundleData
|
|
106
|
-
|
|
106
|
+
|
|
107
|
+
const database = new CohContentDatabase(bundle)
|
|
107
108
|
```
|
|
108
109
|
|
|
109
110
|
#### Access the content
|
|
@@ -114,11 +115,24 @@ for (const badge of db.badges) {
|
|
|
114
115
|
}
|
|
115
116
|
```
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
----
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
# Development
|
|
120
121
|
|
|
121
|
-
|
|
122
|
-
npm
|
|
123
|
-
npm run
|
|
124
|
-
|
|
122
|
+
* `npm run lint`
|
|
123
|
+
* `npm run test`
|
|
124
|
+
* `npm run build`
|
|
125
|
+
|
|
126
|
+
----
|
|
127
|
+
|
|
128
|
+
# Release
|
|
129
|
+
|
|
130
|
+
1. Determine the next [Semantic Release](https://semver.org) version, i.e. `2.0.0-rc.16`
|
|
131
|
+
2. Update the version and release notes in the [CHANGELOG.md](CHANGELOG.md).
|
|
132
|
+
* Commit with the comment `Changelog <semver>`
|
|
133
|
+
3. `npm version <semver>` - Updates the package.json and commits + tags new version. Use semver syntax for version number.
|
|
134
|
+
4. `npm run push` - Push the commit and tags to remote.
|
|
135
|
+
5. GitHub will release automatically.
|
|
136
|
+
|
|
137
|
+
Tags matching the pattern `v<X>.<Y>.<Z>` will attempt to publish to npm (this can only be achieved by the package manager (n15g).
|
|
138
|
+
The `npm version` command automatically prepends the `v` prefix to the version number.
|