@voxgig/sdkgen 1.2.1 → 1.3.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 (345) hide show
  1. package/bin/voxgig-sdkgen +2 -2
  2. package/dist/action/action.d.ts +3 -1
  3. package/dist/action/action.js +26 -10
  4. package/dist/action/action.js.map +1 -1
  5. package/dist/action/feature.js +9 -8
  6. package/dist/action/feature.js.map +1 -1
  7. package/dist/action/target.d.ts +7 -1
  8. package/dist/action/target.js +22 -13
  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 +225 -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 +12 -2
  53. package/dist/sdkgen.js +60 -20
  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.d.ts +2 -1
  59. package/dist/utility.js +39 -11
  60. package/dist/utility.js.map +1 -1
  61. package/model/sdkgen.aontu +137 -0
  62. package/package.json +11 -5
  63. package/project/.sdk/model/feature/feature-index.aontu +5 -0
  64. package/project/.sdk/model/target/go-cli.aontu +47 -0
  65. package/project/.sdk/model/target/go-mcp.aontu +41 -0
  66. package/project/.sdk/model/target/go.aontu +28 -0
  67. package/project/.sdk/model/target/{js.jsonic → js.aontu} +13 -0
  68. package/project/.sdk/model/target/{lua.jsonic → lua.aontu} +13 -0
  69. package/project/.sdk/model/target/{php.jsonic → php.aontu} +13 -0
  70. package/project/.sdk/model/target/{py.jsonic → py.aontu} +13 -0
  71. package/project/.sdk/model/target/{rb.jsonic → rb.aontu} +13 -0
  72. package/project/.sdk/model/target/{ts.jsonic → ts.aontu} +13 -0
  73. package/project/.sdk/src/cmp/go/Config_go.ts +3 -2
  74. package/project/.sdk/src/cmp/go/EntityOperation_go.ts +1 -0
  75. package/project/.sdk/src/cmp/go/EntityTypes_go.ts +197 -0
  76. package/project/.sdk/src/cmp/go/Entity_go.ts +2 -1
  77. package/project/.sdk/src/cmp/go/MainEntity_go.ts +6 -0
  78. package/project/.sdk/src/cmp/go/Main_go.ts +23 -3
  79. package/project/.sdk/src/cmp/go/Package_go.ts +1 -1
  80. package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +48 -10
  81. package/project/.sdk/src/cmp/go/ReadmeExamplesTest_go.ts +688 -0
  82. package/project/.sdk/src/cmp/go/ReadmeExplanation_go.ts +1 -1
  83. package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +52 -8
  84. package/project/.sdk/src/cmp/go/ReadmeInstall_go.ts +11 -6
  85. package/project/.sdk/src/cmp/go/ReadmeIntro_go.ts +40 -1
  86. package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +67 -17
  87. package/project/.sdk/src/cmp/go/ReadmeOptions_go.ts +4 -3
  88. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +146 -116
  89. package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +87 -21
  90. package/project/.sdk/src/cmp/go/ReadmeTopHowto_go.ts +4 -0
  91. package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +75 -16
  92. package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +35 -5
  93. package/project/.sdk/src/cmp/go/TestEntity_go.ts +1 -1
  94. package/project/.sdk/src/cmp/go/Test_go.ts +5 -1
  95. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +21 -0
  96. package/project/.sdk/src/cmp/go/fragment/EntityCreateOp.fragment.go +11 -0
  97. package/project/.sdk/src/cmp/go/fragment/EntityListOp.fragment.go +11 -0
  98. package/project/.sdk/src/cmp/go/fragment/EntityLoadOp.fragment.go +11 -0
  99. package/project/.sdk/src/cmp/go/fragment/EntityRemoveOp.fragment.go +11 -0
  100. package/project/.sdk/src/cmp/go/fragment/EntityUpdateOp.fragment.go +11 -0
  101. package/project/.sdk/src/cmp/go/utility_go.ts +70 -0
  102. package/project/.sdk/src/cmp/go-cli/Main_go-cli.ts +195 -0
  103. package/project/.sdk/src/cmp/go-cli/fragment/main.fragment.go +106 -0
  104. package/project/.sdk/src/cmp/go-cli/fragment/words.fragment.go +132 -0
  105. package/project/.sdk/src/cmp/go-mcp/Main_go-mcp.ts +184 -0
  106. package/project/.sdk/src/cmp/go-mcp/fragment/main.fragment.go +68 -0
  107. package/project/.sdk/src/cmp/go-mcp/fragment/tools.fragment.go +114 -0
  108. package/project/.sdk/src/cmp/js/Config_js.ts +3 -6
  109. package/project/.sdk/src/cmp/js/EntityTypes_js.ts +111 -0
  110. package/project/.sdk/src/cmp/js/MainEntity_js.ts +1 -0
  111. package/project/.sdk/src/cmp/js/Main_js.ts +3 -0
  112. package/project/.sdk/src/cmp/js/Package_js.ts +16 -7
  113. package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +33 -10
  114. package/project/.sdk/src/cmp/js/ReadmeExplanation_js.ts +2 -2
  115. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +52 -11
  116. package/project/.sdk/src/cmp/js/ReadmeIntro_js.ts +39 -1
  117. package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +50 -18
  118. package/project/.sdk/src/cmp/js/ReadmeOptions_js.ts +4 -3
  119. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +70 -20
  120. package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +50 -16
  121. package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +3 -0
  122. package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +45 -19
  123. package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +35 -3
  124. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +5 -0
  125. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +5 -0
  126. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +5 -0
  127. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +5 -0
  128. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +5 -0
  129. package/project/.sdk/src/cmp/js/utility_js.ts +57 -0
  130. package/project/.sdk/src/cmp/lua/Config_lua.ts +3 -2
  131. package/project/.sdk/src/cmp/lua/EntityTypes_lua.ts +113 -0
  132. package/project/.sdk/src/cmp/lua/MainEntity_lua.ts +8 -0
  133. package/project/.sdk/src/cmp/lua/Main_lua.ts +4 -0
  134. package/project/.sdk/src/cmp/lua/Package_lua.ts +23 -4
  135. package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +50 -13
  136. package/project/.sdk/src/cmp/lua/ReadmeExamplesTest_lua.ts +293 -0
  137. package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +46 -8
  138. package/project/.sdk/src/cmp/lua/ReadmeInstall_lua.ts +19 -3
  139. package/project/.sdk/src/cmp/lua/ReadmeIntro_lua.ts +38 -1
  140. package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +51 -16
  141. package/project/.sdk/src/cmp/lua/ReadmeOptions_lua.ts +4 -3
  142. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +156 -21
  143. package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +71 -23
  144. package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +46 -9
  145. package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +43 -5
  146. package/project/.sdk/src/cmp/lua/Test_lua.ts +4 -0
  147. package/project/.sdk/src/cmp/lua/fragment/EntityCreateOp.fragment.lua +4 -0
  148. package/project/.sdk/src/cmp/lua/fragment/EntityListOp.fragment.lua +4 -0
  149. package/project/.sdk/src/cmp/lua/fragment/EntityLoadOp.fragment.lua +4 -0
  150. package/project/.sdk/src/cmp/lua/fragment/EntityRemoveOp.fragment.lua +4 -0
  151. package/project/.sdk/src/cmp/lua/fragment/EntityUpdateOp.fragment.lua +4 -0
  152. package/project/.sdk/src/cmp/php/Config_php.ts +3 -2
  153. package/project/.sdk/src/cmp/php/EntityTypes_php.ts +142 -0
  154. package/project/.sdk/src/cmp/php/MainEntity_php.ts +18 -1
  155. package/project/.sdk/src/cmp/php/Main_php.ts +4 -0
  156. package/project/.sdk/src/cmp/php/Package_php.ts +18 -7
  157. package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +46 -14
  158. package/project/.sdk/src/cmp/php/ReadmeExamplesTest_php.ts +401 -0
  159. package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +56 -13
  160. package/project/.sdk/src/cmp/php/ReadmeInstall_php.ts +15 -3
  161. package/project/.sdk/src/cmp/php/ReadmeIntro_php.ts +40 -1
  162. package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +26 -8
  163. package/project/.sdk/src/cmp/php/ReadmeOptions_php.ts +4 -3
  164. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +159 -25
  165. package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +90 -45
  166. package/project/.sdk/src/cmp/php/ReadmeTopHowto_php.ts +1 -1
  167. package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +43 -11
  168. package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +52 -11
  169. package/project/.sdk/src/cmp/php/TestDirect_php.ts +9 -9
  170. package/project/.sdk/src/cmp/php/TestEntity_php.ts +6 -12
  171. package/project/.sdk/src/cmp/php/Test_php.ts +4 -0
  172. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +13 -1
  173. package/project/.sdk/src/cmp/php/fragment/EntityCreateOp.fragment.php +10 -1
  174. package/project/.sdk/src/cmp/php/fragment/EntityListOp.fragment.php +10 -1
  175. package/project/.sdk/src/cmp/php/fragment/EntityLoadOp.fragment.php +10 -1
  176. package/project/.sdk/src/cmp/php/fragment/EntityRemoveOp.fragment.php +10 -1
  177. package/project/.sdk/src/cmp/php/fragment/EntityUpdateOp.fragment.php +10 -1
  178. package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +22 -14
  179. package/project/.sdk/src/cmp/py/Config_py.ts +3 -2
  180. package/project/.sdk/src/cmp/py/EntityTypes_py.ts +184 -0
  181. package/project/.sdk/src/cmp/py/Entity_py.ts +27 -0
  182. package/project/.sdk/src/cmp/py/MainEntity_py.ts +2 -1
  183. package/project/.sdk/src/cmp/py/Main_py.ts +35 -0
  184. package/project/.sdk/src/cmp/py/Package_py.ts +24 -3
  185. package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +48 -14
  186. package/project/.sdk/src/cmp/py/ReadmeExamplesTest_py.ts +626 -0
  187. package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +53 -14
  188. package/project/.sdk/src/cmp/py/ReadmeInstall_py.ts +19 -3
  189. package/project/.sdk/src/cmp/py/ReadmeIntro_py.ts +48 -1
  190. package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +28 -10
  191. package/project/.sdk/src/cmp/py/ReadmeOptions_py.ts +4 -3
  192. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +150 -27
  193. package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +86 -40
  194. package/project/.sdk/src/cmp/py/ReadmeTopHowto_py.ts +1 -1
  195. package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +45 -11
  196. package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +43 -5
  197. package/project/.sdk/src/cmp/py/TestDirect_py.ts +7 -9
  198. package/project/.sdk/src/cmp/py/TestEntity_py.ts +6 -14
  199. package/project/.sdk/src/cmp/py/Test_py.ts +4 -0
  200. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +5 -2
  201. package/project/.sdk/src/cmp/py/fragment/EntityCreateOp.fragment.py +1 -1
  202. package/project/.sdk/src/cmp/py/fragment/EntityListOp.fragment.py +5 -1
  203. package/project/.sdk/src/cmp/py/fragment/EntityLoadOp.fragment.py +6 -1
  204. package/project/.sdk/src/cmp/py/fragment/EntityRemoveOp.fragment.py +6 -1
  205. package/project/.sdk/src/cmp/py/fragment/EntityUpdateOp.fragment.py +1 -1
  206. package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +17 -10
  207. package/project/.sdk/src/cmp/rb/Config_rb.ts +3 -2
  208. package/project/.sdk/src/cmp/rb/EntityTypes_rb.ts +136 -0
  209. package/project/.sdk/src/cmp/rb/MainEntity_rb.ts +1 -0
  210. package/project/.sdk/src/cmp/rb/Main_rb.ts +4 -0
  211. package/project/.sdk/src/cmp/rb/Package_rb.ts +34 -7
  212. package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +47 -13
  213. package/project/.sdk/src/cmp/rb/ReadmeExamplesTest_rb.ts +289 -0
  214. package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +72 -21
  215. package/project/.sdk/src/cmp/rb/ReadmeInstall_rb.ts +16 -4
  216. package/project/.sdk/src/cmp/rb/ReadmeIntro_rb.ts +40 -1
  217. package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +29 -12
  218. package/project/.sdk/src/cmp/rb/ReadmeOptions_rb.ts +4 -3
  219. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +163 -25
  220. package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +85 -40
  221. package/project/.sdk/src/cmp/rb/ReadmeTopHowto_rb.ts +1 -1
  222. package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +45 -11
  223. package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +54 -11
  224. package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +9 -9
  225. package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +6 -12
  226. package/project/.sdk/src/cmp/rb/Test_rb.ts +4 -0
  227. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +2 -0
  228. package/project/.sdk/src/cmp/rb/fragment/EntityCreateOp.fragment.rb +5 -0
  229. package/project/.sdk/src/cmp/rb/fragment/EntityListOp.fragment.rb +20 -2
  230. package/project/.sdk/src/cmp/rb/fragment/EntityLoadOp.fragment.rb +8 -1
  231. package/project/.sdk/src/cmp/rb/fragment/EntityRemoveOp.fragment.rb +6 -1
  232. package/project/.sdk/src/cmp/rb/fragment/EntityUpdateOp.fragment.rb +5 -0
  233. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +24 -8
  234. package/project/.sdk/src/cmp/ts/Config_ts.ts +3 -6
  235. package/project/.sdk/src/cmp/ts/EntityTypes_ts.ts +105 -0
  236. package/project/.sdk/src/cmp/ts/Entity_ts.ts +17 -1
  237. package/project/.sdk/src/cmp/ts/MainEntity_ts.ts +1 -0
  238. package/project/.sdk/src/cmp/ts/Main_ts.ts +6 -0
  239. package/project/.sdk/src/cmp/ts/Package_ts.ts +14 -7
  240. package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +32 -10
  241. package/project/.sdk/src/cmp/ts/ReadmeExampleTest_ts.ts +81 -0
  242. package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +446 -0
  243. package/project/.sdk/src/cmp/ts/ReadmeExplanation_ts.ts +2 -2
  244. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +57 -11
  245. package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts +19 -6
  246. package/project/.sdk/src/cmp/ts/ReadmeIntro_ts.ts +39 -1
  247. package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +50 -18
  248. package/project/.sdk/src/cmp/ts/ReadmeOptions_ts.ts +4 -3
  249. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +141 -48
  250. package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +50 -16
  251. package/project/.sdk/src/cmp/ts/ReadmeTopHowto_ts.ts +3 -0
  252. package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +58 -19
  253. package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +35 -3
  254. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +2 -2
  255. package/project/.sdk/src/cmp/ts/Test_ts.ts +5 -0
  256. package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +3 -1
  257. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +10 -5
  258. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +4 -2
  259. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +4 -2
  260. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +4 -2
  261. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +4 -2
  262. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +4 -2
  263. package/project/.sdk/src/cmp/ts/utility_ts.ts +59 -0
  264. package/project/.sdk/tm/go/LICENSE +1 -1
  265. package/project/.sdk/tm/go/Makefile +36 -1
  266. package/project/.sdk/tm/go/VERSION +1 -0
  267. package/project/.sdk/tm/go/core/context.go +12 -7
  268. package/project/.sdk/tm/go-cli/src/feature/README.md +6 -0
  269. package/project/.sdk/tm/go-cli/src/feature/base/.gitkeep +0 -0
  270. package/project/.sdk/tm/go-cli/src/feature/log/.gitkeep +0 -0
  271. package/project/.sdk/tm/go-cli/src/feature/test/.gitkeep +0 -0
  272. package/project/.sdk/tm/go-mcp/src/feature/README.md +6 -0
  273. package/project/.sdk/tm/go-mcp/src/feature/base/.gitkeep +0 -0
  274. package/project/.sdk/tm/go-mcp/src/feature/log/.gitkeep +0 -0
  275. package/project/.sdk/tm/go-mcp/src/feature/test/.gitkeep +0 -0
  276. package/project/.sdk/tm/js/LICENSE +1 -1
  277. package/project/.sdk/tm/js/Makefile +41 -0
  278. package/project/.sdk/tm/lua/LICENSE +1 -1
  279. package/project/.sdk/tm/lua/Makefile +40 -1
  280. package/project/.sdk/tm/lua/core/context.lua +13 -8
  281. package/project/.sdk/tm/php/LICENSE +1 -1
  282. package/project/.sdk/tm/php/Makefile +31 -1
  283. package/project/.sdk/tm/php/VERSION +1 -0
  284. package/project/.sdk/tm/php/core/Context.php +12 -6
  285. package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +13 -4
  286. package/project/.sdk/tm/php/utility/Done.php +2 -2
  287. package/project/.sdk/tm/php/utility/MakeError.php +3 -3
  288. package/project/.sdk/tm/py/LICENSE +1 -1
  289. package/project/.sdk/tm/py/Makefile +34 -1
  290. package/project/.sdk/tm/py/core/context.py +12 -7
  291. package/project/.sdk/tm/py/test/test_primary_utility.py +15 -4
  292. package/project/.sdk/tm/py/test/test_struct_utility.py +1 -1
  293. package/project/.sdk/tm/py/utility/done.py +3 -1
  294. package/project/.sdk/tm/py/utility/make_error.py +2 -2
  295. package/project/.sdk/tm/rb/LICENSE +1 -1
  296. package/project/.sdk/tm/rb/Makefile +36 -2
  297. package/project/.sdk/tm/rb/core/context.rb +8 -3
  298. package/project/.sdk/tm/rb/test/primary_utility_test.rb +2 -2
  299. package/project/.sdk/tm/rb/utility/done.rb +3 -1
  300. package/project/.sdk/tm/rb/utility/make_error.rb +5 -2
  301. package/project/.sdk/tm/ts/LICENSE +1 -1
  302. package/project/.sdk/tm/ts/Makefile +42 -0
  303. package/project/.sdk/tm/ts/src/Context.ts +8 -3
  304. package/src/action/action.ts +30 -11
  305. package/src/action/feature.ts +12 -14
  306. package/src/action/target.ts +28 -17
  307. package/src/cmp/Changelog.ts +34 -0
  308. package/src/cmp/Deploy.ts +258 -0
  309. package/src/cmp/FeatureHook.ts +6 -8
  310. package/src/cmp/License.ts +49 -0
  311. package/src/cmp/Readme.ts +2 -0
  312. package/src/cmp/ReadmeErrors.ts +257 -0
  313. package/src/cmp/ReadmeExplanation.ts +250 -230
  314. package/src/cmp/ReadmeModel.ts +7 -2
  315. package/src/cmp/ReadmeTop.ts +411 -95
  316. package/src/cmp/Security.ts +41 -0
  317. package/src/helpers/canonType.ts +89 -0
  318. package/src/helpers/collectDeps.ts +5 -3
  319. package/src/helpers/naming.ts +59 -0
  320. package/src/helpers/opExample.ts +170 -0
  321. package/src/helpers/opShape.ts +274 -0
  322. package/src/helpers/packageMeta.ts +236 -0
  323. package/src/sdkgen.ts +91 -23
  324. package/src/tsconfig.json +1 -0
  325. package/src/types.ts +85 -2
  326. package/src/utility.ts +45 -11
  327. package/README.md +0 -2
  328. package/dist/action/lang.d.ts +0 -2
  329. package/dist/action/lang.js +0 -68
  330. package/dist/action/lang.js.map +0 -1
  331. package/dist/cmp/Hook.d.ts +0 -2
  332. package/dist/cmp/Hook.js +0 -10
  333. package/dist/cmp/Hook.js.map +0 -1
  334. package/dist/cmp/Top.d.ts +0 -2
  335. package/dist/cmp/Top.js +0 -23
  336. package/dist/cmp/Top.js.map +0 -1
  337. package/dist/prepare-openapi.d.ts +0 -2
  338. package/dist/prepare-openapi.js +0 -37
  339. package/dist/prepare-openapi.js.map +0 -1
  340. package/model/sdkgen.jsonic +0 -74
  341. package/project/.sdk/model/feature/feature-index.jsonic +0 -5
  342. package/project/.sdk/model/target/go.jsonic +0 -22
  343. package/project/.sdk/tm/go/utility/struct/go.mod +0 -3
  344. /package/project/.sdk/model/feature/{log.jsonic → log.aontu} +0 -0
  345. /package/project/.sdk/model/feature/{test.jsonic → test.aontu} +0 -0
