coh-content-db 2.0.0-rc.1 → 2.0.0-rc.3

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 CHANGED
@@ -4,22 +4,21 @@ root = true
4
4
  end_of_line = lf
5
5
  insert_final_newline = true
6
6
 
7
- [*.{js,mjs,cj}]
7
+ [*.{ts,js,mjs,cj,md}]
8
8
  indent_style = space
9
9
  indent_size = 2
10
+ ij_javascript_force_quote_style = true
11
+ ij_javascript_force_semicolon_style = true
10
12
  ij_javascript_spaces_within_imports = true
11
13
  ij_javascript_spaces_within_object_literal_braces = true
12
- ij_javascript_force_semicolon_style = true
13
- ij_javascript_use_semicolon_after_statement = false
14
- ij_javascript_force_quote_style = true
15
14
  ij_javascript_use_double_quotes = false
16
-
17
- [*.ts]
18
- indent_style = space
19
- indent_size = 2
15
+ ij_javascript_use_semicolon_after_statement = false
16
+ ij_typescript_force_quote_style = true
17
+ ij_typescript_force_semicolon_style = true
20
18
  ij_typescript_spaces_within_imports = true
21
19
  ij_typescript_spaces_within_object_literal_braces = true
22
- ij_typescript_force_semicolon_style = true
23
- ij_typescript_use_semicolon_after_statement = false
24
- ij_typescript_force_quote_style = true
25
20
  ij_typescript_use_double_quotes = false
21
+ ij_typescript_use_semicolon_after_statement = false
22
+
23
+ [*.md]
24
+ indent_size = 4
@@ -44,7 +44,7 @@ jobs:
44
44
  with:
45
45
  draft: true
46
46
  token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
47
- files: 'dist'
47
+ files: 'dist/*'
48
48
 
49
49
  - name: Publish
50
50
  run: npm publish --provenance --access public
package/README.md CHANGED
@@ -20,7 +20,7 @@ There are two ways to use this package; As a data provider, or a db consumer.
20
20
 
21
21
  ## As a data provider
22
22
 
