@zuplo/runtime 6.70.70 → 6.71.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.
@@ -22,5 +22,5 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{b as l}from"../chunk-GEVKFSKR.js";import{a as o,da as n}from"../chunk-ZIKV2LUM.js";function g(u={request:new Request("https://api.example.com")}){let e=[];function t(i){e.push(Promise.resolve(i))}return o(t,"waitUntil"),{context:new s({event:{waitUntil:t},route:u.route}),invokeResponse:o(async()=>{await Promise.all(e)},"invokeResponse")}}o(g,"createMockContext");var p={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:o(()=>({}),"raw")},s=class extends EventTarget{static{o(this,"MockZuploContext")}#e;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:t=p,parentContext:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:n.console.info,log:n.console.log,debug:n.console.debug,warn:n.console.warn,error:n.console.error,setLogProperties:o(()=>{},"setLogProperties")},this.custom={},this.route=t,this.incomingRequestProperties={asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0,clientCertFingerprintSha256:void 0,clientCertNotBefore:void 0,clientCertNotAfter:void 0,clientCertIssuerDn:void 0,clientCertSubjectDn:void 0},this.parentContext=r,this.#e=e,this.analyticsContext=new l(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,t){throw new Error("Not implemented")}invokeOutboundPolicy(e,t,r){throw new Error("Not implemented")}invokeRoute(e,t){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addEventListener(e,t,r){let d=o(i=>{try{typeof t=="function"?t(i):t.handleEvent(i)}catch(a){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),a}},"wrapped");super.addEventListener(e,d,r)}};export{s as MockZuploContext,g as createMockContext};
25
+ import{b as l}from"../chunk-AZIRK6TC.js";import{a as o,da as n}from"../chunk-ZIKV2LUM.js";function g(u={request:new Request("https://api.example.com")}){let e=[];function t(i){e.push(Promise.resolve(i))}return o(t,"waitUntil"),{context:new s({event:{waitUntil:t},route:u.route}),invokeResponse:o(async()=>{await Promise.all(e)},"invokeResponse")}}o(g,"createMockContext");var p={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:o(()=>({}),"raw")},s=class extends EventTarget{static{o(this,"MockZuploContext")}#e;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:t=p,parentContext:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:n.console.info,log:n.console.log,debug:n.console.debug,warn:n.console.warn,error:n.console.error,setLogProperties:o(()=>{},"setLogProperties")},this.custom={},this.route=t,this.incomingRequestProperties={asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0,clientCertFingerprintSha256:void 0,clientCertNotBefore:void 0,clientCertNotAfter:void 0,clientCertIssuerDn:void 0,clientCertSubjectDn:void 0},this.parentContext=r,this.#e=e,this.analyticsContext=new l(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,t){throw new Error("Not implemented")}invokeOutboundPolicy(e,t,r){throw new Error("Not implemented")}invokeRoute(e,t){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addEventListener(e,t,r){let d=o(i=>{try{typeof t=="function"?t(i):t.handleEvent(i)}catch(a){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),a}},"wrapped");super.addEventListener(e,d,r)}};export{s as MockZuploContext,g as createMockContext};
26
26
  //# sourceMappingURL=index.js.map
@@ -3582,6 +3582,67 @@ export declare class GoogleCloudLoggingPlugin extends LogPlugin {
3582
3582
  /* Excluded from this release type: getTransport */
3583
3583
  }
3584
3584
 
3585
+ /**
3586
+ * Reports GraphQL errors returned in response bodies to Zuplo's GraphQL
3587
+ * analytics. GraphQL servers following the standard Apollo / graphql-yoga
3588
+ * pattern return `200 OK` with an `errors[]` array in the body when an
3589
+ * operation fails, which HTTP-level analytics alone report as a success —
3590
+ * add this policy to a GraphQL route and failed operations show up as
3591
+ * failures on the GraphQL dashboard, classified by error type.
3592
+ *
3593
+ * Each error in `errors[]` is classified from its `extensions.code`
3594
+ * following the Apollo Server conventions (`GRAPHQL_PARSE_FAILED` →
3595
+ * `syntax`, `GRAPHQL_VALIDATION_FAILED` → `validation`, `UNAUTHENTICATED` /
3596
+ * `FORBIDDEN` → `auth`, timeout codes → `timeout`); custom codes can be
3597
+ * mapped with `errorCodeClassification`, and anything unrecognized falls
3598
+ * 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.
3601
+ *
3602
+ * The response always passes through unchanged — the body is read from a
3603
+ * clone, and any internal failure is swallowed so reporting can never
3604
+ * break the request. The route must be marked `x-graphql: true` in
3605
+ * `routes.oas.json` (which enables GraphQL analytics for the route);
3606
+ * without the marker the policy logs a warning and does nothing.
3607
+ *
3608
+ * @title GraphQL Analytics
3609
+ * @product api-gateway
3610
+ * @beta
3611
+ * @public
3612
+ * @param response - The outgoing Response from the handler
3613
+ * @param request - The original incoming Request
3614
+ * @param context - The current context of the Request
3615
+ * @param options - The configuration options for the policy
3616
+ * @param policyName - The name of the policy as set in policies.json
3617
+ * @returns A Response
3618
+ */
3619
+ export declare const GraphqlAnalyticsOutboundPolicy: OutboundPolicyHandler<GraphqlAnalyticsOutboundPolicyOptions>;
3620
+
3621
+ /**
3622
+ * The options for the GraphQL Analytics outbound policy. Reads GraphQL `errors[]` from the response body and reports them to Zuplo's GraphQL analytics.
3623
+ * @public
3624
+ */
3625
+ export declare interface GraphqlAnalyticsOutboundPolicyOptions {
3626
+ /**
3627
+ * Additional `extensions.code` → error-class mappings for codes your GraphQL server emits. Entries are merged over (and win against) the built-in Apollo-convention map (`GRAPHQL_PARSE_FAILED` → `syntax`, `GRAPHQL_VALIDATION_FAILED` / `BAD_USER_INPUT` → `validation`, `UNAUTHENTICATED` / `FORBIDDEN` → `auth`, timeout codes → `timeout`, `INTERNAL_SERVER_ERROR` → `resolver`). Keys are matched case-sensitively; built-in codes are matched case-insensitively.
3628
+ */
3629
+ errorCodeClassification?: {
3630
+ [k: string]: "syntax" | "validation" | "auth" | "timeout" | "resolver";
3631
+ };
3632
+ /**
3633
+ * The error class reported for a GraphQL error whose `extensions.code` is missing or not in the classification map.
3634
+ */
3635
+ defaultErrorClass?: "syntax" | "validation" | "auth" | "timeout" | "resolver";
3636
+ /**
3637
+ * When `true`, also write a structured warning to the request log (message, `extensions.code`, and path of each error — capped at the first 10) whenever a response contains GraphQL errors.
3638
+ */
3639
+ logErrors?: boolean;
3640
+ /**
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.
3642
+ */
3643
+ maxResponseBytes?: number;
3644
+ }
3645
+
3585
3646
  /**
3586
3647
  * The main request handler for the Zuplo runtime. This class initializes the gateway
3587
3648
  * and handles all incoming HTTP requests through the configured pipeline.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.70.70",
4
+ "version": "6.71.0",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {