@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.
@@ -20,7 +20,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/library/index.ts
21
21
  var library_exports = {};
22
22
  __export(library_exports, {
23
- LibraryClient: () => LibraryClient
23
+ CStarAuthenticationError: () => CStarAuthenticationError,
24
+ CStarConflictError: () => CStarConflictError,
25
+ CStarError: () => CStarError,
26
+ CStarFeatureDisabledError: () => CStarFeatureDisabledError,
27
+ CStarNotFoundError: () => CStarNotFoundError,
28
+ CStarPermissionError: () => CStarPermissionError,
29
+ CStarRateLimitError: () => CStarRateLimitError,
30
+ CStarRealtimeUnavailableError: () => CStarRealtimeUnavailableError,
31
+ CStarServerError: () => CStarServerError,
32
+ CStarValidationError: () => CStarValidationError,
33
+ ErrorType: () => ErrorType,
34
+ LibraryClient: () => LibraryClient,
35
+ parseError: () => parseError,
36
+ parsePublicError: () => parsePublicError
24
37
  });
25
38
  module.exports = __toCommonJS(library_exports);
26
39
 
@@ -61,7 +74,7 @@ function normalizeArgs(messageOrStatus, maybeBody, defaults) {
61
74
  }
62
75
  };
63
76
  }
