@30nama/sdk 2.0.0-rc.5 → 2.0.0-rc.6

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 (31) hide show
  1. package/README.md +312 -312
  2. package/lib/generated/news/models/baseResponse.d.ts +3 -0
  3. package/lib/generated/news/models/baseResponseSEO.d.ts +10 -0
  4. package/lib/generated/news/models/baseResponseSEO.js +7 -0
  5. package/lib/generated/news/models/baseResponseSEO.js.map +1 -0
  6. package/lib/generated/news/models/index.d.ts +2 -0
  7. package/lib/generated/news/models/index.js +2 -0
  8. package/lib/generated/news/models/index.js.map +1 -1
  9. package/lib/generated/news/models/newsResponse.d.ts +4 -1
  10. package/lib/generated/news/models/newsResponseSEO.d.ts +10 -0
  11. package/lib/generated/news/models/newsResponseSEO.js +7 -0
  12. package/lib/generated/news/models/newsResponseSEO.js.map +1 -0
  13. package/lib/generated/operator/models/authGoogleCallbackRetrieve400.d.ts +11 -0
  14. package/lib/generated/operator/models/authGoogleCallbackRetrieve400.js +7 -0
  15. package/lib/generated/operator/models/authGoogleCallbackRetrieve400.js.map +1 -0
  16. package/lib/generated/operator/models/authGoogleCallbackRetrieveParams.d.ts +10 -0
  17. package/lib/generated/operator/models/authGoogleCallbackRetrieveParams.js +7 -0
  18. package/lib/generated/operator/models/authGoogleCallbackRetrieveParams.js.map +1 -0
  19. package/lib/generated/operator/models/googleAuthCallbackProperties.d.ts +17 -0
  20. package/lib/generated/operator/models/googleAuthCallbackProperties.js +7 -0
  21. package/lib/generated/operator/models/googleAuthCallbackProperties.js.map +1 -0
  22. package/lib/generated/operator/models/googleAuthCallbackResponse.d.ts +12 -0
  23. package/lib/generated/operator/models/googleAuthCallbackResponse.js +3 -0
  24. package/lib/generated/operator/models/googleAuthCallbackResponse.js.map +1 -0
  25. package/lib/generated/operator/models/systemSettingsDetailRetrieveSetting.d.ts +26 -0
  26. package/lib/generated/operator/models/systemSettingsDetailRetrieveSetting.js +30 -0
  27. package/lib/generated/operator/models/systemSettingsDetailRetrieveSetting.js.map +1 -0
  28. package/lib/services/news/index.d.ts +3 -3
  29. package/lib/services/news/index.js.map +1 -1
  30. package/lib/tsconfig.lib.tsbuildinfo +1 -1
  31. package/package.json +52 -52
