agentlang 0.0.2

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 (240) hide show
  1. package/LICENSE +83 -0
  2. package/README.md +120 -0
  3. package/bin/cli.js +4 -0
  4. package/out/api/http.d.ts +3 -0
  5. package/out/api/http.d.ts.map +1 -0
  6. package/out/api/http.js +290 -0
  7. package/out/api/http.js.map +1 -0
  8. package/out/cli/cli-util.d.ts +7 -0
  9. package/out/cli/cli-util.d.ts.map +1 -0
  10. package/out/cli/cli-util.js +9 -0
  11. package/out/cli/cli-util.js.map +1 -0
  12. package/out/cli/docs.d.ts +2 -0
  13. package/out/cli/docs.d.ts.map +1 -0
  14. package/out/cli/docs.js +236 -0
  15. package/out/cli/docs.js.map +1 -0
  16. package/out/cli/main.d.ts +288 -0
  17. package/out/cli/main.d.ts.map +1 -0
  18. package/out/cli/main.js +119 -0
  19. package/out/cli/main.js.map +1 -0
  20. package/out/cli/openapi-docs.yml +695 -0
  21. package/out/extension/main.cjs +18093 -0
  22. package/out/extension/main.cjs.map +7 -0
  23. package/out/extension/main.d.ts +4 -0
  24. package/out/extension/main.d.ts.map +1 -0
  25. package/out/extension/main.js +42 -0
  26. package/out/extension/main.js.map +1 -0
  27. package/out/language/agentlang-module.d.ts +42 -0
  28. package/out/language/agentlang-module.d.ts.map +1 -0
  29. package/out/language/agentlang-module.js +42 -0
  30. package/out/language/agentlang-module.js.map +1 -0
  31. package/out/language/agentlang-validator.d.ts +15 -0
  32. package/out/language/agentlang-validator.d.ts.map +1 -0
  33. package/out/language/agentlang-validator.js +50 -0
  34. package/out/language/agentlang-validator.js.map +1 -0
  35. package/out/language/generated/ast.d.ts +491 -0
  36. package/out/language/generated/ast.d.ts.map +1 -0
  37. package/out/language/generated/ast.js +934 -0
  38. package/out/language/generated/ast.js.map +1 -0
  39. package/out/language/generated/grammar.d.ts +7 -0
  40. package/out/language/generated/grammar.d.ts.map +1 -0
  41. package/out/language/generated/grammar.js +4475 -0
  42. package/out/language/generated/grammar.js.map +1 -0
  43. package/out/language/generated/module.d.ts +14 -0
  44. package/out/language/generated/module.d.ts.map +1 -0
  45. package/out/language/generated/module.js +21 -0
  46. package/out/language/generated/module.js.map +1 -0
  47. package/out/language/main-browser.d.ts +2 -0
  48. package/out/language/main-browser.d.ts.map +1 -0
  49. package/out/language/main-browser.js +10 -0
  50. package/out/language/main-browser.js.map +1 -0
  51. package/out/language/main.cjs +36229 -0
  52. package/out/language/main.cjs.map +7 -0
  53. package/out/language/main.d.ts +2 -0
  54. package/out/language/main.d.ts.map +1 -0
  55. package/out/language/main.js +11 -0
  56. package/out/language/main.js.map +1 -0
  57. package/out/language/parser.d.ts +9 -0
  58. package/out/language/parser.d.ts.map +1 -0
  59. package/out/language/parser.js +273 -0
  60. package/out/language/parser.js.map +1 -0
  61. package/out/language/syntax.d.ts +155 -0
  62. package/out/language/syntax.d.ts.map +1 -0
  63. package/out/language/syntax.js +527 -0
  64. package/out/language/syntax.js.map +1 -0
  65. package/out/runtime/agents/common.d.ts +2 -0
  66. package/out/runtime/agents/common.d.ts.map +1 -0
  67. package/out/runtime/agents/common.js +178 -0
  68. package/out/runtime/agents/common.js.map +1 -0
  69. package/out/runtime/agents/impl/openai.d.ts +8 -0
  70. package/out/runtime/agents/impl/openai.d.ts.map +1 -0
  71. package/out/runtime/agents/impl/openai.js +15 -0
  72. package/out/runtime/agents/impl/openai.js.map +1 -0
  73. package/out/runtime/agents/provider.d.ts +21 -0
  74. package/out/runtime/agents/provider.d.ts.map +1 -0
  75. package/out/runtime/agents/provider.js +32 -0
  76. package/out/runtime/agents/provider.js.map +1 -0
  77. package/out/runtime/agents/registry.d.ts +2 -0
  78. package/out/runtime/agents/registry.d.ts.map +1 -0
  79. package/out/runtime/agents/registry.js +10 -0
  80. package/out/runtime/agents/registry.js.map +1 -0
  81. package/out/runtime/auth/cognito.d.ts +16 -0
  82. package/out/runtime/auth/cognito.d.ts.map +1 -0
  83. package/out/runtime/auth/cognito.js +186 -0
  84. package/out/runtime/auth/cognito.js.map +1 -0
  85. package/out/runtime/auth/defs.d.ts +11 -0
  86. package/out/runtime/auth/defs.d.ts.map +1 -0
  87. package/out/runtime/auth/defs.js +24 -0
  88. package/out/runtime/auth/defs.js.map +1 -0
  89. package/out/runtime/auth/interface.d.ts +22 -0
  90. package/out/runtime/auth/interface.d.ts.map +1 -0
  91. package/out/runtime/auth/interface.js +2 -0
  92. package/out/runtime/auth/interface.js.map +1 -0
  93. package/out/runtime/defs.js +24 -0
  94. package/out/runtime/defs.js.map +1 -0
  95. package/out/runtime/interpreter.d.ts +69 -0
  96. package/out/runtime/interpreter.d.ts.map +1 -0
  97. package/out/runtime/interpreter.js +1163 -0
  98. package/out/runtime/interpreter.js.map +1 -0
  99. package/out/runtime/loader.d.ts +25 -0
  100. package/out/runtime/loader.d.ts.map +1 -0
  101. package/out/runtime/loader.js +346 -0
  102. package/out/runtime/loader.js.map +1 -0
  103. package/out/runtime/logger.d.ts +2 -0
  104. package/out/runtime/logger.d.ts.map +1 -0
  105. package/out/runtime/logger.js +44 -0
  106. package/out/runtime/logger.js.map +1 -0
  107. package/out/runtime/module.d.ts +273 -0
  108. package/out/runtime/module.d.ts.map +1 -0
  109. package/out/runtime/module.js +1786 -0
  110. package/out/runtime/module.js.map +1 -0
  111. package/out/runtime/modules/ai.d.ts +26 -0
  112. package/out/runtime/modules/ai.d.ts.map +1 -0
  113. package/out/runtime/modules/ai.js +211 -0
  114. package/out/runtime/modules/ai.js.map +1 -0
  115. package/out/runtime/modules/auth.d.ts +39 -0
  116. package/out/runtime/modules/auth.d.ts.map +1 -0
  117. package/out/runtime/modules/auth.js +359 -0
  118. package/out/runtime/modules/auth.js.map +1 -0
  119. package/out/runtime/modules/core.d.ts +2 -0
  120. package/out/runtime/modules/core.d.ts.map +1 -0
  121. package/out/runtime/modules/core.js +67 -0
  122. package/out/runtime/modules/core.js.map +1 -0
  123. package/out/runtime/relgraph.d.ts +21 -0
  124. package/out/runtime/relgraph.d.ts.map +1 -0
  125. package/out/runtime/relgraph.js +156 -0
  126. package/out/runtime/relgraph.js.map +1 -0
  127. package/out/runtime/resolvers/interface.d.ts +59 -0
  128. package/out/runtime/resolvers/interface.d.ts.map +1 -0
  129. package/out/runtime/resolvers/interface.js +111 -0
  130. package/out/runtime/resolvers/interface.js.map +1 -0
  131. package/out/runtime/resolvers/registry.d.ts +8 -0
  132. package/out/runtime/resolvers/registry.d.ts.map +1 -0
  133. package/out/runtime/resolvers/registry.js +26 -0
  134. package/out/runtime/resolvers/registry.js.map +1 -0
  135. package/out/runtime/resolvers/sqldb/database.d.ts +50 -0
  136. package/out/runtime/resolvers/sqldb/database.d.ts.map +1 -0
  137. package/out/runtime/resolvers/sqldb/database.js +618 -0
  138. package/out/runtime/resolvers/sqldb/database.js.map +1 -0
  139. package/out/runtime/resolvers/sqldb/dbutil.d.ts +18 -0
  140. package/out/runtime/resolvers/sqldb/dbutil.d.ts.map +1 -0
  141. package/out/runtime/resolvers/sqldb/dbutil.js +221 -0
  142. package/out/runtime/resolvers/sqldb/dbutil.js.map +1 -0
  143. package/out/runtime/resolvers/sqldb/impl.d.ts +26 -0
  144. package/out/runtime/resolvers/sqldb/impl.d.ts.map +1 -0
  145. package/out/runtime/resolvers/sqldb/impl.js +300 -0
  146. package/out/runtime/resolvers/sqldb/impl.js.map +1 -0
  147. package/out/runtime/state.js +83 -0
  148. package/out/runtime/state.js.map +1 -0
  149. package/out/runtime/util.d.ts +43 -0
  150. package/out/runtime/util.d.ts.map +1 -0
  151. package/out/runtime/util.js +447 -0
  152. package/out/runtime/util.js.map +1 -0
  153. package/out/setupClassic.d.ts +98 -0
  154. package/out/setupClassic.d.ts.map +1 -0
  155. package/out/setupClassic.js +38 -0
  156. package/out/setupClassic.js.map +1 -0
  157. package/out/setupCommon.d.ts +2 -0
  158. package/out/setupCommon.d.ts.map +1 -0
  159. package/out/setupCommon.js +33 -0
  160. package/out/setupCommon.js.map +1 -0
  161. package/out/setupExtended.d.ts +40 -0
  162. package/out/setupExtended.d.ts.map +1 -0
  163. package/out/setupExtended.js +67 -0
  164. package/out/setupExtended.js.map +1 -0
  165. package/out/syntaxes/agentlang.monarch.d.ts +77 -0
  166. package/out/syntaxes/agentlang.monarch.d.ts.map +1 -0
  167. package/out/syntaxes/agentlang.monarch.js +31 -0
  168. package/out/syntaxes/agentlang.monarch.js.map +1 -0
  169. package/out/utils/fs/index.d.ts +14 -0
  170. package/out/utils/fs/index.d.ts.map +1 -0
  171. package/out/utils/fs/index.js +26 -0
  172. package/out/utils/fs/index.js.map +1 -0
  173. package/out/utils/fs/interfaces.d.ts +105 -0
  174. package/out/utils/fs/interfaces.d.ts.map +1 -0
  175. package/out/utils/fs/interfaces.js +5 -0
  176. package/out/utils/fs/interfaces.js.map +1 -0
  177. package/out/utils/fs/lightning-fs.d.ts +116 -0
  178. package/out/utils/fs/lightning-fs.d.ts.map +1 -0
  179. package/out/utils/fs/lightning-fs.js +243 -0
  180. package/out/utils/fs/lightning-fs.js.map +1 -0
  181. package/out/utils/fs/node-fs.d.ts +93 -0
  182. package/out/utils/fs/node-fs.d.ts.map +1 -0
  183. package/out/utils/fs/node-fs.js +169 -0
  184. package/out/utils/fs/node-fs.js.map +1 -0
  185. package/out/utils/fs-utils.d.ts +153 -0
  186. package/out/utils/fs-utils.d.ts.map +1 -0
  187. package/out/utils/fs-utils.js +271 -0
  188. package/out/utils/fs-utils.js.map +1 -0
  189. package/out/utils/runtime.d.ts +36 -0
  190. package/out/utils/runtime.d.ts.map +1 -0
  191. package/out/utils/runtime.js +39 -0
  192. package/out/utils/runtime.js.map +1 -0
  193. package/package.json +155 -0
  194. package/src/api/http.ts +361 -0
  195. package/src/cli/cli-util.ts +18 -0
  196. package/src/cli/main.ts +146 -0
  197. package/src/extension/main.ts +51 -0
  198. package/src/language/agentlang-module.ts +75 -0
  199. package/src/language/agentlang-validator.ts +60 -0
  200. package/src/language/agentlang.langium +178 -0
  201. package/src/language/generated/ast.ts +1698 -0
  202. package/src/language/generated/grammar.ts +4477 -0
  203. package/src/language/generated/module.ts +25 -0
  204. package/src/language/main-browser.ts +19 -0
  205. package/src/language/main.ts +13 -0
  206. package/src/language/parser.ts +329 -0
  207. package/src/language/syntax.ts +646 -0
  208. package/src/runtime/agents/common.ts +177 -0
  209. package/src/runtime/agents/impl/openai.ts +19 -0
  210. package/src/runtime/agents/provider.ts +58 -0
  211. package/src/runtime/agents/registry.ts +9 -0
  212. package/src/runtime/auth/cognito.ts +225 -0
  213. package/src/runtime/auth/defs.ts +33 -0
  214. package/src/runtime/auth/interface.ts +31 -0
  215. package/src/runtime/defs.ts +33 -0
  216. package/src/runtime/interpreter.ts +1352 -0
  217. package/src/runtime/loader.ts +450 -0
  218. package/src/runtime/logger.ts +51 -0
  219. package/src/runtime/module.ts +2188 -0
  220. package/src/runtime/modules/ai.ts +257 -0
  221. package/src/runtime/modules/auth.ts +489 -0
  222. package/src/runtime/modules/core.ts +95 -0
  223. package/src/runtime/relgraph.ts +195 -0
  224. package/src/runtime/resolvers/interface.ts +160 -0
  225. package/src/runtime/resolvers/registry.ts +30 -0
  226. package/src/runtime/resolvers/sqldb/database.ts +823 -0
  227. package/src/runtime/resolvers/sqldb/dbutil.ts +257 -0
  228. package/src/runtime/resolvers/sqldb/impl.ts +471 -0
  229. package/src/runtime/state.ts +87 -0
  230. package/src/runtime/util.ts +513 -0
  231. package/src/setupClassic.ts +43 -0
  232. package/src/setupCommon.ts +33 -0
  233. package/src/setupExtended.ts +79 -0
  234. package/src/syntaxes/agentlang.monarch.ts +31 -0
  235. package/src/utils/fs/index.ts +28 -0
  236. package/src/utils/fs/interfaces.ts +118 -0
  237. package/src/utils/fs/lightning-fs.ts +284 -0
  238. package/src/utils/fs/node-fs.ts +185 -0
  239. package/src/utils/fs-utils.ts +304 -0
  240. package/src/utils/runtime.ts +43 -0
