@flink-app/flink 0.13.5 → 0.14.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @flink-app/flink
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7da5227: Pass extra arguments through to forked process in flink run command. This enables passing arguments like --filter to test runners or other CLI flags to the application being run. Example usage: `npm run test -- --filter="spec/file.spec.ts"`
8
+
9
+ ### Patch Changes
10
+
11
+ - 8ad040f: Support void and undefined types in handler schemas. Handlers can now use `void` or `undefined` for request/response type arguments to explicitly indicate no schema validation is needed. Example: `Handler<Ctx, void, void>` for endpoints with no request or response body.
12
+
3
13
  ## 0.13.5
4
14
 
5
15
  ### Patch Changes
package/cli/run.ts CHANGED
@@ -40,7 +40,14 @@ module.exports = async function run(args: string[]) {
40
40
  console.warn("WARNING: --entry is ignored when using --precompiled");
41
41
  }
42
42
 
43
- const forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js");
43
+ // Collect extra arguments to pass through to the forked process
44
+ const extraArgs = args.filter(arg =>
45
+ arg !== "--precompiled" &&
46
+ !arg.startsWith("--entry") &&
47
+ arg !== args[args.indexOf("--entry") + 1]
48
+ ).filter(arg => arg !== args[0] || args[0].startsWith("--"));
49
+
50
+ const forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js", extraArgs);
44
51
 