@@ -13,6 +13,43 @@ 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.
20
+ const opUnion = new Set<string>()
21
+ entityList.forEach((e: any) => Object.keys(e.op || {})
22
+ .forEach((o: string) => { if (e.op[o] && e.op[o].active !== false) opUnion.add(o) }))
23
+ const opRowDefs: Record<string, string> = {
24
+ load: '| `load` | `load(reqmatch?, ctrl?): Promise<Entity>` | Load a single entity by match criteria. |',
25
+ list: '| `list` | `list(reqmatch?, ctrl?): Promise<Entity[]>` | List entities matching the criteria. |',
26
+ create: '| `create` | `create(reqdata?, ctrl?): Promise<Entity>` | Create a new entity. |',
27
+ update: '| `update` | `update(reqdata?, ctrl?): Promise<Entity>` | Update an existing entity. |',
28
+ remove: '| `remove` | `remove(reqmatch?, ctrl?): Promise<void>` | Remove an entity. |',
29
+ }
30
+ const opRows = ['load', 'list', 'create', 'update', 'remove']
31
+ .filter((o) => opUnion.has(o)).map((o) => opRowDefs[o]).join('\n')
32
+
33
+ // Model-driven return-value bullets: describe only the operations that
34
+ // actually exist (single-object ops among load/create/update, plus
35
+ // list/remove) — never document return semantics for a missing op.
36
+ const singleOps = ['load', 'create', 'update'].filter((o) => opUnion.has(o))
37
+ .map((o) => '`' + o + '`')
38
+ const retBullets: string[] = []
39
+ if (singleOps.length) {
40
+ const joined = singleOps.length > 1
41
+ ? singleOps.slice(0, -1).join(', ') + ' and ' + singleOps[singleOps.length - 1]
42
+ : singleOps[0]
43
+ retBullets.push(`- ${joined} ${singleOps.length > 1 ? 'resolve' : 'resolves'} to a single entity object.`)
44
+ }
45
+ if (opUnion.has('list')) {
46
+ retBullets.push('- `list` resolves to an **array** of entity objects (iterate it directly;\n there is no `.data` and no `.ok`).')
47
+ }
48
+ if (opUnion.has('remove')) {
49
+ retBullets.push('- `remove` resolves to `undefined`.')
50
+ }
51
+ const returnBullets = retBullets.join('\n')
52
+
16
53
  const apikeyOptionRow = isAuthActive(model)
