@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 CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@svadmin/core",
3
- "version": "0.36.0",
3
+ "version": "0.36.2",
4
4
  "author": "zuohuadong",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/zuohuadong/svadmin.git",
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.3",
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/zuohuadong/svadmin/issues"
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/zuohuadong/svadmin#readme",
72
+ "homepage": "https://github.com/vibeunion/svadmin#readme",
73
73
  "license": "MIT",
74
74
  "sideEffects": false,
75
75
  "type": "module",
@@ -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 as string[], data);
644
+ queryClient.setQueryData(queryKey, data);
645
645
  }
646
646
  }
647
647
  if (error instanceof UndoError) return;
package/src/index.ts CHANGED
@@ -16,7 +16,9 @@ export {
16
16
  createProviderBundle,
17
17
  createTenantCacheKey,
18
18
  defaultTenantAdapter,
19
+ appendTenantCacheKey,
19
20
  isTenantCacheKey,
21
+ queryKeyMatchesTenant,
20
22
  resolveTenantProviderMeta,
21
23
  withProviderMeta,
22
24
  withTenantDataProvider,
@@ -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 as string[], data);
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 as string[], data);
543
+ queryClient.setQueryData(queryKey, data);
544
544
  }
545
545
  }
546
546
  if (error instanceof UndoError) return;
@@ -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>;