@innet/server 2.0.0-beta.1 → 2.0.0-beta.10

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 (190) hide show
  1. package/README.md +385 -9
  2. package/handler/handler.d.ts +6 -9
  3. package/handler/handler.es6.js +3 -4
  4. package/handler/handler.js +2 -3
  5. package/hooks/index.d.ts +24 -23
  6. package/hooks/index.es6.js +24 -23
  7. package/hooks/index.js +24 -23
  8. package/hooks/useEffect/index.d.ts +1 -0
  9. package/hooks/useEffect/index.es6.js +1 -0
  10. package/hooks/useEffect/index.js +9 -0
  11. package/hooks/useEffect/useEffect.d.ts +2 -0
  12. package/hooks/useEffect/useEffect.es6.js +8 -0
  13. package/hooks/useEffect/useEffect.js +12 -0
  14. package/hooks/useHeaders/useHeaders.d.ts +0 -1
  15. package/hooks/useNewSchema/useNewSchema.es6.js +1 -1
  16. package/hooks/useNewSchema/useNewSchema.js +1 -1
  17. package/hooks/useRequest/useRequest.d.ts +0 -1
  18. package/hooks/useResponse/useResponse.d.ts +0 -1
  19. package/hooks/useSchemaType/useSchemaType.es6.js +17 -9
  20. package/hooks/useSchemaType/useSchemaType.js +17 -9
  21. package/hooks/useServer/useServer.d.ts +0 -2
  22. package/index.d.ts +2 -2
  23. package/index.es6.js +88 -86
  24. package/index.js +201 -194
  25. package/package.json +16 -15
  26. package/plugins/handler/serverFn/serverFn.es6.js +2 -2
  27. package/plugins/handler/serverFn/serverFn.js +2 -6
  28. package/plugins/index.d.ts +2 -2
  29. package/plugins/index.es6.js +2 -2
  30. package/plugins/index.js +2 -2
  31. package/plugins/main/api/api.es6.js +74 -74
  32. package/plugins/main/api/api.js +75 -79
  33. package/plugins/main/body/body.es6.js +4 -4
  34. package/plugins/main/body/body.js +4 -8
  35. package/plugins/main/endpoint/endpoint.d.ts +5 -0
  36. package/plugins/main/endpoint/endpoint.es6.js +5 -5
  37. package/plugins/main/endpoint/endpoint.js +5 -9
  38. package/plugins/main/host/host.es6.js +4 -2
  39. package/plugins/main/host/host.js +4 -6
  40. package/plugins/main/index.d.ts +8 -8
  41. package/plugins/main/index.es6.js +8 -8
  42. package/plugins/main/index.js +8 -8
  43. package/plugins/main/param/param.es6.js +3 -4
  44. package/plugins/main/param/param.js +3 -8
  45. package/plugins/main/preset/preset.es6.js +1 -1
  46. package/plugins/main/preset/preset.js +1 -5
  47. package/plugins/main/response/response.es6.js +11 -4
  48. package/plugins/main/response/response.js +11 -8
  49. package/plugins/main/server/server.d.ts +0 -1
  50. package/plugins/main/server/server.es6.js +7 -10
  51. package/plugins/main/server/server.js +8 -12
  52. package/plugins/main/tag/index.es6.js +1 -1
  53. package/plugins/main/tag/index.js +1 -0
  54. package/plugins/main/tag/tag.d.ts +8 -1
  55. package/plugins/main/tag/tag.es6.js +20 -3
  56. package/plugins/main/tag/tag.js +20 -6
  57. package/plugins/main/variable/variable.es6.js +3 -4
  58. package/plugins/main/variable/variable.js +3 -4
  59. package/plugins/request/cms/cms.es6.js +1 -1
  60. package/plugins/request/cms/cms.js +2 -3
  61. package/plugins/request/cookie/cookie.d.ts +2 -2
  62. package/plugins/request/cookie/cookie.es6.js +1 -2
  63. package/plugins/request/cookie/cookie.js +1 -2
  64. package/plugins/request/error/error.es6.js +1 -2
  65. package/plugins/request/error/error.js +1 -2
  66. package/plugins/request/file/file.es6.js +2 -3
  67. package/plugins/request/file/file.js +2 -4
  68. package/plugins/request/index.d.ts +5 -5
  69. package/plugins/request/index.es6.js +5 -5
  70. package/plugins/request/index.js +5 -5
  71. package/plugins/request/proxy/proxy.d.ts +0 -1
  72. package/plugins/schema/array/array.d.ts +3 -0
  73. package/plugins/schema/array/array.es6.js +14 -6
  74. package/plugins/schema/array/array.js +15 -11
  75. package/plugins/schema/binary/binary.d.ts +4 -0
  76. package/plugins/schema/boolean/boolean.d.ts +1 -0
  77. package/plugins/schema/date/date.d.ts +2 -1
  78. package/plugins/schema/date/date.es6.js +8 -4
  79. package/plugins/schema/date/date.js +8 -4
  80. package/plugins/schema/field/field.d.ts +4 -0
  81. package/plugins/schema/field/field.es6.js +16 -3
  82. package/plugins/schema/field/field.js +16 -7
  83. package/plugins/schema/index.d.ts +8 -8
  84. package/plugins/schema/index.es6.js +8 -8
  85. package/plugins/schema/index.js +8 -8
  86. package/plugins/schema/integer/integer.d.ts +37 -0
  87. package/plugins/schema/integer/integer.es6.js +29 -9
  88. package/plugins/schema/integer/integer.js +29 -9
  89. package/plugins/schema/number/number.d.ts +32 -0
  90. package/plugins/schema/number/number.es6.js +21 -6
  91. package/plugins/schema/number/number.js +21 -6
  92. package/plugins/schema/object/object.es6.js +9 -8
  93. package/plugins/schema/object/object.js +9 -12
  94. package/plugins/schema/string/string.d.ts +27 -0
  95. package/plugins/schema/string/string.es6.js +9 -4
  96. package/plugins/schema/string/string.js +9 -4
  97. package/plugins/schema/tuple/tuple.es6.js +5 -6
  98. package/plugins/schema/tuple/tuple.js +5 -10
  99. package/plugins/schema/uuid/uuid.es6.js +5 -3
  100. package/plugins/schema/uuid/uuid.js +5 -3
  101. package/plugins/utils/dts/dts.es6.js +5 -2
  102. package/plugins/utils/dts/dts.js +5 -2
  103. package/plugins/utils/env/env.es6.js +1 -1
  104. package/plugins/utils/env/env.js +1 -5
  105. package/plugins/utils/index.d.ts +3 -2
  106. package/plugins/utils/index.es6.js +3 -2
  107. package/plugins/utils/index.js +3 -2
  108. package/plugins/utils/swagger/swagger.d.ts +1 -0
  109. package/plugins/utils/swagger/swagger.es6.js +1 -0
  110. package/plugins/utils/swagger/swagger.js +1 -0
  111. package/plugins/utils/ui/index.d.ts +1 -0
  112. package/plugins/utils/ui/index.es6.js +1 -0
  113. package/plugins/utils/ui/index.js +10 -0
  114. package/plugins/utils/ui/rapidoc.html.es6.js +3 -0
  115. package/plugins/utils/ui/rapidoc.html.js +7 -0
  116. package/plugins/utils/ui/redoc.html.es6.js +3 -0
  117. package/plugins/utils/ui/redoc.html.js +7 -0
  118. package/plugins/utils/ui/scalar.html.es6.js +3 -0
  119. package/plugins/utils/ui/scalar.html.js +7 -0
  120. package/plugins/utils/ui/swagger.html.es6.js +3 -0
  121. package/plugins/utils/ui/swagger.html.js +7 -0
  122. package/plugins/utils/ui/ui.d.ts +13 -0
  123. package/plugins/utils/ui/ui.es6.js +45 -0
  124. package/plugins/utils/ui/ui.js +50 -0
  125. package/types.d.ts +6 -0
  126. package/utils/action/Action.d.ts +4 -5
  127. package/utils/action/Action.es6.js +14 -16
  128. package/utils/action/Action.js +13 -15
  129. package/utils/getSafeSchema/getSafeSchema.d.ts +2 -0
  130. package/utils/getSafeSchema/getSafeSchema.es6.js +5 -0
  131. package/utils/getSafeSchema/getSafeSchema.js +9 -0
  132. package/utils/getSafeSchema/index.d.ts +1 -0
  133. package/utils/getSafeSchema/index.es6.js +1 -0
  134. package/utils/getSafeSchema/index.js +9 -0
  135. package/utils/index.d.ts +9 -8
  136. package/utils/index.es6.js +9 -8
  137. package/utils/index.js +9 -8
  138. package/utils/parseBody/parseBody.d.ts +0 -1
  139. package/utils/parseBody/parseBody.es6.js +13 -16
  140. package/utils/parseBody/parseBody.js +13 -16
  141. package/utils/parseFormBody/parseFormBody.d.ts +0 -1
  142. package/utils/parseFormBody/parseFormBody.es6.js +41 -41
  143. package/utils/parseFormBody/parseFormBody.js +41 -41
  144. package/utils/parseSearch/parseSearch.es6.js +4 -1
  145. package/utils/parseSearch/parseSearch.js +4 -1
  146. package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
  147. package/utils/rules/arrayOf/arrayOf.js +1 -1
  148. package/utils/rules/bin/bin.es6.js +4 -1
  149. package/utils/rules/bin/bin.js +4 -1
  150. package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
  151. package/utils/rules/binaryAccept/binaryAccept.js +5 -2
  152. package/utils/rules/dateTo/dateTo.es6.js +4 -1
  153. package/utils/rules/dateTo/dateTo.js +4 -1
  154. package/utils/rules/helpers.es6.js +4 -1
  155. package/utils/rules/helpers.js +4 -1
  156. package/utils/rules/index.d.ts +17 -17
  157. package/utils/rules/index.es6.js +17 -17
  158. package/utils/rules/index.js +18 -18
  159. package/utils/rules/int/int.es6.js +17 -4
  160. package/utils/rules/int/int.js +17 -4
  161. package/utils/rules/max/max.es6.js +9 -3
  162. package/utils/rules/max/max.js +9 -3
  163. package/utils/rules/maxBin/maxBin.es6.js +5 -2
  164. package/utils/rules/maxBin/maxBin.js +5 -2
  165. package/utils/rules/maxDate/maxDate.es6.js +5 -1
  166. package/utils/rules/maxDate/maxDate.js +5 -1
  167. package/utils/rules/maxLength/maxLength.es6.js +5 -2
  168. package/utils/rules/maxLength/maxLength.js +5 -2
  169. package/utils/rules/min/min.es6.js +9 -3
  170. package/utils/rules/min/min.js +9 -3
  171. package/utils/rules/minBin/minBin.es6.js +5 -2
  172. package/utils/rules/minBin/minBin.js +5 -2
  173. package/utils/rules/minDate/minDate.es6.js +5 -1
  174. package/utils/rules/minDate/minDate.js +5 -1
  175. package/utils/rules/minLength/minLength.es6.js +5 -2
  176. package/utils/rules/minLength/minLength.js +5 -2
  177. package/utils/rules/num/num.es6.js +4 -1
  178. package/utils/rules/num/num.js +4 -1
  179. package/utils/rules/objectOf/objectOf.es6.js +6 -3
  180. package/utils/rules/objectOf/objectOf.js +6 -3
  181. package/utils/rules/pattern/pattern.es6.js +6 -2
  182. package/utils/rules/pattern/pattern.js +6 -2
  183. package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
  184. package/utils/rules/tupleOf/tupleOf.js +1 -1
  185. package/utils/rules/values/values.es6.js +5 -2
  186. package/utils/rules/values/values.js +5 -2
  187. package/utils/stringifySearch/stringifySearch.es6.js +4 -1
  188. package/utils/stringifySearch/stringifySearch.js +4 -1
  189. package/_virtual/_rollup-plugin-process-env.es6.js +0 -10
  190. package/_virtual/_rollup-plugin-process-env.js +0 -12
