@appeeky/spec 0.8.0 → 0.10.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/dist/schema.d.ts CHANGED
@@ -9,7 +9,7 @@ export type TransportMode = z.infer<typeof transportMode>;
9
9
  export declare const CHARTS: readonly ["top-free", "top-paid", "top-grossing"];
10
10
  export type Chart = (typeof CHARTS)[number];
11
11
  /** What `alerts` looks for in the files the daily run writes. */
12
- export declare const ALERT_KINDS: readonly ["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check"];
12
+ export declare const ALERT_KINDS: readonly ["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check", "social-account"];
13
13
  export type AlertKind = (typeof ALERT_KINDS)[number];
14
14
  /** `appeeky.spec.yaml`: who the app is, where it ships, and what it should be found for. */
15
15
  export declare const specFileSchema: z.ZodObject<{
@@ -338,6 +338,19 @@ export declare const specFileSchema: z.ZodObject<{
338
338
  keywords?: Record<string, string[]> | undefined;
339
339
  device?: "mobile" | "desktop" | undefined;
340
340
  }>>;
341
+ /**
342
+ * Which of the social accounts connected in Appeeky belong to this app. Appeeky lists every
343
+ * account on the key's account, so with several apps (or a company account next to the app's)
344
+ * name this app's here: an id from accounts.yaml, a handle (`@saiko`, `u/name`) or
345
+ * `platform:@handle`. `social pull` keeps only these, so drafts can only go to them.
346
+ */
347
+ social: z.ZodOptional<z.ZodObject<{
348
+ accounts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
349
+ }, "strict", z.ZodTypeAny, {
350
+ accounts?: string[] | undefined;
351
+ }, {
352
+ accounts?: string[] | undefined;
353
+ }>>;
341
354
  /** Rank in the app's category chart (top 100), recorded daily by `category pull`. */
342
355
  category: z.ZodOptional<z.ZodObject<{
343
356
  /** App Store genre id, e.g. "6013" for Health & Fitness; read from the app when left out. */
@@ -365,7 +378,7 @@ export declare const specFileSchema: z.ZodObject<{
365
378
  */
366
379
  alerts: z.ZodDefault<z.ZodObject<{
367
380
  /** Kinds to leave out, e.g. [competitor-change]. */
368
- off: z.ZodDefault<z.ZodArray<z.ZodEnum<["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check"]>, "many">>;
381
+ off: z.ZodDefault<z.ZodArray<z.ZodEnum<["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check", "social-account"]>, "many">>;
369
382
  /** A target fell this many places between its last two recorded checks (critical: twice that, or a top-10 target out of the top 20). */
370
383
  "rank-drop": z.ZodDefault<z.ZodObject<{
371
384
  places: z.ZodDefault<z.ZodNumber>;
@@ -445,6 +458,14 @@ export declare const specFileSchema: z.ZodObject<{
445
458
  }, {
446
459
  days?: number | undefined;
447
460
  }>>;
461
+ /** A social account under social.accounts stopped working (needs reconnecting, turned off) or is not connected: read from the last social pull, if it is under `days` old. */
462
+ "social-account": z.ZodDefault<z.ZodObject<{
463
+ days: z.ZodDefault<z.ZodNumber>;
464
+ }, "strict", z.ZodTypeAny, {
465
+ days: number;
466
+ }, {
467
+ days?: number | undefined;
468
+ }>>;
448
469
  }, "strict", z.ZodTypeAny, {
449
470
  "rank-drop": {
450
471
  places: number;
@@ -475,7 +496,10 @@ export declare const specFileSchema: z.ZodObject<{
475
496
  "late-check": {
476
497
  days: number;
477
498
  };
478
- off: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check")[];
499
+ "social-account": {
500
+ days: number;
501
+ };
502
+ off: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check" | "social-account")[];
479
503
  }, {
480
504
  "rank-drop"?: {
481
505
  places?: number | undefined;
@@ -506,7 +530,10 @@ export declare const specFileSchema: z.ZodObject<{
506
530
  "late-check"?: {
507
531
  days?: number | undefined;
508
532
  } | undefined;
509
- off?: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check")[] | undefined;
533
+ "social-account"?: {
534
+ days?: number | undefined;
535
+ } | undefined;
536
+ off?: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check" | "social-account")[] | undefined;
510
537
  }>>;
511
538
  /** Who the app is for. Experiments, screenshots and UGC refer to these by id. */
512
539
  personas: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -600,7 +627,10 @@ export declare const specFileSchema: z.ZodObject<{
600
627
  "late-check": {
601
628
  days: number;
602
629
  };
603
- off: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check")[];
630
+ "social-account": {
631
+ days: number;
632
+ };
633
+ off: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check" | "social-account")[];
604
634
  };
605
635
  personas: {
606
636
  name: string;
@@ -634,6 +664,9 @@ export declare const specFileSchema: z.ZodObject<{
634
664
  keywords?: Record<string, string[]> | undefined;
635
665
  device?: "mobile" | "desktop" | undefined;
636
666
  } | undefined;
667
+ social?: {
668
+ accounts?: string[] | undefined;
669
+ } | undefined;
637
670
  category?: {
638
671
  appStore?: string | undefined;
639
672
  googlePlay?: string | undefined;
@@ -710,6 +743,9 @@ export declare const specFileSchema: z.ZodObject<{
710
743
  keywords?: Record<string, string[]> | undefined;
711
744
  device?: "mobile" | "desktop" | undefined;
712
745
  } | undefined;
746
+ social?: {
747
+ accounts?: string[] | undefined;
748
+ } | undefined;
713
749
  category?: {
714
750
  appStore?: string | undefined;
715
751
  googlePlay?: string | undefined;
@@ -746,7 +782,10 @@ export declare const specFileSchema: z.ZodObject<{
746
782
  "late-check"?: {
747
783
  days?: number | undefined;
748
784
  } | undefined;
749
- off?: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check")[] | undefined;
785
+ "social-account"?: {
786
+ days?: number | undefined;
787
+ } | undefined;
788
+ off?: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check" | "social-account")[] | undefined;
750
789
  } | undefined;
751
790
  personas?: {
752
791
  name: string;
package/dist/schema.js CHANGED
@@ -67,7 +67,7 @@ const aiIntent = z
67
67
  /** Store charts a category rank is read from. */
68
68
  export const CHARTS = ["top-free", "top-paid", "top-grossing"];
69
69
  /** What `alerts` looks for in the files the daily run writes. */
70
- export const ALERT_KINDS = ["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check"];
70
+ export const ALERT_KINDS = ["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check", "social-account"];
71
71
  /** `appeeky.spec.yaml`: who the app is, where it ships, and what it should be found for. */
72
72
  export const specFileSchema = z
73
73
  .object({
@@ -180,6 +180,16 @@ export const specFileSchema = z
180
180
  })
181
181
  .strict()
182
182
  .optional(),
183
+ /**
184
+ * Which of the social accounts connected in Appeeky belong to this app. Appeeky lists every
185
+ * account on the key's account, so with several apps (or a company account next to the app's)
186
+ * name this app's here: an id from accounts.yaml, a handle (`@saiko`, `u/name`) or
187
+ * `platform:@handle`. `social pull` keeps only these, so drafts can only go to them.
188
+ */
189
+ social: z
190
+ .object({ accounts: z.array(z.string().min(1)).min(1).optional() })
191
+ .strict()
192
+ .optional(),
183
193
  /** Rank in the app's category chart (top 100), recorded daily by `category pull`. */
184
194
  category: z
185
195
  .object({
@@ -224,6 +234,8 @@ export const specFileSchema = z
224
234
  .default({}),
225
235
  /** A release or experiment check this many days late or more (critical: 7 days). */
226
236
  "late-check": z.object({ days: z.number().int().min(1).default(2) }).strict().default({}),
237
+ /** A social account under social.accounts stopped working (needs reconnecting, turned off) or is not connected: read from the last social pull, if it is under `days` old. */
238
+ "social-account": z.object({ days: z.number().int().min(1).default(7) }).strict().default({}),
227
239
  })
228
240
  .strict()
229
241
  .default({}),
@@ -3,7 +3,7 @@ import { existsSync } from "node:fs";
3
3
  import { mkdir, readFile, writeFile } from "node:fs/promises";
4
4
  import { join } from "node:path";
5
5
  import { SPEC_DIR } from "./files.js";
6
- import { defaultRunner, onPath, STORE_CLIS } from "./transport.js";
6
+ import { defaultRunner, npxPackage, onPath, STORE_CLIS } from "./transport.js";
7
7
  /**
8
8
  * Apple Search Ads on your own API key, no Appeeky account: the app's campaigns, spend and installs
9
9
  * per day, and the keywords and search terms that brought installs, in appeeky/search-ads/.
@@ -113,7 +113,7 @@ export function cliRequest(options = {}) {
113
113
  const run = async (args) => {
114
114
  const argv = ["--json", ...(options.account ? ["--account", options.account] : []), "search-ads", ...args];
115
115
  const useNpx = options.useNpx ?? !onPath(cli.bin);
116
- const [command, full] = useNpx ? ["npx", ["-y", "-p", cli.npmPackage, cli.bin, ...argv]] : [cli.bin, argv];
116
+ const [command, full] = useNpx ? ["npx", ["-y", "-p", npxPackage("app-store"), cli.bin, ...argv]] : [cli.bin, argv];
117
117
  let r;
118
118
  try {
119
119
  r = await (options.runner ?? defaultRunner)(command, full);
package/dist/setup.d.ts CHANGED
@@ -35,11 +35,26 @@ export interface DoctorCheck {
35
35
  detail: string;
36
36
  /** How to fix it, when it is not ok. */
37
37
  fix?: string;
38
+ /** A warning about something that stopped working, not an optional step to set up. */
39
+ attention?: boolean;
38
40
  }
39
41
  /** Where each store CLI keeps its saved accounts (`appstore accounts add`, `gps accounts add`). */
40
42
  export declare function savedAccountsFile(store: StoreId, env?: NodeJS.ProcessEnv): string;
41
43
  /** Names of the accounts saved with the store CLI, if any. */
42
44
  export declare function savedAccounts(store: StoreId, env?: NodeJS.ProcessEnv): string[];
45
+ /**
46
+ * `diagnose` only sees which keys are set. This asks each store reached through the hosted
47
+ * gateway for one read, so a key that is valid but has no store connected (or the wrong
48
+ * account's key) shows up as a failure instead of "Ready". Local CLIs are not called: that
49
+ * can take a minute through npx; `pull` shows their errors.
50
+ */
51
+ export declare function probeConnections(project: Project, checks: DoctorCheck[], env?: NodeJS.ProcessEnv, fetcher?: typeof fetch, timeoutMs?: number): Promise<DoctorCheck[]>;
52
+ /**
53
+ * The social accounts this repo uses (social.accounts, or any when it is not set), asked live:
54
+ * one that needs reconnecting is a warning with the command that fixes it. Only when
55
+ * APPEEKY_API_KEY is set and the repo uses social (social.accounts or a social pull).
56
+ */
57
+ export declare function probeSocial(project: Project, checks: DoctorCheck[], env?: NodeJS.ProcessEnv, fetcher?: typeof fetch, timeoutMs?: number): Promise<DoctorCheck[]>;
43
58
  /** What is set up for this repo, and what is missing. Works without a spec (it says so). */
44
59
  export declare function diagnose(root: string, project: Project | null, env?: NodeJS.ProcessEnv, nodeVersion?: string): DoctorCheck[];
45
60
  export {};
package/dist/setup.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { existsSync, readdirSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { installedTargets } from "./agents.js";
4
+ import { AppeekyApi } from "./appeeky-api.js";
4
5
  import { SPEC_DIR, SPEC_FILE } from "./files.js";
5
- import { normalize, words } from "./text.js";
6
- import { STORE_CLIS, onPath } from "./transport.js";
6
+ import { accountLabel, accountMatches, accountProblems, listAccountRows, reconnectCommand, toAccount } from "./social.js";
7
+ import { words } from "./text.js";
8
+ import { createTransport, hasLocalKeys, npxPackage, onPath, STORE_CLIS } from "./transport.js";
7
9
  /** App Store apps matching a name, from Apple's public search. */
8
10
  export async function findApps(term, country = "us", fetcher = fetch) {
9
11
  const url = `https://itunes.apple.com/search?media=software&entity=software&limit=6&country=${encodeURIComponent(country)}&term=${encodeURIComponent(term)}`;
@@ -45,7 +47,8 @@ export function targetCandidates(project, limit = 14, storeName) {
45
47
  const play = project.listings["google-play"][locale] ?? Object.values(project.listings["google-play"])[0];
46
48
  const name = asc?.name ?? play?.title ?? storeName ?? project.spec.app.name;
47
49
  const subtitle = asc?.subtitle ?? play?.shortDescription ?? "";
48
- const brand = normalize(project.spec.app.name).trim();
50
+ // The brand is the name's first part ("Saiko AI" in "Saiko AI: Dance Video Maker"), not the whole name.
51
+ const brand = words(project.spec.app.name.split(/[:\-–—|]/)[0]).join(" ");
49
52
  const out = [];
50
53
  const add = (phrase) => {
51
54
  const ws = words(phrase);
@@ -206,9 +209,6 @@ jobs:
206
209
  const ok = (area, detail) => ({ area, status: "ok", detail });
207
210
  const warn = (area, detail, fix) => ({ area, status: "warn", detail, fix });
208
211
  const fail = (area, detail, fix) => ({ area, status: "fail", detail, fix });
209
- const hasLocalKeys = (store, env) => store === "app-store"
210
- ? Boolean(env.ASC_KEY_ID && (env.ASC_PRIVATE_KEY || env.ASC_PRIVATE_KEY_PATH))
211
- : Boolean(env.GPS_CREDENTIALS || env.GOOGLE_PLAY_CREDENTIALS || env.GOOGLE_APPLICATION_CREDENTIALS);
212
212
  /** Where each store CLI keeps its saved accounts (`appstore accounts add`, `gps accounts add`). */
213
213
  export function savedAccountsFile(store, env = process.env) {
214
214
  const base = env.XDG_CONFIG_HOME ?? join(env.HOME ?? env.USERPROFILE ?? "", ".config");
@@ -225,6 +225,90 @@ export function savedAccounts(store, env = process.env) {
225
225
  return [];
226
226
  }
227
227
  }
228
+ const HOSTED_DETAIL = "hosted through your Appeeky connection (APPEEKY_API_KEY)";
229
+ /** One read per store, the cheapest the adapters make, to prove the connection works and not only that a key is set. */
230
+ const PROBES = {
231
+ "app-store": (project) => {
232
+ const cfg = project.spec.stores.appStore;
233
+ return cfg ? ["appstore_list_versions", { appId: cfg.appId, platform: cfg.platform ?? "IOS" }] : null;
234
+ },
235
+ "google-play": (project) => {
236
+ const cfg = project.spec.stores.googlePlay;
237
+ return cfg ? ["gps_list_listings", { packageName: cfg.packageName }] : null;
238
+ },
239
+ };
240
+ /**
241
+ * `diagnose` only sees which keys are set. This asks each store reached through the hosted
242
+ * gateway for one read, so a key that is valid but has no store connected (or the wrong
243
+ * account's key) shows up as a failure instead of "Ready". Local CLIs are not called: that
244
+ * can take a minute through npx; `pull` shows their errors.
245
+ */
246
+ export async function probeConnections(project, checks, env = process.env, fetcher, timeoutMs = 15_000) {
247
+ const out = [...checks];
248
+ for (const store of ["app-store", "google-play"]) {
249
+ const label = store === "app-store" ? "App Store" : "Google Play";
250
+ const i = out.findIndex((c) => c.area === label && c.status === "ok" && c.detail === HOSTED_DETAIL);
251
+ const probe = PROBES[store](project);
252
+ if (i < 0 || !probe)
253
+ continue;
254
+ const cfg = store === "app-store" ? project.spec.stores.appStore : project.spec.stores.googlePlay;
255
+ let timer;
256
+ try {
257
+ const transport = createTransport(store, { via: cfg?.via ?? "auto", env, fetcher });
258
+ if (transport.kind !== "hosted")
259
+ continue;
260
+ const timeout = new Promise((_, reject) => {
261
+ timer = setTimeout(() => reject(new Error(`no answer in ${timeoutMs / 1000}s`)), timeoutMs);
262
+ });
263
+ await Promise.race([transport.call(probe[0], probe[1]), timeout]);
264
+ out[i] = ok(label, `${HOSTED_DETAIL}, connected`);
265
+ }
266
+ catch (e) {
267
+ out[i] = fail(label, `APPEEKY_API_KEY is set, but the hosted gateway refused: ${e.message}`, `Connect ${label} in Appeeky for the account this key belongs to (appeeky.com/dashboard), or use your own store key with \`via: local\`.`);
268
+ }
269
+ finally {
270
+ if (timer)
271
+ clearTimeout(timer);
272
+ }
273
+ }
274
+ return out;
275
+ }
276
+ /**
277
+ * The social accounts this repo uses (social.accounts, or any when it is not set), asked live:
278
+ * one that needs reconnecting is a warning with the command that fixes it. Only when
279
+ * APPEEKY_API_KEY is set and the repo uses social (social.accounts or a social pull).
280
+ */
281
+ export async function probeSocial(project, checks, env = process.env, fetcher, timeoutMs = 15_000) {
282
+ const key = env.APPEEKY_API_KEY;
283
+ const only = project.spec.social?.accounts;
284
+ if (!key || !(only?.length || existsSync(join(project.root, SPEC_DIR, "social", "accounts.yaml"))))
285
+ return checks;
286
+ const api = new AppeekyApi(key, { baseUrl: env.APPEEKY_API_URL, fetcher });
287
+ let timer;
288
+ try {
289
+ const timeout = new Promise((_, reject) => {
290
+ timer = setTimeout(() => reject(new Error(`no answer in ${timeoutMs / 1000}s`)), timeoutMs);
291
+ });
292
+ const all = (await Promise.race([listAccountRows(api), timeout])).map(toAccount);
293
+ const accounts = only?.length ? all.filter((a) => accountMatches(a, only)) : all;
294
+ const working = accounts.filter((a) => a.active);
295
+ const out = [];
296
+ if (working.length)
297
+ out.push(ok("social", `connected: ${working.map((a) => `${a.platform} ${accountLabel(a)}`).join(", ")}`));
298
+ for (const p of accountProblems(accounts, only))
299
+ out.push({ ...warn("social", p.message, p.fix), attention: true });
300
+ if (!out.length)
301
+ out.push({ ...warn("social", "No social account connected in Appeeky", `Run \`${reconnectCommand("<platform>")}\` (tiktok, instagram, …) and sign in with the link.`), attention: true });
302
+ return [...checks, ...out];
303
+ }
304
+ catch (e) {
305
+ return [...checks, { ...warn("social", `Could not read the social accounts: ${e.message}`, "Check APPEEKY_API_KEY, or run `appeeky-spec social pull` to see the error."), attention: true }];
306
+ }
307
+ finally {
308
+ if (timer)
309
+ clearTimeout(timer);
310
+ }
311
+ }
228
312
  /** What is set up for this repo, and what is missing. Works without a spec (it says so). */
229
313
  export function diagnose(root, project, env = process.env, nodeVersion = process.versions.node) {
230
314
  const out = [];
@@ -247,13 +331,14 @@ export function diagnose(root, project, env = process.env, nodeVersion = process
247
331
  // The CLI runs from PATH or through npx; either way it reads keys from the environment or its saved accounts.
248
332
  const accounts = savedAccounts(store, env);
249
333
  const keys = hasLocalKeys(store, env) ? "keys in the environment" : accounts.length ? `saved account${accounts.length > 1 ? "s" : ""} ${accounts.join(", ")}` : "";
250
- const runner = local ? `${cli.bin} CLI` : `npx ${cli.npmPackage}`;
334
+ const runner = local ? `${cli.bin} CLI` : `npx ${npxPackage(store)}`;
251
335
  if (via === "hosted")
252
- out.push(key ? ok(label, "hosted through your Appeeky connection (APPEEKY_API_KEY)") : fail(label, "via: hosted, but APPEEKY_API_KEY is not set", "Set APPEEKY_API_KEY (appeeky.com/dashboard/settings)."));
253
- else if (keys && (via === "local" || local || !key))
336
+ out.push(key ? ok(label, HOSTED_DETAIL) : fail(label, "via: hosted, but APPEEKY_API_KEY is not set", "Set APPEEKY_API_KEY (appeeky.com/dashboard/settings)."));
337
+ // Same order as createTransport: an installed CLI or keys in the environment win over the hosted gateway.
338
+ else if (keys && (via === "local" || local || hasLocalKeys(store, env) || !key))
254
339
  out.push(ok(label, `your own key: ${runner}, ${keys}`));
255
340
  else if (via !== "local" && key)
256
- out.push(ok(label, "hosted through your Appeeky connection (APPEEKY_API_KEY)"));
341
+ out.push(ok(label, HOSTED_DETAIL));
257
342
  else if (local)
258
343
  out.push(fail(label, `${cli.bin} CLI is installed but has no saved account and no keys in the environment`, cli.setupHint));
259
344
  else
package/dist/social.d.ts CHANGED
@@ -21,6 +21,10 @@ export interface SocialAccount {
21
21
  platform: string;
22
22
  name: string;
23
23
  active: boolean;
24
+ /** Why it cannot post or be read: "needs reconnecting" or "turned off". Absent when it works. */
25
+ problem?: string;
26
+ /** The last error the platform gave for it, as Appeeky recorded it. */
27
+ lastError?: string;
24
28
  }
25
29
  export interface SocialPlatformResult {
26
30
  platform: string;
@@ -38,7 +42,8 @@ export interface NativePost {
38
42
  account: string;
39
43
  platform: string;
40
44
  url?: string;
41
- text: string;
45
+ /** Missing when the post or comment has no text (emoji-only, an image, no caption): empty strings are not stored. */
46
+ text?: string;
42
47
  mediaType?: string;
43
48
  publishedAt?: string;
44
49
  metrics?: Partial<Record<SocialMetric | "engagementRate", number>>;
@@ -50,7 +55,8 @@ export interface SocialComment {
50
55
  postUrl?: string;
51
56
  postId?: string;
52
57
  platformPostId?: string;
53
- text: string;
58
+ /** Missing when the post or comment has no text (emoji-only, an image, no caption): empty strings are not stored. */
59
+ text?: string;
54
60
  author?: string;
55
61
  own?: boolean;
56
62
  reply?: boolean;
@@ -87,20 +93,23 @@ export interface SocialData {
87
93
  export interface SocialPost {
88
94
  id: string;
89
95
  status: string;
90
- text: string;
96
+ /** Missing when the post or comment has no text (emoji-only, an image, no caption): empty strings are not stored. */
97
+ text?: string;
91
98
  createdAt: string;
92
99
  scheduledFor?: string;
93
100
  platforms: SocialPlatformResult[];
94
101
  }
95
102
  export declare const socialDir: (root: string) => string;
96
103
  export declare const draftsDir: (root: string) => string;
97
- interface AccountRow {
104
+ export interface AccountRow {
98
105
  id: string;
99
106
  platform: string;
100
107
  displayName?: string | null;
101
108
  platformUserId?: string | null;
102
109
  isActive?: boolean | null;
103
110
  needsReconnect?: boolean | null;
111
+ lastError?: string | null;
112
+ updatedAt?: string | null;
104
113
  }
105
114
  interface PostRow {
106
115
  id: string;
@@ -180,12 +189,64 @@ export declare function toInsights(r: InsightsRow, account: SocialAccount): Acco
180
189
  * Connected accounts and the latest posts made through Appeeky, with analytics for the ones that
181
190
  * went out; then, per account, the posts made in the platform's app, recent comments and followers.
182
191
  */
192
+ /** Whether an account is one of `only` (ids, handles, names or platform:handle, as in `social.accounts`). */
193
+ export declare function accountMatches(a: SocialAccount, only: string[]): boolean;
183
194
  export declare function fetchSocial(api: AppeekyApi, options?: {
184
195
  limit?: number;
196
+ only?: string[];
185
197
  }): Promise<SocialData>;
186
198
  export declare function summaryMarkdown(accounts: SocialAccount[], posts: SocialPost[], now?: Date, more?: Pick<SocialData, "nativePosts" | "comments" | "insights">): string;
187
199
  export declare function saveSocial(root: string, data: SocialData, now?: Date): Promise<void>;
200
+ /** accounts.yaml with the time of the social pull that wrote it (absent in files from before 0.10). */
201
+ export declare function readAccountsFile(root: string): Promise<{
202
+ accounts: SocialAccount[];
203
+ checkedAt?: string;
204
+ }>;
188
205
  export declare function readAccounts(root: string): Promise<SocialAccount[]>;
206
+ /**
207
+ * The platforms keep a connection only so long: a revoked permission, a changed password or a
208
+ * token the platform will not refresh, and Appeeky marks the account `needsReconnect`. Nothing
209
+ * posts or reads on it until someone signs in again, so Spec says so wherever it looks (social
210
+ * pull, doctor, the daily alerts) and `social connect` gives the sign-in link, without the dashboard.
211
+ */
212
+ export declare const reconnectCommand: (platform: string) => string;
213
+ export interface AccountProblem {
214
+ platform: string;
215
+ /** The connected account with the problem; absent for a social.accounts entry that matches none. */
216
+ account?: SocialAccount;
217
+ /** The social.accounts entry that matches no connected account. */
218
+ ref?: string;
219
+ message: string;
220
+ fix: string;
221
+ }
222
+ /** Accounts that cannot post or be read, and entries under social.accounts that no connected account matches. */
223
+ export declare function accountProblems(accounts: SocialAccount[], only?: string[]): AccountProblem[];
224
+ export declare const listAccountRows: (api: AppeekyApi) => Promise<AccountRow[]>;
225
+ /** The Appeeky API route that starts a sign-in for a platform: GET, `account_id` to reconnect one account. */
226
+ export declare const connectPath: (platform: string) => string;
227
+ export interface ConnectLink {
228
+ /** Sign in here (in a browser). */
229
+ url: string;
230
+ /** The same sign-in, made to open on a phone (where the TikTok or Instagram app is signed in). */
231
+ phoneUrl?: string;
232
+ expiresAt?: string;
233
+ }
234
+ export declare class ConnectUnavailableError extends Error {
235
+ constructor(platform: string);
236
+ }
237
+ /** A sign-in link for a platform, from the Appeeky API (which keeps the platform tokens and refreshes them). */
238
+ export declare function connectLink(api: AppeekyApi, platform: string, accountId?: string): Promise<ConnectLink>;
239
+ /**
240
+ * Waits until the sign-in lands: an account on the platform that works and is new, was broken
241
+ * before, or changed since (a fresh sign-in on an account that already worked). Null on timeout.
242
+ */
243
+ export declare function waitForConnection(api: AppeekyApi, platform: string, before: AccountRow[], options?: {
244
+ timeoutMs?: number;
245
+ intervalMs?: number;
246
+ accountId?: string;
247
+ sleep?: (ms: number) => Promise<void>;
248
+ now?: () => number;
249
+ }): Promise<SocialAccount | null>;
189
250
  /** TikTok's posting options, in the words a draft uses; each maps to a key of `extra.tiktok` in the API. */
190
251
  export declare const PRIVACY: {
191
252
  readonly public: "PUBLIC_TO_EVERYONE";
@@ -388,8 +449,8 @@ export declare const draftSchema: z.ZodObject<{
388
449
  sentAt: z.ZodOptional<z.ZodString>;
389
450
  }, "strict", z.ZodTypeAny, {
390
451
  status: "draft" | "sent";
391
- text: string;
392
452
  accounts: string[];
453
+ text: string;
393
454
  tiktok?: {
394
455
  title?: string | undefined;
395
456
  comments?: boolean | undefined;
@@ -419,8 +480,8 @@ export declare const draftSchema: z.ZodObject<{
419
480
  why?: string | undefined;
420
481
  postId?: string | undefined;
421
482
  }, {
422
- text: string;
423
483
  accounts: string[];
484
+ text: string;
424
485
  status?: "draft" | "sent" | undefined;
425
486
  tiktok?: {
426
487
  title?: string | undefined;