@zuplo/runtime 6.71.19 → 6.71.21

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.
@@ -3357,6 +3357,19 @@ declare const EventType: {
3357
3357
 
3358
3358
  declare type EventType = (typeof EventType)[keyof typeof EventType];
3359
3359
 
3360
+ /**
3361
+ * Parse a response body and extract its GraphQL `errors[]`, including
3362
+ * across an Apollo-style batched (array) response.
3363
+ *
3364
+ * Returns `null` when the body isn't a GraphQL response shape at all
3365
+ * (unparseable JSON, or a JSON scalar), and `[]` for a well-formed
3366
+ * response with no errors — callers treat both as "nothing to report"
3367
+ * but the distinction keeps the function testable.
3368
+ */
3369
+ export declare function extractGraphqlErrors(
3370
+ bodyText: string
3371
+ ): GraphqlResponseError[] | null;
3372
+
3360
3373
  declare interface FetchOptions<T> {
3361
3374
  method?: HttpMethod_2;
3362
3375
  data?: T;
@@ -3596,8 +3609,11 @@ export declare class GoogleCloudLoggingPlugin extends LogPlugin {
3596
3609
  * `FORBIDDEN` → `auth`, timeout codes → `timeout`); custom codes can be
3597
3610
  * mapped with `errorCodeClassification`, and anything unrecognized falls
3598
3611
  * back to `defaultErrorClass` (`resolver`). Optionally set `logErrors` to
3599
- * also write a structured warning per errored response. Bodies larger
3600
- * than `maxResponseBytes` (default 5 MiB) are not inspected.
3612
+ * also write a structured warning per errored response. The policy reads
3613
+ * up to `maxScanBytes` of the body (128 KiB by default, 5 MiB maximum),
3614
+ * scanning it for the `errors` token; a response larger than that is
3615
+ * treated as error-free. When the token is found and the body fits, it is
3616
+ * parsed and its errors reported.
3601
3617
  *
3602
3618
  * The response always passes through unchanged — the body is read from a
3603
3619
  * clone, and any internal failure is swallowed so reporting can never
@@ -3638,9 +3654,23 @@ export declare interface GraphqlAnalyticsOutboundPolicyOptions {
3638
3654
  */
3639
3655
  logErrors?: boolean;
3640
3656
  /**
3641
- * Maximum response body size in bytes the policy will inspect. Larger bodies — by `Content-Length`, or measured while reading when the header is absent — pass through without being scanned, so their GraphQL errors (if any) go unreported. The default is 5 MiB.
3657
+ * How many bytes of the response body the policy reads to look for GraphQL errors. The body is read and scanned for the `errors` token up to this limit; a body larger than the limit — by `Content-Length`, or measured while reading when the header is absent — is treated as error-free, so any errors it carries go unreported. The default of 128 KiB suits the common case, where servers emit `errors` near the front of the body. Raise it (up to the 5 MiB maximum) to detect errors in larger responses, at the cost of reading more of every response. When the token is found and the body fits within the limit, the body is parsed and its errors are reported.
3642
3658
  */
3643
- maxResponseBytes?: number;
3659
+ maxScanBytes?: number;
3660
+ }
3661
+
3662
+ /**
3663
+ * One GraphQL error extracted from a response body, reduced to the
3664
+ * fields the GraphQL Analytics outbound policy consumes for
3665
+ * classification and (opt-in) logging.
3666
+ */
3667
+ export declare interface GraphqlResponseError {
3668
+ /** The error's `message`, or `""` when missing/non-string. */
3669
+ message: string;
3670
+ /** The error's `extensions.code`, or `null` when absent. */
3671
+ code: string | null;
3672
+ /** The error's `path` joined with `.` (e.g. `user.posts.0.title`), or `null`. */
3673
+ path: string | null;
3644
3674
  }
3645
3675
 
3646
3676
  /**
@@ -10126,6 +10156,37 @@ declare type ResolveRequestQuery<
10126
10156
  declare type ResolveUserData<TUserData extends UserDataDefault | undefined> =
10127
10157
  TUserData extends UserDataDefault ? TUserData : UserDataDefault;
10128
10158
 
10159
+ /**
10160
+ * Reports whether a `Response` carries GraphQL errors — a `200 OK` with a
10161
+ * top-level `errors[]` array, as Apollo / graphql-yoga servers return on a
10162
+ * failed operation. Reads the body from a clone, so the original response
10163
+ * stream still flows to the client untouched.
10164
+ *
10165
+ * The result is cached against the `response` object: the body is read,
10166
+ * scanned, and parsed at most once per response, and every later call
10167
+ * (including concurrent ones) resolves to the same cached boolean without
10168
+ * touching the stream again.
10169
+ *
10170
+ * Detection reads at most `maxScanBytes` of the body, scanning it for the
10171
+ * `errors` token; a response larger than that — whether by declared
10172
+ * `Content-Length` or as measured while reading — is treated as error-free
10173
+ * and resolves to `false`. Non-JSON responses also resolve to `false`
10174
+ * without reading. Any internal failure is swallowed and reported as
10175
+ * `false` — detection is best-effort and never throws.
10176
+ *
10177
+ * @param response - The response to inspect; left unconsumed.
10178
+ * @param maxScanBytes - How many bytes of the body to read and scan.
10179
+ * Defaults to {@link DEFAULT_GRAPHQL_SCAN_BYTES} (128 KiB); a body larger
10180
+ * than this goes unreported. Only the first call for a given `response`
10181
+ * observes this value; later calls return the cached result.
10182
+ * @returns `true` when the body contains a top-level `errors[]` with at
10183
+ * least one entry, otherwise `false`.
10184
+ */
10185
+ export declare function responseHasGraphqlErrors(
10186
+ response: Response,
10187
+ maxScanBytes?: number
10188
+ ): Promise<boolean>;
10189
+
10129
10190
  /**
10130
10191
  * Definition of responses for a route
10131
10192
  * @public
@@ -10989,6 +11050,52 @@ export declare abstract class TelemetryPlugin extends RuntimePlugin {
10989
11050
 
10990
11051
  /* Excluded from this release type: trackFeature */
10991
11052
 
11053
+ /**
11054
+ * Splits traffic randomly across a set of weighted base paths. On each request
11055
+ * one base path is selected (weighted by `weight`) and written to the request
11056
+ * custom context at `customOutputProperty`. Reference it from a later URL
11057
+ * Rewrite `rewritePattern` or URL Forward `baseUrl`, e.g.
11058
+ * `${context.custom.trafficSplitting.basePath}`.
11059
+ *
11060
+ * @title Traffic Splitting
11061
+ * @product api-gateway
11062
+ * @public
11063
+ * @param request - The ZuploRequest
11064
+ * @param context - The ZuploContext
11065
+ * @param options - The policy options set in policies.json
11066
+ * @param policyName - The name of the policy as set in policies.json
11067
+ * @returns A Request or a Response
11068
+ */
11069
+ export declare const TrafficSplittingInboundPolicy: InboundPolicyHandler<TrafficSplittingInboundPolicyOptions>;
11070
+
11071
+ /**
11072
+ * The options for this policy.
11073
+ * @public
11074
+ */
11075
+ export declare interface TrafficSplittingInboundPolicyOptions {
11076
+ /**
11077
+ * The set of base paths (URLs) to split traffic across. One entry is selected at random per request, weighted by its `weight`.
11078
+ */
11079
+ basePaths: {
11080
+ /**
11081
+ * The base path (URL) to route to when this entry is selected. Supports environment variables, e.g. `$env(BASE_URL)/v2`.
11082
+ */
11083
+ url: string;
11084
+ /**
11085
+ * The relative weight for this base path. Higher weights receive proportionally more traffic. Weights are relative and do not need to add up to 100.
11086
+ */
11087
+ weight: number;
11088
+ }[];
11089
+ /**
11090
+ * A simple dotted property path under the request custom context where the selected URL is written (e.g. `trafficSplitting.basePath`). Reference it later in a URL Rewrite `rewritePattern` or URL Forward `baseUrl` as `${context.custom.trafficSplitting.basePath}`. Only one value is in effect; if multiple Traffic Splitting policies write the same property, the last one to run wins. Array indexes and brackets are not allowed.
11091
+ */
11092
+ customOutputProperty: string;
11093
+ /**
11094
+ * When `true`, logs which base path was selected for each request. Defaults to `false`.
11095
+ */
11096
+ logSelection?: boolean;
11097
+ }
11098
+
10992
11099
  /**
10993
11100
  *
10994
11101
  * @export
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.71.19",
4
+ "version": "6.71.21",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {