Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
...require('gts/.prettierrc.json')
}
...require('gts/.prettierrc.json'),
};
12 changes: 3 additions & 9 deletions build/index.js

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions build/src/api/generated.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as ResponseTypes from './responseTypes';
export type Query = 'getField' | 'getFieldValues' | 'getItemId' | 'getProjectId';
export type Mutation = 'clearItemFieldValue' | 'setItemFieldValue';
export type Request = Query | Mutation;
export declare const supportedQueries: readonly ["getField", "getFieldValues", "getItemId", "getProjectId"];
export declare const supportedMutations: readonly ["clearItemFieldValue", "setItemFieldValue"];
export declare const supportedRequests: ("getField" | "getProjectId" | "getFieldValues" | "getItemId" | "clearItemFieldValue" | "setItemFieldValue")[];
export type ProjectV2FieldValue = {
text: string;
} | {
number: number;
} | {
date: string;
} | {
singleSelectOptionId: string;
} | {
iterationId: string;
};
export type FieldDataType = 'ASSIGNEES' | 'LINKED_PULL_REQUESTS' | 'REVIEWERS' | 'LABELS' | 'MILESTONE' | 'REPOSITORY' | 'TITLE' | 'TEXT' | 'SINGLE_SELECT' | 'NUMBER' | 'DATE' | 'ITERATION' | 'TRACKS' | 'TRACKED_BY';
export type RequestParams<T extends Request> = T extends 'getField' ? {
owner: string;
projectNumber: number;
fieldName: string;
} : T extends 'getFieldValues' ? {
resourceUrl: string;
} : T extends 'getItemId' ? {
resourceUrl: string;
} : T extends 'getProjectId' ? {
owner: string;
number: number;
} : T extends 'clearItemFieldValue' ? {
projectId: string;
itemId: string;
fieldId: string;
} : T extends 'setItemFieldValue' ? {
projectId: string;
itemId: string;
fieldId: string;
value: ProjectV2FieldValue;
} : never;
export type Response<T extends Request> = T extends 'getField' ? ResponseTypes.getField : T extends 'getFieldValues' ? ResponseTypes.getFieldValues : T extends 'getItemId' ? ResponseTypes.getItemId : T extends 'getProjectId' ? ResponseTypes.getProjectId : T extends 'clearItemFieldValue' ? ResponseTypes.clearItemFieldValue : T extends 'setItemFieldValue' ? ResponseTypes.setItemFieldValue : never;
85 changes: 85 additions & 0 deletions build/src/api/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { FieldDataType, Request } from './generated';
type FieldsResult = Record<string, {
value: string | number | undefined;
type: 'TEXT' | 'SINGLE_SELECT' | 'NUMBER' | 'DATE' | 'ITERATION';
id: string;
unsupported?: false;
} | {
value?: never;
id: string;
type: FieldDataType;
unsupported: true;
}>;
export declare class Octo {
octokit: import("@octokit/core").Octokit & import("@octokit/plugin-rest-endpoint-methods/dist-types/types").Api & {
paginate: import("@octokit/plugin-paginate-rest").PaginateInterface;
};
requests: Record<Request, string>;
constructor(token: string);
private _request;
/**
* Gets info about a field in a project
* @param projectOwner The user or organization that owns the project
* @param projectNumber The number of the project
* @param fieldName The name of the field
* @returns Info about the field
*/
getField(projectOwner: string, projectNumber: number, fieldName: string): Promise<{
id: string;
dataType: "SINGLE_SELECT";
options: {
id: string;
name: string;
}[];
} | {
id: string;
dataType: "ITERATION";
configuration: {
iterations: {
id: string;
title: string;
}[];
completedIterations: {
id: string;
title: string;
}[];
};
} | {
id: string;
dataType: Exclude<FieldDataType, "SINGLE_SELECT" | "ITERATION">;
}>;
/**
* Gets the field values for a project item
* @param resourceUrl The link to the issue or PR
* @param projectId The ID of the project
* @returns An object with each field name as a key and the field value as the value
*/
getFieldValues(resourceUrl: string, projectId: string): Promise<FieldsResult>;
/**
* Gets the id of a project item
* @param resourceUrl The link to the issue or PR
* @param projectId The ID of the project
* @returns The item ID
*/
getItemId(resourceUrl: string, projectId: string): Promise<string>;
/**
* Gets the ID of a project
* @param projectOwner The user or organization that owns the project
* @param projectNumber The number of the project
* @returns The project ID
*/
getProjectId(projectOwner: string, projectNumber: number): Promise<string>;
clearFieldValue(projectId: string, itemId: string, fieldId: string): Promise<void>;
setFieldValue(projectId: string, itemId: string, fieldId: string, value: {
text: string;
} | {
number: number;
} | {
date: string;
} | {
singleSelectOptionId: string;
} | {
iterationId: string;
}): Promise<void>;
}
export {};
83 changes: 83 additions & 0 deletions build/src/api/responseTypes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { FieldDataType } from './generated';
export interface getField {
repositoryOwner: {
projectV2: {
field: {
id: string;
dataType: 'SINGLE_SELECT';
options: {
id: string;
name: string;
}[];
} | {
id: string;
dataType: 'ITERATION';
configuration: {
iterations: {
id: string;
title: string;
}[];
completedIterations: {
id: string;
title: string;
}[];
};
} | {
id: string;
dataType: Exclude<FieldDataType, 'SINGLE_SELECT' | 'ITERATION'>;
};
};
};
}
export interface getFieldValues {
resource: {
projectItems: {
nodes: {
itemId: string;
project: {
id: string;
};
fieldValues: {
totalCount: number;
nodes: ({} | {
field: {
name: string;
id: string;
dataType: FieldDataType;
};
text?: string;
name?: string;
number?: number;
date?: string;
title?: string;
})[];
};
}[];
};
};
}
export interface getItemId {
resource: {
projectItems: {
nodes: {
itemId: string;
project: {
id: string;
};
}[];
};
};
}
export interface getProjectId {
repositoryOwner: {
projectV2: {
id: string;
};
};
}
export interface clearItemFieldValue {
clientMutationId: string;
}
export interface setItemFieldValue {
clientMutationId: string;
}
1 change: 1 addition & 0 deletions build/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
32 changes: 32 additions & 0 deletions build/src/io.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export declare enum OperationType {
GET_FIELDS = "GET",
SET_FIELDS = "SET",
CLEAR_FIELDS = "CLEAR"
}
interface Inputs {
operation: OperationType;
fields: string[];
project: {
owner: string;
ownerType: 'users' | 'orgs';
number: number;
};
github_token: string;
resource: {
owner: string;
repo: string;
type: 'pull' | 'issues';
number: number;
url: string;
};
values?: string[];
}
interface Outputs {
values: string;
}
export declare function getInputs(): Promise<Inputs>;
/** Lets you set an output that will also be logged */
export declare function setOutput<T extends keyof Outputs>(key: T, value: Outputs[T]): void;
/** Logs all cached outputs */
export declare function logOutputs(): void;
export {};
19 changes: 19 additions & 0 deletions build/src/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** Excludes `{}` from a `Partial` type */
export type AtLeastOne<T, U = {
[K in keyof T]: Pick<T, K>;
}> = Partial<T> & U[keyof U];
/** Excludes `{}` from a union type */
export type ExcludeEmpty<T> = T extends AtLeastOne<T> ? T : never;
/**
* Can be used as a type guard to check if a value is of a specific type.
* @param value The value to check
* @param test A function that takes the value as an argument and returns a whether it is of the correct type
* @returns Whether the value is of the correct type
*/
export declare function checkType<T>(value: unknown, test: (value: unknown) => boolean): value is T;
/** Shorthand to log a value in the debug logs of the action run */
export declare function debug(item: unknown): void;
/** Generates a CSV string from an array of values */
export declare function stringifyCSVArray(values: (string | number | boolean | undefined)[]): string;
/** Parses a CSV string containing one row into an array of strings */
export declare function parseCSVArray(csv: string): string[];
14 changes: 14 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';
const gtsConfig = require('gts');
const gtsIgnores = require('gts/eslint.ignores.js');
const {defineConfig} = require('eslint/config');

module.exports = defineConfig([
{ignores: gtsIgnores},
...gtsConfig,
{
rules: {
'spaced-comment': 'warn',
},
},
]);
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build",
"declaration": false
"outDir": "build"
},
"include": [
"src/**/*.ts",
Expand Down