@iyulab/enterprise 0.10.0 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.1
4
+
5
+ ### Added
6
+
7
+ - **`ODataService` gained `apiPut<T>(path, body?)`.** The other three custom-REST verbs
8
+ (`apiGet`/`apiPost`/`apiPatch`/`apiDelete`) were already there; `PUT` was the one missing member
9
+ of that set, even though the underlying `@iyulab/http-client` `HttpClient` has always had `.put()`.
10
+ A consumer whose backend models "replace this resource" as `PUT` had no way to reach it through
11
+ this wrapper. Passing a `FormData` body to `apiPost`/`apiPut`/`apiPatch` already worked before this
12
+ change and needed no fix — `HttpClient` never forces JSON serialization on it and lets the browser
13
+ set the multipart boundary itself.
14
+
3
15
  ## 0.10.0
4
16
 
5
17
  ### Changed
package/README.md CHANGED
@@ -95,9 +95,21 @@ export const svc = createODataService({
95
95
 
96
96
  await svc.odataGet<Order>('Orders', { $top: '20' }) // value 배열 언랩
97
97
  await svc.odataPost<Order>('Orders', { name: 'A', note: '' }) // '' → null 정규화 + 성공 토스트
98
- await svc.apiDelete('orders/7') // 204 안전
99
98
  svc.odataUrl('Orders') // flex-table useODataSource 엔드포인트
100
99
  svc.sourceDefaults // { baseUrl, onUnauthorized } 주입용
100
+
101
+ // custom REST — GET/POST/PUT/PATCH/DELETE 전부, 204 빈 바디 안전 파싱 포함
102
+ await svc.apiGet<Order>('reports/summary')
103
+ await svc.apiPost<Order>('orders', { name: 'A' })
104
+ await svc.apiPut<Order>('orders/7', { name: 'A (revised)' }) // 리소스 전체 교체
105
+ await svc.apiPatch<Order>('orders/7', { note: 'urgent' })
106
+ await svc.apiDelete('orders/7') // 204 안전
107
+
108
+ // body가 FormData 인스턴스면 그대로(직렬화 없이) 멀티파트로 전송된다 —
109
+ // Content-Type은 브라우저가 boundary와 함께 자동 설정한다. apiPost/apiPut/apiPatch 전부 동일.
110
+ const form = new FormData()
111
+ form.append('file', file)
112
+ await svc.apiPost<Order>('orders/7/attachments', form)
101
113
  ```
102
114
 
103
115
  주입 항목:
@@ -73,9 +73,13 @@ export interface ODataService {
73
73
  odataDelete(entity: string, id: string): Promise<void>;
74
74
  /** custom REST GET — 204 등 빈 바디를 안전 파싱. */
75
75
  apiGet<T>(path: string): Promise<T>;
76
- /** custom REST POST. */
76
+ /** custom REST POST. `body`가 `FormData` 인스턴스면 그대로(직렬화 없이) 멀티파트로
77
+ * 전송된다 — `@iyulab/http-client`가 Content-Type을 브라우저 자동 설정에 맡기고
78
+ * JSON 직렬화 분기를 타지 않는다. `apiPut`/`apiPatch`도 동일하게 동작한다. */
77
79
  apiPost<T>(path: string, body?: unknown): Promise<T>;
78
- /** custom REST PATCH. */
80
+ /** custom REST PUT(리소스 전체 교체/생성). `body`의 `FormData` 처리는 `apiPost` 참조. */
81
+ apiPut<T>(path: string, body?: unknown): Promise<T>;
82
+ /** custom REST PATCH. `body`의 `FormData` 처리는 `apiPost` 참조. */
79
83
  apiPatch<T>(path: string, body?: unknown): Promise<T>;
80
84
  /** custom REST DELETE — 대부분 204 No Content. */
81
85
  apiDelete<T = void>(path: string): Promise<T>;
package/dist/index.js CHANGED
@@ -774,6 +774,11 @@ function createODataService(config) {
774
774
  await throwIfError(res);
775
775
  return parseJsonBody(res);
776
776
  }
777
+ async function apiPut(path, body) {
778
+ const res = await client.put(apiUrl(path), body ?? {});
779
+ await throwIfError(res);
780
+ return parseJsonBody(res);
781
+ }
777
782
  async function apiPatch(path, body) {
778
783
  const res = await client.patch(apiUrl(path), body ?? {});
779
784
  await throwIfError(res);
@@ -801,6 +806,7 @@ function createODataService(config) {
801
806
  odataDelete,
802
807
  apiGet,
803
808
  apiPost,
809
+ apiPut,
804
810
  apiPatch,
805
811
  apiDelete,
806
812
  fetchRaw,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iyulab/enterprise",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Enterprise utilities and components for iyulab framework",
5
5
  "keywords": [
6
6
  "enterprise",