stellate 2.1.1 → 2.2.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.
@@ -4,6 +4,7 @@ interface Options {
4
4
  serviceName: string;
5
5
  token: string;
6
6
  fetch: typeof fetch;
7
+ sendVariablesAsHash?: boolean;
7
8
  }
8
9
 
9
10
  declare function createBlake3Hash(str: string): number;
@@ -1 +1 @@
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});
1
+ "use strict";var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var A=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 s of v(e))!A.call(t,s)&&s!==r&&l(t,s,{get:()=>e[s],enumerable:!(n=m(e,s))||n.enumerable});return t};var k=t=>P(l({},"__esModule",{value:!0}),t);var H={};w(H,{createBlake3Hash:()=>i,createStellateLoggerPlugin:()=>O});module.exports=k(H);function i(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}var O=t=>{let e=t.sendVariablesAsHash!=null?t.sendVariablesAsHash:!1;return{async requestDidStart(r){let n=Date.now(),{request:s}=r,{operationName:h,query:d,variables:c,http:p}=s;if(!p||!d)return;let{headers:o,method:y}=p;if(!o.has("gcdn-request-id"))return{async willSendResponse(u){let{response:a}=u;if(a.body.kind!=="single"){console.warn("Stellate does not currently support logging incremental results.");return}let g=a.body.singleResult,f=o.get("x-forwarded-for"),S=f?f.split(","):[],b={operation:d,operationName:h,variables:e?void 0:c,variableHash:e?i(JSON.stringify(c)):void 0,hasSetCookie:a.http.headers.has("set-cookie"),method:y,elapsed:Date.now()-n,ip:S[0]||o.get("true-client-ip")||o.get("x-real-ip"),referer:o.get("referer"),userAgent:o.get("user-agent"),statusCode:a.http.status||200,errors:u.errors,responseSize:JSON.stringify(g).length,responseHash:i(JSON.stringify(g))};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(b),headers:{"Content-Type":"application/json","Stellate-Logging-Token":t.token}})}}}}};0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
@@ -16,6 +16,7 @@ function createBlake3Hash(str) {
16
16
  return val >>> 0;
17
17
  }