package/README.md CHANGED
@@ -1,312 +1,312 @@
1
- # 30nama SDK
2
-
3
- Official TypeScript SDK for interacting with the 30nama platform's microservices.
4
-
5
- ## Features
6
-
7
- - 🎯 **Unified API** - Single SDK for all 30nama user microservices
8
- - 📱 **Frontend-First** - Designed specifically for frontend applications
9
- - 🛡️ **Type-Safe** - Full TypeScript support with auto-generated types (synced with the API)
10
- - 🔄 **Auto-Retry** - Built-in retry logic for network failures (configurable)
11
- - 🐛 **Debug Mode** - Comprehensive logging for development
12
- - 🌍 **Multi-Environment** - Support for development, staging, and production
13
- - 🔐 **Simple Auth** - Ultra-simple callback-based authentication
14
-
15
- ## Services Included
16
-
17
- - **VideoContent** - Handles video content management operations
18
- - **VideoData** - Handles video metadata and content access
19
- - **Stream** - Handles video streaming operations including link generation and streaming
20
- - **Operator** - Handles user authentication, profile management, and user operations
21
- - **Comment** - Handles user comments and questions on video content, biography, and news
22
- - **Biography** - Handles user and celebrity profiles
23
- - **News** - Handles news and articles management with SEO and search capabilities
24
- - **Supporter** - Handles user support, accessibility management, and system content viewing
25
- - **Notification** - Handles user notifications and settings
26
-
27
- ## Installation
28
-
29
- ```bash
30
- npm install @30nama/sdk
31
- # or
32
- yarn add @30nama/sdk
33
- # or
34
- pnpm add @30nama/sdk
35
- ```
36
-
37
- ## Quick Start
38
-
39
- ```typescript
40
- import { ThirtyNamaSDK } from '@30nama/sdk'
41
-
42
- // Initialize the SDK
43
- const sdk = new ThirtyNamaSDK({
44
- environment: 'production',
45
- debug: true
46
- })
47
-
48
- // Set up authentication with callback
49
- sdk.setTokenStorageCallback(() => {
50
- return localStorage.getItem('access_token')
51
- })
52
-
53
- // Use the services
54
- const videos = await sdk.videoContent.getUserContents({
55
- limit: 10,
56
- order_by: 'newest'
57
- })
58
-
59
- const streamLink = await sdk.stream.generateStreamLink({
60
- video_content_id: 123
61
- })
62
-
63
- const comments = await sdk.comment.getComments({
64
- content_id: 123,
65
- content_type: 'VIDEO'
66
- })
67
- ```
68
-
69
- ## Configuration
70
-
71
- ### SDK Configuration Options
72
-
73
- ```typescript
74
- interface SDKConfig {
75
- environment: 'staging' | 'production'
76
- debug?: boolean
77
- timeout?: number
78
- retries?: number
79
- }
80
- ```
81
-
82
- ## Authentication
83
-
84
- The SDK uses a simple callback-based authentication system. You provide a function that returns the authentication token when needed.
85
-
86
- ### Token Callback Authentication
87
-
88
- ```typescript
89
- // Set up dynamic token retrieval
90
- sdk.setTokenStorageCallback(() => {
91
- // Return token from your preferred storage
92
- return localStorage.getItem('userToken')
93
- })
94
-
95
- // For async token retrieval
96
- sdk.setTokenStorageCallback(async () => {
97
- // Return token from async source
98
- return await getTokenFromSecureStorage()
99
- })
100
-
101
- // Clear authentication
102
- sdk.clearTokens()
103
- ```
104
-
105
- ## Service Usage Examples
106
-
107
- ### Video Content Service
108
-
109
- ```typescript
110
- // Get user content list with filtering
111
- const content = await sdk.videoContent.getUserContents({
112
- category_slug: 'action',
113
- order_by: 'popularity',
114
- limit: 20
115
- })
116
-
117
- // Search content
118
- const searchResults = await sdk.videoContent.searchContents('batman', {
119
- type: 'movies',
120
- limit: 10
121
- })
122
-
123
- // Get content details
124
- const details = await sdk.videoContent.getContentDetails(123)
125
- ```
126
-
127
- ### Stream Service
128
-
129
- ```typescript
130
- // Generate streaming link
131
- const streamData = await sdk.stream.generateStreamLink({
132
- video_content_id: 123,
133
- season_number: 1,
134
- episode_number: 5
135
- })
136
-
137
- // Save viewing progress
138
- await sdk.stream.saveStreamLog({
139
- video_content_id: 123,
140
- elapsed_time: 1800, // 30 minutes
141
- total_duration: 3600 // 1 hour
142
- })
143
-
144
- // Get watch history
145
- const history = await sdk.stream.getWatchHistory({
146
- limit: 20
147
- })
148
- ```
149
-
150
- ### Comment Service
151
-
152
- ```typescript
153
- // Add a comment
154
- await sdk.comment.addComment({
155
- content_id: 123,
156
- content_type: 'VIDEO',
157
- text: 'Great movie!',
158
- is_spoil: false
159
- })
160
-
161
- // Get comments for content
162
- const comments = await sdk.comment.getComments({
163
- content_id: 123,
164
- content_type: 'VIDEO',
165
- page: 1,
166
- limit: 20
167
- })
168
-
169
- // Like a comment
170
- await sdk.comment.likeDislikeComment('comment-id', 'like')
171
- ```
172
-
173
- ### News Service
174
-
175
- ```typescript
176
- // Get latest news
177
- const news = await sdk.news.getLatestNews(10)
178
-
179
- // Get news by category
180
- const categoryNews = await sdk.news.getNewsByCategory(5, {
181
- page: 1,
182
- limit: 15
183
- })
184
-
185
- // Search news
186
- const searchResults = await sdk.news.searchNews('movie review', {
187
- category_id: 1,
188
- limit: 10
189
- })
190
- ```
191
-
192
- ## Error Handling
193
-
194
- The SDK provides comprehensive error handling with specific error types:
195
-
196
- ```typescript
197
- import { SDKError } from '@30nama/sdk'
198
-
199
- try {
200
- const data = await sdk.videoContent.getUserContents()
201
- } catch (error) {
202
- if (error instanceof SDKError) {
203
- switch (error.type) {
204
- case 'AuthenticationError':
205
- // Handle authentication errors
206
- console.log('Please sign in again')
207
- break
208
- case 'NetworkError':
209
- // Handle network errors
210
- console.log('Check your internet connection')
211
- break
212
- case 'ValidationError':
213
- // Handle validation errors
214
- console.log('Invalid request data')
215
- break
216
- default:
217
- console.log('An error occurred:', error.message)
218
- }
219
- }
220
- }
221
- ```
222
-
223
- ## Advanced Usage
224
-
225
- ### Custom Service Configuration
226
-
227
- ```typescript
228
- // Update SDK configuration
229
- sdk.updateConfig({
230
- timeout: 60000,
231
- retries: 5,
232
- debug: true
233
- })
234
-
235
- // Change environment
236
- sdk.setEnvironment('staging')
237
- ```
238
-
239
- ### Health Monitoring
240
-
241
- ```typescript
242
- // Check services health
243
- const health = await sdk.checkHealth()
244
- console.log('Services Health:', health)
245
- ```
246
-
247
- ### Debug Mode
248
-
249
- Enable debug mode for detailed logging:
250
-
251
- ```typescript
252
- const sdk = new ThirtyNamaSDK({
253
- environment: 'staging',
254
- debug: true // Enable debug logging
255
- })
256
- ```
257
-
258
- ### Authentication Status
259
-
260
- Check authentication status for debugging:
261
-
262
- ```typescript
263
- // Get auth status for a specific service
264
- const authStatus = await sdk.videoContent.getAuthStatus()
265
- console.log('Auth Status:', authStatus)
266
- // Output: { hasAuth: true, service: "VideoContent" }
267
-
268
- // Get detailed auth information
269
- const detailedStatus = sdk.authManager.getAuthStatus()
270
- console.log('Detailed Status:', detailedStatus)
271
- // Output: { hasCallback: true }
272
- ```
273
-
274
- ### Testing
275
-
276
- The SDK is designed to work seamlessly with your testing framework. You can mock the SDK services for unit testing:
277
-
278
- ```typescript
279
- // Mock example for Jest
280
- jest.mock('@30nama/sdk', () => ({
281
- ThirtyNamaSDK: jest.fn().mockImplementation(() => ({
282
- videoContent: {
283
- getUserContents: jest.fn().mockResolvedValue({ items: [], count: 0 })
284
- }
285
- }))
286
- }))
287
- ```
288
-
289
- ## License
290
-
291
- This project is licensed under the ISC License.
292
-
293
- ## Support
294
-
295
- For support and questions:
296
-
297
- - Create an issue on GitHub
298
- - Check the documentation
299
- - Contact us through the official website
300
-
301
- ## Changelog
302
-
303
- ### What's new?
304
-
305
- - Ultra-simplified authentication system
306
- - Callback-based token management only
307
- - Complete rewrite with TypeScript
308
- - Unified SDK for all microservices
309
- - Enhanced error handling and retry logic
310
- - Full type safety with auto-generated types
311
- - Debug mode and health monitoring
312
- - Comprehensive documentation
1
+ # 30nama SDK
2
+
3
+ Official TypeScript SDK for interacting with the 30nama platform's microservices.
4
+
5
+ ## Features
6
+
7
+ - 🎯 **Unified API** - Single SDK for all 30nama user microservices
8
+ - 📱 **Frontend-First** - Designed specifically for frontend applications
9
+ - 🛡️ **Type-Safe** - Full TypeScript support with auto-generated types (synced with the API)
10
+ - 🔄 **Auto-Retry** - Built-in retry logic for network failures (configurable)
11
+ - 🐛 **Debug Mode** - Comprehensive logging for development
12
+ - 🌍 **Multi-Environment** - Support for development, staging, and production
13
+ - 🔐 **Simple Auth** - Ultra-simple callback-based authentication
14
+
15
+ ## Services Included
16
+
17
+ - **VideoContent** - Handles video content management operations
18
+ - **VideoData** - Handles video metadata and content access
19
+ - **Stream** - Handles video streaming operations including link generation and streaming
20
+ - **Operator** - Handles user authentication, profile management, and user operations
21
+ - **Comment** - Handles user comments and questions on video content, biography, and news
22
+ - **Biography** - Handles user and celebrity profiles
23
+ - **News** - Handles news and articles management with SEO and search capabilities
24
+ - **Supporter** - Handles user support, accessibility management, and system content viewing
25
+ - **Notification** - Handles user notifications and settings
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @30nama/sdk
31
+ # or
32
+ yarn add @30nama/sdk
33
+ # or
34
+ pnpm add @30nama/sdk
35
+ ```
36
+
37
+ ## Quick Start
38
+
39
+ ```typescript
40
+ import { ThirtyNamaSDK } from '@30nama/sdk'
41
+
42
+ // Initialize the SDK
43
+ const sdk = new ThirtyNamaSDK({
44
+ environment: 'production',
45
+ debug: true
46
+ })
47
+
48
+ // Set up authentication with callback
49
+ sdk.setTokenStorageCallback(() => {
50
+ return localStorage.getItem('access_token')
51
+ })
52
+
53
+ // Use the services
54
+ const videos = await sdk.videoContent.getUserContents({
55
+ limit: 10,
56
+ order_by: 'newest'
57
+ })
58
+
59
+ const streamLink = await sdk.stream.generateStreamLink({
60
+ video_content_id: 123
61
+ })
62
+
63
+ const comments = await sdk.comment.getComments({
64
+ content_id: 123,
65
+ content_type: 'VIDEO'
66
+ })
67
+ ```
68
+
69
+ ## Configuration
70
+
71
+ ### SDK Configuration Options
72
+
73
+ ```typescript
74
+ interface SDKConfig {
75
+ environment: 'staging' | 'production'
76
+ debug?: boolean
77
+ timeout?: number
78
+ retries?: number
79
+ }
80
+ ```
81
+
82
+ ## Authentication
83
+
84
+ The SDK uses a simple callback-based authentication system. You provide a function that returns the authentication token when needed.
85
+
86
+ ### Token Callback Authentication
87
+
88
+ ```typescript
89
+ // Set up dynamic token retrieval
90
+ sdk.setTokenStorageCallback(() => {
91
+ // Return token from your preferred storage
92
+ return localStorage.getItem('userToken')
93
+ })
94
+
95
+ // For async token retrieval
96
+ sdk.setTokenStorageCallback(async () => {
97
+ // Return token from async source
98
+ return await getTokenFromSecureStorage()
99
+ })
100
+
101
+ // Clear authentication
102
+ sdk.clearTokens()
103
+ ```
104
+
105
+ ## Service Usage Examples
106
+
107
+ ### Video Content Service
108
+
109
+ ```typescript
110
+ // Get user content list with filtering
111
+ const content = await sdk.videoContent.getUserContents({
112
+ category_slug: 'action',
113
+ order_by: 'popularity',
114
+ limit: 20
115
+ })
116
+
117
+ // Search content
118
+ const searchResults = await sdk.videoContent.searchContents('batman', {
119
+ type: 'movies',
120
+ limit: 10
121
+ })
122
+
123
+ // Get content details
124
+ const details = await sdk.videoContent.getContentDetails(123)
125
+ ```
126
+
127
+ ### Stream Service
128
+
129
+ ```typescript
130
+ // Generate streaming link
131
+ const streamData = await sdk.stream.generateStreamLink({
132
+ video_content_id: 123,
133
+ season_number: 1,
134
+ episode_number: 5
135
+ })
136
+
137
+ // Save viewing progress
138
+ await sdk.stream.saveStreamLog({
139
+ video_content_id: 123,
140
+ elapsed_time: 1800, // 30 minutes
141
+ total_duration: 3600 // 1 hour
142
+ })
143
+
144
+ // Get watch history
145
+ const history = await sdk.stream.getWatchHistory({
146
+ limit: 20
147
+ })
148
+ ```
149
+
150
+ ### Comment Service
151
+
152
+ ```typescript
153
+ // Add a comment
154
+ await sdk.comment.addComment({
155
+ content_id: 123,
156
+ content_type: 'VIDEO',
157
+ text: 'Great movie!',
158
+ is_spoil: false
159
+ })
160
+
161
+ // Get comments for content
162
+ const comments = await sdk.comment.getComments({
163
+ content_id: 123,
164
+ content_type: 'VIDEO',
165
+ page: 1,
166
+ limit: 20
167
+ })
168
+
169
+ // Like a comment
170
+ await sdk.comment.likeDislikeComment('comment-id', 'like')
171
+ ```
172
+
173
+ ### News Service
174
+
175
+ ```typescript
176
+ // Get latest news
177
+ const news = await sdk.news.getLatestNews(10)
178
+
179
+ // Get news by category
180
+ const categoryNews = await sdk.news.getNewsByCategory(5, {
181
+ page: 1,
182
+ limit: 15
183
+ })
184
+
185
+ // Search news
186
+ const searchResults = await sdk.news.searchNews('movie review', {
187
+ category_id: 1,
188
+ limit: 10
189
+ })
190
+ ```
191
+
192
+ ## Error Handling
193
+
194
+ The SDK provides comprehensive error handling with specific error types:
195
+
196
+ ```typescript
197
+ import { SDKError } from '@30nama/sdk'
198
+
199
+ try {
200
+ const data = await sdk.videoContent.getUserContents()
201
+ } catch (error) {
202
+ if (error instanceof SDKError) {
203
+ switch (error.type) {
204
+ case 'AuthenticationError':
205
+ // Handle authentication errors
206
+ console.log('Please sign in again')
207
+ break
208
+ case 'NetworkError':
209
+ // Handle network errors
210
+ console.log('Check your internet connection')
211
+ break
212
+ case 'ValidationError':
213
+ // Handle validation errors
214
+ console.log('Invalid request data')
215
+ break
216
+ default:
217
+ console.log('An error occurred:', error.message)
218
+ }
219
+ }
220
+ }
221
+ ```
222
+
223
+ ## Advanced Usage
224
+
225
+ ### Custom Service Configuration
226
+
227
+ ```typescript
228
+ // Update SDK configuration
229
+ sdk.updateConfig({
230
+ timeout: 60000,
231
+ retries: 5,
232
+ debug: true
233
+ })
234
+
235
+ // Change environment
236
+ sdk.setEnvironment('staging')
237
+ ```
238
+
239
+ ### Health Monitoring
240
+
241
+ ```typescript
242
+ // Check services health
243
+ const health = await sdk.checkHealth()
244
+ console.log('Services Health:', health)
245
+ ```
246
+
247
+ ### Debug Mode
248
+
249
+ Enable debug mode for detailed logging:
250
+
251
+ ```typescript
252
+ const sdk = new ThirtyNamaSDK({
253
+ environment: 'staging',
254
+ debug: true // Enable debug logging
255
+ })
256
+ ```
257
+
258
+ ### Authentication Status
259
+
260
+ Check authentication status for debugging:
261
+
262
+ ```typescript
263
+ // Get auth status for a specific service
264
+ const authStatus = await sdk.videoContent.getAuthStatus()
265
+ console.log('Auth Status:', authStatus)
266
+ // Output: { hasAuth: true, service: "VideoContent" }
267
+
268
+ // Get detailed auth information
269
+ const detailedStatus = sdk.authManager.getAuthStatus()
270
+ console.log('Detailed Status:', detailedStatus)
271
+ // Output: { hasCallback: true }
272
+ ```
273
+
274
+ ### Testing
275
+
276
+ The SDK is designed to work seamlessly with your testing framework. You can mock the SDK services for unit testing:
277
+
278
+ ```typescript
279
+ // Mock example for Jest
280
+ jest.mock('@30nama/sdk', () => ({
281
+ ThirtyNamaSDK: jest.fn().mockImplementation(() => ({
282
+ videoContent: {
283
+ getUserContents: jest.fn().mockResolvedValue({ items: [], count: 0 })
284
+ }
285
+ }))
286
+ }))
287
+ ```
288
+
289
+ ## License
290
+
291
+ This project is licensed under the ISC License.
292
+
293
+ ## Support
294
+
295
+ For support and questions:
296
+
297
+ - Create an issue on GitHub
298
+ - Check the documentation
299
+ - Contact us through the official website
300
+
301
+ ## Changelog
302
+
303
+ ### What's new?
304
+
305
+ - Ultra-simplified authentication system
306
+ - Callback-based token management only
307
+ - Complete rewrite with TypeScript
308
+ - Unified SDK for all microservices
309
+ - Enhanced error handling and retry logic
310
+ - Full type safety with auto-generated types
311
+ - Debug mode and health monitoring
312
+ - Comprehensive documentation
@@ -2,9 +2,12 @@
2
2
  * 30nama-SDK 🍺
3
3
  * Do not edit manually.
4
4
  */
5
+ import type { BaseResponseSEO } from './baseResponseSEO';
5
6
  import type { BaseResponseData } from './baseResponseData';
6
7
  import type { BaseResponseErrors } from './baseResponseErrors';
7
8
  export interface BaseResponse {
9
+ /** @nullable */
10
+ SEO?: BaseResponseSEO;
8
11
  /** @nullable */
9
12
  readonly data: BaseResponseData;
10
13
  /** @nullable */
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 30nama-SDK 🍺
3
+ * Do not edit manually.
4
+ */
5
+ /**
6
+ * @nullable
7
+ */
8
+ export type BaseResponseSEO = {
9
+ [key: string]: unknown;
10
+ } | null;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * 30nama-SDK 🍺
4
+ * Do not edit manually.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=baseResponseSEO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseResponseSEO.js","sourceRoot":"","sources":["../../../../src/generated/news/models/baseResponseSEO.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -5,6 +5,7 @@
5
5
  export * from './baseResponse';
6
6
  export * from './baseResponseData';
7
7
  export * from './baseResponseErrors';
8
+ export * from './baseResponseSEO';
8
9
  export * from './category';
9
10
  export * from './categoryTranslate';
10
11
  export * from './createCategory';
@@ -93,6 +94,7 @@ export * from './newsRemoveBookmarkDestroy404';
93
94
  export * from './newsRemoveBookmarkDestroyParams';
94
95
  export * from './newsResponse';
95
96
  export * from './newsResponseErrors';
97
+ export * from './newsResponseSEO';
96
98
  export * from './newsSearchRetrieve200';
97
99
  export * from './newsSearchRetrieve404';
98
100
  export * from './newsSearchRetrieveParams';