17
54
  ? '| `apikey` | `string` | API key for authentication. |\n'
18
55
  : ''
@@ -44,7 +81,8 @@ ${apikeyOptionRow}| \`base\` | \`string\` | Base URL of the API server. |
44
81
  `)
45
82
 
46
83
  each(entityList, (ent: any) => {
47
- Content(`| \`${ent.Name}(data?)\` | \`${ent.Name}Entity\` | Create a ${ent.Name} entity instance. |
84
+ const article = /^[aeiou]/i.test(ent.Name) ? 'an' : 'a'
85
+ Content(`| \`${ent.Name}(data?)\` | \`${ent.Name}Entity\` | Create ${article} ${ent.Name} entity instance. |
48
86
  `)
49
87
  })
50
88
 
@@ -64,29 +102,23 @@ All entities share the same interface.
64
102
 
65
103
  | Method | Signature | Description |
66
104
  | --- | --- | --- |
67
- | \`load\` | \`load(reqmatch?, ctrl?): Promise<Result>\` | Load a single entity by match criteria. |
68
- | \`list\` | \`list(reqmatch?, ctrl?): Promise<Result>\` | List entities matching the criteria. |
69
- | \`create\` | \`create(reqdata?, ctrl?): Promise<Result>\` | Create a new entity. |
70
- | \`update\` | \`update(reqdata?, ctrl?): Promise<Result>\` | Update an existing entity. |
71
- | \`remove\` | \`remove(reqmatch?, ctrl?): Promise<Result>\` | Remove an entity. |
72
- | \`data\` | \`data(data?): any\` | Get or set entity data. |
73
- | \`match\` | \`match(match?): any\` | Get or set entity match criteria. |
105
+ ${opRows}
106
+ | \`data\` | \`data(data?: Partial<Entity>): Entity\` | Get or set entity data. |
107
+ | \`match\` | \`match(match?: Partial<Entity>): Partial<Entity>\` | Get or set entity match criteria. |
74
108
  | \`make\` | \`make(): Entity\` | Create a new instance with the same options. |
75
109
  | \`client\` | \`client(): ${model.const.Name}SDK\` | Return the parent SDK client. |
76
110
  | \`entopts\` | \`entopts(): object\` | Return a copy of the entity options. |
77
111
 
78
- #### Result shape
112
+ #### Return values
79
113
 
80
- All entity operations return a Result object:
114
+ Entity operations resolve to the entity data directly there is no
115
+ result envelope:
81
116
 
82
- \`\`\`js
83
- {
84
- ok: true, // true if the HTTP status is 2xx
85
- status: 200, // HTTP status code
86
- headers: {}, // response headers
87
- data: {} // parsed JSON response body
88
- }
89
- \`\`\`
117
+ ${returnBullets}
118
+
119
+ On a failed request these methods **throw**, so wrap calls in
120
+ \`try\`/\`catch\` to handle errors. Only \`direct()\` returns the result
121
+ envelope described below.
90
122
 
91
123
  ### DirectResult shape
92
124
 
@@ -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 @@ const client = new ${model.Name}SDK({
25
26
 
26
27
  publishedOptions.map((option: any) => {
27
28
  if ('apikey' === option.name) {
28
- Content(` ${option.name}: process.env.${model.NAME}_APIKEY,
29
+ Content(` ${option.name}: process.env.${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, each, Content, isAuthActive, packageName, envName, opRequestShape, entityIdField, entityOps, safeVarName } from '@voxgig/sdkgen'
3
3
 
4
4
  import {
5
5
  KIT,
@@ -7,6 +7,8 @@ import {
7
7
  nom,
8
8
  } from '@voxgig/apidef'
9
9
 
10
+ import { exampleValue } from './utility_js'
11
+
10
12
 
11
13
  const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
12
14
  const { target, ctx$: { model } } = props
@@ -16,32 +18,77 @@ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
16
18
  // Find the first published entity for examples
17
19
  const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
18
20
 
19
- const apikeyArg = isAuthActive(model)
20
- ? `\n apikey: process.env.${model.NAME}_APIKEY,\n`
21
- : ''
21
+ const ctor = isAuthActive(model)
22
+ ? `new ${model.const.Name}SDK({\n apikey: process.env.${envName(model)}_APIKEY,\n})`
23
+ : `new ${model.const.Name}SDK()`
22
24
 
23
25
  Content(`
24
26
  ### Create a Client
25
27
 
26
28
  \`\`\`js
27
- const { ${model.const.Name}SDK } = require('${target.module.name}')
29
+ const { ${model.const.Name}SDK } = require('${packageName(model, target.name)}')
28
30
 
29
- const client = new ${model.const.Name}SDK({${apikeyArg}})
31
+ const client = ${ctor}
30
32
  \`\`\`
31
33
  `)
