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.
Files changed (66) hide show
  1. package/.github/workflows/build.yml +3 -1
  2. package/CHANGELOG.md +11 -2
  3. package/README.md +33 -19
  4. package/dist/coh-content-db.d.ts +230 -170
  5. package/dist/coh-content-db.js +495 -296
  6. package/dist/coh-content-db.js.map +1 -1
  7. package/dist/coh-content-db.mjs +488 -294
  8. package/dist/coh-content-db.mjs.map +1 -1
  9. package/jest.config.mjs +1 -0
  10. package/package.json +14 -14
  11. package/src/main/api/badge-data.ts +13 -7
  12. package/src/main/api/bundle-data.ts +1 -1
  13. package/src/main/api/bundle-header-data.ts +13 -6
  14. package/src/main/api/contact-data.ts +2 -1
  15. package/src/main/api/level-range-data.ts +4 -0
  16. package/src/main/api/mission-data.ts +3 -29
  17. package/src/main/api/mission-flashback-data.ts +31 -0
  18. package/src/main/api/morality.ts +27 -9
  19. package/src/main/api/set-title-data.ts +4 -0
  20. package/src/main/api/variant-context.ts +11 -0
  21. package/src/main/api/{alternate-data.ts → variant-data.ts} +4 -4
  22. package/src/main/api/zone-data.ts +24 -0
  23. package/src/main/api/zone-type.ts +59 -0
  24. package/src/main/db/abstract-index.ts +12 -16
  25. package/src/main/db/badge-index.ts +53 -27
  26. package/src/main/db/badge-requirement.ts +1 -1
  27. package/src/main/db/badge-search-options.ts +15 -14
  28. package/src/main/db/badge.ts +46 -29
  29. package/src/main/db/bundle-header.ts +18 -10
  30. package/src/main/db/coh-content-database.ts +17 -17
  31. package/src/main/db/contact.ts +5 -4
  32. package/src/main/db/level-range.ts +15 -0
  33. package/src/main/db/mission.ts +11 -10
  34. package/src/main/db/paged.ts +7 -3
  35. package/src/main/db/set-title-ids.ts +10 -0
  36. package/src/main/db/variants.ts +84 -0
  37. package/src/main/db/zone.ts +29 -0
  38. package/src/main/index.ts +11 -4
  39. package/src/main/util/coalesce-to-array.ts +13 -0
  40. package/src/main/{util.ts → util/links.ts} +8 -22
  41. package/src/main/util/to-date.ts +9 -0
  42. package/src/test/api/alignment.test.ts +2 -2
  43. package/src/test/api/badge-data.fixture.ts +1 -0
  44. package/src/test/api/badge-data.test.ts +1 -0
  45. package/src/test/api/bundle-data.fixture.ts +3 -2
  46. package/src/test/api/bundle-header-data.fixture.ts +4 -2
  47. package/src/test/api/morality.test.ts +31 -0
  48. package/src/test/api/sex.test.ts +2 -2
  49. package/src/test/api/zone-data.fixture.ts +1 -0
  50. package/src/test/db/abstract-index.test.ts +12 -43
  51. package/src/test/db/badge-index.test.ts +197 -101
  52. package/src/test/db/badge.test.ts +122 -16
  53. package/src/test/db/bundle-header.test.ts +25 -12
  54. package/src/test/db/coh-content-database.test.ts +134 -175
  55. package/src/test/db/contact.test.ts +2 -1
  56. package/src/test/db/level-range.test.ts +47 -0
  57. package/src/test/db/mission.test.ts +8 -6
  58. package/src/test/db/morality-list.test.ts +1 -1
  59. package/src/test/db/set-title-ids.test.ts +19 -0
  60. package/src/test/db/{alternates.test.ts → variants.test.ts} +24 -24
  61. package/src/test/db/zone.test.ts +45 -0
  62. package/src/test/integration.test.ts +3 -3
  63. package/src/test/util/coalese-to-array.test.ts +17 -0
  64. package/src/test/{util.test.ts → util/links.test.ts} +5 -21
  65. package/src/test/util/to-date.test.ts +15 -0
  66. package/src/main/db/alternates.ts +0 -67
@@ -1,5 +1,7 @@
1
1
  name: Build
2
- on: push
2
+ on:
3
+ push:
4
+ branches: [ '*' ]
3
5
  jobs:
4
6
  build:
5
7
  runs-on: ubuntu-latest
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-rc.9] - 2025-04-15
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
- - Redundant interfaces have been replaced with their concrete equivalents.
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
- # Change Log
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 TEST_BADGE: BadgeData = {
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 MY_CONTENT_BUNDLE: BundleData = {
55
- header: { name: 'My Content Bundle' },
56
- badges: [TEST_BADGE],
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, then load a content bundle, such as [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming):
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
- database.load(bundle)
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
- ## Publish
118
+ ----
118
119
 
119
- Tags matching the pattern `v<X>.<Y>.<Z>` will attempt to publish to npm (this can only be achieved by the package manager (n15g).
120
+ # Development
120
121
 
121
- ```shell
122
- npm version 1.4.x
123
- npm run push
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.