@voxgig/sdkgen 1.2.0 → 1.3.1

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 (329) hide show
  1. package/bin/voxgig-sdkgen +2 -2
  2. package/dist/action/action.d.ts +2 -1
  3. package/dist/action/action.js +15 -9
  4. package/dist/action/action.js.map +1 -1
  5. package/dist/action/feature.js +6 -3
  6. package/dist/action/feature.js.map +1 -1
  7. package/dist/action/target.d.ts +7 -1
  8. package/dist/action/target.js +13 -6
  9. package/dist/action/target.js.map +1 -1
  10. package/dist/cmp/Changelog.d.ts +2 -0
  11. package/dist/cmp/Changelog.js +30 -0
  12. package/dist/cmp/Changelog.js.map +1 -0
  13. package/dist/cmp/Deploy.d.ts +2 -0
  14. package/dist/cmp/Deploy.js +227 -0
  15. package/dist/cmp/Deploy.js.map +1 -0
  16. package/dist/cmp/FeatureHook.js +5 -6
  17. package/dist/cmp/FeatureHook.js.map +1 -1
  18. package/dist/cmp/License.d.ts +2 -0
  19. package/dist/cmp/License.js +44 -0
  20. package/dist/cmp/License.js.map +1 -0
  21. package/dist/cmp/Readme.js +2 -0
  22. package/dist/cmp/Readme.js.map +1 -1
  23. package/dist/cmp/ReadmeErrors.d.ts +2 -0
  24. package/dist/cmp/ReadmeErrors.js +210 -0
  25. package/dist/cmp/ReadmeErrors.js.map +1 -0
  26. package/dist/cmp/ReadmeExplanation.js +213 -223
  27. package/dist/cmp/ReadmeExplanation.js.map +1 -1
  28. package/dist/cmp/ReadmeModel.js +6 -1
  29. package/dist/cmp/ReadmeModel.js.map +1 -1
  30. package/dist/cmp/ReadmeTop.js +389 -82
  31. package/dist/cmp/ReadmeTop.js.map +1 -1
  32. package/dist/cmp/Security.d.ts +2 -0
  33. package/dist/cmp/Security.js +36 -0
  34. package/dist/cmp/Security.js.map +1 -0
  35. package/dist/helpers/canonType.d.ts +7 -0
  36. package/dist/helpers/canonType.js +74 -0
  37. package/dist/helpers/canonType.js.map +1 -0
  38. package/dist/helpers/collectDeps.d.ts +3 -2
  39. package/dist/helpers/collectDeps.js.map +1 -1
  40. package/dist/helpers/naming.d.ts +3 -0
  41. package/dist/helpers/naming.js +51 -0
  42. package/dist/helpers/naming.js.map +1 -0
  43. package/dist/helpers/opExample.d.ts +13 -0
  44. package/dist/helpers/opExample.js +149 -0
  45. package/dist/helpers/opExample.js.map +1 -0
  46. package/dist/helpers/opShape.d.ts +18 -0
  47. package/dist/helpers/opShape.js +193 -0
  48. package/dist/helpers/opShape.js.map +1 -0
  49. package/dist/helpers/packageMeta.d.ts +27 -0
  50. package/dist/helpers/packageMeta.js +224 -0
  51. package/dist/helpers/packageMeta.js.map +1 -0
  52. package/dist/sdkgen.d.ts +11 -1
  53. package/dist/sdkgen.js +57 -18
  54. package/dist/sdkgen.js.map +1 -1
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/dist/types.d.ts +65 -2
  57. package/dist/types.js.map +1 -1
  58. package/dist/utility.js +20 -11
  59. package/dist/utility.js.map +1 -1
  60. package/model/sdkgen.aontu +137 -0
  61. package/package.json +13 -6
  62. package/project/.sdk/model/target/go-cli.jsonic +47 -0
  63. package/project/.sdk/model/target/go-mcp.jsonic +41 -0
  64. package/project/.sdk/model/target/go.jsonic +9 -3
  65. package/project/.sdk/model/target/js.jsonic +13 -0
  66. package/project/.sdk/model/target/lua.jsonic +13 -0
  67. package/project/.sdk/model/target/php.jsonic +13 -0
  68. package/project/.sdk/model/target/py.jsonic +13 -0
  69. package/project/.sdk/model/target/rb.jsonic +13 -0
  70. package/project/.sdk/model/target/ts.jsonic +13 -0
  71. package/project/.sdk/src/cmp/go/EntityOperation_go.ts +1 -0
  72. package/project/.sdk/src/cmp/go/EntityTypes_go.ts +197 -0
  73. package/project/.sdk/src/cmp/go/Entity_go.ts +2 -1
  74. package/project/.sdk/src/cmp/go/MainEntity_go.ts +6 -0
  75. package/project/.sdk/src/cmp/go/Main_go.ts +23 -3
  76. package/project/.sdk/src/cmp/go/Package_go.ts +1 -1
  77. package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +18 -6
  78. package/project/.sdk/src/cmp/go/ReadmeExamplesTest_go.ts +684 -0
  79. package/project/.sdk/src/cmp/go/ReadmeExplanation_go.ts +1 -1
  80. package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +48 -8
  81. package/project/.sdk/src/cmp/go/ReadmeInstall_go.ts +11 -6
  82. package/project/.sdk/src/cmp/go/ReadmeIntro_go.ts +40 -1
  83. package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +63 -17
  84. package/project/.sdk/src/cmp/go/ReadmeOptions_go.ts +4 -3
  85. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +124 -115
  86. package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +28 -15
  87. package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +33 -9
  88. package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +35 -5
  89. package/project/.sdk/src/cmp/go/TestEntity_go.ts +1 -1
  90. package/project/.sdk/src/cmp/go/Test_go.ts +5 -1
  91. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +21 -0
  92. package/project/.sdk/src/cmp/go/fragment/EntityCreateOp.fragment.go +11 -0
  93. package/project/.sdk/src/cmp/go/fragment/EntityListOp.fragment.go +11 -0
  94. package/project/.sdk/src/cmp/go/fragment/EntityLoadOp.fragment.go +11 -0
  95. package/project/.sdk/src/cmp/go/fragment/EntityRemoveOp.fragment.go +11 -0
  96. package/project/.sdk/src/cmp/go/fragment/EntityUpdateOp.fragment.go +11 -0
  97. package/project/.sdk/src/cmp/go-cli/Main_go-cli.ts +195 -0
  98. package/project/.sdk/src/cmp/go-cli/fragment/main.fragment.go +106 -0
  99. package/project/.sdk/src/cmp/go-cli/fragment/words.fragment.go +132 -0
  100. package/project/.sdk/src/cmp/go-mcp/Main_go-mcp.ts +184 -0
  101. package/project/.sdk/src/cmp/go-mcp/fragment/main.fragment.go +68 -0
  102. package/project/.sdk/src/cmp/go-mcp/fragment/tools.fragment.go +114 -0
  103. package/project/.sdk/src/cmp/js/EntityTypes_js.ts +111 -0
  104. package/project/.sdk/src/cmp/js/MainEntity_js.ts +1 -0
  105. package/project/.sdk/src/cmp/js/Main_js.ts +3 -0
  106. package/project/.sdk/src/cmp/js/Package_js.ts +16 -7
  107. package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +13 -7
  108. package/project/.sdk/src/cmp/js/ReadmeExplanation_js.ts +2 -2
  109. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +52 -11
  110. package/project/.sdk/src/cmp/js/ReadmeIntro_js.ts +39 -1
  111. package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +50 -18
  112. package/project/.sdk/src/cmp/js/ReadmeOptions_js.ts +4 -3
  113. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +45 -19
  114. package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +24 -13
  115. package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +3 -0
  116. package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +28 -12
  117. package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +23 -3
  118. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +5 -0
  119. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +5 -0
  120. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +5 -0
  121. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +5 -0
  122. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +5 -0
  123. package/project/.sdk/src/cmp/js/utility_js.ts +57 -0
  124. package/project/.sdk/src/cmp/lua/EntityTypes_lua.ts +113 -0
  125. package/project/.sdk/src/cmp/lua/MainEntity_lua.ts +8 -0
  126. package/project/.sdk/src/cmp/lua/Main_lua.ts +4 -0
  127. package/project/.sdk/src/cmp/lua/Package_lua.ts +23 -4
  128. package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +12 -10
  129. package/project/.sdk/src/cmp/lua/ReadmeExamplesTest_lua.ts +293 -0
  130. package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +46 -8
  131. package/project/.sdk/src/cmp/lua/ReadmeInstall_lua.ts +19 -3
  132. package/project/.sdk/src/cmp/lua/ReadmeIntro_lua.ts +38 -1
  133. package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +51 -16
  134. package/project/.sdk/src/cmp/lua/ReadmeOptions_lua.ts +4 -3
  135. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +79 -18
  136. package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +25 -20
  137. package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +17 -9
  138. package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +32 -5
  139. package/project/.sdk/src/cmp/lua/Test_lua.ts +4 -0
  140. package/project/.sdk/src/cmp/lua/fragment/EntityCreateOp.fragment.lua +4 -0
  141. package/project/.sdk/src/cmp/lua/fragment/EntityListOp.fragment.lua +4 -0
  142. package/project/.sdk/src/cmp/lua/fragment/EntityLoadOp.fragment.lua +4 -0
  143. package/project/.sdk/src/cmp/lua/fragment/EntityRemoveOp.fragment.lua +4 -0
  144. package/project/.sdk/src/cmp/lua/fragment/EntityUpdateOp.fragment.lua +4 -0
  145. package/project/.sdk/src/cmp/php/EntityTypes_php.ts +142 -0
  146. package/project/.sdk/src/cmp/php/MainEntity_php.ts +18 -1
  147. package/project/.sdk/src/cmp/php/Main_php.ts +4 -0
  148. package/project/.sdk/src/cmp/php/Package_php.ts +18 -7
  149. package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +15 -11
  150. package/project/.sdk/src/cmp/php/ReadmeExamplesTest_php.ts +401 -0
  151. package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +56 -13
  152. package/project/.sdk/src/cmp/php/ReadmeInstall_php.ts +15 -3
  153. package/project/.sdk/src/cmp/php/ReadmeIntro_php.ts +40 -1
  154. package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +26 -8
  155. package/project/.sdk/src/cmp/php/ReadmeOptions_php.ts +4 -3
  156. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +80 -22
  157. package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +51 -42
  158. package/project/.sdk/src/cmp/php/ReadmeTopHowto_php.ts +1 -1
  159. package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +19 -11
  160. package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +41 -11
  161. package/project/.sdk/src/cmp/php/TestDirect_php.ts +9 -9
  162. package/project/.sdk/src/cmp/php/TestEntity_php.ts +6 -12
  163. package/project/.sdk/src/cmp/php/Test_php.ts +4 -0
  164. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +13 -1
  165. package/project/.sdk/src/cmp/php/fragment/EntityCreateOp.fragment.php +10 -1
  166. package/project/.sdk/src/cmp/php/fragment/EntityListOp.fragment.php +10 -1
  167. package/project/.sdk/src/cmp/php/fragment/EntityLoadOp.fragment.php +10 -1
  168. package/project/.sdk/src/cmp/php/fragment/EntityRemoveOp.fragment.php +10 -1
  169. package/project/.sdk/src/cmp/php/fragment/EntityUpdateOp.fragment.php +10 -1
  170. package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +22 -14
  171. package/project/.sdk/src/cmp/py/EntityTypes_py.ts +184 -0
  172. package/project/.sdk/src/cmp/py/Entity_py.ts +27 -0
  173. package/project/.sdk/src/cmp/py/MainEntity_py.ts +2 -1
  174. package/project/.sdk/src/cmp/py/Main_py.ts +35 -0
  175. package/project/.sdk/src/cmp/py/Package_py.ts +24 -3
  176. package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +27 -11
  177. package/project/.sdk/src/cmp/py/ReadmeExamplesTest_py.ts +626 -0
  178. package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +53 -14
  179. package/project/.sdk/src/cmp/py/ReadmeInstall_py.ts +19 -3
  180. package/project/.sdk/src/cmp/py/ReadmeIntro_py.ts +48 -1
  181. package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +28 -10
  182. package/project/.sdk/src/cmp/py/ReadmeOptions_py.ts +4 -3
  183. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +73 -24
  184. package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +57 -37
  185. package/project/.sdk/src/cmp/py/ReadmeTopHowto_py.ts +1 -1
  186. package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +19 -11
  187. package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +30 -5
  188. package/project/.sdk/src/cmp/py/TestDirect_py.ts +7 -9
  189. package/project/.sdk/src/cmp/py/TestEntity_py.ts +6 -14
  190. package/project/.sdk/src/cmp/py/Test_py.ts +4 -0
  191. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +5 -2
  192. package/project/.sdk/src/cmp/py/fragment/EntityCreateOp.fragment.py +1 -1
  193. package/project/.sdk/src/cmp/py/fragment/EntityListOp.fragment.py +5 -1
  194. package/project/.sdk/src/cmp/py/fragment/EntityLoadOp.fragment.py +6 -1
  195. package/project/.sdk/src/cmp/py/fragment/EntityRemoveOp.fragment.py +6 -1
  196. package/project/.sdk/src/cmp/py/fragment/EntityUpdateOp.fragment.py +1 -1
  197. package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +17 -10
  198. package/project/.sdk/src/cmp/rb/EntityTypes_rb.ts +136 -0
  199. package/project/.sdk/src/cmp/rb/MainEntity_rb.ts +1 -0
  200. package/project/.sdk/src/cmp/rb/Main_rb.ts +4 -0
  201. package/project/.sdk/src/cmp/rb/Package_rb.ts +34 -7
  202. package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +26 -10
  203. package/project/.sdk/src/cmp/rb/ReadmeExamplesTest_rb.ts +289 -0
  204. package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +72 -21
  205. package/project/.sdk/src/cmp/rb/ReadmeInstall_rb.ts +16 -4
  206. package/project/.sdk/src/cmp/rb/ReadmeIntro_rb.ts +40 -1
  207. package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +29 -12
  208. package/project/.sdk/src/cmp/rb/ReadmeOptions_rb.ts +4 -3
  209. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +85 -22
  210. package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +56 -37
  211. package/project/.sdk/src/cmp/rb/ReadmeTopHowto_rb.ts +1 -1
  212. package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +19 -11
  213. package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +43 -11
  214. package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +9 -9
  215. package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +6 -12
  216. package/project/.sdk/src/cmp/rb/Test_rb.ts +4 -0
  217. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +2 -0
  218. package/project/.sdk/src/cmp/rb/fragment/EntityCreateOp.fragment.rb +5 -0
  219. package/project/.sdk/src/cmp/rb/fragment/EntityListOp.fragment.rb +20 -2
  220. package/project/.sdk/src/cmp/rb/fragment/EntityLoadOp.fragment.rb +8 -1
  221. package/project/.sdk/src/cmp/rb/fragment/EntityRemoveOp.fragment.rb +6 -1
  222. package/project/.sdk/src/cmp/rb/fragment/EntityUpdateOp.fragment.rb +5 -0
  223. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +24 -8
  224. package/project/.sdk/src/cmp/ts/EntityTypes_ts.ts +105 -0
  225. package/project/.sdk/src/cmp/ts/Entity_ts.ts +17 -1
  226. package/project/.sdk/src/cmp/ts/MainEntity_ts.ts +1 -0
  227. package/project/.sdk/src/cmp/ts/Main_ts.ts +6 -0
  228. package/project/.sdk/src/cmp/ts/Package_ts.ts +14 -7
  229. package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +13 -7
  230. package/project/.sdk/src/cmp/ts/ReadmeExampleTest_ts.ts +81 -0
  231. package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +446 -0
  232. package/project/.sdk/src/cmp/ts/ReadmeExplanation_ts.ts +2 -2
  233. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +57 -11
  234. package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts +19 -6
  235. package/project/.sdk/src/cmp/ts/ReadmeIntro_ts.ts +39 -1
  236. package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +50 -18
  237. package/project/.sdk/src/cmp/ts/ReadmeOptions_ts.ts +4 -3
  238. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +95 -40
  239. package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +24 -13
  240. package/project/.sdk/src/cmp/ts/ReadmeTopHowto_ts.ts +3 -0
  241. package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +44 -12
  242. package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +23 -3
  243. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +2 -2
  244. package/project/.sdk/src/cmp/ts/Test_ts.ts +5 -0
  245. package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +3 -1
  246. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +10 -5
  247. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +4 -2
  248. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +4 -2
  249. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +4 -2
  250. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +4 -2
  251. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +4 -2
  252. package/project/.sdk/src/cmp/ts/utility_ts.ts +59 -0
  253. package/project/.sdk/tm/go/LICENSE +1 -1
  254. package/project/.sdk/tm/go/Makefile +36 -1
  255. package/project/.sdk/tm/go/VERSION +1 -0
  256. package/project/.sdk/tm/go/core/context.go +12 -7
  257. package/project/.sdk/tm/go-cli/src/feature/README.md +6 -0
  258. package/project/.sdk/tm/go-cli/src/feature/base/.gitkeep +0 -0
  259. package/project/.sdk/tm/go-cli/src/feature/log/.gitkeep +0 -0
  260. package/project/.sdk/tm/go-cli/src/feature/test/.gitkeep +0 -0
  261. package/project/.sdk/tm/go-mcp/src/feature/README.md +6 -0
  262. package/project/.sdk/tm/go-mcp/src/feature/base/.gitkeep +0 -0
  263. package/project/.sdk/tm/go-mcp/src/feature/log/.gitkeep +0 -0
  264. package/project/.sdk/tm/go-mcp/src/feature/test/.gitkeep +0 -0
  265. package/project/.sdk/tm/js/LICENSE +1 -1
  266. package/project/.sdk/tm/js/Makefile +41 -0
  267. package/project/.sdk/tm/lua/LICENSE +1 -1
  268. package/project/.sdk/tm/lua/Makefile +40 -1
  269. package/project/.sdk/tm/lua/core/context.lua +13 -8
  270. package/project/.sdk/tm/php/LICENSE +1 -1
  271. package/project/.sdk/tm/php/Makefile +31 -1
  272. package/project/.sdk/tm/php/VERSION +1 -0
  273. package/project/.sdk/tm/php/core/Context.php +12 -6
  274. package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +13 -4
  275. package/project/.sdk/tm/php/utility/Done.php +2 -2
  276. package/project/.sdk/tm/php/utility/MakeError.php +3 -3
  277. package/project/.sdk/tm/py/LICENSE +1 -1
  278. package/project/.sdk/tm/py/Makefile +34 -1
  279. package/project/.sdk/tm/py/core/context.py +12 -7
  280. package/project/.sdk/tm/py/test/test_primary_utility.py +15 -4
  281. package/project/.sdk/tm/py/utility/done.py +3 -1
  282. package/project/.sdk/tm/py/utility/make_error.py +2 -2
  283. package/project/.sdk/tm/rb/LICENSE +1 -1
  284. package/project/.sdk/tm/rb/Makefile +33 -1
  285. package/project/.sdk/tm/rb/core/context.rb +8 -3
  286. package/project/.sdk/tm/rb/test/primary_utility_test.rb +2 -2
  287. package/project/.sdk/tm/rb/utility/done.rb +3 -1
  288. package/project/.sdk/tm/rb/utility/make_error.rb +5 -2
  289. package/project/.sdk/tm/ts/LICENSE +1 -1
  290. package/project/.sdk/tm/ts/Makefile +42 -0
  291. package/project/.sdk/tm/ts/src/Context.ts +8 -3
  292. package/src/action/action.ts +17 -10
  293. package/src/action/feature.ts +8 -6
  294. package/src/action/target.ts +17 -8
  295. package/src/cmp/Changelog.ts +34 -0
  296. package/src/cmp/Deploy.ts +258 -0
  297. package/src/cmp/FeatureHook.ts +6 -8
  298. package/src/cmp/License.ts +49 -0
  299. package/src/cmp/Readme.ts +2 -0
  300. package/src/cmp/ReadmeErrors.ts +257 -0
  301. package/src/cmp/ReadmeExplanation.ts +250 -230
  302. package/src/cmp/ReadmeModel.ts +7 -2
  303. package/src/cmp/ReadmeTop.ts +411 -95
  304. package/src/cmp/Security.ts +41 -0
  305. package/src/helpers/canonType.ts +89 -0
  306. package/src/helpers/collectDeps.ts +5 -3
  307. package/src/helpers/naming.ts +59 -0
  308. package/src/helpers/opExample.ts +170 -0
  309. package/src/helpers/opShape.ts +236 -0
  310. package/src/helpers/packageMeta.ts +236 -0
  311. package/src/sdkgen.ts +87 -20
  312. package/src/tsconfig.json +1 -0
  313. package/src/types.ts +85 -2
  314. package/src/utility.ts +22 -11
  315. package/README.md +0 -2
  316. package/dist/action/lang.d.ts +0 -2
  317. package/dist/action/lang.js +0 -68
  318. package/dist/action/lang.js.map +0 -1
  319. package/dist/cmp/Hook.d.ts +0 -2
  320. package/dist/cmp/Hook.js +0 -10
  321. package/dist/cmp/Hook.js.map +0 -1
  322. package/dist/cmp/Top.d.ts +0 -2
  323. package/dist/cmp/Top.js +0 -23
  324. package/dist/cmp/Top.js.map +0 -1
  325. package/dist/prepare-openapi.d.ts +0 -2
  326. package/dist/prepare-openapi.js +0 -37
  327. package/dist/prepare-openapi.js.map +0 -1
  328. package/model/sdkgen.jsonic +0 -74
  329. package/project/.sdk/tm/go/utility/struct/go.mod +0 -3
