diff --git a/package-lock.json b/package-lock.json index a1a2e9e..9f4118b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ssntpl/otper-cli", - "version": "0.1.6", + "version": "0.1.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@ssntpl/otper-cli", - "version": "0.1.6", + "version": "0.1.7", "license": "MIT", "dependencies": { "@oclif/core": "^4.0.30", diff --git a/package.json b/package.json index 5125503..0511a98 100644 --- a/package.json +++ b/package.json @@ -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 ", "license": "MIT", diff --git a/src/api/cards.ts b/src/api/cards.ts index fbd991a..c2895ad 100644 --- a/src/api/cards.ts +++ b/src/api/cards.ts @@ -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 } } `; @@ -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; diff --git a/src/api/datetime.ts b/src/api/datetime.ts new file mode 100644 index 0000000..55d7861 --- /dev/null +++ b/src/api/datetime.ts @@ -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", " "); +} diff --git a/src/api/lists.ts b/src/api/lists.ts index ecc94dd..0b87819 100644 --- a/src/api/lists.ts +++ b/src/api/lists.ts @@ -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 } } `; @@ -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 } }, ); diff --git a/src/api/teams.ts b/src/api/teams.ts index e1c86b6..c5f4fb9 100644 --- a/src/api/teams.ts +++ b/src/api/teams.ts @@ -8,7 +8,6 @@ const TEAM_QUERY = /* GraphQL */ ` slug name personal_team - is_private created_at users { id @@ -21,7 +20,6 @@ const TEAM_QUERY = /* GraphQL */ ` slug name key - is_private } } } diff --git a/src/api/types.ts b/src/api/types.ts index 39b2b92..0b61658 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -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[]; diff --git a/src/commands/card/assign.ts b/src/commands/card/assign.ts index 308e228..013f32e 100644 --- a/src/commands/card/assign.ts +++ b/src/commands/card/assign.ts @@ -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[] = [ @@ -23,7 +24,7 @@ export default class CardAssign extends BaseCommand { async run(): Promise { 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 })) }, diff --git a/src/commands/card/update.ts b/src/commands/card/update.ts index 32d4b52..72f26f1 100644 --- a/src/commands/card/update.ts +++ b/src/commands/card/update.ts @@ -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[] = [ @@ -40,7 +41,7 @@ export default class CardUpdate extends BaseCommand { 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 }); diff --git a/src/commands/list/show.ts b/src/commands/list/show.ts index 0183b12..9d8b40b 100644 --- a/src/commands/list/show.ts +++ b/src/commands/list/show.ts @@ -34,6 +34,7 @@ export default class ListShow extends BaseCommand { 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}`, diff --git a/src/commands/team/show.ts b/src/commands/team/show.ts index 770d529..d3180cf 100644 --- a/src/commands/team/show.ts +++ b/src/commands/team/show.ts @@ -9,7 +9,6 @@ const COLUMNS: Column[] = [ { 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 }, ]; diff --git a/src/index.ts b/src/index.ts index c3d9c7c..0e0c8b8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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';