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

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 (51) hide show
  1. package/README.md +4 -4
  2. package/dist/coh-content-db.d.ts +203 -156
  3. package/dist/coh-content-db.js +263 -197
  4. package/dist/coh-content-db.js.map +1 -1
  5. package/dist/coh-content-db.mjs +256 -191
  6. package/dist/coh-content-db.mjs.map +1 -1
  7. package/package.json +1 -1
  8. package/src/main/api/badge-data.ts +16 -9
  9. package/src/main/api/{badge-partial-data.ts → badge-requirement-data.ts} +24 -8
  10. package/src/main/api/badge-requirement-type.ts +11 -0
  11. package/src/main/api/contact-data.ts +46 -0
  12. package/src/main/api/content-bundle.ts +10 -4
  13. package/src/main/api/zone-data.ts +20 -0
  14. package/src/main/changelog.ts +5 -1
  15. package/src/main/db/badge-index.ts +17 -11
  16. package/src/main/db/{badge-partial.ts → badge-requirement.ts} +30 -11
  17. package/src/main/db/badge-search-options.ts +2 -2
  18. package/src/main/db/badge.ts +48 -36
  19. package/src/main/db/bundle-metadata.ts +3 -3
  20. package/src/main/db/coh-content-database.ts +51 -18
  21. package/src/main/db/contact.ts +59 -0
  22. package/src/main/db/zone.ts +28 -0
  23. package/src/main/index.ts +8 -10
  24. package/src/main/util.ts +44 -13
  25. package/src/test/api/badge-data.fixture.ts +9 -7
  26. package/src/test/api/badge-requirement-data.fixture.ts +17 -0
  27. package/src/test/api/badge-requirement-type.test.ts +31 -0
  28. package/src/test/api/contact-data.fixture.ts +13 -0
  29. package/src/test/api/content-bundle.fixture.ts +2 -2
  30. package/src/test/api/content-bundle.test.ts +1 -1
  31. package/src/test/api/zone-data.fixture.ts +8 -0
  32. package/src/test/db/badge-index.test.ts +73 -41
  33. package/src/test/db/badge-requirement.test.ts +180 -0
  34. package/src/test/db/badge.test.ts +190 -15
  35. package/src/test/db/coh-content-database.test.ts +110 -18
  36. package/src/test/db/contact.test.ts +96 -0
  37. package/src/test/db/zone.test.ts +36 -0
  38. package/src/test/index.test.ts +4 -2
  39. package/src/test/util.test.ts +59 -22
  40. package/src/main/api/badge-partial-type.ts +0 -8
  41. package/src/main/api/game-map-data.ts +0 -26
  42. package/src/main/api/vidiot-map-data.ts +0 -18
  43. package/src/main/api/vidiot-map-point-of-interest-data.ts +0 -30
  44. package/src/main/db/game-map.ts +0 -33
  45. package/src/main/db/vidiot-map-point-of-interest.ts +0 -39
  46. package/src/main/db/vidiot-map.ts +0 -25
  47. package/src/test/api/badge-partial-data.fixture.ts +0 -17
  48. package/src/test/api/badge-partial-type.test.ts +0 -31
  49. package/src/test/api/game-map-data.fixture.ts +0 -10
  50. package/src/test/api/vidiot-map-point-of-interest.fixture.ts +0 -10
  51. package/src/test/api/vidiot-map.fixture.ts +0 -9
