@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,12 +1,50 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, canonKey, entityIdField, entityPrimaryOp, opRequestShape } from '@voxgig/sdkgen'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
KIT,
|
|
6
|
+
getModelPath,
|
|
7
|
+
nom,
|
|
8
|
+
} from '@voxgig/apidef'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
// A type-correct Python literal for a field's canonical type.
|
|
12
|
+
function pyLit(type: any): string {
|
|
13
|
+
const k = canonKey(type)
|
|
14
|
+
if ('INTEGER' === k || 'NUMBER' === k) return '1'
|
|
15
|
+
if ('BOOLEAN' === k) return 'True'
|
|
16
|
+
if ('ARRAY' === k) return '[]'
|
|
17
|
+
if ('OBJECT' === k) return '{}'
|
|
18
|
+
return '"example"'
|
|
19
|
+
}
|
|
3
20
|
|
|
4
21
|
|
|
5
22
|
const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
6
23
|
const { target, ctx$: { model } } = props
|
|
7
24
|
|
|
25
|
+
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
26
|
+
const exampleEntity = Object.values(entity || {}).find((e: any) => e && e.active !== false) as any
|
|
27
|
+
const eName = exampleEntity ? nom(exampleEntity, 'Name') : 'Entity'
|
|
28
|
+
// Model-driven id key: null when the entity has no id-like field, so a
|
|
29
|
+
// match op takes no argument.
|
|
30
|
+
const idF = exampleEntity ? entityIdField(exampleEntity) : null
|
|
31
|
+
// Drive the test-mode example off the entity's PRIMARY op — never a hardcoded
|
|
32
|
+
// `load` a create-only entity lacks.
|
|
33
|
+
const primaryOp = exampleEntity ? (entityPrimaryOp(exampleEntity) || 'load') : 'load'
|
|
34
|
+
const isMatchOp = 'load' === primaryOp || 'remove' === primaryOp
|
|
35
|
+
let testArg = ''
|
|
36
|
+
if (exampleEntity && isMatchOp) {
|
|
37
|
+
testArg = idF ? `{"${idF}": "test01"}` : ''
|
|
38
|
+
} else if (exampleEntity && ('create' === primaryOp || 'update' === primaryOp)) {
|
|
39
|
+
const items = opRequestShape(exampleEntity, primaryOp).items
|
|
40
|
+
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
41
|
+
const required = items.filter((it: any) => !it.optional)
|
|
42
|
+
const chosen = required.length ? required : items.slice(0, 3)
|
|
43
|
+
testArg = `{${chosen.map((it: any) => `"${it.name}": ${pyLit(it.type)}`).join(', ')}}`
|
|
44
|
+
}
|
|
45
|
+
|
|
8
46
|
const apikeyEnvLine = isAuthActive(model)
|
|
9
|
-
? `\n${model
|
|
47
|
+
? `\n${envName(model)}_APIKEY=<your-key>`
|
|
10
48
|
: ''
|
|
11
49
|
|
|
12
50
|
Content(`### Make a direct HTTP request
|
|
@@ -14,29 +52,31 @@ const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
|
14
52
|
For endpoints not covered by entity methods:
|
|
15
53
|
|
|
16
54
|
\`\`\`python
|
|
17
|
-
result
|
|
55
|
+
result = client.direct({
|
|
18
56
|
"path": "/api/resource/{id}",
|
|
19
57
|
"method": "GET",
|
|
20
58
|
"params": {"id": "example"},
|
|
21
59
|
})
|
|
22
|
-
if err:
|
|
23
|
-
raise Exception(err)
|
|
24
60
|
|
|
25
61
|
if result["ok"]:
|
|
26
62
|
print(result["status"]) # 200
|
|
27
63
|
print(result["data"]) # response body
|
|
64
|
+
else:
|
|
65
|
+
# A non-2xx response carries status + data (the error body); a
|
|
66
|
+
# transport-level failure carries err instead. Only one is present, so
|
|
67
|
+
# read both with .get() rather than indexing a key that may be absent.
|
|
68
|
+
print(result.get("status"), result.get("err"))
|
|
28
69
|
\`\`\`
|
|
29
70
|
|
|
30
71
|
### Prepare a request without sending it
|
|
31
72
|
|
|
32
73
|
\`\`\`python
|
|
33
|
-
|
|
74
|
+
# prepare() returns the fetch definition and raises on error.
|
|
75
|
+
fetchdef = client.prepare({
|
|
34
76
|
"path": "/api/resource/{id}",
|
|
35
77
|
"method": "DELETE",
|
|
36
78
|
"params": {"id": "example"},
|
|
37
79
|
})
|
|
38
|
-
if err:
|
|
39
|
-
raise Exception(err)
|
|
40
80
|
|
|
41
81
|
print(fetchdef["url"])
|
|
42
82
|
print(fetchdef["method"])
|
|
@@ -48,12 +88,11 @@ print(fetchdef["headers"])
|
|
|
48
88
|
Create a mock client for unit testing — no server required:
|
|
49
89
|
|
|
50
90
|
\`\`\`python
|
|
51
|
-
client = ${model.const.Name}SDK.test(
|
|
91
|
+
client = ${model.const.Name}SDK.test()
|
|
52
92
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
# result contains mock response data
|
|
93
|
+
# Entity ops return the bare record and raise on error.
|
|
94
|
+
${eName.toLowerCase()} = client.${eName}().${primaryOp}(${testArg})
|
|
95
|
+
# ${eName.toLowerCase()} contains the mock response record
|
|
57
96
|
\`\`\`
|
|
58
97
|
|
|
59
98
|
### Use a custom fetch function
|
|
@@ -82,7 +121,7 @@ client = ${model.const.Name}SDK({
|
|
|
82
121
|
Create a \`.env.local\` file at the project root:
|
|
83
122
|
|
|
84
123
|
\`\`\`
|
|
85
|
-
${model
|
|
124
|
+
${envName(model)}_TEST_LIVE=TRUE${apikeyEnvLine}
|
|
86
125
|
\`\`\`
|
|
87
126
|
|
|
88
127
|
Then run:
|
|
@@ -1,13 +1,14 @@
|
|
|
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
6
|
const { target, ctx$ } = props
|
|
7
7
|
const { model } = ctx$
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if (isPublished(model, target.name)) {
|
|
10
|
+
Content(`\`\`\`bash
|
|
11
|
+
${installCommand(model, target.name)}
|
|
11
12
|
\`\`\`
|
|
12
13
|
|
|
13
14
|
Or install from source:
|
|
@@ -16,6 +17,21 @@ Or install from source:
|
|
|
16
17
|
pip install -e .
|
|
17
18
|
\`\`\`
|
|
18
19
|
|
|
20
|
+
`)
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Publish pending: not yet on PyPI. Install from the git release tag or
|
|
25
|
+
// from a local source checkout.
|
|
26
|
+
const { releasesUrl } = repoInfo(model)
|
|
27
|
+
Content(`This package is not yet published to PyPI. Install it from the GitHub
|
|
28
|
+
release tag (\`${target.name}/vX.Y.Z\`, see [Releases](${releasesUrl})) or
|
|
29
|
+
from a source checkout:
|
|
30
|
+
|
|
31
|
+
\`\`\`bash
|
|
32
|
+
pip install -e .
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
19
35
|
`)
|
|
20
36
|
})
|
|
21
37
|
|
|
@@ -1,13 +1,60 @@
|
|
|
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 || ''
|
|
7
15
|
|
|
8
16
|
Content(`# ${model.Name} ${target.title} SDK
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
${tagline}
|
|
19
|
+
|
|
20
|
+
The ${target.title} SDK for the ${model.Name} API — an entity-oriented client following Pythonic conventions.
|
|
21
|
+
|
|
22
|
+
`)
|
|
23
|
+
|
|
24
|
+
// Emphasise the entity-oriented design: the SDK surfaces the API as
|
|
25
|
+
// capitalised, semantic Entities with a small, uniform verb set rather
|
|
26
|
+
// than raw URL paths and query strings. The example entity name is
|
|
27
|
+
// derived from the model, never hardcoded.
|
|
28
|
+
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
29
|
+
const exampleEntity = Object.values(entity || {})
|
|
30
|
+
.find((e: any) => e.active !== false) as any
|
|
31
|
+
const example = exampleEntity
|
|
32
|
+
? `for example \`client.${nom(exampleEntity, 'Name')}()\` — each`
|
|
33
|
+
: 'each'
|
|
34
|
+
|
|
35
|
+
// Model-driven op list — only the operations the active entities actually
|
|
36
|
+
// expose (a read-only entity has just list+load); never claim
|
|
37
|
+
// create/update/remove exist when no entity has them.
|
|
38
|
+
const CANON_OPS = ['list', 'load', 'create', 'update', 'remove']
|
|
39
|
+
const opSet = new Set<string>()
|
|
40
|
+
Object.values(entity || {}).forEach((e: any) => {
|
|
41
|
+
if (!e || e.active === false) return
|
|
42
|
+
Object.keys(e.op || {}).forEach((o: string) => {
|
|
43
|
+
if (e.op[o] && e.op[o].active !== false) opSet.add(o)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
const opNames = CANON_OPS.filter((o) => opSet.has(o))
|
|
47
|
+
.concat([...opSet].filter((o) => !CANON_OPS.includes(o)))
|
|
48
|
+
const opList = (opNames.length ? opNames : ['list', 'load'])
|
|
49
|
+
.map((o) => '`' + o + '`').join(', ')
|
|
50
|
+
|
|
51
|
+
Content(`The SDK exposes the API as capitalised, semantic **Entities** — ${example}
|
|
52
|
+
carrying a small, uniform set of operations (${opList}) instead of raw URL
|
|
53
|
+
paths and query strings. You work with named resources and verbs, which
|
|
54
|
+
keeps the cognitive load low.
|
|
55
|
+
|
|
56
|
+
> Other languages, the CLI, and MCP server live alongside this one — see
|
|
57
|
+
> the [top-level README](../README.md).
|
|
11
58
|
|
|
12
59
|
`)
|
|
13
60
|
})
|
|
@@ -13,6 +13,23 @@ 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` | `(reqmatch, ctrl) -> any` | Load a single entity by match criteria. Raises on error. |',
|
|
25
|
+
list: '| `list` | `(reqmatch, ctrl) -> list` | List entities matching the criteria. Raises on error. |',
|
|
26
|
+
create: '| `create` | `(reqdata, ctrl) -> any` | Create a new entity. Raises on error. |',
|
|
27
|
+
update: '| `update` | `(reqdata, ctrl) -> any` | Update an existing entity. Raises on error. |',
|
|
28
|
+
remove: '| `remove` | `(reqmatch, ctrl) -> any` | Remove an entity. Raises on error. |',
|
|
29
|
+
}
|
|
30
|
+
const opRows = ['load', 'list', 'create', 'update', 'remove']
|
|
31
|
+
.filter((o) => opUnion.has(o)).map((o) => opRowDefs[o]).join('\n')
|
|
32
|
+
|
|
16
33
|
const apikeyOptionRow = isAuthActive(model)
|
|
17
34
|
? '| `apikey` | `str` | API key for authentication. |\n'
|
|
18
35
|
: ''
|
|
@@ -50,12 +67,13 @@ Creates a test-mode client with mock transport. Both arguments may be \`None\`.
|
|
|
50
67
|
| --- | --- | --- |
|
|
51
68
|
| \`options_map\` | \`() -> dict\` | Deep copy of current SDK options. |
|
|
52
69
|
| \`get_utility\` | \`() -> Utility\` | Copy of the SDK utility object. |
|
|
53
|
-
| \`prepare\` | \`(fetchargs) ->
|
|
54
|
-
| \`direct\` | \`(fetchargs) ->
|
|
70
|
+
| \`prepare\` | \`(fetchargs) -> dict\` | Build an HTTP request definition without sending. Raises on error. |
|
|
71
|
+
| \`direct\` | \`(fetchargs) -> dict\` | Build and send an HTTP request. Returns a result dict (branch on \`ok\`). |
|
|
55
72
|
`)
|
|
56
73
|
|
|
57
74
|
each(entityList, (ent: any) => {
|
|
58
|
-
|
|
75
|
+
const article = /^[aeiou]/i.test(ent.Name) ? 'an' : 'a'
|
|
76
|
+
Content(`| \`${ent.Name}\` | \`(data) -> ${ent.Name}Entity\` | Create ${article} ${ent.Name} entity instance. |
|
|
59
77
|
`)
|
|
60
78
|
})
|
|
61
79
|
|
|
@@ -66,11 +84,7 @@ All entities share the same interface.
|
|
|
66
84
|
|
|
67
85
|
| Method | Signature | Description |
|
|
68
86
|
| --- | --- | --- |
|
|
69
|
-
|
|
70
|
-
| \`list\` | \`(reqmatch, ctrl) -> (any, err)\` | List entities matching the criteria. |
|
|
71
|
-
| \`create\` | \`(reqdata, ctrl) -> (any, err)\` | Create a new entity. |
|
|
72
|
-
| \`update\` | \`(reqdata, ctrl) -> (any, err)\` | Update an existing entity. |
|
|
73
|
-
| \`remove\` | \`(reqmatch, ctrl) -> (any, err)\` | Remove an entity. |
|
|
87
|
+
${opRows}
|
|
74
88
|
| \`data_get\` | \`() -> dict\` | Get entity data. |
|
|
75
89
|
| \`data_set\` | \`(data)\` | Set entity data. |
|
|
76
90
|
| \`match_get\` | \`() -> dict\` | Get entity match criteria. |
|
|
@@ -80,8 +94,12 @@ All entities share the same interface.
|
|
|
80
94
|
|
|
81
95
|
### Result shape
|
|
82
96
|
|
|
83
|
-
Entity operations return
|
|
84
|
-
\`
|
|
97
|
+
Entity operations return the bare result data (a \`dict\` for single-entity
|
|
98
|
+
ops, a \`list\` for \`list\`) and raise on error. Wrap calls in
|
|
99
|
+
\`try\`/\`except\` to handle failures.
|
|
100
|
+
|
|
101
|
+
The \`direct()\` escape hatch never raises — it returns a result \`dict\`
|
|
102
|
+
you branch on via \`result["ok"]\`:
|
|
85
103
|
|
|
86
104
|
| Key | Type | Description |
|
|
87
105
|
| --- | --- | --- |
|
|
@@ -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 = ${model.Name}SDK({
|
|
|
25
26
|
|
|
26
27
|
publishedOptions.map((option: any) => {
|
|
27
28
|
if ('apikey' === option.name) {
|
|
28
|
-
Content(` "${option.name}": os.environ.get("${model
|
|
29
|
+
Content(` "${option.name}": os.environ.get("${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, envName, canonKey, opRequestShape, entityIdField, entityDataIdField, entityOps } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -14,59 +14,171 @@ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
|
14
14
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
15
15
|
|
|
16
16
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
17
|
+
|
|
18
|
+
// Find a nested entity if available: one with a parent chain
|
|
19
|
+
// (relations.ancestors), an active load op, and a required non-id load
|
|
20
|
+
// param to demonstrate (the parent key, e.g. page_id).
|
|
17
21
|
const nestedEntity = Object.values(entity).find((e: any) =>
|
|
18
|
-
e.active !== false &&
|
|
22
|
+
e.active !== false &&
|
|
23
|
+
e.relations && e.relations.ancestors && 0 < e.relations.ancestors.length &&
|
|
24
|
+
entityOps(e).includes('load') &&
|
|
25
|
+
opRequestShape(e, 'load').items.some((it: any) =>
|
|
26
|
+
!it.optional && it.name !== entityIdField(e))
|
|
19
27
|
) as any
|
|
20
28
|
|
|
21
29
|
const authActive = isAuthActive(model)
|
|
22
30
|
const apikeyImport = authActive ? `import os\n` : ''
|
|
23
|
-
const
|
|
24
|
-
?
|
|
25
|
-
:
|
|
31
|
+
const ctor = authActive
|
|
32
|
+
? `${model.const.Name}SDK({\n "apikey": os.environ.get("${envName(model)}_APIKEY"),\n})`
|
|
33
|
+
: `${model.const.Name}SDK()`
|
|
26
34
|
|
|
27
35
|
Content(`### 1. Create a client
|
|
28
36
|
|
|
29
37
|
\`\`\`python
|
|
30
38
|
${apikeyImport}from ${model.const.Name.toLowerCase()}_sdk import ${model.const.Name}SDK
|
|
31
39
|
|
|
32
|
-
client = ${
|
|
40
|
+
client = ${ctor}
|
|
33
41
|
\`\`\`
|
|
34
42
|
|
|
35
43
|
`)
|
|
36
44
|
|
|
37
45
|
if (exampleEntity) {
|
|
38
46
|
const eName = nom(exampleEntity, 'Name')
|
|
39
|
-
const
|
|
47
|
+
const article = /^[aeiou]/i.test(eName) ? 'an' : 'a'
|
|
48
|
+
const opnames = entityOps(exampleEntity)
|
|
49
|
+
// Model-driven id key: `idF` is the entity's id-like MATCH field name, or
|
|
50
|
+
// null when it has none (a response-wrapped spec). `dataIdF` is the id on
|
|
51
|
+
// the RETURNED record's data type — an entity can key its match on an id it
|
|
52
|
+
// does not carry as data, so indexing `created["id"]` when the data type has
|
|
53
|
+
// none is wrong (and would KeyError at runtime).
|
|
54
|
+
const idF = entityIdField(exampleEntity)
|
|
55
|
+
const dataIdF = entityDataIdField(exampleEntity)
|
|
56
|
+
|
|
57
|
+
// A type-correct, executable Python literal for a param: numeric/boolean/
|
|
58
|
+
// array/object params render a typed literal; strings render the quoted
|
|
59
|
+
// placeholder (the doc test EXECUTES these blocks, so a comment
|
|
60
|
+
// placeholder would not parse).
|
|
61
|
+
const pyLit = (type: any, placeholder: string = 'example'): string => {
|
|
62
|
+
const k = canonKey(type)
|
|
63
|
+
if ('INTEGER' === k || 'NUMBER' === k) return '1'
|
|
64
|
+
if ('BOOLEAN' === k) return 'True'
|
|
65
|
+
if ('ARRAY' === k) return '[]'
|
|
66
|
+
if ('OBJECT' === k) return '{}'
|
|
67
|
+
return `"${placeholder}"`
|
|
68
|
+
}
|
|
40
69
|
|
|
41
70
|
if (opnames.includes('list')) {
|
|
42
|
-
Content(`### 2. List ${eName.toLowerCase()}
|
|
71
|
+
Content(`### 2. List ${eName.toLowerCase()} records
|
|
72
|
+
|
|
73
|
+
\`list()\` returns a \`list\` of records (each a \`dict\`) and raises on
|
|
74
|
+
error — iterate it directly.
|
|
43
75
|
|
|
44
76
|
\`\`\`python
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
d = item.data_get()
|
|
52
|
-
print(d["id"], d["name"])
|
|
77
|
+
try:
|
|
78
|
+
${eName.toLowerCase()}s = client.${eName}().list()
|
|
79
|
+
for ${eName.toLowerCase()} in ${eName.toLowerCase()}s:
|
|
80
|
+
print(${eName.toLowerCase()})
|
|
81
|
+
except Exception as err:
|
|
82
|
+
print(f"list failed: {err}")
|
|
53
83
|
\`\`\`
|
|
54
84
|
|
|
55
85
|
`)
|
|
56
86
|
}
|
|
57
87
|
|
|
58
|
-
if (
|
|
59
|
-
|
|
88
|
+
if (nestedEntity) {
|
|
89
|
+
const neName = nom(nestedEntity, 'Name')
|
|
90
|
+
const neArticle = /^[aeiou]/i.test(neName) ? 'an' : 'a'
|
|
91
|
+
const neVar = neName.toLowerCase()
|
|
92
|
+
|
|
93
|
+
// Model-driven match: every REQUIRED load-match key — the same shape
|
|
94
|
+
// the runtime resolves path params from, so the example always works.
|
|
95
|
+
// Parent keys (e.g. page_id) first, the entity's own id last.
|
|
96
|
+
const neIdF = entityIdField(nestedEntity)
|
|
97
|
+
const neRequired = opRequestShape(nestedEntity, 'load').items
|
|
98
|
+
.filter((it: any) => !it.optional)
|
|
99
|
+
.sort((a: any, b: any) =>
|
|
100
|
+
(a.name === neIdF ? 1 : 0) - (b.name === neIdF ? 1 : 0))
|
|
101
|
+
const parentItem = neRequired.find((it: any) => it.name !== neIdF) as any
|
|
102
|
+
const parentParam = parentItem && parentItem.name
|
|
103
|
+
const parentName = parentParam ? parentParam.replace(/_id$/, '') : 'its parent'
|
|
104
|
+
const neMatch = neRequired.map((it: any) =>
|
|
105
|
+
`"${it.name}": ${pyLit(it.type,
|
|
106
|
+
it.name === neIdF ? 'example_id' : 'example_' + it.name)}`)
|
|
107
|
+
|
|
108
|
+
Content(`### 3. Load ${neArticle} ${neName.toLowerCase()}
|
|
109
|
+
|
|
110
|
+
${neName} is nested under ${parentName}, so provide the \`${parentParam}\`.
|
|
111
|
+
\`load()\` returns the bare record (a \`dict\`) and raises on error.
|
|
60
112
|
|
|
61
113
|
\`\`\`python
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
114
|
+
try:
|
|
115
|
+
${neVar} = client.${neName}().load({${neMatch.join(', ')}})
|
|
116
|
+
print(${neVar})
|
|
117
|
+
except Exception as err:
|
|
118
|
+
print(f"load failed: {err}")
|
|
66
119
|
\`\`\`
|
|
67
120
|
|
|
68
121
|
`)
|
|
69
122
|
}
|
|
123
|
+
else if (opnames.includes('load')) {
|
|
124
|
+
// Every REQUIRED load-match key (id first, then parent path params like
|
|
125
|
+
// page_id) — the same shape the runtime resolves path params from, so
|
|
126
|
+
// the example always works.
|
|
127
|
+
const loadRequired = opRequestShape(exampleEntity, 'load').items
|
|
128
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
129
|
+
.sort((a: any, b: any) =>
|
|
130
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
131
|
+
const loadArg = 0 < loadRequired.length
|
|
132
|
+
? `{${loadRequired.map((it: any) =>
|
|
133
|
+
`"${it.name}": ${pyLit(it.type,
|
|
134
|
+
it.name === idF ? 'example_id' : 'example_' + it.name)}`).join(', ')}}`
|
|
135
|
+
: ''
|
|
136
|
+
|
|
137
|
+
Content(`### 3. Load ${article} ${eName.toLowerCase()}
|
|
138
|
+
|
|
139
|
+
\`load()\` returns the bare record (a \`dict\`) and raises on error.
|
|
140
|
+
|
|
141
|
+
\`\`\`python
|
|
142
|
+
try:
|
|
143
|
+
${eName.toLowerCase()} = client.${eName}().load(${loadArg})
|
|
144
|
+
print(${eName.toLowerCase()})
|
|
145
|
+
except Exception as err:
|
|
146
|
+
print(f"load failed: {err}")
|
|
147
|
+
\`\`\`
|
|
148
|
+
|
|
149
|
+
`)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Model-driven example fields: derive the create/update body from the op
|
|
153
|
+
// shape (opRequestShape) so the docs reference REAL writable fields, not a
|
|
154
|
+
// hardcoded "name" the entity may not have. Literals are Python-typed by
|
|
155
|
+
// the field's canonical type. ids are rendered separately as the match key
|
|
156
|
+
// for update/remove; a REQUIRED create id stays (the call is invalid
|
|
157
|
+
// without it).
|
|
158
|
+
const examplePairs = (opname: string): string[] => {
|
|
159
|
+
const items = opRequestShape(exampleEntity, opname).items
|
|
160
|
+
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
161
|
+
('create' === opname && !it.optional))
|
|
162
|
+
const required = items.filter((it: any) => !it.optional)
|
|
163
|
+
const optional = items.filter((it: any) => it.optional)
|
|
164
|
+
// create needs ALL required fields; update is a patch, so the required
|
|
165
|
+
// members plus a sample optional field or two suffice.
|
|
166
|
+
const chosen = 'create' === opname
|
|
167
|
+
? (required.length ? required : items.slice(0, 2))
|
|
168
|
+
: required.concat(optional).slice(0, Math.max(2, required.length))
|
|
169
|
+
return chosen.map((it: any) => `"${it.name}": ${pyLit(it.type, 'example_' + it.name)}`)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// The id VALUE for an update/remove match: taken off the returned `created`
|
|
173
|
+
// record only when its data type carries the id AND a create ran; otherwise
|
|
174
|
+
// a type-correct literal.
|
|
175
|
+
const idParamType = (opname: string): any => {
|
|
176
|
+
const it = opRequestShape(exampleEntity, opname).items.find((x: any) => x.name === idF)
|
|
177
|
+
return it && it.type
|
|
178
|
+
}
|
|
179
|
+
const idValueFor = (opname: string): string => (null != dataIdF && opnames.includes('create'))
|
|
180
|
+
? `created["${dataIdF}"]`
|
|
181
|
+
: pyLit(idParamType(opname), 'example_id')
|
|
70
182
|
|
|
71
183
|
if (opnames.includes('create') || opnames.includes('update') || opnames.includes('remove')) {
|
|
72
184
|
Content(`### 4. Create, update, and remove
|
|
@@ -74,20 +186,31 @@ print(result)
|
|
|
74
186
|
\`\`\`python
|
|
75
187
|
`)
|
|
76
188
|
if (opnames.includes('create')) {
|
|
77
|
-
Content(`# Create
|
|
78
|
-
created
|
|
189
|
+
Content(`# Create — returns the bare created record (a dict)
|
|
190
|
+
created = client.${eName}().create({${examplePairs('create').join(', ')}})
|
|
79
191
|
|
|
80
192
|
`)
|
|
81
193
|
}
|
|
82
194
|
if (opnames.includes('update')) {
|
|
83
|
-
|
|
84
|
-
|
|
195
|
+
const updatePairs = (idF ? [`"${idF}": ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
196
|
+
const fromCreated = null != dataIdF && opnames.includes('create')
|
|
197
|
+
Content(`# Update${fromCreated ? " — the created record's id is a plain dict key" : ''}
|
|
198
|
+
client.${eName}().update({${updatePairs.join(', ')}})
|
|
85
199
|
|
|
86
200
|
`)
|
|
87
201
|
}
|
|
88
202
|
if (opnames.includes('remove')) {
|
|
203
|
+
// Every REQUIRED remove-match key: the id (off the created record
|
|
204
|
+
// when possible) plus parent keys like page_id.
|
|
205
|
+
const removePairs = opRequestShape(exampleEntity, 'remove').items
|
|
206
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
207
|
+
.sort((a: any, b: any) =>
|
|
208
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
209
|
+
.map((it: any) => it.name === idF
|
|
210
|
+
? `"${it.name}": ${idValueFor('remove')}`
|
|
211
|
+
: `"${it.name}": ${pyLit(it.type, 'example_' + it.name)}`)
|
|
89
212
|
Content(`# Remove
|
|
90
|
-
client.${eName}(
|
|
213
|
+
client.${eName}().remove(${removePairs.length ? `{${removePairs.join(', ')}}` : ''})
|
|
91
214
|
`)
|
|
92
215
|
}
|
|
93
216
|
Content(`\`\`\`
|