@ph-cms/client-sdk 0.1.18 → 0.1.21
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/README.md +28 -0
- package/dist/core.d.ts +13 -0
- package/dist/core.js +32 -0
- package/dist/modules/content.js +2 -2
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -1261,6 +1261,34 @@ const client = new PHCMSClient({
|
|
|
1261
1261
|
});
|
|
1262
1262
|
```
|
|
1263
1263
|
|
|
1264
|
+
#### React 없는 환경에서 사용 (Node.js, Next.js 서버 컴포넌트 등)
|
|
1265
|
+
|
|
1266
|
+
메인 엔트리포인트(`@ph-cms/client-sdk`)는 React Context(`PHCMSProvider` 등)를 포함하고 있어, React가 없는 환경에서 임포트하면 `TypeError: createContext is not a function` 오류가 발생합니다.
|
|
1267
|
+
|
|
1268
|
+
이 경우 React 의존성이 제거된 `/core` 서브패스를 사용하세요.
|
|
1269
|
+
|
|
1270
|
+
```ts
|
|
1271
|
+
import { PHCMSClient, ContentModule } from '@ph-cms/client-sdk/core';
|
|
1272
|
+
|
|
1273
|
+
const client = new PHCMSClient({
|
|
1274
|
+
baseURL: 'https://api.ph-cms.com',
|
|
1275
|
+
});
|
|
1276
|
+
|
|
1277
|
+
// 모듈을 직접 사용
|
|
1278
|
+
const result = await client.content.list({ channelUid: 'my-channel' });
|
|
1279
|
+
```
|
|
1280
|
+
|
|
1281
|
+
`/core`에서 export되는 항목은 다음과 같습니다 (React 관련 항목 제외):
|
|
1282
|
+
|
|
1283
|
+
| 카테고리 | export 항목 |
|
|
1284
|
+
|---|---|
|
|
1285
|
+
| 클라이언트 | `PHCMSClient` |
|
|
1286
|
+
| 모듈 | `ContentModule`, `AuthModule`, `UserModule`, `ChannelModule`, `MediaModule`, `TermsModule` |
|
|
1287
|
+
| Auth 프로바이더 | `BaseAuthProvider`, `LocalAuthProvider`, `JwtUtils` |
|
|
1288
|
+
| 타입/에러 | `PHCMSClientError`, 각종 DTO/Request 타입 |
|
|
1289
|
+
|
|
1290
|
+
> React 환경에서는 기존대로 `@ph-cms/client-sdk`에서 임포트하면 `PHCMSProvider`, hooks 등을 모두 사용할 수 있습니다.
|
|
1291
|
+
|
|
1264
1292
|
### `UserModule` (`client.user`)
|
|
1265
1293
|
|
|
1266
1294
|
| 메서드 | 설명 |
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './auth/base-provider';
|
|
2
|
+
export * from './auth/interfaces';
|
|
3
|
+
export * from './auth/jwt-utils';
|
|
4
|
+
export * from './auth/local-provider';
|
|
5
|
+
export * from './client';
|
|
6
|
+
export * from './errors';
|
|
7
|
+
export * from './modules/auth';
|
|
8
|
+
export * from './modules/channel';
|
|
9
|
+
export * from './modules/content';
|
|
10
|
+
export * from './modules/media';
|
|
11
|
+
export * from './modules/terms';
|
|
12
|
+
export * from './modules/user';
|
|
13
|
+
export * from './types';
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Core entry point without React dependencies.
|
|
3
|
+
// Use this in non-React environments (Node.js, Next.js server components, etc.)
|
|
4
|
+
// import { ContentModule } from '@ph-cms/client-sdk/core'
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./auth/base-provider"), exports);
|
|
21
|
+
__exportStar(require("./auth/interfaces"), exports);
|
|
22
|
+
__exportStar(require("./auth/jwt-utils"), exports);
|
|
23
|
+
__exportStar(require("./auth/local-provider"), exports);
|
|
24
|
+
__exportStar(require("./client"), exports);
|
|
25
|
+
__exportStar(require("./errors"), exports);
|
|
26
|
+
__exportStar(require("./modules/auth"), exports);
|
|
27
|
+
__exportStar(require("./modules/channel"), exports);
|
|
28
|
+
__exportStar(require("./modules/content"), exports);
|
|
29
|
+
__exportStar(require("./modules/media"), exports);
|
|
30
|
+
__exportStar(require("./modules/terms"), exports);
|
|
31
|
+
__exportStar(require("./modules/user"), exports);
|
|
32
|
+
__exportStar(require("./types"), exports);
|
package/dist/modules/content.js
CHANGED
|
@@ -22,7 +22,7 @@ class ContentModule {
|
|
|
22
22
|
async incrementView(uid) {
|
|
23
23
|
if (!uid)
|
|
24
24
|
throw new errors_1.ValidationError("UID is required", []);
|
|
25
|
-
await this.client.
|
|
25
|
+
await this.client.patch(`/api/contents/${uid}/view`);
|
|
26
26
|
}
|
|
27
27
|
async create(data) {
|
|
28
28
|
const validation = api_contract_1.CreateContentSchema.safeParse(data);
|
|
@@ -83,7 +83,7 @@ class ContentModule {
|
|
|
83
83
|
async toggleLike(uid) {
|
|
84
84
|
if (!uid)
|
|
85
85
|
throw new errors_1.ValidationError("UID is required", []);
|
|
86
|
-
return this.client.post(`/api/contents/${uid}/like
|
|
86
|
+
return this.client.post(`/api/contents/${uid}/like`, {});
|
|
87
87
|
}
|
|
88
88
|
async getLikeStatus(uid) {
|
|
89
89
|
if (!uid)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ph-cms/client-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Unified PH-CMS Client SDK (React + Core)",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"require": "./dist/index.js",
|
|
16
16
|
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./core": {
|
|
19
|
+
"types": "./dist/core.d.ts",
|
|
20
|
+
"require": "./dist/core.js",
|
|
21
|
+
"default": "./dist/core.js"
|
|
17
22
|
}
|
|
18
23
|
},
|
|
19
24
|
"main": "dist/index.js",
|