@@ -1,20 +1,57 @@
1
1
 
2
- import { cmp, Content, isAuthActive } from '@voxgig/sdkgen'
2
+ import { cmp, Content, isAuthActive, envName, canonKey, entityIdField, entityPrimaryOp, opRequestShape, safeVarName } from '@voxgig/sdkgen'
3
3
 
4
4
  import {
5
5
  KIT,
6
6
  getModelPath,
7
+ nom,
7
8
  } from '@voxgig/apidef'
8
9
 
9
10
 
11
+ // A type-correct Go literal for a field's canonical type.
12
+ function goLit(type: any): string {
13
+ const k = canonKey(type)
14
+ if ('INTEGER' === k || 'NUMBER' === k) return '1'
15
+ if ('BOOLEAN' === k) return 'true'
16
+ if ('ARRAY' === k) return '[]any{}'
17
+ if ('OBJECT' === k) return 'map[string]any{}'
18
+ return '"example"'
19
+ }
20
+
21
+ function cap(s: string): string {
22
+ return s.charAt(0).toUpperCase() + s.slice(1)
23
+ }
24
+
25
+
10
26
  const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
11
27
  const { target, ctx$: { model } } = props
12
28
 
13
29
  // Go module path == repo path on GitHub (org from model.origin).
14
- const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
30
+ const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
31
+
32
+ const entity = getModelPath(model, `main.${KIT}.entity`)
33
+ const exampleEntity = Object.values(entity || {}).find((e: any) => e && e.active !== false) as any
34
+ const eName = exampleEntity ? nom(exampleEntity, 'Name') : 'Entity'
35
+ const eLower = safeVarName(eName.toLowerCase(), 'go')
36
+ // Model-driven id key: null when the entity has no id-like field.
37
+ const idF = exampleEntity ? entityIdField(exampleEntity) : null
38
+ // Drive the test-mode example off the entity's PRIMARY op — never a hardcoded
39
+ // `Load` a create-only entity lacks.
40
+ const primaryOp = exampleEntity ? (entityPrimaryOp(exampleEntity) || 'load') : 'load'
41
+ const isMatchOp = 'load' === primaryOp || 'remove' === primaryOp
42
+ let testArg = 'nil'
43
+ if (exampleEntity && isMatchOp) {
44
+ testArg = idF ? `map[string]any{"${idF}": "test01"}` : 'nil'
45
+ } else if (exampleEntity && ('create' === primaryOp || 'update' === primaryOp)) {
46
+ const items = opRequestShape(exampleEntity, primaryOp).items
47
+ .filter((it: any) => it.name !== idF && it.name !== 'id')
48
+ const required = items.filter((it: any) => !it.optional)
49
+ const chosen = required.length ? required : items.slice(0, 3)
50
+ testArg = `map[string]any{${chosen.map((it: any) => `"${it.name}": ${goLit(it.type)}`).join(', ')}}`
51
+ }
15
52
 
