oneentry 1.0.60 → 1.0.61

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
@@ -41,13 +41,13 @@ const {
41
41
  System,
42
42
  Templates,
43
43
  TemplatePreviews
44
- } = defineOneEntry('your-url')
44
+ } = defineOneEntry('your-url');
45
45
  ```
46
46
 
47
47
  Or
48
48
 
49
49
  ```js
50
- const api = defineOneEntry('your-url')
50
+ const api = defineOneEntry('your-url');
51
51
  ```
52
52
 
53
53
  The second parameter of the function takes a configuration object with the keys "token", "langCode" and "multipleResponse".
@@ -98,7 +98,7 @@ Now you can use the following links to jump to specific entries:
98
98
 
99
99
 
100
100
  ```js
101
- const { Admins } = defineOneEntry('your-url')
101
+ const { Admins } = defineOneEntry('your-url');
102
102
  ```
103
103
 
104
104
  ### Admins.getAdminsInfo(langCode, offset, limit)
@@ -625,7 +625,9 @@ Example return:
625
625
 
626
626
  ## <h2 id="fileuploading"> FileUploading </h2>
627
627
 
628
+ ```js
628
629
  const { FileUploading } = defineOneEntry('your-url');
630
+ ```
629
631
 
630
632
  ### FileUploading.upload(data, fileQuery)
631
633
 
@@ -709,7 +711,9 @@ Example return:
709
711
  ## <h2 id="forms"> Forms </h2>
710
712
 
711
713
 
714
+ ```js
712
715
  const { Forms } = defineOneEntry('your-url');
716
+ ```
713
717
 
714
718
  ### Forms.getAllForms(langCode, offset, limit)
715
719
 
@@ -917,15 +921,27 @@ example: List [ OrderedMap { "type": "list", "marker": "l1", "position": 2, "lis
917
921
 
918
922
  ## <h2 id="formdata"> FormData </h2>
919
923
 
924
+ ```js
920
925
  const { FormData } = defineOneEntry('your-url');
926
+ ```
921
927
 
922
- ### FormData.postFormsData(data)
928
+ ### FormData.postFormsData(data, langCode)
923
929
 
924
930
  ```js
925
- const value = await FormData.postFormsData(data)
931
+ const body = {
932
+ formIdentifier: 'test',
933
+ formData: {
934
+ marker: 'test',
935
+ value: 'Test',
936
+ },
937
+ }
938
+
939
+ const value = await FormData.postFormsData(body)
926
940
  ```
927
941
 
928
- > This method retrieves all form data objects from the API. It returns a Promise that resolves to an array of objects of type CreateFormDataDto.
942
+ > This method retrieves all form data objects from the API. It returns a Promise that resolves to an array of objects of type CreateFormData. The method will add the default language to the request body. If you want to change the language, just pass it with the second argument
943
+
944
+
929
945
 
930
946
  Example return:
931
947
 
@@ -1063,7 +1079,9 @@ example: test-form <br>
1063
1079
 
1064
1080
  ## <h2 id="generaltypes"> GeneralTypes </h2>
1065
1081
 
1082
+ ```js
1066
1083
  const { GeneralTypes } = defineOneEntry('your-url');
1084
+ ```
1067
1085
 
1068
1086
  ### GeneralTypes.getAllTypes()
1069
1087
 
@@ -1103,7 +1121,7 @@ Enum:
1103
1121
  ## <h2 id="locales"> Locales </h2>
1104
1122
 
1105
1123
  ```js
1106
- const { Locales } = defineOneEntry('your-url')
1124
+ const { Locales } = defineOneEntry('your-url');
1107
1125
  ```
1108
1126
 
1109
1127
  ### Locales.getLocales()
@@ -1174,7 +1192,7 @@ description:position number
1174
1192
 
1175
1193
 
1176
1194
  ```js
1177
- const { Markers } = defineOneEntry('your-url')
1195
+ const { Markers } = defineOneEntry('your-url');
1178
1196
  ```
1179
1197
 
1180
1198
  ### Markers.getMarkers(offset, limit)
@@ -1408,7 +1426,7 @@ example: List [ OrderedMap { "id": 11, "pageUrl": "122", "localizeInfos": Ordere
1408
1426
  ## <h2 id="orders"> Orders </h2>
1409
1427
 
1410
1428
  ```js
