coh-content-db 2.0.0-rc.8 → 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 (74) hide show
  1. package/.github/workflows/build.yml +3 -1
  2. package/CHANGELOG.md +47 -0
  3. package/README.md +48 -17
  4. package/dist/coh-content-db.d.ts +257 -200
  5. package/dist/coh-content-db.js +509 -339
  6. package/dist/coh-content-db.js.map +1 -1
  7. package/dist/coh-content-db.mjs +501 -335
  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/{content-bundle.ts → bundle-data.ts} +5 -27
  13. package/src/main/api/bundle-header-data.ts +44 -0
  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 +52 -0
  30. package/src/main/db/coh-content-database.ts +22 -22
  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 +14 -8
  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 +7 -0
  46. package/src/test/api/bundle-header-data.fixture.ts +8 -0
  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 +89 -0
  54. package/src/test/db/coh-content-database.test.ts +137 -178
  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 +16 -0
  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/api/change.ts +0 -17
  67. package/src/main/changelog.ts +0 -29
  68. package/src/main/db/alternates.ts +0 -67
  69. package/src/main/db/bundle-metadata.ts +0 -45
  70. package/src/test/api/content-bundle.fixture.ts +0 -6
  71. package/src/test/api/content-bundle.test.ts +0 -14
  72. package/src/test/changelog.test.ts +0 -36
  73. package/src/test/db/bundle-metadata.test.ts +0 -84
  74. package/src/test/index.test.ts +0 -14
@@ -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 ADDED
@@ -0,0 +1,47 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.0.0] - 2026-01-05
9
+
10
+ ### Added
11
+
12
+ - Introduced a simple indexing and search function for badge names, text, and acquisition info.
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.
18
+ - Added GitHub Actions for continuous integration (CI).
19
+ - Included `eslint` for linting.
20
+ - Added `jest` for unit testing.
21
+ - CHANGELOG.md
22
+
23
+ ### Changed
24
+
25
+ - Server groups are now referred to as "forks".
26
+ - Enum types were replaced with union types, and values now use `kebab-case`.
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.
29
+ - `GameMap` was renamed to `Zone`.
30
+ - Badge partials are now referred to as badge requirements.
31
+ - `Badge.getRequirement()` now returns undefined instead of throwing an error on unknown key.
32
+ - Exploration badge locations were moved into the badge requirements list.
33
+ - References to zones and badges now use a standard Markdown link format (`badge://`, `map://`).
34
+ - Some field names were updated for consistent pluralization (e.g., `name`, `icon`).
35
+ - `VidiotMap` data was folded into `Location` data.
36
+ - `settitle` IDs were consolidated into a single tuple field.
37
+ - Bundle metadata is now found in the `BundleData.header` field.
38
+ - Redundant interfaces have been replaced with their concrete equivalents.
39
+ - The project license was changed from GNU to [The Unlicense](https://unlicense.org/).
40
+ - Switched the build system from Webpack to Rollup.
41
+
42
+ ### Removed
43
+
44
+ - The `serverGroup` property was removed from entities to simplify the object model, since only one context is allowed per database.
45
+ - All third-party dependencies were removed.
46
+ - VidiotMap data was removed from the Zone API.
47
+ - Changelog API is removed in favor of the CHANGELOG.md file in the repository.
package/README.md CHANGED
@@ -8,12 +8,20 @@
8
8
 
9
9
  City of Heroes Content Database
10
10
 
11
+ ----
12
+
13
+ # Changelog
14
+
15
+ [CHANGELOG.md](CHANGELOG.md)
16
+
11
17
  # Installation
12
18
 
13
19
  ```
14
20
  npm install coh-content-db
15
21
  ```
16
22
 
23
+ ----
24
+
17
25
  # Usage
18
26
 
19
27
  There are two ways to use this package; As a data provider, or a db consumer.
@@ -33,23 +41,23 @@ To define content, create a new instance using the appropriate `Data` interface
33
41
  ///test-badge.ts
34
42
  import { BadgeData } from 'coh-content-db'
35
43
 
36
- export const TEST_BADGE: BadgeData = {
44
+ export const TestBadge: BadgeData = {
37
45
  key: 'test-badge',
38
46
  type: 'achievement',
39
47
  name: [{ value: 'Test Badge' }, { alignment: 'praetorian', value: 'My Badge for Praetorians' }],
48
+ releaseDate: '2020-03-01',
40
49
  alignment: ['hero', 'praetorian'],
41
50
  }
42
51
  ```
43
52
 
44
- Then, create a `ContentBundle` instance and load your content into the appropriate field.
53
+ Then, create a `BundleData` instance and load your content into the appropriate field.
45
54
 
46
55
  ```typescript
47
- import { ContentBundle } from './content-bundle'
48
- import { TEST_BADGE } from './test-badge'
56
+ import { BundleData } from 'coh-content-db'
49
57
 
50
- export const MY_CONTENT_BUNDLE: ContentBundle = {
51
- name: 'My Content Bundle',
52
- 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],
53
61
  }
54
62
  ```
55
63
 
@@ -79,14 +87,24 @@ const link = `This is a link to the ${badgeLink('ghoulish')} badge.`
79
87
 
80
88
  ## As a DB consumer
81
89
 
82
- 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):
83
91
 
84
92
  ```typescript
85
93
  import { CohContentDatabase } from 'coh-content-db'
86
- import { Homecoming } from 'coh-content-db-homecoming'
94
+ import { HOMECOMING } from 'coh-content-db-homecoming'
87
95
 
88
- const db = new CohContentDatabase()
89
- db.loadBundle(new Homecoming())
96
+ const database = new CohContentDatabase(HOMECOMING)
97
+ ```
98
+
99
+ or from a JSON object:
100
+
101
+ ```typescript
102
+ import { BundleData, CohContentDatabase } from 'coh-content-db'
103
+
104
+ const response = await fetch('https://n15g.github.io/coh-content-db-homecoming/bundle.json')
105
+ const bundle = await response.json() as BundleData
106
+
107
+ const database = new CohContentDatabase(bundle)
90
108
  ```
91
109
 
92
110
  #### Access the content
@@ -97,11 +115,24 @@ for (const badge of db.badges) {
97
115
  }
98
116
  ```
99
117
 
100
- ## Publish
118
+ ----
101
119
 
102
- 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
103
121
 
104
- ```shell
105
- npm version 1.4.x
106
- npm run push
107
- ```
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.