coh-content-db 2.0.0-rc.15 → 2.0.0-rc.17

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 (45) hide show
  1. package/.github/workflows/build.yml +1 -1
  2. package/CHANGELOG.md +3 -1
  3. package/README.md +9 -1
  4. package/dist/coh-content-db.d.ts +93 -44
  5. package/dist/coh-content-db.js +230 -121
  6. package/dist/coh-content-db.js.map +1 -1
  7. package/dist/coh-content-db.mjs +228 -121
  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 +2 -1
  12. package/src/main/api/contact-data.ts +2 -1
  13. package/src/main/api/level-range-data.ts +4 -0
  14. package/src/main/api/mission-data.ts +3 -29
  15. package/src/main/api/mission-flashback-data.ts +31 -0
  16. package/src/main/api/set-title-data.ts +4 -0
  17. package/src/main/api/zone-data.ts +24 -0
  18. package/src/main/api/zone-type.ts +59 -0
  19. package/src/main/db/alternates.ts +1 -1
  20. package/src/main/db/badge-index.ts +10 -8
  21. package/src/main/db/badge-requirement.ts +1 -1
  22. package/src/main/db/badge.ts +5 -4
  23. package/src/main/db/bundle-header.ts +1 -1
  24. package/src/main/db/contact.ts +5 -4
  25. package/src/main/db/level-range.ts +15 -0
  26. package/src/main/db/mission.ts +9 -8
  27. package/src/main/db/set-title-ids.ts +10 -0
  28. package/src/main/db/zone.ts +29 -0
  29. package/src/main/index.ts +8 -2
  30. package/src/main/util/coalesce-to-array.ts +13 -0
  31. package/src/main/{util.ts → util/links.ts} +8 -22
  32. package/src/test/api/alignment.test.ts +2 -2
  33. package/src/test/api/sex.test.ts +2 -2
  34. package/src/test/api/zone-data.fixture.ts +1 -0
  35. package/src/test/db/badge.test.ts +24 -11
  36. package/src/test/db/contact.test.ts +2 -1
  37. package/src/test/db/level-range.test.ts +47 -0
  38. package/src/test/db/mission.test.ts +8 -6
  39. package/src/test/db/morality-list.test.ts +1 -1
  40. package/src/test/db/set-title-ids.test.ts +19 -0
  41. package/src/test/db/zone.test.ts +45 -0
  42. package/src/test/util/coalese-to-array.test.ts +17 -0
  43. package/src/test/{util.test.ts → util/links.test.ts} +5 -21
  44. package/src/test/{to-date.test.ts → util/to-date.test.ts} +1 -1
  45. /package/src/main/{to-date.ts → util/to-date.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  name: Build
2
2
  on:
3
3
  push:
4
- branches: '*'
4
+ branches: [ '*' ]
5
5
  jobs:
6
6
  build:
7
7
  runs-on: ubuntu-latest
package/CHANGELOG.md CHANGED
@@ -5,12 +5,14 @@ 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.15] - 2025-04-23
8
+ ## [2.0.0-rc.17] - 2025-12-16
9
9
 
10
10
  ### Added
11
11
 
12
12
  - Introduced a simple indexing and search function for badge names, text, and acquisition info.
13
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.
14
16
  - Badges now require a `releaseDate`.
15
17
  - Bundle header is now mandatory and requires at least a name, version and last update time.
16
18
  - Added GitHub Actions for continuous integration (CI).
package/README.md CHANGED
@@ -111,9 +111,17 @@ for (const badge of db.badges) {
111
111
  }
112
112
  ```
113
113
 
114
- ## Publish
114
+ ## Release
115
+
116
+ 1. Determine the next [Semantic Release](https://semver.org) version, i.e. `2.0.0-rc.16`
117
+ 2. Update the version and release notes in the [CHANGELOG.md](CHANGELOG.md).
118
+ * Commit with the comment `Changelog <semver>`
119
+ 3. `npm version <semver>` - Updates the package.json and commits + tags new version. Use semver syntax for version number.
120
+ 4. `npm run push` - Push the commit and tags to remote.
121
+ 5. GitHub will release automatically.
115
122
 
116
123
  Tags matching the pattern `v<X>.<Y>.<Z>` will attempt to publish to npm (this can only be achieved by the package manager (n15g).
124
+ The `npm version` command automatically prepends the `v` prefix to the version number.
117
125
 
118
126
  ```shell
