@redocly/openapi-docs 3.25.0-next.2 → 3.25.0-next.4
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/{redocly-openapi-docs.min.AiChatProvider-C_KLy-F0.js → redocly-openapi-docs.min.AiChatProvider-BtZYXzQL.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiChatSqliteDBStorage-xPx3J3uK.js → redocly-openapi-docs.min.AiChatSqliteDBStorage-CMWIhurV.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiPanel-BmK852q6.js → redocly-openapi-docs.min.AiPanel-CzVBo_SJ.js} +1 -1
- package/dist/{redocly-openapi-docs.min.FileWatcher-BtXjqGQC.js → redocly-openapi-docs.min.FileWatcher-DjTW24VD.js} +1 -1
- package/dist/{redocly-openapi-docs.min.SemanticSearchService-gLmwyYO3.js → redocly-openapi-docs.min.SemanticSearchService-BdbJAsUF.js} +1 -1
- package/dist/{redocly-openapi-docs.min.SqliteDBStorage-DfF4kq1F.js → redocly-openapi-docs.min.SqliteDBStorage-DicEB6xf.js} +1 -1
- package/dist/{redocly-openapi-docs.min.TauriFileSystemAdapter-DZLjNpl_.js → redocly-openapi-docs.min.TauriFileSystemAdapter-Bzf6nZVE.js} +1 -1
- package/dist/{redocly-openapi-docs.min.TauriRootStorage-DMQv9g_J.js → redocly-openapi-docs.min.TauriRootStorage-Cg1lmYY7.js} +1 -1
- package/dist/{redocly-openapi-docs.min.ai-chat-mappers-O-bg124u.js → redocly-openapi-docs.min.ai-chat-mappers-BfCwakK5.js} +1 -1
- package/dist/{redocly-openapi-docs.min.external-resolver-D89x3qoA.js → redocly-openapi-docs.min.external-resolver-DftxHgbt.js} +1 -1
- package/dist/{redocly-openapi-docs.min.index-DbxjaOoh.js → redocly-openapi-docs.min.index-BXAn8eur.js} +11 -11
- package/dist/{redocly-openapi-docs.min.index-BBNK1d3n.js → redocly-openapi-docs.min.index-BnxwvVhR.js} +1 -1
- package/dist/{redocly-openapi-docs.min.index-D4_45rLR.js → redocly-openapi-docs.min.index-CHKNddXa.js} +1 -1
- package/dist/redocly-openapi-docs.min.index-U6ORLz-U.js +1 -0
- package/dist/redocly-openapi-docs.min.js +1 -1
- package/dist/{redocly-openapi-docs.min.lint-graphql-1y6KKl09.js → redocly-openapi-docs.min.lint-graphql-BLIlXit9.js} +1 -1
- package/dist/redocly-openapi-docs.min.lint-jyJiMT1p.js +174 -0
- package/dist/{redocly-openapi-docs.min.respect-run-BdIceoa0.js → redocly-openapi-docs.min.respect-run-CTD2qNkS.js} +1 -1
- package/dist/{redocly-openapi-docs.min.standalone-crUOAFz-.js → redocly-openapi-docs.min.standalone-CS00-kVE.js} +709 -600
- package/dist/{redocly-openapi-docs.min.tauri-path-BjTOYabX.js → redocly-openapi-docs.min.tauri-path-Dw7ZXd_2.js} +1 -1
- package/dist/{redocly-openapi-docs.min.useAiChatQueries-Rfa850wl.js → redocly-openapi-docs.min.useAiChatQueries-BH1oro3k.js} +2 -2
- package/package.json +4 -4
- package/dist/redocly-openapi-docs.min.index-DQHVHxbB.js +0 -1
- package/dist/redocly-openapi-docs.min.lint-DLjLNlT2.js +0 -181
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as c}from"./redocly-openapi-docs.min.SemanticSearchService-
|
|
1
|
+
import{g as c}from"./redocly-openapi-docs.min.SemanticSearchService-BdbJAsUF.js";import{S as u,e as S,a as m,b as h}from"./redocly-openapi-docs.min.SemanticSearchService-BdbJAsUF.js";import{r}from"./redocly-openapi-docs.min.standalone-CS00-kVE.js";function f(){const[s,a]=r.useState(!1),[n,t]=r.useState(null);return{search:r.useCallback(async(o,i=10)=>{a(!0),t(null);try{return await c().search(o,i)}catch(e){const l=e instanceof Error?e:new Error(String(e));return t(l),[]}finally{a(!1)}},[]),isSearching:s,error:n}}export{u as SemanticSearchService,S as extractAllDocuments,m as extractApiDocuments,h as extractCollectionDocuments,c as getSemanticSearchService,f as useSemanticSearch};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as n}from"./redocly-openapi-docs.min.index-
|
|
1
|
+
import{z as n}from"./redocly-openapi-docs.min.index-BXAn8eur.js";async function t(o={}){return typeof o=="object"&&Object.freeze(o),await n("plugin:dialog|open",{options:o})}export{t as open};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as T,l as u,aB as E,aC as I,aD as k,aE as w,aF as A,aG as C,aH as v,aI as j,aJ as b,aK as q}from"./redocly-openapi-docs.min.standalone-CS00-kVE.js";import{aL as J,aM as Y,aN as W,aO as X,aP as H,aQ as K,aR as Q,aS as Z,aT as ee,aU as se,aV as ae,aW as te,aX as ne,aY as re,aZ as oe,a_ as ie,a$ as ce,b0 as le,b1 as me,b2 as ue,b3 as pe,b4 as ye,b5 as fe,b6 as de,b7 as ge,b8 as he,b9 as ve,ba as Ee,bb as be,bc as xe,bd as Se,be as Re,bf as Oe,bg as Te,bh as Ie,bi as ke,bj as we,bk as Ae,bl as Ce,bm as je,bn as De,bo as Pe}from"./redocly-openapi-docs.min.standalone-CS00-kVE.js";import{g as D,t as P,A as Ne,c as x,l as S,S as Fe,R as _e,C as Le}from"./redocly-openapi-docs.min.lint-jyJiMT1p.js";import{a as $e,b as ze,d as Ge,e as Ue,f as Ve,h as Me,i as Be,j as qe,k as Je,m as Ye,n as We,o as Xe,p as He,q as Ke,r as Qe,s as Ze,u as es,v as ss,w as as,x as ts,y as ns,z as rs,B as os,s as is,D as cs}from"./redocly-openapi-docs.min.lint-jyJiMT1p.js";function ls(e){return(T.extname(e)===".yaml"||T.extname(e)===".yml")&&!1}function ms(e){return u(e)&&!E(e)}async function us(e){return new Promise(a=>setTimeout(a,e))}const R="type",N=["api-description","api-operation","data-schema"];function F(e,a){const{ctx:s}=D("EntityFileDefault",a),{ctx:t,discriminatorResolver:n}=D("EntityFile",e);return{entityTypes:{...s,...t,EntityFileArray:{properties:{},items:r=>{if(u(r)){const c=r[R];if(!c)return"Entity";const i=n?.(r,c);if(i&&typeof i=="string")return i}return"Entity"}}},discriminatorResolver:n}}function o(e,a){if(I(a.parent))return;const s=a.key.toString(),t=e.counts??={};t[s]=(t[s]??0)+1}function O(e){for(const n of Object.values(e))n.items&&(n.total=n.items.size);const{xExtensions:a}=e,s=a.counts??{},t=Object.keys(s).sort();a.total=t.length,a.counts=Object.fromEntries(t.map(n=>[n,s[n]]))}const ps=e=>({SpecExtension:{enter(a,s){o(e.xExtensions,s)}},XCodeSampleList:{enter(a,s){o(e.xExtensions,s)}},ExamplesMap:{enter(a,s){s.key.toString()==="x-examples"&&o(e.xExtensions,s)}},EnumDescriptions:{enter(a,s){o(e.xExtensions,s)}},TagGroups:{enter(a,s){o(e.xExtensions,s)}},Logo:{enter(a,s){o(e.xExtensions,s)}},XServerList:{enter(a,s){o(e.xExtensions,s)}},XUsePkce:{enter(a,s){o(e.xExtensions,s)}},Operation:{enter(a,s){s.key.toString()==="x-query"&&o(e.xExtensions,s)}},ExternalDocs:{leave(){e.externalDocs.total++}},ref:{enter(a){e.refs.items.add(a.$ref)}},Tag:{leave(a){e.tags.items.add(a.name)}},Link:{leave(a){e.links.items.add(a.operationId)}},WebhooksMap:{enter(a,s){s.key.toString()==="x-webhooks"&&o(e.xExtensions,s)},Operation:{leave(a){if(e.webhooks.total++,a.tags)for(const s of a.tags)e.tags.items.add(s)}}},Paths:{PathItem:{leave(){e.pathItems.total++},Operation:{leave(a){if(e.operations.total++,a.tags)for(const s of a.tags)e.tags.items.add(s)}},Parameter:{leave(a){e.parameters.items.add(a.name)}}}},NamedSchemas:{Schema:{leave(){e.schemas.total++}}},Root:{leave(){O(e)}}}),ys=e=>({SpecExtension:{enter(a,s){o(e.xExtensions,s)}},ExternalDocs:{leave(){e.externalDocs.total++}},ref:{enter(a){e.refs.items.add(a.$ref)}},Tag:{leave(a){e.tags.items.add(a.name)}},ChannelMap:{Channel:{leave(){e.channels.total++},Operation:{leave(a){if(e.operations.total++,a.tags)for(const s of a.tags)e.tags.items.add(s)}},Parameter:{leave(a,{key:s}){e.parameters.items.add(s.toString())}}}},NamedSchemas:{Schema:{leave(){e.schemas.total++}}},Root:{leave(){O(e)}}}),fs=e=>({SpecExtension:{enter(a,s){o(e.xExtensions,s)}},ExternalDocs:{leave(){e.externalDocs.total++}},ref:{enter(a){e.refs.items.add(a.$ref)}},Tag:{leave(a){e.tags.items.add(a.name)}},NamedChannels:{Channel:{leave(){e.channels.total++},Parameter:{leave(a,{key:s}){e.parameters.items.add(s.toString())}}}},NamedOperations:{Operation:{leave(a){if(e.operations.total++,a.tags)for(const s of a.tags)e.tags.items.add(s)}}},NamedSchemas:{Schema:{leave(){e.schemas.total++}}},Root:{leave(){O(e)}}}),ds=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,_=2,L=150,gs=()=>({any(e,{report:a,location:s}){if(u(e)&&"key"in e){const t=e.key;if(typeof t!="string"){a({message:"Entity `key` must be a string.",location:s.child(["key"])});return}t.length<_&&a({message:`Entity 'key' must be at least ${_} characters long.`,location:s.child(["key"])}),t.length>L&&a({message:`Entity 'key' must not exceed ${L} characters.`,location:s.child(["key"])}),ds.test(t)||a({message:"Entity `key` must contain only lowercase letters, numbers, and hyphens, and cannot start or end with a hyphen.",location:s.child(["key"])})}}});function $(e,a){const s=a.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")+e;return Object.values(P).includes(s)?s:e}function hs(e,a){const s={};for(const[t,n]of Object.entries(a))if(z(t,n)){if(n.severity==="off")continue;s[t]={...xs(e,t,n)}}else s[t]=n;return s}function vs(e){const a={},s={};for(const[t,n]of Object.entries(e))if(z(t,n)){const r=n;bs(r)?a[t]=r:s[t]=r}else s[t]=n;return{entityRules:a,apiRules:s}}function Es(e,a,s){if(!u(s.parsed)||!u(s.parsed.components))return null;const t=s.parsed.components,n="schemas"in t?t.schemas:void 0;if(!n||!(e in n))return null;const r=n[e];try{const c=JSON.parse(a);if(k(r,c))return r}catch{return null}return null}function z(e,a){return e.startsWith("rule/")&&u(a)}function bs(e){return Object.values(P).some(a=>e.subject.type===a)}function xs(e,a,s){const t=$(s.subject.type,e),n=s.where?.map(r=>({...r,subject:{...r.subject,type:$(r.subject.type,e)}}));return{assertionId:a,subject:{...s.subject,type:t},assertions:s.assertions,...n&&{where:n},...s.message&&{message:s.message},...s.severity&&{severity:s.severity}}}async function G(e){const{document:a,entitySchema:s,entityDefaultSchema:t,severity:n,externalRefResolver:r=new v,assertionConfig:c={}}=e,i={problems:[],specVersion:"entity",visitorsData:{}},{entityTypes:p,discriminatorResolver:y}=F(s,t),l=w(p);let m=l.Entity;if(Array.isArray(a.parsed))m=l.EntityFileArray;else if(u(a.parsed)){const g=a.parsed[R];if(!g)m=l.Entity;else{const h=y?.(a.parsed,g);h&&typeof h=="string"&&l[h]&&(m=l[h])}}const f=Ne(c),d=Array.isArray(f)?f.map(g=>({severity:n||"error",ruleId:"entity assertions",visitor:g})):[{severity:n||"error",ruleId:"entity assertions",visitor:f}],V=[{severity:n||"error",ruleId:"entity struct",visitor:Fe()},{severity:n||"error",ruleId:"entity no-unresolved-refs",visitor:q()},{severity:n||"error",ruleId:"entity key-valid",visitor:gs()},...d],M=A(V,l),B=await C({rootDocument:a,rootType:m,externalRefResolver:r});return j({document:a,rootType:m,normalizedVisitors:M,resolvedRefMap:B,ctx:i}),i.problems}async function Ss(e,a,s){if(!a.rules)throw new Error(`Scorecard level "${a.name}" has no rules defined.`);const t=new v,n=b(JSON.stringify(e,null,2),"entity"),r=n.parsed[R],c=hs(r||"unknown",a.rules),{entityRules:i,apiRules:p}=vs(c),y=await G({document:n,entitySchema:Le,entityDefaultSchema:_e,externalRefResolver:t,assertionConfig:i});if(N.includes(e.type)){if(Object.keys(p).length===0)return y;if(!s)throw new Error(`Document is required for entity type "${e.type}". Provide the source API document to lint API rules.`);if(e.type==="data-schema"&&e.metadata?.schema){Object.values(p).forEach(d=>{if(u(d)&&u(d.subject)&&d.subject.type!=="Schema")throw new Error(`API rules for "data-schema" entity must target Schema subject, but found "${d.subject.type}".`)});const m=Es(e.title,e.metadata.schema,s);if(!m)throw new Error(`Schema "${e.title}" not found in the document. Ensure the schema exists in components.schemas.`);const f=await U({schema:m,schemaKey:e.title,config:await x({rules:p}),specType:e.metadata.specType,sourceDocument:s,externalRefResolver:t});return[...y,...f]}const l=await S({document:s,externalRefResolver:t,config:await x({rules:p})});return[...y,...l]}else if(!E(p))throw new Error(`API rules are not supported for entity type "${e.type}". Only ${N.join(", ")} support API rules.`);return y}async function U(e){const{schema:a,schemaKey:s,config:t,sourceDocument:n,specType:r,externalRefResolver:c=new v(t.resolve)}=e,i=n.parsed,p=i[r],y=i.info,l=b(JSON.stringify({[r]:p,info:y,components:{schemas:{[s]:a}}},null,2),n?.source.absoluteRef||`schema:${s}`);return(await S({document:l,config:t,externalRefResolver:c})).filter(m=>m.location.some(f=>f.pointer?.includes(`/components/schemas/${s}`)))}class Rs extends Error{}export{J as Arazzo1Types,Y as Arazzo1_1Types,W as AsyncApi2Types,X as AsyncApi3Types,v as BaseResolver,H as CONFIG_BUNDLER_VISITOR_ID,K as CONFIG_FILE_NAME,Q as Config,$e as ConfigTypes,ze as ConfigValidationError,Z as DEFAULT_CONFIG,ee as DEFAULT_PROJECT_PLUGIN_PATHS,Rs as HandledError,se as IGNORE_BANNER,ae as IGNORE_FILE,te as Oas2Types,ne as Oas3Types,re as Oas3_1Types,oe as Oas3_2Types,ie as OpenRpcTypes,ce as Overlay1Types,le as PLUGINS_COLLECTOR_VISITOR_ID,me as ResolveError,ue as Source,ys as StatsAsync2,fs as StatsAsync3,ps as StatsOAS,pe as YamlParseError,Ge as bundle,ye as bundleDocument,Ue as bundleFromString,Ve as clearPluginsCache,x as createConfig,Me as createConfigTypes,F as createEntityTypes,k as dequal,fe as detectSpec,ls as doesYamlFileExist,de as escapePointerFragment,Be as findConfig,qe as formatProblems,Je as getAstNodeByPointer,Ye as getCodeframe,ge as getDir,We as getLineColLocation,he as getMajorSpecVersion,Xe as getPluginCacheVersion,He as getTotals,ve as getTypes,Ee as isAbsoluteUrl,be as isBrowser,E as isEmptyObject,xe as isGraphqlRef,Se as isMappingRef,Ke as isNotEmptyArray,ms as isNotEmptyObject,u as isPlainObject,I as isRef,Re as isString,Oe as isSupportedExtension,Te as isTruthy,Qe as keysOf,Ze as lint,es as lintConfig,S as lintDocument,G as lintEntityFile,Ss as lintEntityWithScorecardLevel,ss as lintFromString,U as lintSchema,as as loadConfig,ts as loadIgnoreConfig,ns as logger,b as makeDocumentFromString,Ie as mapTypeToComponent,w as normalizeTypes,A as normalizeVisitors,ke as parseYaml,us as pause,rs as pluralize,we as readFileFromUrl,Ae as regexFromString,C as resolveDocument,Ce as resolvePath,os as resolvePlugins,je as slash,De as stringifyYaml,Pe as unescapePointerFragment,is as validate,j as walkDocument,cs as xmlEscape};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bO as a,bP as s,bQ as e,bR as t,bS as i,bT as r,bU as b}from"./redocly-openapi-docs.min.standalone-
|
|
1
|
+
import{bO as a,bP as s,bQ as e,bR as t,bS as i,bT as r,bU as b}from"./redocly-openapi-docs.min.standalone-CS00-kVE.js";export{a as hydrate,s as init,e as revision,t as setParameterValue,i as setSecurityDetails,r as setSecurityDetailsVariants,b as version};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{bN as B}from"./redocly-openapi-docs.min.standalone-
|
|
1
|
+
import{bN as B}from"./redocly-openapi-docs.min.standalone-CS00-kVE.js";import{G as y,T as C,F as x,H as I,I as M,J as K,K as A,L as U,M as V,N as a,O as k,P as G,Q as $,U as R,V as Y,W as j}from"./redocly-openapi-docs.min.lint-jyJiMT1p.js";function u(s,t,e){return new y(`Syntax Error: ${e}`,{source:s,positions:[t]})}var n;(function(s){s.SOF="<SOF>",s.EOF="<EOF>",s.BANG="!",s.DOLLAR="$",s.AMP="&",s.PAREN_L="(",s.PAREN_R=")",s.DOT=".",s.SPREAD="...",s.COLON=":",s.EQUALS="=",s.AT="@",s.BRACKET_L="[",s.BRACKET_R="]",s.BRACE_L="{",s.PIPE="|",s.BRACE_R="}",s.NAME="Name",s.INT="Int",s.FLOAT="Float",s.STRING="String",s.BLOCK_STRING="BlockString",s.COMMENT="Comment"})(n||(n={}));class q{constructor(t){const e=new C(n.SOF,0,0,0,0);this.source=t,this.lastToken=e,this.token=e,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let t=this.token;if(t.kind!==n.EOF)do if(t.next)t=t.next;else{const e=Q(this,t.end);t.next=e,e.prev=t,t=e}while(t.kind===n.COMMENT);return t}}function z(s){return s===n.BANG||s===n.DOLLAR||s===n.AMP||s===n.PAREN_L||s===n.PAREN_R||s===n.DOT||s===n.SPREAD||s===n.COLON||s===n.EQUALS||s===n.AT||s===n.BRACKET_L||s===n.BRACKET_R||s===n.BRACE_L||s===n.PIPE||s===n.BRACE_R}function m(s){return s>=0&&s<=55295||s>=57344&&s<=1114111}function N(s,t){return L(s.charCodeAt(t))&&g(s.charCodeAt(t+1))}function L(s){return s>=55296&&s<=56319}function g(s){return s>=56320&&s<=57343}function E(s,t){const e=s.source.body.codePointAt(t);if(e===void 0)return n.EOF;if(e>=32&&e<=126){const r=String.fromCodePoint(e);return r==='"'?`'"'`:`"${r}"`}return"U+"+e.toString(16).toUpperCase().padStart(4,"0")}function p(s,t,e,r,i){const o=s.line,c=1+e-s.lineStart;return new C(t,e,r,o,c,i)}function Q(s,t){const e=s.source.body,r=e.length;let i=t;for(;i<r;){const o=e.charCodeAt(i);switch(o){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++s.line,s.lineStart=i;continue;case 13:e.charCodeAt(i+1)===10?i+=2:++i,++s.line,s.lineStart=i;continue;case 35:return X(s,i);case 33:return p(s,n.BANG,i,i+1);case 36:return p(s,n.DOLLAR,i,i+1);case 38:return p(s,n.AMP,i,i+1);case 40:return p(s,n.PAREN_L,i,i+1);case 41:return p(s,n.PAREN_R,i,i+1);case 46:if(e.charCodeAt(i+1)===46&&e.charCodeAt(i+2)===46)return p(s,n.SPREAD,i,i+3);break;case 58:return p(s,n.COLON,i,i+1);case 61:return p(s,n.EQUALS,i,i+1);case 64:return p(s,n.AT,i,i+1);case 91:return p(s,n.BRACKET_L,i,i+1);case 93:return p(s,n.BRACKET_R,i,i+1);case 123:return p(s,n.BRACE_L,i,i+1);case 124:return p(s,n.PIPE,i,i+1);case 125:return p(s,n.BRACE_R,i,i+1);case 34:return e.charCodeAt(i+1)===34&&e.charCodeAt(i+2)===34?te(s,i):H(s,i)}if(x(o)||o===45)return J(s,i,o);if(I(o))return ie(s,i);throw u(s.source,i,o===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:m(o)||N(e,i)?`Unexpected character: ${E(s,i)}.`:`Invalid character: ${E(s,i)}.`)}return p(s,n.EOF,r,r)}function X(s,t){const e=s.source.body,r=e.length;let i=t+1;for(;i<r;){const o=e.charCodeAt(i);if(o===10||o===13)break;if(m(o))++i;else if(N(e,i))i+=2;else break}return p(s,n.COMMENT,t,i,e.slice(t+1,i))}function J(s,t,e){const r=s.source.body;let i=t,o=e,c=!1;if(o===45&&(o=r.charCodeAt(++i)),o===48){if(o=r.charCodeAt(++i),x(o))throw u(s.source,i,`Invalid number, unexpected digit after 0: ${E(s,i)}.`)}else i=v(s,i,o),o=r.charCodeAt(i);if(o===46&&(c=!0,o=r.charCodeAt(++i),i=v(s,i,o),o=r.charCodeAt(i)),(o===69||o===101)&&(c=!0,o=r.charCodeAt(++i),(o===43||o===45)&&(o=r.charCodeAt(++i)),i=v(s,i,o),o=r.charCodeAt(i)),o===46||I(o))throw u(s.source,i,`Invalid number, expected digit but got: ${E(s,i)}.`);return p(s,c?n.FLOAT:n.INT,t,i,r.slice(t,i))}function v(s,t,e){if(!x(e))throw u(s.source,t,`Invalid number, expected digit but got: ${E(s,t)}.`);const r=s.source.body;let i=t+1;for(;x(r.charCodeAt(i));)++i;return i}function H(s,t){const e=s.source.body,r=e.length;let i=t+1,o=i,c="";for(;i<r;){const h=e.charCodeAt(i);if(h===34)return c+=e.slice(o,i),p(s,n.STRING,t,i+1,c);if(h===92){c+=e.slice(o,i);const d=e.charCodeAt(i+1)===117?e.charCodeAt(i+2)===123?W(s,i):Z(s,i):ee(s,i);c+=d.value,i+=d.size,o=i;continue}if(h===10||h===13)break;if(m(h))++i;else if(N(e,i))i+=2;else throw u(s.source,i,`Invalid character within String: ${E(s,i)}.`)}throw u(s.source,i,"Unterminated string.")}function W(s,t){const e=s.source.body;let r=0,i=3;for(;i<12;){const o=e.charCodeAt(t+i++);if(o===125){if(i<5||!m(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|T(o),r<0)break}throw u(s.source,t,`Invalid Unicode escape sequence: "${e.slice(t,t+i)}".`)}function Z(s,t){const e=s.source.body,r=S(e,t+2);if(m(r))return{value:String.fromCodePoint(r),size:6};if(L(r)&&e.charCodeAt(t+6)===92&&e.charCodeAt(t+7)===117){const i=S(e,t+8);if(g(i))return{value:String.fromCodePoint(r,i),size:12}}throw u(s.source,t,`Invalid Unicode escape sequence: "${e.slice(t,t+6)}".`)}function S(s,t){return T(s.charCodeAt(t))<<12|T(s.charCodeAt(t+1))<<8|T(s.charCodeAt(t+2))<<4|T(s.charCodeAt(t+3))}function T(s){return s>=48&&s<=57?s-48:s>=65&&s<=70?s-55:s>=97&&s<=102?s-87:-1}function ee(s,t){const e=s.source.body;switch(e.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:`
|
|
2
2
|
`,size:2};case 114:return{value:"\r",size:2};case 116:return{value:" ",size:2}}throw u(s.source,t,`Invalid character escape sequence: "${e.slice(t,t+2)}".`)}function te(s,t){const e=s.source.body,r=e.length;let i=s.lineStart,o=t+3,c=o,h="";const d=[];for(;o<r;){const f=e.charCodeAt(o);if(f===34&&e.charCodeAt(o+1)===34&&e.charCodeAt(o+2)===34){h+=e.slice(c,o),d.push(h);const l=p(s,n.BLOCK_STRING,t,o+3,M(d).join(`
|
|
3
3
|
`));return s.line+=d.length-1,s.lineStart=i,l}if(f===92&&e.charCodeAt(o+1)===34&&e.charCodeAt(o+2)===34&&e.charCodeAt(o+3)===34){h+=e.slice(c,o),c=o+1,o+=4;continue}if(f===10||f===13){h+=e.slice(c,o),d.push(h),f===13&&e.charCodeAt(o+1)===10?o+=2:++o,h="",c=o,i=o;continue}if(m(f))++o;else if(N(e,o))o+=2;else throw u(s.source,o,`Invalid character within String: ${E(s,o)}.`)}throw u(s.source,o,"Unterminated string.")}function ie(s,t){const e=s.source.body,r=e.length;let i=t+1;for(;i<r;){const o=e.charCodeAt(i);if(K(o))++i;else break}return p(s,n.NAME,t,i,e.slice(t,i))}class D{constructor(t,e="GraphQL request",r={line:1,column:1}){typeof t=="string"||A(!1,`Body must be a string. Received: ${U(t)}.`),this.body=t,this.name=e,this.locationOffset=r,this.locationOffset.line>0||A(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||A(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function se(s){return V(s,D)}function re(s,t){const e=new ne(s,t),r=e.parseDocument();return Object.defineProperty(r,"tokenCount",{enumerable:!1,value:e.tokenCount}),r}class ne{constructor(t,e={}){const{lexer:r,...i}=e;if(r)this._lexer=r;else{const o=se(t)?t:new D(t);this._lexer=new q(o)}this._options=i,this._tokenCounter=0}get tokenCount(){return this._tokenCounter}parseName(){const t=this.expectToken(n.NAME);return this.node(t,{kind:a.NAME,value:t.value})}parseDocument(){return this.node(this._lexer.token,{kind:a.DOCUMENT,definitions:this.many(n.SOF,this.parseDefinition,n.EOF)})}parseDefinition(){if(this.peek(n.BRACE_L))return this.parseOperationDefinition();const t=this.peekDescription(),e=t?this._lexer.lookahead():this._lexer.token;if(t&&e.kind===n.BRACE_L)throw u(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are not supported on shorthand queries.");if(e.kind===n.NAME){switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}switch(e.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition()}if(t)throw u(this._lexer.source,this._lexer.token.start,"Unexpected description, only GraphQL definitions support descriptions.");if(e.value==="extend")return this.parseTypeSystemExtension()}throw this.unexpected(e)}parseOperationDefinition(){const t=this._lexer.token;if(this.peek(n.BRACE_L))return this.node(t,{kind:a.OPERATION_DEFINITION,operation:k.QUERY,description:void 0,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const e=this.parseDescription(),r=this.parseOperationType();let i;return this.peek(n.NAME)&&(i=this.parseName()),this.node(t,{kind:a.OPERATION_DEFINITION,operation:r,description:e,name:i,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const t=this.expectToken(n.NAME);switch(t.value){case"query":return k.QUERY;case"mutation":return k.MUTATION;case"subscription":return k.SUBSCRIPTION}throw this.unexpected(t)}parseVariableDefinitions(){return this.optionalMany(n.PAREN_L,this.parseVariableDefinition,n.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:a.VARIABLE_DEFINITION,description:this.parseDescription(),variable:this.parseVariable(),type:(this.expectToken(n.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(n.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const t=this._lexer.token;return this.expectToken(n.DOLLAR),this.node(t,{kind:a.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:a.SELECTION_SET,selections:this.many(n.BRACE_L,this.parseSelection,n.BRACE_R)})}parseSelection(){return this.peek(n.SPREAD)?this.parseFragment():this.parseField()}parseField(){const t=this._lexer.token,e=this.parseName();let r,i;return this.expectOptionalToken(n.COLON)?(r=e,i=this.parseName()):i=e,this.node(t,{kind:a.FIELD,alias:r,name:i,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(n.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(t){const e=t?this.parseConstArgument:this.parseArgument;return this.optionalMany(n.PAREN_L,e,n.PAREN_R)}parseArgument(t=!1){const e=this._lexer.token,r=this.parseName();return this.expectToken(n.COLON),this.node(e,{kind:a.ARGUMENT,name:r,value:this.parseValueLiteral(t)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const t=this._lexer.token;this.expectToken(n.SPREAD);const e=this.expectOptionalKeyword("on");return!e&&this.peek(n.NAME)?this.node(t,{kind:a.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(t,{kind:a.INLINE_FRAGMENT,typeCondition:e?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const t=this._lexer.token,e=this.parseDescription();return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(t,{kind:a.FRAGMENT_DEFINITION,description:e,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(t,{kind:a.FRAGMENT_DEFINITION,description:e,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()}parseValueLiteral(t){const e=this._lexer.token;switch(e.kind){case n.BRACKET_L:return this.parseList(t);case n.BRACE_L:return this.parseObject(t);case n.INT:return this.advanceLexer(),this.node(e,{kind:a.INT,value:e.value});case n.FLOAT:return this.advanceLexer(),this.node(e,{kind:a.FLOAT,value:e.value});case n.STRING:case n.BLOCK_STRING:return this.parseStringLiteral();case n.NAME:switch(this.advanceLexer(),e.value){case"true":return this.node(e,{kind:a.BOOLEAN,value:!0});case"false":return this.node(e,{kind:a.BOOLEAN,value:!1});case"null":return this.node(e,{kind:a.NULL});default:return this.node(e,{kind:a.ENUM,value:e.value})}case n.DOLLAR:if(t)if(this.expectToken(n.DOLLAR),this._lexer.token.kind===n.NAME){const r=this._lexer.token.value;throw u(this._lexer.source,e.start,`Unexpected variable "$${r}" in constant value.`)}else throw this.unexpected(e);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const t=this._lexer.token;return this.advanceLexer(),this.node(t,{kind:a.STRING,value:t.value,block:t.kind===n.BLOCK_STRING})}parseList(t){const e=()=>this.parseValueLiteral(t);return this.node(this._lexer.token,{kind:a.LIST,values:this.any(n.BRACKET_L,e,n.BRACKET_R)})}parseObject(t){const e=()=>this.parseObjectField(t);return this.node(this._lexer.token,{kind:a.OBJECT,fields:this.any(n.BRACE_L,e,n.BRACE_R)})}parseObjectField(t){const e=this._lexer.token,r=this.parseName();return this.expectToken(n.COLON),this.node(e,{kind:a.OBJECT_FIELD,name:r,value:this.parseValueLiteral(t)})}parseDirectives(t){const e=[];for(;this.peek(n.AT);)e.push(this.parseDirective(t));return e}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(t){const e=this._lexer.token;return this.expectToken(n.AT),this.node(e,{kind:a.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(t)})}parseTypeReference(){const t=this._lexer.token;let e;if(this.expectOptionalToken(n.BRACKET_L)){const r=this.parseTypeReference();this.expectToken(n.BRACKET_R),e=this.node(t,{kind:a.LIST_TYPE,type:r})}else e=this.parseNamedType();return this.expectOptionalToken(n.BANG)?this.node(t,{kind:a.NON_NULL_TYPE,type:e}):e}parseNamedType(){return this.node(this._lexer.token,{kind:a.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(n.STRING)||this.peek(n.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("schema");const r=this.parseConstDirectives(),i=this.many(n.BRACE_L,this.parseOperationTypeDefinition,n.BRACE_R);return this.node(t,{kind:a.SCHEMA_DEFINITION,description:e,directives:r,operationTypes:i})}parseOperationTypeDefinition(){const t=this._lexer.token,e=this.parseOperationType();this.expectToken(n.COLON);const r=this.parseNamedType();return this.node(t,{kind:a.OPERATION_TYPE_DEFINITION,operation:e,type:r})}parseScalarTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("scalar");const r=this.parseName(),i=this.parseConstDirectives();return this.node(t,{kind:a.SCALAR_TYPE_DEFINITION,description:e,name:r,directives:i})}parseObjectTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("type");const r=this.parseName(),i=this.parseImplementsInterfaces(),o=this.parseConstDirectives(),c=this.parseFieldsDefinition();return this.node(t,{kind:a.OBJECT_TYPE_DEFINITION,description:e,name:r,interfaces:i,directives:o,fields:c})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(n.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(n.BRACE_L,this.parseFieldDefinition,n.BRACE_R)}parseFieldDefinition(){const t=this._lexer.token,e=this.parseDescription(),r=this.parseName(),i=this.parseArgumentDefs();this.expectToken(n.COLON);const o=this.parseTypeReference(),c=this.parseConstDirectives();return this.node(t,{kind:a.FIELD_DEFINITION,description:e,name:r,arguments:i,type:o,directives:c})}parseArgumentDefs(){return this.optionalMany(n.PAREN_L,this.parseInputValueDef,n.PAREN_R)}parseInputValueDef(){const t=this._lexer.token,e=this.parseDescription(),r=this.parseName();this.expectToken(n.COLON);const i=this.parseTypeReference();let o;this.expectOptionalToken(n.EQUALS)&&(o=this.parseConstValueLiteral());const c=this.parseConstDirectives();return this.node(t,{kind:a.INPUT_VALUE_DEFINITION,description:e,name:r,type:i,defaultValue:o,directives:c})}parseInterfaceTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("interface");const r=this.parseName(),i=this.parseImplementsInterfaces(),o=this.parseConstDirectives(),c=this.parseFieldsDefinition();return this.node(t,{kind:a.INTERFACE_TYPE_DEFINITION,description:e,name:r,interfaces:i,directives:o,fields:c})}parseUnionTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("union");const r=this.parseName(),i=this.parseConstDirectives(),o=this.parseUnionMemberTypes();return this.node(t,{kind:a.UNION_TYPE_DEFINITION,description:e,name:r,directives:i,types:o})}parseUnionMemberTypes(){return this.expectOptionalToken(n.EQUALS)?this.delimitedMany(n.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("enum");const r=this.parseName(),i=this.parseConstDirectives(),o=this.parseEnumValuesDefinition();return this.node(t,{kind:a.ENUM_TYPE_DEFINITION,description:e,name:r,directives:i,values:o})}parseEnumValuesDefinition(){return this.optionalMany(n.BRACE_L,this.parseEnumValueDefinition,n.BRACE_R)}parseEnumValueDefinition(){const t=this._lexer.token,e=this.parseDescription(),r=this.parseEnumValueName(),i=this.parseConstDirectives();return this.node(t,{kind:a.ENUM_VALUE_DEFINITION,description:e,name:r,directives:i})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw u(this._lexer.source,this._lexer.token.start,`${_(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("input");const r=this.parseName(),i=this.parseConstDirectives(),o=this.parseInputFieldsDefinition();return this.node(t,{kind:a.INPUT_OBJECT_TYPE_DEFINITION,description:e,name:r,directives:i,fields:o})}parseInputFieldsDefinition(){return this.optionalMany(n.BRACE_L,this.parseInputValueDef,n.BRACE_R)}parseTypeSystemExtension(){const t=this._lexer.lookahead();if(t.kind===n.NAME)switch(t.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension();case"directive":if(this._options.experimentalDirectivesOnDirectiveDefinitions)return this.parseDirectiveDefinitionExtension();break}throw this.unexpected(t)}parseSchemaExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const e=this.parseConstDirectives(),r=this.optionalMany(n.BRACE_L,this.parseOperationTypeDefinition,n.BRACE_R);if(e.length===0&&r.length===0)throw this.unexpected();return this.node(t,{kind:a.SCHEMA_EXTENSION,directives:e,operationTypes:r})}parseScalarTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const e=this.parseName(),r=this.parseConstDirectives();if(r.length===0)throw this.unexpected();return this.node(t,{kind:a.SCALAR_TYPE_EXTENSION,name:e,directives:r})}parseObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const e=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),o=this.parseFieldsDefinition();if(r.length===0&&i.length===0&&o.length===0)throw this.unexpected();return this.node(t,{kind:a.OBJECT_TYPE_EXTENSION,name:e,interfaces:r,directives:i,fields:o})}parseInterfaceTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const e=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),o=this.parseFieldsDefinition();if(r.length===0&&i.length===0&&o.length===0)throw this.unexpected();return this.node(t,{kind:a.INTERFACE_TYPE_EXTENSION,name:e,interfaces:r,directives:i,fields:o})}parseUnionTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const e=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:a.UNION_TYPE_EXTENSION,name:e,directives:r,types:i})}parseEnumTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const e=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:a.ENUM_TYPE_EXTENSION,name:e,directives:r,values:i})}parseInputObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const e=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:a.INPUT_OBJECT_TYPE_EXTENSION,name:e,directives:r,fields:i})}parseDirectiveDefinitionExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("directive"),this.expectToken(n.AT);const e=this.parseName(),r=this.parseConstDirectives();if(r.length===0)throw this.unexpected();return this.node(t,{kind:a.DIRECTIVE_EXTENSION,name:e,directives:r})}parseDirectiveDefinition(){const t=this._lexer.token,e=this.parseDescription();this.expectKeyword("directive"),this.expectToken(n.AT);const r=this.parseName(),i=this.parseArgumentDefs(),o=this._options.experimentalDirectivesOnDirectiveDefinitions?this.parseConstDirectives():[],c=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const h=this.parseDirectiveLocations();return this.node(t,{kind:a.DIRECTIVE_DEFINITION,description:e,name:r,arguments:i,directives:o,repeatable:c,locations:h})}parseDirectiveLocations(){return this.delimitedMany(n.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const t=this._lexer.token,e=this.parseName();if(Object.prototype.hasOwnProperty.call(G,e.value))return e;throw this.unexpected(t)}parseSchemaCoordinate(){const t=this._lexer.token,e=this.expectOptionalToken(n.AT),r=this.parseName();let i;!e&&this.expectOptionalToken(n.DOT)&&(i=this.parseName());let o;return(e||i)&&this.expectOptionalToken(n.PAREN_L)&&(o=this.parseName(),this.expectToken(n.COLON),this.expectToken(n.PAREN_R)),e?o?this.node(t,{kind:a.DIRECTIVE_ARGUMENT_COORDINATE,name:r,argumentName:o}):this.node(t,{kind:a.DIRECTIVE_COORDINATE,name:r}):i?o?this.node(t,{kind:a.ARGUMENT_COORDINATE,name:r,fieldName:i,argumentName:o}):this.node(t,{kind:a.MEMBER_COORDINATE,name:r,memberName:i}):this.node(t,{kind:a.TYPE_COORDINATE,name:r})}node(t,e){return this._options.noLocation!==!0&&(e.loc=new $(t,this._lexer.lastToken,this._lexer.source)),e}peek(t){return this._lexer.token.kind===t}expectToken(t){const e=this._lexer.token;if(e.kind===t)return this.advanceLexer(),e;throw u(this._lexer.source,e.start,`Expected ${w(t)}, found ${_(e)}.`)}expectOptionalToken(t){return this._lexer.token.kind===t?(this.advanceLexer(),!0):!1}expectKeyword(t){const e=this._lexer.token;if(e.kind===n.NAME&&e.value===t)this.advanceLexer();else throw u(this._lexer.source,e.start,`Expected "${t}", found ${_(e)}.`)}expectOptionalKeyword(t){const e=this._lexer.token;return e.kind===n.NAME&&e.value===t?(this.advanceLexer(),!0):!1}unexpected(t){const e=t??this._lexer.token;return u(this._lexer.source,e.start,`Unexpected ${_(e)}.`)}any(t,e,r){this.expectToken(t);const i=[];for(;!this.expectOptionalToken(r);)i.push(e.call(this));return i}optionalMany(t,e,r){if(this.expectOptionalToken(t)){const i=[];do i.push(e.call(this));while(!this.expectOptionalToken(r));return i}return[]}many(t,e,r){this.expectToken(t);const i=[];do i.push(e.call(this));while(!this.expectOptionalToken(r));return i}delimitedMany(t,e){this.expectOptionalToken(t);const r=[];do r.push(e.call(this));while(this.expectOptionalToken(t));return r}advanceLexer(){const{maxTokens:t}=this._options,e=this._lexer.advance();if(e.kind!==n.EOF&&(++this._tokenCounter,t!==void 0&&this._tokenCounter>t))throw u(this._lexer.source,e.start,`Document contains more that ${t} tokens. Parsing aborted.`)}}function _(s){const t=s.value;return w(s.kind)+(t!=null?` "${t}"`:"")}function w(s){return z(s)?`"${s}"`:s}function oe(s,t){const e={};for(const r of Object.keys(s)){const i=s[r];if(!i)continue;const o=typeof i=="function"?i:i.enter,c=typeof i=="function"?void 0:i.leave;e[r]={...o?{enter:b(o,t)}:{},...c?{leave:b(c,t)}:{}}}return e}function b(s,t){return(e,r,i,o,c)=>{s(e,ae(e,t,c))}}function ae(s,t,e=[]){const{ruleId:r,severity:i,message:o,source:c,config:h,problems:d}=t,f=e.filter(l=>!Array.isArray(l));return{source:c,config:h,ancestors:f,report(l){const P=l.node??s,O=l.loc??ce(P),F={source:c,pointer:void 0,start:O?.start??{line:1,col:1},end:O?.end};d.push({ruleId:l.ruleId??r,severity:l.severity??i,message:o?o.replace("{{message}}",l.message):l.message,suggest:l.suggest??[],location:[F]})}}}function ce(s){if(!s?.loc)return;const t=R(s.loc.source,s.loc.start),e=R(s.loc.source,s.loc.end);return{start:{line:t.line,col:t.column},end:{line:e.line,col:e.column}}}function he(s){const{document:t,config:e}=s,r=t.source;if(r.body.trim()==="")return[{ruleId:"struct",severity:"error",message:"The GraphQL document is empty. Expected at least one type definition.",suggest:[],location:[{source:r,pointer:void 0,start:{line:1,col:1}}]}];let i;try{i=re(new D(r.body,r.absoluteRef))}catch(h){if(h instanceof y)return[pe(h,r)];throw h}const o=e.getRulesForSpecVersion("graphql")??[],c=B(o,e,"rules","graphql");return ue({ast:i,source:r,config:e,rules:c}).map(h=>e.addProblemToIgnore(h))}function pe(s,t){const e=s.locations?.[0];return{ruleId:"struct",severity:"error",message:s.message,suggest:[],location:[{source:t,pointer:void 0,start:e?{line:e.line,col:e.column}:{line:1,col:1}}]}}function ue(s){const{ast:t,source:e,config:r,rules:i}=s,o=[],c=i.map(({ruleId:h,severity:d,message:f,visitor:l})=>oe(l,{ruleId:h,severity:d,message:f,source:e,config:r,problems:o}));return c.length>0&&Y(t,j(c)),o}export{he as lintGraphqlDocument};
|