@addn/sdk 1.0.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.
Files changed (156) hide show
  1. package/dist/auth/storage.d.ts +25 -0
  2. package/dist/auth/storage.d.ts.map +1 -0
  3. package/dist/auth/storage.js +72 -0
  4. package/dist/auth/storage.js.map +1 -0
  5. package/dist/auth/token-manager.d.ts +39 -0
  6. package/dist/auth/token-manager.d.ts.map +1 -0
  7. package/dist/auth/token-manager.js +98 -0
  8. package/dist/auth/token-manager.js.map +1 -0
  9. package/dist/client.d.ts +31 -0
  10. package/dist/client.d.ts.map +1 -0
  11. package/dist/client.js +39 -0
  12. package/dist/client.js.map +1 -0
  13. package/dist/http/errors.d.ts +51 -0
  14. package/dist/http/errors.d.ts.map +1 -0
  15. package/dist/http/errors.js +92 -0
  16. package/dist/http/errors.js.map +1 -0
  17. package/dist/http/http-client.d.ts +18 -0
  18. package/dist/http/http-client.d.ts.map +1 -0
  19. package/dist/http/http-client.js +221 -0
  20. package/dist/http/http-client.js.map +1 -0
  21. package/dist/http/types.d.ts +27 -0
  22. package/dist/http/types.d.ts.map +1 -0
  23. package/dist/http/types.js +3 -0
  24. package/dist/http/types.js.map +1 -0
  25. package/dist/index.d.ts +18 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +36 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/modules/accounts.module.d.ts +15 -0
  30. package/dist/modules/accounts.module.d.ts.map +1 -0
  31. package/dist/modules/accounts.module.js +57 -0
  32. package/dist/modules/accounts.module.js.map +1 -0
  33. package/dist/modules/analytics.module.d.ts +14 -0
  34. package/dist/modules/analytics.module.d.ts.map +1 -0
  35. package/dist/modules/analytics.module.js +24 -0
  36. package/dist/modules/analytics.module.js.map +1 -0
  37. package/dist/modules/auth.module.d.ts +18 -0
  38. package/dist/modules/auth.module.d.ts.map +1 -0
  39. package/dist/modules/auth.module.js +113 -0
  40. package/dist/modules/auth.module.js.map +1 -0
  41. package/dist/modules/content-plans.module.d.ts +58 -0
  42. package/dist/modules/content-plans.module.d.ts.map +1 -0
  43. package/dist/modules/content-plans.module.js +125 -0
  44. package/dist/modules/content-plans.module.js.map +1 -0
  45. package/dist/modules/customers.module.d.ts +12 -0
  46. package/dist/modules/customers.module.d.ts.map +1 -0
  47. package/dist/modules/customers.module.js +43 -0
  48. package/dist/modules/customers.module.js.map +1 -0
  49. package/dist/modules/notifications.module.d.ts +20 -0
  50. package/dist/modules/notifications.module.d.ts.map +1 -0
  51. package/dist/modules/notifications.module.js +37 -0
  52. package/dist/modules/notifications.module.js.map +1 -0
  53. package/dist/modules/orgs.module.d.ts +23 -0
  54. package/dist/modules/orgs.module.d.ts.map +1 -0
  55. package/dist/modules/orgs.module.js +112 -0
  56. package/dist/modules/orgs.module.js.map +1 -0
  57. package/dist/modules/projects.module.d.ts +26 -0
  58. package/dist/modules/projects.module.d.ts.map +1 -0
  59. package/dist/modules/projects.module.js +88 -0
  60. package/dist/modules/projects.module.js.map +1 -0
  61. package/dist/modules/scheduling.module.d.ts +13 -0
  62. package/dist/modules/scheduling.module.d.ts.map +1 -0
  63. package/dist/modules/scheduling.module.js +32 -0
  64. package/dist/modules/scheduling.module.js.map +1 -0
  65. package/dist/modules/storage.module.d.ts +36 -0
  66. package/dist/modules/storage.module.d.ts.map +1 -0
  67. package/dist/modules/storage.module.js +100 -0
  68. package/dist/modules/storage.module.js.map +1 -0
  69. package/dist/modules/subscriptions.module.d.ts +25 -0
  70. package/dist/modules/subscriptions.module.d.ts.map +1 -0
  71. package/dist/modules/subscriptions.module.js +62 -0
  72. package/dist/modules/subscriptions.module.js.map +1 -0
  73. package/dist/types/account.types.d.ts +17 -0
  74. package/dist/types/account.types.d.ts.map +1 -0
  75. package/dist/types/account.types.js +3 -0
  76. package/dist/types/account.types.js.map +1 -0
  77. package/dist/types/analytics.types.d.ts +15 -0
  78. package/dist/types/analytics.types.d.ts.map +1 -0
  79. package/dist/types/analytics.types.js +3 -0
  80. package/dist/types/analytics.types.js.map +1 -0
  81. package/dist/types/api.types.d.ts +20 -0
  82. package/dist/types/api.types.d.ts.map +1 -0
  83. package/dist/types/api.types.js +3 -0
  84. package/dist/types/api.types.js.map +1 -0
  85. package/dist/types/auth.types.d.ts +40 -0
  86. package/dist/types/auth.types.d.ts.map +1 -0
  87. package/dist/types/auth.types.js +3 -0
  88. package/dist/types/auth.types.js.map +1 -0
  89. package/dist/types/content-plan.types.d.ts +27 -0
  90. package/dist/types/content-plan.types.d.ts.map +1 -0
  91. package/dist/types/content-plan.types.js +3 -0
  92. package/dist/types/content-plan.types.js.map +1 -0
  93. package/dist/types/customer.types.d.ts +25 -0
  94. package/dist/types/customer.types.d.ts.map +1 -0
  95. package/dist/types/customer.types.js +3 -0
  96. package/dist/types/customer.types.js.map +1 -0
  97. package/dist/types/index.d.ts +585 -0
  98. package/dist/types/index.d.ts.map +1 -0
  99. package/dist/types/index.js +6 -0
  100. package/dist/types/index.js.map +1 -0
  101. package/dist/types/notification.types.d.ts +11 -0
  102. package/dist/types/notification.types.d.ts.map +1 -0
  103. package/dist/types/notification.types.js +3 -0
  104. package/dist/types/notification.types.js.map +1 -0
  105. package/dist/types/org.types.d.ts +25 -0
  106. package/dist/types/org.types.d.ts.map +1 -0
  107. package/dist/types/org.types.js +3 -0
  108. package/dist/types/org.types.js.map +1 -0
  109. package/dist/types/project.types.d.ts +20 -0
  110. package/dist/types/project.types.d.ts.map +1 -0
  111. package/dist/types/project.types.js +3 -0
  112. package/dist/types/project.types.js.map +1 -0
  113. package/dist/types/scheduling.types.d.ts +31 -0
  114. package/dist/types/scheduling.types.d.ts.map +1 -0
  115. package/dist/types/scheduling.types.js +3 -0
  116. package/dist/types/scheduling.types.js.map +1 -0
  117. package/dist/types/storage.types.d.ts +8 -0
  118. package/dist/types/storage.types.d.ts.map +1 -0
  119. package/dist/types/storage.types.js +3 -0
  120. package/dist/types/storage.types.js.map +1 -0
  121. package/dist/types/subscription.types.d.ts +19 -0
  122. package/dist/types/subscription.types.d.ts.map +1 -0
  123. package/dist/types/subscription.types.js +3 -0
  124. package/dist/types/subscription.types.js.map +1 -0
  125. package/package.json +27 -0
  126. package/src/auth/storage.ts +75 -0
  127. package/src/auth/token-manager.ts +107 -0
  128. package/src/client.ts +51 -0
  129. package/src/http/errors.ts +97 -0
  130. package/src/http/http-client.ts +263 -0
  131. package/src/http/types.ts +32 -0
  132. package/src/index.ts +17 -0
  133. package/src/modules/accounts.module.ts +61 -0
  134. package/src/modules/analytics.module.ts +26 -0
  135. package/src/modules/auth.module.ts +129 -0
  136. package/src/modules/content-plans.module.ts +170 -0
  137. package/src/modules/customers.module.ts +48 -0
  138. package/src/modules/notifications.module.ts +41 -0
  139. package/src/modules/orgs.module.ts +122 -0
  140. package/src/modules/projects.module.ts +97 -0
  141. package/src/modules/scheduling.module.ts +35 -0
  142. package/src/modules/storage.module.ts +121 -0
  143. package/src/modules/subscriptions.module.ts +82 -0
  144. package/src/types/account.types.ts +17 -0
  145. package/src/types/analytics.types.ts +15 -0
  146. package/src/types/api.types.ts +21 -0
  147. package/src/types/auth.types.ts +45 -0
  148. package/src/types/content-plan.types.ts +28 -0
  149. package/src/types/customer.types.ts +25 -0
  150. package/src/types/index.ts +682 -0
  151. package/src/types/notification.types.ts +10 -0
  152. package/src/types/org.types.ts +27 -0
  153. package/src/types/project.types.ts +21 -0
  154. package/src/types/scheduling.types.ts +32 -0
  155. package/src/types/storage.types.ts +7 -0
  156. package/src/types/subscription.types.ts +19 -0