45
52
  forkedProcess.on("exit", (code: any) => {
46
53
  process.exit(code);
@@ -62,7 +69,13 @@ module.exports = async function run(args: string[]) {
62
69
 
63
70
  compiler.emit();
64
71
 
65
- const forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js");
72
+ // Collect extra arguments to pass through to the forked process
73
+ const extraArgs = args.filter(arg =>
74
+ !arg.startsWith("--entry") &&
75
+ arg !== args[args.indexOf("--entry") + 1]
76
+ ).filter(arg => arg !== args[0] || args[0].startsWith("--"));
77
+
78
+ const forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js", extraArgs);
66
79
 
67
80
  forkedProcess.on("exit", (code: any) => {
68
81
  process.exit(code);
package/dist/cli/run.js CHANGED
@@ -43,7 +43,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
43
43
  var TypeScriptCompiler_1 = __importDefault(require("../src/TypeScriptCompiler"));
44
44
  module.exports = function run(args) {
45
45
  return __awaiter(this, void 0, void 0, function () {
46
- var startTime, dir, entry, forkedProcess_1, compiler, forkedProcess;
46
+ var startTime, dir, entry, extraArgs_1, forkedProcess_1, compiler, extraArgs, forkedProcess;
47
47
  return __generator(this, function (_a) {
48
48
  switch (_a.label) {
49
49
  case 0:
@@ -65,7 +65,12 @@ module.exports = function run(args) {
65
65
  if (args.includes("--entry")) {
66
66
  console.warn("WARNING: --entry is ignored when using --precompiled");
67
67
  }
68
- forkedProcess_1 = require("child_process").fork(dir + "/dist/.flink/start.js");
68
+ extraArgs_1 = args.filter(function (arg) {
69
+ return arg !== "--precompiled" &&
70
+ !arg.startsWith("--entry") &&
71
+ arg !== args[args.indexOf("--entry") + 1];
72
+ }).filter(function (arg) { return arg !== args[0] || args[0].startsWith("--"); });
73
+ forkedProcess_1 = require("child_process").fork(dir + "/dist/.flink/start.js", extraArgs_1);
69
74
  forkedProcess_1.on("exit", function (code) {
70
75
  process.exit(code);
71
76
  });
@@ -83,7 +88,11 @@ module.exports = function run(args) {
83
88
  _a.sent();
84
89
  console.log("Compilation done, took ".concat(Date.now() - startTime, "ms"));
85
90
  compiler.emit();
86
- forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js");
91
+ extraArgs = args.filter(function (arg) {
92
+ return !arg.startsWith("--entry") &&
93
+ arg !== args[args.indexOf("--entry") + 1];
94
+ }).filter(function (arg) { return arg !== args[0] || args[0].startsWith("--"); });
95
+ forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js", extraArgs);
87
96
  forkedProcess.on("exit", function (code) {
88
97
  process.exit(code);
89
98
  });
@@ -522,11 +522,15 @@ var TypeScriptCompiler = /** @class */ (function () {
522
522
  };
523
523
  TypeScriptCompiler.prototype.saveIntermediateTsSchema = function (schema, handlerFile, suffix) {
524
524
  return __awaiter(this, void 0, void 0, function () {
525
- var handlerFileName, generatedSchemaInterfaceStr, schemaInterfaceName, schemaSymbol, interfaceName, declaration, _i, _a, typeToImport, typeSymbol, declaredTypeSymbol, _b, _c, prop, propDecl, propText, interfaceNameMatches, _d, interfaceNameMatches_1, match, referencedInterfaceName, referencedInterfaceDecl, arrayTypeArg, schemaSymbol, interfaceName, declaration, props, _e, _f, typeToImport, typeSymbol, declaredTypeSymbol, schemaSymbol, declarations, declaration, propertySignatures, _g, _h, prop, propType, typeSymbol, typeDeclaration, elementType, elementSymbol, elementDeclaration, currentPropTypeText, interfaceNameMatches, _j, interfaceNameMatches_2, match, interfaceName, interfaceDecl, typeArgs, _k, typeArgs_1, typeArg, argSymbol, argDeclaration, _l, _m, typeToImport, typeSymbol, declaredTypeSymbol;
525
+ var schemaText, handlerFileName, generatedSchemaInterfaceStr, schemaInterfaceName, schemaSymbol, interfaceName, declaration, _i, _a, typeToImport, typeSymbol, declaredTypeSymbol, _b, _c, prop, propDecl, propText, interfaceNameMatches, _d, interfaceNameMatches_1, match, referencedInterfaceName, referencedInterfaceDecl, arrayTypeArg, schemaSymbol, interfaceName, declaration, props, _e, _f, typeToImport, typeSymbol, declaredTypeSymbol, schemaSymbol, declarations, declaration, propertySignatures, _g, _h, prop, propType, typeSymbol, typeDeclaration, elementType, elementSymbol, elementDeclaration, currentPropTypeText, interfaceNameMatches, _j, interfaceNameMatches_2, match, interfaceName, interfaceDecl, typeArgs, _k, typeArgs_1, typeArg, argSymbol, argDeclaration, _l, _m, typeToImport, typeSymbol, declaredTypeSymbol;
526
526
  return __generator(this, function (_o) {
527
527
  if (schema.isAny()) {
528
528
  return [2 /*return*/]; // 'any' indicates that no schema is used
529
529
  }
530
+ schemaText = schema.getText();
531
+ if (schemaText === 'void' || schemaText === 'undefined') {
532
+ return [2 /*return*/];
533
+ }
530
534
  handlerFileName = handlerFile.getBaseNameWithoutExtension().replace(/\./g, "_");
531
535
  generatedSchemaInterfaceStr = "";
532
536
  schemaInterfaceName = "".concat(handlerFileName, "_").concat(suffix);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flink-app/flink",
3
- "version": "0.13.5",
3
+ "version": "0.14.0",
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",
@@ -0,0 +1,54 @@
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["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/:id",
42
+ };
43
+ var DeleteCar = 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
+ // Delete car logic here
47
+ return [2 /*return*/, {
48
+ data: undefined,
49
+ }];
50
+ });
51
+ }); };
52
+ exports.default = DeleteCar;
53
+ exports.__assumedHttpMethod = "delete", exports.__file = "DeleteCar.ts", exports.__query = [], exports.__params = [];
54
+ exports.__schemas = { reqSchema: undefined, resSchema: undefined };
@@ -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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["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: "/void-request",
42
+ };
43
+ var PostVoidRequest = 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
+ success: true,
49
+ },
50
+ }];
51
+ });
52
+ }); };
53
+ exports.default = PostVoidRequest;
54
+ exports.__assumedHttpMethod = "post", exports.__file = "PostVoidRequest.ts", exports.__query = [], exports.__params = [];
55
+ exports.__schemas = { reqSchema: undefined, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "success": { "type": "boolean" } }, "required": ["success"], "additionalProperties": false, "definitions": {} } };
@@ -456,6 +456,12 @@ export default {}; // Export an empty object to make it a module
456
456
  return; // 'any' indicates that no schema is used
457
457
  }
458
458
 
459
+ // Check for void and undefined types - these indicate no schema validation needed
460
+ const schemaText = schema.getText();
461
+ if (schemaText === 'void' || schemaText === 'undefined') {
462
+ return;
463
+ }
464
+
459
465
  const handlerFileName = handlerFile.getBaseNameWithoutExtension().replace(/\./g, "_");
460
466
 
461
467
  let generatedSchemaInterfaceStr = "";