@gofynd/fdk-client-javascript 1.0.1 → 1.0.2
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/documentation/application/CART.md +251 -251
- package/documentation/application/CATALOG.md +414 -414
- package/documentation/application/CONTENT.md +15 -1
- package/documentation/application/ORDER.md +290 -290
- package/documentation/application/PAYMENT.md +255 -255
- package/documentation/application/POSCART.md +297 -297
- package/documentation/platform/CART.md +499 -499
- package/documentation/platform/CATALOG.md +3088 -2702
- package/documentation/platform/COMPANYPROFILE.md +201 -201
- package/documentation/platform/CONTENT.md +123 -1
- package/documentation/platform/ORDER.md +1233 -1158
- package/documentation/platform/PARTNER.md +7 -7
- package/documentation/platform/PAYMENT.md +83 -83
- package/package.json +1 -1
- package/sdk/application/ApplicationConfig.js +1 -1
- package/sdk/application/Cart/CartApplicationClient.js +619 -108
- package/sdk/application/Cart/CartApplicationModel.d.ts +7 -7
- package/sdk/application/Cart/CartApplicationModel.js +335 -335
- package/sdk/application/Catalog/CatalogApplicationClient.d.ts +1 -1
- package/sdk/application/Catalog/CatalogApplicationClient.js +730 -134
- package/sdk/application/Catalog/CatalogApplicationModel.d.ts +21 -21
- package/sdk/application/Catalog/CatalogApplicationModel.js +547 -547
- package/sdk/application/Common/CommonApplicationClient.js +48 -8
- package/sdk/application/Communication/CommunicationApplicationClient.js +75 -14
- package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +1 -1
- package/sdk/application/Configuration/ConfigurationApplicationClient.js +392 -66
- package/sdk/application/Content/ContentApplicationClient.js +444 -76
- package/sdk/application/Content/ContentApplicationModel.d.ts +1 -0
- package/sdk/application/Content/ContentApplicationModel.js +11 -1
- package/sdk/application/FileStorage/FileStorageApplicationClient.js +74 -12
- package/sdk/application/Lead/LeadApplicationClient.js +164 -30
- package/sdk/application/Logistic/LogisticApplicationClient.js +98 -16
- package/sdk/application/Order/OrderApplicationClient.d.ts +1 -1
- package/sdk/application/Order/OrderApplicationClient.js +287 -54
- package/sdk/application/Order/OrderApplicationModel.d.ts +19 -19
- package/sdk/application/Order/OrderApplicationModel.js +357 -357
- package/sdk/application/Payment/PaymentApplicationClient.js +961 -186
- package/sdk/application/Payment/PaymentApplicationModel.d.ts +3 -3
- package/sdk/application/Payment/PaymentApplicationModel.js +352 -352
- package/sdk/application/PosCart/PosCartApplicationClient.js +645 -114
- package/sdk/application/PosCart/PosCartApplicationModel.d.ts +15 -15
- package/sdk/application/PosCart/PosCartApplicationModel.js +389 -389
- package/sdk/application/Rewards/RewardsApplicationClient.js +168 -28
- package/sdk/application/Share/ShareApplicationClient.js +157 -32
- package/sdk/application/Theme/ThemeApplicationClient.js +94 -16
- package/sdk/application/User/UserApplicationClient.js +806 -148
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +16 -8
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +191 -34
- package/sdk/platform/Analytics/AnalyticsPlatformClient.d.ts +8 -4
- package/sdk/platform/Analytics/AnalyticsPlatformClient.js +103 -16
- package/sdk/platform/AuditTrail/AuditTrailPlatformClient.d.ts +8 -4
- package/sdk/platform/AuditTrail/AuditTrailPlatformClient.js +103 -16
- package/sdk/platform/Billing/BillingPlatformClient.d.ts +24 -12
- package/sdk/platform/Billing/BillingPlatformClient.js +299 -54
- package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +34 -17
- package/sdk/platform/Cart/CartPlatformApplicationClient.js +409 -72
- package/sdk/platform/Cart/CartPlatformModel.d.ts +35 -35
- package/sdk/platform/Cart/CartPlatformModel.js +617 -617
- package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +167 -114
- package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +1562 -453
- package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.d.ts +8 -8
- package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +39 -39
- package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +314 -196
- package/sdk/platform/Catalog/CatalogPlatformClient.js +2459 -718
- package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +103 -94
- package/sdk/platform/Catalog/CatalogPlatformModel.js +2063 -1797
- package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +17 -15
- package/sdk/platform/Catalog/CatalogPlatformValidator.js +95 -76
- package/sdk/platform/Common/CommonPlatformClient.d.ts +4 -2
- package/sdk/platform/Common/CommonPlatformClient.js +51 -8
- package/sdk/platform/Communication/CommunicationPlatformApplicationClient.d.ts +80 -40
- package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +1000 -168
- package/sdk/platform/Communication/CommunicationPlatformClient.d.ts +2 -1
- package/sdk/platform/Communication/CommunicationPlatformClient.js +28 -4
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.d.ts +27 -14
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +335 -54
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.d.ts +10 -10
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +278 -278
- package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.d.ts +56 -28
- package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +702 -118
- package/sdk/platform/Configuration/ConfigurationPlatformClient.d.ts +36 -18
- package/sdk/platform/Configuration/ConfigurationPlatformClient.js +457 -82
- package/sdk/platform/Content/ContentPlatformApplicationClient.d.ts +148 -67
- package/sdk/platform/Content/ContentPlatformApplicationClient.js +1724 -284
- package/sdk/platform/Content/ContentPlatformApplicationValidator.d.ts +1 -0
- package/sdk/platform/Content/ContentPlatformApplicationValidator.js +7 -0
- package/sdk/platform/Content/ContentPlatformModel.d.ts +4 -0
- package/sdk/platform/Content/ContentPlatformModel.js +43 -1
- package/sdk/platform/Discount/DiscountPlatformClient.d.ts +21 -10
- package/sdk/platform/Discount/DiscountPlatformClient.js +270 -44
- package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.d.ts +8 -4
- package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.js +102 -16
- package/sdk/platform/FileStorage/FileStoragePlatformClient.d.ts +12 -6
- package/sdk/platform/FileStorage/FileStoragePlatformClient.js +150 -24
- package/sdk/platform/Inventory/InventoryPlatformClient.d.ts +27 -14
- package/sdk/platform/Inventory/InventoryPlatformClient.js +316 -52
- package/sdk/platform/Lead/LeadPlatformApplicationClient.d.ts +26 -13
- package/sdk/platform/Lead/LeadPlatformApplicationClient.js +311 -52
- package/sdk/platform/Lead/LeadPlatformClient.d.ts +22 -11
- package/sdk/platform/Lead/LeadPlatformClient.js +266 -44
- package/sdk/platform/OAuthClient.js +8 -8
- package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +6 -3
- package/sdk/platform/Order/OrderPlatformApplicationClient.js +78 -14
- package/sdk/platform/Order/OrderPlatformClient.d.ts +95 -43
- package/sdk/platform/Order/OrderPlatformClient.js +1062 -180
- package/sdk/platform/Order/OrderPlatformModel.d.ts +64 -60
- package/sdk/platform/Order/OrderPlatformModel.js +1481 -1425
- package/sdk/platform/Order/OrderPlatformValidator.js +5 -0
- package/sdk/platform/Partner/PartnerPlatformApplicationClient.d.ts +4 -2
- package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +52 -8
- package/sdk/platform/Partner/PartnerPlatformModel.d.ts +1 -1
- package/sdk/platform/Partner/PartnerPlatformModel.js +8 -8
- package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +22 -11
- package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +287 -56
- package/sdk/platform/Payment/PaymentPlatformClient.d.ts +21 -11
- package/sdk/platform/Payment/PaymentPlatformClient.js +263 -48
- package/sdk/platform/Payment/PaymentPlatformModel.js +122 -122
- package/sdk/platform/PlatformApplicationClient.d.ts +2959 -2787
- package/sdk/platform/PlatformApplicationClient.js +3420 -3212
- package/sdk/platform/PlatformClient.d.ts +2959 -2787
- package/sdk/platform/PlatformClient.js +3420 -3212
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.d.ts +26 -13
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +308 -54
- package/sdk/platform/Share/SharePlatformApplicationClient.d.ts +8 -4
- package/sdk/platform/Share/SharePlatformApplicationClient.js +94 -16
- package/sdk/platform/Theme/ThemePlatformApplicationClient.d.ts +47 -23
- package/sdk/platform/Theme/ThemePlatformApplicationClient.js +571 -96
- package/sdk/platform/User/UserPlatformApplicationClient.d.ts +24 -12
- package/sdk/platform/User/UserPlatformApplicationClient.js +296 -48
- package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +12 -6
- package/sdk/platform/Webhook/WebhookPlatformClient.js +157 -30
- package/sdk/public/Configuration/ConfigurationPublicClient.js +51 -8
- package/sdk/public/Inventory/InventoryPublicClient.js +149 -26
- package/sdk/public/Webhook/WebhookPublicClient.js +51 -10
|
@@ -2,6 +2,8 @@ const Paginator = require("../../common/Paginator");
|
|
|
2
2
|
const PlatformAPIClient = require("../PlatformAPIClient");
|
|
3
3
|
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
4
4
|
const FileStorageValidator = require("./FileStoragePlatformApplicationValidator");
|
|
5
|
+
const FileStorageModel = require("./FileStoragePlatformModel");
|
|
6
|
+
const { Logger } = require("./../../common/Logger");
|
|
5
7
|
|
|
6
8
|
class FileStorage {
|
|
7
9
|
constructor(config, applicationId) {
|
|
@@ -13,6 +15,7 @@ class FileStorage {
|
|
|
13
15
|
* @param {Object} arg - Arg object.
|
|
14
16
|
* @param {string} arg.namespace - Bucket name
|
|
15
17
|
* @param {StartRequest} arg.body
|
|
18
|
+
* @returns {Promise<StartResponse>} - Success response
|
|
16
19
|
* @summary: This operation initiates upload and returns storage link which is valid for 30 Minutes. You can use that storage link to make subsequent upload request with file buffer or blob.
|
|
17
20
|
* @description: Uploads an arbitrarily sized buffer or blob.
|
|
18
21
|
*
|
|
@@ -33,7 +36,7 @@ class FileStorage {
|
|
|
33
36
|
* After successfully upload, call `appCompleteUpload` api to complete the upload process.
|
|
34
37
|
* This operation will return the url for the uploaded file.
|
|
35
38
|
*/
|
|
36
|
-
appStartUpload({ namespace, body } = {}) {
|
|
39
|
+
async appStartUpload({ namespace, body } = {}) {
|
|
37
40
|
const { error } = FileStorageValidator.appStartUpload().validate(
|
|
38
41
|
{
|
|
39
42
|
namespace,
|
|
@@ -54,25 +57,46 @@ class FileStorage {
|
|
|
54
57
|
{ abortEarly: false, allowUnknown: false }
|
|
55
58
|
);
|
|
56
59
|
if (warrning) {
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
Logger({
|
|
61
|
+
level: "WARN",
|
|
62
|
+
message: "Parameter Validation warrnings for appStartUpload",
|
|
63
|
+
});
|
|
64
|
+
Logger({ level: "WARN", message: warrning });
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
const query_params = {};
|
|
62
68
|
|
|
63
|
-
|
|
69
|
+
const response = await PlatformAPIClient.execute(
|
|
64
70
|
this.config,
|
|
65
71
|
"post",
|
|
66
72
|
`/service/platform/assets/v1.0/company/${this.config.companyId}/application/${this.applicationId}/namespaces/${namespace}/upload/start/`,
|
|
67
73
|
query_params,
|
|
68
74
|
body
|
|
69
75
|
);
|
|
76
|
+
|
|
77
|
+
const {
|
|
78
|
+
error: res_error,
|
|
79
|
+
} = FileStorageModel.StartResponse().validate(response, {
|
|
80
|
+
abortEarly: false,
|
|
81
|
+
allowUnknown: false,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (res_error) {
|
|
85
|
+
Logger({
|
|
86
|
+
level: "WARN",
|
|
87
|
+
message: "Response Validation Warnnings for appStartUpload",
|
|
88
|
+
});
|
|
89
|
+
Logger({ level: "WARN", message: res_error });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return response;
|
|
70
93
|
}
|
|
71
94
|
|
|
72
95
|
/**
|
|
73
96
|
* @param {Object} arg - Arg object.
|
|
74
97
|
* @param {string} arg.namespace - Bucket name
|
|
75
98
|
* @param {StartResponse} arg.body
|
|
99
|
+
* @returns {Promise<CompleteResponse>} - Success response
|
|
76
100
|
* @summary: This will complete the upload process. After successfully uploading file, you can call this operation to complete the upload process.
|
|
77
101
|
* @description: Uploads an arbitrarily sized buffer or blob.
|
|
78
102
|
*
|
|
@@ -93,7 +117,7 @@ class FileStorage {
|
|
|
93
117
|
* After successfully upload, call `appCompleteUpload` api to complete the upload process.
|
|
94
118
|
* This operation will return the url for the uploaded file.
|
|
95
119
|
*/
|
|
96
|
-
appCompleteUpload({ namespace, body } = {}) {
|
|
120
|
+
async appCompleteUpload({ namespace, body } = {}) {
|
|
97
121
|
const { error } = FileStorageValidator.appCompleteUpload().validate(
|
|
98
122
|
{
|
|
99
123
|
namespace,
|
|
@@ -116,29 +140,50 @@ class FileStorage {
|
|
|
116
140
|
{ abortEarly: false, allowUnknown: false }
|
|
117
141
|
);
|
|
118
142
|
if (warrning) {
|
|
119
|
-
|
|
120
|
-
|
|
143
|
+
Logger({
|
|
144
|
+
level: "WARN",
|
|
145
|
+
message: "Parameter Validation warrnings for appCompleteUpload",
|
|
146
|
+
});
|
|
147
|
+
Logger({ level: "WARN", message: warrning });
|
|
121
148
|
}
|
|
122
149
|
|
|
123
150
|
const query_params = {};
|
|
124
151
|
|
|
125
|
-
|
|
152
|
+
const response = await PlatformAPIClient.execute(
|
|
126
153
|
this.config,
|
|
127
154
|
"post",
|
|
128
155
|
`/service/platform/assets/v1.0/company/${this.config.companyId}/application/${this.applicationId}/namespaces/${namespace}/upload/complete/`,
|
|
129
156
|
query_params,
|
|
130
157
|
body
|
|
131
158
|
);
|
|
159
|
+
|
|
160
|
+
const {
|
|
161
|
+
error: res_error,
|
|
162
|
+
} = FileStorageModel.CompleteResponse().validate(response, {
|
|
163
|
+
abortEarly: false,
|
|
164
|
+
allowUnknown: false,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
if (res_error) {
|
|
168
|
+
Logger({
|
|
169
|
+
level: "WARN",
|
|
170
|
+
message: "Response Validation Warnnings for appCompleteUpload",
|
|
171
|
+
});
|
|
172
|
+
Logger({ level: "WARN", message: res_error });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return response;
|
|
132
176
|
}
|
|
133
177
|
|
|
134
178
|
/**
|
|
135
179
|
* @param {Object} arg - Arg object.
|
|
136
180
|
* @param {boolean} [arg.sync] - Sync
|
|
137
181
|
* @param {BulkRequest} arg.body
|
|
182
|
+
* @returns {Promise<BulkUploadResponse>} - Success response
|
|
138
183
|
* @summary: Copy Files
|
|
139
184
|
* @description: Copy Files
|
|
140
185
|
*/
|
|
141
|
-
appCopyFiles({ body, sync } = {}) {
|
|
186
|
+
async appCopyFiles({ body, sync } = {}) {
|
|
142
187
|
const { error } = FileStorageValidator.appCopyFiles().validate(
|
|
143
188
|
{
|
|
144
189
|
body,
|
|
@@ -159,30 +204,51 @@ class FileStorage {
|
|
|
159
204
|
{ abortEarly: false, allowUnknown: false }
|
|
160
205
|
);
|
|
161
206
|
if (warrning) {
|
|
162
|
-
|
|
163
|
-
|
|
207
|
+
Logger({
|
|
208
|
+
level: "WARN",
|
|
209
|
+
message: "Parameter Validation warrnings for appCopyFiles",
|
|
210
|
+
});
|
|
211
|
+
Logger({ level: "WARN", message: warrning });
|
|
164
212
|
}
|
|
165
213
|
|
|
166
214
|
const query_params = {};
|
|
167
215
|
query_params["sync"] = sync;
|
|
168
216
|
|
|
169
|
-
|
|
217
|
+
const response = await PlatformAPIClient.execute(
|
|
170
218
|
this.config,
|
|
171
219
|
"post",
|
|
172
220
|
`/service/platform/assets/v1.0/company/${this.config.companyId}/application/${this.applicationId}/uploads/copy/`,
|
|
173
221
|
query_params,
|
|
174
222
|
body
|
|
175
223
|
);
|
|
224
|
+
|
|
225
|
+
const {
|
|
226
|
+
error: res_error,
|
|
227
|
+
} = FileStorageModel.BulkUploadResponse().validate(response, {
|
|
228
|
+
abortEarly: false,
|
|
229
|
+
allowUnknown: false,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
if (res_error) {
|
|
233
|
+
Logger({
|
|
234
|
+
level: "WARN",
|
|
235
|
+
message: "Response Validation Warnnings for appCopyFiles",
|
|
236
|
+
});
|
|
237
|
+
Logger({ level: "WARN", message: res_error });
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return response;
|
|
176
241
|
}
|
|
177
242
|
|
|
178
243
|
/**
|
|
179
244
|
* @param {Object} arg - Arg object.
|
|
180
245
|
* @param {string} arg.namespace - Bucket name
|
|
181
246
|
* @param {number} [arg.pageNo] - Page no
|
|
247
|
+
* @returns {Promise<BrowseResponse>} - Success response
|
|
182
248
|
* @summary: Browse Files
|
|
183
249
|
* @description: Browse Files
|
|
184
250
|
*/
|
|
185
|
-
browse({ namespace, pageNo } = {}) {
|
|
251
|
+
async browse({ namespace, pageNo } = {}) {
|
|
186
252
|
const { error } = FileStorageValidator.browse().validate(
|
|
187
253
|
{
|
|
188
254
|
namespace,
|
|
@@ -203,20 +269,40 @@ class FileStorage {
|
|
|
203
269
|
{ abortEarly: false, allowUnknown: false }
|
|
204
270
|
);
|
|
205
271
|
if (warrning) {
|
|
206
|
-
|
|
207
|
-
|
|
272
|
+
Logger({
|
|
273
|
+
level: "WARN",
|
|
274
|
+
message: "Parameter Validation warrnings for browse",
|
|
275
|
+
});
|
|
276
|
+
Logger({ level: "WARN", message: warrning });
|
|
208
277
|
}
|
|
209
278
|
|
|
210
279
|
const query_params = {};
|
|
211
280
|
query_params["page_no"] = pageNo;
|
|
212
281
|
|
|
213
|
-
|
|
282
|
+
const response = await PlatformAPIClient.execute(
|
|
214
283
|
this.config,
|
|
215
284
|
"get",
|
|
216
285
|
`/service/platform/assets/v1.0/company/${this.config.companyId}/application/${this.applicationId}/namespaces/${namespace}/browse/`,
|
|
217
286
|
query_params,
|
|
218
287
|
undefined
|
|
219
288
|
);
|
|
289
|
+
|
|
290
|
+
const {
|
|
291
|
+
error: res_error,
|
|
292
|
+
} = FileStorageModel.BrowseResponse().validate(response, {
|
|
293
|
+
abortEarly: false,
|
|
294
|
+
allowUnknown: false,
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
if (res_error) {
|
|
298
|
+
Logger({
|
|
299
|
+
level: "WARN",
|
|
300
|
+
message: "Response Validation Warnnings for browse",
|
|
301
|
+
});
|
|
302
|
+
Logger({ level: "WARN", message: res_error });
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return response;
|
|
220
306
|
}
|
|
221
307
|
|
|
222
308
|
/**
|
|
@@ -6,6 +6,7 @@ declare class FileStorage {
|
|
|
6
6
|
* @param {Object} arg - Arg object.
|
|
7
7
|
* @param {string} arg.namespace - Bucket name
|
|
8
8
|
* @param {StartRequest} arg.body
|
|
9
|
+
* @returns {Promise<StartResponse>} - Success response
|
|
9
10
|
* @summary: This operation initiates upload and returns storage link which is valid for 30 Minutes. You can use that storage link to make subsequent upload request with file buffer or blob.
|
|
10
11
|
* @description: Uploads an arbitrarily sized buffer or blob.
|
|
11
12
|
*
|
|
@@ -29,11 +30,12 @@ declare class FileStorage {
|
|
|
29
30
|
startUpload({ namespace, body }?: {
|
|
30
31
|
namespace: string;
|
|
31
32
|
body: StartRequest;
|
|
32
|
-
}): Promise<
|
|
33
|
+
}): Promise<StartResponse>;
|
|
33
34
|
/**
|
|
34
35
|
* @param {Object} arg - Arg object.
|
|
35
36
|
* @param {string} arg.namespace - Bucket name
|
|
36
37
|
* @param {StartResponse} arg.body
|
|
38
|
+
* @returns {Promise<CompleteResponse>} - Success response
|
|
37
39
|
* @summary: This will complete the upload process. After successfully uploading file, you can call this operation to complete the upload process.
|
|
38
40
|
* @description: Uploads an arbitrarily sized buffer or blob.
|
|
39
41
|
*
|
|
@@ -57,38 +59,41 @@ declare class FileStorage {
|
|
|
57
59
|
completeUpload({ namespace, body }?: {
|
|
58
60
|
namespace: string;
|
|
59
61
|
body: StartResponse;
|
|
60
|
-
}): Promise<
|
|
62
|
+
}): Promise<CompleteResponse>;
|
|
61
63
|
/**
|
|
62
64
|
* @param {Object} arg - Arg object.
|
|
63
65
|
* @param {SignUrlRequest} arg.body
|
|
66
|
+
* @returns {Promise<SignUrlResponse>} - Success response
|
|
64
67
|
* @summary: Gives signed urls to access private files
|
|
65
68
|
* @description: Describe here
|
|
66
69
|
*/
|
|
67
70
|
getSignUrls({ body }?: {
|
|
68
71
|
body: SignUrlRequest;
|
|
69
|
-
}): Promise<
|
|
72
|
+
}): Promise<SignUrlResponse>;
|
|
70
73
|
/**
|
|
71
74
|
* @param {Object} arg - Arg object.
|
|
72
75
|
* @param {boolean} [arg.sync] - Sync
|
|
73
76
|
* @param {BulkRequest} arg.body
|
|
77
|
+
* @returns {Promise<BulkUploadResponse>} - Success response
|
|
74
78
|
* @summary: Copy Files
|
|
75
79
|
* @description: Copy Files
|
|
76
80
|
*/
|
|
77
81
|
copyFiles({ body, sync }?: {
|
|
78
82
|
sync?: boolean;
|
|
79
83
|
body: BulkRequest;
|
|
80
|
-
}): Promise<
|
|
84
|
+
}): Promise<BulkUploadResponse>;
|
|
81
85
|
/**
|
|
82
86
|
* @param {Object} arg - Arg object.
|
|
83
87
|
* @param {string} arg.namespace - Bucket name
|
|
84
88
|
* @param {number} [arg.pageNo] - Page no
|
|
89
|
+
* @returns {Promise<BrowseResponse>} - Success response
|
|
85
90
|
* @summary: Browse Files
|
|
86
91
|
* @description: Browse Files
|
|
87
92
|
*/
|
|
88
93
|
browse({ namespace, pageNo }?: {
|
|
89
94
|
namespace: string;
|
|
90
95
|
pageNo?: number;
|
|
91
|
-
}): Promise<
|
|
96
|
+
}): Promise<BrowseResponse>;
|
|
92
97
|
/**
|
|
93
98
|
* @param {Object} arg - Arg object.
|
|
94
99
|
* @param {string} arg.namespace - Bucket name
|
|
@@ -101,12 +106,13 @@ declare class FileStorage {
|
|
|
101
106
|
/**
|
|
102
107
|
* @param {Object} arg - Arg object.
|
|
103
108
|
* @param {string} arg.url - Url
|
|
109
|
+
* @returns {Promise<string>} - Success response
|
|
104
110
|
* @summary: Proxy
|
|
105
111
|
* @description: Proxy
|
|
106
112
|
*/
|
|
107
113
|
proxy({ url }?: {
|
|
108
114
|
url: string;
|
|
109
|
-
}): Promise<
|
|
115
|
+
}): Promise<string>;
|
|
110
116
|
/**
|
|
111
117
|
* @param data
|
|
112
118
|
* @param {string} file_name
|
|
@@ -2,6 +2,9 @@ const Paginator = require("../../common/Paginator");
|
|
|
2
2
|
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
3
3
|
const PlatformAPIClient = require("../PlatformAPIClient");
|
|
4
4
|
const FileStorageValidator = require("./FileStoragePlatformValidator");
|
|
5
|
+
const FileStorageModel = require("./FileStoragePlatformModel");
|
|
6
|
+
const { Logger } = require("./../../common/Logger");
|
|
7
|
+
|
|
5
8
|
class FileStorage {
|
|
6
9
|
constructor(config) {
|
|
7
10
|
this.config = config;
|
|
@@ -11,6 +14,7 @@ class FileStorage {
|
|
|
11
14
|
* @param {Object} arg - Arg object.
|
|
12
15
|
* @param {string} arg.namespace - Bucket name
|
|
13
16
|
* @param {StartRequest} arg.body
|
|
17
|
+
* @returns {Promise<StartResponse>} - Success response
|
|
14
18
|
* @summary: This operation initiates upload and returns storage link which is valid for 30 Minutes. You can use that storage link to make subsequent upload request with file buffer or blob.
|
|
15
19
|
* @description: Uploads an arbitrarily sized buffer or blob.
|
|
16
20
|
*
|
|
@@ -31,7 +35,7 @@ class FileStorage {
|
|
|
31
35
|
* After successfully upload, call `completeUpload` api to complete the upload process.
|
|
32
36
|
* This operation will return the url for the uploaded file.
|
|
33
37
|
*/
|
|
34
|
-
startUpload({ namespace, body } = {}) {
|
|
38
|
+
async startUpload({ namespace, body } = {}) {
|
|
35
39
|
const { error } = FileStorageValidator.startUpload().validate(
|
|
36
40
|
{
|
|
37
41
|
namespace,
|
|
@@ -52,15 +56,18 @@ class FileStorage {
|
|
|
52
56
|
{ abortEarly: false, allowUnknown: false }
|
|
53
57
|
);
|
|
54
58
|
if (warrning) {
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
Logger({
|
|
60
|
+
level: "WARN",
|
|
61
|
+
message: "Parameter Validation warrnings for startUpload",
|
|
62
|
+
});
|
|
63
|
+
Logger({ level: "WARN", message: warrning });
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
const query_params = {};
|
|
60
67
|
|
|
61
68
|
const xHeaders = {};
|
|
62
69
|
|
|
63
|
-
|
|
70
|
+
const response = await PlatformAPIClient.execute(
|
|
64
71
|
this.config,
|
|
65
72
|
"post",
|
|
66
73
|
`/service/platform/assets/v1.0/company/${this.config.companyId}/namespaces/${namespace}/upload/start/`,
|
|
@@ -68,12 +75,30 @@ class FileStorage {
|
|
|
68
75
|
body,
|
|
69
76
|
xHeaders
|
|
70
77
|
);
|
|
78
|
+
|
|
79
|
+
const {
|
|
80
|
+
error: res_error,
|
|
81
|
+
} = FileStorageModel.StartResponse().validate(response, {
|
|
82
|
+
abortEarly: false,
|
|
83
|
+
allowUnknown: false,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (res_error) {
|
|
87
|
+
Logger({
|
|
88
|
+
level: "WARN",
|
|
89
|
+
message: "Response Validation Warnnings for startUpload",
|
|
90
|
+
});
|
|
91
|
+
Logger({ level: "WARN", message: res_error });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return response;
|
|
71
95
|
}
|
|
72
96
|
|
|
73
97
|
/**
|
|
74
98
|
* @param {Object} arg - Arg object.
|
|
75
99
|
* @param {string} arg.namespace - Bucket name
|
|
76
100
|
* @param {StartResponse} arg.body
|
|
101
|
+
* @returns {Promise<CompleteResponse>} - Success response
|
|
77
102
|
* @summary: This will complete the upload process. After successfully uploading file, you can call this operation to complete the upload process.
|
|
78
103
|
* @description: Uploads an arbitrarily sized buffer or blob.
|
|
79
104
|
*
|
|
@@ -94,7 +119,7 @@ class FileStorage {
|
|
|
94
119
|
* After successfully upload, call `completeUpload` api to complete the upload process.
|
|
95
120
|
* This operation will return the url for the uploaded file.
|
|
96
121
|
*/
|
|
97
|
-
completeUpload({ namespace, body } = {}) {
|
|
122
|
+
async completeUpload({ namespace, body } = {}) {
|
|
98
123
|
const { error } = FileStorageValidator.completeUpload().validate(
|
|
99
124
|
{
|
|
100
125
|
namespace,
|
|
@@ -115,15 +140,18 @@ class FileStorage {
|
|
|
115
140
|
{ abortEarly: false, allowUnknown: false }
|
|
116
141
|
);
|
|
117
142
|
if (warrning) {
|
|
118
|
-
|
|
119
|
-
|
|
143
|
+
Logger({
|
|
144
|
+
level: "WARN",
|
|
145
|
+
message: "Parameter Validation warrnings for completeUpload",
|
|
146
|
+
});
|
|
147
|
+
Logger({ level: "WARN", message: warrning });
|
|
120
148
|
}
|
|
121
149
|
|
|
122
150
|
const query_params = {};
|
|
123
151
|
|
|
124
152
|
const xHeaders = {};
|
|
125
153
|
|
|
126
|
-
|
|
154
|
+
const response = await PlatformAPIClient.execute(
|
|
127
155
|
this.config,
|
|
128
156
|
"post",
|
|
129
157
|
`/service/platform/assets/v1.0/company/${this.config.companyId}/namespaces/${namespace}/upload/complete/`,
|
|
@@ -131,15 +159,33 @@ class FileStorage {
|
|
|
131
159
|
body,
|
|
132
160
|
xHeaders
|
|
133
161
|
);
|
|
162
|
+
|
|
163
|
+
const {
|
|
164
|
+
error: res_error,
|
|
165
|
+
} = FileStorageModel.CompleteResponse().validate(response, {
|
|
166
|
+
abortEarly: false,
|
|
167
|
+
allowUnknown: false,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (res_error) {
|
|
171
|
+
Logger({
|
|
172
|
+
level: "WARN",
|
|
173
|
+
message: "Response Validation Warnnings for completeUpload",
|
|
174
|
+
});
|
|
175
|
+
Logger({ level: "WARN", message: res_error });
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return response;
|
|
134
179
|
}
|
|
135
180
|
|
|
136
181
|
/**
|
|
137
182
|
* @param {Object} arg - Arg object.
|
|
138
183
|
* @param {SignUrlRequest} arg.body
|
|
184
|
+
* @returns {Promise<SignUrlResponse>} - Success response
|
|
139
185
|
* @summary: Gives signed urls to access private files
|
|
140
186
|
* @description: Describe here
|
|
141
187
|
*/
|
|
142
|
-
getSignUrls({ body } = {}) {
|
|
188
|
+
async getSignUrls({ body } = {}) {
|
|
143
189
|
const { error } = FileStorageValidator.getSignUrls().validate(
|
|
144
190
|
{
|
|
145
191
|
body,
|
|
@@ -158,15 +204,18 @@ class FileStorage {
|
|
|
158
204
|
{ abortEarly: false, allowUnknown: false }
|
|
159
205
|
);
|
|
160
206
|
if (warrning) {
|
|
161
|
-
|
|
162
|
-
|
|
207
|
+
Logger({
|
|
208
|
+
level: "WARN",
|
|
209
|
+
message: "Parameter Validation warrnings for getSignUrls",
|
|
210
|
+
});
|
|
211
|
+
Logger({ level: "WARN", message: warrning });
|
|
163
212
|
}
|
|
164
213
|
|
|
165
214
|
const query_params = {};
|
|
166
215
|
|
|
167
216
|
const xHeaders = {};
|
|
168
217
|
|
|
169
|
-
|
|
218
|
+
const response = await PlatformAPIClient.execute(
|
|
170
219
|
this.config,
|
|
171
220
|
"post",
|
|
172
221
|
`/service/platform/assets/v1.0/company/${this.config.companyId}/sign-urls/`,
|
|
@@ -174,16 +223,34 @@ class FileStorage {
|
|
|
174
223
|
body,
|
|
175
224
|
xHeaders
|
|
176
225
|
);
|
|
226
|
+
|
|
227
|
+
const {
|
|
228
|
+
error: res_error,
|
|
229
|
+
} = FileStorageModel.SignUrlResponse().validate(response, {
|
|
230
|
+
abortEarly: false,
|
|
231
|
+
allowUnknown: false,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
if (res_error) {
|
|
235
|
+
Logger({
|
|
236
|
+
level: "WARN",
|
|
237
|
+
message: "Response Validation Warnnings for getSignUrls",
|
|
238
|
+
});
|
|
239
|
+
Logger({ level: "WARN", message: res_error });
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return response;
|
|
177
243
|
}
|
|
178
244
|
|
|
179
245
|
/**
|
|
180
246
|
* @param {Object} arg - Arg object.
|
|
181
247
|
* @param {boolean} [arg.sync] - Sync
|
|
182
248
|
* @param {BulkRequest} arg.body
|
|
249
|
+
* @returns {Promise<BulkUploadResponse>} - Success response
|
|
183
250
|
* @summary: Copy Files
|
|
184
251
|
* @description: Copy Files
|
|
185
252
|
*/
|
|
186
|
-
copyFiles({ body, sync } = {}) {
|
|
253
|
+
async copyFiles({ body, sync } = {}) {
|
|
187
254
|
const { error } = FileStorageValidator.copyFiles().validate(
|
|
188
255
|
{
|
|
189
256
|
body,
|
|
@@ -204,8 +271,11 @@ class FileStorage {
|
|
|
204
271
|
{ abortEarly: false, allowUnknown: false }
|
|
205
272
|
);
|
|
206
273
|
if (warrning) {
|
|
207
|
-
|
|
208
|
-
|
|
274
|
+
Logger({
|
|
275
|
+
level: "WARN",
|
|
276
|
+
message: "Parameter Validation warrnings for copyFiles",
|
|
277
|
+
});
|
|
278
|
+
Logger({ level: "WARN", message: warrning });
|
|
209
279
|
}
|
|
210
280
|
|
|
211
281
|
const query_params = {};
|
|
@@ -213,7 +283,7 @@ class FileStorage {
|
|
|
213
283
|
|
|
214
284
|
const xHeaders = {};
|
|
215
285
|
|
|
216
|
-
|
|
286
|
+
const response = await PlatformAPIClient.execute(
|
|
217
287
|
this.config,
|
|
218
288
|
"post",
|
|
219
289
|
`/service/platform/assets/v1.0/company/${this.config.companyId}/uploads/copy/`,
|
|
@@ -221,16 +291,34 @@ class FileStorage {
|
|
|
221
291
|
body,
|
|
222
292
|
xHeaders
|
|
223
293
|
);
|
|
294
|
+
|
|
295
|
+
const {
|
|
296
|
+
error: res_error,
|
|
297
|
+
} = FileStorageModel.BulkUploadResponse().validate(response, {
|
|
298
|
+
abortEarly: false,
|
|
299
|
+
allowUnknown: false,
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
if (res_error) {
|
|
303
|
+
Logger({
|
|
304
|
+
level: "WARN",
|
|
305
|
+
message: "Response Validation Warnnings for copyFiles",
|
|
306
|
+
});
|
|
307
|
+
Logger({ level: "WARN", message: res_error });
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return response;
|
|
224
311
|
}
|
|
225
312
|
|
|
226
313
|
/**
|
|
227
314
|
* @param {Object} arg - Arg object.
|
|
228
315
|
* @param {string} arg.namespace - Bucket name
|
|
229
316
|
* @param {number} [arg.pageNo] - Page no
|
|
317
|
+
* @returns {Promise<BrowseResponse>} - Success response
|
|
230
318
|
* @summary: Browse Files
|
|
231
319
|
* @description: Browse Files
|
|
232
320
|
*/
|
|
233
|
-
browse({ namespace, pageNo } = {}) {
|
|
321
|
+
async browse({ namespace, pageNo } = {}) {
|
|
234
322
|
const { error } = FileStorageValidator.browse().validate(
|
|
235
323
|
{
|
|
236
324
|
namespace,
|
|
@@ -251,8 +339,11 @@ class FileStorage {
|
|
|
251
339
|
{ abortEarly: false, allowUnknown: false }
|
|
252
340
|
);
|
|
253
341
|
if (warrning) {
|
|
254
|
-
|
|
255
|
-
|
|
342
|
+
Logger({
|
|
343
|
+
level: "WARN",
|
|
344
|
+
message: "Parameter Validation warrnings for browse",
|
|
345
|
+
});
|
|
346
|
+
Logger({ level: "WARN", message: warrning });
|
|
256
347
|
}
|
|
257
348
|
|
|
258
349
|
const query_params = {};
|
|
@@ -260,7 +351,7 @@ class FileStorage {
|
|
|
260
351
|
|
|
261
352
|
const xHeaders = {};
|
|
262
353
|
|
|
263
|
-
|
|
354
|
+
const response = await PlatformAPIClient.execute(
|
|
264
355
|
this.config,
|
|
265
356
|
"get",
|
|
266
357
|
`/service/platform/assets/v1.0/company/${this.config.companyId}/namespaces/${namespace}/browse/`,
|
|
@@ -268,6 +359,23 @@ class FileStorage {
|
|
|
268
359
|
undefined,
|
|
269
360
|
xHeaders
|
|
270
361
|
);
|
|
362
|
+
|
|
363
|
+
const {
|
|
364
|
+
error: res_error,
|
|
365
|
+
} = FileStorageModel.BrowseResponse().validate(response, {
|
|
366
|
+
abortEarly: false,
|
|
367
|
+
allowUnknown: false,
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
if (res_error) {
|
|
371
|
+
Logger({
|
|
372
|
+
level: "WARN",
|
|
373
|
+
message: "Response Validation Warnnings for browse",
|
|
374
|
+
});
|
|
375
|
+
Logger({ level: "WARN", message: res_error });
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return response;
|
|
271
379
|
}
|
|
272
380
|
|
|
273
381
|
/**
|
|
@@ -299,10 +407,11 @@ class FileStorage {
|
|
|
299
407
|
/**
|
|
300
408
|
* @param {Object} arg - Arg object.
|
|
301
409
|
* @param {string} arg.url - Url
|
|
410
|
+
* @returns {Promise<string>} - Success response
|
|
302
411
|
* @summary: Proxy
|
|
303
412
|
* @description: Proxy
|
|
304
413
|
*/
|
|
305
|
-
proxy({ url } = {}) {
|
|
414
|
+
async proxy({ url } = {}) {
|
|
306
415
|
const { error } = FileStorageValidator.proxy().validate(
|
|
307
416
|
{
|
|
308
417
|
url,
|
|
@@ -321,8 +430,11 @@ class FileStorage {
|
|
|
321
430
|
{ abortEarly: false, allowUnknown: false }
|
|
322
431
|
);
|
|
323
432
|
if (warrning) {
|
|
324
|
-
|
|
325
|
-
|
|
433
|
+
Logger({
|
|
434
|
+
level: "WARN",
|
|
435
|
+
message: "Parameter Validation warrnings for proxy",
|
|
436
|
+
});
|
|
437
|
+
Logger({ level: "WARN", message: warrning });
|
|
326
438
|
}
|
|
327
439
|
|
|
328
440
|
const query_params = {};
|
|
@@ -330,7 +442,7 @@ class FileStorage {
|
|
|
330
442
|
|
|
331
443
|
const xHeaders = {};
|
|
332
444
|
|
|
333
|
-
|
|
445
|
+
const response = await PlatformAPIClient.execute(
|
|
334
446
|
this.config,
|
|
335
447
|
"post",
|
|
336
448
|
`/service/platform/assets/v1.0/company/${this.config.companyId}/proxy/`,
|
|
@@ -338,6 +450,20 @@ class FileStorage {
|
|
|
338
450
|
undefined,
|
|
339
451
|
xHeaders
|
|
340
452
|
);
|
|
453
|
+
|
|
454
|
+
const { error: res_error } = Joi.string()
|
|
455
|
+
.allow("")
|
|
456
|
+
.validate(response, { abortEarly: false, allowUnknown: false });
|
|
457
|
+
|
|
458
|
+
if (res_error) {
|
|
459
|
+
Logger({
|
|
460
|
+
level: "WARN",
|
|
461
|
+
message: "Response Validation Warnnings for proxy",
|
|
462
|
+
});
|
|
463
|
+
Logger({ level: "WARN", message: res_error });
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return response;
|
|
341
467
|
}
|
|
342
468
|
}
|
|
343
469
|
|