@flink-app/flink 0.14.3 → 2.0.0-alpha.100

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 (280) hide show
  1. package/CHANGELOG.md +1051 -0
  2. package/SCHEMA_EXTRACTION_ANALYSIS.md +494 -0
  3. package/SIMPLE_AST_FEASIBILITY.md +570 -0
  4. package/bin/flink.ts +13 -2
  5. package/cli/build.ts +24 -44
  6. package/cli/clean.ts +13 -25
  7. package/cli/cli-utils.ts +190 -17
  8. package/cli/dev.ts +252 -0
  9. package/cli/loadEnvFiles.ts +116 -0
  10. package/cli/run.ts +45 -62
  11. package/dist/bin/flink.js +61 -2
  12. package/dist/cli/build.js +20 -25
  13. package/dist/cli/clean.js +12 -10
  14. package/dist/cli/cli-utils.d.ts +34 -3
  15. package/dist/cli/cli-utils.js +193 -12
  16. package/dist/cli/dev.d.ts +2 -0
  17. package/dist/cli/dev.js +279 -0
  18. package/dist/cli/loadEnvFiles.d.ts +30 -0
  19. package/dist/cli/loadEnvFiles.js +113 -0
  20. package/dist/cli/run.js +47 -46
  21. package/dist/src/DependencyTracker.d.ts +44 -0
  22. package/dist/src/DependencyTracker.js +239 -0
  23. package/dist/src/FlinkApp.d.ts +163 -10
  24. package/dist/src/FlinkApp.js +847 -184
  25. package/dist/src/FlinkContext.d.ts +41 -0
  26. package/dist/src/FlinkErrors.d.ts +19 -6
  27. package/dist/src/FlinkErrors.js +36 -42
  28. package/dist/src/FlinkHttpHandler.d.ts +219 -26
  29. package/dist/src/FlinkHttpHandler.js +37 -1
  30. package/dist/src/FlinkJob.d.ts +10 -0
  31. package/dist/src/FlinkLog.d.ts +82 -18
  32. package/dist/src/FlinkLog.js +165 -13
  33. package/dist/src/FlinkLogFactory.d.ts +288 -0
  34. package/dist/src/FlinkLogFactory.js +619 -0
  35. package/dist/src/FlinkRepo.d.ts +10 -2
  36. package/dist/src/FlinkRepo.js +11 -1
  37. package/dist/src/FlinkRequestContext.d.ts +63 -0
  38. package/dist/src/FlinkRequestContext.js +74 -0
  39. package/dist/src/FlinkResponse.d.ts +6 -0
  40. package/dist/src/FlinkService.d.ts +38 -0
  41. package/dist/src/FlinkService.js +46 -0
  42. package/dist/src/LeaderElection.d.ts +45 -0
  43. package/dist/src/LeaderElection.js +269 -0
  44. package/dist/src/SchemaCache.d.ts +84 -0
  45. package/dist/src/SchemaCache.js +289 -0
  46. package/dist/src/TypeScriptCompiler.d.ts +161 -51
  47. package/dist/src/TypeScriptCompiler.js +1253 -617
  48. package/dist/src/TypeScriptUtils.js +4 -0
  49. package/dist/src/ai/AgentRunner.d.ts +39 -0
  50. package/dist/src/ai/AgentRunner.js +760 -0
  51. package/dist/src/ai/ConversationAgent.d.ts +279 -0
  52. package/dist/src/ai/ConversationAgent.js +404 -0
  53. package/dist/src/ai/ConversationFlinkAgent.d.ts +278 -0
  54. package/dist/src/ai/ConversationFlinkAgent.js +404 -0
  55. package/dist/src/ai/FlinkAgent.d.ts +690 -0
  56. package/dist/src/ai/FlinkAgent.js +729 -0
  57. package/dist/src/ai/FlinkTool.d.ts +135 -0
  58. package/dist/src/ai/FlinkTool.js +2 -0
  59. package/dist/src/ai/InMemoryConversationAgent.d.ts +121 -0
  60. package/dist/src/ai/InMemoryConversationAgent.js +209 -0
  61. package/dist/src/ai/LLMAdapter.d.ts +148 -0
  62. package/dist/src/ai/LLMAdapter.js +2 -0
  63. package/dist/src/ai/PersistentFlinkAgent.d.ts +278 -0
  64. package/dist/src/ai/PersistentFlinkAgent.js +403 -0
  65. package/dist/src/ai/SubAgentExecutor.d.ts +38 -0
  66. package/dist/src/ai/SubAgentExecutor.js +223 -0
  67. package/dist/src/ai/ToolExecutor.d.ts +64 -0
  68. package/dist/src/ai/ToolExecutor.js +497 -0
  69. package/dist/src/ai/agentInstructions.d.ts +68 -0
  70. package/dist/src/ai/agentInstructions.js +286 -0
  71. package/dist/src/ai/index.d.ts +8 -0
  72. package/dist/src/ai/index.js +26 -0
  73. package/dist/src/ai/instructionFileLoader.d.ts +44 -0
  74. package/dist/src/ai/instructionFileLoader.js +179 -0
  75. package/dist/src/auth/FlinkAuthPlugin.d.ts +1 -1
  76. package/dist/src/handlers/StreamWriterFactory.d.ts +20 -0
  77. package/dist/src/handlers/StreamWriterFactory.js +83 -0
  78. package/dist/src/index.d.ts +14 -0
  79. package/dist/src/index.js +17 -0
  80. package/dist/src/loadPluginSchemas.d.ts +45 -0
  81. package/dist/src/loadPluginSchemas.js +143 -0
  82. package/dist/src/schema-extraction/ComplexTypeDetection.d.ts +40 -0
  83. package/dist/src/schema-extraction/ComplexTypeDetection.js +75 -0
  84. package/dist/src/schema-extraction/TypeScriptSourceParser.d.ts +321 -0
  85. package/dist/src/schema-extraction/TypeScriptSourceParser.js +925 -0
  86. package/dist/src/schema-extraction/TypeScriptSourceParser.spec.d.ts +1 -0
  87. package/dist/src/schema-extraction/TypeScriptSourceParser.spec.js +233 -0
  88. package/dist/src/schema-extraction/TypeScriptTokenizer.d.ts +57 -0
  89. package/dist/src/schema-extraction/TypeScriptTokenizer.js +177 -0
  90. package/dist/src/schema-extraction/index.d.ts +2 -0
  91. package/dist/src/schema-extraction/index.js +20 -0
  92. package/dist/src/schema-extraction/types.d.ts +31 -0
  93. package/dist/src/schema-extraction/types.js +2 -0
  94. package/dist/src/utils/loadFlinkConfig.d.ts +53 -0
  95. package/dist/src/utils/loadFlinkConfig.js +77 -0
  96. package/dist/src/utils.d.ts +30 -0
  97. package/dist/src/utils.js +52 -0
  98. package/dist/src/workers/SchemaGeneratorWorker.d.ts +1 -0
  99. package/dist/src/workers/SchemaGeneratorWorker.js +49 -0
  100. package/dist/src/workers/WorkerPool.d.ts +60 -0
  101. package/dist/src/workers/WorkerPool.js +306 -0
  102. package/examples/logging-hierarchical-example.ts +125 -0
  103. package/package.json +29 -4
  104. package/readme.md +499 -0
  105. package/spec/AgentDescendantDetection.spec.ts +335 -0
  106. package/spec/AgentDuplicateDetection.spec.ts +112 -0
  107. package/spec/AgentObserver.spec.ts +266 -0
  108. package/spec/AgentRunner.spec.ts +1062 -0
  109. package/spec/AsyncLocalStorageContext.spec.ts +223 -0
  110. package/spec/ConversationHooks.spec.ts +257 -0
  111. package/spec/FlinkAgent.spec.ts +681 -0
  112. package/spec/FlinkApp.htmlResponse.spec.ts +260 -0
  113. package/spec/FlinkApp.onError.invocation.spec.ts +151 -0
  114. package/spec/FlinkApp.onError.spec.ts +1 -2
  115. package/spec/FlinkApp.query.spec.ts +107 -0
  116. package/spec/FlinkApp.routeOrdering.spec.ts +61 -0
  117. package/spec/FlinkApp.undefinedResponse.spec.ts +123 -0
  118. package/spec/FlinkApp.validationMode.spec.ts +155 -0
  119. package/spec/FlinkJob.spec.ts +171 -0
  120. package/spec/FlinkLogFactory.spec.ts +337 -0
  121. package/spec/FlinkRepo.spec.ts +1 -1
  122. package/spec/LeaderElection.spec.ts +174 -0
  123. package/spec/StreamingIntegration.spec.ts +139 -0
  124. package/spec/ToolExecutor.spec.ts +465 -0
  125. package/spec/TypeScriptCompiler.spec.ts +1 -1
  126. package/spec/TypeScriptSourceParser.spec.ts +1215 -0
  127. package/spec/TypeScriptTokenizer.spec.ts +366 -0
  128. package/spec/ai/ContextCompaction.spec.ts +405 -0
  129. package/spec/ai/ConversationAgent.spec.ts +520 -0
  130. package/spec/ai/InMemoryConversationAgent.spec.ts +144 -0
  131. package/spec/ai/agentInstructions.spec.ts +358 -0
  132. package/spec/fixtures/agent-instructions/TestAgent.ts +24 -0
  133. package/spec/fixtures/agent-instructions/simple.md +3 -0
  134. package/spec/fixtures/agent-instructions/template.md +18 -0
  135. package/spec/fixtures/agent-instructions/yaml-format.yaml +9 -0
  136. package/spec/mock-project/dist/.tsbuildinfo +1 -0
  137. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCar.js +56 -0
  138. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCar2.js +58 -0
  139. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema.js +52 -0
  140. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema2.js +52 -0
  141. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema3.js +52 -0
  142. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithLiteralSchema.js +54 -0
  143. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithLiteralSchema2.js +54 -0
  144. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithSchemaInFile.js +57 -0
  145. package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithSchemaInFile2.js +57 -0
  146. package/spec/mock-project/dist/spec/mock-project/src/handlers/ManuallyAddedHandler.js +53 -0
  147. package/spec/mock-project/dist/spec/mock-project/src/handlers/ManuallyAddedHandler2.js +55 -0
  148. package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchCar.js +57 -0
  149. package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchOnboardingSession.js +75 -0
  150. package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchOrderWithComplexTypes.js +57 -0
  151. package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchProductWithIntersection.js +58 -0
  152. package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchUserWithUnion.js +58 -0
  153. package/spec/mock-project/dist/spec/mock-project/src/handlers/PostCar.js +54 -0
  154. package/spec/mock-project/dist/spec/mock-project/src/handlers/PostLogin.js +55 -0
  155. package/spec/mock-project/dist/spec/mock-project/src/handlers/PostLogout.js +54 -0
  156. package/spec/mock-project/dist/spec/mock-project/src/handlers/PutCar.js +54 -0
  157. package/spec/mock-project/dist/spec/mock-project/src/index.js +83 -0
  158. package/spec/mock-project/dist/spec/mock-project/src/repos/CarRepo.js +26 -0
  159. package/spec/mock-project/dist/spec/mock-project/src/schemas/Car.js +2 -0
  160. package/spec/mock-project/dist/spec/mock-project/src/schemas/DefaultExportSchema.js +2 -0
  161. package/spec/mock-project/dist/spec/mock-project/src/schemas/FileWithTwoSchemas.js +2 -0
  162. package/spec/mock-project/dist/src/FlinkApp.js +1000 -0
  163. package/spec/mock-project/dist/src/FlinkContext.js +2 -0
  164. package/spec/mock-project/dist/src/FlinkErrors.js +143 -0
  165. package/spec/mock-project/dist/src/FlinkHttpHandler.js +47 -0
  166. package/spec/mock-project/dist/src/FlinkJob.js +2 -0
  167. package/spec/mock-project/dist/src/FlinkLog.js +119 -0
  168. package/spec/mock-project/dist/src/FlinkLogFactory.js +617 -0
  169. package/spec/mock-project/dist/src/FlinkPlugin.js +2 -0
  170. package/spec/mock-project/dist/src/FlinkRepo.js +224 -0
  171. package/spec/mock-project/dist/src/FlinkRequestContext.js +74 -0
  172. package/spec/mock-project/dist/src/FlinkResponse.js +2 -0
  173. package/spec/mock-project/dist/src/ai/AgentExecutor.js +279 -0
  174. package/spec/mock-project/dist/src/ai/AgentRunner.js +632 -0
  175. package/spec/mock-project/dist/src/ai/ConversationAgent.js +402 -0
  176. package/spec/mock-project/dist/src/ai/ConversationFlinkAgent.js +422 -0
  177. package/spec/mock-project/dist/src/ai/FlinkAgent.js +699 -0
  178. package/spec/mock-project/dist/src/ai/FlinkTool.js +2 -0
  179. package/spec/mock-project/dist/src/ai/InMemoryConversationAgent.js +209 -0
  180. package/spec/mock-project/dist/src/ai/LLMAdapter.js +2 -0
  181. package/spec/mock-project/dist/src/ai/SubAgentExecutor.js +223 -0
  182. package/spec/mock-project/dist/src/ai/ToolExecutor.js +412 -0
  183. package/spec/mock-project/dist/src/ai/agentInstructions.js +246 -0
  184. package/spec/mock-project/dist/src/auth/FlinkAuthPlugin.js +2 -0
  185. package/spec/mock-project/dist/src/auth/FlinkAuthUser.js +2 -0
  186. package/spec/mock-project/dist/src/handlers/GetCar.js +26 -52
  187. package/spec/mock-project/dist/src/handlers/GetCar.js.map +1 -0
  188. package/spec/mock-project/dist/src/handlers/GetCar2.js +32 -54
  189. package/spec/mock-project/dist/src/handlers/GetCar2.js.map +1 -0
  190. package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema.js +26 -48
  191. package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema.js.map +1 -0
  192. package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema2.js +28 -48
  193. package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema2.js.map +1 -0
  194. package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema3.js +29 -48
  195. package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema3.js.map +1 -0
  196. package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema.js +26 -50
  197. package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema.js.map +1 -0
  198. package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema2.js +28 -50
  199. package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema2.js.map +1 -0
  200. package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile.js +27 -53
  201. package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile.js.map +1 -0
  202. package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile2.js +29 -53
  203. package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile2.js.map +1 -0
  204. package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler.js +16 -49
  205. package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler.js.map +1 -0
  206. package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler2.js +25 -50
  207. package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler2.js.map +1 -0
  208. package/spec/mock-project/dist/src/handlers/PatchCar.js +27 -53
  209. package/spec/mock-project/dist/src/handlers/PatchCar.js.map +1 -0
  210. package/spec/mock-project/dist/src/handlers/PatchOnboardingSession.js +44 -70
  211. package/spec/mock-project/dist/src/handlers/PatchOnboardingSession.js.map +1 -0
  212. package/spec/mock-project/dist/src/handlers/PatchOrderWithComplexTypes.js +27 -53
  213. package/spec/mock-project/dist/src/handlers/PatchOrderWithComplexTypes.js.map +1 -0
  214. package/spec/mock-project/dist/src/handlers/PatchProductWithIntersection.js +28 -54
  215. package/spec/mock-project/dist/src/handlers/PatchProductWithIntersection.js.map +1 -0
  216. package/spec/mock-project/dist/src/handlers/PatchUserWithUnion.js +28 -54
  217. package/spec/mock-project/dist/src/handlers/PatchUserWithUnion.js.map +1 -0
  218. package/spec/mock-project/dist/src/handlers/PostCar.js +24 -50
  219. package/spec/mock-project/dist/src/handlers/PostCar.js.map +1 -0
  220. package/spec/mock-project/dist/src/handlers/PostLogin.js +25 -51
  221. package/spec/mock-project/dist/src/handlers/PostLogin.js.map +1 -0
  222. package/spec/mock-project/dist/src/handlers/PostLogout.js +24 -50
  223. package/spec/mock-project/dist/src/handlers/PostLogout.js.map +1 -0
  224. package/spec/mock-project/dist/src/handlers/PutCar.js +24 -50
  225. package/spec/mock-project/dist/src/handlers/PutCar.js.map +1 -0
  226. package/spec/mock-project/dist/src/handlers/StreamWriterFactory.js +83 -0
  227. package/spec/mock-project/dist/src/index.js +52 -76
  228. package/spec/mock-project/dist/src/index.js.map +1 -0
  229. package/spec/mock-project/dist/src/mock-data-generator.js +9 -0
  230. package/spec/mock-project/dist/src/repos/CarRepo.js +12 -24
  231. package/spec/mock-project/dist/src/repos/CarRepo.js.map +1 -0
  232. package/spec/mock-project/dist/src/schemas/Car.js +3 -1
  233. package/spec/mock-project/dist/src/schemas/Car.js.map +1 -0
  234. package/spec/mock-project/dist/src/schemas/DefaultExportSchema.js +3 -1
  235. package/spec/mock-project/dist/src/schemas/DefaultExportSchema.js.map +1 -0
  236. package/spec/mock-project/dist/src/schemas/FileWithTwoSchemas.js +3 -1
  237. package/spec/mock-project/dist/src/schemas/FileWithTwoSchemas.js.map +1 -0
  238. package/spec/mock-project/dist/src/utils.js +290 -0
  239. package/spec/mock-project/tsconfig.json +6 -1
  240. package/spec/schema-generation-nested-objects.spec.ts +97 -0
  241. package/spec/testHelpers.ts +49 -0
  242. package/spec/utils.caseConversion.spec.ts +78 -0
  243. package/spec/utils.spec.ts +13 -13
  244. package/src/DependencyTracker.ts +166 -0
  245. package/src/FlinkApp.ts +919 -155
  246. package/src/FlinkContext.ts +43 -0
  247. package/src/FlinkErrors.ts +32 -12
  248. package/src/FlinkHttpHandler.ts +246 -28
  249. package/src/FlinkJob.ts +11 -0
  250. package/src/FlinkLog.ts +119 -12
  251. package/src/FlinkLogFactory.ts +699 -0
  252. package/src/FlinkRepo.ts +10 -3
  253. package/src/FlinkRequestContext.ts +95 -0
  254. package/src/FlinkResponse.ts +6 -0
  255. package/src/FlinkService.ts +49 -0
  256. package/src/LeaderElection.ts +203 -0
  257. package/src/SchemaCache.ts +232 -0
  258. package/src/TypeScriptCompiler.ts +1347 -610
  259. package/src/TypeScriptUtils.ts +5 -0
  260. package/src/ai/AgentRunner.ts +646 -0
  261. package/src/ai/ConversationAgent.ts +413 -0
  262. package/src/ai/FlinkAgent.ts +1069 -0
  263. package/src/ai/FlinkTool.ts +165 -0
  264. package/src/ai/InMemoryConversationAgent.ts +149 -0
  265. package/src/ai/LLMAdapter.ts +126 -0
  266. package/src/ai/ToolExecutor.ts +485 -0
  267. package/src/ai/agentInstructions.ts +245 -0
  268. package/src/ai/index.ts +8 -0
  269. package/src/ai/instructionFileLoader.ts +156 -0
  270. package/src/auth/FlinkAuthPlugin.ts +2 -1
  271. package/src/handlers/StreamWriterFactory.ts +84 -0
  272. package/src/index.ts +14 -0
  273. package/src/loadPluginSchemas.ts +141 -0
  274. package/src/schema-extraction/TypeScriptSourceParser.ts +1058 -0
  275. package/src/schema-extraction/TypeScriptTokenizer.ts +205 -0
  276. package/src/schema-extraction/index.ts +2 -0
  277. package/src/schema-extraction/types.ts +34 -0
  278. package/src/utils/loadFlinkConfig.ts +89 -0
  279. package/src/utils.ts +52 -0
  280. package/tsconfig.json +6 -1
