@zthun/romulator-api 1.10.0 → 1.12.0

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.
@@ -0,0 +1,27 @@
1
+ import { IZRomulatorGame } from '@zthun/romulator-client';
2
+ import { IZRomulatorFilesRepository } from './files-repository.mjs';
3
+ import { IZRomulatorFilesSystemsRepository } from './files-systems-repository.mjs';
4
+ export declare const ZRomulatorFilesGamesRepositoryToken: unique symbol;
5
+ /**
6
+ * A repository responsible for joining IZFileSystemNode objects
7
+ * with the contents of a game list json file.
8
+ */
9
+ export interface IZRomulatorFilesGamesRepository {
10
+ /**
11
+ * Reads all of the games in the games directory.
12
+ *
13
+ * Game targets are determined by the extensions in system.json.
14
+ *
15
+ * @returns
16
+ * A list of all the games that are in the games
17
+ * directory decorated with the content data in the matching
18
+ * system json file in the .info directory.
19
+ */
20
+ games(): Promise<Map<string, IZRomulatorGame>>;
21
+ }
22
+ export declare class ZRomulatorFilesGamesRepository implements IZRomulatorFilesGamesRepository {
23
+ private readonly _systemsRepository;
24
+ private readonly _filesRepository;
25
+ constructor(_systemsRepository: IZRomulatorFilesSystemsRepository, _filesRepository: IZRomulatorFilesRepository);
26
+ games(): Promise<Map<string, IZRomulatorGame>>;
27
+ }
@@ -1,12 +1,38 @@
1
1
  import { IZFileRepository, IZFileSystemNode, IZFileSystemService } from '@zthun/crumbtrail-fs';
2
- import { ZRomulatorSystemId } from '@zthun/romulator-client';
2
+ import { ZOptional } from '@zthun/helpful-fn';
3
+ import { IZLogger } from '@zthun/lumberjacky-log';
4
+ import { IZRomulatorSystem, ZRomulatorSystemId } from '@zthun/romulator-client';
3
5
  import { IZRomulatorConfigsService } from '../config/configs-service.mjs';
4
- export declare const ZRomulatorFilesToken: unique symbol;
6
+ export declare const ZRomulatorFilesRepositoryToken: unique symbol;
5
7
  /**
6
8
  * Represents the repository that you can use to
7
9
  * scan the games folder for media, info, games, and systems.
8
10
  */
