coh-content-db 2.0.0-rc.6 → 2.0.0-rc.7

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 (65) hide show
  1. package/README.md +3 -3
  2. package/dist/coh-content-db.d.ts +384 -181
  3. package/dist/coh-content-db.js +604 -348
  4. package/dist/coh-content-db.js.map +1 -1
  5. package/dist/coh-content-db.mjs +592 -347
  6. package/dist/coh-content-db.mjs.map +1 -1
  7. package/eslint.config.mjs +1 -0
  8. package/package.json +1 -1
  9. package/src/main/api/alignment.ts +18 -2
  10. package/src/main/api/badge-data.ts +12 -42
  11. package/src/main/api/badge-requirement-data.ts +17 -35
  12. package/src/main/api/badge-requirement-type.ts +28 -7
  13. package/src/main/api/badge-type.ts +15 -15
  14. package/src/main/api/contact-data.ts +7 -5
  15. package/src/main/api/content-bundle.ts +6 -0
  16. package/src/main/api/enhancement-category.ts +26 -26
  17. package/src/main/api/location-data.ts +28 -0
  18. package/src/main/api/mission-data.ts +83 -0
  19. package/src/main/api/mission-type.ts +2 -0
  20. package/src/main/api/morality.ts +31 -0
  21. package/src/main/api/sex.ts +8 -1
  22. package/src/main/api/zone-data.ts +1 -1
  23. package/src/main/changelog.ts +5 -4
  24. package/src/main/db/alignment-list.ts +54 -0
  25. package/src/main/db/alternates.ts +15 -32
  26. package/src/main/db/badge-index.ts +11 -36
  27. package/src/main/db/badge-requirement.ts +22 -43
  28. package/src/main/db/badge-search-options.ts +4 -4
  29. package/src/main/db/badge.ts +53 -54
  30. package/src/main/db/coh-content-database.ts +28 -24
  31. package/src/main/db/contact.ts +17 -14
  32. package/src/main/db/location.ts +30 -0
  33. package/src/main/db/mission.ts +107 -0
  34. package/src/main/db/morality-list.ts +99 -0
  35. package/src/main/db/zone.ts +1 -1
  36. package/src/main/index.ts +8 -3
  37. package/src/main/util.ts +43 -3
  38. package/src/test/api/alignment.test.ts +38 -4
  39. package/src/test/api/badge-data.fixture.ts +1 -17
  40. package/src/test/api/badge-data.test.ts +3 -3
  41. package/src/test/api/badge-requirement-data.fixture.ts +1 -11
  42. package/src/test/api/badge-requirement-type.test.ts +3 -3
  43. package/src/test/api/badge-type.test.ts +5 -5
  44. package/src/test/api/contact-data.fixture.ts +0 -6
  45. package/src/test/api/content-bundle.fixture.ts +1 -17
  46. package/src/test/api/enhancement-category.test.ts +5 -5
  47. package/src/test/api/mission-data.fixture.ts +12 -0
  48. package/src/test/api/sex.test.ts +33 -1
  49. package/src/test/api/zone-data.fixture.ts +1 -1
  50. package/src/test/db/alignment-list.test.ts +200 -0
  51. package/src/test/db/alternates.test.ts +60 -56
  52. package/src/test/db/badge-index.test.ts +82 -72
  53. package/src/test/db/badge-requirement.test.ts +35 -70
  54. package/src/test/db/badge.test.ts +185 -64
  55. package/src/test/db/coh-content-database.test.ts +58 -69
  56. package/src/test/db/contact.test.ts +25 -24
  57. package/src/test/db/location.test.ts +51 -0
  58. package/src/test/db/mission.test.ts +171 -0
  59. package/src/test/db/morality-list.test.ts +457 -0
  60. package/src/test/db/zone.test.ts +4 -4
  61. package/src/test/util.test.ts +54 -1
  62. package/src/main/api/plaque-type.ts +0 -6
  63. package/src/main/db/alignments.ts +0 -17
  64. package/src/test/api/alignments.test.ts +0 -40
  65. package/src/test/api/plaque-type.test.ts +0 -31
@@ -9,26 +9,26 @@ describe(Zone.name, () => {
9
9
  })
10
10
 