32
34
 
33
35
 
34
36
  if (exampleEntity) {
35
37
  const eName = nom(exampleEntity, 'Name')
36
- const opnames = Object.keys(exampleEntity.op || {})
38
+ const article = /^[aeiou]/i.test(eName) ? 'an' : 'a'
39
+ // ACTIVE ops only — an inactive op generates no method, so an example
40
+ // calling it would be wrong.
41
+ const opnames = entityOps(exampleEntity)
42
+
43
+ // Model-driven example fields, in parity with the ts target: derive the
44
+ // create/update body from the op shape (opRequestShape) so the docs show
45
+ // REAL writable fields, not a hardcoded field the entity may not have.
46
+ // `idF` is the entity's id-like field name, or null when it has none —
47
+ // then load/remove match on no argument and update omits the id.
48
+ const idF = entityIdField(exampleEntity)
49
+ // Variable-safe lowercase name (a `Delete` entity must not bind `delete`).
50
+ const eVar = safeVarName(exampleEntity.name, 'js')
51
+ const exampleFields = (opname: string): string[] => {
52
+ // ids are rendered separately as the match key for update/remove; a
53
+ // REQUIRED id stays for create (dropping it makes the payload
54
+ // incomplete).
55
+ const items = opRequestShape(exampleEntity, opname).items
56
+ .filter((it: any) => (it.name !== idF && it.name !== 'id') ||
57
+ ('create' === opname && !it.optional))
58
+ const required = items.filter((it: any) => !it.optional)
59
+ const optional = items.filter((it: any) => it.optional)
60
+ // create needs ALL required fields for parity with the typed ts target;
61
+ // update is a patch, so the required members plus a sample optional
62
+ // field or two suffice.
63
+ const chosen = 'create' === opname
64
+ ? (required.length ? required : items.slice(0, 2))
65
+ : required.concat(optional).slice(0, Math.max(2, required.length))
66
+ return chosen.map((it: any) =>
67
+ ` ${it.name}: ${exampleValue(exampleEntity, exampleEntity.op[opname], it.name, 'example_' + it.name)},`)
68
+ }
69
+
70
+ // The full REQUIRED match for load/remove (id first, then parent path
71
+ // params like page_id) — the same shape the runtime resolves path params
72
+ // from, so the example always carries the keys the route needs.
73
+ const matchArg = (opname: string): string => {
74
+ const matchItems = opRequestShape(exampleEntity, opname).items
75
+ .filter((it: any) => !it.optional || it.name === idF)
76
+ .sort((a: any, b: any) =>
77
+ (a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
78
+ return 0 < matchItems.length
79
+ ? `{ ${matchItems.map((it: any) =>
80
+ `${it.name}: ${exampleValue(exampleEntity, exampleEntity.op && exampleEntity.op[opname], it.name,
81
+ it.name === idF ? exampleEntity.name + '_id' : 'example_' + it.name)}`).join(', ')} }`
82
+ : ''
83
+ }
37
84
 
38
85
  if (opnames.includes('load')) {
39
86
  Content(`
40
- ### Load a ${eName}
87
+ ### Load ${article} ${eName}
41
88
 
42
89
  \`\`\`js
43
- const ${exampleEntity.name} = await client.${eName}().load({ id: '${exampleEntity.name}_id' })
44
- console.log(${exampleEntity.name})
90
+ const ${eVar} = await client.${eName}().load(${matchArg('load')})
91
+ console.log(${eVar})
45
92
  \`\`\`
46
93
  `)
47
94
  }
@@ -51,34 +98,37 @@ console.log(${exampleEntity.name})
51
98
  ### List ${eName} Records
52
99
 
53
100
  \`\`\`js
54
- const ${exampleEntity.name}s = await client.${eName}().list()
55
- console.log(${exampleEntity.name}s)
101
+ const ${eVar}s = await client.${eName}().list()
102
+ for (const ${eVar} of ${eVar}s) {
103
+ console.log(${eVar})
104
+ }
56
105
  \`\`\`
57
106
  `)
58
107
  }
59
108
 
60
109
  if (opnames.includes('create')) {
110
+ const createLines = exampleFields('create')
111
+ const createBody = createLines.length ? '\n' + createLines.join('\n') + '\n' : ''
61
112
  Content(`
62
113
  ### Create a ${eName}
63
114
 
64
115
  \`\`\`js
65
- const created = await client.${eName}().create({
66
- // Provide ${exampleEntity.name} fields
67
- })
116
+ const created = await client.${eName}().create({${createBody}})
68
117
  console.log(created)
69
118
  \`\`\`
70
119
  `)
71
120
  }
72
121
 
73
122
  if (opnames.includes('update')) {
123
+ const updateLines = (idF
124
+ ? [` ${idF}: ${exampleValue(exampleEntity, exampleEntity.op && exampleEntity.op.update, idF, exampleEntity.name + '_id')},`]
125
+ : []).concat(exampleFields('update'))
126
+ const updateBody = updateLines.length ? '\n' + updateLines.join('\n') + '\n' : ''
74
127
  Content(`
75
128
  ### Update a ${eName}
76
129
 
77
130
  \`\`\`js
78
- const updated = await client.${eName}().update({
79
- id: '${exampleEntity.name}_id',
80
- // Fields to update
81
- })
131
+ const updated = await client.${eName}().update({${updateBody}})
82
132
  console.log(updated)
83
133
  \`\`\`
84
134
  `)
@@ -89,7 +139,7 @@ console.log(updated)
89
139
  ### Remove a ${eName}
90
140
 
91
141
  \`\`\`js
92
- await client.${eName}().remove({ id: '${exampleEntity.name}_id' })
142
+ await client.${eName}().remove(${matchArg('remove')})
93
143
  \`\`\`
94
144
  `)
95
145
  }
