oneentry 1.0.34 → 1.0.35

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
@@ -51,18 +51,33 @@ const api = defineOneEntry('your-url')
51
51
 
52
52
  >If you chose token protection to ensure connection security, just pass your token to the function as an optional parameter.
53
53
 
54
+ You can get a token as follows
55
+ 1) Log in to your personal account
56
+ 2) Go to the "Projects" tab and select a project
57
+ 3) Go to the "Access" tab
58
+ 4) Set the switch to "Security API Token"
59
+ 5) Log in to the project, go to the settings section and open the token tab
60
+ 6) Get and copy the token of your project
61
+
62
+ [Learn more about security](https://oneentry.ru/instructions.html#START)
63
+
64
+
54
65
  ```js
55
66
  const api = defineOneEntry('your-url', 'your-token')
56
67
  ```
57
68
 
69
+
70
+
58
71
  ## Admins
59
72
 
73
+
60
74
  ```js
61
75
  const { Admins } = defineOneEntry('your-url')
62
76
  ```
63
77
 
64
78
  ### Admins.getAdminsInfo(langCode, offset, limit)
65
79
 
80
+
66
81
  ```js
67
82
  const value = await Admins.getAdminsInfo('en_US', 0, 30)
68
83
  ```
@@ -70,7 +85,9 @@ const value = await Admins.getAdminsInfo('en_US', 0, 30)
70
85
 
71
86
  > This method retrieves all user objects of type admin from the API. It returns a Promise that resolves to an array of AdminEntity objects.
72
87
 
73
- Example return:
88
+ <details>
89
+
90
+ <summary>Example return:</summary>
74
91
 
75
92
  ```json
76
93
  [
@@ -91,6 +108,11 @@ Example return:
91
108
  }
92
109
  ]
93
110
  ```
111
+ </details>
112
+
113
+ ---
114
+
115
+
94
116
 
95
117
  ## AttributesSets
96
118
 
@@ -106,7 +128,10 @@ const value = await AttributesSets.getAttributesByMarker('my-marker', 'en_US')
106
128
 
107
129
  > This method return all attributes with data from the attribute sets.
108
130
 
109
- Example return:
131
+ <details>
132
+
133
+ <summary>Example return:</summary>
134
+
110
135
 
111
136
  ```json
112
137
  [
@@ -144,6 +169,9 @@ Example return:
144
169
  }
145
170
  ]
146
171
  ```
172
+ </details>
173
+
174
+
147
175
 
148
176
  ### AttributesSets.getSingleAttributeByMarkerSet(attributeMarker, setMarker, langCode)
149
177
 
@@ -153,7 +181,9 @@ const value = await AttributesSets.getSingleAttributeByMarkerSet('list1', 'list1
153
181
 
154
182
  > This method return a single attribute with data from the attribute sets.
155
183
 
156
- Example return:
184
+ <details>
185
+
186
+ <summary>Example return:</summary>
157
187
 
158
188
  ```json
159
189
  {
@@ -189,65 +219,17 @@ Example return:
189
219
  ]
190
220
  }
191
221
  ```
222
+ </details>
192
223
 
224
+ ---
193
225
 
194
- ## Blocks
195
226
 
196
- ```js
197
- const { Blocks } = defineOneEntry('your-url');
198
- ```
199
227
 
200
- ### Blocks.getBlocks(langCode, offset, limit)
201
228
 
202
- ```js
203
- const value = await Blocks.getBlocks('en_US', 0, 30)
204
- ```
205
-
206
- > This method return all blocks objects.
207
-
208
- Example return:
229
+ ## Blocks
209
230
 
210
- ```json
211
- [
212
- {
213
- "id": 1764,
214
- "attributeSetId": 7,
215
- "localizeInfos": {
216
- "en_US": {
217
- "title": "My block"
218
- }
219
- },
220
- "customSettings": {
221
- "sliderDelay": 0,
222
- "sliderDelayType": "",
223
- "productQuantity": 4,
224
- "productSortType": "By_ID",
225
- "productSortOrder": "Descending",
226
- "productCountElementsPerRow": 10,
227
- "similarProductRules": [
228
- {
229
- "property": "Descending",
230
- "includes": "",
231
- "keywords": "",
232
- "strict": ""
233
- }
234
- ]
235
- },
236
- "version": 10,
237
- "identifier": "catalog",
238
- "position": 192,
239
- "attributeValues": {
240
- "en_US": {
241
- "marker": {
242
- "value": "",
243
- "type": "string"
244
- }
245
- }
246
- },
247
- "type": "forNewsPage",
248
- "templateIdentifier": null
249
- }
250
- ]
231
+ ```js
232
+ const { Blocks } = defineOneEntry('your-url');
251
233
  ```
252
234
 
253
235
  ### Blocks.getBlockByMarker(marker, langCode)
@@ -258,7 +240,9 @@ const value = await Blocks.getBlockByMarker('my-marker', 'en_US')
258
240
 
259
241
  > This method return one blocks object by marker.
260
242
 
261
- Example return:
243
+ <details>
244
+
245
+ <summary>Example return:</summary>
262
246
 
263
247
  ```json
264
248
  {
@@ -300,6 +284,13 @@ Example return:
300
284
  "templateIdentifier": null
301
285
  }
302
286
  ```
287
+ </details>
288
+
289
+ ---
290
+
291
+
292
+
293
+
303
294
 
304
295
  ## FileUploading
305
296
 
@@ -323,7 +314,9 @@ const value = await FileUploading.upload(data, query)
323
314
  > This method uploads a file to a cloud file storage. Pass to the date the value obtained from input type "file".
324
315
  > Data is file object (or array), learn more - [File Object](https://developer.mozilla.org/en-US/docs/Web/API/File)
325
316
 
326
- Example return:
317
+ <details>
318
+
319
+ <summary>Example return:</summary>
327
320
 
328
321
  ```json
329
322
  [
@@ -334,6 +327,8 @@ Example return:
334
327
  }
335
328
  ]
336
329
  ```
330
+ </details>
331
+
337
332
 
338
333
  ### FileUploading.delete(filename, fileQuery)
339
334
 
@@ -358,13 +353,21 @@ const value = await FileUploading.getFile(123, 'page', 'editor', 'file.png')
358
353
 
359
354
  > This method return file object by parameters.
360
355
 
361
- Example return:
356
+ <details>
357
+
358
+ <summary>Example return:</summary>
362
359
 
363
360
  ```json
364
361
  {
365
362
  "file": "string"
366
363
  }
367
364
  ```
365
+ </details>
366
+
367
+ ---
368
+
369
+
370
+
368
371
 
369
372
  ## Forms
370
373
 
@@ -378,7 +381,9 @@ const value = await Forms.getAllForms('en_US', 0, 30)
378
381
 
379
382
  > This method retrieves all form objects from the API. It returns a Promise that resolves to an array of FormEntity objects.
380
383
 
381
- Example return:
384
+ <details>
385
+
386
+ <summary>Example return:</summary>
382
387
 
383
388
  ```json
384
389
  [
@@ -431,6 +436,9 @@ Example return:
431
436
  }
432
437
  ]
