@gofynd/fdk-client-javascript 1.4.6 → 1.4.8-beta.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.
Files changed (140) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/sdk/application/ApplicationClient.d.ts +2 -0
  4. package/sdk/application/ApplicationClient.js +2 -0
  5. package/sdk/application/Cart/CartApplicationClient.d.ts +16 -3
  6. package/sdk/application/Cart/CartApplicationClient.js +118 -13
  7. package/sdk/application/Cart/CartApplicationModel.d.ts +121 -45
  8. package/sdk/application/Cart/CartApplicationModel.js +98 -26
  9. package/sdk/application/Cart/CartApplicationValidator.d.ts +45 -1
  10. package/sdk/application/Cart/CartApplicationValidator.js +26 -0
  11. package/sdk/application/Catalog/CatalogApplicationModel.d.ts +10 -2
  12. package/sdk/application/Catalog/CatalogApplicationModel.js +10 -2
  13. package/sdk/application/Content/ContentApplicationClient.d.ts +1 -1
  14. package/sdk/application/Content/ContentApplicationClient.js +5 -3
  15. package/sdk/application/Content/ContentApplicationModel.d.ts +7 -18
  16. package/sdk/application/Content/ContentApplicationModel.js +6 -20
  17. package/sdk/application/Content/ContentApplicationValidator.d.ts +10 -0
  18. package/sdk/application/Content/ContentApplicationValidator.js +4 -0
  19. package/sdk/application/Lead/LeadApplicationClient.d.ts +0 -27
  20. package/sdk/application/Lead/LeadApplicationClient.js +0 -167
  21. package/sdk/application/Lead/LeadApplicationModel.d.ts +1 -146
  22. package/sdk/application/Lead/LeadApplicationModel.js +0 -126
  23. package/sdk/application/Lead/LeadApplicationValidator.d.ts +1 -25
  24. package/sdk/application/Lead/LeadApplicationValidator.js +0 -24
  25. package/sdk/application/Logistic/LogisticApplicationClient.js +1 -1
  26. package/sdk/application/Logistic/LogisticApplicationModel.d.ts +2 -0
  27. package/sdk/application/Logistic/LogisticApplicationModel.js +2 -0
  28. package/sdk/application/Order/OrderApplicationModel.d.ts +72 -9
  29. package/sdk/application/Order/OrderApplicationModel.js +45 -7
  30. package/sdk/application/Payment/PaymentApplicationModel.d.ts +27 -20
  31. package/sdk/application/Payment/PaymentApplicationModel.js +23 -20
  32. package/sdk/application/Theme/ThemeApplicationModel.d.ts +2 -0
  33. package/sdk/application/Theme/ThemeApplicationModel.js +2 -0
  34. package/sdk/application/Webhook/WebhookApplicationClient.d.ts +22 -0
  35. package/sdk/application/Webhook/WebhookApplicationClient.js +115 -0
  36. package/sdk/application/Webhook/WebhookApplicationModel.d.ts +37 -0
  37. package/sdk/application/Webhook/WebhookApplicationModel.js +46 -0
  38. package/sdk/application/Webhook/WebhookApplicationValidator.d.ts +16 -0
  39. package/sdk/application/Webhook/WebhookApplicationValidator.js +19 -0
  40. package/sdk/application/index.d.ts +1 -0
  41. package/sdk/application/index.js +2 -0
  42. package/sdk/partner/Lead/LeadPartnerClient.d.ts +0 -23
  43. package/sdk/partner/Lead/LeadPartnerClient.js +0 -157
  44. package/sdk/partner/Lead/LeadPartnerModel.d.ts +12 -581
  45. package/sdk/partner/Lead/LeadPartnerModel.js +14 -403
  46. package/sdk/partner/Lead/LeadPartnerValidator.d.ts +0 -2
  47. package/sdk/partner/Lead/LeadPartnerValidator.js +0 -12
  48. package/sdk/partner/Logistics/LogisticsPartnerClient.js +1 -1
  49. package/sdk/partner/Logistics/LogisticsPartnerModel.js +4 -4
  50. package/sdk/partner/Theme/ThemePartnerClient.d.ts +22 -0
  51. package/sdk/partner/Theme/ThemePartnerClient.js +162 -0
  52. package/sdk/partner/Theme/ThemePartnerModel.d.ts +119 -1
  53. package/sdk/partner/Theme/ThemePartnerModel.js +142 -0
  54. package/sdk/partner/Theme/ThemePartnerValidator.d.ts +2 -0
  55. package/sdk/partner/Theme/ThemePartnerValidator.js +14 -0
  56. package/sdk/partner/Webhook/WebhookPartnerClient.d.ts +2 -2
  57. package/sdk/partner/Webhook/WebhookPartnerClient.js +2 -2
  58. package/sdk/partner/Webhook/WebhookPartnerModel.d.ts +23 -19
  59. package/sdk/partner/Webhook/WebhookPartnerModel.js +19 -22
  60. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +43 -0
  61. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +257 -0
  62. package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.d.ts +39 -0
  63. package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.js +45 -0
  64. package/sdk/platform/Analytics/AnalyticsPlatformModel.d.ts +60 -0
  65. package/sdk/platform/Analytics/AnalyticsPlatformModel.js +57 -0
  66. package/sdk/platform/Billing/BillingPlatformClient.d.ts +304 -43
  67. package/sdk/platform/Billing/BillingPlatformClient.js +2218 -118
  68. package/sdk/platform/Billing/BillingPlatformModel.d.ts +1330 -282
  69. package/sdk/platform/Billing/BillingPlatformModel.js +1808 -590
  70. package/sdk/platform/Billing/BillingPlatformValidator.d.ts +324 -16
  71. package/sdk/platform/Billing/BillingPlatformValidator.js +340 -12
  72. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +36 -3
  73. package/sdk/platform/Cart/CartPlatformApplicationClient.js +276 -3
  74. package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +93 -1
  75. package/sdk/platform/Cart/CartPlatformApplicationValidator.js +60 -0
  76. package/sdk/platform/Cart/CartPlatformModel.d.ts +216 -40
  77. package/sdk/platform/Cart/CartPlatformModel.js +166 -24
  78. package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +11 -7
  79. package/sdk/platform/Catalog/CatalogPlatformClient.js +37 -14
  80. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +122 -17
  81. package/sdk/platform/Catalog/CatalogPlatformModel.js +141 -15
  82. package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +40 -7
  83. package/sdk/platform/Catalog/CatalogPlatformValidator.js +19 -5
  84. package/sdk/platform/Content/ContentPlatformApplicationClient.d.ts +1 -1
  85. package/sdk/platform/Content/ContentPlatformApplicationClient.js +18 -1
  86. package/sdk/platform/Content/ContentPlatformApplicationValidator.d.ts +25 -0
  87. package/sdk/platform/Content/ContentPlatformApplicationValidator.js +10 -0
  88. package/sdk/platform/Content/ContentPlatformModel.d.ts +8 -4
  89. package/sdk/platform/Content/ContentPlatformModel.js +8 -4
  90. package/sdk/platform/Finance/FinancePlatformClient.d.ts +49 -28
  91. package/sdk/platform/Finance/FinancePlatformClient.js +181 -28
  92. package/sdk/platform/Finance/FinancePlatformModel.d.ts +350 -127
  93. package/sdk/platform/Finance/FinancePlatformModel.js +378 -108
  94. package/sdk/platform/Finance/FinancePlatformValidator.d.ts +56 -43
  95. package/sdk/platform/Finance/FinancePlatformValidator.js +61 -42
  96. package/sdk/platform/Lead/LeadPlatformApplicationClient.d.ts +0 -47
  97. package/sdk/platform/Lead/LeadPlatformApplicationClient.js +0 -321
  98. package/sdk/platform/Lead/LeadPlatformApplicationValidator.d.ts +1 -46
  99. package/sdk/platform/Lead/LeadPlatformApplicationValidator.js +0 -48
  100. package/sdk/platform/Lead/LeadPlatformClient.d.ts +2 -25
  101. package/sdk/platform/Lead/LeadPlatformClient.js +2 -167
  102. package/sdk/platform/Lead/LeadPlatformModel.d.ts +82 -204
  103. package/sdk/platform/Lead/LeadPlatformModel.js +98 -178
  104. package/sdk/platform/Lead/LeadPlatformValidator.d.ts +1 -25
  105. package/sdk/platform/Lead/LeadPlatformValidator.js +0 -24
  106. package/sdk/platform/Order/OrderPlatformClient.d.ts +11 -1
  107. package/sdk/platform/Order/OrderPlatformClient.js +82 -5
  108. package/sdk/platform/Order/OrderPlatformModel.d.ts +270 -29
  109. package/sdk/platform/Order/OrderPlatformModel.js +139 -28
  110. package/sdk/platform/Order/OrderPlatformValidator.d.ts +58 -17
  111. package/sdk/platform/Order/OrderPlatformValidator.js +28 -16
  112. package/sdk/platform/Payment/PaymentPlatformModel.d.ts +14 -2
  113. package/sdk/platform/Payment/PaymentPlatformModel.js +7 -2
  114. package/sdk/platform/PlatformApplicationClient.d.ts +2 -0
  115. package/sdk/platform/PlatformApplicationClient.js +4 -0
  116. package/sdk/platform/Serviceability/ServiceabilityPlatformModel.js +4 -4
  117. package/sdk/platform/Theme/ThemePlatformApplicationClient.d.ts +12 -0
  118. package/sdk/platform/Theme/ThemePlatformApplicationClient.js +82 -0
  119. package/sdk/platform/Theme/ThemePlatformApplicationValidator.d.ts +18 -1
  120. package/sdk/platform/Theme/ThemePlatformApplicationValidator.js +14 -0
  121. package/sdk/platform/Theme/ThemePlatformModel.d.ts +67 -1
  122. package/sdk/platform/Theme/ThemePlatformModel.js +78 -0
  123. package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +24 -40
  124. package/sdk/platform/Webhook/WebhookPlatformClient.js +78 -221
  125. package/sdk/platform/Webhook/WebhookPlatformModel.d.ts +168 -167
  126. package/sdk/platform/Webhook/WebhookPlatformModel.js +180 -178
  127. package/sdk/platform/Webhook/WebhookPlatformValidator.d.ts +23 -31
  128. package/sdk/platform/Webhook/WebhookPlatformValidator.js +28 -42
  129. package/sdk/platform/index.d.ts +1 -0
  130. package/sdk/platform/index.js +2 -0
  131. package/sdk/public/Billing/BillingPublicClient.d.ts +24 -2
  132. package/sdk/public/Billing/BillingPublicClient.js +156 -3
  133. package/sdk/public/Billing/BillingPublicModel.d.ts +368 -26
  134. package/sdk/public/Billing/BillingPublicModel.js +317 -18
  135. package/sdk/public/Billing/BillingPublicValidator.d.ts +19 -3
  136. package/sdk/public/Billing/BillingPublicValidator.js +22 -3
  137. package/sdk/public/Webhook/WebhookPublicClient.d.ts +2 -2
  138. package/sdk/public/Webhook/WebhookPublicClient.js +2 -2
  139. package/sdk/public/Webhook/WebhookPublicModel.d.ts +24 -22
  140. package/sdk/public/Webhook/WebhookPublicModel.js +24 -22
