@flink-app/flink 0.12.1-alpha.0 → 0.12.1-alpha.10
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/flink.ts +6 -13
- package/dist/bin/flink.js +3 -10
- package/dist/cli/build.js +3 -3
- package/dist/cli/clean.js +2 -2
- package/dist/cli/cli-utils.js +1 -1
- package/dist/cli/run.js +2 -2
- package/dist/src/FlinkApp.d.ts +6 -3
- package/dist/src/FlinkApp.js +109 -78
- package/dist/src/FlinkErrors.d.ts +1 -1
- package/dist/src/FlinkErrors.js +5 -5
- package/dist/src/FlinkHttpHandler.d.ts +7 -7
- package/dist/src/FlinkHttpHandler.js +1 -1
- package/dist/src/FlinkJob.d.ts +2 -2
- package/dist/src/FlinkLog.d.ts +2 -2
- package/dist/src/FlinkRepo.d.ts +17 -8
- package/dist/src/FlinkRepo.js +44 -20
- package/dist/src/FlinkResponse.d.ts +2 -2
- package/dist/src/FsUtils.js +7 -7
- package/dist/src/TypeScriptCompiler.js +83 -68
- package/dist/src/TypeScriptUtils.js +11 -33
- package/dist/src/index.js +5 -1
- package/dist/src/mock-data-generator.js +1 -1
- package/dist/src/utils.js +6 -6
- package/package.json +7 -7
- package/spec/FlinkRepo.spec.ts +11 -0
- package/spec/mock-project/dist/src/handlers/GetCar.js +10 -12
- package/spec/mock-project/dist/src/handlers/GetCar2.js +11 -13
- package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema.js +8 -10
- package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema2.js +8 -10
- package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema3.js +8 -10
- package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema.js +10 -12
- package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema2.js +10 -12
- package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile.js +10 -12
- package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile2.js +10 -12
- package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler.js +10 -12
- package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler2.js +10 -12
- package/spec/mock-project/dist/src/handlers/PostCar.js +10 -12
- package/spec/mock-project/dist/src/handlers/PostLogin.js +11 -13
- package/spec/mock-project/dist/src/handlers/PutCar.js +10 -12
- package/spec/mock-project/dist/src/index.js +6 -2
- package/src/FlinkApp.ts +33 -8
- package/src/FlinkRepo.ts +30 -11
- package/src/TypeScriptCompiler.ts +13 -2
- package/src/TypeScriptUtils.ts +110 -164
- package/cli/generate-schemas.ts +0 -153
package/bin/flink.ts
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const commands = [
|
|
4
|
-
"build",
|
|
5
|
-
"generate" /* 'generate' is alias for 'build' */,
|
|
6
|
-
"run",
|
|
7
|
-
"clean",
|
|
8
|
-
"generate-schemas",
|
|
9
|
-
"help",
|
|
10
|
-
];
|
|
3
|
+
const commands = ["build", "generate" /* 'generate' is alias for 'build' */, "run", "clean", "help"];
|
|
11
4
|
|
|
12
5
|
const argv = process.argv.slice(2);
|
|
13
6
|
let argCommand = argv[0];
|
|
14
7
|
|
|
15
8
|
if (!argCommand || argv[0] === "help") {
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
console.log(`Usage: flink [${commands.join("|")}]`);
|
|
10
|
+
process.exit();
|
|
18
11
|
}
|
|
19
12
|
|
|
20
13
|
if (!commands.includes(argv[0])) {
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
console.log(`Invalid command: ${argCommand}`);
|
|
15
|
+
process.exit(1);
|
|
23
16
|
}
|
|
24
17
|
|
|
25
18
|
if (argCommand === "generate") {
|
|
26
|
-
|
|
19
|
+
argCommand = "build";
|
|
27
20
|
}
|
|
28
21
|
|
|
29
22
|
const cmd = require("../cli/" + argCommand);
|
package/dist/bin/flink.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
var commands = [
|
|
5
|
-
"build",
|
|
6
|
-
"generate" /* 'generate' is alias for 'build' */,
|
|
7
|
-
"run",
|
|
8
|
-
"clean",
|
|
9
|
-
"generate-schemas",
|
|
10
|
-
"help",
|
|
11
|
-
];
|
|
4
|
+
var commands = ["build", "generate" /* 'generate' is alias for 'build' */, "run", "clean", "help"];
|
|
12
5
|
var argv = process.argv.slice(2);
|
|
13
6
|
var argCommand = argv[0];
|
|
14
7
|
if (!argCommand || argv[0] === "help") {
|
|
15
|
-
console.log("Usage: flink ["
|
|
8
|
+
console.log("Usage: flink [".concat(commands.join("|"), "]"));
|
|
16
9
|
process.exit();
|
|
17
10
|
}
|
|
18
11
|
if (!commands.includes(argv[0])) {
|
|
19
|
-
console.log("Invalid command: "
|
|
12
|
+
console.log("Invalid command: ".concat(argCommand));
|
|
20
13
|
process.exit(1);
|
|
21
14
|
}
|
|
22
15
|
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 (_) try {
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) 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 = cli_utils_1.getOption(args, "exclude", "/spec");
|
|
60
|
+
exclude = (0, 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 "
|
|
71
|
+
console.log("Compilation done, took ".concat(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 (_) try {
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) 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 "
|
|
61
|
+
console.log("Cleaned directory ".concat(cleanedFolder));
|
|
62
62
|
return [2 /*return*/];
|
|
63
63
|
}
|
|
64
64
|
});
|
package/dist/cli/cli-utils.js
CHANGED
|
@@ -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 = "--"
|
|
6
|
+
var option = "--".concat(name);
|
|
7
7
|
if (args.includes(option)) {
|
|
8
8
|
if (opts.isBoolean && args[args.indexOf(option) + 1] !== "false") {
|
|
9
9
|
return true;
|
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 (_) try {
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) 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]) {
|
|
@@ -81,7 +81,7 @@ module.exports = function run(args) {
|
|
|
81
81
|
return [4 /*yield*/, Promise.all([compiler.parseRepos(), compiler.parseHandlers(), compiler.parseJobs(), compiler.generateStartScript(entry)])];
|
|
82
82
|
case 2:
|
|
83
83
|
_a.sent();
|
|
84
|
-
console.log("Compilation done, took "
|
|
84
|
+
console.log("Compilation done, took ".concat(Date.now() - startTime, "ms"));
|
|
85
85
|
compiler.emit();
|
|
86
86
|
forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js");
|
|
87
87
|
forkedProcess.on("exit", function (code) {
|
package/dist/src/FlinkApp.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OptionsJson } from "body-parser";
|
|
2
2
|
import { Express } from "express";
|
|
3
3
|
import { JSONSchema7 } from "json-schema";
|
|
4
|
-
import { Db } from "mongodb";
|
|
4
|
+
import { Db, MongoClient } from "mongodb";
|
|
5
5
|
import { ToadScheduler } from "toad-scheduler";
|
|
6
6
|
import { FlinkAuthPlugin } from "./auth/FlinkAuthPlugin";
|
|
7
7
|
import { FlinkContext } from "./FlinkContext";
|
|
@@ -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
|
|
12
|
+
export 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
|
|
@@ -156,6 +156,7 @@ export declare class FlinkApp<C extends FlinkContext> {
|
|
|
156
156
|
name: string;
|
|
157
157
|
expressApp?: Express;
|
|
158
158
|
db?: Db;
|
|
159
|
+
dbClient?: MongoClient;
|
|
159
160
|
handlers: HandlerConfig[];
|
|
160
161
|
port?: number;
|
|
161
162
|
started: boolean;
|
|
@@ -164,13 +165,14 @@ export declare class FlinkApp<C extends FlinkContext> {
|
|
|
164
165
|
private debug;
|
|
165
166
|
private onDbConnection?;
|
|
166
167
|
private plugins;
|
|
167
|
-
|
|
168
|
+
auth?: FlinkAuthPlugin;
|
|
168
169
|
private corsOpts;
|
|
169
170
|
private routingConfigured;
|
|
170
171
|
private jsonOptions?;
|
|
171
172
|
private rawContentTypes?;
|
|
172
173
|
private schedulingOptions?;
|
|
173
174
|
private disableHttpServer;
|
|
175
|
+
private expressServer;
|
|
174
176
|
private repos;
|
|
175
177
|
/**
|
|
176
178
|
* Internal cache used to track registered handlers and potentially any overlapping routes
|
|
@@ -181,6 +183,7 @@ export declare class FlinkApp<C extends FlinkContext> {
|
|
|
181
183
|
constructor(opts: FlinkOptions);
|
|
182
184
|
get ctx(): C;
|
|
183
185
|
start(): Promise<this>;
|
|
186
|
+
stop(): Promise<void>;
|
|
184
187
|
/**
|
|
185
188
|
* Manually registers a handler.
|
|
186
189
|
*
|