scorezilla 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +22 -11
- package/CHANGELOG.md +21 -0
- package/README.md +26 -0
- package/dist/errors-8qzE40-2.d.ts +170 -0
- package/dist/errors-Bu084BD9.d.cts +170 -0
- package/dist/headless.cjs +886 -0
- package/dist/headless.cjs.map +1 -0
- package/dist/headless.d.cts +59 -0
- package/dist/headless.d.ts +59 -0
- package/dist/headless.js +883 -0
- package/dist/headless.js.map +1 -0
- package/dist/index.cjs +13 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +3 -2
- package/dist/server.d.ts +3 -2
- package/dist/server.js +1 -1
- package/dist/{errors-BhPRMQiV.d.cts → types-BxxzS_pF.d.cts} +23 -169
- package/dist/{errors-BhPRMQiV.d.ts → types-BxxzS_pF.d.ts} +23 -169
- package/package.json +14 -1
|
@@ -97,7 +97,25 @@ type ScorezillaErrorCode = 'unauthorized' | 'forbidden' | 'not_found' | 'invalid
|
|
|
97
97
|
/** 402 Payment Required — tenant exceeded their monthly submission cap, OR
|
|
98
98
|
* the tenant is `'suspended'` (see {@link UsageCapReason}). The error body
|
|
99
99
|
* carries `tier`, `cap`, `count`, `period`, `resetsAt`. */
|
|
100
|
-
| 'usage_cap_exceeded'
|
|
100
|
+
| 'usage_cap_exceeded'
|
|
101
|
+
/** 402 — the board's tenant is suspended. Returned by the READ paths
|
|
102
|
+
* (`getLeaderboard` / `getPlayerRank` / `getWindowAround`); the submit path
|
|
103
|
+
* instead returns `usage_cap_exceeded` with `reason: 'suspended'`. */
|
|
104
|
+
| 'tenant_suspended'
|
|
105
|
+
/** 403 — the player is on this board's denylist (banned by the game owner). */
|
|
106
|
+
| 'player_banned'
|
|
107
|
+
/** 409 — the requested display `name` is already held by a different player. */
|
|
108
|
+
| 'name_taken'
|
|
109
|
+
/** 409 — the board is archived (frozen); writes are rejected. */
|
|
110
|
+
| 'board_archived'
|
|
111
|
+
/** 403 — the board requires a Cloudflare Turnstile token and none was sent. */
|
|
112
|
+
| 'turnstile_required'
|
|
113
|
+
/** 403 — the supplied Turnstile token failed verification. */
|
|
114
|
+
| 'turnstile_failed'
|
|
115
|
+
/** 403 — the Turnstile token was solved on an origin not allowed for this game. */
|
|
116
|
+
| 'turnstile_hostname_mismatch'
|
|
117
|
+
/** 403 — the request Origin is not in the board's embed allowlist. */
|
|
118
|
+
| 'origin_not_allowed' | (string & {});
|
|
101
119
|
/** Reason sub-classifier on `out_of_bounds` errors. Open union — see {@link ScorezillaErrorCode}. */
|
|
102
120
|
type OutOfBoundsReason = 'below_min' | 'above_max' | (string & {});
|
|
103
121
|
/** Reason sub-classifier on `usage_cap_exceeded` errors.
|
|
@@ -160,6 +178,9 @@ interface RankedEntry {
|
|
|
160
178
|
/** Milliseconds since epoch. */
|
|
161
179
|
submittedAt: number;
|
|
162
180
|
metadata?: Record<string, unknown>;
|
|
181
|
+
/** The player's public display name, when they've set one. Absent on older
|
|
182
|
+
* entries and for players who submit without a name. */
|
|
183
|
+
name?: string;
|
|
163
184
|
}
|
|
164
185
|
/** Payload from `POST /v1/boards/:boardId/scores`. */
|
|
165
186
|
interface SubmitScoreResponse {
|
|
@@ -217,171 +238,4 @@ interface WindowAroundResponse {
|
|
|
217
238
|
entries: RankedEntry[];
|
|
218
239
|
}
|
|
219
240
|
|
|
220
|
-
|
|
221
|
-
* SDK error type.
|
|
222
|
-
*
|
|
223
|
-
* Every non-2xx API response is normalized into a `ScorezillaError` instance
|
|
224
|
-
* by the transport layer. Network failures and timeouts surface as the same
|
|
225
|
-
* class (with `status: 0`) so callers have a single error type to catch.
|
|
226
|
-
*
|
|
227
|
-
* **Invariant — consumers MUST branch on `code` (and optionally `reason`),
|
|
228
|
-
* never on `message`.** The English-language `message` is for operator
|
|
229
|
-
* logging only and is explicitly **not** part of the SemVer contract; a
|
|
230
|
-
* minor release MAY reword any message. Machine logic that depends on
|
|
231
|
-
* message text will break silently across upgrades.
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Options for {@link ScorezillaError.from}.
|
|
236
|
-
*
|
|
237
|
-
* The fields mirror what's available after a fetch round-trip: the HTTP
|
|
238
|
-
* status, the parsed JSON body (if any), the request ID from
|
|
239
|
-
* `X-Request-Id`, and an optional `cause` for the underlying
|
|
240
|
-
* network/abort error.
|
|
241
|
-
*/
|
|
242
|
-
interface ScorezillaErrorFromInit {
|
|
243
|
-
status: number;
|
|
244
|
-
body?: ApiError | undefined;
|
|
245
|
-
requestId?: string | undefined;
|
|
246
|
-
cause?: unknown;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Thrown by the SDK for every failure path — non-2xx responses, network
|
|
250
|
-
* errors, aborts, and timeouts.
|
|
251
|
-
*
|
|
252
|
-
* Cross-realm `instanceof` is guaranteed: the class sets `Error.prototype`
|
|
253
|
-
* explicitly so checks survive iframe / worker boundaries.
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* ```ts
|
|
257
|
-
* try {
|
|
258
|
-
* await sz.submitScore({ boardId, playerId, score });
|
|
259
|
-
* } catch (e) {
|
|
260
|
-
* if (!(e instanceof ScorezillaError)) throw e;
|
|
261
|
-
*
|
|
262
|
-
* if (e.isRateLimited()) {
|
|
263
|
-
* await sleep((e.retryAfter ?? 30) * 1000);
|
|
264
|
-
* return retry();
|
|
265
|
-
* }
|
|
266
|
-
* if (e.code === 'out_of_bounds') {
|
|
267
|
-
* console.warn(`Score crosses ${e.reason} bound (limit ${e.bound})`);
|
|
268
|
-
* return;
|
|
269
|
-
* }
|
|
270
|
-
* if (e.isAuth()) throw new Error('SDK misconfigured — bad publicKey');
|
|
271
|
-
*
|
|
272
|
-
* // Anything else: surface to your reporter with requestId for support.
|
|
273
|
-
* console.error(`Scorezilla ${e.code} (${e.status}) — request ${e.requestId}`);
|
|
274
|
-
* throw e;
|
|
275
|
-
* }
|
|
276
|
-
* ```
|
|
277
|
-
*
|
|
278
|
-
* @since 0.1.0
|
|
279
|
-
* @stability stable
|
|
280
|
-
*/
|
|
281
|
-
declare class ScorezillaError extends Error {
|
|
282
|
-
/** HTTP status of the response, or {@link STATUS_NETWORK_ERROR} (0) for
|
|
283
|
-
* network / abort / timeout. */
|
|
284
|
-
readonly status: number;
|
|
285
|
-
/** Machine-stable error code from the API. Open union — see
|
|
286
|
-
* {@link ScorezillaErrorCode}. For network errors, this is `'network_error'`;
|
|
287
|
-
* for aborts, `'aborted'`; for timeouts, `'timeout'`. */
|
|
288
|
-
readonly code: ScorezillaErrorCode;
|
|
289
|
-
/** Sub-classifier — present on:
|
|
290
|
-
* - `out_of_bounds`: `'below_min' | 'above_max'`
|
|
291
|
-
* - `usage_cap_exceeded`: `'over_cap' | 'suspended'`
|
|
292
|
-
* and possibly other codes in future minor releases. */
|
|
293
|
-
readonly reason: OutOfBoundsReason | UsageCapReason | string | undefined;
|
|
294
|
-
/** Seconds — present on `rate_limited`. Honored by the transport's retry
|
|
295
|
-
* policy (Step 2.4). */
|
|
296
|
-
readonly retryAfter: number | undefined;
|
|
297
|
-
/** Server-issued request ID, lifted from the `X-Request-Id` response
|
|
298
|
-
* header. Pass this to support when filing bugs. */
|
|
299
|
-
readonly requestId: string | undefined;
|
|
300
|
-
/** The bound value crossed on `out_of_bounds`. */
|
|
301
|
-
readonly bound: number | undefined;
|
|
302
|
-
/** Which rate-limit layer fired on `rate_limited`. */
|
|
303
|
-
readonly layer: string | undefined;
|
|
304
|
-
/** Tenant's billing tier — present on `usage_cap_exceeded`. */
|
|
305
|
-
readonly tier: BillingTier | undefined;
|
|
306
|
-
/** The cap value crossed on `usage_cap_exceeded`. `0` indicates a
|
|
307
|
-
* suspended tenant. `undefined` on all other error codes. */
|
|
308
|
-
readonly cap: number | undefined;
|
|
309
|
-
/** The post-increment submit count on `usage_cap_exceeded`. Always
|
|
310
|
-
* `> cap` when `reason === 'over_cap'`. */
|
|
311
|
-
readonly count: number | undefined;
|
|
312
|
-
/** The period the count belongs to on `usage_cap_exceeded`, in `YYYY-MM`
|
|
313
|
-
* UTC form. */
|
|
314
|
-
readonly period: string | undefined;
|
|
315
|
-
/** ISO-8601 timestamp of midnight UTC on the 1st of the next month —
|
|
316
|
-
* the counter's natural reset point on `usage_cap_exceeded`. */
|
|
317
|
-
readonly resetsAt: string | undefined;
|
|
318
|
-
/** The underlying cause (e.g., a `TypeError: fetch failed`) for
|
|
319
|
-
* network/abort/timeout paths. `undefined` when the error came from a
|
|
320
|
-
* successfully-parsed API error body. */
|
|
321
|
-
readonly cause: unknown;
|
|
322
|
-
constructor(message: string, init: {
|
|
323
|
-
status: number;
|
|
324
|
-
code: ScorezillaErrorCode;
|
|
325
|
-
reason?: string | undefined;
|
|
326
|
-
retryAfter?: number | undefined;
|
|
327
|
-
requestId?: string | undefined;
|
|
328
|
-
bound?: number | undefined;
|
|
329
|
-
layer?: string | undefined;
|
|
330
|
-
tier?: BillingTier | undefined;
|
|
331
|
-
cap?: number | undefined;
|
|
332
|
-
count?: number | undefined;
|
|
333
|
-
period?: string | undefined;
|
|
334
|
-
resetsAt?: string | undefined;
|
|
335
|
-
cause?: unknown;
|
|
336
|
-
});
|
|
337
|
-
/** `true` when this error is a 429 / `rate_limited`. */
|
|
338
|
-
isRateLimited(): boolean;
|
|
339
|
-
/**
|
|
340
|
-
* `true` when this error is a 402 / `usage_cap_exceeded`. The tenant
|
|
341
|
-
* has either hit their tier's monthly submit cap (`reason ===
|
|
342
|
-
* 'over_cap'`) or is suspended (`reason === 'suspended'`).
|
|
343
|
-
*
|
|
344
|
-
* Consumers SHOULD NOT auto-retry on this error — the cap doesn't lift
|
|
345
|
-
* until `resetsAt`. Surface to the developer with an upgrade prompt
|
|
346
|
-
* (over_cap) or contact-support message (suspended).
|
|
347
|
-
*/
|
|
348
|
-
isUsageCapExceeded(): boolean;
|
|
349
|
-
/** `true` when this error is a 402 + reason 'suspended' (vs over-cap). */
|
|
350
|
-
isSuspended(): boolean;
|
|
351
|
-
/** `true` when this error is a 401 / `unauthorized` (or 403 / `forbidden`). */
|
|
352
|
-
isAuth(): boolean;
|
|
353
|
-
/** `true` when this error is a 404 / `not_found`. */
|
|
354
|
-
isNotFound(): boolean;
|
|
355
|
-
/** `true` when this error is a 422 / `out_of_bounds` (score below/above board limit). */
|
|
356
|
-
isOutOfBounds(): boolean;
|
|
357
|
-
/** `true` for the SDK's retryable conditions: pure network errors, 5xx, and
|
|
358
|
-
* 429. Deliberately excludes `timeout` and `aborted` — those are caller-
|
|
359
|
-
* observable terminal states, not transient. Aligned with `shouldRetryError`
|
|
360
|
-
* in `retry.ts` so a consumer mirroring the SDK's retry policy gets the
|
|
361
|
-
* same answer the transport does. */
|
|
362
|
-
isTransient(): boolean;
|
|
363
|
-
/** `true` when this error is a 409 / `conflict` (idempotency-key conflict
|
|
364
|
-
* on retry). */
|
|
365
|
-
isConflict(): boolean;
|
|
366
|
-
/**
|
|
367
|
-
* Build a `ScorezillaError` from a fetch round-trip outcome.
|
|
368
|
-
*
|
|
369
|
-
* Prefer this over `new ScorezillaError(...)` from the transport layer —
|
|
370
|
-
* it does the mapping from API response shape to error fields in one
|
|
371
|
-
* place, so future fields like `correlationId` get added once here.
|
|
372
|
-
*
|
|
373
|
-
* @param init - status, optional parsed body, optional requestId, optional cause
|
|
374
|
-
*/
|
|
375
|
-
static from(init: ScorezillaErrorFromInit): ScorezillaError;
|
|
376
|
-
/**
|
|
377
|
-
* Build a `ScorezillaError` for a transport-level failure (no HTTP
|
|
378
|
-
* response received): network error, abort, or timeout.
|
|
379
|
-
*/
|
|
380
|
-
static network(message: string, cause: unknown): ScorezillaError;
|
|
381
|
-
/** Build a `ScorezillaError` for an `AbortSignal`-triggered cancellation. */
|
|
382
|
-
static aborted(cause: unknown): ScorezillaError;
|
|
383
|
-
/** Build a `ScorezillaError` for a request that exceeded its timeout budget. */
|
|
384
|
-
static timeout(timeoutMs: number): ScorezillaError;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export { type ApiSuccess as A, type BaseConfig as B, type FetchImpl as F, type LeaderboardResponse as L, type OutOfBoundsReason as O, type PlayerRankResponse as P, type RankedEntry as R, type ScorezillaConfig as S, type WindowAroundResponse as W, type SubmitScoreResponse as a, type ApiError as b, type ApiResponse as c, type PublicKeyConfig as d, ScorezillaError as e, type ScorezillaErrorCode as f, type SecretKeyConfig as g };
|
|
241
|
+
export type { ApiError as A, BillingTier as B, FetchImpl as F, LeaderboardResponse as L, OutOfBoundsReason as O, PublicKeyConfig as P, RankedEntry as R, ScorezillaErrorCode as S, UsageCapReason as U, WindowAroundResponse as W, ScorezillaConfig as a, ApiSuccess as b, SubmitScoreResponse as c, PlayerRankResponse as d, ApiResponse as e, BaseConfig as f, SecretKeyConfig as g };
|
|
@@ -97,7 +97,25 @@ type ScorezillaErrorCode = 'unauthorized' | 'forbidden' | 'not_found' | 'invalid
|
|
|
97
97
|
/** 402 Payment Required — tenant exceeded their monthly submission cap, OR
|
|
98
98
|
* the tenant is `'suspended'` (see {@link UsageCapReason}). The error body
|
|
99
99
|
* carries `tier`, `cap`, `count`, `period`, `resetsAt`. */
|
|
100
|
-
| 'usage_cap_exceeded'
|
|
100
|
+
| 'usage_cap_exceeded'
|
|
101
|
+
/** 402 — the board's tenant is suspended. Returned by the READ paths
|
|
102
|
+
* (`getLeaderboard` / `getPlayerRank` / `getWindowAround`); the submit path
|
|
103
|
+
* instead returns `usage_cap_exceeded` with `reason: 'suspended'`. */
|
|
104
|
+
| 'tenant_suspended'
|
|
105
|
+
/** 403 — the player is on this board's denylist (banned by the game owner). */
|
|
106
|
+
| 'player_banned'
|
|
107
|
+
/** 409 — the requested display `name` is already held by a different player. */
|
|
108
|
+
| 'name_taken'
|
|
109
|
+
/** 409 — the board is archived (frozen); writes are rejected. */
|
|
110
|
+
| 'board_archived'
|
|
111
|
+
/** 403 — the board requires a Cloudflare Turnstile token and none was sent. */
|
|
112
|
+
| 'turnstile_required'
|
|
113
|
+
/** 403 — the supplied Turnstile token failed verification. */
|
|
114
|
+
| 'turnstile_failed'
|
|
115
|
+
/** 403 — the Turnstile token was solved on an origin not allowed for this game. */
|
|
116
|
+
| 'turnstile_hostname_mismatch'
|
|
117
|
+
/** 403 — the request Origin is not in the board's embed allowlist. */
|
|
118
|
+
| 'origin_not_allowed' | (string & {});
|
|
101
119
|
/** Reason sub-classifier on `out_of_bounds` errors. Open union — see {@link ScorezillaErrorCode}. */
|
|
102
120
|
type OutOfBoundsReason = 'below_min' | 'above_max' | (string & {});
|
|
103
121
|
/** Reason sub-classifier on `usage_cap_exceeded` errors.
|
|
@@ -160,6 +178,9 @@ interface RankedEntry {
|
|
|
160
178
|
/** Milliseconds since epoch. */
|
|
161
179
|
submittedAt: number;
|
|
162
180
|
metadata?: Record<string, unknown>;
|
|
181
|
+
/** The player's public display name, when they've set one. Absent on older
|
|
182
|
+
* entries and for players who submit without a name. */
|
|
183
|
+
name?: string;
|
|
163
184
|
}
|
|
164
185
|
/** Payload from `POST /v1/boards/:boardId/scores`. */
|
|
165
186
|
interface SubmitScoreResponse {
|
|
@@ -217,171 +238,4 @@ interface WindowAroundResponse {
|
|
|
217
238
|
entries: RankedEntry[];
|
|
218
239
|
}
|
|
219
240
|
|
|
220
|
-
|
|
221
|
-
* SDK error type.
|
|
222
|
-
*
|
|
223
|
-
* Every non-2xx API response is normalized into a `ScorezillaError` instance
|
|
224
|
-
* by the transport layer. Network failures and timeouts surface as the same
|
|
225
|
-
* class (with `status: 0`) so callers have a single error type to catch.
|
|
226
|
-
*
|
|
227
|
-
* **Invariant — consumers MUST branch on `code` (and optionally `reason`),
|
|
228
|
-
* never on `message`.** The English-language `message` is for operator
|
|
229
|
-
* logging only and is explicitly **not** part of the SemVer contract; a
|
|
230
|
-
* minor release MAY reword any message. Machine logic that depends on
|
|
231
|
-
* message text will break silently across upgrades.
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Options for {@link ScorezillaError.from}.
|
|
236
|
-
*
|
|
237
|
-
* The fields mirror what's available after a fetch round-trip: the HTTP
|
|
238
|
-
* status, the parsed JSON body (if any), the request ID from
|
|
239
|
-
* `X-Request-Id`, and an optional `cause` for the underlying
|
|
240
|
-
* network/abort error.
|
|
241
|
-
*/
|
|
242
|
-
interface ScorezillaErrorFromInit {
|
|
243
|
-
status: number;
|
|
244
|
-
body?: ApiError | undefined;
|
|
245
|
-
requestId?: string | undefined;
|
|
246
|
-
cause?: unknown;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Thrown by the SDK for every failure path — non-2xx responses, network
|
|
250
|
-
* errors, aborts, and timeouts.
|
|
251
|
-
*
|
|
252
|
-
* Cross-realm `instanceof` is guaranteed: the class sets `Error.prototype`
|
|
253
|
-
* explicitly so checks survive iframe / worker boundaries.
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* ```ts
|
|
257
|
-
* try {
|
|
258
|
-
* await sz.submitScore({ boardId, playerId, score });
|
|
259
|
-
* } catch (e) {
|
|
260
|
-
* if (!(e instanceof ScorezillaError)) throw e;
|
|
261
|
-
*
|
|
262
|
-
* if (e.isRateLimited()) {
|
|
263
|
-
* await sleep((e.retryAfter ?? 30) * 1000);
|
|
264
|
-
* return retry();
|
|
265
|
-
* }
|
|
266
|
-
* if (e.code === 'out_of_bounds') {
|
|
267
|
-
* console.warn(`Score crosses ${e.reason} bound (limit ${e.bound})`);
|
|
268
|
-
* return;
|
|
269
|
-
* }
|
|
270
|
-
* if (e.isAuth()) throw new Error('SDK misconfigured — bad publicKey');
|
|
271
|
-
*
|
|
272
|
-
* // Anything else: surface to your reporter with requestId for support.
|
|
273
|
-
* console.error(`Scorezilla ${e.code} (${e.status}) — request ${e.requestId}`);
|
|
274
|
-
* throw e;
|
|
275
|
-
* }
|
|
276
|
-
* ```
|
|
277
|
-
*
|
|
278
|
-
* @since 0.1.0
|
|
279
|
-
* @stability stable
|
|
280
|
-
*/
|
|
281
|
-
declare class ScorezillaError extends Error {
|
|
282
|
-
/** HTTP status of the response, or {@link STATUS_NETWORK_ERROR} (0) for
|
|
283
|
-
* network / abort / timeout. */
|
|
284
|
-
readonly status: number;
|
|
285
|
-
/** Machine-stable error code from the API. Open union — see
|
|
286
|
-
* {@link ScorezillaErrorCode}. For network errors, this is `'network_error'`;
|
|
287
|
-
* for aborts, `'aborted'`; for timeouts, `'timeout'`. */
|
|
288
|
-
readonly code: ScorezillaErrorCode;
|
|
289
|
-
/** Sub-classifier — present on:
|
|
290
|
-
* - `out_of_bounds`: `'below_min' | 'above_max'`
|
|
291
|
-
* - `usage_cap_exceeded`: `'over_cap' | 'suspended'`
|
|
292
|
-
* and possibly other codes in future minor releases. */
|
|
293
|
-
readonly reason: OutOfBoundsReason | UsageCapReason | string | undefined;
|
|
294
|
-
/** Seconds — present on `rate_limited`. Honored by the transport's retry
|
|
295
|
-
* policy (Step 2.4). */
|
|
296
|
-
readonly retryAfter: number | undefined;
|
|
297
|
-
/** Server-issued request ID, lifted from the `X-Request-Id` response
|
|
298
|
-
* header. Pass this to support when filing bugs. */
|
|
299
|
-
readonly requestId: string | undefined;
|
|
300
|
-
/** The bound value crossed on `out_of_bounds`. */
|
|
301
|
-
readonly bound: number | undefined;
|
|
302
|
-
/** Which rate-limit layer fired on `rate_limited`. */
|
|
303
|
-
readonly layer: string | undefined;
|
|
304
|
-
/** Tenant's billing tier — present on `usage_cap_exceeded`. */
|
|
305
|
-
readonly tier: BillingTier | undefined;
|
|
306
|
-
/** The cap value crossed on `usage_cap_exceeded`. `0` indicates a
|
|
307
|
-
* suspended tenant. `undefined` on all other error codes. */
|
|
308
|
-
readonly cap: number | undefined;
|
|
309
|
-
/** The post-increment submit count on `usage_cap_exceeded`. Always
|
|
310
|
-
* `> cap` when `reason === 'over_cap'`. */
|
|
311
|
-
readonly count: number | undefined;
|
|
312
|
-
/** The period the count belongs to on `usage_cap_exceeded`, in `YYYY-MM`
|
|
313
|
-
* UTC form. */
|
|
314
|
-
readonly period: string | undefined;
|
|
315
|
-
/** ISO-8601 timestamp of midnight UTC on the 1st of the next month —
|
|
316
|
-
* the counter's natural reset point on `usage_cap_exceeded`. */
|
|
317
|
-
readonly resetsAt: string | undefined;
|
|
318
|
-
/** The underlying cause (e.g., a `TypeError: fetch failed`) for
|
|
319
|
-
* network/abort/timeout paths. `undefined` when the error came from a
|
|
320
|
-
* successfully-parsed API error body. */
|
|
321
|
-
readonly cause: unknown;
|
|
322
|
-
constructor(message: string, init: {
|
|
323
|
-
status: number;
|
|
324
|
-
code: ScorezillaErrorCode;
|
|
325
|
-
reason?: string | undefined;
|
|
326
|
-
retryAfter?: number | undefined;
|
|
327
|
-
requestId?: string | undefined;
|
|
328
|
-
bound?: number | undefined;
|
|
329
|
-
layer?: string | undefined;
|
|
330
|
-
tier?: BillingTier | undefined;
|
|
331
|
-
cap?: number | undefined;
|
|
332
|
-
count?: number | undefined;
|
|
333
|
-
period?: string | undefined;
|
|
334
|
-
resetsAt?: string | undefined;
|
|
335
|
-
cause?: unknown;
|
|
336
|
-
});
|
|
337
|
-
/** `true` when this error is a 429 / `rate_limited`. */
|
|
338
|
-
isRateLimited(): boolean;
|
|
339
|
-
/**
|
|
340
|
-
* `true` when this error is a 402 / `usage_cap_exceeded`. The tenant
|
|
341
|
-
* has either hit their tier's monthly submit cap (`reason ===
|
|
342
|
-
* 'over_cap'`) or is suspended (`reason === 'suspended'`).
|
|
343
|
-
*
|
|
344
|
-
* Consumers SHOULD NOT auto-retry on this error — the cap doesn't lift
|
|
345
|
-
* until `resetsAt`. Surface to the developer with an upgrade prompt
|
|
346
|
-
* (over_cap) or contact-support message (suspended).
|
|
347
|
-
*/
|
|
348
|
-
isUsageCapExceeded(): boolean;
|
|
349
|
-
/** `true` when this error is a 402 + reason 'suspended' (vs over-cap). */
|
|
350
|
-
isSuspended(): boolean;
|
|
351
|
-
/** `true` when this error is a 401 / `unauthorized` (or 403 / `forbidden`). */
|
|
352
|
-
isAuth(): boolean;
|
|
353
|
-
/** `true` when this error is a 404 / `not_found`. */
|
|
354
|
-
isNotFound(): boolean;
|
|
355
|
-
/** `true` when this error is a 422 / `out_of_bounds` (score below/above board limit). */
|
|
356
|
-
isOutOfBounds(): boolean;
|
|
357
|
-
/** `true` for the SDK's retryable conditions: pure network errors, 5xx, and
|
|
358
|
-
* 429. Deliberately excludes `timeout` and `aborted` — those are caller-
|
|
359
|
-
* observable terminal states, not transient. Aligned with `shouldRetryError`
|
|
360
|
-
* in `retry.ts` so a consumer mirroring the SDK's retry policy gets the
|
|
361
|
-
* same answer the transport does. */
|
|
362
|
-
isTransient(): boolean;
|
|
363
|
-
/** `true` when this error is a 409 / `conflict` (idempotency-key conflict
|
|
364
|
-
* on retry). */
|
|
365
|
-
isConflict(): boolean;
|
|
366
|
-
/**
|
|
367
|
-
* Build a `ScorezillaError` from a fetch round-trip outcome.
|
|
368
|
-
*
|
|
369
|
-
* Prefer this over `new ScorezillaError(...)` from the transport layer —
|
|
370
|
-
* it does the mapping from API response shape to error fields in one
|
|
371
|
-
* place, so future fields like `correlationId` get added once here.
|
|
372
|
-
*
|
|
373
|
-
* @param init - status, optional parsed body, optional requestId, optional cause
|
|
374
|
-
*/
|
|
375
|
-
static from(init: ScorezillaErrorFromInit): ScorezillaError;
|
|
376
|
-
/**
|
|
377
|
-
* Build a `ScorezillaError` for a transport-level failure (no HTTP
|
|
378
|
-
* response received): network error, abort, or timeout.
|
|
379
|
-
*/
|
|
380
|
-
static network(message: string, cause: unknown): ScorezillaError;
|
|
381
|
-
/** Build a `ScorezillaError` for an `AbortSignal`-triggered cancellation. */
|
|
382
|
-
static aborted(cause: unknown): ScorezillaError;
|
|
383
|
-
/** Build a `ScorezillaError` for a request that exceeded its timeout budget. */
|
|
384
|
-
static timeout(timeoutMs: number): ScorezillaError;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export { type ApiSuccess as A, type BaseConfig as B, type FetchImpl as F, type LeaderboardResponse as L, type OutOfBoundsReason as O, type PlayerRankResponse as P, type RankedEntry as R, type ScorezillaConfig as S, type WindowAroundResponse as W, type SubmitScoreResponse as a, type ApiError as b, type ApiResponse as c, type PublicKeyConfig as d, ScorezillaError as e, type ScorezillaErrorCode as f, type SecretKeyConfig as g };
|
|
241
|
+
export type { ApiError as A, BillingTier as B, FetchImpl as F, LeaderboardResponse as L, OutOfBoundsReason as O, PublicKeyConfig as P, RankedEntry as R, ScorezillaErrorCode as S, UsageCapReason as U, WindowAroundResponse as W, ScorezillaConfig as a, ApiSuccess as b, SubmitScoreResponse as c, PlayerRankResponse as d, ApiResponse as e, BaseConfig as f, SecretKeyConfig as g };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scorezilla",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -80,6 +80,16 @@
|
|
|
80
80
|
"default": "./dist/identity.cjs"
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
|
+
"./headless": {
|
|
84
|
+
"import": {
|
|
85
|
+
"types": "./dist/headless.d.ts",
|
|
86
|
+
"default": "./dist/headless.js"
|
|
87
|
+
},
|
|
88
|
+
"require": {
|
|
89
|
+
"types": "./dist/headless.d.cts",
|
|
90
|
+
"default": "./dist/headless.cjs"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
83
93
|
"./phaser": {
|
|
84
94
|
"import": {
|
|
85
95
|
"types": "./dist/phaser.d.ts",
|
|
@@ -105,6 +115,9 @@
|
|
|
105
115
|
],
|
|
106
116
|
"identity": [
|
|
107
117
|
"./dist/identity.d.ts"
|
|
118
|
+
],
|
|
119
|
+
"headless": [
|
|
120
|
+
"./dist/headless.d.ts"
|
|
108
121
|
]
|
|
109
122
|
}
|
|
110
123
|
},
|