@squidcloud/client 1.0.147 → 1.0.149

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 (110) hide show
  1. package/dist/cjs/index.js +8793 -8803
  2. package/dist/common/src/ai-assistant.types.d.ts +25 -25
  3. package/dist/common/src/ai-chatbot.context.d.ts +12 -12
  4. package/dist/common/src/ai-chatbot.schemas.d.ts +1 -1
  5. package/dist/common/src/ai-chatbot.types.d.ts +27 -27
  6. package/dist/common/src/api-call.context.d.ts +13 -13
  7. package/dist/common/src/api.types.d.ts +4 -4
  8. package/dist/common/src/application.schemas.d.ts +66 -66
  9. package/dist/common/src/application.types.d.ts +141 -143
  10. package/dist/common/src/backend-function.schemas.d.ts +1 -1
  11. package/dist/common/src/backend-function.types.d.ts +1 -1
  12. package/dist/common/src/backend-run.types.d.ts +2 -2
  13. package/dist/common/src/bundle-api.types.d.ts +41 -43
  14. package/dist/common/src/bundle-data.types.d.ts +5 -5
  15. package/dist/common/src/communication.types.d.ts +10 -8
  16. package/dist/common/src/context.types.d.ts +40 -40
  17. package/dist/common/src/distributed-lock.context.d.ts +4 -4
  18. package/dist/common/src/document.types.d.ts +22 -22
  19. package/dist/common/src/graphql.context.d.ts +7 -7
  20. package/dist/common/src/graphql.types.d.ts +9 -9
  21. package/dist/common/src/heartbeat.types.d.ts +1 -1
  22. package/dist/common/src/http-status.enum.d.ts +50 -50
  23. package/dist/common/src/index.d.ts +54 -57
  24. package/dist/common/src/integrations/ai_chatbot.types.d.ts +31 -31
  25. package/dist/common/src/integrations/api.types.d.ts +80 -80
  26. package/dist/common/src/integrations/auth.types.d.ts +47 -47
  27. package/dist/common/src/integrations/database.types.d.ts +274 -274
  28. package/dist/common/src/integrations/index.d.ts +134 -134
  29. package/dist/common/src/integrations/observability.types.d.ts +23 -23
  30. package/dist/common/src/logger.types.d.ts +21 -21
  31. package/dist/common/src/metrics.types.d.ts +1 -1
  32. package/dist/common/src/mutation.context.d.ts +14 -14
  33. package/dist/common/src/mutation.schemas.d.ts +1 -1
  34. package/dist/common/src/mutation.types.d.ts +53 -53
  35. package/dist/common/src/native-query.context.d.ts +7 -7
  36. package/dist/common/src/native-query.types.d.ts +16 -16
  37. package/dist/common/src/query/base-query-builder.d.ts +147 -147
  38. package/dist/common/src/query/index.d.ts +4 -4
  39. package/dist/common/src/query/pagination.d.ts +62 -62
  40. package/dist/common/src/query/query-context.d.ts +137 -137
  41. package/dist/common/src/query/serialized-query.types.d.ts +24 -24
  42. package/dist/common/src/query.types.d.ts +64 -64
  43. package/dist/common/src/regions.d.ts +1 -1
  44. package/dist/common/src/schema/schema.types.d.ts +54 -54
  45. package/dist/common/src/secret.schemas.d.ts +1 -1
  46. package/dist/common/src/secret.types.d.ts +22 -22
  47. package/dist/common/src/security.types.d.ts +1 -1
  48. package/dist/common/src/socket.schemas.d.ts +1 -1
  49. package/dist/common/src/socket.types.d.ts +5 -5
  50. package/dist/common/src/time-units.d.ts +1 -1
  51. package/dist/common/src/trigger.types.d.ts +1 -1
  52. package/dist/common/src/types.d.ts +14 -14
  53. package/dist/common/src/utils/array.d.ts +1 -1
  54. package/dist/common/src/utils/assert.d.ts +1 -1
  55. package/dist/common/src/utils/error.d.ts +4 -4
  56. package/dist/common/src/utils/global.utils.d.ts +1 -1
  57. package/dist/common/src/utils/http.d.ts +2 -2
  58. package/dist/common/src/utils/id.d.ts +2 -2
  59. package/dist/common/src/utils/lock.manager.d.ts +14 -14
  60. package/dist/common/src/utils/object.d.ts +5 -5
  61. package/dist/common/src/utils/serialization.d.ts +5 -6
  62. package/dist/common/src/utils/transforms.d.ts +18 -18
  63. package/dist/common/src/utils/url.d.ts +1 -1
  64. package/dist/common/src/utils/validation.d.ts +25 -25
  65. package/dist/common/src/webhook-response.d.ts +1 -1
  66. package/dist/common/src/websocket.impl.d.ts +21 -21
  67. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
  68. package/dist/typescript-client/src/ai-assistant-client.d.ts +73 -73
  69. package/dist/typescript-client/src/ai-chatbot-client.d.ts +174 -174
  70. package/dist/typescript-client/src/ai-chatbot-client.factory.d.ts +8 -8
  71. package/dist/typescript-client/src/ai.types.d.ts +61 -61
  72. package/dist/typescript-client/src/api.manager.d.ts +11 -11
  73. package/dist/typescript-client/src/auth.manager.d.ts +26 -26
  74. package/dist/typescript-client/src/backend-function.manager.d.ts +9 -9
  75. package/dist/typescript-client/src/client-id.service.d.ts +27 -27
  76. package/dist/typescript-client/src/collection-reference.d.ts +80 -80
  77. package/dist/typescript-client/src/collection-reference.factory.d.ts +13 -13
  78. package/dist/typescript-client/src/connection-details.d.ts +23 -23
  79. package/dist/typescript-client/src/data.manager.d.ts +174 -173
  80. package/dist/typescript-client/src/destruct.manager.d.ts +12 -12
  81. package/dist/typescript-client/src/distributed-lock.manager.d.ts +16 -16
  82. package/dist/typescript-client/src/document-identity.service.d.ts +12 -12
  83. package/dist/typescript-client/src/document-reference.d.ts +140 -140
  84. package/dist/typescript-client/src/document-reference.factory.d.ts +13 -13
  85. package/dist/typescript-client/src/document-store.d.ts +14 -14
  86. package/dist/typescript-client/src/graphql-client.d.ts +14 -14
  87. package/dist/typescript-client/src/graphql-client.factory.d.ts +11 -11
  88. package/dist/typescript-client/src/index.d.ts +9 -9
  89. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +10 -10
  90. package/dist/typescript-client/src/native-query-manager.d.ts +7 -7
  91. package/dist/typescript-client/src/query/deserializer.d.ts +3 -3
  92. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +161 -161
  93. package/dist/typescript-client/src/query/local-query-manager.d.ts +9 -9
  94. package/dist/typescript-client/src/query/query-builder.factory.d.ts +77 -77
  95. package/dist/typescript-client/src/query/query-sender.d.ts +33 -33
  96. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +131 -130
  97. package/dist/typescript-client/src/query/query.types.d.ts +49 -49
  98. package/dist/typescript-client/src/rate-limiter.d.ts +32 -32
  99. package/dist/typescript-client/src/rpc.manager.d.ts +30 -30
  100. package/dist/typescript-client/src/secret.client.d.ts +22 -22
  101. package/dist/typescript-client/src/socket.manager.d.ts +43 -43
  102. package/dist/typescript-client/src/squid.d.ts +238 -269
  103. package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
  104. package/dist/typescript-client/src/testing/setup-tests.d.ts +1 -1
  105. package/dist/typescript-client/src/types.d.ts +2 -2
  106. package/package.json +3 -2
  107. package/dist/common/src/named-query.context.d.ts +0 -4
  108. package/dist/common/src/named-query.schemas.d.ts +0 -1
  109. package/dist/common/src/named-query.types.d.ts +0 -1
  110. package/dist/typescript-client/src/named-query.manager.d.ts +0 -11
