coh-content-db 1.4.1 → 2.0.0-rc.10
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/.editorconfig +24 -0
- package/.github/workflows/build.yml +38 -0
- package/.github/workflows/pull-request.yml +32 -0
- package/.github/workflows/release.yml +52 -0
- package/CHANGELOG.md +42 -0
- package/LICENSE +24 -674
- package/README.md +101 -16
- package/dist/coh-content-db.d.ts +988 -22
- package/dist/coh-content-db.js +1044 -2
- package/dist/coh-content-db.js.map +1 -0
- package/dist/coh-content-db.mjs +1009 -0
- package/dist/coh-content-db.mjs.map +1 -0
- package/eslint.config.mjs +31 -0
- package/jest.config.mjs +7 -0
- package/package.json +31 -23
- package/rollup.config.mjs +27 -0
- package/src/main/api/alignment.ts +19 -0
- package/src/main/api/alternate-data.ts +22 -0
- package/src/main/api/archetype-data.ts +5 -0
- package/src/main/api/badge-data.ts +81 -0
- package/src/main/api/badge-requirement-data.ts +64 -0
- package/src/main/api/badge-requirement-type.ts +32 -0
- package/src/main/api/badge-type.ts +19 -0
- package/src/main/api/bundle-data.ts +47 -0
- package/src/main/api/bundle-header-data.ts +37 -0
- package/src/main/api/contact-data.ts +48 -0
- package/src/main/api/enhancement-category.ts +30 -0
- package/src/main/api/link.ts +4 -0
- package/src/main/api/location-data.ts +28 -0
- package/src/main/api/markdown-string.ts +4 -0
- package/src/main/api/mission-data.ts +83 -0
- package/src/main/api/mission-type.ts +2 -0
- package/src/main/api/morality.ts +31 -0
- package/src/main/api/sex.ts +10 -0
- package/src/main/api/zone-data.ts +20 -0
- package/src/main/db/abstract-index.ts +37 -0
- package/src/main/db/alignment-list.ts +54 -0
- package/src/main/db/alternates.ts +67 -0
- package/src/main/db/archetype.ts +14 -0
- package/src/main/db/badge-index.ts +57 -0
- package/src/main/db/badge-requirement.ts +81 -0
- package/src/main/db/badge-search-options.ts +51 -0
- package/src/main/db/badge.ts +147 -0
- package/src/main/db/bundle-header.ts +44 -0
- package/src/main/db/coh-content-database.ts +138 -0
- package/src/main/db/contact.ts +62 -0
- package/src/main/db/key.ts +18 -0
- package/src/main/db/location.ts +30 -0
- package/src/main/db/mission.ts +107 -0
- package/src/main/db/morality-list.ts +99 -0
- package/src/main/db/paged.ts +7 -0
- package/src/main/db/zone.ts +28 -0
- package/src/main/index.ts +41 -0
- package/src/main/util.ts +118 -0
- package/src/test/api/alignment.test.ts +65 -0
- package/src/test/api/archetype-data.fixture.ts +8 -0
- package/src/test/api/badge-data.fixture.ts +8 -0
- package/src/test/api/badge-data.test.ts +15 -0
- package/src/test/api/badge-requirement-data.fixture.ts +7 -0
- package/src/test/api/badge-requirement-type.test.ts +31 -0
- package/src/test/api/badge-type.test.ts +35 -0
- package/src/test/api/bundle-data.fixture.ts +6 -0
- package/src/test/api/bundle-header-data.fixture.ts +6 -0
- package/src/test/api/contact-data.fixture.ts +7 -0
- package/src/test/api/enhancement-category.test.ts +35 -0
- package/src/test/api/mission-data.fixture.ts +12 -0
- package/src/test/api/sex.test.ts +63 -0
- package/src/test/api/zone-data.fixture.ts +8 -0
- package/src/test/db/abstract-index.test.ts +55 -0
- package/src/test/db/alignment-list.test.ts +200 -0
- package/src/test/db/alternates.test.ts +188 -0
- package/src/test/db/archetype.test.ts +38 -0
- package/src/test/db/badge-index.test.ts +519 -0
- package/src/test/db/badge-requirement.test.ts +145 -0
- package/src/test/db/badge.test.ts +337 -0
- package/src/test/db/bundle-header.test.ts +76 -0
- package/src/test/db/coh-content-database.test.ts +282 -0
- package/src/test/db/contact.test.ts +97 -0
- package/src/test/db/key.test.ts +22 -0
- package/src/test/db/location.test.ts +51 -0
- package/src/test/db/mission.test.ts +171 -0
- package/src/test/db/morality-list.test.ts +457 -0
- package/src/test/db/zone.test.ts +36 -0
- package/src/test/integration.test.ts +16 -0
- package/src/test/util.test.ts +165 -0
- package/tsconfig.json +117 -0
- package/dist/_changelog.d.ts +0 -3
- package/dist/coh-content-db.nomin.js +0 -635
- package/dist/content-refence-utils.d.ts +0 -4
- package/dist/index.d.ts +0 -8
- package/dist/internal/_common.d.ts +0 -4
- package/dist/internal/archetype.d.ts +0 -10
- package/dist/internal/badge.d.ts +0 -44
- package/dist/internal/game-map.d.ts +0 -33
- package/dist/internal/server-group.d.ts +0 -24
- package/dist/types/archetype.d.ts +0 -9
- package/dist/types/badge.d.ts +0 -192
- package/dist/types/enhancement.d.ts +0 -28
- package/dist/types/game-map.d.ts +0 -47
- package/dist/types/link.d.ts +0 -4
- package/dist/types/server-group.d.ts +0 -75
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Contact } from '../../main'
|
|
2
|
+
import { contactDataFixture } from '../api/contact-data.fixture'
|
|
3
|
+
|
|
4
|
+
describe(Contact.name, () => {
|
|
5
|
+
describe('Constructor', () => {
|
|
6
|
+
test(`should accept the test fixture`, () => {
|
|
7
|
+
new Contact(contactDataFixture.create())
|
|
8
|
+
})
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
describe('key', () => {
|
|
12
|
+
test(`should be set from the data`, () => {
|
|
13
|
+
const contact = new Contact(contactDataFixture.create({ key: 'foo' }))
|
|
14
|
+
expect(contact.key).toEqual('foo')
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
describe('name', () => {
|
|
19
|
+
test(`should be set from the data`, () => {
|
|
20
|
+
const contact = new Contact(contactDataFixture.create({ name: 'foo' }))
|
|
21
|
+
expect(contact.name).toEqual('foo')
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('title', () => {
|
|
26
|
+
test(`should be set from the data`, () => {
|
|
27
|
+
const contact = new Contact(contactDataFixture.create({ title: 'foo' }))
|
|
28
|
+
expect(contact.title).toEqual('foo')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test(`should be optional`, () => {
|
|
32
|
+
const contact = new Contact(contactDataFixture.omit('title').create())
|
|
33
|
+
expect(contact.title).toBeUndefined()
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
describe('morality', () => {
|
|
38
|
+
test(`should be set from the data`, () => {
|
|
39
|
+
const contact = new Contact(contactDataFixture.create({ morality: ['hero'] }))
|
|
40
|
+
expect(contact.morality?.hero).toBeTruthy()
|
|
41
|
+
expect(contact.morality?.vigilante).toBeFalsy()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test(`should be optional`, () => {
|
|
45
|
+
const contact = new Contact(contactDataFixture.omit('morality').create())
|
|
46
|
+
expect(contact.morality?.all).toBeTruthy()
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
describe('zoneKey', () => {
|
|
51
|
+
test(`should be set from the data`, () => {
|
|
52
|
+
const contact = new Contact(contactDataFixture.create({ location: { zoneKey: 'atlas-park', coords: [1, -2, 3.5] } }))
|
|
53
|
+
expect(contact.location).toEqual({ zoneKey: 'atlas-park', coords: [1, -2, 3.5] })
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test(`should be optional`, () => {
|
|
57
|
+
const contact = new Contact(contactDataFixture.omit('location').create())
|
|
58
|
+
expect(contact.location).toBeUndefined()
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
describe('levelRange', () => {
|
|
63
|
+
test(`should be set from the data`, () => {
|
|
64
|
+
const contact = new Contact(contactDataFixture.create({ levelRange: [1, 2] }))
|
|
65
|
+
expect(contact.levelRange).toStrictEqual([1, 2])
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test(`should be optional`, () => {
|
|
69
|
+
const contact = new Contact(contactDataFixture.omit('levelRange').create())
|
|
70
|
+
expect(contact.levelRange).toBeUndefined()
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
describe('notes', () => {
|
|
75
|
+
test(`should be set from the data`, () => {
|
|
76
|
+
const contact = new Contact(contactDataFixture.create({ notes: 'foo' }))
|
|
77
|
+
expect(contact.notes).toEqual('foo')
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
test(`should be optional`, () => {
|
|
81
|
+
const contact = new Contact(contactDataFixture.omit('notes').create())
|
|
82
|
+
expect(contact.notes).toBeUndefined()
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
describe('links', () => {
|
|
87
|
+
test(`should be set from the data`, () => {
|
|
88
|
+
const contact = new Contact(contactDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
89
|
+
expect(contact.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
test(`should be optional`, () => {
|
|
93
|
+
const contact = new Contact(contactDataFixture.omit('links').create())
|
|
94
|
+
expect(contact.links).toHaveLength(0)
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Key } from '../../main'
|
|
2
|
+
|
|
3
|
+
describe(Key.name, () => {
|
|
4
|
+
describe('Constructor', () => {
|
|
5
|
+
test('should set the value field', () => {
|
|
6
|
+
const key = new Key('foo')
|
|
7
|
+
expect(key.value).toBe('foo')
|
|
8
|
+
})
|
|
9
|
+
test('should accept valid keys', () => {
|
|
10
|
+
new Key('abc')
|
|
11
|
+
new Key('123')
|
|
12
|
+
new Key('abc-123')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test('should reject invalid keys', () => {
|
|
16
|
+
expect(() => new Key('ABC')).toThrow('Invalid key')
|
|
17
|
+
expect(() => new Key('abC')).toThrow('Invalid key')
|
|
18
|
+
expect(() => new Key('abc%')).toThrow('Invalid key')
|
|
19
|
+
expect(() => new Key('abc 123')).toThrow('Invalid key')
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Location } from '../../main'
|
|
2
|
+
|
|
3
|
+
describe(Location.name, () => {
|
|
4
|
+
describe('zoneKey', () => {
|
|
5
|
+
test(`should be set from the data`, () => {
|
|
6
|
+
const location = new Location({ zoneKey: 'foo' })
|
|
7
|
+
expect(location.zoneKey).toEqual('foo')
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
test(`should be optional`, () => {
|
|
11
|
+
const location = new Location({})
|
|
12
|
+
expect(location.zoneKey).toBeUndefined()
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
describe('coords', () => {
|
|
17
|
+
test(`should be set from the data`, () => {
|
|
18
|
+
const location = new Location({ coords: [1, 2, 3] })
|
|
19
|
+
expect(location.coords).toStrictEqual([1, 2, 3])
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test(`should be optional`, () => {
|
|
23
|
+
const location = new Location({})
|
|
24
|
+
expect(location.coords).toBeUndefined()
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
describe('icon', () => {
|
|
29
|
+
test(`should be set from the data`, () => {
|
|
30
|
+
const location = new Location({ icon: 'plaque' })
|
|
31
|
+
expect(location.icon).toBe('plaque')
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test(`should be optional`, () => {
|
|
35
|
+
const location = new Location({})
|
|
36
|
+
expect(location.icon).toBeUndefined()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
describe('iconText', () => {
|
|
41
|
+
test(`should be set from the data`, () => {
|
|
42
|
+
const location = new Location({ iconText: '1' })
|
|
43
|
+
expect(location.iconText).toBe('1')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test(`should be optional`, () => {
|
|
47
|
+
const location = new Location({})
|
|
48
|
+
expect(location.iconText).toBeUndefined()
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
})
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Mission } from '../../main'
|
|
2
|
+
import { missionDataFixture, missionFlashbackDataFixture } from '../api/mission-data.fixture'
|
|
3
|
+
|
|
4
|
+
describe(Mission.name, () => {
|
|
5
|
+
describe('Constructor', () => {
|
|
6
|
+
test(`should accept the test fixture`, () => {
|
|
7
|
+
new Mission(missionDataFixture.create())
|
|
8
|
+
})
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
describe('key', () => {
|
|
12
|
+
test(`should be set from the data`, () => {
|
|
13
|
+
const mission = new Mission(missionDataFixture.create({ key: 'foo' }))
|
|
14
|
+
expect(mission.key).toEqual('foo')
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
describe('name', () => {
|
|
19
|
+
test(`should be set from the data`, () => {
|
|
20
|
+
const mission = new Mission(missionDataFixture.create({ name: 'Foo' }))
|
|
21
|
+
expect(mission.name).toEqual('Foo')
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('type', () => {
|
|
26
|
+
test(`should be set from the data`, () => {
|
|
27
|
+
const mission = new Mission(missionDataFixture.create({ type: 'story-arc' }))
|
|
28
|
+
expect(mission.type).toEqual('story-arc')
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
describe('morality', () => {
|
|
33
|
+
test(`should be set from the data`, () => {
|
|
34
|
+
const mission = new Mission(missionDataFixture.create({ morality: ['hero'] }))
|
|
35
|
+
expect(mission.morality?.hero).toBeTruthy()
|
|
36
|
+
expect(mission.morality?.vigilante).toBeFalsy()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test(`should be optional`, () => {
|
|
40
|
+
const mission = new Mission(missionDataFixture.omit('morality').create())
|
|
41
|
+
expect(mission.morality?.all).toBeTruthy()
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
describe('contactKeys', () => {
|
|
46
|
+
test(`should be set from the data`, () => {
|
|
47
|
+
const mission = new Mission(missionDataFixture.create({ contactKeys: 'foo' }))
|
|
48
|
+
expect(mission.contactKeys).toStrictEqual(['foo'])
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test(`should be optional`, () => {
|
|
52
|
+
const mission = new Mission(missionDataFixture.omit('contactKeys').create())
|
|
53
|
+
expect(mission.contactKeys).toBeUndefined()
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
describe('levelRange', () => {
|
|
58
|
+
test(`should be set from the data`, () => {
|
|
59
|
+
const mission = new Mission(missionDataFixture.create({ levelRange: [1, 2] }))
|
|
60
|
+
expect(mission.levelRange).toStrictEqual([1, 2])
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test(`should be optional`, () => {
|
|
64
|
+
const mission = new Mission(missionDataFixture.omit('levelRange').create())
|
|
65
|
+
expect(mission.levelRange).toBeUndefined()
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('notes', () => {
|
|
70
|
+
test(`should be set from the data`, () => {
|
|
71
|
+
const mission = new Mission(missionDataFixture.create({ notes: 'foo' }))
|
|
72
|
+
expect(mission.notes).toBe('foo')
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test(`should be optional`, () => {
|
|
76
|
+
const mission = new Mission(missionDataFixture.omit('notes').create())
|
|
77
|
+
expect(mission.notes).toBeUndefined()
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
describe('links', () => {
|
|
82
|
+
test('should be set from the data', () => {
|
|
83
|
+
const badge = new Mission(missionDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
84
|
+
expect(badge.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('should be optional', () => {
|
|
88
|
+
const badge = new Mission(missionDataFixture.omit('links').create())
|
|
89
|
+
expect(badge.links).toHaveLength(0)
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
describe('flashback', () => {
|
|
94
|
+
test('should be undefined if omitted', () => {
|
|
95
|
+
const badge = new Mission(missionDataFixture.omit('flashback').create())
|
|
96
|
+
expect(badge.flashback).toBeFalsy()
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
describe('id', () => {
|
|
100
|
+
test(`should be set from the data`, () => {
|
|
101
|
+
const mission = new Mission(missionDataFixture.create({ flashback: { id: 'foo' } }))
|
|
102
|
+
expect(mission.flashback?.id).toBe('foo')
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
describe('levelRange', () => {
|
|
107
|
+
test(`should be set from the data`, () => {
|
|
108
|
+
const mission = new Mission(missionDataFixture.create({ flashback: { levelRange: [1, 2] } }))
|
|
109
|
+
expect(mission.flashback?.levelRange).toStrictEqual([1, 2])
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test(`should default to the mission value`, () => {
|
|
113
|
+
const mission = new Mission(missionDataFixture.create({ levelRange: [1, 2], flashback: missionFlashbackDataFixture.omit('levelRange').create() }))
|
|
114
|
+
expect(mission.flashback?.levelRange).toStrictEqual([1, 2])
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
test(`should be optional`, () => {
|
|
118
|
+
const mission = new Mission(missionDataFixture.omit('levelRange').create({ flashback: missionFlashbackDataFixture.omit('levelRange').create() }))
|
|
119
|
+
expect(mission.flashback?.levelRange).toBeUndefined()
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
describe('name', () => {
|
|
124
|
+
test(`should be set from the data`, () => {
|
|
125
|
+
const mission = new Mission(missionDataFixture.create({ flashback: { name: 'Foo' } }))
|
|
126
|
+
expect(mission.flashback?.name).toStrictEqual('Foo')
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
test(`should default to the mission value`, () => {
|
|
130
|
+
const mission = new Mission(missionDataFixture.create({ name: 'Foo', flashback: missionFlashbackDataFixture.omit('name').create() }))
|
|
131
|
+
expect(mission.flashback?.name).toStrictEqual('Foo')
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
test(`should be optional`, () => {
|
|
135
|
+
const mission = new Mission(missionDataFixture.omit('name').create({ flashback: missionFlashbackDataFixture.omit('name').create() }))
|
|
136
|
+
expect(mission.flashback?.name).toBeUndefined()
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
describe('morality', () => {
|
|
141
|
+
test(`should be set from the data`, () => {
|
|
142
|
+
const mission = new Mission(missionDataFixture.create({ flashback: { morality: ['hero'] } }))
|
|
143
|
+
expect(mission.flashback?.morality?.hero).toBeTruthy()
|
|
144
|
+
expect(mission.flashback?.morality?.vigilante).toBeFalsy()
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
test(`should default to the mission value`, () => {
|
|
148
|
+
const mission = new Mission(missionDataFixture.create({ morality: ['hero'], flashback: missionFlashbackDataFixture.omit('morality').create() }))
|
|
149
|
+
expect(mission.flashback?.morality?.hero).toBeTruthy()
|
|
150
|
+
expect(mission.flashback?.morality?.vigilante).toBeFalsy()
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
test(`should be optional`, () => {
|
|
154
|
+
const mission = new Mission(missionDataFixture.omit('morality').create({ flashback: missionFlashbackDataFixture.omit('morality').create() }))
|
|
155
|
+
expect(mission.morality?.all).toBeTruthy()
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
describe('notes', () => {
|
|
160
|
+
test(`should be set from the data`, () => {
|
|
161
|
+
const mission = new Mission(missionDataFixture.create({ flashback: { notes: 'foo' } }))
|
|
162
|
+
expect(mission.flashback?.notes).toStrictEqual('foo')
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
test(`should be optional`, () => {
|
|
166
|
+
const mission = new Mission(missionDataFixture.create({ flashback: missionFlashbackDataFixture.omit('notes').create() }))
|
|
167
|
+
expect(mission.flashback?.notes).toBeUndefined()
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
})
|