posterly-mcp-server 0.54.6 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -4
- package/dist/generated/platform-manifest.d.ts +4 -4
- package/dist/generated/platform-manifest.js +9 -4
- package/dist/index.js +15 -2
- package/dist/lib/alias-transport.js +4 -0
- package/dist/lib/api-client.d.ts +148 -0
- package/dist/lib/api-client.js +84 -0
- package/dist/lib/claude-directory-profile.js +3 -1
- package/dist/lib/format.d.ts +44 -0
- package/dist/lib/format.js +125 -5
- package/dist/lib/gbp-location-preview.d.ts +21 -0
- package/dist/lib/gbp-location-preview.js +27 -0
- package/dist/lib/google-business-review-name.d.ts +4 -0
- package/dist/lib/google-business-review-name.js +11 -0
- package/dist/lib/id-schema.d.ts +14 -0
- package/dist/lib/id-schema.js +82 -0
- package/dist/lib/id-text.d.ts +26 -0
- package/dist/lib/id-text.js +63 -0
- package/dist/lib/reply-window.d.ts +5 -0
- package/dist/lib/reply-window.js +14 -0
- package/dist/lib/service-area-text.d.ts +27 -0
- package/dist/lib/service-area-text.js +41 -0
- package/dist/lib/suggestion-accept-note.d.ts +10 -0
- package/dist/lib/suggestion-accept-note.js +17 -0
- package/dist/lib/tool-registry.js +19 -2
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/tools/audit-google-business-profile.js +7 -3
- package/dist/tools/connect-account.d.ts +2 -2
- package/dist/tools/create-connect-session.d.ts +2 -2
- package/dist/tools/create-post.d.ts +6 -6
- package/dist/tools/create-posts-batch.d.ts +4 -4
- package/dist/tools/create-webhook.d.ts +3 -3
- package/dist/tools/delete-post.d.ts +4 -4
- package/dist/tools/dismiss-suggestion.d.ts +7 -0
- package/dist/tools/dismiss-suggestion.js +21 -2
- package/dist/tools/find-slot.js +7 -4
- package/dist/tools/get-post.js +56 -5
- package/dist/tools/list-accounts.d.ts +4 -0
- package/dist/tools/list-accounts.js +25 -6
- package/dist/tools/list-analytics.d.ts +4 -0
- package/dist/tools/list-analytics.js +29 -7
- package/dist/tools/list-comments.js +13 -3
- package/dist/tools/list-conversations.d.ts +4 -4
- package/dist/tools/list-conversations.js +10 -5
- package/dist/tools/list-google-business-locations.d.ts +27 -0
- package/dist/tools/list-google-business-locations.js +35 -0
- package/dist/tools/list-google-business-media.d.ts +8 -0
- package/dist/tools/list-google-business-media.js +19 -5
- package/dist/tools/list-google-business-reviews.js +3 -2
- package/dist/tools/list-google-business-service-areas.d.ts +37 -0
- package/dist/tools/list-google-business-service-areas.js +33 -0
- package/dist/tools/list-media.js +3 -2
- package/dist/tools/list-platforms.d.ts +10 -10
- package/dist/tools/list-post-suggestions.js +5 -4
- package/dist/tools/list-posts.d.ts +8 -2
- package/dist/tools/list-posts.js +12 -2
- package/dist/tools/list-webhooks.d.ts +18 -1
- package/dist/tools/list-webhooks.js +22 -3
- package/dist/tools/list-workspace-members.js +3 -1
- package/dist/tools/manage-brands.d.ts +47 -0
- package/dist/tools/manage-brands.js +89 -0
- package/dist/tools/manage-comment.js +5 -1
- package/dist/tools/manage-google-business-location.d.ts +123 -0
- package/dist/tools/manage-google-business-location.js +97 -0
- package/dist/tools/manage-google-business-media.js +2 -0
- package/dist/tools/manage-google-business-review.js +29 -3
- package/dist/tools/manage-google-business-service-area.d.ts +74 -0
- package/dist/tools/manage-google-business-service-area.js +79 -0
- package/dist/tools/manage-webhook.d.ts +6 -6
- package/dist/tools/manage-x-posting-addon.d.ts +47 -0
- package/dist/tools/manage-x-posting-addon.js +92 -0
- package/dist/tools/trigger-platform-helper.d.ts +5 -5
- package/dist/tools/update-post.d.ts +14 -6
- package/dist/tools/update-post.js +23 -2
- package/dist/tools/upload-media.d.ts +12 -0
- package/dist/tools/upload-media.js +39 -3
- package/dist/tools/validate-post.d.ts +4 -4
- package/dist/tools/webhook-events.d.ts +2 -2
- package/dist/tools/webhook-events.js +2 -0
- package/dist/tools/whoami.d.ts +4 -0
- package/dist/tools/whoami.js +14 -6
- package/package.json +1 -1
- package/server.json +2 -2
- package/tool-annotations.json +21 -2
- package/tool-registry.json +239 -8
package/dist/lib/api-client.js
CHANGED
|
@@ -40,6 +40,10 @@ function postFilterParams(params) {
|
|
|
40
40
|
const searchParams = new URLSearchParams();
|
|
41
41
|
if (params?.status)
|
|
42
42
|
searchParams.set('status', params.status);
|
|
43
|
+
if (params?.group_id)
|
|
44
|
+
searchParams.set('group_id', params.group_id);
|
|
45
|
+
if (params?.release_id)
|
|
46
|
+
searchParams.set('release_id', params.release_id);
|
|
43
47
|
if (params?.platform)
|
|
44
48
|
searchParams.set('platform', params.platform);
|
|
45
49
|
if (params?.account_id)
|
|
@@ -238,6 +242,9 @@ export class PosterlyClient {
|
|
|
238
242
|
async whoami() {
|
|
239
243
|
return this.request('GET', '/whoami');
|
|
240
244
|
}
|
|
245
|
+
async listApiKeys() {
|
|
246
|
+
return this.request('GET', '/api-keys');
|
|
247
|
+
}
|
|
241
248
|
async createApiKey(data) {
|
|
242
249
|
return this.request('POST', '/api-keys', data);
|
|
243
250
|
}
|
|
@@ -324,6 +331,8 @@ export class PosterlyClient {
|
|
|
324
331
|
const searchParams = new URLSearchParams();
|
|
325
332
|
if (params?.workspace_id)
|
|
326
333
|
searchParams.set('workspace_id', params.workspace_id);
|
|
334
|
+
if (params?.connection)
|
|
335
|
+
searchParams.set('connection', params.connection);
|
|
327
336
|
const qs = searchParams.toString();
|
|
328
337
|
const data = await this.request('GET', `/accounts${qs ? `?${qs}` : ''}`);
|
|
329
338
|
return data.accounts;
|
|
@@ -382,6 +391,15 @@ export class PosterlyClient {
|
|
|
382
391
|
async getBrand(id) {
|
|
383
392
|
return this.request('GET', `/brands/${encodeURIComponent(id)}`);
|
|
384
393
|
}
|
|
394
|
+
async createBrand(data) {
|
|
395
|
+
return this.request('POST', '/brands', data);
|
|
396
|
+
}
|
|
397
|
+
async updateBrand(id, data) {
|
|
398
|
+
return this.request('PATCH', `/brands/${encodeURIComponent(id)}`, data);
|
|
399
|
+
}
|
|
400
|
+
async archiveBrand(id, data) {
|
|
401
|
+
return this.request('POST', `/brands/${encodeURIComponent(id)}/archive`, data);
|
|
402
|
+
}
|
|
385
403
|
async listBrandAccounts(id) {
|
|
386
404
|
const data = await this.request('GET', `/brands/${encodeURIComponent(id)}/accounts`);
|
|
387
405
|
return data.accounts;
|
|
@@ -424,6 +442,15 @@ export class PosterlyClient {
|
|
|
424
442
|
async dismissSuggestion(id) {
|
|
425
443
|
return this.request('POST', `/suggestions/${encodeURIComponent(id)}/dismiss`, {});
|
|
426
444
|
}
|
|
445
|
+
async acceptSuggestion(id) {
|
|
446
|
+
return this.request('POST', `/suggestions/${encodeURIComponent(id)}/accept`, {});
|
|
447
|
+
}
|
|
448
|
+
async getMediaAsset(id) {
|
|
449
|
+
return this.request('GET', `/media/${encodeURIComponent(id)}`);
|
|
450
|
+
}
|
|
451
|
+
async deleteMediaAsset(id) {
|
|
452
|
+
return this.request('DELETE', `/media/${encodeURIComponent(id)}`);
|
|
453
|
+
}
|
|
427
454
|
async listPosts(params) {
|
|
428
455
|
const searchParams = postFilterParams(params);
|
|
429
456
|
if (params?.limit)
|
|
@@ -564,6 +591,8 @@ export class PosterlyClient {
|
|
|
564
591
|
searchParams.set('from', params.from);
|
|
565
592
|
if (params.to)
|
|
566
593
|
searchParams.set('to', params.to);
|
|
594
|
+
if (params.include_extras)
|
|
595
|
+
searchParams.set('include', 'extras');
|
|
567
596
|
return this.request('GET', `/analytics/accounts?${searchParams.toString()}`);
|
|
568
597
|
}
|
|
569
598
|
async getPostAnalytics(params) {
|
|
@@ -627,6 +656,29 @@ export class PosterlyClient {
|
|
|
627
656
|
async deleteGoogleBusinessReviewReply(data) {
|
|
628
657
|
return this.request('DELETE', '/google-business/reviews/reply', data);
|
|
629
658
|
}
|
|
659
|
+
async getGoogleBusinessServiceArea(params) {
|
|
660
|
+
const searchParams = new URLSearchParams();
|
|
661
|
+
if (params.workspace_id)
|
|
662
|
+
searchParams.set('workspace_id', params.workspace_id);
|
|
663
|
+
if (params.account_id)
|
|
664
|
+
searchParams.set('account_id', String(params.account_id));
|
|
665
|
+
if (params.location_id)
|
|
666
|
+
searchParams.set('location_id', params.location_id);
|
|
667
|
+
const qs = searchParams.toString();
|
|
668
|
+
return this.request('GET', `/google-business/service-area${qs ? `?${qs}` : ''}`);
|
|
669
|
+
}
|
|
670
|
+
async searchGoogleBusinessServiceAreaPlaces(params) {
|
|
671
|
+
const searchParams = new URLSearchParams();
|
|
672
|
+
if (params.workspace_id)
|
|
673
|
+
searchParams.set('workspace_id', params.workspace_id);
|
|
674
|
+
searchParams.set('q', params.q);
|
|
675
|
+
if (params.region_code)
|
|
676
|
+
searchParams.set('region_code', params.region_code);
|
|
677
|
+
return this.request('GET', `/google-business/service-area/places?${searchParams.toString()}`);
|
|
678
|
+
}
|
|
679
|
+
async updateGoogleBusinessServiceArea(data) {
|
|
680
|
+
return this.request('PATCH', '/google-business/service-area', data);
|
|
681
|
+
}
|
|
630
682
|
async listGoogleBusinessMedia(params) {
|
|
631
683
|
const searchParams = new URLSearchParams();
|
|
632
684
|
if (params?.workspace_id)
|
|
@@ -644,6 +696,23 @@ export class PosterlyClient {
|
|
|
644
696
|
async deleteGoogleBusinessMedia(data) {
|
|
645
697
|
return this.request('DELETE', '/google-business/media', data);
|
|
646
698
|
}
|
|
699
|
+
async listGoogleBusinessLocation(params) {
|
|
700
|
+
const searchParams = new URLSearchParams();
|
|
701
|
+
if (params?.workspace_id)
|
|
702
|
+
searchParams.set('workspace_id', params.workspace_id);
|
|
703
|
+
if (params?.account_id)
|
|
704
|
+
searchParams.set('account_id', String(params.account_id));
|
|
705
|
+
if (params?.location_id)
|
|
706
|
+
searchParams.set('location_id', params.location_id);
|
|
707
|
+
const qs = searchParams.toString();
|
|
708
|
+
return this.request('GET', `/google-business/location${qs ? `?${qs}` : ''}`);
|
|
709
|
+
}
|
|
710
|
+
async updateGoogleBusinessHours(data) {
|
|
711
|
+
return this.request('PATCH', '/google-business/location', { ...data, attributes: undefined, regular_hours: data.regular_hours });
|
|
712
|
+
}
|
|
713
|
+
async updateGoogleBusinessAttributes(data) {
|
|
714
|
+
return this.request('PATCH', '/google-business/location', { ...data, regular_hours: undefined, attributes: data.attributes });
|
|
715
|
+
}
|
|
647
716
|
async listActivity(params) {
|
|
648
717
|
const searchParams = new URLSearchParams();
|
|
649
718
|
if (params?.workspace_id)
|
|
@@ -681,6 +750,15 @@ export class PosterlyClient {
|
|
|
681
750
|
const qs = searchParams.toString();
|
|
682
751
|
return this.request('GET', `/webhooks${qs ? `?${qs}` : ''}`);
|
|
683
752
|
}
|
|
753
|
+
async listWebhookDeliveries(webhookId, params) {
|
|
754
|
+
const searchParams = new URLSearchParams();
|
|
755
|
+
if (params?.limit)
|
|
756
|
+
searchParams.set('limit', String(params.limit));
|
|
757
|
+
if (params?.offset != null)
|
|
758
|
+
searchParams.set('offset', String(params.offset));
|
|
759
|
+
const qs = searchParams.toString();
|
|
760
|
+
return this.request('GET', `/webhooks/${encodeURIComponent(webhookId)}/deliveries${qs ? `?${qs}` : ''}`);
|
|
761
|
+
}
|
|
684
762
|
async createWebhook(data) {
|
|
685
763
|
return this.request('POST', '/webhooks', data);
|
|
686
764
|
}
|
|
@@ -714,6 +792,12 @@ export class PosterlyClient {
|
|
|
714
792
|
async triggerPlatformHelper(data) {
|
|
715
793
|
return this.request('POST', '/platforms/trigger', data);
|
|
716
794
|
}
|
|
795
|
+
async quoteXPostingAddon(data) {
|
|
796
|
+
return this.request('POST', '/subscription/x-posting-addon', { ...data, dry_run: true });
|
|
797
|
+
}
|
|
798
|
+
async buyXPostingAddon(data) {
|
|
799
|
+
return this.request('POST', '/subscription/x-posting-addon', data);
|
|
800
|
+
}
|
|
717
801
|
async getXPostingQuota(params) {
|
|
718
802
|
const searchParams = new URLSearchParams();
|
|
719
803
|
if (params?.workspace_id)
|
|
@@ -38,7 +38,7 @@ const descriptions = {
|
|
|
38
38
|
update_post: 'Edit a draft or scheduled post, change its status, assign release and group identifiers, or manage client approval using the action selector. Published posts cannot be edited.',
|
|
39
39
|
delete_post: 'Delete one draft or scheduled post, or all eligible posts in a selected group using the action selector. Published posts cannot be deleted.',
|
|
40
40
|
get_x_posting_quota: 'Read managed X posting usage, quota, remaining posts, URL restrictions, and existing add-on information.',
|
|
41
|
-
upload_media: 'Upload an existing image or video to posterly storage from a file, base64 content, or a public HTTPS URL. Returns a reusable media URL and does not publish content.',
|
|
41
|
+
upload_media: 'Upload an existing image or video to posterly storage from a file, base64 content, or a public HTTPS URL. Returns a reusable media URL and does not publish content. Pass asset_id to delete one library file: the first request previews it and deletes nothing until that preview is confirmed. A file a post still uses is kept.',
|
|
42
42
|
create_signed_upload: 'Create a signed storage upload URL for an existing large image or video.',
|
|
43
43
|
create_media_drop: 'Create a short-lived browser page for a human to upload existing media without a dashboard login.',
|
|
44
44
|
list_media: 'List uploaded media assets or files uploaded to a selected media-drop session.',
|
|
@@ -49,6 +49,8 @@ const descriptions = {
|
|
|
49
49
|
manage_google_business_review: 'Suggest text replies, publish owner replies, or delete owner replies to Google Business reviews using the action selector. Suggestions do not publish a reply.',
|
|
50
50
|
list_google_business_media: 'Read existing photos and videos in connected Google Business Profile galleries.',
|
|
51
51
|
manage_google_business_media: 'Add an existing photo or video to a Google Business gallery, or delete a gallery item using the action selector.',
|
|
52
|
+
list_google_business_service_areas: 'Read the towns and postcodes a Google Business location serves, or search for a town or postcode to add.',
|
|
53
|
+
manage_google_business_service_area: 'Replace the service areas on a Google Business location using the action selector. Preview then confirm.',
|
|
52
54
|
list_conversations: 'List Instagram or Facebook Page inbox conversations, or read one conversation using the view selector. Requires a Pro plan and posts:read.',
|
|
53
55
|
manage_conversation: 'Reply to an Instagram or Facebook Page inbox conversation, or synchronize supported social inbox data using the action selector. Requires a Pro plan and posts:write.',
|
|
54
56
|
list_comments: 'List Instagram, Facebook Page, Threads, or LinkedIn Page comments, or read one comment using the view selector. Requires a Pro plan and posts:read.',
|
package/dist/lib/format.d.ts
CHANGED
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
import type { Account, LearnedVoice, ListPostsResponse, Post, PostCountsResponse, PostsRangeEcho } from './api-client.js';
|
|
2
|
+
export declare function platformText(value: unknown): string | undefined;
|
|
3
|
+
/** The saved live post id, from the row or the metadata keys publish actually writes. */
|
|
4
|
+
export declare function platformPostIdText(post: {
|
|
5
|
+
platform_post_id?: unknown;
|
|
6
|
+
metadata?: unknown;
|
|
7
|
+
}): string | undefined;
|
|
8
|
+
/** Caller group and release ids already stored on the post. Order is stable and duplicates are dropped. */
|
|
9
|
+
export declare function groupReleaseIds(post: {
|
|
10
|
+
post_group_id?: unknown;
|
|
11
|
+
metadata?: unknown;
|
|
12
|
+
}): string[];
|
|
13
|
+
/** Why a publish failed, when the payload includes it. */
|
|
14
|
+
export declare function postFailureText(post: {
|
|
15
|
+
failure?: unknown;
|
|
16
|
+
publish_error?: unknown;
|
|
17
|
+
error_message?: unknown;
|
|
18
|
+
}): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The live missing-content report: object items, or a post plus ready/next_actions.
|
|
21
|
+
* The older `{ missing: ["media"] }` body (no post) stays on the generic formatter.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isStructuredMissingReport(data: unknown): boolean;
|
|
2
24
|
type CellValue = string | number | boolean | null | undefined;
|
|
3
25
|
export declare const DASHBOARD_CALENDAR_URL: string;
|
|
4
26
|
export declare const DASHBOARD_TABLE_URL: string;
|
|
5
27
|
export declare const DASHBOARD_CONNECT_URL: string;
|
|
28
|
+
/** Assistant label for the coarse account health fields. Empty when the payload has none. */
|
|
29
|
+
export declare function connectionHealthLabel(account: {
|
|
30
|
+
connection_status?: string | null;
|
|
31
|
+
connection_reason?: string | null;
|
|
32
|
+
connection_since?: string | null;
|
|
33
|
+
}): string;
|
|
6
34
|
export declare function formatLocalDateTime(value?: string | null): string;
|
|
35
|
+
/** Account and parent-post fields the inbox already stores on a comment. No posterly post id exists on the row. */
|
|
36
|
+
export declare function inboxCommentContext(comment: unknown): {
|
|
37
|
+
accountId?: string;
|
|
38
|
+
caption?: string;
|
|
39
|
+
link?: string;
|
|
40
|
+
};
|
|
7
41
|
export declare function dashboardUrlForPost(post: Pick<Post, 'id' | 'scheduled_at'>): string;
|
|
8
42
|
export declare function dashboardUrlForPosts(): string;
|
|
9
43
|
export declare function dashboardUrlForPostList(posts: Array<Pick<Post, 'scheduled_at'>>): string;
|
|
@@ -68,6 +102,16 @@ export declare function formatCalendarDay(day: string): string;
|
|
|
68
102
|
* day before); anything else reads as "from X up to Y".
|
|
69
103
|
*/
|
|
70
104
|
export declare function formatPostRange(range: PostListRange): string;
|
|
105
|
+
export type PublicApiKeyRow = {
|
|
106
|
+
id?: string;
|
|
107
|
+
name?: string;
|
|
108
|
+
key_prefix?: string;
|
|
109
|
+
scopes?: string[];
|
|
110
|
+
created_at?: string | null;
|
|
111
|
+
last_used_at?: string | null;
|
|
112
|
+
};
|
|
113
|
+
/** Assistant card for GET /api/v1/api-keys. Prints only the public fields. */
|
|
114
|
+
export declare function formatApiKeyList(keys: PublicApiKeyRow[] | null | undefined): string;
|
|
71
115
|
/** ISO 8601 in UTC to the second ("2026-10-07T07:32:54Z"); "unknown" when missing. */
|
|
72
116
|
export declare function formatIsoTimestamp(value: string | null | undefined): string;
|
|
73
117
|
/** "Georgia via Dashboard"; whichever half was never recorded reads as unknown. */
|
package/dist/lib/format.js
CHANGED
|
@@ -1,14 +1,101 @@
|
|
|
1
|
+
export function platformText(value) {
|
|
2
|
+
if (Array.isArray(value)) {
|
|
3
|
+
const parts = value.map((item) => (item == null ? '' : String(item).trim())).filter(Boolean);
|
|
4
|
+
return parts.length ? parts.join(', ') : undefined;
|
|
5
|
+
}
|
|
6
|
+
if (typeof value === 'string' && value.trim())
|
|
7
|
+
return value.trim();
|
|
8
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
9
|
+
return String(value);
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
function asRecord(value) {
|
|
13
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
14
|
+
}
|
|
15
|
+
function scalarText(value) {
|
|
16
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
17
|
+
return String(value);
|
|
18
|
+
if (typeof value === 'string' && value.trim())
|
|
19
|
+
return value.trim();
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const PLATFORM_POST_ID_KEYS = ['platform_post_id', 'instagram_media_id', 'facebook_post_id', 'x_tweet_id', 'threads_media_id'];
|
|
23
|
+
/** The saved live post id, from the row or the metadata keys publish actually writes. */
|
|
24
|
+
export function platformPostIdText(post) {
|
|
25
|
+
const direct = scalarText(post.platform_post_id);
|
|
26
|
+
if (direct)
|
|
27
|
+
return direct;
|
|
28
|
+
const meta = asRecord(post.metadata);
|
|
29
|
+
for (const key of PLATFORM_POST_ID_KEYS) {
|
|
30
|
+
const value = scalarText(meta[key]);
|
|
31
|
+
if (value)
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
return scalarText(asRecord(meta.bluesky).uri);
|
|
35
|
+
}
|
|
36
|
+
/** Caller group and release ids already stored on the post. Order is stable and duplicates are dropped. */
|
|
37
|
+
export function groupReleaseIds(post) {
|
|
38
|
+
const meta = asRecord(post.metadata);
|
|
39
|
+
const values = [post.post_group_id, meta.post_group_id, meta.api_group_id, meta.group_id, meta.release_id];
|
|
40
|
+
return [...new Set(values.map(scalarText).filter((value) => Boolean(value)))];
|
|
41
|
+
}
|
|
42
|
+
/** Why a publish failed, when the payload includes it. */
|
|
43
|
+
export function postFailureText(post) {
|
|
44
|
+
const failure = asRecord(post.failure);
|
|
45
|
+
const message = scalarText(failure.message) || scalarText(asRecord(post.publish_error).message) || scalarText(post.error_message);
|
|
46
|
+
if (!message)
|
|
47
|
+
return undefined;
|
|
48
|
+
const code = scalarText(failure.code);
|
|
49
|
+
return code && !message.includes(code) ? `${message} (${code})` : message;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The live missing-content report: object items, or a post plus ready/next_actions.
|
|
53
|
+
* The older `{ missing: ["media"] }` body (no post) stays on the generic formatter.
|
|
54
|
+
*/
|
|
55
|
+
export function isStructuredMissingReport(data) {
|
|
56
|
+
if (!data || typeof data !== 'object')
|
|
57
|
+
return false;
|
|
58
|
+
const body = data;
|
|
59
|
+
if (!Array.isArray(body.missing))
|
|
60
|
+
return false;
|
|
61
|
+
if (body.missing.some((item) => item && typeof item === 'object'))
|
|
62
|
+
return true;
|
|
63
|
+
return Boolean(body.post) && ('ready' in body || Array.isArray(body.next_actions));
|
|
64
|
+
}
|
|
1
65
|
const POSTERLY_APP_URL = (process.env.POSTERLY_URL || 'https://www.poster.ly').replace(/\/$/, '');
|
|
2
66
|
export const DASHBOARD_CALENDAR_URL = `${POSTERLY_APP_URL}/dashboard/calendar`;
|
|
3
67
|
export const DASHBOARD_TABLE_URL = `${POSTERLY_APP_URL}/dashboard/table`;
|
|
4
68
|
export const DASHBOARD_CONNECT_URL = `${POSTERLY_APP_URL}/dashboard/connect`;
|
|
69
|
+
/** Assistant label for the coarse account health fields. Empty when the payload has none. */
|
|
70
|
+
export function connectionHealthLabel(account) {
|
|
71
|
+
if (account.connection_status === 'needs_reconnect') {
|
|
72
|
+
const reason = account.connection_reason === 'access_token_expired'
|
|
73
|
+
? 'access token expired'
|
|
74
|
+
: 'reconnect required';
|
|
75
|
+
const since = account.connection_since ? ` since ${account.connection_since}` : '';
|
|
76
|
+
return `needs reconnect (${reason}${since})`;
|
|
77
|
+
}
|
|
78
|
+
if (account.connection_status === 'ok')
|
|
79
|
+
return 'ok';
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
5
82
|
export function formatLocalDateTime(value) {
|
|
6
83
|
if (!value)
|
|
7
84
|
return 'N/A';
|
|
8
85
|
const date = new Date(value);
|
|
9
86
|
if (Number.isNaN(date.getTime()))
|
|
10
87
|
return value;
|
|
11
|
-
return
|
|
88
|
+
return formatIsoTimestamp(value);
|
|
89
|
+
}
|
|
90
|
+
/** Account and parent-post fields the inbox already stores on a comment. No posterly post id exists on the row. */
|
|
91
|
+
export function inboxCommentContext(comment) {
|
|
92
|
+
const row = comment && typeof comment === 'object' ? comment : {};
|
|
93
|
+
const rawId = row.social_account_id;
|
|
94
|
+
const accountId = rawId != null && rawId !== '' ? String(rawId) : undefined;
|
|
95
|
+
const preview = row.post_preview && typeof row.post_preview === 'object' ? row.post_preview : null;
|
|
96
|
+
const caption = typeof preview?.caption === 'string' ? preview.caption.replace(/\s+/g, ' ').trim() : '';
|
|
97
|
+
const link = typeof preview?.permalink === 'string' ? preview.permalink.trim() : '';
|
|
98
|
+
return { accountId, caption: caption || undefined, link: link || undefined };
|
|
12
99
|
}
|
|
13
100
|
export function dashboardUrlForPost(post) {
|
|
14
101
|
const baseUrl = isInCurrentMonth(post.scheduled_at) ? DASHBOARD_CALENDAR_URL : DASHBOARD_TABLE_URL;
|
|
@@ -117,7 +204,7 @@ export function formatDateTime(value) {
|
|
|
117
204
|
const date = new Date(value);
|
|
118
205
|
if (Number.isNaN(date.getTime()))
|
|
119
206
|
return value;
|
|
120
|
-
return
|
|
207
|
+
return formatIsoTimestamp(value);
|
|
121
208
|
}
|
|
122
209
|
export function formatDate(value) {
|
|
123
210
|
if (!value)
|
|
@@ -203,8 +290,20 @@ export function statusLabel(status) {
|
|
|
203
290
|
return `⏸️ ${status}`;
|
|
204
291
|
return status || 'unknown';
|
|
205
292
|
}
|
|
293
|
+
const GROUPED_INTEGER = /^[+-]?\d{1,3}(?:,\d{3})+$/;
|
|
294
|
+
/** Plain digits for an id, or null when code() should use the normal cell formatter. Keep in step with id-text.ts. */
|
|
295
|
+
function idCodeText(value) {
|
|
296
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
297
|
+
return String(value);
|
|
298
|
+
if (typeof value === 'string' && GROUPED_INTEGER.test(value.trim()))
|
|
299
|
+
return value.trim().replace(/,/g, '');
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
206
302
|
export function code(value) {
|
|
207
|
-
|
|
303
|
+
// Ids stay plain digits. formatCell would print 1961 as "1,961", which is
|
|
304
|
+
// not a valid id to paste back into another tool. Metrics do not use code().
|
|
305
|
+
const text = idCodeText(value) ?? formatCell(value);
|
|
306
|
+
return `\`${text.replace(/`/g, '\\`')}\``;
|
|
208
307
|
}
|
|
209
308
|
function formatCell(value) {
|
|
210
309
|
if (value === null || value === undefined || value === '')
|
|
@@ -304,6 +403,25 @@ export function formatPostRange(range) {
|
|
|
304
403
|
const to = range.to ? `up to ${formatDateTimeInZone(range.to, tz)}` : '';
|
|
305
404
|
return `${[from, to].filter(Boolean).join(' ')} (${tz})`;
|
|
306
405
|
}
|
|
406
|
+
/** Assistant card for GET /api/v1/api-keys. Prints only the public fields. */
|
|
407
|
+
export function formatApiKeyList(keys) {
|
|
408
|
+
const rows = Array.isArray(keys) ? keys : [];
|
|
409
|
+
const table = rows.length
|
|
410
|
+
? mdTable(['Name', 'Prefix', 'Scopes', 'Created', 'Last used', 'Key ID'], rows.map((key) => [
|
|
411
|
+
key.name || 'unnamed',
|
|
412
|
+
key.key_prefix || 'n/a',
|
|
413
|
+
key.scopes?.length ? key.scopes.join(', ') : 'none',
|
|
414
|
+
key.created_at ? formatIsoTimestamp(key.created_at) : 'unknown',
|
|
415
|
+
key.last_used_at ? formatIsoTimestamp(key.last_used_at) : 'never',
|
|
416
|
+
code(String(key.id || '')),
|
|
417
|
+
]))
|
|
418
|
+
: 'No API keys on this account.';
|
|
419
|
+
return [
|
|
420
|
+
mdTitle('API keys'),
|
|
421
|
+
table,
|
|
422
|
+
'The secret is never listed. Revoke one with delete_api_key. That tool refuses to revoke the key making the call.',
|
|
423
|
+
].join('\n\n');
|
|
424
|
+
}
|
|
307
425
|
/** ISO 8601 in UTC to the second ("2026-10-07T07:32:54Z"); "unknown" when missing. */
|
|
308
426
|
export function formatIsoTimestamp(value) {
|
|
309
427
|
if (!value)
|
|
@@ -361,7 +479,8 @@ export function formatPostListPage(data, options) {
|
|
|
361
479
|
: first === 1
|
|
362
480
|
? `**Complete: all ${total} matching posts are shown.**`
|
|
363
481
|
: `**Complete: this is the last page (posts ${first}-${last} of ${total}).**`;
|
|
364
|
-
const
|
|
482
|
+
const showPlatform = posts.some((post) => platformText(post.platform));
|
|
483
|
+
const table = mdTable(['Status', 'Post ID', `Scheduled (${tz})`, 'Type', ...(showPlatform ? ['Platform'] : []), 'Account ID', 'Brand ID', 'Approval', 'Created', 'Created by', 'Caption'],
|
|
365
484
|
// The API post row carries account and brand IDs only (no joined names);
|
|
366
485
|
// list_accounts and list_brands, or view=counts, resolve them.
|
|
367
486
|
posts.map((post) => [
|
|
@@ -369,6 +488,7 @@ export function formatPostListPage(data, options) {
|
|
|
369
488
|
code(String(post.id)),
|
|
370
489
|
formatDateTimeInZone(post.scheduled_at, tz),
|
|
371
490
|
post.post_type || 'post',
|
|
491
|
+
...(showPlatform ? [platformText(post.platform) || 'n/a'] : []),
|
|
372
492
|
post.social_account_id != null ? String(post.social_account_id) : 'n/a',
|
|
373
493
|
post.brand_id || 'none',
|
|
374
494
|
approvalCell(post),
|
|
@@ -402,7 +522,7 @@ export function formatPostCounts(data) {
|
|
|
402
522
|
mdSection('By account', mdTable(['Account', 'Platform', 'Account ID', 'Posts'], (data.by_account || []).map((row) => [
|
|
403
523
|
row.username ? `@${row.username}` : row.account_id ? 'unknown account' : 'no account',
|
|
404
524
|
row.platform || 'n/a',
|
|
405
|
-
row.account_id
|
|
525
|
+
row.account_id != null && row.account_id !== '' ? String(row.account_id) : 'none',
|
|
406
526
|
row.count,
|
|
407
527
|
]))),
|
|
408
528
|
mdSection('By brand', mdTable(['Brand', 'Brand ID', 'Posts'], (data.by_brand || []).map((row) => [row.name || (row.brand_id ? 'unknown brand' : 'no brand'), row.brand_id ?? 'none', row.count]))),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preview text for Google Business location edits, shared by the hosted and
|
|
3
|
+
* npm MCP servers. An hours or attribute edit replaces what is on the public
|
|
4
|
+
* profile, so the preview lists what is there now next to what will be set.
|
|
5
|
+
*/
|
|
6
|
+
export type GbpPreviewPeriod = {
|
|
7
|
+
open_day?: unknown;
|
|
8
|
+
open_time?: unknown;
|
|
9
|
+
close_day?: unknown;
|
|
10
|
+
close_time?: unknown;
|
|
11
|
+
};
|
|
12
|
+
export type GbpPreviewAttribute = {
|
|
13
|
+
name?: unknown;
|
|
14
|
+
value_type?: unknown;
|
|
15
|
+
values?: unknown;
|
|
16
|
+
};
|
|
17
|
+
export declare const GBP_CLOSED_DAYS_NOTE = "A day with no opening period shows as closed on Google.";
|
|
18
|
+
export declare function gbpPeriodLines(periods: GbpPreviewPeriod[] | null | undefined, empty: string): string;
|
|
19
|
+
export declare function gbpAttributeLines(attributes: GbpPreviewAttribute[] | null | undefined, empty: string): string;
|
|
20
|
+
/** The current values of only the attributes this edit names. */
|
|
21
|
+
export declare function gbpCurrentAttributesFor(current: GbpPreviewAttribute[] | null | undefined, requested: GbpPreviewAttribute[] | null | undefined): GbpPreviewAttribute[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preview text for Google Business location edits, shared by the hosted and
|
|
3
|
+
* npm MCP servers. An hours or attribute edit replaces what is on the public
|
|
4
|
+
* profile, so the preview lists what is there now next to what will be set.
|
|
5
|
+
*/
|
|
6
|
+
export const GBP_CLOSED_DAYS_NOTE = 'A day with no opening period shows as closed on Google.';
|
|
7
|
+
export function gbpPeriodLines(periods, empty) {
|
|
8
|
+
const rows = Array.isArray(periods) ? periods : [];
|
|
9
|
+
if (!rows.length)
|
|
10
|
+
return empty;
|
|
11
|
+
return rows
|
|
12
|
+
.map((period) => `- ${String(period?.open_day ?? '?')} ${String(period?.open_time ?? '?')} to ${String(period?.close_day ?? '?')} ${String(period?.close_time ?? '?')}`)
|
|
13
|
+
.join('\n');
|
|
14
|
+
}
|
|
15
|
+
export function gbpAttributeLines(attributes, empty) {
|
|
16
|
+
const rows = Array.isArray(attributes) ? attributes : [];
|
|
17
|
+
if (!rows.length)
|
|
18
|
+
return empty;
|
|
19
|
+
return rows
|
|
20
|
+
.map((attribute) => `- ${String(attribute?.name ?? '?')} (${String(attribute?.value_type ?? '?')}): ${Array.isArray(attribute?.values) ? attribute.values.join(', ') : ''}`)
|
|
21
|
+
.join('\n');
|
|
22
|
+
}
|
|
23
|
+
/** The current values of only the attributes this edit names. */
|
|
24
|
+
export function gbpCurrentAttributesFor(current, requested) {
|
|
25
|
+
const names = new Set((Array.isArray(requested) ? requested : []).map((attribute) => String(attribute?.name ?? '')));
|
|
26
|
+
return (Array.isArray(current) ? current : []).filter((attribute) => names.has(String(attribute?.name ?? '')));
|
|
27
|
+
}
|
|
@@ -25,6 +25,10 @@ export declare function googleBusinessReviewResourceName(params: {
|
|
|
25
25
|
accountName?: string | null;
|
|
26
26
|
locationName?: string | null;
|
|
27
27
|
}): string | null;
|
|
28
|
+
/** Owner reply text, when Google sent one. Whitespace is collapsed for a single cell. */
|
|
29
|
+
export declare function reviewReplyComment(review: {
|
|
30
|
+
reviewReply?: unknown;
|
|
31
|
+
} | null | undefined): string | null;
|
|
28
32
|
/** review_name a formatted list row can show, from the fields a list response carries. */
|
|
29
33
|
export declare function reviewNameFromListItem(review: {
|
|
30
34
|
review_name?: unknown;
|
|
@@ -61,6 +61,17 @@ export function googleBusinessReviewResourceName(params) {
|
|
|
61
61
|
const built = `${accountName}/${locationName}/reviews/${reviewId}`;
|
|
62
62
|
return isGoogleBusinessReviewResourceName(built) ? built : null;
|
|
63
63
|
}
|
|
64
|
+
/** Owner reply text, when Google sent one. Whitespace is collapsed for a single cell. */
|
|
65
|
+
export function reviewReplyComment(review) {
|
|
66
|
+
const reply = review?.reviewReply;
|
|
67
|
+
const raw = typeof reply === 'string'
|
|
68
|
+
? reply
|
|
69
|
+
: reply && typeof reply === 'object'
|
|
70
|
+
? reply.comment || reply.text
|
|
71
|
+
: '';
|
|
72
|
+
const text = String(raw || '').replace(/\s+/g, ' ').trim();
|
|
73
|
+
return text || null;
|
|
74
|
+
}
|
|
64
75
|
/** review_name a formatted list row can show, from the fields a list response carries. */
|
|
65
76
|
export function reviewNameFromListItem(review) {
|
|
66
77
|
if (!review || typeof review !== 'object')
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* npm tool schemas are zod, and a z.number() id rejects both "1961" and
|
|
3
|
+
* "1,961", while a z.string() id rejects the number 1961. Agents copy ids
|
|
4
|
+
* from either shape. Loosen id fields only: counts, limits, and ratings
|
|
5
|
+
* stay strict.
|
|
6
|
+
*/
|
|
7
|
+
import { type ZodTypeAny } from 'zod';
|
|
8
|
+
/** Accept a number or a digit string (with or without thousands separators) for one id schema. */
|
|
9
|
+
export declare function loosenIdSchema(schema: ZodTypeAny): ZodTypeAny;
|
|
10
|
+
export declare function loosenIdShape(shape: Record<string, ZodTypeAny>): Record<string, ZodTypeAny>;
|
|
11
|
+
/** Used by scripts/test-mcp-plain-ids.ts so the assertion shares this file's zod. */
|
|
12
|
+
export declare function parseFlexibleId(kind: 'number' | 'string', value: unknown): unknown;
|
|
13
|
+
/** Same loosening for an alias's old object schema, so a pasted id still validates. */
|
|
14
|
+
export declare function loosenIdObject(schema: ZodTypeAny): ZodTypeAny;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* npm tool schemas are zod, and a z.number() id rejects both "1961" and
|
|
3
|
+
* "1,961", while a z.string() id rejects the number 1961. Agents copy ids
|
|
4
|
+
* from either shape. Loosen id fields only: counts, limits, and ratings
|
|
5
|
+
* stay strict.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { isIdParamName, stripGroupedInteger } from './id-text.js';
|
|
9
|
+
const PLAIN_INTEGER = /^[+-]?\d+$/;
|
|
10
|
+
function coerceIdInput(value, expect) {
|
|
11
|
+
if (expect === 'number') {
|
|
12
|
+
if (typeof value === 'string') {
|
|
13
|
+
const stripped = stripGroupedInteger(value).trim();
|
|
14
|
+
if (PLAIN_INTEGER.test(stripped)) {
|
|
15
|
+
const n = Number(stripped);
|
|
16
|
+
if (Number.isSafeInteger(n))
|
|
17
|
+
return n;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
23
|
+
return String(value);
|
|
24
|
+
if (typeof value === 'string')
|
|
25
|
+
return stripGroupedInteger(value);
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
function withDescription(schema, description) {
|
|
29
|
+
if (!description || schema.description === description)
|
|
30
|
+
return schema;
|
|
31
|
+
return schema.describe(description);
|
|
32
|
+
}
|
|
33
|
+
/** Accept a number or a digit string (with or without thousands separators) for one id schema. */
|
|
34
|
+
export function loosenIdSchema(schema) {
|
|
35
|
+
const description = schema.description;
|
|
36
|
+
let next = schema;
|
|
37
|
+
if (schema instanceof z.ZodOptional) {
|
|
38
|
+
next = loosenIdSchema(schema.unwrap()).optional();
|
|
39
|
+
}
|
|
40
|
+
else if (schema instanceof z.ZodNullable) {
|
|
41
|
+
next = loosenIdSchema(schema.unwrap()).nullable();
|
|
42
|
+
}
|
|
43
|
+
else if (schema instanceof z.ZodDefault) {
|
|
44
|
+
const fallback = schema._def.defaultValue;
|
|
45
|
+
next = loosenIdSchema(schema.removeDefault()).default(typeof fallback === 'function' ? fallback() : fallback);
|
|
46
|
+
}
|
|
47
|
+
else if (schema instanceof z.ZodNumber) {
|
|
48
|
+
next = z.preprocess((value) => coerceIdInput(value, 'number'), schema);
|
|
49
|
+
}
|
|
50
|
+
else if (schema instanceof z.ZodString) {
|
|
51
|
+
next = z.preprocess((value) => coerceIdInput(value, 'string'), schema);
|
|
52
|
+
}
|
|
53
|
+
else if (schema instanceof z.ZodUnion) {
|
|
54
|
+
next = z.preprocess((value) => (typeof value === 'string' ? stripGroupedInteger(value) : value), schema);
|
|
55
|
+
}
|
|
56
|
+
else if (schema instanceof z.ZodArray) {
|
|
57
|
+
// Keep the original def so .min()/.max() limits survive the loosening.
|
|
58
|
+
next = new z.ZodArray({ ...schema._def, type: loosenIdSchema(schema.element) });
|
|
59
|
+
}
|
|
60
|
+
return withDescription(next, description);
|
|
61
|
+
}
|
|
62
|
+
export function loosenIdShape(shape) {
|
|
63
|
+
const out = {};
|
|
64
|
+
for (const [key, schema] of Object.entries(shape)) {
|
|
65
|
+
out[key] = isIdParamName(key) ? loosenIdSchema(schema) : schema;
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
/** Used by scripts/test-mcp-plain-ids.ts so the assertion shares this file's zod. */
|
|
70
|
+
export function parseFlexibleId(kind, value) {
|
|
71
|
+
const schema = kind === 'number'
|
|
72
|
+
? loosenIdSchema(z.number().int().positive())
|
|
73
|
+
: loosenIdSchema(z.string());
|
|
74
|
+
return schema.parse(value);
|
|
75
|
+
}
|
|
76
|
+
/** Same loosening for an alias's old object schema, so a pasted id still validates. */
|
|
77
|
+
export function loosenIdObject(schema) {
|
|
78
|
+
if (!(schema instanceof z.ZodObject))
|
|
79
|
+
return schema;
|
|
80
|
+
const shape = schema.shape;
|
|
81
|
+
return schema.extend(loosenIdShape(shape));
|
|
82
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifiers must round-trip. A numeric id printed with a thousands
|
|
3
|
+
* separator ("1,961") is not the same id when an agent pastes it back, and
|
|
4
|
+
* list or validate calls then miss the account or post with no useful error.
|
|
5
|
+
*
|
|
6
|
+
* Counts and metrics stay on the cell formatter (toLocaleString). Only
|
|
7
|
+
* values that are ids, or strings that are nothing but a grouped integer,
|
|
8
|
+
* use these helpers.
|
|
9
|
+
*/
|
|
10
|
+
/** True for account_id, post_id, account_ids, preview_id, and the same shape. */
|
|
11
|
+
export declare function isIdParamName(name: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* "1,961" becomes "1961". Any other string, including UUIDs and resource
|
|
14
|
+
* names, is returned unchanged.
|
|
15
|
+
*/
|
|
16
|
+
export declare function stripGroupedInteger(value: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Digits to put inside backticks for an id, or null when the value is not
|
|
19
|
+
* an id-shaped number or grouped integer (the caller keeps its own formatter).
|
|
20
|
+
*/
|
|
21
|
+
export declare function idCodeText(value: unknown): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Rewrites id arguments so a pasted "1,961" is the digits "1961".
|
|
24
|
+
* Numbers stay numbers. Non-id strings are left alone.
|
|
25
|
+
*/
|
|
26
|
+
export declare function normalizeIdArgs<T>(args: T): T;
|