@voxgig/sdkgen 0.35.2 → 0.37.0

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 (498) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/cmp/Main.js +0 -12
  3. package/dist/cmp/Main.js.map +1 -1
  4. package/dist/cmp/Readme.js +5 -5
  5. package/dist/cmp/Readme.js.map +1 -1
  6. package/dist/cmp/ReadmeEntity.js +74 -24
  7. package/dist/cmp/ReadmeEntity.js.map +1 -1
  8. package/dist/cmp/ReadmeExplanation.d.ts +2 -0
  9. package/dist/cmp/ReadmeExplanation.js +308 -0
  10. package/dist/cmp/ReadmeExplanation.js.map +1 -0
  11. package/dist/cmp/ReadmeHowto.d.ts +2 -0
  12. package/dist/cmp/ReadmeHowto.js +18 -0
  13. package/dist/cmp/ReadmeHowto.js.map +1 -0
  14. package/dist/cmp/ReadmeIntro.js +8 -23
  15. package/dist/cmp/ReadmeIntro.js.map +1 -1
  16. package/dist/cmp/ReadmeModel.js +55 -91
  17. package/dist/cmp/ReadmeModel.js.map +1 -1
  18. package/dist/cmp/ReadmeOptions.js +35 -11
  19. package/dist/cmp/ReadmeOptions.js.map +1 -1
  20. package/dist/cmp/ReadmeQuick.js +4 -1
  21. package/dist/cmp/ReadmeQuick.js.map +1 -1
  22. package/dist/cmp/ReadmeRef.js +1042 -40
  23. package/dist/cmp/ReadmeRef.js.map +1 -1
  24. package/dist/cmp/ReadmeTop.d.ts +2 -0
  25. package/dist/cmp/ReadmeTop.js +171 -0
  26. package/dist/cmp/ReadmeTop.js.map +1 -0
  27. package/dist/sdkgen.d.ts +7 -1
  28. package/dist/sdkgen.js +13 -1
  29. package/dist/sdkgen.js.map +1 -1
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +2 -2
  32. package/project/.sdk/model/feature/feature-index.jsonic +5 -0
  33. package/project/.sdk/model/feature/log.jsonic +5 -1
  34. package/project/.sdk/model/feature/test.jsonic +1 -1
  35. package/project/.sdk/model/target/lua.jsonic +23 -0
  36. package/project/.sdk/model/target/php.jsonic +22 -0
  37. package/project/.sdk/model/target/py.jsonic +23 -0
  38. package/project/.sdk/model/target/rb.jsonic +23 -0
  39. package/project/.sdk/src/cmp/go/Config_go.ts +6 -2
  40. package/project/.sdk/src/cmp/go/Main_go.ts +2 -6
  41. package/project/.sdk/src/cmp/go/ReadmeExplanation_go.ts +42 -0
  42. package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +112 -0
  43. package/project/.sdk/src/cmp/go/ReadmeInstall_go.ts +29 -0
  44. package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +129 -0
  45. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +163 -0
  46. package/project/.sdk/src/cmp/go/ReadmeTopHowto_go.ts +24 -0
  47. package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +67 -0
  48. package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +40 -0
  49. package/project/.sdk/src/cmp/go/TestDirect_go.ts +46 -2
  50. package/project/.sdk/src/cmp/go/TestEntity_go.ts +360 -160
  51. package/project/.sdk/src/cmp/go/Test_go.ts +24 -1
  52. package/project/.sdk/src/cmp/js/EntityBase_js.ts +34 -0
  53. package/project/.sdk/src/cmp/js/Main_js.ts +10 -0
  54. package/project/.sdk/src/cmp/js/ReadmeExplanation_js.ts +33 -0
  55. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +123 -0
  56. package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +152 -0
  57. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +1 -1
  58. package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +25 -0
  59. package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +65 -0
  60. package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +36 -0
  61. package/project/.sdk/src/cmp/js/TestDirect_js.ts +53 -5
  62. package/project/.sdk/src/cmp/js/TestEntity_js.ts +114 -20
  63. package/project/.sdk/src/cmp/js/fragment/Entity.fragment.js +7 -139
  64. package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +149 -0
  65. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +6 -10
  66. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +6 -10
  67. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +7 -11
  68. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +7 -11
  69. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +7 -11
  70. package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +2 -0
  71. package/project/.sdk/src/cmp/js/fragment/SdkError.fragment.js +0 -2
  72. package/project/.sdk/src/cmp/lua/Config_lua.ts +116 -0
  73. package/project/.sdk/src/cmp/lua/EntityOperation_lua.ts +44 -0
  74. package/project/.sdk/src/cmp/lua/Entity_lua.ts +62 -0
  75. package/project/.sdk/src/cmp/lua/MainEntity_lua.ts +23 -0
  76. package/project/.sdk/src/cmp/lua/Main_lua.ts +133 -0
  77. package/project/.sdk/src/cmp/lua/Package_lua.ts +80 -0
  78. package/project/.sdk/src/cmp/lua/ReadmeExplanation_lua.ts +42 -0
  79. package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +100 -0
  80. package/project/.sdk/src/cmp/lua/ReadmeInstall_lua.ts +26 -0
  81. package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +129 -0
  82. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +99 -0
  83. package/project/.sdk/src/cmp/lua/ReadmeTopHowto_lua.ts +24 -0
  84. package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +55 -0
  85. package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +38 -0
  86. package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +261 -0
  87. package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +485 -0
  88. package/project/.sdk/src/cmp/lua/Test_lua.ts +49 -0
  89. package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +147 -0
  90. package/project/.sdk/src/cmp/lua/fragment/EntityCreateOp.fragment.lua +27 -0
  91. package/project/.sdk/src/cmp/lua/fragment/EntityListOp.fragment.lua +24 -0
  92. package/project/.sdk/src/cmp/lua/fragment/EntityLoadOp.fragment.lua +30 -0
  93. package/project/.sdk/src/cmp/lua/fragment/EntityRemoveOp.fragment.lua +30 -0
  94. package/project/.sdk/src/cmp/lua/fragment/EntityUpdateOp.fragment.lua +30 -0
  95. package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +256 -0
  96. package/project/.sdk/src/cmp/lua/fragment/SdkError.fragment.lua +26 -0
  97. package/project/.sdk/src/cmp/lua/tsconfig.json +15 -0
  98. package/project/.sdk/src/cmp/lua/utility_lua.ts +84 -0
  99. package/project/.sdk/src/cmp/php/Config_php.ts +111 -0
  100. package/project/.sdk/src/cmp/php/EntityOperation_php.ts +44 -0
  101. package/project/.sdk/src/cmp/php/Entity_php.ts +62 -0
  102. package/project/.sdk/src/cmp/php/MainEntity_php.ts +24 -0
  103. package/project/.sdk/src/cmp/php/Main_php.ts +135 -0
  104. package/project/.sdk/src/cmp/php/Package_php.ts +87 -0
  105. package/project/.sdk/src/cmp/php/ReadmeExplanation_php.ts +42 -0
  106. package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +101 -0
  107. package/project/.sdk/src/cmp/php/ReadmeInstall_php.ts +19 -0
  108. package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +129 -0
  109. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +100 -0
  110. package/project/.sdk/src/cmp/php/ReadmeTopHowto_php.ts +24 -0
  111. package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +56 -0
  112. package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +38 -0
  113. package/project/.sdk/src/cmp/php/TestDirect_php.ts +270 -0
  114. package/project/.sdk/src/cmp/php/TestEntity_php.ts +479 -0
  115. package/project/.sdk/src/cmp/php/Test_php.ts +56 -0
  116. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +146 -0
  117. package/project/.sdk/src/cmp/php/fragment/EntityCreateOp.fragment.php +26 -0
  118. package/project/.sdk/src/cmp/php/fragment/EntityListOp.fragment.php +23 -0
  119. package/project/.sdk/src/cmp/php/fragment/EntityLoadOp.fragment.php +29 -0
  120. package/project/.sdk/src/cmp/php/fragment/EntityRemoveOp.fragment.php +29 -0
  121. package/project/.sdk/src/cmp/php/fragment/EntityUpdateOp.fragment.php +29 -0
  122. package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +233 -0
  123. package/project/.sdk/src/cmp/php/fragment/SdkError.fragment.php +24 -0
  124. package/project/.sdk/src/cmp/php/tsconfig.json +15 -0
  125. package/project/.sdk/src/cmp/php/utility_php.ts +85 -0
  126. package/project/.sdk/src/cmp/py/Config_py.ts +97 -0
  127. package/project/.sdk/src/cmp/py/EntityOperation_py.ts +44 -0
  128. package/project/.sdk/src/cmp/py/Entity_py.ts +62 -0
  129. package/project/.sdk/src/cmp/py/MainEntity_py.ts +22 -0
  130. package/project/.sdk/src/cmp/py/Main_py.ts +156 -0
  131. package/project/.sdk/src/cmp/py/Package_py.ts +75 -0
  132. package/project/.sdk/src/cmp/py/ReadmeExplanation_py.ts +41 -0
  133. package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +98 -0
  134. package/project/.sdk/src/cmp/py/ReadmeInstall_py.ts +25 -0
  135. package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +130 -0
  136. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +100 -0
  137. package/project/.sdk/src/cmp/py/ReadmeTopHowto_py.ts +24 -0
  138. package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +56 -0
  139. package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +38 -0
  140. package/project/.sdk/src/cmp/py/TestDirect_py.ts +248 -0
  141. package/project/.sdk/src/cmp/py/TestEntity_py.ts +477 -0
  142. package/project/.sdk/src/cmp/py/Test_py.ts +55 -0
  143. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +112 -0
  144. package/project/.sdk/src/cmp/py/fragment/EntityCreateOp.fragment.py +25 -0
  145. package/project/.sdk/src/cmp/py/fragment/EntityListOp.fragment.py +22 -0
  146. package/project/.sdk/src/cmp/py/fragment/EntityLoadOp.fragment.py +27 -0
  147. package/project/.sdk/src/cmp/py/fragment/EntityRemoveOp.fragment.py +27 -0
  148. package/project/.sdk/src/cmp/py/fragment/EntityUpdateOp.fragment.py +27 -0
  149. package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +222 -0
  150. package/project/.sdk/src/cmp/py/fragment/SdkError.fragment.py +16 -0
  151. package/project/.sdk/src/cmp/py/tsconfig.json +15 -0
  152. package/project/.sdk/src/cmp/py/utility_py.ts +84 -0
  153. package/project/.sdk/src/cmp/rb/Config_rb.ts +105 -0
  154. package/project/.sdk/src/cmp/rb/EntityOperation_rb.ts +44 -0
  155. package/project/.sdk/src/cmp/rb/Entity_rb.ts +62 -0
  156. package/project/.sdk/src/cmp/rb/MainEntity_rb.ts +23 -0
  157. package/project/.sdk/src/cmp/rb/Main_rb.ts +130 -0
  158. package/project/.sdk/src/cmp/rb/Package_rb.ts +111 -0
  159. package/project/.sdk/src/cmp/rb/ReadmeExplanation_rb.ts +42 -0
  160. package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +98 -0
  161. package/project/.sdk/src/cmp/rb/ReadmeInstall_rb.ts +31 -0
  162. package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +129 -0
  163. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +99 -0
  164. package/project/.sdk/src/cmp/rb/ReadmeTopHowto_rb.ts +24 -0
  165. package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +55 -0
  166. package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +38 -0
  167. package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +260 -0
  168. package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +476 -0
  169. package/project/.sdk/src/cmp/rb/Test_rb.ts +50 -0
  170. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +116 -0
  171. package/project/.sdk/src/cmp/rb/fragment/EntityCreateOp.fragment.rb +25 -0
  172. package/project/.sdk/src/cmp/rb/fragment/EntityListOp.fragment.rb +20 -0
  173. package/project/.sdk/src/cmp/rb/fragment/EntityLoadOp.fragment.rb +26 -0
  174. package/project/.sdk/src/cmp/rb/fragment/EntityRemoveOp.fragment.rb +26 -0
  175. package/project/.sdk/src/cmp/rb/fragment/EntityUpdateOp.fragment.rb +26 -0
  176. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +203 -0
  177. package/project/.sdk/src/cmp/rb/fragment/SdkError.fragment.rb +16 -0
  178. package/project/.sdk/src/cmp/rb/tsconfig.json +15 -0
  179. package/project/.sdk/src/cmp/rb/utility_rb.ts +84 -0
  180. package/project/.sdk/src/cmp/ts/Main_ts.ts +7 -0
  181. package/project/.sdk/src/cmp/ts/ReadmeExplanation_ts.ts +34 -0
  182. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +123 -0
  183. package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts +1 -1
  184. package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +159 -0
  185. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +69 -54
  186. package/project/.sdk/src/cmp/ts/ReadmeTopHowto_ts.ts +25 -0
  187. package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +65 -0
  188. package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +36 -0
  189. package/project/.sdk/tm/go/feature/log_feature.go +133 -0
  190. package/project/.sdk/tm/go/src/feature/log/.gitkeep +0 -0
  191. package/project/.sdk/tm/go/test/runner_test.go +16 -2
  192. package/project/.sdk/tm/js/src/Context.js +142 -0
  193. package/project/.sdk/tm/js/src/Control.js +16 -0
  194. package/project/.sdk/tm/js/src/Operation.js +19 -0
  195. package/project/.sdk/tm/js/src/Point.js +24 -0
  196. package/project/.sdk/tm/js/src/README.md +1 -0
  197. package/project/.sdk/tm/js/src/Response.js +19 -0
  198. package/project/.sdk/tm/js/src/Result.js +21 -0
  199. package/project/.sdk/tm/js/src/Spec.js +26 -0
  200. package/project/.sdk/tm/js/src/feature/README.md +1 -0
  201. package/project/.sdk/tm/js/src/feature/base/BaseFeature.js +45 -0
  202. package/project/.sdk/tm/js/src/feature/log/LogFeature.js +46 -47
  203. package/project/.sdk/tm/js/src/feature/test/TestFeature.js +207 -0
  204. package/project/.sdk/tm/js/src/types.js +22 -0
  205. package/project/.sdk/tm/js/src/utility/CleanUtility.js +31 -0
  206. package/project/.sdk/tm/js/src/utility/DoneUtility.js +11 -4
  207. package/project/.sdk/tm/js/src/utility/FeatureAddUtility.js +42 -0
  208. package/project/.sdk/tm/js/src/utility/FeatureHookUtility.js +25 -0
  209. package/project/.sdk/tm/js/src/utility/FeatureInitUtility.js +11 -0
  210. package/project/.sdk/tm/js/src/utility/FetcherUtility.js +28 -0
  211. package/project/.sdk/tm/js/src/utility/MakeContextUtility.js +11 -0
  212. package/project/.sdk/tm/js/src/utility/MakeErrorUtility.js +55 -0
  213. package/project/.sdk/tm/js/src/utility/MakeFetchDefUtility.js +44 -0
  214. package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +93 -0
  215. package/project/.sdk/tm/js/src/utility/MakePointUtility.js +77 -0
  216. package/project/.sdk/tm/js/src/utility/MakeRequestUtility.js +63 -0
  217. package/project/.sdk/tm/js/src/utility/MakeResponseUtility.js +55 -0
  218. package/project/.sdk/tm/js/src/utility/MakeResultUtility.js +54 -0
  219. package/project/.sdk/tm/js/src/utility/MakeSpecUtility.js +58 -0
  220. package/project/.sdk/tm/js/src/utility/MakeUrlUtility.js +40 -0
  221. package/project/.sdk/tm/js/src/utility/ParamUtility.js +61 -0
  222. package/project/.sdk/tm/js/src/utility/PrepareAuthUtility.js +41 -0
  223. package/project/.sdk/tm/js/src/utility/PrepareBodyUtility.js +25 -0
  224. package/project/.sdk/tm/js/src/utility/PrepareHeadersUtility.js +18 -0
  225. package/project/.sdk/tm/js/src/utility/{MethodUtility.js → PrepareMethodUtility.js} +7 -7
  226. package/project/.sdk/tm/js/src/utility/PrepareParamsUtility.js +25 -0
  227. package/project/.sdk/tm/js/src/utility/PreparePathUtility.js +13 -0
  228. package/project/.sdk/tm/js/src/utility/PrepareQueryUtility.js +26 -0
  229. package/project/.sdk/tm/js/src/utility/README.md +1 -0
  230. package/project/.sdk/tm/js/src/utility/ResultBasicUtility.js +34 -0
  231. package/project/.sdk/tm/js/src/utility/ResultBodyUtility.js +18 -0
  232. package/project/.sdk/tm/js/src/utility/ResultHeadersUtility.js +22 -0
  233. package/project/.sdk/tm/js/src/utility/StructUtility.js +2219 -1078
  234. package/project/.sdk/tm/js/src/utility/TransformRequestUtility.js +28 -0
  235. package/project/.sdk/tm/js/src/utility/TransformResponseUtility.js +31 -0
  236. package/project/.sdk/tm/js/src/utility/Utility.js +61 -61
  237. package/project/.sdk/tm/js/test/README.md +1 -0
  238. package/project/.sdk/tm/js/test/exists.test.js +16 -0
  239. package/project/.sdk/tm/js/test/runner.js +323 -107
  240. package/project/.sdk/tm/js/test/utility/Custom.test.js +41 -63
  241. package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +390 -116
  242. package/project/.sdk/tm/js/test/utility/StructUtility.test.js +728 -175
  243. package/project/.sdk/tm/js/test/utility/index.js +9 -0
  244. package/project/.sdk/tm/js/test/utility.js +72 -0
  245. package/project/.sdk/tm/lua/LICENSE +22 -0
  246. package/project/.sdk/tm/lua/Makefile +10 -0
  247. package/project/.sdk/tm/lua/core/context.lua +208 -0
  248. package/project/.sdk/tm/lua/core/control.lua +17 -0
  249. package/project/.sdk/tm/lua/core/error.lua +30 -0
  250. package/project/.sdk/tm/lua/core/helpers.lua +30 -0
  251. package/project/.sdk/tm/lua/core/operation.lua +51 -0
  252. package/project/.sdk/tm/lua/core/response.lua +45 -0
  253. package/project/.sdk/tm/lua/core/result.lua +58 -0
  254. package/project/.sdk/tm/lua/core/spec.lua +29 -0
  255. package/project/.sdk/tm/lua/core/utility_type.lua +90 -0
  256. package/project/.sdk/tm/lua/feature/base_feature.lua +35 -0
  257. package/project/.sdk/tm/lua/feature/log_feature.lua +80 -0
  258. package/project/.sdk/tm/lua/feature/test_feature.lua +202 -0
  259. package/project/.sdk/tm/lua/src/feature/README.md +3 -0
  260. package/project/.sdk/tm/lua/src/feature/base/.gitkeep +0 -0
  261. package/project/.sdk/tm/lua/src/feature/log/.gitkeep +0 -0
  262. package/project/.sdk/tm/lua/src/feature/test/.gitkeep +0 -0
  263. package/project/.sdk/tm/lua/test/primary_utility_test.lua +1213 -0
  264. package/project/.sdk/tm/lua/test/runner.lua +86 -0
  265. package/project/.sdk/tm/lua/test/struct_runner.lua +602 -0
  266. package/project/.sdk/tm/lua/test/struct_utility_test.lua +959 -0
  267. package/project/.sdk/tm/lua/utility/clean.lua +7 -0
  268. package/project/.sdk/tm/lua/utility/done.lua +19 -0
  269. package/project/.sdk/tm/lua/utility/feature_add.lua +8 -0
  270. package/project/.sdk/tm/lua/utility/feature_hook.lua +21 -0
  271. package/project/.sdk/tm/lua/utility/feature_init.lua +24 -0
  272. package/project/.sdk/tm/lua/utility/fetcher.lua +96 -0
  273. package/project/.sdk/tm/lua/utility/make_context.lua +9 -0
  274. package/project/.sdk/tm/lua/utility/make_error.lua +73 -0
  275. package/project/.sdk/tm/lua/utility/make_fetch_def.lua +43 -0
  276. package/project/.sdk/tm/lua/utility/make_options.lua +116 -0
  277. package/project/.sdk/tm/lua/utility/make_point.lua +92 -0
  278. package/project/.sdk/tm/lua/utility/make_request.lua +58 -0
  279. package/project/.sdk/tm/lua/utility/make_response.lua +44 -0
  280. package/project/.sdk/tm/lua/utility/make_result.lua +51 -0
  281. package/project/.sdk/tm/lua/utility/make_spec.lua +72 -0
  282. package/project/.sdk/tm/lua/utility/make_url.lua +46 -0
  283. package/project/.sdk/tm/lua/utility/param.lua +68 -0
  284. package/project/.sdk/tm/lua/utility/prepare_auth.lua +39 -0
  285. package/project/.sdk/tm/lua/utility/prepare_body.lua +14 -0
  286. package/project/.sdk/tm/lua/utility/prepare_headers.lua +20 -0
  287. package/project/.sdk/tm/lua/utility/prepare_method.lua +17 -0
  288. package/project/.sdk/tm/lua/utility/prepare_params.lua +36 -0
  289. package/project/.sdk/tm/lua/utility/prepare_path.lua +19 -0
  290. package/project/.sdk/tm/lua/utility/prepare_query.lua +41 -0
  291. package/project/.sdk/tm/lua/utility/register.lua +71 -0
  292. package/project/.sdk/tm/lua/utility/result_basic.lua +32 -0
  293. package/project/.sdk/tm/lua/utility/result_body.lua +17 -0
  294. package/project/.sdk/tm/lua/utility/result_headers.lua +22 -0
  295. package/project/.sdk/tm/lua/utility/struct/struct.lua +3427 -0
  296. package/project/.sdk/tm/lua/utility/transform_request.lua +31 -0
  297. package/project/.sdk/tm/lua/utility/transform_response.lua +44 -0
  298. package/project/.sdk/tm/php/LICENSE +22 -0
  299. package/project/.sdk/tm/php/Makefile +10 -0
  300. package/project/.sdk/tm/php/core/Context.php +139 -0
  301. package/project/.sdk/tm/php/core/Control.php +18 -0
  302. package/project/.sdk/tm/php/core/Error.php +37 -0
  303. package/project/.sdk/tm/php/core/Helpers.php +25 -0
  304. package/project/.sdk/tm/php/core/Operation.php +36 -0
  305. package/project/.sdk/tm/php/core/Response.php +30 -0
  306. package/project/.sdk/tm/php/core/Result.php +35 -0
  307. package/project/.sdk/tm/php/core/Spec.php +38 -0
  308. package/project/.sdk/tm/php/core/UtilityType.php +89 -0
  309. package/project/.sdk/tm/php/feature/BaseFeature.php +37 -0
  310. package/project/.sdk/tm/php/feature/LogFeature.php +65 -0
  311. package/project/.sdk/tm/php/feature/TestFeature.php +156 -0
  312. package/project/.sdk/tm/php/src/feature/README.md +3 -0
  313. package/project/.sdk/tm/php/src/feature/base/.gitkeep +0 -0
  314. package/project/.sdk/tm/php/src/feature/log/.gitkeep +0 -0
  315. package/project/.sdk/tm/php/src/feature/test/.gitkeep +0 -0
  316. package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +1309 -0
  317. package/project/.sdk/tm/php/test/Runner.php +112 -0
  318. package/project/.sdk/tm/php/test/StructRunner.php +275 -0
  319. package/project/.sdk/tm/php/test/StructUtilityTest.php +1336 -0
  320. package/project/.sdk/tm/php/utility/Clean.php +12 -0
  321. package/project/.sdk/tm/php/utility/Done.php +26 -0
  322. package/project/.sdk/tm/php/utility/FeatureAdd.php +12 -0
  323. package/project/.sdk/tm/php/utility/FeatureHook.php +23 -0
  324. package/project/.sdk/tm/php/utility/FeatureInit.php +25 -0
  325. package/project/.sdk/tm/php/utility/Fetcher.php +105 -0
  326. package/project/.sdk/tm/php/utility/MakeContext.php +14 -0
  327. package/project/.sdk/tm/php/utility/MakeError.php +59 -0
  328. package/project/.sdk/tm/php/utility/MakeFetchDef.php +36 -0
  329. package/project/.sdk/tm/php/utility/MakeOptions.php +102 -0
  330. package/project/.sdk/tm/php/utility/MakePoint.php +87 -0
  331. package/project/.sdk/tm/php/utility/MakeRequest.php +57 -0
  332. package/project/.sdk/tm/php/utility/MakeResponse.php +43 -0
  333. package/project/.sdk/tm/php/utility/MakeResult.php +53 -0
  334. package/project/.sdk/tm/php/utility/MakeSpec.php +64 -0
  335. package/project/.sdk/tm/php/utility/MakeUrl.php +41 -0
  336. package/project/.sdk/tm/php/utility/Param.php +68 -0
  337. package/project/.sdk/tm/php/utility/PrepareAuth.php +33 -0
  338. package/project/.sdk/tm/php/utility/PrepareBody.php +15 -0
  339. package/project/.sdk/tm/php/utility/PrepareHeaders.php +18 -0
  340. package/project/.sdk/tm/php/utility/PrepareMethod.php +21 -0
  341. package/project/.sdk/tm/php/utility/PrepareParams.php +34 -0
  342. package/project/.sdk/tm/php/utility/PreparePath.php +20 -0
  343. package/project/.sdk/tm/php/utility/PrepareQuery.php +32 -0
  344. package/project/.sdk/tm/php/utility/Register.php +67 -0
  345. package/project/.sdk/tm/php/utility/ResultBasic.php +29 -0
  346. package/project/.sdk/tm/php/utility/ResultBody.php +17 -0
  347. package/project/.sdk/tm/php/utility/ResultHeaders.php +21 -0
  348. package/project/.sdk/tm/php/utility/TransformRequest.php +27 -0
  349. package/project/.sdk/tm/php/utility/TransformResponse.php +42 -0
  350. package/project/.sdk/tm/php/utility/struct/Struct.php +3535 -0
  351. package/project/.sdk/tm/py/Makefile +10 -0
  352. package/project/.sdk/tm/py/core/__init__.py +0 -0
  353. package/project/.sdk/tm/py/core/context.py +199 -0
  354. package/project/.sdk/tm/py/core/control.py +12 -0
  355. package/project/.sdk/tm/py/core/error.py +18 -0
  356. package/project/.sdk/tm/py/core/helpers.py +15 -0
  357. package/project/.sdk/tm/py/core/operation.py +37 -0
  358. package/project/.sdk/tm/py/core/response.py +34 -0
  359. package/project/.sdk/tm/py/core/result.py +44 -0
  360. package/project/.sdk/tm/py/core/spec.py +23 -0
  361. package/project/.sdk/tm/py/core/utility_type.py +82 -0
  362. package/project/.sdk/tm/py/entity/__init__.py +0 -0
  363. package/project/.sdk/tm/py/feature/__init__.py +0 -0
  364. package/project/.sdk/tm/py/feature/base_feature.py +61 -0
  365. package/project/.sdk/tm/py/feature/log_feature.py +84 -0
  366. package/project/.sdk/tm/py/feature/test_feature.py +164 -0
  367. package/project/.sdk/tm/py/src/feature/README.md +3 -0
  368. package/project/.sdk/tm/py/src/feature/base/.gitkeep +0 -0
  369. package/project/.sdk/tm/py/src/feature/log/.gitkeep +0 -0
  370. package/project/.sdk/tm/py/src/feature/test/.gitkeep +0 -0
  371. package/project/.sdk/tm/py/test/__init__.py +0 -0
  372. package/project/.sdk/tm/py/test/runner.py +90 -0
  373. package/project/.sdk/tm/py/test/struct_runner.py +411 -0
  374. package/project/.sdk/tm/py/test/test_primary_utility.py +1101 -0
  375. package/project/.sdk/tm/py/test/test_struct_utility.py +751 -0
  376. package/project/.sdk/tm/py/utility/__init__.py +0 -0
  377. package/project/.sdk/tm/py/utility/clean.py +5 -0
  378. package/project/.sdk/tm/py/utility/done.py +14 -0
  379. package/project/.sdk/tm/py/utility/feature_add.py +6 -0
  380. package/project/.sdk/tm/py/utility/feature_hook.py +15 -0
  381. package/project/.sdk/tm/py/utility/feature_init.py +18 -0
  382. package/project/.sdk/tm/py/utility/fetcher.py +95 -0
  383. package/project/.sdk/tm/py/utility/make_context.py +7 -0
  384. package/project/.sdk/tm/py/utility/make_error.py +64 -0
  385. package/project/.sdk/tm/py/utility/make_fetch_def.py +37 -0
  386. package/project/.sdk/tm/py/utility/make_options.py +103 -0
  387. package/project/.sdk/tm/py/utility/make_point.py +74 -0
  388. package/project/.sdk/tm/py/utility/make_request.py +52 -0
  389. package/project/.sdk/tm/py/utility/make_response.py +36 -0
  390. package/project/.sdk/tm/py/utility/make_result.py +41 -0
  391. package/project/.sdk/tm/py/utility/make_spec.py +68 -0
  392. package/project/.sdk/tm/py/utility/make_url.py +34 -0
  393. package/project/.sdk/tm/py/utility/param.py +55 -0
  394. package/project/.sdk/tm/py/utility/prepare_auth.py +34 -0
  395. package/project/.sdk/tm/py/utility/prepare_body.py +11 -0
  396. package/project/.sdk/tm/py/utility/prepare_headers.py +17 -0
  397. package/project/.sdk/tm/py/utility/prepare_method.py +15 -0
  398. package/project/.sdk/tm/py/utility/prepare_params.py +28 -0
  399. package/project/.sdk/tm/py/utility/prepare_path.py +16 -0
  400. package/project/.sdk/tm/py/utility/prepare_query.py +33 -0
  401. package/project/.sdk/tm/py/utility/register.py +68 -0
  402. package/project/.sdk/tm/py/utility/result_basic.py +26 -0
  403. package/project/.sdk/tm/py/utility/result_body.py +13 -0
  404. package/project/.sdk/tm/py/utility/result_headers.py +17 -0
  405. package/project/.sdk/tm/py/utility/transform_request.py +27 -0
  406. package/project/.sdk/tm/py/utility/transform_response.py +39 -0
  407. package/project/.sdk/tm/py/utility/voxgig_struct/__init__.py +72 -0
  408. package/project/.sdk/tm/py/utility/voxgig_struct/voxgig_struct.py +2770 -0
  409. package/project/.sdk/tm/rb/Gemfile +4 -0
  410. package/project/.sdk/tm/rb/LICENSE +22 -0
  411. package/project/.sdk/tm/rb/Makefile +10 -0
  412. package/project/.sdk/tm/rb/core/context.rb +105 -0
  413. package/project/.sdk/tm/rb/core/control.rb +11 -0
  414. package/project/.sdk/tm/rb/core/error.rb +24 -0
  415. package/project/.sdk/tm/rb/core/helpers.rb +16 -0
  416. package/project/.sdk/tm/rb/core/operation.rb +26 -0
  417. package/project/.sdk/tm/rb/core/response.rb +20 -0
  418. package/project/.sdk/tm/rb/core/result.rb +23 -0
  419. package/project/.sdk/tm/rb/core/spec.rb +23 -0
  420. package/project/.sdk/tm/rb/core/utility_type.rb +32 -0
  421. package/project/.sdk/tm/rb/feature/base_feature.rb +30 -0
  422. package/project/.sdk/tm/rb/feature/log_feature.rb +50 -0
  423. package/project/.sdk/tm/rb/feature/test_feature.rb +154 -0
  424. package/project/.sdk/tm/rb/src/feature/README.md +3 -0
  425. package/project/.sdk/tm/rb/src/feature/base/.gitkeep +0 -0
  426. package/project/.sdk/tm/rb/src/feature/log/.gitkeep +0 -0
  427. package/project/.sdk/tm/rb/src/feature/test/.gitkeep +0 -0
  428. package/project/.sdk/tm/rb/test/primary_utility_test.rb +1083 -0
  429. package/project/.sdk/tm/rb/test/runner.rb +70 -0
  430. package/project/.sdk/tm/rb/test/struct_runner.rb +309 -0
  431. package/project/.sdk/tm/rb/test/struct_utility_test.rb +670 -0
  432. package/project/.sdk/tm/rb/utility/clean.rb +4 -0
  433. package/project/.sdk/tm/rb/utility/done.rb +14 -0
  434. package/project/.sdk/tm/rb/utility/feature_add.rb +6 -0
  435. package/project/.sdk/tm/rb/utility/feature_hook.rb +11 -0
  436. package/project/.sdk/tm/rb/utility/feature_init.rb +16 -0
  437. package/project/.sdk/tm/rb/utility/fetcher.rb +67 -0
  438. package/project/.sdk/tm/rb/utility/make_context.rb +7 -0
  439. package/project/.sdk/tm/rb/utility/make_error.rb +44 -0
  440. package/project/.sdk/tm/rb/utility/make_fetch_def.rb +24 -0
  441. package/project/.sdk/tm/rb/utility/make_options.rb +57 -0
  442. package/project/.sdk/tm/rb/utility/make_point.rb +77 -0
  443. package/project/.sdk/tm/rb/utility/make_request.rb +44 -0
  444. package/project/.sdk/tm/rb/utility/make_response.rb +25 -0
  445. package/project/.sdk/tm/rb/utility/make_result.rb +33 -0
  446. package/project/.sdk/tm/rb/utility/make_spec.rb +50 -0
  447. package/project/.sdk/tm/rb/utility/make_url.rb +32 -0
  448. package/project/.sdk/tm/rb/utility/param.rb +48 -0
  449. package/project/.sdk/tm/rb/utility/prepare_auth.rb +26 -0
  450. package/project/.sdk/tm/rb/utility/prepare_body.rb +6 -0
  451. package/project/.sdk/tm/rb/utility/prepare_headers.rb +11 -0
  452. package/project/.sdk/tm/rb/utility/prepare_method.rb +5 -0
  453. package/project/.sdk/tm/rb/utility/prepare_params.rb +25 -0
  454. package/project/.sdk/tm/rb/utility/prepare_path.rb +13 -0
  455. package/project/.sdk/tm/rb/utility/prepare_query.rb +22 -0
  456. package/project/.sdk/tm/rb/utility/register.rb +63 -0
  457. package/project/.sdk/tm/rb/utility/result_basic.rb +23 -0
  458. package/project/.sdk/tm/rb/utility/result_body.rb +11 -0
  459. package/project/.sdk/tm/rb/utility/result_headers.rb +15 -0
  460. package/project/.sdk/tm/rb/utility/struct/voxgig_struct.rb +2256 -0
  461. package/project/.sdk/tm/rb/utility/transform_request.rb +15 -0
  462. package/project/.sdk/tm/rb/utility/transform_response.rb +23 -0
  463. package/src/cmp/Main.ts +1 -16
  464. package/src/cmp/Readme.ts +5 -5
  465. package/src/cmp/ReadmeEntity.ts +77 -25
  466. package/src/cmp/ReadmeExplanation.ts +333 -0
  467. package/src/cmp/ReadmeHowto.ts +28 -0
  468. package/src/cmp/ReadmeIntro.ts +10 -24
  469. package/src/cmp/ReadmeModel.ts +57 -88
  470. package/src/cmp/ReadmeOptions.ts +40 -11
  471. package/src/cmp/ReadmeQuick.ts +4 -1
  472. package/src/cmp/ReadmeRef.ts +1057 -40
  473. package/src/cmp/ReadmeTop.ts +213 -0
  474. package/src/sdkgen.ts +12 -0
  475. package/project/.sdk/src/cmp/js/Quick_js.ts +0 -78
  476. package/project/.sdk/src/cmp/js/TestAcceptEntity_js.ts +0 -13
  477. package/project/.sdk/src/cmp/js/TestAccept_js.ts +0 -18
  478. package/project/.sdk/tm/go/test/exists_test.go +0 -16
  479. package/project/.sdk/tm/js/src/utility/AuthUtility.js +0 -21
  480. package/project/.sdk/tm/js/src/utility/BodyUtility.js +0 -29
  481. package/project/.sdk/tm/js/src/utility/ErrorUtility.js +0 -33
  482. package/project/.sdk/tm/js/src/utility/FindparamUtility.js +0 -31
  483. package/project/.sdk/tm/js/src/utility/FullurlUtility.js +0 -39
  484. package/project/.sdk/tm/js/src/utility/HeadersUtility.js +0 -13
  485. package/project/.sdk/tm/js/src/utility/JoinurlUtility.js +0 -14
  486. package/project/.sdk/tm/js/src/utility/OperatorUtility.js +0 -44
  487. package/project/.sdk/tm/js/src/utility/OptionsUtility.js +0 -54
  488. package/project/.sdk/tm/js/src/utility/ParamsUtility.js +0 -21
  489. package/project/.sdk/tm/js/src/utility/QueryUtility.js +0 -21
  490. package/project/.sdk/tm/js/src/utility/ReqformUtility.js +0 -32
  491. package/project/.sdk/tm/js/src/utility/RequestUtility.js +0 -48
  492. package/project/.sdk/tm/js/src/utility/ResbasicUtility.js +0 -27
  493. package/project/.sdk/tm/js/src/utility/ResbodyUtility.js +0 -15
  494. package/project/.sdk/tm/js/src/utility/ResformUtility.js +0 -34
  495. package/project/.sdk/tm/js/src/utility/ResheadersUtility.js +0 -19
  496. package/project/.sdk/tm/js/src/utility/ResponseUtility.js +0 -37
  497. package/project/.sdk/tm/js/src/utility/ResultUtility.js +0 -28
  498. package/project/.sdk/tm/js/src/utility/SpecUtility.js +0 -35