18
18
  var createStellateLoggerPlugin = (options) => {
19
+ const sendVariablesAsHash = options.sendVariablesAsHash != null ? options.sendVariablesAsHash : false;
19
20
  return {
20
21
  async requestDidStart(requestCtx) {
21
22
  const start = Date.now();
@@ -41,7 +42,8 @@ var createStellateLoggerPlugin = (options) => {
41
42
  const payload = {
42
43
  operation: query,
43
44
  operationName,
44
- variables,
45
+ variables: sendVariablesAsHash ? void 0 : variables,
46
+ variableHash: sendVariablesAsHash ? createBlake3Hash(JSON.stringify(variables)) : void 0,
45
47
  hasSetCookie: response.http.headers.has("set-cookie"),
46
48
  method,
47
49
  elapsed: Date.now() - start,
package/dist/bin.js CHANGED
@@ -1082,7 +1082,7 @@ Try running "stellate pull" first if your service has been created already.`);le
1082
1082
 
1083
1083
  -s, --service Name of the service
1084
1084
  -b, --browser Automatically open the preview UI with the default browser
1085
- `);var On=ge(Zi());var jg=ge(Zi());var VA=class{async parse(e){return vi(e,{"--help":Boolean,"-h":"--help","--version":Boolean,"-v":"--version","--json":Boolean})["--help"]?this.help():"stellate@2.1.1"}help(e){if(e)throw new ln(`
1085
+ `);var On=ge(Zi());var jg=ge(Zi());var VA=class{async parse(e){return vi(e,{"--help":Boolean,"-h":"--help","--version":Boolean,"-v":"--version","--json":Boolean})["--help"]?this.help():"stellate@2.2.0"}help(e){if(e)throw new ln(`
1086
1086
  ${jg.default.bold.red("!")} ${e}
1087
1087
  ${VA.help}`);return VA.help}},i1=VA;i1.help=gi(`
1088
1088
  Print current version of Stellate
@@ -1379,7 +1379,7 @@ Try running "stellate pull" first if your service has been created already.`);le
1379
1379
  value
1380
1380
  }
1381
1381
  }
1382
- `,u=await Sn();a=(await new qi(u).query(l,{name:"serve-token-"+Date.now(),appName:e})).createAdminApiToken.value,this.writePurgeToken(e,a)}let o=(0,cG.default)();o.use("/",(0,uG.createProxyMiddleware)({target:s,changeOrigin:!0,logLevel:"silent",onProxyReq:l=>{l.path.endsWith("/")&&(l.path=l.path.slice(0,-1)),l.setHeader("stellate-cli-serve-port",r),l.setHeader("stellate-token",a)}})),o.listen(r)}setupApiProxy(e,r){let i=`https://${e}.stellate.${process.env.STELLATE_ENDPOINT==="staging"||process.env.STELLATE_ENDPOINT==="local"?"dev":"sh"}`,n=(0,cG.default)();n.use("/",(0,uG.createProxyMiddleware)({target:i,changeOrigin:!0,headers:{"stellate-cli-serve-port":""+r},logLevel:"silent"})),n.listen(r)}ensureConfig(){Ad.default.existsSync(uu)||Ad.default.mkdirSync(uu)}getCache(){try{this.ensureConfig();let e=Ad.default.readFileSync(Q2,"utf-8");return JSON.parse(e)}catch{return{}}}getCacheEntry(e){try{this.ensureConfig();let r=Ad.default.readFileSync(Q2,"utf-8"),i=JSON.parse(r);if(!e)throw new Error('You need a service-name in your "stellate" config or as the "--service" argument.');return i[e]||{checksum:"",envName:""}}catch{return{checksum:"",envName:""}}}getChecksum(e){return iRt(JSON.stringify(e)+"2.1.1")}writePurgeToken(e,r){let i=this.getCache();i[e]={...i[e],purgeToken:r},Ad.default.writeFileSync(Q2,JSON.stringify(i))}writeCache(e,r,i){let n=this.getCache();if(!e)throw new Error('You need a service-name in your "stellate" config or as the "--service" argument.');return n[e]={checksum:this.getChecksum(r),envName:i},Ad.default.writeFileSync(Q2,JSON.stringify(n)),n[e]}},cx=pG;cx.help=gi(`
1382
+ `,u=await Sn();a=(await new qi(u).query(l,{name:"serve-token-"+Date.now(),appName:e})).createAdminApiToken.value,this.writePurgeToken(e,a)}let o=(0,cG.default)();o.use("/",(0,uG.createProxyMiddleware)({target:s,changeOrigin:!0,logLevel:"silent",onProxyReq:l=>{l.path.endsWith("/")&&(l.path=l.path.slice(0,-1)),l.setHeader("stellate-cli-serve-port",r),l.setHeader("stellate-token",a)}})),o.listen(r)}setupApiProxy(e,r){let i=`https://${e}.stellate.${process.env.STELLATE_ENDPOINT==="staging"||process.env.STELLATE_ENDPOINT==="local"?"dev":"sh"}`,n=(0,cG.default)();n.use("/",(0,uG.createProxyMiddleware)({target:i,changeOrigin:!0,headers:{"stellate-cli-serve-port":""+r},logLevel:"silent"})),n.listen(r)}ensureConfig(){Ad.default.existsSync(uu)||Ad.default.mkdirSync(uu)}getCache(){try{this.ensureConfig();let e=Ad.default.readFileSync(Q2,"utf-8");return JSON.parse(e)}catch{return{}}}getCacheEntry(e){try{this.ensureConfig();let r=Ad.default.readFileSync(Q2,"utf-8"),i=JSON.parse(r);if(!e)throw new Error('You need a service-name in your "stellate" config or as the "--service" argument.');return i[e]||{checksum:"",envName:""}}catch{return{checksum:"",envName:""}}}getChecksum(e){return iRt(JSON.stringify(e)+"2.2.0")}writePurgeToken(e,r){let i=this.getCache();i[e]={...i[e],purgeToken:r},Ad.default.writeFileSync(Q2,JSON.stringify(i))}writeCache(e,r,i){let n=this.getCache();if(!e)throw new Error('You need a service-name in your "stellate" config or as the "--service" argument.');return n[e]={checksum:this.getChecksum(r),envName:i},Ad.default.writeFileSync(Q2,JSON.stringify(n)),n[e]}},cx=pG;cx.help=gi(`
1383
1383
  (BETA) - Use a local backend with Stellate\u2019s GraphQL Edge Cache.
1384
1384
 
1385
1385
  ${Zg.default.bold("Usage")}
package/dist/envelop.d.ts CHANGED
@@ -4,6 +4,7 @@ interface Options {
4
4
  serviceName: string;
5
5
  token: string;
6
6
  fetch: typeof fetch;
7
+ sendVariablesAsHash?: boolean;
7
8
  }
8
9
 
9
10
  declare function createBlake3Hash(str: string): number;
package/dist/envelop.js CHANGED
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var o in e)s(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!h.call(t,r)&&r!==o&&s(t,r,{get:()=>e[r],enumerable:!(n=f(e,r))||n.enumerable});return t};var S=t=>y(s({},"__esModule",{value:!0}),t);var x={};m(x,{createBlake3Hash:()=>u,createStellateLoggerPlugin:()=>w});module.exports=S(x);var i=require("graphql"),l=require("@envelop/core");function u(t){let e=0,o=t.length;if(o===0)return e;for(let n=0;n<o;++n){let r=t.charCodeAt(n);e=(e<<5)-e+r,e&=e}return e>>>0}var w=t=>({onExecute(e){let o=Date.now();return{async onExecuteDone({result:n}){if((0,l.isAsyncIterable)(n)){console.warn("Stellate does not currently support logging incremental results.");return}let{headers:r,method:g}=e.args.contextValue.request;if(r.has("gcdn-request-id"))return;let a=r.get("x-forwarded-for"),c=a?a.split(","):[],d={operation:(0,i.print)(e.args.document),operationName:e.args.operationName||void 0,variables:e.args.variableValues||void 0,method:g,elapsed:Date.now()-o,ip:c[0]||r.get("true-client-ip")||r.get("x-real-ip")||void 0,referer:r.get("referer")||void 0,userAgent:r.get("user-agent")||void 0,statusCode:200,errors:n.errors,responseSize:JSON.stringify(n).length,responseHash:u(JSON.stringify(n))};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(d),headers:{"Content-Type":"application/json","Stellate-Logging-Token":t.token}})}}}});0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
1
+ "use strict";var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var n in e)o(t,n,{get:e[n],enumerable:!0})},S=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!b.call(t,r)&&r!==n&&o(t,r,{get:()=>e[r],enumerable:!(s=h(e,r))||s.enumerable});return t};var v=t=>S(o({},"__esModule",{value:!0}),t);var x={};y(x,{createBlake3Hash:()=>i,createStellateLoggerPlugin:()=>w});module.exports=v(x);var d=require("graphql"),g=require("@envelop/core");function i(t){let e=0,n=t.length;if(n===0)return e;for(let s=0;s<n;++s){let r=t.charCodeAt(s);e=(e<<5)-e+r,e&=e}return e>>>0}var w=t=>({onExecute(e){let n=t.sendVariablesAsHash!=null?t.sendVariablesAsHash:!1,s=Date.now();return{async onExecuteDone({result:r}){if((0,g.isAsyncIterable)(r)){console.warn("Stellate does not currently support logging incremental results.");return}let{headers:a,method:c}=e.args.contextValue.request;if(a.has("gcdn-request-id"))return;let l=a.get("x-forwarded-for"),f=l?l.split(","):[],u=e.args.variableValues,p={operation:(0,d.print)(e.args.document),operationName:e.args.operationName||void 0,variables:n?void 0:u,variableHash:n?i(JSON.stringify(u||{})):void 0,method:c,elapsed:Date.now()-s,ip:f[0]||a.get("true-client-ip")||a.get("x-real-ip")||void 0,referer:a.get("referer")||void 0,userAgent:a.get("user-agent")||void 0,statusCode:200,errors:r.errors,responseSize:JSON.stringify(r).length,responseHash:i(JSON.stringify(r))};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(p),headers:{"Content-Type":"application/json","Stellate-Logging-Token":t.token}})}}}});0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
package/dist/envelop.mjs CHANGED
@@ -19,6 +19,7 @@ function createBlake3Hash(str) {
19
19
  }