@@ -1,173 +1,174 @@
1
- import { DocTimestamp, LockManager, Mutation, SquidDocId, SquidDocument } from '@squidcloud/common';
2
- import { QuerySender } from './query/query-sender';
3
- import { DestructManager } from './destruct.manager';
4
- import DocumentIdentityService from './document-identity.service';
5
- import { DocumentStore } from './document-store';
6
- import { MutationSender } from './mutation/mutation-sender';
7
- import { QueryBuilderFactory } from './query/query-builder.factory';
8
- import { QuerySubscriptionManager } from './query/query-subscription.manager';
9
- import { SocketManager } from './socket.manager';
10
- import { TransactionId } from './types';
11
- export interface DocTimestampMetadata {
12
- timestamp: DocTimestamp;
13
- expireTimestamp?: number;
14
- }
15
- export declare class DataManager {
16
- private readonly documentStore;
17
- private readonly mutationSender;
18
- private readonly socketManager;
19
- private readonly querySubscriptionManager;
20
- private readonly queryBuilderFactory;
21
- private readonly lockManager;
22
- private readonly destructManager;
23
- private readonly documentIdentityService;
24
- private readonly querySender;
25
- private readonly docIdToLocalTimestamp;
26
- private currentTransactionId;
27
- /**
28
- * During a batch, any update to a document that may trigger an update to a query is collected here and once the batch
29
- * ends, the relevant subscribes to these queries will be updated.
30
- */
31
- private readonly batchClientRequestIds;
32
- /**
33
- * In this map we save timestamps for documents that are available locally or recently deleted but need to remain
34
- * here so if a mutation comes from the server we know whether to apply it or not based on the timestamp. For
35
- * example, if a document is removed locally and immediately after, an update is received from the server - In that
36
- * case, it may be the update pre-dates the data that was available locally a second ago. For that reason, the
37
- * timestamp needs to be kept and even for removed documents it will be kept for ~20 seconds more.
38
- *
39
- * Eventually, this map is used as a gatekeeper for preventing old versions of a document (based on timestamp) to
40
- * appear on the client.
41
- */
42
- private readonly docIdToServerTimestamp;
43
- /**
44
- * In the case of a local change (outgoing change) without a server timestamp, an incoming server update cannot be
45
- * applied and needs to be queued until the local state allows it. In this case the incoming update will be queued in
46
- * this map. Any future incoming server update to the same document will override the previous update in case it has
47
- * a later timestamp.
48
- */
49
- private readonly pendingIncomingUpdates;
50
- /**
51
- * A mutation sent to the server will be stored in this map until it receives a timestamp from the server. These
52
- * mutations were already applied locally and were sent to the server or about to be sent if sentToServer=false
53
- * (or are queued in the MutationSender due to a lock). The existence of these pending mutations indicates the data
54
- * manager to:
55
- * 1 - Not apply any incoming server mutation while there are outgoing mutations without a timestamp
56
- * 2 - Not delete the local document even if there are no queries related to this document - there is a chance
57
- * that there will be a future query that will need this document and the query needs to return the local version
58
- * of the document.
59
- * 3 - Even when all outgoing mutations have a timestamp, it may be that there is a pending query in flight that will
60
- * need to return the document. In this case, the local document may be different from the server. Hence, it
61
- * cannot accept the server change and will wait for another update from the server. For this purpose, timestamp
62
- * will be stored in docsToTimestamp for ~20 more seconds.
63
- *
64
- * Note: Only one entry per squidDocId can be with sentToServer=false. This is true since all updates to the same doc
65
- * in the same batch are appended (and reduced) to the same outgoing mutation object.
66
- */
67
- private readonly pendingOutgoingMutations;
68
- private readonly pendingOutgoingMutationsChanged;
69
- /**
70
- * A subject for whether there are outgoing mutations. If there are outgoing mutations, any incoming update from the
71
- * server will be delayed until all the outgoing mutations will be acknowledged by the server.
72
- * This mechanism is needed to avoid this case:
73
- *
74
- * collection.docRef('a').delete();
75
- * collection.snapshots().subscribe((res) => {
76
- * // The result here may include doc with id='a' since the delete mutation was not acknowledged.
77
- * });
78
- *
79
- * If we wait for the acknowledgment message, we will have a server timestamp and will be able to ignore the incoming
80
- * result for document with id='a'.
81
- */
82
- private readonly outgoingMutationsEmpty;
83
- /**
84
- * When applying an outgoing mutation, there may be a short time that the mutation is not yet inserted into the
85
- * pending outgoing mutations map. In this case, we mark the document id as known to be dirty and remove it from the
86
- * set once the pending outgoing mutations map is updated.
87
- */
88
- private readonly knownDirtyDocs;
89
- private readonly failedDocsToResync;
90
- private readonly refreshDocIdToTimestamp;
91
- private deleteExpiredTimestampsInterval;
92
- private handleIncomingMessagesForTests;
93
- constructor(documentStore: DocumentStore, mutationSender: MutationSender, socketManager: SocketManager, querySubscriptionManager: QuerySubscriptionManager, queryBuilderFactory: QueryBuilderFactory, lockManager: LockManager, destructManager: DestructManager, documentIdentityService: DocumentIdentityService, querySender: QuerySender);
94
- getProperties(squidDocId: SquidDocId): SquidDocument | undefined;
95
- /** Whether a document has changes that are out of sync with the server. */
96
- isDirty(squidDocId: SquidDocId): boolean;
97
- /**
98
- * Runs the provided function without sending mutations to the server while collecting the updates to the different
99
- * queries. Local updates will still be applied. Once the batch finishes, all the updates will be sent to the server
100
- * and the different queries will be notified. runInTransaction may be invoked inside another runInTransaction, only
101
- * the top level batch will trigger updates to the server.
102
- */
103
- runInTransaction<T = any>(fn: (transactionId: TransactionId) => Promise<T>, transactionId?: TransactionId): Promise<T>;
104
- /** Applies a mutation done from the client (from DocumentReference) and sends it to the server. */
105
- applyOutgoingMutation(mutation: Mutation, transactionId: TransactionId | undefined): Promise<void>;
106
- /** Same as runInTransaction with the exception that the passed function runs synchronously. */
107
- private runInTransactionSync;
108
- /** Remove properties from the document record that should not be sent to the server. */
109
- private removeInternalProperties;
110
- /** Listens and handles mutations and snapshots notifications from the socketManager. */
111
- private handleNotifications;
112
- private handleIncomingMutations;
113
- private handleIncomingQuerySnapshots;
114
- /**
115
- * Returns a boolean for whether some updates were ignored because the client knows of a later timestamp for those
116
- * documents.
117
- */
118
- private applyIncomingUpdates;
119
- private maybeApplyIncomingUpdate;
120
- private destruct;
121
- private stopDeleteExpiredTimestampsJob;
122
- /**
123
- * Removes entries from the docToTimestamp map for all the documents that are no longer relevant for this client.
124
- * If a document is currently tracked, we forget it.
125
- * Cases a document is considered not relevant anymore:
126
- * 1 - There are no outgoing or incoming updates for this document AND:
127
- * a - The document was deleted on the server and this client already received a notification about it OR
128
- * b - The document no longer has a query that will keep it up-to-date
129
- */
130
- private startDeleteExpiredTimestampsJob;
131
- /**
132
- * Whether the document is tracked by any pending mutations or ongoing queries.
133
- */
134
- isTracked(squidDocId: string): boolean;
135
- /**
136
- * Whether a document exists locally, but is no longer tracked by any mutations or queries. This is often the case
137
- * for in-memory DocumentReferences that are not part of any query.
138
- */
139
- isForgotten(squidDocId: SquidDocId): boolean;
140
- /**
141
- * Whether a document only exists locally. This means that the document has never by sent to or received from the
142
- * server.
143
- */
144
- isLocalOnly(squidDocId: SquidDocId): boolean;
145
- /**
146
- * Whether the document has even been acknowledged by the server. Acknowledgements occur when an incoming query or
147
- * mutation is received, and when an outgoing mutation is acknowledged.
148
- */
149
- hasBeenAcknowledged(squidDocId: SquidDocId): boolean;
150
- /**
151
- * Updates the document with the new properties, returns true if an update was done or false in case the doc did not
152
- * change.
153
- */
154
- private updateDocumentFromSnapshot;
155
- private finishTransaction;
156
- private sendAllUnsentOutgoingMutations;
157
- private sendMutationsForIntegration;
158
- private removeOutgoingMutation;
159
- private resyncFailedUpdates;
160
- private refreshUpdatedDocuments;
161
- private groupOutgoingMutationsByIntegrationId;
162
- /**
163
- * Handles the case that due to some change (an incoming or outgoing change to a document), a document becomes orphan.
164
- * That is, there are no ongoing queries that will keep it up-to-date.
165
- * An orphan document should not stay locally since it may be stale after some time.
166
- */
167
- private handleOrphanDocs;
168
- private acknowledgeDocument;
169
- private setExpiration;
170
- private forgetDocument;
171
- private migrateDocIds;
172
- private hasPendingSentMutations;
173
- }
1
+ import { DocTimestamp, LockManager, Mutation, SquidDocId, SquidDocument } from '@squidcloud/common';
2
+ import { DestructManager } from './destruct.manager';
3
+ import DocumentIdentityService from './document-identity.service';
4
+ import { DocumentStore } from './document-store';
5
+ import { MutationSender } from './mutation/mutation-sender';
6
+ import { QueryBuilderFactory } from './query/query-builder.factory';
7
+ import { QuerySender } from './query/query-sender';
8
+ import { QuerySubscriptionManager } from './query/query-subscription.manager';
9
+ import { SocketManager } from './socket.manager';
10
+ import { TransactionId } from './types';
11
+ export interface DocTimestampMetadata {
12
+ timestamp: DocTimestamp;
13
+ expireTimestamp?: number;
14
+ }
15
+ export declare class DataManager {
16
+ private readonly documentStore;
17
+ private readonly mutationSender;
18
+ private readonly socketManager;
19
+ private readonly querySubscriptionManager;
20
+ private readonly queryBuilderFactory;
21
+ private readonly lockManager;
22
+ private readonly destructManager;
23
+ private readonly documentIdentityService;
24
+ private readonly querySender;
25
+ private readonly docIdToLocalTimestamp;
26
+ private currentTransactionId;
27
+ /**
28
+ * During a batch, any update to a document that may trigger an update to a query is collected here and once the batch
29
+ * ends, the relevant subscribes to these queries will be updated.
30
+ */
31
+ private readonly batchClientRequestIds;
32
+ /**
33
+ * In this map we save timestamps for documents that are available locally or recently deleted but need to remain
34
+ * here so if a mutation comes from the server we know whether to apply it or not based on the timestamp. For
35
+ * example, if a document is removed locally and immediately after, an update is received from the server - In that
36
+ * case, it may be the update pre-dates the data that was available locally a second ago. For that reason, the
37
+ * timestamp needs to be kept and even for removed documents it will be kept for ~20 seconds more.
38
+ *
39
+ * Eventually, this map is used as a gatekeeper for preventing old versions of a document (based on timestamp) to
40
+ * appear on the client.
41
+ */
42
+ private readonly docIdToServerTimestamp;
43
+ /**
44
+ * In the case of a local change (outgoing change) without a server timestamp, an incoming server update cannot be
45
+ * applied and needs to be queued until the local state allows it. In this case the incoming update will be queued in
46
+ * this map. Any future incoming server update to the same document will override the previous update in case it has
47
+ * a later timestamp.
48
+ */
49
+ private readonly pendingIncomingUpdates;
50
+ /**
51
+ * A mutation sent to the server will be stored in this map until it receives a timestamp from the server. These
52
+ * mutations were already applied locally and were sent to the server or about to be sent if sentToServer=false
53
+ * (or are queued in the MutationSender due to a lock). The existence of these pending mutations indicates the data
54
+ * manager to:
55
+ * 1 - Not apply any incoming server mutation while there are outgoing mutations without a timestamp
56
+ * 2 - Not delete the local document even if there are no queries related to this document - there is a chance
57
+ * that there will be a future query that will need this document and the query needs to return the local version
58
+ * of the document.
59
+ * 3 - Even when all outgoing mutations have a timestamp, it may be that there is a pending query in flight that will
60
+ * need to return the document. In this case, the local document may be different from the server. Hence, it
61
+ * cannot accept the server change and will wait for another update from the server. For this purpose, timestamp
62
+ * will be stored in docsToTimestamp for ~20 more seconds.
63
+ *
64
+ * Note: Only one entry per squidDocId can be with sentToServer=false. This is true since all updates to the same doc
65
+ * in the same batch are appended (and reduced) to the same outgoing mutation object.
66
+ */
67
+ private readonly pendingOutgoingMutations;
68
+ private readonly pendingOutgoingMutationsChanged;
69
+ /**
70
+ * A subject for whether there are outgoing mutations. If there are outgoing mutations, any incoming update from the
71
+ * server will be delayed until all the outgoing mutations will be acknowledged by the server.
72
+ * This mechanism is needed to avoid this case:
73
+ *
74
+ * collection.docRef('a').delete();
75
+ * collection.snapshots().subscribe((res) => {
76
+ * // The result here may include doc with id='a' since the delete mutation was not acknowledged.
77
+ * });
78
+ *
79
+ * If we wait for the acknowledgment message, we will have a server timestamp and will be able to ignore the incoming
80
+ * result for document with id='a'.
81
+ */
82
+ private readonly outgoingMutationsEmpty;
83
+ /**
84
+ * When applying an outgoing mutation, there may be a short time that the mutation is not yet inserted into the
85
+ * pending outgoing mutations map. In this case, we mark the document id as known to be dirty and remove it from the
86
+ * set once the pending outgoing mutations map is updated.
87
+ */
88
+ private readonly knownDirtyDocs;
89
+ private readonly failedDocsToResync;
90
+ private readonly refreshDocIdToTimestamp;
91
+ private deleteExpiredTimestampsInterval;
92
+ private handleIncomingMessagesForTests;
93
+ constructor(documentStore: DocumentStore, mutationSender: MutationSender, socketManager: SocketManager, querySubscriptionManager: QuerySubscriptionManager, queryBuilderFactory: QueryBuilderFactory, lockManager: LockManager, destructManager: DestructManager, documentIdentityService: DocumentIdentityService, querySender: QuerySender);
94
+ getProperties(squidDocId: SquidDocId): SquidDocument | undefined;
95
+ /** Whether a document has changes that are out of sync with the server. */
96
+ isDirty(squidDocId: SquidDocId): boolean;
97
+ /**
98
+ * Runs the provided function without sending mutations to the server while collecting the updates to the different
99
+ * queries. Local updates will still be applied. Once the batch finishes, all the updates will be sent to the server
100
+ * and the different queries will be notified. runInTransaction may be invoked inside another runInTransaction, only
101
+ * the top level batch will trigger updates to the server.
102
+ */
103
+ runInTransaction<T = any>(fn: (transactionId: TransactionId) => Promise<T>, transactionId?: TransactionId): Promise<T>;
104
+ /** Applies a mutation done from the client (from DocumentReference) and sends it to the server. */
105
+ applyOutgoingMutation(mutation: Mutation, transactionId: TransactionId | undefined): Promise<void>;
106
+ /** Same as runInTransaction with the exception that the passed function runs synchronously. */
107
+ private runInTransactionSync;
108
+ /** Remove properties from the document record that should not be sent to the server. */
109
+ private removeInternalProperties;
110
+ /** Listens and handles mutations and snapshots notifications from the socketManager. */
111
+ private handleNotifications;
112
+ private handleIncomingMutations;
113
+ private handleIncomingQuerySnapshots;
114
+ /**
115
+ * Returns a boolean for whether some updates were ignored because the client knows of a later timestamp for those
116
+ * documents.
117
+ */
118
+ private applyIncomingUpdates;
119
+ private maybeApplyIncomingUpdate;
120
+ private refreshQueryMapping;
121
+ private destruct;
122
+ private stopDeleteExpiredTimestampsJob;
123
+ /**
124
+ * Removes entries from the docToTimestamp map for all the documents that are no longer relevant for this client.
125
+ * If a document is currently tracked, we forget it.
126
+ * Cases a document is considered not relevant anymore:
127
+ * 1 - There are no outgoing or incoming updates for this document AND:
128
+ * a - The document was deleted on the server and this client already received a notification about it OR
129
+ * b - The document no longer has a query that will keep it up-to-date
130
+ */
131
+ private startDeleteExpiredTimestampsJob;
132
+ /**
133
+ * Whether the document is tracked by any pending mutations or ongoing queries.
134
+ */
135
+ isTracked(squidDocId: string): boolean;
136
+ /**
137
+ * Whether a document exists locally, but is no longer tracked by any mutations or queries. This is often the case
138
+ * for in-memory DocumentReferences that are not part of any query.
139
+ */
140
+ isForgotten(squidDocId: SquidDocId): boolean;
141
+ /**
142
+ * Whether a document only exists locally. This means that the document has never by sent to or received from the
143
+ * server.
144
+ */
145
+ isLocalOnly(squidDocId: SquidDocId): boolean;
146
+ /**
147
+ * Whether the document has even been acknowledged by the server. Acknowledgements occur when an incoming query or
148
+ * mutation is received, and when an outgoing mutation is acknowledged.
149
+ */
150
+ hasBeenAcknowledged(squidDocId: SquidDocId): boolean;
151
+ /**
152
+ * Updates the document with the new properties, returns true if an update was done or false in case the doc did not
153
+ * change.
154
+ */
155
+ private updateDocumentFromSnapshot;
156
+ private finishTransaction;
157
+ private sendAllUnsentOutgoingMutations;
158
+ private sendMutationsForIntegration;
159
+ private removeOutgoingMutation;
160
+ private resyncFailedUpdates;
161
+ private refreshUpdatedDocuments;
162
+ private groupOutgoingMutationsByIntegrationId;
163
+ /**
164
+ * Handles the case that due to some change (an incoming or outgoing change to a document), a document becomes orphan.
165
+ * That is, there are no ongoing queries that will keep it up-to-date.
166
+ * An orphan document should not stay locally since it may be stale after some time.
167
+ */
168
+ private handleOrphanDocs;
169
+ private acknowledgeDocument;
170
+ private setExpiration;
171
+ private forgetDocument;
172
+ private migrateDocIds;
173
+ private hasPendingSentMutations;
174
+ }
@@ -1,12 +1,12 @@
1
- import { Observable } from 'rxjs';
2
- export type DestructorFn = () => Promise<void> | void;
3
- export declare class DestructManager {
4
- private readonly predestructors;
5
- private readonly destructors;
6
- private readonly isDestructedSubject;
7
- get isDestructing(): boolean;
8
- observeIsDestructing(): Observable<void>;
9
- onPreDestruct(fn: DestructorFn): void;
10
- onDestruct(fn: DestructorFn): void;
11
- destruct(): Promise<void>;
12
- }
1
+ import { Observable } from 'rxjs';
2
+ export type DestructorFn = () => Promise<void> | void;
3
+ export declare class DestructManager {
4
+ private readonly predestructors;
5
+ private readonly destructors;
6
+ private readonly isDestructedSubject;
7
+ get isDestructing(): boolean;
8
+ observeIsDestructing(): Observable<void>;
9
+ onPreDestruct(fn: DestructorFn): void;
10
+ onDestruct(fn: DestructorFn): void;
11
+ destruct(): Promise<void>;
12
+ }
@@ -1,16 +1,16 @@
1
- import { Observable } from 'rxjs';
2
- /** A handler for a distributed lock that can be released. */
3
- export interface DistributedLock {
4
- /** Releases the lock. */
5
- release(): void;
6
- /**
7
- * Whether the lock has been released.
8
- * @returns True if the lock has been released.
9
- */
10
- isReleased(): boolean;
11
- /**
12
- * Observes when the lock is released (It may be released due to a connection issue)
13
- * @returns An observable that emits when the lock is released.
14
- */
15
- observeRelease(): Observable<void>;
16
- }
1
+ import { Observable } from 'rxjs';
2
+ /** A handler for a distributed lock that can be released. */
3
+ export interface DistributedLock {
4
+ /** Releases the lock. */
5
+ release(): void;
6
+ /**
7
+ * Whether the lock has been released.
8
+ * @returns True if the lock has been released.
9
+ */
10
+ isReleased(): boolean;
11
+ /**
12
+ * Observes when the lock is released (It may be released due to a connection issue)
13
+ * @returns An observable that emits when the lock is released.
14
+ */
15
+ observeRelease(): Observable<void>;
16
+ }
@@ -1,12 +1,12 @@
1
- import { IdResolutionMap } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
- import { DestructManager } from './destruct.manager';
4
- import { DocumentStore } from './document-store';
5
- export default class DocumentIdentityService {
6
- private readonly documentStore;
7
- private readonly destructManager;
8
- private readonly changeNotifier;
9
- constructor(documentStore: DocumentStore, destructManager: DestructManager);
10
- migrate(idResolutionMap: IdResolutionMap): void;
11
- observeChanges(): Observable<IdResolutionMap>;
12
- }
1
+ import { IdResolutionMap } from '@squidcloud/common';
2
+ import { Observable } from 'rxjs';
3
+ import { DestructManager } from './destruct.manager';
4
+ import { DocumentStore } from './document-store';
5
+ export default class DocumentIdentityService {
6
+ private readonly documentStore;
7
+ private readonly destructManager;
8
+ private readonly changeNotifier;
9
+ constructor(documentStore: DocumentStore, destructManager: DestructManager);
10
+ migrate(idResolutionMap: IdResolutionMap): void;
11
+ observeChanges(): Observable<IdResolutionMap>;
12
+ }