@@ -1,305 +1,716 @@
1
+ // VERSION: @voxgig/struct 0.0.10
2
+ // RUN: npm test
3
+ // RUN-SOME: npm run test-some --pattern=getpath
1
4
 
2
- const { readFileSync } = require('node:fs')
3
- const { join } = require('node:path')
4
- const { test, describe } = require('node:test')
5
- const { equal, deepEqual, fail } = require('node:assert')
5
+ const { test, describe, before } = require('node:test')
6
+ const assert = require('node:assert')
7
+
8
+ const {
9
+ makeRunner,
10
+ nullModifier,
11
+ NULLMARK,
12
+ } = require('../runner')
6
13
 
7
14
 
8
15
  const {
9
- clone,
10
- escre,
11
- escurl,
12
- getpath,
13
- getprop,
14
- inject,
15
- isempty,
16
- iskey,
17
- islist,
18
- ismap,
19
- isnode,
20
- items,
21
- haskey,
22
- keysof,
23
- merge,
24
- setprop,
25
- stringify,
26
- transform,
27
- walk,
28
- validate,
29
- joinurl,
30
- } = require('../../src/utility/StructUtility')
31
-
32
-
33
- const { runner } = require('../runner')
34
-
35
-
36
- function walkpath(_key, val, _parent, path) {
37
- return 'string' === typeof val ? val + '~' + path.join('.') : val
38
- }
39
-
40
-
41
- function nullModifier(
42
- key,
43
- val,
44
- parent
45
- ) {
46
- if ("__NULL__" === val) {
47
- setprop(parent, key, null)
48
- }
49
- else if ('string' === typeof val) {
50
- setprop(parent, key, val.replaceAll('__NULL__', 'null'))
51
- }
52
- }
16
+ SDK,
17
+ TEST_JSON_FILE
18
+ } = require('./index')
53
19
 