@@ -0,0 +1,358 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ import { agentInstructions } from "../../src/ai/agentInstructions";
4
+ import { FlinkContext } from "../../src/FlinkContext";
5
+ import { AgentExecuteContext } from "../../src/ai/FlinkAgent";
6
+
7
+ describe("agentInstructions", () => {
8
+ let mockCtx: FlinkContext;
9
+ let mockAgentContext: AgentExecuteContext;
10
+
11
+ beforeEach(() => {
12
+ mockCtx = {} as FlinkContext;
13
+ mockAgentContext = {
14
+ agentId: "test-agent",
15
+ conversationId: "conv-123",
16
+ user: {
17
+ id: "user-456",
18
+ name: "Alice",
19
+ tier: "premium",
20
+ },
21
+ };
22
+ });
23
+
24
+ describe("path resolution", () => {
25
+ it("should load file from project root path", async () => {
26
+ const callback = agentInstructions("spec/fixtures/agent-instructions/simple.md");
27
+ const result = await callback(mockCtx, mockAgentContext);
28
+
29
+ expect(result).toContain("Simple Instructions");
30
+ expect(result).toContain("helpful assistant");
31
+ });
32
+
33
+ it("should throw error when file not found", async () => {
34
+ const callback = agentInstructions("spec/fixtures/agent-instructions/nonexistent.md");
35
+
36
+ await expectAsync(callback(mockCtx, mockAgentContext)).toBeRejectedWithError(
37
+ /Agent instructions file not found/
38
+ );
39
+ });
40
+
41
+ it("should load YAML file as plain text", async () => {
42
+ const callback = agentInstructions("spec/fixtures/agent-instructions/yaml-format.yaml");
43
+ const result = await callback(mockCtx, mockAgentContext);
44
+
45
+ expect(result).toContain("role: Multi-agent orchestrator");
46
+ expect(result).toContain("capabilities:");
47
+ expect(result).toContain("delegation_rules:");
48
+ });
49
+ });
50
+
51
+ describe("template rendering", () => {
52
+ it("should render template with static variables", async () => {
53
+ const callback = agentInstructions("spec/fixtures/agent-instructions/template.md", {
54
+ tier: "gold",
55
+ isPremium: true,
56
+ isBusinessHours: true,
57
+ tools: ["search", "create", "update"],
58
+ });
59
+
60
+ const result = await callback(mockCtx, mockAgentContext);
61
+
62
+ expect(result).toContain("Name: Alice");
63
+ expect(result).toContain("Tier: gold");
64
+ expect(result).toContain("⭐ VIP CUSTOMER");
65
+ expect(result).not.toContain("Outside business hours");
66
+ expect(result).toContain("- search");
67
+ expect(result).toContain("- create");
68
+ expect(result).toContain("- update");
69
+ });
70
+
71
+ it("should render template with callback variables", async () => {
72
+ const callback = agentInstructions("spec/fixtures/agent-instructions/template.md", (ctx, agentContext) => {
73
+ const hour = new Date().getHours();
74
+ return {
75
+ tier: agentContext.user?.tier || "standard",
76
+ isPremium: agentContext.user?.tier === "premium",
77
+ isBusinessHours: hour >= 9 && hour < 17,
78
+ tools: ["ticket-tool"],
79
+ };
80
+ });
81
+
82
+ const result = await callback(mockCtx, mockAgentContext);
83
+
84
+ expect(result).toContain("Name: Alice");
85
+ expect(result).toContain("Tier: premium");
86
+ expect(result).toContain("⭐ VIP CUSTOMER"); // isPremium should be true
87
+ expect(result).toContain("- ticket-tool");
88
+ });
89
+
90
+ it("should support async variable callbacks", async () => {
91
+ const callback = agentInstructions(
92
+ "spec/fixtures/agent-instructions/template.md",
93
+ async (ctx, agentContext) => {
94
+ // Simulate async operation
95
+ await new Promise((resolve) => setTimeout(resolve, 10));
96
+
97
+ return {
98
+ tier: "enterprise",
99
+ isPremium: true,
100
+ isBusinessHours: false,
101
+ tools: ["async-tool"],
102
+ };
103
+ }
104
+ );
105
+
106
+ const result = await callback(mockCtx, mockAgentContext);
107
+
108
+ expect(result).toContain("Tier: enterprise");
109
+ expect(result).toContain("⭐ VIP CUSTOMER");
110
+ expect(result).toContain("Outside business hours");
111
+ expect(result).toContain("- async-tool");
112
+ });
113
+
114
+ it("should have access to ctx, agentContext, and user in templates", async () => {
115
+ // Create a test file that uses context helpers
116
+ const testPath = path.join(process.cwd(), "spec/fixtures/agent-instructions/context-test.md");
117
+ fs.writeFileSync(
118
+ testPath,
119
+ `Agent: {{agentContext.agentId}}
120
+ User: {{user.name}}
121
+ Conversation: {{agentContext.conversationId}}`
122
+ );
123
+
124
+ try {
125
+ const callback = agentInstructions("spec/fixtures/agent-instructions/context-test.md");
126
+ const result = await callback(mockCtx, mockAgentContext);
127
+
128
+ expect(result).toContain("Agent: test-agent");
129
+ expect(result).toContain("User: Alice");
130
+ expect(result).toContain("Conversation: conv-123");
131
+ } finally {
132
+ fs.unlinkSync(testPath);
133
+ }
134
+ });
135
+
136
+ it("should handle Handlebars conditionals", async () => {
137
+ const callback = agentInstructions("spec/fixtures/agent-instructions/template.md", {
138
+ tier: "basic",
139
+ isPremium: false,
140
+ isBusinessHours: false,
141
+ tools: [],
142
+ });
143
+
144
+ const result = await callback(mockCtx, mockAgentContext);
145
+
146
+ expect(result).not.toContain("⭐ VIP CUSTOMER"); // isPremium is false
147
+ expect(result).toContain("Outside business hours"); // isBusinessHours is false
148
+ });
149
+
150
+ it("should pass through content inside {{{{raw}}}} blocks literally", async () => {
151
+ const testPath = path.join(process.cwd(), "spec/fixtures/agent-instructions/raw-block-test.md");
152
+ fs.writeFileSync(
153
+ testPath,
154
+ `Before raw.\n{{{{raw}}}}\nThis has {{literal}} braces and {{#if things}} blocks.\n{{{{/raw}}}}\nAfter raw.`
155
+ );
156
+
157
+ try {
158
+ const callback = agentInstructions("spec/fixtures/agent-instructions/raw-block-test.md");
159
+ const result = await callback(mockCtx, mockAgentContext);
160
+
161
+ expect(result).toContain("Before raw.");
162
+ expect(result).toContain("After raw.");
163
+ expect(result).toContain("{{literal}}");
164
+ expect(result).toContain("{{#if things}}");
165
+ } finally {
166
+ fs.unlinkSync(testPath);
167
+ }
168
+ });
169
+
170
+ it("should throw clear error on template rendering failure", async () => {
171
+ // Create a test file with invalid Handlebars syntax
172
+ const testPath = path.join(process.cwd(), "spec/fixtures/agent-instructions/invalid-template.md");
173
+ fs.writeFileSync(testPath, "Invalid syntax: {{#if unclosed}");
174
+
175
+ try {
176
+ const callback = agentInstructions("spec/fixtures/agent-instructions/invalid-template.md");
177
+
178
+ await expectAsync(callback(mockCtx, mockAgentContext)).toBeRejectedWithError(/Failed to render template/);
179
+ } finally {
180
+ fs.unlinkSync(testPath);
181
+ }
182
+ });
183
+ });
184
+
185
+ describe("file caching", () => {
186
+ it("should cache file and reuse on subsequent loads", async () => {
187
+ const testPath = path.join(process.cwd(), "spec/fixtures/agent-instructions/cache-test.md");
188
+ fs.writeFileSync(testPath, "Original content");
189
+
190
+ try {
191
+ const callback = agentInstructions("spec/fixtures/agent-instructions/cache-test.md");
192
+
193
+ // First load
194
+ const result1 = await callback(mockCtx, mockAgentContext);
195
+ expect(result1).toContain("Original content");
196
+
197
+ // Modify file without changing mtime enough (same second)
198
+ // This should still use cache
199
+ const result2 = await callback(mockCtx, mockAgentContext);
200
+ expect(result2).toContain("Original content");
201
+ expect(result2).toBe(result1); // Should be identical
202
+ } finally {
203
+ fs.unlinkSync(testPath);
204
+ }
205
+ });
206
+
207
+ it("should reload file when mtime changes", async () => {
208
+ const testPath = path.join(process.cwd(), "spec/fixtures/agent-instructions/mtime-test.md");
209
+ fs.writeFileSync(testPath, "Version 1");
210
+
211
+ try {
212
+ const callback = agentInstructions("spec/fixtures/agent-instructions/mtime-test.md");
213
+
214
+ // First load
215
+ const result1 = await callback(mockCtx, mockAgentContext);
216
+ expect(result1).toContain("Version 1");
217
+
218
+ // Wait to ensure different mtime
219
+ await new Promise((resolve) => setTimeout(resolve, 100));
220
+
221
+ // Modify file
222
+ fs.writeFileSync(testPath, "Version 2");
223
+
224
+ // Second load should detect change
225
+ const result2 = await callback(mockCtx, mockAgentContext);
226
+ expect(result2).toContain("Version 2");
227
+ expect(result2).not.toContain("Version 1");
228
+ } finally {
229
+ fs.unlinkSync(testPath);
230
+ }
231
+ });
232
+ });
233
+
234
+ describe("integration with FlinkAgent", () => {
235
+ it("should return InstructionsCallback compatible with FlinkAgent", async () => {
236
+ const callback = agentInstructions("spec/fixtures/agent-instructions/simple.md");
237
+
238
+ // Verify it's a function
239
+ expect(typeof callback).toBe("function");
240
+
241
+ // Verify it returns a string or promise
242
+ const result = callback(mockCtx, mockAgentContext);
243
+ expect(result instanceof Promise).toBe(true);
244
+
245
+ const resolved = await result;
246
+ expect(typeof resolved).toBe("string");
247
+ });
248
+
249
+ it("should work as FlinkAgent instructions property", async () => {
250
+ const TestAgent = require("../fixtures/agent-instructions/TestAgent").default;
251
+ const agent = new TestAgent();
252
+
253
+ // Verify instructions is a callback
254
+ expect(typeof agent.instructions).toBe("function");
255
+
256
+ // Execute the callback
257
+ const result = await agent.instructions(mockCtx, mockAgentContext);
258
+
259
+ // Verify template rendered correctly
260
+ expect(result).toContain("Name: Alice");
261
+ expect(result).toContain("Tier: premium");
262
+ expect(result).toContain("⭐ VIP CUSTOMER");
263
+ expect(result).toContain("- test-tool-1");
264
+ expect(result).toContain("- test-tool-2");
265
+ });
266
+
267
+ it("should work with no variables provided", async () => {
268
+ const callback = agentInstructions("spec/fixtures/agent-instructions/simple.md");
269
+ const result = await callback(mockCtx, mockAgentContext);
270
+
271
+ expect(result).toContain("Simple Instructions");
272
+ expect(typeof result).toBe("string");
273
+ });
274
+
275
+ it("should handle missing user gracefully", async () => {
276
+ const contextWithoutUser: AgentExecuteContext = {
277
+ agentId: "test-agent",
278
+ conversationId: "conv-123",
279
+ user: undefined,
280
+ };
281
+
282
+ const callback = agentInstructions("spec/fixtures/agent-instructions/template.md", {
283
+ tier: "none",
284
+ isPremium: false,
285
+ isBusinessHours: true,
286
+ tools: [],
287
+ });
288
+
289
+ const result = await callback(mockCtx, contextWithoutUser);
290
+
291
+ // Handlebars should handle undefined user.name gracefully
292
+ expect(result).toContain("Name:");
293
+ expect(result).toContain("Tier: none");
294
+ });
295
+ });
296
+
297
+ describe("agent-relative paths", () => {
298
+ it("should support agent-relative paths with ./", async () => {
299
+ // Create a temporary agent file and instruction file in the same directory
300
+ const agentDir = path.join(process.cwd(), "spec/fixtures/agent-instructions/test-agent");
301
+ const instructionsPath = path.join(agentDir, "instructions.md");
302
+
303
+ fs.mkdirSync(agentDir, { recursive: true });
304
+ fs.writeFileSync(instructionsPath, "Agent-relative instructions");
305
+
306
+ try {
307
+ // Note: In real usage, ./ would resolve based on the agent's file location
308
+ // For testing, we use the project root path since we can't easily simulate the stack trace
309
+ const callback = agentInstructions("spec/fixtures/agent-instructions/test-agent/instructions.md");
310
+ const result = await callback(mockCtx, mockAgentContext);
311
+
312
+ expect(result).toContain("Agent-relative instructions");
313
+ } finally {
314
+ fs.unlinkSync(instructionsPath);
315
+ fs.rmdirSync(agentDir);
316
+ }
317
+ });
318
+ });
319
+
320
+ describe("error handling", () => {
321
+ it("should provide clear error with both absolute and original path on file not found", async () => {
322
+ const callback = agentInstructions("does/not/exist.md");
323
+
324
+ try {
325
+ await callback(mockCtx, mockAgentContext);
326
+ fail("Should have thrown error");
327
+ } catch (err: any) {
328
+ expect(err.message).toContain("Agent instructions file not found");
329
+ expect(err.message).toContain("does/not/exist.md"); // Original path
330
+ expect(err.message).toMatch(/\//); // Should contain absolute path
331
+ }
332
+ });
333
+
334
+ it("should provide clear error on file read failure", async () => {
335
+ const testPath = path.join(process.cwd(), "spec/fixtures/agent-instructions/readonly-test.md");
336
+ fs.writeFileSync(testPath, "Content");
337
+
338
+ try {
339
+ // Make file unreadable (skip on Windows where chmod may not work as expected)
340
+ if (process.platform !== "win32") {
341
+ fs.chmodSync(testPath, 0o000);
342
+
343
+ const callback = agentInstructions("spec/fixtures/agent-instructions/readonly-test.md");
344
+
345
+ await expectAsync(callback(mockCtx, mockAgentContext)).toBeRejectedWithError(
346
+ /Failed to load agent instructions file/
347
+ );
348
+ }
349
+ } finally {
350
+ // Restore permissions and clean up
351
+ if (process.platform !== "win32") {
352
+ fs.chmodSync(testPath, 0o644);
353
+ }
354
+ fs.unlinkSync(testPath);
355
+ }
356
+ });
357
+ });
358
+ });
@@ -0,0 +1,24 @@
1
+ import { FlinkAgent, agentInstructions } from "../../../src/ai";
2
+ import { FlinkContext } from "../../../src/FlinkContext";
3
+
4
+ export default class TestAgent extends FlinkAgent<FlinkContext> {
5
+ id = "test-agent";
6
+ description = "Test agent for agentInstructions integration";
7
+
8
+ // Load instructions from file using project-root path
9
+ // Note: For relative paths (./) to work, they must be called from the agent file itself
10
+ // Since this is loaded via require() from test, we use project-root path
11
+ instructions(ctx: FlinkContext, agentContext: any) {
12
+ return agentInstructions(
13
+ "spec/fixtures/agent-instructions/template.md",
14
+ (ctx, agentContext) => ({
15
+ tier: agentContext.user?.tier || "basic",
16
+ isPremium: agentContext.user?.tier === "premium",
17
+ isBusinessHours: true,
18
+ tools: ["test-tool-1", "test-tool-2"],
19
+ })
20
+ )(ctx, agentContext);
21
+ }
22
+
23
+ tools = [];
24
+ }
@@ -0,0 +1,3 @@
1
+ # Simple Instructions
2
+
3
+ You are a helpful assistant with basic capabilities.
@@ -0,0 +1,18 @@
1
+ # Support Agent Instructions
2
+
3
+ Customer Profile:
4
+ - Name: {{user.name}}
5
+ - Tier: {{tier}}
6
+
7
+ {{#if isPremium}}
8
+ ⭐ VIP CUSTOMER - Provide white-glove service!
9
+ {{/if}}
10
+
11
+ {{#unless isBusinessHours}}
12
+ NOTE: Outside business hours.
13
+ {{/unless}}
14
+
15
+ Available Tools:
16
+ {{#each tools}}
17
+ - {{this}}
18
+ {{/each}}
@@ -0,0 +1,9 @@
1
+ role: Multi-agent orchestrator
2
+ capabilities:
3
+ - Analyzing user requests
4
+ - Selecting specialist agents
5
+ - Coordinating workflows
6
+
7
+ delegation_rules:
8
+ pricing: Use CarPricingAgent
9
+ recommendations: Use CarRecommendationAgent
@@ -0,0 +1 @@
1
+ {"version":"5.6.2"}
@@ -0,0 +1,56 @@
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.__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 = [];
@@ -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 = 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.__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 = [];
@@ -0,0 +1,52 @@
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.__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 = [];
@@ -0,0 +1,52 @@
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.__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 = [];