package/LICENSE ADDED
@@ -0,0 +1,83 @@
1
+ # License
2
+
3
+ Portions of this software are licensed as follows:
4
+
5
+ - Content of branches other than the main branch (i.e. "main") are not licensed.
6
+ - All third party components incorporated into the AgentLang Software are licensed under the original license
7
+ provided by the owner of the applicable component.
8
+ - Content outside of the above mentioned files or restrictions is available under the "Sustainable Use
9
+ License" as defined below.
10
+
11
+ ## Sustainable Use License
12
+
13
+ Version 1.0
14
+
15
+ ### Acceptance
16
+
17
+ By using the software, you agree to all of the terms and conditions below.
18
+
19
+ ### Copyright License
20
+
21
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
22
+ to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
23
+ to the limitations below.
24
+
25
+ ### Limitations
26
+
27
+ You may use or modify the software only for your own internal business purposes or for non-commercial or
28
+ personal use. You may distribute the software or provide it to others only if you do so free of charge for
29
+ non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
30
+ the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
31
+
32
+ ### Patents
33
+
34
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
35
+ license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
36
+ subject to the limitations and conditions in this license. This license does not cover any patent claims that
37
+ you cause to be infringed by modifications or additions to the software. If you or your company make any
38
+ written claim that the software infringes or contributes to infringement of any patent, your patent license
39
+ for the software granted under these terms ends immediately. If your company makes such a claim, your patent
40
+ license ends immediately for work on behalf of your company.
41
+
42
+ ### Notices
43
+
44
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
45
+ terms. If you modify the software, you must include in any modified copies of the software a prominent notice
46
+ stating that you have modified the software.
47
+
48
+ ### No Other Rights
49
+
50
+ These terms do not imply any licenses other than those expressly granted in these terms.
51
+
52
+ ### Termination
53
+
54
+ If you use the software in violation of these terms, such use is not licensed, and your license will
55
+ automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
56
+ violation of this license no later than 30 days after you receive that notice, your license will be reinstated
57
+ retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
58
+ terms will cause your license to terminate automatically and permanently.
59
+
60
+ ### No Liability
61
+
62
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
63
+ not be liable to you for any damages arising out of these terms or the use or nature of the software, under
64
+ any kind of legal claim.
65
+
66
+ ### Definitions
67
+
68
+ The “licensor” is the entity offering these terms.
69
+
70
+ The “software” is the software the licensor makes available under these terms, including any portion of it.
71
+
72
+ “You” refers to the individual or entity agreeing to these terms.
73
+
74
+ “Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
75
+ all organizations that have control over, are under the control of, or are under common control with that
76
+ organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
77
+ management and policies by vote, contract, or otherwise. Control can be direct or indirect.
78
+
79
+ “Your license” is the license granted to you for the software under these terms.
80
+
81
+ “Use” means anything you do with the software requiring your license.
82
+
83
+ “Trademark” means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ <div align="center">
2
+
3
+ # AgentLang Programming Language
4
+
5
+ AgentLang is the **easiest way** to build AI Agents, Chatbots and Apps - build **teams of AI agents** that collaborate (with other AI agents and humans) to handle complex, time-consuming, monotonous tasks. AgentLang is a data-oriented, declarative abstraction for building agents and apps, similar to how Terraform is a declarative abstraction for infrastructure-as-code.
6
+
7
+ [![AgentLang CI](https://github.com/agentlang-ai/agentlang/actions/workflows/ci.yml/badge.svg)](https://github.com/agentlang-ai/agentlang/actions/workflows/ci.yml)
8
+ [![Lint and Format Check](https://github.com/agentlang-ai/agentlang/actions/workflows/lint.yml/badge.svg)](https://github.com/agentlang-ai/agentlang/actions/workflows/lint.yml)
9
+
10
+ ### **Open | Enterprise-grade | Production-ready**
11
+
12
+ The AgentLang language specification, its compiler and runtime are open source. AgentLang programs can run anywhere - **avoiding the vendor lock-in** of other AI agent/programming platforms.
13
+
14
+ AgentLang runtime has native integration with databases, vector databases, auth stores, etc. AgentLang programs run on the JVM and can make use of any of the thousands of existing Node and other JavaScript libraries out there.
15
+
16
+ AgentLang comes with all the modern tooling, dependency management and REPL needed to build production-grade agents and apps.
17
+
18
+ </div>
19
+
20
+ ## First-class AI Agents
21
+
22
+ Agents are a built-in language construct - developers can choose from one of the built-in agent-types, or easily add their own agent-types.
23
+
24
+ ## Runtime Support
25
+
26
+ AgentLang supports both Node.js and Deno runtimes for development and execution.
27
+
28
+ ### Prerequisites
29
+
30
+ - Node.js 20+ (CI runs on 20.x, local development often uses 24.x)
31
+ - Note: Some functions may behave differently between versions (e.g., array methods on iterators)
32
+ - [Deno](https://deno.land/) 1.35.0 or later (optional, for Deno-based workflows)
33
+
34
+ ## Common Development Commands
35
+
36
+ AgentLang provides npm scripts for common tasks. Here are the most frequently used commands:
37
+
38
+ ```shell
39
+ # Install dependencies
40
+ npm install
41
+
42
+ # Build the project
43
+ npm run build
44
+
45
+ # Generate Agentlang parser
46
+ npm run langium:generate
47
+
48
+ # Run tests
49
+ npm test
50
+
51
+ # Interactive REPL with specific app.json
52
+ npm run repl -- --app example/erp/app.json
53
+ # To exit REPL: use close() or Ctrl+C or Ctrl+D, then press Ctrl+C again to fully exit
54
+
55
+ # Run TypeScript files with specific app.json
56
+ npm run run -- --app example/blog/app.json path/to/file.ts
57
+
58
+ # Development server
59
+ npm run dev
60
+ ```
61
+
62
+ ## Using Deno
63
+
64
+ When working with Deno, use these npm scripts:
65
+
66
+ ```shell
67
+ # Build with Deno
68
+ npm run build:deno
69
+
70
+ # Watch mode with Deno
71
+ npm run watch:deno
72
+
73
+ # Run tests with Deno
74
+ npm run test:deno
75
+ ```
76
+
77
+ ## Build instructions
78
+
79
+ Make sure you have a working Node environment with version 20 or higher (CI runs on 20.x, while local development often uses 24.x).
80
+
81
+ Install dependencies:
82
+
83
+ ```shell
84
+ npm install
85
+ ```
86
+
87
+ Generate the Agentlang parser and build the project:
88
+
89
+ ```shell
90
+ npm run langium:generate
91
+ npm run build
92
+ npm test
93
+ ```
94
+
95
+ Test with sample app.json files:
96
+
97
+ ```shell
98
+ # Parse and validate an AgentLang file
99
+ node ./bin/cli.js parseAndValidate example/blog/blog.al
100
+
101
+ # Run a specific app
102
+ node ./bin/cli.js run example/blog
103
+ ```
104
+
105
+ ## Linting and Code Style
106
+
107
+ AgentLang uses ESLint and Prettier to maintain code quality. Run the following commands to check and fix linting issues:
108
+
109
+ ```shell
110
+ # Run ESLint
111
+ npm run lint
112
+
113
+ # Fix ESLint issues automatically
114
+ npm run lint -- --fix
115
+
116
+ # Format code with Prettier
117
+ npm run format
118
+ ```
119
+
120
+ The project is currently in the process of adopting stricter TypeScript standards. The ESLint configuration currently allows the use of `any` types and certain deprecated type constructors, but these will be gradually phased out in future releases.
package/bin/cli.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ import main from '../out/cli/main.js';
4
+ main();
@@ -0,0 +1,3 @@
1
+ import { ApplicationSpec } from '../runtime/loader.js';
2
+ export declare function startServer(appSpec: ApplicationSpec, port: number): void;
3
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/api/http.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD,wBAAgB,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,QA2BjE"}
@@ -0,0 +1,290 @@
1
+ import chalk from 'chalk';
2
+ import express from 'express';
3
+ import { getAllChildRelationships, getAllEntityNames, getAllEventNames, Instance, makeInstance, objectAsInstanceAttributes, } from '../runtime/module.js';
4
+ import { evaluate, parseAndEvaluateStatement } from '../runtime/interpreter.js';
5
+ import { logger } from '../runtime/logger.js';
6
+ import { requireAuth, verifySession } from '../runtime/modules/auth.js';
7
+ import { BypassSession, isNoSession, NoSession } from '../runtime/auth/defs.js';
8
+ import { escapeFqName, forceAsEscapedName, forceAsFqName, isString, makeFqName, restoreFqName, splitFqName, walkDownInstancePath, } from '../runtime/util.js';
9
+ import { BadRequestError, PathAttributeNameQuery, UnauthorisedError } from '../runtime/defs.js';
10
+ export function startServer(appSpec, port) {
11
+ const app = express();
12
+ app.use(express.json());
13
+ const appName = appSpec.name;
14
+ const appVersion = appSpec.version;
15
+ app.get('/', (req, res) => {
16
+ res.send(appName);
17
+ });
18
+ getAllEventNames().forEach((eventNames, moduleName) => {
19
+ eventNames.forEach((n) => {
20
+ app.post(`/${moduleName}/${n}`, (req, res) => {
21
+ handleEventPost(moduleName, n, req, res);
22
+ });
23
+ });
24
+ });
25
+ getAllEntityNames().forEach((entityNames, moduleName) => {
26
+ entityNames.forEach((n) => {
27
+ app.get(`/${moduleName}/${n}`, (req, res) => {
28
+ handleEntityGet(moduleName, n, req, res);
29
+ });
30
+ app.get(`/${moduleName}/${n}/*path`, (req, res) => {
31
+ handleEntityGet(moduleName, n, req, res);
32
+ });
33
+ app.post(`/${moduleName}/${n}`, (req, res) => {
34
+ handleEntityPost(moduleName, n, req, res);
35
+ });
36
+ app.post(`/${moduleName}/${n}/*path`, (req, res) => {
37
+ handleEntityPost(moduleName, n, req, res);
38
+ });
39
+ app.put(`/${moduleName}/${n}/*path`, (req, res) => {
40
+ handleEntityPut(moduleName, n, req, res);
41
+ });
42
+ app.delete(`/${moduleName}/${n}/*path`, (req, res) => {
43
+ handleEntityDelete(moduleName, n, req, res);
44
+ });
45
+ });
46
+ });
47
+ app.listen(port, () => {
48
+ console.log(chalk.green(`Application ${chalk.bold(appName + ' version ' + appVersion)} started on port ${chalk.bold(port)}`));
49
+ });
50
+ }
51
+ function ok(res) {
52
+ return (value) => {
53
+ const result = normalizedResult(value);
54
+ res.contentType('application/json');
55
+ res.send(JSON.stringify(result));
56
+ };
57
+ }
58
+ function statusFromErrorType(err) {
59
+ if (err instanceof UnauthorisedError) {
60
+ return 401;
61
+ }
62
+ else if (err instanceof BadRequestError) {
63
+ return 400;
64
+ }
65
+ else {
66
+ return 500;
67
+ }
68
+ }
69
+ function internalError(res) {
70
+ return (reason) => {
71
+ logger.error(reason);
72
+ res.status(statusFromErrorType(reason)).send(reason.message);
73
+ };
74
+ }
75
+ function patternFromAttributes(moduleName, recName, attrs) {
76
+ const attrsStrs = new Array();
77
+ attrs.forEach((v, n) => {
78
+ let av = isString(v) ? `"${v}"` : v;
79
+ if (av instanceof Object) {
80
+ av = JSON.stringify(av);
81
+ }
82
+ attrsStrs.push(`${n} ${av}`);
83
+ });
84
+ return `{${moduleName}/${recName} { ${attrsStrs.join(',\n')} }}`;
85
+ }
86
+ function normalizeRequestPath(path, moduleName) {
87
+ if (path.length <= 1) {
88
+ return path;
89
+ }
90
+ const result = new Array();
91
+ result.push(path[0]);
92
+ for (let i = 1; i < path.length; ++i) {
93
+ const rn = forceAsEscapedName(path[i], moduleName);
94
+ const en = forceAsEscapedName(path[++i], moduleName);
95
+ result.push(rn);
96
+ result.push(en);
97
+ if (i < path.length) {
98
+ result.push(path[++i]);
99
+ }
100
+ }
101
+ return result;
102
+ }
103
+ function pathFromRequest(moduleName, entryName, req) {
104
+ const path = req.params.path;
105
+ if (!path) {
106
+ return req.url;
107
+ }
108
+ let p = '';
109
+ if (path instanceof Array) {
110
+ p = normalizeRequestPath(path, moduleName).join('/');
111
+ }
112
+ else {
113
+ p = path.toString();
114
+ }
115
+ return `${escapeFqName(makeFqName(moduleName, entryName))}/${p}`;
116
+ }
117
+ async function handleEventPost(moduleName, eventName, req, res) {
118
+ try {
119
+ const sessionInfo = await verifyAuth(moduleName, eventName, req.headers.authorization);
120
+ if (isNoSession(sessionInfo)) {
121
+ res.status(401).send('Authorization required');
122
+ return;
123
+ }
124
+ const inst = makeInstance(moduleName, eventName, objectAsInstanceAttributes(req.body)).setAuthContext(sessionInfo);
125
+ evaluate(inst, ok(res)).catch(internalError(res));
126
+ }
127
+ catch (err) {
128
+ logger.error(err);
129
+ res.status(500).send(err.toString());
130
+ }
131
+ }
132
+ async function handleEntityPost(moduleName, entityName, req, res) {
133
+ try {
134
+ const sessionInfo = await verifyAuth(moduleName, entityName, req.headers.authorization);
135
+ if (isNoSession(sessionInfo)) {
136
+ res.status(401).send('Authorization required');
137
+ return;
138
+ }
139
+ console.log("req.body", req.body);
140
+ const pattern = req.params.path
141
+ ? createChildPattern(moduleName, entityName, req)
142
+ : patternFromAttributes(moduleName, entityName, objectAsInstanceAttributes(req.body));
143
+ console.log("p", pattern);
144
+ parseAndEvaluateStatement(pattern, sessionInfo.userId).then(ok(res)).catch(internalError(res));
145
+ }
146
+ catch (err) {
147
+ logger.error(err);
148
+ res.status(500).send(err.toString());
149
+ }
150
+ }
151
+ async function handleEntityGet(moduleName, entityName, req, res) {
152
+ try {
153
+ const path = pathFromRequest(moduleName, entityName, req);
154
+ const sessionInfo = await verifyAuth(moduleName, entityName, req.headers.authorization);
155
+ if (isNoSession(sessionInfo)) {
156
+ res.status(401).send('Authorization required');
157
+ return;
158
+ }
159
+ let pattern = '';
160
+ if (req.query.tree) {
161
+ pattern = fetchTreePattern(makeFqName(moduleName, entityName), path);
162
+ }
163
+ else {
164
+ const r = walkDownInstancePath(path);
165
+ let moduleName = r[0];
166
+ let entityName = r[1];
167
+ const id = r[2];
168
+ const parts = r[3];
169
+ if (parts.length == 2 && id == undefined) {
170
+ pattern = `{${moduleName}/${entityName}? {}}`;
171
+ }
172
+ else {
173
+ moduleName = restoreFqName(moduleName);
174
+ entityName = restoreFqName(entityName);
175
+ if (id == undefined) {
176
+ pattern = `{${moduleName}/${entityName} {${PathAttributeNameQuery}like "${path}%"}}`;
177
+ }
178
+ else {
179
+ pattern = `{${moduleName}/${entityName} {${PathAttributeNameQuery} "${path}"}}`;
180
+ }
181
+ }
182
+ }
183
+ parseAndEvaluateStatement(pattern, sessionInfo.userId).then(ok(res)).catch(internalError(res));
184
+ }
185
+ catch (err) {
186
+ logger.error(err);
187
+ res.status(500).send(err.toString());
188
+ }
189
+ }
190
+ async function handleEntityPut(moduleName, entityName, req, res) {
191
+ try {
192
+ const path = pathFromRequest(moduleName, entityName, req);
193
+ const sessionInfo = await verifyAuth(moduleName, entityName, req.headers.authorization);
194
+ if (isNoSession(sessionInfo)) {
195
+ res.status(401).send('Authorization required');
196
+ return;
197
+ }
198
+ const attrs = objectAsInstanceAttributes(req.body);
199
+ attrs.set(PathAttributeNameQuery, path);
200
+ const pattern = patternFromAttributes(moduleName, entityName, attrs);
201
+ parseAndEvaluateStatement(pattern, sessionInfo.userId).then(ok(res)).catch(internalError(res));
202
+ }
203
+ catch (err) {
204
+ logger.error(err);
205
+ res.status(500).send(err.toString());
206
+ }
207
+ }
208
+ async function handleEntityDelete(moduleName, entityName, req, res) {
209
+ try {
210
+ const path = pathFromRequest(moduleName, entityName, req);
211
+ const sessionInfo = await verifyAuth(moduleName, entityName, req.headers.authorization);
212
+ if (isNoSession(sessionInfo)) {
213
+ res.status(401).send('Authorization required');
214
+ return;
215
+ }
216
+ const pattern = `delete {${moduleName}/${entityName} {${PathAttributeNameQuery} "${path}"}}`;
217
+ parseAndEvaluateStatement(pattern, sessionInfo.userId).then(ok(res)).catch(internalError(res));
218
+ }
219
+ catch (err) {
220
+ logger.error(err);
221
+ res.status(500).send(err.toString());
222
+ }
223
+ }
224
+ function fetchTreePattern(fqName, path) {
225
+ let pattern = path ? `{${fqName} {${PathAttributeNameQuery} "${path}"}` : `{${fqName}? {}`;
226
+ const rels = getAllChildRelationships(fqName);
227
+ if (rels.length > 0) {
228
+ const treePats = new Array();
229
+ rels.forEach((rel) => {
230
+ treePats.push(`${rel.getFqName()} ${fetchTreePattern(rel.getChildFqName())}`);
231
+ });
232
+ pattern = pattern.concat(',', treePats.join(','));
233
+ }
234
+ return `${pattern}}`;
235
+ }
236
+ function createChildPattern(moduleName, entityName, req) {
237
+ const path = pathFromRequest(moduleName, entityName, req);
238
+ try {
239
+ const parts = path.split('/');
240
+ const pinfo = parts.slice(-4);
241
+ const parentFqname = forceAsFqName(pinfo[0], moduleName);
242
+ const relName = forceAsFqName(pinfo[2], moduleName);
243
+ const parentPath = parts.slice(0, parts.length - 2).join('/');
244
+ const childFqName = forceAsFqName(pinfo[3], moduleName);
245
+ const cparts = splitFqName(childFqName);
246
+ const childModuleName = cparts.getModuleName();
247
+ const childName = cparts.getEntryName();
248
+ const cp = patternFromAttributes(childModuleName, childName, objectAsInstanceAttributes(req.body));
249
+ return `{${parentFqname} {${PathAttributeNameQuery} "${parentPath}"}, ${relName} ${cp}}`;
250
+ }
251
+ catch (err) {
252
+ throw new BadRequestError(err.message);
253
+ }
254
+ }
255
+ async function verifyAuth(moduleName, eventName, authValue) {
256
+ if (requireAuth(moduleName, eventName)) {
257
+ if (authValue) {
258
+ const token = authValue.substring(authValue.indexOf(' ')).trim();
259
+ return await verifySession(token);
260
+ }
261
+ else {
262
+ return NoSession;
263
+ }
264
+ }
265
+ return BypassSession;
266
+ }
267
+ function normalizedResult(r) {
268
+ if (r instanceof Array) {
269
+ return r.map((x) => {
270
+ return normalizedResult(x);
271
+ });
272
+ }
273
+ else if (r instanceof Instance) {
274
+ r.mergeRelatedInstances();
275
+ Array.from(r.attributes.keys()).forEach(k => {
276
+ const v = r.attributes.get(k);
277
+ if (v instanceof Array || v instanceof Instance) {
278
+ r.attributes.set(k, normalizedResult(v));
279
+ }
280
+ });
281
+ return r.asObject();
282
+ }
283
+ else {
284
+ if (r instanceof Map) {
285
+ return Object.fromEntries(r.entries());
286
+ }
287
+ return r;
288
+ }
289
+ }
290
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/api/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,OAA8B,MAAM,SAAS,CAAC;AACrD,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EAER,YAAY,EACZ,0BAA0B,GAE3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,yBAAyB,EAAU,MAAM,2BAA2B,CAAC;AAExF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;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CAAC;QACvB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE;YACzB,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,CAAC,YAAY,QAAQ,EAAE,CAAC;QACjC,CAAC,CAAC,qBAAqB,EAAE,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAC1C,MAAM,CAAC,GAAW,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACtC,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,YAAY,QAAQ,EAAE,CAAC;gBAChD,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;YACrB,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ interface FilePathData {
2
+ destination: string;
3
+ name: string;
4
+ }
5
+ export declare function extractDestinationAndName(filePath: string, destination: string | undefined): FilePathData;
6
+ export {};
7
+ //# sourceMappingURL=cli-util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-util.d.ts","sourceRoot":"","sources":["../../src/cli/cli-util.ts"],"names":[],"mappings":"AAEA,UAAU,YAAY;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,YAAY,CAOd"}
@@ -0,0 +1,9 @@
1
+ import { path } from '../utils/runtime.js';
2
+ export function extractDestinationAndName(filePath, destination) {
3
+ const fileName = path.basename(filePath, path.extname(filePath)).replace(/[.-]/g, '');
4
+ return {
5
+ destination: destination !== null && destination !== void 0 ? destination : path.join(path.dirname(filePath), 'generated'),
6
+ name: fileName,
7
+ };
8
+ }
9
+ //# sourceMappingURL=cli-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-util.js","sourceRoot":"","sources":["../../src/cli/cli-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAO3C,MAAM,UAAU,yBAAyB,CACvC,QAAgB,EAChB,WAA+B;IAE/B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAEtF,OAAO;QACL,WAAW,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC;QAC1E,IAAI,EAAE,QAAQ;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const generateSwaggerDoc: (fileName: string) => Promise<void>;
2
+ //# sourceMappingURL=docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/cli/docs.ts"],"names":[],"mappings":"AA8OA,eAAO,MAAM,kBAAkB,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,CAcvE,CAAC"}