coh-content-db 1.4.1 → 2.0.0-rc.2

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 (84) hide show
  1. package/.editorconfig +25 -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/LICENSE +24 -674
  6. package/README.md +74 -17
  7. package/dist/coh-content-db.d.ts +584 -22
  8. package/dist/coh-content-db.js +587 -2
  9. package/dist/coh-content-db.js.map +1 -0
  10. package/dist/coh-content-db.mjs +568 -0
  11. package/dist/coh-content-db.mjs.map +1 -0
  12. package/eslint.config.mjs +30 -0
  13. package/jest.config.mjs +7 -0
  14. package/package.json +31 -23
  15. package/rollup.config.mjs +27 -0
  16. package/src/main/api/alignment.ts +3 -0
  17. package/src/main/api/alternate-data.ts +22 -0
  18. package/src/main/api/archetype-data.ts +5 -0
  19. package/src/main/api/badge-data.ts +109 -0
  20. package/src/main/api/badge-partial-data.ts +65 -0
  21. package/src/main/api/badge-partial-type.ts +8 -0
  22. package/src/main/api/badge-type.ts +19 -0
  23. package/src/main/api/change.ts +14 -0
  24. package/src/main/api/enhancement-category.ts +30 -0
  25. package/src/main/api/game-map-data.ts +26 -0
  26. package/src/main/api/link.ts +4 -0
  27. package/src/main/api/plaque-type.ts +6 -0
  28. package/src/main/api/server-group-data.ts +65 -0
  29. package/src/main/api/sex.ts +3 -0
  30. package/src/main/api/vidiot-map-data.ts +18 -0
  31. package/src/main/api/vidiot-map-point-of-interest-data.ts +30 -0
  32. package/src/main/changelog.ts +20 -0
  33. package/src/main/db/alternates.ts +81 -0
  34. package/src/main/db/archetype.ts +14 -0
  35. package/src/main/db/badge-partial.ts +35 -0
  36. package/src/main/db/badge.ts +141 -0
  37. package/src/main/db/coh-content-database.ts +29 -0
  38. package/src/main/db/game-map.ts +33 -0
  39. package/src/main/db/key.ts +18 -0
  40. package/src/main/db/server-group.ts +112 -0
  41. package/src/main/db/vidiot-map-point-of-interest.ts +40 -0
  42. package/src/main/db/vidiot-map.ts +25 -0
  43. package/src/main/index.ts +33 -0
  44. package/src/main/util.ts +17 -0
  45. package/src/test/api/alignment.test.ts +31 -0
  46. package/src/test/api/archetype-data.fixture.ts +8 -0
  47. package/src/test/api/badge-data.fixture.ts +22 -0
  48. package/src/test/api/badge-data.test.ts +15 -0
  49. package/src/test/api/badge-partial-data.fixture.ts +17 -0
  50. package/src/test/api/badge-partial-type.test.ts +31 -0
  51. package/src/test/api/badge-type.test.ts +35 -0
  52. package/src/test/api/enhancement-category.test.ts +35 -0
  53. package/src/test/api/game-map-data.fixture.ts +10 -0
  54. package/src/test/api/plaque-type.test.ts +31 -0
  55. package/src/test/api/server-group-data.fixture.ts +23 -0
  56. package/src/test/api/server-group-data.test.ts +15 -0
  57. package/src/test/api/sex.test.ts +31 -0
  58. package/src/test/api/vidiot-map-point-of-interest.fixture.ts +10 -0
  59. package/src/test/api/vidiot-map.fixture.ts +9 -0
  60. package/src/test/changelog.test.ts +36 -0
  61. package/src/test/db/alternates.test.ts +223 -0
  62. package/src/test/db/archetype.test.ts +38 -0
  63. package/src/test/db/badge.test.ts +41 -0
  64. package/src/test/db/coh-content-database.test.ts +42 -0
  65. package/src/test/db/key.test.ts +22 -0
  66. package/src/test/db/server-group.test.ts +124 -0
  67. package/src/test/index.test.ts +10 -0
  68. package/src/test/util.test.ts +39 -0
  69. package/tsconfig.json +117 -0
  70. package/dist/_changelog.d.ts +0 -3
  71. package/dist/coh-content-db.nomin.js +0 -635
  72. package/dist/content-refence-utils.d.ts +0 -4
  73. package/dist/index.d.ts +0 -8
  74. package/dist/internal/_common.d.ts +0 -4
  75. package/dist/internal/archetype.d.ts +0 -10
  76. package/dist/internal/badge.d.ts +0 -44
  77. package/dist/internal/game-map.d.ts +0 -33
  78. package/dist/internal/server-group.d.ts +0 -24
  79. package/dist/types/archetype.d.ts +0 -9
  80. package/dist/types/badge.d.ts +0 -192
  81. package/dist/types/enhancement.d.ts +0 -28
  82. package/dist/types/game-map.d.ts +0 -47
  83. package/dist/types/link.d.ts +0 -4
  84. package/dist/types/server-group.d.ts +0 -75
