coh-content-db 2.0.0-rc.2 → 2.0.0-rc.21

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 (120) hide show
  1. package/.editorconfig +10 -11
  2. package/.github/workflows/build.yml +4 -2
  3. package/.github/workflows/pull-request.yml +1 -1
  4. package/.github/workflows/release.yml +1 -1
  5. package/CHANGELOG.md +47 -0
  6. package/README.md +77 -32
  7. package/dist/coh-content-db.d.ts +755 -290
  8. package/dist/coh-content-db.js +1028 -358
  9. package/dist/coh-content-db.js.map +1 -1
  10. package/dist/coh-content-db.mjs +998 -349
  11. package/dist/coh-content-db.mjs.map +1 -1
  12. package/eslint.config.mjs +1 -0
  13. package/jest.config.mjs +1 -0
  14. package/package.json +14 -14
  15. package/src/main/api/alignment.ts +18 -2
  16. package/src/main/api/badge-data.ts +29 -51
  17. package/src/main/api/badge-requirement-data.ts +64 -0
  18. package/src/main/api/badge-requirement-type.ts +32 -0
  19. package/src/main/api/badge-type.ts +15 -15
  20. package/src/main/api/bundle-data.ts +47 -0
  21. package/src/main/api/bundle-header-data.ts +44 -0
  22. package/src/main/api/contact-data.ts +49 -0
  23. package/src/main/api/enhancement-category.ts +26 -26
  24. package/src/main/api/level-range-data.ts +4 -0
  25. package/src/main/api/location-data.ts +28 -0
  26. package/src/main/api/markdown-string.ts +4 -0
  27. package/src/main/api/mission-data.ts +57 -0
  28. package/src/main/api/mission-flashback-data.ts +31 -0
  29. package/src/main/api/mission-type.ts +2 -0
  30. package/src/main/api/morality.ts +49 -0
  31. package/src/main/api/set-title-data.ts +4 -0
  32. package/src/main/api/sex.ts +8 -1
  33. package/src/main/api/variant-context.ts +11 -0
  34. package/src/main/api/variant-data.ts +22 -0
  35. package/src/main/api/zone-data.ts +44 -0
  36. package/src/main/api/zone-type.ts +59 -0
  37. package/src/main/db/abstract-index.ts +37 -0
  38. package/src/main/db/alignment-list.ts +54 -0
  39. package/src/main/db/badge-index.ts +83 -0
  40. package/src/main/db/badge-requirement.ts +81 -0
  41. package/src/main/db/badge-search-options.ts +52 -0
  42. package/src/main/db/badge.ts +97 -74
  43. package/src/main/db/bundle-header.ts +52 -0
  44. package/src/main/db/coh-content-database.ts +123 -14
  45. package/src/main/db/contact.ts +63 -0
  46. package/src/main/db/level-range.ts +15 -0
  47. package/src/main/db/location.ts +30 -0
  48. package/src/main/db/mission.ts +108 -0
  49. package/src/main/db/morality-list.ts +99 -0
  50. package/src/main/db/paged.ts +11 -0
  51. package/src/main/db/set-title-ids.ts +10 -0
  52. package/src/main/db/variants.ts +84 -0
  53. package/src/main/db/zone.ts +57 -0
  54. package/src/main/index.ts +33 -18
  55. package/src/main/util/coalesce-to-array.ts +13 -0
  56. package/src/main/util/links.ts +104 -0
  57. package/src/main/util/to-date.ts +9 -0
  58. package/src/test/api/alignment.test.ts +38 -4
  59. package/src/test/api/badge-data.fixture.ts +2 -15
  60. package/src/test/api/badge-data.test.ts +5 -4
  61. package/src/test/api/badge-requirement-data.fixture.ts +7 -0
  62. package/src/test/api/badge-requirement-type.test.ts +31 -0
  63. package/src/test/api/badge-type.test.ts +5 -5
  64. package/src/test/api/bundle-data.fixture.ts +7 -0
  65. package/src/test/api/bundle-header-data.fixture.ts +8 -0
  66. package/src/test/api/contact-data.fixture.ts +7 -0
  67. package/src/test/api/enhancement-category.test.ts +5 -5
  68. package/src/test/api/mission-data.fixture.ts +12 -0
  69. package/src/test/api/morality.test.ts +31 -0
  70. package/src/test/api/sex.test.ts +33 -1
  71. package/src/test/api/zone-data.fixture.ts +9 -0
  72. package/src/test/db/abstract-index.test.ts +55 -0
  73. package/src/test/db/alignment-list.test.ts +200 -0
  74. package/src/test/db/badge-index.test.ts +653 -0
  75. package/src/test/db/badge-requirement.test.ts +145 -0
  76. package/src/test/db/badge.test.ts +416 -14
  77. package/src/test/db/bundle-header.test.ts +89 -0
  78. package/src/test/db/coh-content-database.test.ts +265 -24
  79. package/src/test/db/contact.test.ts +98 -0
  80. package/src/test/db/level-range.test.ts +47 -0
  81. package/src/test/db/location.test.ts +51 -0
  82. package/src/test/db/mission.test.ts +173 -0
  83. package/src/test/db/morality-list.test.ts +457 -0
  84. package/src/test/db/set-title-ids.test.ts +19 -0
  85. package/src/test/db/variants.test.ts +188 -0
  86. package/src/test/db/zone.test.ts +81 -0
  87. package/src/test/integration.test.ts +16 -0
  88. package/src/test/util/coalese-to-array.test.ts +17 -0
  89. package/src/test/util/links.test.ts +149 -0
  90. package/src/test/util/to-date.test.ts +15 -0
  91. package/src/main/api/alternate-data.ts +0 -22
  92. package/src/main/api/badge-partial-data.ts +0 -65
  93. package/src/main/api/badge-partial-type.ts +0 -8
  94. package/src/main/api/change.ts +0 -14
  95. package/src/main/api/game-map-data.ts +0 -26
  96. package/src/main/api/plaque-type.ts +0 -6
  97. package/src/main/api/server-group-data.ts +0 -65
  98. package/src/main/api/vidiot-map-data.ts +0 -18
  99. package/src/main/api/vidiot-map-point-of-interest-data.ts +0 -30
  100. package/src/main/changelog.ts +0 -20
  101. package/src/main/db/alternates.ts +0 -81
  102. package/src/main/db/badge-partial.ts +0 -35
  103. package/src/main/db/game-map.ts +0 -33
  104. package/src/main/db/server-group.ts +0 -112
  105. package/src/main/db/vidiot-map-point-of-interest.ts +0 -40
  106. package/src/main/db/vidiot-map.ts +0 -25
  107. package/src/main/util.ts +0 -17
  108. package/src/test/api/badge-partial-data.fixture.ts +0 -17
  109. package/src/test/api/badge-partial-type.test.ts +0 -31
  110. package/src/test/api/game-map-data.fixture.ts +0 -10
  111. package/src/test/api/plaque-type.test.ts +0 -31
  112. package/src/test/api/server-group-data.fixture.ts +0 -23
  113. package/src/test/api/server-group-data.test.ts +0 -15
  114. package/src/test/api/vidiot-map-point-of-interest.fixture.ts +0 -10
  115. package/src/test/api/vidiot-map.fixture.ts +0 -9
  116. package/src/test/changelog.test.ts +0 -36
  117. package/src/test/db/alternates.test.ts +0 -223
  118. package/src/test/db/server-group.test.ts +0 -124
  119. package/src/test/index.test.ts +0 -10
  120. package/src/test/util.test.ts +0 -39
