@cstar.help/js 0.16.0 → 0.17.0
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 +234 -38
- package/dist/chat/index.d.cts +40 -84
- package/dist/chat/index.d.ts +40 -84
- package/dist/chat/index.js +234 -38
- 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 +62 -26
- package/dist/index.d.cts +54 -805
- package/dist/index.d.ts +54 -805
- package/dist/index.js +62 -26
- 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
|
@@ -262,7 +262,7 @@ var HttpClient = class {
|
|
|
262
262
|
}
|
|
263
263
|
if (typeof config.teamId !== "string" || config.teamId.length === 0) {
|
|
264
264
|
throw new Error(
|
|
265
|
-
"[cStar] CStarClient: teamId is required. Find your team ID in Settings \u2192
|
|
265
|
+
"[cStar] CStarClient: teamId is required. Find your team ID in Settings \u2192 API Keys (Team Identifiers) or via `cstar status`."
|
|
266
266
|
);
|
|
267
267
|
}
|
|
268
268
|
this.config = {
|
|
@@ -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");
|
|
@@ -469,6 +471,15 @@ var CStarRealtime = class {
|
|
|
469
471
|
this.errorHandlers = /* @__PURE__ */ new Set();
|
|
470
472
|
this.connectionHandlers = /* @__PURE__ */ new Set();
|
|
471
473
|
this.lastEventId = null;
|
|
474
|
+
/**
|
|
475
|
+
* Timestamp of the most recently received event, kept as an ISO-8601 string.
|
|
476
|
+
* Sent as `?since=<iso>` on reconnect so the server can replay events missed
|
|
477
|
+
* during the gap. The `id:` field on each SSE message is a prefixed entity
|
|
478
|
+
* ID (`evt_*`), which `new Date(...)` can't parse — passing it as `since`
|
|
479
|
+
* silently skips the replay branch on the server. Track the timestamp
|
|
480
|
+
* separately so reconnects actually catch up. R62.
|
|
481
|
+
*/
|
|
482
|
+
this.lastEventTimestamp = null;
|
|
472
483
|
this.retryCount = 0;
|
|
473
484
|
this.retryTimer = null;
|
|
474
485
|
this._connected = false;
|
|
@@ -559,9 +570,13 @@ var CStarRealtime = class {
|
|
|
559
570
|
this.exchangeToken().then(() => {
|
|
560
571
|
this.connecting = false;
|
|
561
572
|
this.connect();
|
|
562
|
-
}).catch(() => {
|
|
573
|
+
}).catch((err) => {
|
|
563
574
|
this.connecting = false;
|
|
564
|
-
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
|
+
}
|
|
565
580
|
});
|
|
566
581
|
return;
|
|
567
582
|
}
|
|
@@ -570,24 +585,20 @@ var CStarRealtime = class {
|
|
|
570
585
|
}
|
|
571
586
|
/**
|
|
572
587
|
* Open the EventSource with the given auth token.
|
|
573
|
-
*
|
|
588
|
+
* Secret keys reach this method only after exchanging for an SSE token.
|
|
574
589
|
*/
|
|
575
590
|
connectWithToken(authToken) {
|
|
591
|
+
if (this.destroyed) return;
|
|
576
592
|
const baseUrl = this.httpClient.getBaseUrl();
|
|
577
593
|
const params = new URLSearchParams();
|
|
578
594
|
if (this.types && this.types.length > 0) {
|
|
579
595
|
params.set("types", this.types.join(","));
|
|
580
596
|
}
|
|
581
|
-
if (this.
|
|
582
|
-
params.set("since", this.
|
|
597
|
+
if (this.lastEventTimestamp) {
|
|
598
|
+
params.set("since", this.lastEventTimestamp);
|
|
583
599
|
}
|
|
584
600
|
const qs = params.toString();
|
|
585
601
|
const url = `${baseUrl}/events/stream${qs ? `?${qs}` : ""}`;
|
|
586
|
-
if (authToken.startsWith("sk_") && typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined") {
|
|
587
|
-
console.warn(
|
|
588
|
-
"[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."
|
|
589
|
-
);
|
|
590
|
-
}
|
|
591
602
|
const separator = qs ? "&" : "?";
|
|
592
603
|
const authenticatedUrl = authToken ? `${url}${separator}token=${authToken}` : url;
|
|
593
604
|
const Ctor = this.resolveEventSource();
|
|
@@ -642,6 +653,9 @@ var CStarRealtime = class {
|
|
|
642
653
|
}
|
|
643
654
|
try {
|
|
644
655
|
const parsed = JSON.parse(msgEvent.data);
|
|
656
|
+
if (typeof parsed.timestamp === "string" && parsed.timestamp) {
|
|
657
|
+
this.lastEventTimestamp = parsed.timestamp;
|
|
658
|
+
}
|
|
645
659
|
const realtimeEvent = {
|
|
646
660
|
type: parsed.type || type,
|
|
647
661
|
id: msgEvent.lastEventId || "",
|
|
@@ -672,6 +686,8 @@ var CStarRealtime = class {
|
|
|
672
686
|
}
|
|
673
687
|
this.sseToken = null;
|
|
674
688
|
this.sseTokenExpiresAt = 0;
|
|
689
|
+
this.lastEventId = null;
|
|
690
|
+
this.lastEventTimestamp = null;
|
|
675
691
|
this.setConnected(false);
|
|
676
692
|
this.handlers.clear();
|
|
677
693
|
this.anyHandlers.clear();
|
|
@@ -695,6 +711,9 @@ var CStarRealtime = class {
|
|
|
695
711
|
try {
|
|
696
712
|
const parsed = JSON.parse(event.data);
|
|
697
713
|
if (parsed.type === "connected") return;
|
|
714
|
+
if (typeof parsed.timestamp === "string" && parsed.timestamp) {
|
|
715
|
+
this.lastEventTimestamp = parsed.timestamp;
|
|
716
|
+
}
|
|
698
717
|
const realtimeEvent = {
|
|
699
718
|
type: parsed.type,
|
|
700
719
|
id: event.lastEventId || "",
|
|
@@ -751,9 +770,14 @@ var CStarRealtime = class {
|
|
|
751
770
|
*/
|
|
752
771
|
async exchangeToken() {
|
|
753
772
|
const response = await this.httpClient.request("POST", "/events/token");
|
|
754
|
-
|
|
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
|
+
}
|
|
755
779
|
this.sseToken = token;
|
|
756
|
-
this.sseTokenExpiresAt =
|
|
780
|
+
this.sseTokenExpiresAt = expiry;
|
|
757
781
|
const refreshIn = Math.max((expiresIn - 30) * 1e3, expiresIn / 2 * 1e3);
|
|
758
782
|
this.scheduleTokenRefresh(refreshIn);
|
|
759
783
|
}
|
|
@@ -817,6 +841,8 @@ var Subscription = class {
|
|
|
817
841
|
this.destroyed = false;
|
|
818
842
|
/** Generation counter to prevent stale refresh() from overwriting SSE updates. */
|
|
819
843
|
this.generation = 0;
|
|
844
|
+
/** Replay events against the initial snapshot instead of discarding that snapshot. */
|
|
845
|
+
this.initialEvents = [];
|
|
820
846
|
this.init();
|
|
821
847
|
}
|
|
822
848
|
/** Current data array (updated in real-time). */
|
|
@@ -844,12 +870,12 @@ var Subscription = class {
|
|
|
844
870
|
const gen = ++this.generation;
|
|
845
871
|
try {
|
|
846
872
|
const response = await this.fetchFn();
|
|
847
|
-
if (gen !== this.generation) return;
|
|
873
|
+
if (this.destroyed || gen !== this.generation) return;
|
|
848
874
|
this._data = response.data;
|
|
849
875
|
this._error = null;
|
|
850
876
|
this.emitChange();
|
|
851
877
|
} catch (err) {
|
|
852
|
-
if (gen !== this.generation) return;
|
|
878
|
+
if (this.destroyed || gen !== this.generation) return;
|
|
853
879
|
this._error = err instanceof Error ? err : new Error(String(err));
|
|
854
880
|
this.emitError(this._error);
|
|
855
881
|
}
|
|
@@ -876,6 +902,7 @@ var Subscription = class {
|
|
|
876
902
|
/** Stop the subscription and clean up all listeners. */
|
|
877
903
|
unsubscribe() {
|
|
878
904
|
this.destroyed = true;
|
|
905
|
+
this.initialEvents = [];
|
|
879
906
|
if (this.boundEventHandler) {
|
|
880
907
|
this.realtime.offAny(this.boundEventHandler);
|
|
881
908
|
this.boundEventHandler = null;
|
|
@@ -890,14 +917,18 @@ var Subscription = class {
|
|
|
890
917
|
const gen = ++this.generation;
|
|
891
918
|
try {
|
|
892
919
|
const response = await this.fetchFn();
|
|
893
|
-
if (gen !== this.generation) return;
|
|
920
|
+
if (this.destroyed || gen !== this.generation) return;
|
|
894
921
|
this._data = response.data;
|
|
895
922
|
this._loading = false;
|
|
896
923
|
this._error = null;
|
|
924
|
+
const events = this.initialEvents;
|
|
925
|
+
this.initialEvents = [];
|
|
926
|
+
for (const event of events) this.handleEvent(event);
|
|
897
927
|
this.emitChange();
|
|
898
928
|
} catch (err) {
|
|
899
|
-
if (gen !== this.generation) return;
|
|
929
|
+
if (this.destroyed || gen !== this.generation) return;
|
|
900
930
|
this._loading = false;
|
|
931
|
+
this.initialEvents = [];
|
|
901
932
|
this._error = err instanceof Error ? err : new Error(String(err));
|
|
902
933
|
this.emitError(this._error);
|
|
903
934
|
}
|
|
@@ -919,6 +950,10 @@ var Subscription = class {
|
|
|
919
950
|
}
|
|
920
951
|
const entityData = this.extractEntity(event);
|
|
921
952
|
if (!entityData || !getEntityId(entityData)) return;
|
|
953
|
+
if (this._loading) {
|
|
954
|
+
this.initialEvents.push(event);
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
922
957
|
this.generation++;
|
|
923
958
|
if (event.type.endsWith(".created")) {
|
|
924
959
|
this.handleCreated(entityData);
|
|
@@ -1915,7 +1950,7 @@ var AchievementsResource = class {
|
|
|
1915
1950
|
constructor(client) {
|
|
1916
1951
|
this.client = client;
|
|
1917
1952
|
}
|
|
1918
|
-
/** List all achievements with progress. */
|
|
1953
|
+
/** List all achievements with progress. `params.userId` is required. */
|
|
1919
1954
|
async list(params) {
|
|
1920
1955
|
return this.client.request("GET", "/game/achievements", {
|
|
1921
1956
|
query: params
|
|
@@ -2306,13 +2341,13 @@ var PreferencesResource = class {
|
|
|
2306
2341
|
};
|
|
2307
2342
|
|
|
2308
2343
|
// src/offline.ts
|
|
2309
|
-
var STORAGE_KEY = "cstar_offline_queue";
|
|
2310
2344
|
var OfflineQueue = class {
|
|
2311
2345
|
constructor(httpClient, options) {
|
|
2312
2346
|
this.httpClient = httpClient;
|
|
2313
2347
|
this.items = [];
|
|
2314
2348
|
this.autoFlushEnabled = false;
|
|
2315
2349
|
this.onlineHandler = null;
|
|
2350
|
+
this.storageKey = `cstar_offline_queue:${httpClient.getBaseUrl()}:${httpClient.environment}`;
|
|
2316
2351
|
this.useLocalStorage = options?.storage === "localStorage" && typeof globalThis !== "undefined" && typeof globalThis.localStorage !== "undefined";
|
|
2317
2352
|
if (this.useLocalStorage) {
|
|
2318
2353
|
this.loadFromStorage();
|
|
@@ -2353,7 +2388,7 @@ var OfflineQueue = class {
|
|
|
2353
2388
|
const message = err instanceof Error ? err.message : String(err);
|
|
2354
2389
|
results.push({ id: item.id, success: false, error: message });
|
|
2355
2390
|
const statusCode = err.statusCode;
|
|
2356
|
-
const isRetryable = !statusCode || statusCode >= 500;
|
|
2391
|
+
const isRetryable = !statusCode || statusCode === 429 || statusCode >= 500;
|
|
2357
2392
|
if (isRetryable) {
|
|
2358
2393
|
failedItems.push(item);
|
|
2359
2394
|
}
|
|
@@ -2406,15 +2441,16 @@ var OfflineQueue = class {
|
|
|
2406
2441
|
saveToStorage() {
|
|
2407
2442
|
if (!this.useLocalStorage) return;
|
|
2408
2443
|
try {
|
|
2409
|
-
localStorage.setItem(
|
|
2444
|
+
localStorage.setItem(this.storageKey, JSON.stringify(this.items));
|
|
2410
2445
|
} catch {
|
|
2411
2446
|
}
|
|
2412
2447
|
}
|
|
2413
2448
|
loadFromStorage() {
|
|
2414
2449
|
try {
|
|
2415
|
-
const raw = localStorage.getItem(
|
|
2450
|
+
const raw = localStorage.getItem(this.storageKey);
|
|
2416
2451
|
if (raw) {
|
|
2417
|
-
|
|
2452
|
+
const stored = JSON.parse(raw);
|
|
2453
|
+
this.items = Array.isArray(stored) ? stored : [];
|
|
2418
2454
|
}
|
|
2419
2455
|
} catch {
|
|
2420
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 };
|