package/README.md CHANGED
@@ -1,36 +1,93 @@
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
+ # Installation
12
+
5
13
  ```
6
14
  npm install coh-content-db
7
15
  ```
8
16
 
9
- ### Usage
17
+ # Usage
10
18
 
11
- Initialize the database, then load a server-group data pack, such as `coh-content-db-homecoming`:
12
- ```
13
- import {CohContentDb} from "coh-content-db";
14
- import {Homecoming} from "coh-content-db-homecoming";
19
+ There are two ways to use this package; As a data provider, or a db consumer.
20
+
21
+ ## As a data provider
22
+
23
+ Data providers utilize the various `-Data` interfaces provided in this package to construct server group data packages
24
+ that can be loaded into the db for consumption by DB consumers such as [Badger](https://github.com/n15g/badger).
15
25
 
16
- const contentDb = new CohContentDb();
17
- contentDb.load(new Homecoming());
26
+ For an example data package, see the [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming) project.
27
+
28
+ ### Defining archetypes, map, badges, etc.
29
+
30
+ To define content, create a new instance using the appropriate `Data` interface and provide values for the required fields:
31
+
32
+ ```typescript
33
+ ///test-badge.ts
34
+ import {BadgeData} from 'coh-content-db'
35
+
36
+ export const TEST_BADGE: BadgeData = {
37
+ key: 'test-badge',
38
+ type: 'ACHIEVEMENT',
39
+ name: [{value: 'Test Badge'}, {alignment: 'P', value: 'My Badge for Praetorians'}],
40
+ alignment: ['H', 'V', 'P'],
41
+ }
18
42
  ```
19
43
 
20
- Once loaded, you can start retrieving loaded data using the keys associated with the various content.
44
+ Then, create a `ServerGroupData` instance and load your content into the appropriate field.
45
+
46
+ ```typescript
47
+ import {ServerGroupData} from 'coh-content-db'
48
+ import {TEST_BADGE} from './test-badge'
21
49
 
22
- #### List Loaded Server Groups:
50
+ export const TEST_SERVER_GROUP: ServerGroupData = {
51
+ key: 'my-server-group',
52
+ name: 'My Server Group',
53
+ badges: [TEST_BADGE],
54
+ }
23
55
  ```
24
- contentDb.getServerGroups();
56
+
57
+ ## As a DB consumer
58
+
59
+ Create a new database instance, then load a server-group data pack, such as [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming):
60
+
61
+ ```typescript
62
+ import {CohContentDatabase} from 'coh-content-db';
63
+ import {Homecoming} from 'coh-content-db-homecoming';
64
+
65
+ const db = new CohContentDatabase();
66
+ db.loadServerGroupData(new Homecoming());
25
67
  ```
26
68
 
27
- #### Get a Server Group by key:
69
+ Once loaded, you can start retrieving the loaded data using the keys associated with the various content:
70
+
71
+ #### List loaded server groups:
72
+
73
+ ```typescript
74
+ db.listServerGroups();
28
75
  ```
29
- contentDb.getServerGroup("serverGroupKey");
76
+
77
+ #### Get a server group by key and list the badges:
78
+
79
+ ```typescript
80
+ const sg = db.getServerGroup("server-group-key");
81
+ for (const badge of sg.badges) {
82
+ console.log(badge.key)
83
+ }
30
84
  ```
31
85
 
32
- ### Build
33
- `npm run build`
86
+ ## Publish
34
87
 
35
- ### Deploy
36
- `npm package`
88
+ Tags matching the pattern `v<X>.<Y>.<Z>` will attempt to publish to npm (this can only be achieved by the package manager (n15g).
89
+
90
+ ```shell
91
+ npm version 1.4.x
92
+ npm run push
93
+ ```