@svadmin/core 0.80.0 → 0.81.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/package.json +1 -1
- package/src/cursor-provider.ts +67 -0
- package/src/i18n.svelte.ts +60 -2
- package/src/index.ts +3 -1
- package/src/types.ts +12 -1
package/package.json
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared cursor pagination contracts for providers whose backend does not expose
|
|
3
|
+
* a stable total count. A cursor is opaque to the UI and must only be reused
|
|
4
|
+
* with the query that produced it.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface CursorPage<TItem> {
|
|
8
|
+
items: TItem[];
|
|
9
|
+
nextCursor: string | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CursorProviderInput<TQuery, TOptions = unknown> {
|
|
13
|
+
query: TQuery;
|
|
14
|
+
cursor?: string | null;
|
|
15
|
+
options?: TOptions;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CursorProvider<TQuery, TItem, TOptions = unknown> {
|
|
19
|
+
getList(input: CursorProviderInput<TQuery, TOptions>): Promise<CursorPage<TItem>>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type CursorPageFetcher<TQuery, TItem, TOptions = unknown> =
|
|
23
|
+
(input: CursorProviderInput<TQuery, TOptions>) => Promise<CursorPage<TItem>>;
|
|
24
|
+
|
|
25
|
+
/** Creates a typed cursor provider without coupling projects to a transport. */
|
|
26
|
+
export function createCursorProvider<TQuery, TItem, TOptions = unknown>(
|
|
27
|
+
fetchPage: CursorPageFetcher<TQuery, TItem, TOptions>,
|
|
28
|
+
): CursorProvider<TQuery, TItem, TOptions> {
|
|
29
|
+
return { getList: fetchPage };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface CursorPageCache<TItem> {
|
|
33
|
+
reset(): void;
|
|
34
|
+
cursorForPage(page: number): string | null | undefined;
|
|
35
|
+
page(page: number): CursorPage<TItem> | undefined;
|
|
36
|
+
save(page: number, value: CursorPage<TItem>): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Keeps visited pages and the opaque cursor chain needed to reach them. */
|
|
40
|
+
export function createCursorPageCache<TItem>(): CursorPageCache<TItem> {
|
|
41
|
+
let pages = new Map<number, CursorPage<TItem>>();
|
|
42
|
+
let cursors = new Map<number, string | null>([[1, null]]);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
reset() {
|
|
46
|
+
pages = new Map();
|
|
47
|
+
cursors = new Map([[1, null]]);
|
|
48
|
+
},
|
|
49
|
+
cursorForPage(page) {
|
|
50
|
+
return cursors.get(page);
|
|
51
|
+
},
|
|
52
|
+
page(page) {
|
|
53
|
+
return pages.get(page);
|
|
54
|
+
},
|
|
55
|
+
save(page, value) {
|
|
56
|
+
pages.set(page, value);
|
|
57
|
+
for (const key of pages.keys()) {
|
|
58
|
+
if (key > page) pages.delete(key);
|
|
59
|
+
}
|
|
60
|
+
for (const key of cursors.keys()) {
|
|
61
|
+
if (key > page + 1) cursors.delete(key);
|
|
62
|
+
}
|
|
63
|
+
if (value.nextCursor) cursors.set(page + 1, value.nextCursor);
|
|
64
|
+
else cursors.delete(page + 1);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
package/src/i18n.svelte.ts
CHANGED
|
@@ -231,7 +231,7 @@ const baseLocales: Record<string, Record<string, string>> = {
|
|
|
231
231
|
'common.export': '导出',
|
|
232
232
|
'common.download': '下载',
|
|
233
233
|
'common.preview': '预览',
|
|
234
|
-
'common.remove': '移除',
|
|
234
|
+
'common.remove': '移除', 'common.removeFilter': '移除筛选', 'common.deletePreset': '删除当前预设', 'common.pollInterval': '刷新频率',
|
|
235
235
|
'common.file': '文件',
|
|
236
236
|
'common.import': '导入',
|
|
237
237
|
'common.chooseFile': '选择文件',
|
|
@@ -811,6 +811,35 @@ const baseLocales: Record<string, Record<string, string>> = {
|
|
|
811
811
|
'task.status.dead_lettered': '死信',
|
|
812
812
|
'task.status.retry_scheduled': '等待重试',
|
|
813
813
|
'task.status.leased': '已领取',
|
|
814
|
+
'taskCenter.title': '任务中心',
|
|
815
|
+
'taskCenter.description': '跟踪并管理异步导出和批处理任务',
|
|
816
|
+
'taskCenter.empty': '暂无后台任务',
|
|
817
|
+
'taskCenter.trigger': '任务',
|
|
818
|
+
'taskCenter.open': '打开任务中心',
|
|
819
|
+
'taskCenter.refresh': '刷新任务',
|
|
820
|
+
'taskCenter.close': '关闭任务中心',
|
|
821
|
+
'taskCenter.tab.all': '全部',
|
|
822
|
+
'taskCenter.tab.running': '执行中',
|
|
823
|
+
'taskCenter.tab.pending': '等待中',
|
|
824
|
+
'taskCenter.tab.completed': '已完成',
|
|
825
|
+
'taskCenter.tab.failed': '失败',
|
|
826
|
+
'taskCenter.clear': '清除已完成',
|
|
827
|
+
'taskCenter.status.running': '执行中',
|
|
828
|
+
'taskCenter.status.pending': '等待中',
|
|
829
|
+
'taskCenter.status.completed': '已完成',
|
|
830
|
+
'taskCenter.status.failed': '失败',
|
|
831
|
+
'taskCenter.status.cancelled': '已取消',
|
|
832
|
+
'taskCenter.remaining': '剩余约 {duration}',
|
|
833
|
+
'taskCenter.id': '编号',
|
|
834
|
+
'taskCenter.download': '下载',
|
|
835
|
+
'taskCenter.retry': '重试',
|
|
836
|
+
'taskCenter.cancel': '取消',
|
|
837
|
+
'taskCenter.seconds': '{count} 秒',
|
|
838
|
+
'taskCenter.minutes': '{minutes} 分 {seconds} 秒',
|
|
839
|
+
'approvalTimeline.status.approved': '已通过',
|
|
840
|
+
'approvalTimeline.status.rejected': '已拒绝',
|
|
841
|
+
'approvalTimeline.status.pending': '待处理',
|
|
842
|
+
'approvalTimeline.status.running': '处理中',
|
|
814
843
|
// Profile sections
|
|
815
844
|
'profileSections.about': '关于',
|
|
816
845
|
'profileSections.workExperience': '工作经历',
|
|
@@ -1222,7 +1251,7 @@ const baseLocales: Record<string, Record<string, string>> = {
|
|
|
1222
1251
|
'common.export': 'Export',
|
|
1223
1252
|
'common.download': 'Download',
|
|
1224
1253
|
'common.preview': 'Preview',
|
|
1225
|
-
'common.remove': 'Remove',
|
|
1254
|
+
'common.remove': 'Remove', 'common.removeFilter': 'Remove filter', 'common.deletePreset': 'Delete active preset', 'common.pollInterval': 'Poll interval',
|
|
1226
1255
|
'common.file': 'File',
|
|
1227
1256
|
'common.import': 'Import',
|
|
1228
1257
|
'common.chooseFile': 'Choose file',
|
|
@@ -1802,6 +1831,35 @@ const baseLocales: Record<string, Record<string, string>> = {
|
|
|
1802
1831
|
'task.status.dead_lettered': 'Dead lettered',
|
|
1803
1832
|
'task.status.retry_scheduled': 'Retry scheduled',
|
|
1804
1833
|
'task.status.leased': 'Leased',
|
|
1834
|
+
'taskCenter.title': 'Task Center',
|
|
1835
|
+
'taskCenter.description': 'Track and manage asynchronous background exports and batch jobs',
|
|
1836
|
+
'taskCenter.empty': 'No background tasks',
|
|
1837
|
+
'taskCenter.trigger': 'Tasks',
|
|
1838
|
+
'taskCenter.open': 'Open task center',
|
|
1839
|
+
'taskCenter.refresh': 'Refresh tasks',
|
|
1840
|
+
'taskCenter.close': 'Close task center',
|
|
1841
|
+
'taskCenter.tab.all': 'All',
|
|
1842
|
+
'taskCenter.tab.running': 'Running',
|
|
1843
|
+
'taskCenter.tab.pending': 'Pending',
|
|
1844
|
+
'taskCenter.tab.completed': 'Completed',
|
|
1845
|
+
'taskCenter.tab.failed': 'Failed',
|
|
1846
|
+
'taskCenter.clear': 'Clear completed',
|
|
1847
|
+
'taskCenter.status.running': 'Running',
|
|
1848
|
+
'taskCenter.status.pending': 'Pending',
|
|
1849
|
+
'taskCenter.status.completed': 'Completed',
|
|
1850
|
+
'taskCenter.status.failed': 'Failed',
|
|
1851
|
+
'taskCenter.status.cancelled': 'Cancelled',
|
|
1852
|
+
'taskCenter.remaining': '~{duration} remaining',
|
|
1853
|
+
'taskCenter.id': 'ID',
|
|
1854
|
+
'taskCenter.download': 'Download',
|
|
1855
|
+
'taskCenter.retry': 'Retry',
|
|
1856
|
+
'taskCenter.cancel': 'Cancel',
|
|
1857
|
+
'taskCenter.seconds': '{count}s',
|
|
1858
|
+
'taskCenter.minutes': '{minutes}m {seconds}s',
|
|
1859
|
+
'approvalTimeline.status.approved': 'Approved',
|
|
1860
|
+
'approvalTimeline.status.rejected': 'Rejected',
|
|
1861
|
+
'approvalTimeline.status.pending': 'Pending',
|
|
1862
|
+
'approvalTimeline.status.running': 'In progress',
|
|
1805
1863
|
// Profile sections
|
|
1806
1864
|
'profileSections.about': 'About',
|
|
1807
1865
|
'profileSections.workExperience': 'Work Experience',
|
package/src/index.ts
CHANGED
|
@@ -225,6 +225,8 @@ export { setAdminOptions, getAdminOptions, getTextTransformers } from './options
|
|
|
225
225
|
export type { AdminOptions, TextTransformers, OvertimeConfig } from './options.svelte';
|
|
226
226
|
export { checkError } from './hook-utils.svelte';
|
|
227
227
|
export type { NotificationConfig, OvertimeOptions, OvertimeResult, LiveSubscriptionParams } from './hook-utils.svelte';
|
|
228
|
+
export { createCursorPageCache, createCursorProvider } from './cursor-provider';
|
|
229
|
+
export type { CursorPage, CursorPageCache, CursorPageFetcher, CursorProvider, CursorProviderInput } from './cursor-provider';
|
|
228
230
|
|
|
229
231
|
export { CRUD_FIELD_OPERATORS, DeleteManyPartialError, HttpError, UndoError, isCrudFieldOperator } from './types';
|
|
230
232
|
export {
|
|
@@ -249,7 +251,7 @@ export type {
|
|
|
249
251
|
UpdateManyParams, UpdateManyResult,
|
|
250
252
|
DeleteParams, DeleteResult,
|
|
251
253
|
DeleteManyParams, DeleteManyResult,
|
|
252
|
-
Pagination, Sort, Filter, Identity,
|
|
254
|
+
Pagination, Sort, Filter, Identity, CursorPageInfo,
|
|
253
255
|
ResourceDefinition, ResourceProviderConfig, ResourceTransportConfig, ResourceAdapterConfig,
|
|
254
256
|
FieldDefinition, DateInputOptions, MenuItem,
|
|
255
257
|
AuthActionResult, CheckResult,
|
package/src/types.ts
CHANGED
|
@@ -77,10 +77,19 @@ export type BaseRecord = Record<string, unknown>;
|
|
|
77
77
|
|
|
78
78
|
// ─── DataProvider ─────────────────────────────────────────────
|
|
79
79
|
|
|
80
|
+
export interface CursorPageInfo {
|
|
81
|
+
nextCursor?: string | null;
|
|
82
|
+
hasNextPage?: boolean;
|
|
83
|
+
hasPreviousPage?: boolean;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
80
87
|
export interface Pagination {
|
|
81
88
|
current?: number;
|
|
82
89
|
pageSize?: number;
|
|
83
|
-
mode?: 'server' | 'client' | 'off';
|
|
90
|
+
mode?: 'server' | 'client' | 'cursor' | 'off';
|
|
91
|
+
/** Opaque cursor supplied by a cursor-mode provider. */
|
|
92
|
+
cursor?: string | null;
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
export interface Sort {
|
|
@@ -135,6 +144,8 @@ export interface GetListParams {
|
|
|
135
144
|
export interface GetListResult<TData extends BaseRecord = BaseRecord> {
|
|
136
145
|
data: TData[];
|
|
137
146
|
total: number;
|
|
147
|
+
/** Cursor navigation metadata; offset providers may omit it. */
|
|
148
|
+
cursor?: CursorPageInfo | string;
|
|
138
149
|
[key: string]: unknown;
|
|
139
150
|
}
|
|
140
151
|
|