stellate 2.5.4 → 2.7.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.
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var w=(e,r)=>{for(var t in r)f(e,t,{get:r[t],enumerable:!0})},P=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of k(r))!N.call(e,s)&&s!==t&&f(e,s,{get:()=>r[s],enumerable:!(n=v(r,s))||n.enumerable});return e};var H=e=>P(f({},"__esModule",{value:!0}),e);var L={};w(L,{createBlake3Hash:()=>p,createStellateLoggerPlugin:()=>A});module.exports=H(L);function p(e){let r=0,t=e.length;if(t===0)return r;for(let n=0;n<t;++n){let s=e.charCodeAt(n);r=(r<<5)-r+s,r&=r}return r>>>0}function h({headers:e,operation:r,method:t,start:n,operationName:s,errors:g,response:o,variables:i,sendVariablesAsHash:a,hasSetCookie:l}){let c=e.get("x-forwarded-for"),d=c?c.split(","):[];return{operation:r,operationName:s,variables:a?void 0:i,variableHash:a?p(JSON.stringify(i||{})):void 0,method:t,elapsed:Date.now()-n,ip:d[0]||e.get("true-client-ip")||e.get("x-real-ip")||void 0,hasSetCookie:l,referer:e.get("referer")||void 0,userAgent:e.get("user-agent")||void 0,statusCode:200,errors:g,responseSize:JSON.stringify(o).length,responseHash:p(JSON.stringify(o))}}function y(e){if(typeof e!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}}var x=process.env.STELLATE_ENDPOINT==="local"||process.env.STELLATE_ENDPOINT==="staging"?"stellate.dev":"stellate.sh";async function m({fetch:e,payload:r,token:t,serviceName:n}){return e(`https://${n}.${x}/log`,{method:"POST",body:JSON.stringify(r),headers:{"Content-Type":"application/json","Stellate-Logging-Token":t}})}var A=e=>{let r=e.sendVariablesAsHash!=null?e.sendVariablesAsHash:!1;return{async requestDidStart(t){let n=Date.now(),{request:s}=t,{operationName:g,query:o,variables:i,http:a}=s;if(!a||!o)return;let{headers:l,method:c}=a;if(!l.has("gcdn-request-id"))return{async willSendResponse(d){let{response:u}=d;if(u.body.kind!=="single"){console.warn("Stellate does not currently support logging incremental results.");return}let b=u.body.singleResult,S=h({headers:l,operation:o,method:c,sendVariablesAsHash:r,start:n,operationName:g,errors:d.errors,response:b,variables:i,hasSetCookie:u.http.headers.has("set-cookie")});y(e.fetch),await m({fetch:e.fetch,payload:S,token:e.token,serviceName:e.serviceName})}}}}};0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
1
+ "use strict";var f=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var P=(e,r)=>{for(var t in r)f(e,t,{get:r[t],enumerable:!0})},x=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of N(r))!w.call(e,o)&&o!==t&&f(e,o,{get:()=>r[o],enumerable:!(n=k(r,o))||n.enumerable});return e};var H=e=>x(f({},"__esModule",{value:!0}),e);var O={};P(O,{createBlake3Hash:()=>p,createStellateLoggerPlugin:()=>L});module.exports=H(O);function p(e){let r=0,t=e.length;if(t===0)return r;for(let n=0;n<t;++n){let o=e.charCodeAt(n);r=(r<<5)-r+o,r&=r}return r>>>0}function y({headers:e,operation:r,method:t,start:n,operationName:o,errors:d,response:i,variables:s,sendVariablesAsHash:l,hasSetCookie:c}){let a=e.get("x-forwarded-for"),g=a?a.split(","):[];return{operation:r,operationName:o,variables:l?void 0:s,variableHash:l?p(JSON.stringify(s||{})):void 0,method:t,elapsed:Date.now()-n,ip:g[0]||e.get("true-client-ip")||e.get("x-real-ip")||void 0,hasSetCookie:c,referer:e.get("referer")||void 0,userAgent:e.get("user-agent")||void 0,statusCode:200,errors:d,responseSize:JSON.stringify(i).length,responseHash:p(JSON.stringify(i))}}function m(e){if(typeof e!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}}var A=process.env.STELLATE_ENDPOINT==="local"||process.env.STELLATE_ENDPOINT==="staging"?"stellate.dev":"stellate.sh";async function b({fetch:e,payload:r,token:t,serviceName:n}){return e(`https://${n}.${A}/log`,{method:"POST",body:JSON.stringify(r),headers:{"Content-Type":"application/json","Stellate-Logging-Token":t}})}var L=e=>{var t;let r=(t=e.sendVariablesAsHash)!=null?t:!0;return{async requestDidStart(n){let o=Date.now(),{request:d}=n,{operationName:i,query:s,variables:l,http:c}=d;if(!c||!s)return;let{headers:a,method:g}=c;if(!a.has("gcdn-request-id"))return{async willSendResponse(h){let{response:u}=h;if(u.body.kind!=="single"){console.warn("Stellate does not currently support logging incremental results.");return}let S=u.body.singleResult,v=y({headers:a,operation:s,method:g,sendVariablesAsHash:r,start:o,operationName:i,errors:h.errors,response:S,variables:l,hasSetCookie:u.http.headers.has("set-cookie")});m(e.fetch),await b({fetch:e.fetch,payload:v,token:e.token,serviceName:e.serviceName})}}}}};0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
@@ -73,7 +73,8 @@ async function logRequest({
73
73
 
74
74
  // src/apollo-server.ts
75
75
  var createStellateLoggerPlugin = (options) => {
76
- const sendVariablesAsHash = options.sendVariablesAsHash != null ? options.sendVariablesAsHash : false;
76
+ var _a;
77
+ const sendVariablesAsHash = (_a = options.sendVariablesAsHash) != null ? _a : true;
77
78
  return {
78
79
  async requestDidStart(requestCtx) {
79
80
  const start = Date.now();