@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,20 +1,61 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, canonKey, entityIdField, entityPrimaryOp, opRequestShape } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
6
6
|
getModelPath,
|
|
7
|
+
nom,
|
|
7
8
|
} from '@voxgig/apidef'
|
|
8
9
|
|
|
10
|
+
import { goVarName } from './utility_go'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
// A type-correct Go literal for a field's canonical type.
|
|
14
|
+
function goLit(type: any): string {
|
|
15
|
+
const k = canonKey(type)
|
|
16
|
+
if ('INTEGER' === k || 'NUMBER' === k) return '1'
|
|
17
|
+
if ('BOOLEAN' === k) return 'true'
|
|
18
|
+
if ('ARRAY' === k) return '[]any{}'
|
|
19
|
+
if ('OBJECT' === k) return 'map[string]any{}'
|
|
20
|
+
return '"example"'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function cap(s: string): string {
|
|
24
|
+
return s.charAt(0).toUpperCase() + s.slice(1)
|
|
25
|
+
}
|
|
26
|
+
|
|
9
27
|
|
|
10
28
|
const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
11
29
|
const { target, ctx$: { model } } = props
|
|
12
30
|
|
|
13
31
|
// Go module path == repo path on GitHub (org from model.origin).
|
|
14
|
-
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
|
|
32
|
+
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
|
|
33
|
+
|
|
34
|
+
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
35
|
+
const exampleEntity = Object.values(entity || {}).find((e: any) => e && e.active !== false) as any
|
|
36
|
+
const eName = exampleEntity ? nom(exampleEntity, 'Name') : 'Entity'
|
|
37
|
+
// camelCase Go identifier (never snake_case or flattened lowercase,
|
|
38
|
+
// never a Go keyword).
|
|
39
|
+
const eLower = exampleEntity ? goVarName(exampleEntity.name) : 'entity'
|
|
40
|
+
// Model-driven id key: null when the entity has no id-like field.
|
|
41
|
+
const idF = exampleEntity ? entityIdField(exampleEntity) : null
|
|
42
|
+
// Drive the test-mode example off the entity's PRIMARY op — never a hardcoded
|
|
43
|
+
// `Load` a create-only entity lacks.
|
|
44
|
+
const primaryOp = exampleEntity ? (entityPrimaryOp(exampleEntity) || 'load') : 'load'
|
|
45
|
+
const isMatchOp = 'load' === primaryOp || 'remove' === primaryOp
|
|
46
|
+
let testArg = 'nil'
|
|
47
|
+
if (exampleEntity && isMatchOp) {
|
|
48
|
+
testArg = idF ? `map[string]any{"${idF}": "test01"}` : 'nil'
|
|
49
|
+
} else if (exampleEntity && ('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
|
+
testArg = `map[string]any{${chosen.map((it: any) => `"${it.name}": ${goLit(it.type)}`).join(', ')}}`
|
|
55
|
+
}
|
|
15
56
|
|
|
16
57
|
const apikeyEnvLine = isAuthActive(model)
|
|
17
|
-
? `\n${model
|
|
58
|
+
? `\n${envName(model)}_APIKEY=<your-key>`
|
|
18
59
|
: ''
|
|
19
60
|
|
|
20
61
|
Content(`### Make a direct HTTP request
|
|
@@ -59,12 +100,15 @@ fmt.Println(fetchdef["headers"])
|
|
|
59
100
|
Create a mock client for unit testing \u2014 no server required:
|
|
60
101
|
|
|
61
102
|
\`\`\`go
|
|
62
|
-
client := sdk.
|
|
103
|
+
client := sdk.Test()
|
|
63
104
|
|
|
64
|
-
|
|
65
|
-
|
|
105
|
+
${eLower}, err := client.${eName}(nil).${cap(primaryOp)}(
|
|
106
|
+
${testArg}, nil,
|
|
66
107
|
)
|
|
67
|
-
|
|
108
|
+
if err != nil {
|
|
109
|
+
panic(err)
|
|
110
|
+
}
|
|
111
|
+
fmt.Println(${eLower}) // the returned mock data
|
|
68
112
|
\`\`\`
|
|
69
113
|
|
|
70
114
|
### Use a custom fetch function
|
|
@@ -96,7 +140,7 @@ client := sdk.New${model.const.Name}SDK(map[string]any{
|
|
|
96
140
|
Create a \`.env.local\` file at the project root:
|
|
97
141
|
|
|
98
142
|
\`\`\`
|
|
99
|
-
${model
|
|
143
|
+
${envName(model)}_TEST_LIVE=TRUE${apikeyEnvLine}
|
|
100
144
|
\`\`\`
|
|
101
145
|
|
|
102
146
|
Then run:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, packageName, repoInfo } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
|
|
@@ -7,17 +7,22 @@ const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
|
|
|
7
7
|
const { model } = ctx$
|
|
8
8
|
|
|
9
9
|
// Go module path == repo path on GitHub (org from model.origin).
|
|
10
|
-
const gomodule =
|
|
10
|
+
const gomodule = packageName(model, 'go')
|
|
11
|
+
const { releasesUrl } = repoInfo(model)
|
|
11
12
|
|
|
12
13
|
Content(`\`\`\`bash
|
|
13
|
-
go get ${gomodule}
|
|
14
|
+
go get ${gomodule}@latest
|
|
14
15
|
\`\`\`
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
The Go module proxy resolves the version from the \`go/vX.Y.Z\` GitHub
|
|
18
|
+
release tag — see [Releases](${releasesUrl}) for the available versions.
|
|
19
|
+
|
|
20
|
+
To vendor from a local checkout instead, clone this repo alongside your
|
|
21
|
+
project and add a \`replace\` directive pointing at the checked-out
|
|
22
|
+
\`go/\` directory:
|
|
18
23
|
|
|
19
24
|
\`\`\`bash
|
|
20
|
-
go mod edit -replace ${gomodule}
|
|
25
|
+
go mod edit -replace ${gomodule}=../${model.name}-sdk/go
|
|
21
26
|
\`\`\`
|
|
22
27
|
|
|
23
28
|
`)
|
|
@@ -1,13 +1,52 @@
|
|
|
1
1
|
|
|
2
2
|
import { cmp, Content } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
|
+
import {
|
|
5
|
+
KIT,
|
|
6
|
+
getModelPath,
|
|
7
|
+
nom,
|
|
8
|
+
} from '@voxgig/apidef'
|
|
9
|
+
|
|
4
10
|
|
|
5
11
|
const ReadmeIntro = cmp(function ReadmeIntro(props: any) {
|
|
6
12
|
const { target, ctx$: { model } } = props
|
|
13
|
+
const info = (model.main && model.main.kit && model.main.kit.info) || {}
|
|
14
|
+
const tagline = info.tagline || ''
|
|
15
|
+
|
|
16
|
+
// Derive a real entity accessor from the model for the semantic-entity
|
|
17
|
+
// note (fall back to a generic name if the model has no entities).
|
|
18
|
+
const entity = getModelPath(model, `main.${KIT}.entity`) || {}
|
|
19
|
+
const exampleEntity = Object.values(entity).find((e: any) => e && e.active !== false) as any
|
|
20
|
+
const eName = exampleEntity ? nom(exampleEntity, 'Name') : 'Entity'
|
|
21
|
+
|
|
22
|
+
// Model-driven op list — only the operations the active entities actually
|
|
23
|
+
// expose (a read-only entity has just List+Load); never claim
|
|
24
|
+
// Create/Update/Remove exist when no entity has them. Go method names are
|
|
25
|
+
// capitalised, so present the ops that way.
|
|
26
|
+
const CANON_OPS = ['list', 'load', 'create', 'update', 'remove']
|
|
27
|
+
const cap = (o: string) => o.charAt(0).toUpperCase() + o.slice(1)
|
|
28
|
+
const opSet = new Set<string>()
|
|
29
|
+
Object.values(entity || {}).forEach((e: any) => {
|
|
30
|
+
if (!e || e.active === false) return
|
|
31
|
+
Object.keys(e.op || {}).forEach((o: string) => {
|
|
32
|
+
if (e.op[o] && e.op[o].active !== false) opSet.add(o)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
const opNames = CANON_OPS.filter((o) => opSet.has(o))
|
|
36
|
+
.concat([...opSet].filter((o) => !CANON_OPS.includes(o)))
|
|
37
|
+
const opList = (opNames.length ? opNames : ['list', 'load'])
|
|
38
|
+
.map((o) => '`' + cap(o) + '`').join(', ')
|
|
7
39
|
|
|
8
40
|
Content(`# ${model.Name} ${target.title} SDK
|
|
9
41
|
|
|
10
|
-
|
|
42
|
+
${tagline}
|
|
43
|
+
|
|
44
|
+
The ${target.title} SDK for the ${model.Name} API — an entity-oriented client using standard Go conventions. No generics required; data flows as \`map[string]any\`.
|
|
45
|
+
|
|
46
|
+
It exposes the API as capitalised, semantic **Entities** — e.g. \`client.${eName}(nil)\` — each with the same small set of operations (${opList}) instead of raw URL paths and query strings. You call meaning, not endpoints, which keeps the cognitive load low.
|
|
47
|
+
|
|
48
|
+
> Other languages, the CLI, and MCP server live alongside this one — see
|
|
49
|
+
> the [top-level README](../README.md).
|
|
11
50
|
|
|
12
51
|
`)
|
|
13
52
|
})
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, isAuthActive } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, each, Content, isAuthActive, entityIdField, entityPrimaryOp } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
6
6
|
getModelPath,
|
|
7
7
|
} from '@voxgig/apidef'
|
|
8
8
|
|
|
9
|
+
import { goVarName } from './utility_go'
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
const ReadmeModel = cmp(function ReadmeModel(props: any) {
|
|
11
13
|
const { target, ctx$: { model } } = props
|
|
@@ -13,13 +15,58 @@ const ReadmeModel = cmp(function ReadmeModel(props: any) {
|
|
|
13
15
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
14
16
|
const entityList = each(entity).filter((e: any) => e.active !== false)
|
|
15
17
|
|
|
18
|
+
// Model-driven op rows for the shared entity interface: emit a
|
|
19
|
+
// Load/List/Create/Update/Remove row only for operations at least one active
|
|
20
|
+
// entity actually exposes (a read-only entity has just List+Load) — never
|
|
21
|
+
// document an operation no entity has. Model op keys are lowercase; Go
|
|
22
|
+
// method names are capitalised.
|
|
23
|
+
const opUnion = new Set<string>()
|
|
24
|
+
entityList.forEach((e: any) => Object.keys(e.op || {})
|
|
25
|
+
.forEach((o: string) => { if (e.op[o] && e.op[o].active !== false) opUnion.add(o) }))
|
|
26
|
+
const opRowDefs: Record<string, string> = {
|
|
27
|
+
load: '| `Load` | `(reqmatch, ctrl map[string]any) (any, error)` | Load a single entity by match criteria. |',
|
|
28
|
+
list: '| `List` | `(reqmatch, ctrl map[string]any) (any, error)` | List entities matching the criteria. |',
|
|
29
|
+
create: '| `Create` | `(reqdata, ctrl map[string]any) (any, error)` | Create a new entity. |',
|
|
30
|
+
update: '| `Update` | `(reqdata, ctrl map[string]any) (any, error)` | Update an existing entity. |',
|
|
31
|
+
remove: '| `Remove` | `(reqmatch, ctrl map[string]any) (any, error)` | Remove an entity. |',
|
|
32
|
+
}
|
|
33
|
+
const opRows = ['load', 'list', 'create', 'update', 'remove']
|
|
34
|
+
.filter((o) => opUnion.has(o)).map((o) => opRowDefs[o]).join('\n')
|
|
35
|
+
|
|
36
|
+
// Model-driven Result-shape rows: only describe the operations that
|
|
37
|
+
// actually exist. Record-returning ops (Load/Create/Update/Remove) share
|
|
38
|
+
// one row; List has its own — never name a missing op.
|
|
39
|
+
const recordOps = ['load', 'create', 'update', 'remove'].filter((o) => opUnion.has(o))
|
|
40
|
+
.map((o) => '`' + o.charAt(0).toUpperCase() + o.slice(1) + '`')
|
|
41
|
+
const resultRows: string[] = []
|
|
42
|
+
if (recordOps.length) resultRows.push('| ' + recordOps.join(' / ') + ' | the entity record (`map[string]any`) |')
|
|
43
|
+
if (opUnion.has('list')) resultRows.push('| `List` | a `[]any` of entity records |')
|
|
44
|
+
const resultShapeRows = resultRows.join('\n')
|
|
45
|
+
|
|
16
46
|
// Go module path == repo path on GitHub (org from model.origin).
|
|
17
|
-
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
|
|
47
|
+
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
|
|
18
48
|
|
|
19
49
|
const apikeyOptionRow = isAuthActive(model)
|
|
20
50
|
? '| `"apikey"` | `string` | API key for authentication. |\n'
|
|
21
51
|
: ''
|
|
22
52
|
|
|
53
|
+
// First published entity name, for the Result shape illustration.
|
|
54
|
+
const firstEntityName = (entityList[0] as any)?.Name || 'Entity'
|
|
55
|
+
// camelCase Go identifier (never snake_case or flattened lowercase,
|
|
56
|
+
// never a Go keyword).
|
|
57
|
+
const firstEntityVar = goVarName((entityList[0] as any)?.name || 'entity')
|
|
58
|
+
// Model-driven id key: null when the example entity has no id-like field, so
|
|
59
|
+
// the Result-shape illustration passes a nil match.
|
|
60
|
+
const firstIdF = entityIdField(entityList[0] || {})
|
|
61
|
+
// The example entity's PRIMARY op — an op it actually exposes (never a
|
|
62
|
+
// hardcoded `Load` a create-only entity lacks).
|
|
63
|
+
const firstPrimaryOp = entityList[0] ? (entityPrimaryOp(entityList[0]) || 'load') : 'load'
|
|
64
|
+
const firstPrimaryMethod = firstPrimaryOp.charAt(0).toUpperCase() + firstPrimaryOp.slice(1)
|
|
65
|
+
const firstIsMatchOp = 'load' === firstPrimaryOp || 'remove' === firstPrimaryOp
|
|
66
|
+
const firstOpArg = firstIsMatchOp
|
|
67
|
+
? (firstIdF ? `map[string]any{"${firstIdF}": "example_id"}` : 'nil')
|
|
68
|
+
: 'map[string]any{/* fields */}'
|
|
69
|
+
|
|
23
70
|
Content(`### New${model.const.Name}SDK
|
|
24
71
|
|
|
25
72
|
\`\`\`go
|
|
@@ -56,7 +103,8 @@ Creates a test-mode client with mock transport. Both arguments may be \`nil\`.
|
|
|
56
103
|
`)
|
|
57
104
|
|
|
58
105
|
each(entityList, (ent: any) => {
|
|
59
|
-
|
|
106
|
+
const article = /^[aeiou]/i.test(ent.Name) ? 'an' : 'a'
|
|
107
|
+
Content(`| \`${ent.Name}\` | \`(data map[string]any) ${model.const.Name}Entity\` | Create ${article} ${ent.Name} entity instance. |
|
|
60
108
|
`)
|
|
61
109
|
})
|
|
62
110
|
|
|
@@ -67,11 +115,7 @@ All entities implement the \`${model.const.Name}Entity\` interface.
|
|
|
67
115
|
|
|
68
116
|
| Method | Signature | Description |
|
|
69
117
|
| --- | --- | --- |
|
|
70
|
-
|
|
71
|
-
| \`List\` | \`(reqmatch, ctrl map[string]any) (any, error)\` | List entities matching the criteria. |
|
|
72
|
-
| \`Create\` | \`(reqdata, ctrl map[string]any) (any, error)\` | Create a new entity. |
|
|
73
|
-
| \`Update\` | \`(reqdata, ctrl map[string]any) (any, error)\` | Update an existing entity. |
|
|
74
|
-
| \`Remove\` | \`(reqmatch, ctrl map[string]any) (any, error)\` | Remove an entity. |
|
|
118
|
+
${opRows}
|
|
75
119
|
| \`Data\` | \`(args ...any) any\` | Get or set entity data. |
|
|
76
120
|
| \`Match\` | \`(args ...any) any\` | Get or set entity match criteria. |
|
|
77
121
|
| \`Make\` | \`() Entity\` | Create a new instance with the same options. |
|
|
@@ -79,17 +123,23 @@ All entities implement the \`${model.const.Name}Entity\` interface.
|
|
|
79
123
|
|
|
80
124
|
### Result shape
|
|
81
125
|
|
|
82
|
-
Entity operations return \`(
|
|
83
|
-
|
|
126
|
+
Entity operations return \`(value, error)\`. The \`value\` is the
|
|
127
|
+
operation's data **directly** — there is no wrapper:
|
|
84
128
|
|
|
85
|
-
|
|
|
86
|
-
| --- | --- |
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
129
|
+
| Operation | \`value\` |
|
|
130
|
+
| --- | --- |
|
|
131
|
+
${resultShapeRows}
|
|
132
|
+
|
|
133
|
+
Check \`err\` first, then use the value directly (or the typed
|
|
134
|
+
\`...Typed\` variants, which return the entity's model struct and a typed
|
|
135
|
+
slice):
|
|
136
|
+
|
|
137
|
+
${firstEntityVar}, err := client.${firstEntityName}(nil).${firstPrimaryMethod}(${firstOpArg}, nil)
|
|
138
|
+
if err != nil { /* handle */ }
|
|
139
|
+
// ${firstEntityVar} is the returned record
|
|
91
140
|
|
|
92
|
-
|
|
141
|
+
Only \`Direct()\` returns a response envelope — a \`map[string]any\` with
|
|
142
|
+
\`"ok"\`, \`"status"\`, \`"headers"\`, and \`"data"\` keys.
|
|
93
143
|
|
|
94
144
|
`)
|
|
95
145
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, each, Content, envName, isAuthActive } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const ReadmeOptions = cmp(function ReadmeOptions(props: any) {
|
|
6
6
|
const { target } = props
|
|
7
7
|
const { model } = props.ctx$
|
|
8
8
|
|
|
9
|
-
const publishedOptions = each(target.options).filter((option: any) =>
|
|
9
|
+
const publishedOptions = each(target.options).filter((option: any) =>
|
|
10
|
+
option.publish && ('apikey' !== option.name || isAuthActive(model)))
|
|
10
11
|
if (0 === publishedOptions.length) {
|
|
11
12
|
return
|
|
12
13
|
}
|
|
@@ -25,7 +26,7 @@ client := sdk.New${model.const.Name}SDK(map[string]any{
|
|
|
25
26
|
|
|
26
27
|
publishedOptions.map((option: any) => {
|
|
27
28
|
if ('apikey' === option.name) {
|
|
28
|
-
Content(` "${option.name}": os.Getenv("${model
|
|
29
|
+
Content(` "${option.name}": os.Getenv("${envName(model)}_APIKEY"),
|
|
29
30
|
`)
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp,
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, opRequestShape, entityIdField, entityOps } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -7,157 +7,187 @@ import {
|
|
|
7
7
|
nom,
|
|
8
8
|
} from '@voxgig/apidef'
|
|
9
9
|
|
|
10
|
+
import { exampleValue, goVarName } from './utility_go'
|
|
10
11
|
|
|
12
|
+
|
|
13
|
+
// Emits the go/README.md Quickstart as ONE complete, compilable program.
|
|
14
|
+
// Every entity operation returns `(value, error)` where `value` is the
|
|
15
|
+
// data itself — NOT a `{ok, data, ...}` envelope (only Direct returns
|
|
16
|
+
// that). So examples check `err` and use the value directly. The whole
|
|
17
|
+
// program is compiled by the README snippet test (readme_examples_test.go).
|
|
11
18
|
const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
12
19
|
const { target, ctx$: { model } } = props
|
|
13
20
|
|
|
14
21
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
15
22
|
// Go module path == repo path on GitHub (org from model.origin).
|
|
16
|
-
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
|
|
23
|
+
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
|
|
17
24
|
|
|
18
|
-
// Find the first published entity for examples
|
|
19
25
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
20
26
|
|
|
21
|
-
// Find a nested entity if available
|
|
22
|
-
const nestedEntity = Object.values(entity).find((e: any) =>
|
|
23
|
-
e.active !== false && e.ancestors && e.ancestors.length > 0
|
|
24
|
-
) as any
|
|
25
|
-
|
|
26
27
|
const authActive = isAuthActive(model)
|
|
27
|
-
const
|
|
28
|
-
? `
|
|
29
|
-
: `
|
|
30
|
-
const apikeyArg = authActive
|
|
31
|
-
? `\n "apikey": os.Getenv("${model.NAME}_APIKEY"),\n `
|
|
32
|
-
: ''
|
|
28
|
+
const ctor = authActive
|
|
29
|
+
? `sdk.New${model.const.Name}SDK(map[string]any{\n "apikey": os.Getenv("${envName(model)}_APIKEY"),\n })`
|
|
30
|
+
: `sdk.New()`
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
import (
|
|
40
|
-
${goImports}
|
|
41
|
-
sdk "${gomodule}"
|
|
42
|
-
"${gomodule}/core"
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
func main() {
|
|
46
|
-
client := sdk.New${model.const.Name}SDK(map[string]any{${apikeyArg}})
|
|
47
|
-
\`\`\`
|
|
48
|
-
|
|
49
|
-
`)
|
|
32
|
+
// Build the body of main() from the operations the example entity
|
|
33
|
+
// supports. Each op names a fresh value var, so `:=` always declares a
|
|
34
|
+
// new variable (reusing `err`), and every var is used (printed).
|
|
35
|
+
const body: string[] = []
|
|
36
|
+
let usesFmt = false
|
|
50
37
|
|
|
51
38
|
if (exampleEntity) {
|
|
52
39
|
const eName = nom(exampleEntity, 'Name')
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
// camelCase variable name — a `status_embed_config` entity must not bind
|
|
41
|
+
// a snake_case Go variable, and a `Type`/`Range` entity must not bind a
|
|
42
|
+
// Go keyword (`type, err := ...` fails `go build`).
|
|
43
|
+
const eLower = goVarName(exampleEntity.name)
|
|
44
|
+
// ACTIVE ops only — an inactive op generates no method, so an example
|
|
45
|
+
// calling it would not compile.
|
|
46
|
+
const opnames = entityOps(exampleEntity)
|
|
47
|
+
|
|
48
|
+
// Model-driven id key: null when the entity has no id-like field (a
|
|
49
|
+
// response-wrapped spec). When null, load/remove pass a nil match and
|
|
50
|
+
// update omits the id member.
|
|
51
|
+
const idF = entityIdField(exampleEntity)
|
|
52
|
+
|
|
53
|
+
// Model-driven example members for an op body, from the SAME op shape the
|
|
54
|
+
// request types are built from (opRequestShape), so create/update
|
|
55
|
+
// reference REAL writable fields, not a hardcoded "name", and every value
|
|
56
|
+
// is a type-correct Go literal (exampleValue). ids are rendered
|
|
57
|
+
// separately as the match key for update/remove; a REQUIRED id stays for
|
|
58
|
+
// create (dropping it makes the payload incomplete).
|
|
59
|
+
const exampleFields = (opname: string): string[] => {
|
|
60
|
+
const items = opRequestShape(exampleEntity, opname).items
|
|
61
|
+
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
62
|
+
('create' === opname && !it.optional))
|
|
63
|
+
const required = items.filter((it: any) => !it.optional)
|
|
64
|
+
const optional = items.filter((it: any) => it.optional)
|
|
65
|
+
// Required members must all appear or the payload is incomplete; pad
|
|
66
|
+
// update (a patch) with a sample optional field or two.
|
|
67
|
+
const chosen = 'create' === opname
|
|
68
|
+
? (required.length ? required : items.slice(0, 2))
|
|
69
|
+
: required.concat(optional).slice(0, Math.max(2, required.length))
|
|
70
|
+
return chosen.map((it: any) =>
|
|
71
|
+
`"${it.name}": ${exampleValue(exampleEntity, exampleEntity.op[opname], it.name, 'example_' + it.name)}`)
|
|
62
72
|
}
|
|
63
73
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
// The full REQUIRED match for load/remove (id first, then parent path
|
|
75
|
+
// params like page_id) — the same shape that generates the op's request
|
|
76
|
+
// match, so the example always carries the keys the route needs.
|
|
77
|
+
const matchArg = (opname: string): string => {
|
|
78
|
+
const matchItems = opRequestShape(exampleEntity, opname).items
|
|
79
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
80
|
+
.sort((a: any, b: any) =>
|
|
81
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
82
|
+
return 0 < matchItems.length
|
|
83
|
+
? `map[string]any{${matchItems.map((it: any) =>
|
|
84
|
+
`"${it.name}": ${exampleValue(exampleEntity, exampleEntity.op[opname], it.name,
|
|
85
|
+
it.name === idF ? 'example_id' : 'example_' + it.name)}`).join(', ')}}`
|
|
86
|
+
: 'nil'
|
|
70
87
|
}
|
|
71
|
-
\`\`\`
|
|
72
88
|
|
|
73
|
-
|
|
89
|
+
if (opnames.includes('list')) {
|
|
90
|
+
body.push(` // List ${eLower} records — the value is the array of records itself.`)
|
|
91
|
+
body.push(` ${eLower}s, err := client.${eName}(nil).List(nil, nil)`)
|
|
92
|
+
body.push(` if err != nil {`)
|
|
93
|
+
body.push(` panic(err)`)
|
|
94
|
+
body.push(` }`)
|
|
95
|
+
body.push(` for _, item := range ${eLower}s.([]any) {`)
|
|
96
|
+
body.push(` fmt.Println(item)`)
|
|
97
|
+
body.push(` }`)
|
|
98
|
+
body.push(``)
|
|
99
|
+
usesFmt = true
|
|
74
100
|
}
|
|
75
101
|
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
\`\`\`go
|
|
87
|
-
${neName.toLowerCase()} := client.${neName}(nil)
|
|
88
|
-
result, err = ${neName.toLowerCase()}.Load(
|
|
89
|
-
map[string]any{"${parentParam}": "example", "id": "example_id"}, nil,
|
|
90
|
-
)
|
|
91
|
-
if err != nil {
|
|
92
|
-
panic(err)
|
|
102
|
+
if (opnames.includes('load')) {
|
|
103
|
+
body.push(` // Load a single ${eLower} — the value is the loaded record.`)
|
|
104
|
+
body.push(` ${eLower}, err := client.${eName}(nil).Load(${matchArg('load')}, nil)`)
|
|
105
|
+
body.push(` if err != nil {`)
|
|
106
|
+
body.push(` panic(err)`)
|
|
107
|
+
body.push(` }`)
|
|
108
|
+
body.push(` fmt.Println(${eLower})`)
|
|
109
|
+
body.push(``)
|
|
110
|
+
usesFmt = true
|
|
93
111
|
}
|
|
94
112
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
if (opnames.includes('create')) {
|
|
114
|
+
body.push(` // Create a ${eLower}.`)
|
|
115
|
+
body.push(` created, err := client.${eName}(nil).Create(map[string]any{${exampleFields('create').join(', ')}}, nil)`)
|
|
116
|
+
body.push(` if err != nil {`)
|
|
117
|
+
body.push(` panic(err)`)
|
|
118
|
+
body.push(` }`)
|
|
119
|
+
body.push(` fmt.Println(created)`)
|
|
120
|
+
body.push(``)
|
|
121
|
+
usesFmt = true
|
|
98
122
|
}
|
|
99
|
-
}
|
|
100
|
-
\`\`\`
|
|
101
123
|
|
|
102
|
-
|
|
124
|
+
if (opnames.includes('update')) {
|
|
125
|
+
// The id member (when the entity has an id-like key) plus example
|
|
126
|
+
// patch fields — the same shape that generates the op's request data.
|
|
127
|
+
const updateMembers = (idF
|
|
128
|
+
? [`"${idF}": ${exampleValue(exampleEntity, exampleEntity.op.update, idF, 'example_id')}`]
|
|
129
|
+
: []).concat(exampleFields('update'))
|
|
130
|
+
body.push(` // Update a ${eLower}.`)
|
|
131
|
+
body.push(` updated, err := client.${eName}(nil).Update(map[string]any{${updateMembers.join(', ')}}, nil)`)
|
|
132
|
+
body.push(` if err != nil {`)
|
|
133
|
+
body.push(` panic(err)`)
|
|
134
|
+
body.push(` }`)
|
|
135
|
+
body.push(` fmt.Println(updated)`)
|
|
136
|
+
body.push(``)
|
|
137
|
+
usesFmt = true
|
|
103
138
|
}
|
|
104
|
-
else if (opnames.includes('load')) {
|
|
105
|
-
Content(`### 3. Load a ${eName.toLowerCase()}
|
|
106
139
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
|
|
140
|
+
if (opnames.includes('remove')) {
|
|
141
|
+
body.push(` // Remove a ${eLower}.`)
|
|
142
|
+
body.push(` removed, err := client.${eName}(nil).Remove(${matchArg('remove')}, nil)`)
|
|
143
|
+
body.push(` if err != nil {`)
|
|
144
|
+
body.push(` panic(err)`)
|
|
145
|
+
body.push(` }`)
|
|
146
|
+
body.push(` fmt.Println(removed)`)
|
|
147
|
+
body.push(``)
|
|
148
|
+
usesFmt = true
|
|
113
149
|
}
|
|
150
|
+
}
|
|
114
151
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
\`\`\`
|
|
152
|
+
// Drop trailing blank lines from the body.
|
|
153
|
+
while (body.length > 0 && body[body.length - 1] === '') {
|
|
154
|
+
body.pop()
|
|
155
|
+
}
|
|
121
156
|
|
|
122
|
-
|
|
123
|
-
|
|
157
|
+
const imports: string[] = []
|
|
158
|
+
if (usesFmt) imports.push(` "fmt"`)
|
|
159
|
+
if (authActive) imports.push(` "os"`)
|
|
160
|
+
imports.push(` sdk "${gomodule}"`)
|
|
124
161
|
|
|
125
|
-
|
|
126
|
-
if (opnames.includes('create') || opnames.includes('update') || opnames.includes('remove')) {
|
|
127
|
-
Content(`### 4. Create, update, and remove
|
|
162
|
+
let program = `package main
|
|
128
163
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (opnames.includes('create')) {
|
|
132
|
-
Content(`// Create
|
|
133
|
-
created, _ := client.${eName}(nil).Create(
|
|
134
|
-
map[string]any{"name": "Example"}, nil,
|
|
164
|
+
import (
|
|
165
|
+
${imports.join('\n')}
|
|
135
166
|
)
|
|
136
|
-
cm := core.ToMapAny(created)
|
|
137
|
-
newID := core.ToMapAny(cm["data"])["id"]
|
|
138
167
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (opnames.includes('update')) {
|
|
142
|
-
Content(`// Update
|
|
143
|
-
client.${eName}(nil).Update(
|
|
144
|
-
map[string]any{"id": newID, "name": "Example-Renamed"}, nil,
|
|
145
|
-
)
|
|
168
|
+
func main() {
|
|
169
|
+
client := ${ctor}
|
|
146
170
|
|
|
147
|
-
`
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
client
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
171
|
+
`
|
|
172
|
+
if (body.length > 0) {
|
|
173
|
+
program += body.join('\n') + '\n'
|
|
174
|
+
} else {
|
|
175
|
+
program += ` _ = client\n`
|
|
176
|
+
}
|
|
177
|
+
program += `}`
|
|
178
|
+
|
|
179
|
+
Content(`### Quickstart
|
|
180
|
+
|
|
181
|
+
A complete program: create a client, then call the entity operations.
|
|
182
|
+
Each operation returns \`(value, error)\` — the value is the data itself
|
|
183
|
+
(there is no \`{ok, data}\` wrapper), so check \`err\` and use the value
|
|
184
|
+
directly.
|
|
185
|
+
|
|
186
|
+
\`\`\`go
|
|
187
|
+
${program}
|
|
188
|
+
\`\`\`
|
|
157
189
|
|
|
158
190
|
`)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
191
|
|
|
162
192
|
})
|
|
163
193
|
|