innernote 0.6.0 → 0.6.3

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 +46 -12
  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");
@@ -1475,13 +1497,22 @@ async function askAboutPost(refArg, message, target, json) {
1475
1497
  }
1476
1498
  }
1477
1499
  if (json) {
1478
- out(JSON.stringify({ id: post._id, changed: !!result.changed, post: stored, passage: result.fragment ?? null, reply: result.reply ?? null }, null, 2));
1500
+ out(JSON.stringify({
1501
+ id: post._id,
1502
+ changed: !!result.changed,
1503
+ post: stored,
1504
+ passage: result.fragment ?? null,
1505
+ removed: !!result.removed,
1506
+ reply: result.reply ?? null
1507
+ }, null, 2));
1479
1508
  return 0;
1480
1509
  }
1481
1510
  out();
1482
1511
  out(stored);
1483
1512
  out();
1484
- if (result.changed && result.fragment && target.passage !== undefined) {
1513
+ if (result.changed && result.removed && target.passage !== undefined) {
1514
+ note(dim2(`took out: ${target.passage}`));
1515
+ } else if (result.changed && result.fragment && target.passage !== undefined) {
1485
1516
  note(dim2(`was: ${target.passage}`));
1486
1517
  note(dim2(`now: ${result.fragment}`));
1487
1518
  }
@@ -1834,10 +1865,10 @@ var COMMANDS = {
1834
1865
  ask: {
1835
1866
  summary: "talk to the post in your own words, or edit one passage of it",
1836
1867
  usage: "innernote ask [--post <id>] [--passage <text> | --hook | --ending] [--preset <name> | --shape <name> | --product <name>] [what you want]",
1837
- detail: "The Writer, here. The app's composer is a conversation with the post in front of you, and this is the same assistant: it can change the post, answer a question about it, or say it would rather not. In a session it works on the post in hand. With --post it works on a saved post in one command, and the change is kept in the post's history. --passage is the editor's selection: the exact words to change, and only those change. --hook and --ending are the opening and closing block. --preset is a toolbar edit by name, --shape the format picker.",
1868
+ detail: "The Writer, here. The app's composer is a conversation with the post in front of you, and this is the same assistant: it can change the post, answer a question about it, or say it would rather not. In a session it works on the post in hand. With --post it works on a saved post in one command, and the change is kept in the post's history. --passage is the editor's selection: the exact words to change, and only those change; ask for them to go and they are taken out. --hook and --ending are the opening and closing block. --preset is a toolbar edit by name, --shape the format picker.",
1838
1869
  options: [
1839
1870
  ["--post <id>", "a saved post, by id, instead of the one in hand"],
1840
- ["--passage <text>", "change only these exact words of the post"],
1871
+ ["--passage <text>", "change, or take out, only these exact words of the post"],
1841
1872
  ["--hook, --ending", "change only the opening, or the closing"],
1842
1873
  ["--preset <name>", "on a passage: sharpen shorter punchier simpler example deslop concrete warmer list. On the post: tighten_all as_list as_story fix_spacing rewrite_hook rewrite_ending ending_question"],
1843
1874
  ["--shape <name>", "story opinion listicle contrarian experience howto lessons casestudy framework question announcement prediction beliefbreak"],
@@ -1850,6 +1881,7 @@ var COMMANDS = {
1850
1881
  'innernote ask --post p17abc... "make the opening shorter"',
1851
1882
  'innernote ask --post p17abc... --passage "we got lucky" "say what the luck actually was"',
1852
1883
  'innernote ask --post p17abc... --passage "we got lucky" --preset concrete',
1884
+ 'innernote ask --post p17abc... --passage "comment voice for the link." "take this line out"',
1853
1885
  "innernote ask --post p17abc... --preset ending_question",
1854
1886
  "innernote ask --post p17abc... --shape story",
1855
1887
  'innernote ask --post p17abc... --product "innernote"'
@@ -2097,7 +2129,7 @@ function landing(state) {
2097
2129
  if (state.ideas)
2098
2130
  counts.push(`${state.ideas} ${state.ideas === 1 ? "idea" : "ideas"} waiting`);
2099
2131
  if (state.drafts)
2100
- counts.push(`${state.drafts} ${state.drafts === 1 ? "draft" : "drafts"}`);
2132
+ counts.push(`${state.drafts}${state.moreDrafts ? "+" : ""} ${state.drafts === 1 && !state.moreDrafts ? "draft" : "drafts"}`);
2101
2133
  if (counts.length)
2102
2134
  rows.push(dim2(counts.join(" ")));
2103
2135
  if (state.next) {
@@ -2136,7 +2168,7 @@ function suggest(state) {
2136
2168
  // package.json
2137
2169
  var package_default = {
2138
2170
  name: "innernote",
2139
- version: "0.6.0",
2171
+ version: "0.6.3",
2140
2172
  description: "Write LinkedIn posts in your voice, from the terminal.",
2141
2173
  keywords: [
2142
2174
  "linkedin",
@@ -2212,7 +2244,7 @@ async function home(inSession = false) {
2212
2244
  request("/api/devices/me").catch(() => null),
2213
2245
  request(`/api/posts/calendar?start=${monday.getTime()}&end=${monday.getTime() + 7 * DAY}`).catch(() => null),
2214
2246
  request("/api/ideas").catch(() => null),
2215
- request("/api/posts?status=draft").catch(() => null)
2247
+ request("/api/posts/list?list=drafts&sort=newest&limit=50").catch(() => null)
2216
2248
  ]);
2217
2249
  const posts = week2?.posts ?? [];
2218
2250
  const scheduled = posts.filter((p) => !p.publishedAt).length;
@@ -2227,6 +2259,7 @@ async function home(inSession = false) {
2227
2259
  `).map((l) => l.replace(/^ {2}/, "")) : null,
2228
2260
  ideas: ideas2?.ideas.length,
2229
2261
  drafts: drafts2?.posts.length,
2262
+ moreDrafts: drafts2 ? !drafts2.done : false,
2230
2263
  next: (() => {
2231
2264
  const n = suggest({
2232
2265
  scheduled,
@@ -2827,10 +2860,10 @@ var COMMANDS2 = {
2827
2860
  ask: {
2828
2861
  summary: "talk to the post in your own words, or edit one passage of it",
2829
2862
  usage: "innernote ask [--post <id>] [--passage <text> | --hook | --ending] [--preset <name> | --shape <name> | --product <name>] [what you want]",
2830
- detail: "The Writer, here. The app's composer is a conversation with the post in front of you, and this is the same assistant: it can change the post, answer a question about it, or say it would rather not. In a session it works on the post in hand. With --post it works on a saved post in one command, and the change is kept in the post's history. --passage is the editor's selection: the exact words to change, and only those change. --hook and --ending are the opening and closing block. --preset is a toolbar edit by name, --shape the format picker.",
2863
+ detail: "The Writer, here. The app's composer is a conversation with the post in front of you, and this is the same assistant: it can change the post, answer a question about it, or say it would rather not. In a session it works on the post in hand. With --post it works on a saved post in one command, and the change is kept in the post's history. --passage is the editor's selection: the exact words to change, and only those change; ask for them to go and they are taken out. --hook and --ending are the opening and closing block. --preset is a toolbar edit by name, --shape the format picker.",
2831
2864
  options: [
2832
2865
  ["--post <id>", "a saved post, by id, instead of the one in hand"],
2833
- ["--passage <text>", "change only these exact words of the post"],
2866
+ ["--passage <text>", "change, or take out, only these exact words of the post"],
2834
2867
  ["--hook, --ending", "change only the opening, or the closing"],
2835
2868
  ["--preset <name>", "on a passage: sharpen shorter punchier simpler example deslop concrete warmer list. On the post: tighten_all as_list as_story fix_spacing rewrite_hook rewrite_ending ending_question"],
2836
2869
  ["--shape <name>", "story opinion listicle contrarian experience howto lessons casestudy framework question announcement prediction beliefbreak"],
@@ -2843,6 +2876,7 @@ var COMMANDS2 = {
2843
2876
  'innernote ask --post p17abc... "make the opening shorter"',
2844
2877
  'innernote ask --post p17abc... --passage "we got lucky" "say what the luck actually was"',
2845
2878
  'innernote ask --post p17abc... --passage "we got lucky" --preset concrete',
2879
+ 'innernote ask --post p17abc... --passage "comment voice for the link." "take this line out"',
2846
2880
  "innernote ask --post p17abc... --preset ending_question",
2847
2881
  "innernote ask --post p17abc... --shape story",
2848
2882
  'innernote ask --post p17abc... --product "innernote"'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "innernote",
3
- "version": "0.6.0",
3
+ "version": "0.6.3",
4
4
  "description": "Write LinkedIn posts in your voice, from the terminal.",
5
5
  "keywords": [
6
6
  "linkedin",