@cstar.help/js 0.16.1 → 0.17.2
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/README.md +100 -60
- package/dist/auth/index.d.cts +3 -398
- package/dist/auth/index.d.ts +3 -398
- package/dist/chat/index.cjs +427 -101
- package/dist/chat/index.d.cts +44 -92
- package/dist/chat/index.d.ts +44 -92
- package/dist/chat/index.js +427 -101
- package/dist/community/index.d.cts +4 -586
- package/dist/community/index.d.ts +4 -586
- package/dist/errors-b5A4wfAg.d.cts +398 -0
- package/dist/errors-b5A4wfAg.d.ts +398 -0
- package/dist/index.cjs +42 -23
- package/dist/index.d.cts +24 -802
- package/dist/index.d.ts +24 -802
- package/dist/index.js +42 -23
- package/dist/library/index.d.cts +3 -398
- package/dist/library/index.d.ts +3 -398
- package/dist/quickhelp/index.d.cts +3 -398
- package/dist/quickhelp/index.d.ts +3 -398
- package/dist/types-DF7GprCV.d.cts +190 -0
- package/dist/types-DF7GprCV.d.ts +190 -0
- package/dist/webhook/index.d.cts +2 -434
- package/dist/webhook/index.d.ts +2 -434
- package/dist/webhook/node.d.cts +4 -450
- package/dist/webhook/node.d.ts +4 -450
- package/dist/webhookEvents-1N2i2GcQ.d.cts +449 -0
- package/dist/webhookEvents-1N2i2GcQ.d.ts +449 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -237,7 +237,7 @@ function parseError(statusCode, body, retryAfter) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
// src/client.ts
|
|
240
|
-
var SDK_VERSION = "0.
|
|
240
|
+
var SDK_VERSION = "0.17.2";
|
|
241
241
|
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
242
242
|
var DEFAULT_API_VERSION = "2026-03-01";
|
|
243
243
|
var DEFAULT_MAX_RETRIES = 3;
|
|
@@ -282,7 +282,8 @@ var HttpClient = class {
|
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
284
|
* Make an authenticated request to the cStar API.
|
|
285
|
-
* Automatically retries
|
|
285
|
+
* Automatically retries rate limits and retry-safe failures. POST/PATCH
|
|
286
|
+
* network and 5xx failures require an idempotency key to avoid duplicate writes.
|
|
286
287
|
*/
|
|
287
288
|
async request(method, path, options) {
|
|
288
289
|
return this._sendRequest(method, this.buildUrl(path, options?.query), options);
|
|
@@ -313,6 +314,7 @@ var HttpClient = class {
|
|
|
313
314
|
async _sendRequest(method, url, options) {
|
|
314
315
|
const headers = this.buildHeaders(options?.idempotencyKey);
|
|
315
316
|
const body = options?.body ? JSON.stringify(options.body) : void 0;
|
|
317
|
+
const canRetryAmbiguousFailure = !["POST", "PATCH"].includes(method.toUpperCase()) || !!options?.idempotencyKey;
|
|
316
318
|
let lastError = null;
|
|
317
319
|
for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
|
|
318
320
|
if (attempt > 0 && lastError) {
|
|
@@ -336,7 +338,7 @@ var HttpClient = class {
|
|
|
336
338
|
message: `Network request failed: ${networkErr.message}`,
|
|
337
339
|
doc_url: "https://www.cstar.help/developers/errors#connection-errors"
|
|
338
340
|
});
|
|
339
|
-
if (attempt < this.config.maxRetries) continue;
|
|
341
|
+
if (canRetryAmbiguousFailure && attempt < this.config.maxRetries) continue;
|
|
340
342
|
throw lastError;
|
|
341
343
|
}
|
|
342
344
|
if (response.ok) {
|
|
@@ -361,7 +363,7 @@ var HttpClient = class {
|
|
|
361
363
|
throw lastError;
|
|
362
364
|
}
|
|
363
365
|
lastError = parseError(response.status, errorBody);
|
|
364
|
-
if (attempt < this.config.maxRetries) continue;
|
|
366
|
+
if (canRetryAmbiguousFailure && attempt < this.config.maxRetries) continue;
|
|
365
367
|
throw lastError;
|
|
366
368
|
}
|
|
367
369
|
throw lastError ?? new Error("Request failed after retries");
|
|
@@ -568,9 +570,13 @@ var CStarRealtime = class {
|
|
|
568
570
|
this.exchangeToken().then(() => {
|
|
569
571
|
this.connecting = false;
|
|
570
572
|
this.connect();
|
|
571
|
-
}).catch(() => {
|
|
573
|
+
}).catch((err) => {
|
|
572
574
|
this.connecting = false;
|
|
573
|
-
this.
|
|
575
|
+
if (this.destroyed) return;
|
|
576
|
+
this.emitError(err instanceof Error ? err : new Error(String(err)));
|
|
577
|
+
if (this.autoReconnect && this.retryCount < this.maxRetries) {
|
|
578
|
+
this.scheduleReconnect();
|
|
579
|
+
}
|
|
574
580
|
});
|
|
575
581
|
return;
|
|
576
582
|
}
|
|
@@ -579,9 +585,10 @@ var CStarRealtime = class {
|
|
|
579
585
|
}
|
|
580
586
|
/**
|
|
581
587
|
* Open the EventSource with the given auth token.
|
|
582
|
-
*
|
|
588
|
+
* Secret keys reach this method only after exchanging for an SSE token.
|
|
583
589
|
*/
|
|
584
590
|
connectWithToken(authToken) {
|
|
591
|
+
if (this.destroyed) return;
|
|
585
592
|
const baseUrl = this.httpClient.getBaseUrl();
|
|
586
593
|
const params = new URLSearchParams();
|
|
587
594
|
if (this.types && this.types.length > 0) {
|
|
@@ -592,11 +599,6 @@ var CStarRealtime = class {
|
|
|
592
599
|
}
|
|
593
600
|
const qs = params.toString();
|
|
594
601
|
const url = `${baseUrl}/events/stream${qs ? `?${qs}` : ""}`;
|
|
595
|
-
if (authToken.startsWith("sk_") && typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined") {
|
|
596
|
-
console.warn(
|
|
597
|
-
"[cStar] Secret API key is being passed via SSE query parameter. Query strings may be logged by proxies and CDNs. For production, use a server-side proxy to add the Authorization header."
|
|
598
|
-
);
|
|
599
|
-
}
|
|
600
602
|
const separator = qs ? "&" : "?";
|
|
601
603
|
const authenticatedUrl = authToken ? `${url}${separator}token=${authToken}` : url;
|
|
602
604
|
const Ctor = this.resolveEventSource();
|
|
@@ -768,9 +770,14 @@ var CStarRealtime = class {
|
|
|
768
770
|
*/
|
|
769
771
|
async exchangeToken() {
|
|
770
772
|
const response = await this.httpClient.request("POST", "/events/token");
|
|
771
|
-
|
|
773
|
+
if (this.destroyed) return;
|
|
774
|
+
const { token, expiresAt, expiresIn } = response;
|
|
775
|
+
const expiry = new Date(expiresAt).getTime();
|
|
776
|
+
if (typeof token !== "string" || !token || token.startsWith("sk_") || !Number.isFinite(expiry) || expiry <= Date.now() || !Number.isFinite(expiresIn) || expiresIn <= 0) {
|
|
777
|
+
throw new Error("SSE token exchange returned an invalid token or expiry");
|
|
778
|
+
}
|
|
772
779
|
this.sseToken = token;
|
|
773
|
-
this.sseTokenExpiresAt =
|
|
780
|
+
this.sseTokenExpiresAt = expiry;
|
|
774
781
|
const refreshIn = Math.max((expiresIn - 30) * 1e3, expiresIn / 2 * 1e3);
|
|
775
782
|
this.scheduleTokenRefresh(refreshIn);
|
|
776
783
|
}
|
|
@@ -834,6 +841,8 @@ var Subscription = class {
|
|
|
834
841
|
this.destroyed = false;
|
|
835
842
|
/** Generation counter to prevent stale refresh() from overwriting SSE updates. */
|
|
836
843
|
this.generation = 0;
|
|
844
|
+
/** Replay events against the initial snapshot instead of discarding that snapshot. */
|
|
845
|
+
this.initialEvents = [];
|
|
837
846
|
this.init();
|
|
838
847
|
}
|
|
839
848
|
/** Current data array (updated in real-time). */
|
|
@@ -861,12 +870,12 @@ var Subscription = class {
|
|
|
861
870
|
const gen = ++this.generation;
|
|
862
871
|
try {
|
|
863
872
|
const response = await this.fetchFn();
|
|
864
|
-
if (gen !== this.generation) return;
|
|
873
|
+
if (this.destroyed || gen !== this.generation) return;
|
|
865
874
|
this._data = response.data;
|
|
866
875
|
this._error = null;
|
|
867
876
|
this.emitChange();
|
|
868
877
|
} catch (err) {
|
|
869
|
-
if (gen !== this.generation) return;
|
|
878
|
+
if (this.destroyed || gen !== this.generation) return;
|
|
870
879
|
this._error = err instanceof Error ? err : new Error(String(err));
|
|
871
880
|
this.emitError(this._error);
|
|
872
881
|
}
|
|
@@ -893,6 +902,7 @@ var Subscription = class {
|
|
|
893
902
|
/** Stop the subscription and clean up all listeners. */
|
|
894
903
|
unsubscribe() {
|
|
895
904
|
this.destroyed = true;
|
|
905
|
+
this.initialEvents = [];
|
|
896
906
|
if (this.boundEventHandler) {
|
|
897
907
|
this.realtime.offAny(this.boundEventHandler);
|
|
898
908
|
this.boundEventHandler = null;
|
|
@@ -907,14 +917,18 @@ var Subscription = class {
|
|
|
907
917
|
const gen = ++this.generation;
|
|
908
918
|
try {
|
|
909
919
|
const response = await this.fetchFn();
|
|
910
|
-
if (gen !== this.generation) return;
|
|
920
|
+
if (this.destroyed || gen !== this.generation) return;
|
|
911
921
|
this._data = response.data;
|
|
912
922
|
this._loading = false;
|
|
913
923
|
this._error = null;
|
|
924
|
+
const events = this.initialEvents;
|
|
925
|
+
this.initialEvents = [];
|
|
926
|
+
for (const event of events) this.handleEvent(event);
|
|
914
927
|
this.emitChange();
|
|
915
928
|
} catch (err) {
|
|
916
|
-
if (gen !== this.generation) return;
|
|
929
|
+
if (this.destroyed || gen !== this.generation) return;
|
|
917
930
|
this._loading = false;
|
|
931
|
+
this.initialEvents = [];
|
|
918
932
|
this._error = err instanceof Error ? err : new Error(String(err));
|
|
919
933
|
this.emitError(this._error);
|
|
920
934
|
}
|
|
@@ -936,6 +950,10 @@ var Subscription = class {
|
|
|
936
950
|
}
|
|
937
951
|
const entityData = this.extractEntity(event);
|
|
938
952
|
if (!entityData || !getEntityId(entityData)) return;
|
|
953
|
+
if (this._loading) {
|
|
954
|
+
this.initialEvents.push(event);
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
939
957
|
this.generation++;
|
|
940
958
|
if (event.type.endsWith(".created")) {
|
|
941
959
|
this.handleCreated(entityData);
|
|
@@ -2323,13 +2341,13 @@ var PreferencesResource = class {
|
|
|
2323
2341
|
};
|
|
2324
2342
|
|
|
2325
2343
|
// src/offline.ts
|
|
2326
|
-
var STORAGE_KEY = "cstar_offline_queue";
|
|
2327
2344
|
var OfflineQueue = class {
|
|
2328
2345
|
constructor(httpClient, options) {
|
|
2329
2346
|
this.httpClient = httpClient;
|
|
2330
2347
|
this.items = [];
|
|
2331
2348
|
this.autoFlushEnabled = false;
|
|
2332
2349
|
this.onlineHandler = null;
|
|
2350
|
+
this.storageKey = `cstar_offline_queue:${httpClient.getBaseUrl()}:${httpClient.environment}`;
|
|
2333
2351
|
this.useLocalStorage = options?.storage === "localStorage" && typeof globalThis !== "undefined" && typeof globalThis.localStorage !== "undefined";
|
|
2334
2352
|
if (this.useLocalStorage) {
|
|
2335
2353
|
this.loadFromStorage();
|
|
@@ -2370,7 +2388,7 @@ var OfflineQueue = class {
|
|
|
2370
2388
|
const message = err instanceof Error ? err.message : String(err);
|
|
2371
2389
|
results.push({ id: item.id, success: false, error: message });
|
|
2372
2390
|
const statusCode = err.statusCode;
|
|
2373
|
-
const isRetryable = !statusCode || statusCode >= 500;
|
|
2391
|
+
const isRetryable = !statusCode || statusCode === 429 || statusCode >= 500;
|
|
2374
2392
|
if (isRetryable) {
|
|
2375
2393
|
failedItems.push(item);
|
|
2376
2394
|
}
|
|
@@ -2423,15 +2441,16 @@ var OfflineQueue = class {
|
|
|
2423
2441
|
saveToStorage() {
|
|
2424
2442
|
if (!this.useLocalStorage) return;
|
|
2425
2443
|
try {
|
|
2426
|
-
localStorage.setItem(
|
|
2444
|
+
localStorage.setItem(this.storageKey, JSON.stringify(this.items));
|
|
2427
2445
|
} catch {
|
|
2428
2446
|
}
|
|
2429
2447
|
}
|
|
2430
2448
|
loadFromStorage() {
|
|
2431
2449
|
try {
|
|
2432
|
-
const raw = localStorage.getItem(
|
|
2450
|
+
const raw = localStorage.getItem(this.storageKey);
|
|
2433
2451
|
if (raw) {
|
|
2434
|
-
|
|
2452
|
+
const stored = JSON.parse(raw);
|
|
2453
|
+
this.items = Array.isArray(stored) ? stored : [];
|
|
2435
2454
|
}
|
|
2436
2455
|
} catch {
|
|
2437
2456
|
this.items = [];
|
package/dist/library/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { A as ApiErrorBody, C as CStarAuthenticationError, a as CStarConflictError, b as CStarError, c as CStarFeatureDisabledError, d as CStarNotFoundError, e as CStarPermissionError, f as CStarRateLimitError, g as CStarRealtimeUnavailableError, h as CStarServerError, i as CStarValidationError, E as ErrorType, p as parseError, j as parsePublicError } from '../errors-b5A4wfAg.cjs';
|
|
2
|
+
|
|
1
3
|
/** Configuration for the LibraryClient. */
|
|
2
4
|
interface LibraryConfig {
|
|
3
5
|
/** Team slug (e.g., 'acme'). Identifies the knowledge base to query. */
|
|
@@ -88,403 +90,6 @@ interface ArticleFeedbackResult {
|
|
|
88
90
|
error?: string;
|
|
89
91
|
}
|
|
90
92
|
|
|
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
|
-
|
|
488
93
|
/**
|
|
489
94
|
* Public knowledge base client. Authentication is optional — supply a
|
|
490
95
|
* publishable key (`pk_test_*` or `pk_live_*`) to switch the data scope
|
|
@@ -552,4 +157,4 @@ declare class LibraryClient {
|
|
|
552
157
|
private fetch;
|
|
553
158
|
}
|
|
554
159
|
|
|
555
|
-
export { type
|
|
160
|
+
export { type ArticleFeedbackParams, type ArticleFeedbackResult, type Category, type LibraryArticle, type LibraryArticleListParams, LibraryClient, type LibraryConfig, type LibrarySearchParams, type LibrarySearchResult, type LibraryStats };
|