blixify-ui-web-mcp 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +5 -0
  2. package/lib/components/action/button/README.md +75 -0
  3. package/lib/components/action/button/button.stories.tsx +138 -0
  4. package/lib/components/action/buttonGroup/README.md +79 -0
  5. package/lib/components/action/buttonGroup/buttonGroup.stories.tsx +104 -0
  6. package/lib/components/action/iconButton/README.md +39 -0
  7. package/lib/components/action/iconButton/iconButton.stories.tsx +22 -0
  8. package/lib/components/action/radioList/README.md +98 -0
  9. package/lib/components/action/radioList/radioList.stories.tsx +181 -0
  10. package/lib/components/action/slider/README.md +86 -0
  11. package/lib/components/action/slider/slider.stories.tsx +133 -0
  12. package/lib/components/action/textButton/README.md +34 -0
  13. package/lib/components/action/textButton/textButton.stories.tsx +16 -0
  14. package/lib/components/action/toggle/README.md +39 -0
  15. package/lib/components/action/toggle/toggle.stories.tsx +23 -0
  16. package/lib/components/advanced/collapse/README.md +106 -0
  17. package/lib/components/advanced/collapse/collapse.stories.tsx +165 -0
  18. package/lib/components/advanced/infoWindow/README.md +69 -0
  19. package/lib/components/advanced/infoWindow/infoWindow.stories.tsx +112 -0
  20. package/lib/components/advanced/popUp/README.md +95 -0
  21. package/lib/components/advanced/popUp/popUp.stories.tsx +189 -0
  22. package/lib/components/auth/bareSignIn/README.md +78 -0
  23. package/lib/components/auth/bareSignIn/bareSignIn.stories.tsx +141 -0
  24. package/lib/components/auth/bareSignUp/README.md +130 -0
  25. package/lib/components/auth/bareSignUp/bareSignUp.stories.tsx +159 -0
  26. package/lib/components/auth/signIn/README.md +53 -0
  27. package/lib/components/auth/signIn/signIn.stories.tsx +120 -0
  28. package/lib/components/auth/signUp/README.md +136 -0
  29. package/lib/components/auth/signUp/signUp.stories.tsx +193 -0
  30. package/lib/components/chart/README.md +13 -0
  31. package/lib/components/chart/areaChart/README.md +133 -0
  32. package/lib/components/chart/areaChart/areaChart.stories.tsx +199 -0
  33. package/lib/components/chart/barChart/README.md +193 -0
  34. package/lib/components/chart/barChart/barChart.stories.tsx +318 -0
  35. package/lib/components/chart/boxPlotChart/README.md +124 -0
  36. package/lib/components/chart/boxPlotChart/boxPlotChart.stories.tsx +104 -0
  37. package/lib/components/chart/bubbleChart/README.md +166 -0
  38. package/lib/components/chart/bubbleChart/bubbleChart.stories.tsx +144 -0
  39. package/lib/components/chart/card/README.md +107 -0
  40. package/lib/components/chart/card/card.stories.tsx +89 -0
  41. package/lib/components/chart/ganttChart/README.md +142 -0
  42. package/lib/components/chart/ganttChart/ganttChart.stories.tsx +138 -0
  43. package/lib/components/chart/heatmapChart/README.md +125 -0
  44. package/lib/components/chart/heatmapChart/heatmapChart.stories.tsx +106 -0
  45. package/lib/components/chart/lineChart/README.md +140 -0
  46. package/lib/components/chart/lineChart/lineChart.stories.tsx +152 -0
  47. package/lib/components/chart/pieChart/README.md +117 -0
  48. package/lib/components/chart/pieChart/pieChart.stories.tsx +180 -0
  49. package/lib/components/chart/polarAreaChart/README.md +126 -0
  50. package/lib/components/chart/polarAreaChart/polarAreaChart.stories.tsx +106 -0
  51. package/lib/components/chart/radarChart/README.md +57 -0
  52. package/lib/components/chart/radarChart/radarChart.stories.tsx +36 -0
  53. package/lib/components/chart/radialBar/README.md +152 -0
  54. package/lib/components/chart/radialBar/radialChart.stories.tsx +136 -0
  55. package/lib/components/chart/rangeBarChart/README.md +323 -0
  56. package/lib/components/chart/rangeBarChart/rangeBarChart.stories.tsx +208 -0
  57. package/lib/components/chart/statsCard/README.md +97 -0
  58. package/lib/components/chart/statsCard/statsCard.stories.tsx +183 -0
  59. package/lib/components/chart/treemapChart/README.md +142 -0
  60. package/lib/components/chart/treemapChart/treemapChart.stories.tsx +122 -0
  61. package/lib/components/chat/chatAnchor/README.md +113 -0
  62. package/lib/components/chat/chatAnchor/chatAnchor.stories.tsx +156 -0
  63. package/lib/components/chat/chatBase/README.md +223 -0
  64. package/lib/components/chat/chatBase/chatBase.stories.tsx +306 -0
  65. package/lib/components/chat/chatDashboard/README.md +161 -0
  66. package/lib/components/chat/chatDashboard/chatDashboard.stories.tsx +154 -0
  67. package/lib/components/data/dataGraph/README.md +13 -0
  68. package/lib/components/data/dataGraph/dataGraph.stories.tsx +84 -0
  69. package/lib/components/data/dataReference/README.md +62 -0
  70. package/lib/components/data/dataReference/dataReference.stories.tsx +53 -0
  71. package/lib/components/data/dataTemplate/README.md +903 -0
  72. package/lib/components/data/dataTemplate/dataModule.stories.tsx +196 -0
  73. package/lib/components/data/dataTemplate/dataTemplate.stories.tsx +337 -0
  74. package/lib/components/data/dataWrapper/README.md +1077 -0
  75. package/lib/components/data/dataWrapper/dataWrapper.stories.tsx +831 -0
  76. package/lib/components/data/queryForm/README.md +56 -0
  77. package/lib/components/data/queryForm/queryForm.stories.tsx +85 -0
  78. package/lib/components/data/readQuery/README.md +282 -0
  79. package/lib/components/data/readQuery/readQuery.stories.tsx +256 -0
  80. package/lib/components/data/readQueryHoc/README.md +89 -0
  81. package/lib/components/data/readQueryHoc/readQueryHoc.stories.tsx +33 -0
  82. package/lib/components/data/writeQuery/README.md +178 -0
  83. package/lib/components/data/writeQuery/writeQuery.stories.tsx +209 -0
  84. package/lib/components/design/actionSection/README.md +47 -0
  85. package/lib/components/design/actionSection/actionSection.stories.tsx +74 -0
  86. package/lib/components/design/banner/README.md +43 -0
  87. package/lib/components/design/banner/banner.stories.tsx +34 -0
  88. package/lib/components/design/bannerAction/README.md +44 -0
  89. package/lib/components/design/bannerAction/bannerAction.stories.tsx +25 -0
  90. package/lib/components/design/blogSection/README.md +111 -0
  91. package/lib/components/design/blogSection/blogSection.stories.tsx +72 -0
  92. package/lib/components/design/carouselSection/README.md +82 -0
  93. package/lib/components/design/carouselSection/carouselSection.stories.tsx +52 -0
  94. package/lib/components/design/designList/README.md +60 -0
  95. package/lib/components/design/designList/designList.stories.tsx +44 -0
  96. package/lib/components/design/faq/README.md +121 -0
  97. package/lib/components/design/faq/faq.stories.tsx +103 -0
  98. package/lib/components/design/fileGrid/README.md +87 -0
  99. package/lib/components/design/fileGrid/fileGrid.stories.tsx +110 -0
  100. package/lib/components/design/fileViewer/README.md +40 -0
  101. package/lib/components/design/fileViewer/fileViewer.stories.tsx +28 -0
  102. package/lib/components/design/footerSection/README.md +62 -0
  103. package/lib/components/design/footerSection/footerSection.stories.tsx +84 -0
  104. package/lib/components/design/googleReview/README.md +45 -0
  105. package/lib/components/design/googleReview/googleReview.stories.tsx +33 -0
  106. package/lib/components/design/heroSection/README.md +48 -0
  107. package/lib/components/design/heroSection/heroSection.stories.tsx +85 -0
  108. package/lib/components/design/iconList/README.md +60 -0
  109. package/lib/components/design/iconList/iconList.stories.tsx +41 -0
  110. package/lib/components/design/imageGallery/README.md +56 -0
  111. package/lib/components/design/imageGallery/imageGallery.stories.tsx +45 -0
  112. package/lib/components/design/imageZoom/README.md +47 -0
  113. package/lib/components/design/imageZoom/imageZoom.stories.tsx +30 -0
  114. package/lib/components/design/leftContent/README.md +47 -0
  115. package/lib/components/design/leftContent/leftContent.stories.tsx +32 -0
  116. package/lib/components/design/logoCloud/README.md +42 -0
  117. package/lib/components/design/logoCloud/logoCloud.stories.tsx +44 -0
  118. package/lib/components/design/onboarding/README.md +100 -0
  119. package/lib/components/design/onboarding/onboarding.stories.tsx +113 -0
  120. package/lib/components/design/pricing/README.md +112 -0
  121. package/lib/components/design/pricing/pricing.stories.tsx +86 -0
  122. package/lib/components/design/rightContent/README.md +47 -0
  123. package/lib/components/design/rightContent/rightContent.stories.tsx +32 -0
  124. package/lib/components/design/sectionList/README.md +51 -0
  125. package/lib/components/design/sectionList/sectionList.stories.tsx +35 -0
  126. package/lib/components/design/teams/README.md +62 -0
  127. package/lib/components/design/teams/teams.stories.tsx +61 -0
  128. package/lib/components/display/alert/README.md +82 -0
  129. package/lib/components/display/alert/alert.stories.tsx +71 -0
  130. package/lib/components/display/calendar/README.md +113 -0
  131. package/lib/components/display/calendar/calendar.stories.tsx +159 -0
  132. package/lib/components/display/clipboard/README.md +36 -0
  133. package/lib/components/display/clipboard/clipboard.stories.tsx +32 -0
  134. package/lib/components/display/detailList/README.md +61 -0
  135. package/lib/components/display/detailList/detailList.stories.tsx +131 -0
  136. package/lib/components/display/drawer/README.md +74 -0
  137. package/lib/components/display/drawer/drawer.stories.tsx +66 -0
  138. package/lib/components/display/emptyState/README.md +38 -0
  139. package/lib/components/display/emptyState/emptyState.stories.tsx +22 -0
  140. package/lib/components/display/feeds/README.md +80 -0
  141. package/lib/components/display/feeds/feeds.stories.tsx +75 -0
  142. package/lib/components/display/flexTable/README.md +160 -0
  143. package/lib/components/display/flexTable/flexTable.stories.tsx +313 -0
  144. package/lib/components/display/grid/README.md +121 -0
  145. package/lib/components/display/grid/grid.stories.tsx +234 -0
  146. package/lib/components/display/kanban/README.md +78 -0
  147. package/lib/components/display/kanban/kanban.stories.tsx +133 -0
  148. package/lib/components/display/list/README.md +109 -0
  149. package/lib/components/display/list/list.stories.tsx +188 -0
  150. package/lib/components/display/loading/README.md +25 -0
  151. package/lib/components/display/loading/loading.stories.tsx +15 -0
  152. package/lib/components/display/mapView/README.md +99 -0
  153. package/lib/components/display/mapView/mapView.stories.tsx +225 -0
  154. package/lib/components/display/modal/README.md +43 -0
  155. package/lib/components/display/modal/modal.stories.tsx +81 -0
  156. package/lib/components/display/notification/README.md +43 -0
  157. package/lib/components/display/notification/notification.stories.tsx +30 -0
  158. package/lib/components/display/progress/README.md +25 -0
  159. package/lib/components/display/progress/progress.stories.tsx +15 -0
  160. package/lib/components/display/stepper/README.md +96 -0
  161. package/lib/components/display/stepper/stepper.stories.tsx +175 -0
  162. package/lib/components/display/table/README.md +176 -0
  163. package/lib/components/display/table/table.stories.tsx +330 -0
  164. package/lib/components/display/tag/README.md +74 -0
  165. package/lib/components/display/tag/tag.stories.tsx +79 -0
  166. package/lib/components/input/address/README.md +132 -0
  167. package/lib/components/input/address/address.stories.tsx +147 -0
  168. package/lib/components/input/canvas/README.md +131 -0
  169. package/lib/components/input/canvas/canvas.stories.tsx +165 -0
  170. package/lib/components/input/checkbox/README.md +61 -0
  171. package/lib/components/input/checkbox/checkbox.stories.tsx +30 -0
  172. package/lib/components/input/datePicker/README.md +124 -0
  173. package/lib/components/input/datePicker/datePicker.stories.tsx +197 -0
  174. package/lib/components/input/form/README.md +55 -0
  175. package/lib/components/input/form/form.stories.tsx +143 -0
  176. package/lib/components/input/markdown/README.md +146 -0
  177. package/lib/components/input/markdown/markdown.stories.tsx +40 -0
  178. package/lib/components/input/monthYearPicker/README.md +69 -0
  179. package/lib/components/input/monthYearPicker/monthYearPicker.stories.tsx +47 -0
  180. package/lib/components/input/netPromoterScore/README.md +52 -0
  181. package/lib/components/input/netPromoterScore/netPromoterScore.stories.tsx +30 -0
  182. package/lib/components/input/rating/README.md +51 -0
  183. package/lib/components/input/rating/rating.stories.tsx +30 -0
  184. package/lib/components/input/select/README.md +108 -0
  185. package/lib/components/input/select/select.stories.tsx +286 -0
  186. package/lib/components/input/signature/README.md +106 -0
  187. package/lib/components/input/signature/signature.stories.tsx +188 -0
  188. package/lib/components/input/textArea/README.md +55 -0
  189. package/lib/components/input/textArea/textArea.stories.tsx +30 -0
  190. package/lib/components/input/textInput/README.md +81 -0
  191. package/lib/components/input/textInput/textinput.stories.tsx +231 -0
  192. package/lib/components/input/uploadInput/README.md +134 -0
  193. package/lib/components/input/uploadInput/uploadInput.stories.tsx +193 -0
  194. package/lib/components/navigation/bars/README.md +40 -0
  195. package/lib/components/navigation/bars/bars.stories.tsx +85 -0
  196. package/lib/components/navigation/bottomTab/README.md +53 -0
  197. package/lib/components/navigation/bottomTab/bottomTab.stories.tsx +32 -0
  198. package/lib/components/navigation/breadcrumb/README.md +48 -0
  199. package/lib/components/navigation/breadcrumb/breadcrumb.stories.tsx +27 -0
  200. package/lib/components/navigation/header/README.md +149 -0
  201. package/lib/components/navigation/header/header.stories.tsx +107 -0
  202. package/lib/components/navigation/leftNav/README.md +91 -0
  203. package/lib/components/navigation/leftNav/leftNav.stories.tsx +106 -0
  204. package/lib/components/navigation/tabs/README.md +75 -0
  205. package/lib/components/navigation/tabs/tabs.stories.tsx +60 -0
  206. package/lib/components/structure/column/README.md +40 -0
  207. package/lib/components/structure/column/column.stories.tsx +26 -0
  208. package/lib/components/structure/container/README.md +34 -0
  209. package/lib/components/structure/container/container.stories.tsx +19 -0
  210. package/lib/components/structure/link/README.md +55 -0
  211. package/lib/components/structure/link/link.stories.tsx +30 -0
  212. package/lib/components/structure/text/README.md +42 -0
  213. package/lib/components/structure/text/text.stories.tsx +39 -0
  214. package/lib/components/template/authPage/authPage.stories.tsx +68 -0
  215. package/lib/components/template/landingPage/landingPage.stories.tsx +288 -0
  216. package/lib/components/template/productListing/productListing.stories.tsx +297 -0
  217. package/lib/components/template/productOverview/productOverview.stories.tsx +194 -0
  218. package/lib/components/template/shoppingCart/shoppingCart.stories.tsx +252 -0
  219. package/lib/components/template/userHomePage/userHomePage.stories.tsx +605 -0
  220. package/lib/components/template/userRankingDashboard/userRankingDashboard.stories.tsx +481 -0
  221. package/lib/mcp/server.d.ts +2 -0
  222. package/lib/mcp/server.d.ts.map +1 -0
  223. package/lib/mcp/server.js +33 -0
  224. package/lib/mcp/server.js.map +1 -0
  225. package/lib/mcp/tools/getBackendComponent.d.ts +13 -0
  226. package/lib/mcp/tools/getBackendComponent.d.ts.map +1 -0
  227. package/lib/mcp/tools/getBackendComponent.js +119 -0
  228. package/lib/mcp/tools/getBackendComponent.js.map +1 -0
  229. package/lib/mcp/tools/getComponent.d.ts +17 -0
  230. package/lib/mcp/tools/getComponent.d.ts.map +1 -0
  231. package/lib/mcp/tools/getComponent.js +118 -0
  232. package/lib/mcp/tools/getComponent.js.map +1 -0
  233. package/lib/mcp/tools/listComponents.d.ts +13 -0
  234. package/lib/mcp/tools/listComponents.d.ts.map +1 -0
  235. package/lib/mcp/tools/listComponents.js +113 -0
  236. package/lib/mcp/tools/listComponents.js.map +1 -0
  237. package/lib/mcp/tools/listTemplates.d.ts +13 -0
  238. package/lib/mcp/tools/listTemplates.d.ts.map +1 -0
  239. package/lib/mcp/tools/listTemplates.js +68 -0
  240. package/lib/mcp/tools/listTemplates.js.map +1 -0
  241. package/lib/mcp/tools/suggestTemplate.d.ts +17 -0
  242. package/lib/mcp/tools/suggestTemplate.d.ts.map +1 -0
  243. package/lib/mcp/tools/suggestTemplate.js +212 -0
  244. package/lib/mcp/tools/suggestTemplate.js.map +1 -0
  245. package/package.json +23 -0
