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.
Files changed (101) hide show
  1. package/.editorconfig +24 -0
  2. package/.github/workflows/build.yml +38 -0
  3. package/.github/workflows/pull-request.yml +32 -0
  4. package/.github/workflows/release.yml +52 -0
  5. package/CHANGELOG.md +42 -0
  6. package/LICENSE +24 -674
  7. package/README.md +101 -16
  8. package/dist/coh-content-db.d.ts +988 -22
  9. package/dist/coh-content-db.js +1044 -2
  10. package/dist/coh-content-db.js.map +1 -0
  11. package/dist/coh-content-db.mjs +1009 -0
  12. package/dist/coh-content-db.mjs.map +1 -0
  13. package/eslint.config.mjs +31 -0
  14. package/jest.config.mjs +7 -0
  15. package/package.json +31 -23
  16. package/rollup.config.mjs +27 -0
  17. package/src/main/api/alignment.ts +19 -0
  18. package/src/main/api/alternate-data.ts +22 -0
  19. package/src/main/api/archetype-data.ts +5 -0
  20. package/src/main/api/badge-data.ts +81 -0
  21. package/src/main/api/badge-requirement-data.ts +64 -0
  22. package/src/main/api/badge-requirement-type.ts +32 -0
  23. package/src/main/api/badge-type.ts +19 -0
  24. package/src/main/api/bundle-data.ts +47 -0
  25. package/src/main/api/bundle-header-data.ts +37 -0
  26. package/src/main/api/contact-data.ts +48 -0
  27. package/src/main/api/enhancement-category.ts +30 -0
  28. package/src/main/api/link.ts +4 -0
  29. package/src/main/api/location-data.ts +28 -0
  30. package/src/main/api/markdown-string.ts +4 -0
  31. package/src/main/api/mission-data.ts +83 -0
  32. package/src/main/api/mission-type.ts +2 -0
  33. package/src/main/api/morality.ts +31 -0
  34. package/src/main/api/sex.ts +10 -0
  35. package/src/main/api/zone-data.ts +20 -0
  36. package/src/main/db/abstract-index.ts +37 -0
  37. package/src/main/db/alignment-list.ts +54 -0
  38. package/src/main/db/alternates.ts +67 -0
  39. package/src/main/db/archetype.ts +14 -0
  40. package/src/main/db/badge-index.ts +57 -0
  41. package/src/main/db/badge-requirement.ts +81 -0
  42. package/src/main/db/badge-search-options.ts +51 -0
  43. package/src/main/db/badge.ts +147 -0
  44. package/src/main/db/bundle-header.ts +44 -0
  45. package/src/main/db/coh-content-database.ts +138 -0
  46. package/src/main/db/contact.ts +62 -0
  47. package/src/main/db/key.ts +18 -0
  48. package/src/main/db/location.ts +30 -0
  49. package/src/main/db/mission.ts +107 -0
  50. package/src/main/db/morality-list.ts +99 -0
  51. package/src/main/db/paged.ts +7 -0
  52. package/src/main/db/zone.ts +28 -0
  53. package/src/main/index.ts +41 -0
  54. package/src/main/util.ts +118 -0
  55. package/src/test/api/alignment.test.ts +65 -0
  56. package/src/test/api/archetype-data.fixture.ts +8 -0
  57. package/src/test/api/badge-data.fixture.ts +8 -0
  58. package/src/test/api/badge-data.test.ts +15 -0
  59. package/src/test/api/badge-requirement-data.fixture.ts +7 -0
  60. package/src/test/api/badge-requirement-type.test.ts +31 -0
  61. package/src/test/api/badge-type.test.ts +35 -0
  62. package/src/test/api/bundle-data.fixture.ts +6 -0
  63. package/src/test/api/bundle-header-data.fixture.ts +6 -0
  64. package/src/test/api/contact-data.fixture.ts +7 -0
  65. package/src/test/api/enhancement-category.test.ts +35 -0
  66. package/src/test/api/mission-data.fixture.ts +12 -0
  67. package/src/test/api/sex.test.ts +63 -0
  68. package/src/test/api/zone-data.fixture.ts +8 -0
  69. package/src/test/db/abstract-index.test.ts +55 -0
  70. package/src/test/db/alignment-list.test.ts +200 -0
  71. package/src/test/db/alternates.test.ts +188 -0
  72. package/src/test/db/archetype.test.ts +38 -0
  73. package/src/test/db/badge-index.test.ts +519 -0
  74. package/src/test/db/badge-requirement.test.ts +145 -0
  75. package/src/test/db/badge.test.ts +337 -0
  76. package/src/test/db/bundle-header.test.ts +76 -0
  77. package/src/test/db/coh-content-database.test.ts +282 -0
  78. package/src/test/db/contact.test.ts +97 -0
  79. package/src/test/db/key.test.ts +22 -0
  80. package/src/test/db/location.test.ts +51 -0
  81. package/src/test/db/mission.test.ts +171 -0
  82. package/src/test/db/morality-list.test.ts +457 -0
  83. package/src/test/db/zone.test.ts +36 -0
  84. package/src/test/integration.test.ts +16 -0
  85. package/src/test/util.test.ts +165 -0
  86. package/tsconfig.json +117 -0
  87. package/dist/_changelog.d.ts +0 -3
  88. package/dist/coh-content-db.nomin.js +0 -635
  89. package/dist/content-refence-utils.d.ts +0 -4
  90. package/dist/index.d.ts +0 -8
  91. package/dist/internal/_common.d.ts +0 -4
  92. package/dist/internal/archetype.d.ts +0 -10
  93. package/dist/internal/badge.d.ts +0 -44
  94. package/dist/internal/game-map.d.ts +0 -33
  95. package/dist/internal/server-group.d.ts +0 -24
  96. package/dist/types/archetype.d.ts +0 -9
  97. package/dist/types/badge.d.ts +0 -192
  98. package/dist/types/enhancement.d.ts +0 -28
  99. package/dist/types/game-map.d.ts +0 -47
  100. package/dist/types/link.d.ts +0 -4
  101. package/dist/types/server-group.d.ts +0 -75