11
11
  describe('key', () => {
12
- test(`should should be set from the data`, () => {
12
+ test(`should be set from the data`, () => {
13
13
  const zone = new Zone(zoneDataFixture.create({ key: 'foo' }))
14
14
  expect(zone.key).toEqual('foo')
15
15
  })
16
16
  })
17
17
 
18
18
  describe('name', () => {
19
- test(`should should be set from the data`, () => {
19
+ test(`should be set from the data`, () => {
20
20
  const zone = new Zone(zoneDataFixture.create({ name: 'foo' }))
21
21
  expect(zone.name).toEqual('foo')
22
22
  })
23
23
  })
24
24
 
25
25
  describe('links', () => {
26
- test(`should should be set from the data`, () => {
26
+ test(`should be set from the data`, () => {
27
27
  const zone = new Zone(zoneDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
28
28
  expect(zone.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
29
29
  })
30
30
 
31
- test(`should should be optional`, () => {
31
+ test(`should be optional`, () => {
32
32
  const zone = new Zone(zoneDataFixture.omit('links').create())
33
33
  expect(zone.links).toHaveLength(0)
34
34
  })
@@ -1,7 +1,8 @@
1
- import { Badge, badgeLink, badgeUri, Contact, contactLink, contactUri, Zone, zoneLink, zoneUri } from '../main'
1
+ import { Badge, badgeLink, badgeUri, coalesceToArray, Contact, contactLink, contactUri, Mission, missionLink, missionUri, Zone, zoneLink, zoneUri } from '../main'
2
2
  import { badgeDataFixture } from './api/badge-data.fixture'
3
3
  import { zoneDataFixture } from './api/zone-data.fixture'
4
4
  import { contactDataFixture } from './api/contact-data.fixture'
5
+ import { missionDataFixture } from './api/mission-data.fixture'
5
6
 
6
7
  describe(badgeUri.name, () => {
7
8
  test('should return the expected pattern', () => {
@@ -75,6 +76,42 @@ describe(contactLink.name, () => {
75
76
  })
76
77
  })
77
78
 
79
+ describe(missionUri.name, () => {
80
+ test('should return the expected pattern', () => {
81
+ expect(missionUri('foo')).toBe('mission://foo')
82
+ expect(missionUri('bar')).toBe('mission://bar')
83
+ expect(missionUri('foo-bar')).toBe('mission://foo-bar')
84
+ })
85
+
86
+ test('should accept a Mission object', () => {
87
+ const mission = new Mission(missionDataFixture.create({ key: 'foo' }))
88
+ expect(missionUri(mission)).toBe('mission://foo')
89
+ })
90
+
91
+ test('should accept a MissionData object', () => {
92
+ const mission = missionDataFixture.create({ key: 'foo' })
93
+ expect(missionUri(mission)).toBe('mission://foo')
94
+ })
95
+ })
96
+
97
+ describe(missionLink.name, () => {
98
+ test('should return the expected pattern', () => {
99
+ expect(missionLink('foo')).toBe('[foo](mission://foo)')
100
+ expect(missionLink('bar')).toBe('[bar](mission://bar)')
101
+ expect(missionLink('foo-bar')).toBe('[foo-bar](mission://foo-bar)')
102
+ })
103
+
104
+ test('should accept a Mission object', () => {
105
+ const mission = new Mission(missionDataFixture.create({ key: 'foo' }))
106
+ expect(missionLink(mission)).toBe('[foo](mission://foo)')
107
+ })
108
+
109
+ test('should accept a MissionData object', () => {
110
+ const mission = missionDataFixture.create({ key: 'foo' })
111
+ expect(missionLink(mission)).toBe('[foo](mission://foo)')
112
+ })
113
+ })
114
+
78
115
  describe(zoneUri.name, () => {
79
116
  test('should return the expected pattern', () => {
80
117
  expect(zoneUri('foo')).toBe('zone://foo')
@@ -110,3 +147,19 @@ describe(zoneLink.name, () => {
110
147
  expect(zoneLink(zone)).toBe('[foo](zone://foo)')
111
148
  })
112
149
  })
150
+
151
+ describe(coalesceToArray.name, () => {
152
+ test('should return an array unmodified', () => {
153
+ expect(coalesceToArray(['a', 'b'])).toStrictEqual(['a', 'b'])
154
+ expect(coalesceToArray([1, 2])).toStrictEqual([1, 2])
155
+ })
156
+
157
+ test('should return a single value as a single-value array', () => {
158
+ expect(coalesceToArray('a')).toStrictEqual(['a'])
159
+ expect(coalesceToArray(1)).toStrictEqual([1])
160
+ })
161
+
162
+ test('should return undefined value as undefined', () => {
163
+ expect(coalesceToArray()).toBeUndefined()
164
+ })
165
+ })
@@ -1,6 +0,0 @@
1
- export const PLAQUE_TYPE = [
2
- 'WALL_PLAQUE',
3
- 'MONUMENT',
4
- ]
5
-
6
- export type PlaqueType = typeof PLAQUE_TYPE[number]
@@ -1,17 +0,0 @@
1
- import { Alignment } from '../api/alignment'
2
-
3
- export class Alignments {
4
- readonly items: Alignment[]
5
- readonly hero: boolean
6
- readonly villain: boolean
7
- readonly praetorian: boolean
8
- readonly primal: boolean
9
-
10
- constructor(raw: Alignment[]) {
11
- this.items = raw
12
- this.hero = raw.includes('H')
13
- this.villain = raw.includes('V')
14
- this.praetorian = raw.includes('P')
15
- this.primal = !this.praetorian && (this.hero || this.villain)
16
- }
17
- }
@@ -1,40 +0,0 @@
1
- import { Alignments } from '../../main'
2
-
3
- describe(Alignments.name, () => {
4
- test('should return the raw array', () => {
5
- expect(new Alignments(['H', 'V']).items).toStrictEqual(['H', 'V'])
6
- })
7
-
8
- test('should detect a hero', () => {
9
- expect(new Alignments(['H', 'V']).hero).toBeTruthy()
10
- })
11
-
12
- test('should detect a villain', () => {
13
- expect(new Alignments(['H', 'V']).villain).toBeTruthy()
14
- })
15
-
16
- test('should detect a praetorian', () => {
17
- expect(new Alignments(['H', 'V', 'P']).praetorian).toBeTruthy()
18
- })
19
-
20
- test('should detect a primal', () => {
21
- expect(new Alignments(['H', 'V']).primal).toBeTruthy()
22
- })
23
-
24
- test('should not falsely detect a hero', () => {
25
- expect(new Alignments(['V']).hero).toBeFalsy()
26
- })
27
-
28
- test('should not falsely detect a villain', () => {
29
- expect(new Alignments(['H']).villain).toBeFalsy()
30
- })
31
-
32
- test('should not falsely detect a praetorian', () => {
33
- expect(new Alignments(['V']).praetorian).toBeFalsy()
34
- })
35
-
36
- test('should falsely detect a primal', () => {
37
- expect(new Alignments(['H', 'V', 'P']).primal).toBeFalsy()
38
- expect(new Alignments(['P']).primal).toBeFalsy()
39
- })
40
- })
@@ -1,31 +0,0 @@
1
- import { PLAQUE_TYPE, PlaqueType } from '../../main'
2
-
3
- describe('PLAQUE_TYPE', () => {
4
- test('should be an array', () => {
5
- expect(Array.isArray(PLAQUE_TYPE)).toBeTruthy()
6
- })
7
-
8
- test('should not be empty', () => {
9
- expect(PLAQUE_TYPE).not.toHaveLength(0)
10
- })
11
-
12
- test('should contain only strings', () => {
13
- for (const entry of PLAQUE_TYPE) {
14
- expect(typeof entry).toBe('string')
15
- }
16
- })
17
-
18
- test('should contain all known plaque types', () => {
19
- const expected = ['WALL_PLAQUE', 'MONUMENT']
20
- for (const category of expected) {
21
- expect(PLAQUE_TYPE).toContain(category)
22
- }
23
- })
24
- })
25
-
26
- describe('PlaqueType', () => {
27
- test('should be a usable type', () => {
28
- const field: PlaqueType = 'WALL_PLAQUE'
29
- expect(field).toBe('WALL_PLAQUE')
30
- })
31
- })