@svadmin/core 0.36.0 → 0.36.2
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 +5 -5
- package/src/form-hooks.svelte.ts +2 -2
- package/src/index.ts +2 -0
- package/src/mutation-hooks.svelte.ts +3 -3
- package/src/provider-bundle.ts +25 -0
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/core",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.2",
|
|
4
4
|
"author": "zuohuadong",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/
|
|
7
|
+
"url": "https://github.com/vibeunion/svadmin.git",
|
|
8
8
|
"directory": "packages/core"
|
|
9
9
|
},
|
|
10
10
|
"main": "src/index.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
14
14
|
"@testing-library/dom": "^10.4.1",
|
|
15
15
|
"@testing-library/svelte": "^5.4.2",
|
|
16
|
-
"@testing-library/user-event": "^14.6.
|
|
16
|
+
"@testing-library/user-event": "^14.6.4",
|
|
17
17
|
"@types/bun": "^1.3.14",
|
|
18
18
|
"@types/jsdom": "^30.0.0",
|
|
19
19
|
"happy-dom": "^20.11.2",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"bugs": {
|
|
62
|
-
"url": "https://github.com/
|
|
62
|
+
"url": "https://github.com/vibeunion/svadmin/issues"
|
|
63
63
|
},
|
|
64
64
|
"description": "Core SDK — hooks, types, context, i18n, permissions, router",
|
|
65
65
|
"files": [
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"!src/**/vitest.config.*",
|
|
70
70
|
"!src/**/setupTest.*"
|
|
71
71
|
],
|
|
72
|
-
"homepage": "https://github.com/
|
|
72
|
+
"homepage": "https://github.com/vibeunion/svadmin#readme",
|
|
73
73
|
"license": "MIT",
|
|
74
74
|
"sideEffects": false,
|
|
75
75
|
"type": "module",
|
package/src/form-hooks.svelte.ts
CHANGED
|
@@ -638,10 +638,10 @@ export function useForm<
|
|
|
638
638
|
});
|
|
639
639
|
},
|
|
640
640
|
onError: (error: unknown, _vars: unknown, context: unknown) => {
|
|
641
|
-
const ctx = context as { previousQueries?: [unknown, unknown][] } | undefined;
|
|
641
|
+
const ctx = context as { previousQueries?: [readonly unknown[], unknown][] } | undefined;
|
|
642
642
|
if (ctx?.previousQueries) {
|
|
643
643
|
for (const [queryKey, data] of ctx.previousQueries) {
|
|
644
|
-
queryClient.setQueryData(queryKey
|
|
644
|
+
queryClient.setQueryData(queryKey, data);
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
647
|
if (error instanceof UndoError) return;
|
package/src/index.ts
CHANGED
|
@@ -88,7 +88,7 @@ export function deepMerge(target: unknown, source: unknown): unknown {
|
|
|
88
88
|
interface MutationContext {
|
|
89
89
|
_svadmin_ctx?: boolean;
|
|
90
90
|
userContext?: unknown;
|
|
91
|
-
previousQueries?: [unknown, unknown][];
|
|
91
|
+
previousQueries?: [readonly unknown[], unknown][];
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
interface MutationCallbacks {
|
|
@@ -359,7 +359,7 @@ export function useUpdate<TData extends BaseRecord = BaseRecord, TError = HttpEr
|
|
|
359
359
|
const ctx = context as MutationContext | undefined;
|
|
360
360
|
if (ctx?.previousQueries) {
|
|
361
361
|
for (const [queryKey, data] of ctx.previousQueries) {
|
|
362
|
-
queryClient.setQueryData(queryKey
|
|
362
|
+
queryClient.setQueryData(queryKey, data);
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
if (error instanceof UndoError) return;
|
|
@@ -540,7 +540,7 @@ export function useDelete<TData extends BaseRecord = BaseRecord, TError = HttpEr
|
|
|
540
540
|
const ctx = context as MutationContext | undefined;
|
|
541
541
|
if (ctx?.previousQueries) {
|
|
542
542
|
for (const [queryKey, data] of ctx.previousQueries) {
|
|
543
|
-
queryClient.setQueryData(queryKey
|
|
543
|
+
queryClient.setQueryData(queryKey, data);
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
546
|
if (error instanceof UndoError) return;
|
package/src/provider-bundle.ts
CHANGED
|
@@ -116,6 +116,31 @@ export function isTenantCacheKey(value: unknown): value is TenantCacheKey {
|
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
* @deprecated 0.36 — Query Key v2 replaces positional tenant cache-key appending.
|
|
121
|
+
* Use `keys({ tenant })` instead. Removed in 0.39.
|
|
122
|
+
*/
|
|
123
|
+
export function appendTenantCacheKey(
|
|
124
|
+
queryKey: readonly unknown[],
|
|
125
|
+
tenantCacheKey: TenantCacheKey | undefined,
|
|
126
|
+
): readonly unknown[] {
|
|
127
|
+
return tenantCacheKey ? [...queryKey, tenantCacheKey] : queryKey;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated 0.36 — Query Key v2 replaces positional tenant cache-key matching.
|
|
132
|
+
* Use `queryKeyMatches(queryKey, { tenant })` instead. Removed in 0.39.
|
|
133
|
+
*/
|
|
134
|
+
export function queryKeyMatchesTenant(
|
|
135
|
+
queryKey: readonly unknown[],
|
|
136
|
+
tenantCacheKey: TenantCacheKey | undefined,
|
|
137
|
+
): boolean {
|
|
138
|
+
const candidate = queryKey.at(-1);
|
|
139
|
+
const keyTenant = isTenantCacheKey(candidate) ? candidate : undefined;
|
|
140
|
+
if (!tenantCacheKey) return keyTenant === undefined;
|
|
141
|
+
return keyTenant?.__svadminTenant === tenantCacheKey.__svadminTenant;
|
|
142
|
+
}
|
|
143
|
+
|
|
119
144
|
export interface ProviderMetaInput {
|
|
120
145
|
readonly resource?: string;
|
|
121
146
|
readonly meta?: Record<string, unknown>;
|