coh-content-db 2.0.0-rc.7 → 2.0.0-rc.9
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 +1 -1
- package/.github/workflows/pull-request.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/CHANGELOG.md +38 -0
- package/README.md +24 -7
- package/dist/coh-content-db.d.ts +108 -64
- package/dist/coh-content-db.js +232 -210
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +232 -209
- package/dist/coh-content-db.mjs.map +1 -1
- package/package.json +1 -1
- package/src/main/api/{content-bundle.ts → bundle-data.ts} +5 -27
- package/src/main/api/bundle-header-data.ts +37 -0
- package/src/main/db/abstract-index.ts +41 -0
- package/src/main/db/badge-index.ts +7 -18
- package/src/main/db/bundle-header.ts +44 -0
- package/src/main/db/coh-content-database.ts +81 -72
- package/src/main/index.ts +3 -4
- package/src/test/api/bundle-data.fixture.ts +6 -0
- package/src/test/api/bundle-header-data.fixture.ts +6 -0
- package/src/test/db/abstract-index.test.ts +86 -0
- package/src/test/db/badge-index.test.ts +149 -122
- package/src/test/db/bundle-header.test.ts +76 -0
- package/src/test/db/coh-content-database.test.ts +164 -79
- package/src/test/integration.test.ts +16 -0
- package/src/main/api/change.ts +0 -17
- package/src/main/changelog.ts +0 -29
- package/src/main/db/bundle-metadata.ts +0 -39
- package/src/test/api/content-bundle.fixture.ts +0 -6
- package/src/test/api/content-bundle.test.ts +0 -14
- package/src/test/changelog.test.ts +0 -36
- package/src/test/db/bundle-metadata.test.ts +0 -67
- package/src/test/index.test.ts +0 -14
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
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.9] - 2025-04-15
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Introduced a simple indexing and search function for badge names, text, and acquisition info.
|
|
12
|
+
- Enabled formal support for Missions and Contacts in badge requirements.
|
|
13
|
+
- Added GitHub Actions for continuous integration (CI).
|
|
14
|
+
- Included `eslint` for linting.
|
|
15
|
+
- Added `jest` for unit testing.
|
|
16
|
+
- CHANGELOG.md
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Redundant interfaces have been replaced with their concrete equivalents.
|
|
20
|
+
- Server groups are now referred to as "forks".
|
|
21
|
+
- Enum types were replaced with union types, and values now use `kebab-case`.
|
|
22
|
+
- The `IServerGroupData` interface was renamed to `BundleData`, and databases are now scoped to a single bundle.
|
|
23
|
+
- `GameMap` was renamed to `Zone`.
|
|
24
|
+
- Badge partials are now referred to as badge requirements.
|
|
25
|
+
- Exploration badge locations were moved into the badge requirements list.
|
|
26
|
+
- References to zones and badges now use a standard Markdown link format (`badge://`, `map://`).
|
|
27
|
+
- Some field names were updated for consistent pluralization (e.g., `name`, `icon`).
|
|
28
|
+
- `VidiotMap` data was folded into `Location` data.
|
|
29
|
+
- `settitle` IDs were consolidated into a single tuple field.
|
|
30
|
+
- Bundle metadata is now found in the `BundleData.header` field.
|
|
31
|
+
- The project license was changed from GNU to [The Unlicense](https://unlicense.org/).
|
|
32
|
+
- Switched the build system from Webpack to Rollup.
|
|
33
|
+
|
|
34
|
+
### Removed
|
|
35
|
+
- The `serverGroup` property was removed from entities to simplify the object model, since only one context is allowed per database.
|
|
36
|
+
- All third-party dependencies were removed.
|
|
37
|
+
- VidiotMap data was removed from the Zone API.
|
|
38
|
+
- 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
|
```
|
|
@@ -41,14 +45,14 @@ export const TEST_BADGE: BadgeData = {
|
|
|
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 {
|
|
51
|
+
import { BundleData } from 'coh-content-db'
|
|
48
52
|
import { TEST_BADGE } from './test-badge'
|
|
49
53
|
|
|
50
|
-
export const MY_CONTENT_BUNDLE:
|
|
51
|
-
name: 'My Content Bundle',
|
|
54
|
+
export const MY_CONTENT_BUNDLE: BundleData = {
|
|
55
|
+
header: { name: 'My Content Bundle' },
|
|
52
56
|
badges: [TEST_BADGE],
|
|
53
57
|
}
|
|
54
58
|
```
|
|
@@ -83,10 +87,23 @@ Create a new database instance, then load a content bundle, such as [coh-content
|
|
|
83
87
|
|
|
84
88
|
```typescript
|
|
85
89
|
import { CohContentDatabase } from 'coh-content-db'
|
|
86
|
-
import {
|
|
90
|
+
import { HOMECOMING } from 'coh-content-db-homecoming'
|
|
91
|
+
|
|
92
|
+
const database = new CohContentDatabase()
|
|
93
|
+
|
|
94
|
+
database.load(HOMECOMING)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
or from a JSON object:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { BundleData, CohContentDatabase } from 'coh-content-db'
|
|
101
|
+
|
|
102
|
+
const database = new CohContentDatabase()
|
|
87
103
|
|
|
88
|
-
const
|
|
89
|
-
|
|
104
|
+
const response = await fetch('https://n15g.github.io/coh-content-db-homecoming/bundle.json')
|
|
105
|
+
const bundle = await response.json() as BundleData
|
|
106
|
+
database.load(bundle)
|
|
90
107
|
```
|
|
91
108
|
|
|
92
109
|
#### Access the content
|
package/dist/coh-content-db.d.ts
CHANGED
|
@@ -225,19 +225,21 @@ interface BadgeData {
|
|
|
225
225
|
readonly ignoreInTotals?: boolean;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
interface
|
|
228
|
+
interface ZoneData {
|
|
229
229
|
/**
|
|
230
|
-
*
|
|
230
|
+
* Unique key used to reference this zone.
|
|
231
|
+
*
|
|
232
|
+
* Keys must be unique and can only contain lowercase letters, numbers and hyphens (`-`).
|
|
231
233
|
*/
|
|
232
|
-
|
|
234
|
+
readonly key: string;
|
|
233
235
|
/**
|
|
234
|
-
*
|
|
236
|
+
* The name of the zone as it appears in-game.
|
|
235
237
|
*/
|
|
236
|
-
|
|
238
|
+
readonly name: string;
|
|
237
239
|
/**
|
|
238
|
-
*
|
|
240
|
+
* List of external links. Wiki, forums, etc.
|
|
239
241
|
*/
|
|
240
|
-
|
|
242
|
+
readonly links?: Link[];
|
|
241
243
|
}
|
|
242
244
|
|
|
243
245
|
interface ContactData {
|
|
@@ -277,23 +279,6 @@ interface ContactData {
|
|
|
277
279
|
readonly links?: Link[];
|
|
278
280
|
}
|
|
279
281
|
|
|
280
|
-
interface ZoneData {
|
|
281
|
-
/**
|
|
282
|
-
* Unique key used to reference this zone.
|
|
283
|
-
*
|
|
284
|
-
* Keys must be unique and can only contain lowercase letters, numbers and hyphens (`-`).
|
|
285
|
-
*/
|
|
286
|
-
readonly key: string;
|
|
287
|
-
/**
|
|
288
|
-
* The name of the zone as it appears in-game.
|
|
289
|
-
*/
|
|
290
|
-
readonly name: string;
|
|
291
|
-
/**
|
|
292
|
-
* List of external links. Wiki, forums, etc.
|
|
293
|
-
*/
|
|
294
|
-
readonly links?: Link[];
|
|
295
|
-
}
|
|
296
|
-
|
|
297
282
|
declare const MISSION_TYPE: readonly ["story-arc", "mission", "task-force", "strike-force", "trial", "personal-story"];
|
|
298
283
|
type MissionType = typeof MISSION_TYPE[number];
|
|
299
284
|
|
|
@@ -363,25 +348,43 @@ interface MissionFlashbackData {
|
|
|
363
348
|
}
|
|
364
349
|
|
|
365
350
|
/**
|
|
366
|
-
*
|
|
351
|
+
* Metadata about a content bundle.
|
|
367
352
|
*/
|
|
368
|
-
interface
|
|
353
|
+
interface BundleHeaderData {
|
|
369
354
|
/**
|
|
370
355
|
* Name of the fork this bundle contains data for.
|
|
371
356
|
*/
|
|
372
|
-
readonly name
|
|
357
|
+
readonly name?: string;
|
|
373
358
|
/**
|
|
374
359
|
* Description of the fork.
|
|
375
360
|
*/
|
|
376
361
|
readonly description?: MarkdownString;
|
|
377
362
|
/**
|
|
378
|
-
*
|
|
363
|
+
* Url for the repository where the bundle is maintained.
|
|
364
|
+
*/
|
|
365
|
+
readonly repositoryUrl?: string;
|
|
366
|
+
/**
|
|
367
|
+
* Url for the location of the changelog.
|
|
379
368
|
*/
|
|
380
|
-
readonly
|
|
369
|
+
readonly changelogUrl?: string;
|
|
381
370
|
/**
|
|
382
371
|
* List of external links. Wiki, forums, etc.
|
|
383
372
|
*/
|
|
384
373
|
readonly links?: Link[];
|
|
374
|
+
/**
|
|
375
|
+
* Version number for this data package.
|
|
376
|
+
*/
|
|
377
|
+
readonly version?: string;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* A bundle of game data from a forked instance of the game, such as Homecoming (https://forums.homecomingservers.com/).
|
|
382
|
+
*/
|
|
383
|
+
interface BundleData {
|
|
384
|
+
/**
|
|
385
|
+
* Bundle header.
|
|
386
|
+
*/
|
|
387
|
+
readonly header?: BundleHeaderData;
|
|
385
388
|
/**
|
|
386
389
|
* List of the game server names in this fork.
|
|
387
390
|
* Torchbearer, Excelsior, etc.
|
|
@@ -407,10 +410,6 @@ interface ContentBundle {
|
|
|
407
410
|
* List of badges available on this fork.
|
|
408
411
|
*/
|
|
409
412
|
readonly badges?: BadgeData[];
|
|
410
|
-
/**
|
|
411
|
-
* Change log for this data package.
|
|
412
|
-
*/
|
|
413
|
-
readonly changelog?: Change[];
|
|
414
413
|
}
|
|
415
414
|
|
|
416
415
|
declare class AlignmentList {
|
|
@@ -670,35 +669,62 @@ interface Paged<T> {
|
|
|
670
669
|
totalPages: number;
|
|
671
670
|
}
|
|
672
671
|
|
|
673
|
-
|
|
672
|
+
type KeysOfType<T, V> = {
|
|
673
|
+
[P in keyof T]: T[P] extends V ? P : never;
|
|
674
|
+
}[keyof T];
|
|
675
|
+
declare class AbstractIndex<T> {
|
|
674
676
|
#private;
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
677
|
+
protected _values: T[];
|
|
678
|
+
protected _hashTable: Record<string, T>;
|
|
679
|
+
constructor(keyField: KeysOfType<T, string>);
|
|
680
|
+
/**
|
|
681
|
+
* Return all indexed values
|
|
682
|
+
*/
|
|
683
|
+
get values(): T[];
|
|
684
|
+
/**
|
|
685
|
+
* Load the given list of values into the index, replacing any existing data.
|
|
686
|
+
* @param values List of values.
|
|
687
|
+
*/
|
|
688
|
+
load(values: T[] | undefined): void;
|
|
689
|
+
/**
|
|
690
|
+
* Get a value from the index
|
|
691
|
+
* @param key Key string
|
|
692
|
+
*/
|
|
693
|
+
get(key: string | undefined): T | undefined;
|
|
678
694
|
}
|
|
679
695
|
|
|
680
|
-
declare class
|
|
696
|
+
declare class BadgeIndex extends AbstractIndex<Badge> {
|
|
697
|
+
#private;
|
|
698
|
+
constructor();
|
|
699
|
+
search(options?: BadgeSearchOptions): Paged<Badge>;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
declare class BundleHeader {
|
|
681
703
|
/**
|
|
682
704
|
* Name of the content bundle.
|
|
683
705
|
*/
|
|
684
|
-
readonly name
|
|
706
|
+
readonly name?: string;
|
|
685
707
|
/**
|
|
686
708
|
* Description of the fork.
|
|
687
709
|
*/
|
|
688
710
|
readonly description?: MarkdownString;
|
|
689
711
|
/**
|
|
690
|
-
*
|
|
712
|
+
* Url for the repository where the bundle is maintained.
|
|
713
|
+
*/
|
|
714
|
+
readonly repositoryUrl?: string;
|
|
715
|
+
/**
|
|
716
|
+
* Url for the location of the changelog.
|
|
691
717
|
*/
|
|
692
|
-
readonly
|
|
718
|
+
readonly changelogUrl?: string;
|
|
693
719
|
/**
|
|
694
720
|
* List of external links. Wiki, forums, etc.
|
|
695
721
|
*/
|
|
696
|
-
readonly links
|
|
722
|
+
readonly links?: Link[];
|
|
697
723
|
/**
|
|
698
|
-
*
|
|
724
|
+
* The current version of the data package.
|
|
699
725
|
*/
|
|
700
|
-
readonly
|
|
701
|
-
constructor(
|
|
726
|
+
readonly version?: string;
|
|
727
|
+
constructor(data: BundleHeaderData | undefined);
|
|
702
728
|
}
|
|
703
729
|
|
|
704
730
|
declare class Zone {
|
|
@@ -825,45 +851,65 @@ declare class Mission {
|
|
|
825
851
|
declare class CohContentDatabase {
|
|
826
852
|
#private;
|
|
827
853
|
/**
|
|
828
|
-
*
|
|
854
|
+
* Load the given content bundle, resetting the db if a bundle is already loaded.
|
|
855
|
+
* @param bundle The bundle to load.
|
|
856
|
+
*/
|
|
857
|
+
load(bundle: BundleData): void;
|
|
858
|
+
/**
|
|
859
|
+
* Header information about the content bundle.
|
|
829
860
|
*/
|
|
830
|
-
|
|
861
|
+
get header(): BundleHeader | undefined;
|
|
831
862
|
/**
|
|
832
863
|
* List of the game server names.
|
|
833
864
|
*
|
|
834
865
|
* Torchbearer, Excelsior, etc.
|
|
835
866
|
*/
|
|
836
|
-
|
|
867
|
+
get servers(): string[];
|
|
837
868
|
/**
|
|
838
869
|
* List of archetypes.
|
|
839
870
|
*/
|
|
840
|
-
|
|
871
|
+
get archetypes(): Archetype[];
|
|
872
|
+
/**
|
|
873
|
+
* Get archetype by key.
|
|
874
|
+
* @param key The key.
|
|
875
|
+
*/
|
|
876
|
+
getArchetype(key: string | undefined): Archetype | undefined;
|
|
841
877
|
/**
|
|
842
878
|
* List of game zones.
|
|
843
879
|
*/
|
|
844
|
-
|
|
880
|
+
get zones(): Zone[];
|
|
881
|
+
/**
|
|
882
|
+
* Get zone by key.
|
|
883
|
+
* @param key The key.
|
|
884
|
+
*/
|
|
885
|
+
getZone(key: string | undefined): Zone | undefined;
|
|
845
886
|
/**
|
|
846
887
|
* List of contacts.
|
|
847
888
|
*/
|
|
848
|
-
|
|
889
|
+
get contacts(): Contact[];
|
|
890
|
+
/**
|
|
891
|
+
* Get contact by key.
|
|
892
|
+
* @param key The key.
|
|
893
|
+
*/
|
|
894
|
+
getContact(key: string | undefined): Contact | undefined;
|
|
849
895
|
/**
|
|
850
896
|
* List of missions.
|
|
851
897
|
*/
|
|
852
|
-
|
|
898
|
+
get missions(): Mission[];
|
|
899
|
+
/**
|
|
900
|
+
* Get mission by key.
|
|
901
|
+
* @param key The key.
|
|
902
|
+
*/
|
|
903
|
+
getMission(key: string | undefined): Mission | undefined;
|
|
853
904
|
/**
|
|
854
905
|
* List of badges.
|
|
855
906
|
*/
|
|
856
|
-
|
|
907
|
+
get badges(): Badge[];
|
|
857
908
|
/**
|
|
858
|
-
*
|
|
859
|
-
* @param
|
|
909
|
+
* Get badge by key.
|
|
910
|
+
* @param key The key.
|
|
860
911
|
*/
|
|
861
|
-
|
|
862
|
-
getArchetype(key?: string): Archetype | undefined;
|
|
863
|
-
getZone(key?: string): Zone | undefined;
|
|
864
|
-
getContact(key?: string): Contact | undefined;
|
|
865
|
-
getMission(key?: string): Mission | undefined;
|
|
866
|
-
getBadge(key?: string): Badge | undefined;
|
|
912
|
+
getBadge(key: string | undefined): Badge | undefined;
|
|
867
913
|
/**
|
|
868
914
|
* Search, sort and filter the badge list.
|
|
869
915
|
* This is a fairly brute-forced approach and will not be as performant as loading the badge data into a traditional
|
|
@@ -879,8 +925,6 @@ declare class Key {
|
|
|
879
925
|
get value(): string;
|
|
880
926
|
}
|
|
881
927
|
|
|
882
|
-
declare const CHANGELOG: Change[];
|
|
883
|
-
|
|
884
928
|
/**
|
|
885
929
|
* Returns the URI of the given badge that can be used in {@link MarkdownString} fields.
|
|
886
930
|
*
|
|
@@ -956,4 +1000,4 @@ declare function zoneLink(target: string | Zone | ZoneData): string;
|
|
|
956
1000
|
*/
|
|
957
1001
|
declare function coalesceToArray<T>(value?: T | T[]): T[] | undefined;
|
|
958
1002
|
|
|
959
|
-
export { ALIGNMENT, type Alignment, type AlignmentExtended, AlignmentList, type AlternateData, Alternates, Archetype, type ArchetypeData, BADGE_REQUIREMENT_TYPE, BADGE_TYPE, Badge, type BadgeData, BadgeIndex, BadgeRequirement, type BadgeRequirementData, type BadgeRequirementType, type BadgeSearchOptions, type BadgeType,
|
|
1003
|
+
export { ALIGNMENT, type Alignment, type AlignmentExtended, AlignmentList, type AlternateData, Alternates, Archetype, type ArchetypeData, BADGE_REQUIREMENT_TYPE, BADGE_TYPE, Badge, type BadgeData, BadgeIndex, BadgeRequirement, type BadgeRequirementData, type BadgeRequirementType, type BadgeSearchOptions, type BadgeType, type BundleData, BundleHeader, type BundleHeaderData, CohContentDatabase, Contact, type ContactData, type Coords, ENHANCEMENT_CATEGORY, type EnhancementCategory, Key, type Link, Location, type LocationData, type LocationIcon, MISSION_TYPE, MORALITY, type MarkdownString, Mission, type MissionData, type MissionFlashbackData, type MissionType, type Morality, type MoralityExtended, MoralityList, type Paged, SEX, type Sex, Zone, type ZoneData, badgeLink, badgeUri, coalesceToArray, compareAlignment, compareByDefaultName, compareByZoneKey, compareSex, contactLink, contactUri, missionLink, missionUri, zoneLink, zoneUri };
|