433
438
  ```
439
+ </details>
440
+
441
+
434
442
 
435
443
  ### Forms.getFormByMarker(marker, langCode)
436
444
 
@@ -440,7 +448,9 @@ const value = await Forms.getFormByMarker('My form', 'en_US')
440
448
 
441
449
  > This method retrieves a single form object based on its textual identifier (marker) from the API. It returns a Promise that resolves to a FormEntity object.
442
450
 
443
- Example return:
451
+ <details>
452
+
453
+ <summary>Example return:</summary>
444
454
 
445
455
  ```json
446
456
  {
@@ -491,6 +501,11 @@ Example return:
491
501
  ]
492
502
  }
493
503
  ```
504
+ </details>
505
+
506
+ ---
507
+
508
+
494
509
 
495
510
  ## FormData
496
511
 
@@ -504,7 +519,9 @@ const value = await FormData.postFormsData(data)
504
519
 
505
520
  > This method retrieves all form data objects from the API. It returns a Promise that resolves to an array of objects of type CreateFormDataDto.
506
521
 
507
- Example return:
522
+ <details>
523
+
524
+ <summary>Example return:</summary>
508
525
 
509
526
  ```json
510
527
  {
@@ -521,6 +538,8 @@ Example return:
521
538
  }
522
539
  }
523
540
  ```
541
+ </details>
542
+
524
543
 
525
544
  ### FormData.getFormsData(langCode, offset, limit)
526
545
 
@@ -530,7 +549,9 @@ const value = await FormData.getFormsData('en_US', 0, 30)
530
549
 
531
550
  > This method creates form data objects by sending a request to the API. It accepts an array of objects of type IFormsPost as the request body to provide the necessary form data. It returns a Promise that resolves to the created CreateFormDataDto objects.
532
551
 
533
- Example return:
552
+ <details>
553
+
554
+ <summary>Example return:</summary>
534
555
 
535
556
  ```json
536
557
  {
@@ -548,6 +569,9 @@ Example return:
548
569
  "attributeSetIdentifier": "test-form"
549
570
  }
550
571
  ```
572
+ </details>
573
+
574
+
551
575
 
552
576
  ### FormData.getFormsDataByMarker(marker, langCode, offset, limit)
553
577
 
@@ -557,7 +581,9 @@ const value = await FormData.getFormsDataByMarker('my-marker', 'en_US', 0, 30)
557
581
 
558
582
  > This method retrieves a specific form data object by its marker from the API. It accepts a marker parameter as the marker of the form data. It returns a Promise that resolves to an array of objects of type FormDataEntity.
559
583
 
560
- Example return:
584
+ <details>
585
+
586
+ <summary>Example return:</summary>
561
587
 
562
588
  ```json
563
589
  {
@@ -575,6 +601,11 @@ Example return:
575
601
  "attributeSetIdentifier": "test-form"
576
602
  }
