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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ssntpl/otper-cli",
"version": "0.1.6",
"version": "0.1.7",
"description": "Command-line interface for Otper boards (https://otper.com).",
"author": "SSNTPL <info@ssntpl.com>",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions src/api/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const DELETE_CARD = /* GraphQL */ `

const MOVE_TO = /* GraphQL */ `
mutation MoveTo($input: moveToInput!) {
MoveTo(input: $input) { status message }
MoveTo(input: $input) { message }
}
`;

Expand Down Expand Up @@ -114,8 +114,8 @@ export async function moveCard(
cardId: string,
toListId: string,
overCardId?: string,
): Promise<{ status: string; message: string }> {
const data = await client.gql<{ MoveTo: { status: string; message: string } }>(MOVE_TO, {
): Promise<{ message: string }> {
const data = await client.gql<{ MoveTo: { message: string } }>(MOVE_TO, {
input: { cardId, toListId, overCardId },
});
return data.MoveTo;
Expand Down
8 changes: 8 additions & 0 deletions src/api/datetime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Otper's DateTime scalar expects `YYYY-MM-DD HH:MM:SS` (24-hour, UTC),
* not ISO-8601 with milliseconds and trailing `Z`. Sending `toISOString()`
* output triggers a `Trailing data` validation error from the GraphQL layer.
*/
export function toOtperDateTime(d: Date = new Date()): string {
return d.toISOString().slice(0, 19).replace("T", " ");
}
6 changes: 3 additions & 3 deletions src/api/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const DELETE_LISTS = /* GraphQL */ `

const REORDER_LISTS = /* GraphQL */ `
mutation ReorderLists($input: reorderListsInput!) {
reorderLists(input: $input) { status message }
reorderLists(input: $input) { message }
}
`;

Expand Down Expand Up @@ -116,8 +116,8 @@ export async function reorderLists(
client: OtperClient,
activeListId: string,
toListId: string,
): Promise<{ status: string; message: string }> {
const data = await client.gql<{ reorderLists: { status: string; message: string } }>(
): Promise<{ message: string }> {
const data = await client.gql<{ reorderLists: { message: string } }>(
REORDER_LISTS,
{ input: { activelistId: activeListId, toListId } },
);
Expand Down
2 changes: 0 additions & 2 deletions src/api/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const TEAM_QUERY = /* GraphQL */ `
slug
name
personal_team
is_private
created_at
users {
id
Expand All @@ -21,7 +20,6 @@ const TEAM_QUERY = /* GraphQL */ `
slug
name
key
is_private
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export interface Team {
slug: string;
name: string;
personal_team: boolean;
is_private: boolean;
created_at?: string;
updated_at?: string;
users?: User[];
Expand Down
3 changes: 2 additions & 1 deletion src/commands/card/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Args, Flags } from '@oclif/core';
import { BaseCommand } from '../../base';
import { Column } from '../../format';
import { updateCard } from '../../api/cards';
import { toOtperDateTime } from '../../api/datetime';
import { Card } from '../../api/types';

const COLUMNS: Column<Card>[] = [
Expand All @@ -23,7 +24,7 @@ export default class CardAssign extends BaseCommand<typeof CardAssign> {

async run(): Promise<void> {
const { args } = await this.parse(CardAssign);
const now = new Date().toISOString();
const now = toOtperDateTime();
const card = await updateCard(this.api, {
id: args.id,
users: { connect: this.flags.user.map((id) => ({ id, assigned_at: now })) },
Expand Down
3 changes: 2 additions & 1 deletion src/commands/card/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Args, Flags } from '@oclif/core';
import { BaseCommand } from '../../base';
import { Column } from '../../format';
import { updateCard, UpdateCardInput } from '../../api/cards';
import { toOtperDateTime } from '../../api/datetime';
import { Card } from '../../api/types';

const COLUMNS: Column<Card>[] = [
Expand Down Expand Up @@ -40,7 +41,7 @@ export default class CardUpdate extends BaseCommand<typeof CardUpdate> {
if (this.flags['start-time'] !== undefined)
input.start_time = this.flags['start-time'] === 'null' ? null : this.flags['start-time'];
if (this.flags['mark-done'] !== undefined) input.is_due_date_complete = this.flags['mark-done'];
if (this.flags.archive) input.archived_at = new Date().toISOString();
if (this.flags.archive) input.archived_at = toOtperDateTime();
if (this.flags.unarchive) input.archived_at = null;
const card = await updateCard(this.api, input);
this.output([card], { columns: COLUMNS, vertical: true, json: card });
Expand Down
1 change: 1 addition & 0 deletions src/commands/list/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class ListShow extends BaseCommand<typeof ListShow> {
this.log(JSON.stringify(list, null, 2));
return;
}
if (this.flags.format === 'silent') return;
this.log(`List: ${list.name} (id ${list.id})`);
this.log(
`Cards: ${list.cards.paginatorInfo.total} total, page ${list.cards.paginatorInfo.currentPage}/${list.cards.paginatorInfo.lastPage}`,
Expand Down
1 change: 0 additions & 1 deletion src/commands/team/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const COLUMNS: Column<Team>[] = [
{ header: 'Slug', get: (t) => t.slug },
{ header: 'Name', get: (t) => t.name },
{ header: 'Personal', get: (t) => (t.personal_team ? 'yes' : 'no') },
{ header: 'Private', get: (t) => (t.is_private ? 'yes' : 'no') },
{ header: 'Members', get: (t) => t.users?.length ?? 0 },
{ header: 'Boards', get: (t) => t.boards?.length ?? 0 },
];
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export {
} from './api/config';

export * from './api/types';
export { toOtperDateTime } from './api/datetime';
export * as boards from './api/boards';
export * as lists from './api/lists';
export * as cards from './api/cards';
Expand Down
Loading