119
127
  npm version 1.4.x
@@ -163,6 +163,11 @@ type MoralityExtended = Morality
163
163
  */
164
164
  | 'all';
165
165
 
166
+ /**
167
+ * The id, or a pair of ids [primal, praetorian] that are used with the /settitle command to set a badge
168
+ */
169
+ type SetTitleData = [number, number?];
170
+
166
171
  interface BadgeData {
167
172
  /**
168
173
  * Unique key used to reference this badge.
@@ -214,7 +219,7 @@ interface BadgeData {
214
219
  * The id used with the in-game `/settitle` command to apply the badge.
215
220
  * The first value is the id for primal characters and the (optional) second number is the id for praetorian characters.
216
221
  */
217
- readonly setTitleId?: [number, number?];
222
+ readonly setTitleId?: SetTitleData;
218
223
  /**
219
224
  * A description of the effect the badge will have, such as a buff or granting a temporary power.
220
225
  */
@@ -229,6 +234,14 @@ interface BadgeData {
229
234
  readonly ignoreInTotals?: boolean;
230
235
  }
231
236
 
237
+ declare const ZONE_TYPE: readonly ["city", "echo", "tutorial", "trial", "hazard", "mayhem", "safeguard", "mission", "incarnate", "co-op", "pvp", "arena", "building", "other"];
238
+ type ZoneType = typeof ZONE_TYPE[number];
239
+
240
+ /**
241
+ * Can be an array of [min, max], just the [min], or a number representing the minimum value
242
+ */
243
+ type LevelRangeData = [number, number?] | number;
244
+
232
245
  interface ZoneData {
233
246
  /**
234
247
  * Unique key used to reference this zone.
@@ -240,6 +253,22 @@ interface ZoneData {
240
253
  * The name of the zone as it appears in-game.
241
254
  */
242
255
  readonly name: string;
256
+ /**
257
+ * The type of zone.
258
+ */
259
+ readonly type: ZoneType;
260
+ /**
261
+ * The character moralities that this zone is accessible by.
262
+ */
263
+ readonly morality?: MoralityExtended | MoralityExtended[];
264
+ /**
265
+ * The level range this zone is recommended for.
266
+ */
267
+ readonly levelRange?: LevelRangeData;
268
+ /**
269
+ * Freeform notes or tips about the zone.
270
+ */
271
+ readonly notes?: MarkdownString;
243
272
  /**
244
273
  * List of external links. Wiki, forums, etc.
245
274
  */
@@ -272,7 +301,7 @@ interface ContactData {
272
301
  /**
273
302
  * The level range this contact will offer missions for.
274
303
  */
275
- readonly levelRange?: [number, number?];
304
+ readonly levelRange?: LevelRangeData;
276
305
  /**
277
306
  * Freeform notes or tips about the contact.
278
307
  */
@@ -286,6 +315,29 @@ interface ContactData {
286
315
  declare const MISSION_TYPE: readonly ["story-arc", "mission", "task-force", "strike-force", "trial", "personal-story"];
287
316
  type MissionType = typeof MISSION_TYPE[number];
288
317
 
318
+ interface MissionFlashbackData {
319
+ /**
320
+ * The id of the mission as seen in the Flashback menu, i.e. '14.01'.
321
+ */
322
+ readonly id: string;
323
+ /**
324
+ * The level range this mission appears under as a Flashback.
325
+ */
326
+ readonly levelRange?: LevelRangeData;
327
+ /**
328
+ * The name as it appears in the Flashback list. Leave undefined if the same as the base mission.
329
+ */
330
+ readonly name?: string;
331
+ /**
332
+ * The character moralities that the mission will appear for in the Flashback list. Leave undefined if the same as the base mission.
333
+ */
334
+ readonly morality?: MoralityExtended | MoralityExtended[];
335
+ /**
336
+ * Freeform notes or tips about the Flashback version of the mission.
337
+ */
338
+ readonly notes?: MarkdownString;
339
+ }
340
+
289
341
  interface MissionData {
290
342
  /**
291
343
  * Unique key used to reference this mission.
@@ -314,7 +366,7 @@ interface MissionData {
314
366
  /**
315
367
  * The level range this mission is available for.
316
368
  */
317
- readonly levelRange?: [number, number?];
369
+ readonly levelRange?: LevelRangeData;
318
370
  /**
319
371
  * Freeform notes or tips about the mission.
320
372
  */
@@ -328,28 +380,6 @@ interface MissionData {
328
380
  */
329
381
  readonly flashback?: MissionFlashbackData;
330
382
  }
331
- interface MissionFlashbackData {
332
- /**
333
- * The id of the mission as seen in the Flashback menu, i.e. '14.01'.
334
- */
335
- readonly id: string;
336
- /**
337
- * The level range this mission appears under as a Flashback. Leave undefined if the same as the base mission.
338
- */
339
- readonly levelRange?: [number, number?];
340
- /**
341
- * The name as it appears in the Flashback list. Leave undefined if the same as the base mission.
342
- */
343
- readonly name?: string;
344
- /**
345
- * The character moralities that the mission will appear for in the Flashback list. Leave undefined if the same as the base mission.
346
- */
347
- readonly morality?: MoralityExtended | MoralityExtended[];
348
- /**
349
- * Freeform notes or tips about the Flashback version of the mission.
350
- */
351
- readonly notes?: MarkdownString;
352
- }
353
383
 
354
384
  /**
355
385
  * Metadata about a content bundle.
@@ -554,6 +584,12 @@ declare class MoralityList {
554
584
  has(morality?: MoralityExtended): boolean;
555
585
  }
556
586
 
587
+ declare class SetTitleIds {
588
+ readonly primal: number;
589
+ readonly praetorian?: number;
590
+ constructor(value: SetTitleData);
591
+ }
592
+
557
593
  declare class Badge {
558
594
  #private;
559
595
  /**
@@ -604,7 +640,7 @@ declare class Badge {
604
640
  * The id used with the in-game `/settitle` command to apply the badge.
605
641
  * The first value is the id for primal characters and the (optional) second number is the id for praetorian characters.
606
642
  */
607
- readonly setTitleId?: [number, number?];
643
+ readonly setTitleId?: SetTitleIds;
608
644
  /**
609
645
  * A description of the effect the badge will have, such as a buff or granting a temporary power.
610
646
  */
@@ -737,6 +773,12 @@ declare class BundleHeader {
737
773
  constructor(data: BundleHeaderData);
738
774
  }
739
775
 
776
+ declare class LevelRange {
777
+ readonly min: number;
778
+ readonly max?: number;
779
+ constructor(value: LevelRangeData);
780
+ }
781
+
740
782
  declare class Zone {
741
783
  /**
742
784
  * Unique key used to reference this zone.
@@ -748,6 +790,22 @@ declare class Zone {
748
790
  * The name of the zone as it appears in-game.
749
791
  */
750
792
  readonly name: string;
793
+ /**
794
+ * The type of zone.
795
+ */
796
+ readonly type: ZoneType;
797
+ /**
798
+ * The character moralities that this zone is accessible by.
799
+ */
800
+ readonly morality: MoralityList;
801
+ /**
802
+ * The level range this zone is recommended for.
803
+ */
804
+ readonly levelRange?: LevelRange;
805
+ /**
806
+ * Freeform notes or tips about the zone.
807
+ */
808
+ readonly notes?: MarkdownString;
751
809
  /**
752
810
  * List of external links. Wiki, forums, etc.
753
811
  */
@@ -773,7 +831,7 @@ declare class Contact {
773
831
  /**
774
832
  * The character moralities that this contact will interact with.
775
833
  */
776
- readonly morality?: MoralityList;
834
+ readonly morality: MoralityList;
777
835
  /**
778
836
  * The location of this contact.
779
837
  */
@@ -781,7 +839,7 @@ declare class Contact {
781
839
  /**
782
840
  * The level range this contact will offer missions for.
783
841
  */
784
- readonly levelRange?: [number, number?];
842
+ readonly levelRange?: LevelRange;
785
843
  /**
786
844
  * Freeform notes or tips about the contact.
787
845
  */
@@ -821,7 +879,7 @@ declare class Mission {
821
879
  /**
822
880
  * The level range this mission is available for.
823
881
  */
824
- readonly levelRange?: [number, number?];
882
+ readonly levelRange?: LevelRange;
825
883
  /**
826
884
  * Freeform notes or tips about the mission.
827
885
  */
@@ -839,15 +897,15 @@ declare class Mission {
839
897
  */
840
898
  readonly id: string;
841
899
  /**
842
- * The level range this mission appears under as a Flashback. Leave undefined if the same as the base mission.
900
+ * The level range this mission appears under as a Flashback.
843
901
  */
844
- readonly levelRange?: [number, number?];
902
+ readonly levelRange?: LevelRange;
845
903
  /**
846
- * The name as it appears in the Flashback list. Leave undefined if the same as the base mission.
904
+ * The name as it appears in the Flashback list.
847
905
  */
848
906
  readonly name?: string;
849
907
  /**
850
- * The character moralities that the mission will appear for in the Flashback list. Leave undefined if the same as the base mission.
908
+ * The character moralities that the mission will appear for in the Flashback list.
851
909
  */
852
910
  readonly morality?: MoralityList;
853
911
  /**
@@ -999,15 +1057,6 @@ declare function zoneUri(target: string | Zone | ZoneData): string;
999
1057
  * @param target The {@link Zone} or zone key to target.
1000
1058
  */
1001
1059
  declare function zoneLink(target: string | Zone | ZoneData): string;
1002
- /**
1003
- * For fields that accept either an array of values or a single value, coalesces the value to an array.
1004
- *
1005
- * Arrays are returned as-is.
1006
- * Single values are returned as a single-value array.
1007
- * Undefined values are returned as undefined.
1008
- *
1009
- * @param value The value to coalesce.
1010
- */
1011
- declare function coalesceToArray<T>(value?: T | T[]): T[] | undefined;
1012
1060
 
1013
- export { ALIGNMENT, type Alignment, type AlignmentExtended, AlignmentList, type AlternateData, Alternates, Archetype, type ArchetypeData, BADGE_REQUIREMENT_TYPE, BADGE_TYPE, Badge, type BadgeData, BadgeIndex, type BadgeQueryableField, BadgeRequirement, type BadgeRequirementData, type BadgeRequirementType, type BadgeSearchOptions, type BadgeSort, 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, compareByReleaseDate, compareByZoneKey, compareSex, contactLink, contactUri, missionLink, missionUri, zoneLink, zoneUri };
1061
+ export { ALIGNMENT, AlignmentList, Alternates, Archetype, BADGE_REQUIREMENT_TYPE, BADGE_TYPE, Badge, BadgeIndex, BadgeRequirement, BundleHeader, CohContentDatabase, Contact, ENHANCEMENT_CATEGORY, Key, LevelRange, Location, MISSION_TYPE, MORALITY, Mission, MoralityList, SEX, SetTitleIds, ZONE_TYPE, Zone, badgeLink, badgeUri, compareAlignment, compareByDefaultName, compareByReleaseDate, compareByZoneKey, compareSex, contactLink, contactUri, missionLink, missionUri, zoneLink, zoneUri };
1062
+ export type { Alignment, AlignmentExtended, AlternateData, ArchetypeData, BadgeData, BadgeQueryableField, BadgeRequirementData, BadgeRequirementType, BadgeSearchOptions, BadgeSort, BadgeType, BundleData, BundleHeaderData, ContactData, Coords, EnhancementCategory, LevelRangeData, Link, LocationData, LocationIcon, MarkdownString, MissionData, MissionFlashbackData, MissionType, Morality, MoralityExtended, Paged, SetTitleData, Sex, ZoneData, ZoneType };