@flink-app/flink 1.0.0 → 2.0.0-alpha.48

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 (109) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/cli/build.ts +8 -1
  3. package/cli/run.ts +8 -1
  4. package/dist/cli/build.js +8 -1
  5. package/dist/cli/run.js +8 -1
  6. package/dist/src/FlinkApp.d.ts +33 -0
  7. package/dist/src/FlinkApp.js +247 -27
  8. package/dist/src/FlinkContext.d.ts +21 -0
  9. package/dist/src/FlinkHttpHandler.d.ts +90 -1
  10. package/dist/src/TypeScriptCompiler.d.ts +42 -0
  11. package/dist/src/TypeScriptCompiler.js +346 -4
  12. package/dist/src/TypeScriptUtils.js +4 -0
  13. package/dist/src/ai/AgentRunner.d.ts +39 -0
  14. package/dist/src/ai/AgentRunner.js +625 -0
  15. package/dist/src/ai/FlinkAgent.d.ts +446 -0
  16. package/dist/src/ai/FlinkAgent.js +633 -0
  17. package/dist/src/ai/FlinkTool.d.ts +37 -0
  18. package/dist/src/ai/FlinkTool.js +2 -0
  19. package/dist/src/ai/LLMAdapter.d.ts +119 -0
  20. package/dist/src/ai/LLMAdapter.js +2 -0
  21. package/dist/src/ai/SubAgentExecutor.d.ts +36 -0
  22. package/dist/src/ai/SubAgentExecutor.js +220 -0
  23. package/dist/src/ai/ToolExecutor.d.ts +35 -0
  24. package/dist/src/ai/ToolExecutor.js +237 -0
  25. package/dist/src/ai/index.d.ts +5 -0
  26. package/dist/src/ai/index.js +21 -0
  27. package/dist/src/handlers/StreamWriterFactory.d.ts +20 -0
  28. package/dist/src/handlers/StreamWriterFactory.js +83 -0
  29. package/dist/src/index.d.ts +4 -0
  30. package/dist/src/index.js +4 -0
  31. package/dist/src/utils.d.ts +30 -0
  32. package/dist/src/utils.js +52 -0
  33. package/package.json +14 -2
  34. package/readme.md +425 -0
  35. package/spec/AgentDuplicateDetection.spec.ts +112 -0
  36. package/spec/AgentRunner.spec.ts +527 -0
  37. package/spec/ConversationHooks.spec.ts +290 -0
  38. package/spec/FlinkAgent.spec.ts +310 -0
  39. package/spec/FlinkApp.onError.spec.ts +1 -2
  40. package/spec/StreamingIntegration.spec.ts +138 -0
  41. package/spec/SubAgentSupport.spec.ts +941 -0
  42. package/spec/ToolExecutor.spec.ts +360 -0
  43. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCar.js +57 -0
  44. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCar2.js +59 -0
  45. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema.js +53 -0
  46. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema2.js +53 -0
  47. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema3.js +53 -0
  48. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithLiteralSchema.js +55 -0
  49. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithLiteralSchema2.js +55 -0
  50. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithSchemaInFile.js +58 -0
  51. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithSchemaInFile2.js +58 -0
  52. package/spec/mock-project/dist/spec/mock-project/src/handlers/ManuallyAddedHandler.js +53 -0
  53. package/spec/mock-project/dist/spec/mock-project/src/handlers/ManuallyAddedHandler2.js +55 -0
  54. package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchCar.js +58 -0
  55. package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchOnboardingSession.js +76 -0
  56. package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchOrderWithComplexTypes.js +58 -0
  57. package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchProductWithIntersection.js +59 -0
  58. package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchUserWithUnion.js +59 -0
  59. package/spec/mock-project/dist/spec/mock-project/src/handlers/PostCar.js +55 -0
  60. package/spec/mock-project/dist/spec/mock-project/src/handlers/PostLogin.js +56 -0
  61. package/spec/mock-project/dist/spec/mock-project/src/handlers/PostLogout.js +55 -0
  62. package/spec/mock-project/dist/spec/mock-project/src/handlers/PutCar.js +55 -0
  63. package/spec/mock-project/dist/spec/mock-project/src/index.js +83 -0
  64. package/spec/mock-project/dist/spec/mock-project/src/repos/CarRepo.js +26 -0
  65. package/spec/mock-project/dist/spec/mock-project/src/schemas/Car.js +2 -0
  66. package/spec/mock-project/dist/spec/mock-project/src/schemas/DefaultExportSchema.js +2 -0
  67. package/spec/mock-project/dist/spec/mock-project/src/schemas/FileWithTwoSchemas.js +2 -0
  68. package/spec/mock-project/dist/src/FlinkApp.js +1012 -0
  69. package/spec/mock-project/dist/src/FlinkContext.js +2 -0
  70. package/spec/mock-project/dist/src/FlinkErrors.js +143 -0
  71. package/spec/mock-project/dist/src/FlinkHttpHandler.js +47 -0
  72. package/spec/mock-project/dist/src/FlinkJob.js +2 -0
  73. package/spec/mock-project/dist/src/FlinkLog.js +26 -0
  74. package/spec/mock-project/dist/src/FlinkPlugin.js +2 -0
  75. package/spec/mock-project/dist/src/FlinkRepo.js +224 -0
  76. package/spec/mock-project/dist/src/FlinkResponse.js +2 -0
  77. package/spec/mock-project/dist/src/ai/AgentExecutor.js +279 -0
  78. package/spec/mock-project/dist/src/ai/AgentRunner.js +625 -0
  79. package/spec/mock-project/dist/src/ai/FlinkAgent.js +633 -0
  80. package/spec/mock-project/dist/src/ai/FlinkTool.js +2 -0
  81. package/spec/mock-project/dist/src/ai/LLMAdapter.js +2 -0
  82. package/spec/mock-project/dist/src/ai/SubAgentExecutor.js +220 -0
  83. package/spec/mock-project/dist/src/ai/ToolExecutor.js +237 -0
  84. package/spec/mock-project/dist/src/auth/FlinkAuthPlugin.js +2 -0
  85. package/spec/mock-project/dist/src/auth/FlinkAuthUser.js +2 -0
  86. package/spec/mock-project/dist/src/handlers/StreamWriterFactory.js +83 -0
  87. package/spec/mock-project/dist/src/index.js +17 -69
  88. package/spec/mock-project/dist/src/mock-data-generator.js +9 -0
  89. package/spec/mock-project/dist/src/utils.js +290 -0
  90. package/spec/mock-project/tsconfig.json +6 -1
  91. package/spec/testHelpers.ts +49 -0
  92. package/spec/utils.caseConversion.spec.ts +80 -0
  93. package/spec/utils.spec.ts +13 -13
  94. package/src/FlinkApp.ts +251 -7
  95. package/src/FlinkContext.ts +22 -0
  96. package/src/FlinkHttpHandler.ts +100 -2
  97. package/src/TypeScriptCompiler.ts +398 -7
  98. package/src/TypeScriptUtils.ts +5 -0
  99. package/src/ai/AgentRunner.ts +549 -0
  100. package/src/ai/FlinkAgent.ts +770 -0
  101. package/src/ai/FlinkTool.ts +40 -0
  102. package/src/ai/LLMAdapter.ts +96 -0
  103. package/src/ai/SubAgentExecutor.ts +199 -0
  104. package/src/ai/ToolExecutor.ts +193 -0
  105. package/src/ai/index.ts +5 -0
  106. package/src/handlers/StreamWriterFactory.ts +84 -0
  107. package/src/index.ts +4 -0
  108. package/src/utils.ts +52 -0
  109. package/tsconfig.json +6 -1