1411
- const { Orders } = defineOneEntry('your-url')
1429
+ const { Orders } = defineOneEntry('your-url');
1412
1430
  ```
1413
1431
 
1414
1432
  ### Orders.getOrderByMarker(marker, langCode)
@@ -1466,7 +1484,7 @@ example: [{ "identifier": "p1" }] <br>
1466
1484
  </details>
1467
1485
 
1468
1486
 
1469
- ### Orders.createOrder(marker, data)
1487
+ ### Orders.createOrder(marker, data, langCode)
1470
1488
 
1471
1489
  ```js
1472
1490
  const body = {
@@ -1506,11 +1524,12 @@ example: [{ "identifier": "p1" }] <br>
1506
1524
  const value = await Pages.createOrder('my-order', body)
1507
1525
  ```
1508
1526
 
1509
- > This method retrieves one order storage object by marker.
1527
+ > This method retrieves one order storage object by marker. The method will add the default language to the request body. If you want to change the language, just pass it with the second argument
1510
1528
 
1511
1529
  Example return:
1512
1530
  ```json
1513
1531
  {
1532
+ "id": 17,
1514
1533
  "statusIdentifier": "inprogress",
1515
1534
  "formIdentifier": "order-form",
1516
1535
  "paymentIdentifier": "payment-1",
@@ -1540,7 +1559,6 @@ Example return:
1540
1559
  "totalSum": "12.00",
1541
1560
  "currency": "USD",
1542
1561
  "createdDate": "2023-01-01 12:12",
1543
- "price": 20,
1544
1562
  "paymentAccountIdentifier": "payment-1",
1545
1563
  "paymentAccountLocalizeInfos": {
1546
1564
  "title": "Account 1"
@@ -1602,7 +1620,7 @@ example: { "title": "Account 1" } <br>
1602
1620
 
1603
1621
 
1604
1622
  ```js
1605
- const { Pages } = defineOneEntry('your-url')
1623
+ const { Pages } = defineOneEntry('your-url');
1606
1624
  ```
1607
1625
 
1608
1626
  ### Pages.getRootPages(langCode)
@@ -2564,7 +2582,7 @@ Example return:
2564
2582
  ## <h2 id="payments"> Payments </h2>
2565
2583
 
2566
2584
  ```js
2567
- const { Payments } = defineOneEntry('your-url')
2585
+ const { Payments } = defineOneEntry('your-url');
2568
2586
  ```
2569
2587
 
2570
2588
  ### Payments.getSessions(limit, offset)
@@ -3082,7 +3100,7 @@ const value = await Payments.webhookPaypal()
3082
3100
 
3083
3101
 
3084
3102
  ```js
3085
- const { Products } = defineOneEntry('your-url')
3103
+ const { Products } = defineOneEntry('your-url');
3086
3104
  ```
3087
3105
 
3088
3106
  >This module accepts a set of user parameters called userQuery. If the parameters are not passed to the method, the default value will be applied.
@@ -4173,7 +4191,7 @@ true
4173
4191
 
4174
4192
 
4175
4193
  ```js
4176
- const { System } = defineOneEntry('your-url')
4194
+ const { System } = defineOneEntry('your-url');
4177
4195
  ```
4178
4196
 
4179
4197
  ### System.test404()
@@ -4197,7 +4215,7 @@ const value = await System.test500()
4197
4215
 
4198
4216
 
4199
4217
  ```js
4200
- const { Templates } = defineOneEntry('your-url')
4218
+ const { Templates } = defineOneEntry('your-url');
4201
4219
  ```
4202
4220
 
4203
4221
  ### Templates.getAllTemplates()
@@ -4359,7 +4377,7 @@ general type name <br>
4359
4377
 
4360
4378
 
4361
4379
  ```js
4362
- const { TemplatePreviews } = defineOneEntry('your-url')
4380
+ const { TemplatePreviews } = defineOneEntry('your-url');
4363
4381
  ```
4364
4382
 
4365
4383
  ### TemplatePreviews.getTemplatePreviews()
@@ -20,21 +20,20 @@ export default class FormsDataApi extends OneEntry implements IFormsData {
20
20
  * Find all product page objects with pagination and multiple filtering.
21
21
  *
22
22
  * @param {object} [data] - Request body.
23
- * Example Value:
24
- * {
25
- * "formIdentifier": "my-form",
26
- * "formData": [
27
- * {
28
- * "marker": "name_1",
29
- * "value": "Name",
30
- * "langCode": "en_US"
31
- * }
32
- * ]
23
+ * @param {string} langCode - Optional language field
24
+ *
25
+ * @example
26
+ * const body = {
27
+ * formIdentifier: 'test',
28
+ * formData: {
29
+ * marker: 'test',
30
+ * value: 'Test',
31
+ * },
33
32
  * }
34
33
  *
35
34
  * @returns - Returns created FormData objects.
36
35
  */
37
- postFormsData(data: IFormsPost): Promise<IFormsDataEntity>;
36
+ postFormsData(data: IFormsPost, langCode?: string): Promise<IFormsDataEntity>;
38
37
  /**
39
38
  * Get one object of form data by marker.
40
39
  *
@@ -26,21 +26,23 @@ class FormsDataApi extends oneEntry_1.default {
26
26
  * Find all product page objects with pagination and multiple filtering.
27
27
  *
28
28
  * @param {object} [data] - Request body.
29
- * Example Value:
30
- * {
31
- * "formIdentifier": "my-form",
32
- * "formData": [
33
- * {
34
- * "marker": "name_1",
35
- * "value": "Name",
36
- * "langCode": "en_US"
37
- * }
38
- * ]
29
+ * @param {string} langCode - Optional language field
30
+ *
31
+ * @example
32
+ * const body = {
33
+ * formIdentifier: 'test',
34
+ * formData: {
35
+ * marker: 'test',
36
+ * value: 'Test',
37
+ * },
39
38
  * }
40
39
  *
41
40
  * @returns - Returns created FormData objects.
42
41
  */
43
- async postFormsData(data) {
42
+ async postFormsData(data, langCode = this._defaultLangCode) {
43
+ const formData = {};
44
+ formData[langCode] = Array.isArray(data.formData) ? data.formData : [data.formData];
45
+ data.formData = formData;
44
46
  const result = await this._fetchPost('', JSON.stringify(data));
45
47
  return this._dataPostProcess(result);
46
48
  }
@@ -9,7 +9,7 @@
9
9
  */
10
10
  interface IFormsData {
11
11
  getFormsData(langCode: string, offset?: number, limit?: number): Promise<Array<IFormsDataEntity>>;
12
- postFormsData(data: IFormsPost): Promise<IFormsDataEntity>;
12
+ postFormsData(data: IFormsPost, langCode?: string): Promise<IFormsDataEntity>;
13
13
  getFormsDataByMarker(marker: string, langCode: string, offset?: number, limit?: number): Promise<Array<IFormsDataEntity>>;
14
14
  }
15
15
  /**
@@ -30,13 +30,6 @@ interface IFormsDataEntity {
30
30
  attributeSetIdentifier?: string;
31
31
  }
32
32
  /**
33
- * @property {string} [formIdentifier] - Text identifier of the form object (marker)
34
- *
35
- * Form data get by langcode identifier
36
- * @example formData['en_US']
37
- *
38
- * @property {langCode.<object>}
39
- *
40
33
  * Contains an array of data form objects with the following values
41
34
  *
42
35
  * @property {string} marker Form data marker.
@@ -44,13 +37,8 @@ interface IFormsDataEntity {
44
37
  * @property {string} value Form data value.
45
38
  */
46
39
  interface IFormData {
47
- [langcode: string]: Array<{
48
- marker?: string;
49
- value?: string;
50
- }> | {
51
- marker?: string;
52
- value?: string;
53
- };
40
+ marker?: string;
41
+ value?: string;
54
42
  }
55
43
  /**
56
44
  * interface to create an object of information about saving data using the form
@@ -64,6 +52,6 @@ interface IFormsPost {
64
52
  id?: number;
65
53
  formIdentifier: string;
66
54
  time?: Date | string;
67
- formData: IFormData;
55
+ formData: IFormData | Array<IFormData>;
68
56
  }
69
57
  export { IFormsPost, IFormsData, IFormData, IFormsDataEntity };
@@ -20,29 +20,21 @@ export default class OrdersApi extends OneEntry implements IOrdersApi {
20
20
  *
21
21
  * @param {string} marker - Textual identifier of the order storage object
22
22
  * @param {IOrderData} data - Object for creating an order
23
+ * @param {String} langCode - Optional language field
23
24
  *
24
25
  * @example
25
- * {
26
+ * const body = {
26
27
  * "formIdentifier": "bar-orders-form",
27
28
  * "paymentIdentifier": "usd-payment",
28
29
  * "formData": {
29
- * "en_US": [
30
- * {
31
- * "marker": "name_1",
32
- * "value": "Name"
33
- * }
34
- * ]
30
+ * "marker": "name_1",
31
+ * "value": "Name"
35
32
  * },
36
33
  * "products": [
37
34
  * {
38
35
  * "productId": 1,
39
36
  * "quantity": 2,
40
37
  * "price": "23.02"
41
- * },
42
- * {
43
- * "productId": 2,
44
- * "quantity": 3,
45
- * "price": "3.02"
46
38
  * }
47
39
  * ],
48
40
  * "currency": "USD"
@@ -50,5 +42,5 @@ export default class OrdersApi extends OneEntry implements IOrdersApi {
50
42
  *
51
43
  * @returns Returns object for creating an order.
52
44
  */
53
- createOrder(marker: string, data: IOrderData): Promise<IBaseOrdersEntity>;
45
+ createOrder(marker: string, data: IOrderData, langCode?: string): Promise<IBaseOrdersEntity>;
54
46
  }
@@ -26,29 +26,21 @@ class OrdersApi extends oneEntry_1.default {
26
26
  *
27
27
  * @param {string} marker - Textual identifier of the order storage object
28
28
  * @param {IOrderData} data - Object for creating an order
29
+ * @param {String} langCode - Optional language field
29
30
  *
30
31
  * @example
31
- * {
32
+ * const body = {
32
33
  * "formIdentifier": "bar-orders-form",
33
34
  * "paymentIdentifier": "usd-payment",
34
35
  * "formData": {
35
- * "en_US": [
36
- * {
37
- * "marker": "name_1",
38
- * "value": "Name"
39
- * }
40
- * ]
36
+ * "marker": "name_1",
37
+ * "value": "Name"
41
38
  * },
42
39
  * "products": [
43
40
  * {
44
41
  * "productId": 1,
45
42
  * "quantity": 2,
46
43
  * "price": "23.02"
47
- * },
48
- * {
49
- * "productId": 2,
50
- * "quantity": 3,
51
- * "price": "3.02"
52
44
  * }
53
45
  * ],
54
46
  * "currency": "USD"
@@ -56,7 +48,10 @@ class OrdersApi extends oneEntry_1.default {
56
48
  *
57
49
  * @returns Returns object for creating an order.
58
50
  */
59
- async createOrder(marker, data) {
51
+ async createOrder(marker, data, langCode = this._defaultLangCode) {
52
+ const formData = {};
53
+ formData[langCode] = Array.isArray(data.formData) ? data.formData : [data.formData];
54
+ data.formData = formData;
60
55
  const result = await this._fetchPost(`/marker/${marker}/order`, data);
61
56
  return this._normalizeData(result);
62
57
  }
@@ -29,6 +29,7 @@ interface IOrdersFormData {
29
29
  }
30
30
  /**
31
31
  * @interface
32
+ * @property {number} id
32
33
  * @property {string} statusIdentifier - Text identifier of the order status.
33
34
  * @property {string} formIdentifier - Text identifier of the form status.
34
35
  * @property {string} paymentIdentifier - Text identifier of the order payment.
@@ -37,11 +38,11 @@ interface IOrdersFormData {
37
38
  * @property {string} totalSum - Total order amount.
38
39
  * @property {string} currency - Currency used to pay for the order.
39
40
  * @property {string} createdDate - Date when the order was created.
40
- * @property {number} price - Price of the product per unit (at the time of ordering).
41
41
  * @property {string} paymentAccountIdentifier - Textual identifier for the order payment.
42
42
  * @property {Record<string, any>} paymentAccountLocalizeInfos - Payment account name considering localization.
43
43
  */
44
44
  interface IBaseOrdersEntity {
45
+ id: number;
45
46
  statusIdentifier: string;
46
47
  formIdentifier: string;
47
48
  paymentIdentifier: string;
@@ -50,7 +51,6 @@ interface IBaseOrdersEntity {
50
51
  totalSum: string;
51
52
  currency: string;
52
53
  createdDate: string;
53
- price: number;
54
54
  paymentAccountIdentifier: string;
55
55
  paymentAccountLocalizeInfos: Record<string, any>;
56
56
  }
@@ -93,7 +93,7 @@ interface IOrderProductData {
93
93
  * @property {string} formIdentifier - Text identifier of the form object linked to the order repository.
94
94
  * @property {string} paymentIdentifier - Text identifier of the payment object linked to the order repository.
95
95
  * @property {string} [statusIdentifier] - Text identifier of the order status object (if not specified, the default status will be assigned).
96
- * @property {Record<string, Array<IOrderMarkerData>>} formData - Form data linked to the order repositor.
96
+ * @property {IOrderMarkerData | Array<IOrderMarkerData>} formData - Form data linked to the order repositor.
97
97
  * @property {Array<IOrderProductData>} products - An array of ordered products.
98
98
  * @property {string} currency - Currency used for order paymen.
99
99
  */
@@ -101,7 +101,7 @@ interface IOrderData {
101
101
  formIdentifier: string;
102
102
  paymentIdentifier: string;
103
103
  statusIdentifier?: string;
104
- formData: Record<string, Array<IOrderMarkerData>>;
104
+ formData: IOrderMarkerData | Array<IOrderMarkerData>;
105
105
  products: Array<IOrderProductData>;
106
106
  currency: string;
107
107
  }
@@ -144,36 +144,6 @@ export default class ProductApi extends OneEntry implements IProductApi {
144
144
  * @param {array} [data] - Request body.
145
145
  *
146
146
  * @param {string} [langCode] Language code parameter. Default "en_US".
147
- *
148
- * @example
149
- * const objects = [
150
- *
151
- * {
152
- *
153
- * attributeMarker: "price",
154
- *
155
- * conditionMarker: "mth",
156
- *
157
- * conditionValue: 1,
158
- *
159
- * pageId: 0,
160
- *
161
- * },
162
- *
163
- * {
164
- *
165
- * attributeMarker: "price",
166
- *
167
- * conditionMarker: "lth",
168
- *
169
- * conditionValue: 3,
170
- *
171
- * pageId: 0,
172
- *
173
- * },
174
- *
175
- * ];
176
- *
177
147
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
178
148
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
179
149
  *
@@ -183,6 +153,24 @@ export default class ProductApi extends OneEntry implements IProductApi {
183
153
  *
184
154
  * @param {string} [userQuery.sortKey] - Optional field to sort by
185
155
  *
156
+ *
157
+ * @example
158
+ * const body = [
159
+ *{
160
+ * attributeMarker: "price",
161
+ * conditionMarker: "mth",
162
+ * conditionValue: 1,
163
+ * pageId: 0
164
+ *},
165
+ *{
166
+ * attributeMarker: "price",
167
+ * conditionMarker: "lth",
168
+ * conditionValue: 3,
169
+ * pageId: 0
170
+ *},
171
+ *];
172
+ *
173
+ *
186
174
  * @returns Array with ProductEntity objects
187
175
  */
188
176
  filterProduct(data: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
@@ -179,36 +179,6 @@ class ProductApi extends oneEntry_1.default {
179
179
  * @param {array} [data] - Request body.
180
180
  *
181
181
  * @param {string} [langCode] Language code parameter. Default "en_US".
182
- *
183
- * @example
184
- * const objects = [
185
- *
186
- * {
187
- *
188
- * attributeMarker: "price",
189
- *
190
- * conditionMarker: "mth",
191
- *
192
- * conditionValue: 1,
193
- *
194
- * pageId: 0,
195
- *
196
- * },
197
- *
198
- * {
199
- *
200
- * attributeMarker: "price",
201
- *
202
- * conditionMarker: "lth",
203
- *
204
- * conditionValue: 3,
205
- *
206
- * pageId: 0,
207
- *
208
- * },
209
- *
210
- * ];
211
- *
212
182
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
213
183
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
214
184
  *
@@ -218,6 +188,24 @@ class ProductApi extends oneEntry_1.default {
218
188
  *
219
189
  * @param {string} [userQuery.sortKey] - Optional field to sort by
220
190
  *
191
+ *
192
+ * @example
193
+ * const body = [
194
+ *{
195
+ * attributeMarker: "price",
196
+ * conditionMarker: "mth",
197
+ * conditionValue: 1,
198
+ * pageId: 0
199
+ *},
200
+ *{
201
+ * attributeMarker: "price",
202
+ * conditionMarker: "lth",
203
+ * conditionValue: 3,
204
+ * pageId: 0
205
+ *},
206
+ *];
207
+ *
208
+ *
221
209
  * @returns Array with ProductEntity objects
222
210
  */
223
211
  async filterProduct(data, langCode = this._defaultLangCode, userQuery) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.60",
3
+ "version": "1.0.61",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",