stellate 2.0.0 → 2.1.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.
@@ -6,6 +6,7 @@ interface Options {
6
6
  fetch: typeof fetch;
7
7
  }
8
8
 
9
+ declare function createBlake3Hash(str: string): number;
9
10
  declare const createStellateLoggerPlugin: (options: Options) => ApolloServerPlugin;
10
11
 
11
- export { createStellateLoggerPlugin };
12
+ export { createBlake3Hash, createStellateLoggerPlugin };
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var r in e)l(t,r,{get:e[r],enumerable:!0})},P=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!v.call(t,o)&&o!==r&&l(t,o,{get:()=>e[o],enumerable:!(n=S(e,o))||n.enumerable});return t};var b=t=>P(l({},"__esModule",{value:!0}),t);var O={};w(O,{createStellateLoggerPlugin:()=>A});module.exports=b(O);function k(t){let e=0,r=t.length;if(r===0)return e;for(let n=0;n<r;++n){let o=t.charCodeAt(n);e=(e<<5)-e+o,e&=e}return e>>>0}var A=t=>({async requestDidStart(e){let r=Date.now(),{request:n}=e,{operationName:o,query:i,variables:u,http:p}=n;if(!p||!i)return;let{headers:s,method:f}=p;if(!s.has("gcdn-request-id"))return{async willSendResponse(c){let{response:a}=c;if(a.body.kind!=="single"){console.warn("Stellate does not currently support logging incremental results.");return}let d=a.body.singleResult,g=s.get("x-forwarded-for"),h=g?g.split(","):[],y={operation:i,operationName:o,variables:u,hasSetCookie:a.http.headers.has("set-cookie"),method:f,elapsed:Date.now()-r,ip:h[0]||s.get("true-client-ip")||s.get("x-real-ip"),referer:s.get("referer"),userAgent:s.get("user-agent"),statusCode:a.http.status||200,errors:c.errors,responseSize:JSON.stringify(d).length,responseHash:k(JSON.stringify(d))};if(typeof t.fetch!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}await t.fetch(`https://${t.serviceName}.stellate.sh/log`,{method:"POST",body:JSON.stringify(y),headers:{"Content-Type":"application/json","Stellate-Logging-Token":t.token}})}}}});0&&(module.exports={createStellateLoggerPlugin});
1
+ "use strict";var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var r in e)l(t,r,{get:e[r],enumerable:!0})},P=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of v(e))!b.call(t,o)&&o!==r&&l(t,o,{get:()=>e[o],enumerable:!(n=m(e,o))||n.enumerable});return t};var k=t=>P(l({},"__esModule",{value:!0}),t);var O={};w(O,{createBlake3Hash:()=>u,createStellateLoggerPlugin:()=>A});module.exports=k(O);function u(t){let e=0,r=t.length;if(r===0)return e;for(let n=0;n<r;++n){let o=t.charCodeAt(n);e=(e<<5)-e+o,e&=e}return e>>>0}var A=t=>({async requestDidStart(e){let r=Date.now(),{request:n}=e,{operationName:o,query:i,variables:f,http:p}=n;if(!p||!i)return;let{headers:s,method:h}=p;if(!s.has("gcdn-request-id"))return{async willSendResponse(c){let{response:a}=c;if(a.body.kind!=="single"){console.warn("Stellate does not currently support logging incremental results.");return}let d=a.body.singleResult,g=s.get("x-forwarded-for"),y=g?g.split(","):[],S={operation:i,operationName:o,variables:f,hasSetCookie:a.http.headers.has("set-cookie"),method:h,elapsed:Date.now()-r,ip:y[0]||s.get("true-client-ip")||s.get("x-real-ip"),referer:s.get("referer"),userAgent:s.get("user-agent"),statusCode:a.http.status||200,errors:c.errors,responseSize:JSON.stringify(d).length,responseHash:u(JSON.stringify(d))};if(typeof t.fetch!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}await t.fetch(`https://${t.serviceName}.stellate.sh/log`,{method:"POST",body:JSON.stringify(S),headers:{"Content-Type":"application/json","Stellate-Logging-Token":t.token}})}}}});0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
@@ -76,5 +76,6 @@ var createStellateLoggerPlugin = (options) => {
76
76
  };
77
77
  };
78
78
  export {
79
+ createBlake3Hash,
79
80
  createStellateLoggerPlugin
80
81
  };