@squidcloud/client 1.0.72 → 1.0.74
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/communication.types.d.ts +0 -10
- package/dist/common/src/context.types.d.ts +12 -4
- package/dist/common/src/heartbeat.types.d.ts +1 -0
- package/dist/common/src/index.d.ts +1 -1
- package/dist/common/src/integrations/auth.types.d.ts +19 -2
- package/dist/common/src/integrations/index.d.ts +6 -2
- package/dist/common/src/mutation.context.d.ts +3 -1
- package/dist/common/src/query/query-context.d.ts +6 -1
- package/dist/common/src/query/simple-query-builder.d.ts +5 -25
- package/dist/common/src/query.schemas.d.ts +3 -1
- package/dist/common/src/query.types.d.ts +7 -1
- package/dist/common/src/utils/serialization.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.LICENSE.txt +0 -17
- package/dist/typescript-client/src/ai-assistant-client.d.ts +115 -14
- package/dist/typescript-client/src/ai-client.factory.d.ts +1 -3
- package/dist/typescript-client/src/client-id.service.d.ts +2 -1
- package/dist/typescript-client/src/connection-details.d.ts +23 -0
- package/dist/typescript-client/src/destruct.manager.d.ts +1 -1
- package/dist/typescript-client/src/mutation/mutation-sender.d.ts +1 -3
- package/dist/typescript-client/src/named-query.manager.d.ts +1 -3
- package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +2 -2
- package/dist/typescript-client/src/query/query-builder.factory.d.ts +6 -0
- package/dist/typescript-client/src/query/query-subscription.manager.d.ts +76 -5
- package/dist/typescript-client/src/squid.d.ts +22 -0
- package/package.json +1 -1
- package/dist/common/src/auth.types.d.ts +0 -1
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*! *****************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
|
|
16
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
17
|
-
|
|
18
1
|
/**
|
|
19
2
|
* @license
|
|
20
3
|
* Lodash <https://lodash.com/>
|
|
@@ -1,66 +1,167 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntegrationId, OpenAiModelName } from '@squidcloud/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { ClientIdService } from './client-id.service';
|
|
4
3
|
import { RpcManager } from './rpc.manager';
|
|
5
4
|
import { SocketManager } from './socket.manager';
|
|
6
5
|
export declare class AiAssistantClient {
|
|
7
|
-
private readonly clientIdService;
|
|
8
6
|
private readonly rpcManager;
|
|
9
7
|
private readonly socketManager;
|
|
10
8
|
private readonly integrationId;
|
|
11
9
|
private readonly ongoingChatRequests;
|
|
12
|
-
constructor(
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
constructor(rpcManager: RpcManager, socketManager: SocketManager, integrationId: IntegrationId);
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves a profile reference for the provided id. A profile reference
|
|
13
|
+
* can be used to create and update profiles, add instructions and context
|
|
14
|
+
* and start chats.
|
|
15
|
+
*
|
|
16
|
+
* @param id - The id of the profile.
|
|
17
|
+
* @returns The profile reference.
|
|
18
|
+
*/
|
|
19
|
+
profile(id: string): AiAssistantProfileReference;
|
|
20
|
+
/**
|
|
21
|
+
* Sends a prompt to the specified profile id.
|
|
22
|
+
*
|
|
23
|
+
* @param profileId - The profile id.
|
|
24
|
+
* @param prompt - The prompt.
|
|
25
|
+
* @returns An observable that emits when a new response token is received. The emitted value is the entire response
|
|
26
|
+
* that has been received so far.
|
|
27
|
+
*/
|
|
15
28
|
chat(profileId: string, prompt: string): Observable<string>;
|
|
16
29
|
private handleChatResponse;
|
|
17
30
|
}
|
|
18
|
-
declare class
|
|
31
|
+
declare class AiAssistantProfileReference {
|
|
19
32
|
private readonly client;
|
|
20
33
|
private readonly integrationId;
|
|
21
34
|
private readonly profileId;
|
|
22
35
|
constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string);
|
|
36
|
+
/**
|
|
37
|
+
* Sends a prompt to the current profile.
|
|
38
|
+
*
|
|
39
|
+
* @param prompt - The prompt.
|
|
40
|
+
* @returns An observable that emits when a new response token is received. The emitted value is the entire response
|
|
41
|
+
* that has been received so far.
|
|
42
|
+
*/
|
|
23
43
|
chat(prompt: string): Observable<string>;
|
|
24
|
-
|
|
25
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves a context reference for the current profile. A context reference can be used to add a new context entry
|
|
46
|
+
* to the profile, or update/delete an existing entry context.
|
|
47
|
+
*
|
|
48
|
+
* @param id - The id of the context entry. If no id is passed, an id will be
|
|
49
|
+
* generated and the reference will point to a new context entry.
|
|
50
|
+
* @returns The context reference.
|
|
51
|
+
*/
|
|
52
|
+
context(id?: string): AiAssistantContextReference;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves an instruction reference for the current profile. An instruction reference can be used to add a new
|
|
55
|
+
* instruction entry to the profile, or update/delete an existing instruction entry.
|
|
56
|
+
*
|
|
57
|
+
* @param id - The id of the instruction entry. If no id is passed, an id will be
|
|
58
|
+
* generated and the reference will point to a new instruction entry.
|
|
59
|
+
* @returns The instruction reference.
|
|
60
|
+
*/
|
|
61
|
+
instruction(id?: string): AiAssistantInstructionReference;
|
|
62
|
+
/**
|
|
63
|
+
* Adds a new profile to the assistant. This will result in an error if a profile already exists with the same id.
|
|
64
|
+
*
|
|
65
|
+
* @param data An object containing options for creating the profile.
|
|
66
|
+
* @param data.modelName - The name of the OpenAI model (`gpt-3.5 or `gpt-4`).
|
|
67
|
+
* @returns A promise that resolves when the profile is successfully created.
|
|
68
|
+
*/
|
|
26
69
|
insert(data: {
|
|
27
70
|
modelName: OpenAiModelName;
|
|
28
|
-
strictContext: boolean;
|
|
29
71
|
}): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Updates an existing assistant profile. This will result in an error if a profile has not yet been created for the
|
|
74
|
+
* current profile id.
|
|
75
|
+
*
|
|
76
|
+
* @param data An object containing options for updating the profile.
|
|
77
|
+
* @param data.modelName - The name of the OpenAI model (`gpt-3.5 or `gpt-4`).
|
|
78
|
+
* @returns A promise that resolves when the profile is successfully updated.
|
|
79
|
+
*/
|
|
30
80
|
update(data: {
|
|
31
|
-
modelName
|
|
32
|
-
strictContext: boolean;
|
|
81
|
+
modelName: OpenAiModelName;
|
|
33
82
|
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Deletes an existing assistant profile. This will result in an error if a profile has not yet been created for the
|
|
85
|
+
* current profile id.
|
|
86
|
+
*
|
|
87
|
+
* @returns A promise that resolves when the profile is successfully deleted.
|
|
88
|
+
*/
|
|
34
89
|
delete(): Promise<void>;
|
|
35
90
|
}
|
|
36
|
-
declare class
|
|
91
|
+
declare class AiAssistantContextReference {
|
|
37
92
|
private readonly client;
|
|
38
93
|
private readonly integrationId;
|
|
39
94
|
private readonly profileId;
|
|
40
95
|
private readonly id;
|
|
41
96
|
constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string, id?: string);
|
|
97
|
+
/**
|
|
98
|
+
* Adds a new context entry to the assistant profile. This will result in an error if an entry already exists with
|
|
99
|
+
* the same id.
|
|
100
|
+
*
|
|
101
|
+
* @param data An object containing options for creating the entry.
|
|
102
|
+
* @param data.title - The title of the entry.
|
|
103
|
+
* @param data.context - The context data.
|
|
104
|
+
* @returns A promise that resolves when the context is successfully created.
|
|
105
|
+
*/
|
|
42
106
|
insert(data: {
|
|
43
107
|
title: string;
|
|
44
108
|
context: string;
|
|
45
109
|
}): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Updates an existing context entry on the assistant profile. This will result in an error if an entry has not yet
|
|
112
|
+
* been created for the current context id.
|
|
113
|
+
*
|
|
114
|
+
* @param data An object containing options for updated the entry.
|
|
115
|
+
* @param data.title - The title of the entry.
|
|
116
|
+
* @param data.context - The context data.
|
|
117
|
+
* @returns A promise that resolves when the context is successfully updated.
|
|
118
|
+
*/
|
|
46
119
|
update(data: {
|
|
47
120
|
title?: string;
|
|
48
121
|
context?: string;
|
|
49
122
|
}): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Deletes an existing context entry on the assistant profile. This will result in an error if an entry has not yet
|
|
125
|
+
* been created for the current context id.
|
|
126
|
+
*
|
|
127
|
+
* @returns A promise that resolves when the context is successfully deleted.
|
|
128
|
+
*/
|
|
50
129
|
delete(): Promise<void>;
|
|
51
130
|
}
|
|
52
|
-
declare class
|
|
131
|
+
declare class AiAssistantInstructionReference {
|
|
53
132
|
private readonly client;
|
|
54
133
|
private readonly integrationId;
|
|
55
134
|
private readonly profileId;
|
|
56
135
|
private readonly id;
|
|
57
136
|
constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string, id?: string);
|
|
137
|
+
/**
|
|
138
|
+
* Adds a new instruction entry to the assistant profile. This will result in an error if an entry already exists with
|
|
139
|
+
* the same id.
|
|
140
|
+
*
|
|
141
|
+
* @param data An object containing options for creating the entry.
|
|
142
|
+
* @param data.instruction - The instruction data.
|
|
143
|
+
* @returns A promise that resolves when the instruction is successfully created.
|
|
144
|
+
*/
|
|
58
145
|
insert(data: {
|
|
59
146
|
instruction: string;
|
|
60
147
|
}): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Updates an existing instruction entry on the assistant profile. This will result in an error if an entry has not
|
|
150
|
+
* yet been created for the current instruction id.
|
|
151
|
+
*
|
|
152
|
+
* @param data An object containing options for updated the entry.
|
|
153
|
+
* @param data.instruction - The instruction data.
|
|
154
|
+
* @returns A promise that resolves when the instruction is successfully updated.
|
|
155
|
+
*/
|
|
61
156
|
update(data: {
|
|
62
157
|
instruction: string;
|
|
63
158
|
}): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* Deletes an existing instruction entry on the assistant profile. This will result in an error if an entry has not
|
|
161
|
+
* yet been created for the current instruction id.
|
|
162
|
+
*
|
|
163
|
+
* @returns A promise that resolves when the instruction is successfully deleted.
|
|
164
|
+
*/
|
|
64
165
|
delete(): Promise<void>;
|
|
65
166
|
}
|
|
66
167
|
export {};
|
|
@@ -2,12 +2,10 @@ import { IntegrationId } from '@squidcloud/common';
|
|
|
2
2
|
import { AiAssistantClient } from './ai-assistant-client';
|
|
3
3
|
import { RpcManager } from './rpc.manager';
|
|
4
4
|
import { SocketManager } from './socket.manager';
|
|
5
|
-
import { ClientIdService } from './client-id.service';
|
|
6
5
|
export declare class AiClientFactory {
|
|
7
|
-
private readonly clientIdService;
|
|
8
6
|
private readonly rpcManager;
|
|
9
7
|
private readonly socketManager;
|
|
10
8
|
private readonly assistantsMap;
|
|
11
|
-
constructor(
|
|
9
|
+
constructor(rpcManager: RpcManager, socketManager: SocketManager);
|
|
12
10
|
getAssistant(integrationId: IntegrationId): AiAssistantClient;
|
|
13
11
|
}
|
|
@@ -12,8 +12,9 @@ import { DestructManager } from './destruct.manager';
|
|
|
12
12
|
export declare class ClientIdService {
|
|
13
13
|
private readonly destructManager;
|
|
14
14
|
private readonly clientTooOldSubject;
|
|
15
|
-
private
|
|
15
|
+
private readonly clientIdSubject;
|
|
16
16
|
constructor(destructManager: DestructManager);
|
|
17
|
+
observeClientId(): Observable<ClientId>;
|
|
17
18
|
observeClientTooOld(): Observable<void>;
|
|
18
19
|
/** there was a long-term disconnection of the socket */
|
|
19
20
|
notifyClientTooOld(): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ClientId } from '@squidcloud/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
/**
|
|
4
|
+
* Provides information about the connection to the Squid Server.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConnectionDetails {
|
|
7
|
+
private readonly clientIdService;
|
|
8
|
+
private readonly socketManager;
|
|
9
|
+
private isConnected;
|
|
10
|
+
/** Whether the Squid Client SDK is currently connected to the Squid Server. */
|
|
11
|
+
get connected(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* A unique client ID that is assigned to the client. This client ID is also available to the different backend
|
|
14
|
+
* function in the context object.
|
|
15
|
+
* Note: The client ID may change after a long disconnect.
|
|
16
|
+
*/
|
|
17
|
+
get clientId(): ClientId;
|
|
18
|
+
/**
|
|
19
|
+
* Returns an observable that emits true when the client is connected to the server and false when the client is
|
|
20
|
+
* disconnected from the server.
|
|
21
|
+
*/
|
|
22
|
+
observeConnected(): Observable<boolean>;
|
|
23
|
+
}
|
|
@@ -5,7 +5,7 @@ export declare class DestructManager {
|
|
|
5
5
|
private readonly destructors;
|
|
6
6
|
private readonly isDestructedSubject;
|
|
7
7
|
get isDestructing(): boolean;
|
|
8
|
-
|
|
8
|
+
observeIsDestructing(): Observable<void>;
|
|
9
9
|
onPreDestruct(fn: DestructorFn): void;
|
|
10
10
|
onDestruct(fn: DestructorFn): void;
|
|
11
11
|
destruct(): Promise<void>;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { IntegrationId, LockManager, MutateResponse, Mutation } from '@squidcloud/common';
|
|
2
2
|
import { QuerySubscriptionManager } from '../query/query-subscription.manager';
|
|
3
3
|
import { RpcManager } from '../rpc.manager';
|
|
4
|
-
import { ClientIdService } from '../client-id.service';
|
|
5
4
|
export declare class MutationSender {
|
|
6
|
-
private readonly clientIdService;
|
|
7
5
|
private readonly rpcManager;
|
|
8
6
|
private readonly lockManager;
|
|
9
7
|
private readonly querySubscriptionManager;
|
|
10
|
-
constructor(
|
|
8
|
+
constructor(rpcManager: RpcManager, lockManager: LockManager, querySubscriptionManager: QuerySubscriptionManager);
|
|
11
9
|
sendMutations(mutations: Array<Mutation>, integrationId: IntegrationId): Promise<MutateResponse>;
|
|
12
10
|
}
|
|
@@ -2,13 +2,11 @@ import { IntegrationId, QueryName } from '@squidcloud/common';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RpcManager } from './rpc.manager';
|
|
4
4
|
import { SocketManager } from './socket.manager';
|
|
5
|
-
import { ClientIdService } from './client-id.service';
|
|
6
5
|
export declare class NamedQueryManager {
|
|
7
|
-
private readonly clientIdService;
|
|
8
6
|
private readonly rpcManager;
|
|
9
7
|
private readonly socketManager;
|
|
10
8
|
private readonly ongoingNamedQueryExecutions;
|
|
11
|
-
constructor(
|
|
9
|
+
constructor(rpcManager: RpcManager, socketManager: SocketManager);
|
|
12
10
|
executeNamedQueryAndSubscribe<T>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>): Observable<T>;
|
|
13
11
|
private handleNamedQueryResponse;
|
|
14
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DocumentData, FieldName, Operator, PrimitiveFieldType } from '@squidcloud/common';
|
|
1
|
+
import { BaseQueryBuilderInterface, DocumentData, FieldName, Operator, PrimitiveFieldType } from '@squidcloud/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { DocumentReference } from '../document-reference';
|
|
4
4
|
import { Alias } from './query.types';
|
|
@@ -7,7 +7,7 @@ import { Alias } from './query.types';
|
|
|
7
7
|
* To learn more about join queries, see
|
|
8
8
|
* {@link https://docs.squid.cloud/docs/client-sdk/queries#joining-data-across-collections-and-integrations}.
|
|
9
9
|
*/
|
|
10
|
-
export declare class JoinQueryBuilder<DocumentType extends DocumentData, MyAlias extends Alias, ReturnType extends Record<MyAlias, DocumentReference<DocumentType> | undefined>> {
|
|
10
|
+
export declare class JoinQueryBuilder<DocumentType extends DocumentData, MyAlias extends Alias, ReturnType extends Record<MyAlias, DocumentReference<DocumentType> | undefined>> extends BaseQueryBuilderInterface<ReturnType> {
|
|
11
11
|
private readonly collectionName;
|
|
12
12
|
private readonly integrationId;
|
|
13
13
|
private readonly querySubscriptionManager;
|
|
@@ -44,11 +44,17 @@ export declare class QueryBuilder<DocumentType extends DocumentData> extends Sim
|
|
|
44
44
|
private readonly documentReferenceFactory;
|
|
45
45
|
private readonly queryBuilderFactory;
|
|
46
46
|
private readonly documentIdentityService;
|
|
47
|
+
private forceFetchFromServer;
|
|
47
48
|
getSortOrder(): FieldSort<DocumentType>[];
|
|
48
49
|
/**
|
|
49
50
|
* @inheritDoc
|
|
50
51
|
*/
|
|
51
52
|
snapshot(): Promise<Array<DocumentReference<DocumentType>>>;
|
|
53
|
+
/**
|
|
54
|
+
* Forces the query to return data from the server even if there is a query that already returned the requested
|
|
55
|
+
* result.
|
|
56
|
+
*/
|
|
57
|
+
setForceFetchFromServer(): this;
|
|
52
58
|
/**
|
|
53
59
|
* @inheritDoc
|
|
54
60
|
*/
|
|
@@ -12,9 +12,24 @@ export declare class QuerySubscriptionManager {
|
|
|
12
12
|
private readonly documentStore;
|
|
13
13
|
private readonly destructManager;
|
|
14
14
|
private readonly documentIdentityService;
|
|
15
|
+
/**
|
|
16
|
+
* As long as there are mutations in flight we do not want to send queries because it causes race conditions,
|
|
17
|
+
* preventing parallel queries and mutations simplifies the mental model.
|
|
18
|
+
*/
|
|
15
19
|
readonly safeToSendQueriesToServer: BehaviorSubject<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* An observable used by the data manager, the query subscription manager (this class) identifies when a document no
|
|
22
|
+
* longer has queries that it is part of their result, such document is considered orphan. The data manager will mark
|
|
23
|
+
* as orphan.
|
|
24
|
+
*/
|
|
16
25
|
onOrphanDocuments: Subject<string[]>;
|
|
26
|
+
/** All the currently running queries with their full state. */
|
|
17
27
|
private readonly ongoingQueries;
|
|
28
|
+
/**
|
|
29
|
+
* The number of queries that are currently in-flight (about to be sent to the server or sent but did not get a
|
|
30
|
+
* response yet). This is used by the data manager to prevent it from sending mutations while there are in-flight
|
|
31
|
+
* queries.
|
|
32
|
+
*/
|
|
18
33
|
private readonly inflightQueriesCount;
|
|
19
34
|
/**
|
|
20
35
|
* The two maps below maintain the relation between document ids we know about locally to clientRequestIds (queries).
|
|
@@ -22,11 +37,31 @@ export declare class QuerySubscriptionManager {
|
|
|
22
37
|
*/
|
|
23
38
|
private readonly clientRequestIdToLocalDocuments;
|
|
24
39
|
private readonly localDocumentToClientRequestIds;
|
|
40
|
+
/**
|
|
41
|
+
* A data structure for mapping queries to allow reverse queries search (given a document, find all the matching
|
|
42
|
+
* queries)
|
|
43
|
+
*/
|
|
25
44
|
private readonly queryMappingManager;
|
|
26
45
|
constructor(rpcManager: RpcManager, clientIdService: ClientIdService, documentStore: DocumentStore, destructManager: DestructManager, documentIdentityService: DocumentIdentityService);
|
|
46
|
+
/**
|
|
47
|
+
* Returns true if the client knows about this clientRequestId. It may happen that it will return false in the case
|
|
48
|
+
* that the client unsubscribed from a query but the server sent a mutation update for this clientRequestId.
|
|
49
|
+
*/
|
|
27
50
|
hasOngoingQuery(clientRequestId: ClientRequestId): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the query associated with the given clientRequestId. Throws error if the clientRequestId is not known.
|
|
53
|
+
*/
|
|
28
54
|
getQuery(clientRequestId: ClientRequestId): Query;
|
|
29
|
-
|
|
55
|
+
/**
|
|
56
|
+
* A query receives updates from two different sources:
|
|
57
|
+
* 1 - An initial snapshot from the server or from a parent query
|
|
58
|
+
* 2 - Incremental updates from the server (or from a parent query before the query is registered)
|
|
59
|
+
*
|
|
60
|
+
* If an incremental update is received before the snapshot was received, we cannot process it for this query.
|
|
61
|
+
* This boolean indicates whether the initial snapshot was received.
|
|
62
|
+
*/
|
|
63
|
+
setGotInitialResult(clientRequestId: ClientRequestId): void;
|
|
64
|
+
/** Given a document, returns all the queries that should be notified with the new document properties. */
|
|
30
65
|
findQueriesForDocument(doc: SquidDocument, squidDocId: SquidDocId): Array<QuerySubscriptionId>;
|
|
31
66
|
/**
|
|
32
67
|
* Given the new document's properties, finds all the queries that should be notified with the new properties and
|
|
@@ -35,12 +70,33 @@ export declare class QuerySubscriptionManager {
|
|
|
35
70
|
* will need to be notified due to the change of properties).
|
|
36
71
|
*/
|
|
37
72
|
setClientRequestIdsForLocalDoc(squidDocId: SquidDocId, properties: SquidDocument | undefined): Array<ClientRequestId>;
|
|
73
|
+
/**
|
|
74
|
+
* Due to an error when syncing a document, all the queries that are subscribed to this document should be notified
|
|
75
|
+
* and error out.
|
|
76
|
+
*/
|
|
38
77
|
errorOutAllQueries(squidDocId: SquidDocId, err: any): void;
|
|
78
|
+
/** Notifies to all the given queries (identified by their clientRequestId) with the updated query result. */
|
|
39
79
|
notifyAllSubscriptions(clientRequestIds: ClientRequestId[]): void;
|
|
40
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Given an ongoing query, search for candidate ongoing queries that can serve as a parent.
|
|
82
|
+
* If there is a parent query, the result of that query can be used for serving the current query.
|
|
83
|
+
* We will still register the current query on the server, but we do not need to run the query, apply security rules,
|
|
84
|
+
* etc.
|
|
85
|
+
*/
|
|
86
|
+
private findValidParentQuery;
|
|
87
|
+
processQuery(query: Query, rootAlias: Alias, joins: Record<string, Query>, joinConditions: Record<Alias, JoinCondition>, subscribe: boolean, forceFetchFromServer: boolean): Observable<Array<Record<Alias, SquidDocument | undefined>>>;
|
|
88
|
+
/**
|
|
89
|
+
* Returns whether the given document ID has a query that has this document ID as a result.
|
|
90
|
+
* A document without a query is considered "un-tracked".
|
|
91
|
+
*/
|
|
41
92
|
hasOngoingQueryForDocId(squidDocId: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Removes a query from the mapping and updates the orphan documents as needed.
|
|
95
|
+
*/
|
|
42
96
|
private removeClientRequestIdMapping;
|
|
97
|
+
/** Will resolve once all the in-flight queries are done. */
|
|
43
98
|
waitForAllQueriesToFinish(): Promise<void>;
|
|
99
|
+
/** Register logic for cleaning up the query when it is unsubscribed. */
|
|
44
100
|
private registerQueryFinalizer;
|
|
45
101
|
/** Creates a graph of ongoing queries and returns the root of the graph. */
|
|
46
102
|
private createOngoingQueryGraph;
|
|
@@ -49,16 +105,31 @@ export declare class QuerySubscriptionManager {
|
|
|
49
105
|
private join;
|
|
50
106
|
private getOngoingQueriesBfs;
|
|
51
107
|
private updateOngoingQueryWithNewDataFromSupportingQuery;
|
|
52
|
-
private
|
|
108
|
+
private allOngoingQueriesGotInitialResult;
|
|
53
109
|
private completeAllSupportedQueries;
|
|
54
110
|
private predestruct;
|
|
55
111
|
unsubscribe(): void;
|
|
56
112
|
hasSubscription(clientRequestId: ClientRequestId): boolean;
|
|
57
113
|
/** Sends the query request to the server and makes sure to unsubscribe once the subject completes. */
|
|
58
|
-
private
|
|
114
|
+
private sendQueryToServerOrUseParentQuery;
|
|
59
115
|
/**
|
|
60
|
-
*
|
|
116
|
+
* Uses the parent query as the source of data for the given ongoing query until the ongoing query is registered on
|
|
117
|
+
* the server. It prevents the parent query from being unsubscribed until the query is registered on the server and
|
|
118
|
+
* the first snapshot is received from the parent query.
|
|
119
|
+
* 1 - Prevents the parent query from being unsubscribed
|
|
120
|
+
* 2 - Connects the results of the parent query to the result of the current ongoing query
|
|
121
|
+
* 3 - Registers the query on the server
|
|
61
122
|
*/
|
|
123
|
+
private useParentOngoingQuery;
|
|
124
|
+
/**
|
|
125
|
+
* Sends the /query request to the server. It:
|
|
126
|
+
* 1 - Waits for when it is safe to send a query to the server (no in-flight mutations)
|
|
127
|
+
* 2 - Increments the number of inflightQueriesCount to prevent parallel mutations
|
|
128
|
+
* 3 - Handles errors
|
|
129
|
+
* 4 - Marks the query as registered
|
|
130
|
+
*/
|
|
131
|
+
private sendQueryToServer;
|
|
132
|
+
/** naive way to refresh queries/subscriptions when we have a new client id */
|
|
62
133
|
private refreshOngoingQueries;
|
|
63
134
|
private migrateDocIds;
|
|
64
135
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ApiEndpointId, ApiKey, AppId, CollectionName, DocumentData, EnvironmentId, IntegrationId, QueryName, SquidDeveloperId, SupportedSquidRegion } from '@squidcloud/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
+
import { AiAssistantClient } from './ai-assistant-client';
|
|
3
4
|
import { CollectionReference } from './collection-reference';
|
|
4
5
|
import { DistributedLock } from './distributed-lock.manager';
|
|
5
6
|
import { GraphQLClient } from './graphql-client';
|
|
6
7
|
import { TransactionId } from './types';
|
|
8
|
+
import { ConnectionDetails } from './connection-details';
|
|
7
9
|
/** The different options that can be used to initialize a Squid instance. */
|
|
8
10
|
export interface SquidOptions {
|
|
9
11
|
/**
|
|
@@ -68,6 +70,7 @@ export declare class Squid {
|
|
|
68
70
|
private readonly authManager;
|
|
69
71
|
private readonly clientIdService;
|
|
70
72
|
private readonly aiClientFactory;
|
|
73
|
+
private readonly _connectionDetails;
|
|
71
74
|
private static readonly squidInstancesMap;
|
|
72
75
|
/**
|
|
73
76
|
* Creates a new instance of Squid with the given options.
|
|
@@ -175,6 +178,23 @@ export declare class Squid {
|
|
|
175
178
|
* @returns A GraphQL client for the given integration.
|
|
176
179
|
*/
|
|
177
180
|
graphql: (integrationId: IntegrationId) => GraphQLClient;
|
|
181
|
+
/**
|
|
182
|
+
* Returns a set of AI specific clients. Currently, the only supported client is the AI Assistant, which is accessed
|
|
183
|
+
* through the `assistant`.
|
|
184
|
+
*
|
|
185
|
+
* @returns A set of AI specific clients.
|
|
186
|
+
*/
|
|
187
|
+
ai: () => {
|
|
188
|
+
/**
|
|
189
|
+
* Returns an AI Assistant client for the given integration. The AI Assistant client can be used to build and chat
|
|
190
|
+
* with custom AI profiles. For more information about the AI Assistant in Squid, please refer to the documentation
|
|
191
|
+
* at {@link https://docs.squid.cloud/docs/integrations/ai/ai-assistant}.
|
|
192
|
+
*
|
|
193
|
+
* @param integrationId The id of the AI Assistant integration.
|
|
194
|
+
* @returns An AI Assistant client.
|
|
195
|
+
*/
|
|
196
|
+
assistant: (integrationId: IntegrationId) => AiAssistantClient;
|
|
197
|
+
};
|
|
178
198
|
/**
|
|
179
199
|
* Returns a distributed lock for the given mutex. The lock can be used to synchronize access to a shared resource.
|
|
180
200
|
* The lock will be released when the release method on the returned object is invoked or whenever the connection
|
|
@@ -192,5 +212,7 @@ export declare class Squid {
|
|
|
192
212
|
* @returns A promise that resolves when the destruct process is complete.
|
|
193
213
|
*/
|
|
194
214
|
destruct: () => Promise<void>;
|
|
215
|
+
/** Provides information about the connection to the Squid Server. */
|
|
216
|
+
connectionDetails: () => ConnectionDetails;
|
|
195
217
|
private validateNotDestructed;
|
|
196
218
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|