package/README.md CHANGED
@@ -581,7 +581,7 @@ This section contains elements of utils.
581
581
 
582
582
  [← back](#index)
583
583
 
584
- [\<swagger>](#swagger)
584
+ [\<ui>](#ui)
585
585
  [\<env>](#env)
586
586
  [\<dts>](#dts)
587
587
  [\<blacklist>](#blacklist)
@@ -590,40 +590,151 @@ This section contains elements of utils.
590
590
 
591
591
  ---
592
592
 
593
- ### \<swagger>
593
+ ### \<ui>
594
594
 
595
595
  [← back](#utils)
596
596
 
597
- Use `<swagger>` element to add Swagger UI documentation.
598
- `<swagger>` element MUST be placed in `<api>` element.
597
+ Use `<ui>` element to add API documentation UI. This element supports multiple documentation viewers including Swagger UI, RapiDoc, ReDoc, and Scalar.
598
+ `<ui>` element MUST be placed in `<api>` element.
599
599
 
600
600
  *src/app.tsx*
601
601
  ```typescript jsx
602
602
  export default (
603
603
  <server>
604
604
  <api>
605
- <swagger />
605
+ <ui />
606
606
  </api>
607
607
  </server>
608
608
  )
609
609
  ```
610
610
 
611
- Open http://localhost:80/swagger-ui
612
- You will see Swagger UI documentation.
611
+ Open http://localhost:80/ui
612
+ You will see Swagger UI documentation by default.
613
613
 
614
- You can change the Swagger UI URL path by `path` property of `<swagger>` element.
614
+ #### html
615
+
616
+ You can provide custom HTML template for the documentation viewer.
617
+ Built-in presets are available: `uiPresets.swagger`, `uiPresets.rapidoc`, `uiPresets.redoc`, `uiPresets.scalar`.
618
+
619
+ *src/app.tsx*
620
+ ```typescript jsx
621
+ import { uiPresets } from '@innet/server'
622
+
623
+ export default (
624
+ <server>
625
+ <api>
626
+ <ui html={uiPresets.rapidoc} />
627
+ </api>
628
+ </server>
629
+ )
630
+ ```
631
+
632
+ #### params
633
+
634
+ You can pass additional parameters to the documentation viewer. Parameters depend on the selected UI library.
635
+
636
+ For **Swagger UI** (default):
615
637
 
616
638
  *src/app.tsx*
617
639
  ```typescript jsx
618
640
  export default (
619
641
  <server>
620
642
  <api>
621
- <swagger path='/swagger' />
643
+ <ui
644
+ params={{
645
+ docExpansion: 'full',
646
+ filter: true,
647
+ showExtensions: true,
648
+ }}
649
+ />
622
650
  </api>
623
651
  </server>
624
652
  )
625
653
  ```
626
654
 
655
+ For **Scalar**:
656
+
657
+ *src/app.tsx*
658
+ ```typescript jsx
659
+ import { uiPresets } from '@innet/server'
660
+
661
+ export default (
662
+ <server>
663
+ <api>
664
+ <ui
665
+ html={uiPresets.scalar}
666
+ params={{
667
+ theme: 'moon',
668
+ layout: 'classic',
669
+ }}
670
+ />
671
+ </api>
672
+ </server>
673
+ )
674
+ ```
675
+
676
+ For **RapiDoc**:
677
+
678
+ *src/app.tsx*
679
+ ```typescript jsx
680
+ import { uiPresets } from '@innet/server'
681
+
682
+ export default (
683
+ <server>
684
+ <api>
685
+ <ui
686
+ html={uiPresets.rapidoc}
687
+ params={{
688
+ theme: 'dark',
689
+ layout: 'row',
690
+ showHeader: 'false',
691
+ }}
692
+ />
693
+ </api>
694
+ </server>
695
+ )
696
+ ```
697
+
698
+ For **ReDoc**:
699
+
700
+ *src/app.tsx*
701
+ ```typescript jsx
702
+ import { uiPresets } from '@innet/server'
703
+
704
+ export default (
705
+ <server>
706
+ <api>
707
+ <ui
708
+ html={uiPresets.redoc}
709
+ params={{
710
+ disableSearch: 'true',
711
+ hideDownloadButton: 'true',
712
+ nativeScrollbars: 'true',
713
+ theme: '{"sidebar": {"backgroundColor": "#d1e5ef"}}',
714
+ }}
715
+ />
716
+ </api>
717
+ </server>
718
+ )
719
+ ```
720
+
721
+ #### path
722
+
723
+ You can change the documentation UI URL path by `path` property of `<ui>` element.
724
+
725
+ *src/app.tsx*
726
+ ```typescript jsx
727
+ export default (
728
+ <server>
729
+ <api>
730
+ <ui path='/docs' />
731
+ </api>
732
+ </server>
733
+ )
734
+ ```
735
+
736
+ *default: `INNET_UI_PATH` || `'/ui'`*
737
+
627
738
  ### \<env>
628
739
 
629
740
  [← back](#utils)
@@ -1396,6 +1507,28 @@ export default (
1396
1507
  )
1397
1508
  ```
1398
1509
 
1510
+ #### operationId
1511
+
1512
+ `operationId` is an optional unique string used to identify an operation.
1513
+ If provided, these IDs must be unique among all operations described in your API.
1514
+
1515
+ Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is recommended to follow common programming naming conventions.
1516
+
1517
+ *src/app.tsx*
1518
+ ```typescript jsx
1519
+ export default (
1520
+ <server>
1521
+ <api>
1522
+ <endpoint
1523
+ method='get'
1524
+ path='/users'
1525
+ operationId='getUsers'
1526
+ />
1527
+ </api>
1528
+ </server>
1529
+ )
1530
+ ```
1531
+
1399
1532
  ### \<tag>
1400
1533
 
1401
1534
  [← back](#endpoints)
@@ -1423,6 +1556,34 @@ export default (
1423
1556
  )
1424
1557
  ```
1425
1558
 
1559
+ #### group
1560
+
1561
+ You can organize tags into groups using the `group` property.
1562
+ This adds tag groups support to the OpenAPI specification,
1563
+ which is displayed in documentation viewers.
1564
+
1565
+ *src/app.tsx*
1566
+ ```typescript jsx
1567
+ export default (
1568
+ <server>
1569
+ <api>
1570
+ <tag group='Authentication' name='auth'>
1571
+ <endpoint method='post' path='/login' />
1572
+ <endpoint method='post' path='/logout' />
1573
+ </tag>
1574
+ <tag group='Users' name='users'>
1575
+ <endpoint method='get' path='/users' />
1576
+ <endpoint method='post' path='/users' />
1577
+ </tag>
1578
+ </api>
1579
+ </server>
1580
+ )
1581
+ ```
1582
+
1583
+ This will create tag groups in your OpenAPI documentation:
1584
+ - **Authentication** group containing the `auth` tag
1585
+ - **Users** group containing the `users` tag
1586
+
1426
1587
  ### \<param>
1427
1588
 
1428
1589
  [← back](#endpoints)
@@ -2154,6 +2315,26 @@ you get an error:
2154
2315
  }
2155
2316
  ```
2156
2317
 
2318
+ #### format
2319
+
2320
+ An optional format modifier serves as a hint at the contents and format of the string.
2321
+ Available formats include: `email`, `date-time`, `date`, `uri`, `hostname`, `ipv4`, `ipv6`, `uuid`, `byte`, `binary`, `password` or custom string.
2322
+
2323
+ *src/app.tsx*
2324
+ ```typescript jsx
2325
+ export default (
2326
+ <server>
2327
+ <api>
2328
+ <endpoint method='get' path='/users'>
2329
+ <param in='query' name='email'>
2330
+ <string format='email' />
2331
+ </param>
2332
+ </endpoint>
2333
+ </api>
2334
+ </server>
2335
+ )
2336
+ ```
2337
+
2157
2338
  ### \<number>
2158
2339
 
2159
2340
  [← back](#primitive-data)
@@ -2303,6 +2484,66 @@ export default (
2303
2484
 
2304
2485
  *In this example `/products?rating=5` is valid and `/products?rating=6` is not*
2305
2486
 
2487
+ #### exclusiveMinimum, exclusiveMaximum
2488
+
2489
+ These props restrict the value to be strictly greater than or less than the specified number.
2490
+
2491
+ *src/app.tsx*
2492
+ ```typescript jsx
2493
+ export default (
2494
+ <server>
2495
+ <api>
2496
+ <endpoint method='get' path='/products'>
2497
+ <param in='query' name='rating'>
2498
+ <number
2499
+ exclusiveMinimum={0}
2500
+ exclusiveMaximum={5}
2501
+ />
2502
+ </param>
2503
+ </endpoint>
2504
+ </api>
2505
+ </server>
2506
+ )
2507
+ ```
2508
+
2509
+ #### multipleOf
2510
+
2511
+ This prop restricts the value to be a multiple of the specified number.
2512
+
2513
+ *src/app.tsx*
2514
+ ```typescript jsx
2515
+ export default (
2516
+ <server>
2517
+ <api>
2518
+ <endpoint method='get' path='/products'>
2519
+ <param in='query' name='quantity'>
2520
+ <number multipleOf={10} />
2521
+ </param>
2522
+ </endpoint>
2523
+ </api>
2524
+ </server>
2525
+ )
2526
+ ```
2527
+
2528
+ #### format
2529
+
2530
+ An optional format modifier serves as a hint at the contents and format of the number.
2531
+
2532
+ *src/app.tsx*
2533
+ ```typescript jsx
2534
+ export default (
2535
+ <server>
2536
+ <api>
2537
+ <endpoint method='get' path='/products'>
2538
+ <param in='query' name='price'>
2539
+ <number format='float' />
2540
+ </param>
2541
+ </endpoint>
2542
+ </api>
2543
+ </server>
2544
+ )
2545
+ ```
2546
+
2306
2547
  ### \<integer>
2307
2548
 
2308
2549
  [← back](#primitive-data)
@@ -2476,6 +2717,47 @@ export default (
2476
2717
 
2477
2718
  *In this example `/products?rating=5` is valid and `/products?rating=6` is not*
2478
2719
 
2720
+ #### exclusiveMinimum, exclusiveMaximum
2721
+
2722
+ These props restrict the value to be strictly greater than or less than the specified number.
2723
+
2724
+ *src/app.tsx*
2725
+ ```typescript jsx
2726
+ export default (
2727
+ <server>
2728
+ <api>
2729
+ <endpoint method='get' path='/products'>
2730
+ <param in='query' name='count'>
2731
+ <integer
2732
+ exclusiveMinimum={0}
2733
+ exclusiveMaximum={100}
2734
+ />
2735
+ </param>
2736
+ </endpoint>
2737
+ </api>
2738
+ </server>
2739
+ )
2740
+ ```
2741
+
2742
+ #### multipleOf
2743
+
2744
+ This prop restricts the value to be a multiple of the specified number.
2745
+
2746
+ *src/app.tsx*
2747
+ ```typescript jsx
2748
+ export default (
2749
+ <server>
2750
+ <api>
2751
+ <endpoint method='get' path='/products'>
2752
+ <param in='query' name='quantity'>
2753
+ <integer multipleOf={5} />
2754
+ </param>
2755
+ </endpoint>
2756
+ </api>
2757
+ </server>
2758
+ )
2759
+ ```
2760
+
2479
2761
  ### \<date>
2480
2762
 
2481
2763
  [← back](#primitive-data)
@@ -3113,6 +3395,48 @@ export default (
3113
3395
  )
3114
3396
  ```
3115
3397
 
3398
+ #### minItems, maxItems
3399
+
3400
+ Those two props validate the array by minimum and maximum number of items.
3401
+
3402
+ *src/app.tsx*
3403
+ ```typescript jsx
3404
+ export default (
3405
+ <server>
3406
+ <api>
3407
+ <endpoint method='get' path='/products'>
3408
+ <param in='query' name='tags'>
3409
+ <array minItems={1} maxItems={10}>
3410
+ <string />
3411
+ </array>
3412
+ </param>
3413
+ </endpoint>
3414
+ </api>
3415
+ </server>
3416
+ )
3417
+ ```
3418
+
3419
+ #### uniqueItems
3420
+
3421
+ This prop validates that all items in the array are unique.
3422
+
3423
+ *src/app.tsx*
3424
+ ```typescript jsx
3425
+ export default (
3426
+ <server>
3427
+ <api>
3428
+ <endpoint method='get' path='/products'>
3429
+ <param in='query' name='ids'>
3430
+ <array uniqueItems>
3431
+ <number />
3432
+ </array>
3433
+ </param>
3434
+ </endpoint>
3435
+ </api>
3436
+ </server>
3437
+ )
3438
+ ```
3439
+
3116
3440
  ### \<object>
3117
3441
 
3118
3442
  [← back](#list-of-data)
@@ -3276,6 +3600,58 @@ export default (
3276
3600
  )
3277
3601
  ```
3278
3602
 
3603
+ #### readOnly
3604
+
3605
+ You can mark a field as read-only, meaning it can only be returned in responses, not sent in requests.
3606
+
3607
+ *src/app.tsx*
3608
+ ```typescript jsx
3609
+ export default (
3610
+ <server>
3611
+ <api>
3612
+ <endpoint method='get' path='/users'>
3613
+ <response>
3614
+ <object>
3615
+ <field key='id' readOnly>
3616
+ <uuid />
3617
+ </field>
3618
+ <field key='name'>
3619
+ <string />
3620
+ </field>
3621
+ </object>
3622
+ </response>
3623
+ </endpoint>
3624
+ </api>
3625
+ </server>
3626
+ )
3627
+ ```
3628
+
3629
+ #### writeOnly
3630
+
3631
+ You can mark a field as write-only, meaning it can only be sent in requests, not returned in responses.
3632
+
3633
+ *src/app.tsx*
3634
+ ```typescript jsx
3635
+ export default (
3636
+ <server>
3637
+ <api>
3638
+ <endpoint method='post' path='/users'>
3639
+ <body>
3640
+ <object>
3641
+ <field key='password' writeOnly>
3642
+ <string />
3643
+ </field>
3644
+ <field key='name'>
3645
+ <string />
3646
+ </field>
3647
+ </object>
3648
+ </body>
3649
+ </endpoint>
3650
+ </api>
3651
+ </server>
3652
+ )
3653
+ ```
3654
+
3279
3655
  ## Run-Time
3280
3656
 
3281
3657
  Next elements relate to run-time action.
@@ -1,6 +1,6 @@
1
- import { context, type ContextProps, type JSXElement, slot, type SlotProps, slots, type SlotsProps } from '@innet/jsx';
1
+ import { type JSXElement } from '@innet/jsx';
2
2
  import { arraySync, async } from '@innet/utils';
3
- import { type AnyProps, type ApiProps, type ArrayProps, type BinaryProps, blacklist, type BlacklistProps, type BodyProps, type BooleanProps, cms, type CmsProps, type ContactProps, type CookieProps, type DateProps, type DtsProps, type EndpointProps, type EnvProps, type ErrorProps, type FieldProps, file, type FileProps, type HeaderProps, type HostProps, type IntegerProps, type LicenseProps, type NullProps, type NumberProps, type ObjectProps, type ParamProps, preset, type PresetProps, protection, type ProtectionProps, type ProxyProps, type RedirectProps, type ResponseProps, type ReturnProps, type ServerProps, type StringProps, type SuccessProps, type SwaggerProps, type TagProps, type TupleProps, type UuidProps, type VariableProps, whitelist, type WhitelistProps } from '../plugins';
3
+ import { type AnyProps, type ApiProps, type ArrayProps, type BinaryProps, blacklist, type BlacklistProps, type BodyProps, type BooleanProps, cms, type CmsProps, type ContactProps, type CookieProps, type DateProps, type DtsProps, type EndpointProps, type EnvProps, type ErrorProps, type FieldProps, file, type FileProps, type HeaderProps, type HostProps, type IntegerProps, type LicenseProps, type NullProps, type NumberProps, type ObjectProps, type ParamProps, preset, type PresetProps, protection, type ProtectionProps, type ProxyProps, type RedirectProps, type ResponseProps, type ReturnProps, type ServerProps, type StringProps, type SuccessProps, type SwaggerProps, type TagProps, type TupleProps, type UiProps, type UuidProps, type VariableProps, whitelist, type WhitelistProps } from '../plugins';
4
4
  export declare const arrayPlugins: (typeof arraySync)[];
5
5
  export declare const JSXPlugins: {
6
6
  any: import("innet").HandlerPlugin;
@@ -12,7 +12,6 @@ export declare const JSXPlugins: {
12
12
  boolean: import("innet").HandlerPlugin;
13
13
  cms: typeof cms;
14
14
  contact: import("innet").HandlerPlugin;
15
- context: typeof context;
16
15
  cookie: import("innet").HandlerPlugin;
17
16
  date: import("innet").HandlerPlugin;
18
17
  dts: import("innet").HandlerPlugin;
@@ -36,13 +35,12 @@ export declare const JSXPlugins: {
36
35
  response: import("innet").HandlerPlugin;
37
36
  return: import("innet").HandlerPlugin;
38
37
  server: import("innet").HandlerPlugin;
39
- slot: typeof slot;
40
- slots: typeof slots;
41
38
  string: import("innet").HandlerPlugin;
42
39
  success: import("innet").HandlerPlugin;
43
40
  swagger: import("innet").HandlerPlugin;
44
41
  tag: import("innet").HandlerPlugin;
45
42
  tuple: import("innet").HandlerPlugin;
43
+ ui: import("innet").HandlerPlugin;
46
44
  uuid: import("innet").HandlerPlugin;
47
45
  variable: import("innet").HandlerPlugin;
48
46
  whitelist: typeof whitelist;
@@ -53,7 +51,7 @@ export declare const promisePlugins: (typeof async)[];
53
51
  export declare const handler: import("innet").Handler;
54
52
  declare global {
55
53
  namespace JSX {
56
- type Element = ArrayElement | FunctionElement | JSXElement | boolean | null | number | (string & {}) | undefined;
54
+ type Element = ({} & string) | ArrayElement | FunctionElement | JSXElement | boolean | null | number | undefined;
57
55
  interface ArrayElement extends Array<Element> {
58
56
  }
59
57
  type FunctionElement = () => Element;
@@ -70,7 +68,6 @@ declare global {
70
68
  boolean: BooleanProps;
71
69
  cms: CmsProps;
72
70
  contact: ContactProps;
73
- context: ContextProps;
74
71
  cookie: CookieProps;
75
72
  date: DateProps;
76
73
  dts: DtsProps;
@@ -94,13 +91,13 @@ declare global {
94
91
  response: ResponseProps;
95
92
  return: ReturnProps;
96
93
  server: ServerProps;
97
- slot: SlotProps;
98
- slots: SlotsProps;
99
94
  string: StringProps;
100
95
  success: SuccessProps;
96
+ /** @deprecated Use <ui> */
101
97
  swagger: SwaggerProps;
102
98
  tag: TagProps;
103
99
  tuple: TupleProps;
100
+ ui: UiProps;
104
101
  uuid: UuidProps;
105
102
  variable: VariableProps;
106
103
  whitelist: WhitelistProps;
@@ -1,5 +1,5 @@
1
1
  import { createHandler } from 'innet';
2
- import { context, slot, slots, jsxPlugins, jsxComponent } from '@innet/jsx';
2
+ import { jsxPlugins, jsxComponent } from '@innet/jsx';
3
3
  import { arraySync, async, promise, array as array$1, nullish, object as object$1, fn } from '@innet/utils';
4
4
  import '../plugins/index.es6.js';
5
5
  import { any } from '../plugins/schema/any/any.es6.js';
@@ -39,6 +39,7 @@ import { success } from '../plugins/request/success/success.es6.js';
39
39
  import { swagger } from '../plugins/utils/swagger/swagger.es6.js';
40
40
  import { tag } from '../plugins/main/tag/tag.es6.js';
41
41
  import { tuple } from '../plugins/schema/tuple/tuple.es6.js';
42
+ import { ui } from '../plugins/utils/ui/ui.es6.js';
42
43
  import { uuid } from '../plugins/schema/uuid/uuid.es6.js';
43
44
  import { variable } from '../plugins/main/variable/variable.es6.js';
44
45
  import { whitelist } from '../plugins/utils/whitelist/whitelist.es6.js';
@@ -57,7 +58,6 @@ const JSXPlugins = {
57
58
  boolean,
58
59
  cms,
59
60
  contact,
60
- context,
61
61
  cookie,
62
62
  date,
63
63
  dts,
@@ -81,13 +81,12 @@ const JSXPlugins = {
81
81
  response,
82
82
  return: returnPlugin,
83
83
  server,
84
- slot,
85
- slots,
86
84
  string,
87
85
  success,
88
86
  swagger,
89
87
  tag,
90
88
  tuple,
89
+ ui,
91
90
  uuid,
92
91
  variable,
93
92
  whitelist,
@@ -43,6 +43,7 @@ var success = require('../plugins/request/success/success.js');
43
43
  var swagger = require('../plugins/utils/swagger/swagger.js');
44
44
  var tag = require('../plugins/main/tag/tag.js');
45
45
  var tuple = require('../plugins/schema/tuple/tuple.js');
46
+ var ui = require('../plugins/utils/ui/ui.js');
46
47
  var uuid = require('../plugins/schema/uuid/uuid.js');
47
48
  var variable = require('../plugins/main/variable/variable.js');
48
49
  var whitelist = require('../plugins/utils/whitelist/whitelist.js');
@@ -61,7 +62,6 @@ const JSXPlugins = {
61
62
  boolean: boolean.boolean,
62
63
  cms: cms.cms,
63
64
  contact: contact.contact,
64
- context: jsx.context,
65
65
  cookie: cookie.cookie,
66
66
  date: date.date,
67
67
  dts: dts.dts,
@@ -85,13 +85,12 @@ const JSXPlugins = {
85
85
  response: response.response,
86
86
  return: _return.returnPlugin,
87
87
  server: server.server,
88
- slot: jsx.slot,
89
- slots: jsx.slots,
90
88
  string: string.string,
91
89
  success: success.success,
92
90
  swagger: swagger.swagger,
93
91
  tag: tag.tag,
94
92
  tuple: tuple.tuple,
93
+ ui: ui.ui,
95
94
  uuid: uuid.uuid,
96
95
  variable: variable.variable,
97
96
  whitelist: whitelist.whitelist,
package/hooks/index.d.ts CHANGED
@@ -1,32 +1,33 @@
1
- export * from './useServer';
1
+ export * from './useAction';
2
2
  export * from './useApi';
3
- export * from './useHost';
4
- export * from './useTag';
5
- export * from './useComponentName';
6
- export * from './useOneElementError';
7
- export * from './useSchemaContext';
8
- export * from './useSchemaType';
9
- export * from './useNewSchema';
10
- export * from './useRequest';
11
- export * from './useResponse';
12
- export * from './useParams';
3
+ export * from './useBlock';
13
4
  export * from './useBody';
14
- export * from './useSearch';
15
- export * from './useParam';
5
+ export * from './useBodyFile';
6
+ export * from './useClientIp';
7
+ export * from './useComponentName';
8
+ export * from './useCookies';
9
+ export * from './useEffect';
16
10
  export * from './useEndpoint';
17
- export * from './useBlock';
18
11
  export * from './useHeaders';
19
- export * from './useCookies';
20
- export * from './useAction';
21
- export * from './useThrow';
22
- export * from './useRule';
12
+ export * from './useHost';
13
+ export * from './useIsServerHttps';
14
+ export * from './useNewSchema';
23
15
  export * from './useObjectRule';
24
- export * from './useBodyFile';
16
+ export * from './useObjectSchemaContext';
17
+ export * from './useOneElementError';
18
+ export * from './useParam';
19
+ export * from './useParams';
25
20
  export * from './usePath';
21
+ export * from './useRequest';
22
+ export * from './useRequestHandler';
23
+ export * from './useResponse';
24
+ export * from './useRule';
25
+ export * from './useSchemaContext';
26
+ export * from './useSchemaType';
27
+ export * from './useSearch';
28
+ export * from './useServer';
26
29
  export * from './useServerPlugin';
27
- export * from './useClientIp';
28
30
  export * from './useServerPlugins';
29
- export * from './useObjectSchemaContext';
30
31
  export * from './useServerPort';
31
- export * from './useIsServerHttps';
32
- export * from './useRequestHandler';
32
+ export * from './useTag';
33
+ export * from './useThrow';