@flink-app/flink 0.2.0-beta.15 → 0.2.0-beta.17

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.
Files changed (34) hide show
  1. package/.vscode/notes.txt +11 -0
  2. package/dist/src/FlinkJob.d.ts +58 -0
  3. package/dist/src/FlinkJob.js +2 -0
  4. package/dist/src/FlinkRepo.d.ts +1 -1
  5. package/dist/src/FlinkRepo.js +3 -3
  6. package/package.json +2 -2
  7. package/spec/mock-project/dist/src/handlers/GetCar.js +57 -0
  8. package/spec/mock-project/dist/src/handlers/GetCar2.js +59 -0
  9. package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema.js +53 -0
  10. package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema2.js +53 -0
  11. package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema3.js +53 -0
  12. package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema.js +55 -0
  13. package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema2.js +55 -0
  14. package/{dist/cli/generate.js → spec/mock-project/dist/src/handlers/GetCarWithOmitSchema.js} +19 -14
  15. package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile.js +58 -0
  16. package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile2.js +58 -0
  17. package/spec/mock-project/dist/src/handlers/GetCarWithTypeSchema.js +60 -0
  18. package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler.js +54 -0
  19. package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler2.js +56 -0
  20. package/spec/mock-project/dist/src/handlers/PostCar.js +55 -0
  21. package/{dist/cli/generate-schema.js → spec/mock-project/dist/src/handlers/PostLogin.js} +18 -16
  22. package/spec/mock-project/dist/src/handlers/PutCar.js +55 -0
  23. package/spec/mock-project/dist/src/index.js +83 -0
  24. package/spec/mock-project/dist/src/repos/CarRepo.js +26 -0
  25. package/spec/mock-project/dist/src/schemas/Car.js +2 -0
  26. package/spec/mock-project/dist/src/schemas/DefaultExportSchema.js +2 -0
  27. package/spec/mock-project/dist/src/schemas/FileWithTwoSchemas.js +2 -0
  28. package/src/FlinkRepo.ts +6 -6
  29. package/dist/cli/generate-schema.d.ts +0 -2
  30. package/dist/cli/generate.d.ts +0 -2
  31. package/dist/src/FlinkTsParser.d.ts +0 -2
  32. package/dist/src/FlinkTsParser.js +0 -219
  33. package/dist/src/FlinkTsUtils.d.ts +0 -16
  34. package/dist/src/FlinkTsUtils.js +0 -118
