New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gh-gql

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gh-gql - npm Package Compare versions

Comparing version 3.0.11 to 4.0.0

lib/documents/commit.d.ts

63

CHANGELOG.md

@@ -0,1 +1,5 @@

# BREAKING CHANGES
- Remove codegen [`d956ea2`](https://github.com/keindev/gh-gql/commit/d956ea24fc7c2451ab9f65363f4d714bd53056f4)
# Important Changes

@@ -6,22 +10,57 @@

<details>
<summary>Dependencies</summary>
- Changed **[graphql](https://www.npmjs.com/package/graphql)** from `^16.3.0` to `^16.6.0`
- Changed **[universal-user-agent](https://www.npmjs.com/package/universal-user-agent)** from `^7.0.0` to `^7.0.1`
- Bumped **[graphql-request](https://www.npmjs.com/package/graphql-request)** from `^4.2.0` to `^5.0.0`
- Removed **[graphql-tag](https://www.npmjs.com/package/graphql-tag)**, with `^2.12.6`
</details>
<details>
<summary>Dev Dependencies</summary>
- Changed **[@types/node](https://www.npmjs.com/package/@types/node)** from `^17.0.23` to `^17.0.25`
- Changed **[@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)** from `^5.18.0` to `^5.20.0`
- Changed **[@typescript-eslint/parser](https://www.npmjs.com/package/@typescript-eslint/parser)** from `^5.18.0` to `^5.20.0`
- Changed **[changelog-guru](https://www.npmjs.com/package/changelog-guru)** from `^4.0.4` to `^4.0.5`
- Changed **[cspell](https://www.npmjs.com/package/cspell)** from `^5.19.5` to `^5.19.7`
- Changed **[eslint](https://www.npmjs.com/package/eslint)** from `^8.12.0` to `^8.13.0`
- Changed **[eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import)** from `^2.25.4` to `^2.26.0`
- Changed **[eslint-plugin-jest](https://www.npmjs.com/package/eslint-plugin-jest)** from `^26.1.3` to `^26.1.4`
- Changed **[figma-portal](https://www.npmjs.com/package/figma-portal)** from `^1.0.0` to `^1.0.1`
- Bumped **[@tagproject/ts-package-shared-config](https://www.npmjs.com/package/@tagproject/ts-package-shared-config)** from `^7.3.3` to `^9.0.4`
- Bumped **[@tagproject/vscode-shared-config](https://www.npmjs.com/package/@tagproject/vscode-shared-config)** from `^1.2.5` to `^2.0.0`
- Changed **[@tagproject/docs-shared-config](https://www.npmjs.com/package/@tagproject/docs-shared-config)** from `^1.0.4` to `^1.1.1`
- Changed **[@tagproject/vscode-shared-config](https://www.npmjs.com/package/@tagproject/vscode-shared-config)** from `^2.0.0` to `^2.0.4`
- Changed **[@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)** from `^5.20.0` to `^5.43.0`
- Changed **[@typescript-eslint/parser](https://www.npmjs.com/package/@typescript-eslint/parser)** from `^5.20.0` to `^5.43.0`
- Changed **[changelog-guru](https://www.npmjs.com/package/changelog-guru)** from `^4.0.5` to `^4.0.6`
- Changed **[eslint](https://www.npmjs.com/package/eslint)** from `^8.13.0` to `^8.28.0`
- Changed **[eslint-plugin-promise](https://www.npmjs.com/package/eslint-plugin-promise)** from `^6.0.0` to `^6.1.1`
- Changed **[figma-portal](https://www.npmjs.com/package/figma-portal)** from `^1.0.1` to `^1.0.2`
- Changed **[ghinfo](https://www.npmjs.com/package/ghinfo)** from `^3.0.5` to `^3.0.6`
- Changed **[prettier](https://www.npmjs.com/package/prettier)** from `^2.6.2` to `^2.7.1`
- Changed **[typescript](https://www.npmjs.com/package/typescript)** from `^4.6.3` to `^4.9.3`
- Bumped **[@tagproject/ts-package-shared-config](https://www.npmjs.com/package/@tagproject/ts-package-shared-config)** from `^9.0.4` to `^10.0.1`
- Bumped **[@types/jest](https://www.npmjs.com/package/@types/jest)** from `^27.4.1` to `^29.2.3`
- Bumped **[@types/node](https://www.npmjs.com/package/@types/node)** from `^17.0.25` to `^18.11.9`
- Bumped **[cspell](https://www.npmjs.com/package/cspell)** from `^5.19.7` to `^6.14.3`
- Bumped **[dotenv-cli](https://www.npmjs.com/package/dotenv-cli)** from `^5.1.0` to `^6.0.0`
- Bumped **[eslint-plugin-jest](https://www.npmjs.com/package/eslint-plugin-jest)** from `^26.1.4` to `^27.1.5`
- Bumped **[husky](https://www.npmjs.com/package/husky)** from `^7.0.4` to `^8.0.2`
- Bumped **[jest](https://www.npmjs.com/package/jest)** from `^27.5.1` to `^29.3.1`
- Bumped **[ts-jest](https://www.npmjs.com/package/ts-jest)** from `^27.1.4` to `^29.0.3`
- Removed **[@graphql-codegen/add](https://www.npmjs.com/package/@graphql-codegen/add)**, with `^3.1.1`
- Removed **[@graphql-codegen/cli](https://www.npmjs.com/package/@graphql-codegen/cli)**, with `^2.6.2`
- Removed **[@graphql-codegen/import-types-preset](https://www.npmjs.com/package/@graphql-codegen/import-types-preset)**, with `^2.1.15`
- Removed **[@graphql-codegen/near-operation-file-preset](https://www.npmjs.com/package/@graphql-codegen/near-operation-file-preset)**, with `^2.2.9`
- Removed **[@graphql-codegen/typescript](https://www.npmjs.com/package/@graphql-codegen/typescript)**, with `^2.4.8`
- Removed **[@graphql-codegen/typescript-graphql-request](https://www.npmjs.com/package/@graphql-codegen/typescript-graphql-request)**, with `^4.4.5`
- Removed **[@graphql-codegen/typescript-operations](https://www.npmjs.com/package/@graphql-codegen/typescript-operations)**, with `^2.3.5`
</details>
# :fire: Improvements
- Rewrite queries [`6115b86`](https://github.com/keindev/gh-gql/commit/6115b864df2b09768052bd576cf102f085084d3a)
# :bug: Bug Fixes
- Fix ESM import/export [`3f4e488`](https://github.com/keindev/gh-gql/commit/3f4e4883d3933b94e3b647240b8f4b772e6ab447)
- Remove gql scripts, remove types [`2f24cfe`](https://github.com/keindev/gh-gql/commit/2f24cfeb435ddab58a85ebb9eb4a76faaf6f4dcc)
# :memo: Internal changes
- Rebuild configs [`a8ba34e`](https://github.com/keindev/gh-gql/commit/a8ba34e237bff7e53d98586d22180c6e3752a292)
- Fix API in tests [`7c77903`](https://github.com/keindev/gh-gql/commit/7c7790356bd3a53092cf74a95268ab388521e7a7)
---

@@ -28,0 +67,0 @@

34

lib/queries/Commit.d.ts

@@ -1,31 +0,7 @@

import { GraphQLClient } from 'graphql-request';
import * as SDK from '../__generated__/sdk/commit.js';
import { ArrayElement } from '../types.js';
import { ICommitListLastNodeQueryResult, ICommitListLastNodeQueryVariables, ICommitListQueryEdge, ICommitListQueryVariables, ICommitListTotalQueryVariables } from '../types/commit.js';
import Query from './Query.js';
declare type CommitNode = NonNullable<NonNullable<ArrayElement<NonNullable<SDK.ICommitsHistoryFragment['edges']>>>['node']>;
declare type CommitNodeAuthor = NonNullable<CommitNode['author']>;
declare type CommitNodeAuthorUser = Omit<NonNullable<CommitNodeAuthor['user']>, 'databaseId'> & {
databaseId: NonNullable<NonNullable<CommitNodeAuthor['user']>['databaseId']>;
};
export declare type ICommit = Omit<CommitNode, 'author'> & {
author: Omit<CommitNodeAuthor, 'user'> & {
user: CommitNodeAuthorUser;
};
};
declare type MaybeLastCommitObject = NonNullable<NonNullable<SDK.IGetLastCommitQuery['repository']>['object']>;
declare type LastCommitObject = Exclude<MaybeLastCommitObject, Record<string, never>>;
declare type LastCommitHistoryEdges = NonNullable<NonNullable<LastCommitObject['history']>['edges']>;
declare type LastCommitNode = NonNullable<NonNullable<ArrayElement<LastCommitHistoryEdges>>['node']>;
declare type LastCommitCommitter = NonNullable<LastCommitNode['committer']>;
export declare type ILastCommitInfo = Omit<LastCommitNode, 'committer'> & {
committer: Omit<LastCommitCommitter, 'name'> & {
name: NonNullable<LastCommitCommitter['name']>;
};
};
export default class CommitQuery extends Query<ReturnType<typeof SDK.getSdk>> {
constructor(client: GraphQLClient);
getCount({ since, ...others }: SDK.IGetCountQueryVariables): Promise<number>;
getLastCommit(options: SDK.IGetLastCommitQueryVariables): Promise<ILastCommitInfo | undefined>;
getList(options: Omit<SDK.IGetListQueryVariables, 'limit'>): Promise<ICommit[]>;
export default class CommitQuery extends Query {
getLastCommit(variables: ICommitListLastNodeQueryVariables): Promise<ICommitListLastNodeQueryResult | undefined>;
getList<T = ICommitListQueryEdge['node']>(variables: ICommitListQueryVariables): Promise<T[]>;
getTotal({ since, ...others }: ICommitListTotalQueryVariables): Promise<number>;
}
export {};

@@ -1,55 +0,36 @@

import * as SDK from '../__generated__/sdk/commit.js';
import * as Documents from '../documents/commit.js';
import Query from './Query.js';
export default class CommitQuery extends Query {
constructor(client) {
super(client, SDK.getSdk);
async getLastCommit(variables) {
const response = await this.execute(Documents.getCommitListLastNode, variables);
return response.repository.object.history.edges[0]?.node;
}
async getCount({ since, ...others }) {
const response = await this.execute(this.sdk.getCount, { ...others, since: since ?? new Date(0).toISOString() });
const target = response.repository?.ref?.target;
return target && 'history' in target ? target.history.totalCount ?? 0 : 0;
}
async getLastCommit(options) {
const response = await this.execute(this.sdk.getLastCommit, options);
const edges = response.repository?.object && 'history' in response.repository.object
? response.repository.object.history.edges
: undefined;
let info;
if (Array.isArray(edges)) {
const node = edges[0]?.node;
if (node)
info = node;
}
return info;
}
async getList(options) {
const args = { ...options, limit: CommitQuery.PAGE_SIZE };
const response = await this.execute(this.sdk.getList, args);
async getList(variables) {
const args = { ...variables, limit: CommitQuery.PAGE_SIZE };
const response = await this.execute(Documents.getCommitList, args);
const { history } = response.repository.ref.target;
const nodes = [];
if (response.repository?.ref?.target) {
const { target } = response.repository.ref;
const history = target && 'history' in target ? target.history : undefined;
if (history?.edges?.length) {
const [cursor] = (history.pageInfo.endCursor ?? '').split(' ');
const promises = [];
if (cursor && history.pageInfo.hasNextPage) {
const pagesCount = Math.ceil(history.totalCount / CommitQuery.PAGE_SIZE);
let pageNumber = 1;
while (pagesCount >= pageNumber) {
promises.push(this.execute(this.sdk.getFrom, {
...args,
cursor: `${cursor} ${pageNumber++ * CommitQuery.PAGE_SIZE - 1}`,
}));
}
if (history.edges.length) {
const [cursor] = (history.pageInfo.endCursor ?? '').split(' ');
const promises = [];
if (cursor && history.pageInfo.hasNextPage) {
const pagesCount = Math.ceil(history.totalCount / CommitQuery.PAGE_SIZE);
let pageNumber = 1;
while (pagesCount >= pageNumber) {
promises.push(this.execute(Documents.getCommitListFrom, {
...args,
cursor: `${cursor} ${pageNumber++ * CommitQuery.PAGE_SIZE - 1}`,
}));
}
[response, ...(await Promise.all(promises))].forEach(page => {
const edges = page.repository?.ref?.target && 'history' in page.repository.ref.target
? page.repository?.ref?.target.history.edges ?? []
: [];
edges.forEach(edge => edge?.node && nodes.push(edge.node));
});
}
[response, ...(await Promise.all(promises))].forEach(({ repository }) => {
repository.ref.target.history.edges.forEach(({ node }) => node && nodes.push(node));
});
}
return nodes;
}
async getTotal({ since = new Date(0).toISOString(), ...others }) {
const response = await this.execute(Documents.getCommitListTotal, { ...others, since });
return response.repository.ref.target.history.totalCount;
}
}

@@ -1,12 +0,9 @@

import { GraphQLClient } from 'graphql-request';
import * as SDK from '../__generated__/sdk/file.js';
import { IFileContentQueryVariables, IFileIdQueryVariables } from '../types/file.js';
import Query from './Query.js';
export declare type IGetContentOptions = Omit<SDK.IGetContentQueryVariables, 'expression'> & {
filePath: string;
oid: string;
};
export default class FileQuery extends Query<ReturnType<typeof SDK.getSdk>> {
constructor(client: GraphQLClient);
getContent({ oid, filePath, ...others }: IGetContentOptions): Promise<string | undefined>;
getId(variables: SDK.IGetIdQueryVariables): Promise<string | undefined>;
export default class FileQuery extends Query {
getContent({ oid, filePath, ...others }: Omit<IFileContentQueryVariables, 'expression'> & {
filePath: string;
oid: string;
}): Promise<string>;
getId(variables: IFileIdQueryVariables): Promise<string | undefined>;
}

@@ -1,18 +0,15 @@

import * as SDK from '../__generated__/sdk/file.js';
import * as Documents from '../documents/file.js';
import Query from './Query.js';
export default class FileQuery extends Query {
constructor(client) {
super(client, SDK.getSdk);
}
async getContent({ oid, filePath, ...others }) {
const response = await this.execute(this.sdk.getContent, { ...others, expression: `${oid}:${filePath}` });
const object = response.repository?.object;
return object && 'text' in object ? object.text ?? undefined : undefined;
const response = await this.execute(Documents.getFileContent, {
...others,
expression: `${oid}:${filePath}`,
});
return response.repository.object.text;
}
async getId(variables) {
const response = await this.execute(this.sdk.getId, variables);
const target = response.repository?.ref?.target;
const history = target && 'history' in target ? target.history : undefined;
return Array.isArray(history?.nodes) && history?.nodes[0]?.oid ? history?.nodes[0].oid : undefined;
const response = await this.execute(Documents.getFileId, variables);
return response.repository.ref.target.history.nodes[0]?.oid;
}
}

@@ -1,9 +0,9 @@

import { GraphQLClient } from 'graphql-request';
export default class Query<Q> {
import { GraphQLClient, Variables } from 'graphql-request';
export default class Query {
static readonly DELIMITER = "\n";
static readonly PAGE_SIZE = 100;
static readonly TAB_WIDTH = 2;
protected sdk: Q;
constructor(client: GraphQLClient, getSdk: (client: GraphQLClient) => Q);
protected execute<T, K>(callback: (variables: K) => Promise<T>, variables: K): Promise<T | Partial<T>> | never;
private readonly client;
constructor(client: GraphQLClient);
protected execute<T>(query: string, variables: Variables): Promise<T> | never;
}
import { ClientError } from 'graphql-request';
export default class Query {
constructor(client, getSdk) {
this.sdk = getSdk(client);
constructor(client) {
this.client = client;
}
async execute(callback, variables) {
async execute(query, variables) {
try {
const response = await callback(variables);
const response = await this.client.request(query, variables);
return response;

@@ -10,0 +10,0 @@ }

@@ -1,11 +0,5 @@

import { GraphQLClient } from 'graphql-request';
import * as SDK from '../__generated__/sdk/release.js';
import { ArrayElement } from '../types.js';
import { ILastReleaseQueryResult, ILastReleaseQueryVariables } from '../types/release.js';
import Query from './Query.js';
declare type Repository = NonNullable<SDK.IGetLastQuery['repository']>;
declare type IRelease = NonNullable<ArrayElement<NonNullable<Repository['releases']['nodes']>>>;
export default class ReleaseQuery extends Query<ReturnType<typeof SDK.getSdk>> {
constructor(client: GraphQLClient);
getLast(variables: SDK.IGetLastQueryVariables): Promise<IRelease | undefined>;
export default class ReleaseQuery extends Query {
getLast(variables: ILastReleaseQueryVariables): Promise<ILastReleaseQueryResult | undefined>;
}
export {};

@@ -1,12 +0,8 @@

import * as SDK from '../__generated__/sdk/release.js';
import * as Documents from '../documents/release.js';
import Query from './Query.js';
export default class ReleaseQuery extends Query {
constructor(client) {
super(client, SDK.getSdk);
}
async getLast(variables) {
const response = await this.execute(this.sdk.getLast, variables);
const nodes = response.repository?.releases.nodes;
return Array.isArray(nodes) && nodes[0] ? nodes[0] : undefined;
const response = await this.execute(Documents.getLastRelease, variables);
return response.repository.releases.nodes[0];
}
}

@@ -1,9 +0,6 @@

import { GraphQLClient } from 'graphql-request';
import * as SDK from '../__generated__/sdk/repository.js';
import { IRepositoryListQueryVariables, IRepositoryQueryResult, IRepositoryQueryVariables } from '../types/repository.js';
import Query from './Query.js';
export declare type IRepository = NonNullable<SDK.IGetInfoQuery['viewer']['repository']>;
export default class RepositoryQuery extends Query<ReturnType<typeof SDK.getSdk>> {
constructor(client: GraphQLClient);
getInfo(variables: SDK.IGetInfoQueryVariables): Promise<IRepository | undefined>;
getList(variables: SDK.IGetListQueryVariables): Promise<string[]>;
export default class RepositoryQuery extends Query {
getData(variables: IRepositoryQueryVariables): Promise<IRepositoryQueryResult | undefined>;
getList(variables: IRepositoryListQueryVariables): Promise<string[]>;
}

@@ -1,20 +0,12 @@

import * as SDK from '../__generated__/sdk/repository.js';
import * as Documents from '../documents/repository.js';
import Query from './Query.js';
export default class RepositoryQuery extends Query {
constructor(client) {
super(client, SDK.getSdk);
async getData(variables) {
const response = await this.execute(Documents.getRepository, variables);
return response.viewer.repository;
}
async getInfo(variables) {
const response = await this.execute(this.sdk.getInfo, variables);
return response.viewer?.repository ?? undefined;
}
async getList(variables) {
const response = await this.execute(this.sdk.getList, variables);
const nodes = [];
(response.user?.repositories.nodes ?? []).forEach(node => {
if (node?.name)
nodes.push(node.name);
});
return nodes;
const response = await this.execute(Documents.getRepositories, variables);
return response.user.repositories.nodes.map(({ name }) => name);
}
}
{
"name": "gh-gql",
"version": "3.0.11",
"version": "4.0.0",
"description": "GitHub GraphQL API helper for TypeScript",

@@ -21,3 +21,6 @@ "license": "MIT",

"type": "module",
"exports": "./lib/index.js",
"exports": {
".": "./lib/index.js",
"./lib/queries/*": "./lib/queries/*.js"
},
"repository": {

@@ -36,3 +39,2 @@ "type": "git",

"generate:ghinfo": "node --experimental-specifier-resolution=node node_modules/.bin/ghinfo generate -d media -t utils",
"generate:media": "node --experimental-specifier-resolution=node node_modules/.bin/figma-portal extract -d media -p GitHub",
"lint": "npm-run-all lint:*",

@@ -43,6 +45,5 @@ "lint:eslint": "rimraf coverage && eslint src --ext .ts",

"prepare:config": "node --experimental-specifier-resolution=node node_modules/.bin/ts-package-shared-config",
"prepare:docs": "node --experimental-specifier-resolution=node node_modules/.bin/docs-shared-config",
"prepare:gql": "rimraf src/__generated__ && dotenv -e .env gql-gen --config codegen.yml",
"prepare:docs": "docs-shared-config",
"prepare:husky": "husky install",
"prepare:vscode": "node --experimental-specifier-resolution=node node_modules/.bin/vscode-shared-config",
"prepare:vscode": "vscode-shared-config",
"release": "npm-run-all prepare lint test build generate",

@@ -53,42 +54,34 @@ "test": "npm-run-all test:*",

"dependencies": {
"graphql": "^16.3.0",
"graphql-request": "^4.2.0",
"graphql-tag": "^2.12.6",
"universal-user-agent": "^7.0.0"
"graphql": "^16.6.0",
"graphql-request": "^5.0.0",
"universal-user-agent": "^7.0.1"
},
"devDependencies": {
"@graphql-codegen/add": "^3.1.1",
"@graphql-codegen/cli": "^2.6.2",
"@graphql-codegen/import-types-preset": "^2.1.15",
"@graphql-codegen/near-operation-file-preset": "^2.2.9",
"@graphql-codegen/typescript": "^2.4.8",
"@graphql-codegen/typescript-graphql-request": "^4.4.5",
"@graphql-codegen/typescript-operations": "^2.3.5",
"@tagproject/docs-shared-config": "^1.0.4",
"@tagproject/ts-package-shared-config": "^9.0.4",
"@tagproject/vscode-shared-config": "^2.0.0",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.25",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"changelog-guru": "^4.0.5",
"cspell": "^5.19.7",
"dotenv-cli": "^5.1.0",
"eslint": "^8.13.0",
"@tagproject/docs-shared-config": "^1.1.1",
"@tagproject/ts-package-shared-config": "^10.0.1",
"@tagproject/vscode-shared-config": "^2.0.4",
"@types/jest": "^29.2.3",
"@types/node": "^18.11.9",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"changelog-guru": "^4.0.6",
"cspell": "^6.14.3",
"dotenv-cli": "^6.0.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.1.4",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-optimize-regex": "^1.2.1",
"eslint-plugin-promise": "^6.0.0",
"figma-portal": "^1.0.1",
"ghinfo": "^3.0.5",
"husky": "^7.0.4",
"jest": "^27.5.1",
"eslint-plugin-promise": "^6.1.1",
"figma-portal": "^1.0.2",
"ghinfo": "^3.0.6",
"husky": "^8.0.2",
"jest": "^29.3.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"ts-jest": "^27.1.4",
"typescript": "^4.6.3"
"ts-jest": "^29.0.3",
"typescript": "^4.9.3"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc