@squidcloud/client 1.0.34 → 1.0.36
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-call.context.d.ts +12 -12
- package/dist/common/src/api.types.d.ts +23 -23
- package/dist/common/src/application.schemas.d.ts +883 -883
- package/dist/common/src/application.types.d.ts +205 -205
- package/dist/common/src/backend-function.schemas.d.ts +3 -3
- package/dist/common/src/backend-function.types.d.ts +7 -7
- package/dist/common/src/backend-run.types.d.ts +66 -66
- package/dist/common/src/bundle-api.types.d.ts +64 -64
- package/dist/common/src/bundle-data.types.d.ts +46 -46
- package/dist/common/src/communication.types.d.ts +4 -4
- package/dist/common/src/context.types.d.ts +31 -31
- package/dist/common/src/document.types.d.ts +35 -35
- package/dist/common/src/graphql.context.d.ts +6 -6
- package/dist/common/src/graphql.types.d.ts +16 -16
- package/dist/common/src/http-status.enum.d.ts +50 -50
- package/dist/common/src/index.d.ts +49 -49
- package/dist/common/src/integration.types.d.ts +316 -319
- package/dist/common/src/logger.types.d.ts +21 -21
- package/dist/common/src/metrics.types.d.ts +58 -58
- package/dist/common/src/mutation.context.d.ts +10 -10
- package/dist/common/src/mutation.schemas.d.ts +5 -5
- package/dist/common/src/mutation.types.d.ts +72 -72
- package/dist/common/src/named-query.context.d.ts +4 -4
- package/dist/common/src/named-query.schemas.d.ts +3 -3
- package/dist/common/src/named-query.types.d.ts +9 -9
- package/dist/common/src/query/index.d.ts +2 -2
- package/dist/common/src/query/query-context.d.ts +37 -37
- package/dist/common/src/query/simple-query-builder.d.ts +90 -90
- package/dist/common/src/query.schemas.d.ts +5 -5
- package/dist/common/src/query.types.d.ts +118 -118
- package/dist/common/src/regions.d.ts +22 -22
- package/dist/common/src/schema/schema.types.d.ts +54 -54
- package/dist/common/src/secret.schemas.d.ts +6 -6
- package/dist/common/src/secret.types.d.ts +40 -40
- package/dist/common/src/security.types.d.ts +3 -3
- package/dist/common/src/socket.schemas.d.ts +3 -3
- package/dist/common/src/socket.types.d.ts +68 -68
- package/dist/common/src/time-units.d.ts +5 -5
- package/dist/common/src/trigger.types.d.ts +15 -15
- package/dist/common/src/types.d.ts +15 -15
- package/dist/common/src/utils/array.d.ts +8 -8
- package/dist/common/src/utils/assert.d.ts +8 -8
- package/dist/common/src/utils/error.d.ts +4 -4
- package/dist/common/src/utils/http.d.ts +2 -2
- package/dist/common/src/utils/id.d.ts +2 -2
- package/dist/common/src/utils/lock.manager.d.ts +14 -14
- package/dist/common/src/utils/nullish.d.ts +1 -1
- package/dist/common/src/utils/object.d.ts +6 -6
- package/dist/common/src/utils/serialization.d.ts +6 -6
- package/dist/common/src/utils/transforms.d.ts +18 -18
- package/dist/common/src/utils/validation.d.ts +30 -30
- package/dist/common/src/webhook-response.d.ts +7 -7
- package/dist/index.js +1 -1
- package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
- package/dist/typescript-client/src/api.manager.d.ts +14 -14
- package/dist/typescript-client/src/backend-function.manager.d.ts +13 -13
- package/dist/typescript-client/src/collection-reference.d.ts +53 -53
- package/dist/typescript-client/src/collection-reference.factory.d.ts +16 -16
- package/dist/typescript-client/src/data.manager.d.ts +166 -166
- package/dist/typescript-client/src/destruct.manager.d.ts +12 -12
- package/dist/typescript-client/src/document-identity.service.d.ts +12 -12
- package/dist/typescript-client/src/document-reference.d.ts +100 -100
- package/dist/typescript-client/src/document-reference.factory.d.ts +9 -9
- package/dist/typescript-client/src/document-store.d.ts +11 -11
- package/dist/typescript-client/src/graphql-client.d.ts +12 -12
- package/dist/typescript-client/src/graphql-client.factory.d.ts +9 -9
- package/dist/typescript-client/src/index.d.ts +7 -7
- package/dist/typescript-client/src/mutation/mutation-sender.d.ts +11 -11
- package/dist/typescript-client/src/mutation/mutation.spec.d.ts +1 -1
- package/dist/typescript-client/src/named-query.manager.d.ts +13 -13
- package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +71 -71
- package/dist/typescript-client/src/query/query-builder.factory.d.ts +67 -60
- package/dist/typescript-client/src/query/query-subscription.manager.d.ts +59 -59
- package/dist/typescript-client/src/query/query-subscription.manager.spec.d.ts +1 -1
- package/dist/typescript-client/src/query/query.spec.d.ts +1 -1
- package/dist/typescript-client/src/query/query.types.d.ts +14 -14
- package/dist/typescript-client/src/rpc.manager.d.ts +30 -30
- package/dist/typescript-client/src/socket.manager.d.ts +27 -27
- package/dist/typescript-client/src/squid.d.ts +173 -173
- package/dist/typescript-client/src/state/action.applier.d.ts +7 -7
- package/dist/typescript-client/src/state/actions.d.ts +29 -29
- package/dist/typescript-client/src/state/path_trie.d.ts +27 -27
- package/dist/typescript-client/src/state/state.service.d.ts +22 -22
- package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
- package/dist/typescript-client/src/testing/fake-rpc.manager.d.ts +20 -20
- package/dist/typescript-client/src/testing/fake-socket.manager.d.ts +9 -9
- package/dist/typescript-client/src/testing/setup-tests.d.ts +1 -1
- package/dist/typescript-client/src/testing/squid-env-setup.d.ts +79 -79
- package/dist/typescript-client/src/types.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import { ClientId, ClientRequestId, Query, QuerySubscriptionId, SquidDocId, SquidDocument } from '@squidcloud/common';
|
|
2
|
-
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
|
3
|
-
import { DestructManager } from '../destruct.manager';
|
|
4
|
-
import DocumentIdentityService from '../document-identity.service';
|
|
5
|
-
import { DocumentStore } from '../document-store';
|
|
6
|
-
import { RpcManager } from '../rpc.manager';
|
|
7
|
-
import { Alias, JoinCondition } from './query.types';
|
|
8
|
-
export declare class QuerySubscriptionManager {
|
|
9
|
-
private readonly rpcManager;
|
|
10
|
-
private readonly clientId;
|
|
11
|
-
private readonly documentStore;
|
|
12
|
-
private readonly destructManager;
|
|
13
|
-
private readonly documentIdentityService;
|
|
14
|
-
readonly safeToSendQueriesToServer: BehaviorSubject<boolean>;
|
|
15
|
-
onOrphanDocuments: Subject<string[]>;
|
|
16
|
-
private readonly ongoingQueries;
|
|
17
|
-
private readonly inflightQueriesCount;
|
|
18
|
-
/**
|
|
19
|
-
* The two maps below maintain the relation between document ids we know about locally to clientRequestIds (queries).
|
|
20
|
-
* This relation is used for determining whether a document can be safely removed.
|
|
21
|
-
*/
|
|
22
|
-
private readonly clientRequestIdToLocalDocuments;
|
|
23
|
-
private readonly localDocumentToClientRequestIds;
|
|
24
|
-
private readonly queryMappingManager;
|
|
25
|
-
constructor(rpcManager: RpcManager, clientId: ClientId, documentStore: DocumentStore, destructManager: DestructManager, documentIdentityService: DocumentIdentityService);
|
|
26
|
-
hasOngoingQuery(clientRequestId: ClientRequestId): boolean;
|
|
27
|
-
getQuery(clientRequestId: ClientRequestId): Query;
|
|
28
|
-
setGotResponseFromServer(clientRequestId: ClientRequestId): void;
|
|
29
|
-
findQueriesForDocument(doc: SquidDocument, squidDocId: SquidDocId): Array<QuerySubscriptionId>;
|
|
30
|
-
/**
|
|
31
|
-
* Given the new document's properties, finds all the queries that should be notified with the new properties and
|
|
32
|
-
* updates the internal mappings (squidDocId --> client request Ids and, clientRequestId --> squidDocIds).
|
|
33
|
-
* Returns an array with all the previous and current client request ids (basically all the client request ids that
|
|
34
|
-
* will need to be notified due to the change of properties).
|
|
35
|
-
*/
|
|
36
|
-
setClientRequestIdsForLocalDoc(squidDocId: SquidDocId, properties: SquidDocument | undefined): Array<ClientRequestId>;
|
|
37
|
-
errorOutAllQueries(squidDocId: SquidDocId, err: any): void;
|
|
38
|
-
notifyAllSubscriptions(clientRequestIds: ClientRequestId[]): void;
|
|
39
|
-
processQuery(query: Query, rootAlias: Alias, joins: Record<string, Query>, joinConditions: Record<Alias, JoinCondition>, subscribe: boolean): Observable<Array<Record<Alias, SquidDocument | undefined>>>;
|
|
40
|
-
hasOngoingQueryForDocId(squidDocId: string): boolean;
|
|
41
|
-
private removeClientRequestId;
|
|
42
|
-
waitForAllQueriesToFinish(): Promise<void>;
|
|
43
|
-
private registerQueryFinalizer;
|
|
44
|
-
/** Creates a graph of ongoing queries and returns the root of the graph. */
|
|
45
|
-
private createOngoingQueryGraph;
|
|
46
|
-
private collectAllObservables;
|
|
47
|
-
private joinResults;
|
|
48
|
-
private join;
|
|
49
|
-
private getOngoingQueriesBfs;
|
|
50
|
-
private updateOngoingQueryWithNewDataFromSupportingQuery;
|
|
51
|
-
private allOngoingQueriesGotServerResult;
|
|
52
|
-
private completeAllSupportedQueries;
|
|
53
|
-
private predestruct;
|
|
54
|
-
unsubscribe(): void;
|
|
55
|
-
hasSubscription(clientRequestId: ClientRequestId): boolean;
|
|
56
|
-
/** Sends the query request to the server and makes sure to unsubscribe once the subject completes. */
|
|
57
|
-
private sendQueryToServer;
|
|
58
|
-
private migrateDocIds;
|
|
59
|
-
}
|
|
1
|
+
import { ClientId, ClientRequestId, Query, QuerySubscriptionId, SquidDocId, SquidDocument } from '@squidcloud/common';
|
|
2
|
+
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
|
3
|
+
import { DestructManager } from '../destruct.manager';
|
|
4
|
+
import DocumentIdentityService from '../document-identity.service';
|
|
5
|
+
import { DocumentStore } from '../document-store';
|
|
6
|
+
import { RpcManager } from '../rpc.manager';
|
|
7
|
+
import { Alias, JoinCondition } from './query.types';
|
|
8
|
+
export declare class QuerySubscriptionManager {
|
|
9
|
+
private readonly rpcManager;
|
|
10
|
+
private readonly clientId;
|
|
11
|
+
private readonly documentStore;
|
|
12
|
+
private readonly destructManager;
|
|
13
|
+
private readonly documentIdentityService;
|
|
14
|
+
readonly safeToSendQueriesToServer: BehaviorSubject<boolean>;
|
|
15
|
+
onOrphanDocuments: Subject<string[]>;
|
|
16
|
+
private readonly ongoingQueries;
|
|
17
|
+
private readonly inflightQueriesCount;
|
|
18
|
+
/**
|
|
19
|
+
* The two maps below maintain the relation between document ids we know about locally to clientRequestIds (queries).
|
|
20
|
+
* This relation is used for determining whether a document can be safely removed.
|
|
21
|
+
*/
|
|
22
|
+
private readonly clientRequestIdToLocalDocuments;
|
|
23
|
+
private readonly localDocumentToClientRequestIds;
|
|
24
|
+
private readonly queryMappingManager;
|
|
25
|
+
constructor(rpcManager: RpcManager, clientId: ClientId, documentStore: DocumentStore, destructManager: DestructManager, documentIdentityService: DocumentIdentityService);
|
|
26
|
+
hasOngoingQuery(clientRequestId: ClientRequestId): boolean;
|
|
27
|
+
getQuery(clientRequestId: ClientRequestId): Query;
|
|
28
|
+
setGotResponseFromServer(clientRequestId: ClientRequestId): void;
|
|
29
|
+
findQueriesForDocument(doc: SquidDocument, squidDocId: SquidDocId): Array<QuerySubscriptionId>;
|
|
30
|
+
/**
|
|
31
|
+
* Given the new document's properties, finds all the queries that should be notified with the new properties and
|
|
32
|
+
* updates the internal mappings (squidDocId --> client request Ids and, clientRequestId --> squidDocIds).
|
|
33
|
+
* Returns an array with all the previous and current client request ids (basically all the client request ids that
|
|
34
|
+
* will need to be notified due to the change of properties).
|
|
35
|
+
*/
|
|
36
|
+
setClientRequestIdsForLocalDoc(squidDocId: SquidDocId, properties: SquidDocument | undefined): Array<ClientRequestId>;
|
|
37
|
+
errorOutAllQueries(squidDocId: SquidDocId, err: any): void;
|
|
38
|
+
notifyAllSubscriptions(clientRequestIds: ClientRequestId[]): void;
|
|
39
|
+
processQuery(query: Query, rootAlias: Alias, joins: Record<string, Query>, joinConditions: Record<Alias, JoinCondition>, subscribe: boolean): Observable<Array<Record<Alias, SquidDocument | undefined>>>;
|
|
40
|
+
hasOngoingQueryForDocId(squidDocId: string): boolean;
|
|
41
|
+
private removeClientRequestId;
|
|
42
|
+
waitForAllQueriesToFinish(): Promise<void>;
|
|
43
|
+
private registerQueryFinalizer;
|
|
44
|
+
/** Creates a graph of ongoing queries and returns the root of the graph. */
|
|
45
|
+
private createOngoingQueryGraph;
|
|
46
|
+
private collectAllObservables;
|
|
47
|
+
private joinResults;
|
|
48
|
+
private join;
|
|
49
|
+
private getOngoingQueriesBfs;
|
|
50
|
+
private updateOngoingQueryWithNewDataFromSupportingQuery;
|
|
51
|
+
private allOngoingQueriesGotServerResult;
|
|
52
|
+
private completeAllSupportedQueries;
|
|
53
|
+
private predestruct;
|
|
54
|
+
unsubscribe(): void;
|
|
55
|
+
hasSubscription(clientRequestId: ClientRequestId): boolean;
|
|
56
|
+
/** Sends the query request to the server and makes sure to unsubscribe once the subject completes. */
|
|
57
|
+
private sendQueryToServer;
|
|
58
|
+
private migrateDocIds;
|
|
59
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { FieldName } from '@squidcloud/common';
|
|
2
|
-
/**
|
|
3
|
-
* An alias for a join result. This is used to disambiguate fields in the result.
|
|
4
|
-
*/
|
|
5
|
-
export type Alias = string;
|
|
6
|
-
/**
|
|
7
|
-
* A join condition.
|
|
8
|
-
* The join conditions defines the alias for the left side of the join and the field names to join on.
|
|
9
|
-
*/
|
|
10
|
-
export interface JoinCondition {
|
|
11
|
-
leftAlias: Alias;
|
|
12
|
-
leftFieldName: FieldName;
|
|
13
|
-
rightFieldName: FieldName;
|
|
14
|
-
}
|
|
1
|
+
import { FieldName } from '@squidcloud/common';
|
|
2
|
+
/**
|
|
3
|
+
* An alias for a join result. This is used to disambiguate fields in the result.
|
|
4
|
+
*/
|
|
5
|
+
export type Alias = string;
|
|
6
|
+
/**
|
|
7
|
+
* A join condition.
|
|
8
|
+
* The join conditions defines the alias for the left side of the join and the field names to join on.
|
|
9
|
+
*/
|
|
10
|
+
export interface JoinCondition {
|
|
11
|
+
leftAlias: Alias;
|
|
12
|
+
leftFieldName: FieldName;
|
|
13
|
+
rightFieldName: FieldName;
|
|
14
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { ApiKey } from '@squidcloud/common';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { DestructManager } from './destruct.manager';
|
|
4
|
-
import { SocketManagerInterface } from './socket.manager';
|
|
5
|
-
export declare class RpcManager {
|
|
6
|
-
private readonly rpcEndpoint;
|
|
7
|
-
private readonly socketManager;
|
|
8
|
-
private readonly headers;
|
|
9
|
-
private readonly staticHeaders;
|
|
10
|
-
private readonly onGoingRpcsCounter;
|
|
11
|
-
private readonly authIdTokenSet;
|
|
12
|
-
private readonly authIdTokenObservableSubject;
|
|
13
|
-
private shouldWaitForAuth;
|
|
14
|
-
constructor(rpcEndpoint: string, socketManager: SocketManagerInterface, destructManager: DestructManager, headers?: Record<string, string>, apiKey?: ApiKey);
|
|
15
|
-
awaitAllSettled(): Promise<void>;
|
|
16
|
-
setAuthIdToken(idToken: string | undefined | Promise<string | undefined> | Observable<string | undefined>): void;
|
|
17
|
-
setStaticHeader(key: string, value: string): void;
|
|
18
|
-
deleteStaticHeader(key: string): void;
|
|
19
|
-
getEndpoint(): string;
|
|
20
|
-
getStaticHeaders(): Record<string, string>;
|
|
21
|
-
post<T>(path: string, message: any): Promise<T>;
|
|
22
|
-
}
|
|
23
|
-
export declare class RpcError extends Error {
|
|
24
|
-
readonly statusCode: number;
|
|
25
|
-
readonly statusText: string;
|
|
26
|
-
readonly headers: Headers;
|
|
27
|
-
readonly url: string;
|
|
28
|
-
readonly body: string;
|
|
29
|
-
constructor(statusCode: number, statusText: string, headers: Headers, url: string, body: string);
|
|
30
|
-
}
|
|
1
|
+
import { ApiKey } from '@squidcloud/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { DestructManager } from './destruct.manager';
|
|
4
|
+
import { SocketManagerInterface } from './socket.manager';
|
|
5
|
+
export declare class RpcManager {
|
|
6
|
+
private readonly rpcEndpoint;
|
|
7
|
+
private readonly socketManager;
|
|
8
|
+
private readonly headers;
|
|
9
|
+
private readonly staticHeaders;
|
|
10
|
+
private readonly onGoingRpcsCounter;
|
|
11
|
+
private readonly authIdTokenSet;
|
|
12
|
+
private readonly authIdTokenObservableSubject;
|
|
13
|
+
private shouldWaitForAuth;
|
|
14
|
+
constructor(rpcEndpoint: string, socketManager: SocketManagerInterface, destructManager: DestructManager, headers?: Record<string, string>, apiKey?: ApiKey);
|
|
15
|
+
awaitAllSettled(): Promise<void>;
|
|
16
|
+
setAuthIdToken(idToken: string | undefined | Promise<string | undefined> | Observable<string | undefined>): void;
|
|
17
|
+
setStaticHeader(key: string, value: string): void;
|
|
18
|
+
deleteStaticHeader(key: string): void;
|
|
19
|
+
getEndpoint(): string;
|
|
20
|
+
getStaticHeaders(): Record<string, string>;
|
|
21
|
+
post<T>(path: string, message: any): Promise<T>;
|
|
22
|
+
}
|
|
23
|
+
export declare class RpcError extends Error {
|
|
24
|
+
readonly statusCode: number;
|
|
25
|
+
readonly statusText: string;
|
|
26
|
+
readonly headers: Headers;
|
|
27
|
+
readonly url: string;
|
|
28
|
+
readonly body: string;
|
|
29
|
+
constructor(statusCode: number, statusText: string, headers: Headers, url: string, body: string);
|
|
30
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { ClientId, MessageFromClient, MessageToClient } from '@squidcloud/common';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { DestructManager } from './destruct.manager';
|
|
4
|
-
export interface SocketManagerInterface {
|
|
5
|
-
observeNotifications(): Observable<MessageToClient>;
|
|
6
|
-
observeConnectionReady(): Observable<boolean>;
|
|
7
|
-
sendMessage(message: MessageFromClient): void;
|
|
8
|
-
}
|
|
9
|
-
export declare class SocketManager implements SocketManagerInterface {
|
|
10
|
-
private readonly clientId;
|
|
11
|
-
private readonly socketIoEndpoint;
|
|
12
|
-
private readonly messageNotificationWrapper;
|
|
13
|
-
private readonly destructManager;
|
|
14
|
-
private readonly webSocketObserver;
|
|
15
|
-
private readonly allMessagesObserver;
|
|
16
|
-
private readonly connectionReady;
|
|
17
|
-
private readonly seenMessageIds;
|
|
18
|
-
private socket;
|
|
19
|
-
private firstConnection;
|
|
20
|
-
constructor(clientId: ClientId, socketIoEndpoint: string, messageNotificationWrapper: (fn: () => any) => any, destructManager: DestructManager, extraHeaders?: Record<string, string>);
|
|
21
|
-
observeNotifications(): Observable<MessageToClient>;
|
|
22
|
-
observeConnectionReady(): Observable<boolean>;
|
|
23
|
-
sendMessage(message: MessageFromClient): void;
|
|
24
|
-
private connect;
|
|
25
|
-
private setupMessageAcknowledgments;
|
|
26
|
-
private destruct;
|
|
27
|
-
}
|
|
1
|
+
import { ClientId, MessageFromClient, MessageToClient } from '@squidcloud/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { DestructManager } from './destruct.manager';
|
|
4
|
+
export interface SocketManagerInterface {
|
|
5
|
+
observeNotifications(): Observable<MessageToClient>;
|
|
6
|
+
observeConnectionReady(): Observable<boolean>;
|
|
7
|
+
sendMessage(message: MessageFromClient): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class SocketManager implements SocketManagerInterface {
|
|
10
|
+
private readonly clientId;
|
|
11
|
+
private readonly socketIoEndpoint;
|
|
12
|
+
private readonly messageNotificationWrapper;
|
|
13
|
+
private readonly destructManager;
|
|
14
|
+
private readonly webSocketObserver;
|
|
15
|
+
private readonly allMessagesObserver;
|
|
16
|
+
private readonly connectionReady;
|
|
17
|
+
private readonly seenMessageIds;
|
|
18
|
+
private socket;
|
|
19
|
+
private firstConnection;
|
|
20
|
+
constructor(clientId: ClientId, socketIoEndpoint: string, messageNotificationWrapper: (fn: () => any) => any, destructManager: DestructManager, extraHeaders?: Record<string, string>);
|
|
21
|
+
observeNotifications(): Observable<MessageToClient>;
|
|
22
|
+
observeConnectionReady(): Observable<boolean>;
|
|
23
|
+
sendMessage(message: MessageFromClient): void;
|
|
24
|
+
private connect;
|
|
25
|
+
private setupMessageAcknowledgments;
|
|
26
|
+
private destruct;
|
|
27
|
+
}
|
|
@@ -1,173 +1,173 @@
|
|
|
1
|
-
import { ApiEndpointId, ApiKey, AppId, CollectionName, DocumentData, IntegrationId, QueryName, SupportedSquidRegion } from '@squidcloud/common';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { CollectionReference } from './collection-reference';
|
|
4
|
-
import { GraphQLClient } from './graphql-client';
|
|
5
|
-
import { TransactionId } from './types';
|
|
6
|
-
/** The different options that can be used to initialize a Squid instance. */
|
|
7
|
-
export interface SquidOptions {
|
|
8
|
-
/**
|
|
9
|
-
* A function that can be used to wrap messages coming from Squid to the application. This is useful for
|
|
10
|
-
* different frameworks that need to wrap messages in order to detect changes (like Angular).
|
|
11
|
-
* @param fn The function to wrap.
|
|
12
|
-
*/
|
|
13
|
-
messageNotificationWrapper?: (fn: () => any) => any;
|
|
14
|
-
/**
|
|
15
|
-
* The application ID that is used to identify the application in Squid. The ID can be found in the Squid Cloud
|
|
16
|
-
* Console.
|
|
17
|
-
*/
|
|
18
|
-
appId: AppId;
|
|
19
|
-
/**
|
|
20
|
-
* The application API key, using the API key can be used to bypass security rules and other restrictions.
|
|
21
|
-
* The API key can be found in the Squid Cloud Console.
|
|
22
|
-
*/
|
|
23
|
-
apiKey?: ApiKey;
|
|
24
|
-
/**
|
|
25
|
-
* The region that the application is running in. This is used to determine the URL of the Squid Cloud API.
|
|
26
|
-
*/
|
|
27
|
-
region: SupportedSquidRegion;
|
|
28
|
-
/**
|
|
29
|
-
* A list of API endpoints that can be used for overriding the default API endpoints for the different integrations.
|
|
30
|
-
* This is useful for APIs that have multiple base urls hosted in different regions.
|
|
31
|
-
*/
|
|
32
|
-
apiServerUrlOverrideMapping?: Record<IntegrationId, string>;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* The main entry point to the Squid Client SDK.
|
|
36
|
-
*
|
|
37
|
-
* The Squid class provides a comprehensive array of functionality for accessing the different integrations, executing
|
|
38
|
-
* backend functions, managing data, and more. Upon instantiating the Squid class, you will have access to all of these
|
|
39
|
-
* capabilities.
|
|
40
|
-
*/
|
|
41
|
-
export declare class Squid {
|
|
42
|
-
private readonly socketManager;
|
|
43
|
-
private readonly clientId;
|
|
44
|
-
private readonly rpcManager;
|
|
45
|
-
private readonly dataManager;
|
|
46
|
-
private readonly documentReferenceFactory;
|
|
47
|
-
private readonly documentStore;
|
|
48
|
-
private readonly lockManager;
|
|
49
|
-
private readonly querySubscriptionManager;
|
|
50
|
-
private readonly queryBuilderFactory;
|
|
51
|
-
private readonly joinQueryBuilderFactory;
|
|
52
|
-
private readonly collectionReferenceFactory;
|
|
53
|
-
private readonly backendFunctionManager;
|
|
54
|
-
private readonly namedQueryManager;
|
|
55
|
-
private readonly apiManager;
|
|
56
|
-
private readonly graphqlClientFactory;
|
|
57
|
-
private readonly destructManager;
|
|
58
|
-
private readonly documentIdentityService;
|
|
59
|
-
private static readonly squidInstancesMap;
|
|
60
|
-
/**
|
|
61
|
-
* Creates a new instance of Squid with the given options.
|
|
62
|
-
*
|
|
63
|
-
* @param options The options for initializing the Squid instance.
|
|
64
|
-
*/
|
|
65
|
-
constructor(options: SquidOptions);
|
|
66
|
-
/**
|
|
67
|
-
* Returns the global Squid instance with the given options, creating a new instance if one with the same options
|
|
68
|
-
* does not exist.
|
|
69
|
-
*
|
|
70
|
-
* @param options The options for initializing the Squid instance.
|
|
71
|
-
* @returns A global Squid instance with the given options.
|
|
72
|
-
*/
|
|
73
|
-
static getInstance(options: SquidOptions): Squid;
|
|
74
|
-
/**
|
|
75
|
-
* Returns all the global Squid instances.
|
|
76
|
-
*
|
|
77
|
-
* @returns An array of all the global Squid instances.
|
|
78
|
-
*/
|
|
79
|
-
static getInstances(): Array<Squid>;
|
|
80
|
-
/**
|
|
81
|
-
* Sets the auth id token (OpenId) that will be sent to the server and will be used for providing the `auth` object
|
|
82
|
-
* to the security rules.
|
|
83
|
-
*
|
|
84
|
-
* @param idToken The auth id token, a promise that resolves with the id token, or an observable that emits the id
|
|
85
|
-
* token. Undefined if the user is not authenticated.
|
|
86
|
-
* @returns void
|
|
87
|
-
*/
|
|
88
|
-
setAuthIdToken: (idToken: string | undefined | Promise<string | undefined> | Observable<string | undefined>) => void;
|
|
89
|
-
/**
|
|
90
|
-
* Returns a reference to the collection in the provided integration.
|
|
91
|
-
*
|
|
92
|
-
* If the integrationId is not provided, the `built_in_db` integration id will be used.
|
|
93
|
-
*
|
|
94
|
-
* For more information on the CollectionReference object, please refer to the
|
|
95
|
-
* documentation at {@link https://docs.squid.cloud/docs/client-sdk/collection-reference}.
|
|
96
|
-
*
|
|
97
|
-
* @param collectionName The name of the collection.
|
|
98
|
-
* @param integrationId The id of the integration, default to `built_in_db`.
|
|
99
|
-
* @returns A reference to the collection in the provided integration.
|
|
100
|
-
* @typeParam T The type of the documents in the collection.
|
|
101
|
-
*/
|
|
102
|
-
collection: <T extends DocumentData>(collectionName: CollectionName, integrationId?: IntegrationId) => CollectionReference<T>;
|
|
103
|
-
/**
|
|
104
|
-
* Runs the given callback as an atomic change. All the mutations that are executed using the provided transactionId
|
|
105
|
-
* will be atomic. Note that mutations for different integrations will not be atomic.
|
|
106
|
-
*
|
|
107
|
-
* For more information about transactions in Squid, please refer to the
|
|
108
|
-
* documentation at {@link https://docs.squid.cloud/docs/client-sdk/transactions}.
|
|
109
|
-
*
|
|
110
|
-
* @param fn The callback to run as an atomic change. The function receives a transactionId that should be used for
|
|
111
|
-
* all the mutations that should be atomic. The function should return a promise.
|
|
112
|
-
*
|
|
113
|
-
* @returns A promise that resolves when the transactions is committed on the server.
|
|
114
|
-
*/
|
|
115
|
-
runInTransaction: (fn: (transactionId: TransactionId) => Promise<void>) => Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* Executes the given backend function with the given parameters and returns a promise with the result.
|
|
118
|
-
*
|
|
119
|
-
* For more information about backend functions in Squid, please refer to the
|
|
120
|
-
* documentation at {@link https://docs.squid.cloud/docs/backend/executables}.
|
|
121
|
-
*
|
|
122
|
-
* @param functionName The name of the function to execute on the server.
|
|
123
|
-
* @param params The parameters to pass to the function.
|
|
124
|
-
* @returns A promise that resolves with the result of the function.
|
|
125
|
-
* @typeParam T The type of the result of the function.
|
|
126
|
-
*/
|
|
127
|
-
executeFunction: <T = any>(functionName: string, ...params: any[]) => Promise<T>;
|
|
128
|
-
/**
|
|
129
|
-
* Executes the given named query with the given parameters and returns a promise with the result.
|
|
130
|
-
*
|
|
131
|
-
* For more information about named queries in Squid, please refer to the
|
|
132
|
-
* documentation at {@link https://docs.squid.cloud/docs/backend/named-queries}.
|
|
133
|
-
*
|
|
134
|
-
* @param integrationId The id of the integration that the named query is defined with.
|
|
135
|
-
* @param queryName The name of the named query.
|
|
136
|
-
* @param params The parameters to pass to the named query.
|
|
137
|
-
* @returns A promise that resolves with the result of the named query.
|
|
138
|
-
* @typeParam T The type of the result of the named query.
|
|
139
|
-
*/
|
|
140
|
-
executeNamedQuery: <T = any>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>) => Promise<T>;
|
|
141
|
-
/**
|
|
142
|
-
* Invokes the given HTTP API (defined by the integration ID and the endpoint ID) with the given request parameters
|
|
143
|
-
* and returns a promise with the response. The structure of the request and the response is defined in the
|
|
144
|
-
* integration's schema page.
|
|
145
|
-
*
|
|
146
|
-
* For more information about API integrations in Squid, please refer to the
|
|
147
|
-
* documentation at {@link https://docs.squid.cloud/docs/integrations/httpapi}.
|
|
148
|
-
*
|
|
149
|
-
* @param integrationId The id of the integration that the API is defined with.
|
|
150
|
-
* @param endpointId The id of the endpoint in the API integration.
|
|
151
|
-
* @param request The request parameters to pass to the API.
|
|
152
|
-
* @returns A promise that resolves with the response of the API.
|
|
153
|
-
* @typeParam T The type of the response of the API.
|
|
154
|
-
*/
|
|
155
|
-
callApi: <T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>) => Promise<T>;
|
|
156
|
-
/**
|
|
157
|
-
* Returns a GraphQL client for the given integration. The GraphQL client can be used to execute GraphQL queries and
|
|
158
|
-
* mutations. For more information about GraphQL in Squid, please refer to the documentation at
|
|
159
|
-
* {@link https://docs.squid.cloud/docs/integrations/graphql}.
|
|
160
|
-
*
|
|
161
|
-
* @param integrationId The id of the integration that the GraphQL API is defined with.
|
|
162
|
-
* @returns A GraphQL client for the given integration.
|
|
163
|
-
*/
|
|
164
|
-
graphql: (integrationId: IntegrationId) => GraphQLClient;
|
|
165
|
-
/**
|
|
166
|
-
* Destructs the Squid Client. Unsubscribes from all ongoing queries or requests, and clears the local data.
|
|
167
|
-
* After invoking this method, the Squid client will not be usable.
|
|
168
|
-
*
|
|
169
|
-
* @returns A promise that resolves when the destruct process is complete.
|
|
170
|
-
*/
|
|
171
|
-
destruct: () => Promise<void>;
|
|
172
|
-
private validateNotDestructed;
|
|
173
|
-
}
|
|
1
|
+
import { ApiEndpointId, ApiKey, AppId, CollectionName, DocumentData, IntegrationId, QueryName, SupportedSquidRegion } from '@squidcloud/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { CollectionReference } from './collection-reference';
|
|
4
|
+
import { GraphQLClient } from './graphql-client';
|
|
5
|
+
import { TransactionId } from './types';
|
|
6
|
+
/** The different options that can be used to initialize a Squid instance. */
|
|
7
|
+
export interface SquidOptions {
|
|
8
|
+
/**
|
|
9
|
+
* A function that can be used to wrap messages coming from Squid to the application. This is useful for
|
|
10
|
+
* different frameworks that need to wrap messages in order to detect changes (like Angular).
|
|
11
|
+
* @param fn The function to wrap.
|
|
12
|
+
*/
|
|
13
|
+
messageNotificationWrapper?: (fn: () => any) => any;
|
|
14
|
+
/**
|
|
15
|
+
* The application ID that is used to identify the application in Squid. The ID can be found in the Squid Cloud
|
|
16
|
+
* Console.
|
|
17
|
+
*/
|
|
18
|
+
appId: AppId;
|
|
19
|
+
/**
|
|
20
|
+
* The application API key, using the API key can be used to bypass security rules and other restrictions.
|
|
21
|
+
* The API key can be found in the Squid Cloud Console.
|
|
22
|
+
*/
|
|
23
|
+
apiKey?: ApiKey;
|
|
24
|
+
/**
|
|
25
|
+
* The region that the application is running in. This is used to determine the URL of the Squid Cloud API.
|
|
26
|
+
*/
|
|
27
|
+
region: SupportedSquidRegion;
|
|
28
|
+
/**
|
|
29
|
+
* A list of API endpoints that can be used for overriding the default API endpoints for the different integrations.
|
|
30
|
+
* This is useful for APIs that have multiple base urls hosted in different regions.
|
|
31
|
+
*/
|
|
32
|
+
apiServerUrlOverrideMapping?: Record<IntegrationId, string>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The main entry point to the Squid Client SDK.
|
|
36
|
+
*
|
|
37
|
+
* The Squid class provides a comprehensive array of functionality for accessing the different integrations, executing
|
|
38
|
+
* backend functions, managing data, and more. Upon instantiating the Squid class, you will have access to all of these
|
|
39
|
+
* capabilities.
|
|
40
|
+
*/
|
|
41
|
+
export declare class Squid {
|
|
42
|
+
private readonly socketManager;
|
|
43
|
+
private readonly clientId;
|
|
44
|
+
private readonly rpcManager;
|
|
45
|
+
private readonly dataManager;
|
|
46
|
+
private readonly documentReferenceFactory;
|
|
47
|
+
private readonly documentStore;
|
|
48
|
+
private readonly lockManager;
|
|
49
|
+
private readonly querySubscriptionManager;
|
|
50
|
+
private readonly queryBuilderFactory;
|
|
51
|
+
private readonly joinQueryBuilderFactory;
|
|
52
|
+
private readonly collectionReferenceFactory;
|
|
53
|
+
private readonly backendFunctionManager;
|
|
54
|
+
private readonly namedQueryManager;
|
|
55
|
+
private readonly apiManager;
|
|
56
|
+
private readonly graphqlClientFactory;
|
|
57
|
+
private readonly destructManager;
|
|
58
|
+
private readonly documentIdentityService;
|
|
59
|
+
private static readonly squidInstancesMap;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new instance of Squid with the given options.
|
|
62
|
+
*
|
|
63
|
+
* @param options The options for initializing the Squid instance.
|
|
64
|
+
*/
|
|
65
|
+
constructor(options: SquidOptions);
|
|
66
|
+
/**
|
|
67
|
+
* Returns the global Squid instance with the given options, creating a new instance if one with the same options
|
|
68
|
+
* does not exist.
|
|
69
|
+
*
|
|
70
|
+
* @param options The options for initializing the Squid instance.
|
|
71
|
+
* @returns A global Squid instance with the given options.
|
|
72
|
+
*/
|
|
73
|
+
static getInstance(options: SquidOptions): Squid;
|
|
74
|
+
/**
|
|
75
|
+
* Returns all the global Squid instances.
|
|
76
|
+
*
|
|
77
|
+
* @returns An array of all the global Squid instances.
|
|
78
|
+
*/
|
|
79
|
+
static getInstances(): Array<Squid>;
|
|
80
|
+
/**
|
|
81
|
+
* Sets the auth id token (OpenId) that will be sent to the server and will be used for providing the `auth` object
|
|
82
|
+
* to the security rules.
|
|
83
|
+
*
|
|
84
|
+
* @param idToken The auth id token, a promise that resolves with the id token, or an observable that emits the id
|
|
85
|
+
* token. Undefined if the user is not authenticated.
|
|
86
|
+
* @returns void
|
|
87
|
+
*/
|
|
88
|
+
setAuthIdToken: (idToken: string | undefined | Promise<string | undefined> | Observable<string | undefined>) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Returns a reference to the collection in the provided integration.
|
|
91
|
+
*
|
|
92
|
+
* If the integrationId is not provided, the `built_in_db` integration id will be used.
|
|
93
|
+
*
|
|
94
|
+
* For more information on the CollectionReference object, please refer to the
|
|
95
|
+
* documentation at {@link https://docs.squid.cloud/docs/client-sdk/collection-reference}.
|
|
96
|
+
*
|
|
97
|
+
* @param collectionName The name of the collection.
|
|
98
|
+
* @param integrationId The id of the integration, default to `built_in_db`.
|
|
99
|
+
* @returns A reference to the collection in the provided integration.
|
|
100
|
+
* @typeParam T The type of the documents in the collection.
|
|
101
|
+
*/
|
|
102
|
+
collection: <T extends DocumentData>(collectionName: CollectionName, integrationId?: IntegrationId) => CollectionReference<T>;
|
|
103
|
+
/**
|
|
104
|
+
* Runs the given callback as an atomic change. All the mutations that are executed using the provided transactionId
|
|
105
|
+
* will be atomic. Note that mutations for different integrations will not be atomic.
|
|
106
|
+
*
|
|
107
|
+
* For more information about transactions in Squid, please refer to the
|
|
108
|
+
* documentation at {@link https://docs.squid.cloud/docs/client-sdk/transactions}.
|
|
109
|
+
*
|
|
110
|
+
* @param fn The callback to run as an atomic change. The function receives a transactionId that should be used for
|
|
111
|
+
* all the mutations that should be atomic. The function should return a promise.
|
|
112
|
+
*
|
|
113
|
+
* @returns A promise that resolves when the transactions is committed on the server.
|
|
114
|
+
*/
|
|
115
|
+
runInTransaction: (fn: (transactionId: TransactionId) => Promise<void>) => Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Executes the given backend function with the given parameters and returns a promise with the result.
|
|
118
|
+
*
|
|
119
|
+
* For more information about backend functions in Squid, please refer to the
|
|
120
|
+
* documentation at {@link https://docs.squid.cloud/docs/backend/executables}.
|
|
121
|
+
*
|
|
122
|
+
* @param functionName The name of the function to execute on the server.
|
|
123
|
+
* @param params The parameters to pass to the function.
|
|
124
|
+
* @returns A promise that resolves with the result of the function.
|
|
125
|
+
* @typeParam T The type of the result of the function.
|
|
126
|
+
*/
|
|
127
|
+
executeFunction: <T = any>(functionName: string, ...params: any[]) => Promise<T>;
|
|
128
|
+
/**
|
|
129
|
+
* Executes the given named query with the given parameters and returns a promise with the result.
|
|
130
|
+
*
|
|
131
|
+
* For more information about named queries in Squid, please refer to the
|
|
132
|
+
* documentation at {@link https://docs.squid.cloud/docs/backend/named-queries}.
|
|
133
|
+
*
|
|
134
|
+
* @param integrationId The id of the integration that the named query is defined with.
|
|
135
|
+
* @param queryName The name of the named query.
|
|
136
|
+
* @param params The parameters to pass to the named query.
|
|
137
|
+
* @returns A promise that resolves with the result of the named query.
|
|
138
|
+
* @typeParam T The type of the result of the named query.
|
|
139
|
+
*/
|
|
140
|
+
executeNamedQuery: <T = any>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>) => Promise<T>;
|
|
141
|
+
/**
|
|
142
|
+
* Invokes the given HTTP API (defined by the integration ID and the endpoint ID) with the given request parameters
|
|
143
|
+
* and returns a promise with the response. The structure of the request and the response is defined in the
|
|
144
|
+
* integration's schema page.
|
|
145
|
+
*
|
|
146
|
+
* For more information about API integrations in Squid, please refer to the
|
|
147
|
+
* documentation at {@link https://docs.squid.cloud/docs/integrations/httpapi}.
|
|
148
|
+
*
|
|
149
|
+
* @param integrationId The id of the integration that the API is defined with.
|
|
150
|
+
* @param endpointId The id of the endpoint in the API integration.
|
|
151
|
+
* @param request The request parameters to pass to the API.
|
|
152
|
+
* @returns A promise that resolves with the response of the API.
|
|
153
|
+
* @typeParam T The type of the response of the API.
|
|
154
|
+
*/
|
|
155
|
+
callApi: <T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>) => Promise<T>;
|
|
156
|
+
/**
|
|
157
|
+
* Returns a GraphQL client for the given integration. The GraphQL client can be used to execute GraphQL queries and
|
|
158
|
+
* mutations. For more information about GraphQL in Squid, please refer to the documentation at
|
|
159
|
+
* {@link https://docs.squid.cloud/docs/integrations/graphql}.
|
|
160
|
+
*
|
|
161
|
+
* @param integrationId The id of the integration that the GraphQL API is defined with.
|
|
162
|
+
* @returns A GraphQL client for the given integration.
|
|
163
|
+
*/
|
|
164
|
+
graphql: (integrationId: IntegrationId) => GraphQLClient;
|
|
165
|
+
/**
|
|
166
|
+
* Destructs the Squid Client. Unsubscribes from all ongoing queries or requests, and clears the local data.
|
|
167
|
+
* After invoking this method, the Squid client will not be usable.
|
|
168
|
+
*
|
|
169
|
+
* @returns A promise that resolves when the destruct process is complete.
|
|
170
|
+
*/
|
|
171
|
+
destruct: () => Promise<void>;
|
|
172
|
+
private validateNotDestructed;
|
|
173
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BaseAction } from './actions';
|
|
2
|
-
export type StateLeafNode = string | boolean | number | null | undefined | object | Array<StateLeafNode> | State;
|
|
3
|
-
export type State = {
|
|
4
|
-
[key: string]: StateLeafNode;
|
|
5
|
-
};
|
|
6
|
-
export declare function apply(state: State, action: BaseAction): State;
|
|
7
|
-
export declare function isStateObject(state: StateLeafNode): state is State;
|
|
1
|
+
import { BaseAction } from './actions';
|
|
2
|
+
export type StateLeafNode = string | boolean | number | null | undefined | object | Array<StateLeafNode> | State;
|
|
3
|
+
export type State = {
|
|
4
|
+
[key: string]: StateLeafNode;
|
|
5
|
+
};
|
|
6
|
+
export declare function apply(state: State, action: BaseAction): State;
|
|
7
|
+
export declare function isStateObject(state: StateLeafNode): state is State;
|