@@ -1,13 +1,13 @@
1
1
  const Joi = require("joi");
2
2
 
3
3
  /**
4
- * @typedef UpdateSubscriberResponse
5
- * @property {string} [message]
4
+ * @typedef UpdateSubscriberRequest
5
+ * @property {string} [status]
6
6
  */
7
7
 
8
8
  /**
9
- * @typedef UpdateSubscriberRequest
10
- * @property {string} [status]
9
+ * @typedef UpdateSubscriberResponse
10
+ * @property {string} [message]
11
11
  */
12
12
 
13
13
  /**
@@ -29,6 +29,7 @@ const Joi = require("joi");
29
29
  * @property {number} [id]
30
30
  * @property {number} [event_id]
31
31
  * @property {number} [subscriber_id]
32
+ * @property {string} [topic]
32
33
  * @property {string} [created_on]
33
34
  */
34
35
 
@@ -44,6 +45,7 @@ const Joi = require("joi");
44
45
  * @property {string} [description]
45
46
  * @property {string} [created_on]
46
47
  * @property {string} [updated_on]
48
+ * @property {string} [group]
47
49
  * @property {SubscriberEventMapping} [subscriber_event_mapping]
48
50
  */
49
51
 
@@ -71,11 +73,6 @@ const Joi = require("joi");
71
73
  * @property {number} [count]
