@rebasepro/client 0.21.1-canary.g8c5a265 → 0.21.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/dist/index.es.js +19 -12
- package/dist/index.es.js.map +1 -1
- package/package.json +4 -4
package/dist/index.es.js
CHANGED
|
@@ -2475,6 +2475,20 @@ function extractMessageError(message) {
|
|
|
2475
2475
|
};
|
|
2476
2476
|
}
|
|
2477
2477
|
/**
|
|
2478
|
+
* The error an `ERROR` frame describes, with the server's `details` when it
|
|
2479
|
+
* sent them — `{ stage, path }` for a collection-callback refusal, the object
|
|
2480
|
+
* the REST envelope carries for the same veto. `status` stays `undefined`:
|
|
2481
|
+
* a frame is not an HTTP response (see `RebaseErrorInit.status`).
|
|
2482
|
+
*/
|
|
2483
|
+
function frameError(message) {
|
|
2484
|
+
const { errorMessage, errorCode } = extractMessageError(message);
|
|
2485
|
+
const errPayload = message.payload?.error;
|
|
2486
|
+
return new RebaseApiError$1(errorMessage, {
|
|
2487
|
+
code: errorCode,
|
|
2488
|
+
details: typeof errPayload === "object" && errPayload !== null ? errPayload.details : void 0
|
|
2489
|
+
});
|
|
2490
|
+
}
|
|
2491
|
+
/**
|
|
2478
2492
|
* Broadcast and presence frames.
|
|
2479
2493
|
*
|
|
2480
2494
|
* Fire-and-forget (the server sends no response envelope), and exempt from the
|
|
@@ -2868,8 +2882,7 @@ var RebaseWebSocketClient = class {
|
|
|
2868
2882
|
else this.sendEntitySubscribe(subscriptionKey);
|
|
2869
2883
|
return;
|
|
2870
2884
|
}
|
|
2871
|
-
const
|
|
2872
|
-
const error = new RebaseApiError$1(errorMessage, { code: errorCode });
|
|
2885
|
+
const error = frameError(message);
|
|
2873
2886
|
if (messageType === "subscribe_collection") this.failCollectionSubscription(subscriptionKey, error);
|
|
2874
2887
|
else this.failEntitySubscription(subscriptionKey, error);
|
|
2875
2888
|
}).catch((err) => {
|
|
@@ -2886,17 +2899,13 @@ var RebaseWebSocketClient = class {
|
|
|
2886
2899
|
this.pendingRequests.delete(requestId);
|
|
2887
2900
|
this.handleAuthFailure().then((refreshed) => {
|
|
2888
2901
|
if (refreshed && pendingReq.message) this.doSendMessage(pendingReq.message, pendingReq.resolve, pendingReq.reject).catch(pendingReq.reject);
|
|
2889
|
-
else
|
|
2890
|
-
const { errorMessage, errorCode } = extractMessageError(message);
|
|
2891
|
-
pendingReq.reject(new RebaseApiError$1(errorMessage, { code: errorCode }));
|
|
2892
|
-
}
|
|
2902
|
+
else pendingReq.reject(frameError(message));
|
|
2893
2903
|
}).catch((err) => {
|
|
2894
2904
|
pendingReq.reject(err);
|
|
2895
2905
|
});
|
|
2896
2906
|
} else {
|
|
2897
2907
|
this.pendingRequests.delete(requestId);
|
|
2898
|
-
|
|
2899
|
-
pendingReq.reject(new RebaseApiError$1(errorMessage, { code: errorCode }));
|
|
2908
|
+
pendingReq.reject(frameError(message));
|
|
2900
2909
|
}
|
|
2901
2910
|
else {
|
|
2902
2911
|
this.pendingRequests.delete(requestId);
|
|
@@ -2980,8 +2989,7 @@ var RebaseWebSocketClient = class {
|
|
|
2980
2989
|
if (collectionSub.subscribeTimeout) clearTimeout(collectionSub.subscribeTimeout);
|
|
2981
2990
|
collectionSub.subscribeTimeout = void 0;
|
|
2982
2991
|
collectionSub.subscribeInFlight = false;
|
|
2983
|
-
const
|
|
2984
|
-
const error = new RebaseApiError$1(errorMessage, { code: errorCode });
|
|
2992
|
+
const error = frameError(message);
|
|
2985
2993
|
collectionSub.callbacks.forEach((callback) => {
|
|
2986
2994
|
if (callback.onError) callback.onError(error);
|
|
2987
2995
|
});
|
|
@@ -2999,8 +3007,7 @@ var RebaseWebSocketClient = class {
|
|
|
2999
3007
|
if (entitySub.subscribeTimeout) clearTimeout(entitySub.subscribeTimeout);
|
|
3000
3008
|
entitySub.subscribeTimeout = void 0;
|
|
3001
3009
|
entitySub.subscribeInFlight = false;
|
|
3002
|
-
const
|
|
3003
|
-
const error = new RebaseApiError$1(errorMessage, { code: errorCode });
|
|
3010
|
+
const error = frameError(message);
|
|
3004
3011
|
entitySub.callbacks.forEach((callback) => {
|
|
3005
3012
|
if (callback.onError) callback.onError(error);
|
|
3006
3013
|
});
|