@jsudc/react 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +228 -2
- package/dist/calendar/CalendarRenderer.d.ts +11 -0
- package/dist/calendar/CalendarRenderer.js +343 -0
- package/dist/calendar/CalendarRenderer.js.map +1 -0
- package/dist/calendar/EventBlock.d.ts +16 -0
- package/dist/calendar/EventBlock.js +57 -0
- package/dist/calendar/EventBlock.js.map +1 -0
- package/dist/calendar/EventDetail.d.ts +20 -0
- package/dist/calendar/EventDetail.js +186 -0
- package/dist/calendar/EventDetail.js.map +1 -0
- package/dist/calendar/MonthGrid.d.ts +19 -0
- package/dist/calendar/MonthGrid.js +120 -0
- package/dist/calendar/MonthGrid.js.map +1 -0
- package/dist/calendar/TimeGrid.d.ts +24 -0
- package/dist/calendar/TimeGrid.js +330 -0
- package/dist/calendar/TimeGrid.js.map +1 -0
- package/dist/calendar/model.d.ts +97 -0
- package/dist/calendar/model.js +279 -0
- package/dist/calendar/model.js.map +1 -0
- package/dist/cards/CardRenderer.d.ts +24 -0
- package/dist/cards/CardRenderer.js +274 -0
- package/dist/cards/CardRenderer.js.map +1 -0
- package/dist/cards/cardModel.d.ts +48 -0
- package/dist/cards/cardModel.js +86 -0
- package/dist/cards/cardModel.js.map +1 -0
- package/dist/chart/ChartRenderer.d.ts +16 -0
- package/dist/chart/ChartRenderer.js +529 -0
- package/dist/chart/ChartRenderer.js.map +1 -0
- package/dist/chart/ChartWindowControl.d.ts +13 -0
- package/dist/chart/ChartWindowControl.js +99 -0
- package/dist/chart/ChartWindowControl.js.map +1 -0
- package/dist/chart/model.d.ts +45 -0
- package/dist/chart/model.js +179 -0
- package/dist/chart/model.js.map +1 -0
- package/dist/chart/useChartWindow.d.ts +18 -0
- package/dist/chart/useChartWindow.js +70 -0
- package/dist/chart/useChartWindow.js.map +1 -0
- package/dist/chart/window.d.ts +50 -0
- package/dist/chart/window.js +130 -0
- package/dist/chart/window.js.map +1 -0
- package/dist/components/ui/button.d.ts +21 -0
- package/dist/components/ui/button.js +30 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +2 -0
- package/dist/components/ui/checkbox.js +23 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +14 -0
- package/dist/components/ui/dialog.js +52 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +12 -0
- package/dist/components/ui/dropdown-menu.js +35 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.js +24 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/misc.d.ts +6 -0
- package/dist/components/ui/misc.js +24 -0
- package/dist/components/ui/misc.js.map +1 -0
- package/dist/components/ui/popover.d.ts +6 -0
- package/dist/components/ui/popover.js +21 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/segmented.d.ts +18 -0
- package/dist/components/ui/segmented.js +35 -0
- package/dist/components/ui/segmented.js.map +1 -0
- package/dist/components/ui/select.d.ts +14 -0
- package/dist/components/ui/select.js +39 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/toast.d.ts +14 -0
- package/dist/components/ui/toast.js +72 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +9 -0
- package/dist/components/ui/tooltip.js +19 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/data-view/DocTab.d.ts +8 -0
- package/dist/data-view/DocTab.js +26 -0
- package/dist/data-view/DocTab.js.map +1 -0
- package/dist/data-view/FilePreview.d.ts +10 -0
- package/dist/data-view/FilePreview.js +71 -0
- package/dist/data-view/FilePreview.js.map +1 -0
- package/dist/data-view/FilterBuilder.d.ts +26 -0
- package/dist/data-view/FilterBuilder.js +350 -0
- package/dist/data-view/FilterBuilder.js.map +1 -0
- package/dist/data-view/FilterChips.d.ts +12 -0
- package/dist/data-view/FilterChips.js +295 -0
- package/dist/data-view/FilterChips.js.map +1 -0
- package/dist/data-view/FolderBar.d.ts +5 -0
- package/dist/data-view/FolderBar.js +46 -0
- package/dist/data-view/FolderBar.js.map +1 -0
- package/dist/data-view/FolderEntry.d.ts +13 -0
- package/dist/data-view/FolderEntry.js +37 -0
- package/dist/data-view/FolderEntry.js.map +1 -0
- package/dist/data-view/Freshness.d.ts +18 -0
- package/dist/data-view/Freshness.js +86 -0
- package/dist/data-view/Freshness.js.map +1 -0
- package/dist/data-view/SearchBox.d.ts +7 -0
- package/dist/data-view/SearchBox.js +65 -0
- package/dist/data-view/SearchBox.js.map +1 -0
- package/dist/data-view/SourceTab.d.ts +9 -0
- package/dist/data-view/SourceTab.js +103 -0
- package/dist/data-view/SourceTab.js.map +1 -0
- package/dist/data-view/UdcDataView.d.ts +8 -0
- package/dist/data-view/UdcDataView.js +366 -0
- package/dist/data-view/UdcDataView.js.map +1 -0
- package/dist/data-view/compose.d.ts +24 -0
- package/dist/data-view/compose.js +86 -0
- package/dist/data-view/compose.js.map +1 -0
- package/dist/data-view/folder.d.ts +13 -0
- package/dist/data-view/folder.js +52 -0
- package/dist/data-view/folder.js.map +1 -0
- package/dist/data-view/liveView.d.ts +20 -0
- package/dist/data-view/liveView.js +67 -0
- package/dist/data-view/liveView.js.map +1 -0
- package/dist/data-view/urlState.d.ts +44 -0
- package/dist/data-view/urlState.js +139 -0
- package/dist/data-view/urlState.js.map +1 -0
- package/dist/data-view/useDataViewState.d.ts +36 -0
- package/dist/data-view/useDataViewState.js +69 -0
- package/dist/data-view/useDataViewState.js.map +1 -0
- package/dist/i18n/i18n.d.ts +71 -0
- package/dist/i18n/i18n.js +151 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/dist/i18n/translations.d.ts +16 -0
- package/dist/i18n/translations.js +959 -0
- package/dist/i18n/translations.js.map +1 -0
- package/dist/icons/lucide.generated.d.ts +2 -0
- package/dist/icons/lucide.generated.js +32 -0
- package/dist/icons/lucide.generated.js.map +1 -0
- package/dist/icons/resolve.d.ts +9 -0
- package/dist/icons/resolve.js +25 -0
- package/dist/icons/resolve.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +28 -0
- package/dist/kanban/CardDetailDialog.d.ts +17 -0
- package/dist/kanban/CardDetailDialog.js +52 -0
- package/dist/kanban/CardDetailDialog.js.map +1 -0
- package/dist/kanban/KanbanBoardSwitcher.d.ts +6 -0
- package/dist/kanban/KanbanBoardSwitcher.js +27 -0
- package/dist/kanban/KanbanBoardSwitcher.js.map +1 -0
- package/dist/kanban/KanbanCard.d.ts +21 -0
- package/dist/kanban/KanbanCard.js +188 -0
- package/dist/kanban/KanbanCard.js.map +1 -0
- package/dist/kanban/KanbanColumn.d.ts +30 -0
- package/dist/kanban/KanbanColumn.js +227 -0
- package/dist/kanban/KanbanColumn.js.map +1 -0
- package/dist/kanban/KanbanRenderer.d.ts +3 -0
- package/dist/kanban/KanbanRenderer.js +472 -0
- package/dist/kanban/KanbanRenderer.js.map +1 -0
- package/dist/kanban/model.d.ts +89 -0
- package/dist/kanban/model.js +159 -0
- package/dist/kanban/model.js.map +1 -0
- package/dist/kanban/persist.d.ts +27 -0
- package/dist/kanban/persist.js +54 -0
- package/dist/kanban/persist.js.map +1 -0
- package/dist/kanban/useKanbanBoard.d.ts +21 -0
- package/dist/kanban/useKanbanBoard.js +47 -0
- package/dist/kanban/useKanbanBoard.js.map +1 -0
- package/dist/lib/theme.d.ts +11 -0
- package/dist/lib/theme.js +43 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/lib/utils.d.ts +9 -0
- package/dist/lib/utils.js +29 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/map/MapRenderer.d.ts +13 -0
- package/dist/map/MapRenderer.js +405 -0
- package/dist/map/MapRenderer.js.map +1 -0
- package/dist/map/model.d.ts +68 -0
- package/dist/map/model.js +140 -0
- package/dist/map/model.js.map +1 -0
- package/dist/renderers/AllRowsStatus.d.ts +8 -0
- package/dist/renderers/AllRowsStatus.js +34 -0
- package/dist/renderers/AllRowsStatus.js.map +1 -0
- package/dist/renderers/registry.d.ts +21 -0
- package/dist/renderers/registry.js +103 -0
- package/dist/renderers/registry.js.map +1 -0
- package/dist/renderers/types.d.ts +83 -0
- package/dist/renderers/types.js +8 -0
- package/dist/renderers/types.js.map +1 -0
- package/dist/schema-editor/ColumnHeaderMenu.d.ts +11 -0
- package/dist/schema-editor/ColumnHeaderMenu.js +74 -0
- package/dist/schema-editor/ColumnHeaderMenu.js.map +1 -0
- package/dist/schema-editor/DeleteFieldDialog.d.ts +8 -0
- package/dist/schema-editor/DeleteFieldDialog.js +79 -0
- package/dist/schema-editor/DeleteFieldDialog.js.map +1 -0
- package/dist/schema-editor/FieldFormDialog.d.ts +22 -0
- package/dist/schema-editor/FieldFormDialog.js +313 -0
- package/dist/schema-editor/FieldFormDialog.js.map +1 -0
- package/dist/schema-editor/TagInput.d.ts +9 -0
- package/dist/schema-editor/TagInput.js +46 -0
- package/dist/schema-editor/TagInput.js.map +1 -0
- package/dist/schema-editor/fieldForm.d.ts +52 -0
- package/dist/schema-editor/fieldForm.js +131 -0
- package/dist/schema-editor/fieldForm.js.map +1 -0
- package/dist/schema-editor/useSchemaEditor.d.ts +15 -0
- package/dist/schema-editor/useSchemaEditor.js +87 -0
- package/dist/schema-editor/useSchemaEditor.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/table/CellEditor.d.ts +31 -0
- package/dist/table/CellEditor.js +144 -0
- package/dist/table/CellEditor.js.map +1 -0
- package/dist/table/Pager.d.ts +8 -0
- package/dist/table/Pager.js +90 -0
- package/dist/table/Pager.js.map +1 -0
- package/dist/table/TableRenderer.d.ts +27 -0
- package/dist/table/TableRenderer.js +458 -0
- package/dist/table/TableRenderer.js.map +1 -0
- package/dist/table/cells.d.ts +38 -0
- package/dist/table/cells.js +218 -0
- package/dist/table/cells.js.map +1 -0
- package/dist/table/sparkline.d.ts +31 -0
- package/dist/table/sparkline.js +105 -0
- package/dist/table/sparkline.js.map +1 -0
- package/dist/table/states.d.ts +10 -0
- package/dist/table/states.js +71 -0
- package/dist/table/states.js.map +1 -0
- package/dist/table/style.d.ts +15 -0
- package/dist/table/style.js +53 -0
- package/dist/table/style.js.map +1 -0
- package/dist/table/transforms.d.ts +17 -0
- package/dist/table/transforms.js +95 -0
- package/dist/table/transforms.js.map +1 -0
- package/dist/table/useInfiniteSentinel.d.ts +8 -0
- package/dist/table/useInfiniteSentinel.js +34 -0
- package/dist/table/useInfiniteSentinel.js.map +1 -0
- package/dist/time/timezone.d.ts +27 -0
- package/dist/time/timezone.js +69 -0
- package/dist/time/timezone.js.map +1 -0
- package/dist/time/zoned.d.ts +65 -0
- package/dist/time/zoned.js +208 -0
- package/dist/time/zoned.js.map +1 -0
- package/dist/tokens.css +454 -0
- package/dist/tree/TreeNode.d.ts +9 -0
- package/dist/tree/TreeNode.js +291 -0
- package/dist/tree/TreeNode.js.map +1 -0
- package/dist/tree/TreeRenderer.d.ts +54 -0
- package/dist/tree/TreeRenderer.js +446 -0
- package/dist/tree/TreeRenderer.js.map +1 -0
- package/dist/tree/expand.d.ts +31 -0
- package/dist/tree/expand.js +80 -0
- package/dist/tree/expand.js.map +1 -0
- package/dist/tree/model.d.ts +108 -0
- package/dist/tree/model.js +294 -0
- package/dist/tree/model.js.map +1 -0
- package/dist/udc/hooks.d.ts +644 -0
- package/dist/udc/hooks.js +353 -0
- package/dist/udc/hooks.js.map +1 -0
- package/dist/udc/keys.d.ts +19 -0
- package/dist/udc/keys.js +30 -0
- package/dist/udc/keys.js.map +1 -0
- package/dist/udc/provider.d.ts +14 -0
- package/dist/udc/provider.js +36 -0
- package/dist/udc/provider.js.map +1 -0
- package/package.json +113 -4
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { udcKeys } from "./keys.js";
|
|
2
|
+
import { useUdcClient } from "./provider.js";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { isVersionConflict } from "@jsudc/core";
|
|
5
|
+
import { keepPreviousData, useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
|
+
// src/udc/hooks.ts
|
|
7
|
+
function useUdcCollections() {
|
|
8
|
+
const client = useUdcClient();
|
|
9
|
+
return useQuery({
|
|
10
|
+
queryKey: udcKeys.collections(),
|
|
11
|
+
queryFn: () => client.collections()
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function useUdcDescribe(collection, opts = {}) {
|
|
15
|
+
const client = useUdcClient();
|
|
16
|
+
return useQuery({
|
|
17
|
+
queryKey: udcKeys.describe(collection),
|
|
18
|
+
queryFn: () => client.describe(collection),
|
|
19
|
+
staleTime: 3e5,
|
|
20
|
+
enabled: (opts.enabled ?? true) && collection !== ""
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** The file a `source_yaml` collection is read from (`source.read`); fetched again on every mount. */
|
|
24
|
+
function useUdcSource(collection, opts = {}) {
|
|
25
|
+
const client = useUdcClient();
|
|
26
|
+
return useQuery({
|
|
27
|
+
queryKey: udcKeys.source(collection),
|
|
28
|
+
queryFn: () => client.sourceRead(collection),
|
|
29
|
+
staleTime: 0,
|
|
30
|
+
enabled: (opts.enabled ?? true) && collection !== ""
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** `refetchInterval` for TanStack: a positive number of ms, else off. */
|
|
34
|
+
function pollInterval(ms) {
|
|
35
|
+
return typeof ms === "number" && ms > 0 ? ms : false;
|
|
36
|
+
}
|
|
37
|
+
/** The freshness of a list answer: `fetched_at` and `stale` when the source sent them. */
|
|
38
|
+
function freshnessOf(res) {
|
|
39
|
+
return {
|
|
40
|
+
fetchedAt: res?.fetched_at ?? null,
|
|
41
|
+
stale: res?.stale === true
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** The `offset` a 1-based page asks for. */
|
|
45
|
+
function pageOffset(page, limit) {
|
|
46
|
+
return Math.max(0, Math.floor(page) - 1) * limit;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Rows of one collection. Infinite mode follows `next_cursor` page by page
|
|
50
|
+
* (`useInfiniteQuery`), or the next `offset` while rows remain when the
|
|
51
|
+
* source pages by offset only; pages mode asks for one `offset` page
|
|
52
|
+
* (`useQuery`). Both hooks are always mounted and the inactive one is
|
|
53
|
+
* disabled, so switching modes keeps each cache warm. `refetchInterval`
|
|
54
|
+
* polls the active one.
|
|
55
|
+
*/
|
|
56
|
+
function useUdcCollection(args) {
|
|
57
|
+
const client = useUdcClient();
|
|
58
|
+
const { collection, filter, mode, pageLimit: limit } = args;
|
|
59
|
+
const sort = args.sort ?? [];
|
|
60
|
+
const page = Math.max(1, args.page ?? 1);
|
|
61
|
+
const enabled = args.enabled ?? true;
|
|
62
|
+
const byCursor = args.capabilities?.paging?.includes("cursor") ?? true;
|
|
63
|
+
const refetchInterval = pollInterval(args.refetchInterval);
|
|
64
|
+
const infiniteParams = {
|
|
65
|
+
filter,
|
|
66
|
+
sort,
|
|
67
|
+
limit,
|
|
68
|
+
mode: "infinite"
|
|
69
|
+
};
|
|
70
|
+
const infinite = useInfiniteQuery({
|
|
71
|
+
queryKey: udcKeys.list(collection, infiniteParams),
|
|
72
|
+
queryFn: ({ pageParam, signal }) => client.list({
|
|
73
|
+
collection,
|
|
74
|
+
...filter ? { filter } : {},
|
|
75
|
+
sort,
|
|
76
|
+
page: typeof pageParam === "number" ? {
|
|
77
|
+
limit,
|
|
78
|
+
offset: pageParam
|
|
79
|
+
} : pageParam ? {
|
|
80
|
+
limit,
|
|
81
|
+
cursor: pageParam
|
|
82
|
+
} : { limit }
|
|
83
|
+
}, { signal }),
|
|
84
|
+
initialPageParam: null,
|
|
85
|
+
getNextPageParam: (last, all) => {
|
|
86
|
+
if (byCursor) return last.next_cursor ?? void 0;
|
|
87
|
+
const loaded = all.reduce((n, p) => n + p.rows.length, 0);
|
|
88
|
+
return last.rows.length > 0 && last.total !== null && loaded < last.total ? loaded : void 0;
|
|
89
|
+
},
|
|
90
|
+
placeholderData: keepPreviousData,
|
|
91
|
+
enabled: enabled && mode === "infinite",
|
|
92
|
+
refetchInterval
|
|
93
|
+
});
|
|
94
|
+
const pagesParams = {
|
|
95
|
+
filter,
|
|
96
|
+
sort,
|
|
97
|
+
limit,
|
|
98
|
+
mode: "pages",
|
|
99
|
+
page
|
|
100
|
+
};
|
|
101
|
+
const paged = useQuery({
|
|
102
|
+
queryKey: udcKeys.list(collection, pagesParams),
|
|
103
|
+
queryFn: ({ signal }) => client.list({
|
|
104
|
+
collection,
|
|
105
|
+
...filter ? { filter } : {},
|
|
106
|
+
sort,
|
|
107
|
+
page: {
|
|
108
|
+
limit,
|
|
109
|
+
offset: pageOffset(page, limit)
|
|
110
|
+
}
|
|
111
|
+
}, { signal }),
|
|
112
|
+
placeholderData: keepPreviousData,
|
|
113
|
+
enabled: enabled && mode === "pages",
|
|
114
|
+
refetchInterval
|
|
115
|
+
});
|
|
116
|
+
if (mode === "infinite") {
|
|
117
|
+
const pages = infinite.data?.pages ?? [];
|
|
118
|
+
return {
|
|
119
|
+
rows: pages.flatMap((p) => p.rows),
|
|
120
|
+
total: pages[0]?.total ?? null,
|
|
121
|
+
isLoading: infinite.isLoading,
|
|
122
|
+
isFetching: infinite.isFetching,
|
|
123
|
+
error: infinite.error,
|
|
124
|
+
refetch: () => void infinite.refetch(),
|
|
125
|
+
hasNextPage: infinite.hasNextPage,
|
|
126
|
+
isFetchingNextPage: infinite.isFetchingNextPage,
|
|
127
|
+
fetchNextPage: () => void infinite.fetchNextPage(),
|
|
128
|
+
...freshnessOf(pages[0])
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
rows: paged.data?.rows ?? [],
|
|
133
|
+
total: paged.data?.total ?? null,
|
|
134
|
+
isLoading: paged.isLoading,
|
|
135
|
+
isFetching: paged.isFetching,
|
|
136
|
+
error: paged.error,
|
|
137
|
+
refetch: () => void paged.refetch(),
|
|
138
|
+
hasNextPage: false,
|
|
139
|
+
isFetchingNextPage: false,
|
|
140
|
+
fetchNextPage: () => {},
|
|
141
|
+
...freshnessOf(paged.data)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
var ALL_ROWS_MAX = 2e3;
|
|
145
|
+
var ALL_ROWS_PAGE = 500;
|
|
146
|
+
/**
|
|
147
|
+
* Every row of a filter, `list` page after page, until `total` or `max`.
|
|
148
|
+
* Follows `next_cursor` when keyset paging is on; a source that answers no
|
|
149
|
+
* cursor while rows remain is walked on by offset. Answers one list whose
|
|
150
|
+
* `total` is the server's (so `rows.length < total` means capped), with the
|
|
151
|
+
* first page's `fetched_at` and `stale`.
|
|
152
|
+
*/
|
|
153
|
+
async function fetchAllRows(client, args) {
|
|
154
|
+
const { collection, filter, max } = args;
|
|
155
|
+
const sort = args.sort ?? [];
|
|
156
|
+
const pageLimit = args.pageLimit ?? ALL_ROWS_PAGE;
|
|
157
|
+
const rows = [];
|
|
158
|
+
let total = null;
|
|
159
|
+
let freshness = {};
|
|
160
|
+
let cursor = null;
|
|
161
|
+
let byCursor = args.cursor;
|
|
162
|
+
while (rows.length < max) {
|
|
163
|
+
const limit = Math.min(pageLimit, max - rows.length);
|
|
164
|
+
const page = byCursor ? cursor ? {
|
|
165
|
+
limit,
|
|
166
|
+
cursor
|
|
167
|
+
} : { limit } : {
|
|
168
|
+
limit,
|
|
169
|
+
offset: rows.length
|
|
170
|
+
};
|
|
171
|
+
const res = await client.list({
|
|
172
|
+
collection,
|
|
173
|
+
...filter ? { filter } : {},
|
|
174
|
+
sort,
|
|
175
|
+
page
|
|
176
|
+
}, args.signal ? { signal: args.signal } : void 0);
|
|
177
|
+
if (rows.length === 0) freshness = {
|
|
178
|
+
...res.fetched_at === void 0 ? {} : { fetched_at: res.fetched_at },
|
|
179
|
+
...res.stale === void 0 ? {} : { stale: res.stale }
|
|
180
|
+
};
|
|
181
|
+
rows.push(...res.rows);
|
|
182
|
+
total = res.total;
|
|
183
|
+
args.onProgress?.(rows.length, total);
|
|
184
|
+
if (res.rows.length === 0 || total !== null && rows.length >= total) break;
|
|
185
|
+
if (byCursor) {
|
|
186
|
+
if (res.next_cursor) cursor = res.next_cursor;
|
|
187
|
+
else if (total === null) break;
|
|
188
|
+
else byCursor = false;
|
|
189
|
+
} else if (total === null && res.rows.length < limit) break;
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
...freshness,
|
|
193
|
+
rows,
|
|
194
|
+
next_cursor: null,
|
|
195
|
+
total: total ?? rows.length
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* All rows of the current filter in one cached list: what the kanban (and
|
|
200
|
+
* the calendar, tree, map and charts after it) draw from. The cache entry
|
|
201
|
+
* sits under `udcKeys.lists(collection)`, so `useUdcMutate`'s optimistic
|
|
202
|
+
* patches and invalidations reach it like every other list.
|
|
203
|
+
*/
|
|
204
|
+
function useUdcAllRows(args) {
|
|
205
|
+
const client = useUdcClient();
|
|
206
|
+
const { collection, filter } = args;
|
|
207
|
+
const sort = args.sort ?? [];
|
|
208
|
+
const max = args.max ?? 2e3;
|
|
209
|
+
const cursor = args.capabilities?.paging?.includes("cursor") ?? true;
|
|
210
|
+
const [progress, setProgress] = useState(null);
|
|
211
|
+
const key = {
|
|
212
|
+
filter,
|
|
213
|
+
sort,
|
|
214
|
+
limit: max,
|
|
215
|
+
mode: "all"
|
|
216
|
+
};
|
|
217
|
+
const query = useQuery({
|
|
218
|
+
queryKey: udcKeys.list(collection, key),
|
|
219
|
+
queryFn: async ({ signal }) => {
|
|
220
|
+
setProgress({
|
|
221
|
+
loaded: 0,
|
|
222
|
+
total: null
|
|
223
|
+
});
|
|
224
|
+
try {
|
|
225
|
+
return await fetchAllRows(client, {
|
|
226
|
+
collection,
|
|
227
|
+
filter,
|
|
228
|
+
sort,
|
|
229
|
+
max,
|
|
230
|
+
cursor,
|
|
231
|
+
signal,
|
|
232
|
+
onProgress: (loaded, total) => setProgress({
|
|
233
|
+
loaded,
|
|
234
|
+
total
|
|
235
|
+
})
|
|
236
|
+
});
|
|
237
|
+
} finally {
|
|
238
|
+
setProgress(null);
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
placeholderData: keepPreviousData,
|
|
242
|
+
enabled: args.enabled ?? true,
|
|
243
|
+
refetchInterval: pollInterval(args.refetchInterval)
|
|
244
|
+
});
|
|
245
|
+
const rows = query.data?.rows ?? [];
|
|
246
|
+
const total = query.data?.total ?? null;
|
|
247
|
+
return {
|
|
248
|
+
rows,
|
|
249
|
+
total,
|
|
250
|
+
isLoading: query.isLoading,
|
|
251
|
+
isFetching: query.isFetching,
|
|
252
|
+
error: query.error,
|
|
253
|
+
refetch: () => query.refetch(),
|
|
254
|
+
capped: total !== null && rows.length < total,
|
|
255
|
+
progress,
|
|
256
|
+
...freshnessOf(query.data)
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function isInfinite(data) {
|
|
260
|
+
return "pages" in data;
|
|
261
|
+
}
|
|
262
|
+
/** `data` with every row whose id is `id` passed through `patch`. */
|
|
263
|
+
function patchRowInList(data, id, patch) {
|
|
264
|
+
if (!data) return data;
|
|
265
|
+
const patchPage = (page) => page.rows.some((r) => r.__meta.id === id) ? {
|
|
266
|
+
...page,
|
|
267
|
+
rows: page.rows.map((r) => r.__meta.id === id ? patch(r) : r)
|
|
268
|
+
} : page;
|
|
269
|
+
return isInfinite(data) ? {
|
|
270
|
+
...data,
|
|
271
|
+
pages: data.pages.map(patchPage)
|
|
272
|
+
} : patchPage(data);
|
|
273
|
+
}
|
|
274
|
+
function patchRowEverywhere(qc, collection, id, patch) {
|
|
275
|
+
qc.setQueriesData({ queryKey: udcKeys.lists(collection) }, (data) => patchRowInList(data, id, patch));
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Insert / update / delete one row. An update is applied optimistically to
|
|
279
|
+
* the row in every cached list page and rolled back if the server says no.
|
|
280
|
+
* A `version_conflict` additionally re-reads the row, so the cache holds the
|
|
281
|
+
* value that won; the error still reaches the caller. Lists are invalidated
|
|
282
|
+
* once the call settles.
|
|
283
|
+
*/
|
|
284
|
+
function useUdcMutate(collection) {
|
|
285
|
+
const client = useUdcClient();
|
|
286
|
+
const qc = useQueryClient();
|
|
287
|
+
return useMutation({
|
|
288
|
+
mutationFn: (vars) => client.mutate({
|
|
289
|
+
collection,
|
|
290
|
+
...vars
|
|
291
|
+
}),
|
|
292
|
+
onMutate: async (vars) => {
|
|
293
|
+
await qc.cancelQueries({ queryKey: udcKeys.lists(collection) });
|
|
294
|
+
const snapshot = qc.getQueriesData({ queryKey: udcKeys.lists(collection) });
|
|
295
|
+
const { id, row } = vars;
|
|
296
|
+
if (vars.op === "update" && id && row) patchRowEverywhere(qc, collection, id, (r) => ({
|
|
297
|
+
...r,
|
|
298
|
+
...row,
|
|
299
|
+
__meta: r.__meta
|
|
300
|
+
}));
|
|
301
|
+
return { snapshot };
|
|
302
|
+
},
|
|
303
|
+
onSuccess: (res) => {
|
|
304
|
+
patchRowEverywhere(qc, collection, res.row.__meta.id, () => res.row);
|
|
305
|
+
},
|
|
306
|
+
onError: async (err, vars, ctx) => {
|
|
307
|
+
for (const [key, data] of ctx?.snapshot ?? []) qc.setQueryData(key, data);
|
|
308
|
+
if (isVersionConflict(err) && vars.id) try {
|
|
309
|
+
const fresh = await client.read(collection, vars.id);
|
|
310
|
+
patchRowEverywhere(qc, collection, vars.id, () => fresh.row);
|
|
311
|
+
} catch {}
|
|
312
|
+
},
|
|
313
|
+
onSettled: () => qc.invalidateQueries({ queryKey: udcKeys.lists(collection) })
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* The three schema edits. Each answers the new schema; `describe` (which
|
|
318
|
+
* derives the columns) and the lists are refetched afterwards.
|
|
319
|
+
*/
|
|
320
|
+
function useUdcSchema(collection) {
|
|
321
|
+
const client = useUdcClient();
|
|
322
|
+
const qc = useQueryClient();
|
|
323
|
+
const onSuccess = async () => {
|
|
324
|
+
await qc.invalidateQueries({ queryKey: udcKeys.describe(collection) });
|
|
325
|
+
await qc.invalidateQueries({ queryKey: udcKeys.lists(collection) });
|
|
326
|
+
};
|
|
327
|
+
return {
|
|
328
|
+
addField: useMutation({
|
|
329
|
+
mutationFn: (req) => client.schemaAddField({
|
|
330
|
+
collection,
|
|
331
|
+
...req
|
|
332
|
+
}),
|
|
333
|
+
onSuccess
|
|
334
|
+
}),
|
|
335
|
+
updateField: useMutation({
|
|
336
|
+
mutationFn: (req) => client.schemaUpdateField({
|
|
337
|
+
collection,
|
|
338
|
+
...req
|
|
339
|
+
}),
|
|
340
|
+
onSuccess
|
|
341
|
+
}),
|
|
342
|
+
softDeleteField: useMutation({
|
|
343
|
+
mutationFn: (field) => client.schemaSoftDeleteField({
|
|
344
|
+
collection,
|
|
345
|
+
field
|
|
346
|
+
}),
|
|
347
|
+
onSuccess
|
|
348
|
+
})
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
export { ALL_ROWS_MAX, fetchAllRows, freshnessOf, pageOffset, patchRowInList, pollInterval, useUdcAllRows, useUdcCollection, useUdcCollections, useUdcDescribe, useUdcMutate, useUdcSchema, useUdcSource };
|
|
352
|
+
|
|
353
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","names":[],"sources":["../../src/udc/hooks.ts"],"sourcesContent":["import {\n type ActionRequest,\n type Capabilities,\n type FilterNode,\n isVersionConflict,\n type ListResponse,\n type Row,\n type SortKey,\n} from \"@jsudc/core\";\nimport type { UdcClient } from \"@jsudc/core/client\";\nimport {\n type InfiniteData,\n keepPreviousData,\n type QueryClient,\n useInfiniteQuery,\n useMutation,\n useQuery,\n useQueryClient,\n} from \"@tanstack/react-query\";\nimport { useState } from \"react\";\nimport { type ListKeyParams, type PagingMode, udcKeys } from \"./keys\";\nimport { useUdcClient } from \"./provider\";\n\nexport function useUdcCollections() {\n const client = useUdcClient();\n return useQuery({ queryKey: udcKeys.collections(), queryFn: () => client.collections() });\n}\n\nexport function useUdcDescribe(collection: string, opts: { enabled?: boolean } = {}) {\n const client = useUdcClient();\n return useQuery({\n queryKey: udcKeys.describe(collection),\n queryFn: () => client.describe(collection),\n staleTime: 5 * 60_000,\n enabled: (opts.enabled ?? true) && collection !== \"\",\n });\n}\n\n/** The file a `source_yaml` collection is read from (`source.read`); fetched again on every mount. */\nexport function useUdcSource(collection: string, opts: { enabled?: boolean } = {}) {\n const client = useUdcClient();\n return useQuery({\n queryKey: udcKeys.source(collection),\n queryFn: () => client.sourceRead(collection),\n staleTime: 0,\n enabled: (opts.enabled ?? true) && collection !== \"\",\n });\n}\n\nexport interface UseUdcCollectionArgs {\n collection: string;\n filter?: FilterNode | undefined;\n sort?: SortKey[];\n mode: PagingMode;\n pageLimit: number;\n /** 1-based; pages mode only. */\n page?: number;\n enabled?: boolean;\n /** From `describe`: a source without `cursor` paging is walked by offset in infinite mode too. */\n capabilities?: Pick<Capabilities, \"paging\"> | undefined;\n /** Poll: refetch the loaded rows this often (the view's `refresh_interval_ms`). */\n refetchInterval?: number | undefined;\n}\n\nexport interface UdcCollectionResult {\n rows: Row[];\n total: number | null;\n isLoading: boolean;\n isFetching: boolean;\n error: Error | null;\n refetch: () => void;\n /** Infinite mode only; always false in pages mode. */\n hasNextPage: boolean;\n isFetchingNextPage: boolean;\n fetchNextPage: () => void;\n /** A source serving a fetched copy: when it was fetched, and whether the last refresh failed. */\n fetchedAt: string | null;\n stale: boolean;\n}\n\n/** `refetchInterval` for TanStack: a positive number of ms, else off. */\nexport function pollInterval(ms: number | undefined): number | false {\n return typeof ms === \"number\" && ms > 0 ? ms : false;\n}\n\n/** The freshness of a list answer: `fetched_at` and `stale` when the source sent them. */\nexport function freshnessOf(res: Pick<ListResponse, \"fetched_at\" | \"stale\"> | undefined): {\n fetchedAt: string | null;\n stale: boolean;\n} {\n return { fetchedAt: res?.fetched_at ?? null, stale: res?.stale === true };\n}\n\n/** The `offset` a 1-based page asks for. */\nexport function pageOffset(page: number, limit: number): number {\n return Math.max(0, Math.floor(page) - 1) * limit;\n}\n\n/**\n * Rows of one collection. Infinite mode follows `next_cursor` page by page\n * (`useInfiniteQuery`), or the next `offset` while rows remain when the\n * source pages by offset only; pages mode asks for one `offset` page\n * (`useQuery`). Both hooks are always mounted and the inactive one is\n * disabled, so switching modes keeps each cache warm. `refetchInterval`\n * polls the active one.\n */\nexport function useUdcCollection(args: UseUdcCollectionArgs): UdcCollectionResult {\n const client = useUdcClient();\n const { collection, filter, mode, pageLimit: limit } = args;\n const sort = args.sort ?? [];\n const page = Math.max(1, args.page ?? 1);\n const enabled = args.enabled ?? true;\n const byCursor = args.capabilities?.paging?.includes(\"cursor\") ?? true;\n const refetchInterval = pollInterval(args.refetchInterval);\n\n const infiniteParams: ListKeyParams = { filter, sort, limit, mode: \"infinite\" };\n const infinite = useInfiniteQuery({\n queryKey: udcKeys.list(collection, infiniteParams),\n queryFn: ({ pageParam, signal }) =>\n client.list(\n {\n collection,\n ...(filter ? { filter } : {}),\n sort,\n page:\n typeof pageParam === \"number\"\n ? { limit, offset: pageParam }\n : pageParam\n ? { limit, cursor: pageParam }\n : { limit },\n },\n { signal },\n ),\n initialPageParam: null as string | number | null,\n getNextPageParam: (last, all) => {\n if (byCursor) return last.next_cursor ?? undefined;\n const loaded = all.reduce((n, p) => n + p.rows.length, 0);\n return last.rows.length > 0 && last.total !== null && loaded < last.total\n ? loaded\n : undefined;\n },\n placeholderData: keepPreviousData,\n enabled: enabled && mode === \"infinite\",\n refetchInterval,\n });\n\n const pagesParams: ListKeyParams = { filter, sort, limit, mode: \"pages\", page };\n const paged = useQuery({\n queryKey: udcKeys.list(collection, pagesParams),\n queryFn: ({ signal }) =>\n client.list(\n {\n collection,\n ...(filter ? { filter } : {}),\n sort,\n page: { limit, offset: pageOffset(page, limit) },\n },\n { signal },\n ),\n placeholderData: keepPreviousData,\n enabled: enabled && mode === \"pages\",\n refetchInterval,\n });\n\n if (mode === \"infinite\") {\n const pages = infinite.data?.pages ?? [];\n return {\n rows: pages.flatMap((p) => p.rows),\n total: pages[0]?.total ?? null,\n isLoading: infinite.isLoading,\n isFetching: infinite.isFetching,\n error: infinite.error,\n refetch: () => void infinite.refetch(),\n hasNextPage: infinite.hasNextPage,\n isFetchingNextPage: infinite.isFetchingNextPage,\n fetchNextPage: () => void infinite.fetchNextPage(),\n ...freshnessOf(pages[0]),\n };\n }\n return {\n rows: paged.data?.rows ?? [],\n total: paged.data?.total ?? null,\n isLoading: paged.isLoading,\n isFetching: paged.isFetching,\n error: paged.error,\n refetch: () => void paged.refetch(),\n hasNextPage: false,\n isFetchingNextPage: false,\n fetchNextPage: () => {},\n ...freshnessOf(paged.data),\n };\n}\n\nexport const ALL_ROWS_MAX = 2000;\nconst ALL_ROWS_PAGE = 500;\n\nexport interface FetchAllRowsArgs {\n collection: string;\n filter?: FilterNode | undefined;\n sort?: SortKey[];\n /** Stop after this many rows. */\n max: number;\n /** Rows per `list` call. */\n pageLimit?: number;\n /** Keyset paging unless the source pages by offset only. */\n cursor: boolean;\n signal?: AbortSignal;\n onProgress?: (loaded: number, total: number | null) => void;\n}\n\n/**\n * Every row of a filter, `list` page after page, until `total` or `max`.\n * Follows `next_cursor` when keyset paging is on; a source that answers no\n * cursor while rows remain is walked on by offset. Answers one list whose\n * `total` is the server's (so `rows.length < total` means capped), with the\n * first page's `fetched_at` and `stale`.\n */\nexport async function fetchAllRows(\n client: UdcClient,\n args: FetchAllRowsArgs,\n): Promise<ListResponse> {\n const { collection, filter, max } = args;\n const sort = args.sort ?? [];\n const pageLimit = args.pageLimit ?? ALL_ROWS_PAGE;\n const rows: Row[] = [];\n let total: number | null = null;\n let freshness: Pick<ListResponse, \"fetched_at\" | \"stale\"> = {};\n let cursor: string | null = null;\n let byCursor = args.cursor;\n while (rows.length < max) {\n const limit = Math.min(pageLimit, max - rows.length);\n const page = byCursor\n ? cursor\n ? { limit, cursor }\n : { limit }\n : { limit, offset: rows.length };\n const res = await client.list(\n { collection, ...(filter ? { filter } : {}), sort, page },\n args.signal ? { signal: args.signal } : undefined,\n );\n if (rows.length === 0) {\n freshness = {\n ...(res.fetched_at === undefined ? {} : { fetched_at: res.fetched_at }),\n ...(res.stale === undefined ? {} : { stale: res.stale }),\n };\n }\n rows.push(...res.rows);\n total = res.total;\n args.onProgress?.(rows.length, total);\n if (res.rows.length === 0 || (total !== null && rows.length >= total)) break;\n if (byCursor) {\n if (res.next_cursor) cursor = res.next_cursor;\n else if (total === null) break;\n else byCursor = false;\n } else if (total === null && res.rows.length < limit) {\n break;\n }\n }\n return { ...freshness, rows, next_cursor: null, total: total ?? rows.length };\n}\n\nexport interface UseUdcAllRowsArgs {\n collection: string;\n filter?: FilterNode | undefined;\n sort?: SortKey[];\n /** Default 2,000. */\n max?: number;\n /** From `describe`: whether the source pages by cursor. */\n capabilities?: Pick<Capabilities, \"paging\"> | undefined;\n enabled?: boolean;\n /** Poll: refetch every row this often (the view's `refresh_interval_ms`). */\n refetchInterval?: number | undefined;\n}\n\nexport interface UdcAllRowsResult {\n rows: Row[];\n total: number | null;\n isLoading: boolean;\n isFetching: boolean;\n error: Error | null;\n refetch: () => Promise<unknown>;\n /** More rows match than `max`: only the first `max` are here. */\n capped: boolean;\n /** Rows loaded so far by the fetch in flight, for a progress bar. */\n progress: { loaded: number; total: number | null } | null;\n fetchedAt: string | null;\n stale: boolean;\n}\n\n/**\n * All rows of the current filter in one cached list: what the kanban (and\n * the calendar, tree, map and charts after it) draw from. The cache entry\n * sits under `udcKeys.lists(collection)`, so `useUdcMutate`'s optimistic\n * patches and invalidations reach it like every other list.\n */\nexport function useUdcAllRows(args: UseUdcAllRowsArgs): UdcAllRowsResult {\n const client = useUdcClient();\n const { collection, filter } = args;\n const sort = args.sort ?? [];\n const max = args.max ?? ALL_ROWS_MAX;\n const cursor = args.capabilities?.paging?.includes(\"cursor\") ?? true;\n const [progress, setProgress] = useState<UdcAllRowsResult[\"progress\"]>(null);\n\n const key: ListKeyParams = { filter, sort, limit: max, mode: \"all\" };\n const query = useQuery({\n queryKey: udcKeys.list(collection, key),\n queryFn: async ({ signal }) => {\n setProgress({ loaded: 0, total: null });\n try {\n return await fetchAllRows(client, {\n collection,\n filter,\n sort,\n max,\n cursor,\n signal,\n onProgress: (loaded, total) => setProgress({ loaded, total }),\n });\n } finally {\n setProgress(null);\n }\n },\n placeholderData: keepPreviousData,\n enabled: args.enabled ?? true,\n refetchInterval: pollInterval(args.refetchInterval),\n });\n\n const rows = query.data?.rows ?? [];\n const total = query.data?.total ?? null;\n return {\n rows,\n total,\n isLoading: query.isLoading,\n isFetching: query.isFetching,\n error: query.error,\n refetch: () => query.refetch(),\n capped: total !== null && rows.length < total,\n progress,\n ...freshnessOf(query.data),\n };\n}\n\ntype ListCache = ListResponse | InfiniteData<ListResponse, unknown>;\n\nfunction isInfinite(data: ListCache): data is InfiniteData<ListResponse, unknown> {\n return \"pages\" in data;\n}\n\n/** `data` with every row whose id is `id` passed through `patch`. */\nexport function patchRowInList(\n data: ListCache | undefined,\n id: string,\n patch: (row: Row) => Row,\n): ListCache | undefined {\n if (!data) return data;\n const patchPage = (page: ListResponse): ListResponse =>\n page.rows.some((r) => r.__meta.id === id)\n ? { ...page, rows: page.rows.map((r) => (r.__meta.id === id ? patch(r) : r)) }\n : page;\n return isInfinite(data) ? { ...data, pages: data.pages.map(patchPage) } : patchPage(data);\n}\n\nfunction patchRowEverywhere(\n qc: QueryClient,\n collection: string,\n id: string,\n patch: (row: Row) => Row,\n) {\n qc.setQueriesData<ListCache>({ queryKey: udcKeys.lists(collection) }, (data) =>\n patchRowInList(data, id, patch),\n );\n}\n\nexport type UdcMutateVars = Omit<ActionRequest<\"mutate\">, \"collection\">;\n\n/**\n * Insert / update / delete one row. An update is applied optimistically to\n * the row in every cached list page and rolled back if the server says no.\n * A `version_conflict` additionally re-reads the row, so the cache holds the\n * value that won; the error still reaches the caller. Lists are invalidated\n * once the call settles.\n */\nexport function useUdcMutate(collection: string) {\n const client = useUdcClient();\n const qc = useQueryClient();\n\n return useMutation({\n mutationFn: (vars: UdcMutateVars) => client.mutate({ collection, ...vars }),\n onMutate: async (vars) => {\n await qc.cancelQueries({ queryKey: udcKeys.lists(collection) });\n const snapshot = qc.getQueriesData<ListCache>({ queryKey: udcKeys.lists(collection) });\n const { id, row } = vars;\n if (vars.op === \"update\" && id && row) {\n patchRowEverywhere(qc, collection, id, (r) => ({ ...r, ...row, __meta: r.__meta }));\n }\n return { snapshot };\n },\n onSuccess: (res) => {\n patchRowEverywhere(qc, collection, res.row.__meta.id, () => res.row);\n },\n onError: async (err, vars, ctx) => {\n for (const [key, data] of ctx?.snapshot ?? []) qc.setQueryData(key, data);\n if (isVersionConflict(err) && vars.id) {\n try {\n const fresh = await client.read(collection, vars.id);\n patchRowEverywhere(qc, collection, vars.id, () => fresh.row);\n } catch {\n // The invalidation below refetches the lists anyway.\n }\n }\n },\n onSettled: () => qc.invalidateQueries({ queryKey: udcKeys.lists(collection) }),\n });\n}\n\n/**\n * The three schema edits. Each answers the new schema; `describe` (which\n * derives the columns) and the lists are refetched afterwards.\n */\nexport function useUdcSchema(collection: string) {\n const client = useUdcClient();\n const qc = useQueryClient();\n const onSuccess = async () => {\n await qc.invalidateQueries({ queryKey: udcKeys.describe(collection) });\n await qc.invalidateQueries({ queryKey: udcKeys.lists(collection) });\n };\n\n const addField = useMutation({\n mutationFn: (req: Omit<ActionRequest<\"schema.add_field\">, \"collection\">) =>\n client.schemaAddField({ collection, ...req }),\n onSuccess,\n });\n const updateField = useMutation({\n mutationFn: (req: Omit<ActionRequest<\"schema.update_field\">, \"collection\">) =>\n client.schemaUpdateField({ collection, ...req }),\n onSuccess,\n });\n const softDeleteField = useMutation({\n mutationFn: (field: string) => client.schemaSoftDeleteField({ collection, field }),\n onSuccess,\n });\n return { addField, updateField, softDeleteField };\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,oBAAoB;CAClC,MAAM,SAAS,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AAO,KAAK,MAAM,QAAQ;GACjC,KAAK,MAAM,CAAC,KAAK,SAAS,KAAK,YAAY,CAAC,GAAG,GAAG,aAAa,KAAK,IAAI;GACxE,IAAI,kBAAkB,GAAG,KAAK,KAAK,IACjC,IAAI;IACF,MAAM,QAAQ,MAAM,OAAO,KAAK,YAAY,KAAK,EAAE;IACnD,mBAAmB,IAAI,YAAY,KAAK,UAAU,MAAM,GAAG;GAC7D,QAAQ,CAER;EAEJ;EACA,iBAAiB,GAAG,kBAAkB,EAAE,UAAU,QAAQ,MAAM,UAAU,EAAE,CAAC;CAC/E,CAAC;AACH;;;;;AAMA,SAAgB,aAAa,YAAoB;CAC/C,MAAM,SAAS,aAAa;CAC5B,MAAM,KAAK,eAAe;CAC1B,MAAM,YAAY,YAAY;EAC5B,MAAM,GAAG,kBAAkB,EAAE,UAAU,QAAQ,SAAS,UAAU,EAAE,CAAC;EACrE,MAAM,GAAG,kBAAkB,EAAE,UAAU,QAAQ,MAAM,UAAU,EAAE,CAAC;CACpE;CAgBA,OAAO;EAAE,UAdQ,YAAY;GAC3B,aAAa,QACX,OAAO,eAAe;IAAE;IAAY,GAAG;GAAI,CAAC;GAC9C;EACF,CAUS;EAAU,aATC,YAAY;GAC9B,aAAa,QACX,OAAO,kBAAkB;IAAE;IAAY,GAAG;GAAI,CAAC;GACjD;EACF,CAKmB;EAAa,iBAJR,YAAY;GAClC,aAAa,UAAkB,OAAO,sBAAsB;IAAE;IAAY;GAAM,CAAC;GACjF;EACF,CACgC;CAAgB;AAClD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FilterNode, SortKey } from "@jsudc/core";
|
|
2
|
+
export type PagingMode = "infinite" | "pages";
|
|
3
|
+
export interface ListKeyParams {
|
|
4
|
+
filter: FilterNode | undefined;
|
|
5
|
+
sort: SortKey[];
|
|
6
|
+
limit: number;
|
|
7
|
+
/** `all`: every row up to `limit`, fetched page by page into one list (`useUdcAllRows`). */
|
|
8
|
+
mode: PagingMode | "all";
|
|
9
|
+
page?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Every query this app makes sits under `["udc", ...]`. */
|
|
12
|
+
export declare const udcKeys: {
|
|
13
|
+
all: readonly ["udc"];
|
|
14
|
+
collections: () => readonly ["udc", "collections"];
|
|
15
|
+
describe: (collection: string) => readonly ["udc", "describe", string];
|
|
16
|
+
source: (collection: string) => readonly ["udc", "source", string];
|
|
17
|
+
lists: (collection: string) => readonly ["udc", "list", string];
|
|
18
|
+
list: (collection: string, params: ListKeyParams) => readonly ["udc", "list", string, ListKeyParams];
|
|
19
|
+
};
|
package/dist/udc/keys.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/udc/keys.ts
|
|
2
|
+
/** Every query this app makes sits under `["udc", ...]`. */
|
|
3
|
+
var udcKeys = {
|
|
4
|
+
all: ["udc"],
|
|
5
|
+
collections: () => ["udc", "collections"],
|
|
6
|
+
describe: (collection) => [
|
|
7
|
+
"udc",
|
|
8
|
+
"describe",
|
|
9
|
+
collection
|
|
10
|
+
],
|
|
11
|
+
source: (collection) => [
|
|
12
|
+
"udc",
|
|
13
|
+
"source",
|
|
14
|
+
collection
|
|
15
|
+
],
|
|
16
|
+
lists: (collection) => [
|
|
17
|
+
"udc",
|
|
18
|
+
"list",
|
|
19
|
+
collection
|
|
20
|
+
],
|
|
21
|
+
list: (collection, params) => [
|
|
22
|
+
"udc",
|
|
23
|
+
"list",
|
|
24
|
+
collection,
|
|
25
|
+
params
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
export { udcKeys };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","names":[],"sources":["../../src/udc/keys.ts"],"sourcesContent":["import type { FilterNode, SortKey } from \"@jsudc/core\";\n\nexport type PagingMode = \"infinite\" | \"pages\";\n\nexport interface ListKeyParams {\n filter: FilterNode | undefined;\n sort: SortKey[];\n limit: number;\n /** `all`: every row up to `limit`, fetched page by page into one list (`useUdcAllRows`). */\n mode: PagingMode | \"all\";\n page?: number;\n}\n\n/** Every query this app makes sits under `[\"udc\", ...]`. */\nexport const udcKeys = {\n all: [\"udc\"] as const,\n collections: () => [\"udc\", \"collections\"] as const,\n describe: (collection: string) => [\"udc\", \"describe\", collection] as const,\n source: (collection: string) => [\"udc\", \"source\", collection] as const,\n lists: (collection: string) => [\"udc\", \"list\", collection] as const,\n list: (collection: string, params: ListKeyParams) => [\"udc\", \"list\", collection, params] as const,\n};\n"],"mappings":";;AAcA,IAAa,UAAU;CACrB,KAAK,CAAC,KAAK;CACX,mBAAmB,CAAC,OAAO,aAAa;CACxC,WAAW,eAAuB;EAAC;EAAO;EAAY;CAAU;CAChE,SAAS,eAAuB;EAAC;EAAO;EAAU;CAAU;CAC5D,QAAQ,eAAuB;EAAC;EAAO;EAAQ;CAAU;CACzD,OAAO,YAAoB,WAA0B;EAAC;EAAO;EAAQ;EAAY;CAAM;AACzF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UdcClient } from "@jsudc/core/client";
|
|
2
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { type ReactNode } from "react";
|
|
4
|
+
export declare function UdcProvider({ client, children }: {
|
|
5
|
+
client: UdcClient;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
export declare function useUdcClient(): UdcClient;
|
|
9
|
+
/**
|
|
10
|
+
* A protocol error is the server's answer, not a hiccup: asking again gives
|
|
11
|
+
* the same answer. Only transport failures are retried, twice.
|
|
12
|
+
*/
|
|
13
|
+
export declare function shouldRetry(failureCount: number, error: unknown): boolean;
|
|
14
|
+
export declare function createUdcQueryClient(): QueryClient;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isUdcError } from "@jsudc/core";
|
|
4
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
5
|
+
// src/udc/provider.tsx
|
|
6
|
+
var UdcClientContext = createContext(null);
|
|
7
|
+
function UdcProvider({ client, children }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(UdcClientContext.Provider, {
|
|
9
|
+
value: client,
|
|
10
|
+
children
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function useUdcClient() {
|
|
14
|
+
const client = useContext(UdcClientContext);
|
|
15
|
+
if (!client) throw new Error("useUdcClient needs a <UdcProvider client={...}> above it");
|
|
16
|
+
return client;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A protocol error is the server's answer, not a hiccup: asking again gives
|
|
20
|
+
* the same answer. Only transport failures are retried, twice.
|
|
21
|
+
*/
|
|
22
|
+
function shouldRetry(failureCount, error) {
|
|
23
|
+
return !isUdcError(error) && failureCount < 2;
|
|
24
|
+
}
|
|
25
|
+
function createUdcQueryClient() {
|
|
26
|
+
return new QueryClient({ defaultOptions: {
|
|
27
|
+
queries: {
|
|
28
|
+
retry: shouldRetry,
|
|
29
|
+
refetchOnWindowFocus: false
|
|
30
|
+
},
|
|
31
|
+
mutations: { retry: false }
|
|
32
|
+
} });
|
|
33
|
+
}
|
|
34
|
+
export { UdcProvider, createUdcQueryClient, shouldRetry, useUdcClient };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","names":[],"sources":["../../src/udc/provider.tsx"],"sourcesContent":["import { isUdcError } from \"@jsudc/core\";\nimport type { UdcClient } from \"@jsudc/core/client\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { createContext, type ReactNode, useContext } from \"react\";\n\nconst UdcClientContext = createContext<UdcClient | null>(null);\n\nexport function UdcProvider({ client, children }: { client: UdcClient; children: ReactNode }) {\n return <UdcClientContext.Provider value={client}>{children}</UdcClientContext.Provider>;\n}\n\nexport function useUdcClient(): UdcClient {\n const client = useContext(UdcClientContext);\n if (!client) throw new Error(\"useUdcClient needs a <UdcProvider client={...}> above it\");\n return client;\n}\n\n/**\n * A protocol error is the server's answer, not a hiccup: asking again gives\n * the same answer. Only transport failures are retried, twice.\n */\nexport function shouldRetry(failureCount: number, error: unknown): boolean {\n return !isUdcError(error) && failureCount < 2;\n}\n\nexport function createUdcQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: { retry: shouldRetry, refetchOnWindowFocus: false },\n mutations: { retry: false },\n },\n });\n}\n"],"mappings":";;;;;AAKA,IAAM,mBAAmB,cAAgC,IAAI;AAE7D,SAAgB,YAAY,EAAE,QAAQ,YAAwD;CAC5F,OAAO,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO;EAAS;CAAoC,CAAA;AACxF;AAEA,SAAgB,eAA0B;CACxC,MAAM,SAAS,WAAW,gBAAgB;CAC1C,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,0DAA0D;CACvF,OAAO;AACT;;;;;AAMA,SAAgB,YAAY,cAAsB,OAAyB;CACzE,OAAO,CAAC,WAAW,KAAK,KAAK,eAAe;AAC9C;AAEA,SAAgB,uBAAoC;CAClD,OAAO,IAAI,YAAY,EACrB,gBAAgB;EACd,SAAS;GAAE,OAAO;GAAa,sBAAsB;EAAM;EAC3D,WAAW,EAAE,OAAO,MAAM;CAC5B,EACF,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,115 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsudc/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "React components for UDC collections: the data view with its table, cards, kanban, calendar, tree, map and chart renderers, the schema editor, the hooks over @jsudc/core's client, i18n, theme and a compiled stylesheet.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"udc",
|
|
9
|
+
"jsudc",
|
|
10
|
+
"universal-data-collection",
|
|
11
|
+
"universal-data-collections",
|
|
12
|
+
"data-grid",
|
|
13
|
+
"react",
|
|
14
|
+
"data-table",
|
|
15
|
+
"kanban",
|
|
16
|
+
"calendar",
|
|
17
|
+
"tanstack-query",
|
|
18
|
+
"tailwindcss"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "DigitalCube",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/digital-cube/jsudc-react.git"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/digital-cube/jsudc-react#readme",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/digital-cube/jsudc-react/issues"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=24"
|
|
32
|
+
},
|
|
33
|
+
"sideEffects": [
|
|
34
|
+
"*.css"
|
|
35
|
+
],
|
|
36
|
+
"main": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"default": "./dist/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./styles.css": "./dist/styles.css",
|
|
44
|
+
"./tokens.css": "./dist/tokens.css",
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"README.md",
|
|
50
|
+
"LICENSE"
|
|
51
|
+
],
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "vite build && tsc -p tsconfig.build.json && npm run build:css",
|
|
57
|
+
"build:css": "tailwindcss -i src/styles.css -o dist/styles.css --minify && node -e \"require('node:fs').copyFileSync('src/tokens.css', 'dist/tokens.css')\"",
|
|
58
|
+
"prepare": "npm run build",
|
|
59
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
60
|
+
"lint": "biome check .",
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"test:watch": "vitest"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"clsx": "^2.1.1",
|
|
66
|
+
"marked": "^18.1.2",
|
|
67
|
+
"tailwind-merge": "^3.7.0"
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"@dnd-kit/core": "^6.3.1",
|
|
71
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
72
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
73
|
+
"@jsudc/core": "^0.1.1",
|
|
74
|
+
"@tanstack/react-query": "^5.104.4",
|
|
75
|
+
"@tanstack/react-table": "^8.21.3",
|
|
76
|
+
"leaflet": "^1.9.4",
|
|
77
|
+
"lucide-react": "^1.59.0",
|
|
78
|
+
"radix-ui": "^1.8.1",
|
|
79
|
+
"react": "^19",
|
|
80
|
+
"react-dom": "^19",
|
|
81
|
+
"react-router": "^7",
|
|
82
|
+
"recharts": "^3.10.1"
|
|
83
|
+
},
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"@biomejs/biome": "^2.5.15",
|
|
86
|
+
"@dnd-kit/core": "^6.3.1",
|
|
87
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
88
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
89
|
+
"@jsudc/core": "github:digital-cube/jsudc-core#v0.1.0",
|
|
90
|
+
"@tailwindcss/cli": "^4.3.3",
|
|
91
|
+
"@tanstack/react-query": "^5.104.4",
|
|
92
|
+
"@tanstack/react-table": "^8.21.3",
|
|
93
|
+
"@testing-library/dom": "^10.4.2",
|
|
94
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
95
|
+
"@testing-library/react": "^16.3.3",
|
|
96
|
+
"@testing-library/user-event": "^14.6.8",
|
|
97
|
+
"@types/leaflet": "^1.9.22",
|
|
98
|
+
"@types/node": "^24",
|
|
99
|
+
"@types/react": "^19.3.0",
|
|
100
|
+
"@types/react-dom": "^19.3.0",
|
|
101
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
102
|
+
"jsdom": "^30.1.3",
|
|
103
|
+
"leaflet": "^1.9.4",
|
|
104
|
+
"lucide-react": "^1.59.0",
|
|
105
|
+
"radix-ui": "^1.8.1",
|
|
106
|
+
"react": "^19.3.1",
|
|
107
|
+
"react-dom": "^19.3.1",
|
|
108
|
+
"react-router": "^7.18.4",
|
|
109
|
+
"recharts": "^3.10.1",
|
|
110
|
+
"tailwindcss": "^4.3.3",
|
|
111
|
+
"typescript": "^5.9.3",
|
|
112
|
+
"vite": "^8.3.4",
|
|
113
|
+
"vitest": "^5.0.5"
|
|
114
|
+
}
|
|
115
|
+
}
|