@unboundcx/sdk 1.0.2 → 1.0.3
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 +73 -54
- package/base.js +24 -16
- package/index.js +27 -15
- package/package.json +2 -2
- package/services/ai.js +62 -16
- package/services/enroll.js +48 -11
- package/services/externalOAuth.js +11 -3
- package/services/generateId.js +1 -1
- package/services/googleCalendar.js +22 -6
- package/services/layouts.js +12 -8
- package/services/login.js +12 -3
- package/services/lookup.js +1 -1
- package/services/messaging.js +140 -52
- package/services/notes.js +2 -8
- package/services/objects.js +34 -28
- package/services/phoneNumbers.js +85 -53
- package/services/portals.js +19 -4
- package/services/recordTypes.js +14 -3
- package/services/sipEndpoints.js +10 -3
- package/services/storage.js +222 -11
- package/services/subscriptions.js +19 -11
- package/services/verification.js +11 -3
- package/services/video.js +55 -22
- package/services/voice.js +169 -32
- package/services/workflows.js +122 -54
- package/test-backwards-compatibility.js +82 -51
- package/test-complete-coverage.js +113 -73
- package/test-constructor-patterns.js +32 -11
package/services/phoneNumbers.js
CHANGED
|
@@ -4,31 +4,36 @@ export class PhoneNumbersService {
|
|
|
4
4
|
this.carrier = new PhoneNumberCarrierService(sdk);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
async search({
|
|
8
|
-
type,
|
|
9
|
-
country,
|
|
10
|
-
state,
|
|
11
|
-
city,
|
|
12
|
-
startsWith,
|
|
13
|
-
endsWith,
|
|
14
|
-
contains,
|
|
15
|
-
limit,
|
|
16
|
-
minimumBlockSize,
|
|
17
|
-
sms,
|
|
18
|
-
mms,
|
|
19
|
-
voice
|
|
7
|
+
async search({
|
|
8
|
+
type,
|
|
9
|
+
country,
|
|
10
|
+
state,
|
|
11
|
+
city,
|
|
12
|
+
startsWith,
|
|
13
|
+
endsWith,
|
|
14
|
+
contains,
|
|
15
|
+
limit,
|
|
16
|
+
minimumBlockSize,
|
|
17
|
+
sms,
|
|
18
|
+
mms,
|
|
19
|
+
voice,
|
|
20
20
|
}) {
|
|
21
21
|
// Validate optional parameters
|
|
22
22
|
const validationSchema = {};
|
|
23
23
|
if ('type' in arguments[0]) validationSchema.type = { type: 'string' };
|
|
24
|
-
if ('country' in arguments[0])
|
|
24
|
+
if ('country' in arguments[0])
|
|
25
|
+
validationSchema.country = { type: 'string' };
|
|
25
26
|
if ('state' in arguments[0]) validationSchema.state = { type: 'string' };
|
|
26
27
|
if ('city' in arguments[0]) validationSchema.city = { type: 'string' };
|
|
27
|
-
if ('startsWith' in arguments[0])
|
|
28
|
-
|
|
29
|
-
if ('
|
|
28
|
+
if ('startsWith' in arguments[0])
|
|
29
|
+
validationSchema.startsWith = { type: 'string' };
|
|
30
|
+
if ('endsWith' in arguments[0])
|
|
31
|
+
validationSchema.endsWith = { type: 'string' };
|
|
32
|
+
if ('contains' in arguments[0])
|
|
33
|
+
validationSchema.contains = { type: 'string' };
|
|
30
34
|
if ('limit' in arguments[0]) validationSchema.limit = { type: 'number' };
|
|
31
|
-
if ('minimumBlockSize' in arguments[0])
|
|
35
|
+
if ('minimumBlockSize' in arguments[0])
|
|
36
|
+
validationSchema.minimumBlockSize = { type: 'number' };
|
|
32
37
|
if ('sms' in arguments[0]) validationSchema.sms = { type: 'boolean' };
|
|
33
38
|
if ('mms' in arguments[0]) validationSchema.mms = { type: 'boolean' };
|
|
34
39
|
if ('voice' in arguments[0]) validationSchema.voice = { type: 'boolean' };
|
|
@@ -38,19 +43,19 @@ export class PhoneNumbersService {
|
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
const params = {
|
|
41
|
-
query: {
|
|
42
|
-
type,
|
|
43
|
-
country,
|
|
44
|
-
state,
|
|
45
|
-
city,
|
|
46
|
-
startsWith,
|
|
47
|
-
endsWith,
|
|
48
|
-
contains,
|
|
49
|
-
limit,
|
|
50
|
-
minimumBlockSize,
|
|
51
|
-
sms,
|
|
52
|
-
mms,
|
|
53
|
-
voice
|
|
46
|
+
query: {
|
|
47
|
+
type,
|
|
48
|
+
country,
|
|
49
|
+
state,
|
|
50
|
+
city,
|
|
51
|
+
startsWith,
|
|
52
|
+
endsWith,
|
|
53
|
+
contains,
|
|
54
|
+
limit,
|
|
55
|
+
minimumBlockSize,
|
|
56
|
+
sms,
|
|
57
|
+
mms,
|
|
58
|
+
voice,
|
|
54
59
|
},
|
|
55
60
|
};
|
|
56
61
|
|
|
@@ -86,21 +91,27 @@ export class PhoneNumbersService {
|
|
|
86
91
|
},
|
|
87
92
|
);
|
|
88
93
|
|
|
89
|
-
const result = await this.sdk._fetch(
|
|
94
|
+
const result = await this.sdk._fetch(
|
|
95
|
+
`/phoneNumbers/${phoneNumber}`,
|
|
96
|
+
'DELETE',
|
|
97
|
+
);
|
|
90
98
|
return result;
|
|
91
99
|
}
|
|
92
100
|
|
|
93
|
-
async update(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
async update(
|
|
102
|
+
id,
|
|
103
|
+
{
|
|
104
|
+
name,
|
|
105
|
+
messagingWebHookUrl,
|
|
106
|
+
voiceWebHookUrl,
|
|
107
|
+
voiceAppExternalUrl,
|
|
108
|
+
voiceAppExternalMethod,
|
|
109
|
+
voiceApp,
|
|
110
|
+
voiceAppMetaData,
|
|
111
|
+
voiceRecordTypeId,
|
|
112
|
+
messagingRecordTypeId,
|
|
113
|
+
},
|
|
114
|
+
) {
|
|
104
115
|
this.sdk.validateParams(
|
|
105
116
|
{ id },
|
|
106
117
|
{
|
|
@@ -119,14 +130,18 @@ export class PhoneNumbersService {
|
|
|
119
130
|
|
|
120
131
|
const updateData = {};
|
|
121
132
|
if (name) updateData.name = name;
|
|
122
|
-
if (messagingWebHookUrl)
|
|
133
|
+
if (messagingWebHookUrl)
|
|
134
|
+
updateData.messagingWebHookUrl = messagingWebHookUrl;
|
|
123
135
|
if (voiceWebHookUrl) updateData.voiceWebHookUrl = voiceWebHookUrl;
|
|
124
|
-
if (voiceAppExternalUrl)
|
|
125
|
-
|
|
136
|
+
if (voiceAppExternalUrl)
|
|
137
|
+
updateData.voiceAppExternalUrl = voiceAppExternalUrl;
|
|
138
|
+
if (voiceAppExternalMethod)
|
|
139
|
+
updateData.voiceAppExternalMethod = voiceAppExternalMethod;
|
|
126
140
|
if (voiceApp) updateData.voiceApp = voiceApp;
|
|
127
141
|
if (voiceAppMetaData) updateData.voiceAppMetaData = voiceAppMetaData;
|
|
128
142
|
if (voiceRecordTypeId) updateData.voiceRecordTypeId = voiceRecordTypeId;
|
|
129
|
-
if (messagingRecordTypeId)
|
|
143
|
+
if (messagingRecordTypeId)
|
|
144
|
+
updateData.messagingRecordTypeId = messagingRecordTypeId;
|
|
130
145
|
|
|
131
146
|
const params = {
|
|
132
147
|
body: updateData,
|
|
@@ -149,7 +164,11 @@ export class PhoneNumbersService {
|
|
|
149
164
|
body: { cnam },
|
|
150
165
|
};
|
|
151
166
|
|
|
152
|
-
const result = await this.sdk._fetch(
|
|
167
|
+
const result = await this.sdk._fetch(
|
|
168
|
+
`/phoneNumbers/cnam/${phoneNumber}`,
|
|
169
|
+
'PUT',
|
|
170
|
+
params,
|
|
171
|
+
);
|
|
153
172
|
return result;
|
|
154
173
|
}
|
|
155
174
|
|
|
@@ -161,7 +180,10 @@ export class PhoneNumbersService {
|
|
|
161
180
|
},
|
|
162
181
|
);
|
|
163
182
|
|
|
164
|
-
const result = await this.sdk._fetch(
|
|
183
|
+
const result = await this.sdk._fetch(
|
|
184
|
+
`/phoneNumbers/format/${number}`,
|
|
185
|
+
'GET',
|
|
186
|
+
);
|
|
165
187
|
return result;
|
|
166
188
|
}
|
|
167
189
|
}
|
|
@@ -185,7 +207,11 @@ export class PhoneNumberCarrierService {
|
|
|
185
207
|
query: { updateVoiceConnection, updateMessagingConnection },
|
|
186
208
|
};
|
|
187
209
|
|
|
188
|
-
const result = await this.sdk._fetch(
|
|
210
|
+
const result = await this.sdk._fetch(
|
|
211
|
+
`/phoneNumbers/carrier/syncPhoneNumbers/${carrier}`,
|
|
212
|
+
'POST',
|
|
213
|
+
params,
|
|
214
|
+
);
|
|
189
215
|
return result;
|
|
190
216
|
}
|
|
191
217
|
|
|
@@ -197,7 +223,10 @@ export class PhoneNumberCarrierService {
|
|
|
197
223
|
},
|
|
198
224
|
);
|
|
199
225
|
|
|
200
|
-
const result = await this.sdk._fetch(
|
|
226
|
+
const result = await this.sdk._fetch(
|
|
227
|
+
`/phoneNumbers/carrier/${phoneNumber}`,
|
|
228
|
+
'GET',
|
|
229
|
+
);
|
|
201
230
|
return result;
|
|
202
231
|
}
|
|
203
232
|
|
|
@@ -209,7 +238,10 @@ export class PhoneNumberCarrierService {
|
|
|
209
238
|
},
|
|
210
239
|
);
|
|
211
240
|
|
|
212
|
-
const result = await this.sdk._fetch(
|
|
241
|
+
const result = await this.sdk._fetch(
|
|
242
|
+
`/phoneNumbers/carrier/${phoneNumber}`,
|
|
243
|
+
'DELETE',
|
|
244
|
+
);
|
|
213
245
|
return result;
|
|
214
246
|
}
|
|
215
|
-
}
|
|
247
|
+
}
|
package/services/portals.js
CHANGED
|
@@ -3,7 +3,16 @@ export class PortalsService {
|
|
|
3
3
|
this.sdk = sdk;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
async create({
|
|
6
|
+
async create({
|
|
7
|
+
name,
|
|
8
|
+
domain,
|
|
9
|
+
settings,
|
|
10
|
+
isPublic,
|
|
11
|
+
customCss,
|
|
12
|
+
customJs,
|
|
13
|
+
favicon,
|
|
14
|
+
logo,
|
|
15
|
+
}) {
|
|
7
16
|
this.sdk.validateParams(
|
|
8
17
|
{ name, domain },
|
|
9
18
|
{
|
|
@@ -34,7 +43,10 @@ export class PortalsService {
|
|
|
34
43
|
return result;
|
|
35
44
|
}
|
|
36
45
|
|
|
37
|
-
async update(
|
|
46
|
+
async update(
|
|
47
|
+
portalId,
|
|
48
|
+
{ name, domain, settings, isPublic, customCss, customJs, favicon, logo },
|
|
49
|
+
) {
|
|
38
50
|
this.sdk.validateParams(
|
|
39
51
|
{ portalId },
|
|
40
52
|
{
|
|
@@ -121,7 +133,10 @@ export class PortalsService {
|
|
|
121
133
|
},
|
|
122
134
|
);
|
|
123
135
|
|
|
124
|
-
const result = await this.sdk._fetch(
|
|
136
|
+
const result = await this.sdk._fetch(
|
|
137
|
+
`/portals/${portalId}/verify-dns`,
|
|
138
|
+
'POST',
|
|
139
|
+
);
|
|
125
140
|
return result;
|
|
126
141
|
}
|
|
127
|
-
}
|
|
142
|
+
}
|
package/services/recordTypes.js
CHANGED
|
@@ -4,7 +4,14 @@ export class RecordTypesService {
|
|
|
4
4
|
this.user = new UserRecordTypeDefaultsService(sdk);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
async create({
|
|
7
|
+
async create({
|
|
8
|
+
name,
|
|
9
|
+
description,
|
|
10
|
+
create,
|
|
11
|
+
update,
|
|
12
|
+
read,
|
|
13
|
+
delete: deleteUsers,
|
|
14
|
+
}) {
|
|
8
15
|
this.sdk.validateParams(
|
|
9
16
|
{ name, description },
|
|
10
17
|
{
|
|
@@ -150,7 +157,11 @@ export class UserRecordTypeDefaultsService {
|
|
|
150
157
|
body: deleteData,
|
|
151
158
|
};
|
|
152
159
|
|
|
153
|
-
const result = await this.sdk._fetch(
|
|
160
|
+
const result = await this.sdk._fetch(
|
|
161
|
+
'/recordTypes/user/',
|
|
162
|
+
'DELETE',
|
|
163
|
+
params,
|
|
164
|
+
);
|
|
154
165
|
return result;
|
|
155
166
|
}
|
|
156
167
|
|
|
@@ -170,4 +181,4 @@ export class UserRecordTypeDefaultsService {
|
|
|
170
181
|
const result = await this.sdk._fetch('/recordTypes/user/', 'GET', params);
|
|
171
182
|
return result;
|
|
172
183
|
}
|
|
173
|
-
}
|
|
184
|
+
}
|
package/services/sipEndpoints.js
CHANGED
|
@@ -75,7 +75,11 @@ export class SipEndpointsService {
|
|
|
75
75
|
body: updateData,
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
const result = await this.sdk._fetch(
|
|
78
|
+
const result = await this.sdk._fetch(
|
|
79
|
+
`/sipEndpoints/${endpointId}`,
|
|
80
|
+
'PUT',
|
|
81
|
+
params,
|
|
82
|
+
);
|
|
79
83
|
return result;
|
|
80
84
|
}
|
|
81
85
|
|
|
@@ -87,7 +91,10 @@ export class SipEndpointsService {
|
|
|
87
91
|
},
|
|
88
92
|
);
|
|
89
93
|
|
|
90
|
-
const result = await this.sdk._fetch(
|
|
94
|
+
const result = await this.sdk._fetch(
|
|
95
|
+
`/sipEndpoints/${endpointId}`,
|
|
96
|
+
'DELETE',
|
|
97
|
+
);
|
|
91
98
|
return result;
|
|
92
99
|
}
|
|
93
|
-
}
|
|
100
|
+
}
|
package/services/storage.js
CHANGED
|
@@ -3,6 +3,198 @@ export class StorageService {
|
|
|
3
3
|
this.sdk = sdk;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
async upload({
|
|
7
|
+
classification = 'generic',
|
|
8
|
+
folder,
|
|
9
|
+
fileName,
|
|
10
|
+
file,
|
|
11
|
+
isPublic = false,
|
|
12
|
+
country = 'US',
|
|
13
|
+
expireAfter,
|
|
14
|
+
createAccessKey = false,
|
|
15
|
+
accessKeyExpiresIn,
|
|
16
|
+
}) {
|
|
17
|
+
this.sdk.validateParams(
|
|
18
|
+
{
|
|
19
|
+
classification,
|
|
20
|
+
folder,
|
|
21
|
+
fileName,
|
|
22
|
+
file,
|
|
23
|
+
isPublic,
|
|
24
|
+
country,
|
|
25
|
+
expireAfter,
|
|
26
|
+
createAccessKey,
|
|
27
|
+
accessKeyExpiresIn,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
classification: { type: 'string', required: false },
|
|
31
|
+
folder: { type: 'string', required: false },
|
|
32
|
+
fileName: { type: 'string', required: false },
|
|
33
|
+
file: { type: 'object', required: true },
|
|
34
|
+
isPublic: { type: 'boolean', required: false },
|
|
35
|
+
country: { type: 'string', required: false },
|
|
36
|
+
expireAfter: { type: 'string', required: false },
|
|
37
|
+
createAccessKey: { type: 'boolean', required: false },
|
|
38
|
+
accessKeyExpiresIn: { type: 'string', required: false },
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const isNode = typeof window === 'undefined';
|
|
43
|
+
let formData;
|
|
44
|
+
const headers = {};
|
|
45
|
+
|
|
46
|
+
if (isNode) {
|
|
47
|
+
// Node.js environment - use direct buffer approach
|
|
48
|
+
// Create a simple body with the file buffer and metadata
|
|
49
|
+
const boundary = `----formdata-${Date.now()}-${Math.random().toString(36)}`;
|
|
50
|
+
const CRLF = '\r\n';
|
|
51
|
+
let body = '';
|
|
52
|
+
|
|
53
|
+
// Add file field with proper MIME type detection
|
|
54
|
+
let contentType = 'application/octet-stream';
|
|
55
|
+
if (fileName) {
|
|
56
|
+
try {
|
|
57
|
+
// Try to use mime-types package if available
|
|
58
|
+
const mime = await import('mime-types');
|
|
59
|
+
contentType = mime.lookup(fileName) || 'application/octet-stream';
|
|
60
|
+
} catch (error) {
|
|
61
|
+
// Fallback to basic extension mapping
|
|
62
|
+
const ext = fileName.split('.').pop().toLowerCase();
|
|
63
|
+
const commonTypes = {
|
|
64
|
+
// Documents
|
|
65
|
+
pdf: 'application/pdf',
|
|
66
|
+
doc: 'application/msword',
|
|
67
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
68
|
+
xls: 'application/vnd.ms-excel',
|
|
69
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
70
|
+
ppt: 'application/vnd.ms-powerpoint',
|
|
71
|
+
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
72
|
+
odt: 'application/vnd.oasis.opendocument.text',
|
|
73
|
+
ods: 'application/vnd.oasis.opendocument.spreadsheet',
|
|
74
|
+
odp: 'application/vnd.oasis.opendocument.presentation',
|
|
75
|
+
rtf: 'application/rtf',
|
|
76
|
+
// Images
|
|
77
|
+
jpg: 'image/jpeg',
|
|
78
|
+
jpeg: 'image/jpeg',
|
|
79
|
+
png: 'image/png',
|
|
80
|
+
gif: 'image/gif',
|
|
81
|
+
bmp: 'image/bmp',
|
|
82
|
+
webp: 'image/webp',
|
|
83
|
+
svg: 'image/svg+xml',
|
|
84
|
+
ico: 'image/x-icon',
|
|
85
|
+
tiff: 'image/tiff',
|
|
86
|
+
tif: 'image/tiff',
|
|
87
|
+
psd: 'image/vnd.adobe.photoshop',
|
|
88
|
+
raw: 'image/x-canon-cr2',
|
|
89
|
+
heic: 'image/heic',
|
|
90
|
+
heif: 'image/heif',
|
|
91
|
+
// Audio
|
|
92
|
+
mp3: 'audio/mpeg',
|
|
93
|
+
wav: 'audio/wav',
|
|
94
|
+
flac: 'audio/flac',
|
|
95
|
+
aac: 'audio/aac',
|
|
96
|
+
ogg: 'audio/ogg',
|
|
97
|
+
wma: 'audio/x-ms-wma',
|
|
98
|
+
m4a: 'audio/mp4',
|
|
99
|
+
opus: 'audio/opus',
|
|
100
|
+
// Video
|
|
101
|
+
mp4: 'video/mp4',
|
|
102
|
+
avi: 'video/avi',
|
|
103
|
+
mkv: 'video/mkv',
|
|
104
|
+
mov: 'video/quicktime',
|
|
105
|
+
wmv: 'video/x-ms-wmv',
|
|
106
|
+
flv: 'video/x-flv',
|
|
107
|
+
webm: 'video/webm',
|
|
108
|
+
// Archives
|
|
109
|
+
zip: 'application/zip',
|
|
110
|
+
rar: 'application/x-rar-compressed',
|
|
111
|
+
'7z': 'application/x-7z-compressed',
|
|
112
|
+
tar: 'application/x-tar',
|
|
113
|
+
gz: 'application/gzip',
|
|
114
|
+
// Text
|
|
115
|
+
txt: 'text/plain',
|
|
116
|
+
csv: 'text/csv',
|
|
117
|
+
json: 'application/json',
|
|
118
|
+
xml: 'application/xml',
|
|
119
|
+
html: 'text/html',
|
|
120
|
+
css: 'text/css',
|
|
121
|
+
js: 'application/javascript',
|
|
122
|
+
// Other
|
|
123
|
+
sql: 'application/sql',
|
|
124
|
+
log: 'text/plain',
|
|
125
|
+
};
|
|
126
|
+
contentType = commonTypes[ext] || 'application/octet-stream';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
body += `--${boundary}${CRLF}`;
|
|
131
|
+
body += `Content-Disposition: form-data; name="files"; filename="${fileName || 'file'}"${CRLF}`;
|
|
132
|
+
body += `Content-Type: ${contentType}${CRLF}${CRLF}`;
|
|
133
|
+
|
|
134
|
+
// Add other form fields
|
|
135
|
+
const formFields = [];
|
|
136
|
+
if (classification) formFields.push(['classification', classification]);
|
|
137
|
+
if (folder) formFields.push(['folder', folder]);
|
|
138
|
+
if (isPublic !== undefined) formFields.push(['isPublic', isPublic.toString()]);
|
|
139
|
+
if (country) formFields.push(['country', country]);
|
|
140
|
+
if (expireAfter) formFields.push(['expireAfter', expireAfter]);
|
|
141
|
+
if (createAccessKey !== undefined) formFields.push(['createAccessKey', createAccessKey.toString()]);
|
|
142
|
+
if (accessKeyExpiresIn) formFields.push(['accessKeyExpiresIn', accessKeyExpiresIn]);
|
|
143
|
+
|
|
144
|
+
// Convert to buffers and combine
|
|
145
|
+
const headerBuffer = Buffer.from(body, 'utf8');
|
|
146
|
+
const fileBuffer = Buffer.isBuffer(file) ? file : Buffer.from(file);
|
|
147
|
+
|
|
148
|
+
// Add form fields
|
|
149
|
+
let fieldsBuffer = Buffer.alloc(0);
|
|
150
|
+
for (const [name, value] of formFields) {
|
|
151
|
+
const fieldData = `${CRLF}--${boundary}${CRLF}Content-Disposition: form-data; name="${name}"${CRLF}${CRLF}${value}`;
|
|
152
|
+
fieldsBuffer = Buffer.concat([fieldsBuffer, Buffer.from(fieldData, 'utf8')]);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Final boundary
|
|
156
|
+
const endBoundary = Buffer.from(`${CRLF}--${boundary}--${CRLF}`, 'utf8');
|
|
157
|
+
|
|
158
|
+
// Combine all parts
|
|
159
|
+
formData = Buffer.concat([headerBuffer, fileBuffer, fieldsBuffer, endBoundary]);
|
|
160
|
+
|
|
161
|
+
// Set proper Content-Type header
|
|
162
|
+
headers['content-type'] = `multipart/form-data; boundary=${boundary}`;
|
|
163
|
+
} else {
|
|
164
|
+
// Browser environment - use native FormData
|
|
165
|
+
formData = new FormData();
|
|
166
|
+
|
|
167
|
+
// Add the file - handle both Buffer and File objects
|
|
168
|
+
if (Buffer.isBuffer(file)) {
|
|
169
|
+
const blob = new Blob([file]);
|
|
170
|
+
formData.append('files', blob, fileName || 'file');
|
|
171
|
+
} else if (file instanceof File) {
|
|
172
|
+
formData.append('files', file);
|
|
173
|
+
} else {
|
|
174
|
+
throw new Error('In browser environment, file must be a Buffer or File object');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Add other parameters
|
|
178
|
+
if (classification) formData.append('classification', classification);
|
|
179
|
+
if (folder) formData.append('folder', folder);
|
|
180
|
+
if (isPublic !== undefined) formData.append('isPublic', isPublic.toString());
|
|
181
|
+
if (country) formData.append('country', country);
|
|
182
|
+
if (expireAfter) formData.append('expireAfter', expireAfter);
|
|
183
|
+
if (createAccessKey !== undefined) formData.append('createAccessKey', createAccessKey.toString());
|
|
184
|
+
if (accessKeyExpiresIn) formData.append('accessKeyExpiresIn', accessKeyExpiresIn);
|
|
185
|
+
|
|
186
|
+
// Don't set Content-Type - let browser handle it automatically
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const params = {
|
|
190
|
+
body: formData,
|
|
191
|
+
headers,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const result = await this.sdk._fetch('/storage/upload', 'POST', params, true);
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
|
|
6
198
|
async uploadFiles(files, options = {}) {
|
|
7
199
|
const { classification, expireAfter, isPublic, metadata } = options;
|
|
8
200
|
|
|
@@ -33,26 +225,29 @@ export class StorageService {
|
|
|
33
225
|
formData = new FormData();
|
|
34
226
|
formData.append('files', files);
|
|
35
227
|
} else {
|
|
36
|
-
throw new Error(
|
|
228
|
+
throw new Error(
|
|
229
|
+
'Invalid files format. Expected FormData, FileList, File array, or File object',
|
|
230
|
+
);
|
|
37
231
|
}
|
|
38
232
|
|
|
39
233
|
// Add optional parameters to FormData
|
|
40
234
|
if (classification) formData.append('classification', classification);
|
|
41
235
|
if (expireAfter) formData.append('expireAfter', expireAfter);
|
|
42
|
-
if (isPublic !== undefined)
|
|
236
|
+
if (isPublic !== undefined)
|
|
237
|
+
formData.append('isPublic', isPublic.toString());
|
|
43
238
|
if (metadata) formData.append('metadata', JSON.stringify(metadata));
|
|
44
239
|
|
|
45
240
|
const params = {
|
|
46
241
|
body: formData,
|
|
47
242
|
headers: {
|
|
48
243
|
// Let browser/Node.js set Content-Type with boundary for multipart/form-data
|
|
49
|
-
}
|
|
244
|
+
},
|
|
50
245
|
};
|
|
51
246
|
|
|
52
247
|
// Remove Content-Type to let FormData set it properly
|
|
53
248
|
delete params.headers['Content-Type'];
|
|
54
249
|
|
|
55
|
-
const result = await this.sdk._fetch('/storage/upload', 'POST', params);
|
|
250
|
+
const result = await this.sdk._fetch('/storage/upload', 'POST', params, true);
|
|
56
251
|
return result;
|
|
57
252
|
}
|
|
58
253
|
|
|
@@ -70,7 +265,11 @@ export class StorageService {
|
|
|
70
265
|
params.query = { download: 'true' };
|
|
71
266
|
}
|
|
72
267
|
|
|
73
|
-
const result = await this.sdk._fetch(
|
|
268
|
+
const result = await this.sdk._fetch(
|
|
269
|
+
`/storage/file/${storageId}`,
|
|
270
|
+
'GET',
|
|
271
|
+
params,
|
|
272
|
+
);
|
|
74
273
|
return result;
|
|
75
274
|
}
|
|
76
275
|
|
|
@@ -105,7 +304,10 @@ export class StorageService {
|
|
|
105
304
|
},
|
|
106
305
|
);
|
|
107
306
|
|
|
108
|
-
const result = await this.sdk._fetch(
|
|
307
|
+
const result = await this.sdk._fetch(
|
|
308
|
+
`/storage/file/${storageId}`,
|
|
309
|
+
'DELETE',
|
|
310
|
+
);
|
|
109
311
|
return result;
|
|
110
312
|
}
|
|
111
313
|
|
|
@@ -122,7 +324,10 @@ export class StorageService {
|
|
|
122
324
|
},
|
|
123
325
|
);
|
|
124
326
|
|
|
125
|
-
const result = await this.sdk._fetch(
|
|
327
|
+
const result = await this.sdk._fetch(
|
|
328
|
+
`/storage/file/${storageId}/info`,
|
|
329
|
+
'GET',
|
|
330
|
+
);
|
|
126
331
|
return result;
|
|
127
332
|
}
|
|
128
333
|
|
|
@@ -139,7 +344,11 @@ export class StorageService {
|
|
|
139
344
|
body: { metadata },
|
|
140
345
|
};
|
|
141
346
|
|
|
142
|
-
const result = await this.sdk._fetch(
|
|
347
|
+
const result = await this.sdk._fetch(
|
|
348
|
+
`/storage/file/${storageId}/metadata`,
|
|
349
|
+
'PUT',
|
|
350
|
+
params,
|
|
351
|
+
);
|
|
143
352
|
return result;
|
|
144
353
|
}
|
|
145
354
|
|
|
@@ -148,11 +357,13 @@ export class StorageService {
|
|
|
148
357
|
|
|
149
358
|
// Validate optional parameters
|
|
150
359
|
const validationSchema = {};
|
|
151
|
-
if ('classification' in options)
|
|
360
|
+
if ('classification' in options)
|
|
361
|
+
validationSchema.classification = { type: 'string' };
|
|
152
362
|
if ('limit' in options) validationSchema.limit = { type: 'number' };
|
|
153
363
|
if ('offset' in options) validationSchema.offset = { type: 'number' };
|
|
154
364
|
if ('orderBy' in options) validationSchema.orderBy = { type: 'string' };
|
|
155
|
-
if ('orderDirection' in options)
|
|
365
|
+
if ('orderDirection' in options)
|
|
366
|
+
validationSchema.orderDirection = { type: 'string' };
|
|
156
367
|
|
|
157
368
|
if (Object.keys(validationSchema).length > 0) {
|
|
158
369
|
this.sdk.validateParams(options, validationSchema);
|
|
@@ -165,4 +376,4 @@ export class StorageService {
|
|
|
165
376
|
const result = await this.sdk._fetch('/storage/files', 'GET', params);
|
|
166
377
|
return result;
|
|
167
378
|
}
|
|
168
|
-
}
|
|
379
|
+
}
|
|
@@ -20,11 +20,15 @@ export class SocketSubscriptionsService {
|
|
|
20
20
|
|
|
21
21
|
const params = {
|
|
22
22
|
query: {
|
|
23
|
-
sessionId
|
|
24
|
-
}
|
|
25
|
-
}
|
|
23
|
+
sessionId,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
26
|
|
|
27
|
-
const result = await this.sdk._fetch(
|
|
27
|
+
const result = await this.sdk._fetch(
|
|
28
|
+
'/subscriptions/socket/connection',
|
|
29
|
+
'GET',
|
|
30
|
+
params,
|
|
31
|
+
);
|
|
28
32
|
return result;
|
|
29
33
|
}
|
|
30
34
|
|
|
@@ -41,8 +45,8 @@ export class SocketSubscriptionsService {
|
|
|
41
45
|
body: {
|
|
42
46
|
sessionId,
|
|
43
47
|
...subscriptionParams,
|
|
44
|
-
}
|
|
45
|
-
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
46
50
|
|
|
47
51
|
let uri = `/subscriptions/socket/`;
|
|
48
52
|
if (subscriptionParams?.id) {
|
|
@@ -63,11 +67,15 @@ export class SocketSubscriptionsService {
|
|
|
63
67
|
|
|
64
68
|
const params = {
|
|
65
69
|
body: {
|
|
66
|
-
sessionId
|
|
67
|
-
}
|
|
68
|
-
}
|
|
70
|
+
sessionId,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
69
73
|
|
|
70
|
-
const result = await this.sdk._fetch(
|
|
74
|
+
const result = await this.sdk._fetch(
|
|
75
|
+
`/subscriptions/socket/${id}`,
|
|
76
|
+
'DELETE',
|
|
77
|
+
params,
|
|
78
|
+
);
|
|
71
79
|
return result;
|
|
72
80
|
}
|
|
73
|
-
}
|
|
81
|
+
}
|
package/services/verification.js
CHANGED
|
@@ -40,7 +40,11 @@ export class VerificationService {
|
|
|
40
40
|
body: { phoneNumber, code },
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
const result = await this.sdk._fetch(
|
|
43
|
+
const result = await this.sdk._fetch(
|
|
44
|
+
'/verification/sms/validate',
|
|
45
|
+
'POST',
|
|
46
|
+
params,
|
|
47
|
+
);
|
|
44
48
|
return result;
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -81,7 +85,11 @@ export class VerificationService {
|
|
|
81
85
|
body: { email, code },
|
|
82
86
|
};
|
|
83
87
|
|
|
84
|
-
const result = await this.sdk._fetch(
|
|
88
|
+
const result = await this.sdk._fetch(
|
|
89
|
+
'/verification/email/validate',
|
|
90
|
+
'POST',
|
|
91
|
+
params,
|
|
92
|
+
);
|
|
85
93
|
return result;
|
|
86
94
|
}
|
|
87
|
-
}
|
|
95
|
+
}
|