@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,8 +20,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/quickhelp/index.ts
21
21
  var quickhelp_exports = {};
22
22
  __export(quickhelp_exports, {
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,
23
34
  QuickHelpClient: () => QuickHelpClient,
24
- QuickHelpError: () => QuickHelpError
35
+ QuickHelpError: () => QuickHelpError,
36
+ parseError: () => parseError,
37
+ parsePublicError: () => parsePublicError
25
38
  });
26
39
  module.exports = __toCommonJS(quickhelp_exports);
27
40
 
@@ -62,7 +75,7 @@ function normalizeArgs(messageOrStatus, maybeBody, defaults) {
62
75
  }
63
76
  };
64
77
  }
65
- var CStarError = class extends Error {
78
+ var CStarErrorImpl = class extends Error {
66
79
  constructor(messageOrStatus, body) {
67
80
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body);
68
81
  super(resolved.message);
@@ -75,7 +88,7 @@ var CStarError = class extends Error {
75
88
  this.statusCode = statusCode;
76
89
  }
77
90
  };
78
- var CStarAuthenticationError = class extends CStarError {
91
+ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
79
92
  constructor(messageOrStatus, body) {
80
93
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
81
94
  type: ErrorType.AUTHENTICATION_ERROR,
@@ -86,7 +99,7 @@ var CStarAuthenticationError = class extends CStarError {
86
99
  this.name = "CStarAuthenticationError";
87
100
  }
88
101
  };
89
- var CStarRateLimitError = class extends CStarError {
102
+ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
90
103
  constructor(messageOrStatus, body, retryAfter) {
91
104
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
92
105
  type: ErrorType.RATE_LIMIT_ERROR,
@@ -98,7 +111,7 @@ var CStarRateLimitError = class extends CStarError {
98
111
  this.retryAfter = retryAfter ?? 60;
99
112
  }
100
113
  };
101
- var CStarNotFoundError = class extends CStarError {
114
+ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
102
115
  constructor(messageOrStatus, body) {
103
116
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
104
117
  type: ErrorType.NOT_FOUND_ERROR,
@@ -109,7 +122,7 @@ var CStarNotFoundError = class extends CStarError {
109
122
  this.name = "CStarNotFoundError";
110
123
  }
111
124
  };
112
- var CStarValidationError = class extends CStarError {
125
+ var CStarValidationErrorImpl = class extends CStarErrorImpl {
113
126
  constructor(messageOrStatus, body) {
114
127
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
115
128
  type: ErrorType.INVALID_REQUEST_ERROR,
@@ -120,7 +133,7 @@ var CStarValidationError = class extends CStarError {
120
133
  this.name = "CStarValidationError";
121
134
  }
122
135
  };
123
- var CStarPermissionError = class extends CStarError {
136
+ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
124
137
  constructor(messageOrStatus, body) {
125
138
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
126
139
  type: ErrorType.PERMISSION_ERROR,
@@ -131,7 +144,7 @@ var CStarPermissionError = class extends CStarError {
131
144
  this.name = "CStarPermissionError";
132
145
  }
133
146
  };
134
- var CStarConflictError = class extends CStarError {
147
+ var CStarConflictErrorImpl = class extends CStarErrorImpl {
135
148
  constructor(messageOrStatus, body) {
136
149
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
137
150
  type: ErrorType.CONFLICT_ERROR,
@@ -142,7 +155,7 @@ var CStarConflictError = class extends CStarError {
142
155
  this.name = "CStarConflictError";
143
156
  }
144
157
  };
145
- var CStarServerError = class extends CStarError {
158
+ var CStarServerErrorImpl = class extends CStarErrorImpl {
146
159
  constructor(messageOrStatus, body) {
147
160
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
148
161
  type: ErrorType.SERVER_ERROR,
@@ -153,7 +166,7 @@ var CStarServerError = class extends CStarError {
153
166
  this.name = "CStarServerError";
154
167
  }
155
168
  };
156
- var CStarFeatureDisabledError = class extends CStarError {
169
+ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
157
170
  constructor(messageOrStatus, body) {
158
171
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
159
172
  type: ErrorType.FEATURE_NOT_CONFIGURED,
@@ -166,6 +179,102 @@ var CStarFeatureDisabledError = class extends CStarError {
166
179
  this.enableUrl = resolved.enable_url ?? "";
167
180
  }
168
181
  };
182
+ var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
183
+ constructor(message) {
184
+ 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";
185
+ super(0, {
186
+ type: ErrorType.API_ERROR,
187
+ code: "realtime_unavailable",
188
+ message: resolved,
189
+ doc_url: "https://cstar.help/developers/sdk/realtime#ssr"
190
+ });
191
+ this.name = "CStarRealtimeUnavailableError";
192
+ }
193
+ };
194
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@cstar.help/js/errors/v1");
195
+ var globalSlot = globalThis;
196
+ var registry = globalSlot[REGISTRY_KEY] ?? (globalSlot[REGISTRY_KEY] = {
197
+ CStarError: CStarErrorImpl,
198
+ CStarAuthenticationError: CStarAuthenticationErrorImpl,
199
+ CStarRateLimitError: CStarRateLimitErrorImpl,
200
+ CStarNotFoundError: CStarNotFoundErrorImpl,
201
+ CStarValidationError: CStarValidationErrorImpl,
202
+ CStarPermissionError: CStarPermissionErrorImpl,
203
+ CStarConflictError: CStarConflictErrorImpl,
204
+ CStarServerError: CStarServerErrorImpl,
205
+ CStarFeatureDisabledError: CStarFeatureDisabledErrorImpl,
206
+ CStarRealtimeUnavailableError: CStarRealtimeUnavailableErrorImpl
207
+ });
208
+ var NAME_FIXES = [
209
+ "CStarError",
210
+ "CStarAuthenticationError",
211
+ "CStarRateLimitError",
212
+ "CStarNotFoundError",
213
+ "CStarValidationError",
214
+ "CStarPermissionError",
215
+ "CStarConflictError",
216
+ "CStarServerError",
217
+ "CStarFeatureDisabledError",
218
+ "CStarRealtimeUnavailableError"
219
+ ];
220
+ for (const key of NAME_FIXES) {
221
+ if (registry[key].name !== key) {
222
+ Object.defineProperty(registry[key], "name", {
223
+ value: key,
224
+ configurable: true
225
+ });
226
+ }
227
+ }
228
+ var CStarError = registry.CStarError;
229
+ var CStarAuthenticationError = registry.CStarAuthenticationError;
230
+ var CStarRateLimitError = registry.CStarRateLimitError;
231
+ var CStarNotFoundError = registry.CStarNotFoundError;
232
+ var CStarValidationError = registry.CStarValidationError;
233
+ var CStarPermissionError = registry.CStarPermissionError;
234
+ var CStarConflictError = registry.CStarConflictError;
235
+ var CStarServerError = registry.CStarServerError;
236
+ var CStarFeatureDisabledError = registry.CStarFeatureDisabledError;
237
+ var CStarRealtimeUnavailableError = registry.CStarRealtimeUnavailableError;
238
+ function parsePublicError(status, body, fallbackMessage) {
239
+ const obj = body && typeof body === "object" ? body : null;
240
+ const errVal = obj?.error;
241
+ let message = fallbackMessage;
242
+ let structured = null;
243
+ if (typeof errVal === "string") {
244
+ message = errVal;
245
+ } else if (errVal && typeof errVal === "object") {
246
+ const e = errVal;
247
+ if (typeof e.message === "string") message = e.message;
248
+ structured = {
249
+ type: typeof e.type === "string" ? e.type : ErrorType.API_ERROR,
250
+ code: typeof e.code === "string" ? e.code : "api_error",
251
+ message,
252
+ param: typeof e.param === "string" ? e.param : void 0,
253
+ doc_url: typeof e.doc_url === "string" ? e.doc_url : DEFAULT_DOC_URL,
254
+ request_id: typeof e.request_id === "string" ? e.request_id : void 0,
255
+ feature: typeof e.feature === "string" ? e.feature : void 0,
256
+ enable_url: typeof e.enable_url === "string" ? e.enable_url : void 0
257
+ };
258
+ } else if (typeof obj?.message === "string") {
259
+ message = obj.message;
260
+ }
261
+ const errorBody = structured ?? {
262
+ type: ErrorType.API_ERROR,
263
+ code: status >= 500 ? "server_error" : "request_failed",
264
+ message,
265
+ doc_url: DEFAULT_DOC_URL
266
+ };
267
+ return parseError(status, { error: errorBody });
268
+ }
269
+ var STATUS_TO_CLASS = {
270
+ 400: CStarValidationError,
271
+ 401: CStarAuthenticationError,
272
+ 403: CStarPermissionError,
273
+ 404: CStarNotFoundError,
274
+ 409: CStarConflictError,
275
+ 422: CStarValidationError,
276
+ 429: CStarRateLimitError
277
+ };
169
278
  var TYPE_TO_CLASS = {
170
279
  [ErrorType.AUTHENTICATION_ERROR]: CStarAuthenticationError,
171
280
  [ErrorType.PERMISSION_ERROR]: CStarPermissionError,
@@ -176,6 +285,27 @@ var TYPE_TO_CLASS = {
176
285
  [ErrorType.SERVER_ERROR]: CStarServerError,
177
286
  [ErrorType.FEATURE_NOT_CONFIGURED]: CStarFeatureDisabledError
178
287
  };
288
+ function parseError(statusCode, body, retryAfter) {
289
+ const errorBody = body?.error ?? {
290
+ type: ErrorType.API_ERROR,
291
+ code: "unknown_error",
292
+ message: `Request failed with status ${statusCode}`,
293
+ doc_url: DEFAULT_DOC_URL
294
+ };
295
+ if (statusCode === 429) {
296
+ return new CStarRateLimitError(statusCode, errorBody, retryAfter ?? 60);
297
+ }
298
+ const StatusCls = STATUS_TO_CLASS[statusCode];
299
+ if (StatusCls) {
300
+ return new StatusCls(statusCode, errorBody);
301
+ }
302
+ const TypeCls = TYPE_TO_CLASS[errorBody.type];
303
+ if (TypeCls) {
304
+ return new TypeCls(statusCode, errorBody);
305
+ }
306
+ if (statusCode >= 500) return new CStarServerError(statusCode, errorBody);
307
+ return new CStarError(statusCode, errorBody);
308
+ }
179
309
 
180
310
  // src/quickhelp/index.ts
181
311
  var DEFAULT_BASE_URL = "https://www.cstar.help";
@@ -310,6 +440,19 @@ function parseRetryAfter(header) {
310
440
  }
311
441
  // Annotate the CommonJS export names for ESM import in node:
312
442
  0 && (module.exports = {
443
+ CStarAuthenticationError,
444
+ CStarConflictError,
445
+ CStarError,
446
+ CStarFeatureDisabledError,
447
+ CStarNotFoundError,
448
+ CStarPermissionError,
449
+ CStarRateLimitError,
450
+ CStarRealtimeUnavailableError,
451
+ CStarServerError,
452
+ CStarValidationError,
453
+ ErrorType,
313
454
  QuickHelpClient,
314
- QuickHelpError
455
+ QuickHelpError,
456
+ parseError,
457
+ parsePublicError
315
458
  });
@@ -55,6 +55,403 @@ interface QuickHelpAskResult {
55
55
  turnNumber: number;
56
56
  }
57
57
 
58
+ /**
59
+ * Error classes for the cStar SDK.
60
+ *
61
+ * NEW-v3-01 — Cross-subpath instanceof identity.
62
+ *
63
+ * Each public subpath (`/library`, `/auth`, `/community`, `/quickhelp`, ...)
64
+ * is bundled as a separate tsup entry with `splitting: false`, so each one
65
+ * carries its own copy of this module. Without deduplication, errors thrown
66
+ * by `LibraryClient` carry the LibraryClient-bundled `CStarError` class —
67
+ * not the one a consumer imports from `@cstar.help/js`. That makes
68
+ * `instanceof CStarError` checks fail silently, invalidating every "did the
69
+ * SDK throw a typed cStar error?" branch in user code.
70
+ *
71
+ * Fix: register each class on a `Symbol.for(...)` slot of `globalThis`. The
72
+ * symbol is realm-shared, so every bundled copy of this module resolves to
73
+ * the SAME class identity at runtime — the first copy to load wins, and all
74
+ * subsequent copies surface the canonical class via the same slot. The
75
+ * inline `Impl` definitions are only used as the seed for the very first
76
+ * copy to register. Internal `parseError` / `parsePublicError` reference the
77
+ * EXPORTED canonical names so instances they construct also land on the
78
+ * canonical class.
79
+ */
80
+ /** Error type constants matching the cStar API. */
81
+ declare const ErrorType: {
82
+ readonly AUTHENTICATION_ERROR: "authentication_error";
83
+ readonly PERMISSION_ERROR: "permission_error";
84
+ readonly INVALID_REQUEST_ERROR: "invalid_request_error";
85
+ readonly NOT_FOUND_ERROR: "not_found_error";
86
+ readonly CONFLICT_ERROR: "conflict_error";
87
+ readonly RATE_LIMIT_ERROR: "rate_limit_error";
88
+ readonly FEATURE_NOT_CONFIGURED: "feature_not_configured";
89
+ readonly API_ERROR: "api_error";
90
+ readonly SERVER_ERROR: "server_error";
91
+ };
92
+ /** Shape of the error object returned by the cStar API. */
93
+ interface ApiErrorBody {
94
+ type: string;
95
+ code: string;
96
+ message: string;
97
+ param?: string;
98
+ doc_url: string;
99
+ request_id?: string;
100
+ feature?: string;
101
+ enable_url?: string;
102
+ }
103
+ /** Base error class for all cStar API errors. */
104
+ declare const CStarErrorImpl: {
105
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
106
+ readonly type: string;
107
+ readonly code: string;
108
+ readonly param?: string;
109
+ readonly docUrl: string;
110
+ readonly requestId?: string;
111
+ readonly statusCode: number;
112
+ name: string;
113
+ message: string;
114
+ stack?: string;
115
+ };
116
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
117
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
118
+ stackTraceLimit: number;
119
+ };
120
+ declare const CStarAuthenticationErrorImpl: {
121
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
122
+ readonly type: string;
123
+ readonly code: string;
124
+ readonly param?: string;
125
+ readonly docUrl: string;
126
+ readonly requestId?: string;
127
+ readonly statusCode: number;
128
+ name: string;
129
+ message: string;
130
+ stack?: string;
131
+ };
132
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
133
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
134
+ stackTraceLimit: number;
135
+ };
136
+ declare const CStarRateLimitErrorImpl: {
137
+ new (messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number): {
138
+ readonly retryAfter: number;
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 CStarNotFoundErrorImpl: {
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 CStarValidationErrorImpl: {
170
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
171
+ readonly type: string;
172
+ readonly code: string;
173
+ readonly param?: string;
174
+ readonly docUrl: string;
175
+ readonly requestId?: string;
176
+ readonly statusCode: number;
177
+ name: string;
178
+ message: string;
179
+ stack?: string;
180
+ };
181
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
182
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
183
+ stackTraceLimit: number;
184
+ };
185
+ declare const CStarPermissionErrorImpl: {
186
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
187
+ readonly type: string;
188
+ readonly code: string;
189
+ readonly param?: string;
190
+ readonly docUrl: string;
191
+ readonly requestId?: string;
192
+ readonly statusCode: number;
193
+ name: string;
194
+ message: string;
195
+ stack?: string;
196
+ };
197
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
198
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
199
+ stackTraceLimit: number;
200
+ };
201
+ declare const CStarConflictErrorImpl: {
202
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
203
+ readonly type: string;
204
+ readonly code: string;
205
+ readonly param?: string;
206
+ readonly docUrl: string;
207
+ readonly requestId?: string;
208
+ readonly statusCode: number;
209
+ name: string;
210
+ message: string;
211
+ stack?: string;
212
+ };
213
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
214
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
215
+ stackTraceLimit: number;
216
+ };
217
+ declare const CStarServerErrorImpl: {
218
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
219
+ readonly type: string;
220
+ readonly code: string;
221
+ readonly param?: string;
222
+ readonly docUrl: string;
223
+ readonly requestId?: string;
224
+ readonly statusCode: number;
225
+ name: string;
226
+ message: string;
227
+ stack?: string;
228
+ };
229
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
230
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
231
+ stackTraceLimit: number;
232
+ };
233
+ declare const CStarFeatureDisabledErrorImpl: {
234
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
235
+ readonly feature: string;
236
+ readonly enableUrl: string;
237
+ readonly type: string;
238
+ readonly code: string;
239
+ readonly param?: string;
240
+ readonly docUrl: string;
241
+ readonly requestId?: string;
242
+ readonly statusCode: number;
243
+ name: string;
244
+ message: string;
245
+ stack?: string;
246
+ };
247
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
248
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
249
+ stackTraceLimit: number;
250
+ };
251
+ declare const CStarRealtimeUnavailableErrorImpl: {
252
+ new (message?: string): {
253
+ readonly type: string;
254
+ readonly code: string;
255
+ readonly param?: string;
256
+ readonly docUrl: string;
257
+ readonly requestId?: string;
258
+ readonly statusCode: number;
259
+ name: string;
260
+ message: string;
261
+ stack?: string;
262
+ };
263
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
264
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
265
+ stackTraceLimit: number;
266
+ };
267
+ declare const CStarError: {
268
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
269
+ readonly type: string;
270
+ readonly code: string;
271
+ readonly param?: string;
272
+ readonly docUrl: string;
273
+ readonly requestId?: string;
274
+ readonly statusCode: number;
275
+ name: string;
276
+ message: string;
277
+ stack?: string;
278
+ };
279
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
280
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
281
+ stackTraceLimit: number;
282
+ };
283
+ type CStarError = InstanceType<typeof CStarErrorImpl>;
284
+ declare const CStarAuthenticationError: {
285
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
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
+ type CStarAuthenticationError = InstanceType<typeof CStarAuthenticationErrorImpl>;
301
+ declare const CStarRateLimitError: {
302
+ new (messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number): {
303
+ readonly retryAfter: number;
304
+ readonly type: string;
305
+ readonly code: string;
306
+ readonly param?: string;
307
+ readonly docUrl: string;
308
+ readonly requestId?: string;
309
+ readonly statusCode: number;
310
+ name: string;
311
+ message: string;
312
+ stack?: string;
313
+ };
314
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
315
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
316
+ stackTraceLimit: number;
317
+ };
318
+ type CStarRateLimitError = InstanceType<typeof CStarRateLimitErrorImpl>;
319
+ declare const CStarNotFoundError: {
320
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
321
+ readonly type: string;
322
+ readonly code: string;
323
+ readonly param?: string;
324
+ readonly docUrl: string;
325
+ readonly requestId?: string;
326
+ readonly statusCode: number;
327
+ name: string;
328
+ message: string;
329
+ stack?: string;
330
+ };
331
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
332
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
333
+ stackTraceLimit: number;
334
+ };
335
+ type CStarNotFoundError = InstanceType<typeof CStarNotFoundErrorImpl>;
336
+ declare const CStarValidationError: {
337
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
338
+ readonly type: string;
339
+ readonly code: string;
340
+ readonly param?: string;
341
+ readonly docUrl: string;
342
+ readonly requestId?: string;
343
+ readonly statusCode: number;
344
+ name: string;
345
+ message: string;
346
+ stack?: string;
347
+ };
348
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
349
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
350
+ stackTraceLimit: number;
351
+ };
352
+ type CStarValidationError = InstanceType<typeof CStarValidationErrorImpl>;
353
+ declare const CStarPermissionError: {
354
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
355
+ readonly type: string;
356
+ readonly code: string;
357
+ readonly param?: string;
358
+ readonly docUrl: string;
359
+ readonly requestId?: string;
360
+ readonly statusCode: number;
361
+ name: string;
362
+ message: string;
363
+ stack?: string;
364
+ };
365
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
366
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
367
+ stackTraceLimit: number;
368
+ };
369
+ type CStarPermissionError = InstanceType<typeof CStarPermissionErrorImpl>;
370
+ declare const CStarConflictError: {
371
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
372
+ readonly type: string;
373
+ readonly code: string;
374
+ readonly param?: string;
375
+ readonly docUrl: string;
376
+ readonly requestId?: string;
377
+ readonly statusCode: number;
378
+ name: string;
379
+ message: string;
380
+ stack?: string;
381
+ };
382
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
383
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
384
+ stackTraceLimit: number;
385
+ };
386
+ type CStarConflictError = InstanceType<typeof CStarConflictErrorImpl>;
387
+ declare const CStarServerError: {
388
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
389
+ readonly type: string;
390
+ readonly code: string;
391
+ readonly param?: string;
392
+ readonly docUrl: string;
393
+ readonly requestId?: string;
394
+ readonly statusCode: number;
395
+ name: string;
396
+ message: string;
397
+ stack?: string;
398
+ };
399
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
400
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
401
+ stackTraceLimit: number;
402
+ };
403
+ type CStarServerError = InstanceType<typeof CStarServerErrorImpl>;
404
+ declare const CStarFeatureDisabledError: {
405
+ new (messageOrStatus: string | number, body?: ApiErrorBody): {
406
+ readonly feature: string;
407
+ readonly enableUrl: string;
408
+ readonly type: string;
409
+ readonly code: string;
410
+ readonly param?: string;
411
+ readonly docUrl: string;
412
+ readonly requestId?: string;
413
+ readonly statusCode: number;
414
+ name: string;
415
+ message: string;
416
+ stack?: string;
417
+ };
418
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
419
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
420
+ stackTraceLimit: number;
421
+ };
422
+ type CStarFeatureDisabledError = InstanceType<typeof CStarFeatureDisabledErrorImpl>;
423
+ declare const CStarRealtimeUnavailableError: {
424
+ new (message?: string): {
425
+ readonly type: string;
426
+ readonly code: string;
427
+ readonly param?: string;
428
+ readonly docUrl: string;
429
+ readonly requestId?: string;
430
+ readonly statusCode: number;
431
+ name: string;
432
+ message: string;
433
+ stack?: string;
434
+ };
435
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
436
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
437
+ stackTraceLimit: number;
438
+ };
439
+ type CStarRealtimeUnavailableError = InstanceType<typeof CStarRealtimeUnavailableErrorImpl>;
440
+ /**
441
+ * Parse a public-route response (anonymous LibraryClient, CommunityClient,
442
+ * QuickHelpClient, AuthClient) into a typed `CStarError`.
443
+ *
444
+ * Public routes don't always emit the structured `{error: {type, code,
445
+ * doc_url, ...}}` envelope — many emit `{error: 'message string'}` or
446
+ * `{message: '...'}`. This helper normalizes both shapes and dispatches
447
+ * on HTTP status (closes F-026 and F-034 — Library/Auth used to throw
448
+ * plain `Error`).
449
+ */
450
+ declare function parsePublicError(status: number, body: unknown, fallbackMessage: string): CStarError;
451
+ declare function parseError(statusCode: number, body: {
452
+ error?: ApiErrorBody;
453
+ } | null, retryAfter?: number): CStarError;
454
+
58
455
  /**
59
456
  * Quick Help — anonymous AI Q&A client.
60
457
  *
@@ -127,4 +524,4 @@ declare class QuickHelpError extends Error {
127
524
  });
128
525
  }
129
526
 
130
- export { type QuickHelpAskParams, type QuickHelpAskResult, QuickHelpClient, type QuickHelpConfig, QuickHelpError, type QuickHelpPublicConfig, type QuickHelpTurnOutcome };
527
+ export { type ApiErrorBody, CStarAuthenticationError, CStarConflictError, CStarError, CStarFeatureDisabledError, CStarNotFoundError, CStarPermissionError, CStarRateLimitError, CStarRealtimeUnavailableError, CStarServerError, CStarValidationError, ErrorType, type QuickHelpAskParams, type QuickHelpAskResult, QuickHelpClient, type QuickHelpConfig, QuickHelpError, type QuickHelpPublicConfig, type QuickHelpTurnOutcome, parseError, parsePublicError };