23
- Data providers utilize the various `-Data` interfaces provided in this package to construct server group data packages
23
+ Data providers utilize the various `-Data` interfaces provided in this package to construct content bundles
24
24
  that can be loaded into the db for consumption by DB consumers such as [Badger](https://github.com/n15g/badger).
25
25
 
26
26
  For an example data package, see the [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming) project.
@@ -31,12 +31,12 @@ To define content, create a new instance using the appropriate `Data` interface
31
31
 
32
32
  ```typescript
33
33
  ///test-badge.ts
34
- import {BadgeData} from 'coh-content-db'
34
+ import { BadgeData } from 'coh-content-db'
35
35
 
36
36
  export const TEST_BADGE: BadgeData = {
37
37
  key: 'test-badge',
38
38
  type: 'ACHIEVEMENT',
39
- name: [{value: 'Test Badge'}, {alignment: 'P', value: 'My Badge for Praetorians'}],
39
+ name: [{ value: 'Test Badge' }, { alignment: 'P', value: 'My Badge for Praetorians' }],
40
40
  alignment: ['H', 'V', 'P'],
41
41
  }
42
42
  ```
@@ -44,41 +44,31 @@ export const TEST_BADGE: BadgeData = {
44
44
  Then, create a `ServerGroupData` instance and load your content into the appropriate field.
45
45
 
46
46
  ```typescript
47
- import {ServerGroupData} from 'coh-content-db'
48
- import {TEST_BADGE} from './test-badge'
47
+ import { ContentBundle } from './content-bundle'
48
+ import { TEST_BADGE } from './test-badge'
49
49
 
50
- export const TEST_SERVER_GROUP: ServerGroupData = {
51
- key: 'my-server-group',
52
- name: 'My Server Group',
50
+ export const TEST_SERVER_GROUP: ContentBundle = {
51
+ name: 'My Content Bundle',
53
52
  badges: [TEST_BADGE],
54
53
  }
55
54
  ```
56
55
 
57
56
  ## As a DB consumer
58
57
 
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):
58
+ Create a new database instance, then load a content bundle, such as [coh-content-db-homecoming](https://github.com/n15g/coh-content-db-homecoming):
60
59
 
61
60
  ```typescript
62
- import {CohContentDatabase} from 'coh-content-db';
63
- import {Homecoming} from 'coh-content-db-homecoming';
61
+ import { CohContentDatabase } from 'coh-content-db';
62
+ import { Homecoming } from 'coh-content-db-homecoming';
64
63
 
65
64
  const db = new CohContentDatabase();
66
- db.loadServerGroupData(new Homecoming());
65
+ db.loadBundle(new Homecoming());
67
66
  ```
68
67
 
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();
75
- ```
76
-
77
- #### Get a server group by key and list the badges:
68
+ #### Access the content
78
69
 
79
70
  ```typescript
80
- const sg = db.getServerGroup("server-group-key");
81
- for (const badge of sg.badges) {
71
+ for (const badge of db.badges) {
82
72
  console.log(badge.key)
83
73
  }
84
74
  ```
@@ -263,21 +263,15 @@ interface GameMapData {
263
263
  }
264
264
 
265
265
  /**
266
- * A server group is a group or company that hosts a set of game servers, such as Homecoming (https://forums.homecomingservers.com/).
266
+ * A content bundle holds the data that makes up one forked instance of the game since the original sunset, such as Homecoming (https://forums.homecomingservers.com/).
267
267
  */
268
- interface ServerGroupData {
268
+ interface ContentBundle {
269
269
  /**
270
- * Unique key used to reference this server group.
271
- *
272
- * Keys can only contain lowercase letters, numbers and hyphens (`-`).
273
- */
274
- readonly key: string;
275
- /**
276
- * Name of the server group.
270
+ * Name of the fork this bundle contains data for.
277
271
  */
278
272
  readonly name: string;
279
273
  /**
280
- * Description of the server group.
274
+ * Description of the fork.
281
275
  *
282
276
  * Supports {@link https://www.markdownguide.org/|Markdown} format.
283
277
  */
@@ -291,20 +285,20 @@ interface ServerGroupData {
291
285
  */
292
286
  readonly links?: Link[];
293
287
  /**
294
- * List of the game server names in this server group.
288
+ * List of the game server names in this fork.
295
289
  * Torchbearer, Excelsior, etc.
296
290
  */
297
291
  readonly servers?: string[];
298
292
  /**
299
- * List of archetypes available in this server group.
293
+ * List of archetypes available in this fork.
300
294
  */
301
295
  readonly archetypes?: ArchetypeData[];
302
296
  /**
303
- * List of game maps supported by this server group.
297
+ * List of game maps supported by this fork.
304
298
  */
305
299
  readonly maps?: GameMapData[];
306
300
  /**
307
- * List of badges available on this server group.
301
+ * List of badges available on this fork.
308
302
  */
309
303
  readonly badges?: BadgeData[];
310
304
  /**
@@ -348,6 +342,11 @@ declare class Alternates<T> {
348
342
  * Get the list of alternates sorted in canonical order (alignment then sex, low to high specificity).
349
343
  */
350
344
  get canonical(): AlternateData<T>[];
345
+ /**
346
+ * Create a joined string from the alternate values in canonical order.
347
+ * @param separator Separator to use. Default is ' / '
348
+ */
349
+ toString(separator: string): string;
351
350
  }
352
351
 
353
352
  declare class Badge {
@@ -503,12 +502,7 @@ declare class GameMap {
503
502
  constructor(data: GameMapData);
504
503
  }
505
504
 
506
- declare class ServerGroup {
507
- #private;
508
- /**
509
- * The database key for this server group.
510
- */
511
- readonly key: string;
505
+ declare class BundleMetadata {
512
506
  /**
513
507
  * Name of the server group.
514
508
  */
@@ -526,7 +520,20 @@ declare class ServerGroup {
526
520
  /**
527
521
  * List of external links for this Server Group. Wiki, forums, etc.
528
522
  */
529
- readonly links?: Link[];
523
+ readonly links: Link[];
524
+ /**
525
+ * Change log for this data package.
526
+ */
527
+ readonly changelog: Change[];
528
+ constructor(bundle: ContentBundle);
529
+ }
530
+
531
+ declare class CohContentDatabase {
532
+ #private;
533
+ /**
534
+ * Metadata about the content bundle.
535
+ */
536
+ readonly metadata: BundleMetadata;
530
537
  /**
531
538
  * List of the game server names in this server group.
532
539
  * Torchbearer, Excelsior, etc.
@@ -545,33 +552,15 @@ declare class ServerGroup {
545
552
  */
546
553
  readonly badges: Badge[];
547
554
  /**
548
- * Change log for this data package.
555
+ * Initialize the database with a content bundle.
556
+ * @param bundle The data to load.
549
557
  */
550
- readonly changelog?: Change[];
551
- constructor(data: ServerGroupData);
558
+ constructor(bundle: ContentBundle);
552
559
  getArchetype(key: string): Archetype;
553
560
  getMap(key: string): GameMap;
554
561
  getBadge(key: string): Badge;
555
562
  }
556
563
 
557
- declare class CohContentDatabase {
558
- #private;
559
- /**
560
- * Load a server group data package into the database.
561
- * @param data The data to load.
562
- */
563
- loadServerGroupData(data: ServerGroupData): void;
564
- /**
565
- * Get all the server groups currently loaded in the database.
566
- */
567
- listServerGroups(): ServerGroup[];
568
- /**
569
- * get a server group by key.
570
- * @param serverGroupKey The key.
571
- */
572
- getServerGroup(serverGroupKey: string): ServerGroup | null;
573
- }
574
-
575
564
  declare class Key {
576
565
  #private;
577
566
  constructor(value: string);
@@ -595,4 +584,4 @@ declare function createMapReference(target: string | {
595
584
  key: string;
596
585
  }): string;
597
586
 
598
- export { ALIGNMENT, type Alignment, type AlternateData, Archetype, type ArchetypeData, BADGE_PARTIAL_TYPE, BADGE_TYPE, Badge, type BadgeData, BadgePartial, type BadgePartialData, type BadgePartialType, type BadgeType, CHANGELOG, type Change, CohContentDatabase, ENHANCEMENT_CATEGORY, type EnhancementCategory, GameMap, type GameMapData, Key, type Link, PLAQUE_TYPE, type PlaqueType, SEX, ServerGroup, type ServerGroupData, type Sex, VidiotMap, type VidiotMapData, VidiotMapPointOfInterest, type VidiotMapPointOfInterestData, createBadgeReference, createMapReference };
587
+ export { ALIGNMENT, type Alignment, type AlternateData, Archetype, type ArchetypeData, BADGE_PARTIAL_TYPE, BADGE_TYPE, Badge, type BadgeData, BadgePartial, type BadgePartialData, type BadgePartialType, type BadgeType, BundleMetadata, CHANGELOG, type Change, CohContentDatabase, type ContentBundle, ENHANCEMENT_CATEGORY, type EnhancementCategory, GameMap, type GameMapData, Key, type Link, PLAQUE_TYPE, type PlaqueType, SEX, type Sex, VidiotMap, type VidiotMapData, VidiotMapPointOfInterest, type VidiotMapPointOfInterestData, createBadgeReference, createMapReference };