16
53
  const apikeyEnvLine = isAuthActive(model)
17
- ? `\n${model.NAME}_APIKEY=<your-key>`
54
+ ? `\n${envName(model)}_APIKEY=<your-key>`
18
55
  : ''
19
56
 
20
57
  Content(`### Make a direct HTTP request
@@ -59,12 +96,15 @@ fmt.Println(fetchdef["headers"])
59
96
  Create a mock client for unit testing \u2014 no server required:
60
97
 
61
98
  \`\`\`go
62
- client := sdk.TestSDK(nil, nil)
99
+ client := sdk.Test()
63
100
 
64
- result, err := client.Planet(nil).Load(
65
- map[string]any{"id": "test01"}, nil,
101
+ ${eLower}, err := client.${eName}(nil).${cap(primaryOp)}(
102
+ ${testArg}, nil,
66
103
  )
67
- // result contains mock response data
104
+ if err != nil {
105
+ panic(err)
106
+ }
107
+ fmt.Println(${eLower}) // the returned mock data
68
108
  \`\`\`
69
109
 
70
110
  ### Use a custom fetch function
@@ -96,7 +136,7 @@ client := sdk.New${model.const.Name}SDK(map[string]any{
96
136
  Create a \`.env.local\` file at the project root:
97
137
 
98
138
  \`\`\`
99
- ${model.NAME}_TEST_LIVE=TRUE${apikeyEnvLine}
139
+ ${envName(model)}_TEST_LIVE=TRUE${apikeyEnvLine}
100
140
  \`\`\`
101
141
 
102
142
  Then run:
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, Content } from '@voxgig/sdkgen'
2
+ import { cmp, Content, packageName, repoInfo } from '@voxgig/sdkgen'
3
3
 
4
4
 
5
5
  const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
@@ -7,17 +7,22 @@ const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
7
7
  const { model } = ctx$
8
8
 
9
9
  // Go module path == repo path on GitHub (org from model.origin).
10
- const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
10
+ const gomodule = packageName(model, 'go')
11
+ const { releasesUrl } = repoInfo(model)
11
12
 
12
13
  Content(`\`\`\`bash
13
- go get ${gomodule}
14
+ go get ${gomodule}@latest
14
15
  \`\`\`
15
16
 
16
- If the module is not yet published to a registry, use a \`replace\` directive
17
- in your \`go.mod\` to point to a local checkout:
17
+ The Go module proxy resolves the version from the \`go/vX.Y.Z\` GitHub
18
+ release tag see [Releases](${releasesUrl}) for the available versions.
19
+
20
+ To vendor from a local checkout instead, clone this repo alongside your
21
+ project and add a \`replace\` directive pointing at the checked-out
22
+ \`go/\` directory:
18
23
 
19
24
  \`\`\`bash
20
- go mod edit -replace ${gomodule}=../path/to/${gomodule}
25
+ go mod edit -replace ${gomodule}=../${model.name}-sdk/go
21
26
  \`\`\`
22
27
 
23
28
  `)