package/.editorconfig CHANGED
@@ -4,22 +4,21 @@ root = true
4
4
  end_of_line = lf
5
5
  insert_final_newline = true
6
6
 
7
- [*.{js,mjs,cj}]
7
+ [*.{ts,js,mjs,cj,md}]
8
8
  indent_style = space
9
9
  indent_size = 2
10
+ ij_javascript_force_quote_style = true
11
+ ij_javascript_force_semicolon_style = true
10
12
  ij_javascript_spaces_within_imports = true
11
13
  ij_javascript_spaces_within_object_literal_braces = true
12
- ij_javascript_force_semicolon_style = true
13
- ij_javascript_use_semicolon_after_statement = false
14
- ij_javascript_force_quote_style = true
15
14
  ij_javascript_use_double_quotes = false
16
-
17
- [*.ts]
18
- indent_style = space
19
- indent_size = 2
15
+ ij_javascript_use_semicolon_after_statement = false
16
+ ij_typescript_force_quote_style = true
17
+ ij_typescript_force_semicolon_style = true
20
18
  ij_typescript_spaces_within_imports = true
21
19
  ij_typescript_spaces_within_object_literal_braces = true
22
- ij_typescript_force_semicolon_style = true
23
- ij_typescript_use_semicolon_after_statement = false
24
- ij_typescript_force_quote_style = true
25
20
  ij_typescript_use_double_quotes = false
21
+ ij_typescript_use_semicolon_after_statement = false
22
+
23
+ [*.md]
24
+ indent_size = 4
@@ -1,7 +1,9 @@
1
1
  name: Build
2
- on: push
2
+ on:
3
+ push:
4
+ branches: [ '*' ]
3
5
  jobs:
4
- Build:
6
+ build:
5
7
  runs-on: ubuntu-latest
6
8
  steps:
7
9
  - name: Checkout
@@ -1,7 +1,7 @@
1
1
  name: Build
2
2
  on: pull_request
3
3
  jobs:
4
- Build:
4
+ build:
5
5
  runs-on: ubuntu-latest
6
6
  steps:
