@voxgig/sdkgen 1.2.1 → 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 +11 -5
- 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
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
import { cmp, Content, File } from '@voxgig/sdkgen'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
KIT,
|
|
5
|
+
getModelPath,
|
|
6
|
+
} from '@voxgig/apidef'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// Emits go/test/readme_examples_test.go — a COMPLETENESS GATE over every
|
|
10
|
+
// ```go block in ALL THREE docs that ship go examples:
|
|
11
|
+
// - the root README.md (top-level, multi-language quick start)
|
|
12
|
+
// - the per-language go/README.md
|
|
13
|
+
// - the per-language go/REFERENCE.md
|
|
14
|
+
//
|
|
15
|
+
// For every ```go block, tagged by (source doc, index), it exercises the
|
|
16
|
+
// block against the real generated SDK:
|
|
17
|
+
//
|
|
18
|
+
// - Fragments (statement snippets) are wrapped in a function with a SEEDED
|
|
19
|
+
// test-mode `client` in scope and `go build`-checked. Any stray `import`
|
|
20
|
+
// line inside the fragment is stripped and constructor calls are rewritten
|
|
21
|
+
// to the seeded test client (so undefined-variable placeholders like
|
|
22
|
+
// sdk.TestSDK(testopts, sdkopts) still type-check). A call to a method
|
|
23
|
+
// that does not exist, a wrong argument count/type, or `.data`/`.ok` field
|
|
24
|
+
// access on a bare entity-op result fails to compile — and so fails.
|
|
25
|
+
// - Complete programs (a block with `func main`) are built as-is (the
|
|
26
|
+
// documented, possibly live, form must compile) AND a test-mode variant —
|
|
27
|
+
// its constructor rewritten to a seeded `sdk.TestSDK(...)` — is RUN with
|
|
28
|
+
// `go run`. A genuine runtime panic (nil pointer, nil map, index,
|
|
29
|
+
// interface conversion) FAILS the test; a tolerated not-found domain
|
|
30
|
+
// error does not.
|
|
31
|
+
// - Illustrative blocks are the ONLY blocks skipped, and the class is
|
|
32
|
+
// NARROW: a bare signature (a `func` line with no body) or a comment-only
|
|
33
|
+
// / `/* ... */` placeholder. Everything else must compile or run.
|
|
34
|
+
//
|
|
35
|
+
// Completeness: per doc, total == compiled + illustration is asserted. A block
|
|
36
|
+
// that is neither compiled nor a recognized illustration — e.g. real code
|
|
37
|
+
// hidden behind a `/* ... */` comment that the old logic silently skipped —
|
|
38
|
+
// FAILS the gate, so no compilable example can escape the check.
|
|
39
|
+
const ReadmeExamplesTest = cmp(function ReadmeExamplesTest(props: any) {
|
|
40
|
+
const { ctx$: { model } } = props
|
|
41
|
+
|
|
42
|
+
// Seed a test-mode fixture for every active entity. Complete-program
|
|
43
|
+
// examples load by "example_id", so seed that record for each entity; the
|
|
44
|
+
// offline mock then returns it instead of 404-ing.
|
|
45
|
+
const entity = getModelPath(model, `main.${KIT}.entity`) || {}
|
|
46
|
+
const entnames = Object.values(entity)
|
|
47
|
+
.filter((e: any) => e && e.active !== false)
|
|
48
|
+
.map((e: any) => e.name)
|
|
49
|
+
|
|
50
|
+
const goSeedEntries = entnames
|
|
51
|
+
.map((n: string) =>
|
|
52
|
+
`"${n}": map[string]any{"example_id": map[string]any{"id": "example_id"}}`)
|
|
53
|
+
.join(', ')
|
|
54
|
+
const goSeed = `map[string]any{"entity": map[string]any{${goSeedEntries}}}`
|
|
55
|
+
|
|
56
|
+
File({ name: 'readme_examples_test.go' }, () => {
|
|
57
|
+
Content(`package sdktest
|
|
58
|
+
|
|
59
|
+
import (
|
|
60
|
+
"fmt"
|
|
61
|
+
"os"
|
|
62
|
+
"os/exec"
|
|
63
|
+
"path/filepath"
|
|
64
|
+
"runtime"
|
|
65
|
+
"strconv"
|
|
66
|
+
"strings"
|
|
67
|
+
"testing"
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
// testSeed is a test-mode fixture seeded for every entity. It is spliced as
|
|
71
|
+
// literal Go source into fragment wrappers and into the test-mode variant of
|
|
72
|
+
// complete programs, so the offline mock transport has data to return.
|
|
73
|
+
const testSeed = \`${goSeed}\`
|
|
74
|
+
|
|
75
|
+
// doc names one of the three docs that carry go examples, with its path
|
|
76
|
+
// relative to this test file's directory (which is <repo>/go/test): the root
|
|
77
|
+
// README is two levels up, the go docs are one.
|
|
78
|
+
type doc struct {
|
|
79
|
+
label string
|
|
80
|
+
relpath string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// docStat accumulates the completeness bookkeeping for one doc.
|
|
84
|
+
type docStat struct {
|
|
85
|
+
total int
|
|
86
|
+
compiled int
|
|
87
|
+
illustration int
|
|
88
|
+
leaked []int
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// TestReadmeGoSnippets is a completeness gate over every \`\`\`go fenced block
|
|
92
|
+
// in the root README.md, go/README.md, and go/REFERENCE.md. Fragments are
|
|
93
|
+
// \`go build\`-checked with a seeded test client injected; complete programs
|
|
94
|
+
// are built as-is and their test-mode variant is run with \`go run\`; and per
|
|
95
|
+
// doc, total == compiled + illustration is asserted.
|
|
96
|
+
func TestReadmeGoSnippets(t *testing.T) {
|
|
97
|
+
_, thisFile, _, _ := runtime.Caller(0)
|
|
98
|
+
testDir := filepath.Dir(thisFile)
|
|
99
|
+
moduleRoot := filepath.Dir(testDir)
|
|
100
|
+
|
|
101
|
+
modulePath := readModulePath(moduleRoot)
|
|
102
|
+
if modulePath == "" {
|
|
103
|
+
t.Fatal("could not read module path from go.mod")
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
docs := []doc{
|
|
107
|
+
{"root README", filepath.Join(testDir, "..", "..", "README.md")},
|
|
108
|
+
{"go/README", filepath.Join(testDir, "..", "README.md")},
|
|
109
|
+
{"go/REFERENCE", filepath.Join(testDir, "..", "REFERENCE.md")},
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
work, err := os.MkdirTemp(moduleRoot, "readmecheck-")
|
|
113
|
+
if err != nil {
|
|
114
|
+
t.Fatalf("mkdir temp: %v", err)
|
|
115
|
+
}
|
|
116
|
+
defer os.RemoveAll(work)
|
|
117
|
+
rel := filepath.Base(work)
|
|
118
|
+
|
|
119
|
+
binDir := filepath.Join(work, "bin")
|
|
120
|
+
if err := os.MkdirAll(binDir, 0o755); err != nil {
|
|
121
|
+
t.Fatal(err)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
fragDir := filepath.Join(work, "frag")
|
|
125
|
+
fragFiles := map[string]string{}
|
|
126
|
+
var progDirs []string
|
|
127
|
+
var runDirs []string
|
|
128
|
+
progCount := 0
|
|
129
|
+
|
|
130
|
+
stats := make([]*docStat, len(docs))
|
|
131
|
+
|
|
132
|
+
for di, d := range docs {
|
|
133
|
+
src, err := os.ReadFile(d.relpath)
|
|
134
|
+
if err != nil {
|
|
135
|
+
t.Fatalf("%s not found at %s: %v", d.label, d.relpath, err)
|
|
136
|
+
}
|
|
137
|
+
blocks := extractFencedBlocks(string(src), "go")
|
|
138
|
+
if len(blocks) == 0 {
|
|
139
|
+
t.Fatalf("no go code blocks in %s", d.label)
|
|
140
|
+
}
|
|
141
|
+
st := &docStat{total: len(blocks)}
|
|
142
|
+
stats[di] = st
|
|
143
|
+
|
|
144
|
+
for bi, block := range blocks {
|
|
145
|
+
if isIllustration(block) {
|
|
146
|
+
st.illustration++
|
|
147
|
+
continue
|
|
148
|
+
}
|
|
149
|
+
if strings.Contains(block, "/*") {
|
|
150
|
+
// Real code hidden behind a block comment: neither a
|
|
151
|
+
// recognized illustration nor safely compilable as-is. Flag
|
|
152
|
+
// it so the completeness assertion catches a would-be
|
|
153
|
+
// silently-skipped example rather than dropping it.
|
|
154
|
+
st.leaked = append(st.leaked, bi+1)
|
|
155
|
+
continue
|
|
156
|
+
}
|
|
157
|
+
if strings.Contains(block, "func main") {
|
|
158
|
+
// The documented program (possibly using the live sdk.New)
|
|
159
|
+
// must compile as-is.
|
|
160
|
+
dir := filepath.Join(work, "prog"+strconv.Itoa(progCount))
|
|
161
|
+
if err := os.MkdirAll(dir, 0o755); err != nil {
|
|
162
|
+
t.Fatal(err)
|
|
163
|
+
}
|
|
164
|
+
if err := os.WriteFile(filepath.Join(dir, "main.go"), []byte(block), 0o644); err != nil {
|
|
165
|
+
t.Fatal(err)
|
|
166
|
+
}
|
|
167
|
+
progDirs = append(progDirs, "./"+rel+"/prog"+strconv.Itoa(progCount))
|
|
168
|
+
|
|
169
|
+
// A test-mode variant — constructor rewritten to a seeded
|
|
170
|
+
// sdk.TestSDK(...) — is run offline to prove the program runs.
|
|
171
|
+
if variant, ok := rewriteCtorsToTest(block); ok {
|
|
172
|
+
if !strings.Contains(variant, "os.") {
|
|
173
|
+
variant = removeImportLine(variant, "os")
|
|
174
|
+
}
|
|
175
|
+
runDir := filepath.Join(work, "run"+strconv.Itoa(progCount))
|
|
176
|
+
if err := os.MkdirAll(runDir, 0o755); err != nil {
|
|
177
|
+
t.Fatal(err)
|
|
178
|
+
}
|
|
179
|
+
if err := os.WriteFile(filepath.Join(runDir, "main.go"), []byte(variant), 0o644); err != nil {
|
|
180
|
+
t.Fatal(err)
|
|
181
|
+
}
|
|
182
|
+
runDirs = append(runDirs, "./"+rel+"/run"+strconv.Itoa(progCount))
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
progCount++
|
|
186
|
+
st.compiled++
|
|
187
|
+
continue
|
|
188
|
+
}
|
|
189
|
+
name := "snip" + strconv.Itoa(len(fragFiles))
|
|
190
|
+
fragFiles[name] = wrapFragment(name, block, modulePath)
|
|
191
|
+
st.compiled++
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fragPkg := ""
|
|
196
|
+
if len(fragFiles) > 0 {
|
|
197
|
+
if err := os.MkdirAll(fragDir, 0o755); err != nil {
|
|
198
|
+
t.Fatal(err)
|
|
199
|
+
}
|
|
200
|
+
fragPkg = "./" + rel + "/frag"
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if len(progDirs) == 0 && fragPkg == "" {
|
|
204
|
+
t.Fatal("no buildable go snippets across docs")
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Build. The Go compiler is the oracle for unused imports/vars in the
|
|
208
|
+
// wrapped fragments: blank them out and rebuild. Any OTHER error is a
|
|
209
|
+
// genuine snippet bug and fails the test.
|
|
210
|
+
var lastOut string
|
|
211
|
+
built := false
|
|
212
|
+
for attempt := 0; attempt < 15; attempt++ {
|
|
213
|
+
for name, content := range fragFiles {
|
|
214
|
+
if err := os.WriteFile(filepath.Join(fragDir, name+".go"), []byte(content), 0o644); err != nil {
|
|
215
|
+
t.Fatal(err)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
out, buildErr := runGoBuild(moduleRoot, binDir, progDirs, fragPkg)
|
|
219
|
+
if buildErr == nil {
|
|
220
|
+
built = true
|
|
221
|
+
break
|
|
222
|
+
}
|
|
223
|
+
lastOut = out
|
|
224
|
+
if !applyFixes(out, fragFiles) {
|
|
225
|
+
t.Fatalf("README go snippet failed to compile:\\n%s", out)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if !built {
|
|
229
|
+
t.Fatalf("README go snippets did not converge to a clean build:\\n%s", lastOut)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Everything compiled. Now RUN the test-mode variants of the complete
|
|
233
|
+
// programs and fail on a genuine runtime panic.
|
|
234
|
+
if fail := runProgs(moduleRoot, runDirs); fail != "" {
|
|
235
|
+
t.Fatal(fail)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Completeness: every block in every doc is either compiled/run or a
|
|
239
|
+
// recognized (narrow) illustration. A leaked block or a count mismatch is
|
|
240
|
+
// a silently-untested example and fails the gate.
|
|
241
|
+
for di, d := range docs {
|
|
242
|
+
st := stats[di]
|
|
243
|
+
if len(st.leaked) > 0 {
|
|
244
|
+
t.Errorf("%s: go block(s) %v are neither compiled nor a "+
|
|
245
|
+
"recognized illustration (silently untested) — use // "+
|
|
246
|
+
"comments with real code, or a bare signature / /* ... */ "+
|
|
247
|
+
"placeholder", d.label, st.leaked)
|
|
248
|
+
}
|
|
249
|
+
if st.total != st.compiled+st.illustration {
|
|
250
|
+
t.Errorf("%s completeness: total %d != compiled %d + "+
|
|
251
|
+
"illustration %d", d.label, st.total, st.compiled,
|
|
252
|
+
st.illustration)
|
|
253
|
+
}
|
|
254
|
+
fmt.Printf("[readme-go] %s: total=%d compiled=%d illustration=%d\\n",
|
|
255
|
+
d.label, st.total, st.compiled, st.illustration)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// runProgs executes each test-mode program variant with \`go run\` and reports
|
|
260
|
+
// a genuine runtime panic (nil pointer / nil map / index / interface
|
|
261
|
+
// conversion). A tolerated not-found domain error (panic(err) on an offline
|
|
262
|
+
// fixture miss) is not a failure. A run-variant that fails to even compile is
|
|
263
|
+
// skipped — the documented program already passed the strict build check, so
|
|
264
|
+
// a rewrite artefact must not manufacture a false failure.
|
|
265
|
+
func runProgs(moduleRoot string, dirs []string) string {
|
|
266
|
+
runtimeSigs := []string{
|
|
267
|
+
"runtime error",
|
|
268
|
+
"invalid memory address",
|
|
269
|
+
"nil pointer dereference",
|
|
270
|
+
"index out of range",
|
|
271
|
+
"slice bounds out of range",
|
|
272
|
+
"interface conversion",
|
|
273
|
+
"assignment to entry in nil map",
|
|
274
|
+
}
|
|
275
|
+
for _, d := range dirs {
|
|
276
|
+
cmd := exec.Command("go", "run", d)
|
|
277
|
+
cmd.Dir = moduleRoot
|
|
278
|
+
out, err := cmd.CombinedOutput()
|
|
279
|
+
if err == nil {
|
|
280
|
+
continue
|
|
281
|
+
}
|
|
282
|
+
s := string(out)
|
|
283
|
+
if !strings.Contains(s, "panic:") {
|
|
284
|
+
// Did not run (compile artefact of the rewrite) — tolerate.
|
|
285
|
+
continue
|
|
286
|
+
}
|
|
287
|
+
for _, sig := range runtimeSigs {
|
|
288
|
+
if strings.Contains(s, sig) {
|
|
289
|
+
return "README go complete program panicked at runtime " +
|
|
290
|
+
"(nil / type bug in a documented call):\\n" + s
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// Domain-error panic (e.g. offline fixture miss) — tolerated.
|
|
294
|
+
}
|
|
295
|
+
return ""
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// rewriteCtorsToTest replaces every sdk.New.../sdk.Test... constructor call
|
|
299
|
+
// in src with a seeded test-mode client, so a documented (possibly live)
|
|
300
|
+
// program runs offline against the mock, and a fragment whose constructor
|
|
301
|
+
// takes undefined placeholder variables still type-checks. Single
|
|
302
|
+
// left-to-right pass with balanced-paren matching; returns the rewritten
|
|
303
|
+
// source and whether any replacement was made.
|
|
304
|
+
func rewriteCtorsToTest(src string) (string, bool) {
|
|
305
|
+
repl := "sdk.TestSDK(" + testSeed + ", nil)"
|
|
306
|
+
var b strings.Builder
|
|
307
|
+
changed := false
|
|
308
|
+
i := 0
|
|
309
|
+
for i < len(src) {
|
|
310
|
+
matched := ""
|
|
311
|
+
if strings.HasPrefix(src[i:], "sdk.New") {
|
|
312
|
+
matched = "sdk.New"
|
|
313
|
+
} else if strings.HasPrefix(src[i:], "sdk.Test") {
|
|
314
|
+
matched = "sdk.Test"
|
|
315
|
+
}
|
|
316
|
+
if matched == "" {
|
|
317
|
+
b.WriteByte(src[i])
|
|
318
|
+
i++
|
|
319
|
+
continue
|
|
320
|
+
}
|
|
321
|
+
// Consume the rest of the identifier (e.g. NewAdviceSlipSDK, TestSDK).
|
|
322
|
+
j := i + len(matched)
|
|
323
|
+
for j < len(src) && isIdentByte(src[j]) {
|
|
324
|
+
j++
|
|
325
|
+
}
|
|
326
|
+
if j >= len(src) || src[j] != '(' {
|
|
327
|
+
b.WriteString(src[i:j])
|
|
328
|
+
i = j
|
|
329
|
+
continue
|
|
330
|
+
}
|
|
331
|
+
// Scan the balanced ( ... ) argument list.
|
|
332
|
+
depth := 0
|
|
333
|
+
k := j
|
|
334
|
+
for k < len(src) {
|
|
335
|
+
switch src[k] {
|
|
336
|
+
case '(':
|
|
337
|
+
depth++
|
|
338
|
+
case ')':
|
|
339
|
+
depth--
|
|
340
|
+
}
|
|
341
|
+
k++
|
|
342
|
+
if depth == 0 {
|
|
343
|
+
break
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
b.WriteString(repl)
|
|
347
|
+
changed = true
|
|
348
|
+
i = k
|
|
349
|
+
}
|
|
350
|
+
return b.String(), changed
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
func isIdentByte(c byte) bool {
|
|
354
|
+
return c == '_' ||
|
|
355
|
+
(c >= 'a' && c <= 'z') ||
|
|
356
|
+
(c >= 'A' && c <= 'Z') ||
|
|
357
|
+
(c >= '0' && c <= '9')
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// runGoBuild type-checks the fragment package with a plain \`go build\`
|
|
361
|
+
// (a non-main package produces no output but is still fully type-checked
|
|
362
|
+
// — unlike \`go build -o dir/\`, which skips non-main packages), and builds
|
|
363
|
+
// each complete program with \`-o binDir/\`. Any compile error from either
|
|
364
|
+
// is returned.
|
|
365
|
+
func runGoBuild(dir, binDir string, progDirs []string, fragPkg string) (string, error) {
|
|
366
|
+
var out strings.Builder
|
|
367
|
+
if fragPkg != "" {
|
|
368
|
+
cmd := exec.Command("go", "build", fragPkg)
|
|
369
|
+
cmd.Dir = dir
|
|
370
|
+
o, err := cmd.CombinedOutput()
|
|
371
|
+
out.Write(o)
|
|
372
|
+
if err != nil {
|
|
373
|
+
return out.String(), err
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if len(progDirs) > 0 {
|
|
377
|
+
args := append([]string{"build", "-o", binDir + string(os.PathSeparator)}, progDirs...)
|
|
378
|
+
cmd := exec.Command("go", args...)
|
|
379
|
+
cmd.Dir = dir
|
|
380
|
+
o, err := cmd.CombinedOutput()
|
|
381
|
+
out.Write(o)
|
|
382
|
+
if err != nil {
|
|
383
|
+
return out.String(), err
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return out.String(), nil
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
func extractFencedBlocks(md, lang string) []string {
|
|
390
|
+
var blocks []string
|
|
391
|
+
lines := strings.Split(md, "\\n")
|
|
392
|
+
open := "\`\`\`" + lang
|
|
393
|
+
inBlock := false
|
|
394
|
+
var cur []string
|
|
395
|
+
for _, line := range lines {
|
|
396
|
+
trimmed := strings.TrimSpace(line)
|
|
397
|
+
if !inBlock {
|
|
398
|
+
if trimmed == open {
|
|
399
|
+
inBlock = true
|
|
400
|
+
cur = nil
|
|
401
|
+
}
|
|
402
|
+
continue
|
|
403
|
+
}
|
|
404
|
+
if trimmed == "\`\`\`" {
|
|
405
|
+
blocks = append(blocks, strings.Join(cur, "\\n"))
|
|
406
|
+
inBlock = false
|
|
407
|
+
continue
|
|
408
|
+
}
|
|
409
|
+
cur = append(cur, line)
|
|
410
|
+
}
|
|
411
|
+
return blocks
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// isIllustration is the NARROW class of blocks that are intentionally not
|
|
415
|
+
// compiled:
|
|
416
|
+
// - a bare signature: a top-level func line with no body;
|
|
417
|
+
// - a comment-only block: nothing remains after stripping // and /* */;
|
|
418
|
+
// - a /* ... */ value-slot placeholder: a fill-in-the-blank template such as
|
|
419
|
+
// "field": /* type */, that is deliberately not compilable.
|
|
420
|
+
// Every other block is compiled or run.
|
|
421
|
+
func isIllustration(block string) bool {
|
|
422
|
+
trimmed := strings.TrimSpace(block)
|
|
423
|
+
if strings.HasPrefix(trimmed, "func ") && !strings.Contains(block, "{") {
|
|
424
|
+
return true
|
|
425
|
+
}
|
|
426
|
+
if strings.TrimSpace(stripGoComments(block)) == "" {
|
|
427
|
+
return true
|
|
428
|
+
}
|
|
429
|
+
if hasPlaceholderComment(block) {
|
|
430
|
+
return true
|
|
431
|
+
}
|
|
432
|
+
return false
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// hasPlaceholderComment reports whether the block uses a /* ... */ comment in a
|
|
436
|
+
// value slot — immediately after ':', '=', '(', '{' or ',' (ignoring spaces) —
|
|
437
|
+
// i.e. the comment stands in for a value (\`"field": /* type */,\`), making the
|
|
438
|
+
// block a non-compilable illustration. A /* ... */ elsewhere (an incidental
|
|
439
|
+
// block comment) is NOT a placeholder, so a block that merely contains one is
|
|
440
|
+
// left for the completeness gate to flag rather than silently skip.
|
|
441
|
+
func hasPlaceholderComment(block string) bool {
|
|
442
|
+
i := 0
|
|
443
|
+
for {
|
|
444
|
+
j := strings.Index(block[i:], "/*")
|
|
445
|
+
if j < 0 {
|
|
446
|
+
return false
|
|
447
|
+
}
|
|
448
|
+
start := i + j
|
|
449
|
+
p := start - 1
|
|
450
|
+
for p >= 0 && (block[p] == ' ' || block[p] == '\\t') {
|
|
451
|
+
p--
|
|
452
|
+
}
|
|
453
|
+
if p >= 0 {
|
|
454
|
+
switch block[p] {
|
|
455
|
+
case ':', '=', '(', '{', ',':
|
|
456
|
+
return true
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
end := strings.Index(block[start+2:], "*/")
|
|
460
|
+
if end < 0 {
|
|
461
|
+
return false
|
|
462
|
+
}
|
|
463
|
+
i = start + 2 + end + 2
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// stripGoComments removes /* ... */ block comments and // line comments so a
|
|
468
|
+
// placeholder-only block can be recognized.
|
|
469
|
+
func stripGoComments(s string) string {
|
|
470
|
+
var b strings.Builder
|
|
471
|
+
i := 0
|
|
472
|
+
for i < len(s) {
|
|
473
|
+
if i+1 < len(s) && s[i] == '/' && s[i+1] == '*' {
|
|
474
|
+
j := strings.Index(s[i+2:], "*/")
|
|
475
|
+
if j < 0 {
|
|
476
|
+
break
|
|
477
|
+
}
|
|
478
|
+
i = i + 2 + j + 2
|
|
479
|
+
continue
|
|
480
|
+
}
|
|
481
|
+
if i+1 < len(s) && s[i] == '/' && s[i+1] == '/' {
|
|
482
|
+
k := strings.IndexByte(s[i:], '\\n')
|
|
483
|
+
if k < 0 {
|
|
484
|
+
break
|
|
485
|
+
}
|
|
486
|
+
i += k
|
|
487
|
+
continue
|
|
488
|
+
}
|
|
489
|
+
b.WriteByte(s[i])
|
|
490
|
+
i++
|
|
491
|
+
}
|
|
492
|
+
return b.String()
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// stripImportLines drops any single-line \`import ...\` statement from a
|
|
496
|
+
// fragment. Quick-start fragments carry their own import line (e.g.
|
|
497
|
+
// \`import sdk "..."\`), which is illegal inside the function wrapper; the
|
|
498
|
+
// wrapper re-adds the correct imports itself.
|
|
499
|
+
func stripImportLines(block string) string {
|
|
500
|
+
var kept []string
|
|
501
|
+
for _, line := range strings.Split(block, "\\n") {
|
|
502
|
+
if strings.HasPrefix(strings.TrimSpace(line), "import ") {
|
|
503
|
+
continue
|
|
504
|
+
}
|
|
505
|
+
kept = append(kept, line)
|
|
506
|
+
}
|
|
507
|
+
return strings.Join(kept, "\\n")
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
func wrapFragment(name, block, modulePath string) string {
|
|
511
|
+
// Drop stray import lines and rewrite constructors to the seeded test
|
|
512
|
+
// client so placeholder args (options, testopts, ...) type-check.
|
|
513
|
+
block = stripImportLines(block)
|
|
514
|
+
if rewritten, ok := rewriteCtorsToTest(block); ok {
|
|
515
|
+
block = rewritten
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
declaresClient := strings.Contains(block, "client :=")
|
|
519
|
+
injectClient := !declaresClient && strings.Contains(block, "client")
|
|
520
|
+
|
|
521
|
+
needSdk := injectClient || strings.Contains(block, "sdk.")
|
|
522
|
+
usesFmt := strings.Contains(block, "fmt.")
|
|
523
|
+
usesOs := strings.Contains(block, "os.")
|
|
524
|
+
usesCore := strings.Contains(block, "core.")
|
|
525
|
+
usesEntity := strings.Contains(block, "entity.")
|
|
526
|
+
|
|
527
|
+
var imports []string
|
|
528
|
+
if usesFmt {
|
|
529
|
+
imports = append(imports, "\\t\\"fmt\\"")
|
|
530
|
+
}
|
|
531
|
+
if usesOs {
|
|
532
|
+
imports = append(imports, "\\t\\"os\\"")
|
|
533
|
+
}
|
|
534
|
+
if needSdk {
|
|
535
|
+
imports = append(imports, "\\tsdk \\""+modulePath+"\\"")
|
|
536
|
+
}
|
|
537
|
+
if usesCore {
|
|
538
|
+
imports = append(imports, "\\t\\""+modulePath+"/core\\"")
|
|
539
|
+
}
|
|
540
|
+
if usesEntity {
|
|
541
|
+
imports = append(imports, "\\t\\""+modulePath+"/entity\\"")
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
var b strings.Builder
|
|
545
|
+
b.WriteString("package readmefrag\\n\\n")
|
|
546
|
+
if len(imports) > 0 {
|
|
547
|
+
b.WriteString("import (\\n")
|
|
548
|
+
b.WriteString(strings.Join(imports, "\\n"))
|
|
549
|
+
b.WriteString("\\n)\\n\\n")
|
|
550
|
+
}
|
|
551
|
+
b.WriteString("func " + name + "() {\\n")
|
|
552
|
+
if injectClient {
|
|
553
|
+
// Seeded test client so the fragment's documented calls have data.
|
|
554
|
+
b.WriteString("\\tclient := sdk.TestSDK(" + testSeed + ", nil)\\n")
|
|
555
|
+
}
|
|
556
|
+
b.WriteString(block)
|
|
557
|
+
b.WriteString("\\n}\\n")
|
|
558
|
+
return b.String()
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
func applyFixes(out string, fragFiles map[string]string) bool {
|
|
562
|
+
changed := false
|
|
563
|
+
for _, line := range strings.Split(out, "\\n") {
|
|
564
|
+
if !strings.Contains(line, ".go:") {
|
|
565
|
+
continue
|
|
566
|
+
}
|
|
567
|
+
key := snipKeyFromLine(line)
|
|
568
|
+
if key == "" {
|
|
569
|
+
continue
|
|
570
|
+
}
|
|
571
|
+
content, ok := fragFiles[key]
|
|
572
|
+
if !ok {
|
|
573
|
+
continue
|
|
574
|
+
}
|
|
575
|
+
if strings.Contains(line, "imported and not used") {
|
|
576
|
+
pkg := quoted(line)
|
|
577
|
+
if pkg != "" {
|
|
578
|
+
nc := removeImportLine(content, pkg)
|
|
579
|
+
if nc != content {
|
|
580
|
+
fragFiles[key] = nc
|
|
581
|
+
changed = true
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
} else if strings.Contains(line, "not used") {
|
|
585
|
+
nm := unusedName(line)
|
|
586
|
+
if nm != "" {
|
|
587
|
+
fragFiles[key] = addBlankAssign(content, nm)
|
|
588
|
+
changed = true
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
return changed
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
func snipKeyFromLine(line string) string {
|
|
596
|
+
i := strings.Index(line, "snip")
|
|
597
|
+
if i < 0 {
|
|
598
|
+
return ""
|
|
599
|
+
}
|
|
600
|
+
rest := line[i:]
|
|
601
|
+
j := strings.Index(rest, ".go")
|
|
602
|
+
if j < 0 {
|
|
603
|
+
return ""
|
|
604
|
+
}
|
|
605
|
+
return rest[:j]
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
func quoted(line string) string {
|
|
609
|
+
a := strings.Index(line, "\\"")
|
|
610
|
+
if a < 0 {
|
|
611
|
+
return ""
|
|
612
|
+
}
|
|
613
|
+
b := strings.Index(line[a+1:], "\\"")
|
|
614
|
+
if b < 0 {
|
|
615
|
+
return ""
|
|
616
|
+
}
|
|
617
|
+
return line[a+1 : a+1+b]
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
func unusedName(line string) string {
|
|
621
|
+
marker := "not used:"
|
|
622
|
+
i := strings.Index(line, marker)
|
|
623
|
+
if i >= 0 {
|
|
624
|
+
return strings.TrimSpace(line[i+len(marker):])
|
|
625
|
+
}
|
|
626
|
+
// Fallback: "<name> declared but not used"
|
|
627
|
+
d := strings.Index(line, " declared")
|
|
628
|
+
if d < 0 {
|
|
629
|
+
return ""
|
|
630
|
+
}
|
|
631
|
+
head := strings.TrimSpace(line[:d])
|
|
632
|
+
parts := strings.Fields(head)
|
|
633
|
+
if len(parts) == 0 {
|
|
634
|
+
return ""
|
|
635
|
+
}
|
|
636
|
+
return parts[len(parts)-1]
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
func removeImportLine(content, pkg string) string {
|
|
640
|
+
needle := "\\"" + pkg + "\\""
|
|
641
|
+
var kept []string
|
|
642
|
+
for _, line := range strings.Split(content, "\\n") {
|
|
643
|
+
t := strings.TrimSpace(line)
|
|
644
|
+
// An import spec line ends with the quoted path (with optional
|
|
645
|
+
// alias prefix); the \`import (\` opener does not.
|
|
646
|
+
if strings.HasSuffix(t, needle) && !strings.HasPrefix(t, "import") {
|
|
647
|
+
continue
|
|
648
|
+
}
|
|
649
|
+
kept = append(kept, line)
|
|
650
|
+
}
|
|
651
|
+
return strings.Join(kept, "\\n")
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
func addBlankAssign(content, name string) string {
|
|
655
|
+
// Insert \`_ = name\` before the final closing brace of the func.
|
|
656
|
+
last := strings.LastIndex(content, "}")
|
|
657
|
+
if last < 0 {
|
|
658
|
+
return content
|
|
659
|
+
}
|
|
660
|
+
return content[:last] + "\\t_ = " + name + "\\n" + content[last:]
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
func readModulePath(moduleRoot string) string {
|
|
664
|
+
data, err := os.ReadFile(filepath.Join(moduleRoot, "go.mod"))
|
|
665
|
+
if err != nil {
|
|
666
|
+
return ""
|
|
667
|
+
}
|
|
668
|
+
for _, line := range strings.Split(string(data), "\\n") {
|
|
669
|
+
t := strings.TrimSpace(line)
|
|
670
|
+
if strings.HasPrefix(t, "module ") {
|
|
671
|
+
return strings.TrimSpace(strings.TrimPrefix(t, "module"))
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return ""
|
|
675
|
+
}
|
|
676
|
+
`)
|
|
677
|
+
})
|
|
678
|
+
|
|
679
|
+
})
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
export {
|
|
683
|
+
ReadmeExamplesTest
|
|
684
|
+
}
|
|
@@ -6,7 +6,7 @@ const ReadmeExplanation = cmp(function ReadmeExplanation(props: any) {
|
|
|
6
6
|
const { target, ctx$: { model } } = props
|
|
7
7
|
|
|
8
8
|
// Go module path == repo path on GitHub (org from model.origin).
|
|
9
|
-
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
|
|
9
|
+
const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
|
|
10
10
|
|
|
11
11
|
Content(`### Data as maps
|
|
12
12
|
|