@voxgig/sdkgen 0.35.2 → 0.37.0
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 +1 -1
- package/dist/cmp/Main.js +0 -12
- package/dist/cmp/Main.js.map +1 -1
- package/dist/cmp/Readme.js +5 -5
- package/dist/cmp/Readme.js.map +1 -1
- package/dist/cmp/ReadmeEntity.js +74 -24
- package/dist/cmp/ReadmeEntity.js.map +1 -1
- package/dist/cmp/ReadmeExplanation.d.ts +2 -0
- package/dist/cmp/ReadmeExplanation.js +308 -0
- package/dist/cmp/ReadmeExplanation.js.map +1 -0
- package/dist/cmp/ReadmeHowto.d.ts +2 -0
- package/dist/cmp/ReadmeHowto.js +18 -0
- package/dist/cmp/ReadmeHowto.js.map +1 -0
- package/dist/cmp/ReadmeIntro.js +8 -23
- package/dist/cmp/ReadmeIntro.js.map +1 -1
- package/dist/cmp/ReadmeModel.js +55 -91
- package/dist/cmp/ReadmeModel.js.map +1 -1
- package/dist/cmp/ReadmeOptions.js +35 -11
- package/dist/cmp/ReadmeOptions.js.map +1 -1
- package/dist/cmp/ReadmeQuick.js +4 -1
- package/dist/cmp/ReadmeQuick.js.map +1 -1
- package/dist/cmp/ReadmeRef.js +1042 -40
- package/dist/cmp/ReadmeRef.js.map +1 -1
- package/dist/cmp/ReadmeTop.d.ts +2 -0
- package/dist/cmp/ReadmeTop.js +171 -0
- package/dist/cmp/ReadmeTop.js.map +1 -0
- package/dist/sdkgen.d.ts +7 -1
- package/dist/sdkgen.js +13 -1
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/project/.sdk/model/feature/feature-index.jsonic +5 -0
- package/project/.sdk/model/feature/log.jsonic +5 -1
- package/project/.sdk/model/feature/test.jsonic +1 -1
- package/project/.sdk/model/target/lua.jsonic +23 -0
- package/project/.sdk/model/target/php.jsonic +22 -0
- package/project/.sdk/model/target/py.jsonic +23 -0
- package/project/.sdk/model/target/rb.jsonic +23 -0
- package/project/.sdk/src/cmp/go/Config_go.ts +6 -2
- package/project/.sdk/src/cmp/go/Main_go.ts +2 -6
- package/project/.sdk/src/cmp/go/ReadmeExplanation_go.ts +42 -0
- package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +112 -0
- package/project/.sdk/src/cmp/go/ReadmeInstall_go.ts +29 -0
- package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +129 -0
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +163 -0
- package/project/.sdk/src/cmp/go/ReadmeTopHowto_go.ts +24 -0
- package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +67 -0
- package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +40 -0
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +46 -2
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +360 -160
- package/project/.sdk/src/cmp/go/Test_go.ts +24 -1
- package/project/.sdk/src/cmp/js/EntityBase_js.ts +34 -0
- package/project/.sdk/src/cmp/js/Main_js.ts +10 -0
- package/project/.sdk/src/cmp/js/ReadmeExplanation_js.ts +33 -0
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +123 -0
- package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +152 -0
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +1 -1
- package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +25 -0
- package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +65 -0
- package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +36 -0
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +53 -5
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +114 -20
- package/project/.sdk/src/cmp/js/fragment/Entity.fragment.js +7 -139
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +149 -0
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +6 -10
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +6 -10
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +2 -0
- package/project/.sdk/src/cmp/js/fragment/SdkError.fragment.js +0 -2
- package/project/.sdk/src/cmp/lua/Config_lua.ts +116 -0
- package/project/.sdk/src/cmp/lua/EntityOperation_lua.ts +44 -0
- package/project/.sdk/src/cmp/lua/Entity_lua.ts +62 -0
- package/project/.sdk/src/cmp/lua/MainEntity_lua.ts +23 -0
- package/project/.sdk/src/cmp/lua/Main_lua.ts +133 -0
- package/project/.sdk/src/cmp/lua/Package_lua.ts +80 -0
- package/project/.sdk/src/cmp/lua/ReadmeExplanation_lua.ts +42 -0
- package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +100 -0
- package/project/.sdk/src/cmp/lua/ReadmeInstall_lua.ts +26 -0
- package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +129 -0
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +99 -0
- package/project/.sdk/src/cmp/lua/ReadmeTopHowto_lua.ts +24 -0
- package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +55 -0
- package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +38 -0
- package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +261 -0
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +485 -0
- package/project/.sdk/src/cmp/lua/Test_lua.ts +49 -0
- package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +147 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityCreateOp.fragment.lua +27 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityListOp.fragment.lua +24 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityLoadOp.fragment.lua +30 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityRemoveOp.fragment.lua +30 -0
- package/project/.sdk/src/cmp/lua/fragment/EntityUpdateOp.fragment.lua +30 -0
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +256 -0
- package/project/.sdk/src/cmp/lua/fragment/SdkError.fragment.lua +26 -0
- package/project/.sdk/src/cmp/lua/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/lua/utility_lua.ts +84 -0
- package/project/.sdk/src/cmp/php/Config_php.ts +111 -0
- package/project/.sdk/src/cmp/php/EntityOperation_php.ts +44 -0
- package/project/.sdk/src/cmp/php/Entity_php.ts +62 -0
- package/project/.sdk/src/cmp/php/MainEntity_php.ts +24 -0
- package/project/.sdk/src/cmp/php/Main_php.ts +135 -0
- package/project/.sdk/src/cmp/php/Package_php.ts +87 -0
- package/project/.sdk/src/cmp/php/ReadmeExplanation_php.ts +42 -0
- package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +101 -0
- package/project/.sdk/src/cmp/php/ReadmeInstall_php.ts +19 -0
- package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +129 -0
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +100 -0
- package/project/.sdk/src/cmp/php/ReadmeTopHowto_php.ts +24 -0
- package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +56 -0
- package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +38 -0
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +270 -0
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +479 -0
- package/project/.sdk/src/cmp/php/Test_php.ts +56 -0
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +146 -0
- package/project/.sdk/src/cmp/php/fragment/EntityCreateOp.fragment.php +26 -0
- package/project/.sdk/src/cmp/php/fragment/EntityListOp.fragment.php +23 -0
- package/project/.sdk/src/cmp/php/fragment/EntityLoadOp.fragment.php +29 -0
- package/project/.sdk/src/cmp/php/fragment/EntityRemoveOp.fragment.php +29 -0
- package/project/.sdk/src/cmp/php/fragment/EntityUpdateOp.fragment.php +29 -0
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +233 -0
- package/project/.sdk/src/cmp/php/fragment/SdkError.fragment.php +24 -0
- package/project/.sdk/src/cmp/php/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/php/utility_php.ts +85 -0
- package/project/.sdk/src/cmp/py/Config_py.ts +97 -0
- package/project/.sdk/src/cmp/py/EntityOperation_py.ts +44 -0
- package/project/.sdk/src/cmp/py/Entity_py.ts +62 -0
- package/project/.sdk/src/cmp/py/MainEntity_py.ts +22 -0
- package/project/.sdk/src/cmp/py/Main_py.ts +156 -0
- package/project/.sdk/src/cmp/py/Package_py.ts +75 -0
- package/project/.sdk/src/cmp/py/ReadmeExplanation_py.ts +41 -0
- package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +98 -0
- package/project/.sdk/src/cmp/py/ReadmeInstall_py.ts +25 -0
- package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +130 -0
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +100 -0
- package/project/.sdk/src/cmp/py/ReadmeTopHowto_py.ts +24 -0
- package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +56 -0
- package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +38 -0
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +248 -0
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +477 -0
- package/project/.sdk/src/cmp/py/Test_py.ts +55 -0
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +112 -0
- package/project/.sdk/src/cmp/py/fragment/EntityCreateOp.fragment.py +25 -0
- package/project/.sdk/src/cmp/py/fragment/EntityListOp.fragment.py +22 -0
- package/project/.sdk/src/cmp/py/fragment/EntityLoadOp.fragment.py +27 -0
- package/project/.sdk/src/cmp/py/fragment/EntityRemoveOp.fragment.py +27 -0
- package/project/.sdk/src/cmp/py/fragment/EntityUpdateOp.fragment.py +27 -0
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +222 -0
- package/project/.sdk/src/cmp/py/fragment/SdkError.fragment.py +16 -0
- package/project/.sdk/src/cmp/py/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/py/utility_py.ts +84 -0
- package/project/.sdk/src/cmp/rb/Config_rb.ts +105 -0
- package/project/.sdk/src/cmp/rb/EntityOperation_rb.ts +44 -0
- package/project/.sdk/src/cmp/rb/Entity_rb.ts +62 -0
- package/project/.sdk/src/cmp/rb/MainEntity_rb.ts +23 -0
- package/project/.sdk/src/cmp/rb/Main_rb.ts +130 -0
- package/project/.sdk/src/cmp/rb/Package_rb.ts +111 -0
- package/project/.sdk/src/cmp/rb/ReadmeExplanation_rb.ts +42 -0
- package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +98 -0
- package/project/.sdk/src/cmp/rb/ReadmeInstall_rb.ts +31 -0
- package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +129 -0
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +99 -0
- package/project/.sdk/src/cmp/rb/ReadmeTopHowto_rb.ts +24 -0
- package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +55 -0
- package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +38 -0
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +260 -0
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +476 -0
- package/project/.sdk/src/cmp/rb/Test_rb.ts +50 -0
- package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +116 -0
- package/project/.sdk/src/cmp/rb/fragment/EntityCreateOp.fragment.rb +25 -0
- package/project/.sdk/src/cmp/rb/fragment/EntityListOp.fragment.rb +20 -0
- package/project/.sdk/src/cmp/rb/fragment/EntityLoadOp.fragment.rb +26 -0
- package/project/.sdk/src/cmp/rb/fragment/EntityRemoveOp.fragment.rb +26 -0
- package/project/.sdk/src/cmp/rb/fragment/EntityUpdateOp.fragment.rb +26 -0
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +203 -0
- package/project/.sdk/src/cmp/rb/fragment/SdkError.fragment.rb +16 -0
- package/project/.sdk/src/cmp/rb/tsconfig.json +15 -0
- package/project/.sdk/src/cmp/rb/utility_rb.ts +84 -0
- package/project/.sdk/src/cmp/ts/Main_ts.ts +7 -0
- package/project/.sdk/src/cmp/ts/ReadmeExplanation_ts.ts +34 -0
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +123 -0
- package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts +1 -1
- package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +159 -0
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +69 -54
- package/project/.sdk/src/cmp/ts/ReadmeTopHowto_ts.ts +25 -0
- package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +65 -0
- package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +36 -0
- package/project/.sdk/tm/go/feature/log_feature.go +133 -0
- package/project/.sdk/tm/go/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/go/test/runner_test.go +16 -2
- package/project/.sdk/tm/js/src/Context.js +142 -0
- package/project/.sdk/tm/js/src/Control.js +16 -0
- package/project/.sdk/tm/js/src/Operation.js +19 -0
- package/project/.sdk/tm/js/src/Point.js +24 -0
- package/project/.sdk/tm/js/src/README.md +1 -0
- package/project/.sdk/tm/js/src/Response.js +19 -0
- package/project/.sdk/tm/js/src/Result.js +21 -0
- package/project/.sdk/tm/js/src/Spec.js +26 -0
- package/project/.sdk/tm/js/src/feature/README.md +1 -0
- package/project/.sdk/tm/js/src/feature/base/BaseFeature.js +45 -0
- package/project/.sdk/tm/js/src/feature/log/LogFeature.js +46 -47
- package/project/.sdk/tm/js/src/feature/test/TestFeature.js +207 -0
- package/project/.sdk/tm/js/src/types.js +22 -0
- package/project/.sdk/tm/js/src/utility/CleanUtility.js +31 -0
- package/project/.sdk/tm/js/src/utility/DoneUtility.js +11 -4
- package/project/.sdk/tm/js/src/utility/FeatureAddUtility.js +42 -0
- package/project/.sdk/tm/js/src/utility/FeatureHookUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/FeatureInitUtility.js +11 -0
- package/project/.sdk/tm/js/src/utility/FetcherUtility.js +28 -0
- package/project/.sdk/tm/js/src/utility/MakeContextUtility.js +11 -0
- package/project/.sdk/tm/js/src/utility/MakeErrorUtility.js +55 -0
- package/project/.sdk/tm/js/src/utility/MakeFetchDefUtility.js +44 -0
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +93 -0
- package/project/.sdk/tm/js/src/utility/MakePointUtility.js +77 -0
- package/project/.sdk/tm/js/src/utility/MakeRequestUtility.js +63 -0
- package/project/.sdk/tm/js/src/utility/MakeResponseUtility.js +55 -0
- package/project/.sdk/tm/js/src/utility/MakeResultUtility.js +54 -0
- package/project/.sdk/tm/js/src/utility/MakeSpecUtility.js +58 -0
- package/project/.sdk/tm/js/src/utility/MakeUrlUtility.js +40 -0
- package/project/.sdk/tm/js/src/utility/ParamUtility.js +61 -0
- package/project/.sdk/tm/js/src/utility/PrepareAuthUtility.js +41 -0
- package/project/.sdk/tm/js/src/utility/PrepareBodyUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/PrepareHeadersUtility.js +18 -0
- package/project/.sdk/tm/js/src/utility/{MethodUtility.js → PrepareMethodUtility.js} +7 -7
- package/project/.sdk/tm/js/src/utility/PrepareParamsUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/PreparePathUtility.js +13 -0
- package/project/.sdk/tm/js/src/utility/PrepareQueryUtility.js +26 -0
- package/project/.sdk/tm/js/src/utility/README.md +1 -0
- package/project/.sdk/tm/js/src/utility/ResultBasicUtility.js +34 -0
- package/project/.sdk/tm/js/src/utility/ResultBodyUtility.js +18 -0
- package/project/.sdk/tm/js/src/utility/ResultHeadersUtility.js +22 -0
- package/project/.sdk/tm/js/src/utility/StructUtility.js +2219 -1078
- package/project/.sdk/tm/js/src/utility/TransformRequestUtility.js +28 -0
- package/project/.sdk/tm/js/src/utility/TransformResponseUtility.js +31 -0
- package/project/.sdk/tm/js/src/utility/Utility.js +61 -61
- package/project/.sdk/tm/js/test/README.md +1 -0
- package/project/.sdk/tm/js/test/exists.test.js +16 -0
- package/project/.sdk/tm/js/test/runner.js +323 -107
- package/project/.sdk/tm/js/test/utility/Custom.test.js +41 -63
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +390 -116
- package/project/.sdk/tm/js/test/utility/StructUtility.test.js +728 -175
- package/project/.sdk/tm/js/test/utility/index.js +9 -0
- package/project/.sdk/tm/js/test/utility.js +72 -0
- package/project/.sdk/tm/lua/LICENSE +22 -0
- package/project/.sdk/tm/lua/Makefile +10 -0
- package/project/.sdk/tm/lua/core/context.lua +208 -0
- package/project/.sdk/tm/lua/core/control.lua +17 -0
- package/project/.sdk/tm/lua/core/error.lua +30 -0
- package/project/.sdk/tm/lua/core/helpers.lua +30 -0
- package/project/.sdk/tm/lua/core/operation.lua +51 -0
- package/project/.sdk/tm/lua/core/response.lua +45 -0
- package/project/.sdk/tm/lua/core/result.lua +58 -0
- package/project/.sdk/tm/lua/core/spec.lua +29 -0
- package/project/.sdk/tm/lua/core/utility_type.lua +90 -0
- package/project/.sdk/tm/lua/feature/base_feature.lua +35 -0
- package/project/.sdk/tm/lua/feature/log_feature.lua +80 -0
- package/project/.sdk/tm/lua/feature/test_feature.lua +202 -0
- package/project/.sdk/tm/lua/src/feature/README.md +3 -0
- package/project/.sdk/tm/lua/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/lua/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/lua/test/primary_utility_test.lua +1213 -0
- package/project/.sdk/tm/lua/test/runner.lua +86 -0
- package/project/.sdk/tm/lua/test/struct_runner.lua +602 -0
- package/project/.sdk/tm/lua/test/struct_utility_test.lua +959 -0
- package/project/.sdk/tm/lua/utility/clean.lua +7 -0
- package/project/.sdk/tm/lua/utility/done.lua +19 -0
- package/project/.sdk/tm/lua/utility/feature_add.lua +8 -0
- package/project/.sdk/tm/lua/utility/feature_hook.lua +21 -0
- package/project/.sdk/tm/lua/utility/feature_init.lua +24 -0
- package/project/.sdk/tm/lua/utility/fetcher.lua +96 -0
- package/project/.sdk/tm/lua/utility/make_context.lua +9 -0
- package/project/.sdk/tm/lua/utility/make_error.lua +73 -0
- package/project/.sdk/tm/lua/utility/make_fetch_def.lua +43 -0
- package/project/.sdk/tm/lua/utility/make_options.lua +116 -0
- package/project/.sdk/tm/lua/utility/make_point.lua +92 -0
- package/project/.sdk/tm/lua/utility/make_request.lua +58 -0
- package/project/.sdk/tm/lua/utility/make_response.lua +44 -0
- package/project/.sdk/tm/lua/utility/make_result.lua +51 -0
- package/project/.sdk/tm/lua/utility/make_spec.lua +72 -0
- package/project/.sdk/tm/lua/utility/make_url.lua +46 -0
- package/project/.sdk/tm/lua/utility/param.lua +68 -0
- package/project/.sdk/tm/lua/utility/prepare_auth.lua +39 -0
- package/project/.sdk/tm/lua/utility/prepare_body.lua +14 -0
- package/project/.sdk/tm/lua/utility/prepare_headers.lua +20 -0
- package/project/.sdk/tm/lua/utility/prepare_method.lua +17 -0
- package/project/.sdk/tm/lua/utility/prepare_params.lua +36 -0
- package/project/.sdk/tm/lua/utility/prepare_path.lua +19 -0
- package/project/.sdk/tm/lua/utility/prepare_query.lua +41 -0
- package/project/.sdk/tm/lua/utility/register.lua +71 -0
- package/project/.sdk/tm/lua/utility/result_basic.lua +32 -0
- package/project/.sdk/tm/lua/utility/result_body.lua +17 -0
- package/project/.sdk/tm/lua/utility/result_headers.lua +22 -0
- package/project/.sdk/tm/lua/utility/struct/struct.lua +3427 -0
- package/project/.sdk/tm/lua/utility/transform_request.lua +31 -0
- package/project/.sdk/tm/lua/utility/transform_response.lua +44 -0
- package/project/.sdk/tm/php/LICENSE +22 -0
- package/project/.sdk/tm/php/Makefile +10 -0
- package/project/.sdk/tm/php/core/Context.php +139 -0
- package/project/.sdk/tm/php/core/Control.php +18 -0
- package/project/.sdk/tm/php/core/Error.php +37 -0
- package/project/.sdk/tm/php/core/Helpers.php +25 -0
- package/project/.sdk/tm/php/core/Operation.php +36 -0
- package/project/.sdk/tm/php/core/Response.php +30 -0
- package/project/.sdk/tm/php/core/Result.php +35 -0
- package/project/.sdk/tm/php/core/Spec.php +38 -0
- package/project/.sdk/tm/php/core/UtilityType.php +89 -0
- package/project/.sdk/tm/php/feature/BaseFeature.php +37 -0
- package/project/.sdk/tm/php/feature/LogFeature.php +65 -0
- package/project/.sdk/tm/php/feature/TestFeature.php +156 -0
- package/project/.sdk/tm/php/src/feature/README.md +3 -0
- package/project/.sdk/tm/php/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/php/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +1309 -0
- package/project/.sdk/tm/php/test/Runner.php +112 -0
- package/project/.sdk/tm/php/test/StructRunner.php +275 -0
- package/project/.sdk/tm/php/test/StructUtilityTest.php +1336 -0
- package/project/.sdk/tm/php/utility/Clean.php +12 -0
- package/project/.sdk/tm/php/utility/Done.php +26 -0
- package/project/.sdk/tm/php/utility/FeatureAdd.php +12 -0
- package/project/.sdk/tm/php/utility/FeatureHook.php +23 -0
- package/project/.sdk/tm/php/utility/FeatureInit.php +25 -0
- package/project/.sdk/tm/php/utility/Fetcher.php +105 -0
- package/project/.sdk/tm/php/utility/MakeContext.php +14 -0
- package/project/.sdk/tm/php/utility/MakeError.php +59 -0
- package/project/.sdk/tm/php/utility/MakeFetchDef.php +36 -0
- package/project/.sdk/tm/php/utility/MakeOptions.php +102 -0
- package/project/.sdk/tm/php/utility/MakePoint.php +87 -0
- package/project/.sdk/tm/php/utility/MakeRequest.php +57 -0
- package/project/.sdk/tm/php/utility/MakeResponse.php +43 -0
- package/project/.sdk/tm/php/utility/MakeResult.php +53 -0
- package/project/.sdk/tm/php/utility/MakeSpec.php +64 -0
- package/project/.sdk/tm/php/utility/MakeUrl.php +41 -0
- package/project/.sdk/tm/php/utility/Param.php +68 -0
- package/project/.sdk/tm/php/utility/PrepareAuth.php +33 -0
- package/project/.sdk/tm/php/utility/PrepareBody.php +15 -0
- package/project/.sdk/tm/php/utility/PrepareHeaders.php +18 -0
- package/project/.sdk/tm/php/utility/PrepareMethod.php +21 -0
- package/project/.sdk/tm/php/utility/PrepareParams.php +34 -0
- package/project/.sdk/tm/php/utility/PreparePath.php +20 -0
- package/project/.sdk/tm/php/utility/PrepareQuery.php +32 -0
- package/project/.sdk/tm/php/utility/Register.php +67 -0
- package/project/.sdk/tm/php/utility/ResultBasic.php +29 -0
- package/project/.sdk/tm/php/utility/ResultBody.php +17 -0
- package/project/.sdk/tm/php/utility/ResultHeaders.php +21 -0
- package/project/.sdk/tm/php/utility/TransformRequest.php +27 -0
- package/project/.sdk/tm/php/utility/TransformResponse.php +42 -0
- package/project/.sdk/tm/php/utility/struct/Struct.php +3535 -0
- package/project/.sdk/tm/py/Makefile +10 -0
- package/project/.sdk/tm/py/core/__init__.py +0 -0
- package/project/.sdk/tm/py/core/context.py +199 -0
- package/project/.sdk/tm/py/core/control.py +12 -0
- package/project/.sdk/tm/py/core/error.py +18 -0
- package/project/.sdk/tm/py/core/helpers.py +15 -0
- package/project/.sdk/tm/py/core/operation.py +37 -0
- package/project/.sdk/tm/py/core/response.py +34 -0
- package/project/.sdk/tm/py/core/result.py +44 -0
- package/project/.sdk/tm/py/core/spec.py +23 -0
- package/project/.sdk/tm/py/core/utility_type.py +82 -0
- package/project/.sdk/tm/py/entity/__init__.py +0 -0
- package/project/.sdk/tm/py/feature/__init__.py +0 -0
- package/project/.sdk/tm/py/feature/base_feature.py +61 -0
- package/project/.sdk/tm/py/feature/log_feature.py +84 -0
- package/project/.sdk/tm/py/feature/test_feature.py +164 -0
- package/project/.sdk/tm/py/src/feature/README.md +3 -0
- package/project/.sdk/tm/py/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/py/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/py/test/__init__.py +0 -0
- package/project/.sdk/tm/py/test/runner.py +90 -0
- package/project/.sdk/tm/py/test/struct_runner.py +411 -0
- package/project/.sdk/tm/py/test/test_primary_utility.py +1101 -0
- package/project/.sdk/tm/py/test/test_struct_utility.py +751 -0
- package/project/.sdk/tm/py/utility/__init__.py +0 -0
- package/project/.sdk/tm/py/utility/clean.py +5 -0
- package/project/.sdk/tm/py/utility/done.py +14 -0
- package/project/.sdk/tm/py/utility/feature_add.py +6 -0
- package/project/.sdk/tm/py/utility/feature_hook.py +15 -0
- package/project/.sdk/tm/py/utility/feature_init.py +18 -0
- package/project/.sdk/tm/py/utility/fetcher.py +95 -0
- package/project/.sdk/tm/py/utility/make_context.py +7 -0
- package/project/.sdk/tm/py/utility/make_error.py +64 -0
- package/project/.sdk/tm/py/utility/make_fetch_def.py +37 -0
- package/project/.sdk/tm/py/utility/make_options.py +103 -0
- package/project/.sdk/tm/py/utility/make_point.py +74 -0
- package/project/.sdk/tm/py/utility/make_request.py +52 -0
- package/project/.sdk/tm/py/utility/make_response.py +36 -0
- package/project/.sdk/tm/py/utility/make_result.py +41 -0
- package/project/.sdk/tm/py/utility/make_spec.py +68 -0
- package/project/.sdk/tm/py/utility/make_url.py +34 -0
- package/project/.sdk/tm/py/utility/param.py +55 -0
- package/project/.sdk/tm/py/utility/prepare_auth.py +34 -0
- package/project/.sdk/tm/py/utility/prepare_body.py +11 -0
- package/project/.sdk/tm/py/utility/prepare_headers.py +17 -0
- package/project/.sdk/tm/py/utility/prepare_method.py +15 -0
- package/project/.sdk/tm/py/utility/prepare_params.py +28 -0
- package/project/.sdk/tm/py/utility/prepare_path.py +16 -0
- package/project/.sdk/tm/py/utility/prepare_query.py +33 -0
- package/project/.sdk/tm/py/utility/register.py +68 -0
- package/project/.sdk/tm/py/utility/result_basic.py +26 -0
- package/project/.sdk/tm/py/utility/result_body.py +13 -0
- package/project/.sdk/tm/py/utility/result_headers.py +17 -0
- package/project/.sdk/tm/py/utility/transform_request.py +27 -0
- package/project/.sdk/tm/py/utility/transform_response.py +39 -0
- package/project/.sdk/tm/py/utility/voxgig_struct/__init__.py +72 -0
- package/project/.sdk/tm/py/utility/voxgig_struct/voxgig_struct.py +2770 -0
- package/project/.sdk/tm/rb/Gemfile +4 -0
- package/project/.sdk/tm/rb/LICENSE +22 -0
- package/project/.sdk/tm/rb/Makefile +10 -0
- package/project/.sdk/tm/rb/core/context.rb +105 -0
- package/project/.sdk/tm/rb/core/control.rb +11 -0
- package/project/.sdk/tm/rb/core/error.rb +24 -0
- package/project/.sdk/tm/rb/core/helpers.rb +16 -0
- package/project/.sdk/tm/rb/core/operation.rb +26 -0
- package/project/.sdk/tm/rb/core/response.rb +20 -0
- package/project/.sdk/tm/rb/core/result.rb +23 -0
- package/project/.sdk/tm/rb/core/spec.rb +23 -0
- package/project/.sdk/tm/rb/core/utility_type.rb +32 -0
- package/project/.sdk/tm/rb/feature/base_feature.rb +30 -0
- package/project/.sdk/tm/rb/feature/log_feature.rb +50 -0
- package/project/.sdk/tm/rb/feature/test_feature.rb +154 -0
- package/project/.sdk/tm/rb/src/feature/README.md +3 -0
- package/project/.sdk/tm/rb/src/feature/base/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/rb/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +1083 -0
- package/project/.sdk/tm/rb/test/runner.rb +70 -0
- package/project/.sdk/tm/rb/test/struct_runner.rb +309 -0
- package/project/.sdk/tm/rb/test/struct_utility_test.rb +670 -0
- package/project/.sdk/tm/rb/utility/clean.rb +4 -0
- package/project/.sdk/tm/rb/utility/done.rb +14 -0
- package/project/.sdk/tm/rb/utility/feature_add.rb +6 -0
- package/project/.sdk/tm/rb/utility/feature_hook.rb +11 -0
- package/project/.sdk/tm/rb/utility/feature_init.rb +16 -0
- package/project/.sdk/tm/rb/utility/fetcher.rb +67 -0
- package/project/.sdk/tm/rb/utility/make_context.rb +7 -0
- package/project/.sdk/tm/rb/utility/make_error.rb +44 -0
- package/project/.sdk/tm/rb/utility/make_fetch_def.rb +24 -0
- package/project/.sdk/tm/rb/utility/make_options.rb +57 -0
- package/project/.sdk/tm/rb/utility/make_point.rb +77 -0
- package/project/.sdk/tm/rb/utility/make_request.rb +44 -0
- package/project/.sdk/tm/rb/utility/make_response.rb +25 -0
- package/project/.sdk/tm/rb/utility/make_result.rb +33 -0
- package/project/.sdk/tm/rb/utility/make_spec.rb +50 -0
- package/project/.sdk/tm/rb/utility/make_url.rb +32 -0
- package/project/.sdk/tm/rb/utility/param.rb +48 -0
- package/project/.sdk/tm/rb/utility/prepare_auth.rb +26 -0
- package/project/.sdk/tm/rb/utility/prepare_body.rb +6 -0
- package/project/.sdk/tm/rb/utility/prepare_headers.rb +11 -0
- package/project/.sdk/tm/rb/utility/prepare_method.rb +5 -0
- package/project/.sdk/tm/rb/utility/prepare_params.rb +25 -0
- package/project/.sdk/tm/rb/utility/prepare_path.rb +13 -0
- package/project/.sdk/tm/rb/utility/prepare_query.rb +22 -0
- package/project/.sdk/tm/rb/utility/register.rb +63 -0
- package/project/.sdk/tm/rb/utility/result_basic.rb +23 -0
- package/project/.sdk/tm/rb/utility/result_body.rb +11 -0
- package/project/.sdk/tm/rb/utility/result_headers.rb +15 -0
- package/project/.sdk/tm/rb/utility/struct/voxgig_struct.rb +2256 -0
- package/project/.sdk/tm/rb/utility/transform_request.rb +15 -0
- package/project/.sdk/tm/rb/utility/transform_response.rb +23 -0
- package/src/cmp/Main.ts +1 -16
- package/src/cmp/Readme.ts +5 -5
- package/src/cmp/ReadmeEntity.ts +77 -25
- package/src/cmp/ReadmeExplanation.ts +333 -0
- package/src/cmp/ReadmeHowto.ts +28 -0
- package/src/cmp/ReadmeIntro.ts +10 -24
- package/src/cmp/ReadmeModel.ts +57 -88
- package/src/cmp/ReadmeOptions.ts +40 -11
- package/src/cmp/ReadmeQuick.ts +4 -1
- package/src/cmp/ReadmeRef.ts +1057 -40
- package/src/cmp/ReadmeTop.ts +213 -0
- package/src/sdkgen.ts +12 -0
- package/project/.sdk/src/cmp/js/Quick_js.ts +0 -78
- package/project/.sdk/src/cmp/js/TestAcceptEntity_js.ts +0 -13
- package/project/.sdk/src/cmp/js/TestAccept_js.ts +0 -18
- package/project/.sdk/tm/go/test/exists_test.go +0 -16
- package/project/.sdk/tm/js/src/utility/AuthUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/BodyUtility.js +0 -29
- package/project/.sdk/tm/js/src/utility/ErrorUtility.js +0 -33
- package/project/.sdk/tm/js/src/utility/FindparamUtility.js +0 -31
- package/project/.sdk/tm/js/src/utility/FullurlUtility.js +0 -39
- package/project/.sdk/tm/js/src/utility/HeadersUtility.js +0 -13
- package/project/.sdk/tm/js/src/utility/JoinurlUtility.js +0 -14
- package/project/.sdk/tm/js/src/utility/OperatorUtility.js +0 -44
- package/project/.sdk/tm/js/src/utility/OptionsUtility.js +0 -54
- package/project/.sdk/tm/js/src/utility/ParamsUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/QueryUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/ReqformUtility.js +0 -32
- package/project/.sdk/tm/js/src/utility/RequestUtility.js +0 -48
- package/project/.sdk/tm/js/src/utility/ResbasicUtility.js +0 -27
- package/project/.sdk/tm/js/src/utility/ResbodyUtility.js +0 -15
- package/project/.sdk/tm/js/src/utility/ResformUtility.js +0 -34
- package/project/.sdk/tm/js/src/utility/ResheadersUtility.js +0 -19
- package/project/.sdk/tm/js/src/utility/ResponseUtility.js +0 -37
- package/project/.sdk/tm/js/src/utility/ResultUtility.js +0 -28
- package/project/.sdk/tm/js/src/utility/SpecUtility.js +0 -35
|
@@ -0,0 +1,1083 @@
|
|
|
1
|
+
# ProjectName SDK primary utility test
|
|
2
|
+
|
|
3
|
+
require "minitest/autorun"
|
|
4
|
+
require "json"
|
|
5
|
+
require_relative "../ProjectName_sdk"
|
|
6
|
+
require_relative "runner"
|
|
7
|
+
|
|
8
|
+
class PrimaryUtilityTest < Minitest::Test
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@spec = load_test_spec
|
|
12
|
+
@primary = get_spec(@spec, "primary")
|
|
13
|
+
assert @primary, "primary section not found in test.json"
|
|
14
|
+
|
|
15
|
+
@client = ProjectNameSDK.test(nil, nil)
|
|
16
|
+
@utility = @client.get_utility
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# === exists ===
|
|
21
|
+
|
|
22
|
+
def test_exists
|
|
23
|
+
assert @utility.clean, "clean should not be nil"
|
|
24
|
+
assert @utility.done, "done should not be nil"
|
|
25
|
+
assert @utility.make_error, "make_error should not be nil"
|
|
26
|
+
assert @utility.feature_add, "feature_add should not be nil"
|
|
27
|
+
assert @utility.feature_hook, "feature_hook should not be nil"
|
|
28
|
+
assert @utility.feature_init, "feature_init should not be nil"
|
|
29
|
+
assert @utility.fetcher, "fetcher should not be nil"
|
|
30
|
+
assert @utility.make_fetch_def, "make_fetch_def should not be nil"
|
|
31
|
+
assert @utility.make_context, "make_context should not be nil"
|
|
32
|
+
assert @utility.make_options, "make_options should not be nil"
|
|
33
|
+
assert @utility.make_request, "make_request should not be nil"
|
|
34
|
+
assert @utility.make_response, "make_response should not be nil"
|
|
35
|
+
assert @utility.make_result, "make_result should not be nil"
|
|
36
|
+
assert @utility.make_point, "make_point should not be nil"
|
|
37
|
+
assert @utility.make_spec, "make_spec should not be nil"
|
|
38
|
+
assert @utility.make_url, "make_url should not be nil"
|
|
39
|
+
assert @utility.param, "param should not be nil"
|
|
40
|
+
assert @utility.prepare_auth, "prepare_auth should not be nil"
|
|
41
|
+
assert @utility.prepare_body, "prepare_body should not be nil"
|
|
42
|
+
assert @utility.prepare_headers, "prepare_headers should not be nil"
|
|
43
|
+
assert @utility.prepare_method, "prepare_method should not be nil"
|
|
44
|
+
assert @utility.prepare_params, "prepare_params should not be nil"
|
|
45
|
+
assert @utility.prepare_path, "prepare_path should not be nil"
|
|
46
|
+
assert @utility.prepare_query, "prepare_query should not be nil"
|
|
47
|
+
assert @utility.result_basic, "result_basic should not be nil"
|
|
48
|
+
assert @utility.result_body, "result_body should not be nil"
|
|
49
|
+
assert @utility.result_headers, "result_headers should not be nil"
|
|
50
|
+
assert @utility.transform_request, "transform_request should not be nil"
|
|
51
|
+
assert @utility.transform_response, "transform_response should not be nil"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# === clean ===
|
|
56
|
+
|
|
57
|
+
def test_clean_basic
|
|
58
|
+
ctx = make_test_ctx(@client, @utility, nil)
|
|
59
|
+
val = { "key" => "secret123", "name" => "test" }
|
|
60
|
+
cleaned = @utility.clean.call(ctx, val)
|
|
61
|
+
assert cleaned, "cleaned should not be nil"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# === done ===
|
|
66
|
+
|
|
67
|
+
def test_done_basic
|
|
68
|
+
runset(get_spec(@primary, "done", "basic")) do |entry|
|
|
69
|
+
ctxmap = entry["ctx"] || {}
|
|
70
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
71
|
+
fixctx(ctx, @client)
|
|
72
|
+
@utility.done.call(ctx)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# === makeError ===
|
|
78
|
+
|
|
79
|
+
def test_make_error_basic
|
|
80
|
+
runset(get_spec(@primary, "makeError", "basic")) do |entry|
|
|
81
|
+
args = entry["args"] || [{}]
|
|
82
|
+
|
|
83
|
+
ctxmap = args[0].is_a?(Hash) ? args[0] : {}
|
|
84
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
85
|
+
fixctx(ctx, @client)
|
|
86
|
+
|
|
87
|
+
err = nil
|
|
88
|
+
if args.length > 1 && args[1].is_a?(Hash)
|
|
89
|
+
err = err_from_map(args[1])
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
@utility.make_error.call(ctx, err)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def test_make_error_no_throw
|
|
97
|
+
ctx = make_test_full_ctx(@client, @utility)
|
|
98
|
+
ctx.ctrl.throw_err = false
|
|
99
|
+
ctx.result = ProjectNameResult.new({
|
|
100
|
+
"ok" => false,
|
|
101
|
+
"resdata" => { "id" => "safe01" },
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
out, err = @utility.make_error.call(ctx, ctx.make_error("test_code", "test message"))
|
|
105
|
+
assert_nil err, "expected no error"
|
|
106
|
+
assert out.is_a?(Hash), "expected hash result, got: #{out.class}"
|
|
107
|
+
assert_equal "safe01", out["id"], "expected id=safe01"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# === featureAdd ===
|
|
112
|
+
|
|
113
|
+
def test_feature_add_basic
|
|
114
|
+
ctx = make_test_ctx(@client, @utility, nil)
|
|
115
|
+
start_len = @client.features.length
|
|
116
|
+
|
|
117
|
+
feature = ProjectNameBaseFeature.new
|
|
118
|
+
@utility.feature_add.call(ctx, feature)
|
|
119
|
+
|
|
120
|
+
assert_equal start_len + 1, @client.features.length,
|
|
121
|
+
"expected #{start_len + 1} features, got #{@client.features.length}"
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# === featureHook ===
|
|
126
|
+
|
|
127
|
+
def test_feature_hook_basic
|
|
128
|
+
hook_client = ProjectNameSDK.test(nil, nil)
|
|
129
|
+
hook_utility = hook_client.get_utility
|
|
130
|
+
ctx = make_test_ctx(hook_client, hook_utility, nil)
|
|
131
|
+
|
|
132
|
+
called = false
|
|
133
|
+
hook_feature = TestHookFeature.new { called = true }
|
|
134
|
+
hook_client.features = [hook_feature]
|
|
135
|
+
|
|
136
|
+
hook_utility.feature_hook.call(ctx, "TestHook")
|
|
137
|
+
assert called, "expected TestHook to be called"
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
# === featureInit ===
|
|
142
|
+
|
|
143
|
+
def test_feature_init_basic
|
|
144
|
+
init_client = ProjectNameSDK.test(nil, nil)
|
|
145
|
+
init_utility = init_client.get_utility
|
|
146
|
+
ctx = make_test_ctx(init_client, init_utility, nil)
|
|
147
|
+
ctx.options["feature"] = {
|
|
148
|
+
"initfeat" => { "active" => true },
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
init_called = false
|
|
152
|
+
feature = TestInitFeature.new("initfeat", true) { init_called = true }
|
|
153
|
+
|
|
154
|
+
init_utility.feature_init.call(ctx, feature)
|
|
155
|
+
assert init_called, "expected init to be called"
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_feature_init_inactive
|
|
159
|
+
init_client = ProjectNameSDK.test(nil, nil)
|
|
160
|
+
init_utility = init_client.get_utility
|
|
161
|
+
ctx = make_test_ctx(init_client, init_utility, nil)
|
|
162
|
+
ctx.options["feature"] = {
|
|
163
|
+
"nofeat" => { "active" => false },
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
init_called = false
|
|
167
|
+
feature = TestInitFeature.new("nofeat", false) { init_called = true }
|
|
168
|
+
|
|
169
|
+
init_utility.feature_init.call(ctx, feature)
|
|
170
|
+
refute init_called, "expected init NOT to be called for inactive feature"
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# === fetcher ===
|
|
175
|
+
|
|
176
|
+
def test_fetcher_live
|
|
177
|
+
calls = []
|
|
178
|
+
live_client = ProjectNameSDK.new({
|
|
179
|
+
"system" => {
|
|
180
|
+
"fetch" => ->(url, fetchdef) {
|
|
181
|
+
calls << { "url" => url, "init" => fetchdef }
|
|
182
|
+
return { "status" => 200, "statusText" => "OK" }, nil
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
})
|
|
186
|
+
live_utility = live_client.get_utility
|
|
187
|
+
ctx = live_utility.make_context.call({
|
|
188
|
+
"opname" => "load",
|
|
189
|
+
"client" => live_client,
|
|
190
|
+
"utility" => live_utility,
|
|
191
|
+
}, nil)
|
|
192
|
+
|
|
193
|
+
fetchdef = { "method" => "GET", "headers" => {} }
|
|
194
|
+
_, err = live_utility.fetcher.call(ctx, "http://example.com/test", fetchdef)
|
|
195
|
+
assert_nil err, "expected no error, got: #{err}"
|
|
196
|
+
assert_equal 1, calls.length, "expected 1 call, got #{calls.length}"
|
|
197
|
+
assert_equal "http://example.com/test", calls[0]["url"]
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def test_fetcher_blocked_test_mode
|
|
201
|
+
blocked_client = ProjectNameSDK.new({
|
|
202
|
+
"system" => {
|
|
203
|
+
"fetch" => ->(url, fetchdef) {
|
|
204
|
+
return {}, nil
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
})
|
|
208
|
+
blocked_client.mode = "test"
|
|
209
|
+
|
|
210
|
+
blocked_utility = blocked_client.get_utility
|
|
211
|
+
ctx = blocked_utility.make_context.call({
|
|
212
|
+
"opname" => "load",
|
|
213
|
+
"client" => blocked_client,
|
|
214
|
+
"utility" => blocked_utility,
|
|
215
|
+
}, nil)
|
|
216
|
+
|
|
217
|
+
fetchdef = { "method" => "GET", "headers" => {} }
|
|
218
|
+
_, err = blocked_utility.fetcher.call(ctx, "http://example.com/test", fetchdef)
|
|
219
|
+
assert err, "expected error for test mode fetch"
|
|
220
|
+
assert_match(/blocked/, err.to_s, "expected error containing 'blocked'")
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
# === makeContext ===
|
|
225
|
+
|
|
226
|
+
def test_make_context_basic
|
|
227
|
+
runset(get_spec(@primary, "makeContext", "basic")) do |entry|
|
|
228
|
+
in_val = entry["in"]
|
|
229
|
+
if in_val.is_a?(Hash)
|
|
230
|
+
ctx = @utility.make_context.call(in_val, nil)
|
|
231
|
+
out = { "id" => ctx.id }
|
|
232
|
+
if ctx.op
|
|
233
|
+
out["op"] = {
|
|
234
|
+
"name" => ctx.op.name,
|
|
235
|
+
"input" => ctx.op.input,
|
|
236
|
+
}
|
|
237
|
+
end
|
|
238
|
+
out
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
# === makeFetchDef ===
|
|
245
|
+
|
|
246
|
+
def test_make_fetch_def_basic
|
|
247
|
+
ctx = make_test_full_ctx(@client, @utility)
|
|
248
|
+
ctx.spec = ProjectNameSpec.new({
|
|
249
|
+
"base" => "http://localhost:8080",
|
|
250
|
+
"prefix" => "/api",
|
|
251
|
+
"path" => "items/{id}",
|
|
252
|
+
"suffix" => "",
|
|
253
|
+
"params" => { "id" => "item01" },
|
|
254
|
+
"query" => {},
|
|
255
|
+
"headers" => { "content-type" => "application/json" },
|
|
256
|
+
"method" => "GET",
|
|
257
|
+
"step" => "start",
|
|
258
|
+
})
|
|
259
|
+
ctx.result = ProjectNameResult.new({})
|
|
260
|
+
|
|
261
|
+
fetchdef, err = @utility.make_fetch_def.call(ctx)
|
|
262
|
+
assert_nil err, "should not be error: #{err}"
|
|
263
|
+
assert_equal "GET", fetchdef["method"]
|
|
264
|
+
url = fetchdef["url"] || ""
|
|
265
|
+
assert_includes url, "/api/items/item01"
|
|
266
|
+
assert_equal "application/json", fetchdef["headers"]["content-type"]
|
|
267
|
+
assert_nil fetchdef["body"], "expected nil body"
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def test_make_fetch_def_with_body
|
|
271
|
+
ctx = make_test_full_ctx(@client, @utility)
|
|
272
|
+
ctx.spec = ProjectNameSpec.new({
|
|
273
|
+
"base" => "http://localhost:8080",
|
|
274
|
+
"prefix" => "",
|
|
275
|
+
"path" => "items",
|
|
276
|
+
"suffix" => "",
|
|
277
|
+
"params" => {},
|
|
278
|
+
"query" => {},
|
|
279
|
+
"headers" => {},
|
|
280
|
+
"method" => "POST",
|
|
281
|
+
"step" => "start",
|
|
282
|
+
"body" => { "name" => "test" },
|
|
283
|
+
})
|
|
284
|
+
ctx.result = ProjectNameResult.new({})
|
|
285
|
+
|
|
286
|
+
fetchdef, err = @utility.make_fetch_def.call(ctx)
|
|
287
|
+
assert_nil err, "should not be error: #{err}"
|
|
288
|
+
assert_equal "POST", fetchdef["method"]
|
|
289
|
+
body_str = fetchdef["body"]
|
|
290
|
+
assert body_str.is_a?(String), "expected body string, got #{body_str.class}"
|
|
291
|
+
assert_includes body_str, "\"name\""
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
# === makeOptions ===
|
|
296
|
+
|
|
297
|
+
def test_make_options_basic
|
|
298
|
+
runset(get_spec(@primary, "makeOptions", "basic")) do |entry|
|
|
299
|
+
in_val = entry["in"] || {}
|
|
300
|
+
ctx = @utility.make_context.call({
|
|
301
|
+
"options" => in_val["options"],
|
|
302
|
+
"config" => in_val["config"],
|
|
303
|
+
}, nil)
|
|
304
|
+
ctx.client = @client
|
|
305
|
+
ctx.utility = @utility
|
|
306
|
+
@utility.make_options.call(ctx)
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
# === makeRequest ===
|
|
312
|
+
|
|
313
|
+
def test_make_request_basic
|
|
314
|
+
runset(get_spec(@primary, "makeRequest", "basic")) do |entry|
|
|
315
|
+
ctxmap = entry["ctx"] || {}
|
|
316
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
317
|
+
ctx.options = @client.options_map
|
|
318
|
+
|
|
319
|
+
_, err = @utility.make_request.call(ctx)
|
|
320
|
+
raise err if err
|
|
321
|
+
|
|
322
|
+
# Update entry ctx for match checking
|
|
323
|
+
entry_ctx = entry["ctx"]
|
|
324
|
+
if entry_ctx.is_a?(Hash)
|
|
325
|
+
entry_ctx["response"] = "exists" if ctx.response
|
|
326
|
+
entry_ctx["result"] = "exists" if ctx.result
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
nil
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
# === makeResponse ===
|
|
335
|
+
|
|
336
|
+
def test_make_response_basic
|
|
337
|
+
runset(get_spec(@primary, "makeResponse", "basic")) do |entry|
|
|
338
|
+
ctxmap = entry["ctx"] || {}
|
|
339
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
340
|
+
fixctx(ctx, @client)
|
|
341
|
+
|
|
342
|
+
_, err = @utility.make_response.call(ctx)
|
|
343
|
+
raise err if err
|
|
344
|
+
|
|
345
|
+
# Update entry ctx for match checking with result data
|
|
346
|
+
entry_ctx = entry["ctx"]
|
|
347
|
+
if entry_ctx.is_a?(Hash) && ctx.result
|
|
348
|
+
entry_ctx["result"] = {
|
|
349
|
+
"ok" => ctx.result.ok,
|
|
350
|
+
"status" => ctx.result.status,
|
|
351
|
+
"statusText" => ctx.result.status_text,
|
|
352
|
+
"headers" => ctx.result.headers,
|
|
353
|
+
"body" => ctx.result.body,
|
|
354
|
+
}
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
nil
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
# === makeResult ===
|
|
363
|
+
|
|
364
|
+
def test_make_result_basic
|
|
365
|
+
ctx = make_test_full_ctx(@client, @utility)
|
|
366
|
+
ctx.spec = ProjectNameSpec.new({
|
|
367
|
+
"base" => "http://localhost:8080",
|
|
368
|
+
"prefix" => "/api",
|
|
369
|
+
"path" => "items/{id}",
|
|
370
|
+
"suffix" => "",
|
|
371
|
+
"params" => { "id" => "item01" },
|
|
372
|
+
"query" => {},
|
|
373
|
+
"headers" => {},
|
|
374
|
+
"method" => "GET",
|
|
375
|
+
"step" => "start",
|
|
376
|
+
})
|
|
377
|
+
ctx.result = ProjectNameResult.new({
|
|
378
|
+
"ok" => true,
|
|
379
|
+
"status" => 200,
|
|
380
|
+
"statusText" => "OK",
|
|
381
|
+
"headers" => {},
|
|
382
|
+
"resdata" => { "id" => "item01", "name" => "Test" },
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
result, err = @utility.make_result.call(ctx)
|
|
386
|
+
assert_nil err, "expected no error, got: #{err}"
|
|
387
|
+
assert_equal 200, result.status
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def test_make_result_no_spec
|
|
391
|
+
ctx = make_test_full_ctx(@client, @utility)
|
|
392
|
+
ctx.spec = nil
|
|
393
|
+
ctx.result = ProjectNameResult.new({
|
|
394
|
+
"ok" => true,
|
|
395
|
+
"status" => 200,
|
|
396
|
+
"statusText" => "OK",
|
|
397
|
+
"headers" => {},
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
_, err = @utility.make_result.call(ctx)
|
|
401
|
+
assert err, "expected error for nil spec"
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
def test_make_result_no_result
|
|
405
|
+
ctx = make_test_full_ctx(@client, @utility)
|
|
406
|
+
ctx.spec = ProjectNameSpec.new({ "step" => "start" })
|
|
407
|
+
ctx.result = nil
|
|
408
|
+
|
|
409
|
+
_, err = @utility.make_result.call(ctx)
|
|
410
|
+
assert err, "expected error for nil result"
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
# === makeSpec ===
|
|
415
|
+
|
|
416
|
+
def test_make_spec_basic
|
|
417
|
+
setup_opts = get_spec(@primary, "makeSpec", "DEF", "setup", "a")
|
|
418
|
+
spec_client = ProjectNameSDK.test(nil, setup_opts)
|
|
419
|
+
spec_utility = spec_client.get_utility
|
|
420
|
+
|
|
421
|
+
runset(get_spec(@primary, "makeSpec", "basic")) do |entry|
|
|
422
|
+
ctxmap = entry["ctx"] || {}
|
|
423
|
+
ctx = make_ctx_from_map(ctxmap, spec_client, spec_utility)
|
|
424
|
+
ctx.options = spec_client.options_map
|
|
425
|
+
|
|
426
|
+
_, err = @utility.make_spec.call(ctx)
|
|
427
|
+
raise err if err
|
|
428
|
+
|
|
429
|
+
# Update entry ctx for match
|
|
430
|
+
entry_ctx = entry["ctx"]
|
|
431
|
+
if entry_ctx.is_a?(Hash) && ctx.spec
|
|
432
|
+
entry_ctx["spec"] = {
|
|
433
|
+
"base" => ctx.spec.base,
|
|
434
|
+
"prefix" => ctx.spec.prefix,
|
|
435
|
+
"suffix" => ctx.spec.suffix,
|
|
436
|
+
"method" => ctx.spec.method,
|
|
437
|
+
"params" => ctx.spec.params,
|
|
438
|
+
"query" => ctx.spec.query,
|
|
439
|
+
"headers" => ctx.spec.headers,
|
|
440
|
+
"step" => ctx.spec.step,
|
|
441
|
+
}
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
nil
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
# === makePoint ===
|
|
450
|
+
|
|
451
|
+
def test_make_point_basic
|
|
452
|
+
ctx = make_test_ctx(@client, @utility, nil)
|
|
453
|
+
point = {
|
|
454
|
+
"parts" => ["items", "{id}"],
|
|
455
|
+
"args" => { "params" => [] },
|
|
456
|
+
"params" => [],
|
|
457
|
+
"alias" => {},
|
|
458
|
+
"select" => {},
|
|
459
|
+
"active" => true,
|
|
460
|
+
"transform" => {},
|
|
461
|
+
}
|
|
462
|
+
ctx.op.points = [point]
|
|
463
|
+
|
|
464
|
+
_, err = @utility.make_point.call(ctx)
|
|
465
|
+
assert_nil err, "expected no error, got: #{err}"
|
|
466
|
+
assert ctx.point, "expected point to be set"
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
# === makeUrl ===
|
|
471
|
+
|
|
472
|
+
def test_make_url_basic
|
|
473
|
+
runset(get_spec(@primary, "makeUrl", "basic")) do |entry|
|
|
474
|
+
ctxmap = entry["ctx"] || {}
|
|
475
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
476
|
+
ctx.result = ProjectNameResult.new({}) unless ctx.result
|
|
477
|
+
@utility.make_url.call(ctx)
|
|
478
|
+
end
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
# === operator ===
|
|
483
|
+
|
|
484
|
+
def test_operator_basic
|
|
485
|
+
runset(get_spec(@primary, "operator", "basic")) do |entry|
|
|
486
|
+
in_val = entry["in"] || {}
|
|
487
|
+
op = ProjectNameOperation.new(in_val)
|
|
488
|
+
{
|
|
489
|
+
"entity" => op.entity,
|
|
490
|
+
"name" => op.name,
|
|
491
|
+
"input" => op.input,
|
|
492
|
+
"points" => op.points,
|
|
493
|
+
}
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
# === param ===
|
|
499
|
+
|
|
500
|
+
def test_param_basic
|
|
501
|
+
runset(get_spec(@primary, "param", "basic")) do |entry|
|
|
502
|
+
args = entry["args"] || []
|
|
503
|
+
next nil if args.length < 2
|
|
504
|
+
|
|
505
|
+
ctxmap = args[0].is_a?(Hash) ? args[0] : {}
|
|
506
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
507
|
+
paramdef = args[1]
|
|
508
|
+
|
|
509
|
+
result = @utility.param.call(ctx, paramdef)
|
|
510
|
+
|
|
511
|
+
# Update entry ctx for match
|
|
512
|
+
if entry["match"].is_a?(Hash)
|
|
513
|
+
ctx_match = entry["match"]["ctx"]
|
|
514
|
+
if ctx_match.is_a?(Hash)
|
|
515
|
+
entry_ctx = entry["ctx"]
|
|
516
|
+
if entry_ctx.nil?
|
|
517
|
+
entry_ctx = {}
|
|
518
|
+
entry["ctx"] = entry_ctx
|
|
519
|
+
end
|
|
520
|
+
spec_match = ctx_match["spec"]
|
|
521
|
+
if spec_match.is_a?(Hash) && ctx.spec
|
|
522
|
+
entry_ctx["spec"] = {} unless entry_ctx["spec"]
|
|
523
|
+
if spec_match["alias"]
|
|
524
|
+
entry_ctx["spec"] = {
|
|
525
|
+
"alias" => ctx.spec.alias_map,
|
|
526
|
+
}
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
end
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
result
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
# === prepareAuth ===
|
|
538
|
+
|
|
539
|
+
def test_prepare_auth_basic
|
|
540
|
+
setup_opts = get_spec(@primary, "prepareAuth", "DEF", "setup", "a")
|
|
541
|
+
auth_client = ProjectNameSDK.test(nil, setup_opts)
|
|
542
|
+
auth_utility = auth_client.get_utility
|
|
543
|
+
|
|
544
|
+
runset(get_spec(@primary, "prepareAuth", "basic")) do |entry|
|
|
545
|
+
ctxmap = entry["ctx"] || {}
|
|
546
|
+
ctx = make_ctx_from_map(ctxmap, auth_client, auth_utility)
|
|
547
|
+
fixctx(ctx, auth_client)
|
|
548
|
+
|
|
549
|
+
_, err = @utility.prepare_auth.call(ctx)
|
|
550
|
+
raise err if err
|
|
551
|
+
|
|
552
|
+
# Update entry ctx for match
|
|
553
|
+
entry_ctx = entry["ctx"]
|
|
554
|
+
if entry_ctx.is_a?(Hash) && ctx.spec
|
|
555
|
+
entry_ctx["spec"] = {
|
|
556
|
+
"headers" => ctx.spec.headers,
|
|
557
|
+
}
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
nil
|
|
561
|
+
end
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
# === prepareBody ===
|
|
566
|
+
|
|
567
|
+
def test_prepare_body_basic
|
|
568
|
+
runset(get_spec(@primary, "prepareBody", "basic")) do |entry|
|
|
569
|
+
ctxmap = entry["ctx"] || {}
|
|
570
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
571
|
+
fixctx(ctx, @client)
|
|
572
|
+
@utility.prepare_body.call(ctx)
|
|
573
|
+
end
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
# === prepareHeaders ===
|
|
578
|
+
|
|
579
|
+
def test_prepare_headers_basic
|
|
580
|
+
runset(get_spec(@primary, "prepareHeaders", "basic")) do |entry|
|
|
581
|
+
ctxmap = entry["ctx"] || {}
|
|
582
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
583
|
+
@utility.prepare_headers.call(ctx)
|
|
584
|
+
end
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
# === prepareMethod ===
|
|
589
|
+
|
|
590
|
+
def test_prepare_method_basic
|
|
591
|
+
runset(get_spec(@primary, "prepareMethod", "basic")) do |entry|
|
|
592
|
+
ctxmap = entry["ctx"] || {}
|
|
593
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
594
|
+
@utility.prepare_method.call(ctx)
|
|
595
|
+
end
|
|
596
|
+
end
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
# === prepareParams ===
|
|
600
|
+
|
|
601
|
+
def test_prepare_params_basic
|
|
602
|
+
runset(get_spec(@primary, "prepareParams", "basic")) do |entry|
|
|
603
|
+
ctxmap = entry["ctx"] || {}
|
|
604
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
605
|
+
@utility.prepare_params.call(ctx)
|
|
606
|
+
end
|
|
607
|
+
end
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
# === preparePath ===
|
|
611
|
+
|
|
612
|
+
def test_prepare_path_basic
|
|
613
|
+
ctx = make_test_full_ctx(@client, @utility)
|
|
614
|
+
ctx.point = {
|
|
615
|
+
"parts" => ["api", "planet", "{id}"],
|
|
616
|
+
"args" => { "params" => [] },
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
path = @utility.prepare_path.call(ctx)
|
|
620
|
+
assert_equal "api/planet/{id}", path
|
|
621
|
+
end
|
|
622
|
+
|
|
623
|
+
def test_prepare_path_single
|
|
624
|
+
ctx = make_test_full_ctx(@client, @utility)
|
|
625
|
+
ctx.point = {
|
|
626
|
+
"parts" => ["items"],
|
|
627
|
+
"args" => { "params" => [] },
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
path = @utility.prepare_path.call(ctx)
|
|
631
|
+
assert_equal "items", path
|
|
632
|
+
end
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
# === prepareQuery ===
|
|
636
|
+
|
|
637
|
+
def test_prepare_query_basic
|
|
638
|
+
runset(get_spec(@primary, "prepareQuery", "basic")) do |entry|
|
|
639
|
+
ctxmap = entry["ctx"] || {}
|
|
640
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
641
|
+
@utility.prepare_query.call(ctx)
|
|
642
|
+
end
|
|
643
|
+
end
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
# === resultBasic ===
|
|
647
|
+
|
|
648
|
+
def test_result_basic_basic
|
|
649
|
+
runset(get_spec(@primary, "resultBasic", "basic")) do |entry|
|
|
650
|
+
ctxmap = entry["ctx"] || {}
|
|
651
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
652
|
+
fixctx(ctx, @client)
|
|
653
|
+
|
|
654
|
+
result = @utility.result_basic.call(ctx)
|
|
655
|
+
|
|
656
|
+
out = {
|
|
657
|
+
"status" => result.status,
|
|
658
|
+
"statusText" => result.status_text,
|
|
659
|
+
}
|
|
660
|
+
if result.err
|
|
661
|
+
out["err"] = {
|
|
662
|
+
"message" => result.err.to_s,
|
|
663
|
+
}
|
|
664
|
+
end
|
|
665
|
+
|
|
666
|
+
out
|
|
667
|
+
end
|
|
668
|
+
end
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
# === resultBody ===
|
|
672
|
+
|
|
673
|
+
def test_result_body_basic
|
|
674
|
+
runset(get_spec(@primary, "resultBody", "basic")) do |entry|
|
|
675
|
+
ctxmap = entry["ctx"] || {}
|
|
676
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
677
|
+
|
|
678
|
+
@utility.result_body.call(ctx)
|
|
679
|
+
|
|
680
|
+
# Update entry ctx for match
|
|
681
|
+
entry_ctx = entry["ctx"]
|
|
682
|
+
if entry_ctx.is_a?(Hash) && ctx.result
|
|
683
|
+
entry_ctx["result"] = {
|
|
684
|
+
"body" => ctx.result.body,
|
|
685
|
+
}
|
|
686
|
+
end
|
|
687
|
+
|
|
688
|
+
nil
|
|
689
|
+
end
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
# === resultHeaders ===
|
|
694
|
+
|
|
695
|
+
def test_result_headers_basic
|
|
696
|
+
runset(get_spec(@primary, "resultHeaders", "basic")) do |entry|
|
|
697
|
+
ctxmap = entry["ctx"] || {}
|
|
698
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
699
|
+
|
|
700
|
+
@utility.result_headers.call(ctx)
|
|
701
|
+
|
|
702
|
+
# Update entry ctx for match
|
|
703
|
+
entry_ctx = entry["ctx"]
|
|
704
|
+
if entry_ctx.is_a?(Hash) && ctx.result
|
|
705
|
+
entry_ctx["result"] = {
|
|
706
|
+
"headers" => ctx.result.headers,
|
|
707
|
+
}
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
nil
|
|
711
|
+
end
|
|
712
|
+
end
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
# === transformRequest ===
|
|
716
|
+
|
|
717
|
+
def test_transform_request_basic
|
|
718
|
+
runset(get_spec(@primary, "transformRequest", "basic")) do |entry|
|
|
719
|
+
ctxmap = entry["ctx"] || {}
|
|
720
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
721
|
+
|
|
722
|
+
result = @utility.transform_request.call(ctx)
|
|
723
|
+
|
|
724
|
+
# Update entry ctx for match (step changed)
|
|
725
|
+
entry_ctx = entry["ctx"]
|
|
726
|
+
if entry_ctx.is_a?(Hash) && ctx.spec
|
|
727
|
+
spec_map = entry_ctx["spec"]
|
|
728
|
+
spec_map["step"] = ctx.spec.step if spec_map.is_a?(Hash)
|
|
729
|
+
end
|
|
730
|
+
|
|
731
|
+
result
|
|
732
|
+
end
|
|
733
|
+
end
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
# === transformResponse ===
|
|
737
|
+
|
|
738
|
+
def test_transform_response_basic
|
|
739
|
+
runset(get_spec(@primary, "transformResponse", "basic")) do |entry|
|
|
740
|
+
ctxmap = entry["ctx"] || {}
|
|
741
|
+
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
742
|
+
|
|
743
|
+
result = @utility.transform_response.call(ctx)
|
|
744
|
+
|
|
745
|
+
# Update entry ctx for match (step changed)
|
|
746
|
+
entry_ctx = entry["ctx"]
|
|
747
|
+
if entry_ctx.is_a?(Hash) && ctx.spec
|
|
748
|
+
spec_map = entry_ctx["spec"]
|
|
749
|
+
spec_map["step"] = ctx.spec.step if spec_map.is_a?(Hash)
|
|
750
|
+
end
|
|
751
|
+
|
|
752
|
+
result
|
|
753
|
+
end
|
|
754
|
+
end
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
private
|
|
758
|
+
|
|
759
|
+
# === Helper: load test spec ===
|
|
760
|
+
def load_test_spec
|
|
761
|
+
path = File.join(__dir__, '../../.sdk/test/test.json')
|
|
762
|
+
data = File.read(path)
|
|
763
|
+
JSON.parse(data)
|
|
764
|
+
end
|
|
765
|
+
|
|
766
|
+
# === Helper: get nested spec ===
|
|
767
|
+
def get_spec(spec, *keys)
|
|
768
|
+
cur = spec
|
|
769
|
+
keys.each do |key|
|
|
770
|
+
return nil unless cur.is_a?(Hash)
|
|
771
|
+
cur = cur[key]
|
|
772
|
+
end
|
|
773
|
+
cur.is_a?(Hash) ? cur : nil
|
|
774
|
+
end
|
|
775
|
+
|
|
776
|
+
# === Helper: runset ===
|
|
777
|
+
def runset(testspec, &subject)
|
|
778
|
+
return unless testspec
|
|
779
|
+
set = testspec["set"]
|
|
780
|
+
return unless set.is_a?(Array)
|
|
781
|
+
|
|
782
|
+
set.each_with_index do |entry, i|
|
|
783
|
+
next unless entry.is_a?(Hash)
|
|
784
|
+
|
|
785
|
+
mark = entry["mark"] ? " (mark=#{entry["mark"]})" : ""
|
|
786
|
+
|
|
787
|
+
begin
|
|
788
|
+
result, err = subject.call(entry)
|
|
789
|
+
|
|
790
|
+
expected_err = entry["err"]
|
|
791
|
+
|
|
792
|
+
if err
|
|
793
|
+
if expected_err
|
|
794
|
+
err_msg = err.to_s
|
|
795
|
+
if expected_err.is_a?(String)
|
|
796
|
+
unless match_string(expected_err, err_msg)
|
|
797
|
+
flunk "entry #{i}#{mark}: error mismatch: got #{err_msg.inspect}, want contains #{expected_err.inspect}"
|
|
798
|
+
end
|
|
799
|
+
elsif expected_err == true
|
|
800
|
+
# err: true means any error is acceptable
|
|
801
|
+
end
|
|
802
|
+
if entry["match"].is_a?(Hash)
|
|
803
|
+
result_map = {
|
|
804
|
+
"in" => entry["in"],
|
|
805
|
+
"out" => json_normalize(result),
|
|
806
|
+
"err" => { "message" => err.to_s },
|
|
807
|
+
}
|
|
808
|
+
match_deep(i, mark, entry["match"], result_map, "")
|
|
809
|
+
end
|
|
810
|
+
next
|
|
811
|
+
end
|
|
812
|
+
flunk "entry #{i}#{mark}: unexpected error: #{err}"
|
|
813
|
+
next
|
|
814
|
+
end
|
|
815
|
+
|
|
816
|
+
if expected_err
|
|
817
|
+
flunk "entry #{i}#{mark}: expected error containing #{expected_err.inspect} but got result: #{json_str(result)}"
|
|
818
|
+
next
|
|
819
|
+
end
|
|
820
|
+
|
|
821
|
+
matched = false
|
|
822
|
+
if entry["match"].is_a?(Hash)
|
|
823
|
+
result_map = {
|
|
824
|
+
"in" => entry["in"],
|
|
825
|
+
"out" => json_normalize(result),
|
|
826
|
+
}
|
|
827
|
+
if entry["args"]
|
|
828
|
+
result_map["args"] = entry["args"]
|
|
829
|
+
elsif entry["in"]
|
|
830
|
+
result_map["args"] = [entry["in"]]
|
|
831
|
+
end
|
|
832
|
+
result_map["ctx"] = entry["ctx"] if entry["ctx"]
|
|
833
|
+
match_deep(i, mark, entry["match"], result_map, "")
|
|
834
|
+
matched = true
|
|
835
|
+
end
|
|
836
|
+
|
|
837
|
+
expected_out = entry["out"]
|
|
838
|
+
next if expected_out.nil? && matched
|
|
839
|
+
|
|
840
|
+
if expected_out
|
|
841
|
+
norm_result = json_normalize(result)
|
|
842
|
+
norm_expected = json_normalize(expected_out)
|
|
843
|
+
unless deep_equal(norm_result, norm_expected)
|
|
844
|
+
flunk "entry #{i}#{mark}: output mismatch:\n got: #{json_str(norm_result)}\n want: #{json_str(norm_expected)}"
|
|
845
|
+
end
|
|
846
|
+
end
|
|
847
|
+
|
|
848
|
+
rescue => e
|
|
849
|
+
expected_err = entry["err"]
|
|
850
|
+
if expected_err
|
|
851
|
+
err_msg = e.to_s
|
|
852
|
+
if expected_err.is_a?(String)
|
|
853
|
+
unless match_string(expected_err, err_msg)
|
|
854
|
+
flunk "entry #{i}#{mark}: error mismatch: got #{err_msg.inspect}, want contains #{expected_err.inspect}"
|
|
855
|
+
end
|
|
856
|
+
elsif expected_err == true
|
|
857
|
+
# err: true means any error is acceptable
|
|
858
|
+
end
|
|
859
|
+
if entry["match"].is_a?(Hash)
|
|
860
|
+
result_map = {
|
|
861
|
+
"in" => entry["in"],
|
|
862
|
+
"out" => json_normalize(nil),
|
|
863
|
+
"err" => { "message" => e.to_s },
|
|
864
|
+
}
|
|
865
|
+
match_deep(i, mark, entry["match"], result_map, "")
|
|
866
|
+
end
|
|
867
|
+
next
|
|
868
|
+
end
|
|
869
|
+
raise
|
|
870
|
+
end
|
|
871
|
+
end
|
|
872
|
+
end
|
|
873
|
+
|
|
874
|
+
# === Helper: json_normalize ===
|
|
875
|
+
def json_normalize(val)
|
|
876
|
+
return nil if val.nil?
|
|
877
|
+
j = JSON.generate(val)
|
|
878
|
+
JSON.parse(j)
|
|
879
|
+
rescue
|
|
880
|
+
val
|
|
881
|
+
end
|
|
882
|
+
|
|
883
|
+
# === Helper: json_str ===
|
|
884
|
+
def json_str(val)
|
|
885
|
+
JSON.generate(val)
|
|
886
|
+
rescue
|
|
887
|
+
val.to_s
|
|
888
|
+
end
|
|
889
|
+
|
|
890
|
+
# === Helper: match_deep ===
|
|
891
|
+
def match_deep(entry_idx, mark, check, base, path)
|
|
892
|
+
return if check.nil?
|
|
893
|
+
|
|
894
|
+
if check.is_a?(Hash)
|
|
895
|
+
check.each do |key, check_val|
|
|
896
|
+
child_path = "#{path}.#{key}"
|
|
897
|
+
base_val = base.is_a?(Hash) ? base[key] : nil
|
|
898
|
+
match_deep(entry_idx, mark, check_val, base_val, child_path)
|
|
899
|
+
end
|
|
900
|
+
elsif check.is_a?(Array)
|
|
901
|
+
check.each_with_index do |check_val, ci|
|
|
902
|
+
child_path = "#{path}[#{ci}]"
|
|
903
|
+
base_val = (base.is_a?(Array) && ci < base.length) ? base[ci] : nil
|
|
904
|
+
match_deep(entry_idx, mark, check_val, base_val, child_path)
|
|
905
|
+
end
|
|
906
|
+
else
|
|
907
|
+
if check.is_a?(String) && check == "__EXISTS__"
|
|
908
|
+
if base.nil?
|
|
909
|
+
flunk "entry #{entry_idx}#{mark}: match #{path}: expected value to exist but got nil"
|
|
910
|
+
end
|
|
911
|
+
return
|
|
912
|
+
end
|
|
913
|
+
if check.is_a?(String) && check == "__UNDEF__"
|
|
914
|
+
if base != nil
|
|
915
|
+
flunk "entry #{entry_idx}#{mark}: match #{path}: expected nil but got #{base.inspect}"
|
|
916
|
+
end
|
|
917
|
+
return
|
|
918
|
+
end
|
|
919
|
+
|
|
920
|
+
norm_check = json_normalize(check)
|
|
921
|
+
norm_base = json_normalize(base)
|
|
922
|
+
|
|
923
|
+
unless deep_equal(norm_check, norm_base)
|
|
924
|
+
if check.is_a?(String) && !check.empty?
|
|
925
|
+
base_str = base.nil? ? "" : base.to_s
|
|
926
|
+
return if match_string(check, base_str)
|
|
927
|
+
end
|
|
928
|
+
flunk "entry #{entry_idx}#{mark}: match #{path}: got #{json_str(norm_base)}, want #{json_str(norm_check)}"
|
|
929
|
+
end
|
|
930
|
+
end
|
|
931
|
+
end
|
|
932
|
+
|
|
933
|
+
# === Helper: match_string ===
|
|
934
|
+
def match_string(pattern, val)
|
|
935
|
+
if pattern.length >= 2 && pattern[0] == '/' && pattern[-1] == '/'
|
|
936
|
+
re = Regexp.new(pattern[1..-2])
|
|
937
|
+
return re.match?(val)
|
|
938
|
+
end
|
|
939
|
+
val.downcase.include?(pattern.downcase)
|
|
940
|
+
end
|
|
941
|
+
|
|
942
|
+
# === Helper: deep_equal ===
|
|
943
|
+
def deep_equal(a, b)
|
|
944
|
+
normalize = lambda { |v|
|
|
945
|
+
case v
|
|
946
|
+
when Hash
|
|
947
|
+
sorted = {}
|
|
948
|
+
v.keys.sort.each { |k| sorted[k] = normalize.call(v[k]) }
|
|
949
|
+
sorted
|
|
950
|
+
when Array
|
|
951
|
+
v.map { |e| normalize.call(e) }
|
|
952
|
+
else
|
|
953
|
+
v
|
|
954
|
+
end
|
|
955
|
+
}
|
|
956
|
+
JSON.generate(normalize.call(a)) == JSON.generate(normalize.call(b))
|
|
957
|
+
rescue
|
|
958
|
+
a == b
|
|
959
|
+
end
|
|
960
|
+
|
|
961
|
+
# === Helper: make_test_ctx ===
|
|
962
|
+
def make_test_ctx(client, utility, overrides)
|
|
963
|
+
ctxmap = {
|
|
964
|
+
"opname" => "load",
|
|
965
|
+
"client" => client,
|
|
966
|
+
"utility" => utility,
|
|
967
|
+
}
|
|
968
|
+
if overrides
|
|
969
|
+
overrides.each { |k, v| ctxmap[k] = v }
|
|
970
|
+
end
|
|
971
|
+
utility.make_context.call(ctxmap, client.get_root_ctx)
|
|
972
|
+
end
|
|
973
|
+
|
|
974
|
+
# === Helper: make_test_full_ctx ===
|
|
975
|
+
def make_test_full_ctx(client, utility)
|
|
976
|
+
ctx = make_test_ctx(client, utility, nil)
|
|
977
|
+
ctx.point = {
|
|
978
|
+
"parts" => ["items", "{id}"],
|
|
979
|
+
"args" => { "params" => [{ "name" => "id", "reqd" => true }] },
|
|
980
|
+
"params" => ["id"],
|
|
981
|
+
"alias" => {},
|
|
982
|
+
"select" => {},
|
|
983
|
+
"active" => true,
|
|
984
|
+
"transform" => {},
|
|
985
|
+
}
|
|
986
|
+
ctx.match = { "id" => "item01" }
|
|
987
|
+
ctx.reqmatch = { "id" => "item01" }
|
|
988
|
+
ctx
|
|
989
|
+
end
|
|
990
|
+
|
|
991
|
+
# === Helper: make_ctx_from_map ===
|
|
992
|
+
def make_ctx_from_map(ctxmap, client, utility)
|
|
993
|
+
ctxmap = {} unless ctxmap.is_a?(Hash)
|
|
994
|
+
|
|
995
|
+
ctx = ProjectNameContext.new(ctxmap, nil)
|
|
996
|
+
|
|
997
|
+
if client
|
|
998
|
+
ctx.client = client
|
|
999
|
+
ctx.utility = utility
|
|
1000
|
+
end
|
|
1001
|
+
if ctx.options.nil? && client
|
|
1002
|
+
ctx.options = client.options_map
|
|
1003
|
+
end
|
|
1004
|
+
|
|
1005
|
+
# Handle spec from JSON map
|
|
1006
|
+
if ctxmap["spec"].is_a?(Hash)
|
|
1007
|
+
ctx.spec = ProjectNameSpec.new(ctxmap["spec"])
|
|
1008
|
+
end
|
|
1009
|
+
|
|
1010
|
+
# Handle result from JSON map
|
|
1011
|
+
if ctxmap["result"].is_a?(Hash)
|
|
1012
|
+
res_map = ctxmap["result"]
|
|
1013
|
+
ctx.result = ProjectNameResult.new(res_map)
|
|
1014
|
+
if res_map["err"].is_a?(Hash) && res_map["err"]["message"].is_a?(String)
|
|
1015
|
+
ctx.result.err = ProjectNameError.new("", res_map["err"]["message"])
|
|
1016
|
+
end
|
|
1017
|
+
end
|
|
1018
|
+
|
|
1019
|
+
# Handle response from JSON map
|
|
1020
|
+
if ctxmap["response"].is_a?(Hash)
|
|
1021
|
+
resp_map = ctxmap["response"]
|
|
1022
|
+
ctx.response = ProjectNameResponse.new(resp_map)
|
|
1023
|
+
if resp_map["body"]
|
|
1024
|
+
body_copy = resp_map["body"]
|
|
1025
|
+
ctx.response.json_func = -> { body_copy }
|
|
1026
|
+
end
|
|
1027
|
+
if resp_map["headers"].is_a?(Hash)
|
|
1028
|
+
lower_headers = {}
|
|
1029
|
+
resp_map["headers"].each { |k, v| lower_headers[k.downcase] = v }
|
|
1030
|
+
ctx.response.headers = lower_headers
|
|
1031
|
+
end
|
|
1032
|
+
end
|
|
1033
|
+
|
|
1034
|
+
ctx
|
|
1035
|
+
end
|
|
1036
|
+
|
|
1037
|
+
# === Helper: fixctx ===
|
|
1038
|
+
def fixctx(ctx, client)
|
|
1039
|
+
if ctx && ctx.client && ctx.options.nil?
|
|
1040
|
+
ctx.options = ctx.client.options_map
|
|
1041
|
+
end
|
|
1042
|
+
end
|
|
1043
|
+
|
|
1044
|
+
# === Helper: err_from_map ===
|
|
1045
|
+
def err_from_map(m)
|
|
1046
|
+
return nil unless m.is_a?(Hash)
|
|
1047
|
+
msg = m["message"]
|
|
1048
|
+
return nil unless msg.is_a?(String) && !msg.empty?
|
|
1049
|
+
code = m["code"] || ""
|
|
1050
|
+
ProjectNameError.new(code, msg)
|
|
1051
|
+
end
|
|
1052
|
+
end
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
# === Test hook feature for featureHook test ===
|
|
1056
|
+
class TestHookFeature < ProjectNameBaseFeature
|
|
1057
|
+
def initialize(&hook_fn)
|
|
1058
|
+
super()
|
|
1059
|
+
@hook_fn = hook_fn
|
|
1060
|
+
end
|
|
1061
|
+
|
|
1062
|
+
def TestHook(ctx)
|
|
1063
|
+
@hook_fn.call if @hook_fn
|
|
1064
|
+
end
|
|
1065
|
+
end
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
# === Test init feature for featureInit test ===
|
|
1069
|
+
class TestInitFeature < ProjectNameBaseFeature
|
|
1070
|
+
def initialize(name, active, &init_fn)
|
|
1071
|
+
super()
|
|
1072
|
+
@name = name
|
|
1073
|
+
@active = active
|
|
1074
|
+
@init_fn = init_fn
|
|
1075
|
+
end
|
|
1076
|
+
|
|
1077
|
+
def get_name; @name; end
|
|
1078
|
+
def get_active; @active; end
|
|
1079
|
+
|
|
1080
|
+
def init(ctx, options)
|
|
1081
|
+
@init_fn.call if @init_fn
|
|
1082
|
+
end
|
|
1083
|
+
end
|