72
74
  */
73
75
 
74
- /**
75
- * @typedef DownloadReponse
76
- * @property {string} [file_name]
77
- */
78
-
79
76
  /**
80
77
  * @typedef HistoryFilters
81
78
  * @property {string[]} [events]
@@ -85,6 +82,8 @@ const Joi = require("joi");
85
82
  * @property {string} [start_date] - The start date and time of the history report.
86
83
  * @property {number[]} [subscribers] - An array of subscriber IDs associated
87
84
  * with the history report.
85
+ * @property {string[]} [webhook_type] - An array of webhook type to identify
86
+ * thetype of subscriber i.e (KAFKA or REST).
88
87
  */
89
88
 
90
89
  /**
@@ -246,6 +245,7 @@ const Joi = require("joi");
246
245
  * @property {string} [modified_by]
247
246
  * @property {string} [name]
248
247
  * @property {string} [webhook_url]
248
+ * @property {string} [provider]
249
249
  * @property {Association} [association]
250
250
  * @property {Object} [custom_headers]
251
251
  * @property {string} [status]
@@ -259,17 +259,17 @@ const Joi = require("joi");
259
259
  */
260
260
 
261
261
  class WebhookPartnerModel {
262
- /** @returns {UpdateSubscriberResponse} */
263
- static UpdateSubscriberResponse() {
262
+ /** @returns {UpdateSubscriberRequest} */
263
+ static UpdateSubscriberRequest() {
264
264
  return Joi.object({
265
- message: Joi.string().allow(""),
265
+ status: Joi.string().allow(""),
266
266
  });
267
267
  }
268
268
 
269
- /** @returns {UpdateSubscriberRequest} */
270
- static UpdateSubscriberRequest() {
269
+ /** @returns {UpdateSubscriberResponse} */
270
+ static UpdateSubscriberResponse() {
271
271
  return Joi.object({
272
- status: Joi.string().allow(""),
272
+ message: Joi.string().allow(""),
273
273
  });
274
274
  }
275
275
 
@@ -297,6 +297,7 @@ class WebhookPartnerModel {
297
297
  id: Joi.number(),
298
298
  event_id: Joi.number(),
299
299
  subscriber_id: Joi.number(),
300
+ topic: Joi.string().allow("").allow(null),
300
301
  created_on: Joi.string().allow(""),
301
302
  });
302
303
  }
@@ -314,6 +315,7 @@ class WebhookPartnerModel {
314
315
  description: Joi.string().allow("").allow(null),
315
316
  created_on: Joi.string().allow(""),
316
317
  updated_on: Joi.string().allow(""),
318
+ group: Joi.string().allow("").allow(null),
317
319
  subscriber_event_mapping: WebhookPartnerModel.SubscriberEventMapping(),
318
320
  });
