@cstar.help/js 0.17.3 → 0.17.5
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 +37 -13
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/community/index.d.cts +1 -1
- package/dist/community/index.d.ts +1 -1
- package/dist/errors-bW8CwTn4.d.cts +121 -0
- package/dist/errors-bW8CwTn4.d.ts +121 -0
- package/dist/index.cjs +24 -15
- package/dist/index.d.cts +74 -30
- package/dist/index.d.ts +74 -30
- package/dist/index.js +24 -15
- package/dist/library/index.d.cts +1 -1
- package/dist/library/index.d.ts +1 -1
- package/dist/quickhelp/index.d.cts +1 -1
- package/dist/quickhelp/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/errors-b5A4wfAg.d.cts +0 -398
- package/dist/errors-b5A4wfAg.d.ts +0 -398
package/README.md
CHANGED
|
@@ -49,16 +49,16 @@ Manage tickets, customers, articles, team members, settings, game system, and ev
|
|
|
49
49
|
```typescript
|
|
50
50
|
import { CStarClient } from '@cstar.help/js';
|
|
51
51
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
52
|
+
const apiKey = process.env.CSTAR_SECRET_KEY; // sk_live_... or sk_test_...
|
|
53
|
+
const teamId = process.env.CSTAR_TEAM_ID;
|
|
54
|
+
if (!apiKey || !teamId) throw new Error('Set CSTAR_SECRET_KEY and CSTAR_TEAM_ID.');
|
|
55
|
+
const cstar = new CStarClient({ apiKey, teamId });
|
|
56
56
|
|
|
57
57
|
// List open tickets
|
|
58
58
|
const { data: tickets } = await cstar.tickets.list({ status: 'open' });
|
|
59
59
|
|
|
60
60
|
// Create a ticket
|
|
61
|
-
const
|
|
61
|
+
const ticket = await cstar.tickets.create({
|
|
62
62
|
title: 'Help with billing',
|
|
63
63
|
customerId: 'cus_abc123'
|
|
64
64
|
});
|
|
@@ -69,6 +69,25 @@ for await (const ticket of cstar.tickets.listAutoPaginating({ status: 'open' }))
|
|
|
69
69
|
}
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
Created, retrieved and updated resources are returned directly. List methods return `{ data, pagination, hasMore }`. Search returns `{ results, total, query }`. Read `cstar.lastMeta.requestId` immediately after a call when you need its request ID.
|
|
73
|
+
|
|
74
|
+
### Private notes and message history
|
|
75
|
+
|
|
76
|
+
Run message management on your server with a secret key. Internal notes stay inside the support team.
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const note = await cstar.tickets.messages.create('tkt_123', {
|
|
80
|
+
content: 'The customer has already tried resetting their password.',
|
|
81
|
+
messageType: 'internal'
|
|
82
|
+
});
|
|
83
|
+
console.log(note.isInternal);
|
|
84
|
+
|
|
85
|
+
const page = await cstar.tickets.messages.list('tkt_123', { page: 2, pageSize: 25 });
|
|
86
|
+
console.log(page.data, page.pagination.hasMore);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The `isInternal` boolean is also accepted when creating a note. If you supply both privacy options, they must agree. Message history is paginated, so request the next page while `hasMore` is true.
|
|
90
|
+
|
|
72
91
|
### Full Resource Reference
|
|
73
92
|
|
|
74
93
|
**Core Resources** — Tickets, customers, and knowledge base.
|
|
@@ -76,7 +95,7 @@ for await (const ticket of cstar.tickets.listAutoPaginating({ status: 'open' }))
|
|
|
76
95
|
| Resource | Methods |
|
|
77
96
|
| ------------------------ | ----------------------------------------------------------------------------------------------- |
|
|
78
97
|
| `cstar.tickets` | `.list()` `.get(id)` `.create(params)` `.update(id, params)` `.del(id)` `.listAutoPaginating()` |
|
|
79
|
-
| `cstar.tickets.messages` | `.list(ticketId)` `.create(ticketId, params)`
|
|
98
|
+
| `cstar.tickets.messages` | `.list(ticketId, params?)` `.create(ticketId, params)` |
|
|
80
99
|
| `cstar.customers` | `.list()` `.get(id)` `.create(params)` `.update(id, params)` `.del(id)` `.listAutoPaginating()` |
|
|
81
100
|
| `cstar.articles` | `.list()` `.get(id)` `.create(params)` `.update(id, params)` `.del(id)` `.listAutoPaginating()` |
|
|
82
101
|
| `cstar.categories` | `.list()` `.get(id)` `.create(params)` `.update(id, params)` `.del(id)` |
|
|
@@ -167,14 +186,19 @@ await cstar.bulk.update({
|
|
|
167
186
|
data: { status: 'closed' }
|
|
168
187
|
});
|
|
169
188
|
|
|
170
|
-
// Export
|
|
171
|
-
const
|
|
172
|
-
resources: [
|
|
173
|
-
|
|
189
|
+
// Export closed tickets as JSON with raw rows and per-resource counts
|
|
190
|
+
const exported = await cstar.export.create({
|
|
191
|
+
resources: ['tickets'],
|
|
192
|
+
filters: { status: 'closed' },
|
|
193
|
+
format: 'json'
|
|
174
194
|
});
|
|
195
|
+
console.log(exported.summary.tickets);
|
|
196
|
+
|
|
197
|
+
// CSV is text and supports one resource at a time
|
|
198
|
+
const csv = await cstar.export.create({ resources: ['tickets'], format: 'csv' });
|
|
175
199
|
|
|
176
200
|
// Saved views
|
|
177
|
-
const
|
|
201
|
+
const view = await cstar.views.create({
|
|
178
202
|
name: 'Urgent Unresolved',
|
|
179
203
|
entityType: 'tickets',
|
|
180
204
|
filters: { priority: 'urgent', status: 'open' }
|
|
@@ -182,7 +206,7 @@ const { data: view } = await cstar.views.create({
|
|
|
182
206
|
const { data: results } = await cstar.views.execute(view.id);
|
|
183
207
|
|
|
184
208
|
// Search across everything
|
|
185
|
-
const {
|
|
209
|
+
const { results: searchResults } = await cstar.search.query({
|
|
186
210
|
query: 'billing issue',
|
|
187
211
|
types: ['tickets', 'customers']
|
|
188
212
|
});
|
|
@@ -448,7 +472,7 @@ try {
|
|
|
448
472
|
Safely retry create/update operations:
|
|
449
473
|
|
|
450
474
|
```typescript
|
|
451
|
-
const
|
|
475
|
+
const ticket = await cstar.tickets.create(
|
|
452
476
|
{ title: 'Billing issue', customerId: 'cus_abc' },
|
|
453
477
|
{ idempotencyKey: 'create-billing-issue-usr123' }
|
|
454
478
|
);
|
package/dist/auth/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-bW8CwTn4.cjs';
|
|
2
2
|
|
|
3
3
|
/** Configuration for the AuthClient. */
|
|
4
4
|
interface AuthConfig {
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-bW8CwTn4.js';
|
|
2
2
|
|
|
3
3
|
/** Configuration for the AuthClient. */
|
|
4
4
|
interface AuthConfig {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { h as CommunityConfig, i as CommunityTopic, j as CommunityPostListParams, k as CommunityPost, l as CommunityPostDetail, m as CommunitySearchResult, C as CommunityCreatePostParams, a as CommunityCreatedPost, b as CommunityUpdatePostParams, c as CommunityUpdateCommentParams, d as CommunityCreatedComment, e as CommunityVoteResult, f as CommunityCreateCommentParams, g as CommunityFollowResult } from '../types-DF7GprCV.cjs';
|
|
2
2
|
export { n as CommunityComment } from '../types-DF7GprCV.cjs';
|
|
3
|
-
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-
|
|
3
|
+
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-bW8CwTn4.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Public community client. No authentication required.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { h as CommunityConfig, i as CommunityTopic, j as CommunityPostListParams, k as CommunityPost, l as CommunityPostDetail, m as CommunitySearchResult, C as CommunityCreatePostParams, a as CommunityCreatedPost, b as CommunityUpdatePostParams, c as CommunityUpdateCommentParams, d as CommunityCreatedComment, e as CommunityVoteResult, f as CommunityCreateCommentParams, g as CommunityFollowResult } from '../types-DF7GprCV.js';
|
|
2
2
|
export { n as CommunityComment } from '../types-DF7GprCV.js';
|
|
3
|
-
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-
|
|
3
|
+
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-bW8CwTn4.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Public community client. No authentication required.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error classes for the cStar SDK.
|
|
3
|
+
*
|
|
4
|
+
* NEW-v3-01 — Cross-subpath instanceof identity.
|
|
5
|
+
*
|
|
6
|
+
* Each public subpath (`/library`, `/auth`, `/community`, `/quickhelp`, ...)
|
|
7
|
+
* is bundled as a separate tsup entry with `splitting: false`, so each one
|
|
8
|
+
* carries its own copy of this module. Without deduplication, errors thrown
|
|
9
|
+
* by `LibraryClient` carry the LibraryClient-bundled `CStarError` class —
|
|
10
|
+
* not the one a consumer imports from `@cstar.help/js`. That makes
|
|
11
|
+
* `instanceof CStarError` checks fail silently, invalidating every "did the
|
|
12
|
+
* SDK throw a typed cStar error?" branch in user code.
|
|
13
|
+
*
|
|
14
|
+
* Fix: register each class on a `Symbol.for(...)` slot of `globalThis`. The
|
|
15
|
+
* symbol is realm-shared, so every bundled copy of this module resolves to
|
|
16
|
+
* the SAME class identity at runtime — the first copy to load wins, and all
|
|
17
|
+
* subsequent copies surface the canonical class via the same slot. The
|
|
18
|
+
* inline `Impl` definitions are only used as the seed for the very first
|
|
19
|
+
* copy to register. Internal `parseError` / `parsePublicError` reference the
|
|
20
|
+
* EXPORTED canonical names so instances they construct also land on the
|
|
21
|
+
* canonical class.
|
|
22
|
+
*/
|
|
23
|
+
/** Error type constants matching the cStar API. */
|
|
24
|
+
declare const ErrorType: {
|
|
25
|
+
readonly AUTHENTICATION_ERROR: "authentication_error";
|
|
26
|
+
readonly PERMISSION_ERROR: "permission_error";
|
|
27
|
+
readonly INVALID_REQUEST_ERROR: "invalid_request_error";
|
|
28
|
+
readonly NOT_FOUND_ERROR: "not_found_error";
|
|
29
|
+
readonly CONFLICT_ERROR: "conflict_error";
|
|
30
|
+
readonly RATE_LIMIT_ERROR: "rate_limit_error";
|
|
31
|
+
readonly FEATURE_NOT_CONFIGURED: "feature_not_configured";
|
|
32
|
+
readonly API_ERROR: "api_error";
|
|
33
|
+
readonly SERVER_ERROR: "server_error";
|
|
34
|
+
};
|
|
35
|
+
/** Shape of the error object returned by the cStar API. */
|
|
36
|
+
interface ApiErrorBody {
|
|
37
|
+
type: string;
|
|
38
|
+
code: string;
|
|
39
|
+
message: string;
|
|
40
|
+
param?: string;
|
|
41
|
+
doc_url: string;
|
|
42
|
+
request_id?: string;
|
|
43
|
+
feature?: string;
|
|
44
|
+
enable_url?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Base error class for all cStar API errors. */
|
|
47
|
+
declare class CStarErrorImpl extends Error {
|
|
48
|
+
readonly type: string;
|
|
49
|
+
readonly code: string;
|
|
50
|
+
readonly param?: string;
|
|
51
|
+
readonly docUrl: string;
|
|
52
|
+
readonly requestId?: string;
|
|
53
|
+
readonly statusCode: number;
|
|
54
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
55
|
+
}
|
|
56
|
+
declare class CStarAuthenticationErrorImpl extends CStarErrorImpl {
|
|
57
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
58
|
+
}
|
|
59
|
+
declare class CStarRateLimitErrorImpl extends CStarErrorImpl {
|
|
60
|
+
readonly retryAfter: number;
|
|
61
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number);
|
|
62
|
+
}
|
|
63
|
+
declare class CStarNotFoundErrorImpl extends CStarErrorImpl {
|
|
64
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
65
|
+
}
|
|
66
|
+
declare class CStarValidationErrorImpl extends CStarErrorImpl {
|
|
67
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
68
|
+
}
|
|
69
|
+
declare class CStarPermissionErrorImpl extends CStarErrorImpl {
|
|
70
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
71
|
+
}
|
|
72
|
+
declare class CStarConflictErrorImpl extends CStarErrorImpl {
|
|
73
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
74
|
+
}
|
|
75
|
+
declare class CStarServerErrorImpl extends CStarErrorImpl {
|
|
76
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
77
|
+
}
|
|
78
|
+
declare class CStarFeatureDisabledErrorImpl extends CStarErrorImpl {
|
|
79
|
+
readonly feature: string;
|
|
80
|
+
readonly enableUrl: string;
|
|
81
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
82
|
+
}
|
|
83
|
+
declare class CStarRealtimeUnavailableErrorImpl extends CStarErrorImpl {
|
|
84
|
+
constructor(message?: string);
|
|
85
|
+
}
|
|
86
|
+
declare const CStarError: typeof CStarErrorImpl;
|
|
87
|
+
type CStarError = InstanceType<typeof CStarErrorImpl>;
|
|
88
|
+
declare const CStarAuthenticationError: typeof CStarAuthenticationErrorImpl;
|
|
89
|
+
type CStarAuthenticationError = InstanceType<typeof CStarAuthenticationErrorImpl>;
|
|
90
|
+
declare const CStarRateLimitError: typeof CStarRateLimitErrorImpl;
|
|
91
|
+
type CStarRateLimitError = InstanceType<typeof CStarRateLimitErrorImpl>;
|
|
92
|
+
declare const CStarNotFoundError: typeof CStarNotFoundErrorImpl;
|
|
93
|
+
type CStarNotFoundError = InstanceType<typeof CStarNotFoundErrorImpl>;
|
|
94
|
+
declare const CStarValidationError: typeof CStarValidationErrorImpl;
|
|
95
|
+
type CStarValidationError = InstanceType<typeof CStarValidationErrorImpl>;
|
|
96
|
+
declare const CStarPermissionError: typeof CStarPermissionErrorImpl;
|
|
97
|
+
type CStarPermissionError = InstanceType<typeof CStarPermissionErrorImpl>;
|
|
98
|
+
declare const CStarConflictError: typeof CStarConflictErrorImpl;
|
|
99
|
+
type CStarConflictError = InstanceType<typeof CStarConflictErrorImpl>;
|
|
100
|
+
declare const CStarServerError: typeof CStarServerErrorImpl;
|
|
101
|
+
type CStarServerError = InstanceType<typeof CStarServerErrorImpl>;
|
|
102
|
+
declare const CStarFeatureDisabledError: typeof CStarFeatureDisabledErrorImpl;
|
|
103
|
+
type CStarFeatureDisabledError = InstanceType<typeof CStarFeatureDisabledErrorImpl>;
|
|
104
|
+
declare const CStarRealtimeUnavailableError: typeof CStarRealtimeUnavailableErrorImpl;
|
|
105
|
+
type CStarRealtimeUnavailableError = InstanceType<typeof CStarRealtimeUnavailableErrorImpl>;
|
|
106
|
+
/**
|
|
107
|
+
* Parse a public-route response (anonymous LibraryClient, CommunityClient,
|
|
108
|
+
* QuickHelpClient, AuthClient) into a typed `CStarError`.
|
|
109
|
+
*
|
|
110
|
+
* Public routes don't always emit the structured `{error: {type, code,
|
|
111
|
+
* doc_url, ...}}` envelope — many emit `{error: 'message string'}` or
|
|
112
|
+
* `{message: '...'}`. This helper normalizes both shapes and dispatches
|
|
113
|
+
* on HTTP status (closes F-026 and F-034 — Library/Auth used to throw
|
|
114
|
+
* plain `Error`).
|
|
115
|
+
*/
|
|
116
|
+
declare function parsePublicError(status: number, body: unknown, fallbackMessage: string): CStarError;
|
|
117
|
+
declare function parseError(statusCode: number, body: {
|
|
118
|
+
error?: ApiErrorBody;
|
|
119
|
+
} | null, retryAfter?: number): CStarError;
|
|
120
|
+
|
|
121
|
+
export { type ApiErrorBody as A, CStarAuthenticationError as C, ErrorType as E, CStarConflictError as a, CStarError as b, CStarFeatureDisabledError as c, CStarNotFoundError as d, CStarPermissionError as e, CStarRateLimitError as f, CStarRealtimeUnavailableError as g, CStarServerError as h, CStarValidationError as i, parsePublicError as j, parseError as p };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error classes for the cStar SDK.
|
|
3
|
+
*
|
|
4
|
+
* NEW-v3-01 — Cross-subpath instanceof identity.
|
|
5
|
+
*
|
|
6
|
+
* Each public subpath (`/library`, `/auth`, `/community`, `/quickhelp`, ...)
|
|
7
|
+
* is bundled as a separate tsup entry with `splitting: false`, so each one
|
|
8
|
+
* carries its own copy of this module. Without deduplication, errors thrown
|
|
9
|
+
* by `LibraryClient` carry the LibraryClient-bundled `CStarError` class —
|
|
10
|
+
* not the one a consumer imports from `@cstar.help/js`. That makes
|
|
11
|
+
* `instanceof CStarError` checks fail silently, invalidating every "did the
|
|
12
|
+
* SDK throw a typed cStar error?" branch in user code.
|
|
13
|
+
*
|
|
14
|
+
* Fix: register each class on a `Symbol.for(...)` slot of `globalThis`. The
|
|
15
|
+
* symbol is realm-shared, so every bundled copy of this module resolves to
|
|
16
|
+
* the SAME class identity at runtime — the first copy to load wins, and all
|
|
17
|
+
* subsequent copies surface the canonical class via the same slot. The
|
|
18
|
+
* inline `Impl` definitions are only used as the seed for the very first
|
|
19
|
+
* copy to register. Internal `parseError` / `parsePublicError` reference the
|
|
20
|
+
* EXPORTED canonical names so instances they construct also land on the
|
|
21
|
+
* canonical class.
|
|
22
|
+
*/
|
|
23
|
+
/** Error type constants matching the cStar API. */
|
|
24
|
+
declare const ErrorType: {
|
|
25
|
+
readonly AUTHENTICATION_ERROR: "authentication_error";
|
|
26
|
+
readonly PERMISSION_ERROR: "permission_error";
|
|
27
|
+
readonly INVALID_REQUEST_ERROR: "invalid_request_error";
|
|
28
|
+
readonly NOT_FOUND_ERROR: "not_found_error";
|
|
29
|
+
readonly CONFLICT_ERROR: "conflict_error";
|
|
30
|
+
readonly RATE_LIMIT_ERROR: "rate_limit_error";
|
|
31
|
+
readonly FEATURE_NOT_CONFIGURED: "feature_not_configured";
|
|
32
|
+
readonly API_ERROR: "api_error";
|
|
33
|
+
readonly SERVER_ERROR: "server_error";
|
|
34
|
+
};
|
|
35
|
+
/** Shape of the error object returned by the cStar API. */
|
|
36
|
+
interface ApiErrorBody {
|
|
37
|
+
type: string;
|
|
38
|
+
code: string;
|
|
39
|
+
message: string;
|
|
40
|
+
param?: string;
|
|
41
|
+
doc_url: string;
|
|
42
|
+
request_id?: string;
|
|
43
|
+
feature?: string;
|
|
44
|
+
enable_url?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Base error class for all cStar API errors. */
|
|
47
|
+
declare class CStarErrorImpl extends Error {
|
|
48
|
+
readonly type: string;
|
|
49
|
+
readonly code: string;
|
|
50
|
+
readonly param?: string;
|
|
51
|
+
readonly docUrl: string;
|
|
52
|
+
readonly requestId?: string;
|
|
53
|
+
readonly statusCode: number;
|
|
54
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
55
|
+
}
|
|
56
|
+
declare class CStarAuthenticationErrorImpl extends CStarErrorImpl {
|
|
57
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
58
|
+
}
|
|
59
|
+
declare class CStarRateLimitErrorImpl extends CStarErrorImpl {
|
|
60
|
+
readonly retryAfter: number;
|
|
61
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number);
|
|
62
|
+
}
|
|
63
|
+
declare class CStarNotFoundErrorImpl extends CStarErrorImpl {
|
|
64
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
65
|
+
}
|
|
66
|
+
declare class CStarValidationErrorImpl extends CStarErrorImpl {
|
|
67
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
68
|
+
}
|
|
69
|
+
declare class CStarPermissionErrorImpl extends CStarErrorImpl {
|
|
70
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
71
|
+
}
|
|
72
|
+
declare class CStarConflictErrorImpl extends CStarErrorImpl {
|
|
73
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
74
|
+
}
|
|
75
|
+
declare class CStarServerErrorImpl extends CStarErrorImpl {
|
|
76
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
77
|
+
}
|
|
78
|
+
declare class CStarFeatureDisabledErrorImpl extends CStarErrorImpl {
|
|
79
|
+
readonly feature: string;
|
|
80
|
+
readonly enableUrl: string;
|
|
81
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
82
|
+
}
|
|
83
|
+
declare class CStarRealtimeUnavailableErrorImpl extends CStarErrorImpl {
|
|
84
|
+
constructor(message?: string);
|
|
85
|
+
}
|
|
86
|
+
declare const CStarError: typeof CStarErrorImpl;
|
|
87
|
+
type CStarError = InstanceType<typeof CStarErrorImpl>;
|
|
88
|
+
declare const CStarAuthenticationError: typeof CStarAuthenticationErrorImpl;
|
|
89
|
+
type CStarAuthenticationError = InstanceType<typeof CStarAuthenticationErrorImpl>;
|
|
90
|
+
declare const CStarRateLimitError: typeof CStarRateLimitErrorImpl;
|
|
91
|
+
type CStarRateLimitError = InstanceType<typeof CStarRateLimitErrorImpl>;
|
|
92
|
+
declare const CStarNotFoundError: typeof CStarNotFoundErrorImpl;
|
|
93
|
+
type CStarNotFoundError = InstanceType<typeof CStarNotFoundErrorImpl>;
|
|
94
|
+
declare const CStarValidationError: typeof CStarValidationErrorImpl;
|
|
95
|
+
type CStarValidationError = InstanceType<typeof CStarValidationErrorImpl>;
|
|
96
|
+
declare const CStarPermissionError: typeof CStarPermissionErrorImpl;
|
|
97
|
+
type CStarPermissionError = InstanceType<typeof CStarPermissionErrorImpl>;
|
|
98
|
+
declare const CStarConflictError: typeof CStarConflictErrorImpl;
|
|
99
|
+
type CStarConflictError = InstanceType<typeof CStarConflictErrorImpl>;
|
|
100
|
+
declare const CStarServerError: typeof CStarServerErrorImpl;
|
|
101
|
+
type CStarServerError = InstanceType<typeof CStarServerErrorImpl>;
|
|
102
|
+
declare const CStarFeatureDisabledError: typeof CStarFeatureDisabledErrorImpl;
|
|
103
|
+
type CStarFeatureDisabledError = InstanceType<typeof CStarFeatureDisabledErrorImpl>;
|
|
104
|
+
declare const CStarRealtimeUnavailableError: typeof CStarRealtimeUnavailableErrorImpl;
|
|
105
|
+
type CStarRealtimeUnavailableError = InstanceType<typeof CStarRealtimeUnavailableErrorImpl>;
|
|
106
|
+
/**
|
|
107
|
+
* Parse a public-route response (anonymous LibraryClient, CommunityClient,
|
|
108
|
+
* QuickHelpClient, AuthClient) into a typed `CStarError`.
|
|
109
|
+
*
|
|
110
|
+
* Public routes don't always emit the structured `{error: {type, code,
|
|
111
|
+
* doc_url, ...}}` envelope — many emit `{error: 'message string'}` or
|
|
112
|
+
* `{message: '...'}`. This helper normalizes both shapes and dispatches
|
|
113
|
+
* on HTTP status (closes F-026 and F-034 — Library/Auth used to throw
|
|
114
|
+
* plain `Error`).
|
|
115
|
+
*/
|
|
116
|
+
declare function parsePublicError(status: number, body: unknown, fallbackMessage: string): CStarError;
|
|
117
|
+
declare function parseError(statusCode: number, body: {
|
|
118
|
+
error?: ApiErrorBody;
|
|
119
|
+
} | null, retryAfter?: number): CStarError;
|
|
120
|
+
|
|
121
|
+
export { type ApiErrorBody as A, CStarAuthenticationError as C, ErrorType as E, CStarConflictError as a, CStarError as b, CStarFeatureDisabledError as c, CStarNotFoundError as d, CStarPermissionError as e, CStarRateLimitError as f, CStarRealtimeUnavailableError as g, CStarServerError as h, CStarValidationError as i, parsePublicError as j, parseError as p };
|
package/dist/index.cjs
CHANGED
|
@@ -278,7 +278,7 @@ function parseError(statusCode, body, retryAfter) {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
// src/client.ts
|
|
281
|
-
var SDK_VERSION = "0.17.
|
|
281
|
+
var SDK_VERSION = "0.17.5";
|
|
282
282
|
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
283
283
|
var DEFAULT_API_VERSION = "2026-03-01";
|
|
284
284
|
var DEFAULT_MAX_RETRIES = 3;
|
|
@@ -384,8 +384,13 @@ var HttpClient = class {
|
|
|
384
384
|
}
|
|
385
385
|
if (response.ok) {
|
|
386
386
|
if (response.status === 204) return void 0;
|
|
387
|
-
const json = await response.json();
|
|
388
387
|
const headerRequestId = response.headers.get("x-request-id") ?? response.headers.get("x-cstar-request-id");
|
|
388
|
+
if (options?.responseType === "text") {
|
|
389
|
+
const text = await response.text();
|
|
390
|
+
this.captureMeta(null, headerRequestId);
|
|
391
|
+
return text;
|
|
392
|
+
}
|
|
393
|
+
const json = await response.json();
|
|
389
394
|
this.captureMeta(json, headerRequestId);
|
|
390
395
|
return this.unwrapEnvelope(json);
|
|
391
396
|
}
|
|
@@ -1157,9 +1162,11 @@ var TicketMessagesResource = class {
|
|
|
1157
1162
|
constructor(client) {
|
|
1158
1163
|
this.client = client;
|
|
1159
1164
|
}
|
|
1160
|
-
/** List
|
|
1161
|
-
async list(ticketId) {
|
|
1162
|
-
return this.client.request("GET", `/tickets/${ticketId}/messages
|
|
1165
|
+
/** List one page of a ticket history. Use pagination.hasMore to request the next page. */
|
|
1166
|
+
async list(ticketId, params) {
|
|
1167
|
+
return this.client.request("GET", `/tickets/${ticketId}/messages`, {
|
|
1168
|
+
query: params ? { ...params } : void 0
|
|
1169
|
+
});
|
|
1163
1170
|
}
|
|
1164
1171
|
/** Add a message to a ticket. */
|
|
1165
1172
|
async create(ticketId, params, options) {
|
|
@@ -1495,11 +1502,9 @@ var QuickRepliesResource = class {
|
|
|
1495
1502
|
}
|
|
1496
1503
|
/** Reorder quick replies. */
|
|
1497
1504
|
async reorder(orderedIds) {
|
|
1498
|
-
return this.client.request(
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
{ body: { orderedIds } }
|
|
1502
|
-
);
|
|
1505
|
+
return this.client.request("PUT", "/settings/quick-replies/reorder", {
|
|
1506
|
+
body: { orderedIds }
|
|
1507
|
+
});
|
|
1503
1508
|
}
|
|
1504
1509
|
};
|
|
1505
1510
|
var SettingsResource = class {
|
|
@@ -1673,9 +1678,13 @@ var CustomFieldsResource = class {
|
|
|
1673
1678
|
}
|
|
1674
1679
|
/** Reorder custom fields within a content type. */
|
|
1675
1680
|
async reorder(contentType, orderedIds) {
|
|
1676
|
-
return this.client.request(
|
|
1677
|
-
|
|
1678
|
-
|
|
1681
|
+
return this.client.request(
|
|
1682
|
+
"PUT",
|
|
1683
|
+
"/custom-fields/reorder",
|
|
1684
|
+
{
|
|
1685
|
+
body: { contentType, orderedIds }
|
|
1686
|
+
}
|
|
1687
|
+
);
|
|
1679
1688
|
}
|
|
1680
1689
|
};
|
|
1681
1690
|
|
|
@@ -1810,11 +1819,11 @@ var ExportResource = class {
|
|
|
1810
1819
|
constructor(client) {
|
|
1811
1820
|
this.client = client;
|
|
1812
1821
|
}
|
|
1813
|
-
/** Create an export. Returns exported data synchronously. */
|
|
1814
1822
|
async create(params, options) {
|
|
1815
1823
|
return this.client.request("POST", "/export", {
|
|
1816
1824
|
body: params,
|
|
1817
|
-
idempotencyKey: options?.idempotencyKey
|
|
1825
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1826
|
+
responseType: params.format === "csv" ? "text" : "json"
|
|
1818
1827
|
});
|
|
1819
1828
|
}
|
|
1820
1829
|
};
|