sequences.js
1 import { cli, Strategy } from '@jackwener/opencli/registry'; 2 import { DOMAIN, SITE, gqlRequest } from './_helpers.js'; 3 cli({ 4 site: SITE, 5 name: 'sequences', 6 description: 'List post collections', 7 domain: DOMAIN, 8 strategy: Strategy.PUBLIC, 9 browser: false, 10 args: [{ name: 'limit', type: 'int', default: 10, help: 'Number of results' }], 11 columns: ['rank', 'title', 'author'], 12 func: async (_page, kwargs) => { 13 const limit = Number(kwargs.limit ?? 10); 14 const query = `query Sequences { 15 sequences(input: {terms: {view: "communitySequences", limit: ${limit}}}) { 16 results { _id title user { displayName } createdAt } 17 } 18 }`; 19 const data = await gqlRequest(query); 20 const sequences = (data?.sequences?.results ?? []); 21 return sequences.map((item, i) => ({ 22 rank: i + 1, 23 title: item.title ?? '', 24 author: item.user?.displayName ?? 'Unknown', 25 })); 26 }, 27 });