577
603
  ```
604
+ </details>
605
+
606
+ ---
607
+
608
+
578
609
 
579
610
  ## GeneralTypes
580
611
 
@@ -588,7 +619,9 @@ const value = await GeneralTypes.getAllTypes()
588
619
 
589
620
  > This method retrieves all objects of type GeneralTypeEntity from the API. It returns a Promise that resolves to an array of GeneralTypeEntity objects.
590
621
 
591
- Example return:
622
+ <details>
623
+
624
+ <summary>Example return:</summary>
592
625
 
593
626
  ```json
594
627
  [
@@ -598,6 +631,11 @@ Example return:
598
631
  }
599
632
  ]
600
633
  ```
634
+ </details>
635
+
636
+ ---
637
+
638
+
601
639
 
602
640
  ## Locales
603
641
 
@@ -613,7 +651,9 @@ const value = await Locales.getLocales()
613
651
 
614
652
  > This method retrieves all active language localization objects from the API. It returns a Promise that resolves to an array of LocaleEntity objects.
615
653
 
616
- Example return:
654
+ <details>
655
+
656
+ <summary>Example return:</summary>
617
657
 
618
658
  ```json
619
659
  [
@@ -629,6 +669,11 @@ Example return:
629
669
  }
630
670
  ]
631
671
  ```
672
+ </details>
673
+
674
+ ---
675
+
676
+
632
677
 
633
678
  ## Menus
634
679
 
@@ -644,7 +689,9 @@ const value = await Menus.getMenusByMarker('my-marker')
644
689
 
645
690
  > This method retrieves a single menu object based on its marker (marker) from the API. It returns a Promise that resolves to a single menu object as a ContentMenuDto object with included pages.
646
691
 
647
- Example return:
692
+ <details>
693
+
694
+ <summary>Example return:</summary>
648
695
 
649
696
  ```json
650
697
  {
@@ -672,6 +719,11 @@ Example return:
672
719
  ]
673
720
  }
674
721
  ```
722
+ </details>
723
+
724
+ ---
725
+
726
+
675
727
 
676
728
  ## Pages
677
729
 
@@ -744,7 +796,9 @@ const value = await Pages.getRootPages('en_US')
744
796
 
745
797
  > This method retrieves all top-level page objects from the API. It returns a Promise that resolves to an array of ContentIndexedPageDto objects or an empty array [] if there is no data. Get required language parameter.
746
798
 
747
- Example return:
799
+ <details>
800
+
801
+ <summary>Example return:</summary>
748
802
 
749
803
  ```json
750
804
  [
@@ -783,6 +837,8 @@ Example return:
783
837
  }
784
838
  ]
785
839
  ```
840
+ </details>
841
+
786
842
 
787
843
  ### Pages.getCatalogPages(langCode, limit, offset)
788
844
 
@@ -792,7 +848,9 @@ const value = await Pages.getCatalogPages('en_US', 0, 30)
792
848
 
793
849
  > This method retrieves all page objects with product information as an array from the API. It accepts two optional parameters limit and offset for pagination and language code parameter. It returns a Promise that resolves to an array of ContentIndexedPageDto objects or an empty array [] if there is no data.
794
850
 
795
- Example return:
851
+ <details>
852
+
853
+ <summary>Example return:</summary>
796
854
 
797
855
  ```json
798
856
  [
@@ -831,6 +889,8 @@ Example return:
831
889
  }
832
890
  ]
833
891
  ```
892
+ </details>
893
+
834
894
 
835
895
  ### Pages.getPages(langCode)
836
896
 
@@ -840,7 +900,9 @@ const value = await Pages.getPages('en_US')
840
900
 
841
901
  > This method retrieves all created pages as an array from the API. It returns a Promise that resolves to an array of ContentIndexedPageDto objects or an empty array [] if there is no data. Get required language parameter.
842
902
 
843
- Example return:
903
+ <details>
904
+
905
+ <summary>Example return:</summary>
844
906
 
845
907
  ```json
846
908
  [
@@ -879,6 +941,8 @@ Example return:
879
941
  }
880
942
  ]
881
943
  ```
944
+ </details>
945
+
882
946
 
883
947
  ### Pages.getPageById(id, langCode)
884
948
 
@@ -888,7 +952,9 @@ const value = await Pages.getPageById(1, 'en_US')
888
952
 
889
953
  > This method retrieves a single page object based on its identifier (id) from the API. It returns a Promise that resolves to the page object, with the specific DTO depending on the type of page being returned. Get required language parameter.
890
954
 
891
- Example return:
955
+ <details>
956
+
957
+ <summary>Example return:</summary>
892
958
 
893
959
  ```json
894
960
  {
@@ -919,6 +985,8 @@ Example return:
919
985
  "products": 0
920
986
  }
921
987
  ```
988
+ </details>
989
+
922
990
 
923
991
  ### Pages.getPageByUrl(url, langCode)
924
992
 
@@ -928,7 +996,9 @@ const value = await Pages.getPageByUrl('shop', 'en_US')
928
996
 
929
997
  > This method retrieves a single page object based on its URL (url) from the API. It returns a Promise that resolves to the page object, with the specific DTO depending on the type of page being returned. Get required language parameter.
930
998
 
931
- Example return:
999
+ <details>
1000
+
1001
+ <summary>Example return:</summary>
932
1002
 
933
1003
  ```json