319
321
  }
@@ -348,13 +350,6 @@ class WebhookPartnerModel {
348
350
  });
349
351
  }
350
352
 
351
- /** @returns {DownloadReponse} */
352
- static DownloadReponse() {
353
- return Joi.object({
354
- file_name: Joi.string().allow(""),
355
- });
356
- }
357
-
358
353
  /** @returns {HistoryFilters} */
359
354
  static HistoryFilters() {
360
355
  return Joi.object({
@@ -364,6 +359,7 @@ class WebhookPartnerModel {
364
359
  end_date: Joi.string().allow(""),
365
360
  start_date: Joi.string().allow(""),
366
361
  subscribers: Joi.array().items(Joi.number()),
362
+ webhook_type: Joi.array().items(Joi.string().allow("")),
367
363
  });
368
364
  }
369
365
 
@@ -565,6 +561,7 @@ class WebhookPartnerModel {
565
561
  modified_by: Joi.string().allow(""),
566
562
  name: Joi.string().allow(""),
567
563
  webhook_url: Joi.string().allow(""),
564
+ provider: Joi.string().allow(""),
568
565
  association: WebhookPartnerModel.Association(),
569
566
  custom_headers: Joi.any(),
570
567
  status: Joi.string().allow(""),
@@ -0,0 +1,43 @@
1
+ export = Analytics;
2
+ declare class Analytics {
3
+ constructor(config: any, applicationId: any);
4
+ config: any;
5
+ applicationId: any;
6
+ /**
7
+ * @param {AnalyticsPlatformApplicationValidator.CheckJobStatusByNameV2Param} arg
8
+ * - Arg object
9
+ *
10
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
11
+ * @param {import("../PlatformAPIClient").Options} - Options
12
+ * @returns {Promise<Object>} - Success response
13
+ * @name checkJobStatusByNameV2
14
+ * @summary: Checks download job status
15
+ * @description: Takes job name in path param to check the status of job Returns file URL if downloading is done else returns status of job - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/platform/analytics/checkJobStatusByNameV2/).
16
+ */
17
+ checkJobStatusByNameV2({ fileName, requestHeaders }?: AnalyticsPlatformApplicationValidator.CheckJobStatusByNameV2Param, { responseHeaders }?: object): Promise<any>;
18
+ /**
19
+ * @param {AnalyticsPlatformApplicationValidator.ExecuteJobForProvidedParametersV2Param} arg
20
+ * - Arg object
21
+ *
22
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
23
+ * @param {import("../PlatformAPIClient").Options} - Options
24
+ * @returns {Promise<Object>} - Success response
25
+ * @name executeJobForProvidedParametersV2
26
+ * @summary: Executes given sql(Base64 Encoded) query
27
+ * @description: Query click events data - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/platform/analytics/executeJobForProvidedParametersV2/).
28
+ */
29
+ executeJobForProvidedParametersV2({ body, requestHeaders }?: AnalyticsPlatformApplicationValidator.ExecuteJobForProvidedParametersV2Param, { responseHeaders }?: object): Promise<any>;
30
+ /**
31
+ * @param {AnalyticsPlatformApplicationValidator.StartDownloadForQueryV2Param} arg
32
+ * - Arg object
33
+ *
34
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
35
+ * @param {import("../PlatformAPIClient").Options} - Options
36
+ * @returns {Promise<Object>} - Success response
37
+ * @name startDownloadForQueryV2
38
+ * @summary: Initiates download job
39
+ * @description: Initiates download job and returns job name - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/platform/analytics/startDownloadForQueryV2/).
40
+ */
41
+ startDownloadForQueryV2({ exportType, body, requestHeaders }?: AnalyticsPlatformApplicationValidator.StartDownloadForQueryV2Param, { responseHeaders }?: object): Promise<any>;
42
+ }
43
+ import AnalyticsPlatformApplicationValidator = require("./AnalyticsPlatformApplicationValidator");
@@ -0,0 +1,257 @@
1
+ const PlatformAPIClient = require("../PlatformAPIClient");
2
+ const {
3
+ FDKClientValidationError,
4
+ FDKResponseValidationError,
5
+ } = require("../../common/FDKError");
6
+ const Paginator = require("../../common/Paginator");
7
+ const AnalyticsPlatformApplicationValidator = require("./AnalyticsPlatformApplicationValidator");
8
+ const AnalyticsPlatformModel = require("./AnalyticsPlatformModel");
9
+ const { Logger } = require("./../../common/Logger");
10
+ const Joi = require("joi");
11
+
12
+ class Analytics {
13
+ constructor(config, applicationId) {
14
+ this.config = config;
15
+ this.applicationId = applicationId;
16
+ }
17
+
18
+ /**
19
+ * @param {AnalyticsPlatformApplicationValidator.CheckJobStatusByNameV2Param} arg
20
+ * - Arg object
21
+ *
22
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
23
+ * @param {import("../PlatformAPIClient").Options} - Options
24
+ * @returns {Promise<Object>} - Success response
25
+ * @name checkJobStatusByNameV2
26
+ * @summary: Checks download job status
27
+ * @description: Takes job name in path param to check the status of job Returns file URL if downloading is done else returns status of job - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/platform/analytics/checkJobStatusByNameV2/).
28
+ */
29
+ async checkJobStatusByNameV2(
30
+ { fileName, requestHeaders } = { requestHeaders: {} },
31
+ { responseHeaders } = { responseHeaders: false }
32
+ ) {
33
+ const {
34
+ error,
35
+ } = AnalyticsPlatformApplicationValidator.checkJobStatusByNameV2().validate(
36
+ {
37
+ fileName,
38
+ },
39
+ { abortEarly: false, allowUnknown: true }
40
+ );
41
+ if (error) {
42
+ return Promise.reject(new FDKClientValidationError(error));
43
+ }
44
+
45
+ // Showing warrnings if extra unknown parameters are found
46
+ const {
47
+ error: warrning,
48
+ } = AnalyticsPlatformApplicationValidator.checkJobStatusByNameV2().validate(
49
+ {
50
+ fileName,
51
+ },
52
+ { abortEarly: false, allowUnknown: false }
53
+ );
54
+ if (warrning) {
55
+ Logger({
56
+ level: "WARN",
57
+ message: `Parameter Validation warrnings for platform > Analytics > checkJobStatusByNameV2 \n ${warrning}`,
58
+ });
59
+ }
60
+
61
+ const query_params = {};
62
+
63
+ const response = await PlatformAPIClient.execute(
64
+ this.config,
65
+ "get",
66
+ `/service/platform/insights/v2.0/company/${this.config.companyId}/application/${this.applicationId}/job/${fileName}/status`,
67
+ query_params,
68
+ undefined,
69
+ requestHeaders,
70
+ { responseHeaders }
71
+ );
72
+
73
+ let responseData = response;
74
+ if (responseHeaders) {
75
+ responseData = response[0];
76
+ }
77
+
78
+ const { error: res_error } = Joi.object()
79
+ .pattern(/\S/, Joi.any())
80
+ .validate(responseData, { abortEarly: false, allowUnknown: true });
81
+
82
+ if (res_error) {
83
+ if (this.config.options.strictResponseCheck === true) {
84
+ return Promise.reject(new FDKResponseValidationError(res_error));
85
+ } else {
86
+ Logger({
87
+ level: "WARN",
88
+ message: `Response Validation Warnings for platform > Analytics > checkJobStatusByNameV2 \n ${res_error}`,
89
+ });
90
+ }
91
+ }
92
+
93
+ return response;
94
+ }
95
+
96
+ /**
97
+ * @param {AnalyticsPlatformApplicationValidator.ExecuteJobForProvidedParametersV2Param} arg
98
+ * - Arg object
99
+ *
100
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
101
+ * @param {import("../PlatformAPIClient").Options} - Options
102
+ * @returns {Promise<Object>} - Success response
103
+ * @name executeJobForProvidedParametersV2
104
+ * @summary: Executes given sql(Base64 Encoded) query
105
+ * @description: Query click events data - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/platform/analytics/executeJobForProvidedParametersV2/).
106
+ */
107
+ async executeJobForProvidedParametersV2(
108
+ { body, requestHeaders } = { requestHeaders: {} },
109
+ { responseHeaders } = { responseHeaders: false }
110
+ ) {
111
+ const {
112
+ error,
113
+ } = AnalyticsPlatformApplicationValidator.executeJobForProvidedParametersV2().validate(
114
+ {
115
+ body,
116
+ },
117
+ { abortEarly: false, allowUnknown: true }
118
+ );
119
+ if (error) {
120
+ return Promise.reject(new FDKClientValidationError(error));
121
+ }
122
+
123
+ // Showing warrnings if extra unknown parameters are found
124
+ const {
125
+ error: warrning,
126
+ } = AnalyticsPlatformApplicationValidator.executeJobForProvidedParametersV2().validate(
127
+ {
128
+ body,
129
+ },
130
+ { abortEarly: false, allowUnknown: false }
131
+ );
132
+ if (warrning) {
133
+ Logger({
134
+ level: "WARN",
135
+ message: `Parameter Validation warrnings for platform > Analytics > executeJobForProvidedParametersV2 \n ${warrning}`,
136
+ });
137
+ }
138
+
139
+ const query_params = {};
140
+
141
+ const response = await PlatformAPIClient.execute(
142
+ this.config,
143
+ "post",
144
+ `/service/platform/insights/v2.0/company/${this.config.companyId}/application/${this.applicationId}/job/execute`,
145
+ query_params,
146
+ body,
147
+ requestHeaders,
148
+ { responseHeaders }
149
+ );
150
+
151
+ let responseData = response;
152
+ if (responseHeaders) {
153
+ responseData = response[0];
154
+ }
155
+
156
+ const { error: res_error } = Joi.object()
157
+ .pattern(/\S/, Joi.any())
158
+ .validate(responseData, { abortEarly: false, allowUnknown: true });
159
+
160
+ if (res_error) {
161
+ if (this.config.options.strictResponseCheck === true) {
162
+ return Promise.reject(new FDKResponseValidationError(res_error));
163
+ } else {
164
+ Logger({
165
+ level: "WARN",
166
+ message: `Response Validation Warnings for platform > Analytics > executeJobForProvidedParametersV2 \n ${res_error}`,
167
+ });
168
+ }
169
+ }
170
+
171
+ return response;
172
+ }
173
+
174
+ /**
175
+ * @param {AnalyticsPlatformApplicationValidator.StartDownloadForQueryV2Param} arg
176
+ * - Arg object
177
+ *
178
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
179
+ * @param {import("../PlatformAPIClient").Options} - Options
180
+ * @returns {Promise<Object>} - Success response
181
+ * @name startDownloadForQueryV2
182
+ * @summary: Initiates download job
183
+ * @description: Initiates download job and returns job name - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/platform/analytics/startDownloadForQueryV2/).
184
+ */
185
+ async startDownloadForQueryV2(
186
+ { exportType, body, requestHeaders } = { requestHeaders: {} },
187
+ { responseHeaders } = { responseHeaders: false }
188
+ ) {
189
+ const {
190
+ error,
191
+ } = AnalyticsPlatformApplicationValidator.startDownloadForQueryV2().validate(
192
+ {
193
+ exportType,
194
+ body,
195
+ },
196
+ { abortEarly: false, allowUnknown: true }
197
+ );
198
+ if (error) {
199
+ return Promise.reject(new FDKClientValidationError(error));
200
+ }
201
+
202
+ // Showing warrnings if extra unknown parameters are found
203
+ const {
204
+ error: warrning,
205
+ } = AnalyticsPlatformApplicationValidator.startDownloadForQueryV2().validate(
206
+ {
207
+ exportType,
208
+ body,
209
+ },
210
+ { abortEarly: false, allowUnknown: false }
211
+ );
212
+ if (warrning) {
213
+ Logger({
214
+ level: "WARN",
215
+ message: `Parameter Validation warrnings for platform > Analytics > startDownloadForQueryV2 \n ${warrning}`,
216
+ });
217
+ }
218
+
219
+ const query_params = {};
220
+ query_params["export_type"] = exportType;
221
+
222
+ const response = await PlatformAPIClient.execute(
223
+ this.config,
224
+ "post",
225
+ `/service/platform/insights/v2.0/company/${this.config.companyId}/application/${this.applicationId}/job/download`,
226
+ query_params,
227
+ body,
228
+ requestHeaders,
229
+ { responseHeaders }
230
+ );
231
+
232
+ let responseData = response;
233
+ if (responseHeaders) {
234
+ responseData = response[0];
235
+ }
236
+
237
+ const { error: res_error } = Joi.any().validate(responseData, {
238
+ abortEarly: false,
239
+ allowUnknown: true,
240
+ });
241
+
242
+ if (res_error) {
243
+ if (this.config.options.strictResponseCheck === true) {
244
+ return Promise.reject(new FDKResponseValidationError(res_error));
245
+ } else {
246
+ Logger({
247
+ level: "WARN",
248
+ message: `Response Validation Warnings for platform > Analytics > startDownloadForQueryV2 \n ${res_error}`,
249
+ });
250
+ }
251
+ }
252
+
253
+ return response;
254
+ }
255
+ }
256
+
257
+ module.exports = Analytics;
@@ -0,0 +1,39 @@
1
+ export = AnalyticsPlatformApplicationValidator;
2
+ /**
3
+ * @typedef CheckJobStatusByNameV2Param
4
+ * @property {string} fileName - Download job name
5
+ */
6
+ /**
7
+ * @typedef ExecuteJobForProvidedParametersV2Param
8
+ * @property {AnalyticsPlatformModel.JobExecute} body
9
+ */
10
+ /**
11
+ * @typedef StartDownloadForQueryV2Param
12
+ * @property {string} exportType
13
+ * @property {AnalyticsPlatformModel.FileDownloadRequestBody} body
14
+ */
15
+ declare class AnalyticsPlatformApplicationValidator {
16
+ /** @returns {CheckJobStatusByNameV2Param} */
17
+ static checkJobStatusByNameV2(): CheckJobStatusByNameV2Param;
18
+ /** @returns {ExecuteJobForProvidedParametersV2Param} */
19
+ static executeJobForProvidedParametersV2(): ExecuteJobForProvidedParametersV2Param;
20
+ /** @returns {StartDownloadForQueryV2Param} */
21
+ static startDownloadForQueryV2(): StartDownloadForQueryV2Param;
22
+ }
23
+ declare namespace AnalyticsPlatformApplicationValidator {
24
+ export { CheckJobStatusByNameV2Param, ExecuteJobForProvidedParametersV2Param, StartDownloadForQueryV2Param };
25
+ }
26
+ type CheckJobStatusByNameV2Param = {
27
+ /**
28
+ * - Download job name
29
+ */
30
+ fileName: string;
31
+ };
32
+ type ExecuteJobForProvidedParametersV2Param = {
33
+ body: AnalyticsPlatformModel.JobExecute;
34
+ };
35
+ type StartDownloadForQueryV2Param = {
36
+ exportType: string;
37
+ body: AnalyticsPlatformModel.FileDownloadRequestBody;
38
+ };
39
+ import AnalyticsPlatformModel = require("./AnalyticsPlatformModel");
@@ -0,0 +1,45 @@
1
+ const Joi = require("joi");
2
+
3
+ const AnalyticsPlatformModel = require("./AnalyticsPlatformModel");
4
+
5
+ /**
6
+ * @typedef CheckJobStatusByNameV2Param
7
+ * @property {string} fileName - Download job name
8
+ */
9
+
10
+ /**
11
+ * @typedef ExecuteJobForProvidedParametersV2Param
12
+ * @property {AnalyticsPlatformModel.JobExecute} body
13
+ */
14
+
15
+ /**
16
+ * @typedef StartDownloadForQueryV2Param
17
+ * @property {string} exportType
18
+ * @property {AnalyticsPlatformModel.FileDownloadRequestBody} body
19
+ */
20
+
21
+ class AnalyticsPlatformApplicationValidator {
22
+ /** @returns {CheckJobStatusByNameV2Param} */
23
+ static checkJobStatusByNameV2() {
24
+ return Joi.object({
25
+ fileName: Joi.string().allow("").required(),
26
+ }).required();
27
+ }
28
+
29
+ /** @returns {ExecuteJobForProvidedParametersV2Param} */
30
+ static executeJobForProvidedParametersV2() {
31
+ return Joi.object({
32
+ body: AnalyticsPlatformModel.JobExecute().required(),
33
+ }).required();
34
+ }
35
+
36
+ /** @returns {StartDownloadForQueryV2Param} */
37
+ static startDownloadForQueryV2() {
38
+ return Joi.object({
39
+ exportType: Joi.string().allow("").required(),
40
+ body: AnalyticsPlatformModel.FileDownloadRequestBody().required(),
41
+ }).required();
42
+ }
43
+ }
44
+
45
+ module.exports = AnalyticsPlatformApplicationValidator;
@@ -0,0 +1,60 @@
1
+ export = AnalyticsPlatformModel;
2
+ /**
3
+ * @typedef Page
4
+ * @property {number} [item_total]
5
+ * @property {string} [next_id]
6
+ * @property {boolean} [has_previous]
7
+ * @property {boolean} [has_next]
8
+ * @property {number} [current]
9
+ * @property {string} type
10
+ * @property {number} [size]
11
+ */
12
+ /**
13
+ * @typedef FileDownloadRequestBody
14
+ * @property {string} query - Base64 encoded query to execute on clickhouse.
15
+ * @property {boolean} [split_files] - Flag to indicate whether to split files
16
+ * for larger data.
17
+ */
18
+ /**
19
+ * @typedef JobExecute
20
+ * @property {string} query - Base64 encoded query to execute on clickhouse.
21
+ * @property {Page} [page]
22
+ */
23
+ declare class AnalyticsPlatformModel {
24
+ }
25
+ declare namespace AnalyticsPlatformModel {
26
+ export { Page, FileDownloadRequestBody, JobExecute };
27
+ }
28
+ /** @returns {Page} */
29
+ declare function Page(): Page;
30
+ type Page = {
31
+ item_total?: number;
32
+ next_id?: string;
33
+ has_previous?: boolean;
34
+ has_next?: boolean;
35
+ current?: number;
36
+ type: string;
37
+ size?: number;
38
+ };
39
+ /** @returns {FileDownloadRequestBody} */
40
+ declare function FileDownloadRequestBody(): FileDownloadRequestBody;
41
+ type FileDownloadRequestBody = {
42
+ /**
43
+ * - Base64 encoded query to execute on clickhouse.
44
+ */
45
+ query: string;
46
+ /**
47
+ * - Flag to indicate whether to split files
48
+ * for larger data.
49
+ */
50
+ split_files?: boolean;
51
+ };
52
+ /** @returns {JobExecute} */
53
+ declare function JobExecute(): JobExecute;
54
+ type JobExecute = {
55
+ /**
56
+ * - Base64 encoded query to execute on clickhouse.
57
+ */
58
+ query: string;
59
+ page?: Page;
60
+ };
@@ -0,0 +1,57 @@
1
+ const Joi = require("joi");
2
+
3
+ /**
4
+ * @typedef Page
5
+ * @property {number} [item_total]
6
+ * @property {string} [next_id]
7
+ * @property {boolean} [has_previous]
8
+ * @property {boolean} [has_next]
9
+ * @property {number} [current]
10
+ * @property {string} type
11
+ * @property {number} [size]
12
+ */
13
+
14
+ /**
15
+ * @typedef FileDownloadRequestBody
16
+ * @property {string} query - Base64 encoded query to execute on clickhouse.
17
+ * @property {boolean} [split_files] - Flag to indicate whether to split files
18
+ * for larger data.
19
+ */
20
+
21
+ /**
22
+ * @typedef JobExecute
23
+ * @property {string} query - Base64 encoded query to execute on clickhouse.
24
+ * @property {Page} [page]
25
+ */
26
+
27
+ class AnalyticsPlatformModel {
28
+ /** @returns {Page} */
29
+ static Page() {
30
+ return Joi.object({
31
+ item_total: Joi.number(),
32
+ next_id: Joi.string().allow(""),
33
+ has_previous: Joi.boolean(),
34
+ has_next: Joi.boolean(),
35
+ current: Joi.number(),
36
+ type: Joi.string().allow("").required(),
37
+ size: Joi.number(),
38
+ });
39
+ }
40
+
41
+ /** @returns {FileDownloadRequestBody} */
42
+ static FileDownloadRequestBody() {
43
+ return Joi.object({
44
+ query: Joi.string().allow("").required(),
45
+ split_files: Joi.boolean(),
46
+ });
47
+ }
48
+
49
+ /** @returns {JobExecute} */
50
+ static JobExecute() {
51
+ return Joi.object({
52
+ query: Joi.string().allow("").required(),
53
+ page: AnalyticsPlatformModel.Page(),
54
+ });
55
+ }
56
+ }
57
+ module.exports = AnalyticsPlatformModel;