@svadmin/core 0.79.0 → 0.81.0
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 +10 -10
- package/src/cursor-provider.ts +67 -0
- package/src/i18n.svelte.ts +82 -0
- package/src/index.ts +3 -1
- package/src/task-hooks.svelte.ts +23 -23
- package/src/types.ts +12 -1
- package/src/useCan.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0",
|
|
4
4
|
"author": "zuohuadong",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
},
|
|
10
10
|
"main": "src/index.ts",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@happy-dom/global-registrator": "^
|
|
13
|
-
"@sveltejs/vite-plugin-svelte": "^7.3.
|
|
14
|
-
"@testing-library/dom": "^10.4.
|
|
12
|
+
"@happy-dom/global-registrator": "^21.0.4",
|
|
13
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
14
|
+
"@testing-library/dom": "^10.4.2",
|
|
15
15
|
"@testing-library/svelte": "^5.4.2",
|
|
16
|
-
"@testing-library/user-event": "^14.6.
|
|
16
|
+
"@testing-library/user-event": "^14.6.9",
|
|
17
17
|
"@types/bun": "^1.4.4",
|
|
18
18
|
"@types/jsdom": "^30.0.0",
|
|
19
19
|
"exceljs": "4.4.0",
|
|
20
20
|
"happy-dom": "^21.0.4",
|
|
21
|
-
"jsdom": "^
|
|
22
|
-
"vitest": "^
|
|
21
|
+
"jsdom": "^31.0.0",
|
|
22
|
+
"vitest": "^5.1.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"exceljs": "^4.4.0",
|
|
@@ -183,9 +183,9 @@
|
|
|
183
183
|
"types": "src/index.ts",
|
|
184
184
|
"dependencies": {
|
|
185
185
|
"@types/papaparse": "^5.5.2",
|
|
186
|
-
"@internationalized/date": "^3.12.
|
|
187
|
-
"typebox": "^1.
|
|
188
|
-
"papaparse": "^5.
|
|
186
|
+
"@internationalized/date": "^3.12.4",
|
|
187
|
+
"typebox": "^1.4.6",
|
|
188
|
+
"papaparse": "^5.7.0"
|
|
189
189
|
},
|
|
190
190
|
"peerDependenciesMeta": {
|
|
191
191
|
"exceljs": {
|
|
@@ -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
|
@@ -41,6 +41,18 @@ const baseLocales: Record<string, Record<string, string>> = {
|
|
|
41
41
|
'common.idleLocked': '长时间未操作已自动锁屏',
|
|
42
42
|
'common.shortcuts': '快捷键',
|
|
43
43
|
'common.shortcutsHelp': '快捷键向导',
|
|
44
|
+
'safeDelete.title': '高危操作防误删确认',
|
|
45
|
+
'safeDelete.warning': '此操作不可逆!相关资源将被永久删除且无法恢复。',
|
|
46
|
+
'safeDelete.inputPrompt': '请输入目标全名以确认:',
|
|
47
|
+
'safeDelete.pastePrevented': '安全防护机制已启用:禁止粘贴,请手动输入完整名称',
|
|
48
|
+
'safeDelete.confirm': '确认永久删除',
|
|
49
|
+
'safeDelete.impactTitle': '连带受影响资源与级联评估:',
|
|
50
|
+
'safeDelete.countdown': '安全阅读冷却中 ({seconds}s)',
|
|
51
|
+
'captcha.dragPrompt': '向右拖动滑块填充拼图',
|
|
52
|
+
'captcha.success': '验证通过',
|
|
53
|
+
'captcha.failed': '验证失败,请重试',
|
|
54
|
+
'captcha.refresh': '换一张',
|
|
55
|
+
'captcha.tooFast': '操作过快,请自然滑动',
|
|
44
56
|
// Common
|
|
45
57
|
'common.add': '添加',
|
|
46
58
|
'common.moveUp': '上移',
|
|
@@ -799,6 +811,35 @@ const baseLocales: Record<string, Record<string, string>> = {
|
|
|
799
811
|
'task.status.dead_lettered': '死信',
|
|
800
812
|
'task.status.retry_scheduled': '等待重试',
|
|
801
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': '处理中',
|
|
802
843
|
// Profile sections
|
|
803
844
|
'profileSections.about': '关于',
|
|
804
845
|
'profileSections.workExperience': '工作经历',
|
|
@@ -1000,6 +1041,18 @@ const baseLocales: Record<string, Record<string, string>> = {
|
|
|
1000
1041
|
'common.idleLocked': 'Auto-locked due to inactivity',
|
|
1001
1042
|
'common.shortcuts': 'Shortcuts',
|
|
1002
1043
|
'common.shortcutsHelp': 'Keyboard Shortcuts',
|
|
1044
|
+
'safeDelete.title': 'High-Risk Deletion Confirmation',
|
|
1045
|
+
'safeDelete.warning': 'This action cannot be undone! The resources will be permanently removed.',
|
|
1046
|
+
'safeDelete.inputPrompt': 'Please type the resource name to confirm:',
|
|
1047
|
+
'safeDelete.pastePrevented': 'Security guard enabled: Paste is disabled, please type manually.',
|
|
1048
|
+
'safeDelete.confirm': 'Permanently Delete',
|
|
1049
|
+
'safeDelete.impactTitle': 'Cascading Impact Assessment:',
|
|
1050
|
+
'safeDelete.countdown': 'Safety reading cooldown ({seconds}s)',
|
|
1051
|
+
'captcha.dragPrompt': 'Drag the slider right to fit the puzzle',
|
|
1052
|
+
'captcha.success': 'Verification succeeded',
|
|
1053
|
+
'captcha.failed': 'Verification failed, please try again',
|
|
1054
|
+
'captcha.refresh': 'Refresh',
|
|
1055
|
+
'captcha.tooFast': 'Swipe was too fast, please slide naturally',
|
|
1003
1056
|
// Common
|
|
1004
1057
|
'common.add': 'Add',
|
|
1005
1058
|
'common.moveUp': 'Move Up',
|
|
@@ -1778,6 +1831,35 @@ const baseLocales: Record<string, Record<string, string>> = {
|
|
|
1778
1831
|
'task.status.dead_lettered': 'Dead lettered',
|
|
1779
1832
|
'task.status.retry_scheduled': 'Retry scheduled',
|
|
1780
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',
|
|
1781
1863
|
// Profile sections
|
|
1782
1864
|
'profileSections.about': 'About',
|
|
1783
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/task-hooks.svelte.ts
CHANGED
|
@@ -191,19 +191,19 @@ export function useSubmitTask(options: UseSubmitTaskOptions={}) {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
export interface UseTaskOptions {
|
|
194
|
-
taskId?: string;
|
|
195
|
-
taskProvider?: TaskProvider;
|
|
194
|
+
taskId?: string | undefined;
|
|
195
|
+
taskProvider?: TaskProvider | undefined;
|
|
196
196
|
queryOptions?: {
|
|
197
|
-
enabled?: boolean;
|
|
198
|
-
staleTime?: number;
|
|
199
|
-
gcTime?: number;
|
|
200
|
-
refetchOnWindowFocus?: boolean;
|
|
201
|
-
refetchInterval?: number|false;
|
|
202
|
-
refetchIntervalInBackground?: boolean;
|
|
197
|
+
enabled?: boolean | undefined;
|
|
198
|
+
staleTime?: number | undefined;
|
|
199
|
+
gcTime?: number | undefined;
|
|
200
|
+
refetchOnWindowFocus?: boolean | undefined;
|
|
201
|
+
refetchInterval?: number|false | undefined;
|
|
202
|
+
refetchIntervalInBackground?: boolean | undefined;
|
|
203
203
|
};
|
|
204
|
-
successNotification?: NotificationConfig;
|
|
205
|
-
errorNotification?: NotificationConfig;
|
|
206
|
-
overtimeOptions?: OvertimeOptions;
|
|
204
|
+
successNotification?: NotificationConfig | undefined;
|
|
205
|
+
errorNotification?: NotificationConfig | undefined;
|
|
206
|
+
overtimeOptions?: OvertimeOptions | undefined;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
export function useTask(
|
|
@@ -249,20 +249,20 @@ export function useTask(
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
export interface UseTaskListOptions {
|
|
252
|
-
params?: Record<string,unknown
|
|
253
|
-
dlq?: boolean;
|
|
254
|
-
taskProvider?: TaskProvider;
|
|
252
|
+
params?: Record<string,unknown> | undefined;
|
|
253
|
+
dlq?: boolean | undefined;
|
|
254
|
+
taskProvider?: TaskProvider | undefined;
|
|
255
255
|
queryOptions?: {
|
|
256
|
-
enabled?: boolean;
|
|
257
|
-
staleTime?: number;
|
|
258
|
-
gcTime?: number;
|
|
259
|
-
refetchOnWindowFocus?: boolean;
|
|
260
|
-
refetchInterval?: number|false;
|
|
261
|
-
refetchIntervalInBackground?: boolean;
|
|
256
|
+
enabled?: boolean | undefined;
|
|
257
|
+
staleTime?: number | undefined;
|
|
258
|
+
gcTime?: number | undefined;
|
|
259
|
+
refetchOnWindowFocus?: boolean | undefined;
|
|
260
|
+
refetchInterval?: number|false | undefined;
|
|
261
|
+
refetchIntervalInBackground?: boolean | undefined;
|
|
262
262
|
};
|
|
263
|
-
successNotification?: NotificationConfig;
|
|
264
|
-
errorNotification?: NotificationConfig;
|
|
265
|
-
overtimeOptions?: OvertimeOptions;
|
|
263
|
+
successNotification?: NotificationConfig | undefined;
|
|
264
|
+
errorNotification?: NotificationConfig | undefined;
|
|
265
|
+
overtimeOptions?: OvertimeOptions | undefined;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
export function useTaskList(
|
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
|
|
package/src/useCan.ts
CHANGED
|
@@ -23,8 +23,8 @@ export interface UseCanOptions {
|
|
|
23
23
|
action: Action;
|
|
24
24
|
/** Fixed record target; overrides an ID in additional permission params after validation. */
|
|
25
25
|
id?: string | number;
|
|
26
|
-
params?: NonNullable<CanParams['params']
|
|
27
|
-
meta?: Record<string,unknown
|
|
26
|
+
params?: NonNullable<CanParams['params']> | undefined;
|
|
27
|
+
meta?: Record<string,unknown> | undefined;
|
|
28
28
|
queryOptions?: {
|
|
29
29
|
enabled?: boolean;
|
|
30
30
|
staleTime?: number;
|