@@ -0,0 +1,56 @@
1
+ # Query Form
2
+
3
+ <!-- STORY -->
4
+
5
+ <hr>
6
+
7
+ Query Form
8
+
9
+ ##### Import
10
+
11
+ ```js
12
+ import { QueryForm } from "blixify-ui-web/components/data/readQuery";
13
+ ```
14
+
15
+ ##### Usage
16
+
17
+ ```jsx
18
+ return (
19
+ <QueryForm
20
+ dbModule={axios}
21
+ model={schema}
22
+ devSettings={{
23
+ schemaEndpoint: schemaUrl,
24
+ server: devSettings.defaultServer,
25
+ dbEndpoint: devSettings.defaultAPIUrl,
26
+ dbAPIToken: devSettings.defaultDBAPIToken,
27
+ imageEndpoint: devSettings.defaultAssetAPI,
28
+ uploadEndpoint: devSettings.defaultAssetUploadEndpoint,
29
+ bucketName: devSettings.defaultBucketName,
30
+ }}
31
+ renderReferenceLabelOptions={renderReferenceLabelOptions}
32
+ />
33
+ );
34
+ ```
35
+
36
+ ##### Query Form Props
37
+
38
+ | Name | Type | Description | Optional |
39
+ | ------------- | ---------------------- | ---------------------------- | -------- |
40
+ | `dbModule` | `axios or firebase` | Class | |
41
+ | `model` | `Model Data Structure` | Refer to Blixify Space Model | |
42
+ | `devSettings` | `DevSettings` | Eg api.example.com | |
43
+
44
+ ##### Call Method
45
+
46
+ | Name | Type | Description | Optional |
47
+ | ------------- | ----------------- | ----------- | --------------------------------- |
48
+ | `referenceRQ` | `ReadQuery Class` | Query Type | Returns { data : any } if success |
49
+
50
+ ##### QueryInput Class
51
+
52
+ | Name | Type | Description | Optional |
53
+ | --------- | ---------------- | ----------- | -------- |
54
+ | `queryId` | `string` | Query ID | |
55
+ | `type` | `= / < / > / ><` | Query Type | |
56
+ | `value` | `string` | Query Value | |
@@ -0,0 +1,85 @@
1
+ import { storiesOf } from "@storybook/react";
2
+ import axios from "axios";
3
+ import React, { useEffect, useState } from "react";
4
+ import { QueryForm } from ".";
5
+ import { Loading } from "../../display/loading";
6
+ import { Space } from "../dataTemplate/spaceModel";
7
+ import { Workspace } from "../dataTemplate/workspaceModel";
8
+ import {
9
+ defaultDBEndpoint,
10
+ defaultImageEndpoint,
11
+ defaultUploadEndpoint,
12
+ getAllSpacesList,
13
+ getSpaceData,
14
+ getWorkspaceData,
15
+ schemaUrl,
16
+ storyRenderReferenceLabelOptions,
17
+ } from "../stories";
18
+ import { blixifyDevCollection, blixifyDevWorkspace } from "../testData";
19
+ import { parseSpaceToDataStructure, parseWorkspaceSettings } from "../utils";
20
+ import README from "./README.md";
21
+
22
+ const stories = storiesOf("Data", module);
23
+
24
+ stories.addParameters({
25
+ readme: {
26
+ content: README,
27
+ },
28
+ });
29
+
30
+ stories.add("Query Form", () => {
31
+ const [selectedSpace, setSelectedSpace] = useState<Space | null>(null);
32
+ const [allWorkspaceSpace, setAllWorkspaceSpace] = useState<Space[]>([]);
33
+ const [selectedWorkspace, setSelectedWorkspace] =
34
+ useState<Workspace | null>(null);
35
+ const devSettings = parseWorkspaceSettings(
36
+ {
37
+ dbEndpoint: defaultDBEndpoint,
38
+ imageEndpoint: defaultImageEndpoint,
39
+ uploadEndpoint: defaultUploadEndpoint,
40
+ },
41
+ selectedWorkspace
42
+ );
43
+ const collectionParam = blixifyDevCollection;
44
+ const workspaceParam = blixifyDevWorkspace;
45
+
46
+ useEffect(() => {
47
+ handleRetrieveData();
48
+ }, []);
49
+
50
+ const handleRetrieveData = async () => {
51
+ if (collectionParam) {
52
+ const space: Space = await getSpaceData(collectionParam);
53
+ if (space) {
54
+ setSelectedSpace(space);
55
+ }
56
+ }
57
+ if (workspaceParam) {
58
+ const workspace: any = await getWorkspaceData(workspaceParam);
59
+ if (workspace) {
60
+ setSelectedWorkspace(workspace);
61
+ const allSpaces = await getAllSpacesList(workspaceParam);
62
+ if (allSpaces) setAllWorkspaceSpace(allSpaces);
63
+ }
64
+ }
65
+ };
66
+
67
+ if (selectedSpace && selectedWorkspace) {
68
+ return (
69
+ <QueryForm
70
+ updateQuery={undefined}
71
+ dbModule={axios}
72
+ model={parseSpaceToDataStructure(selectedSpace)}
73
+ devSettings={{
74
+ ...devSettings,
75
+ schemaEndpoint: schemaUrl,
76
+ }}
77
+ handleCloseForm={() => {}}
78
+ renderReferenceLabelOptions={storyRenderReferenceLabelOptions(
79
+ allWorkspaceSpace,
80
+ selectedSpace
81
+ )}
82
+ />
83
+ );
84
+ } else return <Loading />;
85
+ });
@@ -0,0 +1,282 @@
1
+ # Read Query
2
+
3
+ <!-- STORY -->
4
+
5
+ <hr>
6
+
7
+ `ReadQuery` is a low-level utility class for fetching data directly from MongoDB (via server) or Firebase. Use it when you need raw query access outside of DataTemplate or DataTemplateWrapper — for example, fetching lookup data, running aggregations, or building custom data flows.
8
+
9
+ ## How It Works
10
+
11
+ 1. Instantiate `ReadQuery` with your database config
12
+ 2. Call `.call(cond)` with a `ReadQueryType` object
13
+ 3. Get back `{ data, count? }` on success
14
+
15
+ ## Setup
16
+
17
+ ```ts
18
+ import axios from "axios";
19
+ import { ReadQuery } from "blixify-ui-web/data/readQuery";
20
+
21
+ const query = new ReadQuery({
22
+ dbModule: axios,
23
+ dbType: "mongoDB", // "mongoDB" | "fbServer" | "firebase"
24
+ dbCollection: "tasks",
25
+ dbEndpoint: "https://api.example.com/api/mongoData",
26
+ dbAPIToken: "your-api-token", // optional
27
+ dbUserToken: "user-id-token", // optional
28
+ });
29
+ ```
30
+
31
+ ## Usage Examples
32
+
33
+ ### Get a single record
34
+
35
+ ```ts
36
+ const res = await query.call({
37
+ type: "get",
38
+ id: "abc123",
39
+ });
40
+ // res.data → single document
41
+ ```
42
+
43
+ ### List with filter and sort
44
+
45
+ ```ts
46
+ const res = await query.call({
47
+ type: "list",
48
+ query: [{ queryId: "status", type: "=", value: "active" }],
49
+ sort: { sortId: "createdAt", type: "desc" },
50
+ limit: 20,
51
+ });
52
+ // res.data → array, res.count → cursor for next page
53
+ ```
54
+
55
+ ### Paginate with cursor
56
+
57
+ ```ts
58
+ const res = await query.call({
59
+ type: "list",
60
+ query: [],
61
+ sort: { sortId: "createdAt", type: "desc" },
62
+ limit: 20,
63
+ cursor: lastCursorValue, // from previous res.count
64
+ });
65
+ ```
66
+
67
+ ### Range filter (date between two values)
68
+
69
+ ```ts
70
+ const res = await query.call({
71
+ type: "list",
72
+ query: [
73
+ {
74
+ queryId: "createdAt",
75
+ type: "><",
76
+ value: ["2024-01-01T00:00:00Z", "2024-12-31T23:59:59Z"],
77
+ },
78
+ ],
79
+ limit: 50,
80
+ });
81
+ ```
82
+
83
+ ### OR query (group multiple conditions)
84
+
85
+ ```ts
86
+ const res = await query.call({
87
+ type: "list",
88
+ query: [
89
+ {
90
+ queryId: "proposed_date",
91
+ type: ">",
92
+ value: "2024-01-01",
93
+ orQuery: true,
94
+ orQueryGroupId: "dateGroup",
95
+ },
96
+ {
97
+ queryId: "actual_date",
98
+ type: ">",
99
+ value: "2024-01-01",
100
+ orQuery: true,
101
+ orQueryGroupId: "dateGroup",
102
+ },
103
+ ],
104
+ limit: 50,
105
+ });
106
+ ```
107
+
108
+ ### Search across multiple fields
109
+
110
+ ```ts
111
+ const res = await query.call({
112
+ type: "list",
113
+ query: [
114
+ {
115
+ type: "search",
116
+ searchIds: ["name", "email"],
117
+ value: "john",
118
+ },
119
+ ],
120
+ limit: 20,
121
+ });
122
+ ```
123
+
124
+ ### Aggregate — count
125
+
126
+ ```ts
127
+ const res = await query.call({
128
+ type: "list",
129
+ query: [{ queryId: "status", type: "=", value: "active" }],
130
+ aggregate: { type: "count", queryId: "" },
131
+ });
132
+ // res.data → number
133
+ ```
134
+
135
+ ### Aggregate — sum with date range
136
+
137
+ ```ts
138
+ const res = await query.call({
139
+ type: "list",
140
+ aggregate: {
141
+ type: "sum",
142
+ queryId: "amount",
143
+ dateId: "createdAt",
144
+ range: ["01/01/2024 00:00:00-31/12/2024 23:59:59"],
145
+ timezone: "Asia/Kuala_Lumpur",
146
+ },
147
+ });
148
+ ```
149
+
150
+ ### Union collections (merge multiple collections)
151
+
152
+ ```ts
153
+ const res = await query.call({
154
+ type: "list",
155
+ unionCollections: [
156
+ {
157
+ collection: "deliveries",
158
+ source: "Delivery",
159
+ query: [{ queryId: "status", type: "=", value: "active" }],
160
+ projection: { _id: 1, name: 1, status: 1, createdAt: 1 },
161
+ },
162
+ {
163
+ collection: "service-tickets",
164
+ source: "dynamic",
165
+ sourceLogic: {
166
+ $cond: {
167
+ if: { $eq: ["$category", "Defect"] },
168
+ then: "Defect",
169
+ else: "Other",
170
+ },
171
+ },
172
+ projection: { _id: 1, name: 1, status: 1, createdAt: 1 },
173
+ },
174
+ ],
175
+ sort: { sortId: "createdAt", type: "desc" },
176
+ limit: 50,
177
+ });
178
+ ```
179
+
180
+ ### Pipeline (advanced MongoDB aggregation)
181
+
182
+ ```ts
183
+ const res = await query.call({
184
+ type: "get",
185
+ id: "abc123",
186
+ pipeline: [
187
+ {
188
+ $lookup: {
189
+ from: "users",
190
+ localField: "userId",
191
+ foreignField: "_id",
192
+ as: "user",
193
+ },
194
+ },
195
+ { $unwind: "$user" },
196
+ ],
197
+ });
198
+ ```
199
+
200
+ ### Fetch only specific fields
201
+
202
+ ```ts
203
+ const res = await query.call({
204
+ type: "list",
205
+ attributeIds: ["name", "status", "createdAt"], // only return these fields
206
+ limit: 50,
207
+ });
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Constructor
213
+
214
+ | Param | Type | Description | Optional |
215
+ | -------------- | --------------------------------- | -------------------- | -------- |
216
+ | `dbModule` | `axios \| firebase` | HTTP/Firebase module | |
217
+ | `dbType` | `mongoDB \| fbServer \| firebase` | Backend type | |
218
+ | `dbCollection` | `string` | Collection name | |
219
+ | `dbEndpoint` | `string` | API base URL | ✓ |
220
+ | `dbAPIToken` | `string` | API token | ✓ |
221
+ | `dbUserToken` | `string` | User ID token | ✓ |
222
+
223
+ ## ReadQueryType
224
+
225
+ | Param | Type | Description | Optional |
226
+ | --------------------- | ------------------- | --------------------------- | --------------------- |
227
+ | `type` | `get \| list` | Query type | |
228
+ | `id` | `string` | Document ID | Required for `get` |
229
+ | `query` | `Query[]` | Filter conditions | ✓ |
230
+ | `attributeIds` | `string[]` | Fields to include | ✓ |
231
+ | `excludeAttributeIds` | `string[]` | Fields to exclude | ✓ |
232
+ | `cursor` | `any` | Pagination cursor | ✓ |
233
+ | `skip` | `number` | Skip N records (union only) | ✓ |
234
+ | `limit` | `number` | Max records to return | Required for Firebase |
235
+ | `sort` | `Sort \| Sort[]` | Sort config | ✓ |
236
+ | `aggregate` | `Aggregate` | Aggregation config | ✓ |
237
+ | `stopLimit` | `boolean` | Pull all records (no limit) | ✓ |
238
+ | `pipeline` | `PipeLine[]` | Raw MongoDB pipeline | ✓ |
239
+ | `foreign` | `Foreign[]` | Foreign collection joins | ✓ |
240
+ | `unionCollections` | `UnionCollection[]` | Merge multiple collections | ✓ |
241
+ | `uniqueLabel` | `string` | Cache label for the query | ✓ |
242
+
243
+ ## Query
244
+
245
+ | Param | Type | Description | Optional |
246
+ | ---------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------- | ------------------------ |
247
+ | `type` | `search \| = \| != \| > \| < \| >< \| in \| !in \| exists \| elemMatch \| >size \| <size` | Operator | |
248
+ | `value` | `any` | Filter value (array for `><` and `in`) | |
249
+ | `queryId` | `string` | Field name | Required except `search` |
250
+ | `searchIds` | `string[]` | Fields to search across | Required for `search` |
251
+ | `orQuery` | `boolean` | Use OR instead of AND | ✓ |
252
+ | `orQueryGroupId` | `string` | Group OR conditions with AND between groups | ✓ |
253
+
254
+ ## Aggregate
255
+
256
+ | Param | Type | Description | Optional |
257
+ | ---------- | ------------------------------ | ------------------------------------------------------ | -------- |
258
+ | `type` | `count \| avg \| sum \| value` | Aggregation type | |
259
+ | `queryId` | `string` | Field to aggregate | |
260
+ | `groupId` | `string` | Group by field | ✓ |
261
+ | `dateId` | `string` | Date field for range filter | ✓ |
262
+ | `range` | `string[]` | Date range `"DD/MM/YYYY HH:mm:ss-DD/MM/YYYY HH:mm:ss"` | ✓ |
263
+ | `timezone` | `string` | Timezone string e.g. `"Asia/Kuala_Lumpur"` | ✓ |
264
+
265
+ ## Sort
266
+
267
+ | Param | Type | Description | Optional |
268
+ | ------------------ | ------------- | ---------------------------- | -------- |
269
+ | `sortId` | `string` | Field to sort by | |
270
+ | `type` | `asc \| desc` | Sort direction | |
271
+ | `sortBeforeFilter` | `boolean` | Sort before applying filters | ✓ |
272
+
273
+ ## UnionCollection
274
+
275
+ | Param | Type | Description | Optional |
276
+ | ------------- | --------------------- | ---------------------------------------------------------- | -------- |
277
+ | `collection` | `string` | Collection name | |
278
+ | `source` | `string \| "dynamic"` | Label for this source, or `"dynamic"` to use `sourceLogic` | |
279
+ | `sourceLogic` | `any` | MongoDB `$cond` expression for dynamic source label | ✓ |
280
+ | `query` | `Query[]` | Per-collection filters | ✓ |
281
+ | `projection` | `any` | Fields to return | ✓ |
282
+ | `addFields` | `any` | Computed fields to add | ✓ |
@@ -0,0 +1,256 @@
1
+ import { storiesOf } from "@storybook/react";
2
+ import axios from "axios";
3
+ import moment from "moment-timezone";
4
+ import React, { useState } from "react";
5
+ import { ReadQuery } from ".";
6
+ import { Button } from "../../action/button";
7
+ import { StorySection } from "../../storyUtils";
8
+ import README from "./README.md";
9
+
10
+ const stories = storiesOf("Data", module);
11
+
12
+ stories.addParameters({
13
+ readme: { content: README },
14
+ });
15
+
16
+ const query = new ReadQuery({
17
+ dbModule: axios,
18
+ dbType: "fbServer",
19
+ dbCollection: "users",
20
+ dbEndpoint: "https://api.example.com/api/mongoData",
21
+ });
22
+
23
+ stories.add("Read Query", () => {
24
+ const [result, setResult] = useState<string>("");
25
+
26
+ const run = async (label: string, fn: () => Promise<any>) => {
27
+ try {
28
+ const res = await fn();
29
+ setResult(`[${label}] ${JSON.stringify(res?.data ?? res)}`);
30
+ } catch (err: any) {
31
+ setResult(`[${label}] Error: ${err?.message ?? String(err)}`);
32
+ }
33
+ };
34
+
35
+ return (
36
+ <div className="flex flex-col gap-6 w-full p-4">
37
+ <StorySection
38
+ title="Get Single Record"
39
+ description="Fetch one document by ID using type: 'get'."
40
+ >
41
+ <Button
42
+ text="Get by ID"
43
+ type="light"
44
+ onClick={() =>
45
+ run("get", () => query.call({ type: "get", id: "abc123" }))
46
+ }
47
+ />
48
+ </StorySection>
49
+
50
+ <StorySection
51
+ title="List with Filter & Sort"
52
+ description="Fetch a filtered, sorted list. Returns data array and a cursor for pagination."
53
+ >
54
+ <Button
55
+ text="List Active Users"
56
+ type="light"
57
+ onClick={() =>
58
+ run("list", () =>
59
+ query.call({
60
+ type: "list",
61
+ query: [{ queryId: "status", type: "=", value: "active" }],
62
+ sort: { sortId: "createdAt", type: "desc" },
63
+ limit: 20,
64
+ })
65
+ )
66
+ }
67
+ />
68
+ </StorySection>
69
+
70
+ <StorySection
71
+ title="Range Filter"
72
+ description="Filter records where a field falls between two values using type: '><'."
73
+ >
74
+ <Button
75
+ text="Date Range Query"
76
+ type="light"
77
+ onClick={() =>
78
+ run("range", () =>
79
+ query.call({
80
+ type: "list",
81
+ query: [
82
+ {
83
+ queryId: "createdAt",
84
+ type: "><",
85
+ value: ["2024-01-01T00:00:00Z", "2024-12-31T23:59:59Z"],
86
+ },
87
+ ],
88
+ sort: { sortId: "createdAt", type: "desc" },
89
+ limit: 50,
90
+ })
91
+ )
92
+ }
93
+ />
94
+ </StorySection>
95
+
96
+ <StorySection
97
+ title="OR Query"
98
+ description="Group conditions with orQuery + orQueryGroupId so records matching either condition are returned."
99
+ >
100
+ <Button
101
+ text="OR Query"
102
+ type="light"
103
+ onClick={() =>
104
+ run("or", () =>
105
+ query.call({
106
+ type: "list",
107
+ query: [
108
+ {
109
+ queryId: "proposed_date",
110
+ type: ">",
111
+ value: "2024-01-01",
112
+ orQuery: true,
113
+ orQueryGroupId: "dateGroup",
114
+ },
115
+ {
116
+ queryId: "actual_date",
117
+ type: ">",
118
+ value: "2024-01-01",
119
+ orQuery: true,
120
+ orQueryGroupId: "dateGroup",
121
+ },
122
+ ],
123
+ limit: 50,
124
+ })
125
+ )
126
+ }
127
+ />
128
+ </StorySection>
129
+
130
+ <StorySection
131
+ title="Search Across Fields"
132
+ description="Full-text style search across multiple fields using type: 'search'."
133
+ >
134
+ <Button
135
+ text="Search 'john'"
136
+ type="light"
137
+ onClick={() =>
138
+ run("search", () =>
139
+ query.call({
140
+ type: "list",
141
+ query: [
142
+ {
143
+ type: "search",
144
+ searchIds: ["name", "email"],
145
+ value: "john",
146
+ },
147
+ ],
148
+ limit: 20,
149
+ })
150
+ )
151
+ }
152
+ />
153
+ </StorySection>
154
+
155
+ <StorySection
156
+ title="Aggregate — Count"
157
+ description="Count documents matching a filter. Returns a number in res.data."
158
+ >
159
+ <Button
160
+ text="Count Active"
161
+ type="light"
162
+ onClick={() =>
163
+ run("count", () =>
164
+ query.call({
165
+ type: "list",
166
+ query: [{ queryId: "status", type: "=", value: "active" }],
167
+ aggregate: { type: "count", queryId: "" },
168
+ })
169
+ )
170
+ }
171
+ />
172
+ </StorySection>
173
+
174
+ <StorySection
175
+ title="Aggregate — Sum with Date Range"
176
+ description="Sum a numeric field within a date range. Requires dateId and range together."
177
+ >
178
+ <Button
179
+ text="Sum Amount"
180
+ type="light"
181
+ onClick={() =>
182
+ run("sum", () =>
183
+ query.call({
184
+ type: "list",
185
+ aggregate: {
186
+ type: "sum",
187
+ queryId: "amount",
188
+ dateId: "createdAt",
189
+ range: ["01/01/2024 00:00:00-31/12/2024 23:59:59"],
190
+ timezone: moment.tz.guess(),
191
+ },
192
+ })
193
+ )
194
+ }
195
+ />
196
+ </StorySection>
197
+
198
+ <StorySection
199
+ title="Fetch Specific Fields"
200
+ description="Use attributeIds to return only the fields you need, reducing payload size."
201
+ >
202
+ <Button
203
+ text="Fetch name + status only"
204
+ type="light"
205
+ onClick={() =>
206
+ run("fields", () =>
207
+ query.call({
208
+ type: "list",
209
+ attributeIds: ["name", "status", "createdAt"],
210
+ limit: 50,
211
+ })
212
+ )
213
+ }
214
+ />
215
+ </StorySection>
216
+
217
+ <StorySection
218
+ title="Union Collections"
219
+ description="Merge records from multiple collections into one list. Each collection can have its own query and projection."
220
+ >
221
+ <Button
222
+ text="Union Query"
223
+ type="light"
224
+ onClick={() =>
225
+ run("union", () =>
226
+ query.call({
227
+ type: "list",
228
+ unionCollections: [
229
+ {
230
+ collection: "deliveries",
231
+ source: "Delivery",
232
+ query: [{ queryId: "status", type: "=", value: "active" }],
233
+ projection: { _id: 1, name: 1, status: 1, createdAt: 1 },
234
+ },
235
+ {
236
+ collection: "service-tickets",
237
+ source: "Service Ticket",
238
+ projection: { _id: 1, name: 1, status: 1, createdAt: 1 },
239
+ },
240
+ ],
241
+ sort: { sortId: "createdAt", type: "desc" },
242
+ limit: 50,
243
+ })
244
+ )
245
+ }
246
+ />
247
+ </StorySection>
248
+
249
+ {result && (
250
+ <div className="mt-4 p-3 bg-gray-100 rounded text-xs text-gray-700 break-all w-full">
251
+ {result}
252
+ </div>
253
+ )}
254
+ </div>
255
+ );
256
+ });