@voxgig/sdkgen-langpack 0.0.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/.sdk/model/target/dart.aon +63 -0
- package/.sdk/model/target/haskell.aon +72 -0
- package/.sdk/model/target/lean.aon +91 -0
- package/.sdk/src/cmp/dart/Config_dart.ts +248 -0
- package/.sdk/src/cmp/dart/EntityBase_dart.ts +34 -0
- package/.sdk/src/cmp/dart/EntityOperation_dart.ts +43 -0
- package/.sdk/src/cmp/dart/EntityTypes_dart.ts +207 -0
- package/.sdk/src/cmp/dart/Entity_dart.ts +87 -0
- package/.sdk/src/cmp/dart/Gitignore_dart.ts +34 -0
- package/.sdk/src/cmp/dart/MainEntity_dart.ts +33 -0
- package/.sdk/src/cmp/dart/Main_dart.ts +178 -0
- package/.sdk/src/cmp/dart/Package_dart.ts +82 -0
- package/.sdk/src/cmp/dart/ReadmeEntity_dart.ts +177 -0
- package/.sdk/src/cmp/dart/ReadmeExamplesTest_dart.ts +238 -0
- package/.sdk/src/cmp/dart/ReadmeExplanation_dart.ts +53 -0
- package/.sdk/src/cmp/dart/ReadmeHowto_dart.ts +152 -0
- package/.sdk/src/cmp/dart/ReadmeInstall_dart.ts +59 -0
- package/.sdk/src/cmp/dart/ReadmeIntro_dart.ts +65 -0
- package/.sdk/src/cmp/dart/ReadmeModel_dart.ts +151 -0
- package/.sdk/src/cmp/dart/ReadmeOptions_dart.ts +63 -0
- package/.sdk/src/cmp/dart/ReadmeQuick_dart.ts +225 -0
- package/.sdk/src/cmp/dart/ReadmeRef_dart.ts +397 -0
- package/.sdk/src/cmp/dart/ReadmeTopHowto_dart.ts +24 -0
- package/.sdk/src/cmp/dart/ReadmeTopQuick_dart.ts +106 -0
- package/.sdk/src/cmp/dart/ReadmeTopTest_dart.ts +78 -0
- package/.sdk/src/cmp/dart/SdkError_dart.ts +42 -0
- package/.sdk/src/cmp/dart/TestDirect_dart.ts +516 -0
- package/.sdk/src/cmp/dart/TestEntity_dart.ts +628 -0
- package/.sdk/src/cmp/dart/Test_dart.ts +138 -0
- package/.sdk/src/cmp/dart/fragment/Config.data.fragment.dart +98 -0
- package/.sdk/src/cmp/dart/fragment/Config.fragment.dart +70 -0
- package/.sdk/src/cmp/dart/fragment/Direct.test.fragment.dart +25 -0
- package/.sdk/src/cmp/dart/fragment/Entity.fragment.dart +29 -0
- package/.sdk/src/cmp/dart/fragment/Entity.test.fragment.dart +28 -0
- package/.sdk/src/cmp/dart/fragment/EntityBase.fragment.dart +302 -0
- package/.sdk/src/cmp/dart/fragment/EntityCreateOp.fragment.dart +98 -0
- package/.sdk/src/cmp/dart/fragment/EntityListOp.fragment.dart +90 -0
- package/.sdk/src/cmp/dart/fragment/EntityLoadOp.fragment.dart +102 -0
- package/.sdk/src/cmp/dart/fragment/EntityRemoveOp.fragment.dart +108 -0
- package/.sdk/src/cmp/dart/fragment/EntityUpdateOp.fragment.dart +102 -0
- package/.sdk/src/cmp/dart/fragment/Main.fragment.dart +339 -0
- package/.sdk/src/cmp/dart/fragment/SdkError.fragment.dart +26 -0
- package/.sdk/src/cmp/dart/tsconfig.json +15 -0
- package/.sdk/src/cmp/dart/utility_dart.ts +155 -0
- package/.sdk/src/cmp/haskell/Config_haskell.ts +98 -0
- package/.sdk/src/cmp/haskell/Entity_haskell.ts +13 -0
- package/.sdk/src/cmp/haskell/Gitignore_haskell.ts +27 -0
- package/.sdk/src/cmp/haskell/Main_haskell.ts +123 -0
- package/.sdk/src/cmp/haskell/Package_haskell.ts +60 -0
- package/.sdk/src/cmp/haskell/ReadmeEntity_haskell.ts +186 -0
- package/.sdk/src/cmp/haskell/ReadmeExamplesTest_haskell.ts +135 -0
- package/.sdk/src/cmp/haskell/ReadmeExplanation_haskell.ts +48 -0
- package/.sdk/src/cmp/haskell/ReadmeHowto_haskell.ts +168 -0
- package/.sdk/src/cmp/haskell/ReadmeInstall_haskell.ts +51 -0
- package/.sdk/src/cmp/haskell/ReadmeIntro_haskell.ts +67 -0
- package/.sdk/src/cmp/haskell/ReadmeModel_haskell.ts +162 -0
- package/.sdk/src/cmp/haskell/ReadmeOptions_haskell.ts +74 -0
- package/.sdk/src/cmp/haskell/ReadmeQuick_haskell.ts +241 -0
- package/.sdk/src/cmp/haskell/ReadmeRef_haskell.ts +408 -0
- package/.sdk/src/cmp/haskell/ReadmeTopHowto_haskell.ts +31 -0
- package/.sdk/src/cmp/haskell/ReadmeTopQuick_haskell.ts +104 -0
- package/.sdk/src/cmp/haskell/ReadmeTopTest_haskell.ts +80 -0
- package/.sdk/src/cmp/haskell/Test_haskell.ts +297 -0
- package/.sdk/src/cmp/haskell/tsconfig.json +15 -0
- package/.sdk/src/cmp/haskell/utility_haskell.ts +166 -0
- package/.sdk/src/cmp/lean/Config_lean.ts +93 -0
- package/.sdk/src/cmp/lean/Entity_lean.ts +9 -0
- package/.sdk/src/cmp/lean/Gitignore_lean.ts +18 -0
- package/.sdk/src/cmp/lean/Main_lean.ts +120 -0
- package/.sdk/src/cmp/lean/Package_lean.ts +93 -0
- package/.sdk/src/cmp/lean/ReadmeEntity_lean.ts +29 -0
- package/.sdk/src/cmp/lean/ReadmeExplanation_lean.ts +19 -0
- package/.sdk/src/cmp/lean/ReadmeHowto_lean.ts +25 -0
- package/.sdk/src/cmp/lean/ReadmeInstall_lean.ts +39 -0
- package/.sdk/src/cmp/lean/ReadmeIntro_lean.ts +25 -0
- package/.sdk/src/cmp/lean/ReadmeModel_lean.ts +24 -0
- package/.sdk/src/cmp/lean/ReadmeOptions_lean.ts +22 -0
- package/.sdk/src/cmp/lean/ReadmeQuick_lean.ts +50 -0
- package/.sdk/src/cmp/lean/ReadmeRef_lean.ts +40 -0
- package/.sdk/src/cmp/lean/ReadmeTopHowto_lean.ts +16 -0
- package/.sdk/src/cmp/lean/ReadmeTopQuick_lean.ts +23 -0
- package/.sdk/src/cmp/lean/ReadmeTopTest_lean.ts +19 -0
- package/.sdk/src/cmp/lean/Test_lean.ts +261 -0
- package/.sdk/src/cmp/lean/utility_lean.ts +129 -0
- package/.sdk/tm/dart/LICENSE +22 -0
- package/.sdk/tm/dart/Makefile +50 -0
- package/.sdk/tm/dart/lib/Context.dart +150 -0
- package/.sdk/tm/dart/lib/Control.dart +15 -0
- package/.sdk/tm/dart/lib/Operation.dart +31 -0
- package/.sdk/tm/dart/lib/Point.dart +51 -0
- package/.sdk/tm/dart/lib/Response.dart +32 -0
- package/.sdk/tm/dart/lib/Result.dart +39 -0
- package/.sdk/tm/dart/lib/Spec.dart +49 -0
- package/.sdk/tm/dart/lib/feature/audit/AuditFeature.dart +103 -0
- package/.sdk/tm/dart/lib/feature/base/BaseFeature.dart +76 -0
- package/.sdk/tm/dart/lib/feature/cache/CacheFeature.dart +152 -0
- package/.sdk/tm/dart/lib/feature/clienttrack/ClienttrackFeature.dart +104 -0
- package/.sdk/tm/dart/lib/feature/cost/CostFeature.dart +446 -0
- package/.sdk/tm/dart/lib/feature/debug/DebugFeature.dart +153 -0
- package/.sdk/tm/dart/lib/feature/idempotency/IdempotencyFeature.dart +92 -0
- package/.sdk/tm/dart/lib/feature/log/LogFeature.dart +85 -0
- package/.sdk/tm/dart/lib/feature/metrics/MetricsFeature.dart +103 -0
- package/.sdk/tm/dart/lib/feature/netsim/NetsimFeature.dart +186 -0
- package/.sdk/tm/dart/lib/feature/paging/PagingFeature.dart +240 -0
- package/.sdk/tm/dart/lib/feature/proxy/ProxyFeature.dart +118 -0
- package/.sdk/tm/dart/lib/feature/ratelimit/RatelimitFeature.dart +103 -0
- package/.sdk/tm/dart/lib/feature/rbac/RbacFeature.dart +121 -0
- package/.sdk/tm/dart/lib/feature/retry/RetryFeature.dart +155 -0
- package/.sdk/tm/dart/lib/feature/secrets/SecretsFeature.dart +649 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/capability.dart +105 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/catalog.dart +46 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/config.dart +297 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/depend.dart +198 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/env.dart +144 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/export.dart +58 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/graph.dart +160 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/host.dart +1067 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/order.dart +172 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/plugin.dart +23 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/point.dart +117 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/ref.dart +105 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/resolve.dart +58 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/types.dart +201 -0
- package/.sdk/tm/dart/lib/feature/secrets/plugin/version.dart +116 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/aws.dart +285 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/azuresecrets.dart +178 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/boru.dart +145 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/crypto.dart +194 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/doppler.dart +101 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/gcpsecrets.dart +143 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/hashicorp.dart +190 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/httpjson.dart +363 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/infisical.dart +149 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/onepassword.dart +146 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/secretspec.dart +116 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/plugins/sigv4.dart +237 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/addr.dart +138 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/json.dart +276 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/provider.dart +31 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/providers.dart +243 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/sekreto.dart +730 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/spec.dart +200 -0
- package/.sdk/tm/dart/lib/feature/secrets/sekreto/src/support.dart +217 -0
- package/.sdk/tm/dart/lib/feature/streaming/StreamingFeature.dart +97 -0
- package/.sdk/tm/dart/lib/feature/telemetry/TelemetryFeature.dart +136 -0
- package/.sdk/tm/dart/lib/feature/test/TestFeature.dart +328 -0
- package/.sdk/tm/dart/lib/feature/timeout/TimeoutFeature.dart +104 -0
- package/.sdk/tm/dart/lib/utility/CleanUtility.dart +12 -0
- package/.sdk/tm/dart/lib/utility/DoneUtility.dart +18 -0
- package/.sdk/tm/dart/lib/utility/ErrUtility.dart +46 -0
- package/.sdk/tm/dart/lib/utility/FeatureAddUtility.dart +35 -0
- package/.sdk/tm/dart/lib/utility/FeatureHookUtility.dart +20 -0
- package/.sdk/tm/dart/lib/utility/FeatureInitUtility.dart +9 -0
- package/.sdk/tm/dart/lib/utility/FetcherUtility.dart +104 -0
- package/.sdk/tm/dart/lib/utility/GraphqlUtility.dart +162 -0
- package/.sdk/tm/dart/lib/utility/MakeContextUtility.dart +6 -0
- package/.sdk/tm/dart/lib/utility/MakeErrorUtility.dart +71 -0
- package/.sdk/tm/dart/lib/utility/MakeFetchDefUtility.dart +42 -0
- package/.sdk/tm/dart/lib/utility/MakeOptionsUtility.dart +233 -0
- package/.sdk/tm/dart/lib/utility/MakePointUtility.dart +130 -0
- package/.sdk/tm/dart/lib/utility/MakeRequestUtility.dart +66 -0
- package/.sdk/tm/dart/lib/utility/MakeResponseUtility.dart +59 -0
- package/.sdk/tm/dart/lib/utility/MakeResultUtility.dart +49 -0
- package/.sdk/tm/dart/lib/utility/MakeSpecUtility.dart +77 -0
- package/.sdk/tm/dart/lib/utility/MakeUrlUtility.dart +51 -0
- package/.sdk/tm/dart/lib/utility/ParamUtility.dart +56 -0
- package/.sdk/tm/dart/lib/utility/PrepareAuthUtility.dart +46 -0
- package/.sdk/tm/dart/lib/utility/PrepareBodyUtility.dart +19 -0
- package/.sdk/tm/dart/lib/utility/PrepareHeadersUtility.dart +11 -0
- package/.sdk/tm/dart/lib/utility/PrepareMethodUtility.dart +30 -0
- package/.sdk/tm/dart/lib/utility/PrepareParamsUtility.dart +23 -0
- package/.sdk/tm/dart/lib/utility/PreparePathUtility.dart +9 -0
- package/.sdk/tm/dart/lib/utility/PrepareQueryUtility.dart +18 -0
- package/.sdk/tm/dart/lib/utility/ResultBasicUtility.dart +29 -0
- package/.sdk/tm/dart/lib/utility/ResultBodyUtility.dart +15 -0
- package/.sdk/tm/dart/lib/utility/ResultHeadersUtility.dart +18 -0
- package/.sdk/tm/dart/lib/utility/StructUtility.dart +127 -0
- package/.sdk/tm/dart/lib/utility/TransformRequestUtility.dart +28 -0
- package/.sdk/tm/dart/lib/utility/TransformResponseUtility.dart +44 -0
- package/.sdk/tm/dart/lib/utility/Utility.dart +239 -0
- package/.sdk/tm/dart/lib/utility/voxgig_struct.dart +2462 -0
- package/.sdk/tm/dart/src/feature/README.md +3 -0
- package/.sdk/tm/dart/src/feature/audit/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/base/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/cache/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/clienttrack/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/cost/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/debug/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/idempotency/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/log/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/metrics/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/netsim/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/paging/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/proxy/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/ratelimit/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/rbac/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/retry/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/secrets/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/streaming/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/telemetry/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/test/.gitkeep +0 -0
- package/.sdk/tm/dart/src/feature/timeout/.gitkeep +0 -0
- package/.sdk/tm/dart/test/custom_test.dart +65 -0
- package/.sdk/tm/dart/test/exists_test.dart +12 -0
- package/.sdk/tm/dart/test/feature/harness.dart +347 -0
- package/.sdk/tm/dart/test/feature/secrets/secrets_test.dart +1107 -0
- package/.sdk/tm/dart/test/feature_test.dart +1193 -0
- package/.sdk/tm/dart/test/harness.dart +153 -0
- package/.sdk/tm/dart/test/netsim_test.dart +48 -0
- package/.sdk/tm/dart/test/omni.dart +520 -0
- package/.sdk/tm/dart/test/omni_smoke_test.dart +143 -0
- package/.sdk/tm/dart/test/pipeline_test.dart +608 -0
- package/.sdk/tm/dart/test/primary_test.dart +476 -0
- package/.sdk/tm/dart/test/sdk-test-control.json +19 -0
- package/.sdk/tm/dart/test/struct_test.dart +468 -0
- package/.sdk/tm/dart/test/utility.dart +198 -0
- package/.sdk/tm/dart/test/vendor/omni/omni.dart +7 -0
- package/.sdk/tm/dart/test/vendor/omni/runner.dart +653 -0
- package/.sdk/tm/dart/test/vendor/omni/util.dart +232 -0
- package/.sdk/tm/haskell/LICENSE +21 -0
- package/.sdk/tm/haskell/Makefile +22 -0
- package/.sdk/tm/haskell/VERSION +1 -0
- package/.sdk/tm/haskell/src/SdkFeatures.hs +1440 -0
- package/.sdk/tm/haskell/src/SdkHelpers.hs +337 -0
- package/.sdk/tm/haskell/src/SdkJson.hs +111 -0
- package/.sdk/tm/haskell/src/SdkRuntime.hs +1279 -0
- package/.sdk/tm/haskell/src/SdkTypes.hs +195 -0
- package/.sdk/tm/haskell/src/VoxgigStruct.hs +2299 -0
- package/.sdk/tm/haskell/src/Vregex.hs +237 -0
- package/.sdk/tm/haskell/src/feature/README.md +5 -0
- package/.sdk/tm/haskell/src/feature/audit/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/base/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/cache/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/clienttrack/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/debug/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/idempotency/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/log/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/metrics/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/netsim/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/paging/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/proxy/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/ratelimit/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/rbac/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/retry/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/streaming/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/telemetry/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/test/.gitkeep +0 -0
- package/.sdk/tm/haskell/src/feature/timeout/.gitkeep +0 -0
- package/.sdk/tm/haskell/test/Harness.hs +281 -0
- package/.sdk/tm/haskell/test/OmniResolver.hs +252 -0
- package/.sdk/tm/haskell/test/Runner.hs +49 -0
- package/.sdk/tm/haskell/test/StructCorpus.hs +449 -0
- package/.sdk/tm/haskell/test/TCustomUtility.hs +38 -0
- package/.sdk/tm/haskell/test/TFeature.hs +794 -0
- package/.sdk/tm/haskell/test/TNetsim.hs +50 -0
- package/.sdk/tm/haskell/test/TPipeline.hs +334 -0
- package/.sdk/tm/haskell/test/TPrimaryCorpus.hs +263 -0
- package/.sdk/tm/haskell/test/TPrimaryUtility.hs +386 -0
- package/.sdk/tm/haskell/test/Testutil.hs +59 -0
- package/.sdk/tm/haskell/test/vendor/omni/Omni.hs +1147 -0
- package/.sdk/tm/lean/LICENSE +21 -0
- package/.sdk/tm/lean/Makefile +32 -0
- package/.sdk/tm/lean/VERSION +1 -0
- package/.sdk/tm/lean/src/SdkFeature.lean +171 -0
- package/.sdk/tm/lean/src/SdkFeatures.lean +787 -0
- package/.sdk/tm/lean/src/SdkJson.lean +134 -0
- package/.sdk/tm/lean/src/SdkRuntime.lean +374 -0
- package/.sdk/tm/lean/src/SdkUtility.lean +809 -0
- package/.sdk/tm/lean/src/VoxgigStruct.lean +2880 -0
- package/.sdk/tm/lean/src/Vregex.lean +412 -0
- package/.sdk/tm/lean/src/feature/README.md +5 -0
- package/.sdk/tm/lean/src/feature/audit/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/base/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/cache/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/clienttrack/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/cost/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/debug/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/idempotency/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/log/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/metrics/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/netsim/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/paging/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/proxy/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/ratelimit/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/rbac/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/retry/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/streaming/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/telemetry/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/test/.gitkeep +0 -0
- package/.sdk/tm/lean/src/feature/timeout/.gitkeep +0 -0
- package/.sdk/tm/lean/test/OmniResolver.lean +358 -0
- package/.sdk/tm/lean/test/OmniSmoke.lean +174 -0
- package/.sdk/tm/lean/test/StructCorpus.lean +368 -0
- package/.sdk/tm/lean/test/TFeature.lean +281 -0
- package/.sdk/tm/lean/test/TPrimaryUtility.lean +227 -0
- package/.sdk/tm/lean/test/vendor/omni/Omni.lean +997 -0
- package/LICENSE +21 -0
- package/README.md +104 -0
- package/package.json +78 -0
- package/sdkgen-package.json +22 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
-- Minimal backtracking regex engine for the Haskell port of voxgig/struct.
|
|
2
|
+
-- Supports the RE2 subset the corpus exercises: literals, '.', anchors ^ $,
|
|
3
|
+
-- \b, character classes [..] / [^..] with ranges and \d \w \s \D \W \S,
|
|
4
|
+
-- groups (..) and (?:..), alternation |, quantifiers * + ? and {n}/{n,}/{n,m}
|
|
5
|
+
-- with optional lazy '?'. No third-party dependency. The struct library uses
|
|
6
|
+
-- `test` for $LIKE; `find` backs the public re_* API (not corpus-tested).
|
|
7
|
+
|
|
8
|
+
module Vregex
|
|
9
|
+
( Re
|
|
10
|
+
, compile
|
|
11
|
+
, test
|
|
12
|
+
, testStr
|
|
13
|
+
, findBounds
|
|
14
|
+
) where
|
|
15
|
+
|
|
16
|
+
import Control.Applicative ((<|>))
|
|
17
|
+
import Data.Array (Array, listArray, (!))
|
|
18
|
+
import Data.Foldable (asum)
|
|
19
|
+
import Data.Maybe (isJust)
|
|
20
|
+
|
|
21
|
+
data Node
|
|
22
|
+
= Char Char
|
|
23
|
+
| Any
|
|
24
|
+
| Start
|
|
25
|
+
| End
|
|
26
|
+
| WordB
|
|
27
|
+
| Cls Bool [Citem] -- negated?, items
|
|
28
|
+
| Grp [[Node]] -- alternation of sequences
|
|
29
|
+
| Star Bool Node -- greedy?, atom
|
|
30
|
+
| Plus Bool Node
|
|
31
|
+
| Opt Bool Node
|
|
32
|
+
| Rep Bool Int (Maybe Int) Node
|
|
33
|
+
|
|
34
|
+
data Citem
|
|
35
|
+
= CChar Char
|
|
36
|
+
| CRange Char Char
|
|
37
|
+
| CD | CW | CS | CND | CNW | CNS -- \d \w \s \D \W \S
|
|
38
|
+
|
|
39
|
+
-- ----- parser (remaining-string style) -----
|
|
40
|
+
|
|
41
|
+
parse :: String -> [[Node]]
|
|
42
|
+
parse pat = fst (parseAlt pat)
|
|
43
|
+
|
|
44
|
+
parseAlt :: String -> ([[Node]], String)
|
|
45
|
+
parseAlt s0 =
|
|
46
|
+
let (first, s1) = parseSeq s0
|
|
47
|
+
in go [first] s1
|
|
48
|
+
where
|
|
49
|
+
go acc ('|':rest) = let (sq, r) = parseSeq rest in go (sq : acc) r
|
|
50
|
+
go acc r = (reverse acc, r)
|
|
51
|
+
|
|
52
|
+
parseSeq :: String -> ([Node], String)
|
|
53
|
+
parseSeq = goSeq []
|
|
54
|
+
where
|
|
55
|
+
goSeq acc s = case s of
|
|
56
|
+
[] -> (reverse acc, s)
|
|
57
|
+
('|':_) -> (reverse acc, s)
|
|
58
|
+
(')':_) -> (reverse acc, s)
|
|
59
|
+
_ -> case parseAtom s of
|
|
60
|
+
(Nothing, s') -> (reverse acc, s')
|
|
61
|
+
(Just a, s') ->
|
|
62
|
+
let (a', s'') = parseQuantSuffix a s'
|
|
63
|
+
in goSeq (a' : acc) s''
|
|
64
|
+
|
|
65
|
+
parseAtom :: String -> (Maybe Node, String)
|
|
66
|
+
parseAtom s = case s of
|
|
67
|
+
[] -> (Nothing, s)
|
|
68
|
+
('(':rest) ->
|
|
69
|
+
let rest1 = case rest of ('?':':':r) -> r; _ -> rest
|
|
70
|
+
(alts, r2) = parseAlt rest1
|
|
71
|
+
r3 = case r2 of (')':r) -> r; _ -> r2
|
|
72
|
+
in (Just (Grp alts), r3)
|
|
73
|
+
('[':_) -> let (n, r) = parseClass s in (Just n, r)
|
|
74
|
+
('.':rest) -> (Just Any, rest)
|
|
75
|
+
('^':rest) -> (Just Start, rest)
|
|
76
|
+
('$':rest) -> (Just End, rest)
|
|
77
|
+
('\\':rest) -> case rest of
|
|
78
|
+
('d':r) -> (Just (Cls False [CD]), r)
|
|
79
|
+
('w':r) -> (Just (Cls False [CW]), r)
|
|
80
|
+
('s':r) -> (Just (Cls False [CS]), r)
|
|
81
|
+
('D':r) -> (Just (Cls False [CND]), r)
|
|
82
|
+
('W':r) -> (Just (Cls False [CNW]), r)
|
|
83
|
+
('S':r) -> (Just (Cls False [CNS]), r)
|
|
84
|
+
('b':r) -> (Just WordB, r)
|
|
85
|
+
('n':r) -> (Just (Char '\n'), r)
|
|
86
|
+
('t':r) -> (Just (Char '\t'), r)
|
|
87
|
+
('r':r) -> (Just (Char '\r'), r)
|
|
88
|
+
(c:r) -> (Just (Char c), r)
|
|
89
|
+
[] -> (Just (Char '\\'), [])
|
|
90
|
+
(c:rest) -> (Just (Char c), rest)
|
|
91
|
+
|
|
92
|
+
parseClass :: String -> (Node, String)
|
|
93
|
+
parseClass ('[':s0) =
|
|
94
|
+
let (neg, s1) = case s0 of ('^':r) -> (True, r); _ -> (False, s0)
|
|
95
|
+
(items, rest) = goCls [] s1
|
|
96
|
+
in (Cls neg (reverse items), rest)
|
|
97
|
+
where
|
|
98
|
+
goCls acc s = case s of
|
|
99
|
+
[] -> (acc, s)
|
|
100
|
+
(']':r) -> (acc, r)
|
|
101
|
+
('\\':r) -> case r of
|
|
102
|
+
('d':r') -> goCls (CD : acc) r'
|
|
103
|
+
('w':r') -> goCls (CW : acc) r'
|
|
104
|
+
('s':r') -> goCls (CS : acc) r'
|
|
105
|
+
('D':r') -> goCls (CND : acc) r'
|
|
106
|
+
('W':r') -> goCls (CNW : acc) r'
|
|
107
|
+
('S':r') -> goCls (CNS : acc) r'
|
|
108
|
+
('n':r') -> goCls (CChar '\n' : acc) r'
|
|
109
|
+
('t':r') -> goCls (CChar '\t' : acc) r'
|
|
110
|
+
('r':r') -> goCls (CChar '\r' : acc) r'
|
|
111
|
+
(c:r') -> goCls (CChar c : acc) r'
|
|
112
|
+
[] -> (acc, [])
|
|
113
|
+
(c : '-' : c2 : r) | c2 /= ']' -> goCls (CRange c c2 : acc) r
|
|
114
|
+
(c:r) -> goCls (CChar c : acc) r
|
|
115
|
+
parseClass s = (Cls False [], s)
|
|
116
|
+
|
|
117
|
+
parseQuantSuffix :: Node -> String -> (Node, String)
|
|
118
|
+
parseQuantSuffix atom s = case s of
|
|
119
|
+
('*':rest) -> let (lz, r) = lazyq rest in (Star (not lz) atom, r)
|
|
120
|
+
('+':rest) -> let (lz, r) = lazyq rest in (Plus (not lz) atom, r)
|
|
121
|
+
('?':rest) -> let (lz, r) = lazyq rest in (Opt (not lz) atom, r)
|
|
122
|
+
('{':rest) ->
|
|
123
|
+
let (mn, r1) = num rest
|
|
124
|
+
(mx, r2) = case r1 of
|
|
125
|
+
(',':r) -> let (s2, r') = num r in (if null s2 then Nothing else Just (read s2), r')
|
|
126
|
+
_ -> (Just (if null mn then 0 else read mn), r1)
|
|
127
|
+
in case r2 of
|
|
128
|
+
('}':r3) | not (null mn) ->
|
|
129
|
+
let (lz, r4) = lazyq r3 in (Rep (not lz) (read mn) mx atom, r4)
|
|
130
|
+
_ -> (atom, s)
|
|
131
|
+
_ -> (atom, s)
|
|
132
|
+
where
|
|
133
|
+
lazyq ('?':r) = (True, r)
|
|
134
|
+
lazyq r = (False, r)
|
|
135
|
+
num = span (\c -> c >= '0' && c <= '9')
|
|
136
|
+
|
|
137
|
+
-- ----- matcher (backtracking, CPS over Maybe) -----
|
|
138
|
+
|
|
139
|
+
isWord :: Char -> Bool
|
|
140
|
+
isWord c = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
|
|
141
|
+
|| (c >= '0' && c <= '9') || c == '_'
|
|
142
|
+
|
|
143
|
+
spaceChars :: String
|
|
144
|
+
spaceChars = [' ', '\t', '\n', '\r', '\f', '\v']
|
|
145
|
+
|
|
146
|
+
citemMatch :: Citem -> Char -> Bool
|
|
147
|
+
citemMatch it c = case it of
|
|
148
|
+
CChar x -> c == x
|
|
149
|
+
CRange a b -> c >= a && c <= b
|
|
150
|
+
CD -> c >= '0' && c <= '9'
|
|
151
|
+
CND -> not (c >= '0' && c <= '9')
|
|
152
|
+
CW -> isWord c
|
|
153
|
+
CNW -> not (isWord c)
|
|
154
|
+
CS -> c `elem` spaceChars
|
|
155
|
+
CNS -> not (c `elem` spaceChars)
|
|
156
|
+
|
|
157
|
+
mNode :: (Int -> Char) -> Int -> Node -> Int -> (Int -> Maybe r) -> Maybe r
|
|
158
|
+
mNode inp len node pos k = case node of
|
|
159
|
+
Char c -> if pos < len && inp pos == c then k (pos + 1) else Nothing
|
|
160
|
+
Any -> if pos < len && inp pos /= '\n' then k (pos + 1) else Nothing
|
|
161
|
+
Start -> if pos == 0 then k pos else Nothing
|
|
162
|
+
End -> if pos == len then k pos else Nothing
|
|
163
|
+
WordB ->
|
|
164
|
+
let before = pos > 0 && isWord (inp (pos - 1))
|
|
165
|
+
after = pos < len && isWord (inp pos)
|
|
166
|
+
in if before /= after then k pos else Nothing
|
|
167
|
+
Cls neg items ->
|
|
168
|
+
if pos < len
|
|
169
|
+
then let c = inp pos
|
|
170
|
+
hit = any (`citemMatch` c) items
|
|
171
|
+
in if (if neg then not hit else hit) then k (pos + 1) else Nothing
|
|
172
|
+
else Nothing
|
|
173
|
+
Grp alts -> asum [mSeq inp len sq pos k | sq <- alts]
|
|
174
|
+
Opt greedy a ->
|
|
175
|
+
if greedy then mNode inp len a pos k <|> k pos
|
|
176
|
+
else k pos <|> mNode inp len a pos k
|
|
177
|
+
Star greedy a -> mStar inp len greedy a pos k
|
|
178
|
+
Plus greedy a -> mNode inp len a pos (\p -> mStar inp len greedy a p k)
|
|
179
|
+
Rep greedy mn mx a -> mRep inp len greedy mn mx a pos k
|
|
180
|
+
|
|
181
|
+
mStar :: (Int -> Char) -> Int -> Bool -> Node -> Int -> (Int -> Maybe r) -> Maybe r
|
|
182
|
+
mStar inp len greedy a pos k =
|
|
183
|
+
if greedy
|
|
184
|
+
then mNode inp len a pos (\p -> if p > pos then mStar inp len greedy a p k else Nothing) <|> k pos
|
|
185
|
+
else k pos <|> mNode inp len a pos (\p -> if p > pos then mStar inp len greedy a p k else Nothing)
|
|
186
|
+
|
|
187
|
+
mRep :: (Int -> Char) -> Int -> Bool -> Int -> Maybe Int -> Node -> Int -> (Int -> Maybe r) -> Maybe r
|
|
188
|
+
mRep inp len greedy mn mx a pos k =
|
|
189
|
+
if mn > 0
|
|
190
|
+
then mNode inp len a pos (\p -> mRep inp len greedy (mn - 1) (fmap (subtract 1) mx) a p k)
|
|
191
|
+
else case mx of
|
|
192
|
+
Just 0 -> k pos
|
|
193
|
+
_ ->
|
|
194
|
+
let next p = if p > pos then mRep inp len greedy 0 (fmap (subtract 1) mx) a p k else Nothing
|
|
195
|
+
in if greedy then mNode inp len a pos next <|> k pos
|
|
196
|
+
else k pos <|> mNode inp len a pos next
|
|
197
|
+
|
|
198
|
+
mSeq :: (Int -> Char) -> Int -> [Node] -> Int -> (Int -> Maybe r) -> Maybe r
|
|
199
|
+
mSeq inp len sq pos k = case sq of
|
|
200
|
+
[] -> k pos
|
|
201
|
+
(x:rest) -> mNode inp len x pos (\p -> mSeq inp len rest p k)
|
|
202
|
+
|
|
203
|
+
-- Compiled = the alternation AST.
|
|
204
|
+
type Re = [[Node]]
|
|
205
|
+
|
|
206
|
+
compile :: String -> Re
|
|
207
|
+
compile = parse
|
|
208
|
+
|
|
209
|
+
mkInp :: String -> (Int -> Char, Int)
|
|
210
|
+
mkInp input =
|
|
211
|
+
let len = length input
|
|
212
|
+
arr = listArray (0, len - 1) input :: Array Int Char
|
|
213
|
+
in ((arr !), len)
|
|
214
|
+
|
|
215
|
+
-- Does the pattern match anywhere in input?
|
|
216
|
+
test :: Re -> String -> Bool
|
|
217
|
+
test re input = tryAt 0
|
|
218
|
+
where
|
|
219
|
+
(inp, len) = mkInp input
|
|
220
|
+
tryAt i
|
|
221
|
+
| any (\sq -> isJust (mSeq inp len sq i (\_ -> Just ()))) re = True
|
|
222
|
+
| i >= len = False
|
|
223
|
+
| otherwise = tryAt (i + 1)
|
|
224
|
+
|
|
225
|
+
testStr :: String -> String -> Bool
|
|
226
|
+
testStr pat input = test (compile pat) input
|
|
227
|
+
|
|
228
|
+
-- Leftmost match: returns (start, stop) or Nothing. Used by the public re_* API.
|
|
229
|
+
findBounds :: Re -> String -> Maybe (Int, Int)
|
|
230
|
+
findBounds re input = tryAt 0
|
|
231
|
+
where
|
|
232
|
+
(inp, len) = mkInp input
|
|
233
|
+
tryAt i
|
|
234
|
+
| i > len = Nothing
|
|
235
|
+
| otherwise = case asum [mSeq inp len sq i Just | sq <- re] of
|
|
236
|
+
Just p -> Just (i, p)
|
|
237
|
+
Nothing -> tryAt (i + 1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
-- Offline feature-test harness (mirrors the dynamic donors' feature_harness).
|
|
2
|
+
--
|
|
3
|
+
-- Drives each real generated feature through a faithful miniature of the
|
|
4
|
+
-- operation pipeline against a configurable mock transport — the same hook
|
|
5
|
+
-- order and short-circuit rules as the generic op runner, but with no live
|
|
6
|
+
-- server and no API-specific fixtures. Features come from SdkConfig.makeFeature
|
|
7
|
+
-- so only features present in this SDK are exercised (see hasFeature).
|
|
8
|
+
|
|
9
|
+
{-# LANGUAGE ScopedTypeVariables #-}
|
|
10
|
+
|
|
11
|
+
module Harness where
|
|
12
|
+
|
|
13
|
+
import Control.Exception (SomeException, try)
|
|
14
|
+
import Data.IORef
|
|
15
|
+
import Data.List (sort)
|
|
16
|
+
|
|
17
|
+
import VoxgigStruct
|
|
18
|
+
( Value (..), emptyMap, emptyList, mkList, keysof, clone, ismap, escurl, vint
|
|
19
|
+
, isNoval, isNullish, setprop )
|
|
20
|
+
import SdkTypes
|
|
21
|
+
import SdkHelpers
|
|
22
|
+
import SdkRuntime
|
|
23
|
+
import qualified SdkConfig as Cfg
|
|
24
|
+
|
|
25
|
+
-- ----- virtual clock -----
|
|
26
|
+
|
|
27
|
+
data Clock = Clock { clkT :: IORef Double }
|
|
28
|
+
|
|
29
|
+
makeClock :: IO Clock
|
|
30
|
+
makeClock = Clock <$> newIORef 0
|
|
31
|
+
|
|
32
|
+
clockNow :: Clock -> IO Double
|
|
33
|
+
clockNow c = readIORef (clkT c)
|
|
34
|
+
|
|
35
|
+
clockAdvance :: Clock -> Double -> IO ()
|
|
36
|
+
clockAdvance c ms = modifyIORef' (clkT c) (+ ms)
|
|
37
|
+
|
|
38
|
+
clockNowFn :: Clock -> Value
|
|
39
|
+
clockNowFn c = VFunc (\_ _ _ _ -> VNum <$> readIORef (clkT c))
|
|
40
|
+
|
|
41
|
+
clockSleepFn :: Clock -> Value
|
|
42
|
+
clockSleepFn c = VFunc (\_ v _ _ -> do
|
|
43
|
+
case v of VNum ms -> modifyIORef' (clkT c) (+ (if ms < 0 then 0 else ms)); _ -> pure ()
|
|
44
|
+
pure VNoval)
|
|
45
|
+
|
|
46
|
+
-- ----- transport-shaped response -----
|
|
47
|
+
|
|
48
|
+
makeResponse :: Int -> Value -> [(String, Value)] -> IO Value
|
|
49
|
+
makeResponse status dat headers = do
|
|
50
|
+
lower <- emptyMap
|
|
51
|
+
mapM_ (\(k, v) -> setp lower (lower' k) v) headers
|
|
52
|
+
jo [ ("status", vint status)
|
|
53
|
+
, ("statusText", VStr (if status < 400 then "OK" else "ERR"))
|
|
54
|
+
, ("body", VStr "not-used"), ("json", jsonThunk dat), ("headers", lower) ]
|
|
55
|
+
where lower' = map toLowerC
|
|
56
|
+
toLowerC ch = if ch >= 'A' && ch <= 'Z' then toEnum (fromEnum ch + 32) else ch
|
|
57
|
+
|
|
58
|
+
type Server = Fetcher
|
|
59
|
+
|
|
60
|
+
defaultServer :: Server
|
|
61
|
+
defaultServer = \_ _ fetchdef -> do
|
|
62
|
+
m <- getp fetchdef "method"
|
|
63
|
+
let meth = case m of VStr s -> upper s; _ -> "GET"
|
|
64
|
+
if meth == "GET"
|
|
65
|
+
then do d <- jo [("ok", VBool True), ("method", VStr meth)]; r <- makeResponse 200 d []; pure (r, Nothing)
|
|
66
|
+
else do b <- getp fetchdef "body"; d <- jo [("ok", VBool True), ("method", VStr meth), ("echo", b)]; r <- makeResponse 200 d []; pure (r, Nothing)
|
|
67
|
+
|
|
68
|
+
-- A recorder: records every call; optional reply (callNo, fetchdef) -> (resp, err).
|
|
69
|
+
recordingServer :: Maybe (Int -> Value -> IO (Value, Maybe Value)) -> IO (Server, IORef [Value])
|
|
70
|
+
recordingServer mreply = do
|
|
71
|
+
callsRef <- newIORef []
|
|
72
|
+
let srv _ url fetchdef = do
|
|
73
|
+
rec0 <- jo [("url", VStr url), ("fetchdef", fetchdef)]
|
|
74
|
+
modifyIORef callsRef (++ [rec0])
|
|
75
|
+
cs <- readIORef callsRef
|
|
76
|
+
let n = length cs
|
|
77
|
+
case mreply of
|
|
78
|
+
Just r -> r n fetchdef
|
|
79
|
+
Nothing -> do d <- jo [("ok", VBool True), ("n", vint n)]; resp <- makeResponse 200 d []; pure (resp, Nothing)
|
|
80
|
+
pure (srv, callsRef)
|
|
81
|
+
|
|
82
|
+
-- ----- feature presence -----
|
|
83
|
+
|
|
84
|
+
-- A feature is present when the generated feature factory dispatches the
|
|
85
|
+
-- name to a real implementation. In this SDK every feature is always
|
|
86
|
+
-- compiled in (Cfg.makeFeature maps each known name to its own factory and
|
|
87
|
+
-- falls back to the "base" feature for unknown names), so presence is
|
|
88
|
+
-- determined by the factory, not by the model's default-active `feature`
|
|
89
|
+
-- map (which for a minimal API may list only `test`).
|
|
90
|
+
hasFeature :: String -> IO Bool
|
|
91
|
+
hasFeature name = do
|
|
92
|
+
ftr <- Cfg.makeFeature name
|
|
93
|
+
pure (fName ftr == name)
|
|
94
|
+
|
|
95
|
+
-- ----- harness -----
|
|
96
|
+
|
|
97
|
+
data Harness = Harness
|
|
98
|
+
{ hBase :: String
|
|
99
|
+
, hHeaders :: Value
|
|
100
|
+
, hClient :: Client
|
|
101
|
+
, hUtility :: Utility
|
|
102
|
+
, hRootctx :: Context
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
data OpResult = OpResult
|
|
106
|
+
{ orOk :: Bool
|
|
107
|
+
, orData :: Value
|
|
108
|
+
, orResult :: Value
|
|
109
|
+
, orCtx :: Context
|
|
110
|
+
, orErr :: Maybe Value
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
makeClientH :: [(String, Value)] -> Maybe Server -> [(String, Value)] -> IO Harness
|
|
114
|
+
makeClientH features mServer headers = do
|
|
115
|
+
hheaders <- emptyMap
|
|
116
|
+
mapM_ (\(k, v) -> setp hheaders k v) headers
|
|
117
|
+
let srv = maybe defaultServer id mServer
|
|
118
|
+
utility <- newUtility
|
|
119
|
+
writeIORef (uFetcher utility) srv
|
|
120
|
+
writeIORef (uParam utility) paramFn
|
|
121
|
+
modeR <- newIORef "test"; featsR <- newIORef []; rootR <- newIORef Nothing; trackR <- newIORef =<< emptyMap
|
|
122
|
+
hh <- clone hheaders
|
|
123
|
+
fm0 <- emptyMap
|
|
124
|
+
optsMap <- jo [("base", VStr "http://api.test"), ("headers", hh), ("feature", fm0)]
|
|
125
|
+
optsR <- newIORef optsMap
|
|
126
|
+
cfg <- Cfg.makeConfig
|
|
127
|
+
let client = Client { clMode = modeR, clFeatures = featsR, clOptions = optsR, clUtility = utility
|
|
128
|
+
, clRootctx = rootR, clTrack = trackR, clConfig = cfg, clMakeFeature = Cfg.makeFeature }
|
|
129
|
+
rootctx <- makeContextImpl (defaultCtxSpec { csClient = Just client, csUtility = Just utility }) Nothing
|
|
130
|
+
rootOp <- newOperation =<< jo [("name", VStr "root"), ("entity", VStr "_")]
|
|
131
|
+
writeIORef (cOp rootctx) rootOp
|
|
132
|
+
writeIORef rootR (Just rootctx)
|
|
133
|
+
mapM_ (addFeature client rootctx) features
|
|
134
|
+
featureHookUtil rootctx "PostConstruct"
|
|
135
|
+
pure Harness { hBase = "http://api.test", hHeaders = hheaders, hClient = client, hUtility = utility, hRootctx = rootctx }
|
|
136
|
+
where
|
|
137
|
+
paramFn ctx name = do
|
|
138
|
+
let key = case name of VStr s -> s; _ -> ""
|
|
139
|
+
specV <- readIORef (cSpec ctx)
|
|
140
|
+
case specV of
|
|
141
|
+
VMap _ -> do
|
|
142
|
+
params <- getp specV "params"; v <- getp params key
|
|
143
|
+
if not (isNoval v) then pure v else do query <- getp specV "query"; getp query key
|
|
144
|
+
_ -> pure VNoval
|
|
145
|
+
addFeature client rootctx (name, opts) = do
|
|
146
|
+
present <- hasFeature name
|
|
147
|
+
if not present then pure ()
|
|
148
|
+
else do
|
|
149
|
+
ftr <- Cfg.makeFeature name
|
|
150
|
+
fopts <- jo [("active", VBool True)]
|
|
151
|
+
case opts of VMap _ -> do { ks <- keysof opts; mapM_ (\k -> do { v <- getp opts k; setp fopts k v }) ks }; _ -> pure ()
|
|
152
|
+
optsV <- readIORef (clOptions client)
|
|
153
|
+
featm <- getp optsV "feature"
|
|
154
|
+
case featm of VMap _ -> setp featm name fopts; _ -> pure ()
|
|
155
|
+
fInit ftr rootctx fopts
|
|
156
|
+
modifyIORef (clFeatures client) (++ [ftr])
|
|
157
|
+
|
|
158
|
+
harnessFeature :: Harness -> String -> IO (Maybe Feature)
|
|
159
|
+
harnessFeature h name = do fs <- readIORef (clFeatures (hClient h)); pure (findF fs)
|
|
160
|
+
where findF [] = Nothing
|
|
161
|
+
findF (f : rest) = if fName f == name then Just f else findF rest
|
|
162
|
+
|
|
163
|
+
data OpArgs = OpArgs
|
|
164
|
+
{ oaOp :: String
|
|
165
|
+
, oaEntity :: String
|
|
166
|
+
, oaMethod :: Maybe String
|
|
167
|
+
, oaPath :: Maybe String
|
|
168
|
+
, oaQuery :: Maybe Value
|
|
169
|
+
, oaHeaders :: [(String, Value)]
|
|
170
|
+
, oaBody :: Value
|
|
171
|
+
, oaCtrl :: Value
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
defaultOpArgs :: OpArgs
|
|
175
|
+
defaultOpArgs = OpArgs "load" "widget" Nothing Nothing Nothing [] VNoval VNoval
|
|
176
|
+
|
|
177
|
+
defaultMethodH :: String -> String
|
|
178
|
+
defaultMethodH op = case op of "create" -> "POST"; "update" -> "PATCH"; "remove" -> "DELETE"; _ -> "GET"
|
|
179
|
+
|
|
180
|
+
buildUrl :: Value -> IO String
|
|
181
|
+
buildUrl spec = do
|
|
182
|
+
base <- getStrD spec "base" ""
|
|
183
|
+
path <- getStrD spec "path" ""
|
|
184
|
+
qv <- getp spec "query"
|
|
185
|
+
q <- case qv of VMap _ -> pure qv; _ -> emptyMap
|
|
186
|
+
ks0 <- keysof q
|
|
187
|
+
present <- filterM' (\k -> do v <- getp q k; pure (not (isNoval v))) ks0
|
|
188
|
+
let keys = sort present
|
|
189
|
+
parts <- mapM (\k -> do v <- getp q k; ek <- escurlS k; ev <- escurlS (vstring v); pure (ek ++ "=" ++ ev)) keys
|
|
190
|
+
let qs = intercalate' "&" parts
|
|
191
|
+
pure (base ++ path ++ (if null qs then "" else "?" ++ qs))
|
|
192
|
+
|
|
193
|
+
filterM' :: (a -> IO Bool) -> [a] -> IO [a]
|
|
194
|
+
filterM' _ [] = pure []
|
|
195
|
+
filterM' p (x : xs) = do b <- p x; rest <- filterM' p xs; pure (if b then x : rest else rest)
|
|
196
|
+
|
|
197
|
+
populateResultH :: Context -> Value -> Maybe Value -> IO ()
|
|
198
|
+
populateResultH ctx response fetchErr = do
|
|
199
|
+
result <- newResult =<< emptyMap
|
|
200
|
+
writeIORef (cResult ctx) result
|
|
201
|
+
case fetchErr of
|
|
202
|
+
Just e -> setp result "err" e
|
|
203
|
+
Nothing ->
|
|
204
|
+
if isNoval response || isNullV response
|
|
205
|
+
then do e <- mkErr "request_no_response" "response: undefined"; setp result "err" e
|
|
206
|
+
else case response of
|
|
207
|
+
VMap _ -> do
|
|
208
|
+
st <- getp response "status"; setp result "status" st
|
|
209
|
+
stt <- getStrD response "statusText" ""; setp result "statusText" (VStr stt)
|
|
210
|
+
h <- getp response "headers"; hc <- case h of { VMap _ -> clone h; _ -> emptyMap }; setp result "headers" hc
|
|
211
|
+
jsn <- getp response "json"
|
|
212
|
+
case jsn of VFunc _ -> do { d <- callJson jsn; setp result "body" d }; _ -> pure ()
|
|
213
|
+
body <- getp result "body"; setp result "resdata" body
|
|
214
|
+
let status = toInt st
|
|
215
|
+
if status >= 400
|
|
216
|
+
then do e <- mkErr "request_status" ("request: " ++ show status ++ ": " ++ stt); setp result "err" e
|
|
217
|
+
else pure ()
|
|
218
|
+
errv <- getp result "err"; isE <- isErr errv
|
|
219
|
+
if not isE then setp result "ok" (VBool True) else pure ()
|
|
220
|
+
_ -> do e <- mkErr "op_failed" "invalid response"; setp result "err" e
|
|
221
|
+
|
|
222
|
+
runOpH :: Harness -> OpArgs -> IO OpResult
|
|
223
|
+
runOpH h oa = do
|
|
224
|
+
let opname = oaOp oa
|
|
225
|
+
entity = oaEntity oa
|
|
226
|
+
meth = maybe (defaultMethodH opname) id (oaMethod oa)
|
|
227
|
+
ctrlM <- case oaCtrl oa of VMap _ -> pure (oaCtrl oa); _ -> emptyMap
|
|
228
|
+
ctx <- makeContextImpl (defaultCtxSpec { csClient = Just (hClient h), csUtility = Just (hUtility h), csCtrl = Just ctrlM }) (Just (hRootctx h))
|
|
229
|
+
op <- newOperation =<< jo [("name", VStr opname), ("entity", VStr entity)]
|
|
230
|
+
writeIORef (cOp ctx) op
|
|
231
|
+
let fh n = featureHookUtil ctx n
|
|
232
|
+
finishErr err = do
|
|
233
|
+
ctrl <- readIORef (cCtrl ctx); setp ctrl "err" err
|
|
234
|
+
fh "PreUnexpected"
|
|
235
|
+
rv <- readIORef (cResult ctx)
|
|
236
|
+
pure OpResult { orOk = False, orResult = rv, orCtx = ctx, orData = VNoval, orErr = Just err }
|
|
237
|
+
fh "PostConstructEntity"
|
|
238
|
+
fh "PrePoint"
|
|
239
|
+
out <- readIORef (cOut ctx)
|
|
240
|
+
prePoint <- getp out "point"; isPE <- isErr prePoint
|
|
241
|
+
if isPE then finishErr prePoint
|
|
242
|
+
else do
|
|
243
|
+
fh "PreSpec"
|
|
244
|
+
preSpec <- getp out "spec"
|
|
245
|
+
spec <- case preSpec of
|
|
246
|
+
VMap _ -> pure preSpec
|
|
247
|
+
_ -> do
|
|
248
|
+
merged <- clone (hHeaders h); mm <- case merged of VMap _ -> pure merged; _ -> emptyMap
|
|
249
|
+
mapM_ (\(k, v) -> setp mm k v) (oaHeaders oa)
|
|
250
|
+
q <- case oaQuery oa of Just qq -> pure qq; Nothing -> emptyMap
|
|
251
|
+
pm <- emptyMap
|
|
252
|
+
newSpec =<< jo [ ("method", VStr meth), ("base", VStr (hBase h))
|
|
253
|
+
, ("path", VStr (maybe ("/" ++ entity) id (oaPath oa)))
|
|
254
|
+
, ("params", pm), ("headers", mm), ("query", q)
|
|
255
|
+
, ("body", oaBody oa), ("step", VStr "start") ]
|
|
256
|
+
writeIORef (cSpec ctx) spec
|
|
257
|
+
fh "PreRequest"
|
|
258
|
+
url <- buildUrl spec; setp spec "url" (VStr url)
|
|
259
|
+
preReq <- getp out "request"
|
|
260
|
+
(response, fetchErr) <- case preReq of
|
|
261
|
+
VMap _ -> pure (preReq, Nothing)
|
|
262
|
+
_ -> do
|
|
263
|
+
method0 <- getp spec "method"; headers0 <- getp spec "headers"; body0 <- getp spec "body"
|
|
264
|
+
fetchdef <- jo [("url", VStr url), ("method", method0), ("headers", headers0), ("body", body0)]
|
|
265
|
+
fetcher <- readIORef (uFetcher (hUtility h))
|
|
266
|
+
fetcher ctx url fetchdef
|
|
267
|
+
writeIORef (cResponse ctx) (case response of VMap _ -> response; _ -> VNoval)
|
|
268
|
+
fh "PreResponse"
|
|
269
|
+
populateResultH ctx response fetchErr
|
|
270
|
+
fh "PreResult"
|
|
271
|
+
fh "PreDone"
|
|
272
|
+
rv <- readIORef (cResult ctx)
|
|
273
|
+
ok <- case rv of VMap _ -> isTrueV <$> getp rv "ok"; _ -> pure False
|
|
274
|
+
if ok
|
|
275
|
+
then do rd <- getp rv "resdata"; pure OpResult { orOk = True, orData = rd, orResult = rv, orCtx = ctx, orErr = Nothing }
|
|
276
|
+
else do
|
|
277
|
+
errv <- case rv of VMap _ -> getp rv "err"; _ -> pure VNoval
|
|
278
|
+
isE <- isErr errv
|
|
279
|
+
e <- if isE then pure errv else mkErr "op_failed" "operation failed"
|
|
280
|
+
finishErr e
|
|
281
|
+
|