@cstar.help/js 0.18.2 → 0.18.4
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 +9 -3
- package/dist/auth/index.cjs +16 -13
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +16 -13
- package/dist/chat/index.d.cts +1 -1
- package/dist/chat/index.d.ts +1 -1
- package/dist/community/index.cjs +16 -13
- package/dist/community/index.d.cts +1 -1
- package/dist/community/index.d.ts +1 -1
- package/dist/community/index.js +16 -13
- package/dist/{errors-bW8CwTn4.d.cts → errors-BnUUTVlT.d.cts} +2 -1
- package/dist/{errors-bW8CwTn4.d.ts → errors-BnUUTVlT.d.ts} +2 -1
- package/dist/index.cjs +266 -117
- package/dist/index.d.cts +161 -60
- package/dist/index.d.ts +161 -60
- package/dist/index.js +266 -117
- package/dist/library/index.cjs +16 -13
- package/dist/library/index.d.cts +1 -1
- package/dist/library/index.d.ts +1 -1
- package/dist/library/index.js +16 -13
- package/dist/quickhelp/index.cjs +20 -15
- package/dist/quickhelp/index.d.cts +26 -2
- package/dist/quickhelp/index.d.ts +26 -2
- package/dist/quickhelp/index.js +20 -15
- package/dist/webhook/index.d.cts +1 -1
- package/dist/webhook/index.d.ts +1 -1
- package/dist/webhook/node.d.cts +1 -1
- package/dist/webhook/node.d.ts +1 -1
- package/dist/{webhookEvents-Lqpsj935.d.cts → webhookEvents-YQer37My.d.cts} +208 -83
- package/dist/{webhookEvents-Lqpsj935.d.ts → webhookEvents-YQer37My.d.ts} +208 -83
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -404,11 +404,12 @@ const event = await constructEventAsync(rawBody, signature, secret);
|
|
|
404
404
|
```typescript
|
|
405
405
|
const cstar = new CStarClient({
|
|
406
406
|
apiKey: 'sk_live_...', // Required: must be a secret key (sk_*)
|
|
407
|
-
teamId: '
|
|
407
|
+
teamId: '8f14e45f-ea2b-4c8b-9f1e-2a6b3c4d5e6f', // Required: your team ID (a UUID; GET /api/v1/auth/whoami returns it)
|
|
408
408
|
baseUrl: 'https://...', // Optional: defaults to https://www.cstar.help
|
|
409
409
|
version: '2026-03-01', // Optional: API version header
|
|
410
410
|
maxRetries: 3, // Optional: retry attempts for retry-safe failures and 429
|
|
411
|
-
timeout: 30000 // Optional: request timeout in ms
|
|
411
|
+
timeout: 30000, // Optional: request timeout in ms
|
|
412
|
+
realtime: { types: ['ticket.created', 'message.created'] } // Optional: realtime stream options (types, eventSource polyfill, autoReconnect, maxRetries)
|
|
412
413
|
});
|
|
413
414
|
```
|
|
414
415
|
|
|
@@ -432,7 +433,7 @@ Test mode is auto-detected from your API key prefix:
|
|
|
432
433
|
```typescript
|
|
433
434
|
const cstar = new CStarClient({
|
|
434
435
|
apiKey: 'sk_test_abc123...',
|
|
435
|
-
teamId:
|
|
436
|
+
teamId: process.env.CSTAR_TEAM_ID! // a UUID
|
|
436
437
|
});
|
|
437
438
|
|
|
438
439
|
console.log(cstar.isTestMode); // true
|
|
@@ -447,6 +448,7 @@ All API errors throw typed exceptions:
|
|
|
447
448
|
import {
|
|
448
449
|
CStarError,
|
|
449
450
|
CStarAuthenticationError,
|
|
451
|
+
CStarConflictError,
|
|
450
452
|
CStarRateLimitError,
|
|
451
453
|
CStarNotFoundError,
|
|
452
454
|
CStarValidationError
|
|
@@ -461,6 +463,10 @@ try {
|
|
|
461
463
|
console.log('Invalid param:', err.param);
|
|
462
464
|
} else if (err instanceof CStarRateLimitError) {
|
|
463
465
|
console.log('Rate limited, retry after:', err.retryAfter, 'seconds');
|
|
466
|
+
} else if (err instanceof CStarConflictError) {
|
|
467
|
+
// A unique-key conflict, an Idempotency-Key still in use, or the team's
|
|
468
|
+
// webhook limit (code 'webhook_limit_reached': delete unused webhooks first).
|
|
469
|
+
console.log('Conflict:', err.code);
|
|
464
470
|
} else if (err instanceof CStarAuthenticationError) {
|
|
465
471
|
console.log('Bad API key');
|
|
466
472
|
} else if (err instanceof CStarError) {
|
package/dist/auth/index.cjs
CHANGED
|
@@ -59,7 +59,7 @@ var ErrorType = {
|
|
|
59
59
|
API_ERROR: "api_error",
|
|
60
60
|
SERVER_ERROR: "server_error"
|
|
61
61
|
};
|
|
62
|
-
var DEFAULT_DOC_URL = "https://cstar.help/developers/
|
|
62
|
+
var DEFAULT_DOC_URL = "https://www.cstar.help/developers/errors";
|
|
63
63
|
function normalizeArgs(messageOrStatus, maybeBody, defaults) {
|
|
64
64
|
if (typeof messageOrStatus === "string") {
|
|
65
65
|
return {
|
|
@@ -102,7 +102,7 @@ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
|
|
|
102
102
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
103
103
|
type: ErrorType.AUTHENTICATION_ERROR,
|
|
104
104
|
code: "authentication_failed",
|
|
105
|
-
doc_url: `${DEFAULT_DOC_URL}#authentication-
|
|
105
|
+
doc_url: `${DEFAULT_DOC_URL}#authentication-errors`
|
|
106
106
|
});
|
|
107
107
|
super(statusCode, resolved);
|
|
108
108
|
this.name = "CStarAuthenticationError";
|
|
@@ -113,11 +113,11 @@ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
|
|
|
113
113
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
114
114
|
type: ErrorType.RATE_LIMIT_ERROR,
|
|
115
115
|
code: "rate_limit_exceeded",
|
|
116
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
116
|
+
doc_url: `${DEFAULT_DOC_URL}#rate_limit_exceeded`
|
|
117
117
|
});
|
|
118
118
|
super(statusCode === 0 ? 429 : statusCode, resolved);
|
|
119
119
|
this.name = "CStarRateLimitError";
|
|
120
|
-
this.retryAfter = retryAfter
|
|
120
|
+
this.retryAfter = retryAfter;
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
123
|
var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
|
|
@@ -125,7 +125,7 @@ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
|
|
|
125
125
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
126
126
|
type: ErrorType.NOT_FOUND_ERROR,
|
|
127
127
|
code: "resource_not_found",
|
|
128
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
128
|
+
doc_url: `${DEFAULT_DOC_URL}#resource_not_found`
|
|
129
129
|
});
|
|
130
130
|
super(statusCode, resolved);
|
|
131
131
|
this.name = "CStarNotFoundError";
|
|
@@ -136,7 +136,7 @@ var CStarValidationErrorImpl = class extends CStarErrorImpl {
|
|
|
136
136
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
137
137
|
type: ErrorType.INVALID_REQUEST_ERROR,
|
|
138
138
|
code: "validation_error",
|
|
139
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
139
|
+
doc_url: `${DEFAULT_DOC_URL}#invalid-request-errors`
|
|
140
140
|
});
|
|
141
141
|
super(statusCode, resolved);
|
|
142
142
|
this.name = "CStarValidationError";
|
|
@@ -147,7 +147,7 @@ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
|
|
|
147
147
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
148
148
|
type: ErrorType.PERMISSION_ERROR,
|
|
149
149
|
code: "permission_denied",
|
|
150
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
150
|
+
doc_url: `${DEFAULT_DOC_URL}#insufficient_permissions`
|
|
151
151
|
});
|
|
152
152
|
super(statusCode, resolved);
|
|
153
153
|
this.name = "CStarPermissionError";
|
|
@@ -158,7 +158,7 @@ var CStarConflictErrorImpl = class extends CStarErrorImpl {
|
|
|
158
158
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
159
159
|
type: ErrorType.CONFLICT_ERROR,
|
|
160
160
|
code: "conflict",
|
|
161
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
161
|
+
doc_url: `${DEFAULT_DOC_URL}#resource_conflict`
|
|
162
162
|
});
|
|
163
163
|
super(statusCode, resolved);
|
|
164
164
|
this.name = "CStarConflictError";
|
|
@@ -169,7 +169,7 @@ var CStarServerErrorImpl = class extends CStarErrorImpl {
|
|
|
169
169
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
170
170
|
type: ErrorType.SERVER_ERROR,
|
|
171
171
|
code: "server_error",
|
|
172
|
-
doc_url: `${DEFAULT_DOC_URL}#server-
|
|
172
|
+
doc_url: `${DEFAULT_DOC_URL}#server-errors`
|
|
173
173
|
});
|
|
174
174
|
super(statusCode, resolved);
|
|
175
175
|
this.name = "CStarServerError";
|
|
@@ -180,7 +180,7 @@ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
|
|
|
180
180
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
181
181
|
type: ErrorType.FEATURE_NOT_CONFIGURED,
|
|
182
182
|
code: "feature_not_configured",
|
|
183
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
183
|
+
doc_url: `${DEFAULT_DOC_URL}#feature_disabled`
|
|
184
184
|
});
|
|
185
185
|
super(statusCode, resolved);
|
|
186
186
|
this.name = "CStarFeatureDisabledError";
|
|
@@ -190,12 +190,12 @@ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
|
|
|
190
190
|
};
|
|
191
191
|
var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
|
|
192
192
|
constructor(message) {
|
|
193
|
-
const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://cstar.help/developers/sdk/realtime#ssr";
|
|
193
|
+
const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://www.cstar.help/developers/sdk/js/realtime#ssr";
|
|
194
194
|
super(0, {
|
|
195
195
|
type: ErrorType.API_ERROR,
|
|
196
196
|
code: "realtime_unavailable",
|
|
197
197
|
message: resolved,
|
|
198
|
-
doc_url: "https://cstar.help/developers/sdk/realtime#ssr"
|
|
198
|
+
doc_url: "https://www.cstar.help/developers/sdk/js/realtime#ssr"
|
|
199
199
|
});
|
|
200
200
|
this.name = "CStarRealtimeUnavailableError";
|
|
201
201
|
}
|
|
@@ -302,7 +302,10 @@ function parseError(statusCode, body, retryAfter) {
|
|
|
302
302
|
doc_url: DEFAULT_DOC_URL
|
|
303
303
|
};
|
|
304
304
|
if (statusCode === 429) {
|
|
305
|
-
return new CStarRateLimitError(statusCode, errorBody, retryAfter
|
|
305
|
+
return new CStarRateLimitError(statusCode, errorBody, retryAfter);
|
|
306
|
+
}
|
|
307
|
+
if (errorBody.code === "feature_disabled") {
|
|
308
|
+
return new CStarFeatureDisabledError(statusCode, errorBody);
|
|
306
309
|
}
|
|
307
310
|
const StatusCls = STATUS_TO_CLASS[statusCode];
|
|
308
311
|
if (StatusCls) {
|
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-BnUUTVlT.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-BnUUTVlT.js';
|
|
2
2
|
|
|
3
3
|
/** Configuration for the AuthClient. */
|
|
4
4
|
interface AuthConfig {
|
package/dist/auth/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var ErrorType = {
|
|
|
10
10
|
API_ERROR: "api_error",
|
|
11
11
|
SERVER_ERROR: "server_error"
|
|
12
12
|
};
|
|
13
|
-
var DEFAULT_DOC_URL = "https://cstar.help/developers/
|
|
13
|
+
var DEFAULT_DOC_URL = "https://www.cstar.help/developers/errors";
|
|
14
14
|
function normalizeArgs(messageOrStatus, maybeBody, defaults) {
|
|
15
15
|
if (typeof messageOrStatus === "string") {
|
|
16
16
|
return {
|
|
@@ -53,7 +53,7 @@ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
|
|
|
53
53
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
54
54
|
type: ErrorType.AUTHENTICATION_ERROR,
|
|
55
55
|
code: "authentication_failed",
|
|
56
|
-
doc_url: `${DEFAULT_DOC_URL}#authentication-
|
|
56
|
+
doc_url: `${DEFAULT_DOC_URL}#authentication-errors`
|
|
57
57
|
});
|
|
58
58
|
super(statusCode, resolved);
|
|
59
59
|
this.name = "CStarAuthenticationError";
|
|
@@ -64,11 +64,11 @@ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
|
|
|
64
64
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
65
65
|
type: ErrorType.RATE_LIMIT_ERROR,
|
|
66
66
|
code: "rate_limit_exceeded",
|
|
67
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
67
|
+
doc_url: `${DEFAULT_DOC_URL}#rate_limit_exceeded`
|
|
68
68
|
});
|
|
69
69
|
super(statusCode === 0 ? 429 : statusCode, resolved);
|
|
70
70
|
this.name = "CStarRateLimitError";
|
|
71
|
-
this.retryAfter = retryAfter
|
|
71
|
+
this.retryAfter = retryAfter;
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
|
|
@@ -76,7 +76,7 @@ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
|
|
|
76
76
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
77
77
|
type: ErrorType.NOT_FOUND_ERROR,
|
|
78
78
|
code: "resource_not_found",
|
|
79
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
79
|
+
doc_url: `${DEFAULT_DOC_URL}#resource_not_found`
|
|
80
80
|
});
|
|
81
81
|
super(statusCode, resolved);
|
|
82
82
|
this.name = "CStarNotFoundError";
|
|
@@ -87,7 +87,7 @@ var CStarValidationErrorImpl = class extends CStarErrorImpl {
|
|
|
87
87
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
88
88
|
type: ErrorType.INVALID_REQUEST_ERROR,
|
|
89
89
|
code: "validation_error",
|
|
90
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
90
|
+
doc_url: `${DEFAULT_DOC_URL}#invalid-request-errors`
|
|
91
91
|
});
|
|
92
92
|
super(statusCode, resolved);
|
|
93
93
|
this.name = "CStarValidationError";
|
|
@@ -98,7 +98,7 @@ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
|
|
|
98
98
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
99
99
|
type: ErrorType.PERMISSION_ERROR,
|
|
100
100
|
code: "permission_denied",
|
|
101
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
101
|
+
doc_url: `${DEFAULT_DOC_URL}#insufficient_permissions`
|
|
102
102
|
});
|
|
103
103
|
super(statusCode, resolved);
|
|
104
104
|
this.name = "CStarPermissionError";
|
|
@@ -109,7 +109,7 @@ var CStarConflictErrorImpl = class extends CStarErrorImpl {
|
|
|
109
109
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
110
110
|
type: ErrorType.CONFLICT_ERROR,
|
|
111
111
|
code: "conflict",
|
|
112
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
112
|
+
doc_url: `${DEFAULT_DOC_URL}#resource_conflict`
|
|
113
113
|
});
|
|
114
114
|
super(statusCode, resolved);
|
|
115
115
|
this.name = "CStarConflictError";
|
|
@@ -120,7 +120,7 @@ var CStarServerErrorImpl = class extends CStarErrorImpl {
|
|
|
120
120
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
121
121
|
type: ErrorType.SERVER_ERROR,
|
|
122
122
|
code: "server_error",
|
|
123
|
-
doc_url: `${DEFAULT_DOC_URL}#server-
|
|
123
|
+
doc_url: `${DEFAULT_DOC_URL}#server-errors`
|
|
124
124
|
});
|
|
125
125
|
super(statusCode, resolved);
|
|
126
126
|
this.name = "CStarServerError";
|
|
@@ -131,7 +131,7 @@ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
|
|
|
131
131
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
132
132
|
type: ErrorType.FEATURE_NOT_CONFIGURED,
|
|
133
133
|
code: "feature_not_configured",
|
|
134
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
134
|
+
doc_url: `${DEFAULT_DOC_URL}#feature_disabled`
|
|
135
135
|
});
|
|
136
136
|
super(statusCode, resolved);
|
|
137
137
|
this.name = "CStarFeatureDisabledError";
|
|
@@ -141,12 +141,12 @@ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
|
|
|
141
141
|
};
|
|
142
142
|
var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
|
|
143
143
|
constructor(message) {
|
|
144
|
-
const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://cstar.help/developers/sdk/realtime#ssr";
|
|
144
|
+
const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://www.cstar.help/developers/sdk/js/realtime#ssr";
|
|
145
145
|
super(0, {
|
|
146
146
|
type: ErrorType.API_ERROR,
|
|
147
147
|
code: "realtime_unavailable",
|
|
148
148
|
message: resolved,
|
|
149
|
-
doc_url: "https://cstar.help/developers/sdk/realtime#ssr"
|
|
149
|
+
doc_url: "https://www.cstar.help/developers/sdk/js/realtime#ssr"
|
|
150
150
|
});
|
|
151
151
|
this.name = "CStarRealtimeUnavailableError";
|
|
152
152
|
}
|
|
@@ -253,7 +253,10 @@ function parseError(statusCode, body, retryAfter) {
|
|
|
253
253
|
doc_url: DEFAULT_DOC_URL
|
|
254
254
|
};
|
|
255
255
|
if (statusCode === 429) {
|
|
256
|
-
return new CStarRateLimitError(statusCode, errorBody, retryAfter
|
|
256
|
+
return new CStarRateLimitError(statusCode, errorBody, retryAfter);
|
|
257
|
+
}
|
|
258
|
+
if (errorBody.code === "feature_disabled") {
|
|
259
|
+
return new CStarFeatureDisabledError(statusCode, errorBody);
|
|
257
260
|
}
|
|
258
261
|
const StatusCls = STATUS_TO_CLASS[statusCode];
|
|
259
262
|
if (StatusCls) {
|
package/dist/chat/index.d.cts
CHANGED
|
@@ -303,7 +303,7 @@ declare class ChatClientNetworkError extends ChatClientError {
|
|
|
303
303
|
* // HMAC mode
|
|
304
304
|
* const chat = new ChatClient({ teamSlug: 'acme' });
|
|
305
305
|
* await chat.identify(
|
|
306
|
-
* { externalId: '
|
|
306
|
+
* { externalId: 'user_123', email: 'jane@co.com', name: 'Jane', timestamp: Date.now() / 1000 },
|
|
307
307
|
* 'hmac_signature_hex'
|
|
308
308
|
* );
|
|
309
309
|
*
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -303,7 +303,7 @@ declare class ChatClientNetworkError extends ChatClientError {
|
|
|
303
303
|
* // HMAC mode
|
|
304
304
|
* const chat = new ChatClient({ teamSlug: 'acme' });
|
|
305
305
|
* await chat.identify(
|
|
306
|
-
* { externalId: '
|
|
306
|
+
* { externalId: 'user_123', email: 'jane@co.com', name: 'Jane', timestamp: Date.now() / 1000 },
|
|
307
307
|
* 'hmac_signature_hex'
|
|
308
308
|
* );
|
|
309
309
|
*
|
package/dist/community/index.cjs
CHANGED
|
@@ -49,7 +49,7 @@ var ErrorType = {
|
|
|
49
49
|
API_ERROR: "api_error",
|
|
50
50
|
SERVER_ERROR: "server_error"
|
|
51
51
|
};
|
|
52
|
-
var DEFAULT_DOC_URL = "https://cstar.help/developers/
|
|
52
|
+
var DEFAULT_DOC_URL = "https://www.cstar.help/developers/errors";
|
|
53
53
|
function normalizeArgs(messageOrStatus, maybeBody, defaults) {
|
|
54
54
|
if (typeof messageOrStatus === "string") {
|
|
55
55
|
return {
|
|
@@ -92,7 +92,7 @@ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
|
|
|
92
92
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
93
93
|
type: ErrorType.AUTHENTICATION_ERROR,
|
|
94
94
|
code: "authentication_failed",
|
|
95
|
-
doc_url: `${DEFAULT_DOC_URL}#authentication-
|
|
95
|
+
doc_url: `${DEFAULT_DOC_URL}#authentication-errors`
|
|
96
96
|
});
|
|
97
97
|
super(statusCode, resolved);
|
|
98
98
|
this.name = "CStarAuthenticationError";
|
|
@@ -103,11 +103,11 @@ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
|
|
|
103
103
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
104
104
|
type: ErrorType.RATE_LIMIT_ERROR,
|
|
105
105
|
code: "rate_limit_exceeded",
|
|
106
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
106
|
+
doc_url: `${DEFAULT_DOC_URL}#rate_limit_exceeded`
|
|
107
107
|
});
|
|
108
108
|
super(statusCode === 0 ? 429 : statusCode, resolved);
|
|
109
109
|
this.name = "CStarRateLimitError";
|
|
110
|
-
this.retryAfter = retryAfter
|
|
110
|
+
this.retryAfter = retryAfter;
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
|
|
@@ -115,7 +115,7 @@ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
|
|
|
115
115
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
116
116
|
type: ErrorType.NOT_FOUND_ERROR,
|
|
117
117
|
code: "resource_not_found",
|
|
118
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
118
|
+
doc_url: `${DEFAULT_DOC_URL}#resource_not_found`
|
|
119
119
|
});
|
|
120
120
|
super(statusCode, resolved);
|
|
121
121
|
this.name = "CStarNotFoundError";
|
|
@@ -126,7 +126,7 @@ var CStarValidationErrorImpl = class extends CStarErrorImpl {
|
|
|
126
126
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
127
127
|
type: ErrorType.INVALID_REQUEST_ERROR,
|
|
128
128
|
code: "validation_error",
|
|
129
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
129
|
+
doc_url: `${DEFAULT_DOC_URL}#invalid-request-errors`
|
|
130
130
|
});
|
|
131
131
|
super(statusCode, resolved);
|
|
132
132
|
this.name = "CStarValidationError";
|
|
@@ -137,7 +137,7 @@ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
|
|
|
137
137
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
138
138
|
type: ErrorType.PERMISSION_ERROR,
|
|
139
139
|
code: "permission_denied",
|
|
140
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
140
|
+
doc_url: `${DEFAULT_DOC_URL}#insufficient_permissions`
|
|
141
141
|
});
|
|
142
142
|
super(statusCode, resolved);
|
|
143
143
|
this.name = "CStarPermissionError";
|
|
@@ -148,7 +148,7 @@ var CStarConflictErrorImpl = class extends CStarErrorImpl {
|
|
|
148
148
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
149
149
|
type: ErrorType.CONFLICT_ERROR,
|
|
150
150
|
code: "conflict",
|
|
151
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
151
|
+
doc_url: `${DEFAULT_DOC_URL}#resource_conflict`
|
|
152
152
|
});
|
|
153
153
|
super(statusCode, resolved);
|
|
154
154
|
this.name = "CStarConflictError";
|
|
@@ -159,7 +159,7 @@ var CStarServerErrorImpl = class extends CStarErrorImpl {
|
|
|
159
159
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
160
160
|
type: ErrorType.SERVER_ERROR,
|
|
161
161
|
code: "server_error",
|
|
162
|
-
doc_url: `${DEFAULT_DOC_URL}#server-
|
|
162
|
+
doc_url: `${DEFAULT_DOC_URL}#server-errors`
|
|
163
163
|
});
|
|
164
164
|
super(statusCode, resolved);
|
|
165
165
|
this.name = "CStarServerError";
|
|
@@ -170,7 +170,7 @@ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
|
|
|
170
170
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
171
171
|
type: ErrorType.FEATURE_NOT_CONFIGURED,
|
|
172
172
|
code: "feature_not_configured",
|
|
173
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
173
|
+
doc_url: `${DEFAULT_DOC_URL}#feature_disabled`
|
|
174
174
|
});
|
|
175
175
|
super(statusCode, resolved);
|
|
176
176
|
this.name = "CStarFeatureDisabledError";
|
|
@@ -180,12 +180,12 @@ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
|
|
|
180
180
|
};
|
|
181
181
|
var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
|
|
182
182
|
constructor(message) {
|
|
183
|
-
const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://cstar.help/developers/sdk/realtime#ssr";
|
|
183
|
+
const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://www.cstar.help/developers/sdk/js/realtime#ssr";
|
|
184
184
|
super(0, {
|
|
185
185
|
type: ErrorType.API_ERROR,
|
|
186
186
|
code: "realtime_unavailable",
|
|
187
187
|
message: resolved,
|
|
188
|
-
doc_url: "https://cstar.help/developers/sdk/realtime#ssr"
|
|
188
|
+
doc_url: "https://www.cstar.help/developers/sdk/js/realtime#ssr"
|
|
189
189
|
});
|
|
190
190
|
this.name = "CStarRealtimeUnavailableError";
|
|
191
191
|
}
|
|
@@ -292,7 +292,10 @@ function parseError(statusCode, body, retryAfter) {
|
|
|
292
292
|
doc_url: DEFAULT_DOC_URL
|
|
293
293
|
};
|
|
294
294
|
if (statusCode === 429) {
|
|
295
|
-
return new CStarRateLimitError(statusCode, errorBody, retryAfter
|
|
295
|
+
return new CStarRateLimitError(statusCode, errorBody, retryAfter);
|
|
296
|
+
}
|
|
297
|
+
if (errorBody.code === "feature_disabled") {
|
|
298
|
+
return new CStarFeatureDisabledError(statusCode, errorBody);
|
|
296
299
|
}
|
|
297
300
|
const StatusCls = STATUS_TO_CLASS[statusCode];
|
|
298
301
|
if (StatusCls) {
|
|
@@ -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-BHCahwev.cjs';
|
|
2
2
|
export { n as CommunityComment } from '../types-BHCahwev.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-BnUUTVlT.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-BHCahwev.js';
|
|
2
2
|
export { n as CommunityComment } from '../types-BHCahwev.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-BnUUTVlT.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Public community client. No authentication required.
|
package/dist/community/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var ErrorType = {
|
|
|
10
10
|
API_ERROR: "api_error",
|
|
11
11
|
SERVER_ERROR: "server_error"
|
|
12
12
|
};
|
|
13
|
-
var DEFAULT_DOC_URL = "https://cstar.help/developers/
|
|
13
|
+
var DEFAULT_DOC_URL = "https://www.cstar.help/developers/errors";
|
|
14
14
|
function normalizeArgs(messageOrStatus, maybeBody, defaults) {
|
|
15
15
|
if (typeof messageOrStatus === "string") {
|
|
16
16
|
return {
|
|
@@ -53,7 +53,7 @@ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
|
|
|
53
53
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
54
54
|
type: ErrorType.AUTHENTICATION_ERROR,
|
|
55
55
|
code: "authentication_failed",
|
|
56
|
-
doc_url: `${DEFAULT_DOC_URL}#authentication-
|
|
56
|
+
doc_url: `${DEFAULT_DOC_URL}#authentication-errors`
|
|
57
57
|
});
|
|
58
58
|
super(statusCode, resolved);
|
|
59
59
|
this.name = "CStarAuthenticationError";
|
|
@@ -64,11 +64,11 @@ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
|
|
|
64
64
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
65
65
|
type: ErrorType.RATE_LIMIT_ERROR,
|
|
66
66
|
code: "rate_limit_exceeded",
|
|
67
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
67
|
+
doc_url: `${DEFAULT_DOC_URL}#rate_limit_exceeded`
|
|
68
68
|
});
|
|
69
69
|
super(statusCode === 0 ? 429 : statusCode, resolved);
|
|
70
70
|
this.name = "CStarRateLimitError";
|
|
71
|
-
this.retryAfter = retryAfter
|
|
71
|
+
this.retryAfter = retryAfter;
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
|
|
@@ -76,7 +76,7 @@ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
|
|
|
76
76
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
77
77
|
type: ErrorType.NOT_FOUND_ERROR,
|
|
78
78
|
code: "resource_not_found",
|
|
79
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
79
|
+
doc_url: `${DEFAULT_DOC_URL}#resource_not_found`
|
|
80
80
|
});
|
|
81
81
|
super(statusCode, resolved);
|
|
82
82
|
this.name = "CStarNotFoundError";
|
|
@@ -87,7 +87,7 @@ var CStarValidationErrorImpl = class extends CStarErrorImpl {
|
|
|
87
87
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
88
88
|
type: ErrorType.INVALID_REQUEST_ERROR,
|
|
89
89
|
code: "validation_error",
|
|
90
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
90
|
+
doc_url: `${DEFAULT_DOC_URL}#invalid-request-errors`
|
|
91
91
|
});
|
|
92
92
|
super(statusCode, resolved);
|
|
93
93
|
this.name = "CStarValidationError";
|
|
@@ -98,7 +98,7 @@ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
|
|
|
98
98
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
99
99
|
type: ErrorType.PERMISSION_ERROR,
|
|
100
100
|
code: "permission_denied",
|
|
101
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
101
|
+
doc_url: `${DEFAULT_DOC_URL}#insufficient_permissions`
|
|
102
102
|
});
|
|
103
103
|
super(statusCode, resolved);
|
|
104
104
|
this.name = "CStarPermissionError";
|
|
@@ -109,7 +109,7 @@ var CStarConflictErrorImpl = class extends CStarErrorImpl {
|
|
|
109
109
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
110
110
|
type: ErrorType.CONFLICT_ERROR,
|
|
111
111
|
code: "conflict",
|
|
112
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
112
|
+
doc_url: `${DEFAULT_DOC_URL}#resource_conflict`
|
|
113
113
|
});
|
|
114
114
|
super(statusCode, resolved);
|
|
115
115
|
this.name = "CStarConflictError";
|
|
@@ -120,7 +120,7 @@ var CStarServerErrorImpl = class extends CStarErrorImpl {
|
|
|
120
120
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
121
121
|
type: ErrorType.SERVER_ERROR,
|
|
122
122
|
code: "server_error",
|
|
123
|
-
doc_url: `${DEFAULT_DOC_URL}#server-
|
|
123
|
+
doc_url: `${DEFAULT_DOC_URL}#server-errors`
|
|
124
124
|
});
|
|
125
125
|
super(statusCode, resolved);
|
|
126
126
|
this.name = "CStarServerError";
|
|
@@ -131,7 +131,7 @@ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
|
|
|
131
131
|
const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
|
|
132
132
|
type: ErrorType.FEATURE_NOT_CONFIGURED,
|
|
133
133
|
code: "feature_not_configured",
|
|
134
|
-
doc_url: `${DEFAULT_DOC_URL}#
|
|
134
|
+
doc_url: `${DEFAULT_DOC_URL}#feature_disabled`
|
|
135
135
|
});
|
|
136
136
|
super(statusCode, resolved);
|
|
137
137
|
this.name = "CStarFeatureDisabledError";
|
|
@@ -141,12 +141,12 @@ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
|
|
|
141
141
|
};
|
|
142
142
|
var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
|
|
143
143
|
constructor(message) {
|
|
144
|
-
const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://cstar.help/developers/sdk/realtime#ssr";
|
|
144
|
+
const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://www.cstar.help/developers/sdk/js/realtime#ssr";
|
|
145
145
|
super(0, {
|
|
146
146
|
type: ErrorType.API_ERROR,
|
|
147
147
|
code: "realtime_unavailable",
|
|
148
148
|
message: resolved,
|
|
149
|
-
doc_url: "https://cstar.help/developers/sdk/realtime#ssr"
|
|
149
|
+
doc_url: "https://www.cstar.help/developers/sdk/js/realtime#ssr"
|
|
150
150
|
});
|
|
151
151
|
this.name = "CStarRealtimeUnavailableError";
|
|
152
152
|
}
|
|
@@ -253,7 +253,10 @@ function parseError(statusCode, body, retryAfter) {
|
|
|
253
253
|
doc_url: DEFAULT_DOC_URL
|
|
254
254
|
};
|
|
255
255
|
if (statusCode === 429) {
|
|
256
|
-
return new CStarRateLimitError(statusCode, errorBody, retryAfter
|
|
256
|
+
return new CStarRateLimitError(statusCode, errorBody, retryAfter);
|
|
257
|
+
}
|
|
258
|
+
if (errorBody.code === "feature_disabled") {
|
|
259
|
+
return new CStarFeatureDisabledError(statusCode, errorBody);
|
|
257
260
|
}
|
|
258
261
|
const StatusCls = STATUS_TO_CLASS[statusCode];
|
|
259
262
|
if (StatusCls) {
|
|
@@ -57,7 +57,8 @@ declare class CStarAuthenticationErrorImpl extends CStarErrorImpl {
|
|
|
57
57
|
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
58
58
|
}
|
|
59
59
|
declare class CStarRateLimitErrorImpl extends CStarErrorImpl {
|
|
60
|
-
|
|
60
|
+
/** Seconds to wait, from the response's Retry-After; undefined when it gave none. */
|
|
61
|
+
readonly retryAfter: number | undefined;
|
|
61
62
|
constructor(messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number);
|
|
62
63
|
}
|
|
63
64
|
declare class CStarNotFoundErrorImpl extends CStarErrorImpl {
|
|
@@ -57,7 +57,8 @@ declare class CStarAuthenticationErrorImpl extends CStarErrorImpl {
|
|
|
57
57
|
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
58
58
|
}
|
|
59
59
|
declare class CStarRateLimitErrorImpl extends CStarErrorImpl {
|
|
60
|
-
|
|
60
|
+
/** Seconds to wait, from the response's Retry-After; undefined when it gave none. */
|
|
61
|
+
readonly retryAfter: number | undefined;
|
|
61
62
|
constructor(messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number);
|
|
62
63
|
}
|
|
63
64
|
declare class CStarNotFoundErrorImpl extends CStarErrorImpl {
|