@@ -1,13 +1,52 @@
1
1
 
2
2
  import { cmp, Content } from '@voxgig/sdkgen'
3
3
 
4
+ import {
5
+ KIT,
6
+ getModelPath,
7
+ nom,
8
+ } from '@voxgig/apidef'
9
+
4
10
 
5
11
  const ReadmeIntro = cmp(function ReadmeIntro(props: any) {
6
12
  const { target, ctx$: { model } } = props
13
+ const info = (model.main && model.main.kit && model.main.kit.info) || {}
14
+ const tagline = info.tagline || ''
15
+
16
+ // Derive a real entity accessor from the model for the semantic-entity
17
+ // note (fall back to a generic name if the model has no entities).
18
+ const entity = getModelPath(model, `main.${KIT}.entity`) || {}
19
+ const exampleEntity = Object.values(entity).find((e: any) => e && e.active !== false) as any
20
+ const eName = exampleEntity ? nom(exampleEntity, 'Name') : 'Entity'
21
+
22
+ // Model-driven op list — only the operations the active entities actually
23
+ // expose (a read-only entity has just List+Load); never claim
24
+ // Create/Update/Remove exist when no entity has them. Go method names are
25
+ // capitalised, so present the ops that way.
26
+ const CANON_OPS = ['list', 'load', 'create', 'update', 'remove']
27
+ const cap = (o: string) => o.charAt(0).toUpperCase() + o.slice(1)
28
+ const opSet = new Set<string>()
29
+ Object.values(entity || {}).forEach((e: any) => {
30
+ if (!e || e.active === false) return
31
+ Object.keys(e.op || {}).forEach((o: string) => {
32
+ if (e.op[o] && e.op[o].active !== false) opSet.add(o)
33
+ })
34
+ })
35
+ const opNames = CANON_OPS.filter((o) => opSet.has(o))
36
+ .concat([...opSet].filter((o) => !CANON_OPS.includes(o)))
37
+ const opList = (opNames.length ? opNames : ['list', 'load'])
38
+ .map((o) => '`' + cap(o) + '`').join(', ')
7
39
 
8
40
  Content(`# ${model.Name} ${target.title} SDK
9
41
 
10
- The ${target.title} SDK for the ${model.Name} API. Provides an entity-oriented interface using standard Go conventions — no generics required, data flows as \`map[string]any\`.
42
+ ${tagline}
43
+
44
+ The ${target.title} SDK for the ${model.Name} API — an entity-oriented client using standard Go conventions. No generics required; data flows as \`map[string]any\`.
45
+
46
+ It exposes the API as capitalised, semantic **Entities** — e.g. \`client.${eName}(nil)\` — each with the same small set of operations (${opList}) instead of raw URL paths and query strings. You call meaning, not endpoints, which keeps the cognitive load low.
47
+
48
+ > Other languages, the CLI, and MCP server live alongside this one — see
49
+ > the [top-level README](../README.md).
11
50
 
12
51
  `)
13
52
  })
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, each, Content, isAuthActive } from '@voxgig/sdkgen'
2
+ import { cmp, each, Content, isAuthActive, entityIdField, entityPrimaryOp, safeVarName } from '@voxgig/sdkgen'
3
3
 