package/README.md CHANGED
@@ -1,36 +1,121 @@
1
1
  # coh-content-db
2
+
3
+ [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/n15g/coh-content-db/build.yml?branch=master)](https://github.com/n15g/coh-content-db/actions)
4
+ [![Codecov](https://img.shields.io/codecov/c/github/n15g/coh-content-db)](https://app.codecov.io/gh/n15g/coh-content-db)
5
+ [![GitHub Tag](https://img.shields.io/github/v/tag/n15g/coh-content-db)](https://github.com/n15g/coh-content-db/tags)
6
+ [![NPM Version](https://img.shields.io/npm/v/coh-content-db)](https://www.npmjs.com/package/coh-content-db)
7
+ [![GitHub License](https://img.shields.io/github/license/n15g/coh-content-db)](LICENSE)
8
+
2
9
  City of Heroes Content Database
3
10
 
4
- ### Installation
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
- ### Usage
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
- Initialize the database, then load a server-group data pack, such as `coh-content-db-homecoming`:
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
- const contentDb = new CohContentDb();
17
- contentDb.load(new Homecoming());
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
- Once loaded, you can start retrieving loaded data using the keys associated with the various content.
73
+ There are convenience functions also provided to construct the URI automatically that can be used as follows:
21
74
 
22
- #### List Loaded Server Groups:
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
- contentDb.getServerGroups();
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
- #### Get a Server Group by key:
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
- contentDb.getServerGroup("serverGroupKey");
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
- ### Build
33
- `npm run build`
114
+ ## Publish
34
115
 
35
- ### Deploy
36
- `npm package`
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
+ ```