coh-content-db 2.0.0-rc.8 → 2.0.0
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/.github/workflows/build.yml +3 -1
- package/CHANGELOG.md +47 -0
- package/README.md +48 -17
- package/dist/coh-content-db.d.ts +257 -200
- package/dist/coh-content-db.js +509 -339
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +501 -335
- package/dist/coh-content-db.mjs.map +1 -1
- package/jest.config.mjs +1 -0
- package/package.json +14 -14
- package/src/main/api/badge-data.ts +13 -7
- package/src/main/api/{content-bundle.ts → bundle-data.ts} +5 -27
- package/src/main/api/bundle-header-data.ts +44 -0
- package/src/main/api/contact-data.ts +2 -1
- package/src/main/api/level-range-data.ts +4 -0
- package/src/main/api/mission-data.ts +3 -29
- package/src/main/api/mission-flashback-data.ts +31 -0
- package/src/main/api/morality.ts +27 -9
- package/src/main/api/set-title-data.ts +4 -0
- package/src/main/api/variant-context.ts +11 -0
- package/src/main/api/{alternate-data.ts → variant-data.ts} +4 -4
- package/src/main/api/zone-data.ts +24 -0
- package/src/main/api/zone-type.ts +59 -0
- package/src/main/db/abstract-index.ts +12 -16
- package/src/main/db/badge-index.ts +53 -27
- package/src/main/db/badge-requirement.ts +1 -1
- package/src/main/db/badge-search-options.ts +15 -14
- package/src/main/db/badge.ts +46 -29
- package/src/main/db/bundle-header.ts +52 -0
- package/src/main/db/coh-content-database.ts +22 -22
- package/src/main/db/contact.ts +5 -4
- package/src/main/db/level-range.ts +15 -0
- package/src/main/db/mission.ts +11 -10
- package/src/main/db/paged.ts +7 -3
- package/src/main/db/set-title-ids.ts +10 -0
- package/src/main/db/variants.ts +84 -0
- package/src/main/db/zone.ts +29 -0
- package/src/main/index.ts +14 -8
- package/src/main/util/coalesce-to-array.ts +13 -0
- package/src/main/{util.ts → util/links.ts} +8 -22
- package/src/main/util/to-date.ts +9 -0
- package/src/test/api/alignment.test.ts +2 -2
- package/src/test/api/badge-data.fixture.ts +1 -0
- package/src/test/api/badge-data.test.ts +1 -0
- package/src/test/api/bundle-data.fixture.ts +7 -0
- package/src/test/api/bundle-header-data.fixture.ts +8 -0
- package/src/test/api/morality.test.ts +31 -0
- package/src/test/api/sex.test.ts +2 -2
- package/src/test/api/zone-data.fixture.ts +1 -0
- package/src/test/db/abstract-index.test.ts +12 -43
- package/src/test/db/badge-index.test.ts +197 -101
- package/src/test/db/badge.test.ts +122 -16
- package/src/test/db/bundle-header.test.ts +89 -0
- package/src/test/db/coh-content-database.test.ts +137 -178
- package/src/test/db/contact.test.ts +2 -1
- package/src/test/db/level-range.test.ts +47 -0
- package/src/test/db/mission.test.ts +8 -6
- package/src/test/db/morality-list.test.ts +1 -1
- package/src/test/db/set-title-ids.test.ts +19 -0
- package/src/test/db/{alternates.test.ts → variants.test.ts} +24 -24
- package/src/test/db/zone.test.ts +45 -0
- package/src/test/integration.test.ts +16 -0
- package/src/test/util/coalese-to-array.test.ts +17 -0
- package/src/test/{util.test.ts → util/links.test.ts} +5 -21
- package/src/test/util/to-date.test.ts +15 -0
- package/src/main/api/change.ts +0 -17
- package/src/main/changelog.ts +0 -29
- package/src/main/db/alternates.ts +0 -67
- package/src/main/db/bundle-metadata.ts +0 -45
- package/src/test/api/content-bundle.fixture.ts +0 -6
- package/src/test/api/content-bundle.test.ts +0 -14
- package/src/test/changelog.test.ts +0 -36
- package/src/test/db/bundle-metadata.test.ts +0 -84
- package/src/test/index.test.ts +0 -14
|
@@ -8,7 +8,14 @@ interface TestObject {
|
|
|
8
8
|
describe(AbstractIndex.name, () => {
|
|
9
9
|
describe('Constructor', () => {
|
|
10
10
|
test(`should accept the key field`, () => {
|
|
11
|
-
new AbstractIndex<TestObject>('key')
|
|
11
|
+
new AbstractIndex<TestObject>('key', [])
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test(`should throw an error on duplicate key`, () => {
|
|
15
|
+
expect(() => new AbstractIndex<TestObject>('key', [
|
|
16
|
+
{ key: '1', otherValue: 1 },
|
|
17
|
+
{ key: '1', otherValue: 1 },
|
|
18
|
+
])).toThrow('Duplicate key [1]')
|
|
12
19
|
})
|
|
13
20
|
})
|
|
14
21
|
|
|
@@ -18,17 +25,14 @@ describe(AbstractIndex.name, () => {
|
|
|
18
25
|
{ key: '1', otherValue: 1 },
|
|
19
26
|
{ key: '2', otherValue: 2 },
|
|
20
27
|
]
|
|
21
|
-
const index = new AbstractIndex<TestObject>('key')
|
|
22
|
-
index.load(values)
|
|
23
|
-
|
|
28
|
+
const index = new AbstractIndex<TestObject>('key', values)
|
|
24
29
|
expect(index.values).toStrictEqual(values)
|
|
25
30
|
})
|
|
26
31
|
})
|
|
27
32
|
|
|
28
33
|
describe('get', () => {
|
|
29
34
|
test(`should return the indexed value on match`, () => {
|
|
30
|
-
const index = new AbstractIndex<TestObject>('key'
|
|
31
|
-
index.load([
|
|
35
|
+
const index = new AbstractIndex<TestObject>('key', [
|
|
32
36
|
{ key: '1', otherValue: 1 },
|
|
33
37
|
{ key: '2', otherValue: 2 },
|
|
34
38
|
])
|
|
@@ -37,50 +41,15 @@ describe(AbstractIndex.name, () => {
|
|
|
37
41
|
})
|
|
38
42
|
|
|
39
43
|
test(`should return undefined on no match`, () => {
|
|
40
|
-
const index = new AbstractIndex<TestObject>('key')
|
|
44
|
+
const index = new AbstractIndex<TestObject>('key', [])
|
|
41
45
|
|
|
42
46
|
expect(index.get('2')).toBeUndefined()
|
|
43
47
|
})
|
|
44
48
|
|
|
45
49
|
test(`should return undefined on undefined key`, () => {
|
|
46
|
-
const index = new AbstractIndex<TestObject>('key')
|
|
50
|
+
const index = new AbstractIndex<TestObject>('key', [])
|
|
47
51
|
const key = undefined
|
|
48
52
|
expect(index.get(key)).toBeUndefined()
|
|
49
53
|
})
|
|
50
54
|
})
|
|
51
|
-
|
|
52
|
-
describe('load', () => {
|
|
53
|
-
test(`should reset the index when used`, () => {
|
|
54
|
-
const index = new AbstractIndex<TestObject>('key')
|
|
55
|
-
index.load([
|
|
56
|
-
{ key: '1', otherValue: 1 },
|
|
57
|
-
{ key: '2', otherValue: 2 },
|
|
58
|
-
])
|
|
59
|
-
|
|
60
|
-
expect(index.get('2')).toStrictEqual({ key: '2', otherValue: 2 })
|
|
61
|
-
|
|
62
|
-
index.load([
|
|
63
|
-
{ key: '3', otherValue: 3 },
|
|
64
|
-
])
|
|
65
|
-
expect(index.get('1')).toBeUndefined()
|
|
66
|
-
expect(index.get('2')).toBeUndefined()
|
|
67
|
-
expect(index.get('3')).toStrictEqual({ key: '3', otherValue: 3 })
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
test(`should accept an undefined value`, () => {
|
|
71
|
-
const index = new AbstractIndex<TestObject>('key')
|
|
72
|
-
const values = undefined
|
|
73
|
-
index.load(values)
|
|
74
|
-
|
|
75
|
-
expect(index.values).toHaveLength(0)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
test(`should throw an error on duplicate key`, () => {
|
|
79
|
-
const index = new AbstractIndex<TestObject>('key')
|
|
80
|
-
expect(() => index.load([
|
|
81
|
-
{ key: '1', otherValue: 1 },
|
|
82
|
-
{ key: '1', otherValue: 1 },
|
|
83
|
-
])).toThrow('Duplicate key [1]')
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
55
|
})
|