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
package/README.md
CHANGED
|
@@ -1,36 +1,121 @@
|
|
|
1
1
|
# coh-content-db
|
|
2
|
+
|
|
3
|
+
[](https://github.com/n15g/coh-content-db/actions)
|
|
4
|
+
[](https://app.codecov.io/gh/n15g/coh-content-db)
|
|
5
|
+
[](https://github.com/n15g/coh-content-db/tags)
|
|
6
|
+
[](https://www.npmjs.com/package/coh-content-db)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
2
9
|
City of Heroes Content Database
|
|
3
10
|
|
|
4
|
-
|
|
11
|
+
# Change Log
|
|
12
|
+
|
|
13
|
+
[CHANGELOG.md](CHANGELOG.md)
|
|
14
|
+
|
|
15
|
+
# Installation
|
|
16
|
+
|
|
5
17
|
```
|
|
6
18
|
npm install coh-content-db
|
|
7
19
|
```
|
|
8
20
|
|
|
9
|
-
|
|
21
|
+
# Usage
|
|
22
|
+
|
|
23
|
+
There are two ways to use this package; As a data provider, or a db consumer.
|
|
24
|
+
|
|
25
|
+
## As a data provider
|
|
26
|
+
|
|
27
|
+
Data providers utilize the various `-Data` interfaces provided in this package to construct content bundles
|
|
28
|
+
that can be loaded into the db for consumption by DB consumers such as [Badger](https://github.com/n15g/badger).
|
|
29
|
+
|
|
30
|
+
For an example data package, see the [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming) project.
|
|
31
|
+
|
|
32
|
+
### Defining archetypes, zones, badges, etc.
|
|
33
|
+
|
|
34
|
+
To define content, create a new instance using the appropriate `Data` interface and provide values for the required fields:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
///test-badge.ts
|
|
38
|
+
import { BadgeData } from 'coh-content-db'
|
|
39
|
+
|
|
40
|
+
export const TEST_BADGE: BadgeData = {
|
|
41
|
+
key: 'test-badge',
|
|
42
|
+
type: 'achievement',
|
|
43
|
+
name: [{ value: 'Test Badge' }, { alignment: 'praetorian', value: 'My Badge for Praetorians' }],
|
|
44
|
+
alignment: ['hero', 'praetorian'],
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Then, create a `BundleData` instance and load your content into the appropriate field.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { BundleData } from 'coh-content-db'
|
|
52
|
+
import { TEST_BADGE } from './test-badge'
|
|
10
53
|
|
|
11
|
-
|
|
54
|
+
export const MY_CONTENT_BUNDLE: BundleData = {
|
|
55
|
+
header: { name: 'My Content Bundle' },
|
|
56
|
+
badges: [TEST_BADGE],
|
|
57
|
+
}
|
|
12
58
|
```
|
|
13
|
-
import {CohContentDb} from "coh-content-db";
|
|
14
|
-
import {Homecoming} from "coh-content-db-homecoming";
|
|
15
59
|
|
|
16
|
-
|
|
17
|
-
|
|
60
|
+
### Markdown and Links
|
|
61
|
+
|
|
62
|
+
Fields with long text values can typically accept [Markdown](https://www.markdownguide.org/) format. These fields will also be typed with the tag type [MarkdownString](src/main/api/markdown-string.ts).
|
|
63
|
+
|
|
64
|
+
Within markdown, you can construct a link to a badge or zone using the special `badge://` and `zone://` protocol indicators that consumer apps can use to provide runtime links or tooltips.
|
|
65
|
+
This replaces the custom `[badge:xyz]` format from v1 and data packages will need to update accordingly.
|
|
66
|
+
|
|
67
|
+
To create a link, use the standard Markdown link format, with the url as following:
|
|
68
|
+
|
|
69
|
+
```markdown
|
|
70
|
+
This is a link to the [Ghoulish](badge://ghoulish) badge.
|
|
18
71
|
```
|
|
19
72
|
|
|
20
|
-
|
|
73
|
+
There are convenience functions also provided to construct the URI automatically that can be used as follows:
|
|
21
74
|
|
|
22
|
-
|
|
75
|
+
```typescript
|
|
76
|
+
import { badgeLink, badgeUri } from 'coh-content-db'
|
|
77
|
+
|
|
78
|
+
const uri = `This is a link to the [Ghoulish](${badgeUri('ghoulish')}) badge.`
|
|
79
|
+
// This is a link to the [Ghoulish](badge://ghoulish) badge.
|
|
80
|
+
const link = `This is a link to the ${badgeLink('ghoulish')} badge.`
|
|
81
|
+
// This is a link to the [ghoulish](badge://ghoulish) badge.
|
|
23
82
|
```
|
|
24
|
-
|
|
83
|
+
|
|
84
|
+
## As a DB consumer
|
|
85
|
+
|
|
86
|
+
Create a new database instance from a content bundle, such as [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming):
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { CohContentDatabase } from 'coh-content-db'
|
|
90
|
+
import { HOMECOMING } from 'coh-content-db-homecoming'
|
|
91
|
+
|
|
92
|
+
const database = new CohContentDatabase(HOMECOMING)
|
|
25
93
|
```
|
|
26
94
|
|
|
27
|
-
|
|
95
|
+
or from a JSON object:
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { BundleData, CohContentDatabase } from 'coh-content-db'
|
|
99
|
+
|
|
100
|
+
const response = await fetch('https://n15g.github.io/coh-content-db-homecoming/bundle.json')
|
|
101
|
+
const bundle = await response.json() as BundleData
|
|
102
|
+
|
|
103
|
+
const database = new CohContentDatabase(bundle)
|
|
28
104
|
```
|
|
29
|
-
|
|
105
|
+
|
|
106
|
+
#### Access the content
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
for (const badge of db.badges) {
|
|
110
|
+
console.log(badge.key)
|
|
111
|
+
}
|
|
30
112
|
```
|
|
31
113
|
|
|
32
|
-
|
|
33
|
-
`npm run build`
|
|
114
|
+
## Publish
|
|
34
115
|
|
|
35
|
-
|
|
36
|
-
|
|
116
|
+
Tags matching the pattern `v<X>.<Y>.<Z>` will attempt to publish to npm (this can only be achieved by the package manager (n15g).
|
|
117
|
+
|
|
118
|
+
```shell
|
|
119
|
+
npm version 1.4.x
|
|
120
|
+
npm run push
|
|
121
|
+
```
|