934
1004
  {
@@ -959,6 +1029,8 @@ Example return:
959
1029
  "products": 0
960
1030
  }
961
1031
  ```
1032
+ </details>
1033
+
962
1034
 
963
1035
  ### Pages.getChildPagesByParentUrl(url, langCode)
964
1036
 
@@ -968,7 +1040,9 @@ const value = await Pages.getChildPagesByParentUrl('shop', 'en_US')
968
1040
 
969
1041
  > Getting child pages with information about products in the form of an array. Returns all created pages as an array of AdminIndexedPageDto objects or an empty array [] (if there is no data) for the selected parent.
970
1042
 
971
- Example return:
1043
+ <details>
1044
+
1045
+ <summary>Example return:</summary>
972
1046
 
973
1047
  ```json
974
1048
  [
@@ -1001,6 +1075,8 @@ Example return:
1001
1075
  }
1002
1076
  ]
1003
1077
  ```
1078
+ </details>
1079
+
1004
1080
 
1005
1081
  ### Pages.getBlocksByPageUrl(url, langCode)
1006
1082
 
@@ -1010,7 +1086,9 @@ const value = await Pages.getFormsByPageUrl('shop', 'en_US')
1010
1086
 
1011
1087
  > Get PositionBlock objects for a related form by url. Returns an array of PositionBlock objects.
1012
1088
 
1013
- Example return:
1089
+ <details>
1090
+
1091
+ <summary>Example return:</summary>
1014
1092
 
1015
1093
  ```json
1016
1094
  [
@@ -1055,6 +1133,8 @@ Example return:
1055
1133
  }
1056
1134
  ]
1057
1135
  ```
1136
+ </details>
1137
+
1058
1138
 
1059
1139
  ### Pages.getFormsByPageUrl(url, langCode)
1060
1140
 
@@ -1064,7 +1144,9 @@ const value = await Pages.getFormsByPageUrl('shop', 'en_US')
1064
1144
 
1065
1145
  > Get PositionForm objects for a related form by url. Returns an array of PositionForm objects.
1066
1146
 
1067
- Example return:
1147
+ <details>
1148
+
1149
+ <summary>Example return:</summary>
1068
1150
 
1069
1151
  ```json
1070
1152
  [
@@ -1117,6 +1199,8 @@ Example return:
1117
1199
  }
1118
1200
  ]
1119
1201
  ```
1202
+ </details>
1203
+
1120
1204
 
1121
1205
  ### Pages.getConfigPageByUrl(url)
1122
1206
 
@@ -1126,7 +1210,9 @@ const value = await Pages.getConfigPageByUrl('shop')
1126
1210
 
1127
1211
  > This method retrieves the settings for a specific page based on its URL (url). It returns a Promise that resolves to a ConfigPageDto object with page display settings.
1128
1212
 
1129
- Example return:
1213
+ <details>
1214
+
1215
+ <summary>Example return:</summary>
1130
1216
 
1131
1217
  ```json
1132
1218
  {
@@ -1134,6 +1220,8 @@ Example return:
1134
1220
  "productsPerRow": 10
1135
1221
  }
1136
1222
  ```
1223
+ </details>
1224
+
1137
1225
 
1138
1226
  ### Pages.searchPage(name, langCode)
1139
1227
 
@@ -1143,7 +1231,9 @@ const value = await Pages.searchPage('cup', 'en_US')
1143
1231
 
1144
1232
  > This method performs a quick search for page objects based on a text query (name). It returns a Promise that resolves to a ContentIndexedPageDto objects or an empty array []. Get required language parameter.
1145
1233
 
1146
- Example return:
1234
+ <details>
1235
+
1236
+ <summary>Example return:</summary>
1147
1237
 
1148
1238
  ```json
1149
1239
  [
@@ -1176,6 +1266,11 @@ Example return:
1176
1266
  }
1177
1267
  ]
1178
1268
  ```
1269
+ </details>
1270
+
1271
+ ---
1272
+
1273
+
1179
1274
 
1180
1275
  ## Products
1181
1276
 
@@ -1282,7 +1377,9 @@ const value = await Products.getProducts('en_US', userQuery)
1282
1377
 
1283
1378
  > This method searches for product page objects with pagination and filtering based on the provided query parameters (userQuery). It returns a Promise that resolves to a list of products (IProduct[]).
1284
1379
 
1285
- Example return:
1380
+ <details>
1381
+
1382
+ <summary>Example return:</summary>
1286
1383
 
1287
1384
  ```json
1288
1385
  [
@@ -1317,6 +1414,8 @@ Example return:
1317
1414
  }
1318
1415
  ]
1319
1416
  ```
1417
+ </details>
1418
+
1320
1419
 
1321
1420
  ### Products.getProductsEmptyPage(langCode, userQuery)
1322
1421
 
@@ -1326,7 +1425,9 @@ const value = await Products.getProductsEmptyPage('en_US', userQuery)
1326
1425
 
1327
1426
  > This method searches for product page objects with pagination that do not have a category, based on the provided query parameters (userQuery). It returns a Promise that resolves to an array of items, where each item is a ContentIndexedProductDto object.
1328
1427
 
1329
- Example return:
1428
+ <details>
1429
+
1430
+ <summary>Example return:</summary>
1330
1431
 
1331
1432
  ```json
