stellate 2.8.2 → 2.10.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.d.ts CHANGED
@@ -5,6 +5,7 @@ interface Options {
5
5
  token: string;
6
6
  fetch: typeof fetch;
7
7
  sendVariablesAsHash?: boolean;
8
+ schemaSyncing?: boolean;
8
9
  }
9
10
  declare function createBlake3Hash(str: string): number;
10
11
 
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 m=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var r in t)m(e,r,{get:t[r],enumerable:!0})},E=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of T(t))!O.call(e,o)&&o!==r&&m(e,o,{get:()=>t[o],enumerable:!(n=P(t,o))||n.enumerable});return e};var q=e=>E(m({},"__esModule",{value:!0}),e);var R={};C(R,{createBlake3Hash:()=>g,createStellateLoggerPlugin:()=>A});module.exports=q(R);var h=require("graphql"),L=require("@envelop/core");function g(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 w({headers:e,operation:t,method:r,start:n,operationName:o,errors:u,response:i,variables:a,responseHeaders:c,sendVariablesAsHash:s,hasSetCookie:p}){let d=e.get("x-forwarded-for"),b=d?d.split(","):[],f=c&&c.get("vary"),v;if(f&&f.length){let N=f.split(",").map(l=>l&&l.trim()).sort().map(l=>{let k=l&&e.get(l);return k?`${l}:${k}`:void 0}).filter(Boolean).join(`
2
+ `);v=g(N)}return{operation:t,operationName:o,variables:s?void 0:a,variableHash:s?g(JSON.stringify(a||{})):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:u,responseSize:JSON.stringify(i).length,responseHash:g(JSON.stringify(i)),varyHash:v}}function x(e){if(typeof e!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}}var y=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}.${y}/log`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json","Stellate-Logging-Token":r}})}var S=class{constructor(t){this.headers=Object.keys(t).reduce((r,n)=>(r[n.trim().toLowerCase()]=t[n],r),{})}get(t){return this.headers[t.trim().toLowerCase()]}has(t){return!!this.headers[t.trim().toLowerCase()]}},A=e=>{var n;let t=(n=e.schemaSyncing)!=null?n:!0,r;return{onSchemaChange(o){if(t){let u=o.schema,i=Math.random()*5e3;r&&clearTimeout(r),r=setTimeout(async()=>{r=null;try{let a=(0,h.introspectionFromSchema)(u);e.fetch(`https://${e.serviceName}.${y}/schema`,{method:"POST",body:JSON.stringify({schema:a}),headers:{"Content-Type":"application/json","Stellate-Schema-Token":e.token}}).then(()=>{})}catch{}},i)}},onExecute(o){var a;let u=(a=e.sendVariablesAsHash)!=null?a:!0,i=Date.now();return{async onExecuteDone({result:c}){if((0,L.isAsyncIterable)(c)){console.warn("Stellate does not currently support logging incremental results.");return}let{headers:s}=o.args.contextValue.request,{method:p}=o.args.contextValue.request;if(typeof s.get!="function"&&(s=new S(s)),s.has("gcdn-request-id"))return;let d=w({headers:s,operation:(0,h.print)(o.args.document),method:p,sendVariablesAsHash:u,start:i,operationName:o.args.operationName,errors:c.errors,response:c});x(e.fetch);try{await H({fetch:e.fetch,payload:d,token:e.token,serviceName:e.serviceName})}catch{}}}}}};0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
package/dist/envelop.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/envelop.ts
2
- import { print } from "graphql";
2
+ import { introspectionFromSchema, print } from "graphql";
3
3
  import { isAsyncIterable } from "@envelop/core";
4
4
 
5
5
  // src/server-plugins-shared.ts
@@ -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) {
@@ -87,52 +99,83 @@ var FauxHeaders = class {
87
99
  return !!this.headers[key.trim().toLowerCase()];
88
100
  }
89
101
  };
