polyv-live-api-sdk 1.0.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/dist/auth/index.d.ts +9 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/signature.d.ts +67 -0
- package/dist/auth/signature.d.ts.map +1 -0
- package/dist/client.d.ts +209 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/constants/error-codes.d.ts +134 -0
- package/dist/constants/error-codes.d.ts.map +1 -0
- package/dist/constants/index.d.ts +8 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/errors/index.d.ts +11 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/polyv-api-error.d.ts +71 -0
- package/dist/errors/polyv-api-error.d.ts.map +1 -0
- package/dist/errors/polyv-error.d.ts +31 -0
- package/dist/errors/polyv-error.d.ts.map +1 -0
- package/dist/errors/polyv-validation-error.d.ts +72 -0
- package/dist/errors/polyv-validation-error.d.ts.map +1 -0
- package/dist/errors/type-guards.d.ts +19 -0
- package/dist/errors/type-guards.d.ts.map +1 -0
- package/dist/errors/types.d.ts +13 -0
- package/dist/errors/types.d.ts.map +1 -0
- package/dist/index.cjs +15295 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +19501 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15258 -0
- package/dist/index.js.map +1 -0
- package/dist/services/account.service.d.ts +402 -0
- package/dist/services/account.service.d.ts.map +1 -0
- package/dist/services/channel.service.d.ts +2033 -0
- package/dist/services/channel.service.d.ts.map +1 -0
- package/dist/services/chat.service.d.ts +592 -0
- package/dist/services/chat.service.d.ts.map +1 -0
- package/dist/services/finance.service.d.ts +160 -0
- package/dist/services/finance.service.d.ts.map +1 -0
- package/dist/services/group.service.d.ts +191 -0
- package/dist/services/group.service.d.ts.map +1 -0
- package/dist/services/index.d.ts +27 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/live-interaction.service.d.ts +474 -0
- package/dist/services/live-interaction.service.d.ts.map +1 -0
- package/dist/services/other.service.d.ts +687 -0
- package/dist/services/other.service.d.ts.map +1 -0
- package/dist/services/platform.service.d.ts +190 -0
- package/dist/services/platform.service.d.ts.map +1 -0
- package/dist/services/player.service.d.ts +195 -0
- package/dist/services/player.service.d.ts.map +1 -0
- package/dist/services/v4/ai.service.d.ts +205 -0
- package/dist/services/v4/ai.service.d.ts.map +1 -0
- package/dist/services/v4/channel.service.d.ts +854 -0
- package/dist/services/v4/channel.service.d.ts.map +1 -0
- package/dist/services/v4/chat.service.d.ts +199 -0
- package/dist/services/v4/chat.service.d.ts.map +1 -0
- package/dist/services/v4/global.service.d.ts +86 -0
- package/dist/services/v4/global.service.d.ts.map +1 -0
- package/dist/services/v4/group.service.d.ts +132 -0
- package/dist/services/v4/group.service.d.ts.map +1 -0
- package/dist/services/v4/material.service.d.ts +85 -0
- package/dist/services/v4/material.service.d.ts.map +1 -0
- package/dist/services/v4/platform.service.d.ts +148 -0
- package/dist/services/v4/platform.service.d.ts.map +1 -0
- package/dist/services/v4/robot.service.d.ts +144 -0
- package/dist/services/v4/robot.service.d.ts.map +1 -0
- package/dist/services/v4/statistics.service.d.ts +61 -0
- package/dist/services/v4/statistics.service.d.ts.map +1 -0
- package/dist/services/v4/user.service.d.ts +1014 -0
- package/dist/services/v4/user.service.d.ts.map +1 -0
- package/dist/services/v4/webapp.service.d.ts +131 -0
- package/dist/services/v4/webapp.service.d.ts.map +1 -0
- package/dist/services/web.service.d.ts +758 -0
- package/dist/services/web.service.d.ts.map +1 -0
- package/dist/types/account.d.ts +287 -0
- package/dist/types/account.d.ts.map +1 -0
- package/dist/types/auth.d.ts +31 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/callback.d.ts +156 -0
- package/dist/types/callback.d.ts.map +1 -0
- package/dist/types/channel.d.ts +2263 -0
- package/dist/types/channel.d.ts.map +1 -0
- package/dist/types/chat-banned.d.ts +366 -0
- package/dist/types/chat-banned.d.ts.map +1 -0
- package/dist/types/chat-censor-role.d.ts +190 -0
- package/dist/types/chat-censor-role.d.ts.map +1 -0
- package/dist/types/chat.d.ts +142 -0
- package/dist/types/chat.d.ts.map +1 -0
- package/dist/types/client.d.ts +43 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/common.d.ts +52 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/finance.d.ts +252 -0
- package/dist/types/finance.d.ts.map +1 -0
- package/dist/types/group.d.ts +129 -0
- package/dist/types/group.d.ts.map +1 -0
- package/dist/types/index.d.ts +50 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/live-interaction.d.ts +301 -0
- package/dist/types/live-interaction.d.ts.map +1 -0
- package/dist/types/pagination.d.ts +37 -0
- package/dist/types/pagination.d.ts.map +1 -0
- package/dist/types/platform.d.ts +178 -0
- package/dist/types/platform.d.ts.map +1 -0
- package/dist/types/player.d.ts +177 -0
- package/dist/types/player.d.ts.map +1 -0
- package/dist/types/request.d.ts +45 -0
- package/dist/types/request.d.ts.map +1 -0
- package/dist/types/response.d.ts +58 -0
- package/dist/types/response.d.ts.map +1 -0
- package/dist/types/signature.d.ts +50 -0
- package/dist/types/signature.d.ts.map +1 -0
- package/dist/types/upload.d.ts +32 -0
- package/dist/types/upload.d.ts.map +1 -0
- package/dist/types/v4-ai.d.ts +379 -0
- package/dist/types/v4-ai.d.ts.map +1 -0
- package/dist/types/v4-channel.d.ts +2400 -0
- package/dist/types/v4-channel.d.ts.map +1 -0
- package/dist/types/v4-chat.d.ts +190 -0
- package/dist/types/v4-chat.d.ts.map +1 -0
- package/dist/types/v4-global.d.ts +150 -0
- package/dist/types/v4-global.d.ts.map +1 -0
- package/dist/types/v4-group.d.ts +212 -0
- package/dist/types/v4-group.d.ts.map +1 -0
- package/dist/types/v4-material.d.ts +141 -0
- package/dist/types/v4-material.d.ts.map +1 -0
- package/dist/types/v4-platform.d.ts +223 -0
- package/dist/types/v4-platform.d.ts.map +1 -0
- package/dist/types/v4-robot.d.ts +149 -0
- package/dist/types/v4-robot.d.ts.map +1 -0
- package/dist/types/v4-statistics.d.ts +87 -0
- package/dist/types/v4-statistics.d.ts.map +1 -0
- package/dist/types/v4-user.d.ts +1021 -0
- package/dist/types/v4-user.d.ts.map +1 -0
- package/dist/types/v4-webapp.d.ts +161 -0
- package/dist/types/v4-webapp.d.ts.map +1 -0
- package/dist/types/version.d.ts +21 -0
- package/dist/types/version.d.ts.map +1 -0
- package/dist/types/web.d.ts +868 -0
- package/dist/types/web.d.ts.map +1 -0
- package/dist/utils/env.d.ts +54 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/pagination.d.ts +62 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/signature.d.ts +67 -0
- package/dist/utils/signature.d.ts.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,eAAe,GAChB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature Generation Module
|
|
3
|
+
*
|
|
4
|
+
* Provides MD5 and SHA256 signature generation for PolyV API authentication.
|
|
5
|
+
* Supports both Node.js (native crypto) and browser (crypto-js) environments.
|
|
6
|
+
*
|
|
7
|
+
* @module auth/signature
|
|
8
|
+
*/
|
|
9
|
+
import { SignatureMethod } from '../types/signature.js';
|
|
10
|
+
import type { SignatureOutput, SignatureInput } from '../types/signature.js';
|
|
11
|
+
import type { SignatureConfig } from '../types/auth.js';
|
|
12
|
+
/**
|
|
13
|
+
* Generate signature for PolyV API authentication
|
|
14
|
+
*
|
|
15
|
+
* The signature algorithm:
|
|
16
|
+
* 1. Filter out null/undefined parameter values
|
|
17
|
+
* 2. Sort remaining parameters by key (ASCII order)
|
|
18
|
+
* 3. Concatenate as key1value1key2value2...
|
|
19
|
+
* 4. Prepend and append appSecret
|
|
20
|
+
* 5. Compute MD5 or SHA256 hash (uppercase hex)
|
|
21
|
+
*
|
|
22
|
+
* @param params Parameters to sign (includes appId, timestamp, and optional business params)
|
|
23
|
+
* @param config Signature configuration with appSecret and optional method
|
|
24
|
+
* @returns Signature output with sign, timestamp, and method
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const result = generateSignature(
|
|
29
|
+
* { appId: 'g4rqgmmjuo', timestamp: 1660270926732 },
|
|
30
|
+
* { appSecret: 'fsq2k5weced1h8vui657xtdva66whf0g' }
|
|
31
|
+
* );
|
|
32
|
+
* // result.sign === '0D2BDA2FD04D93A2B8832B91FD973C4D'
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateSignature(params: Record<string, unknown>, config: SignatureConfig): SignatureOutput;
|
|
36
|
+
/**
|
|
37
|
+
* Generate signature for PolyV API authentication (alternative signature)
|
|
38
|
+
*
|
|
39
|
+
* @param input Signature input with appId, timestamp, and optional params
|
|
40
|
+
* @param config Signature configuration with appSecret and optional method
|
|
41
|
+
* @returns Signature output with sign, timestamp, and method
|
|
42
|
+
*/
|
|
43
|
+
export declare function generateSignature(input: SignatureInput, config: SignatureConfig): SignatureOutput;
|
|
44
|
+
/**
|
|
45
|
+
* Generate timestamp in milliseconds
|
|
46
|
+
* @param customTimestamp Optional custom timestamp for testing
|
|
47
|
+
* @returns Current timestamp in milliseconds
|
|
48
|
+
*/
|
|
49
|
+
export declare function generateTimestamp(customTimestamp?: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Sort parameters by key name (ASCII order)
|
|
52
|
+
* @param params Parameters to sort
|
|
53
|
+
* @returns Sorted keys array
|
|
54
|
+
*/
|
|
55
|
+
export declare function sortParams(params: Record<string, unknown>): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Create signature with just appId, appSecret, and optional business params
|
|
58
|
+
* Convenience function that auto-generates timestamp
|
|
59
|
+
*
|
|
60
|
+
* @param appId PolyV App ID
|
|
61
|
+
* @param appSecret PolyV App Secret
|
|
62
|
+
* @param params Optional business parameters
|
|
63
|
+
* @param method Signature method (default: MD5)
|
|
64
|
+
* @returns Signature output
|
|
65
|
+
*/
|
|
66
|
+
export declare function createSignature(appId: string, appSecret: string, params?: Record<string, unknown>, method?: SignatureMethod): SignatureOutput;
|
|
67
|
+
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/auth/signature.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAuExD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,eAAe,GACtB,eAAe,CAAC;AAEnB;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,eAAe,GACtB,eAAe,CAAC;AA0EnB;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAIpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,CAAC,EAAE,eAAe,GACvB,eAAe,CAcjB"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PolyV Client
|
|
3
|
+
*
|
|
4
|
+
* The main client class for interacting with the PolyV Live API.
|
|
5
|
+
* Provides automatic signature injection, error handling, and request management.
|
|
6
|
+
*
|
|
7
|
+
* @module client
|
|
8
|
+
*/
|
|
9
|
+
import { type AxiosInstance, type AxiosRequestConfig } from 'axios';
|
|
10
|
+
import { ChannelService } from './services/channel.service.js';
|
|
11
|
+
import { ChatService } from './services/chat.service.js';
|
|
12
|
+
import { LiveInteractionService } from './services/live-interaction.service.js';
|
|
13
|
+
import { AccountService } from './services/account.service.js';
|
|
14
|
+
import { WebService } from './services/web.service.js';
|
|
15
|
+
import { PlatformService } from './services/platform.service.js';
|
|
16
|
+
import { FinanceService } from './services/finance.service.js';
|
|
17
|
+
import { GroupService } from './services/group.service.js';
|
|
18
|
+
import { PlayerService } from './services/player.service.js';
|
|
19
|
+
import { OtherService } from './services/other.service.js';
|
|
20
|
+
import { V4AiService } from './services/v4/ai.service.js';
|
|
21
|
+
import { V4RobotService } from './services/v4/robot.service.js';
|
|
22
|
+
import { V4ChannelService } from './services/v4/channel.service.js';
|
|
23
|
+
import { V4ChatService } from './services/v4/chat.service.js';
|
|
24
|
+
import { V4StatisticsService } from './services/v4/statistics.service.js';
|
|
25
|
+
import { V4UserService } from './services/v4/user.service.js';
|
|
26
|
+
import { V4GlobalService } from './services/v4/global.service.js';
|
|
27
|
+
import { V4GroupService } from './services/v4/group.service.js';
|
|
28
|
+
import { V4MaterialService } from './services/v4/material.service.js';
|
|
29
|
+
import { V4PlatformService } from './services/v4/platform.service.js';
|
|
30
|
+
import { V4WebAppService } from './services/v4/webapp.service.js';
|
|
31
|
+
import type { RequestOptions } from './types/request.js';
|
|
32
|
+
import type { PolyVClientConfig, ResolvedClientConfig } from './types/client.js';
|
|
33
|
+
/**
|
|
34
|
+
* PolyVClient
|
|
35
|
+
*
|
|
36
|
+
* The main client for interacting with PolyV Live API.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const client = new PolyVClient({
|
|
41
|
+
* appId: 'your-app-id',
|
|
42
|
+
* appSecret: 'your-app-secret'
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* // Make a request
|
|
46
|
+
* const channels = await client.get('/channel/list', { page: 1 });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class PolyVClient {
|
|
50
|
+
/**
|
|
51
|
+
* Resolved configuration with defaults applied
|
|
52
|
+
*/
|
|
53
|
+
readonly config: ResolvedClientConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Axios HTTP client instance
|
|
56
|
+
*/
|
|
57
|
+
readonly httpClient: AxiosInstance;
|
|
58
|
+
/**
|
|
59
|
+
* Channel service for managing live channels
|
|
60
|
+
*/
|
|
61
|
+
readonly channel: ChannelService;
|
|
62
|
+
/**
|
|
63
|
+
* Chat service for managing chat messages
|
|
64
|
+
*/
|
|
65
|
+
readonly chat: ChatService;
|
|
66
|
+
/**
|
|
67
|
+
* Live interaction service for managing interactions (lottery, questionnaire, checkin, questions)
|
|
68
|
+
*/
|
|
69
|
+
readonly liveInteraction: LiveInteractionService;
|
|
70
|
+
/**
|
|
71
|
+
* Account service for managing account operations
|
|
72
|
+
*/
|
|
73
|
+
readonly account: AccountService;
|
|
74
|
+
/**
|
|
75
|
+
* Web service for managing web page operations
|
|
76
|
+
*/
|
|
77
|
+
readonly web: WebService;
|
|
78
|
+
/**
|
|
79
|
+
* Platform service for managing platform operations
|
|
80
|
+
*/
|
|
81
|
+
readonly platform: PlatformService;
|
|
82
|
+
/**
|
|
83
|
+
* V4 AI service for managing AI and digital human operations
|
|
84
|
+
*/
|
|
85
|
+
readonly v4Ai: V4AiService;
|
|
86
|
+
/**
|
|
87
|
+
* V4 Robot service for managing robot operations
|
|
88
|
+
*/
|
|
89
|
+
readonly v4Robot: V4RobotService;
|
|
90
|
+
/**
|
|
91
|
+
* V4 Channel service for managing channel operations
|
|
92
|
+
*/
|
|
93
|
+
readonly v4Channel: V4ChannelService;
|
|
94
|
+
/**
|
|
95
|
+
* V4 Chat service for managing chat operations
|
|
96
|
+
*/
|
|
97
|
+
readonly v4Chat: V4ChatService;
|
|
98
|
+
/**
|
|
99
|
+
* V4 Statistics service for managing statistics operations
|
|
100
|
+
*/
|
|
101
|
+
readonly v4Statistics: V4StatisticsService;
|
|
102
|
+
/**
|
|
103
|
+
* V4 User service for managing user operations
|
|
104
|
+
*/
|
|
105
|
+
readonly v4User: V4UserService;
|
|
106
|
+
/**
|
|
107
|
+
* V4 Global service for managing global settings
|
|
108
|
+
*/
|
|
109
|
+
readonly v4Global: V4GlobalService;
|
|
110
|
+
/**
|
|
111
|
+
* V4 Group service for managing group operations
|
|
112
|
+
*/
|
|
113
|
+
readonly v4Group: V4GroupService;
|
|
114
|
+
/**
|
|
115
|
+
* V4 Material service for managing material library
|
|
116
|
+
*/
|
|
117
|
+
readonly v4Material: V4MaterialService;
|
|
118
|
+
/**
|
|
119
|
+
* V4 Platform service for managing coupons
|
|
120
|
+
*/
|
|
121
|
+
readonly v4Platform: V4PlatformService;
|
|
122
|
+
/**
|
|
123
|
+
* V4 WebApp service for managing permissions and roles
|
|
124
|
+
*/
|
|
125
|
+
readonly v4WebApp: V4WebAppService;
|
|
126
|
+
/**
|
|
127
|
+
* Finance service for managing audio/video moderation
|
|
128
|
+
*/
|
|
129
|
+
readonly finance: FinanceService;
|
|
130
|
+
/**
|
|
131
|
+
* Group service for managing group account resources
|
|
132
|
+
*/
|
|
133
|
+
readonly group: GroupService;
|
|
134
|
+
/**
|
|
135
|
+
* Player service for managing player settings (anti-record, adverts, logo, watch feedback)
|
|
136
|
+
*/
|
|
137
|
+
readonly player: PlayerService;
|
|
138
|
+
/**
|
|
139
|
+
* Other service for managing miscellaneous operations
|
|
140
|
+
*/
|
|
141
|
+
readonly other: OtherService;
|
|
142
|
+
/**
|
|
143
|
+
* Create a new PolyVClient instance
|
|
144
|
+
*
|
|
145
|
+
* @param config - Client configuration options
|
|
146
|
+
*/
|
|
147
|
+
constructor(config: PolyVClientConfig);
|
|
148
|
+
/**
|
|
149
|
+
* Create and configure the Axios HTTP client with interceptors
|
|
150
|
+
*/
|
|
151
|
+
private createHttpClient;
|
|
152
|
+
/**
|
|
153
|
+
* Transform Axios errors to PolyVAPIError
|
|
154
|
+
*/
|
|
155
|
+
private transformAxiosError;
|
|
156
|
+
/**
|
|
157
|
+
* Make a generic HTTP request
|
|
158
|
+
*
|
|
159
|
+
* @param config - Axios request configuration
|
|
160
|
+
* @returns Response data (extracted from API response)
|
|
161
|
+
*/
|
|
162
|
+
request<T = unknown>(config: AxiosRequestConfig & RequestOptions): Promise<T>;
|
|
163
|
+
/**
|
|
164
|
+
* Make a GET request
|
|
165
|
+
*
|
|
166
|
+
* @param url - Request URL path
|
|
167
|
+
* @param params - Query parameters
|
|
168
|
+
* @param options - Additional request options
|
|
169
|
+
* @returns Response data
|
|
170
|
+
*/
|
|
171
|
+
get<T = unknown>(url: string, params?: Record<string, unknown>, options?: RequestOptions): Promise<T>;
|
|
172
|
+
/**
|
|
173
|
+
* Make a POST request
|
|
174
|
+
*
|
|
175
|
+
* @param url - Request URL path
|
|
176
|
+
* @param data - Request body data
|
|
177
|
+
* @param options - Additional request options
|
|
178
|
+
* @returns Response data
|
|
179
|
+
*/
|
|
180
|
+
post<T = unknown>(url: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
181
|
+
/**
|
|
182
|
+
* Make a PUT request
|
|
183
|
+
*
|
|
184
|
+
* @param url - Request URL path
|
|
185
|
+
* @param data - Request body data
|
|
186
|
+
* @param options - Additional request options
|
|
187
|
+
* @returns Response data
|
|
188
|
+
*/
|
|
189
|
+
put<T = unknown>(url: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
190
|
+
/**
|
|
191
|
+
* Make a DELETE request
|
|
192
|
+
*
|
|
193
|
+
* @param url - Request URL path
|
|
194
|
+
* @param params - Query parameters
|
|
195
|
+
* @param options - Additional request options
|
|
196
|
+
* @returns Response data
|
|
197
|
+
*/
|
|
198
|
+
delete<T = unknown>(url: string, params?: Record<string, unknown>, options?: RequestOptions): Promise<T>;
|
|
199
|
+
/**
|
|
200
|
+
* Make a PATCH request
|
|
201
|
+
*
|
|
202
|
+
* @param url - Request URL path
|
|
203
|
+
* @param data - Request body data
|
|
204
|
+
* @param options - Additional request options
|
|
205
|
+
* @returns Response data
|
|
206
|
+
*/
|
|
207
|
+
patch<T = unknown>(url: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAc,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAmB,MAAM,OAAO,CAAC;AAG5F,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE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AAE,OAAO,CAAC,EAChC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;IASb;;;;;;;OAOG;IACG,IAAI,CAAC,CAAC,GAAG,OAAO,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;IAQb;;;;;;;OAOG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EACnB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;IAQb;;;;;;;OAOG;IACG,MAAM,CAAC,CAAC,GAAG,OAAO,EACtB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;IASb;;;;;;;OAOG;IACG,KAAK,CAAC,CAAC,GAAG,OAAO,EACrB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;CAOd"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PolyV Error Code Mapping
|
|
3
|
+
*
|
|
4
|
+
* This module defines error codes and their messages for the PolyV Live API.
|
|
5
|
+
* Error codes are organized by category:
|
|
6
|
+
* - Authentication (20000-20999): App ID, signature, timestamp issues
|
|
7
|
+
* - Parameter (10000-19999): Request parameter validation errors
|
|
8
|
+
* - Channel (30000-39999): Channel-related errors
|
|
9
|
+
* - Permission (40000-49999): Authorization and account issues
|
|
10
|
+
* - Service (50000-59999): Server-side errors
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* PolyV API Error Code Enumeration
|
|
14
|
+
*
|
|
15
|
+
* Each error code corresponds to a specific error condition returned by the PolyV API.
|
|
16
|
+
*/
|
|
17
|
+
export declare enum PolyVErrorCode {
|
|
18
|
+
/** Invalid or non-existent appId */
|
|
19
|
+
INVALID_APP_ID = 20001,
|
|
20
|
+
/** Signature verification failed */
|
|
21
|
+
INVALID_SIGNATURE = 20002,
|
|
22
|
+
/** Request timestamp has expired (3 minute window) */
|
|
23
|
+
TIMESTAMP_EXPIRED = 20003,
|
|
24
|
+
/** Duplicate request detected (signatureNonce reuse) */
|
|
25
|
+
DUPLICATE_REQUEST = 20004,
|
|
26
|
+
/** Unsupported signature method */
|
|
27
|
+
INVALID_SIGNATURE_METHOD = 20005,
|
|
28
|
+
/** General parameter error */
|
|
29
|
+
INVALID_PARAMETER = 10001,
|
|
30
|
+
/** Required parameter is missing */
|
|
31
|
+
MISSING_REQUIRED_PARAMETER = 10002,
|
|
32
|
+
/** Parameter format is invalid */
|
|
33
|
+
INVALID_PARAMETER_FORMAT = 10003,
|
|
34
|
+
/** Channel does not exist */
|
|
35
|
+
CHANNEL_NOT_FOUND = 30001,
|
|
36
|
+
/** Channel has been disabled */
|
|
37
|
+
CHANNEL_DISABLED = 30002,
|
|
38
|
+
/** Channel has expired */
|
|
39
|
+
CHANNEL_EXPIRED = 30003,
|
|
40
|
+
/** Channel count limit exceeded */
|
|
41
|
+
CHANNEL_LIMIT_EXCEEDED = 30004,
|
|
42
|
+
/** Permission denied */
|
|
43
|
+
PERMISSION_DENIED = 40001,
|
|
44
|
+
/** Account balance insufficient */
|
|
45
|
+
INSUFFICIENT_BALANCE = 40002,
|
|
46
|
+
/** Feature not enabled for account */
|
|
47
|
+
FEATURE_NOT_ENABLED = 40003,
|
|
48
|
+
/** Internal server error */
|
|
49
|
+
INTERNAL_ERROR = 50001,
|
|
50
|
+
/** Service temporarily unavailable */
|
|
51
|
+
SERVICE_UNAVAILABLE = 50002,
|
|
52
|
+
/** Request timeout */
|
|
53
|
+
REQUEST_TIMEOUT = 50003
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Error message mapping for each error code
|
|
57
|
+
*/
|
|
58
|
+
export declare const ERROR_MESSAGES: Record<PolyVErrorCode, string>;
|
|
59
|
+
/**
|
|
60
|
+
* Error category definition
|
|
61
|
+
*/
|
|
62
|
+
export interface ErrorCategory {
|
|
63
|
+
/** Category name in Chinese */
|
|
64
|
+
name: string;
|
|
65
|
+
/** Error code range for this category */
|
|
66
|
+
range: {
|
|
67
|
+
min: number;
|
|
68
|
+
max: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Error categories organized by code range
|
|
73
|
+
*/
|
|
74
|
+
export declare const ERROR_CATEGORIES: Record<string, ErrorCategory>;
|
|
75
|
+
/**
|
|
76
|
+
* Valid error category names
|
|
77
|
+
*/
|
|
78
|
+
export type ErrorCategoryName = keyof typeof ERROR_CATEGORIES;
|
|
79
|
+
/**
|
|
80
|
+
* Get the error message for a specific error code
|
|
81
|
+
*
|
|
82
|
+
* @param code - The PolyV error code
|
|
83
|
+
* @returns The corresponding error message in Chinese
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const message = getErrorMessage(PolyVErrorCode.INVALID_APP_ID);
|
|
88
|
+
* // Returns: '无效的 appId'
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function getErrorMessage(code: PolyVErrorCode): string;
|
|
92
|
+
/**
|
|
93
|
+
* Check if a number is a valid PolyV error code
|
|
94
|
+
*
|
|
95
|
+
* @param code - The number to check
|
|
96
|
+
* @returns True if the code is a valid PolyV error code
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* isPolyVErrorCode(20001); // true
|
|
101
|
+
* isPolyVErrorCode(99999); // false
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function isPolyVErrorCode(code: number): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Get error message by error code number with optional default message
|
|
107
|
+
*
|
|
108
|
+
* @param code - The error code number
|
|
109
|
+
* @param defaultMessage - Optional default message for unknown codes
|
|
110
|
+
* @returns The error message or default message
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* getErrorMessageByCode(20001); // '无效的 appId'
|
|
115
|
+
* getErrorMessageByCode(99999); // '未知错误'
|
|
116
|
+
* getErrorMessageByCode(99999, '自定义错误'); // '自定义错误'
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function getErrorMessageByCode(code: number, defaultMessage?: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* Get the error category for a given error code
|
|
122
|
+
*
|
|
123
|
+
* @param code - The error code number
|
|
124
|
+
* @returns The category name or 'UNKNOWN' if not in any category range
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* getErrorCodeCategory(20001); // 'AUTH'
|
|
129
|
+
* getErrorCodeCategory(30001); // 'CHANNEL'
|
|
130
|
+
* getErrorCodeCategory(999); // 'UNKNOWN'
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function getErrorCodeCategory(code: number): string;
|
|
134
|
+
//# sourceMappingURL=error-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/constants/error-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,oBAAY,cAAc;IAExB,oCAAoC;IACpC,cAAc,QAAQ;IACtB,oCAAoC;IACpC,iBAAiB,QAAQ;IACzB,sDAAsD;IACtD,iBAAiB,QAAQ;IACzB,wDAAwD;IACxD,iBAAiB,QAAQ;IACzB,mCAAmC;IACnC,wBAAwB,QAAQ;IAGhC,8BAA8B;IAC9B,iBAAiB,QAAQ;IACzB,oCAAoC;IACpC,0BAA0B,QAAQ;IAClC,kCAAkC;IAClC,wBAAwB,QAAQ;IAGhC,6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K Constants Module
|
|
3
|
+
*
|
|
4
|
+
* This module exports all constants, enumerations, and helper functions
|
|
5
|
+
* for error codes and other configuration values.
|
|
6
|
+
*/
|
|
7
|
+
export { PolyVErrorCode, ERROR_MESSAGES, ERROR_CATEGORIES, getErrorMessage, isPolyVErrorCode, getErrorMessageByCode, getErrorCodeCategory, type ErrorCategory, type ErrorCategoryName, } from './error-codes.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PolyV SDK Error Classes
|
|
3
|
+
*
|
|
4
|
+
* This module exports all error classes and type guards for consistent error handling.
|
|
5
|
+
*/
|
|
6
|
+
export { PolyVError } from './polyv-error.js';
|
|
7
|
+
export { PolyVAPIError } from './polyv-api-error.js';
|
|
8
|
+
export { PolyVValidationError } from './polyv-validation-error.js';
|
|
9
|
+
export { isPolyVError, isPolyVAPIError, isPolyVValidationError } from './type-guards.js';
|
|
10
|
+
export type { PolyVErrorOptions, PolyVAPIErrorOptions, PolyVAPIErrorResponse, ValidationConstraints, } from './types.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAGzF,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PolyV API Error Class
|
|
3
|
+
*
|
|
4
|
+
* Represents errors returned from the PolyV API.
|
|
5
|
+
* Contains PolyV-specific error codes and messages.
|
|
6
|
+
*/
|
|
7
|
+
import { PolyVError } from './polyv-error.js';
|
|
8
|
+
/**
|
|
9
|
+
* Options for creating a PolyVAPIError
|
|
10
|
+
*/
|
|
11
|
+
export interface PolyVAPIErrorOptions {
|
|
12
|
+
polyvCode?: number;
|
|
13
|
+
polyvMessage?: string;
|
|
14
|
+
code?: string;
|
|
15
|
+
details?: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* PolyV API response structure for error handling
|
|
19
|
+
*/
|
|
20
|
+
export interface PolyVAPIErrorResponse {
|
|
21
|
+
code: number;
|
|
22
|
+
status: string;
|
|
23
|
+
message: string;
|
|
24
|
+
data?: {
|
|
25
|
+
polyvCode?: number;
|
|
26
|
+
polyvMessage?: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare class PolyVAPIError extends PolyVError {
|
|
30
|
+
/**
|
|
31
|
+
* HTTP status code from the API response
|
|
32
|
+
*/
|
|
33
|
+
readonly statusCode: number;
|
|
34
|
+
/**
|
|
35
|
+
* PolyV-specific error code
|
|
36
|
+
*/
|
|
37
|
+
readonly polyvCode?: number;
|
|
38
|
+
/**
|
|
39
|
+
* PolyV-specific error message
|
|
40
|
+
*/
|
|
41
|
+
readonly polyvMessage?: string;
|
|
42
|
+
constructor(message: string, statusCode: number, options?: PolyVAPIErrorOptions);
|
|
43
|
+
/**
|
|
44
|
+
* Create a PolyVAPIError from an API response
|
|
45
|
+
*/
|
|
46
|
+
static fromResponse(response: PolyVAPIErrorResponse): PolyVAPIError;
|
|
47
|
+
/**
|
|
48
|
+
* Check if the error is retryable
|
|
49
|
+
* - 5xx errors are retryable (server errors)
|
|
50
|
+
* - 429 (rate limit) is retryable
|
|
51
|
+
* - Other 4xx errors are not retryable
|
|
52
|
+
*/
|
|
53
|
+
isRetryable(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Serialize error to JSON for logging and debugging
|
|
56
|
+
*/
|
|
57
|
+
toJSON(): {
|
|
58
|
+
name: string;
|
|
59
|
+
message: string;
|
|
60
|
+
code: string | undefined;
|
|
61
|
+
details: unknown;
|
|
62
|
+
statusCode: number;
|
|
63
|
+
polyvCode: number | undefined;
|
|
64
|
+
polyvMessage: string | undefined;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Return a formatted string representation of the error
|
|
68
|
+
*/
|
|
69
|
+
toString(): string;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=polyv-api-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyv-api-error.d.ts","sourceRoot":"","sources":["../../src/errors/polyv-api-error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE;QACL,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,qBAAa,aAAc,SAAQ,UAAU;IAC3C;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;gBAEnB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB;IAY/E;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,qBAAqB,GAAG,aAAa;IAOnE;;;;;OAKG;IACH,WAAW,IAAI,OAAO;IAYtB;;OAEG;IACM,MAAM,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;KAClC;IASD;;OAEG;IACM,QAAQ,IAAI,MAAM;CAM5B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PolyV SDK Base Error Class
|
|
3
|
+
*
|
|
4
|
+
* All PolyV SDK errors extend from this class.
|
|
5
|
+
* Provides consistent error handling with name, message, code, and details.
|
|
6
|
+
*/
|
|
7
|
+
export declare class PolyVError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Error code for programmatic error handling
|
|
10
|
+
*/
|
|
11
|
+
readonly code?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Additional error details
|
|
14
|
+
*/
|
|
15
|
+
readonly details?: unknown;
|
|
16
|
+
constructor(message: string, code?: string, details?: unknown);
|
|
17
|
+
/**
|
|
18
|
+
* Serialize error to JSON for logging and debugging
|
|
19
|
+
*/
|
|
20
|
+
toJSON(): {
|
|
21
|
+
name: string;
|
|
22
|
+
message: string;
|
|
23
|
+
code: string | undefined;
|
|
24
|
+
details: unknown;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Return a formatted string representation of the error
|
|
28
|
+
*/
|
|
29
|
+
toString(): string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=polyv-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyv-error.d.ts","sourceRoot":"","sources":["../../src/errors/polyv-error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;IAmB7D;;OAEG;IACH,MAAM,IAAI;QACR,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,OAAO,EAAE,OAAO,CAAC;KAClB;IASD;;OAEG;IACH,QAAQ,IAAI,MAAM;CAMnB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PolyV Validation Error Class
|
|
3
|
+
*
|
|
4
|
+
* Represents parameter validation errors.
|
|
5
|
+
* Provides field-level error details and factory methods for common validation errors.
|
|
6
|
+
*/
|
|
7
|
+
import { PolyVError } from './polyv-error.js';
|
|
8
|
+
/**
|
|
9
|
+
* Validation constraints metadata
|
|
10
|
+
*/
|
|
11
|
+
export interface ValidationConstraints {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export declare class PolyVValidationError extends PolyVError {
|
|
15
|
+
/**
|
|
16
|
+
* The field that failed validation
|
|
17
|
+
*/
|
|
18
|
+
readonly field?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The value that was rejected
|
|
21
|
+
*/
|
|
22
|
+
readonly invalidValue?: unknown;
|
|
23
|
+
/**
|
|
24
|
+
* Validation constraints that were not satisfied
|
|
25
|
+
*/
|
|
26
|
+
readonly constraints?: ValidationConstraints;
|
|
27
|
+
/**
|
|
28
|
+
* Array of aggregated errors (when multiple validation errors exist)
|
|
29
|
+
*/
|
|
30
|
+
readonly errors?: PolyVValidationError[];
|
|
31
|
+
constructor(message: string, field?: string, invalidValue?: unknown, constraints?: ValidationConstraints, code?: string);
|
|
32
|
+
/**
|
|
33
|
+
* Serialize error to JSON for logging and debugging
|
|
34
|
+
*/
|
|
35
|
+
toJSON(): {
|
|
36
|
+
name: string;
|
|
37
|
+
message: string;
|
|
38
|
+
code: string | undefined;
|
|
39
|
+
details: unknown;
|
|
40
|
+
field: string | undefined;
|
|
41
|
+
invalidValue: unknown;
|
|
42
|
+
constraints: ValidationConstraints | undefined;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Return a formatted string representation of the error
|
|
46
|
+
*/
|
|
47
|
+
toString(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Factory method for required field errors
|
|
50
|
+
*/
|
|
51
|
+
static required(field: string): PolyVValidationError;
|
|
52
|
+
/**
|
|
53
|
+
* Factory method for invalid type errors
|
|
54
|
+
*/
|
|
55
|
+
static invalidType(field: string, expectedType: string, actualValue: unknown): PolyVValidationError;
|
|
56
|
+
/**
|
|
57
|
+
* Factory method for out of range errors
|
|
58
|
+
*/
|
|
59
|
+
static outOfRange(field: string, value: number, constraints: {
|
|
60
|
+
min?: number;
|
|
61
|
+
max?: number;
|
|
62
|
+
}): PolyVValidationError;
|
|
63
|
+
/**
|
|
64
|
+
* Factory method for pattern mismatch errors
|
|
65
|
+
*/
|
|
66
|
+
static patternMismatch(field: string, value: string, pattern: RegExp): PolyVValidationError;
|
|
67
|
+
/**
|
|
68
|
+
* Aggregate multiple validation errors into a single error
|
|
69
|
+
*/
|
|
70
|
+
static aggregate(errors: PolyVValidationError[]): PolyVValidationError | null;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=polyv-validation-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyv-validation-error.d.ts","sourceRoot":"","sources":["../../src/errors/polyv-validation-error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qBAAa,oBAAqB,SAAQ,UAAU;IAClD;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,qBAAqB,CAAC;IAE7C;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,CAAC;gBAGvC,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,OAAO,EACtB,WAAW,CAAC,EAAE,qBAAqB,EACnC,IAAI,CAAC,EAAE,MAAM;IAwBf;;OAEG;IACM,MAAM,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,qBAAqB,GAAG,SAAS,CAAC;KAChD;IAcD;;OAEG;IACM,QAAQ,IAAI,MAAM;IAO3B;;OAEG;IACH,M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