@@ -0,0 +1,360 @@
1
+ import { z } from "zod";
2
+ import { ToolExecutor } from "../src/ai/ToolExecutor";
3
+ import { FlinkTool, FlinkToolProps, ToolResult } from "../src/ai/FlinkTool";
4
+ import { FlinkContext } from "../src/FlinkContext";
5
+
6
+ describe("ToolExecutor", () => {
7
+ let mockCtx: FlinkContext;
8
+
9
+ beforeEach(() => {
10
+ mockCtx = {
11
+ repos: {},
12
+ plugins: {},
13
+ };
14
+ });
15
+
16
+ describe("Input validation", () => {
17
+ it("should validate input with Zod schema", async () => {
18
+ const toolProps: FlinkToolProps = {
19
+ id: "test_tool",
20
+ description: "Test tool",
21
+ inputSchema: z.object({
22
+ name: z.string(),
23
+ age: z.number(),
24
+ }),
25
+ };
26
+
27
+ const toolFn: FlinkTool<any> = async ({ input }) => {
28
+ return { success: true, data: { result: "ok" } };
29
+ };
30
+
31
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
32
+
33
+ const result = await executor.execute({ name: "John", age: 30 });
34
+
35
+ expect(result.success).toBe(true);
36
+ if (result.success) {
37
+ expect(result.data).toEqual({ result: "ok" });
38
+ }
39
+ });
40
+
41
+ it("should reject invalid input", async () => {
42
+ const toolProps: FlinkToolProps = {
43
+ id: "test_tool",
44
+ description: "Test tool",
45
+ inputSchema: z.object({
46
+ name: z.string(),
47
+ age: z.number(),
48
+ }),
49
+ };
50
+
51
+ const toolFn: FlinkTool<any> = async ({ input }) => {
52
+ return { success: true, data: { result: "ok" } };
53
+ };
54
+
55
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
56
+
57
+ const result = await executor.execute({ name: "John", age: "invalid" });
58
+
59
+ expect(result.success).toBe(false);
60
+ if (!result.success) {
61
+ expect(result.error).toContain("Invalid input");
62
+ }
63
+ });
64
+ });
65
+
66
+ describe("Output validation", () => {
67
+ it("should validate output when schema provided", async () => {
68
+ const toolProps: FlinkToolProps = {
69
+ id: "test_tool",
70
+ description: "Test tool",
71
+ inputSchema: z.object({ input: z.string() }),
72
+ outputSchema: z.object({ result: z.string() }),
73
+ };
74
+
75
+ const toolFn: FlinkTool<any> = async ({ input }) => {
76
+ return { success: true, data: { result: "valid" } };
77
+ };
78
+
79
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
80
+
81
+ const result = await executor.execute({ input: "test" });
82
+
83
+ expect(result.success).toBe(true);
84
+ if (result.success) {
85
+ expect(result.data).toEqual({ result: "valid" });
86
+ }
87
+ });
88
+
89
+ it("should reject invalid output", async () => {
90
+ const toolProps: FlinkToolProps = {
91
+ id: "test_tool",
92
+ description: "Test tool",
93
+ inputSchema: z.object({ input: z.string() }),
94
+ outputSchema: z.object({ result: z.string() }),
95
+ };
96
+
97
+ const toolFn: FlinkTool<any> = async ({ input }) => {
98
+ return { success: true, data: { result: 123 } }; // Invalid: number instead of string
99
+ };
100
+
101
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
102
+
103
+ const result = await executor.execute({ input: "test" });
104
+
105
+ expect(result.success).toBe(false);
106
+ if (!result.success) {
107
+ expect(result.error).toContain("Invalid output");
108
+ }
109
+ });
110
+ });
111
+
112
+ describe("Permission checks", () => {
113
+ it("should allow execution with no permissions", async () => {
114
+ const toolProps: FlinkToolProps = {
115
+ id: "test_tool",
116
+ description: "Test tool",
117
+ inputSchema: z.object({ input: z.string() }),
118
+ };
119
+
120
+ const toolFn: FlinkTool<any> = async ({ input }) => {
121
+ return { success: true, data: { result: "ok" } };
122
+ };
123
+
124
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
125
+
126
+ const result = await executor.execute({ input: "test" });
127
+
128
+ expect(result.success).toBe(true);
129
+ });
130
+
131
+ it("should check static string permission", async () => {
132
+ const toolProps: FlinkToolProps = {
133
+ id: "test_tool",
134
+ description: "Test tool",
135
+ inputSchema: z.object({ input: z.string() }),
136
+ permissions: "admin",
137
+ };
138
+
139
+ const toolFn: FlinkTool<any> = async ({ input }) => {
140
+ return { success: true, data: { result: "ok" } };
141
+ };
142
+
143
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
144
+
145
+ // Without user
146
+ const result1 = await executor.execute({ input: "test" });
147
+ expect(result1.success).toBe(false);
148
+ if (!result1.success) {
149
+ expect(result1.error).toContain("Permission denied");
150
+ }
151
+
152
+ // With user but no permission
153
+ const result2 = await executor.execute({ input: "test" }, { permissions: [] });
154
+ expect(result2.success).toBe(false);
155
+
156
+ // With user and permission
157
+ const result3 = await executor.execute({ input: "test" }, { permissions: ["admin"] });
158
+ expect(result3.success).toBe(true);
159
+ });
160
+
161
+ it("should check array of permissions", async () => {
162
+ const toolProps: FlinkToolProps = {
163
+ id: "test_tool",
164
+ description: "Test tool",
165
+ inputSchema: z.object({ input: z.string() }),
166
+ permissions: ["admin", "user"],
167
+ };
168
+
169
+ const toolFn: FlinkTool<any> = async ({ input }) => {
170
+ return { success: true, data: { result: "ok" } };
171
+ };
172
+
173
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
174
+
175
+ // With partial permissions
176
+ const result1 = await executor.execute({ input: "test" }, { permissions: ["admin"] });
177
+ expect(result1.success).toBe(false);
178
+
179
+ // With all permissions
180
+ const result2 = await executor.execute({ input: "test" }, { permissions: ["admin", "user"] });
181
+ expect(result2.success).toBe(true);
182
+ });
183
+
184
+ it("should check function-based permissions", async () => {
185
+ const toolProps: FlinkToolProps = {
186
+ id: "test_tool",
187
+ description: "Test tool",
188
+ inputSchema: z.object({ value: z.number() }),
189
+ permissions: (input, user) => {
190
+ return input.value > 10 && user?.isAdmin === true;
191
+ },
192
+ };
193
+
194
+ const toolFn: FlinkTool<any> = async ({ input }) => {
195
+ return { success: true, data: { result: "ok" } };
196
+ };
197
+
198
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
199
+
200
+ // Invalid input value
201
+ const result1 = await executor.execute({ value: 5 }, { isAdmin: true });
202
+ expect(result1.success).toBe(false);
203
+
204
+ // Not admin
205
+ const result2 = await executor.execute({ value: 15 }, { isAdmin: false });
206
+ expect(result2.success).toBe(false);
207
+
208
+ // Valid
209
+ const result3 = await executor.execute({ value: 15 }, { isAdmin: true });
210
+ expect(result3.success).toBe(true);
211
+ });
212
+ });
213
+
214
+ describe("Error handling", () => {
215
+ it("should handle tool errors gracefully", async () => {
216
+ const toolProps: FlinkToolProps = {
217
+ id: "test_tool",
218
+ description: "Test tool",
219
+ inputSchema: z.object({ input: z.string() }),
220
+ };
221
+
222
+ const toolFn: FlinkTool<any> = async ({ input }) => {
223
+ return {
224
+ success: false,
225
+ error: "Something went wrong",
226
+ code: "TOOL_ERROR",
227
+ };
228
+ };
229
+
230
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
231
+
232
+ const result = await executor.execute({ input: "test" });
233
+
234
+ expect(result.success).toBe(false);
235
+ if (!result.success) {
236
+ expect(result.error).toBe("Something went wrong");
237
+ expect(result.code).toBe("TOOL_ERROR");
238
+ }
239
+ });
240
+
241
+ it("should catch thrown errors", async () => {
242
+ const toolProps: FlinkToolProps = {
243
+ id: "test_tool",
244
+ description: "Test tool",
245
+ inputSchema: z.object({ input: z.string() }),
246
+ };
247
+
248
+ const toolFn: FlinkTool<any> = async ({ input }) => {
249
+ throw new Error("Unexpected error");
250
+ };
251
+
252
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
253
+
254
+ const result = await executor.execute({ input: "test" });
255
+
256
+ expect(result.success).toBe(false);
257
+ if (!result.success) {
258
+ expect(result.error).toContain("Tool execution failed");
259
+ expect(result.code).toBe("EXECUTION_ERROR");
260
+ }
261
+ });
262
+ });
263
+
264
+ describe("Tool schema generation", () => {
265
+ it("should generate tool schema for AI", () => {
266
+ const toolProps: FlinkToolProps = {
267
+ id: "get_weather",
268
+ description: "Get weather for a city",
269
+ inputSchema: z.object({
270
+ city: z.string().describe("City name"),
271
+ units: z.enum(["celsius", "fahrenheit"]).optional(),
272
+ }),
273
+ };
274
+
275
+ const toolFn: FlinkTool<any> = async ({ input }) => {
276
+ return { success: true, data: {} };
277
+ };
278
+
279
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
280
+
281
+ const schema = executor.getToolSchema();
282
+
283
+ expect(schema.name).toBe("get_weather");
284
+ expect(schema.description).toBe("Get weather for a city");
285
+ expect(schema.inputSchema).toBeDefined();
286
+ });
287
+ });
288
+
289
+ describe("Result formatting for AI", () => {
290
+ it("should format success result as JSON", () => {
291
+ const toolProps: FlinkToolProps = {
292
+ id: "test_tool",
293
+ description: "Test tool",
294
+ inputSchema: z.object({ input: z.string() }),
295
+ };
296
+
297
+ const toolFn: FlinkTool<any> = async ({ input }) => {
298
+ return { success: true, data: {} };
299
+ };
300
+
301
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
302
+
303
+ const result: ToolResult<any> = {
304
+ success: true,
305
+ data: { temperature: 22, conditions: "sunny" },
306
+ };
307
+
308
+ const formatted = executor.formatResultForAI(result);
309
+
310
+ expect(formatted).toBe('{"temperature":22,"conditions":"sunny"}');
311
+ });
312
+
313
+ it("should format error result with code", () => {
314
+ const toolProps: FlinkToolProps = {
315
+ id: "test_tool",
316
+ description: "Test tool",
317
+ inputSchema: z.object({ input: z.string() }),
318
+ };
319
+
320
+ const toolFn: FlinkTool<any> = async ({ input }) => {
321
+ return { success: true, data: {} };
322
+ };
323
+
324
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
325
+
326
+ const result: ToolResult<any> = {
327
+ success: false,
328
+ error: "API rate limit exceeded",
329
+ code: "RATE_LIMIT",
330
+ };
331
+
332
+ const formatted = executor.formatResultForAI(result);
333
+
334
+ expect(formatted).toBe("Error: API rate limit exceeded (RATE_LIMIT)");
335
+ });
336
+
337
+ it("should format error result without code", () => {
338
+ const toolProps: FlinkToolProps = {
339
+ id: "test_tool",
340
+ description: "Test tool",
341
+ inputSchema: z.object({ input: z.string() }),
342
+ };
343
+
344
+ const toolFn: FlinkTool<any> = async ({ input }) => {
345
+ return { success: true, data: {} };
346
+ };
347
+
348
+ const executor = new ToolExecutor(toolProps, toolFn, mockCtx);
349
+
350
+ const result: ToolResult<any> = {
351
+ success: false,
352
+ error: "Something went wrong",
353
+ };
354
+
355
+ const formatted = executor.formatResultForAI(result);
356
+
357
+ expect(formatted).toBe("Error: Something went wrong");
358
+ });
359
+ });
360
+ });
@@ -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 = 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
+ 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 = 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
+ 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 = 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-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 = 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-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 = 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-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": {} } };