@crowdedkingdoms/crowdyjs 1.0.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.
Files changed (124) hide show
  1. package/LICENSE +21 -0
  2. package/MIGRATION.md +247 -0
  3. package/README.md +303 -0
  4. package/dist/auth-state.d.ts +11 -0
  5. package/dist/auth-state.d.ts.map +1 -0
  6. package/dist/auth-state.js +13 -0
  7. package/dist/client.d.ts +135 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +150 -0
  10. package/dist/crowdy-client.d.ts +182 -0
  11. package/dist/crowdy-client.d.ts.map +1 -0
  12. package/dist/crowdy-client.js +146 -0
  13. package/dist/domains/actors.d.ts +117 -0
  14. package/dist/domains/actors.d.ts.map +1 -0
  15. package/dist/domains/actors.js +140 -0
  16. package/dist/domains/admin.d.ts +61 -0
  17. package/dist/domains/admin.d.ts.map +1 -0
  18. package/dist/domains/admin.js +33 -0
  19. package/dist/domains/appAccess.d.ts +141 -0
  20. package/dist/domains/appAccess.d.ts.map +1 -0
  21. package/dist/domains/appAccess.js +198 -0
  22. package/dist/domains/apps.d.ts +192 -0
  23. package/dist/domains/apps.d.ts.map +1 -0
  24. package/dist/domains/apps.js +217 -0
  25. package/dist/domains/auth.d.ts +163 -0
  26. package/dist/domains/auth.d.ts.map +1 -0
  27. package/dist/domains/auth.js +208 -0
  28. package/dist/domains/avatars.d.ts +94 -0
  29. package/dist/domains/avatars.d.ts.map +1 -0
  30. package/dist/domains/avatars.js +137 -0
  31. package/dist/domains/billing.d.ts +97 -0
  32. package/dist/domains/billing.d.ts.map +1 -0
  33. package/dist/domains/billing.js +131 -0
  34. package/dist/domains/channels.d.ts +293 -0
  35. package/dist/domains/channels.d.ts.map +1 -0
  36. package/dist/domains/channels.js +353 -0
  37. package/dist/domains/chunks.d.ts +133 -0
  38. package/dist/domains/chunks.d.ts.map +1 -0
  39. package/dist/domains/chunks.js +153 -0
  40. package/dist/domains/controlPlane.d.ts +174 -0
  41. package/dist/domains/controlPlane.d.ts.map +1 -0
  42. package/dist/domains/controlPlane.js +252 -0
  43. package/dist/domains/environments.d.ts +155 -0
  44. package/dist/domains/environments.d.ts.map +1 -0
  45. package/dist/domains/environments.js +223 -0
  46. package/dist/domains/gameApps.d.ts +114 -0
  47. package/dist/domains/gameApps.d.ts.map +1 -0
  48. package/dist/domains/gameApps.js +169 -0
  49. package/dist/domains/gameModel.d.ts +668 -0
  50. package/dist/domains/gameModel.d.ts.map +1 -0
  51. package/dist/domains/gameModel.js +816 -0
  52. package/dist/domains/host.d.ts +35 -0
  53. package/dist/domains/host.d.ts.map +1 -0
  54. package/dist/domains/host.js +40 -0
  55. package/dist/domains/organizations.d.ts +179 -0
  56. package/dist/domains/organizations.d.ts.map +1 -0
  57. package/dist/domains/organizations.js +269 -0
  58. package/dist/domains/payments.d.ts +104 -0
  59. package/dist/domains/payments.d.ts.map +1 -0
  60. package/dist/domains/payments.js +129 -0
  61. package/dist/domains/platform.d.ts +49 -0
  62. package/dist/domains/platform.d.ts.map +1 -0
  63. package/dist/domains/platform.js +50 -0
  64. package/dist/domains/quotas.d.ts +62 -0
  65. package/dist/domains/quotas.d.ts.map +1 -0
  66. package/dist/domains/quotas.js +79 -0
  67. package/dist/domains/serverStatus.d.ts +90 -0
  68. package/dist/domains/serverStatus.d.ts.map +1 -0
  69. package/dist/domains/serverStatus.js +104 -0
  70. package/dist/domains/sharedEnvironment.d.ts +133 -0
  71. package/dist/domains/sharedEnvironment.d.ts.map +1 -0
  72. package/dist/domains/sharedEnvironment.js +179 -0
  73. package/dist/domains/state.d.ts +64 -0
  74. package/dist/domains/state.d.ts.map +1 -0
  75. package/dist/domains/state.js +75 -0
  76. package/dist/domains/teams.d.ts +292 -0
  77. package/dist/domains/teams.d.ts.map +1 -0
  78. package/dist/domains/teams.js +352 -0
  79. package/dist/domains/teleport.d.ts +41 -0
  80. package/dist/domains/teleport.d.ts.map +1 -0
  81. package/dist/domains/teleport.js +43 -0
  82. package/dist/domains/udp.d.ts +405 -0
  83. package/dist/domains/udp.d.ts.map +1 -0
  84. package/dist/domains/udp.js +457 -0
  85. package/dist/domains/usage.d.ts +76 -0
  86. package/dist/domains/usage.d.ts.map +1 -0
  87. package/dist/domains/usage.js +110 -0
  88. package/dist/domains/users.d.ts +147 -0
  89. package/dist/domains/users.d.ts.map +1 -0
  90. package/dist/domains/users.js +195 -0
  91. package/dist/domains/voxels.d.ts +136 -0
  92. package/dist/domains/voxels.d.ts.map +1 -0
  93. package/dist/domains/voxels.js +153 -0
  94. package/dist/errors.d.ts +158 -0
  95. package/dist/errors.d.ts.map +1 -0
  96. package/dist/errors.js +142 -0
  97. package/dist/generated/graphql.d.ts +12206 -0
  98. package/dist/generated/graphql.d.ts.map +1 -0
  99. package/dist/generated/graphql.js +474 -0
  100. package/dist/index.d.ts +84 -0
  101. package/dist/index.d.ts.map +1 -0
  102. package/dist/index.js +85 -0
  103. package/dist/logger.d.ts +8 -0
  104. package/dist/logger.d.ts.map +1 -0
  105. package/dist/logger.js +1 -0
  106. package/dist/realtime.d.ts +319 -0
  107. package/dist/realtime.d.ts.map +1 -0
  108. package/dist/realtime.js +390 -0
  109. package/dist/session.d.ts +73 -0
  110. package/dist/session.d.ts.map +1 -0
  111. package/dist/session.js +96 -0
  112. package/dist/subscriptions.d.ts +2 -0
  113. package/dist/subscriptions.d.ts.map +1 -0
  114. package/dist/subscriptions.js +1 -0
  115. package/dist/types.d.ts +658 -0
  116. package/dist/types.d.ts.map +1 -0
  117. package/dist/types.js +61 -0
  118. package/dist/utils.d.ts +98 -0
  119. package/dist/utils.d.ts.map +1 -0
  120. package/dist/utils.js +136 -0
  121. package/dist/world.d.ts +236 -0
  122. package/dist/world.d.ts.map +1 -0
  123. package/dist/world.js +275 -0
  124. package/package.json +73 -0
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Structured error classes thrown by CrowdyJS.
3
+ *
4
+ * Every failure the SDK raises is an instance of {@link CrowdyError} (which
5
+ * extends the native `Error`), so you can catch the base class and branch on
6
+ * the concrete subclass with `instanceof`. Transport-level problems
7
+ * (`CrowdyHttpError`, `CrowdyNetworkError`, `CrowdyTimeoutError`) are distinct
8
+ * from API-level problems (`CrowdyGraphQLError`), which lets you retry network
9
+ * blips without retrying a rejected mutation.
10
+ *
11
+ * For API errors prefer branching on the **stable** `extensions.code`
12
+ * (e.g. `UNAUTHENTICATED`, `SCOPE_MISSING`, `FORBIDDEN`, `IDEMPOTENCY_CONFLICT`,
13
+ * `RATE_LIMITED`) rather than the human-readable message — see the
14
+ * [error-code reference](https://docs.crowdedkingdoms.com/overview/error-codes).
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { CrowdyGraphQLError, CrowdyTimeoutError } from '@crowdedkingdoms/crowdyjs';
19
+ * try {
20
+ * await client.actors.delete(uuid, key);
21
+ * } catch (err) {
22
+ * if (err instanceof CrowdyGraphQLError && err.code === 'IDEMPOTENCY_CONFLICT') {
23
+ * // same key was already used with different arguments — don't retry blindly
24
+ * } else if (err instanceof CrowdyTimeoutError) {
25
+ * // safe to retry with the same idempotency key
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ /** A single GraphQL error entry as returned in a response's `errors[]` array. */
31
+ export interface CrowdyGraphQLErrorPayload {
32
+ /** Human-readable message. Do not branch on this — use {@link extensions}.code. */
33
+ message: string;
34
+ /** Source locations in the operation document, when the server reports them. */
35
+ locations?: readonly unknown[];
36
+ /** Response path to the field that errored (e.g. `['createCheckout']`). */
37
+ path?: readonly (string | number)[];
38
+ /**
39
+ * Server-provided metadata. Carries the stable `code` plus, where applicable,
40
+ * `remediation` (a short hint on how to resolve it) and `requiredPermission`
41
+ * (the scope the caller is missing). See the published error-code reference.
42
+ */
43
+ extensions?: Record<string, unknown>;
44
+ }
45
+ /** Options accepted by the {@link CrowdyError} base constructor. */
46
+ export interface CrowdyErrorOptions {
47
+ /** Message passed to the native `Error`. */
48
+ message: string;
49
+ /** Underlying cause (an inner error, rejected promise value, etc.). */
50
+ cause?: unknown;
51
+ }
52
+ /**
53
+ * Base class for every error thrown by the SDK. Catch this to handle any
54
+ * CrowdyJS failure uniformly; `error.name` is set to the concrete subclass
55
+ * name. Prefer `instanceof` checks on the subclasses below for branching.
56
+ */
57
+ export declare class CrowdyError extends Error {
58
+ /** The underlying cause, if this error wraps another. */
59
+ readonly cause?: unknown;
60
+ constructor(options: CrowdyErrorOptions);
61
+ }
62
+ /**
63
+ * A GraphQL endpoint returned a non-2xx HTTP status. This is a transport-level
64
+ * failure (the request never reached resolver execution cleanly) — distinct
65
+ * from {@link CrowdyGraphQLError}, which carries structured `errors[]` from a
66
+ * 200 response. Typical causes: a `401` from an expired token at the gateway,
67
+ * a `413`/`400` malformed request, or a `5xx`.
68
+ */
69
+ export declare class CrowdyHttpError extends CrowdyError {
70
+ /** HTTP status code of the response. */
71
+ readonly status: number;
72
+ /** Raw response body (often JSON text or an error page). */
73
+ readonly body: string;
74
+ constructor(status: number, body: string);
75
+ }
76
+ /**
77
+ * The server returned a 200 response whose `errors[]` array was non-empty.
78
+ * This is the SDK's primary API-error type: authentication, authorization,
79
+ * validation, idempotency conflicts, and business-rule rejections all surface
80
+ * here.
81
+ *
82
+ * Branch on {@link code} (the first error's `extensions.code`) — it is a stable
83
+ * contract; the message text is not. The full array is preserved on
84
+ * {@link graphqlErrors} for multi-error responses.
85
+ */
86
+ export declare class CrowdyGraphQLError extends CrowdyError {
87
+ /** Every GraphQL error entry from the response, in server order. */
88
+ readonly graphqlErrors: CrowdyGraphQLErrorPayload[];
89
+ constructor(errors: CrowdyGraphQLErrorPayload[]);
90
+ /**
91
+ * Stable machine-readable code of the first error (its `extensions.code`),
92
+ * e.g. `'UNAUTHENTICATED'`, `'SCOPE_MISSING'`, `'FORBIDDEN'`,
93
+ * `'IDEMPOTENCY_CONFLICT'`, `'RATE_LIMITED'`, `'BAD_USER_INPUT'`. Returns
94
+ * `undefined` when the server didn't attach a code. Branch on this rather
95
+ * than parsing {@link message}.
96
+ */
97
+ get code(): unknown;
98
+ /**
99
+ * The `extensions` bag of the first error: may include `remediation` (a hint
100
+ * on how to fix it) and `requiredPermission` (the missing scope for
101
+ * `FORBIDDEN`/`SCOPE_MISSING`).
102
+ */
103
+ get extensions(): Record<string, unknown> | undefined;
104
+ }
105
+ /**
106
+ * A network-level failure before any HTTP response was received: DNS failure,
107
+ * TLS error, connection refused, or an aborted `fetch`. Generally retryable
108
+ * with backoff. The original failure is on {@link CrowdyError.cause}.
109
+ */
110
+ export declare class CrowdyNetworkError extends CrowdyError {
111
+ constructor(cause: unknown);
112
+ }
113
+ /**
114
+ * An HTTP request to a GraphQL endpoint exceeded the configured `timeout`.
115
+ *
116
+ * Note: realtime `...AndWait` echo timeouts do **not** throw this — they reject
117
+ * with {@link CrowdyRealtimeError} (`code === 'UDP_SEQUENCE_TIMEOUT'`). For
118
+ * idempotent operations — or any mutation you passed an `idempotencyKey` — a
119
+ * retry is safe; the server replays the first result.
120
+ */
121
+ export declare class CrowdyTimeoutError extends CrowdyError {
122
+ constructor(timeoutMs: number);
123
+ }
124
+ /**
125
+ * A realtime/WebSocket failure: a subscription couldn't be established, was
126
+ * rejected, or dropped — or an `...AndWait` spatial send didn't receive its
127
+ * matching echo in time.
128
+ *
129
+ * Branch on {@link code}:
130
+ * - `'UDP_SEQUENCE_TIMEOUT'` — an `...AndWait` send timed out (retryable).
131
+ * - `'APP_ID_REQUIRED'` — subscribed without an `appId` (not retryable).
132
+ * - `'AUTH_REQUIRED'` / `'AUTH_CLEARED'` — no/!cleared session token.
133
+ * - `'WEBSOCKET_ERROR'` / `'SUBSCRIPTION_FAILED'` — transport-level drops.
134
+ *
135
+ * When an `...AndWait` send is answered by a server `GenericErrorResponse`,
136
+ * {@link code} carries that server error code instead. Use {@link retryable}
137
+ * to decide whether to reconnect/retry.
138
+ */
139
+ export declare class CrowdyRealtimeError extends CrowdyError {
140
+ /** Server- or client-assigned reason code, when available. */
141
+ readonly code?: string;
142
+ /** Whether reconnecting is expected to succeed (transient vs. fatal). */
143
+ readonly retryable?: boolean;
144
+ constructor(message: string, options?: {
145
+ code?: string;
146
+ retryable?: boolean;
147
+ cause?: unknown;
148
+ });
149
+ }
150
+ /**
151
+ * A server response failed the SDK's structural validation — the payload was
152
+ * shaped unexpectedly (e.g. a missing required field on a notification). Almost
153
+ * always indicates an SDK/server version mismatch; check the server
154
+ * compatibility floor in the README.
155
+ */
156
+ export declare class CrowdyProtocolError extends CrowdyError {
157
+ }
158
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,iFAAiF;AACjF,MAAM,WAAW,yBAAyB;IACxC,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,SAAS,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IAC/B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACpC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,oEAAoE;AACpE,MAAM,WAAW,kBAAkB;IACjC,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,yDAAyD;IACzD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEb,OAAO,EAAE,kBAAkB;CAKxC;AAED;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAKzC;AAED;;;;;;;;;GASG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,oEAAoE;IACpE,QAAQ,CAAC,aAAa,EAAE,yBAAyB,EAAE,CAAC;gBAExC,MAAM,EAAE,yBAAyB,EAAE;IAK/C;;;;;;OAMG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IAED;;;;OAIG;IACH,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEpD;CACF;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;gBACrC,KAAK,EAAE,OAAO;CAG3B;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;gBACrC,SAAS,EAAE,MAAM;CAG9B;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAKnG;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;CAAG"}
package/dist/errors.js ADDED
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Structured error classes thrown by CrowdyJS.
3
+ *
4
+ * Every failure the SDK raises is an instance of {@link CrowdyError} (which
5
+ * extends the native `Error`), so you can catch the base class and branch on
6
+ * the concrete subclass with `instanceof`. Transport-level problems
7
+ * (`CrowdyHttpError`, `CrowdyNetworkError`, `CrowdyTimeoutError`) are distinct
8
+ * from API-level problems (`CrowdyGraphQLError`), which lets you retry network
9
+ * blips without retrying a rejected mutation.
10
+ *
11
+ * For API errors prefer branching on the **stable** `extensions.code`
12
+ * (e.g. `UNAUTHENTICATED`, `SCOPE_MISSING`, `FORBIDDEN`, `IDEMPOTENCY_CONFLICT`,
13
+ * `RATE_LIMITED`) rather than the human-readable message — see the
14
+ * [error-code reference](https://docs.crowdedkingdoms.com/overview/error-codes).
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { CrowdyGraphQLError, CrowdyTimeoutError } from '@crowdedkingdoms/crowdyjs';
19
+ * try {
20
+ * await client.actors.delete(uuid, key);
21
+ * } catch (err) {
22
+ * if (err instanceof CrowdyGraphQLError && err.code === 'IDEMPOTENCY_CONFLICT') {
23
+ * // same key was already used with different arguments — don't retry blindly
24
+ * } else if (err instanceof CrowdyTimeoutError) {
25
+ * // safe to retry with the same idempotency key
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ /**
31
+ * Base class for every error thrown by the SDK. Catch this to handle any
32
+ * CrowdyJS failure uniformly; `error.name` is set to the concrete subclass
33
+ * name. Prefer `instanceof` checks on the subclasses below for branching.
34
+ */
35
+ export class CrowdyError extends Error {
36
+ constructor(options) {
37
+ super(options.message);
38
+ this.name = new.target.name;
39
+ this.cause = options.cause;
40
+ }
41
+ }
42
+ /**
43
+ * A GraphQL endpoint returned a non-2xx HTTP status. This is a transport-level
44
+ * failure (the request never reached resolver execution cleanly) — distinct
45
+ * from {@link CrowdyGraphQLError}, which carries structured `errors[]` from a
46
+ * 200 response. Typical causes: a `401` from an expired token at the gateway,
47
+ * a `413`/`400` malformed request, or a `5xx`.
48
+ */
49
+ export class CrowdyHttpError extends CrowdyError {
50
+ constructor(status, body) {
51
+ super({ message: `HTTP ${status}: ${body}` });
52
+ this.status = status;
53
+ this.body = body;
54
+ }
55
+ }
56
+ /**
57
+ * The server returned a 200 response whose `errors[]` array was non-empty.
58
+ * This is the SDK's primary API-error type: authentication, authorization,
59
+ * validation, idempotency conflicts, and business-rule rejections all surface
60
+ * here.
61
+ *
62
+ * Branch on {@link code} (the first error's `extensions.code`) — it is a stable
63
+ * contract; the message text is not. The full array is preserved on
64
+ * {@link graphqlErrors} for multi-error responses.
65
+ */
66
+ export class CrowdyGraphQLError extends CrowdyError {
67
+ constructor(errors) {
68
+ super({ message: errors.map((error) => error.message).join('; ') });
69
+ this.graphqlErrors = errors;
70
+ }
71
+ /**
72
+ * Stable machine-readable code of the first error (its `extensions.code`),
73
+ * e.g. `'UNAUTHENTICATED'`, `'SCOPE_MISSING'`, `'FORBIDDEN'`,
74
+ * `'IDEMPOTENCY_CONFLICT'`, `'RATE_LIMITED'`, `'BAD_USER_INPUT'`. Returns
75
+ * `undefined` when the server didn't attach a code. Branch on this rather
76
+ * than parsing {@link message}.
77
+ */
78
+ get code() {
79
+ return this.graphqlErrors[0]?.extensions?.code;
80
+ }
81
+ /**
82
+ * The `extensions` bag of the first error: may include `remediation` (a hint
83
+ * on how to fix it) and `requiredPermission` (the missing scope for
84
+ * `FORBIDDEN`/`SCOPE_MISSING`).
85
+ */
86
+ get extensions() {
87
+ return this.graphqlErrors[0]?.extensions;
88
+ }
89
+ }
90
+ /**
91
+ * A network-level failure before any HTTP response was received: DNS failure,
92
+ * TLS error, connection refused, or an aborted `fetch`. Generally retryable
93
+ * with backoff. The original failure is on {@link CrowdyError.cause}.
94
+ */
95
+ export class CrowdyNetworkError extends CrowdyError {
96
+ constructor(cause) {
97
+ super({ message: `Network error: ${String(cause)}`, cause });
98
+ }
99
+ }
100
+ /**
101
+ * An HTTP request to a GraphQL endpoint exceeded the configured `timeout`.
102
+ *
103
+ * Note: realtime `...AndWait` echo timeouts do **not** throw this — they reject
104
+ * with {@link CrowdyRealtimeError} (`code === 'UDP_SEQUENCE_TIMEOUT'`). For
105
+ * idempotent operations — or any mutation you passed an `idempotencyKey` — a
106
+ * retry is safe; the server replays the first result.
107
+ */
108
+ export class CrowdyTimeoutError extends CrowdyError {
109
+ constructor(timeoutMs) {
110
+ super({ message: `Request timed out after ${timeoutMs}ms` });
111
+ }
112
+ }
113
+ /**
114
+ * A realtime/WebSocket failure: a subscription couldn't be established, was
115
+ * rejected, or dropped — or an `...AndWait` spatial send didn't receive its
116
+ * matching echo in time.
117
+ *
118
+ * Branch on {@link code}:
119
+ * - `'UDP_SEQUENCE_TIMEOUT'` — an `...AndWait` send timed out (retryable).
120
+ * - `'APP_ID_REQUIRED'` — subscribed without an `appId` (not retryable).
121
+ * - `'AUTH_REQUIRED'` / `'AUTH_CLEARED'` — no/!cleared session token.
122
+ * - `'WEBSOCKET_ERROR'` / `'SUBSCRIPTION_FAILED'` — transport-level drops.
123
+ *
124
+ * When an `...AndWait` send is answered by a server `GenericErrorResponse`,
125
+ * {@link code} carries that server error code instead. Use {@link retryable}
126
+ * to decide whether to reconnect/retry.
127
+ */
128
+ export class CrowdyRealtimeError extends CrowdyError {
129
+ constructor(message, options = {}) {
130
+ super({ message, cause: options.cause });
131
+ this.code = options.code;
132
+ this.retryable = options.retryable;
133
+ }
134
+ }
135
+ /**
136
+ * A server response failed the SDK's structural validation — the payload was
137
+ * shaped unexpectedly (e.g. a missing required field on a notification). Almost
138
+ * always indicates an SDK/server version mismatch; check the server
139
+ * compatibility floor in the README.
140
+ */
141
+ export class CrowdyProtocolError extends CrowdyError {
142
+ }