20
20
  var createStellateLoggerPlugin = (options) => ({
21
21
  onExecute(payload) {
22
+ const sendVariablesAsHash = options.sendVariablesAsHash != null ? options.sendVariablesAsHash : false;
22
23
  const start = Date.now();
23
24
  return {
24
25
  async onExecuteDone({ result }) {
@@ -33,10 +34,12 @@ var createStellateLoggerPlugin = (options) => ({
33
34
  return;
34
35
  const forwardedFor = requestHeaders.get("x-forwarded-for");
35
36
  const ips = forwardedFor ? forwardedFor.split(",") : [];
37
+ const variables = payload.args.variableValues;
36
38
  const stellatePayload = {
37
39
  operation: print(payload.args.document),
38
40
  operationName: payload.args.operationName || void 0,
39
- variables: payload.args.variableValues || void 0,
41
+ variables: sendVariablesAsHash ? void 0 : variables,
42
+ variableHash: sendVariablesAsHash ? createBlake3Hash(JSON.stringify(variables || {})) : void 0,
40
43
  method,
41
44
  elapsed: Date.now() - start,
42
45
  ip: ips[0] || requestHeaders.get("true-client-ip") || requestHeaders.get("x-real-ip") || void 0,
@@ -4,6 +4,7 @@ interface Options {
4
4
  serviceName: string;
5
5
  token: string;
6
6
  fetch: typeof fetch;
7
+ sendVariablesAsHash?: boolean;
7
8
  }
8
9
 
9
10
  declare function createBlake3Hash(str: string): number;
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var o in e)s(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!h.call(t,r)&&r!==o&&s(t,r,{get:()=>e[r],enumerable:!(n=f(e,r))||n.enumerable});return t};var S=t=>y(s({},"__esModule",{value:!0}),t);var x={};m(x,{createBlake3Hash:()=>g,createStellateLoggerPlugin:()=>w});module.exports=S(x);var i=require("graphql"),l=require("graphql-yoga");function g(t){let e=0,o=t.length;if(o===0)return e;for(let n=0;n<o;++n){let r=t.charCodeAt(n);e=(e<<5)-e+r,e&=e}return e>>>0}var w=t=>({onExecute(e){let o=Date.now();return{async onExecuteDone({result:n}){if((0,l.isAsyncIterable)(n)){console.warn("Stellate does not currently support logging incremental results.");return}let{headers:r,method:u}=e.args.contextValue.request;if(r.has("gcdn-request-id"))return;let a=r.get("x-forwarded-for"),c=a?a.split(","):[],d={operation:(0,i.print)(e.args.document),operationName:e.args.operationName||void 0,variables:e.args.variableValues||void 0,method:u,elapsed:Date.now()-o,ip:c[0]||r.get("true-client-ip")||r.get("x-real-ip")||void 0,referer:r.get("referer")||void 0,userAgent:r.get("user-agent")||void 0,statusCode:200,errors:n.errors,responseSize:JSON.stringify(n).length,responseHash:g(JSON.stringify(n))};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(d),headers:{"Content-Type":"application/json","Stellate-Logging-Token":t.token}})}}}});0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
1
+ "use strict";var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var n in e)o(t,n,{get:e[n],enumerable:!0})},S=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!b.call(t,r)&&r!==n&&o(t,r,{get:()=>e[r],enumerable:!(s=h(e,r))||s.enumerable});return t};var v=t=>S(o({},"__esModule",{value:!0}),t);var x={};y(x,{createBlake3Hash:()=>i,createStellateLoggerPlugin:()=>w});module.exports=v(x);var g=require("graphql"),u=require("graphql-yoga");function i(t){let e=0,n=t.length;if(n===0)return e;for(let s=0;s<n;++s){let r=t.charCodeAt(s);e=(e<<5)-e+r,e&=e}return e>>>0}var w=t=>({onExecute(e){let n=t.sendVariablesAsHash!=null?t.sendVariablesAsHash:!1,s=Date.now();return{async onExecuteDone({result:r}){if((0,u.isAsyncIterable)(r)){console.warn("Stellate does not currently support logging incremental results.");return}let{headers:a,method:c}=e.args.contextValue.request;if(a.has("gcdn-request-id"))return;let l=a.get("x-forwarded-for"),f=l?l.split(","):[],d=e.args.variableValues,p={operation:(0,g.print)(e.args.document),operationName:e.args.operationName||void 0,variables:n?void 0:d,variableHash:n?i(JSON.stringify(d||{})):void 0,method:c,elapsed:Date.now()-s,ip:f[0]||a.get("true-client-ip")||a.get("x-real-ip")||void 0,referer:a.get("referer")||void 0,userAgent:a.get("user-agent")||void 0,statusCode:200,errors:r.errors,responseSize:JSON.stringify(r).length,responseHash:i(JSON.stringify(r))};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(p),headers:{"Content-Type":"application/json","Stellate-Logging-Token":t.token}})}}}});0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
@@ -19,6 +19,7 @@ function createBlake3Hash(str) {
19
19
  }
