@cstar.help/js 0.14.0 → 0.15.1
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.cjs +93 -11
- package/dist/auth/index.d.cts +398 -1
- package/dist/auth/index.d.ts +398 -1
- package/dist/auth/index.js +79 -10
- package/dist/chat/index.cjs +30 -8
- package/dist/chat/index.d.cts +18 -15
- package/dist/chat/index.d.ts +18 -15
- package/dist/chat/index.js +30 -8
- package/dist/community/index.cjs +93 -11
- package/dist/community/index.d.cts +398 -1
- package/dist/community/index.d.ts +398 -1
- package/dist/community/index.js +79 -10
- package/dist/index.cjs +55 -11
- package/dist/index.d.cts +334 -53
- package/dist/index.d.ts +334 -53
- package/dist/index.js +55 -11
- package/dist/library/index.cjs +93 -11
- package/dist/library/index.d.cts +398 -1
- package/dist/library/index.d.ts +398 -1
- package/dist/library/index.js +79 -10
- package/dist/quickhelp/index.cjs +154 -11
- package/dist/quickhelp/index.d.cts +398 -1
- package/dist/quickhelp/index.d.ts +398 -1
- package/dist/quickhelp/index.js +140 -10
- package/dist/webhook/index.cjs +64 -8
- package/dist/webhook/index.d.cts +27 -3
- package/dist/webhook/index.d.ts +27 -3
- package/dist/webhook/index.js +62 -8
- package/dist/webhook/node.cjs +53 -5
- package/dist/webhook/node.d.cts +27 -4
- package/dist/webhook/node.d.ts +27 -4
- package/dist/webhook/node.js +51 -5
- package/package.json +1 -1
package/dist/library/index.d.ts
CHANGED
|
@@ -88,6 +88,403 @@ interface ArticleFeedbackResult {
|
|
|
88
88
|
error?: string;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Error classes for the cStar SDK.
|
|
93
|
+
*
|
|
94
|
+
* NEW-v3-01 — Cross-subpath instanceof identity.
|
|
95
|
+
*
|
|
96
|
+
* Each public subpath (`/library`, `/auth`, `/community`, `/quickhelp`, ...)
|
|
97
|
+
* is bundled as a separate tsup entry with `splitting: false`, so each one
|
|
98
|
+
* carries its own copy of this module. Without deduplication, errors thrown
|
|
99
|
+
* by `LibraryClient` carry the LibraryClient-bundled `CStarError` class —
|
|
100
|
+
* not the one a consumer imports from `@cstar.help/js`. That makes
|
|
101
|
+
* `instanceof CStarError` checks fail silently, invalidating every "did the
|
|
102
|
+
* SDK throw a typed cStar error?" branch in user code.
|
|
103
|
+
*
|
|
104
|
+
* Fix: register each class on a `Symbol.for(...)` slot of `globalThis`. The
|
|
105
|
+
* symbol is realm-shared, so every bundled copy of this module resolves to
|
|
106
|
+
* the SAME class identity at runtime — the first copy to load wins, and all
|
|
107
|
+
* subsequent copies surface the canonical class via the same slot. The
|
|
108
|
+
* inline `Impl` definitions are only used as the seed for the very first
|
|
109
|
+
* copy to register. Internal `parseError` / `parsePublicError` reference the
|
|
110
|
+
* EXPORTED canonical names so instances they construct also land on the
|
|
111
|
+
* canonical class.
|
|
112
|
+
*/
|
|
113
|
+
/** Error type constants matching the cStar API. */
|
|
114
|
+
declare const ErrorType: {
|
|
115
|
+
readonly AUTHENTICATION_ERROR: "authentication_error";
|
|
116
|
+
readonly PERMISSION_ERROR: "permission_error";
|
|
117
|
+
readonly INVALID_REQUEST_ERROR: "invalid_request_error";
|
|
118
|
+
readonly NOT_FOUND_ERROR: "not_found_error";
|
|
119
|
+
readonly CONFLICT_ERROR: "conflict_error";
|
|
120
|
+
readonly RATE_LIMIT_ERROR: "rate_limit_error";
|
|
121
|
+
readonly FEATURE_NOT_CONFIGURED: "feature_not_configured";
|
|
122
|
+
readonly API_ERROR: "api_error";
|
|
123
|
+
readonly SERVER_ERROR: "server_error";
|
|
124
|
+
};
|
|
125
|
+
/** Shape of the error object returned by the cStar API. */
|
|
126
|
+
interface ApiErrorBody {
|
|
127
|
+
type: string;
|
|
128
|
+
code: string;
|
|
129
|
+
message: string;
|
|
130
|
+
param?: string;
|
|
131
|
+
doc_url: string;
|
|
132
|
+
request_id?: string;
|
|
133
|
+
feature?: string;
|
|
134
|
+
enable_url?: string;
|
|
135
|
+
}
|
|
136
|
+
/** Base error class for all cStar API errors. */
|
|
137
|
+
declare const CStarErrorImpl: {
|
|
138
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
139
|
+
readonly type: string;
|
|
140
|
+
readonly code: string;
|
|
141
|
+
readonly param?: string;
|
|
142
|
+
readonly docUrl: string;
|
|
143
|
+
readonly requestId?: string;
|
|
144
|
+
readonly statusCode: number;
|
|
145
|
+
name: string;
|
|
146
|
+
message: string;
|
|
147
|
+
stack?: string;
|
|
148
|
+
};
|
|
149
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
150
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
151
|
+
stackTraceLimit: number;
|
|
152
|
+
};
|
|
153
|
+
declare const CStarAuthenticationErrorImpl: {
|
|
154
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
155
|
+
readonly type: string;
|
|
156
|
+
readonly code: string;
|
|
157
|
+
readonly param?: string;
|
|
158
|
+
readonly docUrl: string;
|
|
159
|
+
readonly requestId?: string;
|
|
160
|
+
readonly statusCode: number;
|
|
161
|
+
name: string;
|
|
162
|
+
message: string;
|
|
163
|
+
stack?: string;
|
|
164
|
+
};
|
|
165
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
166
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
167
|
+
stackTraceLimit: number;
|
|
168
|
+
};
|
|
169
|
+
declare const CStarRateLimitErrorImpl: {
|
|
170
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number): {
|
|
171
|
+
readonly retryAfter: number;
|
|
172
|
+
readonly type: string;
|
|
173
|
+
readonly code: string;
|
|
174
|
+
readonly param?: string;
|
|
175
|
+
readonly docUrl: string;
|
|
176
|
+
readonly requestId?: string;
|
|
177
|
+
readonly statusCode: number;
|
|
178
|
+
name: string;
|
|
179
|
+
message: string;
|
|
180
|
+
stack?: string;
|
|
181
|
+
};
|
|
182
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
183
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
184
|
+
stackTraceLimit: number;
|
|
185
|
+
};
|
|
186
|
+
declare const CStarNotFoundErrorImpl: {
|
|
187
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
188
|
+
readonly type: string;
|
|
189
|
+
readonly code: string;
|
|
190
|
+
readonly param?: string;
|
|
191
|
+
readonly docUrl: string;
|
|
192
|
+
readonly requestId?: string;
|
|
193
|
+
readonly statusCode: number;
|
|
194
|
+
name: string;
|
|
195
|
+
message: string;
|
|
196
|
+
stack?: string;
|
|
197
|
+
};
|
|
198
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
199
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
200
|
+
stackTraceLimit: number;
|
|
201
|
+
};
|
|
202
|
+
declare const CStarValidationErrorImpl: {
|
|
203
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
204
|
+
readonly type: string;
|
|
205
|
+
readonly code: string;
|
|
206
|
+
readonly param?: string;
|
|
207
|
+
readonly docUrl: string;
|
|
208
|
+
readonly requestId?: string;
|
|
209
|
+
readonly statusCode: number;
|
|
210
|
+
name: string;
|
|
211
|
+
message: string;
|
|
212
|
+
stack?: string;
|
|
213
|
+
};
|
|
214
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
215
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
216
|
+
stackTraceLimit: number;
|
|
217
|
+
};
|
|
218
|
+
declare const CStarPermissionErrorImpl: {
|
|
219
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
220
|
+
readonly type: string;
|
|
221
|
+
readonly code: string;
|
|
222
|
+
readonly param?: string;
|
|
223
|
+
readonly docUrl: string;
|
|
224
|
+
readonly requestId?: string;
|
|
225
|
+
readonly statusCode: number;
|
|
226
|
+
name: string;
|
|
227
|
+
message: string;
|
|
228
|
+
stack?: string;
|
|
229
|
+
};
|
|
230
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
231
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
232
|
+
stackTraceLimit: number;
|
|
233
|
+
};
|
|
234
|
+
declare const CStarConflictErrorImpl: {
|
|
235
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
236
|
+
readonly type: string;
|
|
237
|
+
readonly code: string;
|
|
238
|
+
readonly param?: string;
|
|
239
|
+
readonly docUrl: string;
|
|
240
|
+
readonly requestId?: string;
|
|
241
|
+
readonly statusCode: number;
|
|
242
|
+
name: string;
|
|
243
|
+
message: string;
|
|
244
|
+
stack?: string;
|
|
245
|
+
};
|
|
246
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
247
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
248
|
+
stackTraceLimit: number;
|
|
249
|
+
};
|
|
250
|
+
declare const CStarServerErrorImpl: {
|
|
251
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
252
|
+
readonly type: string;
|
|
253
|
+
readonly code: string;
|
|
254
|
+
readonly param?: string;
|
|
255
|
+
readonly docUrl: string;
|
|
256
|
+
readonly requestId?: string;
|
|
257
|
+
readonly statusCode: number;
|
|
258
|
+
name: string;
|
|
259
|
+
message: string;
|
|
260
|
+
stack?: string;
|
|
261
|
+
};
|
|
262
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
263
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
264
|
+
stackTraceLimit: number;
|
|
265
|
+
};
|
|
266
|
+
declare const CStarFeatureDisabledErrorImpl: {
|
|
267
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
268
|
+
readonly feature: string;
|
|
269
|
+
readonly enableUrl: string;
|
|
270
|
+
readonly type: string;
|
|
271
|
+
readonly code: string;
|
|
272
|
+
readonly param?: string;
|
|
273
|
+
readonly docUrl: string;
|
|
274
|
+
readonly requestId?: string;
|
|
275
|
+
readonly statusCode: number;
|
|
276
|
+
name: string;
|
|
277
|
+
message: string;
|
|
278
|
+
stack?: string;
|
|
279
|
+
};
|
|
280
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
281
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
282
|
+
stackTraceLimit: number;
|
|
283
|
+
};
|
|
284
|
+
declare const CStarRealtimeUnavailableErrorImpl: {
|
|
285
|
+
new (message?: string): {
|
|
286
|
+
readonly type: string;
|
|
287
|
+
readonly code: string;
|
|
288
|
+
readonly param?: string;
|
|
289
|
+
readonly docUrl: string;
|
|
290
|
+
readonly requestId?: string;
|
|
291
|
+
readonly statusCode: number;
|
|
292
|
+
name: string;
|
|
293
|
+
message: string;
|
|
294
|
+
stack?: string;
|
|
295
|
+
};
|
|
296
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
297
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
298
|
+
stackTraceLimit: number;
|
|
299
|
+
};
|
|
300
|
+
declare const CStarError: {
|
|
301
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
302
|
+
readonly type: string;
|
|
303
|
+
readonly code: string;
|
|
304
|
+
readonly param?: string;
|
|
305
|
+
readonly docUrl: string;
|
|
306
|
+
readonly requestId?: string;
|
|
307
|
+
readonly statusCode: number;
|
|
308
|
+
name: string;
|
|
309
|
+
message: string;
|
|
310
|
+
stack?: string;
|
|
311
|
+
};
|
|
312
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
313
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
314
|
+
stackTraceLimit: number;
|
|
315
|
+
};
|
|
316
|
+
type CStarError = InstanceType<typeof CStarErrorImpl>;
|
|
317
|
+
declare const CStarAuthenticationError: {
|
|
318
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
319
|
+
readonly type: string;
|
|
320
|
+
readonly code: string;
|
|
321
|
+
readonly param?: string;
|
|
322
|
+
readonly docUrl: string;
|
|
323
|
+
readonly requestId?: string;
|
|
324
|
+
readonly statusCode: number;
|
|
325
|
+
name: string;
|
|
326
|
+
message: string;
|
|
327
|
+
stack?: string;
|
|
328
|
+
};
|
|
329
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
330
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
331
|
+
stackTraceLimit: number;
|
|
332
|
+
};
|
|
333
|
+
type CStarAuthenticationError = InstanceType<typeof CStarAuthenticationErrorImpl>;
|
|
334
|
+
declare const CStarRateLimitError: {
|
|
335
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number): {
|
|
336
|
+
readonly retryAfter: number;
|
|
337
|
+
readonly type: string;
|
|
338
|
+
readonly code: string;
|
|
339
|
+
readonly param?: string;
|
|
340
|
+
readonly docUrl: string;
|
|
341
|
+
readonly requestId?: string;
|
|
342
|
+
readonly statusCode: number;
|
|
343
|
+
name: string;
|
|
344
|
+
message: string;
|
|
345
|
+
stack?: string;
|
|
346
|
+
};
|
|
347
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
348
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
349
|
+
stackTraceLimit: number;
|
|
350
|
+
};
|
|
351
|
+
type CStarRateLimitError = InstanceType<typeof CStarRateLimitErrorImpl>;
|
|
352
|
+
declare const CStarNotFoundError: {
|
|
353
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
354
|
+
readonly type: string;
|
|
355
|
+
readonly code: string;
|
|
356
|
+
readonly param?: string;
|
|
357
|
+
readonly docUrl: string;
|
|
358
|
+
readonly requestId?: string;
|
|
359
|
+
readonly statusCode: number;
|
|
360
|
+
name: string;
|
|
361
|
+
message: string;
|
|
362
|
+
stack?: string;
|
|
363
|
+
};
|
|
364
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
365
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
366
|
+
stackTraceLimit: number;
|
|
367
|
+
};
|
|
368
|
+
type CStarNotFoundError = InstanceType<typeof CStarNotFoundErrorImpl>;
|
|
369
|
+
declare const CStarValidationError: {
|
|
370
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
371
|
+
readonly type: string;
|
|
372
|
+
readonly code: string;
|
|
373
|
+
readonly param?: string;
|
|
374
|
+
readonly docUrl: string;
|
|
375
|
+
readonly requestId?: string;
|
|
376
|
+
readonly statusCode: number;
|
|
377
|
+
name: string;
|
|
378
|
+
message: string;
|
|
379
|
+
stack?: string;
|
|
380
|
+
};
|
|
381
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
382
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
383
|
+
stackTraceLimit: number;
|
|
384
|
+
};
|
|
385
|
+
type CStarValidationError = InstanceType<typeof CStarValidationErrorImpl>;
|
|
386
|
+
declare const CStarPermissionError: {
|
|
387
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
388
|
+
readonly type: string;
|
|
389
|
+
readonly code: string;
|
|
390
|
+
readonly param?: string;
|
|
391
|
+
readonly docUrl: string;
|
|
392
|
+
readonly requestId?: string;
|
|
393
|
+
readonly statusCode: number;
|
|
394
|
+
name: string;
|
|
395
|
+
message: string;
|
|
396
|
+
stack?: string;
|
|
397
|
+
};
|
|
398
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
399
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
400
|
+
stackTraceLimit: number;
|
|
401
|
+
};
|
|
402
|
+
type CStarPermissionError = InstanceType<typeof CStarPermissionErrorImpl>;
|
|
403
|
+
declare const CStarConflictError: {
|
|
404
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
405
|
+
readonly type: string;
|
|
406
|
+
readonly code: string;
|
|
407
|
+
readonly param?: string;
|
|
408
|
+
readonly docUrl: string;
|
|
409
|
+
readonly requestId?: string;
|
|
410
|
+
readonly statusCode: number;
|
|
411
|
+
name: string;
|
|
412
|
+
message: string;
|
|
413
|
+
stack?: string;
|
|
414
|
+
};
|
|
415
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
416
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
417
|
+
stackTraceLimit: number;
|
|
418
|
+
};
|
|
419
|
+
type CStarConflictError = InstanceType<typeof CStarConflictErrorImpl>;
|
|
420
|
+
declare const CStarServerError: {
|
|
421
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
422
|
+
readonly type: string;
|
|
423
|
+
readonly code: string;
|
|
424
|
+
readonly param?: string;
|
|
425
|
+
readonly docUrl: string;
|
|
426
|
+
readonly requestId?: string;
|
|
427
|
+
readonly statusCode: number;
|
|
428
|
+
name: string;
|
|
429
|
+
message: string;
|
|
430
|
+
stack?: string;
|
|
431
|
+
};
|
|
432
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
433
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
434
|
+
stackTraceLimit: number;
|
|
435
|
+
};
|
|
436
|
+
type CStarServerError = InstanceType<typeof CStarServerErrorImpl>;
|
|
437
|
+
declare const CStarFeatureDisabledError: {
|
|
438
|
+
new (messageOrStatus: string | number, body?: ApiErrorBody): {
|
|
439
|
+
readonly feature: string;
|
|
440
|
+
readonly enableUrl: string;
|
|
441
|
+
readonly type: string;
|
|
442
|
+
readonly code: string;
|
|
443
|
+
readonly param?: string;
|
|
444
|
+
readonly docUrl: string;
|
|
445
|
+
readonly requestId?: string;
|
|
446
|
+
readonly statusCode: number;
|
|
447
|
+
name: string;
|
|
448
|
+
message: string;
|
|
449
|
+
stack?: string;
|
|
450
|
+
};
|
|
451
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
452
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
453
|
+
stackTraceLimit: number;
|
|
454
|
+
};
|
|
455
|
+
type CStarFeatureDisabledError = InstanceType<typeof CStarFeatureDisabledErrorImpl>;
|
|
456
|
+
declare const CStarRealtimeUnavailableError: {
|
|
457
|
+
new (message?: string): {
|
|
458
|
+
readonly type: string;
|
|
459
|
+
readonly code: string;
|
|
460
|
+
readonly param?: string;
|
|
461
|
+
readonly docUrl: string;
|
|
462
|
+
readonly requestId?: string;
|
|
463
|
+
readonly statusCode: number;
|
|
464
|
+
name: string;
|
|
465
|
+
message: string;
|
|
466
|
+
stack?: string;
|
|
467
|
+
};
|
|
468
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
469
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
470
|
+
stackTraceLimit: number;
|
|
471
|
+
};
|
|
472
|
+
type CStarRealtimeUnavailableError = InstanceType<typeof CStarRealtimeUnavailableErrorImpl>;
|
|
473
|
+
/**
|
|
474
|
+
* Parse a public-route response (anonymous LibraryClient, CommunityClient,
|
|
475
|
+
* QuickHelpClient, AuthClient) into a typed `CStarError`.
|
|
476
|
+
*
|
|
477
|
+
* Public routes don't always emit the structured `{error: {type, code,
|
|
478
|
+
* doc_url, ...}}` envelope — many emit `{error: 'message string'}` or
|
|
479
|
+
* `{message: '...'}`. This helper normalizes both shapes and dispatches
|
|
480
|
+
* on HTTP status (closes F-026 and F-034 — Library/Auth used to throw
|
|
481
|
+
* plain `Error`).
|
|
482
|
+
*/
|
|
483
|
+
declare function parsePublicError(status: number, body: unknown, fallbackMessage: string): CStarError;
|
|
484
|
+
declare function parseError(statusCode: number, body: {
|
|
485
|
+
error?: ApiErrorBody;
|
|
486
|
+
} | null, retryAfter?: number): CStarError;
|
|
487
|
+
|
|
91
488
|
/**
|
|
92
489
|
* Public knowledge base client. Authentication is optional — supply a
|
|
93
490
|
* publishable key (`pk_test_*` or `pk_live_*`) to switch the data scope
|
|
@@ -155,4 +552,4 @@ declare class LibraryClient {
|
|
|
155
552
|
private fetch;
|
|
156
553
|
}
|
|
157
554
|
|
|
158
|
-
export { type ArticleFeedbackParams, type ArticleFeedbackResult, type Category, type LibraryArticle, type LibraryArticleListParams, LibraryClient, type LibraryConfig, type LibrarySearchParams, type LibrarySearchResult, type LibraryStats };
|
|
555
|
+
export { type ApiErrorBody, type ArticleFeedbackParams, type ArticleFeedbackResult, CStarAuthenticationError, CStarConflictError, CStarError, CStarFeatureDisabledError, CStarNotFoundError, CStarPermissionError, CStarRateLimitError, CStarRealtimeUnavailableError, CStarServerError, CStarValidationError, type Category, ErrorType, type LibraryArticle, type LibraryArticleListParams, LibraryClient, type LibraryConfig, type LibrarySearchParams, type LibrarySearchResult, type LibraryStats, parseError, parsePublicError };
|
package/dist/library/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function normalizeArgs(messageOrStatus, maybeBody, defaults) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
var
|
|
38
|
+
var CStarErrorImpl = class extends Error {
|
|
39
39
|
constructor(messageOrStatus, body) {
|
|
40
40
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body);
|
|
41
41
|
super(resolved.message);
|
|
@@ -48,7 +48,7 @@ var CStarError = class extends Error {
|
|
|
48
48
|
this.statusCode = statusCode;
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
var
|
|
51
|
+
var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
|
|
52
52
|
constructor(messageOrStatus, body) {
|
|
53
53
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
54
54
|
type: ErrorType.AUTHENTICATION_ERROR,
|
|
@@ -59,7 +59,7 @@ var CStarAuthenticationError = class extends CStarError {
|
|
|
59
59
|
this.name = "CStarAuthenticationError";
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
var
|
|
62
|
+
var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
|
|
63
63
|
constructor(messageOrStatus, body, retryAfter) {
|
|
64
64
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
65
65
|
type: ErrorType.RATE_LIMIT_ERROR,
|
|
@@ -71,7 +71,7 @@ var CStarRateLimitError = class extends CStarError {
|
|
|
71
71
|
this.retryAfter = retryAfter ?? 60;
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
var
|
|
74
|
+
var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
|
|
75
75
|
constructor(messageOrStatus, body) {
|
|
76
76
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
77
77
|
type: ErrorType.NOT_FOUND_ERROR,
|
|
@@ -82,7 +82,7 @@ var CStarNotFoundError = class extends CStarError {
|
|
|
82
82
|
this.name = "CStarNotFoundError";
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
var
|
|
85
|
+
var CStarValidationErrorImpl = class extends CStarErrorImpl {
|
|
86
86
|
constructor(messageOrStatus, body) {
|
|
87
87
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
88
88
|
type: ErrorType.INVALID_REQUEST_ERROR,
|
|
@@ -93,7 +93,7 @@ var CStarValidationError = class extends CStarError {
|
|
|
93
93
|
this.name = "CStarValidationError";
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
var
|
|
96
|
+
var CStarPermissionErrorImpl = class extends CStarErrorImpl {
|
|
97
97
|
constructor(messageOrStatus, body) {
|
|
98
98
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
99
99
|
type: ErrorType.PERMISSION_ERROR,
|
|
@@ -104,7 +104,7 @@ var CStarPermissionError = class extends CStarError {
|
|
|
104
104
|
this.name = "CStarPermissionError";
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
|
-
var
|
|
107
|
+
var CStarConflictErrorImpl = class extends CStarErrorImpl {
|
|
108
108
|
constructor(messageOrStatus, body) {
|
|
109
109
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
110
110
|
type: ErrorType.CONFLICT_ERROR,
|
|
@@ -115,7 +115,7 @@ var CStarConflictError = class extends CStarError {
|
|
|
115
115
|
this.name = "CStarConflictError";
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
var
|
|
118
|
+
var CStarServerErrorImpl = class extends CStarErrorImpl {
|
|
119
119
|
constructor(messageOrStatus, body) {
|
|
120
120
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
121
121
|
type: ErrorType.SERVER_ERROR,
|
|
@@ -126,7 +126,7 @@ var CStarServerError = class extends CStarError {
|
|
|
126
126
|
this.name = "CStarServerError";
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
|
-
var
|
|
129
|
+
var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
|
|
130
130
|
constructor(messageOrStatus, body) {
|
|
131
131
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
132
132
|
type: ErrorType.FEATURE_NOT_CONFIGURED,
|
|
@@ -139,6 +139,62 @@ var CStarFeatureDisabledError = class extends CStarError {
|
|
|
139
139
|
this.enableUrl = resolved.enable_url ?? "";
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
+
var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
|
|
143
|
+
constructor(message) {
|
|
144
|
+
const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://cstar.help/developers/sdk/realtime#ssr";
|
|
145
|
+
super(0, {
|
|
146
|
+
type: ErrorType.API_ERROR,
|
|
147
|
+
code: "realtime_unavailable",
|
|
148
|
+
message: resolved,
|
|
149
|
+
doc_url: "https://cstar.help/developers/sdk/realtime#ssr"
|
|
150
|
+
});
|
|
151
|
+
this.name = "CStarRealtimeUnavailableError";
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@cstar.help/js/errors/v1");
|
|
155
|
+
var globalSlot = globalThis;
|
|
156
|
+
var registry = globalSlot[REGISTRY_KEY] ?? (globalSlot[REGISTRY_KEY] = {
|
|
157
|
+
CStarError: CStarErrorImpl,
|
|
158
|
+
CStarAuthenticationError: CStarAuthenticationErrorImpl,
|
|
159
|
+
CStarRateLimitError: CStarRateLimitErrorImpl,
|
|
160
|
+
CStarNotFoundError: CStarNotFoundErrorImpl,
|
|
161
|
+
CStarValidationError: CStarValidationErrorImpl,
|
|
162
|
+
CStarPermissionError: CStarPermissionErrorImpl,
|
|
163
|
+
CStarConflictError: CStarConflictErrorImpl,
|
|
164
|
+
CStarServerError: CStarServerErrorImpl,
|
|
165
|
+
CStarFeatureDisabledError: CStarFeatureDisabledErrorImpl,
|
|
166
|
+
CStarRealtimeUnavailableError: CStarRealtimeUnavailableErrorImpl
|
|
167
|
+
});
|
|
168
|
+
var NAME_FIXES = [
|
|
169
|
+
"CStarError",
|
|
170
|
+
"CStarAuthenticationError",
|
|
171
|
+
"CStarRateLimitError",
|
|
172
|
+
"CStarNotFoundError",
|
|
173
|
+
"CStarValidationError",
|
|
174
|
+
"CStarPermissionError",
|
|
175
|
+
"CStarConflictError",
|
|
176
|
+
"CStarServerError",
|
|
177
|
+
"CStarFeatureDisabledError",
|
|
178
|
+
"CStarRealtimeUnavailableError"
|
|
179
|
+
];
|
|
180
|
+
for (const key of NAME_FIXES) {
|
|
181
|
+
if (registry[key].name !== key) {
|
|
182
|
+
Object.defineProperty(registry[key], "name", {
|
|
183
|
+
value: key,
|
|
184
|
+
configurable: true
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
var CStarError = registry.CStarError;
|
|
189
|
+
var CStarAuthenticationError = registry.CStarAuthenticationError;
|
|
190
|
+
var CStarRateLimitError = registry.CStarRateLimitError;
|
|
191
|
+
var CStarNotFoundError = registry.CStarNotFoundError;
|
|
192
|
+
var CStarValidationError = registry.CStarValidationError;
|
|
193
|
+
var CStarPermissionError = registry.CStarPermissionError;
|
|
194
|
+
var CStarConflictError = registry.CStarConflictError;
|
|
195
|
+
var CStarServerError = registry.CStarServerError;
|
|
196
|
+
var CStarFeatureDisabledError = registry.CStarFeatureDisabledError;
|
|
197
|
+
var CStarRealtimeUnavailableError = registry.CStarRealtimeUnavailableError;
|
|
142
198
|
function parsePublicError(status, body, fallbackMessage) {
|
|
143
199
|
const obj = body && typeof body === "object" ? body : null;
|
|
144
200
|
const errVal = obj?.error;
|
|
@@ -375,5 +431,18 @@ var LibraryClient = class {
|
|
|
375
431
|
}
|
|
376
432
|
};
|
|
377
433
|
export {
|
|
378
|
-
|
|
434
|
+
CStarAuthenticationError,
|
|
435
|
+
CStarConflictError,
|
|
436
|
+
CStarError,
|
|
437
|
+
CStarFeatureDisabledError,
|
|
438
|
+
CStarNotFoundError,
|
|
439
|
+
CStarPermissionError,
|
|
440
|
+
CStarRateLimitError,
|
|
441
|
+
CStarRealtimeUnavailableError,
|
|
442
|
+
CStarServerError,
|
|
443
|
+
CStarValidationError,
|
|
444
|
+
ErrorType,
|
|
445
|
+
LibraryClient,
|
|
446
|
+
parseError,
|
|
447
|
+
parsePublicError
|
|
379
448
|
};
|