@@ -0,0 +1,11 @@
1
+ 1. Build time: Convert interfaces to JSON schemas
2
+
3
+
4
+ ./.flink/schemas
5
+
6
+ 2. Run time: Read JSON schemas from dir ./.flink/schemas/*.ts
7
+
8
+
9
+
10
+
11
+ flink prepare
@@ -0,0 +1,58 @@
1
+ import { FlinkContext } from "./FlinkContext";
2
+ export type FlinkJobProps = {
3
+ /**
4
+ * Id of job, must be unique
5
+ */
6
+ id: string;
7
+ /**
8
+ * Cron expression for scheduling job with minute precision
9
+ * Example: * * * * *
10
+ */
11
+ cron?: string;
12
+ /**
13
+ * Timezone for cron expression
14
+ * Example: Europe/Stockholm
15
+ */
16
+ timezone?: string;
17
+ /**
18
+ * Interval for scheduling job
19
+ * Uses ms syntax, i.e. 1s, 1m, 1h, 1d
20
+ */
21
+ interval?: string;
22
+ /**
23
+ * If true, job will only run once at startup after delay.
24
+ * Uses ms syntax, i.e. 1s, 1m, 1h, 1d
25
+ */
26
+ afterDelay?: string;
27
+ /**
28
+ * If true, job will only one at a time.
29
+ *
30
+ * If a job is already running, the next invocation will be ignored and will be
31
+ * retried after the next interval.
32
+ */
33
+ singleton?: boolean;
34
+ };
35
+ /**
36
+ * Type for Flink job function. This function should be default exported from
37
+ * a Job file and the body is what will be executed when the job is invoked.
38
+ */
39
+ export interface FlinkJob<C extends FlinkContext> {
40
+ (params: {
41
+ ctx: C;
42
+ }): Promise<any>;
43
+ }
44
+ /**
45
+ * Type for Job file.
46
+ *
47
+ * Describes shape of exports when using syntax like:
48
+ *
49
+ * `import * as FooJob from "./src/jobs/FooJob"
50
+ */
51
+ export type FlinkJobFile = {
52
+ default: FlinkJob<any>;
53
+ Job: FlinkJobProps;
54
+ /**
55
+ * Typescript source file name, is set at compile time by Flink compiler.
56
+ */
57
+ __file?: string;
58
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,7 +2,7 @@ import { Collection, Db } from "mongodb";
2
2
  import { FlinkContext } from "./FlinkContext";
3
3
  export declare abstract class FlinkRepo<C extends FlinkContext, Model = any> {
4
4
  private collectionName;
5
- private db;
5
+ db: Db;
6
6
  collection: Collection;
7
7
  private _ctx?;
8
8
  set ctx(ctx: FlinkContext);
@@ -67,7 +67,7 @@ var FlinkRepo = /** @class */ (function () {
67
67
  FlinkRepo.prototype.getById = function (id) {
68
68
  return __awaiter(this, void 0, void 0, function () {
69
69
  return __generator(this, function (_a) {
70
- return [2 /*return*/, this.collection.findOne({ _id: new mongodb_1.ObjectID(id) })];
70
+ return [2 /*return*/, this.collection.findOne({ _id: new mongodb_1.ObjectId(id) })];
71
71
  });
72
72
  });
73
73
  };
@@ -98,7 +98,7 @@ var FlinkRepo = /** @class */ (function () {
98
98
  return __generator(this, function (_a) {
99
99
  switch (_a.label) {
100
100
  case 0:
101
- oid = new mongodb_1.ObjectID(id);
101
+ oid = new mongodb_1.ObjectId(id);
102
102
  return [4 /*yield*/, this.collection.updateOne({
103
103
  _id: oid,
104
104
  }, {
@@ -132,7 +132,7 @@ var FlinkRepo = /** @class */ (function () {
132
132
  return __generator(this, function (_a) {
133
133
  switch (_a.label) {
134
134
  case 0: return [4 /*yield*/, this.collection.deleteOne({
135
- _id: new mongodb_1.ObjectID(id),
135
+ _id: new mongodb_1.ObjectId(id),
136
136
  })];
137
137
  case 1:
138
138
  deletedCount = (_a.sent()).deletedCount;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flink-app/flink",
3
- "version": "0.2.0-beta.15",
3
+ "version": "0.2.0-beta.17",
4
4
  "description": "Typescript only framework for creating REST-like APIs on top of Express and mongodb",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "main": "dist/src/index.js",
@@ -62,5 +62,5 @@
62
62
  "rimraf": "^3.0.2",
63
63
  "ts-node": "^9.1.1"
64
64
  },
65
- "gitHead": "798ef9a11c291c0b16ed937436dd46986942546c"
65
+ "gitHead": "76e4647bd059afadeb0070e9392c61e01a494de9"
66
66
  }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ var flink_1 = require("@flink-app/flink");
41
+ exports.Route = {
42
+ path: "/car/:id",
43
+ method: flink_1.HttpMethod.get,
44
+ };
45
+ var GetCar = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
46
+ var ctx = _b.ctx, req = _b.req;
47
+ return __generator(this, function (_c) {
48
+ return [2 /*return*/, {
49
+ data: {
50
+ model: "Volvo",
51
+ },
52
+ }];
53
+ });
54
+ }); };
55
+ exports.default = GetCar;
56
+ exports.__assumedHttpMethod = "get", exports.__file = "GetCar.ts", exports.__query = [{ description: "For pagination", name: "page" }], exports.__params = [{ description: "", name: "id" }];
57
+ exports.__schemas = { reqSchema: undefined, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "model": { "type": "string" }, "metadata": { "type": "object", "properties": { "created": { "type": "string", "format": "date-time" } }, "additionalProperties": false } }, "required": ["model"], "definitions": {} } };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ var flink_1 = require("@flink-app/flink");
41
+ exports.Route = {
42
+ path: "/car2",
43
+ method: flink_1.HttpMethod.get,
44
+ permissions: "*",
45
+ };
46
+ var GetCar2 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
47
+ var ctx = _b.ctx, req = _b.req;
48
+ return __generator(this, function (_c) {
49
+ return [2 /*return*/, {
50
+ data: {
51
+ model: { name: "Mercedes" },
52
+ engine: { name: "Rolls Royce" },
53
+ },
54
+ }];
55
+ });
56
+ }); };
57
+ exports.default = GetCar2;
58
+ exports.__assumedHttpMethod = "get", exports.__file = "GetCar2.ts", exports.__query = [], exports.__params = [];
59
+ exports.__schemas = { reqSchema: undefined, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "model": { "type": "object", "properties": { "name": { "type": "string" }, "metadata": { "type": "object", "properties": { "created": { "type": "string", "format": "date-time" } }, "additionalProperties": false } }, "required": ["name"], "additionalProperties": false }, "engine": { "type": "object", "properties": { "name": { "type": "string" } }, "required": ["name"], "additionalProperties": false } }, "required": ["model", "engine"], "additionalProperties": false, "definitions": {} } };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ exports.Route = {
41
+ path: "/car-with-array-schema",
42
+ };
43
+ var GetCarWithArraySchema = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
44
+ var ctx = _b.ctx, req = _b.req;
45
+ return __generator(this, function (_c) {
46
+ return [2 /*return*/, {
47
+ data: [{ model: "Volvo" }],
48
+ }];
49
+ });
50
+ }); };
51
+ exports.default = GetCarWithArraySchema;
52
+ exports.__assumedHttpMethod = "get", exports.__file = "GetCarWithArraySchema.ts", exports.__query = [], exports.__params = [];
53
+ exports.__schemas = { reqSchema: undefined, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "array", "items": { "type": "object", "properties": { "model": { "type": "string" }, "metadata": { "type": "object", "properties": { "created": { "type": "string", "format": "date-time" } }, "additionalProperties": false } }, "required": ["model"], "additionalProperties": false }, "definitions": {} } };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ exports.Route = {
41
+ path: "/car-with-array-schema2",
42
+ };
43
+ var GetCarWithArraySchema2 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
44
+ var ctx = _b.ctx, req = _b.req;
45
+ return __generator(this, function (_c) {
46
+ return [2 /*return*/, {
47
+ data: [{ car: { model: "Volvo" } }],
48
+ }];
49
+ });
50
+ }); };
51
+ exports.default = GetCarWithArraySchema2;
52
+ exports.__assumedHttpMethod = "get", exports.__file = "GetCarWithArraySchema2.ts", exports.__query = [], exports.__params = [];
53
+ exports.__schemas = { reqSchema: undefined, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "array", "items": { "type": "object", "properties": { "car": { "type": "object", "properties": { "model": { "type": "string" }, "metadata": { "type": "object", "properties": { "created": { "type": "string", "format": "date-time" } }, "additionalProperties": false } }, "required": ["model"], "additionalProperties": false } }, "required": ["car"], "additionalProperties": false }, "definitions": {} } };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ exports.Route = {
41
+ path: "/car-with-array-schema3",
42
+ };
43
+ var GetCarWithArraySchema3 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
44
+ var ctx = _b.ctx, req = _b.req;
45
+ return __generator(this, function (_c) {
46
+ return [2 /*return*/, {
47
+ data: [{ car: { model: "Volvo" }, year: 2002 }],
48
+ }];
49
+ });
50
+ }); };
51
+ exports.default = GetCarWithArraySchema3;
52
+ exports.__assumedHttpMethod = "get", exports.__file = "GetCarWithArraySchema3.ts", exports.__query = [], exports.__params = [];
53
+ exports.__schemas = { reqSchema: undefined, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "array", "items": { "type": "object", "properties": { "car": { "type": "object", "properties": { "model": { "type": "string" }, "metadata": { "type": "object", "properties": { "created": { "type": "string", "format": "date-time" } }, "additionalProperties": false } }, "required": ["model"], "additionalProperties": false }, "year": { "type": "number" } }, "required": ["car", "year"], "additionalProperties": false }, "definitions": {} } };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ exports.Route = {
41
+ path: "/car-with-literal-schema",
42
+ };
43
+ var GetCarWithLiteralSchema = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
44
+ var ctx = _b.ctx, req = _b.req;
45
+ return __generator(this, function (_c) {
46
+ return [2 /*return*/, {
47
+ data: {
48
+ car: { model: "Volvo" },
49
+ },
50
+ }];
51
+ });
52
+ }); };
53
+ exports.default = GetCarWithLiteralSchema;
54
+ exports.__assumedHttpMethod = "get", exports.__file = "GetCarWithLiteralSchema.ts", exports.__query = [], exports.__params = [];
55
+ exports.__schemas = { reqSchema: undefined, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "car": { "type": "object", "properties": { "model": { "type": "string" }, "metadata": { "type": "object", "properties": { "created": { "type": "string", "format": "date-time" } }, "additionalProperties": false } }, "required": ["model"], "additionalProperties": false } }, "required": ["car"], "additionalProperties": false, "definitions": {} } };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ exports.Route = {
41
+ path: "/car-with-literal-schema2",
42
+ };
43
+ var GetCarWithLiteralSchema2 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
44
+ var ctx = _b.ctx, req = _b.req;
45
+ return __generator(this, function (_c) {
46
+ return [2 /*return*/, {
47
+ data: {
48
+ car: { nestedCar: { model: "Volvo" } },
49
+ },
50
+ }];
51
+ });
52
+ }); };
53
+ exports.default = GetCarWithLiteralSchema2;
54
+ exports.__assumedHttpMethod = "get", exports.__file = "GetCarWithLiteralSchema2.ts", exports.__query = [], exports.__params = [];
55
+ exports.__schemas = { reqSchema: undefined, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "car": { "type": "object", "properties": { "nestedCar": { "type": "object", "properties": { "model": { "type": "string" }, "metadata": { "type": "object", "properties": { "created": { "type": "string", "format": "date-time" } }, "additionalProperties": false } }, "required": ["model"], "additionalProperties": false } }, "required": ["nestedCar"], "additionalProperties": false } }, "required": ["car"], "additionalProperties": false, "definitions": {} } };
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  "use strict";
3
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -37,18 +36,24 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
36
  }