1332
1433
  [
@@ -1361,6 +1462,8 @@ Example return:
1361
1462
  }
1362
1463
  ]
1363
1464
  ```
1465
+ </details>
1466
+
1364
1467
 
1365
1468
  ### Products.getProductsPageById(id, langCode, userQuery)
1366
1469
 
@@ -1370,7 +1473,9 @@ const value = await Products.getProductsPageById(1, 'en_US', userQuery)
1370
1473
 
1371
1474
  > This method searches for all product page objects with pagination for the selected category based on the page identifier (id). It accepts an optional userQuery parameter to set query parameters for the search. The query parameters include limit, offset, statusMarker, conditionValue, conditionMarker, attributeMarker, sortOrder, and sortKey. It returns a Promise that resolves to an array of ContentIndexedProductDto objects.
1372
1475
 
1373
- Example return:
1476
+ <details>
1477
+
1478
+ <summary>Example return:</summary>
1374
1479
 
1375
1480
  ```json
1376
1481
  {
@@ -1407,6 +1512,8 @@ Example return:
1407
1512
  "position": 1
1408
1513
  }
1409
1514
  ```
1515
+ </details>
1516
+
1410
1517
 
1411
1518
  ### Products.getProductsPageByUrl(url, langCode, userQuery)
1412
1519
 
@@ -1416,7 +1523,9 @@ const value = await Products.getProductsPageByUrl('cup', 'en_US', userQuery)
1416
1523
 
1417
1524
  > This method searches for all product page objects with pagination for the selected category based on the page URL (url). It accepts an optional userQuery parameter to set query parameters for the search. The query parameters include limit, offset, statusMarker, conditionValue, conditionMarker, attributeMarker, sortOrder, and sortKey. It returns a Promise that resolves to an array of ContentIndexedProductDto objects.
1418
1525
 
1419
- Example return:
1526
+ <details>
1527
+
1528
+ <summary>Example return:</summary>
1420
1529
 
1421
1530
  ```json
1422
1531
  {
@@ -1452,6 +1561,8 @@ Example return:
1452
1561
  "position": 1
1453
1562
  }
1454
1563
  ```
1564
+ </details>
1565
+
1455
1566
 
1456
1567
  ### Products.getRelatedProductsById(id, langCode, userQuery)
1457
1568
 
@@ -1461,7 +1572,9 @@ const value = await Products.getRelatedProductsById(1, 'en_US', {limit:20, offse
1461
1572
 
1462
1573
  > This method retrieves all related product page objects for a specific product based on its identifier (id) from the API. It accepts an optional userQuery parameter for additional query parameters such as limit, offset, sortOrder, and sortKey. It returns a Promise that resolves to an array of ContentIndexedProductDto objects.
1463
1574
 
1464
- Example return:
1575
+ <details>
1576
+
1577
+ <summary>Example return:</summary>
1465
1578
 
1466
1579
  ```json
1467
1580
  {
@@ -1494,6 +1607,8 @@ Example return:
1494
1607
  "position": 1
1495
1608
  }
1496
1609
  ```
1610
+ </details>
1611
+
1497
1612
 
1498
1613
  ### Products.getProductById(id, langCode)
1499
1614
 
@@ -1503,7 +1618,9 @@ const value = await Products.getProductById(1, 'en_US')
1503
1618
 
1504
1619
  > This method retrieves a single product object based on its identifier (id) from the API. It returns a Promise that resolves to a ContentIndexedProductDto object for the product.
1505
1620
 
1506
- Example return:
1621
+ <details>
1622
+
1623
+ <summary>Example return:</summary>
1507
1624
 
1508
1625
  ```json
1509
1626
  {
@@ -1535,8 +1652,9 @@ Example return:
1535
1652
  },
1536
1653
  "position": 1
1537
1654
  }
1538
-
1539
1655
  ```
1656
+ </details>
1657
+
1540
1658
 
1541
1659
  ### Products.filterProduct(data, langCode, userQuery)
1542
1660
 
@@ -1571,7 +1689,9 @@ Example body:
1571
1689
 
1572
1690
  > This method filters product page objects with pagination and multiple filtering based on the provided data request body. The data parameter should be an array of {attributeMarker:string,conditionMarker:string,conditionValue:number,pageId:number}.
1573
1691
 
1574
- Example return:
1692
+ <details>
1693
+
1694
+ <summary>Example return:</summary>
1575
1695
 
1576
1696
  ```json
1577
1697
  {
@@ -1608,6 +1728,8 @@ Example return:
1608
1728
  "position": 1
1609
1729
  }
