@seliseblocks/cli-os 0.1.0-beta.1 → 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.
|
@@ -27,19 +27,20 @@ export async function writeAssetsFeature(root) {
|
|
|
27
27
|
" value: number;",
|
|
28
28
|
"};",
|
|
29
29
|
"",
|
|
30
|
-
"// Advanced filters here are applied client-side
|
|
31
|
-
"//
|
|
32
|
-
"//
|
|
33
|
-
"// category/status/value only narrows the page already fetched.",
|
|
30
|
+
"// Advanced filters here are applied client-side. The collection helper uses",
|
|
31
|
+
"// Data Gateway GraphQL and sends only paging plus the optional search filter",
|
|
32
|
+
"// below, so category/status/value filters narrow the page already fetched.",
|
|
34
33
|
"export type AssetFilters = { category?: string; maxValue?: number; minValue?: number; status?: string };",
|
|
35
34
|
"",
|
|
36
|
-
"const assets = blocksClient.data.collection<Asset>(\"
|
|
35
|
+
"const assets = blocksClient.data.collection<Asset>(\"Asset\", {",
|
|
36
|
+
" fields: [\"name\", \"assetTag\", \"category\", \"status\", \"assignedTo\", \"value\"]",
|
|
37
|
+
"});",
|
|
37
38
|
"",
|
|
38
39
|
"export async function listAssets({ page, pageSize, search }: { page: number; pageSize: number; search: string }) {",
|
|
39
40
|
" const response = await assets.list({",
|
|
40
41
|
" pageNo: page,",
|
|
41
42
|
" pageSize,",
|
|
42
|
-
"
|
|
43
|
+
" filter: search ? { name: { $regex: search, $options: \"i\" } } : undefined",
|
|
43
44
|
" });",
|
|
44
45
|
" return normalizeAssetList(response);",
|
|
45
46
|
"}",
|
|
@@ -75,10 +76,11 @@ export async function writeAssetsFeature(root) {
|
|
|
75
76
|
"}",
|
|
76
77
|
"",
|
|
77
78
|
"function normalizeAssetList(response: unknown): { items: Asset[]; totalCount: number } {",
|
|
78
|
-
" const record = response as { data?: { items?: Asset[]; totalCount?: number } | Asset[]; items?: Asset[]; totalCount?: number };",
|
|
79
|
+
" const record = response as { data?: { getAssets?: { items?: Asset[]; totalCount?: number }; items?: Asset[]; totalCount?: number } | Asset[]; items?: Asset[]; totalCount?: number };",
|
|
79
80
|
" if (Array.isArray(record.data)) return { items: record.data, totalCount: record.data.length };",
|
|
80
|
-
" const
|
|
81
|
-
"
|
|
81
|
+
" const gateway = record.data?.getAssets;",
|
|
82
|
+
" const items = gateway?.items ?? record.data?.items ?? record.items ?? [];",
|
|
83
|
+
" return { items, totalCount: gateway?.totalCount ?? record.data?.totalCount ?? record.totalCount ?? items.length };",
|
|
82
84
|
"}",
|
|
83
85
|
""
|
|
84
86
|
].join("\n"));
|
|
@@ -18,7 +18,7 @@ export async function writeRootFiles(root, options) {
|
|
|
18
18
|
},
|
|
19
19
|
dependencies: {
|
|
20
20
|
"@radix-ui/react-dropdown-menu": "^2.1.24",
|
|
21
|
-
"@seliseblocks/client": "^0.1.
|
|
21
|
+
"@seliseblocks/client": "^0.1.1",
|
|
22
22
|
"@tanstack/react-query": "^5.101.4",
|
|
23
23
|
clsx: "^2.1.1",
|
|
24
24
|
"lucide-react": "^1.28.0",
|