20
20
  var createStellateLoggerPlugin = (options) => ({
21
21
  onExecute(payload) {
22
+ const sendVariablesAsHash = options.sendVariablesAsHash != null ? options.sendVariablesAsHash : false;
22
23
  const start = Date.now();
23
24
  return {
24
25
  async onExecuteDone({ result }) {
@@ -33,10 +34,12 @@ var createStellateLoggerPlugin = (options) => ({
33
34
  return;
34
35
  const forwardedFor = requestHeaders.get("x-forwarded-for");
35
36
  const ips = forwardedFor ? forwardedFor.split(",") : [];
37
+ const variables = payload.args.variableValues;
36
38
  const stellatePayload = {
37
39
  operation: print(payload.args.document),
38
40
  operationName: payload.args.operationName || void 0,
39
- variables: payload.args.variableValues || void 0,
41
+ variables: sendVariablesAsHash ? void 0 : variables,
42
+ variableHash: sendVariablesAsHash ? createBlake3Hash(JSON.stringify(variables || {})) : void 0,
40
43
  method,
41
44
  elapsed: Date.now() - start,
42
45
  ip: ips[0] || requestHeaders.get("true-client-ip") || requestHeaders.get("x-real-ip") || void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stellate",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "engines": {
5
5
  "node": ">=16"
6
6
  },
@@ -12,7 +12,7 @@
12
12
  "devDependencies": {
13
13
  "@apollo/server": "^4.9.0",
14
14
  "@envelop/core": "^4.0.0",
15
- "@graphql-codegen/plugin-helpers": "^2.4.2",
15
+ "@graphql-codegen/plugin-helpers": "^5.0.1",
16
16
  "@graphql-tools/code-file-loader": "^7.2.4",
17
17
  "@graphql-tools/git-loader": "^7.1.3",
18
18
  "@graphql-tools/github-loader": "^7.2.4",