@iyulab/enterprise 0.10.2 → 0.11.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/CHANGELOG.md +13 -0
- package/dist/data/ODataService.d.ts +5 -0
- package/dist/index.js +20 -20
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **`ODataService.odataPatchQuiet`/`odataDeleteQuiet`** — quiet counterparts to
|
|
8
|
+
`odataPatch`/`odataDelete`, mirroring the existing `odataPost`/`odataPostQuiet`
|
|
9
|
+
split. For an action that fires more than one mutation in response to a single
|
|
10
|
+
user click (e.g. editing a row and syncing a denormalized parent field), the
|
|
11
|
+
toasting variants would show a toast per mutation; the quiet variants do the
|
|
12
|
+
request and error handling without one, so the caller can toast once for the
|
|
13
|
+
whole action. Previously PATCH/DELETE had no quiet path, forcing a raw
|
|
14
|
+
`fetch()` that lost 401 handling and `ApiError` extraction.
|
|
15
|
+
|
|
3
16
|
## 0.10.2
|
|
4
17
|
|
|
5
18
|
### Changed
|
|
@@ -67,8 +67,13 @@ export interface ODataService {
|
|
|
67
67
|
odataPostQuiet<T>(entity: string, body: Partial<T>): Promise<T>;
|
|
68
68
|
/** OData POST(생성) — 성공 시 `saved` 토스트. */
|
|
69
69
|
odataPost<T>(entity: string, body: Partial<T>): Promise<T>;
|
|
70
|
+
/** OData PATCH(수정) — 토스트 없이 결과만(자식 컬렉션 편집 후 부모의 파생 필드를
|
|
71
|
+
* 함께 동기화하는 등, 한 사용자 액션이 여러 mutation을 낼 때 토스트 폭주 방지). */
|
|
72
|
+
odataPatchQuiet<T>(entity: string, id: string, body: Partial<T>): Promise<void>;
|
|
70
73
|
/** OData PATCH(수정) — 성공 시 `updated` 토스트. */
|
|
71
74
|
odataPatch<T>(entity: string, id: string, body: Partial<T>): Promise<void>;
|
|
75
|
+
/** OData DELETE — 토스트 없이(`odataPatchQuiet`와 같은 이유). */
|
|
76
|
+
odataDeleteQuiet(entity: string, id: string): Promise<void>;
|
|
72
77
|
/** OData DELETE — 성공 시 `deleted` 토스트. */
|
|
73
78
|
odataDelete(entity: string, id: string): Promise<void>;
|
|
74
79
|
/** custom REST GET — 204 등 빈 바디를 안전 파싱. */
|
package/dist/index.js
CHANGED
|
@@ -743,31 +743,29 @@ function createODataService(config) {
|
|
|
743
743
|
throw e;
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
|
+
async function odataPatchQuiet(entity, id, body) {
|
|
747
|
+
await throwIfError(await client.patch(`${odataUrl(entity)}(${id})`, normalizeBody(body)));
|
|
748
|
+
}
|
|
746
749
|
async function odataPatch(entity, id, body) {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
const msg = await extractErrorMsg(res);
|
|
754
|
-
notifyError?.(msg);
|
|
755
|
-
throw new ApiError(msg, res.status);
|
|
750
|
+
try {
|
|
751
|
+
await odataPatchQuiet(entity, id, body);
|
|
752
|
+
notifySuccess?.(messages.updated);
|
|
753
|
+
} catch (e) {
|
|
754
|
+
if (!(e instanceof ApiError && e.status === 401)) notifyError?.(e instanceof Error ? e.message : messages.requestFailed);
|
|
755
|
+
throw e;
|
|
756
756
|
}
|
|
757
|
-
|
|
757
|
+
}
|
|
758
|
+
async function odataDeleteQuiet(entity, id) {
|
|
759
|
+
await throwIfError(await client.delete(`${odataUrl(entity)}(${id})`));
|
|
758
760
|
}
|
|
759
761
|
async function odataDelete(entity, id) {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
const msg = await extractErrorMsg(res);
|
|
767
|
-
notifyError?.(msg);
|
|
768
|
-
throw new ApiError(msg, res.status);
|
|
762
|
+
try {
|
|
763
|
+
await odataDeleteQuiet(entity, id);
|
|
764
|
+
notifySuccess?.(messages.deleted);
|
|
765
|
+
} catch (e) {
|
|
766
|
+
if (!(e instanceof ApiError && e.status === 401)) notifyError?.(e instanceof Error ? e.message : messages.requestFailed);
|
|
767
|
+
throw e;
|
|
769
768
|
}
|
|
770
|
-
notifySuccess?.(messages.deleted);
|
|
771
769
|
}
|
|
772
770
|
async function apiGet(path) {
|
|
773
771
|
const [p, ...q] = path.split("?");
|
|
@@ -809,7 +807,9 @@ function createODataService(config) {
|
|
|
809
807
|
odataCount,
|
|
810
808
|
odataPostQuiet,
|
|
811
809
|
odataPost,
|
|
810
|
+
odataPatchQuiet,
|
|
812
811
|
odataPatch,
|
|
812
|
+
odataDeleteQuiet,
|
|
813
813
|
odataDelete,
|
|
814
814
|
apiGet,
|
|
815
815
|
apiPost,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyulab/enterprise",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Enterprise utilities and components for iyulab framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"enterprise",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"./styles/preset.css": "./dist/styles/preset.css"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
|
+
"preversion": "node ../../scripts/preversion-check.mjs",
|
|
48
49
|
"build": "npm run typecheck && vite build && node scripts/copy-styles.mjs",
|
|
49
50
|
"test": "vitest run",
|
|
50
51
|
"typecheck": "tsc --noEmit"
|