@ph-cms/client-sdk 0.1.14 → 0.1.16

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.
Files changed (2) hide show
  1. package/bin/cli.js +79 -0
  2. package/package.json +5 -1
package/bin/cli.js ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const command = process.argv[2];
7
+
8
+ if (command === 'init-skill') {
9
+ initSkill();
10
+ } else {
11
+ console.log('Usage: npx @ph-cms/client-sdk init-skill');
12
+ process.exit(1);
13
+ }
14
+
15
+ function initSkill() {
16
+ const skillDir = path.join(process.cwd(), '.gemini/skills/ph-cms-client');
17
+ const skillMdPath = path.join(skillDir, 'SKILL.md');
18
+
19
+ const skillContent = `# PH-CMS Client SDK Skill
20
+
21
+ This skill provides expert guidance for implementing and maintaining applications using the \`@ph-cms/client-sdk\`.
22
+
23
+ ## 📌 Core Directives
24
+
25
+ 1. **Context Scoping**: All hooks (\`useContentList\`, \`useChannelTerms\`, \`useCreateContent\`, etc.) are automatically scoped to the \`channelUid\` provided in the \`PHCMSProvider\`. Do NOT manually pass \`channelUid\` to these hooks unless a cross-channel operation is explicitly requested.
26
+ 2. **Provider Requirement**: Always ensure all components using SDK hooks are wrapped within a \`PHCMSProvider\`.
27
+ 3. **Authentication Lifecycle**: Use the \`useAuth()\` hook for login, registration, and logout. It handles token storage, refreshing, and profile state automatically.
28
+ 4. **Direct API Usage**: For non-React environments or server-to-server calls, use the \`PHCMSClient\` class directly. You can inject a custom \`axiosInstance\` for special network needs (e.g., custom HTTPS agents).
29
+
30
+ ## 🛠 Usage Patterns
31
+
32
+ ### 1. Provider Setup
33
+ \`\`\`tsx
34
+ import { PHCMSClient, LocalAuthProvider, PHCMSProvider } from '@ph-cms/client-sdk';
35
+
36
+ const authProvider = new LocalAuthProvider('my_app_');
37
+ const client = new PHCMSClient({
38
+ baseURL: 'https://api.example.com',
39
+ auth: authProvider,
40
+ });
41
+
42
+ export function App() {
43
+ return (
44
+ <PHCMSProvider client={client} channelUid="target-channel-slug">
45
+ <YourApp />
46
+ </PHCMSProvider>
47
+ );
48
+ }
49
+ \`\`\`
50
+
51
+ ### 2. Content Hook (Auto-scoped)
52
+ \`\`\`tsx
53
+ const { data, isLoading } = useContentList({ limit: 10 });
54
+ \`\`\`
55
+
56
+ ### 3. User & Terms (Auto-scoped)
57
+ \`\`\`tsx
58
+ const { data: terms } = useChannelTerms();
59
+ const { mutate: agree } = useAgreeTerms();
60
+ \`\`\`
61
+
62
+ ## 📚 Detailed Documentation
63
+ For the complete API reference, advanced configuration, and comprehensive examples, always refer to the full documentation:
64
+ - **Location**: \`node_modules/@ph-cms/client-sdk/README.md\`
65
+
66
+ If you need specific details about a module (e.g., \`ContentModule\`, \`AuthModule\`), read that file to ensure correct parameter usage.
67
+
68
+ ## ⚠️ Common Pitfalls
69
+ - **Manual channelUid passing**: Avoid \`useContentList({ channelUid: '...', ... })\` unless necessary. Rely on the provider.
70
+ - **Hook-less API calls**: When using \`client.content.list()\` directly, you MUST provide \`channelUid\` in the params as there is no context available.
71
+ `;
72
+
73
+ if (!fs.existsSync(skillDir)) {
74
+ fs.mkdirSync(skillDir, { recursive: true });
75
+ }
76
+
77
+ fs.writeFileSync(skillMdPath, skillContent);
78
+ console.log('✅ PH-CMS Client SDK Skill has been successfully initialized at .gemini/skills/ph-cms-client/SKILL.md');
79
+ }
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@ph-cms/client-sdk",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Unified PH-CMS Client SDK (React + Core)",
5
5
  "keywords": [],
6
6
  "license": "MIT",
7
7
  "author": "854dev",
8
8
  "type": "commonjs",
9
+ "bin": {
10
+ "ph-cms-client": "./bin/cli.js"
11
+ },
9
12
  "exports": {
10
13
  ".": {
11
14
  "types": "./dist/index.d.ts",
@@ -17,6 +20,7 @@
17
20
  "types": "dist/index.d.ts",
18
21
  "files": [
19
22
  "dist",
23
+ "bin",
20
24
  "README.md",
21
25
  "LICENSE"
22
26
  ],