1610
1730
  ```
1731
+ </details>
1732
+
1611
1733
 
1612
1734
  ### Products.searchProduct(name, langCode)
1613
1735
 
@@ -1617,7 +1739,9 @@ const value = await Products.searchProduct('cup', 'en_US')
1617
1739
 
1618
1740
  > This method performs a quick search for product page objects based on a text query name. The search is performed on the title field of the localizeInfos object, taking the specified lang language code into consideration. It returns a Promise that resolves to an array of ContentIndexedProductDto objects.
1619
1741
 
1620
- Example return:
1742
+ <details>
1743
+
1744
+ <summary>Example return:</summary>
1621
1745
 
1622
1746
  ```json
1623
1747
  [
@@ -1656,6 +1780,11 @@ Example return:
1656
1780
  }
1657
1781
  ]
1658
1782
  ```
1783
+ </details>
1784
+
1785
+ ---
1786
+
1787
+
1659
1788
 
1660
1789
  ## ProductStatuses
1661
1790
 
@@ -1671,7 +1800,9 @@ const value = await ProductStatuses.getProductStatuses()
1671
1800
 
1672
1801
  > This method searches for all product status objects from the API. It returns a Promise that resolves to an array of product status objects.
1673
1802
 
1674
- Example return:
1803
+ <details>
1804
+
1805
+ <summary>Example return:</summary>
1675
1806
 
1676
1807
  ```json
1677
1808
  [
@@ -1688,6 +1819,8 @@ Example return:
1688
1819
  }
1689
1820
  ]
1690
1821
  ```
1822
+ </details>
1823
+
1691
1824
 
1692
1825
  ### ProductStatuses.getProductStatusesById(id)
1693
1826
 
@@ -1697,7 +1830,9 @@ const value = await ProductStatuses.getProductStatusesById(1)
1697
1830
 
1698
1831
  > This method searches for a product status object based on its identifier (id) from the API. It returns a Promise that resolves to a product status object.
1699
1832
 
1700
- Example return:
1833
+ <details>
1834
+
1835
+ <summary>Example return:</summary>
1701
1836
 
1702
1837
  ```json
1703
1838
  {
@@ -1712,6 +1847,8 @@ Example return:
1712
1847
  }
1713
1848
  }
1714
1849
  ```
1850
+ </details>
1851
+
1715
1852
 
1716
1853
  ### ProductStatuses.getProductsByStatusMarker(marker)
1717
1854
 
@@ -1721,7 +1858,9 @@ const value = await ProductStatuses.getProductsByStatusMarker('my-marker')
1721
1858
 
1722
1859
  > This method searches for a product status object based on its textual identifier (marker) from the API. It returns a Promise that resolves to a product status object.
1723
1860
 
1724
- Example return:
1861
+ <details>
1862
+
1863
+ <summary>Example return:</summary>
1725
1864
 
1726
1865
  ```json
1727
1866
  {
@@ -1736,6 +1875,8 @@ Example return:
1736
1875
  }
1737
1876
  }
1738
1877
  ```
1878
+ </details>
1879
+
1739
1880
 
1740
1881
  ### ProductStatuses.validateMarker(marker)
1741
1882
 
@@ -1745,11 +1886,18 @@ const value = await ProductStatuses.validateMarker('marker')
1745
1886
 
1746
1887
  > This method checks the existence of a textual identifier (marker). It takes a marker parameter as input, representing the product marker to validate. It returns a Promise that resolves to true if the textual identifier (marker) exists or false if it doesn't.
1747
1888
 
1748
- Example return:
1889
+ <details>
1890
+
1891
+ <summary>Example return:</summary>
1749
1892
 
1750
1893
  ```json
1751
1894
  true
1752
1895
  ```
1896
+ </details>
1897
+
1898
+ ---
1899
+
1900
+
1753
1901
 
1754
1902
  ## System
1755
1903
 
@@ -1788,7 +1936,9 @@ const value = await Templates.getAllTemplates()
1788
1936
 
1789
1937
  > This method retrieves all template objects grouped by types from the API. It returns a Promise that resolves to an object GroupedTemplatesObject, which contains an array of template objects.
1790
1938
 
1791
- Example return:
1939
+ <details>
1940
+
1941
+ <summary>Example return:</summary>
1792
1942
 
1793
1943
  ```json
1794
1944
  [
@@ -1813,6 +1963,8 @@ Example return:
1813
1963
  }
1814
1964
  ]
1815
1965
  ```
1966
+ </details>
1967
+
1816
1968
 
1817
1969
  ### Templates.getTemplateByType(type)
1818
1970
 
@@ -1822,7 +1974,9 @@ const value = await Templates.getTemplateByType('forCatalogProducts')
1822
1974
 
1823
1975
  > This method retrieves a single template object based on its identifier (id) from the API. It returns a Promise that resolves to a template object.
1824
1976
 
1825
- Example return:
1977
+ <details>
1978
+
1979
+ <summary>Example return:</summary>
1826
1980
 
1827
1981
  ```json
1828
1982
  [
@@ -1847,6 +2001,8 @@ Example return:
1847
2001
  }
1848
2002
  ]
