@zthun/romulator-api 1.1.0 → 1.3.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.
- package/bin/main.mjs +1 -1
- package/dist/config/config-known.d.mts +2 -3
- package/dist/main.cjs +562 -1317
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +569 -1324
- package/dist/main.js.map +1 -1
- package/dist/media/media-controller.d.mts +10 -0
- package/dist/media/media-module.d.mts +2 -0
- package/dist/media/media-service.d.mts +24 -0
- package/dist/systems/system-known.d.mts +78 -9
- package/dist/systems/systems-service.d.mts +4 -1
- package/package.json +19 -13
package/dist/main.js
CHANGED
|
@@ -1,51 +1,38 @@
|
|
|
1
1
|
import { NestFactory } from '@nestjs/core';
|
|
2
|
-
import { ApiProperty, ApiParam, ApiBody, DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
3
|
-
import {
|
|
2
|
+
import { ApiProperty, ApiParam, ApiBody, ApiResponse, DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
3
|
+
import { InternalServerErrorException, NotFoundException, Injectable, Inject, Get, Query, Patch, UsePipes, ValidationPipe, Param, Body, Controller, Module, NotAcceptableException, StreamableFile, ForbiddenException, Req, Delete } from '@nestjs/common';
|
|
4
4
|
import { ZFileSystemModule, ZFileSystemToken } from '@zthun/crumbtrail-nest';
|
|
5
5
|
import { ZLoggerToken, ZLoggerModule } from '@zthun/lumberjacky-nest';
|
|
6
|
-
import {
|
|
6
|
+
import { ZDataSourceStaticOptionsBuilder, ZDataSearchFields, ZDataSourceStatic, ZPageBuilder, ZDataRequestBuilder } from '@zthun/helpful-query';
|
|
7
7
|
import { IsDefined, IsObject, IsNotEmptyObject } from 'class-validator';
|
|
8
|
-
import { firstDefined, createError } from '@zthun/helpful-fn';
|
|
8
|
+
import { firstDefined, createError, detokenize, firstTruthy } from '@zthun/helpful-fn';
|
|
9
9
|
import { ZLoggerContext, ZLogEntryBuilder } from '@zthun/lumberjacky-log';
|
|
10
|
-
import { ZRomulatorConfigBuilder, ZRomulatorConfigId as ZRomulatorConfigId$1, ZRomulatorConfigGamesMetadata, ZRomulatorConfigMediaMetadata, ZRomulatorSystemBuilder } from '@zthun/romulator-client';
|
|
11
|
-
import { find } from 'lodash-es';
|
|
12
|
-
import { readFile, writeFile,
|
|
10
|
+
import { ZRomulatorConfigBuilder, ZRomulatorConfigId as ZRomulatorConfigId$1, ZRomulatorConfigGamesMetadata, ZRomulatorConfigMediaMetadata, ZRomulatorSystemBuilder, ZRomulatorSystemId, ZRomulatorConfigMediaBuilder, ZRomulatorMediaBuilder } from '@zthun/romulator-client';
|
|
11
|
+
import { find, findIndex } from 'lodash-es';
|
|
12
|
+
import { readFile, mkdir, writeFile, unlink } from 'node:fs/promises';
|
|
13
13
|
import { resolve, dirname, basename } from 'node:path';
|
|
14
14
|
import { homedir } from 'node:os';
|
|
15
|
+
import { ZHttpCodeSuccess, ZHttpCodeClient } from '@zthun/webigail-http';
|
|
16
|
+
import { ZMimeTypeApplication } from '@zthun/webigail-url';
|
|
17
|
+
import { lookup } from 'mime-types';
|
|
18
|
+
import { createReadStream } from 'node:fs';
|
|
19
|
+
import { env } from 'node:process';
|
|
20
|
+
import { isTagged, ZTag } from '@zthun/helpful-reflection';
|
|
15
21
|
import 'reflect-metadata';
|
|
16
22
|
|
|
17
|
-
function
|
|
18
|
-
if (!(instance instanceof Constructor)) {
|
|
19
|
-
throw new TypeError("Cannot call a class as a function");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function _define_property$4(obj, key, value) {
|
|
23
|
-
if (key in obj) {
|
|
24
|
-
Object.defineProperty(obj, key, {
|
|
25
|
-
value: value,
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true
|
|
29
|
-
});
|
|
30
|
-
} else {
|
|
31
|
-
obj[key] = value;
|
|
32
|
-
}
|
|
33
|
-
return obj;
|
|
34
|
-
}
|
|
35
|
-
function _ts_decorate$8(decorators, target, key, desc) {
|
|
23
|
+
function _ts_decorate$b(decorators, target, key, desc) {
|
|
36
24
|
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
37
25
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
38
26
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
39
27
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
28
|
}
|
|
41
|
-
function _ts_metadata$
|
|
29
|
+
function _ts_metadata$7(k, v) {
|
|
42
30
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
31
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
_ts_decorate$8([
|
|
32
|
+
class ZRomulatorConfigUpdateDto {
|
|
33
|
+
contents;
|
|
34
|
+
}
|
|
35
|
+
_ts_decorate$b([
|
|
49
36
|
ApiProperty({
|
|
50
37
|
type: "object",
|
|
51
38
|
properties: {}
|
|
@@ -57,727 +44,177 @@ _ts_decorate$8([
|
|
|
57
44
|
message: "The contents of the config must be an object "
|
|
58
45
|
}),
|
|
59
46
|
IsNotEmptyObject(),
|
|
60
|
-
_ts_metadata$
|
|
47
|
+
_ts_metadata$7("design:type", typeof T === "undefined" ? Object : T)
|
|
61
48
|
], ZRomulatorConfigUpdateDto.prototype, "contents", void 0);
|
|
62
49
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
class ZDir {
|
|
51
|
+
static application() {
|
|
52
|
+
return resolve(homedir(), ".zthunworks", "romulator");
|
|
66
53
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
for(var i = 0; i < props.length; i++){
|
|
70
|
-
var descriptor = props[i];
|
|
71
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
72
|
-
descriptor.configurable = true;
|
|
73
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
74
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
54
|
+
static configs() {
|
|
55
|
+
return resolve(ZDir.application(), "configs");
|
|
75
56
|
}
|
|
76
57
|
}
|
|
77
|
-
function _create_class$6(Constructor, protoProps, staticProps) {
|
|
78
|
-
if (staticProps) _defineProperties$6(Constructor, staticProps);
|
|
79
|
-
return Constructor;
|
|
80
|
-
}
|
|
81
|
-
var ZDir = /*#__PURE__*/ function() {
|
|
82
|
-
function ZDir() {
|
|
83
|
-
_class_call_check$9(this, ZDir);
|
|
84
|
-
}
|
|
85
|
-
_create_class$6(ZDir, null, [
|
|
86
|
-
{
|
|
87
|
-
key: "application",
|
|
88
|
-
value: function application() {
|
|
89
|
-
return resolve(homedir(), ".zthunworks", "romulator");
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
key: "configs",
|
|
94
|
-
value: function configs() {
|
|
95
|
-
return resolve(ZDir.application(), "configs");
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
]);
|
|
99
|
-
return ZDir;
|
|
100
|
-
}();
|
|
101
58
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
59
|
+
class ZRomulatorConfigKnown {
|
|
60
|
+
static all() {
|
|
61
|
+
return [
|
|
62
|
+
ZRomulatorConfigKnown.games(),
|
|
63
|
+
ZRomulatorConfigKnown.media()
|
|
64
|
+
];
|
|
105
65
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
var descriptor = props[i];
|
|
110
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
111
|
-
descriptor.configurable = true;
|
|
112
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
113
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
66
|
+
static create(id) {
|
|
67
|
+
const file = resolve(ZDir.configs(), `${id}.json`);
|
|
68
|
+
return new ZRomulatorConfigBuilder().id(id).file(file);
|
|
114
69
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (staticProps) _defineProperties$5(Constructor, staticProps);
|
|
118
|
-
return Constructor;
|
|
119
|
-
}
|
|
120
|
-
var ZRomulatorConfigKnown = /*#__PURE__*/ function() {
|
|
121
|
-
function ZRomulatorConfigKnown() {
|
|
122
|
-
_class_call_check$8(this, ZRomulatorConfigKnown);
|
|
70
|
+
static games() {
|
|
71
|
+
return ZRomulatorConfigKnown.create(ZRomulatorConfigId$1.Games).name("Game Settings").description("Modify where your games are stored and related settings").avatar("gamepad").metadata(ZRomulatorConfigGamesMetadata.all()).build();
|
|
123
72
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
key: "all",
|
|
127
|
-
value: function all() {
|
|
128
|
-
return [
|
|
129
|
-
ZRomulatorConfigKnown.games().build(),
|
|
130
|
-
ZRomulatorConfigKnown.media().build()
|
|
131
|
-
];
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
key: "create",
|
|
136
|
-
value: function create(id) {
|
|
137
|
-
var file = resolve(ZDir.configs(), "".concat(id, ".json"));
|
|
138
|
-
return new ZRomulatorConfigBuilder().id(id).file(file);
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
key: "games",
|
|
143
|
-
value: function games() {
|
|
144
|
-
return ZRomulatorConfigKnown.create(ZRomulatorConfigId$1.Games).name("Game Settings").description("Modify where your games are stored and related settings").avatar("gamepad").metadata(ZRomulatorConfigGamesMetadata.all());
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
key: "media",
|
|
149
|
-
value: function media() {
|
|
150
|
-
return ZRomulatorConfigKnown.create(ZRomulatorConfigId$1.Media).name("Media Settings").description("Modify where media is stored and what media to retrieve").avatar("image").metadata(ZRomulatorConfigMediaMetadata.all());
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
]);
|
|
154
|
-
return ZRomulatorConfigKnown;
|
|
155
|
-
}();
|
|
156
|
-
|
|
157
|
-
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
158
|
-
try {
|
|
159
|
-
var info = gen[key](arg);
|
|
160
|
-
var value = info.value;
|
|
161
|
-
} catch (error) {
|
|
162
|
-
reject(error);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (info.done) {
|
|
166
|
-
resolve(value);
|
|
167
|
-
} else {
|
|
168
|
-
Promise.resolve(value).then(_next, _throw);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function _async_to_generator$3(fn) {
|
|
172
|
-
return function() {
|
|
173
|
-
var self = this, args = arguments;
|
|
174
|
-
return new Promise(function(resolve, reject) {
|
|
175
|
-
var gen = fn.apply(self, args);
|
|
176
|
-
function _next(value) {
|
|
177
|
-
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
178
|
-
}
|
|
179
|
-
function _throw(err) {
|
|
180
|
-
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
181
|
-
}
|
|
182
|
-
_next(undefined);
|
|
183
|
-
});
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function _class_call_check$7(instance, Constructor) {
|
|
187
|
-
if (!(instance instanceof Constructor)) {
|
|
188
|
-
throw new TypeError("Cannot call a class as a function");
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
function _defineProperties$4(target, props) {
|
|
192
|
-
for(var i = 0; i < props.length; i++){
|
|
193
|
-
var descriptor = props[i];
|
|
194
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
195
|
-
descriptor.configurable = true;
|
|
196
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
197
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
function _create_class$4(Constructor, protoProps, staticProps) {
|
|
201
|
-
if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
|
|
202
|
-
return Constructor;
|
|
203
|
-
}
|
|
204
|
-
function _define_property$3(obj, key, value) {
|
|
205
|
-
if (key in obj) {
|
|
206
|
-
Object.defineProperty(obj, key, {
|
|
207
|
-
value: value,
|
|
208
|
-
enumerable: true,
|
|
209
|
-
configurable: true,
|
|
210
|
-
writable: true
|
|
211
|
-
});
|
|
212
|
-
} else {
|
|
213
|
-
obj[key] = value;
|
|
214
|
-
}
|
|
215
|
-
return obj;
|
|
216
|
-
}
|
|
217
|
-
function _object_spread(target) {
|
|
218
|
-
for(var i = 1; i < arguments.length; i++){
|
|
219
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
220
|
-
var ownKeys = Object.keys(source);
|
|
221
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
222
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
223
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
224
|
-
}));
|
|
225
|
-
}
|
|
226
|
-
ownKeys.forEach(function(key) {
|
|
227
|
-
_define_property$3(target, key, source[key]);
|
|
228
|
-
});
|
|
73
|
+
static media() {
|
|
74
|
+
return ZRomulatorConfigKnown.create(ZRomulatorConfigId$1.Media).name("Media Settings").description("Modify where media is stored and what media to retrieve").avatar("image").metadata(ZRomulatorConfigMediaMetadata.all()).build();
|
|
229
75
|
}
|
|
230
|
-
return target;
|
|
231
76
|
}
|
|
232
|
-
|
|
77
|
+
|
|
78
|
+
function _ts_decorate$a(decorators, target, key, desc) {
|
|
233
79
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
234
80
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
235
81
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
236
82
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
237
83
|
}
|
|
238
|
-
function
|
|
239
|
-
var f, y, t, _ = {
|
|
240
|
-
label: 0,
|
|
241
|
-
sent: function() {
|
|
242
|
-
if (t[0] & 1) throw t[1];
|
|
243
|
-
return t[1];
|
|
244
|
-
},
|
|
245
|
-
trys: [],
|
|
246
|
-
ops: []
|
|
247
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
248
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
249
|
-
return this;
|
|
250
|
-
}), g;
|
|
251
|
-
function verb(n) {
|
|
252
|
-
return function(v) {
|
|
253
|
-
return step([
|
|
254
|
-
n,
|
|
255
|
-
v
|
|
256
|
-
]);
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
function step(op) {
|
|
260
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
261
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
262
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
263
|
-
if (y = 0, t) op = [
|
|
264
|
-
op[0] & 2,
|
|
265
|
-
t.value
|
|
266
|
-
];
|
|
267
|
-
switch(op[0]){
|
|
268
|
-
case 0:
|
|
269
|
-
case 1:
|
|
270
|
-
t = op;
|
|
271
|
-
break;
|
|
272
|
-
case 4:
|
|
273
|
-
_.label++;
|
|
274
|
-
return {
|
|
275
|
-
value: op[1],
|
|
276
|
-
done: false
|
|
277
|
-
};
|
|
278
|
-
case 5:
|
|
279
|
-
_.label++;
|
|
280
|
-
y = op[1];
|
|
281
|
-
op = [
|
|
282
|
-
0
|
|
283
|
-
];
|
|
284
|
-
continue;
|
|
285
|
-
case 7:
|
|
286
|
-
op = _.ops.pop();
|
|
287
|
-
_.trys.pop();
|
|
288
|
-
continue;
|
|
289
|
-
default:
|
|
290
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
291
|
-
_ = 0;
|
|
292
|
-
continue;
|
|
293
|
-
}
|
|
294
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
295
|
-
_.label = op[1];
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
299
|
-
_.label = t[1];
|
|
300
|
-
t = op;
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
if (t && _.label < t[2]) {
|
|
304
|
-
_.label = t[2];
|
|
305
|
-
_.ops.push(op);
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
if (t[2]) _.ops.pop();
|
|
309
|
-
_.trys.pop();
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
op = body.call(thisArg, _);
|
|
313
|
-
} catch (e) {
|
|
314
|
-
op = [
|
|
315
|
-
6,
|
|
316
|
-
e
|
|
317
|
-
];
|
|
318
|
-
y = 0;
|
|
319
|
-
} finally{
|
|
320
|
-
f = t = 0;
|
|
321
|
-
}
|
|
322
|
-
if (op[0] & 5) throw op[1];
|
|
323
|
-
return {
|
|
324
|
-
value: op[0] ? op[1] : void 0,
|
|
325
|
-
done: true
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
function _ts_metadata$4(k, v) {
|
|
84
|
+
function _ts_metadata$6(k, v) {
|
|
330
85
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
331
86
|
}
|
|
332
|
-
function _ts_param$
|
|
87
|
+
function _ts_param$5(paramIndex, decorator) {
|
|
333
88
|
return function(target, key) {
|
|
334
89
|
decorator(target, key, paramIndex);
|
|
335
90
|
};
|
|
336
91
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
_define_property$3(this, "_logger", void 0);
|
|
92
|
+
const ZRomulatorConfigsToken = Symbol("configs");
|
|
93
|
+
class ZRomulatorConfigsService {
|
|
94
|
+
_logger;
|
|
95
|
+
constructor(_logger){
|
|
342
96
|
this._logger = new ZLoggerContext("ZRomulatorConfigsService", _logger);
|
|
343
97
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
contents = {};
|
|
399
|
-
_state.label = 2;
|
|
400
|
-
case 2:
|
|
401
|
-
_state.trys.push([
|
|
402
|
-
2,
|
|
403
|
-
4,
|
|
404
|
-
,
|
|
405
|
-
5
|
|
406
|
-
]);
|
|
407
|
-
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
408
|
-
return [
|
|
409
|
-
4,
|
|
410
|
-
readFile(config.file)
|
|
411
|
-
];
|
|
412
|
-
case 3:
|
|
413
|
-
buffer = _state.sent();
|
|
414
|
-
json = buffer.toString("utf-8");
|
|
415
|
-
contents = JSON.parse(json);
|
|
416
|
-
msg = "Finished reading config contents (".concat(buffer.byteLength, " bytes)");
|
|
417
|
-
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
418
|
-
return [
|
|
419
|
-
3,
|
|
420
|
-
5
|
|
421
|
-
];
|
|
422
|
-
case 4:
|
|
423
|
-
e = _state.sent();
|
|
424
|
-
msg = createError(e).message;
|
|
425
|
-
this._logger.log(new ZLogEntryBuilder().warning().message(msg).build());
|
|
426
|
-
return [
|
|
427
|
-
3,
|
|
428
|
-
5
|
|
429
|
-
];
|
|
430
|
-
case 5:
|
|
431
|
-
result = new ZRomulatorConfigBuilder().copy(config).contents(contents).build();
|
|
432
|
-
return [
|
|
433
|
-
2,
|
|
434
|
-
Promise.resolve(result)
|
|
435
|
-
];
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
}).call(this);
|
|
439
|
-
}
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
key: "update",
|
|
443
|
-
value: function update(id, record) {
|
|
444
|
-
return _async_to_generator$3(function() {
|
|
445
|
-
var config, msg, next, json, e, error;
|
|
446
|
-
return _ts_generator$3(this, function(_state) {
|
|
447
|
-
switch(_state.label){
|
|
448
|
-
case 0:
|
|
449
|
-
return [
|
|
450
|
-
4,
|
|
451
|
-
this.get(id)
|
|
452
|
-
];
|
|
453
|
-
case 1:
|
|
454
|
-
config = _state.sent();
|
|
455
|
-
msg = "Updating config file, ".concat(id);
|
|
456
|
-
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
457
|
-
next = _object_spread({}, config.contents, record.contents);
|
|
458
|
-
json = JSON.stringify(next);
|
|
459
|
-
_state.label = 2;
|
|
460
|
-
case 2:
|
|
461
|
-
_state.trys.push([
|
|
462
|
-
2,
|
|
463
|
-
5,
|
|
464
|
-
,
|
|
465
|
-
6
|
|
466
|
-
]);
|
|
467
|
-
return [
|
|
468
|
-
4,
|
|
469
|
-
mkdir(dirname(config.file), {
|
|
470
|
-
recursive: true
|
|
471
|
-
})
|
|
472
|
-
];
|
|
473
|
-
case 3:
|
|
474
|
-
_state.sent();
|
|
475
|
-
return [
|
|
476
|
-
4,
|
|
477
|
-
writeFile(config.file, json)
|
|
478
|
-
];
|
|
479
|
-
case 4:
|
|
480
|
-
_state.sent();
|
|
481
|
-
return [
|
|
482
|
-
2,
|
|
483
|
-
new ZRomulatorConfigBuilder().copy(config).contents(next).build()
|
|
484
|
-
];
|
|
485
|
-
case 5:
|
|
486
|
-
e = _state.sent();
|
|
487
|
-
error = createError(e);
|
|
488
|
-
msg = "Unable to write to, ".concat(config.file);
|
|
489
|
-
this._logger.log(new ZLogEntryBuilder().error().message(msg).build());
|
|
490
|
-
msg = error.message;
|
|
491
|
-
this._logger.log(new ZLogEntryBuilder().error().message(msg).build());
|
|
492
|
-
return [
|
|
493
|
-
2,
|
|
494
|
-
Promise.reject(new InternalServerErrorException(error))
|
|
495
|
-
];
|
|
496
|
-
case 6:
|
|
497
|
-
return [
|
|
498
|
-
2
|
|
499
|
-
];
|
|
500
|
-
}
|
|
501
|
-
});
|
|
502
|
-
}).call(this);
|
|
503
|
-
}
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
key: "_find",
|
|
507
|
-
value: function _find(id) {
|
|
508
|
-
return _async_to_generator$3(function() {
|
|
509
|
-
var msg, configs, config;
|
|
510
|
-
return _ts_generator$3(this, function(_state) {
|
|
511
|
-
msg = "Attempting to retrieve config, ".concat(id);
|
|
512
|
-
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
513
|
-
configs = ZRomulatorConfigKnown.all();
|
|
514
|
-
config = find(configs, function(c) {
|
|
515
|
-
return c.id === id;
|
|
516
|
-
});
|
|
517
|
-
if (config == null) {
|
|
518
|
-
msg = "Could not find config, ".concat(id);
|
|
519
|
-
this._logger.log(new ZLogEntryBuilder().error().message(msg).build());
|
|
520
|
-
return [
|
|
521
|
-
2,
|
|
522
|
-
Promise.reject(new NotFoundException(msg))
|
|
523
|
-
];
|
|
524
|
-
}
|
|
525
|
-
msg = "Config, ".concat(id, ", found");
|
|
526
|
-
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
527
|
-
return [
|
|
528
|
-
2,
|
|
529
|
-
config
|
|
530
|
-
];
|
|
531
|
-
});
|
|
532
|
-
}).call(this);
|
|
533
|
-
}
|
|
98
|
+
async list(req) {
|
|
99
|
+
const page = firstDefined(1, req.page);
|
|
100
|
+
const size = firstDefined(Infinity, req.size);
|
|
101
|
+
let msg = `Retrieving configs page, ${page}, with size, ${size}`;
|
|
102
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
103
|
+
const configs = ZRomulatorConfigKnown.all();
|
|
104
|
+
const options = new ZDataSourceStaticOptionsBuilder().search(new ZDataSearchFields()).build();
|
|
105
|
+
const source = new ZDataSourceStatic(configs, options);
|
|
106
|
+
const data = await source.retrieve(req);
|
|
107
|
+
const count = await source.count(req);
|
|
108
|
+
msg = `Responding with ${data.length} configs out of ${count} total`;
|
|
109
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
110
|
+
return new ZPageBuilder().data(data).count(count).build();
|
|
111
|
+
}
|
|
112
|
+
async get(id) {
|
|
113
|
+
const config = await this._find(id);
|
|
114
|
+
let msg = `Attempting to read the file contents for config, ${id}.`;
|
|
115
|
+
let contents = {};
|
|
116
|
+
try {
|
|
117
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
118
|
+
const buffer = await readFile(config.file);
|
|
119
|
+
const json = buffer.toString("utf-8");
|
|
120
|
+
contents = JSON.parse(json);
|
|
121
|
+
msg = `Finished reading config contents (${buffer.byteLength} bytes)`;
|
|
122
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
123
|
+
} catch (e) {
|
|
124
|
+
msg = createError(e).message;
|
|
125
|
+
this._logger.log(new ZLogEntryBuilder().warning().message(msg).build());
|
|
126
|
+
}
|
|
127
|
+
const result = new ZRomulatorConfigBuilder().copy(config).contents(contents).build();
|
|
128
|
+
return Promise.resolve(result);
|
|
129
|
+
}
|
|
130
|
+
async update(id, record) {
|
|
131
|
+
const config = await this.get(id);
|
|
132
|
+
let msg = `Updating config file, ${id}`;
|
|
133
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
134
|
+
const next = {
|
|
135
|
+
...config.contents,
|
|
136
|
+
...record.contents
|
|
137
|
+
};
|
|
138
|
+
const json = JSON.stringify(next);
|
|
139
|
+
try {
|
|
140
|
+
await mkdir(dirname(config.file), {
|
|
141
|
+
recursive: true
|
|
142
|
+
});
|
|
143
|
+
await writeFile(config.file, json);
|
|
144
|
+
return new ZRomulatorConfigBuilder().copy(config).contents(next).build();
|
|
145
|
+
} catch (e) {
|
|
146
|
+
const error = createError(e);
|
|
147
|
+
msg = `Unable to write to, ${config.file}`;
|
|
148
|
+
this._logger.log(new ZLogEntryBuilder().error().message(msg).build());
|
|
149
|
+
msg = error.message;
|
|
150
|
+
this._logger.log(new ZLogEntryBuilder().error().message(msg).build());
|
|
151
|
+
return Promise.reject(new InternalServerErrorException(error));
|
|
534
152
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
}
|
|
538
|
-
|
|
153
|
+
}
|
|
154
|
+
async _find(id) {
|
|
155
|
+
let msg = `Attempting to retrieve config, ${id}`;
|
|
156
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
157
|
+
const configs = ZRomulatorConfigKnown.all();
|
|
158
|
+
const config = find(configs, (c)=>c.id === id);
|
|
159
|
+
if (config == null) {
|
|
160
|
+
msg = `Could not find config, ${id}`;
|
|
161
|
+
this._logger.log(new ZLogEntryBuilder().error().message(msg).build());
|
|
162
|
+
return Promise.reject(new NotFoundException(msg));
|
|
163
|
+
}
|
|
164
|
+
msg = `Config, ${id}, found`;
|
|
165
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
166
|
+
return config;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
ZRomulatorConfigsService = _ts_decorate$a([
|
|
539
170
|
Injectable(),
|
|
540
|
-
_ts_param$
|
|
541
|
-
_ts_metadata$
|
|
542
|
-
_ts_metadata$
|
|
171
|
+
_ts_param$5(0, Inject(ZLoggerToken)),
|
|
172
|
+
_ts_metadata$6("design:type", Function),
|
|
173
|
+
_ts_metadata$6("design:paramtypes", [
|
|
543
174
|
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
544
175
|
])
|
|
545
176
|
], ZRomulatorConfigsService);
|
|
546
177
|
|
|
547
|
-
function
|
|
548
|
-
try {
|
|
549
|
-
var info = gen[key](arg);
|
|
550
|
-
var value = info.value;
|
|
551
|
-
} catch (error) {
|
|
552
|
-
reject(error);
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
if (info.done) {
|
|
556
|
-
resolve(value);
|
|
557
|
-
} else {
|
|
558
|
-
Promise.resolve(value).then(_next, _throw);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
function _async_to_generator$2(fn) {
|
|
562
|
-
return function() {
|
|
563
|
-
var self = this, args = arguments;
|
|
564
|
-
return new Promise(function(resolve, reject) {
|
|
565
|
-
var gen = fn.apply(self, args);
|
|
566
|
-
function _next(value) {
|
|
567
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
568
|
-
}
|
|
569
|
-
function _throw(err) {
|
|
570
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
571
|
-
}
|
|
572
|
-
_next(undefined);
|
|
573
|
-
});
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
function _class_call_check$6(instance, Constructor) {
|
|
577
|
-
if (!(instance instanceof Constructor)) {
|
|
578
|
-
throw new TypeError("Cannot call a class as a function");
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
function _defineProperties$3(target, props) {
|
|
582
|
-
for(var i = 0; i < props.length; i++){
|
|
583
|
-
var descriptor = props[i];
|
|
584
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
585
|
-
descriptor.configurable = true;
|
|
586
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
587
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
function _create_class$3(Constructor, protoProps, staticProps) {
|
|
591
|
-
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
592
|
-
return Constructor;
|
|
593
|
-
}
|
|
594
|
-
function _define_property$2(obj, key, value) {
|
|
595
|
-
if (key in obj) {
|
|
596
|
-
Object.defineProperty(obj, key, {
|
|
597
|
-
value: value,
|
|
598
|
-
enumerable: true,
|
|
599
|
-
configurable: true,
|
|
600
|
-
writable: true
|
|
601
|
-
});
|
|
602
|
-
} else {
|
|
603
|
-
obj[key] = value;
|
|
604
|
-
}
|
|
605
|
-
return obj;
|
|
606
|
-
}
|
|
607
|
-
function _ts_decorate$6(decorators, target, key, desc) {
|
|
178
|
+
function _ts_decorate$9(decorators, target, key, desc) {
|
|
608
179
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
609
180
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
610
181
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
611
182
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
612
183
|
}
|
|
613
|
-
function
|
|
614
|
-
var f, y, t, _ = {
|
|
615
|
-
label: 0,
|
|
616
|
-
sent: function() {
|
|
617
|
-
if (t[0] & 1) throw t[1];
|
|
618
|
-
return t[1];
|
|
619
|
-
},
|
|
620
|
-
trys: [],
|
|
621
|
-
ops: []
|
|
622
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
623
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
624
|
-
return this;
|
|
625
|
-
}), g;
|
|
626
|
-
function verb(n) {
|
|
627
|
-
return function(v) {
|
|
628
|
-
return step([
|
|
629
|
-
n,
|
|
630
|
-
v
|
|
631
|
-
]);
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
function step(op) {
|
|
635
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
636
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
637
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
638
|
-
if (y = 0, t) op = [
|
|
639
|
-
op[0] & 2,
|
|
640
|
-
t.value
|
|
641
|
-
];
|
|
642
|
-
switch(op[0]){
|
|
643
|
-
case 0:
|
|
644
|
-
case 1:
|
|
645
|
-
t = op;
|
|
646
|
-
break;
|
|
647
|
-
case 4:
|
|
648
|
-
_.label++;
|
|
649
|
-
return {
|
|
650
|
-
value: op[1],
|
|
651
|
-
done: false
|
|
652
|
-
};
|
|
653
|
-
case 5:
|
|
654
|
-
_.label++;
|
|
655
|
-
y = op[1];
|
|
656
|
-
op = [
|
|
657
|
-
0
|
|
658
|
-
];
|
|
659
|
-
continue;
|
|
660
|
-
case 7:
|
|
661
|
-
op = _.ops.pop();
|
|
662
|
-
_.trys.pop();
|
|
663
|
-
continue;
|
|
664
|
-
default:
|
|
665
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
666
|
-
_ = 0;
|
|
667
|
-
continue;
|
|
668
|
-
}
|
|
669
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
670
|
-
_.label = op[1];
|
|
671
|
-
break;
|
|
672
|
-
}
|
|
673
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
674
|
-
_.label = t[1];
|
|
675
|
-
t = op;
|
|
676
|
-
break;
|
|
677
|
-
}
|
|
678
|
-
if (t && _.label < t[2]) {
|
|
679
|
-
_.label = t[2];
|
|
680
|
-
_.ops.push(op);
|
|
681
|
-
break;
|
|
682
|
-
}
|
|
683
|
-
if (t[2]) _.ops.pop();
|
|
684
|
-
_.trys.pop();
|
|
685
|
-
continue;
|
|
686
|
-
}
|
|
687
|
-
op = body.call(thisArg, _);
|
|
688
|
-
} catch (e) {
|
|
689
|
-
op = [
|
|
690
|
-
6,
|
|
691
|
-
e
|
|
692
|
-
];
|
|
693
|
-
y = 0;
|
|
694
|
-
} finally{
|
|
695
|
-
f = t = 0;
|
|
696
|
-
}
|
|
697
|
-
if (op[0] & 5) throw op[1];
|
|
698
|
-
return {
|
|
699
|
-
value: op[0] ? op[1] : void 0,
|
|
700
|
-
done: true
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
function _ts_metadata$3(k, v) {
|
|
184
|
+
function _ts_metadata$5(k, v) {
|
|
705
185
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
706
186
|
}
|
|
707
|
-
function _ts_param$
|
|
187
|
+
function _ts_param$4(paramIndex, decorator) {
|
|
708
188
|
return function(target, key) {
|
|
709
189
|
decorator(target, key, paramIndex);
|
|
710
190
|
};
|
|
711
191
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
_define_property$2(this, "_configs", void 0);
|
|
192
|
+
class ZRomulatorConfigsController {
|
|
193
|
+
_configs;
|
|
194
|
+
constructor(_configs){
|
|
716
195
|
this._configs = _configs;
|
|
717
196
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
});
|
|
731
|
-
}).call(this);
|
|
732
|
-
}
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
key: "update",
|
|
736
|
-
value: function update(identification, payload) {
|
|
737
|
-
return _async_to_generator$2(function() {
|
|
738
|
-
return _ts_generator$2(this, function(_state) {
|
|
739
|
-
return [
|
|
740
|
-
2,
|
|
741
|
-
this._configs.update(identification, payload)
|
|
742
|
-
];
|
|
743
|
-
});
|
|
744
|
-
}).call(this);
|
|
745
|
-
}
|
|
746
|
-
},
|
|
747
|
-
{
|
|
748
|
-
key: "get",
|
|
749
|
-
value: function get(identification) {
|
|
750
|
-
return _async_to_generator$2(function() {
|
|
751
|
-
return _ts_generator$2(this, function(_state) {
|
|
752
|
-
switch(_state.label){
|
|
753
|
-
case 0:
|
|
754
|
-
return [
|
|
755
|
-
4,
|
|
756
|
-
this._configs.get(identification)
|
|
757
|
-
];
|
|
758
|
-
case 1:
|
|
759
|
-
return [
|
|
760
|
-
2,
|
|
761
|
-
_state.sent()
|
|
762
|
-
];
|
|
763
|
-
}
|
|
764
|
-
});
|
|
765
|
-
}).call(this);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
]);
|
|
769
|
-
return ZRomulatorConfigsController;
|
|
770
|
-
}();
|
|
771
|
-
_ts_decorate$6([
|
|
197
|
+
async list(query) {
|
|
198
|
+
const request = new ZDataRequestBuilder().query(query).build();
|
|
199
|
+
return this._configs.list(request);
|
|
200
|
+
}
|
|
201
|
+
async update(identification, payload) {
|
|
202
|
+
return this._configs.update(identification, payload);
|
|
203
|
+
}
|
|
204
|
+
async get(identification) {
|
|
205
|
+
return await this._configs.get(identification);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
_ts_decorate$9([
|
|
772
209
|
Get(),
|
|
773
|
-
_ts_param$
|
|
774
|
-
_ts_metadata$
|
|
775
|
-
_ts_metadata$
|
|
210
|
+
_ts_param$4(0, Query()),
|
|
211
|
+
_ts_metadata$5("design:type", Function),
|
|
212
|
+
_ts_metadata$5("design:paramtypes", [
|
|
776
213
|
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
777
214
|
]),
|
|
778
|
-
_ts_metadata$
|
|
215
|
+
_ts_metadata$5("design:returntype", Promise)
|
|
779
216
|
], ZRomulatorConfigsController.prototype, "list", null);
|
|
780
|
-
_ts_decorate$
|
|
217
|
+
_ts_decorate$9([
|
|
781
218
|
ApiParam({
|
|
782
219
|
type: "string",
|
|
783
220
|
name: "identification",
|
|
@@ -794,53 +231,47 @@ _ts_decorate$6([
|
|
|
794
231
|
skipNullProperties: false,
|
|
795
232
|
skipUndefinedProperties: false
|
|
796
233
|
})),
|
|
797
|
-
_ts_param$
|
|
798
|
-
_ts_param$
|
|
799
|
-
_ts_metadata$
|
|
800
|
-
_ts_metadata$
|
|
234
|
+
_ts_param$4(0, Param("identification")),
|
|
235
|
+
_ts_param$4(1, Body()),
|
|
236
|
+
_ts_metadata$5("design:type", Function),
|
|
237
|
+
_ts_metadata$5("design:paramtypes", [
|
|
801
238
|
typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId,
|
|
802
239
|
typeof ZRomulatorConfigUpdateDto === "undefined" ? Object : ZRomulatorConfigUpdateDto
|
|
803
240
|
]),
|
|
804
|
-
_ts_metadata$
|
|
241
|
+
_ts_metadata$5("design:returntype", Promise)
|
|
805
242
|
], ZRomulatorConfigsController.prototype, "update", null);
|
|
806
|
-
_ts_decorate$
|
|
243
|
+
_ts_decorate$9([
|
|
807
244
|
ApiParam({
|
|
808
245
|
type: "string",
|
|
809
246
|
name: "identification",
|
|
810
247
|
description: "The id of the config"
|
|
811
248
|
}),
|
|
812
249
|
Get(":identification"),
|
|
813
|
-
_ts_param$
|
|
814
|
-
_ts_metadata$
|
|
815
|
-
_ts_metadata$
|
|
250
|
+
_ts_param$4(0, Param("identification")),
|
|
251
|
+
_ts_metadata$5("design:type", Function),
|
|
252
|
+
_ts_metadata$5("design:paramtypes", [
|
|
816
253
|
typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId
|
|
817
254
|
]),
|
|
818
|
-
_ts_metadata$
|
|
255
|
+
_ts_metadata$5("design:returntype", Promise)
|
|
819
256
|
], ZRomulatorConfigsController.prototype, "get", null);
|
|
820
|
-
ZRomulatorConfigsController = _ts_decorate$
|
|
257
|
+
ZRomulatorConfigsController = _ts_decorate$9([
|
|
821
258
|
Controller("configs"),
|
|
822
|
-
_ts_param$
|
|
823
|
-
_ts_metadata$
|
|
824
|
-
_ts_metadata$
|
|
259
|
+
_ts_param$4(0, Inject(ZRomulatorConfigsToken)),
|
|
260
|
+
_ts_metadata$5("design:type", Function),
|
|
261
|
+
_ts_metadata$5("design:paramtypes", [
|
|
825
262
|
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService
|
|
826
263
|
])
|
|
827
264
|
], ZRomulatorConfigsController);
|
|
828
265
|
|
|
829
|
-
function
|
|
830
|
-
if (!(instance instanceof Constructor)) {
|
|
831
|
-
throw new TypeError("Cannot call a class as a function");
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
function _ts_decorate$5(decorators, target, key, desc) {
|
|
266
|
+
function _ts_decorate$8(decorators, target, key, desc) {
|
|
835
267
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
836
268
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
837
269
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
838
270
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
839
271
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
ZRomulatorConfigsModule = _ts_decorate$5([
|
|
272
|
+
class ZRomulatorConfigsModule {
|
|
273
|
+
}
|
|
274
|
+
ZRomulatorConfigsModule = _ts_decorate$8([
|
|
844
275
|
Module({
|
|
845
276
|
imports: [
|
|
846
277
|
ZFileSystemModule,
|
|
@@ -861,137 +292,94 @@ ZRomulatorConfigsModule = _ts_decorate$5([
|
|
|
861
292
|
})
|
|
862
293
|
], ZRomulatorConfigsModule);
|
|
863
294
|
|
|
864
|
-
function
|
|
865
|
-
if (!(instance instanceof Constructor)) {
|
|
866
|
-
throw new TypeError("Cannot call a class as a function");
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
function _defineProperties$2(target, props) {
|
|
870
|
-
for(var i = 0; i < props.length; i++){
|
|
871
|
-
var descriptor = props[i];
|
|
872
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
873
|
-
descriptor.configurable = true;
|
|
874
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
875
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
function _create_class$2(Constructor, protoProps, staticProps) {
|
|
879
|
-
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
880
|
-
return Constructor;
|
|
881
|
-
}
|
|
882
|
-
function _ts_decorate$4(decorators, target, key, desc) {
|
|
295
|
+
function _ts_decorate$7(decorators, target, key, desc) {
|
|
883
296
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
884
297
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
885
298
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
886
299
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
887
300
|
}
|
|
888
|
-
function _ts_metadata$
|
|
301
|
+
function _ts_metadata$4(k, v) {
|
|
889
302
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
890
303
|
}
|
|
891
|
-
|
|
892
|
-
function KnownSystem() {
|
|
893
|
-
return function(_, __, descriptor) {
|
|
894
|
-
Reflect.defineMetadata(IS_SYSTEM, true, descriptor.value);
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
function isKnownSystem(target) {
|
|
898
|
-
return target != null && Reflect.getMetadata(IS_SYSTEM, target) === true;
|
|
899
|
-
}
|
|
304
|
+
const KnownSystem = "@zthunworks/romulator/known-system";
|
|
900
305
|
/**
|
|
901
306
|
* A helper factory class for creating supported systems.
|
|
902
|
-
*/
|
|
903
|
-
|
|
904
|
-
|
|
307
|
+
*/ class ZRomulatorSystemKnown {
|
|
308
|
+
/**
|
|
309
|
+
* Returns all known systems.
|
|
310
|
+
*
|
|
311
|
+
* @returns
|
|
312
|
+
* All supported systems.
|
|
313
|
+
*/ static all() {
|
|
314
|
+
const properties = Object.getOwnPropertyNames(ZRomulatorSystemKnown);
|
|
315
|
+
const methods = properties.filter((p)=>isTagged(KnownSystem, ZRomulatorSystemKnown, p)).map((p)=>ZRomulatorSystemKnown[p]).map((f)=>f);
|
|
316
|
+
return methods.map((m)=>m.call(null));
|
|
905
317
|
}
|
|
906
|
-
|
|
907
|
-
{
|
|
908
|
-
key: "nes",
|
|
909
|
-
value: /**
|
|
318
|
+
/**
|
|
910
319
|
* Creates a system that represents the Nintendo
|
|
911
320
|
* Entertainment System (NES).
|
|
912
321
|
*
|
|
913
322
|
* @returns
|
|
914
323
|
* A {@link ZRomulatorSystemBuilder} instance that has
|
|
915
324
|
* built the nes.
|
|
916
|
-
*/
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
{
|
|
921
|
-
key: "snes",
|
|
922
|
-
value: /**
|
|
325
|
+
*/ static nes() {
|
|
326
|
+
return new ZRomulatorSystemBuilder().id(ZRomulatorSystemId.Nintendo).console().name("Nintendo Entertainment System").alias("Famicom").alias("NES").alias("Hyundai Comboy").alias("Samurai Electronic TV Game System").alias("Dendy").generation(3).manufacturer("Nintendo").build();
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
923
329
|
* Creates a system that represents the Super
|
|
924
330
|
* Nintendo Entertainment System (SNES).
|
|
925
331
|
*
|
|
926
332
|
* @returns
|
|
927
333
|
* This instance.
|
|
928
|
-
*/
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
{
|
|
933
|
-
key: "n64",
|
|
934
|
-
value: /**
|
|
334
|
+
*/ static snes() {
|
|
335
|
+
return new ZRomulatorSystemBuilder().id(ZRomulatorSystemId.SuperNintendo).console().name("Super Nintendo Entertainment System").alias("Super Nintendo").alias("Super Famicom").alias("SNES").alias("Super NES").alias("Super Comboy").generation(4).manufacturer("Nintendo").build();
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
935
338
|
* Creates a system that represents the Nintendo
|
|
936
339
|
* 64 (N64).
|
|
937
340
|
*
|
|
938
341
|
* @returns
|
|
939
342
|
* This instance.
|
|
940
|
-
*/
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
{
|
|
945
|
-
key: "gc",
|
|
946
|
-
value: /**
|
|
343
|
+
*/ static n64() {
|
|
344
|
+
return new ZRomulatorSystemBuilder().id(ZRomulatorSystemId.Nintendo64).console().name("Nintendo 64").alias("N64").alias("Ultra 64").alias("Hyundai Comboy 64").generation(5).manufacturer("Nintendo").build();
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
947
347
|
* Creates a system that represents the Nintendo
|
|
948
348
|
* GameCube (GC).
|
|
949
349
|
*
|
|
950
350
|
* @returns
|
|
951
351
|
* This instance.
|
|
952
|
-
*/
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
{
|
|
957
|
-
key: "wii",
|
|
958
|
-
value: /**
|
|
352
|
+
*/ static gc() {
|
|
353
|
+
return new ZRomulatorSystemBuilder().id(ZRomulatorSystemId.GameCube).console().name("Nintendo GameCube").alias("GameCube").alias("Dolphin").generation(6).manufacturer("Nintendo").manufacturer("Foxconn").build();
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
959
356
|
* Creates a system that represents the Nintendo
|
|
960
357
|
* Wii (Wii).
|
|
961
358
|
*
|
|
962
359
|
* @returns
|
|
963
360
|
* This instance.
|
|
964
|
-
*/
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
{
|
|
969
|
-
key: "wiiu",
|
|
970
|
-
value: /**
|
|
361
|
+
*/ static wii() {
|
|
362
|
+
return new ZRomulatorSystemBuilder().id(ZRomulatorSystemId.Wii).console().name("Nintendo Wii").alias("Wii").alias("Revolution").generation(7).manufacturer("Foxconn").build();
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
971
365
|
* Creates a system that represents the Nintendo
|
|
972
366
|
* Wii U (WiiU).
|
|
973
367
|
*
|
|
974
368
|
* @returns
|
|
975
369
|
* This instance.
|
|
976
|
-
*/
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
{
|
|
981
|
-
key: "switch",
|
|
982
|
-
value: /**
|
|
370
|
+
*/ static wiiu() {
|
|
371
|
+
return new ZRomulatorSystemBuilder().id(ZRomulatorSystemId.WiiU).console().name("Nintendo Wii U").alias("WiiU").alias("Project Cafe").generation(8).manufacturer("Nintendo").manufacturer("Foxconn").manufacturer("Mitsumi").build();
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
983
374
|
* Creates a system that represents the Nintendo
|
|
984
375
|
* Switch (Switch).
|
|
985
376
|
*
|
|
986
377
|
* @returns
|
|
987
378
|
* This instance.
|
|
988
|
-
*/
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
{
|
|
993
|
-
key: "from",
|
|
994
|
-
value: /**
|
|
379
|
+
*/ static switch() {
|
|
380
|
+
return new ZRomulatorSystemBuilder().id(ZRomulatorSystemId.Switch).console().name("Nintendo Switch").alias("Switch").alias("NX").alias("HAC").alias("Odin").generation(9).manufacturer("Foxconn").manufacturer("Hosiden").build();
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
995
383
|
* Creates a system from an id slug.
|
|
996
384
|
*
|
|
997
385
|
* @param id -
|
|
@@ -999,216 +387,317 @@ function isKnownSystem(target) {
|
|
|
999
387
|
*
|
|
1000
388
|
* @return
|
|
1001
389
|
* The system, or null if the id is not known.
|
|
1002
|
-
*/
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
return system();
|
|
1006
|
-
}
|
|
1007
|
-
return null;
|
|
1008
|
-
}
|
|
390
|
+
*/ static from(id) {
|
|
391
|
+
if (isTagged(KnownSystem, ZRomulatorSystemKnown, id)) {
|
|
392
|
+
return ZRomulatorSystemKnown[id]();
|
|
1009
393
|
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1013
|
-
_ts_decorate$
|
|
1014
|
-
KnownSystem
|
|
1015
|
-
_ts_metadata$
|
|
1016
|
-
_ts_metadata$
|
|
1017
|
-
_ts_metadata$
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
_ts_decorate$7([
|
|
398
|
+
ZTag(KnownSystem),
|
|
399
|
+
_ts_metadata$4("design:type", Function),
|
|
400
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
401
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1018
402
|
], ZRomulatorSystemKnown, "nes", null);
|
|
1019
|
-
_ts_decorate$
|
|
1020
|
-
KnownSystem
|
|
1021
|
-
_ts_metadata$
|
|
1022
|
-
_ts_metadata$
|
|
1023
|
-
_ts_metadata$
|
|
403
|
+
_ts_decorate$7([
|
|
404
|
+
ZTag(KnownSystem),
|
|
405
|
+
_ts_metadata$4("design:type", Function),
|
|
406
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
407
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1024
408
|
], ZRomulatorSystemKnown, "snes", null);
|
|
1025
|
-
_ts_decorate$
|
|
1026
|
-
KnownSystem
|
|
1027
|
-
_ts_metadata$
|
|
1028
|
-
_ts_metadata$
|
|
1029
|
-
_ts_metadata$
|
|
409
|
+
_ts_decorate$7([
|
|
410
|
+
ZTag(KnownSystem),
|
|
411
|
+
_ts_metadata$4("design:type", Function),
|
|
412
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
413
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1030
414
|
], ZRomulatorSystemKnown, "n64", null);
|
|
1031
|
-
_ts_decorate$
|
|
1032
|
-
KnownSystem
|
|
1033
|
-
_ts_metadata$
|
|
1034
|
-
_ts_metadata$
|
|
1035
|
-
_ts_metadata$
|
|
415
|
+
_ts_decorate$7([
|
|
416
|
+
ZTag(KnownSystem),
|
|
417
|
+
_ts_metadata$4("design:type", Function),
|
|
418
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
419
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1036
420
|
], ZRomulatorSystemKnown, "gc", null);
|
|
1037
|
-
_ts_decorate$
|
|
1038
|
-
KnownSystem
|
|
1039
|
-
_ts_metadata$
|
|
1040
|
-
_ts_metadata$
|
|
1041
|
-
_ts_metadata$
|
|
421
|
+
_ts_decorate$7([
|
|
422
|
+
ZTag(KnownSystem),
|
|
423
|
+
_ts_metadata$4("design:type", Function),
|
|
424
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
425
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1042
426
|
], ZRomulatorSystemKnown, "wii", null);
|
|
1043
|
-
_ts_decorate$
|
|
1044
|
-
KnownSystem
|
|
1045
|
-
_ts_metadata$
|
|
1046
|
-
_ts_metadata$
|
|
1047
|
-
_ts_metadata$
|
|
427
|
+
_ts_decorate$7([
|
|
428
|
+
ZTag(KnownSystem),
|
|
429
|
+
_ts_metadata$4("design:type", Function),
|
|
430
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
431
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1048
432
|
], ZRomulatorSystemKnown, "wiiu", null);
|
|
1049
|
-
_ts_decorate$
|
|
1050
|
-
KnownSystem
|
|
1051
|
-
_ts_metadata$
|
|
1052
|
-
_ts_metadata$
|
|
1053
|
-
_ts_metadata$
|
|
433
|
+
_ts_decorate$7([
|
|
434
|
+
ZTag(KnownSystem),
|
|
435
|
+
_ts_metadata$4("design:type", Function),
|
|
436
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
437
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1054
438
|
], ZRomulatorSystemKnown, "switch", null);
|
|
1055
439
|
|
|
1056
|
-
function
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
reject(error);
|
|
1062
|
-
return;
|
|
1063
|
-
}
|
|
1064
|
-
if (info.done) {
|
|
1065
|
-
resolve(value);
|
|
1066
|
-
} else {
|
|
1067
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1068
|
-
}
|
|
440
|
+
function _ts_decorate$6(decorators, target, key, desc) {
|
|
441
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
442
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
443
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
444
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1069
445
|
}
|
|
1070
|
-
function
|
|
1071
|
-
return
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
1077
|
-
}
|
|
1078
|
-
function _throw(err) {
|
|
1079
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1080
|
-
}
|
|
1081
|
-
_next(undefined);
|
|
1082
|
-
});
|
|
446
|
+
function _ts_metadata$3(k, v) {
|
|
447
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
448
|
+
}
|
|
449
|
+
function _ts_param$3(paramIndex, decorator) {
|
|
450
|
+
return function(target, key) {
|
|
451
|
+
decorator(target, key, paramIndex);
|
|
1083
452
|
};
|
|
1084
453
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
454
|
+
const ZRomulatorMediaToken = Symbol("romulator-media-service");
|
|
455
|
+
class ZRomulatorMediaService {
|
|
456
|
+
_file;
|
|
457
|
+
_config;
|
|
458
|
+
_logger;
|
|
459
|
+
constructor(_file, _config, logger){
|
|
460
|
+
this._file = _file;
|
|
461
|
+
this._config = _config;
|
|
462
|
+
this._logger = new ZLoggerContext("ZRomulatorMediaService", logger);
|
|
463
|
+
}
|
|
464
|
+
async getMediaFolder() {
|
|
465
|
+
const mediaConfig = ZRomulatorConfigKnown.media();
|
|
466
|
+
const { contents } = await this._config.get(mediaConfig.id);
|
|
467
|
+
const { mediaFolder } = new ZRomulatorConfigMediaBuilder().copy(contents).build();
|
|
468
|
+
return detokenize(mediaFolder, env);
|
|
469
|
+
}
|
|
470
|
+
async findAllMedia(cwd) {
|
|
471
|
+
const systems = ZRomulatorSystemKnown.all().map((s)=>s.id).join(",");
|
|
472
|
+
const glob = `{${systems}}/**`;
|
|
473
|
+
const files = await this._file.search(glob, {
|
|
474
|
+
cwd,
|
|
475
|
+
stat: false
|
|
476
|
+
});
|
|
477
|
+
return files.map((f)=>new ZRomulatorMediaBuilder().from(f.path).build()).filter((media)=>!!media.id);
|
|
478
|
+
}
|
|
479
|
+
async list(req) {
|
|
480
|
+
const cwd = await this.getMediaFolder();
|
|
481
|
+
let msg = `Reading all media from ${cwd}`;
|
|
482
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
483
|
+
const time = new Date();
|
|
484
|
+
const mediaList = await this.findAllMedia(cwd);
|
|
485
|
+
const span = new Date().getTime() - time.getTime();
|
|
486
|
+
msg = `Found ${mediaList.length} media files. Search took ${span} milliseconds`;
|
|
487
|
+
const options = new ZDataSourceStaticOptionsBuilder().search(new ZDataSearchFields()).build();
|
|
488
|
+
const source = new ZDataSourceStatic(mediaList, options);
|
|
489
|
+
const page = await source.retrieve(req);
|
|
490
|
+
const count = await source.count(req);
|
|
491
|
+
return new ZPageBuilder().data(page).count(count).build();
|
|
492
|
+
}
|
|
493
|
+
async get(id) {
|
|
494
|
+
const cwd = await this.getMediaFolder();
|
|
495
|
+
const time = new Date();
|
|
496
|
+
let log = `Searching for media with id ${id}.`;
|
|
497
|
+
this._logger.log(new ZLogEntryBuilder().info().message(log).build());
|
|
498
|
+
const mediaList = await this.findAllMedia(cwd);
|
|
499
|
+
const index = findIndex(mediaList, (m)=>m.id === id);
|
|
500
|
+
const span = new Date().getTime() - time.getTime();
|
|
501
|
+
if (index < 0) {
|
|
502
|
+
const msg = `Could not find any media with id, ${id}.`;
|
|
503
|
+
log = `${msg} Search took ${span} milliseconds`;
|
|
504
|
+
this._logger.log(new ZLogEntryBuilder().warning().message(log).build());
|
|
505
|
+
throw new NotFoundException(msg);
|
|
506
|
+
}
|
|
507
|
+
const media = mediaList[index];
|
|
508
|
+
log = `Found media, ${media.url} after ${span} milliseconds`;
|
|
509
|
+
this._logger.log(new ZLogEntryBuilder().info().message(log).build());
|
|
510
|
+
return media;
|
|
511
|
+
}
|
|
512
|
+
async download(id, accept) {
|
|
513
|
+
let log = `Download request received for ${id}`;
|
|
514
|
+
this._logger.log(new ZLogEntryBuilder().info().message(log).build());
|
|
515
|
+
const fallback = ZMimeTypeApplication.OctetStream;
|
|
516
|
+
const { fileName, url } = await this.get(id);
|
|
517
|
+
const lookupResult = lookup(firstDefined("", fileName));
|
|
518
|
+
const mime = firstTruthy(fallback, lookupResult);
|
|
519
|
+
const accepts = accept.split(",").map((h)=>h.split(";")[0].trim());
|
|
520
|
+
const acceptable = accepts.some((a)=>{
|
|
521
|
+
if (a === "*/*") {
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
if (a.endsWith("/*")) {
|
|
525
|
+
return mime.startsWith(a.slice(0, -1));
|
|
526
|
+
}
|
|
527
|
+
return a === mime;
|
|
528
|
+
});
|
|
529
|
+
if (!acceptable) {
|
|
530
|
+
const msg = `The media requested is of type ${mime}. ` + `The request only accepts ${accept}.`;
|
|
531
|
+
this._logger.log(new ZLogEntryBuilder().error().message(msg).build());
|
|
532
|
+
throw new NotAcceptableException(msg);
|
|
533
|
+
}
|
|
534
|
+
log = `Streaming ${url}`;
|
|
535
|
+
this._logger.log(new ZLogEntryBuilder().info().message(log).build());
|
|
536
|
+
return new StreamableFile(createReadStream(firstDefined("", url)), {
|
|
537
|
+
type: mime,
|
|
538
|
+
disposition: `inline; filename=${fileName}`
|
|
539
|
+
});
|
|
1088
540
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
541
|
+
async delete(id) {
|
|
542
|
+
const { url } = await this.get(id);
|
|
543
|
+
const _url = firstDefined("", url);
|
|
544
|
+
let log = `Attempting to delete file ${_url}`;
|
|
545
|
+
this._logger.log(new ZLogEntryBuilder().info().message(log).build());
|
|
546
|
+
try {
|
|
547
|
+
await unlink(_url);
|
|
548
|
+
} catch (err) {
|
|
549
|
+
const { message } = createError(err);
|
|
550
|
+
this._logger.log(new ZLogEntryBuilder().error().message(message).build());
|
|
551
|
+
throw new ForbiddenException(message);
|
|
552
|
+
}
|
|
553
|
+
log = `Deleted ${url}`;
|
|
554
|
+
this._logger.log(new ZLogEntryBuilder().info().message(log).build());
|
|
1097
555
|
}
|
|
1098
556
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
557
|
+
ZRomulatorMediaService = _ts_decorate$6([
|
|
558
|
+
Injectable(),
|
|
559
|
+
_ts_param$3(0, Inject(ZFileSystemToken)),
|
|
560
|
+
_ts_param$3(1, Inject(ZRomulatorConfigsToken)),
|
|
561
|
+
_ts_param$3(2, Inject(ZLoggerToken)),
|
|
562
|
+
_ts_metadata$3("design:type", Function),
|
|
563
|
+
_ts_metadata$3("design:paramtypes", [
|
|
564
|
+
typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
|
|
565
|
+
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
|
|
566
|
+
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
567
|
+
])
|
|
568
|
+
], ZRomulatorMediaService);
|
|
569
|
+
|
|
570
|
+
function _ts_decorate$5(decorators, target, key, desc) {
|
|
571
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
572
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
573
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
574
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1102
575
|
}
|
|
1103
|
-
function
|
|
1104
|
-
if (
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
576
|
+
function _ts_metadata$2(k, v) {
|
|
577
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
578
|
+
}
|
|
579
|
+
function _ts_param$2(paramIndex, decorator) {
|
|
580
|
+
return function(target, key) {
|
|
581
|
+
decorator(target, key, paramIndex);
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
class ZRomulatorMediaController {
|
|
585
|
+
_media;
|
|
586
|
+
constructor(_media){
|
|
587
|
+
this._media = _media;
|
|
588
|
+
}
|
|
589
|
+
list(params) {
|
|
590
|
+
const request = new ZDataRequestBuilder().query(params).build();
|
|
591
|
+
return this._media.list(request);
|
|
592
|
+
}
|
|
593
|
+
async get(identification, req) {
|
|
594
|
+
const { accept = "*/*" } = req.headers;
|
|
595
|
+
return accept.includes("application/json") ? this._media.get(identification) : this._media.download(identification, accept);
|
|
596
|
+
}
|
|
597
|
+
async delete(identification) {
|
|
598
|
+
await this._media.delete(identification);
|
|
1113
599
|
}
|
|
1114
|
-
return obj;
|
|
1115
600
|
}
|
|
1116
|
-
|
|
601
|
+
_ts_decorate$5([
|
|
602
|
+
Get(),
|
|
603
|
+
_ts_param$2(0, Query()),
|
|
604
|
+
_ts_metadata$2("design:type", Function),
|
|
605
|
+
_ts_metadata$2("design:paramtypes", [
|
|
606
|
+
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
607
|
+
]),
|
|
608
|
+
_ts_metadata$2("design:returntype", void 0)
|
|
609
|
+
], ZRomulatorMediaController.prototype, "list", null);
|
|
610
|
+
_ts_decorate$5([
|
|
611
|
+
ApiParam({
|
|
612
|
+
type: "string",
|
|
613
|
+
name: "identification",
|
|
614
|
+
description: "The id of the media"
|
|
615
|
+
}),
|
|
616
|
+
ApiResponse({
|
|
617
|
+
status: ZHttpCodeSuccess.OK,
|
|
618
|
+
description: "Returns the media",
|
|
619
|
+
content: {
|
|
620
|
+
"*/*": {},
|
|
621
|
+
"image/*": {},
|
|
622
|
+
"image/png": {},
|
|
623
|
+
"image/jpeg": {},
|
|
624
|
+
"application/mp4": {},
|
|
625
|
+
"application/json": {}
|
|
626
|
+
}
|
|
627
|
+
}),
|
|
628
|
+
ApiResponse({
|
|
629
|
+
status: ZHttpCodeClient.NotFound,
|
|
630
|
+
description: "Media not found"
|
|
631
|
+
}),
|
|
632
|
+
ApiResponse({
|
|
633
|
+
status: ZHttpCodeClient.NotAcceptable,
|
|
634
|
+
description: "Unsupported Accept header"
|
|
635
|
+
}),
|
|
636
|
+
Get(":identification"),
|
|
637
|
+
_ts_param$2(0, Param("identification")),
|
|
638
|
+
_ts_param$2(1, Req()),
|
|
639
|
+
_ts_metadata$2("design:type", Function),
|
|
640
|
+
_ts_metadata$2("design:paramtypes", [
|
|
641
|
+
String,
|
|
642
|
+
typeof Request === "undefined" ? Object : Request
|
|
643
|
+
]),
|
|
644
|
+
_ts_metadata$2("design:returntype", Promise)
|
|
645
|
+
], ZRomulatorMediaController.prototype, "get", null);
|
|
646
|
+
_ts_decorate$5([
|
|
647
|
+
ApiParam({
|
|
648
|
+
type: "string",
|
|
649
|
+
name: "identification",
|
|
650
|
+
description: "The id of the media"
|
|
651
|
+
}),
|
|
652
|
+
Delete(":identification"),
|
|
653
|
+
_ts_param$2(0, Param("identification")),
|
|
654
|
+
_ts_metadata$2("design:type", Function),
|
|
655
|
+
_ts_metadata$2("design:paramtypes", [
|
|
656
|
+
String
|
|
657
|
+
]),
|
|
658
|
+
_ts_metadata$2("design:returntype", Promise)
|
|
659
|
+
], ZRomulatorMediaController.prototype, "delete", null);
|
|
660
|
+
ZRomulatorMediaController = _ts_decorate$5([
|
|
661
|
+
Controller("media"),
|
|
662
|
+
_ts_param$2(0, Inject(ZRomulatorMediaToken)),
|
|
663
|
+
_ts_metadata$2("design:type", Function),
|
|
664
|
+
_ts_metadata$2("design:paramtypes", [
|
|
665
|
+
typeof IZRomulatorMediaService === "undefined" ? Object : IZRomulatorMediaService
|
|
666
|
+
])
|
|
667
|
+
], ZRomulatorMediaController);
|
|
668
|
+
|
|
669
|
+
function _ts_decorate$4(decorators, target, key, desc) {
|
|
1117
670
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1118
671
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1119
672
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1120
673
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1121
674
|
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
n,
|
|
1139
|
-
v
|
|
1140
|
-
]);
|
|
1141
|
-
};
|
|
1142
|
-
}
|
|
1143
|
-
function step(op) {
|
|
1144
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1145
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1146
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1147
|
-
if (y = 0, t) op = [
|
|
1148
|
-
op[0] & 2,
|
|
1149
|
-
t.value
|
|
1150
|
-
];
|
|
1151
|
-
switch(op[0]){
|
|
1152
|
-
case 0:
|
|
1153
|
-
case 1:
|
|
1154
|
-
t = op;
|
|
1155
|
-
break;
|
|
1156
|
-
case 4:
|
|
1157
|
-
_.label++;
|
|
1158
|
-
return {
|
|
1159
|
-
value: op[1],
|
|
1160
|
-
done: false
|
|
1161
|
-
};
|
|
1162
|
-
case 5:
|
|
1163
|
-
_.label++;
|
|
1164
|
-
y = op[1];
|
|
1165
|
-
op = [
|
|
1166
|
-
0
|
|
1167
|
-
];
|
|
1168
|
-
continue;
|
|
1169
|
-
case 7:
|
|
1170
|
-
op = _.ops.pop();
|
|
1171
|
-
_.trys.pop();
|
|
1172
|
-
continue;
|
|
1173
|
-
default:
|
|
1174
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1175
|
-
_ = 0;
|
|
1176
|
-
continue;
|
|
1177
|
-
}
|
|
1178
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1179
|
-
_.label = op[1];
|
|
1180
|
-
break;
|
|
1181
|
-
}
|
|
1182
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1183
|
-
_.label = t[1];
|
|
1184
|
-
t = op;
|
|
1185
|
-
break;
|
|
1186
|
-
}
|
|
1187
|
-
if (t && _.label < t[2]) {
|
|
1188
|
-
_.label = t[2];
|
|
1189
|
-
_.ops.push(op);
|
|
1190
|
-
break;
|
|
1191
|
-
}
|
|
1192
|
-
if (t[2]) _.ops.pop();
|
|
1193
|
-
_.trys.pop();
|
|
1194
|
-
continue;
|
|
675
|
+
class ZRomulatorMediaModule {
|
|
676
|
+
}
|
|
677
|
+
ZRomulatorMediaModule = _ts_decorate$4([
|
|
678
|
+
Module({
|
|
679
|
+
imports: [
|
|
680
|
+
ZFileSystemModule,
|
|
681
|
+
ZRomulatorConfigsModule,
|
|
682
|
+
ZLoggerModule
|
|
683
|
+
],
|
|
684
|
+
controllers: [
|
|
685
|
+
ZRomulatorMediaController
|
|
686
|
+
],
|
|
687
|
+
providers: [
|
|
688
|
+
{
|
|
689
|
+
provide: ZRomulatorMediaToken,
|
|
690
|
+
useClass: ZRomulatorMediaService
|
|
1195
691
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
}
|
|
1206
|
-
if (op[0] & 5) throw op[1];
|
|
1207
|
-
return {
|
|
1208
|
-
value: op[0] ? op[1] : void 0,
|
|
1209
|
-
done: true
|
|
1210
|
-
};
|
|
1211
|
-
}
|
|
692
|
+
]
|
|
693
|
+
})
|
|
694
|
+
], ZRomulatorMediaModule);
|
|
695
|
+
|
|
696
|
+
function _ts_decorate$3(decorators, target, key, desc) {
|
|
697
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
698
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
699
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
700
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1212
701
|
}
|
|
1213
702
|
function _ts_metadata$1(k, v) {
|
|
1214
703
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
@@ -1218,150 +707,69 @@ function _ts_param$1(paramIndex, decorator) {
|
|
|
1218
707
|
decorator(target, key, paramIndex);
|
|
1219
708
|
};
|
|
1220
709
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
710
|
+
const ZRomulatorSystemsToken = Symbol("romulator-systems-service");
|
|
711
|
+
class ZRomulatorSystemsService {
|
|
712
|
+
_file;
|
|
713
|
+
_configs;
|
|
714
|
+
logger;
|
|
715
|
+
_logger;
|
|
716
|
+
constructor(_file, _configs, logger){
|
|
1227
717
|
this._file = _file;
|
|
1228
718
|
this._configs = _configs;
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
"name",
|
|
1267
|
-
"short"
|
|
1268
|
-
])).build();
|
|
1269
|
-
source = new ZDataSourceStatic(systems, sourceOptions);
|
|
1270
|
-
return [
|
|
1271
|
-
4,
|
|
1272
|
-
source.retrieve(req)
|
|
1273
|
-
];
|
|
1274
|
-
case 3:
|
|
1275
|
-
data = _state.sent();
|
|
1276
|
-
return [
|
|
1277
|
-
4,
|
|
1278
|
-
source.count(req)
|
|
1279
|
-
];
|
|
1280
|
-
case 4:
|
|
1281
|
-
count = _state.sent();
|
|
1282
|
-
return [
|
|
1283
|
-
2,
|
|
1284
|
-
new ZPageBuilder().data(data).count(count).build()
|
|
1285
|
-
];
|
|
1286
|
-
}
|
|
1287
|
-
});
|
|
1288
|
-
}).call(this);
|
|
1289
|
-
}
|
|
1290
|
-
},
|
|
1291
|
-
{
|
|
1292
|
-
key: "get",
|
|
1293
|
-
value: function get(id) {
|
|
1294
|
-
return _async_to_generator$1(function() {
|
|
1295
|
-
var all, system;
|
|
1296
|
-
return _ts_generator$1(this, function(_state) {
|
|
1297
|
-
switch(_state.label){
|
|
1298
|
-
case 0:
|
|
1299
|
-
return [
|
|
1300
|
-
4,
|
|
1301
|
-
this.list(new ZDataRequestBuilder().build())
|
|
1302
|
-
];
|
|
1303
|
-
case 1:
|
|
1304
|
-
all = _state.sent();
|
|
1305
|
-
system = find(all.data, function(system) {
|
|
1306
|
-
return system.id === id;
|
|
1307
|
-
});
|
|
1308
|
-
if (!system) {
|
|
1309
|
-
throw new NotFoundException("Unable to find system with id, ".concat(id, "."));
|
|
1310
|
-
}
|
|
1311
|
-
return [
|
|
1312
|
-
2,
|
|
1313
|
-
system
|
|
1314
|
-
];
|
|
1315
|
-
}
|
|
1316
|
-
});
|
|
1317
|
-
}).call(this);
|
|
1318
|
-
}
|
|
719
|
+
this.logger = logger;
|
|
720
|
+
this._logger = new ZLoggerContext("ZRomulatorSystemsService", logger);
|
|
721
|
+
}
|
|
722
|
+
async list(req) {
|
|
723
|
+
const page = firstDefined(1, req.page);
|
|
724
|
+
const size = firstDefined(Infinity, req.size);
|
|
725
|
+
let msg = `Retrieving systems page, ${page}, with size, ${size}.`;
|
|
726
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
727
|
+
const { contents } = await this._configs.get(ZRomulatorConfigId$1.Games);
|
|
728
|
+
const { gamesFolder } = contents;
|
|
729
|
+
const { fallback } = ZRomulatorConfigGamesMetadata.gamesFolder();
|
|
730
|
+
const _folder = firstDefined(fallback, gamesFolder);
|
|
731
|
+
const cwd = detokenize(_folder, process.env);
|
|
732
|
+
msg = `Looking for systems in ${cwd}`;
|
|
733
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
734
|
+
const searchOptions = {
|
|
735
|
+
cwd
|
|
736
|
+
};
|
|
737
|
+
const folders = await this._file.search("*/", searchOptions);
|
|
738
|
+
const systems = folders.map((folder)=>folder.path).map((path)=>basename(path)).map((slug)=>ZRomulatorSystemKnown.from(slug)).filter((system)=>system != null);
|
|
739
|
+
msg = `Found ${systems.length} systems`;
|
|
740
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
741
|
+
const sourceOptions = new ZDataSourceStaticOptionsBuilder().search(new ZDataSearchFields([
|
|
742
|
+
"id",
|
|
743
|
+
"name",
|
|
744
|
+
"short"
|
|
745
|
+
])).build();
|
|
746
|
+
const source = new ZDataSourceStatic(systems, sourceOptions);
|
|
747
|
+
const data = await source.retrieve(req);
|
|
748
|
+
const count = await source.count(req);
|
|
749
|
+
return new ZPageBuilder().data(data).count(count).build();
|
|
750
|
+
}
|
|
751
|
+
async get(id) {
|
|
752
|
+
const all = await this.list(new ZDataRequestBuilder().build());
|
|
753
|
+
const system = find(all.data, (system)=>system.id === id);
|
|
754
|
+
if (!system) {
|
|
755
|
+
throw new NotFoundException(`Unable to find system with id, ${id}.`);
|
|
1319
756
|
}
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
}
|
|
757
|
+
return system;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
1323
760
|
ZRomulatorSystemsService = _ts_decorate$3([
|
|
1324
761
|
Injectable(),
|
|
1325
762
|
_ts_param$1(0, Inject(ZFileSystemToken)),
|
|
1326
763
|
_ts_param$1(1, Inject(ZRomulatorConfigsToken)),
|
|
764
|
+
_ts_param$1(2, Inject(ZLoggerToken)),
|
|
1327
765
|
_ts_metadata$1("design:type", Function),
|
|
1328
766
|
_ts_metadata$1("design:paramtypes", [
|
|
1329
767
|
typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
|
|
1330
|
-
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService
|
|
768
|
+
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
|
|
769
|
+
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
1331
770
|
])
|
|
1332
771
|
], ZRomulatorSystemsService);
|
|
1333
772
|
|
|
1334
|
-
function _class_call_check$2(instance, Constructor) {
|
|
1335
|
-
if (!(instance instanceof Constructor)) {
|
|
1336
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
function _defineProperties(target, props) {
|
|
1340
|
-
for(var i = 0; i < props.length; i++){
|
|
1341
|
-
var descriptor = props[i];
|
|
1342
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1343
|
-
descriptor.configurable = true;
|
|
1344
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
1345
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
1349
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
1350
|
-
return Constructor;
|
|
1351
|
-
}
|
|
1352
|
-
function _define_property(obj, key, value) {
|
|
1353
|
-
if (key in obj) {
|
|
1354
|
-
Object.defineProperty(obj, key, {
|
|
1355
|
-
value: value,
|
|
1356
|
-
enumerable: true,
|
|
1357
|
-
configurable: true,
|
|
1358
|
-
writable: true
|
|
1359
|
-
});
|
|
1360
|
-
} else {
|
|
1361
|
-
obj[key] = value;
|
|
1362
|
-
}
|
|
1363
|
-
return obj;
|
|
1364
|
-
}
|
|
1365
773
|
function _ts_decorate$2(decorators, target, key, desc) {
|
|
1366
774
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1367
775
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1376,28 +784,18 @@ function _ts_param(paramIndex, decorator) {
|
|
|
1376
784
|
decorator(target, key, paramIndex);
|
|
1377
785
|
};
|
|
1378
786
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
_define_property(this, "_systems", void 0);
|
|
787
|
+
class ZRomulatorSystemsController {
|
|
788
|
+
_systems;
|
|
789
|
+
constructor(_systems){
|
|
1383
790
|
this._systems = _systems;
|
|
1384
791
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
{
|
|
1393
|
-
key: "get",
|
|
1394
|
-
value: function get(identification) {
|
|
1395
|
-
return this._systems.get(identification);
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
]);
|
|
1399
|
-
return ZRomulatorSystemsController;
|
|
1400
|
-
}();
|
|
792
|
+
list(query) {
|
|
793
|
+
return this._systems.list(new ZDataRequestBuilder().query(query).build());
|
|
794
|
+
}
|
|
795
|
+
get(identification) {
|
|
796
|
+
return this._systems.get(identification);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
1401
799
|
_ts_decorate$2([
|
|
1402
800
|
Get(),
|
|
1403
801
|
_ts_param(0, Query()),
|
|
@@ -1409,7 +807,7 @@ _ts_decorate$2([
|
|
|
1409
807
|
], ZRomulatorSystemsController.prototype, "list", null);
|
|
1410
808
|
_ts_decorate$2([
|
|
1411
809
|
ApiParam({
|
|
1412
|
-
type: "string
|
|
810
|
+
type: "string",
|
|
1413
811
|
name: "identification",
|
|
1414
812
|
description: "The id of the system"
|
|
1415
813
|
}),
|
|
@@ -1430,25 +828,20 @@ ZRomulatorSystemsController = _ts_decorate$2([
|
|
|
1430
828
|
])
|
|
1431
829
|
], ZRomulatorSystemsController);
|
|
1432
830
|
|
|
1433
|
-
function _class_call_check$1(instance, Constructor) {
|
|
1434
|
-
if (!(instance instanceof Constructor)) {
|
|
1435
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
831
|
function _ts_decorate$1(decorators, target, key, desc) {
|
|
1439
832
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1440
833
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1441
834
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1442
835
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1443
836
|
}
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
};
|
|
837
|
+
class ZRomulatorSystemsModule {
|
|
838
|
+
}
|
|
1447
839
|
ZRomulatorSystemsModule = _ts_decorate$1([
|
|
1448
840
|
Module({
|
|
1449
841
|
imports: [
|
|
1450
842
|
ZRomulatorConfigsModule,
|
|
1451
|
-
ZFileSystemModule
|
|
843
|
+
ZFileSystemModule,
|
|
844
|
+
ZLoggerModule
|
|
1452
845
|
],
|
|
1453
846
|
controllers: [
|
|
1454
847
|
ZRomulatorSystemsController
|
|
@@ -1462,180 +855,32 @@ ZRomulatorSystemsModule = _ts_decorate$1([
|
|
|
1462
855
|
})
|
|
1463
856
|
], ZRomulatorSystemsModule);
|
|
1464
857
|
|
|
1465
|
-
/* istanbul ignore file -- @preserve */ function
|
|
1466
|
-
if (!(instance instanceof Constructor)) {
|
|
1467
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
858
|
+
/* istanbul ignore file -- @preserve */ function _ts_decorate(decorators, target, key, desc) {
|
|
1471
859
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1472
860
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1473
861
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1474
862
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1475
863
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
};
|
|
864
|
+
class ZRomulatorModule {
|
|
865
|
+
}
|
|
1479
866
|
ZRomulatorModule = _ts_decorate([
|
|
1480
867
|
Module({
|
|
1481
868
|
imports: [
|
|
1482
869
|
ZRomulatorSystemsModule,
|
|
1483
|
-
ZRomulatorConfigsModule
|
|
870
|
+
ZRomulatorConfigsModule,
|
|
871
|
+
ZRomulatorMediaModule
|
|
1484
872
|
]
|
|
1485
873
|
})
|
|
1486
874
|
], ZRomulatorModule);
|
|
1487
875
|
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
resolve(value);
|
|
1498
|
-
} else {
|
|
1499
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
function _async_to_generator(fn) {
|
|
1503
|
-
return function() {
|
|
1504
|
-
var self = this, args = arguments;
|
|
1505
|
-
return new Promise(function(resolve, reject) {
|
|
1506
|
-
var gen = fn.apply(self, args);
|
|
1507
|
-
function _next(value) {
|
|
1508
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
1509
|
-
}
|
|
1510
|
-
function _throw(err) {
|
|
1511
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1512
|
-
}
|
|
1513
|
-
_next(undefined);
|
|
1514
|
-
});
|
|
1515
|
-
};
|
|
1516
|
-
}
|
|
1517
|
-
function _ts_generator(thisArg, body) {
|
|
1518
|
-
var f, y, t, _ = {
|
|
1519
|
-
label: 0,
|
|
1520
|
-
sent: function() {
|
|
1521
|
-
if (t[0] & 1) throw t[1];
|
|
1522
|
-
return t[1];
|
|
1523
|
-
},
|
|
1524
|
-
trys: [],
|
|
1525
|
-
ops: []
|
|
1526
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
1527
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
1528
|
-
return this;
|
|
1529
|
-
}), g;
|
|
1530
|
-
function verb(n) {
|
|
1531
|
-
return function(v) {
|
|
1532
|
-
return step([
|
|
1533
|
-
n,
|
|
1534
|
-
v
|
|
1535
|
-
]);
|
|
1536
|
-
};
|
|
1537
|
-
}
|
|
1538
|
-
function step(op) {
|
|
1539
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1540
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1541
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1542
|
-
if (y = 0, t) op = [
|
|
1543
|
-
op[0] & 2,
|
|
1544
|
-
t.value
|
|
1545
|
-
];
|
|
1546
|
-
switch(op[0]){
|
|
1547
|
-
case 0:
|
|
1548
|
-
case 1:
|
|
1549
|
-
t = op;
|
|
1550
|
-
break;
|
|
1551
|
-
case 4:
|
|
1552
|
-
_.label++;
|
|
1553
|
-
return {
|
|
1554
|
-
value: op[1],
|
|
1555
|
-
done: false
|
|
1556
|
-
};
|
|
1557
|
-
case 5:
|
|
1558
|
-
_.label++;
|
|
1559
|
-
y = op[1];
|
|
1560
|
-
op = [
|
|
1561
|
-
0
|
|
1562
|
-
];
|
|
1563
|
-
continue;
|
|
1564
|
-
case 7:
|
|
1565
|
-
op = _.ops.pop();
|
|
1566
|
-
_.trys.pop();
|
|
1567
|
-
continue;
|
|
1568
|
-
default:
|
|
1569
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1570
|
-
_ = 0;
|
|
1571
|
-
continue;
|
|
1572
|
-
}
|
|
1573
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1574
|
-
_.label = op[1];
|
|
1575
|
-
break;
|
|
1576
|
-
}
|
|
1577
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1578
|
-
_.label = t[1];
|
|
1579
|
-
t = op;
|
|
1580
|
-
break;
|
|
1581
|
-
}
|
|
1582
|
-
if (t && _.label < t[2]) {
|
|
1583
|
-
_.label = t[2];
|
|
1584
|
-
_.ops.push(op);
|
|
1585
|
-
break;
|
|
1586
|
-
}
|
|
1587
|
-
if (t[2]) _.ops.pop();
|
|
1588
|
-
_.trys.pop();
|
|
1589
|
-
continue;
|
|
1590
|
-
}
|
|
1591
|
-
op = body.call(thisArg, _);
|
|
1592
|
-
} catch (e) {
|
|
1593
|
-
op = [
|
|
1594
|
-
6,
|
|
1595
|
-
e
|
|
1596
|
-
];
|
|
1597
|
-
y = 0;
|
|
1598
|
-
} finally{
|
|
1599
|
-
f = t = 0;
|
|
1600
|
-
}
|
|
1601
|
-
if (op[0] & 5) throw op[1];
|
|
1602
|
-
return {
|
|
1603
|
-
value: op[0] ? op[1] : void 0,
|
|
1604
|
-
done: true
|
|
1605
|
-
};
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
var PORT = 3000;
|
|
1609
|
-
(function() {
|
|
1610
|
-
return _async_to_generator(function() {
|
|
1611
|
-
var app, config, document;
|
|
1612
|
-
return _ts_generator(this, function(_state) {
|
|
1613
|
-
switch(_state.label){
|
|
1614
|
-
case 0:
|
|
1615
|
-
return [
|
|
1616
|
-
4,
|
|
1617
|
-
NestFactory.create(ZRomulatorModule)
|
|
1618
|
-
];
|
|
1619
|
-
case 1:
|
|
1620
|
-
app = _state.sent();
|
|
1621
|
-
app.setGlobalPrefix("api");
|
|
1622
|
-
app.enableCors();
|
|
1623
|
-
config = new DocumentBuilder().setTitle("Romulator API").setDescription("The Romulator API").setVersion("1").build();
|
|
1624
|
-
document = function() {
|
|
1625
|
-
return SwaggerModule.createDocument(app, config);
|
|
1626
|
-
};
|
|
1627
|
-
SwaggerModule.setup("api/docs", app, document);
|
|
1628
|
-
return [
|
|
1629
|
-
4,
|
|
1630
|
-
app.listen(PORT)
|
|
1631
|
-
];
|
|
1632
|
-
case 2:
|
|
1633
|
-
_state.sent();
|
|
1634
|
-
return [
|
|
1635
|
-
2
|
|
1636
|
-
];
|
|
1637
|
-
}
|
|
1638
|
-
});
|
|
1639
|
-
})();
|
|
876
|
+
const PORT = 3000;
|
|
877
|
+
(async function() {
|
|
878
|
+
const app = await NestFactory.create(ZRomulatorModule);
|
|
879
|
+
app.setGlobalPrefix("api");
|
|
880
|
+
app.enableCors();
|
|
881
|
+
const config = new DocumentBuilder().setTitle("Romulator API").setDescription("The Romulator API").setVersion("1").build();
|
|
882
|
+
const document = ()=>SwaggerModule.createDocument(app, config);
|
|
883
|
+
SwaggerModule.setup("api/docs", app, document);
|
|
884
|
+
await app.listen(PORT);
|
|
1640
885
|
})();
|
|
1641
886
|
//# sourceMappingURL=main.js.map
|