@@ -1,11 +1,13 @@
1
1
 
2
- import { cmp, each, Content, File, isAuthActive } from '@voxgig/sdkgen'
2
+ import { cmp, each, Content, canonToType, File, isAuthActive, entityIdField, opRequestShape, safeVarName } from '@voxgig/sdkgen'
3
3
 
4
4
  import {
5
5
  KIT,
6
6
  getModelPath,
7
7
  } from '@voxgig/apidef'
8
8
 
9
+ import { exampleValue } from './utility_js'
10
+
9
11
 
10
12
  const OP_SIGNATURES: Record<string, { sig: string, returns: string, desc: string }> = {
11
13
  load: {
@@ -70,8 +72,7 @@ Create a new SDK client instance.
70
72
  | Name | Type | Description |
71
73
  | --- | --- | --- |
72
74
  | \`options\` | \`object\` | SDK configuration options. |
73
- | \`options.apikey\` | \`string\` | API key for authentication. |
74
- | \`options.base\` | \`string\` | Base URL for API requests. |
75
+ ${isAuthActive(model) ? '| \`options.apikey\` | \`string\` | API key for authentication. |\n' : ''}| \`options.base\` | \`string\` | Base URL for API requests. |
75
76
  | \`options.prefix\` | \`string\` | URL prefix appended after base. |
76
77
  | \`options.suffix\` | \`string\` | URL suffix appended after path. |
77
78
  | \`options.headers\` | \`object\` | Custom headers for all requests. |
@@ -180,6 +181,11 @@ Alias for \`${model.Name}SDK.test()\`.
180
181
  publishedEntities.map((ent: any) => {
181
182
  const opnames = Object.keys(ent.op || {})
182
183
  const fields = ent.fields || []
184
+ // Model-driven id key: null when this entity has no id-like field, in
185
+ // which case load/remove match on no argument and update omits the id.
186
+ const idF = entityIdField(ent)
187
+ // Variable-safe lowercase name (a `Delete` entity must not bind `delete`).
188
+ const eVar = safeVarName(ent.name, 'js')
183
189
 
184
190
  Content(`
185
191
  ---
@@ -195,7 +201,7 @@ Alias for \`${model.Name}SDK.test()\`.
195
201
  }
196
202
 
197
203
  Content(`\`\`\`ts
198
- const ${ent.name} = client.${ent.Name}()
204
+ const ${eVar} = client.${ent.Name}()
199
205
  \`\`\`
200
206
 
201
207
  `)
@@ -211,7 +217,7 @@ const ${ent.name} = client.${ent.Name}()
211
217
  each(fields, (field: any) => {
212
218
  const req = field.req ? 'Yes' : 'No'
213
219
  const desc = field.short || ''
214
- Content(`| \`${field.name}\` | \`${field.type || 'any'}\` | ${req} | ${desc} |
220
+ Content(`| \`${field.name}\` | \`${canonToType(field.type, target.name)}\` | ${req} | ${desc} |
215
221
  `)
216
222
  })
217
223
 
@@ -221,15 +227,18 @@ const ${ent.name} = client.${ent.Name}()
221
227
  // Field operations breakdown
222
228
  const hasFieldOps = fields.some((f: any) => f.op && Object.keys(f.op).length > 0)
223
229
  if (hasFieldOps) {
230
+ // Only emit columns for operations this entity actually exposes —
231
+ // never advertise a create/update/remove column the entity lacks.
232
+ const opcols = ['load', 'list', 'create', 'update', 'remove']
233
+ .filter((op: string) => opnames.includes(op) && ent.op[op]?.active !== false)
224
234
  Content(`### Field Usage by Operation
225
235
 
226
- | Field | load | list | create | update | remove |
227
- | --- | --- | --- | --- | --- | --- |
236
+ | Field | ${opcols.join(' | ')} |
237
+ | --- | ${opcols.map(() => '---').join(' | ')} |
228
238
  `)
229
239
  each(fields, (field: any) => {
230
240
  const fops = field.op || {}
231
- const cols = ['load', 'list', 'create', 'update', 'remove'].map((op: string) => {
232
- if (!opnames.includes(op)) return '-'
241
+ const cols = opcols.map((op: string) => {
233
242
  const fop = fops[op]
234
243
  if (null == fop) return '-'
235
244
  if (fop.active === false) return '-'
@@ -263,8 +272,20 @@ ${info.desc}
263
272
 
264
273
  // Show example
265
274
  if ('load' === opname || 'remove' === opname) {
275
+ // The id key plus every REQUIRED match key (parent path params
276
+ // like page_id) — the same shape the runtime resolves path
277
+ // params from, so the example always works.
278
+ const matchItems = opRequestShape(ent, opname).items
279
+ .filter((it: any) => !it.optional || it.name === idF)
280
+ .sort((a: any, b: any) =>
281
+ (a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
282
+ const arg = 0 < matchItems.length
283
+ ? `{ ${matchItems.map((it: any) =>
284
+ `${it.name}: ${exampleValue(ent, ent.op && ent.op[opname], it.name,
285
+ it.name === idF ? ent.name + '_id' : it.name)}`).join(', ')} }`
286
+ : ''
266
287
  Content(`\`\`\`ts
267
- const result = await client.${ent.Name}().${opname}({ id: '${ent.name}_id' })
288
+ const result = await client.${ent.Name}().${opname}(${arg})
268
289
  \`\`\`
269
290
 
270
291
  `)
@@ -277,14 +298,19 @@ const results = await client.${ent.Name}().${opname}()
277
298
  `)
278
299
  }
279
300
  else if ('create' === opname) {
301
+ // Members come from the SAME shape the runtime validates
302
+ // (opRequestShape): every required member must appear — including
303
+ // a required id and parent keys like page_id (the /* type */
304
+ // placeholders mark the block as an illustration); an
305
+ // all-optional create renders an empty — still valid — literal.
306
+ const createItems = opRequestShape(ent, 'create').items
307
+ .filter((it: any) => !it.optional)
280
308
  Content(`\`\`\`ts
281
309
  const result = await client.${ent.Name}().create({
282
310
  `)
283
- each(fields, (field: any) => {
284
- if ('id' !== field.name && field.req) {
285
- Content(` ${field.name}: /* ${field.type || 'value'} */,
311
+ createItems.map((it: any) => {
312
+ Content(` ${it.name}: /* ${canonToType(it.type, target.name)} */,
286
313
  `)
287
- }
288
314
  })
289
315
  Content(`})
290
316
  \`\`\`
@@ -292,10 +318,18 @@ const result = await client.${ent.Name}().create({
292
318
  `)
293
319
  }
294
320
  else if ('update' === opname) {
321
+ // The id key plus every REQUIRED data member — the same shape the
322
+ // runtime validates — then the patch-fields note.
323
+ const updateItems = opRequestShape(ent, 'update').items
324
+ .filter((it: any) => !it.optional || it.name === idF)
325
+ .sort((a: any, b: any) =>
326
+ (a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
327
+ const updateLines = updateItems.map((it: any) =>
328
+ ` ${it.name}: ${exampleValue(ent, ent.op && ent.op.update, it.name,
329
+ it.name === idF ? ent.name + '_id' : it.name)},\n`).join('')
295
330
  Content(`\`\`\`ts
296
331
  const result = await client.${ent.Name}().update({
297
- id: '${ent.name}_id',
298
- // Fields to update
332
+ ${updateLines} // Fields to update
299
333
  })
300
334
  \`\`\`
301
335
 
@@ -12,6 +12,9 @@ const result = await client.direct({
12
12
  method: 'GET',
13
13
  params: { id: 'example' },
14
14
  })
15
+ if (result instanceof Error) {
16
+ throw result
17
+ }
15
18
  console.log(result.data)
16
19
  \`\`\`
17
20
 
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, Content, isAuthActive } from '@voxgig/sdkgen'
2
+ import { cmp, Content, isAuthActive, packageName, envName, entityIdField, entityOps, opRequestShape, safeVarName } from '@voxgig/sdkgen'
3
3
 
4
4
  import {
5
5
  KIT,
@@ -7,6 +7,8 @@ import {
7
7
  nom,
8
8
  } from '@voxgig/apidef'
9
9
 
10
+ import { exampleValue } from './utility_js'
11
+
10
12
 
11
13
  const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
12
14
  const { target, ctx$: { model } } = props
@@ -14,44 +16,68 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
14
16
  const entity = getModelPath(model, `main.${KIT}.entity`)
15
17
  const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
16
18
 
17
- const apikeyArg = isAuthActive(model)
18
- ? `\n apikey: process.env.${model.NAME}_APIKEY,\n`
19
- : ''
19
+ const ctor = isAuthActive(model)
20
+ ? `new ${model.const.Name}SDK({\n apikey: process.env.${envName(model)}_APIKEY,\n})`
21
+ : `new ${model.const.Name}SDK()`
20
22
 
21
23
  Content(`\`\`\`js
22
- const { ${model.const.Name}SDK } = require('${target.module.name}')
24
+ const { ${model.const.Name}SDK } = require('${packageName(model, target.name)}')
23
25
 
24
- const client = new ${model.const.Name}SDK({${apikeyArg}})
26
+ const client = ${ctor}
25
27
 
26
28
  `)
27
29
 
28
30
  if (exampleEntity) {
29
31
  const eName = nom(exampleEntity, 'Name')
30
- const opnames = Object.keys(exampleEntity.op || {})
32
+ const eVar = safeVarName(eName.toLowerCase(), 'js')
33
+ // ACTIVE ops only — an inactive op generates no method, so an example
34
+ // calling it would be wrong.
35
+ const opnames = entityOps(exampleEntity)
31
36
 
32
37
  if (opnames.includes('list')) {
33
- Content(`// List all ${eName.toLowerCase()}s
34
- const ${eName.toLowerCase()}s = await client.${eName}().list()
38
+ Content(`// List all ${eName.toLowerCase()}s (returns an array)
39
+ const ${eVar}s = await client.${eName}().list()
40
+ for (const ${eVar} of ${eVar}s) {
41
+ console.log(${eVar})
42
+ }
35
43
  `)
36
44
  }
37
45
 
38
- // Find a nested entity for a more interesting example
46
+ // Find a nested entity for a more interesting example: one with a parent
47
+ // chain (relations.ancestors), an active load op of its OWN, and a
48
+ // required non-id load param to demonstrate (the parent key, e.g.
49
+ // page_id).
39
50
  const nestedEntity = Object.values(entity).find((e: any) =>
40
- e.active !== false && e.ancestors && e.ancestors.length > 0
51
+ e.active !== false &&
52
+ e.relations && e.relations.ancestors && 0 < e.relations.ancestors.length &&
53
+ entityOps(e).includes('load') &&
54
+ opRequestShape(e, 'load').items.some((it: any) =>
55
+ !it.optional && it.name !== entityIdField(e))
41
56
  ) as any
42
57
 
43
- if (nestedEntity && opnames.includes('load')) {
58
+ if (nestedEntity) {
44
59
  const neName = nom(nestedEntity, 'Name')
45
- const parentFields = (nestedEntity.fields || [])
46
- .filter((f: any) => f.name !== 'id' && f.name.endsWith('_id'))
47
- const parentParam = parentFields.length > 0 ? parentFields[0].name : 'parent_id'
60
+ const neVar = safeVarName(neName.toLowerCase(), 'js')
61
+ const loadOp = nestedEntity.op && nestedEntity.op.load
62
+
63
+ // Every REQUIRED load-match key (parent keys like page_id first, the
64
+ // entity's own id last) — the same shape the runtime resolves path
65
+ // params from, so the example always works.
66
+ const neIdF = entityIdField(nestedEntity)
67
+ const neMatchLines = opRequestShape(nestedEntity, 'load').items
68
+ .filter((it: any) => !it.optional || it.name === neIdF)
69
+ .sort((a: any, b: any) =>
70
+ (a.name === neIdF ? 1 : 0) - (b.name === neIdF ? 1 : 0))
71
+ .map((it: any) =>
72
+ ` ${it.name}: ${exampleValue(nestedEntity, loadOp, it.name,
73
+ it.name === neIdF ? 'example_id' : 'example_' + it.name)},`)
48
74
 
49
75
  Content(`
50
- // Load a specific ${neName.toLowerCase()}
51
- const ${neName.toLowerCase()} = await client.${neName}().load({
52
- ${parentParam}: 'example',
53
- id: 'example_id',
76
+ // Load a specific ${neName.toLowerCase()} (returns the entity)
77
+ const ${neVar} = await client.${neName}().load({
78
+ ${neMatchLines.join('\n')}
54
79
  })
80
+ console.log(${neVar})
55
81
  `)
56
82
  }
57
83
  }
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, Content } from '@voxgig/sdkgen'
2
+ import { cmp, Content, entityIdField, entityPrimaryOp, opRequestShape, safeVarName } from '@voxgig/sdkgen'
3
3
 
4
4
  import {
5
5
  KIT,
@@ -7,6 +7,8 @@ import {
7
7
  nom,
8
8
  } from '@voxgig/apidef'
9
9
 
10
+ import { exampleValue } from './utility_js'
11
+
10
12
 
11
13
  const ReadmeTopTest = cmp(function ReadmeTopTest(props: any) {
12
14
  const { target, ctx$: { model } } = props
@@ -20,8 +22,38 @@ const client = ${model.const.Name}SDK.test()
20
22
 
21
23
  if (exampleEntity) {
22
24
  const eName = nom(exampleEntity, 'Name')
23
- Content(`const result = await client.${eName}().load({ id: 'test01' })
24
- // result.ok === true, result.data contains mock data
25
+ // Drive the test-mode example off the entity's PRIMARY op (never a
26
+ // hardcoded `load` a create-only entity lacks).
27
+ const primaryOp = entityPrimaryOp(exampleEntity) || 'load'
28
+ // A list() result is an array — name the variable accordingly.
29
+ const eVar = safeVarName(eName.toLowerCase(), 'js') +
30
+ ('list' === primaryOp ? 's' : '')
31
+ const primaryOpDef = exampleEntity.op && exampleEntity.op[primaryOp]
32
+ const idF = entityIdField(exampleEntity)
33
+ let arg = ''
34
+ if ('load' === primaryOp || 'remove' === primaryOp) {
35
+ // Every REQUIRED match key (id first, then parent path params like
36
+ // page_id) — the same shape the runtime resolves path params from.
37
+ const items = opRequestShape(exampleEntity, primaryOp).items
38
+ .filter((it: any) => !it.optional || it.name === idF)
39
+ .sort((a: any, b: any) =>
40
+ (a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
41
+ arg = 0 < items.length
42
+ ? `{ ${items.map((it: any) =>
43
+ `${it.name}: ${exampleValue(exampleEntity, primaryOpDef, it.name,
44
+ it.name === idF ? 'test01' : 'example_' + it.name)}`).join(', ')} }`
45
+ : ''
46
+ } else if ('create' === primaryOp || 'update' === primaryOp) {
47
+ const items = opRequestShape(exampleEntity, primaryOp).items
48
+ .filter((it: any) => it.name !== idF && it.name !== 'id')
49
+ const required = items.filter((it: any) => !it.optional)
50
+ const chosen = required.length ? required : items.slice(0, 3)
51
+ arg = `{ ${chosen.map((it: any) =>
52
+ `${it.name}: ${exampleValue(exampleEntity, primaryOpDef, it.name, 'example_' + it.name)}`).join(', ')} }`
53
+ }
54
+ Content(`const ${eVar} = await client.${eName}().${primaryOp}(${arg})
55
+ // ${eVar} is ${'list' === primaryOp ? 'an array of bare entities' : 'a bare entity'} populated with mock data
56
+ console.log(${eVar})
25
57
  `)
26
58
  }
27
59
 
@@ -4,6 +4,11 @@ class EntityOperation {
4
4
 
5
5
  // EJECT-START
6
6
 
7
+ /**
8
+ * @param {EntityNameCreateData} [reqdata]
9
+ * @param {Object} [ctrl]
10
+ * @returns {Promise<EntityName>}
11
+ */
7
12
  async create(reqdata, ctrl) {
8
13
 
9
14
  const utility = this._utility
@@ -4,6 +4,11 @@ class EntityOperation {
4
4
 
5
5
  // EJECT-START
6
6
 
7
+ /**
8
+ * @param {EntityNameListMatch} [reqmatch]
9
+ * @param {Object} [ctrl]
10
+ * @returns {Promise<EntityName[]>}
11
+ */
7
12
  async list(reqmatch, ctrl) {
8
13
 
9
14
  const utility = this._utility
@@ -4,6 +4,11 @@ class EntityOperation {
4
4
 
5
5
  // EJECT-START
6
6
 
7
+ /**
8
+ * @param {EntityNameLoadMatch} [reqmatch]
9
+ * @param {Object} [ctrl]
10
+ * @returns {Promise<EntityName>}
11
+ */
7
12
  async load(reqmatch, ctrl) {
8
13
 
9
14
  const utility = this._utility
@@ -4,6 +4,11 @@ class EntityOperation {
4
4
 
5
5
  // EJECT-START
6
6
 
7
+ /**
8
+ * @param {EntityNameRemoveMatch} [reqmatch]
9
+ * @param {Object} [ctrl]
10
+ * @returns {Promise<EntityName>}
11
+ */
7
12
  async remove(reqmatch, ctrl) {
8
13
 
9
14
  const utility = this._utility
@@ -4,6 +4,11 @@ class EntityOperation {
4
4
 
5
5
  // EJECT-START
6
6
 
7
+ /**
8
+ * @param {EntityNameUpdateData} [reqdata]
9
+ * @param {Object} [ctrl]
10
+ * @returns {Promise<EntityName>}
11
+ */
7
12
  async update(reqdata, ctrl) {
8
13
 
9
14
  const utility = this._utility