90
- var createStellateLoggerPlugin = (options) => ({
91
- onExecute(payload) {
92
- var _a;
93
- const sendVariablesAsHash = (_a = options.sendVariablesAsHash) != null ? _a : true;
94
- const start = Date.now();
95
- return {
96
- async onExecuteDone({ result }) {
97
- if (isAsyncIterable(result)) {
98
- console.warn(
99
- `Stellate does not currently support logging incremental results.`
100
- );
101
- return;
102
- }
103
- let { headers } = payload.args.contextValue.request;
104
- const { method } = payload.args.contextValue.request;
105
- if (typeof headers.get !== "function") {
106
- headers = new FauxHeaders(
107
- headers
108
- );
109
- }
110
- if (headers.has("gcdn-request-id"))
111
- return;
112
- const stellatePayload = extractStellatePayload({
113
- headers,
114
- operation: print(payload.args.document),
115
- method,
116
- sendVariablesAsHash,
117
- start,
118
- operationName: payload.args.operationName,
119
- errors: result.errors,
120
- response: result
121
- });
122
- warnFetch(options.fetch);
123
- try {
124
- await logRequest({
125
- fetch: options.fetch,
126
- payload: stellatePayload,
127
- token: options.token,
128
- serviceName: options.serviceName
102
+ var createStellateLoggerPlugin = (options) => {
103
+ var _a;
104
+ const shouldSyncSchema = (_a = options.schemaSyncing) != null ? _a : true;
105
+ let timeout;
106
+ return {
107
+ onSchemaChange(opts) {
108
+ if (shouldSyncSchema) {
109
+ const apiSchema = opts.schema;
110
+ const randomTimeout = Math.random() * 5e3;
111
+ if (timeout)
112
+ clearTimeout(timeout);
113
+ timeout = setTimeout(async () => {
114
+ timeout = null;
115
+ try {
116
+ const introspection = introspectionFromSchema(apiSchema);
117
+ options.fetch(`https://${options.serviceName}.${hostname}/schema`, {
118
+ method: "POST",
119
+ body: JSON.stringify({
120
+ schema: introspection
121
+ }),
122
+ headers: {
123
+ "Content-Type": "application/json",
124
+ "Stellate-Schema-Token": options.token
125
+ }
126
+ }).then(() => {
127
+ });
128
+ } catch (e) {
129
+ }
130
+ }, randomTimeout);
131
+ }
132
+ },
133
+ onExecute(payload) {
134
+ var _a2;
135
+ const sendVariablesAsHash = (_a2 = options.sendVariablesAsHash) != null ? _a2 : true;
136
+ const start = Date.now();
137
+ return {
138
+ async onExecuteDone({ result }) {
139
+ if (isAsyncIterable(result)) {
140
+ console.warn(
141
+ `Stellate does not currently support logging incremental results.`
142
+ );
143
+ return;
144
+ }
145
+ let { headers } = payload.args.contextValue.request;
146
+ const { method } = payload.args.contextValue.request;
147
+ if (typeof headers.get !== "function") {
148
+ headers = new FauxHeaders(
149
+ headers
150
+ );
151
+ }
152
+ if (headers.has("gcdn-request-id"))
153
+ return;
154
+ const stellatePayload = extractStellatePayload({
155
+ headers,
156
+ operation: print(payload.args.document),
157
+ method,
158
+ sendVariablesAsHash,
159
+ start,
160
+ operationName: payload.args.operationName,
161
+ errors: result.errors,
162
+ response: result
129
163
  });
130
- } catch (e) {
164
+ warnFetch(options.fetch);
165
+ try {
166
+ await logRequest({
167
+ fetch: options.fetch,
168
+ payload: stellatePayload,
169
+ token: options.token,
170
+ serviceName: options.serviceName
171
+ });
172
+ } catch (e) {
173
+ }
131
174
  }
132
- }
133
- };
134
- }
135
- });
175
+ };
176
+ }
177
+ };
178
+ };
136
179
  export {
137
180
  createBlake3Hash,
138
181
  createStellateLoggerPlugin
@@ -5,6 +5,7 @@ interface Options {
5
5
  token: string;
6
6
  fetch: typeof fetch;
7
7
  sendVariablesAsHash?: boolean;
8
+ schemaSyncing?: boolean;
8
9
  }
9
10
  declare function createBlake3Hash(str: string): number;
10
11
 
@@ -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 m=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},E=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of L(t))!w.call(e,r)&&r!==n&&m(e,r,{get:()=>t[r],enumerable:!(a=T(t,r))||a.enumerable});return e};var A=e=>E(m({},"__esModule",{value:!0}),e);var q={};O(q,{createBlake3Hash:()=>g,createStellateLoggerPlugin:()=>C});module.exports=A(q);var p=require("graphql"),N=require("graphql-yoga");function g(e){let t=0,n=e.length;if(n===0)return t;for(let a=0;a<n;++a){let r=e.charCodeAt(a);t=(t<<5)-t+r,t&=t}return t>>>0}function k({headers:e,operation:t,method:n,start:a,operationName:r,errors:l,response:s,variables:o,responseHeaders:i,sendVariablesAsHash:u,hasSetCookie:h}){let d=e.get("x-forwarded-for"),S=d?d.split(","):[],f=i&&i.get("vary"),b;if(f&&f.length){let P=f.split(",").map(c=>c&&c.trim()).sort().map(c=>{let v=c&&e.get(c);return v?`${c}:${v}`:void 0}).filter(Boolean).join(`
2
+ `);b=g(P)}return{operation:t,operationName:r,variables:u?void 0:o,variableHash:u?g(JSON.stringify(o||{})):void 0,method:n,elapsed:Date.now()-a,ip:S[0]||e.get("true-client-ip")||e.get("x-real-ip")||void 0,hasSetCookie:h,referer:e.get("referer")||void 0,userAgent:e.get("user-agent")||void 0,statusCode:200,errors:l,responseSize:JSON.stringify(s).length,responseHash:g(JSON.stringify(s)),varyHash:b}}function x(e){if(typeof e!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}}var y=process.env.STELLATE_ENDPOINT==="local"||process.env.STELLATE_ENDPOINT==="staging"?"stellate.dev":"stellate.sh";async function H({fetch:e,payload:t,token:n,serviceName:a}){return e(`https://${a}.${y}/log`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json","Stellate-Logging-Token":n}})}var C=e=>{var a;let t=(a=e.schemaSyncing)!=null?a:!0,n;return{onSchemaChange(r){if(t){let l=r.schema,s=Math.random()*5e3;n&&clearTimeout(n),n=setTimeout(async()=>{n=null;try{let o=(0,p.introspectionFromSchema)(l);e.fetch(`https://${e.serviceName}.${y}/schema`,{method:"POST",body:JSON.stringify({schema:o}),headers:{"Content-Type":"application/json","Stellate-Schema-Token":e.token}}).then(()=>{}).catch(()=>{})}catch{}},s)}},onExecute(r){var o;let l=(o=e.sendVariablesAsHash)!=null?o:!0,s=Date.now();return{async onExecuteDone({result:i}){if((0,N.isAsyncIterable)(i)){console.warn("Stellate does not currently support logging incremental results.");return}let{headers:u,method:h}=r.args.contextValue.request;if(u.has("gcdn-request-id"))return;let d=k({headers:u,operation:(0,p.print)(r.args.document),method:h,sendVariablesAsHash:l,start:s,operationName:r.args.operationName,errors:i.errors,response:i});x(e.fetch);try{await H({fetch:e.fetch,payload:d,token:e.token,serviceName:e.serviceName})}catch{}}}}}};0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
@@ -1,5 +1,5 @@
1
1
  // src/graphql-yoga.ts
2
- import { print } from "graphql";
2
+ import { print, introspectionFromSchema } from "graphql";
3
3
  import { isAsyncIterable } from "graphql-yoga";
4
4
 
5
5
  // src/server-plugins-shared.ts
@@ -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) {
@@ -73,46 +85,78 @@ async function logRequest({
73
85
  }
74
86
 
75
87
  // src/graphql-yoga.ts
76
- var createStellateLoggerPlugin = (options) => ({
77
- onExecute(payload) {
78
- var _a;
79
- const sendVariablesAsHash = (_a = options.sendVariablesAsHash) != null ? _a : true;
80
- const start = Date.now();
81
- return {
82
- async onExecuteDone({ result }) {
83
- if (isAsyncIterable(result)) {
84
- console.warn(
85
- `Stellate does not currently support logging incremental results.`
86
- );
87
- return;
88
- }
89
- const { headers, method } = payload.args.contextValue.request;
90
- if (headers.has("gcdn-request-id"))
91
- return;
92
- const stellatePayload = extractStellatePayload({
93
- headers,
94
- operation: print(payload.args.document),
95
- method,
96
- sendVariablesAsHash,
97
- start,
98
- operationName: payload.args.operationName,
99
- errors: result.errors,
100
- response: result
101
- });
102
- warnFetch(options.fetch);
103
- try {
104
- await logRequest({
105
- fetch: options.fetch,
106
- payload: stellatePayload,
107
- token: options.token,
108
- serviceName: options.serviceName
88
+ var createStellateLoggerPlugin = (options) => {
89
+ var _a;
90
+ const shouldSyncSchema = (_a = options.schemaSyncing) != null ? _a : true;
91
+ let timeout;
92
+ return {
93
+ onSchemaChange(opts) {
94
+ if (shouldSyncSchema) {
95
+ const apiSchema = opts.schema;
96
+ const randomTimeout = Math.random() * 5e3;
97
+ if (timeout)
98
+ clearTimeout(timeout);
99
+ timeout = setTimeout(async () => {
100
+ timeout = null;
101
+ try {
102
+ const introspection = introspectionFromSchema(apiSchema);
103
+ options.fetch(`https://${options.serviceName}.${hostname}/schema`, {
104
+ method: "POST",
105
+ body: JSON.stringify({
106
+ schema: introspection
107
+ }),
108
+ headers: {
109
+ "Content-Type": "application/json",
110
+ "Stellate-Schema-Token": options.token
111
+ }
112
+ }).then(() => {
113
+ }).catch(() => {
114
+ });
115
+ } catch (e) {
116
+ }
117
+ }, randomTimeout);
118
+ }
119
+ },
120
+ onExecute(payload) {
121
+ var _a2;
122
+ const sendVariablesAsHash = (_a2 = options.sendVariablesAsHash) != null ? _a2 : true;
123
+ const start = Date.now();
124
+ return {
125
+ async onExecuteDone({ result }) {
126
+ if (isAsyncIterable(result)) {
127
+ console.warn(
128
+ `Stellate does not currently support logging incremental results.`
129
+ );
130
+ return;
131
+ }
132
+ const { headers, method } = payload.args.contextValue.request;
133
+ if (headers.has("gcdn-request-id"))
134
+ return;
135
+ const stellatePayload = extractStellatePayload({
136
+ headers,
137
+ operation: print(payload.args.document),
138
+ method,
139
+ sendVariablesAsHash,
140
+ start,
141
+ operationName: payload.args.operationName,
142
+ errors: result.errors,
143
+ response: result
109
144
  });
110
- } catch (e) {
145
+ warnFetch(options.fetch);
146
+ try {
147
+ await logRequest({
148
+ fetch: options.fetch,
149
+ payload: stellatePayload,
150
+ token: options.token,
151
+ serviceName: options.serviceName
152
+ });
153
+ } catch (e) {
154
+ }
111
155
  }
112
- }
113
- };
114
- }
115
- });
156
+ };
157
+ }
158
+ };
159
+ };
116
160
  export {
117
161
  createBlake3Hash,
118
162
  createStellateLoggerPlugin
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.10.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",