54
20
 
21
+ const { equal, deepEqual } = assert
22
+
23
+
24
+ // NOTE: tests are (mostly) in order of increasing dependence.
55
25
  describe('struct', async () => {
56
26
 
57
- const { spec, runset, subject } = await runner('struct')
27
+ let spec
28
+ let runset
29
+ let runsetflags
30
+ let client
31
+ let struct
58
32
 
59
-
60
- // minor tests
61
- // ===========
33
+ before(async () => {
34
+ const runner = await makeRunner(TEST_JSON_FILE, await SDK.test())
35
+ const runner_struct = await runner('struct')
62
36
 
63
- test('minor-exists', () => {
64
- equal('function', typeof clone)
65
- equal('function', typeof escre)
66
- equal('function', typeof escurl)
67
- equal('function', typeof getprop)
68
- equal('function', typeof isempty)
69
- equal('function', typeof iskey)
70
- equal('function', typeof islist)
71
- equal('function', typeof ismap)
72
- equal('function', typeof isnode)
73
- equal('function', typeof items)
74
- equal('function', typeof setprop)
75
- equal('function', typeof stringify)
76
- equal('function', typeof haskey)
77
- equal('function', typeof keysof)
78
- equal('function', typeof joinurl)
37
+ spec = runner_struct.spec
38
+
39
+ runset = runner_struct.runset
40
+ runsetflags = runner_struct.runsetflags
41
+ client = runner_struct.client
42
+
43
+ struct = client.utility().struct
79
44
  })
80
45
 
81
- test('minor-clone', async () => {
82
- await runset(spec.minor.clone, clone)
46
+
47
+
48
+ test('exists', () => {
49
+ const s = struct
50
+
51
+ equal('function', typeof s.clone)
52
+ equal('function', typeof s.delprop)
53
+ equal('function', typeof s.escre)
54
+ equal('function', typeof s.escurl)
55
+ equal('function', typeof s.filter)
56
+
57
+ equal('function', typeof s.flatten)
58
+ equal('function', typeof s.getelem)
59
+ equal('function', typeof s.getprop)
60
+
61
+ equal('function', typeof s.getpath)
62
+ equal('function', typeof s.haskey)
63
+ equal('function', typeof s.inject)
64
+ equal('function', typeof s.isempty)
65
+ equal('function', typeof s.isfunc)
66
+
67
+ equal('function', typeof s.iskey)
68
+ equal('function', typeof s.islist)
69
+ equal('function', typeof s.ismap)
70
+ equal('function', typeof s.isnode)
71
+ equal('function', typeof s.items)
72
+
73
+ equal('function', typeof s.join)
74
+ equal('function', typeof s.jsonify)
75
+ equal('function', typeof s.keysof)
76
+ equal('function', typeof s.merge)
77
+ equal('function', typeof s.pad)
78
+ equal('function', typeof s.pathify)
79
+
80
+ equal('function', typeof s.select)
81
+ equal('function', typeof s.setpath)
82
+ equal('function', typeof s.size)
83
+ equal('function', typeof s.slice)
84
+ equal('function', typeof s.setprop)
85
+
86
+ equal('function', typeof s.strkey)
87
+ equal('function', typeof s.stringify)
88
+ equal('function', typeof s.transform)
89
+ equal('function', typeof s.typify)
90
+ equal('function', typeof s.typename)
91
+
92
+ equal('function', typeof s.validate)
93
+ equal('function', typeof s.walk)
83
94
  })
84
95
 
96
+
97
+ // minor tests
98
+ // ===========
99
+
85
100
  test('minor-isnode', async () => {
86
- await runset(spec.minor.isnode, isnode)
101
+ await runset(spec.minor.isnode, struct.isnode)
87
102
  })
88
103
 
104
+
89
105
  test('minor-ismap', async () => {
90
- await runset(spec.minor.ismap, ismap)
106
+ await runset(spec.minor.ismap, struct.ismap)
91
107
  })
92
108
 
109
+
93
110
  test('minor-islist', async () => {
94
- await runset(spec.minor.islist, islist)
111
+ await runset(spec.minor.islist, struct.islist)
95
112
  })
96
113
 
114
+
97
115
  test('minor-iskey', async () => {
98
- await runset(spec.minor.iskey, iskey)
116
+ await runsetflags(spec.minor.iskey, { null: false }, struct.iskey)
99
117
  })
100
118
 
119
+
120
+ test('minor-strkey', async () => {
121
+ await runsetflags(spec.minor.strkey, { null: false }, struct.strkey)
122
+ })
123
+
124
+
101
125
  test('minor-isempty', async () => {
102
- await runset(spec.minor.isempty, isempty)
126
+ await runsetflags(spec.minor.isempty, { null: false }, struct.isempty)
103
127
  })
104
128
 
129
+
130
+ test('minor-isfunc', async () => {
131
+ const { isfunc } = struct
132
+ await runset(spec.minor.isfunc, isfunc)
133
+ function f0() { return null }
134
+ equal(isfunc(f0), true)
135
+ equal(isfunc(() => null), true)
136
+ })
137
+
138
+
139
+ test('minor-clone', async () => {
140
+ await runsetflags(spec.minor.clone, { null: false }, struct.clone)
141
+ })
142
+
143
+
144
+ test('minor-edge-clone', async () => {
145
+ const { clone } = struct
146
+
147
+ const f0 = () => null
148
+ deepEqual({ a: f0 }, clone({ a: f0 }))
149
+
150
+ const x = { y: 1 }
151
+ let xc = clone(x)
152
+ deepEqual(x, xc)
153
+ assert(x !== xc)
154
+
155
+ class A { x = 1 }
156
+ const a = new A()
157
+ let ac = clone(a)
158
+ deepEqual(a, ac)
159
+ assert(a === ac)
160
+ equal(a.constructor.name, ac.constructor.name)
161
+ })
162
+
163
+
164
+ test('minor-filter', async () => {
165
+ const checkmap = {
166
+ gt3: (n) => n[1] > 3,
167
+ lt3: (n) => n[1] < 3,
168
+ }
169
+ await runset(spec.minor.filter, (vin) => struct.filter(vin.val, checkmap[vin.check]))
170
+ })
171
+
172
+
173
+ test('minor-flatten', async () => {
174
+ await runset(spec.minor.flatten, (vin) => struct.flatten(vin.val, vin.depth))
175
+ })
176
+
177
+
105
178
  test('minor-escre', async () => {
106
- await runset(spec.minor.escre, escre)
179
+ await runset(spec.minor.escre, struct.escre)
107
180
  })
108
181
 
182
+
109
183
  test('minor-escurl', async () => {
110
- await runset(spec.minor.escurl, escurl)
184
+ await runset(spec.minor.escurl, struct.escurl)
111
185
  })
112
186
 
187
+
113
188
  test('minor-stringify', async () => {
114
189
  await runset(spec.minor.stringify, (vin) =>
115
- null == vin.max ? stringify(vin.val) : stringify(vin.val, vin.max))
190
+ struct.stringify((NULLMARK === vin.val ? "null" : vin.val), vin.max))
191
+ })
192
+
193
+
194
+ test('minor-edge-stringify', async () => {
195
+ const { stringify } = struct
196
+ const a = {}
197
+ a.a = a
198
+ equal(stringify(a), '__STRINGIFY_FAILED__')
199
+
200
+ equal(stringify({ a: [9] }, -1, true),
201
+ '\x1B[38;5;81m\x1B[38;5;118m{\x1B[38;5;118ma\x1B[38;5;118m:' +
202
+ '\x1B[38;5;213m[\x1B[38;5;213m9\x1B[38;5;213m]\x1B[38;5;118m}\x1B[0m')
203
+ })
204
+
205
+
206
+ test('minor-jsonify', async () => {
207
+ await runsetflags(spec.minor.jsonify, { null: false },
208
+ (vin) => struct.jsonify(vin.val, vin.flags))
209
+ })
210
+
211
+
212
+ test('minor-edge-jsonify', async () => {
213
+ const { jsonify } = struct
214
+ equal(jsonify(() => 1), 'null')
215
+ })
216
+
217
+
218
+ test('minor-pathify', async () => {
219
+ await runsetflags(
220
+ spec.minor.pathify, { null: true },
221
+ (vin) => {
222
+ let path = NULLMARK == vin.path ? undefined : vin.path
223
+ let pathstr = struct.pathify(path, vin.from).replace('__NULL__.', '')
224
+ pathstr = NULLMARK === vin.path ? pathstr.replace('>', ':null>') : pathstr
225
+ return pathstr
226
+ })
116
227
  })
117
228
 
229
+
118
230
  test('minor-items', async () => {
119
- await runset(spec.minor.items, items)
231
+ await runset(spec.minor.items, struct.items)
232
+ })
233
+
234
+
235
+ test('minor-edge-items', async () => {
236
+ const { items } = struct
237
+ const a0 = [11, 22, 33]
238
+ a0.x = 1
239
+ deepEqual(items(a0), [['0', 11], ['1', 22], ['2', 33]])
120
240
  })
121
241
 
242
+
243
+ test('minor-getelem', async () => {
244
+ const { getelem } = struct
245
+ await runsetflags(spec.minor.getelem, { null: false }, (vin) =>
246
+ null == vin.alt ? getelem(vin.val, vin.key) : getelem(vin.val, vin.key, vin.alt))
247
+ })
248
+
249
+
250
+ test('minor-edge-getelem', async () => {
251
+ const { getelem } = struct
252
+ equal(getelem([], 1, () => 2), 2)
253
+ })
254
+
255
+
122
256
  test('minor-getprop', async () => {
123
- await runset(spec.minor.getprop, (vin) =>
124
- null == vin.alt ? getprop(vin.val, vin.key) : getprop(vin.val, vin.key, vin.alt))
257
+ const { getprop } = struct
258
+ await runsetflags(spec.minor.getprop, { null: false }, (vin) =>
259
+ undefined === vin.alt ? getprop(vin.val, vin.key) : getprop(vin.val, vin.key, vin.alt))
260
+ })
261
+
262
+
263
+ test('minor-edge-getprop', async () => {
264
+ const { getprop } = struct
265
+
266
+ let strarr = ['a', 'b', 'c', 'd', 'e']
267
+ deepEqual(getprop(strarr, 2), 'c')
268
+ deepEqual(getprop(strarr, '2'), 'c')
269
+
270
+ let intarr = [2, 3, 5, 7, 11]
271
+ deepEqual(getprop(intarr, 2), 5)
272
+ deepEqual(getprop(intarr, '2'), 5)
125
273
  })
126
274
 
275
+
127
276
  test('minor-setprop', async () => {
128
277
  await runset(spec.minor.setprop, (vin) =>
129
- setprop(vin.parent, vin.key, vin.val))
278
+ struct.setprop(vin.parent, vin.key, vin.val))
279
+ })
280
+
281
+
282
+ test('minor-edge-setprop', async () => {
283
+ const { setprop } = struct
284
+
285
+ let strarr0 = ['a', 'b', 'c', 'd', 'e']
286
+ let strarr1 = ['a', 'b', 'c', 'd', 'e']
287
+ deepEqual(setprop(strarr0, 2, 'C'), ['a', 'b', 'C', 'd', 'e'])
288
+ deepEqual(setprop(strarr1, '2', 'CC'), ['a', 'b', 'CC', 'd', 'e'])
289
+
290
+ let intarr0 = [2, 3, 5, 7, 11]
291
+ let intarr1 = [2, 3, 5, 7, 11]
292
+ deepEqual(setprop(intarr0, 2, 55), [2, 3, 55, 7, 11])
293
+ deepEqual(setprop(intarr1, '2', 555), [2, 3, 555, 7, 11])
294
+ })
295
+
296
+
297
+ test('minor-delprop', async () => {
298
+ await runset(spec.minor.delprop, (vin) =>
299
+ struct.delprop(vin.parent, vin.key))
300
+ })
301
+
302
+
303
+ test('minor-edge-delprop', async () => {
304
+ const { delprop } = struct
305
+
306
+ let strarr0 = ['a', 'b', 'c', 'd', 'e']
307
+ let strarr1 = ['a', 'b', 'c', 'd', 'e']
308
+ deepEqual(delprop(strarr0, 2), ['a', 'b', 'd', 'e'])
309
+ deepEqual(delprop(strarr1, '2'), ['a', 'b', 'd', 'e'])
310
+
311
+ let intarr0 = [2, 3, 5, 7, 11]
312
+ let intarr1 = [2, 3, 5, 7, 11]
313
+ deepEqual(delprop(intarr0, 2), [2, 3, 7, 11])
314
+ deepEqual(delprop(intarr1, '2'), [2, 3, 7, 11])
130
315
  })
131
316
 
317
+
132
318
  test('minor-haskey', async () => {
133
- await runset(spec.minor.haskey, haskey)
319
+ await runsetflags(spec.minor.haskey, { null: false }, (vin) =>
320
+ struct.haskey(vin.src, vin.key))
134
321
  })
135
322
 
323
+
136
324
  test('minor-keysof', async () => {
137
- await runset(spec.minor.keysof, keysof)
325
+ await runset(spec.minor.keysof, struct.keysof)
326
+ })
327
+
328
+ test('minor-edge-keysof', async () => {
329
+ const { keysof } = struct
330
+ const a0 = [11, 22, 33]
331
+ a0.x = 1
332
+ deepEqual(keysof(a0), [0, 1, 2])
333
+ })
334
+
335
+
336
+
337
+ test('minor-join', async () => {
338
+ await runsetflags(spec.minor.join, { null: false },
339
+ (vin) => struct.join(vin.val, vin.sep, vin.url))
340
+ })
341
+
342
+
343
+ test('minor-typename', async () => {
344
+ await runset(spec.minor.typename, struct.typename)
345
+ })
346
+
347
+
348
+ test('minor-typify', async () => {
349
+ await runsetflags(spec.minor.typify, { null: false }, struct.typify)
138
350
  })
139
351
 
140
- test('minor-joinurl', async () => {
141
- await runset(spec.minor.joinurl, joinurl)
352
+
353
+ test('minor-edge-typify', async () => {
354
+ const {
355
+ typify, T_noval, T_scalar, T_function, T_symbol, T_any, T_node, T_instance, T_null
356
+ } = struct
357
+ class X { }
358
+ const x = new X()
359
+ equal(typify(), T_noval)
360
+ equal(typify(undefined), T_noval)
361
+ equal(typify(NaN), T_noval)
362
+ equal(typify(null), T_scalar | T_null)
363
+ equal(typify(() => null), T_scalar | T_function)
364
+ equal(typify(Symbol('S')), T_scalar | T_symbol)
365
+ equal(typify(BigInt(1)), T_any)
366
+ equal(typify(x), T_node | T_instance)
367
+ })
368
+
369
+
370
+ test('minor-size', async () => {
371
+ await runsetflags(spec.minor.size, { null: false }, struct.size)
372
+ })
373
+
374
+
375
+ test('minor-slice', async () => {
376
+ await runsetflags(spec.minor.slice, { null: false },
377
+ (vin) => struct.slice(vin.val, vin.start, vin.end))
378
+ })
379
+
380
+
381
+ test('minor-pad', async () => {
382
+ await runsetflags(spec.minor.pad, { null: false },
383
+ (vin) => struct.pad(vin.val, vin.pad, vin.char))
384
+ })
385
+
386
+
387
+ test('minor-setpath', async () => {
388
+ await runsetflags(spec.minor.setpath, { null: false },
389
+ (vin) => struct.setpath(vin.store, vin.path, vin.val))
390
+ })
391
+
392
+
393
+ test('minor-edge-setpath', async () => {
394
+ const { setpath, DELETE } = struct
395
+ const x = { y: { z: 1, q: 2 } }
396
+ deepEqual(setpath(x, 'y.q', DELETE), { z: 1 })
397
+ deepEqual(x, { y: { z: 1 } })
142
398
  })
143
399
 
144
400
 
401
+
145
402
  // walk tests
146
403
  // ==========
147
404
 
148
- test('walk-exists', async () => {
149
- equal('function', typeof merge)
405
+ test('walk-log', async () => {
406
+ const { clone, stringify, pathify, walk } = struct
407
+
408
+ const test = clone(spec.walk.log)
409
+
410
+ let log = []
411
+
412
+ function walklog(key, val, parent, path) {
413
+ log.push('k=' + stringify(key) +
414
+ ', v=' + stringify(val) +
415
+ ', p=' + stringify(parent) +
416
+ ', t=' + pathify(path))
417
+ return val
418
+ }
419
+
420
+ walk(test.in, undefined, walklog)
421
+ deepEqual(log, test.out.after)
422
+
423
+ log = []
424
+ walk(test.in, walklog)
425
+ deepEqual(log, test.out.before)
426
+
427
+ log = []
428
+ walk(test.in, walklog, walklog)
429
+ deepEqual(log, test.out.both)
150
430
  })
151
431
 
432
+
152
433
  test('walk-basic', async () => {
153
- await runset(spec.walk.basic, (vin) => walk(vin, walkpath))
434
+ function walkpath(_key, val, _parent, path) {
435
+ return 'string' === typeof val ? val + '~' + path.join('.') : val
436
+ }
437
+
438
+ await runset(spec.walk.basic, (vin) => struct.walk(vin, walkpath))
154
439
  })
155
440
 
156
441
 
157
- // merge tests
158
- // ===========
442
+ test('walk-depth', async () => {
443
+
444
+ await runsetflags(spec.walk.depth, { null: false },
445
+ (vin) => {
446
+ let top = undefined
447
+ let cur = undefined
448
+ function copy(key, val, _parent, _path) {
449
+ if (undefined === key || struct.isnode(val)) {
450
+ let child = struct.islist(val) ? [] : {}
451
+ if (undefined === key) {
452
+ top = cur = child
453
+ }
454
+ else {
455
+ cur = cur[key] = child
456
+ }
457
+ }
458
+ else {
459
+ cur[key] = val
460
+ }
461
+ return val
462
+ }
463
+ struct.walk(vin.src, copy, undefined, vin.maxdepth)
464
+ return top
465
+ })
466
+ })
467
+
468
+
469
+ test('walk-copy', async () => {
470
+ const { walk, isnode, ismap, islist, size, setprop } = struct
471
+
472
+ let cur
473
+ function walkcopy(key, val, _parent, path) {
474
+ if (undefined === key) {
475
+ cur = []
476
+ cur[0] = ismap(val) ? {} : islist(val) ? [] : val
477
+ return val
478
+ }
479
+
480
+ let v = val
481
+ let i = size(path)
482
+
483
+ if (isnode(v)) {
484
+ v = cur[i] = ismap(v) ? {} : []
485
+ }
486
+
487
+ setprop(cur[i - 1], key, v)
488
+
489
+ return val
490
+ }
159
491
 
160
- test('merge-exists', async () => {
161
- equal('function', typeof merge)
492
+ await runset(spec.walk.copy, (vin) => (walk(vin, walkcopy), cur[0]))
162
493
  })
163
494
 
495
+
496
+
497
+ // merge tests
498
+ // ===========
499
+
164
500
  test('merge-basic', async () => {
501
+ const { clone, merge } = struct
165
502
  const test = clone(spec.merge.basic)
166
503
  deepEqual(merge(test.in), test.out)
167
504
  })
168
505
 
506
+
169
507
  test('merge-cases', async () => {
170
- await runset(spec.merge.cases, merge)
508
+ await runset(spec.merge.cases, struct.merge)
171
509
  })
172
510
 
511
+
173
512
  test('merge-array', async () => {
174
- await runset(spec.merge.array, merge)
513
+ await runset(spec.merge.array, struct.merge)
514
+ })
515
+
516
+
517
+ test('merge-integrity', async () => {
518
+ await runset(spec.merge.integrity, struct.merge)
519
+ })
520
+
521
+
522
+ test('merge-depth', async () => {
523
+ await runset(spec.merge.depth, (vin) => struct.merge(vin.val, vin.depth))
175
524
  })
176
525
 
526
+
177
527
  test('merge-special', async () => {
178
- const f0 = ()=>null
528
+ const { merge } = struct
529
+ const f0 = () => null
179
530
  deepEqual(merge([f0]), f0)
180
- deepEqual(merge([null,f0]), f0)
181
- deepEqual(merge([{a:f0}]), {a:f0})
182
- deepEqual(merge([{a:{b:f0}}]), {a:{b:f0}})
531
+ deepEqual(merge([null, f0]), f0)
532
+ deepEqual(merge([{ a: f0 }]), { a: f0 })
533
+ deepEqual(merge([[f0]]), [f0])
534
+ deepEqual(merge([{ a: { b: f0 } }]), { a: { b: f0 } })
535
+
536
+ // JavaScript only
537
+ deepEqual(merge([{ a: global.fetch }]), { a: global.fetch })
538
+ deepEqual(merge([[global.fetch]]), [global.fetch])
539
+ deepEqual(merge([{ a: { b: global.fetch } }]), { a: { b: global.fetch } })
540
+
541
+ class Bar { x = 1 }
542
+ const b0 = new Bar()
543
+ let out
544
+
545
+ equal(merge([{ x: 10 }, b0]), b0)
546
+ equal(b0.x, 1)
547
+ equal(b0 instanceof Bar, true)
548
+
549
+ deepEqual(merge([{ a: b0 }, { a: { x: 11 } }]), { a: { x: 11 } })
550
+ equal(b0.x, 1)
551
+ equal(b0 instanceof Bar, true)
552
+
553
+ deepEqual(merge([b0, { x: 20 }]), { x: 20 })
554
+ equal(b0.x, 1)
555
+ equal(b0 instanceof Bar, true)
556
+
557
+ out = merge([{ a: { x: 21 } }, { a: b0 }])
558
+ deepEqual(out, { a: b0 })
559
+ equal(b0, out.a)
560
+ equal(b0.x, 1)
561
+ equal(b0 instanceof Bar, true)
183
562
 
184
- deepEqual(merge([{a:global.fetch}]), {a:global.fetch})
185
- deepEqual(merge([{a:{b:global.fetch}}]), {a:{b:global.fetch}})
563
+ out = merge([{}, { b: b0 }])
564
+ deepEqual(out, { b: b0 })
565
+ equal(b0, out.b)
566
+ equal(b0.x, 1)
567
+ equal(b0 instanceof Bar, true)
186
568
  })
187
-
569
+
188
570
 
189
571
  // getpath tests
190
572
  // =============
191
573
 
192
- test('getpath-exists', async () => {
193
- equal('function', typeof getpath)
574
+ test('getpath-basic', async () => {
575
+ await runset(spec.getpath.basic, (vin) => struct.getpath(vin.store, vin.path))
194
576
  })
195
577
 
196
- test('getpath-basic', async () => {
197
- await runset(spec.getpath.basic, (vin) => getpath(vin.path, vin.store))
578
+
579
+ test('getpath-relative', async () => {
580
+ await runset(spec.getpath.relative, (vin) =>
581
+ struct.getpath(vin.store, vin.path,
582
+ { dparent: vin.dparent, dpath: vin.dpath?.split('.') }))
198
583
  })
199
584
 
200
- test('getpath-current', async () => {
201
- await runset(spec.getpath.current, (vin) =>
202
- getpath(vin.path, vin.store, vin.current))
585
+
586
+ test('getpath-special', async () => {
587
+ await runset(spec.getpath.special, (vin) =>
588
+ struct.getpath(vin.store, vin.path, vin.inj))
203
589
  })
204
590
 
205
- test('getpath-state', async () => {
206
- const state = {
207
- handler: (state, val, _current, _store) => {
208
- let out = state.step + ':' + val
209
- state.step++
210
- return out
211
- },
212
- step: 0,
213
- mode: 'val',
214
- full: false,
215
- keyI: 0,
216
- keys: ['$TOP'],
217
- key: '$TOP',
218
- val: '',
219
- parent: {},
220
- path: ['$TOP'],
221
- nodes: [{}],
222
- base: '$TOP'
223
- }
224
- await runset(spec.getpath.state, (vin) =>
225
- getpath(vin.path, vin.store, vin.current, state))
591
+
592
+ test('getpath-handler', async () => {
593
+ await runset(spec.getpath.handler, (vin) =>
594
+ struct.getpath(
595
+ {
596
+ $TOP: vin.store,
597
+ $FOO: () => 'foo',
598
+ },
599
+ vin.path,
600
+ {
601
+ handler: (_inj, val, _cur, _ref) => {
602
+ return val()
603
+ }
604
+ }
605
+ ))
226
606
  })
227
607
 
228
608
 
229
609
  // inject tests
230
610
  // ============
231
611
 
232
- test('inject-exists', async () => {
233
- equal('function', typeof inject)
234
- })
235
-
236
612
  test('inject-basic', async () => {
613
+ const { clone, inject } = struct
237
614
  const test = clone(spec.inject.basic)
238
615
  deepEqual(inject(test.in.val, test.in.store), test.out)
239
616
  })
240
617
 
618
+
241
619
  test('inject-string', async () => {
242
620
  await runset(spec.inject.string, (vin) =>
243
- inject(vin.val, vin.store, nullModifier, vin.current))
621
+ struct.inject(vin.val, vin.store, { modify: nullModifier }))
244
622
  })
245
623
 
624
+
246
625
  test('inject-deep', async () => {
247
- await runset(spec.inject.deep, (vin) => inject(vin.val, vin.store))
626
+ await runset(spec.inject.deep, (vin) => struct.inject(vin.val, vin.store))
248
627
  })
249
628
 
250
629
 
251
630
  // transform tests
252
631
  // ===============
253
632
 
254
- test('transform-exists', async () => {
255
- equal('function', typeof transform)
256
- })
257
-
258
633
  test('transform-basic', async () => {
634
+ const { clone, transform } = struct
259
635
  const test = clone(spec.transform.basic)
260
- deepEqual(transform(test.in.data, test.in.spec, test.in.store), test.out)
636
+ deepEqual(transform(test.in.data, test.in.spec), test.out)
261
637
  })
262
638
 
639
+
263
640
  test('transform-paths', async () => {
264
641
  await runset(spec.transform.paths, (vin) =>
265
- transform(vin.data, vin.spec, vin.store))
642
+ struct.transform(vin.data, vin.spec))
266
643
  })
267
644
 
645
+
268
646
  test('transform-cmds', async () => {
269
647
  await runset(spec.transform.cmds, (vin) =>
270
- transform(vin.data, vin.spec, vin.store))
648
+ struct.transform(vin.data, vin.spec))
271
649
  })
272
650
 
651
+
273
652
  test('transform-each', async () => {
274
653
  await runset(spec.transform.each, (vin) =>
275
- transform(vin.data, vin.spec, vin.store))
654
+ struct.transform(vin.data, vin.spec))
276
655
  })
277
656
 
657
+
278
658
  test('transform-pack', async () => {
279
659
  await runset(spec.transform.pack, (vin) =>
280
- transform(vin.data, vin.spec, vin.store))
660
+ struct.transform(vin.data, vin.spec))
661
+ })
662
+
663
+
664
+ test('transform-ref', async () => {
665
+ await runset(spec.transform.ref, (vin) =>
666
+ struct.transform(vin.data, vin.spec))
667
+ })
668
+
669
+
670
+ test('transform-format', async () => {
671
+ await runsetflags(spec.transform.format, { null: false }, (vin) =>
672
+ struct.transform(vin.data, vin.spec))
673
+ })
674
+
675
+
676
+ test('transform-apply', async () => {
677
+ await runset(spec.transform.apply, (vin) =>
678
+ struct.transform(vin.data, vin.spec))
679
+ })
680
+
681
+ test('transform-edge-apply', async () => {
682
+ const { transform } = struct
683
+ equal(2, transform({}, ['`$APPLY`', (v) => 1 + v, 1]))
281
684
  })
282
685
 
283
686
 
687
+
284
688
  test('transform-modify', async () => {
285
689
  await runset(spec.transform.modify, (vin) =>
286
- transform(vin.data, vin.spec, vin.store,
287
- (key, val, parent) => {
288
- if (null != key && null != parent && 'string' === typeof val) {
289
- val = parent[key] = '@' + val
690
+ struct.transform(
691
+ vin.data,
692
+ vin.spec,
693
+ {
694
+ modify: (val, key, parent) => {
695
+ if (null != key && null != parent && 'string' === typeof val) {
696
+ val = parent[key] = '@' + val
697
+ }
290
698
  }
291
699
  }
292
700
  ))
293
701
  })
294
702
 
703
+
295
704
  test('transform-extra', async () => {
296
- deepEqual(transform(
705
+ deepEqual(struct.transform(
297
706
  { a: 1 },
298
707
  { x: '`a`', b: '`$COPY`', c: '`$UPPER`' },
299
708
  {
300
- b: 2, $UPPER: (state) => {
301
- const { path } = state
302
- return ('' + getprop(path, path.length - 1)).toUpperCase()
709
+ extra: {
710
+ b: 2, $UPPER: (state) => {
711
+ const { path } = state
712
+ return ('' + struct.getprop(path, path.length - 1)).toUpperCase()
713
+ }
303
714
  }
304
715
  }
305
716
  ), {
@@ -311,42 +722,84 @@ describe('struct', async () => {
311
722
 
312
723
 
313
724
  test('transform-funcval', async () => {
314
- const f0 = ()=>99
315
- deepEqual(transform({},{x:1}), {x:1})
316
- deepEqual(transform({},{x:f0}), {x:f0})
317
- deepEqual(transform({a:1},{x:'`a`'}), {x:1})
318
- deepEqual(transform({f0},{x:'`f0`'}), {x:f0})
725
+ const { transform } = struct
726
+ // f0 should never be called (no $ prefix).
727
+ const f0 = () => 99
728
+ deepEqual(transform({}, { x: 1 }), { x: 1 })
729
+ deepEqual(transform({}, { x: f0 }), { x: f0 })
730
+ deepEqual(transform({ a: 1 }, { x: '`a`' }), { x: 1 })
731
+ deepEqual(transform({ f0 }, { x: '`f0`' }), { x: f0 })
319
732
  })
320
733
 
321
-
734
+
322
735
  // validate tests
323
736
  // ===============
324
737
 
325
- test('validate-exists', async () => {
326
- equal('function', typeof validate)
738
+ test('validate-basic', async () => {
739
+ await runsetflags(spec.validate.basic, { null: false },
740
+ (vin) => struct.validate(vin.data, vin.spec))
327
741
  })
328
742
 
329
-
330
- test('validate-basic', async () => {
331
- await runset(spec.validate.basic, (vin)=>validate(vin.data,vin.spec))
743
+
744
+ test('validate-child', async () => {
745
+ await runset(spec.validate.child, (vin) => struct.validate(vin.data, vin.spec))
332
746
  })
333
747
 
334
748
 
335
- test('validate-node', async () => {
336
- await runset(spec.validate.node, (vin)=>validate(vin.data,vin.spec))
749
+ test('validate-one', async () => {
750
+ await runset(spec.validate.one, (vin) => struct.validate(vin.data, vin.spec))
751
+ })
752
+
753
+
754
+ test('validate-exact', async () => {
755
+ await runset(spec.validate.exact, (vin) => struct.validate(vin.data, vin.spec))
756
+ })
757
+
758
+
759
+ test('validate-invalid', async () => {
760
+ await runsetflags(spec.validate.invalid, { null: false },
761
+ (vin) => struct.validate(vin.data, vin.spec))
762
+ })
763
+
764
+
765
+ test('validate-special', async () => {
766
+ await runset(spec.validate.special, (vin) =>
767
+ struct.validate(vin.data, vin.spec, vin.inj))
768
+ })
769
+
770
+
771
+ test('validate-edge', async () => {
772
+ const { validate } = struct
773
+ let errs = []
774
+ validate({ x: 1 }, { x: '`$INSTANCE`' }, { errs })
775
+ equal(errs[0], 'Expected field x to be instance, but found integer: 1.')
776
+
777
+ errs = []
778
+ validate({ x: {} }, { x: '`$INSTANCE`' }, { errs })
779
+ equal(errs[0], 'Expected field x to be instance, but found map: {}.')
780
+
781
+ errs = []
782
+ validate({ x: [] }, { x: '`$INSTANCE`' }, { errs })
783
+ equal(errs[0], 'Expected field x to be instance, but found list: [].')
784
+
785
+ class C { }
786
+ const c = new C()
787
+ errs = []
788
+ validate({ x: c }, { x: '`$INSTANCE`' }, { errs })
789
+ equal(errs.length, 0)
337
790
  })
338
791
 
339
792
 
340
793
  test('validate-custom', async () => {
341
794
  const errs = []
342
795
  const extra = {
343
- $INTEGER: (state, val, current)=>{
344
- const { mode, key, parent } = state
345
- let out = getprop(current, key)
796
+ $INTEGER: (inj) => {
797
+ const { key } = inj
798
+ let out = struct.getprop(inj.dparent, key)
346
799
 
347
800
  let t = typeof out
348
- if('number' !== t && !Number.isInteger(out)) {
349
- state.errs.push('Not an integer at '+state.path.slice(1).join('.')+': '+out)
801
+ if ('number' !== t && !Number.isInteger(out)) {
802
+ inj.errs.push('Not an integer at ' + inj.path.slice(1).join('.') + ': ' + out)
350
803
  return
351
804
  }
352
805
 
@@ -354,14 +807,114 @@ describe('struct', async () => {
354
807
  },
355
808
  }
356
809
 
357
- validate({a:1},{a:'`$INTEGER`'},extra,errs)
810
+ const shape = { a: '`$INTEGER`' }
811
+
812
+ let out = struct.validate({ a: 1 }, shape, { extra, errs })
813
+ deepEqual(out, { a: 1 })
358
814
  equal(errs.length, 0)
359
815
 
360
- validate({a:'A'},{a:'`$INTEGER`'},extra,errs)
361
- deepEqual(errs, [ 'Not an integer at a: A' ])
816
+ out = struct.validate({ a: 'A' }, shape, { extra, errs })
817
+ deepEqual(out, { a: 'A' })
818
+ deepEqual(errs, ['Not an integer at a: A'])
362
819
  })
363
820
 
364
821
 
365
- })
822
+ // select tests
823
+ // ============
824
+
825
+ test('select-basic', async () => {
826
+ await runset(spec.select.basic, (vin) => struct.select(vin.obj, vin.query))
827
+ })
828
+
829
+
830
+ test('select-operators', async () => {
831
+ await runset(spec.select.operators, (vin) => struct.select(vin.obj, vin.query))
832
+ })
366
833
 
367
834
 
835
+ test('select-edge', async () => {
836
+ await runset(spec.select.edge, (vin) => struct.select(vin.obj, vin.query))
837
+ })
838
+
839
+
840
+ test('select-alts', async () => {
841
+ await runset(spec.select.alts, (vin) => struct.select(vin.obj, vin.query))
842
+ })
843
+
844
+
845
+ // JSON Builder
846
+ // ============
847
+
848
+ test('json-builder', async () => {
849
+ const { jsonify, jm, jt } = struct
850
+ equal(jsonify(jm(
851
+ 'a', 1
852
+ )), `{
853
+ "a": 1
854
+ }`)
855
+
856
+ equal(jsonify(jt(
857
+ 'b', 2
858
+ )), `[
859
+ "b",
860
+ 2
861
+ ]`)
862
+
863
+ equal(jsonify(jm(
864
+ 'c', 'C',
865
+ 'd', jm('x', true),
866
+ 'e', jt(null, false)
867
+ )), `{
868
+ "c": "C",
869
+ "d": {
870
+ "x": true
871
+ },
872
+ "e": [
873
+ null,
874
+ false
875
+ ]
876
+ }`)
877
+
878
+ equal(jsonify(jt(
879
+ 3.3, jm(
880
+ 'f', true,
881
+ 'g', false,
882
+ 'h', null,
883
+ 'i', jt('y', 0),
884
+ 'j', jm('z', -1),
885
+ 'k')
886
+ )), `[
887
+ 3.3,
888
+ {
889
+ "f": true,
890
+ "g": false,
891
+ "h": null,
892
+ "i": [
893
+ "y",
894
+ 0
895
+ ],
896
+ "j": {
897
+ "z": -1
898
+ },
899
+ "k": null
900
+ }
901
+ ]`)
902
+
903
+ equal(jsonify(jm(
904
+ true, 1,
905
+ false, 2,
906
+ null, 3,
907
+ ['a'], 4,
908
+ { 'b': 0 }, 5
909
+ )), `{
910
+ "true": 1,
911
+ "false": 2,
912
+ "null": 3,
913
+ "[a]": 4,
914
+ "{b:0}": 5
915
+ }`)
916
+
917
+ })
918
+
919
+
920
+ })