@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,21 +1,64 @@
|
|
|
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_ts'
|
|
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
|
+
// Variable-safe lowercase name (a `Delete` entity must not bind `delete`).
|
|
20
|
+
const eVar = safeVarName(eName.toLowerCase(), 'ts')
|
|
21
|
+
|
|
22
|
+
// Drive the test-mode / stateful examples off the entity's PRIMARY op — an op
|
|
23
|
+
// it actually exposes — never a hardcoded `load` a create-only entity lacks.
|
|
24
|
+
const primaryOp = exampleEntity ? (entityPrimaryOp(exampleEntity) || 'load') : 'load'
|
|
25
|
+
const primaryOpDef = exampleEntity && exampleEntity.op && exampleEntity.op[primaryOp]
|
|
26
|
+
const isMatchOp = 'load' === primaryOp || 'remove' === primaryOp
|
|
27
|
+
// Model-driven id key: `idF` is the entity's id-like MATCH field name, or null
|
|
28
|
+
// when it has none. `dataIdF` is the id on the RETURNED record's data type —
|
|
29
|
+
// reading `.id` off a record whose data type has none is a TS2339.
|
|
30
|
+
const idF = exampleEntity ? entityIdField(exampleEntity) : null
|
|
31
|
+
const dataIdF = exampleEntity ? entityDataIdField(exampleEntity) : null
|
|
32
|
+
|
|
33
|
+
// A type-correct, language-idiomatic argument for the primary op call.
|
|
34
|
+
const primaryArg = (idPlaceholder: string): string => {
|
|
35
|
+
if (!exampleEntity) return ''
|
|
36
|
+
if ('list' === primaryOp) return ''
|
|
37
|
+
if (isMatchOp) {
|
|
38
|
+
return idF ? `{ ${idF}: ${exampleValue(exampleEntity, primaryOpDef, idF, idPlaceholder)} }` : ''
|
|
39
|
+
}
|
|
40
|
+
// create / update: a body of the required writable fields.
|
|
41
|
+
const items = opRequestShape(exampleEntity, primaryOp).items
|
|
42
|
+
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
43
|
+
const required = items.filter((it: any) => !it.optional)
|
|
44
|
+
const chosen = required.length ? required : items.slice(0, 3)
|
|
45
|
+
const pairs = chosen.map((it: any) =>
|
|
46
|
+
`${it.name}: ${exampleValue(exampleEntity, primaryOpDef, it.name, 'example_' + it.name)}`)
|
|
47
|
+
return `{ ${pairs.join(', ')} }`
|
|
48
|
+
}
|
|
49
|
+
const testCallArg = primaryArg('test01')
|
|
50
|
+
const stateCallArg = primaryArg('example')
|
|
51
|
+
// Only read `.id` off the returned record when its data type carries one.
|
|
52
|
+
const stateDataLine = dataIdF
|
|
53
|
+
? `console.log(data.${dataIdF})`
|
|
54
|
+
: `console.log(data)`
|
|
55
|
+
|
|
13
56
|
const authActive = isAuthActive(model)
|
|
14
57
|
const apikeyTesterCtor = authActive
|
|
15
58
|
? `new ${model.const.Name}SDK({ apikey: '...' })`
|
|
16
59
|
: `new ${model.const.Name}SDK()`
|
|
17
60
|
const apikeyExtendField = authActive ? `\n apikey: '...',` : ''
|
|
18
|
-
const apikeyEnvLine = authActive ? `\n${model
|
|
61
|
+
const apikeyEnvLine = authActive ? `\n${envName(model)}_APIKEY=<your-key>` : ''
|
|
19
62
|
|
|
20
63
|
Content(`### Make a direct HTTP request
|
|
21
64
|
|
|
@@ -28,6 +71,9 @@ const result = await client.direct({
|
|
|
28
71
|
params: { id: 'example' },
|
|
29
72
|
})
|
|
30
73
|
|
|
74
|
+
if (result instanceof Error) {
|
|
75
|
+
throw result
|
|
76
|
+
}
|
|
31
77
|
if (result.ok) {
|
|
32
78
|
console.log(result.status) // 200
|
|
33
79
|
console.log(result.data) // response body
|
|
@@ -56,9 +102,9 @@ Create a mock client for unit testing \u2014 no server required:
|
|
|
56
102
|
\`\`\`ts
|
|
57
103
|
const client = ${model.const.Name}SDK.test()
|
|
58
104
|
|
|
59
|
-
const
|
|
60
|
-
//
|
|
61
|
-
|
|
105
|
+
const ${eVar} = await client.${eName}().${primaryOp}(${testCallArg})
|
|
106
|
+
// ${eVar} is a bare entity populated with mock response data
|
|
107
|
+
console.log(${eVar})
|
|
62
108
|
\`\`\`
|
|
63
109
|
|
|
64
110
|
You can also use the instance method:
|
|
@@ -73,14 +119,14 @@ const testClient = client.tester()
|
|
|
73
119
|
Entity instances remember their last match and data:
|
|
74
120
|
|
|
75
121
|
\`\`\`ts
|
|
76
|
-
const entity = client
|
|
122
|
+
const entity = client.${eName}()
|
|
77
123
|
|
|
78
|
-
// First call
|
|
79
|
-
await entity
|
|
124
|
+
// First call runs the operation and stores its result
|
|
125
|
+
await entity.${primaryOp}(${stateCallArg})
|
|
80
126
|
|
|
81
|
-
// Subsequent calls reuse the stored
|
|
127
|
+
// Subsequent calls reuse the stored state
|
|
82
128
|
const data = entity.data()
|
|
83
|
-
|
|
129
|
+
${stateDataLine}
|
|
84
130
|
\`\`\`
|
|
85
131
|
|
|
86
132
|
### Add custom middleware
|
|
@@ -109,7 +155,7 @@ const client = new ${model.const.Name}SDK({${apikeyExtendField}
|
|
|
109
155
|
Create a \`.env.local\` file at the project root:
|
|
110
156
|
|
|
111
157
|
\`\`\`
|
|
112
|
-
${model
|
|
158
|
+
${envName(model)}_TEST_LIVE=TRUE${apikeyEnvLine}
|
|
113
159
|
\`\`\`
|
|
114
160
|
|
|
115
161
|
Then run:
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, installCommand, isPublished, repoInfo } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
|
|
6
|
-
const { target } = props
|
|
6
|
+
const { target, ctx$ } = props
|
|
7
|
+
const { model } = ctx$
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if (isPublished(model, target.name)) {
|
|
10
|
+
Content('```bash')
|
|
11
|
+
Content(`
|
|
12
|
+
${installCommand(model, target.name)}
|
|
11
13
|
`)
|
|
12
|
-
|
|
14
|
+
Content('```')
|
|
15
|
+
return
|
|
16
|
+
}
|
|
13
17
|
|
|
18
|
+
// Publish pending: the package is not yet on npm, so install from the
|
|
19
|
+
// git release tag instead of a `npm install` that would 404.
|
|
20
|
+
const { releasesUrl } = repoInfo(model)
|
|
21
|
+
Content(`This package is not yet published to npm. Install it from the GitHub
|
|
22
|
+
release tag (\`${target.name}/vX.Y.Z\`):
|
|
23
|
+
|
|
24
|
+
- Releases: [${releasesUrl}](${releasesUrl})
|
|
25
|
+
|
|
26
|
+
`)
|
|
14
27
|
})
|
|
15
28
|
|
|
16
29
|
|
|
@@ -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 — a type-safe, 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
|
})
|
|
@@ -13,6 +13,43 @@ const ReadmeModel = cmp(function ReadmeModel(props: any) {
|
|
|
13
13
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
14
14
|
const entityList = each(entity).filter((e: any) => e.active !== false)
|
|
15
15
|
|
|
16
|
+
// Model-driven op rows for the shared entity interface: emit a
|
|
17
|
+
// load/list/create/update/remove row only for operations at least one active
|
|
18
|
+
// entity actually exposes (a read-only entity has just list+load) — never
|
|
19
|
+
// document an operation no entity has.
|
|
20
|
+
const opUnion = new Set<string>()
|
|
21
|
+
entityList.forEach((e: any) => Object.keys(e.op || {})
|
|
22
|
+
.forEach((o: string) => { if (e.op[o] && e.op[o].active !== false) opUnion.add(o) }))
|
|
23
|
+
const opRowDefs: Record<string, string> = {
|
|
24
|
+
load: '| `load` | `load(reqmatch?, ctrl?): Promise<Entity>` | Load a single entity by match criteria. |',
|
|
25
|
+
list: '| `list` | `list(reqmatch?, ctrl?): Promise<Entity[]>` | List entities matching the criteria. |',
|
|
26
|
+
create: '| `create` | `create(reqdata?, ctrl?): Promise<Entity>` | Create a new entity. |',
|
|
27
|
+
update: '| `update` | `update(reqdata?, ctrl?): Promise<Entity>` | Update an existing entity. |',
|
|
28
|
+
remove: '| `remove` | `remove(reqmatch?, ctrl?): Promise<void>` | Remove an entity. |',
|
|
29
|
+
}
|
|
30
|
+
const opRows = ['load', 'list', 'create', 'update', 'remove']
|
|
31
|
+
.filter((o) => opUnion.has(o)).map((o) => opRowDefs[o]).join('\n')
|
|
32
|
+
|
|
33
|
+
// Model-driven return-value bullets: describe only the operations that
|
|
34
|
+
// actually exist (single-object ops among load/create/update, plus
|
|
35
|
+
// list/remove) — never document return semantics for a missing op.
|
|
36
|
+
const singleOps = ['load', 'create', 'update'].filter((o) => opUnion.has(o))
|
|
37
|
+
.map((o) => '`' + o + '`')
|
|
38
|
+
const retBullets: string[] = []
|
|
39
|
+
if (singleOps.length) {
|
|
40
|
+
const joined = singleOps.length > 1
|
|
41
|
+
? singleOps.slice(0, -1).join(', ') + ' and ' + singleOps[singleOps.length - 1]
|
|
42
|
+
: singleOps[0]
|
|
43
|
+
retBullets.push(`- ${joined} ${singleOps.length > 1 ? 'resolve' : 'resolves'} to a single entity object.`)
|
|
44
|
+
}
|
|
45
|
+
if (opUnion.has('list')) {
|
|
46
|
+
retBullets.push('- `list` resolves to an **array** of entity objects (iterate it directly;\n there is no `.data` and no `.ok`).')
|
|
47
|
+
}
|
|
48
|
+
if (opUnion.has('remove')) {
|
|
49
|
+
retBullets.push('- `remove` resolves to `void`.')
|
|
50
|
+
}
|
|
51
|
+
const returnBullets = retBullets.join('\n')
|
|
52
|
+
|
|
16
53
|
const authActive = isAuthActive(model)
|
|
17
54
|
const apikeyOptionType = authActive ? `\n apikey?: string` : ''
|
|
18
55
|
const apikeyOptionRow = authActive
|
|
@@ -52,7 +89,8 @@ ${apikeyOptionRow}| \`base\` | \`string\` | Base URL of the API server. |
|
|
|
52
89
|
`)
|
|
53
90
|
|
|
54
91
|
each(entityList, (ent: any) => {
|
|
55
|
-
|
|
92
|
+
const article = /^[aeiou]/i.test(ent.Name) ? 'an' : 'a'
|
|
93
|
+
Content(`| \`${ent.Name}(data?)\` | \`${ent.Name}Entity\` | Create ${article} ${ent.Name} entity instance. |
|
|
56
94
|
`)
|
|
57
95
|
})
|
|
58
96
|
|
|
@@ -72,29 +110,23 @@ All entities share the same interface.
|
|
|
72
110
|
|
|
73
111
|
| Method | Signature | Description |
|
|
74
112
|
| --- | --- | --- |
|
|
75
|
-
|
|
76
|
-
| \`
|
|
77
|
-
| \`
|
|
78
|
-
| \`update\` | \`update(reqdata?, ctrl?): Promise<Result>\` | Update an existing entity. |
|
|
79
|
-
| \`remove\` | \`remove(reqmatch?, ctrl?): Promise<Result>\` | Remove an entity. |
|
|
80
|
-
| \`data\` | \`data(data?): any\` | Get or set entity data. |
|
|
81
|
-
| \`match\` | \`match(match?): any\` | Get or set entity match criteria. |
|
|
113
|
+
${opRows}
|
|
114
|
+
| \`data\` | \`data(data?: Partial<Entity>): Entity\` | Get or set entity data. |
|
|
115
|
+
| \`match\` | \`match(match?: Partial<Entity>): Partial<Entity>\` | Get or set entity match criteria. |
|
|
82
116
|
| \`make\` | \`make(): Entity\` | Create a new instance with the same options. |
|
|
83
117
|
| \`client\` | \`client(): ${model.const.Name}SDK\` | Return the parent SDK client. |
|
|
84
118
|
| \`entopts\` | \`entopts(): object\` | Return a copy of the entity options. |
|
|
85
119
|
|
|
86
|
-
####
|
|
120
|
+
#### Return values
|
|
87
121
|
|
|
88
|
-
|
|
122
|
+
Entity operations resolve to the entity data directly — there is no
|
|
123
|
+
result envelope:
|
|
89
124
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
data: any // parsed JSON response body
|
|
96
|
-
}
|
|
97
|
-
\`\`\`
|
|
125
|
+
${returnBullets}
|
|
126
|
+
|
|
127
|
+
On a failed request these methods **throw**, so wrap calls in
|
|
128
|
+
\`try\`/\`catch\` to handle errors. Only \`direct()\` returns the result
|
|
129
|
+
envelope described below.
|
|
98
130
|
|
|
99
131
|
### DirectResult shape
|
|
100
132
|
|
|
@@ -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 @@ const client = new ${model.Name}SDK({
|
|
|
25
26
|
|
|
26
27
|
publishedOptions.map((option: any) => {
|
|
27
28
|
if ('apikey' === option.name) {
|
|
28
|
-
Content(` ${option.name}: process.env.${model
|
|
29
|
+
Content(` ${option.name}: process.env.${envName(model)}_APIKEY,
|
|
29
30
|
`)
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, isAuthActive } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, each, Content, isAuthActive, packageName, envName, opRequestShape, entityIdField, entityDataIdField, entityOps, safeVarName } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
nom,
|
|
8
8
|
} from '@voxgig/apidef'
|
|
9
9
|
|
|
10
|
+
import { exampleValue } from './utility_ts'
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
12
14
|
const { target, ctx$: { model } } = props
|
|
@@ -16,21 +18,27 @@ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
|
16
18
|
// Find the first published entity for examples
|
|
17
19
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
18
20
|
|
|
19
|
-
// Find a nested entity if available
|
|
21
|
+
// Find a nested entity if available: one with a parent chain
|
|
22
|
+
// (relations.ancestors), an active load op, and a required non-id load
|
|
23
|
+
// param to demonstrate (the parent key, e.g. page_id).
|
|
20
24
|
const nestedEntity = Object.values(entity).find((e: any) =>
|
|
21
|
-
e.active !== false &&
|
|
25
|
+
e.active !== false &&
|
|
26
|
+
e.relations && e.relations.ancestors && 0 < e.relations.ancestors.length &&
|
|
27
|
+
entityOps(e).includes('load') &&
|
|
28
|
+
opRequestShape(e, 'load').items.some((it: any) =>
|
|
29
|
+
!it.optional && it.name !== entityIdField(e))
|
|
22
30
|
) as any
|
|
23
31
|
|
|
24
|
-
const
|
|
25
|
-
?
|
|
26
|
-
:
|
|
32
|
+
const ctor = isAuthActive(model)
|
|
33
|
+
? `new ${model.const.Name}SDK({\n apikey: process.env.${envName(model)}_APIKEY,\n})`
|
|
34
|
+
: `new ${model.const.Name}SDK()`
|
|
27
35
|
|
|
28
36
|
Content(`### 1. Create a client
|
|
29
37
|
|
|
30
38
|
\`\`\`ts
|
|
31
|
-
import { ${model.const.Name}SDK } from '${target.
|
|
39
|
+
import { ${model.const.Name}SDK } from '${packageName(model, target.name)}'
|
|
32
40
|
|
|
33
|
-
const client =
|
|
41
|
+
const client = ${ctor}
|
|
34
42
|
\`\`\`
|
|
35
43
|
|
|
36
44
|
`)
|
|
@@ -38,18 +46,30 @@ const client = new ${model.const.Name}SDK({${apikeyArg}})
|
|
|
38
46
|
|
|
39
47
|
if (exampleEntity) {
|
|
40
48
|
const eName = nom(exampleEntity, 'Name')
|
|
41
|
-
|
|
49
|
+
// Variable-safe lowercase name — a `Delete`/`Class` entity must not bind a
|
|
50
|
+
// reserved word (`const delete = ...` is a TS1109 syntax error).
|
|
51
|
+
const eVar = safeVarName(eName.toLowerCase(), 'ts')
|
|
52
|
+
const article = /^[aeiou]/i.test(eName) ? 'an' : 'a'
|
|
53
|
+
const opnames = entityOps(exampleEntity)
|
|
54
|
+
// Model-driven id key: `idF` is the entity's id-like MATCH field name, or
|
|
55
|
+
// null when it has none (then load/remove match on no argument).
|
|
56
|
+
const idF = entityIdField(exampleEntity)
|
|
57
|
+
// The id field on the RETURNED record's data type, or null. DISTINCT from
|
|
58
|
+
// idF (the match key): an entity can key its load-match on an id it does not
|
|
59
|
+
// carry as a data field, so `.id` off a returned record must be guarded on
|
|
60
|
+
// this — reading `created.id` when the data type has no id is a TS2339.
|
|
61
|
+
const dataIdF = entityDataIdField(exampleEntity)
|
|
42
62
|
|
|
43
63
|
if (opnames.includes('list')) {
|
|
44
|
-
Content(`### 2. List ${eName.toLowerCase()}
|
|
64
|
+
Content(`### 2. List ${eName.toLowerCase()} records
|
|
65
|
+
|
|
66
|
+
\`list()\` resolves to an array of ${eName} objects — iterate it directly:
|
|
45
67
|
|
|
46
68
|
\`\`\`ts
|
|
47
|
-
const
|
|
69
|
+
const ${eVar}s = await client.${eName}().list()
|
|
48
70
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.log(item.id, item.name)
|
|
52
|
-
}
|
|
71
|
+
for (const ${eVar} of ${eVar}s) {
|
|
72
|
+
console.log(${eVar})
|
|
53
73
|
}
|
|
54
74
|
\`\`\`
|
|
55
75
|
|
|
@@ -58,70 +78,143 @@ if (result.ok) {
|
|
|
58
78
|
|
|
59
79
|
if (nestedEntity) {
|
|
60
80
|
const neName = nom(nestedEntity, 'Name')
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
const neVar = safeVarName(neName.toLowerCase(), 'ts')
|
|
82
|
+
const neArticle = /^[aeiou]/i.test(neName) ? 'an' : 'a'
|
|
83
|
+
const loadOp = nestedEntity.op && nestedEntity.op.load
|
|
84
|
+
|
|
85
|
+
// Model-driven match: every REQUIRED load-match key — the same shape
|
|
86
|
+
// that generates <Name>LoadMatch, so the example always type-checks.
|
|
87
|
+
// Parent keys (e.g. page_id) first, the entity's own id last.
|
|
88
|
+
const neIdF = entityIdField(nestedEntity)
|
|
89
|
+
const neRequired = opRequestShape(nestedEntity, 'load').items
|
|
90
|
+
.filter((it: any) => !it.optional)
|
|
91
|
+
.sort((a: any, b: any) =>
|
|
92
|
+
(a.name === neIdF ? 1 : 0) - (b.name === neIdF ? 1 : 0))
|
|
93
|
+
const parentItem = neRequired.find((it: any) => it.name !== neIdF) as any
|
|
94
|
+
const parentParam = parentItem && parentItem.name
|
|
95
|
+
const parentName = parentParam ? parentParam.replace(/_id$/, '') : 'its parent'
|
|
96
|
+
const neMatchLines = neRequired.map((it: any) =>
|
|
97
|
+
` ${it.name}: ${exampleValue(nestedEntity, loadOp, it.name,
|
|
98
|
+
it.name === neIdF ? 'example_id' : 'example_' + it.name)},`)
|
|
99
|
+
|
|
100
|
+
Content(`### 3. Load ${neArticle} ${neName.toLowerCase()}
|
|
101
|
+
|
|
102
|
+
${neName} is nested under ${parentName}, so provide the \`${parentParam}\`.
|
|
103
|
+
\`load()\` returns the entity directly and throws on failure:
|
|
68
104
|
|
|
69
105
|
\`\`\`ts
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
console.log(result.data)
|
|
106
|
+
try {
|
|
107
|
+
const ${neVar} = await client.${neName}().load({
|
|
108
|
+
${neMatchLines.join('\n')}
|
|
109
|
+
})
|
|
110
|
+
console.log(${neVar})
|
|
111
|
+
} catch (err) {
|
|
112
|
+
console.error('load failed:', err)
|
|
78
113
|
}
|
|
79
114
|
\`\`\`
|
|
80
115
|
|
|
81
116
|
`)
|
|
82
117
|
}
|
|
83
118
|
else if (opnames.includes('load')) {
|
|
84
|
-
|
|
119
|
+
// Every REQUIRED load-match key (id first) — the same shape that
|
|
120
|
+
// generates <Name>LoadMatch, so the example always type-checks.
|
|
121
|
+
const loadRequired = opRequestShape(exampleEntity, 'load').items
|
|
122
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
123
|
+
.sort((a: any, b: any) =>
|
|
124
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
125
|
+
const loadArg = 0 < loadRequired.length
|
|
126
|
+
? `{ ${loadRequired.map((it: any) =>
|
|
127
|
+
`${it.name}: ${exampleValue(exampleEntity, exampleEntity.op && exampleEntity.op.load, it.name,
|
|
128
|
+
it.name === idF ? 'example_id' : 'example_' + it.name)}`).join(', ')} }`
|
|
129
|
+
: ''
|
|
130
|
+
|
|
131
|
+
Content(`### 3. Load ${article} ${eName.toLowerCase()}
|
|
132
|
+
|
|
133
|
+
\`load()\` returns the entity directly and throws on failure:
|
|
85
134
|
|
|
86
135
|
\`\`\`ts
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
136
|
+
try {
|
|
137
|
+
const ${eVar} = await client.${eName}().load(${loadArg})
|
|
138
|
+
console.log(${eVar})
|
|
139
|
+
} catch (err) {
|
|
140
|
+
console.error('load failed:', err)
|
|
91
141
|
}
|
|
92
142
|
\`\`\`
|
|
93
143
|
|
|
94
144
|
`)
|
|
95
145
|
}
|
|
96
146
|
|
|
97
|
-
// CRUD operations
|
|
147
|
+
// CRUD operations. The create/update example payloads are derived from the
|
|
148
|
+
// SAME op shapes that generate the <Name>CreateData / <Name>UpdateData types
|
|
149
|
+
// (opRequestShape), so the snippet always type-checks. Prefer writable
|
|
150
|
+
// non-id fields and render a type-correct literal per field via
|
|
151
|
+
// exampleValue — never a hardcoded field the entity may not have.
|
|
98
152
|
if (opnames.includes('create') || opnames.includes('update') || opnames.includes('remove')) {
|
|
153
|
+
// Writable non-id example fields for an op body. For create the REQUIRED
|
|
154
|
+
// fields must all appear or the literal is not assignable to the typed
|
|
155
|
+
// <Name>CreateData (a TS2345); update is a patch, so a couple of fields
|
|
156
|
+
// suffice.
|
|
157
|
+
const exampleFields = (opname: string): string[] => {
|
|
158
|
+
// ids are rendered separately as the match key for update/remove; a
|
|
159
|
+
// REQUIRED id stays (dropping it makes the literal unassignable).
|
|
160
|
+
const items = opRequestShape(exampleEntity, opname).items
|
|
161
|
+
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
162
|
+
('create' === opname && !it.optional))
|
|
163
|
+
const required = items.filter((it: any) => !it.optional)
|
|
164
|
+
const optional = items.filter((it: any) => it.optional)
|
|
165
|
+
// Required members must all appear or the literal is not assignable
|
|
166
|
+
// to the typed <Name>{Create,Update}Data; pad update (a patch) with a
|
|
167
|
+
// sample optional field or two.
|
|
168
|
+
const chosen = 'create' === opname
|
|
169
|
+
? (required.length ? required : items.slice(0, 2))
|
|
170
|
+
: required.concat(optional).slice(0, Math.max(2, required.length))
|
|
171
|
+
return chosen.map((it: any) =>
|
|
172
|
+
` ${it.name}: ${exampleValue(exampleEntity, exampleEntity.op[opname], it.name, 'example_' + it.name)},`)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// The id VALUE for an update/remove match. When the entity's DATA type
|
|
176
|
+
// carries the id (dataIdF) AND a `created` record exists, take it off the
|
|
177
|
+
// returned record; otherwise use a type-correct literal — reading
|
|
178
|
+
// `created.id` off an id-less data type is a TS2339.
|
|
179
|
+
const canUseCreatedId = null != dataIdF && opnames.includes('create')
|
|
180
|
+
const idValueFor = (opname: string): string => canUseCreatedId
|
|
181
|
+
? `created.${dataIdF}!`
|
|
182
|
+
: exampleValue(exampleEntity, exampleEntity.op[opname], idF as string, 'example_id')
|
|
183
|
+
|
|
99
184
|
Content(`### 4. Create, update, and remove
|
|
100
185
|
|
|
101
186
|
\`\`\`ts
|
|
102
187
|
`)
|
|
103
188
|
if (opnames.includes('create')) {
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
})
|
|
189
|
+
const createLines = exampleFields('create')
|
|
190
|
+
const createBody = createLines.length ? '\n' + createLines.join('\n') + '\n' : ''
|
|
191
|
+
Content(`// Create — returns the created ${eName}
|
|
192
|
+
const created = await client.${eName}().create({${createBody}})
|
|
108
193
|
|
|
109
194
|
`)
|
|
110
195
|
}
|
|
111
196
|
if (opnames.includes('update')) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
197
|
+
// Match on the id (from the returned `created` record when the data
|
|
198
|
+
// type carries one, else a literal), plus a couple of patch fields.
|
|
199
|
+
const updateLines = (idF ? [` ${idF}: ${idValueFor('update')},`] : []).concat(exampleFields('update'))
|
|
200
|
+
const updateBody = updateLines.length ? '\n' + updateLines.join('\n') + '\n' : ''
|
|
201
|
+
Content(`// Update${canUseCreatedId ? ' — the id comes straight off the returned entity' : ''}
|
|
202
|
+
const updated = await client.${eName}().update({${updateBody}})
|
|
117
203
|
|
|
118
204
|
`)
|
|
119
205
|
}
|
|
120
206
|
if (opnames.includes('remove')) {
|
|
207
|
+
// Every REQUIRED remove-match key: the id (off the created record
|
|
208
|
+
// when possible) plus parent keys like page_id.
|
|
209
|
+
const removeLines = opRequestShape(exampleEntity, 'remove').items
|
|
210
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
211
|
+
.sort((a: any, b: any) =>
|
|
212
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
213
|
+
.map((it: any) => it.name === idF
|
|
214
|
+
? ` ${it.name}: ${idValueFor('remove')},`
|
|
215
|
+
: ` ${it.name}: ${exampleValue(exampleEntity, exampleEntity.op.remove, it.name, 'example_' + it.name)},`)
|
|
121
216
|
Content(`// Remove
|
|
122
|
-
|
|
123
|
-
id: created.data.id,
|
|
124
|
-
})
|
|
217
|
+
await client.${eName}().remove(${removeLines.length ? `{\n${removeLines.join('\n')}\n}` : ''})
|
|
125
218
|
`)
|
|
126
219
|
}
|
|
127
220
|
Content(`\`\`\`
|