me.js
1 import { cli, Strategy } from '@jackwener/opencli/registry'; 2 import { CliError } from '@jackwener/opencli/errors'; 3 import { onesFetchInPage } from './common.js'; 4 cli({ 5 site: 'ones', 6 name: 'me', 7 description: 'ONES Project API — current user (GET users/me) via Chrome Bridge', 8 domain: 'ones.cn', 9 strategy: Strategy.COOKIE, 10 browser: true, 11 navigateBefore: false, 12 args: [], 13 columns: ['uuid', 'name', 'email', 'phone', 'status'], 14 func: async (page) => { 15 const data = (await onesFetchInPage(page, 'users/me')); 16 const u = data.user && typeof data.user === 'object' ? data.user : data; 17 if (!u || typeof u.uuid !== 'string') { 18 throw new CliError('FETCH_ERROR', 'Unexpected users/me response', 'See raw JSON with: opencli ones me -f json'); 19 } 20 return [ 21 { 22 uuid: String(u.uuid), 23 name: String(u.name ?? ''), 24 email: String(u.email ?? ''), 25 phone: String(u.phone ?? ''), 26 status: u.status != null ? String(u.status) : '', 27 }, 28 ]; 29 }, 30 });