7
7
  - name: Checkout
@@ -4,7 +4,7 @@ on:
4
4
  tags:
5
5
  - "v*.*.*"
6
6
  jobs:
7
- Checkout:
7
+ build:
8
8
  runs-on: ubuntu-latest
9
9
  permissions:
10
10
  contents: read
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-rc.21] - 2026-01-04
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,86 +8,131 @@
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.
20
28
 
21
29
  ## As a data provider
22
30
 
23
- Data providers utilize the various `-Data` interfaces provided in this package to construct server group data packages
31
+ Data providers utilize the various `-Data` interfaces provided in this package to construct content bundles
24
32
  that can be loaded into the db for consumption by DB consumers such as [Badger](https://github.com/n15g/badger).
25
33
 
26
34
  For an example data package, see the [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming) project.
27
35
 
28
- ### Defining archetypes, map, badges, etc.
36
+ ### Defining archetypes, zones, badges, etc.
29
37
 
30
38
  To define content, create a new instance using the appropriate `Data` interface and provide values for the required fields:
31
39
 
32
40
  ```typescript
33
41
  ///test-badge.ts
34
- import {BadgeData} from 'coh-content-db'
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
- type: 'ACHIEVEMENT',
39
- name: [{value: 'Test Badge'}, {alignment: 'P', value: 'My Badge for Praetorians'}],
40
- alignment: ['H', 'V', 'P'],
46
+ type: 'achievement',
47
+ name: [{ value: 'Test Badge' }, { alignment: 'praetorian', value: 'My Badge for Praetorians' }],
48
+ releaseDate: '2020-03-01',
49
+ alignment: ['hero', 'praetorian'],
41
50
  }
42
51
  ```
43
52
 
44
- Then, create a `ServerGroupData` 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 {ServerGroupData} from 'coh-content-db'
48
- import {TEST_BADGE} from './test-badge'
56
+ import { BundleData } from 'coh-content-db'
49
57
 
50
- export const TEST_SERVER_GROUP: ServerGroupData = {
51
- key: 'my-server-group',
52
- name: 'My Server Group',
53
- 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],
54
61
  }
55
62
  ```
56
63
 
57
- ## As a DB consumer
64
+ ### Markdown and Links
65
+
66
+ Fields with long text values can typically accept [Markdown](https://www.markdownguide.org/) format. These fields will also be typed with the tag type [MarkdownString](src/main/api/markdown-string.ts).
67
+
68
+ 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.
69
+ This replaces the custom `[badge:xyz]` format from v1 and data packages will need to update accordingly.
58
70
 
59
- Create a new database instance, then load a server-group data pack, such as [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming):
71
+ To create a link, use the standard Markdown link format, with the url as following:
72
+
73
+ ```markdown
74
+ This is a link to the [Ghoulish](badge://ghoulish) badge.
75
+ ```
76
+
77
+ There are convenience functions also provided to construct the URI automatically that can be used as follows:
60
78
 
61
79
  ```typescript
62
- import {CohContentDatabase} from 'coh-content-db';
63
- import {Homecoming} from 'coh-content-db-homecoming';
80
+ import { badgeLink, badgeUri } from 'coh-content-db'
64
81
 
65
- const db = new CohContentDatabase();
66
- db.loadServerGroupData(new Homecoming());
82
+ const uri = `This is a link to the [Ghoulish](${badgeUri('ghoulish')}) badge.`
83
+ // This is a link to the [Ghoulish](badge://ghoulish) badge.
84
+ const link = `This is a link to the ${badgeLink('ghoulish')} badge.`
85
+ // This is a link to the [ghoulish](badge://ghoulish) badge.
67
86
  ```
68
87
 
69
- Once loaded, you can start retrieving the loaded data using the keys associated with the various content:
88
+ ## As a DB consumer
70
89
 
71
- #### List loaded server groups:
90
+ Create a new database instance from a content bundle, such as [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming):
72
91
 
73
92
  ```typescript
74
- db.listServerGroups();
93
+ import { CohContentDatabase } from 'coh-content-db'
94
+ import { HOMECOMING } from 'coh-content-db-homecoming'
95
+
96
+ const database = new CohContentDatabase(HOMECOMING)
75
97
  ```
76
98
 
77
- #### Get a server group by key and list the badges:
99
+ or from a JSON object:
78
100
 
79
101
  ```typescript
80
- const sg = db.getServerGroup("server-group-key");
81
- for (const badge of sg.badges) {
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)
108
+ ```
109
+
110
+ #### Access the content
111
+
112
+ ```typescript
113
+ for (const badge of db.badges) {
82
114
  console.log(badge.key)
83
115
  }
84
116
  ```
85
117
 
86
- ## Publish
118
+ ----
87
119
 
88
- 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
89
121
 
90
- ```shell
91
- npm version 1.4.x
92
- npm run push
93
- ```
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.