@sentroy-co/client-sdk 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/react/MediaManager.d.ts +69 -0
- package/dist/react/MediaManager.d.ts.map +1 -0
- package/dist/react/MediaManager.js +216 -0
- package/dist/react/MediaManager.js.map +1 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +13 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/lib/Lightbox.d.ts +18 -0
- package/dist/react/lib/Lightbox.d.ts.map +1 -0
- package/dist/react/lib/Lightbox.js +40 -0
- package/dist/react/lib/Lightbox.js.map +1 -0
- package/dist/react/lib/use-media-list.d.ts +21 -0
- package/dist/react/lib/use-media-list.d.ts.map +1 -0
- package/dist/react/lib/use-media-list.js +50 -0
- package/dist/react/lib/use-media-list.js.map +1 -0
- package/dist/react/lib/utils.d.ts +17 -0
- package/dist/react/lib/utils.d.ts.map +1 -0
- package/dist/react/lib/utils.js +62 -0
- package/dist/react/lib/utils.js.map +1 -0
- package/dist/resources/storage.d.ts +23 -0
- package/dist/resources/storage.d.ts.map +1 -0
- package/dist/resources/storage.js +31 -0
- package/dist/resources/storage.js.map +1 -0
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +40 -4
- package/src/http.ts +151 -0
- package/src/index.ts +106 -0
- package/src/react/MediaManager.tsx +628 -0
- package/src/react/index.ts +13 -0
- package/src/react/lib/Lightbox.tsx +162 -0
- package/src/react/lib/use-media-list.ts +54 -0
- package/src/react/lib/utils.ts +73 -0
- package/src/resources/buckets.ts +50 -0
- package/src/resources/domains.ts +16 -0
- package/src/resources/inbox.ts +99 -0
- package/src/resources/mailboxes.ts +11 -0
- package/src/resources/media.ts +115 -0
- package/src/resources/send.ts +11 -0
- package/src/resources/storage.ts +28 -0
- package/src/resources/templates.ts +16 -0
- package/src/types.ts +316 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
// ── Configuration ──────────────────────────────────────────────────────────
|
|
2
|
+
|
|
3
|
+
export interface SentroyClientConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Platform root URL, e.g. "https://sentroy.com". Every resource —
|
|
6
|
+
* mail (domains, mailboxes, templates, inbox, send) and storage
|
|
7
|
+
* (buckets, media) — is reached through this single origin. The
|
|
8
|
+
* platform gateway transparently forwards mail requests to the mail
|
|
9
|
+
* subdomain and storage requests to the storage subdomain; consumers
|
|
10
|
+
* never see the split.
|
|
11
|
+
*/
|
|
12
|
+
baseUrl: string
|
|
13
|
+
/** Company slug */
|
|
14
|
+
companySlug: string
|
|
15
|
+
/** Access token (stk_...). Same token works for mail + storage. */
|
|
16
|
+
accessToken: string
|
|
17
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
18
|
+
timeout?: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ── API response ───────────────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
export interface ApiResponse<T> {
|
|
24
|
+
data: T
|
|
25
|
+
error?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ── Domains ────────────────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
export interface Domain {
|
|
31
|
+
id: string
|
|
32
|
+
domain: string
|
|
33
|
+
status: "pending" | "verifying" | "active" | "failed"
|
|
34
|
+
spfVerified: boolean
|
|
35
|
+
dkimVerified: boolean
|
|
36
|
+
dmarcVerified: boolean
|
|
37
|
+
createdAt: string
|
|
38
|
+
updatedAt: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ── Mailboxes ──────────────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
export interface MailboxUser {
|
|
44
|
+
email: string
|
|
45
|
+
domain: string
|
|
46
|
+
username: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ── Templates ──────────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
export type LocalizedString = string | Record<string, string>
|
|
52
|
+
|
|
53
|
+
export interface Template {
|
|
54
|
+
id: string
|
|
55
|
+
name: LocalizedString
|
|
56
|
+
subject: LocalizedString
|
|
57
|
+
mjmlBody: LocalizedString
|
|
58
|
+
htmlBody?: LocalizedString
|
|
59
|
+
variables?: string[]
|
|
60
|
+
domainId?: string
|
|
61
|
+
domainName?: string
|
|
62
|
+
createdAt: string
|
|
63
|
+
updatedAt: string
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ── Inbox ──────────────────────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
export interface MessageAddress {
|
|
69
|
+
name: string
|
|
70
|
+
address: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface MessageSummary {
|
|
74
|
+
uid: number
|
|
75
|
+
subject: string
|
|
76
|
+
from: MessageAddress
|
|
77
|
+
to: MessageAddress[]
|
|
78
|
+
date: string
|
|
79
|
+
seen: boolean
|
|
80
|
+
flagged: boolean
|
|
81
|
+
size: number
|
|
82
|
+
hasAttachments: boolean
|
|
83
|
+
preview: string
|
|
84
|
+
messageId: string | null
|
|
85
|
+
inReplyTo: string | null
|
|
86
|
+
category: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface MessageDetail {
|
|
90
|
+
uid: number
|
|
91
|
+
subject: string
|
|
92
|
+
from: MessageAddress
|
|
93
|
+
to: MessageAddress[]
|
|
94
|
+
cc: MessageAddress[]
|
|
95
|
+
replyTo: MessageAddress | null
|
|
96
|
+
date: string
|
|
97
|
+
seen: boolean
|
|
98
|
+
flagged: boolean
|
|
99
|
+
textBody: string | null
|
|
100
|
+
htmlBody: string | null
|
|
101
|
+
attachments: AttachmentInfo[]
|
|
102
|
+
headers: Record<string, string>
|
|
103
|
+
messageId: string | null
|
|
104
|
+
inReplyTo: string | null
|
|
105
|
+
references: string[]
|
|
106
|
+
folder?: string
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface AttachmentInfo {
|
|
110
|
+
partId: string
|
|
111
|
+
filename: string
|
|
112
|
+
size: number
|
|
113
|
+
contentType: string
|
|
114
|
+
contentId: string | null
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface Mailbox {
|
|
118
|
+
name: string
|
|
119
|
+
path: string
|
|
120
|
+
specialUse: string | null
|
|
121
|
+
totalMessages: number
|
|
122
|
+
unreadMessages: number
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface InboxListParams {
|
|
126
|
+
mailbox?: string
|
|
127
|
+
folder?: string
|
|
128
|
+
page?: number
|
|
129
|
+
limit?: number
|
|
130
|
+
unreadOnly?: boolean
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ── Send ───────────────────────────────────────────────────────────────────
|
|
134
|
+
|
|
135
|
+
export interface Attachment {
|
|
136
|
+
filename: string
|
|
137
|
+
content: string
|
|
138
|
+
contentType?: string
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface SendParams {
|
|
142
|
+
to: string | string[]
|
|
143
|
+
from: string
|
|
144
|
+
subject: string
|
|
145
|
+
domainId: string
|
|
146
|
+
cc?: string | string[]
|
|
147
|
+
templateId?: string
|
|
148
|
+
/** Template language code (e.g. "en", "tr"). Falls back to default if omitted. */
|
|
149
|
+
lang?: string
|
|
150
|
+
html?: string
|
|
151
|
+
text?: string
|
|
152
|
+
variables?: Record<string, string>
|
|
153
|
+
replyTo?: string
|
|
154
|
+
attachments?: Attachment[]
|
|
155
|
+
scheduledAt?: string
|
|
156
|
+
headers?: Record<string, string>
|
|
157
|
+
inReplyTo?: string
|
|
158
|
+
references?: string[]
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface SendResult {
|
|
162
|
+
jobId: string
|
|
163
|
+
mailLogId: string
|
|
164
|
+
status: string
|
|
165
|
+
scheduledAt?: string
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ── Storage / Buckets ──────────────────────────────────────────────────────
|
|
169
|
+
|
|
170
|
+
export interface Bucket {
|
|
171
|
+
id: string
|
|
172
|
+
companyId: string
|
|
173
|
+
name: string
|
|
174
|
+
slug: string
|
|
175
|
+
description?: string
|
|
176
|
+
isPublic: boolean
|
|
177
|
+
storageUsed: number
|
|
178
|
+
fileCount: number
|
|
179
|
+
createdAt: string
|
|
180
|
+
updatedAt: string
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface CreateBucketParams {
|
|
184
|
+
name: string
|
|
185
|
+
/** URL-safe slug. Auto-derived from name if omitted. */
|
|
186
|
+
slug?: string
|
|
187
|
+
description?: string
|
|
188
|
+
/** Public buckets serve files without auth; private requires proxy. */
|
|
189
|
+
isPublic?: boolean
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface UpdateBucketParams {
|
|
193
|
+
name?: string
|
|
194
|
+
description?: string
|
|
195
|
+
/** Toggling cascades to every file's S3 ACL + Media doc. */
|
|
196
|
+
isPublic?: boolean
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// ── Storage / Media ────────────────────────────────────────────────────────
|
|
200
|
+
|
|
201
|
+
export type MediaType = "image" | "video" | "audio" | "document" | "other"
|
|
202
|
+
|
|
203
|
+
export interface MediaThumbnail {
|
|
204
|
+
width: number
|
|
205
|
+
height: number
|
|
206
|
+
fileName: string
|
|
207
|
+
size: number
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface MediaImageMeta {
|
|
211
|
+
width: number
|
|
212
|
+
height: number
|
|
213
|
+
orientation: "landscape" | "portrait" | "square"
|
|
214
|
+
thumbnails: MediaThumbnail[]
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface Media {
|
|
218
|
+
id: string
|
|
219
|
+
bucketId: string
|
|
220
|
+
companyId: string
|
|
221
|
+
fileName: string
|
|
222
|
+
originalName: string
|
|
223
|
+
type: MediaType
|
|
224
|
+
size: number
|
|
225
|
+
mimeType: string
|
|
226
|
+
folder: string
|
|
227
|
+
uploadedBy: string
|
|
228
|
+
tags: string[]
|
|
229
|
+
alt?: string
|
|
230
|
+
caption?: string
|
|
231
|
+
isPublic: boolean
|
|
232
|
+
imageMeta?: MediaImageMeta
|
|
233
|
+
/** Public bucket'larda direct CDN URL — server response'undan gelir
|
|
234
|
+
* (her zaman değil). Yoksa caller proxy/download endpoint'i kullanmalı. */
|
|
235
|
+
url?: string
|
|
236
|
+
/** Auth'lu download URL — short-lived signed link veya proxy. */
|
|
237
|
+
downloadUrl?: string
|
|
238
|
+
createdAt: string
|
|
239
|
+
updatedAt: string
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface MediaListResult {
|
|
243
|
+
items: Media[]
|
|
244
|
+
total: number
|
|
245
|
+
limit: number
|
|
246
|
+
skip: number
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface MediaListParams {
|
|
250
|
+
type?: MediaType
|
|
251
|
+
folder?: string
|
|
252
|
+
limit?: number
|
|
253
|
+
skip?: number
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Upload input. Works in both Node and the browser:
|
|
258
|
+
* - Node: pass a `Blob` via `new Blob([buffer])` or `File` polyfill.
|
|
259
|
+
* - Browser: pass a `File` (from input) or `Blob` directly.
|
|
260
|
+
*
|
|
261
|
+
* `filename` is required when `body` is a raw `Blob` without a `.name`;
|
|
262
|
+
* otherwise the client reads `body.name` (File) or defaults to
|
|
263
|
+
* `"upload.bin"`.
|
|
264
|
+
*/
|
|
265
|
+
export interface UploadMediaParams {
|
|
266
|
+
body: Blob
|
|
267
|
+
filename?: string
|
|
268
|
+
/** Folder name inside the bucket (default "uploads"). */
|
|
269
|
+
folder?: string
|
|
270
|
+
/** Sets media.isPublic; bucket must itself be public for this to take. */
|
|
271
|
+
isPublic?: boolean
|
|
272
|
+
alt?: string
|
|
273
|
+
caption?: string
|
|
274
|
+
tags?: string[]
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// ── Storage quota / usage ─────────────────────────────────────────────────
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Plan-level storage quota for the company. Mail and storage share the
|
|
281
|
+
* same byte pool; `used` reports storage's slice and `mailUsed` what mail
|
|
282
|
+
* has occupied. `limit` of `0` means the plan is unlimited.
|
|
283
|
+
*/
|
|
284
|
+
export interface StorageQuota {
|
|
285
|
+
used: number
|
|
286
|
+
limit: number
|
|
287
|
+
mailUsed: number
|
|
288
|
+
planName?: string
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Per-bucket usage row inside `StorageUsage.buckets`. */
|
|
292
|
+
export interface StorageUsageBucket {
|
|
293
|
+
id: string
|
|
294
|
+
name: string
|
|
295
|
+
slug: string
|
|
296
|
+
storageUsed: number
|
|
297
|
+
fileCount: number
|
|
298
|
+
isPublic: boolean
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Per-type aggregation row inside `StorageUsage.byType`. */
|
|
302
|
+
export interface StorageUsageByType {
|
|
303
|
+
type: MediaType
|
|
304
|
+
count: number
|
|
305
|
+
bytes: number
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Combined snapshot for a "Usage" dashboard: plan quota + every bucket
|
|
310
|
+
* with its byte/file counts + a media-type breakdown across the company.
|
|
311
|
+
*/
|
|
312
|
+
export interface StorageUsage {
|
|
313
|
+
quota: StorageQuota
|
|
314
|
+
buckets: StorageUsageBucket[]
|
|
315
|
+
byType: StorageUsageByType[]
|
|
316
|
+
}
|