@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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Generated by sdkgen go-mcp target.
|
|
2
|
+
package main
|
|
3
|
+
|
|
4
|
+
import (
|
|
5
|
+
"context"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"fmt"
|
|
8
|
+
"strings"
|
|
9
|
+
|
|
10
|
+
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
11
|
+
sdk "GOMODULE"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
// Args is the common argument shape for both tools. `entity` selects
|
|
15
|
+
// the SDK entity to operate on; `query` is the optional reqmatch /
|
|
16
|
+
// reqdata map passed through to the SDK. For load, `query` should be
|
|
17
|
+
// `{"id": <value>}`. For list, omit `query` or pass an empty map.
|
|
18
|
+
type Args struct {
|
|
19
|
+
Entity string `json:"entity" jsonschema:"// <[SLOT:entityHelp]>"`
|
|
20
|
+
Query map[string]any `json:"query,omitempty" jsonschema:"optional match map e.g. {\"id\":1} for load, omit for list"`
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func registerTools(server *mcp.Server, client *sdk.ProjectNameSDK) {
|
|
24
|
+
mcp.AddTool(server, &mcp.Tool{
|
|
25
|
+
Name: "// <[SLOT:toolPrefixList]>",
|
|
26
|
+
Description: "List records from ProjectName. " +
|
|
27
|
+
"Args: entity (one of the supported SDK entities), query (optional filter map). " +
|
|
28
|
+
"Returns the first page of records as JSON.",
|
|
29
|
+
}, func(ctx context.Context, req *mcp.CallToolRequest, args Args) (*mcp.CallToolResult, any, error) {
|
|
30
|
+
return runOp(client, "list", args)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
mcp.AddTool(server, &mcp.Tool{
|
|
34
|
+
Name: "// <[SLOT:toolPrefixLoad]>",
|
|
35
|
+
Description: "Load a single record from ProjectName. " +
|
|
36
|
+
"Args: entity, query ({\"id\":N} required). Returns the record as JSON.",
|
|
37
|
+
}, func(ctx context.Context, req *mcp.CallToolRequest, args Args) (*mcp.CallToolResult, any, error) {
|
|
38
|
+
return runOp(client, "load", args)
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func runOp(client *sdk.ProjectNameSDK, op string, args Args) (*mcp.CallToolResult, any, error) {
|
|
43
|
+
ent, err := entityFor(client, args.Entity)
|
|
44
|
+
if err != nil {
|
|
45
|
+
return toolError(err.Error())
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var result any
|
|
49
|
+
switch op {
|
|
50
|
+
case "list":
|
|
51
|
+
result, err = ent.List(args.Query, nil)
|
|
52
|
+
case "load":
|
|
53
|
+
result, err = ent.Load(args.Query, nil)
|
|
54
|
+
default:
|
|
55
|
+
return toolError(fmt.Sprintf("unknown op %q", op))
|
|
56
|
+
}
|
|
57
|
+
if err != nil {
|
|
58
|
+
return toolError(err.Error())
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// SDK returns *Entity wrappers; unwrap each via .Data() to get a
|
|
62
|
+
// plain map[string]any (or []any of maps for list) suitable for
|
|
63
|
+
// JSON marshalling.
|
|
64
|
+
data := extractData(result)
|
|
65
|
+
body, err := json.MarshalIndent(data, "", " ")
|
|
66
|
+
if err != nil {
|
|
67
|
+
return toolError(fmt.Sprintf("marshal: %v", err))
|
|
68
|
+
}
|
|
69
|
+
return &mcp.CallToolResult{
|
|
70
|
+
Content: []mcp.Content{
|
|
71
|
+
&mcp.TextContent{Text: string(body)},
|
|
72
|
+
},
|
|
73
|
+
}, data, nil
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// entityFor dispatches on the lowercase entity name. The generator
|
|
77
|
+
// emits one `case "<name>":` per entity defined in the SDK model.
|
|
78
|
+
func entityFor(client *sdk.ProjectNameSDK, name string) (sdk.ProjectNameEntity, error) {
|
|
79
|
+
switch strings.ToLower(name) {
|
|
80
|
+
// <[SLOT:entityCases]>
|
|
81
|
+
}
|
|
82
|
+
return nil, fmt.Errorf("unknown entity %q", name)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// extractData walks an SDK result and replaces any sdk.Entity wrapper
|
|
86
|
+
// with its underlying record (via .Data()).
|
|
87
|
+
func extractData(x any) any {
|
|
88
|
+
switch v := x.(type) {
|
|
89
|
+
case sdk.Entity:
|
|
90
|
+
return extractData(v.Data())
|
|
91
|
+
case []any:
|
|
92
|
+
out := make([]any, len(v))
|
|
93
|
+
for i, e := range v {
|
|
94
|
+
out[i] = extractData(e)
|
|
95
|
+
}
|
|
96
|
+
return out
|
|
97
|
+
case map[string]any:
|
|
98
|
+
out := make(map[string]any, len(v))
|
|
99
|
+
for k, vv := range v {
|
|
100
|
+
out[k] = extractData(vv)
|
|
101
|
+
}
|
|
102
|
+
return out
|
|
103
|
+
}
|
|
104
|
+
return x
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
func toolError(msg string) (*mcp.CallToolResult, any, error) {
|
|
108
|
+
return &mcp.CallToolResult{
|
|
109
|
+
IsError: true,
|
|
110
|
+
Content: []mcp.Content{
|
|
111
|
+
&mcp.TextContent{Text: msg},
|
|
112
|
+
},
|
|
113
|
+
}, nil, nil
|
|
114
|
+
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
each,
|
|
12
12
|
indent,
|
|
13
13
|
isAuthActive,
|
|
14
|
+
resolveAuthPrefix,
|
|
14
15
|
} from '@voxgig/sdkgen'
|
|
15
16
|
|
|
16
17
|
|
|
@@ -42,12 +43,8 @@ const Config = cmp(async function Config(props: any) {
|
|
|
42
43
|
const headers = getModelPath(model, `main.${KIT}.config.headers`) || {}
|
|
43
44
|
|
|
44
45
|
const authActive = isAuthActive(model)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const v = getModelPath(model, `main.${KIT}.config.auth.prefix`,
|
|
48
|
-
{ only_active: false, required: false })
|
|
49
|
-
if (null != v) authPrefix = v
|
|
50
|
-
} catch (_e) { /* ignore */ }
|
|
46
|
+
// config.auth.prefix override -> spec-derived info.security.prefix -> 'Bearer'
|
|
47
|
+
const authPrefix = resolveAuthPrefix(model)
|
|
51
48
|
const authBlock = authActive
|
|
52
49
|
? `auth: {
|
|
53
50
|
prefix: '${authPrefix}',
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
// Typed-model generator (JavaScript target).
|
|
4
|
+
//
|
|
5
|
+
// JavaScript is dynamically typed, so the "types" are JSDoc typedefs
|
|
6
|
+
// (@typedef / @property) for editor/tooling DX only — no runtime effect.
|
|
7
|
+
//
|
|
8
|
+
// Reads main.<KIT>.entity.<e>.fields[] and per-op params
|
|
9
|
+
// (op.<name>.points[].args.params[]) and emits one file, src/<Sdk>Types.js,
|
|
10
|
+
// with a `@typedef {Object} <Name>` per active entity plus a request/match
|
|
11
|
+
// typedef per active op. Field/param sentinels ($STRING, $INTEGER, ...) are
|
|
12
|
+
// turned into JSDoc types by the shared sdkgen helper `canonToType`
|
|
13
|
+
// ('js' column: Object / Array / * for open shapes).
|
|
14
|
+
//
|
|
15
|
+
// The typedefs are emitted at file (script) scope so they are GLOBAL across
|
|
16
|
+
// the SDK's JS program — the op fragments reference them by bare name
|
|
17
|
+
// (@param {AdviceLoadMatch} / @returns {Promise<Advice>}). Keeps the SAME
|
|
18
|
+
// type-name scheme as the TS reference (<Name>, <Name>LoadMatch,
|
|
19
|
+
// <Name>ListMatch, <Name>CreateData, <Name>UpdateData, <Name>RemoveMatch).
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
cmp, each,
|
|
23
|
+
File, Content,
|
|
24
|
+
} from '@voxgig/sdkgen'
|
|
25
|
+
|
|
26
|
+
import { canonToType, opTypeName, opRequestShape } from '@voxgig/sdkgen'
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
KIT,
|
|
30
|
+
getModelPath,
|
|
31
|
+
} from '@voxgig/apidef'
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const LANG = 'js'
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// A bare JSDoc property key, or a quoted string literal for anything that is
|
|
38
|
+
// not a plain identifier.
|
|
39
|
+
function propKey(name: string): string {
|
|
40
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? name : JSON.stringify(name)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const EntityTypes = cmp(function EntityTypes(props: any) {
|
|
45
|
+
const { model } = props.ctx$
|
|
46
|
+
|
|
47
|
+
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
48
|
+
const entityList = each(entity).filter((e: any) => e.active !== false)
|
|
49
|
+
|
|
50
|
+
File({ name: model.const.Name + 'Types.' + LANG }, () => {
|
|
51
|
+
|
|
52
|
+
Content(`// Typed models for the ${model.const.Name} SDK (JSDoc typedefs).
|
|
53
|
+
//
|
|
54
|
+
// GENERATED from the API model: main.${KIT}.entity.<e>.fields[] and per-op
|
|
55
|
+
// params (op.<name>.points[].args.params[]). Field/param types come from the
|
|
56
|
+
// canonical type sentinels via @voxgig/sdkgen canonToType (source of truth:
|
|
57
|
+
// @voxgig/apidef VALID_CANON). Annotations only — no runtime effect. Do not
|
|
58
|
+
// edit by hand.
|
|
59
|
+
|
|
60
|
+
`)
|
|
61
|
+
|
|
62
|
+
entityList.forEach((ent: any) => {
|
|
63
|
+
const Name = ent.Name
|
|
64
|
+
const fields = (ent.fields ? each(ent.fields) : [])
|
|
65
|
+
.filter((f: any) => f.active !== false)
|
|
66
|
+
|
|
67
|
+
// Entity data model: one @property per field, `req:false` -> optional [].
|
|
68
|
+
Content(`/**
|
|
69
|
+
* @typedef {Object} ${Name}
|
|
70
|
+
`)
|
|
71
|
+
fields.forEach((f: any) => {
|
|
72
|
+
const key = false === f.req ? '[' + propKey(f.name) + ']' : propKey(f.name)
|
|
73
|
+
Content(` * @property {${canonToType(f.type, LANG)}} ${key}
|
|
74
|
+
`)
|
|
75
|
+
})
|
|
76
|
+
Content(` */
|
|
77
|
+
|
|
78
|
+
`)
|
|
79
|
+
|
|
80
|
+
// Per active op: a request/match typedef. Members and their optionality
|
|
81
|
+
// come from the shared partiality policy (opRequestShape); this file only
|
|
82
|
+
// renders them as JSDoc @property lines (optional -> [bracketed] key).
|
|
83
|
+
const ops = ent.op || {}
|
|
84
|
+
;['load', 'list', 'create', 'update', 'remove'].forEach((opname: string) => {
|
|
85
|
+
if (null == ops[opname]) {
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const typeName = opTypeName(Name, opname)
|
|
90
|
+
const { items } = opRequestShape(ent, opname)
|
|
91
|
+
|
|
92
|
+
Content(`/**
|
|
93
|
+
* @typedef {Object} ${typeName}
|
|
94
|
+
`)
|
|
95
|
+
items.forEach((it: any) => {
|
|
96
|
+
const key = it.optional ? '[' + propKey(it.name) + ']' : propKey(it.name)
|
|
97
|
+
Content(` * @property {${canonToType(it.type, LANG)}} ${key}
|
|
98
|
+
`)
|
|
99
|
+
})
|
|
100
|
+
Content(` */
|
|
101
|
+
|
|
102
|
+
`)
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
EntityTypes,
|
|
111
|
+
}
|
|
@@ -7,6 +7,7 @@ const MainEntity = cmp(async function MainEntity(props: any) {
|
|
|
7
7
|
const { entity } = props
|
|
8
8
|
|
|
9
9
|
Content(`
|
|
10
|
+
// Entity access: \`client.${entity.Name}().list()\` / \`client.${entity.Name}().load({ id })\`.
|
|
10
11
|
${entity.Name}(data) {
|
|
11
12
|
const self = this
|
|
12
13
|
return new ${entity.Name}Entity(self,data)
|
|
@@ -24,6 +24,7 @@ import { Gitignore } from './Gitignore_js'
|
|
|
24
24
|
import { MainEntity } from './MainEntity_js'
|
|
25
25
|
import { SdkError } from './SdkError_js'
|
|
26
26
|
import { EntityBase } from './EntityBase_js'
|
|
27
|
+
import { EntityTypes } from './EntityTypes_js'
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
const Main = cmp(async function Main(props: any) {
|
|
@@ -101,6 +102,8 @@ if (fres instanceof Promise) { await fres }
|
|
|
101
102
|
|
|
102
103
|
EntityBase({ target })
|
|
103
104
|
|
|
105
|
+
EntityTypes({ target })
|
|
106
|
+
|
|
104
107
|
})
|
|
105
108
|
})
|
|
106
109
|
|
|
@@ -5,6 +5,12 @@ import {
|
|
|
5
5
|
cmp,
|
|
6
6
|
each,
|
|
7
7
|
omap,
|
|
8
|
+
packageName,
|
|
9
|
+
pkgDescription,
|
|
10
|
+
keywords,
|
|
11
|
+
repoInfo,
|
|
12
|
+
PUBLISHER,
|
|
13
|
+
PUBLISHER_URL,
|
|
8
14
|
} from '@voxgig/sdkgen'
|
|
9
15
|
|
|
10
16
|
|
|
@@ -43,16 +49,19 @@ const Package = cmp(async function Package(props: any) {
|
|
|
43
49
|
dev: only('dev', target.deps),
|
|
44
50
|
})
|
|
45
51
|
|
|
46
|
-
const sdkname = model.name
|
|
47
52
|
const SdkName = nom(model, 'Name')
|
|
48
|
-
const
|
|
49
|
-
const sdknamesuffix = model.origin?.endsWith('-sdk') ? '' : '-sdk'
|
|
53
|
+
const { repoUrl, issuesUrl } = repoInfo(model)
|
|
50
54
|
|
|
51
|
-
// TODO: complete SDK meta data in model and use here
|
|
52
55
|
const pkg = {
|
|
53
|
-
name
|
|
56
|
+
// The ts target publishes the canonical scoped npm name; the js target
|
|
57
|
+
// appends `-js` so the two never collide on npm.
|
|
58
|
+
name: packageName(model, 'js'),
|
|
54
59
|
version: `0.0.1`,
|
|
55
|
-
description:
|
|
60
|
+
description: pkgDescription(model, target.name),
|
|
61
|
+
keywords: keywords(model),
|
|
62
|
+
homepage: `${repoUrl}#readme`,
|
|
63
|
+
repository: { type: 'git', url: `git+${repoUrl}.git` },
|
|
64
|
+
bugs: { url: issuesUrl },
|
|
56
65
|
main: `src/${SdkName}SDK.js`,
|
|
57
66
|
type: 'commonjs',
|
|
58
67
|
scripts: {
|
|
@@ -64,7 +73,7 @@ const Package = cmp(async function Package(props: any) {
|
|
|
64
73
|
"clean": "rm -rf node_modules yarn.lock package-lock.json",
|
|
65
74
|
"reset": "npm run clean && npm i && npm test",
|
|
66
75
|
},
|
|
67
|
-
author:
|
|
76
|
+
author: { name: PUBLISHER, url: PUBLISHER_URL },
|
|
68
77
|
|
|
69
78
|
// TODO: needs to be config
|
|
70
79
|
license: 'MIT',
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, each, Content, canonToType, entityIdField, opRequestShape, safeVarName } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
6
6
|
getModelPath,
|
|
7
7
|
} from '@voxgig/apidef'
|
|
8
8
|
|
|
9
|
+
import { exampleValue } from './utility_js'
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
// Operation method spelling differs between Go and other languages — Go
|
|
11
13
|
// uses PascalCase methods with explicit ctrl arg, others use lowercase
|
|
@@ -41,6 +43,10 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
41
43
|
publishedEntities.map((entity: any) => {
|
|
42
44
|
const opnames = Object.keys(entity.op || {})
|
|
43
45
|
const fields = entity.fields || []
|
|
46
|
+
// Model-driven id key: null when this entity has no id-like field.
|
|
47
|
+
const idF = entityIdField(entity)
|
|
48
|
+
// Variable-safe lowercase name (a `Delete` entity must not bind `delete`).
|
|
49
|
+
const eVar = safeVarName(entity.name, 'js')
|
|
44
50
|
|
|
45
51
|
Content(`
|
|
46
52
|
### ${entity.Name}
|
|
@@ -53,7 +59,7 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
53
59
|
`)
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
Content(`Create an instance: \`const ${
|
|
62
|
+
Content(`Create an instance: \`const ${eVar} = client.${entity.Name}()\`
|
|
57
63
|
|
|
58
64
|
`)
|
|
59
65
|
|
|
@@ -84,7 +90,7 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
84
90
|
|
|
85
91
|
each(fields, (field: any) => {
|
|
86
92
|
const desc = field.short || ''
|
|
87
|
-
Content(`| \`${field.name}\` | \`${field.type
|
|
93
|
+
Content(`| \`${field.name}\` | \`${canonToType(field.type, target.name)}\` | ${desc} |
|
|
88
94
|
`)
|
|
89
95
|
})
|
|
90
96
|
|
|
@@ -93,10 +99,22 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
if (opnames.includes('load')) {
|
|
102
|
+
// The id key plus every REQUIRED match key (parent path params like
|
|
103
|
+
// page_id) — the same shape the runtime resolves path params from, so
|
|
104
|
+
// the example always works.
|
|
105
|
+
const loadItems = opRequestShape(entity, 'load').items
|
|
106
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
107
|
+
.sort((a: any, b: any) =>
|
|
108
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
109
|
+
const loadArg = 0 < loadItems.length
|
|
110
|
+
? `{ ${loadItems.map((it: any) =>
|
|
111
|
+
`${it.name}: ${exampleValue(entity, entity.op && entity.op.load, it.name,
|
|
112
|
+
it.name === idF ? entity.name + '_id' : it.name)}`).join(', ')} }`
|
|
113
|
+
: ''
|
|
96
114
|
Content(`#### Example: Load
|
|
97
115
|
|
|
98
116
|
\`\`\`ts
|
|
99
|
-
const ${
|
|
117
|
+
const ${eVar} = await client.${entity.Name}().load(${loadArg})
|
|
100
118
|
\`\`\`
|
|
101
119
|
|
|
102
120
|
`)
|
|
@@ -106,23 +124,28 @@ const ${entity.name} = await client.${entity.Name}().load({ id: '${entity.name}_
|
|
|
106
124
|
Content(`#### Example: List
|
|
107
125
|
|
|
108
126
|
\`\`\`ts
|
|
109
|
-
const ${
|
|
127
|
+
const ${eVar}s = await client.${entity.Name}().list()
|
|
110
128
|
\`\`\`
|
|
111
129
|
|
|
112
130
|
`)
|
|
113
131
|
}
|
|
114
132
|
|
|
115
133
|
if (opnames.includes('create')) {
|
|
134
|
+
// Members come from the SAME shape the runtime validates
|
|
135
|
+
// (opRequestShape): every required member must appear — including a
|
|
136
|
+
// required id and parent keys like page_id (the /* type */
|
|
137
|
+
// placeholders mark the block as an illustration); an all-optional
|
|
138
|
+
// create renders an empty — still valid — literal.
|
|
139
|
+
const createItems = opRequestShape(entity, 'create').items
|
|
140
|
+
.filter((it: any) => !it.optional)
|
|
116
141
|
Content(`#### Example: Create
|
|
117
142
|
|
|
118
143
|
\`\`\`ts
|
|
119
|
-
const ${
|
|
144
|
+
const ${eVar} = await client.${entity.Name}().create({
|
|
120
145
|
`)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
Content(` ${field.name}: /* ${field.type || 'value'} */,
|
|
146
|
+
createItems.map((it: any) => {
|
|
147
|
+
Content(` ${it.name}: /* ${canonToType(it.type, target.name)} */,
|
|
124
148
|
`)
|
|
125
|
-
}
|
|
126
149
|
})
|
|
127
150
|
Content(`})
|
|
128
151
|
\`\`\`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, packageName } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const ReadmeExplanation = cmp(function ReadmeExplanation(props: any) {
|
|
@@ -20,7 +20,7 @@ ${model.name}/
|
|
|
20
20
|
Import the SDK from the package root:
|
|
21
21
|
|
|
22
22
|
\`\`\`js
|
|
23
|
-
const { ${model.Name}SDK } = require('${model.name}')
|
|
23
|
+
const { ${model.Name}SDK } = require('${packageName(model, target.name)}')
|
|
24
24
|
\`\`\`
|
|
25
25
|
|
|
26
26
|
`)
|
|
@@ -1,21 +1,59 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, entityIdField, entityDataIdField, entityPrimaryOp, opRequestShape, safeVarName } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
6
6
|
getModelPath,
|
|
7
|
+
nom,
|
|
7
8
|
} from '@voxgig/apidef'
|
|
8
9
|
|
|
10
|
+
import { exampleValue } from './utility_js'
|
|
11
|
+
|
|
9
12
|
|
|
10
13
|
const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
11
14
|
const { target, ctx$: { model } } = props
|
|
12
15
|
|
|
16
|
+
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
17
|
+
const exampleEntity = Object.values(entity || {}).find((e: any) => e && e.active !== false) as any
|
|
18
|
+
const eName = exampleEntity ? nom(exampleEntity, 'Name') : 'Entity'
|
|
19
|
+
const eVar = safeVarName(eName.toLowerCase(), 'js')
|
|
20
|
+
|
|
21
|
+
// Drive the test-mode / stateful examples off the entity's PRIMARY op — an op
|
|
22
|
+
// it actually exposes — never a hardcoded `load` a create-only entity lacks.
|
|
23
|
+
const primaryOp = exampleEntity ? (entityPrimaryOp(exampleEntity) || 'load') : 'load'
|
|
24
|
+
const primaryOpDef = exampleEntity && exampleEntity.op && exampleEntity.op[primaryOp]
|
|
25
|
+
const isMatchOp = 'load' === primaryOp || 'remove' === primaryOp
|
|
26
|
+
// idF is the MATCH key; dataIdF is the id on the RETURNED record's data type
|
|
27
|
+
// (guard `.id` reads off a returned record on this, not the match key).
|
|
28
|
+
const idF = exampleEntity ? entityIdField(exampleEntity) : null
|
|
29
|
+
const dataIdF = exampleEntity ? entityDataIdField(exampleEntity) : null
|
|
30
|
+
|
|
31
|
+
const primaryArg = (idPlaceholder: string): string => {
|
|
32
|
+
if (!exampleEntity) return ''
|
|
33
|
+
if ('list' === primaryOp) return ''
|
|
34
|
+
if (isMatchOp) {
|
|
35
|
+
return idF ? `{ ${idF}: ${exampleValue(exampleEntity, primaryOpDef, idF, idPlaceholder)} }` : ''
|
|
36
|
+
}
|
|
37
|
+
const items = opRequestShape(exampleEntity, primaryOp).items
|
|
38
|
+
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
39
|
+
const required = items.filter((it: any) => !it.optional)
|
|
40
|
+
const chosen = required.length ? required : items.slice(0, 3)
|
|
41
|
+
const pairs = chosen.map((it: any) =>
|
|
42
|
+
`${it.name}: ${exampleValue(exampleEntity, primaryOpDef, it.name, 'example_' + it.name)}`)
|
|
43
|
+
return `{ ${pairs.join(', ')} }`
|
|
44
|
+
}
|
|
45
|
+
const testCallArg = primaryArg('test01')
|
|
46
|
+
const stateCallArg = primaryArg('example')
|
|
47
|
+
const stateDataLine = dataIdF
|
|
48
|
+
? `console.log(data.${dataIdF})`
|
|
49
|
+
: `console.log(data)`
|
|
50
|
+
|
|
13
51
|
const authActive = isAuthActive(model)
|
|
14
52
|
const apikeyTesterCtor = authActive
|
|
15
53
|
? `new ${model.const.Name}SDK({ apikey: '...' })`
|
|
16
54
|
: `new ${model.const.Name}SDK()`
|
|
17
55
|
const apikeyExtendField = authActive ? `\n apikey: '...',` : ''
|
|
18
|
-
const apikeyEnvLine = authActive ? `\n${model
|
|
56
|
+
const apikeyEnvLine = authActive ? `\n${envName(model)}_APIKEY=<your-key>` : ''
|
|
19
57
|
|
|
20
58
|
Content(`### Make a direct HTTP request
|
|
21
59
|
|
|
@@ -28,6 +66,9 @@ const result = await client.direct({
|
|
|
28
66
|
params: { id: 'example' },
|
|
29
67
|
})
|
|
30
68
|
|
|
69
|
+
if (result instanceof Error) {
|
|
70
|
+
throw result
|
|
71
|
+
}
|
|
31
72
|
if (result.ok) {
|
|
32
73
|
console.log(result.status) // 200
|
|
33
74
|
console.log(result.data) // response body
|
|
@@ -56,9 +97,9 @@ Create a mock client for unit testing — no server required:
|
|
|
56
97
|
\`\`\`js
|
|
57
98
|
const client = ${model.const.Name}SDK.test()
|
|
58
99
|
|
|
59
|
-
const
|
|
60
|
-
//
|
|
61
|
-
|
|
100
|
+
const ${eVar} = await client.${eName}().${primaryOp}(${testCallArg})
|
|
101
|
+
// ${eVar} is a bare entity populated with mock response data
|
|
102
|
+
console.log(${eVar})
|
|
62
103
|
\`\`\`
|
|
63
104
|
|
|
64
105
|
You can also use the instance method:
|
|
@@ -73,14 +114,14 @@ const testClient = client.tester()
|
|
|
73
114
|
Entity instances remember their last match and data:
|
|
74
115
|
|
|
75
116
|
\`\`\`js
|
|
76
|
-
const entity = client
|
|
117
|
+
const entity = client.${eName}()
|
|
77
118
|
|
|
78
|
-
// First call
|
|
79
|
-
await entity
|
|
119
|
+
// First call runs the operation and stores its result
|
|
120
|
+
await entity.${primaryOp}(${stateCallArg})
|
|
80
121
|
|
|
81
|
-
// Subsequent calls reuse the stored
|
|
122
|
+
// Subsequent calls reuse the stored state
|
|
82
123
|
const data = entity.data()
|
|
83
|
-
|
|
124
|
+
${stateDataLine}
|
|
84
125
|
\`\`\`
|
|
85
126
|
|
|
86
127
|
### Add custom middleware
|
|
@@ -109,7 +150,7 @@ const client = new ${model.const.Name}SDK({${apikeyExtendField}
|
|
|
109
150
|
Create a \`.env.local\` file at the project root:
|
|
110
151
|
|
|
111
152
|
\`\`\`
|
|
112
|
-
${model
|
|
153
|
+
${envName(model)}_TEST_LIVE=TRUE${apikeyEnvLine}
|
|
113
154
|
\`\`\`
|
|
114
155
|
|
|
115
156
|
Then run:
|
|
@@ -1,13 +1,51 @@
|
|
|
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
|
+
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
17
|
+
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
18
|
+
const eName = exampleEntity ? nom(exampleEntity, 'Name') : 'Entity'
|
|
19
|
+
|
|
20
|
+
// Model-driven op list — only the operations the active entities actually
|
|
21
|
+
// expose (a read-only entity has just list+load); never claim
|
|
22
|
+
// create/update/remove exist when no entity has them.
|
|
23
|
+
const CANON_OPS = ['list', 'load', 'create', 'update', 'remove']
|
|
24
|
+
const opSet = new Set<string>()
|
|
25
|
+
Object.values(entity || {}).forEach((e: any) => {
|
|
26
|
+
if (!e || e.active === false) return
|
|
27
|
+
Object.keys(e.op || {}).forEach((o: string) => {
|
|
28
|
+
if (e.op[o] && e.op[o].active !== false) opSet.add(o)
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
const opNames = CANON_OPS.filter((o) => opSet.has(o))
|
|
32
|
+
.concat([...opSet].filter((o) => !CANON_OPS.includes(o)))
|
|
33
|
+
const opList = (opNames.length ? opNames : ['list', 'load'])
|
|
34
|
+
.map((o) => '`' + o + '`').join(', ')
|
|
7
35
|
|
|
8
36
|
Content(`# ${model.Name} ${target.title} SDK
|
|
9
37
|
|
|
10
|
-
|
|
38
|
+
${tagline}
|
|
39
|
+
|
|
40
|
+
The ${target.title} SDK for the ${model.Name} API — an entity-oriented client with full async/await support.
|
|
41
|
+
|
|
42
|
+
The API is exposed as capitalised, semantic **Entities** — e.g.
|
|
43
|
+
\`client.${eName}()\` — each with a small set of operations (${opList})
|
|
44
|
+
instead of raw URL paths and query parameters. This keeps the surface
|
|
45
|
+
predictable and low-friction for both humans and AI agents.
|
|
46
|
+
|
|
47
|
+
> Other languages, the CLI, and MCP server live alongside this one — see
|
|
48
|
+
> the [top-level README](../README.md).
|
|
11
49
|
|
|
12
50
|
`)
|
|
13
51
|
})
|