@voxgig/sdkgen 1.2.0 → 1.3.1
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 +2 -1
- package/dist/action/action.js +15 -9
- package/dist/action/action.js.map +1 -1
- package/dist/action/feature.js +6 -3
- package/dist/action/feature.js.map +1 -1
- package/dist/action/target.d.ts +7 -1
- package/dist/action/target.js +13 -6
- 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 +193 -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 +11 -1
- package/dist/sdkgen.js +57 -18
- 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.js +20 -11
- package/dist/utility.js.map +1 -1
- package/model/sdkgen.aontu +137 -0
- package/package.json +13 -6
- package/project/.sdk/model/target/go-cli.jsonic +47 -0
- package/project/.sdk/model/target/go-mcp.jsonic +41 -0
- package/project/.sdk/model/target/go.jsonic +9 -3
- package/project/.sdk/model/target/js.jsonic +13 -0
- package/project/.sdk/model/target/lua.jsonic +13 -0
- package/project/.sdk/model/target/php.jsonic +13 -0
- package/project/.sdk/model/target/py.jsonic +13 -0
- package/project/.sdk/model/target/rb.jsonic +13 -0
- package/project/.sdk/model/target/ts.jsonic +13 -0
- 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 +18 -6
- package/project/.sdk/src/cmp/go/ReadmeExamplesTest_go.ts +684 -0
- package/project/.sdk/src/cmp/go/ReadmeExplanation_go.ts +1 -1
- package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +48 -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 +63 -17
- package/project/.sdk/src/cmp/go/ReadmeOptions_go.ts +4 -3
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +124 -115
- package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +28 -15
- package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +33 -9
- 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-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/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 +13 -7
- 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 +45 -19
- package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +24 -13
- package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +3 -0
- package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +28 -12
- package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +23 -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/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 +12 -10
- 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 +79 -18
- package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +25 -20
- package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +17 -9
- package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +32 -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/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 +15 -11
- 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 +80 -22
- package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +51 -42
- package/project/.sdk/src/cmp/php/ReadmeTopHowto_php.ts +1 -1
- package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +19 -11
- package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +41 -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/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 +27 -11
- 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 +73 -24
- package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +57 -37
- package/project/.sdk/src/cmp/py/ReadmeTopHowto_py.ts +1 -1
- package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +19 -11
- package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +30 -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/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 +26 -10
- 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 +85 -22
- package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +56 -37
- package/project/.sdk/src/cmp/rb/ReadmeTopHowto_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +19 -11
- package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +43 -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/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 +13 -7
- 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 +95 -40
- package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +24 -13
- package/project/.sdk/src/cmp/ts/ReadmeTopHowto_ts.ts +3 -0
- package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +44 -12
- package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +23 -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/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 +33 -1
- 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 +17 -10
- package/src/action/feature.ts +8 -6
- package/src/action/target.ts +17 -8
- 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 +236 -0
- package/src/helpers/packageMeta.ts +236 -0
- package/src/sdkgen.ts +87 -20
- package/src/tsconfig.json +1 -0
- package/src/types.ts +85 -2
- package/src/utility.ts +22 -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/tm/go/utility/struct/go.mod +0 -3
|
@@ -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, 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_js'
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
12
14
|
const { target, ctx$: { model } } = props
|
|
@@ -16,32 +18,53 @@ 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
|
-
const
|
|
20
|
-
?
|
|
21
|
-
:
|
|
21
|
+
const ctor = isAuthActive(model)
|
|
22
|
+
? `new ${model.const.Name}SDK({\n apikey: process.env.${envName(model)}_APIKEY,\n})`
|
|
23
|
+
: `new ${model.const.Name}SDK()`
|
|
22
24
|
|
|
23
25
|
Content(`
|
|
24
26
|
### Create a Client
|
|
25
27
|
|
|
26
28
|
\`\`\`js
|
|
27
|
-
const { ${model.const.Name}SDK } = require('${target.
|
|
29
|
+
const { ${model.const.Name}SDK } = require('${packageName(model, target.name)}')
|
|
28
30
|
|
|
29
|
-
const client =
|
|
31
|
+
const client = ${ctor}
|
|
30
32
|
\`\`\`
|
|
31
33
|
`)
|
|
32
34
|
|
|
33
35
|
|
|
34
36
|
if (exampleEntity) {
|
|
35
37
|
const eName = nom(exampleEntity, 'Name')
|
|
38
|
+
const article = /^[aeiou]/i.test(eName) ? 'an' : 'a'
|
|
36
39
|
const opnames = Object.keys(exampleEntity.op || {})
|
|
37
40
|
|
|
41
|
+
// Model-driven example fields, in parity with the ts target: derive the
|
|
42
|
+
// create/update body from the op shape (opRequestShape) so the docs show
|
|
43
|
+
// REAL writable fields, not a hardcoded field the entity may not have.
|
|
44
|
+
// `idF` is the entity's id-like field name, or null when it has none —
|
|
45
|
+
// then load/remove match on no argument and update omits the id.
|
|
46
|
+
const idF = entityIdField(exampleEntity)
|
|
47
|
+
// Variable-safe lowercase name (a `Delete` entity must not bind `delete`).
|
|
48
|
+
const eVar = safeVarName(exampleEntity.name, 'js')
|
|
49
|
+
const exampleFields = (opname: string): string[] => {
|
|
50
|
+
const items = opRequestShape(exampleEntity, opname).items
|
|
51
|
+
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
52
|
+
const required = items.filter((it: any) => !it.optional)
|
|
53
|
+
// create needs ALL required fields for parity with the typed ts target.
|
|
54
|
+
const chosen = 'create' === opname
|
|
55
|
+
? (required.length ? required : items.slice(0, 2))
|
|
56
|
+
: items.slice(0, 2)
|
|
57
|
+
return chosen.map((it: any) =>
|
|
58
|
+
` ${it.name}: ${exampleValue(exampleEntity, exampleEntity.op[opname], it.name, 'example_' + it.name)},`)
|
|
59
|
+
}
|
|
60
|
+
|
|
38
61
|
if (opnames.includes('load')) {
|
|
39
62
|
Content(`
|
|
40
|
-
### Load
|
|
63
|
+
### Load ${article} ${eName}
|
|
41
64
|
|
|
42
65
|
\`\`\`js
|
|
43
|
-
const ${
|
|
44
|
-
console.log(${
|
|
66
|
+
const ${eVar} = await client.${eName}().load(${idF ? `{ ${idF}: ${exampleValue(exampleEntity, exampleEntity.op && exampleEntity.op.load, idF, exampleEntity.name + '_id')} }` : ''})
|
|
67
|
+
console.log(${eVar})
|
|
45
68
|
\`\`\`
|
|
46
69
|
`)
|
|
47
70
|
}
|
|
@@ -51,34 +74,37 @@ console.log(${exampleEntity.name})
|
|
|
51
74
|
### List ${eName} Records
|
|
52
75
|
|
|
53
76
|
\`\`\`js
|
|
54
|
-
const ${
|
|
55
|
-
|
|
77
|
+
const ${eVar}s = await client.${eName}().list()
|
|
78
|
+
for (const ${eVar} of ${eVar}s) {
|
|
79
|
+
console.log(${eVar})
|
|
80
|
+
}
|
|
56
81
|
\`\`\`
|
|
57
82
|
`)
|
|
58
83
|
}
|
|
59
84
|
|
|
60
85
|
if (opnames.includes('create')) {
|
|
86
|
+
const createLines = exampleFields('create')
|
|
87
|
+
const createBody = createLines.length ? '\n' + createLines.join('\n') + '\n' : ''
|
|
61
88
|
Content(`
|
|
62
89
|
### Create a ${eName}
|
|
63
90
|
|
|
64
91
|
\`\`\`js
|
|
65
|
-
const created = await client.${eName}().create({
|
|
66
|
-
// Provide ${exampleEntity.name} fields
|
|
67
|
-
})
|
|
92
|
+
const created = await client.${eName}().create({${createBody}})
|
|
68
93
|
console.log(created)
|
|
69
94
|
\`\`\`
|
|
70
95
|
`)
|
|
71
96
|
}
|
|
72
97
|
|
|
73
98
|
if (opnames.includes('update')) {
|
|
99
|
+
const updateLines = (idF
|
|
100
|
+
? [` ${idF}: ${exampleValue(exampleEntity, exampleEntity.op && exampleEntity.op.update, idF, exampleEntity.name + '_id')},`]
|
|
101
|
+
: []).concat(exampleFields('update'))
|
|
102
|
+
const updateBody = updateLines.length ? '\n' + updateLines.join('\n') + '\n' : ''
|
|
74
103
|
Content(`
|
|
75
104
|
### Update a ${eName}
|
|
76
105
|
|
|
77
106
|
\`\`\`js
|
|
78
|
-
const updated = await client.${eName}().update({
|
|
79
|
-
id: '${exampleEntity.name}_id',
|
|
80
|
-
// Fields to update
|
|
81
|
-
})
|
|
107
|
+
const updated = await client.${eName}().update({${updateBody}})
|
|
82
108
|
console.log(updated)
|
|
83
109
|
\`\`\`
|
|
84
110
|
`)
|
|
@@ -89,7 +115,7 @@ console.log(updated)
|
|
|
89
115
|
### Remove a ${eName}
|
|
90
116
|
|
|
91
117
|
\`\`\`js
|
|
92
|
-
await client.${eName}().remove({
|
|
118
|
+
await client.${eName}().remove(${idF ? `{ ${idF}: ${exampleValue(exampleEntity, exampleEntity.op && exampleEntity.op.remove, idF, exampleEntity.name + '_id')} }` : ''})
|
|
93
119
|
\`\`\`
|
|
94
120
|
`)
|
|
95
121
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, File, isAuthActive } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, each, Content, canonToType, File, isAuthActive, entityIdField, safeVarName } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
6
6
|
getModelPath,
|
|
7
7
|
} from '@voxgig/apidef'
|
|
8
8
|
|
|
9
|
+
import { exampleValue } from './utility_js'
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
const OP_SIGNATURES: Record<string, { sig: string, returns: string, desc: string }> = {
|
|
11
13
|
load: {
|
|
@@ -70,8 +72,7 @@ Create a new SDK client instance.
|
|
|
70
72
|
| Name | Type | Description |
|
|
71
73
|
| --- | --- | --- |
|
|
72
74
|
| \`options\` | \`object\` | SDK configuration options. |
|
|
73
|
-
| \`options.apikey\` | \`string\` | API key for authentication. |
|
|
74
|
-
| \`options.base\` | \`string\` | Base URL for API requests. |
|
|
75
|
+
${isAuthActive(model) ? '| \`options.apikey\` | \`string\` | API key for authentication. |\n' : ''}| \`options.base\` | \`string\` | Base URL for API requests. |
|
|
75
76
|
| \`options.prefix\` | \`string\` | URL prefix appended after base. |
|
|
76
77
|
| \`options.suffix\` | \`string\` | URL suffix appended after path. |
|
|
77
78
|
| \`options.headers\` | \`object\` | Custom headers for all requests. |
|
|
@@ -180,6 +181,11 @@ Alias for \`${model.Name}SDK.test()\`.
|
|
|
180
181
|
publishedEntities.map((ent: any) => {
|
|
181
182
|
const opnames = Object.keys(ent.op || {})
|
|
182
183
|
const fields = ent.fields || []
|
|
184
|
+
// Model-driven id key: null when this entity has no id-like field, in
|
|
185
|
+
// which case load/remove match on no argument and update omits the id.
|
|
186
|
+
const idF = entityIdField(ent)
|
|
187
|
+
// Variable-safe lowercase name (a `Delete` entity must not bind `delete`).
|
|
188
|
+
const eVar = safeVarName(ent.name, 'js')
|
|
183
189
|
|
|
184
190
|
Content(`
|
|
185
191
|
---
|
|
@@ -195,7 +201,7 @@ Alias for \`${model.Name}SDK.test()\`.
|
|
|
195
201
|
}
|
|
196
202
|
|
|
197
203
|
Content(`\`\`\`ts
|
|
198
|
-
const ${
|
|
204
|
+
const ${eVar} = client.${ent.Name}()
|
|
199
205
|
\`\`\`
|
|
200
206
|
|
|
201
207
|
`)
|
|
@@ -211,7 +217,7 @@ const ${ent.name} = client.${ent.Name}()
|
|
|
211
217
|
each(fields, (field: any) => {
|
|
212
218
|
const req = field.req ? 'Yes' : 'No'
|
|
213
219
|
const desc = field.short || ''
|
|
214
|
-
Content(`| \`${field.name}\` | \`${field.type
|
|
220
|
+
Content(`| \`${field.name}\` | \`${canonToType(field.type, target.name)}\` | ${req} | ${desc} |
|
|
215
221
|
`)
|
|
216
222
|
})
|
|
217
223
|
|
|
@@ -221,15 +227,18 @@ const ${ent.name} = client.${ent.Name}()
|
|
|
221
227
|
// Field operations breakdown
|
|
222
228
|
const hasFieldOps = fields.some((f: any) => f.op && Object.keys(f.op).length > 0)
|
|
223
229
|
if (hasFieldOps) {
|
|
230
|
+
// Only emit columns for operations this entity actually exposes —
|
|
231
|
+
// never advertise a create/update/remove column the entity lacks.
|
|
232
|
+
const opcols = ['load', 'list', 'create', 'update', 'remove']
|
|
233
|
+
.filter((op: string) => opnames.includes(op) && ent.op[op]?.active !== false)
|
|
224
234
|
Content(`### Field Usage by Operation
|
|
225
235
|
|
|
226
|
-
| Field |
|
|
227
|
-
| --- |
|
|
236
|
+
| Field | ${opcols.join(' | ')} |
|
|
237
|
+
| --- | ${opcols.map(() => '---').join(' | ')} |
|
|
228
238
|
`)
|
|
229
239
|
each(fields, (field: any) => {
|
|
230
240
|
const fops = field.op || {}
|
|
231
|
-
const cols =
|
|
232
|
-
if (!opnames.includes(op)) return '-'
|
|
241
|
+
const cols = opcols.map((op: string) => {
|
|
233
242
|
const fop = fops[op]
|
|
234
243
|
if (null == fop) return '-'
|
|
235
244
|
if (fop.active === false) return '-'
|
|
@@ -264,7 +273,7 @@ ${info.desc}
|
|
|
264
273
|
// Show example
|
|
265
274
|
if ('load' === opname || 'remove' === opname) {
|
|
266
275
|
Content(`\`\`\`ts
|
|
267
|
-
const result = await client.${ent.Name}().${opname}({
|
|
276
|
+
const result = await client.${ent.Name}().${opname}(${idF ? `{ ${idF}: ${exampleValue(ent, ent.op && ent.op[opname], idF, ent.name + '_id')} }` : ''})
|
|
268
277
|
\`\`\`
|
|
269
278
|
|
|
270
279
|
`)
|
|
@@ -282,7 +291,7 @@ const result = await client.${ent.Name}().create({
|
|
|
282
291
|
`)
|
|
283
292
|
each(fields, (field: any) => {
|
|
284
293
|
if ('id' !== field.name && field.req) {
|
|
285
|
-
Content(` ${field.name}: /* ${field.type
|
|
294
|
+
Content(` ${field.name}: /* ${canonToType(field.type, target.name)} */,
|
|
286
295
|
`)
|
|
287
296
|
}
|
|
288
297
|
})
|
|
@@ -292,10 +301,12 @@ const result = await client.${ent.Name}().create({
|
|
|
292
301
|
`)
|
|
293
302
|
}
|
|
294
303
|
else if ('update' === opname) {
|
|
304
|
+
const updateIdLine = idF
|
|
305
|
+
? ` ${idF}: ${exampleValue(ent, ent.op && ent.op.update, idF, ent.name + '_id')},\n`
|
|
306
|
+
: ''
|
|
295
307
|
Content(`\`\`\`ts
|
|
296
308
|
const result = await client.${ent.Name}().update({
|
|
297
|
-
|
|
298
|
-
// Fields to update
|
|
309
|
+
${updateIdLine} // Fields to update
|
|
299
310
|
})
|
|
300
311
|
\`\`\`
|
|
301
312
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, packageName, envName, entityIdField, 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_js'
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
12
14
|
const { target, ctx$: { model } } = props
|
|
@@ -14,24 +16,28 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
|
14
16
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
15
17
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
16
18
|
|
|
17
|
-
const
|
|
18
|
-
?
|
|
19
|
-
:
|
|
19
|
+
const ctor = isAuthActive(model)
|
|
20
|
+
? `new ${model.const.Name}SDK({\n apikey: process.env.${envName(model)}_APIKEY,\n})`
|
|
21
|
+
: `new ${model.const.Name}SDK()`
|
|
20
22
|
|
|
21
23
|
Content(`\`\`\`js
|
|
22
|
-
const { ${model.const.Name}SDK } = require('${target.
|
|
24
|
+
const { ${model.const.Name}SDK } = require('${packageName(model, target.name)}')
|
|
23
25
|
|
|
24
|
-
const client =
|
|
26
|
+
const client = ${ctor}
|
|
25
27
|
|
|
26
28
|
`)
|
|
27
29
|
|
|
28
30
|
if (exampleEntity) {
|
|
29
31
|
const eName = nom(exampleEntity, 'Name')
|
|
32
|
+
const eVar = safeVarName(eName.toLowerCase(), 'js')
|
|
30
33
|
const opnames = Object.keys(exampleEntity.op || {})
|
|
31
34
|
|
|
32
35
|
if (opnames.includes('list')) {
|
|
33
|
-
Content(`// List all ${eName.toLowerCase()}s
|
|
34
|
-
const ${
|
|
36
|
+
Content(`// List all ${eName.toLowerCase()}s (returns an array)
|
|
37
|
+
const ${eVar}s = await client.${eName}().list()
|
|
38
|
+
for (const ${eVar} of ${eVar}s) {
|
|
39
|
+
console.log(${eVar})
|
|
40
|
+
}
|
|
35
41
|
`)
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -42,16 +48,26 @@ const ${eName.toLowerCase()}s = await client.${eName}().list()
|
|
|
42
48
|
|
|
43
49
|
if (nestedEntity && opnames.includes('load')) {
|
|
44
50
|
const neName = nom(nestedEntity, 'Name')
|
|
51
|
+
const neVar = safeVarName(neName.toLowerCase(), 'js')
|
|
45
52
|
const parentFields = (nestedEntity.fields || [])
|
|
46
53
|
.filter((f: any) => f.name !== 'id' && f.name.endsWith('_id'))
|
|
47
54
|
const parentParam = parentFields.length > 0 ? parentFields[0].name : 'parent_id'
|
|
55
|
+
const loadOp = nestedEntity.op && nestedEntity.op.load
|
|
56
|
+
|
|
57
|
+
// Model-driven id key: only emit an id match line if the nested entity
|
|
58
|
+
// has an id-like key field.
|
|
59
|
+
const neIdF = entityIdField(nestedEntity)
|
|
60
|
+
const neMatchLines = [` ${parentParam}: ${exampleValue(nestedEntity, loadOp, parentParam, 'example')},`]
|
|
61
|
+
if (neIdF) {
|
|
62
|
+
neMatchLines.push(` ${neIdF}: ${exampleValue(nestedEntity, loadOp, neIdF, 'example_id')},`)
|
|
63
|
+
}
|
|
48
64
|
|
|
49
65
|
Content(`
|
|
50
|
-
// Load a specific ${neName.toLowerCase()}
|
|
51
|
-
const ${
|
|
52
|
-
|
|
53
|
-
id: 'example_id',
|
|
66
|
+
// Load a specific ${neName.toLowerCase()} (returns the entity)
|
|
67
|
+
const ${neVar} = await client.${neName}().load({
|
|
68
|
+
${neMatchLines.join('\n')}
|
|
54
69
|
})
|
|
70
|
+
console.log(${neVar})
|
|
55
71
|
`)
|
|
56
72
|
}
|
|
57
73
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, entityIdField, entityPrimaryOp, opRequestShape, 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_js'
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
const ReadmeTopTest = cmp(function ReadmeTopTest(props: any) {
|
|
12
14
|
const { target, ctx$: { model } } = props
|
|
@@ -20,8 +22,26 @@ const client = ${model.const.Name}SDK.test()
|
|
|
20
22
|
|
|
21
23
|
if (exampleEntity) {
|
|
22
24
|
const eName = nom(exampleEntity, 'Name')
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
+
const eVar = safeVarName(eName.toLowerCase(), 'js')
|
|
26
|
+
// Drive the test-mode example off the entity's PRIMARY op (never a
|
|
27
|
+
// hardcoded `load` a create-only entity lacks).
|
|
28
|
+
const primaryOp = entityPrimaryOp(exampleEntity) || 'load'
|
|
29
|
+
const primaryOpDef = exampleEntity.op && exampleEntity.op[primaryOp]
|
|
30
|
+
const idF = entityIdField(exampleEntity)
|
|
31
|
+
let arg = ''
|
|
32
|
+
if ('load' === primaryOp || 'remove' === primaryOp) {
|
|
33
|
+
arg = idF ? `{ ${idF}: ${exampleValue(exampleEntity, primaryOpDef, idF, 'test01')} }` : ''
|
|
34
|
+
} else if ('create' === primaryOp || 'update' === primaryOp) {
|
|
35
|
+
const items = opRequestShape(exampleEntity, primaryOp).items
|
|
36
|
+
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
37
|
+
const required = items.filter((it: any) => !it.optional)
|
|
38
|
+
const chosen = required.length ? required : items.slice(0, 3)
|
|
39
|
+
arg = `{ ${chosen.map((it: any) =>
|
|
40
|
+
`${it.name}: ${exampleValue(exampleEntity, primaryOpDef, it.name, 'example_' + it.name)}`).join(', ')} }`
|
|
41
|
+
}
|
|
42
|
+
Content(`const ${eVar} = await client.${eName}().${primaryOp}(${arg})
|
|
43
|
+
// ${eVar} is a bare entity populated with mock data
|
|
44
|
+
console.log(${eVar})
|
|
25
45
|
`)
|
|
26
46
|
}
|
|
27
47
|
|
|
@@ -2,12 +2,68 @@
|
|
|
2
2
|
import * as Path from 'node:path'
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
import {
|
|
6
|
+
canonKey,
|
|
7
|
+
each,
|
|
8
|
+
} from '@voxgig/sdkgen'
|
|
9
|
+
|
|
5
10
|
import {
|
|
6
11
|
clone,
|
|
7
12
|
walk,
|
|
8
13
|
} from '@voxgig/struct'
|
|
9
14
|
|
|
10
15
|
|
|
16
|
+
// --- Model-driven example literals -----------------------------------------
|
|
17
|
+
// Doc snippets must use example values whose TYPE matches the generated
|
|
18
|
+
// types, or the snippet misrepresents the API. The id/match params of
|
|
19
|
+
// load/remove/update are the common trap: their generated
|
|
20
|
+
// `<Name><Op>Match` / `<Name><Op>Data` type is built from the op's params
|
|
21
|
+
// (see EntityTypes_js.ts), so a numeric id shown as a quoted string is
|
|
22
|
+
// wrong. These helpers derive the example literal from the SAME model
|
|
23
|
+
// source, so the docs and the generated types can never disagree.
|
|
24
|
+
|
|
25
|
+
// The declared canon-type sentinel of a named parameter of an op — looked up
|
|
26
|
+
// in the op's `points[].args.params[]` exactly as the typed-model generator
|
|
27
|
+
// does. Falls back to the entity field of the same name (used when the op
|
|
28
|
+
// has no params). Returns undefined when neither is present.
|
|
29
|
+
function paramCanonType(entity: any, op: any, paramName: string): unknown {
|
|
30
|
+
const points = op && op.points ? each(op.points) : []
|
|
31
|
+
for (const pt of points as any[]) {
|
|
32
|
+
const params = pt && pt.args && pt.args.params ? each(pt.args.params) : []
|
|
33
|
+
const found = (params as any[]).find((p: any) => p && p.name === paramName)
|
|
34
|
+
if (found) {
|
|
35
|
+
return found.type
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const field = (entity && entity.fields ? each(entity.fields) : [])
|
|
39
|
+
.find((f: any) => f && f.name === paramName) as any
|
|
40
|
+
return field && field.type
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// A type-correct example literal for a named match/data parameter of an op,
|
|
45
|
+
// derived entirely from the model. INTEGER/NUMBER render as the bare number
|
|
46
|
+
// `1`, BOOLEAN as `true`, ARRAY as the empty `[]` and OBJECT as the empty
|
|
47
|
+
// `{}`, everything else (STRING, unknown, missing) as the quoted
|
|
48
|
+
// `placeholder`.
|
|
49
|
+
function exampleValue(entity: any, op: any, paramName: string, placeholder: string): string {
|
|
50
|
+
const key = canonKey(paramCanonType(entity, op, paramName))
|
|
51
|
+
if ('INTEGER' === key || 'NUMBER' === key) {
|
|
52
|
+
return '1'
|
|
53
|
+
}
|
|
54
|
+
if ('BOOLEAN' === key) {
|
|
55
|
+
return 'true'
|
|
56
|
+
}
|
|
57
|
+
if ('ARRAY' === key) {
|
|
58
|
+
return '[]'
|
|
59
|
+
}
|
|
60
|
+
if ('OBJECT' === key) {
|
|
61
|
+
return '{}'
|
|
62
|
+
}
|
|
63
|
+
return `'${placeholder}'`
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
11
67
|
function projectPath(suffix?: string): string {
|
|
12
68
|
return Path.normalize(Path.join(__dirname, '../../..', suffix ?? ''))
|
|
13
69
|
}
|
|
@@ -61,4 +117,5 @@ export {
|
|
|
61
117
|
formatJSONSrc,
|
|
62
118
|
formatJson,
|
|
63
119
|
projectPath,
|
|
120
|
+
exampleValue,
|
|
64
121
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
// Typed-model generator (Lua target).
|
|
4
|
+
//
|
|
5
|
+
// Lua is dynamically typed, so the "types" are LuaLS annotations
|
|
6
|
+
// (---@class / ---@field) for editor/tooling DX only — no runtime effect.
|
|
7
|
+
//
|
|
8
|
+
// Reads main.<KIT>.entity.<e>.fields[] and per-op params
|
|
9
|
+
// (op.<name>.points[].args.params[]) and emits one file, <sdk>_types.lua,
|
|
10
|
+
// with a `---@class <Name>` per active entity plus a request/match ---@class
|
|
11
|
+
// per active op. Field/param sentinels ($STRING, $INTEGER, ...) are turned
|
|
12
|
+
// into LuaLS types by the shared sdkgen helper `canonToType` ('lua' column).
|
|
13
|
+
//
|
|
14
|
+
// Keeps the SAME type-name scheme as the TS reference (<Name>,
|
|
15
|
+
// <Name>LoadMatch, <Name>ListMatch, <Name>CreateData, <Name>UpdateData,
|
|
16
|
+
// <Name>RemoveMatch). The op fragments reference these class names via
|
|
17
|
+
// ---@param / ---@return.
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
cmp, each,
|
|
21
|
+
File, Content,
|
|
22
|
+
} from '@voxgig/sdkgen'
|
|
23
|
+
|
|
24
|
+
import { canonToType, opTypeName, opRequestShape } from '@voxgig/sdkgen'
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
KIT,
|
|
28
|
+
getModelPath,
|
|
29
|
+
} from '@voxgig/apidef'
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const LANG = 'lua'
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
// A bare LuaLS field key, or a bracketed string literal for anything that is
|
|
36
|
+
// not a plain Lua identifier.
|
|
37
|
+
function propKey(name: string): string {
|
|
38
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) ? name : '[' + JSON.stringify(name) + ']'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const EntityTypes = cmp(function EntityTypes(props: any) {
|
|
43
|
+
const { target } = props
|
|
44
|
+
const { model } = props.ctx$
|
|
45
|
+
|
|
46
|
+
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
47
|
+
const entityList = each(entity).filter((e: any) => e.active !== false)
|
|
48
|
+
|
|
49
|
+
File({ name: model.name + '_types.' + (target.ext || LANG) }, () => {
|
|
50
|
+
|
|
51
|
+
Content(`-- Typed models for the ${model.const.Name} SDK (LuaLS annotations).
|
|
52
|
+
--
|
|
53
|
+
-- GENERATED from the API model: main.${KIT}.entity.<e>.fields[] and per-op
|
|
54
|
+
-- params (op.<name>.points[].args.params[]). Field/param types come from the
|
|
55
|
+
-- canonical type sentinels via @voxgig/sdkgen canonToType (source of truth:
|
|
56
|
+
-- @voxgig/apidef VALID_CANON). Annotations only — no runtime effect. Do not
|
|
57
|
+
-- edit by hand.
|
|
58
|
+
|
|
59
|
+
`)
|
|
60
|
+
|
|
61
|
+
entityList.forEach((ent: any) => {
|
|
62
|
+
const Name = ent.Name
|
|
63
|
+
const fields = (ent.fields ? each(ent.fields) : [])
|
|
64
|
+
.filter((f: any) => f.active !== false)
|
|
65
|
+
|
|
66
|
+
// Entity data model: one ---@field per field, `req:false` -> optional (?).
|
|
67
|
+
Content(`---@class ${Name}
|
|
68
|
+
`)
|
|
69
|
+
fields.forEach((f: any) => {
|
|
70
|
+
const opt = false === f.req ? '?' : ''
|
|
71
|
+
Content(`---@field ${propKey(f.name)}${opt} ${canonToType(f.type, LANG)}
|
|
72
|
+
`)
|
|
73
|
+
})
|
|
74
|
+
Content(`
|
|
75
|
+
`)
|
|
76
|
+
|
|
77
|
+
// Per active op: a request/match class. Members and their optionality
|
|
78
|
+
// come from the shared partiality policy (opRequestShape); this file only
|
|
79
|
+
// renders them as LuaLS ---@field lines.
|
|
80
|
+
const ops = ent.op || {}
|
|
81
|
+
;['load', 'list', 'create', 'update', 'remove'].forEach((opname: string) => {
|
|
82
|
+
if (null == ops[opname]) {
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const typeName = opTypeName(Name, opname)
|
|
87
|
+
const { items } = opRequestShape(ent, opname)
|
|
88
|
+
|
|
89
|
+
Content(`---@class ${typeName}
|
|
90
|
+
`)
|
|
91
|
+
items.forEach((it: any) => {
|
|
92
|
+
const opt = it.optional ? '?' : ''
|
|
93
|
+
Content(`---@field ${propKey(it.name)}${opt} ${canonToType(it.type, LANG)}
|
|
94
|
+
`)
|
|
95
|
+
})
|
|
96
|
+
Content(`
|
|
97
|
+
`)
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
// Make the file a require-able (empty) module. The blank line above keeps
|
|
102
|
+
// LuaLS from binding the last ---@class to this local.
|
|
103
|
+
Content(`local M = {}
|
|
104
|
+
|
|
105
|
+
return M
|
|
106
|
+
`)
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
EntityTypes,
|
|
113
|
+
}
|
|
@@ -8,8 +8,16 @@ const MainEntity = cmp(async function MainEntity(props: any) {
|
|
|
8
8
|
const { model } = props.ctx$
|
|
9
9
|
|
|
10
10
|
Content(`
|
|
11
|
+
-- Idiomatic facade: client:${entity.Name}():list() / client:${entity.Name}():load({ id = ... })
|
|
12
|
+
-- Entity access is capitalised (PascalCase) for parity with the other SDKs.
|
|
11
13
|
function ${model.const.Name}SDK:${entity.Name}(data)
|
|
12
14
|
local EntityMod = require("entity.${entity.name}_entity")
|
|
15
|
+
if data == nil then
|
|
16
|
+
if self._${entity.name} == nil then
|
|
17
|
+
self._${entity.name} = EntityMod.new(self, nil)
|
|
18
|
+
end
|
|
19
|
+
return self._${entity.name}
|
|
20
|
+
end
|
|
13
21
|
return EntityMod.new(self, data)
|
|
14
22
|
end
|
|
15
23
|
|
|
@@ -22,6 +22,7 @@ import { Package } from './Package_lua'
|
|
|
22
22
|
import { Config } from './Config_lua'
|
|
23
23
|
import { Gitignore } from './Gitignore_lua'
|
|
24
24
|
import { MainEntity } from './MainEntity_lua'
|
|
25
|
+
import { EntityTypes } from './EntityTypes_lua'
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
const Main = cmp(async function Main(props: any) {
|
|
@@ -79,6 +80,9 @@ self._utility.feature_hook(self._rootctx, "${name}")
|
|
|
79
80
|
})
|
|
80
81
|
})
|
|
81
82
|
|
|
83
|
+
// Generate typed-model annotations (LuaLS ---@class / ---@field)
|
|
84
|
+
EntityTypes({ target })
|
|
85
|
+
|
|
82
86
|
// Generate config module
|
|
83
87
|
Folder({ name: '.' }, () => {
|
|
84
88
|
Config({ target })
|