9
11
  export interface IZRomulatorFilesRepository {
12
+ /**
13
+ * The absolute path to the configured games
14
+ * folder.
15
+ *
16
+ * @returns
17
+ * The absolute path to the games folder.
18
+ */
19
+ gamesFolder(): Promise<string>;
20
+ /**
21
+ * The path to the media folder.
22
+ *
23
+ * @returns
24
+ * The path to the .media folder inside the
25
+ * games folder.
26
+ */
27
+ mediaFolder(): Promise<string>;
28
+ /**
29
+ * The path to the info folder.
30
+ *
31
+ * @returns
32
+ * The path to the .info folder inside the
33
+ * games folder.
34
+ */
35
+ infoFolder(): Promise<string>;
10
36
  /**
11
37
  * Retrieves all media found in the games .media folder.
12
38
  *
@@ -25,19 +51,16 @@ export interface IZRomulatorFilesRepository {
25
51
  */
26
52
  systems(): Promise<IZFileSystemNode[]>;
27
53
  /**
28
- * Retrieves a single system found in the games folder.
54
+ * Retrieves all games for the given systems list.
29
55
  *
30
- * @param id -
31
- * The id of the system, which is also the name of the folder.
56
+ * @param systems -
57
+ * The list of systems to query games by.
32
58
  *
33
59
  * @returns
34
- * The node that represents the system slug. Returns null if
35
- * the folder does not exist or is not supported. Note
36
- * that the path is relative to the configured games folder. If you
37
- * want to supply a fully qualified absolute path, then this string
38
- * should start with the root of an OS drive (not recommended).
60
+ * A list of file system nodes that represent a game
61
+ * in the system directory.
39
62
  */
40
- systems(id: ZRomulatorSystemId): Promise<IZFileSystemNode | null>;
63
+ games(systems: IZRomulatorSystem[]): Promise<IZFileSystemNode[]>;
41
64
  /**
42
65
  * Retrieves the file that represents the systems info or games info
43
66
  * for a given system.
@@ -51,6 +74,16 @@ export interface IZRomulatorFilesRepository {
51
74
  * exists.
52
75
  */
53
76
  info(id: "systems" | ZRomulatorSystemId): Promise<IZFileSystemNode | null>;
77
+ /**
78
+ * Reads a file and returns the json representation.
79
+ *
80
+ * @param node -
81
+ * The node to read. If this is falsy, then null is returned.
82
+ *
83
+ * @returns
84
+ * The file contents as json, or null if the contents cannot be read.
85
+ */
86
+ json(node: ZOptional<IZFileSystemNode>): Promise<unknown>;
54
87
  /**
55
88
  * Initializes the file repository.
56
89
  */
@@ -63,20 +96,24 @@ export interface IZRomulatorFilesRepository {
63
96
  export declare class ZRomulatorFilesRepository implements IZRomulatorFilesRepository {
64
97
  private readonly _configs;
65
98
  private readonly _fileSystem;
99
+ readonly logger: IZLogger;
66
100
  private static readonly MediaFolderName;
67
101
  private static readonly InfoFolderName;
102
+ private _logger;
68
103
  private _repository;
69
104
  private _folderStream;
105
+ private _fileStream;
70
106
  private _globs;
71
107
  private _systems;
72
- constructor(_configs: IZRomulatorConfigsService, _fileSystem: IZFileSystemService);
73
- private gamesFolder;
74
- private mediaFolder;
75
- private infoFolder;
108
+ constructor(_configs: IZRomulatorConfigsService, _fileSystem: IZFileSystemService, logger: IZLogger);
109
+ gamesFolder(): Promise<string>;
110
+ mediaFolder(): Promise<string>;
111
+ infoFolder(): Promise<string>;
76
112
  dispose(): Promise<void>;
77
113
  init(): Promise<IZFileRepository>;
78
114
  media(): Promise<IZFileSystemNode[]>;
79
115
  info(id?: "systems" | ZRomulatorSystemId): Promise<IZFileSystemNode | null>;
116
+ json(node: IZFileSystemNode): Promise<unknown>;
80
117
  systems(): Promise<IZFileSystemNode[]>;
81
- systems(id: ZRomulatorSystemId): Promise<IZFileSystemNode | null>;
118
+ games(systems: IZRomulatorSystem[]): Promise<IZFileSystemNode[]>;
82
119
  }
@@ -0,0 +1,27 @@
1
+ import { IZRomulatorSystem, ZRomulatorSystemId } from '@zthun/romulator-client';
2
+ import { IZRomulatorFilesRepository } from './files-repository.mjs';
3
+ export declare const ZRomulatorFilesSystemsRepositoryToken: unique symbol;
4
+ /**
5
+ * A repository responsible for joining IZFileSystemNode objects
6
+ * with the contents of system.json.
7
+ */
8
+ export interface IZRomulatorFilesSystemsRepository {
9
+ /**
10
+ * Reads all system entries in the systems.json file and combines
11
+ * them with the existing system list in the games directory
12
+ *
13
+ * @returns
14
+ * A list of all the systems that are in the games
15
+ * directory decorated with the content data in systems.json
16
+ * in the .info directory.
17
+ */
18
+ systems(): Promise<Map<ZRomulatorSystemId, IZRomulatorSystem>>;
19
+ }
20
+ export declare class ZRomulatorFilesSystemsRepository implements IZRomulatorFilesSystemsRepository {
21
+ private _filesRepository;
22
+ /**
23
+ * Initializes a new instance of this object.
24
+ */
25
+ constructor(_filesRepository: IZRomulatorFilesRepository);
26
+ systems(): Promise<Map<ZRomulatorSystemId, IZRomulatorSystem>>;
27
+ }
@@ -1,19 +1,19 @@
1
- import { IZFileSystemService } from '@zthun/crumbtrail-fs';
2
- import { IZDataMatch, IZDataRequest, IZPage } from '@zthun/helpful-query';
1
+ import { IZDataRequest, IZPage } from '@zthun/helpful-query';
3
2
  import { IZLogger } from '@zthun/lumberjacky-log';
4
3
  import { IZRomulatorGame } from '@zthun/romulator-client';
5
4
  import { IZRestfulGet } from '@zthun/webigail-rest';
6
- import { IZRomulatorConfigsService } from '../config/configs-service.mjs';
5
+ import { IZRomulatorFilesGamesRepository } from '../files/files-games-repository.mjs';
6
+ import { IZRomulatorFilesSystemsRepository } from '../files/files-systems-repository.mjs';
7
7
  export declare const ZRomulatorGamesToken: unique symbol;
8
8
  export interface IZRomulatorGamesService extends IZRestfulGet<IZRomulatorGame> {
9
9
  list(req: IZDataRequest): Promise<IZPage<IZRomulatorGame>>;
10
10
  }
11
- export declare class ZRomulatorGamesService implements IZRomulatorGamesService, IZDataMatch<IZRomulatorGame, string> {
12
- private readonly _file;
13
- private readonly _config;
11
+ export declare class ZRomulatorGamesService implements IZRomulatorGamesService {
12
+ private readonly _systemsRepository;
13
+ private readonly _filesRepository;
14
+ readonly logger: IZLogger;
14
15
  private readonly _logger;
15
- constructor(_file: IZFileSystemService, _config: IZRomulatorConfigsService, logger: IZLogger);
16
+ constructor(_systemsRepository: IZRomulatorFilesSystemsRepository, _filesRepository: IZRomulatorFilesGamesRepository, logger: IZLogger);
16
17
  list(req: IZDataRequest): Promise<IZPage<IZRomulatorGame>>;
17
18
  get(id: string): Promise<IZRomulatorGame>;
18
- match(data: IZRomulatorGame, filter: string): boolean;
19
19
  }