38
37
  };
39
38
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.run = void 0;
41
- var FlinkTsParser_1 = require("../src/FlinkTsParser");
42
- function run() {
43
- return __awaiter(this, void 0, void 0, function () {
44
- return __generator(this, function (_a) {
45
- switch (_a.label) {
46
- case 0: return [4 /*yield*/, FlinkTsParser_1.parseSourceFiles()];
47
- case 1:
48
- _a.sent();
49
- return [2 /*return*/];
50
- }
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ exports.Route = {
41
+ path: "/car-with-omit-schema",
42
+ };
43
+ // interface CarWithoutId extends Omit<Car, "_id"> {}
44
+ var GetCarWithOmitSchema = function (_a) {
45
+ var ctx = _a.ctx, req = _a.req;
46
+ return __awaiter(void 0, void 0, void 0, function () {
47
+ return __generator(this, function (_b) {
48
+ return [2 /*return*/, {
49
+ data: {
50
+ model: "Volvo",
51
+ foo: 1,
52
+ },
53
+ }];
51
54
  });
52
55
  });
53
- }
54
- exports.run = run;
56
+ };
57
+ exports.default = GetCarWithOmitSchema;
58
+ exports.__assumedHttpMethod = "get", exports.__file = "GetCarWithOmitSchema.ts", exports.__query = [], exports.__params = [];
59
+ exports.__schemas = { reqSchema: undefined, resSchema: undefined };
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
40
+ var flink_1 = require("@flink-app/flink");
41
+ exports.Route = {
42
+ path: "/car-with-schema-in-file",
43
+ method: flink_1.HttpMethod.get,
44
+ permissions: "*",
45
+ };
46
+ var GetCarWithSchemaInFile = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
47
+ var ctx = _b.ctx, req = _b.req;
48
+ return __generator(this, function (_c) {
49
+ return [2 /*return*/, {
50
+ data: {
51
+ model: "Volvo",
52
+ },
53
+ }];
54
+ });
55
+ }); };
56
+ exports.default = GetCarWithSchemaInFile;
57
+ exports.__assumedHttpMethod = "get", exports.__file = "GetCarWithSchemaInFile.ts", exports.__query = [], exports.__params = [];
58
+ exports.__schemas = { reqSchema: undefined, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "model": { "type": "string" } }, "required": ["model"], "additionalProperties": false, "definitions": {} } };