@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.
- package/bin/voxgig-sdkgen +2 -2
- package/dist/action/action.d.ts +3 -1
- package/dist/action/action.js +26 -10
- package/dist/action/action.js.map +1 -1
- package/dist/action/feature.js +9 -8
- package/dist/action/feature.js.map +1 -1
- package/dist/action/target.d.ts +7 -1
- package/dist/action/target.js +22 -13
- package/dist/action/target.js.map +1 -1
- package/dist/cmp/Changelog.d.ts +2 -0
- package/dist/cmp/Changelog.js +30 -0
- package/dist/cmp/Changelog.js.map +1 -0
- package/dist/cmp/Deploy.d.ts +2 -0
- package/dist/cmp/Deploy.js +227 -0
- package/dist/cmp/Deploy.js.map +1 -0
- package/dist/cmp/FeatureHook.js +5 -6
- package/dist/cmp/FeatureHook.js.map +1 -1
- package/dist/cmp/License.d.ts +2 -0
- package/dist/cmp/License.js +44 -0
- package/dist/cmp/License.js.map +1 -0
- package/dist/cmp/Readme.js +2 -0
- package/dist/cmp/Readme.js.map +1 -1
- package/dist/cmp/ReadmeErrors.d.ts +2 -0
- package/dist/cmp/ReadmeErrors.js +210 -0
- package/dist/cmp/ReadmeErrors.js.map +1 -0
- package/dist/cmp/ReadmeExplanation.js +213 -223
- package/dist/cmp/ReadmeExplanation.js.map +1 -1
- package/dist/cmp/ReadmeModel.js +6 -1
- package/dist/cmp/ReadmeModel.js.map +1 -1
- package/dist/cmp/ReadmeTop.js +389 -82
- package/dist/cmp/ReadmeTop.js.map +1 -1
- package/dist/cmp/Security.d.ts +2 -0
- package/dist/cmp/Security.js +36 -0
- package/dist/cmp/Security.js.map +1 -0
- package/dist/helpers/canonType.d.ts +7 -0
- package/dist/helpers/canonType.js +74 -0
- package/dist/helpers/canonType.js.map +1 -0
- package/dist/helpers/collectDeps.d.ts +3 -2
- package/dist/helpers/collectDeps.js.map +1 -1
- package/dist/helpers/naming.d.ts +3 -0
- package/dist/helpers/naming.js +51 -0
- package/dist/helpers/naming.js.map +1 -0
- package/dist/helpers/opExample.d.ts +13 -0
- package/dist/helpers/opExample.js +149 -0
- package/dist/helpers/opExample.js.map +1 -0
- package/dist/helpers/opShape.d.ts +18 -0
- package/dist/helpers/opShape.js +225 -0
- package/dist/helpers/opShape.js.map +1 -0
- package/dist/helpers/packageMeta.d.ts +27 -0
- package/dist/helpers/packageMeta.js +224 -0
- package/dist/helpers/packageMeta.js.map +1 -0
- package/dist/sdkgen.d.ts +12 -2
- package/dist/sdkgen.js +60 -20
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +65 -2
- package/dist/types.js.map +1 -1
- package/dist/utility.d.ts +2 -1
- package/dist/utility.js +39 -11
- package/dist/utility.js.map +1 -1
- package/model/sdkgen.aontu +137 -0
- package/package.json +11 -5
- package/project/.sdk/model/feature/feature-index.aontu +5 -0
- package/project/.sdk/model/target/go-cli.aontu +47 -0
- package/project/.sdk/model/target/go-mcp.aontu +41 -0
- package/project/.sdk/model/target/go.aontu +28 -0
- package/project/.sdk/model/target/{js.jsonic → js.aontu} +13 -0
- package/project/.sdk/model/target/{lua.jsonic → lua.aontu} +13 -0
- package/project/.sdk/model/target/{php.jsonic → php.aontu} +13 -0
- package/project/.sdk/model/target/{py.jsonic → py.aontu} +13 -0
- package/project/.sdk/model/target/{rb.jsonic → rb.aontu} +13 -0
- package/project/.sdk/model/target/{ts.jsonic → ts.aontu} +13 -0
- package/project/.sdk/src/cmp/go/Config_go.ts +3 -2
- package/project/.sdk/src/cmp/go/EntityOperation_go.ts +1 -0
- package/project/.sdk/src/cmp/go/EntityTypes_go.ts +197 -0
- package/project/.sdk/src/cmp/go/Entity_go.ts +2 -1
- package/project/.sdk/src/cmp/go/MainEntity_go.ts +6 -0
- package/project/.sdk/src/cmp/go/Main_go.ts +23 -3
- package/project/.sdk/src/cmp/go/Package_go.ts +1 -1
- package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +48 -10
- package/project/.sdk/src/cmp/go/ReadmeExamplesTest_go.ts +688 -0
- package/project/.sdk/src/cmp/go/ReadmeExplanation_go.ts +1 -1
- package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +52 -8
- package/project/.sdk/src/cmp/go/ReadmeInstall_go.ts +11 -6
- package/project/.sdk/src/cmp/go/ReadmeIntro_go.ts +40 -1
- package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +67 -17
- package/project/.sdk/src/cmp/go/ReadmeOptions_go.ts +4 -3
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +146 -116
- package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +87 -21
- package/project/.sdk/src/cmp/go/ReadmeTopHowto_go.ts +4 -0
- package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +75 -16
- package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +35 -5
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +1 -1
- package/project/.sdk/src/cmp/go/Test_go.ts +5 -1
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +21 -0
- package/project/.sdk/src/cmp/go/fragment/EntityCreateOp.fragment.go +11 -0
- package/project/.sdk/src/cmp/go/fragment/EntityListOp.fragment.go +11 -0
- package/project/.sdk/src/cmp/go/fragment/EntityLoadOp.fragment.go +11 -0
- package/project/.sdk/src/cmp/go/fragment/EntityRemoveOp.fragment.go +11 -0
- package/project/.sdk/src/cmp/go/fragment/EntityUpdateOp.fragment.go +11 -0
- package/project/.sdk/src/cmp/go/utility_go.ts +70 -0
- package/project/.sdk/src/cmp/go-cli/Main_go-cli.ts +195 -0
- package/project/.sdk/src/cmp/go-cli/fragment/main.fragment.go +106 -0
- package/project/.sdk/src/cmp/go-cli/fragment/words.fragment.go +132 -0
- package/project/.sdk/src/cmp/go-mcp/Main_go-mcp.ts +184 -0
- package/project/.sdk/src/cmp/go-mcp/fragment/main.fragment.go +68 -0
- package/project/.sdk/src/cmp/go-mcp/fragment/tools.fragment.go +114 -0
- package/project/.sdk/src/cmp/js/Config_js.ts +3 -6
- package/project/.sdk/src/cmp/js/EntityTypes_js.ts +111 -0
- package/project/.sdk/src/cmp/js/MainEntity_js.ts +1 -0
- package/project/.sdk/src/cmp/js/Main_js.ts +3 -0
- package/project/.sdk/src/cmp/js/Package_js.ts +16 -7
- package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +33 -10
- package/project/.sdk/src/cmp/js/ReadmeExplanation_js.ts +2 -2
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +52 -11
- package/project/.sdk/src/cmp/js/ReadmeIntro_js.ts +39 -1
- package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +50 -18
- package/project/.sdk/src/cmp/js/ReadmeOptions_js.ts +4 -3
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +70 -20
- package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +50 -16
- package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +3 -0
- package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +45 -19
- package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +35 -3
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +5 -0
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +5 -0
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +5 -0
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +5 -0
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +5 -0
- package/project/.sdk/src/cmp/js/utility_js.ts +57 -0
- package/project/.sdk/src/cmp/lua/Config_lua.ts +3 -2
- package/project/.sdk/src/cmp/lua/EntityTypes_lua.ts +113 -0
- package/project/.sdk/src/cmp/lua/MainEntity_lua.ts +8 -0
- package/project/.sdk/src/cmp/lua/Main_lua.ts +4 -0
- package/project/.sdk/src/cmp/lua/Package_lua.ts +23 -4
- package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +50 -13
- package/project/.sdk/src/cmp/lua/ReadmeExamplesTest_lua.ts +293 -0
- package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +46 -8
- package/project/.sdk/src/cmp/lua/ReadmeInstall_lua.ts +19 -3
- package/project/.sdk/src/cmp/lua/ReadmeIntro_lua.ts +38 -1
- package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +51 -16
- package/project/.sdk/src/cmp/lua/ReadmeOptions_lua.ts +4 -3
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +156 -21
- package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +71 -23
- package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +46 -9
- package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +43 -5
- package/project/.sdk/src/cmp/lua/Test_lua.ts +4 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityCreateOp.fragment.lua +4 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityListOp.fragment.lua +4 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityLoadOp.fragment.lua +4 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityRemoveOp.fragment.lua +4 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityUpdateOp.fragment.lua +4 -0
- package/project/.sdk/src/cmp/php/Config_php.ts +3 -2
- package/project/.sdk/src/cmp/php/EntityTypes_php.ts +142 -0
- package/project/.sdk/src/cmp/php/MainEntity_php.ts +18 -1
- package/project/.sdk/src/cmp/php/Main_php.ts +4 -0
- package/project/.sdk/src/cmp/php/Package_php.ts +18 -7
- package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +46 -14
- package/project/.sdk/src/cmp/php/ReadmeExamplesTest_php.ts +401 -0
- package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +56 -13
- package/project/.sdk/src/cmp/php/ReadmeInstall_php.ts +15 -3
- package/project/.sdk/src/cmp/php/ReadmeIntro_php.ts +40 -1
- package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +26 -8
- package/project/.sdk/src/cmp/php/ReadmeOptions_php.ts +4 -3
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +159 -25
- package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +90 -45
- package/project/.sdk/src/cmp/php/ReadmeTopHowto_php.ts +1 -1
- package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +43 -11
- package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +52 -11
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +9 -9
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +6 -12
- package/project/.sdk/src/cmp/php/Test_php.ts +4 -0
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +13 -1
- package/project/.sdk/src/cmp/php/fragment/EntityCreateOp.fragment.php +10 -1
- package/project/.sdk/src/cmp/php/fragment/EntityListOp.fragment.php +10 -1
- package/project/.sdk/src/cmp/php/fragment/EntityLoadOp.fragment.php +10 -1
- package/project/.sdk/src/cmp/php/fragment/EntityRemoveOp.fragment.php +10 -1
- package/project/.sdk/src/cmp/php/fragment/EntityUpdateOp.fragment.php +10 -1
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +22 -14
- package/project/.sdk/src/cmp/py/Config_py.ts +3 -2
- package/project/.sdk/src/cmp/py/EntityTypes_py.ts +184 -0
- package/project/.sdk/src/cmp/py/Entity_py.ts +27 -0
- package/project/.sdk/src/cmp/py/MainEntity_py.ts +2 -1
- package/project/.sdk/src/cmp/py/Main_py.ts +35 -0
- package/project/.sdk/src/cmp/py/Package_py.ts +24 -3
- package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +48 -14
- package/project/.sdk/src/cmp/py/ReadmeExamplesTest_py.ts +626 -0
- package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +53 -14
- package/project/.sdk/src/cmp/py/ReadmeInstall_py.ts +19 -3
- package/project/.sdk/src/cmp/py/ReadmeIntro_py.ts +48 -1
- package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +28 -10
- package/project/.sdk/src/cmp/py/ReadmeOptions_py.ts +4 -3
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +150 -27
- package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +86 -40
- package/project/.sdk/src/cmp/py/ReadmeTopHowto_py.ts +1 -1
- package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +45 -11
- package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +43 -5
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +7 -9
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +6 -14
- package/project/.sdk/src/cmp/py/Test_py.ts +4 -0
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +5 -2
- package/project/.sdk/src/cmp/py/fragment/EntityCreateOp.fragment.py +1 -1
- package/project/.sdk/src/cmp/py/fragment/EntityListOp.fragment.py +5 -1
- package/project/.sdk/src/cmp/py/fragment/EntityLoadOp.fragment.py +6 -1
- package/project/.sdk/src/cmp/py/fragment/EntityRemoveOp.fragment.py +6 -1
- package/project/.sdk/src/cmp/py/fragment/EntityUpdateOp.fragment.py +1 -1
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +17 -10
- package/project/.sdk/src/cmp/rb/Config_rb.ts +3 -2
- package/project/.sdk/src/cmp/rb/EntityTypes_rb.ts +136 -0
- package/project/.sdk/src/cmp/rb/MainEntity_rb.ts +1 -0
- package/project/.sdk/src/cmp/rb/Main_rb.ts +4 -0
- package/project/.sdk/src/cmp/rb/Package_rb.ts +34 -7
- package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +47 -13
- package/project/.sdk/src/cmp/rb/ReadmeExamplesTest_rb.ts +289 -0
- package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +72 -21
- package/project/.sdk/src/cmp/rb/ReadmeInstall_rb.ts +16 -4
- package/project/.sdk/src/cmp/rb/ReadmeIntro_rb.ts +40 -1
- package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +29 -12
- package/project/.sdk/src/cmp/rb/ReadmeOptions_rb.ts +4 -3
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +163 -25
- package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +85 -40
- package/project/.sdk/src/cmp/rb/ReadmeTopHowto_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +45 -11
- package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +54 -11
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +9 -9
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +6 -12
- package/project/.sdk/src/cmp/rb/Test_rb.ts +4 -0
- package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +2 -0
- package/project/.sdk/src/cmp/rb/fragment/EntityCreateOp.fragment.rb +5 -0
- package/project/.sdk/src/cmp/rb/fragment/EntityListOp.fragment.rb +20 -2
- package/project/.sdk/src/cmp/rb/fragment/EntityLoadOp.fragment.rb +8 -1
- package/project/.sdk/src/cmp/rb/fragment/EntityRemoveOp.fragment.rb +6 -1
- package/project/.sdk/src/cmp/rb/fragment/EntityUpdateOp.fragment.rb +5 -0
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +24 -8
- package/project/.sdk/src/cmp/ts/Config_ts.ts +3 -6
- package/project/.sdk/src/cmp/ts/EntityTypes_ts.ts +105 -0
- package/project/.sdk/src/cmp/ts/Entity_ts.ts +17 -1
- package/project/.sdk/src/cmp/ts/MainEntity_ts.ts +1 -0
- package/project/.sdk/src/cmp/ts/Main_ts.ts +6 -0
- package/project/.sdk/src/cmp/ts/Package_ts.ts +14 -7
- package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +32 -10
- package/project/.sdk/src/cmp/ts/ReadmeExampleTest_ts.ts +81 -0
- package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +446 -0
- package/project/.sdk/src/cmp/ts/ReadmeExplanation_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +57 -11
- package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts +19 -6
- package/project/.sdk/src/cmp/ts/ReadmeIntro_ts.ts +39 -1
- package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +50 -18
- package/project/.sdk/src/cmp/ts/ReadmeOptions_ts.ts +4 -3
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +141 -48
- package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +50 -16
- package/project/.sdk/src/cmp/ts/ReadmeTopHowto_ts.ts +3 -0
- package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +58 -19
- package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +35 -3
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/Test_ts.ts +5 -0
- package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +3 -1
- package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +10 -5
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +4 -2
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +4 -2
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +4 -2
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +4 -2
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +4 -2
- package/project/.sdk/src/cmp/ts/utility_ts.ts +59 -0
- package/project/.sdk/tm/go/LICENSE +1 -1
- package/project/.sdk/tm/go/Makefile +36 -1
- package/project/.sdk/tm/go/VERSION +1 -0
- package/project/.sdk/tm/go/core/context.go +12 -7
- package/project/.sdk/tm/go-cli/src/feature/README.md +6 -0
- package/project/.sdk/tm/go-cli/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/go-cli/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/README.md +6 -0
- package/project/.sdk/tm/go-mcp/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/go-mcp/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/js/LICENSE +1 -1
- package/project/.sdk/tm/js/Makefile +41 -0
- package/project/.sdk/tm/lua/LICENSE +1 -1
- package/project/.sdk/tm/lua/Makefile +40 -1
- package/project/.sdk/tm/lua/core/context.lua +13 -8
- package/project/.sdk/tm/php/LICENSE +1 -1
- package/project/.sdk/tm/php/Makefile +31 -1
- package/project/.sdk/tm/php/VERSION +1 -0
- package/project/.sdk/tm/php/core/Context.php +12 -6
- package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +13 -4
- package/project/.sdk/tm/php/utility/Done.php +2 -2
- package/project/.sdk/tm/php/utility/MakeError.php +3 -3
- package/project/.sdk/tm/py/LICENSE +1 -1
- package/project/.sdk/tm/py/Makefile +34 -1
- package/project/.sdk/tm/py/core/context.py +12 -7
- package/project/.sdk/tm/py/test/test_primary_utility.py +15 -4
- package/project/.sdk/tm/py/test/test_struct_utility.py +1 -1
- package/project/.sdk/tm/py/utility/done.py +3 -1
- package/project/.sdk/tm/py/utility/make_error.py +2 -2
- package/project/.sdk/tm/rb/LICENSE +1 -1
- package/project/.sdk/tm/rb/Makefile +36 -2
- package/project/.sdk/tm/rb/core/context.rb +8 -3
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +2 -2
- package/project/.sdk/tm/rb/utility/done.rb +3 -1
- package/project/.sdk/tm/rb/utility/make_error.rb +5 -2
- package/project/.sdk/tm/ts/LICENSE +1 -1
- package/project/.sdk/tm/ts/Makefile +42 -0
- package/project/.sdk/tm/ts/src/Context.ts +8 -3
- package/src/action/action.ts +30 -11
- package/src/action/feature.ts +12 -14
- package/src/action/target.ts +28 -17
- package/src/cmp/Changelog.ts +34 -0
- package/src/cmp/Deploy.ts +258 -0
- package/src/cmp/FeatureHook.ts +6 -8
- package/src/cmp/License.ts +49 -0
- package/src/cmp/Readme.ts +2 -0
- package/src/cmp/ReadmeErrors.ts +257 -0
- package/src/cmp/ReadmeExplanation.ts +250 -230
- package/src/cmp/ReadmeModel.ts +7 -2
- package/src/cmp/ReadmeTop.ts +411 -95
- package/src/cmp/Security.ts +41 -0
- package/src/helpers/canonType.ts +89 -0
- package/src/helpers/collectDeps.ts +5 -3
- package/src/helpers/naming.ts +59 -0
- package/src/helpers/opExample.ts +170 -0
- package/src/helpers/opShape.ts +274 -0
- package/src/helpers/packageMeta.ts +236 -0
- package/src/sdkgen.ts +91 -23
- package/src/tsconfig.json +1 -0
- package/src/types.ts +85 -2
- package/src/utility.ts +45 -11
- package/README.md +0 -2
- package/dist/action/lang.d.ts +0 -2
- package/dist/action/lang.js +0 -68
- package/dist/action/lang.js.map +0 -1
- package/dist/cmp/Hook.d.ts +0 -2
- package/dist/cmp/Hook.js +0 -10
- package/dist/cmp/Hook.js.map +0 -1
- package/dist/cmp/Top.d.ts +0 -2
- package/dist/cmp/Top.js +0 -23
- package/dist/cmp/Top.js.map +0 -1
- package/dist/prepare-openapi.d.ts +0 -2
- package/dist/prepare-openapi.js +0 -37
- package/dist/prepare-openapi.js.map +0 -1
- package/model/sdkgen.jsonic +0 -74
- package/project/.sdk/model/feature/feature-index.jsonic +0 -5
- package/project/.sdk/model/target/go.jsonic +0 -22
- package/project/.sdk/tm/go/utility/struct/go.mod +0 -3
- /package/project/.sdk/model/feature/{log.jsonic → log.aontu} +0 -0
- /package/project/.sdk/model/feature/{test.jsonic → test.aontu} +0 -0
|
@@ -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, entityOps, opRequestShape } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
6
6
|
getModelPath,
|
|
7
7
|
} from '@voxgig/apidef'
|
|
8
8
|
|
|
9
|
+
import { exampleValue, goVarName } from './utility_go'
|
|
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\` | \`map[string]any\` | 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"]\` | \`map[string]any\` | Custom headers for all requests. |
|
|
@@ -86,12 +87,20 @@ Create a new SDK client instance.
|
|
|
86
87
|
|
|
87
88
|
`)
|
|
88
89
|
|
|
89
|
-
Content(`#### \`
|
|
90
|
+
Content(`#### \`Test() *${model.const.Name}SDK\`
|
|
91
|
+
|
|
92
|
+
No-arg convenience constructor for the common no-options test case.
|
|
93
|
+
|
|
94
|
+
\`\`\`go
|
|
95
|
+
client := sdk.Test()
|
|
96
|
+
\`\`\`
|
|
97
|
+
|
|
98
|
+
#### \`TestSDK(testopts, sdkopts map[string]any) *${model.const.Name}SDK\`
|
|
90
99
|
|
|
91
|
-
|
|
100
|
+
Test client with options. Both arguments may be \`nil\`.
|
|
92
101
|
|
|
93
102
|
\`\`\`go
|
|
94
|
-
client := sdk.TestSDK(
|
|
103
|
+
client := sdk.TestSDK(testopts, sdkopts)
|
|
95
104
|
\`\`\`
|
|
96
105
|
|
|
97
106
|
`)
|
|
@@ -151,8 +160,16 @@ same parameters as \`Direct()\`.
|
|
|
151
160
|
|
|
152
161
|
// Entity reference sections
|
|
153
162
|
publishedEntities.map((ent: any) => {
|
|
154
|
-
|
|
163
|
+
// ACTIVE ops only — an inactive op generates no method, so an example
|
|
164
|
+
// calling it would not compile.
|
|
165
|
+
const opnames = entityOps(ent)
|
|
155
166
|
const fields = ent.fields || []
|
|
167
|
+
// Model-driven id key: null when this entity has no id-like field, in
|
|
168
|
+
// which case load/remove pass a nil match and update omits the id.
|
|
169
|
+
const idF = entityIdField(ent)
|
|
170
|
+
// camelCase Go identifier (a `status_embed_config` entity must not bind
|
|
171
|
+
// a snake_case Go variable).
|
|
172
|
+
const eVar = goVarName(ent.name)
|
|
156
173
|
|
|
157
174
|
Content(`
|
|
158
175
|
---
|
|
@@ -168,7 +185,8 @@ same parameters as \`Direct()\`.
|
|
|
168
185
|
}
|
|
169
186
|
|
|
170
187
|
Content(`\`\`\`go
|
|
171
|
-
${
|
|
188
|
+
${eVar} := client.${ent.Name}(nil)
|
|
189
|
+
fmt.Println(${eVar}.GetName()) // "${ent.name}"
|
|
172
190
|
\`\`\`
|
|
173
191
|
|
|
174
192
|
`)
|
|
@@ -184,7 +202,7 @@ ${ent.name} := client.${ent.Name}(nil)
|
|
|
184
202
|
each(fields, (field: any) => {
|
|
185
203
|
const req = field.req ? 'Yes' : 'No'
|
|
186
204
|
const desc = field.short || ''
|
|
187
|
-
Content(`| \`${field.name}\` | \`${field.type
|
|
205
|
+
Content(`| \`${field.name}\` | \`${canonToType(field.type, target.name)}\` | ${req} | ${desc} |
|
|
188
206
|
`)
|
|
189
207
|
})
|
|
190
208
|
|
|
@@ -194,15 +212,19 @@ ${ent.name} := client.${ent.Name}(nil)
|
|
|
194
212
|
// Field operations breakdown
|
|
195
213
|
const hasFieldOps = fields.some((f: any) => f.op && Object.keys(f.op).length > 0)
|
|
196
214
|
if (hasFieldOps) {
|
|
215
|
+
// Only emit columns for operations this entity actually exposes —
|
|
216
|
+
// never advertise a create/update/remove column the entity lacks
|
|
217
|
+
// (opnames already carries active ops only).
|
|
218
|
+
const opcols = ['load', 'list', 'create', 'update', 'remove']
|
|
219
|
+
.filter((op: string) => opnames.includes(op))
|
|
197
220
|
Content(`### Field Usage by Operation
|
|
198
221
|
|
|
199
|
-
| Field |
|
|
200
|
-
| --- |
|
|
222
|
+
| Field | ${opcols.join(' | ')} |
|
|
223
|
+
| --- | ${opcols.map(() => '---').join(' | ')} |
|
|
201
224
|
`)
|
|
202
225
|
each(fields, (field: any) => {
|
|
203
226
|
const fops = field.op || {}
|
|
204
|
-
const cols =
|
|
205
|
-
if (!opnames.includes(op)) return '-'
|
|
227
|
+
const cols = opcols.map((op: string) => {
|
|
206
228
|
const fop = fops[op]
|
|
207
229
|
if (null == fop) return '-'
|
|
208
230
|
if (fop.active === false) return '-'
|
|
@@ -234,11 +256,29 @@ ${info.desc}
|
|
|
234
256
|
|
|
235
257
|
`)
|
|
236
258
|
|
|
237
|
-
// Show example
|
|
259
|
+
// Show example. Every compiled example is self-consuming — check
|
|
260
|
+
// `err` and print the result — so the doc gate builds it without
|
|
261
|
+
// unused-variable repairs, and readers see the idiomatic pattern.
|
|
238
262
|
if ('load' === opname || 'remove' === opname) {
|
|
239
263
|
const goOpName = opname.charAt(0).toUpperCase() + opname.slice(1)
|
|
264
|
+
// The id key plus every REQUIRED match key (parent path params
|
|
265
|
+
// like page_id) — the same shape that generates the op's request
|
|
266
|
+
// match, so the example always carries the keys the route needs.
|
|
267
|
+
const matchItems = opRequestShape(ent, opname).items
|
|
268
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
269
|
+
.sort((a: any, b: any) =>
|
|
270
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
271
|
+
const arg = 0 < matchItems.length
|
|
272
|
+
? `map[string]any{${matchItems.map((it: any) =>
|
|
273
|
+
`"${it.name}": ${exampleValue(ent, ent.op && ent.op[opname], it.name,
|
|
274
|
+
it.name === idF ? ent.name + '_id' : it.name)}`).join(', ')}}`
|
|
275
|
+
: 'nil'
|
|
240
276
|
Content(`\`\`\`go
|
|
241
|
-
result, err := client.${ent.Name}(nil).${goOpName}(
|
|
277
|
+
result, err := client.${ent.Name}(nil).${goOpName}(${arg}, nil)
|
|
278
|
+
if err != nil {
|
|
279
|
+
panic(err)
|
|
280
|
+
}
|
|
281
|
+
fmt.Println(result)
|
|
242
282
|
\`\`\`
|
|
243
283
|
|
|
244
284
|
`)
|
|
@@ -246,31 +286,57 @@ result, err := client.${ent.Name}(nil).${goOpName}(map[string]any{"id": "${ent.n
|
|
|
246
286
|
else if ('list' === opname) {
|
|
247
287
|
Content(`\`\`\`go
|
|
248
288
|
results, err := client.${ent.Name}(nil).List(nil, nil)
|
|
289
|
+
if err != nil {
|
|
290
|
+
panic(err)
|
|
291
|
+
}
|
|
292
|
+
fmt.Println(results)
|
|
249
293
|
\`\`\`
|
|
250
294
|
|
|
251
295
|
`)
|
|
252
296
|
}
|
|
253
297
|
else if ('create' === opname) {
|
|
298
|
+
// Members come from the SAME shape that generates the op's
|
|
299
|
+
// request data: every required member must appear — including a
|
|
300
|
+
// required id (the /* type */ placeholders also mark the block
|
|
301
|
+
// as an illustration for the doc gates); an all-optional create
|
|
302
|
+
// renders an empty — still valid — literal.
|
|
303
|
+
const createItems = opRequestShape(ent, 'create').items
|
|
304
|
+
.filter((it: any) => !it.optional)
|
|
254
305
|
Content(`\`\`\`go
|
|
255
306
|
result, err := client.${ent.Name}(nil).Create(map[string]any{
|
|
256
307
|
`)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
Content(` "${field.name}": /* ${field.type || 'value'} */,
|
|
308
|
+
createItems.map((it: any) => {
|
|
309
|
+
Content(` "${it.name}": /* ${canonToType(it.type, target.name)} */,
|
|
260
310
|
`)
|
|
261
|
-
}
|
|
262
311
|
})
|
|
263
312
|
Content(`}, nil)
|
|
313
|
+
if err != nil {
|
|
314
|
+
panic(err)
|
|
315
|
+
}
|
|
316
|
+
fmt.Println(result)
|
|
264
317
|
\`\`\`
|
|
265
318
|
|
|
266
319
|
`)
|
|
267
320
|
}
|
|
268
321
|
else if ('update' === opname) {
|
|
322
|
+
// The id key plus every REQUIRED data member — the same shape
|
|
323
|
+
// that generates the op's request data — then the patch-fields
|
|
324
|
+
// note.
|
|
325
|
+
const updateItems = opRequestShape(ent, 'update').items
|
|
326
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
327
|
+
.sort((a: any, b: any) =>
|
|
328
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
329
|
+
const updateLines = updateItems.map((it: any) =>
|
|
330
|
+
` "${it.name}": ${exampleValue(ent, ent.op && ent.op.update, it.name,
|
|
331
|
+
it.name === idF ? ent.name + '_id' : it.name)},\n`).join('')
|
|
269
332
|
Content(`\`\`\`go
|
|
270
333
|
result, err := client.${ent.Name}(nil).Update(map[string]any{
|
|
271
|
-
|
|
272
|
-
// Fields to update
|
|
334
|
+
${updateLines} // Fields to update
|
|
273
335
|
}, nil)
|
|
336
|
+
if err != nil {
|
|
337
|
+
panic(err)
|
|
338
|
+
}
|
|
339
|
+
fmt.Println(result)
|
|
274
340
|
\`\`\`
|
|
275
341
|
|
|
276
342
|
`)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, entityIdField, entityOps, opRequestShape } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -7,54 +7,113 @@ import {
|
|
|
7
7
|
nom,
|
|
8
8
|
} from '@voxgig/apidef'
|
|
9
9
|
|
|
10
|
+
import { exampleValue, goVarName } from './utility_go'
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
12
14
|
const { target, ctx$: { model } } = props
|
|
13
15
|
|
|
14
16
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
15
17
|
// Go module path == repo path on GitHub (org from model.origin).
|
|
16
|
-
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
|
|
18
|
+
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
|
|
17
19
|
|
|
18
20
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
19
21
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
:
|
|
22
|
+
const authActive = isAuthActive(model)
|
|
23
|
+
const ctor = authActive
|
|
24
|
+
? `sdk.New${model.const.Name}SDK(map[string]any{\n "apikey": os.Getenv("${envName(model)}_APIKEY"),\n})`
|
|
25
|
+
: `sdk.New()`
|
|
23
26
|
|
|
24
27
|
Content(`\`\`\`go
|
|
25
28
|
import sdk "${gomodule}"
|
|
26
29
|
|
|
27
|
-
client :=
|
|
30
|
+
client := ${ctor}
|
|
28
31
|
|
|
29
32
|
`)
|
|
30
33
|
|
|
31
34
|
if (exampleEntity) {
|
|
32
35
|
const eName = nom(exampleEntity, 'Name')
|
|
33
|
-
|
|
36
|
+
// camelCase Go identifier (never snake_case, never a Go keyword).
|
|
37
|
+
const eVar = goVarName(exampleEntity.name)
|
|
38
|
+
// ACTIVE ops only — an inactive op generates no method, so an example
|
|
39
|
+
// calling it would not compile.
|
|
40
|
+
const opnames = entityOps(exampleEntity)
|
|
41
|
+
|
|
42
|
+
let hasCall = false
|
|
34
43
|
|
|
35
44
|
if (opnames.includes('list')) {
|
|
36
45
|
Content(`// List all ${eName.toLowerCase()}s
|
|
37
|
-
${
|
|
46
|
+
${eVar}s, err := client.${eName}(nil).List(nil, nil)
|
|
47
|
+
if err != nil {
|
|
48
|
+
panic(err)
|
|
49
|
+
}
|
|
50
|
+
fmt.Println(${eVar}s)
|
|
38
51
|
`)
|
|
52
|
+
hasCall = true
|
|
39
53
|
}
|
|
40
54
|
|
|
41
|
-
// Find a nested entity for a more interesting example
|
|
55
|
+
// Find a nested entity for a more interesting example: one with a parent
|
|
56
|
+
// chain (relations.ancestors), an active load op, and a required non-id
|
|
57
|
+
// load param to demonstrate (the parent key, e.g. page_id).
|
|
42
58
|
const nestedEntity = Object.values(entity).find((e: any) =>
|
|
43
|
-
e.active !== false &&
|
|
59
|
+
e.active !== false &&
|
|
60
|
+
e.relations && e.relations.ancestors && 0 < e.relations.ancestors.length &&
|
|
61
|
+
entityOps(e).includes('load') &&
|
|
62
|
+
opRequestShape(e, 'load').items.some((it: any) =>
|
|
63
|
+
!it.optional && it.name !== entityIdField(e))
|
|
44
64
|
) as any
|
|
45
65
|
|
|
46
|
-
if (nestedEntity
|
|
66
|
+
if (nestedEntity) {
|
|
47
67
|
const neName = nom(nestedEntity, 'Name')
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
const neVar = goVarName(nestedEntity.name)
|
|
69
|
+
// Model-driven match: every REQUIRED load-match key — the same shape
|
|
70
|
+
// that generates the op's request match, so the example always carries
|
|
71
|
+
// the keys the route needs. Parent keys (e.g. page_id) first, the
|
|
72
|
+
// entity's own id last, each value a type-correct Go literal.
|
|
73
|
+
const neIdF = entityIdField(nestedEntity)
|
|
74
|
+
const neLoadOp = nestedEntity.op && nestedEntity.op.load
|
|
75
|
+
const neMatchPairs = opRequestShape(nestedEntity, 'load').items
|
|
76
|
+
.filter((it: any) => !it.optional)
|
|
77
|
+
.sort((a: any, b: any) =>
|
|
78
|
+
(a.name === neIdF ? 1 : 0) - (b.name === neIdF ? 1 : 0))
|
|
79
|
+
.map((it: any) =>
|
|
80
|
+
`"${it.name}": ${exampleValue(nestedEntity, neLoadOp, it.name,
|
|
81
|
+
it.name === neIdF ? 'example_id' : 'example_' + it.name)}`)
|
|
51
82
|
|
|
52
83
|
Content(`
|
|
53
84
|
// Load a specific ${neName.toLowerCase()}
|
|
54
|
-
${
|
|
55
|
-
map[string]any{
|
|
85
|
+
${neVar}, err := client.${neName}(nil).Load(
|
|
86
|
+
map[string]any{${neMatchPairs.join(', ')}}, nil,
|
|
56
87
|
)
|
|
88
|
+
if err != nil {
|
|
89
|
+
panic(err)
|
|
90
|
+
}
|
|
91
|
+
fmt.Println(${neVar})
|
|
92
|
+
`)
|
|
93
|
+
hasCall = true
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Fallback: APIs with only `load` (no list, no nested) — still show one call.
|
|
97
|
+
if (!hasCall && opnames.includes('load')) {
|
|
98
|
+
// Every REQUIRED load-match key (id first) — nil when there are none.
|
|
99
|
+
const idF = entityIdField(exampleEntity)
|
|
100
|
+
const loadItems = opRequestShape(exampleEntity, 'load').items
|
|
101
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
102
|
+
.sort((a: any, b: any) =>
|
|
103
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
104
|
+
const loadArg = 0 < loadItems.length
|
|
105
|
+
? `map[string]any{${loadItems.map((it: any) =>
|
|
106
|
+
`"${it.name}": ${exampleValue(exampleEntity, exampleEntity.op && exampleEntity.op.load, it.name,
|
|
107
|
+
it.name === idF ? 'example_id' : 'example_' + it.name)}`).join(', ')}}`
|
|
108
|
+
: 'nil'
|
|
109
|
+
Content(`// Load ${eName.toLowerCase()} data
|
|
110
|
+
${eVar}, err := client.${eName}(nil).Load(${loadArg}, nil)
|
|
111
|
+
if err != nil {
|
|
112
|
+
panic(err)
|
|
113
|
+
}
|
|
114
|
+
fmt.Println(${eVar})
|
|
57
115
|
`)
|
|
116
|
+
hasCall = true
|
|
58
117
|
}
|
|
59
118
|
}
|
|
60
119
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, canonKey, entityIdField, entityPrimaryOp, opRequestShape } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -8,23 +8,53 @@ import {
|
|
|
8
8
|
} from '@voxgig/apidef'
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
// A type-correct Go literal for a field's canonical type.
|
|
12
|
+
function goLit(type: any): string {
|
|
13
|
+
const k = canonKey(type)
|
|
14
|
+
if ('INTEGER' === k || 'NUMBER' === k) return '1'
|
|
15
|
+
if ('BOOLEAN' === k) return 'true'
|
|
16
|
+
if ('ARRAY' === k) return '[]any{}'
|
|
17
|
+
if ('OBJECT' === k) return 'map[string]any{}'
|
|
18
|
+
return '"example"'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function cap(s: string): string {
|
|
22
|
+
return s.charAt(0).toUpperCase() + s.slice(1)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
11
26
|
const ReadmeTopTest = cmp(function ReadmeTopTest(props: any) {
|
|
12
27
|
const { target, ctx$: { model } } = props
|
|
13
28
|
|
|
14
29
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
15
30
|
// Go module path == repo path on GitHub (org from model.origin).
|
|
16
|
-
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
|
|
31
|
+
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
|
|
17
32
|
|
|
18
33
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
19
34
|
|
|
20
35
|
Content(`\`\`\`go
|
|
21
|
-
client := sdk.
|
|
36
|
+
client := sdk.Test()
|
|
22
37
|
`)
|
|
23
38
|
|
|
24
39
|
if (exampleEntity) {
|
|
25
40
|
const eName = nom(exampleEntity, 'Name')
|
|
26
|
-
|
|
27
|
-
|
|
41
|
+
// Drive the test-mode example off the entity's PRIMARY op (never a hardcoded
|
|
42
|
+
// `Load` a create-only entity lacks).
|
|
43
|
+
const idF = entityIdField(exampleEntity)
|
|
44
|
+
const primaryOp = entityPrimaryOp(exampleEntity) || 'load'
|
|
45
|
+
const isMatchOp = 'load' === primaryOp || 'remove' === primaryOp
|
|
46
|
+
let arg = 'nil'
|
|
47
|
+
if (isMatchOp) {
|
|
48
|
+
arg = idF ? `map[string]any{"${idF}": "test01"}` : 'nil'
|
|
49
|
+
} else if ('create' === primaryOp || 'update' === primaryOp) {
|
|
50
|
+
const items = opRequestShape(exampleEntity, primaryOp).items
|
|
51
|
+
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
52
|
+
const required = items.filter((it: any) => !it.optional)
|
|
53
|
+
const chosen = required.length ? required : items.slice(0, 3)
|
|
54
|
+
arg = `map[string]any{${chosen.map((it: any) => `"${it.name}": ${goLit(it.type)}`).join(', ')}}`
|
|
55
|
+
}
|
|
56
|
+
Content(`result, err := client.${eName}(nil).${cap(primaryOp)}(
|
|
57
|
+
${arg}, nil,
|
|
28
58
|
)
|
|
29
59
|
`)
|
|
30
60
|
}
|
|
@@ -13,6 +13,7 @@ import { cmp, each, Folder, File, Content } from '@voxgig/sdkgen'
|
|
|
13
13
|
|
|
14
14
|
import { TestEntity } from './TestEntity_go'
|
|
15
15
|
import { TestDirect } from './TestDirect_go'
|
|
16
|
+
import { ReadmeExamplesTest } from './ReadmeExamplesTest_go'
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
const Test = cmp(function Test(props: any) {
|
|
@@ -21,7 +22,7 @@ const Test = cmp(function Test(props: any) {
|
|
|
21
22
|
|
|
22
23
|
// Module name: concatenated lowercase
|
|
23
24
|
// Go module path == repo path on GitHub (org from model.origin).
|
|
24
|
-
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
|
|
25
|
+
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
|
|
25
26
|
|
|
26
27
|
Folder({ name: 'test' }, () => {
|
|
27
28
|
|
|
@@ -51,6 +52,9 @@ func TestExists(t *testing.T) {
|
|
|
51
52
|
TestEntity({ target, entity, gomodule })
|
|
52
53
|
TestDirect({ target, entity, gomodule })
|
|
53
54
|
})
|
|
55
|
+
|
|
56
|
+
// README ```go example snippets must compile against the real SDK.
|
|
57
|
+
ReadmeExamplesTest({ target })
|
|
54
58
|
})
|
|
55
59
|
})
|
|
56
60
|
|
|
@@ -85,6 +85,27 @@ func (e *EntityNameEntity) Match(args ...any) any {
|
|
|
85
85
|
return out
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
// DataTyped is the statically-typed accessor for this entity's data. With no
|
|
89
|
+
// argument it returns the current data as an EntityName; with an argument it
|
|
90
|
+
// sets the data and returns the stored value. It delegates to the untyped Data
|
|
91
|
+
// (identical runtime) and converts at the typed boundary.
|
|
92
|
+
func (e *EntityNameEntity) DataTyped(data ...EntityName) EntityName {
|
|
93
|
+
if len(data) > 0 {
|
|
94
|
+
return typedFrom[EntityName](e.Data(asMap(data[0])))
|
|
95
|
+
}
|
|
96
|
+
return typedFrom[EntityName](e.Data())
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// MatchTyped mirrors DataTyped for the entity's match filter. The match is a
|
|
100
|
+
// partial of the entity, so it round-trips through EntityName (all fields
|
|
101
|
+
// optional at the wire level).
|
|
102
|
+
func (e *EntityNameEntity) MatchTyped(match ...EntityName) EntityName {
|
|
103
|
+
if len(match) > 0 {
|
|
104
|
+
return typedFrom[EntityName](e.Match(asMap(match[0])))
|
|
105
|
+
}
|
|
106
|
+
return typedFrom[EntityName](e.Match())
|
|
107
|
+
}
|
|
108
|
+
|
|
88
109
|
// #LoadOp
|
|
89
110
|
|
|
90
111
|
// #ListOp
|
|
@@ -32,4 +32,15 @@ func (e *EntityNameEntity) Create(reqdata map[string]any, ctrl map[string]any) (
|
|
|
32
32
|
})
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// CreateTyped is the statically-typed variant of Create: it takes an
|
|
36
|
+
// EntityNameCreateData and returns an EntityName. It delegates to the untyped
|
|
37
|
+
// Create (identical runtime) and converts at the typed boundary.
|
|
38
|
+
func (e *EntityNameEntity) CreateTyped(reqdata EntityNameCreateData, ctrl map[string]any) (EntityName, error) {
|
|
39
|
+
res, err := e.Create(asMap(reqdata), ctrl)
|
|
40
|
+
if err != nil {
|
|
41
|
+
return EntityName{}, err
|
|
42
|
+
}
|
|
43
|
+
return typedFrom[EntityName](res), nil
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
// EJECT-END
|
|
@@ -23,4 +23,15 @@ func (e *EntityNameEntity) List(reqmatch map[string]any, ctrl map[string]any) (a
|
|
|
23
23
|
})
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// ListTyped is the statically-typed variant of List: it takes an
|
|
27
|
+
// EntityNameListMatch and returns []EntityName. It delegates to the untyped
|
|
28
|
+
// List (identical runtime) and converts at the typed boundary.
|
|
29
|
+
func (e *EntityNameEntity) ListTyped(reqmatch EntityNameListMatch, ctrl map[string]any) ([]EntityName, error) {
|
|
30
|
+
res, err := e.List(asMap(reqmatch), ctrl)
|
|
31
|
+
if err != nil {
|
|
32
|
+
return nil, err
|
|
33
|
+
}
|
|
34
|
+
return typedSliceFrom[EntityName](res), nil
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
// EJECT-END
|
|
@@ -35,4 +35,15 @@ func (e *EntityNameEntity) Load(reqmatch map[string]any, ctrl map[string]any) (a
|
|
|
35
35
|
})
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// LoadTyped is the statically-typed variant of Load: it takes an
|
|
39
|
+
// EntityNameLoadMatch and returns an EntityName. It delegates to the untyped
|
|
40
|
+
// Load (identical runtime) and converts at the typed boundary.
|
|
41
|
+
func (e *EntityNameEntity) LoadTyped(reqmatch EntityNameLoadMatch, ctrl map[string]any) (EntityName, error) {
|
|
42
|
+
res, err := e.Load(asMap(reqmatch), ctrl)
|
|
43
|
+
if err != nil {
|
|
44
|
+
return EntityName{}, err
|
|
45
|
+
}
|
|
46
|
+
return typedFrom[EntityName](res), nil
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
// EJECT-END
|
|
@@ -35,4 +35,15 @@ func (e *EntityNameEntity) Remove(reqmatch map[string]any, ctrl map[string]any)
|
|
|
35
35
|
})
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// RemoveTyped is the statically-typed variant of Remove: it takes an
|
|
39
|
+
// EntityNameRemoveMatch and returns an EntityName. It delegates to the untyped
|
|
40
|
+
// Remove (identical runtime) and converts at the typed boundary.
|
|
41
|
+
func (e *EntityNameEntity) RemoveTyped(reqmatch EntityNameRemoveMatch, ctrl map[string]any) (EntityName, error) {
|
|
42
|
+
res, err := e.Remove(asMap(reqmatch), ctrl)
|
|
43
|
+
if err != nil {
|
|
44
|
+
return EntityName{}, err
|
|
45
|
+
}
|
|
46
|
+
return typedFrom[EntityName](res), nil
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
// EJECT-END
|
|
@@ -35,4 +35,15 @@ func (e *EntityNameEntity) Update(reqdata map[string]any, ctrl map[string]any) (
|
|
|
35
35
|
})
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// UpdateTyped is the statically-typed variant of Update: it takes an
|
|
39
|
+
// EntityNameUpdateData and returns an EntityName. It delegates to the untyped
|
|
40
|
+
// Update (identical runtime) and converts at the typed boundary.
|
|
41
|
+
func (e *EntityNameEntity) UpdateTyped(reqdata EntityNameUpdateData, ctrl map[string]any) (EntityName, error) {
|
|
42
|
+
res, err := e.Update(asMap(reqdata), ctrl)
|
|
43
|
+
if err != nil {
|
|
44
|
+
return EntityName{}, err
|
|
45
|
+
}
|
|
46
|
+
return typedFrom[EntityName](res), nil
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
// EJECT-END
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
import * as Path from 'node:path'
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
import {
|
|
6
|
+
camelify,
|
|
7
|
+
canonKey,
|
|
8
|
+
each,
|
|
9
|
+
safeVarName,
|
|
10
|
+
} from '@voxgig/sdkgen'
|
|
11
|
+
|
|
5
12
|
import {
|
|
6
13
|
clone,
|
|
7
14
|
walk,
|
|
@@ -13,6 +20,67 @@ function projectPath(suffix?: string): string {
|
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
|
|
23
|
+
// --- Model-driven example literals -----------------------------------------
|
|
24
|
+
// Doc snippets must use example values whose TYPE matches the model's
|
|
25
|
+
// declared param/field type — a number id shown as a quoted string documents
|
|
26
|
+
// a call the API would reject. These helpers derive the example literal from
|
|
27
|
+
// the SAME model source the request shapes are built from (opRequestShape),
|
|
28
|
+
// so the docs and the model can never disagree. Go twin of the ts
|
|
29
|
+
// exampleValue (cmp/ts/utility_ts.ts), rendering Go literals.
|
|
30
|
+
|
|
31
|
+
// The declared canon-type sentinel of a named parameter of an op — looked up
|
|
32
|
+
// in the op's `points[].args.params[]` exactly as the typed-model generator
|
|
33
|
+
// does. Falls back to the entity field of the same name (used when the op
|
|
34
|
+
// has no params and the request shape mirrors the entity fields). Returns
|
|
35
|
+
// undefined when neither is present.
|
|
36
|
+
function paramCanonType(entity: any, op: any, paramName: string): unknown {
|
|
37
|
+
const points = op && op.points ? each(op.points) : []
|
|
38
|
+
for (const pt of points as any[]) {
|
|
39
|
+
const params = pt && pt.args && pt.args.params ? each(pt.args.params) : []
|
|
40
|
+
const found = (params as any[]).find((p: any) => p && p.name === paramName)
|
|
41
|
+
if (found) {
|
|
42
|
+
return found.type
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const field = (entity && entity.fields ? each(entity.fields) : [])
|
|
46
|
+
.find((f: any) => f && f.name === paramName) as any
|
|
47
|
+
return field && field.type
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
// A type-correct Go example literal for a named match/data parameter of an
|
|
52
|
+
// op, derived entirely from the model. INTEGER/NUMBER render as the bare
|
|
53
|
+
// number `1`, BOOLEAN as `true`, ARRAY as the empty `[]any{}` and OBJECT as
|
|
54
|
+
// the empty `map[string]any{}`, everything else (STRING, unknown, missing)
|
|
55
|
+
// as the quoted `placeholder`.
|
|
56
|
+
function exampleValue(entity: any, op: any, paramName: string, placeholder: string): string {
|
|
57
|
+
const key = canonKey(paramCanonType(entity, op, paramName))
|
|
58
|
+
if ('INTEGER' === key || 'NUMBER' === key) {
|
|
59
|
+
return '1'
|
|
60
|
+
}
|
|
61
|
+
if ('BOOLEAN' === key) {
|
|
62
|
+
return 'true'
|
|
63
|
+
}
|
|
64
|
+
if ('ARRAY' === key) {
|
|
65
|
+
return '[]any{}'
|
|
66
|
+
}
|
|
67
|
+
if ('OBJECT' === key) {
|
|
68
|
+
return 'map[string]any{}'
|
|
69
|
+
}
|
|
70
|
+
return `"${placeholder}"`
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// A camelCase Go identifier for a snake_case model name
|
|
75
|
+
// (`status_embed_config` -> `statusEmbedConfig`) — Go variables are
|
|
76
|
+
// camelCase, never snake_case — with the reserved-word guard applied (a
|
|
77
|
+
// `type`/`range` entity must not bind a Go keyword).
|
|
78
|
+
function goVarName(name: string): string {
|
|
79
|
+
const pascal = camelify(name)
|
|
80
|
+
return safeVarName(pascal.charAt(0).toLowerCase() + pascal.slice(1), 'go')
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
16
84
|
function formatGoMap(obj: any, indent: number = 0): string {
|
|
17
85
|
if (obj == null) {
|
|
18
86
|
return 'nil'
|
|
@@ -82,7 +150,9 @@ function clean(o: any) {
|
|
|
82
150
|
|
|
83
151
|
export {
|
|
84
152
|
clean,
|
|
153
|
+
exampleValue,
|
|
85
154
|
formatGoMap,
|
|
86
155
|
formatGoValue,
|
|
156
|
+
goVarName,
|
|
87
157
|
projectPath,
|
|
88
158
|
}
|