@zthun/romulator-api 1.9.0 → 1.11.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,7 +1,7 @@
1
- import { IZRomulatorFilesService } from './files-service.mjs';
1
+ import { IZRomulatorFilesRepository } from './files-repository.mjs';
2
2
  export declare class ZRomulatorFilesModule {
3
3
  private readonly _files;
4
- constructor(_files: IZRomulatorFilesService);
4
+ constructor(_files: IZRomulatorFilesRepository);
5
5
  onModuleInit(): Promise<void>;
6
6
  onModuleDestroy(): Promise<void>;
7
7
  }
@@ -0,0 +1,119 @@
1
+ import { IZFileRepository, IZFileSystemNode, IZFileSystemService } from '@zthun/crumbtrail-fs';
2
+ import { ZOptional } from '@zthun/helpful-fn';
3
+ import { IZLogger } from '@zthun/lumberjacky-log';
4
+ import { IZRomulatorSystem, ZRomulatorSystemId } from '@zthun/romulator-client';
5
+ import { IZRomulatorConfigsService } from '../config/configs-service.mjs';
6
+ export declare const ZRomulatorFilesRepositoryToken: unique symbol;
7
+ /**
8
+ * Represents the repository that you can use to
9
+ * scan the games folder for media, info, games, and systems.
10
+ */
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>;
36
+ /**
37
+ * Retrieves all media found in the games .media folder.
38
+ *
39
+ * @returns
40
+ * A list of all media found in the game media folder.
41
+ */
42
+ media(): Promise<IZFileSystemNode[]>;
43
+ /**
44
+ * Retrieves all systems found in the games folder.
45
+ *
46
+ * A system is a root folder that is a slug of a supported
47
+ * system.
48
+ *
49
+ * @returns
50
+ * A list of all system folders found in the games folder.
51
+ */
52
+ systems(): Promise<IZFileSystemNode[]>;
53
+ /**
54
+ * Retrieves all games for the given systems list.
55
+ *
56
+ * @param systems -
57
+ * The list of systems to query games by.
58
+ *
59
+ * @returns
60
+ * A list of file system nodes that represent a game
61
+ * in the system directory.
62
+ */
63
+ games(systems: IZRomulatorSystem[]): Promise<IZFileSystemNode[]>;
64
+ /**
65
+ * Retrieves the file that represents the systems info or games info
66
+ * for a given system.
67
+ *
68
+ * @param id -
69
+ * Which info item you want to receive - the root system information
70
+ * or the information for a given game list for an individual system.
71
+ *
72
+ * @returns
73
+ * The node that represents the info json, or null if no such file
74
+ * exists.
75
+ */
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>;
87
+ /**
88
+ * Initializes the file repository.
89
+ */
90
+ init(): Promise<any>;
91
+ /**
92
+ * Cleans up internal resources.
93
+ */
94
+ dispose(): Promise<void>;
95
+ }
96
+ export declare class ZRomulatorFilesRepository implements IZRomulatorFilesRepository {
97
+ private readonly _configs;
98
+ private readonly _fileSystem;
99
+ readonly logger: IZLogger;
100
+ private static readonly MediaFolderName;
101
+ private static readonly InfoFolderName;
102
+ private _logger;
103
+ private _repository;
104
+ private _folderStream;
105
+ private _fileStream;
106
+ private _globs;
107
+ private _systems;
108
+ constructor(_configs: IZRomulatorConfigsService, _fileSystem: IZFileSystemService, logger: IZLogger);
109
+ gamesFolder(): Promise<string>;
110
+ mediaFolder(): Promise<string>;
111
+ infoFolder(): Promise<string>;
112
+ dispose(): Promise<void>;
113
+ init(): Promise<IZFileRepository>;
114
+ media(): Promise<IZFileSystemNode[]>;
115
+ info(id?: "systems" | ZRomulatorSystemId): Promise<IZFileSystemNode | null>;
116
+ json(node: IZFileSystemNode): Promise<unknown>;
117
+ systems(): Promise<IZFileSystemNode[]>;
118
+ games(systems: IZRomulatorSystem[]): Promise<IZFileSystemNode[]>;
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
  }