stellate 2.7.3 → 2.7.5
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/apollo-server.js +1 -1
- package/dist/apollo-server.mjs +7 -4
- package/dist/bin.js +4 -4
- package/dist/index.d.ts +0 -10
- package/package.json +2 -2
package/dist/apollo-server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var H=(e,r)=>{for(var t in r)f(e,t,{get:r[t],enumerable:!0})},A=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of P(r))!x.call(e,o)&&o!==t&&f(e,o,{get:()=>r[o],enumerable:!(n=w(r,o))||n.enumerable});return e};var L=e=>A(f({},"__esModule",{value:!0}),e);var T={};H(T,{createBlake3Hash:()=>c,createStellateLoggerPlugin:()=>q});module.exports=L(T);function c(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 m({headers:e,operation:r,method:t,start:n,operationName:o,errors:p,response:i,variables:l,sendVariablesAsHash:s,hasSetCookie:u}){let a=e.get("x-forwarded-for"),d=a?a.split(","):[];return{operation:r,operationName:o,variables:s?void 0:l,variableHash:s?c(JSON.stringify(l||{})):void 0,method:t,elapsed:Date.now()-n,ip:d[0]||e.get("true-client-ip")||e.get("x-real-ip")||void 0,hasSetCookie:u,referer:e.get("referer")||void 0,userAgent:e.get("user-agent")||void 0,statusCode:200,errors:p,responseSize:JSON.stringify(i).length,responseHash:c(JSON.stringify(i))}}function b(e){if(typeof e!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}}var O=process.env.STELLATE_ENDPOINT==="local"||process.env.STELLATE_ENDPOINT==="staging"?"stellate.dev":"stellate.sh";async function S({fetch:e,payload:r,token:t,serviceName:n}){return e(`https://${n}.${O}/log`,{method:"POST",body:JSON.stringify(r),headers:{"Content-Type":"application/json","Stellate-Logging-Token":t}})}var q=e=>{var t;let r=(t=e.sendVariablesAsHash)!=null?t:!0;return{async requestDidStart(n){let o=Date.now(),{request:p}=n,{operationName:i,variables:l,http:s,query:u}=p;if(!s)return;let{headers:a,method:d}=s;if(!a.has("gcdn-request-id"))return{async willSendResponse(h){let{response:g,source:v}=h;if(g.body.kind!=="single"){console.warn("Stellate does not currently support logging incremental results.");return}let k=g.body.singleResult,y=u||v;if(!y)return;let N=m({headers:a,operation:y,method:d,sendVariablesAsHash:r,start:o,operationName:i,errors:h.errors,response:k,variables:l,hasSetCookie:g.http.headers.has("set-cookie")});b(e.fetch);try{await S({fetch:e.fetch,payload:N,token:e.token,serviceName:e.serviceName})}catch{}}}}}};0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
|
package/dist/apollo-server.mjs
CHANGED
|
@@ -79,15 +79,15 @@ var createStellateLoggerPlugin = (options) => {
|
|
|
79
79
|
async requestDidStart(requestCtx) {
|
|
80
80
|
const start = Date.now();
|
|
81
81
|
const { request } = requestCtx;
|
|
82
|
-
const { operationName,
|
|
83
|
-
if (!http
|
|
82
|
+
const { operationName, variables, http, query } = request;
|
|
83
|
+
if (!http)
|
|
84
84
|
return;
|
|
85
85
|
const { headers, method } = http;
|
|
86
86
|
if (headers.has("gcdn-request-id"))
|
|
87
87
|
return;
|
|
88
88
|
return {
|
|
89
89
|
async willSendResponse(respContext) {
|
|
90
|
-
const { response } = respContext;
|
|
90
|
+
const { response, source } = respContext;
|
|
91
91
|
if (response.body.kind !== "single") {
|
|
92
92
|
console.warn(
|
|
93
93
|
`Stellate does not currently support logging incremental results.`
|
|
@@ -95,9 +95,12 @@ var createStellateLoggerPlugin = (options) => {
|
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
const respBody = response.body.singleResult;
|
|
98
|
+
const queryString = query || source;
|
|
99
|
+
if (!queryString)
|
|
100
|
+
return;
|
|
98
101
|
const stellatePayload = extractStellatePayload({
|
|
99
102
|
headers,
|
|
100
|
-
operation:
|
|
103
|
+
operation: queryString,
|
|
101
104
|
method,
|
|
102
105
|
sendVariablesAsHash,
|
|
103
106
|
start,
|
package/dist/bin.js
CHANGED
|
@@ -509,7 +509,7 @@ ${r.data.toString("base64")}
|
|
|
509
509
|
${e.message}
|
|
510
510
|
|
|
511
511
|
Please try to use any of the available CLI options to provide this information.`)}return(0,bne.default)({...t[0],onState:e=>{e.aborted&&process.nextTick(()=>{process.exit(0)})}},{...t[1],onSubmit:()=>{console.log()}})};function py(){return Rs(`${il}/app/settings/access-tokens`)}function nm(t,e,r="overview"){return Rs(`${il}/app/${t}/${e}/${r}`)}var R6=(0,Sne.default)("stellate:client");var Tne=process.env.STELLATE_ENDPOINT==="local",Ene=process.env.STELLATE_ENDPOINT==="staging",il=Tne?"http://localhost:3000":Ene?"https://dev.stellate.co":"https://stellate.co";R6({baseUrl:il});var xne=Tne?"http://localhost:3001/api":Ene?"https://api-dev.stellate.co/api":"https://api.stellate.co/api";R6({apiUrl:xne});var En=class{constructor(e){this.token=e}async query(e,r){let i={"Content-Type":"application/json"};this.token&&(i["stellate-token"]=this.token);let n=JSON.stringify({query:e,variables:r}),s=await f6(xne,{method:"POST",body:n,headers:i}),a=await s.text();R6(a);let o;try{o=JSON.parse(a)}catch{throw new Error(a)}if(!s.ok)throw o.message==="Request Entity Too Large"||s.status===413?new Error("Payload too large, your GraphQL schema might be too large"):new Error(a);if(o.errors)throw new Error(PRe(o.errors[0].message));return R6(o),o.data||{}}};function PRe(t){return t.toLowerCase().includes("not authorized")?`Invalid api token. Please make sure that the env var STELLATE_TOKEN is valid or run "stellate login".
|
|
512
|
-
You can get a new api token at ${py()}`:t}var Fe=_e(require("zod"));var dt=_e(require("zod")),CRe=dt.string().refine(t=>t.match(/^[1-9][0-9]*(s|m|h)$/)),DRe=dt.object({value:dt.number().int().min(1),unit:dt.enum(["seconds","minutes","hours"])}).strict(),wne=dt.union([CRe,DRe]),vO=dt.object({type:dt.literal("QueryComplexity"),budget:dt.number().int().min(1),warning:dt.number().int().min(1).optional(),window:wne}).strict(),SO=dt.object({type:dt.literal("RequestCount"),budget:dt.number().int().min(1),warning:dt.number().int().min(1).optional(),window:wne}).strict(),b2=dt.union([dt.function(),dt.string()]),TO=["enabled","disabled","dryRun"],fy=dt.object({name:dt.string(),description:dt.string().optional(),state:dt.enum(TO).optional(),groupBy:dt.union([dt.literal("ip"),dt.object({header:dt.string()}),dt.object({cookie:dt.string()}),dt.object({jwt:dt.string()}),dt.object({consumerIdentifier:dt.string()})]),allowList:dt.array(dt.string()).optional(),limit:dt.union([vO,SO])}).strict(),E0r=dt.array(fy),x0r=dt.array(dt.union([fy,dt.object({name:dt.string(),description:dt.string().optional(),state:dt.enum(TO).optional(),group:dt.string(),allowList:dt.array(dt.string()).optional(),limit:dt.union([vO,SO])})])),B6=dt.object({name:dt.string(),description:dt.string().optional(),state:dt.enum(TO).optional(),consumerIdentifier:dt.string().optional(),allowList:dt.array(dt.string()).optional(),limit:dt.union([vO,SO])}).strict(),M6=dt.object({listSizeArguments:dt.array(dt.string()).optional(),maxComplexity:dt.number().int().min(1).optional()}).strict();var NRe=Fe.object({types:Fe.record(Fe.boolean().or(Fe.record(Fe.boolean())).or(Fe.array(Fe.string()))).or(Fe.array(Fe.string())),maxAge:Fe.number().min(0).optional().nullable(),swr:Fe.number().min(0).optional().nullable(),scope:Fe.string().nonempty().optional().nullable(),description:Fe.string().optional().nullable()}),IRe=["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES256k","EdDSA","PS256","PS384","PS512"],EO=Fe.object({claim:Fe.string().optional().nullable(),algorithm:Fe.enum(IRe).optional().nullable(),secret:Fe.string().optional().nullable()}).optional().nullable(),Cne=Fe.function().args(Fe.object({headers:Fe.record(Fe.string().or(Fe.array(Fe.string()))),cookies:Fe.record(Fe.string())})).returns(Fe.string().nullable()),ORe=Fe.object({definition:Fe.union([Fe.string(),Cne]).optional().nullable(),jwt:EO}),kRe=Fe.object({autoAdd:Fe.boolean().optional().nullable(),defaults:Fe.array(Fe.string()).optional().nullable(),types:Fe.record(Fe.array(Fe.string())).nullable()}),LRe=Fe.object({query:Fe.string().optional().nullable(),mutation:Fe.string().optional().nullable(),subscription:Fe.string().optional().nullable()}),Ane=Fe.object({isEnabled:Fe.boolean().optional().nullable(),whenGraphQLResponse:Fe.boolean().optional().nullable()}),FRe=Fe.object({networkErrors:Ane.optional().nullable(),serverErrors:Ane.optional().nullable()}),_ne=5,RRe=Fe.record(Fe.union([Fe.object({header:Fe.string(),jwt:EO}),Fe.object({cookie:Fe.string(),jwt:EO})])).refine(t=>Object.keys(t).length<=_ne,{message:`You can't define more than ${_ne} custom attributes`}),BRe=Fe.object({secret:Fe.string().optional().nullable()}),MRe=Fe.object({name:Fe.string()}),xO=Fe.object({enabled:Fe.boolean(),title:Fe.string().optional(),readme:Fe.string().optional(),description:Fe.string().optional(),urls:Fe.object({privacy:Fe.string().url().optional(),terms:Fe.string().url().optional(),website:Fe.string().url().optional(),logo:Fe.string().url().optional(),favicon:Fe.string().url().optional(),support:Fe.string().url().or(Fe.string().refine(t=>{if(!t.startsWith("mailto:"))return!1;let e=t.slice(7);return Fe.string().email().safeParse(e).success})).optional()}).optional(),brandColor:Fe.string().optional(),auth:Fe.boolean().optional()}),wO=Fe.object({enabled:Fe.boolean()
|
|
512
|
+
You can get a new api token at ${py()}`:t}var Fe=_e(require("zod"));var dt=_e(require("zod")),CRe=dt.string().refine(t=>t.match(/^[1-9][0-9]*(s|m|h)$/)),DRe=dt.object({value:dt.number().int().min(1),unit:dt.enum(["seconds","minutes","hours"])}).strict(),wne=dt.union([CRe,DRe]),vO=dt.object({type:dt.literal("QueryComplexity"),budget:dt.number().int().min(1),warning:dt.number().int().min(1).optional(),window:wne}).strict(),SO=dt.object({type:dt.literal("RequestCount"),budget:dt.number().int().min(1),warning:dt.number().int().min(1).optional(),window:wne}).strict(),b2=dt.union([dt.function(),dt.string()]),TO=["enabled","disabled","dryRun"],fy=dt.object({name:dt.string(),description:dt.string().optional(),state:dt.enum(TO).optional(),groupBy:dt.union([dt.literal("ip"),dt.object({header:dt.string()}),dt.object({cookie:dt.string()}),dt.object({jwt:dt.string()}),dt.object({consumerIdentifier:dt.string()})]),allowList:dt.array(dt.string()).optional(),limit:dt.union([vO,SO])}).strict(),E0r=dt.array(fy),x0r=dt.array(dt.union([fy,dt.object({name:dt.string(),description:dt.string().optional(),state:dt.enum(TO).optional(),group:dt.string(),allowList:dt.array(dt.string()).optional(),limit:dt.union([vO,SO])})])),B6=dt.object({name:dt.string(),description:dt.string().optional(),state:dt.enum(TO).optional(),consumerIdentifier:dt.string().optional(),allowList:dt.array(dt.string()).optional(),limit:dt.union([vO,SO])}).strict(),M6=dt.object({listSizeArguments:dt.array(dt.string()).optional(),maxComplexity:dt.number().int().min(1).optional()}).strict();var NRe=Fe.object({types:Fe.record(Fe.boolean().or(Fe.record(Fe.boolean())).or(Fe.array(Fe.string()))).or(Fe.array(Fe.string())),maxAge:Fe.number().min(0).optional().nullable(),swr:Fe.number().min(0).optional().nullable(),scope:Fe.string().nonempty().optional().nullable(),description:Fe.string().optional().nullable()}),IRe=["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES256k","EdDSA","PS256","PS384","PS512"],EO=Fe.object({claim:Fe.string().optional().nullable(),algorithm:Fe.enum(IRe).optional().nullable(),secret:Fe.string().optional().nullable()}).optional().nullable(),Cne=Fe.function().args(Fe.object({headers:Fe.record(Fe.string().or(Fe.array(Fe.string()))),cookies:Fe.record(Fe.string())})).returns(Fe.string().nullable()),ORe=Fe.object({definition:Fe.union([Fe.string(),Cne]).optional().nullable(),jwt:EO}),kRe=Fe.object({autoAdd:Fe.boolean().optional().nullable(),defaults:Fe.array(Fe.string()).optional().nullable(),types:Fe.record(Fe.array(Fe.string())).nullable()}),LRe=Fe.object({query:Fe.string().optional().nullable(),mutation:Fe.string().optional().nullable(),subscription:Fe.string().optional().nullable()}),Ane=Fe.object({isEnabled:Fe.boolean().optional().nullable(),whenGraphQLResponse:Fe.boolean().optional().nullable()}),FRe=Fe.object({networkErrors:Ane.optional().nullable(),serverErrors:Ane.optional().nullable()}),_ne=5,RRe=Fe.record(Fe.union([Fe.object({header:Fe.string(),jwt:EO}),Fe.object({cookie:Fe.string(),jwt:EO})])).refine(t=>Object.keys(t).length<=_ne,{message:`You can't define more than ${_ne} custom attributes`}),BRe=Fe.object({secret:Fe.string().optional().nullable()}),MRe=Fe.object({name:Fe.string()}),xO=Fe.object({enabled:Fe.boolean(),title:Fe.string().optional(),readme:Fe.string().optional(),description:Fe.string().optional(),urls:Fe.object({privacy:Fe.string().url().optional(),terms:Fe.string().url().optional(),website:Fe.string().url().optional(),logo:Fe.string().url().optional(),favicon:Fe.string().url().optional(),support:Fe.string().url().or(Fe.string().refine(t=>{if(!t.startsWith("mailto:"))return!1;let e=t.slice(7);return Fe.string().email().safeParse(e).success})).optional()}).optional(),brandColor:Fe.string().optional(),auth:Fe.boolean().optional()}),wO=Fe.object({enabled:Fe.boolean()}),jRe=Fe.object({enabled:Fe.boolean(),title:Fe.string().optional()}),Pne=Fe.string().max(60).regex(/^(?!-)[a-z0-9-]*[a-z0-9]$/i).transform(t=>t.toLowerCase()),VRe=Fe.object({app:Pne.optional(),name:Pne.optional(),originUrl:Fe.string().url().optional(),schema:Fe.string().optional().nullable(),cacheIntrospection:Fe.boolean().optional().nullable(),injectHeaders:Fe.boolean().optional().nullable(),devPortal:xO.optional().nullable(),partialQueryCaching:wO.optional().nullable(),ignoreOriginCacheControl:Fe.boolean().optional().nullable(),queryDepthLimit:Fe.number().int().min(0).max(1e3).optional().nullable(),passThroughOnly:Fe.boolean().optional().nullable(),mutationPolicy:Fe.enum(["Type","List","Entity"]).optional().nullable(),bypassCacheHeaders:Fe.array(MRe).optional().nullable(),enablePlayground:Fe.boolean().optional().nullable(),headers:Fe.record(Fe.string().nonempty()).optional().nullable(),scopes:Fe.record(Fe.string().or(Cne).or(ORe)).optional().nullable(),rootTypeNames:LRe.optional().nullable(),keyFields:kRe.optional().nullable(),rules:Fe.array(NRe).optional().nullable(),nonCacheable:Fe.array(Fe.string()).optional().nullable(),retries:FRe.optional().nullable(),customAttributes:RRe.optional().nullable(),graphiql:jRe.optional().nullable(),requestSigning:BRe.optional().nullable(),getConsumerIdentifiers:b2.optional().nullable(),rateLimit:B6.optional().nullable(),rateLimits:Fe.union([Fe.array(fy),b2]).optional().nullable(),complexity:M6.optional().nullable(),schemaView:Fe.object({include:Fe.array(Fe.string()),exclude:Fe.array(Fe.string())}).optional().nullable()}),Dne={schema:null,bypassCacheHeaders:null,injectHeaders:null,enablePlayground:null,ignoreOriginCacheControl:null,queryDepthLimit:null,passThroughOnly:null,mutationPolicy:null,headers:null,scopes:null,rootTypeNames:null,keyFields:null,rules:null,nonCacheable:null,retries:null,schemaView:null},dy=t=>{try{return VRe.parse(t)}catch(e){throw e instanceof Fe.ZodError?new Error(e.errors.map(r=>`${r.path.length>0?`${r.path.join(".")}: `:""}${r.message}`).join(`
|
|
513
513
|
- `),{cause:e}):e}};var sm=Object.freeze({major:16,minor:6,patch:0,preReleaseTag:null});function Jt(t,e){if(!!!t)throw new Error(e)}function Ga(t){return typeof(t==null?void 0:t.then)=="function"}function xn(t){return typeof t=="object"&&t!==null}function Ei(t,e){if(!!!t)throw new Error(e!=null?e:"Unexpected invariant triggered.")}var URe=/\r\n|[\n\r]/g;function hy(t,e){let r=0,i=1;for(let n of t.body.matchAll(URe)){if(typeof n.index=="number"||Ei(!1),n.index>=e)break;r=n.index+n[0].length,i+=1}return{line:i,column:e+1-r}}function AO(t){return j6(t.source,hy(t.source,t.start))}function j6(t,e){let r=t.locationOffset.column-1,i="".padStart(r)+t.body,n=e.line-1,s=t.locationOffset.line-1,a=e.line+s,o=e.line===1?r:0,l=e.column+o,u=`${t.name}:${a}:${l}
|
|
514
514
|
`,c=i.split(/\r\n|[\n\r]/g),p=c[n];if(p.length>120){let d=Math.floor(l/80),f=l%80,h=[];for(let m=0;m<p.length;m+=80)h.push(p.slice(m,m+80));return u+Nne([[`${a} |`,h[0]],...h.slice(1,d+1).map(m=>["|",m]),["|","^".padStart(f)],["|",h[d+1]]])}return u+Nne([[`${a-1} |`,c[n-1]],[`${a} |`,p],["|","^".padStart(l)],[`${a+1} |`,c[n+1]]])}function Nne(t){let e=t.filter(([i,n])=>n!==void 0),r=Math.max(...e.map(([i])=>i.length));return e.map(([i,n])=>i.padStart(r)+(n?" "+n:"")).join(`
|
|
515
515
|
`)}function qRe(t){let e=t[0];return e==null||"kind"in e||"length"in e?{nodes:e,source:t[1],positions:t[2],path:t[3],originalError:t[4],extensions:t[5]}:e}var le=class extends Error{constructor(e,...r){var i,n,s;let{nodes:a,source:o,positions:l,path:u,originalError:c,extensions:p}=qRe(r);super(e),this.name="GraphQLError",this.path=u!=null?u:void 0,this.originalError=c!=null?c:void 0,this.nodes=Ine(Array.isArray(a)?a:a?[a]:void 0);let d=Ine((i=this.nodes)===null||i===void 0?void 0:i.map(h=>h.loc).filter(h=>h!=null));this.source=o!=null?o:d==null||(n=d[0])===null||n===void 0?void 0:n.source,this.positions=l!=null?l:d==null?void 0:d.map(h=>h.start),this.locations=l&&o?l.map(h=>hy(o,h)):d==null?void 0:d.map(h=>hy(h.source,h.start));let f=xn(c==null?void 0:c.extensions)?c==null?void 0:c.extensions:void 0;this.extensions=(s=p!=null?p:f)!==null&&s!==void 0?s:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),c!=null&&c.stack?Object.defineProperty(this,"stack",{value:c.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,le):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(let r of this.nodes)r.loc&&(e+=`
|
|
@@ -1094,7 +1094,7 @@ Try running "stellate pull" first if your service has been created already.`);le
|
|
|
1094
1094
|
|
|
1095
1095
|
-s, --service Name of the service
|
|
1096
1096
|
-b, --browser Automatically open the preview UI with the default browser
|
|
1097
|
-
`);var ms=_e(gn());var bv=_e(gn());var LD=class{async parse(e){return Ji(e,{"--help":Boolean,"-h":"--help","--version":Boolean,"-v":"--version","--json":Boolean})["--help"]?this.help():"stellate@2.7.
|
|
1097
|
+
`);var ms=_e(gn());var bv=_e(gn());var LD=class{async parse(e){return Ji(e,{"--help":Boolean,"-h":"--help","--version":Boolean,"-v":"--version","--json":Boolean})["--help"]?this.help():"stellate@2.7.5"}help(e){if(e)throw new Vn(`
|
|
1098
1098
|
${bv.default.bold.red("!")} ${e}
|
|
1099
1099
|
${LD.help}`);return LD.help}},_1=LD;_1.help=Yi(`
|
|
1100
1100
|
Print current version of Stellate
|
|
@@ -1293,7 +1293,7 @@ ${AN.help}`);return AN.help}},aw=AN;aw.help=Yi(`
|
|
|
1293
1293
|
All further pulls once a ${$s.default.dim("stellate")} config file has been created
|
|
1294
1294
|
${$s.default.dim("$")} stellate pull
|
|
1295
1295
|
|
|
1296
|
-
`);var dn=_e(gn()),D9e=_e(qf()),EJ=_e(require("is-ci"));var ow=_e(gn()),TJ="stellate_cache";function C9e(t,e,r){let i=[],n=t.getDirective(TJ);if(!n)return r;if(!(n.locations.includes(ut.FIELD_DEFINITION)&&n.locations.includes(ut.OBJECT)))return console.warn(ow.default.yellowBright("The @stellate_cache defined by the schema is defined for unexpected locations, expected are 'FIELD_DEFINITION' and 'OBJECT'.")),r;if(!n.args.find(c=>c.name==="maxAge"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'maxAge: Int!' argument.")),r;if(!n.args.find(c=>c.name==="swr"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'swr: Int' argument.")),r;if(!n.args.find(c=>c.name==="scope"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'scope: String' argument.")),r;let u=Object.entries(t.getTypeMap()).map(([c,p])=>c.startsWith("__")?void 0:p).filter(Boolean);for(let c=0;c<u.length;c++){let p=u[c];if(!qe(p))continue;let d=Yx(t,p,TJ);if(d&&d.length){let[h]=d;if(h.scope&&!e.includes(h.scope))throw new Error(`Found scope "${h.scope}" in the schema but not in the stellate config.`);i.push({type:p.name,field:void 0,...h})}let f=Object.values(p.getFields());for(let h=0;h<f.length;h++){let m=f[h],g=Yx(t,m,TJ);if(!g||!g.length)continue;let[b]=g;if(b.scope&&!e.includes(b.scope))throw new Error(`Found scope "${b.scope}" in the schema but not in the stellate config.`);i.push({type:p.name,field:m.name,...b})}}return i.reduce((c,p)=>{let d=Efr(p,c);if(!d)c.push({types:{[p.type]:p.field?[p.field]:!0},maxAge:p.maxAge,swr:p.swr,scope:p.scope});else if(p.field)if(Array.isArray(d.types[p.type]))d.types[p.type].includes(p.field)||d.types[p.type].push(p.field);else if(!d.types[p.type])d.types[p.type]=[p.field];else throw new Error(`Found "${typeof d.types[p.type]}" for "${p.type}" which is unexpected, file an issue at https://github.com/StellateHQ/cli/issues`);else Array.isArray(d.types[p.type])?c.push({types:{[p.type]:p.field?[p.field]:!0},maxAge:p.maxAge,swr:p.swr,scope:p.scope}):d.types[p.type]=!0;return c},r)}function Efr(t,e){let r=e.filter(i=>i.maxAge===t.maxAge);if(r.length)if(t.swr){let i=r.filter(n=>n.swr===t.swr);if(t.scope){let n=i.filter(s=>s.scope===t.scope);return t.field?n.find(s=>Array.isArray(s.types[t.type])):n.find(s=>!s.types[t.type])}else{let n=i.filter(s=>!s.scope);return t.field?n.find(s=>Array.isArray(s.types[t.type])):n.find(s=>!s.types[t.type])}}else if(t.scope){let i=r.filter(n=>n.scope===t.scope&&!n.swr);return t.field?i.find(n=>Array.isArray(n.types[t.type])):i.find(n=>!n.types[t.type])}else return r.find(i=>!i.swr&&!i.scope)}var PN=class{async parse(e){let r=Ji(e,{"--service":String,"--env":String,"--org":String,"--help":Boolean,"--dry":Boolean,"-e":"--env","-o":"--org","-h":"--help","--app":"--service"},!1);if(r["--help"])return this.help();if(r["--env"]&&r["--service"])throw new Error("Please only specify --env or --service.");let i=r._[0];if(i&&i!=="schema")throw new Error("The CLI does not support `stellate push [field]` anymore.\nInstead the entire configuration is now pushed for your environment to match it exactly.\nTo migrate, pull the latest configuration, which may include new fields you have set up in your dashboard, and run `stellate push`.");let n=r._[0]==="schema",s=await Zn(),a=r["--env"],o=await no(a),l=oc(o,r["--service"]),u=r["--dry"];if(a&&!o)throw new Error(`Could not find configuration for environment "${a}".
|
|
1296
|
+
`);var dn=_e(gn()),D9e=_e(qf()),EJ=_e(require("is-ci"));var ow=_e(gn()),TJ="stellate_cache";function C9e(t,e,r){let i=[],n=t.getDirective(TJ);if(!n)return r;if(!(n.locations.includes(ut.FIELD_DEFINITION)&&n.locations.includes(ut.OBJECT)))return console.warn(ow.default.yellowBright("The @stellate_cache defined by the schema is defined for unexpected locations, expected are 'FIELD_DEFINITION' and 'OBJECT'.")),r;if(!n.args.find(c=>c.name==="maxAge"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'maxAge: Int!' argument.")),r;if(!n.args.find(c=>c.name==="swr"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'swr: Int' argument.")),r;if(!n.args.find(c=>c.name==="scope"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'scope: String' argument.")),r;let u=Object.entries(t.getTypeMap()).map(([c,p])=>c.startsWith("__")?void 0:p).filter(Boolean);for(let c=0;c<u.length;c++){let p=u[c];if(!qe(p))continue;let d=Yx(t,p,TJ);if(d&&d.length){let[h]=d;if(h.scope&&!e.includes(h.scope))throw new Error(`Found scope "${h.scope}" in the schema but not in the stellate config.`);i.push({type:p.name,field:void 0,...h})}let f=Object.values(p.getFields());for(let h=0;h<f.length;h++){let m=f[h],g=Yx(t,m,TJ);if(!g||!g.length)continue;let[b]=g;if(b.scope&&!e.includes(b.scope))throw new Error(`Found scope "${b.scope}" in the schema but not in the stellate config.`);i.push({type:p.name,field:m.name,...b})}}return i.reduce((c,p)=>{let d=Efr(p,c);if(!d)c.push({description:"This rule was generated from schema-directives",types:{[p.type]:p.field?[p.field]:!0},maxAge:p.maxAge,swr:p.swr,scope:p.scope});else if(p.field)if(Array.isArray(d.types[p.type]))d.types[p.type].includes(p.field)||d.types[p.type].push(p.field);else if(!d.types[p.type])d.types[p.type]=[p.field];else throw new Error(`Found "${typeof d.types[p.type]}" for "${p.type}" which is unexpected, file an issue at https://github.com/StellateHQ/cli/issues`);else Array.isArray(d.types[p.type])?c.push({description:"This rule was generated from schema-directives",types:{[p.type]:p.field?[p.field]:!0},maxAge:p.maxAge,swr:p.swr,scope:p.scope}):d.types[p.type]=!0;return c},r)}function Efr(t,e){let r=e.filter(i=>i.maxAge===t.maxAge);if(r.length)if(t.swr){let i=r.filter(n=>n.swr===t.swr);if(t.scope){let n=i.filter(s=>s.scope===t.scope);return t.field?n.find(s=>Array.isArray(s.types[t.type])):n.find(s=>!s.types[t.type])}else{let n=i.filter(s=>!s.scope);return t.field?n.find(s=>Array.isArray(s.types[t.type])):n.find(s=>!s.types[t.type])}}else if(t.scope){let i=r.filter(n=>n.scope===t.scope&&!n.swr);return t.field?i.find(n=>Array.isArray(n.types[t.type])):i.find(n=>!n.types[t.type])}else return r.find(i=>!i.swr&&!i.scope)}var PN=class{async parse(e){let r=Ji(e,{"--service":String,"--env":String,"--org":String,"--help":Boolean,"--dry":Boolean,"-e":"--env","-o":"--org","-h":"--help","--app":"--service"},!1);if(r["--help"])return this.help();if(r["--env"]&&r["--service"])throw new Error("Please only specify --env or --service.");let i=r._[0];if(i&&i!=="schema")throw new Error("The CLI does not support `stellate push [field]` anymore.\nInstead the entire configuration is now pushed for your environment to match it exactly.\nTo migrate, pull the latest configuration, which may include new fields you have set up in your dashboard, and run `stellate push`.");let n=r._[0]==="schema",s=await Zn(),a=r["--env"],o=await no(a),l=oc(o,r["--service"]),u=r["--dry"];if(a&&!o)throw new Error(`Could not find configuration for environment "${a}".
|
|
1297
1297
|
Either remove the --env (-e) flag or add configuration for this environment.`);if(!o)throw new Error(`Could not find stellate configuration file.
|
|
1298
1298
|
Try running "stellate pull" first if your service has been created already.`);let c=new En(s);if(u&&n)throw new Error(`We currently don't support combining "--dry" with schema pushes.`);if(Array.isArray(o.rateLimits)){let b=o.rateLimits.map(E=>E.name),T=new Set(b.filter((E,v)=>b.indexOf(E)!==v));if(T.size>0){let E=[...T].join(", ");throw new Error(`You have configured rate limits with the same name: ${E}.
|
|
1299
1299
|
Please make sure to provide a unique name for each rate limit.`)}}let p=await BY(o.schema,o.headers),d=await _f(p,o.headers,o.schemaView);if(Bs(p)){let b=C9e(p,Object.keys(o.scopes||{}),o.rules||[]);o.rules=b}if(!n)try{await this.diffConfig(c,o,l)||process.exit(0)}catch{}if(u)return"";let f=(0,D9e.default)(`Pushing ${n?"schema":"configuration"} for ${dn.default.bold(o.name)}`).start(),{app:h}=await c.query(`
|
|
@@ -1391,7 +1391,7 @@ Try running "stellate pull" first if your service has been created already.`);le
|
|
|
1391
1391
|
value
|
|
1392
1392
|
}
|
|
1393
1393
|
}
|
|
1394
|
-
`,u=await Zn();a=(await new En(u).query(l,{name:"serve-token-"+Date.now(),appName:e})).createAdminApiToken.value,this.writePurgeToken(e,a)}let o=(0,$J.default)();o.use("/",(0,qJ.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,$J.default)();n.use("/",(0,qJ.createProxyMiddleware)({target:i,changeOrigin:!0,headers:{"stellate-cli-serve-port":""+r},logLevel:"silent"})),n.listen(r)}ensureConfig(){qh.default.existsSync(lc)||qh.default.mkdirSync(lc)}getCache(){try{this.ensureConfig();let e=qh.default.readFileSync(RS,"utf-8");return JSON.parse(e)}catch{return{}}}getCacheEntry(e){try{this.ensureConfig();let r=qh.default.readFileSync(RS,"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 jdr(JSON.stringify(e)+"2.7.
|
|
1394
|
+
`,u=await Zn();a=(await new En(u).query(l,{name:"serve-token-"+Date.now(),appName:e})).createAdminApiToken.value,this.writePurgeToken(e,a)}let o=(0,$J.default)();o.use("/",(0,qJ.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,$J.default)();n.use("/",(0,qJ.createProxyMiddleware)({target:i,changeOrigin:!0,headers:{"stellate-cli-serve-port":""+r},logLevel:"silent"})),n.listen(r)}ensureConfig(){qh.default.existsSync(lc)||qh.default.mkdirSync(lc)}getCache(){try{this.ensureConfig();let e=qh.default.readFileSync(RS,"utf-8");return JSON.parse(e)}catch{return{}}}getCacheEntry(e){try{this.ensureConfig();let r=qh.default.readFileSync(RS,"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 jdr(JSON.stringify(e)+"2.7.5")}writePurgeToken(e,r){let i=this.getCache();i[e]={...i[e],purgeToken:r},qh.default.writeFileSync(RS,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},qh.default.writeFileSync(RS,JSON.stringify(n)),n[e]}},Sw=KJ;Sw.help=Yi(`
|
|
1395
1395
|
(BETA) - Use a local backend with Stellate\u2019s GraphQL Edge Cache.
|
|
1396
1396
|
|
|
1397
1397
|
${Ov.default.bold("Usage")}
|
package/dist/index.d.ts
CHANGED
|
@@ -158,13 +158,10 @@ declare const inputSchema: z.ZodObject<{
|
|
|
158
158
|
}>>>;
|
|
159
159
|
partialQueryCaching: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
160
160
|
enabled: z.ZodBoolean;
|
|
161
|
-
includeOperations: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
162
161
|
}, "strip", z.ZodTypeAny, {
|
|
163
162
|
enabled: boolean;
|
|
164
|
-
includeOperations?: string[] | null | undefined;
|
|
165
163
|
}, {
|
|
166
164
|
enabled: boolean;
|
|
167
|
-
includeOperations?: string[] | null | undefined;
|
|
168
165
|
}>>>;
|
|
169
166
|
ignoreOriginCacheControl: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
170
167
|
queryDepthLimit: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -805,7 +802,6 @@ declare const inputSchema: z.ZodObject<{
|
|
|
805
802
|
} | null | undefined;
|
|
806
803
|
partialQueryCaching?: {
|
|
807
804
|
enabled: boolean;
|
|
808
|
-
includeOperations?: string[] | null | undefined;
|
|
809
805
|
} | null | undefined;
|
|
810
806
|
ignoreOriginCacheControl?: boolean | null | undefined;
|
|
811
807
|
queryDepthLimit?: number | null | undefined;
|
|
@@ -990,7 +986,6 @@ declare const inputSchema: z.ZodObject<{
|
|
|
990
986
|
} | null | undefined;
|
|
991
987
|
partialQueryCaching?: {
|
|
992
988
|
enabled: boolean;
|
|
993
|
-
includeOperations?: string[] | null | undefined;
|
|
994
989
|
} | null | undefined;
|
|
995
990
|
ignoreOriginCacheControl?: boolean | null | undefined;
|
|
996
991
|
queryDepthLimit?: number | null | undefined;
|
|
@@ -1221,13 +1216,10 @@ declare const environmentsSchema: z__default.ZodRecord<z__default.ZodString, z__
|
|
|
1221
1216
|
}>>>;
|
|
1222
1217
|
readonly partialQueryCaching: z__default.ZodNullable<z__default.ZodOptional<z__default.ZodObject<{
|
|
1223
1218
|
enabled: z__default.ZodBoolean;
|
|
1224
|
-
includeOperations: z__default.ZodNullable<z__default.ZodOptional<z__default.ZodArray<z__default.ZodString, "many">>>;
|
|
1225
1219
|
}, "strip", z__default.ZodTypeAny, {
|
|
1226
1220
|
enabled: boolean;
|
|
1227
|
-
includeOperations?: string[] | null | undefined;
|
|
1228
1221
|
}, {
|
|
1229
1222
|
enabled: boolean;
|
|
1230
|
-
includeOperations?: string[] | null | undefined;
|
|
1231
1223
|
}>>>;
|
|
1232
1224
|
readonly rateLimit: z__default.ZodNullable<z__default.ZodOptional<z__default.ZodObject<{
|
|
1233
1225
|
name: z__default.ZodString;
|
|
@@ -1595,7 +1587,6 @@ declare const environmentsSchema: z__default.ZodRecord<z__default.ZodString, z__
|
|
|
1595
1587
|
} | null | undefined;
|
|
1596
1588
|
readonly partialQueryCaching?: {
|
|
1597
1589
|
enabled: boolean;
|
|
1598
|
-
includeOperations?: string[] | null | undefined;
|
|
1599
1590
|
} | null | undefined;
|
|
1600
1591
|
readonly rateLimit?: {
|
|
1601
1592
|
name: string;
|
|
@@ -1701,7 +1692,6 @@ declare const environmentsSchema: z__default.ZodRecord<z__default.ZodString, z__
|
|
|
1701
1692
|
} | null | undefined;
|
|
1702
1693
|
readonly partialQueryCaching?: {
|
|
1703
1694
|
enabled: boolean;
|
|
1704
|
-
includeOperations?: string[] | null | undefined;
|
|
1705
1695
|
} | null | undefined;
|
|
1706
1696
|
readonly rateLimit?: {
|
|
1707
1697
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stellate",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.5",
|
|
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.29.
|
|
47
|
+
"@gcdn/configuration": "1.29.3"
|
|
48
48
|
},
|
|
49
49
|
"bin": {
|
|
50
50
|
"stellate": "dist/bin.js",
|