@@ -1,26 +0,0 @@
1
- import { Link } from './link'
2
- import { VidiotMapData } from './vidiot-map-data'
3
-
4
- export interface GameMapData {
5
- /**
6
- * Unique key used to reference this badge.
7
- *
8
- * Keys can only contain lowercase letters, numbers and hyphens (`-`).
9
- */
10
- readonly key: string
11
-
12
- /**
13
- * The name of the map as it appears in-game.
14
- */
15
- readonly name: string
16
-
17
- /**
18
- * List of external links for this Map. Wiki, forums, etc.
19
- */
20
- readonly links?: Link[]
21
-
22
- /**
23
- * List of Vidiot Map assets for this map.
24
- */
25
- readonly vidiotMaps?: VidiotMapData[]
26
- }
@@ -1,18 +0,0 @@
1
- import { VidiotMapPointOfInterestData } from './vidiot-map-point-of-interest-data'
2
-
3
- export interface VidiotMapData {
4
- /**
5
- * URL of the map image.
6
- */
7
- readonly imageUrl: string
8
-
9
- /**
10
- * Name to display for the Vidiot map.
11
- */
12
- readonly name?: string
13
-
14
- /**
15
- * List of Points of Interest labelled on the image.
16
- */
17
- readonly pointsOfInterest?: VidiotMapPointOfInterestData[]
18
- }
@@ -1,30 +0,0 @@
1
- import { MarkdownString } from './markdown-string'
2
-
3
- export interface VidiotMapPointOfInterestData {
4
- /**
5
- * The pixel-space position of the PoI on the map graphic.
6
- *
7
- * Screen-space, pixels from top-left `[0, 0]`.
8
- */
9
- readonly pos?: [number, number]
10
-
11
- /**
12
- * Freeform notes about the PoI.
13
- */
14
- readonly notes?: MarkdownString
15
-
16
- /**
17
- * If the POI is a zone transfer, the map it transfers to.
18
- */
19
- readonly mapKey?: string
20
-
21
- /**
22
- * If the POI is a badge, the badge.
23
- */
24
- readonly badgeKey?: string
25
-
26
- /**
27
- * If the POI is a partial for a badge, the partial key.
28
- */
29
- readonly badgePartialKey?: string
30
- }
@@ -1,33 +0,0 @@
1
- import { VidiotMap } from './vidiot-map'
2
- import { Link } from '../api/link'
3
- import { GameMapData } from '../api/game-map-data'
4
- import { Key } from './key'
5
-
6
- export class GameMap {
7
- /**
8
- * The database key for this map.
9
- */
10
- readonly key: string
11
-
12
- /**
13
- * The name of the map as it appears in-game.
14
- */
15
- readonly name: string
16
-
17
- /**
18
- * List of external links for this Map. Wiki, forums, etc.
19
- */
20
- readonly links?: Link[]
21
-
22
- /**
23
- * List of Vidiot Map assets for this map.
24
- */
25
- readonly vidiotMaps?: VidiotMap[]
26
-
27
- constructor(data: GameMapData) {
28
- this.key = new Key(data.key).value
29
- this.name = data.name
30
- this.links = data.links
31
- this.vidiotMaps = data.vidiotMaps?.map(data => new VidiotMap(data))
32
- }
33
- }
@@ -1,39 +0,0 @@
1
- import { VidiotMapPointOfInterestData } from '../api/vidiot-map-point-of-interest-data'
2
- import { MarkdownString } from '../api/markdown-string'
3
-
4
- export class VidiotMapPointOfInterest {
5
- /**
6
- * The pixel-space position of the PoI on the map graphic.
7
- *
8
- * Screen-space, pixels from top-left `[0, 0]`.
9
- */
10
- readonly pos?: [number, number]
11
-
12
- /**
13
- * Freeform notes about the PoI.
14
- */
15
- readonly notes?: MarkdownString
16
-
17
- /**
18
- * If the POI is a zone transfer, the map it transfers to.
19
- */
20
- readonly mapKey?: string
21
-
22
- /**
23
- * If the POI is a badge, the badge.
24
- */
25
- readonly badgeKey?: string
26
-
27
- /**
28
- * If the POI is a partial for a badge, the partial key.
29
- */
30
- readonly badgePartialKey?: string
31
-
32
- constructor(data: VidiotMapPointOfInterestData) {
33
- this.pos = data.pos
34
- this.notes = data.notes
35
- this.mapKey = data.mapKey
36
- this.badgeKey = data.badgeKey
37
- this.badgePartialKey = data.badgePartialKey
38
- }
39
- }
@@ -1,25 +0,0 @@
1
- import { VidiotMapData } from '../api/vidiot-map-data'
2
- import { VidiotMapPointOfInterest } from './vidiot-map-point-of-interest'
3
-
4
- export class VidiotMap {
5
- /**
6
- * URL of the map image.
7
- */
8
- readonly imageUrl: string
9
-
10
- /**
11
- * Name to display for the Vidiot map.
12
- */
13
- readonly name?: string
14
-
15
- /**
16
- * List of Points of Interest labelled on the image.
17
- */
18
- readonly pointsOfInterest?: VidiotMapPointOfInterest[]
19
-
20
- constructor(data: VidiotMapData) {
21
- this.imageUrl = data.imageUrl
22
- this.name = data.name
23
- this.pointsOfInterest = data.pointsOfInterest?.map(data => new VidiotMapPointOfInterest(data))
24
- }
25
- }
@@ -1,17 +0,0 @@
1
- import { defineFixture } from 'efate'
2
- import { BADGE_PARTIAL_TYPE, BadgePartialData, ENHANCEMENT_CATEGORY, PLAQUE_TYPE } from '../../main'
3
-
4
- export const badgePartialDataFixture = defineFixture<BadgePartialData>((t) => {
5
- t.key.as(index => `badge-partial-${index}`)
6
- t.type.pickFrom([...BADGE_PARTIAL_TYPE])
7
- t.mapKey?.asString()
8
- t.loc?.asArray()
9
- t.plaqueType?.pickFrom([...PLAQUE_TYPE])
10
- t.plaqueInscription?.asLoremIpsum()
11
- t.vidiotMapKey?.asString()
12
- t.badgeKey?.as(index => `badge-${index}`)
13
- t.inventionLevel?.asNumber()
14
- t.inventionTypes?.pickFrom([...ENHANCEMENT_CATEGORY])
15
- t.inventionCount?.asNumber()
16
- t.notes?.asLoremIpsum()
17
- })
@@ -1,31 +0,0 @@
1
- import { BADGE_PARTIAL_TYPE, BadgePartialType } from '../../main'
2
-
3
- describe('BADGE_PARTIAL_TYPE', () => {
4
- test('should be an array', () => {
5
- expect(Array.isArray(BADGE_PARTIAL_TYPE)).toBeTruthy()
6
- })
7
-
8
- test('should not be empty', () => {
9
- expect(BADGE_PARTIAL_TYPE).not.toHaveLength(0)
10
- })
11
-
12
- test('should contain only strings', () => {
13
- for (const entry of BADGE_PARTIAL_TYPE) {
14
- expect(typeof entry).toBe('string')
15
- }
16
- })
17
-
18
- test('should contain all known badge partial types', () => {
19
- const expected = ['PLAQUE', 'BADGE', 'INVENTION', 'INVENTION_PLUS_ONE']
20
- for (const category of expected) {
21
- expect(BADGE_PARTIAL_TYPE).toContain(category)
22
- }
23
- })
24
- })
25
-
26
- describe('BadgePartialType', () => {
27
- test('should be a usable type', () => {
28
- const field: BadgePartialType = 'PLAQUE'
29
- expect(field).toBe('PLAQUE')
30
- })
31
- })
@@ -1,10 +0,0 @@
1
- import { GameMapData } from '../../main'
2
- import { defineFixture } from 'efate'
3
- import { vidiotMapFixture } from './vidiot-map.fixture'
4
-
5
- export const gameMapDataFixture = defineFixture<GameMapData>((t) => {
6
- t.key.as(index => `map-${index}`)
7
- t.name.as(index => `Map ${index}`)
8
- t.links?.asArray([{ href: 'https://nouri.org' }])
9
- t.vidiotMaps?.arrayOfFixture({ fixture: vidiotMapFixture })
10
- })
@@ -1,10 +0,0 @@
1
- import { defineFixture } from 'efate'
2
- import { VidiotMapPointOfInterest } from '../../main'
3
-
4
- export const vidiotMapPointOfInterestFixture = defineFixture<VidiotMapPointOfInterest>((t) => {
5
- t.pos?.as(index => [index, index])
6
- t.notes?.asLoremIpsum()
7
- t.mapKey?.as(index => `map-${index}`)
8
- t.badgeKey?.as(index => `badge-${index}`)
9
- t.badgePartialKey?.as(index => `partial-${index}`)
10
- })
@@ -1,9 +0,0 @@
1
- import { defineFixture } from 'efate'
2
- import { VidiotMap } from '../../main'
3
- import { vidiotMapPointOfInterestFixture } from './vidiot-map-point-of-interest.fixture'
4
-
5
- export const vidiotMapFixture = defineFixture<VidiotMap>((t) => {
6
- t.imageUrl.as(index => `https://nouri.org?id=${index}`)
7
- t.name?.as(index => `Vidiot Map ${index}`)
8
- t.pointsOfInterest?.arrayOfFixture({ fixture: vidiotMapPointOfInterestFixture })
9
- })