stellate 2.8.2 → 2.9.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.
package/dist/envelop.js CHANGED
@@ -1 +1,2 @@
1
- "use strict";var g=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var r in e)g(t,r,{get:e[r],enumerable:!0})},v=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of N(e))!S.call(t,s)&&s!==r&&g(t,s,{get:()=>e[s],enumerable:!(n=k(e,s))||n.enumerable});return t};var L=t=>v(g({},"__esModule",{value:!0}),t);var O={};x(O,{createBlake3Hash:()=>c,createStellateLoggerPlugin:()=>H});module.exports=L(O);var y=require("graphql"),b=require("@envelop/core");function c(t){let e=0,r=t.length;if(r===0)return e;for(let n=0;n<r;++n){let s=t.charCodeAt(n);e=(e<<5)-e+s,e&=e}return e>>>0}function f({headers:t,operation:e,method:r,start:n,operationName:s,errors:a,response:o,variables:i,sendVariablesAsHash:l,hasSetCookie:d}){let p=t.get("x-forwarded-for"),w=p?p.split(","):[];return{operation:e,operationName:s,variables:l?void 0:i,variableHash:l?c(JSON.stringify(i||{})):void 0,method:r,elapsed:Date.now()-n,ip:w[0]||t.get("true-client-ip")||t.get("x-real-ip")||void 0,hasSetCookie:d,referer:t.get("referer")||void 0,userAgent:t.get("user-agent")||void 0,statusCode:200,errors:a,responseSize:JSON.stringify(o).length,responseHash:c(JSON.stringify(o))}}function h(t){if(typeof t!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}}var P=process.env.STELLATE_ENDPOINT==="local"||process.env.STELLATE_ENDPOINT==="staging"?"stellate.dev":"stellate.sh";async function m({fetch:t,payload:e,token:r,serviceName:n}){return t(`https://${n}.${P}/log`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json","Stellate-Logging-Token":r}})}var u=class{constructor(e){this.headers=Object.keys(e).reduce((r,n)=>(r[n.trim().toLowerCase()]=e[n],r),{})}get(e){return this.headers[e.trim().toLowerCase()]}has(e){return!!this.headers[e.trim().toLowerCase()]}},H=t=>({onExecute(e){var s;let r=(s=t.sendVariablesAsHash)!=null?s:!0,n=Date.now();return{async onExecuteDone({result:a}){if((0,b.isAsyncIterable)(a)){console.warn("Stellate does not currently support logging incremental results.");return}let{headers:o}=e.args.contextValue.request,{method:i}=e.args.contextValue.request;if(typeof o.get!="function"&&(o=new u(o)),o.has("gcdn-request-id"))return;let l=f({headers:o,operation:(0,y.print)(e.args.document),method:i,sendVariablesAsHash:r,start:n,operationName:e.args.operationName,errors:a.errors,response:a});h(t.fetch);try{await m({fetch:t.fetch,payload:l,token:t.token,serviceName:t.serviceName})}catch{}}}}});0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
1
+ "use strict";var f=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var E=(t,e)=>{for(var r in e)f(t,r,{get:e[r],enumerable:!0})},q=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of N(e))!O.call(t,s)&&s!==r&&f(t,s,{get:()=>e[s],enumerable:!(n=P(e,s))||n.enumerable});return t};var A=t=>q(f({},"__esModule",{value:!0}),t);var R={};E(R,{createBlake3Hash:()=>l,createStellateLoggerPlugin:()=>T});module.exports=A(R);var k=require("graphql"),S=require("@envelop/core");function l(t){let e=0,r=t.length;if(r===0)return e;for(let n=0;n<r;++n){let s=t.charCodeAt(n);e=(e<<5)-e+s,e&=e}return e>>>0}function b({headers:t,operation:e,method:r,start:n,operationName:s,errors:i,response:o,variables:c,responseHeaders:u,sendVariablesAsHash:g,hasSetCookie:H}){let h=t.get("x-forwarded-for"),x=h?h.split(","):[],d=u&&u.get("vary"),m;if(d&&d.length){let L=d.split(",").map(a=>a&&a.trim()).sort().map(a=>{let y=a&&t.get(a);return y?`${a}:${y}`:void 0}).filter(Boolean).join(`
2
+ `);m=l(L)}return{operation:e,operationName:s,variables:g?void 0:c,variableHash:g?l(JSON.stringify(c||{})):void 0,method:r,elapsed:Date.now()-n,ip:x[0]||t.get("true-client-ip")||t.get("x-real-ip")||void 0,hasSetCookie:H,referer:t.get("referer")||void 0,userAgent:t.get("user-agent")||void 0,statusCode:200,errors:i,responseSize:JSON.stringify(o).length,responseHash:l(JSON.stringify(o)),varyHash:m}}function v(t){if(typeof t!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}}var C=process.env.STELLATE_ENDPOINT==="local"||process.env.STELLATE_ENDPOINT==="staging"?"stellate.dev":"stellate.sh";async function w({fetch:t,payload:e,token:r,serviceName:n}){return t(`https://${n}.${C}/log`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json","Stellate-Logging-Token":r}})}var p=class{constructor(e){this.headers=Object.keys(e).reduce((r,n)=>(r[n.trim().toLowerCase()]=e[n],r),{})}get(e){return this.headers[e.trim().toLowerCase()]}has(e){return!!this.headers[e.trim().toLowerCase()]}},T=t=>({onExecute(e){var s;let r=(s=t.sendVariablesAsHash)!=null?s:!0,n=Date.now();return{async onExecuteDone({result:i}){if((0,S.isAsyncIterable)(i)){console.warn("Stellate does not currently support logging incremental results.");return}let{headers:o}=e.args.contextValue.request,{method:c}=e.args.contextValue.request;if(typeof o.get!="function"&&(o=new p(o)),o.has("gcdn-request-id"))return;let u=b({headers:o,operation:(0,k.print)(e.args.document),method:c,sendVariablesAsHash:r,start:n,operationName:e.args.operationName,errors:i.errors,response:i});v(t.fetch);try{await w({fetch:t.fetch,payload:u,token:t.token,serviceName:t.serviceName})}catch{}}}}});0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
package/dist/envelop.mjs CHANGED
@@ -25,11 +25,22 @@ function extractStellatePayload({
25
25
  errors,
26
26
  response,
27
27
  variables,
28
+ responseHeaders,
28
29
  sendVariablesAsHash,
29
30
  hasSetCookie
30
31
  }) {
31
32
  const forwardedFor = headers.get("x-forwarded-for");
32
33
  const ips = forwardedFor ? forwardedFor.split(",") : [];
34
+ const vary = responseHeaders && responseHeaders.get("vary");
35
+ let varyHash = void 0;
36
+ if (vary && vary.length) {
37
+ const varyHeaders = vary.split(",").map((headerName) => headerName && headerName.trim()).sort();
38
+ const variedValues = varyHeaders.map((headerName) => {
39
+ const headerValue = headerName && headers.get(headerName);
40
+ return headerValue ? `${headerName}:${headerValue}` : void 0;
41
+ }).filter(Boolean).join("\n");
42
+ varyHash = createBlake3Hash(variedValues);
43
+ }
33
44
  return {
34
45
  operation,
35
46
  operationName,
@@ -44,7 +55,8 @@ function extractStellatePayload({
44
55
  statusCode: 200,
45
56
  errors,
46
57
  responseSize: JSON.stringify(response).length,
47
- responseHash: createBlake3Hash(JSON.stringify(response))
58
+ responseHash: createBlake3Hash(JSON.stringify(response)),
59
+ varyHash
48
60
  };
49
61
  }
50
62
  function warnFetch(fetch) {
@@ -1 +1,2 @@
1
- "use strict";var g=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},k=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of S(t))!x.call(e,o)&&o!==r&&g(e,o,{get:()=>t[o],enumerable:!(n=N(t,o))||n.enumerable});return e};var P=e=>k(g({},"__esModule",{value:!0}),e);var E={};v(E,{createBlake3Hash:()=>c,createStellateLoggerPlugin:()=>H});module.exports=P(E);var m=require("graphql"),y=require("graphql-yoga");function c(e){let t=0,r=e.length;if(r===0)return t;for(let n=0;n<r;++n){let o=e.charCodeAt(n);t=(t<<5)-t+o,t&=t}return t>>>0}function d({headers:e,operation:t,method:r,start:n,operationName:o,errors:a,response:s,variables:i,sendVariablesAsHash:l,hasSetCookie:p}){let u=e.get("x-forwarded-for"),b=u?u.split(","):[];return{operation:t,operationName:o,variables:l?void 0:i,variableHash:l?c(JSON.stringify(i||{})):void 0,method:r,elapsed:Date.now()-n,ip:b[0]||e.get("true-client-ip")||e.get("x-real-ip")||void 0,hasSetCookie:p,referer:e.get("referer")||void 0,userAgent:e.get("user-agent")||void 0,statusCode:200,errors:a,responseSize:JSON.stringify(s).length,responseHash:c(JSON.stringify(s))}}function f(e){if(typeof e!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}}var w=process.env.STELLATE_ENDPOINT==="local"||process.env.STELLATE_ENDPOINT==="staging"?"stellate.dev":"stellate.sh";async function h({fetch:e,payload:t,token:r,serviceName:n}){return e(`https://${n}.${w}/log`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json","Stellate-Logging-Token":r}})}var H=e=>({onExecute(t){var o;let r=(o=e.sendVariablesAsHash)!=null?o:!0,n=Date.now();return{async onExecuteDone({result:a}){if((0,y.isAsyncIterable)(a)){console.warn("Stellate does not currently support logging incremental results.");return}let{headers:s,method:i}=t.args.contextValue.request;if(s.has("gcdn-request-id"))return;let l=d({headers:s,operation:(0,m.print)(t.args.document),method:i,sendVariablesAsHash:r,start:n,operationName:t.args.operationName,errors:a.errors,response:a});f(e.fetch);try{await h({fetch:e.fetch,payload:l,token:e.token,serviceName:e.serviceName})}catch{}}}}});0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
1
+ "use strict";var p=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var r in t)p(e,r,{get:t[r],enumerable:!0})},O=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of w(t))!L.call(e,o)&&o!==r&&p(e,o,{get:()=>t[o],enumerable:!(n=N(t,o))||n.enumerable});return e};var A=e=>O(p({},"__esModule",{value:!0}),e);var C={};E(C,{createBlake3Hash:()=>l,createStellateLoggerPlugin:()=>q});module.exports=A(C);var S=require("graphql"),H=require("graphql-yoga");function l(e){let t=0,r=e.length;if(r===0)return t;for(let n=0;n<r;++n){let o=e.charCodeAt(n);t=(t<<5)-t+o,t&=t}return t>>>0}function y({headers:e,operation:t,method:r,start:n,operationName:o,errors:s,response:i,variables:c,responseHeaders:g,sendVariablesAsHash:u,hasSetCookie:k}){let f=e.get("x-forwarded-for"),x=f?f.split(","):[],d=g&&g.get("vary"),h;if(d&&d.length){let P=d.split(",").map(a=>a&&a.trim()).sort().map(a=>{let m=a&&e.get(a);return m?`${a}:${m}`:void 0}).filter(Boolean).join(`
2
+ `);h=l(P)}return{operation:t,operationName:o,variables:u?void 0:c,variableHash:u?l(JSON.stringify(c||{})):void 0,method:r,elapsed:Date.now()-n,ip:x[0]||e.get("true-client-ip")||e.get("x-real-ip")||void 0,hasSetCookie:k,referer:e.get("referer")||void 0,userAgent:e.get("user-agent")||void 0,statusCode:200,errors:s,responseSize:JSON.stringify(i).length,responseHash:l(JSON.stringify(i)),varyHash:h}}function b(e){if(typeof e!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}}var T=process.env.STELLATE_ENDPOINT==="local"||process.env.STELLATE_ENDPOINT==="staging"?"stellate.dev":"stellate.sh";async function v({fetch:e,payload:t,token:r,serviceName:n}){return e(`https://${n}.${T}/log`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json","Stellate-Logging-Token":r}})}var q=e=>({onExecute(t){var o;let r=(o=e.sendVariablesAsHash)!=null?o:!0,n=Date.now();return{async onExecuteDone({result:s}){if((0,H.isAsyncIterable)(s)){console.warn("Stellate does not currently support logging incremental results.");return}let{headers:i,method:c}=t.args.contextValue.request;if(i.has("gcdn-request-id"))return;let g=y({headers:i,operation:(0,S.print)(t.args.document),method:c,sendVariablesAsHash:r,start:n,operationName:t.args.operationName,errors:s.errors,response:s});b(e.fetch);try{await v({fetch:e.fetch,payload:g,token:e.token,serviceName:e.serviceName})}catch{}}}}});0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
@@ -25,11 +25,22 @@ function extractStellatePayload({
25
25
  errors,
26
26
  response,
27
27
  variables,
28
+ responseHeaders,
28
29
  sendVariablesAsHash,
29
30
  hasSetCookie
30
31
  }) {
31
32
  const forwardedFor = headers.get("x-forwarded-for");
32
33
  const ips = forwardedFor ? forwardedFor.split(",") : [];
34
+ const vary = responseHeaders && responseHeaders.get("vary");
35
+ let varyHash = void 0;
36
+ if (vary && vary.length) {
37
+ const varyHeaders = vary.split(",").map((headerName) => headerName && headerName.trim()).sort();
38
+ const variedValues = varyHeaders.map((headerName) => {
39
+ const headerValue = headerName && headers.get(headerName);
40
+ return headerValue ? `${headerName}:${headerValue}` : void 0;
41
+ }).filter(Boolean).join("\n");
42
+ varyHash = createBlake3Hash(variedValues);
43
+ }
33
44
  return {
34
45
  operation,
35
46
  operationName,
@@ -44,7 +55,8 @@ function extractStellatePayload({
44
55
  statusCode: 200,
45
56
  errors,
46
57
  responseSize: JSON.stringify(response).length,
47
- responseHash: createBlake3Hash(JSON.stringify(response))
58
+ responseHash: createBlake3Hash(JSON.stringify(response)),
59
+ varyHash
48
60
  };
49
61
  }
50
62
  function warnFetch(fetch) {
package/dist/index.d.ts CHANGED
@@ -790,6 +790,100 @@ declare const inputSchema: z.ZodObject<{
790
790
  include: string[];
791
791
  exclude: string[];
792
792
  }>>>;
793
+ security: z.ZodNullable<z.ZodOptional<z.ZodObject<{
794
+ requestSize: z.ZodOptional<z.ZodNullable<z.ZodObject<{
795
+ maxBytes: z.ZodNumber;
796
+ enabled: z.ZodBoolean;
797
+ }, "strip", z.ZodTypeAny, {
798
+ enabled: boolean;
799
+ maxBytes: number;
800
+ }, {
801
+ enabled: boolean;
802
+ maxBytes: number;
803
+ }>>>;
804
+ directives: z.ZodOptional<z.ZodNullable<z.ZodObject<{
805
+ max: z.ZodNumber;
806
+ enabled: z.ZodBoolean;
807
+ }, "strip", z.ZodTypeAny, {
808
+ enabled: boolean;
809
+ max: number;
810
+ }, {
811
+ enabled: boolean;
812
+ max: number;
813
+ }>>>;
814
+ depth: z.ZodOptional<z.ZodNullable<z.ZodObject<{
815
+ max: z.ZodNumber;
816
+ enabled: z.ZodBoolean;
817
+ }, "strip", z.ZodTypeAny, {
818
+ enabled: boolean;
819
+ max: number;
820
+ }, {
821
+ enabled: boolean;
822
+ max: number;
823
+ }>>>;
824
+ aliases: z.ZodOptional<z.ZodNullable<z.ZodObject<{
825
+ max: z.ZodNumber;
826
+ enabled: z.ZodBoolean;
827
+ }, "strip", z.ZodTypeAny, {
828
+ enabled: boolean;
829
+ max: number;
830
+ }, {
831
+ enabled: boolean;
832
+ max: number;
833
+ }>>>;
834
+ suggestionsInErrors: z.ZodOptional<z.ZodNullable<z.ZodObject<{
835
+ mode: z.ZodEnum<["mask"]>;
836
+ enabled: z.ZodBoolean;
837
+ }, "strip", z.ZodTypeAny, {
838
+ enabled: boolean;
839
+ mode: "mask";
840
+ }, {
841
+ enabled: boolean;
842
+ mode: "mask";
843
+ }>>>;
844
+ }, "strip", z.ZodTypeAny, {
845
+ requestSize?: {
846
+ enabled: boolean;
847
+ maxBytes: number;
848
+ } | null | undefined;
849
+ directives?: {
850
+ enabled: boolean;
851
+ max: number;
852
+ } | null | undefined;
853
+ depth?: {
854
+ enabled: boolean;
855
+ max: number;
856
+ } | null | undefined;
857
+ aliases?: {
858
+ enabled: boolean;
859
+ max: number;
860
+ } | null | undefined;
861
+ suggestionsInErrors?: {
862
+ enabled: boolean;
863
+ mode: "mask";
864
+ } | null | undefined;
865
+ }, {
866
+ requestSize?: {
867
+ enabled: boolean;
868
+ maxBytes: number;
869
+ } | null | undefined;
870
+ directives?: {
871
+ enabled: boolean;
872
+ max: number;
873
+ } | null | undefined;
874
+ depth?: {
875
+ enabled: boolean;
876
+ max: number;
877
+ } | null | undefined;
878
+ aliases?: {
879
+ enabled: boolean;
880
+ max: number;
881
+ } | null | undefined;
882
+ suggestionsInErrors?: {
883
+ enabled: boolean;
884
+ mode: "mask";
885
+ } | null | undefined;
886
+ }>>>;
793
887
  }, "strip", z.ZodTypeAny, {
794
888
  app?: string | undefined;
795
889
  name?: string | undefined;
@@ -979,6 +1073,28 @@ declare const inputSchema: z.ZodObject<{
979
1073
  include: string[];
980
1074
  exclude: string[];
981
1075
  } | null | undefined;
1076
+ security?: {
1077
+ requestSize?: {
1078
+ enabled: boolean;
1079
+ maxBytes: number;
1080
+ } | null | undefined;
1081
+ directives?: {
1082
+ enabled: boolean;
1083
+ max: number;
1084
+ } | null | undefined;
1085
+ depth?: {
1086
+ enabled: boolean;
1087
+ max: number;
1088
+ } | null | undefined;
1089
+ aliases?: {
1090
+ enabled: boolean;
1091
+ max: number;
1092
+ } | null | undefined;
1093
+ suggestionsInErrors?: {
1094
+ enabled: boolean;
1095
+ mode: "mask";
1096
+ } | null | undefined;
1097
+ } | null | undefined;
982
1098
  }, {
983
1099
  app?: string | undefined;
984
1100
  name?: string | undefined;
@@ -1168,6 +1284,28 @@ declare const inputSchema: z.ZodObject<{
1168
1284
  include: string[];
1169
1285
  exclude: string[];
1170
1286
  } | null | undefined;
1287
+ security?: {
1288
+ requestSize?: {
1289
+ enabled: boolean;
1290
+ maxBytes: number;
1291
+ } | null | undefined;
1292
+ directives?: {
1293
+ enabled: boolean;
1294
+ max: number;
1295
+ } | null | undefined;
1296
+ depth?: {
1297
+ enabled: boolean;
1298
+ max: number;
1299
+ } | null | undefined;
1300
+ aliases?: {
1301
+ enabled: boolean;
1302
+ max: number;
1303
+ } | null | undefined;
1304
+ suggestionsInErrors?: {
1305
+ enabled: boolean;
1306
+ mode: "mask";
1307
+ } | null | undefined;
1308
+ } | null | undefined;
1171
1309
  }>;
1172
1310
  type Input$1 = Readonly<z.infer<typeof inputSchema>>;
1173
1311
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stellate",
3
- "version": "2.8.2",
3
+ "version": "2.9.0",
4
4
  "engines": {
5
5
  "node": ">=16"
6
6
  },
@@ -44,7 +44,7 @@
44
44
  "vitest": "^0.29.7",
45
45
  "ws": "8.11.0",
46
46
  "yaml": "^1.10.2",
47
- "@gcdn/configuration": "1.30.0"
47
+ "@gcdn/configuration": "1.30.1"
48
48
  },
49
49
  "bin": {
50
50
  "stellate": "dist/bin.js",