@gofynd/fdk-client-javascript 1.4.0 → 1.4.1
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
CHANGED
|
@@ -214,7 +214,7 @@ console.log("Active Theme: ", response.information.name);
|
|
|
214
214
|
The above code will log the curl command in the console
|
|
215
215
|
|
|
216
216
|
```bash
|
|
217
|
-
curl --request GET "https://api.fynd.com/service/application/theme/v1.0/applied-theme" --header 'authorization: Bearer <authorization-token>' --header 'x-fp-sdk-version: 1.4.
|
|
217
|
+
curl --request GET "https://api.fynd.com/service/application/theme/v1.0/applied-theme" --header 'authorization: Bearer <authorization-token>' --header 'x-fp-sdk-version: 1.4.1' --header 'x-fp-date: 20230222T115108Z' --header 'x-fp-signature: v1.1:1e3ab3b02b5bc626e3c32a37ee844266ade02bbcbaafc28fc7a0e46a76a7a1a8'
|
|
218
218
|
Active Theme: Emerge
|
|
219
219
|
```
|
|
220
220
|
|
package/package.json
CHANGED
|
@@ -68,18 +68,37 @@ class OAuthClient extends BaseOAuthClient {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
async renewAccessToken(isOfflineToken =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
async renewAccessToken(isOfflineToken = false) {
|
|
72
|
+
try {
|
|
73
|
+
Logger({ level: "INFO", message: "Renewing partner access token..." });
|
|
74
|
+
let res;
|
|
75
|
+
if (isOfflineToken) {
|
|
76
|
+
let requestCacheKey = `${this.config.apiKey}:${this.config.organizationId}`;
|
|
77
|
+
if (!refreshTokenRequestCache[requestCacheKey]) {
|
|
78
|
+
refreshTokenRequestCache[requestCacheKey] = this.getAccesstokenObj({
|
|
79
|
+
grant_type: "refresh_token",
|
|
80
|
+
refresh_token: this.refreshToken,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
res = await refreshTokenRequestCache[requestCacheKey].finally(() => {
|
|
84
|
+
delete refreshTokenRequestCache[requestCacheKey];
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
res = await this.getAccesstokenObj({
|
|
88
|
+
grant_type: "refresh_token",
|
|
89
|
+
refresh_token: this.refreshToken,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
81
92
|
this.setToken(res);
|
|
93
|
+
this.token_expires_at =
|
|
94
|
+
new Date().getTime() + this.token_expires_in * 1000;
|
|
95
|
+
Logger({ level: "INFO", message: "Done." });
|
|
82
96
|
return res;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (error.isAxiosError) {
|
|
99
|
+
throw new FDKTokenIssueError(error.message);
|
|
100
|
+
}
|
|
101
|
+
throw error;
|
|
83
102
|
}
|
|
84
103
|
}
|
|
85
104
|
|
|
@@ -16,7 +16,7 @@ class APIClient {
|
|
|
16
16
|
* @param {Options} options
|
|
17
17
|
*/
|
|
18
18
|
static async execute(conf, method, url, query, body, xHeaders, options) {
|
|
19
|
-
const token = await conf.oauthClient.
|
|
19
|
+
const token = await conf.oauthClient.getAccessToken();
|
|
20
20
|
|
|
21
21
|
const extraHeaders = conf.extraHeaders.reduce((acc, curr) => {
|
|
22
22
|
acc = { ...acc, ...curr };
|
|
@@ -57,20 +57,6 @@ export = WebhookPlatformModel;
|
|
|
57
57
|
* @typedef EventConfigResponse
|
|
58
58
|
* @property {EventConfig[]} [event_configs]
|
|
59
59
|
*/
|
|
60
|
-
/**
|
|
61
|
-
* @typedef EventConfigs
|
|
62
|
-
* @property {string} [created_on]
|
|
63
|
-
* @property {string} [description]
|
|
64
|
-
* @property {string} [display_name]
|
|
65
|
-
* @property {string} [event_category]
|
|
66
|
-
* @property {string} [event_name]
|
|
67
|
-
* @property {Object} [event_schema]
|
|
68
|
-
* @property {string} [event_type]
|
|
69
|
-
* @property {number} [id]
|
|
70
|
-
* @property {SubscriberEventMapping} [subscriber_event_mapping]
|
|
71
|
-
* @property {string} [updated_on]
|
|
72
|
-
* @property {string} [version]
|
|
73
|
-
*/
|
|
74
60
|
/**
|
|
75
61
|
* @typedef EventProcessReportObject
|
|
76
62
|
* @property {number} [attempt] - The attempt number of the event.
|
|
@@ -241,19 +227,6 @@ export = WebhookPlatformModel;
|
|
|
241
227
|
* @property {string} [updated_on]
|
|
242
228
|
* @property {string} [webhook_url]
|
|
243
229
|
*/
|
|
244
|
-
/**
|
|
245
|
-
* @typedef SubscriberEventMapping
|
|
246
|
-
* @property {string} [created_on]
|
|
247
|
-
* @property {number} [event_id]
|
|
248
|
-
* @property {number} [id]
|
|
249
|
-
* @property {number} [subscriber_id]
|
|
250
|
-
*/
|
|
251
|
-
/**
|
|
252
|
-
* @typedef SubscriberFailureResponse
|
|
253
|
-
* @property {string} [code]
|
|
254
|
-
* @property {string} [message]
|
|
255
|
-
* @property {string} [stack]
|
|
256
|
-
*/
|
|
257
230
|
/**
|
|
258
231
|
* @typedef SubscriberResponse
|
|
259
232
|
* @property {Association} [association]
|
|
@@ -261,7 +234,7 @@ export = WebhookPlatformModel;
|
|
|
261
234
|
* @property {string} [created_on]
|
|
262
235
|
* @property {Object} [custom_headers]
|
|
263
236
|
* @property {string} [email_id]
|
|
264
|
-
* @property {
|
|
237
|
+
* @property {EventConfig[]} [event_configs]
|
|
265
238
|
* @property {number} [id]
|
|
266
239
|
* @property {string} [modified_by]
|
|
267
240
|
* @property {string} [name]
|
|
@@ -283,7 +256,7 @@ export = WebhookPlatformModel;
|
|
|
283
256
|
declare class WebhookPlatformModel {
|
|
284
257
|
}
|
|
285
258
|
declare namespace WebhookPlatformModel {
|
|
286
|
-
export { Association, AuthMeta, CancelResponse, CdnObject, DownloadReportResponse, Err, Error, Event, EventConfig, EventConfigResponse,
|
|
259
|
+
export { Association, AuthMeta, CancelResponse, CdnObject, DownloadReportResponse, Err, Error, Event, EventConfig, EventConfigResponse, EventProcessReportObject, EventProcessReports, EventProcessRequest, HistoryAssociation, HistoryFilters, HistoryItems, HistoryPayload, HistoryResponse, Item, Page, PingWebhook, PingWebhookResponse, ReportFilterResponse, ReportFiltersPayload, RetryCountResponse, RetryEventRequest, RetryFailureResponse, RetryStatusResponse, RetrySuccessResponse, SubscriberConfig, SubscriberConfigList, SubscriberConfigResponse, SubscriberResponse, UploadServiceObject, Url, SubscriberStatus };
|
|
287
260
|
}
|
|
288
261
|
/** @returns {Association} */
|
|
289
262
|
declare function Association(): Association;
|
|
@@ -359,21 +332,6 @@ declare function EventConfigResponse(): EventConfigResponse;
|
|
|
359
332
|
type EventConfigResponse = {
|
|
360
333
|
event_configs?: EventConfig[];
|
|
361
334
|
};
|
|
362
|
-
/** @returns {EventConfigs} */
|
|
363
|
-
declare function EventConfigs(): EventConfigs;
|
|
364
|
-
type EventConfigs = {
|
|
365
|
-
created_on?: string;
|
|
366
|
-
description?: string;
|
|
367
|
-
display_name?: string;
|
|
368
|
-
event_category?: string;
|
|
369
|
-
event_name?: string;
|
|
370
|
-
event_schema?: any;
|
|
371
|
-
event_type?: string;
|
|
372
|
-
id?: number;
|
|
373
|
-
subscriber_event_mapping?: SubscriberEventMapping;
|
|
374
|
-
updated_on?: string;
|
|
375
|
-
version?: string;
|
|
376
|
-
};
|
|
377
335
|
/** @returns {EventProcessReportObject} */
|
|
378
336
|
declare function EventProcessReportObject(): EventProcessReportObject;
|
|
379
337
|
type EventProcessReportObject = {
|
|
@@ -671,21 +629,6 @@ type SubscriberConfigResponse = {
|
|
|
671
629
|
updated_on?: string;
|
|
672
630
|
webhook_url?: string;
|
|
673
631
|
};
|
|
674
|
-
/** @returns {SubscriberEventMapping} */
|
|
675
|
-
declare function SubscriberEventMapping(): SubscriberEventMapping;
|
|
676
|
-
type SubscriberEventMapping = {
|
|
677
|
-
created_on?: string;
|
|
678
|
-
event_id?: number;
|
|
679
|
-
id?: number;
|
|
680
|
-
subscriber_id?: number;
|
|
681
|
-
};
|
|
682
|
-
/** @returns {SubscriberFailureResponse} */
|
|
683
|
-
declare function SubscriberFailureResponse(): SubscriberFailureResponse;
|
|
684
|
-
type SubscriberFailureResponse = {
|
|
685
|
-
code?: string;
|
|
686
|
-
message?: string;
|
|
687
|
-
stack?: string;
|
|
688
|
-
};
|
|
689
632
|
/** @returns {SubscriberResponse} */
|
|
690
633
|
declare function SubscriberResponse(): SubscriberResponse;
|
|
691
634
|
type SubscriberResponse = {
|
|
@@ -694,7 +637,7 @@ type SubscriberResponse = {
|
|
|
694
637
|
created_on?: string;
|
|
695
638
|
custom_headers?: any;
|
|
696
639
|
email_id?: string;
|
|
697
|
-
event_configs?:
|
|
640
|
+
event_configs?: EventConfig[];
|
|
698
641
|
id?: number;
|
|
699
642
|
modified_by?: string;
|
|
700
643
|
name?: string;
|
|
@@ -68,21 +68,6 @@ const Joi = require("joi");
|
|
|
68
68
|
* @property {EventConfig[]} [event_configs]
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* @typedef EventConfigs
|
|
73
|
-
* @property {string} [created_on]
|
|
74
|
-
* @property {string} [description]
|
|
75
|
-
* @property {string} [display_name]
|
|
76
|
-
* @property {string} [event_category]
|
|
77
|
-
* @property {string} [event_name]
|
|
78
|
-
* @property {Object} [event_schema]
|
|
79
|
-
* @property {string} [event_type]
|
|
80
|
-
* @property {number} [id]
|
|
81
|
-
* @property {SubscriberEventMapping} [subscriber_event_mapping]
|
|
82
|
-
* @property {string} [updated_on]
|
|
83
|
-
* @property {string} [version]
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
71
|
/**
|
|
87
72
|
* @typedef EventProcessReportObject
|
|
88
73
|
* @property {number} [attempt] - The attempt number of the event.
|
|
@@ -275,21 +260,6 @@ const Joi = require("joi");
|
|
|
275
260
|
* @property {string} [webhook_url]
|
|
276
261
|
*/
|
|
277
262
|
|
|
278
|
-
/**
|
|
279
|
-
* @typedef SubscriberEventMapping
|
|
280
|
-
* @property {string} [created_on]
|
|
281
|
-
* @property {number} [event_id]
|
|
282
|
-
* @property {number} [id]
|
|
283
|
-
* @property {number} [subscriber_id]
|
|
284
|
-
*/
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* @typedef SubscriberFailureResponse
|
|
288
|
-
* @property {string} [code]
|
|
289
|
-
* @property {string} [message]
|
|
290
|
-
* @property {string} [stack]
|
|
291
|
-
*/
|
|
292
|
-
|
|
293
263
|
/**
|
|
294
264
|
* @typedef SubscriberResponse
|
|
295
265
|
* @property {Association} [association]
|
|
@@ -297,7 +267,7 @@ const Joi = require("joi");
|
|
|
297
267
|
* @property {string} [created_on]
|
|
298
268
|
* @property {Object} [custom_headers]
|
|
299
269
|
* @property {string} [email_id]
|
|
300
|
-
* @property {
|
|
270
|
+
* @property {EventConfig[]} [event_configs]
|
|
301
271
|
* @property {number} [id]
|
|
302
272
|
* @property {string} [modified_by]
|
|
303
273
|
* @property {string} [name]
|
|
@@ -409,23 +379,6 @@ class WebhookPlatformModel {
|
|
|
409
379
|
});
|
|
410
380
|
}
|
|
411
381
|
|
|
412
|
-
/** @returns {EventConfigs} */
|
|
413
|
-
static EventConfigs() {
|
|
414
|
-
return Joi.object({
|
|
415
|
-
created_on: Joi.string().allow(""),
|
|
416
|
-
description: Joi.string().allow(""),
|
|
417
|
-
display_name: Joi.string().allow(""),
|
|
418
|
-
event_category: Joi.string().allow(""),
|
|
419
|
-
event_name: Joi.string().allow(""),
|
|
420
|
-
event_schema: Joi.object().pattern(/\S/, Joi.any()),
|
|
421
|
-
event_type: Joi.string().allow(""),
|
|
422
|
-
id: Joi.number(),
|
|
423
|
-
subscriber_event_mapping: WebhookPlatformModel.SubscriberEventMapping(),
|
|
424
|
-
updated_on: Joi.string().allow(""),
|
|
425
|
-
version: Joi.string().allow(""),
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
|
|
429
382
|
/** @returns {EventProcessReportObject} */
|
|
430
383
|
static EventProcessReportObject() {
|
|
431
384
|
return Joi.object({
|
|
@@ -656,25 +609,6 @@ class WebhookPlatformModel {
|
|
|
656
609
|
});
|
|
657
610
|
}
|
|
658
611
|
|
|
659
|
-
/** @returns {SubscriberEventMapping} */
|
|
660
|
-
static SubscriberEventMapping() {
|
|
661
|
-
return Joi.object({
|
|
662
|
-
created_on: Joi.string().allow(""),
|
|
663
|
-
event_id: Joi.number(),
|
|
664
|
-
id: Joi.number(),
|
|
665
|
-
subscriber_id: Joi.number(),
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
/** @returns {SubscriberFailureResponse} */
|
|
670
|
-
static SubscriberFailureResponse() {
|
|
671
|
-
return Joi.object({
|
|
672
|
-
code: Joi.string().allow(""),
|
|
673
|
-
message: Joi.string().allow(""),
|
|
674
|
-
stack: Joi.string().allow(""),
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
|
|
678
612
|
/** @returns {SubscriberResponse} */
|
|
679
613
|
static SubscriberResponse() {
|
|
680
614
|
return Joi.object({
|
|
@@ -683,7 +617,7 @@ class WebhookPlatformModel {
|
|
|
683
617
|
created_on: Joi.string().allow(""),
|
|
684
618
|
custom_headers: Joi.any(),
|
|
685
619
|
email_id: Joi.string().allow(""),
|
|
686
|
-
event_configs: Joi.array().items(WebhookPlatformModel.
|
|
620
|
+
event_configs: Joi.array().items(WebhookPlatformModel.EventConfig()),
|
|
687
621
|
id: Joi.number(),
|
|
688
622
|
modified_by: Joi.string().allow(""),
|
|
689
623
|
name: Joi.string().allow(""),
|