1849
2003
  ```
2004
+ </details>
2005
+
1850
2006
 
1851
2007
  ## TemplatePreviews
1852
2008
 
@@ -1862,7 +2018,9 @@ const value = await TemplatePreviews.getTemplatePreviews()
1862
2018
 
1863
2019
  > This method retrieves all template objects from the API. It returns a Promise that resolves to an array of TemplatePreviewsEntity template objects.
1864
2020
 
1865
- Example return:
2021
+ <details>
2022
+
2023
+ <summary>Example return:</summary>
1866
2024
 
1867
2025
  ```json
1868
2026
  [
@@ -1902,6 +2060,8 @@ Example return:
1902
2060
  }
1903
2061
  ]
1904
2062
  ```
2063
+ </details>
2064
+
1905
2065
 
1906
2066
  ### TemplatePreviews.getTemplatesPreviewById(id)
1907
2067
 
@@ -1911,7 +2071,9 @@ const value = await TemplatePreviews.getTemplatePreviewById(1)
1911
2071
 
1912
2072
  > This method retrieves a single template object based on its identifier (id) from the API. It returns a Promise that resolves to a TemplatePreviewsEntity object.
1913
2073
 
1914
- Example return:
2074
+ <details>
2075
+
2076
+ <summary>Example return:</summary>
1915
2077
 
1916
2078
  ```json
1917
2079
  {
@@ -1949,6 +2111,8 @@ Example return:
1949
2111
  "position": 0
1950
2112
  }
1951
2113
  ```
2114
+ </details>
2115
+
1952
2116
 
1953
2117
  ### TemplatePreviews.getTemplatesPreviewByMarker(marker)
1954
2118
 
@@ -1958,7 +2122,11 @@ const value = await TemplatePreviews.getTemplatePreviewByMarker('my-marker')
1958
2122
 
1959
2123
  > This method retrieves a single template object based on its textual identifier (marker) from the API. It returns a Promise that resolves to a TemplatePreviewsEntity object.
1960
2124
 
1961
- Example return:
2125
+ <details>
2126
+
2127
+ <summary>Example return:</summary>
2128
+
2129
+
1962
2130
 
1963
2131
  ```json
1964
2132
  {
@@ -1995,4 +2163,5 @@ Example return:
1995
2163
  },
1996
2164
  "position": 0
1997
2165
  }
1998
- ```
2166
+ ```
2167
+ </details>
@@ -5,6 +5,7 @@ export default abstract class OneEntry {
5
5
  protected _url: string;
6
6
  protected _token: string;
7
7
  protected _LANGCODE_KEY: string;
8
+ protected _NO_FETCH: boolean;
8
9
  constructor(url: string, token?: string);
9
10
  protected _getFullPath(path: string): string;
10
11
  protected _fetchGet(path: string): Promise<any>;
@@ -1,49 +1,114 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const https = require('https');
3
4
  class OneEntry {
4
5
  constructor(url, token) {
5
6
  this._LANGCODE_KEY = '$LANGCODE';
7
+ this._NO_FETCH = false;
6
8
  this._url = url;
7
9
  if (token) {
8
10
  this._token = token;
9
11
  }
12
+ if (typeof process === 'object' && process.versions && process.versions.node) {
13
+ this._NO_FETCH = true;
14
+ }
10
15
  }
11
16
  _getFullPath(path) {
12
17
  return (this._url + path);
13
18
  }
14
19
  async _fetchGet(path) {
15
- const response = await fetch(this._getFullPath(path), {
20
+ const options = {
16
21
  method: 'GET',
17
22
  headers: {
18
23
  'Content-Type': 'application/json',
19
24
  'x-app-token': this._token,
20
25
  }
21
- });
22
- const result = await response.json();
23
- return result;
26
+ };
27
+ if (!this._NO_FETCH) {
28
+ const response = await fetch(this._getFullPath(path), options);
29
+ const result = await response.json();
30
+ return result;
31
+ }
32
+ else {
33
+ return new Promise((resolve, reject) => {
34
+ const req = https.get(this._getFullPath(path), options, (res) => {
35
+ let data = '';
36
+ res.on('data', (chunk) => {
37
+ data += chunk;
38
+ });
39
+ res.on('end', () => {
40
+ resolve(JSON.parse(data));
41
+ });
42
+ });
43
+ req.on('error', (error) => {
44
+ reject(error);
45
+ });
46
+ });
47
+ }
24
48
  }
25
49
  async _fetchPost(path, data) {
26
- const response = await fetch(this._getFullPath(path), {
50
+ const options = {
27
51
  method: 'POST',
28
52
  headers: {
29
53
  'Content-Type': 'application/json',
30
54
  'x-app-token': this._token,
31
- },
32
- body: JSON.stringify(data)
33
- });
34
- const result = await response.json();
35
- return result;
55
+ }
56
+ };
57
+ if (!this._NO_FETCH) {
58
+ const response = await fetch(this._getFullPath(path), {
59
+ ...options,
60
+ body: JSON.stringify(data)
61
+ });
62
+ return await response.json();
63
+ }
64
+ else {
65
+ return new Promise((resolve, reject) => {
66
+ const req = https.request(this._getFullPath(path), options, (res) => {
67
+ let responseData = '';
68
+ res.on('data', (chunk) => {
69
+ responseData += chunk;
70
+ });
71
+ res.on('end', () => {
72
+ resolve(JSON.parse(responseData));
73
+ });
74
+ });
75
+ req.on('error', (error) => {
76
+ reject(error);
77
+ });
78
+ req.write(JSON.stringify(data));
79
+ req.end();
80
+ });
81
+ }
36
82
  }
37
83
  async _fetchDelete(path) {
38
- const response = await fetch(this._getFullPath(path), {
84
+ const options = {
39
85
  method: 'DELETE',
40
86
  headers: {
41
87
  'Content-Type': 'application/json',
42
88
  'x-app-token': this._token,
43
- },
44
- });
45
- const result = await response.json();
46
- return result;
89
+ }
90
+ };
91
+ if (!this._NO_FETCH) {
92
+ const response = await fetch(this._getFullPath(path), options);
93
+ const result = await response.json();
94
+ return result;
95
+ }
96
+ else {
97
+ return new Promise((resolve, reject) => {
98
+ const req = https.get(this._getFullPath(path), options, (res) => {
99
+ let data = '';
100
+ res.on('data', (chunk) => {
101
+ data += chunk;
102
+ });
103
+ res.on('end', () => {
104
+ resolve(JSON.parse(data));
105
+ });
106
+ });
107
+ req.on('error', (error) => {
108
+ reject(error);
109
+ });
110
+ });
111
+ }
47
112
  }