64
- var CStarError = class extends Error {
77
+ var CStarErrorImpl = class extends Error {
65
78
  constructor(messageOrStatus, body) {
66
79
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body);
67
80
  super(resolved.message);
@@ -74,7 +87,7 @@ var CStarError = class extends Error {
74
87
  this.statusCode = statusCode;
75
88
  }
76
89
  };
77
- var CStarAuthenticationError = class extends CStarError {
90
+ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
78
91
  constructor(messageOrStatus, body) {
79
92
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
80
93
  type: ErrorType.AUTHENTICATION_ERROR,
@@ -85,7 +98,7 @@ var CStarAuthenticationError = class extends CStarError {
85
98
  this.name = "CStarAuthenticationError";
86
99
  }
87
100
  };
88
- var CStarRateLimitError = class extends CStarError {
101
+ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
89
102
  constructor(messageOrStatus, body, retryAfter) {
90
103
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
91
104
  type: ErrorType.RATE_LIMIT_ERROR,
@@ -97,7 +110,7 @@ var CStarRateLimitError = class extends CStarError {
97
110
  this.retryAfter = retryAfter ?? 60;
98
111
  }
99
112
  };
100
- var CStarNotFoundError = class extends CStarError {
113
+ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
101
114
  constructor(messageOrStatus, body) {
102
115
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
103
116
  type: ErrorType.NOT_FOUND_ERROR,
@@ -108,7 +121,7 @@ var CStarNotFoundError = class extends CStarError {
108
121
  this.name = "CStarNotFoundError";
109
122
  }
110
123
  };
111
- var CStarValidationError = class extends CStarError {
124
+ var CStarValidationErrorImpl = class extends CStarErrorImpl {
112
125
  constructor(messageOrStatus, body) {
113
126
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
114
127
  type: ErrorType.INVALID_REQUEST_ERROR,
@@ -119,7 +132,7 @@ var CStarValidationError = class extends CStarError {
119
132
  this.name = "CStarValidationError";
120
133
  }
121
134
  };
122
- var CStarPermissionError = class extends CStarError {
135
+ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
123
136
  constructor(messageOrStatus, body) {
124
137
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
125
138
  type: ErrorType.PERMISSION_ERROR,
@@ -130,7 +143,7 @@ var CStarPermissionError = class extends CStarError {
130
143
  this.name = "CStarPermissionError";
131
144
  }
132
145
  };
133
- var CStarConflictError = class extends CStarError {
146
+ var CStarConflictErrorImpl = class extends CStarErrorImpl {
134
147
  constructor(messageOrStatus, body) {
135
148
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
136
149
  type: ErrorType.CONFLICT_ERROR,
@@ -141,7 +154,7 @@ var CStarConflictError = class extends CStarError {
141
154
  this.name = "CStarConflictError";
142
155
  }
143
156
  };
144
- var CStarServerError = class extends CStarError {
157
+ var CStarServerErrorImpl = class extends CStarErrorImpl {
145
158
  constructor(messageOrStatus, body) {
146
159
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
147
160
  type: ErrorType.SERVER_ERROR,
@@ -152,7 +165,7 @@ var CStarServerError = class extends CStarError {
152
165
  this.name = "CStarServerError";
153
166
  }
154
167
  };
155
- var CStarFeatureDisabledError = class extends CStarError {
168
+ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
156
169
  constructor(messageOrStatus, body) {
157
170
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
158
171
  type: ErrorType.FEATURE_NOT_CONFIGURED,
@@ -165,6 +178,62 @@ var CStarFeatureDisabledError = class extends CStarError {
165
178
  this.enableUrl = resolved.enable_url ?? "";
166
179
  }
167
180
  };
181
+ var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
182
+ constructor(message) {
183
+ 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";
184
+ super(0, {
185
+ type: ErrorType.API_ERROR,
186
+ code: "realtime_unavailable",
187
+ message: resolved,
188
+ doc_url: "https://cstar.help/developers/sdk/realtime#ssr"
189
+ });
190
+ this.name = "CStarRealtimeUnavailableError";
191
+ }
192
+ };
193
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@cstar.help/js/errors/v1");
194
+ var globalSlot = globalThis;
195
+ var registry = globalSlot[REGISTRY_KEY] ?? (globalSlot[REGISTRY_KEY] = {
196
+ CStarError: CStarErrorImpl,
197
+ CStarAuthenticationError: CStarAuthenticationErrorImpl,
198
+ CStarRateLimitError: CStarRateLimitErrorImpl,
199
+ CStarNotFoundError: CStarNotFoundErrorImpl,
200
+ CStarValidationError: CStarValidationErrorImpl,
201
+ CStarPermissionError: CStarPermissionErrorImpl,
202
+ CStarConflictError: CStarConflictErrorImpl,
203
+ CStarServerError: CStarServerErrorImpl,
204
+ CStarFeatureDisabledError: CStarFeatureDisabledErrorImpl,
205
+ CStarRealtimeUnavailableError: CStarRealtimeUnavailableErrorImpl
206
+ });
207
+ var NAME_FIXES = [
208
+ "CStarError",
209
+ "CStarAuthenticationError",
210
+ "CStarRateLimitError",
211
+ "CStarNotFoundError",
212
+ "CStarValidationError",
213
+ "CStarPermissionError",
214
+ "CStarConflictError",
215
+ "CStarServerError",
216
+ "CStarFeatureDisabledError",
217
+ "CStarRealtimeUnavailableError"
218
+ ];
219
+ for (const key of NAME_FIXES) {
220
+ if (registry[key].name !== key) {
221
+ Object.defineProperty(registry[key], "name", {
222
+ value: key,
223
+ configurable: true
224
+ });
225
+ }
226
+ }
227
+ var CStarError = registry.CStarError;
228
+ var CStarAuthenticationError = registry.CStarAuthenticationError;
229
+ var CStarRateLimitError = registry.CStarRateLimitError;
230
+ var CStarNotFoundError = registry.CStarNotFoundError;
231
+ var CStarValidationError = registry.CStarValidationError;
232
+ var CStarPermissionError = registry.CStarPermissionError;
233
+ var CStarConflictError = registry.CStarConflictError;
234
+ var CStarServerError = registry.CStarServerError;
235
+ var CStarFeatureDisabledError = registry.CStarFeatureDisabledError;
236
+ var CStarRealtimeUnavailableError = registry.CStarRealtimeUnavailableError;
168
237
  function parsePublicError(status, body, fallbackMessage) {
169
238
  const obj = body && typeof body === "object" ? body : null;
170
239
  const errVal = obj?.error;
@@ -402,5 +471,18 @@ var LibraryClient = class {
402
471
  };
403
472
  // Annotate the CommonJS export names for ESM import in node:
404
473
  0 && (module.exports = {
405
- LibraryClient
474
+ CStarAuthenticationError,
475
+ CStarConflictError,
476
+ CStarError,
477
+ CStarFeatureDisabledError,
478
+ CStarNotFoundError,
479
+ CStarPermissionError,
480
+ CStarRateLimitError,
481
+ CStarRealtimeUnavailableError,
482
+ CStarServerError,
483
+ CStarValidationError,
484
+ ErrorType,
485
+ LibraryClient,
486
+ parseError,
487
+ parsePublicError
406
488
  });
@@ -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 };