coh-content-db 2.0.0-rc.8 → 2.0.0-rc.9
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/CHANGELOG.md +38 -0
- package/README.md +24 -7
- package/dist/coh-content-db.d.ts +45 -48
- package/dist/coh-content-db.js +22 -51
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +22 -50
- package/dist/coh-content-db.mjs.map +1 -1
- package/package.json +1 -1
- package/src/main/api/{content-bundle.ts → bundle-data.ts} +5 -27
- package/src/main/api/bundle-header-data.ts +37 -0
- package/src/main/db/bundle-header.ts +44 -0
- package/src/main/db/coh-content-database.ts +8 -8
- package/src/main/index.ts +3 -4
- package/src/test/api/bundle-data.fixture.ts +6 -0
- package/src/test/api/bundle-header-data.fixture.ts +6 -0
- package/src/test/db/bundle-header.test.ts +76 -0
- package/src/test/db/coh-content-database.test.ts +42 -42
- package/src/test/integration.test.ts +16 -0
- package/src/main/api/change.ts +0 -17
- package/src/main/changelog.ts +0 -29
- 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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { BundleHeader } from '../../main'
|
|
2
|
+
import { bundleHeaderDataFixture } from '../api/bundle-header-data.fixture'
|
|
3
|
+
|
|
4
|
+
describe(BundleHeader.name, () => {
|
|
5
|
+
describe('name', () => {
|
|
6
|
+
test(`should be set from the data`, () => {
|
|
7
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ name: 'foo' }))
|
|
8
|
+
expect(header.name).toEqual('foo')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test(`should be optional`, () => {
|
|
12
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('name').create())
|
|
13
|
+
expect(header.name).toBeUndefined()
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
describe('description', () => {
|
|
18
|
+
test(`should be set from the data`, () => {
|
|
19
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ description: 'foo' }))
|
|
20
|
+
expect(header.description).toEqual('foo')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test(`should be optional`, () => {
|
|
24
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('description').create())
|
|
25
|
+
expect(header.description).toBeUndefined()
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
describe('repositoryUrl', () => {
|
|
30
|
+
test(`should be set from the data`, () => {
|
|
31
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ repositoryUrl: 'foo' }))
|
|
32
|
+
expect(header.repositoryUrl).toEqual('foo')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test(`should be optional`, () => {
|
|
36
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('repositoryUrl').create())
|
|
37
|
+
expect(header.repositoryUrl).toBeUndefined()
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
describe('changelogUrl', () => {
|
|
42
|
+
test(`should be set from the data`, () => {
|
|
43
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ changelogUrl: 'foo' }))
|
|
44
|
+
expect(header.changelogUrl).toEqual('foo')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test(`should be optional`, () => {
|
|
48
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('changelogUrl').create())
|
|
49
|
+
expect(header.changelogUrl).toBeUndefined()
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
describe('links', () => {
|
|
54
|
+
test(`should be set from the data`, () => {
|
|
55
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
56
|
+
expect(header.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test(`should be optional`, () => {
|
|
60
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('links').create())
|
|
61
|
+
expect(header.links).toHaveLength(0)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
describe('version', () => {
|
|
66
|
+
test(`should be set from the data`, () => {
|
|
67
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ version: 'foo' }))
|
|
68
|
+
expect(header.version).toEqual('foo')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test(`should be optional`, () => {
|
|
72
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('version').create())
|
|
73
|
+
expect(header.version).toBeUndefined()
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
})
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { CohContentDatabase } from '../../main'
|
|
2
|
-
import { contentBundleFixture } from '../api/content-bundle.fixture'
|
|
3
2
|
import { archetypeDataFixture } from '../api/archetype-data.fixture'
|
|
4
3
|
import { badgeDataFixture } from '../api/badge-data.fixture'
|
|
5
4
|
import { zoneDataFixture } from '../api/zone-data.fixture'
|
|
6
5
|
import { contactDataFixture } from '../api/contact-data.fixture'
|
|
7
6
|
import { missionDataFixture } from '../api/mission-data.fixture'
|
|
7
|
+
import { bundleDataFixture } from '../api/bundle-data.fixture'
|
|
8
8
|
|
|
9
9
|
describe(CohContentDatabase.name, () => {
|
|
10
10
|
describe('load', () => {
|
|
11
11
|
test('should load a basic bundle', () => {
|
|
12
12
|
const database = new CohContentDatabase()
|
|
13
|
-
database.load(
|
|
13
|
+
database.load({})
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
test('should reset the database if load is called again', () => {
|
|
17
17
|
const database = new CohContentDatabase()
|
|
18
|
-
database.load(
|
|
19
|
-
name: '
|
|
18
|
+
database.load(bundleDataFixture.create({
|
|
19
|
+
header: { name: 'Homecoming' },
|
|
20
20
|
servers: ['Test'],
|
|
21
21
|
archetypes: [archetypeDataFixture.create()],
|
|
22
22
|
zones: [zoneDataFixture.create()],
|
|
@@ -25,7 +25,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
25
25
|
badges: [badgeDataFixture.create()],
|
|
26
26
|
}))
|
|
27
27
|
|
|
28
|
-
expect(database.
|
|
28
|
+
expect(database.header?.name).toEqual('Homecoming')
|
|
29
29
|
expect(database.servers).toHaveLength(1)
|
|
30
30
|
expect(database.archetypes).toHaveLength(1)
|
|
31
31
|
expect(database.zones).toHaveLength(1)
|
|
@@ -33,8 +33,8 @@ describe(CohContentDatabase.name, () => {
|
|
|
33
33
|
expect(database.missions).toHaveLength(1)
|
|
34
34
|
expect(database.badges).toHaveLength(1)
|
|
35
35
|
|
|
36
|
-
database.load(
|
|
37
|
-
expect(database.
|
|
36
|
+
database.load(bundleDataFixture.create({ header: { name: 'Reset' } }))
|
|
37
|
+
expect(database.header?.name).toEqual('Reset')
|
|
38
38
|
expect(database.servers).toHaveLength(0)
|
|
39
39
|
expect(database.archetypes).toHaveLength(0)
|
|
40
40
|
expect(database.zones).toHaveLength(0)
|
|
@@ -44,25 +44,25 @@ describe(CohContentDatabase.name, () => {
|
|
|
44
44
|
})
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
-
describe('
|
|
48
|
-
test(`should
|
|
47
|
+
describe('header', () => {
|
|
48
|
+
test(`should be undefined if not initialized`, () => {
|
|
49
49
|
const database = new CohContentDatabase()
|
|
50
|
-
expect(database.
|
|
50
|
+
expect(database.header).toBeUndefined()
|
|
51
51
|
})
|
|
52
52
|
|
|
53
53
|
test(`should load values from bundle`, () => {
|
|
54
54
|
const database = new CohContentDatabase()
|
|
55
|
-
database.load(
|
|
56
|
-
.create({ name: '
|
|
55
|
+
database.load(bundleDataFixture
|
|
56
|
+
.create({ header: { name: 'Homecoming' } }))
|
|
57
57
|
|
|
58
|
-
expect(database.
|
|
58
|
+
expect(database.header?.name).toBe('Homecoming')
|
|
59
59
|
})
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
describe('servers', () => {
|
|
63
63
|
test(`should accept an undefined field`, () => {
|
|
64
64
|
const database = new CohContentDatabase()
|
|
65
|
-
database.load(
|
|
65
|
+
database.load(bundleDataFixture
|
|
66
66
|
.omit('servers')
|
|
67
67
|
.create())
|
|
68
68
|
|
|
@@ -76,7 +76,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
76
76
|
|
|
77
77
|
test(`should load values from bundle`, () => {
|
|
78
78
|
const database = new CohContentDatabase()
|
|
79
|
-
database.load(
|
|
79
|
+
database.load(bundleDataFixture
|
|
80
80
|
.create({ servers: ['Foo', 'Bar'] }))
|
|
81
81
|
|
|
82
82
|
expect(database.servers).toStrictEqual(['Foo', 'Bar'])
|
|
@@ -86,7 +86,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
86
86
|
describe('archetypes', () => {
|
|
87
87
|
test(`should throw an error on duplicate key`, () => {
|
|
88
88
|
const database = new CohContentDatabase()
|
|
89
|
-
expect(() => database.load(
|
|
89
|
+
expect(() => database.load(bundleDataFixture.create({
|
|
90
90
|
archetypes: [
|
|
91
91
|
archetypeDataFixture.create({ key: 'foo' }),
|
|
92
92
|
archetypeDataFixture.create({ key: 'foo' }),
|
|
@@ -96,7 +96,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
96
96
|
|
|
97
97
|
test(`should accept an undefined field`, () => {
|
|
98
98
|
const database = new CohContentDatabase()
|
|
99
|
-
database.load(
|
|
99
|
+
database.load(bundleDataFixture
|
|
100
100
|
.omit('archetypes')
|
|
101
101
|
.create())
|
|
102
102
|
expect(database.archetypes).toHaveLength(0)
|
|
@@ -104,7 +104,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
104
104
|
|
|
105
105
|
test(`should load data from bundle`, () => {
|
|
106
106
|
const database = new CohContentDatabase()
|
|
107
|
-
database.load(
|
|
107
|
+
database.load(bundleDataFixture
|
|
108
108
|
.create({ archetypes: [archetypeDataFixture.create({ key: 'foo' })] }))
|
|
109
109
|
expect(database.getArchetype('foo')).not.toBeUndefined()
|
|
110
110
|
})
|
|
@@ -113,7 +113,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
113
113
|
describe('badges', () => {
|
|
114
114
|
test(`should throw an error on duplicate key`, () => {
|
|
115
115
|
const database = new CohContentDatabase()
|
|
116
|
-
expect(() => database.load(
|
|
116
|
+
expect(() => database.load(bundleDataFixture.create({
|
|
117
117
|
badges: [
|
|
118
118
|
badgeDataFixture.create({ key: 'foo' }),
|
|
119
119
|
badgeDataFixture.create({ key: 'foo' }),
|
|
@@ -123,7 +123,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
123
123
|
|
|
124
124
|
test(`should accept an undefined field`, () => {
|
|
125
125
|
const database = new CohContentDatabase()
|
|
126
|
-
database.load(
|
|
126
|
+
database.load(bundleDataFixture
|
|
127
127
|
.omit('badges')
|
|
128
128
|
.create())
|
|
129
129
|
expect(database.badges).toHaveLength(0)
|
|
@@ -133,7 +133,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
133
133
|
describe('zones', () => {
|
|
134
134
|
test(`should throw an error on duplicate zone`, () => {
|
|
135
135
|
const database = new CohContentDatabase()
|
|
136
|
-
expect(() => database.load(
|
|
136
|
+
expect(() => database.load(bundleDataFixture.create({
|
|
137
137
|
zones: [
|
|
138
138
|
zoneDataFixture.create({ key: 'foo' }),
|
|
139
139
|
zoneDataFixture.create({ key: 'foo' }),
|
|
@@ -143,7 +143,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
143
143
|
|
|
144
144
|
test(`should accept an undefined field`, () => {
|
|
145
145
|
const database = new CohContentDatabase()
|
|
146
|
-
database.load(
|
|
146
|
+
database.load(bundleDataFixture
|
|
147
147
|
.omit('zones')
|
|
148
148
|
.create())
|
|
149
149
|
expect(database.zones).toHaveLength(0)
|
|
@@ -153,7 +153,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
153
153
|
describe('contacts', () => {
|
|
154
154
|
test(`should throw an error on duplicate contact`, () => {
|
|
155
155
|
const database = new CohContentDatabase()
|
|
156
|
-
expect(() => database.load(
|
|
156
|
+
expect(() => database.load(bundleDataFixture.create({
|
|
157
157
|
contacts: [
|
|
158
158
|
contactDataFixture.create({ key: 'foo' }),
|
|
159
159
|
contactDataFixture.create({ key: 'foo' }),
|
|
@@ -163,7 +163,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
163
163
|
|
|
164
164
|
test(`should accept an undefined field`, () => {
|
|
165
165
|
const database = new CohContentDatabase()
|
|
166
|
-
database.load(
|
|
166
|
+
database.load(bundleDataFixture
|
|
167
167
|
.omit('contacts')
|
|
168
168
|
.create())
|
|
169
169
|
expect(database.contacts).toHaveLength(0)
|
|
@@ -173,7 +173,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
173
173
|
describe('missions', () => {
|
|
174
174
|
test(`should throw an error on duplicate mission`, () => {
|
|
175
175
|
const database = new CohContentDatabase()
|
|
176
|
-
expect(() => database.load(
|
|
176
|
+
expect(() => database.load(bundleDataFixture.create({
|
|
177
177
|
missions: [
|
|
178
178
|
missionDataFixture.create({ key: 'foo' }),
|
|
179
179
|
missionDataFixture.create({ key: 'foo' }),
|
|
@@ -183,7 +183,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
183
183
|
|
|
184
184
|
test(`should accept an undefined field`, () => {
|
|
185
185
|
const database = new CohContentDatabase()
|
|
186
|
-
database.load(
|
|
186
|
+
database.load(bundleDataFixture
|
|
187
187
|
.omit('missions')
|
|
188
188
|
.create())
|
|
189
189
|
expect(database.missions).toHaveLength(0)
|
|
@@ -193,7 +193,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
193
193
|
describe('getArchetype', () => {
|
|
194
194
|
test(`should retrieve archetype from the index`, () => {
|
|
195
195
|
const database = new CohContentDatabase()
|
|
196
|
-
database.load(
|
|
196
|
+
database.load(bundleDataFixture.create({
|
|
197
197
|
archetypes: [archetypeDataFixture.create({ key: 'foo' })],
|
|
198
198
|
}))
|
|
199
199
|
expect(database.getArchetype('foo')).not.toBeUndefined()
|
|
@@ -201,13 +201,13 @@ describe(CohContentDatabase.name, () => {
|
|
|
201
201
|
|
|
202
202
|
test(`should return undefined for unknown archetype`, () => {
|
|
203
203
|
const database = new CohContentDatabase()
|
|
204
|
-
database.load(
|
|
204
|
+
database.load(bundleDataFixture.create({ archetypes: [] }))
|
|
205
205
|
expect(database.getArchetype('foo')).toBeUndefined()
|
|
206
206
|
})
|
|
207
207
|
|
|
208
208
|
test(`should return undefined for undefined key`, () => {
|
|
209
209
|
const database = new CohContentDatabase()
|
|
210
|
-
database.load(
|
|
210
|
+
database.load(bundleDataFixture.create({ archetypes: [] }))
|
|
211
211
|
const key = undefined
|
|
212
212
|
expect(database.getArchetype(key)).toBeUndefined()
|
|
213
213
|
})
|
|
@@ -216,7 +216,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
216
216
|
describe('getZone', () => {
|
|
217
217
|
test(`should retrieve zone from the index`, () => {
|
|
218
218
|
const database = new CohContentDatabase()
|
|
219
|
-
database.load(
|
|
219
|
+
database.load(bundleDataFixture.create({
|
|
220
220
|
zones: [zoneDataFixture.create({ key: 'foo' })],
|
|
221
221
|
}))
|
|
222
222
|
|
|
@@ -225,13 +225,13 @@ describe(CohContentDatabase.name, () => {
|
|
|
225
225
|
|
|
226
226
|
test(`should return undefined for unknown zone`, () => {
|
|
227
227
|
const database = new CohContentDatabase()
|
|
228
|
-
database.load(
|
|
228
|
+
database.load(bundleDataFixture.create({ zones: [] }))
|
|
229
229
|
expect(database.getZone('foo')).toBeUndefined()
|
|
230
230
|
})
|
|
231
231
|
|
|
232
232
|
test(`should return undefined for undefined key`, () => {
|
|
233
233
|
const database = new CohContentDatabase()
|
|
234
|
-
database.load(
|
|
234
|
+
database.load(bundleDataFixture.create({ zones: [] }))
|
|
235
235
|
const key = undefined
|
|
236
236
|
expect(database.getZone(key)).toBeUndefined()
|
|
237
237
|
})
|
|
@@ -240,7 +240,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
240
240
|
describe('getContact', () => {
|
|
241
241
|
test(`should retrieve contact from the index`, () => {
|
|
242
242
|
const database = new CohContentDatabase()
|
|
243
|
-
database.load(
|
|
243
|
+
database.load(bundleDataFixture.create({
|
|
244
244
|
contacts: [contactDataFixture.create({ key: 'foo' })],
|
|
245
245
|
}))
|
|
246
246
|
expect(database.getContact('foo')).not.toBeUndefined()
|
|
@@ -248,13 +248,13 @@ describe(CohContentDatabase.name, () => {
|
|
|
248
248
|
|
|
249
249
|
test(`should return undefined for unknown contact`, () => {
|
|
250
250
|
const database = new CohContentDatabase()
|
|
251
|
-
database.load(
|
|
251
|
+
database.load(bundleDataFixture.create({ contacts: [] }))
|
|
252
252
|
expect(database.getContact('foo')).toBeUndefined()
|
|
253
253
|
})
|
|
254
254
|
|
|
255
255
|
test(`should return undefined for undefined key`, () => {
|
|
256
256
|
const database = new CohContentDatabase()
|
|
257
|
-
database.load(
|
|
257
|
+
database.load(bundleDataFixture.create({ contacts: [] }))
|
|
258
258
|
const key = undefined
|
|
259
259
|
expect(database.getContact(key)).toBeUndefined()
|
|
260
260
|
})
|
|
@@ -263,7 +263,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
263
263
|
describe('getMission', () => {
|
|
264
264
|
test(`should retrieve mission from the index`, () => {
|
|
265
265
|
const database = new CohContentDatabase()
|
|
266
|
-
database.load(
|
|
266
|
+
database.load(bundleDataFixture.create({
|
|
267
267
|
missions: [missionDataFixture.create({ key: 'foo' })],
|
|
268
268
|
}))
|
|
269
269
|
expect(database.getMission('foo')).not.toBeUndefined()
|
|
@@ -271,13 +271,13 @@ describe(CohContentDatabase.name, () => {
|
|
|
271
271
|
|
|
272
272
|
test(`should return undefined for unknown mission`, () => {
|
|
273
273
|
const database = new CohContentDatabase()
|
|
274
|
-
database.load(
|
|
274
|
+
database.load(bundleDataFixture.create({ missions: [] }))
|
|
275
275
|
expect(database.getMission('foo')).toBeUndefined()
|
|
276
276
|
})
|
|
277
277
|
|
|
278
278
|
test(`should return undefined for undefined key`, () => {
|
|
279
279
|
const database = new CohContentDatabase()
|
|
280
|
-
database.load(
|
|
280
|
+
database.load(bundleDataFixture.create({ missions: [] }))
|
|
281
281
|
const key = undefined
|
|
282
282
|
expect(database.getMission(key)).toBeUndefined()
|
|
283
283
|
})
|
|
@@ -286,7 +286,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
286
286
|
describe('getBadge', () => {
|
|
287
287
|
test(`should retrieve badge from the index`, () => {
|
|
288
288
|
const database = new CohContentDatabase()
|
|
289
|
-
database.load(
|
|
289
|
+
database.load(bundleDataFixture.create({
|
|
290
290
|
badges: [badgeDataFixture.create({ key: 'foo' })],
|
|
291
291
|
}))
|
|
292
292
|
expect(database.getBadge('foo')).not.toBeUndefined()
|
|
@@ -294,13 +294,13 @@ describe(CohContentDatabase.name, () => {
|
|
|
294
294
|
|
|
295
295
|
test(`should return undefined for unknown badge`, () => {
|
|
296
296
|
const database = new CohContentDatabase()
|
|
297
|
-
database.load(
|
|
297
|
+
database.load(bundleDataFixture.create({ badges: [] }))
|
|
298
298
|
expect(database.getBadge('foo')).toBeUndefined()
|
|
299
299
|
})
|
|
300
300
|
|
|
301
301
|
test(`should return undefined for undefined key`, () => {
|
|
302
302
|
const database = new CohContentDatabase()
|
|
303
|
-
database.load(
|
|
303
|
+
database.load(bundleDataFixture.create({ badges: [] }))
|
|
304
304
|
const key = undefined
|
|
305
305
|
expect(database.getBadge(key)).toBeUndefined()
|
|
306
306
|
})
|
|
@@ -309,7 +309,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
309
309
|
describe('searchBadges', () => {
|
|
310
310
|
test(`should search the badge list`, () => {
|
|
311
311
|
const database = new CohContentDatabase()
|
|
312
|
-
database.load(
|
|
312
|
+
database.load(bundleDataFixture.create({
|
|
313
313
|
badges: [
|
|
314
314
|
badgeDataFixture.create({ key: 'foo', name: [{ value: 'Foo' }] }),
|
|
315
315
|
badgeDataFixture.create({ key: 'bar', name: [{ value: 'Bar' }] }),
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BundleData } from '../main'
|
|
2
|
+
import { TEST_BADGE } from './api/badge-data.test'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* If you change this test, update the example in the README as well
|
|
6
|
+
*/
|
|
7
|
+
export const TEST_BUNDLE: BundleData = {
|
|
8
|
+
header: { name: 'My Content Bundle' },
|
|
9
|
+
badges: [TEST_BADGE],
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('BundleData', () => {
|
|
13
|
+
test('should be a usable interface', () => {
|
|
14
|
+
expect(TEST_BUNDLE).not.toBeUndefined()
|
|
15
|
+
})
|
|
16
|
+
})
|
package/src/main/api/change.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MarkdownString } from './markdown-string'
|
|
2
|
-
|
|
3
|
-
export interface Change {
|
|
4
|
-
/**
|
|
5
|
-
* The version number in {@link http://semver.org|semver} format.
|
|
6
|
-
*/
|
|
7
|
-
version: string
|
|
8
|
-
/**
|
|
9
|
-
* Date of the change.
|
|
10
|
-
*/
|
|
11
|
-
date: Date
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Description of the change.
|
|
15
|
-
*/
|
|
16
|
-
description: MarkdownString
|
|
17
|
-
}
|
package/src/main/changelog.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Change } from './api/change'
|
|
2
|
-
|
|
3
|
-
export const CHANGELOG: Change[] = [
|
|
4
|
-
{
|
|
5
|
-
version: '2.0.0',
|
|
6
|
-
date: new Date('2025-03-12'),
|
|
7
|
-
description: ''
|
|
8
|
-
+ '* Replaced redundant interfaces with their concrete equivalents.\n'
|
|
9
|
-
+ `* Server groups are now referred to as 'forks'.\n`
|
|
10
|
-
+ '* Replaced enums with union types and changed values to `kebab-case`.\n'
|
|
11
|
-
+ '* `IServerGroupData` is now `ContentBundle` and each database instance is now designed to accept only a single bundle.\n'
|
|
12
|
-
+ '* `GameMap` is now `Zone`.\n'
|
|
13
|
-
+ '* Removed the `serverGroup` property from entities to simplify the object tree given that only a single context can exist per db now.\n'
|
|
14
|
-
+ '* Added a simple indexing and search function for badge names, text and acquisition info.\n'
|
|
15
|
-
+ '* Zone and badge references now follow a standard Markdown link format with a `badge://` or `map://` protocol.\n'
|
|
16
|
-
+ '* Badge partials are now known as badge requirements.\n'
|
|
17
|
-
+ '* Removed the `VidiotMap` API as it was never used or fleshed out properly.\n'
|
|
18
|
-
+ '* Added formal support for Missions and Contacts in badge requirements.\n'
|
|
19
|
-
+ '* Move exploration badge locations into badge requirement list.\n'
|
|
20
|
-
+ '* Standardized pluralization of some field names (name, icon).\n'
|
|
21
|
-
+ '* Combined `settitle` ids into a single tuple field.\n'
|
|
22
|
-
+ '* Change from GNU to The Unlicense.\n'
|
|
23
|
-
+ '* Removed all third-party dependencies.\n'
|
|
24
|
-
+ '* Moved from webpack to rollup for packaging.\n'
|
|
25
|
-
+ '* Add eslint for linting.\n'
|
|
26
|
-
+ '* Add jest for unit tests.\n'
|
|
27
|
-
+ '* Added GitHub Actions for CI.\n',
|
|
28
|
-
},
|
|
29
|
-
]
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ContentBundle } from '../api/content-bundle'
|
|
2
|
-
import { Change } from '../api/change'
|
|
3
|
-
import { Link } from '../api/link'
|
|
4
|
-
import { MarkdownString } from '../api/markdown-string'
|
|
5
|
-
|
|
6
|
-
export class BundleMetadata {
|
|
7
|
-
/**
|
|
8
|
-
* Name of the content bundle.
|
|
9
|
-
*/
|
|
10
|
-
readonly name: string
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Description of the fork.
|
|
14
|
-
*/
|
|
15
|
-
readonly description?: MarkdownString
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Repository where the db content package is maintained.
|
|
19
|
-
*/
|
|
20
|
-
readonly repository?: string
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* List of external links. Wiki, forums, etc.
|
|
24
|
-
*/
|
|
25
|
-
readonly links?: Link[]
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Change log for this data package.
|
|
29
|
-
*/
|
|
30
|
-
readonly changelog?: Change[]
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The current version of the data package.
|
|
34
|
-
*/
|
|
35
|
-
readonly version?: string
|
|
36
|
-
|
|
37
|
-
constructor(bundle: ContentBundle) {
|
|
38
|
-
this.name = bundle.name
|
|
39
|
-
this.description = bundle.description
|
|
40
|
-
this.repository = bundle.repository
|
|
41
|
-
this.links = bundle.links ?? []
|
|
42
|
-
this.changelog = bundle.changelog ?? []
|
|
43
|
-
this.version = this.changelog?.at(-1)?.version
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ContentBundle } from '../../main'
|
|
2
|
-
import { TEST_BADGE } from './badge-data.test'
|
|
3
|
-
|
|
4
|
-
// If you change this test, update the example in the README as well
|
|
5
|
-
export const TEST_BUNDLE: ContentBundle = {
|
|
6
|
-
name: 'My Content Bundle',
|
|
7
|
-
badges: [TEST_BADGE],
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
describe('ContentBundle', () => {
|
|
11
|
-
test('should be a usable interface', () => {
|
|
12
|
-
expect(TEST_BUNDLE).not.toBeUndefined()
|
|
13
|
-
})
|
|
14
|
-
})
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { CHANGELOG } from '../main'
|
|
2
|
-
|
|
3
|
-
describe('CHANGELOG', () => {
|
|
4
|
-
test('should be extant', () => {
|
|
5
|
-
expect(CHANGELOG).not.toBeUndefined()
|
|
6
|
-
expect(CHANGELOG).not.toBeUndefined()
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('should be an array', () => {
|
|
10
|
-
expect(Array.isArray(CHANGELOG)).toBeTruthy()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('should have only semver versions', () => {
|
|
14
|
-
// semver.org - https://regex101.com/r/vkijKf/1/
|
|
15
|
-
const pattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
|
|
16
|
-
|
|
17
|
-
for (const change of CHANGELOG) {
|
|
18
|
-
expect(pattern.test(change.version)).toBeTruthy()
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
test('should have dates', () => {
|
|
23
|
-
for (const change of CHANGELOG) {
|
|
24
|
-
const date = change.date
|
|
25
|
-
expect(date).not.toBeUndefined()
|
|
26
|
-
expect(date).not.toBeUndefined()
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test('should have descriptions', () => {
|
|
31
|
-
for (const change of CHANGELOG) {
|
|
32
|
-
expect(change).not.toBeUndefined()
|
|
33
|
-
expect(change).not.toBeUndefined()
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
})
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { BundleMetadata } from '../../main'
|
|
2
|
-
import { contentBundleFixture } from '../api/content-bundle.fixture'
|
|
3
|
-
|
|
4
|
-
describe(BundleMetadata.name, () => {
|
|
5
|
-
describe('Constructor', () => {
|
|
6
|
-
test(`should accept the test fixture`, () => {
|
|
7
|
-
new BundleMetadata(contentBundleFixture.create())
|
|
8
|
-
})
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
describe('name', () => {
|
|
12
|
-
test(`should be read from the bundle`, () => {
|
|
13
|
-
const bundle = new BundleMetadata(contentBundleFixture.create({ name: 'foo' }))
|
|
14
|
-
expect(bundle.name).toBe('foo')
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
describe('description', () => {
|
|
19
|
-
test(`should be read from the bundle`, () => {
|
|
20
|
-
const bundle = new BundleMetadata(contentBundleFixture.create({ description: 'foo' }))
|
|
21
|
-
expect(bundle.description).toBe('foo')
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test(`should be optional`, () => {
|
|
25
|
-
const bundle = new BundleMetadata(contentBundleFixture.omit('description').create())
|
|
26
|
-
expect(bundle.description).toBeUndefined()
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
describe('repository', () => {
|
|
31
|
-
test(`should be read from the bundle`, () => {
|
|
32
|
-
const bundle = new BundleMetadata(contentBundleFixture.create({ repository: 'foo' }))
|
|
33
|
-
expect(bundle.repository).toBe('foo')
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test(`should be optional`, () => {
|
|
37
|
-
const bundle = new BundleMetadata(contentBundleFixture.omit('repository').create())
|
|
38
|
-
expect(bundle.repository).toBeUndefined()
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
describe('links', () => {
|
|
43
|
-
test(`should be read from the bundle`, () => {
|
|
44
|
-
const bundle = new BundleMetadata(contentBundleFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
45
|
-
expect(bundle.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
test(`should be optional`, () => {
|
|
49
|
-
const bundle = new BundleMetadata(contentBundleFixture.omit('links').create())
|
|
50
|
-
expect(bundle.links).toHaveLength(0)
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
describe('changelog', () => {
|
|
55
|
-
test(`should be read from the bundle`, () => {
|
|
56
|
-
const bundle = new BundleMetadata(contentBundleFixture.create({
|
|
57
|
-
changelog: [{ version: 'foo', date: new Date('2025-03-12'), description: 'bar' }],
|
|
58
|
-
}))
|
|
59
|
-
expect(bundle.changelog).toStrictEqual([{ version: 'foo', date: new Date('2025-03-12'), description: 'bar' }])
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
test(`should be optional`, () => {
|
|
63
|
-
const bundle = new BundleMetadata(contentBundleFixture.omit('changelog').create())
|
|
64
|
-
expect(bundle.changelog).toHaveLength(0)
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
describe('version', () => {
|
|
69
|
-
test(`should be read from the latest changelog entry`, () => {
|
|
70
|
-
const bundle = new BundleMetadata(contentBundleFixture.create({
|
|
71
|
-
changelog: [
|
|
72
|
-
{ version: 'foo', date: new Date('2025-03-12'), description: 'Foo' },
|
|
73
|
-
{ version: 'latest', date: new Date('2025-04-12'), description: 'Bar' },
|
|
74
|
-
],
|
|
75
|
-
}))
|
|
76
|
-
expect(bundle.version).toBe('latest')
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test(`should be undefined if there is no changelog`, () => {
|
|
80
|
-
const bundle = new BundleMetadata(contentBundleFixture.omit('changelog').create())
|
|
81
|
-
expect(bundle.version).toBeUndefined()
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
})
|
package/src/test/index.test.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as index from '../main/index'
|
|
2
|
-
|
|
3
|
-
test('should export the changelog', () => {
|
|
4
|
-
expect(index).toHaveProperty('CHANGELOG')
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
test('should export badge reference utils', () => {
|
|
8
|
-
expect(index).toHaveProperty('badgeUri')
|
|
9
|
-
expect(index).toHaveProperty('badgeLink')
|
|
10
|
-
expect(index).toHaveProperty('contactUri')
|
|
11
|
-
expect(index).toHaveProperty('contactLink')
|
|
12
|
-
expect(index).toHaveProperty('zoneUri')
|
|
13
|
-
expect(index).toHaveProperty('zoneLink')
|
|
14
|
-
})
|