@squidcloud/client 1.0.47 → 1.0.49
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/common/src/api.types.d.ts +2 -1
- package/dist/common/src/backend-run.types.d.ts +1 -1
- package/dist/common/src/bundle-api.types.d.ts +2 -0
- package/dist/common/src/bundle-data.types.d.ts +6 -0
- package/dist/common/src/distributed-lock.context.d.ts +5 -0
- package/dist/common/src/graphql.types.d.ts +0 -5
- package/dist/common/src/index.d.ts +3 -1
- package/dist/common/src/integration.types.d.ts +17 -4
- package/dist/common/src/socket.types.d.ts +34 -4
- package/dist/common/src/utils/url.d.ts +1 -0
- package/dist/index.js +6 -6
- package/dist/typescript-client/src/distributed-lock.manager.d.ts +19 -0
- package/dist/typescript-client/src/socket.manager.d.ts +2 -2
- package/dist/typescript-client/src/squid.d.ts +12 -0
- package/package.json +1 -1
- package/dist/typescript-client/src/mutation/mutation.spec.d.ts +0 -1
- package/dist/typescript-client/src/query/query-subscription.manager.spec.d.ts +0 -1
- package/dist/typescript-client/src/query/query.spec.d.ts +0 -1
- package/dist/typescript-client/src/testing/fake-rpc.manager.d.ts +0 -20
- package/dist/typescript-client/src/testing/fake-socket.manager.d.ts +0 -9
- package/dist/typescript-client/src/testing/squid-env-setup.d.ts +0 -79
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
/** A handler for a distributed lock that can be released. */
|
|
3
|
+
export interface DistributedLock {
|
|
4
|
+
/**
|
|
5
|
+
* Releases the lock.
|
|
6
|
+
* @returns A promise that resolves when the lock is released.
|
|
7
|
+
*/
|
|
8
|
+
release(): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the lock has been released.
|
|
11
|
+
* @returns True if the lock has been released.
|
|
12
|
+
*/
|
|
13
|
+
isReleased(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Observes when the lock is released (It may be released due to a connection issue)
|
|
16
|
+
* @returns An observable that emits when the lock is released.
|
|
17
|
+
*/
|
|
18
|
+
observeRelease(): Observable<void>;
|
|
19
|
+
}
|
|
@@ -2,7 +2,7 @@ import { ClientId, MessageFromClient, MessageToClient } from '@squidcloud/common
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { DestructManager } from './destruct.manager';
|
|
4
4
|
export interface SocketManagerInterface {
|
|
5
|
-
observeNotifications(): Observable<
|
|
5
|
+
observeNotifications<T extends MessageToClient>(): Observable<T>;
|
|
6
6
|
observeConnectionReady(): Observable<boolean>;
|
|
7
7
|
sendMessage(message: MessageFromClient): void;
|
|
8
8
|
}
|
|
@@ -18,7 +18,7 @@ export declare class SocketManager implements SocketManagerInterface {
|
|
|
18
18
|
private socket;
|
|
19
19
|
private firstConnection;
|
|
20
20
|
constructor(clientId: ClientId, socketIoEndpoint: string, messageNotificationWrapper: (fn: () => any) => any, destructManager: DestructManager, extraHeaders?: Record<string, string>);
|
|
21
|
-
observeNotifications(): Observable<
|
|
21
|
+
observeNotifications<T extends MessageToClient>(): Observable<T>;
|
|
22
22
|
observeConnectionReady(): Observable<boolean>;
|
|
23
23
|
sendMessage(message: MessageFromClient): void;
|
|
24
24
|
private connect;
|
|
@@ -3,6 +3,7 @@ import { Observable } from 'rxjs';
|
|
|
3
3
|
import { CollectionReference } from './collection-reference';
|
|
4
4
|
import { GraphQLClient } from './graphql-client';
|
|
5
5
|
import { TransactionId } from './types';
|
|
6
|
+
import { DistributedLock } from './distributed-lock.manager';
|
|
6
7
|
/** The different options that can be used to initialize a Squid instance. */
|
|
7
8
|
export interface SquidOptions {
|
|
8
9
|
/**
|
|
@@ -56,6 +57,7 @@ export declare class Squid {
|
|
|
56
57
|
private readonly graphqlClientFactory;
|
|
57
58
|
private readonly destructManager;
|
|
58
59
|
private readonly documentIdentityService;
|
|
60
|
+
private readonly distributedLockManager;
|
|
59
61
|
private static readonly squidInstancesMap;
|
|
60
62
|
/**
|
|
61
63
|
* Creates a new instance of Squid with the given options.
|
|
@@ -162,6 +164,16 @@ export declare class Squid {
|
|
|
162
164
|
* @returns A GraphQL client for the given integration.
|
|
163
165
|
*/
|
|
164
166
|
graphql: (integrationId: IntegrationId) => GraphQLClient;
|
|
167
|
+
/**
|
|
168
|
+
* Returns a distributed lock for the given mutex. The lock can be used to synchronize access to a shared resource.
|
|
169
|
+
* The lock will be released when the release method on the returned object is invoked or whenever the connection
|
|
170
|
+
* with the server is lost.
|
|
171
|
+
* @param mutex A string that uniquely identifies the lock.
|
|
172
|
+
* @param exclusive Whether the lock should be exclusive or not. If the lock is exclusive, only one client can hold
|
|
173
|
+
* the lock.
|
|
174
|
+
* @returns A promise that resolves with the lock object. The promise will reject if failed to acquire the lock.
|
|
175
|
+
*/
|
|
176
|
+
distributedLock: (mutex: string, exclusive?: boolean) => Promise<DistributedLock>;
|
|
165
177
|
/**
|
|
166
178
|
* Destructs the Squid Client. Unsubscribes from all ongoing queries or requests, and clears the local data.
|
|
167
179
|
* After invoking this method, the Squid client will not be usable.
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ClientRequestId } from '@squidcloud/common';
|
|
2
|
-
import { DestructManager } from '../destruct.manager';
|
|
3
|
-
import { RpcManager } from '../rpc.manager';
|
|
4
|
-
import { FakeSocketManager } from './fake-socket.manager';
|
|
5
|
-
export declare class FakeRpcManager extends RpcManager {
|
|
6
|
-
lastQueryClientRequestId: ClientRequestId | undefined;
|
|
7
|
-
lastPostRequest?: {
|
|
8
|
-
path: string;
|
|
9
|
-
message: any;
|
|
10
|
-
};
|
|
11
|
-
allPostRequests: Array<{
|
|
12
|
-
path: string;
|
|
13
|
-
message: any;
|
|
14
|
-
}>;
|
|
15
|
-
errorResponses: Array<any>;
|
|
16
|
-
constructor(socketManager: FakeSocketManager, destructManager: DestructManager);
|
|
17
|
-
setStaticHeader(key: string, value: string): void;
|
|
18
|
-
deleteStaticHeader(key: string): void;
|
|
19
|
-
post<T>(path: string, message: any): Promise<T>;
|
|
20
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MessageFromClient, MessageToClient } from '@squidcloud/common';
|
|
2
|
-
import { Observable, Subject } from 'rxjs';
|
|
3
|
-
import { SocketManagerInterface } from '../socket.manager';
|
|
4
|
-
export declare class FakeSocketManager implements SocketManagerInterface {
|
|
5
|
-
messagesToClient: Subject<MessageToClient>;
|
|
6
|
-
observeConnectionReady(): Observable<boolean>;
|
|
7
|
-
observeNotifications(): Observable<MessageToClient>;
|
|
8
|
-
sendMessage(message: MessageFromClient): void;
|
|
9
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { ClientRequestId, CollectionName, DocId, IntegrationId, LockManager, MutationType, SquidDocument } from '@squidcloud/common';
|
|
2
|
-
import { Subject, Subscription } from 'rxjs';
|
|
3
|
-
import { CollectionReference } from '../collection-reference';
|
|
4
|
-
import { CollectionReferenceFactory } from '../collection-reference.factory';
|
|
5
|
-
import { DataManager } from '../data.manager';
|
|
6
|
-
import { DestructManager } from '../destruct.manager';
|
|
7
|
-
import DocumentIdentityService from '../document-identity.service';
|
|
8
|
-
import { DocumentReferenceFactory } from '../document-reference.factory';
|
|
9
|
-
import { DocumentStore } from '../document-store';
|
|
10
|
-
import { MutationSender } from '../mutation/mutation-sender';
|
|
11
|
-
import { JoinQueryBuilderFactory } from '../query/join-query-builder.factory';
|
|
12
|
-
import { QueryBuilderFactory } from '../query/query-builder.factory';
|
|
13
|
-
import { QuerySubscriptionManager } from '../query/query-subscription.manager';
|
|
14
|
-
import { FakeRpcManager } from './fake-rpc.manager';
|
|
15
|
-
import { FakeSocketManager } from './fake-socket.manager';
|
|
16
|
-
export type TestDocTypeA = {
|
|
17
|
-
a: number;
|
|
18
|
-
b?: {
|
|
19
|
-
c: number;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export type TestDocTypeB = {
|
|
23
|
-
b: number;
|
|
24
|
-
c?: {
|
|
25
|
-
d: number;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export type QueryResponse = {
|
|
29
|
-
resCount: number;
|
|
30
|
-
results: Array<TestDocTypeA> | undefined;
|
|
31
|
-
receivedSubject: Subject<void>;
|
|
32
|
-
};
|
|
33
|
-
export type JoinQueryResponse = {
|
|
34
|
-
resCount: number;
|
|
35
|
-
results: Array<{
|
|
36
|
-
a: TestDocTypeA;
|
|
37
|
-
b: TestDocTypeB | undefined;
|
|
38
|
-
}> | undefined;
|
|
39
|
-
receivedSubject: Subject<void>;
|
|
40
|
-
subscription: Subscription;
|
|
41
|
-
};
|
|
42
|
-
export declare class SquidEnvSetup {
|
|
43
|
-
readonly querySubscriptionManager: QuerySubscriptionManager;
|
|
44
|
-
readonly socketManager: FakeSocketManager;
|
|
45
|
-
readonly rpcManager: FakeRpcManager;
|
|
46
|
-
readonly documentStore: DocumentStore;
|
|
47
|
-
readonly documentReferenceFactory: DocumentReferenceFactory;
|
|
48
|
-
readonly collectionReferenceFactory: CollectionReferenceFactory;
|
|
49
|
-
readonly queryBuilderFactory: QueryBuilderFactory;
|
|
50
|
-
readonly joinQueryBuilderFactory: JoinQueryBuilderFactory;
|
|
51
|
-
readonly lockManager: LockManager;
|
|
52
|
-
readonly mutationSender: MutationSender;
|
|
53
|
-
readonly dataManager: DataManager;
|
|
54
|
-
readonly clientId = "fakeClientId";
|
|
55
|
-
readonly destructManager: DestructManager;
|
|
56
|
-
readonly documentIdentityService: DocumentIdentityService;
|
|
57
|
-
readonly collectionA: CollectionReference<TestDocTypeA>;
|
|
58
|
-
readonly collectionB: CollectionReference<TestDocTypeB>;
|
|
59
|
-
constructor();
|
|
60
|
-
simulateQueryResponse(docs: Array<Partial<SquidDocument>>, collectionName: CollectionName, integrationId?: IntegrationId, clientRequestId?: ClientRequestId): void;
|
|
61
|
-
simulateMutationsResponse(updates: Array<{
|
|
62
|
-
mutationType: MutationType;
|
|
63
|
-
collectionName: CollectionName;
|
|
64
|
-
integrationId?: IntegrationId;
|
|
65
|
-
clientRequestId?: ClientRequestId;
|
|
66
|
-
doc: Partial<SquidDocument> & {
|
|
67
|
-
__docId__: DocId;
|
|
68
|
-
};
|
|
69
|
-
}>, mutationsTimestamp?: number): Promise<void>;
|
|
70
|
-
simulateErrorResponse(message: string): void;
|
|
71
|
-
runAsync(fn: () => any): Promise<void>;
|
|
72
|
-
getBuiltInDocId(idValue: string): string;
|
|
73
|
-
executeQueryOnCollectionA(subscribe?: boolean): QueryResponse;
|
|
74
|
-
executeJoinQuery(subscribe?: boolean): JoinQueryResponse;
|
|
75
|
-
simulateResponseForCollectionA(id?: string, a?: number): void;
|
|
76
|
-
simulateResponseForCollectionB(id: string, b: number): void;
|
|
77
|
-
}
|
|
78
|
-
export declare let squidEnvSetup: SquidEnvSetup;
|
|
79
|
-
export declare function squidEnvSetupBeforeEach(): void;
|