@flink-app/flink 0.4.4 → 0.4.5

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/dist/bin/flink.js CHANGED
@@ -12,11 +12,11 @@ var commands = [
12
12
  var argv = process.argv.slice(2);
13
13
  var argCommand = argv[0];
14
14
  if (!argCommand || argv[0] === "help") {
15
- console.log("Usage: flink [".concat(commands.join("|"), "]"));
15
+ console.log("Usage: flink [" + commands.join("|") + "]");
16
16
  process.exit();
17
17
  }
18
18
  if (!commands.includes(argv[0])) {
19
- console.log("Invalid command: ".concat(argCommand));
19
+ console.log("Invalid command: " + argCommand);
20
20
  process.exit(1);
21
21
  }
22
22
  if (argCommand === "generate") {
package/dist/cli/build.js CHANGED
@@ -15,7 +15,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
15
15
  function verb(n) { return function (v) { return step([n, v]); }; }
16
16
  function step(op) {
17
17
  if (f) throw new TypeError("Generator is already executing.");
18
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ while (_) try {
19
19
  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;
20
20
  if (y = 0, t) op = [op[0] & 2, t.value];
21
21
  switch (op[0]) {
@@ -57,7 +57,7 @@ module.exports = function run(args) {
57
57
  if (args[0] && !args[0].startsWith("--")) {
58
58
  dir = args[0];
59
59
  }
60
- exclude = (0, cli_utils_1.getOption)(args, "exclude", "/spec");
60
+ exclude = cli_utils_1.getOption(args, "exclude", "/spec");
61
61
  return [4 /*yield*/, TypeScriptCompiler_1.default.clean(dir)];
62
62
  case 1:
63
63
  _a.sent();
@@ -68,7 +68,7 @@ module.exports = function run(args) {
68
68
  return [4 /*yield*/, Promise.all([compiler.parseRepos(), compiler.parseHandlers(exclude.split(",")), compiler.parseJobs(), compiler.generateStartScript()])];
69
69
  case 2:
70
70
  _a.sent();
71
- console.log("Compilation done, took ".concat(Date.now() - startTime, "ms"));
71
+ console.log("Compilation done, took " + (Date.now() - startTime) + "ms");
72
72
  compiler.emit();
73
73
  return [2 /*return*/];
74
74
  }
package/dist/cli/clean.js CHANGED
@@ -15,7 +15,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
15
15
  function verb(n) { return function (v) { return step([n, v]); }; }
16
16
  function step(op) {
17
17
  if (f) throw new TypeError("Generator is already executing.");
18
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ while (_) try {
19
19
  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;
20
20
  if (y = 0, t) op = [op[0] & 2, t.value];
21
21
  switch (op[0]) {
@@ -58,7 +58,7 @@ module.exports = function run(args) {
58
58
  return [4 /*yield*/, TypeScriptCompiler_1.default.clean(dir)];
59
59
  case 1:
60
60
  cleanedFolder = _a.sent();
61
- console.log("Cleaned directory ".concat(cleanedFolder));
61
+ console.log("Cleaned directory " + cleanedFolder);
62
62
  return [2 /*return*/];
63
63
  }
64
64
  });
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getOption = void 0;
4
4
  function getOption(args, name, defaultValue, opts) {
5
5
  if (opts === void 0) { opts = {}; }
6
- var option = "--".concat(name);
6
+ var option = "--" + name;
7
7
  if (args.includes(option)) {
8
8
  if (opts.isBoolean && args[args.indexOf(option) + 1] !== "false") {
9
9
  return true;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ var TypeScriptCompiler_1 = __importDefault(require("../src/TypeScriptCompiler"));
8
+ var startTime = Date.now();
9
+ var args = process.argv.slice(2);
10
+ var dir = args[0];
11
+ var actions = args[1];
12
+ console.log("Parallel compilation enabled, will fork 3 processes");
13
+ var compiler = new TypeScriptCompiler_1.default(dir);
14
+ if (actions.includes("preEmit")) {
15
+ // Only emit diagnostics for the first compiler
16
+ if (!compiler.getPreEmitDiagnostics()) {
17
+ process.exit(1);
18
+ }
19
+ }
20
+ if (actions.includes("parseRepos")) {
21
+ compiler.parseRepos();
22
+ }
23
+ if (actions.includes("parseHandlers")) {
24
+ compiler.parseHandlers();
25
+ }
26
+ if (actions.includes("parseJobs")) {
27
+ compiler.parseJobs();
28
+ }
29
+ if (actions.includes("generateStartScript")) {
30
+ compiler.generateStartScript();
31
+ }
32
+ console.log("Forked compiler done with ".concat(actions.replaceAll(",", ", "), ", took ").concat(Date.now() - startTime, "ms"));
33
+ compiler.emit();
@@ -26,7 +26,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
26
26
  function verb(n) { return function (v) { return step([n, v]); }; }
27
27
  function step(op) {
28
28
  if (f) throw new TypeError("Generator is already executing.");
29
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ while (_) try {
30
30
  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;
31
31
  if (y = 0, t) op = [op[0] & 2, t.value];
32
32
  switch (op[0]) {
@@ -47,14 +47,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
48
  }
49
49
  };
50
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
51
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
52
- if (ar || !(i in from)) {
53
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
54
- ar[i] = from[i];
55
- }
56
- }
57
- return to.concat(ar || Array.prototype.slice.call(from));
50
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
51
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
52
+ to[j] = from[i];
53
+ return to;
58
54
  };
59
55
  Object.defineProperty(exports, "__esModule", { value: true });
60
56
  var path_1 = require("path");
@@ -76,19 +72,19 @@ module.exports = function run(args) {
76
72
  if (args[0] && !args[0].startsWith("--")) {
77
73
  dir = args[0];
78
74
  }
79
- verbose = (0, cli_utils_1.getOption)(args, "verbose", false, {
75
+ verbose = cli_utils_1.getOption(args, "verbose", false, {
80
76
  isBoolean: true,
81
77
  });
82
- typesDir = (0, cli_utils_1.getOption)(args, "types-dir", "./src/schemas");
83
- outFile = (0, cli_utils_1.getOption)(args, "out-file", "./.flink/generated-schemas.json");
78
+ typesDir = cli_utils_1.getOption(args, "types-dir", "./src/schemas");
79
+ outFile = cli_utils_1.getOption(args, "out-file", "./.flink/generated-schemas.json");
84
80
  project = new ts_morph_1.Project({
85
- tsConfigFilePath: (0, path_1.join)(dir, "tsconfig.json"),
81
+ tsConfigFilePath: path_1.join(dir, "tsconfig.json"),
86
82
  skipAddingFilesFromTsConfig: true,
87
83
  compilerOptions: {
88
84
  noEmit: true,
89
85
  },
90
86
  });
91
- project.addSourceFilesAtPaths((0, path_1.join)(dir, typesDir, "**/*.ts"));
87
+ project.addSourceFilesAtPaths(path_1.join(dir, typesDir, "**/*.ts"));
92
88
  console.log("Found", project.getSourceFiles().length, "files");
93
89
  schemaDeclarations = [];
94
90
  generator = initJsonSchemaGenerator(project);
@@ -96,11 +92,11 @@ module.exports = function run(args) {
96
92
  for (_i = 0, _a = project.getSourceFiles(); _i < _a.length; _i++) {
97
93
  sf = _a[_i];
98
94
  if (sf.getDefaultExportSymbol()) {
99
- console.warn("WARN: Schema file ".concat(sf.getBaseName(), " has default export, but only named exports are picked up by json schemas parser"));
95
+ console.warn("WARN: Schema file " + sf.getBaseName() + " has default export, but only named exports are picked up by json schemas parser");
100
96
  }
101
97
  sourceFileInterfaceDeclarations = sf.getChildrenOfKind(ts_morph_1.SyntaxKind.InterfaceDeclaration);
102
98
  sourceFileEnumDeclarations = sf.getChildrenOfKind(ts_morph_1.SyntaxKind.EnumDeclaration);
103
- sourceFileDeclarations = __spreadArray(__spreadArray([], sourceFileEnumDeclarations, true), sourceFileInterfaceDeclarations, true);
99
+ sourceFileDeclarations = __spreadArray(__spreadArray([], sourceFileEnumDeclarations), sourceFileInterfaceDeclarations);
104
100
  schemaDeclarations.push.apply(schemaDeclarations, sourceFileDeclarations.map(function (d) { return d.compilerNode; }));
105
101
  verbose &&
106
102
  console.log("Found", sourceFileDeclarations.length, "schema(s) in file", sf.getBaseName());
@@ -124,8 +120,8 @@ module.exports = function run(args) {
124
120
  $ref: "#/definitions/Schemas",
125
121
  definitions: {},
126
122
  });
127
- file = (0, path_1.join)(dir, outFile);
128
- return [4 /*yield*/, (0, FsUtils_1.writeJsonFile)(file, mergedSchemas, {
123
+ file = path_1.join(dir, outFile);
124
+ return [4 /*yield*/, FsUtils_1.writeJsonFile(file, mergedSchemas, {
129
125
  ensureDir: true,
130
126
  })];
131
127
  case 1:
@@ -137,8 +133,8 @@ module.exports = function run(args) {
137
133
  });
138
134
  };
139
135
  function initJsonSchemaGenerator(project) {
140
- var formatter = (0, ts_json_schema_generator_1.createFormatter)({});
141
- var parser = (0, ts_json_schema_generator_1.createParser)(project.getProgram().compilerObject, {});
136
+ var formatter = ts_json_schema_generator_1.createFormatter({});
137
+ var parser = ts_json_schema_generator_1.createParser(project.getProgram().compilerObject, {});
142
138
  var generator = new ts_json_schema_generator_1.SchemaGenerator(project.getProgram().compilerObject, parser, formatter, { expose: "export" });
143
139
  return generator;
144
140
  }
package/dist/cli/run.js CHANGED
@@ -15,7 +15,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
15
15
  function verb(n) { return function (v) { return step([n, v]); }; }
16
16
  function step(op) {
17
17
  if (f) throw new TypeError("Generator is already executing.");
18
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ while (_) try {
19
19
  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;
20
20
  if (y = 0, t) op = [op[0] & 2, t.value];
21
21
  switch (op[0]) {
@@ -78,7 +78,7 @@ module.exports = function run(args) {
78
78
  return [4 /*yield*/, Promise.all([compiler.parseRepos(), compiler.parseHandlers(), compiler.parseJobs(), compiler.generateStartScript(entry)])];
79
79
  case 2:
80
80
  _a.sent();
81
- console.log("Compilation done, took ".concat(Date.now() - startTime, "ms"));
81
+ console.log("Compilation done, took " + (Date.now() - startTime) + "ms");
82
82
  compiler.emit();
83
83
  require("child_process").fork(dir + "/dist/.flink/start.js");
84
84
  return [2 /*return*/];
@@ -9,7 +9,7 @@ import { HandlerFile, HttpMethod, QueryParamMetadata, RouteProps } from "./Flink
9
9
  import { FlinkJobFile } from "./FlinkJob";
10
10
  import { FlinkPlugin } from "./FlinkPlugin";
11
11
  import { FlinkRepo } from "./FlinkRepo";
12
- export type JSONSchema = JSONSchema7;
12
+ export declare type JSONSchema = JSONSchema7;
13
13
  /**
14
14
  * This will be populated at compile time when the apps handlers
15
15
  * are picked up by TypeScript compiler
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ while (_) try {
29
29
  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;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -65,7 +65,7 @@ var FlinkLog_1 = require("./FlinkLog");
65
65
  var mock_data_generator_1 = __importDefault(require("./mock-data-generator"));
66
66
  var utils_1 = require("./utils");
67
67
  var ajv = new ajv_1.default();
68
- (0, ajv_formats_1.default)(ajv);
68
+ ajv_formats_1.default(ajv);
69
69
  var defaultCorsOptions = {
70
70
  allowedHeaders: "",
71
71
  credentials: true,
@@ -134,23 +134,23 @@ var FlinkApp = /** @class */ (function () {
134
134
  _c.sent();
135
135
  if (this.debug) {
136
136
  offsetTime = Date.now();
137
- FlinkLog_1.log.bgColorLog("cyan", "Init db took ".concat(offsetTime - startTime, " ms"));
137
+ FlinkLog_1.log.bgColorLog("cyan", "Init db took " + (offsetTime - startTime) + " ms");
138
138
  }
139
139
  return [4 /*yield*/, this.buildContext()];
140
140
  case 2:
141
141
  _c.sent();
142
142
  if (this.debug) {
143
- FlinkLog_1.log.bgColorLog("cyan", "Build context took ".concat(Date.now() - offsetTime, " ms"));
143
+ FlinkLog_1.log.bgColorLog("cyan", "Build context took " + (Date.now() - offsetTime) + " ms");
144
144
  offsetTime = Date.now();
145
145
  }
146
146
  if (this.isSchedulingEnabled) {
147
147
  this.scheduler = new toad_scheduler_1.ToadScheduler();
148
148
  }
149
- this.expressApp = (0, express_1.default)();
150
- this.expressApp.use((0, cors_1.default)(this.corsOpts));
149
+ this.expressApp = express_1.default();
150
+ this.expressApp.use(cors_1.default(this.corsOpts));
151
151
  this.expressApp.use(body_parser_1.default.json(this.jsonOptions));
152
152
  this.expressApp.use(function (req, res, next) {
153
- req.reqId = (0, uuid_1.v4)();
153
+ req.reqId = uuid_1.v4();
154
154
  next();
155
155
  });
156
156
  _i = 0, _b = this.plugins;
@@ -171,7 +171,7 @@ var FlinkApp = /** @class */ (function () {
171
171
  _c.sent();
172
172
  _c.label = 7;
173
173
  case 7:
174
- FlinkLog_1.log.info("Initialized plugin '".concat(plugin.id, "'"));
174
+ FlinkLog_1.log.info("Initialized plugin '" + plugin.id + "'");
175
175
  _c.label = 8;
176
176
  case 8:
177
177
  _i++;
@@ -180,7 +180,7 @@ var FlinkApp = /** @class */ (function () {
180
180
  case 10:
181
181
  _c.sent();
182
182
  if (this.debug) {
183
- FlinkLog_1.log.bgColorLog("cyan", "Register handlers took ".concat(Date.now() - offsetTime, " ms"));
183
+ FlinkLog_1.log.bgColorLog("cyan", "Register handlers took " + (Date.now() - offsetTime) + " ms");
184
184
  offsetTime = Date.now();
185
185
  }
186
186
  if (!this.isSchedulingEnabled) return [3 /*break*/, 12];
@@ -188,7 +188,7 @@ var FlinkApp = /** @class */ (function () {
188
188
  case 11:
189
189
  _c.sent();
190
190
  if (this.debug) {
191
- FlinkLog_1.log.bgColorLog("cyan", "Register jobs took ".concat(Date.now() - offsetTime, " ms"));
191
+ FlinkLog_1.log.bgColorLog("cyan", "Register jobs took " + (Date.now() - offsetTime) + " ms");
192
192
  offsetTime = Date.now();
193
193
  }
194
194
  _c.label = 12;
@@ -197,12 +197,12 @@ var FlinkApp = /** @class */ (function () {
197
197
  // TODO: Is there a better solution to force this handler to always run last?
198
198
  setTimeout(function () {
199
199
  _this.expressApp.use(function (req, res, next) {
200
- res.status(404).json((0, FlinkErrors_1.notFound)());
200
+ res.status(404).json(FlinkErrors_1.notFound());
201
201
  });
202
202
  _this.routingConfigured = true;
203
203
  });
204
204
  (_a = this.expressApp) === null || _a === void 0 ? void 0 : _a.listen(this.port, function () {
205
- FlinkLog_1.log.fontColorLog("magenta", "\u26A1\uFE0F HTTP server '".concat(_this.name, "' is running and waiting for connections on ").concat(_this.port));
205
+ FlinkLog_1.log.fontColorLog("magenta", "\u26A1\uFE0F HTTP server '" + _this.name + "' is running and waiting for connections on " + _this.port);
206
206
  _this.started = true;
207
207
  });
208
208
  return [2 /*return*/, this];
@@ -223,18 +223,18 @@ var FlinkApp = /** @class */ (function () {
223
223
  }
224
224
  var routeProps = __assign(__assign({}, (handler.Route || {})), routePropsOverride);
225
225
  if (!routeProps.method) {
226
- FlinkLog_1.log.error("Failed to register handler '".concat(handler.__file, "': Missing 'method' in route props, either set it or name handler file with HTTP method as prefix"));
226
+ FlinkLog_1.log.error("Failed to register handler '" + handler.__file + "': Missing 'method' in route props, either set it or name handler file with HTTP method as prefix");
227
227
  return;
228
228
  }
229
229
  if (!routeProps.path) {
230
- FlinkLog_1.log.error("Failed to register handler '".concat(handler.__file, "': Missing 'path' in route props"));
230
+ FlinkLog_1.log.error("Failed to register handler '" + handler.__file + "': Missing 'path' in route props");
231
231
  return;
232
232
  }
233
233
  var dup = this.handlers.find(function (h) { return h.routeProps.path === routeProps.path && h.routeProps.method === routeProps.method; });
234
- var methodAndPath = "".concat(routeProps.method.toUpperCase(), " ").concat(routeProps.path);
234
+ var methodAndPath = routeProps.method.toUpperCase() + " " + routeProps.path;
235
235
  if (dup) {
236
236
  // TODO: Not sure if there is a case where you'd want to overwrite a route?
237
- FlinkLog_1.log.warn("".concat(methodAndPath, " overlaps existing route"));
237
+ FlinkLog_1.log.warn(methodAndPath + " overlaps existing route");
238
238
  }
239
239
  var handlerConfig = {
240
240
  routeProps: __assign(__assign({}, routeProps), { method: routeProps.method, path: routeProps.path }),
@@ -246,10 +246,10 @@ var FlinkApp = /** @class */ (function () {
246
246
  paramsMetadata: handler.__params || [],
247
247
  };
248
248
  if (((_c = handler.__schemas) === null || _c === void 0 ? void 0 : _c.reqSchema) && !((_d = handlerConfig.schema) === null || _d === void 0 ? void 0 : _d.reqSchema)) {
249
- FlinkLog_1.log.warn("Expected request schema ".concat(handler.__schemas.reqSchema, " for handler ").concat(methodAndPath, " but no such schema was found"));
249
+ FlinkLog_1.log.warn("Expected request schema " + handler.__schemas.reqSchema + " for handler " + methodAndPath + " but no such schema was found");
250
250
  }
251
251
  if (((_e = handler.__schemas) === null || _e === void 0 ? void 0 : _e.resSchema) && !((_f = handlerConfig.schema) === null || _f === void 0 ? void 0 : _f.resSchema)) {
252
- FlinkLog_1.log.warn("Expected response schema ".concat(handler.__schemas.resSchema, " for handler ").concat(methodAndPath, " but no such schema was found"));
252
+ FlinkLog_1.log.warn("Expected response schema " + handler.__schemas.resSchema + " for handler " + methodAndPath + " but no such schema was found");
253
253
  }
254
254
  this.registerHandler(handlerConfig, handler.default);
255
255
  };
@@ -260,10 +260,10 @@ var FlinkApp = /** @class */ (function () {
260
260
  var method = routeProps.method;
261
261
  var app = this.expressApp;
262
262
  if (!method) {
263
- FlinkLog_1.log.error("Route ".concat(routeProps.path, " is missing http method"));
263
+ FlinkLog_1.log.error("Route " + routeProps.path + " is missing http method");
264
264
  }
265
265
  if (method) {
266
- var methodAndRoute_1 = "".concat(method.toUpperCase(), " ").concat(routeProps.path);
266
+ var methodAndRoute_1 = method.toUpperCase() + " " + routeProps.path;
267
267
  app[method](routeProps.path, function (req, res) { return __awaiter(_this, void 0, void 0, function () {
268
268
  var validate, valid, data, handlerRes, err_1, validate, valid;
269
269
  return __generator(this, function (_a) {
@@ -273,7 +273,7 @@ var FlinkApp = /** @class */ (function () {
273
273
  return [4 /*yield*/, this.authenticate(req, routeProps.permissions)];
274
274
  case 1:
275
275
  if (!(_a.sent())) {
276
- return [2 /*return*/, res.status(401).json((0, FlinkErrors_1.unauthorized)())];
276
+ return [2 /*return*/, res.status(401).json(FlinkErrors_1.unauthorized())];
277
277
  }
278
278
  _a.label = 2;
279
279
  case 2:
@@ -281,21 +281,21 @@ var FlinkApp = /** @class */ (function () {
281
281
  validate = ajv.compile(schema.reqSchema);
282
282
  valid = validate(req.body);
283
283
  if (!valid) {
284
- FlinkLog_1.log.warn("".concat(methodAndRoute_1, ": Bad request ").concat(JSON.stringify(validate.errors, null, 2)));
285
- FlinkLog_1.log.debug("Invalid json: ".concat(JSON.stringify(req.body)));
284
+ FlinkLog_1.log.warn(methodAndRoute_1 + ": Bad request " + JSON.stringify(validate.errors, null, 2));
285
+ FlinkLog_1.log.debug("Invalid json: " + JSON.stringify(req.body));
286
286
  return [2 /*return*/, res.status(400).json({
287
287
  status: 400,
288
288
  error: {
289
- id: (0, uuid_1.v4)(),
289
+ id: uuid_1.v4(),
290
290
  title: "Bad request",
291
- detail: "Schema did not validate ".concat(JSON.stringify(validate.errors)),
291
+ detail: "Schema did not validate " + JSON.stringify(validate.errors),
292
292
  },
293
293
  })];
294
294
  }
295
295
  }
296
296
  if (routeProps.mockApi && schema.resSchema) {
297
- FlinkLog_1.log.warn("Mock response for ".concat(req.method.toUpperCase(), " ").concat(req.path));
298
- data = (0, mock_data_generator_1.default)(schema.resSchema);
297
+ FlinkLog_1.log.warn("Mock response for " + req.method.toUpperCase() + " " + req.path);
298
+ data = mock_data_generator_1.default(schema.resSchema);
299
299
  res.status(200).json({
300
300
  status: 200,
301
301
  data: data,
@@ -316,23 +316,23 @@ var FlinkApp = /** @class */ (function () {
316
316
  return [3 /*break*/, 6];
317
317
  case 5:
318
318
  err_1 = _a.sent();
319
- FlinkLog_1.log.warn("Handler '".concat(methodAndRoute_1, "' threw unhandled exception ").concat(err_1));
319
+ FlinkLog_1.log.warn("Handler '" + methodAndRoute_1 + "' threw unhandled exception " + err_1);
320
320
  console.error(err_1);
321
- return [2 /*return*/, res.status(500).json((0, FlinkErrors_1.internalServerError)(err_1))];
321
+ return [2 /*return*/, res.status(500).json(FlinkErrors_1.internalServerError(err_1))];
322
322
  case 6:
323
- if (schema.resSchema && !(0, utils_1.isError)(handlerRes)) {
323
+ if (schema.resSchema && !utils_1.isError(handlerRes)) {
324
324
  validate = ajv.compile(schema.resSchema);
325
325
  valid = validate(JSON.parse(JSON.stringify(handlerRes.data)));
326
326
  if (!valid) {
327
- FlinkLog_1.log.warn("[".concat(req.reqId, "] ").concat(methodAndRoute_1, ": Bad response ").concat(JSON.stringify(validate.errors, null, 2)));
328
- FlinkLog_1.log.debug("Invalid json: ".concat(JSON.stringify(handlerRes.data)));
327
+ FlinkLog_1.log.warn("[" + req.reqId + "] " + methodAndRoute_1 + ": Bad response " + JSON.stringify(validate.errors, null, 2));
328
+ FlinkLog_1.log.debug("Invalid json: " + JSON.stringify(handlerRes.data));
329
329
  // log.debug(JSON.stringify(schema, null, 2));
330
330
  return [2 /*return*/, res.status(500).json({
331
331
  status: 500,
332
332
  error: {
333
- id: (0, uuid_1.v4)(),
333
+ id: uuid_1.v4(),
334
334
  title: "Bad response",
335
- detail: "Schema did not validate ".concat(JSON.stringify(validate.errors)),
335
+ detail: "Schema did not validate " + JSON.stringify(validate.errors),
336
336
  },
337
337
  })];
338
338
  }
@@ -344,12 +344,12 @@ var FlinkApp = /** @class */ (function () {
344
344
  });
345
345
  }); });
346
346
  if (this.handlerRouteCache.has(methodAndRoute_1)) {
347
- FlinkLog_1.log.error("Cannot register handler ".concat(methodAndRoute_1, " - route already registered"));
347
+ FlinkLog_1.log.error("Cannot register handler " + methodAndRoute_1 + " - route already registered");
348
348
  return process.exit(1); // TODO: Do we need to exit?
349
349
  }
350
350
  else {
351
351
  this.handlerRouteCache.set(methodAndRoute_1, JSON.stringify(routeProps));
352
- FlinkLog_1.log.info("Registered route ".concat(methodAndRoute_1));
352
+ FlinkLog_1.log.info("Registered route " + methodAndRoute_1);
353
353
  }
354
354
  }
355
355
  };
@@ -367,11 +367,11 @@ var FlinkApp = /** @class */ (function () {
367
367
  for (_i = 0, autoRegisteredHandlers_1 = exports.autoRegisteredHandlers; _i < autoRegisteredHandlers_1.length; _i++) {
368
368
  _c = autoRegisteredHandlers_1[_i], handler = _c.handler, assumedHttpMethod = _c.assumedHttpMethod;
369
369
  if (!handler.Route) {
370
- FlinkLog_1.log.error("Missing Props in handler ".concat(handler.__file));
370
+ FlinkLog_1.log.error("Missing Props in handler " + handler.__file);
371
371
  continue;
372
372
  }
373
373
  if (!handler.default) {
374
- FlinkLog_1.log.error("Missing exported handler function in handler ".concat(handler.__file));
374
+ FlinkLog_1.log.error("Missing exported handler function in handler " + handler.__file);
375
375
  continue;
376
376
  }
377
377
  this.registerHandler({
@@ -398,29 +398,29 @@ var FlinkApp = /** @class */ (function () {
398
398
  }
399
399
  _loop_1 = function (jobProps, jobFn, __file) {
400
400
  if (jobProps.cron && jobProps.interval) {
401
- FlinkLog_1.log.error("Cannot register job ".concat(jobProps.id, " - both cron and interval are set in ").concat(__file));
401
+ FlinkLog_1.log.error("Cannot register job " + jobProps.id + " - both cron and interval are set in " + __file);
402
402
  return "continue";
403
403
  }
404
404
  if (jobProps.cron && jobProps.afterDelay) {
405
- FlinkLog_1.log.error("Cannot register job ".concat(jobProps.id, " - both cron and afterDelay are set in ").concat(__file));
405
+ FlinkLog_1.log.error("Cannot register job " + jobProps.id + " - both cron and afterDelay are set in " + __file);
406
406
  return "continue";
407
407
  }
408
408
  if (jobProps.interval && jobProps.afterDelay) {
409
- FlinkLog_1.log.error("Cannot register job ".concat(jobProps.id, " - both interval and afterDelay are set in ").concat(__file));
409
+ FlinkLog_1.log.error("Cannot register job " + jobProps.id + " - both interval and afterDelay are set in " + __file);
410
410
  return "continue";
411
411
  }
412
412
  if (this_1.scheduler.existsById(jobProps.id)) {
413
- FlinkLog_1.log.error("Job with id ".concat(jobProps.id, " is already registered, found duplicate in ").concat(__file));
413
+ FlinkLog_1.log.error("Job with id " + jobProps.id + " is already registered, found duplicate in " + __file);
414
414
  return "continue";
415
415
  }
416
- FlinkLog_1.log.debug("Registering job ".concat(jobProps.id, ": ").concat(JSON.stringify(jobProps), " from ").concat(__file));
416
+ FlinkLog_1.log.debug("Registering job " + jobProps.id + ": " + JSON.stringify(jobProps) + " from " + __file);
417
417
  var task = new toad_scheduler_1.AsyncTask(jobProps.id, function () { return __awaiter(_this, void 0, void 0, function () {
418
418
  return __generator(this, function (_a) {
419
419
  switch (_a.label) {
420
420
  case 0: return [4 /*yield*/, jobFn({ ctx: this.ctx })];
421
421
  case 1:
422
422
  _a.sent();
423
- FlinkLog_1.log.debug("Job ".concat(jobProps.id, " completed"));
423
+ FlinkLog_1.log.debug("Job " + jobProps.id + " completed");
424
424
  if (jobProps.afterDelay) {
425
425
  // afterDelay runs only once, so we remove the job
426
426
  this.scheduler.removeById(jobProps.id);
@@ -429,7 +429,7 @@ var FlinkApp = /** @class */ (function () {
429
429
  }
430
430
  });
431
431
  }); }, function (err) {
432
- FlinkLog_1.log.error("Job ".concat(jobProps.id, " threw unhandled exception ").concat(err));
432
+ FlinkLog_1.log.error("Job " + jobProps.id + " threw unhandled exception " + err);
433
433
  console.error(err);
434
434
  });
435
435
  if (jobProps.cron) {
@@ -441,7 +441,7 @@ var FlinkApp = /** @class */ (function () {
441
441
  }
442
442
  else if (jobProps.interval) {
443
443
  var job = new toad_scheduler_1.SimpleIntervalJob({
444
- milliseconds: (0, ms_1.default)(jobProps.interval),
444
+ milliseconds: ms_1.default(jobProps.interval),
445
445
  runImmediately: false, // TODO: Expose to props?
446
446
  }, task, {
447
447
  id: jobProps.id,
@@ -451,7 +451,7 @@ var FlinkApp = /** @class */ (function () {
451
451
  }
452
452
  else if (jobProps.afterDelay !== undefined) {
453
453
  var job = new toad_scheduler_1.SimpleIntervalJob({
454
- milliseconds: (0, ms_1.default)(jobProps.afterDelay),
454
+ milliseconds: ms_1.default(jobProps.afterDelay),
455
455
  runImmediately: false,
456
456
  }, task, {
457
457
  id: jobProps.id,
@@ -460,7 +460,7 @@ var FlinkApp = /** @class */ (function () {
460
460
  this_1.scheduler.addSimpleIntervalJob(job);
461
461
  }
462
462
  else {
463
- FlinkLog_1.log.error("Cannot register job ".concat(jobProps.id, " - no cron, interval or once set in ").concat(__file));
463
+ FlinkLog_1.log.error("Cannot register job " + jobProps.id + " - no cron, interval or once set in " + __file);
464
464
  return "continue";
465
465
  }
466
466
  };
@@ -491,7 +491,7 @@ var FlinkApp = /** @class */ (function () {
491
491
  _a = autoRegisteredRepos_1[_i], collectionName = _a.collectionName, repoInstanceName = _a.repoInstanceName, Repo = _a.Repo;
492
492
  repoInstance = new Repo(collectionName, this.db);
493
493
  this.repos[repoInstanceName] = repoInstance;
494
- FlinkLog_1.log.info("Registered repo ".concat(repoInstanceName));
494
+ FlinkLog_1.log.info("Registered repo " + repoInstanceName);
495
495
  }
496
496
  }
497
497
  else if (exports.autoRegisteredRepos.length > 0) {
@@ -499,7 +499,7 @@ var FlinkApp = /** @class */ (function () {
499
499
  }
500
500
  pluginCtx = this.plugins.reduce(function (out, plugin) {
501
501
  if (out[plugin.id]) {
502
- throw new Error("Plugin ".concat(plugin.id, " is already registered"));
502
+ throw new Error("Plugin " + plugin.id + " is already registered");
503
503
  }
504
504
  out[plugin.id] = plugin.ctx;
505
505
  return out;
@@ -570,7 +570,7 @@ var FlinkApp = /** @class */ (function () {
570
570
  if (!plugin.db) return [3 /*break*/, 5];
571
571
  if (!plugin.db.useHostDb) return [3 /*break*/, 1];
572
572
  if (!this.db) {
573
- FlinkLog_1.log.error("Plugin '".concat(this.name, " configured to use host app db, but no db exists in FlinkApp'"));
573
+ FlinkLog_1.log.error("Plugin '" + this.name + " configured to use host app db, but no db exists in FlinkApp'");
574
574
  }
575
575
  else {
576
576
  return [2 /*return*/, this.db];
@@ -581,7 +581,7 @@ var FlinkApp = /** @class */ (function () {
581
581
  _a.label = 2;
582
582
  case 2:
583
583
  _a.trys.push([2, 4, , 5]);
584
- FlinkLog_1.log.debug("Connecting to '".concat(plugin.id, "' db"));
584
+ FlinkLog_1.log.debug("Connecting to '" + plugin.id + "' db");
585
585
  return [4 /*yield*/, mongodb_1.default.connect(plugin.db.uri, {
586
586
  useUnifiedTopology: true,
587
587
  })];
@@ -590,7 +590,7 @@ var FlinkApp = /** @class */ (function () {
590
590
  return [2 /*return*/, client.db()];
591
591
  case 4:
592
592
  err_3 = _a.sent();
593
- FlinkLog_1.log.error("Failed to connect to db defined in plugin '".concat(plugin.id, "': ") + err_3);
593
+ FlinkLog_1.log.error("Failed to connect to db defined in plugin '" + plugin.id + "': " + err_3);
594
594
  return [3 /*break*/, 5];
595
595
  case 5: return [2 /*return*/];
596
596
  }
@@ -603,7 +603,7 @@ var FlinkApp = /** @class */ (function () {
603
603
  switch (_a.label) {
604
604
  case 0:
605
605
  if (!this.auth) {
606
- throw new Error("Attempting to authenticate request (".concat(req.method, " ").concat(req.path, ") but no authPlugin is set"));
606
+ throw new Error("Attempting to authenticate request (" + req.method + " " + req.path + ") but no authPlugin is set");
607
607
  }
608
608
  return [4 /*yield*/, this.auth.authenticateRequest(req, permissions)];
609
609
  case 1: return [2 /*return*/, _a.sent()];
@@ -1,5 +1,5 @@
1
1
  import { FlinkResponse } from "./FlinkResponse";
2
- export type FlinkError = undefined;
2
+ export declare type FlinkError = undefined;
3
3
  export declare function notFound(detail?: string, code?: string): FlinkResponse<FlinkError>;
4
4
  export declare function conflict(detail?: string, code?: string): FlinkResponse<FlinkError>;
5
5
  export declare function badRequest(detail?: string, code?: string): FlinkResponse<FlinkError>;