coh-content-db 2.0.0-rc.10 → 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.
@@ -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 CHANGED
@@ -5,7 +5,7 @@ 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.10] - 2025-04-16
8
+ ## [2.0.0-rc.11] - 2025-04-19
9
9
 
10
10
  ### Added
11
11
 
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
24
24
  - Database instance is now immutable and bundle data is loaded in the constructor.
25
25
  - `GameMap` was renamed to `Zone`.
26
26
  - Badge partials are now referred to as badge requirements.
27
+ - `Badge.getRequirement()` now returns undefined instead of throwing an error on unknown key.
27
28
  - Exploration badge locations were moved into the badge requirements list.
28
29
  - References to zones and badges now use a standard Markdown link format (`badge://`, `map://`).
29
30
  - Some field names were updated for consistent pluralization (e.g., `name`, `icon`).
@@ -595,16 +595,16 @@ declare class Badge {
595
595
  * A description of the effect the badge will have, such as a buff or granting a temporary power.
596
596
  */
597
597
  readonly effect?: MarkdownString;
598
- /**
599
- * Represents the requirements for badges with multiple fulfillment steps, such as visiting monuments for history badges, completing missions, or collecting other badges.
600
- */
601
- readonly requirements?: BadgeRequirement[];
602
598
  /**
603
599
  * Some badges are not included in the badge total count... such as Flames of Prometheus, which can be removed by redeeming it for a Notice of the Well.
604
600
  */
605
601
  readonly ignoreInTotals: boolean;
606
602
  constructor(badgeData: BadgeData);
607
- getRequirement(key: string): BadgeRequirement;
603
+ /**
604
+ * Represents the requirements for badges with multiple fulfillment steps, such as visiting monuments for history badges, completing missions, or collecting other badges.
605
+ */
606
+ get requirements(): BadgeRequirement[];
607
+ getRequirement(key: string): BadgeRequirement | undefined;
608
608
  /**
609
609
  * Return a list of all the zone keys referenced by this badge.
610
610
  */
@@ -617,6 +617,8 @@ declare class Badge {
617
617
  declare function compareByDefaultName(a?: Badge, b?: Badge): number;
618
618
  declare function compareByZoneKey(a?: Badge, b?: Badge): number;
619
619
 
620
+ type BadgeQueryableField = 'name' | 'badge-text' | 'acquisition' | 'notes' | 'effect' | 'set-title-id';
621
+ type BadgeSortableField = 'canonical' | 'badge-name' | 'zone-key';
620
622
  interface BadgeSearchOptions {
621
623
  /**
622
624
  * Text-based search.
@@ -625,14 +627,7 @@ interface BadgeSearchOptions {
625
627
  */
626
628
  query?: {
627
629
  str?: string;
628
- on?: {
629
- name?: boolean;
630
- badgeText?: boolean;
631
- acquisition?: boolean;
632
- notes?: boolean;
633
- effect?: boolean;
634
- setTitle?: boolean;
635
- };
630
+ fields?: BadgeQueryableField[];
636
631
  };
637
632
  /**
638
633
  * Filter results matching the given values.
@@ -648,7 +643,7 @@ interface BadgeSearchOptions {
648
643
  * Badges are assumed to be in canonical order in the content bundle, and should match the in-game display order.
649
644
  */
650
645
  sort?: {
651
- by?: 'canonical' | 'badge-name' | 'zone-key';
646
+ by?: BadgeSortableField;
652
647
  dir?: 'asc' | 'desc';
653
648
  };
654
649
  /**
@@ -999,4 +994,4 @@ declare function zoneLink(target: string | Zone | ZoneData): string;
999
994
  */
1000
995
  declare function coalesceToArray<T>(value?: T | T[]): T[] | undefined;
1001
996
 
1002
- 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 };
997
+ 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 BadgeSortableField, 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 };
@@ -107,7 +107,7 @@ var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !==
107
107
  var __accessCheck$6 = (obj, member, msg) => member.has(obj) || __typeError$6("Cannot " + msg);
108
108
  var __privateGet$5 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
109
109
  var __privateAdd$6 = (obj, member, value) => member.has(obj) ? __typeError$6("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
110
- var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
110
+ var __privateSet$5 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
111
111
  var _items$1;
112
112
  class AlignmentList {
113
113
  constructor(items) {
@@ -123,7 +123,7 @@ class AlignmentList {
123
123
  this.praetorian = set.has("praetorian") || set.has("all");
124
124
  this.primal = this.hero && this.villain;
125
125
  this.all = this.hero && this.villain && this.praetorian;
126
- __privateSet$4(this, _items$1, /* @__PURE__ */ new Set());
126
+ __privateSet$5(this, _items$1, /* @__PURE__ */ new Set());
127
127
  if (this.hero) __privateGet$5(this, _items$1).add("hero");
128
128
  if (this.villain) __privateGet$5(this, _items$1).add("villain");
129
129
  if (this.praetorian) __privateGet$5(this, _items$1).add("praetorian");
@@ -162,7 +162,7 @@ var __typeError$5 = (msg) => {
162
162
  var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Cannot " + msg);
163
163
  var __privateGet$4 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
164
164
  var __privateAdd$5 = (obj, member, value) => member.has(obj) ? __typeError$5("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
165
- var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
165
+ var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
166
166
  var __privateMethod$2 = (obj, member, method) => (__accessCheck$5(obj, member, "access private method"), method);
167
167
  var _sortedValues, _Alternates_instances, compareAlternates_fn;
168
168
  class Alternates {
@@ -174,10 +174,10 @@ class Alternates {
174
174
  __privateAdd$5(this, _Alternates_instances);
175
175
  __privateAdd$5(this, _sortedValues, []);
176
176
  if (Array.isArray(value)) {
177
- __privateSet$3(this, _sortedValues, value.sort());
177
+ __privateSet$4(this, _sortedValues, value.sort());
178
178
  __privateGet$4(this, _sortedValues).sort((a, b) => __privateMethod$2(this, _Alternates_instances, compareAlternates_fn).call(this, a, b));
179
179
  } else {
180
- __privateSet$3(this, _sortedValues, [{ value }]);
180
+ __privateSet$4(this, _sortedValues, [{ value }]);
181
181
  }
182
182
  }
183
183
  getValue(alignment, sex) {
@@ -226,7 +226,7 @@ var __typeError$4 = (msg) => {
226
226
  var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
227
227
  var __privateGet$3 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
228
228
  var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
229
- var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
229
+ var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
230
230
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
231
231
  var _value, _Key_instances, validateKey_fn;
232
232
  const INVALID_KEY_PATTERN = /[^a-z0-9-]/;
@@ -235,7 +235,7 @@ class Key {
235
235
  __privateAdd$4(this, _Key_instances);
236
236
  __privateAdd$4(this, _value);
237
237
  __privateMethod$1(this, _Key_instances, validateKey_fn).call(this, value);
238
- __privateSet$2(this, _value, value);
238
+ __privateSet$3(this, _value, value);
239
239
  }
240
240
  get value() {
241
241
  return __privateGet$3(this, _value);
@@ -372,7 +372,7 @@ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !==
372
372
  var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
373
373
  var __privateGet$2 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
374
374
  var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
375
- var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
375
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
376
376
  var _items;
377
377
  class MoralityList {
378
378
  constructor(items) {
@@ -404,7 +404,7 @@ class MoralityList {
404
404
  this.paragonCityAccess = this.heroic && this.rogue;
405
405
  this.rogueIslesAccess = this.villainous && this.vigilante;
406
406
  this.all = this.primal && this.praetorian;
407
- __privateSet$1(this, _items, /* @__PURE__ */ new Set());
407
+ __privateSet$2(this, _items, /* @__PURE__ */ new Set());
408
408
  if (this.hero) __privateGet$2(this, _items).add("hero");
409
409
  if (this.vigilante) __privateGet$2(this, _items).add("vigilante");
410
410
  if (this.villain) __privateGet$2(this, _items).add("villain");
@@ -465,76 +465,109 @@ class MoralityList {
465
465
  _items = new WeakMap();
466
466
 
467
467
  var __defProp$6 = Object.defineProperty;
468
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
469
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
470
+ class AbstractIndex {
471
+ /**
472
+ * Create a new index.
473
+ * @param keyField The field of the values that will act as the key.
474
+ * @param values Values to index.
475
+ */
476
+ constructor(keyField, values) {
477
+ __publicField$6(this, "_values", []);
478
+ __publicField$6(this, "_hashTable", {});
479
+ this._values = values ?? [];
480
+ this._hashTable = {};
481
+ for (const value of this.values) {
482
+ const key = value[keyField];
483
+ if (this._hashTable[key] !== void 0) throw new Error(`Duplicate key [${key}]`);
484
+ this._hashTable[key] = value;
485
+ }
486
+ }
487
+ /**
488
+ * Return all indexed values
489
+ */
490
+ get values() {
491
+ return this._values;
492
+ }
493
+ /**
494
+ * Get a value from the index
495
+ * @param key Key string
496
+ */
497
+ get(key) {
498
+ if (!key) return void 0;
499
+ return this._hashTable[key];
500
+ }
501
+ }
502
+
503
+ var __defProp$5 = Object.defineProperty;
468
504
  var __typeError$2 = (msg) => {
469
505
  throw TypeError(msg);
470
506
  };
471
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
472
- var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
507
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
508
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
473
509
  var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
474
510
  var __privateGet$1 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
475
511
  var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
512
+ var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
476
513
  var _requirementsIndex, _zoneKeys;
477
514
  class Badge {
478
515
  constructor(badgeData) {
479
- __privateAdd$2(this, _requirementsIndex, {});
516
+ __privateAdd$2(this, _requirementsIndex);
480
517
  __privateAdd$2(this, _zoneKeys, /* @__PURE__ */ new Set());
481
518
  /**
482
519
  * The database key for this badge.
483
520
  */
484
- __publicField$6(this, "key");
521
+ __publicField$5(this, "key");
485
522
  /**
486
523
  * The type of badge.
487
524
  */
488
- __publicField$6(this, "type");
525
+ __publicField$5(this, "type");
489
526
  /**
490
527
  * The name of this badge.
491
528
  *
492
529
  * May vary by character sex or alignment.
493
530
  */
494
- __publicField$6(this, "name");
531
+ __publicField$5(this, "name");
495
532
  /**
496
533
  * The character moralities that this badge is available to.
497
534
  */
498
- __publicField$6(this, "morality");
535
+ __publicField$5(this, "morality");
499
536
  /**
500
537
  * The badge text as it appears in-game. May vary by character sex or alignment.
501
538
  */
502
- __publicField$6(this, "badgeText");
539
+ __publicField$5(this, "badgeText");
503
540
  /**
504
541
  * Short description of how to acquire the badge. Detailed instructions will be in the notes field.
505
542
  */
506
- __publicField$6(this, "acquisition");
543
+ __publicField$5(this, "acquisition");
507
544
  /**
508
545
  * Absolute URL to this badge's icon.
509
546
  *
510
547
  * May vary by character sex or alignment.
511
548
  */
512
- __publicField$6(this, "icon");
549
+ __publicField$5(this, "icon");
513
550
  /**
514
551
  * Freeform notes or tips about the badge.
515
552
  */
516
- __publicField$6(this, "notes");
553
+ __publicField$5(this, "notes");
517
554
  /**
518
555
  * List of external links. Wiki, forums, etc.
519
556
  */
520
- __publicField$6(this, "links");
557
+ __publicField$5(this, "links");
521
558
  /**
522
559
  * The id used with the in-game `/settitle` command to apply the badge.
523
560
  * The first value is the id for primal characters and the (optional) second number is the id for praetorian characters.
524
561
  */
525
- __publicField$6(this, "setTitleId");
562
+ __publicField$5(this, "setTitleId");
526
563
  /**
527
564
  * A description of the effect the badge will have, such as a buff or granting a temporary power.
528
565
  */
529
- __publicField$6(this, "effect");
530
- /**
531
- * Represents the requirements for badges with multiple fulfillment steps, such as visiting monuments for history badges, completing missions, or collecting other badges.
532
- */
533
- __publicField$6(this, "requirements");
566
+ __publicField$5(this, "effect");
534
567
  /**
535
568
  * Some badges are not included in the badge total count... such as Flames of Prometheus, which can be removed by redeeming it for a Notice of the Well.
536
569
  */
537
- __publicField$6(this, "ignoreInTotals");
570
+ __publicField$5(this, "ignoreInTotals");
538
571
  this.key = new Key(badgeData.key).value;
539
572
  this.type = badgeData.type;
540
573
  this.name = new Alternates(badgeData.name);
@@ -547,20 +580,21 @@ class Badge {
547
580
  this.effect = badgeData.effect;
548
581
  this.setTitleId = badgeData.setTitleId;
549
582
  this.ignoreInTotals = badgeData.ignoreInTotals ?? false;
550
- this.requirements = badgeData.requirements?.map((requirementData) => {
551
- if (__privateGet$1(this, _requirementsIndex)[requirementData.key]) throw new Error(`Duplicate badge requirement key [${badgeData.key}:${requirementData.key}]`);
552
- const requirement = new BadgeRequirement(requirementData);
553
- __privateGet$1(this, _requirementsIndex)[requirement.key] = requirement;
583
+ __privateSet$1(this, _requirementsIndex, new AbstractIndex("key", badgeData.requirements?.map((x) => new BadgeRequirement(x))));
584
+ for (const requirement of __privateGet$1(this, _requirementsIndex).values) {
554
585
  if (requirement.location) for (const location of requirement.location) {
555
586
  if (location.zoneKey) __privateGet$1(this, _zoneKeys).add(location.zoneKey);
556
587
  }
557
- return requirement;
558
- });
588
+ }
589
+ }
590
+ /**
591
+ * Represents the requirements for badges with multiple fulfillment steps, such as visiting monuments for history badges, completing missions, or collecting other badges.
592
+ */
593
+ get requirements() {
594
+ return __privateGet$1(this, _requirementsIndex).values;
559
595
  }
560
596
  getRequirement(key) {
561
- const result = __privateGet$1(this, _requirementsIndex)[key];
562
- if (result === void 0) throw new Error(`Unknown badge requirement key [${key}]`);
563
- return result;
597
+ return __privateGet$1(this, _requirementsIndex).get(key);
564
598
  }
565
599
  /**
566
600
  * Return a list of all the zone keys referenced by this badge.
@@ -594,42 +628,6 @@ function compareByZoneKey(a, b) {
594
628
  return aZone.localeCompare(bZone);
595
629
  }
596
630
 
597
- var __defProp$5 = Object.defineProperty;
598
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
599
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
600
- class AbstractIndex {
601
- /**
602
- * Create a new index.
603
- * @param keyField The field of the values that will act as the key.
604
- * @param values Values to index.
605
- */
606
- constructor(keyField, values) {
607
- __publicField$5(this, "_values", []);
608
- __publicField$5(this, "_hashTable", {});
609
- this._values = values ?? [];
610
- this._hashTable = {};
611
- for (const value of this.values) {
612
- const key = value[keyField];
613
- if (this._hashTable[key] !== void 0) throw new Error(`Duplicate key [${key}]`);
614
- this._hashTable[key] = value;
615
- }
616
- }
617
- /**
618
- * Return all indexed values
619
- */
620
- get values() {
621
- return this._values;
622
- }
623
- /**
624
- * Get a value from the index
625
- * @param key Key string
626
- */
627
- get(key) {
628
- if (!key) return void 0;
629
- return this._hashTable[key];
630
- }
631
- }
632
-
633
631
  var __typeError$1 = (msg) => {
634
632
  throw TypeError(msg);
635
633
  };
@@ -660,7 +658,9 @@ class BadgeIndex extends AbstractIndex {
660
658
  _BadgeIndex_instances = new WeakSet();
661
659
  satisfiesQueryPredicate_fn = function(badge, query) {
662
660
  const queryString = query?.str?.toLowerCase() ?? "";
663
- return !!((query?.on?.name ?? true) && badge.name.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || query?.on?.badgeText && badge.badgeText.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || query?.on?.acquisition && badge.acquisition?.toLowerCase().includes(queryString) || query?.on?.effect && badge.effect?.toLowerCase().includes(queryString) || query?.on?.notes && badge.notes?.toLowerCase().includes(queryString) || query?.on?.setTitle && badge.setTitleId?.some((x) => x?.toString().includes(queryString)));
661
+ const fields = query?.fields ? new Set(query?.fields) : /* @__PURE__ */ new Set(["name"]);
662
+ if (fields.size === 0) return true;
663
+ return !!(fields.has("name") && badge.name.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || fields.has("badge-text") && badge.badgeText.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || fields.has("acquisition") && badge.acquisition?.toLowerCase().includes(queryString) || fields.has("effect") && badge.effect?.toLowerCase().includes(queryString) || fields.has("notes") && badge.notes?.toLowerCase().includes(queryString) || fields.has("set-title-id") && badge.setTitleId?.some((x) => x?.toString().includes(queryString)));
664
664
  };
665
665
  satisfiesFilterPredicate_fn = function(badge, filter) {
666
666
  return (!filter?.type || badge.type === filter.type) && (!filter?.zoneKey || badge.zoneKey === filter.zoneKey) && (!filter?.morality || badge.morality.has(filter.morality));