Skip to content

Commit b720cec

Browse files
feat: add projects (#12)
1 parent 181f579 commit b720cec

File tree

13 files changed

+1268
-463
lines changed

13 files changed

+1268
-463
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
!.vscode
44
node_modules
55
lock.json
6-
.pspace
6+
.paperspace

.graphql/projects/mutations.graphql

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
mutation CreateProject($input: CreateProjectInput!) {
2+
createProject(input: $input) {
3+
project {
4+
id
5+
name
6+
dtCreated
7+
}
8+
}
9+
}
10+
11+
mutation UpdateProject($input: UpdateProjectInput!) {
12+
updateProject(input: $input) {
13+
project {
14+
id
15+
name
16+
dtCreated
17+
}
18+
}
19+
}

.graphql/projects/queries.graphql

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
query ActivityLog(
2-
$projectId: String!
3-
$first: Int
4-
$last: Int
5-
$before: String
6-
$after: String
7-
) {
8-
projectActivities(
9-
projectId: $projectId
10-
first: $first
11-
last: $last
12-
before: $before
13-
after: $after
14-
) {
1+
query GetProject($id: String!) {
2+
project(id: $id) {
3+
id
4+
name
5+
dtCreated
6+
}
7+
}
8+
9+
query ListProjects($first: Int, $after: String, $orderBy: ProjectOrder) {
10+
projects(first: $first, after: $after, orderBy: $orderBy) {
11+
nodes {
12+
id
13+
name
14+
dtCreated
15+
}
16+
17+
pageInfo {
18+
hasNextPage
19+
endCursor
20+
}
21+
}
22+
}
23+
24+
query ActivityLog($projectId: String!, $first: Int, $after: String) {
25+
projectActivities(projectId: $projectId, first: $first, after: $after) {
1526
nodes {
1627
__typename
1728

deno.lock

Lines changed: 393 additions & 255 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/act.ts

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,6 @@ import * as credentials from "./credentials.ts";
33
import * as config from "./config.ts";
44
import { info, strip } from "./ansi.ts";
55

6-
/**
7-
* Logs a message to the console in the appropriate format based on the
8-
* CLI options.
9-
*
10-
* @param formats - Formats to print.
11-
* @param opt - Configuration options
12-
*/
13-
function print(
14-
formats: Formats,
15-
opt: {
16-
json: boolean;
17-
},
18-
): void {
19-
if (opt?.json) {
20-
let json = "value" in formats ? formats.value : formats.json;
21-
22-
if (typeof json === "string") {
23-
json = strip(json);
24-
}
25-
26-
console.log(JSON.stringify(json, null, 2));
27-
} else {
28-
console.log("value" in formats ? formats.value : formats.human);
29-
}
30-
}
31-
326
/**
337
* A higher order function that needs to be added to every action. This will also
348
* print the return value of an action function in the appropriate format based on
@@ -44,9 +18,10 @@ function print(
4418
* ```
4519
*/
4620
export function act<
47-
Fn extends (...args: any[]) => Formats | Promise<Formats>,
21+
Args extends any[],
22+
Fn extends (...args: Args) => Formats | Promise<Formats>,
4823
>(fn: Fn) {
49-
return async function action(...args: Parameters<Fn>): Promise<void> {
24+
return async function action(...args: Args): Promise<void> {
5025
const opt = args[0];
5126

5227
if (opt.debug !== undefined) {
@@ -88,9 +63,10 @@ export function act<
8863
* ```
8964
*/
9065
act.ifLoggedIn = <
91-
Fn extends (...args: any[]) => Formats | Promise<Formats>,
66+
Args extends any[],
67+
Fn extends (...args: Args) => Formats | Promise<Formats>,
9268
>(fn: Fn) => {
93-
return async function action(...args: Parameters<Fn>): Promise<void> {
69+
return async function action(...args: Args): Promise<void> {
9470
const opt = args[0];
9571
const isLoggedIn = !!(opt.apiKey || await config.get("team"));
9672
const availableTeams = await credentials.list();
@@ -115,11 +91,37 @@ ${loginHelper}`,
11591
);
11692
}
11793

118-
return act(fn)(...args);
94+
return act(fn as any)(...args);
11995
};
12096
};
12197

122-
type Formats =
98+
/**
99+
* Logs a message to the console in the appropriate format based on the
100+
* CLI options.
101+
*
102+
* @param formats - Formats to print.
103+
* @param opt - Configuration options
104+
*/
105+
function print(
106+
formats: Formats,
107+
opt: {
108+
json: boolean;
109+
},
110+
): void {
111+
if (opt?.json) {
112+
let json = "value" in formats ? formats.value : formats.json;
113+
114+
if (typeof json === "string") {
115+
json = strip(json);
116+
}
117+
118+
console.log(JSON.stringify(json, null, 2));
119+
} else {
120+
console.log("value" in formats ? formats.value : formats.human);
121+
}
122+
}
123+
124+
export type Formats =
123125
| {
124126
/**
125127
* A JSON-serializable value to print.

0 commit comments

Comments
 (0)