Comparing version 1.0.3 to 1.1.0-canary-2601bd8f646b4dae54f333609d150a6739201041
import { | ||
Kind, | ||
OperationTypeNode, | ||
DocumentNode, | ||
FragmentSpreadNode, | ||
@@ -10,2 +9,3 @@ InlineFragmentNode, | ||
TypeNode, | ||
DocumentNode, | ||
} from '@0no-co/graphql.web'; | ||
@@ -903,26 +903,36 @@ | ||
type fragmentRefs = typeof fragmentRefs; | ||
const fragmentDef: unique symbol; | ||
type fragmentDef = typeof fragmentDef; | ||
const fragmentId: unique symbol; | ||
type fragmentId = typeof fragmentId; | ||
const definition: unique symbol; | ||
type definition = typeof definition; | ||
const ref: unique symbol; | ||
type ref = typeof ref; | ||
} | ||
interface FragmentDefDecorationLike { | ||
readonly [$tada.fragmentId]: symbol; | ||
kind: Kind.FRAGMENT_DEFINITION; | ||
name: any; | ||
typeCondition: any; | ||
fragment: any; | ||
on: any; | ||
masked: any; | ||
} | ||
interface DocumentDefDecorationLike extends DocumentNode { | ||
[$tada.fragmentDef]?: FragmentDefDecorationLike; | ||
interface DocumentDefDecorationLike { | ||
[$tada.definition]?: FragmentDefDecorationLike; | ||
} | ||
type isMaskedRec<Directives extends readonly unknown[] | undefined> = Directives extends readonly [ | ||
infer Directive, | ||
...infer Rest, | ||
] | ||
? Directive extends { | ||
kind: Kind.DIRECTIVE; | ||
name: any; | ||
} | ||
? Directive['name']['value'] extends '_unmask' | ||
? false | ||
: isMaskedRec<Rest> | ||
: isMaskedRec<Rest> | ||
: true; | ||
type decorateFragmentDef<Document extends DocumentNodeLike> = Document['definitions'][0] extends { | ||
kind: Kind.FRAGMENT_DEFINITION; | ||
name: any; | ||
typeCondition: any; | ||
} | ||
? { | ||
kind: Kind.FRAGMENT_DEFINITION; | ||
name: Document['definitions'][0]['name']; | ||
typeCondition: Document['definitions'][0]['typeCondition']; | ||
readonly [$tada.fragmentId]: unique symbol; | ||
fragment: Document['definitions'][0]['name']['value']; | ||
on: Document['definitions'][0]['typeCondition']['name']['value']; | ||
masked: isMaskedRec<Document['definitions'][0]['directives']>; | ||
} | ||
@@ -935,11 +945,22 @@ : never; | ||
? (Document extends { | ||
[$tada.fragmentDef]?: any; | ||
[$tada.definition]?: any; | ||
} | ||
? Exclude<Document[$tada.fragmentDef], undefined> extends infer FragmentDef extends { | ||
kind: Kind.FRAGMENT_DEFINITION; | ||
name: any; | ||
typeCondition: any; | ||
} | ||
? Exclude<Document[$tada.definition], undefined> extends infer Definition extends | ||
FragmentDefDecorationLike | ||
? { | ||
[Name in FragmentDef['name']['value']]: FragmentDef; | ||
[Name in Definition['fragment']]: { | ||
kind: Kind.FRAGMENT_DEFINITION; | ||
name: { | ||
kind: Kind.NAME; | ||
value: Definition['fragment']; | ||
}; | ||
typeCondition: { | ||
kind: Kind.NAMED_TYPE; | ||
name: { | ||
kind: Kind.NAME; | ||
value: Definition['on']; | ||
}; | ||
}; | ||
[$tada.ref]: makeFragmentRef<Document>; | ||
}; | ||
} | ||
@@ -950,7 +971,21 @@ : {} | ||
: {}; | ||
type makeFragmentRef<Definition extends FragmentDefDecorationLike> = obj<{ | ||
[$tada.fragmentRefs]: { | ||
[Name in Definition['name']['value']]: Definition[$tada.fragmentId]; | ||
}; | ||
}>; | ||
type makeFragmentRef<Document> = Document extends { | ||
[$tada.definition]?: infer Definition; | ||
} | ||
? Definition extends FragmentDefDecorationLike | ||
? Definition['masked'] extends false | ||
? Document extends DocumentDecoration<infer Result, any> | ||
? Result | ||
: { | ||
[$tada.fragmentRefs]: { | ||
[Name in Definition['fragment']]: $tada.ref; | ||
}; | ||
} | ||
: { | ||
[$tada.fragmentRefs]: { | ||
[Name in Definition['fragment']]: $tada.ref; | ||
}; | ||
} | ||
: never | ||
: never; | ||
type makeUndefinedFragmentRef<FragmentName extends string> = { | ||
@@ -961,4 +996,4 @@ [$tada.fragmentRefs]: { | ||
}; | ||
type makeFragmentDefDecoration<Definition> = { | ||
[$tada.fragmentDef]?: Definition extends DocumentDefDecorationLike[$tada.fragmentDef] | ||
type makeDefinitionDecoration<Definition> = { | ||
[$tada.definition]?: Definition extends DocumentDefDecorationLike[$tada.definition] | ||
? Definition | ||
@@ -1016,5 +1051,23 @@ : never; | ||
}, | ||
TypeDirective = void, | ||
> = Type extends IntrospectionNonNullTypeRef | ||
? _unwrapTypeRec$1<Type['ofType'], SelectionSet, Introspection, Fragments> | ||
: null | _unwrapTypeRec$1<Type, SelectionSet, Introspection, Fragments>; | ||
? TypeDirective extends 'optional' | ||
? null | _unwrapTypeRec$1<Type['ofType'], SelectionSet, Introspection, Fragments> | ||
: _unwrapTypeRec$1<Type['ofType'], SelectionSet, Introspection, Fragments> | ||
: TypeDirective extends 'required' | ||
? _unwrapTypeRec$1<Type, SelectionSet, Introspection, Fragments> | ||
: null | _unwrapTypeRec$1<Type, SelectionSet, Introspection, Fragments>; | ||
type getTypeDirective<Directives extends readonly unknown[] | undefined> = | ||
Directives extends readonly [infer Directive, ...infer Rest] | ||
? Directive extends { | ||
kind: Kind.DIRECTIVE; | ||
name: any; | ||
} | ||
? Directive['name']['value'] extends 'required' | '_required' | ||
? 'required' | ||
: Directive['name']['value'] extends 'optional' | '_optional' | ||
? 'optional' | ||
: getTypeDirective<Rest> | ||
: getTypeDirective<Rest> | ||
: void; | ||
type isOptionalRec<Directives extends readonly unknown[] | undefined> = | ||
@@ -1055,4 +1108,6 @@ Directives extends readonly [infer Directive, ...infer Rest] | ||
? Node['name']['value'] extends keyof Fragments | ||
? Fragments[Node['name']['value']] extends FragmentDefDecorationLike | ||
? makeFragmentRef<Fragments[Node['name']['value']]> | ||
? Fragments[Node['name']['value']] extends { | ||
[$tada.ref]: any; | ||
} | ||
? Fragments[Node['name']['value']][$tada.ref] | ||
: getSelection< | ||
@@ -1135,3 +1190,4 @@ Fragments[Node['name']['value']]['selectionSet']['selections'], | ||
Introspection, | ||
Fragments | ||
Fragments, | ||
getTypeDirective<Node['directives']> | ||
>; | ||
@@ -1146,3 +1202,4 @@ } | ||
Introspection, | ||
Fragments | ||
Fragments, | ||
getTypeDirective<Node['directives']> | ||
>; | ||
@@ -1544,3 +1601,3 @@ } | ||
DocumentDecoration<Result, Variables>, | ||
makeFragmentDefDecoration<Decoration> {} | ||
makeDefinitionDecoration<Decoration> {} | ||
/** A utility type returning the `Result` type of typed GraphQL documents. | ||
@@ -1552,5 +1609,3 @@ * | ||
*/ | ||
type ResultOf<Document> = Document extends DocumentDecoration<infer Result, infer _> | ||
? Result | ||
: never; | ||
type ResultOf<Document> = Document extends DocumentDecoration<infer Result, any> ? Result : never; | ||
/** A utility type returning the `Variables` type of typed GraphQL documents. | ||
@@ -1562,3 +1617,3 @@ * | ||
*/ | ||
type VariablesOf<Document> = Document extends DocumentDecoration<infer _, infer Variables> | ||
type VariablesOf<Document> = Document extends DocumentDecoration<any, infer Variables> | ||
? Variables | ||
@@ -1597,8 +1652,3 @@ : never; | ||
*/ | ||
type FragmentOf<Document extends DocumentDefDecorationLike> = Exclude< | ||
Document[$tada.fragmentDef], | ||
undefined | ||
> extends infer FragmentDef extends FragmentDefDecorationLike | ||
? makeFragmentRef<FragmentDef> | ||
: never; | ||
type FragmentOf<Document extends DocumentDefDecorationLike> = makeFragmentRef<Document>; | ||
type mirrorFragmentTypeRec<Fragment, Data> = Fragment extends (infer Value)[] | ||
@@ -1605,0 +1655,0 @@ ? mirrorFragmentTypeRec<Value, Data>[] |
@@ -8,16 +8,19 @@ Object.defineProperty(exports, "__esModule", { | ||
function initGraphQLTada() { | ||
return function graphql(a, e) { | ||
var n = r.parse(a).definitions; | ||
var i = new Set; | ||
for (var t of e || []) { | ||
for (var o of t.definitions) { | ||
if (o.kind === r.Kind.FRAGMENT_DEFINITION && !i.has(o)) { | ||
n.push(o); | ||
i.add(o); | ||
return function graphql(e, i) { | ||
var a = r.parse(e).definitions; | ||
var n = new Set; | ||
for (var t of i || []) { | ||
for (var d of t.definitions) { | ||
if (d.kind === r.Kind.FRAGMENT_DEFINITION && !n.has(d)) { | ||
a.push(d); | ||
n.add(d); | ||
} | ||
} | ||
} | ||
if (a[0].kind === r.Kind.FRAGMENT_DEFINITION && a[0].directives) { | ||
a[0].directives = a[0].directives.filter((r => "_unmask" !== r.name.value)); | ||
} | ||
return { | ||
kind: r.Kind.DOCUMENT, | ||
definitions: [ ...n ] | ||
definitions: a | ||
}; | ||
@@ -27,15 +30,15 @@ }; | ||
var a = initGraphQLTada(); | ||
var e = initGraphQLTada(); | ||
exports.graphql = a; | ||
exports.graphql = e; | ||
exports.initGraphQLTada = initGraphQLTada; | ||
exports.parse = function parse(a) { | ||
return r.parse(a); | ||
exports.parse = function parse(e) { | ||
return r.parse(e); | ||
}; | ||
exports.readFragment = function readFragment(r, a) { | ||
return a; | ||
exports.readFragment = function readFragment(r, e) { | ||
return e; | ||
}; | ||
//# sourceMappingURL=gql-tada.js.map |
{ | ||
"name": "gql.tada", | ||
"description": "The spec-compliant & magical GraphQL query language engine in the TypeScript type system", | ||
"version": "1.0.3", | ||
"version": "1.1.0-canary-2601bd8f646b4dae54f333609d150a6739201041", | ||
"author": "0no.co <hi@0no.co>", | ||
@@ -6,0 +6,0 @@ "source": "./src/index.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88982
80755
1785
2