@bangkeut-technology/supportdock-sdk 0.2.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/LICENSE +21 -0
- package/README.md +18 -0
- package/dist/client.js +19 -5
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +8 -0
- package/package.json +5 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SupportDock
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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,7 +55,20 @@ class SupportDockClient {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
|
|
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
|
+
}
|
|
71
|
+
return this.request('/api/v1/feedback/remote', {
|
|
59
72
|
method: 'POST',
|
|
60
73
|
body: JSON.stringify({
|
|
61
74
|
type: options.type ?? 'general',
|
|
@@ -66,31 +79,32 @@ 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
|
}
|
|
72
86
|
// ─── FAQ ─────────────────────────────────────────────────────
|
|
73
87
|
/** List all FAQ entries for this app. */
|
|
74
88
|
async listFAQs() {
|
|
75
|
-
return this.request('/api/faqs/remote');
|
|
89
|
+
return this.request('/api/v1/faqs/remote');
|
|
76
90
|
}
|
|
77
91
|
/** Create a new FAQ entry. */
|
|
78
92
|
async createFAQ(options) {
|
|
79
|
-
return this.request('/api/faqs/remote', {
|
|
93
|
+
return this.request('/api/v1/faqs/remote', {
|
|
80
94
|
method: 'POST',
|
|
81
95
|
body: JSON.stringify(options),
|
|
82
96
|
});
|
|
83
97
|
}
|
|
84
98
|
/** Update an existing FAQ entry. */
|
|
85
99
|
async updateFAQ(faqId, options) {
|
|
86
|
-
return this.request(`/api/faqs/remote/${faqId}`, {
|
|
100
|
+
return this.request(`/api/v1/faqs/remote/${faqId}`, {
|
|
87
101
|
method: 'PATCH',
|
|
88
102
|
body: JSON.stringify(options),
|
|
89
103
|
});
|
|
90
104
|
}
|
|
91
105
|
/** Delete a FAQ entry. */
|
|
92
106
|
async deleteFAQ(faqId) {
|
|
93
|
-
return this.request(`/api/faqs/remote/${faqId}`, {
|
|
107
|
+
return this.request(`/api/v1/faqs/remote/${faqId}`, {
|
|
94
108
|
method: 'DELETE',
|
|
95
109
|
});
|
|
96
110
|
}
|
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": [
|