@squidcloud/client 1.0.183 → 1.0.185

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/cjs/index.js CHANGED
@@ -30949,6 +30949,9 @@ class DocumentReference {
30949
30949
  * the server.
30950
30950
  */
30951
30951
  async snapshot() {
30952
+ if (this.hasSquidPlaceholderId()) {
30953
+ throw new Error('Cannot invoke snapshot of a document that was created locally without storing it on the server.');
30954
+ }
30952
30955
  if (this.isTracked() && this.hasData)
30953
30956
  return this.data;
30954
30957
  const results = await this.queryBuilderFactory.getForDocument(this.squidDocId).dereference().snapshot();
@@ -31144,6 +31147,16 @@ class DocumentReference {
31144
31147
  this._squidDocId = newSquidDocId;
31145
31148
  }
31146
31149
  }
31150
+ hasSquidPlaceholderId() {
31151
+ const obj = deserializeObj(this._squidDocId);
31152
+ if (typeof obj === 'object' && !!obj.docId) {
31153
+ const docIdObj = deserializeObj(obj.docId);
31154
+ if (typeof docIdObj === 'object' && Object.keys(docIdObj).includes(SquidPlaceholderId)) {
31155
+ return true;
31156
+ }
31157
+ }
31158
+ return false;
31159
+ }
31147
31160
  }
31148
31161
 
31149
31162
  ;// CONCATENATED MODULE: ../node_modules/ts-invariant/lib/invariant.js
@@ -49532,7 +49545,9 @@ class QuerySubscriptionManager {
49532
49545
  * updates. In this case we should clear the mapping we have for this clientRequestId since a new updated mapping
49533
49546
  * will be created when applying the update.
49534
49547
  */
49535
- this.removeClientRequestIdMapping(clientRequestId);
49548
+ if (ongoingQuery === null || ongoingQuery === void 0 ? void 0 : ongoingQuery.gotInitialResponse) {
49549
+ this.removeClientRequestIdMapping(clientRequestId);
49550
+ }
49536
49551
  if (ongoingQuery) {
49537
49552
  ongoingQuery.gotInitialResponse = true;
49538
49553
  ongoingQuery.isInFlight = false;
@@ -50508,7 +50523,13 @@ async function performAxiosRequest({ files, filesFieldName, message: body, url,
50508
50523
  statusText: axiosResponse.statusText,
50509
50524
  };
50510
50525
  }
50511
- /** @internal. */
50526
+ /**
50527
+ * @internal.
50528
+ *
50529
+ * @deprecated: this method hides potential error.
50530
+ * Every endpoint call should know what kind result to expect
50531
+ * and call 'deserializeObj' directly.
50532
+ */
50512
50533
  function tryDeserializing(text) {
50513
50534
  if (!text)
50514
50535
  return undefined;
@@ -146,4 +146,5 @@ export declare class DocumentReference<T extends DocumentData = any> {
146
146
  * immediately.
147
147
  */
148
148
  delete(transactionId?: TransactionId): Promise<void>;
149
+ private hasSquidPlaceholderId;
149
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.183",
3
+ "version": "1.0.185",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/typescript-client/src/index.d.ts",