@crowdedkingdoms/crowdyjs 18.5.0-dev.1 → 18.7.0-dev.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/MIGRATION.md +118 -0
- package/README.md +109 -4
- package/dist/binary-wire.d.ts +30 -2
- package/dist/binary-wire.d.ts.map +1 -1
- package/dist/binary-wire.js +61 -3
- package/dist/crowdy-client.d.ts +3 -0
- package/dist/crowdy-client.d.ts.map +1 -1
- package/dist/crowdy-client.js +2 -0
- package/dist/domains/appAccess.d.ts +32 -1
- package/dist/domains/appAccess.d.ts.map +1 -1
- package/dist/domains/appAccess.js +49 -1
- package/dist/domains/apps.d.ts +7 -1
- package/dist/domains/apps.d.ts.map +1 -1
- package/dist/domains/apps.js +7 -1
- package/dist/domains/channels.d.ts +8 -3
- package/dist/domains/channels.d.ts.map +1 -1
- package/dist/domains/channels.js +8 -3
- package/dist/domains/exec.d.ts +14 -0
- package/dist/domains/exec.d.ts.map +1 -1
- package/dist/domains/exec.js +13 -1
- package/dist/domains/grids.d.ts +1 -0
- package/dist/domains/grids.d.ts.map +1 -1
- package/dist/domains/grids.js +1 -0
- package/dist/domains/inputLog.d.ts +74 -0
- package/dist/domains/inputLog.d.ts.map +1 -0
- package/dist/domains/inputLog.js +74 -0
- package/dist/domains/portal.d.ts +18 -0
- package/dist/domains/portal.d.ts.map +1 -1
- package/dist/domains/portal.js +1 -1
- package/dist/domains/udp.d.ts +27 -8
- package/dist/domains/udp.d.ts.map +1 -1
- package/dist/domains/udp.js +39 -9
- package/dist/domains/users.d.ts +23 -2
- package/dist/domains/users.d.ts.map +1 -1
- package/dist/domains/users.js +34 -2
- package/dist/domains/voxels.d.ts +4 -3
- package/dist/domains/voxels.d.ts.map +1 -1
- package/dist/domains/voxels.js +4 -3
- package/dist/errors.d.ts +52 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +74 -0
- package/dist/generated/graphql-schema.d.ts +576 -49
- package/dist/generated/graphql-schema.d.ts.map +1 -1
- package/dist/generated/graphql-schema.js +30 -1
- package/dist/generated/graphql.d.ts +232 -17
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +30 -21
- package/dist/grid-mods/grid-host-calls.d.ts +34 -0
- package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
- package/dist/grid-mods/grid-host-calls.js +28 -5
- package/dist/grid-mods/index.d.ts +1 -1
- package/dist/grid-mods/index.d.ts.map +1 -1
- package/dist/grid-mods/index.js +1 -1
- package/dist/grid-scope.d.ts +3 -0
- package/dist/grid-scope.d.ts.map +1 -1
- package/dist/grid-scope.js +6 -0
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/media/voice-frames.d.ts +258 -0
- package/dist/media/voice-frames.d.ts.map +1 -0
- package/dist/media/voice-frames.js +424 -0
- package/dist/metrics.d.ts +1 -1
- package/dist/realtime.d.ts +19 -3
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +8 -0
- package/dist/stores/actors.d.ts +3 -1
- package/dist/stores/actors.d.ts.map +1 -1
- package/dist/stores/chunks.d.ts +65 -6
- package/dist/stores/chunks.d.ts.map +1 -1
- package/dist/stores/chunks.js +161 -19
- package/dist/stores/index.d.ts +2 -2
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +1 -1
- package/dist/stores/keys.d.ts +5 -0
- package/dist/stores/keys.d.ts.map +1 -1
- package/dist/stores/keys.js +7 -0
- package/dist/stores/session.d.ts +1 -1
- package/dist/stores/session.d.ts.map +1 -1
- package/dist/stores/session.js +2 -0
- package/dist/types.d.ts +49 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/domains/udp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GraphQLClient } from '../client.js';
|
|
2
2
|
import type { SubscriptionManager, UdpNotificationHandlers } from '../subscriptions.js';
|
|
3
|
-
import { type ConnectUdpProxyMutation, type UdpProxyConnectionStatusQuery, type SendActorUpdateMutationVariables, type SendVoxelUpdateMutationVariables, type SendAudioPacketMutationVariables, type SendVideoPacketMutationVariables, type SendTextPacketMutationVariables, type SendClientEventMutationVariables, type SendSingleActorMessageMutationVariables, type SendChannelMessageMutationVariables, type SendRangedChannelMessageMutationVariables } from '../generated/graphql.js';
|
|
3
|
+
import { type ConnectUdpProxyMutation, type UdpProxyConnectionStatusQuery, type SendActorUpdateMutationVariables, type SendVoxelUpdateMutationVariables, type SendAudioPacketMutationVariables, type SendVideoPacketMutationVariables, type SendTextPacketMutationVariables, type SendClientEventMutationVariables, type SendSingleActorMessageMutationVariables, type SendChannelMessageMutationVariables, type SendChannelAudioMutationVariables, type SendRangedChannelMessageMutationVariables } from '../generated/graphql.js';
|
|
4
4
|
import type { RealtimeMetrics } from '../metrics.js';
|
|
5
5
|
import type { SpatialNotification } from '../realtime.js';
|
|
6
6
|
import { type VideoCodec } from '../media/video-frames.js';
|
|
@@ -200,10 +200,10 @@ export declare class UdpAPI {
|
|
|
200
200
|
* chunk is a 16x16x16 voxel cube.
|
|
201
201
|
* - `uuid` — 32-ASCII-character actor/source id (not RFC-4122).
|
|
202
202
|
* - `voxel` — `{ x, y, z }` voxel coordinates within the chunk; each is an
|
|
203
|
-
* int16 (-32768 to 32767).
|
|
204
|
-
* - `voxelType` — the new voxel type id.
|
|
205
|
-
* - `voxelState` — optional voxel state blob, base64-encoded
|
|
206
|
-
* when the voxel has no state; do not send `''`.
|
|
203
|
+
* app-defined int16 (-32768 to 32767).
|
|
204
|
+
* - `voxelType` — the new voxel type id, an app-defined int16.
|
|
205
|
+
* - `voxelState` — optional voxel state blob, base64-encoded, at most
|
|
206
|
+
* 1,024 bytes decoded. Omit when the voxel has no state; do not send `''`.
|
|
207
207
|
* - `distance` — replication radius in chunk units, 0-8 (clamped); defaults
|
|
208
208
|
* to 8 for voxel updates.
|
|
209
209
|
* - `decayRate` — decay algorithm 0-5 (see {@link sendActorUpdate});
|
|
@@ -211,6 +211,8 @@ export declare class UdpAPI {
|
|
|
211
211
|
* - `sequenceNumber` — optional uint8 (0-255) correlation id.
|
|
212
212
|
* @returns `true` when accepted for sending — **not** confirmation the world
|
|
213
213
|
* applied the change.
|
|
214
|
+
* @throws {RangeError} when a position or the type is not an int16, or the
|
|
215
|
+
* state is over 1,024 bytes; nothing is sent.
|
|
214
216
|
* @throws {CrowdyGraphQLError} on auth/validation failures.
|
|
215
217
|
*/
|
|
216
218
|
sendVoxelUpdate(input: Omit<SendVoxelUpdateMutationVariables['input'], 'voxelState'> & {
|
|
@@ -466,6 +468,23 @@ export declare class UdpAPI {
|
|
|
466
468
|
* @throws {CrowdyGraphQLError} on auth/validation failures.
|
|
467
469
|
*/
|
|
468
470
|
sendChannelMessage(input: SendChannelMessageMutationVariables['input']): Promise<boolean>;
|
|
471
|
+
/**
|
|
472
|
+
* Send audio to a channel (opcode 35, Buddy v0.37.0): delivered to every
|
|
473
|
+
* active member of the channel wherever they are (party or guild voice) as
|
|
474
|
+
* a `channelAudio` notification. The sender receives no echo. Needs the
|
|
475
|
+
* channel's `send_voice` right (`createChannel({ membersCanSpeak: true })`
|
|
476
|
+
* gives the default member role it) and the player's `use_voice_chat`;
|
|
477
|
+
* without either the server answers `UNAUTHORIZED` on `genericError`.
|
|
478
|
+
* Every member's downlink is billed as egress, so keep voice channels small.
|
|
479
|
+
*
|
|
480
|
+
* @param input - {@link ChannelMessageInput}: `channelId`, the sender's own
|
|
481
|
+
* 32-character actor `uuid`, `payload` (base64, at most 1,024 bytes; one
|
|
482
|
+
* `VoicePacketizer` packet with the SDK voice helpers)
|
|
483
|
+
* and an optional uint8 `sequenceNumber` for correlating a refusal.
|
|
484
|
+
* @returns `true` when accepted for sending, not confirmation of delivery.
|
|
485
|
+
* @throws {CrowdyGraphQLError} on auth/validation failures.
|
|
486
|
+
*/
|
|
487
|
+
sendChannelAudio(input: SendChannelAudioMutationVariables['input']): Promise<boolean>;
|
|
469
488
|
/**
|
|
470
489
|
* Publish a message to a channel that only members near an origin chunk
|
|
471
490
|
* receive (needs ck-api with `sendRangedChannelMessage` and Buddy v0.35.0).
|
|
@@ -511,9 +530,9 @@ export declare class UdpAPI {
|
|
|
511
530
|
*
|
|
512
531
|
* @param handlers - {@link UdpNotificationHandlers}: optional per-typename
|
|
513
532
|
* callbacks (`actorUpdate`, `voxelUpdate`, `audio`, `text`, `clientEvent`,
|
|
514
|
-
* `singleActorMessage`, `channelMessage`, `genericError`, `connectionEvent`,
|
|
515
|
-
* etc
|
|
516
|
-
* {@link CrowdyRealtimeError}).
|
|
533
|
+
* `singleActorMessage`, `channelMessage`, `channelAudio`, `genericError`, `connectionEvent`,
|
|
534
|
+
* etc.; `genericSpatial` fires on the binary relay only) plus `any` (every
|
|
535
|
+
* notification) and `error` (a {@link CrowdyRealtimeError}).
|
|
517
536
|
* @param appId - The app to scope delivery to (`BigInt` as a decimal string).
|
|
518
537
|
* Required.
|
|
519
538
|
* @returns An unsubscribe function that detaches these handlers (and closes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"udp.d.ts","sourceRoot":"","sources":["../../src/domains/udp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEL,KAAK,uBAAuB,EAG5B,KAAK,6BAA6B,EAElC,KAAK,gCAAgC,EAErC,KAAK,gCAAgC,EAErC,KAAK,gCAAgC,EAErC,KAAK,gCAAgC,EAErC,KAAK,+BAA+B,EAEpC,KAAK,gCAAgC,EAErC,KAAK,uCAAuC,EAE5C,KAAK,mCAAmC,EAExC,KAAK,yCAAyC,EAC/C,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MA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KAAK,EAAE,gCAAgC,CAAC,OAAO,CAAC,GAC/C,OAAO,CAAC,OAAO,CAAC;IAcnB;;;;;;;;;;;;;;;;;;OAkBG;IACG,sBAAsB,CAC1B,KAAK,EAAE,gCAAgC,CAAC,OAAO,CAAC,EAChD,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnC,OAAO,CAAC,mBAAmB,CAAC;IAU/B;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,sBAAsB,CAC1B,KAAK,EAAE,uCAAuC,CAAC,OAAO,CAAC,GACtD,OAAO,CAAC,OAAO,CAAC;IAgBnB;;;;;;;;;;;;;;;;;;;OAmBG;IACG,kBAAkB,CACtB,KAAK,EAAE,mCAAmC,CAAC,OAAO,CAAC,GAClD,OAAO,CAAC,OAAO,CAAC;IAcnB;;;;;;;;;;;;;;;OAeG;IACG,gBAAgB,CACpB,KAAK,EAAE,iCAAiC,CAAC,OAAO,CAAC,GAChD,OAAO,CAAC,OAAO,CAAC;IAcnB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,wBAAwB,CAC5B,KAAK,EAAE,yCAAyC,CAAC,OAAO,CAAC,GACxD,OAAO,CAAC,OAAO,CAAC;IAcnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,SAAS,CAAC,QAAQ,EAAE,uBAAuB,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,IAAI;IAIvE,OAAO,CAAC,YAAY;CAQrB"}
|
package/dist/domains/udp.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ConnectUdpProxyDocument, DisconnectUdpProxyDocument, UdpProxyConnectionStatusDocument, SendActorUpdateDocument, SendVoxelUpdateDocument, SendAudioPacketDocument, SendVideoPacketDocument, SendTextPacketDocument, SendClientEventDocument, SendSingleActorMessageDocument, SendChannelMessageDocument, SendRangedChannelMessageDocument, } from '../generated/graphql.js';
|
|
1
|
+
import { ConnectUdpProxyDocument, DisconnectUdpProxyDocument, UdpProxyConnectionStatusDocument, SendActorUpdateDocument, SendVoxelUpdateDocument, SendAudioPacketDocument, SendVideoPacketDocument, SendTextPacketDocument, SendClientEventDocument, SendSingleActorMessageDocument, SendChannelMessageDocument, SendChannelAudioDocument, SendRangedChannelMessageDocument, } from '../generated/graphql.js';
|
|
2
2
|
import { payloadBytesOf } from '../metrics.js';
|
|
3
3
|
import { SequenceAllocator } from '../utils.js';
|
|
4
|
-
import { serializeActorUpdate, serializeAudioPacket, serializeChannelMessage, serializeClientEvent, serializeRangedChannelMessage, serializeSingleActorMessage, serializeTextPacket, serializeVideoPacket, serializeVoxelUpdate, } from '../binary-wire.js';
|
|
4
|
+
import { serializeActorUpdate, serializeAudioPacket, serializeChannelAudio, serializeChannelMessage, serializeClientEvent, serializeRangedChannelMessage, serializeSingleActorMessage, serializeTextPacket, serializeVideoPacket, serializeVoxelUpdate, assertVoxelEdit, } from '../binary-wire.js';
|
|
5
5
|
import { fragmentFrame } from '../media/video-frames.js';
|
|
6
6
|
import { encodeBase64 } from '../utils.js';
|
|
7
7
|
/**
|
|
@@ -308,10 +308,10 @@ export class UdpAPI {
|
|
|
308
308
|
* chunk is a 16x16x16 voxel cube.
|
|
309
309
|
* - `uuid` — 32-ASCII-character actor/source id (not RFC-4122).
|
|
310
310
|
* - `voxel` — `{ x, y, z }` voxel coordinates within the chunk; each is an
|
|
311
|
-
* int16 (-32768 to 32767).
|
|
312
|
-
* - `voxelType` — the new voxel type id.
|
|
313
|
-
* - `voxelState` — optional voxel state blob, base64-encoded
|
|
314
|
-
* when the voxel has no state; do not send `''`.
|
|
311
|
+
* app-defined int16 (-32768 to 32767).
|
|
312
|
+
* - `voxelType` — the new voxel type id, an app-defined int16.
|
|
313
|
+
* - `voxelState` — optional voxel state blob, base64-encoded, at most
|
|
314
|
+
* 1,024 bytes decoded. Omit when the voxel has no state; do not send `''`.
|
|
315
315
|
* - `distance` — replication radius in chunk units, 0-8 (clamped); defaults
|
|
316
316
|
* to 8 for voxel updates.
|
|
317
317
|
* - `decayRate` — decay algorithm 0-5 (see {@link sendActorUpdate});
|
|
@@ -319,9 +319,12 @@ export class UdpAPI {
|
|
|
319
319
|
* - `sequenceNumber` — optional uint8 (0-255) correlation id.
|
|
320
320
|
* @returns `true` when accepted for sending — **not** confirmation the world
|
|
321
321
|
* applied the change.
|
|
322
|
+
* @throws {RangeError} when a position or the type is not an int16, or the
|
|
323
|
+
* state is over 1,024 bytes; nothing is sent.
|
|
322
324
|
* @throws {CrowdyGraphQLError} on auth/validation failures.
|
|
323
325
|
*/
|
|
324
326
|
async sendVoxelUpdate(input) {
|
|
327
|
+
assertVoxelEdit(input);
|
|
325
328
|
await this.awaitGameplayTokenReady();
|
|
326
329
|
const viaRelay = await this.sendViaRelay((ctx) => serializeVoxelUpdate(ctx, input));
|
|
327
330
|
if (viaRelay !== null) {
|
|
@@ -669,6 +672,33 @@ export class UdpAPI {
|
|
|
669
672
|
this.record('channelMessage', input);
|
|
670
673
|
return data.sendChannelMessage;
|
|
671
674
|
}
|
|
675
|
+
/**
|
|
676
|
+
* Send audio to a channel (opcode 35, Buddy v0.37.0): delivered to every
|
|
677
|
+
* active member of the channel wherever they are (party or guild voice) as
|
|
678
|
+
* a `channelAudio` notification. The sender receives no echo. Needs the
|
|
679
|
+
* channel's `send_voice` right (`createChannel({ membersCanSpeak: true })`
|
|
680
|
+
* gives the default member role it) and the player's `use_voice_chat`;
|
|
681
|
+
* without either the server answers `UNAUTHORIZED` on `genericError`.
|
|
682
|
+
* Every member's downlink is billed as egress, so keep voice channels small.
|
|
683
|
+
*
|
|
684
|
+
* @param input - {@link ChannelMessageInput}: `channelId`, the sender's own
|
|
685
|
+
* 32-character actor `uuid`, `payload` (base64, at most 1,024 bytes; one
|
|
686
|
+
* `VoicePacketizer` packet with the SDK voice helpers)
|
|
687
|
+
* and an optional uint8 `sequenceNumber` for correlating a refusal.
|
|
688
|
+
* @returns `true` when accepted for sending, not confirmation of delivery.
|
|
689
|
+
* @throws {CrowdyGraphQLError} on auth/validation failures.
|
|
690
|
+
*/
|
|
691
|
+
async sendChannelAudio(input) {
|
|
692
|
+
await this.awaitGameplayTokenReady();
|
|
693
|
+
const viaRelay = await this.sendViaRelay((ctx) => serializeChannelAudio(ctx, input));
|
|
694
|
+
if (viaRelay !== null) {
|
|
695
|
+
this.record('channelAudio', input);
|
|
696
|
+
return viaRelay;
|
|
697
|
+
}
|
|
698
|
+
const data = await this.gql.request(SendChannelAudioDocument, { input });
|
|
699
|
+
this.record('channelAudio', input);
|
|
700
|
+
return data.sendChannelAudio;
|
|
701
|
+
}
|
|
672
702
|
/**
|
|
673
703
|
* Publish a message to a channel that only members near an origin chunk
|
|
674
704
|
* receive (needs ck-api with `sendRangedChannelMessage` and Buddy v0.35.0).
|
|
@@ -724,9 +754,9 @@ export class UdpAPI {
|
|
|
724
754
|
*
|
|
725
755
|
* @param handlers - {@link UdpNotificationHandlers}: optional per-typename
|
|
726
756
|
* callbacks (`actorUpdate`, `voxelUpdate`, `audio`, `text`, `clientEvent`,
|
|
727
|
-
* `singleActorMessage`, `channelMessage`, `genericError`, `connectionEvent`,
|
|
728
|
-
* etc
|
|
729
|
-
* {@link CrowdyRealtimeError}).
|
|
757
|
+
* `singleActorMessage`, `channelMessage`, `channelAudio`, `genericError`, `connectionEvent`,
|
|
758
|
+
* etc.; `genericSpatial` fires on the binary relay only) plus `any` (every
|
|
759
|
+
* notification) and `error` (a {@link CrowdyRealtimeError}).
|
|
730
760
|
* @param appId - The app to scope delivery to (`BigInt` as a decimal string).
|
|
731
761
|
* Required.
|
|
732
762
|
* @returns An unsubscribe function that detaches these handlers (and closes
|
package/dist/domains/users.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { GraphQLClient } from '../client.js';
|
|
2
|
-
import { type MeQuery, type UpdateGamertagInput, type UpdateGamertagMutation, type UserQuery, type UpdateUserStateMutation, type UpdateUserStateInput, type FreePlayWindowQuery } from '../generated/graphql.js';
|
|
2
|
+
import { type PlayerProfileQuery, type PlayerProfilesQuery, type MeQuery, type UpdateGamertagInput, type UpdateGamertagMutation, type UserQuery, type UpdateUserStateMutation, type UpdateUserStateInput, type FreePlayWindowQuery } from '../generated/graphql.js';
|
|
3
|
+
/** Most ids {@link UsersAPI.playerProfiles} takes in one call. */
|
|
4
|
+
export declare const PLAYER_PROFILES_MAX = 100;
|
|
3
5
|
/**
|
|
4
6
|
* User identity & account management — exposed as `client.users`.
|
|
5
7
|
*
|
|
@@ -62,12 +64,31 @@ export declare class UsersAPI {
|
|
|
62
64
|
*/
|
|
63
65
|
freePlayWindow(): Promise<FreePlayWindowQuery['freePlayWindowInfo']>;
|
|
64
66
|
/**
|
|
65
|
-
* Look up a user by id. Requires a valid session.
|
|
67
|
+
* Look up a user by id. Requires a valid session. The private fields
|
|
68
|
+
* (`email`, `state`, `isConfirmed`, the early-access grants, `orgId`,
|
|
69
|
+
* `externalId`, `userType`, `isSuperAdmin`) come back `null` for anyone but
|
|
70
|
+
* yourself; for another player's nametag use {@link playerProfile}.
|
|
66
71
|
*
|
|
67
72
|
* @param id - Numeric user id (`BigInt` as a decimal string).
|
|
68
73
|
* @returns The {@link User}, or `null` if no such user.
|
|
69
74
|
*/
|
|
70
75
|
get(id: string): Promise<UserQuery['user']>;
|
|
76
|
+
/**
|
|
77
|
+
* A player's public profile (`userId`, `gamertag`, `disambiguation`), for
|
|
78
|
+
* nametags and friends lists. Needs a game token; carries nothing private.
|
|
79
|
+
*
|
|
80
|
+
* @param userId - Numeric user id (`BigInt` as a decimal string).
|
|
81
|
+
* @returns The profile, or `null` when there is no such user.
|
|
82
|
+
*/
|
|
83
|
+
playerProfile(userId: string): Promise<PlayerProfileQuery['playerProfile']>;
|
|
84
|
+
/**
|
|
85
|
+
* Public profiles for up to 100 players in one call (duplicates are read
|
|
86
|
+
* once; unknown ids are left out).
|
|
87
|
+
*
|
|
88
|
+
* @param userIds - Numeric user ids (`BigInt` decimal strings), at most 100.
|
|
89
|
+
* @throws {RangeError} for more than 100 ids; nothing is sent.
|
|
90
|
+
*/
|
|
91
|
+
playerProfiles(userIds: string[]): Promise<PlayerProfilesQuery['playerProfiles']>;
|
|
71
92
|
/**
|
|
72
93
|
* Replace the caller's own top-level state blob (base64; `null` clears it).
|
|
73
94
|
* Only ever writes the caller. Requires a valid session.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/domains/users.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/domains/users.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,OAAO,EACZ,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AAEjC,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,aAAa;IAEnD;;;;;;;OAOG;IACG,EAAE,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAKlC;;;;;;;;;;;;;OAaG;IACG,cAAc,CAClB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IAKpD;;;;;;;;;OASG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAKzC;;;;;OAKG;IACG,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;IAK1E;;;;;;;;OAQG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAKjD;;;;;;OAMG;IACG,aAAa,CACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IAK/C;;;;;;OAMG;IACG,cAAc,CAClB,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAWjD;;;;;;OAMG;IACG,WAAW,CACf,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CAIvD"}
|
package/dist/domains/users.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { MeDocument, UpdateGamertagDocument, DeleteMyAccountDocument, UserDocument, UpdateUserStateDocument, FreePlayWindowDocument, } from '../generated/graphql.js';
|
|
1
|
+
import { MeDocument, UpdateGamertagDocument, DeleteMyAccountDocument, UserDocument, UpdateUserStateDocument, FreePlayWindowDocument, PlayerProfileDocument, PlayerProfilesDocument, } from '../generated/graphql.js';
|
|
2
|
+
/** Most ids {@link UsersAPI.playerProfiles} takes in one call. */
|
|
3
|
+
export const PLAYER_PROFILES_MAX = 100;
|
|
2
4
|
/**
|
|
3
5
|
* User identity & account management — exposed as `client.users`.
|
|
4
6
|
*
|
|
@@ -74,7 +76,10 @@ export class UsersAPI {
|
|
|
74
76
|
return data.freePlayWindowInfo;
|
|
75
77
|
}
|
|
76
78
|
/**
|
|
77
|
-
* Look up a user by id. Requires a valid session.
|
|
79
|
+
* Look up a user by id. Requires a valid session. The private fields
|
|
80
|
+
* (`email`, `state`, `isConfirmed`, the early-access grants, `orgId`,
|
|
81
|
+
* `externalId`, `userType`, `isSuperAdmin`) come back `null` for anyone but
|
|
82
|
+
* yourself; for another player's nametag use {@link playerProfile}.
|
|
78
83
|
*
|
|
79
84
|
* @param id - Numeric user id (`BigInt` as a decimal string).
|
|
80
85
|
* @returns The {@link User}, or `null` if no such user.
|
|
@@ -83,6 +88,33 @@ export class UsersAPI {
|
|
|
83
88
|
const data = await this.graphql.request(UserDocument, { id });
|
|
84
89
|
return data.user;
|
|
85
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* A player's public profile (`userId`, `gamertag`, `disambiguation`), for
|
|
93
|
+
* nametags and friends lists. Needs a game token; carries nothing private.
|
|
94
|
+
*
|
|
95
|
+
* @param userId - Numeric user id (`BigInt` as a decimal string).
|
|
96
|
+
* @returns The profile, or `null` when there is no such user.
|
|
97
|
+
*/
|
|
98
|
+
async playerProfile(userId) {
|
|
99
|
+
const data = await this.graphql.request(PlayerProfileDocument, { userId });
|
|
100
|
+
return data.playerProfile;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Public profiles for up to 100 players in one call (duplicates are read
|
|
104
|
+
* once; unknown ids are left out).
|
|
105
|
+
*
|
|
106
|
+
* @param userIds - Numeric user ids (`BigInt` decimal strings), at most 100.
|
|
107
|
+
* @throws {RangeError} for more than 100 ids; nothing is sent.
|
|
108
|
+
*/
|
|
109
|
+
async playerProfiles(userIds) {
|
|
110
|
+
if (userIds.length > PLAYER_PROFILES_MAX) {
|
|
111
|
+
throw new RangeError(`playerProfiles takes at most ${PLAYER_PROFILES_MAX} ids: ${userIds.length}`);
|
|
112
|
+
}
|
|
113
|
+
if (userIds.length === 0)
|
|
114
|
+
return [];
|
|
115
|
+
const data = await this.graphql.request(PlayerProfilesDocument, { userIds });
|
|
116
|
+
return data.playerProfiles;
|
|
117
|
+
}
|
|
86
118
|
/**
|
|
87
119
|
* Replace the caller's own top-level state blob (base64; `null` clears it).
|
|
88
120
|
* Only ever writes the caller. Requires a valid session.
|
package/dist/domains/voxels.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ import { type ListVoxelsQuery, type ListVoxelsQueryVariables, type ListVoxelUpda
|
|
|
14
14
|
*
|
|
15
15
|
* Coordinate & encoding conventions:
|
|
16
16
|
* - **Chunk coordinates** are int64 **decimal strings**; **voxel positions**
|
|
17
|
-
* (`location`) are signed 16-bit ints
|
|
17
|
+
* (`location`) and voxel types are app-defined signed 16-bit ints; an app on
|
|
18
|
+
* the 16x16x16 dense grid uses `0-15` per axis and types `0-255`.
|
|
18
19
|
* - `appId` / `userId` are `BigInt` sent and received as decimal strings.
|
|
19
20
|
* - Voxel `state` blobs are **base64-encoded** binary.
|
|
20
21
|
*
|
|
@@ -65,8 +66,8 @@ export declare class VoxelsAPI {
|
|
|
65
66
|
* grids cover the chunk, `update_voxel_data` on a covering grid).
|
|
66
67
|
*
|
|
67
68
|
* @param input - {@link UpdateVoxelInput}: `appId`, chunk `coordinates`, the
|
|
68
|
-
* local voxel `location`
|
|
69
|
-
*
|
|
69
|
+
* local voxel `location` and the `voxelType` to write (app-defined
|
|
70
|
+
* int16s), and an optional base64 `state` blob (at most 1,024 bytes).
|
|
70
71
|
* @returns The resulting {@link Voxel}.
|
|
71
72
|
* @throws {CrowdyGraphQLError} `SCOPE_MISSING` / `FORBIDDEN` (missing
|
|
72
73
|
* `update_voxel_data`), `BAD_USER_INPUT`, or `UNAUTHENTICATED`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voxels.d.ts","sourceRoot":"","sources":["../../src/domains/voxels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAE7B,KAAK,+BAA+B,EACpC,KAAK,wCAAwC,EAE7C,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EAEjC,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EAErC,KAAK,iCAAiC,EACtC,KAAK,0CAA0C,EAE/C,KAAK,4BAA4B,EACjC,KAAK,qCAAqC,EAC3C,MAAM,yBAAyB,CAAC;AAEjC
|
|
1
|
+
{"version":3,"file":"voxels.d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C,OAAO,CAAC,GACpD,OAAO,CAAC,4BAA4B,CAAC,sBAAsB,CAAC,CAAC;CAIjE"}
|
package/dist/domains/voxels.js
CHANGED
|
@@ -13,7 +13,8 @@ import { ListVoxelsDocument, ListVoxelUpdatesByDistanceDocument, UpdateVoxelDocu
|
|
|
13
13
|
*
|
|
14
14
|
* Coordinate & encoding conventions:
|
|
15
15
|
* - **Chunk coordinates** are int64 **decimal strings**; **voxel positions**
|
|
16
|
-
* (`location`) are signed 16-bit ints
|
|
16
|
+
* (`location`) and voxel types are app-defined signed 16-bit ints; an app on
|
|
17
|
+
* the 16x16x16 dense grid uses `0-15` per axis and types `0-255`.
|
|
17
18
|
* - `appId` / `userId` are `BigInt` sent and received as decimal strings.
|
|
18
19
|
* - Voxel `state` blobs are **base64-encoded** binary.
|
|
19
20
|
*
|
|
@@ -71,8 +72,8 @@ export class VoxelsAPI {
|
|
|
71
72
|
* grids cover the chunk, `update_voxel_data` on a covering grid).
|
|
72
73
|
*
|
|
73
74
|
* @param input - {@link UpdateVoxelInput}: `appId`, chunk `coordinates`, the
|
|
74
|
-
* local voxel `location`
|
|
75
|
-
*
|
|
75
|
+
* local voxel `location` and the `voxelType` to write (app-defined
|
|
76
|
+
* int16s), and an optional base64 `state` blob (at most 1,024 bytes).
|
|
76
77
|
* @returns The resulting {@link Voxel}.
|
|
77
78
|
* @throws {CrowdyGraphQLError} `SCOPE_MISSING` / `FORBIDDEN` (missing
|
|
78
79
|
* `update_voxel_data`), `BAD_USER_INPUT`, or `UNAUTHENTICATED`.
|
package/dist/errors.d.ts
CHANGED
|
@@ -247,6 +247,58 @@ export declare class CrowdyUserCodeFaultError extends CrowdyGraphQLError {
|
|
|
247
247
|
* ```
|
|
248
248
|
*/
|
|
249
249
|
export declare function playerFaultOf(value: unknown): CrowdyPlayerFault | null;
|
|
250
|
+
/** `extensions.code` for "an actor with this uuid already exists" (HTTP 409). */
|
|
251
|
+
export declare const ACTOR_EXISTS_CODE = "ACTOR_EXISTS";
|
|
252
|
+
/** `extensions.code` for "this player's access to the app was revoked" (HTTP 403). */
|
|
253
|
+
export declare const ACCESS_REVOKED_CODE = "ACCESS_REVOKED";
|
|
254
|
+
/** `extensions.code` for "this player is suspended from the app until a time" (HTTP 403). */
|
|
255
|
+
export declare const ACCESS_SUSPENDED_CODE = "ACCESS_SUSPENDED";
|
|
256
|
+
/** `extensions.code` for "this player holds no access to the app" (HTTP 403). */
|
|
257
|
+
export declare const ACCESS_NOT_GRANTED_CODE = "ACCESS_NOT_GRANTED";
|
|
258
|
+
/** `extensions.code` for "the app is paused" (HTTP 403); see {@link appPausedOf}. */
|
|
259
|
+
export declare const APP_PAUSED_CODE = "APP_PAUSED";
|
|
260
|
+
/**
|
|
261
|
+
* Why an app is paused, as `extensions.reason` on `APP_PAUSED` and
|
|
262
|
+
* `AppRuntimeGate.reason` carry it. Open union: the server may add one.
|
|
263
|
+
*/
|
|
264
|
+
export type AppPauseReason = 'insufficient_funds' | 'spend_cap' | 'subscription_lapsed' | (string & {});
|
|
265
|
+
/**
|
|
266
|
+
* An `ACTOR_EXISTS` refusal (creating an actor whose uuid is taken), or `null`.
|
|
267
|
+
* `ownedByCaller` is `extensions.ownedByCaller`: `true` means the actor is
|
|
268
|
+
* already yours (a retried create; read it rather than failing), `false` that
|
|
269
|
+
* another player holds the uuid, `null` when the server did not say.
|
|
270
|
+
*/
|
|
271
|
+
export declare function actorExistsOf(value: unknown): {
|
|
272
|
+
ownedByCaller: boolean | null;
|
|
273
|
+
} | null;
|
|
274
|
+
/** A refusal of the player's own access to an app; see {@link accessRefusalOf}. */
|
|
275
|
+
export interface CrowdyAccessRefusal {
|
|
276
|
+
code: 'ACCESS_REVOKED' | 'ACCESS_SUSPENDED' | 'ACCESS_NOT_GRANTED';
|
|
277
|
+
/** `extensions.suspendedUntil` (ISO-8601) on `ACCESS_SUSPENDED`; access returns by itself then. */
|
|
278
|
+
suspendedUntil?: string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* An access refusal (`ACCESS_REVOKED`, `ACCESS_SUSPENDED` or `ACCESS_NOT_GRANTED`,
|
|
282
|
+
* all HTTP 403) from a thrown error or a raw error payload, or `null`. None of
|
|
283
|
+
* them is fixed by retrying; tell the player.
|
|
284
|
+
*/
|
|
285
|
+
export declare function accessRefusalOf(value: unknown): CrowdyAccessRefusal | null;
|
|
286
|
+
/**
|
|
287
|
+
* An `APP_PAUSED` refusal (HTTP 403: the app's runtime gate is not ACTIVE), or
|
|
288
|
+
* `null`. `reason` is `extensions.reason`. Show the player that the world is
|
|
289
|
+
* paused instead of retrying in a loop.
|
|
290
|
+
*/
|
|
291
|
+
export declare function appPausedOf(value: unknown): {
|
|
292
|
+
reason: AppPauseReason | null;
|
|
293
|
+
} | null;
|
|
294
|
+
/**
|
|
295
|
+
* Whether an app's runtime gate (`AppTokenResponse.runtimeGate`,
|
|
296
|
+
* `GameClientBootstrap.runtimeGate`) says the app is paused: any status but
|
|
297
|
+
* `ACTIVE`. A missing gate (an older server) reads as not paused.
|
|
298
|
+
*/
|
|
299
|
+
export declare function isAppPaused(gate: {
|
|
300
|
+
status: string;
|
|
301
|
+
} | null | undefined): boolean;
|
|
250
302
|
/**
|
|
251
303
|
* A network-level failure before any HTTP response was received: DNS failure,
|
|
252
304
|
* TLS error, connection refused, or an aborted `fetch`. Generally retryable
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +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,CA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GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,GAAG,IAAI,CAc1E;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAKpF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAC1C,OAAO,CAET;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
CHANGED
|
@@ -243,6 +243,80 @@ export function playerFaultOf(value) {
|
|
|
243
243
|
return faultFromExtensions(payload.extensions);
|
|
244
244
|
return null;
|
|
245
245
|
}
|
|
246
|
+
/** `extensions.code` for "an actor with this uuid already exists" (HTTP 409). */
|
|
247
|
+
export const ACTOR_EXISTS_CODE = 'ACTOR_EXISTS';
|
|
248
|
+
/** `extensions.code` for "this player's access to the app was revoked" (HTTP 403). */
|
|
249
|
+
export const ACCESS_REVOKED_CODE = 'ACCESS_REVOKED';
|
|
250
|
+
/** `extensions.code` for "this player is suspended from the app until a time" (HTTP 403). */
|
|
251
|
+
export const ACCESS_SUSPENDED_CODE = 'ACCESS_SUSPENDED';
|
|
252
|
+
/** `extensions.code` for "this player holds no access to the app" (HTTP 403). */
|
|
253
|
+
export const ACCESS_NOT_GRANTED_CODE = 'ACCESS_NOT_GRANTED';
|
|
254
|
+
/** `extensions.code` for "the app is paused" (HTTP 403); see {@link appPausedOf}. */
|
|
255
|
+
export const APP_PAUSED_CODE = 'APP_PAUSED';
|
|
256
|
+
/** The first error entry carrying `code`, from an error or a raw payload. */
|
|
257
|
+
function errorWithCode(value, code) {
|
|
258
|
+
if (!value || typeof value !== 'object')
|
|
259
|
+
return null;
|
|
260
|
+
const entries = value instanceof CrowdyGraphQLError
|
|
261
|
+
? value.graphqlErrors
|
|
262
|
+
: [value];
|
|
263
|
+
return entries.find((entry) => entry?.extensions?.code === code) ?? null;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* An `ACTOR_EXISTS` refusal (creating an actor whose uuid is taken), or `null`.
|
|
267
|
+
* `ownedByCaller` is `extensions.ownedByCaller`: `true` means the actor is
|
|
268
|
+
* already yours (a retried create; read it rather than failing), `false` that
|
|
269
|
+
* another player holds the uuid, `null` when the server did not say.
|
|
270
|
+
*/
|
|
271
|
+
export function actorExistsOf(value) {
|
|
272
|
+
const entry = errorWithCode(value, ACTOR_EXISTS_CODE);
|
|
273
|
+
if (!entry)
|
|
274
|
+
return null;
|
|
275
|
+
const owned = entry.extensions?.ownedByCaller;
|
|
276
|
+
return { ownedByCaller: typeof owned === 'boolean' ? owned : null };
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* An access refusal (`ACCESS_REVOKED`, `ACCESS_SUSPENDED` or `ACCESS_NOT_GRANTED`,
|
|
280
|
+
* all HTTP 403) from a thrown error or a raw error payload, or `null`. None of
|
|
281
|
+
* them is fixed by retrying; tell the player.
|
|
282
|
+
*/
|
|
283
|
+
export function accessRefusalOf(value) {
|
|
284
|
+
for (const code of [
|
|
285
|
+
ACCESS_SUSPENDED_CODE,
|
|
286
|
+
ACCESS_REVOKED_CODE,
|
|
287
|
+
ACCESS_NOT_GRANTED_CODE,
|
|
288
|
+
]) {
|
|
289
|
+
const entry = errorWithCode(value, code);
|
|
290
|
+
if (!entry)
|
|
291
|
+
continue;
|
|
292
|
+
const refusal = { code };
|
|
293
|
+
const until = entry.extensions?.suspendedUntil;
|
|
294
|
+
if (typeof until === 'string' && until.length > 0)
|
|
295
|
+
refusal.suspendedUntil = until;
|
|
296
|
+
return refusal;
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* An `APP_PAUSED` refusal (HTTP 403: the app's runtime gate is not ACTIVE), or
|
|
302
|
+
* `null`. `reason` is `extensions.reason`. Show the player that the world is
|
|
303
|
+
* paused instead of retrying in a loop.
|
|
304
|
+
*/
|
|
305
|
+
export function appPausedOf(value) {
|
|
306
|
+
const entry = errorWithCode(value, APP_PAUSED_CODE);
|
|
307
|
+
if (!entry)
|
|
308
|
+
return null;
|
|
309
|
+
const reason = entry.extensions?.reason;
|
|
310
|
+
return { reason: typeof reason === 'string' && reason.length > 0 ? reason : null };
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Whether an app's runtime gate (`AppTokenResponse.runtimeGate`,
|
|
314
|
+
* `GameClientBootstrap.runtimeGate`) says the app is paused: any status but
|
|
315
|
+
* `ACTIVE`. A missing gate (an older server) reads as not paused.
|
|
316
|
+
*/
|
|
317
|
+
export function isAppPaused(gate) {
|
|
318
|
+
return gate != null && gate.status !== 'ACTIVE';
|
|
319
|
+
}
|
|
246
320
|
/**
|
|
247
321
|
* A network-level failure before any HTTP response was received: DNS failure,
|
|
248
322
|
* TLS error, connection refused, or an aborted `fetch`. Generally retryable
|