@voxgig/sdkgen 1.5.1 → 2.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/dist/cmp/AgentGuideContent.js +5 -0
- package/dist/cmp/AgentGuideContent.js.map +1 -1
- package/dist/cmp/Feature.js +13 -0
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/helpers/canonType.d.ts +3 -1
- package/dist/helpers/canonType.js +44 -1
- package/dist/helpers/canonType.js.map +1 -1
- package/dist/helpers/packageMeta.js +7 -0
- package/dist/helpers/packageMeta.js.map +1 -1
- package/dist/sdkgen.d.ts +3 -3
- package/dist/sdkgen.js +4 -1
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/project/.sdk/model/feature/paging.aontu +7 -0
- package/project/.sdk/model/target/py-data.aontu +64 -0
- package/project/.sdk/src/cmp/c/fragment/Main.fragment.c +89 -1
- package/project/.sdk/src/cmp/clojure/Main_clojure.ts +1 -0
- package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +97 -0
- package/project/.sdk/src/cmp/dart/fragment/Main.fragment.dart +78 -0
- package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +84 -0
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +87 -0
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +75 -0
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +85 -0
- package/project/.sdk/src/cmp/ocaml/Main_ocaml.ts +4 -0
- package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +80 -0
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +86 -0
- package/project/.sdk/src/cmp/py/Entity_py.ts +9 -2
- package/project/.sdk/src/cmp/py/MainEntity_py.ts +1 -1
- package/project/.sdk/src/cmp/py/Main_py.ts +34 -6
- package/project/.sdk/src/cmp/py/Package_py.ts +6 -9
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +2 -2
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +3 -3
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +2 -2
- package/project/.sdk/src/cmp/py/fragment/EntityCreateOp.fragment.py +2 -2
- package/project/.sdk/src/cmp/py/fragment/EntityLoadOp.fragment.py +2 -2
- package/project/.sdk/src/cmp/py/fragment/EntityRemoveOp.fragment.py +2 -2
- package/project/.sdk/src/cmp/py/fragment/EntityUpdateOp.fragment.py +2 -2
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +75 -8
- package/project/.sdk/src/cmp/py-data/Main_py-data.ts +987 -0
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +71 -0
- package/project/.sdk/src/cmp/rust/fragment/Main.fragment.rs +95 -0
- package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +86 -0
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +75 -0
- package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +95 -0
- package/project/.sdk/tm/c/core/sdk.h +7 -0
- package/project/.sdk/tm/c/feature/paging.c +141 -2
- package/project/.sdk/tm/c/utility/graphql.c +178 -0
- package/project/.sdk/tm/c/utility/make_options.c +1 -1
- package/project/.sdk/tm/c/utility/make_response.c +6 -0
- package/project/.sdk/tm/c/utility/make_spec.c +23 -3
- package/project/.sdk/tm/clojure/src/sdk/client.clj +64 -1
- package/project/.sdk/tm/clojure/src/sdk/core.clj +126 -3
- package/project/.sdk/tm/clojure/src/sdk/features.clj +80 -14
- package/project/.sdk/tm/cpp/core/types.hpp +83 -0
- package/project/.sdk/tm/cpp/feature/paging.hpp +103 -1
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +152 -3
- package/project/.sdk/tm/csharp/core/Utility.cs +4 -0
- package/project/.sdk/tm/csharp/feature/PagingFeature.cs +118 -1
- package/project/.sdk/tm/csharp/utility/Graphql.cs +190 -0
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +1 -1
- package/project/.sdk/tm/csharp/utility/MakeResponse.cs +7 -0
- package/project/.sdk/tm/csharp/utility/MakeSpec.cs +21 -2
- package/project/.sdk/tm/csharp/utility/Register.cs +2 -0
- package/project/.sdk/tm/dart/lib/Point.dart +7 -0
- package/project/.sdk/tm/dart/lib/feature/paging/PagingFeature.dart +99 -4
- package/project/.sdk/tm/dart/lib/utility/GraphqlUtility.dart +162 -0
- package/project/.sdk/tm/dart/lib/utility/MakeOptionsUtility.dart +1 -1
- package/project/.sdk/tm/dart/lib/utility/MakeResponseUtility.dart +5 -0
- package/project/.sdk/tm/dart/lib/utility/MakeSpecUtility.dart +18 -2
- package/project/.sdk/tm/dart/lib/utility/PrepareMethodUtility.dart +6 -1
- package/project/.sdk/tm/dart/lib/utility/Utility.dart +9 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/paging.ex +136 -13
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +187 -3
- package/project/.sdk/tm/go/core/utility_type.go +2 -0
- package/project/.sdk/tm/go/feature/paging_feature.go +87 -1
- package/project/.sdk/tm/go/utility/graphql.go +168 -0
- package/project/.sdk/tm/go/utility/make_options.go +1 -1
- package/project/.sdk/tm/go/utility/make_response.go +6 -0
- package/project/.sdk/tm/go/utility/make_spec.go +19 -2
- package/project/.sdk/tm/go/utility/register.go +2 -0
- package/project/.sdk/tm/haskell/src/SdkFeatures.hs +146 -7
- package/project/.sdk/tm/haskell/src/SdkRuntime.hs +153 -3
- package/project/.sdk/tm/java/core/SdkClient.java +93 -0
- package/project/.sdk/tm/java/core/Utility.java +4 -0
- package/project/.sdk/tm/java/feature/PagingFeature.java +100 -1
- package/project/.sdk/tm/java/utility/Graphql.java +191 -0
- package/project/.sdk/tm/java/utility/MakeOptions.java +1 -1
- package/project/.sdk/tm/java/utility/MakeResponse.java +6 -0
- package/project/.sdk/tm/java/utility/MakeSpec.java +17 -2
- package/project/.sdk/tm/java/utility/Register.java +2 -0
- package/project/.sdk/tm/js/src/Point.js +5 -0
- package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +82 -3
- package/project/.sdk/tm/js/src/feature/test/TestFeature.js +14 -2
- package/project/.sdk/tm/js/src/utility/GraphqlUtility.js +148 -0
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +1 -1
- package/project/.sdk/tm/js/src/utility/MakeResponseUtility.js +7 -0
- package/project/.sdk/tm/js/src/utility/MakeSpecUtility.js +19 -2
- package/project/.sdk/tm/js/src/utility/Utility.js +4 -0
- package/project/.sdk/tm/kotlin/core/SdkClient.kt +84 -0
- package/project/.sdk/tm/kotlin/core/Utility.kt +2 -0
- package/project/.sdk/tm/kotlin/feature/PagingFeature.kt +92 -1
- package/project/.sdk/tm/kotlin/utility/Graphql.kt +145 -0
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +1 -1
- package/project/.sdk/tm/kotlin/utility/MakeReqRes.kt +6 -0
- package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +17 -2
- package/project/.sdk/tm/kotlin/utility/Register.kt +2 -0
- package/project/.sdk/tm/lean/src/SdkUtility.lean +134 -1
- package/project/.sdk/tm/lua/feature/paging_feature.lua +97 -2
- package/project/.sdk/tm/lua/utility/graphql.lua +163 -0
- package/project/.sdk/tm/lua/utility/make_options.lua +1 -1
- package/project/.sdk/tm/lua/utility/make_response.lua +6 -0
- package/project/.sdk/tm/lua/utility/make_spec.lua +18 -2
- package/project/.sdk/tm/lua/utility/register.lua +3 -0
- package/project/.sdk/tm/ocaml/sdk_features.ml +164 -20
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +143 -4
- package/project/.sdk/tm/ocaml/sdk_types.ml +2 -0
- package/project/.sdk/tm/perl/feature/paging_feature.pm +91 -3
- package/project/.sdk/tm/perl/utility/graphql.pm +150 -0
- package/project/.sdk/tm/perl/utility/make_options.pm +1 -1
- package/project/.sdk/tm/perl/utility/make_response.pm +6 -0
- package/project/.sdk/tm/perl/utility/make_spec.pm +20 -2
- package/project/.sdk/tm/perl/utility/register.pm +1 -0
- package/project/.sdk/tm/php/core/UtilityType.php +2 -0
- package/project/.sdk/tm/php/feature/PagingFeature.php +106 -4
- package/project/.sdk/tm/php/utility/Graphql.php +176 -0
- package/project/.sdk/tm/php/utility/MakeOptions.php +1 -1
- package/project/.sdk/tm/php/utility/MakeResponse.php +7 -0
- package/project/.sdk/tm/php/utility/MakeSpec.php +20 -2
- package/project/.sdk/tm/php/utility/Register.php +3 -0
- package/project/.sdk/tm/py/pkg/core/__init__.py +0 -0
- package/project/.sdk/tm/py/{core → pkg/core}/context.py +8 -8
- package/project/.sdk/tm/py/{core → pkg/core}/operation.py +1 -1
- package/project/.sdk/tm/py/{core → pkg/core}/response.py +1 -1
- package/project/.sdk/tm/py/{core → pkg/core}/result.py +1 -1
- package/project/.sdk/tm/py/{core → pkg/core}/utility_type.py +2 -0
- package/project/.sdk/tm/py/pkg/entity/__init__.py +0 -0
- package/project/.sdk/tm/py/pkg/feature/__init__.py +0 -0
- package/project/.sdk/tm/py/{feature → pkg/feature}/audit_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/cache_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/clienttrack_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/debug_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/idempotency_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/log_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/metrics_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/netsim_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/paging_feature.py +87 -6
- package/project/.sdk/tm/py/{feature → pkg/feature}/proxy_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/ratelimit_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/rbac_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/retry_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/streaming_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/telemetry_feature.py +1 -1
- package/project/.sdk/tm/py/{feature → pkg/feature}/test_feature.py +2 -2
- package/project/.sdk/tm/py/{feature → pkg/feature}/timeout_feature.py +1 -1
- package/project/.sdk/tm/py/pkg/utility/__init__.py +0 -0
- package/project/.sdk/tm/py/{utility → pkg/utility}/feature_init.py +1 -1
- package/project/.sdk/tm/py/{utility → pkg/utility}/fetcher.py +1 -1
- package/project/.sdk/tm/py/pkg/utility/graphql.py +145 -0
- package/project/.sdk/tm/py/{utility → pkg/utility}/make_context.py +1 -1
- package/project/.sdk/tm/py/{utility → pkg/utility}/make_error.py +5 -5
- package/project/.sdk/tm/py/{utility → pkg/utility}/make_fetch_def.py +2 -2
- package/project/.sdk/tm/py/{utility → pkg/utility}/make_options.py +2 -2
- package/project/.sdk/tm/py/{utility → pkg/utility}/make_point.py +2 -2
- package/project/.sdk/tm/py/{utility → pkg/utility}/make_request.py +2 -2
- package/project/.sdk/tm/py/{utility → pkg/utility}/make_response.py +6 -0
- package/project/.sdk/tm/py/{utility → pkg/utility}/make_spec.py +19 -4
- package/project/.sdk/tm/py/{utility → pkg/utility}/make_url.py +1 -1
- package/project/.sdk/tm/py/{utility → pkg/utility}/param.py +2 -2
- package/project/.sdk/tm/py/{utility → pkg/utility}/prepare_auth.py +1 -1
- package/project/.sdk/tm/py/{utility → pkg/utility}/prepare_headers.py +1 -1
- package/project/.sdk/tm/py/{utility → pkg/utility}/prepare_method.py +1 -1
- package/project/.sdk/tm/py/{utility → pkg/utility}/prepare_params.py +1 -1
- package/project/.sdk/tm/py/{utility → pkg/utility}/prepare_path.py +1 -1
- package/project/.sdk/tm/py/{utility → pkg/utility}/prepare_query.py +1 -1
- package/project/.sdk/tm/py/pkg/utility/register.py +71 -0
- package/project/.sdk/tm/py/{utility → pkg/utility}/transform_request.py +2 -2
- package/project/.sdk/tm/py/{utility → pkg/utility}/transform_response.py +2 -2
- package/project/.sdk/tm/py/test/feature_harness.py +6 -6
- package/project/.sdk/tm/py/test/runner.py +1 -1
- package/project/.sdk/tm/py/test/struct_runner.py +1 -1
- package/project/.sdk/tm/py/test/test_pipeline.py +5 -5
- package/project/.sdk/tm/py/test/test_primary_utility.py +8 -8
- package/project/.sdk/tm/py/test/test_struct_utility.py +3 -3
- package/project/.sdk/tm/py-data/LICENSE +22 -0
- package/project/.sdk/tm/py-data/Makefile +57 -0
- package/project/.sdk/tm/py-data/pkg/auth.py +131 -0
- package/project/.sdk/tm/py-data/pkg/fetch.py +178 -0
- package/project/.sdk/tm/py-data/pkg/frames.py +236 -0
- package/project/.sdk/tm/py-data/src/feature/README.md +8 -0
- package/project/.sdk/tm/py-data/src/feature/debug/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/idempotency/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/log/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/metrics/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/netsim/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/paging/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/proxy/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/ratelimit/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/rbac/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/retry/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/streaming/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/telemetry/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/test/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/src/feature/timeout/.gitkeep +0 -0
- package/project/.sdk/tm/py-data/test/__init__.py +0 -0
- package/project/.sdk/tm/py-data/test/test_auth.py +95 -0
- package/project/.sdk/tm/py-data/test/test_fetch.py +152 -0
- package/project/.sdk/tm/py-data/test/test_frames.py +250 -0
- package/project/.sdk/tm/rb/core/utility_type.rb +1 -0
- package/project/.sdk/tm/rb/feature/paging_feature.rb +89 -3
- package/project/.sdk/tm/rb/utility/graphql.rb +131 -0
- package/project/.sdk/tm/rb/utility/make_options.rb +1 -1
- package/project/.sdk/tm/rb/utility/make_response.rb +6 -0
- package/project/.sdk/tm/rb/utility/make_spec.rb +18 -2
- package/project/.sdk/tm/rb/utility/register.rb +3 -0
- package/project/.sdk/tm/rust/feature/paging.rs +124 -2
- package/project/.sdk/tm/rust/utility/graphql.rs +193 -0
- package/project/.sdk/tm/rust/utility/make_options.rs +1 -1
- package/project/.sdk/tm/rust/utility/make_response.rs +6 -0
- package/project/.sdk/tm/rust/utility/make_spec.rs +32 -4
- package/project/.sdk/tm/rust/utility/mod.rs +1 -0
- package/project/.sdk/tm/scala/core/SdkClient.scala +90 -0
- package/project/.sdk/tm/scala/core/Utility.scala +4 -0
- package/project/.sdk/tm/scala/feature/PagingFeature.scala +104 -3
- package/project/.sdk/tm/scala/utility/Graphql.scala +160 -0
- package/project/.sdk/tm/scala/utility/Make.scala +7 -1
- package/project/.sdk/tm/scala/utility/MakeSpec.scala +22 -2
- package/project/.sdk/tm/scala/utility/Register.scala +2 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Utility.swift +4 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/PagingFeature.swift +86 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Graphql.swift +142 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Make.swift +24 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +1 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Register.swift +2 -0
- package/project/.sdk/tm/ts/src/Point.ts +7 -0
- package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +82 -3
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +14 -2
- package/project/.sdk/tm/ts/src/utility/GraphqlUtility.ts +152 -0
- package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +1 -1
- package/project/.sdk/tm/ts/src/utility/MakeResponseUtility.ts +7 -0
- package/project/.sdk/tm/ts/src/utility/MakeSpecUtility.ts +19 -2
- package/project/.sdk/tm/ts/src/utility/Utility.ts +4 -0
- package/project/.sdk/tm/zig/core/utility.zig +198 -3
- package/project/.sdk/tm/zig/feature/paging.zig +128 -1
- package/src/cmp/AgentGuideContent.ts +5 -0
- package/src/cmp/Feature.ts +13 -0
- package/src/helpers/canonType.ts +46 -0
- package/src/helpers/packageMeta.ts +7 -0
- package/src/sdkgen.ts +6 -1
- package/project/.sdk/tm/py/utility/register.py +0 -68
- /package/project/.sdk/tm/py/{core → pkg/core}/control.py +0 -0
- /package/project/.sdk/tm/py/{core → pkg/core}/error.py +0 -0
- /package/project/.sdk/tm/py/{core → pkg/core}/helpers.py +0 -0
- /package/project/.sdk/tm/py/{core → pkg/core}/spec.py +0 -0
- /package/project/.sdk/tm/py/{feature → pkg/feature}/base_feature.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/clean.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/done.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/feature_add.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/feature_hook.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/make_result.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/prepare_body.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/result_basic.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/result_body.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/result_headers.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/voxgig_struct/__init__.py +0 -0
- /package/project/.sdk/tm/py/{utility → pkg/utility}/voxgig_struct/voxgig_struct.py +0 -0
- /package/project/.sdk/tm/{py/core/__init__.py → py-data/src/feature/audit/.gitkeep} +0 -0
- /package/project/.sdk/tm/{py/entity/__init__.py → py-data/src/feature/base/.gitkeep} +0 -0
- /package/project/.sdk/tm/{py/feature/__init__.py → py-data/src/feature/cache/.gitkeep} +0 -0
- /package/project/.sdk/tm/{py/utility/__init__.py → py-data/src/feature/clienttrack/.gitkeep} +0 -0
|
File without changes
|
|
File without changes
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
import re
|
|
5
5
|
|
|
6
|
-
from
|
|
6
|
+
from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
|
|
7
|
+
|
|
8
|
+
from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
# Pagination support for list operations. On the way out (PreRequest) it
|
|
@@ -53,6 +55,14 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
|
|
|
53
55
|
if not isinstance(paging, dict):
|
|
54
56
|
paging = {}
|
|
55
57
|
|
|
58
|
+
# GraphQL paginates through operation VARIABLES, not the query
|
|
59
|
+
# string. This hook runs after make_spec, so spec.body already holds
|
|
60
|
+
# the { query, variables } envelope, and before make_fetch_def
|
|
61
|
+
# serialises it.
|
|
62
|
+
if "graphql" == vs.getprop(ctx.point, "kind"):
|
|
63
|
+
self._graphql_pre_request(ctx, paging)
|
|
64
|
+
return
|
|
65
|
+
|
|
56
66
|
if paging.get("cursor") is not None:
|
|
57
67
|
spec.query[cursor_param] = paging["cursor"]
|
|
58
68
|
elif spec.query.get(page_param) is None:
|
|
@@ -64,6 +74,39 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
|
|
|
64
74
|
if self.options.get("limit") is not None and spec.query.get(limit_param) is None:
|
|
65
75
|
spec.query[limit_param] = self.options.get("limit")
|
|
66
76
|
|
|
77
|
+
# Relay pagination: the cursor is the `after` variable (or whatever the
|
|
78
|
+
# model named it), and the page size is `first`.
|
|
79
|
+
def _graphql_pre_request(self, ctx, paging):
|
|
80
|
+
body = ctx.spec.body
|
|
81
|
+
if not isinstance(body, dict):
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
variables = body.get("variables")
|
|
85
|
+
if not isinstance(variables, dict):
|
|
86
|
+
variables = {}
|
|
87
|
+
body["variables"] = variables
|
|
88
|
+
|
|
89
|
+
after_var = self.options.get("afterVar") or "after"
|
|
90
|
+
first_var = self.options.get("firstVar") or "first"
|
|
91
|
+
|
|
92
|
+
# Only bind variables the operation actually declares, or the server
|
|
93
|
+
# rejects the document.
|
|
94
|
+
declared = set()
|
|
95
|
+
varlist = vs.getpath(ctx.point, "graphql.vars")
|
|
96
|
+
if isinstance(varlist, list):
|
|
97
|
+
for v in varlist:
|
|
98
|
+
name = vs.getprop(v, "name")
|
|
99
|
+
if name is not None:
|
|
100
|
+
declared.add(name)
|
|
101
|
+
|
|
102
|
+
if paging.get("cursor") is not None and after_var in declared:
|
|
103
|
+
variables[after_var] = paging["cursor"]
|
|
104
|
+
|
|
105
|
+
limit = self.options.get("limit")
|
|
106
|
+
if (limit is not None and variables.get(first_var) is None
|
|
107
|
+
and first_var in declared):
|
|
108
|
+
variables[first_var] = limit
|
|
109
|
+
|
|
67
110
|
def PreResult(self, ctx):
|
|
68
111
|
if not self.active:
|
|
69
112
|
return
|
|
@@ -92,6 +135,37 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
|
|
|
92
135
|
if m:
|
|
93
136
|
paging["next"] = m.group(1)
|
|
94
137
|
|
|
138
|
+
# Set when the response states hasMore outright, rather than leaving
|
|
139
|
+
# it to be inferred from the presence of a cursor.
|
|
140
|
+
explicit_more = False
|
|
141
|
+
|
|
142
|
+
# Relay connections carry the cursor in pageInfo, at the path the
|
|
143
|
+
# model recorded for this op.
|
|
144
|
+
page = vs.getpath(ctx.point, "graphql.page")
|
|
145
|
+
if isinstance(page, dict) and isinstance(body, dict):
|
|
146
|
+
# `connpath` locates the connection object inside the response
|
|
147
|
+
# envelope (data.<field>); the cursor/more paths are relative
|
|
148
|
+
# to it.
|
|
149
|
+
connpath = page.get("connpath")
|
|
150
|
+
conn = body
|
|
151
|
+
if isinstance(connpath, str) and "" != connpath:
|
|
152
|
+
sub = vs.getpath(body, connpath)
|
|
153
|
+
if sub is not None:
|
|
154
|
+
conn = sub
|
|
155
|
+
|
|
156
|
+
cursorpath = page.get("cursor")
|
|
157
|
+
if isinstance(cursorpath, str) and "" != cursorpath:
|
|
158
|
+
cursor = vs.getpath(conn, cursorpath)
|
|
159
|
+
if cursor is not None:
|
|
160
|
+
paging["cursor"] = cursor
|
|
161
|
+
|
|
162
|
+
morepath = page.get("more")
|
|
163
|
+
if isinstance(morepath, str) and "" != morepath:
|
|
164
|
+
more = vs.getpath(conn, morepath)
|
|
165
|
+
if isinstance(more, bool):
|
|
166
|
+
paging["hasMore"] = more
|
|
167
|
+
explicit_more = True
|
|
168
|
+
|
|
95
169
|
# Body-level cursors.
|
|
96
170
|
if isinstance(body, dict):
|
|
97
171
|
if body.get("next") is not None:
|
|
@@ -102,11 +176,18 @@ class ProjectNamePagingFeature(ProjectNameBaseFeature):
|
|
|
102
176
|
paging["cursor"] = body["nextCursor"]
|
|
103
177
|
if isinstance(body.get("hasMore"), bool):
|
|
104
178
|
paging["hasMore"] = body["hasMore"]
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
179
|
+
explicit_more = True
|
|
180
|
+
|
|
181
|
+
# Cursor presence only INFERS another page. When the server stated
|
|
182
|
+
# the answer outright — relay's `hasNextPage: false`, or a body
|
|
183
|
+
# `hasMore` — that wins: a final page normally carries both an end
|
|
184
|
+
# cursor and hasNextPage false, and inferring from the cursor there
|
|
185
|
+
# would send the caller back for a page that does not exist, forever.
|
|
186
|
+
if not explicit_more:
|
|
187
|
+
paging["hasMore"] = (paging["hasMore"]
|
|
188
|
+
or paging["next"] is not None
|
|
189
|
+
or paging["cursor"] is not None
|
|
190
|
+
or paging["nextPage"] is not None)
|
|
110
191
|
|
|
111
192
|
result.paging = paging
|
|
112
193
|
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
import os
|
|
5
5
|
import re
|
|
6
6
|
|
|
7
|
-
from feature.base_feature import ProjectNameBaseFeature
|
|
7
|
+
from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
# Outbound HTTP(S) proxy support. Wraps the active transport and attaches
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
import math
|
|
5
5
|
import time
|
|
6
6
|
|
|
7
|
-
from feature.base_feature import ProjectNameBaseFeature
|
|
7
|
+
from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
# Client-side rate limiting via a token bucket. Each request consumes a
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
import random
|
|
5
5
|
import time
|
|
6
6
|
|
|
7
|
-
from feature.base_feature import ProjectNameBaseFeature
|
|
7
|
+
from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
# Automatic retry of transient failures with exponential backoff and
|
|
@@ -5,8 +5,8 @@ import re
|
|
|
5
5
|
import random
|
|
6
6
|
import time
|
|
7
7
|
|
|
8
|
-
from utility.voxgig_struct import voxgig_struct as vs
|
|
9
|
-
from feature.base_feature import ProjectNameBaseFeature
|
|
8
|
+
from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
|
|
9
|
+
from projectname_sdk.feature.base_feature import ProjectNameBaseFeature
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
# The `body.<key>` form of an op's response transform: the mock wraps its
|
|
File without changes
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# ProjectName SDK utility: graphql
|
|
2
|
+
|
|
3
|
+
# GraphQL transport. API-INDEPENDENT: every GraphQL SDK this generator
|
|
4
|
+
# produces uses this file unchanged. The API-specific part — which
|
|
5
|
+
# operations exist and what each one's document is — is model data,
|
|
6
|
+
# computed once by apidef and emitted into Config.
|
|
7
|
+
#
|
|
8
|
+
# Two jobs:
|
|
9
|
+
#
|
|
10
|
+
# graphql_body — build { query, variables } for a point, binding the
|
|
11
|
+
# op's arguments to the document's declared variables.
|
|
12
|
+
#
|
|
13
|
+
# graphql_errors — lift a GraphQL failure into an SDK error. GraphQL
|
|
14
|
+
# reports failures as a top-level `errors` array under
|
|
15
|
+
# HTTP 200, so the status-driven path in result_basic
|
|
16
|
+
# never sees them.
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# Content type every GraphQL-over-HTTP request uses.
|
|
23
|
+
GRAPHQL_CONTENT_TYPE = "application/json"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def graphql_error_code(gqlerr):
|
|
27
|
+
"""Map a GraphQL error to the same error codes the HTTP path produces,
|
|
28
|
+
so a caller handles auth or rate limiting identically on both
|
|
29
|
+
transports. Servers put the machine-readable code in
|
|
30
|
+
`extensions.code`; Linear-style APIs use `extensions.type`."""
|
|
31
|
+
ext = vs.getprop(gqlerr, "extensions") or {}
|
|
32
|
+
|
|
33
|
+
raw = vs.getprop(ext, "code") or vs.getprop(ext, "type") or ""
|
|
34
|
+
raw = str(raw).upper()
|
|
35
|
+
|
|
36
|
+
if "AUTH" in raw or "FORBIDDEN" in raw or "UNAUTHENTICATED" in raw:
|
|
37
|
+
return "request_auth"
|
|
38
|
+
if "RATELIMIT" in raw or "RATE_LIMIT" in raw or "TOO_MANY" in raw:
|
|
39
|
+
return "request_ratelimit"
|
|
40
|
+
if "BAD_USER_INPUT" in raw or "VALIDATION" in raw or "INVALID" in raw:
|
|
41
|
+
return "request_invalid"
|
|
42
|
+
|
|
43
|
+
return "request_graphql"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def graphql_body_util(ctx):
|
|
47
|
+
"""Build the request body for a GraphQL point.
|
|
48
|
+
|
|
49
|
+
Variables come from the op's own arguments: a named variable binds to
|
|
50
|
+
the like-named argument (`from`), and the input-object variable (empty
|
|
51
|
+
`from`) takes the request data as a whole — which is what makes a
|
|
52
|
+
generated create/update call look exactly like its REST equivalent."""
|
|
53
|
+
point = ctx.point
|
|
54
|
+
gql = vs.getprop(point, "graphql")
|
|
55
|
+
|
|
56
|
+
if not isinstance(gql, dict):
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
# reqmatch/reqdata hold the caller's arguments for THIS call; data/match
|
|
60
|
+
# hold the entity's current state. Which pair depends on whether the op
|
|
61
|
+
# takes match or data input. A named variable falls back to the current
|
|
62
|
+
# state, so updating a loaded entity with just {title} still binds the
|
|
63
|
+
# stored id the mutation requires.
|
|
64
|
+
reqsrc, datasrc = ctx.reqmatch, ctx.match
|
|
65
|
+
if ctx.op is not None and getattr(ctx.op, "input", "match") == "data":
|
|
66
|
+
reqsrc, datasrc = ctx.reqdata, ctx.data
|
|
67
|
+
if not isinstance(reqsrc, dict):
|
|
68
|
+
reqsrc = {}
|
|
69
|
+
if not isinstance(datasrc, dict):
|
|
70
|
+
datasrc = {}
|
|
71
|
+
|
|
72
|
+
variables = {}
|
|
73
|
+
|
|
74
|
+
varlist = vs.getprop(gql, "vars")
|
|
75
|
+
if not isinstance(varlist, list):
|
|
76
|
+
varlist = []
|
|
77
|
+
|
|
78
|
+
for spec in varlist:
|
|
79
|
+
if not isinstance(spec, dict):
|
|
80
|
+
continue
|
|
81
|
+
|
|
82
|
+
name = vs.getprop(spec, "name")
|
|
83
|
+
frm = vs.getprop(spec, "from")
|
|
84
|
+
|
|
85
|
+
if frm is None or frm == "":
|
|
86
|
+
# The input object IS the request body. Strip the action
|
|
87
|
+
# selector, which is an SDK-side point discriminator, not an
|
|
88
|
+
# API field.
|
|
89
|
+
variables[name] = {
|
|
90
|
+
k: v for k, v in reqsrc.items() if k != "$action"
|
|
91
|
+
}
|
|
92
|
+
continue
|
|
93
|
+
|
|
94
|
+
# Only send variables the caller actually supplied: sending an
|
|
95
|
+
# explicit null would clear a field on many APIs.
|
|
96
|
+
val = vs.getprop(reqsrc, frm)
|
|
97
|
+
if val is None:
|
|
98
|
+
val = vs.getprop(datasrc, frm)
|
|
99
|
+
if val is not None:
|
|
100
|
+
variables[name] = val
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
"query": vs.getprop(gql, "doc"),
|
|
104
|
+
"variables": variables,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def graphql_errors_util(ctx):
|
|
109
|
+
"""Inspect a decoded GraphQL response body and record a failure when
|
|
110
|
+
the server reported one. Returns True when an error was recorded.
|
|
111
|
+
|
|
112
|
+
Partial data (`data` alongside `errors`) is treated as failure: the
|
|
113
|
+
REST surface has no partial-success concept, and silently returning
|
|
114
|
+
half an object would be worse than failing. The raw envelope stays
|
|
115
|
+
available on the result for callers that need it."""
|
|
116
|
+
result = ctx.result
|
|
117
|
+
point = ctx.point
|
|
118
|
+
|
|
119
|
+
if result is None or point is None:
|
|
120
|
+
return False
|
|
121
|
+
|
|
122
|
+
if vs.getprop(point, "kind") != "graphql":
|
|
123
|
+
return False
|
|
124
|
+
|
|
125
|
+
errors = vs.getprop(result.body, "errors")
|
|
126
|
+
if not isinstance(errors, list) or 0 == len(errors):
|
|
127
|
+
return False
|
|
128
|
+
|
|
129
|
+
first = errors[0]
|
|
130
|
+
msg = vs.getprop(first, "message") or "graphql error"
|
|
131
|
+
if 1 < len(errors):
|
|
132
|
+
msg = msg + " (+" + str(len(errors) - 1) + " more)"
|
|
133
|
+
|
|
134
|
+
err = ctx.make_error(graphql_error_code(first), "graphql: " + msg)
|
|
135
|
+
|
|
136
|
+
# Keep the full error list reachable for diagnostics.
|
|
137
|
+
try:
|
|
138
|
+
err.graphql = errors
|
|
139
|
+
except Exception:
|
|
140
|
+
pass
|
|
141
|
+
|
|
142
|
+
result.err = err
|
|
143
|
+
result.ok = False
|
|
144
|
+
|
|
145
|
+
return True
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# ProjectName SDK utility: make_error
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from core.operation import ProjectNameOperation
|
|
5
|
-
from core.result import ProjectNameResult
|
|
6
|
-
from core.control import ProjectNameControl
|
|
7
|
-
from core.error import ProjectNameError
|
|
4
|
+
from projectname_sdk.core.operation import ProjectNameOperation
|
|
5
|
+
from projectname_sdk.core.result import ProjectNameResult
|
|
6
|
+
from projectname_sdk.core.control import ProjectNameControl
|
|
7
|
+
from projectname_sdk.core.error import ProjectNameError
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def make_error_util(ctx, err):
|
|
11
11
|
if ctx is None:
|
|
12
|
-
from core.context import ProjectNameContext
|
|
12
|
+
from projectname_sdk.core.context import ProjectNameContext
|
|
13
13
|
ctx = ProjectNameContext({}, None)
|
|
14
14
|
|
|
15
15
|
op = ctx.op
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# ProjectName SDK utility: make_fetch_def
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from utility.voxgig_struct import voxgig_struct as vs
|
|
4
|
+
from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def make_fetch_def_util(ctx):
|
|
@@ -10,7 +10,7 @@ def make_fetch_def_util(ctx):
|
|
|
10
10
|
return None, ctx.make_error("fetchdef_no_spec",
|
|
11
11
|
"Expected context spec property to be defined.")
|
|
12
12
|
|
|
13
|
-
from core.result import ProjectNameResult
|
|
13
|
+
from projectname_sdk.core.result import ProjectNameResult
|
|
14
14
|
if ctx.result is None:
|
|
15
15
|
ctx.result = ProjectNameResult({})
|
|
16
16
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# ProjectName SDK utility: make_options
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from utility.voxgig_struct import voxgig_struct as vs
|
|
4
|
+
from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def make_options_util(ctx):
|
|
@@ -58,7 +58,7 @@ def make_options_util(ctx):
|
|
|
58
58
|
},
|
|
59
59
|
"allow": {
|
|
60
60
|
"method": "GET,PUT,POST,PATCH,DELETE,OPTIONS",
|
|
61
|
-
"op": "create,update,load,list,remove,command,direct",
|
|
61
|
+
"op": "create,update,load,list,remove,command,direct,graphql",
|
|
62
62
|
},
|
|
63
63
|
"entity": {
|
|
64
64
|
"`$CHILD`": {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# ProjectName SDK utility: make_point
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from utility.voxgig_struct import voxgig_struct as vs
|
|
5
|
-
from core.helpers import to_map
|
|
4
|
+
from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
|
|
5
|
+
from projectname_sdk.core.helpers import to_map
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def make_point_util(ctx):
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# ProjectName SDK utility: make_request
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from core.response import ProjectNameResponse
|
|
5
|
-
from core.result import ProjectNameResult
|
|
4
|
+
from projectname_sdk.core.response import ProjectNameResponse
|
|
5
|
+
from projectname_sdk.core.result import ProjectNameResult
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def make_request_util(ctx):
|
|
@@ -29,6 +29,12 @@ def make_response_util(ctx):
|
|
|
29
29
|
utility.result_basic(ctx)
|
|
30
30
|
utility.result_headers(ctx)
|
|
31
31
|
utility.result_body(ctx)
|
|
32
|
+
|
|
33
|
+
# GraphQL reports failures as a top-level `errors` array under HTTP
|
|
34
|
+
# 200, so result_basic's status check never sees them. Lift them here,
|
|
35
|
+
# before the response transform tries to unwrap data that is not there.
|
|
36
|
+
utility.graphql_errors(ctx)
|
|
37
|
+
|
|
32
38
|
utility.transform_response(ctx)
|
|
33
39
|
|
|
34
40
|
if result.err is None:
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# ProjectName SDK utility: make_spec
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from utility.voxgig_struct import voxgig_struct as vs
|
|
5
|
-
from core.spec import ProjectNameSpec
|
|
4
|
+
from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
|
|
5
|
+
from projectname_sdk.core.spec import ProjectNameSpec
|
|
6
|
+
from projectname_sdk.utility.graphql import GRAPHQL_CONTENT_TYPE
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
def make_spec_util(ctx):
|
|
@@ -58,8 +59,22 @@ def make_spec_util(ctx):
|
|
|
58
59
|
ctx.spec.params = utility.prepare_params(ctx)
|
|
59
60
|
ctx.spec.query = utility.prepare_query(ctx)
|
|
60
61
|
ctx.spec.headers = utility.prepare_headers(ctx)
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
|
|
63
|
+
if "graphql" == vs.getprop(point, "kind"):
|
|
64
|
+
# GraphQL addresses one endpoint: no path parts, no query string,
|
|
65
|
+
# and the body carries the operation. prepare_body is skipped
|
|
66
|
+
# deliberately — it only emits a body for data-input ops, whereas
|
|
67
|
+
# every GraphQL op posts one, including load/list/remove.
|
|
68
|
+
ctx.spec.body = utility.graphql_body(ctx)
|
|
69
|
+
ctx.spec.path = ""
|
|
70
|
+
# prepare_query already copied the op's match arguments into the
|
|
71
|
+
# query string. Those same values are bound as operation
|
|
72
|
+
# variables, so leaving them would send /graphql?id=i1.
|
|
73
|
+
ctx.spec.query = {}
|
|
74
|
+
ctx.spec.headers["content-type"] = GRAPHQL_CONTENT_TYPE
|
|
75
|
+
else:
|
|
76
|
+
ctx.spec.body = utility.prepare_body(ctx)
|
|
77
|
+
ctx.spec.path = utility.prepare_path(ctx)
|
|
63
78
|
|
|
64
79
|
if ctx.ctrl.explain is not None:
|
|
65
80
|
ctx.ctrl.explain["spec"] = ctx.spec
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# ProjectName SDK utility: param
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from utility.voxgig_struct import voxgig_struct as vs
|
|
5
|
-
from core.helpers import to_map
|
|
4
|
+
from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
|
|
5
|
+
from projectname_sdk.core.helpers import to_map
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def param_util(ctx, paramdef):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# ProjectName SDK utility: prepare_auth
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from utility.voxgig_struct import voxgig_struct as vs
|
|
4
|
+
from projectname_sdk.utility.voxgig_struct import voxgig_struct as vs
|
|
5
5
|
|
|
6
6
|
HEADER_AUTH = "authorization"
|
|
7
7
|
OPTION_APIKEY = "apikey"
|