@panomc/client 0.0.0-stage → 1.0.0-dev.62
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/package.json +22 -4
- package/src/client.js +267 -0
- package/src/client.test.js +348 -0
- package/src/core/index.js +522 -0
- package/src/core/openapi.json +5820 -0
- package/src/core/operations.js +69 -0
- package/src/core/types.js +360 -0
- package/src/errors.js +55 -0
- package/src/index.js +2 -0
- package/src/types.js +61 -0
- package/README.md +0 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Generated by pano-client from openapi.json. Do not edit; run pano-client again.
|
|
2
|
+
|
|
3
|
+
export const operations = /** @type {const} */ ({
|
|
4
|
+
changeEmail: { method: 'POST', path: '/api/v1/profile/change-email', auth: 'user', mutation: true },
|
|
5
|
+
completePendingAuth: { method: 'POST', path: '/api/v1/auth/complete-pending', auth: 'none', mutation: true },
|
|
6
|
+
createTicket: { method: 'POST', path: '/api/v1/tickets', auth: 'user', mutation: true },
|
|
7
|
+
createWsTicket: { method: 'POST', path: '/api/v1/auth/ws-ticket', auth: 'user', mutation: true },
|
|
8
|
+
deleteAllNotification: { method: 'DELETE', path: '/api/v1/notifications', auth: 'user', mutation: true },
|
|
9
|
+
deleteNotification: { method: 'DELETE', path: '/api/v1/notifications/{id}', auth: 'user', mutation: true },
|
|
10
|
+
getCredentials: { method: 'GET', path: '/api/v1/auth/credentials', auth: 'user', mutation: false },
|
|
11
|
+
getCsrfToken: { method: 'GET', path: '/api/v1/auth/csrf', auth: 'user', mutation: false },
|
|
12
|
+
getFavicon: { method: 'GET', path: '/api/v1/favicon', auth: 'none', mutation: false },
|
|
13
|
+
getFrontendSettings: { method: 'GET', path: '/api/v1/frontend/settings', auth: 'none', mutation: false },
|
|
14
|
+
getFrontendUrls: { method: 'GET', path: '/api/v1/frontend/urls', auth: 'none', mutation: false },
|
|
15
|
+
getLocales: { method: 'GET', path: '/api/v1/locales', auth: 'none', mutation: false },
|
|
16
|
+
getMoreNotifications: { method: 'GET', path: '/api/v1/notifications/{id}/more', auth: 'user', mutation: false },
|
|
17
|
+
getMySessions: { method: 'GET', path: '/api/v1/profile/sessions', auth: 'user', mutation: false },
|
|
18
|
+
getNotifications: { method: 'GET', path: '/api/v1/notifications', auth: 'user', mutation: false },
|
|
19
|
+
getOpenApi: { method: 'GET', path: '/api/v1/openapi.json', auth: 'none', mutation: false },
|
|
20
|
+
getPlayerProfile: { method: 'GET', path: '/api/v1/profiles/{username}', auth: 'none', mutation: false },
|
|
21
|
+
getPluginOpenApi: { method: 'GET', path: '/api/v1/plugins/{pluginId}/_/openapi.json', auth: 'none', mutation: false },
|
|
22
|
+
getPluginPackages: { method: 'GET', path: '/api/v1/plugin-packages', auth: 'none', mutation: false },
|
|
23
|
+
getPluginTranslations: { method: 'GET', path: '/api/v1/plugins/{pluginId}/_/translations/{locale}', auth: 'none', mutation: false },
|
|
24
|
+
getPluginUiFile: { method: 'GET', path: '/api/v1/plugins/{pluginId}/_/ui/*', auth: 'none', mutation: false },
|
|
25
|
+
getPostDetail: { method: 'GET', path: '/api/v1/posts/{url}', auth: 'none', mutation: false },
|
|
26
|
+
getPostPreview: { method: 'GET', path: '/api/v1/posts/previews/{id}', auth: 'user', mutation: false },
|
|
27
|
+
getPostThumbnail: { method: 'GET', path: '/api/v1/posts/thumbnails/{filename}', auth: 'none', mutation: false },
|
|
28
|
+
getPosts: { method: 'GET', path: '/api/v1/posts', auth: 'none', mutation: false },
|
|
29
|
+
getProfile: { method: 'GET', path: '/api/v1/profile', auth: 'user', mutation: false },
|
|
30
|
+
getProfilePicture: { method: 'GET', path: '/api/v1/profile/picture/{username}', auth: 'none', mutation: false },
|
|
31
|
+
getQuickNotifications: { method: 'GET', path: '/api/v1/notifications/quick', auth: 'user', mutation: false },
|
|
32
|
+
getRegisterAgreement: { method: 'GET', path: '/api/v1/register-agreement', auth: 'none', mutation: false },
|
|
33
|
+
getServers: { method: 'GET', path: '/api/v1/servers', auth: 'none', mutation: false },
|
|
34
|
+
getSiteInfo: { method: 'GET', path: '/api/v1/site-info', auth: 'none', mutation: false },
|
|
35
|
+
getSitemap: { method: 'GET', path: '/api/v1/sitemap', auth: 'none', mutation: false },
|
|
36
|
+
getThemeSettingResource: { method: 'GET', path: '/api/v1/theme/file/{filename}', auth: 'none', mutation: false },
|
|
37
|
+
getTicket: { method: 'GET', path: '/api/v1/tickets/{id}', auth: 'user', mutation: false },
|
|
38
|
+
getTicketCategories: { method: 'GET', path: '/api/v1/ticket-categories', auth: 'user', mutation: false },
|
|
39
|
+
getTicketMessages: { method: 'GET', path: '/api/v1/tickets/{id}/messages', auth: 'user', mutation: false },
|
|
40
|
+
getTickets: { method: 'GET', path: '/api/v1/tickets', auth: 'user', mutation: false },
|
|
41
|
+
getTranslations: { method: 'GET', path: '/api/v1/locales/{code}/translations/types/{type}', auth: 'none', mutation: false },
|
|
42
|
+
getWebsiteLogo: { method: 'GET', path: '/api/v1/website-logo', auth: 'none', mutation: false },
|
|
43
|
+
getWidgetIndex: { method: 'GET', path: '/api/v1/widgets/index.json', auth: 'none', mutation: false },
|
|
44
|
+
getWidgetLoader: { method: 'GET', path: '/api/v1/widgets/loader.js', auth: 'none', mutation: false },
|
|
45
|
+
getWidgetRuntimeFile: { method: 'GET', path: '/api/v1/widgets/runtime/*', auth: 'none', mutation: false },
|
|
46
|
+
health: { method: 'GET', path: '/api/v1/health', auth: 'none', mutation: false },
|
|
47
|
+
homeSidebar: { method: 'GET', path: '/api/v1/sidebars/home', auth: 'none', mutation: false },
|
|
48
|
+
login: { method: 'POST', path: '/api/v1/auth/login', auth: 'none', mutation: true },
|
|
49
|
+
logout: { method: 'POST', path: '/api/v1/auth/logout', auth: 'user', mutation: true },
|
|
50
|
+
logoutMySession: { method: 'DELETE', path: '/api/v1/profile/sessions/{id}', auth: 'user', mutation: true },
|
|
51
|
+
markNotificationAsRead: { method: 'POST', path: '/api/v1/notifications/{id}/read', auth: 'user', mutation: true },
|
|
52
|
+
markQuickNotificationsAsRead: { method: 'POST', path: '/api/v1/notifications/quick/mark-as-read', auth: 'user', mutation: true },
|
|
53
|
+
playerProfileSidebar: { method: 'GET', path: '/api/v1/sidebars/profile/{username}', auth: 'none', mutation: false },
|
|
54
|
+
profileSidebar: { method: 'GET', path: '/api/v1/sidebars/profile', auth: 'user', mutation: false },
|
|
55
|
+
register: { method: 'POST', path: '/api/v1/auth/register', auth: 'none', mutation: true },
|
|
56
|
+
renewPassword: { method: 'POST', path: '/api/v1/auth/renew-password', auth: 'none', mutation: true },
|
|
57
|
+
resetPassword: { method: 'POST', path: '/api/v1/auth/reset-password', auth: 'none', mutation: true },
|
|
58
|
+
sendResetPasswordEmail: { method: 'POST', path: '/api/v1/profile/reset-password', auth: 'user', mutation: true },
|
|
59
|
+
sendTicketMessage: { method: 'POST', path: '/api/v1/tickets/{id}/messages', auth: 'user', mutation: true },
|
|
60
|
+
supportSidebar: { method: 'GET', path: '/api/v1/sidebars/support', auth: 'none', mutation: false },
|
|
61
|
+
trackPostView: { method: 'POST', path: '/api/v1/posts/{url}/view', auth: 'none', mutation: true },
|
|
62
|
+
updateProfile: { method: 'PUT', path: '/api/v1/profile', auth: 'user', mutation: true },
|
|
63
|
+
updateTicket: { method: 'PUT', path: '/api/v1/tickets/{id}', auth: 'user', mutation: true },
|
|
64
|
+
verifyEmail: { method: 'POST', path: '/api/v1/auth/verify-email', auth: 'none', mutation: true },
|
|
65
|
+
verifyLinkCode: { method: 'POST', path: '/api/v1/auth/verify-link-code', auth: 'none', mutation: true },
|
|
66
|
+
verifyNewEmail: { method: 'POST', path: '/api/v1/auth/verify-new-email', auth: 'none', mutation: true },
|
|
67
|
+
visitorVisit: { method: 'POST', path: '/api/v1/visitor-visit', auth: 'none', mutation: true },
|
|
68
|
+
websiteWebSocket: { method: 'GET', path: '/api/v1/ws', auth: 'user', mutation: false }
|
|
69
|
+
});
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
// Generated by pano-client from openapi.json. Do not edit; run pano-client again.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The body of every non-2xx answer.
|
|
5
|
+
* @typedef {Object} Error
|
|
6
|
+
* @property {{ code: string, details?: Record<string, any>, fields?: Record<string, string>, message?: string }} error
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} Locale
|
|
11
|
+
* @property {string} code
|
|
12
|
+
* @property {number} [createdAt]
|
|
13
|
+
* @property {string} dateFnsCode
|
|
14
|
+
* @property {'SYSTEM' | 'USER'} [definedBy]
|
|
15
|
+
* @property {string[]} derivatives
|
|
16
|
+
* @property {number} id
|
|
17
|
+
* @property {string} name
|
|
18
|
+
* @property {number} [updatedAt]
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {Object} Notification
|
|
23
|
+
* @property {number} createdAt
|
|
24
|
+
* @property {Record<string, any>} details
|
|
25
|
+
* @property {number} id
|
|
26
|
+
* @property {boolean} isPersonal
|
|
27
|
+
* @property {string | null} pluginId
|
|
28
|
+
* @property {'NOT_READ' | 'READ'} status
|
|
29
|
+
* @property {string} type
|
|
30
|
+
* @property {number} updatedAt
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Where a list stands: page numbers start at 1, `pageSize` is at most 100.
|
|
35
|
+
* @typedef {Object} Page
|
|
36
|
+
* @property {number} number
|
|
37
|
+
* @property {number} size
|
|
38
|
+
* @property {number} totalItems
|
|
39
|
+
* @property {number} totalPages
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} Post
|
|
44
|
+
* @property {{ color?: string, description?: string, id?: number, title: string, url?: string }} category
|
|
45
|
+
* @property {number} date
|
|
46
|
+
* @property {number} id
|
|
47
|
+
* @property {'PUBLISHED' | 'DRAFT' | 'TRASH'} status
|
|
48
|
+
* @property {string} text
|
|
49
|
+
* @property {string} thumbnailUrl
|
|
50
|
+
* @property {string} title
|
|
51
|
+
* @property {string} url
|
|
52
|
+
* @property {number} views
|
|
53
|
+
* @property {{ username: string }} writer
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @typedef {Object} PostDetail
|
|
58
|
+
* @property {string | { id: number, title: string, url: string }} nextPost
|
|
59
|
+
* @property {Post} post
|
|
60
|
+
* @property {string | { id: number, title: string, url: string }} previousPost
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @typedef {Object} PostSummary
|
|
65
|
+
* @property {{ color?: string, description?: string, id?: number, title: string, url?: string }} category
|
|
66
|
+
* @property {number} date
|
|
67
|
+
* @property {number} id
|
|
68
|
+
* @property {string} text
|
|
69
|
+
* @property {string} thumbnailUrl
|
|
70
|
+
* @property {string} title
|
|
71
|
+
* @property {string} url
|
|
72
|
+
* @property {number} views
|
|
73
|
+
* @property {{ username: string }} writer
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @typedef {Object} Server
|
|
78
|
+
* @property {string | null} iconUrl
|
|
79
|
+
* @property {number} id
|
|
80
|
+
* @property {boolean} main
|
|
81
|
+
* @property {number} maxPlayerCount
|
|
82
|
+
* @property {string} motd
|
|
83
|
+
* @property {string} name
|
|
84
|
+
* @property {boolean} online
|
|
85
|
+
* @property {number} playerCount
|
|
86
|
+
* @property {'BUNGEECORD' | 'FABRIC' | 'FOLIA' | 'PAPER' | 'SPIGOT' | 'BUKKIT' | 'VELOCITY' | 'VANILLA' | 'PURPUR' | 'WATERFALL' | 'QUILT' | 'FORGE' | 'NEOFORGE'} type
|
|
87
|
+
* @property {string} version
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @typedef {Object} Session
|
|
92
|
+
* @property {string} [csrfToken]
|
|
93
|
+
* @property {number} [expiresAt]
|
|
94
|
+
* @property {string} [sessionToken]
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @typedef {Object} Ticket
|
|
99
|
+
* @property {{ color?: string, description?: string, id?: number, title: string, url?: string }} category
|
|
100
|
+
* @property {number} date
|
|
101
|
+
* @property {number} id
|
|
102
|
+
* @property {number} lastUpdate
|
|
103
|
+
* @property {'NEW' | 'REPLIED' | 'CLOSED'} status
|
|
104
|
+
* @property {string} title
|
|
105
|
+
* @property {{ username: string | null }} writer
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @typedef {Object} TicketCategory
|
|
110
|
+
* @property {string} description
|
|
111
|
+
* @property {number} id
|
|
112
|
+
* @property {string} title
|
|
113
|
+
* @property {string} url
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @typedef {Object} TicketDetail
|
|
118
|
+
* @property {{ title: string, url: string }} category
|
|
119
|
+
* @property {number} date
|
|
120
|
+
* @property {number} id
|
|
121
|
+
* @property {number} messageCount
|
|
122
|
+
* @property {TicketMessage[]} messages
|
|
123
|
+
* @property {'NEW' | 'REPLIED' | 'CLOSED'} status
|
|
124
|
+
* @property {string} title
|
|
125
|
+
* @property {string} username
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @typedef {Object} TicketMessage
|
|
130
|
+
* @property {number} date
|
|
131
|
+
* @property {number} id
|
|
132
|
+
* @property {string} message
|
|
133
|
+
* @property {number} panel
|
|
134
|
+
* @property {number} ticketId
|
|
135
|
+
* @property {number} userId
|
|
136
|
+
* @property {string} username
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @typedef {Object} User
|
|
141
|
+
* @property {number} [lastLoginDate]
|
|
142
|
+
* @property {number} registerDate
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
/** @typedef {Record<string, any>} ChangeEmailResponse */
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @typedef {Object} ChangeEmailRequest
|
|
149
|
+
* @property {string} currentPassword
|
|
150
|
+
* @property {string} newEmail
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
/** @typedef {Session} CompletePendingAuthResponse */
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @typedef {Object} CompletePendingAuthRequest
|
|
157
|
+
* @property {string} pendingToken
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
/** @typedef {{ id: number }} CreateTicketResponse */
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @typedef {Object} CreateTicketRequest
|
|
164
|
+
* @property {number} categoryId
|
|
165
|
+
* @property {string} message
|
|
166
|
+
* @property {string} title
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
/** @typedef {{ expiresIn: number, ticket: string }} CreateWsTicketResponse */
|
|
170
|
+
|
|
171
|
+
/** @typedef {Record<string, any>} DeleteAllNotificationResponse */
|
|
172
|
+
|
|
173
|
+
/** @typedef {Record<string, any>} DeleteNotificationResponse */
|
|
174
|
+
|
|
175
|
+
/** @typedef {{ admin: boolean, email: string | null, panelAccess: boolean, permissions: string[], username: string }} GetCredentialsResponse */
|
|
176
|
+
|
|
177
|
+
/** @typedef {Record<string, any>} GetCsrfTokenResponse */
|
|
178
|
+
|
|
179
|
+
/** @typedef {Blob} GetFaviconResponse */
|
|
180
|
+
|
|
181
|
+
/** @typedef {{ files: Record<string, any>, id: string, settings: Record<string, any> }} GetFrontendSettingsResponse */
|
|
182
|
+
|
|
183
|
+
/** @typedef {{ siteUrl: string, urls: Record<string, string> }} GetFrontendUrlsResponse */
|
|
184
|
+
|
|
185
|
+
/** @typedef {{ items: Locale[] }} GetLocalesResponse */
|
|
186
|
+
|
|
187
|
+
/** @typedef {{ notifications: Notification[] }} GetMoreNotificationsResponse */
|
|
188
|
+
|
|
189
|
+
/** @typedef {{ sessions: { expireDate: number, id: number, ip: string, isCurrent: boolean, lastActivityTime: number, userAgent: string }[] }} GetMySessionsResponse */
|
|
190
|
+
|
|
191
|
+
/** @typedef {{ items: Notification[], page: Page }} GetNotificationsResponse */
|
|
192
|
+
|
|
193
|
+
/** @typedef {{ components: Record<string, any>, info: Record<string, any>, openapi: string, paths: Record<string, any>, servers: any[] }} GetOpenApiResponse */
|
|
194
|
+
|
|
195
|
+
/** @typedef {User} GetPlayerProfileResponse */
|
|
196
|
+
|
|
197
|
+
/** @typedef {{ components: Record<string, any>, info: Record<string, any>, openapi: string, paths: Record<string, any>, servers: any[] }} GetPluginOpenApiResponse */
|
|
198
|
+
|
|
199
|
+
/** @typedef {{ plugins: Record<string, Record<string, any>> }} GetPluginPackagesResponse */
|
|
200
|
+
|
|
201
|
+
/** @typedef {{ locale: string, translations: Record<string, any> }} GetPluginTranslationsResponse */
|
|
202
|
+
|
|
203
|
+
/** @typedef {Blob} GetPluginUiFileResponse */
|
|
204
|
+
|
|
205
|
+
/** @typedef {PostDetail} GetPostDetailResponse */
|
|
206
|
+
|
|
207
|
+
/** @typedef {PostDetail} GetPostPreviewResponse */
|
|
208
|
+
|
|
209
|
+
/** @typedef {Blob} GetPostThumbnailResponse */
|
|
210
|
+
|
|
211
|
+
/** @typedef {{ items: PostSummary[], page: Page }} GetPostsResponse */
|
|
212
|
+
|
|
213
|
+
/** @typedef {User} GetProfileResponse */
|
|
214
|
+
|
|
215
|
+
/** @typedef {Blob} GetProfilePictureResponse */
|
|
216
|
+
|
|
217
|
+
/** @typedef {{ notificationCount: number, notifications: Notification[] }} GetQuickNotificationsResponse */
|
|
218
|
+
|
|
219
|
+
/** @typedef {{ registerAgreement: string }} GetRegisterAgreementResponse */
|
|
220
|
+
|
|
221
|
+
/** @typedef {{ address: string, items: Server[] }} GetServersResponse */
|
|
222
|
+
|
|
223
|
+
/** @typedef {{ allowUserLocaleSelection: boolean, developmentMode: boolean, emailEnabled: boolean, faviconHash: string, hasRegisterAgreement: boolean, homePage: string | null, ipAddress: string, isDemo: boolean, keywords: string[], locale: string, locales?: Locale[], panoVersion: string, platformLocale: string, plugins: Record<string, { dependencies: string[], uiHash: string, version: string | null }>, supportEmail: string, themeSettings: Record<string, any>, usageMode: 'WEBSITE' | 'SERVERS' | 'BOTH', userLocaleCode?: string | null, websiteDescription: string, websiteLogoHash: string, websiteName: string, websiteUrl: string }} GetSiteInfoResponse */
|
|
224
|
+
|
|
225
|
+
/** @typedef {{ items: { params: Record<string, any>, type: string, updatedAt?: number }[], page: Page }} GetSitemapResponse */
|
|
226
|
+
|
|
227
|
+
/** @typedef {Blob} GetThemeSettingResourceResponse */
|
|
228
|
+
|
|
229
|
+
/** @typedef {{ ticket: TicketDetail }} GetTicketResponse */
|
|
230
|
+
|
|
231
|
+
/** @typedef {{ items: TicketCategory[], page: Page }} GetTicketCategoriesResponse */
|
|
232
|
+
|
|
233
|
+
/** @typedef {{ messages: TicketMessage[] }} GetTicketMessagesResponse */
|
|
234
|
+
|
|
235
|
+
/** @typedef {{ items: Ticket[], page: Page }} GetTicketsResponse */
|
|
236
|
+
|
|
237
|
+
/** @typedef {{ data: Record<string, any>, meta: { pluginAdminKeys: Record<string, any>, totalCount: number } }} GetTranslationsResponse */
|
|
238
|
+
|
|
239
|
+
/** @typedef {Blob} GetWebsiteLogoResponse */
|
|
240
|
+
|
|
241
|
+
/** @typedef {any} GetWidgetIndexResponse */
|
|
242
|
+
|
|
243
|
+
/** @typedef {any} GetWidgetLoaderResponse */
|
|
244
|
+
|
|
245
|
+
/** @typedef {any} GetWidgetRuntimeFileResponse */
|
|
246
|
+
|
|
247
|
+
/** @typedef {any} HealthResponse */
|
|
248
|
+
|
|
249
|
+
/** @typedef {{ ipAddress: string, lastRegisteredUsers: { lastActivityTime: number, registerDate: number, username: string }[], mainServer: { maxPlayerCount: number, playerCount: number, status: 'ONLINE' | 'OFFLINE' } | null, serverGameVersion: string }} HomeSidebarResponse */
|
|
250
|
+
|
|
251
|
+
/** @typedef {Session} LoginResponse */
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @typedef {Object} LoginRequest
|
|
255
|
+
* @property {string} [newUsername]
|
|
256
|
+
* @property {boolean} [panel]
|
|
257
|
+
* @property {string} [password]
|
|
258
|
+
* @property {string} [registerEmail]
|
|
259
|
+
* @property {string} usernameOrEmail
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
/** @typedef {Record<string, any>} LogoutResponse */
|
|
263
|
+
|
|
264
|
+
/** @typedef {Record<string, any>} LogoutMySessionResponse */
|
|
265
|
+
|
|
266
|
+
/** @typedef {Record<string, any>} MarkNotificationAsReadResponse */
|
|
267
|
+
|
|
268
|
+
/** @typedef {{ notificationCount: number }} MarkQuickNotificationsAsReadResponse */
|
|
269
|
+
|
|
270
|
+
/** @typedef {{ banned: boolean, inGame: boolean, lastActivityTime: number, permissionGroupName: string | null }} PlayerProfileSidebarResponse */
|
|
271
|
+
|
|
272
|
+
/** @typedef {{ inGame: boolean, lastActivityTime: number, permissionGroupName: string | null }} ProfileSidebarResponse */
|
|
273
|
+
|
|
274
|
+
/** @typedef {{ csrfToken?: string, email?: string, emailVerificationRequired?: boolean, expiresAt?: number, login?: boolean, sessionToken?: string }} RegisterResponse */
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @typedef {Object} RegisterRequest
|
|
278
|
+
* @property {boolean} agreement
|
|
279
|
+
* @property {string} email
|
|
280
|
+
* @property {string} password
|
|
281
|
+
* @property {string} passwordRepeat
|
|
282
|
+
* @property {string} [registerWithLinkToken]
|
|
283
|
+
* @property {string} [username]
|
|
284
|
+
*/
|
|
285
|
+
|
|
286
|
+
/** @typedef {Record<string, any>} RenewPasswordResponse */
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @typedef {Object} RenewPasswordRequest
|
|
290
|
+
* @property {string} [captchaToken]
|
|
291
|
+
* @property {string} newPassword
|
|
292
|
+
* @property {string} newPasswordRepeat
|
|
293
|
+
* @property {string} token
|
|
294
|
+
*/
|
|
295
|
+
|
|
296
|
+
/** @typedef {Record<string, any>} ResetPasswordResponse */
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @typedef {Object} ResetPasswordRequest
|
|
300
|
+
* @property {string} [captchaToken]
|
|
301
|
+
* @property {string} usernameOrEmail
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
/** @typedef {Record<string, any>} SendResetPasswordEmailResponse */
|
|
305
|
+
|
|
306
|
+
/** @typedef {{ message: TicketMessage }} SendTicketMessageResponse */
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* @typedef {Object} SendTicketMessageRequest
|
|
310
|
+
* @property {string} message
|
|
311
|
+
*/
|
|
312
|
+
|
|
313
|
+
/** @typedef {{ items: string[] }} SupportSidebarResponse */
|
|
314
|
+
|
|
315
|
+
/** @typedef {{ counted: boolean }} TrackPostViewResponse */
|
|
316
|
+
|
|
317
|
+
/** @typedef {Record<string, any>} UpdateProfileResponse */
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* @typedef {Object} UpdateProfileRequest
|
|
321
|
+
* @property {string} [localeCode]
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
/** @typedef {Record<string, any>} UpdateTicketResponse */
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* @typedef {Object} UpdateTicketRequest
|
|
328
|
+
* @property {'NEW' | 'REPLIED' | 'CLOSED'} [status]
|
|
329
|
+
*/
|
|
330
|
+
|
|
331
|
+
/** @typedef {Record<string, any>} VerifyEmailResponse */
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @typedef {Object} VerifyEmailRequest
|
|
335
|
+
* @property {string} [captchaToken]
|
|
336
|
+
* @property {string} token
|
|
337
|
+
*/
|
|
338
|
+
|
|
339
|
+
/** @typedef {{ token: string, username: string }} VerifyLinkCodeResponse */
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* @typedef {Object} VerifyLinkCodeRequest
|
|
343
|
+
* @property {string} [captchaToken]
|
|
344
|
+
* @property {string} code
|
|
345
|
+
* @property {string} username
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
/** @typedef {Record<string, any>} VerifyNewEmailResponse */
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* @typedef {Object} VerifyNewEmailRequest
|
|
352
|
+
* @property {string} [captchaToken]
|
|
353
|
+
* @property {string} token
|
|
354
|
+
*/
|
|
355
|
+
|
|
356
|
+
/** @typedef {Record<string, any>} VisitorVisitResponse */
|
|
357
|
+
|
|
358
|
+
/** @typedef {any} WebsiteWebSocketResponse */
|
|
359
|
+
|
|
360
|
+
export {};
|
package/src/errors.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Thrown only by `unwrap`; the client itself never throws for an HTTP or network failure. */
|
|
2
|
+
export class PanoApiError extends Error {
|
|
3
|
+
/**
|
|
4
|
+
* @param {import('./types.js').ApiFailure} failure
|
|
5
|
+
*/
|
|
6
|
+
constructor(failure) {
|
|
7
|
+
const error = failure?.error ?? { code: 'UNKNOWN' }
|
|
8
|
+
super(error.message || error.code)
|
|
9
|
+
this.name = 'PanoApiError'
|
|
10
|
+
/** @type {string} */
|
|
11
|
+
this.code = error.code
|
|
12
|
+
/** @type {number} */
|
|
13
|
+
this.status = failure?.status ?? 0
|
|
14
|
+
/** @type {Record<string, string>} */
|
|
15
|
+
this.fields = error.fields ?? {}
|
|
16
|
+
/** @type {Record<string, any>|undefined} */
|
|
17
|
+
this.details = error.details
|
|
18
|
+
/** @type {import('./types.js').ApiFailure} */
|
|
19
|
+
this.result = failure
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {number} status
|
|
25
|
+
* @param {string} code
|
|
26
|
+
* @param {Partial<import('./types.js').ApiErrorBody>} [rest]
|
|
27
|
+
* @returns {import('./types.js').ApiFailure}
|
|
28
|
+
*/
|
|
29
|
+
export function failure(status, code, rest = {}) {
|
|
30
|
+
return { ok: false, status, error: { ...rest, code } }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Builds an ApiFailure from a non-2xx response body: the `{ error: { code, message?, details?, fields? } }` envelope,
|
|
35
|
+
* or a fallback `HTTP_<status>` when the body is not that.
|
|
36
|
+
* @param {number} status
|
|
37
|
+
* @param {any} body parsed body (object, string or undefined)
|
|
38
|
+
* @returns {import('./types.js').ApiFailure}
|
|
39
|
+
*/
|
|
40
|
+
export function failureFromBody(status, body) {
|
|
41
|
+
const e = body && typeof body === 'object' ? body.error : undefined
|
|
42
|
+
|
|
43
|
+
if (e && typeof e === 'object' && typeof e.code === 'string') {
|
|
44
|
+
/** @type {import('./types.js').ApiErrorBody} */
|
|
45
|
+
const error = { code: e.code }
|
|
46
|
+
if (typeof e.message === 'string') error.message = e.message
|
|
47
|
+
if (e.details && typeof e.details === 'object') error.details = e.details
|
|
48
|
+
if (e.fields && typeof e.fields === 'object') error.fields = e.fields
|
|
49
|
+
return { ok: false, status, error }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const failed = failure(status, `HTTP_${status}`)
|
|
53
|
+
if (typeof body === 'string' && body) failed.error.message = body.slice(0, 500)
|
|
54
|
+
return failed
|
|
55
|
+
}
|
package/src/index.js
ADDED
package/src/types.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Shared JSDoc typedefs for @panomc/client. No runtime code.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} ApiErrorBody
|
|
5
|
+
* @property {string} code machine readable, e.g. NETWORK_ERROR, INVALID_CSRF_TOKEN, NOT_LOGGED_IN
|
|
6
|
+
* @property {string} [message]
|
|
7
|
+
* @property {Record<string, any>} [details]
|
|
8
|
+
* @property {Record<string, string>} [fields] field name -> error code (validation errors)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} ApiFailure
|
|
13
|
+
* @property {false} ok
|
|
14
|
+
* @property {number} status HTTP status, 0 when no response arrived
|
|
15
|
+
* @property {ApiErrorBody} error
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @template T
|
|
20
|
+
* @typedef {{ ok: true, status: number, data: T } | ApiFailure} ApiResult
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {Object} PanoClientOptions
|
|
25
|
+
* @property {string} baseUrl what precedes "/api/v1": Pano's origin, or a proxy prefix such as "/pano"
|
|
26
|
+
* @property {typeof fetch} [fetch] default globalThis.fetch
|
|
27
|
+
* @property {string} [frontendKey] server only; X-Pano-Frontend-Key
|
|
28
|
+
* @property {string|(() => string|null|Promise<string|null>)} [sessionToken] Authorization: Bearer
|
|
29
|
+
* @property {string} [clientIp] X-Pano-Client-Ip; sent only with frontendKey
|
|
30
|
+
* @property {string} [locale] Accept-Language
|
|
31
|
+
* @property {'include'|'omit'} [credentials] default 'include' in a browser, 'omit' elsewhere
|
|
32
|
+
* @property {'auto'|'off'} [csrf] default 'auto' with credentials 'include' and no sessionToken, else 'off'
|
|
33
|
+
* @property {(result: ApiFailure) => void} [onUnauthorized]
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* An operation as found in a generated operations.js, or the escape hatch `{ method, path }`.
|
|
38
|
+
* `path` may hold `{name}` placeholders filled from `params.path`.
|
|
39
|
+
* @typedef {Object} PanoOperation
|
|
40
|
+
* @property {string} method
|
|
41
|
+
* @property {string} path
|
|
42
|
+
* @property {'none'|'user'} [auth]
|
|
43
|
+
* @property {boolean} [mutation]
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {Object} RequestParams
|
|
48
|
+
* @property {Record<string, string|number|boolean>} [path] values for {placeholders}
|
|
49
|
+
* @property {Record<string, any>} [query] undefined / null are skipped, arrays repeat the key
|
|
50
|
+
* @property {any} [body] FormData and other raw bodies pass through, the rest is JSON
|
|
51
|
+
* @property {Record<string, string>} [headers]
|
|
52
|
+
* @property {AbortSignal} [signal]
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {Object} PanoClient
|
|
57
|
+
* @property {<T = any>(operation: PanoOperation, params?: RequestParams) => Promise<ApiResult<T>>} request
|
|
58
|
+
* @property {Readonly<PanoClientOptions>} options
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
export {};
|
package/README.md
DELETED