diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..a6c57f5f --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +*.json diff --git a/lib/command.ts b/lib/command.ts index f92dbdc3..f42a7391 100644 --- a/lib/command.ts +++ b/lib/command.ts @@ -5,7 +5,7 @@ import { ListValueFlag, NoParams, OutputInterface, - ValueFlag + ValueFlag, } from "@2fd/command"; import Bluebird from "bluebird"; import fs from "fs"; @@ -17,7 +17,7 @@ import { httpSchemaLoader, idlSchemaLoader, jsonSchemaLoader, - jsSchemaLoader + jsSchemaLoader, } from "./schema-loader"; import { createData, getFilenameOf, Output, Plugin } from "./utility"; import { @@ -25,7 +25,7 @@ import { readFile, removeBuildDirectory, resolve, - writeFile + writeFile, } from "./utility/fs"; // tslint:disable-next-line:no-var-requires @@ -116,7 +116,7 @@ export class GraphQLDocumentGenerator extends Command { "Delete outputDirectory if exists." ), new BooleanFlag("verbose", ["-v", "--verbose"], "Output more information."), - new BooleanFlag("version", ["-V", "--version"], "Show graphdoc version.") + new BooleanFlag("version", ["-V", "--version"], "Show graphdoc version."), ]; public async action(input: Input, out: OutputInterface) { @@ -143,13 +143,13 @@ export class GraphQLDocumentGenerator extends Command { graphdocPackageJSON ); - projectPackageJSON.graphdoc.plugins.forEach(plugin => + projectPackageJSON.graphdoc.plugins.forEach((plugin) => output.info("use plugin", plugin) ); // Collect assets const assets: string[] = await Plugin.collectAssets(plugins); - assets.forEach(asset => + assets.forEach((asset) => output.info("use asset", path.relative(process.cwd(), asset)) ); @@ -261,7 +261,7 @@ export class GraphQLDocumentGenerator extends Command { projectPackageJSON: object, pluginGraphdocPackageJSON: object ): PluginInterface[] { - return paths.map(p => { + return paths.map((p) => { const absolutePaths = resolve(p); const plugin = require(absolutePaths).default; @@ -284,10 +284,10 @@ export class GraphQLDocumentGenerator extends Command { )("**/*.mustache", { cwd: templateDir }); await Promise.all( - files.map(file => { + files.map((file) => { const name = path.basename(file, ".mustache"); return readFile(path.resolve(templateDir, file), "utf8").then( - content => (partials[name] = content) + (content) => (partials[name] = content) ); }) ); diff --git a/lib/schema-loader/http.ts b/lib/schema-loader/http.ts index ffc5777b..8b16a3cc 100644 --- a/lib/schema-loader/http.ts +++ b/lib/schema-loader/http.ts @@ -5,7 +5,7 @@ import { GraphQLIntrospection, Introspection, Schema, - SchemaLoader + SchemaLoader, } from "../interface"; import { query as introspectionQuery } from "../utility"; @@ -62,7 +62,7 @@ export const httpSchemaLoader: SchemaLoader = async ( url: options.endpoint, method: "POST", body: { query: introspectionQuery }, - json: true + json: true, }; requestOptions.headers = options.headers.reduce( diff --git a/lib/schema-loader/idl.ts b/lib/schema-loader/idl.ts index 4caf7190..9d6a39bb 100644 --- a/lib/schema-loader/idl.ts +++ b/lib/schema-loader/idl.ts @@ -4,7 +4,7 @@ import { ApolloIntrospection, GraphQLIntrospection, Introspection, - SchemaLoader + SchemaLoader, } from "../interface"; import { query as introspectionQuery } from "../utility"; import { readFile } from "../utility/fs"; diff --git a/lib/schema-loader/index.ts b/lib/schema-loader/index.ts index 214472ce..595f0aa0 100644 --- a/lib/schema-loader/index.ts +++ b/lib/schema-loader/index.ts @@ -2,9 +2,9 @@ export { IHttpSchemaLoaderOptions, httpSchemaLoader } from "./http"; export { IIdlSchemaLoaderOptions, idlSchemaLoader } from "./idl"; export { IJsSchemaLoaderOptions as TJsSchemaLoaderOptions, - jsSchemaLoader + jsSchemaLoader, } from "./js"; export { IJsonSchemaLoaderOptions as TJsonSchemaLoaderOptions, - jsonSchemaLoader + jsonSchemaLoader, } from "./json"; diff --git a/lib/schema-loader/js.ts b/lib/schema-loader/js.ts index 2ceb067c..ea2fec1f 100644 --- a/lib/schema-loader/js.ts +++ b/lib/schema-loader/js.ts @@ -4,7 +4,7 @@ import { ApolloIntrospection, GraphQLIntrospection, Introspection, - SchemaLoader + SchemaLoader, } from "../interface"; import { query as introspectionQuery } from "../utility"; diff --git a/lib/schema-loader/json.ts b/lib/schema-loader/json.ts index 0eea8b74..a73adc52 100644 --- a/lib/schema-loader/json.ts +++ b/lib/schema-loader/json.ts @@ -4,7 +4,7 @@ import { GraphQLIntrospection, Introspection, Schema, - SchemaLoader + SchemaLoader, } from "../interface"; export interface IJsonSchemaLoaderOptions { diff --git a/lib/utility/fs.ts b/lib/utility/fs.ts index 2f4be10f..345b7676 100644 --- a/lib/utility/fs.ts +++ b/lib/utility/fs.ts @@ -56,10 +56,10 @@ export async function createBuildDirectory( files // ignore *.mustache templates - .filter(file => path.extname(file) !== ".mustache") + .filter((file) => path.extname(file) !== ".mustache") // copy recursive - .map(file => + .map((file) => copyAll( path.resolve(templateDirectory, file), path.resolve(buildDirectory, file) @@ -71,7 +71,7 @@ export async function createBuildDirectory( await mkDir(path.resolve(buildDirectory, "assets")); await Bluebird.all( - assets.map(asset => + assets.map((asset) => copyAll( asset, path.resolve(buildDirectory, "assets", path.basename(asset)) diff --git a/lib/utility/html.test.ts b/lib/utility/html.test.ts index 00e6187e..2ccf0c57 100644 --- a/lib/utility/html.test.ts +++ b/lib/utility/html.test.ts @@ -1,11 +1,11 @@ -import { Description, Field, InputValue, SchemaType } from '../interface' -import { split, HTML } from './html' -import { data } from '../../test/empty.schema.json' - -test('utility/html.split', () => { - const LOREM_IPSU = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.` - expect(split('', 0)).toEqual(['']) - expect(split(LOREM_IPSU, 1)).toEqual(LOREM_IPSU.split(' ')) +import { Description, Field, InputValue, SchemaType } from "../interface"; +import { split, HTML } from "./html"; +import { data } from "../../test/empty.schema.json"; + +test("utility/html.split", () => { + const LOREM_IPSU = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.`; + expect(split("", 0)).toEqual([""]); + expect(split(LOREM_IPSU, 1)).toEqual(LOREM_IPSU.split(" ")); expect(split(LOREM_IPSU, 10)).toEqual([ "Lorem Ipsum", "is simply dummy", @@ -25,89 +25,116 @@ test('utility/html.split', () => { "it to make", "a type specimen", "book.", - ]) + ]); expect(split(LOREM_IPSU, 100)).toEqual([ "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's", "standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled", "it to make a type specimen book.", - ]) -}) - - -describe('lib/utility/html#HTML', () => { - test('.code', () => { - const html = new HTML - expect(html.code('CODE')).toBe('CODE
') - }) - - test('.highlight', () => { - const html = new HTML - expect(html.highlight('CODE')).toBe('CODE') - }) - - test('.sup', () => { - const html = new HTML - expect(html.sup('CODE')).toBe(' CODE') - }) - - test('.line', () => { - const html = new HTML - expect(html.index).toBe(1) - expect(html.line('CODE')).toBe('1CODE') - expect(html.index).toBe(2) - }) - - test('.tab', () => { - const html = new HTML - expect(html.tab('CODE')).toBe('CODE') - }) - - test('.keyword', () => { - const html = new HTML - expect(html.keyword('CODE')).toBe('CODE') - }) - - test('.comment', () => { - const html = new HTML - expect(html.comment('CODE')).toBe('# CODE') - }) - - test('.identifier', () => { - const html = new HTML - const type = data.__schema.types.find(t => t.name === 'Query') - expect(html.identifier(type as Description)).toBe('Query') - }) - - test('.parameter', () => { - const html = new HTML - const input: InputValue = data.__schema.types.find(t => t.name === 'AddCommentInput') as any - expect(html.parameter(input)).toBe('AddCommentInput') - }) - - test('.property', () => { - const html = new HTML - expect(html.property('PROPERTY')).toBe('PROPERTY') - }) - - test('.useIdentifier', () => { - const html = new HTML - const schema: SchemaType = data.__schema.types.find(t => t.name === '__Schema') as any - const field: Field = (schema.fields || []).find(f => f.name === 'types') as any - - expect(html.useIdentifier(field.type, 'HREF')).toBe('[__Type!]!') - }) - - test('.useIdentifierLength', () => { - const html = new HTML - const schema: SchemaType = data.__schema.types.find(t => t.name === '__Schema') as any - const field: Field = (schema.fields || []).find(f => f.name === 'types') as any - - expect(html.useIdentifierLength(field.type)).toBe(10) - }) - - test('.value', () => { - const html = new HTML - expect(html.value('"STRING"')).toBe('"STRING"') - expect(html.value('NUMBER')).toBe('NUMBER') - }) -}) \ No newline at end of file + ]); +}); + +describe("lib/utility/html#HTML", () => { + test(".code", () => { + const html = new HTML(); + expect(html.code("CODE")).toBe( + 'CODE
' + ); + }); + + test(".highlight", () => { + const html = new HTML(); + expect(html.highlight("CODE")).toBe("CODE"); + }); + + test(".sup", () => { + const html = new HTML(); + expect(html.sup("CODE")).toBe(" CODE"); + }); + + test(".line", () => { + const html = new HTML(); + expect(html.index).toBe(1); + expect(html.line("CODE")).toBe( + '1CODE' + ); + expect(html.index).toBe(2); + }); + + test(".tab", () => { + const html = new HTML(); + expect(html.tab("CODE")).toBe('CODE'); + }); + + test(".keyword", () => { + const html = new HTML(); + expect(html.keyword("CODE")).toBe( + 'CODE' + ); + }); + + test(".comment", () => { + const html = new HTML(); + expect(html.comment("CODE")).toBe( + '# CODE' + ); + }); + + test(".identifier", () => { + const html = new HTML(); + const type = data.__schema.types.find((t) => t.name === "Query"); + expect(html.identifier(type as Description)).toBe( + 'Query' + ); + }); + + test(".parameter", () => { + const html = new HTML(); + const input: InputValue = data.__schema.types.find( + (t) => t.name === "AddCommentInput" + ) as any; + expect(html.parameter(input)).toBe( + 'AddCommentInput' + ); + }); + + test(".property", () => { + const html = new HTML(); + expect(html.property("PROPERTY")).toBe( + 'PROPERTY' + ); + }); + + test(".useIdentifier", () => { + const html = new HTML(); + const schema: SchemaType = data.__schema.types.find( + (t) => t.name === "__Schema" + ) as any; + const field: Field = (schema.fields || []).find( + (f) => f.name === "types" + ) as any; + + expect(html.useIdentifier(field.type, "HREF")).toBe( + '[__Type!]!' + ); + }); + + test(".useIdentifierLength", () => { + const html = new HTML(); + const schema: SchemaType = data.__schema.types.find( + (t) => t.name === "__Schema" + ) as any; + const field: Field = (schema.fields || []).find( + (f) => f.name === "types" + ) as any; + + expect(html.useIdentifierLength(field.type)).toBe(10); + }); + + test(".value", () => { + const html = new HTML(); + expect(html.value('"STRING"')).toBe('"STRING"'); + expect(html.value("NUMBER")).toBe( + 'NUMBER' + ); + }); +}); diff --git a/lib/utility/html.ts b/lib/utility/html.ts index 70d38f4d..dccc16f4 100644 --- a/lib/utility/html.ts +++ b/lib/utility/html.ts @@ -18,8 +18,9 @@ export class HTML { line(code?: string): string { const row = this.index++; - return `${row}${code || - ""}`; + return `${row}${ + code || "" + }`; } tab(code: string): string { diff --git a/lib/utility/index.ts b/lib/utility/index.ts index 42ce2cff..5fb14071 100644 --- a/lib/utility/index.ts +++ b/lib/utility/index.ts @@ -5,7 +5,7 @@ export { NavigationSection, DocumentSection, Plugin, - sortTypes + sortTypes, } from "./plugin"; export { @@ -19,7 +19,7 @@ export { NON_NULL, OBJECT, SCALAR, - UNION + UNION, } from "./introspection"; export { Output } from "./output"; diff --git a/lib/utility/introspection.test.ts b/lib/utility/introspection.test.ts index 2c3753af..90f235c4 100644 --- a/lib/utility/introspection.test.ts +++ b/lib/utility/introspection.test.ts @@ -1,17 +1,25 @@ -import { getTypeOf, getFilenameOf } from './introspection' -import { data } from '../../test/empty.schema.json' -import { DeepTypeRef, SchemaType, Field } from '../interface' +import { getTypeOf, getFilenameOf } from "./introspection"; +import { data } from "../../test/empty.schema.json"; +import { DeepTypeRef, SchemaType, Field } from "../interface"; test(`lib/utility/introspection#getTypeOf`, () => { - const schema: SchemaType = data.__schema.types.find(t => t.name === '__Schema') as any - const field: Field = (schema.fields || []).find(f => f.name === 'types') as any + const schema: SchemaType = data.__schema.types.find( + (t) => t.name === "__Schema" + ) as any; + const field: Field = (schema.fields || []).find( + (f) => f.name === "types" + ) as any; - expect(getTypeOf(field.type)).toBe(field.type.ofType?.ofType?.ofType) -}) + expect(getTypeOf(field.type)).toBe(field.type.ofType?.ofType?.ofType); +}); test(`lib/utility/introspection#getTypeOf`, () => { - const schema: SchemaType = data.__schema.types.find(t => t.name === '__Schema') as any - const field: DeepTypeRef = (schema.fields || []).find(f => f.name === 'types') as any + const schema: SchemaType = data.__schema.types.find( + (t) => t.name === "__Schema" + ) as any; + const field: DeepTypeRef = (schema.fields || []).find( + (f) => f.name === "types" + ) as any; - expect(getFilenameOf(field)).toBe('types.doc.html') -}) \ No newline at end of file + expect(getFilenameOf(field)).toBe("types.doc.html"); +}); diff --git a/lib/utility/output.test.ts b/lib/utility/output.test.ts index abd6dc6f..ee5a9c59 100644 --- a/lib/utility/output.test.ts +++ b/lib/utility/output.test.ts @@ -1,115 +1,59 @@ -import { Output } from './output' +import { Output } from "./output"; test(`lib/utility/output#Output`, () => { const m = { log: jest.fn(), - error: jest.fn() - } + error: jest.fn(), + }; - const exit = jest.fn() - Object.assign(process, { exit }) + const exit = jest.fn(); + Object.assign(process, { exit }); - const output = new Output(m, { verbose: false }) - output.ok('ref', 'value') - output.info('ref', 'value') - output.error('string message' as any) - output.error({ message: 'error message', stack: 'error stack' } as any) + const output = new Output(m, { verbose: false }); + output.ok("ref", "value"); + output.info("ref", "value"); + output.error("string message" as any); + output.error({ message: "error message", stack: "error stack" } as any); expect(m.log.mock.calls).toEqual([ - [ - "%c ✓ %s: %c%s", - "color:green", - "ref", - "color:grey", - "value", - ] - ]) + ["%c ✓ %s: %c%s", "color:green", "ref", "color:grey", "value"], + ]); expect(m.error.mock.calls).toEqual([ - [ - "%c ✗ %s", - "color:red", - "string message", - ], - [ - "", - ], - [ - "%c ✗ %s", - "color:red", - "error message", - ], - [ - "", - ], - ]) - expect(exit.mock.calls).toEqual([ - [1], - [1], - ]) -}) + ["%c ✗ %s", "color:red", "string message"], + [""], + ["%c ✗ %s", "color:red", "error message"], + [""], + ]); + expect(exit.mock.calls).toEqual([[1], [1]]); +}); test(`lib/utility/output#Output (verbose)`, () => { const m = { log: jest.fn(), - error: jest.fn() - } + error: jest.fn(), + }; - const exit = jest.fn() - Object.assign(process, { exit }) + const exit = jest.fn(); + Object.assign(process, { exit }); - const output = new Output(m, { verbose: true }) - output.ok('ref', 'value') - output.info('ref', 'value') - output.error('string message' as any) - output.error({ message: 'error message', stack: 'error stack' } as any) + const output = new Output(m, { verbose: true }); + output.ok("ref", "value"); + output.info("ref", "value"); + output.error("string message" as any); + output.error({ message: "error message", stack: "error stack" } as any); expect(m.log.mock.calls).toEqual([ - [ - "%c ✓ %s: %c%s", - "color:green", - "ref", - "color:grey", - "value", - ], - [ - "%c ❭ %s: %c%s", - "color:yellow", - "ref", - "color:grey", - "value", - ], - ]) + ["%c ✓ %s: %c%s", "color:green", "ref", "color:grey", "value"], + ["%c ❭ %s: %c%s", "color:yellow", "ref", "color:grey", "value"], + ]); expect(m.error.mock.calls).toEqual([ - [ - "%c ✗ %s", - "color:red", - "string message", - ], - [ - "%c%s", - "color:grey", - " NO STACK", - ], - [ - "", - ], - [ - "%c ✗ %s", - "color:red", - "error message", - ], - [ - "%c%s", - "color:grey", - "error stack", - ], - [ - "", - ], - ]) - - expect(exit.mock.calls).toEqual([ - [1], - [1], - ]) -}) + ["%c ✗ %s", "color:red", "string message"], + ["%c%s", "color:grey", " NO STACK"], + [""], + ["%c ✗ %s", "color:red", "error message"], + ["%c%s", "color:grey", "error stack"], + [""], + ]); + + expect(exit.mock.calls).toEqual([[1], [1]]); +}); diff --git a/lib/utility/plugin.ts b/lib/utility/plugin.ts index 13fe7246..7b5d9861 100644 --- a/lib/utility/plugin.ts +++ b/lib/utility/plugin.ts @@ -9,7 +9,7 @@ import { PluginInterface, Schema, SchemaType, - TypeRef + TypeRef, } from "../interface"; import { getFilenameOf } from "./introspection"; @@ -20,7 +20,7 @@ export abstract class Plugin { static collect(collection: T[][]): T[] { let result: T[] = []; - collection.forEach(item => { + collection.forEach((item) => { if (Array.isArray(item)) { result = result.concat(item); } @@ -36,7 +36,7 @@ export abstract class Plugin { const navigationCollection = await Promise.all< NavigationSectionInterface[] >( - plugins.map(plugin => { + plugins.map((plugin) => { return plugin.getNavigations ? plugin.getNavigations(buildForType) : (null as any); @@ -51,7 +51,7 @@ export abstract class Plugin { buildForType?: string ): Promise { const navigationCollection = await Promise.all( - plugins.map(plugin => { + plugins.map((plugin) => { return plugin.getDocuments ? plugin.getDocuments(buildForType) : (null as any); @@ -66,7 +66,7 @@ export abstract class Plugin { buildForType?: string ): Promise { const headerCollection = await Promise.all( - plugins.map(plugin => { + plugins.map((plugin) => { return plugin.getHeaders ? plugin.getHeaders(buildForType) : (null as any); @@ -78,7 +78,7 @@ export abstract class Plugin { static async collectAssets(plugins: PluginInterface[]): Promise { const assetCollection = await Promise.all( - plugins.map(plugin => { + plugins.map((plugin) => { return plugin.getAssets ? plugin.getAssets() : (null as any); }) ); @@ -116,11 +116,11 @@ export abstract class Plugin { ) : []; - this.document.types.forEach(type => { + this.document.types.forEach((type) => { this.typeMap[type.name || ""] = type; }); - this.document.directives.forEach(directive => { + this.document.directives.forEach((directive) => { this.directiveMap[directive.name || ""] = directive; }); diff --git a/lib/utility/template.test.ts b/lib/utility/template.test.ts index b2010637..a54bb2b8 100644 --- a/lib/utility/template.test.ts +++ b/lib/utility/template.test.ts @@ -1,12 +1,12 @@ -import { slugTemplate, createData } from './template' +import { slugTemplate, createData } from "./template"; -test('lib/utility/template#slugTemplate', () => { - const slug = slugTemplate() - expect(typeof slug).toBe('function') - expect(slug('{{RAW TEXT}}', (value: string) => value)).toBe('raw-text') -}) +test("lib/utility/template#slugTemplate", () => { + const slug = slugTemplate(); + expect(typeof slug).toBe("function"); + expect(slug("{{RAW TEXT}}", (value: string) => value)).toBe("raw-text"); +}); -describe('lib/utility/template#createData', () => { +describe("lib/utility/template#createData", () => { // test(`default data`, async () => { // const data = await createData({}, {}, []) // expect(data).toHaveProperty('description', '') @@ -21,54 +21,81 @@ describe('lib/utility/template#createData', () => { // }) test(`prop "title"`, async () => { - const defaultTitle = await createData({}, {}, []) + const defaultTitle = await createData({}, {}, []); - const configTitle = await createData({ - graphdoc: { - title: "Package title" - } - }, {}, []) + const configTitle = await createData( + { + graphdoc: { + title: "Package title", + }, + }, + {}, + [] + ); - const typeTitle = await createData({ - graphdoc: { - title: "Package title" + const typeTitle = await createData( + { + graphdoc: { + title: "Package title", + }, + }, + {}, + [], + { + name: "Type title", + description: "Type description", + kind: "SCALAR", + ofType: null, } - }, {}, [], { - name: "Type title", - description: "Type description", - kind: "SCALAR", - ofType: null - }) + ); - expect(defaultTitle).toHaveProperty('title', "Graphql schema documentation") - expect(configTitle).toHaveProperty('title', "Package title") - expect(typeTitle).toHaveProperty('title', "Type title") - }) + expect(defaultTitle).toHaveProperty( + "title", + "Graphql schema documentation" + ); + expect(configTitle).toHaveProperty("title", "Package title"); + expect(typeTitle).toHaveProperty("title", "Type title"); + }); test(`prop "description"`, async () => { - const defaultDescription = await createData({}, {}, []) + const defaultDescription = await createData({}, {}, []); - const configDescription = await createData({ - description: "Package description", - graphdoc: { - title: "Package title" - } - }, {}, []) + const configDescription = await createData( + { + description: "Package description", + graphdoc: { + title: "Package title", + }, + }, + {}, + [] + ); - const typeDescription = await createData({ - description: "Package description", - graphdoc: { - title: "Package title" + const typeDescription = await createData( + { + description: "Package description", + graphdoc: { + title: "Package title", + }, + }, + {}, + [], + { + name: "Type title", + description: "Type description", + kind: "SCALAR", + ofType: null, } - }, {}, [], { - name: "Type title", - description: "Type description", - kind: "SCALAR", - ofType: null - }) + ); - expect(defaultDescription).toHaveProperty('description', "") - expect(configDescription).toHaveProperty('description', "

Package description

\n") - expect(typeDescription).toHaveProperty('description', "

Type description

\n") - }) -}) \ No newline at end of file + expect(defaultDescription).toHaveProperty("description", ""); + expect(configDescription).toHaveProperty( + "description", + "

Package description

\n" + ); + expect(typeDescription).toHaveProperty( + "description", + "

Type description

\n" + ); + }); +}); diff --git a/lib/utility/template.ts b/lib/utility/template.ts index d9556aa1..d5fd8ff7 100644 --- a/lib/utility/template.ts +++ b/lib/utility/template.ts @@ -4,7 +4,7 @@ import { DocumentSectionInterface, NavigationSectionInterface, PluginInterface, - TypeRef + TypeRef, } from "../interface"; import { Plugin } from "./plugin"; @@ -42,11 +42,15 @@ export async function createData( ] = await Promise.all([ Plugin.collectHeaders(plugins, name), Plugin.collectNavigations(plugins, name), - Plugin.collectDocuments(plugins, name) + Plugin.collectDocuments(plugins, name), ]); const title = - name || (projectPackage && projectPackage.graphdoc && projectPackage.graphdoc.title) || "Graphql schema documentation"; + name || + (projectPackage && + projectPackage.graphdoc && + projectPackage.graphdoc.title) || + "Graphql schema documentation"; const description = type ? marked(type.description || "") @@ -61,6 +65,6 @@ export async function createData( documents, projectPackage, graphdocPackage, - slug: slugTemplate + slug: slugTemplate, }; } diff --git a/package-lock.json b/package-lock.json index d64c7413..8617cf09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4674,9 +4674,9 @@ "dev": true }, "prettier": { - "version": "1.18.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", - "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz", + "integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==", "dev": true }, "pretty-format": { diff --git a/package.json b/package.json index 1116c41a..1d45ff80 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "doc.scaphold": "node bin/graphdoc.js -c example.scaphold.json -f -v", "doc.starwars": "node bin/graphdoc.js -c example.starWars.json -f -v", "doc.starwars-js": "node bin/graphdoc.js -c example.starWars-js.json -f -v", - "test": "jest" + "test": "jest", + "format": "prettier lib plugins template test --write" }, "repository": { "type": "git", @@ -55,7 +56,7 @@ "express-graphql": "^0.12.0", "handlebars": "^4.7.6", "jest": "^24.9.0", - "prettier": "^1.18.2", + "prettier": "^2.2.1", "ts-jest": "^24.3.0", "ts-node": "^9.1.1", "tslint": "^6.1.3", diff --git a/plugins/default.ts b/plugins/default.ts index a297868e..2326308f 100644 --- a/plugins/default.ts +++ b/plugins/default.ts @@ -2,7 +2,7 @@ import { DocumentSectionInterface, NavigationSectionInterface, PluginInterface, - Schema + Schema, } from "../lib/interface"; import { Plugin } from "../lib/utility"; import RequireByPlugin from "./document.require-by"; @@ -16,7 +16,8 @@ import NavigationScalar from "./navigation.scalar"; import NavigationSchema from "./navigation.schema"; import NavigationUnion from "./navigation.union"; -export default class NavigationDirectives extends Plugin +export default class NavigationDirectives + extends Plugin implements PluginInterface { plugins: PluginInterface[]; @@ -32,7 +33,7 @@ export default class NavigationDirectives extends Plugin new NavigationInput(document, graphdocPackage, projectPackage), new NavigationDirective(document, graphdocPackage, projectPackage), new DocumentSchema(document, graphdocPackage, projectPackage), - new RequireByPlugin(document, graphdocPackage, projectPackage) + new RequireByPlugin(document, graphdocPackage, projectPackage), ]; } diff --git a/plugins/document.require-by/index.ts b/plugins/document.require-by/index.ts index 227affcc..2683bf62 100644 --- a/plugins/document.require-by/index.ts +++ b/plugins/document.require-by/index.ts @@ -4,7 +4,7 @@ import { DocumentSectionInterface, PluginInterface, Schema, - SchemaType + SchemaType, } from "../../lib/interface"; import { ENUM, @@ -14,7 +14,7 @@ import { OBJECT, Plugin, SCALAR, - UNION + UNION, } from "../../lib/utility"; export default class RequireByPlugin extends Plugin implements PluginInterface { @@ -60,15 +60,15 @@ export default class RequireByPlugin extends Plugin implements PluginInterface { const deps: string[] = []; if (Array.isArray(type.interfaces) && type.interfaces.length > 0) { - type.interfaces.forEach(i => deps.push(i.name)); + type.interfaces.forEach((i) => deps.push(i.name)); } if (Array.isArray(type.fields) && type.fields.length > 0) { - type.fields.forEach(field => { + type.fields.forEach((field) => { deps.push(getTypeOf(field.type).name); if (Array.isArray(field.args) && field.args.length > 0) { - field.args.forEach(arg => { + field.args.forEach((arg) => { deps.push(getTypeOf(arg.type).name); }); } @@ -76,7 +76,7 @@ export default class RequireByPlugin extends Plugin implements PluginInterface { } if (Array.isArray(type.inputFields) && type.inputFields.length > 0) { - type.inputFields.forEach(field => { + type.inputFields.forEach((field) => { deps.push(getTypeOf(field.type).name); }); } @@ -86,7 +86,7 @@ export default class RequireByPlugin extends Plugin implements PluginInterface { Array.isArray(type.possibleTypes) && type.possibleTypes.length > 0 ) { - type.possibleTypes.forEach(t => { + type.possibleTypes.forEach((t) => { deps.push(getTypeOf(t).name); }); } @@ -127,8 +127,8 @@ export default class RequireByPlugin extends Plugin implements PluginInterface { description: '
' + "This element is not required by anyone" + - "
" - } + "", + }, ]; } @@ -140,19 +140,19 @@ export default class RequireByPlugin extends Plugin implements PluginInterface { description: '
    ' + requireBy - .filter(t => { + .filter((t) => { return used.has(t.name) ? false : used.add(t.name); }) - .map(t => this.getDescription(t)) + .map((t) => this.getDescription(t)) .join("") + - "
" - } + "", + }, ]; } getHeaders(): string[] { return [ - '' + '', ]; } } diff --git a/plugins/document.require-by/require-by.css b/plugins/document.require-by/require-by.css index a8871b6c..65a7fd7a 100644 --- a/plugins/document.require-by/require-by.css +++ b/plugins/document.require-by/require-by.css @@ -1,43 +1,43 @@ div.require-by.anyone, ul.require-by a { - max-width: 100%; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - display: block; + max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + display: block; } div.require-by.anyone { - background-color: #f0f8fc; - border: 1px solid #d8dde6; - color: grey; - padding: 2rem; - text-align: center; - margin: 1rem 0; - border-radius: 0.25rem; + background-color: #f0f8fc; + border: 1px solid #d8dde6; + color: grey; + padding: 2rem; + text-align: center; + margin: 1rem 0; + border-radius: 0.25rem; } ul.require-by { - margin: 0; - padding: 0; + margin: 0; + padding: 0; } ul.require-by a { - border-left: .25rem solid transparent; - border-top: 1px solid transparent; - border-bottom: 1px solid transparent; - padding: .5rem 1.5rem; + border-left: 0.25rem solid transparent; + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; + padding: 0.5rem 1.5rem; } ul.require-by a:hover { - text-decoration: none; - background-color: #f0f8fc; - border-color: #d8dde6; - border-left-color: #005fb2; + text-decoration: none; + background-color: #f0f8fc; + border-color: #d8dde6; + border-left-color: #005fb2; } ul.require-by a em { - margin-left: 1rem; - font-size: .75rem; - color: grey; -} \ No newline at end of file + margin-left: 1rem; + font-size: 0.75rem; + color: grey; +} diff --git a/plugins/document.schema/assets/code.css b/plugins/document.schema/assets/code.css index 89919bfd..03d97cc3 100644 --- a/plugins/document.schema/assets/code.css +++ b/plugins/document.schema/assets/code.css @@ -1,29 +1,29 @@ .code { background-color: #fff; - color: #4D4D4C; - border: 1px solid #4D4D4C; + color: #4d4d4c; + border: 1px solid #4d4d4c; font-size: 14px; - font-family: 'Ubuntu Mono'; + font-family: "Ubuntu Mono"; list-style-type: decimal; - border-radius: 0.25rem; + border-radius: 0.25rem; } .code .gutter { background: #f6f6f6; - color: #4D4D4C; + color: #4d4d4c; } .code .print-margin { width: 1px; - background: #f6f6f6 + background: #f6f6f6; } .code .row:hover { - background: #EFEFEF; + background: #efefef; } .code .td-index { - color: rgba(27, 31, 35, .3); + color: rgba(27, 31, 35, 0.3); padding: 1px 8px 1px 16px; text-align: right; width: 1%; @@ -31,7 +31,7 @@ .code .td-index:hover { cursor: pointer; - color: rgba(27, 31, 35, .6); + color: rgba(27, 31, 35, 0.6); } .code .td-code { @@ -47,40 +47,40 @@ } .code .cursor { - color: #AEAFAD + color: #aeafad; } .code .marker-layer .selection { - background: #D6D6D6 + background: #d6d6d6; } .code.multiselect .selection.start { - box-shadow: 0 0 3px 0px #FFFFFF; + box-shadow: 0 0 3px 0px #ffffff; } .code .marker-layer .step { - background: rgb(255, 255, 0) + background: rgb(255, 255, 0); } .code .marker-layer .bracket { margin: -1px 0 0 -1px; - border: 1px solid #D1D1D1 + border: 1px solid #d1d1d1; } .code .marker-layer .active-line { - background: #EFEFEF + background: #efefef; } .code .gutter-active-line { - background-color: #dcdcdc + background-color: #dcdcdc; } .code .marker-layer .selected-word { - border: 1px solid #D6D6D6 + border: 1px solid #d6d6d6; } .code .invisible { - color: #D1D1D1 + color: #d1d1d1; } .code .keyword, @@ -88,11 +88,11 @@ .code .storage, .code .storage.type, .code .support.type { - color: #8959A8 + color: #8959a8; } .code .keyword.operator { - color: #3E999F + color: #3e999f; } .code .constant.character, @@ -100,44 +100,44 @@ .code .constant.numeric, .code .keyword.other.unit, .code .support.constant { - color: #F5871F + color: #f5871f; } .code .constant.other { - color: #666969 + color: #666969; } .code .invalid { - color: #FFFFFF; - background-color: #C82829 + color: #ffffff; + background-color: #c82829; } .code .invalid.deprecated { - color: #FFFFFF; - background-color: #8959A8 + color: #ffffff; + background-color: #8959a8; } .code .fold { - background-color: #4271AE; - border-color: #4D4D4C + background-color: #4271ae; + border-color: #4d4d4c; } .code .entity.name.function, .code .support.function, .code .variable.parameter, .code .variable { - color: #4271AE + color: #4271ae; } .code .support.class, .code .support.type { - color: #C99E00 + color: #c99e00; } .code .heading, .code .markup.heading, .code .string { - color: #718C00 + color: #718c00; } .code .entity.name.tag, @@ -145,13 +145,14 @@ .code .meta.tag, .code .string.regexp, .code .variable { - color: #C82829 + color: #c82829; } .code .comment { - color: #8E908C + color: #8e908c; } .code .indent-guide { - background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bdu3f/BwAlfgctduB85QAAAABJRU5ErkJggg==) right repeat-y -} \ No newline at end of file + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bdu3f/BwAlfgctduB85QAAAABJRU5ErkJggg==) + right repeat-y; +} diff --git a/plugins/document.schema/assets/line-link.js b/plugins/document.schema/assets/line-link.js index 5ba06240..913799f6 100644 --- a/plugins/document.schema/assets/line-link.js +++ b/plugins/document.schema/assets/line-link.js @@ -1,11 +1,11 @@ (function () { ready(function () { - var tables = window.document.getElementsByClassName('code'); + var tables = window.document.getElementsByClassName("code"); for (var i = 0; i < tables.length; i++) { var table = tables[i]; - table.addEventListener('click', onClick); + table.addEventListener("click", onClick); } window.addEventListener("hashchange", onHashChange, false); @@ -14,58 +14,66 @@ }); function onHashChange() { - var id = window.location.href.split('#')[1]; + var id = window.location.href.split("#")[1]; if (!id) { return; } - var lcid = id.indexOf('C') === -1 ? id.replace('L', 'LC') : id; + var lcid = id.indexOf("C") === -1 ? id.replace("L", "LC") : id; var lineCode = window.document.getElementById(lcid); if (!lineCode) { return; } - var highlighted = lineCode.closest('.code').getElementsByClassName('highlighted'); + var highlighted = lineCode + .closest(".code") + .getElementsByClassName("highlighted"); for (var i = 0; i < highlighted.length; i++) { - highlighted[i].classList.remove('highlighted'); + highlighted[i].classList.remove("highlighted"); } - lineCode.classList.add('highlighted'); + lineCode.classList.add("highlighted"); } function onClick(e) { var target = e.target; - if (!target.classList.contains('td-index')) { + if (!target.classList.contains("td-index")) { return; } - var href = window.location.href.split('#')[0]; + var href = window.location.href.split("#")[0]; - window.location.href = href + '#' + target.id; + window.location.href = href + "#" + target.id; } function ready(fn) { - if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){ + if ( + document.attachEvent + ? document.readyState === "complete" + : document.readyState !== "loading" + ) { fn(); } else { - document.addEventListener('DOMContentLoaded', fn); + document.addEventListener("DOMContentLoaded", fn); } } })(); // https://developer.mozilla.org/ru/docs/Web/API/Element/closest -(function(e){ - e.closest = e.closest || function(css){ - var node = this; - - while (node) { - if (node.matches(css)) return node; - else node = node.parentElement; - } - return null; - } -})(Element.prototype); \ No newline at end of file +(function (e) { + e.closest = + e.closest || + function (css) { + var node = this; + + while (node) { + if (node.matches(css)) return node; + else node = node.parentElement; + } + return null; + }; +})(Element.prototype); diff --git a/plugins/document.schema/index.ts b/plugins/document.schema/index.ts index 41c7aa23..09d516ae 100644 --- a/plugins/document.schema/index.ts +++ b/plugins/document.schema/index.ts @@ -8,7 +8,7 @@ import { InputValue, PluginInterface, Schema, - SchemaType + SchemaType, } from "../../lib/interface"; import { DocumentSection, @@ -19,7 +19,7 @@ import { OBJECT, Plugin, SCALAR, - UNION + UNION, } from "../../lib/utility"; const MAX_CODE_LEN = 80; @@ -32,14 +32,14 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { return [ '', '', - '' + '', ]; } getAssets() { return [ resolve(__dirname, "assets/code.css"), - resolve(__dirname, "assets/line-link.js") + resolve(__dirname, "assets/line-link.js"), ]; } @@ -49,7 +49,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { if (code) { return [ - new DocumentSection("GraphQL Schema definition", this.html.code(code)) + new DocumentSection("GraphQL Schema definition", this.html.code(code)), ]; } @@ -62,7 +62,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { } const directive = this.document.directives.find( - eachDirective => eachDirective.name === (buildForType as string) + (eachDirective) => eachDirective.name === (buildForType as string) ); if (directive) { @@ -70,7 +70,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { } const type = this.document.types.find( - eachType => eachType.name === (buildForType as string) + (eachType) => eachType.name === (buildForType as string) ); if (type) { @@ -117,7 +117,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { return ( "(" + - fieldOrDirectives.args.map(arg => this.argument(arg)).join(", ") + + fieldOrDirectives.args.map((arg) => this.argument(arg)).join(", ") + ")" ); } @@ -162,7 +162,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { descriptions.concat(this.argumentDescription(arg)); return fieldOrDirectives.args.reduce(reduceArguments, [ - this.html.comment("Arguments") + this.html.comment("Arguments"), ]); } @@ -202,10 +202,10 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { description(description: string | null): string[] { if (description) { return wrap(description, { - width: MAX_CODE_LEN + width: MAX_CODE_LEN, }) .split("\n") - .map(l => this.html.comment(l)); + .map((l) => this.html.comment(l)); } return []; @@ -219,7 +219,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { this.arguments(directive) + " on " + directive.locations - .map(location => this.html.keyword(location)) + .map((location) => this.html.keyword(location)) .join(" | ") ); } @@ -227,7 +227,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { enum(type: SchemaType): string { const reduceEnumValues = (lines: string[], enumValue: EnumValue) => lines.concat([""], this.description(enumValue.description), [ - this.html.property(enumValue.name) + this.deprecated(enumValue) + this.html.property(enumValue.name) + this.deprecated(enumValue), ]); return ( @@ -236,7 +236,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { ) + (type.enumValues || []) .reduce(reduceEnumValues, []) - .map(line => this.html.line(this.html.tab(line))) + .map((line) => this.html.line(this.html.tab(line))) .join("") + this.html.line("}") ); @@ -258,11 +258,11 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { // ): ReturnType [@deprecated...] [ this.html.property(field.name) + "(", - ...this.argumentsMultiline(field).map(l => this.html.tab(l)), + ...this.argumentsMultiline(field).map((l) => this.html.tab(l)), "): " + this.html.useIdentifier(field.type, this.url(field.type)) + " " + - this.deprecated(field) + this.deprecated(field), ] : // Single line // fieldName(argumentName: ArgumentType): ReturnType [@deprecated...] @@ -272,14 +272,14 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { ": " + this.html.useIdentifier(field.type, this.url(field.type)) + " " + - this.deprecated(field) + this.deprecated(field), ]; return ([] as string[]) .concat(fieldDescription) .concat(argumentsDescription) .concat(fieldDefinition) - .map(line => this.html.line(this.html.tab(line))) + .map((line) => this.html.line(this.html.tab(line))) .join(""); } @@ -298,7 +298,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { let fields = ""; fields += this.html.line(); fields += (type.fields || []) - .map(field => this.field(field)) + .map((field) => this.field(field)) .join(this.html.line()); if (type.fields && type.fields.length > 0) { @@ -320,7 +320,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { inputValues(inputValues: InputValue[]): string { return inputValues - .map(inputValue => + .map((inputValue) => this.html.line(this.html.tab(this.inputValue(inputValue))) ) .join(""); @@ -334,9 +334,9 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { .concat([ this.html.property(arg.name) + ": " + - this.html.useIdentifier(arg.type, this.url(arg.type)) // + ' ' + this.deprecated(arg) + this.html.useIdentifier(arg.type, this.url(arg.type)), // + ' ' + this.deprecated(arg) ]) - .map(line => this.html.line(this.html.tab(line))) + .map((line) => this.html.line(this.html.tab(line))) .join(""); } @@ -352,7 +352,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { object(type: SchemaType): string { const interfaces = (type.interfaces || []) - .map(i => this.html.useIdentifier(i, this.url(i))) + .map((i) => this.html.useIdentifier(i, this.url(i))) .join(", "); const implement = @@ -386,7 +386,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { definition += this.html.line() + this.description(schema.queryType.description) - .map(line => this.html.line(this.html.tab(line))) + .map((line) => this.html.line(this.html.tab(line))) .join("") + this.html.line( this.html.tab( @@ -404,7 +404,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { definition += this.html.line() + this.description(schema.mutationType.description) - .map(line => this.html.line(this.html.tab(line))) + .map((line) => this.html.line(this.html.tab(line))) .join("") + this.html.line( this.html.tab( @@ -422,7 +422,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { definition += this.html.line() + this.description(schema.subscriptionType.description) - .map(line => this.html.line(this.html.tab(line))) + .map((line) => this.html.line(this.html.tab(line))) .join("") + this.html.line( this.html.tab( @@ -475,7 +475,7 @@ export default class SchemaPlugin extends Plugin implements PluginInterface { this.html.identifier(type) + " = " + (type.possibleTypes || []) - .map(eachType => + .map((eachType) => this.html.useIdentifier(eachType, this.url(eachType)) ) .join(" | ") diff --git a/plugins/navigation.directive.test.ts b/plugins/navigation.directive.test.ts index c50a2983..1afda0d9 100644 --- a/plugins/navigation.directive.test.ts +++ b/plugins/navigation.directive.test.ts @@ -3,22 +3,20 @@ import projectPackage from "../test/empty.package.json"; import schema from "../test/empty.schema.json"; describe("pĺugins/navigation.directive#NavigationDirectives", () => { - test("plugin return empty", () => { const plugin = new NavigationDirectives( { ...schema.data.__schema, - directives: [] + directives: [], }, projectPackage, {} ); - expect(plugin.getNavigations("Query")).toEqual([]) - }) + expect(plugin.getNavigations("Query")).toEqual([]); + }); test("plugin return navigation", () => { - const plugin = new NavigationDirectives( schema.data.__schema, projectPackage, @@ -31,9 +29,9 @@ describe("pĺugins/navigation.directive#NavigationDirectives", () => { items: [ { text: "deprecated", href: "/deprecated.doc.html", isActive: false }, { text: "include", href: "/include.doc.html", isActive: false }, - { text: "skip", href: "/skip.doc.html", isActive: false } - ] - } + { text: "skip", href: "/skip.doc.html", isActive: false }, + ], + }, ]); }); }); diff --git a/plugins/navigation.directive.ts b/plugins/navigation.directive.ts index b933be6e..4079f720 100644 --- a/plugins/navigation.directive.ts +++ b/plugins/navigation.directive.ts @@ -1,11 +1,12 @@ import { NavigationItemInterface, PluginInterface } from "../lib/interface"; import { NavigationItem, NavigationSection, Plugin } from "../lib/utility"; -export default class NavigationDirectives extends Plugin +export default class NavigationDirectives + extends Plugin implements PluginInterface { getTypes(buildForType: string): NavigationItemInterface[] { return this.document.directives.map( - directive => + (directive) => new NavigationItem( directive.name, this.url(directive), diff --git a/plugins/navigation.enum.test.ts b/plugins/navigation.enum.test.ts index 761ede53..1c8438a4 100644 --- a/plugins/navigation.enum.test.ts +++ b/plugins/navigation.enum.test.ts @@ -13,11 +13,15 @@ describe("pĺugins/navigation.directive#NavigationDirectives", () => { {} ); - expect(plugin.getNavigations("Query")).toEqual([]) - }) + expect(plugin.getNavigations("Query")).toEqual([]); + }); test("plugin return navigation", () => { - const plugin = new NavigationEnums(schema.data.__schema, projectPackage, {}); + const plugin = new NavigationEnums( + schema.data.__schema, + projectPackage, + {} + ); expect(plugin.getNavigations("Query")).toEqual([ { title: "Enums", @@ -25,11 +29,11 @@ describe("pĺugins/navigation.directive#NavigationDirectives", () => { { text: "__DirectiveLocation", href: "/directivelocation.spec.html", - isActive: false + isActive: false, }, - { text: "__TypeKind", href: "/typekind.spec.html", isActive: false } - ] - } + { text: "__TypeKind", href: "/typekind.spec.html", isActive: false }, + ], + }, ]); }); }); diff --git a/plugins/navigation.enum.ts b/plugins/navigation.enum.ts index 8a081fed..f222a800 100644 --- a/plugins/navigation.enum.ts +++ b/plugins/navigation.enum.ts @@ -3,15 +3,15 @@ import { ENUM, NavigationItem, NavigationSection, - Plugin + Plugin, } from "../lib/utility"; export default class NavigationEnums extends Plugin implements PluginInterface { getTypes(buildForType: string): NavigationItemInterface[] { return this.document.types - .filter(type => type.kind === ENUM) + .filter((type) => type.kind === ENUM) .map( - type => + (type) => new NavigationItem( type.name, this.url(type), diff --git a/plugins/navigation.input.test.ts b/plugins/navigation.input.test.ts index cb62d488..709808cb 100644 --- a/plugins/navigation.input.test.ts +++ b/plugins/navigation.input.test.ts @@ -13,11 +13,15 @@ describe("pĺugins/navigation.directive#NavigationDirectives", () => { {} ); - expect(plugin.getNavigations("Query")).toEqual([]) - }) + expect(plugin.getNavigations("Query")).toEqual([]); + }); test("plugin return navigation", () => { - const plugin = new NavigationInputs(schema.data.__schema, projectPackage, {}); + const plugin = new NavigationInputs( + schema.data.__schema, + projectPackage, + {} + ); expect(plugin.getNavigations("Query")).toEqual([ { title: "Input Objects", @@ -25,10 +29,10 @@ describe("pĺugins/navigation.directive#NavigationDirectives", () => { { text: "AddCommentInput", href: "/addcommentinput.doc.html", - isActive: false - } - ] - } + isActive: false, + }, + ], + }, ]); }); }); diff --git a/plugins/navigation.input.ts b/plugins/navigation.input.ts index e6a046bb..579f8aee 100644 --- a/plugins/navigation.input.ts +++ b/plugins/navigation.input.ts @@ -3,16 +3,17 @@ import { INPUT_OBJECT, NavigationItem, NavigationSection, - Plugin + Plugin, } from "../lib/utility"; -export default class NavigationInputs extends Plugin +export default class NavigationInputs + extends Plugin implements PluginInterface { getTypes(buildForType: string): NavigationItemInterface[] { return this.document.types - .filter(type => type.kind === INPUT_OBJECT) + .filter((type) => type.kind === INPUT_OBJECT) .map( - type => + (type) => new NavigationItem( type.name, this.url(type), diff --git a/plugins/navigation.interface.test.ts b/plugins/navigation.interface.test.ts index de36f06d..d8f09a95 100644 --- a/plugins/navigation.interface.test.ts +++ b/plugins/navigation.interface.test.ts @@ -13,7 +13,7 @@ describe("pĺugins/navigation.interface#NavigationInterfaces", () => { {} ); - expect(plugin.getNavigations("Query")).toEqual([]) + expect(plugin.getNavigations("Query")).toEqual([]); }); test("plugin return navigation", () => { @@ -28,82 +28,82 @@ describe("pĺugins/navigation.interface#NavigationInterfaces", () => { title: "Interfaces", items: [ { - "href": "/author.doc.html", - "isActive": false, - "text": "Author", + href: "/author.doc.html", + isActive: false, + text: "Author", }, { - "href": "/comment.doc.html", - "isActive": false, - "text": "Comment", + href: "/comment.doc.html", + isActive: false, + text: "Comment", }, { - "href": "/gitobject.doc.html", - "isActive": false, - "text": "GitObject", + href: "/gitobject.doc.html", + isActive: false, + text: "GitObject", }, { - "href": "/gitsignature.doc.html", - "isActive": false, - "text": "GitSignature", + href: "/gitsignature.doc.html", + isActive: false, + text: "GitSignature", }, { - "href": "/issueevent.doc.html", - "isActive": false, - "text": "IssueEvent", + href: "/issueevent.doc.html", + isActive: false, + text: "IssueEvent", }, { - "href": "/issueish.doc.html", - "isActive": false, - "text": "Issueish", + href: "/issueish.doc.html", + isActive: false, + text: "Issueish", }, { - "href": "/node.doc.html", - "isActive": false, - "text": "Node", + href: "/node.doc.html", + isActive: false, + text: "Node", }, { - "href": "/projectowner.doc.html", - "isActive": false, - "text": "ProjectOwner", + href: "/projectowner.doc.html", + isActive: false, + text: "ProjectOwner", }, { - "href": "/reactable.doc.html", - "isActive": false, - "text": "Reactable", + href: "/reactable.doc.html", + isActive: false, + text: "Reactable", }, { - "href": "/repositoryinfo.doc.html", - "isActive": false, - "text": "RepositoryInfo", + href: "/repositoryinfo.doc.html", + isActive: false, + text: "RepositoryInfo", }, { - "href": "/repositorynode.doc.html", - "isActive": false, - "text": "RepositoryNode", + href: "/repositorynode.doc.html", + isActive: false, + text: "RepositoryNode", }, { - "href": "/repositoryowner.doc.html", - "isActive": false, - "text": "RepositoryOwner", + href: "/repositoryowner.doc.html", + isActive: false, + text: "RepositoryOwner", }, { - "href": "/subscribable.doc.html", - "isActive": false, - "text": "Subscribable", + href: "/subscribable.doc.html", + isActive: false, + text: "Subscribable", }, { - "href": "/timeline.doc.html", - "isActive": false, - "text": "Timeline", + href: "/timeline.doc.html", + isActive: false, + text: "Timeline", }, { - "href": "/uniformresourcelocatable.doc.html", - "isActive": false, - "text": "UniformResourceLocatable", + href: "/uniformresourcelocatable.doc.html", + isActive: false, + text: "UniformResourceLocatable", }, - ] - } + ], + }, ]); }); }); diff --git a/plugins/navigation.interface.ts b/plugins/navigation.interface.ts index c662c5fa..37032be8 100644 --- a/plugins/navigation.interface.ts +++ b/plugins/navigation.interface.ts @@ -3,16 +3,17 @@ import { INTERFACE, NavigationItem, NavigationSection, - Plugin + Plugin, } from "../lib/utility"; -export default class NavigationInterfaces extends Plugin +export default class NavigationInterfaces + extends Plugin implements PluginInterface { getTypes(buildForType: string): NavigationItemInterface[] { return this.document.types - .filter(type => type.kind === INTERFACE) + .filter((type) => type.kind === INTERFACE) .map( - type => + (type) => new NavigationItem( type.name, this.url(type), diff --git a/plugins/navigation.object.test.ts b/plugins/navigation.object.test.ts index 5dfb1008..4e84f759 100644 --- a/plugins/navigation.object.test.ts +++ b/plugins/navigation.object.test.ts @@ -13,857 +13,861 @@ describe("pĺugins/navigation.directive#NavigationDirectives", () => { {} ); - expect(plugin.getNavigations("Query")).toEqual([]) - }) + expect(plugin.getNavigations("Query")).toEqual([]); + }); test("plugin return navigation", () => { - const plugin = new NavigationObject(schema.data.__schema, projectPackage, {}); + const plugin = new NavigationObject( + schema.data.__schema, + projectPackage, + {} + ); expect(plugin.getNavigations("Query")).toEqual([ { title: "Objects", items: [ { - "href": "/addcommentpayload.doc.html", - "isActive": false, - "text": "AddCommentPayload", + href: "/addcommentpayload.doc.html", + isActive: false, + text: "AddCommentPayload", }, { - "href": "/addprojectcardpayload.doc.html", - "isActive": false, - "text": "AddProjectCardPayload", + href: "/addprojectcardpayload.doc.html", + isActive: false, + text: "AddProjectCardPayload", }, { - "href": "/addprojectcolumnpayload.doc.html", - "isActive": false, - "text": "AddProjectColumnPayload", + href: "/addprojectcolumnpayload.doc.html", + isActive: false, + text: "AddProjectColumnPayload", }, { - "href": "/addpullrequestreviewcommentpayload.doc.html", - "isActive": false, - "text": "AddPullRequestReviewCommentPayload", + href: "/addpullrequestreviewcommentpayload.doc.html", + isActive: false, + text: "AddPullRequestReviewCommentPayload", }, { - "href": "/addpullrequestreviewpayload.doc.html", - "isActive": false, - "text": "AddPullRequestReviewPayload", + href: "/addpullrequestreviewpayload.doc.html", + isActive: false, + text: "AddPullRequestReviewPayload", }, { - "href": "/addreactionpayload.doc.html", - "isActive": false, - "text": "AddReactionPayload", + href: "/addreactionpayload.doc.html", + isActive: false, + text: "AddReactionPayload", }, { - "href": "/assignedevent.doc.html", - "isActive": false, - "text": "AssignedEvent", + href: "/assignedevent.doc.html", + isActive: false, + text: "AssignedEvent", }, { - "href": "/baserefforcepushedevent.doc.html", - "isActive": false, - "text": "BaseRefForcePushedEvent", + href: "/baserefforcepushedevent.doc.html", + isActive: false, + text: "BaseRefForcePushedEvent", }, { - "href": "/blame.doc.html", - "isActive": false, - "text": "Blame", + href: "/blame.doc.html", + isActive: false, + text: "Blame", }, { - "href": "/blamerange.doc.html", - "isActive": false, - "text": "BlameRange", + href: "/blamerange.doc.html", + isActive: false, + text: "BlameRange", }, { - "href": "/blob.doc.html", - "isActive": false, - "text": "Blob", + href: "/blob.doc.html", + isActive: false, + text: "Blob", }, { - "href": "/bot.doc.html", - "isActive": false, - "text": "Bot", + href: "/bot.doc.html", + isActive: false, + text: "Bot", }, { - "href": "/closedevent.doc.html", - "isActive": false, - "text": "ClosedEvent", + href: "/closedevent.doc.html", + isActive: false, + text: "ClosedEvent", }, { - "href": "/commit.doc.html", - "isActive": false, - "text": "Commit", + href: "/commit.doc.html", + isActive: false, + text: "Commit", }, { - "href": "/commitcomment.doc.html", - "isActive": false, - "text": "CommitComment", + href: "/commitcomment.doc.html", + isActive: false, + text: "CommitComment", }, { - "href": "/commitcommentconnection.doc.html", - "isActive": false, - "text": "CommitCommentConnection", + href: "/commitcommentconnection.doc.html", + isActive: false, + text: "CommitCommentConnection", }, { - "href": "/commitcommentedge.doc.html", - "isActive": false, - "text": "CommitCommentEdge", + href: "/commitcommentedge.doc.html", + isActive: false, + text: "CommitCommentEdge", }, { - "href": "/commitconnection.doc.html", - "isActive": false, - "text": "CommitConnection", + href: "/commitconnection.doc.html", + isActive: false, + text: "CommitConnection", }, { - "href": "/commitedge.doc.html", - "isActive": false, - "text": "CommitEdge", + href: "/commitedge.doc.html", + isActive: false, + text: "CommitEdge", }, { - "href": "/commithistoryconnection.doc.html", - "isActive": false, - "text": "CommitHistoryConnection", + href: "/commithistoryconnection.doc.html", + isActive: false, + text: "CommitHistoryConnection", }, { - "href": "/createprojectpayload.doc.html", - "isActive": false, - "text": "CreateProjectPayload", + href: "/createprojectpayload.doc.html", + isActive: false, + text: "CreateProjectPayload", }, { - "href": "/deleteprojectcardpayload.doc.html", - "isActive": false, - "text": "DeleteProjectCardPayload", + href: "/deleteprojectcardpayload.doc.html", + isActive: false, + text: "DeleteProjectCardPayload", }, { - "href": "/deleteprojectcolumnpayload.doc.html", - "isActive": false, - "text": "DeleteProjectColumnPayload", + href: "/deleteprojectcolumnpayload.doc.html", + isActive: false, + text: "DeleteProjectColumnPayload", }, { - "href": "/deleteprojectpayload.doc.html", - "isActive": false, - "text": "DeleteProjectPayload", + href: "/deleteprojectpayload.doc.html", + isActive: false, + text: "DeleteProjectPayload", }, { - "href": "/deletepullrequestreviewpayload.doc.html", - "isActive": false, - "text": "DeletePullRequestReviewPayload", + href: "/deletepullrequestreviewpayload.doc.html", + isActive: false, + text: "DeletePullRequestReviewPayload", }, { - "href": "/demilestonedevent.doc.html", - "isActive": false, - "text": "DemilestonedEvent", + href: "/demilestonedevent.doc.html", + isActive: false, + text: "DemilestonedEvent", }, { - "href": "/deployedevent.doc.html", - "isActive": false, - "text": "DeployedEvent", + href: "/deployedevent.doc.html", + isActive: false, + text: "DeployedEvent", }, { - "href": "/deployment.doc.html", - "isActive": false, - "text": "Deployment", + href: "/deployment.doc.html", + isActive: false, + text: "Deployment", }, { - "href": "/deploymentstatus.doc.html", - "isActive": false, - "text": "DeploymentStatus", + href: "/deploymentstatus.doc.html", + isActive: false, + text: "DeploymentStatus", }, { - "href": "/deploymentstatusconnection.doc.html", - "isActive": false, - "text": "DeploymentStatusConnection", + href: "/deploymentstatusconnection.doc.html", + isActive: false, + text: "DeploymentStatusConnection", }, { - "href": "/deploymentstatusedge.doc.html", - "isActive": false, - "text": "DeploymentStatusEdge", + href: "/deploymentstatusedge.doc.html", + isActive: false, + text: "DeploymentStatusEdge", }, { - "href": "/dismisspullrequestreviewpayload.doc.html", - "isActive": false, - "text": "DismissPullRequestReviewPayload", + href: "/dismisspullrequestreviewpayload.doc.html", + isActive: false, + text: "DismissPullRequestReviewPayload", }, { - "href": "/followerconnection.doc.html", - "isActive": false, - "text": "FollowerConnection", + href: "/followerconnection.doc.html", + isActive: false, + text: "FollowerConnection", }, { - "href": "/followingconnection.doc.html", - "isActive": false, - "text": "FollowingConnection", + href: "/followingconnection.doc.html", + isActive: false, + text: "FollowingConnection", }, { - "href": "/gist.doc.html", - "isActive": false, - "text": "Gist", + href: "/gist.doc.html", + isActive: false, + text: "Gist", }, { - "href": "/gistcomment.doc.html", - "isActive": false, - "text": "GistComment", + href: "/gistcomment.doc.html", + isActive: false, + text: "GistComment", }, { - "href": "/gistconnection.doc.html", - "isActive": false, - "text": "GistConnection", + href: "/gistconnection.doc.html", + isActive: false, + text: "GistConnection", }, { - "href": "/gistedge.doc.html", - "isActive": false, - "text": "GistEdge", + href: "/gistedge.doc.html", + isActive: false, + text: "GistEdge", }, { - "href": "/gitactor.doc.html", - "isActive": false, - "text": "GitActor", + href: "/gitactor.doc.html", + isActive: false, + text: "GitActor", }, { - "href": "/gpgsignature.doc.html", - "isActive": false, - "text": "GpgSignature", + href: "/gpgsignature.doc.html", + isActive: false, + text: "GpgSignature", }, { - "href": "/headrefdeletedevent.doc.html", - "isActive": false, - "text": "HeadRefDeletedEvent", + href: "/headrefdeletedevent.doc.html", + isActive: false, + text: "HeadRefDeletedEvent", }, { - "href": "/headrefforcepushedevent.doc.html", - "isActive": false, - "text": "HeadRefForcePushedEvent", + href: "/headrefforcepushedevent.doc.html", + isActive: false, + text: "HeadRefForcePushedEvent", }, { - "href": "/headrefrestoredevent.doc.html", - "isActive": false, - "text": "HeadRefRestoredEvent", + href: "/headrefrestoredevent.doc.html", + isActive: false, + text: "HeadRefRestoredEvent", }, { - "href": "/issue.doc.html", - "isActive": false, - "text": "Issue", + href: "/issue.doc.html", + isActive: false, + text: "Issue", }, { - "href": "/issuecomment.doc.html", - "isActive": false, - "text": "IssueComment", + href: "/issuecomment.doc.html", + isActive: false, + text: "IssueComment", }, { - "href": "/issuecommentconnection.doc.html", - "isActive": false, - "text": "IssueCommentConnection", + href: "/issuecommentconnection.doc.html", + isActive: false, + text: "IssueCommentConnection", }, { - "href": "/issuecommentedge.doc.html", - "isActive": false, - "text": "IssueCommentEdge", + href: "/issuecommentedge.doc.html", + isActive: false, + text: "IssueCommentEdge", }, { - "href": "/issueconnection.doc.html", - "isActive": false, - "text": "IssueConnection", + href: "/issueconnection.doc.html", + isActive: false, + text: "IssueConnection", }, { - "href": "/issueedge.doc.html", - "isActive": false, - "text": "IssueEdge", + href: "/issueedge.doc.html", + isActive: false, + text: "IssueEdge", }, { - "href": "/issuetimelineconnection.doc.html", - "isActive": false, - "text": "IssueTimelineConnection", + href: "/issuetimelineconnection.doc.html", + isActive: false, + text: "IssueTimelineConnection", }, { - "href": "/issuetimelineitemedge.doc.html", - "isActive": false, - "text": "IssueTimelineItemEdge", + href: "/issuetimelineitemedge.doc.html", + isActive: false, + text: "IssueTimelineItemEdge", }, { - "href": "/label.doc.html", - "isActive": false, - "text": "Label", + href: "/label.doc.html", + isActive: false, + text: "Label", }, { - "href": "/labelconnection.doc.html", - "isActive": false, - "text": "LabelConnection", + href: "/labelconnection.doc.html", + isActive: false, + text: "LabelConnection", }, { - "href": "/labeledevent.doc.html", - "isActive": false, - "text": "LabeledEvent", + href: "/labeledevent.doc.html", + isActive: false, + text: "LabeledEvent", }, { - "href": "/labeledge.doc.html", - "isActive": false, - "text": "LabelEdge", + href: "/labeledge.doc.html", + isActive: false, + text: "LabelEdge", }, { - "href": "/language.doc.html", - "isActive": false, - "text": "Language", + href: "/language.doc.html", + isActive: false, + text: "Language", }, { - "href": "/languageconnection.doc.html", - "isActive": false, - "text": "LanguageConnection", + href: "/languageconnection.doc.html", + isActive: false, + text: "LanguageConnection", }, { - "href": "/languageedge.doc.html", - "isActive": false, - "text": "LanguageEdge", + href: "/languageedge.doc.html", + isActive: false, + text: "LanguageEdge", }, { - "href": "/lockedevent.doc.html", - "isActive": false, - "text": "LockedEvent", + href: "/lockedevent.doc.html", + isActive: false, + text: "LockedEvent", }, { - "href": "/mentionedevent.doc.html", - "isActive": false, - "text": "MentionedEvent", + href: "/mentionedevent.doc.html", + isActive: false, + text: "MentionedEvent", }, { - "href": "/mergedevent.doc.html", - "isActive": false, - "text": "MergedEvent", + href: "/mergedevent.doc.html", + isActive: false, + text: "MergedEvent", }, { - "href": "/milestone.doc.html", - "isActive": false, - "text": "Milestone", + href: "/milestone.doc.html", + isActive: false, + text: "Milestone", }, { - "href": "/milestoneconnection.doc.html", - "isActive": false, - "text": "MilestoneConnection", + href: "/milestoneconnection.doc.html", + isActive: false, + text: "MilestoneConnection", }, { - "href": "/milestonedevent.doc.html", - "isActive": false, - "text": "MilestonedEvent", + href: "/milestonedevent.doc.html", + isActive: false, + text: "MilestonedEvent", }, { - "href": "/milestoneedge.doc.html", - "isActive": false, - "text": "MilestoneEdge", + href: "/milestoneedge.doc.html", + isActive: false, + text: "MilestoneEdge", }, { - "href": "/moveprojectcardpayload.doc.html", - "isActive": false, - "text": "MoveProjectCardPayload", + href: "/moveprojectcardpayload.doc.html", + isActive: false, + text: "MoveProjectCardPayload", }, { - "href": "/moveprojectcolumnpayload.doc.html", - "isActive": false, - "text": "MoveProjectColumnPayload", + href: "/moveprojectcolumnpayload.doc.html", + isActive: false, + text: "MoveProjectColumnPayload", }, { - "href": "/organization.doc.html", - "isActive": false, - "text": "Organization", + href: "/organization.doc.html", + isActive: false, + text: "Organization", }, { - "href": "/organizationconnection.doc.html", - "isActive": false, - "text": "OrganizationConnection", + href: "/organizationconnection.doc.html", + isActive: false, + text: "OrganizationConnection", }, { - "href": "/organizationedge.doc.html", - "isActive": false, - "text": "OrganizationEdge", + href: "/organizationedge.doc.html", + isActive: false, + text: "OrganizationEdge", }, { - "href": "/organizationinvitation.doc.html", - "isActive": false, - "text": "OrganizationInvitation", + href: "/organizationinvitation.doc.html", + isActive: false, + text: "OrganizationInvitation", }, { - "href": "/organizationinvitationconnection.doc.html", - "isActive": false, - "text": "OrganizationInvitationConnection", + href: "/organizationinvitationconnection.doc.html", + isActive: false, + text: "OrganizationInvitationConnection", }, { - "href": "/organizationinvitationedge.doc.html", - "isActive": false, - "text": "OrganizationInvitationEdge", + href: "/organizationinvitationedge.doc.html", + isActive: false, + text: "OrganizationInvitationEdge", }, { - "href": "/pageinfo.doc.html", - "isActive": false, - "text": "PageInfo", + href: "/pageinfo.doc.html", + isActive: false, + text: "PageInfo", }, { - "href": "/project.doc.html", - "isActive": false, - "text": "Project", + href: "/project.doc.html", + isActive: false, + text: "Project", }, { - "href": "/projectcard.doc.html", - "isActive": false, - "text": "ProjectCard", + href: "/projectcard.doc.html", + isActive: false, + text: "ProjectCard", }, { - "href": "/projectcardconnection.doc.html", - "isActive": false, - "text": "ProjectCardConnection", + href: "/projectcardconnection.doc.html", + isActive: false, + text: "ProjectCardConnection", }, { - "href": "/projectcardedge.doc.html", - "isActive": false, - "text": "ProjectCardEdge", + href: "/projectcardedge.doc.html", + isActive: false, + text: "ProjectCardEdge", }, { - "href": "/projectcolumn.doc.html", - "isActive": false, - "text": "ProjectColumn", + href: "/projectcolumn.doc.html", + isActive: false, + text: "ProjectColumn", }, { - "href": "/projectcolumnconnection.doc.html", - "isActive": false, - "text": "ProjectColumnConnection", + href: "/projectcolumnconnection.doc.html", + isActive: false, + text: "ProjectColumnConnection", }, { - "href": "/projectcolumnedge.doc.html", - "isActive": false, - "text": "ProjectColumnEdge", + href: "/projectcolumnedge.doc.html", + isActive: false, + text: "ProjectColumnEdge", }, { - "href": "/projectconnection.doc.html", - "isActive": false, - "text": "ProjectConnection", + href: "/projectconnection.doc.html", + isActive: false, + text: "ProjectConnection", }, { - "href": "/projectedge.doc.html", - "isActive": false, - "text": "ProjectEdge", + href: "/projectedge.doc.html", + isActive: false, + text: "ProjectEdge", }, { - "href": "/protectedbranch.doc.html", - "isActive": false, - "text": "ProtectedBranch", + href: "/protectedbranch.doc.html", + isActive: false, + text: "ProtectedBranch", }, { - "href": "/protectedbranchconnection.doc.html", - "isActive": false, - "text": "ProtectedBranchConnection", + href: "/protectedbranchconnection.doc.html", + isActive: false, + text: "ProtectedBranchConnection", }, { - "href": "/protectedbranchedge.doc.html", - "isActive": false, - "text": "ProtectedBranchEdge", + href: "/protectedbranchedge.doc.html", + isActive: false, + text: "ProtectedBranchEdge", }, { - "href": "/pullrequest.doc.html", - "isActive": false, - "text": "PullRequest", + href: "/pullrequest.doc.html", + isActive: false, + text: "PullRequest", }, { - "href": "/pullrequestconnection.doc.html", - "isActive": false, - "text": "PullRequestConnection", + href: "/pullrequestconnection.doc.html", + isActive: false, + text: "PullRequestConnection", }, { - "href": "/pullrequestedge.doc.html", - "isActive": false, - "text": "PullRequestEdge", + href: "/pullrequestedge.doc.html", + isActive: false, + text: "PullRequestEdge", }, { - "href": "/pullrequestreview.doc.html", - "isActive": false, - "text": "PullRequestReview", + href: "/pullrequestreview.doc.html", + isActive: false, + text: "PullRequestReview", }, { - "href": "/pullrequestreviewcomment.doc.html", - "isActive": false, - "text": "PullRequestReviewComment", + href: "/pullrequestreviewcomment.doc.html", + isActive: false, + text: "PullRequestReviewComment", }, { - "href": "/pullrequestreviewcommentconnection.doc.html", - "isActive": false, - "text": "PullRequestReviewCommentConnection", + href: "/pullrequestreviewcommentconnection.doc.html", + isActive: false, + text: "PullRequestReviewCommentConnection", }, { - "href": "/pullrequestreviewcommentedge.doc.html", - "isActive": false, - "text": "PullRequestReviewCommentEdge", + href: "/pullrequestreviewcommentedge.doc.html", + isActive: false, + text: "PullRequestReviewCommentEdge", }, { - "href": "/pullrequestreviewconnection.doc.html", - "isActive": false, - "text": "PullRequestReviewConnection", + href: "/pullrequestreviewconnection.doc.html", + isActive: false, + text: "PullRequestReviewConnection", }, { - "href": "/pullrequestreviewedge.doc.html", - "isActive": false, - "text": "PullRequestReviewEdge", + href: "/pullrequestreviewedge.doc.html", + isActive: false, + text: "PullRequestReviewEdge", }, { - "href": "/pullrequestreviewthread.doc.html", - "isActive": false, - "text": "PullRequestReviewThread", + href: "/pullrequestreviewthread.doc.html", + isActive: false, + text: "PullRequestReviewThread", }, { - "href": "/reactinguserconnection.doc.html", - "isActive": false, - "text": "ReactingUserConnection", + href: "/reactinguserconnection.doc.html", + isActive: false, + text: "ReactingUserConnection", }, { - "href": "/reactinguseredge.doc.html", - "isActive": false, - "text": "ReactingUserEdge", + href: "/reactinguseredge.doc.html", + isActive: false, + text: "ReactingUserEdge", }, { - "href": "/reaction.doc.html", - "isActive": false, - "text": "Reaction", + href: "/reaction.doc.html", + isActive: false, + text: "Reaction", }, { - "href": "/reactionconnection.doc.html", - "isActive": false, - "text": "ReactionConnection", + href: "/reactionconnection.doc.html", + isActive: false, + text: "ReactionConnection", }, { - "href": "/reactionedge.doc.html", - "isActive": false, - "text": "ReactionEdge", + href: "/reactionedge.doc.html", + isActive: false, + text: "ReactionEdge", }, { - "href": "/reactiongroup.doc.html", - "isActive": false, - "text": "ReactionGroup", + href: "/reactiongroup.doc.html", + isActive: false, + text: "ReactionGroup", }, { - "href": "/ref.doc.html", - "isActive": false, - "text": "Ref", + href: "/ref.doc.html", + isActive: false, + text: "Ref", }, { - "href": "/refconnection.doc.html", - "isActive": false, - "text": "RefConnection", + href: "/refconnection.doc.html", + isActive: false, + text: "RefConnection", }, { - "href": "/refedge.doc.html", - "isActive": false, - "text": "RefEdge", + href: "/refedge.doc.html", + isActive: false, + text: "RefEdge", }, { - "href": "/referencedevent.doc.html", - "isActive": false, - "text": "ReferencedEvent", + href: "/referencedevent.doc.html", + isActive: false, + text: "ReferencedEvent", }, { - "href": "/release.doc.html", - "isActive": false, - "text": "Release", + href: "/release.doc.html", + isActive: false, + text: "Release", }, { - "href": "/releaseasset.doc.html", - "isActive": false, - "text": "ReleaseAsset", + href: "/releaseasset.doc.html", + isActive: false, + text: "ReleaseAsset", }, { - "href": "/releaseassetconnection.doc.html", - "isActive": false, - "text": "ReleaseAssetConnection", + href: "/releaseassetconnection.doc.html", + isActive: false, + text: "ReleaseAssetConnection", }, { - "href": "/releaseassetedge.doc.html", - "isActive": false, - "text": "ReleaseAssetEdge", + href: "/releaseassetedge.doc.html", + isActive: false, + text: "ReleaseAssetEdge", }, { - "href": "/releaseconnection.doc.html", - "isActive": false, - "text": "ReleaseConnection", + href: "/releaseconnection.doc.html", + isActive: false, + text: "ReleaseConnection", }, { - "href": "/releaseedge.doc.html", - "isActive": false, - "text": "ReleaseEdge", + href: "/releaseedge.doc.html", + isActive: false, + text: "ReleaseEdge", }, { - "href": "/removeoutsidecollaboratorpayload.doc.html", - "isActive": false, - "text": "RemoveOutsideCollaboratorPayload", + href: "/removeoutsidecollaboratorpayload.doc.html", + isActive: false, + text: "RemoveOutsideCollaboratorPayload", }, { - "href": "/removereactionpayload.doc.html", - "isActive": false, - "text": "RemoveReactionPayload", + href: "/removereactionpayload.doc.html", + isActive: false, + text: "RemoveReactionPayload", }, { - "href": "/renamedevent.doc.html", - "isActive": false, - "text": "RenamedEvent", + href: "/renamedevent.doc.html", + isActive: false, + text: "RenamedEvent", }, { - "href": "/reopenedevent.doc.html", - "isActive": false, - "text": "ReopenedEvent", + href: "/reopenedevent.doc.html", + isActive: false, + text: "ReopenedEvent", }, { - "href": "/repository.doc.html", - "isActive": false, - "text": "Repository", + href: "/repository.doc.html", + isActive: false, + text: "Repository", }, { - "href": "/repositoryconnection.doc.html", - "isActive": false, - "text": "RepositoryConnection", + href: "/repositoryconnection.doc.html", + isActive: false, + text: "RepositoryConnection", }, { - "href": "/repositoryedge.doc.html", - "isActive": false, - "text": "RepositoryEdge", + href: "/repositoryedge.doc.html", + isActive: false, + text: "RepositoryEdge", }, { - "href": "/repositoryinvitation.doc.html", - "isActive": false, - "text": "RepositoryInvitation", + href: "/repositoryinvitation.doc.html", + isActive: false, + text: "RepositoryInvitation", }, { - "href": "/repositoryinvitationrepository.doc.html", - "isActive": false, - "text": "RepositoryInvitationRepository", + href: "/repositoryinvitationrepository.doc.html", + isActive: false, + text: "RepositoryInvitationRepository", }, { - "href": "/requestreviewspayload.doc.html", - "isActive": false, - "text": "RequestReviewsPayload", + href: "/requestreviewspayload.doc.html", + isActive: false, + text: "RequestReviewsPayload", }, { - "href": "/reviewdismissalallowance.doc.html", - "isActive": false, - "text": "ReviewDismissalAllowance", + href: "/reviewdismissalallowance.doc.html", + isActive: false, + text: "ReviewDismissalAllowance", }, { - "href": "/reviewdismissalallowanceconnection.doc.html", - "isActive": false, - "text": "ReviewDismissalAllowanceConnection", + href: "/reviewdismissalallowanceconnection.doc.html", + isActive: false, + text: "ReviewDismissalAllowanceConnection", }, { - "href": "/reviewdismissalallowanceedge.doc.html", - "isActive": false, - "text": "ReviewDismissalAllowanceEdge", + href: "/reviewdismissalallowanceedge.doc.html", + isActive: false, + text: "ReviewDismissalAllowanceEdge", }, { - "href": "/reviewdismissedevent.doc.html", - "isActive": false, - "text": "ReviewDismissedEvent", + href: "/reviewdismissedevent.doc.html", + isActive: false, + text: "ReviewDismissedEvent", }, { - "href": "/reviewrequest.doc.html", - "isActive": false, - "text": "ReviewRequest", + href: "/reviewrequest.doc.html", + isActive: false, + text: "ReviewRequest", }, { - "href": "/reviewrequestconnection.doc.html", - "isActive": false, - "text": "ReviewRequestConnection", + href: "/reviewrequestconnection.doc.html", + isActive: false, + text: "ReviewRequestConnection", }, { - "href": "/reviewrequestedevent.doc.html", - "isActive": false, - "text": "ReviewRequestedEvent", + href: "/reviewrequestedevent.doc.html", + isActive: false, + text: "ReviewRequestedEvent", }, { - "href": "/reviewrequestedge.doc.html", - "isActive": false, - "text": "ReviewRequestEdge", + href: "/reviewrequestedge.doc.html", + isActive: false, + text: "ReviewRequestEdge", }, { - "href": "/reviewrequestremovedevent.doc.html", - "isActive": false, - "text": "ReviewRequestRemovedEvent", + href: "/reviewrequestremovedevent.doc.html", + isActive: false, + text: "ReviewRequestRemovedEvent", }, { - "href": "/searchresultitemconnection.doc.html", - "isActive": false, - "text": "SearchResultItemConnection", + href: "/searchresultitemconnection.doc.html", + isActive: false, + text: "SearchResultItemConnection", }, { - "href": "/searchresultitemedge.doc.html", - "isActive": false, - "text": "SearchResultItemEdge", + href: "/searchresultitemedge.doc.html", + isActive: false, + text: "SearchResultItemEdge", }, { - "href": "/smimesignature.doc.html", - "isActive": false, - "text": "SmimeSignature", + href: "/smimesignature.doc.html", + isActive: false, + text: "SmimeSignature", }, { - "href": "/stargazerconnection.doc.html", - "isActive": false, - "text": "StargazerConnection", + href: "/stargazerconnection.doc.html", + isActive: false, + text: "StargazerConnection", }, { - "href": "/stargazeredge.doc.html", - "isActive": false, - "text": "StargazerEdge", + href: "/stargazeredge.doc.html", + isActive: false, + text: "StargazerEdge", }, { - "href": "/starredrepositoryconnection.doc.html", - "isActive": false, - "text": "StarredRepositoryConnection", + href: "/starredrepositoryconnection.doc.html", + isActive: false, + text: "StarredRepositoryConnection", }, { - "href": "/starredrepositoryedge.doc.html", - "isActive": false, - "text": "StarredRepositoryEdge", + href: "/starredrepositoryedge.doc.html", + isActive: false, + text: "StarredRepositoryEdge", }, { - "href": "/status.doc.html", - "isActive": false, - "text": "Status", + href: "/status.doc.html", + isActive: false, + text: "Status", }, { - "href": "/statuscontext.doc.html", - "isActive": false, - "text": "StatusContext", + href: "/statuscontext.doc.html", + isActive: false, + text: "StatusContext", }, { - "href": "/submitpullrequestreviewpayload.doc.html", - "isActive": false, - "text": "SubmitPullRequestReviewPayload", + href: "/submitpullrequestreviewpayload.doc.html", + isActive: false, + text: "SubmitPullRequestReviewPayload", }, { - "href": "/subscribedevent.doc.html", - "isActive": false, - "text": "SubscribedEvent", + href: "/subscribedevent.doc.html", + isActive: false, + text: "SubscribedEvent", }, { - "href": "/tag.doc.html", - "isActive": false, - "text": "Tag", + href: "/tag.doc.html", + isActive: false, + text: "Tag", }, { - "href": "/team.doc.html", - "isActive": false, - "text": "Team", + href: "/team.doc.html", + isActive: false, + text: "Team", }, { - "href": "/teamconnection.doc.html", - "isActive": false, - "text": "TeamConnection", + href: "/teamconnection.doc.html", + isActive: false, + text: "TeamConnection", }, { - "href": "/teamedge.doc.html", - "isActive": false, - "text": "TeamEdge", + href: "/teamedge.doc.html", + isActive: false, + text: "TeamEdge", }, { - "href": "/tree.doc.html", - "isActive": false, - "text": "Tree", + href: "/tree.doc.html", + isActive: false, + text: "Tree", }, { - "href": "/treeentry.doc.html", - "isActive": false, - "text": "TreeEntry", + href: "/treeentry.doc.html", + isActive: false, + text: "TreeEntry", }, { - "href": "/unassignedevent.doc.html", - "isActive": false, - "text": "UnassignedEvent", + href: "/unassignedevent.doc.html", + isActive: false, + text: "UnassignedEvent", }, { - "href": "/unknownsignature.doc.html", - "isActive": false, - "text": "UnknownSignature", + href: "/unknownsignature.doc.html", + isActive: false, + text: "UnknownSignature", }, { - "href": "/unlabeledevent.doc.html", - "isActive": false, - "text": "UnlabeledEvent", + href: "/unlabeledevent.doc.html", + isActive: false, + text: "UnlabeledEvent", }, { - "href": "/unlockedevent.doc.html", - "isActive": false, - "text": "UnlockedEvent", + href: "/unlockedevent.doc.html", + isActive: false, + text: "UnlockedEvent", }, { - "href": "/unsubscribedevent.doc.html", - "isActive": false, - "text": "UnsubscribedEvent", + href: "/unsubscribedevent.doc.html", + isActive: false, + text: "UnsubscribedEvent", }, { - "href": "/updateprojectcardpayload.doc.html", - "isActive": false, - "text": "UpdateProjectCardPayload", + href: "/updateprojectcardpayload.doc.html", + isActive: false, + text: "UpdateProjectCardPayload", }, { - "href": "/updateprojectcolumnpayload.doc.html", - "isActive": false, - "text": "UpdateProjectColumnPayload", + href: "/updateprojectcolumnpayload.doc.html", + isActive: false, + text: "UpdateProjectColumnPayload", }, { - "href": "/updateprojectpayload.doc.html", - "isActive": false, - "text": "UpdateProjectPayload", + href: "/updateprojectpayload.doc.html", + isActive: false, + text: "UpdateProjectPayload", }, { - "href": "/updatepullrequestreviewcommentpayload.doc.html", - "isActive": false, - "text": "UpdatePullRequestReviewCommentPayload", + href: "/updatepullrequestreviewcommentpayload.doc.html", + isActive: false, + text: "UpdatePullRequestReviewCommentPayload", }, { - "href": "/updatepullrequestreviewpayload.doc.html", - "isActive": false, - "text": "UpdatePullRequestReviewPayload", + href: "/updatepullrequestreviewpayload.doc.html", + isActive: false, + text: "UpdatePullRequestReviewPayload", }, { - "href": "/updatesubscriptionpayload.doc.html", - "isActive": false, - "text": "UpdateSubscriptionPayload", + href: "/updatesubscriptionpayload.doc.html", + isActive: false, + text: "UpdateSubscriptionPayload", }, { - "href": "/user.doc.html", - "isActive": false, - "text": "User", + href: "/user.doc.html", + isActive: false, + text: "User", }, { - "href": "/userconnection.doc.html", - "isActive": false, - "text": "UserConnection", + href: "/userconnection.doc.html", + isActive: false, + text: "UserConnection", }, { - "href": "/useredge.doc.html", - "isActive": false, - "text": "UserEdge", + href: "/useredge.doc.html", + isActive: false, + text: "UserEdge", }, { - "href": "/directive.spec.html", - "isActive": false, - "text": "__Directive", + href: "/directive.spec.html", + isActive: false, + text: "__Directive", }, { - "href": "/enumvalue.spec.html", - "isActive": false, - "text": "__EnumValue", + href: "/enumvalue.spec.html", + isActive: false, + text: "__EnumValue", }, { - "href": "/field.spec.html", - "isActive": false, - "text": "__Field", + href: "/field.spec.html", + isActive: false, + text: "__Field", }, { - "href": "/inputvalue.spec.html", - "isActive": false, - "text": "__InputValue", + href: "/inputvalue.spec.html", + isActive: false, + text: "__InputValue", }, { - "href": "/schema.spec.html", - "isActive": false, - "text": "__Schema", + href: "/schema.spec.html", + isActive: false, + text: "__Schema", }, { - "href": "/type.spec.html", - "isActive": false, - "text": "__Type", + href: "/type.spec.html", + isActive: false, + text: "__Type", }, - ] - } + ], + }, ]); }); }); diff --git a/plugins/navigation.object.ts b/plugins/navigation.object.ts index 3604c7e1..658645b1 100644 --- a/plugins/navigation.object.ts +++ b/plugins/navigation.object.ts @@ -3,13 +3,14 @@ import { NavigationItem, NavigationSection, OBJECT, - Plugin + Plugin, } from "../lib/utility"; -export default class NavigationObjects extends Plugin +export default class NavigationObjects + extends Plugin implements PluginInterface { getTypes(buildForType: string): NavigationItemInterface[] { - const obj = this.document.types.filter(type => { + const obj = this.document.types.filter((type) => { return ( type.kind === OBJECT && (!this.queryType || this.queryType.name !== type.name) && @@ -19,7 +20,7 @@ export default class NavigationObjects extends Plugin }); return obj.map( - type => + (type) => new NavigationItem( type.name, this.url(type), diff --git a/plugins/navigation.scalar.test.ts b/plugins/navigation.scalar.test.ts index 91574ac5..87492a7b 100644 --- a/plugins/navigation.scalar.test.ts +++ b/plugins/navigation.scalar.test.ts @@ -13,47 +13,51 @@ describe("pĺugins/navigation.directive#NavigationDirectives", () => { {} ); - expect(plugin.getNavigations("Query")).toEqual([]) - }) + expect(plugin.getNavigations("Query")).toEqual([]); + }); test("plugin return navigation", () => { - const plugin = new NavigationScalar(schema.data.__schema, projectPackage, {}); + const plugin = new NavigationScalar( + schema.data.__schema, + projectPackage, + {} + ); expect(plugin.getNavigations("Query")).toEqual([ { title: "Objects", items: [ { - "href": "/directive.spec.html", - "isActive": false, - "text": "__Directive", + href: "/directive.spec.html", + isActive: false, + text: "__Directive", }, { - "href": "/enumvalue.spec.html", - "isActive": false, - "text": "__EnumValue", + href: "/enumvalue.spec.html", + isActive: false, + text: "__EnumValue", }, { - "href": "/field.spec.html", - "isActive": false, - "text": "__Field", + href: "/field.spec.html", + isActive: false, + text: "__Field", }, { - "href": "/inputvalue.spec.html", - "isActive": false, - "text": "__InputValue", + href: "/inputvalue.spec.html", + isActive: false, + text: "__InputValue", }, { - "href": "/schema.spec.html", - "isActive": false, - "text": "__Schema", + href: "/schema.spec.html", + isActive: false, + text: "__Schema", }, { - "href": "/type.spec.html", - "isActive": false, - "text": "__Type", + href: "/type.spec.html", + isActive: false, + text: "__Type", }, - ] - } + ], + }, ]); }); }); diff --git a/plugins/navigation.scalar.ts b/plugins/navigation.scalar.ts index 38983ecc..0b940637 100644 --- a/plugins/navigation.scalar.ts +++ b/plugins/navigation.scalar.ts @@ -3,16 +3,17 @@ import { NavigationItem, NavigationSection, Plugin, - SCALAR + SCALAR, } from "../lib/utility"; -export default class NavigationScalars extends Plugin +export default class NavigationScalars + extends Plugin implements PluginInterface { getTypes(buildForType: string): NavigationItemInterface[] { return this.document.types - .filter(type => type.kind === SCALAR) + .filter((type) => type.kind === SCALAR) .map( - type => + (type) => new NavigationItem( type.name, this.url(type), diff --git a/plugins/navigation.schema.test.ts b/plugins/navigation.schema.test.ts index 00ba6f3c..f7fe9dcf 100644 --- a/plugins/navigation.schema.test.ts +++ b/plugins/navigation.schema.test.ts @@ -9,23 +9,23 @@ describe("pĺugins/navigation.directive#NavigationDirectives", () => { ...schema.data.__schema, mutationType: null, queryType: null, - subscriptionType: null + subscriptionType: null, }, projectPackage, {} ); - expect(plugin.getNavigations("Query")).toEqual([]) - }) + expect(plugin.getNavigations("Query")).toEqual([]); + }); test("plugin return navigation", () => { const plugin = new NavigationSchema( { ...schema.data.__schema, subscriptionType: { - "name": "Subscription", - "description": "The subscription root of GitHub's GraphQL interface.", - "kind": "OBJECT" + name: "Subscription", + description: "The subscription root of GitHub's GraphQL interface.", + kind: "OBJECT", }, }, projectPackage, @@ -36,22 +36,22 @@ describe("pĺugins/navigation.directive#NavigationDirectives", () => { title: "Schema", items: [ { - "href": "/query.doc.html", - "isActive": true, - "text": "Query" + href: "/query.doc.html", + isActive: true, + text: "Query", }, { - "href": "/mutation.doc.html", - "isActive": false, - "text": "Mutation", + href: "/mutation.doc.html", + isActive: false, + text: "Mutation", }, { - "href": "/subscription.doc.html", - "isActive": false, - "text": "Subscription" + href: "/subscription.doc.html", + isActive: false, + text: "Subscription", }, - ] - } + ], + }, ]); }); }); diff --git a/plugins/navigation.schema.ts b/plugins/navigation.schema.ts index f215793c..f77c3f31 100644 --- a/plugins/navigation.schema.ts +++ b/plugins/navigation.schema.ts @@ -1,16 +1,16 @@ import { NavigationSectionInterface, PluginInterface } from "../lib/interface"; import { NavigationItem, NavigationSection, Plugin } from "../lib/utility"; -export default class NavigationSchema extends Plugin +export default class NavigationSchema + extends Plugin implements PluginInterface { getNavigations(buildFrom?: string): NavigationSectionInterface[] { - if ( !this.document.queryType && !this.document.mutationType && !this.document.subscriptionType ) { - return [] + return []; } const section = new NavigationSection("Schema", []); diff --git a/plugins/navigation.union.test.ts b/plugins/navigation.union.test.ts index aa820db9..19641226 100644 --- a/plugins/navigation.union.test.ts +++ b/plugins/navigation.union.test.ts @@ -13,37 +13,41 @@ describe("pĺugins/navigation.directive#NavigationDirectives", () => { {} ); - expect(plugin.getNavigations("Query")).toEqual([]) - }) + expect(plugin.getNavigations("Query")).toEqual([]); + }); test("plugin return navigation", () => { - const plugin = new NavigationUnion(schema.data.__schema, projectPackage, {}); + const plugin = new NavigationUnion( + schema.data.__schema, + projectPackage, + {} + ); expect(plugin.getNavigations("Query")).toEqual([ { title: "Unions", items: [ { - "href": "/issuetimelineitem.doc.html", - "isActive": false, - "text": "IssueTimelineItem", + href: "/issuetimelineitem.doc.html", + isActive: false, + text: "IssueTimelineItem", }, { - "href": "/projectcarditem.doc.html", - "isActive": false, - "text": "ProjectCardItem", + href: "/projectcarditem.doc.html", + isActive: false, + text: "ProjectCardItem", }, { - "href": "/reviewdismissalallowanceactor.doc.html", - "isActive": false, - "text": "ReviewDismissalAllowanceActor", + href: "/reviewdismissalallowanceactor.doc.html", + isActive: false, + text: "ReviewDismissalAllowanceActor", }, { - "href": "/searchresultitem.doc.html", - "isActive": false, - "text": "SearchResultItem", + href: "/searchresultitem.doc.html", + isActive: false, + text: "SearchResultItem", }, - ] - } + ], + }, ]); }); }); diff --git a/plugins/navigation.union.ts b/plugins/navigation.union.ts index 2c599f4f..62cf4772 100644 --- a/plugins/navigation.union.ts +++ b/plugins/navigation.union.ts @@ -3,16 +3,17 @@ import { NavigationItem, NavigationSection, Plugin, - UNION + UNION, } from "../lib/utility"; -export default class NavigationScalars extends Plugin +export default class NavigationScalars + extends Plugin implements PluginInterface { getTypes(buildForType: string): NavigationItemInterface[] { return this.document.types - .filter(type => type.kind === UNION) + .filter((type) => type.kind === UNION) .map( - type => + (type) => new NavigationItem( type.name, this.url(type), diff --git a/template/slds/scripts/filter-types.js b/template/slds/scripts/filter-types.js index 88e6c4b5..90acb2b8 100644 --- a/template/slds/scripts/filter-types.js +++ b/template/slds/scripts/filter-types.js @@ -1,102 +1,94 @@ (function () { - var HIDE_CLASS = 'slds-hide'; - var ITEM_CLASS = 'slds-item'; - - /** - * @class Item - * @param {HTMLLIElement} li - */ - function Item(li) { - this.li = li; - this.type = li.title; - this.typeLowerCase = li.title.toLowerCase(); - } - - /** - * @return boolean - */ - Item.prototype.contains = function (searchText) { - return this.typeLowerCase.indexOf(searchText) >= 0; - } - - /** - * @return boolean - */ - Item.prototype.isHide = function () { - this.li.classList.contains(HIDE_CLASS); - } - - /** - * @return void - */ - Item.prototype.hide = function () { - if (!this.isHide()) - this.li.classList.add(HIDE_CLASS); - } - - /** - * @return void - */ - Item.prototype.show = function () { - this.li.classList.remove(HIDE_CLASS); - } - - /** - * @class ItemList - * @param {Item[]} items - */ - function ItemList(items) { - this.items = items; - } - - /** - * @function ItemsList.fromSelector - * @param {string} selector - * @return ItemList - */ - ItemList.fromSelector = function (selector) { - - var lis = document.querySelectorAll(selector); - var items = Array.prototype.map.call(lis, function (li) { - return new Item(li); - }) - - return new ItemList(items); - } - - /** - * @return void - */ - ItemList.prototype.showIfmatch = function (match) { - - match = match.toLowerCase(match); - - this - .items - .forEach(function (item) { - item.contains(match) ? - item.show(): - item.hide(); - }) - } - - /** - * @var {ItemList} items - * @var {HTMLInputElement} input - */ - var items = ItemList.fromSelector('nav .slds-navigation-list--vertical li'); - var input = document.getElementById('type-search'); - var lastMatch = ''; - - function onChange() { - if (input.value === lastMatch) - return; - - lastMatch = input.value; - items.showIfmatch(lastMatch); - } - - input.addEventListener('change', onChange); - input.addEventListener('keyup', onChange); - input.addEventListener('mouseup', onChange); -})() \ No newline at end of file + var HIDE_CLASS = "slds-hide"; + var ITEM_CLASS = "slds-item"; + + /** + * @class Item + * @param {HTMLLIElement} li + */ + function Item(li) { + this.li = li; + this.type = li.title; + this.typeLowerCase = li.title.toLowerCase(); + } + + /** + * @return boolean + */ + Item.prototype.contains = function (searchText) { + return this.typeLowerCase.indexOf(searchText) >= 0; + }; + + /** + * @return boolean + */ + Item.prototype.isHide = function () { + this.li.classList.contains(HIDE_CLASS); + }; + + /** + * @return void + */ + Item.prototype.hide = function () { + if (!this.isHide()) this.li.classList.add(HIDE_CLASS); + }; + + /** + * @return void + */ + Item.prototype.show = function () { + this.li.classList.remove(HIDE_CLASS); + }; + + /** + * @class ItemList + * @param {Item[]} items + */ + function ItemList(items) { + this.items = items; + } + + /** + * @function ItemsList.fromSelector + * @param {string} selector + * @return ItemList + */ + ItemList.fromSelector = function (selector) { + var lis = document.querySelectorAll(selector); + var items = Array.prototype.map.call(lis, function (li) { + return new Item(li); + }); + + return new ItemList(items); + }; + + /** + * @return void + */ + ItemList.prototype.showIfmatch = function (match) { + match = match.toLowerCase(match); + + this.items.forEach(function (item) { + item.contains(match) ? item.show() : item.hide(); + }); + }; + + /** + * @var {ItemList} items + * @var {HTMLInputElement} input + */ + var items = ItemList.fromSelector("nav .slds-navigation-list--vertical li"); + var input = document.getElementById("type-search"); + var lastMatch = ""; + + function onChange() { + if (input.value === lastMatch) return; + + lastMatch = input.value; + items.showIfmatch(lastMatch); + } + + input.addEventListener("change", onChange); + input.addEventListener("keyup", onChange); + input.addEventListener("mouseup", onChange); +})(); diff --git a/template/slds/scripts/focus-active.js b/template/slds/scripts/focus-active.js index f411c585..497abed3 100644 --- a/template/slds/scripts/focus-active.js +++ b/template/slds/scripts/focus-active.js @@ -1,8 +1,11 @@ (function () { - var navScroll = document.getElementById('navication-scroll'); - var header = document.querySelector('nav header'); - var active = document.querySelector('.slds-is-active a'); + var navScroll = document.getElementById("navication-scroll"); + var header = document.querySelector("nav header"); + var active = document.querySelector(".slds-is-active a"); - if(active) - navScroll.scrollTop = active.offsetTop - header.offsetHeight - Math.ceil(active.offsetHeight / 2) -})() \ No newline at end of file + if (active) + navScroll.scrollTop = + active.offsetTop - + header.offsetHeight - + Math.ceil(active.offsetHeight / 2); +})(); diff --git a/template/slds/scripts/toggle-navigation.js b/template/slds/scripts/toggle-navigation.js index 39d21643..57a61323 100644 --- a/template/slds/scripts/toggle-navigation.js +++ b/template/slds/scripts/toggle-navigation.js @@ -1,23 +1,21 @@ (function () { + var ACTIVE_CLASS = "is-active"; + var navigation = document.querySelector("nav"); + var toggles = document.querySelectorAll(".js-toggle-navigation"); - var ACTIVE_CLASS = 'is-active'; - var navigation = document.querySelector('nav'); - var toggles = document.querySelectorAll('.js-toggle-navigation'); + function toggleNavigation() { + navigation.classList.contains(ACTIVE_CLASS) + ? navigation.classList.remove(ACTIVE_CLASS) + : navigation.classList.add(ACTIVE_CLASS); + } - function toggleNavigation() { - navigation.classList.contains(ACTIVE_CLASS) ? - navigation.classList.remove(ACTIVE_CLASS) : - navigation.classList.add(ACTIVE_CLASS); + Array.prototype.forEach.call( + toggles, + /** + * @param {HTMLElement} toggle + */ + function (toggle) { + toggle.addEventListener("click", toggleNavigation); } - - Array.prototype.forEach.call( - toggles, - /** - * @param {HTMLElement} toggle - */ - function (toggle) { - toggle.addEventListener('click', toggleNavigation); - } - ) - -})() \ No newline at end of file + ); +})(); diff --git a/test/empty.ts b/test/empty.ts index 3d9d938d..7a57560c 100644 --- a/test/empty.ts +++ b/test/empty.ts @@ -6,7 +6,7 @@ import { GraphQLNonNull, GraphQLObjectType, GraphQLSchema, - GraphQLString + GraphQLString, } from "graphql"; import pack from "../package.json"; @@ -19,17 +19,17 @@ export const EmptySchema = new GraphQLSchema({ fields: { version: { type: new GraphQLNonNull(GraphQLString), - resolve: () => pack.version - } - } - }) + resolve: () => pack.version, + }, + }, + }), }); app.use( "/graphql", graphqlHTTP({ schema: EmptySchema, - graphiql: true + graphiql: true, }) ); app.listen(4000); diff --git a/test/schema.ts b/test/schema.ts index 589995e5..db9f2b41 100644 --- a/test/schema.ts +++ b/test/schema.ts @@ -14,7 +14,7 @@ import { GraphQLNonNull, GraphQLObjectType, GraphQLSchema, - GraphQLString + GraphQLString, } from "graphql"; /** @@ -78,17 +78,17 @@ const episodeEnum = new GraphQLEnumType({ values: { EMPIRE: { description: "Released in 1980.", - value: 5 + value: 5, }, JEDI: { description: "Released in 1983.", - value: 6 + value: 6, }, NEWHOPE: { description: "Released in 1977.", - value: 4 - } - } + value: 4, + }, + }, }); /** @@ -109,27 +109,28 @@ const characterInterface = new GraphQLInterfaceType({ fields: () => ({ id: { type: new GraphQLNonNull(GraphQLID), - description: "The id of the character." + description: "The id of the character.", }, name: { type: GraphQLString, - description: "The name of the character." + description: "The name of the character.", }, friends: { type: new GraphQLList(characterInterface), description: - "The friends of the character, or an empty list if they " + "have none." + "The friends of the character, or an empty list if they " + + "have none.", }, appearsIn: { type: new GraphQLList(episodeEnum), - description: "Which movies they appear in." + description: "Which movies they appear in.", }, secretBackstory: { type: GraphQLString, - description: "All secrets about their past." - } + description: "All secrets about their past.", + }, }), - resolveType: _ => humanType + resolveType: (_) => humanType, }); /** @@ -150,35 +151,35 @@ const humanType = new GraphQLObjectType({ fields: () => ({ id: { type: new GraphQLNonNull(GraphQLID), - description: "The id of the human." + description: "The id of the human.", }, name: { type: GraphQLString, - description: "The name of the human." + description: "The name of the human.", }, friends: { type: new GraphQLList(characterInterface), description: "The friends of the human, or an empty list if they " + "have none.", - resolve: human => human + resolve: (human) => human, }, appearsIn: { type: new GraphQLList(episodeEnum), - description: "Which movies they appear in." + description: "Which movies they appear in.", }, homePlanet: { type: GraphQLString, - description: "The home planet of the human, or null if unknown." + description: "The home planet of the human, or null if unknown.", }, secretBackstory: { type: GraphQLString, description: "Where are they from and how they came to be who they are.", resolve: () => { throw new Error("secretBackstory is secret."); - } - } + }, + }, }), - interfaces: [characterInterface] + interfaces: [characterInterface], }); /** @@ -200,35 +201,35 @@ const droidType = new GraphQLObjectType({ fields: () => ({ id: { type: new GraphQLNonNull(GraphQLID), - description: "The id of the droid." + description: "The id of the droid.", }, name: { type: GraphQLString, - description: "The name of the droid." + description: "The name of the droid.", }, friends: { type: new GraphQLList(characterInterface), description: "The friends of the droid, or an empty list if they " + "have none.", - resolve: droid => droid + resolve: (droid) => droid, }, appearsIn: { type: new GraphQLList(episodeEnum), - description: "Which movies they appear in." + description: "Which movies they appear in.", }, secretBackstory: { type: GraphQLString, description: "Construction date and the name of the designer.", resolve: () => { throw new Error("secretBackstory is secret."); - } + }, }, primaryFunction: { type: GraphQLString, - description: "The primary function of the droid." - } + description: "The primary function of the droid.", + }, }), - interfaces: [characterInterface] + interfaces: [characterInterface], }); /** @@ -257,10 +258,10 @@ const queryType = new GraphQLObjectType({ description: "If omitted, returns the hero of the whole saga. If " + "provided, returns the hero of that particular episode.", - type: episodeEnum - } + type: episodeEnum, + }, }, - resolve: () => null + resolve: () => null, }, human: { type: humanType, @@ -268,10 +269,10 @@ const queryType = new GraphQLObjectType({ args: { id: { description: "id of the human", - type: new GraphQLNonNull(GraphQLID) - } + type: new GraphQLNonNull(GraphQLID), + }, }, - resolve: () => null + resolve: () => null, }, droid: { type: droidType, @@ -279,12 +280,12 @@ const queryType = new GraphQLObjectType({ args: { id: { description: "id of the droid", - type: new GraphQLNonNull(GraphQLID) - } + type: new GraphQLNonNull(GraphQLID), + }, }, - resolve: () => null - } - }) + resolve: () => null, + }, + }), }); /** @@ -302,12 +303,12 @@ const mutationType = new GraphQLObjectType({ args: { episode: { type: new GraphQLNonNull(episodeEnum), - description: "Favorite episode." - } + description: "Favorite episode.", + }, }, - resolve: (_, { episode }) => episode - } - }) + resolve: (_, { episode }) => episode, + }, + }), }); /** @@ -316,5 +317,5 @@ const mutationType = new GraphQLObjectType({ */ export const StarWarsSchema = new GraphQLSchema({ query: queryType, - mutation: mutationType + mutation: mutationType, }); diff --git a/test/starWars.ts b/test/starWars.ts index 0c332703..08c875f6 100644 --- a/test/starWars.ts +++ b/test/starWars.ts @@ -129,5 +129,5 @@ export default () => [ Human, Mutation, Query, - Schema + Schema, ];