4
4
  import {
5
5
  KIT,
@@ -13,13 +13,56 @@ const ReadmeModel = cmp(function ReadmeModel(props: any) {
13
13
  const entity = getModelPath(model, `main.${KIT}.entity`)
14
14
  const entityList = each(entity).filter((e: any) => e.active !== false)
15
15
 
16
+ // Model-driven op rows for the shared entity interface: emit a
17
+ // Load/List/Create/Update/Remove row only for operations at least one active
18
+ // entity actually exposes (a read-only entity has just List+Load) — never
19
+ // document an operation no entity has. Model op keys are lowercase; Go
20
+ // method names are capitalised.
21
+ const opUnion = new Set<string>()
22
+ entityList.forEach((e: any) => Object.keys(e.op || {})
23
+ .forEach((o: string) => { if (e.op[o] && e.op[o].active !== false) opUnion.add(o) }))
24
+ const opRowDefs: Record<string, string> = {
25
+ load: '| `Load` | `(reqmatch, ctrl map[string]any) (any, error)` | Load a single entity by match criteria. |',
26
+ list: '| `List` | `(reqmatch, ctrl map[string]any) (any, error)` | List entities matching the criteria. |',
27
+ create: '| `Create` | `(reqdata, ctrl map[string]any) (any, error)` | Create a new entity. |',
28
+ update: '| `Update` | `(reqdata, ctrl map[string]any) (any, error)` | Update an existing entity. |',
29
+ remove: '| `Remove` | `(reqmatch, ctrl map[string]any) (any, error)` | Remove an entity. |',
30
+ }
31
+ const opRows = ['load', 'list', 'create', 'update', 'remove']
32
+ .filter((o) => opUnion.has(o)).map((o) => opRowDefs[o]).join('\n')
33
+
34
+ // Model-driven Result-shape rows: only describe the operations that
35
+ // actually exist. Record-returning ops (Load/Create/Update/Remove) share
36
+ // one row; List has its own — never name a missing op.
37
+ const recordOps = ['load', 'create', 'update', 'remove'].filter((o) => opUnion.has(o))
38
+ .map((o) => '`' + o.charAt(0).toUpperCase() + o.slice(1) + '`')
39
+ const resultRows: string[] = []
40
+ if (recordOps.length) resultRows.push('| ' + recordOps.join(' / ') + ' | the entity record (`map[string]any`) |')
41
+ if (opUnion.has('list')) resultRows.push('| `List` | a `[]any` of entity records |')
42
+ const resultShapeRows = resultRows.join('\n')
43
+
16
44
  // Go module path == repo path on GitHub (org from model.origin).
17
- const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
45
+ const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
18
46
 
19
47
  const apikeyOptionRow = isAuthActive(model)
20
48
  ? '| `"apikey"` | `string` | API key for authentication. |\n'
21
49
  : ''
22
50
 
51
+ // First published entity name, for the Result shape illustration.
52
+ const firstEntityName = (entityList[0] as any)?.Name || 'Entity'
53
+ const firstEntityVar = safeVarName(firstEntityName.toLowerCase(), 'go')
54
+ // Model-driven id key: null when the example entity has no id-like field, so
55
+ // the Result-shape illustration passes a nil match.
56
+ const firstIdF = entityIdField(entityList[0] || {})
57
+ // The example entity's PRIMARY op — an op it actually exposes (never a
58
+ // hardcoded `Load` a create-only entity lacks).
59
+ const firstPrimaryOp = entityList[0] ? (entityPrimaryOp(entityList[0]) || 'load') : 'load'
60
+ const firstPrimaryMethod = firstPrimaryOp.charAt(0).toUpperCase() + firstPrimaryOp.slice(1)
61
+ const firstIsMatchOp = 'load' === firstPrimaryOp || 'remove' === firstPrimaryOp
62
+ const firstOpArg = firstIsMatchOp
63
+ ? (firstIdF ? `map[string]any{"${firstIdF}": "example_id"}` : 'nil')
64
+ : 'map[string]any{/* fields */}'
65
+
23
66
  Content(`### New${model.const.Name}SDK
24
67
 
25
68
  \`\`\`go
@@ -56,7 +99,8 @@ Creates a test-mode client with mock transport. Both arguments may be \`nil\`.
56
99
  `)
57
100
 
58
101
  each(entityList, (ent: any) => {
59
- Content(`| \`${ent.Name}\` | \`(data map[string]any) ${model.const.Name}Entity\` | Create a ${ent.Name} entity instance. |
102
+ const article = /^[aeiou]/i.test(ent.Name) ? 'an' : 'a'
103
+ Content(`| \`${ent.Name}\` | \`(data map[string]any) ${model.const.Name}Entity\` | Create ${article} ${ent.Name} entity instance. |
60
104
  `)
61
105
  })
62
106
 
@@ -67,11 +111,7 @@ All entities implement the \`${model.const.Name}Entity\` interface.
67
111
 
68
112
  | Method | Signature | Description |
69
113
  | --- | --- | --- |
70
- | \`Load\` | \`(reqmatch, ctrl map[string]any) (any, error)\` | Load a single entity by match criteria. |
71
- | \`List\` | \`(reqmatch, ctrl map[string]any) (any, error)\` | List entities matching the criteria. |
72
- | \`Create\` | \`(reqdata, ctrl map[string]any) (any, error)\` | Create a new entity. |
73
- | \`Update\` | \`(reqdata, ctrl map[string]any) (any, error)\` | Update an existing entity. |
74
- | \`Remove\` | \`(reqmatch, ctrl map[string]any) (any, error)\` | Remove an entity. |
114
+ ${opRows}
75
115
  | \`Data\` | \`(args ...any) any\` | Get or set entity data. |
76
116
  | \`Match\` | \`(args ...any) any\` | Get or set entity match criteria. |
77
117
  | \`Make\` | \`() Entity\` | Create a new instance with the same options. |
@@ -79,17 +119,23 @@ All entities implement the \`${model.const.Name}Entity\` interface.
79
119
 
80
120
  ### Result shape
81
121
 
82
- Entity operations return \`(any, error)\`. The \`any\` value is a
83
- \`map[string]any\` with these keys:
122
+ Entity operations return \`(value, error)\`. The \`value\` is the
123
+ operation's data **directly** — there is no wrapper:
84
124
 
85
- | Key | Type | Description |
86
- | --- | --- | --- |
87
- | \`"ok"\` | \`bool\` | \`true\` if the HTTP status is 2xx. |
88
- | \`"status"\` | \`int\` | HTTP status code. |
89
- | \`"headers"\` | \`map[string]any\` | Response headers. |
90
- | \`"data"\` | \`any\` | Parsed JSON response body. |
125
+ | Operation | \`value\` |
126
+ | --- | --- |
127
+ ${resultShapeRows}
128
+
129
+ Check \`err\` first, then use the value directly (or the typed
130
+ \`...Typed\` variants, which return the entity's model struct and a typed
131
+ slice):
132
+
133
+ ${firstEntityVar}, err := client.${firstEntityName}(nil).${firstPrimaryMethod}(${firstOpArg}, nil)
134
+ if err != nil { /* handle */ }
135
+ // ${firstEntityVar} is the returned record
91
136
 
92
- On error, \`"ok"\` is \`false\` and \`"err"\` contains the error value.
137
+ Only \`Direct()\` returns a response envelope a \`map[string]any\` with
138
+ \`"ok"\`, \`"status"\`, \`"headers"\`, and \`"data"\` keys.
93
139
 
94
140
  `)
95
141
 
@@ -1,12 +1,13 @@
1
1
 
2
- import { cmp, each, Content } from '@voxgig/sdkgen'
2
+ import { cmp, each, Content, envName, isAuthActive } from '@voxgig/sdkgen'
3
3
 
4
4
 
5
5
  const ReadmeOptions = cmp(function ReadmeOptions(props: any) {
6
6
  const { target } = props
7
7
  const { model } = props.ctx$
8
8
 
9
- const publishedOptions = each(target.options).filter((option: any) => option.publish)
9
+ const publishedOptions = each(target.options).filter((option: any) =>
10
+ option.publish && ('apikey' !== option.name || isAuthActive(model)))
10
11
  if (0 === publishedOptions.length) {
11
12
  return
12
13
  }
@@ -25,7 +26,7 @@ client := sdk.New${model.const.Name}SDK(map[string]any{
25
26
 
26
27
  publishedOptions.map((option: any) => {
27
28
  if ('apikey' === option.name) {
28
- Content(` "${option.name}": os.Getenv("${model.NAME}_APIKEY"),
29
+ Content(` "${option.name}": os.Getenv("${envName(model)}_APIKEY"),
29
30
  `)
30
31
  }
31
32
  else {
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, each, Content, isAuthActive } from '@voxgig/sdkgen'
2
+ import { cmp, Content, isAuthActive, envName, canonKey, opRequestShape, entityIdField, safeVarName } from '@voxgig/sdkgen'
3
3
 
4
4
  import {
5
5
  KIT,
@@ -8,156 +8,165 @@ import {
8
8
  } from '@voxgig/apidef'
9
9
 
10
10
 
11
+ // Emits the go/README.md Quickstart as ONE complete, compilable program.
12
+ // Every entity operation returns `(value, error)` where `value` is the
13
+ // data itself — NOT a `{ok, data, ...}` envelope (only Direct returns
14
+ // that). So examples check `err` and use the value directly. The whole
15
+ // program is compiled by the README snippet test (readme_examples_test.go).
11
16
  const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
12
17
  const { target, ctx$: { model } } = props
13
18
 
14
19
  const entity = getModelPath(model, `main.${KIT}.entity`)
15
20
  // Go module path == repo path on GitHub (org from model.origin).
16
- const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
21
+ const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
17
22
 
18
- // Find the first published entity for examples
19
23
  const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
20
24
 
21
- // Find a nested entity if available
22
- const nestedEntity = Object.values(entity).find((e: any) =>
23
- e.active !== false && e.ancestors && e.ancestors.length > 0
24
- ) as any
25
-
26
25
  const authActive = isAuthActive(model)
27
- const goImports = authActive
28
- ? ` "fmt"\n "os"\n`
29
- : ` "fmt"\n`
30
- const apikeyArg = authActive
31
- ? `\n "apikey": os.Getenv("${model.NAME}_APIKEY"),\n `
32
- : ''
33
-
34
- Content(`### 1. Create a client
26
+ const ctor = authActive
27
+ ? `sdk.New${model.const.Name}SDK(map[string]any{\n "apikey": os.Getenv("${envName(model)}_APIKEY"),\n })`
28
+ : `sdk.New()`
35
29
 
36
- \`\`\`go
37
- package main
38
-
39
- import (
40
- ${goImports}
41
- sdk "${gomodule}"
42
- "${gomodule}/core"
43
- )
44
-
45
- func main() {
46
- client := sdk.New${model.const.Name}SDK(map[string]any{${apikeyArg}})
47
- \`\`\`
48
-
49
- `)
30
+ // Build the body of main() from the operations the example entity
31
+ // supports. Each op names a fresh value var, so `:=` always declares a
32
+ // new variable (reusing `err`), and every var is used (printed).
33
+ const body: string[] = []
34
+ let usesFmt = false
50
35
 
51
36
  if (exampleEntity) {
52
37
  const eName = nom(exampleEntity, 'Name')
38
+ // Variable-safe lowercase name — a `Type`/`Range` entity must not bind a Go
39
+ // keyword (`type, err := ...` fails `go build`).
40
+ const eLower = safeVarName(eName.toLowerCase(), 'go')
53
41
  const opnames = Object.keys(exampleEntity.op || {})
54
42
 
55
- if (opnames.includes('list')) {
56
- Content(`### 2. List ${eName.toLowerCase()}s
57
-
58
- \`\`\`go
59
- result, err := client.${eName}(nil).List(nil, nil)
60
- if err != nil {
61
- panic(err)
43
+ // Model-driven example fields (from the same op shape the request types are
44
+ // built from) so create/update reference REAL writable fields, not a
45
+ // hardcoded "name", and ids use a type-correct literal.
46
+ const idField = (exampleEntity.id && exampleEntity.id.field) || 'id'
47
+ // Model-driven id key: null when the entity has no id-like field (a
48
+ // response-wrapped spec). When null, load/remove pass a nil match and
49
+ // update omits the id member.
50
+ const idF = entityIdField(exampleEntity)
51
+ const goLit = (type: any): string => {
52
+ const k = canonKey(type)
53
+ if ('INTEGER' === k || 'NUMBER' === k) return '1'
54
+ if ('BOOLEAN' === k) return 'true'
55
+ if ('ARRAY' === k) return '[]any{}'
56
+ if ('OBJECT' === k) return 'map[string]any{}'
57
+ return '"example"'
62
58
  }
63
-
64
- rm := core.ToMapAny(result)
65
- if rm["ok"] == true {
66
- for _, item := range rm["data"].([]any) {
67
- p := core.ToMapAny(item)
68
- fmt.Println(p["id"], p["name"])
69
- }
59
+ const examplePairs = (opname: string): string[] => {
60
+ const items = opRequestShape(exampleEntity, opname).items
61
+ .filter((it: any) => it.name !== idField && it.name !== 'id')
62
+ const required = items.filter((it: any) => !it.optional)
63
+ const chosen = 'create' === opname
64
+ ? (required.length ? required : items.slice(0, 2))
65
+ : items.slice(0, 2)
66
+ return chosen.map((it: any) => `"${it.name}": ${goLit(it.type)}`)
70
67
  }
71
- \`\`\`
68
+ const idOp = opnames.includes('load') ? 'load' : (opnames.includes('update') ? 'update' : 'remove')
69
+ const idShape = opRequestShape(exampleEntity, idOp)
70
+ .items.find((it: any) => it.name === idField || it.name === 'id')
71
+ const idLit = idShape ? goLit(idShape.type) : '"example_id"'
72
72
 
73
- `)
73
+ if (opnames.includes('list')) {
74
+ body.push(` // List ${eLower} records — the value is the array of records itself.`)
75
+ body.push(` ${eLower}s, err := client.${eName}(nil).List(nil, nil)`)
76
+ body.push(` if err != nil {`)
77
+ body.push(` panic(err)`)
78
+ body.push(` }`)
79
+ body.push(` for _, item := range ${eLower}s.([]any) {`)
80
+ body.push(` fmt.Println(item)`)
81
+ body.push(` }`)
82
+ body.push(``)
83
+ usesFmt = true
74
84
  }
75
85
 
76
- if (nestedEntity && opnames.includes('load')) {
77
- const neName = nom(nestedEntity, 'Name')
78
- const parentFields = (nestedEntity.fields || [])
79
- .filter((f: any) => f.name !== 'id' && f.name.endsWith('_id'))
80
- const parentParam = parentFields.length > 0 ? parentFields[0].name : 'parent_id'
81
-
82
- Content(`### 3. Load a ${neName.toLowerCase()}
83
-
84
- ${neName} is nested under ${eName}, so provide the \`${parentParam}\`:
85
-
86
- \`\`\`go
87
- ${neName.toLowerCase()} := client.${neName}(nil)
88
- result, err = ${neName.toLowerCase()}.Load(
89
- map[string]any{"${parentParam}": "example", "id": "example_id"}, nil,
90
- )
91
- if err != nil {
92
- panic(err)
86
+ if (opnames.includes('load')) {
87
+ body.push(` // Load a single ${eLower} — the value is the loaded record.`)
88
+ body.push(` ${eLower}, err := client.${eName}(nil).Load(${idF ? `map[string]any{"${idF}": ${idLit}}` : 'nil'}, nil)`)
89
+ body.push(` if err != nil {`)
90
+ body.push(` panic(err)`)
91
+ body.push(` }`)
92
+ body.push(` fmt.Println(${eLower})`)
93
+ body.push(``)
94
+ usesFmt = true
93
95
  }
94
96
 
95
- rm = core.ToMapAny(result)
96
- if rm["ok"] == true {
97
- fmt.Println(rm["data"])
97
+ if (opnames.includes('create')) {
98
+ body.push(` // Create a ${eLower}.`)
99
+ body.push(` created, err := client.${eName}(nil).Create(map[string]any{${examplePairs('create').join(', ')}}, nil)`)
100
+ body.push(` if err != nil {`)
101
+ body.push(` panic(err)`)
102
+ body.push(` }`)
103
+ body.push(` fmt.Println(created)`)
104
+ body.push(``)
105
+ usesFmt = true
98
106
  }
99
- }
100
- \`\`\`
101
107
 
102
- `)
108
+ if (opnames.includes('update')) {
109
+ body.push(` // Update a ${eLower}.`)
110
+ body.push(` updated, err := client.${eName}(nil).Update(map[string]any{${(idF ? [`"${idF}": ${idLit}`] : []).concat(examplePairs('update')).join(', ')}}, nil)`)
111
+ body.push(` if err != nil {`)
112
+ body.push(` panic(err)`)
113
+ body.push(` }`)
114
+ body.push(` fmt.Println(updated)`)
115
+ body.push(``)
116
+ usesFmt = true
103
117
  }
104
- else if (opnames.includes('load')) {
105
- Content(`### 3. Load a ${eName.toLowerCase()}
106
118
 
107
- \`\`\`go
108
- result, err = client.${eName}(nil).Load(
109
- map[string]any{"id": "example_id"}, nil,
110
- )
111
- if err != nil {
112
- panic(err)
119
+ if (opnames.includes('remove')) {
120
+ body.push(` // Remove a ${eLower}.`)
121
+ body.push(` removed, err := client.${eName}(nil).Remove(${idF ? `map[string]any{"${idF}": ${idLit}}` : 'nil'}, nil)`)
122
+ body.push(` if err != nil {`)
123
+ body.push(` panic(err)`)
124
+ body.push(` }`)
125
+ body.push(` fmt.Println(removed)`)
126
+ body.push(``)
127
+ usesFmt = true
113
128
  }
129
+ }
114
130
 
115
- rm = core.ToMapAny(result)
116
- if rm["ok"] == true {
117
- fmt.Println(rm["data"])
118
- }
119
- }
120
- \`\`\`
131
+ // Drop trailing blank lines from the body.
132
+ while (body.length > 0 && body[body.length - 1] === '') {
133
+ body.pop()
134
+ }
121
135
 
122
- `)
123
- }
136
+ const imports: string[] = []
137
+ if (usesFmt) imports.push(` "fmt"`)
138
+ if (authActive) imports.push(` "os"`)
139
+ imports.push(` sdk "${gomodule}"`)
124
140
 
125
- // CRUD operations
126
- if (opnames.includes('create') || opnames.includes('update') || opnames.includes('remove')) {
127
- Content(`### 4. Create, update, and remove
141
+ let program = `package main
128
142
 
129
- \`\`\`go
130
- `)
131
- if (opnames.includes('create')) {
132
- Content(`// Create
133
- created, _ := client.${eName}(nil).Create(
134
- map[string]any{"name": "Example"}, nil,
143
+ import (
144
+ ${imports.join('\n')}
135
145
  )
136
- cm := core.ToMapAny(created)
137
- newID := core.ToMapAny(cm["data"])["id"]
138
146
 
139
- `)
140
- }
141
- if (opnames.includes('update')) {
142
- Content(`// Update
143
- client.${eName}(nil).Update(
144
- map[string]any{"id": newID, "name": "Example-Renamed"}, nil,
145
- )
147
+ func main() {
148
+ client := ${ctor}
146
149
 
147
- `)
148
- }
149
- if (opnames.includes('remove')) {
150
- Content(`// Remove
151
- client.${eName}(nil).Remove(
152
- map[string]any{"id": newID}, nil,
153
- )
154
- `)
155
- }
156
- Content(`\`\`\`
150
+ `
151
+ if (body.length > 0) {
152
+ program += body.join('\n') + '\n'
153
+ } else {
154
+ program += ` _ = client\n`
155
+ }
156
+ program += `}`
157
+
158
+ Content(`### Quickstart
159
+
160
+ A complete program: create a client, then call the entity operations.
161
+ Each operation returns \`(value, error)\` — the value is the data itself
162
+ (there is no \`{ok, data}\` wrapper), so check \`err\` and use the value
163
+ directly.
164
+
165
+ \`\`\`go
166
+ ${program}
167
+ \`\`\`
157
168
 
158
169
  `)
159
- }
160
- }
161
170
 
162
171
  })
163
172