@bangkeut-technology/supportdock-sdk 0.3.0 → 0.4.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 +18 -0
- package/dist/client.js +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +8 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -89,6 +89,7 @@ await sdk.sendFeedback({
|
|
|
89
89
|
metadata?: Record<string, string>,
|
|
90
90
|
source?: string, // default: 'mobile-app'
|
|
91
91
|
images?: string[], // up to 3 base64 data URLs (PNG/JPEG/WebP/GIF, each ≤ 2 MB)
|
|
92
|
+
attachments?: { name: string; data: string }[], // up to 3 PDFs (each ≤ 5 MB)
|
|
92
93
|
});
|
|
93
94
|
```
|
|
94
95
|
|
|
@@ -109,6 +110,23 @@ await sdk.sendFeedback({
|
|
|
109
110
|
});
|
|
110
111
|
```
|
|
111
112
|
|
|
113
|
+
#### Attaching PDFs
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
// Convert a local PDF to base64 (React Native example)
|
|
117
|
+
import * as FileSystem from 'expo-file-system';
|
|
118
|
+
|
|
119
|
+
const base64 = await FileSystem.readAsStringAsync(pdfUri, {
|
|
120
|
+
encoding: FileSystem.EncodingType.Base64,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
await sdk.sendFeedback({
|
|
124
|
+
type: 'bug',
|
|
125
|
+
message: 'Steps to reproduce are in the attached report',
|
|
126
|
+
attachments: [{ name: 'report.pdf', data: `data:application/pdf;base64,${base64}` }],
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
112
130
|
### FAQs
|
|
113
131
|
|
|
114
132
|
```ts
|
package/dist/client.js
CHANGED
|
@@ -55,6 +55,19 @@ class SupportDockClient {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
if (options.attachments) {
|
|
59
|
+
if (options.attachments.length > 3) {
|
|
60
|
+
throw new SupportDockError('Maximum 3 PDF attachments allowed', 400);
|
|
61
|
+
}
|
|
62
|
+
for (const att of options.attachments) {
|
|
63
|
+
if (!att?.name) {
|
|
64
|
+
throw new SupportDockError('Each attachment requires a name', 400);
|
|
65
|
+
}
|
|
66
|
+
if (!/^data:application\/pdf;base64,/.test(att.data ?? '')) {
|
|
67
|
+
throw new SupportDockError('Attachments must be base64-encoded PDF data URLs', 400);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
58
71
|
return this.request('/api/v1/feedback/remote', {
|
|
59
72
|
method: 'POST',
|
|
60
73
|
body: JSON.stringify({
|
|
@@ -66,6 +79,7 @@ class SupportDockClient {
|
|
|
66
79
|
metadata: Object.keys(metadata).length > 0 ? metadata : undefined,
|
|
67
80
|
source: options.source ?? 'mobile-app',
|
|
68
81
|
images: options.images,
|
|
82
|
+
attachments: options.attachments,
|
|
69
83
|
}),
|
|
70
84
|
});
|
|
71
85
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { SupportDockClient, SupportDockError } from './client';
|
|
2
2
|
export { useSupportDock } from './react';
|
|
3
|
-
export type { SupportDockConfig, FeedbackOptions, FeedbackResult, FeedbackType, FAQ, CreateFAQOptions, UpdateFAQOptions, } from './types';
|
|
3
|
+
export type { SupportDockConfig, FeedbackOptions, FeedbackAttachment, FeedbackResult, FeedbackType, FAQ, CreateFAQOptions, UpdateFAQOptions, } from './types';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export type FeedbackType = 'bug' | 'feature' | 'question' | 'general';
|
|
2
|
+
export interface FeedbackAttachment {
|
|
3
|
+
/** Display filename, e.g. "logs.pdf". */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Base64-encoded PDF data URL (data:application/pdf;base64,…); ≤ 5 MB. */
|
|
6
|
+
data: string;
|
|
7
|
+
}
|
|
2
8
|
export interface FeedbackOptions {
|
|
3
9
|
/** Feedback type. Defaults to 'general'. */
|
|
4
10
|
type?: FeedbackType;
|
|
@@ -16,6 +22,8 @@ export interface FeedbackOptions {
|
|
|
16
22
|
source?: string;
|
|
17
23
|
/** Up to 3 base64-encoded data-URL images (PNG, JPEG, WebP, or GIF; each ≤ 2 MB). */
|
|
18
24
|
images?: string[];
|
|
25
|
+
/** Up to 3 PDF files ({ name, data }); each ≤ 5 MB. */
|
|
26
|
+
attachments?: FeedbackAttachment[];
|
|
19
27
|
}
|
|
20
28
|
export interface FeedbackResult {
|
|
21
29
|
success: boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bangkeut-technology/supportdock-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "SupportDock SDK — submit feedback and manage FAQs from your React Native / Expo app",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/bangkeut-technology/supportdock-sdk-js.git"
|
|
8
|
+
},
|
|
5
9
|
"main": "dist/index.js",
|
|
6
10
|
"types": "dist/index.d.ts",
|
|
7
11
|
"files": [
|