@appeeky/spec 0.3.0 → 0.4.0
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.
- package/README.md +36 -6
- package/agents/appeeky-social.md +12 -5
- package/agents/cofounder.md +1 -1
- package/dist/appeeky-api.d.ts +6 -0
- package/dist/appeeky-api.js +14 -3
- package/dist/cli.js +10 -5
- package/dist/social.d.ts +253 -17
- package/dist/social.js +296 -34
- package/package.json +1 -1
- package/skills/appeeky-spec-experiments/SKILL.md +2 -2
package/README.md
CHANGED
|
@@ -139,7 +139,7 @@ A field you leave out of a listing file is not managed by the spec: it is never
|
|
|
139
139
|
| `experiment add\|list\|close` | Track growth experiments outside the listing (screenshots, UGC, ads, pricing) with one metric and a check date. |
|
|
140
140
|
| `screenshots pull\|check` | Download the live App Store screenshots into `appeeky/screenshots/` and check their sizes. |
|
|
141
141
|
| `report` | Markdown for a pull request: listing changes, check results and coverage against `--base`. |
|
|
142
|
-
| `social pull\|check\|push` | Organic social media through the accounts connected in Appeeky: `pull` writes the accounts, recent posts and how they did to `appeeky/social/`; `check` checks the drafts in `appeeky/social/drafts/`; `push` sends them. Needs `APPEEKY_API_KEY`. |
|
|
142
|
+
| `social pull\|check\|push` | Organic social media through the accounts connected in Appeeky: `pull` writes the accounts, recent posts (made through Appeeky and in each platform's app), how they did, comments and followers to `appeeky/social/`; `check` checks the drafts in `appeeky/social/drafts/`; `push` sends them. Needs `APPEEKY_API_KEY`. |
|
|
143
143
|
| `ugc pull\|generate` | UGC from your Appeeky creator personas: `pull` writes the personas and their clips to `appeeky/ugc/`; `generate` makes a clip from each brief in `appeeky/ugc/briefs/` (`--dry-run` shows the cost in media credits). Needs `APPEEKY_API_KEY`. |
|
|
144
144
|
| `agents install` | Write the specialist subagents and the `/appeeky-cofounder` review into `.claude/` (`--for opencode` or `all` for `.opencode/`). Files you changed are kept unless `--force`. |
|
|
145
145
|
|
|
@@ -275,9 +275,12 @@ With the social accounts and creator personas you set up in Appeeky, posts and v
|
|
|
275
275
|
|
|
276
276
|
```
|
|
277
277
|
appeeky/social/accounts.yaml connected accounts (platform, name, id)
|
|
278
|
-
appeeky/social/posts.jsonl
|
|
279
|
-
appeeky/social/
|
|
280
|
-
appeeky/social/
|
|
278
|
+
appeeky/social/posts.jsonl posts made through Appeeky and each platform's result: views, likes, comments, shares
|
|
279
|
+
appeeky/social/native-posts.jsonl posts made in the platform's own app, with the same numbers
|
|
280
|
+
appeeky/social/comments.jsonl recent comments under the accounts' posts
|
|
281
|
+
appeeky/social/insights.yaml followers and growth per account
|
|
282
|
+
appeeky/social/summary.md the last 30 days per platform and account, and what did best across all posts
|
|
283
|
+
appeeky/social/drafts/<name>.yaml a post to send: accounts, text, when, media, tiktok, why
|
|
281
284
|
appeeky/ugc/personas.yaml creator personas, and whether each can make clips yet
|
|
282
285
|
appeeky/ugc/clips.jsonl the clips made with them
|
|
283
286
|
appeeky/ugc/briefs/<name>.yaml a video to make: persona, script, scene, caption, why
|
|
@@ -286,14 +289,41 @@ appeeky/ugc/personas/<name>.yaml optional: a persona kept in the repo, with i
|
|
|
286
289
|
|
|
287
290
|
```yaml
|
|
288
291
|
# appeeky/social/drafts/2026-11-10-fan-sounds.yaml
|
|
289
|
-
accounts: [twitter,
|
|
292
|
+
accounts: [twitter, tiktok:@sleepysounds]
|
|
290
293
|
text: "Fan sounds are here. Pick a fan, set a timer, sleep."
|
|
291
294
|
when: "2026-11-12T16:00:00Z" # without it, the post goes out when it is sent
|
|
292
295
|
media: ["https://…/fan.mp4"] # Instagram, TikTok and Pinterest need one
|
|
296
|
+
tiktok:
|
|
297
|
+
disclosure: own_brand # it promotes your own app
|
|
298
|
+
inbox_draft: true # lands in the TikTok inbox; finish it in the app
|
|
293
299
|
why: "Users asked for fan sounds in 9 reviews; it shipped in 3.2."
|
|
294
300
|
```
|
|
295
301
|
|
|
296
|
-
|
|
302
|
+
Each entry in `accounts` is one of:
|
|
303
|
+
|
|
304
|
+
| Entry | Goes to |
|
|
305
|
+
| --- | --- |
|
|
306
|
+
| `twitter`, `x`, `instagram`, … | the one account connected on that platform; with several, `check` fails and lists their handles |
|
|
307
|
+
| `tiktok:all` | every account connected on that platform |
|
|
308
|
+
| `@sleepysounds`, `u/sleepdev` | the account with that handle (add the platform when two platforms share it) |
|
|
309
|
+
| `tiktok:@sleepysounds` | that handle on that platform |
|
|
310
|
+
| an `id` from accounts.yaml | that account |
|
|
311
|
+
|
|
312
|
+
The `tiktok` block applies to the TikTok accounts the draft goes to. Every key is optional:
|
|
313
|
+
|
|
314
|
+
| Key | Values | Default |
|
|
315
|
+
| --- | --- | --- |
|
|
316
|
+
| `privacy` | `public`, `friends`, `followers`, `only_me` | `public` |
|
|
317
|
+
| `disclosure` | `none`, `own_brand` (promotes your own app or business), `paid_partnership` | `none` |
|
|
318
|
+
| `inbox_draft` | `true` uploads it to the creator's TikTok inbox to finish and post in the app, for example to add TikTok's AI-generated label | `false` |
|
|
319
|
+
| `comments` | `false` turns comments off | `true` |
|
|
320
|
+
| `title` | photo posts: up to 90 characters; the text becomes the description | |
|
|
321
|
+
| `auto_music` | photo posts: `true` lets TikTok add music | |
|
|
322
|
+
| `cover_index` | photo posts: the cover image, from 0 | |
|
|
323
|
+
| `cover_time_ms` | video posts: the frame used as the cover | |
|
|
324
|
+
| `cover_image_url` | video posts: an https image used as the cover | |
|
|
325
|
+
|
|
326
|
+
`social check` flags drafts that would fail: an account that is not connected, a platform name that matches several accounts, text over the platform's limit, a missing image, a time in the past, and TikTok's rules (a disclosed post can't be `only_me` unless it is an inbox draft, at most 35 images, images and a video can't mix, a title over 90 characters). `ugc generate --dry-run` shows what each brief costs in media credits without making anything. The push workflow written by `init --ci` (and the docker `push` routine) runs `social push --yes` and `ugc generate --yes` when a merged pull request adds drafts or briefs; each is marked `sent` or `generating` and committed, so it never goes out twice. Social media needs the Startup plan or above in Appeeky; a persona needs a look (reference images) before it can make clips.
|
|
297
327
|
|
|
298
328
|
### Clips on your own fal key
|
|
299
329
|
|
package/agents/appeeky-social.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: appeeky-social
|
|
3
|
-
description: Social media specialist for an Appeeky Spec repo. Reads the accounts connected in Appeeky
|
|
3
|
+
description: Social media specialist for an Appeeky Spec repo. Reads the accounts connected in Appeeky, how every post on them did (made through Appeeky or in the platform's app) and what commenters say, what shipped and what won, the next version's notes, what users say and which channels bring installs, and returns posts to publish, drafted per connected account, with the link to use. Use it in the co-founder review, or when asked what to post this week.
|
|
4
4
|
tools: Read, Grep, Glob, Bash
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -10,8 +10,12 @@ Run the CLI the way the co-founder tells you (`appeeky-spec <command> --json` or
|
|
|
10
10
|
|
|
11
11
|
## Read
|
|
12
12
|
|
|
13
|
-
- `appeeky/social/accounts.yaml`: the accounts connected in Appeeky. Only draft for these
|
|
14
|
-
- `appeeky/social/summary.md
|
|
13
|
+
- `appeeky/social/accounts.yaml`: the accounts connected in Appeeky. Only draft for these accounts. A platform can have several (one TikTok account per theme, say); each has its own audience.
|
|
14
|
+
- `appeeky/social/summary.md`: the last 30 days per platform and per account, followers, the posts that did best across all of them, posts waiting to go out or sitting in the TikTok inbox
|
|
15
|
+
- `appeeky/social/posts.jsonl`: posts made through Appeeky, and how each did (views, likes, comments, shares)
|
|
16
|
+
- `appeeky/social/native-posts.jsonl`: posts made in the platform's own app, with the same numbers. Most of an account's history is often here, so read it before deciding which hooks work.
|
|
17
|
+
- `appeeky/social/comments.jsonl`: what people write under the posts (`own: true` is the account replying). Questions and objections here are post ideas.
|
|
18
|
+
- `appeeky/social/insights.yaml`: followers and growth per account
|
|
15
19
|
- `appeeky/social/drafts/`: drafts already waiting, so you do not repeat them
|
|
16
20
|
- `status --json`, `log --json` and `appeeky/releases/*.yaml`: what went live and what won
|
|
17
21
|
- `whatsNew` in `appeeky/store/**`, and the app's git history since the last version tag (`git log --oneline`, `git tag`)
|
|
@@ -26,11 +30,14 @@ Run the CLI the way the co-founder tells you (`appeeky-spec <command> --json` or
|
|
|
26
30
|
- A result worth sharing (a rank won, a rating that rose), said plainly
|
|
27
31
|
- Something users praise that the posts never mention
|
|
28
32
|
- The channels that bring installs that pay, so posts go there first
|
|
29
|
-
-
|
|
33
|
+
- Which hooks (the first line) did best on each account, across all its posts, and what never got seen
|
|
34
|
+
- What commenters ask again and again
|
|
30
35
|
|
|
31
36
|
## Rules
|
|
32
37
|
|
|
33
38
|
- Draft each post for its channel: X (under 280 characters), Instagram (a caption and what the image shows), TikTok (the first line on screen and a caption).
|
|
39
|
+
- Name each account by its handle from `accounts.yaml` (`tiktok:@sleepysounds`), and write each post for that account's theme. A bare platform name only works when one account is connected on it; post the same thing on every account of a platform only when it fits all of them (`tiktok:all`).
|
|
40
|
+
- TikTok: when the post promotes the user's own app, it is branded content: say `disclosure: own_brand`. When the video or images are AI-generated (UGC clips, generated images), TikTok wants its AI-generated label, which Appeeky cannot set yet: say `inbox_draft: true`, so the post lands in the creator's TikTok inbox and they add the label in the app before posting.
|
|
34
41
|
- Only what the app does today, from the repo. No made-up numbers, quotes or dates. Quote users only from the review files, without names.
|
|
35
42
|
- Suggest a smart link per channel when `attribution:` is set up, so the post is measured.
|
|
36
43
|
- Instagram, TikTok and Pinterest need an image or video: name one that exists (a public URL), or say a person has to add it.
|
|
@@ -47,7 +54,7 @@ Edit files, post anything, or run `push`, `pull`, `experiment add` or any comman
|
|
|
47
54
|
Findings
|
|
48
55
|
- <one line each, max 5: what shipped or won, and which channels bring installs>
|
|
49
56
|
Posts to publish (a person posts them)
|
|
50
|
-
1. <platform from accounts.yaml>: "<post text>" (<count>/<limit>). When: <ISO time, or "now">. Media: <URL or "a person adds one">. Why now: <the release or
|
|
57
|
+
1. <platform:@handle from accounts.yaml>: "<post text>" (<count>/<limit>). When: <ISO time, or "now">. Media: <URL or "a person adds one">. TikTok: <disclosure, inbox_draft, privacy, or "defaults">. Why now: <the release, result or comment>. Link: <smart link channel or "none">
|
|
51
58
|
2. <channel>: ...
|
|
52
59
|
Missing data
|
|
53
60
|
- <what is missing, and the command that fills it>
|
package/agents/cofounder.md
CHANGED
|
@@ -27,7 +27,7 @@ Run the review below, write the brief, and propose at most one listing change.
|
|
|
27
27
|
- **Not now:** good candidates you did not pick, and why
|
|
28
28
|
|
|
29
29
|
6. **Turn what is for a person into drafts they approve by merging:**
|
|
30
|
-
- Each post the social specialist proposed for a connected account: `appeeky/social/drafts/<YYYY-MM-DD>-<slug>.yaml` with `accounts` (
|
|
30
|
+
- Each post the social specialist proposed for a connected account: `appeeky/social/drafts/<YYYY-MM-DD>-<slug>.yaml` with `accounts` (each as `<platform>:@handle` from `appeeky/social/accounts.yaml`; a bare platform only when one account is connected on it), `text`, `when` (ISO, at least a day ahead), `media` (public URLs, when the platform needs one), `tiktok` for TikTok posts (`disclosure: own_brand` when it promotes the app, `inbox_draft: true` when the media is AI-generated) and `why`. Run `social check` and fix every problem, or leave the post out.
|
|
31
31
|
- The video the UGC specialist proposed, if a persona is ready: `appeeky/ugc/briefs/<YYYY-MM-DD>-<slug>.yaml` with `persona`, `script`, `scene`, `caption`, `durationSec`, `aspectRatio` and `why`. Run `ugc generate --dry-run` to show its cost in credits.
|
|
32
32
|
- After the merge, `social push` sends the posts and `ugc generate` makes the clips. Never run those yourself.
|
|
33
33
|
|
package/dist/appeeky-api.d.ts
CHANGED
|
@@ -9,6 +9,12 @@ export interface KeywordMetric {
|
|
|
9
9
|
fetchedAt: string;
|
|
10
10
|
}
|
|
11
11
|
type Fetcher = typeof fetch;
|
|
12
|
+
/** An error answer from the Appeeky API, with its HTTP status and error code, so callers can tell "not there" from "failed". */
|
|
13
|
+
export declare class AppeekyApiError extends Error {
|
|
14
|
+
readonly status: number;
|
|
15
|
+
readonly code?: string | undefined;
|
|
16
|
+
constructor(message: string, status: number, code?: string | undefined);
|
|
17
|
+
}
|
|
12
18
|
/**
|
|
13
19
|
* Small client for the Appeeky API (market data for ASO). Needs an API key
|
|
14
20
|
* from appeeky.com; every command that uses it also works without it.
|
package/dist/appeeky-api.js
CHANGED
|
@@ -4,6 +4,17 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { combineSources, summarizeMeta, summarizeMetrics, summarizeTikTok, } from "./metrics.js";
|
|
5
5
|
import { normalize } from "./text.js";
|
|
6
6
|
export const APPEEKY_API_URL = "https://api.appeeky.com/v1";
|
|
7
|
+
/** An error answer from the Appeeky API, with its HTTP status and error code, so callers can tell "not there" from "failed". */
|
|
8
|
+
export class AppeekyApiError extends Error {
|
|
9
|
+
status;
|
|
10
|
+
code;
|
|
11
|
+
constructor(message, status, code) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.name = "AppeekyApiError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
7
18
|
/**
|
|
8
19
|
* Small client for the Appeeky API (market data for ASO). Needs an API key
|
|
9
20
|
* from appeeky.com; every command that uses it also works without it.
|
|
@@ -25,7 +36,7 @@ export class AppeekyApi {
|
|
|
25
36
|
const body = (await res.json().catch(() => null));
|
|
26
37
|
if (!res.ok) {
|
|
27
38
|
const retry = res.headers.get("retry-after");
|
|
28
|
-
throw new
|
|
39
|
+
throw new AppeekyApiError(`Appeeky API ${path}: ${body?.error?.message ?? `HTTP ${res.status}`}${retry ? ` (retry after ${retry}s)` : ""}`, res.status, body?.error?.code);
|
|
29
40
|
}
|
|
30
41
|
return body?.data;
|
|
31
42
|
}
|
|
@@ -37,7 +48,7 @@ export class AppeekyApi {
|
|
|
37
48
|
});
|
|
38
49
|
const json = (await res.json().catch(() => null));
|
|
39
50
|
if (!res.ok)
|
|
40
|
-
throw new
|
|
51
|
+
throw new AppeekyApiError(`Appeeky API ${path}: ${json?.error?.message ?? `HTTP ${res.status}`}`, res.status, json?.error?.code);
|
|
41
52
|
return json?.data;
|
|
42
53
|
}
|
|
43
54
|
/** Any other method, e.g. DELETE. */
|
|
@@ -49,7 +60,7 @@ export class AppeekyApi {
|
|
|
49
60
|
});
|
|
50
61
|
const json = (await res.json().catch(() => null));
|
|
51
62
|
if (!res.ok)
|
|
52
|
-
throw new
|
|
63
|
+
throw new AppeekyApiError(`Appeeky API ${path}: ${json?.error?.message ?? `HTTP ${res.status}`}`, res.status, json?.error?.code);
|
|
53
64
|
return json?.data;
|
|
54
65
|
}
|
|
55
66
|
/** Keyword opportunities for an app: popular searches it does not rank for yet. */
|
package/dist/cli.js
CHANGED
|
@@ -880,7 +880,7 @@ export function buildProgram() {
|
|
|
880
880
|
const social = program.command("social").description("Organic social media in the repo: accounts, posts and their results, and posts sent through a pull request (needs APPEEKY_API_KEY)");
|
|
881
881
|
social
|
|
882
882
|
.command("pull")
|
|
883
|
-
.description("Write the connected accounts, recent posts and their analytics to appeeky/social/, and summary.md")
|
|
883
|
+
.description("Write the connected accounts, recent posts and their analytics, posts made in the platform apps, comments and followers to appeeky/social/, and summary.md")
|
|
884
884
|
.option("--limit <n>", "How many recent posts", "100")
|
|
885
885
|
.action(async (opts) => {
|
|
886
886
|
const project = await load();
|
|
@@ -890,16 +890,21 @@ export function buildProgram() {
|
|
|
890
890
|
const data = await fetchSocial(a, { limit: Number(opts.limit) || 100 });
|
|
891
891
|
await saveSocial(project.root, data);
|
|
892
892
|
if (g().json) {
|
|
893
|
-
printJson({ accounts: data.accounts.length, posts: data.posts.length });
|
|
893
|
+
printJson({ accounts: data.accounts.length, posts: data.posts.length, nativePosts: data.nativePosts?.length ?? null, comments: data.comments?.length ?? null, insights: data.insights?.length ?? null, warnings: data.warnings ?? [] });
|
|
894
894
|
return;
|
|
895
895
|
}
|
|
896
896
|
console.log(`${c.bold("Accounts")} ${data.accounts.map((x) => `${x.platform} (${x.name})`).join(", ") || c.dim("none connected")}`);
|
|
897
|
-
console.log(`${c.bold("Posts")} ${data.posts.length} · ${data.posts.filter((p) => p.platforms.some((x) => x.publishedAt)).length} published`);
|
|
898
|
-
|
|
897
|
+
console.log(`${c.bold("Posts")} ${data.posts.length} through Appeeky · ${data.posts.filter((p) => p.platforms.some((x) => x.publishedAt)).length} published${data.nativePosts ? ` · ${data.nativePosts.length} made in the apps` : ""}`);
|
|
898
|
+
if (data.comments)
|
|
899
|
+
console.log(`${c.bold("Comments")} ${data.comments.length}`);
|
|
900
|
+
for (const w of data.warnings ?? [])
|
|
901
|
+
console.log(`${c.yellow("warn ")} ${w}`);
|
|
902
|
+
const files = ["accounts.yaml", "posts.jsonl", data.nativePosts && "native-posts.jsonl", data.comments && "comments.jsonl", data.insights && "insights.yaml", "summary.md"].filter(Boolean);
|
|
903
|
+
console.log(c.dim(`Written to appeeky/social/: ${files.join(", ")}.`));
|
|
899
904
|
});
|
|
900
905
|
social
|
|
901
906
|
.command("check")
|
|
902
|
-
.description("Check the drafts in appeeky/social/drafts/:
|
|
907
|
+
.description("Check the drafts in appeeky/social/drafts/: which account each goes to, length, media, TikTok options, time")
|
|
903
908
|
.action(async () => {
|
|
904
909
|
const project = await load();
|
|
905
910
|
const accounts = await readAccounts(project.root);
|
package/dist/social.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type
|
|
2
|
+
import { type AppeekyApi } from "./appeeky-api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Organic social media in the repo, through the accounts connected in Appeeky (APPEEKY_API_KEY,
|
|
5
5
|
* Startup plan or above):
|
|
6
6
|
*
|
|
7
7
|
* appeeky/social/accounts.yaml the connected accounts (platform, name, id)
|
|
8
|
-
* appeeky/social/posts.jsonl recent posts, one per line, with each platform's result
|
|
9
|
-
* appeeky/social/
|
|
8
|
+
* appeeky/social/posts.jsonl recent posts made through Appeeky, one per line, with each platform's result
|
|
9
|
+
* appeeky/social/native-posts.jsonl posts made in the platform's own app, with their results
|
|
10
|
+
* appeeky/social/comments.jsonl recent comments on the accounts' posts
|
|
11
|
+
* appeeky/social/insights.yaml followers and growth per account
|
|
12
|
+
* appeeky/social/summary.md the last 30 days per account and platform, and the posts that did best
|
|
10
13
|
* appeeky/social/drafts/<name>.yaml a post: drafted, reviewed in a pull request, then sent
|
|
11
14
|
*
|
|
12
15
|
* Sending creates the post in Appeeky, which publishes it right away, or at `when`.
|
|
@@ -25,8 +28,59 @@ export interface SocialPlatformResult {
|
|
|
25
28
|
url?: string;
|
|
26
29
|
publishedAt?: string;
|
|
27
30
|
error?: string;
|
|
31
|
+
/** Uploaded to the creator's TikTok inbox: they finish and post it in the app, so there is no public URL yet. */
|
|
32
|
+
draft?: boolean;
|
|
28
33
|
metrics?: Partial<Record<SocialMetric, number>>;
|
|
29
34
|
}
|
|
35
|
+
/** A post made in the platform's own app, not through Appeeky. */
|
|
36
|
+
export interface NativePost {
|
|
37
|
+
id: string;
|
|
38
|
+
account: string;
|
|
39
|
+
platform: string;
|
|
40
|
+
url?: string;
|
|
41
|
+
text: string;
|
|
42
|
+
mediaType?: string;
|
|
43
|
+
publishedAt?: string;
|
|
44
|
+
metrics?: Partial<Record<SocialMetric | "engagementRate", number>>;
|
|
45
|
+
}
|
|
46
|
+
export interface SocialComment {
|
|
47
|
+
id: string;
|
|
48
|
+
account: string;
|
|
49
|
+
platform: string;
|
|
50
|
+
postUrl?: string;
|
|
51
|
+
postId?: string;
|
|
52
|
+
platformPostId?: string;
|
|
53
|
+
text: string;
|
|
54
|
+
author?: string;
|
|
55
|
+
own?: boolean;
|
|
56
|
+
reply?: boolean;
|
|
57
|
+
at?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface AccountInsights {
|
|
60
|
+
account: string;
|
|
61
|
+
platform: string;
|
|
62
|
+
followers?: number;
|
|
63
|
+
growth?: number;
|
|
64
|
+
growthPercentage?: number;
|
|
65
|
+
stats?: Record<string, unknown>;
|
|
66
|
+
history?: Array<{
|
|
67
|
+
date: string;
|
|
68
|
+
followers: number;
|
|
69
|
+
}>;
|
|
70
|
+
updatedAt?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* What `social pull` writes. The native posts, comments and insights are left out (undefined) when
|
|
74
|
+
* the Appeeky API does not have them yet, so the files from an earlier pull are kept.
|
|
75
|
+
*/
|
|
76
|
+
export interface SocialData {
|
|
77
|
+
accounts: SocialAccount[];
|
|
78
|
+
posts: SocialPost[];
|
|
79
|
+
nativePosts?: NativePost[];
|
|
80
|
+
comments?: SocialComment[];
|
|
81
|
+
insights?: AccountInsights[];
|
|
82
|
+
warnings?: string[];
|
|
83
|
+
}
|
|
30
84
|
export interface SocialPost {
|
|
31
85
|
id: string;
|
|
32
86
|
status: string;
|
|
@@ -57,35 +111,179 @@ interface PostRow {
|
|
|
57
111
|
platform_post_url: string | null;
|
|
58
112
|
published_at: string | null;
|
|
59
113
|
error_message: string | null;
|
|
114
|
+
is_draft?: boolean | null;
|
|
60
115
|
}>;
|
|
61
116
|
}
|
|
117
|
+
interface ExternalPostRow {
|
|
118
|
+
id: string;
|
|
119
|
+
accountId: string;
|
|
120
|
+
platform: string;
|
|
121
|
+
platformPostId?: string | null;
|
|
122
|
+
platformPostUrl?: string | null;
|
|
123
|
+
content?: string | null;
|
|
124
|
+
thumbnailUrl?: string | null;
|
|
125
|
+
mediaType?: string | null;
|
|
126
|
+
publishedAt?: string | null;
|
|
127
|
+
metrics?: Record<string, unknown> | null;
|
|
128
|
+
}
|
|
129
|
+
interface CommentRow {
|
|
130
|
+
id: string;
|
|
131
|
+
accountId: string;
|
|
132
|
+
platform: string;
|
|
133
|
+
postId?: string | null;
|
|
134
|
+
platformPostId?: string | null;
|
|
135
|
+
postPermalink?: string | null;
|
|
136
|
+
text?: string | null;
|
|
137
|
+
author?: {
|
|
138
|
+
id?: string | null;
|
|
139
|
+
username?: string | null;
|
|
140
|
+
name?: string | null;
|
|
141
|
+
} | null;
|
|
142
|
+
isOwnAccount?: boolean | null;
|
|
143
|
+
isReply?: boolean | null;
|
|
144
|
+
parentCommentId?: string | null;
|
|
145
|
+
commentedAt?: string | null;
|
|
146
|
+
}
|
|
147
|
+
interface InsightsRow {
|
|
148
|
+
accountId: string;
|
|
149
|
+
platform: string;
|
|
150
|
+
followers?: number | null;
|
|
151
|
+
growth?: number | null;
|
|
152
|
+
growthPercentage?: number | null;
|
|
153
|
+
stats?: Record<string, unknown> | null;
|
|
154
|
+
history?: Array<{
|
|
155
|
+
date: string;
|
|
156
|
+
followers: number;
|
|
157
|
+
}> | null;
|
|
158
|
+
updatedAt?: string | null;
|
|
159
|
+
}
|
|
62
160
|
interface AnalyticsItem {
|
|
63
161
|
platform: string;
|
|
64
162
|
analytics: Record<string, unknown>;
|
|
65
163
|
}
|
|
66
164
|
export declare function toAccount(r: AccountRow): SocialAccount;
|
|
67
165
|
export declare function toPost(r: PostRow, analytics?: AnalyticsItem[]): SocialPost;
|
|
68
|
-
|
|
166
|
+
export declare function toNativePost(r: ExternalPostRow, accounts: SocialAccount[]): NativePost;
|
|
167
|
+
export declare function toComment(r: CommentRow, accounts: SocialAccount[]): SocialComment;
|
|
168
|
+
export declare function toInsights(r: InsightsRow, account: SocialAccount): AccountInsights;
|
|
169
|
+
/**
|
|
170
|
+
* Connected accounts and the latest posts made through Appeeky, with analytics for the ones that
|
|
171
|
+
* went out; then, per account, the posts made in the platform's app, recent comments and followers.
|
|
172
|
+
*/
|
|
69
173
|
export declare function fetchSocial(api: AppeekyApi, options?: {
|
|
70
174
|
limit?: number;
|
|
71
|
-
}): Promise<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}>;
|
|
75
|
-
export declare function summaryMarkdown(accounts: SocialAccount[], posts: SocialPost[], now?: Date): string;
|
|
76
|
-
export declare function saveSocial(root: string, data: {
|
|
77
|
-
accounts: SocialAccount[];
|
|
78
|
-
posts: SocialPost[];
|
|
79
|
-
}, now?: Date): Promise<void>;
|
|
175
|
+
}): Promise<SocialData>;
|
|
176
|
+
export declare function summaryMarkdown(accounts: SocialAccount[], posts: SocialPost[], now?: Date, more?: Pick<SocialData, "nativePosts" | "comments" | "insights">): string;
|
|
177
|
+
export declare function saveSocial(root: string, data: SocialData, now?: Date): Promise<void>;
|
|
80
178
|
export declare function readAccounts(root: string): Promise<SocialAccount[]>;
|
|
179
|
+
/** TikTok's posting options, in the words a draft uses; each maps to a key of `extra.tiktok` in the API. */
|
|
180
|
+
export declare const PRIVACY: {
|
|
181
|
+
readonly public: "PUBLIC_TO_EVERYONE";
|
|
182
|
+
readonly friends: "MUTUAL_FOLLOW_FRIENDS";
|
|
183
|
+
readonly followers: "FOLLOWER_OF_CREATOR";
|
|
184
|
+
readonly only_me: "SELF_ONLY";
|
|
185
|
+
};
|
|
186
|
+
export declare const DISCLOSURE: {
|
|
187
|
+
readonly none: "none";
|
|
188
|
+
readonly own_brand: "brand_organic";
|
|
189
|
+
readonly paid_partnership: "brand_content";
|
|
190
|
+
};
|
|
191
|
+
export declare const TIKTOK_MAX_PHOTOS = 35;
|
|
192
|
+
export declare const TIKTOK_TITLE_LIMIT = 90;
|
|
193
|
+
declare const tiktokSchema: z.ZodObject<{
|
|
194
|
+
/** Who can see it: public (default), friends, followers or only_me. */
|
|
195
|
+
privacy: z.ZodOptional<z.ZodEnum<["followers" | "public" | "friends" | "only_me", ...("followers" | "public" | "friends" | "only_me")[]]>>;
|
|
196
|
+
/** Commercial content: none (default), own_brand (promotes your own app or business) or paid_partnership. */
|
|
197
|
+
disclosure: z.ZodOptional<z.ZodEnum<["none" | "own_brand" | "paid_partnership", ...("none" | "own_brand" | "paid_partnership")[]]>>;
|
|
198
|
+
/** Upload to the creator's TikTok inbox instead of posting: they finish and post it in the app. */
|
|
199
|
+
inbox_draft: z.ZodOptional<z.ZodBoolean>;
|
|
200
|
+
/** Photo posts: let TikTok add music. */
|
|
201
|
+
auto_music: z.ZodOptional<z.ZodBoolean>;
|
|
202
|
+
/** Allow comments (default true). */
|
|
203
|
+
comments: z.ZodOptional<z.ZodBoolean>;
|
|
204
|
+
/** Photo posts: the title; the text becomes the description. */
|
|
205
|
+
title: z.ZodOptional<z.ZodString>;
|
|
206
|
+
/** Photo posts: which image is the cover, from 0. */
|
|
207
|
+
cover_index: z.ZodOptional<z.ZodNumber>;
|
|
208
|
+
/** Video posts: the frame used as the cover, in milliseconds. */
|
|
209
|
+
cover_time_ms: z.ZodOptional<z.ZodNumber>;
|
|
210
|
+
/** Video posts: an https image used as the cover. */
|
|
211
|
+
cover_image_url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
212
|
+
}, "strict", z.ZodTypeAny, {
|
|
213
|
+
title?: string | undefined;
|
|
214
|
+
comments?: boolean | undefined;
|
|
215
|
+
privacy?: "followers" | "public" | "friends" | "only_me" | undefined;
|
|
216
|
+
disclosure?: "none" | "own_brand" | "paid_partnership" | undefined;
|
|
217
|
+
inbox_draft?: boolean | undefined;
|
|
218
|
+
auto_music?: boolean | undefined;
|
|
219
|
+
cover_index?: number | undefined;
|
|
220
|
+
cover_time_ms?: number | undefined;
|
|
221
|
+
cover_image_url?: string | undefined;
|
|
222
|
+
}, {
|
|
223
|
+
title?: string | undefined;
|
|
224
|
+
comments?: boolean | undefined;
|
|
225
|
+
privacy?: "followers" | "public" | "friends" | "only_me" | undefined;
|
|
226
|
+
disclosure?: "none" | "own_brand" | "paid_partnership" | undefined;
|
|
227
|
+
inbox_draft?: boolean | undefined;
|
|
228
|
+
auto_music?: boolean | undefined;
|
|
229
|
+
cover_index?: number | undefined;
|
|
230
|
+
cover_time_ms?: number | undefined;
|
|
231
|
+
cover_image_url?: string | undefined;
|
|
232
|
+
}>;
|
|
233
|
+
export type TikTokOptions = z.infer<typeof tiktokSchema>;
|
|
81
234
|
export declare const draftSchema: z.ZodObject<{
|
|
82
|
-
/**
|
|
235
|
+
/**
|
|
236
|
+
* Who it goes to: a platform with one connected account (`twitter`), every account on a
|
|
237
|
+
* platform (`tiktok:all`), a handle (`@sleepysounds`, `tiktok:@sleepysounds`, `u/name`) or an
|
|
238
|
+
* account id from accounts.yaml.
|
|
239
|
+
*/
|
|
83
240
|
accounts: z.ZodArray<z.ZodString, "many">;
|
|
84
241
|
text: z.ZodString;
|
|
85
242
|
/** ISO time to schedule it; without it, the post goes out when it is sent. */
|
|
86
243
|
when: z.ZodOptional<z.ZodString>;
|
|
87
244
|
/** Public image or video URLs. Instagram, TikTok and Pinterest need one. */
|
|
88
245
|
media: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
246
|
+
/** TikTok's options for the TikTok accounts it goes to. */
|
|
247
|
+
tiktok: z.ZodOptional<z.ZodObject<{
|
|
248
|
+
/** Who can see it: public (default), friends, followers or only_me. */
|
|
249
|
+
privacy: z.ZodOptional<z.ZodEnum<["followers" | "public" | "friends" | "only_me", ...("followers" | "public" | "friends" | "only_me")[]]>>;
|
|
250
|
+
/** Commercial content: none (default), own_brand (promotes your own app or business) or paid_partnership. */
|
|
251
|
+
disclosure: z.ZodOptional<z.ZodEnum<["none" | "own_brand" | "paid_partnership", ...("none" | "own_brand" | "paid_partnership")[]]>>;
|
|
252
|
+
/** Upload to the creator's TikTok inbox instead of posting: they finish and post it in the app. */
|
|
253
|
+
inbox_draft: z.ZodOptional<z.ZodBoolean>;
|
|
254
|
+
/** Photo posts: let TikTok add music. */
|
|
255
|
+
auto_music: z.ZodOptional<z.ZodBoolean>;
|
|
256
|
+
/** Allow comments (default true). */
|
|
257
|
+
comments: z.ZodOptional<z.ZodBoolean>;
|
|
258
|
+
/** Photo posts: the title; the text becomes the description. */
|
|
259
|
+
title: z.ZodOptional<z.ZodString>;
|
|
260
|
+
/** Photo posts: which image is the cover, from 0. */
|
|
261
|
+
cover_index: z.ZodOptional<z.ZodNumber>;
|
|
262
|
+
/** Video posts: the frame used as the cover, in milliseconds. */
|
|
263
|
+
cover_time_ms: z.ZodOptional<z.ZodNumber>;
|
|
264
|
+
/** Video posts: an https image used as the cover. */
|
|
265
|
+
cover_image_url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
266
|
+
}, "strict", z.ZodTypeAny, {
|
|
267
|
+
title?: string | undefined;
|
|
268
|
+
comments?: boolean | undefined;
|
|
269
|
+
privacy?: "followers" | "public" | "friends" | "only_me" | undefined;
|
|
270
|
+
disclosure?: "none" | "own_brand" | "paid_partnership" | undefined;
|
|
271
|
+
inbox_draft?: boolean | undefined;
|
|
272
|
+
auto_music?: boolean | undefined;
|
|
273
|
+
cover_index?: number | undefined;
|
|
274
|
+
cover_time_ms?: number | undefined;
|
|
275
|
+
cover_image_url?: string | undefined;
|
|
276
|
+
}, {
|
|
277
|
+
title?: string | undefined;
|
|
278
|
+
comments?: boolean | undefined;
|
|
279
|
+
privacy?: "followers" | "public" | "friends" | "only_me" | undefined;
|
|
280
|
+
disclosure?: "none" | "own_brand" | "paid_partnership" | undefined;
|
|
281
|
+
inbox_draft?: boolean | undefined;
|
|
282
|
+
auto_music?: boolean | undefined;
|
|
283
|
+
cover_index?: number | undefined;
|
|
284
|
+
cover_time_ms?: number | undefined;
|
|
285
|
+
cover_image_url?: string | undefined;
|
|
286
|
+
}>>;
|
|
89
287
|
/** Why this post, for whoever reviews the pull request. */
|
|
90
288
|
why: z.ZodOptional<z.ZodString>;
|
|
91
289
|
status: z.ZodDefault<z.ZodEnum<["draft", "sent"]>>;
|
|
@@ -95,6 +293,17 @@ export declare const draftSchema: z.ZodObject<{
|
|
|
95
293
|
status: "draft" | "sent";
|
|
96
294
|
accounts: string[];
|
|
97
295
|
text: string;
|
|
296
|
+
tiktok?: {
|
|
297
|
+
title?: string | undefined;
|
|
298
|
+
comments?: boolean | undefined;
|
|
299
|
+
privacy?: "followers" | "public" | "friends" | "only_me" | undefined;
|
|
300
|
+
disclosure?: "none" | "own_brand" | "paid_partnership" | undefined;
|
|
301
|
+
inbox_draft?: boolean | undefined;
|
|
302
|
+
auto_music?: boolean | undefined;
|
|
303
|
+
cover_index?: number | undefined;
|
|
304
|
+
cover_time_ms?: number | undefined;
|
|
305
|
+
cover_image_url?: string | undefined;
|
|
306
|
+
} | undefined;
|
|
98
307
|
when?: string | undefined;
|
|
99
308
|
media?: string[] | undefined;
|
|
100
309
|
why?: string | undefined;
|
|
@@ -104,6 +313,17 @@ export declare const draftSchema: z.ZodObject<{
|
|
|
104
313
|
accounts: string[];
|
|
105
314
|
text: string;
|
|
106
315
|
status?: "draft" | "sent" | undefined;
|
|
316
|
+
tiktok?: {
|
|
317
|
+
title?: string | undefined;
|
|
318
|
+
comments?: boolean | undefined;
|
|
319
|
+
privacy?: "followers" | "public" | "friends" | "only_me" | undefined;
|
|
320
|
+
disclosure?: "none" | "own_brand" | "paid_partnership" | undefined;
|
|
321
|
+
inbox_draft?: boolean | undefined;
|
|
322
|
+
auto_music?: boolean | undefined;
|
|
323
|
+
cover_index?: number | undefined;
|
|
324
|
+
cover_time_ms?: number | undefined;
|
|
325
|
+
cover_image_url?: string | undefined;
|
|
326
|
+
} | undefined;
|
|
107
327
|
when?: string | undefined;
|
|
108
328
|
media?: string[] | undefined;
|
|
109
329
|
why?: string | undefined;
|
|
@@ -116,12 +336,28 @@ export declare const TEXT_LIMIT: Record<string, number>;
|
|
|
116
336
|
export declare function readDrafts(root: string): Promise<Array<Draft & {
|
|
117
337
|
file: string;
|
|
118
338
|
}>>;
|
|
119
|
-
/** The
|
|
120
|
-
export declare function
|
|
339
|
+
/** The handles an account answers to: its name, and any @handle or u/name inside it ("Appeeky (@appeeky)"). */
|
|
340
|
+
export declare function accountHandles(a: SocialAccount): string[];
|
|
341
|
+
/** How an account is named in messages: its @handle or u/name when it has one. */
|
|
342
|
+
export declare const accountLabel: (a: SocialAccount) => string;
|
|
343
|
+
export interface Resolved {
|
|
121
344
|
accounts: SocialAccount[];
|
|
122
345
|
missing: string[];
|
|
123
|
-
|
|
346
|
+
/** Platform names that match more than one connected account, with the handles to pick from. */
|
|
347
|
+
ambiguous: Array<{
|
|
348
|
+
ref: string;
|
|
349
|
+
platform: string;
|
|
350
|
+
choices: string[];
|
|
351
|
+
}>;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* The connected accounts a draft goes to. A platform name is only enough when one account is
|
|
355
|
+
* connected on it; with several, the draft names one by handle or says `<platform>:all`.
|
|
356
|
+
*/
|
|
357
|
+
export declare function resolveAccounts(draft: Pick<Draft, "accounts">, accounts: SocialAccount[]): Resolved;
|
|
124
358
|
export declare function draftIssues(draft: Draft, accounts: SocialAccount[], now?: Date): string[];
|
|
359
|
+
/** A draft's `tiktok:` block as the API's `extra.tiktok`. */
|
|
360
|
+
export declare function tiktokExtra(t: TikTokOptions): Record<string, unknown>;
|
|
125
361
|
/** Create the post in Appeeky (it publishes now, or at `when`) and mark the draft sent. */
|
|
126
362
|
export declare function sendDraft(api: AppeekyApi, draft: Draft & {
|
|
127
363
|
file: string;
|
package/dist/social.js
CHANGED
|
@@ -3,14 +3,18 @@ import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import YAML from "yaml";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
+
import { AppeekyApiError } from "./appeeky-api.js";
|
|
6
7
|
import { SPEC_DIR, SpecError } from "./files.js";
|
|
7
8
|
/**
|
|
8
9
|
* Organic social media in the repo, through the accounts connected in Appeeky (APPEEKY_API_KEY,
|
|
9
10
|
* Startup plan or above):
|
|
10
11
|
*
|
|
11
12
|
* appeeky/social/accounts.yaml the connected accounts (platform, name, id)
|
|
12
|
-
* appeeky/social/posts.jsonl recent posts, one per line, with each platform's result
|
|
13
|
-
* appeeky/social/
|
|
13
|
+
* appeeky/social/posts.jsonl recent posts made through Appeeky, one per line, with each platform's result
|
|
14
|
+
* appeeky/social/native-posts.jsonl posts made in the platform's own app, with their results
|
|
15
|
+
* appeeky/social/comments.jsonl recent comments on the accounts' posts
|
|
16
|
+
* appeeky/social/insights.yaml followers and growth per account
|
|
17
|
+
* appeeky/social/summary.md the last 30 days per account and platform, and the posts that did best
|
|
14
18
|
* appeeky/social/drafts/<name>.yaml a post: drafted, reviewed in a pull request, then sent
|
|
15
19
|
*
|
|
16
20
|
* Sending creates the post in Appeeky, which publishes it right away, or at `when`.
|
|
@@ -38,12 +42,83 @@ export function toPost(r, analytics = []) {
|
|
|
38
42
|
url: p.platform_post_url ?? undefined,
|
|
39
43
|
publishedAt: p.published_at ?? undefined,
|
|
40
44
|
error: p.error_message ?? undefined,
|
|
45
|
+
draft: p.is_draft ? true : undefined,
|
|
41
46
|
metrics: Object.keys(metrics).length ? metrics : undefined,
|
|
42
47
|
});
|
|
43
48
|
}),
|
|
44
49
|
});
|
|
45
50
|
}
|
|
46
|
-
|
|
51
|
+
const numbers = (m, keys) => Object.fromEntries(keys.filter((k) => typeof m?.[k] === "number" && m[k] > 0).map((k) => [k, m[k]]));
|
|
52
|
+
export function toNativePost(r, accounts) {
|
|
53
|
+
const metrics = numbers(r.metrics, [...METRICS, "engagementRate"]);
|
|
54
|
+
return compact({
|
|
55
|
+
id: r.id,
|
|
56
|
+
account: accounts.find((a) => a.id === r.accountId)?.name ?? r.accountId,
|
|
57
|
+
platform: r.platform,
|
|
58
|
+
url: r.platformPostUrl ?? undefined,
|
|
59
|
+
text: r.content ?? "",
|
|
60
|
+
mediaType: r.mediaType ?? undefined,
|
|
61
|
+
publishedAt: r.publishedAt ?? undefined,
|
|
62
|
+
metrics: Object.keys(metrics).length ? metrics : undefined,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export function toComment(r, accounts) {
|
|
66
|
+
return compact({
|
|
67
|
+
id: r.id,
|
|
68
|
+
account: accounts.find((a) => a.id === r.accountId)?.name ?? r.accountId,
|
|
69
|
+
platform: r.platform,
|
|
70
|
+
postUrl: r.postPermalink ?? undefined,
|
|
71
|
+
postId: r.postId ?? undefined,
|
|
72
|
+
platformPostId: r.platformPostId ?? undefined,
|
|
73
|
+
text: r.text ?? "",
|
|
74
|
+
author: r.author?.username ?? r.author?.name ?? undefined,
|
|
75
|
+
own: r.isOwnAccount ? true : undefined,
|
|
76
|
+
reply: r.isReply ? true : undefined,
|
|
77
|
+
at: r.commentedAt ?? undefined,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export function toInsights(r, account) {
|
|
81
|
+
return compact({
|
|
82
|
+
account: account.name,
|
|
83
|
+
platform: r.platform ?? account.platform,
|
|
84
|
+
followers: r.followers ?? undefined,
|
|
85
|
+
growth: r.growth ?? undefined,
|
|
86
|
+
growthPercentage: r.growthPercentage ?? undefined,
|
|
87
|
+
stats: r.stats && Object.keys(r.stats).length ? r.stats : undefined,
|
|
88
|
+
history: r.history?.length ? r.history : undefined,
|
|
89
|
+
updatedAt: r.updatedAt ?? undefined,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* One call per connected account to an endpoint the deployed Appeeky API may not have yet. A 404
|
|
94
|
+
* (or any other failure) becomes a warning and the pull goes on; a 404 on the first account skips
|
|
95
|
+
* the rest, since the endpoint is missing. `skip` lists error codes that only mean "not for this
|
|
96
|
+
* account" (insights on X or LinkedIn).
|
|
97
|
+
*/
|
|
98
|
+
async function perAccount(accounts, what, warnings, fetchOne, map, skip = []) {
|
|
99
|
+
const out = [];
|
|
100
|
+
let ok = false;
|
|
101
|
+
for (const a of accounts) {
|
|
102
|
+
try {
|
|
103
|
+
out.push(...map(await fetchOne(a), a));
|
|
104
|
+
ok = true;
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
if (e instanceof AppeekyApiError && e.code && skip.includes(e.code))
|
|
108
|
+
continue;
|
|
109
|
+
if (e instanceof AppeekyApiError && e.status === 404 && !ok) {
|
|
110
|
+
warnings.push(`${what}: not available on this Appeeky API yet, skipped (the file from the last pull is kept)`);
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
warnings.push(`${what} for ${a.platform} ${a.name}: ${e.message}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return ok || !warnings.some((w) => w.startsWith(`${what} for `)) ? out : undefined;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Connected accounts and the latest posts made through Appeeky, with analytics for the ones that
|
|
120
|
+
* went out; then, per account, the posts made in the platform's app, recent comments and followers.
|
|
121
|
+
*/
|
|
47
122
|
export async function fetchSocial(api, options = {}) {
|
|
48
123
|
const accounts = ((await api.get("/connect/social/accounts")) ?? []).map(toAccount);
|
|
49
124
|
const rows = (await api.get("/social/posts", { limit: String(options.limit ?? 100) })) ?? [];
|
|
@@ -53,21 +128,37 @@ export async function fetchSocial(api, options = {}) {
|
|
|
53
128
|
const analytics = published ? ((await api.get(`/social/posts/${encodeURIComponent(row.id)}/analytics`).catch(() => null))?.analytics ?? []) : [];
|
|
54
129
|
posts.push(toPost(row, analytics));
|
|
55
130
|
}
|
|
56
|
-
|
|
131
|
+
const warnings = [];
|
|
132
|
+
const active = accounts.filter((a) => a.active);
|
|
133
|
+
const nativePosts = await perAccount(active, "Native posts", warnings, (a) => api.get("/social/external-posts", { account_id: a.id, limit: "200" }), (rows) => (rows ?? []).map((r) => toNativePost(r, accounts)));
|
|
134
|
+
const comments = await perAccount(active, "Comments", warnings, (a) => api.get("/social/comments", { account_id: a.id, limit: "100" }), (rows) => (rows ?? []).map((r) => toComment(r, accounts)));
|
|
135
|
+
const insights = await perAccount(active, "Follower insights", warnings, (a) => api.get(`/connect/social/accounts/${encodeURIComponent(a.id)}/insights`), (row, a) => (row ? [toInsights(row, a)] : []), ["INSIGHTS_UNAVAILABLE"]);
|
|
136
|
+
const unique = (rows) => rows?.filter((r, i) => rows.findIndex((x) => x.id === r.id) === i);
|
|
137
|
+
return { accounts, posts, nativePosts: unique(nativePosts), comments: unique(comments), insights, warnings };
|
|
57
138
|
}
|
|
58
139
|
const total = (p, k) => p.metrics?.[k] ?? 0;
|
|
59
140
|
/** The reach of a post on one platform: views when the platform reports them, else impressions or reach. */
|
|
60
141
|
const seen = (p) => total(p, "views") || total(p, "impressions") || total(p, "reach");
|
|
61
|
-
|
|
142
|
+
const score = (p) => seen(p) + total(p, "likes") * 10;
|
|
143
|
+
const oneLine = (text, max) => {
|
|
144
|
+
const t = text.replace(/\s+/g, " ").trim();
|
|
145
|
+
return `${t.slice(0, max)}${t.length > max ? "…" : ""}`;
|
|
146
|
+
};
|
|
147
|
+
const signed = (n) => (n > 0 ? `+${n}` : String(n));
|
|
148
|
+
export function summaryMarkdown(accounts, posts, now = new Date(), more = {}) {
|
|
62
149
|
const since = new Date(now.getTime() - 30 * 86_400_000).toISOString();
|
|
63
150
|
const recent = posts.filter((p) => (p.platforms.find((x) => x.publishedAt)?.publishedAt ?? p.createdAt) >= since);
|
|
151
|
+
const native = (more.nativePosts ?? []).filter((p) => (p.publishedAt ?? "") >= since);
|
|
64
152
|
const lines = [`# Social media`, "", `Updated ${now.toISOString().slice(0, 10)}. The last 30 days, from the accounts connected in Appeeky.`, ""];
|
|
65
153
|
lines.push("## Accounts", "");
|
|
66
154
|
if (!accounts.length)
|
|
67
155
|
lines.push("None connected. Connect them in Appeeky (Social).");
|
|
68
|
-
for (const a of accounts)
|
|
69
|
-
|
|
70
|
-
|
|
156
|
+
for (const a of accounts) {
|
|
157
|
+
const i = more.insights?.find((x) => x.account === a.name && x.platform === a.platform);
|
|
158
|
+
const followers = i?.followers !== undefined ? `, ${i.followers} followers${i.growth !== undefined ? ` (${signed(i.growth)}${i.growthPercentage !== undefined ? `, ${signed(Math.round(i.growthPercentage * 10) / 10)}%` : ""})` : ""}` : "";
|
|
159
|
+
lines.push(`- ${a.platform}: ${a.name}${followers}${a.active ? "" : " (needs reconnecting in Appeeky)"}`);
|
|
160
|
+
}
|
|
161
|
+
lines.push("", "## By platform, posts made through Appeeky", "");
|
|
71
162
|
const platforms = [...new Set(recent.flatMap((p) => p.platforms.map((x) => x.platform)))].sort();
|
|
72
163
|
if (!platforms.length)
|
|
73
164
|
lines.push("No posts in the last 30 days.");
|
|
@@ -79,30 +170,72 @@ export function summaryMarkdown(accounts, posts, now = new Date()) {
|
|
|
79
170
|
lines.push(`| ${platform} | ${results.filter((x) => x.publishedAt).length} | ${sum(seen)} | ${sum((x) => total(x, "likes"))} | ${sum((x) => total(x, "comments"))} | ${sum((x) => total(x, "shares") + total(x, "reposts"))} | ${results.filter((x) => x.error).length} |`);
|
|
80
171
|
}
|
|
81
172
|
}
|
|
82
|
-
|
|
83
|
-
.
|
|
84
|
-
|
|
85
|
-
.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
173
|
+
if (more.nativePosts) {
|
|
174
|
+
lines.push("", "## By account, posts made in the platform's app", "");
|
|
175
|
+
const byAccount = [...new Set(native.map((p) => `${p.platform} ${p.account}`))].sort();
|
|
176
|
+
if (!byAccount.length)
|
|
177
|
+
lines.push("No posts made in the platform apps in the last 30 days.");
|
|
178
|
+
else {
|
|
179
|
+
lines.push("| Account | Posts | Seen | Likes | Comments | Shares | Saves |", "| --- | --- | --- | --- | --- | --- | --- |");
|
|
180
|
+
for (const key of byAccount) {
|
|
181
|
+
const list = native.filter((p) => `${p.platform} ${p.account}` === key);
|
|
182
|
+
const sum = (f) => list.reduce((n, x) => n + f(x), 0);
|
|
183
|
+
lines.push(`| ${key} | ${list.length} | ${sum(seen)} | ${sum((x) => total(x, "likes"))} | ${sum((x) => total(x, "comments"))} | ${sum((x) => total(x, "shares") + total(x, "reposts"))} | ${sum((x) => total(x, "saves"))} |`);
|
|
184
|
+
}
|
|
91
185
|
}
|
|
92
186
|
}
|
|
187
|
+
const best = [
|
|
188
|
+
...recent.flatMap((p) => p.platforms.filter((x) => x.publishedAt).map((x) => ({ where: x.platform, via: "through Appeeky", text: p.text, at: x.publishedAt, url: x.url, metrics: x.metrics }))),
|
|
189
|
+
...native.map((p) => ({ where: `${p.platform} ${p.account}`, via: "in the app", text: p.text, at: p.publishedAt, url: p.url, metrics: p.metrics })),
|
|
190
|
+
]
|
|
191
|
+
.sort((a, b) => score(b) - score(a))
|
|
192
|
+
.slice(0, 8);
|
|
193
|
+
if (best.length) {
|
|
194
|
+
lines.push("", "## Did best, all posts", "");
|
|
195
|
+
for (const b of best)
|
|
196
|
+
lines.push(`- ${b.where}, ${b.at.slice(0, 10)}, ${b.via}: ${seen(b)} seen, ${total(b, "likes")} likes. "${oneLine(b.text, 90)}"${b.url ? ` ${b.url}` : ""}`);
|
|
197
|
+
}
|
|
198
|
+
const inbox = posts.flatMap((p) => p.platforms.filter((x) => x.draft).map((x) => ({ post: p, result: x })));
|
|
199
|
+
if (inbox.length) {
|
|
200
|
+
lines.push("", "## In the TikTok inbox", "", "Uploaded as drafts: the creator finishes and posts them in the TikTok app.", "");
|
|
201
|
+
for (const { post } of inbox)
|
|
202
|
+
lines.push(`- ${post.createdAt.slice(0, 10)}: "${oneLine(post.text, 80)}"`);
|
|
203
|
+
}
|
|
204
|
+
const heard = (more.comments ?? []).filter((x) => !x.own).sort((a, b) => (b.at ?? "").localeCompare(a.at ?? ""));
|
|
205
|
+
if (heard.length) {
|
|
206
|
+
lines.push("", "## Latest comments", "", `${heard.length} in comments.jsonl. The latest:`, "");
|
|
207
|
+
for (const x of heard.slice(0, 5))
|
|
208
|
+
lines.push(`- ${x.platform} ${x.account}${x.at ? `, ${x.at.slice(0, 10)}` : ""}: "${oneLine(x.text, 120)}"`);
|
|
209
|
+
}
|
|
93
210
|
const waiting = posts.filter((p) => p.status === "scheduled" || p.status === "pending");
|
|
94
211
|
if (waiting.length) {
|
|
95
212
|
lines.push("", "## Waiting to go out", "");
|
|
96
213
|
for (const p of waiting)
|
|
97
|
-
lines.push(`- ${p.scheduledFor?.slice(0, 16).replace("T", " ") ?? "now"} on ${p.platforms.map((x) => x.platform).join(", ")}: "${p.text
|
|
214
|
+
lines.push(`- ${p.scheduledFor?.slice(0, 16).replace("T", " ") ?? "now"} on ${p.platforms.map((x) => x.platform).join(", ")}: "${oneLine(p.text, 80)}"`);
|
|
98
215
|
}
|
|
99
216
|
return `${lines.join("\n")}\n`;
|
|
100
217
|
}
|
|
218
|
+
const jsonl = (rows) => rows.map((r) => JSON.stringify(r)).join("\n") + (rows.length ? "\n" : "");
|
|
101
219
|
export async function saveSocial(root, data, now = new Date()) {
|
|
102
|
-
|
|
103
|
-
await
|
|
104
|
-
await writeFile(join(
|
|
105
|
-
await writeFile(join(
|
|
220
|
+
const dir = socialDir(root);
|
|
221
|
+
await mkdir(dir, { recursive: true });
|
|
222
|
+
await writeFile(join(dir, "accounts.yaml"), YAML.stringify({ accounts: data.accounts }, { lineWidth: 0 }));
|
|
223
|
+
await writeFile(join(dir, "posts.jsonl"), jsonl(data.posts));
|
|
224
|
+
if (data.nativePosts)
|
|
225
|
+
await writeFile(join(dir, "native-posts.jsonl"), jsonl(data.nativePosts));
|
|
226
|
+
if (data.comments)
|
|
227
|
+
await writeFile(join(dir, "comments.jsonl"), jsonl(data.comments));
|
|
228
|
+
if (data.insights)
|
|
229
|
+
await writeFile(join(dir, "insights.yaml"), YAML.stringify({ accounts: data.insights }, { lineWidth: 0 }));
|
|
230
|
+
// A file the API could not fill this time is kept, and still counts in the summary.
|
|
231
|
+
const kept = async (file, rows) => {
|
|
232
|
+
if (rows || !existsSync(join(dir, file)))
|
|
233
|
+
return rows;
|
|
234
|
+
return (await readFile(join(dir, file), "utf8")).split("\n").filter(Boolean).map((l) => JSON.parse(l));
|
|
235
|
+
};
|
|
236
|
+
const insights = data.insights ?? (existsSync(join(dir, "insights.yaml")) ? (YAML.parse(await readFile(join(dir, "insights.yaml"), "utf8"))?.accounts ?? undefined) : undefined);
|
|
237
|
+
const more = { nativePosts: await kept("native-posts.jsonl", data.nativePosts), comments: await kept("comments.jsonl", data.comments), insights };
|
|
238
|
+
await writeFile(join(dir, "summary.md"), summaryMarkdown(data.accounts, data.posts, now, more));
|
|
106
239
|
}
|
|
107
240
|
export async function readAccounts(root) {
|
|
108
241
|
const file = join(socialDir(root), "accounts.yaml");
|
|
@@ -111,15 +244,52 @@ export async function readAccounts(root) {
|
|
|
111
244
|
return (YAML.parse(await readFile(file, "utf8"))?.accounts ?? []);
|
|
112
245
|
}
|
|
113
246
|
// ── Drafts ──────────────────────────────────────────────────────────────────
|
|
247
|
+
/** TikTok's posting options, in the words a draft uses; each maps to a key of `extra.tiktok` in the API. */
|
|
248
|
+
export const PRIVACY = { public: "PUBLIC_TO_EVERYONE", friends: "MUTUAL_FOLLOW_FRIENDS", followers: "FOLLOWER_OF_CREATOR", only_me: "SELF_ONLY" };
|
|
249
|
+
export const DISCLOSURE = { none: "none", own_brand: "brand_organic", paid_partnership: "brand_content" };
|
|
250
|
+
export const TIKTOK_MAX_PHOTOS = 35;
|
|
251
|
+
export const TIKTOK_TITLE_LIMIT = 90;
|
|
252
|
+
const tiktokSchema = z
|
|
253
|
+
.object({
|
|
254
|
+
/** Who can see it: public (default), friends, followers or only_me. */
|
|
255
|
+
privacy: z.enum(Object.keys(PRIVACY)).optional(),
|
|
256
|
+
/** Commercial content: none (default), own_brand (promotes your own app or business) or paid_partnership. */
|
|
257
|
+
disclosure: z.enum(Object.keys(DISCLOSURE)).optional(),
|
|
258
|
+
/** Upload to the creator's TikTok inbox instead of posting: they finish and post it in the app. */
|
|
259
|
+
inbox_draft: z.boolean().optional(),
|
|
260
|
+
/** Photo posts: let TikTok add music. */
|
|
261
|
+
auto_music: z.boolean().optional(),
|
|
262
|
+
/** Allow comments (default true). */
|
|
263
|
+
comments: z.boolean().optional(),
|
|
264
|
+
/** Photo posts: the title; the text becomes the description. */
|
|
265
|
+
title: z.string().min(1).optional(),
|
|
266
|
+
/** Photo posts: which image is the cover, from 0. */
|
|
267
|
+
cover_index: z.number().int().min(0).max(TIKTOK_MAX_PHOTOS - 1).optional(),
|
|
268
|
+
/** Video posts: the frame used as the cover, in milliseconds. */
|
|
269
|
+
cover_time_ms: z.number().int().min(0).optional(),
|
|
270
|
+
/** Video posts: an https image used as the cover. */
|
|
271
|
+
cover_image_url: z
|
|
272
|
+
.string()
|
|
273
|
+
.url()
|
|
274
|
+
.refine((u) => u.startsWith("https://"), "must be an https URL")
|
|
275
|
+
.optional(),
|
|
276
|
+
})
|
|
277
|
+
.strict();
|
|
114
278
|
export const draftSchema = z
|
|
115
279
|
.object({
|
|
116
|
-
/**
|
|
280
|
+
/**
|
|
281
|
+
* Who it goes to: a platform with one connected account (`twitter`), every account on a
|
|
282
|
+
* platform (`tiktok:all`), a handle (`@sleepysounds`, `tiktok:@sleepysounds`, `u/name`) or an
|
|
283
|
+
* account id from accounts.yaml.
|
|
284
|
+
*/
|
|
117
285
|
accounts: z.array(z.string().min(1)).min(1),
|
|
118
286
|
text: z.string().min(1),
|
|
119
287
|
/** ISO time to schedule it; without it, the post goes out when it is sent. */
|
|
120
288
|
when: z.string().optional(),
|
|
121
289
|
/** Public image or video URLs. Instagram, TikTok and Pinterest need one. */
|
|
122
290
|
media: z.array(z.string().url()).optional(),
|
|
291
|
+
/** TikTok's options for the TikTok accounts it goes to. */
|
|
292
|
+
tiktok: tiktokSchema.optional(),
|
|
123
293
|
/** Why this post, for whoever reviews the pull request. */
|
|
124
294
|
why: z.string().optional(),
|
|
125
295
|
status: z.enum(["draft", "sent"]).default("draft"),
|
|
@@ -143,44 +313,136 @@ export async function readDrafts(root) {
|
|
|
143
313
|
}
|
|
144
314
|
return out;
|
|
145
315
|
}
|
|
146
|
-
|
|
316
|
+
const platformKey = (p) => (p.toLowerCase() === "x" ? "twitter" : p.toLowerCase());
|
|
317
|
+
/** The handles an account answers to: its name, and any @handle or u/name inside it ("Appeeky (@appeeky)"). */
|
|
318
|
+
export function accountHandles(a) {
|
|
319
|
+
const name = a.name.toLowerCase();
|
|
320
|
+
return [...new Set([name, ...(name.match(/@[\w.]+|u\/[\w-]+/g) ?? [])])];
|
|
321
|
+
}
|
|
322
|
+
/** How an account is named in messages: its @handle or u/name when it has one. */
|
|
323
|
+
export const accountLabel = (a) => accountHandles(a).find((h) => h.startsWith("@") || h.startsWith("u/")) ?? a.name;
|
|
324
|
+
/**
|
|
325
|
+
* The connected accounts a draft goes to. A platform name is only enough when one account is
|
|
326
|
+
* connected on it; with several, the draft names one by handle or says `<platform>:all`.
|
|
327
|
+
*/
|
|
147
328
|
export function resolveAccounts(draft, accounts) {
|
|
148
329
|
const found = [];
|
|
149
330
|
const missing = [];
|
|
331
|
+
const ambiguous = [];
|
|
332
|
+
const active = accounts.filter((a) => a.active);
|
|
150
333
|
for (const ref of draft.accounts) {
|
|
151
|
-
const
|
|
152
|
-
const
|
|
334
|
+
const trimmed = ref.trim();
|
|
335
|
+
const colon = trimmed.indexOf(":");
|
|
336
|
+
const [platform, who] = colon > 0 ? [platformKey(trimmed.slice(0, colon)), trimmed.slice(colon + 1).trim().toLowerCase()] : [undefined, trimmed.toLowerCase()];
|
|
337
|
+
const onPlatform = (a) => !platform || platformKey(a.platform) === platform;
|
|
338
|
+
let match;
|
|
339
|
+
if (platform && who === "all")
|
|
340
|
+
match = active.filter(onPlatform);
|
|
341
|
+
else if (!platform && active.some((a) => a.id === trimmed))
|
|
342
|
+
match = active.filter((a) => a.id === trimmed);
|
|
343
|
+
else if (!platform && !who.startsWith("@") && !who.startsWith("u/") && active.some((a) => platformKey(a.platform) === platformKey(who))) {
|
|
344
|
+
match = active.filter((a) => platformKey(a.platform) === platformKey(who));
|
|
345
|
+
if (match.length > 1) {
|
|
346
|
+
ambiguous.push({ ref, platform: match[0].platform, choices: match.map(accountLabel) });
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
match = active.filter((a) => onPlatform(a) && (a.id === trimmed.slice(colon + 1).trim() || accountHandles(a).includes(who)));
|
|
352
|
+
if (match.length > 1) {
|
|
353
|
+
ambiguous.push({ ref, platform: "", choices: match.map((a) => `${a.platform}:${accountLabel(a)}`) });
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
153
357
|
if (match.length)
|
|
154
358
|
found.push(...match.filter((a) => !found.includes(a)));
|
|
155
359
|
else
|
|
156
360
|
missing.push(ref);
|
|
157
361
|
}
|
|
158
|
-
return { accounts: found, missing };
|
|
362
|
+
return { accounts: found, missing, ambiguous };
|
|
363
|
+
}
|
|
364
|
+
const VIDEO = /\.(mp4|mov|m4v|webm)(\?|#|$)/i;
|
|
365
|
+
const IMAGE = /\.(jpe?g|png|webp|gif|heic)(\?|#|$)/i;
|
|
366
|
+
function tiktokIssues(draft, toTikTok) {
|
|
367
|
+
const t = draft.tiktok;
|
|
368
|
+
const media = draft.media ?? [];
|
|
369
|
+
const videos = media.filter((m) => VIDEO.test(m)).length;
|
|
370
|
+
const images = media.filter((m) => IMAGE.test(m)).length;
|
|
371
|
+
const issues = [];
|
|
372
|
+
if (toTikTok) {
|
|
373
|
+
if (videos && images)
|
|
374
|
+
issues.push("tiktok: a post is either images or one video, not both (media:)");
|
|
375
|
+
if (images > TIKTOK_MAX_PHOTOS)
|
|
376
|
+
issues.push(`tiktok: ${images} images, at most ${TIKTOK_MAX_PHOTOS}`);
|
|
377
|
+
}
|
|
378
|
+
if (!t)
|
|
379
|
+
return issues;
|
|
380
|
+
if (!toTikTok)
|
|
381
|
+
return [...issues, "tiktok: options set, but the draft goes to no TikTok account"];
|
|
382
|
+
const disclosed = t.disclosure && t.disclosure !== "none";
|
|
383
|
+
if (disclosed && t.privacy === "only_me" && !t.inbox_draft)
|
|
384
|
+
issues.push(`tiktok: disclosure ${t.disclosure} can't be privacy only_me; make it public, friends or followers, or set inbox_draft: true`);
|
|
385
|
+
if (t.title && t.title.length > TIKTOK_TITLE_LIMIT)
|
|
386
|
+
issues.push(`tiktok: title ${t.title.length}/${TIKTOK_TITLE_LIMIT} characters`);
|
|
387
|
+
const photo = ["title", "auto_music", "cover_index"].filter((k) => t[k] !== undefined);
|
|
388
|
+
const video = ["cover_time_ms", "cover_image_url"].filter((k) => t[k] !== undefined);
|
|
389
|
+
if (videos && photo.length)
|
|
390
|
+
issues.push(`tiktok: ${photo.join(", ")} only apply to photo posts, and media: is a video`);
|
|
391
|
+
if (images && !videos && video.length)
|
|
392
|
+
issues.push(`tiktok: ${video.join(", ")} only apply to video posts, and media: is images`);
|
|
393
|
+
if (t.cover_index !== undefined && images && t.cover_index >= images)
|
|
394
|
+
issues.push(`tiktok: cover_index ${t.cover_index} is past the last image (there are ${images}, counted from 0)`);
|
|
395
|
+
return issues;
|
|
159
396
|
}
|
|
160
397
|
export function draftIssues(draft, accounts, now = new Date()) {
|
|
161
398
|
const issues = [];
|
|
162
|
-
const { accounts: to, missing } = resolveAccounts(draft, accounts);
|
|
399
|
+
const { accounts: to, missing, ambiguous } = resolveAccounts(draft, accounts);
|
|
163
400
|
if (missing.length)
|
|
164
401
|
issues.push(`no connected account for ${missing.join(", ")}`);
|
|
165
|
-
for (const a of
|
|
166
|
-
|
|
402
|
+
for (const a of ambiguous) {
|
|
403
|
+
issues.push(a.platform
|
|
404
|
+
? `${a.ref} matches ${a.choices.length} ${a.platform} accounts (${a.choices.join(", ")}): name the ones to post on, e.g. ${a.platform}:${a.choices[0]}, or write ${a.platform}:all to post on all ${a.choices.length}`
|
|
405
|
+
: `${a.ref} matches ${a.choices.length} accounts (${a.choices.join(", ")}): add the platform, e.g. ${a.choices[0]}`);
|
|
406
|
+
}
|
|
407
|
+
const platforms = [...new Set(to.map((a) => a.platform.toLowerCase()))];
|
|
408
|
+
for (const p of platforms) {
|
|
409
|
+
const limit = TEXT_LIMIT[p];
|
|
167
410
|
if (limit && draft.text.length > limit)
|
|
168
|
-
issues.push(`${
|
|
169
|
-
if (NEEDS_MEDIA.has(
|
|
170
|
-
issues.push(`${
|
|
411
|
+
issues.push(`${p}: ${draft.text.length}/${limit} characters`);
|
|
412
|
+
if (NEEDS_MEDIA.has(p) && !draft.media?.length)
|
|
413
|
+
issues.push(`${p} needs an image or video (media:)`);
|
|
171
414
|
}
|
|
415
|
+
issues.push(...tiktokIssues(draft, platforms.includes("tiktok")));
|
|
172
416
|
if (draft.when && !(new Date(draft.when) > now))
|
|
173
417
|
issues.push(`when ${draft.when} is not in the future`);
|
|
174
418
|
return issues;
|
|
175
419
|
}
|
|
420
|
+
/** A draft's `tiktok:` block as the API's `extra.tiktok`. */
|
|
421
|
+
export function tiktokExtra(t) {
|
|
422
|
+
return compact({
|
|
423
|
+
privacyLevel: t.privacy ? PRIVACY[t.privacy] : undefined,
|
|
424
|
+
commercialContentType: t.disclosure ? DISCLOSURE[t.disclosure] : undefined,
|
|
425
|
+
draft: t.inbox_draft,
|
|
426
|
+
autoAddMusic: t.auto_music,
|
|
427
|
+
allowComment: t.comments,
|
|
428
|
+
title: t.title,
|
|
429
|
+
photoCoverIndex: t.cover_index,
|
|
430
|
+
videoCoverTimestampMs: t.cover_time_ms,
|
|
431
|
+
videoCoverImageUrl: t.cover_image_url,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
176
434
|
/** Create the post in Appeeky (it publishes now, or at `when`) and mark the draft sent. */
|
|
177
435
|
export async function sendDraft(api, draft, accounts, now = new Date()) {
|
|
178
|
-
const { accounts: to } = resolveAccounts(draft, accounts);
|
|
436
|
+
const { accounts: to, missing, ambiguous } = resolveAccounts(draft, accounts);
|
|
437
|
+
if (missing.length || ambiguous.length || !to.length)
|
|
438
|
+
throw new Error(draftIssues(draft, accounts, now).join("; ") || "no connected account to send to");
|
|
439
|
+
const tiktok = draft.tiktok && to.some((a) => a.platform.toLowerCase() === "tiktok") ? tiktokExtra(draft.tiktok) : {};
|
|
179
440
|
const created = await api.post("/social/posts", {
|
|
180
441
|
content: draft.text,
|
|
181
442
|
account_ids: to.map((a) => a.id),
|
|
182
443
|
...(draft.when ? { scheduled_for: new Date(draft.when).toISOString() } : {}),
|
|
183
444
|
...(draft.media?.length ? { media_urls: draft.media } : {}),
|
|
445
|
+
...(Object.keys(tiktok).length ? { extra: { tiktok } } : {}),
|
|
184
446
|
});
|
|
185
447
|
const { file, ...rest } = draft;
|
|
186
448
|
await writeFile(file, YAML.stringify({ ...rest, status: "sent", postId: created.id, sentAt: now.toISOString() }, { lineWidth: 0 }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appeeky/spec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Your app's store listing as a spec: lint it, check keyword coverage, diff it against the live store and push it to App Store Connect and Google Play.",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -79,8 +79,8 @@ npx @appeeky/spec experiment close <id> --value 3.1 --note "Hook B: 3.1 installs
|
|
|
79
79
|
|
|
80
80
|
With accounts and creator personas set up in Appeeky (`APPEEKY_API_KEY`):
|
|
81
81
|
|
|
82
|
-
- `social pull` writes the connected accounts,
|
|
83
|
-
- To post: write `appeeky/social/drafts/<date>-<slug>.yaml` (`accounts`, `text`, `when`, `media`, `why`) and run `social check`. To make a video: write `appeeky/ugc/briefs/<date>-<slug>.yaml` (`persona`, `script`, `scene`, `caption`, `durationSec`, `aspectRatio`, `why`) and run `ugc generate --dry-run` for its cost.
|
|
82
|
+
- `social pull` writes the connected accounts, the posts made through Appeeky and in each platform's app, how each did, comments and followers to `appeeky/social/` (read `summary.md`). `ugc pull` writes the personas (`ready` when they can make clips) and their clips to `appeeky/ugc/`.
|
|
83
|
+
- To post: write `appeeky/social/drafts/<date>-<slug>.yaml` (`accounts`, `text`, `when`, `media`, `tiktok`, `why`) and run `social check`. Name accounts by handle (`tiktok:@handle`) when a platform has more than one. To make a video: write `appeeky/ugc/briefs/<date>-<slug>.yaml` (`persona`, `script`, `scene`, `caption`, `durationSec`, `aspectRatio`, `why`) and run `ugc generate --dry-run` for its cost.
|
|
84
84
|
- Open a pull request. `social push` and `ugc generate` run after the merge (the push workflow does it). Never run them, or `ugc generate --yes`, unless the user asked: posts are public and clips use media credits.
|
|
85
85
|
- Give each post or video its own smart link (`experiment add --link <channel>`) so `experiment close` can say what it brought.
|
|
86
86
|
|