48
113
  _queryParamsToString(query) {
49
114
  let result = '';
@@ -5,16 +5,6 @@ import { IBlocks, IBlocksEntity } from "./blocksInterfaces";
5
5
  */
6
6
  export default class BlocksApi extends OneEntry implements IBlocks {
7
7
  constructor(url: string, token: string);
8
- /**
9
- * Get blocks by parameters.
10
- *
11
- * @param {string} [langCode] - Language code. Default "en_US"
12
- * @param {number} [offset] - Parameter for pagination. Default 0
13
- * @param {number} [limit] - Parameter for pagination. Default 30
14
- *
15
- * @returns Return array of BlocksEntity object.
16
- */
17
- getBlocks(langCode?: string, offset?: number, limit?: number): Promise<Array<IBlocksEntity>>;
18
8
  /**
19
9
  * Get block by marker.
20
10
  *
@@ -9,19 +9,19 @@ class BlocksApi extends oneEntry_1.default {
9
9
  super(url, token);
10
10
  this._url += '/api/content/blocks';
11
11
  }
12
- /**
13
- * Get blocks by parameters.
14
- *
15
- * @param {string} [langCode] - Language code. Default "en_US"
16
- * @param {number} [offset] - Parameter for pagination. Default 0
17
- * @param {number} [limit] - Parameter for pagination. Default 30
18
- *
19
- * @returns Return array of BlocksEntity object.
20
- */
21
- async getBlocks(langCode = 'en_US', offset = 0, limit = 30) {
22
- const result = await this._fetchGet(`&langCode=${langCode}&offset=${offset}&limit=${limit}`);
23
- return result;
24
- }
12
+ // /**
13
+ // * Get blocks by parameters.
14
+ // *
15
+ // * @param {string} [langCode] - Language code. Default "en_US"
16
+ // * @param {number} [offset] - Parameter for pagination. Default 0
17
+ // * @param {number} [limit] - Parameter for pagination. Default 30
18
+ // *
19
+ // * @returns Return array of BlocksEntity object.
20
+ // */
21
+ // public async getBlocks(langCode:string = 'en_US', offset:number = 0, limit:number = 30):Promise<Array<IBlocksEntity>>{
22
+ // const result = await this._fetchGet(`&langCode=${langCode}&offset=${offset}&limit=${limit}`)
23
+ // return result
24
+ // }
25
25
  /**
26
26
  * Get block by marker.
27
27
  *
@@ -31,7 +31,7 @@ class BlocksApi extends oneEntry_1.default {
31
31
  * @returns Return BlocksEntity object.
32
32
  */
33
33
  async getBlockByMarker(marker, langCode = 'en_US') {
34
- const result = await this._fetchGet(`/marker/${marker}&langCode=${langCode}`);
34
+ const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
35
35
  return result;
36
36
  }
37
37
  }
@@ -6,7 +6,6 @@ import { IAttributeValues, ILocalizeInfos } from "../base/utils";
6
6
  * @property {function} getBlockByMarker - Get Block object by marker.
7
7
  */
8
8
  interface IBlocks {
9
- getBlocks(langCode: string, offset?: number, limit?: number): Promise<Array<IBlocksEntity>>;
10
9
  getBlockByMarker(marker: string, langCode: string): Promise<IBlocksEntity>;
11
10
  }
12
11
  interface IBlocksEntity {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,5 +12,8 @@
12
12
  "dependencies": {
13
13
  "jsdoc": "^4.0.2",
14
14
  "typescript": "^5.2.2"
15
+ },
16
+ "devDependencies": {
17
+ "@types/node": "^20.10.4"
15
18
  }
16
19
  }