ad2app-lib 1.0.11 → 1.1.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.
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Scheduling domain — Connected Account DTOs
3
+ *
4
+ * Represents a social-media account that a user has connected via OAuth
5
+ * through the Late API integration layer.
6
+ */
7
+
8
+ // ── SchedulingConnectedAccountDTO ────────────────────────────────────────────
9
+
10
+ /**
11
+ * Response DTO for a single connected social account.
12
+ * Returned in list form by GET /social/accounts.
13
+ */
14
+ export class SchedulingConnectedAccountDTO {
15
+ /** Internal (Late) account identifier */
16
+ id: string;
17
+ platform: string;
18
+ username: string;
19
+ display_name?: string;
20
+ avatar_url?: string;
21
+
22
+ constructor(data: SchedulingConnectedAccountDTO) {
23
+ this.id = data.id;
24
+ this.platform = data.platform;
25
+ this.username = data.username;
26
+ this.display_name = data.display_name;
27
+ this.avatar_url = data.avatar_url;
28
+ }
29
+ }
30
+
31
+ // ── SchedulingConnectAccountResultDTO ────────────────────────────────────────
32
+
33
+ /**
34
+ * Response DTO returned after initiating an OAuth account connection.
35
+ * The client should redirect the user to the returned URL.
36
+ */
37
+ export class SchedulingConnectAccountResultDTO {
38
+ /** OAuth redirect URL the client must navigate to */
39
+ url: string;
40
+ platform: string;
41
+
42
+ constructor(data: SchedulingConnectAccountResultDTO) {
43
+ this.url = data.url;
44
+ this.platform = data.platform;
45
+ }
46
+ }
47
+
48
+ // ── SchedulingPinterestBoardDTO ───────────────────────────────────────────────
49
+
50
+ /**
51
+ * A Pinterest board that the connected account has access to.
52
+ * Returned by GET /social/accounts/pinterest-boards.
53
+ */
54
+ export class SchedulingPinterestBoardDTO {
55
+ id: string;
56
+ name: string;
57
+
58
+ constructor(data: SchedulingPinterestBoardDTO) {
59
+ this.id = data.id;
60
+ this.name = data.name;
61
+ }
62
+ }
63
+
64
+ // ── SchedulingAccountFollowerStatDTO ─────────────────────────────────────────
65
+
66
+ /**
67
+ * Latest follower count for a single platform.
68
+ * Returned by GET /social/accounts/follower-stats.
69
+ */
70
+ export class SchedulingAccountFollowerStatDTO {
71
+ platform: string;
72
+ followers: number;
73
+ date: string;
74
+
75
+ constructor(data: SchedulingAccountFollowerStatDTO) {
76
+ this.platform = data.platform;
77
+ this.followers = data.followers;
78
+ this.date = data.date;
79
+ }
80
+ }
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Scheduling domain — Inbox DTOs
3
+ *
4
+ * Covers direct-message conversations and post comments received through
5
+ * the connected social accounts.
6
+ */
7
+
8
+ // ── SchedulingInboxConversationDTO ────────────────────────────────────────────
9
+
10
+ /**
11
+ * A DM conversation (thread) entry.
12
+ * Returned by GET /social/inbox/messages.
13
+ */
14
+ export class SchedulingInboxConversationDTO {
15
+ id: string;
16
+ platform: string;
17
+ accountId: string;
18
+ senderId: string;
19
+ senderName: string;
20
+ senderAvatarUrl?: string;
21
+ snippet: string;
22
+ receivedAt: string;
23
+ isUnread: boolean;
24
+
25
+ constructor(data: SchedulingInboxConversationDTO) {
26
+ this.id = data.id;
27
+ this.platform = data.platform;
28
+ this.accountId = data.accountId;
29
+ this.senderId = data.senderId;
30
+ this.senderName = data.senderName;
31
+ this.senderAvatarUrl = data.senderAvatarUrl;
32
+ this.snippet = data.snippet;
33
+ this.receivedAt = data.receivedAt;
34
+ this.isUnread = data.isUnread;
35
+ }
36
+ }
37
+
38
+ // ── SchedulingInboxPostWithCommentsDTO ────────────────────────────────────────
39
+
40
+ /**
41
+ * A published post that has comments attached.
42
+ * Returned by GET /social/inbox/comments.
43
+ */
44
+ export class SchedulingInboxPostWithCommentsDTO {
45
+ postId: string;
46
+ platform: string;
47
+ accountId: string;
48
+ contentSnippet: string;
49
+ publishedAt: string;
50
+ commentCount: number;
51
+ thumbnailUrl?: string;
52
+
53
+ constructor(data: SchedulingInboxPostWithCommentsDTO) {
54
+ this.postId = data.postId;
55
+ this.platform = data.platform;
56
+ this.accountId = data.accountId;
57
+ this.contentSnippet = data.contentSnippet;
58
+ this.publishedAt = data.publishedAt;
59
+ this.commentCount = data.commentCount;
60
+ this.thumbnailUrl = data.thumbnailUrl;
61
+ }
62
+ }
63
+
64
+ // ── SchedulingInboxCommentDTO ─────────────────────────────────────────────────
65
+
66
+ /**
67
+ * A single comment (or nested reply) on a post.
68
+ * Returned by GET /social/inbox/comments/:postId/thread.
69
+ */
70
+ export class SchedulingInboxCommentDTO {
71
+ id: string;
72
+ authorName: string;
73
+ authorAvatarUrl?: string;
74
+ text: string;
75
+ createdAt: string;
76
+ replies?: SchedulingInboxCommentDTO[];
77
+
78
+ constructor(data: SchedulingInboxCommentDTO) {
79
+ this.id = data.id;
80
+ this.authorName = data.authorName;
81
+ this.authorAvatarUrl = data.authorAvatarUrl;
82
+ this.text = data.text;
83
+ this.createdAt = data.createdAt;
84
+ this.replies = data.replies;
85
+ }
86
+ }
87
+
88
+ // ── SchedulingSendMessageDTO ──────────────────────────────────────────────────
89
+
90
+ /** Input DTO for sending a DM reply. */
91
+ export class SchedulingSendMessageDTO {
92
+ accountId: string;
93
+ conversationId: string;
94
+ text: string;
95
+
96
+ constructor(data: SchedulingSendMessageDTO) {
97
+ this.accountId = data.accountId;
98
+ this.conversationId = data.conversationId;
99
+ this.text = data.text;
100
+ }
101
+ }
102
+
103
+ // ── SchedulingReplyToCommentDTO ───────────────────────────────────────────────
104
+
105
+ /** Input DTO for replying to a comment. */
106
+ export class SchedulingReplyToCommentDTO {
107
+ postId: string;
108
+ accountId: string;
109
+ text: string;
110
+ commentId?: string;
111
+
112
+ constructor(data: SchedulingReplyToCommentDTO) {
113
+ this.postId = data.postId;
114
+ this.accountId = data.accountId;
115
+ this.text = data.text;
116
+ this.commentId = data.commentId;
117
+ }
118
+ }
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Scheduling domain — Post / Content DTOs
3
+ *
4
+ * Covers content creation, scheduling metadata, per-platform status,
5
+ * and the media items attached to a post.
6
+ */
7
+
8
+ // ── Enums ─────────────────────────────────────────────────────────────────────
9
+
10
+ export enum SchedulingPostStatus {
11
+ DRAFT = 'draft',
12
+ SCHEDULED = 'scheduled',
13
+ PUBLISHED = 'published',
14
+ FAILED = 'failed',
15
+ PARTIAL = 'partial',
16
+ }
17
+
18
+ // ── Platform-status map ───────────────────────────────────────────────────────
19
+
20
+ export type SchedulingPlatformStatusMap = Record<
21
+ string,
22
+ 'scheduled' | 'published' | 'failed'
23
+ >;
24
+
25
+ // ── SchedulingPlatformTargetDTO ───────────────────────────────────────────────
26
+
27
+ export class SchedulingPlatformTargetDTO {
28
+ platform: string;
29
+ accountId: string;
30
+
31
+ constructor(data?: Partial<SchedulingPlatformTargetDTO>) {
32
+ if (!data) return;
33
+ this.platform = data.platform;
34
+ this.accountId = data.accountId;
35
+ }
36
+ }
37
+
38
+ // ── SchedulingMediaItemDTO ────────────────────────────────────────────────────
39
+
40
+ export class SchedulingMediaItemDTO {
41
+ type: 'image' | 'video';
42
+ url: string;
43
+
44
+ constructor(data?: Partial<SchedulingMediaItemDTO>) {
45
+ if (!data) return;
46
+ this.type = data.type;
47
+ this.url = data.url;
48
+ }
49
+ }
50
+
51
+ // ── SchedulingCreatePostDTO ───────────────────────────────────────────────────
52
+
53
+ /** Input DTO for creating a new scheduled or immediate post. */
54
+ export class SchedulingCreatePostDTO {
55
+ content: string;
56
+ platforms: SchedulingPlatformTargetDTO[];
57
+ scheduledAt?: string;
58
+ publishNow?: boolean;
59
+ mediaItems?: SchedulingMediaItemDTO[];
60
+ platformSpecificData?: Record<string, Record<string, unknown>>;
61
+
62
+ constructor(data?: Partial<SchedulingCreatePostDTO>) {
63
+ if (!data) return;
64
+ this.content = data.content;
65
+ this.platforms = data.platforms;
66
+ this.scheduledAt = data.scheduledAt;
67
+ this.publishNow = data.publishNow;
68
+ this.mediaItems = data.mediaItems;
69
+ this.platformSpecificData = data.platformSpecificData;
70
+ }
71
+ }
72
+
73
+ // ── SchedulingUpdatePostDTO ───────────────────────────────────────────────────
74
+
75
+ /** Input DTO for updating an existing post's content or scheduled time. */
76
+ export class SchedulingUpdatePostDTO {
77
+ content?: string;
78
+ scheduledAt?: string;
79
+
80
+ constructor(data?: Partial<SchedulingUpdatePostDTO>) {
81
+ if (!data) return;
82
+ this.content = data.content;
83
+ this.scheduledAt = data.scheduledAt;
84
+ }
85
+ }
86
+
87
+ // ── SchedulingPostDTO ─────────────────────────────────────────────────────────
88
+
89
+ /** Response DTO representing a single post returned from the API. */
90
+ export class SchedulingPostDTO {
91
+ id: string;
92
+ latePostId?: string;
93
+ platforms: string[];
94
+ platformStatuses: SchedulingPlatformStatusMap;
95
+ /** Per-platform URLs to the published post (e.g. { instagram: 'https://...' }). */
96
+ postUrls?: Record<string, string>;
97
+ scheduledAt?: string;
98
+ publishedAt?: string;
99
+ status: SchedulingPostStatus;
100
+ contentSnippet?: string;
101
+ createdAt: string;
102
+ updatedAt: string;
103
+
104
+ constructor(data: SchedulingPostDTO) {
105
+ this.id = data.id;
106
+ this.latePostId = data.latePostId;
107
+ this.platforms = data.platforms;
108
+ this.platformStatuses = data.platformStatuses;
109
+ this.postUrls = data.postUrls;
110
+ this.scheduledAt = data.scheduledAt;
111
+ this.publishedAt = data.publishedAt;
112
+ this.status = data.status;
113
+ this.contentSnippet = data.contentSnippet;
114
+ this.createdAt = data.createdAt;
115
+ this.updatedAt = data.updatedAt;
116
+ }
117
+ }
118
+
119
+ // ── SchedulingPostListParamsDTO ───────────────────────────────────────────────
120
+
121
+ /** Query parameters for listing posts with optional filters. */
122
+ export class SchedulingPostListParamsDTO {
123
+ fromDate?: string;
124
+ toDate?: string;
125
+ status?: string;
126
+ limit?: number;
127
+ offset?: number;
128
+
129
+ constructor(data: SchedulingPostListParamsDTO) {
130
+ this.fromDate = data.fromDate;
131
+ this.toDate = data.toDate;
132
+ this.status = data.status;
133
+ this.limit = data.limit;
134
+ this.offset = data.offset;
135
+ }
136
+ }
137
+
138
+ // ── SchedulingContentCalendarDTO ─────────────────────────────────────────────
139
+
140
+ /**
141
+ * Response DTO for the content calendar view.
142
+ * Groups posts by ISO date string for visual rendering.
143
+ */
144
+ export class SchedulingContentCalendarDTO {
145
+ /** ISO date → posts scheduled on that date */
146
+ postsByDate: Record<string, SchedulingPostDTO[]>;
147
+ /** ISO range covered by the calendar view */
148
+ fromDate: string;
149
+ toDate: string;
150
+
151
+ constructor(data: SchedulingContentCalendarDTO) {
152
+ this.postsByDate = data.postsByDate;
153
+ this.fromDate = data.fromDate;
154
+ this.toDate = data.toDate;
155
+ }
156
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Scheduling domain — Pro Upgrade / Subscription DTOs
3
+ *
4
+ * Covers subscription tier state, Stripe checkout flows,
5
+ * and the customer portal redirect.
6
+ */
7
+
8
+ // ── SchedulingSubscriptionTier ────────────────────────────────────────────────
9
+
10
+ export type SchedulingSubscriptionTier = 'free' | 'pro';
11
+
12
+ // ── SchedulingSubscriptionStatus ─────────────────────────────────────────────
13
+
14
+ export type SchedulingSubscriptionStatus = 'active' | 'canceled' | 'expired';
15
+
16
+ // ── SchedulingSubscriptionInfoDTO ────────────────────────────────────────────
17
+
18
+ /**
19
+ * Current subscription state for the authenticated user.
20
+ * Returned by GET /social/subscription.
21
+ */
22
+ export class SchedulingSubscriptionInfoDTO {
23
+ tier: SchedulingSubscriptionTier;
24
+ status: SchedulingSubscriptionStatus;
25
+ expiresAt: string | null;
26
+
27
+ constructor(data: SchedulingSubscriptionInfoDTO) {
28
+ this.tier = data.tier;
29
+ this.status = data.status;
30
+ this.expiresAt = data.expiresAt;
31
+ }
32
+ }
33
+
34
+ // ── SchedulingCheckoutSessionResultDTO ───────────────────────────────────────
35
+
36
+ /**
37
+ * Response DTO for POST /social/subscription/checkout.
38
+ * The client should redirect to the returned URL to complete payment.
39
+ */
40
+ export class SchedulingCheckoutSessionResultDTO {
41
+ url: string;
42
+
43
+ constructor(data: SchedulingCheckoutSessionResultDTO) {
44
+ this.url = data.url;
45
+ }
46
+ }
47
+
48
+ // ── SchedulingPortalSessionResultDTO ─────────────────────────────────────────
49
+
50
+ /**
51
+ * Response DTO for POST /social/subscription/portal.
52
+ * The client should redirect to the returned URL to manage billing.
53
+ */
54
+ export class SchedulingPortalSessionResultDTO {
55
+ url: string;
56
+
57
+ constructor(data: SchedulingPortalSessionResultDTO) {
58
+ this.url = data.url;
59
+ }
60
+ }
61
+
62
+ // ── SchedulingProUpgradeDTO ───────────────────────────────────────────────────
63
+
64
+ /**
65
+ * Aggregated Pro-upgrade context DTO.
66
+ * Combines subscription info with action URLs for UI display.
67
+ */
68
+ export class SchedulingProUpgradeDTO {
69
+ subscriptionInfo: SchedulingSubscriptionInfoDTO;
70
+ checkoutUrl?: string;
71
+ portalUrl?: string;
72
+
73
+ constructor(data: SchedulingProUpgradeDTO) {
74
+ this.subscriptionInfo = data.subscriptionInfo;
75
+ this.checkoutUrl = data.checkoutUrl;
76
+ this.portalUrl = data.portalUrl;
77
+ }
78
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Scheduling domain — barrel export
3
+ *
4
+ * All scheduling DTOs are available from 'ad2app-lib/types' via:
5
+ * import { SchedulingPostDTO, SchedulingAnalyticsKpiDTO, ... } from 'ad2app-lib/types';
6
+ */
7
+
8
+ export * from './I_SchedulingPost';
9
+ export * from './I_SchedulingAnalytics';
10
+ export * from './I_SchedulingConnectedAccount';
11
+ export * from './I_SchedulingInbox';
12
+ export * from './I_SchedulingProUpgrade';