@gofynd/fdk-client-javascript 1.3.6-beta.1 → 1.3.6
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 +1 -1
- package/package.json +2 -2
- package/sdk/application/ApplicationConfig.d.ts +11 -3
- package/sdk/application/ApplicationConfig.js +21 -3
- package/sdk/application/Cart/CartApplicationClient.js +228 -113
- package/sdk/application/Catalog/CatalogApplicationClient.js +244 -121
- package/sdk/application/Common/CommonApplicationClient.js +20 -9
- package/sdk/application/Communication/CommunicationApplicationClient.js +28 -13
- package/sdk/application/Configuration/ConfigurationApplicationClient.js +132 -65
- package/sdk/application/Content/ContentApplicationClient.js +156 -77
- package/sdk/application/FileStorage/FileStorageApplicationClient.js +28 -13
- package/sdk/application/Lead/LeadApplicationClient.js +60 -29
- package/sdk/application/Logistic/LogisticApplicationClient.js +44 -21
- package/sdk/application/Order/OrderApplicationClient.js +100 -49
- package/sdk/application/Payment/PaymentApplicationClient.js +340 -169
- package/sdk/application/PosCart/PosCartApplicationClient.js +220 -109
- package/sdk/application/Rewards/RewardsApplicationClient.js +60 -29
- package/sdk/application/Share/ShareApplicationClient.js +60 -29
- package/sdk/application/Theme/ThemeApplicationClient.js +36 -17
- package/sdk/application/User/UserApplicationClient.js +324 -161
- package/sdk/common/AxiosHelper.js +3 -3
- package/sdk/common/FDKError.d.ts +4 -0
- package/sdk/common/FDKError.js +9 -0
- package/sdk/partner/FileStorage/FileStoragePartnerClient.d.ts +16 -40
- package/sdk/partner/FileStorage/FileStoragePartnerClient.js +160 -38
- package/sdk/partner/PartnerConfig.d.ts +10 -0
- package/sdk/partner/PartnerConfig.js +10 -1
- package/sdk/partner/Theme/ThemePartnerClient.d.ts +96 -199
- package/sdk/partner/Theme/ThemePartnerClient.js +935 -170
- package/sdk/platform/AuditTrail/AuditTrailPlatformClient.js +36 -17
- package/sdk/platform/Billing/BillingPlatformClient.js +140 -69
- package/sdk/platform/Cart/CartPlatformApplicationClient.js +456 -228
- package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +512 -256
- package/sdk/platform/Catalog/CatalogPlatformClient.js +620 -309
- package/sdk/platform/Common/CommonPlatformClient.js +20 -9
- package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +472 -236
- package/sdk/platform/Communication/CommunicationPlatformClient.js +12 -5
- package/sdk/platform/Communication/CommunicationPlatformModel.d.ts +14 -1
- package/sdk/platform/Communication/CommunicationPlatformModel.js +16 -0
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +116 -57
- package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +256 -128
- package/sdk/platform/Configuration/ConfigurationPlatformClient.js +148 -73
- package/sdk/platform/Content/ContentPlatformApplicationClient.js +552 -276
- package/sdk/platform/Discount/DiscountPlatformClient.js +92 -45
- package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.js +88 -44
- package/sdk/platform/FileStorage/FileStoragePlatformClient.js +52 -25
- package/sdk/platform/Finance/FinancePlatformClient.js +196 -97
- package/sdk/platform/Inventory/InventoryPlatformClient.js +100 -49
- package/sdk/platform/Lead/LeadPlatformApplicationClient.js +104 -52
- package/sdk/platform/Lead/LeadPlatformClient.js +92 -45
- package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +26 -0
- package/sdk/platform/Order/OrderPlatformApplicationClient.js +239 -5
- package/sdk/platform/Order/OrderPlatformApplicationValidator.d.ts +57 -1
- package/sdk/platform/Order/OrderPlatformApplicationValidator.js +55 -0
- package/sdk/platform/Order/OrderPlatformClient.js +356 -177
- package/sdk/platform/Order/OrderPlatformModel.d.ts +44 -5
- package/sdk/platform/Order/OrderPlatformModel.js +52 -4
- package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +16 -8
- package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +336 -168
- package/sdk/platform/Payment/PaymentPlatformClient.js +84 -41
- package/sdk/platform/PlatformConfig.d.ts +10 -0
- package/sdk/platform/PlatformConfig.js +10 -1
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +96 -48
- package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationClient.js +112 -56
- package/sdk/platform/Serviceability/ServiceabilityPlatformClient.js +148 -73
- package/sdk/platform/Share/SharePlatformApplicationClient.js +40 -20
- package/sdk/platform/Theme/ThemePlatformApplicationClient.js +224 -112
- package/sdk/platform/Theme/ThemePlatformClient.js +28 -13
- package/sdk/platform/User/UserPlatformApplicationClient.js +144 -72
- package/sdk/platform/Webhook/WebhookPlatformClient.js +132 -65
- package/sdk/public/Configuration/ConfigurationPublicClient.js +20 -9
- package/sdk/public/Inventory/InventoryPublicClient.js +52 -25
- package/sdk/public/Partner/PartnerPublicClient.js +12 -5
- package/sdk/public/PublicConfig.d.ts +11 -1
- package/sdk/public/PublicConfig.js +10 -1
- package/sdk/public/Webhook/WebhookPublicClient.js +20 -9
|
@@ -73,10 +73,10 @@ function requestInterceptorFn() {
|
|
|
73
73
|
body: transformedData,
|
|
74
74
|
headers: headersToSign,
|
|
75
75
|
};
|
|
76
|
-
sign(signingOptions
|
|
76
|
+
const signature = sign(signingOptions);
|
|
77
77
|
|
|
78
|
-
config.headers["x-fp-date"] =
|
|
79
|
-
config.headers["x-fp-signature"] =
|
|
78
|
+
config.headers["x-fp-date"] = signature["x-fp-date"];
|
|
79
|
+
config.headers["x-fp-signature"] = signature["x-fp-signature"];
|
|
80
80
|
// config.headers["fp-sdk-version"] = version;
|
|
81
81
|
return config;
|
|
82
82
|
};
|
package/sdk/common/FDKError.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export class FDKClientValidationError extends Error {
|
|
|
15
15
|
constructor(errObj: any);
|
|
16
16
|
details: any;
|
|
17
17
|
}
|
|
18
|
+
export class FDKResponseValidationError extends Error {
|
|
19
|
+
constructor(errObj: any);
|
|
20
|
+
details: any;
|
|
21
|
+
}
|
|
18
22
|
export class FDKInvalidCredentialError extends Error {
|
|
19
23
|
constructor(message: any);
|
|
20
24
|
}
|
package/sdk/common/FDKError.js
CHANGED
|
@@ -23,6 +23,14 @@ class FDKClientValidationError extends Error {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
class FDKResponseValidationError extends Error {
|
|
27
|
+
constructor(errObj) {
|
|
28
|
+
super(errObj.message);
|
|
29
|
+
this.name = "FDKResponseValidationError";
|
|
30
|
+
this.details = JSON.parse(JSON.stringify(errObj.details));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
class FDKInvalidCredentialError extends Error {
|
|
27
35
|
constructor(message) {
|
|
28
36
|
super(message);
|
|
@@ -52,6 +60,7 @@ class FDKException extends Error {
|
|
|
52
60
|
module.exports = {
|
|
53
61
|
FDKServerResponseError,
|
|
54
62
|
FDKClientValidationError,
|
|
63
|
+
FDKResponseValidationError,
|
|
55
64
|
FDKInvalidCredentialError,
|
|
56
65
|
FDKTokenIssueError,
|
|
57
66
|
FDKOAuthCodeError,
|
|
@@ -3,14 +3,11 @@ declare class FileStorage {
|
|
|
3
3
|
constructor(config: any);
|
|
4
4
|
config: any;
|
|
5
5
|
/**
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {string} arg.namespace - Segregation of different types of
|
|
8
|
-
* files(products, orders, logistics etc), Required for validating the
|
|
9
|
-
* data of the file being uploaded, decides where exactly the file will be
|
|
10
|
-
* stored inside the storage bucket.
|
|
11
|
-
* @param {StartRequest} arg.body
|
|
6
|
+
* @param {FileStoragePartnerValidator.StartUploadParam} arg - Arg object.
|
|
12
7
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
13
8
|
* @param {import("../PartnerAPIClient").Options} - Options
|
|
9
|
+
* @returns {Promise<FileStoragePartnerModel.StartResponse>} - Success response
|
|
10
|
+
* @name startUpload
|
|
14
11
|
* @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
12
|
* @description: Uploads an arbitrarily sized buffer or blob.
|
|
16
13
|
*
|
|
@@ -30,21 +27,15 @@ declare class FileStorage {
|
|
|
30
27
|
* ### Complete
|
|
31
28
|
* After successfully upload, call `completeUpload` api to complete the upload process.
|
|
32
29
|
* This operation will return the url for the uploaded file.
|
|
30
|
+
* - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/filestorage/startUpload/).
|
|
33
31
|
*/
|
|
34
|
-
startUpload({ namespace, body, requestHeaders }?: {
|
|
35
|
-
namespace: string;
|
|
36
|
-
body: StartRequest;
|
|
37
|
-
requestHeaders?: object;
|
|
38
|
-
}, { responseHeaders }?: import("../PartnerAPIClient").Options): Promise<any>;
|
|
32
|
+
startUpload({ namespace, body, requestHeaders }?: FileStoragePartnerValidator.StartUploadParam, { responseHeaders }?: object): Promise<FileStoragePartnerModel.StartResponse>;
|
|
39
33
|
/**
|
|
40
|
-
* @param {
|
|
41
|
-
* @param {string} arg.namespace - Segregation of different types of
|
|
42
|
-
* files(products, orders, logistics etc), Required for validating the
|
|
43
|
-
* data of the file being uploaded, decides where exactly the file will be
|
|
44
|
-
* stored inside the storage bucket.
|
|
45
|
-
* @param {StartResponse} arg.body
|
|
34
|
+
* @param {FileStoragePartnerValidator.CompleteUploadParam} arg - Arg object.
|
|
46
35
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
47
36
|
* @param {import("../PartnerAPIClient").Options} - Options
|
|
37
|
+
* @returns {Promise<FileStoragePartnerModel.CompleteResponse>} - Success response
|
|
38
|
+
* @name completeUpload
|
|
48
39
|
* @summary: This will complete the upload process. After successfully uploading file, you can call this operation to complete the upload process.
|
|
49
40
|
* @description: Uploads an arbitrarily sized buffer or blob.
|
|
50
41
|
*
|
|
@@ -64,33 +55,18 @@ declare class FileStorage {
|
|
|
64
55
|
* ### Complete
|
|
65
56
|
* After successfully upload, call `completeUpload` api to complete the upload process.
|
|
66
57
|
* This operation will return the url for the uploaded file.
|
|
58
|
+
* - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/filestorage/completeUpload/).
|
|
67
59
|
*/
|
|
68
|
-
completeUpload({ namespace, body, requestHeaders }?: {
|
|
69
|
-
namespace: string;
|
|
70
|
-
body: StartResponse;
|
|
71
|
-
requestHeaders?: object;
|
|
72
|
-
}, { responseHeaders }?: import("../PartnerAPIClient").Options): Promise<any>;
|
|
60
|
+
completeUpload({ namespace, body, requestHeaders }?: FileStoragePartnerValidator.CompleteUploadParam, { responseHeaders }?: object): Promise<FileStoragePartnerModel.CompleteResponse>;
|
|
73
61
|
/**
|
|
74
|
-
* @param {
|
|
75
|
-
* @param {string} arg.namespace - Segregation of different types of
|
|
76
|
-
* files(products, orders, logistics etc), Required for validating the
|
|
77
|
-
* data of the file being uploaded, decides where exactly the file will be
|
|
78
|
-
* stored inside the storage bucket.
|
|
79
|
-
* @param {string} arg.applicationId -
|
|
80
|
-
* @param {number} arg.companyId -
|
|
81
|
-
* @param {number} [arg.page] - Page no
|
|
82
|
-
* @param {number} [arg.limit] - Limit
|
|
62
|
+
* @param {FileStoragePartnerValidator.BrowseParam} arg - Arg object.
|
|
83
63
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
84
64
|
* @param {import("../PartnerAPIClient").Options} - Options
|
|
65
|
+
* @returns {Promise<Object>} - Success response
|
|
66
|
+
* @name browse
|
|
85
67
|
* @summary: Browse Files
|
|
86
|
-
* @description: Browse Files
|
|
68
|
+
* @description: Browse Files - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/filestorage/browse/).
|
|
87
69
|
*/
|
|
88
|
-
browse({ namespace, applicationId, companyId, page, limit, requestHeaders }?: {
|
|
89
|
-
namespace: string;
|
|
90
|
-
applicationId: string;
|
|
91
|
-
companyId: number;
|
|
92
|
-
page?: number;
|
|
93
|
-
limit?: number;
|
|
94
|
-
requestHeaders?: object;
|
|
95
|
-
}, { responseHeaders }?: import("../PartnerAPIClient").Options): Promise<any>;
|
|
70
|
+
browse({ namespace, applicationId, companyId, page, limit, requestHeaders }?: FileStoragePartnerValidator.BrowseParam, { responseHeaders }?: object): Promise<any>;
|
|
96
71
|
}
|
|
72
|
+
import FileStoragePartnerModel = require("./FileStoragePartnerModel");
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
const Paginator = require("../../common/Paginator");
|
|
2
|
-
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
3
1
|
const PartnerAPIClient = require("../PartnerAPIClient");
|
|
4
|
-
const
|
|
5
|
-
|
|
2
|
+
const {
|
|
3
|
+
FDKClientValidationError,
|
|
4
|
+
FDKResponseValidationError,
|
|
5
|
+
} = require("../../common/FDKError");
|
|
6
|
+
const Paginator = require("../../common/Paginator");
|
|
7
|
+
const FileStoragePartnerValidator = require("./FileStoragePartnerValidator");
|
|
8
|
+
const FileStoragePartnerModel = require("./FileStoragePartnerModel");
|
|
6
9
|
const { Logger } = require("./../../common/Logger");
|
|
10
|
+
const Joi = require("joi");
|
|
7
11
|
|
|
8
12
|
class FileStorage {
|
|
9
13
|
constructor(config) {
|
|
@@ -11,14 +15,11 @@ class FileStorage {
|
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
/**
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {string} arg.namespace - Segregation of different types of
|
|
16
|
-
* files(products, orders, logistics etc), Required for validating the
|
|
17
|
-
* data of the file being uploaded, decides where exactly the file will be
|
|
18
|
-
* stored inside the storage bucket.
|
|
19
|
-
* @param {StartRequest} arg.body
|
|
18
|
+
* @param {FileStoragePartnerValidator.StartUploadParam} arg - Arg object.
|
|
20
19
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
21
20
|
* @param {import("../PartnerAPIClient").Options} - Options
|
|
21
|
+
* @returns {Promise<FileStoragePartnerModel.StartResponse>} - Success response
|
|
22
|
+
* @name startUpload
|
|
22
23
|
* @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.
|
|
23
24
|
* @description: Uploads an arbitrarily sized buffer or blob.
|
|
24
25
|
*
|
|
@@ -38,25 +39,44 @@ class FileStorage {
|
|
|
38
39
|
* ### Complete
|
|
39
40
|
* After successfully upload, call `completeUpload` api to complete the upload process.
|
|
40
41
|
* This operation will return the url for the uploaded file.
|
|
42
|
+
* - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/filestorage/startUpload/).
|
|
41
43
|
*/
|
|
42
|
-
startUpload(
|
|
44
|
+
async startUpload(
|
|
43
45
|
{ namespace, body, requestHeaders } = { requestHeaders: {} },
|
|
44
46
|
{ responseHeaders } = { responseHeaders: false }
|
|
45
47
|
) {
|
|
46
|
-
const { error } =
|
|
48
|
+
const { error } = FileStoragePartnerValidator.startUpload().validate(
|
|
47
49
|
{
|
|
48
50
|
namespace,
|
|
49
51
|
body,
|
|
50
52
|
},
|
|
51
|
-
{ abortEarly: false }
|
|
53
|
+
{ abortEarly: false, allowUnknown: true }
|
|
52
54
|
);
|
|
53
55
|
if (error) {
|
|
54
56
|
return Promise.reject(new FDKClientValidationError(error));
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
// Showing warrnings if extra unknown parameters are found
|
|
60
|
+
const {
|
|
61
|
+
error: warrning,
|
|
62
|
+
} = FileStoragePartnerValidator.startUpload().validate(
|
|
63
|
+
{
|
|
64
|
+
namespace,
|
|
65
|
+
|
|
66
|
+
body,
|
|
67
|
+
},
|
|
68
|
+
{ abortEarly: false, allowUnknown: false }
|
|
69
|
+
);
|
|
70
|
+
if (warrning) {
|
|
71
|
+
Logger({
|
|
72
|
+
level: "WARN",
|
|
73
|
+
message: `Parameter Validation warrnings for partner > FileStorage > startUpload \n ${warrning}`,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
57
77
|
const query_params = {};
|
|
58
78
|
|
|
59
|
-
|
|
79
|
+
const response = await PartnerAPIClient.execute(
|
|
60
80
|
this.config,
|
|
61
81
|
"post",
|
|
62
82
|
`/service/partner/assets/v1.0/organization/${this.config.organizationId}/namespaces/${namespace}/upload/start`,
|
|
@@ -65,17 +85,39 @@ class FileStorage {
|
|
|
65
85
|
requestHeaders,
|
|
66
86
|
{ responseHeaders }
|
|
67
87
|
);
|
|
88
|
+
|
|
89
|
+
let responseData = response;
|
|
90
|
+
if (responseHeaders) {
|
|
91
|
+
responseData = response[0];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const {
|
|
95
|
+
error: res_error,
|
|
96
|
+
} = FileStoragePartnerModel.StartResponse().validate(responseData, {
|
|
97
|
+
abortEarly: false,
|
|
98
|
+
allowUnknown: false,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (res_error) {
|
|
102
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
103
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
104
|
+
} else {
|
|
105
|
+
Logger({
|
|
106
|
+
level: "WARN",
|
|
107
|
+
message: `Response Validation Warnings for partner > FileStorage > startUpload \n ${res_error}`,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return response;
|
|
68
113
|
}
|
|
69
114
|
|
|
70
115
|
/**
|
|
71
|
-
* @param {
|
|
72
|
-
* @param {string} arg.namespace - Segregation of different types of
|
|
73
|
-
* files(products, orders, logistics etc), Required for validating the
|
|
74
|
-
* data of the file being uploaded, decides where exactly the file will be
|
|
75
|
-
* stored inside the storage bucket.
|
|
76
|
-
* @param {StartResponse} arg.body
|
|
116
|
+
* @param {FileStoragePartnerValidator.CompleteUploadParam} arg - Arg object.
|
|
77
117
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
78
118
|
* @param {import("../PartnerAPIClient").Options} - Options
|
|
119
|
+
* @returns {Promise<FileStoragePartnerModel.CompleteResponse>} - Success response
|
|
120
|
+
* @name completeUpload
|
|
79
121
|
* @summary: This will complete the upload process. After successfully uploading file, you can call this operation to complete the upload process.
|
|
80
122
|
* @description: Uploads an arbitrarily sized buffer or blob.
|
|
81
123
|
*
|
|
@@ -95,25 +137,44 @@ class FileStorage {
|
|
|
95
137
|
* ### Complete
|
|
96
138
|
* After successfully upload, call `completeUpload` api to complete the upload process.
|
|
97
139
|
* This operation will return the url for the uploaded file.
|
|
140
|
+
* - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/filestorage/completeUpload/).
|
|
98
141
|
*/
|
|
99
|
-
completeUpload(
|
|
142
|
+
async completeUpload(
|
|
100
143
|
{ namespace, body, requestHeaders } = { requestHeaders: {} },
|
|
101
144
|
{ responseHeaders } = { responseHeaders: false }
|
|
102
145
|
) {
|
|
103
|
-
const { error } =
|
|
146
|
+
const { error } = FileStoragePartnerValidator.completeUpload().validate(
|
|
104
147
|
{
|
|
105
148
|
namespace,
|
|
106
149
|
body,
|
|
107
150
|
},
|
|
108
|
-
{ abortEarly: false }
|
|
151
|
+
{ abortEarly: false, allowUnknown: true }
|
|
109
152
|
);
|
|
110
153
|
if (error) {
|
|
111
154
|
return Promise.reject(new FDKClientValidationError(error));
|
|
112
155
|
}
|
|
113
156
|
|
|
157
|
+
// Showing warrnings if extra unknown parameters are found
|
|
158
|
+
const {
|
|
159
|
+
error: warrning,
|
|
160
|
+
} = FileStoragePartnerValidator.completeUpload().validate(
|
|
161
|
+
{
|
|
162
|
+
namespace,
|
|
163
|
+
|
|
164
|
+
body,
|
|
165
|
+
},
|
|
166
|
+
{ abortEarly: false, allowUnknown: false }
|
|
167
|
+
);
|
|
168
|
+
if (warrning) {
|
|
169
|
+
Logger({
|
|
170
|
+
level: "WARN",
|
|
171
|
+
message: `Parameter Validation warrnings for partner > FileStorage > completeUpload \n ${warrning}`,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
114
175
|
const query_params = {};
|
|
115
176
|
|
|
116
|
-
|
|
177
|
+
const response = await PartnerAPIClient.execute(
|
|
117
178
|
this.config,
|
|
118
179
|
"post",
|
|
119
180
|
`/service/partner/assets/v1.0/organization/${this.config.organizationId}/namespaces/${namespace}/upload/complete`,
|
|
@@ -122,30 +183,49 @@ class FileStorage {
|
|
|
122
183
|
requestHeaders,
|
|
123
184
|
{ responseHeaders }
|
|
124
185
|
);
|
|
186
|
+
|
|
187
|
+
let responseData = response;
|
|
188
|
+
if (responseHeaders) {
|
|
189
|
+
responseData = response[0];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const {
|
|
193
|
+
error: res_error,
|
|
194
|
+
} = FileStoragePartnerModel.CompleteResponse().validate(responseData, {
|
|
195
|
+
abortEarly: false,
|
|
196
|
+
allowUnknown: false,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
if (res_error) {
|
|
200
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
201
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
202
|
+
} else {
|
|
203
|
+
Logger({
|
|
204
|
+
level: "WARN",
|
|
205
|
+
message: `Response Validation Warnings for partner > FileStorage > completeUpload \n ${res_error}`,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return response;
|
|
125
211
|
}
|
|
126
212
|
|
|
127
213
|
/**
|
|
128
|
-
* @param {
|
|
129
|
-
* @param {string} arg.namespace - Segregation of different types of
|
|
130
|
-
* files(products, orders, logistics etc), Required for validating the
|
|
131
|
-
* data of the file being uploaded, decides where exactly the file will be
|
|
132
|
-
* stored inside the storage bucket.
|
|
133
|
-
* @param {string} arg.applicationId -
|
|
134
|
-
* @param {number} arg.companyId -
|
|
135
|
-
* @param {number} [arg.page] - Page no
|
|
136
|
-
* @param {number} [arg.limit] - Limit
|
|
214
|
+
* @param {FileStoragePartnerValidator.BrowseParam} arg - Arg object.
|
|
137
215
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
138
216
|
* @param {import("../PartnerAPIClient").Options} - Options
|
|
217
|
+
* @returns {Promise<Object>} - Success response
|
|
218
|
+
* @name browse
|
|
139
219
|
* @summary: Browse Files
|
|
140
|
-
* @description: Browse Files
|
|
220
|
+
* @description: Browse Files - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/filestorage/browse/).
|
|
141
221
|
*/
|
|
142
|
-
browse(
|
|
222
|
+
async browse(
|
|
143
223
|
{ namespace, applicationId, companyId, page, limit, requestHeaders } = {
|
|
144
224
|
requestHeaders: {},
|
|
145
225
|
},
|
|
146
226
|
{ responseHeaders } = { responseHeaders: false }
|
|
147
227
|
) {
|
|
148
|
-
const { error } =
|
|
228
|
+
const { error } = FileStoragePartnerValidator.browse().validate(
|
|
149
229
|
{
|
|
150
230
|
namespace,
|
|
151
231
|
applicationId,
|
|
@@ -153,17 +233,36 @@ class FileStorage {
|
|
|
153
233
|
page,
|
|
154
234
|
limit,
|
|
155
235
|
},
|
|
156
|
-
{ abortEarly: false }
|
|
236
|
+
{ abortEarly: false, allowUnknown: true }
|
|
157
237
|
);
|
|
158
238
|
if (error) {
|
|
159
239
|
return Promise.reject(new FDKClientValidationError(error));
|
|
160
240
|
}
|
|
161
241
|
|
|
242
|
+
// Showing warrnings if extra unknown parameters are found
|
|
243
|
+
const { error: warrning } = FileStoragePartnerValidator.browse().validate(
|
|
244
|
+
{
|
|
245
|
+
namespace,
|
|
246
|
+
|
|
247
|
+
applicationId,
|
|
248
|
+
companyId,
|
|
249
|
+
page,
|
|
250
|
+
limit,
|
|
251
|
+
},
|
|
252
|
+
{ abortEarly: false, allowUnknown: false }
|
|
253
|
+
);
|
|
254
|
+
if (warrning) {
|
|
255
|
+
Logger({
|
|
256
|
+
level: "WARN",
|
|
257
|
+
message: `Parameter Validation warrnings for partner > FileStorage > browse \n ${warrning}`,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
162
261
|
const query_params = {};
|
|
163
262
|
query_params["page"] = page;
|
|
164
263
|
query_params["limit"] = limit;
|
|
165
264
|
|
|
166
|
-
|
|
265
|
+
const response = await PartnerAPIClient.execute(
|
|
167
266
|
this.config,
|
|
168
267
|
"get",
|
|
169
268
|
`/service/partner/assets/v1.0/organization/${this.config.organizationId}/company/${companyId}/application/${applicationId}/namespaces/${namespace}/browse`,
|
|
@@ -172,6 +271,29 @@ class FileStorage {
|
|
|
172
271
|
requestHeaders,
|
|
173
272
|
{ responseHeaders }
|
|
174
273
|
);
|
|
274
|
+
|
|
275
|
+
let responseData = response;
|
|
276
|
+
if (responseHeaders) {
|
|
277
|
+
responseData = response[0];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const { error: res_error } = Joi.any().validate(responseData, {
|
|
281
|
+
abortEarly: false,
|
|
282
|
+
allowUnknown: false,
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
if (res_error) {
|
|
286
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
287
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
288
|
+
} else {
|
|
289
|
+
Logger({
|
|
290
|
+
level: "WARN",
|
|
291
|
+
message: `Response Validation Warnings for partner > FileStorage > browse \n ${res_error}`,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return response;
|
|
175
297
|
}
|
|
176
298
|
}
|
|
177
299
|
module.exports = FileStorage;
|
|
@@ -20,6 +20,11 @@ declare class PartnerConfig {
|
|
|
20
20
|
* to use the auto-renew timer. Default is `true`
|
|
21
21
|
* @param {logLevelEnum} [config.logLevel='ERROR'] - The log level. Available
|
|
22
22
|
* options: TRACE, DEBUG, INFO, WARN, ERROR. Default is `'ERROR'`
|
|
23
|
+
* @param {object} [options] - Additional options.
|
|
24
|
+
* @param {boolean} [options.strictResponseCheck=false] - Strict check for
|
|
25
|
+
* response schema validation. Passing this `true` will check response
|
|
26
|
+
* against response schema and throw FDKResponseValidationError if it
|
|
27
|
+
* doesn't match. Default is `false`
|
|
23
28
|
*/
|
|
24
29
|
constructor(config: {
|
|
25
30
|
organizationId: string;
|
|
@@ -29,6 +34,8 @@ declare class PartnerConfig {
|
|
|
29
34
|
scope?: string;
|
|
30
35
|
useAutoRenewTimer?: boolean;
|
|
31
36
|
logLevel?: "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
37
|
+
}, options?: {
|
|
38
|
+
strictResponseCheck?: boolean;
|
|
32
39
|
});
|
|
33
40
|
organizationId: string;
|
|
34
41
|
domain: string;
|
|
@@ -39,6 +46,9 @@ declare class PartnerConfig {
|
|
|
39
46
|
oauthClient: OauthClient;
|
|
40
47
|
logLevel: "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
41
48
|
extraHeaders: any[];
|
|
49
|
+
options: {
|
|
50
|
+
strictResponseCheck: boolean;
|
|
51
|
+
};
|
|
42
52
|
/**
|
|
43
53
|
* Sets the log level for the partner.
|
|
44
54
|
*
|
|
@@ -23,8 +23,13 @@ class PartnerConfig {
|
|
|
23
23
|
* to use the auto-renew timer. Default is `true`
|
|
24
24
|
* @param {logLevelEnum} [config.logLevel='ERROR'] - The log level. Available
|
|
25
25
|
* options: TRACE, DEBUG, INFO, WARN, ERROR. Default is `'ERROR'`
|
|
26
|
+
* @param {object} [options] - Additional options.
|
|
27
|
+
* @param {boolean} [options.strictResponseCheck=false] - Strict check for
|
|
28
|
+
* response schema validation. Passing this `true` will check response
|
|
29
|
+
* against response schema and throw FDKResponseValidationError if it
|
|
30
|
+
* doesn't match. Default is `false`
|
|
26
31
|
*/
|
|
27
|
-
constructor(config) {
|
|
32
|
+
constructor(config, options) {
|
|
28
33
|
this.organizationId = config.organizationId;
|
|
29
34
|
this.domain = config.domain || "https://api.fynd.com";
|
|
30
35
|
this.apiKey = config.apiKey;
|
|
@@ -36,6 +41,10 @@ class PartnerConfig {
|
|
|
36
41
|
this.logLevel = config.logLevel || "ERROR";
|
|
37
42
|
this.setLogLevel(this.logLevel);
|
|
38
43
|
this.extraHeaders = [];
|
|
44
|
+
this.options = {
|
|
45
|
+
...{ strictResponseCheck: false },
|
|
46
|
+
...options,
|
|
47
|
+
};
|
|
39
48
|
}
|
|
40
49
|
|
|
41
50
|
/**
|