@jackchuka/sdl-decompose 1.3.14 → 1.3.16
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/bin/cli.js +1 -1
- package/package.json +3 -3
package/bin/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var g=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var m=g((W,C)=>{C.exports={name:"@jackchuka/sdl-decompose",version:"1.3.
|
|
2
|
+
var g=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var m=g((W,C)=>{C.exports={name:"@jackchuka/sdl-decompose",version:"1.3.16",description:"Decompose GraphQL SDL by operation name to produce partial SDL",keywords:["decompose","graphql","schema","sdl"],license:"MIT",author:"jackchuka",repository:{type:"git",url:"https://github.com/jackchuka/sdl-decompose.git"},bin:{"sdl-decompose":"bin/cli.js"},files:["bin/**/*","dist/**/*"],type:"module",main:"dist/index.js",types:"dist/index.d.ts",scripts:{lint:"oxlint --type-aware --tsconfig ./tsconfig.json","lint:fix":"oxlint --fix --type-aware --tsconfig ./tsconfig.json",fmt:"oxfmt",build:"tsc","build:cli":"node esbuild.config.js",dev:"tsc --watch",test:"jest",prepublishOnly:"npm run build && npm run build:cli"},dependencies:{commander:"^14.0.2",graphql:"^16.12.0"},devDependencies:{"@types/jest":"^30.0.0","@types/node":"^25.0.6",esbuild:"^0.28.0",jest:"^30.2.0",oxfmt:"^0.50.0",oxlint:"^1.39.0","oxlint-tsgolint":"^0.23.0","ts-jest":"^29.4.6",typescript:"^6.0.2"},packageManager:"pnpm@10.33.0",pnpm:{onlyBuiltDependencies:["esbuild","unrs-resolver"]}}});import{Command as G}from"commander";import{readFileSync as N,writeFileSync as $,existsSync as q}from"fs";import{resolve as I}from"path";import{buildASTSchema as D,parse as T,visit as h,isObjectType as S,isInputObjectType as b,isInterfaceType as L,isUnionType as x,getNamedType as d,printType as O}from"graphql";var j=new Set(["String","Int","Float","Boolean","ID"]);function v(n,t){return t.excludeComments||!t.includeDeprecated?h(n,{FieldDefinition(e){return!t.includeDeprecated&&e.directives&&e.directives.some(s=>s.name.value==="deprecated")?null:t.excludeComments&&e.description?{...e,description:void 0}:e},Directive(e){return e.name.value==="deprecated"&&!t.includeDeprecated?null:e},ObjectTypeDefinition(e){return t.excludeComments&&e.description?{...e,description:void 0}:e},InputObjectTypeDefinition(e){return t.excludeComments&&e.description?{...e,description:void 0}:e},InterfaceTypeDefinition(e){return t.excludeComments&&e.description?{...e,description:void 0}:e},UnionTypeDefinition(e){return t.excludeComments&&e.description?{...e,description:void 0}:e},EnumTypeDefinition(e){return t.excludeComments&&e.description?{...e,description:void 0}:e},ScalarTypeDefinition(e){return t.excludeComments&&e.description?{...e,description:void 0}:e}}):n}function l(n,t,i="query",e={}){try{let r=T(n),s=v(r,e),o=D(s),c={collected:new Set,typeNames:new Set},p=f(o,i);if(!p)return{sdl:"",collectedTypes:new Set,operationFound:!1};let a=p.getFields()[t];return a?(F(a,c,e),{sdl:Q(o,c,i,t),collectedTypes:c.typeNames,operationFound:!0}):{sdl:"",collectedTypes:new Set,operationFound:!1}}catch(r){throw new Error(`Failed to decompose GraphQL: ${r instanceof Error?r.message:String(r)}`)}}function f(n,t){switch(t){case"query":return n.getQueryType();case"mutation":return n.getMutationType();case"subscription":return n.getSubscriptionType();default:return null}}function F(n,t,i){let e=d(n.type);if(u(e,t,i),n.args)for(let r of n.args){let s=d(r.type);u(s,t,i)}}function u(n,t,i){if(!(!n||t.collected.has(n))&&!(!i.includeBuiltinScalars&&j.has(n.name))){if(t.collected.add(n),t.typeNames.add(n.name),S(n)||b(n)){let e=n.getFields();for(let r of Object.values(e)){let s=d(r.type);if(u(s,t,i),"args"in r&&r.args)for(let o of r.args){let c=d(o.type);u(c,t,i)}}}else if(L(n)){let e=n.getFields();for(let r of Object.values(e)){let s=d(r.type);if(u(s,t,i),r.args)for(let o of r.args){let c=d(o.type);u(c,t,i)}}}else if(x(n))for(let e of n.getTypes())u(e,t,i)}}function Q(n,t,i,e){let r=[],s=f(n,i);if(s){let o=s.getFields()[e];if(o){let c=i==="query"?"Query":i==="mutation"?"Mutation":"Subscription";r.push(`type ${c} {
|
|
3
3
|
${e}${w(o)}
|
|
4
4
|
}`)}}for(let o of t.collected)o.name==="Query"||o.name==="Mutation"||o.name==="Subscription"||r.push(O(o));return r.join(`
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jackchuka/sdl-decompose",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.16",
|
|
4
4
|
"description": "Decompose GraphQL SDL by operation name to produce partial SDL",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"decompose",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"@types/node": "^25.0.6",
|
|
34
34
|
"esbuild": "^0.28.0",
|
|
35
35
|
"jest": "^30.2.0",
|
|
36
|
-
"oxfmt": "^0.
|
|
36
|
+
"oxfmt": "^0.50.0",
|
|
37
37
|
"oxlint": "^1.39.0",
|
|
38
|
-
"oxlint-tsgolint": "^0.
|
|
38
|
+
"oxlint-tsgolint": "^0.23.0",
|
|
39
39
|
"ts-jest": "^29.4.6",
|
|
40
40
|
"typescript": "^6.0.2"
|
|
41
41
|
},
|