coh-content-db 2.0.0-rc.1 → 2.0.0-rc.11
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/.editorconfig +10 -11
- package/.github/workflows/build.yml +4 -2
- package/.github/workflows/pull-request.yml +1 -1
- package/.github/workflows/release.yml +2 -2
- package/CHANGELOG.md +43 -0
- package/README.md +52 -24
- package/dist/coh-content-db.d.ts +678 -279
- package/dist/coh-content-db.js +828 -371
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +803 -362
- package/dist/coh-content-db.mjs.map +1 -1
- package/eslint.config.mjs +1 -0
- package/package.json +1 -1
- package/src/main/api/alignment.ts +18 -2
- package/src/main/api/alternate-data.ts +2 -2
- package/src/main/api/badge-data.ts +20 -48
- package/src/main/api/badge-requirement-data.ts +64 -0
- package/src/main/api/badge-requirement-type.ts +32 -0
- package/src/main/api/badge-type.ts +15 -15
- package/src/main/api/bundle-data.ts +47 -0
- package/src/main/api/bundle-header-data.ts +37 -0
- package/src/main/api/contact-data.ts +48 -0
- package/src/main/api/enhancement-category.ts +26 -26
- package/src/main/api/location-data.ts +28 -0
- package/src/main/api/markdown-string.ts +4 -0
- package/src/main/api/mission-data.ts +83 -0
- package/src/main/api/mission-type.ts +2 -0
- package/src/main/api/morality.ts +31 -0
- package/src/main/api/sex.ts +8 -1
- package/src/main/api/zone-data.ts +20 -0
- package/src/main/db/abstract-index.ts +37 -0
- package/src/main/db/alignment-list.ts +54 -0
- package/src/main/db/alternates.ts +28 -42
- package/src/main/db/badge-index.ts +60 -0
- package/src/main/db/badge-requirement.ts +81 -0
- package/src/main/db/badge-search-options.ts +47 -0
- package/src/main/db/badge.ts +76 -71
- package/src/main/db/bundle-header.ts +44 -0
- package/src/main/db/coh-content-database.ts +123 -14
- package/src/main/db/contact.ts +62 -0
- package/src/main/db/location.ts +30 -0
- package/src/main/db/mission.ts +107 -0
- package/src/main/db/morality-list.ts +99 -0
- package/src/main/db/paged.ts +7 -0
- package/src/main/db/zone.ts +28 -0
- package/src/main/index.ts +23 -15
- package/src/main/util.ts +108 -7
- package/src/test/api/alignment.test.ts +38 -4
- package/src/test/api/badge-data.fixture.ts +1 -15
- package/src/test/api/badge-data.test.ts +4 -4
- package/src/test/api/badge-requirement-data.fixture.ts +7 -0
- package/src/test/api/badge-requirement-type.test.ts +31 -0
- package/src/test/api/badge-type.test.ts +5 -5
- package/src/test/api/bundle-data.fixture.ts +6 -0
- package/src/test/api/bundle-header-data.fixture.ts +6 -0
- package/src/test/api/contact-data.fixture.ts +7 -0
- package/src/test/api/enhancement-category.test.ts +5 -5
- package/src/test/api/mission-data.fixture.ts +12 -0
- package/src/test/api/sex.test.ts +33 -1
- package/src/test/api/zone-data.fixture.ts +8 -0
- package/src/test/db/abstract-index.test.ts +55 -0
- package/src/test/db/alignment-list.test.ts +200 -0
- package/src/test/db/alternates.test.ts +82 -117
- package/src/test/db/badge-index.test.ts +547 -0
- package/src/test/db/badge-requirement.test.ts +145 -0
- package/src/test/db/badge.test.ts +322 -14
- package/src/test/db/bundle-header.test.ts +76 -0
- package/src/test/db/coh-content-database.test.ts +264 -24
- package/src/test/db/contact.test.ts +97 -0
- package/src/test/db/location.test.ts +51 -0
- package/src/test/db/mission.test.ts +171 -0
- package/src/test/db/morality-list.test.ts +457 -0
- package/src/test/db/zone.test.ts +36 -0
- package/src/test/integration.test.ts +16 -0
- package/src/test/util.test.ts +144 -18
- package/src/main/api/badge-partial-data.ts +0 -65
- package/src/main/api/badge-partial-type.ts +0 -8
- package/src/main/api/change.ts +0 -14
- package/src/main/api/game-map-data.ts +0 -26
- package/src/main/api/plaque-type.ts +0 -6
- package/src/main/api/server-group-data.ts +0 -65
- package/src/main/api/vidiot-map-data.ts +0 -18
- package/src/main/api/vidiot-map-point-of-interest-data.ts +0 -30
- package/src/main/changelog.ts +0 -20
- package/src/main/db/badge-partial.ts +0 -35
- package/src/main/db/game-map.ts +0 -33
- package/src/main/db/server-group.ts +0 -112
- package/src/main/db/vidiot-map-point-of-interest.ts +0 -40
- package/src/main/db/vidiot-map.ts +0 -25
- package/src/test/api/badge-partial-data.fixture.ts +0 -17
- package/src/test/api/badge-partial-type.test.ts +0 -31
- package/src/test/api/game-map-data.fixture.ts +0 -10
- package/src/test/api/plaque-type.test.ts +0 -31
- package/src/test/api/server-group-data.fixture.ts +0 -23
- package/src/test/api/server-group-data.test.ts +0 -15
- package/src/test/api/vidiot-map-point-of-interest.fixture.ts +0 -10
- package/src/test/api/vidiot-map.fixture.ts +0 -9
- package/src/test/changelog.test.ts +0 -36
- package/src/test/db/server-group.test.ts +0 -124
- package/src/test/index.test.ts +0 -10
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
|
-
|
|
18
|
-
|
|
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
|
|
@@ -4,7 +4,7 @@ on:
|
|
|
4
4
|
tags:
|
|
5
5
|
- "v*.*.*"
|
|
6
6
|
jobs:
|
|
7
|
-
|
|
7
|
+
build:
|
|
8
8
|
runs-on: ubuntu-latest
|
|
9
9
|
permissions:
|
|
10
10
|
contents: read
|
|
@@ -44,7 +44,7 @@ jobs:
|
|
|
44
44
|
with:
|
|
45
45
|
draft: true
|
|
46
46
|
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
|
|
47
|
-
files: 'dist'
|
|
47
|
+
files: 'dist/*'
|
|
48
48
|
|
|
49
49
|
- name: Publish
|
|
50
50
|
run: npm publish --provenance --access public
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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.11] - 2025-04-19
|
|
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
|
+
- Added GitHub Actions for continuous integration (CI).
|
|
15
|
+
- Included `eslint` for linting.
|
|
16
|
+
- Added `jest` for unit testing.
|
|
17
|
+
- CHANGELOG.md
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Server groups are now referred to as "forks".
|
|
22
|
+
- Enum types were replaced with union types, and values now use `kebab-case`.
|
|
23
|
+
- The `IServerGroupData` interface was renamed to `BundleData`, and databases are now scoped to a single bundle.
|
|
24
|
+
- Database instance is now immutable and bundle data is loaded in the constructor.
|
|
25
|
+
- `GameMap` was renamed to `Zone`.
|
|
26
|
+
- Badge partials are now referred to as badge requirements.
|
|
27
|
+
- `Badge.getRequirement()` now returns undefined instead of throwing an error on unknown key.
|
|
28
|
+
- Exploration badge locations were moved into the badge requirements list.
|
|
29
|
+
- References to zones and badges now use a standard Markdown link format (`badge://`, `map://`).
|
|
30
|
+
- Some field names were updated for consistent pluralization (e.g., `name`, `icon`).
|
|
31
|
+
- `VidiotMap` data was folded into `Location` data.
|
|
32
|
+
- `settitle` IDs were consolidated into a single tuple field.
|
|
33
|
+
- Bundle metadata is now found in the `BundleData.header` field.
|
|
34
|
+
- Redundant interfaces have been replaced with their concrete equivalents.
|
|
35
|
+
- The project license was changed from GNU to [The Unlicense](https://unlicense.org/).
|
|
36
|
+
- Switched the build system from Webpack to Rollup.
|
|
37
|
+
|
|
38
|
+
### Removed
|
|
39
|
+
|
|
40
|
+
- The `serverGroup` property was removed from entities to simplify the object model, since only one context is allowed per database.
|
|
41
|
+
- All third-party dependencies were removed.
|
|
42
|
+
- VidiotMap data was removed from the Zone API.
|
|
43
|
+
- Changelog API is removed in favor of the CHANGELOG.md file in the repository.
|
package/README.md
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
City of Heroes Content Database
|
|
10
10
|
|
|
11
|
+
# Change Log
|
|
12
|
+
|
|
13
|
+
[CHANGELOG.md](CHANGELOG.md)
|
|
14
|
+
|
|
11
15
|
# Installation
|
|
12
16
|
|
|
13
17
|
```
|
|
@@ -20,65 +24,89 @@ There are two ways to use this package; As a data provider, or a db consumer.
|
|
|
20
24
|
|
|
21
25
|
## As a data provider
|
|
22
26
|
|
|
23
|
-
Data providers utilize the various `-Data` interfaces provided in this package to construct
|
|
27
|
+
Data providers utilize the various `-Data` interfaces provided in this package to construct content bundles
|
|
24
28
|
that can be loaded into the db for consumption by DB consumers such as [Badger](https://github.com/n15g/badger).
|
|
25
29
|
|
|
26
30
|
For an example data package, see the [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming) project.
|
|
27
31
|
|
|
28
|
-
### Defining archetypes,
|
|
32
|
+
### Defining archetypes, zones, badges, etc.
|
|
29
33
|
|
|
30
34
|
To define content, create a new instance using the appropriate `Data` interface and provide values for the required fields:
|
|
31
35
|
|
|
32
36
|
```typescript
|
|
33
37
|
///test-badge.ts
|
|
34
|
-
import {BadgeData} from 'coh-content-db'
|
|
38
|
+
import { BadgeData } from 'coh-content-db'
|
|
35
39
|
|
|
36
40
|
export const TEST_BADGE: BadgeData = {
|
|
37
41
|
key: 'test-badge',
|
|
38
|
-
type: '
|
|
39
|
-
name: [{value: 'Test Badge'}, {alignment: '
|
|
40
|
-
alignment: ['
|
|
42
|
+
type: 'achievement',
|
|
43
|
+
name: [{ value: 'Test Badge' }, { alignment: 'praetorian', value: 'My Badge for Praetorians' }],
|
|
44
|
+
alignment: ['hero', 'praetorian'],
|
|
41
45
|
}
|
|
42
46
|
```
|
|
43
47
|
|
|
44
|
-
Then, create a `
|
|
48
|
+
Then, create a `BundleData` instance and load your content into the appropriate field.
|
|
45
49
|
|
|
46
50
|
```typescript
|
|
47
|
-
import {
|
|
48
|
-
import {TEST_BADGE} from './test-badge'
|
|
51
|
+
import { BundleData } from 'coh-content-db'
|
|
52
|
+
import { TEST_BADGE } from './test-badge'
|
|
49
53
|
|
|
50
|
-
export const
|
|
51
|
-
|
|
52
|
-
name: 'My Server Group',
|
|
54
|
+
export const MY_CONTENT_BUNDLE: BundleData = {
|
|
55
|
+
header: { name: 'My Content Bundle' },
|
|
53
56
|
badges: [TEST_BADGE],
|
|
54
57
|
}
|
|
55
58
|
```
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
### Markdown and Links
|
|
61
|
+
|
|
62
|
+
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).
|
|
63
|
+
|
|
64
|
+
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.
|
|
65
|
+
This replaces the custom `[badge:xyz]` format from v1 and data packages will need to update accordingly.
|
|
66
|
+
|
|
67
|
+
To create a link, use the standard Markdown link format, with the url as following:
|
|
68
|
+
|
|
69
|
+
```markdown
|
|
70
|
+
This is a link to the [Ghoulish](badge://ghoulish) badge.
|
|
71
|
+
```
|
|
58
72
|
|
|
59
|
-
|
|
73
|
+
There are convenience functions also provided to construct the URI automatically that can be used as follows:
|
|
60
74
|
|
|
61
75
|
```typescript
|
|
62
|
-
import {
|
|
63
|
-
import {Homecoming} from 'coh-content-db-homecoming';
|
|
76
|
+
import { badgeLink, badgeUri } from 'coh-content-db'
|
|
64
77
|
|
|
65
|
-
const
|
|
66
|
-
|
|
78
|
+
const uri = `This is a link to the [Ghoulish](${badgeUri('ghoulish')}) badge.`
|
|
79
|
+
// This is a link to the [Ghoulish](badge://ghoulish) badge.
|
|
80
|
+
const link = `This is a link to the ${badgeLink('ghoulish')} badge.`
|
|
81
|
+
// This is a link to the [ghoulish](badge://ghoulish) badge.
|
|
67
82
|
```
|
|
68
83
|
|
|
69
|
-
|
|
84
|
+
## As a DB consumer
|
|
85
|
+
|
|
86
|
+
Create a new database instance from a content bundle, such as [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming):
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { CohContentDatabase } from 'coh-content-db'
|
|
90
|
+
import { HOMECOMING } from 'coh-content-db-homecoming'
|
|
70
91
|
|
|
71
|
-
|
|
92
|
+
const database = new CohContentDatabase(HOMECOMING)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
or from a JSON object:
|
|
72
96
|
|
|
73
97
|
```typescript
|
|
74
|
-
db
|
|
98
|
+
import { BundleData, CohContentDatabase } from 'coh-content-db'
|
|
99
|
+
|
|
100
|
+
const response = await fetch('https://n15g.github.io/coh-content-db-homecoming/bundle.json')
|
|
101
|
+
const bundle = await response.json() as BundleData
|
|
102
|
+
|
|
103
|
+
const database = new CohContentDatabase(bundle)
|
|
75
104
|
```
|
|
76
105
|
|
|
77
|
-
####
|
|
106
|
+
#### Access the content
|
|
78
107
|
|
|
79
108
|
```typescript
|
|
80
|
-
const
|
|
81
|
-
for (const badge of sg.badges) {
|
|
109
|
+
for (const badge of db.badges) {
|
|
82
110
|
console.log(badge.key)
|
|
83
111
|
}
|
|
84
112
|
```
|