@postonus/cli 0.1.23 → 0.1.25
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/index.js +549 -398
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -166,6 +166,23 @@ function isCredentialPlatform(platform) {
|
|
|
166
166
|
return CREDENTIAL_PLATFORMS.includes(platform);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
// ../../packages/app-config/src/site.ts
|
|
170
|
+
var SITE = {
|
|
171
|
+
title: "Postonus",
|
|
172
|
+
subtitle: "Effortless Social Media Scheduling",
|
|
173
|
+
url: "https://postonus.com",
|
|
174
|
+
description: "Plan, automate and track your social content across platforms with ease.",
|
|
175
|
+
shortDescription: "Post once and publish everywhere.",
|
|
176
|
+
colorScheme: "light",
|
|
177
|
+
/**
|
|
178
|
+
* GA4 measurement id for the marketing site. Public by design — it ships in
|
|
179
|
+
* the page source of every site that uses gtag — so it is a constant rather
|
|
180
|
+
* than an env var, and there is nothing per-environment to configure. The tag
|
|
181
|
+
* only loads in production, so a dev session cannot pollute the property.
|
|
182
|
+
*/
|
|
183
|
+
gaMeasurementId: "G-896SCPPTRK"
|
|
184
|
+
};
|
|
185
|
+
|
|
169
186
|
// ../../packages/app-config/src/file-scenarios.ts
|
|
170
187
|
var scenarios = {
|
|
171
188
|
post_attachments: {
|
|
@@ -209,91 +226,6 @@ var FILE_TYPE_EXTENSIONS = {
|
|
|
209
226
|
var FILE_SCENARIOS = ["post_attachments", "user_avatar"];
|
|
210
227
|
var MAX_FILE_SIZE_BYTES = Math.max(...Object.values(scenarios).map((s) => s.maxSize));
|
|
211
228
|
|
|
212
|
-
// ../../packages/app-config/src/posting-times.ts
|
|
213
|
-
var RECOMMENDED_POSTING_TIMES = {
|
|
214
|
-
INSTAGRAM: [
|
|
215
|
-
{ dayOfWeek: 1, startTime: "11:00", endTime: "13:00", strength: 5 },
|
|
216
|
-
{ dayOfWeek: 2, startTime: "10:00", endTime: "13:00", strength: 5 },
|
|
217
|
-
{ dayOfWeek: 3, startTime: "11:00", endTime: "13:00", strength: 5 },
|
|
218
|
-
{ dayOfWeek: 4, startTime: "11:00", endTime: "12:00", strength: 4 },
|
|
219
|
-
{ dayOfWeek: 5, startTime: "12:00", endTime: "14:00", strength: 3 },
|
|
220
|
-
{ dayOfWeek: 6, startTime: "10:00", endTime: "11:00", strength: 2 }
|
|
221
|
-
],
|
|
222
|
-
FACEBOOK: [
|
|
223
|
-
{ dayOfWeek: 2, startTime: "09:00", endTime: "13:00", strength: 5 },
|
|
224
|
-
{ dayOfWeek: 3, startTime: "09:00", endTime: "13:00", strength: 5 },
|
|
225
|
-
{ dayOfWeek: 4, startTime: "09:00", endTime: "13:00", strength: 4 },
|
|
226
|
-
{ dayOfWeek: 1, startTime: "10:00", endTime: "12:00", strength: 3 },
|
|
227
|
-
{ dayOfWeek: 5, startTime: "10:00", endTime: "11:00", strength: 3 },
|
|
228
|
-
{ dayOfWeek: 6, startTime: "09:00", endTime: "11:00", strength: 2 }
|
|
229
|
-
],
|
|
230
|
-
LINKEDIN: [
|
|
231
|
-
{ dayOfWeek: 2, startTime: "08:00", endTime: "10:00", strength: 5 },
|
|
232
|
-
{ dayOfWeek: 3, startTime: "08:00", endTime: "10:00", strength: 5 },
|
|
233
|
-
{ dayOfWeek: 4, startTime: "09:00", endTime: "11:00", strength: 4 },
|
|
234
|
-
{ dayOfWeek: 2, startTime: "12:00", endTime: "13:00", strength: 3 },
|
|
235
|
-
{ dayOfWeek: 3, startTime: "12:00", endTime: "13:00", strength: 3 }
|
|
236
|
-
],
|
|
237
|
-
LINKEDIN_PAGE: [
|
|
238
|
-
{ dayOfWeek: 2, startTime: "08:00", endTime: "10:00", strength: 5 },
|
|
239
|
-
{ dayOfWeek: 3, startTime: "08:00", endTime: "10:00", strength: 5 },
|
|
240
|
-
{ dayOfWeek: 4, startTime: "09:00", endTime: "11:00", strength: 4 }
|
|
241
|
-
],
|
|
242
|
-
TWITTER: [
|
|
243
|
-
{ dayOfWeek: 2, startTime: "09:00", endTime: "11:00", strength: 5 },
|
|
244
|
-
{ dayOfWeek: 3, startTime: "09:00", endTime: "11:00", strength: 5 },
|
|
245
|
-
{ dayOfWeek: 4, startTime: "09:00", endTime: "11:00", strength: 4 },
|
|
246
|
-
{ dayOfWeek: 1, startTime: "09:00", endTime: "10:00", strength: 3 },
|
|
247
|
-
{ dayOfWeek: 5, startTime: "09:00", endTime: "10:00", strength: 3 },
|
|
248
|
-
{ dayOfWeek: 3, startTime: "14:00", endTime: "15:00", strength: 2 }
|
|
249
|
-
],
|
|
250
|
-
TIKTOK: [
|
|
251
|
-
{ dayOfWeek: 2, startTime: "06:00", endTime: "10:00", strength: 5 },
|
|
252
|
-
{ dayOfWeek: 4, startTime: "07:00", endTime: "11:00", strength: 5 },
|
|
253
|
-
{ dayOfWeek: 2, startTime: "19:00", endTime: "21:00", strength: 4 },
|
|
254
|
-
{ dayOfWeek: 4, startTime: "19:00", endTime: "21:00", strength: 4 },
|
|
255
|
-
{ dayOfWeek: 5, startTime: "16:00", endTime: "18:00", strength: 3 },
|
|
256
|
-
{ dayOfWeek: 3, startTime: "09:00", endTime: "10:00", strength: 3 }
|
|
257
|
-
],
|
|
258
|
-
PINTEREST: [
|
|
259
|
-
{ dayOfWeek: 5, startTime: "15:00", endTime: "17:00", strength: 4 },
|
|
260
|
-
{ dayOfWeek: 6, startTime: "08:00", endTime: "11:00", strength: 5 },
|
|
261
|
-
{ dayOfWeek: 0, startTime: "20:00", endTime: "22:00", strength: 4 },
|
|
262
|
-
{ dayOfWeek: 2, startTime: "20:00", endTime: "22:00", strength: 3 }
|
|
263
|
-
],
|
|
264
|
-
YOUTUBE: [
|
|
265
|
-
{ dayOfWeek: 4, startTime: "14:00", endTime: "16:00", strength: 4 },
|
|
266
|
-
{ dayOfWeek: 5, startTime: "14:00", endTime: "16:00", strength: 5 },
|
|
267
|
-
{ dayOfWeek: 6, startTime: "09:00", endTime: "11:00", strength: 5 },
|
|
268
|
-
{ dayOfWeek: 0, startTime: "09:00", endTime: "11:00", strength: 4 }
|
|
269
|
-
]
|
|
270
|
-
};
|
|
271
|
-
function getRecommendedWindows(platform) {
|
|
272
|
-
return RECOMMENDED_POSTING_TIMES[platform] ?? [];
|
|
273
|
-
}
|
|
274
|
-
function getConsensusWindows(platforms) {
|
|
275
|
-
const buckets = /* @__PURE__ */ new Map();
|
|
276
|
-
for (const platform of platforms) {
|
|
277
|
-
for (const w of getRecommendedWindows(platform)) {
|
|
278
|
-
const key = `${w.dayOfWeek}|${w.startTime}|${w.endTime}`;
|
|
279
|
-
const existing = buckets.get(key);
|
|
280
|
-
if (existing) {
|
|
281
|
-
existing.strength += w.strength;
|
|
282
|
-
existing.platforms.push(platform);
|
|
283
|
-
} else {
|
|
284
|
-
buckets.set(key, {
|
|
285
|
-
dayOfWeek: w.dayOfWeek,
|
|
286
|
-
startTime: w.startTime,
|
|
287
|
-
endTime: w.endTime,
|
|
288
|
-
strength: w.strength,
|
|
289
|
-
platforms: [platform]
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return [...buckets.values()].filter((b) => b.platforms.length >= 2).toSorted((a, b) => b.strength - a.strength);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
229
|
// src/index.ts
|
|
298
230
|
import { Command, Option } from "commander";
|
|
299
231
|
|
|
@@ -3175,7 +3107,7 @@ function handleIntersectionResults(result, left, right) {
|
|
|
3175
3107
|
const unrecKeys = /* @__PURE__ */ new Map();
|
|
3176
3108
|
let unrecIssue;
|
|
3177
3109
|
const keyIssues = /* @__PURE__ */ new Map();
|
|
3178
|
-
const
|
|
3110
|
+
const collect2 = (iss, side) => {
|
|
3179
3111
|
let keys;
|
|
3180
3112
|
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
3181
3113
|
unrecIssue ?? (unrecIssue = iss);
|
|
@@ -3196,11 +3128,11 @@ function handleIntersectionResults(result, left, right) {
|
|
|
3196
3128
|
return true;
|
|
3197
3129
|
};
|
|
3198
3130
|
for (const iss of left.issues) {
|
|
3199
|
-
if (!
|
|
3131
|
+
if (!collect2(iss, "l"))
|
|
3200
3132
|
result.issues.push(iss);
|
|
3201
3133
|
}
|
|
3202
3134
|
for (const iss of right.issues) {
|
|
3203
|
-
if (!
|
|
3135
|
+
if (!collect2(iss, "r"))
|
|
3204
3136
|
result.issues.push(iss);
|
|
3205
3137
|
}
|
|
3206
3138
|
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
@@ -6910,6 +6842,7 @@ var JsonValueSchema = lazy(
|
|
|
6910
6842
|
])
|
|
6911
6843
|
);
|
|
6912
6844
|
var DateInput = coerce_exports.date();
|
|
6845
|
+
var InstantInput = iso_exports.datetime({ offset: true, error: "Use an RFC 3339 time with an offset, e.g. 2026-08-01T09:30:00Z" }).transform((value2) => new Date(value2));
|
|
6913
6846
|
var Uuid = string2().uuid();
|
|
6914
6847
|
var IdPathParam = object({ id: Uuid });
|
|
6915
6848
|
var DeletedSchema = object({ success: literal(true) });
|
|
@@ -6917,11 +6850,20 @@ var SuccessSchema = object({ success: literal(true) });
|
|
|
6917
6850
|
var AggregateCount = coerce_exports.number().int();
|
|
6918
6851
|
|
|
6919
6852
|
// ../../packages/api-contract/src/errors.ts
|
|
6853
|
+
var ViolationSchema = object({
|
|
6854
|
+
message: string2(),
|
|
6855
|
+
field: string2().optional(),
|
|
6856
|
+
platform: PlatformSchema.optional(),
|
|
6857
|
+
limit: number2().optional(),
|
|
6858
|
+
actual: number2().optional()
|
|
6859
|
+
});
|
|
6860
|
+
var ErrorDataSchema = object({ violations: array(ViolationSchema) });
|
|
6861
|
+
var ApiErrorSchema = object({ code: string2(), message: string2(), data: ErrorDataSchema });
|
|
6920
6862
|
var publicErrors = {
|
|
6921
6863
|
RATE_LIMITED: {
|
|
6922
6864
|
status: 429,
|
|
6923
6865
|
message: "Too many requests.",
|
|
6924
|
-
data:
|
|
6866
|
+
data: ErrorDataSchema.extend({ retryAfter: number2().int().optional() })
|
|
6925
6867
|
}
|
|
6926
6868
|
};
|
|
6927
6869
|
var authedErrors = {
|
|
@@ -7422,6 +7364,45 @@ var commentsContract = {
|
|
|
7422
7364
|
resolve: tagged6.route({ method: "POST", path: "/comments/{id}/resolve", summary: "Resolve or reopen a comment" }).errors(writableErrors).input(object({ id: Uuid, resolved: boolean2() })).output(CommentSchema)
|
|
7423
7365
|
};
|
|
7424
7366
|
|
|
7367
|
+
// ../../packages/api-contract/src/platforms.ts
|
|
7368
|
+
var PlatformLimitsSchema = object({
|
|
7369
|
+
maxChars: number2().int(),
|
|
7370
|
+
maxCharsWithMedia: number2().int().nullable(),
|
|
7371
|
+
/** `grapheme` where the platform counts an emoji as one; otherwise UTF-16 units. */
|
|
7372
|
+
countUnit: _enum(["grapheme", "utf16"]),
|
|
7373
|
+
maxTitleChars: number2().int().nullable(),
|
|
7374
|
+
supportsThreads: boolean2(),
|
|
7375
|
+
supportsFirstComment: boolean2(),
|
|
7376
|
+
maxFirstCommentChars: number2().int().nullable(),
|
|
7377
|
+
maxMediaCount: number2().int(),
|
|
7378
|
+
supportedMediaTypes: array(string2())
|
|
7379
|
+
});
|
|
7380
|
+
var PlatformRulesOutputSchema = object({
|
|
7381
|
+
platforms: array(PlatformLimitsSchema.extend({ platform: PlatformSchema }))
|
|
7382
|
+
});
|
|
7383
|
+
var BestTimeSlotSchema = object({
|
|
7384
|
+
scheduledAt: Timestamp,
|
|
7385
|
+
platforms: array(string2()),
|
|
7386
|
+
strength: number2(),
|
|
7387
|
+
/** Where the slot came from: the user's saved windows, research several platforms share, one platform's research, or a default. */
|
|
7388
|
+
source: _enum(["user", "consensus", "platform", "default"])
|
|
7389
|
+
});
|
|
7390
|
+
var BestTimesSchema = object({
|
|
7391
|
+
timezone: string2(),
|
|
7392
|
+
slots: array(BestTimeSlotSchema),
|
|
7393
|
+
/** Requested platforms with no research data; their slots are a default, not a recommendation. */
|
|
7394
|
+
platformsWithoutData: array(PlatformSchema)
|
|
7395
|
+
});
|
|
7396
|
+
var BestTimesInputSchema = object({
|
|
7397
|
+
platforms: array(PlatformSchema).min(1),
|
|
7398
|
+
count: coerce_exports.number().int().min(1).max(20).default(5)
|
|
7399
|
+
});
|
|
7400
|
+
var tagged7 = base.route({ tags: ["Platforms"] });
|
|
7401
|
+
var platformsContract = {
|
|
7402
|
+
rules: tagged7.route({ method: "GET", path: "/platforms/rules", summary: "Publishing limits for every platform" }).errors(orgErrors).output(PlatformRulesOutputSchema),
|
|
7403
|
+
bestTimes: tagged7.route({ method: "GET", path: "/best-times", summary: "Upcoming recommended send times" }).errors(orgErrors).input(BestTimesInputSchema).output(BestTimesSchema)
|
|
7404
|
+
};
|
|
7405
|
+
|
|
7425
7406
|
// ../../packages/api-contract/src/integrations.ts
|
|
7426
7407
|
var IntegrationConnectStatusSchema = _enum(["PENDING_SELECTION", "ACTIVE", "DISCONNECTED"]);
|
|
7427
7408
|
var IntegrationTokenStatusSchema = _enum(["VALID", "EXPIRED", "UNKNOWN"]);
|
|
@@ -7449,7 +7430,9 @@ var IntegrationSchema = object({
|
|
|
7449
7430
|
lastValidatedAt: Timestamp.nullable(),
|
|
7450
7431
|
expiresAt: Timestamp.nullable(),
|
|
7451
7432
|
autoRefreshUnavailable: boolean2(),
|
|
7452
|
-
hasFailedSchedules: boolean2()
|
|
7433
|
+
hasFailedSchedules: boolean2(),
|
|
7434
|
+
/** The channel's publishing limits, the same values `GET /platforms/rules` reports for its platform. */
|
|
7435
|
+
limits: PlatformLimitsSchema
|
|
7453
7436
|
});
|
|
7454
7437
|
var UnhealthyIntegrationSchema = object({
|
|
7455
7438
|
id: Uuid,
|
|
@@ -7540,10 +7523,10 @@ var DisconnectImpactSchema = object({
|
|
|
7540
7523
|
strandedScheduleCount: number2().int(),
|
|
7541
7524
|
isLastBinding: boolean2()
|
|
7542
7525
|
});
|
|
7543
|
-
var
|
|
7544
|
-
var internal2 =
|
|
7526
|
+
var tagged8 = base.route({ tags: ["Integrations"] });
|
|
7527
|
+
var internal2 = tagged8.meta({ internal: true });
|
|
7545
7528
|
var integrationsContract = {
|
|
7546
|
-
get:
|
|
7529
|
+
get: tagged8.route({ method: "GET", path: "/integrations", summary: "List active integrations with health" }).errors(orgErrors).output(array(IntegrationSchema)),
|
|
7547
7530
|
getCapacity: internal2.route({ method: "GET", path: "/integrations/capacity", summary: "Social-account plan capacity" }).errors(orgErrors).output(IntegrationCapacitySchema),
|
|
7548
7531
|
listUnhealthy: internal2.route({ method: "GET", path: "/integrations/unhealthy", summary: "Integrations needing reconnect" }).errors(orgErrors).output(array(UnhealthyIntegrationSchema)),
|
|
7549
7532
|
listAtRiskSchedules: internal2.route({
|
|
@@ -7552,7 +7535,7 @@ var integrationsContract = {
|
|
|
7552
7535
|
summary: "Scheduled posts whose channel cannot currently publish"
|
|
7553
7536
|
}).errors(orgErrors).output(array(AtRiskScheduleSchema)),
|
|
7554
7537
|
listPendingSelection: internal2.route({ method: "GET", path: "/integrations/pending-selection", summary: "Channels stuck at the account picker" }).errors(orgErrors).output(array(PendingSelectionIntegrationSchema)),
|
|
7555
|
-
connectIntegration:
|
|
7538
|
+
connectIntegration: tagged8.route({ method: "POST", path: "/integrations/connect", summary: "Start an OAuth connect" }).errors(writableErrors).input(ConnectIntegrationInputSchema).output(object({ redirectUrl: string2() })),
|
|
7556
7539
|
connectCredentialIntegration: internal2.route({
|
|
7557
7540
|
method: "POST",
|
|
7558
7541
|
path: "/integrations/connect-with-credentials",
|
|
@@ -7649,17 +7632,17 @@ var FromUrlOutputSchema = object({
|
|
|
7649
7632
|
publicUrl: string2(),
|
|
7650
7633
|
type: MediaTypeSchema
|
|
7651
7634
|
});
|
|
7652
|
-
var
|
|
7635
|
+
var tagged9 = base.route({ tags: ["Uploads"] });
|
|
7653
7636
|
var uploadContract = {
|
|
7654
|
-
initiateUpload:
|
|
7655
|
-
completeUpload:
|
|
7637
|
+
initiateUpload: tagged9.route({ method: "POST", path: "/uploads/initiate", summary: "Get a signed URL to upload a file" }).errors(uploadErrors).input(InitiateUploadInputSchema).output(InitiateUploadOutputSchema),
|
|
7638
|
+
completeUpload: tagged9.route({ method: "POST", path: "/uploads/complete", summary: "Complete an upload once its bytes are in storage" }).errors(uploadErrors).input(CompleteUploadInputSchema).output(CompleteUploadOutputSchema),
|
|
7656
7639
|
/** Org-scoped, not gated on `canWrite` — deleting is always allowed, even read-only. */
|
|
7657
|
-
deleteFile:
|
|
7640
|
+
deleteFile: tagged9.route({ method: "DELETE", path: "/uploads/{uploadId}", summary: "Delete an uploaded file" }).errors(orgErrors).input(DeleteFileInputSchema).output(DeletedSchema),
|
|
7658
7641
|
/**
|
|
7659
7642
|
* Fetches a caller-supplied URL server-side (through `fetchPublicUrl`'s SSRF
|
|
7660
7643
|
* guard) and stores the result as a completed upload.
|
|
7661
7644
|
*/
|
|
7662
|
-
fromUrl:
|
|
7645
|
+
fromUrl: tagged9.route({
|
|
7663
7646
|
method: "POST",
|
|
7664
7647
|
path: "/uploads/from-url",
|
|
7665
7648
|
summary: "Import a file from a public URL",
|
|
@@ -7742,8 +7725,8 @@ var DeleteMediaOutputSchema = object({
|
|
|
7742
7725
|
deletedIds: array(Uuid),
|
|
7743
7726
|
blocked: array(object({ mediaId: Uuid, usedInPostsCount: number2().int() }))
|
|
7744
7727
|
});
|
|
7745
|
-
var
|
|
7746
|
-
var internal3 =
|
|
7728
|
+
var tagged10 = base.route({ tags: ["Media library"] });
|
|
7729
|
+
var internal3 = tagged10.meta({ internal: true });
|
|
7747
7730
|
var folderErrors = {
|
|
7748
7731
|
...writableErrors,
|
|
7749
7732
|
FOLDER_CYCLE: { status: 422, message: "A folder cannot be moved inside itself." }
|
|
@@ -7830,19 +7813,19 @@ var enableSourceErrors = {
|
|
|
7830
7813
|
...writableErrors,
|
|
7831
7814
|
NOT_CONFIGURED: { status: 412, message: "Source is not configured on this deployment." }
|
|
7832
7815
|
};
|
|
7833
|
-
var
|
|
7816
|
+
var tagged11 = base.route({ tags: ["Media sources"] }).meta({ internal: true });
|
|
7834
7817
|
var mediaSourcesContract = {
|
|
7835
|
-
list:
|
|
7836
|
-
enable:
|
|
7837
|
-
disable:
|
|
7818
|
+
list: tagged11.route({ method: "GET", path: "/media-sources", summary: "List media source pickers and their status" }).errors(orgErrors).output(array(MediaSourceSchema)),
|
|
7819
|
+
enable: tagged11.route({ method: "POST", path: "/media-sources/{sourceId}/enable", summary: "Enable a media source for this org" }).errors(enableSourceErrors).input(SourceIdInputSchema).output(DeletedSchema),
|
|
7820
|
+
disable: tagged11.route({
|
|
7838
7821
|
method: "POST",
|
|
7839
7822
|
path: "/media-sources/{sourceId}/disable",
|
|
7840
7823
|
summary: "Disable a media source for this org"
|
|
7841
7824
|
}).errors(writableErrors).input(SourceIdInputSchema).output(DeletedSchema),
|
|
7842
|
-
suggestSource:
|
|
7843
|
-
importAsset:
|
|
7844
|
-
unsplashTrending:
|
|
7845
|
-
unsplashSearch:
|
|
7825
|
+
suggestSource: tagged11.route({ method: "POST", path: "/media-sources/suggestions", summary: "Suggest a media source not yet supported" }).errors(orgErrors).input(SuggestSourceInputSchema).output(DeletedSchema),
|
|
7826
|
+
importAsset: tagged11.route({ method: "POST", path: "/media-sources/import", summary: "Import an asset picked from a media source" }).errors(writableErrors).input(ImportAssetInputSchema).output(ImportAssetOutputSchema),
|
|
7827
|
+
unsplashTrending: tagged11.route({ method: "GET", path: "/media-sources/unsplash/trending", summary: "Unsplash curated/trending photos" }).errors(unsplashErrors).input(UnsplashPageInputSchema).output(UnsplashTrendingOutputSchema),
|
|
7828
|
+
unsplashSearch: tagged11.route({ method: "GET", path: "/media-sources/unsplash/search", summary: "Search Unsplash photos" }).errors(unsplashErrors).input(UnsplashSearchInputSchema).output(UnsplashSearchOutputSchema)
|
|
7846
7829
|
};
|
|
7847
7830
|
|
|
7848
7831
|
// ../../packages/api-contract/src/notifications.ts
|
|
@@ -7859,15 +7842,15 @@ var NotificationSchema = object({
|
|
|
7859
7842
|
updatedAt: Timestamp
|
|
7860
7843
|
});
|
|
7861
7844
|
var WorkspaceUnreadCountSchema = object({ organizationId: string2(), unread: number2().int() });
|
|
7862
|
-
var
|
|
7845
|
+
var tagged12 = base.route({ tags: ["Notifications"] }).meta({ internal: true });
|
|
7863
7846
|
var notificationsContract = {
|
|
7864
7847
|
/** Full history across every workspace — backs the standalone /notifications page. */
|
|
7865
|
-
list:
|
|
7848
|
+
list: tagged12.route({ method: "GET", path: "/notifications", summary: "List notifications across every workspace" }).errors(authedErrors).input(object({ limit: number2().int().positive().max(100).optional() })).output(object({ notifications: array(NotificationSchema) })),
|
|
7866
7849
|
/**
|
|
7867
7850
|
* Bell-dropdown feed: current workspace + user-global rows, plus a compact
|
|
7868
7851
|
* "other workspaces" unread summary.
|
|
7869
7852
|
*/
|
|
7870
|
-
bellFeed:
|
|
7853
|
+
bellFeed: tagged12.route({ method: "GET", path: "/notifications/bell-feed", summary: "Get the bell-dropdown notification feed" }).errors(orgErrors).input(object({ limit: number2().int().positive().max(50).optional() })).output(
|
|
7871
7854
|
object({
|
|
7872
7855
|
notifications: array(NotificationSchema),
|
|
7873
7856
|
unread: object({
|
|
@@ -7877,8 +7860,8 @@ var notificationsContract = {
|
|
|
7877
7860
|
})
|
|
7878
7861
|
})
|
|
7879
7862
|
),
|
|
7880
|
-
markRead:
|
|
7881
|
-
markAllRead:
|
|
7863
|
+
markRead: tagged12.route({ method: "POST", path: "/notifications/{id}/read", summary: "Mark one notification as read" }).errors({ ...authedErrors, NOT_FOUND: { message: "Notification not found." } }).input(object({ id: string2().min(1) })).output(object({ notification: NotificationSchema })),
|
|
7864
|
+
markAllRead: tagged12.route({ method: "POST", path: "/notifications/mark-all-read", summary: "Mark every notification as read" }).errors(orgErrors).output(object({ updated: number2().int() }))
|
|
7882
7865
|
};
|
|
7883
7866
|
|
|
7884
7867
|
// ../../packages/api-contract/src/posts.ts
|
|
@@ -7953,17 +7936,32 @@ var hasContentOrMedia = (data) => Boolean(data.content && data.content.trim().le
|
|
|
7953
7936
|
var CreatePostRowSchema = object({
|
|
7954
7937
|
content: ContentField,
|
|
7955
7938
|
media: array(PostMediaInputSchema).optional(),
|
|
7956
|
-
scheduledAt:
|
|
7939
|
+
scheduledAt: InstantInput.optional()
|
|
7957
7940
|
}).refine(hasContentOrMedia, "Add some content or media to your post");
|
|
7941
|
+
var ThreadSchema = array(string2().trim().min(1).max(DRAFT_MAX_CHARS)).min(2).max(MAX_THREAD_SEGMENTS);
|
|
7942
|
+
var DryRunField = boolean2().optional();
|
|
7943
|
+
var TargetFields = {
|
|
7944
|
+
/**
|
|
7945
|
+
* Every active channel on these platforms. The alternative to
|
|
7946
|
+
* `selectedIntegrations`, which names channels by id and is the only way to pick
|
|
7947
|
+
* between two channels on one platform.
|
|
7948
|
+
*/
|
|
7949
|
+
platforms: array(PlatformSchema).min(1).optional(),
|
|
7950
|
+
thread: ThreadSchema.optional()
|
|
7951
|
+
};
|
|
7958
7952
|
var CreatePostsInputSchema = object({
|
|
7959
7953
|
rows: array(CreatePostRowSchema).min(1).max(50),
|
|
7960
|
-
shared: object(SharedPostFields),
|
|
7954
|
+
shared: object({ ...SharedPostFields, ...TargetFields }),
|
|
7961
7955
|
postAction: PostActionEnum.default("NEXT_WINDOW"),
|
|
7962
|
-
stagger: object({ startAt: DateInput, intervalMinutes: number2().int().positive() }).optional()
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7956
|
+
stagger: object({ startAt: DateInput, intervalMinutes: number2().int().positive() }).optional(),
|
|
7957
|
+
dryRun: DryRunField
|
|
7958
|
+
}).refine(
|
|
7959
|
+
(data) => data.postAction === "DRAFT" || Boolean(data.shared.selectedIntegrations?.length || data.shared.platforms?.length),
|
|
7960
|
+
{ message: "Select at least one channel or platform", path: ["shared", "selectedIntegrations"] }
|
|
7961
|
+
).refine((data) => !(data.shared.selectedIntegrations?.length && data.shared.platforms), {
|
|
7962
|
+
message: "Name channels by `selectedIntegrations` or `platforms`, not both",
|
|
7963
|
+
path: ["shared", "platforms"]
|
|
7964
|
+
}).refine((data) => data.rows.length === 1 || !(data.shared.integrationThreadSegments || data.shared.thread), {
|
|
7967
7965
|
message: "Thread segments apply to a single post. Use autoThreadIntegrationIds to thread a bulk import.",
|
|
7968
7966
|
path: ["shared", "integrationThreadSegments"]
|
|
7969
7967
|
});
|
|
@@ -7971,19 +7969,34 @@ var UpdatePostInputSchema = object({
|
|
|
7971
7969
|
id: Uuid,
|
|
7972
7970
|
content: ContentField,
|
|
7973
7971
|
media: array(PostMediaInputSchema).optional(),
|
|
7974
|
-
scheduledAt:
|
|
7975
|
-
postAction: PostActionEnum.
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7972
|
+
scheduledAt: InstantInput.nullable().optional(),
|
|
7973
|
+
postAction: PostActionEnum.optional(),
|
|
7974
|
+
/** Move named schedules individually. Applied after the rest of the update. */
|
|
7975
|
+
scheduleTimes: array(object({ scheduleId: Uuid, scheduledAt: InstantInput })).min(1).optional(),
|
|
7976
|
+
dryRun: DryRunField,
|
|
7977
|
+
...SharedPostFields,
|
|
7978
|
+
...TargetFields
|
|
7979
|
+
}).refine((data) => !(data.selectedIntegrations && data.platforms), {
|
|
7980
|
+
message: "Name channels by `selectedIntegrations` or `platforms`, not both",
|
|
7981
|
+
path: ["platforms"]
|
|
7982
|
+
}).refine((data) => !(data.content !== void 0 && data.thread), {
|
|
7983
|
+
message: "Send `content` or `thread`, not both: a thread carries its own text",
|
|
7984
|
+
path: ["thread"]
|
|
7985
|
+
}).refine((data) => !(data.scheduledAt && data.scheduleTimes), {
|
|
7986
|
+
message: "Send `scheduledAt` to move the whole post or `scheduleTimes` to move single schedules, not both",
|
|
7987
|
+
path: ["scheduleTimes"]
|
|
7980
7988
|
});
|
|
7981
7989
|
var ScheduleDraftInputSchema = object({
|
|
7982
7990
|
id: Uuid,
|
|
7983
|
-
scheduledAt:
|
|
7991
|
+
scheduledAt: InstantInput.optional(),
|
|
7984
7992
|
useOptimalTime: boolean2().optional(),
|
|
7985
7993
|
// Required when the draft was saved with no channels; replaces them otherwise.
|
|
7986
|
-
selectedIntegrations: array(string2()).min(1).optional()
|
|
7994
|
+
selectedIntegrations: array(string2()).min(1).optional(),
|
|
7995
|
+
platforms: array(PlatformSchema).min(1).optional(),
|
|
7996
|
+
dryRun: DryRunField
|
|
7997
|
+
}).refine((data) => !(data.selectedIntegrations && data.platforms), {
|
|
7998
|
+
message: "Name channels by `selectedIntegrations` or `platforms`, not both",
|
|
7999
|
+
path: ["platforms"]
|
|
7987
8000
|
}).refine((data) => Boolean(data.scheduledAt) !== Boolean(data.useOptimalTime), {
|
|
7988
8001
|
message: "Provide `scheduledAt` or set `useOptimalTime`, not both and not neither",
|
|
7989
8002
|
path: ["scheduledAt"]
|
|
@@ -8023,7 +8036,7 @@ var RetryScheduleInputSchema = object({
|
|
|
8023
8036
|
*/
|
|
8024
8037
|
attachmentMediaUrls: array(string2()).optional()
|
|
8025
8038
|
});
|
|
8026
|
-
var RescheduleInputSchema = object({ scheduleId: Uuid, scheduledAt:
|
|
8039
|
+
var RescheduleInputSchema = object({ scheduleId: Uuid, scheduledAt: InstantInput });
|
|
8027
8040
|
var BulkScheduleInWindowsInputSchema = object({
|
|
8028
8041
|
scheduleIds: array(Uuid),
|
|
8029
8042
|
horizonDays: number2().int().min(1).default(14),
|
|
@@ -8138,13 +8151,29 @@ var MediaMetadataSchema = object({
|
|
|
8138
8151
|
*/
|
|
8139
8152
|
autoCover: object({ id: string2(), url: string2(), timestampMs: number2().int().nullable() }).nullable()
|
|
8140
8153
|
});
|
|
8141
|
-
var
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8154
|
+
var PostScheduleStateSchema = object({
|
|
8155
|
+
scheduleId: string2(),
|
|
8156
|
+
channelId: string2(),
|
|
8157
|
+
platform: PlatformSchema,
|
|
8158
|
+
channelName: string2(),
|
|
8159
|
+
scheduledAt: Timestamp.nullable(),
|
|
8160
|
+
status: _enum(SCHEDULE_STATUS_VALUES)
|
|
8146
8161
|
});
|
|
8147
|
-
var
|
|
8162
|
+
var PostStateSchema = object({
|
|
8163
|
+
postId: string2(),
|
|
8164
|
+
content: string2(),
|
|
8165
|
+
thread: array(string2()).nullable(),
|
|
8166
|
+
media: array(object({ url: string2(), type: MediaTypeSchema, altText: string2().nullable() })),
|
|
8167
|
+
schedules: array(PostScheduleStateSchema),
|
|
8168
|
+
/** The post in the dashboard, for a human to take over. */
|
|
8169
|
+
url: string2(),
|
|
8170
|
+
/** `pending` while the workspace's review gate holds the post. */
|
|
8171
|
+
review: _enum(["pending"]).nullable(),
|
|
8172
|
+
/** True when the write was rehearsed with `dryRun` and nothing was stored. */
|
|
8173
|
+
dryRun: boolean2()
|
|
8174
|
+
});
|
|
8175
|
+
var CreatePostsOutputSchema = object({ posts: array(PostStateSchema) });
|
|
8176
|
+
var DeletePostOutputSchema = PostStateSchema.extend({ deletedFromPlatforms: boolean2() });
|
|
8148
8177
|
var AddChannelsOutputSchema = object({ postId: string2(), scheduleCount: number2() });
|
|
8149
8178
|
var BulkScheduleInWindowsOutputSchema = object({
|
|
8150
8179
|
placed: array(object({ scheduleId: string2(), scheduledAt: Timestamp })),
|
|
@@ -8152,34 +8181,14 @@ var BulkScheduleInWindowsOutputSchema = object({
|
|
|
8152
8181
|
});
|
|
8153
8182
|
var DeletePostInputSchema = object({ id: Uuid, deleteRemote: boolean2().default(false) });
|
|
8154
8183
|
var postDomainErrors = {
|
|
8155
|
-
POST_QUOTA_EXCEEDED: {
|
|
8156
|
-
status: 403,
|
|
8157
|
-
message: "Post limit reached.",
|
|
8158
|
-
data: object({
|
|
8159
|
-
platform: PlatformSchema.optional(),
|
|
8160
|
-
limit: number2().int().optional(),
|
|
8161
|
-
used: number2().int().optional()
|
|
8162
|
-
})
|
|
8163
|
-
},
|
|
8184
|
+
POST_QUOTA_EXCEEDED: { status: 403, message: "Post limit reached.", data: ErrorDataSchema },
|
|
8164
8185
|
PAYMENT_REQUIRED: {
|
|
8165
8186
|
status: 402,
|
|
8166
8187
|
message: "Choose a plan to schedule and publish."
|
|
8167
8188
|
},
|
|
8168
|
-
CONTENT_TOO_LONG: {
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
data: object({ platform: PlatformSchema, limit: number2().int(), actual: number2().int() }).optional()
|
|
8172
|
-
},
|
|
8173
|
-
MEDIA_RULE_VIOLATED: {
|
|
8174
|
-
status: 400,
|
|
8175
|
-
message: "Media does not satisfy the platform rules.",
|
|
8176
|
-
data: object({ platform: PlatformSchema, detail: string2() }).optional()
|
|
8177
|
-
},
|
|
8178
|
-
VIDEO_TOO_LONG: {
|
|
8179
|
-
status: 400,
|
|
8180
|
-
message: "Video exceeds the platform duration limit.",
|
|
8181
|
-
data: object({ platform: PlatformSchema, detail: string2() }).optional()
|
|
8182
|
-
},
|
|
8189
|
+
CONTENT_TOO_LONG: { status: 400, message: "Content exceeds the platform limit.", data: ErrorDataSchema },
|
|
8190
|
+
MEDIA_RULE_VIOLATED: { status: 400, message: "Media does not satisfy the platform rules.", data: ErrorDataSchema },
|
|
8191
|
+
VIDEO_TOO_LONG: { status: 400, message: "Video exceeds the platform duration limit.", data: ErrorDataSchema },
|
|
8183
8192
|
SCHEDULE_IN_PAST: { status: 400, message: "Scheduled time must be in the future." },
|
|
8184
8193
|
THREAD_NOT_ALLOWED: { status: 400, message: "Thread segments require explicit opt-in." },
|
|
8185
8194
|
INVALID_INTEGRATIONS: { status: 400, message: "Some integrations are invalid or do not belong to you." },
|
|
@@ -8191,41 +8200,49 @@ var postDomainErrors = {
|
|
|
8191
8200
|
message: "This channel cannot be changed from a retry. Edit it in the composer."
|
|
8192
8201
|
},
|
|
8193
8202
|
CHANNEL_ALREADY_SCHEDULED: { status: 409, message: "That channel already has a schedule on this post." },
|
|
8194
|
-
REMOTE_DELETE_FAILED: {
|
|
8195
|
-
status: 400,
|
|
8196
|
-
message: "The platform refused to delete the post.",
|
|
8197
|
-
data: object({ platform: PlatformSchema }).optional()
|
|
8198
|
-
},
|
|
8203
|
+
REMOTE_DELETE_FAILED: { status: 400, message: "The platform refused to delete the post.", data: ErrorDataSchema },
|
|
8199
8204
|
REMOTE_DELETE_NOT_SUPPORTED: {
|
|
8200
8205
|
status: 400,
|
|
8201
8206
|
message: "This platform cannot delete a published post through its API.",
|
|
8202
|
-
data:
|
|
8203
|
-
}
|
|
8204
|
-
}
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
+
data: ErrorDataSchema
|
|
8208
|
+
},
|
|
8209
|
+
NOT_A_DRAFT: { status: 409, message: "That post is not a draft." },
|
|
8210
|
+
DRAFT_HAS_NO_CHANNELS: { status: 400, message: "Choose the channels to schedule this draft on." }
|
|
8211
|
+
};
|
|
8212
|
+
var tagged13 = base.route({ tags: ["Posts"] });
|
|
8213
|
+
var idempotent = tagged13.route({
|
|
8214
|
+
spec: (operation) => ({
|
|
8215
|
+
...operation,
|
|
8216
|
+
parameters: [
|
|
8217
|
+
...operation.parameters ?? [],
|
|
8218
|
+
{
|
|
8219
|
+
name: "Idempotency-Key",
|
|
8220
|
+
in: "header",
|
|
8221
|
+
required: false,
|
|
8222
|
+
schema: { type: "string", maxLength: 255 },
|
|
8223
|
+
description: "Repeating a key within 24 hours returns the first response and writes nothing again."
|
|
8224
|
+
}
|
|
8225
|
+
]
|
|
8226
|
+
})
|
|
8227
|
+
});
|
|
8228
|
+
var internal4 = tagged13.meta({ internal: true });
|
|
8207
8229
|
var postsContract = {
|
|
8208
|
-
list:
|
|
8230
|
+
list: tagged13.route({ method: "GET", path: "/posts", summary: "List posts" }).errors(orgErrors).input(ListPostsInputSchema).output(PostsListOutputSchema),
|
|
8209
8231
|
// Declared before `getById` so `/posts/counts` is not read as `/posts/{id}`.
|
|
8210
8232
|
// Dashboard plumbing: the status segment row on `/posts`.
|
|
8211
8233
|
counts: internal4.route({ method: "GET", path: "/posts/counts", summary: "Count posts per status" }).errors(orgErrors).input(CountPostsInputSchema).output(CountPostsOutputSchema),
|
|
8212
|
-
getById:
|
|
8234
|
+
getById: tagged13.route({ method: "GET", path: "/posts/{id}", summary: "Get a post" }).errors(orgErrors).input(IdPathParam).output(PostWithRelationsSchema),
|
|
8213
8235
|
mediaById: internal4.route({ method: "GET", path: "/posts/media/{id}", summary: "Get post media metadata" }).errors(orgErrors).input(IdPathParam).output(MediaMetadataSchema),
|
|
8214
|
-
create:
|
|
8215
|
-
update:
|
|
8216
|
-
scheduleDraft:
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
DRAFT_HAS_NO_CHANNELS: { status: 400, message: "Choose the channels to schedule this draft on." }
|
|
8221
|
-
}).input(ScheduleDraftInputSchema).output(PostWithRelationsSchema),
|
|
8222
|
-
delete: tagged12.route({ method: "DELETE", path: "/posts/{id}", summary: "Delete a post" }).errors({ ...writableErrors, ...postDomainErrors }).input(DeletePostInputSchema).output(DeletedSchema),
|
|
8223
|
-
retrySchedule: tagged12.route({ method: "POST", path: "/posts/schedules/{scheduleId}/retry", summary: "Retry a failed schedule" }).errors({ ...publishErrors, ...postDomainErrors }).input(RetryScheduleInputSchema).output(DeletedSchema),
|
|
8224
|
-
rescheduleSchedule: tagged12.route({
|
|
8236
|
+
create: idempotent.route({ method: "POST", path: "/posts", summary: "Create posts in bulk", successStatus: 201 }).errors({ ...writableErrors, ...postDomainErrors }).input(CreatePostsInputSchema).output(CreatePostsOutputSchema),
|
|
8237
|
+
update: idempotent.route({ method: "PATCH", path: "/posts/{id}", summary: "Update a post" }).errors({ ...writableErrors, ...postDomainErrors }).input(UpdatePostInputSchema).output(PostStateSchema),
|
|
8238
|
+
scheduleDraft: idempotent.route({ method: "POST", path: "/posts/{id}/schedule", summary: "Schedule a draft" }).errors({ ...writableErrors, ...postDomainErrors }).input(ScheduleDraftInputSchema).output(PostStateSchema),
|
|
8239
|
+
delete: idempotent.route({ method: "DELETE", path: "/posts/{id}", summary: "Delete a post" }).errors({ ...writableErrors, ...postDomainErrors }).input(DeletePostInputSchema).output(DeletePostOutputSchema),
|
|
8240
|
+
retrySchedule: idempotent.route({ method: "POST", path: "/posts/schedules/{scheduleId}/retry", summary: "Retry a failed schedule" }).errors({ ...publishErrors, ...postDomainErrors }).input(RetryScheduleInputSchema).output(PostStateSchema),
|
|
8241
|
+
rescheduleSchedule: idempotent.route({
|
|
8225
8242
|
method: "POST",
|
|
8226
8243
|
path: "/posts/schedules/{scheduleId}/reschedule",
|
|
8227
8244
|
summary: "Move a schedule to a new time"
|
|
8228
|
-
}).errors({ ...writableErrors, ...postDomainErrors }).input(RescheduleInputSchema).output(
|
|
8245
|
+
}).errors({ ...writableErrors, ...postDomainErrors }).input(RescheduleInputSchema).output(PostStateSchema),
|
|
8229
8246
|
bulkScheduleInWindows: internal4.route({
|
|
8230
8247
|
method: "POST",
|
|
8231
8248
|
path: "/posts/schedules/bulk-schedule-windows",
|
|
@@ -8496,12 +8513,12 @@ var quotaErrors = {
|
|
|
8496
8513
|
REPURPOSE_QUOTA_EXCEEDED: {
|
|
8497
8514
|
status: 403,
|
|
8498
8515
|
message: "Daily import limit reached.",
|
|
8499
|
-
data:
|
|
8516
|
+
data: ErrorDataSchema.extend({ limit: number2().int().nullable() })
|
|
8500
8517
|
},
|
|
8501
8518
|
WORKFLOW_CONCURRENCY_EXCEEDED: {
|
|
8502
8519
|
status: 403,
|
|
8503
8520
|
message: "Maximum number of running workflows reached.",
|
|
8504
|
-
data:
|
|
8521
|
+
data: ErrorDataSchema.extend({ limit: number2().int().nullable() })
|
|
8505
8522
|
}
|
|
8506
8523
|
};
|
|
8507
8524
|
var badRequest = { BAD_REQUEST: { message: "Bad request." } };
|
|
@@ -8660,9 +8677,9 @@ var ArchiveImportInputSchema = discriminatedUnion("source", [
|
|
|
8660
8677
|
posts: array(CapturedPostSchema).min(1).max(CAPTURE_BATCH_LIMIT)
|
|
8661
8678
|
})
|
|
8662
8679
|
]);
|
|
8663
|
-
var
|
|
8680
|
+
var tagged14 = base.route({ tags: ["Repurpose"] }).meta({ internal: true });
|
|
8664
8681
|
var sourcesContract = {
|
|
8665
|
-
list:
|
|
8682
|
+
list: tagged14.route({ method: "GET", path: "/repurpose/sources", summary: "List imported source posts" }).errors(orgErrors).input(
|
|
8666
8683
|
object({
|
|
8667
8684
|
platform: PlatformSchema.optional(),
|
|
8668
8685
|
hasMedia: boolean2().optional(),
|
|
@@ -8672,13 +8689,13 @@ var sourcesContract = {
|
|
|
8672
8689
|
page: number2().int().min(1).optional()
|
|
8673
8690
|
})
|
|
8674
8691
|
).output(object({ items: array(SourcePostSchema), pageInfo: SourcePageInfoSchema })),
|
|
8675
|
-
import:
|
|
8692
|
+
import: tagged14.route({
|
|
8676
8693
|
method: "POST",
|
|
8677
8694
|
path: "/repurpose/sources/import",
|
|
8678
8695
|
summary: "Import a batch of source posts from a connected integration"
|
|
8679
8696
|
}).errors({ ...publishErrors, ...badRequest, ...quotaErrors }).input(object({ integrationId: Uuid })).output(object({ success: literal(true), message: string2() })),
|
|
8680
|
-
importByUrl:
|
|
8681
|
-
importArchive:
|
|
8697
|
+
importByUrl: tagged14.route({ method: "POST", path: "/repurpose/sources/import/url", summary: "Import a single source post by URL" }).errors({ ...publishErrors, ...badRequest, ...quotaErrors }).input(object({ url: string2().url() })).output(object({ success: literal(true), sourcePostId: Uuid })),
|
|
8698
|
+
importArchive: tagged14.route({
|
|
8682
8699
|
method: "POST",
|
|
8683
8700
|
path: "/repurpose/sources/import/archive",
|
|
8684
8701
|
summary: "Bulk-import a creator's own back catalogue from an export file or a client capture"
|
|
@@ -8697,9 +8714,9 @@ var sourcesContract = {
|
|
|
8697
8714
|
})
|
|
8698
8715
|
})
|
|
8699
8716
|
),
|
|
8700
|
-
delete:
|
|
8701
|
-
update:
|
|
8702
|
-
createDraft:
|
|
8717
|
+
delete: tagged14.route({ method: "DELETE", path: "/repurpose/sources/{id}", summary: "Delete a source post" }).errors(orgErrors).input(IdPathParam).output(DeletedSchema),
|
|
8718
|
+
update: tagged14.route({ method: "PATCH", path: "/repurpose/sources/{id}", summary: "Edit a source post's raw content" }).errors(writableErrors).input(object({ id: Uuid, rawContent: string2().min(1) })).output(object({ success: literal(true), id: Uuid })),
|
|
8719
|
+
createDraft: tagged14.route({
|
|
8703
8720
|
method: "POST",
|
|
8704
8721
|
path: "/repurpose/sources/{id}/draft",
|
|
8705
8722
|
summary: "Create a draft post from a source post, unadapted",
|
|
@@ -8707,7 +8724,7 @@ var sourcesContract = {
|
|
|
8707
8724
|
}).errors(writableErrors).input(IdPathParam).output(object({ success: literal(true), postId: Uuid }))
|
|
8708
8725
|
};
|
|
8709
8726
|
var adaptContract = {
|
|
8710
|
-
preview:
|
|
8727
|
+
preview: tagged14.route({
|
|
8711
8728
|
method: "POST",
|
|
8712
8729
|
path: "/repurpose/adapt/preview",
|
|
8713
8730
|
summary: "Adapt a source post for a target platform synchronously and create a draft"
|
|
@@ -8719,7 +8736,7 @@ var adaptContract = {
|
|
|
8719
8736
|
media: array(MediaAttachmentSchema)
|
|
8720
8737
|
})
|
|
8721
8738
|
),
|
|
8722
|
-
batch:
|
|
8739
|
+
batch: tagged14.route({
|
|
8723
8740
|
method: "POST",
|
|
8724
8741
|
path: "/repurpose/adapt/batch",
|
|
8725
8742
|
summary: "Queue asynchronous adaptation for many source posts across many target platforms"
|
|
@@ -8731,14 +8748,14 @@ var adaptContract = {
|
|
|
8731
8748
|
).output(object({ success: literal(true), queued: number2().int() }))
|
|
8732
8749
|
};
|
|
8733
8750
|
var draftsContract = {
|
|
8734
|
-
list:
|
|
8751
|
+
list: tagged14.route({ method: "GET", path: "/repurpose/drafts", summary: "List drafts created from source posts" }).errors(orgErrors).input(
|
|
8735
8752
|
object({
|
|
8736
8753
|
sourcePostId: Uuid.optional(),
|
|
8737
8754
|
targetPlatform: PlatformSchema.optional(),
|
|
8738
8755
|
limit: number2().int().min(1).max(100).optional()
|
|
8739
8756
|
})
|
|
8740
8757
|
).output(array(DraftListItemSchema)),
|
|
8741
|
-
listForWorkflow:
|
|
8758
|
+
listForWorkflow: tagged14.route({
|
|
8742
8759
|
method: "GET",
|
|
8743
8760
|
path: "/repurpose/workflows/{workflowId}/drafts",
|
|
8744
8761
|
summary: "List drafts created by one growth workflow"
|
|
@@ -8750,7 +8767,7 @@ var runsContract = {
|
|
|
8750
8767
|
* oRPC matches the literal `recent-statuses` segment ahead of `{runId}`
|
|
8751
8768
|
* regardless of declaration order.
|
|
8752
8769
|
*/
|
|
8753
|
-
recentStatuses:
|
|
8770
|
+
recentStatuses: tagged14.route({
|
|
8754
8771
|
method: "GET",
|
|
8755
8772
|
path: "/repurpose/workflows/{workflowId}/runs/recent-statuses",
|
|
8756
8773
|
summary: "Sparkline of recent tick outcomes for a workflow"
|
|
@@ -8764,7 +8781,7 @@ var runsContract = {
|
|
|
8764
8781
|
})
|
|
8765
8782
|
)
|
|
8766
8783
|
),
|
|
8767
|
-
list:
|
|
8784
|
+
list: tagged14.route({ method: "GET", path: "/repurpose/workflows/{workflowId}/runs", summary: "List a workflow\u2019s ticks" }).errors(orgErrors).input(
|
|
8768
8785
|
object({
|
|
8769
8786
|
workflowId: Uuid,
|
|
8770
8787
|
statuses: array(WorkflowRunStatusSchema).optional(),
|
|
@@ -8782,7 +8799,7 @@ var runsContract = {
|
|
|
8782
8799
|
})
|
|
8783
8800
|
})
|
|
8784
8801
|
),
|
|
8785
|
-
get:
|
|
8802
|
+
get: tagged14.route({
|
|
8786
8803
|
method: "GET",
|
|
8787
8804
|
path: "/repurpose/workflows/{workflowId}/runs/{runId}",
|
|
8788
8805
|
summary: "Get one tick, with the source posts fetched and drafts created in it"
|
|
@@ -8814,19 +8831,19 @@ var runsContract = {
|
|
|
8814
8831
|
)
|
|
8815
8832
|
};
|
|
8816
8833
|
var workflowsContract = {
|
|
8817
|
-
create:
|
|
8818
|
-
list:
|
|
8819
|
-
get:
|
|
8820
|
-
update:
|
|
8821
|
-
pause:
|
|
8822
|
-
resume:
|
|
8823
|
-
delete:
|
|
8824
|
-
runNow:
|
|
8834
|
+
create: tagged14.route({ method: "POST", path: "/repurpose/workflows", summary: "Create a growth workflow", successStatus: 201 }).errors({ ...publishErrors, ...quotaErrors }).input(WorkflowSettingsSchema).output(GrowthWorkflowSchema),
|
|
8835
|
+
list: tagged14.route({ method: "GET", path: "/repurpose/workflows", summary: "List growth workflows" }).errors(orgErrors).output(array(GrowthWorkflowSchema)),
|
|
8836
|
+
get: tagged14.route({ method: "GET", path: "/repurpose/workflows/{id}", summary: "Get a growth workflow" }).errors(orgErrors).input(IdPathParam).output(GrowthWorkflowSchema),
|
|
8837
|
+
update: tagged14.route({ method: "PATCH", path: "/repurpose/workflows/{id}", summary: "Update a growth workflow" }).errors({ ...publishErrors, ...quotaErrors }).input(UpdateWorkflowInputSchema).output(GrowthWorkflowSchema),
|
|
8838
|
+
pause: tagged14.route({ method: "POST", path: "/repurpose/workflows/{id}/pause", summary: "Pause a growth workflow" }).errors({ ...writableErrors, ...stateConflict }).input(object({ id: Uuid, reason: string2().optional() })).output(GrowthWorkflowSchema),
|
|
8839
|
+
resume: tagged14.route({ method: "POST", path: "/repurpose/workflows/{id}/resume", summary: "Resume a paused growth workflow" }).errors({ ...publishErrors, ...quotaErrors, ...stateConflict }).input(object({ id: Uuid, resumeFromCursor: _enum(["old", "now"]) })).output(GrowthWorkflowSchema),
|
|
8840
|
+
delete: tagged14.route({ method: "DELETE", path: "/repurpose/workflows/{id}", summary: "Delete a growth workflow" }).errors(orgErrors).input(IdPathParam).output(DeletedSchema),
|
|
8841
|
+
runNow: tagged14.route({
|
|
8825
8842
|
method: "POST",
|
|
8826
8843
|
path: "/repurpose/workflows/{id}/run-now",
|
|
8827
8844
|
summary: "Trigger an immediate one-off tick for a running workflow"
|
|
8828
8845
|
}).errors({ ...publishErrors, ...badRequest }).input(IdPathParam).output(object({ enqueued: boolean2() })),
|
|
8829
|
-
upcomingTimeline:
|
|
8846
|
+
upcomingTimeline: tagged14.route({
|
|
8830
8847
|
method: "GET",
|
|
8831
8848
|
path: "/repurpose/workflows/{id}/timeline",
|
|
8832
8849
|
summary: "Project upcoming ticks and list already-scheduled drafts for a workflow"
|
|
@@ -8899,9 +8916,9 @@ var ReviewStatusSchema = object({
|
|
|
8899
8916
|
canCurrentUserApprove: boolean2(),
|
|
8900
8917
|
approvalSettings: ApprovalSettingsSchema
|
|
8901
8918
|
});
|
|
8902
|
-
var
|
|
8919
|
+
var tagged15 = base.route({ tags: ["Reviews"] }).meta({ internal: true });
|
|
8903
8920
|
var reviewsContract = {
|
|
8904
|
-
getStatus:
|
|
8921
|
+
getStatus: tagged15.route({ method: "GET", path: "/posts/{postId}/reviews/status", summary: "Get review status and history" }).errors(orgErrors).input(object({ postId: Uuid, postScheduleId: Uuid.optional() })).output(ReviewStatusSchema),
|
|
8905
8922
|
/**
|
|
8906
8923
|
* Sends mail from our domain to addresses the caller names, so it spends
|
|
8907
8924
|
* outbound reputation — `publishBase`, not `writableBase`, same rule as
|
|
@@ -8909,14 +8926,14 @@ var reviewsContract = {
|
|
|
8909
8926
|
* before anything is queued, so a caller cannot use this to email an
|
|
8910
8927
|
* arbitrary address.
|
|
8911
8928
|
*/
|
|
8912
|
-
requestReview:
|
|
8929
|
+
requestReview: tagged15.route({ method: "POST", path: "/posts/{postId}/reviews/request", summary: "Request review of a post" }).errors(publishErrors).input(
|
|
8913
8930
|
object({
|
|
8914
8931
|
postId: Uuid,
|
|
8915
8932
|
postScheduleIds: array(Uuid).optional(),
|
|
8916
8933
|
requiredApproverIds: array(string2()).optional()
|
|
8917
8934
|
})
|
|
8918
8935
|
).output(SuccessSchema),
|
|
8919
|
-
submitDecision:
|
|
8936
|
+
submitDecision: tagged15.route({ method: "POST", path: "/posts/{postId}/reviews/decision", summary: "Approve, reject, or request changes" }).errors(writableErrors).input(
|
|
8920
8937
|
object({
|
|
8921
8938
|
postId: Uuid,
|
|
8922
8939
|
postScheduleId: Uuid.nullable().optional(),
|
|
@@ -8924,7 +8941,7 @@ var reviewsContract = {
|
|
|
8924
8941
|
comment: string2().trim().max(2e3).optional()
|
|
8925
8942
|
})
|
|
8926
8943
|
).output(SuccessSchema),
|
|
8927
|
-
cancelReview:
|
|
8944
|
+
cancelReview: tagged15.route({ method: "POST", path: "/posts/{postId}/reviews/cancel", summary: "Cancel a pending review" }).errors(writableErrors).input(object({ postId: Uuid })).output(SuccessSchema)
|
|
8928
8945
|
};
|
|
8929
8946
|
|
|
8930
8947
|
// ../../packages/api-contract/src/schedules.ts
|
|
@@ -9067,14 +9084,14 @@ var ScheduleWithPostSchema = PostRowSchema.extend({
|
|
|
9067
9084
|
/** The requested schedule, followed by the rest of its thread in publish order. */
|
|
9068
9085
|
schedules: array(ScheduleWithIntegrationSchema)
|
|
9069
9086
|
});
|
|
9070
|
-
var
|
|
9087
|
+
var tagged16 = base.route({ tags: ["Schedules"] });
|
|
9071
9088
|
var schedulesContract = {
|
|
9072
|
-
list:
|
|
9089
|
+
list: tagged16.route({ method: "GET", path: "/schedules", summary: "List schedules (calendar view)" }).errors(orgErrors).input(ListSchedulesInputSchema).output(ListSchedulesOutputSchema),
|
|
9073
9090
|
// Dashboard plumbing: the status segment row on `/posts` and `/calendar`. No
|
|
9074
9091
|
// external caller needs it, so it stays out of the public surface.
|
|
9075
|
-
counts:
|
|
9076
|
-
getById:
|
|
9077
|
-
delete:
|
|
9092
|
+
counts: tagged16.route({ method: "GET", path: "/schedules/counts", summary: "Count schedules per status" }).meta({ internal: true }).errors(orgErrors).input(CountSchedulesInputSchema).output(CountSchedulesOutputSchema),
|
|
9093
|
+
getById: tagged16.route({ method: "GET", path: "/schedules/{id}", summary: "Get a schedule" }).errors(orgErrors).input(GetScheduleByIdInputSchema).output(ScheduleWithPostSchema),
|
|
9094
|
+
delete: tagged16.route({ method: "DELETE", path: "/schedules/{id}", summary: "Delete a schedule" }).errors({ ...writableErrors, ...postDomainErrors }).input(DeleteScheduleInputSchema).output(DeletedSchema)
|
|
9078
9095
|
};
|
|
9079
9096
|
|
|
9080
9097
|
// ../../packages/api-contract/src/support.ts
|
|
@@ -9157,17 +9174,17 @@ var TagSchema = object({
|
|
|
9157
9174
|
var CreateTagInputSchema = object({ name: TagNameSchema });
|
|
9158
9175
|
var UpdateTagInputSchema = object({ id: Uuid, name: TagNameSchema });
|
|
9159
9176
|
var TagUsageCountSchema = object({ tagId: Uuid, count: AggregateCount });
|
|
9160
|
-
var
|
|
9161
|
-
var internal6 =
|
|
9177
|
+
var tagged17 = base.route({ tags: ["Tags"] });
|
|
9178
|
+
var internal6 = tagged17.meta({ internal: true });
|
|
9162
9179
|
var tagsContract = {
|
|
9163
|
-
list:
|
|
9180
|
+
list: tagged17.route({ method: "GET", path: "/tags", summary: "List tags" }).errors(orgErrors).output(array(TagSchema)),
|
|
9164
9181
|
/**
|
|
9165
9182
|
* Declared before `getById` for readability only — oRPC matches a literal
|
|
9166
9183
|
* segment ahead of a path parameter regardless of declaration order, so
|
|
9167
9184
|
* `/tags/usage-counts` never resolves as `/tags/{id}`.
|
|
9168
9185
|
*/
|
|
9169
9186
|
getUsageCounts: internal6.route({ method: "GET", path: "/tags/usage-counts", summary: "Count posts per tag" }).errors(orgErrors).output(array(TagUsageCountSchema)),
|
|
9170
|
-
getById:
|
|
9187
|
+
getById: tagged17.route({ method: "GET", path: "/tags/{id}", summary: "Get a tag" }).errors(orgErrors).input(IdPathParam).output(TagSchema),
|
|
9171
9188
|
create: internal6.route({ method: "POST", path: "/tags", summary: "Create a tag", successStatus: 201 }).errors({ ...writableErrors, CONFLICT: { message: "A tag with that name already exists." } }).input(CreateTagInputSchema).output(TagSchema),
|
|
9172
9189
|
update: internal6.route({ method: "PATCH", path: "/tags/{id}", summary: "Rename a tag" }).errors(writableErrors).input(UpdateTagInputSchema).output(TagSchema),
|
|
9173
9190
|
delete: internal6.route({ method: "DELETE", path: "/tags/{id}", summary: "Delete a tag" }).errors(orgErrors).input(IdPathParam).output(DeletedSchema)
|
|
@@ -9205,10 +9222,10 @@ var UsageEventSchema = object({
|
|
|
9205
9222
|
callerLabel: string2().nullable(),
|
|
9206
9223
|
createdAt: Timestamp
|
|
9207
9224
|
});
|
|
9208
|
-
var
|
|
9209
|
-
var internal7 =
|
|
9225
|
+
var tagged18 = base.route({ tags: ["Usage"] });
|
|
9226
|
+
var internal7 = tagged18.meta({ internal: true });
|
|
9210
9227
|
var usageContract = {
|
|
9211
|
-
summary:
|
|
9228
|
+
summary: tagged18.route({ method: "GET", path: "/usage", summary: "Get API and MCP call totals for the workspace" }).errors(orgErrors).input(object({ days: WindowDays })).output(UsageSummarySchema),
|
|
9212
9229
|
daily: internal7.route({ method: "GET", path: "/usage/daily", summary: "Get daily call counts for one surface" }).errors(orgErrors).input(object({ surface: UsageSurfaceSchema, days: WindowDays })).output(object({ items: array(UsageDailyPointSchema) })),
|
|
9213
9230
|
events: internal7.route({ method: "GET", path: "/usage/events", summary: "List recent API and MCP calls" }).errors(orgErrors).input(
|
|
9214
9231
|
object({
|
|
@@ -9359,15 +9376,15 @@ var AiQuotaSchema = object({
|
|
|
9359
9376
|
remaining: number2().nullable(),
|
|
9360
9377
|
unlimited: boolean2()
|
|
9361
9378
|
});
|
|
9362
|
-
var
|
|
9363
|
-
var internal8 =
|
|
9379
|
+
var tagged19 = base.route({ tags: ["User"] });
|
|
9380
|
+
var internal8 = tagged19.meta({ internal: true });
|
|
9364
9381
|
var userContract = {
|
|
9365
|
-
me:
|
|
9382
|
+
me: tagged19.route({ method: "GET", path: "/users/me", summary: "Get the current user" }).errors({ ...authedErrors, NOT_FOUND: { message: "User not found." } }).output(MeSchema),
|
|
9366
9383
|
update: internal8.route({ method: "PATCH", path: "/users/me", summary: "Update the current user" }).errors({ ...authedErrors, NOT_FOUND: { message: "User not found." } }).input(UpdateUserInputSchema).output(UserAccountSchema),
|
|
9367
|
-
getPreferences:
|
|
9384
|
+
getPreferences: tagged19.route({ method: "GET", path: "/users/me/preferences", summary: "Get the current user's preferences" }).errors(authedErrors).output(UserPreferencesSchema),
|
|
9368
9385
|
updatePreferences: internal8.route({ method: "PATCH", path: "/users/me/preferences", summary: "Update the current user's preferences" }).errors(authedErrors).input(UpdatePreferencesInputSchema).output(UserPreferencesSchema),
|
|
9369
9386
|
resetPreferences: internal8.route({ method: "DELETE", path: "/users/me/preferences", summary: "Reset the current user's preferences" }).errors(authedErrors).output(object({ message: string2() })),
|
|
9370
|
-
getPlanQuota:
|
|
9387
|
+
getPlanQuota: tagged19.route({ method: "GET", path: "/users/me/plan-quota", summary: "Get the active workspace's plan quota" }).errors(orgErrors).input(object({ platforms: array(PlatformEnum).optional() })).output(PlanQuotaSchema),
|
|
9371
9388
|
getAiQuota: internal8.route({ method: "GET", path: "/users/me/ai-quota", summary: "Get the active workspace's AI credit quota" }).errors(orgErrors).output(AiQuotaSchema),
|
|
9372
9389
|
setDefaultWorkspace: internal8.route({ method: "POST", path: "/users/me/default-workspace", summary: "Set the current user's default workspace" }).errors({ ...authedErrors, FORBIDDEN: { message: "You are not a member of this workspace." } }).input(object({ organizationId: string2() })).output(DeletedSchema)
|
|
9373
9390
|
};
|
|
@@ -9430,7 +9447,7 @@ var WorkspaceSummarySchema = object({
|
|
|
9430
9447
|
role: string2()
|
|
9431
9448
|
});
|
|
9432
9449
|
var publicTagged2 = base.route({ tags: ["Workspace"] });
|
|
9433
|
-
var
|
|
9450
|
+
var tagged20 = publicTagged2.meta({ internal: true });
|
|
9434
9451
|
var workspaceContract = {
|
|
9435
9452
|
/**
|
|
9436
9453
|
* Public, so an OAuth client can offer a workspace switcher: the chosen id goes
|
|
@@ -9438,8 +9455,8 @@ var workspaceContract = {
|
|
|
9438
9455
|
* only that one.
|
|
9439
9456
|
*/
|
|
9440
9457
|
list: publicTagged2.route({ method: "GET", path: "/workspaces", summary: "List your workspaces" }).errors(authedErrors).output(array(WorkspaceSummarySchema)),
|
|
9441
|
-
getOwnedCapacity:
|
|
9442
|
-
create:
|
|
9458
|
+
getOwnedCapacity: tagged20.route({ method: "GET", path: "/workspaces/owned-capacity", summary: "Get owned workspace capacity" }).errors(authedErrors).output(OwnedCapacitySchema),
|
|
9459
|
+
create: tagged20.route({ method: "POST", path: "/workspaces", summary: "Create a workspace", successStatus: 201 }).errors({
|
|
9443
9460
|
...authedErrors,
|
|
9444
9461
|
FORBIDDEN: { message: "You have reached your workspace capacity." },
|
|
9445
9462
|
INTERNAL_SERVER_ERROR: { message: "Failed to create workspace." }
|
|
@@ -9449,7 +9466,7 @@ var workspaceContract = {
|
|
|
9449
9466
|
* workspace active. Ownership is verified against the `organizationId` in
|
|
9450
9467
|
* the body, exactly as the tRPC procedure did.
|
|
9451
9468
|
*/
|
|
9452
|
-
transferOwnership:
|
|
9469
|
+
transferOwnership: tagged20.route({
|
|
9453
9470
|
method: "POST",
|
|
9454
9471
|
path: "/workspaces/{organizationId}/transfer-ownership",
|
|
9455
9472
|
summary: "Transfer workspace ownership"
|
|
@@ -9459,15 +9476,15 @@ var workspaceContract = {
|
|
|
9459
9476
|
FORBIDDEN: { message: "Only the billing owner can transfer workspace ownership." },
|
|
9460
9477
|
BAD_REQUEST: { message: "New owner must be a member of the workspace." }
|
|
9461
9478
|
}).input(TransferOwnershipInputSchema).output(SuccessSchema),
|
|
9462
|
-
updateApprovalSettings:
|
|
9463
|
-
getBrandVoice:
|
|
9464
|
-
updateBrandVoice:
|
|
9465
|
-
getAlertWebhook:
|
|
9466
|
-
updateAlertWebhook:
|
|
9479
|
+
updateApprovalSettings: tagged20.route({ method: "PATCH", path: "/workspaces/approval-settings", summary: "Update approval settings" }).errors(orgErrors).input(ApprovalSettingsInputSchema).output(SuccessSchema),
|
|
9480
|
+
getBrandVoice: tagged20.route({ method: "GET", path: "/workspaces/brand-voice", summary: "Get the workspace brand voice" }).errors(orgErrors).output(object({ voiceProfile: string2() })),
|
|
9481
|
+
updateBrandVoice: tagged20.route({ method: "PATCH", path: "/workspaces/brand-voice", summary: "Update the workspace brand voice" }).errors(orgErrors).input(object({ voiceProfile: string2().max(2e3) })).output(SuccessSchema),
|
|
9482
|
+
getAlertWebhook: tagged20.route({ method: "GET", path: "/workspaces/alert-webhook", summary: "Get workspace alert webhook settings" }).errors(orgErrors).output(AlertWebhookSettingsSchema),
|
|
9483
|
+
updateAlertWebhook: tagged20.route({ method: "PATCH", path: "/workspaces/alert-webhook", summary: "Update workspace alert webhook settings" }).errors({
|
|
9467
9484
|
...orgErrors,
|
|
9468
9485
|
FORBIDDEN: { message: "Only workspace administrators can update alert webhook settings" }
|
|
9469
9486
|
}).input(UpdateAlertWebhookInputSchema).output(SuccessSchema),
|
|
9470
|
-
testAlertWebhook:
|
|
9487
|
+
testAlertWebhook: tagged20.route({
|
|
9471
9488
|
method: "POST",
|
|
9472
9489
|
path: "/workspaces/alert-webhook/test",
|
|
9473
9490
|
summary: "Send a test notification to the webhook"
|
|
@@ -9492,6 +9509,7 @@ var contract = {
|
|
|
9492
9509
|
media: mediaContract,
|
|
9493
9510
|
mediaSources: mediaSourcesContract,
|
|
9494
9511
|
notifications: notificationsContract,
|
|
9512
|
+
platforms: platformsContract,
|
|
9495
9513
|
posts: postsContract,
|
|
9496
9514
|
publicCalendar: publicCalendarContract,
|
|
9497
9515
|
publicPost: publicPostContract,
|
|
@@ -12103,7 +12121,7 @@ function resolveApiKey() {
|
|
|
12103
12121
|
}
|
|
12104
12122
|
|
|
12105
12123
|
// src/output.ts
|
|
12106
|
-
var EXIT = { ok: 0, failure: 1, usage: 2 };
|
|
12124
|
+
var EXIT = { ok: 0, failure: 1, usage: 2, auth: 3, plan: 4, rateLimited: 5 };
|
|
12107
12125
|
var globals = {};
|
|
12108
12126
|
function setGlobalOptions(options) {
|
|
12109
12127
|
globals = options;
|
|
@@ -12128,18 +12146,48 @@ function printStatus(line) {
|
|
|
12128
12146
|
process.stderr.write(`${line}
|
|
12129
12147
|
`);
|
|
12130
12148
|
}
|
|
12131
|
-
function
|
|
12149
|
+
function workspaceOption() {
|
|
12150
|
+
return globals.workspace;
|
|
12151
|
+
}
|
|
12152
|
+
var PLAN_CODES = /* @__PURE__ */ new Set(["PAYMENT_REQUIRED", "POST_QUOTA_EXCEEDED", "REPURPOSE_QUOTA_EXCEEDED"]);
|
|
12153
|
+
function exitCodeFor(error2, status) {
|
|
12154
|
+
if (error2.code === "RATE_LIMITED" || status === 429) return EXIT.rateLimited;
|
|
12155
|
+
if (PLAN_CODES.has(error2.code) || status === 402) return EXIT.plan;
|
|
12156
|
+
if (error2.code === "UNAUTHORIZED" || status === 401) return EXIT.auth;
|
|
12157
|
+
if (status === 400) return EXIT.usage;
|
|
12158
|
+
return EXIT.failure;
|
|
12159
|
+
}
|
|
12160
|
+
function failWith(error2, exitCode) {
|
|
12132
12161
|
if (globals.json) {
|
|
12133
|
-
process.stdout.write(`${JSON.stringify(
|
|
12162
|
+
process.stdout.write(`${JSON.stringify(error2, null, 2)}
|
|
12134
12163
|
`);
|
|
12135
12164
|
} else {
|
|
12136
|
-
process.stderr.write(`Error: ${message}
|
|
12165
|
+
process.stderr.write(`Error: ${error2.message}
|
|
12166
|
+
`);
|
|
12167
|
+
if (error2.data.violations.length > 1) {
|
|
12168
|
+
for (const violation of error2.data.violations) process.stderr.write(` - ${violation.message}
|
|
12137
12169
|
`);
|
|
12170
|
+
}
|
|
12138
12171
|
}
|
|
12139
|
-
process.exit(
|
|
12172
|
+
process.exit(exitCode);
|
|
12173
|
+
}
|
|
12174
|
+
function fail(message, exitCode = EXIT.failure) {
|
|
12175
|
+
return failWith(
|
|
12176
|
+
{ code: exitCode === EXIT.usage ? "BAD_REQUEST" : "CLI_ERROR", message, data: { violations: [] } },
|
|
12177
|
+
exitCode
|
|
12178
|
+
);
|
|
12140
12179
|
}
|
|
12141
12180
|
function failUsage(message) {
|
|
12142
|
-
return
|
|
12181
|
+
return failWith({ code: "BAD_REQUEST", message, data: { violations: [{ message }] } }, EXIT.usage);
|
|
12182
|
+
}
|
|
12183
|
+
var INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/i;
|
|
12184
|
+
function parseInstant(value2, flag) {
|
|
12185
|
+
if (!INSTANT.test(value2) || Number.isNaN(new Date(value2).getTime())) {
|
|
12186
|
+
failUsage(
|
|
12187
|
+
`${flag} "${value2}" needs a time zone. Use RFC 3339 with an offset, e.g. 2026-08-01T09:30:00Z or 2026-08-01T11:30:00+02:00.`
|
|
12188
|
+
);
|
|
12189
|
+
}
|
|
12190
|
+
return value2;
|
|
12143
12191
|
}
|
|
12144
12192
|
function requireInteractive(what) {
|
|
12145
12193
|
if (isInteractive()) return;
|
|
@@ -12154,7 +12202,7 @@ function formatTable(headers, rows) {
|
|
|
12154
12202
|
}
|
|
12155
12203
|
|
|
12156
12204
|
// src/version.ts
|
|
12157
|
-
var CLI_VERSION = "0.1.
|
|
12205
|
+
var CLI_VERSION = "0.1.25";
|
|
12158
12206
|
|
|
12159
12207
|
// src/client.ts
|
|
12160
12208
|
var DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
@@ -12222,11 +12270,16 @@ function buildClient(apiUrl, auth) {
|
|
|
12222
12270
|
const oauth = auth.kind === "oauth" ? { accessToken: auth.accessToken, refreshToken: auth.refreshToken, clientId: auth.clientId } : null;
|
|
12223
12271
|
const link = new OpenAPILink(contract, {
|
|
12224
12272
|
url: `${apiUrl}/api/v1`,
|
|
12225
|
-
headers: () =>
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12273
|
+
headers: () => {
|
|
12274
|
+
const headers = new Headers({
|
|
12275
|
+
[CLI_VERSION_HEADER]: CLI_VERSION,
|
|
12276
|
+
"x-postonus-client": "cli",
|
|
12277
|
+
...auth.kind === "api-key" ? { "x-api-key": auth.apiKey } : { authorization: `Bearer ${oauth?.accessToken}` }
|
|
12278
|
+
});
|
|
12279
|
+
const workspace = workspaceOption();
|
|
12280
|
+
if (workspace) headers.set("x-workspace-id", workspace);
|
|
12281
|
+
return Object.fromEntries(headers);
|
|
12282
|
+
},
|
|
12230
12283
|
fetch: oauth ? createOAuthFetch(apiUrl, oauth, persistRefreshedTokens(apiUrl, oauth)) : (request, init) => fetch(request, init)
|
|
12231
12284
|
});
|
|
12232
12285
|
return createORPCClient(link);
|
|
@@ -12277,6 +12330,18 @@ function describeError(cause) {
|
|
|
12277
12330
|
}
|
|
12278
12331
|
return String(cause);
|
|
12279
12332
|
}
|
|
12333
|
+
function failApi(cause) {
|
|
12334
|
+
if (cause instanceof ORPCError3) {
|
|
12335
|
+
const data = cause.data;
|
|
12336
|
+
const error2 = {
|
|
12337
|
+
code: cause.code,
|
|
12338
|
+
message: describeError(cause),
|
|
12339
|
+
data: { violations: data?.violations ?? [] }
|
|
12340
|
+
};
|
|
12341
|
+
return failWith(error2, exitCodeFor(error2, cause.status));
|
|
12342
|
+
}
|
|
12343
|
+
return failWith({ code: "CLI_ERROR", message: describeError(cause), data: { violations: [] } }, EXIT.failure);
|
|
12344
|
+
}
|
|
12280
12345
|
|
|
12281
12346
|
// src/ui.tsx
|
|
12282
12347
|
import { Box, render, Text, useApp, useInput } from "ink";
|
|
@@ -12364,6 +12429,7 @@ async function renderOnce(node2) {
|
|
|
12364
12429
|
// src/commands/auth.tsx
|
|
12365
12430
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
12366
12431
|
var CLI_OAUTH_SCOPE = "openid profile offline_access";
|
|
12432
|
+
var AGENT_SETUP_PROMPT = `Set up Postonus for me. Fetch ${SITE.url}/docs/setup.md and follow it.`;
|
|
12367
12433
|
var DeviceCodeError = class extends Error {
|
|
12368
12434
|
constructor(code, message) {
|
|
12369
12435
|
super(message);
|
|
@@ -12493,7 +12559,7 @@ async function login() {
|
|
|
12493
12559
|
;
|
|
12494
12560
|
({ clientId, device } = await startDeviceLogin(apiUrl, carried.clientId));
|
|
12495
12561
|
} catch (error2) {
|
|
12496
|
-
|
|
12562
|
+
failApi(error2);
|
|
12497
12563
|
}
|
|
12498
12564
|
if (clientId !== carried.clientId) await writeConfig({ ...carried, clientId, apiUrl });
|
|
12499
12565
|
void open2(device.verification_uri_complete).catch(() => {
|
|
@@ -12517,17 +12583,22 @@ async function login() {
|
|
|
12517
12583
|
email: user.email
|
|
12518
12584
|
});
|
|
12519
12585
|
if (isJsonMode()) {
|
|
12520
|
-
printJson({ status: "signed-in", email: user.email, apiUrl });
|
|
12586
|
+
printJson({ status: "signed-in", email: user.email, apiUrl, next: AGENT_SETUP_PROMPT });
|
|
12521
12587
|
return;
|
|
12522
12588
|
}
|
|
12523
12589
|
printLine(`Signed in as ${user.email}`);
|
|
12590
|
+
printStatus(`
|
|
12591
|
+
Next, paste this into your coding agent (Claude Code, Cursor, Codex):
|
|
12592
|
+
|
|
12593
|
+
${AGENT_SETUP_PROMPT}
|
|
12594
|
+
`);
|
|
12524
12595
|
};
|
|
12525
12596
|
if (!isInteractive()) {
|
|
12526
12597
|
printStatus(`Enter code ${device.user_code} at ${device.verification_uri}`);
|
|
12527
12598
|
try {
|
|
12528
12599
|
await finish(await pollForToken(apiUrl, clientId, device));
|
|
12529
12600
|
} catch (error2) {
|
|
12530
|
-
|
|
12601
|
+
failApi(error2);
|
|
12531
12602
|
}
|
|
12532
12603
|
return;
|
|
12533
12604
|
}
|
|
@@ -12537,7 +12608,7 @@ async function login() {
|
|
|
12537
12608
|
try {
|
|
12538
12609
|
await instance.waitUntilExit();
|
|
12539
12610
|
} catch (error2) {
|
|
12540
|
-
|
|
12611
|
+
failApi(error2);
|
|
12541
12612
|
}
|
|
12542
12613
|
}
|
|
12543
12614
|
async function logout() {
|
|
@@ -12560,7 +12631,7 @@ async function whoami() {
|
|
|
12560
12631
|
printLine(`${user.email} (${user.name})`);
|
|
12561
12632
|
printStatus(`${apiUrl} \xB7 ${auth.kind === "api-key" ? "API key" : "OAuth"}`);
|
|
12562
12633
|
} catch (error2) {
|
|
12563
|
-
|
|
12634
|
+
failApi(error2);
|
|
12564
12635
|
}
|
|
12565
12636
|
}
|
|
12566
12637
|
|
|
@@ -12587,7 +12658,7 @@ async function listChannels() {
|
|
|
12587
12658
|
try {
|
|
12588
12659
|
channels2 = await api.integrations.get();
|
|
12589
12660
|
} catch (error2) {
|
|
12590
|
-
|
|
12661
|
+
failApi(error2);
|
|
12591
12662
|
}
|
|
12592
12663
|
if (isJsonMode()) {
|
|
12593
12664
|
printJson({
|
|
@@ -12671,7 +12742,7 @@ async function connectChannel(options) {
|
|
|
12671
12742
|
try {
|
|
12672
12743
|
existing = await api.integrations.get();
|
|
12673
12744
|
} catch (error2) {
|
|
12674
|
-
|
|
12745
|
+
failApi(error2);
|
|
12675
12746
|
}
|
|
12676
12747
|
let platform;
|
|
12677
12748
|
if (options.platform) {
|
|
@@ -12690,7 +12761,7 @@ async function connectChannel(options) {
|
|
|
12690
12761
|
const result = await api.integrations.connectIntegration({ platform });
|
|
12691
12762
|
redirectUrl = result.redirectUrl;
|
|
12692
12763
|
} catch (error2) {
|
|
12693
|
-
|
|
12764
|
+
failApi(error2);
|
|
12694
12765
|
}
|
|
12695
12766
|
if (isJsonMode()) {
|
|
12696
12767
|
printJson({ platform, authorizeUrl: redirectUrl });
|
|
@@ -12922,7 +12993,7 @@ async function uploadCommand(paths) {
|
|
|
12922
12993
|
try {
|
|
12923
12994
|
uploaded.push(await uploadMedia(api, path));
|
|
12924
12995
|
} catch (error2) {
|
|
12925
|
-
|
|
12996
|
+
failApi(error2);
|
|
12926
12997
|
}
|
|
12927
12998
|
}
|
|
12928
12999
|
if (isJsonMode()) {
|
|
@@ -12933,19 +13004,27 @@ async function uploadCommand(paths) {
|
|
|
12933
13004
|
printLine(`${item.mediaId} ${item.url}`);
|
|
12934
13005
|
}
|
|
12935
13006
|
}
|
|
13007
|
+
async function importCommand(url2) {
|
|
13008
|
+
const { api } = await getApi();
|
|
13009
|
+
try {
|
|
13010
|
+
const imported = await api.upload.fromUrl({ url: url2, scenarioId: SCENARIO });
|
|
13011
|
+
if (isJsonMode()) {
|
|
13012
|
+
printJson(imported);
|
|
13013
|
+
return;
|
|
13014
|
+
}
|
|
13015
|
+
printLine(`${imported.type.toLowerCase()} ${imported.mediaId ?? "\u2014"} ${imported.publicUrl}`);
|
|
13016
|
+
} catch (error2) {
|
|
13017
|
+
failApi(error2);
|
|
13018
|
+
}
|
|
13019
|
+
}
|
|
12936
13020
|
|
|
12937
13021
|
// src/commands/post.ts
|
|
12938
13022
|
import { spawnSync } from "child_process";
|
|
12939
13023
|
import { mkdtemp, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "fs/promises";
|
|
12940
13024
|
import { tmpdir } from "os";
|
|
12941
13025
|
import { join as join2 } from "path";
|
|
12942
|
-
async function
|
|
12943
|
-
if (options.file)
|
|
12944
|
-
const content = await readFile2(options.file, "utf8").catch(() => {
|
|
12945
|
-
return fail(`Could not read ${options.file}`);
|
|
12946
|
-
});
|
|
12947
|
-
return content.trim();
|
|
12948
|
-
}
|
|
13026
|
+
async function readContent(text, options) {
|
|
13027
|
+
if (options.file) return (await readFileOrFail(options.file)).trim();
|
|
12949
13028
|
if (options.editor) {
|
|
12950
13029
|
requireInteractive("--editor");
|
|
12951
13030
|
return openEditor(text ?? "");
|
|
@@ -12957,7 +13036,15 @@ async function resolveContent(text, options) {
|
|
|
12957
13036
|
const piped = Buffer.concat(chunks).toString("utf8").trim();
|
|
12958
13037
|
if (piped) return piped;
|
|
12959
13038
|
}
|
|
12960
|
-
return
|
|
13039
|
+
return void 0;
|
|
13040
|
+
}
|
|
13041
|
+
function readFileOrFail(path) {
|
|
13042
|
+
return readFile2(path, "utf8").catch(() => fail(`Could not read ${path}`));
|
|
13043
|
+
}
|
|
13044
|
+
async function readThread(path) {
|
|
13045
|
+
const segments = (await readFileOrFail(path)).split(/^---[ \t]*$/m).map((segment) => segment.trim()).filter(Boolean);
|
|
13046
|
+
if (segments.length < 2) failUsage(`${path} holds one segment. Separate thread segments with a line of \`---\`.`);
|
|
13047
|
+
return segments;
|
|
12961
13048
|
}
|
|
12962
13049
|
async function openEditor(initial) {
|
|
12963
13050
|
const editor = process.env.VISUAL || process.env.EDITOR;
|
|
@@ -12975,123 +13062,164 @@ async function openEditor(initial) {
|
|
|
12975
13062
|
await rm2(directory, { recursive: true, force: true });
|
|
12976
13063
|
}
|
|
12977
13064
|
}
|
|
12978
|
-
|
|
12979
|
-
const
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
return
|
|
13065
|
+
function readTargets(options) {
|
|
13066
|
+
const platforms = (options.to ?? "").split(",").map((value2) => value2.trim()).filter(Boolean).map(parsePlatform);
|
|
13067
|
+
if (platforms.length > 0 && options.channel?.length) failUsage("Use --to or --channel, not both.");
|
|
13068
|
+
return {
|
|
13069
|
+
platforms: platforms.length > 0 ? platforms : void 0,
|
|
13070
|
+
selectedIntegrations: options.channel?.length ? options.channel : void 0
|
|
13071
|
+
};
|
|
13072
|
+
}
|
|
13073
|
+
function readCopy(pairs) {
|
|
13074
|
+
if (!pairs?.length) return void 0;
|
|
13075
|
+
return Object.fromEntries(
|
|
13076
|
+
pairs.map((pair) => {
|
|
13077
|
+
const split = pair.indexOf("=");
|
|
13078
|
+
if (split < 1) failUsage(`--copy "${pair}" must be <channelId>=<text>.`);
|
|
13079
|
+
return [pair.slice(0, split), pair.slice(split + 1)];
|
|
13080
|
+
})
|
|
13081
|
+
);
|
|
12989
13082
|
}
|
|
12990
|
-
function
|
|
13083
|
+
function readTiming(options) {
|
|
13084
|
+
const chosen = [options.at, options.optimal, options.now, options.draft].filter(Boolean);
|
|
13085
|
+
if (chosen.length > 1) failUsage("Use one of --at, --optimal, --now or --draft.");
|
|
12991
13086
|
if (options.draft) return { postAction: "DRAFT" };
|
|
12992
|
-
if (options.
|
|
12993
|
-
const when = new Date(options.at);
|
|
12994
|
-
if (Number.isNaN(when.getTime())) {
|
|
12995
|
-
return failUsage(`Could not read "${options.at}" as a date. Use an ISO timestamp, e.g. 2026-08-01T09:30:00Z.`);
|
|
12996
|
-
}
|
|
12997
|
-
if (when.getTime() <= Date.now()) return failUsage("That time is in the past.");
|
|
12998
|
-
return { postAction: "SCHEDULED_TIME", scheduledAt: when };
|
|
12999
|
-
}
|
|
13087
|
+
if (options.now) return { postAction: "PUBLISH_NOW" };
|
|
13000
13088
|
if (options.optimal) return { postAction: "NEXT_WINDOW" };
|
|
13001
|
-
|
|
13089
|
+
if (options.at) return { postAction: "SCHEDULED_TIME", scheduledAt: parseInstant(options.at, "--at") };
|
|
13090
|
+
return failUsage("Say when to post: --at <time>, --optimal, --now, or --draft.");
|
|
13002
13091
|
}
|
|
13003
|
-
async function
|
|
13004
|
-
if (options.at && options.optimal) failUsage("Use either --at or --optimal, not both.");
|
|
13005
|
-
const platforms = (options.to ?? "").split(",").map((value2) => value2.trim()).filter(Boolean).map(parsePlatform);
|
|
13006
|
-
const content = await resolveContent(text, options);
|
|
13007
|
-
const { postAction, scheduledAt } = resolveSchedule(options);
|
|
13008
|
-
if (postAction !== "DRAFT" && platforms.length === 0) {
|
|
13009
|
-
failUsage("Say where to post: --to x,linkedin (or use --draft).");
|
|
13010
|
-
}
|
|
13011
|
-
const { api } = await getApi();
|
|
13012
|
-
let integrationIds = [];
|
|
13013
|
-
let matched = [];
|
|
13014
|
-
if (platforms.length > 0) {
|
|
13015
|
-
const resolved = await resolveIntegrations(api, platforms);
|
|
13016
|
-
integrationIds = resolved.ids;
|
|
13017
|
-
matched = resolved.matched;
|
|
13018
|
-
}
|
|
13019
|
-
if (options.dryRun) {
|
|
13020
|
-
const plan = {
|
|
13021
|
-
dryRun: true,
|
|
13022
|
-
content,
|
|
13023
|
-
postAction,
|
|
13024
|
-
scheduledAt: scheduledAt?.toISOString() ?? null,
|
|
13025
|
-
media: options.media ?? [],
|
|
13026
|
-
channels: matched.map((channel) => ({ id: channel.id, platform: channel.platform, name: channel.name }))
|
|
13027
|
-
};
|
|
13028
|
-
if (isJsonMode()) {
|
|
13029
|
-
printJson(plan);
|
|
13030
|
-
return;
|
|
13031
|
-
}
|
|
13032
|
-
printLine(`Would ${postAction === "DRAFT" ? "save a draft" : "schedule"}: ${content}`);
|
|
13033
|
-
for (const channel of matched) printLine(` \u2192 ${channel.platform} ${channel.name}`);
|
|
13034
|
-
if (scheduledAt) printLine(` at ${scheduledAt.toISOString()}`);
|
|
13035
|
-
return;
|
|
13036
|
-
}
|
|
13092
|
+
async function uploadAll(api, paths) {
|
|
13037
13093
|
const media2 = [];
|
|
13038
|
-
for (const path of
|
|
13094
|
+
for (const path of paths ?? []) {
|
|
13039
13095
|
printStatus(`Uploading ${path}\u2026`);
|
|
13040
13096
|
try {
|
|
13041
13097
|
media2.push(await uploadMedia(api, path));
|
|
13042
13098
|
} catch (error2) {
|
|
13043
|
-
|
|
13099
|
+
failApi(error2);
|
|
13044
13100
|
}
|
|
13045
13101
|
}
|
|
13102
|
+
return media2;
|
|
13103
|
+
}
|
|
13104
|
+
function printState(state, verb) {
|
|
13105
|
+
if (isJsonMode()) {
|
|
13106
|
+
printJson(state);
|
|
13107
|
+
return;
|
|
13108
|
+
}
|
|
13109
|
+
printLine(
|
|
13110
|
+
`${state.dryRun ? `Would ${verb.toLowerCase()}` : verb} ${state.postId}${state.review ? " (waiting for review)" : ""}`
|
|
13111
|
+
);
|
|
13112
|
+
for (const schedule of state.schedules) {
|
|
13113
|
+
printLine(
|
|
13114
|
+
` ${schedule.platform.toLowerCase()} ${schedule.channelName} ${schedule.status.toLowerCase()} ${schedule.scheduledAt ?? "\u2014"} ${schedule.scheduleId}`
|
|
13115
|
+
);
|
|
13116
|
+
}
|
|
13117
|
+
if (!state.dryRun) printStatus(state.url);
|
|
13118
|
+
}
|
|
13119
|
+
async function post(text, options) {
|
|
13120
|
+
const thread = options.threadFile ? await readThread(options.threadFile) : void 0;
|
|
13121
|
+
const content = thread ? void 0 : await readContent(text, options);
|
|
13122
|
+
if (!thread && !content) failUsage("No content. Pass text, --file, --thread-file, --editor, or pipe it in.");
|
|
13123
|
+
const timing = readTiming(options);
|
|
13124
|
+
const targets = readTargets(options);
|
|
13125
|
+
if (timing.postAction !== "DRAFT" && !targets.platforms && !targets.selectedIntegrations) {
|
|
13126
|
+
failUsage("Say where to post: --to x,linkedin or --channel <id> (or use --draft).");
|
|
13127
|
+
}
|
|
13128
|
+
const { api } = await getApi();
|
|
13129
|
+
const media2 = options.dryRun ? [] : await uploadAll(api, options.media);
|
|
13046
13130
|
try {
|
|
13047
|
-
const
|
|
13131
|
+
const { posts } = await api.posts.create({
|
|
13048
13132
|
rows: [
|
|
13049
13133
|
{
|
|
13050
|
-
content,
|
|
13051
|
-
scheduledAt,
|
|
13134
|
+
content: thread ? thread.join("\n\n") : content,
|
|
13135
|
+
scheduledAt: "scheduledAt" in timing ? timing.scheduledAt : void 0,
|
|
13052
13136
|
media: media2.map((item) => ({ url: item.url, type: item.type, id: item.mediaId, fileId: item.uploadId }))
|
|
13053
13137
|
}
|
|
13054
13138
|
],
|
|
13055
|
-
shared: {
|
|
13056
|
-
postAction
|
|
13139
|
+
shared: { ...targets, thread, integrationContent: readCopy(options.copy) },
|
|
13140
|
+
postAction: timing.postAction,
|
|
13141
|
+
dryRun: options.dryRun
|
|
13142
|
+
});
|
|
13143
|
+
const created = posts[0];
|
|
13144
|
+
if (!created) return fail("The server created no post.");
|
|
13145
|
+
printState(created, timing.postAction === "DRAFT" ? "Saved draft" : "Scheduled");
|
|
13146
|
+
} catch (error2) {
|
|
13147
|
+
failApi(error2);
|
|
13148
|
+
}
|
|
13149
|
+
}
|
|
13150
|
+
async function editPost(postId, text, options) {
|
|
13151
|
+
const thread = options.threadFile ? await readThread(options.threadFile) : void 0;
|
|
13152
|
+
const content = thread ? void 0 : await readContent(text, options);
|
|
13153
|
+
const targets = readTargets(options);
|
|
13154
|
+
const integrationContent = readCopy(options.copy);
|
|
13155
|
+
const scheduledAt = options.at ? parseInstant(options.at, "--at") : void 0;
|
|
13156
|
+
if (!thread && content === void 0 && !targets.platforms && !targets.selectedIntegrations && !integrationContent && !scheduledAt && !options.media?.length) {
|
|
13157
|
+
failUsage("Nothing to change. Pass new text, --thread-file, --at, --to, --channel, --copy or --media.");
|
|
13158
|
+
}
|
|
13159
|
+
const { api } = await getApi();
|
|
13160
|
+
const media2 = options.media?.length ? await uploadAll(api, options.media) : void 0;
|
|
13161
|
+
try {
|
|
13162
|
+
const state = await api.posts.update({
|
|
13163
|
+
id: postId,
|
|
13164
|
+
content,
|
|
13165
|
+
thread,
|
|
13166
|
+
scheduledAt,
|
|
13167
|
+
...targets,
|
|
13168
|
+
integrationContent,
|
|
13169
|
+
media: media2?.map((item) => ({ url: item.url, type: item.type, id: item.mediaId, fileId: item.uploadId })),
|
|
13170
|
+
dryRun: options.dryRun
|
|
13057
13171
|
});
|
|
13172
|
+
printState(state, "Updated");
|
|
13173
|
+
} catch (error2) {
|
|
13174
|
+
failApi(error2);
|
|
13175
|
+
}
|
|
13176
|
+
}
|
|
13177
|
+
async function deletePost(postId, options) {
|
|
13178
|
+
const { api } = await getApi();
|
|
13179
|
+
try {
|
|
13180
|
+
const state = await api.posts.delete({ id: postId, deleteRemote: options.remote ?? false });
|
|
13058
13181
|
if (isJsonMode()) {
|
|
13059
|
-
printJson(
|
|
13182
|
+
printJson(state);
|
|
13060
13183
|
return;
|
|
13061
13184
|
}
|
|
13062
|
-
printLine(
|
|
13063
|
-
postAction === "DRAFT" ? `Draft saved (${result.postId})` : `Scheduled ${result.scheduleCount} post${result.scheduleCount === 1 ? "" : "s"} (${result.postId})`
|
|
13064
|
-
);
|
|
13185
|
+
printLine(`Deleted ${postId}${state.deletedFromPlatforms ? ", and on its platforms" : ""}`);
|
|
13065
13186
|
} catch (error2) {
|
|
13066
|
-
|
|
13187
|
+
failApi(error2);
|
|
13067
13188
|
}
|
|
13068
13189
|
}
|
|
13069
|
-
function
|
|
13190
|
+
async function retrySchedule(scheduleId, options) {
|
|
13191
|
+
const { api } = await getApi();
|
|
13192
|
+
try {
|
|
13193
|
+
printState(await api.posts.retrySchedule({ scheduleId, content: options.content }), "Queued again");
|
|
13194
|
+
} catch (error2) {
|
|
13195
|
+
failApi(error2);
|
|
13196
|
+
}
|
|
13197
|
+
}
|
|
13198
|
+
async function bestTimes(options) {
|
|
13070
13199
|
const platforms = (options.to ?? "").split(",").map((value2) => value2.trim()).filter(Boolean).map(parsePlatform);
|
|
13071
13200
|
if (platforms.length === 0) failUsage("Which platforms? e.g. --to x,linkedin");
|
|
13072
|
-
const
|
|
13073
|
-
if (
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
|
-
|
|
13077
|
-
|
|
13078
|
-
|
|
13079
|
-
|
|
13201
|
+
const count = Number.parseInt(options.count ?? "5", 10);
|
|
13202
|
+
if (!Number.isInteger(count) || count < 1 || count > 20) failUsage("--count must be between 1 and 20.");
|
|
13203
|
+
const { api } = await getApi();
|
|
13204
|
+
try {
|
|
13205
|
+
const result = await api.platforms.bestTimes({ platforms, count });
|
|
13206
|
+
if (isJsonMode()) {
|
|
13207
|
+
printJson(result);
|
|
13208
|
+
return;
|
|
13209
|
+
}
|
|
13210
|
+
printLine(
|
|
13211
|
+
formatTable(
|
|
13212
|
+
["WHEN", "PLATFORMS", "SOURCE"],
|
|
13213
|
+
result.slots.map((slot) => [slot.scheduledAt, slot.platforms.join(", ").toLowerCase(), slot.source])
|
|
13214
|
+
)
|
|
13080
13215
|
);
|
|
13081
|
-
|
|
13216
|
+
if (result.platformsWithoutData.length > 0) {
|
|
13217
|
+
printStatus(`No research for ${result.platformsWithoutData.join(", ").toLowerCase()}; those times are a default.`);
|
|
13218
|
+
}
|
|
13219
|
+
} catch (error2) {
|
|
13220
|
+
failApi(error2);
|
|
13082
13221
|
}
|
|
13083
|
-
printLine(
|
|
13084
|
-
formatTable(
|
|
13085
|
-
["DAY", "WINDOW", "PLATFORMS"],
|
|
13086
|
-
windows.map((window) => [
|
|
13087
|
-
DAY_NAMES[window.dayOfWeek],
|
|
13088
|
-
`${window.startTime}\u2013${window.endTime}`,
|
|
13089
|
-
window.platforms.join(", ").toLowerCase()
|
|
13090
|
-
])
|
|
13091
|
-
)
|
|
13092
|
-
);
|
|
13093
13222
|
}
|
|
13094
|
-
var DAY_NAMES = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
13095
13223
|
|
|
13096
13224
|
// src/commands/queue.tsx
|
|
13097
13225
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -13131,14 +13259,12 @@ async function listQueue(options) {
|
|
|
13131
13259
|
limit,
|
|
13132
13260
|
direction: "forward",
|
|
13133
13261
|
platforms: platforms.length > 0 ? platforms : void 0,
|
|
13134
|
-
//
|
|
13135
|
-
|
|
13136
|
-
// existed, and asking for it made every default `queue list` a 500.
|
|
13137
|
-
statuses: statuses.length > 0 ? statuses : ["SCHEDULED", "PUBLISHING"]
|
|
13262
|
+
// The same default as MCP's `list_queue`: work the user can still act on.
|
|
13263
|
+
statuses: statuses.length > 0 ? statuses : ["DRAFT", "SCHEDULED", "FAILED"]
|
|
13138
13264
|
});
|
|
13139
13265
|
schedules = result.schedules;
|
|
13140
13266
|
} catch (error2) {
|
|
13141
|
-
|
|
13267
|
+
failApi(error2);
|
|
13142
13268
|
}
|
|
13143
13269
|
if (isJsonMode()) {
|
|
13144
13270
|
printJson({
|
|
@@ -13173,49 +13299,61 @@ async function listQueue(options) {
|
|
|
13173
13299
|
printLine(formatTable(HEADERS2, rows));
|
|
13174
13300
|
}
|
|
13175
13301
|
async function scheduleDraft(postId, options) {
|
|
13176
|
-
if (Boolean(options.at) === Boolean(options.optimal)) failUsage("Say when to post: --at <
|
|
13177
|
-
const
|
|
13178
|
-
if (when && Number.isNaN(when.getTime())) {
|
|
13179
|
-
failUsage(`Could not read "${options.at}" as a date. Use an ISO timestamp, e.g. 2026-08-01T09:30:00Z.`);
|
|
13180
|
-
}
|
|
13181
|
-
if (when && when.getTime() <= Date.now()) failUsage("That time is in the past.");
|
|
13302
|
+
if (Boolean(options.at) === Boolean(options.optimal)) failUsage("Say when to post: --at <time> or --optimal.");
|
|
13303
|
+
const scheduledAt = options.at ? parseInstant(options.at, "--at") : void 0;
|
|
13182
13304
|
const channelIds = options.channels?.split(",").map((id) => id.trim()).filter(Boolean);
|
|
13183
13305
|
const { api } = await getApi();
|
|
13184
|
-
let post2;
|
|
13185
13306
|
try {
|
|
13186
|
-
|
|
13307
|
+
const state = await api.posts.scheduleDraft({
|
|
13187
13308
|
id: postId,
|
|
13188
|
-
scheduledAt
|
|
13309
|
+
scheduledAt,
|
|
13189
13310
|
useOptimalTime: options.optimal,
|
|
13190
|
-
selectedIntegrations: channelIds?.length ? channelIds : void 0
|
|
13311
|
+
selectedIntegrations: channelIds?.length ? channelIds : void 0,
|
|
13312
|
+
dryRun: options.dryRun
|
|
13191
13313
|
});
|
|
13314
|
+
if (isJsonMode()) {
|
|
13315
|
+
printJson(state);
|
|
13316
|
+
return;
|
|
13317
|
+
}
|
|
13318
|
+
const when = state.schedules.find((schedule) => schedule.scheduledAt)?.scheduledAt;
|
|
13319
|
+
printLine(`${state.dryRun ? "Would schedule" : "Scheduled"} ${postId} for ${when ?? "its next window"}`);
|
|
13192
13320
|
} catch (error2) {
|
|
13193
|
-
|
|
13321
|
+
failApi(error2);
|
|
13194
13322
|
}
|
|
13195
|
-
const times = post2.schedules.flatMap((schedule) => schedule.scheduledAt ? [schedule.scheduledAt] : []);
|
|
13196
|
-
if (isJsonMode()) {
|
|
13197
|
-
printJson({ postId, schedules: post2.schedules.map(({ id, scheduledAt, status }) => ({ id, scheduledAt, status })) });
|
|
13198
|
-
return;
|
|
13199
|
-
}
|
|
13200
|
-
printLine(`Scheduled ${postId} for ${times[0] ?? "its next window"}`);
|
|
13201
13323
|
}
|
|
13202
13324
|
async function moveQueueItem(scheduleId, options) {
|
|
13203
|
-
const
|
|
13204
|
-
if (Number.isNaN(when.getTime())) {
|
|
13205
|
-
failUsage(`Could not read "${options.at}" as a date. Use an ISO timestamp, e.g. 2026-08-01T09:30:00Z.`);
|
|
13206
|
-
}
|
|
13207
|
-
if (when.getTime() <= Date.now()) failUsage("That time is in the past.");
|
|
13325
|
+
const scheduledAt = parseInstant(options.at, "--at");
|
|
13208
13326
|
const { api } = await getApi();
|
|
13209
13327
|
try {
|
|
13210
|
-
await api.posts.rescheduleSchedule({ scheduleId, scheduledAt
|
|
13328
|
+
const state = await api.posts.rescheduleSchedule({ scheduleId, scheduledAt });
|
|
13329
|
+
if (isJsonMode()) {
|
|
13330
|
+
printJson(state);
|
|
13331
|
+
return;
|
|
13332
|
+
}
|
|
13333
|
+
printLine(`Moved ${scheduleId} to ${scheduledAt}`);
|
|
13211
13334
|
} catch (error2) {
|
|
13212
|
-
|
|
13335
|
+
failApi(error2);
|
|
13213
13336
|
}
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13337
|
+
}
|
|
13338
|
+
|
|
13339
|
+
// src/commands/workspaces.ts
|
|
13340
|
+
async function listWorkspaces() {
|
|
13341
|
+
const { api } = await getApi();
|
|
13342
|
+
try {
|
|
13343
|
+
const workspaces = await api.workspace.list();
|
|
13344
|
+
if (isJsonMode()) {
|
|
13345
|
+
printJson({ workspaces: workspaces.map(({ id, name, role }) => ({ id, name, role })) });
|
|
13346
|
+
return;
|
|
13347
|
+
}
|
|
13348
|
+
printLine(
|
|
13349
|
+
formatTable(
|
|
13350
|
+
["NAME", "ROLE", "ID"],
|
|
13351
|
+
workspaces.map((w) => [w.name, w.role, w.id])
|
|
13352
|
+
)
|
|
13353
|
+
);
|
|
13354
|
+
} catch (error2) {
|
|
13355
|
+
failApi(error2);
|
|
13217
13356
|
}
|
|
13218
|
-
printLine(`Moved ${scheduleId} to ${when.toISOString()}`);
|
|
13219
13357
|
}
|
|
13220
13358
|
|
|
13221
13359
|
// src/index.ts
|
|
@@ -13223,7 +13361,7 @@ var program = new Command();
|
|
|
13223
13361
|
program.exitOverride((error2) => {
|
|
13224
13362
|
process.exit(error2.exitCode === 0 ? EXIT.ok : EXIT.usage);
|
|
13225
13363
|
});
|
|
13226
|
-
program.name("postonus").description("Schedule and publish social posts from your terminal").version(CLI_VERSION, "-v, --version").option("--json", "output machine-readable JSON on stdout").option("-q, --quiet", "suppress progress output on stderr").option("--no-color", "disable coloured output").option("--no-input", "never prompt; fail instead of waiting for input").addHelpText(
|
|
13364
|
+
program.name("postonus").description("Schedule and publish social posts from your terminal").version(CLI_VERSION, "-v, --version").option("--json", "output machine-readable JSON on stdout").option("-q, --quiet", "suppress progress output on stderr").option("--no-color", "disable coloured output").option("--no-input", "never prompt; fail instead of waiting for input").option("-w, --workspace <id>", "workspace to act in (from `postonus workspaces list`); sent as x-workspace-id").addHelpText(
|
|
13227
13365
|
"after",
|
|
13228
13366
|
`
|
|
13229
13367
|
Environment:
|
|
@@ -13232,10 +13370,17 @@ Environment:
|
|
|
13232
13370
|
${"EDITOR".padEnd(18)} editor opened by \`post --editor\`
|
|
13233
13371
|
${"NO_COLOR".padEnd(18)} disable coloured output
|
|
13234
13372
|
|
|
13373
|
+
Times are RFC 3339 with an offset: 2026-08-01T09:30:00Z or 2026-08-01T11:30:00+02:00.
|
|
13374
|
+
|
|
13375
|
+
Exit codes:
|
|
13376
|
+
0 ok, 1 other failure, 2 usage or validation, 3 auth, 4 plan or quota, 5 rate limit.
|
|
13377
|
+
With --json a failure prints { code, message, data: { violations } } on stdout.
|
|
13378
|
+
|
|
13235
13379
|
Examples:
|
|
13236
13380
|
$ postonus login
|
|
13237
13381
|
$ postonus post "shipping today" --to x,linkedin --optimal
|
|
13238
13382
|
$ postonus post --file notes.md --to linkedin --at 2026-08-01T09:30:00Z
|
|
13383
|
+
$ postonus post --thread-file thread.md --channel <id> --at 2026-08-01T09:30:00Z --dry-run
|
|
13239
13384
|
$ postonus queue list --json | jq '.queue[].scheduledAt'
|
|
13240
13385
|
$ postonus media upload ./demo.mp4
|
|
13241
13386
|
|
|
@@ -13252,17 +13397,23 @@ program.command("whoami").description("show the signed-in account").action(whoam
|
|
|
13252
13397
|
var channels = program.command("channels").description("manage connected channels");
|
|
13253
13398
|
channels.command("list").alias("ls").description("list connected channels").action(listChannels);
|
|
13254
13399
|
channels.command("connect").description("connect a new channel via OAuth").option("-p, --platform <platform>", "platform to connect (prompts when omitted)").option("--no-wait", "return immediately instead of waiting for approval").action(connectChannel);
|
|
13255
|
-
|
|
13256
|
-
program.command("
|
|
13400
|
+
var collect = (value2, previous = []) => [...previous, value2];
|
|
13401
|
+
var postCommand = program.command("post").description("create a post: scheduled, now, at the next optimal time, or as a draft").argument("[text]", "post content; also accepts piped stdin").option("-t, --to <platforms>", "comma-separated platforms, e.g. x,linkedin").option("-c, --channel <id>", "a channel id from `postonus channels list`; repeatable", collect).option("-a, --at <time>", "RFC 3339 time with an offset").option("-o, --optimal", "the next recommended window").option("--now", "publish as soon as the queue picks it up").option("-d, --draft", "save as a draft without scheduling").option("-f, --file <path>", "read content from a file").option("--thread-file <path>", "read a thread: segments separated by a line of ---").option("-e, --editor", "compose in $EDITOR").option("-m, --media <path...>", "attach local image or video files").option("--copy <channelId=text>", "text that replaces the body on one channel; repeatable", collect).option("--dry-run", "run every server check and show the result without saving").action(post);
|
|
13402
|
+
postCommand.command("edit").description("change a post; only the flags given change").argument("<postId>", "post id from `postonus queue list`").argument("[text]", "new content").option("-t, --to <platforms>", "replace the channels with these platforms").option("-c, --channel <id>", "replace the channels with these ids; repeatable", collect).option("-a, --at <time>", "move every channel to this RFC 3339 time").option("-f, --file <path>", "read new content from a file").option("--thread-file <path>", "replace the body with a thread file").option("-m, --media <path...>", "replace the media with these files").option("--copy <channelId=text>", "replace one channel's copy; repeatable", collect).option("--dry-run", "run every server check and show the result without saving").action(editPost);
|
|
13403
|
+
postCommand.command("delete").description("delete a post and every schedule on it").argument("<postId>", "post id from `postonus queue list`").option("--remote", "also delete published copies on their platforms").action(deletePost);
|
|
13404
|
+
postCommand.command("retry").description("queue a failed schedule to publish again").argument("<scheduleId>", "schedule id from `postonus queue list --status failed`").option("--content <text>", "replacement copy for this channel only").action(retrySchedule);
|
|
13405
|
+
program.command("best-times").description("recommended posting windows for the given platforms").requiredOption("-t, --to <platforms>", "comma-separated platforms, e.g. x,linkedin").option("-n, --count <count>", "how many times to list (1-20)", "5").action(bestTimes);
|
|
13406
|
+
program.command("workspaces").description("workspaces you belong to").command("list").alias("ls").description("list workspaces and their ids").action(listWorkspaces);
|
|
13257
13407
|
var queue = program.command("queue").description("inspect and adjust scheduled posts");
|
|
13258
|
-
queue.command("list").alias("ls").description("list
|
|
13259
|
-
queue.command("schedule").description("give a draft its send time").argument("<postId>", "post id from `postonus queue list --status draft` or `postonus post --draft`").option("-a, --at <time>", "
|
|
13408
|
+
queue.command("list").alias("ls").description("list drafts, scheduled posts and failures").addOption(new Option("-n, --limit <count>", "how many to show (10-100)").default("20")).option("-t, --to <platforms>", "filter by comma-separated platforms").option("-s, --status <statuses>", "filter by comma-separated statuses").action(listQueue);
|
|
13409
|
+
queue.command("schedule").description("give a draft its send time").argument("<postId>", "post id from `postonus queue list --status draft` or `postonus post --draft`").option("-a, --at <time>", "RFC 3339 time with an offset").option("-o, --optimal", "next recommended window").option("--dry-run", "run every server check and show the result without saving").option(
|
|
13260
13410
|
"-c, --channels <ids>",
|
|
13261
13411
|
"comma-separated channel ids from `postonus channels list`; needed if the draft has none"
|
|
13262
13412
|
).action(scheduleDraft);
|
|
13263
|
-
queue.command("move").description("reschedule one queued post").argument("<scheduleId>", "schedule id from `postonus queue list`").requiredOption("-a, --at <time>", "new
|
|
13413
|
+
queue.command("move").description("reschedule one queued post").argument("<scheduleId>", "schedule id from `postonus queue list`").requiredOption("-a, --at <time>", "new RFC 3339 time with an offset").action(moveQueueItem);
|
|
13264
13414
|
var media = program.command("media").description("upload media for use in posts");
|
|
13265
13415
|
media.command("upload").description("upload one or more local files").argument("<paths...>", "local image or video paths").action(uploadCommand);
|
|
13416
|
+
media.command("import").description("import an image or video from a public URL").argument("<url>", "public http(s) URL").action(importCommand);
|
|
13266
13417
|
program.command("mcp").description("serve the Postonus MCP tools over stdio for an editor").action(mcpServe);
|
|
13267
13418
|
try {
|
|
13268
13419
|
await program.parseAsync(process.argv);
|