innernote 0.6.1 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +29 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -501,12 +501,34 @@ function resolveRef(ref) {
501
501
  }
502
502
 
503
503
  // src/posts.ts
504
+ var LIST_PAGE = 50;
504
505
  async function listPosts(status) {
505
- const data = await request(`/api/posts${status ? `?status=${encodeURIComponent(status)}` : ""}`);
506
- return data.posts;
506
+ if (status === "ready" || status === "scheduled") {
507
+ const data = await request(`/api/posts?status=${encodeURIComponent(status)}`);
508
+ return data.posts;
509
+ }
510
+ const list = status ? `status:${status}` : "every";
511
+ const posts = [];
512
+ let cursor = null;
513
+ do {
514
+ const query = new URLSearchParams({ list, sort: "newest", limit: String(LIST_PAGE) });
515
+ if (cursor)
516
+ query.set("cursor", cursor);
517
+ const page = await request(`/api/posts/list?${query}`);
518
+ posts.push(...page.posts);
519
+ cursor = page.done ? null : page.cursor;
520
+ } while (cursor);
521
+ return posts;
507
522
  }
508
523
  async function fetchPost(id) {
509
- return (await listPosts()).find((p) => p._id === id) ?? null;
524
+ try {
525
+ const data = await request(`/api/posts/${encodeURIComponent(id)}`);
526
+ return data.post ?? null;
527
+ } catch (err) {
528
+ if (isApiError2(err) && err.status === 404)
529
+ return null;
530
+ throw err;
531
+ }
510
532
  }
511
533
  async function listSeries() {
512
534
  const data = await request("/api/campaigns");
@@ -2107,7 +2129,7 @@ function landing(state) {
2107
2129
  if (state.ideas)
2108
2130
  counts.push(`${state.ideas} ${state.ideas === 1 ? "idea" : "ideas"} waiting`);
2109
2131
  if (state.drafts)
2110
- counts.push(`${state.drafts} ${state.drafts === 1 ? "draft" : "drafts"}`);
2132
+ counts.push(`${state.drafts}${state.moreDrafts ? "+" : ""} ${state.drafts === 1 && !state.moreDrafts ? "draft" : "drafts"}`);
2111
2133
  if (counts.length)
2112
2134
  rows.push(dim2(counts.join(" ")));
2113
2135
  if (state.next) {
@@ -2146,7 +2168,7 @@ function suggest(state) {
2146
2168
  // package.json
2147
2169
  var package_default = {
2148
2170
  name: "innernote",
2149
- version: "0.6.1",
2171
+ version: "0.6.5",
2150
2172
  description: "Write LinkedIn posts in your voice, from the terminal.",
2151
2173
  keywords: [
2152
2174
  "linkedin",
@@ -2222,7 +2244,7 @@ async function home(inSession = false) {
2222
2244
  request("/api/devices/me").catch(() => null),
2223
2245
  request(`/api/posts/calendar?start=${monday.getTime()}&end=${monday.getTime() + 7 * DAY}`).catch(() => null),
2224
2246
  request("/api/ideas").catch(() => null),
2225
- request("/api/posts?status=draft").catch(() => null)
2247
+ request("/api/posts/list?list=drafts&sort=newest&limit=50").catch(() => null)
2226
2248
  ]);
2227
2249
  const posts = week2?.posts ?? [];
2228
2250
  const scheduled = posts.filter((p) => !p.publishedAt).length;
@@ -2237,6 +2259,7 @@ async function home(inSession = false) {
2237
2259
  `).map((l) => l.replace(/^ {2}/, "")) : null,
2238
2260
  ideas: ideas2?.ideas.length,
2239
2261
  drafts: drafts2?.posts.length,
2262
+ moreDrafts: drafts2 ? !drafts2.done : false,
2240
2263
  next: (() => {
2241
2264
  const n = suggest({
2242
2265
  scheduled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "innernote",
3
- "version": "0.6.1",
3
+ "version": "0.6.5",
4
4
  "description": "Write LinkedIn posts in your voice, from the terminal.",
5
5
  "keywords": [
6
6
  "linkedin",