@@ -0,0 +1,48 @@
1
+ import { HttpClient } from "../http/http-client";
2
+ import type { Customer, CreateCustomerPayload, UpdateCustomerPayload } from "../types";
3
+
4
+ export class CustomersModule {
5
+ private readonly http: HttpClient;
6
+
7
+ constructor(http: HttpClient) {
8
+ this.http = http;
9
+ }
10
+
11
+ public async listCustomers(orgId?: string): Promise<Customer[]> {
12
+ return await this.http.request<Customer[]>({
13
+ path: "/api/v1/customers",
14
+ method: "GET",
15
+ query: orgId ? { org_id: orgId } : undefined,
16
+ });
17
+ }
18
+
19
+ public async getCustomer(customerId: string): Promise<Customer> {
20
+ return await this.http.request<Customer>({
21
+ path: `/api/v1/customers/${customerId}`,
22
+ method: "GET",
23
+ });
24
+ }
25
+
26
+ public async createCustomer(payload: CreateCustomerPayload): Promise<Customer> {
27
+ return await this.http.request<Customer>({
28
+ path: "/api/v1/customers",
29
+ method: "POST",
30
+ body: payload,
31
+ });
32
+ }
33
+
34
+ public async updateCustomer(customerId: string, payload: UpdateCustomerPayload): Promise<Customer> {
35
+ return await this.http.request<Customer>({
36
+ path: `/api/v1/customers/${customerId}`,
37
+ method: "PATCH",
38
+ body: payload,
39
+ });
40
+ }
41
+
42
+ public async deleteCustomer(customerId: string): Promise<void> {
43
+ await this.http.request({
44
+ path: `/api/v1/customers/${customerId}`,
45
+ method: "DELETE",
46
+ });
47
+ }
48
+ }
@@ -0,0 +1,41 @@
1
+ import { HttpClient } from "../http/http-client";
2
+ import type { NotificationItem, NotificationListResponse } from "../types";
3
+
4
+ export class NotificationsModule {
5
+ private readonly http: HttpClient;
6
+
7
+ constructor(http: HttpClient) {
8
+ this.http = http;
9
+ }
10
+
11
+ public async getNotifications(params?: { unread_only?: boolean; limit?: number; offset?: number }): Promise<NotificationListResponse> {
12
+ return await this.http.request<NotificationListResponse>({
13
+ path: "/api/v1/notifications",
14
+ method: "GET",
15
+ query: params,
16
+ });
17
+ }
18
+
19
+ public async markAsRead(notificationIds?: string[]): Promise<{ success: boolean; marked_count: number }> {
20
+ return await this.http.request<{ success: boolean; marked_count: number }>({
21
+ path: "/api/v1/notifications/read",
22
+ method: "PATCH",
23
+ query: notificationIds ? { notification_ids: notificationIds } : undefined,
24
+ });
25
+ }
26
+
27
+ public async deleteNotification(notificationId: string): Promise<{ deleted: boolean }> {
28
+ return await this.http.request<{ deleted: boolean }>({
29
+ path: `/api/v1/notifications/${notificationId}`,
30
+ method: "DELETE",
31
+ });
32
+ }
33
+
34
+ public async registerPushToken(token: string, platform: "web" | "ios" | "android"): Promise<void> {
35
+ await this.http.request({
36
+ path: "/api/v1/notifications/push-token",
37
+ method: "POST",
38
+ body: { push_token: token, platform },
39
+ });
40
+ }
41
+ }
@@ -0,0 +1,122 @@
1
+ import { HttpClient } from "../http/http-client";
2
+ import type { Organization, OrganizationMember, CreateOrgPayload, InviteMemberPayload, OrgJoinRequest } from "../types";
3
+
4
+ export class OrgsModule {
5
+ private readonly http: HttpClient;
6
+
7
+ constructor(http: HttpClient) {
8
+ this.http = http;
9
+ }
10
+
11
+ public async getMyOrganizations(): Promise<Organization[]> {
12
+ return await this.http.request<Organization[]>({
13
+ path: "/api/v1/orgs",
14
+ method: "GET",
15
+ });
16
+ }
17
+
18
+ public async getOrganization(orgId: string): Promise<Organization> {
19
+ return await this.http.request<Organization>({
20
+ path: `/api/v1/orgs/${orgId}`,
21
+ method: "GET",
22
+ });
23
+ }
24
+
25
+ public async createOrganization(payload: CreateOrgPayload): Promise<Organization> {
26
+ const res = await this.http.request<any>({
27
+ path: "/api/v1/org/create",
28
+ method: "POST",
29
+ body: payload,
30
+ });
31
+ return res?.organization || res;
32
+ }
33
+
34
+ public async joinOrganization(code: string): Promise<OrgJoinRequest> {
35
+ const res = await this.http.request<any>({
36
+ path: "/api/v1/org/join",
37
+ method: "POST",
38
+ body: { code },
39
+ });
40
+ return res?.request || res;
41
+ }
42
+
43
+ public async getMyJoinRequest(): Promise<OrgJoinRequest | null> {
44
+ const res = await this.http.request<any>({
45
+ path: "/api/v1/org/my-join-request",
46
+ method: "GET",
47
+ });
48
+ return res?.request || res || null;
49
+ }
50
+
51
+ public async cancelJoinRequest(): Promise<void> {
52
+ await this.http.request({
53
+ path: "/api/v1/org/my-join-request",
54
+ method: "DELETE",
55
+ });
56
+ }
57
+
58
+ public async listJoinRequests(): Promise<OrgJoinRequest[]> {
59
+ const res = await this.http.request<any>({
60
+ path: "/api/v1/org/join-requests",
61
+ method: "GET",
62
+ });
63
+ if (Array.isArray(res)) return res;
64
+ if (Array.isArray(res?.requests)) return res.requests;
65
+ return [];
66
+ }
67
+
68
+ public async approveJoinRequest(requestId: string, designation: string = "Team Member"): Promise<void> {
69
+ await this.http.request({
70
+ path: `/api/v1/org/join-requests/${requestId}/approve`,
71
+ method: "POST",
72
+ body: { designation },
73
+ });
74
+ }
75
+
76
+ public async rejectJoinRequest(requestId: string, reason: string = "Declined"): Promise<void> {
77
+ await this.http.request({
78
+ path: `/api/v1/org/join-requests/${requestId}/reject`,
79
+ method: "POST",
80
+ body: { reason },
81
+ });
82
+ }
83
+
84
+ public async getMembers(): Promise<OrganizationMember[]> {
85
+ const res = await this.http.request<any>({
86
+ path: "/api/v1/org/members",
87
+ method: "GET",
88
+ });
89
+ if (Array.isArray(res)) return res;
90
+ if (Array.isArray(res?.members)) return res.members;
91
+ return [];
92
+ }
93
+
94
+ public async inviteMember(orgId: string, payload: InviteMemberPayload): Promise<void> {
95
+ await this.http.request({
96
+ path: `/api/v1/orgs/${orgId}/invite`,
97
+ method: "POST",
98
+ body: payload,
99
+ });
100
+ }
101
+
102
+ public async removeMember(orgId: string, userId: string): Promise<void> {
103
+ await this.http.request({
104
+ path: `/api/v1/orgs/${orgId}/members/${userId}`,
105
+ method: "DELETE",
106
+ });
107
+ }
108
+
109
+ public async kickMember(memberId: string): Promise<void> {
110
+ await this.http.request({
111
+ path: `/api/v1/org/members/${memberId}/kick`,
112
+ method: "POST",
113
+ });
114
+ }
115
+
116
+ public async rotateCode(): Promise<{ code: string }> {
117
+ return await this.http.request<{ code: string }>({
118
+ path: "/api/v1/org/rotate-code",
119
+ method: "POST",
120
+ });
121
+ }
122
+ }
@@ -0,0 +1,97 @@
1
+ import { HttpClient } from "../http/http-client";
2
+ import type { Project, CreateProjectPayload, UpdateProjectPayload, ProjectMember, ProjectAccount } from "../types";
3
+
4
+ export class ProjectsModule {
5
+ private readonly http: HttpClient;
6
+
7
+ constructor(http: HttpClient) {
8
+ this.http = http;
9
+ }
10
+
11
+ public async listProjects(params?: { org_id?: string; customer_id?: string; status?: string }): Promise<Project[]> {
12
+ const res = await this.http.request<any>({
13
+ path: "/api/v1/projects",
14
+ method: "GET",
15
+ query: params,
16
+ });
17
+ if (Array.isArray(res)) return res;
18
+ if (res?.projects && Array.isArray(res.projects)) return res.projects;
19
+ return [];
20
+ }
21
+
22
+ public async getProject(projectId: string): Promise<{ project: Project; members: ProjectMember[]; accounts: ProjectAccount[] }> {
23
+ return await this.http.request({
24
+ path: `/api/v1/projects/${projectId}`,
25
+ method: "GET",
26
+ });
27
+ }
28
+
29
+ public async createProject(payload: CreateProjectPayload): Promise<Project> {
30
+ const res = await this.http.request<any>({
31
+ path: "/api/v1/projects",
32
+ method: "POST",
33
+ body: payload,
34
+ });
35
+ return res?.project || res;
36
+ }
37
+
38
+ public async updateProject(projectId: string, payload: UpdateProjectPayload): Promise<Project> {
39
+ const res = await this.http.request<any>({
40
+ path: `/api/v1/projects/${projectId}`,
41
+ method: "PATCH",
42
+ body: payload,
43
+ });
44
+ return res?.project || res;
45
+ }
46
+
47
+ public async archiveProject(projectId: string): Promise<void> {
48
+ await this.http.request({
49
+ path: `/api/v1/projects/${projectId}/archive`,
50
+ method: "POST",
51
+ });
52
+ }
53
+
54
+ public async restoreProject(projectId: string): Promise<void> {
55
+ await this.http.request({
56
+ path: `/api/v1/projects/${projectId}/restore`,
57
+ method: "POST",
58
+ });
59
+ }
60
+
61
+ public async deleteProject(projectId: string): Promise<void> {
62
+ await this.http.request({
63
+ path: `/api/v1/projects/${projectId}`,
64
+ method: "DELETE",
65
+ });
66
+ }
67
+
68
+ public async assignMember(projectId: string, userId: string, role: string): Promise<void> {
69
+ await this.http.request({
70
+ path: `/api/v1/projects/${projectId}/members`,
71
+ method: "POST",
72
+ body: { user_id: userId, role },
73
+ });
74
+ }
75
+
76
+ public async removeMember(projectId: string, userId: string): Promise<void> {
77
+ await this.http.request({
78
+ path: `/api/v1/projects/${projectId}/members/${userId}`,
79
+ method: "DELETE",
80
+ });
81
+ }
82
+
83
+ public async assignAccount(projectId: string, accountId: string): Promise<void> {
84
+ await this.http.request({
85
+ path: `/api/v1/projects/${projectId}/accounts`,
86
+ method: "POST",
87
+ body: { account_id: accountId },
88
+ });
89
+ }
90
+
91
+ public async removeAccount(projectId: string, accountId: string): Promise<void> {
92
+ await this.http.request({
93
+ path: `/api/v1/projects/${projectId}/accounts/${accountId}`,
94
+ method: "DELETE",
95
+ });
96
+ }
97
+ }
@@ -0,0 +1,35 @@
1
+ import { HttpClient } from "../http/http-client";
2
+ import type { ScheduledPost, PublicApprovalView, SubmitApprovalPayload } from "../types";
3
+
4
+ export class SchedulingModule {
5
+ private readonly http: HttpClient;
6
+
7
+ constructor(http: HttpClient) {
8
+ this.http = http;
9
+ }
10
+
11
+ public async getScheduledPosts(params?: { project_id?: string; month?: string }): Promise<ScheduledPost[]> {
12
+ return await this.http.request<ScheduledPost[]>({
13
+ path: "/api/v1/scheduling",
14
+ method: "GET",
15
+ query: params,
16
+ });
17
+ }
18
+
19
+ public async getPublicApprovalView(token: string): Promise<PublicApprovalView> {
20
+ return await this.http.request<PublicApprovalView>({
21
+ path: `/approval/${token}`,
22
+ method: "GET",
23
+ requiresAuth: false,
24
+ });
25
+ }
26
+
27
+ public async submitPublicApproval(payload: SubmitApprovalPayload): Promise<void> {
28
+ await this.http.request({
29
+ path: `/approval/${payload.token}/action`,
30
+ method: "POST",
31
+ body: payload,
32
+ requiresAuth: false,
33
+ });
34
+ }
35
+ }
@@ -0,0 +1,121 @@
1
+ import { HttpClient } from "../http/http-client";
2
+ import type { MediaAsset, PresignedUploadResponse, UploadFileResponse } from "../types";
3
+
4
+ export class StorageModule {
5
+ private readonly http: HttpClient;
6
+
7
+ constructor(http: HttpClient) {
8
+ this.http = http;
9
+ }
10
+
11
+ public async requestPresignedUpload(payload: {
12
+ filename: string;
13
+ content_type: string;
14
+ file_size: number;
15
+ project_id?: string;
16
+ }): Promise<PresignedUploadResponse> {
17
+ const res = await this.http.request<any>({
18
+ path: "/api/v1/storage/presign-upload",
19
+ method: "POST",
20
+ body: payload,
21
+ });
22
+ const data = res?.data || res;
23
+ const uploadUrl = data?.upload_url || data?.presigned_url || data?.uploadUrl || "";
24
+ const downloadUrl = data?.download_url || data?.url || data?.downloadUrl || "";
25
+ const assetId = data?.asset_id || data?.assetId || "";
26
+ const storagePath = data?.storage_path || data?.storagePath || "";
27
+
28
+ return {
29
+ upload_url: uploadUrl,
30
+ presigned_url: uploadUrl,
31
+ asset_id: assetId,
32
+ storage_path: storagePath,
33
+ download_url: downloadUrl,
34
+ url: downloadUrl,
35
+ };
36
+ }
37
+
38
+ public async uploadBinaryFile(
39
+ presignedUrl: string,
40
+ file: File,
41
+ onProgress?: (percent: number) => void
42
+ ): Promise<void> {
43
+ if (!presignedUrl || typeof presignedUrl !== "string" || !presignedUrl.startsWith("http")) {
44
+ throw new Error(`Invalid upload URL: "${presignedUrl}". Could not initialize file upload.`);
45
+ }
46
+
47
+ return new Promise((resolve, reject) => {
48
+ const xhr = new XMLHttpRequest();
49
+ xhr.open("PUT", presignedUrl, true);
50
+ xhr.setRequestHeader("Content-Type", file.type || "application/octet-stream");
51
+ xhr.upload.onprogress = (event) => {
52
+ if (event.lengthComputable && onProgress && event.total > 0) {
53
+ onProgress(Math.round((event.loaded / event.total) * 100));
54
+ }
55
+ };
56
+ xhr.onload = () => {
57
+ if (xhr.status >= 200 && xhr.status < 300) {
58
+ resolve();
59
+ } else {
60
+ try {
61
+ const err = JSON.parse(xhr.responseText);
62
+ reject(new Error(err.message || err.detail || `Upload failed with status ${xhr.status}`));
63
+ } catch {
64
+ reject(new Error(`Upload failed with status ${xhr.status}`));
65
+ }
66
+ }
67
+ };
68
+ xhr.onerror = () => reject(new Error("Network error during file upload"));
69
+ xhr.send(file);
70
+ });
71
+ }
72
+
73
+ public async uploadFile(fileInput: File | Blob | FormData | { uri: string; name: string; type: string }): Promise<UploadFileResponse> {
74
+ let formData: FormData;
75
+
76
+ if (fileInput instanceof FormData) {
77
+ formData = fileInput;
78
+ } else {
79
+ formData = new FormData();
80
+ if ("uri" in fileInput) {
81
+ formData.append("file", fileInput as any);
82
+ } else {
83
+ formData.append("file", fileInput, (fileInput as File).name || "upload");
84
+ }
85
+ }
86
+
87
+ return await this.http.request<UploadFileResponse>({
88
+ path: "/api/v1/storage/upload",
89
+ method: "POST",
90
+ formData,
91
+ });
92
+ }
93
+
94
+ public async listAssets(params?: {
95
+ project_id?: string;
96
+ media_type?: string;
97
+ search?: string;
98
+ page?: number;
99
+ page_size?: number;
100
+ }): Promise<{ assets: MediaAsset[]; total: number; page: number; page_size: number }> {
101
+ return await this.http.request({
102
+ path: "/api/v1/storage/assets",
103
+ method: "GET",
104
+ query: params,
105
+ });
106
+ }
107
+
108
+ public async getUploadStatus(assetId: string): Promise<{ status: string; url?: string }> {
109
+ return await this.http.request<{ status: string; url?: string }>({
110
+ path: `/api/v1/storage/uploads/${assetId}/status`,
111
+ method: "GET",
112
+ });
113
+ }
114
+
115
+ public async deleteAsset(assetId: string): Promise<void> {
116
+ await this.http.request({
117
+ path: `/api/v1/storage/assets/${assetId}`,
118
+ method: "DELETE",
119
+ });
120
+ }
121
+ }
@@ -0,0 +1,82 @@
1
+ import { HttpClient } from "../http/http-client";
2
+ import type {
3
+ SubscriptionPlan,
4
+ CurrentSubscription,
5
+ QuotaStatus,
6
+ RazorpayCreateResult,
7
+ RazorpayVerifyResult,
8
+ } from "../types";
9
+
10
+ export class SubscriptionsModule {
11
+ private readonly http: HttpClient;
12
+
13
+ constructor(http: HttpClient) {
14
+ this.http = http;
15
+ }
16
+
17
+ public async getPlans(): Promise<SubscriptionPlan[]> {
18
+ return await this.http.request<SubscriptionPlan[]>({
19
+ path: "/api/v1/subscriptions/plans",
20
+ method: "GET",
21
+ requiresAuth: false,
22
+ });
23
+ }
24
+
25
+ public async getCurrentSubscription(): Promise<CurrentSubscription> {
26
+ return await this.http.request<CurrentSubscription>({
27
+ path: "/api/v1/subscriptions/current",
28
+ method: "GET",
29
+ });
30
+ }
31
+
32
+ public async getQuotaStatus(): Promise<QuotaStatus> {
33
+ return await this.http.request<QuotaStatus>({
34
+ path: "/api/v1/subscriptions/quota-status",
35
+ method: "GET",
36
+ });
37
+ }
38
+
39
+ public async cancelSubscription(): Promise<any> {
40
+ return await this.http.request({
41
+ path: "/api/v1/subscriptions/cancel",
42
+ method: "POST",
43
+ });
44
+ }
45
+
46
+ public async reactivateSubscription(): Promise<any> {
47
+ return await this.http.request({
48
+ path: "/api/v1/subscriptions/reactivate",
49
+ method: "POST",
50
+ });
51
+ }
52
+
53
+ public async createRazorpayOrder(planId: string): Promise<RazorpayCreateResult> {
54
+ return await this.http.request<RazorpayCreateResult>({
55
+ path: "/api/v1/subscriptions/razorpay/create",
56
+ method: "POST",
57
+ body: { plan_id: planId },
58
+ });
59
+ }
60
+
61
+ public async verifyRazorpayPayment(payload: {
62
+ razorpay_order_id?: string;
63
+ razorpay_payment_id?: string;
64
+ razorpay_signature?: string;
65
+ plan_id?: string;
66
+ razorpay_subscription_id?: string;
67
+ }): Promise<RazorpayVerifyResult> {
68
+ return await this.http.request<RazorpayVerifyResult>({
69
+ path: "/api/v1/subscriptions/razorpay/verify",
70
+ method: "POST",
71
+ body: payload,
72
+ });
73
+ }
74
+
75
+ public async verifyGooglePlayPurchase(payload: { package_name: string; product_id: string; purchase_token: string }): Promise<any> {
76
+ return await this.http.request({
77
+ path: "/api/v1/subscriptions/google-play/verify",
78
+ method: "POST",
79
+ body: payload,
80
+ });
81
+ }
82
+ }
@@ -0,0 +1,17 @@
1
+ export interface ConnectedAccount {
2
+ id: string;
3
+ organization_id: string;
4
+ platform: "instagram" | "facebook" | "linkedin";
5
+ account_name: string;
6
+ account_id: string;
7
+ username?: string;
8
+ profile_picture_url?: string;
9
+ is_active: boolean;
10
+ connected_at: string;
11
+ }
12
+
13
+ export interface ConnectAccountPayload {
14
+ platform: "instagram" | "facebook" | "linkedin";
15
+ auth_code: string;
16
+ redirect_uri: string;
17
+ }
@@ -0,0 +1,15 @@
1
+ export interface AnalyticsMetric {
2
+ date: string;
3
+ reach: number;
4
+ impressions: number;
5
+ engagement: number;
6
+ followers_gained: number;
7
+ }
8
+
9
+ export interface AnalyticsSummary {
10
+ total_posts: number;
11
+ total_reach: number;
12
+ total_engagement: number;
13
+ average_engagement_rate: number;
14
+ metrics: AnalyticsMetric[];
15
+ }
@@ -0,0 +1,21 @@
1
+ export interface ApiResponse<T = any> {
2
+ success: boolean;
3
+ message?: string;
4
+ data: T;
5
+ code?: string;
6
+ details?: any;
7
+ }
8
+
9
+ export interface PaginatedMeta {
10
+ total: number;
11
+ page: number;
12
+ limit: number;
13
+ pages: number;
14
+ }
15
+
16
+ export interface PaginatedResponse<T = any> {
17
+ success: boolean;
18
+ message?: string;
19
+ data: T[];
20
+ meta: PaginatedMeta;
21
+ }
@@ -0,0 +1,45 @@
1
+ export interface UserProfile {
2
+ id: string;
3
+ email: string;
4
+ full_name: string;
5
+ role: "admin" | "org_admin" | "member" | "viewer" | string;
6
+ organization_id?: string | null;
7
+ avatar_url?: string | null;
8
+ is_active: boolean;
9
+ created_at?: string;
10
+ updated_at?: string;
11
+ }
12
+
13
+ export interface LoginPayload {
14
+ email: string;
15
+ password: string;
16
+ }
17
+
18
+ export interface RegisterPayload {
19
+ email: string;
20
+ password: string;
21
+ full_name: string;
22
+ organization_name?: string;
23
+ }
24
+
25
+ export interface AuthTokenResponse {
26
+ access_token: string;
27
+ refresh_token: string;
28
+ token_type: string;
29
+ expires_in?: number;
30
+ user: UserProfile;
31
+ }
32
+
33
+ export interface PasswordResetRequestPayload {
34
+ email: string;
35
+ }
36
+
37
+ export interface PasswordResetConfirmPayload {
38
+ token: string;
39
+ new_password: string;
40
+ }
41
+
42
+ export interface MetaLoginPayload {
43
+ code: string;
44
+ redirect_uri: string;
45
+ }
@@ -0,0 +1,28 @@
1
+ export interface PostItem {
2
+ id: string;
3
+ title: string;
4
+ caption?: string;
5
+ media_urls?: string[];
6
+ post_type: "reel" | "carousel" | "single_image" | "story";
7
+ scheduled_at?: string;
8
+ status: "draft" | "pending_approval" | "approved" | "rejected" | "published";
9
+ rejection_reason?: string;
10
+ }
11
+
12
+ export interface ContentPlan {
13
+ id: string;
14
+ project_id: string;
15
+ title: string;
16
+ month: string;
17
+ status: "draft" | "in_review" | "approved" | "published";
18
+ posts: PostItem[];
19
+ created_at: string;
20
+ updated_at: string;
21
+ }
22
+
23
+ export interface CreateContentPlanPayload {
24
+ project_id: string;
25
+ title: string;
26
+ month: string;
27
+ posts?: Partial<PostItem>[];
28
+ }