@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,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 = new ${model.Name}SDK([
|
|
|
25
26
|
|
|
26
27
|
publishedOptions.map((option: any) => {
|
|
27
28
|
if ('apikey' === option.name) {
|
|
28
|
-
Content(` "${option.name}" => getenv("${model
|
|
29
|
+
Content(` "${option.name}" => getenv("${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,13 +14,21 @@ 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
|
-
const
|
|
22
|
-
?
|
|
23
|
-
:
|
|
29
|
+
const ctor = isAuthActive(model)
|
|
30
|
+
? `new ${model.const.Name}SDK([\n "apikey" => getenv("${envName(model)}_APIKEY"),\n])`
|
|
31
|
+
: `new ${model.const.Name}SDK()`
|
|
24
32
|
|
|
25
33
|
Content(`### 1. Create a client
|
|
26
34
|
|
|
@@ -28,65 +36,191 @@ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
|
28
36
|
<?php
|
|
29
37
|
require_once '${model.const.Name.toLowerCase()}_sdk.php';
|
|
30
38
|
|
|
31
|
-
$client =
|
|
39
|
+
$client = ${ctor};
|
|
32
40
|
\`\`\`
|
|
33
41
|
|
|
34
42
|
`)
|
|
35
43
|
|
|
36
44
|
if (exampleEntity) {
|
|
37
45
|
const eName = nom(exampleEntity, 'Name')
|
|
38
|
-
const
|
|
46
|
+
const article = /^[aeiou]/i.test(eName) ? "an" : "a"
|
|
47
|
+
const opnames = entityOps(exampleEntity)
|
|
48
|
+
// Model-driven id key: `idF` is the MATCH key (null when none). `dataIdF` is
|
|
49
|
+
// the id on the RETURNED record's data type — an entity can key its match on
|
|
50
|
+
// an id it does not carry as data, so `["id"]` off a returned record must be
|
|
51
|
+
// guarded on this, not the match key.
|
|
52
|
+
const idF = entityIdField(exampleEntity)
|
|
53
|
+
const dataIdF = entityDataIdField(exampleEntity)
|
|
54
|
+
|
|
55
|
+
// A type-correct, executable PHP literal for a param: numeric/boolean/
|
|
56
|
+
// array params render a typed literal; strings render the quoted
|
|
57
|
+
// placeholder (the doc test EXECUTES these blocks, so a comment
|
|
58
|
+
// placeholder would not parse).
|
|
59
|
+
const phpLit = (type: any, placeholder: string = 'example'): string => {
|
|
60
|
+
const k = canonKey(type)
|
|
61
|
+
if ('INTEGER' === k || 'NUMBER' === k) return '1'
|
|
62
|
+
if ('BOOLEAN' === k) return 'true'
|
|
63
|
+
if ('ARRAY' === k || 'OBJECT' === k) return '[]'
|
|
64
|
+
return `"${placeholder}"`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Model-driven display field: the entity's first non-id string field
|
|
68
|
+
// (falling back to any non-id field), so the list example prints a real
|
|
69
|
+
// column instead of a hardcoded "name" the entity may not have.
|
|
70
|
+
const fields = exampleEntity.fields || []
|
|
71
|
+
const displayField =
|
|
72
|
+
fields.find((f: any) => f && f.name !== 'id' && f.type === '$STRING') ||
|
|
73
|
+
fields.find((f: any) => f && f.name !== 'id') ||
|
|
74
|
+
null
|
|
75
|
+
const idCol = dataIdF ? `$item[${JSON.stringify(dataIdF)}]` : null
|
|
76
|
+
const dispCol = displayField ? `$item[${JSON.stringify(displayField.name)}]` : null
|
|
77
|
+
const itemPrint = [idCol, dispCol].filter(Boolean).join(' . " " . ') || 'json_encode($item)'
|
|
39
78
|
|
|
40
79
|
if (opnames.includes('list')) {
|
|
41
|
-
Content(`### 2. List ${eName.toLowerCase()}
|
|
80
|
+
Content(`### 2. List ${eName.toLowerCase()} records
|
|
42
81
|
|
|
43
82
|
\`\`\`php
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
$d = $item->data_get();
|
|
50
|
-
echo $d["id"] . " " . $d["name"] . "\\n";
|
|
83
|
+
try {
|
|
84
|
+
// list() returns an array of ${eName} records — iterate directly.
|
|
85
|
+
$${eName.toLowerCase()}s = $client->${eName}()->list();
|
|
86
|
+
foreach ($${eName.toLowerCase()}s as $item) {
|
|
87
|
+
echo ${itemPrint} . "\\n";
|
|
51
88
|
}
|
|
89
|
+
} catch (\\Throwable $err) {
|
|
90
|
+
echo "Error: " . $err->getMessage();
|
|
52
91
|
}
|
|
53
92
|
\`\`\`
|
|
54
93
|
|
|
55
94
|
`)
|
|
56
95
|
}
|
|
57
96
|
|
|
58
|
-
if (
|
|
59
|
-
|
|
97
|
+
if (nestedEntity) {
|
|
98
|
+
const neName = nom(nestedEntity, 'Name')
|
|
99
|
+
const neArticle = /^[aeiou]/i.test(neName) ? "an" : "a"
|
|
100
|
+
const neVar = neName.toLowerCase()
|
|
101
|
+
|
|
102
|
+
// Model-driven match: every REQUIRED load-match key — the same shape
|
|
103
|
+
// the runtime resolves path params from, so the example always works.
|
|
104
|
+
// Parent keys (e.g. page_id) first, the entity's own id last.
|
|
105
|
+
const neIdF = entityIdField(nestedEntity)
|
|
106
|
+
const neRequired = opRequestShape(nestedEntity, 'load').items
|
|
107
|
+
.filter((it: any) => !it.optional)
|
|
108
|
+
.sort((a: any, b: any) =>
|
|
109
|
+
(a.name === neIdF ? 1 : 0) - (b.name === neIdF ? 1 : 0))
|
|
110
|
+
const parentItem = neRequired.find((it: any) => it.name !== neIdF) as any
|
|
111
|
+
const parentParam = parentItem && parentItem.name
|
|
112
|
+
const parentName = parentParam ? parentParam.replace(/_id$/, '') : 'its parent'
|
|
113
|
+
const neMatch = neRequired.map((it: any) =>
|
|
114
|
+
`"${it.name}" => ${phpLit(it.type,
|
|
115
|
+
it.name === neIdF ? 'example_id' : 'example_' + it.name)}`)
|
|
116
|
+
|
|
117
|
+
Content(`### 3. Load ${neArticle} ${neName.toLowerCase()}
|
|
118
|
+
|
|
119
|
+
${neName} is nested under ${parentName}, so provide the \`${parentParam}\`.
|
|
120
|
+
|
|
121
|
+
\`\`\`php
|
|
122
|
+
try {
|
|
123
|
+
// load() returns the bare ${neName} record (throws on error).
|
|
124
|
+
$${neVar} = $client->${neName}()->load([${neMatch.join(', ')}]);
|
|
125
|
+
print_r($${neVar});
|
|
126
|
+
} catch (\\Throwable $err) {
|
|
127
|
+
echo "Error: " . $err->getMessage();
|
|
128
|
+
}
|
|
129
|
+
\`\`\`
|
|
130
|
+
|
|
131
|
+
`)
|
|
132
|
+
}
|
|
133
|
+
else if (opnames.includes('load')) {
|
|
134
|
+
// Every REQUIRED load-match key (id first, then parent path params like
|
|
135
|
+
// page_id) — the same shape the runtime resolves path params from, so
|
|
136
|
+
// the example always works.
|
|
137
|
+
const loadRequired = opRequestShape(exampleEntity, 'load').items
|
|
138
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
139
|
+
.sort((a: any, b: any) =>
|
|
140
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
141
|
+
const loadArg = 0 < loadRequired.length
|
|
142
|
+
? `[${loadRequired.map((it: any) =>
|
|
143
|
+
`"${it.name}" => ${phpLit(it.type,
|
|
144
|
+
it.name === idF ? 'example_id' : 'example_' + it.name)}`).join(', ')}]`
|
|
145
|
+
: ''
|
|
146
|
+
|
|
147
|
+
Content(`### 3. Load ${article} ${eName.toLowerCase()}
|
|
60
148
|
|
|
61
149
|
\`\`\`php
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
150
|
+
try {
|
|
151
|
+
// load() returns the bare ${eName} record (throws on error).
|
|
152
|
+
$${eName.toLowerCase()} = $client->${eName}()->load(${loadArg});
|
|
153
|
+
print_r($${eName.toLowerCase()});
|
|
154
|
+
} catch (\\Throwable $err) {
|
|
155
|
+
echo "Error: " . $err->getMessage();
|
|
156
|
+
}
|
|
65
157
|
\`\`\`
|
|
66
158
|
|
|
67
159
|
`)
|
|
68
160
|
}
|
|
69
161
|
|
|
162
|
+
// Model-driven example fields: derive the create/update body from the op
|
|
163
|
+
// shape (opRequestShape) so the docs reference REAL writable fields, not a
|
|
164
|
+
// hardcoded "name" the entity may not have. Literals are PHP-typed by the
|
|
165
|
+
// field's canonical type. ids are rendered separately as the match key for
|
|
166
|
+
// update/remove; a REQUIRED create id stays (the call is invalid without
|
|
167
|
+
// it).
|
|
168
|
+
const examplePairs = (opname: string): string[] => {
|
|
169
|
+
const items = opRequestShape(exampleEntity, opname).items
|
|
170
|
+
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
171
|
+
('create' === opname && !it.optional))
|
|
172
|
+
const required = items.filter((it: any) => !it.optional)
|
|
173
|
+
const optional = items.filter((it: any) => it.optional)
|
|
174
|
+
// create needs ALL required fields; update is a patch, so the required
|
|
175
|
+
// members plus a sample optional field or two suffice.
|
|
176
|
+
const chosen = 'create' === opname
|
|
177
|
+
? (required.length ? required : items.slice(0, 2))
|
|
178
|
+
: required.concat(optional).slice(0, Math.max(2, required.length))
|
|
179
|
+
return chosen.map((it: any) => `"${it.name}" => ${phpLit(it.type, 'example_' + it.name)}`)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// The id VALUE for an update/remove match: off the returned `$created`
|
|
183
|
+
// record only when its data type carries the id AND a create ran, else a
|
|
184
|
+
// type-correct literal.
|
|
185
|
+
const idParamType = (opname: string): any => {
|
|
186
|
+
const it = opRequestShape(exampleEntity, opname).items.find((x: any) => x.name === idF)
|
|
187
|
+
return it && it.type
|
|
188
|
+
}
|
|
189
|
+
const idValueFor = (opname: string): string => (null != dataIdF && opnames.includes('create'))
|
|
190
|
+
? `$created["${dataIdF}"]`
|
|
191
|
+
: phpLit(idParamType(opname), 'example_id')
|
|
192
|
+
|
|
70
193
|
if (opnames.includes('create') || opnames.includes('update') || opnames.includes('remove')) {
|
|
71
194
|
Content(`### 4. Create, update, and remove
|
|
72
195
|
|
|
73
196
|
\`\`\`php
|
|
74
197
|
`)
|
|
75
198
|
if (opnames.includes('create')) {
|
|
76
|
-
Content(`//
|
|
77
|
-
|
|
199
|
+
Content(`// create() returns the bare created ${eName} record.
|
|
200
|
+
$created = $client->${eName}()->create([${examplePairs('create').join(', ')}]);
|
|
78
201
|
|
|
79
202
|
`)
|
|
80
203
|
}
|
|
81
204
|
if (opnames.includes('update')) {
|
|
82
|
-
|
|
83
|
-
|
|
205
|
+
const updatePairs = (idF ? [`"${idF}" => ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
206
|
+
const fromCreated = null != dataIdF && opnames.includes('create')
|
|
207
|
+
Content(`// Update${fromCreated ? ` — index the bare record directly ($created["${dataIdF}"]).` : ''}
|
|
208
|
+
$client->${eName}()->update([${updatePairs.join(', ')}]);
|
|
84
209
|
|
|
85
210
|
`)
|
|
86
211
|
}
|
|
87
212
|
if (opnames.includes('remove')) {
|
|
213
|
+
// Every REQUIRED remove-match key: the id (off the created record
|
|
214
|
+
// when possible) plus parent keys like page_id.
|
|
215
|
+
const removePairs = opRequestShape(exampleEntity, 'remove').items
|
|
216
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
217
|
+
.sort((a: any, b: any) =>
|
|
218
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
219
|
+
.map((it: any) => it.name === idF
|
|
220
|
+
? `"${it.name}" => ${idValueFor('remove')}`
|
|
221
|
+
: `"${it.name}" => ${phpLit(it.type, 'example_' + it.name)}`)
|
|
88
222
|
Content(`// Remove
|
|
89
|
-
$client->${eName}(
|
|
223
|
+
$client->${eName}()->remove(${removePairs.length ? `[${removePairs.join(', ')}]` : ''});
|
|
90
224
|
`)
|
|
91
225
|
}
|
|
92
226
|
Content(`\`\`\`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, File, isAuthActive } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, each, Content, canonToType, canonKey, File, isAuthActive, entityIdField, opRequestShape } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -7,31 +7,44 @@ import {
|
|
|
7
7
|
} from '@voxgig/apidef'
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
// A type-correct, executable PHP literal for a param: numeric/boolean/array
|
|
11
|
+
// params render a typed literal; strings render the quoted placeholder (the
|
|
12
|
+
// doc test EXECUTES runnable blocks, so a comment placeholder would not
|
|
13
|
+
// parse).
|
|
14
|
+
function phpLit(type: any, placeholder: string = 'example'): string {
|
|
15
|
+
const k = canonKey(type)
|
|
16
|
+
if ('INTEGER' === k || 'NUMBER' === k) return '1'
|
|
17
|
+
if ('BOOLEAN' === k) return 'true'
|
|
18
|
+
if ('ARRAY' === k || 'OBJECT' === k) return '[]'
|
|
19
|
+
return `"${placeholder}"`
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
10
23
|
const OP_SIGNATURES: Record<string, { sig: string, returns: string, desc: string }> = {
|
|
11
24
|
load: {
|
|
12
|
-
sig: 'load(array $reqmatch, ?array $ctrl = null):
|
|
13
|
-
returns: '
|
|
14
|
-
desc: 'Load a single entity matching the given criteria.',
|
|
25
|
+
sig: 'load(array $reqmatch, ?array $ctrl = null): mixed',
|
|
26
|
+
returns: 'mixed — the result data; throws on error',
|
|
27
|
+
desc: 'Load a single entity matching the given criteria. Throws on error.',
|
|
15
28
|
},
|
|
16
29
|
list: {
|
|
17
|
-
sig: 'list(array $reqmatch, ?array $ctrl = null):
|
|
18
|
-
returns: 'array
|
|
19
|
-
desc: 'List entities matching the given criteria. Returns an array.',
|
|
30
|
+
sig: 'list(?array $reqmatch = null, ?array $ctrl = null): mixed',
|
|
31
|
+
returns: 'array — the list of results; throws on error',
|
|
32
|
+
desc: 'List entities matching the given criteria (call with no argument to list all). Returns an array. Throws on error.',
|
|
20
33
|
},
|
|
21
34
|
create: {
|
|
22
|
-
sig: 'create(array $reqdata, ?array $ctrl = null):
|
|
23
|
-
returns: '
|
|
24
|
-
desc: 'Create a new entity with the given data.',
|
|
35
|
+
sig: 'create(array $reqdata, ?array $ctrl = null): mixed',
|
|
36
|
+
returns: 'mixed — the result data; throws on error',
|
|
37
|
+
desc: 'Create a new entity with the given data. Throws on error.',
|
|
25
38
|
},
|
|
26
39
|
update: {
|
|
27
|
-
sig: 'update(array $reqdata, ?array $ctrl = null):
|
|
28
|
-
returns: '
|
|
29
|
-
desc: 'Update an existing entity. The data must include the entity `id`.',
|
|
40
|
+
sig: 'update(array $reqdata, ?array $ctrl = null): mixed',
|
|
41
|
+
returns: 'mixed — the result data; throws on error',
|
|
42
|
+
desc: 'Update an existing entity. The data must include the entity `id`. Throws on error.',
|
|
30
43
|
},
|
|
31
44
|
remove: {
|
|
32
|
-
sig: 'remove(array $reqmatch, ?array $ctrl = null):
|
|
33
|
-
returns: '
|
|
34
|
-
desc: 'Remove the entity matching the given criteria.',
|
|
45
|
+
sig: 'remove(array $reqmatch, ?array $ctrl = null): mixed',
|
|
46
|
+
returns: 'mixed — the result data; throws on error',
|
|
47
|
+
desc: 'Remove the entity matching the given criteria. Throws on error.',
|
|
35
48
|
},
|
|
36
49
|
}
|
|
37
50
|
|
|
@@ -60,7 +73,7 @@ Complete API reference for the ${model.Name} ${target.title} SDK.
|
|
|
60
73
|
`)
|
|
61
74
|
|
|
62
75
|
Content(`\`\`\`php
|
|
63
|
-
require_once __DIR__ . '/${model.
|
|
76
|
+
require_once __DIR__ . '/${model.const.Name.toLowerCase()}_sdk.php';
|
|
64
77
|
|
|
65
78
|
$client = new ${model.const.Name}SDK($options);
|
|
66
79
|
\`\`\`
|
|
@@ -72,8 +85,7 @@ Create a new SDK client instance.
|
|
|
72
85
|
| Name | Type | Description |
|
|
73
86
|
| --- | --- | --- |
|
|
74
87
|
| \`$options\` | \`array\` | SDK configuration options. |
|
|
75
|
-
| \`$options["apikey"]\` | \`string\` | API key for authentication. |
|
|
76
|
-
| \`$options["base"]\` | \`string\` | Base URL for API requests. |
|
|
88
|
+
${isAuthActive(model) ? '| \`$options["apikey"]\` | \`string\` | API key for authentication. |\n' : ''}| \`$options["base"]\` | \`string\` | Base URL for API requests. |
|
|
77
89
|
| \`$options["prefix"]\` | \`string\` | URL prefix appended after base. |
|
|
78
90
|
| \`$options["suffix"]\` | \`string\` | URL suffix appended after path. |
|
|
79
91
|
| \`$options["headers"]\` | \`array\` | Custom headers for all requests. |
|
|
@@ -115,17 +127,20 @@ Create a new \`${ent.Name}Entity\` instance. Pass \`null\` for no initial data.
|
|
|
115
127
|
})
|
|
116
128
|
|
|
117
129
|
|
|
118
|
-
Content(`#### \`
|
|
130
|
+
Content(`#### \`options_map(): array\`
|
|
119
131
|
|
|
120
132
|
Return a deep copy of the current SDK options.
|
|
121
133
|
|
|
122
|
-
#### \`
|
|
134
|
+
#### \`get_utility(): ${model.const.Name}Utility\`
|
|
123
135
|
|
|
124
136
|
Return a copy of the SDK utility object.
|
|
125
137
|
|
|
126
138
|
#### \`direct(array $fetchargs = []): array\`
|
|
127
139
|
|
|
128
|
-
Make a direct HTTP request to any API endpoint.
|
|
140
|
+
Make a direct HTTP request to any API endpoint. This is the raw-HTTP escape
|
|
141
|
+
hatch: it does **not** throw. It returns a result array
|
|
142
|
+
\`["ok" => bool, "status" => int, "headers" => array, "data" => mixed]\`, or
|
|
143
|
+
\`["ok" => false, "err" => \\Exception]\` on failure. Branch on \`$result["ok"]\`.
|
|
129
144
|
|
|
130
145
|
**Parameters:**
|
|
131
146
|
|
|
@@ -139,11 +154,12 @@ Make a direct HTTP request to any API endpoint. Returns \`[$result, $err]\`.
|
|
|
139
154
|
| \`$fetchargs["body"]\` | \`mixed\` | Request body (arrays are JSON-serialized). |
|
|
140
155
|
| \`$fetchargs["ctrl"]\` | \`array\` | Control options. |
|
|
141
156
|
|
|
142
|
-
**Returns:** \`array
|
|
157
|
+
**Returns:** \`array\` — the result dict (see above); never throws.
|
|
143
158
|
|
|
144
|
-
#### \`prepare(array $fetchargs = []):
|
|
159
|
+
#### \`prepare(array $fetchargs = []): mixed\`
|
|
145
160
|
|
|
146
|
-
Prepare a fetch definition without sending the request. Returns
|
|
161
|
+
Prepare a fetch definition without sending the request. Returns the
|
|
162
|
+
\`$fetchdef\` array. Throws on error.
|
|
147
163
|
|
|
148
164
|
`)
|
|
149
165
|
|
|
@@ -152,6 +168,9 @@ Prepare a fetch definition without sending the request. Returns \`[$fetchdef, $e
|
|
|
152
168
|
publishedEntities.map((ent: any) => {
|
|
153
169
|
const opnames = Object.keys(ent.op || {})
|
|
154
170
|
const fields = ent.fields || []
|
|
171
|
+
// Model-driven id key: null when this entity has no id-like field, in
|
|
172
|
+
// which case load/remove match on no argument and update omits the id.
|
|
173
|
+
const idF = entityIdField(ent)
|
|
155
174
|
|
|
156
175
|
Content(`
|
|
157
176
|
---
|
|
@@ -183,7 +202,7 @@ $${ent.name} = $client->${ent.Name}();
|
|
|
183
202
|
each(fields, (field: any) => {
|
|
184
203
|
const req = field.req ? 'Yes' : 'No'
|
|
185
204
|
const desc = field.short || ''
|
|
186
|
-
Content(`| \`${field.name}\` | \`${field.type
|
|
205
|
+
Content(`| \`${field.name}\` | \`${canonToType(field.type, target.name)}\` | ${req} | ${desc} |
|
|
187
206
|
`)
|
|
188
207
|
})
|
|
189
208
|
|
|
@@ -193,15 +212,18 @@ $${ent.name} = $client->${ent.Name}();
|
|
|
193
212
|
// Field operations breakdown
|
|
194
213
|
const hasFieldOps = fields.some((f: any) => f.op && Object.keys(f.op).length > 0)
|
|
195
214
|
if (hasFieldOps) {
|
|
215
|
+
// Only emit columns for operations this entity actually exposes —
|
|
216
|
+
// never advertise a create/update/remove column the entity lacks.
|
|
217
|
+
const opcols = ['load', 'list', 'create', 'update', 'remove']
|
|
218
|
+
.filter((op: string) => opnames.includes(op) && ent.op[op]?.active !== false)
|
|
196
219
|
Content(`### Field Usage by Operation
|
|
197
220
|
|
|
198
|
-
| Field |
|
|
199
|
-
| --- |
|
|
221
|
+
| Field | ${opcols.join(' | ')} |
|
|
222
|
+
| --- | ${opcols.map(() => '---').join(' | ')} |
|
|
200
223
|
`)
|
|
201
224
|
each(fields, (field: any) => {
|
|
202
225
|
const fops = field.op || {}
|
|
203
|
-
const cols =
|
|
204
|
-
if (!opnames.includes(op)) return '-'
|
|
226
|
+
const cols = opcols.map((op: string) => {
|
|
205
227
|
const fop = fops[op]
|
|
206
228
|
if (null == fop) return '-'
|
|
207
229
|
if (fop.active === false) return '-'
|
|
@@ -235,28 +257,43 @@ ${info.desc}
|
|
|
235
257
|
|
|
236
258
|
// Show example
|
|
237
259
|
if ('load' === opname || 'remove' === opname) {
|
|
260
|
+
// The id key plus every REQUIRED match key (parent path params
|
|
261
|
+
// like page_id) — the same shape the runtime resolves path
|
|
262
|
+
// params from, so the example always works.
|
|
263
|
+
const matchItems = opRequestShape(ent, opname).items
|
|
264
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
265
|
+
.sort((a: any, b: any) =>
|
|
266
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
267
|
+
const arg = 0 < matchItems.length
|
|
268
|
+
? `[${matchItems.map((it: any) =>
|
|
269
|
+
`"${it.name}" => ${phpLit(it.type,
|
|
270
|
+
it.name === idF ? ent.name + '_id' : it.name)}`).join(', ')}]`
|
|
271
|
+
: ''
|
|
238
272
|
Content(`\`\`\`php
|
|
239
|
-
|
|
273
|
+
$result = $client->${ent.Name}()->${opname}(${arg});
|
|
240
274
|
\`\`\`
|
|
241
275
|
|
|
242
276
|
`)
|
|
243
277
|
}
|
|
244
278
|
else if ('list' === opname) {
|
|
245
279
|
Content(`\`\`\`php
|
|
246
|
-
|
|
280
|
+
$results = $client->${ent.Name}()->list();
|
|
247
281
|
\`\`\`
|
|
248
282
|
|
|
249
283
|
`)
|
|
250
284
|
}
|
|
251
285
|
else if ('create' === opname) {
|
|
286
|
+
// Members come from the SAME shape the runtime validates
|
|
287
|
+
// (opRequestShape): every required member must appear — including
|
|
288
|
+
// a required id and parent keys like page_id.
|
|
289
|
+
const createItems = opRequestShape(ent, 'create').items
|
|
290
|
+
.filter((it: any) => !it.optional)
|
|
252
291
|
Content(`\`\`\`php
|
|
253
|
-
|
|
292
|
+
$result = $client->${ent.Name}()->create([
|
|
254
293
|
`)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
Content(` "${field.name}" => /* ${field.type || 'value'} */,
|
|
294
|
+
createItems.map((it: any) => {
|
|
295
|
+
Content(` "${it.name}" => null, // ${canonToType(it.type, target.name)}
|
|
258
296
|
`)
|
|
259
|
-
}
|
|
260
297
|
})
|
|
261
298
|
Content(`]);
|
|
262
299
|
\`\`\`
|
|
@@ -264,10 +301,18 @@ ${info.desc}
|
|
|
264
301
|
`)
|
|
265
302
|
}
|
|
266
303
|
else if ('update' === opname) {
|
|
304
|
+
// The id key plus every REQUIRED data member — the same shape the
|
|
305
|
+
// runtime validates — then the patch-fields note.
|
|
306
|
+
const updateItems = opRequestShape(ent, 'update').items
|
|
307
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
308
|
+
.sort((a: any, b: any) =>
|
|
309
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
310
|
+
const updateLines = updateItems.map((it: any) =>
|
|
311
|
+
` "${it.name}" => ${phpLit(it.type,
|
|
312
|
+
it.name === idF ? ent.name + '_id' : it.name)},\n`).join('')
|
|
267
313
|
Content(`\`\`\`php
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
// Fields to update
|
|
314
|
+
$result = $client->${ent.Name}()->update([
|
|
315
|
+
${updateLines} // Fields to update
|
|
271
316
|
]);
|
|
272
317
|
\`\`\`
|
|
273
318
|
|
|
@@ -280,19 +325,19 @@ ${info.desc}
|
|
|
280
325
|
// Common methods
|
|
281
326
|
Content(`### Common Methods
|
|
282
327
|
|
|
283
|
-
#### \`
|
|
328
|
+
#### \`data_get(): array\`
|
|
284
329
|
|
|
285
330
|
Get the entity data. Returns a copy of the current data.
|
|
286
331
|
|
|
287
|
-
#### \`
|
|
332
|
+
#### \`data_set($data): void\`
|
|
288
333
|
|
|
289
334
|
Set the entity data.
|
|
290
335
|
|
|
291
|
-
#### \`
|
|
336
|
+
#### \`match_get(): array\`
|
|
292
337
|
|
|
293
338
|
Get the entity match criteria.
|
|
294
339
|
|
|
295
|
-
#### \`
|
|
340
|
+
#### \`match_set($match): void\`
|
|
296
341
|
|
|
297
342
|
Set the entity match criteria.
|
|
298
343
|
|
|
@@ -301,7 +346,7 @@ Set the entity match criteria.
|
|
|
301
346
|
Create a new \`${ent.Name}Entity\` instance with the same client and
|
|
302
347
|
options.
|
|
303
348
|
|
|
304
|
-
#### \`
|
|
349
|
+
#### \`get_name(): string\`
|
|
305
350
|
|
|
306
351
|
Return the entity name.
|
|
307
352
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, canonKey, entityIdField, opRequestShape } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -8,6 +8,18 @@ import {
|
|
|
8
8
|
} from '@voxgig/apidef'
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
// A type-correct, executable PHP literal for a param: numeric/boolean/array
|
|
12
|
+
// params render a typed literal; strings render the quoted placeholder (the
|
|
13
|
+
// doc test EXECUTES this block, so a comment placeholder would break it).
|
|
14
|
+
function phpLit(type: any, placeholder: string = 'example'): string {
|
|
15
|
+
const k = canonKey(type)
|
|
16
|
+
if ('INTEGER' === k || 'NUMBER' === k) return '1'
|
|
17
|
+
if ('BOOLEAN' === k) return 'true'
|
|
18
|
+
if ('ARRAY' === k || 'OBJECT' === k) return '[]'
|
|
19
|
+
return `"${placeholder}"`
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
11
23
|
const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
12
24
|
const { target, ctx$: { model } } = props
|
|
13
25
|
|
|
@@ -15,35 +27,55 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
|
15
27
|
|
|
16
28
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
17
29
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
const authActive = isAuthActive(model)
|
|
31
|
+
const ctor = authActive
|
|
32
|
+
? `new ${model.const.Name}SDK([\n "apikey" => getenv("${envName(model)}_APIKEY"),\n])`
|
|
33
|
+
: `new ${model.const.Name}SDK()`
|
|
21
34
|
|
|
22
35
|
Content(`\`\`\`php
|
|
23
36
|
<?php
|
|
24
37
|
require_once '${model.const.Name.toLowerCase()}_sdk.php';
|
|
25
38
|
|
|
26
|
-
$client =
|
|
39
|
+
$client = ${ctor};
|
|
27
40
|
|
|
28
41
|
`)
|
|
29
42
|
|
|
30
43
|
if (exampleEntity) {
|
|
31
44
|
const eName = nom(exampleEntity, 'Name')
|
|
32
45
|
const opnames = Object.keys(exampleEntity.op || {})
|
|
46
|
+
// Model-driven id key: null when the entity has no id-like field, in which
|
|
47
|
+
// case the load example takes no match argument.
|
|
48
|
+
const idF = entityIdField(exampleEntity)
|
|
49
|
+
|
|
50
|
+
let hasCall = false
|
|
33
51
|
|
|
34
52
|
if (opnames.includes('list')) {
|
|
35
|
-
Content(`// List all ${eName.toLowerCase()}s
|
|
36
|
-
|
|
53
|
+
Content(`// List all ${eName.toLowerCase()}s (returns an array; throws on error)
|
|
54
|
+
$${eName.toLowerCase()}s = $client->${eName}()->list();
|
|
55
|
+
print_r($${eName.toLowerCase()}s);
|
|
37
56
|
`)
|
|
57
|
+
hasCall = true
|
|
38
58
|
}
|
|
39
59
|
|
|
40
60
|
if (opnames.includes('load')) {
|
|
61
|
+
// Every REQUIRED load-match key (id first, then parent path params like
|
|
62
|
+
// page_id) — the same shape the runtime resolves path params from, so
|
|
63
|
+
// the example always works.
|
|
64
|
+
const loadItems = opRequestShape(exampleEntity, 'load').items
|
|
65
|
+
.filter((it: any) => !it.optional || it.name === idF)
|
|
66
|
+
.sort((a: any, b: any) =>
|
|
67
|
+
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
68
|
+
const loadArg = 0 < loadItems.length
|
|
69
|
+
? `[${loadItems.map((it: any) =>
|
|
70
|
+
`"${it.name}" => ${phpLit(it.type,
|
|
71
|
+
it.name === idF ? 'example_id' : 'example_' + it.name)}`).join(', ')}]`
|
|
72
|
+
: ''
|
|
41
73
|
Content(`
|
|
42
|
-
// Load a specific ${eName.toLowerCase()}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
);
|
|
74
|
+
// Load a specific ${eName.toLowerCase()} (returns the bare record; throws on error)
|
|
75
|
+
$${eName.toLowerCase()} = $client->${eName}()->load(${loadArg});
|
|
76
|
+
print_r($${eName.toLowerCase()});
|
|
46
77
|
`)
|
|
78
|
+
hasCall = true
|
|
47
79
|
}
|
|
48
80
|
}
|
|
49
81
|
|